@rongcloud/plugin-rtc 5.36.1-nctest-alpha.3 → 5.38.0-alpha.1
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/dist/index.cjs.js +1 -3
- package/dist/index.d.ts +95 -36
- package/dist/index.esm.js +2 -2
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ConversationType as e,RCConnectionStatus as t,VersionManage as r}from"@nexconn/engine";import"@nexconn/chat";const i=e=>"string"==typeof e,n=e=>"boolean"==typeof e,s=e=>"number"==typeof e&&!Number.isNaN(e),o=e=>-1!==Object.prototype.toString.call(e).indexOf("Array"),a=e=>i(e)&&e.length>0,c=e=>"[object Object]"===Object.prototype.toString.call(e),l=e=>"function"==typeof e,d=e=>void 0===e||"[object Undefined]"===Object.prototype.toString.call(e),u=e=>i(e)&&/https?:\/\//.test(e);var _;!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"}(_||(_={}));const h={[_.STRING]:a,[_.ONLY_STRING]:i,[_.NUMBER]:s,[_.BOOLEAN]:e=>"boolean"==typeof e,[_.OBJECT]:c,[_.ARRAY]:o,[_.CALLBACK]:e=>{let t=!0;return c(e)||(t=!1),(e=e||{}).onSuccess&&!l(e.onSuccess)&&(t=!1),e.onError&&!l(e.onError)&&(t=!1),t}};class p extends Error{constructor(e){super(e),this.name="RCAssertError"}}const f=(e,t,r,i=!1)=>{if(!g(e,t,r,i))throw new p(`'${e}' is invalid: ${JSON.stringify(t)}`)},g=(e,t,r,i=!1)=>{r=h[r]||r;const n=i?r(t):d(t)||null==t||r(t);return n||null===console||void 0===console||console.error(`'${e}' is invalid: ${JSON.stringify(t)}`),n};class m{constructor(){Object.defineProperty(this,"_map",{enumerable:!0,configurable:!0,writable:!0,value:{}})}on(e,t,r){const i=this._map[e]||(this._map[e]=[]);i.some(e=>e.listener===t&&e.target===r)||i.push({listener:t,target:r})}once(e,t,r){const i=this._map[e]||(this._map[e]=[]);i.some(e=>e.listener===t&&e.target===r)||i.push({listener:t,target:r,once:!0})}off(e,t,r){let i=this._map[e];i&&(i=i.filter(e=>e.listener!==t||e.target!==r),i.length?this._map[e]=i:delete this._map[e])}emit(e,...t){const r=this._map[e];if(r)for(let e=0;e<r.length;e+=1){const{target:i,once:n,listener:s}=r[e];n&&(r.splice(e,1),e-=1);try{s.call(i,...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 R,E,T;!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT"}(R||(R={})),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"}(E||(E={})),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"}(T||(T={}));const I=(e,t,r)=>{const n=null==r?void 0:r.isReverse;c(e)&&(()=>{for(const r in e)t(e[r],r,e)})(),(o(e)||i(e))&&(()=>{if(n)for(let r=e.length-1;r>=0;r--)t(e[r],r);else for(let r=0,i=e.length;r<i;r++)t(e[r],r)})()};var S;function v(e,t,r,i){return new(r||(r=Promise))(function(n,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,a)}c((i=i.apply(e,t||[])).next())})}function O(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)}!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"}(S||(S={})),"function"==typeof SuppressedError&&SuppressedError;class b{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 C(e){const t=e.method||R.GET,r=e.timeout||6e4,{headers:i,query:n,body:s,onProgress:o}=e,a=((e,t)=>{if(e=e.replace(/\?$/,""),!t)return e;const r=Object.keys(t).map(e=>`${e}=${t[e]}`).filter(e=>!!e);return r.length?[e,r.join("&")].join("?"):e})(e.url,n),c=new XMLHttpRequest;if(c.open(t,a),i&&c.setRequestHeader)for(const e in i)c.setRequestHeader(e,i[e]);return function(e,t,r,i){return new b(n=>{e.onreadystatechange=()=>{4===e.readyState&&n({data:e.responseText,status:e.status,xhr:e})},e.onerror=()=>{n({status:e.status})},i&&(e.upload.onprogress=e=>i(e)),0!==t&&setTimeout(()=>{e.abort(),n({status:e.status})},t),e.send(r)},t=>{e.abort(),t({status:-1})})}(c,r,s,o)}class y{constructor(e,t,r){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=r}next(e){return v(this,void 0,void 0,function*(){return this.isOk?e(this.data):this.wipe()})}or(e){return v(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?L(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?L(void 0,this.msg):A(this.code,this.msg)}}const L=(e,t)=>new y(0,t||"success",e),A=(e,t,r)=>new y(e,t||`fail: ${e}`,r);var N,P,w;class D{constructor(e){N.add(this),P.set(this,void 0),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!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"===i?n.call(e,r):n?n.value=r:t.set(e,r)}(this,P,e,"f"),this._logger=e.logger}open(e){return v(this,void 0,void 0,function*(){return e=e.sort((e,t)=>t.weight-e.weight),O(this,N,"m",w).call(this,e,O(this,P,"f"))})}}P=new WeakMap,N=new WeakSet,w=function e(t,r){return v(this,void 0,void 0,function*(){if(0===t.length)return A(39005,"All addrs failed");const i=t.shift();let n=function(e,t){var r;if(!e)return"";const i="undefined"!=typeof window&&"https:"===(null===(r=null===window||void 0===window?void 0:window.location)||void 0===r?void 0:r.protocol);return/^https?:\/\//.test(e)?i?e.replace(/^https?:\/\//i,"https://"):e:t!==T.HTTP||i?`https://${e}`:`http://${e}`}(i.addr,i.protocol);n=`${n}/v3/message/get_stream.json?sdkVersion=5.36.1-nctest-alpha.3&platform=Websocket&messageUID=${r.msgUId}`,this._logger.info("L-req_stream_msg_content-O",`try open -> ${n}`);const s=yield this._openHandler(n,r);return s.or(i=>v(this,void 0,void 0,function*(){return-1===i?O(this,N,"m",e).call(this,t,r):s}))})};class U extends D{_openHandler(e,t){return v(this,void 0,void 0,function*(){const{resolve:r,promise:i}=(()=>{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}`),r(A(-1,"timeout"))},n.onreadystatechange=i=>{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);r(A(e.code,e.message))});r(L());let a=0;n.onprogress=e=>{const r=n.response.slice(a);a=n.response.length,t.onRawContent(r)},n.onerror=r=>{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}`),r(A(-1))},n.setRequestHeader("Content-Type","application/json;charset=UTF-8"),n.setRequestHeader("App-Key",t.appkey),n.setRequestHeader("Authorization",`Bearer ${t.token}`),n.send(),i})}}const k=!("undefined"==typeof uni||!(e=>{const t=["request","getSystemInfo"];for(let r=0,i=t.length;r<i;r++)if(!e[t[r]])return!1;return!0})(uni));let M=null;const x=e=>v(void 0,void 0,void 0,function*(){const t=yield B.getNetworkType();M({status:"online"===e.type,type:t})});const B={tag:"browser",httpReq:e=>C(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:k,createWebSocket:function(e,t){const r=new WebSocket(e,t);return r.binaryType="arraybuffer",Promise.resolve(L({id:Date.now(),onClose(e){r.onclose=t=>{const{code:r,reason:i}=t;e(r,i)}},onError(e){r.onerror=e},onMessage(e){r.onmessage=t=>{e(t.data)}},onOpen(e){r.onopen=e},send(e){r.send(e)},close(e,t){r.close()}}))},getNetworkType(){const{type:e,effectiveType:t}=navigator.connection||navigator.mozConnection||navigator.webkitConnection||{effectiveType:E.UNKONWN},r=e||t||E.UNKONWN;return Promise.resolve(r)},setNetworkStatusListener:function(e){M=e,"undefined"!=typeof window&&window&&(window.addEventListener("offline",x),window.addEventListener("online",x))},removeNetworkStatusListener:function(){"undefined"!=typeof window&&window&&(window.removeEventListener("offline",x),window.removeEventListener("online",x)),M=null},createSSEClient:e=>L(new U(e)),getApiVer:()=>{const{type:e,version:t}=B.runtimeInfo;return`|${e}|${t}`},get runtimeInfo(){const{userAgent:e}=navigator;let t,r;const i={IE:/rv:([\d.]+)\) like Gecko|MSIE ([\d.]+)/,Edge:/Edge\/([\d.]+)/,Firefox:/Firefox\/([\d.]+)/,Opera:/(?:OPERA|OPR).([\d.]+)/,WeChat:/MicroMessenger\/([\d.]+)/,QQBrowser:/QQBrowser\/([\d.]+)/,Chrome:/Chrome\/([\d.]+)/,Safari:/Version\/([\d.]+).*Safari/,iOSChrome:/Mobile\/([\d.]+).*Safari/};for(const n in i){if(!i.hasOwnProperty(n))continue;let s=e.match(i[n]);if(s){r=n,t=s[1]||s[2];break}}return{type:r||"Unknown",version:t||"Unknown"}}},V=B;var F,j,G,J;!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"}(F||(F={})),function(e){e[e.DISCONNECTED=0]="DISCONNECTED",e[e.CONNECTING=1]="CONNECTING",e[e.CONNECTED=2]="CONNECTED",e[e.SUSPENDED=3]="SUSPENDED"}(j||(j={})),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"}(G||(G={})),function(e){e.RTC="RTC",e.CallPlus="CallPlus"}(J||(J={}));class H{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,r){this._writer.writeLog(G.Debug,e,null!=t?t:"",r)}info(e,t,r){this._writer.writeLog(G.Info,e,null!=t?t:"",r)}warn(e,t,r){this._writer.writeLog(G.Warn,e,null!=t?t:"",r)}error(e,t,r){this._writer.writeLog(G.Error,e,null!=t?t:"",r)}createTraceId(){return""+ ++this._traceId}setOutputLevel(e){this._writer.setOutputLevel(e)}__statistics(e,t,r){this._writer.writeLog(G.STATISTICS,e,null!=t?t:"",r)}}const K={toCommon:e=>e,toNative:e=>e},q={[e.PRIVATE]:F.PRIVATE,[e.GROUP]:F.GROUP,[e.SYSTEM]:F.SYSTEM,[e.CHATROOM]:F.CUSTOM,[e.APP_PUBLIC_SERVICE]:F.RTC_ROOM,[e.RTC_ROOM]:F.RTC_ROOM},$={[F.PRIVATE]:e.PRIVATE,[F.GROUP]:e.GROUP,[F.SYSTEM]:e.SYSTEM,[F.CUSTOM]:e.CHATROOM,[F.RTC_ROOM]:e.APP_PUBLIC_SERVICE},Y={toCommon(e){var t;return null!==(t=q[e])&&void 0!==t?t:e},toNative(e){var t;return null!==(t=$[e])&&void 0!==t?t:e}},W={[t.CONNECTED]:j.CONNECTED,[t.CONNECTING]:j.CONNECTING,[t.DISCONNECTED]:j.DISCONNECTED,[t.SUSPENDED]:j.SUSPENDED},z={[j.DISCONNECTED]:t.DISCONNECTED,[j.CONNECTING]:t.CONNECTING,[j.CONNECTED]:t.CONNECTED,[j.SUSPENDED]:t.SUSPENDED},Q={toNative:e=>Object.assign({},e)},Z={errorCode:K,conversationType:Y,connectionStatus:{toCommon(e){var t;return null!==(t=W[e])&&void 0!==t?t:e},toNative(e){var t;return null!==(t=z[e])&&void 0!==t?t:e}},sendMsgOptions:Q,receivedMessage:{toCommon:e=>e},naviInfo:{toCommon(e){var t,r,i;return{voipCallInfo:null!==(t=e.voipCallInfo)&&void 0!==t?t:void 0,rtcAISwitch:e.rtcAISwitch,jwtToken:null!==(r=e.jwtToken)&&void 0!==r?r:e.jwt,logServer:e.logServer,dataCenter:null!==(i=e.dataCenter)&&void 0!==i?i:e.dc,openGzip:e.openGzip,ipType:e.ipType}}}};var X,ee,te,re;!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"}(X||(X={})),function(e){e[e.DISCONNECTED=0]="DISCONNECTED",e[e.CONNECTING=1]="CONNECTING",e[e.CONNECTED=2]="CONNECTED",e[e.SUSPENDED=3]="SUSPENDED"}(ee||(ee={})),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"}(te||(te={})),function(e){e.RTC="RTC",e.CallPlus="CallPlus"}(re||(re={}));const ie=0,ne=2,se=-1;var oe,ae,ce;!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"}(oe||(oe={})),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"}(ae||(ae={})),function(e){e.FAILED="fail",e.SUCCESSED="success",e.TIMEOUT="timeout",e.INFO="info"}(ce||(ce={}));let le=!0,de=!0;function ue(e,t,r){const i=e.match(t);return i&&i.length>=r&&parseInt(i[r],10)}function _e(e,t,r){if(!e.RTCPeerConnection)return;const i=e.RTCPeerConnection.prototype,n=i.addEventListener;i.addEventListener=function(e,i){if(e!==t)return n.apply(this,arguments);const s=e=>{const t=r(e);t&&(i.handleEvent?i.handleEvent(t):i(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(i,s),n.apply(this,[e,s])};const s=i.removeEventListener;i.removeEventListener=function(e,r){if(e!==t||!this._eventMap||!this._eventMap[t])return s.apply(this,arguments);if(!this._eventMap[t].has(r))return s.apply(this,arguments);const i=this._eventMap[t].get(r);return this._eventMap[t].delete(r),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,s.apply(this,[e,i])},Object.defineProperty(i,"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 he(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(le=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(le)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function ge(e,t){de&&console.warn(e+" is deprecated, please use "+t+" instead.")}function me(e){return"[object Object]"===Object.prototype.toString.call(e)}function Re(e){return me(e)?Object.keys(e).reduce(function(t,r){const i=me(e[r]),n=i?Re(e[r]):e[r],s=i&&!Object.keys(n).length;return void 0===n||s?t:Object.assign(t,{[r]:n})},{}):e}function Ee(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),Object.keys(t).forEach(i=>{i.endsWith("Id")?Ee(e,e.get(t[i]),r):i.endsWith("Ids")&&t[i].forEach(t=>{Ee(e,e.get(t),r)})}))}function Te(e,t,r){const i=r?"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(r=>{r.type===i&&r.trackId===t.id&&Ee(e,r,n)})}),n}const Ie=fe;function Se(e,t){const r=e&&e.navigator;if(!r.mediaDevices)return;const i=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach(r=>{if("require"===r||"advanced"===r||"mediaSource"===r)return;const i="object"==typeof e[r]?e[r]:{ideal:e[r]};void 0!==i.exact&&"number"==typeof i.exact&&(i.min=i.max=i.exact);const n=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==i.ideal){t.optional=t.optional||[];let e={};"number"==typeof i.ideal?(e[n("min",r)]=i.ideal,t.optional.push(e),e={},e[n("max",r)]=i.ideal,t.optional.push(e)):(e[n("",r)]=i.ideal,t.optional.push(e))}void 0!==i.exact&&"number"!=typeof i.exact?(t.mandatory=t.mandatory||{},t.mandatory[n("",r)]=i.exact):["min","max"].forEach(e=>{void 0!==i[e]&&(t.mandatory=t.mandatory||{},t.mandatory[n(e,r)]=i[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,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=i(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)&&(!r.mediaDevices.getSupportedConstraints||!r.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 r.mediaDevices.enumerateDevices().then(r=>{let o=(r=r.filter(e=>"videoinput"===e.kind)).find(e=>t.some(t=>e.label.toLowerCase().includes(t)));return!o&&r.length&&t.includes("back")&&(o=r[r.length-1]),o&&(e.video.deviceId=s.exact?{exact:o.deviceId}:{ideal:o.deviceId}),e.video=i(e.video),Ie("chrome: "+JSON.stringify(e)),n(e)})}e.video=i(e.video)}return Ie("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(r.getUserMedia=function(e,t,i){n(e,e=>{r.webkitGetUserMedia(e,t,e=>{i&&i(s(e))})})}.bind(r),r.mediaDevices.getUserMedia){const e=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.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 ve(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",r=>{let i;i=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(e=>e.track&&e.track.id===r.track.id):{track:r.track};const n=new Event("track");n.track=r.track,n.receiver=i,n.transceiver={receiver:i},n.streams=[t.stream],this.dispatchEvent(n)}),t.stream.getTracks().forEach(r=>{let i;i=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(e=>e.track&&e.track.id===r.id):{track:r};const n=new Event("track");n.track=r,n.receiver=i,n.transceiver={receiver:i},n.streams=[t.stream],this.dispatchEvent(n)})},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else _e(e,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e))}function be(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 r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,i){let n=r.apply(this,arguments);return n||(n=t(this,e),this._senders.push(n)),n};const i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){i.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}const r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],r.apply(this,[e]),e.getTracks().forEach(e=>{this._senders.push(t(this,e))})};const i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],i.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 Ce(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,r,i]=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 r={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach(t=>{r[t]=e.stat(t)}),t[r.id]=r}),t},s=function(e){return new Map(Object.keys(e).map(t=>[t,e[t]]))};if(arguments.length>=2){const i=function(e){r(s(n(e)))};return t.apply(this,[i,e])}return new Promise((e,r)=>{t.apply(this,[function(t){e(s(n(t)))},r])}).then(r,i)}}function ye(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 r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){const e=this;return this._pc.getStats().then(t=>Te(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}),_e(e,"track",e=>(e.receiver._pc=e.srcElement,e)),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then(t=>Te(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,r,i;return this.getSenders().forEach(r=>{r.track===e&&(t?i=!0:t=r)}),this.getReceivers().forEach(t=>(t.track===e&&(r?i=!0:r=t),t.track===e)),i||t&&r?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():r?r.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function Le(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,r){if(!r)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const i=t.apply(this,arguments);return this._shimmedLocalStreams[r.id]?-1===this._shimmedLocalStreams[r.id].indexOf(i)&&this._shimmedLocalStreams[r.id].push(i):this._shimmedLocalStreams[r.id]=[r,i],i};const r=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();r.apply(this,arguments);const i=this.getSenders().filter(e=>-1===t.indexOf(e));this._shimmedLocalStreams[e.id]=[e].concat(i)};const i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],i.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 r=this._shimmedLocalStreams[t].indexOf(e);-1!==r&&this._shimmedLocalStreams[t].splice(r,1),1===this._shimmedLocalStreams[t].length&&delete this._shimmedLocalStreams[t]}),n.apply(this,arguments)}}function Ae(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return Le(e);const r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const e=r.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map(e=>this._reverseStreams[e.id])};const i=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 r=new e.MediaStream(t.getTracks());this._streams[t.id]=r,this._reverseStreams[r.id]=t,t=r}i.apply(this,[t])};const n=e.RTCPeerConnection.prototype.removeStream;function s(e,t){let r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(t=>{const i=e._reverseStreams[t],n=e._streams[i.id];r=r.replace(new RegExp(n.id,"g"),i.id)}),new RTCSessionDescription({type:t.type,sdp:r})}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,r){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const i=[].slice.call(arguments,1);if(1!==i.length||!i[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[r.id];if(n)n.addTrack(t),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const i=new e.MediaStream([t]);this._streams[r.id]=i,this._reverseStreams[i.id]=r,this.addStream(i)}return this.getSenders().find(e=>e.track===t)},["createOffer","createAnswer"].forEach(function(t){const r=e.RTCPeerConnection.prototype[t],i={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?r.apply(this,[t=>{const r=s(this,t);e[0].apply(null,[r])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):r.apply(this,arguments).then(e=>s(this,e))}};e.RTCPeerConnection.prototype[t]=i[t]});const o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=function(e,t){let r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(t=>{const i=e._reverseStreams[t],n=e._streams[i.id];r=r.replace(new RegExp(i.id,"g"),n.id)}),new RTCSessionDescription({type:t.type,sdp:r})}(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(r=>{this._streams[r].getTracks().find(t=>e.track===t)&&(t=this._streams[r])}),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function Ne(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){const r=e.RTCPeerConnection.prototype[t],i={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=i[t]})}function Pe(e,t){_e(e,"negotiationneeded",e=>{const r=e.target;if(!(t.version<72||r.getConfiguration&&"plan-b"===r.getConfiguration().sdpSemantics)||"stable"===r.signalingState)return e})}var we=Object.freeze({__proto__:null,shimMediaStream:ve,shimOnTrack:Oe,shimGetSendersWithDtmf:be,shimGetStats:Ce,shimSenderReceiverGetStats:ye,shimAddTrackRemoveTrackWithNative:Le,shimAddTrackRemoveTrack:Ae,shimPeerConnection:Ne,fixNegotiationNeeded:Pe,shimGetUserMedia:Se,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(r){return t(r).then(t=>{const i=r.video&&r.video.width,n=r.video&&r.video.height,s=r.video&&r.video.frameRate;return r.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:s||3}},i&&(r.video.mandatory.maxWidth=i),n&&(r.video.mandatory.maxHeight=n),e.navigator.mediaDevices.getUserMedia(r)})}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}});var De,Ue,ke=(De=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 r=t.splitSections(e);return r&&r[0]},t.getMediaSections=function(e){var r=t.splitSections(e);return r.shift(),r},t.matchPrefix=function(e,r){return t.splitLines(e).filter(function(e){return 0===e.indexOf(r)})},t.parseCandidate=function(e){for(var t,r={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]},i=8;i<t.length;i+=2)switch(t[i]){case"raddr":r.relatedAddress=t[i+1];break;case"rport":r.relatedPort=parseInt(t[i+1],10);break;case"tcptype":r.tcpType=t[i+1];break;case"ufrag":r.ufrag=t[i+1],r.usernameFragment=t[i+1];break;default:r[t[i]]=t[i+1]}return r},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 r=e.type;return t.push("typ"),t.push(r),"host"!==r&&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(" "),r={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),r.name=t[0],r.clockRate=parseInt(t[1],10),r.channels=3===t.length?parseInt(t[2],10):1,r.numChannels=r.channels,r},t.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var r=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==r?"/"+r:"")+"\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,r={},i=e.substr(e.indexOf(" ")+1).split(";"),n=0;n<i.length;n++)r[(t=i[n].trim().split("="))[0].trim()]=t[1];return r},t.writeFmtp=function(e){var t="",r=e.payloadType;if(void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var i=[];Object.keys(e.parameters).forEach(function(t){e.parameters[t]?i.push(t+"="+e.parameters[t]):i.push(t)}),t+="a=fmtp:"+r+" "+i.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="",r=e.payloadType;return void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach(function(e){t+="a=rtcp-fb:"+r+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"}),t},t.parseSsrcMedia=function(e){var t=e.indexOf(" "),r={ssrc:parseInt(e.substr(7,t-7),10)},i=e.indexOf(":",t);return i>-1?(r.attribute=e.substr(t+1,i-t-1),r.value=e.substr(i+1)):r.attribute=e.substr(t+1),r},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 r=t.matchPrefix(e,"a=mid:")[0];if(r)return r.substr(6)},t.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},t.getDtlsParameters=function(e,r){return{role:"auto",fingerprints:t.matchPrefix(e+r,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){var r="a=setup:"+t+"\r\n";return e.fingerprints.forEach(function(e){r+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"}),r},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,r){return t.matchPrefix(e+r,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,r){var i=t.matchPrefix(e+r,"a=ice-ufrag:")[0],n=t.matchPrefix(e+r,"a=ice-pwd:")[0];return i&&n?{usernameFragment:i.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 r={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},i=t.splitLines(e)[0].split(" "),n=3;n<i.length;n++){var s=i[n],o=t.matchPrefix(e,"a=rtpmap:"+s+" ")[0];if(o){var a=t.parseRtpMap(o),c=t.matchPrefix(e,"a=fmtp:"+s+" ");switch(a.parameters=c.length?t.parseFmtp(c[0]):{},a.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+s+" ").map(t.parseRtcpFb),r.codecs.push(a),a.name.toUpperCase()){case"RED":case"ULPFEC":r.fecMechanisms.push(a.name.toUpperCase())}}}return t.matchPrefix(e,"a=extmap:").forEach(function(e){r.headerExtensions.push(t.parseExtmap(e))}),r},t.writeRtpDescription=function(e,r){var i="";i+="m="+e+" ",i+=r.codecs.length>0?"9":"0",i+=" UDP/TLS/RTP/SAVPF ",i+=r.codecs.map(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType}).join(" ")+"\r\n",i+="c=IN IP4 0.0.0.0\r\n",i+="a=rtcp:9 IN IP4 0.0.0.0\r\n",r.codecs.forEach(function(e){i+=t.writeRtpMap(e),i+=t.writeFmtp(e),i+=t.writeRtcpFb(e)});var n=0;return r.codecs.forEach(function(e){e.maxptime>n&&(n=e.maxptime)}),n>0&&(i+="a=maxptime:"+n+"\r\n"),i+="a=rtcp-mux\r\n",r.headerExtensions&&r.headerExtensions.forEach(function(e){i+=t.writeExtmap(e)}),i},t.parseRtpEncodingParameters=function(e){var r,i=[],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}),c=a.length>0&&a[0].ssrc,l=t.matchPrefix(e,"a=ssrc-group:FID").map(function(e){return e.substr(17).split(" ").map(function(e){return parseInt(e,10)})});l.length>0&&l[0].length>1&&l[0][0]===c&&(r=l[0][1]),n.codecs.forEach(function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&r&&(t.rtx={ssrc:r}),i.push(t),s&&((t=JSON.parse(JSON.stringify(t))).fec={ssrc:c,mechanism:o?"red+ulpfec":"red"},i.push(t))}}),0===i.length&&c&&i.push({ssrc:c});var d=t.matchPrefix(e,"b=");return d.length&&(d=0===d[0].indexOf("b=TIAS:")?parseInt(d[0].substr(7),10):0===d[0].indexOf("b=AS:")?1e3*parseInt(d[0].substr(5),10)*.95-16e3:void 0,i.forEach(function(e){e.maxBitrate=d})),i},t.parseRtcpParameters=function(e){var r={},i=t.matchPrefix(e,"a=ssrc:").map(function(e){return t.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute})[0];i&&(r.cname=i.value,r.ssrc=i.ssrc);var n=t.matchPrefix(e,"a=rtcp-rsize");r.reducedSize=n.length>0,r.compound=0===n.length;var s=t.matchPrefix(e,"a=rtcp-mux");return r.mux=s.length>0,r},t.parseMsid=function(e){var r,i=t.matchPrefix(e,"a=msid:");if(1===i.length)return{stream:(r=i[0].substr(7).split(" "))[0],track:r[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:(r=n[0].value.split(" "))[0],track:r[1]}:void 0},t.parseSctpDescription=function(e){var r,i=t.parseMLine(e),n=t.matchPrefix(e,"a=max-message-size:");n.length>0&&(r=parseInt(n[0].substr(19),10)),isNaN(r)&&(r=65536);var s=t.matchPrefix(e,"a=sctp-port:");if(s.length>0)return{port:parseInt(s[0].substr(12),10),protocol:i.fmt,maxMessageSize:r};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:r}}},t.writeSctpDescription=function(e,t){var r=[];return r="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&&r.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),r.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,21)},t.writeSessionBoilerplate=function(e,r,i){var n=void 0!==r?r:2;return"v=0\r\no="+(i||"thisisadapterortc")+" "+(e||t.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.writeMediaSection=function(e,r,i,n){var s=t.writeRtpDescription(e.kind,r);if(s+=t.writeIceParameters(e.iceGatherer.getLocalParameters()),s+=t.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===i?"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,r){for(var i=t.splitLines(e),n=0;n<i.length;n++)switch(i[n]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return i[n].substr(2)}return r?t.getDirection(r):"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 r=t.splitLines(e)[0].substr(2).split(" ");return{kind:r[0],port:parseInt(r[1],10),protocol:r[2],fmt:r.slice(3).join(" ")}},t.parseOLine=function(e){var r=t.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:r[0],sessionId:r[1],sessionVersion:parseInt(r[2],10),netType:r[3],addressType:r[4],address:r[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var r=t.splitLines(e),i=0;i<r.length;i++)if(r[i].length<2||"="!==r[i].charAt(1))return!1;return!0},e.exports=t},De(Ue={exports:{}},Ue.exports),Ue.exports);function Me(e,t,r,i,n){var s=ke.writeRtpDescription(e.kind,t);if(s+=ke.writeIceParameters(e.iceGatherer.getLocalParameters()),s+=ke.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"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:"+(i?i.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 xe(e,t){var r={codecs:[],headerExtensions:[],fecMechanisms:[]},i=function(e,t){e=parseInt(e,10);for(var r=0;r<t.length;r++)if(t[r].payloadType===e||t[r].preferredPayloadType===e)return t[r]},n=function(e,t,r,n){var s=i(e.parameters.apt,r),o=i(t.parameters.apt,n);return s&&o&&s.name.toLowerCase()===o.name.toLowerCase()};return e.codecs.forEach(function(i){for(var s=0;s<t.codecs.length;s++){var o=t.codecs[s];if(i.name.toLowerCase()===o.name.toLowerCase()&&i.clockRate===o.clockRate){if("rtx"===i.name.toLowerCase()&&i.parameters&&o.parameters.apt&&!n(i,o,e.codecs,t.codecs))continue;(o=JSON.parse(JSON.stringify(o))).numChannels=Math.min(i.numChannels,o.numChannels),r.codecs.push(o),o.rtcpFeedback=o.rtcpFeedback.filter(function(e){for(var t=0;t<i.rtcpFeedback.length;t++)if(i.rtcpFeedback[t].type===e.type&&i.rtcpFeedback[t].parameter===e.parameter)return!0;return!1});break}}}),e.headerExtensions.forEach(function(e){for(var i=0;i<t.headerExtensions.length;i++){var n=t.headerExtensions[i];if(e.uri===n.uri){r.headerExtensions.push(n);break}}}),r}function Be(e,t,r){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(r)}function Ve(e,t){var r=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 r||e.addRemoteCandidate(t),!r}function Fe(e,t){var r=new Error(t);return r.name=e,r.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[e],r}var je=function(e,t){function r(t,r){r.addTrack(t),r.dispatchEvent(new e.MediaStreamTrackEvent("addtrack",{track:t}))}function i(t,r,i,n){var s=new Event("track");s.track=r,s.receiver=i,s.transceiver={receiver:i},s.streams=n,e.setTimeout(function(){t._dispatchEvent("track",s)})}var n=function(r){var i=this,n=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach(function(e){i[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",r=JSON.parse(JSON.stringify(r||{})),this.usingBundle="max-bundle"===r.bundlePolicy,"negotiate"===r.rtcpMuxPolicy)throw Fe("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(r.rtcpMuxPolicy||(r.rtcpMuxPolicy="require"),r.iceTransportPolicy){case"all":case"relay":break;default:r.iceTransportPolicy="all"}switch(r.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:r.bundlePolicy="balanced"}if(r.iceServers=function(e,t){var r=!1;return(e=JSON.parse(JSON.stringify(e))).filter(function(e){if(e&&(e.urls||e.url)){var i=e.urls||e.url;e.url&&!e.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var n="string"==typeof i;return n&&(i=[i]),i=i.filter(function(e){return 0!==e.indexOf("turn:")||-1===e.indexOf("transport=udp")||-1!==e.indexOf("turn:[")||r?0===e.indexOf("stun:")&&t>=14393&&-1===e.indexOf("?transport=udp"):(r=!0,!0)}),delete e.url,e.urls=n?i[0]:i,!!i.length}})}(r.iceServers||[],t),this._iceGatherers=[],r.iceCandidatePoolSize)for(var s=r.iceCandidatePoolSize;s>0;s--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:r.iceServers,gatherPolicy:r.iceTransportPolicy}));else r.iceCandidatePoolSize=0;this._config=r,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 r=this.transceivers.length>0,i={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&&r)i.iceTransport=this.transceivers[0].iceTransport,i.dtlsTransport=this.transceivers[0].dtlsTransport;else{var n=this._createIceAndDtlsTransports();i.iceTransport=n.iceTransport,i.dtlsTransport=n.dtlsTransport}return t||this.transceivers.push(i),i},n.prototype.addTrack=function(t,r){if(this._isClosed)throw Fe("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var i;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||(i=this.transceivers[n]);return i||(i=this._createTransceiver(t.kind)),this._maybeFireNegotiationNeeded(),-1===this.localStreams.indexOf(r)&&this.localStreams.push(r),i.track=t,i.stream=r,i.rtpSender=new e.RTCRtpSender(t,i.dtlsTransport),i.rtpSender},n.prototype.addStream=function(e){var r=this;if(t>=15025)e.getTracks().forEach(function(t){r.addTrack(t,e)});else{var i=e.clone();e.getTracks().forEach(function(e,t){var r=i.getTracks()[t];e.addEventListener("enabled",function(e){r.enabled=e.enabled})}),i.getTracks().forEach(function(e){r.addTrack(e,i)})}},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 r=this.transceivers.find(function(e){return e.rtpSender===t});if(!r)throw Fe("InvalidAccessError","Sender was not created by this connection.");var i=r.stream;r.rtpSender.stop(),r.rtpSender=null,r.track=null,r.stream=null,-1===this.transceivers.map(function(e){return e.stream}).indexOf(i)&&this.localStreams.indexOf(i)>-1&&this.localStreams.splice(this.localStreams.indexOf(i),1),this._maybeFireNegotiationNeeded()},n.prototype.removeStream=function(e){var t=this;e.getTracks().forEach(function(e){var r=t.getSenders().find(function(t){return t.track===e});r&&t.removeTrack(r)})},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,r){var i=this;if(r&&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 r=!e.candidate||0===Object.keys(e.candidate).length;n.state=r?"completed":"gathering",null!==i.transceivers[t].bufferedCandidateEvents&&i.transceivers[t].bufferedCandidateEvents.push(e)},n.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),n},n.prototype._gather=function(t,r){var i=this,n=this.transceivers[r].iceGatherer;if(!n.onlocalcandidate){var s=this.transceivers[r].bufferedCandidateEvents;this.transceivers[r].bufferedCandidateEvents=null,n.removeEventListener("localcandidate",this.transceivers[r].bufferCandidates),n.onlocalcandidate=function(e){if(!(i.usingBundle&&r>0)){var s=new Event("icecandidate");s.candidate={sdpMid:t,sdpMLineIndex:r};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 c=ke.writeCandidate(o);s.candidate=Object.assign(s.candidate,ke.parseCandidate(c)),s.candidate.candidate=c,s.candidate.toJSON=function(){return{candidate:s.candidate.candidate,sdpMid:s.candidate.sdpMid,sdpMLineIndex:s.candidate.sdpMLineIndex,usernameFragment:s.candidate.usernameFragment}}}var l=ke.getMediaSections(i._localDescription.sdp);l[s.candidate.sdpMLineIndex]+=a?"a=end-of-candidates\r\n":"a="+s.candidate.candidate+"\r\n",i._localDescription.sdp=ke.getDescription(i._localDescription.sdp)+l.join("");var d=i.transceivers.every(function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state});"gathering"!==i.iceGatheringState&&(i.iceGatheringState="gathering",i._emitGatheringStateChange()),a||i._dispatchEvent("icecandidate",s),d&&(i._dispatchEvent("icecandidate",new Event("icecandidate")),i.iceGatheringState="complete",i._emitGatheringStateChange())}},e.setTimeout(function(){s.forEach(function(e){n.onlocalcandidate(e)})},0)}},n.prototype._createIceAndDtlsTransports=function(){var t=this,r=new e.RTCIceTransport(null);r.onicestatechange=function(){t._updateIceConnectionState(),t._updateConnectionState()};var i=new e.RTCDtlsTransport(r);return i.ondtlsstatechange=function(){t._updateConnectionState()},i.onerror=function(){Object.defineProperty(i,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:r,dtlsTransport:i}},n.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var r=this.transceivers[e].iceTransport;r&&(delete r.onicestatechange,delete this.transceivers[e].iceTransport);var i=this.transceivers[e].dtlsTransport;i&&(delete i.ondtlsstatechange,delete i.onerror,delete this.transceivers[e].dtlsTransport)},n.prototype._transceive=function(e,r,i){var n=xe(e.localCapabilities,e.remoteCapabilities);r&&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)),i&&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,r,i=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(Fe("TypeError",'Unsupported type "'+e.type+'"'));if(!Be("setLocalDescription",e.type,i.signalingState)||i._isClosed)return Promise.reject(Fe("InvalidStateError","Can not set local "+e.type+" in state "+i.signalingState));if("offer"===e.type)t=ke.splitSections(e.sdp),r=t.shift(),t.forEach(function(e,t){var r=ke.parseRtpParameters(e);i.transceivers[t].localCapabilities=r}),i.transceivers.forEach(function(e,t){i._gather(e.mid,t)});else if("answer"===e.type){t=ke.splitSections(i._remoteDescription.sdp),r=t.shift();var n=ke.matchPrefix(r,"a=ice-lite").length>0;t.forEach(function(e,t){var s=i.transceivers[t],o=s.iceGatherer,a=s.iceTransport,c=s.dtlsTransport,l=s.localCapabilities,d=s.remoteCapabilities;if(!(ke.isRejected(e)&&0===ke.matchPrefix(e,"a=bundle-only").length)&&!s.rejected){var u=ke.getIceParameters(e,r),_=ke.getDtlsParameters(e,r);n&&(_.role="server"),i.usingBundle&&0!==t||(i._gather(s.mid,t),"new"===a.state&&a.start(o,u,n?"controlling":"controlled"),"new"===c.state&&c.start(_));var h=xe(l,d);i._transceive(s,h.codecs.length>0,!1)}})}return i._localDescription={type:e.type,sdp:e.sdp},"offer"===e.type?i._updateSignalingState("have-local-offer"):i._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(!Be("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=[],c=ke.splitSections(n.sdp),l=c.shift(),d=ke.matchPrefix(l,"a=ice-lite").length>0,u=ke.matchPrefix(l,"a=group:BUNDLE ").length>0;s.usingBundle=u;var _=ke.matchPrefix(l,"a=ice-options:")[0];return s.canTrickleIceCandidates=!!_&&_.substr(14).split(" ").indexOf("trickle")>=0,c.forEach(function(i,c){var _=ke.splitLines(i),h=ke.getKind(i),p=ke.isRejected(i)&&0===ke.matchPrefix(i,"a=bundle-only").length,f=_[0].substr(2).split(" ")[2],g=ke.getDirection(i,l),m=ke.parseMsid(i),R=ke.getMid(i)||ke.generateIdentifier();if(p||"application"===h&&("DTLS/SCTP"===f||"UDP/DTLS/SCTP"===f))s.transceivers[c]={mid:R,kind:h,protocol:f,rejected:!0};else{var E,T,I,S,v,O,b,C,y;!p&&s.transceivers[c]&&s.transceivers[c].rejected&&(s.transceivers[c]=s._createTransceiver(h,!0));var L,A,N=ke.parseRtpParameters(i);p||(L=ke.getIceParameters(i,l),(A=ke.getDtlsParameters(i,l)).role="client"),b=ke.parseRtpEncodingParameters(i);var P=ke.parseRtcpParameters(i),w=ke.matchPrefix(i,"a=end-of-candidates",l).length>0,D=ke.matchPrefix(i,"a=candidate:").map(function(e){return ke.parseCandidate(e)}).filter(function(e){return 1===e.component});if(("offer"===n.type||"answer"===n.type)&&!p&&u&&c>0&&s.transceivers[c]&&(s._disposeIceAndDtlsTransports(c),s.transceivers[c].iceGatherer=s.transceivers[0].iceGatherer,s.transceivers[c].iceTransport=s.transceivers[0].iceTransport,s.transceivers[c].dtlsTransport=s.transceivers[0].dtlsTransport,s.transceivers[c].rtpSender&&s.transceivers[c].rtpSender.setTransport(s.transceivers[0].dtlsTransport),s.transceivers[c].rtpReceiver&&s.transceivers[c].rtpReceiver.setTransport(s.transceivers[0].dtlsTransport)),"offer"!==n.type||p){if("answer"===n.type&&!p){T=(E=s.transceivers[c]).iceGatherer,I=E.iceTransport,S=E.dtlsTransport,v=E.rtpReceiver,O=E.sendEncodingParameters,C=E.localCapabilities,s.transceivers[c].recvEncodingParameters=b,s.transceivers[c].remoteCapabilities=N,s.transceivers[c].rtcpParameters=P,D.length&&"new"===I.state&&(!d&&!w||u&&0!==c?D.forEach(function(e){Ve(E.iceTransport,e)}):I.setRemoteCandidates(D)),u&&0!==c||("new"===I.state&&I.start(T,L,"controlling"),"new"===S.state&&S.start(A)),!xe(E.localCapabilities,E.remoteCapabilities).codecs.filter(function(e){return"rtx"===e.name.toLowerCase()}).length&&E.sendEncodingParameters[0].rtx&&delete E.sendEncodingParameters[0].rtx,s._transceive(E,"sendrecv"===g||"recvonly"===g,"sendrecv"===g||"sendonly"===g),!v||"sendrecv"!==g&&"sendonly"!==g?delete E.rtpReceiver:(y=v.track,m?(o[m.stream]||(o[m.stream]=new e.MediaStream),r(y,o[m.stream]),a.push([y,v,o[m.stream]])):(o.default||(o.default=new e.MediaStream),r(y,o.default),a.push([y,v,o.default])))}}else{(E=s.transceivers[c]||s._createTransceiver(h)).mid=R,E.iceGatherer||(E.iceGatherer=s._createIceGatherer(c,u)),D.length&&"new"===E.iceTransport.state&&(!w||u&&0!==c?D.forEach(function(e){Ve(E.iceTransport,e)}):E.iceTransport.setRemoteCandidates(D)),C=e.RTCRtpReceiver.getCapabilities(h),t<15019&&(C.codecs=C.codecs.filter(function(e){return"rtx"!==e.name})),O=E.sendEncodingParameters||[{ssrc:1001*(2*c+2)}];var U,k=!1;if("sendrecv"===g||"sendonly"===g){if(k=!E.rtpReceiver,v=E.rtpReceiver||new e.RTCRtpReceiver(E.dtlsTransport,h),k)y=v.track,m&&"-"===m.stream||(m?(o[m.stream]||(o[m.stream]=new e.MediaStream,Object.defineProperty(o[m.stream],"id",{get:function(){return m.stream}})),Object.defineProperty(y,"id",{get:function(){return m.track}}),U=o[m.stream]):(o.default||(o.default=new e.MediaStream),U=o.default)),U&&(r(y,U),E.associatedRemoteMediaStreams.push(U)),a.push([y,v,U])}else E.rtpReceiver&&E.rtpReceiver.track&&(E.associatedRemoteMediaStreams.forEach(function(t){var r=t.getTracks().find(function(e){return e.id===E.rtpReceiver.track.id});r&&function(t,r){r.removeTrack(t),r.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:t}))}(r,t)}),E.associatedRemoteMediaStreams=[]);E.localCapabilities=C,E.remoteCapabilities=N,E.rtpReceiver=v,E.rtcpParameters=P,E.sendEncodingParameters=O,E.recvEncodingParameters=b,s._transceive(s.transceivers[c],!1,k)}}}),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 r=o[t];if(r.getTracks().length){if(-1===s.remoteStreams.indexOf(r)){s.remoteStreams.push(r);var n=new Event("addstream");n.stream=r,e.setTimeout(function(){s._dispatchEvent("addstream",n)})}a.forEach(function(e){var t=e[0],n=e[1];r.id===e[2].id&&i(s,t,n,[r])})}}),a.forEach(function(e){e[2]||i(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 r=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",r)}},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 r=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",r)}},n.prototype.createOffer=function(){var r=this;if(r._isClosed)return Promise.reject(Fe("InvalidStateError","Can not call createOffer after close"));var i=r.transceivers.filter(function(e){return"audio"===e.kind}).length,n=r.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&&(i=!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(r.transceivers.forEach(function(e){"audio"===e.kind?--i<0&&(e.wantReceive=!1):"video"===e.kind&&--n<0&&(e.wantReceive=!1)});i>0||n>0;)i>0&&(r._createTransceiver("audio"),i--),n>0&&(r._createTransceiver("video"),n--);var o=ke.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);r.transceivers.forEach(function(i,n){var s=i.track,o=i.kind,a=i.mid||ke.generateIdentifier();i.mid=a,i.iceGatherer||(i.iceGatherer=r._createIceGatherer(n,r.usingBundle));var c=e.RTCRtpSender.getCapabilities(o);t<15019&&(c.codecs=c.codecs.filter(function(e){return"rtx"!==e.name})),c.codecs.forEach(function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1"),i.remoteCapabilities&&i.remoteCapabilities.codecs&&i.remoteCapabilities.codecs.forEach(function(t){e.name.toLowerCase()===t.name.toLowerCase()&&e.clockRate===t.clockRate&&(e.preferredPayloadType=t.payloadType)})}),c.headerExtensions.forEach(function(e){(i.remoteCapabilities&&i.remoteCapabilities.headerExtensions||[]).forEach(function(t){e.uri===t.uri&&(e.id=t.id)})});var l=i.sendEncodingParameters||[{ssrc:1001*(2*n+1)}];s&&t>=15019&&"video"===o&&!l[0].rtx&&(l[0].rtx={ssrc:l[0].ssrc+1}),i.wantReceive&&(i.rtpReceiver=new e.RTCRtpReceiver(i.dtlsTransport,o)),i.localCapabilities=c,i.sendEncodingParameters=l}),"max-compat"!==r._config.bundlePolicy&&(o+="a=group:BUNDLE "+r.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"),o+="a=ice-options:trickle\r\n",r.transceivers.forEach(function(e,t){o+=Me(e,e.localCapabilities,"offer",e.stream,r._dtlsRole),o+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===r.iceGatheringState||0!==t&&r.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 r=this;if(r._isClosed)return Promise.reject(Fe("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==r.signalingState&&"have-local-pranswer"!==r.signalingState)return Promise.reject(Fe("InvalidStateError","Can not call createAnswer in signalingState "+r.signalingState));var i=ke.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);r.usingBundle&&(i+="a=group:BUNDLE "+r.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"),i+="a=ice-options:trickle\r\n";var n=ke.getMediaSections(r._remoteDescription.sdp).length;r.transceivers.forEach(function(e,s){if(!(s+1>n)){if(e.rejected)return"application"===e.kind?"DTLS/SCTP"===e.protocol?i+="m=application 0 DTLS/SCTP 5000\r\n":i+="m=application 0 "+e.protocol+" webrtc-datachannel\r\n":"audio"===e.kind?i+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n":"video"===e.kind&&(i+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"),void(i+="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=xe(e.localCapabilities,e.remoteCapabilities);!a.codecs.filter(function(e){return"rtx"===e.name.toLowerCase()}).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,i+=Me(e,a,"answer",e.stream,r._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(i+="a=rtcp-rsize\r\n")}});var s=new e.RTCSessionDescription({type:"answer",sdp:i});return Promise.resolve(s)},n.prototype.addIceCandidate=function(e){var t,r=this;return e&&void 0===e.sdpMLineIndex&&!e.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(i,n){if(!r._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<r.transceivers.length;o++)if(r.transceivers[o].mid===e.sdpMid){s=o;break}var a=r.transceivers[s];if(!a)return n(Fe("OperationError","Can not add ICE candidate"));if(a.rejected)return i();var c=Object.keys(e.candidate).length>0?ke.parseCandidate(e.candidate):{};if("tcp"===c.protocol&&(0===c.port||9===c.port))return i();if(c.component&&1!==c.component)return i();if((0===s||s>0&&a.iceTransport!==r.transceivers[0].iceTransport)&&!Ve(a.iceTransport,c))return n(Fe("OperationError","Can not add ICE candidate"));var l=e.candidate.trim();0===l.indexOf("a=")&&(l=l.substr(2)),(t=ke.getMediaSections(r._remoteDescription.sdp))[s]+="a="+(c.type?l:"end-of-candidates")+"\r\n",r._remoteDescription.sdp=ke.getDescription(r._remoteDescription.sdp)+t.join("")}else for(var d=0;d<r.transceivers.length&&(r.transceivers[d].rejected||(r.transceivers[d].iceTransport.addRemoteCandidate({}),(t=ke.getMediaSections(r._remoteDescription.sdp))[d]+="a=end-of-candidates\r\n",r._remoteDescription.sdp=ke.getDescription(r._remoteDescription.sdp)+t.join(""),!r.usingBundle));d++);i()})},n.prototype.getStats=function(t){if(t&&t instanceof e.MediaStreamTrack){var r=null;if(this.transceivers.forEach(function(e){e.rtpSender&&e.rtpSender.track===t?r=e.rtpSender:e.rtpReceiver&&e.rtpReceiver.track===t&&(r=e.rtpReceiver)}),!r)throw Fe("InvalidAccessError","Invalid selector.");return r.getStats()}var i=[];return this.transceivers.forEach(function(e){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(t){e[t]&&i.push(e[t].getStats())})}),Promise.all(i).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 r=e[t];if(r&&r.prototype&&r.prototype.getStats){var i=r.prototype.getStats;r.prototype.getStats=function(){return i.apply(this).then(function(e){var t=new Map;return Object.keys(e).forEach(function(r){var i;e[r].type={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[(i=e[r]).type]||i.type,t.set(r,e[r])}),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 Ge(e){const t=e&&e.navigator,r=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return r(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 He(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 r=new Event("enabled");r.enabled=e,this.dispatchEvent(r)}})}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 r=je(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 r=e.urls||e.url;e.url&&!e.urls&&ge("RTCIceServer.url","RTCIceServer.urls");const i="string"==typeof r;return i&&(r=[r]),r=r.filter(e=>{if(0===e.indexOf("stun:"))return!1;const r=e.startsWith("turn")&&!e.startsWith("turn:[")&&e.includes("transport=udp");return r&&!t?(t=!0,!0):r&&!t}),delete e.url,e.urls=i?r[0]:r,!!r.length}})}(e.iceServers,t.version),fe("ICE servers after filtering:",e.iceServers)),new r(e)},e.RTCPeerConnection.prototype=r.prototype}function Ke(e){e.RTCRtpSender&&!("replaceTrack"in e.RTCRtpSender.prototype)&&(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}var qe=Object.freeze({__proto__:null,shimPeerConnection:He,shimReplaceTrack:Ke,shimGetUserMedia:Ge,shimGetDisplayMedia:Je});function $e(e,t){const r=e&&e.navigator,i=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,i){ge("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(e).then(t,i)},!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){const e=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])},t=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(r){return"object"==typeof r&&"object"==typeof r.audio&&(r=JSON.parse(JSON.stringify(r)),e(r.audio,"autoGainControl","mozAutoGainControl"),e(r.audio,"noiseSuppression","mozNoiseSuppression")),t(r)},i&&i.prototype.getSettings){const t=i.prototype.getSettings;i.prototype.getSettings=function(){const r=t.apply(this,arguments);return e(r,"mozAutoGainControl","autoGainControl"),e(r,"mozNoiseSuppression","noiseSuppression"),r}}if(i&&i.prototype.applyConstraints){const t=i.prototype.applyConstraints;i.prototype.applyConstraints=function(r){return"audio"===this.kind&&"object"==typeof r&&(r=JSON.parse(JSON.stringify(r)),e(r,"autoGainControl","mozAutoGainControl"),e(r,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[r])}}}}function Ye(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 We(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 r=e.RTCPeerConnection.prototype[t],i={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=i[t]});const r={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},i=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,n,s]=arguments;return i.apply(this,[e||null]).then(e=>{if(t.version<53&&!n)try{e.forEach(e=>{e.type=r[e.type]||e.type})}catch(t){if("TypeError"!==t.name)throw t;e.forEach((t,i)=>{e.set(i,Object.assign({},t,{type:r[t.type]||t.type}))})}return e}).then(n,s)}}function ze(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 r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=r.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 Qe(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}),_e(e,"track",e=>(e.receiver._pc=e.srcElement,e)),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function Ze(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){ge("removeStream","removeTrack"),this.getSenders().forEach(t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)})})}function Xe(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function et(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],r=e&&"sendEncodings"in e;r&&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 i=t.apply(this,arguments);if(r){const{sender:t}=i,r=t.getParameters();(!("encodings"in r)||1===r.encodings.length&&0===Object.keys(r.encodings[0]).length)&&(r.encodings=e.sendEncodings,t.sendEncodings=e.sendEncodings,this.setParametersPromises.push(t.setParameters(r).then(()=>{delete t.sendEncodings}).catch(()=>{delete t.sendEncodings})))}return i})}function tt(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 it(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 nt=Object.freeze({__proto__:null,shimOnTrack:Ye,shimPeerConnection:We,shimSenderGetStats:ze,shimReceiverGetStats:Qe,shimRemoveStream:Ze,shimRTCDataChannel:Xe,shimAddTransceiver:et,shimGetParameters:tt,shimCreateOffer:rt,shimCreateAnswer:it,shimGetUserMedia:$e,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(r){if(!r||!r.video){const e=new DOMException("getDisplayMedia without video constraints is undefined");return e.name="NotFoundError",e.code=8,Promise.reject(e)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)})}});function st(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(r=>t.call(this,r,e)),e.getVideoTracks().forEach(r=>t.call(this,r,e))},e.RTCPeerConnection.prototype.addTrack=function(e,...r){return r&&r.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 r=e.getTracks();this.getSenders().forEach(e=>{r.includes(e.track)&&this.removeTrack(e)})})}}function ot(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 r=new Event("addstream");r.stream=t,e.dispatchEvent(r)})}),t.apply(e,arguments)}}}function at(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,r=t.createOffer,i=t.createAnswer,n=t.setLocalDescription,s=t.setRemoteDescription,o=t.addIceCandidate;t.createOffer=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},t.createAnswer=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};let a=function(e,t,r){const i=n.apply(this,[e]);return r?(i.then(t,r),Promise.resolve()):i};t.setLocalDescription=a,a=function(e,t,r){const i=s.apply(this,[e]);return r?(i.then(t,r),Promise.resolve()):i},t.setRemoteDescription=a,a=function(e,t,r){const i=o.apply(this,[e]);return r?(i.then(t,r),Promise.resolve()):i},t.addIceCandidate=a}function ct(e){const t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,r=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>r(lt(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,i){t.mediaDevices.getUserMedia(e).then(r,i)}.bind(t))}function lt(e){return e&&void 0!==e.video?Object.assign({},e,{video:Re(e.video)}):e}function dt(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){const t=[];for(let r=0;r<e.iceServers.length;r++){let i=e.iceServers[r];!i.hasOwnProperty("urls")&&i.hasOwnProperty("url")?(ge("RTCIceServer.url","RTCIceServer.urls"),i=JSON.parse(JSON.stringify(i)),i.urls=i.url,delete i.url,t.push(i)):t.push(e.iceServers[r])}e.iceServers=t}return new t(e,r)},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 _t(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 r=this.getTransceivers().find(e=>"video"===e.receiver.track.kind);!1===e.offerToReceiveVideo&&r?"sendrecv"===r.direction?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":"recvonly"===r.direction&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):!0!==e.offerToReceiveVideo||r||this.addTransceiver("video")}return t.apply(this,arguments)}}function ht(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var pt=Object.freeze({__proto__:null,shimLocalStreamsAPI:st,shimRemoteStreamsAPI:ot,shimCallbacksAPI:at,shimGetUserMedia:ct,shimConstraints:lt,shimRTCIceServerUrls:dt,shimTrackEventTransceiver:ut,shimCreateOfferLegacy:_t,shimAudioContext:ht});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 r=new t(e),i=ke.parseCandidate(e.candidate),n=Object.assign(r,i);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,_e(e,"icecandidate",t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t))}function gt(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 r=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 r=parseInt(t[1],10);return r!=r?-1:r}(arguments[0]),r=function(e){let r=65536;return"firefox"===t.browser&&(r=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),r}(e),i=function(e,r){let i=65536;"firefox"===t.browser&&57===t.version&&(i=65535);const n=ke.matchPrefix(e.sdp,"a=max-message-size:");return n.length>0?i=parseInt(n[0].substr(19),10):"firefox"===t.browser&&-1!==r&&(i=2147483637),i}(arguments[0],e);let n;n=0===r&&0===i?Number.POSITIVE_INFINITY:0===r||0===i?Math.max(r,i):Math.min(r,i);const s={};Object.defineProperty(s,"maxMessageSize",{get:()=>n}),this._sctp=s}return r.apply(this,arguments)}}function mt(e){if(!e.RTCPeerConnection||!("createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){const r=e.send;e.send=function(){const i=arguments[0],n=i.length||i.size||i.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 r.apply(e,arguments)}}const r=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=r.apply(this,arguments);return t(e,this),e},_e(e,"datachannel",e=>(t(e.channel,e.target),e))}function Rt(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 r=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 r=new Event("connectionstatechange",e);t.dispatchEvent(r)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}})}function Et(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;const r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){const r=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:r}):t.sdp=r}return r.apply(this,arguments)}}function Tt(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const r=e.RTCPeerConnection.prototype.addIceCandidate;r&&0!==r.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():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}var It=Object.freeze({__proto__:null,shimRTCIceCandidate:ft,shimMaxMessageSize:gt,shimSendThrowTypeError:mt,shimConnectionState:Rt,removeExtmapAllowMixed:Et,shimAddIceCandidateNullOrEmpty:Tt});const St=function({window:e}={},t={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const r=fe,i=function(e){const t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;const{navigator:r}=e;if(r.mozGetUserMedia)t.browser="firefox",t.version=ue(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer)t.browser="chrome",t.version=ue(r.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(r.mediaDevices&&r.userAgent.match(/Edge\/(\d+).(\d+)$/))t.browser="edge",t.version=ue(r.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!e.RTCPeerConnection||!r.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=ue(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(e),n={browserDetails:i,commonShim:It,extractVersion:ue,disableLog:he,disableWarnings:pe};switch(i.browser){case"chrome":if(!we||!Ne||!t.shimChrome)return r("Chrome shim is not included in this adapter release."),n;if(null===i.version)return r("Chrome shim can not determine version, not shimming."),n;r("adapter.js shimming chrome."),n.browserShim=we,Tt(e,i),Se(e,i),ve(e),Ne(e,i),Oe(e),Ae(e,i),be(e),Ce(e),ye(e),Pe(e,i),ft(e),Rt(e),gt(e,i),mt(e),Et(e,i);break;case"firefox":if(!nt||!We||!t.shimFirefox)return r("Firefox shim is not included in this adapter release."),n;r("adapter.js shimming firefox."),n.browserShim=nt,Tt(e,i),$e(e,i),We(e,i),Ye(e),Ze(e),ze(e),Qe(e),Xe(e),et(e),tt(e),rt(e),it(e),ft(e),Rt(e),gt(e,i),mt(e);break;case"edge":if(!qe||!He||!t.shimEdge)return r("MS edge shim is not included in this adapter release."),n;r("adapter.js shimming edge."),n.browserShim=qe,Ge(e),Je(e),He(e,i),Ke(e),gt(e,i),mt(e);break;case"safari":if(!pt||!t.shimSafari)return r("Safari shim is not included in this adapter release."),n;r("adapter.js shimming safari."),n.browserShim=pt,Tt(e,i),dt(e),_t(e),at(e),st(e),ot(e),ut(e),ct(e),ht(e),ft(e),gt(e,i),mt(e),Et(e,i);break;default:r("Unsupported browser!")}return n}({window:"undefined"==typeof window?void 0:window});var vt,Ot,bt;!function(e){e.FPS_10="FPS_10",e.FPS_15="FPS_15",e.FPS_24="FPS_24",e.FPS_30="FPS_30"}(vt||(vt={})),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"}(bt||(bt={}));const Ct={[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}},yt=e=>{const t={192:180,368:360,1088:1080};return t[e]?t[e]:e},Lt=(e,t)=>{e=yt(e),t=yt(t);const r=Ct[`W${e}_H${t}`];if(r)return r;const i=e*t;return Object.keys(Ct).map(e=>Ct[e]).sort((e,t)=>e.height*e.width-t.width*t.height).filter(e=>e.height*e.width>=i)[0]||Ct.W1920_H1080},At={10:1,15:1,24:1.5,30:1.5},Nt=e=>{let t=Number.MAX_VALUE,r=1;for(const i in At){const n=Math.abs(e-parseInt(i));n<t&&(t=n,r=At[i])}return r},Pt={getCameras:()=>v(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(e=>"videoinput"===e.kind)}),getMicrophones:()=>v(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(e=>"audioinput"===e.kind)}),getSpeakers:()=>v(void 0,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(e=>"audiooutput"===e.kind)})};var wt,Dt;!function(e){e.AUDIO="audio",e.VIDEO="video"}(wt||(wt={}));class Ut extends m{constructor(e,t,r,i,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:r}),Object.defineProperty(this,"_kind",{enumerable:!0,configurable:!0,writable:!0,value:i}),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,r=t.getTracks()[0];r&&t.removeTrack(r),this._isLocalTrack||this._logger.warn(ae.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 v(this,void 0,void 0,function*(){return this._msTrack&&(this._msTrack.enabled=!e),this._localMuted=e,oe.SUCCESS})}mute(){return v(this,void 0,void 0,function*(){return this._setLocalMuted(!0)})}unmute(){return v(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(!s(null==e?void 0:e.volume))return this._logger.error(ae.L_TRACK_PLAY_E,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> options.volume not a number"})),{code:oe.PARAMS_ERROR};(null==e?void 0:e.volume)<0&&(e.volume=0,this._logger.warn(ae.L_TRACK_PLAY_E,JSON.stringify({status:ce.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(ae.L_TRACK_PLAY_E,JSON.stringify({status:ce.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 v(this,void 0,void 0,function*(){if(!this._msTrack)return this._logger.error(ae.L_TRACK_PLAY_E,JSON.stringify({status:ce.FAILED,code:oe.TRACK_NOT_READY,kind:this._kind,msg:`the track is not ready to play -> id: ${this._id}`})),{code:oe.TRACK_NOT_READY};"ended"===this._msTrack.readyState&&this._logger.warn(ae.L_TRACK_PLAY_E,`track readyState is ended -> id: ${this._id}`);const r=this._validateVolume(t);if(r)return r;if(null==t?void 0:t.audioDeviceId){if(!(yield Pt.getSpeakers()).map(e=>e.deviceId).includes(t.audioDeviceId))return this._logger.error(ae.L_TRACK_PLAY_E,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> options.audioDeviceId"})),{code:oe.PARAMS_ERROR}}return!this.isVideoTrack()||e&&(e instanceof HTMLVideoElement||this._validateVideoNodeName(e))?void 0:(this._logger.error(ae.L_TRACK_PLAY_E,JSON.stringify({status:ce.FAILED,code:oe.VIDEO_TRACK_MISS_MEDIA_ELEMENT,kind:this._kind,msg:"params element is not a HTMLVideoElement"})),{code:oe.VIDEO_TRACK_MISS_MEDIA_ELEMENT})})}_setPlayAttrs(e,t){return v(this,void 0,void 0,function*(){var r;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===(r=this._element)||void 0===r||r.setAttribute(this.DataTrackId,this.getTrackId())})}play(e,t){return v(this,void 0,void 0,function*(){this._logger.info(ae.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 r=yield this._validatePlayOptions(e,t);if(r)return r;const i=this.isVideoTrack();return this._element=i?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(ae.L_TRACK_LOAD_START_O,JSON.stringify({status:ce.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(ae.L_TRACK_DURATION_CHANGE_O,JSON.stringify({status:ce.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(ae.L_TRACK_LOADED_META_DATA_O,JSON.stringify({status:ce.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(ae.L_TRACK_LOADED_DATA_O,JSON.stringify({status:ce.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(ae.L_TRACK_ABORT_O,JSON.stringify({status:ce.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=>v(this,void 0,void 0,function*(){var r,n;this._logger.info(ae.L_TRACK_CANPLAY_O,JSON.stringify({status:ce.INFO,kind:this._kind,msg:`HTMLMediaElement oncanplay -> id: ${null===(r=e.target)||void 0===r?void 0:r.id}, trackId: ${this._id}`}));try{(null==t?void 0:t.audioDeviceId)&&!i&&(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(ae.L_TRACK_PLAY_E,JSON.stringify({status:ce.FAILED,kind:this._kind,code:oe.NO_PERMISSION_TO_USE_REQUESTED_DEVICE,msg:`setSinkId failed, error msg: ${e.message}`}));this._logger.error(ae.L_TRACK_PLAY_E,JSON.stringify({status:ce.FAILED,code:oe.TRACK_PLAY_ERROR,kind:this._kind,msg:`play error, error msg: ${e.message}`}))}}),this._element.onvolumechange=e=>{var t,r;const i=Math.floor(100*(null===(t=e.target)||void 0===t?void 0:t.volume));this._logger.info(ae.L_TRACK_VOLUME_CHANGE_O,JSON.stringify({status:ce.INFO,msg:`HTMLMediaElement onvolumechange -> id: ${null===(r=e.target)||void 0===r?void 0:r.id}, volume: ${i}, trackId: ${this._id}`}))},this._element.srcObject=this._msStream,this._element.autoplay=!0,yield this._setPlayAttrs(i,t),{code:oe.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"}(Dt||(Dt={}));const kt={[Dt.Music]:{max:64,min:64},[Dt.MusicHigh]:{max:128,min:128},[Dt.Speech]:{max:32,min:32}};var Mt;!function(e){e.LEVEL0="LEVEL0",e.LEVEL1="LEVEL1",e.LEVEL2="LEVEL2",e.LEVEL3="LEVEL3",e.LEVEL4="LEVEL4",e.LEVEL5="LEVEL5"}(Mt||(Mt={}));const xt={[Mt.LEVEL0]:{max:150,min:80},[Mt.LEVEL1]:{max:280,min:120},[Mt.LEVEL2]:{max:650,min:150},[Mt.LEVEL3]:{max:1e3,min:200},[Mt.LEVEL4]:{max:2200,min:250},[Mt.LEVEL5]:{max:4e3,min:400}};class Bt{static apply3ANoiseWorklet(e){return v(this,void 0,void 0,function*(){const t=new AudioContext({sampleRate:44100});let r;try{yield t.audioWorklet.addModule(Bt.SCRIPT_URL);const e=yield fetch(Bt.WASM_URL,{cache:"force-cache",credentials:"same-origin"});r=yield e.arrayBuffer()}catch(e){return{code:oe.LOAD_3A_MODULE_FAILED}}const i=t.createMediaStreamSource(new MediaStream([e])),n=new AudioWorkletNode(t,"process-worklet",{numberOfInputs:1,numberOfOutputs:1,outputChannelCount:[1],processorOptions:{binary:r}}),s=t.createMediaStreamDestination();i.connect(n).connect(s);const o=s.stream.getAudioTracks()[0];return Bt._maps.set(e.id,t),{code:oe.SUCCESS,track:o}})}static release3ANoiseWorklet(e){const t=Bt._maps.get(e.id);t&&(t.close(),Bt._maps.delete(e.id))}}Object.defineProperty(Bt,"WASM_URL",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(Bt,"SCRIPT_URL",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(Bt,"_maps",{enumerable:!0,configurable:!0,writable:!0,value:new Map});class Vt extends Ut{constructor(e,t,r,i,n){super(e,t,r,i,!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(Vt.EVENT_LOCAL_TRACK_END,this),this.removeAll(Vt.EVENT_LOCAL_TRACK_END)}_setLocalMuted(e){return new Promise(t=>{const r=this._localMuted!==e;super._setLocalMuted(e),this._remoteMuted=this._localMuted,r&&this._isPublished?this.emit(Vt.__INNER_EVENT_MUTED_CHANGE__,this,t):t(oe.SUCCESS),this._logger.info(ae.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(ae.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(Vt.__INNER_EVENT_DESTROY__,this))}isDestroyed(){return this._isDestroyed}setBitrate(e=0,t=0,r=0){!s(e)||!s(t)||!s(r)||e<=0||t<=0||e<t?this._logger.error(ae.L_LOCAL_TRACK_SET_BITRATE_O,JSON.stringify({status:ce.FAILED,msg:`params error -> max: ${e},min: ${t}, start: ${r}`,trackId:this._id})):(this._logger.info(ae.L_LOCAL_TRACK_SET_BITRATE_O,JSON.stringify({status:ce.SUCCESSED,max:e,min:t,start:r,trackId:this._id})),this._bitrateInfo={max:e,min:t,start:r})}getBitrate(){var e,t,r,i,n,s,o;let{min:a,max:c,start:l}={min:0,max:0,start:0};return(null===(e=this._msTrack)||void 0===e?void 0:e.kind)===wt.VIDEO?({min:a,max:c}=nr(this._msTrack)):(null===(t=this._msTrack)||void 0===t?void 0:t.kind)===wt.AUDIO&&({min:a,max:c}={min:32,max:32}),(null===(r=this._bitrateInfo)||void 0===r?void 0:r.max)&&(l=.7*(null===(i=this._bitrateInfo)||void 0===i?void 0:i.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)||c,start:(null===(o=this._bitrateInfo)||void 0===o?void 0:o.start)||l}}getSettings(){var e;return null===(e=this._msTrack)||void 0===e?void 0:e.getSettings()}}Object.defineProperty(Vt,"EVENT_LOCAL_TRACK_END",{enumerable:!0,configurable:!0,writable:!0,value:"local-track-end"}),Object.defineProperty(Vt,"__INNER_EVENT_MUTED_CHANGE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-muted-change"}),Object.defineProperty(Vt,"__INNER_EVENT_DESTROY__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-destroy"});class Ft extends Vt{constructor(e,t,r,i){super(e,t,r,"audio",i)}setRecommendBitrate(e){if(!g("audioBitrate",e,e=>e in Dt))return void this._logger.warn(ae.L_RTC_SET_RECOMMEND_BITRATE_O,JSON.stringify({status:ce.FAILED,msg:"params error -> params type is RCAudioBitrate"}));const t=kt[e];this.setBitrate(t.max,t.min,t.start||.7*t.max)}setBitrate(e,...t){const[r=1,i=.7*e||1]=t;super.setBitrate(e,r,i)}}class jt extends Vt{constructor(e,t,r,i,n=!1){super(e,t,r,"video",i),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(!g("videoBitrate",e,e=>e in Mt))return void this._logger.warn(ae.L_RTC_SET_RECOMMEND_BITRATE_O,JSON.stringify({status:ce.FAILED,msg:"params error -> params type is RCVideoBitrate"}));const t=xt[e];this.setBitrate(t.max,t.min,t.start||.7*t.max)}setBitrate(e,...t){const[r=1,i=.7*e||1]=t;super.setBitrate(e,r,i)}}class Gt extends Vt{static _innerSetMapping(e,t){const r=this._mapping.get(t)||[];r.push(e),this._mapping.set(t,r)}static _innerRemoveMapping(e,t){var r,i;const n=null===(r=this._mapping.get(t))||void 0===r?void 0:r.filter(t=>t!==e);n&&n.length>0?this._mapping.set(t,n):(this._mapping.delete(t),t.pause(),t.src="",null===(i=t.parentNode)||void 0===i||i.removeChild(t))}constructor(e,t,r,i,n,s){super(e,t,r,i,n),Object.defineProperty(this,"_resource",{enumerable:!0,configurable:!0,writable:!0,value:s}),Gt._innerSetMapping(this.getTrackId(),s)}destroy(){this.isAudioTrack()&&this.mute(),Gt._innerRemoveMapping(this.getTrackId(),this._resource),super.destroy()}}Object.defineProperty(Gt,"_mapping",{enumerable:!0,configurable:!0,writable:!0,value:new Map});class Jt extends Gt{constructor(e,t,r,i,n){super(e,t,r,"video",i,n)}}class Ht extends Gt{constructor(e,t,r,i,n){super(e,t,r,"audio",i,n)}_setLocalMuted(e){const t=Object.create(null,{_setLocalMuted:{get:()=>super._setLocalMuted}});return v(this,void 0,void 0,function*(){return this._resource&&(this._resource.muted=e),t._setLocalMuted.call(this,e)})}play(){return v(this,void 0,void 0,function*(){return{code:yield this._setLocalMuted(!1)}})}}class Kt extends Ft{constructor(){super(...arguments),Object.defineProperty(this,"_originTrack",{enumerable:!0,configurable:!0,writable:!0,value:null})}apply3ANoiseWorklet(){return v(this,void 0,void 0,function*(){if(this._logger.info(ae.A_APPLY_3A_NOISE_WORKLET_T),this._originTrack)return this._logger.warn(ae.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:ce.FAILED,msg:"3A noise module already applied"})),{code:oe.SUCCESS};if(!this._msTrack||this.isDestroyed())return this._logger.warn(ae.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:ce.FAILED,msg:"track not ready"})),{code:oe.TRACK_NOT_READY};if(this.isPublished())return this._logger.warn(ae.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:ce.FAILED,msg:"track already published"})),{code:oe.APPLY_3A_NOISE_WORKLET_BEFORE_PUBLISH};const{code:e,track:t}=yield Bt.apply3ANoiseWorklet(this._msTrack);return e===oe.SUCCESS&&t?(this._originTrack=this._msTrack,this._msTrack=t,this._logger.info(ae.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:ce.SUCCESSED})),{code:oe.SUCCESS}):(this._logger.warn(ae.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:ce.FAILED,msg:`apply 3A noise module failed: ${e}`,SCRIPT_URL:Bt.SCRIPT_URL,WASM_URL:Bt.WASM_URL})),{code:e})})}__innerSetMediaStreamTrack(e){!e&&this._originTrack&&(Bt.release3ANoiseWorklet(this._originTrack),this._originTrack.stop(),this._originTrack=null),super.__innerSetMediaStreamTrack(e)}replaceInnerTrack(e){}}class qt extends jt{constructor(e,t,r,i,n=!1){super(e,t,r,i,n)}replaceInnerTrack(e){}}class $t extends jt{_onTrackEnded(){super._onTrackEnded(),this.isPublished()&&this.emit(Vt.__INNER_EVENT_DESTROY__,this)}}class Yt extends Ft{_onTrackEnded(){super._onTrackEnded(),this.isPublished()&&this.emit(Vt.__INNER_EVENT_DESTROY__,this)}}class Wt extends Ut{constructor(e,t,r,i,n){super(e,t,r,i,!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 zt extends Wt{constructor(e,t,r,i){super(e,t,r,"audio",i)}_setLocalMuted(e){const{browser:t,version:r}=fr;return this._element&&r&&/chrome/i.test(t)&&r>=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 Qt extends Wt{constructor(e,t,r,i){super(e,t,r,"video",i),Object.defineProperty(this,"_isSubTiny",{enumerable:!0,configurable:!0,writable:!0,value:!1})}__innerSetIsTinyTrack(e){this._isSubTiny=e}isSubTiny(){return this._isSubTiny}}var Zt;!function(e){e[e.MARK_DOWN=0]="MARK_DOWN",e[e.JSON=1]="JSON"}(Zt||(Zt={}));const Xt=(e,t)=>({name:e,content:JSON.stringify({uris:t,ignore:!0})}),er=e=>JSON.stringify(e),tr=e=>/^[a-zA-Z\d-=]+$/g.test(e),rr=e=>{if(void 0===e)return 0;if(s(e))return e;const t=e;return t.exact||t.ideal||t.max||0},ir=e=>{const t=e.getSettings(),r=e.getConstraints();return{width:rr(r.width)||t.width||0,height:rr(r.height)||t.height||0,frameRate:t.frameRate||rr(r.frameRate)}},nr=e=>{const{width:t,height:r,frameRate:i}=ir(e),n=Lt(t||1920,r||1080),s=Nt(i);return{min:n.minBitrate*s,max:n.maxBitrate*s}},sr=e=>[e.msid,e.mediaType].join("_"),or=e=>{const t=e.split("_");return{mediaType:parseInt(t.pop()),tag:t.pop(),userId:t.join("_")}},ar=(e,t)=>[e,t].join("_"),cr=e=>e.map(e=>Object.assign({},e)),lr=(e,t,r=!1)=>{e=e.slice();const i=[],n=[],s=[];return t.forEach(t=>{const n=sr(t);let o=e.findIndex(e=>sr(e)===n);if(r&&(o=e.findIndex(e=>e.uri===t.uri)),-1===o)return void i.push(t);const a=e[o];a.uri!==t.uri?i.push(t):a.state!==t.state&&s.push(t),e.splice(o,1)}),n.push(...e),{publishedList:i,unpublishedList:n,modifiedList:s}},dr=()=>{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(""),r=t.length+1;let i=+e;const n=[];do{const e=i%r;i=(i-e)/r,n.unshift(t[e])}while(i);return n.join("")})(e),e.length>22&&(e=e.slice(0,22)),e},ur=e=>{if(Ct[e]){const{width:t,height:r}=Ct[e];return{width:t,height:r}}const[t,r]=e.split("_").map(e=>parseInt(e.replace(/[^\d]/g,"")));return{width:t,height:r}},_r=e=>!!Ot[e],hr=e=>!!vt[e],pr=e=>parseInt(e.replace("FPS_","")),fr=(()=>{const{browser:e,version:t,supportsUnifiedPlan:r}=St.browserDetails;return{browser:e,version:t,supportsUnifiedPlan:!1!==r}})();function gr(){return"captureStream"in HTMLMediaElement.prototype||"mozCaptureStream"in HTMLMediaElement.prototype}function mr(){return"mediaDevices"in navigator&&"getDisplayMedia"in navigator.mediaDevices}const Rr=e=>"[object Null]"===Object.prototype.toString.call(e),Er=e=>1===e.type,Tr=(e,t,r,i)=>{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){r.warn(ae.L_PARSE_ROOMDATA_URIS_R,`invalid user data -> userId: ${s}, userData: ${a}`,i)}n[s]=o}),n},Ir=e=>e instanceof Ut?e.getTrackId():e.track.getTrackId(),Sr=e=>{if(!c(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 vr,Or;!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"}(vr||(vr={})),function(e){e.SUCCESS="Success",e.FAIL="Fail"}(Or||(Or={}));class br{constructor(e,t,r,i=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:r}),Object.defineProperty(this,"_gap",{enumerable:!0,configurable:!0,writable:!0,value:i}),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(ae.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:se})})}_checkAlive(e){return v(this,void 0,void 0,function*(){const{logger:t}=this._context,r=t.createTraceId(),{code:i,data:n}=yield this._sendPing();if(!this._started)return;const s=Date.now();return i===ie?(this._latestTimestamp=s,this.onPingResult(Or.SUCCESS,n.version),void(this._timer=setTimeout(()=>this._checkAlive(e),this._gap))):(t.error(ae.L_PINGER_SEND_RTCPING_E,JSON.stringify({roomId:this._roomId,code:i}),r),this.onPingResult(Or.FAIL),40003===i||s-this._latestTimestamp>e?(this.stop(),void this.onFailed(40003===i)):void(this._timer=setTimeout(()=>this._checkAlive(e),this._gap)))})}stop(){this._started&&(this._logger.info(ae.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 Cr(e){let t=e.length;for(;--t>=0;)e[t]=0}const yr=256,Lr=286,Ar=30,Nr=15,Pr=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]),wr=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]),Dr=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Ur=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),kr=new Array(576);Cr(kr);const Mr=new Array(60);Cr(Mr);const xr=new Array(512);Cr(xr);const Br=new Array(256);Cr(Br);const Vr=new Array(29);Cr(Vr);const Fr=new Array(Ar);function jr(e,t,r,i,n){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=i,this.max_length=n,this.has_stree=e&&e.length}let Gr,Jr,Hr;function Kr(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}Cr(Fr);const qr=e=>e<256?xr[e]:xr[256+(e>>>7)],$r=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},Yr=(e,t,r)=>{e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,$r(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)},Wr=(e,t,r)=>{Yr(e,r[2*t],r[2*t+1])},zr=(e,t)=>{let r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1},Qr=(e,t,r)=>{const i=new Array(16);let n,s,o=0;for(n=1;n<=Nr;n++)o=o+r[n-1]<<1,i[n]=o;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=zr(i[t]++,t))}},Zr=e=>{let t;for(t=0;t<Lr;t++)e.dyn_ltree[2*t]=0;for(t=0;t<Ar;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},Xr=e=>{e.bi_valid>8?$r(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},ei=(e,t,r,i)=>{const n=2*t,s=2*r;return e[n]<e[s]||e[n]===e[s]&&i[t]<=i[r]},ti=(e,t,r)=>{const i=e.heap[r];let n=r<<1;for(;n<=e.heap_len&&(n<e.heap_len&&ei(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!ei(t,i,e.heap[n],e.depth));)e.heap[r]=e.heap[n],r=n,n<<=1;e.heap[r]=i},ri=(e,t,r)=>{let i,n,s,o,a=0;if(0!==e.sym_next)do{i=255&e.pending_buf[e.sym_buf+a++],i+=(255&e.pending_buf[e.sym_buf+a++])<<8,n=e.pending_buf[e.sym_buf+a++],0===i?Wr(e,n,t):(s=Br[n],Wr(e,s+yr+1,t),o=Pr[s],0!==o&&(n-=Vr[s],Yr(e,n,o)),i--,s=qr(i),Wr(e,s,r),o=wr[s],0!==o&&(i-=Fr[s],Yr(e,i,o)))}while(a<e.sym_next);Wr(e,256,t)},ii=(e,t)=>{const r=t.dyn_tree,i=t.stat_desc.static_tree,n=t.stat_desc.has_stree,s=t.stat_desc.elems;let o,a,c,l=-1;for(e.heap_len=0,e.heap_max=573,o=0;o<s;o++)0!==r[2*o]?(e.heap[++e.heap_len]=l=o,e.depth[o]=0):r[2*o+1]=0;for(;e.heap_len<2;)c=e.heap[++e.heap_len]=l<2?++l:0,r[2*c]=1,e.depth[c]=0,e.opt_len--,n&&(e.static_len-=i[2*c+1]);for(t.max_code=l,o=e.heap_len>>1;o>=1;o--)ti(e,r,o);c=s;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],ti(e,r,1),a=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=a,r[2*c]=r[2*o]+r[2*a],e.depth[c]=(e.depth[o]>=e.depth[a]?e.depth[o]:e.depth[a])+1,r[2*o+1]=r[2*a+1]=c,e.heap[1]=c++,ti(e,r,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const r=t.dyn_tree,i=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,c=t.stat_desc.max_length;let l,d,u,_,h,p,f=0;for(_=0;_<=Nr;_++)e.bl_count[_]=0;for(r[2*e.heap[e.heap_max]+1]=0,l=e.heap_max+1;l<573;l++)d=e.heap[l],_=r[2*r[2*d+1]+1]+1,_>c&&(_=c,f++),r[2*d+1]=_,d>i||(e.bl_count[_]++,h=0,d>=a&&(h=o[d-a]),p=r[2*d],e.opt_len+=p*(_+h),s&&(e.static_len+=p*(n[2*d+1]+h)));if(0!==f){do{for(_=c-1;0===e.bl_count[_];)_--;e.bl_count[_]--,e.bl_count[_+1]+=2,e.bl_count[c]--,f-=2}while(f>0);for(_=c;0!==_;_--)for(d=e.bl_count[_];0!==d;)u=e.heap[--l],u>i||(r[2*u+1]!==_&&(e.opt_len+=(_-r[2*u+1])*r[2*u],r[2*u+1]=_),d--)}})(e,t),Qr(r,l,e.bl_count)},ni=(e,t,r)=>{let i,n,s=-1,o=t[1],a=0,c=7,l=4;for(0===o&&(c=138,l=3),t[2*(r+1)+1]=65535,i=0;i<=r;i++)n=o,o=t[2*(i+1)+1],++a<c&&n===o||(a<l?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?(c=138,l=3):n===o?(c=6,l=3):(c=7,l=4))},si=(e,t,r)=>{let i,n,s=-1,o=t[1],a=0,c=7,l=4;for(0===o&&(c=138,l=3),i=0;i<=r;i++)if(n=o,o=t[2*(i+1)+1],!(++a<c&&n===o)){if(a<l)do{Wr(e,n,e.bl_tree)}while(0!==--a);else 0!==n?(n!==s&&(Wr(e,n,e.bl_tree),a--),Wr(e,16,e.bl_tree),Yr(e,a-3,2)):a<=10?(Wr(e,17,e.bl_tree),Yr(e,a-3,3)):(Wr(e,18,e.bl_tree),Yr(e,a-11,7));a=0,s=n,0===o?(c=138,l=3):n===o?(c=6,l=3):(c=7,l=4)}};let oi=!1;const ai=(e,t,r,i)=>{Yr(e,0+(i?1:0),3),Xr(e),$r(e,r),$r(e,~r),r&&e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r};var ci=(e,t,r,i)=>{let n,s,o=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&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<yr;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),ii(e,e.l_desc),ii(e,e.d_desc),o=(e=>{let t;for(ni(e,e.dyn_ltree,e.l_desc.max_code),ni(e,e.dyn_dtree,e.d_desc.max_code),ii(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Ur[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=r+5,r+4<=n&&-1!==t?ai(e,t,r,i):4===e.strategy||s===n?(Yr(e,2+(i?1:0),3),ri(e,kr,Mr)):(Yr(e,4+(i?1:0),3),((e,t,r,i)=>{let n;for(Yr(e,t-257,5),Yr(e,r-1,5),Yr(e,i-4,4),n=0;n<i;n++)Yr(e,e.bl_tree[2*Ur[n]+1],3);si(e,e.dyn_ltree,t-1),si(e,e.dyn_dtree,r-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),ri(e,e.dyn_ltree,e.dyn_dtree)),Zr(e),i&&Xr(e)},li={_tr_init:e=>{oi||((()=>{let e,t,r,i,n;const s=new Array(16);for(r=0,i=0;i<28;i++)for(Vr[i]=r,e=0;e<1<<Pr[i];e++)Br[r++]=i;for(Br[r-1]=i,n=0,i=0;i<16;i++)for(Fr[i]=n,e=0;e<1<<wr[i];e++)xr[n++]=i;for(n>>=7;i<Ar;i++)for(Fr[i]=n<<7,e=0;e<1<<wr[i]-7;e++)xr[256+n++]=i;for(t=0;t<=Nr;t++)s[t]=0;for(e=0;e<=143;)kr[2*e+1]=8,e++,s[8]++;for(;e<=255;)kr[2*e+1]=9,e++,s[9]++;for(;e<=279;)kr[2*e+1]=7,e++,s[7]++;for(;e<=287;)kr[2*e+1]=8,e++,s[8]++;for(Qr(kr,287,s),e=0;e<Ar;e++)Mr[2*e+1]=5,Mr[2*e]=zr(e,5);Gr=new jr(kr,Pr,257,Lr,Nr),Jr=new jr(Mr,wr,0,Ar,Nr),Hr=new jr(new Array(0),Dr,0,19,7)})(),oi=!0),e.l_desc=new Kr(e.dyn_ltree,Gr),e.d_desc=new Kr(e.dyn_dtree,Jr),e.bl_desc=new Kr(e.bl_tree,Hr),e.bi_buf=0,e.bi_valid=0,Zr(e)},_tr_stored_block:ai,_tr_flush_block:ci,_tr_tally:(e,t,r)=>(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++]=r,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(Br[r]+yr+1)]++,e.dyn_dtree[2*qr(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Yr(e,2,3),Wr(e,256,kr),(e=>{16===e.bi_valid?($r(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 di=(e,t,r,i)=>{let n=65535&e,s=e>>>16&65535,o=0;for(;0!==r;){o=r>2e3?2e3:r,r-=o;do{n=n+t[i++]|0,s=s+n|0}while(--o);n%=65521,s%=65521}return n|s<<16};const ui=new Uint32Array((()=>{let e,t=[];for(var r=0;r<256;r++){e=r;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t})());var _i=(e,t,r,i)=>{const n=ui,s=i+r;e^=-1;for(let r=i;r<s;r++)e=e>>>8^n[255&(e^t[r])];return-1^e},hi={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"},pi={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:fi,_tr_stored_block:gi,_tr_flush_block:mi,_tr_tally:Ri,_tr_align:Ei}=li,{Z_NO_FLUSH:Ti,Z_PARTIAL_FLUSH:Ii,Z_FULL_FLUSH:Si,Z_FINISH:vi,Z_BLOCK:Oi,Z_OK:bi,Z_STREAM_END:Ci,Z_STREAM_ERROR:yi,Z_DATA_ERROR:Li,Z_BUF_ERROR:Ai,Z_DEFAULT_COMPRESSION:Ni,Z_FILTERED:Pi,Z_HUFFMAN_ONLY:wi,Z_RLE:Di,Z_FIXED:Ui,Z_DEFAULT_STRATEGY:ki,Z_UNKNOWN:Mi,Z_DEFLATED:xi}=pi,Bi=258,Vi=262,Fi=42,ji=113,Gi=666,Ji=(e,t)=>(e.msg=hi[t],t),Hi=e=>2*e-(e>4?9:0),Ki=e=>{let t=e.length;for(;--t>=0;)e[t]=0},qi=e=>{let t,r,i,n=e.w_size;t=e.hash_size,i=t;do{r=e.head[--i],e.head[i]=r>=n?r-n:0}while(--t);t=n,i=t;do{r=e.prev[--i],e.prev[i]=r>=n?r-n:0}while(--t)};let $i=(e,t,r)=>(t<<e.hash_shift^r)&e.hash_mask;const Yi=e=>{const t=e.state;let r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+r),e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))},Wi=(e,t)=>{mi(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Yi(e.strm)},zi=(e,t)=>{e.pending_buf[e.pending++]=t},Qi=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},Zi=(e,t,r,i)=>{let n=e.avail_in;return n>i&&(n=i),0===n?0:(e.avail_in-=n,t.set(e.input.subarray(e.next_in,e.next_in+n),r),1===e.state.wrap?e.adler=di(e.adler,t,n,r):2===e.state.wrap&&(e.adler=_i(e.adler,t,n,r)),e.next_in+=n,e.total_in+=n,n)},Xi=(e,t)=>{let r,i,n=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match;const c=e.strstart>e.w_size-Vi?e.strstart-(e.w_size-Vi):0,l=e.window,d=e.w_mask,u=e.prev,_=e.strstart+Bi;let h=l[s+o-1],p=l[s+o];e.prev_length>=e.good_match&&(n>>=2),a>e.lookahead&&(a=e.lookahead);do{if(r=t,l[r+o]===p&&l[r+o-1]===h&&l[r]===l[s]&&l[++r]===l[s+1]){s+=2,r++;do{}while(l[++s]===l[++r]&&l[++s]===l[++r]&&l[++s]===l[++r]&&l[++s]===l[++r]&&l[++s]===l[++r]&&l[++s]===l[++r]&&l[++s]===l[++r]&&l[++s]===l[++r]&&s<_);if(i=Bi-(_-s),s=_-Bi,i>o){if(e.match_start=t,o=i,i>=a)break;h=l[s+o-1],p=l[s+o]}}}while((t=u[t&d])>c&&0!==--n);return o<=e.lookahead?o:e.lookahead},en=e=>{const t=e.w_size;let r,i,n;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Vi)&&(e.window.set(e.window.subarray(t,t+t-i),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),qi(e),i+=t),0===e.strm.avail_in)break;if(r=Zi(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=r,e.lookahead+e.insert>=3)for(n=e.strstart-e.insert,e.ins_h=e.window[n],e.ins_h=$i(e,e.ins_h,e.window[n+1]);e.insert&&(e.ins_h=$i(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<Vi&&0!==e.strm.avail_in)},tn=(e,t)=>{let r,i,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(r=65535,n=e.bi_valid+42>>3,e.strm.avail_out<n)break;if(n=e.strm.avail_out-n,i=e.strstart-e.block_start,r>i+e.strm.avail_in&&(r=i+e.strm.avail_in),r>n&&(r=n),r<s&&(0===r&&t!==vi||t===Ti||r!==i+e.strm.avail_in))break;o=t===vi&&r===i+e.strm.avail_in?1:0,gi(e,0,0,o),e.pending_buf[e.pending-4]=r,e.pending_buf[e.pending-3]=r>>8,e.pending_buf[e.pending-2]=~r,e.pending_buf[e.pending-1]=~r>>8,Yi(e.strm),i&&(i>r&&(i=r),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+i),e.strm.next_out),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i,e.block_start+=i,r-=i),r&&(Zi(e.strm,e.strm.output,e.strm.next_out,r),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r)}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!==Ti&&t!==vi&&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&&(Zi(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,i=e.strstart-e.block_start,(i>=s||(i||t===vi)&&t!==Ti&&0===e.strm.avail_in&&i<=n)&&(r=i>n?n:i,o=t===vi&&0===e.strm.avail_in&&r===i?1:0,gi(e,e.block_start,r,o),e.block_start+=r,Yi(e.strm)),o?3:1)},rn=(e,t)=>{let r,i;for(;;){if(e.lookahead<Vi){if(en(e),e.lookahead<Vi&&t===Ti)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=$i(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-Vi&&(e.match_length=Xi(e,r)),e.match_length>=3)if(i=Ri(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=$i(e,e.ins_h,e.window[e.strstart+3-1]),r=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=$i(e,e.ins_h,e.window[e.strstart+1]);else i=Ri(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(Wi(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===vi?(Wi(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Wi(e,!1),0===e.strm.avail_out)?1:2},nn=(e,t)=>{let r,i,n;for(;;){if(e.lookahead<Vi){if(en(e),e.lookahead<Vi&&t===Ti)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=$i(e,e.ins_h,e.window[e.strstart+3-1]),r=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!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-Vi&&(e.match_length=Xi(e,r),e.match_length<=5&&(e.strategy===Pi||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,i=Ri(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=$i(e,e.ins_h,e.window[e.strstart+3-1]),r=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++,i&&(Wi(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(i=Ri(e,0,e.window[e.strstart-1]),i&&Wi(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&&(i=Ri(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===vi?(Wi(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Wi(e,!1),0===e.strm.avail_out)?1:2};function sn(e,t,r,i,n){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=i,this.func=n}const on=[new sn(0,0,0,0,tn),new sn(4,4,8,4,rn),new sn(4,5,16,8,rn),new sn(4,6,32,32,rn),new sn(4,4,16,16,nn),new sn(8,16,32,32,nn),new sn(8,16,128,128,nn),new sn(8,32,128,256,nn),new sn(32,128,258,1024,nn),new sn(32,258,258,4096,nn)];function an(){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=xi,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),Ki(this.dyn_ltree),Ki(this.dyn_dtree),Ki(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),Ki(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Ki(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 cn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==Fi&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==ji&&t.status!==Gi?1:0},ln=e=>{if(cn(e))return Ji(e,yi);e.total_in=e.total_out=0,e.data_type=Mi;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?Fi:ji,e.adler=2===t.wrap?0:1,t.last_flush=-2,fi(t),bi},dn=e=>{const t=ln(e);var r;return t===bi&&((r=e.state).window_size=2*r.w_size,Ki(r.head),r.max_lazy_match=on[r.level].max_lazy,r.good_match=on[r.level].good_length,r.nice_match=on[r.level].nice_length,r.max_chain_length=on[r.level].max_chain,r.strstart=0,r.block_start=0,r.lookahead=0,r.insert=0,r.match_length=r.prev_length=2,r.match_available=0,r.ins_h=0),t},un=(e,t,r,i,n,s)=>{if(!e)return yi;let o=1;if(t===Ni&&(t=6),i<0?(o=0,i=-i):i>15&&(o=2,i-=16),n<1||n>9||r!==xi||i<8||i>15||t<0||t>9||s<0||s>Ui||8===i&&1!==o)return Ji(e,yi);8===i&&(i=9);const a=new an;return e.state=a,a.strm=e,a.status=Fi,a.wrap=o,a.gzhead=null,a.w_bits=i,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=r,dn(e)};var _n={deflateInit:(e,t)=>un(e,t,xi,15,8,ki),deflateInit2:un,deflateReset:dn,deflateResetKeep:ln,deflateSetHeader:(e,t)=>cn(e)||2!==e.state.wrap?yi:(e.state.gzhead=t,bi),deflate:(e,t)=>{if(cn(e)||t>Oi||t<0)return e?Ji(e,yi):yi;const r=e.state;if(!e.output||0!==e.avail_in&&!e.input||r.status===Gi&&t!==vi)return Ji(e,0===e.avail_out?Ai:yi);const i=r.last_flush;if(r.last_flush=t,0!==r.pending){if(Yi(e),0===e.avail_out)return r.last_flush=-1,bi}else if(0===e.avail_in&&Hi(t)<=Hi(i)&&t!==vi)return Ji(e,Ai);if(r.status===Gi&&0!==e.avail_in)return Ji(e,Ai);if(r.status===Fi&&0===r.wrap&&(r.status=ji),r.status===Fi){let t=xi+(r.w_bits-8<<4)<<8,i=-1;if(i=r.strategy>=wi||r.level<2?0:r.level<6?1:6===r.level?2:3,t|=i<<6,0!==r.strstart&&(t|=32),t+=31-t%31,Qi(r,t),0!==r.strstart&&(Qi(r,e.adler>>>16),Qi(r,65535&e.adler)),e.adler=1,r.status=ji,Yi(e),0!==r.pending)return r.last_flush=-1,bi}if(57===r.status)if(e.adler=0,zi(r,31),zi(r,139),zi(r,8),r.gzhead)zi(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),zi(r,255&r.gzhead.time),zi(r,r.gzhead.time>>8&255),zi(r,r.gzhead.time>>16&255),zi(r,r.gzhead.time>>24&255),zi(r,9===r.level?2:r.strategy>=wi||r.level<2?4:0),zi(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(zi(r,255&r.gzhead.extra.length),zi(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=_i(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69;else if(zi(r,0),zi(r,0),zi(r,0),zi(r,0),zi(r,0),zi(r,9===r.level?2:r.strategy>=wi||r.level<2?4:0),zi(r,3),r.status=ji,Yi(e),0!==r.pending)return r.last_flush=-1,bi;if(69===r.status){if(r.gzhead.extra){let t=r.pending,i=(65535&r.gzhead.extra.length)-r.gzindex;for(;r.pending+i>r.pending_buf_size;){let n=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+n),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>t&&(e.adler=_i(e.adler,r.pending_buf,r.pending-t,t)),r.gzindex+=n,Yi(e),0!==r.pending)return r.last_flush=-1,bi;t=0,i-=n}let n=new Uint8Array(r.gzhead.extra);r.pending_buf.set(n.subarray(r.gzindex,r.gzindex+i),r.pending),r.pending+=i,r.gzhead.hcrc&&r.pending>t&&(e.adler=_i(e.adler,r.pending_buf,r.pending-t,t)),r.gzindex=0}r.status=73}if(73===r.status){if(r.gzhead.name){let t,i=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>i&&(e.adler=_i(e.adler,r.pending_buf,r.pending-i,i)),Yi(e),0!==r.pending)return r.last_flush=-1,bi;i=0}t=r.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,zi(r,t)}while(0!==t);r.gzhead.hcrc&&r.pending>i&&(e.adler=_i(e.adler,r.pending_buf,r.pending-i,i)),r.gzindex=0}r.status=91}if(91===r.status){if(r.gzhead.comment){let t,i=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>i&&(e.adler=_i(e.adler,r.pending_buf,r.pending-i,i)),Yi(e),0!==r.pending)return r.last_flush=-1,bi;i=0}t=r.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,zi(r,t)}while(0!==t);r.gzhead.hcrc&&r.pending>i&&(e.adler=_i(e.adler,r.pending_buf,r.pending-i,i))}r.status=103}if(103===r.status){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(Yi(e),0!==r.pending))return r.last_flush=-1,bi;zi(r,255&e.adler),zi(r,e.adler>>8&255),e.adler=0}if(r.status=ji,Yi(e),0!==r.pending)return r.last_flush=-1,bi}if(0!==e.avail_in||0!==r.lookahead||t!==Ti&&r.status!==Gi){let i=0===r.level?tn(r,t):r.strategy===wi?((e,t)=>{let r;for(;;){if(0===e.lookahead&&(en(e),0===e.lookahead)){if(t===Ti)return 1;break}if(e.match_length=0,r=Ri(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(Wi(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===vi?(Wi(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Wi(e,!1),0===e.strm.avail_out)?1:2})(r,t):r.strategy===Di?((e,t)=>{let r,i,n,s;const o=e.window;for(;;){if(e.lookahead<=Bi){if(en(e),e.lookahead<=Bi&&t===Ti)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=e.strstart-1,i=o[n],i===o[++n]&&i===o[++n]&&i===o[++n])){s=e.strstart+Bi;do{}while(i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&n<s);e.match_length=Bi-(s-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=Ri(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=Ri(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(Wi(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===vi?(Wi(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Wi(e,!1),0===e.strm.avail_out)?1:2})(r,t):on[r.level].func(r,t);if(3!==i&&4!==i||(r.status=Gi),1===i||3===i)return 0===e.avail_out&&(r.last_flush=-1),bi;if(2===i&&(t===Ii?Ei(r):t!==Oi&&(gi(r,0,0,!1),t===Si&&(Ki(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),Yi(e),0===e.avail_out))return r.last_flush=-1,bi}return t!==vi?bi:r.wrap<=0?Ci:(2===r.wrap?(zi(r,255&e.adler),zi(r,e.adler>>8&255),zi(r,e.adler>>16&255),zi(r,e.adler>>24&255),zi(r,255&e.total_in),zi(r,e.total_in>>8&255),zi(r,e.total_in>>16&255),zi(r,e.total_in>>24&255)):(Qi(r,e.adler>>>16),Qi(r,65535&e.adler)),Yi(e),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?bi:Ci)},deflateEnd:e=>{if(cn(e))return yi;const t=e.state.status;return e.state=null,t===ji?Ji(e,Li):bi},deflateSetDictionary:(e,t)=>{let r=t.length;if(cn(e))return yi;const i=e.state,n=i.wrap;if(2===n||1===n&&i.status!==Fi||i.lookahead)return yi;if(1===n&&(e.adler=di(e.adler,t,r,0)),i.wrap=0,r>=i.w_size){0===n&&(Ki(i.head),i.strstart=0,i.block_start=0,i.insert=0);let e=new Uint8Array(i.w_size);e.set(t.subarray(r-i.w_size,r),0),t=e,r=i.w_size}const s=e.avail_in,o=e.next_in,a=e.input;for(e.avail_in=r,e.next_in=0,e.input=t,en(i);i.lookahead>=3;){let e=i.strstart,t=i.lookahead-2;do{i.ins_h=$i(i,i.ins_h,i.window[e+3-1]),i.prev[e&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=e,e++}while(--t);i.strstart=e,i.lookahead=2,en(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,e.next_in=o,e.input=a,e.avail_in=s,i.wrap=n,bi},deflateInfo:"pako deflate (from Nodeca project)"};const hn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var pn=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(const t in r)hn(r,t)&&(e[t]=r[t])}}return e},fn=e=>{let t=0;for(let r=0,i=e.length;r<i;r++)t+=e[r].length;const r=new Uint8Array(t);for(let t=0,i=0,n=e.length;t<n;t++){let n=e[t];r.set(n,i),i+=n.length}return r};let gn=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){gn=!1}const mn=new Uint8Array(256);for(let e=0;e<256;e++)mn[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;mn[254]=mn[254]=1;var Rn=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,r,i,n,s,o=e.length,a=0;for(n=0;n<o;n++)r=e.charCodeAt(n),55296==(64512&r)&&n+1<o&&(i=e.charCodeAt(n+1),56320==(64512&i)&&(r=65536+(r-55296<<10)+(i-56320),n++)),a+=r<128?1:r<2048?2:r<65536?3:4;for(t=new Uint8Array(a),s=0,n=0;s<a;n++)r=e.charCodeAt(n),55296==(64512&r)&&n+1<o&&(i=e.charCodeAt(n+1),56320==(64512&i)&&(r=65536+(r-55296<<10)+(i-56320),n++)),r<128?t[s++]=r:r<2048?(t[s++]=192|r>>>6,t[s++]=128|63&r):r<65536?(t[s++]=224|r>>>12,t[s++]=128|r>>>6&63,t[s++]=128|63&r):(t[s++]=240|r>>>18,t[s++]=128|r>>>12&63,t[s++]=128|r>>>6&63,t[s++]=128|63&r);return t},En=(e,t)=>{const r=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let i,n;const s=new Array(2*r);for(n=0,i=0;i<r;){let t=e[i++];if(t<128){s[n++]=t;continue}let o=mn[t];if(o>4)s[n++]=65533,i+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&i<r;)t=t<<6|63&e[i++],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&&gn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let r="";for(let i=0;i<t;i++)r+=String.fromCharCode(e[i]);return r})(s,n)},Tn=(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let r=t-1;for(;r>=0&&128==(192&e[r]);)r--;return r<0||0===r?t:r+mn[e[r]]>t?r:t};var In=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:vn,Z_SYNC_FLUSH:On,Z_FULL_FLUSH:bn,Z_FINISH:Cn,Z_OK:yn,Z_STREAM_END:Ln,Z_DEFAULT_COMPRESSION:An,Z_DEFAULT_STRATEGY:Nn,Z_DEFLATED:Pn}=pi;function wn(e){this.options=pn({level:An,method:Pn,chunkSize:16384,windowBits:15,memLevel:8,strategy:Nn},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 In,this.strm.avail_out=0;let r=_n.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==yn)throw new Error(hi[r]);if(t.header&&_n.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Rn(t.dictionary):"[object ArrayBuffer]"===Sn.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,r=_n.deflateSetDictionary(this.strm,e),r!==yn)throw new Error(hi[r]);this._dict_set=!0}}function Dn(e,t){const r=new wn(t);if(r.push(e,!0),r.err)throw r.msg||hi[r.err];return r.result}wn.prototype.push=function(e,t){const r=this.strm,i=this.options.chunkSize;let n,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Cn:vn,"string"==typeof e?r.input=Rn(e):"[object ArrayBuffer]"===Sn.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;)if(0===r.avail_out&&(r.output=new Uint8Array(i),r.next_out=0,r.avail_out=i),(s===On||s===bn)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if(n=_n.deflate(r,s),n===Ln)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),n=_n.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===yn;if(0!==r.avail_out){if(s>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(0===r.avail_in)break}else this.onData(r.output)}return!0},wn.prototype.onData=function(e){this.chunks.push(e)},wn.prototype.onEnd=function(e){e===yn&&(this.result=fn(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Un={Deflate:wn,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:pi};const kn=16209;var Mn=function(e,t){let r,i,n,s,o,a,c,l,d,u,_,h,p,f,g,m,R,E,T,I,S,v,O,b;const C=e.state;r=e.next_in,O=e.input,i=r+(e.avail_in-5),n=e.next_out,b=e.output,s=n-(t-e.avail_out),o=n+(e.avail_out-257),a=C.dmax,c=C.wsize,l=C.whave,d=C.wnext,u=C.window,_=C.hold,h=C.bits,p=C.lencode,f=C.distcode,g=(1<<C.lenbits)-1,m=(1<<C.distbits)-1;e:do{h<15&&(_+=O[r++]<<h,h+=8,_+=O[r++]<<h,h+=8),R=p[_&g];t:for(;;){if(E=R>>>24,_>>>=E,h-=E,E=R>>>16&255,0===E)b[n++]=65535&R;else{if(!(16&E)){if(64&E){if(32&E){C.mode=16191;break e}e.msg="invalid literal/length code",C.mode=kn;break e}R=p[(65535&R)+(_&(1<<E)-1)];continue t}for(T=65535&R,E&=15,E&&(h<E&&(_+=O[r++]<<h,h+=8),T+=_&(1<<E)-1,_>>>=E,h-=E),h<15&&(_+=O[r++]<<h,h+=8,_+=O[r++]<<h,h+=8),R=f[_&m];;){if(E=R>>>24,_>>>=E,h-=E,E=R>>>16&255,16&E){if(I=65535&R,E&=15,h<E&&(_+=O[r++]<<h,h+=8,h<E&&(_+=O[r++]<<h,h+=8)),I+=_&(1<<E)-1,I>a){e.msg="invalid distance too far back",C.mode=kn;break e}if(_>>>=E,h-=E,E=n-s,I>E){if(E=I-E,E>l&&C.sane){e.msg="invalid distance too far back",C.mode=kn;break e}if(S=0,v=u,0===d){if(S+=c-E,E<T){T-=E;do{b[n++]=u[S++]}while(--E);S=n-I,v=b}}else if(d<E){if(S+=c+d-E,E-=d,E<T){T-=E;do{b[n++]=u[S++]}while(--E);if(S=0,d<T){E=d,T-=E;do{b[n++]=u[S++]}while(--E);S=n-I,v=b}}}else if(S+=d-E,E<T){T-=E;do{b[n++]=u[S++]}while(--E);S=n-I,v=b}for(;T>2;)b[n++]=v[S++],b[n++]=v[S++],b[n++]=v[S++],T-=3;T&&(b[n++]=v[S++],T>1&&(b[n++]=v[S++]))}else{S=n-I;do{b[n++]=b[S++],b[n++]=b[S++],b[n++]=b[S++],T-=3}while(T>2);T&&(b[n++]=b[S++],T>1&&(b[n++]=b[S++]))}break}if(64&E){e.msg="invalid distance code",C.mode=kn;break e}R=f[(65535&R)+(_&(1<<E)-1)]}}break}}while(r<i&&n<o);T=h>>3,r-=T,h-=T<<3,_&=(1<<h)-1,e.next_in=r,e.next_out=n,e.avail_in=r<i?i-r+5:5-(r-i),e.avail_out=n<o?o-n+257:257-(n-o),C.hold=_,C.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]),Fn=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]),jn=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 Gn=(e,t,r,i,n,s,o,a)=>{const c=a.bits;let l,d,u,_,h,p,f=0,g=0,m=0,R=0,E=0,T=0,I=0,S=0,v=0,O=0,b=null;const C=new Uint16Array(16),y=new Uint16Array(16);let L,A,N,P=null;for(f=0;f<=xn;f++)C[f]=0;for(g=0;g<i;g++)C[t[r+g]]++;for(E=c,R=xn;R>=1&&0===C[R];R--);if(E>R&&(E=R),0===R)return n[s++]=20971520,n[s++]=20971520,a.bits=1,0;for(m=1;m<R&&0===C[m];m++);for(E<m&&(E=m),S=1,f=1;f<=xn;f++)if(S<<=1,S-=C[f],S<0)return-1;if(S>0&&(0===e||1!==R))return-1;for(y[1]=0,f=1;f<xn;f++)y[f+1]=y[f]+C[f];for(g=0;g<i;g++)0!==t[r+g]&&(o[y[t[r+g]]++]=g);if(0===e?(b=P=o,p=20):1===e?(b=Bn,P=Vn,p=257):(b=Fn,P=jn,p=0),O=0,g=0,f=m,h=s,T=E,I=0,u=-1,v=1<<E,_=v-1,1===e&&v>852||2===e&&v>592)return 1;for(;;){L=f-I,o[g]+1<p?(A=0,N=o[g]):o[g]>=p?(A=P[o[g]-p],N=b[o[g]-p]):(A=96,N=0),l=1<<f-I,d=1<<T,m=d;do{d-=l,n[h+(O>>I)+d]=L<<24|A<<16|N}while(0!==d);for(l=1<<f-1;O&l;)l>>=1;if(0!==l?(O&=l-1,O+=l):O=0,g++,0===--C[f]){if(f===R)break;f=t[r+o[g]]}if(f>E&&(O&_)!==u){for(0===I&&(I=E),h+=m,T=f-I,S=1<<T;T+I<R&&(S-=C[T+I],!(S<=0));)T++,S<<=1;if(v+=1<<T,1===e&&v>852||2===e&&v>592)return 1;u=O&_,n[u]=E<<24|T<<16|h-s}}return 0!==O&&(n[h+O]=f-I<<24|64<<16),a.bits=E,0};const{Z_FINISH:Jn,Z_BLOCK:Hn,Z_TREES:Kn,Z_OK:qn,Z_STREAM_END:$n,Z_NEED_DICT:Yn,Z_STREAM_ERROR:Wn,Z_DATA_ERROR:zn,Z_MEM_ERROR:Qn,Z_BUF_ERROR:Zn,Z_DEFLATED:Xn}=pi,es=16180,ts=16190,rs=16191,is=16192,ns=16194,ss=16199,os=16200,as=16206,cs=16209,ls=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function ds(){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 us=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<es||t.mode>16211?1:0},_s=e=>{if(us(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,qn},hs=e=>{if(us(e))return Wn;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,_s(e)},ps=(e,t)=>{let r;if(us(e))return Wn;const i=e.state;return t<0?(r=0,t=-t):(r=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Wn:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=r,i.wbits=t,hs(e))},fs=(e,t)=>{if(!e)return Wn;const r=new ds;e.state=r,r.strm=e,r.window=null,r.mode=es;const i=ps(e,t);return i!==qn&&(e.state=null),i};let gs,ms,Rs=!0;const Es=e=>{if(Rs){gs=new Int32Array(512),ms=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(Gn(1,e.lens,0,288,gs,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Gn(2,e.lens,0,32,ms,0,e.work,{bits:5}),Rs=!1}e.lencode=gs,e.lenbits=9,e.distcode=ms,e.distbits=5},Ts=(e,t,r,i)=>{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)),i>=s.wsize?(s.window.set(t.subarray(r-s.wsize,r),0),s.wnext=0,s.whave=s.wsize):(n=s.wsize-s.wnext,n>i&&(n=i),s.window.set(t.subarray(r-i,r-i+n),s.wnext),(i-=n)?(s.window.set(t.subarray(r-i,r),0),s.wnext=i,s.whave=s.wsize):(s.wnext+=n,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=n))),0};var Is={inflateReset:hs,inflateReset2:ps,inflateResetKeep:_s,inflateInit:e=>fs(e,15),inflateInit2:fs,inflate:(e,t)=>{let r,i,n,s,o,a,c,l,d,u,_,h,p,f,g,m,R,E,T,I,S,v,O=0;const b=new Uint8Array(4);let C,y;const L=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(us(e)||!e.output||!e.input&&0!==e.avail_in)return Wn;r=e.state,r.mode===rs&&(r.mode=is),o=e.next_out,n=e.output,c=e.avail_out,s=e.next_in,i=e.input,a=e.avail_in,l=r.hold,d=r.bits,u=a,_=c,v=qn;e:for(;;)switch(r.mode){case es:if(0===r.wrap){r.mode=is;break}for(;d<16;){if(0===a)break e;a--,l+=i[s++]<<d,d+=8}if(2&r.wrap&&35615===l){0===r.wbits&&(r.wbits=15),r.check=0,b[0]=255&l,b[1]=l>>>8&255,r.check=_i(r.check,b,2,0),l=0,d=0,r.mode=16181;break}if(r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg="incorrect header check",r.mode=cs;break}if((15&l)!==Xn){e.msg="unknown compression method",r.mode=cs;break}if(l>>>=4,d-=4,S=8+(15&l),0===r.wbits&&(r.wbits=S),S>15||S>r.wbits){e.msg="invalid window size",r.mode=cs;break}r.dmax=1<<r.wbits,r.flags=0,e.adler=r.check=1,r.mode=512&l?16189:rs,l=0,d=0;break;case 16181:for(;d<16;){if(0===a)break e;a--,l+=i[s++]<<d,d+=8}if(r.flags=l,(255&r.flags)!==Xn){e.msg="unknown compression method",r.mode=cs;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=cs;break}r.head&&(r.head.text=l>>8&1),512&r.flags&&4&r.wrap&&(b[0]=255&l,b[1]=l>>>8&255,r.check=_i(r.check,b,2,0)),l=0,d=0,r.mode=16182;case 16182:for(;d<32;){if(0===a)break e;a--,l+=i[s++]<<d,d+=8}r.head&&(r.head.time=l),512&r.flags&&4&r.wrap&&(b[0]=255&l,b[1]=l>>>8&255,b[2]=l>>>16&255,b[3]=l>>>24&255,r.check=_i(r.check,b,4,0)),l=0,d=0,r.mode=16183;case 16183:for(;d<16;){if(0===a)break e;a--,l+=i[s++]<<d,d+=8}r.head&&(r.head.xflags=255&l,r.head.os=l>>8),512&r.flags&&4&r.wrap&&(b[0]=255&l,b[1]=l>>>8&255,r.check=_i(r.check,b,2,0)),l=0,d=0,r.mode=16184;case 16184:if(1024&r.flags){for(;d<16;){if(0===a)break e;a--,l+=i[s++]<<d,d+=8}r.length=l,r.head&&(r.head.extra_len=l),512&r.flags&&4&r.wrap&&(b[0]=255&l,b[1]=l>>>8&255,r.check=_i(r.check,b,2,0)),l=0,d=0}else r.head&&(r.head.extra=null);r.mode=16185;case 16185:if(1024&r.flags&&(h=r.length,h>a&&(h=a),h&&(r.head&&(S=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(i.subarray(s,s+h),S)),512&r.flags&&4&r.wrap&&(r.check=_i(r.check,i,h,s)),a-=h,s+=h,r.length-=h),r.length))break e;r.length=0,r.mode=16186;case 16186:if(2048&r.flags){if(0===a)break e;h=0;do{S=i[s+h++],r.head&&S&&r.length<65536&&(r.head.name+=String.fromCharCode(S))}while(S&&h<a);if(512&r.flags&&4&r.wrap&&(r.check=_i(r.check,i,h,s)),a-=h,s+=h,S)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=16187;case 16187:if(4096&r.flags){if(0===a)break e;h=0;do{S=i[s+h++],r.head&&S&&r.length<65536&&(r.head.comment+=String.fromCharCode(S))}while(S&&h<a);if(512&r.flags&&4&r.wrap&&(r.check=_i(r.check,i,h,s)),a-=h,s+=h,S)break e}else r.head&&(r.head.comment=null);r.mode=16188;case 16188:if(512&r.flags){for(;d<16;){if(0===a)break e;a--,l+=i[s++]<<d,d+=8}if(4&r.wrap&&l!==(65535&r.check)){e.msg="header crc mismatch",r.mode=cs;break}l=0,d=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=rs;break;case 16189:for(;d<32;){if(0===a)break e;a--,l+=i[s++]<<d,d+=8}e.adler=r.check=ls(l),l=0,d=0,r.mode=ts;case ts:if(0===r.havedict)return e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,r.hold=l,r.bits=d,Yn;e.adler=r.check=1,r.mode=rs;case rs:if(t===Hn||t===Kn)break e;case is:if(r.last){l>>>=7&d,d-=7&d,r.mode=as;break}for(;d<3;){if(0===a)break e;a--,l+=i[s++]<<d,d+=8}switch(r.last=1&l,l>>>=1,d-=1,3&l){case 0:r.mode=16193;break;case 1:if(Es(r),r.mode=ss,t===Kn){l>>>=2,d-=2;break e}break;case 2:r.mode=16196;break;case 3:e.msg="invalid block type",r.mode=cs}l>>>=2,d-=2;break;case 16193:for(l>>>=7&d,d-=7&d;d<32;){if(0===a)break e;a--,l+=i[s++]<<d,d+=8}if((65535&l)!=(l>>>16^65535)){e.msg="invalid stored block lengths",r.mode=cs;break}if(r.length=65535&l,l=0,d=0,r.mode=ns,t===Kn)break e;case ns:r.mode=16195;case 16195:if(h=r.length,h){if(h>a&&(h=a),h>c&&(h=c),0===h)break e;n.set(i.subarray(s,s+h),o),a-=h,s+=h,c-=h,o+=h,r.length-=h;break}r.mode=rs;break;case 16196:for(;d<14;){if(0===a)break e;a--,l+=i[s++]<<d,d+=8}if(r.nlen=257+(31&l),l>>>=5,d-=5,r.ndist=1+(31&l),l>>>=5,d-=5,r.ncode=4+(15&l),l>>>=4,d-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=cs;break}r.have=0,r.mode=16197;case 16197:for(;r.have<r.ncode;){for(;d<3;){if(0===a)break e;a--,l+=i[s++]<<d,d+=8}r.lens[L[r.have++]]=7&l,l>>>=3,d-=3}for(;r.have<19;)r.lens[L[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,C={bits:r.lenbits},v=Gn(0,r.lens,0,19,r.lencode,0,r.work,C),r.lenbits=C.bits,v){e.msg="invalid code lengths set",r.mode=cs;break}r.have=0,r.mode=16198;case 16198:for(;r.have<r.nlen+r.ndist;){for(;O=r.lencode[l&(1<<r.lenbits)-1],g=O>>>24,m=O>>>16&255,R=65535&O,!(g<=d);){if(0===a)break e;a--,l+=i[s++]<<d,d+=8}if(R<16)l>>>=g,d-=g,r.lens[r.have++]=R;else{if(16===R){for(y=g+2;d<y;){if(0===a)break e;a--,l+=i[s++]<<d,d+=8}if(l>>>=g,d-=g,0===r.have){e.msg="invalid bit length repeat",r.mode=cs;break}S=r.lens[r.have-1],h=3+(3&l),l>>>=2,d-=2}else if(17===R){for(y=g+3;d<y;){if(0===a)break e;a--,l+=i[s++]<<d,d+=8}l>>>=g,d-=g,S=0,h=3+(7&l),l>>>=3,d-=3}else{for(y=g+7;d<y;){if(0===a)break e;a--,l+=i[s++]<<d,d+=8}l>>>=g,d-=g,S=0,h=11+(127&l),l>>>=7,d-=7}if(r.have+h>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=cs;break}for(;h--;)r.lens[r.have++]=S}}if(r.mode===cs)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=cs;break}if(r.lenbits=9,C={bits:r.lenbits},v=Gn(1,r.lens,0,r.nlen,r.lencode,0,r.work,C),r.lenbits=C.bits,v){e.msg="invalid literal/lengths set",r.mode=cs;break}if(r.distbits=6,r.distcode=r.distdyn,C={bits:r.distbits},v=Gn(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,C),r.distbits=C.bits,v){e.msg="invalid distances set",r.mode=cs;break}if(r.mode=ss,t===Kn)break e;case ss:r.mode=os;case os:if(a>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,r.hold=l,r.bits=d,Mn(e,_),o=e.next_out,n=e.output,c=e.avail_out,s=e.next_in,i=e.input,a=e.avail_in,l=r.hold,d=r.bits,r.mode===rs&&(r.back=-1);break}for(r.back=0;O=r.lencode[l&(1<<r.lenbits)-1],g=O>>>24,m=O>>>16&255,R=65535&O,!(g<=d);){if(0===a)break e;a--,l+=i[s++]<<d,d+=8}if(m&&!(240&m)){for(E=g,T=m,I=R;O=r.lencode[I+((l&(1<<E+T)-1)>>E)],g=O>>>24,m=O>>>16&255,R=65535&O,!(E+g<=d);){if(0===a)break e;a--,l+=i[s++]<<d,d+=8}l>>>=E,d-=E,r.back+=E}if(l>>>=g,d-=g,r.back+=g,r.length=R,0===m){r.mode=16205;break}if(32&m){r.back=-1,r.mode=rs;break}if(64&m){e.msg="invalid literal/length code",r.mode=cs;break}r.extra=15&m,r.mode=16201;case 16201:if(r.extra){for(y=r.extra;d<y;){if(0===a)break e;a--,l+=i[s++]<<d,d+=8}r.length+=l&(1<<r.extra)-1,l>>>=r.extra,d-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=16202;case 16202:for(;O=r.distcode[l&(1<<r.distbits)-1],g=O>>>24,m=O>>>16&255,R=65535&O,!(g<=d);){if(0===a)break e;a--,l+=i[s++]<<d,d+=8}if(!(240&m)){for(E=g,T=m,I=R;O=r.distcode[I+((l&(1<<E+T)-1)>>E)],g=O>>>24,m=O>>>16&255,R=65535&O,!(E+g<=d);){if(0===a)break e;a--,l+=i[s++]<<d,d+=8}l>>>=E,d-=E,r.back+=E}if(l>>>=g,d-=g,r.back+=g,64&m){e.msg="invalid distance code",r.mode=cs;break}r.offset=R,r.extra=15&m,r.mode=16203;case 16203:if(r.extra){for(y=r.extra;d<y;){if(0===a)break e;a--,l+=i[s++]<<d,d+=8}r.offset+=l&(1<<r.extra)-1,l>>>=r.extra,d-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=cs;break}r.mode=16204;case 16204:if(0===c)break e;if(h=_-c,r.offset>h){if(h=r.offset-h,h>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=cs;break}h>r.wnext?(h-=r.wnext,p=r.wsize-h):p=r.wnext-h,h>r.length&&(h=r.length),f=r.window}else f=n,p=o-r.offset,h=r.length;h>c&&(h=c),c-=h,r.length-=h;do{n[o++]=f[p++]}while(--h);0===r.length&&(r.mode=os);break;case 16205:if(0===c)break e;n[o++]=r.length,c--,r.mode=os;break;case as:if(r.wrap){for(;d<32;){if(0===a)break e;a--,l|=i[s++]<<d,d+=8}if(_-=c,e.total_out+=_,r.total+=_,4&r.wrap&&_&&(e.adler=r.check=r.flags?_i(r.check,n,_,o-_):di(r.check,n,_,o-_)),_=c,4&r.wrap&&(r.flags?l:ls(l))!==r.check){e.msg="incorrect data check",r.mode=cs;break}l=0,d=0}r.mode=16207;case 16207:if(r.wrap&&r.flags){for(;d<32;){if(0===a)break e;a--,l+=i[s++]<<d,d+=8}if(4&r.wrap&&l!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=cs;break}l=0,d=0}r.mode=16208;case 16208:v=$n;break e;case cs:v=zn;break e;case 16210:return Qn;default:return Wn}return e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,r.hold=l,r.bits=d,(r.wsize||_!==e.avail_out&&r.mode<cs&&(r.mode<as||t!==Jn))&&Ts(e,e.output,e.next_out,_-e.avail_out),u-=e.avail_in,_-=e.avail_out,e.total_in+=u,e.total_out+=_,r.total+=_,4&r.wrap&&_&&(e.adler=r.check=r.flags?_i(r.check,n,_,e.next_out-_):di(r.check,n,_,e.next_out-_)),e.data_type=r.bits+(r.last?64:0)+(r.mode===rs?128:0)+(r.mode===ss||r.mode===ns?256:0),(0===u&&0===_||t===Jn)&&v===qn&&(v=Zn),v},inflateEnd:e=>{if(us(e))return Wn;let t=e.state;return t.window&&(t.window=null),e.state=null,qn},inflateGetHeader:(e,t)=>{if(us(e))return Wn;const r=e.state;return 2&r.wrap?(r.head=t,t.done=!1,qn):Wn},inflateSetDictionary:(e,t)=>{const r=t.length;let i,n,s;return us(e)?Wn:(i=e.state,0!==i.wrap&&i.mode!==ts?Wn:i.mode===ts&&(n=1,n=di(n,t,r,0),n!==i.check)?zn:(s=Ts(e,t,r,r),s?(i.mode=16210,Qn):(i.havedict=1,qn)))},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 vs=Object.prototype.toString,{Z_NO_FLUSH:Os,Z_FINISH:bs,Z_OK:Cs,Z_STREAM_END:ys,Z_NEED_DICT:Ls,Z_STREAM_ERROR:As,Z_DATA_ERROR:Ns,Z_MEM_ERROR:Ps}=pi;function ws(e){this.options=pn({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 In,this.strm.avail_out=0;let r=Is.inflateInit2(this.strm,t.windowBits);if(r!==Cs)throw new Error(hi[r]);if(this.header=new Ss,Is.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Rn(t.dictionary):"[object ArrayBuffer]"===vs.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=Is.inflateSetDictionary(this.strm,t.dictionary),r!==Cs)))throw new Error(hi[r])}ws.prototype.push=function(e,t){const r=this.strm,i=this.options.chunkSize,n=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=t===~~t?t:!0===t?bs:Os,"[object ArrayBuffer]"===vs.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){for(0===r.avail_out&&(r.output=new Uint8Array(i),r.next_out=0,r.avail_out=i),s=Is.inflate(r,o),s===Ls&&n&&(s=Is.inflateSetDictionary(r,n),s===Cs?s=Is.inflate(r,o):s===Ns&&(s=Ls));r.avail_in>0&&s===ys&&r.state.wrap>0&&0!==e[r.next_in];)Is.inflateReset(r),s=Is.inflate(r,o);switch(s){case As:case Ns:case Ls:case Ps:return this.onEnd(s),this.ended=!0,!1}if(a=r.avail_out,r.next_out&&(0===r.avail_out||s===ys))if("string"===this.options.to){let e=Tn(r.output,r.next_out),t=r.next_out-e,n=En(r.output,e);r.next_out=t,r.avail_out=i-t,t&&r.output.set(r.output.subarray(e,e+t),0),this.onData(n)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(s!==Cs||0!==a){if(s===ys)return s=Is.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},ws.prototype.onData=function(e){this.chunks.push(e)},ws.prototype.onEnd=function(e){e===Cs&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=fn(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};const{Deflate:Ds,deflate:Us,deflateRaw:ks,gzip:Ms}=Un;var xs=Ms;const Bs=-1,Vs="RongCloudSEIAI",Fs=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),js=(e,t,r)=>v(void 0,void 0,void 0,function*(){const i=[],n=r.jwtToken||"";return new Promise((r,s)=>{e.forEach(e=>v(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 c={jwt:n};200===(yield t.httpReq({url:s,body:JSON.stringify(c),timeout:5e3,method:R.POST})).status&&i.push(e.clusterId),r(i)}))})}),Gs=(e,t)=>{var r;if(!t)return"";let i;try{i=JSON.parse(t.voipCallInfo||'{ "strategy": 0 }')}catch(r){return e.warn(ae.L_MEDIA_SERVICE_PARSE_NAVI_CALLVOIP_INFO_O,`parse \`voipCallInfo\` of navi failed: ${t.voipCallInfo}`),""}if(0===i.strategy)return"";const n=null===(r=i.callEngine)||void 0===r?void 0:r.filter(e=>4===e.engineType);if(!n||0===n.length)return"";const s=n[0];return s.detectorManager?s.detectorManager:""};var Js;!function(e){e.OPEN="2",e.CLOSE="1"}(Js||(Js={}));function Hs(e){const t=e.method||R.GET,r=e.timeout||6e4,{headers:i,query:n,body:s,onProgress:o}=e,a=((e,t)=>{if(e=e.replace(/\?$/,""),!t)return e;const r=Object.keys(t).map(e=>`${e}=${t[e]}`).filter(e=>!!e);return r.length?[e,r.join("&")].join("?"):e})(e.url,n),c=new XMLHttpRequest;if(c.open(t,a),i&&c.setRequestHeader)for(const e in i)c.setRequestHeader(e,i[e]);return function(e,t,r,i){return new Promise(n=>{e.onreadystatechange=()=>{i?2===e.readyState?n({data:e.responseText,status:e.status,xhr:e}):4===e.readyState?i(e.responseText,!0):3===e.readyState&&i(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(r)})}(c,r,s,o)}const Ks=()=>({"Content-Type":"application/json;charset=UTF-8","Cache-Control":"no-cache",ClientType:`web|${fr.browser}|${fr.version}`,ClientVersion:"5.36.1-nctest-alpha.3","Client-Session-Id":Fs(),"Request-Id":Date.now().toString()});class qs{constructor(e,t,r,i=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:r}),Object.defineProperty(this,"_timeout",{enumerable:!0,configurable:!0,writable:!0,value:i}),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()===ee.CONNECTED&&this.isNededDetector()&&this.detectorMediaSever()}isNededDetector(){const e=this._context.getNaviInfo();if(!e)return!1;const t=Gs(this._logger,e),r=e.jwtToken||"",i=Date.now();let n=!1;return 0===qs.detectorTime?n=!1:qs.detectValidMinute+qs.detectorTime<i&&(n=!0),!(!t||!r||this._msUrl||n)}detectorMediaSever(){this.clearMSList();const e=this._context.getNaviInfo();this._startDetector(e)}_startDetector(e){return v(this,void 0,void 0,function*(){var t;const{detectoraddrs:r,clientDetectMinute:i,status:n}=yield((e,t,r)=>v(void 0,void 0,void 0,function*(){const i=Gs(t,r);let n=120,s=0;const o={jwt:r.jwtToken||"",ipType:r.ipType||0},a=yield e.httpReq({url:`${i}/rtc/detector/servers`,body:JSON.stringify(o),headers:{"Content-Type":"application/json;charset=UTF-8","Cache-Control":"no-cache",ClientType:`web|${fr.browser}|${fr.version}`,ClientVersion:"5.36.1-nctest-alpha.3","Client-Session-Id":Fs(),"Request-Id":Date.now().toString()},method:R.POST}),c=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:c,clientDetectMinute:n,status:s}}))(this._runtime,this._logger,e);if(n===oe.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()}r.length&&(qs.msInDetector=yield js(r,this._runtime,e)),qs.detectorTime=Date.now(),qs.detectValidMinute=60*i*1e3})}clearMSList(){this._msList.length=0}getMsList(){return this._msUrl?[this._msUrl]:(this._sortMediaServiceList(),[...this._msList])}_sortMediaServiceList(){let e=qs.msInDetector[0];const t=qs.msInDetector.slice(1),r=((e,t)=>{var r;if(!e)return[];let i;try{i=JSON.parse(e.voipCallInfo||'{ "strategy": 0 }')}catch(r){return t.warn(ae.L_PARSE_VOIP_SERVER_CONF_E,e.voipCallInfo),[]}if(0===i.strategy)return[];const n=null===(r=i.callEngine)||void 0===r?void 0:r.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),i=r[0],n=r.slice(1);const s=[this._clusterId,e,i,...t,...n].filter(e=>!!e).map(e=>e.replace(/^(https?:\/\/)?/,"https://"));this._msList=[...new Set(s)],this._logger.info(ae.L_MEDIA_SERVICE_MSLIST_CHANGE_O,`MediaServiceList msList -> ${JSON.stringify(this._msList)}`)}_openGzip(e,t){const r=JSON.stringify(t),i=r.length,n=new Uint8Array(i);for(let e=0;e<i;e++)n[e]=r.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:oe.SUCCESS,data:t,qualityMsList:this._qualityMsList}}_request(e,t,r,i,n,s){return v(this,void 0,void 0,function*(){this._qualityMsList=[];const{headers:o,body:a}={headers:t,body:r},c=this.getMsList();if(0===c.length)return this._logger.error(ae.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:ce.FAILED,code:oe.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"have no valid service address"}),i),{code:oe.NOT_OPEN_VIDEO_AUDIO_SERVER};this._rtcFinger&&(a.rtcFinger=this._rtcFinger);for(let t=0;t<c.length;t+=1){const r=Date.now(),l=`${c[t]}${e}`,d=Ks(),u=Object.assign(Object.assign({},d),o),_=/x-www-form-urlencoded/.test(u["Content-Type"])?a:JSON.stringify(a),h=d["Request-Id"];let p;this._logger.info(ae.L_MEDIA_SERVICE_REQUEST_T,JSON.stringify({url:l,"Request-Id":h}),i);const f={url:l,body:_,headers:u,method:R.POST,timeout:this._timeout};p=s?yield Hs(Object.assign(Object.assign({},f),{onProgress:s})):yield this._runtime.httpReq(Object.assign({},f));const{status:g,data:m,xhr:E}=p;if(n&&this._qualityMsList.push({rsdur:Date.now()-r,rsid:h,rscod:200===g?oe.SUCCESS:oe.REQUEST_FAILED,msa:l}),200===g)return this._logger.info(ae.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:ce.SUCCESSED,url:l}),i),s?{code:oe.SUCCESS,data:E}:this._dealRequestSuccessResult(m);this._logger.error(ae.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:ce.FAILED,msg:`request error -> Request-Id: ${h}, status: ${g}, url: ${l}`,timeout:this._timeout}),i)}return{code:oe.REQUEST_FAILED,qualityMsList:this._qualityMsList}})}exchange(e,t,r,i){return v(this,void 0,void 0,function*(){var n;const s=yield this._request("/exchange",e,t,r,i);if(s.code===oe.SUCCESS&&(null===(n=s.data)||void 0===n?void 0:n.resultCode)===oe.SUCCESS){const{urls:e}=s.data;e&&(this._configUrl=e.configUrl)}return s})}exit(e){return v(this,void 0,void 0,function*(){const t=this._logger.createTraceId(),{code:r}=yield this._request("/exit",e,{},t);return r})}broadcastSubscribe(e,t){const r=this._logger.createTraceId();return this._request("/broadcast/subscribe",e,t,r,!0)}broadcastExit(e){return v(this,void 0,void 0,function*(){const t=this._logger.createTraceId(),{code:r}=yield this._request("/broadcast/exit",e,{},t,!0);return{code:r}})}setMcuConfig(e,t){return v(this,void 0,void 0,function*(){const r=this._logger.createTraceId();if(this._logger.info(ae.L_MEDIA_SERVICE_SET_MCU_CONFIG_T,JSON.stringify({body:t}),r),!this._configUrl)return this._logger.error(ae.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:ce.FAILED,code:oe.MCU_SERVER_NOT_FOUND,msg:"MCU server not found"}),r),{code:oe.MCU_SERVER_NOT_FOUND};const i=`${this._configUrl.replace(/^(https?:\/\/)?/,"https://")}/server/mcu/config`,n=Ks(),s=Object.assign(Object.assign({},n),e),o=JSON.stringify(t),a=n["Request-Id"],{status:c,data:l}=yield this._runtime.httpReq({url:i,headers:s,body:o,method:R.POST});if(200===c){const e=JSON.parse(l),t=e.resultCode;return t===oe.SUCCESS?this._logger.info(ae.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:ce.SUCCESSED,"Request-Id":a}),r):this._logger.warn(ae.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({code:t,"Request-Id":a}),r),{code:t,res:e}}return this._logger.error(ae.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:ce.FAILED,code:oe.REQUEST_FAILED,msg:`request error -> Request-Id: ${a}, status: ${c}, url: ${i}`}),r),{code:oe.REQUEST_FAILED}})}getCDNResourceInfo(e,t,r){return v(this,void 0,void 0,function*(){const i=Ks(),n=Object.assign(Object.assign({},i),e),s=i["Request-Id"];this._logger.info(ae.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_T,`Request-Id: ${s}, url: ${t}`,r);const{status:o,data:a}=yield this._runtime.httpReq({url:t,headers:n,method:R.GET});if(200===o){const e=JSON.parse(a);return this._logger.info(ae.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_R,JSON.stringify({status:ce.SUCCESSED,cdnPlayerUrl:null==e?void 0:e.data.pull_url}),r),{code:e.resultCode,res:e}}return this._logger.info(ae.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_R,JSON.stringify({status:ce.FAILED,code:oe.REQUEST_FAILED}),r),{code:oe.REQUEST_FAILED}})}updateASRStatus(e,t,r){return v(this,void 0,void 0,function*(){return yield this._request("/rtc/media/v1/asr/update",e,t,r)})}operateRealtimeTranslation(e,t,r){return v(this,void 0,void 0,function*(){return yield this._request("/rtc/media/v1/asr/translation",e,t,r)})}operateSummarization(e,t,r){return v(this,void 0,void 0,function*(){const i="/rtc/media/v1/ai/room/sum/"+(t.status===Js.OPEN?"start":"stop");return yield this._request(i,e,t,r)})}generateSummarization(e,t,r,i,n,s,o){return v(this,void 0,void 0,function*(){const a={"App-Key":this._context.getAppkey(),UserId:this._context.getCurrentId(),RoomId:e,"X-Stream":!0},c={taskId:t,startTime:r,endTime:i,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:l,data:d}=yield this._request("/rtc/media/v1/ai/room/sum/gen",a,c,o,!1,(e,t)=>{s(e,t)}),u=null==d?void 0:d.getResponseHeader("x-code"),_=null==d?void 0:d.getResponseHeader("x-msg");return l===oe.SUCCESS&&u&&Number(u)!==oe.SUCCESS?{code:Number(u),msg:_}:{code:l}})}getASRContent(e,t,r,i,n,s,o){return v(this,void 0,void 0,function*(){const a={"App-Key":this._context.getAppkey(),UserId:this._context.getCurrentId(),RoomId:e,"X-Stream":!0},c={taskId:t,startTime:r,endTime:i,language:o},{code:l,data:d}=yield this._request("/rtc/media/v1/ai/room/sum/asr",a,c,s,!1,(e,t)=>{n(e,t)}),u=null==d?void 0:d.getResponseHeader("x-code"),_=null==d?void 0:d.getResponseHeader("x-msg");return l===oe.SUCCESS&&u&&Number(u)!==oe.SUCCESS?{code:Number(u),msg:_}:{code:l}})}}var $s;Object.defineProperty(qs,"msInDetector",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(qs,"detectorTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(qs,"detectValidMinute",{enumerable:!0,configurable:!0,writable:!0,value:72e5}),function(e){e[e.NORMAL=1]="NORMAL",e[e.TINY=2]="TINY"}($s||($s={}));const Ys=(e,t)=>Math.round(8*t/e),Ws=(e,t=2)=>{const r=10**t;return Math.round(e*r)/r},zs=(e,t=2)=>{e>1&&(e=1);const r=10**t;return Math.round(e*r)},Qs=(e,t,r,i)=>{if(0===t)return 0;if(!r||!i)return Ws(e/t,3);const n=t-i;if(0===n)return 0;const s=e-r;return s<0||n<0?0:Ws(s/n,3)},Zs=e=>{const{jitter:t,rtt:r,packetsLostRate:i}=e;return!Rr(t)||!Rr(r)||0!==i};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,r,i,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:r}),Object.defineProperty(this,"_sdpSemantics",{enumerable:!0,configurable:!0,writable:!0,value:i}),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,r){let i,n;if(this._latestBytesSent[e]&&t<this._latestBytesSent[e].bytesSent&&this.clearLatestpacketsSent([e]),this._latestBytesSent[e]){const{bytesSent:s,timestamp:o}=this._latestBytesSent[e];i=t-s,n=r-o,this._latestBytesSent[e]={bytesSent:t,timestamp:r}}else i=t,n=1e3,this._latestBytesSent[e]={bytesSent:t,timestamp:r};return Ys(n,i)}updateBytesRecv(e,t,r){let i,n;if(this._latestBytesRecv[e]&&t<this._latestBytesRecv[e].bytesRecv&&this.clearLatestPacketsRecv([e]),this._latestBytesRecv[e]){const{bytesRecv:s,timestamp:o}=this._latestBytesRecv[e];i=t-s,n=r-o,this._latestBytesRecv[e]={bytesRecv:t,timestamp:r}}else i=t,n=1e3,this._latestBytesRecv[e]={bytesRecv:t,timestamp:r};return Ys(n,i)}updateSenderPacketsLost(e,t,r){let i;if(Object.prototype.hasOwnProperty.call(this._latestPacketsSent[e],"packetsSent")){const{packetsLost:n,packetsSent:s}=this._latestPacketsSent[e];i=Qs(t,r,n,s),this._latestPacketsSent[e].packetsLost=t,this._latestPacketsSent[e].packetsSent=n===t?s:r}else i=Qs(t,r),this._latestPacketsSent[e].packetsLost=t,this._latestPacketsSent[e].packetsSent=r;return i}updateReceiverPacketsLost(e,t,r){let i;if(this._latestPacketsRecv[e]){const{packetsLost:n,packetsRecv:s}=this._latestPacketsRecv[e];i=Qs(t,r+t,n,s+n)}else i=Qs(t,r);return this._latestPacketsRecv[e]={packetsLost:t,packetsRecv:r},i}clearLatestpacketsSent(e){e.forEach(e=>{if(parseInt(e.split("_").pop())===bt.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[r,i]of e.entries())/codec/gi.test(i)&&r.includes("RTCCodec_")||(t[r]=i);return t}formatRCRTCStateReport(e){const t={senders:[],receivers:[]};return this._logger.info(ae.L_ABSTRACT_STAT_PARSER_FORMAT_RTC_STATE_REPORT_O,JSON.stringify({status:ce.SUCCESSED,stats:e,reports:t})),t}isValidTranceiver(e,t){var r,i;const n="outbound-rtp"===t?null===(r=this._rtcPeerConn.currentLocalDescription)||void 0===r?void 0:r.sdp:null===(i=this._rtcPeerConn.currentRemoteDescription)||void 0===i?void 0:i.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 ro extends to{formatRCRTCStateReport(e){const{outbound:t,remoteInbound:r,inbound:i,transport:n,connection:s}=this.formatStateData(e),o={senders:[],receivers:[]},a=Math.floor(s[0].timestamp);o.timestamp=a;let c=0,l=0;({totalPacketsLost:c,bitrateSend:l,senders:o.senders}=this.pickOutbound(t,e,c,a,l)),r.length>0&&o.senders.length>0&&this.pickRemoteInbound(r,o.senders,e);let d=0;if(({totalPacketsLost:c,bitrateRecv:d,receivers:o.receivers}=this.pickInbound(i,e,c,a,d)),n.length>0){const t=n[0];this.pickRtcTransport(t,e,o,d,l,c)}return o}pickRtcTransport(e,t,r,i,n,s){const{selectedCandidatePairId:o}=e;if(o){const e=t[o],{availableOutgoingBitrate:a,availableIncomingBitrate:c,currentRoundTripTime:l,localCandidateId:d,remoteCandidateId:u}=e,_=t[d],{ip:h,port:p,networkType:f}=_,g=t[u],{ip:m,port:R,protocol:E}=g;r.iceCandidatePair={IP:h,port:p,networkType:f,remoteIP:m,remotePort:R,protocol:E,bitrateRecv:i,bitrateSend:n,rtt:1e3*l,availableOutgoingBitrate:a,availableIncomingBitrate:c,totalPacketsLost:s},r.receivers.forEach(e=>{e.rtt=1e3*l})}}pickRemoteInbound(e,t,r){e.forEach(e=>{var i;const{localId:n,jitter:s,roundTripTime:o,packetsLost:a}=e,c=t.filter(e=>e.id===n)[0];if(c&&!Zs(c)){const e=null===(i=this._store)||void 0===i?void 0:i.getTrackIdBySSRC(r[c.id].ssrc);c.jitter=Math.round(1e3*s),c.rtt=o;const t=this._latestPacketsSent[e].crtPacketsSent;c.packetsLostRate=this.updateSenderPacketsLost(e,a,t)}})}_getOutboundVideoAttrs(e,t,r,i,n){var s,o,a;let{framesPerSecond:c,frameWidth:l,frameHeight:d}=e;return"video"!==r||l||d||c||(l=(null===(s=t[i])||void 0===s?void 0:s.frameWidth)||t[n].width,d=(null===(o=t[i])||void 0===o?void 0:o.frameHeight)||t[n].height,c=(null===(a=t[n])||void 0===a?void 0:a.framesPerSecond)||null),{frameRate:c,frameWidth:l,frameHeight:d}}pickOutbound(e,t,r,i,n){const s=[];return e.forEach(e=>{var o;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,"outbound-rtp"))return;const{id:a,kind:c,mediaSourceId:l,remoteId:d,packetsSent:u,bytesSent:_,encoderImplementation:h,pliCount:p,nackCount:f,mid:g}=e;let{trackId:m}=e;if(void 0!==g&&(m=this.getTrackIdByMid(g)),!m)return;const{frameRate:R,frameWidth:E,frameHeight:T}=this._getOutboundVideoAttrs(e,t,c,m,l),I=t[d];let S=null,v=null,O=0;I&&(S=I.jitter,v=I.roundTripTime,O=I.packetsLost),r+=O;const b=null===(o=this._store)||void 0===o?void 0:o.getTrackIdBySSRC(e.ssrc);if(!b)return;const C=l?t[l].audioLevel:t[m].audioLevel;let y=0;!this._latestPacketsSent[b]&&(this._latestPacketsSent[b]={}),I?y=this.updateSenderPacketsLost(b,O,u):this._latestPacketsSent[b].crtPacketsSent=u;let L=this.updateBytesSent(b,_,i);L<0&&(L=0),n+=L,s.push({id:a,trackId:b,kind:c,packetsLostRate:y,remoteResource:!1,audioLevel:C||0===C?zs(C):null,frameWidth:E,frameHeight:T,frameRate:R,bitrate:L,jitter:S?Math.round(1e3*S):S,rtt:v?Math.round(1e3*v):v,encoderImplementation:h,pliCount:p,nackCount:f,googFirsSent:Bs,samplingRate:Bs,googRenderDelayMs:Bs,trackState:Bs})}),{totalPacketsLost:r,bitrateSend:n,senders:s}}_getInboundMediaAttrs(e,t,r,i,n){var s,o,a;let{frameWidth:c,frameHeight:l,audioLevel:d}=e;return"video"===n?c||l||(c=(null===(s=t[r])||void 0===s?void 0:s.frameWidth)||t[i].width,l=(null===(o=t[r])||void 0===o?void 0:o.frameHeight)||t[i].height):d||(d=(null===(a=t[r])||void 0===a?void 0:a.audioLevel)||t[i].audioLevel),{frameWidth:c,frameHeight:l,audioLevel:d}}pickInbound(e,t,r,i,n){let s=[];return e.forEach(e=>{var o;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,"inbound-rtp"))return;const{packetsLost:a,packetsReceived:c,jitter:l,bytesReceived:d,framesPerSecond:u,kind:_,codecImplementationName:h,nackCount:p,pliCount:f,mid:g,id:m}=e;let{trackId:R}=e;if(void 0!==g&&(R=this.getTrackIdByMid(g)),!R)return;const{frameWidth:E,frameHeight:T,audioLevel:I}=this._getInboundMediaAttrs(e,t,R,m,_);r+=a;const S=null===(o=this._store)||void 0===o?void 0:o.getTrackIdBySSRC(e.ssrc),v=this.updateReceiverPacketsLost(S,a,c);let O=this.updateBytesRecv(S,d,i);O<0&&(O=0),n+=O,s.push({trackId:S,kind:_,packetsLostRate:v,remoteResource:!0,audioLevel:I||0===I?zs(I):null,frameWidth:E,frameHeight:T,frameRate:u,bitrate:O,jitter:l?Math.round(1e3*l):0,codecImplementationName:h,nackCount:p,pliCount:f,rtt:null,samplingRate:Bs,googFirsReceived:Bs,googRenderDelayMs:Bs,trackState:Bs})}),{totalPacketsLost:r,bitrateRecv:n,receivers:s}}}class io 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,r){var i;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,r))return;const{kind:n,bytesSent:s,packetsSent:o,bitrateMean:a,framerateMean:c,nackCount:l,pliCount:d,remoteId:u}=e,{jitter:_,roundTripTime:h,packetsLost:p}=u?t[u]:{jitter:null,roundTripTime:null,packetsLost:0},f=null===(i=this._store)||void 0===i?void 0:i.getTrackIdBySSRC(e.ssrc);this._totalPacketsLost+=p;let g=0;!this._latestPacketsSent[f]&&(this._latestPacketsSent[f]={}),u?g=this.updateSenderPacketsLost(f,p,o):this._latestPacketsSent[f].crtPacketsSent=o;let m=0;"video"===n?a&&(m=Math.floor(a/1e3)):m=this.updateBytesSent(f,s,this._reportsData.timestamp),m<0&&(m=0),this._bitrateSend+=m,this._reportsData.senders.push({trackId:f,kind:n,packetsLostRate:g,remoteResource:!1,audioLevel:null,frameWidth:null,frameHeight:null,frameRate:Math.floor(c),bitrate:m,jitter:_?Math.round(1e3*_):null,rtt:h,encoderImplementation:null,pliCount:d,nackCount:l,googFirsSent:Bs,samplingRate:Bs,googRenderDelayMs:Bs,trackState:Bs})}_addSenderData(e,t){var r;const{localId:i}=t,n=null===(r=this._store)||void 0===r?void 0:r.getTrackIdBySSRC(e[i].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 r;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,t))return;const{packetsLost:i,bytesReceived:n,packetsReceived:s,jitter:o,framerateMean:a,kind:c,bitrateMean:l,nackCount:d,pliCount:u}=e,_=null===(r=this._store)||void 0===r?void 0:r.getTrackIdBySSRC(e.ssrc);this._totalPacketsLost+=i;const h=this.updateReceiverPacketsLost(_,i,s);let p=0;"video"===c?l&&(p=Math.floor(l/1e3)):p=this.updateBytesRecv(_,n,this._reportsData.timestamp),p<0&&(p=0),this._bitrateRecv+=p,this._reportsData.receivers.push({trackId:_,kind:c,packetsLostRate:h,remoteResource:!0,audioLevel:null,frameWidth:null,frameHeight:null,frameRate:Math.floor(a),bitrate:p,jitter:o?Math.round(1e3*o):null,codecImplementationName:null,nackCount:d,pliCount:u,rtt:null,samplingRate:Bs,googFirsReceived:Bs,googRenderDelayMs:Bs,trackState:Bs})}_pickIceCandidatePair(e,t){const r=e[t.localCandidateId],{address:i,port:n}=r,s=e[t.remoteCandidateId],{address:o,port:a,protocol:c}=s;this._reportsData.iceCandidatePair={IP:i,port:n,networkType:null,remoteIP:o,remotePort:a,protocol:c,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 r=e[t],{type:i}=r;"outbound-rtp"===i&&this._pickSenderData(r,e,i),"remote-inbound-rtp"===i&&this._addSenderData(e,r),"inbound-rtp"===i&&this._pickReceiverData(r,i),"candidate-pair"===i&&"succeeded"===r.state&&this._pickIceCandidatePair(e,r)}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:r,packetsReceived:i,jitter:n,bytesReceived:s,kind:o,nackCount:a,pliCount:c,audioLevel:l,frameHeight:d,frameWidth:u}=e,_=null===(t=this._store)||void 0===t?void 0:t.getTrackIdBySSRC(e.ssrc);if(!_)return;this._totalPacketsLost+=r;const h=this.updateReceiverPacketsLost(_,r,i);let p=this.updateBytesRecv(_,s,this._reportsData.timestamp);p<0&&(p=0),this._bitrateRecv+=p,this._reportsData.receivers.push({trackId:_,kind:o,packetsLostRate:h,remoteResource:!0,audioLevel:l||0===l?zs(l):null,frameWidth:u,frameHeight:d,frameRate:null,bitrate:p,jitter:n?Math.round(1e3*n):n,codecImplementationName:null,nackCount:a,pliCount:c,rtt:null,samplingRate:Bs,googFirsReceived:Bs,googRenderDelayMs:Bs,trackState:Bs})})}_pickSenderData(e,t){e.forEach(e=>{var r;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,"outbound-rtp"))return;const i=null===(r=this._store)||void 0===r?void 0:r.getTrackIdBySSRC(e.ssrc),{kind:n,bytesSent:s,pliCount:o,nackCount:a,audioLevel:c,frameHeight:l,frameWidth:d,codecId:u,remoteId:_,packetsSent:h}=e;if(!i)return;const p=t[_];let f=null,g=null,m=0;p&&(f=p.jitter,g=p.roundTripTime,m=p.packetsLost),this._totalPacketsLost+=m;let R=0;!this._latestPacketsSent[i]&&(this._latestPacketsSent[i]={}),p?R=this.updateSenderPacketsLost(i,m,h):this._latestPacketsSent[i].crtPacketsSent=h;let E=this.updateBytesSent(i,s,this._reportsData.timestamp);E<0&&(E=0),this._bitrateSend+=E,this._reportsData.senders.push({trackId:i,kind:n,packetsLostRate:R,remoteResource:!1,audioLevel:c||0===c?zs(c):null,frameWidth:d,frameHeight:l,frameRate:null,bitrate:E,jitter:f?Math.round(1e3*f):f,rtt:g?Math.round(1e3*g):g,encoderImplementation:t[u].mimeType,pliCount:o,nackCount:a,googFirsSent:Bs,samplingRate:Bs,googRenderDelayMs:Bs,trackState:Bs})})}_pickIceCandidatePair(e,t){const{selectedCandidatePairId:r}=e;if(r){const e=t[r],{availableOutgoingBitrate:i,availableIncomingBitrate:n,currentRoundTripTime:s,localCandidateId:o,remoteCandidateId:a}=e,c=t[o],{address:l,port:d}=c,u=t[a],{address:_,port:h,protocol:p}=u;this._reportsData.iceCandidatePair={IP:l||null,port:d,networkType:null,remoteIP:_,remotePort:h,protocol:p,bitrateRecv:this._bitrateRecv,bitrateSend:this._bitrateSend,rtt:1e3*s,availableOutgoingBitrate:i,availableIncomingBitrate:n,totalPacketsLost:this._totalPacketsLost},this._reportsData.receivers.forEach(e=>{e.rtt=1e3*s})}}formatRCRTCStateReport(e){const{outbound:t,inbound:r,transport:i,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(r,e),i.length>0){const t=i[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,r){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:r}),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 i=this.getStreamIndex();this.spliteStreams(i)}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 r=e.exec(this.SDP);for(;null!==r;)t.add(null==r?void 0:r.index),r=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 r=this.SDP.substring(e[t],e[t+1]);/^\bm=video\b/.test(r)?this.videoStreams.push(r):this.audioStreams.push(r)}}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(r=>new RegExp(`\\bmsid:${t}\\b`,"ig").test(r)?this.setAudioItemBitrate(r,e):r),this}setAudioBitrateWithMid(e,t){return this.audioStreams=this.audioStreams.map(r=>new RegExp(`\\bmid:${t}\\b`,"ig").test(r)?this.setAudioItemBitrate(r,e):r),this}setAudioItemBitrate(e,t){if(0===t.max&&/\ba=inactive\b/gi.test(e))return e;if(!/\bmaxaveragebitrate\b/gi.test(e)){const r=["$1","maxaveragebitrate="+t.max*so.KBitrate*1e3];e=e.replace(/(\buseinbandfec=[^\r\n]+)/gi,r.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(r=>new RegExp(`\\bmsid:${t}\\b`,"ig").test(r)?this.setVideoItemBitrate(r,e):r),this}setVideoBitrateWithMid(e,t){return this.videoStreams=this.videoStreams.map(r=>new RegExp(`\\bmid:${t}\\b`,"ig").test(r)?this.setVideoItemBitrate(r,e):r),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 r=["$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,r.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(r=>new RegExp(`\\bmid:${e}\\b`,"ig").test(r)?this.clearSSRC(r,t):r),this.videoStreams=this.videoStreams.map(r=>new RegExp(`\\bmid:${e}\\b`,"ig").test(r)?this.clearSSRC(r,t):r),this}clearSSRC(e,t){if(t===_o.SENDONLY){if(/\ba=sendonly\b/.test(e))return e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,"")}if(t===_o.RECVONLY){if(/\ba=recvonly\b/.test(e))return e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,"")}if(t===_o.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(ae.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(ae.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(ae.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(ae.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 r=ao.matchPrefix(e,"a=msid:");if(1===r.length)return t=r[0].substr(7).split(" "),{stream:t[0],track:t[1]};const i=ao.matchPrefix(e,"a=ssrc:").map(e=>ao.parseSsrcMedia(e)).filter(e=>"msid"===e.attribute);return i.length>0&&i[0].value?(t=i[0].value.split(" "),{stream:t[0],track:t[1]}):{stream:"",track:""}}static parseSsrcMedia(e){const t=e.indexOf(" "),r={ssrc:parseInt(e.substr(7,t-7),10)},i=e.indexOf(":",t);return i>-1?(r.attribute=e.substr(t+1,i-t-1),r.value=e.substr(i+1)):r.attribute=e.substr(t+1),r}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 r=0;if(this.isIFrame(t)){const e=t.join(",");let i=e.indexOf("0,0,0,1,101");-1===i&&(i=e.indexOf("0,0,0,1,37"));r=e.substring(0,i).split(",").length-1+4+8}else r=12;return{header:t.slice(0,r),payloadData:t.slice(r)}}static deal0x03(e,t){let r=[];return r="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(r)}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 r=t.match(/a=rtpmap:(\d+)\s+(\S+)/g);r&&(ao.payloadTypeCodecMap=r.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:[]});function co(e,t){let r=0,i=t;for(;i<e.length;){const t=e[i];if(r+=t,i++,255!==t)break}return{value:r,nextOffset:i}}function lo(e,t){if(t>=e.length)return null;const r=co(e,t),i=r.value;let n=r.nextOffset;const s=co(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),c=n+16,l=o-16;let d=e.slice(c,c+l);return d.length>=2&&0===d[d.length-2]&&128===d[d.length-1]?d=d.slice(0,d.length-2):d.length>=1&&128===d[d.length-1]&&(d=d.slice(0,d.length-1)),5===i?{payloadSize:o,uuid:a,content:d}:null}var uo,_o,ho,po,fo,go,mo,Ro,Eo;!function(e){e.PLANB="plan-b",e.UNIFIEDPLAN="unified-plan"}(uo||(uo={})),function(e){e.SENDONLY="sendonly",e.RECVONLY="recvonly",e.INACTIVE="inactive"}(_o||(_o={}));class To{static setSdpSemantics(e,t){const{browser:r,version:i,supportsUnifiedPlan:n}=fr;if(t.info(ae.L_A_SDP_STRATEGY_SET_SDP_SEMANTICS_O,JSON.stringify({sdpSemantics:e,supportsUnifiedPlan:n,browser:r,version:i})),n)return/chrome/i.test(r)?i?void(this._sdpSemantics=i>92?"unified-plan":i<72?"plan-b":e):void(this._sdpSemantics="unified-plan"):void(/firefox/i.test(r)?this._sdpSemantics="unified-plan":/safari/i.test(r)?this._sdpSemantics=i<12?"plan-b":"unified-plan":this._sdpSemantics="unified-plan");this._sdpSemantics="plan-b"}static getSdpSemantics(){return To._sdpSemantics}constructor(e,t,r,i){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:r}),Object.defineProperty(this,"_useEncrypt",{enumerable:!0,configurable:!0,writable:!0,value:i}),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 r=this._outboundStreams[t].getVideoTracks()[0];if(!r)continue;const i=/_tiny$/.test(t),{width:n,height:s}=ir(r);e.push({trackId:r.id,simulcast:i?$s.TINY:$s.NORMAL,resolution:`${n}x${s}`})}return e}setRemoteAnswer(e){return v(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(ae.L_A_SDP_STRATEGY_SET_REMOTE_ANSWER_O,JSON.stringify({status:ce.FAILED,msg:e})),oe.SET_REMOTE_DESCRIPTION_FAILED}return this._logger.info(ae.L_A_SDP_STRATEGY_SET_REMOTE_ANSWER_O,JSON.stringify({status:ce.SUCCESSED,sdp:e})),oe.SUCCESS})}getStatParsr(e,t,r,i){return/chrome/i.test(fr.browser)?new ro(this,e,this._logger,t,r,i):/Firefox/i.test(fr.browser)?new io(this,e,this._logger,t,r,i):/Safari/i.test(fr.browser)?new no(this,e,this._logger,t,r,i):null}getTrackIdByMid(e){return null}resetSdp(e){return so.trimBlankLine(e)}_setupSenderTransform(e){if(!this._useEncrypt)return;const t=e.createEncodedStreams(),{readable:r,writable:i}=t,n=new TransformStream({transform:this._encodeRtpChunk.bind(this,e)});r.pipeThrough(n).pipeTo(i)}_setupReceiverTransform(e){const t=e.createEncodedStreams(),{readable:r,writable:i}=t,n=new TransformStream({transform:this._decodeRtpChunk.bind(this,e)});r.pipeThrough(n).pipeTo(i)}_encodeVideoFrame(e){const{header:t,payloadData:r}=ao.splitNaluData(e),i=oo.encodeVideo(r),n=ao.deal0x03(i,"encode");return new Uint8Array([...t,...n]).buffer}_decodeVideoFrame(e){var t;const r=new Uint8Array(e),i=r.join(",").indexOf("0,0,0,1,6,5");if(-1!==i&&r.join(",").includes("84,128,131,151,240,35,71,75,183,247,79,50,181,78,6,172")){const n=r.join(",").slice(i);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 r=function(e){const t=[];let r=0;for(;;){let i,n,s,o,a=!(e[r]>>7),c=127&e[r];if(a?(i=0,n=e.byteLength-(t.length>0?t.map(e=>4+e.block.byteLength).reduce((e,t)=>e+t):0)-1,s=e.slice(r,r+1),r+=1):(i=(e[r+1]<<6)+(e[r+2]>>2),n=((3&e[r+2])<<8)+e[r+3],s=e.slice(r,r+4),r+=4),o=new Uint8Array(n),t.push({timestampOffset:i,header:s,block:o,isPrimary:a,blockPType:c}),a)break}return t.forEach(t=>{const i=t.block.byteLength,n=e.slice(r,r+i);t.block.set(n),r+=i}),t}(new Uint8Array(e)),i=[],n=[];let s=0;r.forEach(e=>{const r="decode"===t?oo.decodeAudio(e.block):oo.encodeAudio(e.block);if(r.byteLength!==e.block.byteLength&&!e.isPrimary){let[,,t,i]=e.header;t=(t>>2<<2)+r.byteLength>>8,i=255&r.byteLength,e.header=new Uint8Array([e.header[0],e.header[1],t,i])}e.block=r,s+=e.block.byteLength+e.header.byteLength,i.push(e.header),n.push(e.block)});const o=new Uint8Array(s);let a=0;return[...i,...n].forEach(e=>{o.set(e,a),a+=e.byteLength}),o.buffer}_handleOpusFrame(e,t){const r=new Uint8Array(e);return("encode"===t?oo.encodeAudio(r):oo.decodeAudio(r)).buffer}_encodeRtpChunk(e,t,r){const i=t.data;if(t instanceof RTCEncodedVideoFrame)t.data=this._encodeVideoFrame(i);else{const{payloadType:e}=t.getMetadata(),{codec:r}=ao.payloadTypeCodecMap.filter(t=>t.payloadType===e)[0];"red"===r?t.data=this._handleAudioREDFrame(i,"encode"):"opus"===r?t.data=this._handleOpusFrame(i,"encode"):console.error(`Unsupport audio payloadType: ${e}, codec: ${r}`)}r.enqueue(t)}_decodeRtpChunk(e,t,r){const i=t.data;if(t instanceof RTCEncodedVideoFrame)t.data=this._decodeVideoFrame(i);else if(this._useEncrypt){const{payloadType:e}=t.getMetadata(),{codec:r}=ao.payloadTypeCodecMap.filter(t=>t.payloadType===e)[0];"red"===r?t.data=this._handleAudioREDFrame(i,"decode"):"opus"===r?t.data=this._handleOpusFrame(i,"decode"):console.error(`Unsupport audio payloadType: ${e}, codec: ${r}`)}r.enqueue(t)}}class Io 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 r=t.match(/\ba=mid:(video|audio)\b/),i=so.clearInactiveOrRecvonly(t);r&&r[1]===wt.AUDIO&&(e[1]=i),r&&r[1]===wt.VIDEO&&(e[2]=i)});const t=e.join("");return so.trimBlankLine(t)}setAudioBitrateWithStreamId(e,t){return this._logger.warn(ae.L_FUNCTION_IS_UNAVAILABLE,"plan-b not support set Audio Bitrate With Stream Id"),this}setVideoBitrateWithStreamId(e,t){return this._logger.warn(ae.L_FUNCTION_IS_UNAVAILABLE,"plan-b not support set Video Bitrate With Stream Id"),this}}class So extends To{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(),r=e.__innerGetMediaStreamTrack(),i=this._outboundStreams[t]||(this._outboundStreams[t]=new MediaStream);i.getTracks().forEach(e=>{e.kind===r.kind&&i.removeTrack(e)}),i.addTrack(r);const n=e.getTrackId(),s=this.senders[n];s?s.replaceTrack(r):(this.senders[n]=this._peer.addTrack(r,i),Object.defineProperty(r,"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 r=e.getTrackId(),i=this.senders[r];i&&(i.replaceTrack(null),this._peer.removeTrack(i),delete this.senders[r])}updateSubRemoteTracks(e){}updateRecvTransceiverMap(e,t){}setBitrate(e,t,r){}createOffer(e){return v(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 r=this._outboundStreams[e].id;t.sdp=t.sdp.replace(new RegExp(r,"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===bt.AUDIO_ONLY?t.isAudioTrack():t.isVideoTrack()),r={max:0,min:0};return t.forEach(e=>{const{min:t,max:i,start:n}=e.getBitrate();r.max=r.max<i?i:r.max,r.min=r.min>t?t:r.min,r.max===i?r.start=n:r.start=.7*r.max}),r}resetSdp(e){const t=new Io(this._logger,e),r=this._getMaxRangeBitrate(bt.VIDEO_ONLY),i=this._getMaxRangeBitrate(bt.AUDIO_ONLY);return t.setAudiosBitrate(i),t.setVideosBitrate(r),t.stringify()}}class vo extends so{constructor(e,t){super(t,uo.UNIFIEDPLAN,e)}stringify(){const e=[this.SDPHeader];[...this.audioStreams,...this.videoStreams].forEach(t=>{const r=t.match(/\ba=mid:(\d+)\b/);r&&r[1]&&(e[+r[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 bo extends To{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,r){this._logger.warn(ae.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 r=e.getTrackId(),i=e.getStreamId(),n=e.__innerGetMediaStreamTrack();this._localTracks[r]=e;const s=this._outboundStreams[i]||(this._outboundStreams[i]=new MediaStream);s.getTracks().forEach(e=>{e.kind===n.kind&&s.removeTrack(e)}),s.addTrack(n);const o=this._sendTransceiver[r];if(o)o.sender.replaceTrack(n),o.direction="sendonly";else{const e=this._sendTransceiver[r]=this._peer.addTransceiver(n,{direction:"sendonly",streams:[s]});this._setupSenderTransform(e.sender)}Oo.getInstance().push(r,{msid:i,id:this._outboundStreams[i].id,kind:null===(t=e.streamTrack)||void 0===t?void 0:t.kind})}removeLocalTrack(e,t=!0){const r=e.getTrackId(),i=e.getStreamId();delete this._localTracks[r];const n=this._sendTransceiver[r];if(!n)return;"closed"!==this._peer.connectionState&&(n.direction="inactive",this._peer.removeTrack(n.sender),n.sender.replaceTrack(null));const s=this._outboundStreams[i];(e.isAudioTrack()?s.getAudioTracks():s.getVideoTracks()).forEach(e=>s.removeTrack(e));const o=this._sendTransceiver[`${r}_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[`${i}_tiny`].removeTrack(t),t.stop()}}updateRecvTransceiverMap(e,t){const{mediaType:r}=or(e);this._recvTransceiver[e]=t;const i=r===bt.AUDIO_ONLY?this._recvAudio:this._recvVideo,n=i.findIndex(e=>e===t);n>=0&&i.splice(n,1)}updateSubRemoteTracks(e){const t=e.slice(),r=this._subedTracks.slice();this._subedTracks=e.slice();for(let e=t.length-1;e>=0;e-=1){const i=t[e],n=r.findIndex(e=>e===i);n>=0&&(t.splice(e,1),r.splice(n,1))}r.length&&r.forEach(e=>{const t=e.getTrackId();e.__innerSetMediaStreamTrack(void 0);const r=this._recvTransceiver[t];r&&(r.direction="inactive")});const i={audio:0,video:0};t.length&&t.forEach(e=>{const t=e.isAudioTrack()?"audio":"video",r=this._recvTransceiver[e.getTrackId()];r?r.direction="recvonly":i[t]+=1});for(let e=this._recvAudio.length;e<i.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<i.video;e+=1){const e=this._peer.addTransceiver("video",{direction:"recvonly"});this._recvVideo.push(e),this._setupReceiverTransform(e.receiver)}}createOffer(e){return v(this,void 0,void 0,function*(){const t=yield this._peer.createOffer({iceRestart:e});let r=t.sdp;for(const e in this._outboundStreams){const t=this._outboundStreams[e].id;r=r.replace(new RegExp(t,"g"),e)}return r=this.resetOfferSdp(r),r=r.replace(/(a=ice-options:trickle)/g,"$1\r\na=ice-options:renomination"),t.sdp=r,yield this._peer.setLocalDescription(t),{type:"offer",semantics:"unified-plan",sdp:r}})}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,r){let i=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"===r?/tiny$/.test(s)?s=s.replace(/tiny$/gi,"1_tiny"):s+="_1":s+="_0",s===t&&r===n&&o&&(i=o)}),i}_setSenderTransceiverBitrate(e,t,r,i){const n=this._localTracks[t],s=null==n?void 0:n.getBitrate();i===wt.AUDIO&&s&&e.setAudioBitrateWithMid(s,r),i===wt.VIDEO&&s&&e.setVideoBitrateWithMid(s,r)}_resetSenderTransceiver(e,t){var r;for(const i in this._sendTransceiver){const n=this._sendTransceiver[i],s=null===(r=n.sender.track)||void 0===r?void 0:r.kind;let{direction:o,mid:a}=n;a||(a=this._genarateMid(e,i,s)),a&&(o===_o.SENDONLY&&this._setSenderTransceiverBitrate(t,i,a,s),o===_o.INACTIVE&&t.clearnSsrcWithMid(a,_o.INACTIVE))}}_resetRecvTransceiver(e){for(const t in this._recvTransceiver){const r=this._recvTransceiver[t],{direction:i,mid:n}=r;n&&i===_o.INACTIVE&&e.clearnSsrcWithMid(n,_o.RECVONLY)}}resetOfferSdp(e){const t=new vo(this._logger,e);return this._resetSenderTransceiver(e,t),this._resetRecvTransceiver(t),t.stringify()}resetAnswerSdp(e){var t;const r=new vo(this._logger,e);for(const e in this._sendTransceiver){const i=this._sendTransceiver[e],{mid:n}=i;if(n){const s=this._localTracks[e],o=null==s?void 0:s.getBitrate(),a=null===(t=i.sender.track)||void 0===t?void 0:t.kind;a===wt.AUDIO&&o&&r.setAudioBitrateWithMid(o,n),a===wt.VIDEO&&o&&r.setVideoBitrateWithMid(o,n)}}return r.stringify()}}class Co extends m{constructor(e,t,r,i,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:r}),Object.defineProperty(this,"_currentUserId",{enumerable:!0,configurable:!0,writable:!0,value:i}),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 c=To.getSdpSemantics(),l="unified-plan"===c&&a&&"function"==typeof RTCRtpSender.prototype.createEncodedStreams&&"function"==typeof RTCRtpReceiver.prototype.createEncodedStreams&&oo.isInit(),d=this._rtcPeerConn=new RTCPeerConnection({sdpSemantics:c,encodedInsertableStreams:l});this._sdpStrategy="plan-b"===c?new So(e,this._logger,d,!1):new bo(e,this._logger,d,l),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,c,this._currentUserId,this._store)}getLocalTracks(){return Object.values(this.pubLocalTracks)}_decodeSeiData(e){const t=e.split(",").map(e=>Number(e)),r=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 r=t+(1===e[t+2]?3:4);if(r>=e.length)break;if(6==(31&e[r])){const t=lo(e,r+1);if(t)return{payloadSize:t.payloadSize,content:t.content}}t=r+1}else t++}else{let t=0;for(;t+4<=e.length;){const r=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];if(r<=0||t+4+r>e.length)break;const i=t+4;if(6==(31&e[i])){const n=i+1,s=lo(e.subarray(n,t+4+r),0);if(s)return{payloadSize:s.payloadSize,content:s.content}}t+=4+r}}return null}(new Uint8Array(t));if(null==r?void 0:r.content.length){const e=this._context.decodeAsrText(r.content,t);e.length&&this.emit(Co.__INNER_SEI_CONTENT__,e)}}_onConnectionStateChange(){this._logger.info(ae.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 v(this,void 0,void 0,function*(){var e,t;const{iceConnectionState:r}=this._rtcPeerConn;this._logger.info(ae.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_S,JSON.stringify({iceConnectionState:r}));const i=yield this._getStatsData(),n=i?this._createRCRTCStateReport(i).iceCandidatePair:null;this.emit(Co.__INNER_ICE_STATE_CHANGE__,{status:r,time:Date.now(),iceCandidatePair:n}),"connected"===r?(this.emit(Co.__INNER_ICE_CONNECTED__,this._firstConnectFromPub),this.startAutoExecute(1e3)):"failed"!==r&&"disconnected"!==r||this._handleRetry();try{null===(t=null===(e=this._reportListener)||void 0===e?void 0:e.onICEConnectionStateChange)||void 0===t||t.call(e,r)}catch(e){this._logger.error(ae.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_REPORT_R,JSON.stringify({status:ce.FAILED,mag:e}))}})}_handleRetry(){return v(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!==oe.SUCCESS&&(this._reTryExchangeTimer=setTimeout(()=>this._handleRetry(),15e3))})}_onTrackReady(e){if(!e.streams.length)return;const t=e.streams[0].id,{track:r}=e.receiver,i=[t,"audio"===r.kind?bt.AUDIO_ONLY:bt.VIDEO_ONLY].join("_");Object.defineProperty(r,"trackId",{value:i,writable:!1,enumerable:!1,configurable:!1}),this._updateRecvTransceiverMap(i,e.transceiver);const{tag:n}=or(i);n!==Vs&&this.emit(Co.__INNER_EVENT_TRACK_READY__,e)}setBitrate(e,t,r){return v(this,void 0,void 0,function*(){this._sdpStrategy.setBitrate(e,t,r),this._logger.info(ae.L_RTC_PEER_CONNECTION_SET_BITRATE_O,JSON.stringify({status:ce.SUCCESSED,max:e,min:t,start:r}))})}createOffer(e){return v(this,void 0,void 0,function*(){const t=yield this._sdpStrategy.createOffer(e);return this._logger.info(ae.L_RTC_PEER_CONNECTION_CREATE_OFFER_O,JSON.stringify({offerSDP:t.sdp,sdpDemantics:t.semantics})),t})}setRemoteAnswer(e){return v(this,arguments,void 0,function*(e,t=!1){var r;return ao.parsePayloadTypes(null===(r=this._rtcPeerConn.localDescription)||void 0===r?void 0:r.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(Vt.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.off(Vt.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),e.on(Vt.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.on(Vt.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),this._logger.info(ae.L_RTC_PEER_CONNECTION_ADD_LOCAL_TRACK_O,`trackId: ${e.getTrackId()}`)}removeLocalTrackById(e){const t=this.getLocalTrack(e);t?(this._logger.info(ae.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_BY_ID_O,JSON.stringify({status:ce.SUCCESSED,trackId:e})),this.removeLocalTrack(t)):this._logger.warn(ae.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_BY_ID_O,JSON.stringify({status:ce.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 r=e.getTrackId();delete this.pubLocalTracks[r],this._sdpStrategy.removeLocalTrack(e,t),e.__innerSetPublished(!1),e.off(Vt.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.off(Vt.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this);const i=`${r}_tiny`,n=this.getLocalTrack(i);n&&t&&(this._sdpStrategy.removeLocalTrack(n,t),delete this.pubLocalTracks[i],n.destroy()),this._logger.info(ae.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_O,JSON.stringify({trackId:r}))}_updateRecvTransceiverMap(e,t){this._sdpStrategy.updateRecvTransceiverMap(e,t)}updateSubRemoteTracks(e){this._sdpStrategy.updateSubRemoteTracks(e)}getOutboundVideoInfo(){return this._sdpStrategy.getOutboundVideoInfo()}_onLocalTrackMuted(e,t){const r=this.getLocalTrack(`${e.getTrackId()}_tiny`);r&&(r.__innerGetMediaStreamTrack().enabled=!e.isLocalMuted()),this.emit(Vt.__INNER_EVENT_MUTED_CHANGE__,e,t)}_onLocalTrackDestroied(e){this.emit(Vt.__INNER_EVENT_DESTROY__,e)}registerReportListener(e){this._reportListener=e}_createSenderReport(e){return e.filter(e=>e.trackId).map(e=>{const{trackId:t,kind:r,packetsLostRate:i,remoteResource:n,bitrate:s,jitter:o,rtt:a}=e,c={trackId:t,kind:r,packetsLostRate:i,remoteResource:n,bitrate:s,jitter:o,rtt:a};return(e.audioLevel||0===e.audioLevel)&&(c.audioLevel=e.audioLevel),e.frameWidth&&(c.frameWidth=e.frameWidth),e.frameHeight&&(c.frameHeight=e.frameHeight),e.frameRate&&(c.frameRate=e.frameRate),Object.assign({},c)})}_createReceiverReport(e){return e.filter(e=>e.trackId).map(e=>{const{trackId:t,kind:r,packetsLostRate:i,remoteResource:n,bitrate:s,jitter:o,rtt:a}=e,c={trackId:t,kind:r,packetsLostRate:i,remoteResource:n,bitrate:s,jitter:o,rtt:a};return(e.audioLevel||0===e.audioLevel)&&(c.audioLevel=e.audioLevel),e.frameWidth&&(c.frameWidth=e.frameWidth),e.frameHeight&&(c.frameHeight=e.frameHeight),e.frameRate&&(c.frameRate=e.frameRate),Object.assign({},c)})}_createRCRTCStateReport(e){const{timestamp:t,iceCandidatePair:r,senders:i,receivers:n}=e;(null==r?void 0:r.totalPacketsLost)&&(null==r||delete r.totalPacketsLost);for(const e in r)Rr(r[e])&&delete r[e];return{timestamp:t,iceCandidatePair:r,senders:this._createSenderReport(i),receivers:this._createReceiverReport(n)}}_getStatsData(){return v(this,void 0,void 0,function*(){var e,t;this._formatStatsData=null;let r=null;const i=yield this._rtcPeerConn.getStats();r=null===(e=this.reportParser)||void 0===e?void 0:e.parseRTCStatsReport(i);const n=null===(t=this.reportParser)||void 0===t?void 0:t.formatRCRTCStateReport(r);return this._formatStatsData=n,n})}_reportHandle(){return v(this,void 0,void 0,function*(){var e,t,r,i,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(ae.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(Co.__INNER_AUDIOLEVEL_CHANGE__,a),this._isRoomAudience&&(null===(r=this._reportListener)||void 0===r?void 0:r.onReportLiveAudioStates)){const e=this._getLiveAudioState();try{e.length&&(null===(n=null===(i=this._reportListener)||void 0===i?void 0:i.onReportLiveAudioStates)||void 0===n||n.call(i,e))}catch(e){this._logger.error(ae.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,null==e?void 0:e.stack)}}})}_getLiveAudioState(){const e=[];return this._rtcPeerConn.getReceivers().forEach(t=>{const r=t.getContributingSources();r.length&&e.push(...r)}),e.map(e=>{const{source:t,audioLevel:r}=e,i=this._store.getTrackIdBySSRC(t);if(!i)return{};const{userId:n}=or(i);return{audioLevel:zs(r),userId:n,trackId:i}}).filter(e=>!!e.userId)}_sendR3R4Data(){return v(this,void 0,void 0,function*(){var e,t,r,i;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===(r=this._polarisReport)||void 0===r?void 0:r.sendR3Data(n)),o.length&&(yield null===(i=this._polarisReport)||void 0===i?void 0:i.sendR4Data(n)),s.length=0,o.length=0,n=null})}__reportR3R4ToPolaris(){return v(this,void 0,void 0,function*(){this._isDestroyed||(clearTimeout(this._reportR3R4ToPolarisTimer),this._reportR3R4ToPolarisTimer=setTimeout(()=>v(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(ae.L_RTC_PEER_CONNECTION_DESTROY_O,JSON.stringify({status:ce.SUCCESSED}))}clearReTryExchangeTimer(){clearTimeout(this._reTryExchangeTimer),this._reTryExchangeTimer=null}isDestroyed(){return this._isDestroyed}}Object.defineProperty(Co,"__INNER_EVENT_TRACK_READY__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-track-ready"}),Object.defineProperty(Co,"__INNER_AUDIOLEVEL_CHANGE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-audio-level-change"}),Object.defineProperty(Co,"__INNER_ICE_STATE_CHANGE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-ice-state-change"}),Object.defineProperty(Co,"__INNER_ICE_CONNECTED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-ice-connected"}),Object.defineProperty(Co,"__INNER_SEI_CONTENT__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-sei-content"});class yo{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:r}=or(e.trackId),i=this._store.crtUserId===r?this._peer.getLocalTrack(e.trackId):this._store.getRemoteTrack(e.trackId);i&&t.push({track:i,audioLevel:e.audioLevel||0})}),this._audioLevelChangeHandler(t)}onAudioLevelChange(e){this._audioLevelChangeHandler=e}}!function(e){e[e.ANCHOR=1]="ANCHOR",e[e.AUDIENCE=2]="AUDIENCE"}(ho||(ho={})),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"}(go||(go={}));class Lo{get priority(){return fo.LOW}get kind(){return po.UNKNOWN}}class Ao{constructor(e,t,r,i){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:r}),Object.defineProperty(this,"abortCode",{enumerable:!0,configurable:!0,writable:!0,value:i}),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 v(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 r;const i=this._logger.createTraceId();try{this._logger.info(ae.L_INVOKER_EXECUTE_T,`kind: ${e.kind}, length: ${this._queue.length}`,i),r=yield e.execute(this._context,this._store,this)}catch(t){return console.error(t),this._logger.error(ae.L_INVOKER_EXECUTE_R,e.kind,i),void this._next()}const{code:n}=r;n!==oe.SUCCESS&&n!==ie?this._logger.warn(ae.L_INVOKER_EXECUTE_R,`code: ${n}, kind: ${e.kind}`,i):this._logger.info(ae.L_INVOKER_EXECUTE_R,`kind: ${e.kind}, Done`,i),t(r),this._next()})}push(e){return v(this,void 0,void 0,function*(){return new Promise(t=>{if(this._logger.info(ae.L_INVOKER_PUSH_O,JSON.stringify({isDestroyed:this._isDestroyed,kind:e.kind,length:this._queue.length})),this._isDestroyed)return void t({code:oe.NOT_IN_ROOM});const{priority:r}=e;if(r===fo.LOW)this._queue.push({command:e,resolve:t});else{const i=this._queue.findIndex(e=>e.command.priority<r),n=-1===i?this._queue.length-1:i;this._queue.splice(n,0,{command:e,resolve:t})}setTimeout(()=>{this._execute()},0)})})}isDestroyed(){return this._isDestroyed}destroy(){this._isDestroyed||(this._logger.info(ae.L_INVOKER_DESTROY_O),this._isDestroyed=!0,this._queue.forEach(e=>{e.resolve({code:this.abortCode})}),this._queue.length=0)}}class No extends Ao{constructor(e,t){super(e.logger,e,t,oe.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"}(mo||(mo={}));class Po{constructor(e,t,r,i,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:r}),Object.defineProperty(this,"roomId",{enumerable:!0,configurable:!0,writable:!0,value:i}),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:mo.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 r in this._remoteTracks){const i=this._remoteTracks[r];i.getUserId()===e&&t.push(i)}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:r}=or(e);return t===Vs?this._asrSeiUris[r][0]:this._roomResources[r].find(t=>sr(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 wo extends Po{_updateTrackIdSSRCMap(){Object.values(this._roomResources).forEach(e=>{e.forEach(e=>{const{ssrc:t,resourceId:r}=JSON.parse(e.uri);this._trackIdSSRCMap.set(t,r)})})}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=sr(e),{tag:r,userId:i,mediaType:n}=or(t),s=n===bt.AUDIO_ONLY?new zt(this._logger,r,i):new Qt(this._logger,r,i);s.__innerSetRemoteMuted(0===e.state),this._remoteTracks[t]=s})}}initWithRoomData(e,t){this._sessionId=e.sessionId,this._token=e.token,this._roomStatusVersion=Sr(e.version),this._roomResources=Tr(e,this.roomId,this._logger,t),this._updateTrackIdSSRCMap(),this._initRemoteTracks(),this.setResourcesByUserId(this.crtUserId,this.getResourcesByUserId(this.crtUserId)||[]),this._logger.info(ae.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=Sr(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],r=t.split("_")[0];this._asrSeiUris[r]=e}else this._asrSeiUris={}}addSeiRemoteTrack(e){const{msid:t}=e[0],r=t.split("_"),i=r.pop(),n=r[0],s=new Qt(this._logger,i,n);this.addRemoteTrack(s)}removeSeiRemoteTrack(){if(!this.getASRSeiUris().length)return;const{msid:e,mediaType:t}=this.getASRSeiUris()[0],r=`${e}_${t}`;this.removeRemoteTrack(r)}setIsStartRealTranslate(e){this._isStartRealTranslate=e}setTranslationLang(e){this._translationLang=e}setSummarizationStatusData(e){this._summarizationStatusData=e}setNickName(e){this._nickName=e}}class Do extends Lo{get kind(){return po.UNPUBLISH_PREV}execute(e,t){return v(this,void 0,void 0,function*(){const{logger:r,context:i}=e,n=t.getResourcesByUserId(t.crtUserId),s=n.slice();n.length=0;const o=r.createTraceId();r.info(ae.L_UNPUBLISH_PREV_COMMAND_T,JSON.stringify({resource:s}),o);const a=yield i.setRTCTotalRes(t.roomId,[Xt(vr.UNPUBLISH,s)],er([]),vr.TOTAL_CONTENT_RESOURCE,er([]));return a!==ie?r.error(ae.L_UNPUBLISH_PREV_COMMAND_R,JSON.stringify({status:ce.FAILED,code:a}),o):r.info(ae.L_UNPUBLISH_PREV_COMMAND_R,JSON.stringify({status:ce.SUCCESSED}),o),{code:oe.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"}(Ro||(Ro={}));class Uo extends Lo{constructor(e,t,r,i,n,s,o,a,c){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:r}),Object.defineProperty(this,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:i}),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:c})}get kind(){return po.JOINROOM}_getResultTag(){let e=ae.L_RTC_CLIENT_JOIN_RTC_ROOM_R;return this.roomType===Ro.LIVE&&(e=ae.L_RTC_CLIENT_JOIN_LIVING_ROOM_R),e}_validateParams(e,t,r){if(e.getConnectionStatus()!==ee.CONNECTED)return t.error(r,JSON.stringify({status:ce.FAILED,code:oe.SIGNAL_DISCONNECTED,msg:"im not connected"}),this.traceId),{code:oe.SIGNAL_DISCONNECTED};if(Er(e.getNaviInfo()))return t.error(r,JSON.stringify({status:ce.FAILED,code:oe.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"}),this.traceId),{code:oe.PACKAGE_ENVIRONMENT_ERROR};if(!g("roomId",this.roomId,a,!0))return t.error(r,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> roomId"}),this.traceId),{code:oe.PARAMS_ERROR};if(!g("roomType",this.roomType,e=>void 0!==Ro[e]))return t.error(r,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> roomType"}),this.traceId),{code:oe.PARAMS_ERROR};if(!g("outerUserDatas",this.outerUserDatas,c,!1))return t.error(r,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> outerUserDatas"}),this.traceId),{code:oe.PARAMS_ERROR};if(this.outerUserDatas){if(!Object.keys(this.outerUserDatas).every(e=>g(`outerUserDatas.${e}`,this.outerUserDatas[e],i,!0)))return t.error(r,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> outerUserDatas"}),this.traceId),{code:oe.PARAMS_ERROR}}if(this.nickName){if(!g("nickName",this.nickName,i,!0)||this.nickName.length>64)return t.error(r,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> nickName"}),this.traceId),{code:oe.PARAMS_ERROR}}if(this.srcLanguage){if(!g("srcLanguage",this.srcLanguage,i,!0)||this.srcLanguage.length>50)return t.error(r,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> srcLanguage"}),this.traceId),{code:oe.PARAMS_ERROR}}return{code:oe.SUCCESS}}execute(e,t,r){return v(this,void 0,void 0,function*(){var i,n,s,o;const a=Date.now(),{context:c,service:l,logger:d,reportMediaActionLogger:u}=e,_=this._getResultTag(),{code:h}=this._validateParams(c,d,_);if(h!==oe.SUCCESS)return{code:h};if(!l.getMsList().length)return d.error(_,JSON.stringify({status:ce.FAILED,code:oe.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"No audio / video server address available"}),this.traceId),{code:oe.NOT_OPEN_VIDEO_AUDIO_SERVER};const p=t.getSupportNtf(),{code:f,data:g}=yield c.joinRTCRoom(this.roomId,this.roomType,this.livingType,this.joinType,this.innerUserDatas,this.outerUserDatas,p);if(u.reportQualityJoinRoomData(a,f,this.roomType,null==g?void 0:g.sessionId),f!==ie||!g){const e=40032===f?oe.SIGNAL_JOIN_RTC_ROOM_REFUSED:f;return d.error(_,JSON.stringify({status:ce.FAILED,code:e,msg:"joinRoom failed"}),this.traceId),{code:e}}t.initWithRoomData(g,this.traceId),this.nickName&&t.setNickName(this.nickName),this.srcLanguage&&t.setSrcLanguage(this.srcLanguage);t.getResourcesByUserId(t.crtUserId).length>0&&r.push(new Do);const m=null===(i=g.roomInfo.filter(e=>"cdn_uris"===e.key)[0])||void 0===i?void 0:i.value;m&&t.setCDNUris(JSON.parse(m)[0]);const R=null===(n=g.roomInfo.filter(e=>"asr_status"===e.key)[0])||void 0===n?void 0:n.value;R&&t.setASRStatus(R);const E=null===(s=g.roomInfo.filter(e=>"sei_ai_uris"===e.key)[0])||void 0===s?void 0:s.value;if(E){const e=JSON.parse(E);e.length&&(t.setASRSeiUris(e),t.addSeiRemoteTrack(e))}const T=null===(o=g.roomInfo.filter(e=>"summarization"===e.key)[0])||void 0===o?void 0:o.value;if(T){const e=JSON.parse(T);t.setSummarizationStatusData(e)}return d.info(_,JSON.stringify({status:ce.SUCCESSED,userId:t.crtUserId,roomId:this.roomId,sessionId:g.sessionId}),this.traceId),{code:oe.SUCCESS,data:g}})}}!function(e){e[e.ROOM=1]="ROOM",e[e.PERSON=2]="PERSON"}(Eo||(Eo={}));const ko="PEER_CONNECTION_CLOSED_BY_EXCEPTION",Mo="USER_JOIN",xo="USER_LEAVE",Bo="TRACKS_PUBLISH",Vo="TRACKS_UNPUBLISH",Fo="AUDIO_MUTE_CHANGE",jo="VIDEO_MUTE_CHANGE",Go="CDN_ENABLE_CHANGE",Jo="USER_STATE_CHANGE",Ho="ASR_SEI_PUBLISH",Ko="ASR_SEI_UNPUBLISH",qo="SUMMARIZATION_START",$o="SUMMARIZATION_STOP";class Yo extends m{constructor(e,t,r,i,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:r}),Object.defineProperty(this,"runtime",{enumerable:!0,configurable:!0,writable:!0,value:i}),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 Wo,zo,Qo,Zo;!function(e){e.PUBLISH="publish",e.SUBSCRIBE="subscribe"}(Wo||(Wo={})),function(e){e.BEGIN="begin",e.END="end"}(zo||(zo={})),function(e){e[e.SPREAD=0]="SPREAD",e[e.NO_SPREAD=-1]="NO_SPREAD"}(Qo||(Qo={}));class Xo extends Lo{constructor(e,t,r){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:r})}execute(e,t,r){return v(this,void 0,void 0,function*(){var r;const{service:i,context:n}=e,s=yield i.exchange(t.getRTCRequestHeader(),this.reqBody,this.traceId,this.isNeedUpdateMsas),{code:o,data:a,qualityMsList:c}=s,l={code:o,data:{data:a,qualityMsList:c}},d=null===(r=null==a?void 0:a.urls)||void 0===r?void 0:r.pull_url;if(t.roomMode===Ro.LIVE&&d){const e=JSON.parse(d);if(t.setCDNUris(e),(null==e?void 0:e.broadcast)===Qo.SPREAD){t.setCDNEnabel(!0);const r=Object.assign(Object.assign({},e),{enableInnerCDN:!0});sa(n,t.roomId,r)}}return l})}}!function(e){e.PUB="pub",e.UNPUB="unpub",e.SUB="sub",e.UNSUB="unsub"}(Zo||(Zo={}));class ea extends Lo{constructor(e,t,r,i=Zo.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:r}),Object.defineProperty(this,"fromCommand",{enumerable:!0,configurable:!0,writable:!0,value:i}),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,r,i){const n=null==i?void 0:i.map(e=>`${e.msid}_${e.mediaType}`),s=r.filter(e=>null==n?void 0:n.includes(e.track.getTrackId())),o=r.filter(e=>!(null==n?void 0:n.includes(e.track.getTrackId())));t.info(ae.L_ABSTRACT_ROOM_SUBSCRIBE_R,JSON.stringify({status:ce.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 r=s.some(t=>t.track.getTrackId()===e&&t.subTiny);a[e].isVideoTrack()&&a[e].__innerSetIsTinyTrack(r)}return e.resetSubscribedList(s),o}_getParams(e,t,r){let i=r.map(e=>e instanceof Wt?{track:e}:Object.assign({},e));const n={};return i=i.filter(r=>{const i=r.track.getTrackId();return e.getRemoteTrack(i)?!n[i]&&(n[i]=!0,!0):(t.warn(ae.L_UPDATE_SUBSCRIBELIST_COMMAND_P,`track cannot found in room -> trackId: ${i}`,this.traceId),!1)}).map(e=>Object.assign({},e)),i}_validateParams(e,t){return g("tracks",t,()=>o(t)&&t.every(e=>e instanceof Wt||e.track instanceof Wt),!0)?{code:oe.SUCCESS}:(e.warn(ae.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"tracks is invalid"}),this.traceId),{code:oe.PARAMS_ERROR})}_reportPubOrSubQualityData(e,t,r){(null==r?void 0:r.length)&&e.reportPubOrSubQualityData(this.fromCommand,this._actionStartTime,r,t,this._trackMediaMap)}execute(e,t,r){return v(this,void 0,void 0,function*(){const{logger:i,peer:n,reportMediaActionLogger:s,context:o}=e;this._actionStartTime=Date.now();const{tracks:a,forceReq:c}=this,{roomId:l}=t;i.info(ae.L_UPDATE_SUBSCRIBELIST_COMMAND_T,`roomId: ${l}, forceReq: ${c}, trackIds: ${a.map(Ir)}`,this.traceId);const{code:d}=this._validateParams(i,a);if(d!==oe.SUCCESS)return{code:d};const u=this._getParams(t,i,a),_=t.getSubscribedList().map(e=>Object.assign({},e));if(!c){if(!_a(u,_))return i.warn(ae.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:ce.SUCCESSED,msg:"subscribe list unchanged"}),this.traceId),{code:oe.SUCCESS};if(_.length){const e=_.map(e=>e.track);i.warn(ae.L_CLEAR_UNSUBSCRIBE_LIST_O,JSON.stringify({list:e.map(e=>e.getTrackId())}),this.traceId);const r=t.getSubscribedList().filter(t=>e.every(e=>e.getTrackId()!==t.track.getTrackId()));t.resetSubscribedList(r)}}n.__reportR3R4ToPolaris(),n.clearReTryExchangeTimer(),n.updateSubRemoteTracks(u.map(e=>e.track));const h=yield ia(u,!1,n,t,o);h.pushOtherRooms=e.getPushOtherRooms();const p=yield new Xo(h,this.traceId,!0).execute(e,t,r);a.forEach(e=>{const t=e instanceof Wt?e.getTrackId():e.track.getTrackId();this._trackMediaMap[t]=p.data.qualityMsList||[]});const f=this.fromCommand===Zo.SUB?a:this.unsubTracks;if(p.code!==oe.SUCCESS)return this._reportPubOrSubQualityData(s,p.code,f),i.error(ae.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:ce.FAILED,code:p.code}),this.traceId),{code:p.code};const{sdp:g,resultCode:m,subscribedList:R}=p.data.data;if(m!==oe.SUCCESS)return this._reportPubOrSubQualityData(s,m,f),i.error(ae.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:ce.FAILED,code:m}),this.traceId),{code:m};s.setPubOrSubSuccessTime(Date.now());const E=yield n.setRemoteAnswer(g.sdp);if(this._reportPubOrSubQualityData(s,E,f),E!==oe.SUCCESS)return{code:E};const T=this._dealSubscribeResult(t,i,u,R);return T.length?{code:oe.SUCCESS,data:T}:{code:oe.SUCCESS}})}}class ta extends Lo{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,r){return v(this,void 0,void 0,function*(){const{logger:i,polarisReport:n}=e,{tracks:s}=this;if(!g("tracks",s,()=>o(s)&&s.length>0&&s.every(e=>e instanceof Wt),!0))return i.warn(ae.L_ABSTRACT_ROOM_UNSUBSCRIBE_E,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> tracks"}),this.traceId),{code:oe.PARAMS_ERROR};i.info(ae.L_ABSTRACT_ROOM_UNSUBSCRIBE_T,JSON.stringify({unSubscribeTrackIds:s.map(Ir)}),this.traceId);const a=t.getSubscribedList().map(e=>Object.assign({},e)).filter(e=>s.every(t=>t.getTrackId()!==e.track.getTrackId()));return n.sendR2(Wo.SUBSCRIBE,zo.END,s.map(e=>e.getTrackId())),new ea(a,!1,this.traceId,Zo.UNSUB,this.tracks).execute(e,t,r)})}}class ra extends Lo{constructor(e){super(),Object.defineProperty(this,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e})}execute(e,t,r){return v(this,void 0,void 0,function*(){const{logger:i}=e,{tracks:n}=this,s=i.createTraceId();return i.info(ae.L_USER_LEFT_UNSUBSCRIBE_O,void 0,s),yield new ta(n,s).execute(e,t,r),n.forEach(e=>{e.__innerDestroy(),t.removeRemoteTrack(e.getTrackId())}),e.emit(Vo,n),{code:oe.SUCCESS}})}}function ia(e,t,r,i,n){return v(this,void 0,void 0,function*(){var s;const o=(null===(s=n.getNaviInfo())||void 0===s?void 0:s.ipType)||0,a=yield r.createOffer(t),c=i.getSrcLanguage(),l=i.getNickName(),d={resolutionInfo:r.getOutboundVideoInfo()};c&&Object.assign(d,{srcLanguage:c}),l&&Object.assign(d,{nickName:l});return{asr_status:i.getASRStatus(),ipType:o,sdp:a,extend:JSON.stringify(d),subscribeList:e.filter(e=>{const t=e.track.getTrackId(),{userId:r}=or(t),n=i.getResourcesByUserId(r);if(!n)return!1;const s=n.filter(e=>t===`${e.msid}_${e.mediaType}`).length;return s}).map(e=>({simulcast:e.subTiny?$s.TINY:$s.NORMAL,resolution:"",uri:i.getPublishedResourceByTrackId(e.track.getTrackId()).uri})),switchstream:!1}})}function na(e,t,r){return v(this,void 0,void 0,function*(){const i=e.logger.createTraceId();e.logger.info(ae.L_LIVING_ROOM_SPREAD_CDN_INFO_T,JSON.stringify({CDNUris:r}),i);const n=yield e.setRTCCDNUris(t,vr.TOTAL_CONTENT_RESOURCE,JSON.stringify([r]));return n!==ie?(e.logger.error(ae.L_LIVING_ROOM_SPREAD_CDN_INFO_R,`status: ${ce.FAILED}, code: ${n}`,i),{code:oe.SIGNAL_ERROR}):(e.logger.info(ae.L_LIVING_ROOM_SPREAD_CDN_INFO_R,`status: ${ce.SUCCESSED}`,i),{code:oe.SUCCESS})})}function sa(e,t,r){return v(this,void 0,void 0,function*(){const i=e.logger.createTraceId();e.logger.info(ae.L_LIVING_ROOM_SET_ROOM_CDN_INFO_T,`CDNUris: ${r}`,i);const n=yield e.setRTCData(t,"cdn_uris",JSON.stringify([r]),!0,Eo.ROOM);return n!==ie?(e.logger.error(ae.L_LIVING_ROOM_SET_ROOM_CDN_INFO_R,`status: ${ce.FAILED}, code: ${n}`,i),{code:oe.SIGNAL_ERROR}):(e.logger.info(ae.L_LIVING_ROOM_SET_ROOM_CDN_INFO_R,`status: ${ce.SUCCESSED}`,i),{code:oe.SUCCESS})})}function oa(e,t){return v(this,void 0,void 0,function*(){const{roomId:r}=t,i=Object.assign({},t.getCDNUris(),{enableInnerCDN:t.getCDNEnable()});return(yield Promise.all([na(e,r,i),sa(e,r,i)])).every(e=>e.code===oe.SUCCESS)?{code:oe.SUCCESS}:{code:oe.SIGNAL_ERROR}})}function aa(e,t,r,i,n,s){return v(this,void 0,void 0,function*(){const{logger:o}=r,{roomId:a,roomMode:c}=t,l=[],d={},u={},_={},h=Tr(e,a,o,s),p=Object.keys(h),f=t.getAllUserIds();for(let e=p.length-1;e>=0;e-=1){const r=p[e],i=f.indexOf(r);if(-1===i){l.push(r),d[r]=cr(h[r]);continue}const n=t.getResourcesByUserId(r),s=h[r],{publishedList:o,modifiedList:a,unpublishedList:c}=lr(n,s,!0);d[r]=cr(o),u[r]=cr(c),_[r]=cr(a),f.splice(i,1)}f.length&&f.forEach(e=>{t.removeResourcesByUserId(e)}),t.assignRoomData(h),f.length&&(yield ca(f,r,t,i,s),r.emit(xo,f)),l.length&&r.emit(Mo,l),yield((e,t,r,i)=>v(void 0,void 0,void 0,function*(){const{crtUserId:n}=e;for(const s in i){if(s===n)continue;const o=i[s];if(o.length){const i=o.map(t=>e.getRemoteTrack(sr(t)));yield new ra(i).execute(t,e,r)}}}))(t,r,i,u),((e,t,r)=>{const{logger:i}=t;Object.keys(r).forEach(n=>{const s=r[n];if(0===s.length)return;const o=s.map(t=>{const r=sr(t),{userId:n,tag:s,mediaType:o}=or(r),a=o===bt.AUDIO_ONLY?new zt(i,s,n):new Qt(i,s,n);return e.addRemoteTrack(a),a.__innerSetRemoteMuted(0===t.state),a});o.length&&t.emit(Bo,o)})})(t,r,d),((e,t,r)=>{Object.keys(r).forEach(i=>{r[i].forEach(r=>{const i=sr(r),n=e.getRemoteTrack(i);n.__innerSetRemoteMuted(0===r.state),n.isAudioTrack()?t.emit(Fo,n):t.emit(jo,n)})})})(t,r,_),c===S.LIVE&&function(e,t,r,i){var n;if(!i)return void r.warn(ae.L_LIVING_ROOM_RECONNECTED_R,JSON.stringify({status:ce.FAILED,code:"",msg:"cdn_uris not found"}));const s=JSON.parse(i),o=(null===(n=t.getCDNUris())||void 0===n?void 0:n.enableInnerCDN)!==s.enableInnerCDN;t.setCDNUris(s),o&&e.emit(Go,s.enableInnerCDN)}(r,t,o,n)})}function ca(e,t,r,i,n){return v(this,void 0,void 0,function*(){const s=[],o=[];e.forEach(e=>{s.push(...r.getRemoteTracksByUserId(e)),o.push(e)}),s.length&&(yield new ta(s,n).execute(t,r,i),s.forEach(e=>r.removeRemoteTrack(e.getTrackId()))),o.length&&o.forEach(e=>r.removeResourcesByUserId(e))})}function la(e){var t;const{userId:r,userData:i,event:n,switchRoleType:s}=e;return{users:[{userId:r,extra:null===(t=i.filter(e=>"extra"===e.key)[0])||void 0===t?void 0:t.value,state:n,switchRoleType:s}]}}function da(e){var t,r;const{userId:i,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===(r=n.filter(e=>"cdn_uris"===e.key)[0])||void 0===r?void 0:r.value;return{userId:i,content:{uris:o?JSON.parse(o):[],cdn_uris:a&&JSON.parse(a)}}}const ua=(e,t,r)=>{const i=e.split("\r\nm"),n=r===bt.AUDIO_ONLY?"audio":"video",s=i.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]:""},_a=(e,t)=>{let r=!1;return e.forEach(e=>{const i=t.findIndex(t=>t.track.getTrackId()===e.track.getTrackId());if(-1===i)return void(r=!0);t.splice(i,1)[0].subTiny!==e.subTiny&&(r=!0)}),t.length&&(r=!0),r};class ha extends Lo{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 r of t){if(r.extra&&r.extra.roomId!==e.roomId)return!0;if(1===Number(r.state)&&!e.getRemoteUserIds().includes(r.userId))return!0}return!1}_dealAddUser(e,t,r,i,n){const s=e.getResourcesByUserId(n);s||(i?r.upgrade.push(n):r.joined.push(n),t.info(ae.L_PARSE_USERSTATE_COMMAND_R,JSON.stringify({userId:n,msg:"user "+(i?"upgrade":"joined")}),this.traceId)),e.setResourcesByUserId(n,s||[])}_dealReduceUser(e,t,r,i,n){e.info(ae.L_PARSE_USERSTATE_COMMAND_R,JSON.stringify({userId:n,msg:"user "+(i?"downgrade":"left")}),this.traceId),i?t.downgrade.push(n):1!==Number(r)?t.offline.push(n):t.left.push(n)}execute(e,t,r){return v(this,void 0,void 0,function*(){const{logger:i}=e,n={joined:[],left:[],offline:[],upgrade:[],downgrade:[]},{users:s}=this.msgContent;if(0===s.length)return{code:oe.SUCCESS,data:n};if(this._isPKRoomUser(t,s))return{code:oe.SUCCESS,data:n};s.forEach(e=>{const{userId:r}=e;0===Number(e.state)?this._dealAddUser(t,i,n,e.switchRoleType,r):this._dealReduceUser(i,n,e.state,e.switchRoleType,r)});const o=[...n.left,...n.downgrade,...n.offline];return o.length&&(yield ca(o,e,t,r,this.traceId)),{code:oe.SUCCESS,data:n}})}}class pa extends Lo{constructor(e,t,r,i,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:r}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:i}),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,r){return v(this,void 0,void 0,function*(){const{logger:i,reportMediaActionLogger:n}=e,s=this._nowResources.map(sr),o=[],a=[];if(this._publishedList.forEach(e=>{const r=sr(e),n=s.indexOf(r),{userId:c,tag:l,mediaType:d}=or(r);n>-1?this._nowResources[n]=e:this._nowResources.push(e);let u=t.getRemoteTrack(r);u?u.isSubscribed()&&o.push(u):(u=d===bt.AUDIO_ONLY?new zt(i,l,c):new Qt(i,l,c),t.addRemoteTrack(u),a.push(u)),u.__innerSetRemoteMuted(0===e.state)}),o.length){const n=o.map(e=>e.getTrackId()),{code:s}=yield new ea(o,!0,this.traceId).execute(e,t,r);s!==oe.SUCCESS&&i.error(ae.L_RESUB_REPUB_RES_R,JSON.stringify({status:ce.FAILED,trackIds:n,code:s}),this.traceId)}a.length&&e.emit(Bo,a),n.reportQualityRecvPubMsgData(this.sentTime,this.senderId)})}_dealUnpublishList(e,t,r){return v(this,void 0,void 0,function*(){const i=this._unpublishedList.map(sr);for(let e=this._nowResources.length-1;e>=0;e-=1){const t=this._nowResources[e];i.includes(sr(t))&&this._nowResources.splice(e,1)}const n=this._unpublishedList.map(e=>{const r=sr(e);return t.getRemoteTrack(r)});yield new ra(n).execute(e,t,r)})}_dealModifiedList(e,t){return v(this,void 0,void 0,function*(){const r=this._nowResources.map(sr);for(const i of this._modifiedList){const n=sr(i),s=r.indexOf(n);this._nowResources[s].state=i.state;const o=t.getRemoteTrack(n);o.__innerSetRemoteMuted(0===i.state),o.isAudioTrack()?e.emit(Fo,o):e.emit(jo,o)}})}_updateCDNUris(e,t){var r,i;const n=this.msgContent.cdn_uris[0],s=(null===(r=t.getCDNUris())||void 0===r?void 0:r.enableInnerCDN)!==n.enableInnerCDN;t.setCDNUris(n),s&&e.emit(Go,!!(null===(i=t.getCDNUris())||void 0===i?void 0:i.enableInnerCDN))}execute(e,t,r){return v(this,void 0,void 0,function*(){const{uris:i}=this.msgContent;let n;this._publishedList=[],this._unpublishedList=[],this._modifiedList=[];const s=this.senderId,{messageType:o}=this;if(!t.getRemoteUserIds().includes(s))return{code:oe.SUCCESS};switch(this._nowResources=t.getResourcesByUserId(s)||[],o){case vr.MODIFY:this._modifiedList.push(...i);break;case vr.PUBLISH:this._publishedList.push(...i);break;case vr.UNPUBLISH:this._unpublishedList.push(...i);break;case vr.TOTAL_CONTENT_RESOURCE:n=lr(this._nowResources,i),this._publishedList.push(...n.publishedList),this._unpublishedList.push(...n.unpublishedList),this._modifiedList.push(...n.modifiedList)}if(this._publishedList.length&&(yield this._dealPublishList(e,t,r)),this._unpublishedList.length&&(yield this._dealUnpublishList(e,t,r)),this._modifiedList.length&&(yield this._dealModifiedList(e,t)),t.setResourcesByUserId(s,this._nowResources),t.roomMode!==Ro.LIVE)return{code:oe.SUCCESS};return this.msgContent.cdn_uris?(this._updateCDNUris(e,t),{code:oe.SUCCESS}):{code:oe.SUCCESS}})}}class fa extends Lo{constructor(e,t,r){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:r})}get kind(){return po.SUBSCRIBE}execute(e,t,r){return v(this,void 0,void 0,function*(){const{logger:i,polarisReport:n}=e,{tracks:s,forceReq:a}=this;if(!g("tracks",s,()=>o(s)&&s.length>0&&s.every(e=>e instanceof Wt||e.track instanceof Wt),!0))return i.error(ae.L_ABSTRACT_ROOM_SUBSCRIBE_E,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> tracks"}),this.traceId),{code:oe.PARAMS_ERROR};i.info(ae.L_ABSTRACT_ROOM_SUBSCRIBE_T,JSON.stringify({trackIds:s.map(Ir),forceReq:a}),this.traceId);const c=t.getSubscribedList().map(e=>Object.assign({},e)),l=s.map(e=>e instanceof Wt?{track:e}:e);let d=!1;const u=[];return l.forEach(e=>{const t=e.track.getTrackId();u.push(t);const r=c.find(e=>e.track.getTrackId()===t);r&&r.subTiny===e.subTiny||(r?r.subTiny=e.subTiny:c.push(e),d=!0)}),d||a?(n.sendR2(Wo.SUBSCRIBE,zo.BEGIN,u),new ea(c,!0,this.traceId).execute(e,t,r)):(i.warn(ae.L_ABSTRACT_ROOM_SUBSCRIBE_R,JSON.stringify({status:ce.SUCCESSED,msg:"repeat subscribe"}),this.traceId),{code:oe.SUCCESS})})}}class ga extends Lo{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 r=e instanceof Vt?e:e.track;t.removeLocalTrackById(r.getTrackId())})}_addLocalTracks(e,t){return v(this,void 0,void 0,function*(){const r=[];for(const i of e){const{track:e,pubTiny:n}=i instanceof Vt?{pubTiny:!1,track:i}:i;if(e.isVideoTrack()&&n){let i;try{i=e.__innerGetMediaStreamTrack().clone();const t=n.frameRate||vt.FPS_15,r=n.resolution||Ot.W176_H144,{width:s,height:o}=ur(r),a=pr(t);yield i.applyConstraints({width:s,height:o,frameRate:a})}catch(t){null==i||i.stop(),this._logger.warn(ae.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(),i,!0);r.push(s),t.addLocalTrack(s)}t.addLocalTrack(e)}return r})}__publish(e,t,r,i){return v(this,void 0,void 0,function*(){const{peer:n,reportMediaActionLogger:s,context:o}=e,a=[];r.forEach(e=>{const{track:t}=e instanceof Vt?{track:e}:e;a.push(t)}),r.sort((e,t)=>{const{track:r}=e instanceof Vt?{track:e}:e,{max:i}=r.getBitrate(),{track:n}=t instanceof Vt?{track:t}:t,{max:s}=n.getBitrate();return i-s});if(n.getLocalTracks().length+((e,t)=>{let r=0;return e.forEach(e=>{const i=e instanceof Vt?e.getTrackId():e.track.getTrackId();t.getLocalTrack(i)||(e instanceof Vt?r++:e.pubTiny&&e.track.isVideoTrack()&&(r+=2))}),r})(r,n)>10)return this._logger.error(ae.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:ce.FAILED,code:oe.PUBLISH_TRACK_LIMIT_EXCEEDED,trackIds:r.map(Ir),msg:"publish track limit exceeded"}),this._traceId),{code:oe.PUBLISH_TRACK_LIMIT_EXCEEDED,tracks:a};const c=yield this._addLocalTracks(r,n);n.clearReTryExchangeTimer();const l=t.getSubscribedList(),d=yield ia(l,!1,n,t,o);d.pushOtherRooms=e.getPushOtherRooms();const u=yield new Xo(d,this._traceId,!0).execute(e,t,i);if(a.forEach(e=>{const t=e.getTrackId();this._trackMediaMap[t]=u.data.qualityMsList||[]}),u.code!==oe.SUCCESS)return s.reportPubOrSubQualityData(Zo.PUB,this._actionStartTime,a,u.code,this._trackMediaMap),this._logger.error(ae.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:ce.FAILED,tracks:r.map(Ir),code:u.code,msg:"exchange failed"}),this._traceId),this._removePubFailedTracks(r,n),{code:u.code,tracks:a};const{sdp:_,resultCode:h,message:p}=u.data.data;if(h!==oe.SUCCESS)return s.reportPubOrSubQualityData(Zo.PUB,this._actionStartTime,a,h,this._trackMediaMap),this._logger.error(ae.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:ce.FAILED,trackIds:r.map(Ir),code:h,msg:`exchange inner failed: ${p}`}),this._traceId),this._removePubFailedTracks(r,n),{code:h,tracks:a};s.setPubOrSubSuccessTime(Date.now());const f=yield n.setRemoteAnswer(_.sdp,!0);return f!==oe.SUCCESS?(s.reportPubOrSubQualityData(Zo.PUB,this._actionStartTime,a,f,this._trackMediaMap),this._logger.error(ae.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:ce.FAILED,trackIds:r.map(Ir),code:f,msg:"set remote answer error"}),this._traceId),{code:f,tracks:a}):(c.length&&this._updateTinyTrackIdSSRCMap(t,d.sdp.sdp,c),Object.assign(Object.assign({code:h},u.data),{tracks:a}))})}_updateTinyTrackIdSSRCMap(e,t,r){r.forEach(r=>{const i=ua(t,r.getStreamId(),bt.VIDEO_ONLY);e.setTrackIdSSRCMap(Number(i),r.getTrackId())})}_dealPublishRes(e,t,r){return v(this,void 0,void 0,function*(){const{polarisReport:i,context:n,peer:s,reportMediaActionLogger:o}=r,a=t.crtUserId,{roomId:c}=t;let l="";const d=t.getResourcesByUserId(a),u=[...d];let _=[];const{tracks:h}=e;if(e.code!==oe.SUCCESS)return{code:e.code};const{publishList:p,urls:f,mcuPublishList:g}=e.data;l=null==f?void 0:f.liveUrl;p.map(e=>Object.assign({tag:e.msid.split("_").pop(),state:s.getLocalTrack(sr(e)).isLocalMuted()?0:1},e)).forEach(e=>{const{isInclude:t,index:r}=((e,t)=>{let r=!1,i=0;for(let n=0;n<t.length;n++){const s=t[n];if(`${e.msid}_${e.mediaType}`==`${s.msid}_${s.mediaType}`){r=!0,i=n;break}}return{isInclude:r,index:i}})(e,u);t?u.splice(r,1,e):u.push(e)});_=(null==g?void 0:g.map(e=>Object.assign({tag:e.msid.split("_").pop(),state:1},e)))||[];const{publishedList:m}=lr(d,u),R=Object.assign(Object.assign({},t.getCDNUris()),{enableInnerCDN:t.getCDNEnable()}),E=R&&R.broadcast===Qo.SPREAD?JSON.stringify([R]):"",T=Date.now(),I=yield n.setRTCTotalRes(c,[Xt(vr.PUBLISH,m)],er(u),vr.TOTAL_CONTENT_RESOURCE,er(_),E);if(o.reportPubOrSubQualityData(Zo.PUB,this._actionStartTime,h,I,this._trackMediaMap,[{dur:Date.now()-T,cod:I}]),I!==ie)return this._logger.error(ae.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:ce.FAILED,code:I,msg:"send publish streams notification failed"}),this._traceId),{code:oe.SIGNAL_ERROR};t.setResourcesByUserId(a,u);const S=m.map(e=>sr(e));i.sendR2(Wo.PUBLISH,zo.BEGIN,S),m.forEach(e=>{s.getLocalTrack(`${e.msid}_${e.mediaType}`).__innerSetPublished(!0)});const v={code:oe.SUCCESS};return l&&(v.liveUrl=l),v})}execute(e,t,r){return v(this,void 0,void 0,function*(){const{logger:i,peer:n}=e;this._traceId=i.createTraceId(),this._logger=i,this._actionStartTime=Date.now();let{tracks:s}=this;if(!g("tracks",s,()=>o(s)&&s.length>0&&s.every(e=>e instanceof Vt||e.track instanceof Vt),!0))return this._logger.error(ae.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> tracks"}),this._traceId),{code:oe.PARAMS_ERROR};if(this._logger.info(ae.L_ABSTRACT_ROOM_PUBLISH_T,JSON.stringify({trackIds:s.map(Ir)})),s=s.filter(e=>{const{track:t}=e instanceof Vt?{track:e}:e,r=t.isDestroyed();return r&&this._logger.warn(ae.L_ABSTRACT_ROOM_PUBLISH_E,`track '${t.getTrackId()}' has beem destroyed`,this._traceId),!r}),!s.length)return this._logger.error(ae.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:ce.FAILED,code:oe.PUBLISH_TRACKS_IS_INVALID,msg:"params tracks is empty"}),this._traceId),{code:oe.PUBLISH_TRACKS_IS_INVALID};n.__reportR3R4ToPolaris(),n.clearReTryExchangeTimer();const a=yield this.__publish(e,t,s,r);return yield this._dealPublishRes(a,t,e)})}}class ma extends Lo{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,r,i){return v(this,void 0,void 0,function*(){const{peer:n,polarisReport:s,logger:o,reportMediaActionLogger:a,context:c}=e,l=i.map(e=>e.getTrackId());if(0===l.map(t.getPublishedResourceByTrackId.bind(t)).filter(e=>!!e).length)return{code:oe.SUCCESS,tracks:i};l.forEach(e=>n.removeLocalTrackById(e)),s.sendR2(Wo.PUBLISH,zo.END,l),n.clearReTryExchangeTimer();const d=t.getSubscribedList(),u=yield ia(d,!1,n,t,c),_=e.getPushOtherRooms();_.length&&(u.pushOtherRooms=_);const h=yield new Xo(u,this._traceId,!0).execute(e,t,r);if(i.forEach(e=>{const t=e.getTrackId();this._trackMediaMap[t]=h.data.qualityMsList||[]}),h.code!==oe.SUCCESS)return a.reportPubOrSubQualityData(Zo.UNPUB,this._actionStartTime,i,h.code,this._trackMediaMap),o.error(ae.L_ABSTRACT_ROOM_UNPUBLISH_P,JSON.stringify({status:ce.FAILED,code:h.code,trackIds:i.map(Ir),msg:"exchange failed"}),this._traceId),{code:h.code,tracks:i};const{resultCode:p,message:f}=h.data.data;return p!==oe.SUCCESS?(a.reportPubOrSubQualityData(Zo.UNPUB,this._actionStartTime,i,h.data.data.resultCode,this._trackMediaMap),o.error(ae.L_ABSTRACT_ROOM_UNPUBLISH_P,JSON.stringify({status:ce.FAILED,code:p,trackIds:i.map(Ir),msg:`exchange inner failed: ${f}`}),this._traceId),{code:p,tracks:i}):Object.assign(Object.assign({code:h.code},h.data),{tracks:i})})}_dealUnpublishRes(e,t,r){return v(this,void 0,void 0,function*(){const{context:i,logger:n,peer:s,reportMediaActionLogger:o}=e,a=i.getCurrentId(),{roomId:c}=t,l=[];let d=[];const{tracks:u,code:_,data:h}=r;if(_!==oe.SUCCESS)return n.error(ae.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({code:_,msg:"unpublish failed"}),this._traceId),{code:_};if(!h)return n.info(ae.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:ce.SUCCESSED,msg:"unpublish list is empty "})),{code:oe.SUCCESS};const{mcuPublishList:p}=h,f=u.map(e=>e.getTrackId()),g=f.map(t.getPublishedResourceByTrackId.bind(t)).filter(e=>!!e);l.push(...g);d=p?p.map(e=>Object.assign({tag:e.msid.split("_").pop(),state:1},e)):[];const m=t.getResourcesByUserId(a).filter(e=>!l.includes(e)),R=Date.now(),E=yield i.setRTCTotalRes(c,[Xt(vr.UNPUBLISH,l)],er(m),vr.TOTAL_CONTENT_RESOURCE,er(d));if(o.reportPubOrSubQualityData(Zo.UNPUB,this._actionStartTime,u,E,this._trackMediaMap,[{dur:Date.now()-R,cod:E}]),E!==ie)return n.error(ae.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:ce.FAILED,code:E,msg:"send unpublish notification failed"}),this._traceId),{code:oe.SIGNAL_ERROR};n.info(ae.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:ce.SUCCESSED,code:oe.SUCCESS,msg:"unpublish success",unPubResourceIds:f}),this._traceId);const{sdp:T}=r.data;return yield s.setRemoteAnswer(T.sdp),t.setResourcesByUserId(a,m),{code:oe.SUCCESS}})}execute(e,t,r){return v(this,void 0,void 0,function*(){const{logger:i}=e;this._actionStartTime=Date.now();const{crtUserId:n}=t,{tracks:s}=this;this._traceId=i.createTraceId();if(!g("tracks",s,()=>s.every(e=>e.getUserId()===n&&e instanceof Vt),!0))return i.error(ae.L_ABSTRACT_ROOM_UNPUBLISH_E,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> tracks"})),{code:oe.PARAMS_ERROR};i.info(ae.L_ABSTRACT_ROOM_UNPUBLISH_T,JSON.stringify({trackIds:s.map(Ir)}));const o=yield this.__unpublish(e,t,r,s);return yield this._dealUnpublishRes(e,t,o)})}}class Ra extends Lo{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,r){return v(this,void 0,void 0,function*(){const{logger:r,context:i}=e,{localTrack:n}=this,s=n.getTrackId(),{crtUserId:o,roomId:a}=t,c=!n.isLocalMuted(),l=r.createTraceId();r.info(ae.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_T,JSON.stringify({enabled:c,trackId:this.localTrack.getTrackId()}),l);const d=[{resourceId:s,enabled:c}],u=t.getResourcesByUserId(o),_=[];for(const e of u){const t=sr(e),r=d.findIndex(e=>e.resourceId===t);if(r>=0){const{enabled:t}=d[r];e.state=t?1:0,_.push(e);break}}const h=yield i.setRTCTotalRes(a,[Xt(vr.MODIFY,_)],er(u),vr.TOTAL_CONTENT_RESOURCE);return h!==ie?(r.error(ae.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_R,JSON.stringify({status:ce.FAILED,code:h,msg:"signal error"}),l),{code:h}):(r.info(ae.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_R,JSON.stringify({status:ce.SUCCESSED}),l),{code:oe.SUCCESS})})}}class Ea extends Lo{get kind(){return po.RETRY_EXCHANGE}get priority(){return fo.HIGH}execute(e,t,r){return v(this,void 0,void 0,function*(){const{logger:i,peer:n,context:s}=e,o=i.createTraceId();i.info(ae.L_RETRY_EXCHANGE_COMMAND_T);const a=s.getCurrentId(),c=t.getSubscribedList(),l=yield ia(c,!0,n,t,s);l.pushOtherRooms=e.getPushOtherRooms();const d=yield new Xo(l,o).execute(e,t,r);if(d.code!==oe.SUCCESS)return{code:d.code};const{sdp:u,resultCode:_}=d.data.data;if(_!==oe.SUCCESS)return{code:_};n.clearReTryExchangeTimer();const h=yield n.setRemoteAnswer(u.sdp);if(h!==oe.SUCCESS)return{code:h};const p=d.data.data.publishList||[],{plus:f,minus:g}=this._diffPublishListChange(p,t,n,a);return(f.length||g.length)&&(yield this._spreadPublishListUri(e,a,f,g,o)),{code:oe.SUCCESS}})}_diffPublishListChange(e,t,r,i){const n=t.getResourcesByUserId(i);let s=JSON.parse(JSON.stringify(n));e.forEach(e=>{var t;const{mediaType:i,msid:n}=e,o=s.findIndex(e=>{const{mediaType:t,msid:r}=e;return i===t&&n===r});if(-1===o){const i=Object.assign({tag:n.split("_").pop(),state:(null===(t=r.getLocalTrack(sr(e)))||void 0===t?void 0:t.isLocalMuted)?0:1},e);s.push(i)}else s[o].uri=e.uri});const{publishedList:o,unpublishedList:a}=lr(n,s,!0);return t.setResourcesByUserId(i,s),{plus:o,minus:a}}_spreadPublishListUri(e,t,r,i,n){return v(this,void 0,void 0,function*(){const{store:s,logger:o}=e,a=s.getResourcesByUserId(t);o.info(ae.L_RETRY_EXCHANGE_SPREAD_T,JSON.stringify({plus:r,minus:i,allPublishList:a}),n);const c=[];i.length&&c.push(Xt(vr.UNPUBLISH,i)),r.length&&c.push(Xt(vr.PUBLISH,r));(yield e.context.setRTCTotalRes(s.roomId,c,er(a),vr.TOTAL_CONTENT_RESOURCE))===ie?o.info(ae.L_RETRY_EXCHANGE_SPREAD_R,`status: ${ce.SUCCESSED}`,n):o.error(ae.L_RETRY_EXCHANGE_SPREAD_R,`status: ${ce.FAILED}`,n)})}}var Ta;!function(e){e[e.JOIN=0]="JOIN",e[e.LEAVE=1]="LEAVE",e[e.OFFLINE=2]="OFFLINE",e[e.RESOURCECHANGE=3]="RESOURCECHANGE"}(Ta||(Ta={}));class Ia extends Lo{constructor(e,t,r,i){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:r}),Object.defineProperty(this,"_targetPullVersion",{enumerable:!0,configurable:!0,writable:!0,value:i})}get kind(){return po.PULL_RTCROOM_STATUS}execute(e,t,r){return v(this,void 0,void 0,function*(){const{logger:i}=e,n=t.getRoomStatusVersion();if(i.info(ae.L_PULL_ROOM_STATUS_T,JSON.stringify({roomId:this._roomId,localVersion:n}),this._traceId),this._targetPullVersion&&this._targetPullVersion<=n)return i.info(ae.L_PULL_ROOM_STATUS_R,JSON.stringify({status:ce.SUCCESSED,msg:"the roomData has been pulled",localVersion:n,targetPullVersion:this._targetPullVersion}),this._traceId),{code:ie};const{code:s,data:o}=yield this._context.pullRTCRoomStatus(this._roomId,n);if(s!==ie)return i.info(ae.L_PULL_ROOM_STATUS_R,JSON.stringify({status:ce.FAILED,code:s}),this._traceId),{code:s};const{bFullStatus:a,version:c,usersData:l,roomStatus:d}=o;if(i.info(ae.L_PULL_ROOM_STATUS_R,JSON.stringify({bFullStatus:a,version:Sr(c),usersData:l,roomStatus:d}),this._traceId),t.setRoomStatusVersion(c),a){const{urisData:i,CDNUris:n}=function(e){const t={users:{}};let r="";return e.forEach(e=>{var i,n;const{userId:s,userData:o}=e;t.users[s]={};const a=null===(i=o.filter(e=>"uris"===e.key)[0])||void 0===i?void 0:i.value,c=null===(n=o.filter(e=>"cdn_uris"===e.key)[0])||void 0===n?void 0:n.value;r=c||r,t.users[s]={uris:a}}),{urisData:t,CDNUris:r&&JSON.stringify(JSON.parse(r)[0])}}(l);return yield aa(i,t,e,r,n,this._traceId),{code:s}}for(const i of d)if(i.event===Ta.RESOURCECHANGE){const n=da(i);if(!n)continue;const{content:s,userId:o}=n;if(o===t.crtUserId)continue;yield new pa(s,vr.TOTAL_CONTENT_RESOURCE,o,this._traceId).execute(e,t,r)}else{const n=la(i),{data:s}=yield new ha(n,this._traceId).execute(e,t,r);e.emit(Jo,s)}return{code:s}})}}class Sa extends Lo{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,r){return v(this,void 0,void 0,function*(){const{logger:i,peer:n,context:s}=e,{roomId:o,roomMode:a}=t,c=i.createTraceId();if(i.info(ae.L_ABSTRACT_ROOM_IM_RECONNECTED_T,void 0,c),"closed"===n.getRTCPeerConn().connectionState)return i.error(ae.L_ABSTRACT_ROOM_IM_RECONNECTED_R,"RTCPeerConnection closed. Please rejoin room to restore services",c),e.emit(ko),{code:oe.SUCCESS};const{code:l}=yield s.rtcPing(o,a);if(40001===l){(yield this._joinRoom(e,t,r,c))===ie&&(yield this._restoreMediaServer(e,t,r))}else yield new Ia(o,c,s).execute(e,t,r);return{code:oe.SUCCESS}})}_joinRoom(e,t,r,i){return v(this,void 0,void 0,function*(){var n,s,o,a;const{context:c,logger:l}=e,{code:d,data:u}=yield c.joinRTCRoom(t.roomId,t.roomMode,this.livingType);if(d!==ie)return void l.error(ae.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:ce.FAILED,code:d,msg:"im reconnect joinRTCRoom failed"}),i);if(!u)return void l.info(ae.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:ce.FAILED,msg:"im reconnect joinRTCRoom, roomData is empty"}),i);const _=null===(n=u.roomInfo.filter(e=>"cdn_uris"===e.key)[0])||void 0===n?void 0:n.value;yield aa(u,t,e,r,_,i);const h=null===(s=u.roomInfo.filter(e=>"asr_status"===e.key)[0])||void 0===s?void 0:s.value;h&&t.setASRStatus(h);const p=null===(o=u.roomInfo.filter(e=>"sei_ai_uris"===e.key)[0])||void 0===o?void 0:o.value,f=t.getASRIsAvailable();if(p){const r=JSON.parse(p);if(r.length){f||e.emit(Ho),t.setASRSeiUris(r);const{msid:i,mediaType:n}=r[0],s=`${i}_${n}`;!t.getRemoteTrack(s)&&t.addSeiRemoteTrack(r)}else f&&e.emit(Ko),t.removeSeiRemoteTrack(),t.setASRSeiUris(r)}const g=null===(a=u.roomInfo.filter(e=>"summarization"===e.key)[0])||void 0===a?void 0:a.value;if(g){const r=JSON.parse(g),i=t.getSummarizationStatusData();i&&i.status!==r.status&&e.emit(r.status===Js.OPEN?qo:$o,r.taskId),t.setSummarizationStatusData(r)}return l.info(ae.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:ce.SUCCESSED,roomData:u}),i),d})}_restoreMediaServer(e,t,r){return v(this,void 0,void 0,function*(){const i=e.peer.getLocalTracks(),n=Object.values(t.getRemoteTracks()).filter(e=>!!e.isSubscribed());i.length&&(yield new ga(i).execute(e,t,r)),!i.length&&n.length&&(yield new fa(n,!0).execute(e,t,r))})}}const va=1,Oa=5;var ba,Ca,ya,La,Aa,Na,Pa,wa;!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"}(ba||(ba={})),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"}(Ca||(Ca={}));class Da{constructor(e,t,r,i){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:r}),Object.defineProperty(this,"_userId",{enumerable:!0,configurable:!0,writable:!0,value:i}),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,r,i)=>{this._baseReportData=Object.assign(this._baseReportData,{snid:i});const n=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{cod:t,time:e,dur:Date.now()-e,rtp:r});this._logger.__statistics(ae.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===Ca.OTHER_KICK?Oa:va});this._logger.__statistics(ae.L_QS_KICKED_S,JSON.stringify(t))}reportPubOrSubQualityData(e,t,r,i,n,s){r.forEach(r=>{var o,a;const c=r instanceof Vt||r instanceof Wt?r:r.track,l=c.getTrackId(),{mediaType:d}=or(l);let u=!1;u=c instanceof Vt?!!c.isVideoTrack()&&(null===(a=(o=c).__isTiny)||void 0===a?void 0:a.call(o)):r.subTiny||!1;const _=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{resid:l,mtp:d,smct:u?$s.TINY:$s.NORMAL,stp:"Rongcloud"!==c.getTag()?1:0,cod:i,msas:n?n[l]:[],sigs:s,time:Date.now(),dur:Date.now()-t});switch(e){case"pub":this._logger.__statistics(ae.L_QS_PUBLISH_S,JSON.stringify(_));break;case"unpub":this._logger.__statistics(ae.L_QS_UNPUBLISH_S,JSON.stringify(_));break;case"sub":this._logger.__statistics(ae.L_QS_SUBSCRIBE_S,JSON.stringify(_));break;case"unsub":this._logger.__statistics(ae.L_QS_UNSUBSCRIBE_S,JSON.stringify(_))}})}reportQualityRecvPubMsgData(e,t){const r=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{puid:t,time:Date.now(),dur:Date.now()-e});this._logger.__statistics(ae.L_QS_RECV_PUB_MSG_S,JSON.stringify(r))}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}),r="pub"===e?ae.L_QS_PUB_ICE_STATUS_S:ae.L_QS_SUB_ICE_STATUS_S;this._logger.__statistics(r,JSON.stringify(t))}recordQualityIceStatusData(e,t,r){const{status:i,time:n}=this._peerCStatus||{};if(!n)return void(this._peerCStatus={status:t,time:r});const{IP:s,port:o,networkType:a,remoteIP:c,remotePort:l}=e,d=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{dur:r-n,time:r,pices:ba[i],ices:ba[t],rcdts:[{ip:`${c}:${l}`}],lcdts:[{ip:`${s}:${o}`,nttp:a}],cncdts:[]});this._logger.__statistics(ae.L_QS_ICE_STATUS_S,JSON.stringify(d)),this._peerCStatus={status:t,time:r}}}!function(e){e[e.DISABLE=0]="DISABLE",e[e.ENABLE=1]="ENABLE"}(ya||(ya={})),function(e){e[e.MeetingOrAnchor=1]="MeetingOrAnchor",e[e.Audience=2]="Audience"}(La||(La={})),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"}(Aa||(Aa={})),function(e){e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4"}(Na||(Na={}));class Ua{constructor(e,t,r,i,n=La.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:r}),Object.defineProperty(this,"_crtRTCRoom",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_userRole",{enumerable:!0,configurable:!0,writable:!0,value:n})}_send(e){return v(this,void 0,void 0,function*(){if(this._context.getConnectionStatus()!==ee.CONNECTED)return Aa.NOT_REPORT;return(yield this._context.setRTCState(this._roomId,e))===ie?Aa.REPORT_SUCCESS:Aa.REPORT_FAIL})}_getClientID(){const e="uuid";let t=this._runtime.localStorage.getItem(e);return t||(t=dr(),this._runtime.localStorage.setItem(e,t)),t}_getRealResourceId(e){let t=e;const r=e.indexOf("_tiny");return r>-1&&(t=e.slice(0,r)),t}_getPolarisTrackId(e){let t="";const r=e.split("_");if(e.includes("_tiny")){const e=r.pop(),i=parseInt(r.pop())===bt.AUDIO_ONLY?"audio":"video",n=r.pop();t=[r.join("_"),n,e,i].join("_")}else{const e=parseInt(r.pop())===bt.AUDIO_ONLY?"audio":"video",i=r.pop();t=[r.join("_"),i,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 r=e?this._crtRTCRoom.getLocalTrack(t):this._crtRTCRoom.getRemoteTrack(t);return(null==r?void 0:r.isLocalMuted())?ya.DISABLE:ya.ENABLE}sendR3Data(e){return v(this,void 0,void 0,function*(){const{iceCandidatePair:t,senders:r}=e,i=this._getBaseData(t);let n=`R3\t${i.bitrateSend}\t-1\t-1\t-1\t${i.networkType}\t${i.rtt}\t${i.localAddress}\t${i.receiveBand}\t${i.sendBand}\t${i.packetsLost}\t${i.deviceId}\r`;n+=r.map(e=>{const{trackId:t,audioLevel:r,samplingRate:i,bitrate:n,packetsLostRate:s,frameRate:o,frameWidth:a,frameHeight:c,googRenderDelayMs:l,jitter:d,nackCount:u,pliCount:_,rtt:h,googFirsSent:p,encoderImplementation:f}=e,g=this._getPolarisTrackId(t),m=this._getRealResourceId(t);return{trackId:g,googCodecName:f||String(Bs),audioLevel:this._getAudioLevel(r),bitrate:this._getBitrate(n),packetsLostRate:this._getPacketsLostRate(s),frameRate:this._getFrameRate(o),resolution:this._getResolution(a,c),jitter:this._getJitter(d),nackCount:this._getNackCount(u),pliCount:this._getPliCount(_),rtt:this._getRTT(h),googFirsSent:p,samplingRate:i,googRenderDelayMs:l,encoderImplementation:f||String(Bs),trackState:this._getTrackState(!0,m)}}).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}`))!==Aa.REPORT_SUCCESS?Aa.REPORT_FAIL:Aa.REPORT_SUCCESS})}sendR4Data(e){return v(this,void 0,void 0,function*(){const{iceCandidatePair:t,receivers:r}=e,i=this._getBaseData(t);let n=`R4\t${i.bitrateRecv}\t-1\t-1\t-1\t${i.networkType}\t${i.rtt}\t${i.localAddress}\t${i.receiveBand}\t${i.sendBand}\t${i.packetsLost}\t${i.deviceId}\r`;n+=r.filter(e=>!!e.trackId).map(e=>{const{trackId:t,audioLevel:r,samplingRate:i,bitrate:n,packetsLostRate:s,frameRate:o,frameWidth:a,frameHeight:c,googRenderDelayMs:l,jitter:d,nackCount:u,pliCount:_,rtt:h,googFirsReceived:p,codecImplementationName:f}=e,g=this._getPolarisTrackId(t),m=this._getRealResourceId(t);return{trackId:g,googCodecName:f||String(Bs),audioLevel:this._getAudioLevel(r),bitrate:this._getBitrate(n),packetsLostRate:this._getPacketsLostRate(s),frameRate:this._getFrameRate(o),resolution:this._getResolution(a,c),jitter:this._getJitter(d),nackCount:this._getNackCount(u),pliCount:this._getPliCount(_),rtt:this._getRTT(h),googFirsReceived:p,samplingRate:i,googRenderDelayMs:l,codecImplementationName:f||String(Bs),trackState:this._getTrackState(!1,m)}}).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}`))!==Aa.REPORT_SUCCESS?Aa.REPORT_FAIL:Aa.REPORT_SUCCESS})}sendR1(){var e;const t=this._context.getCoreVersion(),r=(null===(e=navigator.userAgentData)||void 0===e?void 0:e.platformn)||navigator.platform,i=`R1\t5.36.1-nctest-alpha.3\t${t}\tweb\t${r}\t-1\t${fr.browser}\t${fr.version}\t${this._getClientID()}\t${this._userRole}`;this._send(i)}sendR2(e,t,r){const i=`R2\t${e}\t${t}\t${this._getClientID()}\r${r.join("\t")}\r${this._userRole}`;this._send(i)}}class ka extends Lo{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,r){return v(this,void 0,void 0,function*(){const{peer:i,logger:n}=e;if(!this.oldTrack||!this.newTrack)return n.error(ae.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack or newTrack is empty"),{code:oe.PARAMS_ERROR};if([qt,Kt].every(e=>!(this.oldTrack instanceof e)))return n.error(ae.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack is not RCCameraVideoTrack or RCMicphoneAudioTrack"),{code:oe.PARAMS_ERROR};if([qt,Kt].every(e=>!(this.newTrack instanceof e)))return n.error(ae.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"newTrack is not RCCameraVideoTrack or RCMicphoneAudioTrack"),{code:oe.PARAMS_ERROR};const s=this.oldTrack.getSettings(),o=this.newTrack.getSettings(),a=this.oldTrack.getTrackId(),c=this.newTrack.getTrackId(),l=this.oldTrack.isAudioTrack()?"audio":"video",d=this.newTrack.isAudioTrack()?"audio":"video";if(n.info(ae.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_T,JSON.stringify({oldTrackId:a,newTrackId:c,oldSettings:s,newSettings:o})),!this.oldTrack.isPublished())return n.error(ae.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack is not published"),{code:oe.PARAMS_ERROR};if(a!==c)return n.error(ae.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,`oldTrack and newTrack trackId are different, oldTrackId: ${a}, newTrackId: ${c}`),{code:oe.PARAMS_ERROR};if(l!==d)return n.error(ae.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,`oldTrack and newTrack are not the same kind, oldTrackKind: ${l}, newTrackKind: ${d}`),{code:oe.PARAMS_ERROR};if((null==s?void 0:s.deviceId)===(null==o?void 0:o.deviceId))return n.error(ae.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:oe.PARAMS_ERROR};i.addLocalTrack(this.newTrack);const u=(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),_=i.getLocalTrack(`${this.oldTrack.getTrackId()}_tiny`);if(!u)return _&&_.destroy(),this.oldTrack.destroy(!1),this.newTrack.__innerSetPublished(!0),n.info(ae.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"changeMediaDevice success"),{code:oe.SUCCESS};const h=yield(new Ea).execute(e,t,r);return h.code!==oe.SUCCESS?(i.removeLocalTrack(this.newTrack,!1),i.addLocalTrack(this.oldTrack),this.newTrack.destroy(),n.error(ae.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,`negotiation failed, code: ${h.code}`),{code:h.code}):(_&&_.destroy(),this.oldTrack.destroy(!1),this.newTrack.__innerSetPublished(!0),n.info(ae.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"changeMediaDevice success"),{code:h.code})})}}!function(e){e[e.OPEN=1]="OPEN",e[e.CLOSE=0]="CLOSE"}(Pa||(Pa={}));class Ma extends Lo{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,r){return v(this,void 0,void 0,function*(){const{logger:r,context:i,service:n}=e;this._traceId=r.createTraceId(),this._logger=r,this._logger.info(ae.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_T,`type: ${this._type}`,this._traceId);const s=i.getNaviInfo();if((null==s?void 0:s.rtcAISwitch)===Pa.CLOSE)return this._logger.error(ae.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:oe.ASR_NOT_AVAILABLE}),this._traceId),{code:oe.ASR_NOT_AVAILABLE};if(this._type===t.getASRStatus())return this._logger.info(ae.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:oe.SUCCESS}),this._traceId),{code:oe.SUCCESS};const{roomId:o}=t,a=yield i.setRTCData(o,"asr_status",this._type.toString(),!0,Eo.ROOM,{name:vr.ASR_STATUS,content:JSON.stringify({asr_status:this._type.toString()})});if(a!==ie)return this._logger.error(ae.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:a}),this._traceId),{code:oe.SIGNAL_ERROR};t.setASRStatus(this._type);const c=yield n.updateASRStatus(t.getRTCRequestHeader(),{asr_status:this._type},this._traceId),{code:l,data:d}=c;if(l!==oe.SUCCESS||(null==d?void 0:d.resultCode)!==oe.SUCCESS&&42200!==(null==d?void 0:d.resultCode)){const e=l!==oe.SUCCESS?l:null==d?void 0:d.resultCode;return this._logger.error(ae.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:e}),this._traceId),{code:e}}return this._logger.info(ae.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:oe.SUCCESS}),this._traceId),{code:oe.SUCCESS}})}}class xa extends Lo{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,r,i){const n=`${e[0].msid}_${e[0].mediaType}`,s=r.getRemoteTrack(n);return this._enable?new fa([s]).execute(t,r,i):new ta([s],this._traceId).execute(t,r,i)}execute(e,t,r){return v(this,void 0,void 0,function*(){const{logger:i,context:n}=e;this._traceId=i.createTraceId(),this._logger=i,this._logger.info(ae.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)===Pa.CLOSE)return this._logger.error(ae.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R,JSON.stringify({code:oe.ASR_NOT_AVAILABLE}),this._traceId),{code:oe.ASR_NOT_AVAILABLE};const o=t.getASRSeiUris();if(!o.length)return this._logger.info(ae.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R,JSON.stringify({code:oe.SUCCESS,asrSeiUrisLength:0}),this._traceId),{code:oe.SUCCESS};const{code:a}=yield this._updateSubSei(o,e,t,r);return a!==oe.SUCCESS?(this._logger.error(ae.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R,JSON.stringify({code:a}),this._traceId),{code:a}):(this._logger.info(ae.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R,JSON.stringify({code:oe.SUCCESS}),this._traceId),{code:oe.SUCCESS})})}}!function(e){e[e.OPEN=1]="OPEN",e[e.CLOSE=0]="CLOSE"}(wa||(wa={}));class Ba extends Lo{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 v(this,arguments,void 0,function*(e,t,r=3,i=3e3){for(let n=1;n<=r;n++){try{const{code:r,data:i}=yield t.operateRealtimeTranslation(e.getRTCRequestHeader(),{status:this._status},this._traceId);if(r===oe.SUCCESS)return;console.warn(`第 ${n} 次调用失败,code=${r}`)}catch(e){console.error(`第 ${n} 次调用异常:`,e)}n<r&&(yield new Promise(e=>{setTimeout(e,i)}))}})}execute(e,t,r){return v(this,void 0,void 0,function*(){const{logger:r,service:i,context:n}=e;this._traceId=r.createTraceId(),this._logger=r,this._logger.info(ae.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)===Pa.CLOSE)return this._logger.error(ae.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:oe.ASR_NOT_AVAILABLE}),this._traceId),{code:oe.ASR_NOT_AVAILABLE};if(this._status===wa.OPEN){if(!this._destLanguage)return this._logger.error(ae.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:oe.PARAMS_ERROR}),this._traceId),{code:oe.PARAMS_ERROR};if(!t.getASRSeiUris().length)return this._logger.error(ae.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:oe.ASR_NOT_START}),this._traceId),{code:oe.ASR_NOT_START}}const o={status:this._status};this._destLanguage&&(o.destLanguage=this._destLanguage);const{code:a,data:c}=yield i.operateRealtimeTranslation(t.getRTCRequestHeader(),o,this._traceId);if(this._status===wa.CLOSE)return t.setIsStartRealTranslate(!1),this._logger.info(ae.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:oe.SUCCESS}),this._traceId),a!==oe.SUCCESS&&this._operateWithRetry(t,i),{code:oe.SUCCESS};if(a!==oe.SUCCESS||(null==c?void 0:c.resultCode)!==oe.SUCCESS){const e=a!==oe.SUCCESS?a:null==c?void 0:c.resultCode;return this._logger.error(ae.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(ae.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:oe.SUCCESS}),this._traceId),{code:oe.SUCCESS}})}}class Va extends Lo{constructor(e){super(),Object.defineProperty(this,"_type",{enumerable:!0,configurable:!0,writable:!0,value:e})}execute(e,t){return v(this,void 0,void 0,function*(){return t.setASRStatus(this._type),{code:oe.SUCCESS}})}}class Fa extends Lo{constructor(e){super(),Object.defineProperty(this,"_asrSeiUris",{enumerable:!0,configurable:!0,writable:!0,value:e})}_setEnableAsr(e,t,r){return v(this,void 0,void 0,function*(){const i=t.getASREnable();i&&(yield new xa(this._asrSeiUris.length>0).execute(e,t,r),t.setASREnable(i))})}_onPublish(e,t,r){e.emit(Ho),t.setASRSeiUris(this._asrSeiUris),t.addSeiRemoteTrack(this._asrSeiUris),this._setEnableAsr(e,t,r)}_onUnPublish(e,t,r){return v(this,void 0,void 0,function*(){e.emit(Ko),yield this._setEnableAsr(e,t,r),t.removeSeiRemoteTrack(),t.setASRSeiUris(this._asrSeiUris)})}execute(e,t,r){return v(this,void 0,void 0,function*(){return this._asrSeiUris.length?this._onPublish(e,t,r):this._onUnPublish(e,t,r),{code:oe.SUCCESS}})}}class ja extends Lo{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,r){return v(this,void 0,void 0,function*(){var r,i;const{logger:n,context:s,service:o}=e;this._traceId=n.createTraceId(),this._logger=n,this._logger.info(ae.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_T,`isStart: ${this._isStart}`,this._traceId);const a=s.getNaviInfo();if((null==a?void 0:a.rtcAISwitch)===Pa.CLOSE)return this._logger.error(ae.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_R,JSON.stringify({code:oe.ASR_NOT_AVAILABLE}),this._traceId),{code:oe.ASR_NOT_AVAILABLE};if(!t.getASRSeiUris().length)return this._logger.error(ae.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:oe.ASR_NOT_START}),this._traceId),{code:oe.ASR_NOT_START};if((null===(r=t.getSummarizationStatusData())||void 0===r?void 0:r.status)===Js.OPEN&&this._isStart||(null===(i=t.getSummarizationStatusData())||void 0===i?void 0:i.status)===Js.CLOSE&&!this._isStart)return this._logger.info(ae.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_R,JSON.stringify({isStart:this._isStart,code:oe.SUCCESS,taskId:t.getSummarizationStatusData().taskId}),this._traceId),{code:oe.SUCCESS,taskId:t.getSummarizationStatusData().taskId};const c={status:this._isStart?Js.OPEN:Js.CLOSE},{code:l,data:d}=yield o.operateSummarization(t.getRTCRequestHeader(),c,this._traceId);return l!==oe.SUCCESS?(this._logger.error(ae.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_R,JSON.stringify({isStart:this._isStart,code:l}),this._traceId),{code:l}):(t.setSummarizationStatusData({taskId:d.taskId,status:this._isStart?Js.OPEN:Js.CLOSE}),this._logger.info(ae.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_R,JSON.stringify({isStart:this._isStart,code:oe.SUCCESS,taskId:null==d?void 0:d.taskId}),this._traceId),{code:oe.SUCCESS,taskId:null==d?void 0:d.taskId})})}}class Ga extends Lo{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 v(this,void 0,void 0,function*(){return t.setSummarizationStatusData({status:this._status,taskId:this._taskId}),e.emit(this._status===Js.OPEN?qo:$o,this._taskId),{code:oe.SUCCESS}})}}const Ja="evt-leave";class Ha extends m{constructor(e,t,r,i,n,s,o,a,c=Fs(),l=!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: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,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:c}),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 d=this._logger=this._context.logger;this._reportMediaActionLogger=new Da(d,this._roomId,this._clientSessionId,this._context.getCurrentId()),this._polarisReport=new Ua(this._context,this._runtime,this._roomId,this);const u=this._context.getCurrentId(),_=new wo(d,c,this._context.getAppkey(),r,u,i,o,a),h=this._peerConnection=new Co(e,d,this._reTryExchange.bind(this),u,_,this._polarisReport,!1,l);this._setPeerConnectionListener();const p=this._executeCtx=new Yo(d,this._service,e,t,h,_,this._polarisReport,this._reportMediaActionLogger);p.getPushOtherRooms=()=>this._getPushOtherRoomsParams(),this.setCommandEventListener(),this._invoker=new No(p,_),this._store=this._invoker.store,this._audioLevelReport=new yo(this._store,h),h.on(Co.__INNER_AUDIOLEVEL_CHANGE__,this._audioLevelReport.audioLevelReport,this._audioLevelReport),this._pinger=new br(this._context,this._roomId,i,this._initOptions.pingGap),this._pinger.onFailed=this.__kickoff.bind(this),this._pinger.onPingResult=this._handlePingResult.bind(this),this._context.registerRTCSignalListener(e=>v(this,void 0,void 0,function*(){const{time:t,type:r,roomId:i}=this._context.decodeRtcNotify(e);if(this._invoker.isDestroyed())this._logger.info(ae.L_RTCNTF_PULL_ROOM_STATUS_O,JSON.stringify({isDestroyed:!0,type:r,time:t,roomId:i}));else if(2===r&&i===this._roomId){const e=this._logger.createTraceId();this._logger.info(ae.L_RTCNTF_PULL_ROOM_STATUS_O,null,e),this._startPullRTCRoomStatus(i,e,t)}}))}_setPeerConnectionListener(){const e=this._peerConnection;e.on(Co.__INNER_EVENT_TRACK_READY__,this._onTrackReady,this),e.on(Vt.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.on(Vt.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),e.once(Co.__INNER_ICE_CONNECTED__,e=>{this._reportMediaActionLogger.reportIceFirstConnectData(e?"pub":"sub")},this),e.on(Co.__INNER_ICE_STATE_CHANGE__,e=>{const{status:t,time:r,iceCandidatePair:i}=e;i&&this._reportMediaActionLogger.recordQualityIceStatusData(i,t,r)}),e.on(Co.__INNER_SEI_CONTENT__,this._onReceiveAsrSeiContent,this)}setCommandEventListener(){const e=this._executeCtx;e.on(ko,this._rtcpeerClosed,this),e.on(Mo,this._callAppListener.bind(this,"onUserJoin"),this),e.on(xo,this._callAppListener.bind(this,"onUserLeave"),this),e.on(Bo,this._onTrackPublish,this),e.on(Vo,this._onTrackUnpublish,this),e.on(Fo,this._onAudioMuteChange,this),e.on(jo,this._onVideoMuteChange,this),e.on(Go,this._callAppListener.bind(this,"onCDNEnableChange"),this),e.on(Jo,this._dealUserAppListener,this),e.on(Ho,this._callAppListener.bind(this,"onReceiveStartASR"),this),e.on(Ko,this._callAppListener.bind(this,"onReceiveStopASR"),this),e.on(qo,this._callAppListener.bind(this,"onReceiveStartSummarization"),this),e.on($o,this._callAppListener.bind(this,"onReceiveStopSummarization"),this)}_startPullRTCRoomStatus(e,t,r){return v(this,void 0,void 0,function*(){yield this._invoker.push(new Ia(e,t,this._context,r))})}__innerInit(e,t,r,i,n,s,o,a){return v(this,void 0,void 0,function*(){const{code:c,data:l}=yield this._invoker.push(new Uo(this._roomId,e,t,r,i,n,s,o,a));return c!==oe.SUCCESS?{code:c}:(this._initWithRoomData(l.offlineKickTime),{code:c,data:l})})}_initWithRoomData(e){this._pinger.start(1e3*e),this._polarisReport.sendR1()}_handlePingResult(e,t){if(e===Or.SUCCESS){if(t>this._store.getRoomStatusVersion()&&this._store.getSupportNtf()){const e=this._logger.createTraceId();this._logger.info(ae.L_RTCPING_PULL_ROOM_STATUS_O,JSON.stringify({dataVersion:t}),e),this._startPullRTCRoomStatus(this._roomId,e,t)}}this._callAppListener("onPing",e)}setBitrate(e,t,r){this._logger.warn(ae.L_ABSTRACT_ROOM_SETBITRATE_O,"`RCAbstractRoom.setBitrate` will be deprecated, use `RCLocalTrack.setBitrate` instead."),f("max",e,e=>s(e)&&e>Math.max(t||1,200),!0),f("min",t,t=>s(t)&&t>=1&&(!s(e)||t<e),!0),f("start",r,r=>s(r)&&r>t&&r<=e),this._peerConnection.setBitrate(e,t,r)}_onTrackReady(e){const t=e.streams[0].id,{track:r}=e.receiver,i=[t,"audio"===r.kind?bt.AUDIO_ONLY:bt.VIDEO_ONLY].join("_"),n=this._store.getRemoteTrack(i);n?(n.__innerSetMediaStreamTrack(r),this._logger.info(ae.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ce.SUCCESSED,eventType:"onTrackReady",trackId:n.getTrackId()})),this._callAppListener("onTrackReady",n)):this._logger.warn(ae.L_ABSTRACT_ROOM_ONTRACKREADY_O,`cannot found remote track ${r.id}`)}_callAppListener(e,...t){var r;const i=null===(r=this._appListener)||void 0===r?void 0:r[e];if(i)try{i(...t)}catch(e){this._logger.error(ae.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,null==e?void 0:e.stack)}}_onTrackUnpublish(e){this._logger.info(ae.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ce.SUCCESSED,eventType:"onTrackUnpublish",trackIds:null==e?void 0:e.map(e=>e.getTrackId())})),this._callAppListener("onTrackUnpublish",e)}__parseInnerMessage(e,t){const{targetId:r}=e;if(r!==this._roomId)return void this._logger.warn(ae.L_ABSTRACT_ROOM_RECEIVE_MESSAGE_O,JSON.stringify({status:ce.FAILED,message:`roomId is different, msg roomId-> ${r}, this._roomId-> ${this._roomId} `}),t);this._logger.info(ae.L_ABSTRACT_ROOM_RECEIVE_MESSAGE_O,`recv inner msg -> message: ${JSON.stringify(e)} | roomid: ${this._roomId}`,t);const{content:i}=e;switch(e.messageType){case vr.KICK:this.__kickoff(!0,i);break;case vr.STATE:this._stateHandle(i,t);break;case vr.MODIFY:case vr.PUBLISH:case vr.UNPUBLISH:case vr.TOTAL_CONTENT_RESOURCE:this._resourceHandle(i,e.messageType,e.senderUserId,e.sentTime,t);break;case vr.ASR_STATUS:this._invoker.push(new Va(i.asr_status));break;case vr.ASR_SEI:this._invoker.push(new Fa(JSON.parse(i.sei_ai_uris||[])));break;case vr.SUMMARIZATION_STATUS:this._invoker.push(new Ga(i.status,i.taskId));break;case vr.ROOM_NOTIFY:this._logger.info(ae.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ce.SUCCESSED,eventType:"onRoomAttributeChange",messageType:e.messageType,messageContent:e.content})),this._callAppListener("onRoomAttributeChange",e.messageType,e.content);break;case vr.USER_NOTIFY:this._logger.warn(ae.L_OLD_DAILY_RECORD_O,`TODO: ${vr.USER_NOTIFY}`);break;case vr.PK_INVITE:case vr.PK_CANCEL_INVITE:case vr.PK_INVITE_TIMEOUT:case vr.PK_INVITE_ANSWER:case vr.PK_END:this._onRecvPKMsg&&this._onRecvPKMsg(e);break;case vr.OTHER_ROOM_OFFLINE:break;default:this._logger.info(ae.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ce.SUCCESSED,eventType:"onMessageReceive",messageType:e.messageType,messageContent:e.content,senderUserId:e.senderUserId,messageUId:e.messageUId})),this._callAppListener("onMessageReceive",e.messageType,i,e.senderUserId,e.messageUId)}}__kickoff(e,t){return v(this,void 0,void 0,function*(){if(this._invoker.isDestroyed())return;let r,i;this._logger.warn(ae.L_ABSTRACT_ROOM_ONKICKOFF_O,`onKickOff -> byServer: ${e}, kickContent: ${JSON.stringify(t)}`),this.emit(Ja),this._leaveHandle(!e),e&&((null==t?void 0:t.users)||[]).forEach(e=>{e.userId===this._context.getCurrentId()&&(i=e.type,r=e.kickExtra,this._reportMediaActionLogger.reportQualityKickedData(i))}),this._logger.info(ae.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ce.SUCCESSED,eventType:"onKickOff",byServer:e,kickType:i,kickExtra:r})),this._callAppListener("onKickOff",e,i,r)})}_rtcpeerClosed(){this.emit(Ja),this._leaveHandle(!0),this._logger.info(ae.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,r,i,n){return v(this,void 0,void 0,function*(){const{uris:s,ignore:o}=e;!o&&s&&this._invoker.push(new pa(e,t,r,n,i))})}_onTrackPublish(e,t,r){this._logger.info(ae.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ce.SUCCESSED,eventType:"onTrackPublish",trackIds:null==e?void 0:e.map(e=>e.getTrackId())})),this._callAppListener("onTrackPublish",e)}_stateHandle(e,t){return v(this,void 0,void 0,function*(){const r=(yield this._invoker.push(new ha(e,t))).data;this._dealUserAppListener(r)})}_dealUserAppListener(e){var t,r;const{left:i,joined:n,upgrade:s,downgrade:o,offline:a}=e,c=[...n],l=[...i];(null===(t=this._appListener)||void 0===t?void 0:t.onSwitchRole)?(null==s||s.forEach(e=>{this._logger.info(ae.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ce.SUCCESSED,eventType:"onSwitchRole",userId:e,role:ho.ANCHOR})),this._callAppListener("onSwitchRole",e,ho.ANCHOR)}),null==o||o.forEach(e=>{this._logger.info(ae.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ce.SUCCESSED,eventType:"onSwitchRole",userId:e,role:ho.AUDIENCE})),this._callAppListener("onSwitchRole",e,ho.AUDIENCE)})):(c.push(...s),l.push(...o)),a.length&&((null===(r=this._appListener)||void 0===r?void 0:r.onUserOffline)?(this._logger.info(ae.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ce.SUCCESSED,eventType:"onUserOffline",offline:a})),this._callAppListener("onUserOffline",a)):l.push(...a)),c.length>0&&(this._logger.info(ae.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ce.SUCCESSED,eventType:"onUserJoin",allJoined:c})),this._callAppListener("onUserJoin",c)),l.length>0&&(this._logger.info(ae.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ce.SUCCESSED,eventType:"onUserLeave",allLeft:l})),this._callAppListener("onUserLeave",l))}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 v(this,void 0,void 0,function*(){const r=this._logger.createTraceId();this._logger.info(ae.L_ABSTRACT_ROOM_SEND_MESSAGE_T,JSON.stringify({name:e,content:t}),r);const{code:i}=yield this._context.sendMessage(X.RTC_ROOM,this._roomId,{messageType:e,content:t,isStatusMessage:!0});return i!==ie?(this._logger.error(ae.L_ABSTRACT_ROOM_SEND_MESSAGE_R,JSON.stringify({status:ce.FAILED,code:i}),r),{code:oe.SIGNAL_ERROR}):(this._logger.info(ae.L_ABSTRACT_ROOM_SEND_MESSAGE_R,JSON.stringify({status:ce.SUCCESSED,name:e,content:t}),r),{code:oe.SUCCESS})})}setRoomAttribute(e,t,r){return v(this,arguments,void 0,function*(e,t,r,i=!1){const n=this._logger.createTraceId();this._logger.info(ae.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:this._roomId,key:e,value:t,message:r,isInner:i}),n);const s=yield this._context.setRTCData(this._roomId,e,t,i,Eo.ROOM,r);return s!==ie?(this._logger.error(ae.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_R,JSON.stringify({status:ce.FAILED,code:s}),n),{code:oe.SIGNAL_ERROR}):(this._logger.info(ae.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_R,JSON.stringify({status:ce.SUCCESSED,roomId:this._roomId,key:e,value:t,message:r,isInner:i}),n),{code:oe.SUCCESS})})}deleteRoomAttributes(e,t){return v(this,arguments,void 0,function*(e,t,r=!1){const i=this._logger.createTraceId();this._logger.info(ae.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:this._roomId,keys:e,message:t,isInner:r}),i);const n=yield this._context.removeRTCData(this._roomId,e,r,Eo.ROOM,t);return n!==ie?(this._logger.error(ae.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:ce.FAILED,code:n}),i),{code:oe.SIGNAL_ERROR}):(this._logger.info(ae.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:ce.SUCCESSED,roomId:this._roomId,keys:e,message:t,isInner:r}),i),{code:oe.SUCCESS})})}getRoomAttributes(){return v(this,arguments,void 0,function*(e=[],t=!1){const r=this._logger.createTraceId();this._logger.info(ae.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:this._roomId,keys:e,isInner:t}),r);const{code:i,data:n}=yield this._context.getRTCData(this._roomId,e,t,Eo.ROOM);return i!==ie?(this._logger.error(ae.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_R,`GetRoomAttributes Failed: ${i}`,r),{code:oe.SIGNAL_ERROR}):(this._logger.info(ae.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:ce.SUCCESSED,data:n}),r),{code:oe.SUCCESS,data:n})})}_setUserAttributeValue(e,t,r){return this._context.setRTCData(this._roomId,e,t,!1,Eo.PERSON,r)}_deleteUserAttributes(e,t){return this._context.removeRTCData(this._roomId,e,!1,Eo.PERSON,t)}_getUserAttributes(e){return this._context.getRTCData(this._roomId,e,!1,Eo.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 v(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 v(this,void 0,void 0,function*(){const{code:r}=yield this._invoker.push(new Ra(e));t(r)})}publish(e){return v(this,void 0,void 0,function*(){return this._invoker.push(new ga(e))})}_getPushOtherRoomsParams(){return[]}_reTryExchange(){return this._invoker.push(new Ea)}unpublish(e){return v(this,void 0,void 0,function*(){return this._invoker.push(new ma(e))})}_isValidResourceId(e){var t;const{userId:r}=or(e);return!!(null===(t=this._store.getResourcesByUserId(r))||void 0===t?void 0:t.find(t=>sr(t)===e))}subscribe(e){return v(this,void 0,void 0,function*(){return this._invoker.push(new fa(e,void 0,void 0))})}unsubscribe(e){return v(this,void 0,void 0,function*(){const t=this._logger.createTraceId();return this._logger.info(ae.L_APP_CALL_UNSUBSCRIBE_O,void 0,t),this._invoker.push(new ta(e,t))})}updateSubList(e){return v(this,void 0,void 0,function*(){return this._invoker.push(new ea(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(ae.L_ABSTRACT_ROOM_REGISTER_ROOM_EVENT_LISTENER_O,e?Object.keys(e).join(","):null),this._appListener=e,this.asrIsAvailable()&&this._executeCtx.emit(Ho);const t=this.getSummarizationStatusData();t&&(null==t?void 0:t.status)===Js.OPEN&&this._executeCtx.emit(qo,t.taskId)}registerReportListener(e){this._logger.info(ae.L_ABSTRACT_ROOM_REGISTER_REPORT_LISTENER_O,e?Object.keys(e).join(","):null),this._peerConnection.registerReportListener(e)}onAudioLevelChange(e,t){this._logger.info(ae.L_ABSTRACT_ROOM_AUDIO_LEVEL_O),this._audioLevelReport.onAudioLevelChange(e)}__onReconnected(e){this._invoker.push(new Sa(e))}_onAudioMuteChange(e){this._logger.info(ae.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ce.SUCCESSED,eventType:"onAudioMuteChange",trackId:e.getTrackId()})),this._callAppListener("onAudioMuteChange",e)}_onVideoMuteChange(e){this._logger.info(ae.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:ce.SUCCESSED,eventType:"onVideoMuteChange",trackId:e.getTrackId()})),this._callAppListener("onVideoMuteChange",e)}_registerPKMsgListener(e){this._onRecvPKMsg=e}_quitAllPKRoom(){return v(this,void 0,void 0,function*(){})}getClientSessionId(){return this._store.clientSessionId}changeMediaDevice(e,t){return v(this,void 0,void 0,function*(){return this._invoker.push(new ka(e,t))})}startASR(){return this._invoker.push(new Ma(mo.OPEN))}stopASR(){return this._invoker.push(new Ma(mo.CLOSE))}asrIsAvailable(){return this._store.getASRIsAvailable()}setEnableASR(e){return this._invoker.push(new xa(e))}startRealtimeTranslation(e){return this._invoker.push(new Ba(wa.OPEN,e))}stopRealtimeTranslation(){return this._invoker.push(new Ba(wa.CLOSE))}startSummarization(){return this._invoker.push(new ja(!0))}stopSummarization(){return this._invoker.push(new ja(!1))}getSummarizationStatusData(){return this._store.getSummarizationStatusData()}}class Ka extends Lo{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,r){return v(this,void 0,void 0,function*(){var r,i,n,s;const{context:o,service:a}=e,c={"App-Key":o.getAppkey(),Token:t.getToken(),RoomId:t.roomId,UserId:o.getCurrentId(),SessionId:t.getSessionId()},{code:l,res:d}=yield a.setMcuConfig(c,this.data);if(l!==oe.SUCCESS)return{code:l};d.pull_url&&t.setCDNUris(JSON.parse(d.pull_url));const u=this.cdnValues;return l===oe.SUCCESS&&((null===(i=null===(r=u.output)||void 0===r?void 0:r.video.normal)||void 0===i?void 0:i.width)||(null===(s=null===(n=u.output)||void 0===n?void 0:n.video.normal)||void 0===s?void 0:s.fps))&&oa(o,t),{code:l,data:d}})}}var qa,$a,Ya,Wa;!function(e){e[e.CROP=1]="CROP",e[e.WHOLE=2]="WHOLE"}(qa||(qa={})),function(e){e[e.CUSTOMIZE=1]="CUSTOMIZE",e[e.SUSPENSION=2]="SUSPENSION",e[e.ADAPTATION=3]="ADAPTATION"}($a||($a={})),function(e){e[e.CROP=1]="CROP",e[e.WHOLE=2]="WHOLE"}(Ya||(Ya={})),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"}(Wa||(Wa={}));const za=()=>({version:2,mode:$a.SUSPENSION});class Qa{constructor(e,t,r){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:r}),Object.defineProperty(this,"_values",{enumerable:!0,configurable:!0,writable:!0,value:za()}),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(ae.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:ce.FAILED,msg:`videoTrackId: ${e} is invalid`})),this;const{mediaType:t,tag:r,userId:i}=or(e);return t!==bt.VIDEO_ONLY?(this._logger.error(ae.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:ce.FAILED,msg:`kind of ${e} is not video`})),this):(this._values.host_stream_id=ar(i,r),this._logger.info(ae.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:ce.SUCCESSED,videoTrackId:e})),this)}setMixLayoutMode(e){return[$a.CUSTOMIZE,$a.SUSPENSION,$a.ADAPTATION].includes(e)?(this._values.mode=e,this._logger.info(ae.L_MCU_CONFIG_BUILDER_SET_MIX_LAYOUT_MODE_O,JSON.stringify({status:ce.SUCCESSED,mode:e})),this):(this._logger.error(ae.L_MCU_CONFIG_BUILDER_SET_MIX_LAYOUT_MODE_O,JSON.stringify({status:ce.SUCCESSED,msg:`mode: ${e} is invalid`})),this)}_addOutputValue(e,t,r="normal"){const i=this._values.output||(this._values.output={video:{normal:{width:640,height:480}}});if("cdn"===e)return void(i.cdn=t);if("audio"===e)return void(i.audio={bitrate:t});const{video:n}=i;if("normal"===r||"tiny"===r){const e=n[r]||(n[r]={});return void Object.assign(e,t)}if("backgroundColor"!==r)if("exparams"!==r){if("backgroundPicture"===r){const e=n.backgroundPicture||(n.backgroundPicture={fillMode:qa.CROP,picture:[]});Object.assign(e,t)}}else n.exparams={renderMode:t};else n.backgroundColor=t}setOutputVideoResolution(e){if(!_r(e))return this._logger.error(ae.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RESOLUTION_O,JSON.stringify({status:ce.FAILED,msg:`params error -> resolution: ${e}`})),this;const{width:t,height:r}=ur(e);return this._addOutputValue("video",{width:t,height:r},"normal"),this._logger.info(ae.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RESOLUTION_O,JSON.stringify({status:ce.SUCCESSED,resolution:e})),this}setOutputVideoFPS(e){if(!hr(e))return this._logger.error(ae.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_FPS_O,JSON.stringify({status:ce.FAILED,msg:`params error -> fps: ${e}`})),this;const t=pr(e);return this._addOutputValue("video",{fps:t},"normal"),this._logger.info(ae.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_FPS_O,JSON.stringify({status:ce.SUCCESSED,fps:e})),this}setOutputVideoBitrate(e){return!s(e)||e<=0?(this._logger.error(ae.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_BITRATE_O,JSON.stringify({status:ce.FAILED,msg:`params error -> bitrate: ${e}`})),this):(this._addOutputValue("video",{bitrate:e},"normal"),this._logger.info(ae.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_BITRATE_O,JSON.stringify({status:ce.SUCCESSED,bitrate:e})),this)}setOutputTinyVideoResolution(e){if(!_r(e))return this._logger.error(ae.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_RESOLUTION_O,JSON.stringify({status:ce.FAILED,msg:`params error -> resolution: ${e}`})),this;const{width:t,height:r}=ur(e);return this._addOutputValue("video",{width:t,height:r},"tiny"),this._logger.info(ae.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_RESOLUTION_O,JSON.stringify({status:ce.SUCCESSED,resolution:e})),this}setOutputTinyVideoFPS(e){if(!hr(e))return this._logger.error(ae.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_FPS_O,JSON.stringify({status:ce.FAILED,msg:`params error -> fps: ${e}`})),this;const t=pr(e);return this._addOutputValue("video",{fps:t},"tiny"),this._logger.info(ae.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_FPS_O,JSON.stringify({status:ce.SUCCESSED,fps:e})),this}setOutputTinyVideoBitrate(e){return!s(e)||e<=0?(this._logger.error(ae.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_BITRATE_O,JSON.stringify({status:ce.FAILED,msg:`params error -> bitrate: ${e}`})),this):(this._addOutputValue("video",{bitrate:e},"tiny"),this._logger.info(ae.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_BITRATE_O,JSON.stringify({status:ce.SUCCESSED,bitrate:e})),this)}setOutputVideoRenderMode(e){return[Ya.CROP,Ya.WHOLE].includes(e)?(this._addOutputValue("video",e,"exparams"),this._logger.info(ae.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RENDER_MODE_O,JSON.stringify({status:ce.SUCCESSED,renderMode:e})),this):(this._logger.error(ae.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RENDER_MODE_O,JSON.stringify({status:ce.FAILED,msg:`params error -> renderMode: ${e}`})),this)}setOutputAudioBitrate(e){return s(e)&&e>0?(this._addOutputValue("audio",e),this._logger.info(ae.L_MCU_CONFIG_BUILDER_SET_OUTPUT_AUDIO_BITRATE_O,JSON.stringify({status:ce.SUCCESSED,bitrate:e})),this):(this._logger.error(ae.L_MCU_CONFIG_BUILDER_SET_OUTPUT_AUDIO_BITRATE_O,JSON.stringify({status:ce.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(ae.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_COLOR_O,JSON.stringify({status:ce.SUCCESSED,color:e})),this):(this._logger.error(ae.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_COLOR_O,JSON.stringify({status:ce.FAILED,msg:`params error -> color: ${e}`})),this)}addOutputBackgroundPicture(e,t,r,i,n){var o,a,c;if(!u(e))return this._logger.error(ae.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:ce.FAILED,msg:`params error -> uri: ${e}`})),this;if([t,r,i,n].some(e=>!s(e)||e<0||e>1))return this._logger.error(ae.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:ce.FAILED,msg:`params of (x, y, w, h) error -> x: ${t}, y: ${r}, w: ${i}, h: ${n}`})),this;const l=(null===(c=null===(a=null===(o=this._values.output)||void 0===o?void 0:o.video)||void 0===a?void 0:a.backgroundPicture)||void 0===c?void 0:c.picture)||[];return l.push({uri:e,w:i,h:n,x:t,y:r}),this._addOutputValue("video",{picture:l},"backgroundPicture"),this._logger.info(ae.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:ce.SUCCESSED,uri:e,x:t,y:r,w:i,h:n})),this}removeOutputBackgroundPicture(e){var t,r,i;if(!u(e))return this._logger.error(ae.L_MCU_CONFIG_BUILDER_REMOVE_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:ce.FAILED,msg:`params error -> uri: ${e}`})),this;let n=null===(i=null===(r=null===(t=this._values.output)||void 0===t?void 0:t.video)||void 0===r?void 0:r.backgroundPicture)||void 0===i?void 0:i.picture;return n&&(n=n.filter(t=>t.uri!==e),this._addOutputValue("video",{pictures:n},"backgroundPicture")),this._logger.info(ae.L_MCU_CONFIG_BUILDER_REMOVE_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:ce.SUCCESSED,uri:e})),this}clearOutputBackgroundPicture(){return this._addOutputValue("video",{pictures:[]},"backgroundPicture"),this._logger.info(ae.L_MCU_CONFIG_BUILDER_CLEAR_OUTPUT_BACKGROUND_PICTURE_O),this}setOutputBackgroundPictureFillMode(e){return[qa.CROP,qa.WHOLE].includes(e)?(this._addOutputValue("video",{fillMode:e},"backgroundPicture"),this._logger.info(ae.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:ce.SUCCESSED,fillMode:e})),this):(this._logger.error(ae.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:ce.FAILED,msg:`params error -> fillMode: ${e}`})),this)}addPublishStreamUrls(e){var t,r;const i=/^rtmp:\/\/.+/;if(!o(e)||0===e.length||e.some(e=>!i.test(e)))return this._logger.error(ae.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:ce.FAILED,msg:`params error -> urls: ${e.join(",")}`})),this;const n=(null===(r=null===(t=this._values.output)||void 0===t?void 0:t.cdn)||void 0===r?void 0:r.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(ae.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:ce.FAILED,msg:`params error -> publish stream urls no more than 5, length: ${e.length}`})),this):(s&&this._addOutputValue("cdn",n),this._logger.info(ae.L_MCU_CONFIG_BUILDER_ADD_PUBLISH_STREAM_URLS_O,JSON.stringify({status:ce.SUCCESSED,urls:e})),this)}removePublishStreamUrls(e){var t,r;const i=/^rtmp:\/\/.+/;if(!o(e)||0===e.length||e.some(e=>!i.test(e)))return this._logger.error(ae.L_MCU_CONFIG_BUILDER_REMOVE_PUBLISH_STREAM_URLS_O,JSON.stringify({status:ce.FAILED,msg:`params error -> urls: ${e.join(",")}`})),this;const n=(null===(r=null===(t=this._values.output)||void 0===t?void 0:t.cdn)||void 0===r?void 0:r.concat())||[];for(let t=n.length-1;t>=0;t-=1){const{pushurl:r}=n[t],i=e.indexOf(r);i>=0&&(e.splice(i,1),n.splice(t,1))}return this._addOutputValue("cdn",n),this._logger.info(ae.L_MCU_CONFIG_BUILDER_REMOVE_PUBLISH_STREAM_URLS_O,JSON.stringify({status:ce.SUCCESSED,urls:e})),this}clearPublishStreamUrls(){return this._addOutputValue("cdn",[]),this._logger.info(ae.L_MCU_CONFIG_BUILDER_CLEAR_PUBLISH_STREAM_URLS_O),this}addCustomizeLayoutVideo(e,t,r,i,n){if(!a(e)||!this._isValidTrackId(e))return this._logger.error(ae.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ce.FAILED,msg:`params error -> trackId: ${e}`})),this;if(!s(t)||!s(r))return this._logger.error(ae.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ce.FAILED,msg:`params x or y is error -> x: ${t}, y: ${r}`})),this;if([i,n].some(e=>!s(e)||e<0))return this._logger.error(ae.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ce.FAILED,msg:`params width or height error -> width: ${i}, height: ${n}`})),this;const{userId:o,tag:c,mediaType:l}=or(e);if(l!==bt.VIDEO_ONLY)return this._logger.error(ae.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ce.FAILED,msg:`type of trackId: ${e} is not video`})),this;const d=ar(o,c),u=this._values.input||(this._values.input={}),_=u.video||(u.video=[]);return _.some(e=>e.height===n&&e.width===i&&e.stream_id===d&&e.user_id===o&&e.x===t&&e.y===r)?(this._logger.warn(ae.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ce.FAILED,msg:"Duplicate configuration item place ignored"})),this):(_.push({user_id:o,stream_id:d,x:t,y:r,width:i,height:n}),this._logger.info(ae.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ce.SUCCESSED,trackId:e,x:t,y:r,width:i,height:n})),this)}removeCustomizeLayoutVideo(e){if(!this._isValidTrackId(e))return this._logger.error(ae.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ce.FAILED,msg:`params error -> trackId: ${e}`})),this;const{userId:t,tag:r,mediaType:i}=or(e);if(i!==bt.VIDEO_ONLY)return this._logger.error(ae.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ce.FAILED,msg:`type of trackId: ${e} is not video`})),this;const n=ar(t,r),{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(ae.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:ce.SUCCESSED,trackId:e})),this}clearCustomizeLayoutVideo(){const{input:e}=this._values;return null==e||delete e.video,this._logger.info(ae.L_MCU_CONFIG_BUILDER_CLEAR_CUSTOMIZE_LAYOUT_VIDEO_O),this}setCustomizeInputAudio(e){if(e.some(e=>this._isValidTrackId(e)))return this._logger.error(ae.L_MCU_CONFIG_BUILDER_SET_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:ce.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:r}=or(e);return{stream_id:ar(t,r),user_id:t}}),this._values.inputFilterMode=Wa.AUDIO_INPUT_VIDEO_ALL,this._logger.info(ae.L_MCU_CONFIG_BUILDER_SET_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:ce.SUCCESSED,trackIds:e})),this}addCustomizeInputAudio(e){if(!this._isValidTrackId(e))return this._logger.error(ae.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:ce.FAILED,msg:`params error -> trackId: ${e}`})),this;const t=this._values.input||(this._values.input={}),r=t.audio||(t.audio=[]),{userId:i,tag:n}=or(e),s=ar(i,n);return r.some(e=>e.stream_id===s&&e.user_id===i)?(this._logger.warn(ae.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:ce.FAILED,msg:`trackId: ${e} is exist`})),this):(r.push({user_id:i,stream_id:s}),this._values.inputFilterMode=Wa.AUDIO_INPUT_VIDEO_ALL,this._logger.info(ae.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:ce.SUCCESSED,trackId:e})),this)}removeCustomizeInputAudio(e){if(!this._isValidTrackId(e))return this._logger.error(ae.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:ce.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(ae.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:ce.FAILED,msg:`type of trackId: ${e} is not audio`})),this;const{userId:r,tag:i}=or(e),n=ar(r,i);return t.audio=t.audio.filter(e=>r!==e.user_id||n!==e.stream_id),this._logger.info(ae.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:ce.SUCCESSED,trackId:e})),this}clearCustomizeInputAudio(){const{input:e}=this._values;return(null==e?void 0:e.audio)&&delete e.audio,this._values.inputFilterMode=Wa.AUDIO_VIDEO_ALL,this._logger.info(ae.L_MCU_CONFIG_BUILDER_CLEAR_CUSTOMIZE_INPUT_AUDIO_O),this}addPictureWaterMark(e,t,r,i,n,o){if(!this._isValidTrackId(e))return this._logger.error(ae.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:ce.FAILED,msg:`params error -> trackId: ${e}`})),this;if(!u(t))return this._logger.error(ae.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:ce.FAILED,msg:`params error -> uri: ${t}`})),this;if([r,i,n,o].some(e=>!s(e)||e<0||e>1)||r+n>1||i+o>1)return this._logger.error(ae.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:ce.FAILED,msg:`some attrs of (x, y, w, h) is invalid -> x: ${r}, y: ${i}, w: ${n}, h: ${o}`})),this;const{userId:a,tag:c}=or(e),l=ar(a,c),d=this._values.waterMark||(this._values.waterMark={enable:"on",singleScreen:[]}),{singleScreen:_}=d,h=_.filter(e=>e.streamId===l)[0];return h?h.picture.push({uri:t,w:n,h:o,x:r,y:i}):_.push({streamId:l,picture:[{uri:t,w:n,h:o,x:r,y:i}]}),this._values.waterMark.singleScreen=_,this._logger.info(ae.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:ce.SUCCESSED,trackId:e,uri:t,x:r,y:i,w:n,h:o,singleScreen:_})),this}clearPictureWaterMark(){return(this._values.waterMark||(this._values.waterMark={enable:"on",singleScreen:[]})).singleScreen=[],this._logger.info(ae.L_MCU_CONFIG_BUILDER_CLEAR_OUTPUT_BACKGROUND_PICTURE_O),this}removePictureWaterMark(e,t){if(!a(e)||!this._isValidTrackId(e))return this._logger.error(ae.L_MCU_CONFIG_BUILDER_REMOVE_SINGLE_WATER_MARK_O,JSON.stringify({status:ce.FAILED,msg:`params error -> trackId: ${e}`})),this;const{userId:r,tag:i}=or(e),n=ar(r,i),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(ae.L_MCU_CONFIG_BUILDER_REMOVE_SINGLE_WATER_MARK_O,JSON.stringify({status:ce.SUCCESSED,trackId:e,uri:t})),this}reset(){return this._values=za(),this._logger.info(ae.L_MCU_CONFIG_BUILDER_RESET_O),this}flush(){return v(this,arguments,void 0,function*(e=!0){const t=JSON.parse(JSON.stringify(this._values)),{code:r}=yield this._invoker.push(new Ka(t,this._values));return e&&(this._values=za()),{code:r}})}__innerGetValues(){return JSON.parse(JSON.stringify(this._values))}}var Za,Xa,ec;!function(e){e[e.VIDEO=0]="VIDEO",e[e.AUDIO=1]="AUDIO"}(Za||(Za={}));class tc extends Lo{constructor(e,t,r){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:r})}_exchangeWithPushOtherRoom(e,t,r){return v(this,void 0,void 0,function*(){const{logger:i,peer:n,context:s}=e;if(!n.getLocalTracks().length)return void i.info(ae.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:ce.SUCCESSED,msg:"have not published resource"}),this.traceId);const o=n,a=t.getSubscribedList(),c=yield ia(a,!1,o,t,s),l=e.getPushOtherRooms();c.pushOtherRooms=l;const d=yield new Xo(c,this.traceId,!0).execute(e,t,r);if(d.code!==oe.SUCCESS)return void i.error(ae.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:ce.FAILED,code:d.code,pushOtherRooms:l}),this.traceId);const{sdp:u,resultCode:_}=d.data.data;_===oe.SUCCESS?(i.info(ae.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:ce.SUCCESSED,pushOtherRooms:l}),this.traceId),o.setRemoteAnswer(u.sdp)):i.error(ae.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:ce.FAILED,code:_,pushOtherRooms:l}),this.traceId)})}get kind(){return po.EXCHANGE_WITH_PUSH_OTHER_ROOM}execute(e,t,r){return v(this,void 0,void 0,function*(){const{logger:i}=e,{roomId:n}=this;if(i.info(ae.L_EXCHANGE_WITH_PUSHOTHERROOM_T,n),!this.roomPKHandler)return i.error(ae.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:ce.FAILED,msg:"_roomPKHandler not exist"}),this.traceId),{code:oe.SUCCESS};return this.roomPKHandler.getPKInfo(n)?(yield this._exchangeWithPushOtherRoom(e,t,r),{code:oe.SUCCESS}):(i.warn(ae.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:ce.FAILED,msg:"PKInfo not exist"}),this.traceId),{code:oe.SUCCESS})})}}class rc extends Lo{constructor(e,t,r,i,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:r}),Object.defineProperty(this,"_joinedPKRooms",{enumerable:!0,configurable:!0,writable:!0,value:i}),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,r,i){return v(this,void 0,void 0,function*(){const{logger:n,context:s}=e;if(n.info(ae.L_QUIT_PK_T,`roomId: ${t}`,i),!this._PKInfo[t])return void n.warn(ae.L_QUIT_PK_R,`status: ${ce.FAILED}, msg: pkinfo is empty`,i);const{inviterRoomId:o,inviteeRoomId:a,inviterUserId:c,inviteSessionId:l}=this._PKInfo[t],d={inviteeRoomId:a,inviterRoomId:o,userId:r.crtUserId},u={roomId:r.roomId,endRoomId:t,sessionId:l,content:JSON.stringify(d),keys:[`${o}|${c}`]},_=yield s.endRoomPK(u);if(_!==ie)return n.error(ae.L_QUIT_PK_R,`status: ${ce.FAILED}, code: ${_}`,i),{code:oe.SIGNAL_ERROR};n.info(ae.L_QUIT_PK_R,`status: ${ce.SUCCESSED}`,i),delete this._PKInfo[t]})}execute(e,t,r){return v(this,void 0,void 0,function*(){const{logger:i}=e,{room:n,isQuitPK:s}=this,o=n.getRoomId();return i.info(ae.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 tc(o,this.pkHandler,this.traceId).execute(e,t,r),s&&this.quitRoomPK(e,o,t,this.traceId),i.info(ae.L_LIVING_ROOM_LEAVE_PK_ROOM_R,JSON.stringify({status:ce.SUCCESSED}),this.traceId),{code:oe.SUCCESS}})}}class ic{constructor(e,t,r,i,n,s,o,a,c,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:r}),Object.defineProperty(this,"_runtime",{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,"_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:c}),Object.defineProperty(this,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:l}),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 r;const i=null===(r=this._appListener)||void 0===r?void 0:r[e];if(i)try{i(...t)}catch(e){this._logger.error(ae.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify(e))}}_onInvite(e){const t=e.inviteInfo||{},{inviterRoomId:r,inviterUserId:i,extra:n}=t,s={inviterRoomId:r,inviterUserId:i,extra:n};this._PKInfo[r]=t,this._logger.info(ae.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onRequestJoinOtherRoom",info:s})),this._callAppListener("onRequestJoinOtherRoom",s)}_onCancelInvite(e){const{inviterRoomId:t,inviterUserId:r,extra:i}=e.inviteInfo||{},n={inviterRoomId:t,inviterUserId:r,extra:i};delete this._PKInfo[t],this._logger.info(ae.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:r}=e,{inviteSessionId:i,inviterUserId:n,inviterRoomId:s,inviteeUserId:o,inviterUserAutoMix:a,inviteeUserAutoMix:c,inviteeRoomId:l,extra:d}=r,u={agree:1===t,inviterRoomId:s,inviterUserId:n,inviteeRoomId:l,inviteeUserId:o,extra:d};this._PKInfo[l]=this._PKInfo[l]||{inviteSessionId:i,inviterRoomId:s,inviterUserId:n,inviterUserAutoMix:a,inviteeRoomId:l},this._PKInfo[l].inviteeUserAutoMix=c,this._logger.info(ae.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onResponseJoinOtherRoom",answerInfo:u})),this._callAppListener("onResponseJoinOtherRoom",u)}createLeaveOtherRoomCommand(e,t,r){return new rc(this,e,this._PKInfo,this._joinedPKRooms,t,r)}_onPKEnd(e){return v(this,void 0,void 0,function*(){const{inviteeRoomId:t,inviterRoomId:r,userId:i}=e.inviteInfo,n=r===this._mainRoomId?t:r,s={endRoomId:n,endUserId:i},o=this._joinedPKRooms[n],a=this._logger.createTraceId();this._logger.info(ae.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(ae.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onFinishOtherRoom",endInfo:s})),this._callAppListener("onFinishOtherRoom",s)})}_onRecvPKMsg(e){const{content:t,messageType:r}=e;switch(r){case vr.PK_INVITE:this._onInvite(t);break;case vr.PK_CANCEL_INVITE:this._onCancelInvite(t);break;case vr.PK_INVITE_TIMEOUT:this._onInviteTimeout(t);break;case vr.PK_INVITE_ANSWER:this._onInviteAnswer(t);break;case vr.PK_END:this._onPKEnd(t)}}registerRoomPKEventListener(e){this._logger.info(ae.L_LIVING_PK_HANDLER_REGISTER_ROOM_PK_EVENT_LISTENER_O,JSON.stringify({listener:e&&Object.keys(e)})),this._appListener=e}requestJoinOtherRoom(e,t,r){return v(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(ae.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_T,JSON.stringify({inviteeRoomId:e,inviteeUserId:t,options:r}),i),!g("inviteeRoomId",e,a,!0)||!g("inviteeUserId",t,a,!0))return this._logger.error(ae.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> inviteeRoomId or inviteeUserId"}),i),{code:oe.PARAMS_ERROR};const s=Fs(),o=!n(null==r?void 0:r.autoMix)||(null==r?void 0:r.autoMix),c={inviteSessionId:s,inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviterUserAutoMix:o,inviteeRoomId:e,inviteeUserId:t,inviteeTimeoutTime:this._inviteTimeout,extra:(null==r?void 0:r.extra)||""},l={roomId:this._mainRoomId,invitedRoomId:e,invitedUserId:t,inviteTimeout:this._inviteTimeout,inviteInfo:JSON.stringify(c),inviteSessionId:s},d=yield this._context.requestRoomPK(l);return d!==ie?(this._logger.error(ae.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:ce.FAILED,code:d}),i),{code:d}):(this._PKInfo[e]={inviteSessionId:s,inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviterUserAutoMix:o,inviteeRoomId:e},this._logger.info(ae.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:ce.SUCCESSED}),i),{code:oe.SUCCESS})})}cancelRequestJoinOtherRoom(e,t,r){return v(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(ae.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_T,JSON.stringify({inviteeRoomId:e,inviteeUserId:t,extra:r}),i),!g("inviteeRoomId",e,a,!0)||!g("inviteeUserId",t,a,!0))return this._logger.error(ae.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> inviteeRoomId or inviteeUserId"}),i),{code:oe.PARAMS_ERROR};if(!this._PKInfo[e])return this._logger.error(ae.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:`The request to connect with ${t} user in room ${e} is not initiated`}),i),{code:oe.PARAMS_ERROR};const n={inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviteeRoomId:e,inviteeUserId:t,extra:r||""},s={roomId:this._mainRoomId,invitedRoomId:e,invitedUserId:t,inviteSessionId:this._PKInfo[e].inviteSessionId,inviteInfo:JSON.stringify(n)},o=yield this._context.cancelRoomPK(s);return o!==ie?(this._logger.error(ae.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:ce.FAILED,code:o}),i),{code:o}):(this._logger.info(ae.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:ce.SUCCESSED}),i),delete this._PKInfo[e],{code:oe.SUCCESS})})}responseJoinOtherRoom(e,t,r,i){return v(this,void 0,void 0,function*(){const s=this._logger.createTraceId();if(this._logger.info(ae.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_T,JSON.stringify({inviterRoomId:e,inviterUserId:t,agree:r,options:i}),s),!g("inviterRoomId",e,a,!0)||!g("inviterUserId",t,a,!0))return this._logger.error(ae.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> inviterRoomId or inviterUserId"}),s),{code:oe.PARAMS_ERROR};if(!this._PKInfo[e])return this._logger.error(ae.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:`User ${t} in room ${e} did not send a request for connection`}),s),{code:oe.PARAMS_ERROR};const{inviteSessionId:o,inviterUserAutoMix:c}=this._PKInfo[e],l=!n(null==i?void 0:i.autoMix)||(null==i?void 0:i.autoMix),u={inviteSessionId:o,inviterRoomId:e,inviterUserId:t,inviterUserAutoMix:c,inviteeRoomId:this._mainRoomId,inviteeUserId:this._context.getCurrentId(),inviteeUserAutoMix:l},_=Object.assign(u,{inviterUserAutoMix:c}),h=r?Object.assign(u,{MultiRoomKey:`${e}|${this._mainRoomId}`,MultiRoomValue:JSON.stringify(_)}):u;!d(null==i?void 0:i.extra)&&Object.assign(h,{extra:i.extra});const p={agree:r,roomId:this._mainRoomId,inviteSessionId:o,inviteRoomId:e,inviteUserId:t,content:JSON.stringify(h),key:`${e}|${this._mainRoomId}`,value:JSON.stringify(u)},f=yield this._context.responseRoomPK(p);return f!==ie?(this._logger.error(ae.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:ce.FAILED,code:f}),s),{code:f}):(this._logger.info(ae.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:ce.SUCCESSED}),s),this._PKInfo[e].inviteeUserAutoMix=l,{code:oe.SUCCESS})})}joinOtherRoom(e){return v(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(ae.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_T,JSON.stringify({roomId:e}),t),!g("roomId",e,a,!0))return this._logger.error(ae.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> roomId"}),t),{code:oe.PARAMS_ERROR};if(this._context.getConnectionStatus()!==ee.CONNECTED)return this._logger.error(ae.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:ce.FAILED,code:oe.SIGNAL_DISCONNECTED,msg:"IM disconnected"}),t),{code:oe.SIGNAL_DISCONNECTED};if(this._joinedPKRooms[e])return this._logger.warn(ae.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:ce.FAILED,code:oe.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),t),{code:oe.REPERT_JOIN_ROOM};const r=Za.VIDEO,i={extra:`{"roomId": "${this._mainRoomId}"}`},n=new oc(this._context,this._runtime,e,this._service,this._initOptions,r,!1,!1,this._clientSessionId),{code:s}=yield n.__innerInit(Ro.LIVE,void 0,r,i);return s!==oe.SUCCESS?(this._logger.error(ae.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:ce.FAILED,code:s}),t),{code:s}):(this._joinedPKRooms[e]=n,yield this._onJoinedPKRoom(e,t),this._logger.info(ae.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:ce.SUCCESSED}),t),{room:n,code:oe.SUCCESS,userIds:n.getRemoteUserIds(),tracks:n.getRemoteTracks()})})}leaveOtherRoom(e,t){return v(this,void 0,void 0,function*(){const r=this._logger.createTraceId();return this._logger.info(ae.L_APP_CALL_LEAVE_PK_ROOM_O,void 0,r),this._invoker.push(this.createLeaveOtherRoomCommand(e,t,r))})}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"}(Xa||(Xa={}));class nc extends Lo{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,r){return v(this,void 0,void 0,function*(){const{logger:i,context:s}=e,{enable:o}=this;if(i.info(ae.L_LIVING_ROOM_ENABLE_INNER_CDN_T,JSON.stringify({roomId:t.roomId,enable:o})),!t.isMainRoom)return i.error(ae.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:ce.FAILED,code:oe.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),{code:oe.THE_FUNCTION_IS_DISABLED_IN_PKROOM};if(!n(o))return i.error(ae.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> enable"})),{code:oe.PARAMS_ERROR};t.setCDNEnabel(o);const a={version:2,output:{inCDNModel:o?Xa.OPEN:Xa.STOP}},{code:c}=yield new Ka(a,this.cdnValues).execute(e,t,r);if(c!==oe.SUCCESS)return i.error(ae.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:ce.FAILED,code:c,msg:"signal error"})),{code:oe.SIGNAL_ERROR};const l=t.getCDNUris();if(l&&l.broadcast!==Qo.SPREAD)return i.info(ae.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:ce.SUCCESSED,enable:o})),{code:oe.SUCCESS};const{code:d}=yield oa(s,t);return d===oe.SUCCESS?(i.info(ae.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:ce.SUCCESSED,enable:o})),{code:oe.SUCCESS}):(i.error(ae.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:ce.FAILED,code:d})),{code:d})})}}!function(e){e[e.AnchorToViewer=1]="AnchorToViewer",e[e.ViewerToAnchor=2]="ViewerToAnchor"}(ec||(ec={}));class sc extends Lo{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,r){return v(this,void 0,void 0,function*(){var i;const{context:n}=e,{code:s,data:o}=yield n.rtcIdentityChange(t.roomId,ec.ViewerToAnchor,this.livingType);if(s!==ie||!o)return{code:s};t.initWithRoomData(o,this.traceId);t.getResourcesByUserId(t.crtUserId).length>0&&r.push(new Do);const a=null===(i=o.roomInfo.filter(e=>"cdn_uris"===e.key)[0])||void 0===i?void 0:i.value;return a&&t.setCDNUris(JSON.parse(a)[0]),{code:s,data:o}})}}class oc extends Ha{constructor(e,t,r,i,n,s,o,a,c){super(e,t,r,Ro.LIVE,i,n,o,a,c),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 Qa(this._executeCtx,this._invoker,this._isValidResourceId.bind(this))}_initRoomPKHandler(e){if(this._store.isMainRoom){const t=((e,t)=>{const r={};return t.forEach(t=>{const i=JSON.parse(t.value),{inviterRoomId:n,inviteeRoomId:s}=i;r[e===n?s:n]=JSON.parse(t.value)}),r})(this._roomId,e.roomInfo);this._roomPKHandler=new ic(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,r,i,n,s){const o=Object.create(null,{__innerInit:{get:()=>super.__innerInit}});return v(this,void 0,void 0,function*(){if(!g("livingType",r,e=>e===Za.AUDIO||e===Za.VIDEO))return this._logger.error(ae.L_RTC_CLIENT_JOIN_LIVING_ROOM_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> livingType"}),s),{code:oe.PARAMS_ERROR};const{code:a,data:c}=yield o.__innerInit.call(this,e,t,r,i,n,s);return a===oe.SUCCESS&&c&&this._initRoomPKHandler(c),{code:a,data:c}})}__innerInitByIdentityChange(e){return v(this,void 0,void 0,function*(){const{code:t,data:r}=yield this._invoker.push(new sc(this._livingType,e));return t===ie&&r?(this._initRoomPKHandler(r),this._initWithRoomData(r.offlineKickTime),this._logger.info(ae.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:ce.SUCCESSED,roomData:r}),e)):this._logger.error(ae.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:ce.FAILED,code:t}),e),t})}publish(e){const t=Object.create(null,{publish:{get:()=>super.publish}});return v(this,void 0,void 0,function*(){return this._store.isMainRoom?t.publish.call(this,e):(this._logger.error(ae.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:ce.FAILED,code:oe.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),{code:oe.THE_FUNCTION_IS_DISABLED_IN_PKROOM})})}unpublish(e){const t=Object.create(null,{unpublish:{get:()=>super.unpublish}});return v(this,void 0,void 0,function*(){return this._store.isMainRoom?t.unpublish.call(this,e):(this._logger.error(ae.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:ce.FAILED,code:oe.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),{code:oe.THE_FUNCTION_IS_DISABLED_IN_PKROOM})})}_isValidResourceId(e){var t;const{userId:r}=or(e),i=!!(null===(t=this._store.getResourcesByUserId(r))||void 0===t?void 0:t.find(t=>sr(t)===e));let n=!1;const{code:s,roomPKHandler:o}=this.getRoomPKHandler();if(s!==oe.SUCCESS||!o)return i;const a=o.getJoinedPKRooms(),c=[];return Object.values(a).forEach(e=>{c.push(...e.getRemoteTracks())}),n=c.some(t=>e===t.getTrackId()),i||n}getLivingType(){return this._livingType}getMCUConfigBuilder(){return this._store.isMainRoom?this._mcuConfigBuilder:(this._logger.error(ae.L_LIVING_ROOM_GET_MCU_CONFIG_BUILDER_O,"the `getMCUConfigBuilder` is disabled in PK room"),{code:oe.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}enableInnerCDN(e){return v(this,void 0,void 0,function*(){return this._invoker.push(new nc(this._mcuConfigBuilder.__innerGetValues(),e))})}_resourceHandle(e,t,r,i,n){const s=Object.create(null,{_resourceHandle:{get:()=>super._resourceHandle}});return v(this,void 0,void 0,function*(){s._resourceHandle.call(this,e,t,r,i,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 v(this,void 0,void 0,function*(){this._invoker.push(new tc(e,this._roomPKHandler,t))})}_getPushOtherRoomsParams(){const e=[];if(!this.isMainRoom()||!this._roomPKHandler)return e;const t=this._roomPKHandler.getJoinedPKRooms();for(const r in t){const i=t[r].getSessionId(),n=this._roomPKHandler.getPKInfo(r);if(!n)continue;const{inviterUserAutoMix:s,inviteeUserAutoMix:o,inviterUserId:a}=n,c=this._context.getCurrentId()===a;e.push({roomId:r,sessionId:i,autoMix:c?!!s:!!o})}return e}getRoomPKHandler(){return this._store.isMainRoom?(this._logger.info(ae.L_LIVING_ROOM_GET_ROOM_PK_HANDLER_O,JSON.stringify({status:ce.SUCCESSED})),{code:oe.SUCCESS,roomPKHandler:this._roomPKHandler}):(this._logger.error(ae.L_LIVING_ROOM_GET_ROOM_PK_HANDLER_O,JSON.stringify({status:ce.SUCCESSED,code:oe.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),{code:oe.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}_quitAllPKRoom(){return v(this,void 0,void 0,function*(){const e=this._roomPKHandler.getJoinedPKRooms();for(const t in e)this._roomPKHandler.leaveOtherRoom(e[t]);this._logger.info(ae.L_LIVING_ROOM_QUIT_ALL_PK_ROOM_O,JSON.stringify({status:ce.SUCCESSED,roomIds:Object.keys(e)}))})}isMainRoom(){return this._store.isMainRoom}}class ac extends Ha{constructor(e,t,r,i,n,s=Ro.RTC,o=!1){super(e,t,r,s,i,n,!1,!1,Fs(),o)}}const cc=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 v(this,void 0,void 0,function*(){if(0===this.queue.length||this.locked)return;this.locked=!0;const{resolve:e,task:t,reject:r}=this.queue.shift();let i;try{i=yield t(),e(i)}catch(e){r(e)}this.locked=!1,this.checkToStart()})}push(e,t=""){const r=new Promise((t,r)=>{this.queue.push({resolve:t,task:e,reject:r})});return this.checkToStart(),r}},lc=(e,t="")=>cc.push(e,t);class dc{constructor(e,t,r){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:Fs()}),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 qs(t,e,r.mediaServer),this._logger=this._context.logger,this._store=new wo(this._logger,this._clientSessionId,this._context.getAppkey(),this._crtUserId,this._crtUserId,Ro.LIVE)}_getReqHeaders(e){return v(this,void 0,void 0,function*(){const t=this._crtUserId;if(!this._rtcToken){const{code:r,data:i}=yield this._context.getRTCToken(t,Ro.LIVE,e);if(r!==ie)return{code:oe.SIGNAL_ERROR};this._rtcToken=i.rtcToken}return{code:oe.SUCCESS,headers:{"App-Key":this._context.getAppkey(),UserId:this._crtUserId,RoomId:t,RoomType:Ro.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 v(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===oe.SUCCESS&&(null===(e=this._pc)||void 0===e||e.clearReTryExchangeTimer()),{code:t}})}subscribe(e,t,r){return v(this,arguments,void 0,function*(e,t,r,i=!1){return lc(()=>this.__subscribe(e,t,r,i),"audience-client-sub")})}__subscribe(e,t,r){return v(this,arguments,void 0,function*(e,t,r,n=!1){var s;this._logger.info(ae.L_AUDIENCE_CLIENT_SUBSCRIBE_T,JSON.stringify({liveUrl:e,livingType:t,mediaType:r,subTiny:n}));const o=[];if(Er(this._context.getNaviInfo()))return this._logger.error(ae.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ce.FAILED,code:oe.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"})),{code:oe.PACKAGE_ENVIRONMENT_ERROR,tracks:o};if(!this._fromRetry&&(null===(s=this._pc)||void 0===s||s.clearReTryExchangeTimer()),this._fromRetry=!1,!i(e))return this._logger.error(ae.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:`params error -> liveUrl: ${e}`})),{code:oe.PARAMS_ERROR,tracks:o};if(![Za.AUDIO,Za.VIDEO].includes(t))return this._logger.error(`livingType is invalid: ${t}`),this._logger.error(ae.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:`params error -> livingType: ${t}`})),{code:oe.PARAMS_ERROR,tracks:o};if(![bt.AUDIO_ONLY,bt.VIDEO_ONLY,bt.AUDIO_VIDEO].includes(r))return this._logger.error(ae.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:`params error -> -> mediaType: ${r}`})),{code:oe.PARAMS_ERROR,tracks:o};if(this._liveUrl&&this._liveUrl!==e)return this._logger.error(ae.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ce.FAILED,code:oe.BROADCAST_SUB_LIST_NOT_EMPTY,msg:"repeat subscribe"})),{code:oe.BROADCAST_SUB_LIST_NOT_EMPTY,tracks:o};this._pc||(this._pc=new Co(this._context,this._logger,this._reTryExchange.bind(this),this._crtUserId,this._store,void 0,!1),this._pc.on(Co.__INNER_EVENT_TRACK_READY__,this._onTrackReady,this),this._pc.registerReportListener(this._reportListener),this._pc.__reportR3R4ToPolaris()),this._liveUrl=e;const{code:a,headers:c}=yield this._getReqHeaders(t);if(a!==oe.SUCCESS)return this._logger.error(ae.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ce.FAILED,code:a,msg:"getRTCToken failed"})),{code:a,tracks:o};const l=`rc_mcu_${Date.now()}`,d="RongCloudRTC";0===this._subTracks.length&&(this._subTracks.push(new zt(this._logger,d,l),new Qt(this._logger,d,l)),this._pc.updateSubRemoteTracks(this._subTracks.slice()));const u={sdp:yield this._pc.createOffer(!0),liveUrl:e,mediaType:r,simulcast:n?$s.TINY:$s.NORMAL,switchstream:!1},_=yield this._service.broadcastSubscribe(c,u);if(_.code!==oe.SUCCESS)return this._logger.error(ae.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ce.FAILED,code:_.code})),{code:_.code,tracks:o};const h=_.data;if(h.resultCode!==oe.SUCCESS)return this._logger.error(ae.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ce.FAILED,code:h.resultCode,msg:h.message})),{code:h.resultCode,tracks:o};this._livingType=t,this._mediaType=r,this._subTiny=n;const{sdp:p,subscribedList:f}=h;this._subscribedList=f;const g=[];return f.forEach(e=>{const{mediaType:t}=e,r=this._subTracks[t];g.push(r),r.__innerSetRemoteMuted(!0)}),this._pc.setRemoteAnswer(p.sdp),g&&this._updateTrackIdSSRCMap(p.sdp,g),this._logger.info(ae.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:ce.SUCCESSED,liveUrl:e})),{code:oe.SUCCESS,tracks:g}})}_updateTrackIdSSRCMap(e,t){t.forEach(t=>{const r=t.getTrackId(),{mediaType:i}=or(r),{msid:n}=this._subscribedList.filter(e=>e.mediaType===i)[0],s=ua(e,n,i);this._store.setTrackIdSSRCMap(Number(s),r)})}unsubscribe(){return v(this,void 0,void 0,function*(){return lc(()=>this.__unsubscribe(),"audience-client-unsub")})}__unsubscribe(){return v(this,void 0,void 0,function*(){var e;if(this._logger.info(ae.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(ae.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:ce.FAILED,code:"",msg:"Address does not exist, without unsubscribe"})),{code:oe.SUCCESS};const{headers:t}=yield this._getReqHeaders(),{code:r}=yield this._service.broadcastExit(t);return r!==oe.SUCCESS?this._logger.error(ae.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:ce.FAILED,code:r})):(this._logger.info(ae.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:ce.SUCCESSED,liveUrl:this._liveUrl})),this._subscribedList=[]),this._clearSubscribeInfo(),{code:r}})}registerReportListener(e){this._reportListener=e}registerTrackEventListener(e){this._appListener=e}_onTrackReady(e){var t,r;const{track:i}=e.receiver,n="audio"===i.kind?bt.AUDIO_ONLY:bt.VIDEO_ONLY,s=this._subTracks[n];s.__innerSetMediaStreamTrack(i);try{this._logger.info(ae.L_AUDIENCE_CLIENT_CALL_ONTRACKREADY_O,`trackId: ${s.getTrackId()}`),null===(r=null===(t=this._appListener)||void 0===t?void 0:t.onTrackReady)||void 0===r||r.call(t,s)}catch(e){this._logger.error(ae.L_AUDIENCE_CLIENT_CALL_ONTRACKREADY_O,JSON.stringify(e))}}}var uc,_c;!function(e){e.RTMP="rtmp",e.FLV="flv",e.HLS="hls"}(uc||(uc={})),function(e){e[e.NOT_HTTPS=0]="NOT_HTTPS",e[e.HTTPS=1]="HTTPS"}(_c||(_c={}));const hc=Object.assign(Object.assign({},ur(Ot.W176_H144)),{frameRate:pr(vt.FPS_15)});class pc{constructor(e,t,r,i,n,s,o=Fs()){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:r}),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:i}),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 Ua(this._context,this._runtime,this._roomId,this,La.Audience),this._reportMediaActionLogger=new Da(this._logger,this._roomId,this._clientSessionId,this._crtUserId),this._service=new qs(this._runtime,this._context,this._initOptions.mediaServer,this._initOptions.timeout);const a=this._store=new wo(this._logger,o,e.getAppkey(),i,this._crtUserId,Ro.LIVE),c=this._pc=new Co(this._context,this._logger,this._reTryExchange.bind(this),this._crtUserId,a,this._polarisReport,!0);this._audioLevelReport=new yo(this._store,c),c.on(Co.__INNER_AUDIOLEVEL_CHANGE__,this._audioLevelReport.audioLevelReport,this._audioLevelReport),this._polarisReport.sendR1(),this._context.registerRTCSignalListener(e=>v(this,void 0,void 0,function*(){const{time:t,type:r,roomId:i}=this._context.decodeRtcNotify(e);1===r&&this._startPull(i,t)})),this._setInitData()}_startPull(e,t){return v(this,void 0,void 0,function*(){if(this._isPulling)return;this._isPulling=!0;if(this._pullTime>t)return void(this._isPulling=!1);const r=this._logger.createTraceId();this._logger.info(ae.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_T,`pullTime: ${this._pullTime}`,r);const{code:i,data:n}=yield this._context.pullRTCRoomEntry(e);if(i===ie){this._isPulling=!1,this._pullTime=(null==n?void 0:n.syncTime)||0;const t=(null==n?void 0:n.kvEntries)||[];this._logger.info(ae.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R,`status: ${ce.SUCCESSED}, kvEntries: ${JSON.stringify(t)}`,r),this.singalDataChange(t,e,r)}this._logger.info(ae.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R,`status: ${ce.FAILED}, code: ${i}`,r)})}_setInitData(){const{sessionId:e,remoteUserIds:t,remoteRTCUris:r,remoteMUCUris:i,remoteTracks:n,CDNUris:s}=((e,t,r)=>{const i=t.filter(e=>"RC_RTC_SESSIONID"===e.key)[0],n=i?i.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||"[]"):[],c=[];a.forEach(t=>{const{mediaType:i,tag:n}=t,s=i===bt.AUDIO_ONLY?new zt(r,n,"",e):new Qt(r,n,"",e);c.push(s)});const l=[],d=[];o.forEach(e=>{const t=JSON.parse(e.uris||"[]");l.push(...t),t.forEach(e=>{const{mediaType:t,tag:i,msid:n}=e,s=n.split("_");s.pop();const o=s.join("_"),a=t===bt.AUDIO_ONLY?new zt(r,i,o):new Qt(r,i,o);d.push(a)})});const u=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:l,remoteMUCUris:a,remoteRTCTracks:d,remoteMCUTracks:c,remoteTracks:[...d,...c],CDNUris:u||{}}})(this._roomId,this._joinResData.kvEntries,this._logger);this._sessionId=e,this._roomAnchorList=t,n.forEach(e=>{this._remoteTracks[e.getTrackId()]=e}),this._CDNUris=s,r.forEach(e=>{const t=e.msid.split("_")[0];this._roomAnchorRes[t]?this._roomAnchorRes[t].push(e):this._roomAnchorRes[t]=[e];const{ssrc:r,resourceId:i}=JSON.parse(e.uri);this._store.setTrackIdSSRCMap(r,i)}),i.forEach(e=>{const{mediaType:t,tag:r}=e,i=[this._roomId,r,t].join("_");this._roomRes[i]=e;const{ssrc:n}=JSON.parse(e.uri);this._store.setTrackIdSSRCMap(n,i)}),r.forEach(e=>{const t=sr(e);this._roomRes[t]=e})}_assertRoomDestroyed(){if(this._destroyed)return oe.ROOM_HAS_BEEN_DESTROYED}singalDataChange(e,t,r){var i;if(t!==this._roomId)return void this._logger.error(ae.L_AUDIENCE_LIVING_ROOM_SINGAL_DATA_CHANGE_P,JSON.stringify({status:ce.FAILED,msg:`roomId inconsistency -> params roomId:${t}, current roomId:${this._roomId}`}),r);const n=[],s=null===(i=e.filter(e=>"RC_CDN"===e.key)[0])||void 0===i?void 0:i.value;s&&this._diffCDNUris(JSON.parse(JSON.parse(s).cdn_uris)[0],r),e.forEach(e=>{const{key:t,value:i,uid:s}=e;if(-1!==t.indexOf("RC_RES_")){const e=JSON.parse(i||"{}"),t=JSON.parse(e.mcu_uris||"[]"),o=JSON.parse(e.uris||"[]");return n.push(...t),void this._diffAnchorResource(o,s,r)}if("RC_ANCHOR_LIST"===t){const e=JSON.parse(i||"[]");this._diffAnchorList(e,r)}}),this._diffRoomResource(n,r)}_diffAnchorList(e,t){const r=e.filter(e=>this._roomAnchorList.indexOf(e)<0),i=this._roomAnchorList.filter(t=>e.indexOf(t)<0);r.length>0&&this._handleNewJoinedAnchor(r,t),i.length>0&&this._handleLeftedAnchor(i,t)}_handleNewJoinedAnchor(e,t){this._roomAnchorList.push(...e),this._logger.info(ae.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorJoin",list:e}),t),this._callAppListener("onAnchorJoin",e)}_handleLeftedAnchor(e,t){return v(this,void 0,void 0,function*(){this._roomAnchorList=this._roomAnchorList.filter(t=>!e.includes(t));const r=[];e.forEach(e=>{r.push(...this.getRemoteTracksByUserId(e)),delete this._roomAnchorRes[e]}),r.length&&(yield this.unsubscribe(r),r.forEach(e=>delete this._remoteTracks[e.getTrackId()])),this._logger.info(ae.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorLeave",list:e}),t),this._callAppListener("onAnchorLeave",e)})}_diffRoomResource(e,t){return v(this,void 0,void 0,function*(){const r=[],i=[],n=[];e.forEach(e=>{const t=sr(e),{tag:i,mediaType:s}=or(t),o=[this._roomId,i,s].join("_"),{ssrc:a}=JSON.parse(e.uri);if(this._store.setTrackIdSSRCMap(a,o),!this._remoteTracks[o]){const t=s===bt.AUDIO_ONLY?new zt(this._logger,i,"",this._roomId):new Qt(this._logger,i,"",this._roomId);r.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()&&i.push(this._remoteTracks[e])}),r.length>0&&(this._logger.info(ae.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onTrackPublish",trackIds:r.map(e=>e.getTrackId())}),t),this._callAppListener("onTrackPublish",r)),i.length>0&&this._onUserUnpublish(i,"onTrackUnpublish",t)})}_dealPublished(e,t,r){return v(this,void 0,void 0,function*(){const i=e.map(sr),n=[],s=[];if(t.forEach(t=>{const r=sr(t),o=i.indexOf(r),{userId:a,tag:c,mediaType:l}=or(r),{ssrc:d}=JSON.parse(t.uri);this._store.setTrackIdSSRCMap(d,r),o>-1?e[o]=t:e.push(t);let u=this._remoteTracks[r];this._roomRes[r]=t,u?u.isSubscribed()&&n.push(u):(u=l===bt.AUDIO_ONLY?new zt(this._logger,c,a):new Qt(this._logger,c,a),this._remoteTracks[r]=u,s.push(u)),u.__innerSetRemoteMuted(0===t.state)}),n.length){const e=n.map(e=>e.getTrackId()),{code:t}=yield lc(()=>this._subscribeHandle(n,!0));t!==oe.SUCCESS&&this._logger.error(ae.L_RESUB_REPUB_RES_R,JSON.stringify({status:ce.FAILED,trackIds:e,code:t}))}this._logger.info(ae.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorTrackPublish",trackIds:s.map(e=>e.getTrackId())}),r),this._callAppListener("onAnchorTrackPublish",s)})}_dealUnpublished(e,t,r){return v(this,void 0,void 0,function*(){const i=t.map(sr);for(let t=e.length-1;t>=0;t-=1){const r=e[t];i.includes(sr(r))&&e.splice(t,1)}const n=t.map(e=>{const t=sr(e);return this._remoteTracks[t]});yield this._onUserUnpublish(n,"onAnchorTrackUnpublish",r)})}_dealModified(e,t,r){const i=e.map(sr);for(const n of t){const t=sr(n);e[i.indexOf(t)].state=n.state;const s=this._remoteTracks[t];s.__innerSetRemoteMuted(0===n.state);const o=s.isAudioTrack()?"onAudioMuteChange":"onVideoMuteChange";this._logger.info(ae.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:o,trackId:s.getTrackId()}),r),this._callAppListener(o,s)}}_diffAnchorResource(e,t,r){return v(this,void 0,void 0,function*(){const i=this._roomAnchorRes[t]||(this._roomAnchorRes[t]=[]),{publishedList:n,unpublishedList:s,modifiedList:o}=lr(i,e);n.length&&(yield this._dealPublished(i,n,r)),s.length&&(yield this._dealUnpublished(i,s,r)),o.length&&this._dealModified(i,o,r)})}_onUserUnpublish(e,t,r){return v(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(ae.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:t,trackIds:e.map(e=>e.getTrackId())}),r),this._callAppListener(t,e)})}_callAppListener(e,...t){var r;const i=null===(r=this._appListener)||void 0===r?void 0:r[e];if(i)try{i(...t)}catch(e){this._logger.error(ae.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify(e))}}_reTryExchange(){return v(this,void 0,void 0,function*(){return lc(()=>v(this,void 0,void 0,function*(){var e;const{reqBody:t}=yield this._createSubscribeParams(this._subscribedList,{},!0),r=yield this._exchangeHandle(t);if(r.code!==oe.SUCCESS)return{code:r.code};const{sdp:i,resultCode:n}=r.data;if(n!==oe.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(),r=null===(e=this._roomRes[t])||void 0===e?void 0:e.msid,n=[this._roomId,"RongCloudRTC"].join("_");i.sdp=i.sdp.replace(new RegExp(r,"g"),n)}return{code:yield this._pc.setRemoteAnswer(i.sdp)}}),"audience-retry-exchange")})}_createSubscribeParams(e,t,r){return v(this,void 0,void 0,function*(){const i=yield this._pc.createOffer(r),n={resolutionInfo:[]},s={min:0,max:0};Object.keys(t).forEach(e=>{const{mediaStream:r,tinyStream:o}=t[e];[r,o].forEach((t,r)=>{var o;const a=1===r?[e,"tiny"].join("_"):e;i.sdp=null===(o=i.sdp)||void 0===o?void 0:o.replace(new RegExp(t.id,"g"),a);const c=t.getVideoTracks()[0];if(!c)return;const l=0===r,{width:d,height:u,frameRate:_}=l?ir(c):hc;n.resolutionInfo.push({trackId:c.id,simulcast:l?$s.NORMAL:$s.TINY,resolution:`${d}x${u}`});const h=Lt(d,u),p=Nt(_);s.min+=h.minBitrate*p,s.max+=h.maxBitrate*p})});return{reqBody:{sdp:i,switchstream:!1,newVersionFlag:!0,subscribeList:e.map(e=>({simulcast:e.subTiny?$s.TINY:$s.NORMAL,resolution:"",uri:this._roomRes[e.track.getTrackId()].uri}))},dynamicBitrate:s,offer:i}})}_subscribeHandle(e){return v(this,arguments,void 0,function*(e,t=!1,r=!1){const i=Date.now(),n=r?Zo.SUB:void 0,s=this._logger.createTraceId();this._logger.info(ae.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_T,JSON.stringify({trackIds:e.map(Ir),forceReq:t}),s);if(this._assertRoomDestroyed())return this._logger.error(ae.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_R,JSON.stringify({status:ce.FAILED,code:oe.ROOM_HAS_BEEN_DESTROYED,msg:"room destroyed"}),s),this._reportPubOrSubQualityData(i,e,oe.ROOM_HAS_BEEN_DESTROYED,n),{code:oe.ROOM_HAS_BEEN_DESTROYED};if(!g("tracks",e,()=>o(e)&&e.length>0&&e.every(e=>e instanceof Wt||e.track instanceof Wt),!0))return this._logger.error(ae.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> tracks"}),s),this._reportPubOrSubQualityData(i,e,oe.PARAMS_ERROR,n),{code:oe.PARAMS_ERROR};this._pc.__reportR3R4ToPolaris(),this._pc.registerReportListener(this._reportListener),this._addPeerCEvent();const a=this._subscribedList.map(e=>Object.assign({},e)),c=e.map(e=>e instanceof Wt?{track:e}:e),l=[];return c.forEach(e=>{const t=e.track.getTrackId();l.push(t);const r=a.find(e=>e.track.getTrackId()===t);r&&r.subTiny===e.subTiny||(r?r.subTiny=e.subTiny:a.push(e))}),this._polarisReport.sendR2(Wo.SUBSCRIBE,zo.BEGIN,l),this._updateSubListHandle(a,s,i,n,!0)})}_addPeerCEvent(){this._pc.on(Co.__INNER_EVENT_TRACK_READY__,e=>{const t=e.streams[0].id,{track:r}=e.receiver,i=[t,"audio"===r.kind?bt.AUDIO_ONLY:bt.VIDEO_ONLY].join("_"),n=this._remoteTracks[i];n?(n.__innerSetMediaStreamTrack(r),this._logger.info(ae.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onTrackReady",trackId:n.getTrackId()})),this._callAppListener("onTrackReady",n)):this._logger.warn(ae.L_AUDIENCE_LIVING_ROOM_ONTRACKREADY_O,`cannot found RCRemoteTrack: ${r.id}`)}),this._pc.once(Co.__INNER_ICE_CONNECTED__,()=>{this._reportMediaActionLogger.reportIceFirstConnectData("sub")},this),this._pc.on(Co.__INNER_ICE_STATE_CHANGE__,e=>{const{status:t,time:r,iceCandidatePair:i}=e;i&&this._reportMediaActionLogger.recordQualityIceStatusData(i,t,r)})}_getReqHeaders(){const e=this._crtUserId;return{"App-Key":this._context.getAppkey(),RoomId:e,Token:this._joinResData.token,RoomType:Ro.LIVE,UserId:e,"Session-Id":this._sessionId,"Client-Session-Id":this._clientSessionId}}_exchangeHandle(e){return this._service.broadcastSubscribe(this._getReqHeaders(),e)}_dealSubscribeResult(e,t,r){const i=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()],r=`${t.msid}_${t.mediaType}`;return i.includes(r)}return null==i?void 0:i.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(ae.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:ce.SUCCESSED,subSuccessTrackIds:i,failedList:o}),r),o}_getParams(e){let t=e.map(e=>e instanceof Wt?{track:e}:Object.assign({},e));const r={};return t=t.filter(e=>{const t=e.track.getTrackId();return!r[t]&&(r[t]=!0,!0)}).map(e=>Object.assign({},e)),t}_reportPubOrSubQualityData(e,t,r,i){i&&this._reportMediaActionLogger.reportPubOrSubQualityData(i,e,t,r,this._trackMediaMap)}_updateSubListHandle(e,t,r,i){return v(this,arguments,void 0,function*(e,t,r,i,n=!1){var s;this._logger.info(ae.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_T,JSON.stringify({trackIds:e.map(Ir),forceReq:n}),t);const o=this._getParams(e),a=this._subscribedList.map(e=>Object.assign({},e));if(!n&&!_a(o,a))return this._logger.info(ae.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:ce.SUCCESSED,msg:"repeat subscribe"}),t),{code:oe.SUCCESS};this._pc.clearReTryExchangeTimer(),this._pc.updateSubRemoteTracks(o.map(e=>e.track));const{reqBody:c}=yield this._createSubscribeParams(o,{},!1),l=yield this._exchangeHandle(c);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 Wt?e.getTrackId():e.track.getTrackId();this._trackMediaMap[t]=l.qualityMsList||[]}),l.code!==oe.SUCCESS)return this._reportPubOrSubQualityData(r,e,l.code,i),this._logger.error(ae.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:ce.FAILED,code:l.code}),t),{code:l.code};const{sdp:d,resultCode:u,message:_,subscribedList:h}=l.data;if(u!==oe.SUCCESS)return this._reportPubOrSubQualityData(r,e,u,i),this._logger.error(ae.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:ce.FAILED,code:u,msg:_}),t),{code:u};o.forEach(e=>{const{track:t}=e;if(t.isMCUTrack()){const e=this._roomRes[t.getTrackId()].msid,{tag:r,userId:i}=or(t.getTrackId()),n=[i,r].join("_");d.sdp=d.sdp.replace(new RegExp(e,"g"),n)}});const p=yield this._pc.setRemoteAnswer(d.sdp);if(this._reportPubOrSubQualityData(r,e,p,i),p!==oe.SUCCESS)return this._logger.error(ae.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:ce.FAILED,code:p,msg:"set remote answer error"}),t),{code:p};const f=this._dealSubscribeResult(o,h,t);return f.length?{code:oe.SUCCESS,failedList:f}:{code:oe.SUCCESS}})}_diffCDNUris(e,t){return v(this,void 0,void 0,function*(){if(this._CDNUris.url&&!e.url)return this._logger.info(ae.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(ae.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 r=this._CDNUris.w&&e.w&&this._CDNUris.w!==e.w,i=this._CDNUris.h&&e.h&&this._CDNUris.h!==e.h,n=this._CDNUris.fps&&e.fps&&this._CDNUris.fps!==e.fps;(r||i||n)&&(this._logger.info(ae.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 v(this,void 0,void 0,function*(){const{w:r,h:i,fps:n}=e,s=this._initOptions.pullInnerCDNProtocol||uc.FLV,o=this._initOptions.pullInnerCDNUseHttps===_c.NOT_HTTPS?_c.NOT_HTTPS:_c.HTTPS;if(!this._CDNUris.url)return this._logger.error(ae.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:ce.FAILED,code:oe.CDN_RESOURCE_IS_EMPTY,msg:"cdn_uris url is empty, the anchor need to open or push CDN"}),t),{code:oe.CDN_RESOURCE_IS_EMPTY};const a={"App-Key":this._context.getAppkey(),Token:this._joinResData.token,RoomId:this.getRoomId(),UserId:this._crtUserId,SessionId:this.getSessionId()},c=[],{w:l=0,h:d=1}=this._CDNUris;l/d>1?(r&&c.push(`w=${r}`),i&&c.push(`h=${i}`)):(r&&c.push(`h=${r}`),i&&c.push(`w=${i}`)),n&&c.push(`fps=${n}`),c.push(`kind=${s}`),c.push(`is_https=${o}`);const u=c.join("&");let _=`${this._CDNUris.url}?`;u&&(_+=u);const{code:h,res:p}=yield this._service.getCDNResourceInfo(a,_,t);return h!==oe.SUCCESS?{code:h}:{code:h,CDNPlayUrl:null==p?void 0:p.data.pull_url}})}getCDNPlayUrl(e,t){return v(this,void 0,void 0,function*(){const r=this._logger.createTraceId();if(this._logger.info(ae.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_T,JSON.stringify({resolution:e,fps:t}),r),e&&!_r(e))return this._logger.error(ae.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> resolution"}),r),{code:oe.PARAMS_ERROR};if(t&&!hr(t))return this._logger.error(ae.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> fps"}),r),{code:oe.PARAMS_ERROR};const{width:i,height:n}=e?ur(e):{width:null,height:null},s=t?pr(t):null,o={};return i&&(o.w=i),n&&(o.h=n),s&&(o.fps=s),this._getCDNPlayUrl(o,r)})}subscribe(e){return v(this,void 0,void 0,function*(){return lc(()=>this._subscribeHandle(e,!1,!0),"audience-sub")})}__unsubscribe(e){return v(this,void 0,void 0,function*(){const t=Date.now(),r=Zo.UNSUB,i=this._logger.createTraceId();this._logger.info(ae.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_T,JSON.stringify({trackIds:e.map(e=>e.getTrackId())}),i);if(this._assertRoomDestroyed())return this._logger.error(ae.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_R,JSON.stringify({status:ce.FAILED,code:oe.ROOM_HAS_BEEN_DESTROYED,msg:"room destroyed"}),i),{code:oe.ROOM_HAS_BEEN_DESTROYED};if(!g("tracks",e,()=>o(e)&&e.length>0&&e.every(e=>e instanceof Wt),!0))return this._logger.error(ae.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> tracks"}),i),{code:oe.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(Wo.SUBSCRIBE,zo.END,e.map(e=>e.getTrackId())),this._updateSubListHandle(n,i,t,r,!1)})}unsubscribe(e){return v(this,void 0,void 0,function*(){return lc(()=>this.__unsubscribe(e),"audience-unsub")})}__destroy(e){return v(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 v(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(ae.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_T,void 0,e);const{code:t}=yield this._context.joinLivingRoomAsAudience(this._roomId,Ro.LIVE);t!==ie&&this._logger.error(ae.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_R,`status: ${ce.FAILED}`,e),this._logger.info(ae.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_R,`status: ${ce.SUCCESSED}`,e)})}registerRoomEventListener(e){this._appListener=e}onAudioLevelChange(e,t){this._logger.info(ae.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 r in this._remoteTracks){const i=this._remoteTracks[r];i.getUserId()===e&&t.push(i)}return t}getRemoteTracks(){const e=[],t=[];for(const e in this._remoteTracks){if(2===t.length)break;const r=this._remoteTracks[e];r.isMCUTrack()&&t.push(r)}return this._roomAnchorList.forEach(t=>{e.push(...this.getRemoteTracksByUserId(t))}),[...t,...e]}getRemoteRTCTracks(){const e=[];for(const t in this._remoteTracks){const r=this._remoteTracks[t];r.isMCUTrack()||e.push(r)}return e}getRemoteMCUTracks(){const e=[];for(const t in this._remoteTracks){const r=this._remoteTracks[t];r.isMCUTrack()&&e.push(r)}return e}getCDNInfo(){return this._CDNUris.w?{resolution:`W${this._CDNUris.w}_H${this._CDNUris.h}`,fps:`FPS_${this._CDNUris.fps}`,CDNEnable:this._CDNUris.enableInnerCDN}:{CDNEnable:!1}}getClientSessionId(){return this._clientSessionId}}var fc;!function(e){e[e.AUTOMATIC=0]="AUTOMATIC",e[e.MANUAL=1]="MANUAL"}(fc||(fc={}));class gc{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 v(this,arguments,void 0,function*(e,t="getUserMedia"){try{const r=this.setConstraintsConfig(e),i=yield navigator.mediaDevices[t](r);return{code:oe.SUCCESS,stream:i}}catch(e){if(this._logger.error(ae.L_GET_MEDIA_STREAM_E,JSON.stringify({name:e.name,message:e.message})),"Permission denied"===e.message)return{code:oe.BROWSER_PERMISSION_DENIED};if("Permission denied by system"===e.message)return{code:oe.SYSTEM_PERMISSION_DENIED}}return{code:"getUserMedia"===t?oe.GET_USER_MEDIA_FAILED:oe.GET_DISPLAY_MEDIA_FAILED}})}_getMediaStreamErrorReason(e){let t="";return e===oe.BROWSER_PERMISSION_DENIED&&(t="Permission denied"),e===oe.SYSTEM_PERMISSION_DENIED&&(t="Permission denied by system"),t}setConstraintsConfig(e){var t,r;if((null==e?void 0:e.audio)&&!this._isElectron){"boolean"==typeof e.audio&&(e.audio={});const i=null===(r=(t=navigator.mediaDevices).getSupportedConstraints)||void 0===r?void 0:r.call(t);(null==i?void 0:i.noiseSuppression)&&(e.audio.noiseSuppression=!!i.noiseSuppression),(null==i?void 0:i.autoGainControl)&&(e.audio.autoGainControl=!!i.autoGainControl),(null==i?void 0:i.echoCancellation)&&(e.audio.echoCancellation=!!i.echoCancellation),this._logger.info(ae.L_SET_AUDIO_CONSTRAINTS_O,`browser supported -> ${JSON.stringify(i)}`)}return e}createMicrophoneAudioTrack(){return v(this,arguments,void 0,function*(e="RongCloudRTC",t){if(!tr(e))return this._logger.error(ae.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:ce.FAILED,code:oe.INVALID_TAGS,msg:"invalid tag"})),{code:oe.INVALID_TAGS};const r=this._context.getCurrentId();if(!r)return this._logger.error(ae.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:ce.FAILED,code:oe.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:oe.INVALID_USER_ID};const{stream:i,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!==oe.SUCCESS)return this._logger.error(ae.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:ce.FAILED,code:n,msg:this._getMediaStreamErrorReason(n)})),{code:n};const s=i.getAudioTracks()[0],o=new Kt(this._logger,e,r,s);return this._logger.info(ae.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:ce.SUCCESSED,trackId:o.getTrackId()})),{code:n,track:o}})}createCameraVideoTrack(){return v(this,arguments,void 0,function*(e="RongCloudRTC",t){if(!tr(e))return this._logger.error(ae.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:ce.FAILED,code:oe.INVALID_TAGS,msg:"invalid tag"})),{code:oe.INVALID_TAGS};const r=this._context.getCurrentId();if(!r)return this._logger.error(ae.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:ce.FAILED,code:oe.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:oe.INVALID_USER_ID};const i=_r(null==t?void 0:t.resolution)?t.resolution:Ot.W640_H480,{width:n,height:s}=ur(i),{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:pr((null==t?void 0:t.frameRate)||vt.FPS_15),width:{ideal:n,max:n},height:{ideal:s,max:s},facingMode:null==t?void 0:t.faceMode}});if(a!==oe.SUCCESS)return this._logger.error(ae.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:ce.FAILED,code:a,msg:this._getMediaStreamErrorReason(a)})),{code:a};const c=o.getVideoTracks()[0];yield this._applyVideoAspectRatio(c,n,s);const l=new qt(this._logger,e,r,c);return this._logger.info(ae.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:ce.SUCCESSED,trackId:l.getTrackId()})),{code:a,track:l}})}createMicrophoneAndCameraTracks(){return v(this,arguments,void 0,function*(e="RongCloudRTC",t){var r;const i=[];if(!tr(e))return this._logger.error(ae.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:ce.FAILED,code:oe.INVALID_TAGS,msg:"invalid tag"})),{code:oe.INVALID_TAGS,tracks:i};const n=this._context.getCurrentId();if(!n)return this._logger.error(ae.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:ce.FAILED,code:oe.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:oe.INVALID_USER_ID,tracks:i};const s=_r(null===(r=null==t?void 0:t.video)||void 0===r?void 0:r.resolution)?t.video.resolution:Ot.W640_H480,{width:o,height:a}=ur(s),c=null==t?void 0:t.audio,l=null==t?void 0:t.video,{stream:d,code:u}=yield this._getMediaStream({video:{deviceId:(null==l?void 0:l.cameraId)?{exact:null==l?void 0:l.cameraId}:void 0,frameRate:pr((null==l?void 0:l.frameRate)||vt.FPS_15),width:{ideal:o,max:o},height:{ideal:a,max:a},facingMode:null==l?void 0:l.faceMode},audio:{deviceId:(null==c?void 0:c.micphoneId)?{exact:null==c?void 0:c.micphoneId}:void 0,sampleRate:null==c?void 0:c.sampleRate,noiseSuppression:null==c?void 0:c.noiseSuppression,echoCancellation:null==c?void 0:c.echoCancellation,autoGainControl:null==c?void 0:c.autoGainControl}});if(u!==oe.SUCCESS)return this._logger.error(ae.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:ce.FAILED,code:u,msg:this._getMediaStreamErrorReason(u)})),{code:u,tracks:i};const _=d.getTracks();for(let t=0;t<_.length;t++){const r=_[t];"video"===r.kind?(yield this._applyVideoAspectRatio(r,o,a),i.push(new qt(this._logger,e,n,r))):i.unshift(new Kt(this._logger,e,n,r))}return this._logger.info(ae.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:ce.SUCCESSED,trackIds:i.map(e=>e.getTrackId())})),{code:u,tracks:i}})}createScreenVideoTrack(){return v(this,arguments,void 0,function*(e="screenshare",t){const r=yield this._createScreenTracks(e,!1,ae.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_TRACK_O,t);return r.code===oe.SUCCESS?{code:r.code,track:r.tracks[0]}:r})}createScreenWithAudioTracks(){return v(this,arguments,void 0,function*(e="screenshare",t){return this._createScreenTracks(e,!0,ae.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_AND_AUDIO_TRACKS_O,t)})}_createScreenTracks(e,t,r,i){return v(this,void 0,void 0,function*(){if(!tr(e))return this._logger.error(r,JSON.stringify({status:ce.FAILED,code:oe.INVALID_TAGS,msg:"invalid tag"})),{code:oe.INVALID_TAGS};const n=this._context.getCurrentId();if(!n)return this._logger.error(r,JSON.stringify({status:ce.FAILED,code:oe.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:oe.INVALID_USER_ID};if(!mr())return this._logger.error(ae.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_TRACK_O,JSON.stringify({status:ce.FAILED,code:oe.BROWSER_NOT_SUPPORT,msg:"browser not support"})),{code:oe.BROWSER_NOT_SUPPORT};const s=/macintosh|mac os x/i.test(navigator.userAgent),o=(!this._isElectron||!s)&&t,a=_r(null==i?void 0:i.resolution)?i.resolution:Ot.W1280_H720,{stream:c,code:l}=this._isElectron?yield this._createElectronScreenStream(t,r,a,null==i?void 0:i.chromeMediaSourceId):yield this._createWebScreenStream(t,a,null==i?void 0:i.frameRate);if(l!==oe.SUCCESS)return this._logger.error(r,JSON.stringify({status:ce.FAILED,code:l,msg:this._getMediaStreamErrorReason(l)})),{code:l};const d=c.getVideoTracks()[0],u=[new $t(this._logger,e,n,d)];if(o){const t=c.getAudioTracks()[0];t&&u.push(new Yt(this._logger,e,n,t))}return this._logger.info(r,JSON.stringify({status:ce.SUCCESSED,trackIds:u.map(e=>e.getTrackId())})),{code:l,tracks:u}})}_createElectronScreenStream(e,t,r,n){return v(this,void 0,void 0,function*(){var s,o;const a=/macintosh|mac os x/i.test(navigator.userAgent);this._isElectron&&a&&e&&this._logger.warn(t,JSON.stringify({status:ce.INFO,code:oe.MAC_IN_ELECTRON_NOT_SUPPORT_SCREEN_SHARE_WITH_AUDIO,msg:"mac in electron not support screen share with audio"}));const c=(!this._isElectron||!a)&&e;if(this._isElectron&&!d(n)&&!i(n))return this._logger.error(t,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> options.chromeMediaSourceId type is string"})),{code:oe.PARAMS_ERROR};const{width:l,height:u}=ur(r),_={mandatory:{chromeMediaSourceId:n,chromeMediaSource:"desktop",minWidth:l,maxWidth:l,minHeight:u,maxHeight:u}};!n&&this._isElectron&&(null===(s=_.mandatory)||void 0===s||delete s.chromeMediaSourceId);let h=null;return c&&this._isElectron&&(null===(o=_.mandatory)||void 0===o||delete o.chromeMediaSourceId,h={mandatory:{chromeMediaSource:"desktop"}}),this._getMediaStream({video:_,audio:h||c},"getUserMedia")})}_createWebScreenStream(e,t,r){return v(this,void 0,void 0,function*(){const{width:i,height:n}=ur(t),s={frameRate:pr(r||vt.FPS_15),width:i,height:n};return this._getMediaStream({video:s,audio:e},"getDisplayMedia")})}createLocalAudioTrack(e,t){return v(this,void 0,void 0,function*(){if(!tr(e))return this._logger.error(ae.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:ce.FAILED,code:oe.INVALID_TAGS,msg:"invalid tag"})),{code:oe.INVALID_TAGS};if(!t||"[object MediaStreamTrack]"!==t.toString()||"audio"!==t.kind)return this._logger.error(ae.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:ce.FAILED,code:oe.CREATE_CUSTOM_TRACK_FAILED,msg:"params track is not MediaStreamTrack or kind is not audio"})),{code:oe.CREATE_CUSTOM_TRACK_FAILED};const r=this._context.getCurrentId();if(!r)return this._logger.error(ae.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:ce.FAILED,code:oe.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:oe.INVALID_USER_ID};const i=new Ft(this._logger,e,r,t);return this._logger.info(ae.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:ce.SUCCESSED,trackId:i.getTrackId()})),{code:oe.SUCCESS,track:i}})}createLocalVideoTrack(e,t){return v(this,void 0,void 0,function*(){if(!tr(e))return this._logger.error(ae.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:ce.FAILED,code:oe.INVALID_TAGS,msg:"invalid tag"})),{code:oe.INVALID_TAGS};if(!(t&&t instanceof MediaStreamTrack&&"video"===t.kind))return this._logger.error(ae.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:ce.FAILED,code:oe.CREATE_CUSTOM_TRACK_FAILED,msg:"params track is not MediaStreamTrack or kind is not video"})),{code:oe.CREATE_CUSTOM_TRACK_FAILED};const r=this._context.getCurrentId();if(!r)return this._logger.error(ae.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:ce.FAILED,code:oe.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:oe.INVALID_USER_ID};const i=new jt(this._logger,e,r,t);return this._logger.info(ae.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:ce.SUCCESSED,trackId:i.getTrackId()})),{code:oe.SUCCESS,track:i}})}_validateCreateLocalFileTracks(e,t){if(!tr(e))return this._logger.error(ae.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:ce.FAILED,code:oe.INVALID_TAGS,msg:"invalid tag"})),{code:oe.INVALID_TAGS,tracks:[]};if(!gr())return this._logger.error(ae.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:ce.FAILED,code:oe.BROWSER_NOT_SUPPORT,msg:"browser not support"})),{code:oe.BROWSER_NOT_SUPPORT,tracks:[]};const r=t instanceof File?URL.createObjectURL(t):t;if(!u(r)&&!/^blob:/.test(r))return this._logger.error(ae.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> file"})),{code:oe.PARAMS_ERROR,tracks:[]};return this._context.getCurrentId()?{code:oe.SUCCESS,tracks:[],url:r}:(this._logger.error(ae.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:ce.FAILED,code:oe.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:oe.INVALID_USER_ID,tracks:[]})}createLocalFileTracks(e,t,r){return v(this,void 0,void 0,function*(){const i=this._validateCreateLocalFileTracks(e,t);if(i.code!==oe.SUCCESS)return i;const n=this._context.getCurrentId();return new Promise(t=>{const s=document.createElement("video");(null==r?void 0:r.withoutAudio)&&(s.muted=!0),s.onloadedmetadata=()=>{const i=[];let o;try{const e=s.mozCaptureStream?"mozCaptureStream":"captureStream";o=s[e]()}catch(e){this._logger.error(ae.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:ce.FAILED,code:oe.CREATE_FILE_TRACK_FAILED,msg:`captureSteam error -> ${JSON.stringify(e)}`})),t({code:oe.CREATE_FILE_TRACK_FAILED,tracks:i})}const[a,c]=gc.getTracksWithOptions(o,r);a&&i.push(new Ht(this._logger,e,n,a,s)),c&&i.push(new Jt(this._logger,e,n,c,s)),0===i.length&&(s.pause(),s.src=""),s.onerror=null,this._logger.info(ae.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:ce.SUCCESSED,trackIds:i.map(e=>e.getTrackId())})),t({code:oe.SUCCESS,tracks:i})},s.onerror=()=>{this._logger.error(ae.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:ce.FAILED,code:oe.CREATE_FILE_TRACK_FAILED,msg:"Failed to create file stream, video onerror"})),t({code:oe.CREATE_FILE_TRACK_FAILED,tracks:[]})},s.src=i.url,s.loop=!0,s.play()})})}createLocalTracks(e,t,r){return v(this,void 0,void 0,function*(){const i=[];if(!tr(e))return this._logger.error(ae.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:ce.FAILED,code:oe.INVALID_TAGS,msg:"invalid tag"})),{code:oe.INVALID_TAGS,tracks:i};if(!(t instanceof MediaStream))return this._logger.error(ae.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> stream"})),{code:oe.PARAMS_ERROR,tracks:i};const n=this._context.getCurrentId();if(!n)return this._logger.error(ae.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:ce.FAILED,code:oe.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:oe.INVALID_USER_ID,tracks:i};const[s,o]=gc.getTracksWithOptions(t,r);return s&&i.push(new Ft(this._logger,e,n,s)),o&&i.push(new jt(this._logger,e,n,o)),this._logger.info(ae.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:ce.SUCCESSED,trackIds:i.map(e=>e.getTrackId())})),{code:oe.SUCCESS,tracks:i}})}static getTracksWithOptions(e,t){const r=[];return r[0]=(null==t?void 0:t.withoutAudio)?void 0:e.getAudioTracks()[0],r[1]=(null==t?void 0:t.withoutVideo)?void 0:e.getVideoTracks()[0],r}_applyVideoAspectRatio(e,t,r){return v(this,void 0,void 0,function*(){const{width:i,height:n}=e.getSettings();if(i===t&&n===r)return;const s=t/r>=1?{width:{ideal:i,max:i}}:{height:{ideal:n,max:n}};try{yield e.applyConstraints(Object.assign(Object.assign({},s),{aspectRatio:{ideal:t/r}})),this._logger.info(ae.L_RTC_CLIENT_APPLY_VIDEO_ASPECT_RATIO_O,JSON.stringify({status:ce.SUCCESSED,msg:`apply aspectRatio success -> ${t} / ${r}`}))}catch(e){this._logger.warn(ae.L_RTC_CLIENT_APPLY_VIDEO_ASPECT_RATIO_O,JSON.stringify({status:ce.FAILED,msg:`apply aspectRatio error -> ${JSON.stringify(e)}`}))}})}}const mc=function(){var e,t={},r=function(e){var t=function(e,r,n){if(void 0===e&&(e=t.DEFAULT_CAPACITY),void 0===r&&(r=t.DEFAULT_ENDIAN),void 0===n&&(n=t.DEFAULT_NOASSERT),!n){if((e|=0)<0)throw RangeError("Illegal capacity");r=!!r,n=!!n}this.buffer=0===e?i:new ArrayBuffer(e),this.view=0===e?null:new Uint8Array(this.buffer),this.offset=0,this.markedOffset=-1,this.limit=e,this.littleEndian=r,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 r=t.prototype;r.__isByteBuffer__,Object.defineProperty(r,"__isByteBuffer__",{value:!0,enumerable:!1,configurable:!1});var i=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,r,i,n){var s,o,a=8*n-i-1,c=(1<<a)-1,l=c>>1,d=-7,u=r?n-1:0,_=r?-1:1,h=e[t+u];for(u+=_,s=h&(1<<-d)-1,h>>=-d,d+=a;d>0;s=256*s+e[t+u],u+=_,d-=8);for(o=s&(1<<-d)-1,s>>=-d,d+=i;d>0;o=256*o+e[t+u],u+=_,d-=8);if(0===s)s=1-l;else{if(s===c)return o?NaN:1/0*(h?-1:1);o+=Math.pow(2,i),s-=l}return(h?-1:1)*o*Math.pow(2,s-i)}function c(e,t,r,i,n,s){var o,a,c,l=8*s-n-1,d=(1<<l)-1,u=d>>1,_=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,h=i?0:s-1,p=i?1:-1,f=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=d):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),(t+=o+u>=1?_/c:_*Math.pow(2,1-u))*c>=2&&(o++,c/=2),o+u>=d?(a=0,o=d):o+u>=1?(a=(t*c-1)*Math.pow(2,n),o+=u):(a=t*Math.pow(2,u-1)*Math.pow(2,n),o=0));n>=8;e[r+h]=255&a,h+=p,a/=256,n-=8);for(o=o<<n|a,l+=n;l>0;e[r+h]=255&o,h+=p,o/=256,l-=8);e[r+h-p]|=128*f}t.accessor=function(){return Uint8Array},t.allocate=function(e,r,i){return new t(e,r,i)},t.concat=function(e,r,i,n){"boolean"!=typeof r&&"string"==typeof r||(n=i,i=r,r=void 0);for(var s,o=0,a=0,c=e.length;a<c;++a)t.isByteBuffer(e[a])||(e[a]=t.wrap(e[a],r)),(s=e[a].limit-e[a].offset)>0&&(o+=s);if(0===o)return new t(0,i,n);var l,d=new t(o,i,n);for(a=0;a<c;)(s=(l=e[a++]).limit-l.offset)<=0||(d.view.set(l.view.subarray(l.offset,l.limit),d.offset),d.offset+=s);return d.limit=d.offset,d.offset=0,d},t.isByteBuffer=function(e){return!0===(e&&e.__isByteBuffer__)},t.type=function(){return ArrayBuffer},t.wrap=function(e,i,n,s){if("string"!=typeof i&&(s=n,n=i,i=void 0),"string"==typeof e)switch(void 0===i&&(i="utf8"),i){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: "+i)}if(null===e||"object"!=typeof e)throw TypeError("Illegal buffer");var o;if(t.isByteBuffer(e))return(o=r.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},r.writeBitSet=function(e,t){var r=void 0===t;if(r&&(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 i,n=t,s=e.length,o=s>>3,a=0;for(t+=this.writeVarint32(s,t);o--;)i=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(i,t++);if(a<s){var c=0;for(i=0;a<s;)i|=(1&!!e[a++])<<c++;this.writeByte(i,t++)}return r?(this.offset=t,this):t-n},r.readBitSet=function(e){var t=void 0===e;t&&(e=this.offset);var r,i=this.readVarint32(e),n=i.value,s=n>>3,o=0,a=[];for(e+=i.length;s--;)r=this.readByte(e++),a[o++]=!!(1&r),a[o++]=!!(2&r),a[o++]=!!(4&r),a[o++]=!!(8&r),a[o++]=!!(16&r),a[o++]=!!(32&r),a[o++]=!!(64&r),a[o++]=!!(128&r);if(o<n){var c=0;for(r=this.readByte(e++);o<n;)a[o++]=!!(r>>c++&1)}return t&&(this.offset=e),a},r.readBytes=function(e,t){var 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+e>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+"+e+") <= "+this.buffer.byteLength)}var i=this.slice(t,t+e);return r&&(this.offset+=e),i},r.writeBytes=r.append,r.writeInt8=function(e,t){var r=void 0===t;if(r&&(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 i=this.buffer.byteLength;return t>i&&this.resize((i*=2)>t?i:t),t-=1,this.view[t]=e,r&&(this.offset+=1),this},r.writeByte=r.writeInt8,r.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 r=this.view[e];return 128&~r||(r=-(255-r+1)),t&&(this.offset+=1),r},r.readByte=r.readInt8,r.writeUint8=function(e,t){var r=void 0===t;if(r&&(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 i=this.buffer.byteLength;return t>i&&this.resize((i*=2)>t?i:t),t-=1,this.view[t]=e,r&&(this.offset+=1),this},r.writeUInt8=r.writeUint8,r.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 r=this.view[e];return t&&(this.offset+=1),r},r.readUInt8=r.readUint8,r.writeInt16=function(e,t){var r=void 0===t;if(r&&(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 i=this.buffer.byteLength;return t>i&&this.resize((i*=2)>t?i: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),r&&(this.offset+=2),this},r.writeShort=r.writeInt16,r.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 r=0;return this.littleEndian?(r=this.view[e],r|=this.view[e+1]<<8):(r=this.view[e]<<8,r|=this.view[e+1]),32768&~r||(r=-(65535-r+1)),t&&(this.offset+=2),r},r.readShort=r.readInt16,r.writeUint16=function(e,t){var r=void 0===t;if(r&&(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 i=this.buffer.byteLength;return t>i&&this.resize((i*=2)>t?i: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),r&&(this.offset+=2),this},r.writeUInt16=r.writeUint16,r.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 r=0;return this.littleEndian?(r=this.view[e],r|=this.view[e+1]<<8):(r=this.view[e]<<8,r|=this.view[e+1]),t&&(this.offset+=2),r},r.readUInt16=r.readUint16,r.writeInt32=function(e,t){var r=void 0===t;if(r&&(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 i=this.buffer.byteLength;return t>i&&this.resize((i*=2)>t?i: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),r&&(this.offset+=4),this},r.writeInt=r.writeInt32,r.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 r=0;return this.littleEndian?(r=this.view[e+2]<<16,r|=this.view[e+1]<<8,r|=this.view[e],r+=this.view[e+3]<<24>>>0):(r=this.view[e+1]<<16,r|=this.view[e+2]<<8,r|=this.view[e+3],r+=this.view[e]<<24>>>0),r|=0,t&&(this.offset+=4),r},r.readInt=r.readInt32,r.writeUint32=function(e,t){var r=void 0===t;if(r&&(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 i=this.buffer.byteLength;return t>i&&this.resize((i*=2)>t?i: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),r&&(this.offset+=4),this},r.writeUInt32=r.writeUint32,r.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 r=0;return this.littleEndian?(r=this.view[e+2]<<16,r|=this.view[e+1]<<8,r|=this.view[e],r+=this.view[e+3]<<24>>>0):(r=this.view[e+1]<<16,r|=this.view[e+2]<<8,r|=this.view[e+3],r+=this.view[e]<<24>>>0),t&&(this.offset+=4),r},r.readUInt32=r.readUint32,e&&(r.writeInt64=function(t,r){var i=void 0===r;if(i&&(r=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 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 t?t=e.fromNumber(t):"string"==typeof t&&(t=e.fromString(t)),r+=8;var n=this.buffer.byteLength;r>n&&this.resize((n*=2)>r?n:r),r-=8;var s=t.low,o=t.high;return this.littleEndian?(this.view[r+3]=s>>>24&255,this.view[r+2]=s>>>16&255,this.view[r+1]=s>>>8&255,this.view[r]=255&s,r+=4,this.view[r+3]=o>>>24&255,this.view[r+2]=o>>>16&255,this.view[r+1]=o>>>8&255,this.view[r]=255&o):(this.view[r]=o>>>24&255,this.view[r+1]=o>>>16&255,this.view[r+2]=o>>>8&255,this.view[r+3]=255&o,r+=4,this.view[r]=s>>>24&255,this.view[r+1]=s>>>16&255,this.view[r+2]=s>>>8&255,this.view[r+3]=255&s),i&&(this.offset+=8),this},r.writeLong=r.writeInt64,r.readInt64=function(t){var 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+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+8) <= "+this.buffer.byteLength)}var i=0,n=0;this.littleEndian?(i=this.view[t+2]<<16,i|=this.view[t+1]<<8,i|=this.view[t],i+=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,i=this.view[t+1]<<16,i|=this.view[t+2]<<8,i|=this.view[t+3],i+=this.view[t]<<24>>>0);var s=new e(i,n,!1);return r&&(this.offset+=8),s},r.readLong=r.readInt64,r.writeUint64=function(t,r){var i=void 0===r;if(i&&(r=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 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 t?t=e.fromNumber(t):"string"==typeof t&&(t=e.fromString(t)),r+=8;var n=this.buffer.byteLength;r>n&&this.resize((n*=2)>r?n:r),r-=8;var s=t.low,o=t.high;return this.littleEndian?(this.view[r+3]=s>>>24&255,this.view[r+2]=s>>>16&255,this.view[r+1]=s>>>8&255,this.view[r]=255&s,r+=4,this.view[r+3]=o>>>24&255,this.view[r+2]=o>>>16&255,this.view[r+1]=o>>>8&255,this.view[r]=255&o):(this.view[r]=o>>>24&255,this.view[r+1]=o>>>16&255,this.view[r+2]=o>>>8&255,this.view[r+3]=255&o,r+=4,this.view[r]=s>>>24&255,this.view[r+1]=s>>>16&255,this.view[r+2]=s>>>8&255,this.view[r+3]=255&s),i&&(this.offset+=8),this},r.writeUInt64=r.writeUint64,r.readUint64=function(t){var 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+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+8) <= "+this.buffer.byteLength)}var i=0,n=0;this.littleEndian?(i=this.view[t+2]<<16,i|=this.view[t+1]<<8,i|=this.view[t],i+=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,i=this.view[t+1]<<16,i|=this.view[t+2]<<8,i|=this.view[t+3],i+=this.view[t]<<24>>>0);var s=new e(i,n,!0);return r&&(this.offset+=8),s},r.readUInt64=r.readUint64),r.writeFloat32=function(e,t){var r=void 0===t;if(r&&(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 i=this.buffer.byteLength;return t>i&&this.resize((i*=2)>t?i:t),t-=4,c(this.view,e,t,this.littleEndian,23,4),r&&(this.offset+=4),this},r.writeFloat=r.writeFloat32,r.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 r=a(this.view,e,this.littleEndian,23,4);return t&&(this.offset+=4),r},r.readFloat=r.readFloat32,r.writeFloat64=function(e,t){var r=void 0===t;if(r&&(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 i=this.buffer.byteLength;return t>i&&this.resize((i*=2)>t?i:t),t-=8,c(this.view,e,t,this.littleEndian,52,8),r&&(this.offset+=8),this},r.writeDouble=r.writeFloat64,r.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 r=a(this.view,e,this.littleEndian,52,8);return t&&(this.offset+=8),r},r.readDouble=r.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)},r.writeVarint32=function(e,r){var i=void 0===r;if(i&&(r=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+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 n,s=t.calculateVarint32(e);r+=s;var o=this.buffer.byteLength;for(r>o&&this.resize((o*=2)>r?o:r),r-=s,e>>>=0;e>=128;)n=127&e|128,this.view[r++]=n,e>>>=7;return this.view[r++]=e,i?(this.offset=r,this):s},r.writeVarint32ZigZag=function(e,r){return this.writeVarint32(t.zigZagEncode32(e),r)},r.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 r,i=0,n=0;do{if(!this.noAssert&&e>this.limit){var s=Error("Truncated");throw s.truncated=!0,s}r=this.view[e++],i<5&&(n|=(127&r)<<7*i),++i}while(128&r);return n|=0,t?(this.offset=e,n):{value:n,length:i}},r.readVarint32ZigZag=function(e){var r=this.readVarint32(e);return"object"==typeof r?r.value=t.zigZagDecode32(r.value):r=t.zigZagDecode32(r),r},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 r=t.toInt()>>>0,i=t.shiftRightUnsigned(28).toInt()>>>0,n=t.shiftRightUnsigned(56).toInt()>>>0;return 0==n?0==i?r<16384?r<128?1:2:r<1<<21?3:4:i<16384?i<128?5:6:i<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()},r.writeVarint64=function(r,i){var n=void 0===i;if(n&&(i=this.offset),!this.noAssert){if("number"==typeof r)r=e.fromNumber(r);else if("string"==typeof r)r=e.fromString(r);else if(!(r&&r instanceof e))throw TypeError("Illegal value: "+r+" (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 r?r=e.fromNumber(r,!1):"string"==typeof r?r=e.fromString(r,!1):!1!==r.unsigned&&(r=r.toSigned());var s=t.calculateVarint64(r),o=r.toInt()>>>0,a=r.shiftRightUnsigned(28).toInt()>>>0,c=r.shiftRightUnsigned(56).toInt()>>>0;i+=s;var l=this.buffer.byteLength;switch(i>l&&this.resize((l*=2)>i?l:i),i-=s,s){case 10:this.view[i+9]=c>>>7&1;case 9:this.view[i+8]=9!==s?128|c:127&c;case 8:this.view[i+7]=8!==s?a>>>21|128:a>>>21&127;case 7:this.view[i+6]=7!==s?a>>>14|128:a>>>14&127;case 6:this.view[i+5]=6!==s?a>>>7|128:a>>>7&127;case 5:this.view[i+4]=5!==s?128|a:127&a;case 4:this.view[i+3]=4!==s?o>>>21|128:o>>>21&127;case 3:this.view[i+2]=3!==s?o>>>14|128:o>>>14&127;case 2:this.view[i+1]=2!==s?o>>>7|128:o>>>7&127;case 1:this.view[i]=1!==s?128|o:127&o}return n?(this.offset+=s,this):s},r.writeVarint64ZigZag=function(e,r){return this.writeVarint64(t.zigZagEncode64(e),r)},r.readVarint64=function(t){var 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+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+1) <= "+this.buffer.byteLength)}var i=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 c=e.fromBits(n|s<<28,s>>>4|o<<24,!1);return r?(this.offset=t,c):{value:c,length:t-i}},r.readVarint64ZigZag=function(r){var i=this.readVarint64(r);return i&&i.value instanceof e?i.value=t.zigZagDecode64(i.value):i=t.zigZagDecode64(i),i}),r.writeCString=function(e,t){var r=void 0===t;r&&(t=this.offset);var i,n=e.length;if(!this.noAssert){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");for(i=0;i<n;++i)if(0===e.charCodeAt(i))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=d.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,d.encodeUTF16toUTF8(s(e),function(e){this.view[t++]=e}.bind(this)),this.view[t++]=0,r?(this.offset=t,this):n},r.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 r,i=e,n=-1;return d.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),r=o(),!0),t?(this.offset=e,r()):{string:r(),length:e-i}},r.writeIString=function(e,t){var r=void 0===t;if(r&&(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 i,n=t;i=d.calculateUTF16asUTF8(s(e),this.noAssert)[1],t+=4+i;var o=this.buffer.byteLength;if(t>o&&this.resize((o*=2)>t?o:t),t-=4+i,this.littleEndian?(this.view[t+3]=i>>>24&255,this.view[t+2]=i>>>16&255,this.view[t+1]=i>>>8&255,this.view[t]=255&i):(this.view[t]=i>>>24&255,this.view[t+1]=i>>>16&255,this.view[t+2]=i>>>8&255,this.view[t+3]=255&i),t+=4,d.encodeUTF16toUTF8(s(e),function(e){this.view[t++]=e}.bind(this)),t!==n+4+i)throw RangeError("Illegal range: Truncated data, "+t+" == "+(t+4+i));return r?(this.offset=t,this):t-n},r.readIString=function(e){var r=void 0===e;if(r&&(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=e,n=this.readUint32(e),s=this.readUTF8String(n,t.METRICS_BYTES,e+=4);return e+=s.length,r?(this.offset=e,s.string):{string:s.string,length:e-i}},t.METRICS_CHARS="c",t.METRICS_BYTES="b",r.writeUTF8String=function(e,t){var r,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+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}var n=t;r=d.calculateUTF16asUTF8(s(e))[1],t+=r;var o=this.buffer.byteLength;return t>o&&this.resize((o*=2)>t?o:t),t-=r,d.encodeUTF16toUTF8(s(e),function(e){this.view[t++]=e}.bind(this)),i?(this.offset=t,this):t-n},r.writeString=r.writeUTF8String,t.calculateUTF8Chars=function(e){return d.calculateUTF16asUTF8(s(e))[0]},t.calculateUTF8Bytes=function(e){return d.calculateUTF16asUTF8(s(e))[1]},t.calculateString=t.calculateUTF8Bytes,r.readUTF8String=function(e,r,i){"number"==typeof r&&(i=r,r=void 0);var n=void 0===i;if(n&&(i=this.offset),void 0===r&&(r=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 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 s,a=0,c=i;if(r===t.METRICS_CHARS){if(s=o(),d.decodeUTF8(function(){return a<e&&i<this.limit?this.view[i++]:null}.bind(this),function(e){++a,d.UTF8toUTF16(e,s)}),a!==e)throw RangeError("Illegal range: Truncated data, "+a+" == "+e);return n?(this.offset=i,s()):{string:s(),length:i-c}}if(r===t.METRICS_BYTES){if(!this.noAssert){if("number"!=typeof i||i%1!=0)throw TypeError("Illegal offset: "+i+" (not an integer)");if((i>>>=0)<0||i+e>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+i+" (+"+e+") <= "+this.buffer.byteLength)}var l=i+e;if(d.decodeUTF8toUTF16(function(){return i<l?this.view[i++]:null}.bind(this),s=o(),this.noAssert),i!==l)throw RangeError("Illegal range: Truncated data, "+i+" == "+l);return n?(this.offset=i,s()):{string:s(),length:i-c}}throw TypeError("Unsupported metrics: "+r)},r.readString=r.readUTF8String,r.writeVString=function(e,r){var i=void 0===r;if(i&&(r=this.offset),!this.noAssert){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");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)}var n,o,a=r;n=d.calculateUTF16asUTF8(s(e),this.noAssert)[1],o=t.calculateVarint32(n),r+=o+n;var c=this.buffer.byteLength;if(r>c&&this.resize((c*=2)>r?c:r),r-=o+n,r+=this.writeVarint32(n,r),d.encodeUTF16toUTF8(s(e),function(e){this.view[r++]=e}.bind(this)),r!==a+n+o)throw RangeError("Illegal range: Truncated data, "+r+" == "+(r+n+o));return i?(this.offset=r,this):r-a},r.readVString=function(e){var r=void 0===e;if(r&&(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=e,n=this.readVarint32(e),s=this.readUTF8String(n.value,t.METRICS_BYTES,e+=n.length);return e+=s.length,r?(this.offset=e,s.string):{string:s.string,length:e-i}},r.append=function(e,r,i){"number"!=typeof r&&"string"==typeof r||(i=r,r=void 0);var n=void 0===i;if(n&&(i=this.offset),!this.noAssert){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)}e instanceof t||(e=t.wrap(e,r));var s=e.limit-e.offset;if(s<=0)return this;i+=s;var o=this.buffer.byteLength;return i>o&&this.resize((o*=2)>i?o:i),i-=s,this.view.set(e.view.subarray(e.offset,e.limit),i),e.offset+=s,n&&(this.offset+=s),this},r.appendTo=function(e,t){return e.append(this,t),this},r.assert=function(e){return this.noAssert=!e,this},r.capacity=function(){return this.buffer.byteLength},r.clear=function(){return this.offset=0,this.limit=this.buffer.byteLength,this.markedOffset=-1,this},r.clone=function(e){var r=new t(0,this.littleEndian,this.noAssert);return e?(r.buffer=new ArrayBuffer(this.buffer.byteLength),r.view=new Uint8Array(r.buffer)):(r.buffer=this.buffer,r.view=this.view),r.offset=this.offset,r.markedOffset=this.markedOffset,r.limit=this.limit,r},r.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 r=t-e;if(0===r)return this.buffer=i,this.view=null,this.markedOffset>=0&&(this.markedOffset-=e),this.offset=0,this.limit=0,this;var n=new ArrayBuffer(r),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=r,this},r.copy=function(e,r){if(void 0===e&&(e=this.offset),void 0===r&&(r=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof r||r%1!=0)throw TypeError("Illegal end: Not an integer");if(r>>>=0,e<0||e>r||r>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+r+" <= "+this.buffer.byteLength)}if(e===r)return new t(0,this.littleEndian,this.noAssert);var i=r-e,n=new t(i,this.littleEndian,this.noAssert);return n.offset=0,n.limit=i,n.markedOffset>=0&&(n.markedOffset-=e),this.copyTo(n,0,e,r),n},r.copyTo=function(e,r,i,n){var s,o;if(!this.noAssert&&!t.isByteBuffer(e))throw TypeError("Illegal target: Not a ByteBuffer");if(r=(o=void 0===r)?e.offset:0|r,i=(s=void 0===i)?this.offset:0|i,n=void 0===n?this.limit:0|n,r<0||r>e.buffer.byteLength)throw RangeError("Illegal target range: 0 <= "+r+" <= "+e.buffer.byteLength);if(i<0||n>this.buffer.byteLength)throw RangeError("Illegal source range: 0 <= "+i+" <= "+this.buffer.byteLength);var a=n-i;return 0===a?e:(e.ensureCapacity(r+a),e.view.set(this.view.subarray(i,n),r),s&&(this.offset+=a),o&&(e.offset+=a),this)},r.ensureCapacity=function(e){var t=this.buffer.byteLength;return t<e?this.resize((t*=2)>e?t:e):this},r.fill=function(e,t,r){var i=void 0===t;if(i&&(t=this.offset),"string"==typeof e&&e.length>0&&(e=e.charCodeAt(0)),void 0===t&&(t=this.offset),void 0===r&&(r=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 r||r%1!=0)throw TypeError("Illegal end: Not an integer");if(r>>>=0,t<0||t>r||r>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+t+" <= "+r+" <= "+this.buffer.byteLength)}if(t>=r)return this;for(;t<r;)this.view[t++]=e;return i&&(this.offset=t),this},r.flip=function(){return this.limit=this.offset,this.offset=0,this},r.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},r.order=function(e){if(!this.noAssert&&"boolean"!=typeof e)throw TypeError("Illegal littleEndian: Not a boolean");return this.littleEndian=!!e,this},r.LE=function(e){return this.littleEndian=void 0===e||!!e,this},r.BE=function(e){return this.littleEndian=void 0!==e&&!e,this},r.prepend=function(e,r,i){"number"!=typeof r&&"string"==typeof r||(i=r,r=void 0);var n=void 0===i;if(n&&(i=this.offset),!this.noAssert){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)}e instanceof t||(e=t.wrap(e,r));var s=e.limit-e.offset;if(s<=0)return this;var o=s-i;if(o>0){var a=new ArrayBuffer(this.buffer.byteLength+o),c=new Uint8Array(a);c.set(this.view.subarray(i,this.buffer.byteLength),s),this.buffer=a,this.view=c,this.offset+=o,this.markedOffset>=0&&(this.markedOffset+=o),this.limit+=o,i+=o}else new Uint8Array(this.buffer);return this.view.set(e.view.subarray(e.offset,e.limit),i-s),e.offset=e.limit,n&&(this.offset-=s),this},r.prependTo=function(e,t){return e.prepend(this,t),this},r.printDebug=function(e){"function"!=typeof e&&(e=console.log.bind(console)),e(this.toString()+"\n-------------------------------------------------------------------\n"+this.toDebug(!0))},r.remaining=function(){return this.limit-this.offset},r.reset=function(){return this.markedOffset>=0?(this.offset=this.markedOffset,this.markedOffset=-1):this.offset=0,this},r.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),r=new Uint8Array(t);r.set(this.view),this.buffer=t,this.view=r}return this},r.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},r.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},r.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 r=this.clone();return r.offset=e,r.limit=t,r},r.toBuffer=function(e){var t=this.offset,r=this.limit;if(!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: Not an integer");if(t>>>=0,"number"!=typeof r||r%1!=0)throw TypeError("Illegal limit: Not an integer");if(r>>>=0,t<0||t>r||r>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+t+" <= "+r+" <= "+this.buffer.byteLength)}if(!e&&0===t&&r===this.buffer.byteLength)return this.buffer;if(t===r)return i;var n=new ArrayBuffer(r-t);return new Uint8Array(n).set(new Uint8Array(this.buffer).subarray(t,r),0),n},r.toArrayBuffer=r.toBuffer,r.toString=function(e,t,r){if(void 0===e)return"ByteBufferAB(offset="+this.offset+",markedOffset="+this.markedOffset+",limit="+this.limit+",capacity="+this.capacity()+")";switch("number"==typeof e&&(r=t=e="utf8"),e){case"utf8":return this.toUTF8(t,r);case"base64":return this.toBase64(t,r);case"hex":return this.toHex(t,r);case"binary":return this.toBinary(t,r);case"debug":return this.toDebug();case"columns":return this.toColumns();default:throw Error("Unsupported encoding: "+e)}};var l=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],r=[],i=0,n=t.length;i<n;++i)r[t[i]]=i;return e.encode=function(e,r){for(var i,n;null!==(i=e());)r(t[i>>2&63]),n=(3&i)<<4,null!==(i=e())?(r(t[63&((n|=i>>4&15)|i>>4&15)]),n=(15&i)<<2,null!==(i=e())?(r(t[63&(n|i>>6&3)]),r(t[63&i])):(r(t[63&n]),r(61))):(r(t[63&n]),r(61),r(61))},e.decode=function(e,t){var i,n,s;function o(e){throw Error("Illegal character code: "+e)}for(;null!==(i=e());)if(void 0===(n=r[i])&&o(i),null!==(i=e())&&(void 0===(s=r[i])&&o(i),t(n<<2>>>0|(48&s)>>4),null!==(i=e()))){if(void 0===(n=r[i])){if(61===i)break;o(i)}if(t((15&s)<<4>>>0|(60&n)>>2),null!==(i=e())){if(void 0===(s=r[i])){if(61===i)break;o(i)}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}();r.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 r;return l.encode(function(){return e<t?this.view[e++]:null}.bind(this),r=o()),r()},t.fromBase64=function(e,r){if("string"!=typeof e)throw TypeError("str");var i=new t(e.length/4*3,r),n=0;return l.decode(s(e),function(e){i.view[n++]=e}),i.limit=n,i},t.btoa=function(e){return t.fromBinary(e).toBase64()},t.atob=function(e){return t.fromBase64(e).toBinary()},r.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 r=[],i=[];e<t;)r.push(this.view[e++]),r.length>=1024&&(i.push(String.fromCharCode.apply(String,r)),r=[]);return i.join("")+String.fromCharCode.apply(String,r)},t.fromBinary=function(e,r){if("string"!=typeof e)throw TypeError("str");for(var i,n=0,s=e.length,o=new t(s,r);n<s;){if((i=e.charCodeAt(n))>255)throw RangeError("illegal char code: "+i);o.view[n++]=i}return o.limit=s,o},r.toDebug=function(e){for(var t,r=-1,i=this.buffer.byteLength,n="",s="",o="";r<i;){if(-1!==r&&(n+=(t=this.view[r])<16?"0"+t.toString(16).toUpperCase():t.toString(16).toUpperCase(),e&&(s+=t>32&&t<127?String.fromCharCode(t):".")),++r,e&&r>0&&r%16==0&&r!==i){for(;n.length<51;)n+=" ";o+=n+s+"\n",n=s=""}r===this.offset&&r===this.limit?n+=r===this.markedOffset?"!":"|":r===this.offset?n+=r===this.markedOffset?"[":"<":r===this.limit?n+=r===this.markedOffset?"]":">":n+=r===this.markedOffset?"'":e||0!==r&&r!==i?" ":""}if(e&&" "!==n){for(;n.length<51;)n+=" ";o+=n+s+"\n"}return e?o:n},t.fromDebug=function(e,r,i){for(var n,s,o=e.length,a=new t((o+1)/3|0,r,i),c=0,l=0,d=!1,u=!1,_=!1,h=!1,p=!1;c<o;){switch(n=e.charAt(c++)){case"!":if(!i){if(u||_||h){p=!0;break}u=_=h=!0}a.offset=a.markedOffset=a.limit=l,d=!1;break;case"|":if(!i){if(u||h){p=!0;break}u=h=!0}a.offset=a.limit=l,d=!1;break;case"[":if(!i){if(u||_){p=!0;break}u=_=!0}a.offset=a.markedOffset=l,d=!1;break;case"<":if(!i){if(u){p=!0;break}u=!0}a.offset=l,d=!1;break;case"]":if(!i){if(h||_){p=!0;break}h=_=!0}a.limit=a.markedOffset=l,d=!1;break;case">":if(!i){if(h){p=!0;break}h=!0}a.limit=l,d=!1;break;case"'":if(!i){if(_){p=!0;break}_=!0}a.markedOffset=l,d=!1;break;case" ":d=!1;break;default:if(!i&&d){p=!0;break}if(s=parseInt(n+e.charAt(c++),16),!i&&(isNaN(s)||s<0||s>255))throw TypeError("Illegal str: Not a debug encoded string");a.view[l++]=s,d=!0}if(p)throw TypeError("Illegal str: Invalid symbol at "+c)}if(!i){if(!u||!h)throw TypeError("Illegal str: Missing offset or limit");if(l<a.buffer.byteLength)throw TypeError("Illegal str: Not a debug encoded string (is it hex?) "+l+" < "+o)}return a},r.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 r,i=new Array(t-e);e<t;)(r=this.view[e++])<16?i.push("0",r.toString(16)):i.push(r.toString(16));return i.join("")},t.fromHex=function(e,r,i){if(!i){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,r),a=0,c=0;a<s;a+=2){if(n=parseInt(e.substring(a,a+2),16),!i&&(!isFinite(n)||n<0||n>255))throw TypeError("Illegal str: Contains non-hex characters");o.view[c++]=n}return o.limit=c,o};var d=function(){var e={MAX_CODEPOINT:1114111,encodeUTF8:function(e,t){var r=null;for("number"==typeof e&&(r=e,e=function(){return null});null!==r||null!==(r=e());)r<128?t(127&r):r<2048?(t(r>>6&31|192),t(63&r|128)):r<65536?(t(r>>12&15|224),t(r>>6&63|128),t(63&r|128)):(t(r>>18&7|240),t(r>>12&63|128),t(r>>6&63|128),t(63&r|128)),r=null},decodeUTF8:function(e,t){for(var r,i,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!==(r=e());)if(128&r)if(192==(224&r))null===(i=e())&&o([r,i]),t((31&r)<<6|63&i);else if(224==(240&r))(null===(i=e())||null===(n=e()))&&o([r,i,n]),t((15&r)<<12|(63&i)<<6|63&n);else{if(240!=(248&r))throw RangeError("Illegal starting byte: "+r);(null===(i=e())||null===(n=e())||null===(s=e()))&&o([r,i,n,s]),t((7&r)<<18|(63&i)<<12|(63&n)<<6|63&s)}else t(r)},UTF16toUTF8:function(e,t){for(var r,i=null;null!==(r=null!==i?i:e());)r>=55296&&r<=57343&&null!==(i=e())&&i>=56320&&i<=57343?(t(1024*(r-55296)+i-56320+65536),i=null):t(r);null!==i&&t(i)},UTF8toUTF16:function(e,t){var r=null;for("number"==typeof e&&(r=e,e=function(){return null});null!==r||null!==(r=e());)r<=65535?t(r):(t(55296+((r-=65536)>>10)),t(r%1024+56320)),r=null},encodeUTF16toUTF8:function(t,r){e.UTF16toUTF8(t,function(t){e.encodeUTF8(t,r)})},decodeUTF8toUTF16:function(t,r){e.decodeUTF8(t,function(t){e.UTF8toUTF16(t,r)})},calculateCodePoint:function(e){return e<128?1:e<2048?2:e<65536?3:4},calculateUTF8:function(e){for(var t,r=0;null!==(t=e());)r+=t<128?1:t<2048?2:t<65536?3:4;return r},calculateUTF16asUTF8:function(t){var r=0,i=0;return e.UTF16toUTF8(t,function(e){++r,i+=e<128?1:e<2048?2:e<65536?3:4}),[r,i]}};return e}();return r.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 r;try{d.decodeUTF8toUTF16(function(){return e<t?this.view[e++]:null}.bind(this),r=o())}catch(r){if(e!==t)throw RangeError("Illegal range: Truncated data, "+e+" != "+t)}return r()},t.fromUTF8=function(e,r,i){if(!i&&"string"!=typeof e)throw TypeError("Illegal str: Not a string");var n=new t(d.calculateUTF16asUTF8(s(e),!0)[1],r,i),o=0;return d.encodeUTF16toUTF8(s(e),function(e){n.view[o++]=e}),n.limit=o,n},t}(function(){function e(e,t,r){this.low=0|e,this.high=0|t,this.unsigned=!!r}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 r={},i={};function n(e,t){var n,s,a;return t?(a=0<=(e>>>=0)&&e<256)&&(s=i[e])?s:(n=o(e,(0|e)<0?-1:0,!0),a&&(i[e]=n),n):(a=-128<=(e|=0)&&e<128)&&(s=r[e])?s:(n=o(e,e<0?-1:0,!1),a&&(r[e]=n),n)}function s(e,t){if(isNaN(e)||!isFinite(e))return t?f:p;if(t){if(e<0)return f;if(e>=u)return T}else{if(e<=-_)return I;if(e+1>=_)return E}return e<0?s(-e,t).neg():o(e%d|0,e/d|0,t)}function o(t,r,i){return new e(t,r,i)}e.fromInt=n,e.fromNumber=s,e.fromBits=o;var a=Math.pow;function c(e,t,r){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return p;if("number"==typeof t?(r=t,t=!1):t=!!t,(r=r||10)<2||36<r)throw RangeError("radix");var i;if((i=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===i)return c(e.substring(1),t,r).neg();for(var n=s(a(r,8)),o=p,l=0;l<e.length;l+=8){var d=Math.min(8,e.length-l),u=parseInt(e.substring(l,l+d),r);if(d<8){var _=s(a(r,d));o=o.mul(_).add(s(u))}else o=(o=o.mul(n)).add(s(u))}return o.unsigned=t,o}function l(t){return t instanceof e?t:"number"==typeof t?s(t):"string"==typeof t?c(t):o(t.low,t.high,t.unsigned)}e.fromString=c,e.fromValue=l;var d=4294967296,u=d*d,_=u/2,h=n(1<<24),p=n(0);e.ZERO=p;var f=n(0,!0);e.UZERO=f;var g=n(1);e.ONE=g;var m=n(1,!0);e.UONE=m;var R=n(-1);e.NEG_ONE=R;var E=o(-1,2147483647,!1);e.MAX_VALUE=E;var T=o(-1,-1,!0);e.MAX_UNSIGNED_VALUE=T;var I=o(0,-2147483648,!1);e.MIN_VALUE=I;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)*d+(this.low>>>0):this.high*d+(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(I)){var t=s(e),r=this.div(t),i=r.mul(t).sub(this);return r.toString(e)+i.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var n=s(a(e,6),this.unsigned),o=this,c="";;){var l=o.div(n),d=(o.sub(l.mul(n)).toInt()>>>0).toString(e);if((o=l).isZero())return d+c;for(;d.length<6;)d="0"+d;c=""+d+c}},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(I)?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=l(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=l(e)),this.eq(e))return 0;var r=this.isNegative(),i=e.isNegative();return r&&!i?-1:!r&&i?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(I)?I:this.not().add(g)},S.neg=S.negate,S.add=function(e){t(e)||(e=l(e));var r=this.high>>>16,i=65535&this.high,n=this.low>>>16,s=65535&this.low,a=e.high>>>16,c=65535&e.high,d=e.low>>>16,u=0,_=0,h=0,p=0;return h+=(p+=s+(65535&e.low))>>>16,_+=(h+=n+d)>>>16,u+=(_+=i+c)>>>16,u+=r+a,o((h&=65535)<<16|(p&=65535),(u&=65535)<<16|(_&=65535),this.unsigned)},S.subtract=function(e){return t(e)||(e=l(e)),this.add(e.neg())},S.sub=S.subtract,S.multiply=function(e){if(this.isZero())return p;if(t(e)||(e=l(e)),e.isZero())return p;if(this.eq(I))return e.isOdd()?I:p;if(e.eq(I))return this.isOdd()?I:p;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 r=this.high>>>16,i=65535&this.high,n=this.low>>>16,a=65535&this.low,c=e.high>>>16,d=65535&e.high,u=e.low>>>16,_=65535&e.low,f=0,g=0,m=0,R=0;return m+=(R+=a*_)>>>16,g+=(m+=n*_)>>>16,m&=65535,g+=(m+=a*u)>>>16,f+=(g+=i*_)>>>16,g&=65535,f+=(g+=n*u)>>>16,g&=65535,f+=(g+=a*d)>>>16,f+=r*_+i*u+n*d+a*c,o((m&=65535)<<16|(R&=65535),(f&=65535)<<16|(g&=65535),this.unsigned)},S.mul=S.multiply,S.divide=function(e){if(t(e)||(e=l(e)),e.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?f:p;var r,i,n;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return f;if(e.gt(this.shru(1)))return m;n=f}else{if(this.eq(I))return e.eq(g)||e.eq(R)?I:e.eq(I)?g:(r=this.shr(1).div(e).shl(1)).eq(p)?e.isNegative()?g:R:(i=this.sub(e.mul(r)),n=r.add(i.div(e)));if(e.eq(I))return this.unsigned?f:p;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();n=p}for(i=this;i.gte(e);){r=Math.max(1,Math.floor(i.toNumber()/e.toNumber()));for(var o=Math.ceil(Math.log(r)/Math.LN2),c=o<=48?1:a(2,o-48),d=s(r),u=d.mul(e);u.isNegative()||u.gt(i);)u=(d=s(r-=c,this.unsigned)).mul(e);d.isZero()&&(d=g),n=n.add(d),i=i.sub(u)}return n},S.div=S.divide,S.modulo=function(e){return t(e)||(e=l(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=l(e)),o(this.low&e.low,this.high&e.high,this.unsigned)},S.or=function(e){return t(e)||(e=l(e)),o(this.low|e.low,this.high|e.high,this.unsigned)},S.xor=function(e){return t(e)||(e=l(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 r=this.high;return e<32?o(this.low>>>e|r<<32-e,r>>>e,this.unsigned):o(32===e?r:r>>>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=r,t.Long=r.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 r={},i=function(e){this.source=e+"",this.index=0,this.line=1,this.stack=[],this._stringOpen=null},n=i.prototype;n._readString=function(){var e='"'===this._stringOpen?t.STRING_DQ:t.STRING_SQ;e.lastIndex=this.index-1;var r=e.exec(this.source);if(!r)throw Error("unterminated string");return this.index=e.lastIndex,this.stack.push(this._stringOpen),this._stringOpen=null,r[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,r,i;do{for(e=!1;t.WHITESPACE.test(i=this.source.charAt(this.index));)if("\n"===i&&++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("*"!==(i=this.source.charAt(this.index)))return"/";do{if("\n"===i&&++this.line,++this.index===this.source.length)return null;r=i,i=this.source.charAt(this.index)}while("*"!==r||"/"!==i);++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+")"},r.Tokenizer=i;var s=function(e){this.tn=new i(e),this.proto3=!1},o=s.prototype;function a(e,r){var i=-1,n=1;if("-"==e.charAt(0)&&(n=-1,e=e.substring(1)),t.NUMBER_DEC.test(e))i=parseInt(e);else if(t.NUMBER_HEX.test(e))i=parseInt(e.substring(2),16);else{if(!t.NUMBER_OCT.test(e))throw Error("illegal id value: "+(n<0?"-":"")+e);i=parseInt(e.substring(1),8)}if(i=n*i|0,!r&&i<0)throw Error("illegal id value: "+(n<0?"-":"")+e);return i}function c(e){var r=1;if("-"==e.charAt(0)&&(r=-1,e=e.substring(1)),t.NUMBER_DEC.test(e))return r*parseInt(e,10);if(t.NUMBER_HEX.test(e))return r*parseInt(e.substring(2),16);if(t.NUMBER_OCT.test(e))return r*parseInt(e.substring(1),8);if("inf"===e)return r*(1/0);if("nan"===e)return NaN;if(t.NUMBER_FLT.test(e))return r*parseFloat(e);throw Error("illegal number value: "+(r<0?"-":"")+e)}function l(e,t,r){void 0===e[t]?e[t]=r:(Array.isArray(e[t])||(e[t]=[e[t]]),e[t].push(r))}return o.parse=function(){var e,r,i={name:"[ROOT]",package:null,messages:[],enums:[],imports:[],options:{},services:[]},n=!0;try{for(;e=this.tn.next();)switch(e){case"package":if(!n||null!==i.package)throw Error("unexpected 'package'");if(e=this.tn.next(),!t.TYPEREF.test(e))throw Error("illegal package name: "+e);this.tn.skip(";"),i.package=e;break;case"import":if(!n)throw Error("unexpected 'import'");("public"===(e=this.tn.peek())||(r="weak"===e))&&this.tn.next(),e=this._readString(),this.tn.skip(";"),r||i.imports.push(e);break;case"syntax":if(!n)throw Error("unexpected 'syntax'");this.tn.skip("="),"proto3"===(i.syntax=this._readString())&&(this.proto3=!0),this.tn.skip(";");break;case"message":this._parseMessage(i,null),n=!1;break;case"enum":this._parseEnum(i),n=!1;break;case"option":this._parseOption(i);break;case"service":this._parseService(i);break;case"extend":this._parseExtend(i);break;default:throw Error("unexpected '"+e+"'")}}catch(e){throw e.message="Parse error at line "+this.tn.line+": "+e.message,e}return delete i.name,i},s.parse=function(e){return new s(e).parse()},o._readString=function(){var e,t,r="";do{if("'"!==(t=this.tn.next())&&'"'!==t)throw Error("illegal string delimiter: "+t);r+=this.tn.next(),this.tn.skip(t),e=this.tn.peek()}while('"'===e||'"'===e);return r},o._readValue=function(e){var r=this.tn.peek();if('"'===r||"'"===r)return this._readString();if(this.tn.next(),t.NUMBER.test(r))return c(r);if(t.BOOL.test(r))return"true"===r.toLowerCase();if(e&&t.TYPEREF.test(r))return r;throw Error("illegal value: "+r)},o._parseOption=function(e,r){var i=this.tn.next(),n=!1;if("("===i&&(n=!0,i=this.tn.next()),!t.TYPEREF.test(i))throw Error("illegal option name: "+i);var s=i;n&&(this.tn.skip(")"),s="("+s+")",i=this.tn.peek(),t.FQTYPEREF.test(i)&&(s+=i,this.tn.next())),this.tn.skip("="),this._parseOptionValue(e,s),r||this.tn.skip(";")},o._parseOptionValue=function(e,r){var i=this.tn.peek();if("{"!==i)l(e.options,r,this._readValue(!0));else for(this.tn.skip("{");"}"!==(i=this.tn.next());){if(!t.NAME.test(i))throw Error("illegal option name: "+r+"."+i);this.tn.omit(":")?l(e.options,r+"."+i,this._readValue(!0)):this._parseOptionValue(e,r+"."+i)}},o._parseService=function(e){var r=this.tn.next();if(!t.NAME.test(r))throw Error("illegal service name at line "+this.tn.line+": "+r);var i={name:r,rpc:{},options:{}};for(this.tn.skip("{");"}"!==(r=this.tn.next());)if("option"===r)this._parseOption(i);else{if("rpc"!==r)throw Error("illegal service token: "+r);this._parseServiceRPC(i)}this.tn.omit(";"),e.services.push(i)},o._parseServiceRPC=function(e){var r="rpc",i=this.tn.next();if(!t.NAME.test(i))throw Error("illegal rpc service method name: "+i);var n=i,s={request:null,response:null,request_stream:!1,response_stream:!1,options:{}};if(this.tn.skip("("),"stream"===(i=this.tn.next()).toLowerCase()&&(s.request_stream=!0,i=this.tn.next()),!t.TYPEREF.test(i))throw Error("illegal rpc service request type: "+i);if(s.request=i,this.tn.skip(")"),"returns"!==(i=this.tn.next()).toLowerCase())throw Error("illegal rpc service request type delimiter: "+i);if(this.tn.skip("("),"stream"===(i=this.tn.next()).toLowerCase()&&(s.response_stream=!0,i=this.tn.next()),s.response=i,this.tn.skip(")"),"{"===(i=this.tn.peek())){for(this.tn.next();"}"!==(i=this.tn.next());){if("option"!==i)throw Error("illegal rpc service token: "+i);this._parseOption(s)}this.tn.omit(";")}else this.tn.skip(";");void 0===e[r]&&(e[r]={}),e[r][n]=s},o._parseMessage=function(e,r){var i=!!r,n=this.tn.next(),s={name:"",fields:[],enums:[],messages:[],options:{},services:[],oneofs:{}};if(!t.NAME.test(n))throw Error("illegal "+(i?"group":"message")+" name: "+n);for(s.name=n,i&&(this.tn.skip("="),r.id=a(this.tn.next()),s.isGroup=!0),"["===(n=this.tn.peek())&&r&&this._parseFieldOptions(r),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,r,i){if(!t.RULE.test(r))throw Error("illegal message field rule: "+r);var n,s={rule:r,type:"",name:"",options:{},id:0};if("map"===r){if(i)throw Error("illegal type: "+i);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"===(i=void 0!==i?i: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(i)&&!t.TYPEREF.test(i))throw Error("illegal message field type: "+i);if(s.type=i,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 r=this.tn.next();if(!t.NAME.test(r))throw Error("illegal oneof name: "+r);var i,n=r,s=[];for(this.tn.skip("{");"}"!==(r=this.tn.next());)(i=this._parseMessageField(e,"optional",r)).oneof=n,s.push(i.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 r={name:"",values:[],options:{}},i=this.tn.next();if(!t.NAME.test(i))throw Error("illegal name: "+i);for(r.name=i,this.tn.skip("{");"}"!==(i=this.tn.next());)if("option"===i)this._parseOption(r);else{if(!t.NAME.test(i))throw Error("illegal name: "+i);this.tn.skip("=");var n={name:i,id:a(this.tn.next(),!0)};"["===(i=this.tn.peek())&&this._parseFieldOptions({options:{}}),this.tn.skip(";"),r.values.push(n)}this.tn.omit(";"),e.enums.push(r)},o._parseExtensionRanges=function(){var t,r,i,n=[];do{for(r=[];;){switch(t=this.tn.next()){case"min":i=e.ID_MIN;break;case"max":i=e.ID_MAX;break;default:i=c(t)}if(r.push(i),2===r.length)break;if("to"!==this.tn.peek()){r.push(i);break}this.tn.next()}n.push(r)}while(this.tn.omit(","));return this.tn.skip(";"),n},o._parseExtend=function(e){var r=this.tn.next();if(!t.TYPEREF.test(r))throw Error("illegal extend reference: "+r);var i={ref:r,fields:[]};for(this.tn.skip("{");"}"!==(r=this.tn.next());)if(t.RULE.test(r))this._parseMessageField(i,r);else{if(!t.TYPEREF.test(r))throw Error("illegal extend token: "+r);if(!this.proto3)throw Error("illegal field rule: "+r);this._parseMessageField(i,"optional",r)}return this.tn.omit(";"),e.messages.push(i),i},o.toString=function(){return"Parser at line "+this.tn.line},r.Parser=s,r}(t,t.Lang),t.Reflect=function(e){var t={},i=function(e,t,r){this.builder=e,this.parent=t,this.name=r,this.className},n=i.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=i;var s=function(e,t,r,n,s){i.call(this,e,t,r),this.className="Namespace",this.children=[],this.options=n||{},this.syntax=s||"proto2"},o=s.prototype=Object.create(i.prototype);o.getChildren=function(e){if(null==(e=e||null))return this.children.slice();for(var t=[],r=0,i=this.children.length;r<i;++r)this.children[r]instanceof e&&t.push(this.children[r]);return t},o.addChild=function(e){var t;if(t=this.getChild(e.name))if(t instanceof d.Field&&t.name!==t.originalName&&null===this.getChild(t.originalName))t.name=t.originalName;else{if(!(e instanceof d.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",r=0,i=this.children.length;r<i;++r)if(this.children[r][t]===e)return this.children[r];return null},o.resolve=function(e,r){var i,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(!(i=s.getChild(n[o]))||!(i instanceof t.T)||r&&!(i instanceof t.Namespace)){s=null;break}s=i,o++}while(o<n.length);if(null!=s)break;if(null!==this.parent)return this.parent.resolve(e,r)}while(null!=s);return s},o.qn=function(e){var r=[],i=e;do{r.unshift(i.name),i=i.parent}while(null!==i);for(var n=1;n<=r.length;n++){var s=r.slice(r.length-n);if(e===this.resolve(s,e instanceof t.Namespace))return s.join(".")}return e.fqn()},o.build=function(){for(var e,t={},r=this.children,i=0,n=r.length;i<n;++i)(e=r[i])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),r=0,i=t.length;r<i;++r){var n=t[r],s=this.options[t[r]];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,r,i,n,s){if(this.type=t,this.resolvedType=r,this.isMapKey=i,this.syntax=n,this.name=s,i&&e.MAP_KEY_TYPES.indexOf(t)<0)throw Error("Invalid map key type: "+t.name)},c=a.prototype;function l(t,r){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===r?t.unsigned:r);if("string"==typeof t)return e.Long.fromString(t,r||!1,10);if("number"==typeof t)return e.Long.fromNumber(t,r||!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 r(0):t.defaultValue},c.toString=function(){return(this.name||"")+(this.isMapKey?"map":"value")+" element"},c.verifyValue=function(t){var i=this;function n(e,t){throw Error("Illegal value for "+i.toString(!0)+" of type "+i.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 l(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 l(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 r.isByteBuffer(t)?t:r.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+")")},c.calculateLength=function(t,i){if(null===i)return 0;var n;switch(this.type){case e.TYPES.int32:return i<0?r.calculateVarint64(i):r.calculateVarint32(i);case e.TYPES.uint32:return r.calculateVarint32(i);case e.TYPES.sint32:return r.calculateVarint32(r.zigZagEncode32(i));case e.TYPES.fixed32:case e.TYPES.sfixed32:case e.TYPES.float:return 4;case e.TYPES.int64:case e.TYPES.uint64:return r.calculateVarint64(i);case e.TYPES.sint64:return r.calculateVarint64(r.zigZagEncode64(i));case e.TYPES.fixed64:case e.TYPES.sfixed64:return 8;case e.TYPES.bool:return 1;case e.TYPES.enum:return r.calculateVarint32(i);case e.TYPES.double:return 8;case e.TYPES.string:return n=r.calculateUTF8Bytes(i),r.calculateVarint32(n)+n;case e.TYPES.bytes:if(i.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+i.remaining()+" bytes remaining");return r.calculateVarint32(i.remaining())+i.remaining();case e.TYPES.message:return n=this.resolvedType.calculate(i),r.calculateVarint32(n)+n;case e.TYPES.group:return(n=this.resolvedType.calculate(i))+r.calculateVarint32(t<<3|e.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+i+" (unknown type)")},c.encodeValue=function(t,i,n){if(null===i)return n;switch(this.type){case e.TYPES.int32:i<0?n.writeVarint64(i):n.writeVarint32(i);break;case e.TYPES.uint32:n.writeVarint32(i);break;case e.TYPES.sint32:n.writeVarint32ZigZag(i);break;case e.TYPES.fixed32:n.writeUint32(i);break;case e.TYPES.sfixed32:n.writeInt32(i);break;case e.TYPES.int64:case e.TYPES.uint64:n.writeVarint64(i);break;case e.TYPES.sint64:n.writeVarint64ZigZag(i);break;case e.TYPES.fixed64:n.writeUint64(i);break;case e.TYPES.sfixed64:n.writeInt64(i);break;case e.TYPES.bool:"string"==typeof i?n.writeVarint32("false"===i.toLowerCase()?0:!!i):n.writeVarint32(i?1:0);break;case e.TYPES.enum:n.writeVarint32(i);break;case e.TYPES.float:n.writeFloat32(i);break;case e.TYPES.double:n.writeFloat64(i);break;case e.TYPES.string:n.writeVString(i);break;case e.TYPES.bytes:if(i.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+i.remaining()+" bytes remaining");var s=i.offset;n.writeVarint32(i.remaining()),n.append(i),i.offset=s;break;case e.TYPES.message:var o=(new r).LE();this.resolvedType.encode(i,o),n.writeVarint32(o.offset),n.append(o.flip());break;case e.TYPES.group:this.resolvedType.encode(i,n),n.writeVarint32(t<<3|e.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+i+" (unknown type)")}return n},c.decode=function(t,r,i){if(r!=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,i)}throw Error("[INTERNAL] Illegal decode type")},c.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 r.fromBinary(t)}},c.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 d=function(e,t,r,i,n,o){s.call(this,e,t,r,i,o),this.className="Message",this.extensions=void 0,this.clazz=null,this.isGroup=!!n,this._fields=null,this._fieldsById=null,this._fieldsByName=null},u=d.prototype=Object.create(s.prototype);function _(t,r){var i=r.readVarint32(),n=7&i,s=i>>>3;switch(n){case e.WIRE_TYPES.VARINT:do{i=r.readUint8()}while(!(128&~i));break;case e.WIRE_TYPES.BITS64:r.offset+=8;break;case e.WIRE_TYPES.LDELIM:i=r.readVarint32(),r.offset+=i;break;case e.WIRE_TYPES.STARTGROUP:_(s,r);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:r.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+t+": "+n)}return!0}u.build=function(t){if(this.clazz&&!t)return this.clazz;var i=function(e,t){var i=t.getChildren(e.Reflect.Message.Field),n=t.getChildren(e.Reflect.Message.OneOf),s=function(o,a){e.Builder.Message.call(this);for(var c=0,l=n.length;c<l;++c)this[n[c].name]=null;for(c=0,l=i.length;c<l;++c){var d=i[c];this[d.name]=d.repeated?[]:d.map?new e.Map(d):null,!d.required&&"proto3"!==t.syntax||null===d.defaultValue||(this[d.name]=d.defaultValue)}var u;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||r.isByteBuffer(o)||o instanceof ArrayBuffer||e.Long&&o instanceof e.Long)for(c=0,l=arguments.length;c<l;++c)void 0!==(u=arguments[c])&&this.$set(i[c].name,u);else this.$set(o)},o=s.prototype=Object.create(e.Builder.Message.prototype);o.add=function(r,i,n){var s=t._fieldsByName[r];if(!n){if(!s)throw Error(this+"#"+r+" is undefined");if(!(s instanceof e.Reflect.Message.Field))throw Error(this+"#"+r+" is not a field: "+s.toString(!0));if(!s.repeated)throw Error(this+"#"+r+" is not a repeated field");i=s.verifyValue(i,!0)}return null===this[r]&&(this[r]=[]),this[r].push(i),this},o.$add=o.add,o.set=function(r,i,n){if(r&&"object"==typeof r){for(var s in n=i,r)r.hasOwnProperty(s)&&void 0!==(i=r[s])&&void 0===t._oneofsByName[s]&&this.$set(s,i,n);return this}var o=t._fieldsByName[r];if(n)this[r]=i;else{if(!o)throw Error(this+"#"+r+" is not a field: undefined");if(!(o instanceof e.Reflect.Message.Field))throw Error(this+"#"+r+" is not a field: "+o.toString(!0));this[o.name]=i=o.verifyValue(i)}if(o&&o.oneof){var a=this[o.oneof.name];null!==i?(null!==a&&a!==o.name&&(this[a]=null),this[o.oneof.name]=o.name):a===r&&(this[o.oneof.name]=null)}return this},o.$set=o.set,o.get=function(r,i){if(i)return this[r];var n=t._fieldsByName[r];if(!(n&&n instanceof e.Reflect.Message.Field))throw Error(this+"#"+r+" is not a field: undefined");if(!(n instanceof e.Reflect.Message.Field))throw Error(this+"#"+r+" is not a field: "+n.toString(!0));return this[n.name]},o.$get=o.get;for(var a=0;a<i.length;a++){var c=i[a];c instanceof e.Reflect.Message.ExtensionField||t.builder.options.populateAccessors&&function(e){var r=e.originalName.replace(/(_[a-zA-Z])/g,function(e){return e.toUpperCase().replace("_","")});r=r.substring(0,1).toUpperCase()+r.substring(1);var i=e.originalName.replace(/([A-Z])/g,function(e){return"_"+e}),n=function(t,r){return this[e.name]=r?t:e.verifyValue(t),this},s=function(){return this[e.name]};null===t.getChild("set"+r)&&(o["set"+r]=n),null===t.getChild("set_"+i)&&(o["set_"+i]=n),null===t.getChild("get"+r)&&(o["get"+r]=s),null===t.getChild("get_"+i)&&(o["get_"+i]=s)}(c)}function l(t,i,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(r.isByteBuffer(t))return i?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]=l(e,i,n,s)}),a;if(a={},t instanceof e.Map){for(var c=t.entries(),d=c.next();!d.done;d=c.next())a[t.keyElem.valueToString(d.value[0])]=l(d.value[1],i,n,t.valueElem.resolvedType);return a}var u=t.$type,_=void 0;for(var h in t)t.hasOwnProperty(h)&&(u&&(_=u.getChild(h))?a[h]=l(t[h],i,n,_.resolvedType):a[h]=l(t[h],i,n));return a}return o.encode=function(e,i){"boolean"==typeof e&&(i=e,e=void 0);var n=!1;e||(e=new r,n=!0);var s=e.littleEndian;try{return t.encode(this,e.LE(),i),(n?e.flip():e).LE(s)}catch(t){throw e.LE(s),t}},s.encode=function(e,t,r){return new s(e).encode(t,r)},o.calculate=function(){return t.calculate(this)},o.encodeDelimited=function(e,i){var n=!1;e||(e=new r,n=!0);var s=(new r).LE();return t.encode(this,s,i).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 l(this,!!e,!!t,this.$type)},o.encodeJSON=function(){return JSON.stringify(l(this,!0,!0,this.$type))},s.decode=function(e,i,n){"string"==typeof i&&(n=i,i=-1),"string"==typeof e?e=r.wrap(e,n||"base64"):r.isByteBuffer(e)||(e=r.wrap(e));var s=e.littleEndian;try{var o=t.decode(e.LE(),i);return e.LE(s),o}catch(t){throw e.LE(s),t}},s.decodeDelimited=function(e,i){if("string"==typeof e?e=r.wrap(e,i||"base64"):r.isByteBuffer(e)||(e=r.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 g||n instanceof d||n instanceof E){if(i.hasOwnProperty(n.name))throw Error("Illegal reflect child of "+this.toString(!0)+": "+n.toString(!0)+" cannot override static property '"+n.name+"'");i[n.name]=n.build()}else if(n instanceof d.Field)n.build(),this._fields.push(n),this._fieldsById[n.id]=n,this._fieldsByName[n.name]=n;else if(n instanceof d.OneOf)this._oneofsByName[n.name]=n;else if(!(n instanceof d.OneOf||n instanceof R))throw Error("Illegal reflect child of "+this.toString(!0)+": "+this.children[s].toString(!0));return this.clazz=i},u.encode=function(e,t,r){for(var i,n,s=null,o=0,a=this._fields.length;o<a;++o)n=e[(i=this._fields[o]).name],i.required&&null===n?null===s&&(s=i):i.encode(r?n:i.verifyValue(n),t,e);if(null!==s){var c=Error("Missing at least one required field for "+this.toString(!0)+": "+s);throw c.encoded=t,c}return t},u.calculate=function(e){for(var t,r,i=0,n=0,s=this._fields.length;n<s;++n){if(r=e[(t=this._fields[n]).name],t.required&&null===r)throw Error("Missing at least one required field for "+this.toString(!0)+": "+t);i+=t.calculate(r,e)}return i},u.decode=function(t,r,i){"number"!=typeof r&&(r=-1);for(var n,s,o,a,c=t.offset,l=new this.clazz;t.offset<c+r||-1===r&&t.remaining()>0;){if(o=(n=t.readVarint32())>>>3,(s=7&n)===e.WIRE_TYPES.ENDGROUP){if(o!==i)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+o+" ("+(i?i+" expected":"not a group")+")");break}if(a=this._fieldsById[o]){if(a.repeated&&!a.options.packed)l[a.name].push(a.decode(s,t));else if(a.map){var d=a.decode(s,t);l[a.name].set(d[0],d[1])}else if(l[a.name]=a.decode(s,t),a.oneof){var u=l[a.oneof.name];null!==u&&u!==a.name&&(l[u]=null),l[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(;_(o,t););break;default:throw Error("Illegal wire type for unknown field "+o+" in "+this.toString(!0)+"#decode: "+s)}}for(var p=0,f=this._fields.length;p<f;++p)if(null===l[(a=this._fields[p]).name])if("proto3"===this.syntax)l[a.name]=a.defaultValue;else{if(a.required){var g=Error("Missing at least one required field for "+this.toString(!0)+": "+a.name);throw g.decoded=l,g}e.populateDefaults&&null!==a.defaultValue&&(l[a.name]=a.defaultValue)}return l},t.Message=d;var h=function(t,r,n,s,o,a,c,l,u,_){i.call(this,t,r,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=c,this.options=l||{},this.defaultValue=null,this.oneof=u||null,this.syntax=_||"proto2",this.originalName=this.name,this.element=null,this.keyElement=null,!this.builder.options.convertFieldsToCamelCase||this instanceof d.ExtensionField||(this.name=e.Util.toCamelCase(this.name))},p=h.prototype=Object.create(i.prototype);p.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)},p.verifyValue=function(t,r){r=r||!1;var i,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&&!r){Array.isArray(t)||(t=[t]);var o=[];for(i=0;i<t.length;i++)o.push(this.element.verifyValue(t[i]));return o}return this.map&&!r?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))},p.hasWirePresence=function(t,r){if("proto3"!==this.syntax)return null!==t;if(this.oneof&&r[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}},p.encode=function(t,i,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 i;try{var s;if(this.repeated)if(this.options.packed&&e.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0){i.writeVarint32(this.id<<3|e.WIRE_TYPES.LDELIM),i.ensureCapacity(i.offset+=1);var o=i.offset;for(s=0;s<t.length;s++)this.element.encodeValue(this.id,t[s],i);var a=i.offset-o,c=r.calculateVarint32(a);if(c>1){var l=i.slice(o,i.offset);o+=c-1,i.offset=o,i.append(l)}i.writeVarint32(a,o-c)}else for(s=0;s<t.length;s++)i.writeVarint32(this.id<<3|this.type.wireType),this.element.encodeValue(this.id,t[s],i);else this.map?t.forEach(function(t,n,s){var o=r.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,n)+r.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,t);i.writeVarint32(this.id<<3|e.WIRE_TYPES.LDELIM),i.writeVarint32(o),i.writeVarint32(8|this.keyType.wireType),this.keyElement.encodeValue(1,n,i),i.writeVarint32(16|this.type.wireType),this.element.encodeValue(2,t,i)},this):this.hasWirePresence(t,n)&&(i.writeVarint32(this.id<<3|this.type.wireType),this.element.encodeValue(this.id,t,i))}catch(e){throw Error("Illegal value for "+this.toString(!0)+": "+t+" ("+e+")")}return i},p.calculate=function(t,i){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+=r.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+=r.calculateVarint32(o),n+=o}else for(s=0;s<t.length;s++)n+=r.calculateVarint32(this.id<<3|this.type.wireType),n+=this.element.calculateLength(this.id,t[s]);else this.map?t.forEach(function(t,i,s){var o=r.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,i)+r.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,t);n+=r.calculateVarint32(this.id<<3|e.WIRE_TYPES.LDELIM),n+=r.calculateVarint32(o),n+=o},this):this.hasWirePresence(t,i)&&(n+=r.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},p.decode=function(t,r,i){var n,s;if(!(!this.map&&t==this.type.wireType||!i&&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&&!i){s=r.readVarint32(),s=r.offset+s;for(var o=[];r.offset<s;)o.push(this.decode(this.type.wireType,r,!0));return o}if(this.map){var c=a.defaultFieldValue(this.keyType);if(n=a.defaultFieldValue(this.type),s=r.readVarint32(),r.remaining()<s)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+s+" required but got only "+r.remaining());var l=r.clone();for(l.limit=l.offset+s,r.offset+=s;l.remaining()>0;){var d=l.readVarint32();t=7&d;var u=d>>>3;if(1===u)c=this.keyElement.decode(l,t,u);else{if(2!==u)throw Error("Unexpected tag in map field key/value submessage");n=this.element.decode(l,t,u)}}return[c,n]}return this.element.decode(r,t,this.id)},t.Message.Field=h;var f=function(e,t,r,i,n,s,o){h.call(this,e,t,r,null,i,n,s,o),this.extension};f.prototype=Object.create(h.prototype),t.Message.ExtensionField=f;t.Message.OneOf=function(e,t,r){i.call(this,e,t,r),this.fields=[]};var g=function(e,t,r,i,n){s.call(this,e,t,r,i,n),this.className="Enum",this.object=null};g.getName=function(e,t){for(var r,i=Object.keys(e),n=0;n<i.length;++n)if(e[r=i[n]]===t)return r;return null},(g.prototype=Object.create(s.prototype)).build=function(t){if(this.object&&!t)return this.object;for(var r=new e.Builder.Enum,i=this.getChildren(g.Value),n=0,s=i.length;n<s;++n)r[i[n].name]=i[n].id;return Object.defineProperty&&Object.defineProperty(r,"$options",{value:this.buildOpt(),enumerable:!1}),this.object=r},t.Enum=g;var m=function(e,t,r,n){i.call(this,e,t,r),this.className="Enum.Value",this.id=n};m.prototype=Object.create(i.prototype),t.Enum.Value=m;var R=function(e,t,r,n){i.call(this,e,t,r),this.field=n};R.prototype=Object.create(i.prototype),t.Extension=R;var E=function(e,t,r,i){s.call(this,e,t,r,i),this.className="Service",this.clazz=null};(E.prototype=Object.create(s.prototype)).build=function(t){return this.clazz&&!t?this.clazz:this.clazz=function(e,t){for(var i=function(t){e.Builder.Service.call(this),this.rpcImpl=t||function(e,t,r){setTimeout(r.bind(this,Error("Not implemented, see: https://github.com/dcodeIO/ProtoBuf.js/wiki/Services")),0)}},n=i.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(i,n){try{try{i=e.resolvedRequestType.clazz.decode(r.wrap(i))}catch(e){if(!(e instanceof TypeError))throw e}if(null===i||"object"!=typeof i)throw Error("Illegal arguments");i instanceof e.resolvedRequestType.clazz||(i=new e.resolvedRequestType.clazz(i)),this.rpcImpl(e.fqn(),i,function(r,i){if(r)n(r);else{null===i&&(i="");try{i=e.resolvedResponseType.clazz.decode(i)}catch(e){}i&&i instanceof e.resolvedResponseType.clazz?n(null,i):n(Error("Illegal response type received in service method "+t.name+"#"+e.name))}})}catch(e){setTimeout(n.bind(this,e),0)}},i[e.name]=function(t,r,n){new i(t)[e.name](r,n)},Object.defineProperty&&(Object.defineProperty(i[e.name],"$options",{value:e.buildOpt()}),Object.defineProperty(n[e.name],"$options",{value:i[e.name].$options}))})(s[o]);return Object.defineProperty&&(Object.defineProperty(i,"$options",{value:t.buildOpt()}),Object.defineProperty(n,"$options",{value:i.$options}),Object.defineProperty(i,"$type",{value:t}),Object.defineProperty(n,"$type",{value:t})),i}(e,this)},t.Service=E;var T=function(e,t,r,n){i.call(this,e,t,r),this.className="Service.Method",this.options=n||{}};(T.prototype=Object.create(i.prototype)).buildOpt=o.buildOpt,t.Service.Method=T;var I=function(e,t,r,i,n,s,o,a){T.call(this,e,t,r,a),this.className="Service.RPCMethod",this.requestName=i,this.responseName=n,this.requestStream=s,this.responseStream=o,this.resolvedRequestType=null,this.resolvedResponseType=null};return I.prototype=Object.create(T.prototype),t.Service.RPCMethod=I,t}(t),t.Builder=function(e,t,r){var i=function(e){this.ns=new r.Namespace(this,null,""),this.ptr=this.ns,this.resolved=!1,this.result=null,this.files={},this.importRoot=null,this.options=e||{}},n=i.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 i.isMessage=function(e){return"string"==typeof e.name&&(void 0===e.values&&void 0===e.rpc)},i.isMessageField=function(e){return"string"==typeof e.rule&&"string"==typeof e.name&&"string"==typeof e.type&&void 0!==e.id},i.isEnum=function(e){return"string"==typeof e.name&&!(void 0===e.values||!Array.isArray(e.values)||0===e.values.length)},i.isService=function(e){return!("string"!=typeof e.name||"object"!=typeof e.rpc||!e.rpc)},i.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 r.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(i.isMessage(s)){var o=new r.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 r.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 r.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 c=[];if(s.enums&&s.enums.forEach(function(e){c.push(e)}),s.messages&&s.messages.forEach(function(e){c.push(e)}),s.services&&s.services.forEach(function(e){c.push(e)}),s.extensions&&("number"==typeof s.extensions[0]?o.extensions=[s.extensions]:o.extensions=s.extensions),this.ptr.addChild(o),c.length>0){n.push(t),t=c,c=null,this.ptr=o,o=null;continue}c=null}else if(i.isEnum(s))o=new r.Enum(this,this.ptr,s.name,s.options,s.syntax),s.values.forEach(function(e){o.addChild(new r.Enum.Value(this,o,e.name,e.id))},this),this.ptr.addChild(o);else if(i.isService(s))o=new r.Service(this,this.ptr,s.name,s.options),Object.keys(s.rpc).forEach(function(e){var t=s.rpc[e];o.addChild(new r.Service.RPCMethod(this,o,e,t.request,t.response,!!t.request_stream,!!t.response_stream,t.options))},this),this.ptr.addChild(o);else{if(!i.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 i=!1;if(o.extensions.forEach(function(e){t.id>=e[0]&&t.id<=e[1]&&(i=!0)}),!i)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 r.Message.ExtensionField(this,o,t.rule,t.type,this.ptr.fqn()+"."+n,t.id,t.options),a=new r.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,r){var i="/";if("string"==typeof r){if(e.Util.IS_NODE&&(r=require("path").resolve(r)),!0===this.files[r])return this.reset();this.files[r]=!0}else if("object"==typeof r){var n,o=r.root;if(e.Util.IS_NODE&&(o=require("path").resolve(o)),(o.indexOf("\\")>=0||r.file.indexOf("\\")>=0)&&(i="\\"),n=e.Util.IS_NODE?require("path").join(o,r.file):o+i+r.file,!0===this.files[n])return this.reset();this.files[n]=!0}if(t.imports&&t.imports.length>0){var a,c=!1;"object"==typeof r?(this.importRoot=r.root,c=!0,a=this.importRoot,r=r.file,(a.indexOf("\\")>=0||r.indexOf("\\")>=0)&&(i="\\")):"string"==typeof r?this.importRoot?a=this.importRoot:r.indexOf("/")>=0?""===(a=r.replace(/\/[^\/]*$/,""))&&(a="/"):r.indexOf("\\")>=0?(a=r.replace(/\\[^\\]*$/,""),i="\\"):a=".":a=null;for(var l=0;l<t.imports.length;l++)if("string"==typeof t.imports[l]){if(!a)throw Error("cannot determine import root");var d=t.imports[l];if("google/protobuf/descriptor.proto"===d)continue;if(d=e.Util.IS_NODE?require("path").join(a,d):a+i+d,!0===this.files[d])continue;/\.proto$/i.test(d)&&!e.DotProto&&(d=d.replace(/\.proto$/,".json"));var u=e.Util.fetch(d);if(null===u)throw Error("failed to import '"+d+"' in '"+r+"': file not found");/\.json$/i.test(d)?this.import(JSON.parse(u+""),d):this.import(e.DotProto.Parser.parse(u),d)}else r?/\.(\w+)$/.test(r)?this.import(t.imports[l],r.replace(/^(.+)\.(\w+)$/,function(e,t,r){return t+"_import"+l+"."+r})):this.import(t.imports[l],r+"_import"+l):this.import(t.imports[l]);c&&(this.importRoot=null)}t.package&&this.define(t.package),t.syntax&&s(t);var _=this.ptr;return t.options&&Object.keys(t.options).forEach(function(e){_.options[e]=t.options[e]}),t.messages&&(this.create(t.messages),this.ptr=_),t.enums&&(this.create(t.enums),this.ptr=_),t.services&&(this.create(t.services),this.ptr=_),t.extends&&this.create(t.extends),this.reset()},n.resolveAll=function(){var i;if(null==this.ptr||"object"==typeof this.ptr.type)return this;if(this.ptr instanceof r.Namespace)this.ptr.children.forEach(function(e){this.ptr=e,this.resolveAll()},this);else if(this.ptr instanceof r.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(!(i=(this.ptr instanceof r.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=i,i instanceof r.Enum){if(this.ptr.type=e.TYPES.enum,"proto3"===this.ptr.syntax&&"proto3"!==i.syntax)throw Error("proto3 message cannot reference proto2 enum")}else{if(!(i instanceof r.Message))throw Error("illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);this.ptr.type=i.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(!((i=this.ptr.parent.resolve(this.ptr.requestName,!0))&&i instanceof e.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.requestName);if(this.ptr.resolvedRequestType=i,!((i=this.ptr.parent.resolve(this.ptr.responseName,!0))&&i instanceof e.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.responseName);this.ptr.resolvedResponseType=i}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,r=this.result,i=0;i<t.length;i++){if(!r[t[i]]){r=null;break}r=r[t[i]]}return r},n.lookup=function(e,t){return e?this.ns.resolve(e,t):this.ns},n.toString=function(){return"Builder"},i.Message=function(){},i.Enum=function(){},i.Service=function(){},i}(t,t.Lang,t.Reflect),t.Map=function(e,t){var r=function(e,r){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}}),r)for(var i=Object.keys(r),n=0;n<i.length;n++){var s=this.keyElem.valueFromString(i[n]),o=this.valueElem.verifyValue(r[i[n]]);this.map[this.keyElem.valueToString(s)]={key:s,value:o}}},i=r.prototype;function n(e){var t=0;return{next:function(){return t<e.length?{done:!1,value:e[t++]}:{done:!0}}}}return i.clear=function(){this.map={}},i.delete=function(e){var t=this.keyElem.valueToString(this.keyElem.verifyValue(e)),r=t in this.map;return delete this.map[t],r},i.entries=function(){for(var e,t=[],r=Object.keys(this.map),i=0;i<r.length;i++)t.push([(e=this.map[r[i]]).key,e.value]);return n(t)},i.keys=function(){for(var e=[],t=Object.keys(this.map),r=0;r<t.length;r++)e.push(this.map[t[r]].key);return n(e)},i.values=function(){for(var e=[],t=Object.keys(this.map),r=0;r<t.length;r++)e.push(this.map[t[r]].value);return n(e)},i.forEach=function(e,t){for(var r,i=Object.keys(this.map),n=0;n<i.length;n++)e.call(t,(r=this.map[i[n]]).value,r.key,this)},i.set=function(e,t){var r=this.keyElem.verifyValue(e),i=this.valueElem.verifyValue(t);return this.map[this.keyElem.valueToString(r)]={key:r,value:i},this},i.get=function(e){var t=this.keyElem.valueToString(this.keyElem.verifyValue(e));if(t in this.map)return this.map[t].value},i.has=function(e){return this.keyElem.valueToString(this.keyElem.verifyValue(e))in this.map},r}(0,t.Reflect),t.loadProto=function(e,r,i){return("string"==typeof r||r&&"string"==typeof r.file&&"string"==typeof r.root)&&(i=r,r=void 0),t.loadJson(t.DotProto.Parser.parse(e),r,i)},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,r,i){return("string"==typeof r||r&&"string"==typeof r.file&&"string"==typeof r.root)&&(i=r,r=null),r&&"object"==typeof r||(r=t.newBuilder()),"string"==typeof e&&(e=JSON.parse(e)),r.import(e,i),r.resolveAll(),r},t}();var Rc,Ec;class Tc{constructor(e){Rc.add(this),Object.defineProperty(this,"pbModules",{enumerable:!0,configurable:!0,writable:!0,value:void 0});const t=mc.loadProto(e);this.pbModules=t.build("Modules").probuf}encode(e,t){return this.pbModules[e].encode(t).toArrayBuffer()}decode(e,t){try{const r=this.pbModules[e].decode(t);return O(this,Rc,"m",Ec).call(this,r)}catch(t){const r=`name: ${e}, stack: ${t.stack}`;throw null===console||void 0===console||console.error("pb decode error!",r),t}}}Rc=new WeakSet,Ec=function e(t){if(t instanceof Array)return t.map(t=>O(this,Rc,"m",e).call(this,t));if(r=t,"[object Object]"!==Object.prototype.toString.call(r))return t;var r;if(t instanceof mc.ByteBuffer)return t.toArrayBuffer();if(t instanceof mc.Long)return t.toNumber();const i={};return Object.keys(t).forEach(r=>{i[r]=O(this,Rc,"m",e).call(this,t[r])}),i};var Ic,Sc,vc,Oc,bc,Cc,yc;!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"}(Ic||(Ic={})),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"}(Sc||(Sc={})),function(e){e[e.GROUP_SUCCESS=0]="GROUP_SUCCESS",e[e.GROUP_FAILURE=1]="GROUP_FAILURE"}(vc||(vc={})),function(e){e[e.IsSilent=1]="IsSilent",e[e.IsTop=2]="IsTop",e[e.Tags=3]="Tags",e[e.AutoTrans=4]="AutoTrans"}(Oc||(Oc={})),function(e){e[e.KICK=0]="KICK",e[e.REFUSE=1]="REFUSE",e[e.COEXIST=2]="COEXIST"}(bc||(bc={})),function(e){e[e.ROOM=1]="ROOM",e[e.PERSON=2]="PERSON"}(Cc||(Cc={})),function(e){e[e.AnchorToViewer=1]="AnchorToViewer",e[e.ViewerToAnchor=2]="ViewerToAnchor"}(yc||(yc={})),new Tc("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 Lc{constructor(e){Object.defineProperty(this,"pbCodec",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.pbCodec=new Tc(e)}encode(e,t,r){return r?t:this.pbCodec.encode(e,t)}decode(e,t){return this.pbCodec.decode(e,t)}}const Ac="rtcRJoin_data",Nc="rtcRExit",Pc="rtcRInfo",wc="rtcUData",Dc="rtcUDel",Uc="rtcSetData",kc="userSetData",Mc="rtcQryData",xc="rtcDelData",Bc="rtcToken",Vc="rtcUserState",Fc="rtcUList",jc="viewerJoinR",Gc="viewerExitR",Jc="rtcPullKv",Hc="rtcIdentityChange",Kc="rtcInvite",qc="rtcCancelInvite",$c="rtcInviteAnswer",Yc="rtcEndInvite",Wc="rtcQueryJoined",zc="rtcPullRoomStatus",Qc="reportsdk",Zc="rtcPing";var Xc;!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"}(Xc||(Xc={})),Xc.RtcInput,Xc.RtcOutput,Xc.RtcUserListOutput,Xc.SetUserStatusInput,Xc.RtcSetDataInput,Xc.RtcUserSetDataInput,Xc.RtcDataInput,Xc.RtcSetOutDataInput,Xc.MCFollowInput,Xc.RtcTokenOutput,Xc.RtcQryOutput,Xc.RtcQryUserOutDataInput,Xc.RtcUserOutDataOutput,Xc.RtcQueryListInput,Xc.RtcRoomInfoOutput,Xc.RtcValueInfo,Xc.RtcKeyDeleteInput,Xc.RtcNotifyMsg,Xc.RtcPullKV,Xc.RtcKVOutput,Xc.RtcQueryUserJoinedInput,Xc.RtcQueryUserJoinedOutput,Xc.RtcInviteInput,Xc.RtcCancelInviteInput,Xc.RtcInviteAnswerInput,Xc.RtcEndInviteInput,Xc.RtcRoomStatusInput,Xc.RtcRoomStatusOutput,Xc.RtcReportSDKInput,Xc.RtcPBPolaris,Xc.RtcPBR1Info,Xc.RtcPBR2Info,Xc.RtcPBR3Info,Xc.RtcPBR4Info,Xc.RtcPBStatusInfo,Xc.RtcPBStreamInfo,Xc.AsrTextMsg,Xc.AsrResTextMsg;const el=`\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 ${Xc.SetUserStatusInput}\n {\n optional int32 status=1;\n }\n message ${Xc.MCFollowInput}\n {\n required string state = 1;\n }\n message ${Xc.RtcQueryListInput}{\n optional int32 order=1;\n }\n message ${Xc.RtcKeyDeleteInput}{\n repeated string key=1;\n }\n message ${Xc.RtcValueInfo}{\n required string key=1;\n required string value=2;\n }\n message RtcUserInfo{\n required string userId=1;\n repeated ${Xc.RtcValueInfo} userData=2; //用户资源信息\n }\n message ${Xc.RtcRoomStatusInput}{ // rtc 和 living room 拉房间资源状态使用的参数\n required int64 version =1; //当前客户端最大的房间状态的version\n }\n message ${Xc.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 ${Xc.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 ${Xc.RtcValueInfo} roomData = 2;\n optional int32 userCount = 3;\n repeated RtcUserInfo list=4;\n }\n message ${Xc.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 ${Xc.RtcValueInfo} innerDatas = 7; //用户内部inner数据,角色或者连麦信息等\n repeated ${Xc.RtcValueInfo} outerDatas = 8; //用户内部outer数据,自定义数据结构RtcInput。\n optional bool supportNtf = 9; //是否支持房间状态的变更通过通知拉取的方式获取\n }\n message ${Xc.RtcQryOutput}{\n repeated ${Xc.RtcValueInfo} outInfo=1;\n }\n message ${Xc.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 ${Xc.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 ${Xc.RtcUserSetDataInput} {\n repeated ${Xc.RtcValueInfo} valueInfo = 1;\n required string objectName = 2;\n repeated ${Xc.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 ${Xc.RtcTokenOutput}{\n required string rtcToken=1;\n }\n message ${Xc.RtcSetOutDataInput}{\n required targetType target=1;\n repeated ${Xc.RtcValueInfo} valueInfo=2;\n optional string objectName=3;\n optional string content=4;\n }\n message ${Xc.RtcQryUserOutDataInput}{\n repeated string userId = 1;\n }\n message ${Xc.RtcUserOutDataOutput}{\n repeated RtcUserInfo user = 1;\n }\n message ${Xc.RtcNotifyMsg} \n {\n required int32 type= 1; //(通知类型 1:rtc房间状态KV变更通知)\n optional int64 time= 2; //消息产生时间\n optional string roomId=3; //主播房间id\n }\n message ${Xc.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 ${Xc.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 ${Xc.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 ${Xc.RtcQueryUserJoinedOutput}\n {\n repeated RtcJoinedInfo info = 1;\n }\n message ${Xc.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 ${Xc.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 ${Xc.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 ${Xc.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 ${Xc.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 ${Xc.RtcReportSDKInput} {\n required string sdkInfo=1; // 用户集成的 sdk 信息,json 格式 {"web-rtc": "4.0.3.7"}\n }\n // ---- 北极星数据上报 -------\n message ${Xc.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 ${Xc.RtcPBR1Info} r1Info = 10;\n optional ${Xc.RtcPBR2Info} r2Info = 11;\n optional ${Xc.RtcPBR3Info} r3Info = 12;\n optional ${Xc.RtcPBR4Info} r4Info = 13;\n }\n message ${Xc.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 ${Xc.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 ${Xc.RtcPBR3Info} {\n required ${Xc.RtcPBStatusInfo} info = 1;\n }\n message ${Xc.RtcPBR4Info} {\n required ${Xc.RtcPBStatusInfo} info = 1;\n }\n message ${Xc.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 ${Xc.RtcPBStreamInfo} streams = 13;\n }\n message ${Xc.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 ${Xc.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 ${Xc.AsrResTextMsg} {\n optional int32 type = 1; //1 为语音识别,后续会扩展其它类型\n required string uid = 2; //对应转写的用户Id\n repeated ${Xc.AsrTextMsg} asr = 3; //识别出的结果列表\n }\n}\n`,tl=(e,t,r,i,n,s,o)=>{const a=n?Object.keys(n).map(t=>e.encode(Xc.RtcValueInfo,{key:t,value:n[t]},!0)):void 0,c=s?Object.keys(s).map(t=>e.encode(Xc.RtcValueInfo,{key:t,value:s[t]},!0)):void 0;return e.encode(Xc.RtcInput,{roomType:t,broadcastType:r,joinType:i,innerDatas:a,outerDatas:c,supportNtf:o})},rl=(e,t)=>{const r=e.decode(Xc.RtcUserListOutput,t),{users:i,token:n,sessionId:s,roomInfo:o,entries:a,offlineKickTime:c=60,codeFormat:l,roomCreateTime:d,userJoinTime:u,version:_}=r,h={};return I(i,e=>{const{userId:t,userData:r}=e,i={};I(r,e=>{const{key:t,value:r}=e;i[t]=r}),h[t]=i}),{users:h,token:n,sessionId:s,roomInfo:o,kvEntries:a,offlineKickTime:c,codeFormat:l,roomCreateTime:Sr(d),userJoinTime:Sr(u),version:_}};var il,nl;!function(e){e[e.SUBTITLE=1]="SUBTITLE",e[e.TRANSLATION=2]="TRANSLATION"}(il||(il={}));class sl{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 Lc(el)})}get logger(){return this.context.logger}joinRTCRoom(e,t,r,i,n,s,o){return v(this,void 0,void 0,function*(){const a=tl(this.codec,t,r,i,n,s,o),{code:c,buffer:l}=yield this.context.rtcSignaling(e,Ac,!0,a);let d;if(c===ie&&l){d=rl(this.codec,l);const{users:e,token:t,sessionId:r,roomInfo:i,kvEntries:n,offlineKickTime:s,roomCreateTime:o,userJoinTime:a,version:u}=d;return this.roomCreateTime=o,this.userJoinTime=a,{code:c,data:{users:e,token:t,sessionId:r,roomInfo:i,kvEntries:n,offlineKickTime:s,version:u}}}return{code:c,data:d}})}quitRTCRoom(e){return v(this,void 0,void 0,function*(){const t=this.codec.encode(Xc.SetUserStatusInput,{status:0}),{code:r}=yield this.context.rtcSignaling(e,Nc,!0,t);return r})}getRTCRoomInfo(e){return v(this,void 0,void 0,function*(){const t=this.codec.encode(Xc.RtcQueryListInput,{order:2}),{code:r,buffer:i}=yield this.context.rtcSignaling(e,Pc,!0,t);let n;return r===ie&&i&&(n=this.codec.decode(Xc.RtcRoomInfoOutput,i)),{code:r,data:n}})}getRTCUserInfoList(e){return v(this,void 0,void 0,function*(){const t=this.codec.encode(Xc.RtcQueryListInput,{order:2}),{code:r,buffer:i}=yield this.context.rtcSignaling(e,wc,!0,t);let n;if(r===ie&&i){n={users:rl(this.codec,i).users}}return{code:r,data:n}})}getRTCUserInfo(e){throw new Error("Method not implemented.")}removeRTCUserInfo(e,t){return v(this,void 0,void 0,function*(){const r=this.codec.encode(Xc.RtcKeyDeleteInput,{key:t}),{code:i}=yield this.context.rtcSignaling(e,Dc,!1,r);return i})}setRTCData(e,t,r,i,n,s){return v(this,void 0,void 0,function*(){const o=this.codec.encode(Xc.RtcSetDataInput,{interior:i,target:n,key:t,value:r,objectName:null==s?void 0:s.name,content:null==s?void 0:s.content}),{code:a}=yield this.context.rtcSignaling(e,Uc,!1,o);return a})}setRTCTotalRes(e,t,r,i,n,s){return v(this,void 0,void 0,function*(){const o={objectName:i,content:[],valueInfo:[this.codec.encode(Xc.RtcValueInfo,{key:"uris",value:r},!0)]};t.forEach(e=>{const t=this.codec.encode(Xc.RtcValueInfo,{key:e.name,value:e.content},!0);o.content.push(t)}),n&&o.valueInfo.push(this.codec.encode(Xc.RtcValueInfo,{key:"mcu_uris",value:n},!0)),s&&o.valueInfo.push(this.codec.encode(Xc.RtcValueInfo,{key:"cdn_uris",value:s},!0));const a=this.codec.encode(Xc.RtcUserSetDataInput,o),{code:c}=yield this.context.rtcSignaling(e,kc,!0,a);return c})}setRTCCDNUris(e,t,r){return v(this,void 0,void 0,function*(){const i=this.codec.encode(Xc.RtcUserSetDataInput,{objectName:t,valueInfo:this.codec.encode(Xc.RtcValueInfo,{key:"cdn_uris",value:r},!0)}),{code:n}=yield this.context.rtcSignaling(e,kc,!0,i);return n})}getRTCData(e,t,r,i){return v(this,void 0,void 0,function*(){const n=this.codec.encode(Xc.RtcDataInput,{interior:r,target:i,key:t}),{code:s,buffer:o}=yield this.context.rtcSignaling(e,Mc,!0,n);if(s!==ie||!o)return{code:s};const{outInfo:a}=this.codec.decode(Xc.RtcQryOutput,o),c={};return a.forEach(e=>{c[e.key]=e.value}),{code:s,data:c}})}removeRTCData(e,t,r,i,n){return v(this,void 0,void 0,function*(){const s=this.codec.encode(Xc.RtcDataInput,{interior:r,target:i,key:t,objectName:(null==n?void 0:n.name)||"",content:(null==n?void 0:n.content)||""}),{code:o}=yield this.context.rtcSignaling(e,xc,!1,s);return o})}setRTCOutData(e,t,r,i){return v(this,void 0,void 0,function*(){throw new Error("JSEngine's method not implemented.")})}getRTCOutData(e,t){return v(this,void 0,void 0,function*(){throw new Error("JSEngine's method not implemented.")})}getRTCToken(e,t,r){return v(this,void 0,void 0,function*(){const i=tl(this.codec,t,r),{code:n,buffer:s}=yield this.context.rtcSignaling(e,Bc,!0,i);if(n!==ie||!s)return{code:n};const{rtcToken:o}=this.codec.decode(Xc.RtcTokenOutput,s);return{code:n,data:{rtcToken:o}}})}setRTCState(e,t){return v(this,void 0,void 0,function*(){const r=this.codec.encode(Xc.MCFollowInput,{state:t}),{code:i}=yield this.context.rtcSignaling(e,Vc,!0,r);return i})}setRTCStateByHttp(e,t,r,i){return v(this,void 0,void 0,function*(){var n;const s=((e,t,r)=>{const{type:i,appKey:n,sessionId:s,roomId:o,roomCreateTime:a,userId:c,userRole:l,joinTime:d,signalDataCenter:u,r1Info:_,r2Info:h,r3Info:p,r4Info:f}=t,g={type:i,appKey:n,sessionId:s,roomId:o,roomCreateTime:a,userId:c,userRole:l,joinTime:d,signalDataCenter:u};if(r===Na.R1&&_){const t=e.encode(Xc.RtcPBR1Info,_,!0);return e.encode(Xc.RtcPBPolaris,Object.assign(Object.assign({},g),{r1Info:t}))}if(r===Na.R2&&h){const t=e.encode(Xc.RtcPBR2Info,h,!0);return e.encode(Xc.RtcPBPolaris,Object.assign(Object.assign({},g),{r2Info:t}))}if(r===Na.R3&&p){const{info:t}=p,{streams:r}=t;let i=Array.isArray(r)&&r.map(t=>t&&e.encode(Xc.RtcPBStreamInfo,t,!0)),n=e.encode(Xc.RtcPBStatusInfo,Object.assign(Object.assign({},t),{streams:i}),!0),s=e.encode(Xc.RtcPBR3Info,{info:n},!0);return e.encode(Xc.RtcPBPolaris,Object.assign(Object.assign({},g),{r3Info:s}))}if(r===Na.R4&&f){const{info:t}=f,{streams:r}=t;let i=Array.isArray(r)&&r.map(t=>t&&e.encode(Xc.RtcPBStreamInfo,t,!0)),n=e.encode(Xc.RtcPBStatusInfo,Object.assign(Object.assign({},t),{streams:i}),!0),s=e.encode(Xc.RtcPBR4Info,{info:n},!0);return e.encode(Xc.RtcPBPolaris,Object.assign(Object.assign({},g),{r4Info:s}))}return{}})(this.codec,r,i);let o=e;/^https:\/\//.test(e)||(o=`https://${e}`);try{const e=yield t.httpReq({url:`${o}/rtc/logserver/polaris`,body:s,method:R.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 Aa.REPORT_FAIL}})}getRTCUserList(e){return v(this,void 0,void 0,function*(){const t=this.codec.encode(Xc.RtcQueryListInput,{order:2}),{code:r,buffer:i}=yield this.context.rtcSignaling(e,Fc,!0,t);if(r!==ie||!i)return{code:r};return{code:r,data:rl(this.codec,i)}})}joinLivingRoomAsAudience(e,t,r){return v(this,void 0,void 0,function*(){const i=tl(this.codec,t,r),{code:n,buffer:s}=yield this.context.rtcSignaling(e,jc,!0,i);if(n!==ie||!s)return{code:n};const{rtcToken:o,entries:a,roomCreateTime:c,userJoinTime:l}=this.codec.decode(Xc.RtcViewerJoinedOutput,s);return this.roomCreateTime=Sr(c),this.userJoinTime=Sr(l),{code:n,data:{token:o,kvEntries:a}}})}quitLivingRoomAsAudience(e){return v(this,void 0,void 0,function*(){const t=this.codec.encode(Xc.SetUserStatusInput,{status:0}),{code:r}=yield this.context.rtcSignaling(e,Gc,!0,t);return r})}rtcIdentityChange(e,t,r){return v(this,void 0,void 0,function*(){const i=this.codec.encode(Xc.RtcInput,{roomType:Ro.LIVE,broadcastType:r,identityChangeType:t,needSysChatroom:!1}),{code:n,buffer:s}=yield this.context.rtcSignaling(e,Hc,!0,i);if(n!==ie||!s)return{code:n};return{code:n,data:rl(this.codec,s)}})}requestRoomPK(e){return v(this,void 0,void 0,function*(){const{invitedRoomId:t,invitedUserId:r,inviteSessionId:i,inviteTimeout:n,inviteInfo:s,roomId:o}=e,a=this.codec.encode(Xc.RtcInviteInput,{invitedRoomId:t,invitedUserId:r,inviteSessionId:i,timeoutTime:n,inviteInfo:s}),{code:c}=yield this.context.rtcSignaling(o,Kc,!0,a);return c})}cancelRoomPK(e){return v(this,void 0,void 0,function*(){const{invitedRoomId:t,invitedUserId:r,inviteSessionId:i,inviteInfo:n,roomId:s}=e,o=this.codec.encode(Xc.RtcCancelInviteInput,{invitedRoomId:t,invitedUserId:r,inviteSessionId:i,inviteInfo:n}),{code:a}=yield this.context.rtcSignaling(s,qc,!0,o);return a})}responseRoomPK(e){return v(this,void 0,void 0,function*(){const{inviteUserId:t,inviteRoomId:r,inviteSessionId:i,content:n,key:s,value:o,agree:a,roomId:c}=e,l=this.codec.encode(Xc.RtcInviteAnswerInput,{inviteUserId:t,inviteRoomId:r,inviteSessionId:i,content:n,key:s,value:o,answerCode:a?1:0}),{code:d}=yield this.context.rtcSignaling(c,$c,!0,l);return d})}endRoomPK(e){return v(this,void 0,void 0,function*(){const{endRoomId:t,sessionId:r,content:i,keys:n,roomId:s}=e,o=this.codec.encode(Xc.RtcEndInviteInput,{inviteRoomId:t,inviteSessionId:r,inviteContent:i,inviteRoomKeys:n}),{code:a}=yield this.context.rtcSignaling(s,Yc,!0,o);return a})}getRTCJoinedUserInfo(e){return v(this,void 0,void 0,function*(){const t=this.codec.encode(Xc.RtcQueryUserJoinedInput,{userId:e}),{code:r,buffer:i}=yield this.context.rtcSignaling("",Wc,!0,t);if(r!==ie||!i)return{code:r};return{code:r,data:(this.codec.decode(Xc.RtcQueryUserJoinedOutput,i).info||[]).map(e=>({deviceId:e.deviceId,roomId:e.roomId,joinTime:Sr(e.joinTime)}))}})}pullRTCRoomEntry(e){return v(this,void 0,void 0,function*(){const t=this.codec.encode(Xc.RtcPullKV,{timestamp:0,roomId:e}),{code:r,buffer:i}=yield this.context.rtcSignaling(e,Jc,!0,t);if(r!==ie)return{code:r};const n=this.codec.decode(Xc.RtcKVOutput,i);let{entries:s,syncTime:o}=n;return s=(s||[]).map(e=>Object.assign(Object.assign({},e),{timestamp:Sr(e.timestamp)})),{code:r,data:{kvEntries:s,syncTime:Sr(o)}}})}pullRTCRoomStatus(e,t){return v(this,void 0,void 0,function*(){const r=this.codec.encode(Xc.RtcRoomStatusInput,{version:t}),{code:i,buffer:n}=yield this.context.rtcSignaling(e,zc,!0,r);if(i!==ie)return{code:i};return{code:i,data:this.codec.decode(Xc.RtcRoomStatusOutput,n)}})}decodeRtcNotify(e){const{time:t,type:r,roomId:i}=this.codec.decode(Xc.RtcNotifyMsg,e);return{time:Sr(t),type:r,roomId:i}}getCurrentId(){return this.context.getCurrentId()}getNaviInfo(){return this.context.getNaviInfo()}getConnectionStatus(){return this.context.getConnectionStatus()}getAppkey(){return this.context.getAppkey()}webRtcPing(e,t,r){return v(this,void 0,void 0,function*(){const i=this.codec.encode(Xc.RtcInput,{roomType:t,broadcastType:r}),{code:n,buffer:s}=yield this.context.rtcSignaling(e,Zc,!0,i);if(n!==ie)return{code:n};const o=this.codec.decode(Xc.RtcOutput,s);return o.version=Sr(o.version),{code:n,data:o}})}rtcPing(e,t,r){var i,n;return/Electron/.test(navigator.userAgent)?null===(n=(i=this.context).rtcPingResVersion)||void 0===n?void 0:n.call(i,e,t,r):this.webRtcPing(e,t,r)}sendMessage(e,t,r){return this.context.sendMessage(e,t,r)}registerRTCSignalListener(e){this.context.registerRTCSignalListener(e)}registerConnectionStateChangeListener(e){var t,r;null===(r=(t=this.context).registerConnectionStateChangeListener)||void 0===r||r.call(t,e)}registerDisconnectListener(e){var t,r;null===(r=(t=this.context).registerDisconnectListener)||void 0===r||r.call(t,e)}registerDestroyListener(e){var t,r;null===(r=(t=this.context).registerDestroyListener)||void 0===r||r.call(t,e)}registerMessageListener(e){var t,r;null===(r=(t=this.context).registerMessageListener)||void 0===r||r.call(t,e)}getCoreVersion(){return this.context.getCoreVersion()}getPluginContext(){return this.context}reportSDKInfo(e){const t=this.codec.encode(Xc.RtcReportSDKInput,{sdkInfo:JSON.stringify(e)});this.context.rtcSignaling("",Qc,!0,t)}decodeAsrText(e,t){let r;try{r=this.codec.decode(Xc.AsrResTextMsg,e)}catch(r){console.error("decodeAsrText error",{error:r,seiFrameData:e.join(","),seiOriginData:t.join(",")})}const{type:i,uid:n,asr:s}=r||{asr:[]};return s.map(e=>{const{bms:t,t:r,isEnd:s,msgId:o,lang:a}=e,c={userID:n,timeUTC:t,msg:r,msgId:o,isEnd:s};return i===il.SUBTITLE?c:Object.assign(Object.assign({},c),{destLangCode:a})})}}class ol extends gc{constructor(e,t,r){var i,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:r}),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}),To.setSdpSemantics(r.sdpSemantics||"unified-plan",this._logger),this._service=new qs(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=(i=this._context.getPluginContext()).setOnnavidatachange)||void 0===n||n.call(i,this.naviDataChange.bind(this))}static init(e={},t,r){const{logger:i}=t;if(i.warn(ae.L_INDEX_INSTALL_RTC_PLUGIN_O,JSON.stringify({"RCRTC Version":"5.36.1-nctest-alpha.3",Commit:"c96e5775862767fb76abb0c16a37ad4961f58f6a","browserInfo.browser":fr.browser,"browserInfo.supportsUnifiedPlan":fr.supportsUnifiedPlan,"browserInfo.version":fr.version})),f("options",e,_.OBJECT,!0),f("options.mediaServer",e.mediaServer,e=>!(!u(e)||"https:"===location.protocol&&!/^https/.test(e))),f("options.timeout",e.timeout,e=>s(e)&&e>=5e3&&e<=3e4),f("options.pingGap",e.pingGap,e=>s(e)&&e>=3e3&&e<=1e4),e.AAAWorklet){f("options.AAAWorklet",e.AAAWorklet,_.OBJECT,!0);const{scriptUrl:t,wasmUrl:r}=e.AAAWorklet;f("AAAWorklet.scriptUrl",t,_.STRING,!0),f("AAAWorklet.wasmUrl",r,_.STRING,!0),Bt.SCRIPT_URL=t,Bt.WASM_URL=r}return e.encryptor&&(f("options.encrypt",e.encryptor,_.OBJECT,!0),f("options.encrypt.decodeAudio",e.encryptor.decodeAudio,e=>"function"==typeof e,!0),f("options.encrypt.decodeVideo",e.encryptor.decodeVideo,e=>"function"==typeof e,!0),f("options.encrypt.encodeAudio",e.encryptor.encodeAudio,e=>"function"==typeof e,!0),f("options.encrypt.encodeVideo",e.encryptor.encodeVideo,e=>"function"==typeof e,!0),oo.init(e.encryptor,i)),ol._instance||(ol._instance=new ol(new sl(t),r,e)),ol._instance}_handleMessage(e){if(e.conversationType!==X.RTC_ROOM)return!1;const t=this._logger.createTraceId();if(this._crtRoom instanceof oc){this._getJoinedPKRoomList().forEach(r=>{r.__parseInnerMessage(e,t)})}return this._logger.info(ae.L_RTC_CLIENT_MESSAGE_O,JSON.stringify({status:ce.SUCCESSED,message:e}),t),this._crtRoom?(this._crtRoom.__parseInnerMessage(e,t),!0):(this._logger.warn(ae.L_RTC_CLIENT_MESSAGE_O,JSON.stringify({status:ce.FAILED,message:"the crtRoom is empty"}),t),!0)}naviDataChange(e){this._logger.info(ae.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===oe.SUCCESS&&t){const e=t.getJoinedPKRooms()||{};return Object.values(e)}return[]}getPluginContext(){return this._context.getPluginContext()}getCurrentId(){return this._context.getCurrentId()}joinCrossRTCRoom(e,t,r){return v(this,arguments,void 0,function*(e,t,r,i=!1,n=Ro.CROSS_MUTI){return console.warn("joinCrossRTCRoom is deprecated, use joinRTCRoomWithOptions instead"),this.joinRTCRoomWithOptions(e,{joinType:t,userData:r,mode:Ro.CROSS_MUTI})})}joinRTCRoom(e,t,r){return v(this,arguments,void 0,function*(e,t,r,i=!1,n=Ro.RTC){return console.warn("joinRTCRoom is deprecated, use joinRTCRoomWithOptions instead"),this.joinRTCRoomWithOptions(e,{mode:n,joinType:t,userData:r})})}joinRTCRoomWithOptions(e,t){return v(this,void 0,void 0,function*(){const r=this._logger.createTraceId();if(this._logger.info(ae.L_RTC_CLIENT_JOIN_RTC_ROOM_T,JSON.stringify({roomId:e,options:t}),r),this._crtRoom)return this._logger.error(ae.L_RTC_CLIENT_JOIN_RTC_ROOM_R,JSON.stringify({status:ce.FAILED,code:oe.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),r),{code:oe.REPERT_JOIN_ROOM};const i=this._crtRoom=new ac(this._context,this._runtime,e,this._service,this._options,null==t?void 0:t.mode,null==t?void 0:t.encrypt),{code:n}=yield i.__innerInit((null==t?void 0:t.mode)||Ro.RTC,null==t?void 0:t.joinType,void 0,void 0,null==t?void 0:t.userData,r,null==t?void 0:t.srcLanguage,null==t?void 0:t.nickName);return n!==oe.SUCCESS?(this._crtRoom=null,{code:n}):(i.once(Ja,()=>{this._crtRoom=null}),{code:n,room:i,userIds:i.getRemoteUserIds(),tracks:i.getRemoteTracks()})})}joinLivingRoom(e,t,r,i){return v(this,arguments,void 0,function*(e,t,r,i,n=!1){const s=this._logger.createTraceId();if(this._logger.info(ae.L_RTC_CLIENT_JOIN_LIVING_ROOM_T,JSON.stringify({roomId:e,livingType:t,joinType:r,outerUserDatas:i}),s),this._crtRoom)return this._logger.error(ae.L_RTC_CLIENT_JOIN_LIVING_ROOM_R,JSON.stringify({status:ce.FAILED,code:oe.REPERT_JOIN_ROOM,msg:`Join the room repeatedly -> roomId: ${e}`}),s),{code:oe.REPERT_JOIN_ROOM};const o=this._crtRoom=new oc(this._context,this._runtime,e,this._service,this._options,t,!1,!0),{code:a}=yield o.__innerInit(Ro.LIVE,r,t,void 0,i,s);if(a!==oe.SUCCESS)return this._crtRoom=null,{code:a};o.once(Ja,()=>{this._crtRoom=null});const c={code:a,room:o,userIds:o.getRemoteUserIds(),tracks:o.getRemoteTracks()};return o.__getCDNPushMode()===fc.MANUAL&&Object.assign(c,{CDNEnable:o.__getCDNEnable()}),c})}getAudienceClient(e){return this._audience||(this._audience=new dc(this._context,this._runtime,this._options)),this._logger.info(ae.L_RTC_CLIENT_GET_AUDIENCE_CLIENT_O),this._audience}_onIMStatusChange(e,t){if(this._logger.info(ae.L_RTC_CLIENT_IM_CONNECTION_STATE_S,JSON.stringify({status:e,code:t,desc:ee[e]})),e===ee.SUSPENDED&&40001===t&&this._service.clearMSList(),e===ee.DISCONNECTED){if(this._crtRoom){let e=Ca.IM_DISCONNECTED;40002===t?e=Ca.OTHER_CLIENT_IM_CONNECTED:t===ne&&(e=Ca.IM_LOGOUT),this._crtRoom.__kickoff(!0,{users:[{userId:this._context.getCurrentId(),type:e}]})}}else if(e===ee.CONNECTED){if(this._service.isNededDetector()&&this._service.detectorMediaSever(),this._crtRoom instanceof oc){this._getJoinedPKRoomList().forEach(e=>{e.__onReconnected()})}this._crtRoom&&this._crtRoom.__onReconnected()}}_onIMUninit(){var e;this._logger.info(ae.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 v(this,void 0,void 0,function*(){var t;const r=this._logger.createTraceId();return this._logger.info(ae.L_RTC_CLIENT_LEAVE_ROOM_T,JSON.stringify({roomId:e.getRoomId()}),r),this._crtRoom?(yield this._crtRoom.__destroy(!0),this._service.isNededDetector()&&this._service.detectorMediaSever(),this._logger.info(ae.L_RTC_CLIENT_LEAVE_ROOM_R,JSON.stringify({status:ce.SUCCESSED,roomId:null===(t=this._crtRoom)||void 0===t?void 0:t.getRoomId()}),r),this._crtRoom=null,{code:oe.SUCCESS}):(this._logger.warn(ae.L_RTC_CLIENT_LEAVE_ROOM_R,JSON.stringify({status:ce.FAILED,msg:"Room does not exist, without leave"}),r),{code:oe.SUCCESS})})}joinLivingRoomAsAudience(e,t,r){return v(this,void 0,void 0,function*(){const r=this._logger.createTraceId();if(this._logger.info(ae.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_T,JSON.stringify({roomId:e,livingType:t}),r),this._service.isNededDetector()&&this._service.detectorMediaSever(),Er(this._context.getNaviInfo()))return this._logger.error(ae.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ce.FAILED,code:oe.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"}),r),{code:oe.PACKAGE_ENVIRONMENT_ERROR};if(!g("roomId",e,a,!0)||!g("livingType",t,e=>e===Za.AUDIO||e===Za.VIDEO))return this._logger.error(ae.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> roomId or livingType"}),r),{code:oe.PARAMS_ERROR};if(this._crtAudienceLivingRoom)return this._logger.error(ae.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ce.FAILED,code:oe.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),r),{code:oe.REPERT_JOIN_ROOM};if(!this._service.getMsList().length)return this._logger.error(ae.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ce.FAILED,code:oe.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"No audio / video server address available"}),r),{code:oe.NOT_OPEN_VIDEO_AUDIO_SERVER};const{code:i,data:n}=yield this._context.joinLivingRoomAsAudience(e,Ro.LIVE,t);if(i!==ie)return this._logger.error(ae.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ce.FAILED,code:i,msg:"signal error -> audience join room"}),r),{code:oe.SIGNAL_AUDIENCE_JOIN_ROOM_FAILED};const s=Fs(),o=new pc(this._context,this._runtime,this._options,e,n,t,s);return this._crtAudienceLivingRoom=o,this._logger.info(ae.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ce.SUCCESSED,roomData:n}),r),{room:o,code:oe.SUCCESS,userIds:o.getRemoteUserIds(),RTCTracks:o.getRemoteRTCTracks(),MCUTracks:o.getRemoteMCUTracks(),CDNUris:o.getCDNInfo()}})}leaveLivingRoomAsAudience(e){return v(this,void 0,void 0,function*(){const t=this._logger.createTraceId();return this._logger.info(ae.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(ae.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> room"}),t),{code:oe.PARAMS_ERROR}):(yield this._crtAudienceLivingRoom.__destroy(!0),this._crtAudienceLivingRoom=null,this._logger.info(ae.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ce.SUCCESSED}),t),{code:oe.SUCCESS}):(this._logger.warn(ae.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:ce.FAILED,msg:"Room does not exist, without leave"}),t),{code:oe.SUCCESS})})}upgradeToAnchorRoom(e){return v(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(ae.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_T,void 0,t),!g("room",e,()=>e instanceof pc,!0))return this._logger.error(ae.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> room"}),t),{code:oe.PARAMS_ERROR};const r=e.getRoomId();if(this._crtRoom)return this._logger.error(ae.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:ce.FAILED,code:oe.REPERT_JOIN_ROOM,msg:"Join the room repeatedly",roomId:r}),t),{code:oe.REPERT_JOIN_ROOM};const i=this._crtRoom=new oc(this._context,this._runtime,r,this._service,this._options,e.livingType,!0,!0,e.getClientSessionId()),n=yield i.__innerInitByIdentityChange(t);if(n!==ie)return this._crtRoom=null,{code:n};i.once(Ja,()=>{this._crtRoom=null}),yield this._crtAudienceLivingRoom.__destroy(!1),this._crtAudienceLivingRoom=null;const s={room:i,code:oe.SUCCESS,userIds:i.getRemoteUserIds(),tracks:i.getRemoteTracks()};return i.__getCDNPushMode()===fc.MANUAL&&Object.assign(s,{CDNEnable:i.__getCDNEnable()}),s})}downgradeToAudienceRoom(e){return v(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(ae.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_T,JSON.stringify({roomId:e._roomId,userId:this._context.getCurrentId()}),t),!e.isMainRoom())return this._logger.error(ae.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:ce.FAILED,code:oe.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"the `downgradeToAudienceRoom` is disabled in PK room"}),t),{code:oe.THE_FUNCTION_IS_DISABLED_IN_PKROOM};if(!g("room",e,()=>e instanceof oc,!0))return this._logger.error(ae.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> room"}),t),{code:oe.PARAMS_ERROR};if(this._crtAudienceLivingRoom)return this._logger.error(ae.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:ce.FAILED,code:oe.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),t),{code:oe.REPERT_JOIN_ROOM};const{code:r,data:i}=yield this._context.rtcIdentityChange(e._roomId,ec.AnchorToViewer,e.getLivingType());if(r!==ie)return this._logger.error(ae.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:ce.FAILED,code:oe.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED}),t),{code:oe.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED};this._logger.info(ae.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:ce.SUCCESSED,roomData:i}),t);const n=e.getClientSessionId(),s=new pc(this._context,this._runtime,this._options,e._roomId,i,e.getLivingType(),n);return this._crtAudienceLivingRoom=s,this._crtRoom.__destroy(!1),this._crtRoom=null,{room:s,code:oe.SUCCESS,userIds:s.getRemoteUserIds(),RTCTracks:s.getRemoteRTCTracks(),MCUTracks:s.getRemoteMCUTracks(),CDNUris:s.getCDNInfo()}})}getJoinedRoomInfo(){return v(this,void 0,void 0,function*(){const e=this._logger.createTraceId(),t=this._context.getCurrentId();this._logger.error(ae.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_T,JSON.stringify({userId:t}),e);const{code:r,data:i}=yield this._context.getRTCJoinedUserInfo(t);return r!==ie?(this._logger.error(ae.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_R,JSON.stringify({status:ce.FAILED,code:r}),e),{code:r}):(this._logger.info(ae.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_R,JSON.stringify({status:ce.SUCCESSED,roomInfo:i}),e),{code:oe.SUCCESS,data:i})})}generateSummarization(e,t){return v(this,arguments,void 0,function*(e,t,r=0,o=0,l,d){const u=this._logger.createTraceId();if(this._logger.info(ae.L_RTC_CLIENT_GENERATE_SUMMARIZATION_T,JSON.stringify({roomId:e,taskId:t,startTime:r,endTime:o,config:l,contentBlock:d}),u),!g("roomId",e,a,!0))return this._logger.error(ae.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> roomId"}),u),{code:oe.PARAMS_ERROR};if(!g("taskId",t,a,!0))return this._logger.error(ae.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> taskId"}),u),{code:oe.PARAMS_ERROR};if(!s(r)||r<0)return this._logger.error(ae.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> startTime"}),u),{code:oe.PARAMS_ERROR};if(!s(o)||o<0)return this._logger.error(ae.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> endTime"}),u),{code:oe.PARAMS_ERROR};if(!g("config",l,c,!0))return this._logger.error(ae.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> config"}),u),{code:oe.PARAMS_ERROR};const{isValid:_,key:h}=(e=>{if("destLang"in e&&!i(e.destLang))return{isValid:!1,key:"destLang"};if("customPrompt"in e&&!i(e.customPrompt))return{isValid:!1,key:"customPrompt"};if("enableSummarization"in e&&!n(e.enableSummarization))return{isValid:!1,key:"enableSummarization"};if("enableSummarizationDetails"in e&&!n(e.enableSummarizationDetails))return{isValid:!1,key:"enableSummarizationDetails"};if("enableChapterSummary"in e&&!n(e.enableChapterSummary))return{isValid:!1,key:"enableChapterSummary"};if("enableTodoList"in e&&!n(e.enableTodoList))return{isValid:!1,key:"enableTodoList"};if("enableHashtag"in e&&!n(e.enableHashtag))return{isValid:!1,key:"enableHashtag"};if("format"in e&&void 0===Zt[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"}})(l);_||this._logger.warn(ae.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:`params error -> config.${h}`}),u);const{code:p,msg:f}=yield this._service.generateSummarization(e,t,r,o,l,d,u);return p!==oe.SUCCESS?(this._logger.error(ae.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:ce.FAILED,code:p,msg:f}),u),{code:p}):(this._logger.info(ae.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:ce.SUCCESSED}),u),{code:p})})}getASRContent(e,t){return v(this,arguments,void 0,function*(e,t,r=0,n=0,o,c){const l=this._logger.createTraceId();if(this._logger.info(ae.L_RTC_CLIENT_GET_ASR_CONTENT_T,JSON.stringify({roomId:e,taskId:t,startTime:r,endTime:n,destLang:c,contentBlock:o}),l),!g("roomId",e,a,!0))return this._logger.error(ae.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> roomId"}),l),{code:oe.PARAMS_ERROR};if(!g("taskId",t,a,!0))return this._logger.error(ae.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> taskId"}),l),{code:oe.PARAMS_ERROR};if(!s(r)||r<0)return this._logger.error(ae.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> startTime"}),l),{code:oe.PARAMS_ERROR};if(!s(n)||n<0)return this._logger.error(ae.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> endTime"}),l),{code:oe.PARAMS_ERROR};if(!g("destLang",c,i,!1))return this._logger.error(ae.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:ce.FAILED,code:oe.PARAMS_ERROR,msg:"params error -> destLang"}),l),{code:oe.PARAMS_ERROR};const{code:d,msg:u}=yield this._service.getASRContent(e,t,r,n,o,l,c);return d!==oe.SUCCESS?(this._logger.error(ae.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:ce.FAILED,code:d,msg:u}),l),{code:d}):(this._logger.info(ae.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:ce.SUCCESSED}),l),{code:d})})}}Object.defineProperty(ol,"_instance",{enumerable:!0,configurable:!0,writable:!0,value:null}),function(e){e[e.KICK=0]="KICK",e[e.REFUSE=1]="REFUSE"}(nl||(nl={})),r.add("rtclib","5.36.1-nctest-alpha.3");const al={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=function(e){const t={logger:(J.RTC,r=e.createLogger("RCRTC","RTC"),new H({writeLog(e,t,i,n){switch(e){case G.Debug:r.debug(t,i,n);break;case G.Info:r.info(t,i,n);break;case G.Warn:r.warn(t,i,n);break;case G.Error:r.error(t,i,n);break;case G.STATISTICS:r.__statistics(t,i,n);break;default:r.info(t,i,n)}},setOutputLevel(e){r.setOutputLevel(e)}})),rtcSignaling(t,r,i,n){return v(this,void 0,void 0,function*(){const s=yield e.rtcSignaling(t,r,i,n);return{code:Z.errorCode.toCommon(null==s?void 0:s.code),buffer:null==s?void 0:s.buffer}})},registerRTCSignalListener(t){e.registerRTCSignalListener(t)},sendGroupCallSignalInfo(t,r,i){return v(this,void 0,void 0,function*(){const n=yield e.setCallInfo(t,r,i);return{code:Z.errorCode.toCommon(n.code),data:n.data}})},registerGroupCallSignalInfoListener(t){e.onCallInfo=e=>{t(e)}},setOnnavidatachange(t){const r=t?e=>{const r=Z.naviInfo.toCommon(e);t(r)}:void 0;e.onnavidatachange=r},refetchNaviInfo:e.refetchNaviInfo?()=>v(this,void 0,void 0,function*(){yield e.refetchNaviInfo()}):void 0,registerConnectionStateChangeListener(t){e.onconnectionstatechange=(e,r)=>{t(Z.connectionStatus.toCommon(e),Z.errorCode.toCommon(null!=r?r:0))}},registerDisconnectListener(t){e.ondisconnect=t},registerDestroyListener(t){e.ondestroy=t},registerMessageListener(t){const r=t?e=>t(Z.receivedMessage.toCommon(e)):void 0;e.onmessage=r},sendMessage(t,r,i){return v(this,void 0,void 0,function*(){const n=Z.conversationType.toNative(t),s=Z.sendMsgOptions.toNative(i),o=yield e.sendMessage(n,r,s);return{code:Z.errorCode.toCommon(o.code),data:void 0!==o.data?Z.receivedMessage.toCommon(o.data):void 0}})},getCurrentId:()=>e.getCurrentId(),getNaviInfo(){const t=e.getNaviInfo();return null!=t?Z.naviInfo.toCommon(t):null},getConnectionStatus:()=>Z.connectionStatus.toCommon(e.getConnectionStatus()),getAppkey:()=>e.getAppkey(),getCoreVersion:()=>e.getCoreVersion(),registerMessageType(t,r,i,n){e.registerMessageType(t,r,i,n)}};var r;return e.rtcPingResVersion&&(t.rtcPingResVersion=(t,r,i)=>v(this,void 0,void 0,function*(){const n=yield e.rtcPingResVersion(t,r,i);return{code:Z.errorCode.toCommon(n.code),data:n.data}})),t}(e),{logger:r}=t;return r.warn(ae.L_INDEX_INSTALL_RTC_PLUGIN_O,JSON.stringify({"RCRTC Version":"5.36.1-nctest-alpha.3",Commit:"c96e5775862767fb76abb0c16a37ad4961f58f6a","browserInfo.browser":fr.browser,"browserInfo.supportsUnifiedPlan":fr.supportsUnifiedPlan,"browserInfo.version":fr.version})),new ol(new sl(t),V,{})}},cl={DEFAULT:"RongCloudRTC"},ll={transResolution:ur,transFrameRate:pr,parseTrackId:or,ifSupportLocalFileTrack:gr,ifSupportScreenShare:mr};export{qa as BackgroundPictureFillMode,$a as MixLayoutMode,Ya as MixVideoRenderMode,Ha as RCAbstractRoom,dc as RCAudienceClient,pc as RCAudienceLivingRoom,Dt as RCAudioBitrate,qt as RCCameraVideoTrack,vt as RCFrameRate,_c as RCInnerCDNPullIsHttps,uc as RCInnerCDNPullKind,Ca as RCKickReason,oc as RCLivingRoom,Za as RCLivingType,Ft as RCLocalAudioTrack,Ht as RCLocalFileAudioTrack,Gt as RCLocalFileTrack,Jt as RCLocalFileVideoTrack,Vt as RCLocalTrack,jt as RCLocalVideoTrack,Qa as RCMCUConfigBuilder,gc as RCMediaStreamCapture,bt as RCMediaType,Kt as RCMicphoneAudioTrack,ol as RCRTCClient,oe as RCRTCCode,Zt as RCRTCGenerateSummarizationFormat,ho as RCRTCLiveRole,Js as RCRTCOperateSummarizationType,Or as RCRTCPingResult,ac as RCRTCRoom,zt as RCRemoteAudioTrack,Wt as RCRemoteTrack,Qt as RCRemoteVideoTrack,Ot as RCResolution,Yt as RCScreenAudioTrack,$t as RCScreenVideoTrack,cl as RCTag,Ut as RCTrack,Mt as RCVideoBitrate,nl as RTCJoinType,Ro as RTCMode,Pt as device,ll as helper,al as installer};
|
|
1
|
+
import{EventEmitter as e,isNumber as t,validate as r,isObject as i,isString as n,isBoolean as s,ErrorCode as o,HttpMethod as a,RCConnectionStatus as c,notEmptyString as _,isArray as d,RTCMode as l,RTCApiType as u,assert as h,ConversationType as g,isHttpUrl as R,isUndefined as p,forEach as m,VersionManage as f,AssertRules as S}from"@rongcloud/engine";function E(e,t,r,i){return new(r||(r=Promise))((function(n,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))}var I,T,O;"function"==typeof SuppressedError&&SuppressedError,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"}(I||(I={})),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_A_SDP_STRATEGY_SET_SENDER_TRANSFORM_O="L-a_sdp_strategy_set_sender_transform-O",e.L_A_SDP_STRATEGY_SET_RECEIVER_TRANSFORM_O="L-a_sdp_strategy_set_receiver_transform-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"}(T||(T={})),function(e){e.FAILED="fail",e.SUCCESSED="success",e.TIMEOUT="timeout",e.INFO="info"}(O||(O={}));let C=!0,v=!0;function L(e,t,r){const i=e.match(t);return i&&i.length>=r&&parseInt(i[r],10)}function b(e,t,r){if(!e.RTCPeerConnection)return;const i=e.RTCPeerConnection.prototype,n=i.addEventListener;i.addEventListener=function(e,i){if(e!==t)return n.apply(this,arguments);const s=e=>{const t=r(e);t&&(i.handleEvent?i.handleEvent(t):i(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(i,s),n.apply(this,[e,s])};const s=i.removeEventListener;i.removeEventListener=function(e,r){if(e!==t||!this._eventMap||!this._eventMap[t])return s.apply(this,arguments);if(!this._eventMap[t].has(r))return s.apply(this,arguments);const i=this._eventMap[t].get(r);return this._eventMap[t].delete(r),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,s.apply(this,[e,i])},Object.defineProperty(i,"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 A(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(C=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function y(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(v=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function N(){if("object"==typeof window){if(C)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function D(e,t){v&&console.warn(e+" is deprecated, please use "+t+" instead.")}function P(e){return"[object Object]"===Object.prototype.toString.call(e)}function k(e){return P(e)?Object.keys(e).reduce((function(t,r){const i=P(e[r]),n=i?k(e[r]):e[r],s=i&&!Object.keys(n).length;return void 0===n||s?t:Object.assign(t,{[r]:n})}),{}):e}function U(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),Object.keys(t).forEach((i=>{i.endsWith("Id")?U(e,e.get(t[i]),r):i.endsWith("Ids")&&t[i].forEach((t=>{U(e,e.get(t),r)}))})))}function M(e,t,r){const i=r?"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((r=>{r.type===i&&r.trackId===t.id&&U(e,r,n)}))})),n}const w=N;function x(e,t){const r=e&&e.navigator;if(!r.mediaDevices)return;const i=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach((r=>{if("require"===r||"advanced"===r||"mediaSource"===r)return;const i="object"==typeof e[r]?e[r]:{ideal:e[r]};void 0!==i.exact&&"number"==typeof i.exact&&(i.min=i.max=i.exact);const n=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==i.ideal){t.optional=t.optional||[];let e={};"number"==typeof i.ideal?(e[n("min",r)]=i.ideal,t.optional.push(e),e={},e[n("max",r)]=i.ideal,t.optional.push(e)):(e[n("",r)]=i.ideal,t.optional.push(e))}void 0!==i.exact&&"number"!=typeof i.exact?(t.mandatory=t.mandatory||{},t.mandatory[n("",r)]=i.exact):["min","max"].forEach((e=>{void 0!==i[e]&&(t.mandatory=t.mandatory||{},t.mandatory[n(e,r)]=i[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,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=i(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)&&(!r.mediaDevices.getSupportedConstraints||!r.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 r.mediaDevices.enumerateDevices().then((r=>{let o=(r=r.filter((e=>"videoinput"===e.kind))).find((e=>t.some((t=>e.label.toLowerCase().includes(t)))));return!o&&r.length&&t.includes("back")&&(o=r[r.length-1]),o&&(e.video.deviceId=s.exact?{exact:o.deviceId}:{ideal:o.deviceId}),e.video=i(e.video),w("chrome: "+JSON.stringify(e)),n(e)}))}e.video=i(e.video)}return w("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(r.getUserMedia=function(e,t,i){n(e,(e=>{r.webkitGetUserMedia(e,t,(e=>{i&&i(s(e))}))}))}.bind(r),r.mediaDevices.getUserMedia){const e=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.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 B(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function V(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",(r=>{let i;i=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===r.track.id)):{track:r.track};const n=new Event("track");n.track=r.track,n.receiver=i,n.transceiver={receiver:i},n.streams=[t.stream],this.dispatchEvent(n)})),t.stream.getTracks().forEach((r=>{let i;i=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===r.id)):{track:r};const n=new Event("track");n.track=r,n.receiver=i,n.transceiver={receiver:i},n.streams=[t.stream],this.dispatchEvent(n)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else b(e,"track",(e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e)))}function j(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 r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,i){let n=r.apply(this,arguments);return n||(n=t(this,e),this._senders.push(n)),n};const i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){i.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}const r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],r.apply(this,[e]),e.getTracks().forEach((e=>{this._senders.push(t(this,e))}))};const i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],i.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 F(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,r,i]=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 r={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((t=>{r[t]=e.stat(t)})),t[r.id]=r})),t},s=function(e){return new Map(Object.keys(e).map((t=>[t,e[t]])))};if(arguments.length>=2){const i=function(e){r(s(n(e)))};return t.apply(this,[i,e])}return new Promise(((e,r)=>{t.apply(this,[function(t){e(s(n(t)))},r])})).then(r,i)}}function J(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 r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>M(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}),b(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>M(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,r,i;return this.getSenders().forEach((r=>{r.track===e&&(t?i=!0:t=r)})),this.getReceivers().forEach((t=>(t.track===e&&(r?i=!0:r=t),t.track===e))),i||t&&r?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():r?r.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function G(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,r){if(!r)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const i=t.apply(this,arguments);return this._shimmedLocalStreams[r.id]?-1===this._shimmedLocalStreams[r.id].indexOf(i)&&this._shimmedLocalStreams[r.id].push(i):this._shimmedLocalStreams[r.id]=[r,i],i};const r=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();r.apply(this,arguments);const i=this.getSenders().filter((e=>-1===t.indexOf(e)));this._shimmedLocalStreams[e.id]=[e].concat(i)};const i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],i.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 r=this._shimmedLocalStreams[t].indexOf(e);-1!==r&&this._shimmedLocalStreams[t].splice(r,1),1===this._shimmedLocalStreams[t].length&&delete this._shimmedLocalStreams[t]})),n.apply(this,arguments)}}function H(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return G(e);const r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const e=r.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map((e=>this._reverseStreams[e.id]))};const i=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 r=new e.MediaStream(t.getTracks());this._streams[t.id]=r,this._reverseStreams[r.id]=t,t=r}i.apply(this,[t])};const n=e.RTCPeerConnection.prototype.removeStream;function s(e,t){let r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const i=e._reverseStreams[t],n=e._streams[i.id];r=r.replace(new RegExp(n.id,"g"),i.id)})),new RTCSessionDescription({type:t.type,sdp:r})}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,r){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const i=[].slice.call(arguments,1);if(1!==i.length||!i[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[r.id];if(n)n.addTrack(t),Promise.resolve().then((()=>{this.dispatchEvent(new Event("negotiationneeded"))}));else{const i=new e.MediaStream([t]);this._streams[r.id]=i,this._reverseStreams[i.id]=r,this.addStream(i)}return this.getSenders().find((e=>e.track===t))},["createOffer","createAnswer"].forEach((function(t){const r=e.RTCPeerConnection.prototype[t],i={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?r.apply(this,[t=>{const r=s(this,t);e[0].apply(null,[r])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):r.apply(this,arguments).then((e=>s(this,e)))}};e.RTCPeerConnection.prototype[t]=i[t]}));const o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=function(e,t){let r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const i=e._reverseStreams[t],n=e._streams[i.id];r=r.replace(new RegExp(i.id,"g"),n.id)})),new RTCSessionDescription({type:t.type,sdp:r})}(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((r=>{this._streams[r].getTracks().find((t=>e.track===t))&&(t=this._streams[r])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function K(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const r=e.RTCPeerConnection.prototype[t],i={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=i[t]}))}function $(e,t){b(e,"negotiationneeded",(e=>{const r=e.target;if(!(t.version<72||r.getConfiguration&&"plan-b"===r.getConfiguration().sdpSemantics)||"stable"===r.signalingState)return e}))}var W=Object.freeze({__proto__:null,shimMediaStream:B,shimOnTrack:V,shimGetSendersWithDtmf:j,shimGetStats:F,shimSenderReceiverGetStats:J,shimAddTrackRemoveTrackWithNative:G,shimAddTrackRemoveTrack:H,shimPeerConnection:K,fixNegotiationNeeded:$,shimGetUserMedia:x,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(r){return t(r).then((t=>{const i=r.video&&r.video.width,n=r.video&&r.video.height,s=r.video&&r.video.frameRate;return r.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:s||3}},i&&(r.video.mandatory.maxWidth=i),n&&(r.video.mandatory.maxHeight=n),e.navigator.mediaDevices.getUserMedia(r)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}});var z,Y,q=(z=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 r=t.splitSections(e);return r&&r[0]},t.getMediaSections=function(e){var r=t.splitSections(e);return r.shift(),r},t.matchPrefix=function(e,r){return t.splitLines(e).filter((function(e){return 0===e.indexOf(r)}))},t.parseCandidate=function(e){for(var t,r={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]},i=8;i<t.length;i+=2)switch(t[i]){case"raddr":r.relatedAddress=t[i+1];break;case"rport":r.relatedPort=parseInt(t[i+1],10);break;case"tcptype":r.tcpType=t[i+1];break;case"ufrag":r.ufrag=t[i+1],r.usernameFragment=t[i+1];break;default:r[t[i]]=t[i+1]}return r},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 r=e.type;return t.push("typ"),t.push(r),"host"!==r&&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(" "),r={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),r.name=t[0],r.clockRate=parseInt(t[1],10),r.channels=3===t.length?parseInt(t[2],10):1,r.numChannels=r.channels,r},t.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var r=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==r?"/"+r:"")+"\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,r={},i=e.substr(e.indexOf(" ")+1).split(";"),n=0;n<i.length;n++)r[(t=i[n].trim().split("="))[0].trim()]=t[1];return r},t.writeFmtp=function(e){var t="",r=e.payloadType;if(void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var i=[];Object.keys(e.parameters).forEach((function(t){e.parameters[t]?i.push(t+"="+e.parameters[t]):i.push(t)})),t+="a=fmtp:"+r+" "+i.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="",r=e.payloadType;return void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((function(e){t+="a=rtcp-fb:"+r+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},t.parseSsrcMedia=function(e){var t=e.indexOf(" "),r={ssrc:parseInt(e.substr(7,t-7),10)},i=e.indexOf(":",t);return i>-1?(r.attribute=e.substr(t+1,i-t-1),r.value=e.substr(i+1)):r.attribute=e.substr(t+1),r},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 r=t.matchPrefix(e,"a=mid:")[0];if(r)return r.substr(6)},t.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},t.getDtlsParameters=function(e,r){return{role:"auto",fingerprints:t.matchPrefix(e+r,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){var r="a=setup:"+t+"\r\n";return e.fingerprints.forEach((function(e){r+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),r},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,r){return t.matchPrefix(e+r,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,r){var i=t.matchPrefix(e+r,"a=ice-ufrag:")[0],n=t.matchPrefix(e+r,"a=ice-pwd:")[0];return i&&n?{usernameFragment:i.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 r={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},i=t.splitLines(e)[0].split(" "),n=3;n<i.length;n++){var s=i[n],o=t.matchPrefix(e,"a=rtpmap:"+s+" ")[0];if(o){var a=t.parseRtpMap(o),c=t.matchPrefix(e,"a=fmtp:"+s+" ");switch(a.parameters=c.length?t.parseFmtp(c[0]):{},a.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+s+" ").map(t.parseRtcpFb),r.codecs.push(a),a.name.toUpperCase()){case"RED":case"ULPFEC":r.fecMechanisms.push(a.name.toUpperCase())}}}return t.matchPrefix(e,"a=extmap:").forEach((function(e){r.headerExtensions.push(t.parseExtmap(e))})),r},t.writeRtpDescription=function(e,r){var i="";i+="m="+e+" ",i+=r.codecs.length>0?"9":"0",i+=" UDP/TLS/RTP/SAVPF ",i+=r.codecs.map((function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",i+="c=IN IP4 0.0.0.0\r\n",i+="a=rtcp:9 IN IP4 0.0.0.0\r\n",r.codecs.forEach((function(e){i+=t.writeRtpMap(e),i+=t.writeFmtp(e),i+=t.writeRtcpFb(e)}));var n=0;return r.codecs.forEach((function(e){e.maxptime>n&&(n=e.maxptime)})),n>0&&(i+="a=maxptime:"+n+"\r\n"),i+="a=rtcp-mux\r\n",r.headerExtensions&&r.headerExtensions.forEach((function(e){i+=t.writeExtmap(e)})),i},t.parseRtpEncodingParameters=function(e){var r,i=[],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})),c=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]===c&&(r=_[0][1]),n.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&r&&(t.rtx={ssrc:r}),i.push(t),s&&((t=JSON.parse(JSON.stringify(t))).fec={ssrc:c,mechanism:o?"red+ulpfec":"red"},i.push(t))}})),0===i.length&&c&&i.push({ssrc:c});var d=t.matchPrefix(e,"b=");return d.length&&(d=0===d[0].indexOf("b=TIAS:")?parseInt(d[0].substr(7),10):0===d[0].indexOf("b=AS:")?1e3*parseInt(d[0].substr(5),10)*.95-16e3:void 0,i.forEach((function(e){e.maxBitrate=d}))),i},t.parseRtcpParameters=function(e){var r={},i=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute}))[0];i&&(r.cname=i.value,r.ssrc=i.ssrc);var n=t.matchPrefix(e,"a=rtcp-rsize");r.reducedSize=n.length>0,r.compound=0===n.length;var s=t.matchPrefix(e,"a=rtcp-mux");return r.mux=s.length>0,r},t.parseMsid=function(e){var r,i=t.matchPrefix(e,"a=msid:");if(1===i.length)return{stream:(r=i[0].substr(7).split(" "))[0],track:r[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:(r=n[0].value.split(" "))[0],track:r[1]}:void 0},t.parseSctpDescription=function(e){var r,i=t.parseMLine(e),n=t.matchPrefix(e,"a=max-message-size:");n.length>0&&(r=parseInt(n[0].substr(19),10)),isNaN(r)&&(r=65536);var s=t.matchPrefix(e,"a=sctp-port:");if(s.length>0)return{port:parseInt(s[0].substr(12),10),protocol:i.fmt,maxMessageSize:r};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:r}}},t.writeSctpDescription=function(e,t){var r=[];return r="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&&r.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),r.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,21)},t.writeSessionBoilerplate=function(e,r,i){var n=void 0!==r?r:2;return"v=0\r\no="+(i||"thisisadapterortc")+" "+(e||t.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.writeMediaSection=function(e,r,i,n){var s=t.writeRtpDescription(e.kind,r);if(s+=t.writeIceParameters(e.iceGatherer.getLocalParameters()),s+=t.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===i?"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,r){for(var i=t.splitLines(e),n=0;n<i.length;n++)switch(i[n]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return i[n].substr(2)}return r?t.getDirection(r):"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 r=t.splitLines(e)[0].substr(2).split(" ");return{kind:r[0],port:parseInt(r[1],10),protocol:r[2],fmt:r.slice(3).join(" ")}},t.parseOLine=function(e){var r=t.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:r[0],sessionId:r[1],sessionVersion:parseInt(r[2],10),netType:r[3],addressType:r[4],address:r[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var r=t.splitLines(e),i=0;i<r.length;i++)if(r[i].length<2||"="!==r[i].charAt(1))return!1;return!0},e.exports=t},z(Y={exports:{}},Y.exports),Y.exports);function Z(e,t,r,i,n){var s=q.writeRtpDescription(e.kind,t);if(s+=q.writeIceParameters(e.iceGatherer.getLocalParameters()),s+=q.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"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:"+(i?i.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:"+q.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+q.localCName+"\r\n"),s}function Q(e,t){var r={codecs:[],headerExtensions:[],fecMechanisms:[]},i=function(e,t){e=parseInt(e,10);for(var r=0;r<t.length;r++)if(t[r].payloadType===e||t[r].preferredPayloadType===e)return t[r]},n=function(e,t,r,n){var s=i(e.parameters.apt,r),o=i(t.parameters.apt,n);return s&&o&&s.name.toLowerCase()===o.name.toLowerCase()};return e.codecs.forEach((function(i){for(var s=0;s<t.codecs.length;s++){var o=t.codecs[s];if(i.name.toLowerCase()===o.name.toLowerCase()&&i.clockRate===o.clockRate){if("rtx"===i.name.toLowerCase()&&i.parameters&&o.parameters.apt&&!n(i,o,e.codecs,t.codecs))continue;(o=JSON.parse(JSON.stringify(o))).numChannels=Math.min(i.numChannels,o.numChannels),r.codecs.push(o),o.rtcpFeedback=o.rtcpFeedback.filter((function(e){for(var t=0;t<i.rtcpFeedback.length;t++)if(i.rtcpFeedback[t].type===e.type&&i.rtcpFeedback[t].parameter===e.parameter)return!0;return!1}));break}}})),e.headerExtensions.forEach((function(e){for(var i=0;i<t.headerExtensions.length;i++){var n=t.headerExtensions[i];if(e.uri===n.uri){r.headerExtensions.push(n);break}}})),r}function X(e,t,r){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(r)}function ee(e,t){var r=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 r||e.addRemoteCandidate(t),!r}function te(e,t){var r=new Error(t);return r.name=e,r.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[e],r}var re=function(e,t){function r(t,r){r.addTrack(t),r.dispatchEvent(new e.MediaStreamTrackEvent("addtrack",{track:t}))}function i(t,r,i,n){var s=new Event("track");s.track=r,s.receiver=i,s.transceiver={receiver:i},s.streams=n,e.setTimeout((function(){t._dispatchEvent("track",s)}))}var n=function(r){var i=this,n=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach((function(e){i[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",r=JSON.parse(JSON.stringify(r||{})),this.usingBundle="max-bundle"===r.bundlePolicy,"negotiate"===r.rtcpMuxPolicy)throw te("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(r.rtcpMuxPolicy||(r.rtcpMuxPolicy="require"),r.iceTransportPolicy){case"all":case"relay":break;default:r.iceTransportPolicy="all"}switch(r.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:r.bundlePolicy="balanced"}if(r.iceServers=function(e,t){var r=!1;return(e=JSON.parse(JSON.stringify(e))).filter((function(e){if(e&&(e.urls||e.url)){var i=e.urls||e.url;e.url&&!e.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var n="string"==typeof i;return n&&(i=[i]),i=i.filter((function(e){return 0!==e.indexOf("turn:")||-1===e.indexOf("transport=udp")||-1!==e.indexOf("turn:[")||r?0===e.indexOf("stun:")&&t>=14393&&-1===e.indexOf("?transport=udp"):(r=!0,!0)})),delete e.url,e.urls=n?i[0]:i,!!i.length}}))}(r.iceServers||[],t),this._iceGatherers=[],r.iceCandidatePoolSize)for(var s=r.iceCandidatePoolSize;s>0;s--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:r.iceServers,gatherPolicy:r.iceTransportPolicy}));else r.iceCandidatePoolSize=0;this._config=r,this.transceivers=[],this._sdpSessionId=q.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 r=this.transceivers.length>0,i={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&&r)i.iceTransport=this.transceivers[0].iceTransport,i.dtlsTransport=this.transceivers[0].dtlsTransport;else{var n=this._createIceAndDtlsTransports();i.iceTransport=n.iceTransport,i.dtlsTransport=n.dtlsTransport}return t||this.transceivers.push(i),i},n.prototype.addTrack=function(t,r){if(this._isClosed)throw te("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var i;if(this.transceivers.find((function(e){return e.track===t})))throw te("InvalidAccessError","Track already exists.");for(var n=0;n<this.transceivers.length;n++)this.transceivers[n].track||this.transceivers[n].kind!==t.kind||(i=this.transceivers[n]);return i||(i=this._createTransceiver(t.kind)),this._maybeFireNegotiationNeeded(),-1===this.localStreams.indexOf(r)&&this.localStreams.push(r),i.track=t,i.stream=r,i.rtpSender=new e.RTCRtpSender(t,i.dtlsTransport),i.rtpSender},n.prototype.addStream=function(e){var r=this;if(t>=15025)e.getTracks().forEach((function(t){r.addTrack(t,e)}));else{var i=e.clone();e.getTracks().forEach((function(e,t){var r=i.getTracks()[t];e.addEventListener("enabled",(function(e){r.enabled=e.enabled}))})),i.getTracks().forEach((function(e){r.addTrack(e,i)}))}},n.prototype.removeTrack=function(t){if(this._isClosed)throw te("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 r=this.transceivers.find((function(e){return e.rtpSender===t}));if(!r)throw te("InvalidAccessError","Sender was not created by this connection.");var i=r.stream;r.rtpSender.stop(),r.rtpSender=null,r.track=null,r.stream=null,-1===this.transceivers.map((function(e){return e.stream})).indexOf(i)&&this.localStreams.indexOf(i)>-1&&this.localStreams.splice(this.localStreams.indexOf(i),1),this._maybeFireNegotiationNeeded()},n.prototype.removeStream=function(e){var t=this;e.getTracks().forEach((function(e){var r=t.getSenders().find((function(t){return t.track===e}));r&&t.removeTrack(r)}))},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,r){var i=this;if(r&&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 r=!e.candidate||0===Object.keys(e.candidate).length;n.state=r?"completed":"gathering",null!==i.transceivers[t].bufferedCandidateEvents&&i.transceivers[t].bufferedCandidateEvents.push(e)},n.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),n},n.prototype._gather=function(t,r){var i=this,n=this.transceivers[r].iceGatherer;if(!n.onlocalcandidate){var s=this.transceivers[r].bufferedCandidateEvents;this.transceivers[r].bufferedCandidateEvents=null,n.removeEventListener("localcandidate",this.transceivers[r].bufferCandidates),n.onlocalcandidate=function(e){if(!(i.usingBundle&&r>0)){var s=new Event("icecandidate");s.candidate={sdpMid:t,sdpMLineIndex:r};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 c=q.writeCandidate(o);s.candidate=Object.assign(s.candidate,q.parseCandidate(c)),s.candidate.candidate=c,s.candidate.toJSON=function(){return{candidate:s.candidate.candidate,sdpMid:s.candidate.sdpMid,sdpMLineIndex:s.candidate.sdpMLineIndex,usernameFragment:s.candidate.usernameFragment}}}var _=q.getMediaSections(i._localDescription.sdp);_[s.candidate.sdpMLineIndex]+=a?"a=end-of-candidates\r\n":"a="+s.candidate.candidate+"\r\n",i._localDescription.sdp=q.getDescription(i._localDescription.sdp)+_.join("");var d=i.transceivers.every((function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state}));"gathering"!==i.iceGatheringState&&(i.iceGatheringState="gathering",i._emitGatheringStateChange()),a||i._dispatchEvent("icecandidate",s),d&&(i._dispatchEvent("icecandidate",new Event("icecandidate")),i.iceGatheringState="complete",i._emitGatheringStateChange())}},e.setTimeout((function(){s.forEach((function(e){n.onlocalcandidate(e)}))}),0)}},n.prototype._createIceAndDtlsTransports=function(){var t=this,r=new e.RTCIceTransport(null);r.onicestatechange=function(){t._updateIceConnectionState(),t._updateConnectionState()};var i=new e.RTCDtlsTransport(r);return i.ondtlsstatechange=function(){t._updateConnectionState()},i.onerror=function(){Object.defineProperty(i,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:r,dtlsTransport:i}},n.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var r=this.transceivers[e].iceTransport;r&&(delete r.onicestatechange,delete this.transceivers[e].iceTransport);var i=this.transceivers[e].dtlsTransport;i&&(delete i.ondtlsstatechange,delete i.onerror,delete this.transceivers[e].dtlsTransport)},n.prototype._transceive=function(e,r,i){var n=Q(e.localCapabilities,e.remoteCapabilities);r&&e.rtpSender&&(n.encodings=e.sendEncodingParameters,n.rtcp={cname:q.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(n.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(n)),i&&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,r,i=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(te("TypeError",'Unsupported type "'+e.type+'"'));if(!X("setLocalDescription",e.type,i.signalingState)||i._isClosed)return Promise.reject(te("InvalidStateError","Can not set local "+e.type+" in state "+i.signalingState));if("offer"===e.type)t=q.splitSections(e.sdp),r=t.shift(),t.forEach((function(e,t){var r=q.parseRtpParameters(e);i.transceivers[t].localCapabilities=r})),i.transceivers.forEach((function(e,t){i._gather(e.mid,t)}));else if("answer"===e.type){t=q.splitSections(i._remoteDescription.sdp),r=t.shift();var n=q.matchPrefix(r,"a=ice-lite").length>0;t.forEach((function(e,t){var s=i.transceivers[t],o=s.iceGatherer,a=s.iceTransport,c=s.dtlsTransport,_=s.localCapabilities,d=s.remoteCapabilities;if(!(q.isRejected(e)&&0===q.matchPrefix(e,"a=bundle-only").length)&&!s.rejected){var l=q.getIceParameters(e,r),u=q.getDtlsParameters(e,r);n&&(u.role="server"),i.usingBundle&&0!==t||(i._gather(s.mid,t),"new"===a.state&&a.start(o,l,n?"controlling":"controlled"),"new"===c.state&&c.start(u));var h=Q(_,d);i._transceive(s,h.codecs.length>0,!1)}}))}return i._localDescription={type:e.type,sdp:e.sdp},"offer"===e.type?i._updateSignalingState("have-local-offer"):i._updateSignalingState("stable"),Promise.resolve()},n.prototype.setRemoteDescription=function(n){var s=this;if(-1===["offer","answer"].indexOf(n.type))return Promise.reject(te("TypeError",'Unsupported type "'+n.type+'"'));if(!X("setRemoteDescription",n.type,s.signalingState)||s._isClosed)return Promise.reject(te("InvalidStateError","Can not set remote "+n.type+" in state "+s.signalingState));var o={};s.remoteStreams.forEach((function(e){o[e.id]=e}));var a=[],c=q.splitSections(n.sdp),_=c.shift(),d=q.matchPrefix(_,"a=ice-lite").length>0,l=q.matchPrefix(_,"a=group:BUNDLE ").length>0;s.usingBundle=l;var u=q.matchPrefix(_,"a=ice-options:")[0];return s.canTrickleIceCandidates=!!u&&u.substr(14).split(" ").indexOf("trickle")>=0,c.forEach((function(i,c){var u=q.splitLines(i),h=q.getKind(i),g=q.isRejected(i)&&0===q.matchPrefix(i,"a=bundle-only").length,R=u[0].substr(2).split(" ")[2],p=q.getDirection(i,_),m=q.parseMsid(i),f=q.getMid(i)||q.generateIdentifier();if(g||"application"===h&&("DTLS/SCTP"===R||"UDP/DTLS/SCTP"===R))s.transceivers[c]={mid:f,kind:h,protocol:R,rejected:!0};else{var S,E,I,T,O,C,v,L,b;!g&&s.transceivers[c]&&s.transceivers[c].rejected&&(s.transceivers[c]=s._createTransceiver(h,!0));var A,y,N=q.parseRtpParameters(i);g||(A=q.getIceParameters(i,_),(y=q.getDtlsParameters(i,_)).role="client"),v=q.parseRtpEncodingParameters(i);var D=q.parseRtcpParameters(i),P=q.matchPrefix(i,"a=end-of-candidates",_).length>0,k=q.matchPrefix(i,"a=candidate:").map((function(e){return q.parseCandidate(e)})).filter((function(e){return 1===e.component}));if(("offer"===n.type||"answer"===n.type)&&!g&&l&&c>0&&s.transceivers[c]&&(s._disposeIceAndDtlsTransports(c),s.transceivers[c].iceGatherer=s.transceivers[0].iceGatherer,s.transceivers[c].iceTransport=s.transceivers[0].iceTransport,s.transceivers[c].dtlsTransport=s.transceivers[0].dtlsTransport,s.transceivers[c].rtpSender&&s.transceivers[c].rtpSender.setTransport(s.transceivers[0].dtlsTransport),s.transceivers[c].rtpReceiver&&s.transceivers[c].rtpReceiver.setTransport(s.transceivers[0].dtlsTransport)),"offer"!==n.type||g){if("answer"===n.type&&!g){E=(S=s.transceivers[c]).iceGatherer,I=S.iceTransport,T=S.dtlsTransport,O=S.rtpReceiver,C=S.sendEncodingParameters,L=S.localCapabilities,s.transceivers[c].recvEncodingParameters=v,s.transceivers[c].remoteCapabilities=N,s.transceivers[c].rtcpParameters=D,k.length&&"new"===I.state&&(!d&&!P||l&&0!==c?k.forEach((function(e){ee(S.iceTransport,e)})):I.setRemoteCandidates(k)),l&&0!==c||("new"===I.state&&I.start(E,A,"controlling"),"new"===T.state&&T.start(y)),!Q(S.localCapabilities,S.remoteCapabilities).codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&S.sendEncodingParameters[0].rtx&&delete S.sendEncodingParameters[0].rtx,s._transceive(S,"sendrecv"===p||"recvonly"===p,"sendrecv"===p||"sendonly"===p),!O||"sendrecv"!==p&&"sendonly"!==p?delete S.rtpReceiver:(b=O.track,m?(o[m.stream]||(o[m.stream]=new e.MediaStream),r(b,o[m.stream]),a.push([b,O,o[m.stream]])):(o.default||(o.default=new e.MediaStream),r(b,o.default),a.push([b,O,o.default])))}}else{(S=s.transceivers[c]||s._createTransceiver(h)).mid=f,S.iceGatherer||(S.iceGatherer=s._createIceGatherer(c,l)),k.length&&"new"===S.iceTransport.state&&(!P||l&&0!==c?k.forEach((function(e){ee(S.iceTransport,e)})):S.iceTransport.setRemoteCandidates(k)),L=e.RTCRtpReceiver.getCapabilities(h),t<15019&&(L.codecs=L.codecs.filter((function(e){return"rtx"!==e.name}))),C=S.sendEncodingParameters||[{ssrc:1001*(2*c+2)}];var U,M=!1;if("sendrecv"===p||"sendonly"===p){if(M=!S.rtpReceiver,O=S.rtpReceiver||new e.RTCRtpReceiver(S.dtlsTransport,h),M)b=O.track,m&&"-"===m.stream||(m?(o[m.stream]||(o[m.stream]=new e.MediaStream,Object.defineProperty(o[m.stream],"id",{get:function(){return m.stream}})),Object.defineProperty(b,"id",{get:function(){return m.track}}),U=o[m.stream]):(o.default||(o.default=new e.MediaStream),U=o.default)),U&&(r(b,U),S.associatedRemoteMediaStreams.push(U)),a.push([b,O,U])}else S.rtpReceiver&&S.rtpReceiver.track&&(S.associatedRemoteMediaStreams.forEach((function(t){var r=t.getTracks().find((function(e){return e.id===S.rtpReceiver.track.id}));r&&function(t,r){r.removeTrack(t),r.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:t}))}(r,t)})),S.associatedRemoteMediaStreams=[]);S.localCapabilities=L,S.remoteCapabilities=N,S.rtpReceiver=O,S.rtcpParameters=D,S.sendEncodingParameters=C,S.recvEncodingParameters=v,s._transceive(s.transceivers[c],!1,M)}}})),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 r=o[t];if(r.getTracks().length){if(-1===s.remoteStreams.indexOf(r)){s.remoteStreams.push(r);var n=new Event("addstream");n.stream=r,e.setTimeout((function(){s._dispatchEvent("addstream",n)}))}a.forEach((function(e){var t=e[0],n=e[1];r.id===e[2].id&&i(s,t,n,[r])}))}})),a.forEach((function(e){e[2]||i(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 r=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",r)}},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 r=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",r)}},n.prototype.createOffer=function(){var r=this;if(r._isClosed)return Promise.reject(te("InvalidStateError","Can not call createOffer after close"));var i=r.transceivers.filter((function(e){return"audio"===e.kind})).length,n=r.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&&(i=!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(r.transceivers.forEach((function(e){"audio"===e.kind?--i<0&&(e.wantReceive=!1):"video"===e.kind&&--n<0&&(e.wantReceive=!1)}));i>0||n>0;)i>0&&(r._createTransceiver("audio"),i--),n>0&&(r._createTransceiver("video"),n--);var o=q.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);r.transceivers.forEach((function(i,n){var s=i.track,o=i.kind,a=i.mid||q.generateIdentifier();i.mid=a,i.iceGatherer||(i.iceGatherer=r._createIceGatherer(n,r.usingBundle));var c=e.RTCRtpSender.getCapabilities(o);t<15019&&(c.codecs=c.codecs.filter((function(e){return"rtx"!==e.name}))),c.codecs.forEach((function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1"),i.remoteCapabilities&&i.remoteCapabilities.codecs&&i.remoteCapabilities.codecs.forEach((function(t){e.name.toLowerCase()===t.name.toLowerCase()&&e.clockRate===t.clockRate&&(e.preferredPayloadType=t.payloadType)}))})),c.headerExtensions.forEach((function(e){(i.remoteCapabilities&&i.remoteCapabilities.headerExtensions||[]).forEach((function(t){e.uri===t.uri&&(e.id=t.id)}))}));var _=i.sendEncodingParameters||[{ssrc:1001*(2*n+1)}];s&&t>=15019&&"video"===o&&!_[0].rtx&&(_[0].rtx={ssrc:_[0].ssrc+1}),i.wantReceive&&(i.rtpReceiver=new e.RTCRtpReceiver(i.dtlsTransport,o)),i.localCapabilities=c,i.sendEncodingParameters=_})),"max-compat"!==r._config.bundlePolicy&&(o+="a=group:BUNDLE "+r.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),o+="a=ice-options:trickle\r\n",r.transceivers.forEach((function(e,t){o+=Z(e,e.localCapabilities,"offer",e.stream,r._dtlsRole),o+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===r.iceGatheringState||0!==t&&r.usingBundle||(e.iceGatherer.getLocalCandidates().forEach((function(e){e.component=1,o+="a="+q.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 r=this;if(r._isClosed)return Promise.reject(te("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==r.signalingState&&"have-local-pranswer"!==r.signalingState)return Promise.reject(te("InvalidStateError","Can not call createAnswer in signalingState "+r.signalingState));var i=q.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);r.usingBundle&&(i+="a=group:BUNDLE "+r.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),i+="a=ice-options:trickle\r\n";var n=q.getMediaSections(r._remoteDescription.sdp).length;r.transceivers.forEach((function(e,s){if(!(s+1>n)){if(e.rejected)return"application"===e.kind?"DTLS/SCTP"===e.protocol?i+="m=application 0 DTLS/SCTP 5000\r\n":i+="m=application 0 "+e.protocol+" webrtc-datachannel\r\n":"audio"===e.kind?i+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n":"video"===e.kind&&(i+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"),void(i+="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=Q(e.localCapabilities,e.remoteCapabilities);!a.codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,i+=Z(e,a,"answer",e.stream,r._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(i+="a=rtcp-rsize\r\n")}}));var s=new e.RTCSessionDescription({type:"answer",sdp:i});return Promise.resolve(s)},n.prototype.addIceCandidate=function(e){var t,r=this;return e&&void 0===e.sdpMLineIndex&&!e.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise((function(i,n){if(!r._remoteDescription)return n(te("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<r.transceivers.length;o++)if(r.transceivers[o].mid===e.sdpMid){s=o;break}var a=r.transceivers[s];if(!a)return n(te("OperationError","Can not add ICE candidate"));if(a.rejected)return i();var c=Object.keys(e.candidate).length>0?q.parseCandidate(e.candidate):{};if("tcp"===c.protocol&&(0===c.port||9===c.port))return i();if(c.component&&1!==c.component)return i();if((0===s||s>0&&a.iceTransport!==r.transceivers[0].iceTransport)&&!ee(a.iceTransport,c))return n(te("OperationError","Can not add ICE candidate"));var _=e.candidate.trim();0===_.indexOf("a=")&&(_=_.substr(2)),(t=q.getMediaSections(r._remoteDescription.sdp))[s]+="a="+(c.type?_:"end-of-candidates")+"\r\n",r._remoteDescription.sdp=q.getDescription(r._remoteDescription.sdp)+t.join("")}else for(var d=0;d<r.transceivers.length&&(r.transceivers[d].rejected||(r.transceivers[d].iceTransport.addRemoteCandidate({}),(t=q.getMediaSections(r._remoteDescription.sdp))[d]+="a=end-of-candidates\r\n",r._remoteDescription.sdp=q.getDescription(r._remoteDescription.sdp)+t.join(""),!r.usingBundle));d++);i()}))},n.prototype.getStats=function(t){if(t&&t instanceof e.MediaStreamTrack){var r=null;if(this.transceivers.forEach((function(e){e.rtpSender&&e.rtpSender.track===t?r=e.rtpSender:e.rtpReceiver&&e.rtpReceiver.track===t&&(r=e.rtpReceiver)})),!r)throw te("InvalidAccessError","Invalid selector.");return r.getStats()}var i=[];return this.transceivers.forEach((function(e){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach((function(t){e[t]&&i.push(e[t].getStats())}))})),Promise.all(i).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 r=e[t];if(r&&r.prototype&&r.prototype.getStats){var i=r.prototype.getStats;r.prototype.getStats=function(){return i.apply(this).then((function(e){var t=new Map;return Object.keys(e).forEach((function(r){var i;e[r].type={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[(i=e[r]).type]||i.type,t.set(r,e[r])})),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 ie(e){const t=e&&e.navigator,r=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return r(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 ne(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 se(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 r=new Event("enabled");r.enabled=e,this.dispatchEvent(r)}})}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 r=re(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 r=e.urls||e.url;e.url&&!e.urls&&D("RTCIceServer.url","RTCIceServer.urls");const i="string"==typeof r;return i&&(r=[r]),r=r.filter((e=>{if(0===e.indexOf("stun:"))return!1;const r=e.startsWith("turn")&&!e.startsWith("turn:[")&&e.includes("transport=udp");return r&&!t?(t=!0,!0):r&&!t})),delete e.url,e.urls=i?r[0]:r,!!r.length}}))}(e.iceServers,t.version),N("ICE servers after filtering:",e.iceServers)),new r(e)},e.RTCPeerConnection.prototype=r.prototype}function oe(e){e.RTCRtpSender&&!("replaceTrack"in e.RTCRtpSender.prototype)&&(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}var ae=Object.freeze({__proto__:null,shimPeerConnection:se,shimReplaceTrack:oe,shimGetUserMedia:ie,shimGetDisplayMedia:ne});function ce(e,t){const r=e&&e.navigator,i=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,i){D("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(e).then(t,i)},!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){const e=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])},t=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(r){return"object"==typeof r&&"object"==typeof r.audio&&(r=JSON.parse(JSON.stringify(r)),e(r.audio,"autoGainControl","mozAutoGainControl"),e(r.audio,"noiseSuppression","mozNoiseSuppression")),t(r)},i&&i.prototype.getSettings){const t=i.prototype.getSettings;i.prototype.getSettings=function(){const r=t.apply(this,arguments);return e(r,"mozAutoGainControl","autoGainControl"),e(r,"mozNoiseSuppression","noiseSuppression"),r}}if(i&&i.prototype.applyConstraints){const t=i.prototype.applyConstraints;i.prototype.applyConstraints=function(r){return"audio"===this.kind&&"object"==typeof r&&(r=JSON.parse(JSON.stringify(r)),e(r,"autoGainControl","mozAutoGainControl"),e(r,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[r])}}}}function _e(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 de(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 r=e.RTCPeerConnection.prototype[t],i={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=i[t]}));const r={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},i=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,n,s]=arguments;return i.apply(this,[e||null]).then((e=>{if(t.version<53&&!n)try{e.forEach((e=>{e.type=r[e.type]||e.type}))}catch(t){if("TypeError"!==t.name)throw t;e.forEach(((t,i)=>{e.set(i,Object.assign({},t,{type:r[t.type]||t.type}))}))}return e})).then(n,s)}}function le(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 r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=r.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 ue(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}),b(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function he(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){D("removeStream","removeTrack"),this.getSenders().forEach((t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)}))})}function ge(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function Re(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],r=e&&"sendEncodings"in e;r&&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 i=t.apply(this,arguments);if(r){const{sender:t}=i,r=t.getParameters();(!("encodings"in r)||1===r.encodings.length&&0===Object.keys(r.encodings[0]).length)&&(r.encodings=e.sendEncodings,t.sendEncodings=e.sendEncodings,this.setParametersPromises.push(t.setParameters(r).then((()=>{delete t.sendEncodings})).catch((()=>{delete t.sendEncodings}))))}return i})}function pe(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 me(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 fe(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 Se=Object.freeze({__proto__:null,shimOnTrack:_e,shimPeerConnection:de,shimSenderGetStats:le,shimReceiverGetStats:ue,shimRemoveStream:he,shimRTCDataChannel:ge,shimAddTransceiver:Re,shimGetParameters:pe,shimCreateOffer:me,shimCreateAnswer:fe,shimGetUserMedia:ce,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(r){if(!r||!r.video){const e=new DOMException("getDisplayMedia without video constraints is undefined");return e.name="NotFoundError",e.code=8,Promise.reject(e)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)})}});function Ee(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((r=>t.call(this,r,e))),e.getVideoTracks().forEach((r=>t.call(this,r,e)))},e.RTCPeerConnection.prototype.addTrack=function(e,...r){return r&&r.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 r=e.getTracks();this.getSenders().forEach((e=>{r.includes(e.track)&&this.removeTrack(e)}))})}}function Ie(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 r=new Event("addstream");r.stream=t,e.dispatchEvent(r)}))}),t.apply(e,arguments)}}}function Te(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,r=t.createOffer,i=t.createAnswer,n=t.setLocalDescription,s=t.setRemoteDescription,o=t.addIceCandidate;t.createOffer=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},t.createAnswer=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};let a=function(e,t,r){const i=n.apply(this,[e]);return r?(i.then(t,r),Promise.resolve()):i};t.setLocalDescription=a,a=function(e,t,r){const i=s.apply(this,[e]);return r?(i.then(t,r),Promise.resolve()):i},t.setRemoteDescription=a,a=function(e,t,r){const i=o.apply(this,[e]);return r?(i.then(t,r),Promise.resolve()):i},t.addIceCandidate=a}function Oe(e){const t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,r=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>r(Ce(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,i){t.mediaDevices.getUserMedia(e).then(r,i)}.bind(t))}function Ce(e){return e&&void 0!==e.video?Object.assign({},e,{video:k(e.video)}):e}function ve(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){const t=[];for(let r=0;r<e.iceServers.length;r++){let i=e.iceServers[r];!i.hasOwnProperty("urls")&&i.hasOwnProperty("url")?(D("RTCIceServer.url","RTCIceServer.urls"),i=JSON.parse(JSON.stringify(i)),i.urls=i.url,delete i.url,t.push(i)):t.push(e.iceServers[r])}e.iceServers=t}return new t(e,r)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:()=>t.generateCertificate})}function Le(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 be(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 r=this.getTransceivers().find((e=>"video"===e.receiver.track.kind));!1===e.offerToReceiveVideo&&r?"sendrecv"===r.direction?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":"recvonly"===r.direction&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):!0!==e.offerToReceiveVideo||r||this.addTransceiver("video")}return t.apply(this,arguments)}}function Ae(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var ye=Object.freeze({__proto__:null,shimLocalStreamsAPI:Ee,shimRemoteStreamsAPI:Ie,shimCallbacksAPI:Te,shimGetUserMedia:Oe,shimConstraints:Ce,shimRTCIceServerUrls:ve,shimTrackEventTransceiver:Le,shimCreateOfferLegacy:be,shimAudioContext:Ae});function Ne(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 r=new t(e),i=q.parseCandidate(e.candidate),n=Object.assign(r,i);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,b(e,"icecandidate",(t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t)))}function De(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 r=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=q.splitSections(e.sdp);return t.shift(),t.some((e=>{const t=q.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 r=parseInt(t[1],10);return r!=r?-1:r}(arguments[0]),r=function(e){let r=65536;return"firefox"===t.browser&&(r=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),r}(e),i=function(e,r){let i=65536;"firefox"===t.browser&&57===t.version&&(i=65535);const n=q.matchPrefix(e.sdp,"a=max-message-size:");return n.length>0?i=parseInt(n[0].substr(19),10):"firefox"===t.browser&&-1!==r&&(i=2147483637),i}(arguments[0],e);let n;n=0===r&&0===i?Number.POSITIVE_INFINITY:0===r||0===i?Math.max(r,i):Math.min(r,i);const s={};Object.defineProperty(s,"maxMessageSize",{get:()=>n}),this._sctp=s}return r.apply(this,arguments)}}function Pe(e){if(!e.RTCPeerConnection||!("createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){const r=e.send;e.send=function(){const i=arguments[0],n=i.length||i.size||i.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 r.apply(e,arguments)}}const r=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=r.apply(this,arguments);return t(e,this),e},b(e,"datachannel",(e=>(t(e.channel,e.target),e)))}function ke(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 r=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 r=new Event("connectionstatechange",e);t.dispatchEvent(r)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}}))}function Ue(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;const r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){const r=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:r}):t.sdp=r}return r.apply(this,arguments)}}function Me(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const r=e.RTCPeerConnection.prototype.addIceCandidate;r&&0!==r.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():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}var we=Object.freeze({__proto__:null,shimRTCIceCandidate:Ne,shimMaxMessageSize:De,shimSendThrowTypeError:Pe,shimConnectionState:ke,removeExtmapAllowMixed:Ue,shimAddIceCandidateNullOrEmpty:Me});const xe=function({window:e}={},t={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const r=N,i=function(e){const t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;const{navigator:r}=e;if(r.mozGetUserMedia)t.browser="firefox",t.version=L(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer)t.browser="chrome",t.version=L(r.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(r.mediaDevices&&r.userAgent.match(/Edge\/(\d+).(\d+)$/))t.browser="edge",t.version=L(r.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!e.RTCPeerConnection||!r.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=L(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(e),n={browserDetails:i,commonShim:we,extractVersion:L,disableLog:A,disableWarnings:y};switch(i.browser){case"chrome":if(!W||!K||!t.shimChrome)return r("Chrome shim is not included in this adapter release."),n;if(null===i.version)return r("Chrome shim can not determine version, not shimming."),n;r("adapter.js shimming chrome."),n.browserShim=W,Me(e,i),x(e,i),B(e),K(e,i),V(e),H(e,i),j(e),F(e),J(e),$(e,i),Ne(e),ke(e),De(e,i),Pe(e),Ue(e,i);break;case"firefox":if(!Se||!de||!t.shimFirefox)return r("Firefox shim is not included in this adapter release."),n;r("adapter.js shimming firefox."),n.browserShim=Se,Me(e,i),ce(e,i),de(e,i),_e(e),he(e),le(e),ue(e),ge(e),Re(e),pe(e),me(e),fe(e),Ne(e),ke(e),De(e,i),Pe(e);break;case"edge":if(!ae||!se||!t.shimEdge)return r("MS edge shim is not included in this adapter release."),n;r("adapter.js shimming edge."),n.browserShim=ae,ie(e),ne(e),se(e,i),oe(e),De(e,i),Pe(e);break;case"safari":if(!ye||!t.shimSafari)return r("Safari shim is not included in this adapter release."),n;r("adapter.js shimming safari."),n.browserShim=ye,Me(e,i),ve(e),be(e),Te(e),Ee(e),Ie(e),Le(e),Oe(e),Ae(e),Ne(e),De(e,i),Pe(e),Ue(e,i);break;default:r("Unsupported browser!")}return n}({window:"undefined"==typeof window?void 0:window});var Be,Ve,je;!function(e){e.FPS_10="FPS_10",e.FPS_15="FPS_15",e.FPS_24="FPS_24",e.FPS_30="FPS_30"}(Be||(Be={})),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"}(Ve||(Ve={})),function(e){e[e.AUDIO_ONLY=0]="AUDIO_ONLY",e[e.VIDEO_ONLY=1]="VIDEO_ONLY",e[e.AUDIO_VIDEO=2]="AUDIO_VIDEO"}(je||(je={}));const Fe={[Ve.W176_H132]:{width:176,height:132,maxBitrate:150,minBitrate:80},[Ve.W176_H144]:{width:176,height:144,maxBitrate:150,minBitrate:80},[Ve.W180_H180]:{width:180,height:180,maxBitrate:200,minBitrate:100},[Ve.W240_H180]:{width:240,height:180,maxBitrate:240,minBitrate:120},[Ve.W240_H240]:{width:240,height:240,maxBitrate:280,minBitrate:120},[Ve.W256_H144]:{width:256,height:144,maxBitrate:240,minBitrate:120},[Ve.W320_H180]:{width:320,height:180,maxBitrate:280,minBitrate:120},[Ve.W320_H240]:{width:320,height:240,maxBitrate:400,minBitrate:120},[Ve.W360_H360]:{width:360,height:360,maxBitrate:520,minBitrate:140},[Ve.W480_H360]:{width:480,height:360,maxBitrate:650,minBitrate:150},[Ve.W480_H480]:{width:480,height:480,maxBitrate:800,minBitrate:180},[Ve.W640_H360]:{width:640,height:360,maxBitrate:800,minBitrate:180},[Ve.W640_H480]:{width:640,height:480,maxBitrate:900,minBitrate:200},[Ve.W720_H480]:{width:720,height:480,maxBitrate:1e3,minBitrate:200},[Ve.W848_H480]:{width:848,height:480,maxBitrate:1860,minBitrate:200},[Ve.W960_H720]:{width:960,height:720,maxBitrate:2e3,minBitrate:250},[Ve.W1280_H720]:{width:1280,height:720,maxBitrate:2200,minBitrate:250},[Ve.W1920_H1080]:{width:1920,height:1080,maxBitrate:4e3,minBitrate:400},[Ve.W144_H176]:{width:144,height:176,maxBitrate:150,minBitrate:80},[Ve.W144_H256]:{width:144,height:256,maxBitrate:240,minBitrate:120},[Ve.W180_H240]:{width:180,height:240,maxBitrate:240,minBitrate:120},[Ve.W180_H320]:{width:180,height:320,maxBitrate:280,minBitrate:120},[Ve.W240_H320]:{width:240,height:320,maxBitrate:400,minBitrate:120},[Ve.W360_H480]:{width:360,height:480,maxBitrate:650,minBitrate:150},[Ve.W360_H640]:{width:360,height:640,maxBitrate:800,minBitrate:180},[Ve.W480_H640]:{width:480,height:640,maxBitrate:900,minBitrate:200},[Ve.W480_H720]:{width:480,height:720,maxBitrate:1e3,minBitrate:200},[Ve.W480_H848]:{width:480,height:848,maxBitrate:1860,minBitrate:930},[Ve.W720_H1280]:{width:720,height:1280,maxBitrate:2200,minBitrate:250},[Ve.W720_H960]:{width:720,height:960,maxBitrate:2760,minBitrate:910},[Ve.W1080_H1920]:{width:1080,height:1920,maxBitrate:4e3,minBitrate:400}},Je=e=>{const t={192:180,368:360,1088:1080};return t[e]?t[e]:e},Ge=(e,t)=>{e=Je(e),t=Je(t);const r=Fe[`W${e}_H${t}`];if(r)return r;const i=e*t;return Object.keys(Fe).map((e=>Fe[e])).sort(((e,t)=>e.height*e.width-t.width*t.height)).filter((e=>e.height*e.width>=i))[0]||Fe.W1920_H1080},He={10:1,15:1,24:1.5,30:1.5},Ke=e=>{let t=Number.MAX_VALUE,r=1;for(const i in He){const n=Math.abs(e-parseInt(i));n<t&&(t=n,r=He[i])}return r},$e={getCameras:()=>E(void 0,void 0,void 0,(function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter((e=>"videoinput"===e.kind))})),getMicrophones:()=>E(void 0,void 0,void 0,(function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter((e=>"audioinput"===e.kind))})),getSpeakers:()=>E(void 0,void 0,void 0,(function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter((e=>"audiooutput"===e.kind))}))};var We,ze;!function(e){e.AUDIO="audio",e.VIDEO="video"}(We||(We={}));class Ye extends e{constructor(e,t,r,i,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:r}),Object.defineProperty(this,"_kind",{enumerable:!0,configurable:!0,writable:!0,value:i}),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,r=t.getTracks()[0];r&&t.removeTrack(r),this._isLocalTrack||this._logger.warn(T.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 E(this,void 0,void 0,(function*(){return this._msTrack&&(this._msTrack.enabled=!e),this._localMuted=e,I.SUCCESS}))}mute(){return E(this,void 0,void 0,(function*(){return this._setLocalMuted(!0)}))}unmute(){return E(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(!t(null==e?void 0:e.volume))return this._logger.error(T.L_TRACK_PLAY_E,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> options.volume not a number"})),{code:I.PARAMS_ERROR};(null==e?void 0:e.volume)<0&&(e.volume=0,this._logger.warn(T.L_TRACK_PLAY_E,JSON.stringify({status:O.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(T.L_TRACK_PLAY_E,JSON.stringify({status:O.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 E(this,void 0,void 0,(function*(){if(!this._msTrack)return this._logger.error(T.L_TRACK_PLAY_E,JSON.stringify({status:O.FAILED,code:I.TRACK_NOT_READY,kind:this._kind,msg:`the track is not ready to play -> id: ${this._id}`})),{code:I.TRACK_NOT_READY};"ended"===this._msTrack.readyState&&this._logger.warn(T.L_TRACK_PLAY_E,`track readyState is ended -> id: ${this._id}`);const r=this._validateVolume(t);if(r)return r;if(null==t?void 0:t.audioDeviceId){if(!(yield $e.getSpeakers()).map((e=>e.deviceId)).includes(t.audioDeviceId))return this._logger.error(T.L_TRACK_PLAY_E,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> options.audioDeviceId"})),{code:I.PARAMS_ERROR}}return!this.isVideoTrack()||e&&(e instanceof HTMLVideoElement||this._validateVideoNodeName(e))?void 0:(this._logger.error(T.L_TRACK_PLAY_E,JSON.stringify({status:O.FAILED,code:I.VIDEO_TRACK_MISS_MEDIA_ELEMENT,kind:this._kind,msg:"params element is not a HTMLVideoElement"})),{code:I.VIDEO_TRACK_MISS_MEDIA_ELEMENT})}))}_setPlayAttrs(e,t){var r;return E(this,void 0,void 0,(function*(){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===(r=this._element)||void 0===r||r.setAttribute(this.DataTrackId,this.getTrackId())}))}play(e,t){return E(this,void 0,void 0,(function*(){this._logger.info(T.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 r=yield this._validatePlayOptions(e,t);if(r)return r;const i=this.isVideoTrack();return this._element=i?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(T.L_TRACK_LOAD_START_O,JSON.stringify({status:O.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(T.L_TRACK_DURATION_CHANGE_O,JSON.stringify({status:O.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(T.L_TRACK_LOADED_META_DATA_O,JSON.stringify({status:O.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(T.L_TRACK_LOADED_DATA_O,JSON.stringify({status:O.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(T.L_TRACK_ABORT_O,JSON.stringify({status:O.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=>E(this,void 0,void 0,(function*(){var r,n;this._logger.info(T.L_TRACK_CANPLAY_O,JSON.stringify({status:O.INFO,kind:this._kind,msg:`HTMLMediaElement oncanplay -> id: ${null===(r=e.target)||void 0===r?void 0:r.id}, trackId: ${this._id}`}));try{(null==t?void 0:t.audioDeviceId)&&!i&&(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(T.L_TRACK_PLAY_E,JSON.stringify({status:O.FAILED,kind:this._kind,code:I.NO_PERMISSION_TO_USE_REQUESTED_DEVICE,msg:`setSinkId failed, error msg: ${e.message}`}));this._logger.error(T.L_TRACK_PLAY_E,JSON.stringify({status:O.FAILED,code:I.TRACK_PLAY_ERROR,kind:this._kind,msg:`play error, error msg: ${e.message}`}))}})),this._element.onvolumechange=e=>{var t,r;const i=Math.floor(100*(null===(t=e.target)||void 0===t?void 0:t.volume));this._logger.info(T.L_TRACK_VOLUME_CHANGE_O,JSON.stringify({status:O.INFO,msg:`HTMLMediaElement onvolumechange -> id: ${null===(r=e.target)||void 0===r?void 0:r.id}, volume: ${i}, trackId: ${this._id}`}))},this._element.srcObject=this._msStream,this._element.autoplay=!0,yield this._setPlayAttrs(i,t),{code:I.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"}(ze||(ze={}));const qe={[ze.Music]:{max:64,min:64},[ze.MusicHigh]:{max:128,min:128},[ze.Speech]:{max:32,min:32}};var Ze;!function(e){e.LEVEL0="LEVEL0",e.LEVEL1="LEVEL1",e.LEVEL2="LEVEL2",e.LEVEL3="LEVEL3",e.LEVEL4="LEVEL4",e.LEVEL5="LEVEL5"}(Ze||(Ze={}));const Qe={[Ze.LEVEL0]:{max:150,min:80},[Ze.LEVEL1]:{max:280,min:120},[Ze.LEVEL2]:{max:650,min:150},[Ze.LEVEL3]:{max:1e3,min:200},[Ze.LEVEL4]:{max:2200,min:250},[Ze.LEVEL5]:{max:4e3,min:400}};class Xe{static apply3ANoiseWorklet(e){return E(this,void 0,void 0,(function*(){const t=new AudioContext({sampleRate:44100});let r;try{yield t.audioWorklet.addModule(Xe.SCRIPT_URL);const e=yield fetch(Xe.WASM_URL,{cache:"force-cache",credentials:"same-origin"});r=yield e.arrayBuffer()}catch(e){return{code:I.LOAD_3A_MODULE_FAILED}}const i=t.createMediaStreamSource(new MediaStream([e])),n=new AudioWorkletNode(t,"process-worklet",{numberOfInputs:1,numberOfOutputs:1,outputChannelCount:[1],processorOptions:{binary:r}}),s=t.createMediaStreamDestination();i.connect(n).connect(s);const o=s.stream.getAudioTracks()[0];return Xe._maps.set(e.id,t),{code:I.SUCCESS,track:o}}))}static release3ANoiseWorklet(e){const t=Xe._maps.get(e.id);t&&(t.close(),Xe._maps.delete(e.id))}}Object.defineProperty(Xe,"WASM_URL",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(Xe,"SCRIPT_URL",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(Xe,"_maps",{enumerable:!0,configurable:!0,writable:!0,value:new Map});class et extends Ye{constructor(e,t,r,i,n){super(e,t,r,i,!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(et.EVENT_LOCAL_TRACK_END,this),this.removeAll(et.EVENT_LOCAL_TRACK_END)}_setLocalMuted(e){return new Promise((t=>{const r=this._localMuted!==e;super._setLocalMuted(e),this._remoteMuted=this._localMuted,r&&this._isPublished?this.emit(et.__INNER_EVENT_MUTED_CHANGE__,this,t):t(I.SUCCESS),this._logger.info(T.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(T.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(et.__INNER_EVENT_DESTROY__,this))}isDestroyed(){return this._isDestroyed}setBitrate(e=0,r=0,i=0){!t(e)||!t(r)||!t(i)||e<=0||r<=0||e<r?this._logger.error(T.L_LOCAL_TRACK_SET_BITRATE_O,JSON.stringify({status:O.FAILED,msg:`params error -> max: ${e},min: ${r}, start: ${i}`,trackId:this._id})):(this._logger.info(T.L_LOCAL_TRACK_SET_BITRATE_O,JSON.stringify({status:O.SUCCESSED,max:e,min:r,start:i,trackId:this._id})),this._bitrateInfo={max:e,min:r,start:i})}getBitrate(){var e,t,r,i,n,s,o;let{min:a,max:c,start:_}={min:0,max:0,start:0};return(null===(e=this._msTrack)||void 0===e?void 0:e.kind)===We.VIDEO?({min:a,max:c}=St(this._msTrack)):(null===(t=this._msTrack)||void 0===t?void 0:t.kind)===We.AUDIO&&({min:a,max:c}={min:32,max:32}),(null===(r=this._bitrateInfo)||void 0===r?void 0:r.max)&&(_=.7*(null===(i=this._bitrateInfo)||void 0===i?void 0:i.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)||c,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(et,"EVENT_LOCAL_TRACK_END",{enumerable:!0,configurable:!0,writable:!0,value:"local-track-end"}),Object.defineProperty(et,"__INNER_EVENT_MUTED_CHANGE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-muted-change"}),Object.defineProperty(et,"__INNER_EVENT_DESTROY__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-destroy"});class tt extends et{constructor(e,t,r,i){super(e,t,r,"audio",i)}setRecommendBitrate(e){if(!r("audioBitrate",e,(e=>e in ze)))return void this._logger.warn(T.L_RTC_SET_RECOMMEND_BITRATE_O,JSON.stringify({status:O.FAILED,msg:"params error -> params type is RCAudioBitrate"}));const t=qe[e];this.setBitrate(t.max,t.min,t.start||.7*t.max)}setBitrate(e,...t){const[r=1,i=.7*e||1]=t;super.setBitrate(e,r,i)}}class rt extends et{constructor(e,t,r,i,n=!1){super(e,t,r,"video",i),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(!r("videoBitrate",e,(e=>e in Ze)))return void this._logger.warn(T.L_RTC_SET_RECOMMEND_BITRATE_O,JSON.stringify({status:O.FAILED,msg:"params error -> params type is RCVideoBitrate"}));const t=Qe[e];this.setBitrate(t.max,t.min,t.start||.7*t.max)}setBitrate(e,...t){const[r=1,i=.7*e||1]=t;super.setBitrate(e,r,i)}}class it extends et{constructor(e,t,r,i,n,s){super(e,t,r,i,n),Object.defineProperty(this,"_resource",{enumerable:!0,configurable:!0,writable:!0,value:s}),it._innerSetMapping(this.getTrackId(),s)}static _innerSetMapping(e,t){const r=this._mapping.get(t)||[];r.push(e),this._mapping.set(t,r)}static _innerRemoveMapping(e,t){var r,i;const n=null===(r=this._mapping.get(t))||void 0===r?void 0:r.filter((t=>t!==e));n&&n.length>0?this._mapping.set(t,n):(this._mapping.delete(t),t.pause(),t.src="",null===(i=t.parentNode)||void 0===i||i.removeChild(t))}destroy(){this.isAudioTrack()&&this.mute(),it._innerRemoveMapping(this.getTrackId(),this._resource),super.destroy()}}Object.defineProperty(it,"_mapping",{enumerable:!0,configurable:!0,writable:!0,value:new Map});class nt extends it{constructor(e,t,r,i,n){super(e,t,r,"video",i,n)}}class st extends it{constructor(e,t,r,i,n){super(e,t,r,"audio",i,n)}_setLocalMuted(e){const t=Object.create(null,{_setLocalMuted:{get:()=>super._setLocalMuted}});return E(this,void 0,void 0,(function*(){return this._resource&&(this._resource.muted=e),t._setLocalMuted.call(this,e)}))}play(){return E(this,void 0,void 0,(function*(){return{code:yield this._setLocalMuted(!1)}}))}}class ot extends tt{constructor(){super(...arguments),Object.defineProperty(this,"_originTrack",{enumerable:!0,configurable:!0,writable:!0,value:null})}apply3ANoiseWorklet(){return E(this,void 0,void 0,(function*(){if(this._logger.info(T.A_APPLY_3A_NOISE_WORKLET_T),this._originTrack)return this._logger.warn(T.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:O.FAILED,msg:"3A noise module already applied"})),{code:I.SUCCESS};if(!this._msTrack||this.isDestroyed())return this._logger.warn(T.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:O.FAILED,msg:"track not ready"})),{code:I.TRACK_NOT_READY};if(this.isPublished())return this._logger.warn(T.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:O.FAILED,msg:"track already published"})),{code:I.APPLY_3A_NOISE_WORKLET_BEFORE_PUBLISH};const{code:e,track:t}=yield Xe.apply3ANoiseWorklet(this._msTrack);return e===I.SUCCESS&&t?(this._originTrack=this._msTrack,this._msTrack=t,this._logger.info(T.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:O.SUCCESSED})),{code:I.SUCCESS}):(this._logger.warn(T.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:O.FAILED,msg:`apply 3A noise module failed: ${e}`,SCRIPT_URL:Xe.SCRIPT_URL,WASM_URL:Xe.WASM_URL})),{code:e})}))}__innerSetMediaStreamTrack(e){!e&&this._originTrack&&(Xe.release3ANoiseWorklet(this._originTrack),this._originTrack.stop(),this._originTrack=null),super.__innerSetMediaStreamTrack(e)}replaceInnerTrack(e){}}class at extends rt{constructor(e,t,r,i,n=!1){super(e,t,r,i,n)}replaceInnerTrack(e){}}class ct extends rt{_onTrackEnded(){super._onTrackEnded(),this.isPublished()&&this.emit(et.__INNER_EVENT_DESTROY__,this)}}class _t extends tt{_onTrackEnded(){super._onTrackEnded(),this.isPublished()&&this.emit(et.__INNER_EVENT_DESTROY__,this)}}class dt extends Ye{constructor(e,t,r,i,n){super(e,t,r,i,!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 lt extends dt{constructor(e,t,r,i){super(e,t,r,"audio",i)}_setLocalMuted(e){const{browser:t,version:r}=Nt;return this._element&&r&&/chrome/i.test(t)&&r>=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 ut extends dt{constructor(e,t,r,i){super(e,t,r,"video",i),Object.defineProperty(this,"_isSubTiny",{enumerable:!0,configurable:!0,writable:!0,value:!1})}__innerSetIsTinyTrack(e){this._isSubTiny=e}isSubTiny(){return this._isSubTiny}}var ht;!function(e){e[e.MARK_DOWN=0]="MARK_DOWN",e[e.JSON=1]="JSON"}(ht||(ht={}));const gt=(e,t)=>({name:e,content:JSON.stringify({uris:t,ignore:!0})}),Rt=e=>JSON.stringify(e),pt=e=>/^[a-zA-Z\d-=]+$/g.test(e),mt=e=>{if(void 0===e)return 0;if(t(e))return e;const r=e;return r.exact||r.ideal||r.max||0},ft=e=>{const t=e.getSettings(),r=e.getConstraints();return{width:mt(r.width)||t.width||0,height:mt(r.height)||t.height||0,frameRate:t.frameRate||mt(r.frameRate)}},St=e=>{const{width:t,height:r,frameRate:i}=ft(e),n=Ge(t||1920,r||1080),s=Ke(i);return{min:n.minBitrate*s,max:n.maxBitrate*s}},Et=e=>[e.msid,e.mediaType].join("_"),It=e=>{const t=e.split("_");return{mediaType:parseInt(t.pop()),tag:t.pop(),userId:t.join("_")}},Tt=(e,t)=>[e,t].join("_"),Ot=e=>e.map((e=>Object.assign({},e))),Ct=(e,t,r=!1)=>{e=e.slice();const i=[],n=[],s=[];return t.forEach((t=>{const n=Et(t);let o=e.findIndex((e=>Et(e)===n));if(r&&(o=e.findIndex((e=>e.uri===t.uri))),-1===o)return void i.push(t);const a=e[o];a.uri!==t.uri?i.push(t):a.state!==t.state&&s.push(t),e.splice(o,1)})),n.push(...e),{publishedList:i,unpublishedList:n,modifiedList:s}},vt=()=>{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(""),r=t.length+1;let i=+e;const n=[];do{const e=i%r;i=(i-e)/r,n.unshift(t[e])}while(i);return n.join("")})(e),e.length>22&&(e=e.slice(0,22)),e},Lt=e=>{if(Fe[e]){const{width:t,height:r}=Fe[e];return{width:t,height:r}}const[t,r]=e.split("_").map((e=>parseInt(e.replace(/[^\d]/g,""))));return{width:t,height:r}},bt=e=>!!Ve[e],At=e=>!!Be[e],yt=e=>parseInt(e.replace("FPS_","")),Nt=(()=>{const{browser:e,version:t,supportsUnifiedPlan:r}=xe.browserDetails;return{browser:e,version:t,supportsUnifiedPlan:!1!==r}})();function Dt(){return"captureStream"in HTMLMediaElement.prototype||"mozCaptureStream"in HTMLMediaElement.prototype}function Pt(){return"mediaDevices"in navigator&&"getDisplayMedia"in navigator.mediaDevices}const kt=e=>"[object Null]"===Object.prototype.toString.call(e),Ut=e=>1===e.type,Mt=(e,t,r,i)=>{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){r.warn(T.L_PARSE_ROOMDATA_URIS_R,`invalid user data -> userId: ${s}, userData: ${a}`,i)}n[s]=o})),n},wt=e=>e instanceof Ye?e.getTrackId():e.track.getTrackId(),xt=e=>{if(!i(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)},Bt=()=>"function"==typeof RTCRtpSender.prototype.createEncodedStreams&&"function"==typeof RTCRtpReceiver.prototype.createEncodedStreams;var Vt,jt;!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"}(Vt||(Vt={})),function(e){e.SUCCESS="Success",e.FAIL="Fail"}(jt||(jt={}));class Ft{constructor(e,t,r,i=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:r}),Object.defineProperty(this,"_gap",{enumerable:!0,configurable:!0,writable:!0,value:i}),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(T.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:o.TIMEOUT})}))}_checkAlive(e){return E(this,void 0,void 0,(function*(){const{logger:t}=this._context,r=t.createTraceId(),{code:i,data:n}=yield this._sendPing();if(!this._started)return;const s=Date.now();return i===o.SUCCESS?(this._latestTimestamp=s,this.onPingResult(jt.SUCCESS,n.version),void(this._timer=setTimeout((()=>this._checkAlive(e)),this._gap))):(t.error(T.L_PINGER_SEND_RTCPING_E,JSON.stringify({roomId:this._roomId,code:i}),r),this.onPingResult(jt.FAIL),40003===i||s-this._latestTimestamp>e?(this.stop(),void this.onFailed(40003===i)):void(this._timer=setTimeout((()=>this._checkAlive(e)),this._gap)))}))}stop(){this._started&&(this._logger.info(T.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 Jt(e){let t=e.length;for(;--t>=0;)e[t]=0}const Gt=256,Ht=286,Kt=30,$t=15,Wt=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]),zt=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]),Yt=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),qt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Zt=new Array(576);Jt(Zt);const Qt=new Array(60);Jt(Qt);const Xt=new Array(512);Jt(Xt);const er=new Array(256);Jt(er);const tr=new Array(29);Jt(tr);const rr=new Array(Kt);function ir(e,t,r,i,n){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=i,this.max_length=n,this.has_stree=e&&e.length}let nr,sr,or;function ar(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}Jt(rr);const cr=e=>e<256?Xt[e]:Xt[256+(e>>>7)],_r=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},dr=(e,t,r)=>{e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,_r(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)},lr=(e,t,r)=>{dr(e,r[2*t],r[2*t+1])},ur=(e,t)=>{let r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1},hr=(e,t,r)=>{const i=new Array(16);let n,s,o=0;for(n=1;n<=$t;n++)o=o+r[n-1]<<1,i[n]=o;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=ur(i[t]++,t))}},gr=e=>{let t;for(t=0;t<Ht;t++)e.dyn_ltree[2*t]=0;for(t=0;t<Kt;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},Rr=e=>{e.bi_valid>8?_r(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},pr=(e,t,r,i)=>{const n=2*t,s=2*r;return e[n]<e[s]||e[n]===e[s]&&i[t]<=i[r]},mr=(e,t,r)=>{const i=e.heap[r];let n=r<<1;for(;n<=e.heap_len&&(n<e.heap_len&&pr(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!pr(t,i,e.heap[n],e.depth));)e.heap[r]=e.heap[n],r=n,n<<=1;e.heap[r]=i},fr=(e,t,r)=>{let i,n,s,o,a=0;if(0!==e.sym_next)do{i=255&e.pending_buf[e.sym_buf+a++],i+=(255&e.pending_buf[e.sym_buf+a++])<<8,n=e.pending_buf[e.sym_buf+a++],0===i?lr(e,n,t):(s=er[n],lr(e,s+Gt+1,t),o=Wt[s],0!==o&&(n-=tr[s],dr(e,n,o)),i--,s=cr(i),lr(e,s,r),o=zt[s],0!==o&&(i-=rr[s],dr(e,i,o)))}while(a<e.sym_next);lr(e,256,t)},Sr=(e,t)=>{const r=t.dyn_tree,i=t.stat_desc.static_tree,n=t.stat_desc.has_stree,s=t.stat_desc.elems;let o,a,c,_=-1;for(e.heap_len=0,e.heap_max=573,o=0;o<s;o++)0!==r[2*o]?(e.heap[++e.heap_len]=_=o,e.depth[o]=0):r[2*o+1]=0;for(;e.heap_len<2;)c=e.heap[++e.heap_len]=_<2?++_:0,r[2*c]=1,e.depth[c]=0,e.opt_len--,n&&(e.static_len-=i[2*c+1]);for(t.max_code=_,o=e.heap_len>>1;o>=1;o--)mr(e,r,o);c=s;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],mr(e,r,1),a=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=a,r[2*c]=r[2*o]+r[2*a],e.depth[c]=(e.depth[o]>=e.depth[a]?e.depth[o]:e.depth[a])+1,r[2*o+1]=r[2*a+1]=c,e.heap[1]=c++,mr(e,r,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const r=t.dyn_tree,i=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,c=t.stat_desc.max_length;let _,d,l,u,h,g,R=0;for(u=0;u<=$t;u++)e.bl_count[u]=0;for(r[2*e.heap[e.heap_max]+1]=0,_=e.heap_max+1;_<573;_++)d=e.heap[_],u=r[2*r[2*d+1]+1]+1,u>c&&(u=c,R++),r[2*d+1]=u,d>i||(e.bl_count[u]++,h=0,d>=a&&(h=o[d-a]),g=r[2*d],e.opt_len+=g*(u+h),s&&(e.static_len+=g*(n[2*d+1]+h)));if(0!==R){do{for(u=c-1;0===e.bl_count[u];)u--;e.bl_count[u]--,e.bl_count[u+1]+=2,e.bl_count[c]--,R-=2}while(R>0);for(u=c;0!==u;u--)for(d=e.bl_count[u];0!==d;)l=e.heap[--_],l>i||(r[2*l+1]!==u&&(e.opt_len+=(u-r[2*l+1])*r[2*l],r[2*l+1]=u),d--)}})(e,t),hr(r,_,e.bl_count)},Er=(e,t,r)=>{let i,n,s=-1,o=t[1],a=0,c=7,_=4;for(0===o&&(c=138,_=3),t[2*(r+1)+1]=65535,i=0;i<=r;i++)n=o,o=t[2*(i+1)+1],++a<c&&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?(c=138,_=3):n===o?(c=6,_=3):(c=7,_=4))},Ir=(e,t,r)=>{let i,n,s=-1,o=t[1],a=0,c=7,_=4;for(0===o&&(c=138,_=3),i=0;i<=r;i++)if(n=o,o=t[2*(i+1)+1],!(++a<c&&n===o)){if(a<_)do{lr(e,n,e.bl_tree)}while(0!=--a);else 0!==n?(n!==s&&(lr(e,n,e.bl_tree),a--),lr(e,16,e.bl_tree),dr(e,a-3,2)):a<=10?(lr(e,17,e.bl_tree),dr(e,a-3,3)):(lr(e,18,e.bl_tree),dr(e,a-11,7));a=0,s=n,0===o?(c=138,_=3):n===o?(c=6,_=3):(c=7,_=4)}};let Tr=!1;const Or=(e,t,r,i)=>{dr(e,0+(i?1:0),3),Rr(e),_r(e,r),_r(e,~r),r&&e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r};var Cr=(e,t,r,i)=>{let n,s,o=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&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<Gt;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),Sr(e,e.l_desc),Sr(e,e.d_desc),o=(e=>{let t;for(Er(e,e.dyn_ltree,e.l_desc.max_code),Er(e,e.dyn_dtree,e.d_desc.max_code),Sr(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*qt[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=r+5,r+4<=n&&-1!==t?Or(e,t,r,i):4===e.strategy||s===n?(dr(e,2+(i?1:0),3),fr(e,Zt,Qt)):(dr(e,4+(i?1:0),3),((e,t,r,i)=>{let n;for(dr(e,t-257,5),dr(e,r-1,5),dr(e,i-4,4),n=0;n<i;n++)dr(e,e.bl_tree[2*qt[n]+1],3);Ir(e,e.dyn_ltree,t-1),Ir(e,e.dyn_dtree,r-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),fr(e,e.dyn_ltree,e.dyn_dtree)),gr(e),i&&Rr(e)},vr={_tr_init:e=>{Tr||((()=>{let e,t,r,i,n;const s=new Array(16);for(r=0,i=0;i<28;i++)for(tr[i]=r,e=0;e<1<<Wt[i];e++)er[r++]=i;for(er[r-1]=i,n=0,i=0;i<16;i++)for(rr[i]=n,e=0;e<1<<zt[i];e++)Xt[n++]=i;for(n>>=7;i<Kt;i++)for(rr[i]=n<<7,e=0;e<1<<zt[i]-7;e++)Xt[256+n++]=i;for(t=0;t<=$t;t++)s[t]=0;for(e=0;e<=143;)Zt[2*e+1]=8,e++,s[8]++;for(;e<=255;)Zt[2*e+1]=9,e++,s[9]++;for(;e<=279;)Zt[2*e+1]=7,e++,s[7]++;for(;e<=287;)Zt[2*e+1]=8,e++,s[8]++;for(hr(Zt,287,s),e=0;e<Kt;e++)Qt[2*e+1]=5,Qt[2*e]=ur(e,5);nr=new ir(Zt,Wt,257,Ht,$t),sr=new ir(Qt,zt,0,Kt,$t),or=new ir(new Array(0),Yt,0,19,7)})(),Tr=!0),e.l_desc=new ar(e.dyn_ltree,nr),e.d_desc=new ar(e.dyn_dtree,sr),e.bl_desc=new ar(e.bl_tree,or),e.bi_buf=0,e.bi_valid=0,gr(e)},_tr_stored_block:Or,_tr_flush_block:Cr,_tr_tally:(e,t,r)=>(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++]=r,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(er[r]+Gt+1)]++,e.dyn_dtree[2*cr(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{dr(e,2,3),lr(e,256,Zt),(e=>{16===e.bi_valid?(_r(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 Lr=(e,t,r,i)=>{let n=65535&e,s=e>>>16&65535,o=0;for(;0!==r;){o=r>2e3?2e3:r,r-=o;do{n=n+t[i++]|0,s=s+n|0}while(--o);n%=65521,s%=65521}return n|s<<16};const br=new Uint32Array((()=>{let e,t=[];for(var r=0;r<256;r++){e=r;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t})());var Ar=(e,t,r,i)=>{const n=br,s=i+r;e^=-1;for(let r=i;r<s;r++)e=e>>>8^n[255&(e^t[r])];return~e},yr={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"},Nr={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:Dr,_tr_stored_block:Pr,_tr_flush_block:kr,_tr_tally:Ur,_tr_align:Mr}=vr,{Z_NO_FLUSH:wr,Z_PARTIAL_FLUSH:xr,Z_FULL_FLUSH:Br,Z_FINISH:Vr,Z_BLOCK:jr,Z_OK:Fr,Z_STREAM_END:Jr,Z_STREAM_ERROR:Gr,Z_DATA_ERROR:Hr,Z_BUF_ERROR:Kr,Z_DEFAULT_COMPRESSION:$r,Z_FILTERED:Wr,Z_HUFFMAN_ONLY:zr,Z_RLE:Yr,Z_FIXED:qr,Z_DEFAULT_STRATEGY:Zr,Z_UNKNOWN:Qr,Z_DEFLATED:Xr}=Nr,ei=258,ti=262,ri=42,ii=113,ni=666,si=(e,t)=>(e.msg=yr[t],t),oi=e=>2*e-(e>4?9:0),ai=e=>{let t=e.length;for(;--t>=0;)e[t]=0},ci=e=>{let t,r,i,n=e.w_size;t=e.hash_size,i=t;do{r=e.head[--i],e.head[i]=r>=n?r-n:0}while(--t);t=n,i=t;do{r=e.prev[--i],e.prev[i]=r>=n?r-n:0}while(--t)};let _i=(e,t,r)=>(t<<e.hash_shift^r)&e.hash_mask;const di=e=>{const t=e.state;let r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+r),e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))},li=(e,t)=>{kr(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,di(e.strm)},ui=(e,t)=>{e.pending_buf[e.pending++]=t},hi=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},gi=(e,t,r,i)=>{let n=e.avail_in;return n>i&&(n=i),0===n?0:(e.avail_in-=n,t.set(e.input.subarray(e.next_in,e.next_in+n),r),1===e.state.wrap?e.adler=Lr(e.adler,t,n,r):2===e.state.wrap&&(e.adler=Ar(e.adler,t,n,r)),e.next_in+=n,e.total_in+=n,n)},Ri=(e,t)=>{let r,i,n=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match;const c=e.strstart>e.w_size-ti?e.strstart-(e.w_size-ti):0,_=e.window,d=e.w_mask,l=e.prev,u=e.strstart+ei;let h=_[s+o-1],g=_[s+o];e.prev_length>=e.good_match&&(n>>=2),a>e.lookahead&&(a=e.lookahead);do{if(r=t,_[r+o]===g&&_[r+o-1]===h&&_[r]===_[s]&&_[++r]===_[s+1]){s+=2,r++;do{}while(_[++s]===_[++r]&&_[++s]===_[++r]&&_[++s]===_[++r]&&_[++s]===_[++r]&&_[++s]===_[++r]&&_[++s]===_[++r]&&_[++s]===_[++r]&&_[++s]===_[++r]&&s<u);if(i=ei-(u-s),s=u-ei,i>o){if(e.match_start=t,o=i,i>=a)break;h=_[s+o-1],g=_[s+o]}}}while((t=l[t&d])>c&&0!=--n);return o<=e.lookahead?o:e.lookahead},pi=e=>{const t=e.w_size;let r,i,n;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-ti)&&(e.window.set(e.window.subarray(t,t+t-i),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),ci(e),i+=t),0===e.strm.avail_in)break;if(r=gi(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=r,e.lookahead+e.insert>=3)for(n=e.strstart-e.insert,e.ins_h=e.window[n],e.ins_h=_i(e,e.ins_h,e.window[n+1]);e.insert&&(e.ins_h=_i(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<ti&&0!==e.strm.avail_in)},mi=(e,t)=>{let r,i,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(r=65535,n=e.bi_valid+42>>3,e.strm.avail_out<n)break;if(n=e.strm.avail_out-n,i=e.strstart-e.block_start,r>i+e.strm.avail_in&&(r=i+e.strm.avail_in),r>n&&(r=n),r<s&&(0===r&&t!==Vr||t===wr||r!==i+e.strm.avail_in))break;o=t===Vr&&r===i+e.strm.avail_in?1:0,Pr(e,0,0,o),e.pending_buf[e.pending-4]=r,e.pending_buf[e.pending-3]=r>>8,e.pending_buf[e.pending-2]=~r,e.pending_buf[e.pending-1]=~r>>8,di(e.strm),i&&(i>r&&(i=r),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+i),e.strm.next_out),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i,e.block_start+=i,r-=i),r&&(gi(e.strm,e.strm.output,e.strm.next_out,r),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r)}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!==wr&&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&&(gi(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,i=e.strstart-e.block_start,(i>=s||(i||t===Vr)&&t!==wr&&0===e.strm.avail_in&&i<=n)&&(r=i>n?n:i,o=t===Vr&&0===e.strm.avail_in&&r===i?1:0,Pr(e,e.block_start,r,o),e.block_start+=r,di(e.strm)),o?3:1)},fi=(e,t)=>{let r,i;for(;;){if(e.lookahead<ti){if(pi(e),e.lookahead<ti&&t===wr)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=_i(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-ti&&(e.match_length=Ri(e,r)),e.match_length>=3)if(i=Ur(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=_i(e,e.ins_h,e.window[e.strstart+3-1]),r=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=_i(e,e.ins_h,e.window[e.strstart+1]);else i=Ur(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(li(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Vr?(li(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(li(e,!1),0===e.strm.avail_out)?1:2},Si=(e,t)=>{let r,i,n;for(;;){if(e.lookahead<ti){if(pi(e),e.lookahead<ti&&t===wr)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=_i(e,e.ins_h,e.window[e.strstart+3-1]),r=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!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-ti&&(e.match_length=Ri(e,r),e.match_length<=5&&(e.strategy===Wr||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,i=Ur(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=_i(e,e.ins_h,e.window[e.strstart+3-1]),r=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++,i&&(li(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(i=Ur(e,0,e.window[e.strstart-1]),i&&li(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&&(i=Ur(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Vr?(li(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(li(e,!1),0===e.strm.avail_out)?1:2};function Ei(e,t,r,i,n){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=i,this.func=n}const Ii=[new Ei(0,0,0,0,mi),new Ei(4,4,8,4,fi),new Ei(4,5,16,8,fi),new Ei(4,6,32,32,fi),new Ei(4,4,16,16,Si),new Ei(8,16,32,32,Si),new Ei(8,16,128,128,Si),new Ei(8,32,128,256,Si),new Ei(32,128,258,1024,Si),new Ei(32,258,258,4096,Si)];function Ti(){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=Xr,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),ai(this.dyn_ltree),ai(this.dyn_dtree),ai(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),ai(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),ai(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 Oi=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==ri&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==ii&&t.status!==ni?1:0},Ci=e=>{if(Oi(e))return si(e,Gr);e.total_in=e.total_out=0,e.data_type=Qr;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?ri:ii,e.adler=2===t.wrap?0:1,t.last_flush=-2,Dr(t),Fr},vi=e=>{const t=Ci(e);var r;return t===Fr&&((r=e.state).window_size=2*r.w_size,ai(r.head),r.max_lazy_match=Ii[r.level].max_lazy,r.good_match=Ii[r.level].good_length,r.nice_match=Ii[r.level].nice_length,r.max_chain_length=Ii[r.level].max_chain,r.strstart=0,r.block_start=0,r.lookahead=0,r.insert=0,r.match_length=r.prev_length=2,r.match_available=0,r.ins_h=0),t},Li=(e,t,r,i,n,s)=>{if(!e)return Gr;let o=1;if(t===$r&&(t=6),i<0?(o=0,i=-i):i>15&&(o=2,i-=16),n<1||n>9||r!==Xr||i<8||i>15||t<0||t>9||s<0||s>qr||8===i&&1!==o)return si(e,Gr);8===i&&(i=9);const a=new Ti;return e.state=a,a.strm=e,a.status=ri,a.wrap=o,a.gzhead=null,a.w_bits=i,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=r,vi(e)};var bi={deflateInit:(e,t)=>Li(e,t,Xr,15,8,Zr),deflateInit2:Li,deflateReset:vi,deflateResetKeep:Ci,deflateSetHeader:(e,t)=>Oi(e)||2!==e.state.wrap?Gr:(e.state.gzhead=t,Fr),deflate:(e,t)=>{if(Oi(e)||t>jr||t<0)return e?si(e,Gr):Gr;const r=e.state;if(!e.output||0!==e.avail_in&&!e.input||r.status===ni&&t!==Vr)return si(e,0===e.avail_out?Kr:Gr);const i=r.last_flush;if(r.last_flush=t,0!==r.pending){if(di(e),0===e.avail_out)return r.last_flush=-1,Fr}else if(0===e.avail_in&&oi(t)<=oi(i)&&t!==Vr)return si(e,Kr);if(r.status===ni&&0!==e.avail_in)return si(e,Kr);if(r.status===ri&&0===r.wrap&&(r.status=ii),r.status===ri){let t=Xr+(r.w_bits-8<<4)<<8,i=-1;if(i=r.strategy>=zr||r.level<2?0:r.level<6?1:6===r.level?2:3,t|=i<<6,0!==r.strstart&&(t|=32),t+=31-t%31,hi(r,t),0!==r.strstart&&(hi(r,e.adler>>>16),hi(r,65535&e.adler)),e.adler=1,r.status=ii,di(e),0!==r.pending)return r.last_flush=-1,Fr}if(57===r.status)if(e.adler=0,ui(r,31),ui(r,139),ui(r,8),r.gzhead)ui(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),ui(r,255&r.gzhead.time),ui(r,r.gzhead.time>>8&255),ui(r,r.gzhead.time>>16&255),ui(r,r.gzhead.time>>24&255),ui(r,9===r.level?2:r.strategy>=zr||r.level<2?4:0),ui(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(ui(r,255&r.gzhead.extra.length),ui(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=Ar(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69;else if(ui(r,0),ui(r,0),ui(r,0),ui(r,0),ui(r,0),ui(r,9===r.level?2:r.strategy>=zr||r.level<2?4:0),ui(r,3),r.status=ii,di(e),0!==r.pending)return r.last_flush=-1,Fr;if(69===r.status){if(r.gzhead.extra){let t=r.pending,i=(65535&r.gzhead.extra.length)-r.gzindex;for(;r.pending+i>r.pending_buf_size;){let n=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+n),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>t&&(e.adler=Ar(e.adler,r.pending_buf,r.pending-t,t)),r.gzindex+=n,di(e),0!==r.pending)return r.last_flush=-1,Fr;t=0,i-=n}let n=new Uint8Array(r.gzhead.extra);r.pending_buf.set(n.subarray(r.gzindex,r.gzindex+i),r.pending),r.pending+=i,r.gzhead.hcrc&&r.pending>t&&(e.adler=Ar(e.adler,r.pending_buf,r.pending-t,t)),r.gzindex=0}r.status=73}if(73===r.status){if(r.gzhead.name){let t,i=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>i&&(e.adler=Ar(e.adler,r.pending_buf,r.pending-i,i)),di(e),0!==r.pending)return r.last_flush=-1,Fr;i=0}t=r.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,ui(r,t)}while(0!==t);r.gzhead.hcrc&&r.pending>i&&(e.adler=Ar(e.adler,r.pending_buf,r.pending-i,i)),r.gzindex=0}r.status=91}if(91===r.status){if(r.gzhead.comment){let t,i=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>i&&(e.adler=Ar(e.adler,r.pending_buf,r.pending-i,i)),di(e),0!==r.pending)return r.last_flush=-1,Fr;i=0}t=r.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,ui(r,t)}while(0!==t);r.gzhead.hcrc&&r.pending>i&&(e.adler=Ar(e.adler,r.pending_buf,r.pending-i,i))}r.status=103}if(103===r.status){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(di(e),0!==r.pending))return r.last_flush=-1,Fr;ui(r,255&e.adler),ui(r,e.adler>>8&255),e.adler=0}if(r.status=ii,di(e),0!==r.pending)return r.last_flush=-1,Fr}if(0!==e.avail_in||0!==r.lookahead||t!==wr&&r.status!==ni){let i=0===r.level?mi(r,t):r.strategy===zr?((e,t)=>{let r;for(;;){if(0===e.lookahead&&(pi(e),0===e.lookahead)){if(t===wr)return 1;break}if(e.match_length=0,r=Ur(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(li(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Vr?(li(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(li(e,!1),0===e.strm.avail_out)?1:2})(r,t):r.strategy===Yr?((e,t)=>{let r,i,n,s;const o=e.window;for(;;){if(e.lookahead<=ei){if(pi(e),e.lookahead<=ei&&t===wr)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=e.strstart-1,i=o[n],i===o[++n]&&i===o[++n]&&i===o[++n])){s=e.strstart+ei;do{}while(i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&n<s);e.match_length=ei-(s-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=Ur(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=Ur(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(li(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Vr?(li(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(li(e,!1),0===e.strm.avail_out)?1:2})(r,t):Ii[r.level].func(r,t);if(3!==i&&4!==i||(r.status=ni),1===i||3===i)return 0===e.avail_out&&(r.last_flush=-1),Fr;if(2===i&&(t===xr?Mr(r):t!==jr&&(Pr(r,0,0,!1),t===Br&&(ai(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),di(e),0===e.avail_out))return r.last_flush=-1,Fr}return t!==Vr?Fr:r.wrap<=0?Jr:(2===r.wrap?(ui(r,255&e.adler),ui(r,e.adler>>8&255),ui(r,e.adler>>16&255),ui(r,e.adler>>24&255),ui(r,255&e.total_in),ui(r,e.total_in>>8&255),ui(r,e.total_in>>16&255),ui(r,e.total_in>>24&255)):(hi(r,e.adler>>>16),hi(r,65535&e.adler)),di(e),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?Fr:Jr)},deflateEnd:e=>{if(Oi(e))return Gr;const t=e.state.status;return e.state=null,t===ii?si(e,Hr):Fr},deflateSetDictionary:(e,t)=>{let r=t.length;if(Oi(e))return Gr;const i=e.state,n=i.wrap;if(2===n||1===n&&i.status!==ri||i.lookahead)return Gr;if(1===n&&(e.adler=Lr(e.adler,t,r,0)),i.wrap=0,r>=i.w_size){0===n&&(ai(i.head),i.strstart=0,i.block_start=0,i.insert=0);let e=new Uint8Array(i.w_size);e.set(t.subarray(r-i.w_size,r),0),t=e,r=i.w_size}const s=e.avail_in,o=e.next_in,a=e.input;for(e.avail_in=r,e.next_in=0,e.input=t,pi(i);i.lookahead>=3;){let e=i.strstart,t=i.lookahead-2;do{i.ins_h=_i(i,i.ins_h,i.window[e+3-1]),i.prev[e&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=e,e++}while(--t);i.strstart=e,i.lookahead=2,pi(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,e.next_in=o,e.input=a,e.avail_in=s,i.wrap=n,Fr},deflateInfo:"pako deflate (from Nodeca project)"};const Ai=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var yi=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(const t in r)Ai(r,t)&&(e[t]=r[t])}}return e},Ni=e=>{let t=0;for(let r=0,i=e.length;r<i;r++)t+=e[r].length;const r=new Uint8Array(t);for(let t=0,i=0,n=e.length;t<n;t++){let n=e[t];r.set(n,i),i+=n.length}return r};let Di=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){Di=!1}const Pi=new Uint8Array(256);for(let e=0;e<256;e++)Pi[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Pi[254]=Pi[254]=1;var ki=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,r,i,n,s,o=e.length,a=0;for(n=0;n<o;n++)r=e.charCodeAt(n),55296==(64512&r)&&n+1<o&&(i=e.charCodeAt(n+1),56320==(64512&i)&&(r=65536+(r-55296<<10)+(i-56320),n++)),a+=r<128?1:r<2048?2:r<65536?3:4;for(t=new Uint8Array(a),s=0,n=0;s<a;n++)r=e.charCodeAt(n),55296==(64512&r)&&n+1<o&&(i=e.charCodeAt(n+1),56320==(64512&i)&&(r=65536+(r-55296<<10)+(i-56320),n++)),r<128?t[s++]=r:r<2048?(t[s++]=192|r>>>6,t[s++]=128|63&r):r<65536?(t[s++]=224|r>>>12,t[s++]=128|r>>>6&63,t[s++]=128|63&r):(t[s++]=240|r>>>18,t[s++]=128|r>>>12&63,t[s++]=128|r>>>6&63,t[s++]=128|63&r);return t},Ui=(e,t)=>{const r=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let i,n;const s=new Array(2*r);for(n=0,i=0;i<r;){let t=e[i++];if(t<128){s[n++]=t;continue}let o=Pi[t];if(o>4)s[n++]=65533,i+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&i<r;)t=t<<6|63&e[i++],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&&Di)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let r="";for(let i=0;i<t;i++)r+=String.fromCharCode(e[i]);return r})(s,n)},Mi=(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let r=t-1;for(;r>=0&&128==(192&e[r]);)r--;return r<0||0===r?t:r+Pi[e[r]]>t?r:t};var wi=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 xi=Object.prototype.toString,{Z_NO_FLUSH:Bi,Z_SYNC_FLUSH:Vi,Z_FULL_FLUSH:ji,Z_FINISH:Fi,Z_OK:Ji,Z_STREAM_END:Gi,Z_DEFAULT_COMPRESSION:Hi,Z_DEFAULT_STRATEGY:Ki,Z_DEFLATED:$i}=Nr;function Wi(e){this.options=yi({level:Hi,method:$i,chunkSize:16384,windowBits:15,memLevel:8,strategy:Ki},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 wi,this.strm.avail_out=0;let r=bi.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==Ji)throw new Error(yr[r]);if(t.header&&bi.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?ki(t.dictionary):"[object ArrayBuffer]"===xi.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,r=bi.deflateSetDictionary(this.strm,e),r!==Ji)throw new Error(yr[r]);this._dict_set=!0}}function zi(e,t){const r=new Wi(t);if(r.push(e,!0),r.err)throw r.msg||yr[r.err];return r.result}Wi.prototype.push=function(e,t){const r=this.strm,i=this.options.chunkSize;let n,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Fi:Bi,"string"==typeof e?r.input=ki(e):"[object ArrayBuffer]"===xi.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;)if(0===r.avail_out&&(r.output=new Uint8Array(i),r.next_out=0,r.avail_out=i),(s===Vi||s===ji)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if(n=bi.deflate(r,s),n===Gi)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),n=bi.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Ji;if(0!==r.avail_out){if(s>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(0===r.avail_in)break}else this.onData(r.output)}return!0},Wi.prototype.onData=function(e){this.chunks.push(e)},Wi.prototype.onEnd=function(e){e===Ji&&(this.result=Ni(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Yi={Deflate:Wi,deflate:zi,deflateRaw:function(e,t){return(t=t||{}).raw=!0,zi(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,zi(e,t)},constants:Nr};const qi=16209;var Zi=function(e,t){let r,i,n,s,o,a,c,_,d,l,u,h,g,R,p,m,f,S,E,I,T,O,C,v;const L=e.state;r=e.next_in,C=e.input,i=r+(e.avail_in-5),n=e.next_out,v=e.output,s=n-(t-e.avail_out),o=n+(e.avail_out-257),a=L.dmax,c=L.wsize,_=L.whave,d=L.wnext,l=L.window,u=L.hold,h=L.bits,g=L.lencode,R=L.distcode,p=(1<<L.lenbits)-1,m=(1<<L.distbits)-1;e:do{h<15&&(u+=C[r++]<<h,h+=8,u+=C[r++]<<h,h+=8),f=g[u&p];t:for(;;){if(S=f>>>24,u>>>=S,h-=S,S=f>>>16&255,0===S)v[n++]=65535&f;else{if(!(16&S)){if(64&S){if(32&S){L.mode=16191;break e}e.msg="invalid literal/length code",L.mode=qi;break e}f=g[(65535&f)+(u&(1<<S)-1)];continue t}for(E=65535&f,S&=15,S&&(h<S&&(u+=C[r++]<<h,h+=8),E+=u&(1<<S)-1,u>>>=S,h-=S),h<15&&(u+=C[r++]<<h,h+=8,u+=C[r++]<<h,h+=8),f=R[u&m];;){if(S=f>>>24,u>>>=S,h-=S,S=f>>>16&255,16&S){if(I=65535&f,S&=15,h<S&&(u+=C[r++]<<h,h+=8,h<S&&(u+=C[r++]<<h,h+=8)),I+=u&(1<<S)-1,I>a){e.msg="invalid distance too far back",L.mode=qi;break e}if(u>>>=S,h-=S,S=n-s,I>S){if(S=I-S,S>_&&L.sane){e.msg="invalid distance too far back",L.mode=qi;break e}if(T=0,O=l,0===d){if(T+=c-S,S<E){E-=S;do{v[n++]=l[T++]}while(--S);T=n-I,O=v}}else if(d<S){if(T+=c+d-S,S-=d,S<E){E-=S;do{v[n++]=l[T++]}while(--S);if(T=0,d<E){S=d,E-=S;do{v[n++]=l[T++]}while(--S);T=n-I,O=v}}}else if(T+=d-S,S<E){E-=S;do{v[n++]=l[T++]}while(--S);T=n-I,O=v}for(;E>2;)v[n++]=O[T++],v[n++]=O[T++],v[n++]=O[T++],E-=3;E&&(v[n++]=O[T++],E>1&&(v[n++]=O[T++]))}else{T=n-I;do{v[n++]=v[T++],v[n++]=v[T++],v[n++]=v[T++],E-=3}while(E>2);E&&(v[n++]=v[T++],E>1&&(v[n++]=v[T++]))}break}if(64&S){e.msg="invalid distance code",L.mode=qi;break e}f=R[(65535&f)+(u&(1<<S)-1)]}}break}}while(r<i&&n<o);E=h>>3,r-=E,h-=E<<3,u&=(1<<h)-1,e.next_in=r,e.next_out=n,e.avail_in=r<i?i-r+5:5-(r-i),e.avail_out=n<o?o-n+257:257-(n-o),L.hold=u,L.bits=h};const Qi=15,Xi=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]),en=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]),tn=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]),rn=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 nn=(e,t,r,i,n,s,o,a)=>{const c=a.bits;let _,d,l,u,h,g,R=0,p=0,m=0,f=0,S=0,E=0,I=0,T=0,O=0,C=0,v=null;const L=new Uint16Array(16),b=new Uint16Array(16);let A,y,N,D=null;for(R=0;R<=Qi;R++)L[R]=0;for(p=0;p<i;p++)L[t[r+p]]++;for(S=c,f=Qi;f>=1&&0===L[f];f--);if(S>f&&(S=f),0===f)return n[s++]=20971520,n[s++]=20971520,a.bits=1,0;for(m=1;m<f&&0===L[m];m++);for(S<m&&(S=m),T=1,R=1;R<=Qi;R++)if(T<<=1,T-=L[R],T<0)return-1;if(T>0&&(0===e||1!==f))return-1;for(b[1]=0,R=1;R<Qi;R++)b[R+1]=b[R]+L[R];for(p=0;p<i;p++)0!==t[r+p]&&(o[b[t[r+p]]++]=p);if(0===e?(v=D=o,g=20):1===e?(v=Xi,D=en,g=257):(v=tn,D=rn,g=0),C=0,p=0,R=m,h=s,E=S,I=0,l=-1,O=1<<S,u=O-1,1===e&&O>852||2===e&&O>592)return 1;for(;;){A=R-I,o[p]+1<g?(y=0,N=o[p]):o[p]>=g?(y=D[o[p]-g],N=v[o[p]-g]):(y=96,N=0),_=1<<R-I,d=1<<E,m=d;do{d-=_,n[h+(C>>I)+d]=A<<24|y<<16|N}while(0!==d);for(_=1<<R-1;C&_;)_>>=1;if(0!==_?(C&=_-1,C+=_):C=0,p++,0==--L[R]){if(R===f)break;R=t[r+o[p]]}if(R>S&&(C&u)!==l){for(0===I&&(I=S),h+=m,E=R-I,T=1<<E;E+I<f&&(T-=L[E+I],!(T<=0));)E++,T<<=1;if(O+=1<<E,1===e&&O>852||2===e&&O>592)return 1;l=C&u,n[l]=S<<24|E<<16|h-s}}return 0!==C&&(n[h+C]=R-I<<24|64<<16),a.bits=S,0};const{Z_FINISH:sn,Z_BLOCK:on,Z_TREES:an,Z_OK:cn,Z_STREAM_END:_n,Z_NEED_DICT:dn,Z_STREAM_ERROR:ln,Z_DATA_ERROR:un,Z_MEM_ERROR:hn,Z_BUF_ERROR:gn,Z_DEFLATED:Rn}=Nr,pn=16180,mn=16190,fn=16191,Sn=16192,En=16194,In=16199,Tn=16200,On=16206,Cn=16209,vn=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Ln(){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 bn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<pn||t.mode>16211?1:0},An=e=>{if(bn(e))return ln;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=pn,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,cn},yn=e=>{if(bn(e))return ln;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,An(e)},Nn=(e,t)=>{let r;if(bn(e))return ln;const i=e.state;return t<0?(r=0,t=-t):(r=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?ln:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=r,i.wbits=t,yn(e))},Dn=(e,t)=>{if(!e)return ln;const r=new Ln;e.state=r,r.strm=e,r.window=null,r.mode=pn;const i=Nn(e,t);return i!==cn&&(e.state=null),i};let Pn,kn,Un=!0;const Mn=e=>{if(Un){Pn=new Int32Array(512),kn=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(nn(1,e.lens,0,288,Pn,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;nn(2,e.lens,0,32,kn,0,e.work,{bits:5}),Un=!1}e.lencode=Pn,e.lenbits=9,e.distcode=kn,e.distbits=5},wn=(e,t,r,i)=>{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)),i>=s.wsize?(s.window.set(t.subarray(r-s.wsize,r),0),s.wnext=0,s.whave=s.wsize):(n=s.wsize-s.wnext,n>i&&(n=i),s.window.set(t.subarray(r-i,r-i+n),s.wnext),(i-=n)?(s.window.set(t.subarray(r-i,r),0),s.wnext=i,s.whave=s.wsize):(s.wnext+=n,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=n))),0};var xn={inflateReset:yn,inflateReset2:Nn,inflateResetKeep:An,inflateInit:e=>Dn(e,15),inflateInit2:Dn,inflate:(e,t)=>{let r,i,n,s,o,a,c,_,d,l,u,h,g,R,p,m,f,S,E,I,T,O,C=0;const v=new Uint8Array(4);let L,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(bn(e)||!e.output||!e.input&&0!==e.avail_in)return ln;r=e.state,r.mode===fn&&(r.mode=Sn),o=e.next_out,n=e.output,c=e.avail_out,s=e.next_in,i=e.input,a=e.avail_in,_=r.hold,d=r.bits,l=a,u=c,O=cn;e:for(;;)switch(r.mode){case pn:if(0===r.wrap){r.mode=Sn;break}for(;d<16;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}if(2&r.wrap&&35615===_){0===r.wbits&&(r.wbits=15),r.check=0,v[0]=255&_,v[1]=_>>>8&255,r.check=Ar(r.check,v,2,0),_=0,d=0,r.mode=16181;break}if(r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&_)<<8)+(_>>8))%31){e.msg="incorrect header check",r.mode=Cn;break}if((15&_)!==Rn){e.msg="unknown compression method",r.mode=Cn;break}if(_>>>=4,d-=4,T=8+(15&_),0===r.wbits&&(r.wbits=T),T>15||T>r.wbits){e.msg="invalid window size",r.mode=Cn;break}r.dmax=1<<r.wbits,r.flags=0,e.adler=r.check=1,r.mode=512&_?16189:fn,_=0,d=0;break;case 16181:for(;d<16;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}if(r.flags=_,(255&r.flags)!==Rn){e.msg="unknown compression method",r.mode=Cn;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=Cn;break}r.head&&(r.head.text=_>>8&1),512&r.flags&&4&r.wrap&&(v[0]=255&_,v[1]=_>>>8&255,r.check=Ar(r.check,v,2,0)),_=0,d=0,r.mode=16182;case 16182:for(;d<32;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}r.head&&(r.head.time=_),512&r.flags&&4&r.wrap&&(v[0]=255&_,v[1]=_>>>8&255,v[2]=_>>>16&255,v[3]=_>>>24&255,r.check=Ar(r.check,v,4,0)),_=0,d=0,r.mode=16183;case 16183:for(;d<16;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}r.head&&(r.head.xflags=255&_,r.head.os=_>>8),512&r.flags&&4&r.wrap&&(v[0]=255&_,v[1]=_>>>8&255,r.check=Ar(r.check,v,2,0)),_=0,d=0,r.mode=16184;case 16184:if(1024&r.flags){for(;d<16;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}r.length=_,r.head&&(r.head.extra_len=_),512&r.flags&&4&r.wrap&&(v[0]=255&_,v[1]=_>>>8&255,r.check=Ar(r.check,v,2,0)),_=0,d=0}else r.head&&(r.head.extra=null);r.mode=16185;case 16185:if(1024&r.flags&&(h=r.length,h>a&&(h=a),h&&(r.head&&(T=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(i.subarray(s,s+h),T)),512&r.flags&&4&r.wrap&&(r.check=Ar(r.check,i,h,s)),a-=h,s+=h,r.length-=h),r.length))break e;r.length=0,r.mode=16186;case 16186:if(2048&r.flags){if(0===a)break e;h=0;do{T=i[s+h++],r.head&&T&&r.length<65536&&(r.head.name+=String.fromCharCode(T))}while(T&&h<a);if(512&r.flags&&4&r.wrap&&(r.check=Ar(r.check,i,h,s)),a-=h,s+=h,T)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=16187;case 16187:if(4096&r.flags){if(0===a)break e;h=0;do{T=i[s+h++],r.head&&T&&r.length<65536&&(r.head.comment+=String.fromCharCode(T))}while(T&&h<a);if(512&r.flags&&4&r.wrap&&(r.check=Ar(r.check,i,h,s)),a-=h,s+=h,T)break e}else r.head&&(r.head.comment=null);r.mode=16188;case 16188:if(512&r.flags){for(;d<16;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}if(4&r.wrap&&_!==(65535&r.check)){e.msg="header crc mismatch",r.mode=Cn;break}_=0,d=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=fn;break;case 16189:for(;d<32;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}e.adler=r.check=vn(_),_=0,d=0,r.mode=mn;case mn:if(0===r.havedict)return e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,r.hold=_,r.bits=d,dn;e.adler=r.check=1,r.mode=fn;case fn:if(t===on||t===an)break e;case Sn:if(r.last){_>>>=7&d,d-=7&d,r.mode=On;break}for(;d<3;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}switch(r.last=1&_,_>>>=1,d-=1,3&_){case 0:r.mode=16193;break;case 1:if(Mn(r),r.mode=In,t===an){_>>>=2,d-=2;break e}break;case 2:r.mode=16196;break;case 3:e.msg="invalid block type",r.mode=Cn}_>>>=2,d-=2;break;case 16193:for(_>>>=7&d,d-=7&d;d<32;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}if((65535&_)!=(_>>>16^65535)){e.msg="invalid stored block lengths",r.mode=Cn;break}if(r.length=65535&_,_=0,d=0,r.mode=En,t===an)break e;case En:r.mode=16195;case 16195:if(h=r.length,h){if(h>a&&(h=a),h>c&&(h=c),0===h)break e;n.set(i.subarray(s,s+h),o),a-=h,s+=h,c-=h,o+=h,r.length-=h;break}r.mode=fn;break;case 16196:for(;d<14;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}if(r.nlen=257+(31&_),_>>>=5,d-=5,r.ndist=1+(31&_),_>>>=5,d-=5,r.ncode=4+(15&_),_>>>=4,d-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=Cn;break}r.have=0,r.mode=16197;case 16197:for(;r.have<r.ncode;){for(;d<3;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}r.lens[A[r.have++]]=7&_,_>>>=3,d-=3}for(;r.have<19;)r.lens[A[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,L={bits:r.lenbits},O=nn(0,r.lens,0,19,r.lencode,0,r.work,L),r.lenbits=L.bits,O){e.msg="invalid code lengths set",r.mode=Cn;break}r.have=0,r.mode=16198;case 16198:for(;r.have<r.nlen+r.ndist;){for(;C=r.lencode[_&(1<<r.lenbits)-1],p=C>>>24,m=C>>>16&255,f=65535&C,!(p<=d);){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}if(f<16)_>>>=p,d-=p,r.lens[r.have++]=f;else{if(16===f){for(b=p+2;d<b;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}if(_>>>=p,d-=p,0===r.have){e.msg="invalid bit length repeat",r.mode=Cn;break}T=r.lens[r.have-1],h=3+(3&_),_>>>=2,d-=2}else if(17===f){for(b=p+3;d<b;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}_>>>=p,d-=p,T=0,h=3+(7&_),_>>>=3,d-=3}else{for(b=p+7;d<b;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}_>>>=p,d-=p,T=0,h=11+(127&_),_>>>=7,d-=7}if(r.have+h>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=Cn;break}for(;h--;)r.lens[r.have++]=T}}if(r.mode===Cn)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=Cn;break}if(r.lenbits=9,L={bits:r.lenbits},O=nn(1,r.lens,0,r.nlen,r.lencode,0,r.work,L),r.lenbits=L.bits,O){e.msg="invalid literal/lengths set",r.mode=Cn;break}if(r.distbits=6,r.distcode=r.distdyn,L={bits:r.distbits},O=nn(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,L),r.distbits=L.bits,O){e.msg="invalid distances set",r.mode=Cn;break}if(r.mode=In,t===an)break e;case In:r.mode=Tn;case Tn:if(a>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,r.hold=_,r.bits=d,Zi(e,u),o=e.next_out,n=e.output,c=e.avail_out,s=e.next_in,i=e.input,a=e.avail_in,_=r.hold,d=r.bits,r.mode===fn&&(r.back=-1);break}for(r.back=0;C=r.lencode[_&(1<<r.lenbits)-1],p=C>>>24,m=C>>>16&255,f=65535&C,!(p<=d);){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}if(m&&!(240&m)){for(S=p,E=m,I=f;C=r.lencode[I+((_&(1<<S+E)-1)>>S)],p=C>>>24,m=C>>>16&255,f=65535&C,!(S+p<=d);){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}_>>>=S,d-=S,r.back+=S}if(_>>>=p,d-=p,r.back+=p,r.length=f,0===m){r.mode=16205;break}if(32&m){r.back=-1,r.mode=fn;break}if(64&m){e.msg="invalid literal/length code",r.mode=Cn;break}r.extra=15&m,r.mode=16201;case 16201:if(r.extra){for(b=r.extra;d<b;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}r.length+=_&(1<<r.extra)-1,_>>>=r.extra,d-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=16202;case 16202:for(;C=r.distcode[_&(1<<r.distbits)-1],p=C>>>24,m=C>>>16&255,f=65535&C,!(p<=d);){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}if(!(240&m)){for(S=p,E=m,I=f;C=r.distcode[I+((_&(1<<S+E)-1)>>S)],p=C>>>24,m=C>>>16&255,f=65535&C,!(S+p<=d);){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}_>>>=S,d-=S,r.back+=S}if(_>>>=p,d-=p,r.back+=p,64&m){e.msg="invalid distance code",r.mode=Cn;break}r.offset=f,r.extra=15&m,r.mode=16203;case 16203:if(r.extra){for(b=r.extra;d<b;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}r.offset+=_&(1<<r.extra)-1,_>>>=r.extra,d-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=Cn;break}r.mode=16204;case 16204:if(0===c)break e;if(h=u-c,r.offset>h){if(h=r.offset-h,h>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=Cn;break}h>r.wnext?(h-=r.wnext,g=r.wsize-h):g=r.wnext-h,h>r.length&&(h=r.length),R=r.window}else R=n,g=o-r.offset,h=r.length;h>c&&(h=c),c-=h,r.length-=h;do{n[o++]=R[g++]}while(--h);0===r.length&&(r.mode=Tn);break;case 16205:if(0===c)break e;n[o++]=r.length,c--,r.mode=Tn;break;case On:if(r.wrap){for(;d<32;){if(0===a)break e;a--,_|=i[s++]<<d,d+=8}if(u-=c,e.total_out+=u,r.total+=u,4&r.wrap&&u&&(e.adler=r.check=r.flags?Ar(r.check,n,u,o-u):Lr(r.check,n,u,o-u)),u=c,4&r.wrap&&(r.flags?_:vn(_))!==r.check){e.msg="incorrect data check",r.mode=Cn;break}_=0,d=0}r.mode=16207;case 16207:if(r.wrap&&r.flags){for(;d<32;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}if(4&r.wrap&&_!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=Cn;break}_=0,d=0}r.mode=16208;case 16208:O=_n;break e;case Cn:O=un;break e;case 16210:return hn;default:return ln}return e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,r.hold=_,r.bits=d,(r.wsize||u!==e.avail_out&&r.mode<Cn&&(r.mode<On||t!==sn))&&wn(e,e.output,e.next_out,u-e.avail_out),l-=e.avail_in,u-=e.avail_out,e.total_in+=l,e.total_out+=u,r.total+=u,4&r.wrap&&u&&(e.adler=r.check=r.flags?Ar(r.check,n,u,e.next_out-u):Lr(r.check,n,u,e.next_out-u)),e.data_type=r.bits+(r.last?64:0)+(r.mode===fn?128:0)+(r.mode===In||r.mode===En?256:0),(0===l&&0===u||t===sn)&&O===cn&&(O=gn),O},inflateEnd:e=>{if(bn(e))return ln;let t=e.state;return t.window&&(t.window=null),e.state=null,cn},inflateGetHeader:(e,t)=>{if(bn(e))return ln;const r=e.state;return 2&r.wrap?(r.head=t,t.done=!1,cn):ln},inflateSetDictionary:(e,t)=>{const r=t.length;let i,n,s;return bn(e)?ln:(i=e.state,0!==i.wrap&&i.mode!==mn?ln:i.mode===mn&&(n=1,n=Lr(n,t,r,0),n!==i.check)?un:(s=wn(e,t,r,r),s?(i.mode=16210,hn):(i.havedict=1,cn)))},inflateInfo:"pako inflate (from Nodeca project)"};var Bn=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 Vn=Object.prototype.toString,{Z_NO_FLUSH:jn,Z_FINISH:Fn,Z_OK:Jn,Z_STREAM_END:Gn,Z_NEED_DICT:Hn,Z_STREAM_ERROR:Kn,Z_DATA_ERROR:$n,Z_MEM_ERROR:Wn}=Nr;function zn(e){this.options=yi({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 wi,this.strm.avail_out=0;let r=xn.inflateInit2(this.strm,t.windowBits);if(r!==Jn)throw new Error(yr[r]);if(this.header=new Bn,xn.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=ki(t.dictionary):"[object ArrayBuffer]"===Vn.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=xn.inflateSetDictionary(this.strm,t.dictionary),r!==Jn)))throw new Error(yr[r])}zn.prototype.push=function(e,t){const r=this.strm,i=this.options.chunkSize,n=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=t===~~t?t:!0===t?Fn:jn,"[object ArrayBuffer]"===Vn.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){for(0===r.avail_out&&(r.output=new Uint8Array(i),r.next_out=0,r.avail_out=i),s=xn.inflate(r,o),s===Hn&&n&&(s=xn.inflateSetDictionary(r,n),s===Jn?s=xn.inflate(r,o):s===$n&&(s=Hn));r.avail_in>0&&s===Gn&&r.state.wrap>0&&0!==e[r.next_in];)xn.inflateReset(r),s=xn.inflate(r,o);switch(s){case Kn:case $n:case Hn:case Wn:return this.onEnd(s),this.ended=!0,!1}if(a=r.avail_out,r.next_out&&(0===r.avail_out||s===Gn))if("string"===this.options.to){let e=Mi(r.output,r.next_out),t=r.next_out-e,n=Ui(r.output,e);r.next_out=t,r.avail_out=i-t,t&&r.output.set(r.output.subarray(e,e+t),0),this.onData(n)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(s!==Jn||0!==a){if(s===Gn)return s=xn.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},zn.prototype.onData=function(e){this.chunks.push(e)},zn.prototype.onEnd=function(e){e===Jn&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Ni(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};const{Deflate:Yn,deflate:qn,deflateRaw:Zn,gzip:Qn}=Yi;var Xn=Qn;const es=-1,ts="RongCloudSEIAI",rs=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})),is=(e,t,r)=>E(void 0,void 0,void 0,(function*(){const i=[],n=r.jwt||"";return new Promise(((r,s)=>{e.forEach((e=>E(void 0,void 0,void 0,(function*(){const s=`${e.detectorAddr.replace(/^(https?:\/\/)?/,"https://")}/rtc/detector/ping?t=${o=1e3,c=9999,o+Math.floor(Math.random()*(c-o))}`;var o,c;const _={jwt:n};200===(yield t.httpReq({url:s,body:JSON.stringify(_),timeout:5e3,method:a.POST})).status&&i.push(e.clusterId),r(i)}))))}))})),ns=(e,t)=>{var r;if(!t)return"";let i;try{i=JSON.parse(t.voipCallInfo||'{ "strategy": 0 }')}catch(r){return e.warn(T.L_MEDIA_SERVICE_PARSE_NAVI_CALLVOIP_INFO_O,`parse \`voipCallInfo\` of navi failed: ${t.voipCallInfo}`),""}if(0===i.strategy)return"";const n=null===(r=i.callEngine)||void 0===r?void 0:r.filter((e=>4===e.engineType));if(!n||0===n.length)return"";const s=n[0];return s.detectorManager?s.detectorManager:""};var ss;!function(e){e.OPEN="2",e.CLOSE="1"}(ss||(ss={}));function os(e){const t=e.method||a.GET,r=e.timeout||6e4,{headers:i,query:n,body:s,onProgress:o}=e,c=((e,t)=>{if(e=e.replace(/\?$/,""),!t)return e;const r=Object.keys(t).map((e=>`${e}=${t[e]}`)).filter((e=>!!e));return r.length?[e,r.join("&")].join("?"):e})(e.url,n),_=new XMLHttpRequest;if(_.open(t,c),i&&_.setRequestHeader)for(const e in i)_.setRequestHeader(e,i[e]);return function(e,t,r,i){return new Promise((n=>{e.onreadystatechange=()=>{i?2===e.readyState?n({data:e.responseText,status:e.status,xhr:e}):4===e.readyState?i(e.responseText,!0):3===e.readyState&&i(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(r)}))}(_,r,s,o)}const as=()=>({"Content-Type":"application/json;charset=UTF-8","Cache-Control":"no-cache",ClientType:`web|${Nt.browser}|${Nt.version}`,ClientVersion:"5.38.0-alpha.1","Client-Session-Id":rs(),"Request-Id":Date.now().toString()});class cs{constructor(e,t,r,i=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:r}),Object.defineProperty(this,"_timeout",{enumerable:!0,configurable:!0,writable:!0,value:i}),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()===c.CONNECTED&&this.isNededDetector()&&this.detectorMediaSever()}isNededDetector(){const e=this._context.getNaviInfo();if(!e)return!1;const t=ns(this._logger,e),r=e.jwt||"",i=Date.now();let n=!1;return 0===cs.detectorTime?n=!1:cs.detectValidMinute+cs.detectorTime<i&&(n=!0),!(!t||!r||this._msUrl||n)}detectorMediaSever(){this.clearMSList();const e=this._context.getNaviInfo();this._startDetector(e)}_startDetector(e){return E(this,void 0,void 0,(function*(){const{detectoraddrs:t,clientDetectMinute:r,status:i}=yield((e,t,r)=>E(void 0,void 0,void 0,(function*(){const i=ns(t,r);let n=120,s=0;const o={jwt:r.jwt||"",ipType:r.ipType||0},c=yield e.httpReq({url:`${i}/rtc/detector/servers`,body:JSON.stringify(o),headers:{"Content-Type":"application/json;charset=UTF-8","Cache-Control":"no-cache",ClientType:`web|${Nt.browser}|${Nt.version}`,ClientVersion:"5.38.0-alpha.1","Client-Session-Id":rs(),"Request-Id":Date.now().toString()},method:a.POST}),_=c.data&&JSON.parse(c.data).detectorAddrs||[];return n=c.data&&JSON.parse(c.data).clientDetectMinute,s=c.data&&JSON.parse(c.data).resultCode,{detectoraddrs:_,clientDetectMinute:n,status:s}})))(this._runtime,this._logger,e);if(i===I.JWT_TIME_OUT){const e=this._context.getPluginContext();return yield e.refetchNaviInfo(),void this.detectorMediaSever()}t.length&&(cs.msInDetector=yield is(t,this._runtime,e)),cs.detectorTime=Date.now(),cs.detectValidMinute=60*r*1e3}))}clearMSList(){this._msList.length=0}getMsList(){return this._msUrl?[this._msUrl]:(this._sortMediaServiceList(),[...this._msList])}_sortMediaServiceList(){let e=cs.msInDetector[0];const t=cs.msInDetector.slice(1),r=((e,t)=>{var r;if(!e)return[];let i;try{i=JSON.parse(e.voipCallInfo||'{ "strategy": 0 }')}catch(r){return t.warn(T.L_PARSE_VOIP_SERVER_CONF_E,e.voipCallInfo),[]}if(0===i.strategy)return[];const n=null===(r=i.callEngine)||void 0===r?void 0:r.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),i=r[0],n=r.slice(1);const s=[this._clusterId,e,i,...t,...n].filter((e=>!!e)).map((e=>e.replace(/^(https?:\/\/)?/,"https://")));this._msList=[...new Set(s)],this._logger.info(T.L_MEDIA_SERVICE_MSLIST_CHANGE_O,`MediaServiceList msList -> ${JSON.stringify(this._msList)}`)}_openGzip(e,t){const r=JSON.stringify(t),i=r.length,n=new Uint8Array(i);for(let e=0;e<i;e++)n[e]=r.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=Xn(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:I.SUCCESS,data:t,qualityMsList:this._qualityMsList}}_request(e,t,r,i,n,s){return E(this,void 0,void 0,(function*(){this._qualityMsList=[];const{headers:o,body:c}={headers:t,body:r},_=this.getMsList();if(0===_.length)return this._logger.error(T.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:O.FAILED,code:I.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"have no valid service address"}),i),{code:I.NOT_OPEN_VIDEO_AUDIO_SERVER};this._rtcFinger&&(c.rtcFinger=this._rtcFinger);for(let t=0;t<_.length;t+=1){const r=Date.now(),d=`${_[t]}${e}`,l=as(),u=Object.assign(Object.assign({},l),o),h=/x-www-form-urlencoded/.test(u["Content-Type"])?c:JSON.stringify(c),g=l["Request-Id"];let R;this._logger.info(T.L_MEDIA_SERVICE_REQUEST_T,JSON.stringify({url:d,"Request-Id":g}),i);const p={url:d,body:h,headers:u,method:a.POST,timeout:this._timeout};R=s?yield os(Object.assign(Object.assign({},p),{onProgress:s})):yield this._runtime.httpReq(Object.assign({},p));const{status:m,data:f,xhr:S}=R;if(n&&this._qualityMsList.push({rsdur:Date.now()-r,rsid:g,rscod:200===m?I.SUCCESS:I.REQUEST_FAILED,msa:d}),200===m)return this._logger.info(T.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:O.SUCCESSED,url:d}),i),s?{code:I.SUCCESS,data:S}:this._dealRequestSuccessResult(f);this._logger.error(T.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:O.FAILED,msg:`request error -> Request-Id: ${g}, status: ${m}, url: ${d}`,timeout:this._timeout}),i)}return{code:I.REQUEST_FAILED,qualityMsList:this._qualityMsList}}))}exchange(e,t,r,i){var n;return E(this,void 0,void 0,(function*(){const s=yield this._request("/exchange",e,t,r,i);if(s.code===I.SUCCESS&&(null===(n=s.data)||void 0===n?void 0:n.resultCode)===I.SUCCESS){const{urls:e}=s.data;e&&(this._configUrl=e.configUrl)}return s}))}exit(e){return E(this,void 0,void 0,(function*(){const t=this._logger.createTraceId(),{code:r}=yield this._request("/exit",e,{},t);return r}))}broadcastSubscribe(e,t){const r=this._logger.createTraceId();return this._request("/broadcast/subscribe",e,t,r,!0)}broadcastExit(e){return E(this,void 0,void 0,(function*(){const t=this._logger.createTraceId(),{code:r}=yield this._request("/broadcast/exit",e,{},t,!0);return{code:r}}))}setMcuConfig(e,t){return E(this,void 0,void 0,(function*(){const r=this._logger.createTraceId();if(this._logger.info(T.L_MEDIA_SERVICE_SET_MCU_CONFIG_T,JSON.stringify({body:t}),r),!this._configUrl)return this._logger.error(T.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:O.FAILED,code:I.MCU_SERVER_NOT_FOUND,msg:"MCU server not found"}),r),{code:I.MCU_SERVER_NOT_FOUND};const i=`${this._configUrl.replace(/^(https?:\/\/)?/,"https://")}/server/mcu/config`,n=as(),s=Object.assign(Object.assign({},n),e),o=JSON.stringify(t),c=n["Request-Id"],{status:_,data:d}=yield this._runtime.httpReq({url:i,headers:s,body:o,method:a.POST});if(200===_){const e=JSON.parse(d),t=e.resultCode;return t===I.SUCCESS?this._logger.info(T.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:O.SUCCESSED,"Request-Id":c}),r):this._logger.warn(T.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({code:t,"Request-Id":c}),r),{code:t,res:e}}return this._logger.error(T.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:O.FAILED,code:I.REQUEST_FAILED,msg:`request error -> Request-Id: ${c}, status: ${_}, url: ${i}`}),r),{code:I.REQUEST_FAILED}}))}getCDNResourceInfo(e,t,r){return E(this,void 0,void 0,(function*(){const i=as(),n=Object.assign(Object.assign({},i),e),s=i["Request-Id"];this._logger.info(T.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_T,`Request-Id: ${s}, url: ${t}`,r);const{status:o,data:c}=yield this._runtime.httpReq({url:t,headers:n,method:a.GET});if(200===o){const e=JSON.parse(c);return this._logger.info(T.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_R,JSON.stringify({status:O.SUCCESSED,cdnPlayerUrl:null==e?void 0:e.data.pull_url}),r),{code:e.resultCode,res:e}}return this._logger.info(T.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_R,JSON.stringify({status:O.FAILED,code:I.REQUEST_FAILED}),r),{code:I.REQUEST_FAILED}}))}updateASRStatus(e,t,r){return E(this,void 0,void 0,(function*(){return yield this._request("/rtc/media/v1/asr/update",e,t,r)}))}operateRealtimeTranslation(e,t,r){return E(this,void 0,void 0,(function*(){return yield this._request("/rtc/media/v1/asr/translation",e,t,r)}))}operateSummarization(e,t,r){return E(this,void 0,void 0,(function*(){const i="/rtc/media/v1/ai/room/sum/"+(t.status===ss.OPEN?"start":"stop");return yield this._request(i,e,t,r)}))}generateSummarization(e,t,r,i,n,s,o){return E(this,void 0,void 0,(function*(){const a={"App-Key":this._context.getAppkey(),UserId:this._context.getCurrentId(),RoomId:e,"X-Stream":!0},c={taskId:t,startTime:r,endTime:i,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:d}=yield this._request("/rtc/media/v1/ai/room/sum/gen",a,c,o,!1,((e,t)=>{s(e,t)})),l=null==d?void 0:d.getResponseHeader("x-code"),u=null==d?void 0:d.getResponseHeader("x-msg");return _===I.SUCCESS&&l&&Number(l)!==I.SUCCESS?{code:Number(l),msg:u}:{code:_}}))}getASRContent(e,t,r,i,n,s,o){return E(this,void 0,void 0,(function*(){const a={"App-Key":this._context.getAppkey(),UserId:this._context.getCurrentId(),RoomId:e,"X-Stream":!0},c={taskId:t,startTime:r,endTime:i,language:o},{code:_,data:d}=yield this._request("/rtc/media/v1/ai/room/sum/asr",a,c,s,!1,((e,t)=>{n(e,t)})),l=null==d?void 0:d.getResponseHeader("x-code"),u=null==d?void 0:d.getResponseHeader("x-msg");return _===I.SUCCESS&&l&&Number(l)!==I.SUCCESS?{code:Number(l),msg:u}:{code:_}}))}}var _s;Object.defineProperty(cs,"msInDetector",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(cs,"detectorTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(cs,"detectValidMinute",{enumerable:!0,configurable:!0,writable:!0,value:72e5}),function(e){e[e.NORMAL=1]="NORMAL",e[e.TINY=2]="TINY"}(_s||(_s={}));const ds=(e,t)=>Math.round(8*t/e),ls=(e,t=2)=>{const r=10**t;return Math.round(e*r)/r},us=(e,t=2)=>{e>1&&(e=1);const r=10**t;return Math.round(e*r)},hs=(e,t,r,i)=>{if(0===t)return 0;if(!r||!i)return ls(e/t,3);const n=t-i;if(0===n)return 0;const s=e-r;return s<0||n<0?0:ls(s/n,3)},gs=e=>{const{jitter:t,rtt:r,packetsLostRate:i}=e;return!kt(t)||!kt(r)||0!==i};var Rs,ps;!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"}(Rs||(Rs={}));class ms{constructor(e,t,r,i,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:r}),Object.defineProperty(this,"_sdpSemantics",{enumerable:!0,configurable:!0,writable:!0,value:i}),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,r){let i,n;if(this._latestBytesSent[e]&&t<this._latestBytesSent[e].bytesSent&&this.clearLatestpacketsSent([e]),this._latestBytesSent[e]){const{bytesSent:s,timestamp:o}=this._latestBytesSent[e];i=t-s,n=r-o,this._latestBytesSent[e]={bytesSent:t,timestamp:r}}else i=t,n=1e3,this._latestBytesSent[e]={bytesSent:t,timestamp:r};return ds(n,i)}updateBytesRecv(e,t,r){let i,n;if(this._latestBytesRecv[e]&&t<this._latestBytesRecv[e].bytesRecv&&this.clearLatestPacketsRecv([e]),this._latestBytesRecv[e]){const{bytesRecv:s,timestamp:o}=this._latestBytesRecv[e];i=t-s,n=r-o,this._latestBytesRecv[e]={bytesRecv:t,timestamp:r}}else i=t,n=1e3,this._latestBytesRecv[e]={bytesRecv:t,timestamp:r};return ds(n,i)}updateSenderPacketsLost(e,t,r){let i;if(Object.prototype.hasOwnProperty.call(this._latestPacketsSent[e],"packetsSent")){const{packetsLost:n,packetsSent:s}=this._latestPacketsSent[e];i=hs(t,r,n,s),this._latestPacketsSent[e].packetsLost=t,this._latestPacketsSent[e].packetsSent=n===t?s:r}else i=hs(t,r),this._latestPacketsSent[e].packetsLost=t,this._latestPacketsSent[e].packetsSent=r;return i}updateReceiverPacketsLost(e,t,r){let i;if(this._latestPacketsRecv[e]){const{packetsLost:n,packetsRecv:s}=this._latestPacketsRecv[e];i=hs(t,r+t,n,s+n)}else i=hs(t,r);return this._latestPacketsRecv[e]={packetsLost:t,packetsRecv:r},i}clearLatestpacketsSent(e){e.forEach((e=>{if(parseInt(e.split("_").pop())===je.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[r,i]of e.entries())/codec/gi.test(i)&&r.includes("RTCCodec_")||(t[r]=i);return t}formatRCRTCStateReport(e){const t={senders:[],receivers:[]};return this._logger.info(T.L_ABSTRACT_STAT_PARSER_FORMAT_RTC_STATE_REPORT_O,JSON.stringify({status:O.SUCCESSED,stats:e,reports:t})),t}isValidTranceiver(e,t){var r,i;const n="outbound-rtp"===t?null===(r=this._rtcPeerConn.currentLocalDescription)||void 0===r?void 0:r.sdp:null===(i=this._rtcPeerConn.currentRemoteDescription)||void 0===i?void 0:i.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===Rs.REMOTEINBOUNDRTP?(e.remoteInbound.push(t),e):t.type===Rs.INBOUNDRTP?(e.inbound.push(t),e):t.type===Rs.OUTBOUNDRTP?(e.outbound.push(t),e):t.type===Rs.TRANSPORT?(e.transport.push(t),e):t.type===Rs.PEERCONNECTION?(e.connection.push(t),e):e),{outbound:[],remoteInbound:[],inbound:[],transport:[],connection:[]})}}class fs extends ms{formatRCRTCStateReport(e){const{outbound:t,remoteInbound:r,inbound:i,transport:n,connection:s}=this.formatStateData(e),o={senders:[],receivers:[]},a=Math.floor(s[0].timestamp);o.timestamp=a;let c=0,_=0;({totalPacketsLost:c,bitrateSend:_,senders:o.senders}=this.pickOutbound(t,e,c,a,_)),r.length>0&&o.senders.length>0&&this.pickRemoteInbound(r,o.senders,e);let d=0;if(({totalPacketsLost:c,bitrateRecv:d,receivers:o.receivers}=this.pickInbound(i,e,c,a,d)),n.length>0){const t=n[0];this.pickRtcTransport(t,e,o,d,_,c)}return o}pickRtcTransport(e,t,r,i,n,s){const{selectedCandidatePairId:o}=e;if(o){const e=t[o],{availableOutgoingBitrate:a,availableIncomingBitrate:c,currentRoundTripTime:_,localCandidateId:d,remoteCandidateId:l}=e,u=t[d],{ip:h,port:g,networkType:R}=u,p=t[l],{ip:m,port:f,protocol:S}=p;r.iceCandidatePair={IP:h,port:g,networkType:R,remoteIP:m,remotePort:f,protocol:S,bitrateRecv:i,bitrateSend:n,rtt:1e3*_,availableOutgoingBitrate:a,availableIncomingBitrate:c,totalPacketsLost:s},r.receivers.forEach((e=>{e.rtt=1e3*_}))}}pickRemoteInbound(e,t,r){e.forEach((e=>{var i;const{localId:n,jitter:s,roundTripTime:o,packetsLost:a}=e,c=t.filter((e=>e.id===n))[0];if(c&&!gs(c)){const e=null===(i=this._store)||void 0===i?void 0:i.getTrackIdBySSRC(r[c.id].ssrc);c.jitter=Math.round(1e3*s),c.rtt=o;const t=this._latestPacketsSent[e].crtPacketsSent;c.packetsLostRate=this.updateSenderPacketsLost(e,a,t)}}))}_getOutboundVideoAttrs(e,t,r,i,n){var s,o,a;let{framesPerSecond:c,frameWidth:_,frameHeight:d}=e;return"video"!==r||_||d||c||(_=(null===(s=t[i])||void 0===s?void 0:s.frameWidth)||t[n].width,d=(null===(o=t[i])||void 0===o?void 0:o.frameHeight)||t[n].height,c=(null===(a=t[n])||void 0===a?void 0:a.framesPerSecond)||null),{frameRate:c,frameWidth:_,frameHeight:d}}pickOutbound(e,t,r,i,n){const s=[];return e.forEach((e=>{var o;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,"outbound-rtp"))return;const{id:a,kind:c,mediaSourceId:_,remoteId:d,packetsSent:l,bytesSent:u,encoderImplementation:h,pliCount:g,nackCount:R,mid:p}=e;let{trackId:m}=e;if(void 0!==p&&(m=this.getTrackIdByMid(p)),!m)return;const{frameRate:f,frameWidth:S,frameHeight:E}=this._getOutboundVideoAttrs(e,t,c,m,_),I=t[d];let T=null,O=null,C=0;I&&(T=I.jitter,O=I.roundTripTime,C=I.packetsLost),r+=C;const v=null===(o=this._store)||void 0===o?void 0:o.getTrackIdBySSRC(e.ssrc);if(!v)return;const L=_?t[_].audioLevel:t[m].audioLevel;let b=0;!this._latestPacketsSent[v]&&(this._latestPacketsSent[v]={}),I?b=this.updateSenderPacketsLost(v,C,l):this._latestPacketsSent[v].crtPacketsSent=l;let A=this.updateBytesSent(v,u,i);A<0&&(A=0),n+=A,s.push({id:a,trackId:v,kind:c,packetsLostRate:b,remoteResource:!1,audioLevel:L||0===L?us(L):null,frameWidth:S,frameHeight:E,frameRate:f,bitrate:A,jitter:T?Math.round(1e3*T):T,rtt:O?Math.round(1e3*O):O,encoderImplementation:h,pliCount:g,nackCount:R,googFirsSent:es,samplingRate:es,googRenderDelayMs:es,trackState:es})})),{totalPacketsLost:r,bitrateSend:n,senders:s}}_getInboundMediaAttrs(e,t,r,i,n){var s,o,a;let{frameWidth:c,frameHeight:_,audioLevel:d}=e;return"video"===n?c||_||(c=(null===(s=t[r])||void 0===s?void 0:s.frameWidth)||t[i].width,_=(null===(o=t[r])||void 0===o?void 0:o.frameHeight)||t[i].height):d||(d=(null===(a=t[r])||void 0===a?void 0:a.audioLevel)||t[i].audioLevel),{frameWidth:c,frameHeight:_,audioLevel:d}}pickInbound(e,t,r,i,n){let s=[];return e.forEach((e=>{var o;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,"inbound-rtp"))return;const{packetsLost:a,packetsReceived:c,jitter:_,bytesReceived:d,framesPerSecond:l,kind:u,codecImplementationName:h,nackCount:g,pliCount:R,mid:p,id:m}=e;let{trackId:f}=e;if(void 0!==p&&(f=this.getTrackIdByMid(p)),!f)return;const{frameWidth:S,frameHeight:E,audioLevel:I}=this._getInboundMediaAttrs(e,t,f,m,u);r+=a;const T=null===(o=this._store)||void 0===o?void 0:o.getTrackIdBySSRC(e.ssrc),O=this.updateReceiverPacketsLost(T,a,c);let C=this.updateBytesRecv(T,d,i);C<0&&(C=0),n+=C,s.push({trackId:T,kind:u,packetsLostRate:O,remoteResource:!0,audioLevel:I||0===I?us(I):null,frameWidth:S,frameHeight:E,frameRate:l,bitrate:C,jitter:_?Math.round(1e3*_):0,codecImplementationName:h,nackCount:g,pliCount:R,rtt:null,samplingRate:es,googFirsReceived:es,googRenderDelayMs:es,trackState:es})})),{totalPacketsLost:r,bitrateRecv:n,receivers:s}}}class Ss extends ms{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,r){var i;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,r))return;const{kind:n,bytesSent:s,packetsSent:o,bitrateMean:a,framerateMean:c,nackCount:_,pliCount:d,remoteId:l}=e,{jitter:u,roundTripTime:h,packetsLost:g}=l?t[l]:{jitter:null,roundTripTime:null,packetsLost:0},R=null===(i=this._store)||void 0===i?void 0:i.getTrackIdBySSRC(e.ssrc);this._totalPacketsLost+=g;let p=0;!this._latestPacketsSent[R]&&(this._latestPacketsSent[R]={}),l?p=this.updateSenderPacketsLost(R,g,o):this._latestPacketsSent[R].crtPacketsSent=o;let m=0;"video"===n?a&&(m=Math.floor(a/1e3)):m=this.updateBytesSent(R,s,this._reportsData.timestamp),m<0&&(m=0),this._bitrateSend+=m,this._reportsData.senders.push({trackId:R,kind:n,packetsLostRate:p,remoteResource:!1,audioLevel:null,frameWidth:null,frameHeight:null,frameRate:Math.floor(c),bitrate:m,jitter:u?Math.round(1e3*u):null,rtt:h,encoderImplementation:null,pliCount:d,nackCount:_,googFirsSent:es,samplingRate:es,googRenderDelayMs:es,trackState:es})}_addSenderData(e,t){var r;const{localId:i}=t,n=null===(r=this._store)||void 0===r?void 0:r.getTrackIdBySSRC(e[i].ssrc),s=this._reportsData.senders.filter((e=>e.trackId===n))[0];s&&gs(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 r;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,t))return;const{packetsLost:i,bytesReceived:n,packetsReceived:s,jitter:o,framerateMean:a,kind:c,bitrateMean:_,nackCount:d,pliCount:l}=e,u=null===(r=this._store)||void 0===r?void 0:r.getTrackIdBySSRC(e.ssrc);this._totalPacketsLost+=i;const h=this.updateReceiverPacketsLost(u,i,s);let g=0;"video"===c?_&&(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:c,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:d,pliCount:l,rtt:null,samplingRate:es,googFirsReceived:es,googRenderDelayMs:es,trackState:es})}_pickIceCandidatePair(e,t){const r=e[t.localCandidateId],{address:i,port:n}=r,s=e[t.remoteCandidateId],{address:o,port:a,protocol:c}=s;this._reportsData.iceCandidatePair={IP:i,port:n,networkType:null,remoteIP:o,remotePort:a,protocol:c,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 r=e[t],{type:i}=r;"outbound-rtp"===i&&this._pickSenderData(r,e,i),"remote-inbound-rtp"===i&&this._addSenderData(e,r),"inbound-rtp"===i&&this._pickReceiverData(r,i),"candidate-pair"===i&&"succeeded"===r.state&&this._pickIceCandidatePair(e,r)}return this._reportsData}}class Es extends ms{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:r,packetsReceived:i,jitter:n,bytesReceived:s,kind:o,nackCount:a,pliCount:c,audioLevel:_,frameHeight:d,frameWidth:l}=e,u=null===(t=this._store)||void 0===t?void 0:t.getTrackIdBySSRC(e.ssrc);if(!u)return;this._totalPacketsLost+=r;const h=this.updateReceiverPacketsLost(u,r,i);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===_?us(_):null,frameWidth:l,frameHeight:d,frameRate:null,bitrate:g,jitter:n?Math.round(1e3*n):n,codecImplementationName:null,nackCount:a,pliCount:c,rtt:null,samplingRate:es,googFirsReceived:es,googRenderDelayMs:es,trackState:es})}))}_pickSenderData(e,t){e.forEach((e=>{var r;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,"outbound-rtp"))return;const i=null===(r=this._store)||void 0===r?void 0:r.getTrackIdBySSRC(e.ssrc),{kind:n,bytesSent:s,pliCount:o,nackCount:a,audioLevel:c,frameHeight:_,frameWidth:d,codecId:l,remoteId:u,packetsSent:h}=e;if(!i)return;const g=t[u];let R=null,p=null,m=0;g&&(R=g.jitter,p=g.roundTripTime,m=g.packetsLost),this._totalPacketsLost+=m;let f=0;!this._latestPacketsSent[i]&&(this._latestPacketsSent[i]={}),g?f=this.updateSenderPacketsLost(i,m,h):this._latestPacketsSent[i].crtPacketsSent=h;let S=this.updateBytesSent(i,s,this._reportsData.timestamp);S<0&&(S=0),this._bitrateSend+=S,this._reportsData.senders.push({trackId:i,kind:n,packetsLostRate:f,remoteResource:!1,audioLevel:c||0===c?us(c):null,frameWidth:d,frameHeight:_,frameRate:null,bitrate:S,jitter:R?Math.round(1e3*R):R,rtt:p?Math.round(1e3*p):p,encoderImplementation:t[l].mimeType,pliCount:o,nackCount:a,googFirsSent:es,samplingRate:es,googRenderDelayMs:es,trackState:es})}))}_pickIceCandidatePair(e,t){const{selectedCandidatePairId:r}=e;if(r){const e=t[r],{availableOutgoingBitrate:i,availableIncomingBitrate:n,currentRoundTripTime:s,localCandidateId:o,remoteCandidateId:a}=e,c=t[o],{address:_,port:d}=c,l=t[a],{address:u,port:h,protocol:g}=l;this._reportsData.iceCandidatePair={IP:_||null,port:d,networkType:null,remoteIP:u,remotePort:h,protocol:g,bitrateRecv:this._bitrateRecv,bitrateSend:this._bitrateSend,rtt:1e3*s,availableOutgoingBitrate:i,availableIncomingBitrate:n,totalPacketsLost:this._totalPacketsLost},this._reportsData.receivers.forEach((e=>{e.rtt=1e3*s}))}}formatRCRTCStateReport(e){const{outbound:t,inbound:r,transport:i,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(r,e),i.length>0){const t=i[0];this._pickIceCandidatePair(t,e)}return this._reportsData}}class Is{constructor(e,t,r){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:r}),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 i=this.getStreamIndex();this.spliteStreams(i)}get videoSdps(){return this.videoStreams.slice()}get audioSdps(){return this.audioStreams.slice()}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 r=e.exec(this.SDP);for(;null!==r;)t.add(null==r?void 0:r.index),r=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 r=this.SDP.substring(e[t],e[t+1]);/^\bm=video\b/.test(r)?this.videoStreams.push(r):this.audioStreams.push(r)}}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*Is.KBitrate}\r\nb=TIAS:${e*Is.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((r=>new RegExp(`\\bmsid:${t}\\b`,"ig").test(r)?this.setAudioItemBitrate(r,e):r)),this}setAudioBitrateWithMid(e,t){return this.audioStreams=this.audioStreams.map((r=>new RegExp(`\\bmid:${t}\\b`,"ig").test(r)?this.setAudioItemBitrate(r,e):r)),this}setAudioItemBitrate(e,t){if(0===t.max&&/\ba=inactive\b/gi.test(e))return e;if(!/\bmaxaveragebitrate\b/gi.test(e)){const r=["$1","maxaveragebitrate="+t.max*Is.KBitrate*1e3];e=e.replace(/(\buseinbandfec=[^\r\n]+)/gi,r.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*Is.KBitrate}\r\nb=TIAS:${t.max*Is.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((r=>new RegExp(`\\bmsid:${t}\\b`,"ig").test(r)?this.setVideoItemBitrate(r,e):r)),this}setVideoBitrateWithMid(e,t){return this.videoStreams=this.videoStreams.map((r=>new RegExp(`\\bmid:${t}\\b`,"ig").test(r)?this.setVideoItemBitrate(r,e):r)),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 r=["$1","x-google-max-bitrate="+t.max*Is.KBitrate,"x-google-min-bitrate="+t.min*Is.KBitrate,`x-google-start-bitrate=${t.start||t.max*Is.KBitrate*.7}`];e=e.replace(/(\bprofile-level-id=42[e0]01f\b)/gi,r.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*Is.KBitrate}\r\nb=TIAS:${t.max*Is.KBitrate*850}`)}clearnSsrcWithMid(e,t){return this.audioStreams=this.audioStreams.map((r=>new RegExp(`\\bmid:${e}\\b`,"ig").test(r)?this.clearSSRC(r,t):r)),this.videoStreams=this.videoStreams.map((r=>new RegExp(`\\bmid:${e}\\b`,"ig").test(r)?this.clearSSRC(r,t):r)),this}clearSSRC(e,t){if(t===bs.SENDONLY){if(/\ba=sendonly\b/.test(e))return e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,"")}if(t===bs.RECVONLY){if(/\ba=recvonly\b/.test(e))return e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,"")}if(t===bs.INACTIVE){if(/\ba=inactive\b/.test(e))return e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,"")}return e}}Object.defineProperty(Is,"KBitrate",{enumerable:!0,configurable:!0,writable:!0,value:1});class Ts{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(T.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(T.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(T.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(T.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"}(ps||(ps={})),ps.NB,ps.NB,ps.NB,ps.NB,ps.MB,ps.MB,ps.MB,ps.MB,ps.WB,ps.WB,ps.WB,ps.WB,ps.SWB,ps.SWB,ps.FB,ps.FB,ps.NB,ps.NB,ps.NB,ps.NB,ps.WB,ps.WB,ps.WB,ps.WB,ps.SWB,ps.SWB,ps.SWB,ps.SWB,ps.FB,ps.FB,ps.FB,ps.FB;class Os{static splitSections(e){return e.split("\nm=").map(((e,t)=>`${(t>0?`m=${e}`:e).trim()}\r\n`))}static getMediaSections(e){const t=Os.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=Os.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 Os.splitLines(e).filter((e=>0===e.indexOf(t)))}static parseMsid(e){let t;const r=Os.matchPrefix(e,"a=msid:");if(1===r.length)return t=r[0].substr(7).split(" "),{stream:t[0],track:t[1]};const i=Os.matchPrefix(e,"a=ssrc:").map((e=>Os.parseSsrcMedia(e))).filter((e=>"msid"===e.attribute));return i.length>0&&i[0].value?(t=i[0].value.split(" "),{stream:t[0],track:t[1]}):{stream:"",track:""}}static parseSsrcMedia(e){const t=e.indexOf(" "),r={ssrc:parseInt(e.substr(7,t-7),10)},i=e.indexOf(":",t);return i>-1?(r.attribute=e.substr(t+1,i-t-1),r.value=e.substr(i+1)):r.attribute=e.substr(t+1),r}static getMid(e){const t=Os.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)}static splitNaluData(e){const t=new Uint8Array(e);let r=0;if(this.isIFrame(t)){const e=t.join(",");let i=e.indexOf("0,0,0,1,101");-1===i&&(i=e.indexOf("0,0,0,1,37"));r=e.substring(0,i).split(",").length-1+4+8}else r=12;return{header:t.slice(0,r),payloadData:t.slice(r)}}static deal0x03(e,t){let r=[];return r="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(r)}static isIFrame(e){let t=e.join("").startsWith("0001103");return t||(t=e.join("").startsWith("000139")),t}static parsePayloadTypes(e){const t=Os.getMediaSections(e).find((e=>"audio"===Os.parseMLine(e).kind));if(!t)return;const r=t.match(/a=rtpmap:(\d+)\s+(\S+)/g);r&&(Os.payloadTypeCodecMap=r.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(Os,"payloadTypeCodecMap",{enumerable:!0,configurable:!0,writable:!0,value:[]});function Cs(e,t){let r=0,i=t;for(;i<e.length;){const t=e[i];if(r+=t,i++,255!==t)break}return{value:r,nextOffset:i}}function vs(e,t){if(t>=e.length)return null;const r=Cs(e,t),i=r.value;let n=r.nextOffset;const s=Cs(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),c=n+16,_=o-16;let d=e.slice(c,c+_);return d.length>=2&&0===d[d.length-2]&&128===d[d.length-1]?d=d.slice(0,d.length-2):d.length>=1&&128===d[d.length-1]&&(d=d.slice(0,d.length-1)),5===i?{payloadSize:o,uuid:a,content:d}:null}var Ls,bs,As,ys,Ns,Ds,Ps,ks,Us;!function(e){e.PLANB="plan-b",e.UNIFIEDPLAN="unified-plan"}(Ls||(Ls={})),function(e){e.SENDONLY="sendonly",e.RECVONLY="recvonly",e.INACTIVE="inactive"}(bs||(bs={}));class Ms{constructor(e,t,r,i){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:r}),Object.defineProperty(this,"_useEncrypt",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_onReceiveSeiListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_outboundStreams",{enumerable:!0,configurable:!0,writable:!0,value:{}})}static setSdpSemantics(e,t){const{browser:r,version:i,supportsUnifiedPlan:n}=Nt;if(t.info(T.L_A_SDP_STRATEGY_SET_SDP_SEMANTICS_O,JSON.stringify({sdpSemantics:e,supportsUnifiedPlan:n,browser:r,version:i})),n)return/chrome/i.test(r)?i?void(this._sdpSemantics=i>92?"unified-plan":i<72?"plan-b":e):void(this._sdpSemantics="unified-plan"):void(/firefox/i.test(r)?this._sdpSemantics="unified-plan":/safari/i.test(r)?this._sdpSemantics=i<12?"plan-b":"unified-plan":this._sdpSemantics="unified-plan");this._sdpSemantics="plan-b"}static getSdpSemantics(){return Ms._sdpSemantics}setReceiveSeiListener(e){this._onReceiveSeiListener=e}getOutboundVideoInfo(){const e=[];for(const t in this._outboundStreams){const r=this._outboundStreams[t].getVideoTracks()[0];if(!r)continue;const i=/_tiny$/.test(t),{width:n,height:s}=ft(r);e.push({trackId:r.id,simulcast:i?_s.TINY:_s.NORMAL,resolution:`${n}x${s}`})}return e}setRemoteAnswer(e){return E(this,void 0,void 0,(function*(){e=Is.trimBlankLine(e);try{yield this._peer.setRemoteDescription({type:"answer",sdp:e})}catch(e){return this._logger.info(T.L_A_SDP_STRATEGY_SET_REMOTE_ANSWER_O,JSON.stringify({status:O.FAILED,msg:e})),I.SET_REMOTE_DESCRIPTION_FAILED}return this._logger.info(T.L_A_SDP_STRATEGY_SET_REMOTE_ANSWER_O,JSON.stringify({status:O.SUCCESSED,sdp:e})),I.SUCCESS}))}getStatParsr(e,t,r,i){return/chrome/i.test(Nt.browser)?new fs(this,e,this._logger,t,r,i):/Firefox/i.test(Nt.browser)?new Ss(this,e,this._logger,t,r,i):/Safari/i.test(Nt.browser)?new Es(this,e,this._logger,t,r,i):null}getTrackIdByMid(e){return null}resetSdp(e){return Is.trimBlankLine(e)}_setupSenderTransform(e){if(!this._useEncrypt)return;if(!Bt())return void this._logger.warn(T.L_A_SDP_STRATEGY_SET_SENDER_TRANSFORM_O,"not support encrypt");const t=e.createEncodedStreams(),{readable:r,writable:i}=t,n=new TransformStream({transform:this._encodeRtpChunk.bind(this,e)});r.pipeThrough(n).pipeTo(i)}_setupReceiverTransform(e){if(!Bt())return void this._logger.warn(T.L_A_SDP_STRATEGY_SET_RECEIVER_TRANSFORM_O,"not support encrypt");const t=e.createEncodedStreams(),{readable:r,writable:i}=t,n=new TransformStream({transform:this._decodeRtpChunk.bind(this,e)});r.pipeThrough(n).pipeTo(i)}_encodeVideoFrame(e){const{header:t,payloadData:r}=Os.splitNaluData(e),i=Ts.encodeVideo(r),n=Os.deal0x03(i,"encode");return new Uint8Array([...t,...n]).buffer}_decodeVideoFrame(e){var t;const r=new Uint8Array(e),i=r.join(",").indexOf("0,0,0,1,6,5");if(-1!==i&&r.join(",").includes("84,128,131,151,240,35,71,75,183,247,79,50,181,78,6,172")){const n=r.join(",").slice(i);return null===(t=this._onReceiveSeiListener)||void 0===t||t.call(this,n),e}if(!this._useEncrypt)return e;const{header:n,payloadData:s}=Os.splitNaluData(e),o=Os.deal0x03(s,"decode"),a=Ts.decodeVideo(o);return new Uint8Array([...n,...a]).buffer}_handleAudioREDFrame(e,t){const r=function(e){const t=[];let r=0;for(;;){let i,n,s,o,a=!(e[r]>>7),c=127&e[r];if(a?(i=0,n=e.byteLength-(t.length>0?t.map((e=>4+e.block.byteLength)).reduce(((e,t)=>e+t)):0)-1,s=e.slice(r,r+1),r+=1):(i=(e[r+1]<<6)+(e[r+2]>>2),n=((3&e[r+2])<<8)+e[r+3],s=e.slice(r,r+4),r+=4),o=new Uint8Array(n),t.push({timestampOffset:i,header:s,block:o,isPrimary:a,blockPType:c}),a)break}return t.forEach((t=>{const i=t.block.byteLength,n=e.slice(r,r+i);t.block.set(n),r+=i})),t}(new Uint8Array(e)),i=[],n=[];let s=0;r.forEach((e=>{const r="decode"===t?Ts.decodeAudio(e.block):Ts.encodeAudio(e.block);if(r.byteLength!==e.block.byteLength&&!e.isPrimary){let[,,t,i]=e.header;t=(t>>2<<2)+r.byteLength>>8,i=255&r.byteLength,e.header=new Uint8Array([e.header[0],e.header[1],t,i])}e.block=r,s+=e.block.byteLength+e.header.byteLength,i.push(e.header),n.push(e.block)}));const o=new Uint8Array(s);let a=0;return[...i,...n].forEach((e=>{o.set(e,a),a+=e.byteLength})),o.buffer}_handleOpusFrame(e,t){const r=new Uint8Array(e);return("encode"===t?Ts.encodeAudio(r):Ts.decodeAudio(r)).buffer}_encodeRtpChunk(e,t,r){const i=t.data;if(t instanceof RTCEncodedVideoFrame)t.data=this._encodeVideoFrame(i);else{const{payloadType:e}=t.getMetadata(),{codec:r}=Os.payloadTypeCodecMap.filter((t=>t.payloadType===e))[0];"red"===r?t.data=this._handleAudioREDFrame(i,"encode"):"opus"===r?t.data=this._handleOpusFrame(i,"encode"):console.error(`Unsupport audio payloadType: ${e}, codec: ${r}`)}r.enqueue(t)}_decodeRtpChunk(e,t,r){const i=t.data;if(t instanceof RTCEncodedVideoFrame)t.data=this._decodeVideoFrame(i);else if(this._useEncrypt){const{payloadType:e}=t.getMetadata(),{codec:r}=Os.payloadTypeCodecMap.filter((t=>t.payloadType===e))[0];"red"===r?t.data=this._handleAudioREDFrame(i,"decode"):"opus"===r?t.data=this._handleOpusFrame(i,"decode"):console.error(`Unsupport audio payloadType: ${e}, codec: ${r}`)}r.enqueue(t)}}class ws extends Is{constructor(e,t){super(t,Ls.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 r=t.match(/\ba=mid:(video|audio)\b/),i=Is.clearInactiveOrRecvonly(t);r&&r[1]===We.AUDIO&&(e[1]=i),r&&r[1]===We.VIDEO&&(e[2]=i)}));const t=e.join("");return Is.trimBlankLine(t)}setAudioBitrateWithStreamId(e,t){return this._logger.warn(T.L_FUNCTION_IS_UNAVAILABLE,"plan-b not support set Audio Bitrate With Stream Id"),this}setVideoBitrateWithStreamId(e,t){return this._logger.warn(T.L_FUNCTION_IS_UNAVAILABLE,"plan-b not support set Video Bitrate With Stream Id"),this}}class xs extends Ms{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(),r=e.__innerGetMediaStreamTrack(),i=this._outboundStreams[t]||(this._outboundStreams[t]=new MediaStream);i.getTracks().forEach((e=>{e.kind===r.kind&&i.removeTrack(e)})),i.addTrack(r);const n=e.getTrackId(),s=this.senders[n];s?s.replaceTrack(r):(this.senders[n]=this._peer.addTrack(r,i),Object.defineProperty(r,"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 r=e.getTrackId(),i=this.senders[r];i&&(i.replaceTrack(null),this._peer.removeTrack(i),delete this.senders[r])}updateSubRemoteTracks(e){}updateRecvTransceiverMap(e,t){}setBitrate(e,t,r){}createOffer(e){return E(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 r=this._outboundStreams[e].id;t.sdp=t.sdp.replace(new RegExp(r,"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===je.AUDIO_ONLY?t.isAudioTrack():t.isVideoTrack())),r={max:0,min:0};return t.forEach((e=>{const{min:t,max:i,start:n}=e.getBitrate();r.max=r.max<i?i:r.max,r.min=r.min>t?t:r.min,r.max===i?r.start=n:r.start=.7*r.max})),r}resetSdp(e){const t=new ws(this._logger,e),r=this._getMaxRangeBitrate(je.VIDEO_ONLY),i=this._getMaxRangeBitrate(je.AUDIO_ONLY);return t.setAudiosBitrate(i),t.setVideosBitrate(r),t.stringify()}}class Bs extends Is{constructor(e,t){super(t,Ls.UNIFIEDPLAN,e)}stringify(){const e=[this.SDPHeader];[...this.audioStreams,...this.videoStreams].forEach((t=>{const r=t.match(/\ba=mid:(\d+)\b/);r&&r[1]&&(e[+r[1]+1]=t)})),this.SDPHeader="",this.videoStreams=[],this.audioStreams=[];const t=e.join("");return Is.trimBlankLine(t)}}class Vs{constructor(){Object.defineProperty(this,"__streams",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}static getInstance(){return Vs.instance||(Vs.instance=new Vs),Vs.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 js extends Ms{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,r){this._logger.warn(T.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 r=e.getTrackId(),i=e.getStreamId(),n=e.__innerGetMediaStreamTrack();this._localTracks[r]=e;const s=this._outboundStreams[i]||(this._outboundStreams[i]=new MediaStream);s.getTracks().forEach((e=>{e.kind===n.kind&&s.removeTrack(e)})),s.addTrack(n);const o=this._sendTransceiver[r];if(o)o.sender.replaceTrack(n),o.direction="sendonly";else{const e=this._sendTransceiver[r]=this._peer.addTransceiver(n,{direction:"sendonly",streams:[s]});this._setupSenderTransform(e.sender)}Vs.getInstance().push(r,{msid:i,id:this._outboundStreams[i].id,kind:null===(t=e.streamTrack)||void 0===t?void 0:t.kind})}removeLocalTrack(e,t=!0){const r=e.getTrackId(),i=e.getStreamId();delete this._localTracks[r];const n=this._sendTransceiver[r];if(!n)return;"closed"!==this._peer.connectionState&&(n.direction="inactive",this._peer.removeTrack(n.sender),n.sender.replaceTrack(null));const s=this._outboundStreams[i];(e.isAudioTrack()?s.getAudioTracks():s.getVideoTracks()).forEach((e=>s.removeTrack(e)));const o=this._sendTransceiver[`${r}_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[`${i}_tiny`].removeTrack(t),t.stop()}}updateRecvTransceiverMap(e,t){const{mediaType:r}=It(e);this._recvTransceiver[e]=t;const i=r===je.AUDIO_ONLY?this._recvAudio:this._recvVideo,n=i.findIndex((e=>e===t));n>=0&&i.splice(n,1)}updateSubRemoteTracks(e){const t=e.slice(),r=this._subedTracks.slice();this._subedTracks=e.slice();for(let e=t.length-1;e>=0;e-=1){const i=t[e],n=r.findIndex((e=>e===i));n>=0&&(t.splice(e,1),r.splice(n,1))}r.length&&r.forEach((e=>{const t=e.getTrackId();e.__innerSetMediaStreamTrack(void 0);const r=this._recvTransceiver[t];r&&(r.direction="inactive")}));const i={audio:0,video:0};t.length&&t.forEach((e=>{const t=e.isAudioTrack()?"audio":"video",r=this._recvTransceiver[e.getTrackId()];r?r.direction="recvonly":i[t]+=1}));for(let e=this._recvAudio.length;e<i.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<i.video;e+=1){const e=this._peer.addTransceiver("video",{direction:"recvonly"});this._recvVideo.push(e),this._setupReceiverTransform(e.receiver)}}createOffer(e){return E(this,void 0,void 0,(function*(){const t=yield this._peer.createOffer({iceRestart:e});let r=t.sdp;for(const e in this._outboundStreams){const t=this._outboundStreams[e].id;r=r.replace(new RegExp(t,"g"),e)}return r=this.resetOfferSdp(r),r=r.replace(/(a=ice-options:trickle)/g,"$1\r\na=ice-options:renomination"),t.sdp=r,yield this._peer.setLocalDescription(t),{type:"offer",semantics:"unified-plan",sdp:r}}))}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,r){let i=null;return Os.getMediaSections(e).forEach((e=>{Os.parseExtmap(e);const{kind:n}=Os.parseMLine(e);let{stream:s}=Os.parseMsid(e);const o=Os.getMid(e);"video"===r?/tiny$/.test(s)?s=s.replace(/tiny$/gi,"1_tiny"):s+="_1":s+="_0",s===t&&r===n&&o&&(i=o)})),i}_setSenderTransceiverBitrate(e,t,r,i){const n=this._localTracks[t],s=null==n?void 0:n.getBitrate();i===We.AUDIO&&s&&e.setAudioBitrateWithMid(s,r),i===We.VIDEO&&s&&e.setVideoBitrateWithMid(s,r)}_resetSenderTransceiver(e,t){var r;for(const i in this._sendTransceiver){const n=this._sendTransceiver[i],s=null===(r=n.sender.track)||void 0===r?void 0:r.kind;let{direction:o,mid:a}=n;a||(a=this._genarateMid(e,i,s)),a&&(o===bs.SENDONLY&&this._setSenderTransceiverBitrate(t,i,a,s),o===bs.INACTIVE&&t.clearnSsrcWithMid(a,bs.INACTIVE))}}_resetRecvTransceiver(e){for(const t in this._recvTransceiver){const r=this._recvTransceiver[t],{direction:i,mid:n}=r;n&&i===bs.INACTIVE&&e.clearnSsrcWithMid(n,bs.RECVONLY)}}resetOfferSdp(e){const t=new Bs(this._logger,e);return this._resetSenderTransceiver(e,t),this._resetRecvTransceiver(t),t.stringify()}resetAnswerSdp(e){var t;const r=new Bs(this._logger,e);for(const e in this._sendTransceiver){const i=this._sendTransceiver[e],{mid:n}=i;if(n){const s=this._localTracks[e],o=null==s?void 0:s.getBitrate(),a=null===(t=i.sender.track)||void 0===t?void 0:t.kind;a===We.AUDIO&&o&&r.setAudioBitrateWithMid(o,n),a===We.VIDEO&&o&&r.setVideoBitrateWithMid(o,n)}}return r.stringify()}}class Fs extends e{constructor(e,t,r,i,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:r}),Object.defineProperty(this,"_currentUserId",{enumerable:!0,configurable:!0,writable:!0,value:i}),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 c=Ms.getSdpSemantics(),_="unified-plan"===c&&a&&Bt()&&Ts.isInit(),d=this._rtcPeerConn=new RTCPeerConnection({sdpSemantics:c,encodedInsertableStreams:_});this._sdpStrategy="plan-b"===c?new xs(e,this._logger,d,!1):new js(e,this._logger,d,_),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,c,this._currentUserId,this._store)}getLocalTracks(){return Object.values(this.pubLocalTracks)}_decodeSeiData(e){const t=e.split(",").map((e=>Number(e))),r=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 r=t+(1===e[t+2]?3:4);if(r>=e.length)break;if(6==(31&e[r])){const t=vs(e,r+1);if(t)return{payloadSize:t.payloadSize,content:t.content}}t=r+1}else t++}else{let t=0;for(;t+4<=e.length;){const r=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];if(r<=0||t+4+r>e.length)break;const i=t+4;if(6==(31&e[i])){const n=i+1,s=vs(e.subarray(n,t+4+r),0);if(s)return{payloadSize:s.payloadSize,content:s.content}}t+=4+r}}return null}(new Uint8Array(t));if(null==r?void 0:r.content.length){const e=this._context.decodeAsrText(r.content,t);e.length&&this.emit(Fs.__INNER_SEI_CONTENT__,e)}}_onConnectionStateChange(){this._logger.info(T.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(){var e,t;return E(this,void 0,void 0,(function*(){const{iceConnectionState:r}=this._rtcPeerConn;this._logger.info(T.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_S,JSON.stringify({iceConnectionState:r}));const i=yield this._getStatsData(),n=i?this._createRCRTCStateReport(i).iceCandidatePair:null;this.emit(Fs.__INNER_ICE_STATE_CHANGE__,{status:r,time:Date.now(),iceCandidatePair:n}),"connected"===r?(this.emit(Fs.__INNER_ICE_CONNECTED__,this._firstConnectFromPub),this.startAutoExecute(1e3)):"failed"!==r&&"disconnected"!==r||this._handleRetry();try{null===(t=null===(e=this._reportListener)||void 0===e?void 0:e.onICEConnectionStateChange)||void 0===t||t.call(e,r)}catch(e){this._logger.error(T.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_REPORT_R,JSON.stringify({status:O.FAILED,mag:e}))}}))}_handleRetry(){return E(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!==I.SUCCESS&&(this._reTryExchangeTimer=setTimeout((()=>this._handleRetry()),15e3))}))}_onTrackReady(e){if(!e.streams.length)return;const t=e.streams[0].id,{track:r}=e.receiver,i=[t,"audio"===r.kind?je.AUDIO_ONLY:je.VIDEO_ONLY].join("_");Object.defineProperty(r,"trackId",{value:i,writable:!1,enumerable:!1,configurable:!1}),this._updateRecvTransceiverMap(i,e.transceiver);const{tag:n}=It(i);n!==ts&&this.emit(Fs.__INNER_EVENT_TRACK_READY__,e)}setBitrate(e,t,r){return E(this,void 0,void 0,(function*(){this._sdpStrategy.setBitrate(e,t,r),this._logger.info(T.L_RTC_PEER_CONNECTION_SET_BITRATE_O,JSON.stringify({status:O.SUCCESSED,max:e,min:t,start:r}))}))}createOffer(e){return E(this,void 0,void 0,(function*(){const t=yield this._sdpStrategy.createOffer(e);return this._logger.info(T.L_RTC_PEER_CONNECTION_CREATE_OFFER_O,JSON.stringify({offerSDP:t.sdp,sdpDemantics:t.semantics})),t}))}setRemoteAnswer(e,t=!1){var r;return E(this,void 0,void 0,(function*(){return Os.parsePayloadTypes(null===(r=this._rtcPeerConn.localDescription)||void 0===r?void 0:r.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(et.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.off(et.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),e.on(et.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.on(et.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),this._logger.info(T.L_RTC_PEER_CONNECTION_ADD_LOCAL_TRACK_O,`trackId: ${e.getTrackId()}`)}removeLocalTrackById(e){const t=this.getLocalTrack(e);t?(this._logger.info(T.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_BY_ID_O,JSON.stringify({status:O.SUCCESSED,trackId:e})),this.removeLocalTrack(t)):this._logger.warn(T.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_BY_ID_O,JSON.stringify({status:O.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 r=e.getTrackId();delete this.pubLocalTracks[r],this._sdpStrategy.removeLocalTrack(e,t),e.__innerSetPublished(!1),e.off(et.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.off(et.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this);const i=`${r}_tiny`,n=this.getLocalTrack(i);n&&t&&(this._sdpStrategy.removeLocalTrack(n,t),delete this.pubLocalTracks[i],n.destroy()),this._logger.info(T.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_O,JSON.stringify({trackId:r}))}_updateRecvTransceiverMap(e,t){this._sdpStrategy.updateRecvTransceiverMap(e,t)}updateSubRemoteTracks(e){this._sdpStrategy.updateSubRemoteTracks(e)}getOutboundVideoInfo(){return this._sdpStrategy.getOutboundVideoInfo()}_onLocalTrackMuted(e,t){const r=this.getLocalTrack(`${e.getTrackId()}_tiny`);r&&(r.__innerGetMediaStreamTrack().enabled=!e.isLocalMuted()),this.emit(et.__INNER_EVENT_MUTED_CHANGE__,e,t)}_onLocalTrackDestroied(e){this.emit(et.__INNER_EVENT_DESTROY__,e)}registerReportListener(e){this._reportListener=e}_createSenderReport(e){return e.filter((e=>e.trackId)).map((e=>{const{trackId:t,kind:r,packetsLostRate:i,remoteResource:n,bitrate:s,jitter:o,rtt:a}=e,c={trackId:t,kind:r,packetsLostRate:i,remoteResource:n,bitrate:s,jitter:o,rtt:a};return(e.audioLevel||0===e.audioLevel)&&(c.audioLevel=e.audioLevel),e.frameWidth&&(c.frameWidth=e.frameWidth),e.frameHeight&&(c.frameHeight=e.frameHeight),e.frameRate&&(c.frameRate=e.frameRate),Object.assign({},c)}))}_createReceiverReport(e){return e.filter((e=>e.trackId)).map((e=>{const{trackId:t,kind:r,packetsLostRate:i,remoteResource:n,bitrate:s,jitter:o,rtt:a}=e,c={trackId:t,kind:r,packetsLostRate:i,remoteResource:n,bitrate:s,jitter:o,rtt:a};return(e.audioLevel||0===e.audioLevel)&&(c.audioLevel=e.audioLevel),e.frameWidth&&(c.frameWidth=e.frameWidth),e.frameHeight&&(c.frameHeight=e.frameHeight),e.frameRate&&(c.frameRate=e.frameRate),Object.assign({},c)}))}_createRCRTCStateReport(e){const{timestamp:t,iceCandidatePair:r,senders:i,receivers:n}=e;(null==r?void 0:r.totalPacketsLost)&&(null==r||delete r.totalPacketsLost);for(const e in r)kt(r[e])&&delete r[e];return{timestamp:t,iceCandidatePair:r,senders:this._createSenderReport(i),receivers:this._createReceiverReport(n)}}_getStatsData(){var e,t;return E(this,void 0,void 0,(function*(){this._formatStatsData=null;let r=null;const i=yield this._rtcPeerConn.getStats();r=null===(e=this.reportParser)||void 0===e?void 0:e.parseRTCStatsReport(i);const n=null===(t=this.reportParser)||void 0===t?void 0:t.formatRCRTCStateReport(r);return this._formatStatsData=n,n}))}_reportHandle(){var e,t,r,i,n;return E(this,void 0,void 0,(function*(){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(T.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(Fs.__INNER_AUDIOLEVEL_CHANGE__,a),this._isRoomAudience&&(null===(r=this._reportListener)||void 0===r?void 0:r.onReportLiveAudioStates)){const e=this._getLiveAudioState();try{e.length&&(null===(n=null===(i=this._reportListener)||void 0===i?void 0:i.onReportLiveAudioStates)||void 0===n||n.call(i,e))}catch(e){this._logger.error(T.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,null==e?void 0:e.stack)}}}))}_getLiveAudioState(){const e=[];return this._rtcPeerConn.getReceivers().forEach((t=>{const r=t.getContributingSources();r.length&&e.push(...r)})),e.map((e=>{const{source:t,audioLevel:r}=e,i=this._store.getTrackIdBySSRC(t);if(!i)return{};const{userId:n}=It(i);return{audioLevel:us(r),userId:n,trackId:i}})).filter((e=>!!e.userId))}_sendR3R4Data(){var e,t,r,i;return E(this,void 0,void 0,(function*(){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===(r=this._polarisReport)||void 0===r?void 0:r.sendR3Data(n)),o.length&&(yield null===(i=this._polarisReport)||void 0===i?void 0:i.sendR4Data(n)),s.length=0,o.length=0,n=null}))}__reportR3R4ToPolaris(){return E(this,void 0,void 0,(function*(){this._isDestroyed||(clearTimeout(this._reportR3R4ToPolarisTimer),this._reportR3R4ToPolarisTimer=setTimeout((()=>E(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(T.L_RTC_PEER_CONNECTION_DESTROY_O,JSON.stringify({status:O.SUCCESSED}))}clearReTryExchangeTimer(){clearTimeout(this._reTryExchangeTimer),this._reTryExchangeTimer=null}isDestroyed(){return this._isDestroyed}}Object.defineProperty(Fs,"__INNER_EVENT_TRACK_READY__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-track-ready"}),Object.defineProperty(Fs,"__INNER_AUDIOLEVEL_CHANGE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-audio-level-change"}),Object.defineProperty(Fs,"__INNER_ICE_STATE_CHANGE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-ice-state-change"}),Object.defineProperty(Fs,"__INNER_ICE_CONNECTED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-ice-connected"}),Object.defineProperty(Fs,"__INNER_SEI_CONTENT__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-sei-content"});class Js{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:r}=It(e.trackId),i=this._store.crtUserId===r?this._peer.getLocalTrack(e.trackId):this._store.getRemoteTrack(e.trackId);i&&t.push({track:i,audioLevel:e.audioLevel||0})})),this._audioLevelChangeHandler(t)}onAudioLevelChange(e){this._audioLevelChangeHandler=e}}!function(e){e[e.ANCHOR=1]="ANCHOR",e[e.AUDIENCE=2]="AUDIENCE"}(As||(As={})),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"}(ys||(ys={})),function(e){e[e.LOW=0]="LOW",e[e.NORMAL=1]="NORMAL",e[e.HIGH=2]="HIGH"}(Ns||(Ns={})),function(e){e[e.Destroy=40400]="Destroy"}(Ds||(Ds={}));class Gs{get priority(){return Ns.LOW}get kind(){return ys.UNKNOWN}}class Hs{constructor(e,t,r,i){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:r}),Object.defineProperty(this,"abortCode",{enumerable:!0,configurable:!0,writable:!0,value:i}),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 E(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 r;const i=this._logger.createTraceId();try{this._logger.info(T.L_INVOKER_EXECUTE_T,`kind: ${e.kind}, length: ${this._queue.length}`,i),r=yield e.execute(this._context,this._store,this)}catch(t){return console.error(t),this._logger.error(T.L_INVOKER_EXECUTE_R,e.kind,i),void this._next()}const{code:n}=r;n!==I.SUCCESS&&n!==o.SUCCESS?this._logger.warn(T.L_INVOKER_EXECUTE_R,`code: ${n}, kind: ${e.kind}`,i):this._logger.info(T.L_INVOKER_EXECUTE_R,`kind: ${e.kind}, Done`,i),t(r),this._next()}))}push(e){return E(this,void 0,void 0,(function*(){return new Promise((t=>{if(this._logger.info(T.L_INVOKER_PUSH_O,JSON.stringify({isDestroyed:this._isDestroyed,kind:e.kind,length:this._queue.length})),this._isDestroyed)return void t({code:I.NOT_IN_ROOM});const{priority:r}=e;if(r===Ns.LOW)this._queue.push({command:e,resolve:t});else{const i=this._queue.findIndex((e=>e.command.priority<r)),n=-1===i?this._queue.length-1:i;this._queue.splice(n,0,{command:e,resolve:t})}setTimeout((()=>{this._execute()}),0)}))}))}isDestroyed(){return this._isDestroyed}destroy(){this._isDestroyed||(this._logger.info(T.L_INVOKER_DESTROY_O),this._isDestroyed=!0,this._queue.forEach((e=>{e.resolve({code:this.abortCode})})),this._queue.length=0)}}class Ks extends Hs{constructor(e,t){super(e.logger,e,t,I.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"}(Ps||(Ps={}));class $s{constructor(e,t,r,i,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:r}),Object.defineProperty(this,"roomId",{enumerable:!0,configurable:!0,writable:!0,value:i}),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:Ps.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 r in this._remoteTracks){const i=this._remoteTracks[r];i.getUserId()===e&&t.push(i)}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:r}=It(e);return t===ts?this._asrSeiUris[r][0]:this._roomResources[r].find((t=>Et(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 Ws extends $s{_updateTrackIdSSRCMap(){Object.values(this._roomResources).forEach((e=>{e.forEach((e=>{const{ssrc:t,resourceId:r}=JSON.parse(e.uri);this._trackIdSSRCMap.set(t,r)}))}))}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=Et(e),{tag:r,userId:i,mediaType:n}=It(t),s=n===je.AUDIO_ONLY?new lt(this._logger,r,i):new ut(this._logger,r,i);s.__innerSetRemoteMuted(0===e.state),this._remoteTracks[t]=s}))}}initWithRoomData(e,t){this._sessionId=e.sessionId,this._token=e.token,this._roomStatusVersion=xt(e.version),this._roomResources=Mt(e,this.roomId,this._logger,t),this._updateTrackIdSSRCMap(),this._initRemoteTracks(),this.setResourcesByUserId(this.crtUserId,this.getResourcesByUserId(this.crtUserId)||[]),this._logger.info(T.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=xt(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],r=t.split("_")[0];this._asrSeiUris[r]=e}else this._asrSeiUris={}}addSeiRemoteTrack(e){const{msid:t}=e[0],r=t.split("_"),i=r.pop(),n=r[0],s=new ut(this._logger,i,n);this.addRemoteTrack(s)}removeSeiRemoteTrack(){if(!this.getASRSeiUris().length)return;const{msid:e,mediaType:t}=this.getASRSeiUris()[0],r=`${e}_${t}`;this.removeRemoteTrack(r)}setIsStartRealTranslate(e){this._isStartRealTranslate=e}setTranslationLang(e){this._translationLang=e}setSummarizationStatusData(e){this._summarizationStatusData=e}setNickName(e){this._nickName=e}}class zs extends Gs{get kind(){return ys.UNPUBLISH_PREV}execute(e,t){return E(this,void 0,void 0,(function*(){const{logger:r,context:i}=e,n=t.getResourcesByUserId(t.crtUserId),s=n.slice();n.length=0;const a=r.createTraceId();r.info(T.L_UNPUBLISH_PREV_COMMAND_T,JSON.stringify({resource:s}),a);const c=yield i.setRTCTotalRes(t.roomId,[gt(Vt.UNPUBLISH,s)],Rt([]),Vt.TOTAL_CONTENT_RESOURCE,Rt([]));return c!==o.SUCCESS?r.error(T.L_UNPUBLISH_PREV_COMMAND_R,JSON.stringify({status:O.FAILED,code:c}),a):r.info(T.L_UNPUBLISH_PREV_COMMAND_R,JSON.stringify({status:O.SUCCESSED}),a),{code:I.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"}(ks||(ks={}));class Ys extends Gs{constructor(e,t,r,i,n,s,o,a,c){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:r}),Object.defineProperty(this,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:i}),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:c})}get kind(){return ys.JOINROOM}_getResultTag(){let e=T.L_RTC_CLIENT_JOIN_RTC_ROOM_R;return this.roomType===ks.LIVE&&(e=T.L_RTC_CLIENT_JOIN_LIVING_ROOM_R),e}_validateParams(e,t,s){if(e.getConnectionStatus()!==c.CONNECTED)return t.error(s,JSON.stringify({status:O.FAILED,code:I.SIGNAL_DISCONNECTED,msg:"im not connected"}),this.traceId),{code:I.SIGNAL_DISCONNECTED};if(Ut(e.getNaviInfo()))return t.error(s,JSON.stringify({status:O.FAILED,code:I.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"}),this.traceId),{code:I.PACKAGE_ENVIRONMENT_ERROR};if(!r("roomId",this.roomId,_,!0))return t.error(s,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> roomId"}),this.traceId),{code:I.PARAMS_ERROR};if(!r("roomType",this.roomType,(e=>void 0!==ks[e])))return t.error(s,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> roomType"}),this.traceId),{code:I.PARAMS_ERROR};if(!r("outerUserDatas",this.outerUserDatas,i,!1))return t.error(s,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> outerUserDatas"}),this.traceId),{code:I.PARAMS_ERROR};if(this.outerUserDatas){if(!Object.keys(this.outerUserDatas).every((e=>r(`outerUserDatas.${e}`,this.outerUserDatas[e],n,!0))))return t.error(s,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> outerUserDatas"}),this.traceId),{code:I.PARAMS_ERROR}}if(this.nickName){if(!r("nickName",this.nickName,n,!0)||this.nickName.length>64)return t.error(s,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> nickName"}),this.traceId),{code:I.PARAMS_ERROR}}if(this.srcLanguage){if(!r("srcLanguage",this.srcLanguage,n,!0)||this.srcLanguage.length>50)return t.error(s,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> srcLanguage"}),this.traceId),{code:I.PARAMS_ERROR}}return{code:I.SUCCESS}}execute(e,t,r){var i,n,s,a;return E(this,void 0,void 0,(function*(){const c=Date.now(),{context:_,service:d,logger:l,reportMediaActionLogger:u}=e,h=this._getResultTag(),{code:g}=this._validateParams(_,l,h);if(g!==I.SUCCESS)return{code:g};if(!d.getMsList().length)return l.error(h,JSON.stringify({status:O.FAILED,code:I.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"No audio / video server address available"}),this.traceId),{code:I.NOT_OPEN_VIDEO_AUDIO_SERVER};const R=t.getSupportNtf(),{code:p,data:m}=yield _.joinRTCRoom(this.roomId,this.roomType,this.livingType,this.joinType,this.innerUserDatas,this.outerUserDatas,R);if(u.reportQualityJoinRoomData(c,p,this.roomType,null==m?void 0:m.sessionId),p!==o.SUCCESS||!m){const e=40032===p?I.SIGNAL_JOIN_RTC_ROOM_REFUSED:p;return l.error(h,JSON.stringify({status:O.FAILED,code:e,msg:"joinRoom failed"}),this.traceId),{code:e}}t.initWithRoomData(m,this.traceId),this.nickName&&t.setNickName(this.nickName),this.srcLanguage&&t.setSrcLanguage(this.srcLanguage);t.getResourcesByUserId(t.crtUserId).length>0&&r.push(new zs);const f=null===(i=m.roomInfo.filter((e=>"cdn_uris"===e.key))[0])||void 0===i?void 0:i.value;f&&t.setCDNUris(JSON.parse(f)[0]);const S=null===(n=m.roomInfo.filter((e=>"asr_status"===e.key))[0])||void 0===n?void 0:n.value;S&&t.setASRStatus(S);const E=null===(s=m.roomInfo.filter((e=>"sei_ai_uris"===e.key))[0])||void 0===s?void 0:s.value;if(E){const e=JSON.parse(E);e.length&&(t.setASRSeiUris(e),t.addSeiRemoteTrack(e))}const T=null===(a=m.roomInfo.filter((e=>"summarization"===e.key))[0])||void 0===a?void 0:a.value;if(T){const e=JSON.parse(T);t.setSummarizationStatusData(e)}return l.info(h,JSON.stringify({status:O.SUCCESSED,userId:t.crtUserId,roomId:this.roomId,sessionId:m.sessionId}),this.traceId),{code:I.SUCCESS,data:m}}))}}!function(e){e[e.ROOM=1]="ROOM",e[e.PERSON=2]="PERSON"}(Us||(Us={}));const qs="PEER_CONNECTION_CLOSED_BY_EXCEPTION",Zs="USER_JOIN",Qs="USER_LEAVE",Xs="TRACKS_PUBLISH",eo="TRACKS_UNPUBLISH",to="AUDIO_MUTE_CHANGE",ro="VIDEO_MUTE_CHANGE",io="CDN_ENABLE_CHANGE",no="USER_STATE_CHANGE",so="ASR_SEI_PUBLISH",oo="ASR_SEI_UNPUBLISH",ao="SUMMARIZATION_START",co="SUMMARIZATION_STOP";class _o extends e{constructor(e,t,r,i,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:r}),Object.defineProperty(this,"runtime",{enumerable:!0,configurable:!0,writable:!0,value:i}),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 lo,uo,ho,go;!function(e){e.PUBLISH="publish",e.SUBSCRIBE="subscribe"}(lo||(lo={})),function(e){e.BEGIN="begin",e.END="end"}(uo||(uo={})),function(e){e[e.SPREAD=0]="SPREAD",e[e.NO_SPREAD=-1]="NO_SPREAD"}(ho||(ho={}));class Ro extends Gs{constructor(e,t,r){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:r})}execute(e,t,r){var i;return E(this,void 0,void 0,(function*(){const{service:r,context:n}=e,s=yield r.exchange(t.getRTCRequestHeader(),this.reqBody,this.traceId,this.isNeedUpdateMsas),{code:o,data:a,qualityMsList:c}=s,_={code:o,data:{data:a,qualityMsList:c}},d=null===(i=null==a?void 0:a.urls)||void 0===i?void 0:i.pull_url;if(t.roomMode===ks.LIVE&&d){const e=JSON.parse(d);if(t.setCDNUris(e),(null==e?void 0:e.broadcast)===ho.SPREAD){t.setCDNEnabel(!0);const r=Object.assign(Object.assign({},e),{enableInnerCDN:!0});Io(n,t.roomId,r)}}return _}))}}!function(e){e.PUB="pub",e.UNPUB="unpub",e.SUB="sub",e.UNSUB="unsub"}(go||(go={}));class po extends Gs{constructor(e,t,r,i=go.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:r}),Object.defineProperty(this,"fromCommand",{enumerable:!0,configurable:!0,writable:!0,value:i}),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 ys.UPDATE_SUBSCRIBE_LIST}_dealSubscribeResult(e,t,r,i){const n=null==i?void 0:i.map((e=>`${e.msid}_${e.mediaType}`)),s=r.filter((e=>null==n?void 0:n.includes(e.track.getTrackId()))),o=r.filter((e=>!(null==n?void 0:n.includes(e.track.getTrackId()))));t.info(T.L_ABSTRACT_ROOM_SUBSCRIBE_R,JSON.stringify({status:O.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 r=s.some((t=>t.track.getTrackId()===e&&t.subTiny));a[e].isVideoTrack()&&a[e].__innerSetIsTinyTrack(r)}return e.resetSubscribedList(s),o}_getParams(e,t,r){let i=r.map((e=>e instanceof dt?{track:e}:Object.assign({},e)));const n={};return i=i.filter((r=>{const i=r.track.getTrackId();return e.getRemoteTrack(i)?!n[i]&&(n[i]=!0,!0):(t.warn(T.L_UPDATE_SUBSCRIBELIST_COMMAND_P,`track cannot found in room -> trackId: ${i}`,this.traceId),!1)})).map((e=>Object.assign({},e))),i}_validateParams(e,t){return r("tracks",t,(()=>d(t)&&t.every((e=>e instanceof dt||e.track instanceof dt))),!0)?{code:I.SUCCESS}:(e.warn(T.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"tracks is invalid"}),this.traceId),{code:I.PARAMS_ERROR})}_reportPubOrSubQualityData(e,t,r){(null==r?void 0:r.length)&&e.reportPubOrSubQualityData(this.fromCommand,this._actionStartTime,r,t,this._trackMediaMap)}execute(e,t,r){return E(this,void 0,void 0,(function*(){const{logger:i,peer:n,reportMediaActionLogger:s,context:o}=e;this._actionStartTime=Date.now();const{tracks:a,forceReq:c}=this,{roomId:_}=t;i.info(T.L_UPDATE_SUBSCRIBELIST_COMMAND_T,`roomId: ${_}, forceReq: ${c}, trackIds: ${a.map(wt)}`,this.traceId);const{code:d}=this._validateParams(i,a);if(d!==I.SUCCESS)return{code:d};const l=this._getParams(t,i,a),u=t.getSubscribedList().map((e=>Object.assign({},e)));if(!c){if(!Ao(l,u))return i.warn(T.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:O.SUCCESSED,msg:"subscribe list unchanged"}),this.traceId),{code:I.SUCCESS};if(u.length){const e=u.map((e=>e.track));i.warn(T.L_CLEAR_UNSUBSCRIBE_LIST_O,JSON.stringify({list:e.map((e=>e.getTrackId()))}),this.traceId);const r=t.getSubscribedList().filter((t=>e.every((e=>e.getTrackId()!==t.track.getTrackId()))));t.resetSubscribedList(r)}}n.__reportR3R4ToPolaris(),n.clearReTryExchangeTimer(),n.updateSubRemoteTracks(l.map((e=>e.track)));const h=yield So(l,!1,n,t,o);h.pushOtherRooms=e.getPushOtherRooms();const g=yield new Ro(h,this.traceId,!0).execute(e,t,r);a.forEach((e=>{const t=e instanceof dt?e.getTrackId():e.track.getTrackId();this._trackMediaMap[t]=g.data.qualityMsList||[]}));const R=this.fromCommand===go.SUB?a:this.unsubTracks;if(g.code!==I.SUCCESS)return this._reportPubOrSubQualityData(s,g.code,R),i.error(T.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:O.FAILED,code:g.code}),this.traceId),{code:g.code};const{sdp:p,resultCode:m,subscribedList:f}=g.data.data;if(m!==I.SUCCESS)return this._reportPubOrSubQualityData(s,m,R),i.error(T.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:O.FAILED,code:m}),this.traceId),{code:m};s.setPubOrSubSuccessTime(Date.now());const S=yield n.setRemoteAnswer(p.sdp);if(this._reportPubOrSubQualityData(s,S,R),S!==I.SUCCESS)return{code:S};const E=this._dealSubscribeResult(t,i,l,f);return E.length?{code:I.SUCCESS,data:E}:{code:I.SUCCESS}}))}}class mo extends Gs{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 ys.UNSUBSCRIBE}execute(e,t,i){return E(this,void 0,void 0,(function*(){const{logger:n,polarisReport:s}=e,{tracks:o}=this;if(!r("tracks",o,(()=>d(o)&&o.length>0&&o.every((e=>e instanceof dt))),!0))return n.warn(T.L_ABSTRACT_ROOM_UNSUBSCRIBE_E,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> tracks"}),this.traceId),{code:I.PARAMS_ERROR};n.info(T.L_ABSTRACT_ROOM_UNSUBSCRIBE_T,JSON.stringify({unSubscribeTrackIds:o.map(wt)}),this.traceId);const a=t.getSubscribedList().map((e=>Object.assign({},e))).filter((e=>o.every((t=>t.getTrackId()!==e.track.getTrackId()))));return s.sendR2(lo.SUBSCRIBE,uo.END,o.map((e=>e.getTrackId()))),new po(a,!1,this.traceId,go.UNSUB,this.tracks).execute(e,t,i)}))}}class fo extends Gs{constructor(e){super(),Object.defineProperty(this,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e})}execute(e,t,r){return E(this,void 0,void 0,(function*(){const{logger:i}=e,{tracks:n}=this,s=i.createTraceId();return i.info(T.L_USER_LEFT_UNSUBSCRIBE_O,void 0,s),yield new mo(n,s).execute(e,t,r),n.forEach((e=>{e.__innerDestroy(),t.removeRemoteTrack(e.getTrackId())})),e.emit(eo,n),{code:I.SUCCESS}}))}}function So(e,t,r,i,n){var s;return E(this,void 0,void 0,(function*(){const o=(null===(s=n.getNaviInfo())||void 0===s?void 0:s.ipType)||0,a=yield r.createOffer(t),c=i.getSrcLanguage(),_=i.getNickName(),d={resolutionInfo:r.getOutboundVideoInfo()};c&&Object.assign(d,{srcLanguage:c}),_&&Object.assign(d,{nickName:_});return{asr_status:i.getASRStatus(),ipType:o,sdp:a,extend:JSON.stringify(d),subscribeList:e.filter((e=>{const t=e.track.getTrackId(),{userId:r}=It(t),n=i.getResourcesByUserId(r);if(!n)return!1;const s=n.filter((e=>t===`${e.msid}_${e.mediaType}`)).length;return s})).map((e=>({simulcast:e.subTiny?_s.TINY:_s.NORMAL,resolution:"",uri:i.getPublishedResourceByTrackId(e.track.getTrackId()).uri}))),switchstream:!1}}))}function Eo(e,t,r){return E(this,void 0,void 0,(function*(){const i=e.logger.createTraceId();e.logger.info(T.L_LIVING_ROOM_SPREAD_CDN_INFO_T,JSON.stringify({CDNUris:r}),i);const n=yield e.setRTCCDNUris(t,Vt.TOTAL_CONTENT_RESOURCE,JSON.stringify([r]));return n!==o.SUCCESS?(e.logger.error(T.L_LIVING_ROOM_SPREAD_CDN_INFO_R,`status: ${O.FAILED}, code: ${n}`,i),{code:I.SIGNAL_ERROR}):(e.logger.info(T.L_LIVING_ROOM_SPREAD_CDN_INFO_R,`status: ${O.SUCCESSED}`,i),{code:I.SUCCESS})}))}function Io(e,t,r){return E(this,void 0,void 0,(function*(){const i=e.logger.createTraceId();e.logger.info(T.L_LIVING_ROOM_SET_ROOM_CDN_INFO_T,`CDNUris: ${r}`,i);const n=yield e.setRTCData(t,"cdn_uris",JSON.stringify([r]),!0,Us.ROOM);return n!==o.SUCCESS?(e.logger.error(T.L_LIVING_ROOM_SET_ROOM_CDN_INFO_R,`status: ${O.FAILED}, code: ${n}`,i),{code:I.SIGNAL_ERROR}):(e.logger.info(T.L_LIVING_ROOM_SET_ROOM_CDN_INFO_R,`status: ${O.SUCCESSED}`,i),{code:I.SUCCESS})}))}function To(e,t){return E(this,void 0,void 0,(function*(){const{roomId:r}=t,i=Object.assign({},t.getCDNUris(),{enableInnerCDN:t.getCDNEnable()});return(yield Promise.all([Eo(e,r,i),Io(e,r,i)])).every((e=>e.code===I.SUCCESS))?{code:I.SUCCESS}:{code:I.SIGNAL_ERROR}}))}function Oo(e,t,r,i,n,s){return E(this,void 0,void 0,(function*(){const{logger:o}=r,{roomId:a,roomMode:c}=t,_=[],d={},u={},h={},g=Mt(e,a,o,s),R=Object.keys(g),p=t.getAllUserIds();for(let e=R.length-1;e>=0;e-=1){const r=R[e],i=p.indexOf(r);if(-1===i){_.push(r),d[r]=Ot(g[r]);continue}const n=t.getResourcesByUserId(r),s=g[r],{publishedList:o,modifiedList:a,unpublishedList:c}=Ct(n,s,!0);d[r]=Ot(o),u[r]=Ot(c),h[r]=Ot(a),p.splice(i,1)}p.length&&p.forEach((e=>{t.removeResourcesByUserId(e)})),t.assignRoomData(g),p.length&&(yield Co(p,r,t,i,s),r.emit(Qs,p)),_.length&&r.emit(Zs,_),yield((e,t,r,i)=>E(void 0,void 0,void 0,(function*(){const{crtUserId:n}=e;for(const s in i){if(s===n)continue;const o=i[s];if(o.length){const i=o.map((t=>e.getRemoteTrack(Et(t))));yield new fo(i).execute(t,e,r)}}})))(t,r,i,u),((e,t,r)=>{const{logger:i}=t;Object.keys(r).forEach((n=>{const s=r[n];if(0===s.length)return;const o=s.map((t=>{const r=Et(t),{userId:n,tag:s,mediaType:o}=It(r),a=o===je.AUDIO_ONLY?new lt(i,s,n):new ut(i,s,n);return e.addRemoteTrack(a),a.__innerSetRemoteMuted(0===t.state),a}));o.length&&t.emit(Xs,o)}))})(t,r,d),((e,t,r)=>{Object.keys(r).forEach((i=>{r[i].forEach((r=>{const i=Et(r),n=e.getRemoteTrack(i);n.__innerSetRemoteMuted(0===r.state),n.isAudioTrack()?t.emit(to,n):t.emit(ro,n)}))}))})(t,r,h),c===l.LIVE&&function(e,t,r,i){var n;if(!i)return void r.warn(T.L_LIVING_ROOM_RECONNECTED_R,JSON.stringify({status:O.FAILED,code:"",msg:"cdn_uris not found"}));const s=JSON.parse(i),o=(null===(n=t.getCDNUris())||void 0===n?void 0:n.enableInnerCDN)!==s.enableInnerCDN;t.setCDNUris(s),o&&e.emit(io,s.enableInnerCDN)}(r,t,o,n)}))}function Co(e,t,r,i,n){return E(this,void 0,void 0,(function*(){const s=[],o=[];e.forEach((e=>{s.push(...r.getRemoteTracksByUserId(e)),o.push(e)})),s.length&&(yield new mo(s,n).execute(t,r,i),s.forEach((e=>r.removeRemoteTrack(e.getTrackId())))),o.length&&o.forEach((e=>r.removeResourcesByUserId(e)))}))}function vo(e){var t;const{userId:r,userData:i,event:n,switchRoleType:s}=e;return{users:[{userId:r,extra:null===(t=i.filter((e=>"extra"===e.key))[0])||void 0===t?void 0:t.value,state:n,switchRoleType:s}]}}function Lo(e){var t,r;const{userId:i,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===(r=n.filter((e=>"cdn_uris"===e.key))[0])||void 0===r?void 0:r.value;return{userId:i,content:{uris:o?JSON.parse(o):[],cdn_uris:a&&JSON.parse(a)}}}const bo=(e,t,r)=>{const i=e.split("\r\nm"),n=r===je.AUDIO_ONLY?"audio":"video",s=i.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]:""},Ao=(e,t)=>{let r=!1;return e.forEach((e=>{const i=t.findIndex((t=>t.track.getTrackId()===e.track.getTrackId()));if(-1===i)return void(r=!0);t.splice(i,1)[0].subTiny!==e.subTiny&&(r=!0)})),t.length&&(r=!0),r};class yo extends Gs{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 ys.PARSE_USERSTATE}get priority(){return Ns.NORMAL}_isPKRoomUser(e,t){for(const r of t){if(r.extra&&r.extra.roomId!==e.roomId)return!0;if(1===Number(r.state)&&!e.getRemoteUserIds().includes(r.userId))return!0}return!1}_dealAddUser(e,t,r,i,n){const s=e.getResourcesByUserId(n);s||(i?r.upgrade.push(n):r.joined.push(n),t.info(T.L_PARSE_USERSTATE_COMMAND_R,JSON.stringify({userId:n,msg:"user "+(i?"upgrade":"joined")}),this.traceId)),e.setResourcesByUserId(n,s||[])}_dealReduceUser(e,t,r,i,n){e.info(T.L_PARSE_USERSTATE_COMMAND_R,JSON.stringify({userId:n,msg:"user "+(i?"downgrade":"left")}),this.traceId),i?t.downgrade.push(n):1!==Number(r)?t.offline.push(n):t.left.push(n)}execute(e,t,r){return E(this,void 0,void 0,(function*(){const{logger:i}=e,n={joined:[],left:[],offline:[],upgrade:[],downgrade:[]},{users:s}=this.msgContent;if(0===s.length)return{code:I.SUCCESS,data:n};if(this._isPKRoomUser(t,s))return{code:I.SUCCESS,data:n};s.forEach((e=>{const{userId:r}=e;0===Number(e.state)?this._dealAddUser(t,i,n,e.switchRoleType,r):this._dealReduceUser(i,n,e.state,e.switchRoleType,r)}));const o=[...n.left,...n.downgrade,...n.offline];return o.length&&(yield Co(o,e,t,r,this.traceId)),{code:I.SUCCESS,data:n}}))}}class No extends Gs{constructor(e,t,r,i,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:r}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:i}),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 ys.PARSE_REMOTERES}get priority(){return Ns.NORMAL}_dealPublishList(e,t,r){return E(this,void 0,void 0,(function*(){const{logger:i,reportMediaActionLogger:n}=e,s=this._nowResources.map(Et),o=[],a=[];if(this._publishedList.forEach((e=>{const r=Et(e),n=s.indexOf(r),{userId:c,tag:_,mediaType:d}=It(r);n>-1?this._nowResources[n]=e:this._nowResources.push(e);let l=t.getRemoteTrack(r);l?l.isSubscribed()&&o.push(l):(l=d===je.AUDIO_ONLY?new lt(i,_,c):new ut(i,_,c),t.addRemoteTrack(l),a.push(l)),l.__innerSetRemoteMuted(0===e.state)})),o.length){const n=o.map((e=>e.getTrackId())),{code:s}=yield new po(o,!0,this.traceId).execute(e,t,r);s!==I.SUCCESS&&i.error(T.L_RESUB_REPUB_RES_R,JSON.stringify({status:O.FAILED,trackIds:n,code:s}),this.traceId)}a.length&&e.emit(Xs,a),n.reportQualityRecvPubMsgData(this.sentTime,this.senderId)}))}_dealUnpublishList(e,t,r){return E(this,void 0,void 0,(function*(){const i=this._unpublishedList.map(Et);for(let e=this._nowResources.length-1;e>=0;e-=1){const t=this._nowResources[e];i.includes(Et(t))&&this._nowResources.splice(e,1)}const n=this._unpublishedList.map((e=>{const r=Et(e);return t.getRemoteTrack(r)}));yield new fo(n).execute(e,t,r)}))}_dealModifiedList(e,t){return E(this,void 0,void 0,(function*(){const r=this._nowResources.map(Et);for(const i of this._modifiedList){const n=Et(i),s=r.indexOf(n);this._nowResources[s].state=i.state;const o=t.getRemoteTrack(n);o.__innerSetRemoteMuted(0===i.state),o.isAudioTrack()?e.emit(to,o):e.emit(ro,o)}}))}_updateCDNUris(e,t){var r,i;const n=this.msgContent.cdn_uris[0],s=(null===(r=t.getCDNUris())||void 0===r?void 0:r.enableInnerCDN)!==n.enableInnerCDN;t.setCDNUris(n),s&&e.emit(io,!!(null===(i=t.getCDNUris())||void 0===i?void 0:i.enableInnerCDN))}execute(e,t,r){return E(this,void 0,void 0,(function*(){const{uris:i}=this.msgContent;let n;this._publishedList=[],this._unpublishedList=[],this._modifiedList=[];const s=this.senderId,{messageType:o}=this;if(!t.getRemoteUserIds().includes(s))return{code:I.SUCCESS};switch(this._nowResources=t.getResourcesByUserId(s)||[],o){case Vt.MODIFY:this._modifiedList.push(...i);break;case Vt.PUBLISH:this._publishedList.push(...i);break;case Vt.UNPUBLISH:this._unpublishedList.push(...i);break;case Vt.TOTAL_CONTENT_RESOURCE:n=Ct(this._nowResources,i),this._publishedList.push(...n.publishedList),this._unpublishedList.push(...n.unpublishedList),this._modifiedList.push(...n.modifiedList)}if(this._publishedList.length&&(yield this._dealPublishList(e,t,r)),this._unpublishedList.length&&(yield this._dealUnpublishList(e,t,r)),this._modifiedList.length&&(yield this._dealModifiedList(e,t)),t.setResourcesByUserId(s,this._nowResources),t.roomMode!==ks.LIVE)return{code:I.SUCCESS};return this.msgContent.cdn_uris?(this._updateCDNUris(e,t),{code:I.SUCCESS}):{code:I.SUCCESS}}))}}class Do extends Gs{constructor(e,t,r){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:r})}get kind(){return ys.SUBSCRIBE}execute(e,t,i){return E(this,void 0,void 0,(function*(){const{logger:n,polarisReport:s}=e,{tracks:o,forceReq:a}=this;if(!r("tracks",o,(()=>d(o)&&o.length>0&&o.every((e=>e instanceof dt||e.track instanceof dt))),!0))return n.error(T.L_ABSTRACT_ROOM_SUBSCRIBE_E,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> tracks"}),this.traceId),{code:I.PARAMS_ERROR};n.info(T.L_ABSTRACT_ROOM_SUBSCRIBE_T,JSON.stringify({trackIds:o.map(wt),forceReq:a}),this.traceId);const c=t.getSubscribedList().map((e=>Object.assign({},e))),_=o.map((e=>e instanceof dt?{track:e}:e));let l=!1;const u=[];return _.forEach((e=>{const t=e.track.getTrackId();u.push(t);const r=c.find((e=>e.track.getTrackId()===t));r&&r.subTiny===e.subTiny||(r?r.subTiny=e.subTiny:c.push(e),l=!0)})),l||a?(s.sendR2(lo.SUBSCRIBE,uo.BEGIN,u),new po(c,!0,this.traceId).execute(e,t,i)):(n.warn(T.L_ABSTRACT_ROOM_SUBSCRIBE_R,JSON.stringify({status:O.SUCCESSED,msg:"repeat subscribe"}),this.traceId),{code:I.SUCCESS})}))}}class Po extends Gs{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 ys.PUBLISH}_removePubFailedTracks(e,t){e.forEach((e=>{const r=e instanceof et?e:e.track;t.removeLocalTrackById(r.getTrackId())}))}_addLocalTracks(e,t){return E(this,void 0,void 0,(function*(){const r=[];for(const i of e){const{track:e,pubTiny:n}=i instanceof et?{pubTiny:!1,track:i}:i;if(e.isVideoTrack()&&n){let i;try{i=e.__innerGetMediaStreamTrack().clone();const t=n.frameRate||Be.FPS_15,r=n.resolution||Ve.W176_H144,{width:s,height:o}=Lt(r),a=yt(t);yield i.applyConstraints({width:s,height:o,frameRate:a})}catch(t){null==i||i.stop(),this._logger.warn(T.L_ABSTRACT_ROOM_PUBLISH_E,`pubTiny failed -> id: ${e.getTrackId()}, msg: ${t.message}`,this._traceId);break}const s=new rt(this._logger,e.getTag(),e.getUserId(),i,!0);r.push(s),t.addLocalTrack(s)}t.addLocalTrack(e)}return r}))}__publish(e,t,r,i){return E(this,void 0,void 0,(function*(){const{peer:n,reportMediaActionLogger:s,context:o}=e,a=[];r.forEach((e=>{const{track:t}=e instanceof et?{track:e}:e;a.push(t)})),r.sort(((e,t)=>{const{track:r}=e instanceof et?{track:e}:e,{max:i}=r.getBitrate(),{track:n}=t instanceof et?{track:t}:t,{max:s}=n.getBitrate();return i-s}));if(n.getLocalTracks().length+((e,t)=>{let r=0;return e.forEach((e=>{const i=e instanceof et?e.getTrackId():e.track.getTrackId();t.getLocalTrack(i)||(e instanceof et?r++:e.pubTiny&&e.track.isVideoTrack()&&(r+=2))})),r})(r,n)>10)return this._logger.error(T.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:O.FAILED,code:I.PUBLISH_TRACK_LIMIT_EXCEEDED,trackIds:r.map(wt),msg:"publish track limit exceeded"}),this._traceId),{code:I.PUBLISH_TRACK_LIMIT_EXCEEDED,tracks:a};const c=yield this._addLocalTracks(r,n);n.clearReTryExchangeTimer();const _=t.getSubscribedList(),d=yield So(_,!1,n,t,o);d.pushOtherRooms=e.getPushOtherRooms();const l=yield new Ro(d,this._traceId,!0).execute(e,t,i);if(a.forEach((e=>{const t=e.getTrackId();this._trackMediaMap[t]=l.data.qualityMsList||[]})),l.code!==I.SUCCESS)return s.reportPubOrSubQualityData(go.PUB,this._actionStartTime,a,l.code,this._trackMediaMap),this._logger.error(T.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:O.FAILED,tracks:r.map(wt),code:l.code,msg:"exchange failed"}),this._traceId),this._removePubFailedTracks(r,n),{code:l.code,tracks:a};const{sdp:u,resultCode:h,message:g}=l.data.data;if(h!==I.SUCCESS)return s.reportPubOrSubQualityData(go.PUB,this._actionStartTime,a,h,this._trackMediaMap),this._logger.error(T.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:O.FAILED,trackIds:r.map(wt),code:h,msg:`exchange inner failed: ${g}`}),this._traceId),this._removePubFailedTracks(r,n),{code:h,tracks:a};s.setPubOrSubSuccessTime(Date.now());const R=yield n.setRemoteAnswer(u.sdp,!0);return R!==I.SUCCESS?(s.reportPubOrSubQualityData(go.PUB,this._actionStartTime,a,R,this._trackMediaMap),this._logger.error(T.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:O.FAILED,trackIds:r.map(wt),code:R,msg:"set remote answer error"}),this._traceId),{code:R,tracks:a}):(c.length&&this._updateTinyTrackIdSSRCMap(t,d.sdp.sdp,c),Object.assign(Object.assign({code:h},l.data),{tracks:a}))}))}_updateTinyTrackIdSSRCMap(e,t,r){r.forEach((r=>{const i=bo(t,r.getStreamId(),je.VIDEO_ONLY);e.setTrackIdSSRCMap(Number(i),r.getTrackId())}))}_dealPublishRes(e,t,r){return E(this,void 0,void 0,(function*(){const{polarisReport:i,context:n,peer:s,reportMediaActionLogger:a}=r,c=t.crtUserId,{roomId:_}=t;let d="";const l=t.getResourcesByUserId(c),u=[...l];let h=[];const{tracks:g}=e;if(e.code!==I.SUCCESS)return{code:e.code};const{publishList:R,urls:p,mcuPublishList:m}=e.data;d=null==p?void 0:p.liveUrl;R.map((e=>Object.assign({tag:e.msid.split("_").pop(),state:s.getLocalTrack(Et(e)).isLocalMuted()?0:1},e))).forEach((e=>{const{isInclude:t,index:r}=((e,t)=>{let r=!1,i=0;for(let n=0;n<t.length;n++){const s=t[n];if(`${e.msid}_${e.mediaType}`==`${s.msid}_${s.mediaType}`){r=!0,i=n;break}}return{isInclude:r,index:i}})(e,u);t?u.splice(r,1,e):u.push(e)}));h=(null==m?void 0:m.map((e=>Object.assign({tag:e.msid.split("_").pop(),state:1},e))))||[];const{publishedList:f}=Ct(l,u),S=Object.assign(Object.assign({},t.getCDNUris()),{enableInnerCDN:t.getCDNEnable()}),E=S&&S.broadcast===ho.SPREAD?JSON.stringify([S]):"",C=Date.now(),v=yield n.setRTCTotalRes(_,[gt(Vt.PUBLISH,f)],Rt(u),Vt.TOTAL_CONTENT_RESOURCE,Rt(h),E);if(a.reportPubOrSubQualityData(go.PUB,this._actionStartTime,g,v,this._trackMediaMap,[{dur:Date.now()-C,cod:v}]),v!==o.SUCCESS)return this._logger.error(T.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:O.FAILED,code:v,msg:"send publish streams notification failed"}),this._traceId),{code:I.SIGNAL_ERROR};t.setResourcesByUserId(c,u);const L=f.map((e=>Et(e)));i.sendR2(lo.PUBLISH,uo.BEGIN,L),f.forEach((e=>{s.getLocalTrack(`${e.msid}_${e.mediaType}`).__innerSetPublished(!0)}));const b={code:I.SUCCESS};return d&&(b.liveUrl=d),b}))}execute(e,t,i){return E(this,void 0,void 0,(function*(){const{logger:n,peer:s}=e;this._traceId=n.createTraceId(),this._logger=n,this._actionStartTime=Date.now();let{tracks:o}=this;if(!r("tracks",o,(()=>d(o)&&o.length>0&&o.every((e=>e instanceof et||e.track instanceof et))),!0))return this._logger.error(T.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> tracks"}),this._traceId),{code:I.PARAMS_ERROR};if(this._logger.info(T.L_ABSTRACT_ROOM_PUBLISH_T,JSON.stringify({trackIds:o.map(wt)})),o=o.filter((e=>{const{track:t}=e instanceof et?{track:e}:e,r=t.isDestroyed();return r&&this._logger.warn(T.L_ABSTRACT_ROOM_PUBLISH_E,`track '${t.getTrackId()}' has beem destroyed`,this._traceId),!r})),!o.length)return this._logger.error(T.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:O.FAILED,code:I.PUBLISH_TRACKS_IS_INVALID,msg:"params tracks is empty"}),this._traceId),{code:I.PUBLISH_TRACKS_IS_INVALID};s.__reportR3R4ToPolaris(),s.clearReTryExchangeTimer();const a=yield this.__publish(e,t,o,i);return yield this._dealPublishRes(a,t,e)}))}}class ko extends Gs{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 ys.UNPUBLISH}__unpublish(e,t,r,i){return E(this,void 0,void 0,(function*(){const{peer:n,polarisReport:s,logger:o,reportMediaActionLogger:a,context:c}=e,_=i.map((e=>e.getTrackId()));if(0===_.map(t.getPublishedResourceByTrackId.bind(t)).filter((e=>!!e)).length)return{code:I.SUCCESS,tracks:i};_.forEach((e=>n.removeLocalTrackById(e))),s.sendR2(lo.PUBLISH,uo.END,_),n.clearReTryExchangeTimer();const d=t.getSubscribedList(),l=yield So(d,!1,n,t,c),u=e.getPushOtherRooms();u.length&&(l.pushOtherRooms=u);const h=yield new Ro(l,this._traceId,!0).execute(e,t,r);if(i.forEach((e=>{const t=e.getTrackId();this._trackMediaMap[t]=h.data.qualityMsList||[]})),h.code!==I.SUCCESS)return a.reportPubOrSubQualityData(go.UNPUB,this._actionStartTime,i,h.code,this._trackMediaMap),o.error(T.L_ABSTRACT_ROOM_UNPUBLISH_P,JSON.stringify({status:O.FAILED,code:h.code,trackIds:i.map(wt),msg:"exchange failed"}),this._traceId),{code:h.code,tracks:i};const{resultCode:g,message:R}=h.data.data;return g!==I.SUCCESS?(a.reportPubOrSubQualityData(go.UNPUB,this._actionStartTime,i,h.data.data.resultCode,this._trackMediaMap),o.error(T.L_ABSTRACT_ROOM_UNPUBLISH_P,JSON.stringify({status:O.FAILED,code:g,trackIds:i.map(wt),msg:`exchange inner failed: ${R}`}),this._traceId),{code:g,tracks:i}):Object.assign(Object.assign({code:h.code},h.data),{tracks:i})}))}_dealUnpublishRes(e,t,r){return E(this,void 0,void 0,(function*(){const{context:i,logger:n,peer:s,reportMediaActionLogger:a}=e,c=i.getCurrentId(),{roomId:_}=t,d=[];let l=[];const{tracks:u,code:h,data:g}=r;if(h!==I.SUCCESS)return n.error(T.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({code:h,msg:"unpublish failed"}),this._traceId),{code:h};if(!g)return n.info(T.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:O.SUCCESSED,msg:"unpublish list is empty "})),{code:I.SUCCESS};const{mcuPublishList:R}=g,p=u.map((e=>e.getTrackId())),m=p.map(t.getPublishedResourceByTrackId.bind(t)).filter((e=>!!e));d.push(...m);l=R?R.map((e=>Object.assign({tag:e.msid.split("_").pop(),state:1},e))):[];const f=t.getResourcesByUserId(c).filter((e=>!d.includes(e))),S=Date.now(),E=yield i.setRTCTotalRes(_,[gt(Vt.UNPUBLISH,d)],Rt(f),Vt.TOTAL_CONTENT_RESOURCE,Rt(l));if(a.reportPubOrSubQualityData(go.UNPUB,this._actionStartTime,u,E,this._trackMediaMap,[{dur:Date.now()-S,cod:E}]),E!==o.SUCCESS)return n.error(T.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:O.FAILED,code:E,msg:"send unpublish notification failed"}),this._traceId),{code:I.SIGNAL_ERROR};n.info(T.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:O.SUCCESSED,code:I.SUCCESS,msg:"unpublish success",unPubResourceIds:p}),this._traceId);const{sdp:C}=r.data;return yield s.setRemoteAnswer(C.sdp),t.setResourcesByUserId(c,f),{code:I.SUCCESS}}))}execute(e,t,i){return E(this,void 0,void 0,(function*(){const{logger:n}=e;this._actionStartTime=Date.now();const{crtUserId:s}=t,{tracks:o}=this;this._traceId=n.createTraceId();if(!r("tracks",o,(()=>o.every((e=>e.getUserId()===s&&e instanceof et))),!0))return n.error(T.L_ABSTRACT_ROOM_UNPUBLISH_E,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> tracks"})),{code:I.PARAMS_ERROR};n.info(T.L_ABSTRACT_ROOM_UNPUBLISH_T,JSON.stringify({trackIds:o.map(wt)}));const a=yield this.__unpublish(e,t,i,o);return yield this._dealUnpublishRes(e,t,a)}))}}class Uo extends Gs{constructor(e){super(),Object.defineProperty(this,"localTrack",{enumerable:!0,configurable:!0,writable:!0,value:e})}get kind(){return ys.LOCAL_TRACK_MUTE}execute(e,t,r){return E(this,void 0,void 0,(function*(){const{logger:r,context:i}=e,{localTrack:n}=this,s=n.getTrackId(),{crtUserId:a,roomId:c}=t,_=!n.isLocalMuted(),d=r.createTraceId();r.info(T.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_T,JSON.stringify({enabled:_,trackId:this.localTrack.getTrackId()}),d);const l=[{resourceId:s,enabled:_}],u=t.getResourcesByUserId(a),h=[];for(const e of u){const t=Et(e),r=l.findIndex((e=>e.resourceId===t));if(r>=0){const{enabled:t}=l[r];e.state=t?1:0,h.push(e);break}}const g=yield i.setRTCTotalRes(c,[gt(Vt.MODIFY,h)],Rt(u),Vt.TOTAL_CONTENT_RESOURCE);return g!==o.SUCCESS?(r.error(T.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_R,JSON.stringify({status:O.FAILED,code:g,msg:"signal error"}),d),{code:g}):(r.info(T.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_R,JSON.stringify({status:O.SUCCESSED}),d),{code:I.SUCCESS})}))}}class Mo extends Gs{get kind(){return ys.RETRY_EXCHANGE}get priority(){return Ns.HIGH}execute(e,t,r){return E(this,void 0,void 0,(function*(){const{logger:i,peer:n,context:s}=e,o=i.createTraceId();i.info(T.L_RETRY_EXCHANGE_COMMAND_T);const a=s.getCurrentId(),c=t.getSubscribedList(),_=yield So(c,!0,n,t,s);_.pushOtherRooms=e.getPushOtherRooms();const d=yield new Ro(_,o).execute(e,t,r);if(d.code!==I.SUCCESS)return{code:d.code};const{sdp:l,resultCode:u}=d.data.data;if(u!==I.SUCCESS)return{code:u};n.clearReTryExchangeTimer();const h=yield n.setRemoteAnswer(l.sdp);if(h!==I.SUCCESS)return{code:h};const g=d.data.data.publishList||[],{plus:R,minus:p}=this._diffPublishListChange(g,t,n,a);return(R.length||p.length)&&(yield this._spreadPublishListUri(e,a,R,p,o)),{code:I.SUCCESS}}))}_diffPublishListChange(e,t,r,i){const n=t.getResourcesByUserId(i);let s=JSON.parse(JSON.stringify(n));e.forEach((e=>{var t;const{mediaType:i,msid:n}=e,o=s.findIndex((e=>{const{mediaType:t,msid:r}=e;return i===t&&n===r}));if(-1===o){const i=Object.assign({tag:n.split("_").pop(),state:(null===(t=r.getLocalTrack(Et(e)))||void 0===t?void 0:t.isLocalMuted)?0:1},e);s.push(i)}else s[o].uri=e.uri}));const{publishedList:o,unpublishedList:a}=Ct(n,s,!0);return t.setResourcesByUserId(i,s),{plus:o,minus:a}}_spreadPublishListUri(e,t,r,i,n){return E(this,void 0,void 0,(function*(){const{store:s,logger:a}=e,c=s.getResourcesByUserId(t);a.info(T.L_RETRY_EXCHANGE_SPREAD_T,JSON.stringify({plus:r,minus:i,allPublishList:c}),n);const _=[];i.length&&_.push(gt(Vt.UNPUBLISH,i)),r.length&&_.push(gt(Vt.PUBLISH,r));(yield e.context.setRTCTotalRes(s.roomId,_,Rt(c),Vt.TOTAL_CONTENT_RESOURCE))===o.SUCCESS?a.info(T.L_RETRY_EXCHANGE_SPREAD_R,`status: ${O.SUCCESSED}`,n):a.error(T.L_RETRY_EXCHANGE_SPREAD_R,`status: ${O.FAILED}`,n)}))}}var wo;!function(e){e[e.JOIN=0]="JOIN",e[e.LEAVE=1]="LEAVE",e[e.OFFLINE=2]="OFFLINE",e[e.RESOURCECHANGE=3]="RESOURCECHANGE"}(wo||(wo={}));class xo extends Gs{constructor(e,t,r,i){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:r}),Object.defineProperty(this,"_targetPullVersion",{enumerable:!0,configurable:!0,writable:!0,value:i})}get kind(){return ys.PULL_RTCROOM_STATUS}execute(e,t,r){return E(this,void 0,void 0,(function*(){const{logger:i}=e,n=t.getRoomStatusVersion();if(i.info(T.L_PULL_ROOM_STATUS_T,JSON.stringify({roomId:this._roomId,localVersion:n}),this._traceId),this._targetPullVersion&&this._targetPullVersion<=n)return i.info(T.L_PULL_ROOM_STATUS_R,JSON.stringify({status:O.SUCCESSED,msg:"the roomData has been pulled",localVersion:n,targetPullVersion:this._targetPullVersion}),this._traceId),{code:o.SUCCESS};const{code:s,data:a}=yield this._context.pullRTCRoomStatus(this._roomId,n);if(s!==o.SUCCESS)return i.info(T.L_PULL_ROOM_STATUS_R,JSON.stringify({status:O.FAILED,code:s}),this._traceId),{code:s};const{bFullStatus:c,version:_,usersData:d,roomStatus:l}=a;if(i.info(T.L_PULL_ROOM_STATUS_R,JSON.stringify({bFullStatus:c,version:xt(_),usersData:d,roomStatus:l}),this._traceId),t.setRoomStatusVersion(_),c){const{urisData:i,CDNUris:n}=function(e){const t={users:{}};let r="";return e.forEach((e=>{var i,n;const{userId:s,userData:o}=e;t.users[s]={};const a=null===(i=o.filter((e=>"uris"===e.key))[0])||void 0===i?void 0:i.value,c=null===(n=o.filter((e=>"cdn_uris"===e.key))[0])||void 0===n?void 0:n.value;r=c||r,t.users[s]={uris:a}})),{urisData:t,CDNUris:r&&JSON.stringify(JSON.parse(r)[0])}}(d);return yield Oo(i,t,e,r,n,this._traceId),{code:s}}for(const i of l)if(i.event===wo.RESOURCECHANGE){const n=Lo(i);if(!n)continue;const{content:s,userId:o}=n;if(o===t.crtUserId)continue;yield new No(s,Vt.TOTAL_CONTENT_RESOURCE,o,this._traceId).execute(e,t,r)}else{const n=vo(i),{data:s}=yield new yo(n,this._traceId).execute(e,t,r);e.emit(no,s)}return{code:s}}))}}class Bo extends Gs{constructor(e){super(),Object.defineProperty(this,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:e})}get kind(){return ys.ON_SIGNAL_RECONNECTED}get priority(){return Ns.HIGH}execute(e,t,r){return E(this,void 0,void 0,(function*(){const{logger:i,peer:n,context:s}=e,{roomId:a,roomMode:c}=t,_=i.createTraceId();if(i.info(T.L_ABSTRACT_ROOM_IM_RECONNECTED_T,void 0,_),"closed"===n.getRTCPeerConn().connectionState)return i.error(T.L_ABSTRACT_ROOM_IM_RECONNECTED_R,"RTCPeerConnection closed. Please rejoin room to restore services",_),e.emit(qs),{code:I.SUCCESS};const{code:d}=yield s.rtcPing(a,c);if(40001===d){(yield this._joinRoom(e,t,r,_))===o.SUCCESS&&(yield this._restoreMediaServer(e,t,r))}else yield new xo(a,_,s).execute(e,t,r);return{code:I.SUCCESS}}))}_joinRoom(e,t,r,i){var n,s,a,c;return E(this,void 0,void 0,(function*(){const{context:_,logger:d}=e,{code:l,data:u}=yield _.joinRTCRoom(t.roomId,t.roomMode,this.livingType);if(l!==o.SUCCESS)return void d.error(T.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:O.FAILED,code:l,msg:"im reconnect joinRTCRoom failed"}),i);if(!u)return void d.info(T.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:O.FAILED,msg:"im reconnect joinRTCRoom, roomData is empty"}),i);const h=null===(n=u.roomInfo.filter((e=>"cdn_uris"===e.key))[0])||void 0===n?void 0:n.value;yield Oo(u,t,e,r,h,i);const g=null===(s=u.roomInfo.filter((e=>"asr_status"===e.key))[0])||void 0===s?void 0:s.value;g&&t.setASRStatus(g);const R=null===(a=u.roomInfo.filter((e=>"sei_ai_uris"===e.key))[0])||void 0===a?void 0:a.value,p=t.getASRIsAvailable();if(R){const r=JSON.parse(R);if(r.length){p||e.emit(so),t.setASRSeiUris(r);const{msid:i,mediaType:n}=r[0],s=`${i}_${n}`;!t.getRemoteTrack(s)&&t.addSeiRemoteTrack(r)}else p&&e.emit(oo),t.removeSeiRemoteTrack(),t.setASRSeiUris(r)}const m=null===(c=u.roomInfo.filter((e=>"summarization"===e.key))[0])||void 0===c?void 0:c.value;if(m){const r=JSON.parse(m),i=t.getSummarizationStatusData();i&&i.status!==r.status&&e.emit(r.status===ss.OPEN?ao:co,r.taskId),t.setSummarizationStatusData(r)}return d.info(T.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:O.SUCCESSED,roomData:u}),i),l}))}_restoreMediaServer(e,t,r){return E(this,void 0,void 0,(function*(){const i=e.peer.getLocalTracks(),n=Object.values(t.getRemoteTracks()).filter((e=>!!e.isSubscribed()));i.length&&(yield new Po(i).execute(e,t,r)),!i.length&&n.length&&(yield new Do(n,!0).execute(e,t,r))}))}}const Vo=1,jo=5;var Fo,Jo,Go,Ho,Ko,$o,Wo,zo;!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"}(Fo||(Fo={})),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"}(Jo||(Jo={}));class Yo{constructor(e,t,r,i){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:r}),Object.defineProperty(this,"_userId",{enumerable:!0,configurable:!0,writable:!0,value:i}),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,r,i)=>{this._baseReportData=Object.assign(this._baseReportData,{snid:i});const n=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{cod:t,time:e,dur:Date.now()-e,rtp:r});this._logger.__statistics(T.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===Jo.OTHER_KICK?jo:Vo});this._logger.__statistics(T.L_QS_KICKED_S,JSON.stringify(t))}reportPubOrSubQualityData(e,t,r,i,n,s){r.forEach((r=>{var o,a;const c=r instanceof et||r instanceof dt?r:r.track,_=c.getTrackId(),{mediaType:d}=It(_);let l=!1;l=c instanceof et?!!c.isVideoTrack()&&(null===(a=(o=c).__isTiny)||void 0===a?void 0:a.call(o)):r.subTiny||!1;const u=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{resid:_,mtp:d,smct:l?_s.TINY:_s.NORMAL,stp:"Rongcloud"!==c.getTag()?1:0,cod:i,msas:n?n[_]:[],sigs:s,time:Date.now(),dur:Date.now()-t});switch(e){case"pub":this._logger.__statistics(T.L_QS_PUBLISH_S,JSON.stringify(u));break;case"unpub":this._logger.__statistics(T.L_QS_UNPUBLISH_S,JSON.stringify(u));break;case"sub":this._logger.__statistics(T.L_QS_SUBSCRIBE_S,JSON.stringify(u));break;case"unsub":this._logger.__statistics(T.L_QS_UNSUBSCRIBE_S,JSON.stringify(u))}}))}reportQualityRecvPubMsgData(e,t){const r=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{puid:t,time:Date.now(),dur:Date.now()-e});this._logger.__statistics(T.L_QS_RECV_PUB_MSG_S,JSON.stringify(r))}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}),r="pub"===e?T.L_QS_PUB_ICE_STATUS_S:T.L_QS_SUB_ICE_STATUS_S;this._logger.__statistics(r,JSON.stringify(t))}recordQualityIceStatusData(e,t,r){const{status:i,time:n}=this._peerCStatus||{};if(!n)return void(this._peerCStatus={status:t,time:r});const{IP:s,port:o,networkType:a,remoteIP:c,remotePort:_}=e,d=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{dur:r-n,time:r,pices:Fo[i],ices:Fo[t],rcdts:[{ip:`${c}:${_}`}],lcdts:[{ip:`${s}:${o}`,nttp:a}],cncdts:[]});console.log(T.L_QS_ICE_STATUS_S,d),this._logger.__statistics(T.L_QS_ICE_STATUS_S,JSON.stringify(d)),this._peerCStatus={status:t,time:r}}}!function(e){e[e.DISABLE=0]="DISABLE",e[e.ENABLE=1]="ENABLE"}(Go||(Go={})),function(e){e[e.MeetingOrAnchor=1]="MeetingOrAnchor",e[e.Audience=2]="Audience"}(Ho||(Ho={})),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"}(Ko||(Ko={})),function(e){e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4"}($o||($o={}));class qo{constructor(e,t,r,i,n=Ho.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:r}),Object.defineProperty(this,"_crtRTCRoom",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_userRole",{enumerable:!0,configurable:!0,writable:!0,value:n})}_send(e){return E(this,void 0,void 0,(function*(){if(this._context.getConnectionStatus()!==c.CONNECTED)return Ko.NOT_REPORT;return(yield this._context.setRTCState(this._roomId,e))===o.SUCCESS?Ko.REPORT_SUCCESS:Ko.REPORT_FAIL}))}_getClientID(){const e="uuid";let t=this._runtime.localStorage.getItem(e);return t||(t=vt(),this._runtime.localStorage.setItem(e,t)),t}_getRealResourceId(e){let t=e;const r=e.indexOf("_tiny");return r>-1&&(t=e.slice(0,r)),t}_getPolarisTrackId(e){let t="";const r=e.split("_");if(e.includes("_tiny")){const e=r.pop(),i=parseInt(r.pop())===je.AUDIO_ONLY?"audio":"video",n=r.pop();t=[r.join("_"),n,e,i].join("_")}else{const e=parseInt(r.pop())===je.AUDIO_ONLY?"audio":"video",i=r.pop();t=[r.join("_"),i,e].join("_")}return t}_getBaseData(e){return{bitrateSend:(null==e?void 0:e.bitrateSend)||es,bitrateRecv:(null==e?void 0:e.bitrateRecv)||es,networkType:(null==e?void 0:e.networkType)||"unknown",rtt:(null==e?void 0:e.rtt)||es,localAddress:`${(null==e?void 0:e.IP)||es}:${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)||es,sendBand:(null==e?void 0:e.availableOutgoingBitrate)||es,packetsLost:(null==e?void 0:e.totalPacketsLost)||es,deviceId:this._context.getCurrentId()}}_getAudioLevel(e){return e||0===e?e:es}_getBitrate(e){return e||0===e?e:es}_getPacketsLostRate(e){return e||0===e?e:es}_getFrameRate(e){return e||es}_getResolution(e,t){return e&&t?`${e} * ${t}`:"-1"}_getJitter(e){return e||es}_getNackCount(e){return e||0===e?e:es}_getPliCount(e){return e||0===e?e:es}_getRTT(e){return e||es}_getTrackState(e,t){const r=e?this._crtRTCRoom.getLocalTrack(t):this._crtRTCRoom.getRemoteTrack(t);return(null==r?void 0:r.isLocalMuted())?Go.DISABLE:Go.ENABLE}sendR3Data(e){return E(this,void 0,void 0,(function*(){const{iceCandidatePair:t,senders:r}=e,i=this._getBaseData(t);let n=`R3\t${i.bitrateSend}\t-1\t-1\t-1\t${i.networkType}\t${i.rtt}\t${i.localAddress}\t${i.receiveBand}\t${i.sendBand}\t${i.packetsLost}\t${i.deviceId}\r`;n+=r.map((e=>{const{trackId:t,audioLevel:r,samplingRate:i,bitrate:n,packetsLostRate:s,frameRate:o,frameWidth:a,frameHeight:c,googRenderDelayMs:_,jitter:d,nackCount:l,pliCount:u,rtt:h,googFirsSent:g,encoderImplementation:R}=e,p=this._getPolarisTrackId(t),m=this._getRealResourceId(t);return{trackId:p,googCodecName:R||String(es),audioLevel:this._getAudioLevel(r),bitrate:this._getBitrate(n),packetsLostRate:this._getPacketsLostRate(s),frameRate:this._getFrameRate(o),resolution:this._getResolution(a,c),jitter:this._getJitter(d),nackCount:this._getNackCount(l),pliCount:this._getPliCount(u),rtt:this._getRTT(h),googFirsSent:g,samplingRate:i,googRenderDelayMs:_,encoderImplementation:R||String(es),trackState:this._getTrackState(!0,m)}})).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}`))!==Ko.REPORT_SUCCESS?Ko.REPORT_FAIL:Ko.REPORT_SUCCESS}))}sendR4Data(e){return E(this,void 0,void 0,(function*(){const{iceCandidatePair:t,receivers:r}=e,i=this._getBaseData(t);let n=`R4\t${i.bitrateRecv}\t-1\t-1\t-1\t${i.networkType}\t${i.rtt}\t${i.localAddress}\t${i.receiveBand}\t${i.sendBand}\t${i.packetsLost}\t${i.deviceId}\r`;n+=r.filter((e=>!!e.trackId)).map((e=>{const{trackId:t,audioLevel:r,samplingRate:i,bitrate:n,packetsLostRate:s,frameRate:o,frameWidth:a,frameHeight:c,googRenderDelayMs:_,jitter:d,nackCount:l,pliCount:u,rtt:h,googFirsReceived:g,codecImplementationName:R}=e,p=this._getPolarisTrackId(t),m=this._getRealResourceId(t);return{trackId:p,googCodecName:R||String(es),audioLevel:this._getAudioLevel(r),bitrate:this._getBitrate(n),packetsLostRate:this._getPacketsLostRate(s),frameRate:this._getFrameRate(o),resolution:this._getResolution(a,c),jitter:this._getJitter(d),nackCount:this._getNackCount(l),pliCount:this._getPliCount(u),rtt:this._getRTT(h),googFirsReceived:g,samplingRate:i,googRenderDelayMs:_,codecImplementationName:R||String(es),trackState:this._getTrackState(!1,m)}})).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}`))!==Ko.REPORT_SUCCESS?Ko.REPORT_FAIL:Ko.REPORT_SUCCESS}))}sendR1(){var e;const t=this._context.getCoreVersion(),r=(null===(e=navigator.userAgentData)||void 0===e?void 0:e.platformn)||navigator.platform,i=`R1\t5.38.0-alpha.1\t${t}\tweb\t${r}\t-1\t${Nt.browser}\t${Nt.version}\t${this._getClientID()}\t${this._userRole}`;this._send(i)}sendR2(e,t,r){const i=`R2\t${e}\t${t}\t${this._getClientID()}\r${r.join("\t")}\r${this._userRole}`;this._send(i)}}class Zo extends Gs{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,r){return E(this,void 0,void 0,(function*(){const{peer:i,logger:n}=e;if(!this.oldTrack||!this.newTrack)return n.error(T.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack or newTrack is empty"),{code:I.PARAMS_ERROR};if([at,ot].every((e=>!(this.oldTrack instanceof e))))return n.error(T.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack is not RCCameraVideoTrack or RCMicphoneAudioTrack"),{code:I.PARAMS_ERROR};if([at,ot].every((e=>!(this.newTrack instanceof e))))return n.error(T.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"newTrack is not RCCameraVideoTrack or RCMicphoneAudioTrack"),{code:I.PARAMS_ERROR};const s=this.oldTrack.getSettings(),o=this.newTrack.getSettings(),a=this.oldTrack.getTrackId(),c=this.newTrack.getTrackId(),_=this.oldTrack.isAudioTrack()?"audio":"video",d=this.newTrack.isAudioTrack()?"audio":"video";if(n.info(T.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_T,JSON.stringify({oldTrackId:a,newTrackId:c,oldSettings:s,newSettings:o})),!this.oldTrack.isPublished())return n.error(T.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack is not published"),{code:I.PARAMS_ERROR};if(a!==c)return n.error(T.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,`oldTrack and newTrack trackId are different, oldTrackId: ${a}, newTrackId: ${c}`),{code:I.PARAMS_ERROR};if(_!==d)return n.error(T.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,`oldTrack and newTrack are not the same kind, oldTrackKind: ${_}, newTrackKind: ${d}`),{code:I.PARAMS_ERROR};if((null==s?void 0:s.deviceId)===(null==o?void 0:o.deviceId))return n.error(T.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:I.PARAMS_ERROR};i.addLocalTrack(this.newTrack);const l=(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=i.getLocalTrack(`${this.oldTrack.getTrackId()}_tiny`);if(!l)return u&&u.destroy(),this.oldTrack.destroy(!1),this.newTrack.__innerSetPublished(!0),n.info(T.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"changeMediaDevice success"),{code:I.SUCCESS};const h=yield(new Mo).execute(e,t,r);return h.code!==I.SUCCESS?(i.removeLocalTrack(this.newTrack,!1),i.addLocalTrack(this.oldTrack),this.newTrack.destroy(),n.error(T.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(T.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"changeMediaDevice success"),{code:h.code})}))}}!function(e){e[e.OPEN=1]="OPEN",e[e.CLOSE=0]="CLOSE"}(Wo||(Wo={}));class Qo extends Gs{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,r){return E(this,void 0,void 0,(function*(){const{logger:r,context:i,service:n}=e;this._traceId=r.createTraceId(),this._logger=r,this._logger.info(T.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_T,`type: ${this._type}`,this._traceId);const s=i.getNaviInfo();if((null==s?void 0:s.rtcAISwitch)===Wo.CLOSE)return this._logger.error(T.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:I.ASR_NOT_AVAILABLE}),this._traceId),{code:I.ASR_NOT_AVAILABLE};if(this._type===t.getASRStatus())return this._logger.info(T.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:I.SUCCESS}),this._traceId),{code:I.SUCCESS};const{roomId:a}=t,c=yield i.setRTCData(a,"asr_status",this._type.toString(),!0,u.ROOM,{name:Vt.ASR_STATUS,content:JSON.stringify({asr_status:this._type.toString()})});if(c!==o.SUCCESS)return this._logger.error(T.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:c}),this._traceId),{code:I.SIGNAL_ERROR};t.setASRStatus(this._type);const _=yield n.updateASRStatus(t.getRTCRequestHeader(),{asr_status:this._type},this._traceId),{code:d,data:l}=_;if(d!==I.SUCCESS||(null==l?void 0:l.resultCode)!==I.SUCCESS&&42200!==(null==l?void 0:l.resultCode)){const e=d!==I.SUCCESS?d:null==l?void 0:l.resultCode;return this._logger.error(T.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:e}),this._traceId),{code:e}}return this._logger.info(T.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:I.SUCCESS}),this._traceId),{code:I.SUCCESS}}))}}class Xo extends Gs{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,r,i){const n=`${e[0].msid}_${e[0].mediaType}`,s=r.getRemoteTrack(n);return this._enable?new Do([s]).execute(t,r,i):new mo([s],this._traceId).execute(t,r,i)}execute(e,t,r){return E(this,void 0,void 0,(function*(){const{logger:i,context:n}=e;this._traceId=i.createTraceId(),this._logger=i,this._logger.info(T.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)===Wo.CLOSE)return this._logger.error(T.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R,JSON.stringify({code:I.ASR_NOT_AVAILABLE}),this._traceId),{code:I.ASR_NOT_AVAILABLE};const o=t.getASRSeiUris();if(!o.length)return this._logger.info(T.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R,JSON.stringify({code:I.SUCCESS,asrSeiUrisLength:0}),this._traceId),{code:I.SUCCESS};const{code:a}=yield this._updateSubSei(o,e,t,r);return a!==I.SUCCESS?(this._logger.error(T.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R,JSON.stringify({code:a}),this._traceId),{code:a}):(this._logger.info(T.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R,JSON.stringify({code:I.SUCCESS}),this._traceId),{code:I.SUCCESS})}))}}!function(e){e[e.OPEN=1]="OPEN",e[e.CLOSE=0]="CLOSE"}(zo||(zo={}));class ea extends Gs{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,r=3,i=3e3){return E(this,void 0,void 0,(function*(){for(let n=1;n<=r;n++){try{const{code:r,data:i}=yield t.operateRealtimeTranslation(e.getRTCRequestHeader(),{status:this._status},this._traceId);if(r===I.SUCCESS)return;console.warn(`第 ${n} 次调用失败,code=${r}`)}catch(e){console.error(`第 ${n} 次调用异常:`,e)}n<r&&(yield new Promise((e=>{setTimeout(e,i)})))}}))}execute(e,t,r){return E(this,void 0,void 0,(function*(){const{logger:r,service:i,context:n}=e;this._traceId=r.createTraceId(),this._logger=r,this._logger.info(T.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)===Wo.CLOSE)return this._logger.error(T.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:I.ASR_NOT_AVAILABLE}),this._traceId),{code:I.ASR_NOT_AVAILABLE};if(this._status===zo.OPEN){if(!this._destLanguage)return this._logger.error(T.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:I.PARAMS_ERROR}),this._traceId),{code:I.PARAMS_ERROR};if(!t.getASRSeiUris().length)return this._logger.error(T.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:I.ASR_NOT_START}),this._traceId),{code:I.ASR_NOT_START}}const o={status:this._status};this._destLanguage&&(o.destLanguage=this._destLanguage);const{code:a,data:c}=yield i.operateRealtimeTranslation(t.getRTCRequestHeader(),o,this._traceId);if(this._status===zo.CLOSE)return t.setIsStartRealTranslate(!1),this._logger.info(T.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:I.SUCCESS}),this._traceId),a!==I.SUCCESS&&this._operateWithRetry(t,i),{code:I.SUCCESS};if(a!==I.SUCCESS||(null==c?void 0:c.resultCode)!==I.SUCCESS){const e=a!==I.SUCCESS?a:null==c?void 0:c.resultCode;return this._logger.error(T.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(T.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:I.SUCCESS}),this._traceId),{code:I.SUCCESS}}))}}class ta extends Gs{constructor(e){super(),Object.defineProperty(this,"_type",{enumerable:!0,configurable:!0,writable:!0,value:e})}execute(e,t){return E(this,void 0,void 0,(function*(){return t.setASRStatus(this._type),{code:I.SUCCESS}}))}}class ra extends Gs{constructor(e){super(),Object.defineProperty(this,"_asrSeiUris",{enumerable:!0,configurable:!0,writable:!0,value:e})}_setEnableAsr(e,t,r){return E(this,void 0,void 0,(function*(){const i=t.getASREnable();i&&(yield new Xo(this._asrSeiUris.length>0).execute(e,t,r),t.setASREnable(i))}))}_onPublish(e,t,r){e.emit(so),t.setASRSeiUris(this._asrSeiUris),t.addSeiRemoteTrack(this._asrSeiUris),this._setEnableAsr(e,t,r)}_onUnPublish(e,t,r){return E(this,void 0,void 0,(function*(){e.emit(oo),yield this._setEnableAsr(e,t,r),t.removeSeiRemoteTrack(),t.setASRSeiUris(this._asrSeiUris)}))}execute(e,t,r){return E(this,void 0,void 0,(function*(){return this._asrSeiUris.length?this._onPublish(e,t,r):this._onUnPublish(e,t,r),{code:I.SUCCESS}}))}}class ia extends Gs{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,r){var i,n;return E(this,void 0,void 0,(function*(){const{logger:r,context:s,service:o}=e;this._traceId=r.createTraceId(),this._logger=r,this._logger.info(T.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_T,`isStart: ${this._isStart}`,this._traceId);const a=s.getNaviInfo();if((null==a?void 0:a.rtcAISwitch)===Wo.CLOSE)return this._logger.error(T.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_R,JSON.stringify({code:I.ASR_NOT_AVAILABLE}),this._traceId),{code:I.ASR_NOT_AVAILABLE};if(!t.getASRSeiUris().length)return this._logger.error(T.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:I.ASR_NOT_START}),this._traceId),{code:I.ASR_NOT_START};if((null===(i=t.getSummarizationStatusData())||void 0===i?void 0:i.status)===ss.OPEN&&this._isStart||(null===(n=t.getSummarizationStatusData())||void 0===n?void 0:n.status)===ss.CLOSE&&!this._isStart)return this._logger.info(T.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_R,JSON.stringify({isStart:this._isStart,code:I.SUCCESS,taskId:t.getSummarizationStatusData().taskId}),this._traceId),{code:I.SUCCESS,taskId:t.getSummarizationStatusData().taskId};const c={status:this._isStart?ss.OPEN:ss.CLOSE},{code:_,data:d}=yield o.operateSummarization(t.getRTCRequestHeader(),c,this._traceId);return _!==I.SUCCESS?(this._logger.error(T.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_R,JSON.stringify({isStart:this._isStart,code:_}),this._traceId),{code:_}):(t.setSummarizationStatusData({taskId:d.taskId,status:this._isStart?ss.OPEN:ss.CLOSE}),this._logger.info(T.L_ABSTRACT_ROOM_OPERATE_SUMMARIZATION_R,JSON.stringify({isStart:this._isStart,code:I.SUCCESS,taskId:null==d?void 0:d.taskId}),this._traceId),{code:I.SUCCESS,taskId:null==d?void 0:d.taskId})}))}}class na extends Gs{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 E(this,void 0,void 0,(function*(){return t.setSummarizationStatusData({status:this._status,taskId:this._taskId}),e.emit(this._status===ss.OPEN?ao:co,this._taskId),{code:I.SUCCESS}}))}}const sa="evt-leave";class oa extends e{constructor(e,t,r,i,n,s,o,a,c=rs(),_=!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: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,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:c}),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 d=this._logger=this._context.logger;this._reportMediaActionLogger=new Yo(d,this._roomId,this._clientSessionId,this._context.getCurrentId()),this._polarisReport=new qo(this._context,this._runtime,this._roomId,this);const l=this._context.getCurrentId(),u=new Ws(d,c,this._context.getAppkey(),r,l,i,o,a),h=this._peerConnection=new Fs(e,d,this._reTryExchange.bind(this),l,u,this._polarisReport,!1,_);this._setPeerConnectionListener();const g=this._executeCtx=new _o(d,this._service,e,t,h,u,this._polarisReport,this._reportMediaActionLogger);g.getPushOtherRooms=()=>this._getPushOtherRoomsParams(),this.setCommandEventListener(),this._invoker=new Ks(g,u),this._store=this._invoker.store,this._audioLevelReport=new Js(this._store,h),h.on(Fs.__INNER_AUDIOLEVEL_CHANGE__,this._audioLevelReport.audioLevelReport,this._audioLevelReport),this._pinger=new Ft(this._context,this._roomId,i,this._initOptions.pingGap),this._pinger.onFailed=this.__kickoff.bind(this),this._pinger.onPingResult=this._handlePingResult.bind(this),this._context.registerRTCSignalListener((e=>E(this,void 0,void 0,(function*(){const{time:t,type:r,roomId:i}=this._context.decodeRtcNotify(e);if(this._invoker.isDestroyed())this._logger.info(T.L_RTCNTF_PULL_ROOM_STATUS_O,JSON.stringify({isDestroyed:!0,type:r,time:t,roomId:i}));else if(2===r&&i===this._roomId){const e=this._logger.createTraceId();this._logger.info(T.L_RTCNTF_PULL_ROOM_STATUS_O,null,e),this._startPullRTCRoomStatus(i,e,t)}}))))}_setPeerConnectionListener(){const e=this._peerConnection;e.on(Fs.__INNER_EVENT_TRACK_READY__,this._onTrackReady,this),e.on(et.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.on(et.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),e.once(Fs.__INNER_ICE_CONNECTED__,(e=>{this._reportMediaActionLogger.reportIceFirstConnectData(e?"pub":"sub")}),this),e.on(Fs.__INNER_ICE_STATE_CHANGE__,(e=>{const{status:t,time:r,iceCandidatePair:i}=e;this._reportMediaActionLogger.recordQualityIceStatusData(i,t,r)})),e.on(Fs.__INNER_SEI_CONTENT__,this._onReceiveAsrSeiContent,this)}setCommandEventListener(){const e=this._executeCtx;e.on(qs,this._rtcpeerClosed,this),e.on(Zs,this._callAppListener.bind(this,"onUserJoin"),this),e.on(Qs,this._callAppListener.bind(this,"onUserLeave"),this),e.on(Xs,this._onTrackPublish,this),e.on(eo,this._onTrackUnpublish,this),e.on(to,this._onAudioMuteChange,this),e.on(ro,this._onVideoMuteChange,this),e.on(io,this._callAppListener.bind(this,"onCDNEnableChange"),this),e.on(no,this._dealUserAppListener,this),e.on(so,this._callAppListener.bind(this,"onReceiveStartASR"),this),e.on(oo,this._callAppListener.bind(this,"onReceiveStopASR"),this),e.on(ao,this._callAppListener.bind(this,"onReceiveStartSummarization"),this),e.on(co,this._callAppListener.bind(this,"onReceiveStopSummarization"),this)}_startPullRTCRoomStatus(e,t,r){return E(this,void 0,void 0,(function*(){yield this._invoker.push(new xo(e,t,this._context,r))}))}__innerInit(e,t,r,i,n,s,o,a){return E(this,void 0,void 0,(function*(){const{code:c,data:_}=yield this._invoker.push(new Ys(this._roomId,e,t,r,i,n,s,o,a));return c!==I.SUCCESS?{code:c}:(this._initWithRoomData(_.offlineKickTime),{code:c,data:_})}))}_initWithRoomData(e){this._pinger.start(1e3*e),this._polarisReport.sendR1()}_handlePingResult(e,t){if(e===jt.SUCCESS){if(t>this._store.getRoomStatusVersion()&&this._store.getSupportNtf()){const e=this._logger.createTraceId();this._logger.info(T.L_RTCPING_PULL_ROOM_STATUS_O,JSON.stringify({dataVersion:t}),e),this._startPullRTCRoomStatus(this._roomId,e,t)}}this._callAppListener("onPing",e)}setBitrate(e,r,i){this._logger.warn(T.L_ABSTRACT_ROOM_SETBITRATE_O,"`RCAbstractRoom.setBitrate` will be deprecated, use `RCLocalTrack.setBitrate` instead."),h("max",e,(e=>t(e)&&e>Math.max(r||1,200)),!0),h("min",r,(r=>t(r)&&r>=1&&(!t(e)||r<e)),!0),h("start",i,(i=>t(i)&&i>r&&i<=e)),this._peerConnection.setBitrate(e,r,i)}_onTrackReady(e){const t=e.streams[0].id,{track:r}=e.receiver,i=[t,"audio"===r.kind?je.AUDIO_ONLY:je.VIDEO_ONLY].join("_"),n=this._store.getRemoteTrack(i);n?(n.__innerSetMediaStreamTrack(r),this._logger.info(T.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:O.SUCCESSED,eventType:"onTrackReady",trackId:n.getTrackId()})),this._callAppListener("onTrackReady",n)):this._logger.warn(T.L_ABSTRACT_ROOM_ONTRACKREADY_O,`cannot found remote track ${r.id}`)}_callAppListener(e,...t){var r;const i=null===(r=this._appListener)||void 0===r?void 0:r[e];if(i)try{i(...t)}catch(e){this._logger.error(T.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,null==e?void 0:e.stack)}}_onTrackUnpublish(e){this._logger.info(T.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:O.SUCCESSED,eventType:"onTrackUnpublish",trackIds:null==e?void 0:e.map((e=>e.getTrackId()))})),this._callAppListener("onTrackUnpublish",e)}__parseInnerMessage(e,t){const{targetId:r}=e;if(r!==this._roomId)return void this._logger.warn(T.L_ABSTRACT_ROOM_RECEIVE_MESSAGE_O,JSON.stringify({status:O.FAILED,message:`roomId is different, msg roomId-> ${r}, this._roomId-> ${this._roomId} `}),t);this._logger.info(T.L_ABSTRACT_ROOM_RECEIVE_MESSAGE_O,`recv inner msg -> message: ${JSON.stringify(e)} | roomid: ${this._roomId}`,t);const{content:i}=e;switch(e.messageType){case Vt.KICK:this.__kickoff(!0,i);break;case Vt.STATE:this._stateHandle(i,t);break;case Vt.MODIFY:case Vt.PUBLISH:case Vt.UNPUBLISH:case Vt.TOTAL_CONTENT_RESOURCE:this._resourceHandle(i,e.messageType,e.senderUserId,e.sentTime,t);break;case Vt.ASR_STATUS:this._invoker.push(new ta(i.asr_status));break;case Vt.ASR_SEI:this._invoker.push(new ra(JSON.parse(i.sei_ai_uris||"[]")));break;case Vt.SUMMARIZATION_STATUS:this._invoker.push(new na(i.status,i.taskId));break;case Vt.ROOM_NOTIFY:this._logger.info(T.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:O.SUCCESSED,eventType:"onRoomAttributeChange",messageType:e.messageType,messageContent:e.content})),this._callAppListener("onRoomAttributeChange",e.messageType,e.content);break;case Vt.USER_NOTIFY:this._logger.warn(T.L_OLD_DAILY_RECORD_O,`TODO: ${Vt.USER_NOTIFY}`);break;case Vt.PK_INVITE:case Vt.PK_CANCEL_INVITE:case Vt.PK_INVITE_TIMEOUT:case Vt.PK_INVITE_ANSWER:case Vt.PK_END:this._onRecvPKMsg&&this._onRecvPKMsg(e);break;case Vt.OTHER_ROOM_OFFLINE:break;default:this._logger.info(T.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:O.SUCCESSED,eventType:"onMessageReceive",messageType:e.messageType,messageContent:e.content,senderUserId:e.senderUserId,messageUId:e.messageUId})),this._callAppListener("onMessageReceive",e.messageType,i,e.senderUserId,e.messageUId)}}__kickoff(e,t){return E(this,void 0,void 0,(function*(){if(this._invoker.isDestroyed())return;let r,i;this._logger.warn(T.L_ABSTRACT_ROOM_ONKICKOFF_O,`onKickOff -> byServer: ${e}, kickContent: ${JSON.stringify(t)}`),this.emit(sa),this._leaveHandle(!e),e&&((null==t?void 0:t.users)||[]).forEach((e=>{e.userId===this._context.getCurrentId()&&(i=e.type,r=e.kickExtra,this._reportMediaActionLogger.reportQualityKickedData(i))})),this._logger.info(T.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:O.SUCCESSED,eventType:"onKickOff",byServer:e,kickType:i,kickExtra:r})),this._callAppListener("onKickOff",e,i,r)}))}_rtcpeerClosed(){this.emit(sa),this._leaveHandle(!0),this._logger.info(T.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,r,i,n){return E(this,void 0,void 0,(function*(){const{uris:s,ignore:o}=e;!o&&s&&this._invoker.push(new No(e,t,r,n,i))}))}_onTrackPublish(e,t,r){this._logger.info(T.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:O.SUCCESSED,eventType:"onTrackPublish",trackIds:null==e?void 0:e.map((e=>e.getTrackId()))})),this._callAppListener("onTrackPublish",e)}_stateHandle(e,t){return E(this,void 0,void 0,(function*(){const r=(yield this._invoker.push(new yo(e,t))).data;this._dealUserAppListener(r)}))}_dealUserAppListener(e){var t,r;const{left:i,joined:n,upgrade:s,downgrade:o,offline:a}=e,c=[...n],_=[...i];(null===(t=this._appListener)||void 0===t?void 0:t.onSwitchRole)?(null==s||s.forEach((e=>{this._logger.info(T.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:O.SUCCESSED,eventType:"onSwitchRole",userId:e,role:As.ANCHOR})),this._callAppListener("onSwitchRole",e,As.ANCHOR)})),null==o||o.forEach((e=>{this._logger.info(T.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:O.SUCCESSED,eventType:"onSwitchRole",userId:e,role:As.AUDIENCE})),this._callAppListener("onSwitchRole",e,As.AUDIENCE)}))):(c.push(...s),_.push(...o)),a.length&&((null===(r=this._appListener)||void 0===r?void 0:r.onUserOffline)?(this._logger.info(T.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:O.SUCCESSED,eventType:"onUserOffline",offline:a})),this._callAppListener("onUserOffline",a)):_.push(...a)),c.length>0&&(this._logger.info(T.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:O.SUCCESSED,eventType:"onUserJoin",allJoined:c})),this._callAppListener("onUserJoin",c)),_.length>0&&(this._logger.info(T.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:O.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 E(this,void 0,void 0,(function*(){const r=this._logger.createTraceId();this._logger.info(T.L_ABSTRACT_ROOM_SEND_MESSAGE_T,JSON.stringify({name:e,content:t}),r);const{code:i}=yield this._context.sendMessage(g.RTC_ROOM,this._roomId,{messageType:e,content:t,isStatusMessage:!0});return i!==o.SUCCESS?(this._logger.error(T.L_ABSTRACT_ROOM_SEND_MESSAGE_R,JSON.stringify({status:O.FAILED,code:i}),r),{code:I.SIGNAL_ERROR}):(this._logger.info(T.L_ABSTRACT_ROOM_SEND_MESSAGE_R,JSON.stringify({status:O.SUCCESSED,name:e,content:t}),r),{code:I.SUCCESS})}))}setRoomAttribute(e,t,r,i=!1){return E(this,void 0,void 0,(function*(){const n=this._logger.createTraceId();this._logger.info(T.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:this._roomId,key:e,value:t,message:r,isInner:i}),n);const s=yield this._context.setRTCData(this._roomId,e,t,i,Us.ROOM,r);return s!==o.SUCCESS?(this._logger.error(T.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_R,JSON.stringify({status:O.FAILED,code:s}),n),{code:I.SIGNAL_ERROR}):(this._logger.info(T.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_R,JSON.stringify({status:O.SUCCESSED,roomId:this._roomId,key:e,value:t,message:r,isInner:i}),n),{code:I.SUCCESS})}))}deleteRoomAttributes(e,t,r=!1){return E(this,void 0,void 0,(function*(){const i=this._logger.createTraceId();this._logger.info(T.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:this._roomId,keys:e,message:t,isInner:r}),i);const n=yield this._context.removeRTCData(this._roomId,e,r,Us.ROOM,t);return n!==o.SUCCESS?(this._logger.error(T.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:O.FAILED,code:n}),i),{code:I.SIGNAL_ERROR}):(this._logger.info(T.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:O.SUCCESSED,roomId:this._roomId,keys:e,message:t,isInner:r}),i),{code:I.SUCCESS})}))}getRoomAttributes(e=[],t=!1){return E(this,void 0,void 0,(function*(){const r=this._logger.createTraceId();this._logger.info(T.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:this._roomId,keys:e,isInner:t}),r);const{code:i,data:n}=yield this._context.getRTCData(this._roomId,e,t,Us.ROOM);return i!==o.SUCCESS?(this._logger.error(T.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_R,`GetRoomAttributes Failed: ${i}`,r),{code:I.SIGNAL_ERROR}):(this._logger.info(T.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:O.SUCCESSED,data:n}),r),{code:I.SUCCESS,data:n})}))}_setUserAttributeValue(e,t,r){return this._context.setRTCData(this._roomId,e,t,!1,Us.PERSON,r)}_deleteUserAttributes(e,t){return this._context.removeRTCData(this._roomId,e,!1,Us.PERSON,t)}_getUserAttributes(e){return this._context.getRTCData(this._roomId,e,!1,Us.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 E(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 rt&&e.__isTiny()||this.unpublish([e])}_onLocalTrackMuted(e,t){return E(this,void 0,void 0,(function*(){const{code:r}=yield this._invoker.push(new Uo(e));t(r)}))}publish(e){return E(this,void 0,void 0,(function*(){return this._invoker.push(new Po(e))}))}_getPushOtherRoomsParams(){return[]}_reTryExchange(){return this._invoker.push(new Mo)}unpublish(e){return E(this,void 0,void 0,(function*(){return this._invoker.push(new ko(e))}))}_isValidResourceId(e){var t;const{userId:r}=It(e);return!!(null===(t=this._store.getResourcesByUserId(r))||void 0===t?void 0:t.find((t=>Et(t)===e)))}subscribe(e){return E(this,void 0,void 0,(function*(){return this._invoker.push(new Do(e,void 0,void 0))}))}unsubscribe(e){return E(this,void 0,void 0,(function*(){const t=this._logger.createTraceId();return this._logger.info(T.L_APP_CALL_UNSUBSCRIBE_O,void 0,t),this._invoker.push(new mo(e,t))}))}updateSubList(e){return E(this,void 0,void 0,(function*(){return this._invoker.push(new po(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(T.L_ABSTRACT_ROOM_REGISTER_ROOM_EVENT_LISTENER_O,e?Object.keys(e).join(","):null),this._appListener=e,this.asrIsAvailable()&&this._executeCtx.emit(so);const t=this.getSummarizationStatusData();t&&(null==t?void 0:t.status)===ss.OPEN&&this._executeCtx.emit(ao,t.taskId)}registerReportListener(e){this._logger.info(T.L_ABSTRACT_ROOM_REGISTER_REPORT_LISTENER_O,e?Object.keys(e).join(","):null),this._peerConnection.registerReportListener(e)}onAudioLevelChange(e,t){this._logger.info(T.L_ABSTRACT_ROOM_AUDIO_LEVEL_O),this._audioLevelReport.onAudioLevelChange(e)}__onReconnected(e){this._invoker.push(new Bo(e))}_onAudioMuteChange(e){this._logger.info(T.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:O.SUCCESSED,eventType:"onAudioMuteChange",trackId:e.getTrackId()})),this._callAppListener("onAudioMuteChange",e)}_onVideoMuteChange(e){this._logger.info(T.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:O.SUCCESSED,eventType:"onVideoMuteChange",trackId:e.getTrackId()})),this._callAppListener("onVideoMuteChange",e)}_registerPKMsgListener(e){this._onRecvPKMsg=e}_quitAllPKRoom(){return E(this,void 0,void 0,(function*(){}))}getClientSessionId(){return this._store.clientSessionId}changeMediaDevice(e,t){return E(this,void 0,void 0,(function*(){return this._invoker.push(new Zo(e,t))}))}startASR(){return this._invoker.push(new Qo(Ps.OPEN))}stopASR(){return this._invoker.push(new Qo(Ps.CLOSE))}asrIsAvailable(){return this._store.getASRIsAvailable()}setEnableASR(e){return this._invoker.push(new Xo(e))}startRealtimeTranslation(e){return this._invoker.push(new ea(zo.OPEN,e))}stopRealtimeTranslation(){return this._invoker.push(new ea(zo.CLOSE))}startSummarization(){return this._invoker.push(new ia(!0))}stopSummarization(){return this._invoker.push(new ia(!1))}getSummarizationStatusData(){return this._store.getSummarizationStatusData()}}class aa extends Gs{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 ys.MCUCONFIG_FLUSH}execute(e,t,r){var i,n,s,o;return E(this,void 0,void 0,(function*(){const{context:r,service:a}=e,c={"App-Key":r.getAppkey(),Token:t.getToken(),RoomId:t.roomId,UserId:r.getCurrentId(),SessionId:t.getSessionId()},{code:_,res:d}=yield a.setMcuConfig(c,this.data);if(_!==I.SUCCESS)return{code:_};d.pull_url&&t.setCDNUris(JSON.parse(d.pull_url));const l=this.cdnValues;return _===I.SUCCESS&&((null===(n=null===(i=l.output)||void 0===i?void 0:i.video.normal)||void 0===n?void 0:n.width)||(null===(o=null===(s=l.output)||void 0===s?void 0:s.video.normal)||void 0===o?void 0:o.fps))&&To(r,t),{code:_,data:d}}))}}var ca,_a,da,la;!function(e){e[e.CROP=1]="CROP",e[e.WHOLE=2]="WHOLE"}(ca||(ca={})),function(e){e[e.CUSTOMIZE=1]="CUSTOMIZE",e[e.SUSPENSION=2]="SUSPENSION",e[e.ADAPTATION=3]="ADAPTATION"}(_a||(_a={})),function(e){e[e.CROP=1]="CROP",e[e.WHOLE=2]="WHOLE"}(da||(da={})),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"}(la||(la={}));const ua=()=>({version:2,mode:_a.SUSPENSION});class ha{constructor(e,t,r){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:r}),Object.defineProperty(this,"_values",{enumerable:!0,configurable:!0,writable:!0,value:ua()}),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(T.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:O.FAILED,msg:`videoTrackId: ${e} is invalid`})),this;const{mediaType:t,tag:r,userId:i}=It(e);return t!==je.VIDEO_ONLY?(this._logger.error(T.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:O.FAILED,msg:`kind of ${e} is not video`})),this):(this._values.host_stream_id=Tt(i,r),this._logger.info(T.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:O.SUCCESSED,videoTrackId:e})),this)}setMixLayoutMode(e){return[_a.CUSTOMIZE,_a.SUSPENSION,_a.ADAPTATION].includes(e)?(this._values.mode=e,this._logger.info(T.L_MCU_CONFIG_BUILDER_SET_MIX_LAYOUT_MODE_O,JSON.stringify({status:O.SUCCESSED,mode:e})),this):(this._logger.error(T.L_MCU_CONFIG_BUILDER_SET_MIX_LAYOUT_MODE_O,JSON.stringify({status:O.SUCCESSED,msg:`mode: ${e} is invalid`})),this)}_addOutputValue(e,t,r="normal"){const i=this._values.output||(this._values.output={video:{normal:{width:640,height:480}}});if("cdn"===e)return void(i.cdn=t);if("audio"===e)return void(i.audio={bitrate:t});const{video:n}=i;if("normal"!==r&&"tiny"!==r)if("backgroundColor"!==r)if("exparams"!==r){if("backgroundPicture"===r){const e=n.backgroundPicture||(n.backgroundPicture={fillMode:ca.CROP,picture:[]});Object.assign(e,t)}}else n.exparams={renderMode:t};else n.backgroundColor=t;else{const e=n[r]||(n[r]={});Object.assign(e,t)}}setOutputVideoResolution(e){if(!bt(e))return this._logger.error(T.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RESOLUTION_O,JSON.stringify({status:O.FAILED,msg:`params error -> resolution: ${e}`})),this;const{width:t,height:r}=Lt(e);return this._addOutputValue("video",{width:t,height:r},"normal"),this._logger.info(T.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RESOLUTION_O,JSON.stringify({status:O.SUCCESSED,resolution:e})),this}setOutputVideoFPS(e){if(!At(e))return this._logger.error(T.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_FPS_O,JSON.stringify({status:O.FAILED,msg:`params error -> fps: ${e}`})),this;const t=yt(e);return this._addOutputValue("video",{fps:t},"normal"),this._logger.info(T.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_FPS_O,JSON.stringify({status:O.SUCCESSED,fps:e})),this}setOutputVideoBitrate(e){return!t(e)||e<=0?(this._logger.error(T.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_BITRATE_O,JSON.stringify({status:O.FAILED,msg:`params error -> bitrate: ${e}`})),this):(this._addOutputValue("video",{bitrate:e},"normal"),this._logger.info(T.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_BITRATE_O,JSON.stringify({status:O.SUCCESSED,bitrate:e})),this)}setOutputTinyVideoResolution(e){if(!bt(e))return this._logger.error(T.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_RESOLUTION_O,JSON.stringify({status:O.FAILED,msg:`params error -> resolution: ${e}`})),this;const{width:t,height:r}=Lt(e);return this._addOutputValue("video",{width:t,height:r},"tiny"),this._logger.info(T.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_RESOLUTION_O,JSON.stringify({status:O.SUCCESSED,resolution:e})),this}setOutputTinyVideoFPS(e){if(!At(e))return this._logger.error(T.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_FPS_O,JSON.stringify({status:O.FAILED,msg:`params error -> fps: ${e}`})),this;const t=yt(e);return this._addOutputValue("video",{fps:t},"tiny"),this._logger.info(T.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_FPS_O,JSON.stringify({status:O.SUCCESSED,fps:e})),this}setOutputTinyVideoBitrate(e){return!t(e)||e<=0?(this._logger.error(T.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_BITRATE_O,JSON.stringify({status:O.FAILED,msg:`params error -> bitrate: ${e}`})),this):(this._addOutputValue("video",{bitrate:e},"tiny"),this._logger.info(T.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_BITRATE_O,JSON.stringify({status:O.SUCCESSED,bitrate:e})),this)}setOutputVideoRenderMode(e){return[da.CROP,da.WHOLE].includes(e)?(this._addOutputValue("video",e,"exparams"),this._logger.info(T.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RENDER_MODE_O,JSON.stringify({status:O.SUCCESSED,renderMode:e})),this):(this._logger.error(T.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RENDER_MODE_O,JSON.stringify({status:O.FAILED,msg:`params error -> renderMode: ${e}`})),this)}setOutputAudioBitrate(e){return t(e)&&e>0?(this._addOutputValue("audio",e),this._logger.info(T.L_MCU_CONFIG_BUILDER_SET_OUTPUT_AUDIO_BITRATE_O,JSON.stringify({status:O.SUCCESSED,bitrate:e})),this):(this._logger.error(T.L_MCU_CONFIG_BUILDER_SET_OUTPUT_AUDIO_BITRATE_O,JSON.stringify({status:O.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(T.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_COLOR_O,JSON.stringify({status:O.SUCCESSED,color:e})),this):(this._logger.error(T.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_COLOR_O,JSON.stringify({status:O.FAILED,msg:`params error -> color: ${e}`})),this)}addOutputBackgroundPicture(e,r,i,n,s){var o,a,c;if(!R(e))return this._logger.error(T.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:O.FAILED,msg:`params error -> uri: ${e}`})),this;if([r,i,n,s].some((e=>!t(e)||e<0||e>1)))return this._logger.error(T.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:O.FAILED,msg:`params of (x, y, w, h) error -> x: ${r}, y: ${i}, w: ${n}, h: ${s}`})),this;const _=(null===(c=null===(a=null===(o=this._values.output)||void 0===o?void 0:o.video)||void 0===a?void 0:a.backgroundPicture)||void 0===c?void 0:c.picture)||[];return _.push({uri:e,w:n,h:s,x:r,y:i}),this._addOutputValue("video",{picture:_},"backgroundPicture"),this._logger.info(T.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:O.SUCCESSED,uri:e,x:r,y:i,w:n,h:s})),this}removeOutputBackgroundPicture(e){var t,r,i;if(!R(e))return this._logger.error(T.L_MCU_CONFIG_BUILDER_REMOVE_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:O.FAILED,msg:`params error -> uri: ${e}`})),this;let n=null===(i=null===(r=null===(t=this._values.output)||void 0===t?void 0:t.video)||void 0===r?void 0:r.backgroundPicture)||void 0===i?void 0:i.picture;return n&&(n=n.filter((t=>t.uri!==e)),this._addOutputValue("video",{pictures:n},"backgroundPicture")),this._logger.info(T.L_MCU_CONFIG_BUILDER_REMOVE_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:O.SUCCESSED,uri:e})),this}clearOutputBackgroundPicture(){return this._addOutputValue("video",{pictures:[]},"backgroundPicture"),this._logger.info(T.L_MCU_CONFIG_BUILDER_CLEAR_OUTPUT_BACKGROUND_PICTURE_O),this}setOutputBackgroundPictureFillMode(e){return[ca.CROP,ca.WHOLE].includes(e)?(this._addOutputValue("video",{fillMode:e},"backgroundPicture"),this._logger.info(T.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:O.SUCCESSED,fillMode:e})),this):(this._logger.error(T.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:O.FAILED,msg:`params error -> fillMode: ${e}`})),this)}addPublishStreamUrls(e){var t,r;const i=/^rtmp:\/\/.+/;if(!d(e)||0===e.length||e.some((e=>!i.test(e))))return this._logger.error(T.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:O.FAILED,msg:`params error -> urls: ${e.join(",")}`})),this;const n=(null===(r=null===(t=this._values.output)||void 0===t?void 0:t.cdn)||void 0===r?void 0:r.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(T.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:O.FAILED,msg:`params error -> publish stream urls no more than 5, length: ${e.length}`})),this):(s&&this._addOutputValue("cdn",n),this._logger.info(T.L_MCU_CONFIG_BUILDER_ADD_PUBLISH_STREAM_URLS_O,JSON.stringify({status:O.SUCCESSED,urls:e})),this)}removePublishStreamUrls(e){var t,r;const i=/^rtmp:\/\/.+/;if(!d(e)||0===e.length||e.some((e=>!i.test(e))))return this._logger.error(T.L_MCU_CONFIG_BUILDER_REMOVE_PUBLISH_STREAM_URLS_O,JSON.stringify({status:O.FAILED,msg:`params error -> urls: ${e.join(",")}`})),this;const n=(null===(r=null===(t=this._values.output)||void 0===t?void 0:t.cdn)||void 0===r?void 0:r.concat())||[];for(let t=n.length-1;t>=0;t-=1){const{pushurl:r}=n[t],i=e.indexOf(r);i>=0&&(e.splice(i,1),n.splice(t,1))}return this._addOutputValue("cdn",n),this._logger.info(T.L_MCU_CONFIG_BUILDER_REMOVE_PUBLISH_STREAM_URLS_O,JSON.stringify({status:O.SUCCESSED,urls:e})),this}clearPublishStreamUrls(){return this._addOutputValue("cdn",[]),this._logger.info(T.L_MCU_CONFIG_BUILDER_CLEAR_PUBLISH_STREAM_URLS_O),this}addCustomizeLayoutVideo(e,r,i,n,s){if(!_(e)||!this._isValidTrackId(e))return this._logger.error(T.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:O.FAILED,msg:`params error -> trackId: ${e}`})),this;if(!t(r)||!t(i))return this._logger.error(T.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:O.FAILED,msg:`params x or y is error -> x: ${r}, y: ${i}`})),this;if([n,s].some((e=>!t(e)||e<0)))return this._logger.error(T.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:O.FAILED,msg:`params width or height error -> width: ${n}, height: ${s}`})),this;const{userId:o,tag:a,mediaType:c}=It(e);if(c!==je.VIDEO_ONLY)return this._logger.error(T.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:O.FAILED,msg:`type of trackId: ${e} is not video`})),this;const d=Tt(o,a),l=this._values.input||(this._values.input={}),u=l.video||(l.video=[]);return u.some((e=>e.height===s&&e.width===n&&e.stream_id===d&&e.user_id===o&&e.x===r&&e.y===i))?(this._logger.warn(T.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:O.FAILED,msg:"Duplicate configuration item place ignored"})),this):(u.push({user_id:o,stream_id:d,x:r,y:i,width:n,height:s}),this._logger.info(T.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:O.SUCCESSED,trackId:e,x:r,y:i,width:n,height:s})),this)}removeCustomizeLayoutVideo(e){if(!this._isValidTrackId(e))return this._logger.error(T.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:O.FAILED,msg:`params error -> trackId: ${e}`})),this;const{userId:t,tag:r,mediaType:i}=It(e);if(i!==je.VIDEO_ONLY)return this._logger.error(T.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:O.FAILED,msg:`type of trackId: ${e} is not video`})),this;const n=Tt(t,r),{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(T.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:O.SUCCESSED,trackId:e})),this}clearCustomizeLayoutVideo(){const{input:e}=this._values;return null==e||delete e.video,this._logger.info(T.L_MCU_CONFIG_BUILDER_CLEAR_CUSTOMIZE_LAYOUT_VIDEO_O),this}setCustomizeInputAudio(e){if(e.some((e=>this._isValidTrackId(e))))return this._logger.error(T.L_MCU_CONFIG_BUILDER_SET_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:O.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:r}=It(e);return{stream_id:Tt(t,r),user_id:t}})),this._values.inputFilterMode=la.AUDIO_INPUT_VIDEO_ALL,this._logger.info(T.L_MCU_CONFIG_BUILDER_SET_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:O.SUCCESSED,trackIds:e})),this}addCustomizeInputAudio(e){if(!this._isValidTrackId(e))return this._logger.error(T.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:O.FAILED,msg:`params error -> trackId: ${e}`})),this;const t=this._values.input||(this._values.input={}),r=t.audio||(t.audio=[]),{userId:i,tag:n}=It(e),s=Tt(i,n);return r.some((e=>e.stream_id===s&&e.user_id===i))?(this._logger.warn(T.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:O.FAILED,msg:`trackId: ${e} is exist`})),this):(r.push({user_id:i,stream_id:s}),this._values.inputFilterMode=la.AUDIO_INPUT_VIDEO_ALL,this._logger.info(T.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:O.SUCCESSED,trackId:e})),this)}removeCustomizeInputAudio(e){if(!this._isValidTrackId(e))return this._logger.error(T.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:O.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(T.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:O.FAILED,msg:`type of trackId: ${e} is not audio`})),this;const{userId:r,tag:i}=It(e),n=Tt(r,i);return t.audio=t.audio.filter((e=>r!==e.user_id||n!==e.stream_id)),this._logger.info(T.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:O.SUCCESSED,trackId:e})),this}clearCustomizeInputAudio(){const{input:e}=this._values;return(null==e?void 0:e.audio)&&delete e.audio,this._values.inputFilterMode=la.AUDIO_VIDEO_ALL,this._logger.info(T.L_MCU_CONFIG_BUILDER_CLEAR_CUSTOMIZE_INPUT_AUDIO_O),this}addPictureWaterMark(e,r,i,n,s,o){if(!this._isValidTrackId(e))return this._logger.error(T.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:O.FAILED,msg:`params error -> trackId: ${e}`})),this;if(!R(r))return this._logger.error(T.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:O.FAILED,msg:`params error -> uri: ${r}`})),this;if([i,n,s,o].some((e=>!t(e)||e<0||e>1))||i+s>1||n+o>1)return this._logger.error(T.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:O.FAILED,msg:`some attrs of (x, y, w, h) is invalid -> x: ${i}, y: ${n}, w: ${s}, h: ${o}`})),this;const{userId:a,tag:c}=It(e),_=Tt(a,c),d=this._values.waterMark||(this._values.waterMark={enable:"on",singleScreen:[]}),{singleScreen:l}=d,u=l.filter((e=>e.streamId===_))[0];return u?u.picture.push({uri:r,w:s,h:o,x:i,y:n}):l.push({streamId:_,picture:[{uri:r,w:s,h:o,x:i,y:n}]}),this._values.waterMark.singleScreen=l,this._logger.info(T.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:O.SUCCESSED,trackId:e,uri:r,x:i,y:n,w:s,h:o,singleScreen:l})),this}clearPictureWaterMark(){return(this._values.waterMark||(this._values.waterMark={enable:"on",singleScreen:[]})).singleScreen=[],this._logger.info(T.L_MCU_CONFIG_BUILDER_CLEAR_OUTPUT_BACKGROUND_PICTURE_O),this}removePictureWaterMark(e,t){if(!_(e)||!this._isValidTrackId(e))return this._logger.error(T.L_MCU_CONFIG_BUILDER_REMOVE_SINGLE_WATER_MARK_O,JSON.stringify({status:O.FAILED,msg:`params error -> trackId: ${e}`})),this;const{userId:r,tag:i}=It(e),n=Tt(r,i),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(T.L_MCU_CONFIG_BUILDER_REMOVE_SINGLE_WATER_MARK_O,JSON.stringify({status:O.SUCCESSED,trackId:e,uri:t})),this}reset(){return this._values=ua(),this._logger.info(T.L_MCU_CONFIG_BUILDER_RESET_O),this}flush(e=!0){return E(this,void 0,void 0,(function*(){const t=JSON.parse(JSON.stringify(this._values)),{code:r}=yield this._invoker.push(new aa(t,this._values));return e&&(this._values=ua()),{code:r}}))}__innerGetValues(){return JSON.parse(JSON.stringify(this._values))}}var ga,Ra,pa;!function(e){e[e.VIDEO=0]="VIDEO",e[e.AUDIO=1]="AUDIO"}(ga||(ga={}));class ma extends Gs{constructor(e,t,r){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:r})}_exchangeWithPushOtherRoom(e,t,r){return E(this,void 0,void 0,(function*(){const{logger:i,peer:n,context:s}=e;if(!n.getLocalTracks().length)return void i.info(T.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:O.SUCCESSED,msg:"have not published resource"}),this.traceId);const o=n,a=t.getSubscribedList(),c=yield So(a,!1,o,t,s),_=e.getPushOtherRooms();c.pushOtherRooms=_;const d=yield new Ro(c,this.traceId,!0).execute(e,t,r);if(d.code!==I.SUCCESS)return void i.error(T.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:O.FAILED,code:d.code,pushOtherRooms:_}),this.traceId);const{sdp:l,resultCode:u}=d.data.data;u===I.SUCCESS?(i.info(T.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:O.SUCCESSED,pushOtherRooms:_}),this.traceId),o.setRemoteAnswer(l.sdp)):i.error(T.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:O.FAILED,code:u,pushOtherRooms:_}),this.traceId)}))}get kind(){return ys.EXCHANGE_WITH_PUSH_OTHER_ROOM}execute(e,t,r){return E(this,void 0,void 0,(function*(){const{logger:i}=e,{roomId:n}=this;if(i.info(T.L_EXCHANGE_WITH_PUSHOTHERROOM_T,n),!this.roomPKHandler)return i.error(T.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:O.FAILED,msg:"_roomPKHandler not exist"}),this.traceId),{code:I.SUCCESS};return this.roomPKHandler.getPKInfo(n)?(yield this._exchangeWithPushOtherRoom(e,t,r),{code:I.SUCCESS}):(i.warn(T.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:O.FAILED,msg:"PKInfo not exist"}),this.traceId),{code:I.SUCCESS})}))}}class fa extends Gs{constructor(e,t,r,i,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:r}),Object.defineProperty(this,"_joinedPKRooms",{enumerable:!0,configurable:!0,writable:!0,value:i}),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 ys.LEAVE_OTHER_ROOM}quitRoomPK(e,t,r,i){return E(this,void 0,void 0,(function*(){const{logger:n,context:s}=e;if(n.info(T.L_QUIT_PK_T,`roomId: ${t}`,i),!this._PKInfo[t])return void n.warn(T.L_QUIT_PK_R,`status: ${O.FAILED}, msg: pkinfo is empty`,i);const{inviterRoomId:a,inviteeRoomId:c,inviterUserId:_,inviteSessionId:d}=this._PKInfo[t],l={inviteeRoomId:c,inviterRoomId:a,userId:r.crtUserId},u={roomId:r.roomId,endRoomId:t,sessionId:d,content:JSON.stringify(l),keys:[`${a}|${_}`]},h=yield s.endRoomPK(u);if(h!==o.SUCCESS)return n.error(T.L_QUIT_PK_R,`status: ${O.FAILED}, code: ${h}`,i),{code:I.SIGNAL_ERROR};n.info(T.L_QUIT_PK_R,`status: ${O.SUCCESSED}`,i),delete this._PKInfo[t]}))}execute(e,t,r){return E(this,void 0,void 0,(function*(){const{logger:i}=e,{room:n,isQuitPK:s}=this,o=n.getRoomId();return i.info(T.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 ma(o,this.pkHandler,this.traceId).execute(e,t,r),s&&this.quitRoomPK(e,o,t,this.traceId),i.info(T.L_LIVING_ROOM_LEAVE_PK_ROOM_R,JSON.stringify({status:O.SUCCESSED}),this.traceId),{code:I.SUCCESS}}))}}class Sa{constructor(e,t,r,i,n,s,o,a,c,_){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:r}),Object.defineProperty(this,"_runtime",{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,"_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:c}),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 r;const i=null===(r=this._appListener)||void 0===r?void 0:r[e];if(i)try{i(...t)}catch(e){this._logger.error(T.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify(e))}}_onInvite(e){const t=e.inviteInfo||{},{inviterRoomId:r,inviterUserId:i,extra:n}=t,s={inviterRoomId:r,inviterUserId:i,extra:n};this._PKInfo[r]=t,this._logger.info(T.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onRequestJoinOtherRoom",info:s})),this._callAppListener("onRequestJoinOtherRoom",s)}_onCancelInvite(e){const{inviterRoomId:t,inviterUserId:r,extra:i}=e.inviteInfo||{},n={inviterRoomId:t,inviterUserId:r,extra:i};delete this._PKInfo[t],this._logger.info(T.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:r}=e,{inviteSessionId:i,inviterUserId:n,inviterRoomId:s,inviteeUserId:o,inviterUserAutoMix:a,inviteeUserAutoMix:c,inviteeRoomId:_,extra:d}=r,l={agree:1===t,inviterRoomId:s,inviterUserId:n,inviteeRoomId:_,inviteeUserId:o,extra:d};this._PKInfo[_]=this._PKInfo[_]||{inviteSessionId:i,inviterRoomId:s,inviterUserId:n,inviterUserAutoMix:a,inviteeRoomId:_},this._PKInfo[_].inviteeUserAutoMix=c,this._logger.info(T.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onResponseJoinOtherRoom",answerInfo:l})),this._callAppListener("onResponseJoinOtherRoom",l)}createLeaveOtherRoomCommand(e,t,r){return new fa(this,e,this._PKInfo,this._joinedPKRooms,t,r)}_onPKEnd(e){return E(this,void 0,void 0,(function*(){const{inviteeRoomId:t,inviterRoomId:r,userId:i}=e.inviteInfo,n=r===this._mainRoomId?t:r,s={endRoomId:n,endUserId:i},o=this._joinedPKRooms[n],a=this._logger.createTraceId();this._logger.info(T.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(T.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onFinishOtherRoom",endInfo:s})),this._callAppListener("onFinishOtherRoom",s)}))}_onRecvPKMsg(e){const{content:t,messageType:r}=e;switch(r){case Vt.PK_INVITE:this._onInvite(t);break;case Vt.PK_CANCEL_INVITE:this._onCancelInvite(t);break;case Vt.PK_INVITE_TIMEOUT:this._onInviteTimeout(t);break;case Vt.PK_INVITE_ANSWER:this._onInviteAnswer(t);break;case Vt.PK_END:this._onPKEnd(t)}}registerRoomPKEventListener(e){this._logger.info(T.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 E(this,void 0,void 0,(function*(){const n=this._logger.createTraceId();if(this._logger.info(T.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_T,JSON.stringify({inviteeRoomId:e,inviteeUserId:t,options:i}),n),!r("inviteeRoomId",e,_,!0)||!r("inviteeUserId",t,_,!0))return this._logger.error(T.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> inviteeRoomId or inviteeUserId"}),n),{code:I.PARAMS_ERROR};const a=rs(),c=!s(null==i?void 0:i.autoMix)||(null==i?void 0:i.autoMix),d={inviteSessionId:a,inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviterUserAutoMix:c,inviteeRoomId:e,inviteeUserId:t,inviteeTimeoutTime:this._inviteTimeout,extra:(null==i?void 0:i.extra)||""},l={roomId:this._mainRoomId,invitedRoomId:e,invitedUserId:t,inviteTimeout:this._inviteTimeout,inviteInfo:JSON.stringify(d),inviteSessionId:a},u=yield this._context.requestRoomPK(l);return u!==o.SUCCESS?(this._logger.error(T.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.FAILED,code:u}),n),{code:u}):(this._PKInfo[e]={inviteSessionId:a,inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviterUserAutoMix:c,inviteeRoomId:e},this._logger.info(T.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.SUCCESSED}),n),{code:I.SUCCESS})}))}cancelRequestJoinOtherRoom(e,t,i){return E(this,void 0,void 0,(function*(){const n=this._logger.createTraceId();if(this._logger.info(T.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_T,JSON.stringify({inviteeRoomId:e,inviteeUserId:t,extra:i}),n),!r("inviteeRoomId",e,_,!0)||!r("inviteeUserId",t,_,!0))return this._logger.error(T.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> inviteeRoomId or inviteeUserId"}),n),{code:I.PARAMS_ERROR};if(!this._PKInfo[e])return this._logger.error(T.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:`The request to connect with ${t} user in room ${e} is not initiated`}),n),{code:I.PARAMS_ERROR};const s={inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviteeRoomId:e,inviteeUserId:t,extra:i||""},a={roomId:this._mainRoomId,invitedRoomId:e,invitedUserId:t,inviteSessionId:this._PKInfo[e].inviteSessionId,inviteInfo:JSON.stringify(s)},c=yield this._context.cancelRoomPK(a);return c!==o.SUCCESS?(this._logger.error(T.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.FAILED,code:c}),n),{code:c}):(this._logger.info(T.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.SUCCESSED}),n),delete this._PKInfo[e],{code:I.SUCCESS})}))}responseJoinOtherRoom(e,t,i,n){return E(this,void 0,void 0,(function*(){const a=this._logger.createTraceId();if(this._logger.info(T.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_T,JSON.stringify({inviterRoomId:e,inviterUserId:t,agree:i,options:n}),a),!r("inviterRoomId",e,_,!0)||!r("inviterUserId",t,_,!0))return this._logger.error(T.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> inviterRoomId or inviterUserId"}),a),{code:I.PARAMS_ERROR};if(!this._PKInfo[e])return this._logger.error(T.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:`User ${t} in room ${e} did not send a request for connection`}),a),{code:I.PARAMS_ERROR};const{inviteSessionId:c,inviterUserAutoMix:d}=this._PKInfo[e],l=!s(null==n?void 0:n.autoMix)||(null==n?void 0:n.autoMix),u={inviteSessionId:c,inviterRoomId:e,inviterUserId:t,inviterUserAutoMix:d,inviteeRoomId:this._mainRoomId,inviteeUserId:this._context.getCurrentId(),inviteeUserAutoMix:l},h=Object.assign(u,{inviterUserAutoMix:d}),g=i?Object.assign(u,{MultiRoomKey:`${e}|${this._mainRoomId}`,MultiRoomValue:JSON.stringify(h)}):u;!p(null==n?void 0:n.extra)&&Object.assign(g,{extra:n.extra});const R={agree:i,roomId:this._mainRoomId,inviteSessionId:c,inviteRoomId:e,inviteUserId:t,content:JSON.stringify(g),key:`${e}|${this._mainRoomId}`,value:JSON.stringify(u)},m=yield this._context.responseRoomPK(R);return m!==o.SUCCESS?(this._logger.error(T.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.FAILED,code:m}),a),{code:m}):(this._logger.info(T.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.SUCCESSED}),a),this._PKInfo[e].inviteeUserAutoMix=l,{code:I.SUCCESS})}))}joinOtherRoom(e){return E(this,void 0,void 0,(function*(){const t=this._logger.createTraceId();if(this._logger.info(T.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_T,JSON.stringify({roomId:e}),t),!r("roomId",e,_,!0))return this._logger.error(T.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> roomId"}),t),{code:I.PARAMS_ERROR};if(this._context.getConnectionStatus()!==c.CONNECTED)return this._logger.error(T.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.FAILED,code:I.SIGNAL_DISCONNECTED,msg:"IM disconnected"}),t),{code:I.SIGNAL_DISCONNECTED};if(this._joinedPKRooms[e])return this._logger.warn(T.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.FAILED,code:I.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),t),{code:I.REPERT_JOIN_ROOM};const i=ga.VIDEO,n={extra:`{"roomId": "${this._mainRoomId}"}`},s=new Ta(this._context,this._runtime,e,this._service,this._initOptions,i,!1,!1,this._clientSessionId),{code:o}=yield s.__innerInit(ks.LIVE,void 0,i,n);return o!==I.SUCCESS?(this._logger.error(T.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.FAILED,code:o}),t),{code:o}):(this._joinedPKRooms[e]=s,yield this._onJoinedPKRoom(e,t),this._logger.info(T.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.SUCCESSED}),t),{room:s,code:I.SUCCESS,userIds:s.getRemoteUserIds(),tracks:s.getRemoteTracks()})}))}leaveOtherRoom(e,t){return E(this,void 0,void 0,(function*(){const r=this._logger.createTraceId();return this._logger.info(T.L_APP_CALL_LEAVE_PK_ROOM_O,void 0,r),this._invoker.push(this.createLeaveOtherRoomCommand(e,t,r))}))}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"}(Ra||(Ra={}));class Ea extends Gs{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 ys.ENABLE_INNER_CDN}execute(e,t,r){return E(this,void 0,void 0,(function*(){const{logger:i,context:n}=e,{enable:o}=this;if(i.info(T.L_LIVING_ROOM_ENABLE_INNER_CDN_T,JSON.stringify({roomId:t.roomId,enable:o})),!t.isMainRoom)return i.error(T.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:O.FAILED,code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),{code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM};if(!s(o))return i.error(T.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> enable"})),{code:I.PARAMS_ERROR};t.setCDNEnabel(o);const a={version:2,output:{inCDNModel:o?Ra.OPEN:Ra.STOP}},{code:c}=yield new aa(a,this.cdnValues).execute(e,t,r);if(c!==I.SUCCESS)return i.error(T.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:O.FAILED,code:c,msg:"signal error"})),{code:I.SIGNAL_ERROR};const _=t.getCDNUris();if(_&&_.broadcast!==ho.SPREAD)return i.info(T.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:O.SUCCESSED,enable:o})),{code:I.SUCCESS};const{code:d}=yield To(n,t);return d===I.SUCCESS?(i.info(T.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:O.SUCCESSED,enable:o})),{code:I.SUCCESS}):(i.error(T.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:O.FAILED,code:d})),{code:d})}))}}!function(e){e[e.AnchorToViewer=1]="AnchorToViewer",e[e.ViewerToAnchor=2]="ViewerToAnchor"}(pa||(pa={}));class Ia extends Gs{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 ys.RTC_IDENTITY_CHANGE}execute(e,t,r){var i;return E(this,void 0,void 0,(function*(){const{context:n}=e,{code:s,data:a}=yield n.rtcIdentityChange(t.roomId,pa.ViewerToAnchor,this.livingType);if(s!==o.SUCCESS||!a)return{code:s};t.initWithRoomData(a,this.traceId);t.getResourcesByUserId(t.crtUserId).length>0&&r.push(new zs);const c=null===(i=a.roomInfo.filter((e=>"cdn_uris"===e.key))[0])||void 0===i?void 0:i.value;return c&&t.setCDNUris(JSON.parse(c)[0]),{code:s,data:a}}))}}class Ta extends oa{constructor(e,t,r,i,n,s,o,a,c){super(e,t,r,ks.LIVE,i,n,o,a,c),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 ha(this._executeCtx,this._invoker,this._isValidResourceId.bind(this))}_initRoomPKHandler(e){if(this._store.isMainRoom){const t=((e,t)=>{const r={};return t.forEach((t=>{const i=JSON.parse(t.value),{inviterRoomId:n,inviteeRoomId:s}=i;r[e===n?s:n]=JSON.parse(t.value)})),r})(this._roomId,e.roomInfo);this._roomPKHandler=new Sa(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,n,s,o){const a=Object.create(null,{__innerInit:{get:()=>super.__innerInit}});return E(this,void 0,void 0,(function*(){if(!r("livingType",i,(e=>e===ga.AUDIO||e===ga.VIDEO)))return this._logger.error(T.L_RTC_CLIENT_JOIN_LIVING_ROOM_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> livingType"}),o),{code:I.PARAMS_ERROR};const{code:c,data:_}=yield a.__innerInit.call(this,e,t,i,n,s,o);return c===I.SUCCESS&&_&&this._initRoomPKHandler(_),{code:c,data:_}}))}__innerInitByIdentityChange(e){return E(this,void 0,void 0,(function*(){const{code:t,data:r}=yield this._invoker.push(new Ia(this._livingType,e));return t===o.SUCCESS&&r?(this._initRoomPKHandler(r),this._initWithRoomData(r.offlineKickTime),this._logger.info(T.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:O.SUCCESSED,roomData:r}),e)):this._logger.error(T.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:O.FAILED,code:t}),e),t}))}publish(e){const t=Object.create(null,{publish:{get:()=>super.publish}});return E(this,void 0,void 0,(function*(){return this._store.isMainRoom?t.publish.call(this,e):(this._logger.error(T.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:O.FAILED,code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),{code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}))}unpublish(e){const t=Object.create(null,{unpublish:{get:()=>super.unpublish}});return E(this,void 0,void 0,(function*(){return this._store.isMainRoom?t.unpublish.call(this,e):(this._logger.error(T.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:O.FAILED,code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),{code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}))}_isValidResourceId(e){var t;const{userId:r}=It(e),i=!!(null===(t=this._store.getResourcesByUserId(r))||void 0===t?void 0:t.find((t=>Et(t)===e)));let n=!1;const{code:s,roomPKHandler:o}=this.getRoomPKHandler();if(s!==I.SUCCESS||!o)return i;const a=o.getJoinedPKRooms(),c=[];return Object.values(a).forEach((e=>{c.push(...e.getRemoteTracks())})),n=c.some((t=>e===t.getTrackId())),i||n}getLivingType(){return this._livingType}getMCUConfigBuilder(){return this._store.isMainRoom?this._mcuConfigBuilder:(this._logger.error(T.L_LIVING_ROOM_GET_MCU_CONFIG_BUILDER_O,"the `getMCUConfigBuilder` is disabled in PK room"),{code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}enableInnerCDN(e){return E(this,void 0,void 0,(function*(){return this._invoker.push(new Ea(this._mcuConfigBuilder.__innerGetValues(),e))}))}_resourceHandle(e,t,r,i,n){const s=Object.create(null,{_resourceHandle:{get:()=>super._resourceHandle}});return E(this,void 0,void 0,(function*(){s._resourceHandle.call(this,e,t,r,i,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 E(this,void 0,void 0,(function*(){this._invoker.push(new ma(e,this._roomPKHandler,t))}))}_getPushOtherRoomsParams(){const e=[];if(!this.isMainRoom()||!this._roomPKHandler)return e;const t=this._roomPKHandler.getJoinedPKRooms();for(const r in t){const i=t[r].getSessionId(),n=this._roomPKHandler.getPKInfo(r);if(!n)continue;const{inviterUserAutoMix:s,inviteeUserAutoMix:o,inviterUserId:a}=n,c=this._context.getCurrentId()===a;e.push({roomId:r,sessionId:i,autoMix:c?!!s:!!o})}return e}getRoomPKHandler(){return this._store.isMainRoom?(this._logger.info(T.L_LIVING_ROOM_GET_ROOM_PK_HANDLER_O,JSON.stringify({status:O.SUCCESSED})),{code:I.SUCCESS,roomPKHandler:this._roomPKHandler}):(this._logger.error(T.L_LIVING_ROOM_GET_ROOM_PK_HANDLER_O,JSON.stringify({status:O.SUCCESSED,code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),{code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}_quitAllPKRoom(){return E(this,void 0,void 0,(function*(){const e=this._roomPKHandler.getJoinedPKRooms();for(const t in e)this._roomPKHandler.leaveOtherRoom(e[t]);this._logger.info(T.L_LIVING_ROOM_QUIT_ALL_PK_ROOM_O,JSON.stringify({status:O.SUCCESSED,roomIds:Object.keys(e)}))}))}isMainRoom(){return this._store.isMainRoom}}class Oa extends oa{constructor(e,t,r,i,n,s=ks.RTC,o=!1){super(e,t,r,s,i,n,!1,!1,rs(),o)}}const Ca=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 E(this,void 0,void 0,(function*(){if(0===this.queue.length||this.locked)return;this.locked=!0;const{resolve:e,task:t,reject:r}=this.queue.shift();let i;try{i=yield t(),e(i)}catch(e){r(e)}this.locked=!1,this.checkToStart()}))}push(e,t=""){const r=new Promise(((t,r)=>{this.queue.push({resolve:t,task:e,reject:r})}));return this.checkToStart(),r}},va=(e,t="")=>Ca.push(e,t);class La{constructor(e,t,r){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:rs()}),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 cs(t,e,r.mediaServer),this._logger=this._context.logger,this._store=new Ws(this._logger,this._clientSessionId,this._context.getAppkey(),this._crtUserId,this._crtUserId,ks.LIVE)}_getReqHeaders(e){return E(this,void 0,void 0,(function*(){const t=this._crtUserId;if(!this._rtcToken){const{code:r,data:i}=yield this._context.getRTCToken(t,ks.LIVE,e);if(r!==o.SUCCESS)return{code:I.SIGNAL_ERROR};this._rtcToken=i.rtcToken}return{code:I.SUCCESS,headers:{"App-Key":this._context.getAppkey(),UserId:this._crtUserId,RoomId:t,RoomType:ks.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(){var e;return E(this,void 0,void 0,(function*(){this._fromRetry=!0;const{code:t}=yield this.subscribe(this._liveUrl,this._livingType,this._mediaType,this._subTiny);return t===I.SUCCESS&&(null===(e=this._pc)||void 0===e||e.clearReTryExchangeTimer()),{code:t}}))}subscribe(e,t,r,i=!1){return E(this,void 0,void 0,(function*(){return va((()=>this.__subscribe(e,t,r,i)),"audience-client-sub")}))}__subscribe(e,t,r,i=!1){var s;return E(this,void 0,void 0,(function*(){this._logger.info(T.L_AUDIENCE_CLIENT_SUBSCRIBE_T,JSON.stringify({liveUrl:e,livingType:t,mediaType:r,subTiny:i}));const o=[];if(Ut(this._context.getNaviInfo()))return this._logger.error(T.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:I.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"})),{code:I.PACKAGE_ENVIRONMENT_ERROR,tracks:o};if(!this._fromRetry&&(null===(s=this._pc)||void 0===s||s.clearReTryExchangeTimer()),this._fromRetry=!1,!n(e))return this._logger.error(T.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:`params error -> liveUrl: ${e}`})),{code:I.PARAMS_ERROR,tracks:o};if(![ga.AUDIO,ga.VIDEO].includes(t))return this._logger.error(`livingType is invalid: ${t}`),this._logger.error(T.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:`params error -> livingType: ${t}`})),{code:I.PARAMS_ERROR,tracks:o};if(![je.AUDIO_ONLY,je.VIDEO_ONLY,je.AUDIO_VIDEO].includes(r))return this._logger.error(T.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:`params error -> -> mediaType: ${r}`})),{code:I.PARAMS_ERROR,tracks:o};if(this._liveUrl&&this._liveUrl!==e)return this._logger.error(T.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:I.BROADCAST_SUB_LIST_NOT_EMPTY,msg:"repeat subscribe"})),{code:I.BROADCAST_SUB_LIST_NOT_EMPTY,tracks:o};this._pc||(this._pc=new Fs(this._context,this._logger,this._reTryExchange.bind(this),this._crtUserId,this._store,void 0,!1),this._pc.on(Fs.__INNER_EVENT_TRACK_READY__,this._onTrackReady,this),this._pc.registerReportListener(this._reportListener),this._pc.__reportR3R4ToPolaris()),this._liveUrl=e;const{code:a,headers:c}=yield this._getReqHeaders(t);if(a!==I.SUCCESS)return this._logger.error(T.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:a,msg:"getRTCToken failed"})),{code:a,tracks:o};const _=`rc_mcu_${Date.now()}`,d="RongCloudRTC";0===this._subTracks.length&&(this._subTracks.push(new lt(this._logger,d,_),new ut(this._logger,d,_)),this._pc.updateSubRemoteTracks(this._subTracks.slice()));const l={sdp:yield this._pc.createOffer(!0),liveUrl:e,mediaType:r,simulcast:i?_s.TINY:_s.NORMAL,switchstream:!1},u=yield this._service.broadcastSubscribe(c,l);if(u.code!==I.SUCCESS)return this._logger.error(T.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:u.code})),{code:u.code,tracks:o};const h=u.data;if(h.resultCode!==I.SUCCESS)return this._logger.error(T.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:h.resultCode,msg:h.message})),{code:h.resultCode,tracks:o};this._livingType=t,this._mediaType=r,this._subTiny=i;const{sdp:g,subscribedList:R}=h;this._subscribedList=R;const p=[];return R.forEach((e=>{const{mediaType:t}=e,r=this._subTracks[t];p.push(r),r.__innerSetRemoteMuted(!0)})),this._pc.setRemoteAnswer(g.sdp),p&&this._updateTrackIdSSRCMap(g.sdp,p),this._logger.info(T.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:O.SUCCESSED,liveUrl:e})),{code:I.SUCCESS,tracks:p}}))}_updateTrackIdSSRCMap(e,t){t.forEach((t=>{const r=t.getTrackId(),{mediaType:i}=It(r),{msid:n}=this._subscribedList.filter((e=>e.mediaType===i))[0],s=bo(e,n,i);this._store.setTrackIdSSRCMap(Number(s),r)}))}unsubscribe(){return E(this,void 0,void 0,(function*(){return va((()=>this.__unsubscribe()),"audience-client-unsub")}))}__unsubscribe(){var e;return E(this,void 0,void 0,(function*(){if(this._logger.info(T.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(T.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:"",msg:"Address does not exist, without unsubscribe"})),{code:I.SUCCESS};const{headers:t}=yield this._getReqHeaders(),{code:r}=yield this._service.broadcastExit(t);return r!==I.SUCCESS?this._logger.error(T.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:r})):(this._logger.info(T.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:O.SUCCESSED,liveUrl:this._liveUrl})),this._subscribedList=[]),this._clearSubscribeInfo(),{code:r}}))}registerReportListener(e){this._reportListener=e}registerTrackEventListener(e){this._appListener=e}_onTrackReady(e){var t,r;const{track:i}=e.receiver,n="audio"===i.kind?je.AUDIO_ONLY:je.VIDEO_ONLY,s=this._subTracks[n];s.__innerSetMediaStreamTrack(i);try{this._logger.info(T.L_AUDIENCE_CLIENT_CALL_ONTRACKREADY_O,`trackId: ${s.getTrackId()}`),null===(r=null===(t=this._appListener)||void 0===t?void 0:t.onTrackReady)||void 0===r||r.call(t,s)}catch(e){this._logger.error(T.L_AUDIENCE_CLIENT_CALL_ONTRACKREADY_O,JSON.stringify(e))}}}var ba,Aa;!function(e){e.RTMP="rtmp",e.FLV="flv",e.HLS="hls"}(ba||(ba={})),function(e){e[e.NOT_HTTPS=0]="NOT_HTTPS",e[e.HTTPS=1]="HTTPS"}(Aa||(Aa={}));const ya=Object.assign(Object.assign({},Lt(Ve.W176_H144)),{frameRate:yt(Be.FPS_15)});class Na{constructor(e,t,r,i,n,s,o=rs()){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:r}),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:i}),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 qo(this._context,this._runtime,this._roomId,this,Ho.Audience),this._reportMediaActionLogger=new Yo(this._logger,this._roomId,this._clientSessionId,this._crtUserId),this._service=new cs(this._runtime,this._context,this._initOptions.mediaServer,this._initOptions.timeout);const a=this._store=new Ws(this._logger,o,e.getAppkey(),i,this._crtUserId,ks.LIVE),c=this._pc=new Fs(this._context,this._logger,this._reTryExchange.bind(this),this._crtUserId,a,this._polarisReport,!0);this._audioLevelReport=new Js(this._store,c),c.on(Fs.__INNER_AUDIOLEVEL_CHANGE__,this._audioLevelReport.audioLevelReport,this._audioLevelReport),this._polarisReport.sendR1(),this._context.registerRTCSignalListener((e=>E(this,void 0,void 0,(function*(){const{time:t,type:r,roomId:i}=this._context.decodeRtcNotify(e);1===r&&this._startPull(i,t)})))),this._setInitData()}_startPull(e,t){return E(this,void 0,void 0,(function*(){if(this._isPulling)return;this._isPulling=!0;if(this._pullTime>t)return void(this._isPulling=!1);const r=this._logger.createTraceId();this._logger.info(T.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_T,`pullTime: ${this._pullTime}`,r);const{code:i,data:n}=yield this._context.pullRTCRoomEntry(e);if(i===o.SUCCESS){this._isPulling=!1,this._pullTime=(null==n?void 0:n.syncTime)||0;const t=(null==n?void 0:n.kvEntries)||[];this._logger.info(T.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R,`status: ${O.SUCCESSED}, kvEntries: ${JSON.stringify(t)}`,r),this.singalDataChange(t,e,r)}this._logger.info(T.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R,`status: ${O.FAILED}, code: ${i}`,r)}))}_setInitData(){const{sessionId:e,remoteUserIds:t,remoteRTCUris:r,remoteMUCUris:i,remoteTracks:n,CDNUris:s}=((e,t,r)=>{const i=t.filter((e=>"RC_RTC_SESSIONID"===e.key))[0],n=i?i.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||"[]"):[],c=[];a.forEach((t=>{const{mediaType:i,tag:n}=t,s=i===je.AUDIO_ONLY?new lt(r,n,"",e):new ut(r,n,"",e);c.push(s)}));const _=[],d=[];o.forEach((e=>{const t=JSON.parse(e.uris||"[]");_.push(...t),t.forEach((e=>{const{mediaType:t,tag:i,msid:n}=e,s=n.split("_");s.pop();const o=s.join("_"),a=t===je.AUDIO_ONLY?new lt(r,i,o):new ut(r,i,o);d.push(a)}))}));const l=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:d,remoteMCUTracks:c,remoteTracks:[...d,...c],CDNUris:l||{}}})(this._roomId,this._joinResData.kvEntries,this._logger);this._sessionId=e,this._roomAnchorList=t,n.forEach((e=>{this._remoteTracks[e.getTrackId()]=e})),this._CDNUris=s,r.forEach((e=>{const t=e.msid.split("_")[0];this._roomAnchorRes[t]?this._roomAnchorRes[t].push(e):this._roomAnchorRes[t]=[e];const{ssrc:r,resourceId:i}=JSON.parse(e.uri);this._store.setTrackIdSSRCMap(r,i)})),i.forEach((e=>{const{mediaType:t,tag:r}=e,i=[this._roomId,r,t].join("_");this._roomRes[i]=e;const{ssrc:n}=JSON.parse(e.uri);this._store.setTrackIdSSRCMap(n,i)})),r.forEach((e=>{const t=Et(e);this._roomRes[t]=e}))}_assertRoomDestroyed(){if(this._destroyed)return I.ROOM_HAS_BEEN_DESTROYED}singalDataChange(e,t,r){var i;if(t!==this._roomId)return void this._logger.error(T.L_AUDIENCE_LIVING_ROOM_SINGAL_DATA_CHANGE_P,JSON.stringify({status:O.FAILED,msg:`roomId inconsistency -> params roomId:${t}, current roomId:${this._roomId}`}),r);const n=[],s=null===(i=e.filter((e=>"RC_CDN"===e.key))[0])||void 0===i?void 0:i.value;s&&this._diffCDNUris(JSON.parse(JSON.parse(s).cdn_uris)[0],r),e.forEach((e=>{const{key:t,value:i,uid:s}=e;if(-1!==t.indexOf("RC_RES_")){const e=JSON.parse(i||"{}"),t=JSON.parse(e.mcu_uris||"[]"),o=JSON.parse(e.uris||"[]");return n.push(...t),void this._diffAnchorResource(o,s,r)}if("RC_ANCHOR_LIST"===t){const e=JSON.parse(i||"[]");this._diffAnchorList(e,r)}})),this._diffRoomResource(n,r)}_diffAnchorList(e,t){const r=e.filter((e=>this._roomAnchorList.indexOf(e)<0)),i=this._roomAnchorList.filter((t=>e.indexOf(t)<0));r.length>0&&this._handleNewJoinedAnchor(r,t),i.length>0&&this._handleLeftedAnchor(i,t)}_handleNewJoinedAnchor(e,t){this._roomAnchorList.push(...e),this._logger.info(T.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorJoin",list:e}),t),this._callAppListener("onAnchorJoin",e)}_handleLeftedAnchor(e,t){return E(this,void 0,void 0,(function*(){this._roomAnchorList=this._roomAnchorList.filter((t=>!e.includes(t)));const r=[];e.forEach((e=>{r.push(...this.getRemoteTracksByUserId(e)),delete this._roomAnchorRes[e]})),r.length&&(yield this.unsubscribe(r),r.forEach((e=>delete this._remoteTracks[e.getTrackId()]))),this._logger.info(T.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorLeave",list:e}),t),this._callAppListener("onAnchorLeave",e)}))}_diffRoomResource(e,t){return E(this,void 0,void 0,(function*(){const r=[],i=[],n=[];e.forEach((e=>{const t=Et(e),{tag:i,mediaType:s}=It(t),o=[this._roomId,i,s].join("_"),{ssrc:a}=JSON.parse(e.uri);if(this._store.setTrackIdSSRCMap(a,o),!this._remoteTracks[o]){const t=s===je.AUDIO_ONLY?new lt(this._logger,i,"",this._roomId):new ut(this._logger,i,"",this._roomId);r.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()&&i.push(this._remoteTracks[e])})),r.length>0&&(this._logger.info(T.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onTrackPublish",trackIds:r.map((e=>e.getTrackId()))}),t),this._callAppListener("onTrackPublish",r)),i.length>0&&this._onUserUnpublish(i,"onTrackUnpublish",t)}))}_dealPublished(e,t,r){return E(this,void 0,void 0,(function*(){const i=e.map(Et),n=[],s=[];if(t.forEach((t=>{const r=Et(t),o=i.indexOf(r),{userId:a,tag:c,mediaType:_}=It(r),{ssrc:d}=JSON.parse(t.uri);this._store.setTrackIdSSRCMap(d,r),o>-1?e[o]=t:e.push(t);let l=this._remoteTracks[r];this._roomRes[r]=t,l?l.isSubscribed()&&n.push(l):(l=_===je.AUDIO_ONLY?new lt(this._logger,c,a):new ut(this._logger,c,a),this._remoteTracks[r]=l,s.push(l)),l.__innerSetRemoteMuted(0===t.state)})),n.length){const e=n.map((e=>e.getTrackId())),{code:t}=yield va((()=>this._subscribeHandle(n,!0)));t!==I.SUCCESS&&this._logger.error(T.L_RESUB_REPUB_RES_R,JSON.stringify({status:O.FAILED,trackIds:e,code:t}))}this._logger.info(T.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorTrackPublish",trackIds:s.map((e=>e.getTrackId()))}),r),this._callAppListener("onAnchorTrackPublish",s)}))}_dealUnpublished(e,t,r){return E(this,void 0,void 0,(function*(){const i=t.map(Et);for(let t=e.length-1;t>=0;t-=1){const r=e[t];i.includes(Et(r))&&e.splice(t,1)}const n=t.map((e=>{const t=Et(e);return this._remoteTracks[t]}));yield this._onUserUnpublish(n,"onAnchorTrackUnpublish",r)}))}_dealModified(e,t,r){const i=e.map(Et);for(const n of t){const t=Et(n);e[i.indexOf(t)].state=n.state;const s=this._remoteTracks[t];s.__innerSetRemoteMuted(0===n.state);const o=s.isAudioTrack()?"onAudioMuteChange":"onVideoMuteChange";this._logger.info(T.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:o,trackId:s.getTrackId()}),r),this._callAppListener(o,s)}}_diffAnchorResource(e,t,r){return E(this,void 0,void 0,(function*(){const i=this._roomAnchorRes[t]||(this._roomAnchorRes[t]=[]),{publishedList:n,unpublishedList:s,modifiedList:o}=Ct(i,e);n.length&&(yield this._dealPublished(i,n,r)),s.length&&(yield this._dealUnpublished(i,s,r)),o.length&&this._dealModified(i,o,r)}))}_onUserUnpublish(e,t,r){return E(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(T.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:t,trackIds:e.map((e=>e.getTrackId()))}),r),this._callAppListener(t,e)}))}_callAppListener(e,...t){var r;const i=null===(r=this._appListener)||void 0===r?void 0:r[e];if(i)try{i(...t)}catch(e){this._logger.error(T.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify(e))}}_reTryExchange(){return E(this,void 0,void 0,(function*(){return va((()=>E(this,void 0,void 0,(function*(){var e;const{reqBody:t}=yield this._createSubscribeParams(this._subscribedList,{},!0),r=yield this._exchangeHandle(t);if(r.code!==I.SUCCESS)return{code:r.code};const{sdp:i,resultCode:n}=r.data;if(n!==I.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(),r=null===(e=this._roomRes[t])||void 0===e?void 0:e.msid,n=[this._roomId,"RongCloudRTC"].join("_");i.sdp=i.sdp.replace(new RegExp(r,"g"),n)}return{code:yield this._pc.setRemoteAnswer(i.sdp)}}))),"audience-retry-exchange")}))}_createSubscribeParams(e,t,r){return E(this,void 0,void 0,(function*(){const i=yield this._pc.createOffer(r),n={resolutionInfo:[]},s={min:0,max:0};Object.keys(t).forEach((e=>{const{mediaStream:r,tinyStream:o}=t[e];[r,o].forEach(((t,r)=>{var o;const a=1===r?[e,"tiny"].join("_"):e;i.sdp=null===(o=i.sdp)||void 0===o?void 0:o.replace(new RegExp(t.id,"g"),a);const c=t.getVideoTracks()[0];if(!c)return;const _=0===r,{width:d,height:l,frameRate:u}=_?ft(c):ya;n.resolutionInfo.push({trackId:c.id,simulcast:_?_s.NORMAL:_s.TINY,resolution:`${d}x${l}`});const h=Ge(d,l),g=Ke(u);s.min+=h.minBitrate*g,s.max+=h.maxBitrate*g}))}));return{reqBody:{sdp:i,switchstream:!1,newVersionFlag:!0,subscribeList:e.map((e=>({simulcast:e.subTiny?_s.TINY:_s.NORMAL,resolution:"",uri:this._roomRes[e.track.getTrackId()].uri})))},dynamicBitrate:s,offer:i}}))}_subscribeHandle(e,t=!1,i=!1){return E(this,void 0,void 0,(function*(){const n=Date.now(),s=i?go.SUB:void 0,o=this._logger.createTraceId();this._logger.info(T.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_T,JSON.stringify({trackIds:e.map(wt),forceReq:t}),o);if(this._assertRoomDestroyed())return this._logger.error(T.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:I.ROOM_HAS_BEEN_DESTROYED,msg:"room destroyed"}),o),this._reportPubOrSubQualityData(n,e,I.ROOM_HAS_BEEN_DESTROYED,s),{code:I.ROOM_HAS_BEEN_DESTROYED};if(!r("tracks",e,(()=>d(e)&&e.length>0&&e.every((e=>e instanceof dt||e.track instanceof dt))),!0))return this._logger.error(T.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> tracks"}),o),this._reportPubOrSubQualityData(n,e,I.PARAMS_ERROR,s),{code:I.PARAMS_ERROR};this._pc.__reportR3R4ToPolaris(),this._pc.registerReportListener(this._reportListener),this._addPeerCEvent();const a=this._subscribedList.map((e=>Object.assign({},e))),c=e.map((e=>e instanceof dt?{track:e}:e)),_=[];return c.forEach((e=>{const t=e.track.getTrackId();_.push(t);const r=a.find((e=>e.track.getTrackId()===t));r&&r.subTiny===e.subTiny||(r?r.subTiny=e.subTiny:a.push(e))})),this._polarisReport.sendR2(lo.SUBSCRIBE,uo.BEGIN,_),this._updateSubListHandle(a,o,n,s,!0)}))}_addPeerCEvent(){this._pc.on(Fs.__INNER_EVENT_TRACK_READY__,(e=>{const t=e.streams[0].id,{track:r}=e.receiver,i=[t,"audio"===r.kind?je.AUDIO_ONLY:je.VIDEO_ONLY].join("_"),n=this._remoteTracks[i];n?(n.__innerSetMediaStreamTrack(r),this._logger.info(T.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onTrackReady",trackId:n.getTrackId()})),this._callAppListener("onTrackReady",n)):this._logger.warn(T.L_AUDIENCE_LIVING_ROOM_ONTRACKREADY_O,`cannot found RCRemoteTrack: ${r.id}`)})),this._pc.once(Fs.__INNER_ICE_CONNECTED__,(()=>{this._reportMediaActionLogger.reportIceFirstConnectData("sub")}),this),this._pc.on(Fs.__INNER_ICE_STATE_CHANGE__,(e=>{const{status:t,time:r,iceCandidatePair:i}=e;i&&this._reportMediaActionLogger.recordQualityIceStatusData(i,t,r)}))}_getReqHeaders(){const e=this._crtUserId;return{"App-Key":this._context.getAppkey(),RoomId:e,Token:this._joinResData.token,RoomType:ks.LIVE,UserId:e,"Session-Id":this._sessionId,"Client-Session-Id":this._clientSessionId}}_exchangeHandle(e){return this._service.broadcastSubscribe(this._getReqHeaders(),e)}_dealSubscribeResult(e,t,r){const i=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()],r=`${t.msid}_${t.mediaType}`;return i.includes(r)}return null==i?void 0:i.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(T.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:O.SUCCESSED,subSuccessTrackIds:i,failedList:o}),r),o}_getParams(e){let t=e.map((e=>e instanceof dt?{track:e}:Object.assign({},e)));const r={};return t=t.filter((e=>{const t=e.track.getTrackId();return!r[t]&&(r[t]=!0,!0)})).map((e=>Object.assign({},e))),t}_reportPubOrSubQualityData(e,t,r,i){i&&this._reportMediaActionLogger.reportPubOrSubQualityData(i,e,t,r,this._trackMediaMap)}_updateSubListHandle(e,t,r,i,n=!1){var s;return E(this,void 0,void 0,(function*(){this._logger.info(T.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_T,JSON.stringify({trackIds:e.map(wt),forceReq:n}),t);const o=this._getParams(e),a=this._subscribedList.map((e=>Object.assign({},e)));if(!n&&!Ao(o,a))return this._logger.info(T.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:O.SUCCESSED,msg:"repeat subscribe"}),t),{code:I.SUCCESS};this._pc.clearReTryExchangeTimer(),this._pc.updateSubRemoteTracks(o.map((e=>e.track)));const{reqBody:c}=yield this._createSubscribeParams(o,{},!1),_=yield this._exchangeHandle(c);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 dt?e.getTrackId():e.track.getTrackId();this._trackMediaMap[t]=_.qualityMsList||[]})),_.code!==I.SUCCESS)return this._reportPubOrSubQualityData(r,e,_.code,i),this._logger.error(T.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:O.FAILED,code:_.code}),t),{code:_.code};const{sdp:d,resultCode:l,message:u,subscribedList:h}=_.data;if(l!==I.SUCCESS)return this._reportPubOrSubQualityData(r,e,l,i),this._logger.error(T.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:O.FAILED,code:l,msg:u}),t),{code:l};o.forEach((e=>{const{track:t}=e;if(t.isMCUTrack()){const e=this._roomRes[t.getTrackId()].msid,{tag:r,userId:i}=It(t.getTrackId()),n=[i,r].join("_");d.sdp=d.sdp.replace(new RegExp(e,"g"),n)}}));const g=yield this._pc.setRemoteAnswer(d.sdp);if(this._reportPubOrSubQualityData(r,e,g,i),g!==I.SUCCESS)return this._logger.error(T.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:O.FAILED,code:g,msg:"set remote answer error"}),t),{code:g};const R=this._dealSubscribeResult(o,h,t);return R.length?{code:I.SUCCESS,failedList:R}:{code:I.SUCCESS}}))}_diffCDNUris(e,t){return E(this,void 0,void 0,(function*(){if(this._CDNUris.url&&!e.url)return this._logger.info(T.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(T.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 r=this._CDNUris.w&&e.w&&this._CDNUris.w!==e.w,i=this._CDNUris.h&&e.h&&this._CDNUris.h!==e.h,n=this._CDNUris.fps&&e.fps&&this._CDNUris.fps!==e.fps;(r||i||n)&&(this._logger.info(T.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 E(this,void 0,void 0,(function*(){const{w:r,h:i,fps:n}=e,s=this._initOptions.pullInnerCDNProtocol||ba.FLV,o=this._initOptions.pullInnerCDNUseHttps===Aa.NOT_HTTPS?Aa.NOT_HTTPS:Aa.HTTPS;if(!this._CDNUris.url)return this._logger.error(T.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:O.FAILED,code:I.CDN_RESOURCE_IS_EMPTY,msg:"cdn_uris url is empty, the anchor need to open or push CDN"}),t),{code:I.CDN_RESOURCE_IS_EMPTY};const a={"App-Key":this._context.getAppkey(),Token:this._joinResData.token,RoomId:this.getRoomId(),UserId:this._crtUserId,SessionId:this.getSessionId()},c=[],{w:_=0,h:d=1}=this._CDNUris;_/d>1?(r&&c.push(`w=${r}`),i&&c.push(`h=${i}`)):(r&&c.push(`h=${r}`),i&&c.push(`w=${i}`)),n&&c.push(`fps=${n}`),c.push(`kind=${s}`),c.push(`is_https=${o}`);const l=c.join("&");let u=`${this._CDNUris.url}?`;l&&(u+=l);const{code:h,res:g}=yield this._service.getCDNResourceInfo(a,u,t);return h!==I.SUCCESS?{code:h}:{code:h,CDNPlayUrl:null==g?void 0:g.data.pull_url}}))}getCDNPlayUrl(e,t){return E(this,void 0,void 0,(function*(){const r=this._logger.createTraceId();if(this._logger.info(T.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_T,JSON.stringify({resolution:e,fps:t}),r),e&&!bt(e))return this._logger.error(T.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> resolution"}),r),{code:I.PARAMS_ERROR};if(t&&!At(t))return this._logger.error(T.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> fps"}),r),{code:I.PARAMS_ERROR};const{width:i,height:n}=e?Lt(e):{width:null,height:null},s=t?yt(t):null,o={};return i&&(o.w=i),n&&(o.h=n),s&&(o.fps=s),this._getCDNPlayUrl(o,r)}))}subscribe(e){return E(this,void 0,void 0,(function*(){return va((()=>this._subscribeHandle(e,!1,!0)),"audience-sub")}))}__unsubscribe(e){return E(this,void 0,void 0,(function*(){const t=Date.now(),i=go.UNSUB,n=this._logger.createTraceId();this._logger.info(T.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_T,JSON.stringify({trackIds:e.map((e=>e.getTrackId()))}),n);if(this._assertRoomDestroyed())return this._logger.error(T.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:I.ROOM_HAS_BEEN_DESTROYED,msg:"room destroyed"}),n),{code:I.ROOM_HAS_BEEN_DESTROYED};if(!r("tracks",e,(()=>d(e)&&e.length>0&&e.every((e=>e instanceof dt))),!0))return this._logger.error(T.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> tracks"}),n),{code:I.PARAMS_ERROR};const s=this._subscribedList.map((e=>Object.assign({},e))).filter((t=>e.every((e=>e.getTrackId()!==t.track.getTrackId()))));return this._polarisReport.sendR2(lo.SUBSCRIBE,uo.END,e.map((e=>e.getTrackId()))),this._updateSubListHandle(s,n,t,i,!1)}))}unsubscribe(e){return E(this,void 0,void 0,(function*(){return va((()=>this.__unsubscribe(e)),"audience-unsub")}))}__destroy(e){var t;return E(this,void 0,void 0,(function*(){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 E(this,void 0,void 0,(function*(){const e=this._logger.createTraceId();this._logger.info(T.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_T,void 0,e);const{code:t}=yield this._context.joinLivingRoomAsAudience(this._roomId,ks.LIVE);t!==o.SUCCESS&&this._logger.error(T.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_R,`status: ${O.FAILED}`,e),this._logger.info(T.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_R,`status: ${O.SUCCESSED}`,e)}))}registerRoomEventListener(e){this._appListener=e}onAudioLevelChange(e,t){this._logger.info(T.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 r in this._remoteTracks){const i=this._remoteTracks[r];i.getUserId()===e&&t.push(i)}return t}getRemoteTracks(){const e=[],t=[];for(const e in this._remoteTracks){if(2===t.length)break;const r=this._remoteTracks[e];r.isMCUTrack()&&t.push(r)}return this._roomAnchorList.forEach((t=>{e.push(...this.getRemoteTracksByUserId(t))})),[...t,...e]}getRemoteRTCTracks(){const e=[];for(const t in this._remoteTracks){const r=this._remoteTracks[t];r.isMCUTrack()||e.push(r)}return e}getRemoteMCUTracks(){const e=[];for(const t in this._remoteTracks){const r=this._remoteTracks[t];r.isMCUTrack()&&e.push(r)}return e}getCDNInfo(){return this._CDNUris.w?{resolution:`W${this._CDNUris.w}_H${this._CDNUris.h}`,fps:`FPS_${this._CDNUris.fps}`,CDNEnable:this._CDNUris.enableInnerCDN}:{CDNEnable:!1}}getClientSessionId(){return this._clientSessionId}}var Da,Pa;!function(e){e[e.AUTOMATIC=0]="AUTOMATIC",e[e.MANUAL=1]="MANUAL"}(Da||(Da={}));class ka{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,t="getUserMedia"){return E(this,void 0,void 0,(function*(){try{const r=this.setConstraintsConfig(e),i=yield navigator.mediaDevices[t](r);return{code:I.SUCCESS,stream:i}}catch(e){if(this._logger.error(T.L_GET_MEDIA_STREAM_E,JSON.stringify({name:e.name,message:e.message})),"Permission denied"===e.message)return{code:I.BROWSER_PERMISSION_DENIED};if("Permission denied by system"===e.message)return{code:I.SYSTEM_PERMISSION_DENIED}}return{code:"getUserMedia"===t?I.GET_USER_MEDIA_FAILED:I.GET_DISPLAY_MEDIA_FAILED}}))}_getMediaStreamErrorReason(e){let t="";return e===I.BROWSER_PERMISSION_DENIED&&(t="Permission denied"),e===I.SYSTEM_PERMISSION_DENIED&&(t="Permission denied by system"),t}setConstraintsConfig(e){var t,r;if((null==e?void 0:e.audio)&&!this._isElectron){"boolean"==typeof e.audio&&(e.audio={});const i=null===(r=(t=navigator.mediaDevices).getSupportedConstraints)||void 0===r?void 0:r.call(t);(null==i?void 0:i.noiseSuppression)&&(e.audio.noiseSuppression=!!i.noiseSuppression),(null==i?void 0:i.autoGainControl)&&(e.audio.autoGainControl=!!i.autoGainControl),(null==i?void 0:i.echoCancellation)&&(e.audio.echoCancellation=!!i.echoCancellation),this._logger.info(T.L_SET_AUDIO_CONSTRAINTS_O,`browser supported -> ${JSON.stringify(i)}`)}return e}createMicrophoneAudioTrack(e="RongCloudRTC",t){return E(this,void 0,void 0,(function*(){if(!pt(e))return this._logger.error(T.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:O.FAILED,code:I.INVALID_TAGS,msg:"invalid tag"})),{code:I.INVALID_TAGS};const r=this._context.getCurrentId();if(!r)return this._logger.error(T.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:O.FAILED,code:I.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:I.INVALID_USER_ID};const{stream:i,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!==I.SUCCESS)return this._logger.error(T.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:O.FAILED,code:n,msg:this._getMediaStreamErrorReason(n)})),{code:n};const s=i.getAudioTracks()[0],o=new ot(this._logger,e,r,s);return this._logger.info(T.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:O.SUCCESSED,trackId:o.getTrackId()})),{code:n,track:o}}))}createCameraVideoTrack(e="RongCloudRTC",t){return E(this,void 0,void 0,(function*(){if(!pt(e))return this._logger.error(T.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:O.FAILED,code:I.INVALID_TAGS,msg:"invalid tag"})),{code:I.INVALID_TAGS};const r=this._context.getCurrentId();if(!r)return this._logger.error(T.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:O.FAILED,code:I.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:I.INVALID_USER_ID};const i=bt(null==t?void 0:t.resolution)?t.resolution:Ve.W640_H480,{width:n,height:s}=Lt(i),{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:yt((null==t?void 0:t.frameRate)||Be.FPS_15),width:{ideal:n,max:n},height:{ideal:s,max:s},facingMode:null==t?void 0:t.faceMode}});if(a!==I.SUCCESS)return this._logger.error(T.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:O.FAILED,code:a,msg:this._getMediaStreamErrorReason(a)})),{code:a};const c=o.getVideoTracks()[0];yield this._applyVideoAspectRatio(c,n,s);const _=new at(this._logger,e,r,c);return this._logger.info(T.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:O.SUCCESSED,trackId:_.getTrackId()})),{code:a,track:_}}))}createMicrophoneAndCameraTracks(e="RongCloudRTC",t){var r;return E(this,void 0,void 0,(function*(){const i=[];if(!pt(e))return this._logger.error(T.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:O.FAILED,code:I.INVALID_TAGS,msg:"invalid tag"})),{code:I.INVALID_TAGS,tracks:i};const n=this._context.getCurrentId();if(!n)return this._logger.error(T.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:O.FAILED,code:I.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:I.INVALID_USER_ID,tracks:i};const s=bt(null===(r=null==t?void 0:t.video)||void 0===r?void 0:r.resolution)?t.video.resolution:Ve.W640_H480,{width:o,height:a}=Lt(s),c=null==t?void 0:t.audio,_=null==t?void 0:t.video,{stream:d,code:l}=yield this._getMediaStream({video:{deviceId:(null==_?void 0:_.cameraId)?{exact:null==_?void 0:_.cameraId}:void 0,frameRate:yt((null==_?void 0:_.frameRate)||Be.FPS_15),width:{ideal:o,max:o},height:{ideal:a,max:a},facingMode:null==_?void 0:_.faceMode},audio:{deviceId:(null==c?void 0:c.micphoneId)?{exact:null==c?void 0:c.micphoneId}:void 0,sampleRate:null==c?void 0:c.sampleRate,noiseSuppression:null==c?void 0:c.noiseSuppression,echoCancellation:null==c?void 0:c.echoCancellation,autoGainControl:null==c?void 0:c.autoGainControl}});if(l!==I.SUCCESS)return this._logger.error(T.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:O.FAILED,code:l,msg:this._getMediaStreamErrorReason(l)})),{code:l,tracks:i};const u=d.getTracks();for(let t=0;t<u.length;t++){const r=u[t];"video"===r.kind?(yield this._applyVideoAspectRatio(r,o,a),i.push(new at(this._logger,e,n,r))):i.unshift(new ot(this._logger,e,n,r))}return this._logger.info(T.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:O.SUCCESSED,trackIds:i.map((e=>e.getTrackId()))})),{code:l,tracks:i}}))}createScreenVideoTrack(e="screenshare",t){return E(this,void 0,void 0,(function*(){const r=yield this._createScreenTracks(e,!1,T.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_TRACK_O,t);return r.code===I.SUCCESS?{code:r.code,track:r.tracks[0]}:r}))}createScreenWithAudioTracks(e="screenshare",t){return E(this,void 0,void 0,(function*(){return this._createScreenTracks(e,!0,T.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_AND_AUDIO_TRACKS_O,t)}))}_createScreenTracks(e,t,r,i){return E(this,void 0,void 0,(function*(){if(!pt(e))return this._logger.error(r,JSON.stringify({status:O.FAILED,code:I.INVALID_TAGS,msg:"invalid tag"})),{code:I.INVALID_TAGS};const n=this._context.getCurrentId();if(!n)return this._logger.error(r,JSON.stringify({status:O.FAILED,code:I.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:I.INVALID_USER_ID};if(!Pt())return this._logger.error(T.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_TRACK_O,JSON.stringify({status:O.FAILED,code:I.BROWSER_NOT_SUPPORT,msg:"browser not support"})),{code:I.BROWSER_NOT_SUPPORT};const s=/macintosh|mac os x/i.test(navigator.userAgent),o=(!this._isElectron||!s)&&t,a=bt(null==i?void 0:i.resolution)?i.resolution:Ve.W1280_H720,{stream:c,code:_}=this._isElectron?yield this._createElectronScreenStream(t,r,a,null==i?void 0:i.chromeMediaSourceId):yield this._createWebScreenStream(t,a,null==i?void 0:i.frameRate);if(_!==I.SUCCESS)return this._logger.error(r,JSON.stringify({status:O.FAILED,code:_,msg:this._getMediaStreamErrorReason(_)})),{code:_};const d=c.getVideoTracks()[0],l=[new ct(this._logger,e,n,d)];if(o){const t=c.getAudioTracks()[0];t&&l.push(new _t(this._logger,e,n,t))}return this._logger.info(r,JSON.stringify({status:O.SUCCESSED,trackIds:l.map((e=>e.getTrackId()))})),{code:_,tracks:l}}))}_createElectronScreenStream(e,t,r,i){var s,o;return E(this,void 0,void 0,(function*(){const a=/macintosh|mac os x/i.test(navigator.userAgent);this._isElectron&&a&&e&&this._logger.warn(t,JSON.stringify({status:O.INFO,code:I.MAC_IN_ELECTRON_NOT_SUPPORT_SCREEN_SHARE_WITH_AUDIO,msg:"mac in electron not support screen share with audio"}));const c=(!this._isElectron||!a)&&e;if(this._isElectron&&!p(i)&&!n(i))return this._logger.error(t,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> options.chromeMediaSourceId type is string"})),{code:I.PARAMS_ERROR};const{width:_,height:d}=Lt(r),l={mandatory:{chromeMediaSourceId:i,chromeMediaSource:"desktop",minWidth:_,maxWidth:_,minHeight:d,maxHeight:d}};!i&&this._isElectron&&(null===(s=l.mandatory)||void 0===s||delete s.chromeMediaSourceId);let u=null;return c&&this._isElectron&&(null===(o=l.mandatory)||void 0===o||delete o.chromeMediaSourceId,u={mandatory:{chromeMediaSource:"desktop"}}),this._getMediaStream({video:l,audio:u||c},"getUserMedia")}))}_createWebScreenStream(e,t,r){return E(this,void 0,void 0,(function*(){const{width:i,height:n}=Lt(t),s={frameRate:yt(r||Be.FPS_15),width:i,height:n};return this._getMediaStream({video:s,audio:e},"getDisplayMedia")}))}createLocalAudioTrack(e,t){return E(this,void 0,void 0,(function*(){if(!pt(e))return this._logger.error(T.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:O.FAILED,code:I.INVALID_TAGS,msg:"invalid tag"})),{code:I.INVALID_TAGS};if(!t||"[object MediaStreamTrack]"!==t.toString()||"audio"!==t.kind)return this._logger.error(T.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:O.FAILED,code:I.CREATE_CUSTOM_TRACK_FAILED,msg:"params track is not MediaStreamTrack or kind is not audio"})),{code:I.CREATE_CUSTOM_TRACK_FAILED};const r=this._context.getCurrentId();if(!r)return this._logger.error(T.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:O.FAILED,code:I.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:I.INVALID_USER_ID};const i=new tt(this._logger,e,r,t);return this._logger.info(T.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:O.SUCCESSED,trackId:i.getTrackId()})),{code:I.SUCCESS,track:i}}))}createLocalVideoTrack(e,t){return E(this,void 0,void 0,(function*(){if(!pt(e))return this._logger.error(T.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:O.FAILED,code:I.INVALID_TAGS,msg:"invalid tag"})),{code:I.INVALID_TAGS};if(!(t&&t instanceof MediaStreamTrack&&"video"===t.kind))return this._logger.error(T.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:O.FAILED,code:I.CREATE_CUSTOM_TRACK_FAILED,msg:"params track is not MediaStreamTrack or kind is not video"})),{code:I.CREATE_CUSTOM_TRACK_FAILED};const r=this._context.getCurrentId();if(!r)return this._logger.error(T.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:O.FAILED,code:I.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:I.INVALID_USER_ID};const i=new rt(this._logger,e,r,t);return this._logger.info(T.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:O.SUCCESSED,trackId:i.getTrackId()})),{code:I.SUCCESS,track:i}}))}_validateCreateLocalFileTracks(e,t){if(!pt(e))return this._logger.error(T.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:O.FAILED,code:I.INVALID_TAGS,msg:"invalid tag"})),{code:I.INVALID_TAGS,tracks:[]};if(!Dt())return this._logger.error(T.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:O.FAILED,code:I.BROWSER_NOT_SUPPORT,msg:"browser not support"})),{code:I.BROWSER_NOT_SUPPORT,tracks:[]};const r=t instanceof File?URL.createObjectURL(t):t;if(!R(r)&&!/^blob:/.test(r))return this._logger.error(T.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> file"})),{code:I.PARAMS_ERROR,tracks:[]};return this._context.getCurrentId()?{code:I.SUCCESS,tracks:[],url:r}:(this._logger.error(T.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:O.FAILED,code:I.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:I.INVALID_USER_ID,tracks:[]})}createLocalFileTracks(e,t,r){return E(this,void 0,void 0,(function*(){const i=this._validateCreateLocalFileTracks(e,t);if(i.code!==I.SUCCESS)return i;const n=this._context.getCurrentId();return new Promise((t=>{const s=document.createElement("video");(null==r?void 0:r.withoutAudio)&&(s.muted=!0),s.onloadedmetadata=()=>{const i=[];let o;try{const e=s.mozCaptureStream?"mozCaptureStream":"captureStream";o=s[e]()}catch(e){this._logger.error(T.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:O.FAILED,code:I.CREATE_FILE_TRACK_FAILED,msg:`captureSteam error -> ${JSON.stringify(e)}`})),t({code:I.CREATE_FILE_TRACK_FAILED,tracks:i})}const[a,c]=ka.getTracksWithOptions(o,r);a&&i.push(new st(this._logger,e,n,a,s)),c&&i.push(new nt(this._logger,e,n,c,s)),0===i.length&&(s.pause(),s.src=""),s.onerror=null,this._logger.info(T.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:O.SUCCESSED,trackIds:i.map((e=>e.getTrackId()))})),t({code:I.SUCCESS,tracks:i})},s.onerror=()=>{this._logger.error(T.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:O.FAILED,code:I.CREATE_FILE_TRACK_FAILED,msg:"Failed to create file stream, video onerror"})),t({code:I.CREATE_FILE_TRACK_FAILED,tracks:[]})},s.src=i.url,s.loop=!0,s.play()}))}))}createLocalTracks(e,t,r){return E(this,void 0,void 0,(function*(){const i=[];if(!pt(e))return this._logger.error(T.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:O.FAILED,code:I.INVALID_TAGS,msg:"invalid tag"})),{code:I.INVALID_TAGS,tracks:i};if(!(t instanceof MediaStream))return this._logger.error(T.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> stream"})),{code:I.PARAMS_ERROR,tracks:i};const n=this._context.getCurrentId();if(!n)return this._logger.error(T.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:O.FAILED,code:I.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:I.INVALID_USER_ID,tracks:i};const[s,o]=ka.getTracksWithOptions(t,r);return s&&i.push(new tt(this._logger,e,n,s)),o&&i.push(new rt(this._logger,e,n,o)),this._logger.info(T.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:O.SUCCESSED,trackIds:i.map((e=>e.getTrackId()))})),{code:I.SUCCESS,tracks:i}}))}static getTracksWithOptions(e,t){const r=[];return r[0]=(null==t?void 0:t.withoutAudio)?void 0:e.getAudioTracks()[0],r[1]=(null==t?void 0:t.withoutVideo)?void 0:e.getVideoTracks()[0],r}_applyVideoAspectRatio(e,t,r){return E(this,void 0,void 0,(function*(){const{width:i,height:n}=e.getSettings();if(i===t&&n===r)return;const s=t/r>=1?{width:{ideal:i,max:i}}:{height:{ideal:n,max:n}};try{yield e.applyConstraints(Object.assign(Object.assign({},s),{aspectRatio:{ideal:t/r}})),this._logger.info(T.L_RTC_CLIENT_APPLY_VIDEO_ASPECT_RATIO_O,JSON.stringify({status:O.SUCCESSED,msg:`apply aspectRatio success -> ${t} / ${r}`}))}catch(e){this._logger.warn(T.L_RTC_CLIENT_APPLY_VIDEO_ASPECT_RATIO_O,JSON.stringify({status:O.FAILED,msg:`apply aspectRatio error -> ${JSON.stringify(e)}`}))}}))}}class Ua extends ka{constructor(e,t,r){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:r}),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}),Ms.setSdpSemantics(r.sdpSemantics||"unified-plan",this._logger),this._service=new cs(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)),this._context.getPluginContext().onnavidatachange=this.naviDataChange.bind(this)}_handleMessage(e){if(e.conversationType!==g.RTC_ROOM)return!1;const t=this._logger.createTraceId();if(this._crtRoom instanceof Ta){this._getJoinedPKRoomList().forEach((r=>{r.__parseInnerMessage(e,t)}))}return this._logger.info(T.L_RTC_CLIENT_MESSAGE_O,JSON.stringify({status:O.SUCCESSED,message:e}),t),this._crtRoom?(this._crtRoom.__parseInnerMessage(e,t),!0):(this._logger.warn(T.L_RTC_CLIENT_MESSAGE_O,JSON.stringify({status:O.FAILED,message:"the crtRoom is empty"}),t),!0)}naviDataChange(e){this._logger.info(T.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===I.SUCCESS&&t){const e=t.getJoinedPKRooms()||{};return Object.values(e)}return[]}getCurrentId(){return this._context.getCurrentId()}joinCrossRTCRoom(e,t,r,i=!1,n=ks.CROSS_MUTI){return E(this,void 0,void 0,(function*(){return console.warn("joinCrossRTCRoom is deprecated, use joinRTCRoomWithOptions instead"),this.joinRTCRoomWithOptions(e,{joinType:t,userData:r,mode:ks.CROSS_MUTI})}))}joinRTCRoom(e,t,r,i=!1,n=ks.RTC){return E(this,void 0,void 0,(function*(){return console.warn("joinRTCRoom is deprecated, use joinRTCRoomWithOptions instead"),this.joinRTCRoomWithOptions(e,{mode:n,joinType:t,userData:r})}))}joinRTCRoomWithOptions(e,t){return E(this,void 0,void 0,(function*(){const r=this._logger.createTraceId();if(this._logger.info(T.L_RTC_CLIENT_JOIN_RTC_ROOM_T,JSON.stringify({roomId:e,options:t}),r),this._crtRoom)return this._logger.error(T.L_RTC_CLIENT_JOIN_RTC_ROOM_R,JSON.stringify({status:O.FAILED,code:I.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),r),{code:I.REPERT_JOIN_ROOM};const i=this._crtRoom=new Oa(this._context,this._runtime,e,this._service,this._options,null==t?void 0:t.mode,null==t?void 0:t.encrypt),{code:n}=yield i.__innerInit((null==t?void 0:t.mode)||ks.RTC,null==t?void 0:t.joinType,void 0,void 0,null==t?void 0:t.userData,r,null==t?void 0:t.srcLanguage,null==t?void 0:t.nickName);return n!==I.SUCCESS?(this._crtRoom=null,{code:n}):(i.once(sa,(()=>{this._crtRoom=null})),{code:n,room:i,userIds:i.getRemoteUserIds(),tracks:i.getRemoteTracks()})}))}joinLivingRoom(e,t,r,i,n=!1){return E(this,void 0,void 0,(function*(){const n=this._logger.createTraceId();if(this._logger.info(T.L_RTC_CLIENT_JOIN_LIVING_ROOM_T,JSON.stringify({roomId:e,livingType:t,joinType:r,outerUserDatas:i}),n),this._crtRoom)return this._logger.error(T.L_RTC_CLIENT_JOIN_LIVING_ROOM_R,JSON.stringify({status:O.FAILED,code:I.REPERT_JOIN_ROOM,msg:`Join the room repeatedly -> roomId: ${e}`}),n),{code:I.REPERT_JOIN_ROOM};const s=this._crtRoom=new Ta(this._context,this._runtime,e,this._service,this._options,t,!1,!0),{code:o}=yield s.__innerInit(ks.LIVE,r,t,void 0,i,n);if(o!==I.SUCCESS)return this._crtRoom=null,{code:o};s.once(sa,(()=>{this._crtRoom=null}));const a={code:o,room:s,userIds:s.getRemoteUserIds(),tracks:s.getRemoteTracks()};return s.__getCDNPushMode()===Da.MANUAL&&Object.assign(a,{CDNEnable:s.__getCDNEnable()}),a}))}getAudienceClient(e){return this._audience||(this._audience=new La(this._context,this._runtime,this._options)),this._logger.info(T.L_RTC_CLIENT_GET_AUDIENCE_CLIENT_O),this._audience}_onIMStatusChange(e,t){if(this._logger.info(T.L_RTC_CLIENT_IM_CONNECTION_STATE_S,JSON.stringify({status:e,code:t,desc:c[e]})),e===c.SUSPENDED&&t===o.RC_CONN_REDIRECTED&&this._service.clearMSList(),e===c.DISCONNECTED){if(this._crtRoom){let e=Jo.IM_DISCONNECTED;t===o.RC_DISCONN_KICK?e=Jo.OTHER_CLIENT_IM_CONNECTED:2===t&&(e=Jo.IM_LOGOUT),this._crtRoom.__kickoff(!0,{users:[{userId:this._context.getCurrentId(),type:e}]})}}else if(e===c.CONNECTED){if(this._service.isNededDetector()&&this._service.detectorMediaSever(),this._crtRoom instanceof Ta){this._getJoinedPKRoomList().forEach((e=>{e.__onReconnected()}))}this._crtRoom&&this._crtRoom.__onReconnected()}}_onIMUninit(){var e;this._logger.info(T.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){var t;return E(this,void 0,void 0,(function*(){const r=this._logger.createTraceId();return this._logger.info(T.L_RTC_CLIENT_LEAVE_ROOM_T,JSON.stringify({roomId:e.getRoomId()}),r),this._crtRoom?(yield this._crtRoom.__destroy(!0),this._service.isNededDetector()&&this._service.detectorMediaSever(),this._logger.info(T.L_RTC_CLIENT_LEAVE_ROOM_R,JSON.stringify({status:O.SUCCESSED,roomId:null===(t=this._crtRoom)||void 0===t?void 0:t.getRoomId()}),r),this._crtRoom=null,{code:I.SUCCESS}):(this._logger.warn(T.L_RTC_CLIENT_LEAVE_ROOM_R,JSON.stringify({status:O.FAILED,msg:"Room does not exist, without leave"}),r),{code:I.SUCCESS})}))}joinLivingRoomAsAudience(e,t,i){return E(this,void 0,void 0,(function*(){const i=this._logger.createTraceId();if(this._logger.info(T.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_T,JSON.stringify({roomId:e,livingType:t}),i),this._service.isNededDetector()&&this._service.detectorMediaSever(),Ut(this._context.getNaviInfo()))return this._logger.error(T.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:O.FAILED,code:I.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"}),i),{code:I.PACKAGE_ENVIRONMENT_ERROR};if(!r("roomId",e,_,!0)||!r("livingType",t,(e=>e===ga.AUDIO||e===ga.VIDEO)))return this._logger.error(T.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> roomId or livingType"}),i),{code:I.PARAMS_ERROR};if(this._crtAudienceLivingRoom)return this._logger.error(T.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:O.FAILED,code:I.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),i),{code:I.REPERT_JOIN_ROOM};if(!this._service.getMsList().length)return this._logger.error(T.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:O.FAILED,code:I.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"No audio / video server address available"}),i),{code:I.NOT_OPEN_VIDEO_AUDIO_SERVER};const{code:n,data:s}=yield this._context.joinLivingRoomAsAudience(e,ks.LIVE,t);if(n!==o.SUCCESS)return this._logger.error(T.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:O.FAILED,code:n,msg:"signal error -> audience join room"}),i),{code:I.SIGNAL_AUDIENCE_JOIN_ROOM_FAILED};const a=rs(),c=new Na(this._context,this._runtime,this._options,e,s,t,a);return this._crtAudienceLivingRoom=c,this._logger.info(T.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:O.SUCCESSED,roomData:s}),i),{room:c,code:I.SUCCESS,userIds:c.getRemoteUserIds(),RTCTracks:c.getRemoteRTCTracks(),MCUTracks:c.getRemoteMCUTracks(),CDNUris:c.getCDNInfo()}}))}leaveLivingRoomAsAudience(e){return E(this,void 0,void 0,(function*(){const t=this._logger.createTraceId();return this._logger.info(T.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(T.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> room"}),t),{code:I.PARAMS_ERROR}):(yield this._crtAudienceLivingRoom.__destroy(!0),this._crtAudienceLivingRoom=null,this._logger.info(T.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:O.SUCCESSED}),t),{code:I.SUCCESS}):(this._logger.warn(T.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:O.FAILED,msg:"Room does not exist, without leave"}),t),{code:I.SUCCESS})}))}upgradeToAnchorRoom(e){return E(this,void 0,void 0,(function*(){const t=this._logger.createTraceId();if(this._logger.info(T.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_T,void 0,t),!r("room",e,(()=>e instanceof Na),!0))return this._logger.error(T.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> room"}),t),{code:I.PARAMS_ERROR};const i=e.getRoomId();if(this._crtRoom)return this._logger.error(T.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:O.FAILED,code:I.REPERT_JOIN_ROOM,msg:"Join the room repeatedly",roomId:i}),t),{code:I.REPERT_JOIN_ROOM};const n=this._crtRoom=new Ta(this._context,this._runtime,i,this._service,this._options,e.livingType,!0,!0,e.getClientSessionId()),s=yield n.__innerInitByIdentityChange(t);if(s!==o.SUCCESS)return this._crtRoom=null,{code:s};n.once(sa,(()=>{this._crtRoom=null})),yield this._crtAudienceLivingRoom.__destroy(!1),this._crtAudienceLivingRoom=null;const a={room:n,code:I.SUCCESS,userIds:n.getRemoteUserIds(),tracks:n.getRemoteTracks()};return n.__getCDNPushMode()===Da.MANUAL&&Object.assign(a,{CDNEnable:n.__getCDNEnable()}),a}))}downgradeToAudienceRoom(e){return E(this,void 0,void 0,(function*(){const t=this._logger.createTraceId();if(this._logger.info(T.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_T,JSON.stringify({roomId:e._roomId,userId:this._context.getCurrentId()}),t),!e.isMainRoom())return this._logger.error(T.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:O.FAILED,code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"the `downgradeToAudienceRoom` is disabled in PK room"}),t),{code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM};if(!r("room",e,(()=>e instanceof Ta),!0))return this._logger.error(T.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> room"}),t),{code:I.PARAMS_ERROR};if(this._crtAudienceLivingRoom)return this._logger.error(T.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:O.FAILED,code:I.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),t),{code:I.REPERT_JOIN_ROOM};const{code:i,data:n}=yield this._context.rtcIdentityChange(e._roomId,pa.AnchorToViewer,e.getLivingType());if(i!==o.SUCCESS)return this._logger.error(T.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:O.FAILED,code:I.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED}),t),{code:I.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED};this._logger.info(T.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:O.SUCCESSED,roomData:n}),t);const s=e.getClientSessionId(),a=new Na(this._context,this._runtime,this._options,e._roomId,n,e.getLivingType(),s);return this._crtAudienceLivingRoom=a,this._crtRoom.__destroy(!1),this._crtRoom=null,{room:a,code:I.SUCCESS,userIds:a.getRemoteUserIds(),RTCTracks:a.getRemoteRTCTracks(),MCUTracks:a.getRemoteMCUTracks(),CDNUris:a.getCDNInfo()}}))}getJoinedRoomInfo(){return E(this,void 0,void 0,(function*(){const e=this._logger.createTraceId(),t=this._context.getCurrentId();this._logger.error(T.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_T,JSON.stringify({userId:t}),e);const{code:r,data:i}=yield this._context.getRTCJoinedUserInfo(t);return r!==o.SUCCESS?(this._logger.error(T.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_R,JSON.stringify({status:O.FAILED,code:r}),e),{code:r}):(this._logger.info(T.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_R,JSON.stringify({status:O.SUCCESSED,roomInfo:i}),e),{code:I.SUCCESS,data:i})}))}generateSummarization(e,o,a=0,c=0,d,l){return E(this,void 0,void 0,(function*(){const u=this._logger.createTraceId();if(this._logger.info(T.L_RTC_CLIENT_GENERATE_SUMMARIZATION_T,JSON.stringify({roomId:e,taskId:o,startTime:a,endTime:c,config:d,contentBlock:l}),u),!r("roomId",e,_,!0))return this._logger.error(T.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> roomId"}),u),{code:I.PARAMS_ERROR};if(!r("taskId",o,_,!0))return this._logger.error(T.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> taskId"}),u),{code:I.PARAMS_ERROR};if(!t(a)||a<0)return this._logger.error(T.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> startTime"}),u),{code:I.PARAMS_ERROR};if(!t(c)||c<0)return this._logger.error(T.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> endTime"}),u),{code:I.PARAMS_ERROR};if(!r("config",d,i,!0))return this._logger.error(T.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> config"}),u),{code:I.PARAMS_ERROR};const{isValid:h,key:g}=(e=>{if("destLang"in e&&!n(e.destLang))return{isValid:!1,key:"destLang"};if("customPrompt"in e&&!n(e.customPrompt))return{isValid:!1,key:"customPrompt"};if("enableSummarization"in e&&!s(e.enableSummarization))return{isValid:!1,key:"enableSummarization"};if("enableSummarizationDetails"in e&&!s(e.enableSummarizationDetails))return{isValid:!1,key:"enableSummarizationDetails"};if("enableChapterSummary"in e&&!s(e.enableChapterSummary))return{isValid:!1,key:"enableChapterSummary"};if("enableTodoList"in e&&!s(e.enableTodoList))return{isValid:!1,key:"enableTodoList"};if("enableHashtag"in e&&!s(e.enableHashtag))return{isValid:!1,key:"enableHashtag"};if("format"in e&&void 0===ht[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"}})(d);h||this._logger.warn(T.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:`params error -> config.${g}`}),u);const{code:R,msg:p}=yield this._service.generateSummarization(e,o,a,c,d,l,u);return R!==I.SUCCESS?(this._logger.error(T.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:O.FAILED,code:R,msg:p}),u),{code:R}):(this._logger.info(T.L_RTC_CLIENT_GENERATE_SUMMARIZATION_R,JSON.stringify({status:O.SUCCESSED}),u),{code:R})}))}getASRContent(e,i,s=0,o=0,a,c){return E(this,void 0,void 0,(function*(){const d=this._logger.createTraceId();if(this._logger.info(T.L_RTC_CLIENT_GET_ASR_CONTENT_T,JSON.stringify({roomId:e,taskId:i,startTime:s,endTime:o,destLang:c,contentBlock:a}),d),!r("roomId",e,_,!0))return this._logger.error(T.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> roomId"}),d),{code:I.PARAMS_ERROR};if(!r("taskId",i,_,!0))return this._logger.error(T.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> taskId"}),d),{code:I.PARAMS_ERROR};if(!t(s)||s<0)return this._logger.error(T.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> startTime"}),d),{code:I.PARAMS_ERROR};if(!t(o)||o<0)return this._logger.error(T.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> endTime"}),d),{code:I.PARAMS_ERROR};if(!r("destLang",c,n,!1))return this._logger.error(T.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> destLang"}),d),{code:I.PARAMS_ERROR};const{code:l,msg:u}=yield this._service.getASRContent(e,i,s,o,a,d,c);return l!==I.SUCCESS?(this._logger.error(T.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:O.FAILED,code:l,msg:u}),d),{code:l}):(this._logger.info(T.L_RTC_CLIENT_GET_ASR_CONTENT_R,JSON.stringify({status:O.SUCCESSED}),d),{code:l})}))}}!function(e){e[e.KICK=0]="KICK",e[e.REFUSE=1]="REFUSE"}(Pa||(Pa={}));const Ma="rtcRJoin_data",wa="rtcRExit",xa="rtcRInfo",Ba="rtcUData",Va="rtcUDel",ja="rtcSetData",Fa="userSetData",Ja="rtcQryData",Ga="rtcDelData",Ha="rtcToken",Ka="rtcUserState",$a="rtcUList",Wa="viewerJoinR",za="viewerExitR",Ya="rtcPullKv",qa="rtcIdentityChange",Za="rtcInvite",Qa="rtcCancelInvite",Xa="rtcInviteAnswer",ec="rtcEndInvite",tc="rtcQueryJoined",rc="rtcPullRoomStatus",ic="reportsdk",nc="rtcPing";var sc;!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"}(sc||(sc={}));const oc={[sc.RtcInput]:["roomType","broadcastType","extraInnerData","needSysChatroom","identityChangeType","joinType","innerDatas","outerDatas","supportNtf"],[sc.RtcOutput]:["version"],[sc.RtcUserListOutput]:["users","token","sessionId","roomInfo","version"],[sc.SetUserStatusInput]:["status"],[sc.RtcSetDataInput]:["interior","target","key","value","objectName","content"],[sc.RtcUserSetDataInput]:["valueInfo","objectName","content"],[sc.RtcDataInput]:["interior","target","key","objectName","content"],[sc.RtcSetOutDataInput]:["target","valueInfo","objectName","content"],[sc.MCFollowInput]:["state"],[sc.RtcTokenOutput]:["rtcToken"],[sc.RtcQryOutput]:["outInfo"],[sc.RtcQryUserOutDataInput]:["userId"],[sc.RtcUserOutDataOutput]:["user"],[sc.RtcQueryListInput]:["order"],[sc.RtcRoomInfoOutput]:["roomId","roomData","userCount","list"],[sc.RtcValueInfo]:["key","value"],[sc.RtcKeyDeleteInput]:["key"],[sc.RtcNotifyMsg]:["type","time","roomId"],[sc.RtcPullKV]:["timestamp","roomId"],[sc.RtcKVOutput]:["entries","bFullUpdate","syncTime"],[sc.RtcQueryUserJoinedInput]:["userId"],[sc.RtcQueryUserJoinedOutput]:["info"],[sc.RtcInviteInput]:["invitedUserId","timeoutTime","invitedRoomId","inviteInfo","inviteSessionId"],[sc.RtcCancelInviteInput]:["invitedUserId","invitedRoomId","inviteInfo","inviteSessionId"],[sc.RtcInviteAnswerInput]:["inviteUserId","answerCode","inviteRoomId","inviteSessionId","content","key","value"],[sc.RtcEndInviteInput]:["inviteRoomId","inviteSessionId","inviteContent","inviteRoomKeys"],[sc.RtcRoomStatusInput]:["version"],[sc.RtcRoomStatusOutput]:["bFullStatus","version","usersData","roomStatus"],[sc.RtcReportSDKInput]:["sdkInfo"],[sc.RtcPBPolaris]:["type","appKey","sessionId","roomId","roomCreateTime","userId","userRole","joinTime","signalDataCenter","r1Info","r2Info","r3Info","r4Info"],[sc.RtcPBR1Info]:["joinTime","rtcVersion","imVersion","platform","device","os","browserName","browserVersion"],[sc.RtcPBR2Info]:["joinTime","sendTime","rtcActionType","rtcActionStatus","trackId"],[sc.RtcPBR3Info]:["info"],[sc.RtcPBR4Info]:["info"],[sc.RtcPBStatusInfo]:["joinTime","receiveTime","totalBitRate","appCPUUsage","systemCPUUsage","systemCPUFrequency","networkStatus","googleRTTNetwork","ipAddress","useReceiveBroadBand","useSendBroadBand","packetLossCount","streams"],[sc.RtcPBStreamInfo]:["trackId","codeName","volume","samplingRate","bitRate","packetLossRate","frameRate","resolution","blockTime","jitterData","nAckCount","pliCount","googleRTTTotalTime","isReceiveFirstFrameRate","codeType","isEnabled"],[sc.AsrTextMsg]:["bms","t","isEnd","msgId","lang"],[sc.AsrResTextMsg]:["type","uid","asr"]},ac=`\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 ${sc.SetUserStatusInput}\n {\n optional int32 status=1;\n }\n message ${sc.MCFollowInput}\n {\n required string state = 1;\n }\n message ${sc.RtcQueryListInput}{\n optional int32 order=1;\n }\n message ${sc.RtcKeyDeleteInput}{\n repeated string key=1;\n }\n message ${sc.RtcValueInfo}{\n required string key=1;\n required string value=2;\n }\n message RtcUserInfo{\n required string userId=1;\n repeated ${sc.RtcValueInfo} userData=2; //用户资源信息\n }\n message ${sc.RtcRoomStatusInput}{ // rtc 和 living room 拉房间资源状态使用的参数\n required int64 version =1; //当前客户端最大的房间状态的version\n }\n message ${sc.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 ${sc.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 ${sc.RtcValueInfo} roomData = 2;\n optional int32 userCount = 3;\n repeated RtcUserInfo list=4;\n }\n message ${sc.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 ${sc.RtcValueInfo} innerDatas = 7; //用户内部inner数据,角色或者连麦信息等\n repeated ${sc.RtcValueInfo} outerDatas = 8; //用户内部outer数据,自定义数据结构RtcInput。\n optional bool supportNtf = 9; //是否支持房间状态的变更通过通知拉取的方式获取\n }\n message ${sc.RtcQryOutput}{\n repeated ${sc.RtcValueInfo} outInfo=1;\n }\n message ${sc.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 ${sc.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 ${sc.RtcUserSetDataInput} {\n repeated ${sc.RtcValueInfo} valueInfo = 1;\n required string objectName = 2;\n repeated ${sc.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 ${sc.RtcTokenOutput}{\n required string rtcToken=1;\n }\n message ${sc.RtcSetOutDataInput}{\n required targetType target=1;\n repeated ${sc.RtcValueInfo} valueInfo=2;\n optional string objectName=3;\n optional string content=4;\n }\n message ${sc.RtcQryUserOutDataInput}{\n repeated string userId = 1;\n }\n message ${sc.RtcUserOutDataOutput}{\n repeated RtcUserInfo user = 1;\n }\n message ${sc.RtcNotifyMsg} \n {\n required int32 type= 1; //(通知类型 1:rtc房间状态KV变更通知)\n optional int64 time= 2; //消息产生时间\n optional string roomId=3; //主播房间id\n }\n message ${sc.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 ${sc.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 ${sc.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 ${sc.RtcQueryUserJoinedOutput}\n {\n repeated RtcJoinedInfo info = 1;\n }\n message ${sc.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 ${sc.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 ${sc.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 ${sc.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 ${sc.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 ${sc.RtcReportSDKInput} {\n required string sdkInfo=1; // 用户集成的 sdk 信息,json 格式 {"web-rtc": "4.0.3.7"}\n }\n // ---- 北极星数据上报 -------\n message ${sc.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 ${sc.RtcPBR1Info} r1Info = 10;\n optional ${sc.RtcPBR2Info} r2Info = 11;\n optional ${sc.RtcPBR3Info} r3Info = 12;\n optional ${sc.RtcPBR4Info} r4Info = 13;\n }\n message ${sc.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 ${sc.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 ${sc.RtcPBR3Info} {\n required ${sc.RtcPBStatusInfo} info = 1;\n }\n message ${sc.RtcPBR4Info} {\n required ${sc.RtcPBStatusInfo} info = 1;\n }\n message ${sc.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 ${sc.RtcPBStreamInfo} streams = 13;\n }\n message ${sc.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 ${sc.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 ${sc.AsrResTextMsg} {\n optional int32 type = 1; //1 为语音识别,后续会扩展其它类型\n required string uid = 2; //对应转写的用户Id\n repeated ${sc.AsrTextMsg} asr = 3; //识别出的结果列表\n }\n}\n`,cc=(e,t,r,i,n,s,o)=>{const a=n?Object.keys(n).map((t=>e.encode(sc.RtcValueInfo,{key:t,value:n[t]},!0))):void 0,c=s?Object.keys(s).map((t=>e.encode(sc.RtcValueInfo,{key:t,value:s[t]},!0))):void 0;return e.encode(sc.RtcInput,{roomType:t,broadcastType:r,joinType:i,innerDatas:a,outerDatas:c,supportNtf:o})},_c=(e,t)=>{const r=e.decode(sc.RtcUserListOutput,t),{users:i,token:n,sessionId:s,roomInfo:o,entries:a,offlineKickTime:c=60,codeFormat:_,roomCreateTime:d,userJoinTime:l,version:u}=r,h={};return m(i,(e=>{const{userId:t,userData:r}=e,i={};m(r,(e=>{const{key:t,value:r}=e;i[t]=r})),h[t]=i})),{users:h,token:n,sessionId:s,roomInfo:o,kvEntries:a,offlineKickTime:c,codeFormat:_,roomCreateTime:xt(d),userJoinTime:xt(l),version:u}};var dc,lc;!function(e){e[e.SUBTITLE=1]="SUBTITLE",e[e.TRANSLATION=2]="TRANSLATION"}(dc||(dc={}));class uc{constructor(e,t,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,"codec",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"roomCreateTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"userJoinTime",{enumerable:!0,configurable:!0,writable:!0,value:0})}joinRTCRoom(e,t,r,i,n,s,a){return E(this,void 0,void 0,(function*(){const c=cc(this.codec,t,r,i,n,s,a),{code:_,buffer:d}=yield this.context.rtcSignaling(e,Ma,!0,c);let l;if(_===o.SUCCESS&&d){l=_c(this.codec,d);const{users:e,token:t,sessionId:r,roomInfo:i,kvEntries:n,offlineKickTime:s,roomCreateTime:o,userJoinTime:a,version:c}=l;return this.roomCreateTime=o,this.userJoinTime=a,{code:_,data:{users:e,token:t,sessionId:r,roomInfo:i,kvEntries:n,offlineKickTime:s,version:c}}}return{code:_,data:l}}))}quitRTCRoom(e){return E(this,void 0,void 0,(function*(){const t=this.codec.encode(sc.SetUserStatusInput,{status:0}),{code:r}=yield this.context.rtcSignaling(e,wa,!0,t);return r}))}getRTCRoomInfo(e){return E(this,void 0,void 0,(function*(){const t=this.codec.encode(sc.RtcQueryListInput,{order:2}),{code:r,buffer:i}=yield this.context.rtcSignaling(e,xa,!0,t);let n;return r===o.SUCCESS&&i&&(n=this.codec.decode(sc.RtcRoomInfoOutput,i)),{code:r,data:n}}))}getRTCUserInfoList(e){return E(this,void 0,void 0,(function*(){const t=this.codec.encode(sc.RtcQueryListInput,{order:2}),{code:r,buffer:i}=yield this.context.rtcSignaling(e,Ba,!0,t);let n;if(r===o.SUCCESS&&i){n={users:_c(this.codec,i).users}}return{code:r,data:n}}))}getRTCUserInfo(e){throw new Error("Method not implemented.")}removeRTCUserInfo(e,t){return E(this,void 0,void 0,(function*(){const r=this.codec.encode(sc.RtcKeyDeleteInput,{key:t}),{code:i}=yield this.context.rtcSignaling(e,Va,!1,r);return i}))}setRTCData(e,t,r,i,n,s){return E(this,void 0,void 0,(function*(){const o=this.codec.encode(sc.RtcSetDataInput,{interior:i,target:n,key:t,value:r,objectName:null==s?void 0:s.name,content:null==s?void 0:s.content}),{code:a}=yield this.context.rtcSignaling(e,ja,!1,o);return a}))}setRTCTotalRes(e,t,r,i,n,s){return E(this,void 0,void 0,(function*(){const o={objectName:i,content:[],valueInfo:[this.codec.encode(sc.RtcValueInfo,{key:"uris",value:r},!0)]};t.forEach((e=>{const t=this.codec.encode(sc.RtcValueInfo,{key:e.name,value:e.content},!0);o.content.push(t)})),n&&o.valueInfo.push(this.codec.encode(sc.RtcValueInfo,{key:"mcu_uris",value:n},!0)),s&&o.valueInfo.push(this.codec.encode(sc.RtcValueInfo,{key:"cdn_uris",value:s},!0));const a=this.codec.encode(sc.RtcUserSetDataInput,o),{code:c}=yield this.context.rtcSignaling(e,Fa,!0,a);return c}))}setRTCCDNUris(e,t,r){return E(this,void 0,void 0,(function*(){const i=this.codec.encode(sc.RtcUserSetDataInput,{objectName:t,valueInfo:this.codec.encode(sc.RtcValueInfo,{key:"cdn_uris",value:r},!0)}),{code:n}=yield this.context.rtcSignaling(e,Fa,!0,i);return n}))}getRTCData(e,t,r,i){return E(this,void 0,void 0,(function*(){const n=this.codec.encode(sc.RtcDataInput,{interior:r,target:i,key:t}),{code:s,buffer:a}=yield this.context.rtcSignaling(e,Ja,!0,n);if(s!==o.SUCCESS||!a)return{code:s};const{outInfo:c}=this.codec.decode(sc.RtcQryOutput,a),_={};return c.forEach((e=>{_[e.key]=e.value})),{code:s,data:_}}))}removeRTCData(e,t,r,i,n){return E(this,void 0,void 0,(function*(){const s=this.codec.encode(sc.RtcDataInput,{interior:r,target:i,key:t,objectName:(null==n?void 0:n.name)||"",content:(null==n?void 0:n.content)||""}),{code:o}=yield this.context.rtcSignaling(e,Ga,!1,s);return o}))}setRTCOutData(e,t,r,i){return E(this,void 0,void 0,(function*(){throw new Error("JSEngine's method not implemented.")}))}getRTCOutData(e,t){return E(this,void 0,void 0,(function*(){throw new Error("JSEngine's method not implemented.")}))}getRTCToken(e,t,r){return E(this,void 0,void 0,(function*(){const i=cc(this.codec,t,r),{code:n,buffer:s}=yield this.context.rtcSignaling(e,Ha,!0,i);if(n!==o.SUCCESS||!s)return{code:n};const{rtcToken:a}=this.codec.decode(sc.RtcTokenOutput,s);return{code:n,data:{rtcToken:a}}}))}setRTCState(e,t){return E(this,void 0,void 0,(function*(){const r=this.codec.encode(sc.MCFollowInput,{state:t}),{code:i}=yield this.context.rtcSignaling(e,Ka,!0,r);return i}))}setRTCStateByHttp(e,t,r,i){var n;return E(this,void 0,void 0,(function*(){const s=((e,t,r)=>{const{type:i,appKey:n,sessionId:s,roomId:o,roomCreateTime:a,userId:c,userRole:_,joinTime:d,signalDataCenter:l,r1Info:u,r2Info:h,r3Info:g,r4Info:R}=t,p={type:i,appKey:n,sessionId:s,roomId:o,roomCreateTime:a,userId:c,userRole:_,joinTime:d,signalDataCenter:l};if(r===$o.R1&&u){const t=e.encode(sc.RtcPBR1Info,u,!0);return e.encode(sc.RtcPBPolaris,Object.assign(Object.assign({},p),{r1Info:t}))}if(r===$o.R2&&h){const t=e.encode(sc.RtcPBR2Info,h,!0);return e.encode(sc.RtcPBPolaris,Object.assign(Object.assign({},p),{r2Info:t}))}if(r===$o.R3&&g){const{info:t}=g,{streams:r}=t;let i=Array.isArray(r)&&r.map((t=>t&&e.encode(sc.RtcPBStreamInfo,t,!0))),n=e.encode(sc.RtcPBStatusInfo,Object.assign(Object.assign({},t),{streams:i}),!0),s=e.encode(sc.RtcPBR3Info,{info:n},!0);return e.encode(sc.RtcPBPolaris,Object.assign(Object.assign({},p),{r3Info:s}))}if(r===$o.R4&&R){const{info:t}=R,{streams:r}=t;let i=Array.isArray(r)&&r.map((t=>t&&e.encode(sc.RtcPBStreamInfo,t,!0))),n=e.encode(sc.RtcPBStatusInfo,Object.assign(Object.assign({},t),{streams:i}),!0),s=e.encode(sc.RtcPBR4Info,{info:n},!0);return e.encode(sc.RtcPBPolaris,Object.assign(Object.assign({},p),{r4Info:s}))}return{}})(this.codec,r,i);let o=e;/^https:\/\//.test(e)||(o=`https://${e}`);try{const e=yield t.httpReq({url:`${o}/rtc/logserver/polaris`,body:s,method:a.POST,headers:{jwt:(null===(n=this.context.getNaviInfo())||void 0===n?void 0:n.jwt)||""},timeout:2e3});if(!e.data)throw new Error("http request fail");return JSON.parse(e.data).resultCode}catch(e){return Ko.REPORT_FAIL}}))}getRTCUserList(e){return E(this,void 0,void 0,(function*(){const t=this.codec.encode(sc.RtcQueryListInput,{order:2}),{code:r,buffer:i}=yield this.context.rtcSignaling(e,$a,!0,t);if(r!==o.SUCCESS||!i)return{code:r};return{code:r,data:_c(this.codec,i)}}))}joinLivingRoomAsAudience(e,t,r){return E(this,void 0,void 0,(function*(){const i=cc(this.codec,t,r),{code:n,buffer:s}=yield this.context.rtcSignaling(e,Wa,!0,i);if(n!==o.SUCCESS||!s)return{code:n};const{rtcToken:a,entries:c,roomCreateTime:_,userJoinTime:d}=this.codec.decode(sc.RtcViewerJoinedOutput,s);return this.roomCreateTime=xt(_),this.userJoinTime=xt(d),{code:n,data:{token:a,kvEntries:c}}}))}quitLivingRoomAsAudience(e){return E(this,void 0,void 0,(function*(){const t=this.codec.encode(sc.SetUserStatusInput,{status:0}),{code:r}=yield this.context.rtcSignaling(e,za,!0,t);return r}))}rtcIdentityChange(e,t,r){return E(this,void 0,void 0,(function*(){const i=this.codec.encode(sc.RtcInput,{roomType:ks.LIVE,broadcastType:r,identityChangeType:t,needSysChatroom:!1}),{code:n,buffer:s}=yield this.context.rtcSignaling(e,qa,!0,i);if(n!==o.SUCCESS||!s)return{code:n};return{code:n,data:_c(this.codec,s)}}))}requestRoomPK(e){return E(this,void 0,void 0,(function*(){const{invitedRoomId:t,invitedUserId:r,inviteSessionId:i,inviteTimeout:n,inviteInfo:s,roomId:o}=e,a=this.codec.encode(sc.RtcInviteInput,{invitedRoomId:t,invitedUserId:r,inviteSessionId:i,timeoutTime:n,inviteInfo:s}),{code:c}=yield this.context.rtcSignaling(o,Za,!0,a);return c}))}cancelRoomPK(e){return E(this,void 0,void 0,(function*(){const{invitedRoomId:t,invitedUserId:r,inviteSessionId:i,inviteInfo:n,roomId:s}=e,o=this.codec.encode(sc.RtcCancelInviteInput,{invitedRoomId:t,invitedUserId:r,inviteSessionId:i,inviteInfo:n}),{code:a}=yield this.context.rtcSignaling(s,Qa,!0,o);return a}))}responseRoomPK(e){return E(this,void 0,void 0,(function*(){const{inviteUserId:t,inviteRoomId:r,inviteSessionId:i,content:n,key:s,value:o,agree:a,roomId:c}=e,_=this.codec.encode(sc.RtcInviteAnswerInput,{inviteUserId:t,inviteRoomId:r,inviteSessionId:i,content:n,key:s,value:o,answerCode:a?1:0}),{code:d}=yield this.context.rtcSignaling(c,Xa,!0,_);return d}))}endRoomPK(e){return E(this,void 0,void 0,(function*(){const{endRoomId:t,sessionId:r,content:i,keys:n,roomId:s}=e,o=this.codec.encode(sc.RtcEndInviteInput,{inviteRoomId:t,inviteSessionId:r,inviteContent:i,inviteRoomKeys:n}),{code:a}=yield this.context.rtcSignaling(s,ec,!0,o);return a}))}getRTCJoinedUserInfo(e){return E(this,void 0,void 0,(function*(){const t=this.codec.encode(sc.RtcQueryUserJoinedInput,{userId:e}),{code:r,buffer:i}=yield this.context.rtcSignaling("",tc,!0,t);if(r!==o.SUCCESS||!i)return{code:r};return{code:r,data:(this.codec.decode(sc.RtcQueryUserJoinedOutput,i).info||[]).map((e=>({deviceId:e.deviceId,roomId:e.roomId,joinTime:xt(e.joinTime)})))}}))}pullRTCRoomEntry(e){return E(this,void 0,void 0,(function*(){const t=this.codec.encode(sc.RtcPullKV,{timestamp:0,roomId:e}),{code:r,buffer:i}=yield this.context.rtcSignaling(e,Ya,!0,t);if(r!==o.SUCCESS)return{code:r};const n=this.codec.decode(sc.RtcKVOutput,i);let{entries:s,syncTime:a}=n;return s=(s||[]).map((e=>Object.assign(Object.assign({},e),{timestamp:xt(e.timestamp)}))),{code:r,data:{kvEntries:s,syncTime:xt(a)}}}))}pullRTCRoomStatus(e,t){return E(this,void 0,void 0,(function*(){const r=this.codec.encode(sc.RtcRoomStatusInput,{version:t}),{code:i,buffer:n}=yield this.context.rtcSignaling(e,rc,!0,r);if(i!==o.SUCCESS)return{code:i};return{code:i,data:this.codec.decode(sc.RtcRoomStatusOutput,n)}}))}decodeRtcNotify(e){const{time:t,type:r,roomId:i}=this.codec.decode(sc.RtcNotifyMsg,e);return{time:xt(t),type:r,roomId:i}}getCurrentId(){return this.context.getCurrentId()}getNaviInfo(){return this.context.getNaviInfo()}getConnectionStatus(){return this.context.getConnectionStatus()}getAppkey(){return this.context.getAppkey()}webRtcPing(e,t,r){return E(this,void 0,void 0,(function*(){const i=this.codec.encode(sc.RtcInput,{roomType:t,broadcastType:r}),{code:n,buffer:s}=yield this.context.rtcSignaling(e,nc,!0,i);if(n!==o.SUCCESS)return{code:n};const a=this.codec.decode(sc.RtcOutput,s);return a.version=xt(a.version),{code:n,data:a}}))}rtcPing(e,t,r){return/Electron/.test(navigator.userAgent)?this.context.rtcPingResVersion(e,t,r):this.webRtcPing(e,t,r)}sendMessage(e,t,r){return this.context.sendMessage(e,t,r)}registerRTCSignalListener(e){this.context.registerRTCSignalListener(e)}registerConnectionStateChangeListener(e){this.context.onconnectionstatechange=e}registerDisconnectListener(e){this.context.ondisconnect=e}registerDestroyListener(e){this.context.ondestroy=e}registerMessageListener(e){this.context.onmessage=e}getCoreVersion(){return this.context.getCoreVersion()}getPluginContext(){return this.context}reportSDKInfo(e){const t=this.codec.encode(sc.RtcReportSDKInput,{sdkInfo:JSON.stringify(e)});this.context.rtcSignaling("",ic,!0,t)}decodeAsrText(e,t){let r;try{r=this.codec.decode(sc.AsrResTextMsg,e)}catch(r){console.error("decodeAsrText error",{error:r,seiFrameData:e.join(","),seiOriginData:t.join(",")})}const{type:i,uid:n,asr:s}=r||{asr:[]};return s.map((e=>{const{bms:t,t:r,isEnd:s,msgId:o,lang:a}=e,c={userID:n,timeUTC:t,msg:r,msgId:o,isEnd:s};return i===dc.SUBTITLE?c:Object.assign(Object.assign({},c),{destLangCode:a})}))}}!function(e){e.RTC="RTC"}(lc||(lc={})),f.add("rtclib","5.38.0-alpha.1");const hc={tag:"RCRTC",verify:e=>"undefined"==typeof isSecureContext||isSecureContext?!!f.validEngine("5.36.1")||(console.error(`The current engine version '${f.getInfo().engine}' error, plugin-rtc required engine version at least '5.36.1'.`),!1):(console.error("Please use the https protocol or use `http://localhost` to open the page!"),!1),setup(e,r,i={}){const n=e.createLogger("RCRTC",lc.RTC);if(i.logLevel&&n.setOutputLevel(i.logLevel),n.warn(T.L_INDEX_INSTALL_RTC_PLUGIN_O,JSON.stringify({"RCRTC Version":"5.38.0-alpha.1",Commit:"0828c6a022873ab0cb30d904d24eea6e70084bd2","browserInfo.browser":Nt.browser,"browserInfo.supportsUnifiedPlan":Nt.supportsUnifiedPlan,"browserInfo.version":Nt.version})),h("options",i,S.OBJECT,!0),h("options.mediaServer",i.mediaServer,(e=>!(!R(e)||"https:"===location.protocol&&!/^https/.test(e)))),h("options.timeout",i.timeout,(e=>t(e)&&e>=5e3&&e<=3e4)),h("options.pingGap",i.pingGap,(e=>t(e)&&e>=3e3&&e<=1e4)),i.AAAWorklet){h("options.AAAWorklet",i.AAAWorklet,S.OBJECT,!0);const{scriptUrl:e,wasmUrl:t}=i.AAAWorklet;h("AAAWorklet.scriptUrl",e,S.STRING,!0),h("AAAWorklet.wasmUrl",t,S.STRING,!0),Xe.SCRIPT_URL=e,Xe.WASM_URL=t}return i.encryptor&&(h("options.encrypt",i.encryptor,S.OBJECT,!0),h("options.encrypt.decodeAudio",i.encryptor.decodeAudio,(e=>"function"==typeof e),!0),h("options.encrypt.decodeVideo",i.encryptor.decodeVideo,(e=>"function"==typeof e),!0),h("options.encrypt.encodeAudio",i.encryptor.encodeAudio,(e=>"function"==typeof e),!0),h("options.encrypt.encodeVideo",i.encryptor.encodeVideo,(e=>"function"==typeof e),!0),Ts.init(i.encryptor,n)),new Ua(new uc(e,n,e.createCodec(oc,ac)),r,i)}},gc={DEFAULT:"RongCloudRTC"},Rc={transResolution:Lt,transFrameRate:yt,parseTrackId:It,ifSupportLocalFileTrack:Dt,ifSupportScreenShare:Pt};export{ca as BackgroundPictureFillMode,_a as MixLayoutMode,da as MixVideoRenderMode,oa as RCAbstractRoom,La as RCAudienceClient,Na as RCAudienceLivingRoom,ze as RCAudioBitrate,at as RCCameraVideoTrack,Be as RCFrameRate,Aa as RCInnerCDNPullIsHttps,ba as RCInnerCDNPullKind,Jo as RCKickReason,Ta as RCLivingRoom,ga as RCLivingType,tt as RCLocalAudioTrack,st as RCLocalFileAudioTrack,it as RCLocalFileTrack,nt as RCLocalFileVideoTrack,et as RCLocalTrack,rt as RCLocalVideoTrack,ha as RCMCUConfigBuilder,ka as RCMediaStreamCapture,je as RCMediaType,ot as RCMicphoneAudioTrack,Ua as RCRTCClient,I as RCRTCCode,ht as RCRTCGenerateSummarizationFormat,As as RCRTCLiveRole,ss as RCRTCOperateSummarizationType,jt as RCRTCPingResult,Oa as RCRTCRoom,lt as RCRemoteAudioTrack,dt as RCRemoteTrack,ut as RCRemoteVideoTrack,Ve as RCResolution,_t as RCScreenAudioTrack,ct as RCScreenVideoTrack,gc as RCTag,Ye as RCTrack,Ze as RCVideoBitrate,Pa as RTCJoinType,ks as RTCMode,$e as device,Rc as helper,hc as installer};
|