UNPKG

@rongcloud/plugin-call-plus

Version:

@rongcloud/plugin-call-plus

2 lines (1 loc) 41.9 kB
import{EventEmitter as e,ConversationType as t,ErrorCode as n,VersionManage as _,isUndefined as i,LogL as r}from"@rongcloud/engine";import{RCCallPlusSessionUserState as o,RCCallPlusCallState as a,RCCallPlusCode as l,RCCallPlusReason as E,RCCallPlusMediaType as s,RCCallPlusMediaTypeChangeResult as c,RCCallPlusType as u}from"@rongcloud/plugin-call-plus";var I=function(e,t){return I=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},I(e,t)};function R(e,t,n,_){return new(n||(n=Promise))(function(i,r){function o(e){try{l(_.next(e))}catch(e){r(e)}}function a(e){try{l(_.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,a)}l((_=_.apply(e,t||[])).next())})}function O(e,t){var n,_,i,r,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(a){return function(l){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;r&&(r=0,a[0]&&(o=0)),o;)try{if(n=1,_&&(i=2&a[0]?_.return:a[0]?_.throw||((i=_.return)&&i.call(_),0):_.next)&&!(i=i.call(_,a[1])).done)return i;switch(_=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,_=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],_=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}}function C(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var _,i,r=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(_=r.next()).done;)o.push(_.value)}catch(e){i={error:e}}finally{try{_&&!_.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return o}function L(e,t,n){if(n||2===arguments.length)for(var _,i=0,r=t.length;i<r;i++)!_&&i in t||(_||(_=Array.prototype.slice.call(t,0,i)),_[i]=t[i]);return e.concat(_||Array.prototype.slice.call(t))}var N,d,T,S,A,f;"function"==typeof SuppressedError&&SuppressedError;!function(e){e[e.AUDIO=1]="AUDIO",e[e.AUDIO_VIDEO=2]="AUDIO_VIDEO"}(N||(N={})),function(e){e[e.SUCCESS=1e4]="SUCCESS",e[e.STATE_MACHINE_EXIT=53200]="STATE_MACHINE_EXIT",e[e.SEND_MSG_ERROR=53201]="SEND_MSG_ERROR",e[e.REJECTED_BY_BLACKLIST=53202]="REJECTED_BY_BLACKLIST",e[e.NOT_IN_GROUP=53203]="NOT_IN_GROUP",e[e.GET_LOCAL_AUDIO_TRACK_ERROR=53301]="GET_LOCAL_AUDIO_TRACK_ERROR",e[e.GET_LOCAL_VIDEO_TRACK_ERROR=53302]="GET_LOCAL_VIDEO_TRACK_ERROR",e[e.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR=53303]="GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR",e[e.JOIN_ROOM_ERROR=53304]="JOIN_ROOM_ERROR",e[e.AUDIO_PUBLISH_ERROR=53305]="AUDIO_PUBLISH_ERROR",e[e.VIDEO_PUBLISH_ERROR=53306]="VIDEO_PUBLISH_ERROR",e[e.AUDIO_AND_VIDEO_PUBLISH_ERROR=53307]="AUDIO_AND_VIDEO_PUBLISH_ERROR",e[e.QUERY_JOINED_USER_INFO_ERROR=53308]="QUERY_JOINED_USER_INFO_ERROR",e[e.MISSING_VIDEO_TRACK_ERROR=53309]="MISSING_VIDEO_TRACK_ERROR",e[e.UNPUBLISH_VIDEO_ERROR=53310]="UNPUBLISH_VIDEO_ERROR",e[e.CONVERSATION_NOT_GROUP_ERROR=53311]="CONVERSATION_NOT_GROUP_ERROR",e[e.NOT_IN_ROOM_ERROR=53312]="NOT_IN_ROOM_ERROR",e[e.PARAM_ERROR=53313]="PARAM_ERROR",e[e.NOT_IN_CALL=53314]="NOT_IN_CALL",e[e.MEDIATYPE_INVALID=53315]="MEDIATYPE_INVALID",e[e.NOT_VIDEO_CALL=53316]="NOT_VIDEO_CALL",e[e.RTC_SERVICE_UNAVAILABLE=53317]="RTC_SERVICE_UNAVAILABLE",e[e.USER_LIST_INVAILD=53318]="USER_LIST_INVAILD",e[e.CALL_ID_INVALID=53319]="CALL_ID_INVALID",e[e.TRANSACTION_ID_INVALID=53320]="TRANSACTION_ID_INVALID",e[e.USER_ID_INVALID=53321]="USER_ID_INVALID",e[e.SINGLE_CALL_NOT_SUPPORT_MULTI_PERSON=53322]="SINGLE_CALL_NOT_SUPPORT_MULTI_PERSON",e[e.MICROPHONE_CLOSED=53323]="MICROPHONE_CLOSED",e[e.MEDIA_RESOURCE_INVALIED=53324]="MEDIA_RESOURCE_INVALIED",e[e.NOT_INSTALL_RTC_PLUGIN=53325]="NOT_INSTALL_RTC_PLUGIN",e[e.PLAY_MEDIA_FAILED=53326]="PLAY_MEDIA_FAILED",e[e.VIDEO_VIEW_NOT_SET=53327]="VIDEO_VIEW_NOT_SET"}(d||(d={})),function(e){e[e.NONE=0]="NONE",e[e.WAITING=1]="WAITING",e[e.KEEPING=2]="KEEPING"}(T||(T={})),function(e){e[e.WAITING=0]="WAITING",e[e.KEEPING=1]="KEEPING",e[e.END=2]="END"}(S||(S={})),function(e){e[e.CANCEL=1]="CANCEL",e[e.REJECT=2]="REJECT",e[e.HANGUP=3]="HANGUP",e[e.BUSY_LINE=4]="BUSY_LINE",e[e.NO_RESPONSE=5]="NO_RESPONSE",e[e.ENGINE_UNSUPPORTED=6]="ENGINE_UNSUPPORTED",e[e.NETWORK_ERROR=7]="NETWORK_ERROR",e[e.GET_MEDIA_RESOURCES_ERROR=8]="GET_MEDIA_RESOURCES_ERROR",e[e.PUBLISH_ERROR=9]="PUBLISH_ERROR",e[e.SUBSCRIBE_ERROR=10]="SUBSCRIBE_ERROR",e[e.REMOTE_CANCEL=11]="REMOTE_CANCEL",e[e.REMOTE_REJECT=12]="REMOTE_REJECT",e[e.REMOTE_HANGUP=13]="REMOTE_HANGUP",e[e.REMOTE_BUSY_LINE=14]="REMOTE_BUSY_LINE",e[e.REMOTE_NO_RESPONSE=15]="REMOTE_NO_RESPONSE",e[e.REMOTE_ENGINE_UNSUPPORTED=16]="REMOTE_ENGINE_UNSUPPORTED",e[e.REMOTE_NETWORK_ERROR=17]="REMOTE_NETWORK_ERROR",e[e.REMOTE_GET_MEDIA_RESOURCE_ERROR=18]="REMOTE_GET_MEDIA_RESOURCE_ERROR",e[e.REMOTE_PUBLISH_ERROR=19]="REMOTE_PUBLISH_ERROR",e[e.REMOTE_SUBSCRIBE_ERROR=20]="REMOTE_SUBSCRIBE_ERROR",e[e.OTHER_CLIENT_JOINED_CALL=21]="OTHER_CLIENT_JOINED_CALL",e[e.OTHER_CLIENT_IN_CALL=22]="OTHER_CLIENT_IN_CALL",e[e.KICKED_BY_SERVER=23]="KICKED_BY_SERVER",e[e.ACCEPT_SYSTEM_CALL=24]="ACCEPT_SYSTEM_CALL",e[e.REMOTE_OTHER_CLIENT_JOINED_CALL=31]="REMOTE_OTHER_CLIENT_JOINED_CALL",e[e.REMOTE_OTHER_CLIENT_IN_CALL=32]="REMOTE_OTHER_CLIENT_IN_CALL",e[e.REMOTE_KICKED_BY_SERVER=33]="REMOTE_KICKED_BY_SERVER",e[e.REMOTE_ACCEPT_SYSTEM_CALL=34]="REMOTE_ACCEPT_SYSTEM_CALL",e[e.ACCEPT_BY_OTHER_CLIENT=101]="ACCEPT_BY_OTHER_CLIENT",e[e.HANGUP_BY_OTHER_CLIENT=102]="HANGUP_BY_OTHER_CLIENT",e[e.ADDED_TO_BLACKLIST=103]="ADDED_TO_BLACKLIST",e[e.SERVICE_NOT_OPENED=104]="SERVICE_NOT_OPENED"}(f||(f={}));(A={})[f.CANCEL]=f.REMOTE_CANCEL,A[f.REJECT]=f.REMOTE_REJECT,A[f.HANGUP]=f.REMOTE_HANGUP,A[f.BUSY_LINE]=f.REMOTE_BUSY_LINE,A[f.NO_RESPONSE]=f.REMOTE_NO_RESPONSE,A[f.ENGINE_UNSUPPORTED]=f.REMOTE_ENGINE_UNSUPPORTED,A[f.NETWORK_ERROR]=f.REMOTE_NETWORK_ERROR,A[f.GET_MEDIA_RESOURCES_ERROR]=f.REMOTE_GET_MEDIA_RESOURCE_ERROR,A[f.PUBLISH_ERROR]=f.REMOTE_PUBLISH_ERROR,A[f.SUBSCRIBE_ERROR]=f.REMOTE_SUBSCRIBE_ERROR,A[f.OTHER_CLIENT_JOINED_CALL]=f.REMOTE_OTHER_CLIENT_JOINED_CALL,A[f.OTHER_CLIENT_IN_CALL]=f.REMOTE_OTHER_CLIENT_IN_CALL,A[f.KICKED_BY_SERVER]=f.REMOTE_KICKED_BY_SERVER,A[f.REMOTE_NO_RESPONSE]=f.NO_RESPONSE,A[f.ACCEPT_SYSTEM_CALL]=f.REMOTE_ACCEPT_SYSTEM_CALL;var p,g=function(e){var t=null;switch(e){case o.IDLE:t=T.NONE;break;case o.CALLING:case o.INVITED:case o.RINGING:t=T.WAITING;break;case o.BUSYLINE_RINGING:case o.BUSYLINE_WAIT:t=T.NONE;break;case o.CONNECTING:t=T.WAITING;break;case o.ONCALL:t=T.KEEPING;break;case o.ONPHONE:t=T.WAITING;break;case o.ENDED:case o.NO_ANSWER:case o.MISSED:case o.CANCELLED:case o.DECLINED:case o.ERROR:default:t=T.NONE}return t},b=function(e){var t=null;switch(e){case l.SUCCESS:t=d.SUCCESS;break;case l.PARAM_ERROR:t=d.PARAM_ERROR;break;case l.SESSION_EXIST:t=d.STATE_MACHINE_EXIT;break;case l.NOT_IN_CALL:t=d.NOT_IN_CALL;break;case l.MEDIATYPE_INVALID:t=d.MEDIATYPE_INVALID;break;case l.NOT_VIDEO_CALL:t=d.NOT_VIDEO_CALL;break;case l.RTC_SERVICE_UNAVAILABLE:t=d.RTC_SERVICE_UNAVAILABLE;break;case l.USER_LIST_INVAILD:t=d.USER_LIST_INVAILD;break;case l.CALL_ID_INVALID:t=d.CALL_ID_INVALID;break;case l.TRANSACTION_ID_INVALID:t=d.TRANSACTION_ID_INVALID;break;case l.USER_ID_INVALID:t=d.USER_ID_INVALID;break;case l.SINGLE_CALL_NOT_SUPPORT_MULTI_PERSON:t=d.SINGLE_CALL_NOT_SUPPORT_MULTI_PERSON;break;case l.CAMERA_CLOSED:t=d.MISSING_VIDEO_TRACK_ERROR;break;case l.MICROPHONE_CLOSED:t=d.MICROPHONE_CLOSED;break;case l.MEDIA_RESOURCE_INVALIED:t=d.MEDIA_RESOURCE_INVALIED;break;case l.NOT_INSTALL_RTC_PLUGIN:t=d.NOT_INSTALL_RTC_PLUGIN;break;case l.PLAY_MEDIA_FAILED:t=d.PLAY_MEDIA_FAILED;break;case l.VIDEO_VIEW_NOT_SET:t=d.VIDEO_VIEW_NOT_SET;break;default:t=e}return t},h=function(e,t){var n=null;switch(e){case E.BUSYLINE_RINGING:n=t?f.BUSY_LINE:f.REMOTE_BUSY_LINE;break;case E.ON_DEVICE_DISABLE:n=f.REMOTE_GET_MEDIA_RESOURCE_ERROR;break;case E.ENDED:n=t?f.HANGUP:f.REMOTE_HANGUP;break;case E.NO_ANSWER:n=f.REMOTE_NO_RESPONSE;break;case E.MISSED:n=f.NO_RESPONSE;break;case E.CANCELLED:n=t?f.CANCEL:f.REMOTE_CANCEL;break;case E.DECLINED:n=t?f.REJECT:f.REMOTE_REJECT;break;case E.OTHER_CLIENT_ACCEPT:n=f.ACCEPT_BY_OTHER_CLIENT;break;case E.PUBLISH_ERR:n=f.PUBLISH_ERROR;break;case E.SUBSCRIBE_ERR:n=f.SUBSCRIBE_ERROR;break;case E.ACCEPT_CARRIER:n=t?f.ACCEPT_SYSTEM_CALL:f.REMOTE_ACCEPT_SYSTEM_CALL;break;case E.KICKED_BY_SERVER:n=f.KICKED_BY_SERVER;break;case E.CONNECTION_ERR:n=f.NETWORK_ERROR;break;case E.OTHER_CLIENT_JOINED:n=t?f.OTHER_CLIENT_JOINED_CALL:f.REMOTE_OTHER_CLIENT_JOINED_CALL;break;case E.OTHER_CLIENT_IN_ROOM:n=f.OTHER_CLIENT_IN_CALL;break;case E.OTHER_CLIENT_HANGUP:n=f.HANGUP_BY_OTHER_CLIENT;break;case E.REMOTE_PUBLISH_ERROR:n=f.REMOTE_PUBLISH_ERROR;break;case E.REMOTE_SUBSCRIBE_ERROR:n=f.REMOTE_SUBSCRIBE_ERROR;break;case E.REMOTE_KICKED_BY_SERVER:n=f.REMOTE_KICKED_BY_SERVER;break;case E.REMOTE_CONNECTION_ERROR:n=f.REMOTE_NETWORK_ERROR;break;case E.ABNORMAL_END:n=t?f.NETWORK_ERROR:f.REMOTE_NETWORK_ERROR;break;case E.OTHER_CLIENT_CALLING:n=f.REMOTE_OTHER_CLIENT_JOINED_CALL;break;case E.JOIN_ROOM_ERR:n=f.NETWORK_ERROR;break;case E.LOGOUT:n=f.HANGUP;break;case E.OTHER_CLIENT_LOGIN:n=f.NETWORK_ERROR;break;case E.REMOTE_JOIN_RTC_ERROR:n=f.REMOTE_NETWORK_ERROR;break;case E.REMOTE_LOGOUT:n=f.REMOTE_HANGUP;break;case E.REMOTE_OTHER_CLIENT_LOGIN:n=f.REMOTE_NETWORK_ERROR;break;case E.REMOTE_OTHER_JOINED_RTC:n=f.REMOTE_OTHER_CLIENT_JOINED_CALL;break;case E.REMOTE_OTHER_CLIENT_IN_RTC:n=f.REMOTE_OTHER_CLIENT_IN_CALL;break;default:n=f.NETWORK_ERROR}return n};!function(e){e.L_CALL_PLUS_WRAPPER_INIT_O="L-call_plus_wrapper_init-O",e.L_CALL_CLIENT_REGISTER_USER_INFO_O="L-call_client_register_user_info-O",e.L_CALL_CLIENT_START_CROSS_CALL_O="L-call_client_start_cross_call-O",e.L_CALL_CLIENT_CALL_T="L-call_client_call-T",e.L_CALL_CLIENT_CALL_R="L-call_client_call-R",e.L_CALL_CLIENT_CALL_IN_GROUP_T="L-call_client_call_in_group-T",e.L_CALL_CLIENT_CALL_IN_GROUP_R="L-call_client_call_in_group-R",e.L_CALL_CLIENT_SET_PUSH_CONFIG_O="L-call_client_set_push_config-O",e.L_CALL_SESSION_REGISTER_SESSION_LISTENER_O="L-call_session_register_session_listener-O",e.L_CALL_SESSION_CHANGE_AUDIO_DEVICE_T="L-call_session_change_audio_device-T",e.L_CALL_SESSION_CHANGE_AUDIO_DEVICE_R="L-call_session_change_audio_device-R",e.L_CALL_SESSION_INVITE_T="L-call_session_invite-T",e.L_CALL_SESSION_INVITE_R="L-call_session_invite-R",e.L_CALL_SESSION_ACCEPT_T="L-call_session_accept-T",e.L_CALL_SESSION_ACCEPT_R="L-call_session_accept-R",e.L_CALL_SESSION_HUNGUP_T="L-call_session_hungup-T",e.L_CALL_SESSION_HUNGUP_R="L-call_session_hungup-R",e.L_CALL_SESSION_DESCEND_ABILITY_T="L-call_session_descend_ability-T",e.L_CALL_SESSION_DESCEND_ABILITY_R="L-call_session_descend_ability-R",e.L_CALL_SESSION_DISABLE_VIDEO_TRACK_T="L-call_session_disable_video_track-T",e.L_CALL_SESSION_DISABLE_VIDEO_TRACK_R="L-call_session_disable_video_track-R",e.L_CALL_SESSION_ENABLE_VIDEO_TRACK_T="L-call_session_enable_video_track-T",e.L_CALL_SESSION_ENABLE_VIDEO_TRACK_R="L-call_session_enable_video_track-R",e.L_CALL_SESSION_DISABLE_AUDIO_TRACK_T="L-call_session_disable_audio_track-T",e.L_CALL_SESSION_DISABLE_AUDIO_TRACK_R="L-call_session_disable_audio_track-R",e.L_CALL_SESSION_ENABLE_AUDIO_TRACK_T="L-call_session_enable_audio_track-T",e.L_CALL_SESSION_ENABLE_AUDIO_TRACK_R="L-call_session_enable_audio_track-R",e.L_CALL_EXECUTE_EVENT_LISTENER_O="L-call_execute_event_listener-O",e.L_CALL_CLIENT_GET_JOINED_ROOM_INFO_E="L-call_client_get_joined_room_info-E"}(p||(p={}));var v,P=function(){function e(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_listener",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}return Object.defineProperty(e.prototype,"registerEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._listener=e}}),Object.defineProperty(e.prototype,"_callAppListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,n=[],_=1;_<arguments.length;_++)n[_-1]=arguments[_];return R(this,void 0,void 0,function(){var _,i;return O(this,function(r){switch(r.label){case 0:if(!(_=null===(t=this._listener)||void 0===t?void 0:t[e]))return[2];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,_.apply(void 0,L([],C(n),!1))];case 2:return r.sent(),[3,4];case 3:return i=r.sent(),this._logger.error(p.L_CALL_EXECUTE_EVENT_LISTENER_O,JSON.stringify({eventName:e,name:i.name,message:i.message})),[3,4];case 4:return[2]}})})}}),Object.defineProperty(e.prototype,"onRinging",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(p.L_CALL_EXECUTE_EVENT_LISTENER_O,JSON.stringify({eventType:"onRinging",sender:e,sessionId:t.getSessionId()})),this._callAppListener("onRinging",e,t)}}),Object.defineProperty(e.prototype,"onAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(p.L_CALL_EXECUTE_EVENT_LISTENER_O,JSON.stringify({eventType:"onAccept",sender:e,sessionId:t.getSessionId()})),this._callAppListener("onAccept",e,t)}}),Object.defineProperty(e.prototype,"onHungup",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){this._logger.info(p.L_CALL_EXECUTE_EVENT_LISTENER_O,JSON.stringify({eventType:"onHungup",sender:e,reason:t,sessionId:n.getSessionId()})),this._callAppListener("onHungup",e,t,n)}}),Object.defineProperty(e.prototype,"onMemberModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){this._logger.info(p.L_CALL_EXECUTE_EVENT_LISTENER_O,JSON.stringify({eventType:"onMemberModify",sender:e,invitedUsers:t,sessionId:n.getSessionId()})),this._callAppListener("onMemberModify",e,t,n)}}),Object.defineProperty(e.prototype,"onMediaModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){this._logger.info(p.L_CALL_EXECUTE_EVENT_LISTENER_O,JSON.stringify({eventType:"onMediaModify",sender:e,mediaType:t,sessionId:n.getSessionId()})),this._callAppListener("onMediaModify",e,t,n)}}),Object.defineProperty(e.prototype,"onTrackReady",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){this._logger.info(p.L_CALL_EXECUTE_EVENT_LISTENER_O,JSON.stringify({eventType:"onTrackReady",userId:e,mediaType:t,sessionId:null==n?void 0:n.getSessionId()})),this._callAppListener("onTrackReady",e,t,n)}}),Object.defineProperty(e.prototype,"onAudioMuteChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(p.L_CALL_EXECUTE_EVENT_LISTENER_O,JSON.stringify({eventType:"onAudioMuteChange",muteUser:e,sessionId:t.getSessionId()})),this._callAppListener("onAudioMuteChange",e,t)}}),Object.defineProperty(e.prototype,"onVideoMuteChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(p.L_CALL_EXECUTE_EVENT_LISTENER_O,JSON.stringify({eventType:"onVideoMuteChange",muteUser:e,sessionId:t.getSessionId()})),this._callAppListener("onVideoMuteChange",e,t)}}),Object.defineProperty(e.prototype,"onTrackSubscribeFail",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(p.L_CALL_EXECUTE_EVENT_LISTENER_O,JSON.stringify({eventType:"onTrackSubscribeFail",code:e,sessionId:t.getSessionId()})),this._callAppListener("onTrackSubscribeFail",e,t)}}),Object.defineProperty(e.prototype,"onSendPacketLoss",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){this._logger.info(p.L_CALL_EXECUTE_EVENT_LISTENER_O,JSON.stringify({eventType:"onSendPacketLoss",sessionId:n.getSessionId()})),this._callAppListener("onSendPacketLoss",e,t,n)}}),Object.defineProperty(e.prototype,"onReceivePacketLoss",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(p.L_CALL_EXECUTE_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivePacketLoss",sessionId:t.getSessionId()})),this._callAppListener("onReceivePacketLoss",e,t)}}),e}();!function(e){e.INNER_ON_RINGING="inner-on-ringing",e.INNER_ON_ACCEPT="inner-on-accept",e.INNER_ON_HANGUP="inner-on-hangup",e.INNER_ON_TRACK_READY="inner-on-track-ready",e.INNER_ON_MEMBER_MODIFY="inner-on-member-modify",e.INNER_ON_MEDIA_MODIFY="inner-on-media-modify",e.INNER_ON_AUDIO_MUTE_CHANGE="inner-on-audio-mute-change",e.INNER_ON_VIDEO_MUTE_CHANGE="inner-on-video-mute-change",e.INNER_ON_TRACK_SUBSCRIBE_FAIL="inner-on-track-subscribe-fail",e.INNER_ON_SELF_HANGUP="inner-on-self-hangup",e.INNER_ON_SEND_PACKET_LOSS="inner-on-send-packet-loss",e.INNER_ON_RECEIVE_PACKET_LOSS="inner-on-receive-packet-loss"}(v||(v={}));var D,U=function(e){function n(t,n,_,i,r,o,a,l,E){var s=e.call(this)||this;return Object.defineProperty(s,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(s,"_callPlusClient",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(s,"_channelId",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(s,"_targetId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(s,"_callType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(s,"_mediaType",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(s,"_context",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(s,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:l}),Object.defineProperty(s,"_options",{enumerable:!0,configurable:!0,writable:!0,value:E}),Object.defineProperty(s,"_descendResolve",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(s,"_audioConfigBuilder",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(s,"_videoConfigBuilder",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(s,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),s._audioConfigBuilder=s._callPlusClient.createAudioConfigBuilder(),s._videoConfigBuilder=s._callPlusClient.createVideoConfigBuilder(),s._reportAppEventModule=new P(l),s}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}I(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(n,e),Object.defineProperty(n.prototype,"registerSessionListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;this._logger.info(p.L_CALL_SESSION_REGISTER_SESSION_LISTENER_O,Object.keys(e).join(",")),this._reportAppEventModule.registerEventListener(e),this.on(v.INNER_ON_RINGING,function(e,n){t._reportAppEventModule.onRinging(e,n)}),this.on(v.INNER_ON_ACCEPT,function(e,n){t._reportAppEventModule.onAccept(e,n)}),this.on(v.INNER_ON_HANGUP,function(e,n,_){t._reportAppEventModule.onHungup(e,n,_)}),this.on(v.INNER_ON_TRACK_READY,function(e,n,_){t._reportAppEventModule.onTrackReady(e,n,_)}),this.on(v.INNER_ON_MEMBER_MODIFY,function(e,n,_){t._reportAppEventModule.onMemberModify(e,n,_)}),this.on(v.INNER_ON_MEDIA_MODIFY,function(e,n,_,i){t._reportAppEventModule.onMediaModify(e,n,_)}),this.on(v.INNER_ON_AUDIO_MUTE_CHANGE,function(e,n){t._reportAppEventModule.onAudioMuteChange(e,n)}),this.on(v.INNER_ON_VIDEO_MUTE_CHANGE,function(e,n){t._reportAppEventModule.onVideoMuteChange(e,n)}),this.on(v.INNER_ON_TRACK_SUBSCRIBE_FAIL,function(e,n){var _,i;null===(i=(_=t._reportAppEventModule).onTrackSubscribeFail)||void 0===i||i.call(_,e,n)}),this.on(v.INNER_ON_SEND_PACKET_LOSS,function(e,n,_){var i,r;null===(r=(i=t._reportAppEventModule).onSendPacketLoss)||void 0===r||r.call(i,e,n,_)}),this.on(v.INNER_ON_RECEIVE_PACKET_LOSS,function(e,n){var _,i;null===(i=(_=t._reportAppEventModule).onReceivePacketLoss)||void 0===i||i.call(_,e,n)})}}),Object.defineProperty(n.prototype,"changeAudioDevice",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return R(this,void 0,void 0,function(){var t,n,_,i;return O(this,function(r){switch(r.label){case 0:return t=this._logger.createTraceId(),this._logger.info(p.L_CALL_SESSION_CHANGE_AUDIO_DEVICE_T,JSON.stringify(e),t),e?(n=e.micphoneId,_=e.sampleRate,this._callPlusClient.setAudioConfig({microphoneId:n,sampleRate:_}),[4,this._callPlusClient.switchMicrophone(n)]):(this._logger.error(p.L_CALL_SESSION_CHANGE_AUDIO_DEVICE_R,"errorCode: ".concat(d.PARAM_ERROR),t),[2,{code:d.PARAM_ERROR}]);case 1:return(i=r.sent().code)!==l.SUCCESS?(this._logger.error(p.L_CALL_SESSION_CHANGE_AUDIO_DEVICE_R,"errorCode: ".concat(b(i)),t),[2,{code:b(i)}]):(this._logger.info(p.L_CALL_SESSION_CHANGE_AUDIO_DEVICE_R,"success",t),[2,{code:b(i)}])}})})}}),Object.defineProperty(n.prototype,"invite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,n){return void 0===n&&(n={}),R(this,void 0,void 0,function(){var _,i,r,o,a;return O(this,function(E){switch(E.label){case 0:return _=this._logger.createTraceId(),this._logger.info(p.L_CALL_SESSION_INVITE_T,JSON.stringify({userIds:e,options:n}),_),i=n.extra,r=JSON.stringify({callLibExtra:i,targetId:this._targetId,channelId:this._channelId,conversationType:t.GROUP}),o=this._options.callPushConfig||n.pushConfig,[4,this._callPlusClient.invite(e,o,r)];case 1:return(a=E.sent().code)!==l.SUCCESS?(this._logger.error(p.L_CALL_SESSION_INVITE_R,"errorCode: ".concat(b(a)),_),[2,{code:b(a)}]):(this._logger.info(p.L_CALL_SESSION_INVITE_R,"success",_),[2,{code:b(a)}])}})})}}),Object.defineProperty(n.prototype,"accept",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return R(this,void 0,void 0,function(){var t,n,_,i,r,o;return O(this,function(a){switch(a.label){case 0:return t=this._logger.createTraceId(),this._logger.info(p.L_CALL_SESSION_ACCEPT_T,JSON.stringify(e),t),e&&(n=e.audio,_=e.video,(null==n?void 0:n.micphoneId)&&this._audioConfigBuilder.setDefaultMicrophoneId(n.micphoneId),(null==n?void 0:n.sampleRate)&&this._audioConfigBuilder.setSampleRate(n.sampleRate),(null==_?void 0:_.cameraId)&&this._videoConfigBuilder.setDefaultCameraId(_.cameraId),(null==_?void 0:_.frameRate)&&this._videoConfigBuilder.setFrameRate(_.frameRate),(null==_?void 0:_.resolution)&&this._videoConfigBuilder.setVideoResolution(_.resolution)),i=this._audioConfigBuilder.build(),r=this._videoConfigBuilder.build(),this._callPlusClient.setAudioConfig(i),this._callPlusClient.setVideoConfig(r),[4,this._callPlusClient.accept(this._callId,this._options.callPushConfig)];case 1:return(o=a.sent().code)!==l.SUCCESS?(this._logger.error(p.L_CALL_SESSION_ACCEPT_R,"errorCode: ".concat(b(o)),t),[2,{code:b(o)}]):(this._logger.info(p.L_CALL_SESSION_ACCEPT_R,"success",t),[2,{code:b(o)}])}})})}}),Object.defineProperty(n.prototype,"hungup",{enumerable:!1,configurable:!0,writable:!0,value:function(){return R(this,void 0,void 0,function(){var e,t;return O(this,function(n){switch(n.label){case 0:return e=this._logger.createTraceId(),this._logger.info(p.L_CALL_SESSION_HUNGUP_T,"",e),this.emit(v.INNER_ON_SELF_HANGUP),[4,this._callPlusClient.hangup(this._callId,this._options.hangupPushConfig)];case 1:return(t=n.sent().code)!==l.SUCCESS?this._logger.error(p.L_CALL_SESSION_HUNGUP_R,"errorCode: ".concat(b(t)),e):this._logger.info(p.L_CALL_SESSION_HUNGUP_R,"success",e),[2,{code:b(t)}]}})})}}),Object.defineProperty(n.prototype,"descendAbility",{enumerable:!1,configurable:!0,writable:!0,value:function(){return R(this,void 0,void 0,function(){var e,t,n,_,i,r=this;return O(this,function(o){switch(o.label){case 0:return e=this._logger.createTraceId(),this._logger.info(p.L_CALL_SESSION_DESCEND_ABILITY_T,"",e),[4,this._callPlusClient.requestChangeMediaType(s.AUDIO)];case 1:return t=o.sent(),n=t.code,_=t.transactionId,n!==l.SUCCESS?(this._logger.error(p.L_CALL_SESSION_DESCEND_ABILITY_R,"errorCode: ".concat(b(n)),e),[2,{code:b(n)}]):[4,new Promise(function(e){r._descendResolve[_]=e})];case 2:return i=o.sent(),this._logger.info(p.L_CALL_SESSION_DESCEND_ABILITY_R,"transactionId: ".concat(_),e),[2,{code:i.code}]}})})}}),Object.defineProperty(n.prototype,"disableVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return R(this,void 0,void 0,function(){var e,t;return O(this,function(n){switch(n.label){case 0:return e=this._logger.createTraceId(),this._logger.info(p.L_CALL_SESSION_DISABLE_VIDEO_TRACK_T,"",e),[4,this._callPlusClient.stopCamera()];case 1:return(t=n.sent().code)!==l.SUCCESS?(this._logger.error(p.L_CALL_SESSION_DISABLE_VIDEO_TRACK_R,"errorCode: ".concat(b(t)),e),[2,{code:b(t)}]):(this._logger.info(p.L_CALL_SESSION_DISABLE_VIDEO_TRACK_R,"success",e),[2,{code:b(t)}])}})})}}),Object.defineProperty(n.prototype,"enableVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return R(this,void 0,void 0,function(){var e,t;return O(this,function(n){switch(n.label){case 0:return e=this._logger.createTraceId(),this._logger.info(p.L_CALL_SESSION_ENABLE_VIDEO_TRACK_T,"",e),[4,this._callPlusClient.startCamera()];case 1:return(t=n.sent().code)!==l.SUCCESS?(this._logger.error(p.L_CALL_SESSION_ENABLE_VIDEO_TRACK_R,"errorCode: ".concat(b(t)),e),[2,{code:b(t)}]):(this._logger.info(p.L_CALL_SESSION_ENABLE_VIDEO_TRACK_R,"success",e),[2,{code:b(t)}])}})})}}),Object.defineProperty(n.prototype,"disableAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return R(this,void 0,void 0,function(){var e,t;return O(this,function(n){switch(n.label){case 0:return e=this._logger.createTraceId(),this._logger.info(p.L_CALL_SESSION_DISABLE_AUDIO_TRACK_T,"",e),[4,this._callPlusClient.stopMicrophone()];case 1:return(t=n.sent().code)!==l.SUCCESS?(this._logger.error(p.L_CALL_SESSION_DISABLE_AUDIO_TRACK_R,"errorCode: ".concat(b(t)),e),[2,{code:b(t)}]):(this._logger.info(p.L_CALL_SESSION_DISABLE_AUDIO_TRACK_R,"success",e),[2,{code:b(t)}])}})})}}),Object.defineProperty(n.prototype,"enableAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return R(this,void 0,void 0,function(){var e,t;return O(this,function(n){switch(n.label){case 0:return e=this._logger.createTraceId(),this._logger.info(p.L_CALL_SESSION_ENABLE_AUDIO_TRACK_T,"",e),[4,this._callPlusClient.startMicrophone()];case 1:return(t=n.sent().code)!==l.SUCCESS?(this._logger.error(p.L_CALL_SESSION_ENABLE_AUDIO_TRACK_R,"errorCode: ".concat(b(t)),e),[2,{code:b(t)}]):(this._logger.info(p.L_CALL_SESSION_ENABLE_AUDIO_TRACK_R,"success",e),[2,{code:b(t)}])}})})}}),Object.defineProperty(n.prototype,"getSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callId}}),Object.defineProperty(n.prototype,"getRTCSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._callPlusClient.getCurrentCallSession();return this._callId!==(null==e?void 0:e.getCallId())?null:this._callPlusClient.getRTCSessionId()}}),Object.defineProperty(n.prototype,"getTargetId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._targetId}}),Object.defineProperty(n.prototype,"getChannelId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._channelId}}),Object.defineProperty(n.prototype,"getConversationType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callType}}),Object.defineProperty(n.prototype,"getRemoteUsers",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=this._callPlusClient.getCurrentCallSession();if(this._callId!==(null==t?void 0:t.getCallId()))return[];var n=(null==t?void 0:t.getUserList())||[];return null==n?void 0:n.map(function(t){var n=t.userId,_=t.state;return{userId:n,state:g(_),isCaller:n===e.getCallerId(),isRemote:n!==e._context.getCurrentId()}})}}),Object.defineProperty(n.prototype,"getUserState",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._callPlusClient.getCurrentCallSession();if(this._callId!==(null==t?void 0:t.getCallId()))return T.NONE;var n=null==t?void 0:t.getUserList().filter(function(t){return t.userId===e})[0].state;return g(n)}}),Object.defineProperty(n.prototype,"getState",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._callPlusClient.getCurrentCallSession();return function(e){var t=null;switch(e){case a.IDLE:t=S.END;break;case a.CALLING:case a.INVITED:case a.RINGING:case a.BUSYLINE_RINGING:case a.BUSYLINE_WAIT:t=S.WAITING;break;case a.CONNECTING:case a.ONCALL:t=S.KEEPING;break;case a.ENDED:case a.NOANSWER:case a.MISSED:case a.CANCELED:case a.DECLINED:case a.ERROR:default:t=S.END}return t}(this._callId===(null==e?void 0:e.getCallId())?null==e?void 0:e.getState():a.ENDED)}}),Object.defineProperty(n.prototype,"getCallerId",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._callPlusClient.getCurrentCallSession();return this._callId!==(null==e?void 0:e.getCallId())?"":e.getCreatorUserId()}}),Object.defineProperty(n.prototype,"getMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._mediaType===s.AUDIO?N.AUDIO:N.AUDIO_VIDEO}}),Object.defineProperty(n.prototype,"__innerEndTranction",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._mediaType=e,this._descendResolve[t]&&(this._descendResolve[t]({code:d.SUCCESS}),delete this._descendResolve[t])}}),n}(e),y=function(){function e(e,t,n){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,"_options",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_callPlusClient",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_targetId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_channelId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_session",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_sessionStartTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_listener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_mediaType",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_audioConfigBuilder",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_videoConfigBuilder",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_callPushConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_hangupPushConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_isSelfHangup",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._callPlusClient=n.callPlusClient,this._reportAppEventModule=new P(t),this._setCallPlusEventListener(),this._audioConfigBuilder=this._callPlusClient.createAudioConfigBuilder(),this._videoConfigBuilder=this._callPlusClient.createVideoConfigBuilder()}return Object.defineProperty(e.prototype,"_setCallPlusEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,n=0,_={},i={};this._callPlusClient.setStatusReportListener({onSendPacketLoss:function(t,n){var _,i,r;e._listener?null===(i=(_=e._listener).onSendPacketLoss)||void 0===i||i.call(_,t,n,e._session):null===(r=e._session)||void 0===r||r.emit(v.INNER_ON_SEND_PACKET_LOSS,t,n,e._session)},onReceivePacketLoss:function(t){var n,_,i;e._listener?null===(_=(n=e._listener).onReceivePacketLoss)||void 0===_||_.call(n,t,e._session):null===(i=e._session)||void 0===i||i.emit(v.INNER_ON_RECEIVE_PACKET_LOSS,t,e._session)}}),this._callPlusClient.setCallPlusEventListener({onReceivedCall:function(n,_){return void 0===_&&(_="{}"),R(this,void 0,void 0,function(){var i,r,o;return O(this,function(a){return i=n.getCallId(),e._session?(e._callPlusClient.hangup(i,e._hangupPushConfig),[2]):(e._targetId=JSON.parse(_).targetId||"",e._channelId=JSON.parse(_).channelId||"",e._mediaType=n.getMediaType()===s.AUDIO?N.AUDIO:N.AUDIO_VIDEO,r=n.getCallType(),o=r===u.MULTI?t.GROUP:t.PRIVATE,e._session=new U(i,e._callPlusClient,e._channelId,e._targetId,o,n.getMediaType(),e._context,e._logger,{callPushConfig:e._callPushConfig,hangupPushConfig:e._hangupPushConfig}),e._session.on(v.INNER_ON_SELF_HANGUP,function(){e._isSelfHangup=!0}),e._options.onSession(e._session,JSON.parse(_).callLibExtra||""),[2])})})},onRemoteUserInvited:function(t,n,_){var i,r={userId:n},o=t.map(function(e){return{userId:e}});e._listener?e._reportAppEventModule.onMemberModify(r,o,e._session):null===(i=e._session)||void 0===i||i.emit(v.INNER_ON_MEMBER_MODIFY,r,o,e._session)},onCallConnected:function(e){var t=e.getCallId();i[t]=!0},onCallTypeChanged:function(e,t){},onRemoteUserStateChanged:function(t,n,i,r){var a,l,s;return R(this,void 0,void 0,function(){var c,I,R,C,L,N,d,T,S;return O(this,function(O){return c={userId:n},I=[o.IDLE,o.DECLINED,o.MISSED,o.NO_ANSWER].includes(i),e._listener?(i===o.RINGING&&e._reportAppEventModule.onRinging(c,e._session),i===o.CONNECTING&&e._reportAppEventModule.onAccept(c,e._session),I&&e._reportAppEventModule.onHungup(c,h(r,e._isSelfHangup),e._session)):(i===o.RINGING&&(null===(a=e._session)||void 0===a||a.emit(v.INNER_ON_RINGING,c,e._session)),i===o.CONNECTING&&(null===(l=e._session)||void 0===l||l.emit(v.INNER_ON_ACCEPT,c,e._session)),I&&(null===(s=e._session)||void 0===s||s.emit(v.INNER_ON_HANGUP,c,h(r,e._isSelfHangup),e._session))),R=e._callPlusClient.getCurrentCallSession(),C=null==R?void 0:R.getCallType(),L=null==R?void 0:R.getUserList(),N=null==L?void 0:L.filter(function(t){return t.userId===e._context.getCurrentId()})[0],d=null==L?void 0:L.filter(function(t){return t.userId!==e._context.getCurrentId()}),T=null==d?void 0:d.every(function(e){return e.state===o.IDLE}),S=(null==N?void 0:N.state)===o.ONCALL&&T,I&&C===u.MULTI&&S&&(e._callPlusClient.hangup(),_[t]=r===E.MISSED?E.NO_ANSWER:r,e._isSelfHangup=!1),[2]})})},onCallEnded:function(t,r){return R(this,void 0,void 0,function(){var o,a,l;return O(this,function(E){return o=+new Date-n,a=t.getCallId(),l={conversationType:e._session.getConversationType(),channelId:e._session.getChannelId(),targetId:e._session.getTargetId(),mediaType:e._session.getMediaType(),beginTimestamp:e._sessionStartTime,endTimestamp:o,duration:i[a]?Math.ceil((o-e._sessionStartTime)/1e3):0,endReason:_[a]?h(_[a],e._isSelfHangup):h(r,e._isSelfHangup)},e._options.onSessionClose(e._session,l),e._session=null,e._sessionStartTime=0,delete _[a],delete i[a],[2]})})},onUserMediaAvailable:function(t,n){var _;return R(this,void 0,void 0,function(){var i;return O(this,function(r){return i=n===s.AUDIO?N.AUDIO:N.AUDIO_VIDEO,e._listener?e._reportAppEventModule.onTrackReady(t,i,e._session):null===(_=e._session)||void 0===_||_.emit(v.INNER_ON_TRACK_READY,t,i,e._session),[2]})})},onFetchRemoteMediaError:function(t,n){var _,i,r;e._listener?null===(i=(_=e._reportAppEventModule).onTrackSubscribeFail)||void 0===i||i.call(_,n,e._session):null===(r=e._session)||void 0===r||r.emit(v.INNER_ON_TRACK_SUBSCRIBE_FAIL,n,e._session)},onRemoteCameraStateChanged:function(t,n,_){var i,r={userId:n,muted:_,kind:"video",trackId:"".concat(n,"_RongCloudRTC_1")};e._listener?e._reportAppEventModule.onVideoMuteChange(r,e._session):null===(i=e._session)||void 0===i||i.emit(v.INNER_ON_VIDEO_MUTE_CHANGE,r,e._session)},onRemoteMicrophoneStateChanged:function(t,n,_){var i,r={userId:n,muted:_,kind:"audio",trackId:"".concat(n,"_RongCloudRTC_0")};e._listener?e._reportAppEventModule.onAudioMuteChange(r,e._session):null===(i=e._session)||void 0===i||i.emit(v.INNER_ON_AUDIO_MUTE_CHANGE,r,e._session)},onReceivedCallRecord:function(e){},onReceivedChangeMediaTypeRequest:function(t,n,_){e._callPlusClient.replyChangeMediaType(n,!0)},onReceivedChangeMediaTypeResult:function(t){var n,_;if(e._mediaType===N.AUDIO_VIDEO&&t.mediaType===s.AUDIO&&t.code===c.SERVER_ALLOW_MEDIA_TYPE){var i={userId:t.userId};e._mediaType=N.AUDIO,null===(n=e._session)||void 0===n||n.__innerEndTranction(s.AUDIO,t.transactionId),e._listener?e._reportAppEventModule.onMediaModify(i,e._mediaType,e._session):null===(_=e._session)||void 0===_||_.emit(v.INNER_ON_MEDIA_MODIFY,i,e._mediaType,e._session,t.transactionId)}},onReceivedCallStartTime:function(t){e._sessionStartTime=t.callStartTime,n=+new Date-t.callStartTime},onReceivedCallFirstFrameTime:function(e,t){},onUserAudioLevelChanged:function(e,t){}})}}),Object.defineProperty(e.prototype,"registerUserInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.error(p.L_CALL_CLIENT_REGISTER_USER_INFO_O,"`RCCallClient.registerUserInfo` has been deprecated.")}}),Object.defineProperty(e.prototype,"startCrossCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return R(this,void 0,void 0,function(){return O(this,function(e){return this._logger.error(p.L_CALL_CLIENT_START_CROSS_CALL_O,"`RCCallClient.startCrossCall` has been deprecated"),[2]})})}}),Object.defineProperty(e.prototype,"__startCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,n){var _=n.targetId,i=n.userIds,r=n.mediaType,o=void 0===r?N.AUDIO:r,a=n.listener,E=n.constraints,c=n.channelId,I=void 0===c?"":c,C=n.extra,L=void 0===C?"":C,T=n.bitrate;return R(this,void 0,void 0,function(){var n,r,c,R,C,S,A,f,g,h,P,D,y,M,m=this;return O(this,function(O){switch(O.label){case 0:return n=this._logger.createTraceId(),this._logger.info(p.L_CALL_CLIENT_CALL_T,JSON.stringify({targetId:_,userIds:i,mediaType:o,listener:Object.keys(a),constraints:E,channelId:I,extra:L,bitrate:T}),n),E&&(r=E.audio,c=E.video,(null==r?void 0:r.micphoneId)&&this._audioConfigBuilder.setDefaultMicrophoneId(r.micphoneId),(null==r?void 0:r.sampleRate)&&this._audioConfigBuilder.setSampleRate(r.sampleRate),(null==c?void 0:c.cameraId)&&this._videoConfigBuilder.setDefaultCameraId(c.cameraId),(null==c?void 0:c.frameRate)&&this._videoConfigBuilder.setFrameRate(c.frameRate),(null==c?void 0:c.resolution)&&this._videoConfigBuilder.setVideoResolution(c.resolution)),T&&(r=T.audio,c=T.video,r&&this._audioConfigBuilder.setBitrate(r,r),c&&this._videoConfigBuilder.setBitrate(c.min,c.max)),R=this._audioConfigBuilder.build(),C=this._videoConfigBuilder.build(),this._callPlusClient.setAudioConfig(R),this._callPlusClient.setVideoConfig(C),this._targetId=_,this._listener=a,this._reportAppEventModule.registerEventListener(a),this._mediaType=o,S=o===N.AUDIO?s.AUDIO:s.AUDIO_VIDEO,A=e?u.SINGLE:u.MULTI,f=e?[_]:i,g=e?t.PRIVATE:t.GROUP,h=e?this._context.getCurrentId():_,P=JSON.stringify({callLibExtra:L,channelId:I,targetId:h,conversationType:g}),[4,this._callPlusClient.startCall(f,A,S,this._callPushConfig,P)];case 1:return D=O.sent(),y=D.code,M=D.callId,y!==l.SUCCESS?(this._logger.error(p.L_CALL_CLIENT_CALL_R,"errorCode: ".concat(b(y)),n),[2,{code:b(y)}]):(this._logger.info(p.L_CALL_CLIENT_CALL_R,"success",n),this._session=new U(M,this._callPlusClient,this._channelId,this._targetId,g,S,this._context,this._logger,{callPushConfig:this._callPushConfig,hangupPushConfig:this._hangupPushConfig}),this._session.on(v.INNER_ON_SELF_HANGUP,function(){m._isSelfHangup=!0}),[2,{code:d.SUCCESS,session:this._session}])}})})}}),Object.defineProperty(e.prototype,"call",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.targetId,n=e.mediaType,_=void 0===n?N.AUDIO:n,i=e.listener,r=e.constraints,o=e.channelId,a=void 0===o?"":o,l=e.extra,E=void 0===l?"":l,s=e.bitrate;return R(this,void 0,void 0,function(){return O(this,function(e){return[2,this.__startCall(!0,{targetId:t,userIds:[],mediaType:_,listener:i,constraints:r,channelId:a,extra:E,bitrate:s})]})})}}),Object.defineProperty(e.prototype,"callInGroup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.targetId,n=e.userIds,_=e.mediaType,i=void 0===_?N.AUDIO:_,r=e.listener,o=e.constraints,a=e.channelId,l=void 0===a?"":a,E=e.extra,s=void 0===E?"":E,c=e.bitrate;return R(this,void 0,void 0,function(){return O(this,function(e){return[2,this.__startCall(!1,{targetId:t,userIds:n,mediaType:i,listener:r,constraints:o,channelId:l,extra:s,bitrate:c})]})})}}),Object.defineProperty(e.prototype,"getJoinedRoomInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return R(this,void 0,void 0,function(){var e,t,_;return O(this,function(i){switch(i.label){case 0:return[4,this._context.getRTCJoinedUserInfo(this._context.getCurrentId())];case 1:return e=i.sent(),t=e.code,_=e.data,t!==n.SUCCESS?(this._logger.error(p.L_CALL_CLIENT_GET_JOINED_ROOM_INFO_E,t),[2,{code:d.QUERY_JOINED_USER_INFO_ERROR}]):[2,{code:d.SUCCESS,data:_}]}})})}}),Object.defineProperty(e.prototype,"setPushConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===e&&(e={}),void 0===t&&(t={}),this._logger.info(p.L_CALL_CLIENT_SET_PUSH_CONFIG_O,JSON.stringify({callPushConfig:e,hangupPushConfig:t})),this._callPushConfig=e,this._hangupPushConfig=t,delete this._callPushConfig.pushContent,delete this._hangupPushConfig.pushContent}}),e}();!function(e){e.ZH="zh",e.EN="en"}(D||(D={})),_.add("callpluswrapper","2.24.0");var M={tag:"CallPlusWrapper",verify:function(e){return"browser"===e.tag},setup:function(e,t,n){var _=e.createLogger("CWrapper","RTC"),o=i(n.logOutputLevel)?r.WARN:n.logOutputLevel;return _.setOutputLevel(o),_.warn(p.L_CALL_PLUS_WRAPPER_INIT_O,"CallPlus Version: ".concat("2.24.0",", Commit: ").concat("5f224140da330e67dad7c51921b244ec674211bc")),new y(e,_,n)}};export{y as RCCallClient,f as RCCallEndReason,d as RCCallErrorCode,D as RCCallLanguage,N as RCCallMediaType,U as RCCallSession,S as RCCallSessionState,T as RCCallUserState,M as installer};