@rongcloud/plugin-call-plus 2.1.7 → 2.1.10-enterprise-lz.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +232 -62
- package/index.esm.js +1 -1
- package/index.js +1 -1
- package/package.json +3 -3
- package/wrapper/index.esm.js +1 -1
- package/wrapper/index.js +1 -1
package/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isNumber as e,isBoolean as t,isUndefined as r,isString as i,EventEmitter as n,ErrorCode as o,RCConnectionStatus as a,isNull as _,getUUID22 as l,getUUID as s,ConversationType as c,MessageDirection as u,ReceivedStatus as L,RTCMode as d,notEmptyArray as E,notEmptyString as C,isObject as T,VersionManage as I,LogL as g}from"@rongcloud/engine";import{RCFrameRate as S,RCResolution as f,RCRTCCode as p,RCKickReason as h,helper as b,RCLocalTrack as R,device as O}from"@rongcloud/plugin-rtc";export{RCFrameRate as RCCallPlusFrameRate,RCResolution as RCCallPlusResolution}from"@rongcloud/plugin-rtc";var A=function(e,t){return A=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},A(e,t)};function N(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}A(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var m=function(){return m=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},m.apply(this,arguments)};function v(e,t,r,i){return new(r||(r=Promise))((function(n,o){function a(e){try{l(i.next(e))}catch(e){o(e)}}function _(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,_)}l((i=i.apply(e,t||[])).next())}))}function y(e,t){var r,i,n,o,a={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:_(0),throw:_(1),return:_(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function _(_){return function(l){return function(_){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,_[0]&&(a=0)),a;)try{if(r=1,i&&(n=2&_[0]?i.return:_[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,_[1])).done)return n;switch(i=0,n&&(_=[2&_[0],n.value]),_[0]){case 0:case 1:n=_;break;case 4:return a.label++,{value:_[1],done:!1};case 5:a.label++,i=_[1],_=[0];continue;case 7:_=a.ops.pop(),a.trys.pop();continue;default:if(!(n=a.trys,(n=n.length>0&&n[n.length-1])||6!==_[0]&&2!==_[0])){a=0;continue}if(3===_[0]&&(!n||_[1]>n[0]&&_[1]<n[3])){a.label=_[1];break}if(6===_[0]&&a.label<n[1]){a.label=n[1],n=_;break}if(n&&a.label<n[2]){a.label=n[2],a.ops.push(_);break}n[2]&&a.ops.pop(),a.trys.pop();continue}_=t.call(e,a)}catch(e){_=[6,e],i=0}finally{r=n=0}if(5&_[0])throw _[1];return{value:_[0]?_[1]:void 0,done:!0}}([_,l])}}}function P(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var i,n,o=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)a.push(i.value)}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return a}function U(e,t,r){if(r||2===arguments.length)for(var i,n=0,o=t.length;n<o;n++)!i&&n in t||(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var M,D={SUCCESS:0,PARAM_ERROR:80001,SESSION_EXIST:80002,NOT_IN_CALL:80003,MEDIATYPE_INVALID:80004,NOT_VIDEO_CALL:80005,RTC_SERVICE_UNAVAILABLE:80006,USER_LIST_INVAILD:80007,CALL_ID_INVALID:80008,TRANSACTION_ID_INVALID:80009,USER_ID_INVALID:80010,SINGLE_CALL_NOT_SUPPORT_MULTI_PERSON:80011,SIGNAL_DISCONNECTED:80012,CAMERA_CLOSED:80100,MICROPHONE_CLOSED:80101,MEDIA_RESOURCE_INVALIED:80102,NOT_INSTALL_RTC_PLUGIN:80103,PLAY_MEDIA_FAILED:80104,VIDEO_VIEW_NOT_SET:80105};!function(e){e.L_INDEX_INSTALL_CALL_PLUS_PLUGIN_O="L-index_install_call_plus_plugin-O",e.L_CALLPLUS_CLIENT_SET_EVENT_LISTENER_O="L-callplus_client_set_event_listener-O",e.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O="L-callplus_client_call_event_listener-O",e.L_CALLPLUS_CLIENT_SET_STATUS_REPORT_LISTENER_O="L-callplus_client_set_status_report_listener-O",e.L_CALLPLUS_CLIENT_CALL_STATUS_REPORT_LISTENER_O="L-callplus_client_call_status_report_listener-O",e.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_T="L-callplus_client_set_video_config-T",e.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R="L-callplus_client_set_video_config-R",e.L_CALLPLUS_VIDEO_CONFIG_SET_FRAME_RATE_O="L-callplus_video_config_set_frame_rate-O",e.L_CALLPLUS_VIDEO_CONFIG_SET_RESOLUTION_O="L-callplus_video_config_set_resolution-O",e.L_CALLPLUS_VIDEO_CONFIG_SET_BITRATE_O="L-callplus_video_config_set_bitrate-O",e.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_T="L-callplus_client_set_audio_config-T",e.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R="L-callplus_client_set_audio_config-R",e.L_CALLPLUS_AUDIO_CONFIG_SET_BITRATE_O="L-callplus_audio_config_set_bitrate-O",e.L_CALLPLUS_AUDIO_CONFIG_SET_SAMPLE_RATE_O="L-callplus_audio_config_set_sample_rate-O",e.L_CALLPLUS_CLIENT_PREVIEW_T="L-callplus_client_preview-T",e.L_CALLPLUS_CLIENT_PREVIEW_R="L-callplus_client_preview-R",e.L_CALLPLUS_CLIENT_START_CALL_T="L-callplus_client_start_call-T",e.L_CALLPLUS_CLIENT_START_CALL_R="L-callplus_client_start_call-R",e.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_T="L-callplus_client_join_multi_call-T",e.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R="L-callplus_client_join_multi_call-R",e.L_CALLPLUS_CLIENT_ACCEPT_T="L-callplus_client_accept-T",e.L_CALLPLUS_CLIENT_ACCEPT_R="L-callplus_client_accept-R",e.L_CALLPLUS_CLIENT_HANGUP_T="L-callplus_client_hangup-T",e.L_CALLPLUS_CLIENT_HANGUP_R="L-callplus_client_hangup-R",e.L_CALLPLUS_CLIENT_INVITE_T="L-callplus_client_invite-T",e.L_CALLPLUS_CLIENT_INVITE_R="L-callplus_client_invite-R",e.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_T="L-callplus_client_request_change_media_type-T",e.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R="L-callplus_client_request_change_media_type-R",e.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_T="L-callplus_client_cancel_change_media_type-T",e.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R="L-callplus_client_cancel_change_media_type-R",e.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_T="L-callplus_client_reply_change_media_type-T",e.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R="L-callplus_client_reply_change_media_type-R",e.L_CALLPLUS_CLIENT_GET_CURRENT_CALL_SESSION_T="L-callplus_client_get_current_call_session-T",e.L_CALLPLUS_CLIENT_GET_CURRENT_CALL_SESSION_R="L-callplus_client_get_current_call_session-R",e.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_T="L-callplus_client_get_available_call_sessions_from_server-T",e.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R="L-callplus_client_get_available_call_sessions_from_server-R",e.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_T="L-callplus_client_get_call_records-T",e.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R="L-callplus_client_get_call_records-R",e.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_T="L-callplus_client_delete_call_records_by_callId-T",e.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R="L-callplus_client_delete_call_records_by_callId-R",e.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_T="L-callplus_client_delete_all_call_records_from_server-T",e.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R="L-callplus_client_delete_all_call_records_from_server-R",e.L_CALLPLUS_CLIENT_START_CAMERA_T="L-callplus_client_start_camera-T",e.L_CALLPLUS_CLIENT_START_CAMERA_R="L-callplus_client_start_camera-R",e.L_CALLPLUS_CLIENT_STOP_CAMERA_T="L-callplus_client_stop_camera-T",e.L_CALLPLUS_CLIENT_STOP_CAMERA_R="L-callplus_client_stop_camera-R",e.L_CALLPLUS_CLIENT_SWITCH_CAMERA_T="L-callplus_client_switch_camera-T",e.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R="L-callplus_client_switch_camera-R",e.L_CALLPLUS_CLIENT_START_MICROPHONE_T="L-callplus_client_start_microphone-T",e.L_CALLPLUS_CLIENT_START_MICROPHONE_R="L-callplus_client_start_microphone-R",e.L_CALLPLUS_CLIENT_STOP_MICROPHONE_T="L-callplus_client_stop_microphone-T",e.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R="L-callplus_client_stop_microphone-R",e.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_T="L-callplus_client_switch_microphone-T",e.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R="L-callplus_client_switch_microphone-R",e.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_T="L-callplus_client_set_video_view-T",e.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R="L-callplus_client_set_video_view-R",e.L_RTC_MODULE_SET_VIDEO_VIEW_O="L-rtc_module_set_video_view-O",e.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_T="L-callplus_client_remove_video_view-T",e.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R="L-callplus_client_remove_video_view-R",e.L_RTC_MODULE_REMOVE_VIDEO_VIEW_O="L-rtc_module_remove_video_view-O",e.L_CALLPLUS_CLIENT_PLAY_MEDIA_T="L-callplus_client_play_media-T",e.L_CALLPLUS_CLIENT_PLAY_MEDIA_R="L-callplus_client_play_media-R",e.L_RTC_MODULE_PLAY_MEDIA_T="L-rtc_module_play_media-T",e.L_RTC_MODULE_PLAY_MEDIA_R="L-rtc_module_play_media-R",e.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_T="L-rtc_module_set_all_remote_audio_enbale-T",e.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R="L-rtc_module_set_all_remote_audio_enable-R",e.L_RTC_MODULE_SUBSCRIBE_T="L-rtc_module_subscribe-T",e.L_RTC_MODULE_SUBSCRIBE_R="L-rtc_module_subscribe-R",e.L_RTC_MODULE_UNSUBSCRIBE_T="L-rtc_module_unsubscribe-T",e.L_RTC_MODULE_UNSUBSCRIBE_R="L-rtc_module_unsubscribe-R",e.L_RTC_MODULE_PUBLISH_T="L-rtc_module_publish-T",e.L_RTC_MODULE_PUBLISH_R="L-rtc_module_publish-R",e.L_RTC_MODULE_UNPUBLISH_T="L-rtc_module_unpublish-T",e.L_RTC_MODULE_UNPUBLISH_R="L-rtc_module_unpublish-R",e.L_RTC_MODULE_DESTROY_ALL_TRACKS_O="L-rtc_module_destroy_all_tracks-O",e.L_RTC_MODULE_SESSION_CONNECT_T="L-rtc_module_session_connect-T",e.L_RTC_MODULE_SESSION_CONNECT_P="L-rtc_module_session_connect-P",e.L_RTC_MODULE_SESSION_CONNECT_R="L-rtc_module_session_connect-R",e.L_RTC_MODULE_SESSION_CLOSE_T="L-rtc_module_session_close-T",e.L_RTC_MODULE_SESSION_CLOSE_P="L-rtc_module_session_close-P",e.L_RTC_MODULE_SESSION_CLOSE_R="L-rtc_module_session_close-R",e.L_RTC_MODULE_CREATE_VIDEO_TRACK_T="L-rtc_module_create_video_track-T",e.L_RTC_MODULE_CREATE_VIDEO_TRACK_R="L-rtc_module_create_video_track-R",e.L_RTC_MODULE_CREATE_AUDIO_TRACK_T="L-rtc_module_create_audio_track-T",e.L_RTC_MODULE_CREATE_AUDIO_TRACK_R="L-rtc_module_create_audio_track-R",e.L_RTC_MODULE_RECEIVE_TRACK_PUBLISH_O="L-rtc_module_receive_track_publish-O",e.L_RTC_MODULE_RECEIVE_TRACK_UNPUBLISH_O="L-rtc_module_receive_track_unpublish-O",e.L_RTC_MODULE_RECEIVE_TRACK_ENABLE_CHANGE_O="L-rtc_module_receive_track_enable_change-O",e.L_RTC_MODULE_RECEIVE_KICK_OFF_O="L-rtc_module_receive_kick_off-O",e.L_RTC_MODULE_RECEIVE_PEERCONNECTION_EXCEPT_CLOSE_O="L-rtc_module_receive_peerconnection_except_close-O",e.L_RTC_MODULE_CHANGE_MEDIA_TYPE_T="L-rtc_module_change_media_type-T",e.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R="L-rtc_module_change_media_type-R",e.L_RTC_MODULE_JOIN_RTC_ROOM_T="L-rtc_module_join_rtc_room-T",e.L_RTC_MODULE_JOIN_RTC_ROOM_R="L-rtc_module_join_rtc_room-R",e.L_RTC_MODULE_QUIT_RTC_ROOM_T="L-rtc_module_quit_rtc_room-T",e.L_RTC_MODULE_QUIT_RTC_ROOM_R="L-rtc_module_quit_rtc_room-R",e.L_RTC_MODULE_CREATE_CALL_MEDIA_TRACKS_P="L-rtc_module_create_call_media_tracks-P",e.L_SIGNAL_TRANSPORTER_SINGLE_CALL_T="L-signal_transporter_single_call-T",e.L_SIGNAL_TRANSPORTER_GROUP_CALL_T="L-signal_transporter_group_call-T",e.L_SIGNAL_TRANSPORTER_INVITE_T="L-signal_transporter_invite-T",e.L_SIGNAL_TRANSPORTER_RING_T="L-signal_transporter_ring-T",e.L_SIGNAL_TRANSPORTER_ACCEPT_T="L-signal_transporter_accept-T",e.L_SIGNAL_TRANSPORTER_ACCEPT_R="L-signal_transporter_accept-R",e.L_SIGNAL_TRANSPORTER_JOIN_CALL_T="L-signal_transporter_join_call-T",e.L_SIGNAL_TRANSPORTER_HANGUP_T="L-signal_transporter_hangup-T",e.L_SIGNAL_TRANSPORTER_CALL_STATUS_UP_T="L-signal_transporter_call_status_up-T",e.L_SIGNAL_TRANSPORTER_CALL_EVENT_UP_T="L-signal_transporter_call_event_up-T",e.L_SIGNAL_TRANSPORTER_CALL_DIALOG_UP_T="L-signal_transporter_call_dialog_up-T",e.L_SIGNAL_TRANSPORTER_DELETE_CALL_RECORD_T="L-signal_transporter_delete_call_record-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_RECORD_T="L-signal_transporter_get_call_record-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_SERVER_TIME_T="L-signal_transporter_get_call_server_time-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_TIME_INFO_T="L-signal_transporter_get_call_time_info-T",e.L_SIGNAL_TRANSPORTER_GET_AVAILABLE_CALL_LIST_T="L-signal_transporter_get_available_call_list-T",e.L_SIGNAL_TRANSPORTER_CLEAR_CALL_RECORD_T="L-signal_transporter_clear_call_record-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_INFO_BY_CALLID_T="L-signal_transporter_get_call_info_by_callId-T",e.L_SIGNAL_TRANSPORTER_USER_SYSTEM_STATE_UP_T="L-signal_transporter_user_system_state_up-T",e.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_SIGNAL_DATA_O="L-signal_transporter_receive_call_signal_data-O",e.L_SIGNAL_TRANSPORTER_IM_STATE_CHANGE_O="L-signal_transporter_im_state_change-O",e.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O="L-signal_transporter_receive_invite-O",e.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O="L-signal_transporter_receive_call_status-O",e.L_SIGNAL_TRANSPORTER_RECEIVE_MISS_MESSAGE_O="L-signal_transporter_receive_miss_message-O",e.L_CALL_ENGINE_UPDATE_USERS_STATE_O="L-call_engine_update_users_state-O",e.L_CALL_ENGINE_IM_STATE_CHANGE_O="L-call_engine_im_state_change-O",e.L_CALL_ENGINE_CALL_TIMEOUT_O="L-call_engine_call_timeout-O",e.L_CALL_ENGINE_START_CALL_TIMER_O="L-call_engine_start_call_timer-O",e.L_CALL_ENGINE_STOP_CALL_TIMER_O="L-call_engine_stop_call_timer-O",e.L_CALL_ENGINE_UP_ON_PHONE_END_T="L-call_engine_up_on_phone_end-T",e.L_CALL_ENGINE_UP_ON_PHONE_END_R="L-call_engine_up_on_phone_end-R",e.L_CALL_ENGINE_RECEIVE_FIRST_FRAME_TIME_O="L-call_engine_receive_first_frame_time-O",e.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O="L-call_engine_receive_mediatype_change-O",e.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O="L-call_engine_receive_close_session-O",e.L_CALL_ENGINE_RECEIVE_CALL_RECORD_O="L-call_engine_receive_call_record-O",e.L_CALL_ENGINE_RECEIVE_COMPLEMENTARY_DATA_O="L-call_engine_receive_complementary_data-O",e.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_T="L-call_engine_create_session_by_server-T",e.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R="L-call_engine_create_session_by_server-R",e.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_T="L-call_engine_up_first_frame_time-T",e.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_R="L-call_engine_up_first_frame_time-R",e.L_TIME_CORRECT_START_O="L-time_correct_start-O",e.L_TIME_CORRECT_STOP_O="L-time_correct_stop-O",e.L_TIME_CORRECT_RESTART_O="L-time_correct_restart-O",e.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_T="L-time_correct_get_call_client_time_by_server-T",e.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_P="L-time_correct_get_call_client_time_by_server-P",e.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R="L-time_correct_get_call_client_time_by_server-R",e.L_TIME_CORRECT_CALC_CLIENT_START_TIME_T="L-time_correct_calc_client_start_time-T",e.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R="L-time_correct_calc_client_start_time-R",e.L_TIME_CORRECT_SET_DELTA_TIME_O="L-time_correct_set_delta_time-O",e.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_T="L-time_correct_loop_correct_client_time-T",e.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R="L-time_correct_loop_correct_client_time-R",e.L_INNER_SESSION_UPDATE_USER_STATE_O="L-inner_session_update_user_state-O",e.L_INNER_SESSION_SET_USER_DEVICE_ENABLE_O="L-inner_session_set_user_device_enable-O",e.L_CALLPLUS_SESSION_GET_CREATE_TIME_T="L-callplus_session_get_create_time-T",e.L_CALLPLUS_SESSION_GET_CREATE_TIME_R="L-callplus_session_get_create_time-R",e.L_CALLPLUS_SESSION_GET_DURATION_T="L-callplus_session_get_duration-T",e.L_CALLPLUS_SESSION_GET_DURATION_R="L-callplus_session_get_duration-R",e.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O="L-callplus_set_android_push_config-O",e.L_ABNORMAL_ADD_CALL_ID_E="L-ABNORMAL_ADD_CALL_ID-E",e.L_ABNORMAL_REMOVE_CALL_IDS_E="L-ABNORMAL_REMOVE_CALL_IDS-E",e.L_ABNORMAL_GET_CALL_IDS_E="L-ABNORMAL_GET_CALL_IDS-E",e.L_CALLPLUS_CLIENT_SET_AUDIO_OUTPUT_DEVICE_ID_O="L-set_audio_output_device_id-O"}(M||(M={}));var w,j,G,V,H,k,B=function(){function e(e,t,r){Object.defineProperty(this,"_session",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_startTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_duration",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:""}),this._callId=this._session.getCallId()}return Object.defineProperty(e.prototype,"getCallId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callId}}),Object.defineProperty(e.prototype,"getState",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._session.getSessionState()}}),Object.defineProperty(e.prototype,"getCallType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._session.getCallType()}}),Object.defineProperty(e.prototype,"getMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._session.getMediaType()}}),Object.defineProperty(e.prototype,"getUserList",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._session.getUserList().map((function(e){return{userId:e.userId,state:e.userState,cameraEnable:e.cameraEnable,microphoneEnable:e.microphoneEnable}}))}}),Object.defineProperty(e.prototype,"getCreatorUserId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._session.getStartCallerId()}}),Object.defineProperty(e.prototype,"getInviterUserId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._session.getCallerId()}}),Object.defineProperty(e.prototype,"getCreateTimestamp",{enumerable:!1,configurable:!0,writable:!0,value:function(){return v(this,void 0,void 0,(function(){var e,t,r,i;return y(this,(function(n){switch(n.label){case 0:return e=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_SESSION_GET_CREATE_TIME_T,"",e),this._startTime?[2,{code:D.SUCCESS,startTime:this._startTime}]:[4,this._callEngine.getCallStaringTime({callId:this._callId},e)];case 1:return t=n.sent(),r=t.code,i=t.clientStartTime,r!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_SESSION_GET_CREATE_TIME_R,"errCode: ".concat(r),e),[2,{code:r}]):(this._logger.info(M.L_CALLPLUS_SESSION_GET_CREATE_TIME_R,"success",e),this._startTime=i,[2,{code:D.SUCCESS,startTime:this._startTime}])}}))}))}}),Object.defineProperty(e.prototype,"getDuration",{enumerable:!1,configurable:!0,writable:!0,value:function(){return v(this,void 0,void 0,(function(){var e,t,r,i;return y(this,(function(n){switch(n.label){case 0:return e=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_SESSION_GET_DURATION_T,"",e),this._duration?(this._logger.info(M.L_CALLPLUS_SESSION_GET_DURATION_R,"code: ".concat(D.SUCCESS,", duration: ").concat(this._duration),e),[2,{code:D.SUCCESS,duration:this._duration}]):[4,this._callEngine.getCallTimeInfo(this._callId,e)];case 1:return t=n.sent(),r=t.code,i=t.data,r!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_SESSION_GET_DURATION_R,"code: ".concat(r),e),[2,{code:r}]):(this._logger.info(M.L_CALLPLUS_SESSION_GET_DURATION_R,"code: ".concat(D.SUCCESS,", duration: ").concat(i.duration),e),this._duration=i.duration,[2,{code:D.SUCCESS,duration:this._duration}])}}))}))}}),e}();!function(e){e[e.SINGLE=0]="SINGLE",e[e.MULTI=1]="MULTI"}(w||(w={})),function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",e[e.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ONPHONE=301]="ONPHONE",e[e.ENDED=1e3]="ENDED",e[e.NO_ANSWER=1001]="NO_ANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELLED=1003]="CANCELLED",e[e.DECLINED=1004]="DECLINED",e[e.ERROR=2e3]="ERROR"}(j||(j={})),function(e){e[e.AUDIO=0]="AUDIO",e[e.AUDIO_VIDEO=1]="AUDIO_VIDEO",e[e.VIDEO=2]="VIDEO"}(G||(G={})),function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",e[e.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ENDED=1e3]="ENDED",e[e.NOANSWER=1001]="NOANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELED=1003]="CANCELED",e[e.DECLINED=1004]="DECLINED",e[e.ERROR=2e3]="ERROR"}(V||(V={})),function(e){e[e.CANCEL_CHANGE_MEDIA_TYPE=0]="CANCEL_CHANGE_MEDIA_TYPE",e[e.REFUSE_CHANGE_MEDIA_TYPE=1]="REFUSE_CHANGE_MEDIA_TYPE",e[e.SERVER_ALLOW_MEDIA_TYPE=2]="SERVER_ALLOW_MEDIA_TYPE",e[e.CHANGE_MEDIA_TYPE_TIMEOUT=3]="CHANGE_MEDIA_TYPE_TIMEOUT"}(H||(H={})),function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",e[e.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ON_PHONE=301]="ON_PHONE",e[e.ON_PHONE_END=302]="ON_PHONE_END",e[e.ON_DEVICE_DISABLE=303]="ON_DEVICE_DISABLE",e[e.ON_DEVICE_ENABLE=304]="ON_DEVICE_ENABLE",e[e.ABNORMAL_END=999]="ABNORMAL_END",e[e.ENDED=1e3]="ENDED",e[e.NO_ANSWER=1001]="NO_ANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELLED=1003]="CANCELLED",e[e.DECLINED=1004]="DECLINED",e[e.OTHER_CLIENT_CALLING=1010]="OTHER_CLIENT_CALLING",e[e.OTHER_CLIENT_ACCEPT=1011]="OTHER_CLIENT_ACCEPT",e[e.JOIN_ROOM_ERR=1105]="JOIN_ROOM_ERR",e[e.PUBLISH_ERR=1106]="PUBLISH_ERR",e[e.SUBSCRIBE_ERR=1107]="SUBSCRIBE_ERR",e[e.ACCEPT_CARRIER=1108]="ACCEPT_CARRIER",e[e.KICKED_BY_SERVER=1109]="KICKED_BY_SERVER",e[e.CONNECTION_ERR=1110]="CONNECTION_ERR",e[e.LOGOUT=1111]="LOGOUT",e[e.OTHER_CLIENT_LOGIN=1112]="OTHER_CLIENT_LOGIN",e[e.OTHER_CLIENT_JOINED=1113]="OTHER_CLIENT_JOINED",e[e.OTHER_CLIENT_IN_ROOM=1114]="OTHER_CLIENT_IN_ROOM",e[e.OTHER_CLIENT_HANGUP=1151]="OTHER_CLIENT_HANGUP",e[e.REMOTE_JOIN_RTC_ERROR=1205]="REMOTE_JOIN_RTC_ERROR",e[e.REMOTE_PUBLISH_ERROR=1206]="REMOTE_PUBLISH_ERROR",e[e.REMOTE_SUBSCRIBE_ERROR=1207]="REMOTE_SUBSCRIBE_ERROR",e[e.REMOTE_KICKED_BY_SERVER=1209]="REMOTE_KICKED_BY_SERVER",e[e.REMOTE_CONNECTION_ERROR=1210]="REMOTE_CONNECTION_ERROR",e[e.REMOTE_LOGOUT=1211]="REMOTE_LOGOUT",e[e.REMOTE_OTHER_CLIENT_LOGIN=1212]="REMOTE_OTHER_CLIENT_LOGIN",e[e.REMOTE_OTHER_JOINED_RTC=1213]="REMOTE_OTHER_JOINED_RTC",e[e.REMOTE_OTHER_CLIENT_IN_RTC=1214]="REMOTE_OTHER_CLIENT_IN_RTC"}(k||(k={}));var x,F=function(){function t(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_audioConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}})}return Object.defineProperty(t.prototype,"setDefaultMicrophoneId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._audioConfig.microphoneId=e,this}}),Object.defineProperty(t.prototype,"setBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return!e(t)||!e(r)||r<=0||t<=0||r<t?(this._logger.error(M.L_CALLPLUS_AUDIO_CONFIG_SET_BITRATE_O,"params error -> max: ".concat(r,",min: ").concat(t,", max and min is a number > 0, max should > min")),this):(this._audioConfig.minBitrate=t,this._audioConfig.maxBitrate=r,this)}}),Object.defineProperty(t.prototype,"setSampleRate",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e(t)?(this._audioConfig.sampleRate=t,this):(this._logger.error(M.L_CALLPLUS_AUDIO_CONFIG_SET_SAMPLE_RATE_O,"params error -> sampleRate: ".concat(t)),this)}}),Object.defineProperty(t.prototype,"build",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._audioConfig}}),t}(),Y=function(){function t(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:f.W640_H480,frameRate:S.FPS_15}})}return Object.defineProperty(t.prototype,"setFrameRate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return S[e]?(this._videoConfig.frameRate=e,this):(this._logger.error(M.L_CALLPLUS_VIDEO_CONFIG_SET_FRAME_RATE_O,"params error -> fps: ".concat(e)),this)}}),Object.defineProperty(t.prototype,"setVideoResolution",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return f[e]?(this._videoConfig.resolution=e,this):(this._logger.error(M.L_CALLPLUS_VIDEO_CONFIG_SET_RESOLUTION_O,"params error -> resolution: ".concat(e)),this)}}),Object.defineProperty(t.prototype,"setDefaultCameraId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._videoConfig.cameraId=e,this}}),Object.defineProperty(t.prototype,"setBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return!e(t)||!e(r)||r<=0||t<=0||r<t?(this._logger.error(M.L_CALLPLUS_VIDEO_CONFIG_SET_BITRATE_O,"params error -> max: ".concat(r,",min: ").concat(t,", max and min is a number > 0, max should > min")),this):(this._videoConfig.minBitrate=t,this._videoConfig.maxBitrate=r,this)}}),Object.defineProperty(t.prototype,"build",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._videoConfig}}),t}(),J=function(e){return{callId:e.callId,callType:e.callType,callDirection:e.callDir,mediaType:e.mediaType,callerUserId:e.callingUserId,callUserIds:e.callUserIds,sessionState:e.callStatus,userState:e.sessionStatus,startTimestamp:e.startTime,endTimestamp:e.endTime,duration:e.duration,syncTimestamp:e.syncTime,systemState:e.sysStatus,createTimestamp:e.crtTime}},W=function(e){var t=e.voipCallInfo;return!!t&&1===JSON.parse(t).strategy},K=function(t,r){return!t&&0!==t||e(t)&&!(t<=0)?!r&&0!==r||e(r)&&!(r<=0)?t&&r&&r<t?{code:D.PARAM_ERROR,errorMsg:"params error -> maxBitrate: ".concat(r,", minBitrate: ").concat(t,", maxBitrate should > minBitrate")}:{code:D.SUCCESS}:{code:D.PARAM_ERROR,errorMsg:"params error -> maxBitrate: a number of > 0, value: ".concat(r)}:{code:D.PARAM_ERROR,errorMsg:"params error -> minBitrate: a number of > 0, value: ".concat(t)}},Q=function(e){var t=[];for(var r in e){var i=e[r],n=i.videoView,o=i.isTiny;t.push({userId:r,videoView:n.nodeName,isTiny:o})}return t},q=function(e,t,r){void 0===t&&(t={}),void 0===r&&(r={});var i=t.threadId,n=t.apnsCollapseId,o=t.richMediaUri,a=r.channelIdMi,_=r.channelIdHW,l=r.channelIdOPPO,s=r.typeVivo,c=r.fcmChannelId,u=r.fcmCollapseKey,L=r.fcmImageUrl,d=r.importanceHW,E=r.categoryHW,C=r.imageUrlHW,T=r.categoryVivo,I=r.importanceHonor,g=r.imageUrlHonor,S={};i&&(S["thread-id"]=i),S["apns-collapse-id"]=n||e,o&&(S.richMediaUri=o);var f={};_&&(f.channelId=_),C&&(f.image=C),E&&(f.category=E),f.importance=d||"NORMAL";var p,h,b,R,O=[{HW:f},{APNS:S}];return(u||L||c)&&(p={},u&&(p.collapse_key=u),L&&(p.imageUrl=L),c&&(p.channelId=c),O[0].FCM=p),a&&(O[0].MI={channelId:a}),l&&((h={}).channelId=l,O[0].OPPO=h),(s||T)&&(b={},s&&(b.classification=s),T&&(b.category=T),O[0].VIVO=b),(I||g)&&(R={},I&&(R.importance=I),g&&(R.image=g),O[0].HONOR=R),JSON.stringify(O)},X=function(e,r){var i=e.pushTitle,n=void 0===i?"":i,o=e.iOSConfig,a=e.androidConfig,_=e.disablePushTitle,l=e.templateId,s={pushConfigs:q(r,o,a)};return t(_)&&(s.disableTitle=_),n&&(s.title=n),l&&(s.templateId=l),JSON.stringify(s)},z=function(e){var n=["pushTitle","iOSConfig","androidConfig","disablePushTitle","templateId"],o=Object.keys(e).every((function(e){return n.includes(e)}));if(!o)return{code:D.PARAM_ERROR,errorMsg:"right key: ".concat(n.join(","))};for(var a=0;a<n.length;a++){var _=n[a];if("disablePushTitle"===_){if(!r(e[_])&&!t(e[_]))return{code:D.PARAM_ERROR,errorMsg:"".concat(_," type is boolean")}}else if(("pushTitle"===_||"templateId"===_)&&e[_]&&!i(e[_]))return{code:D.PARAM_ERROR,errorMsg:"".concat(_," type is string")}}var l=e.iOSConfig,s=e.androidConfig,c=Z(l||{});if(c.code!==D.SUCCESS)return c;var u=$(s||{});return u.code!==D.SUCCESS?u:{code:D.SUCCESS}},Z=function(e){var t=e||{},r=t.threadId,n=t.richMediaUri;return r&&!i(r)?{code:D.PARAM_ERROR,errorMsg:"iOSConfig.threadId type is string"}:n&&!i(n)?{code:D.PARAM_ERROR,errorMsg:"iOSConfig.richMediaUri type is string"}:{code:D.SUCCESS}},$=function(e){var t=["channelIdMi","channelIdHW","categoryHW","importanceHW","imageUrlHW","channelIdOPPO","typeVivo","categoryVivo","fcmChannelId","fcmCollapseKey","fcmImageUrl","importanceHonor","imageUrlHonor"],r=Object.keys(e).every((function(e){return t.includes(e)}));if(!r)return{code:D.PARAM_ERROR,errorMsg:"right key: ".concat(t.join(","))};for(var n=0;n<t.length;n++){var o=t[n];if("importanceHW"===o||"importanceHonor"===o){if(e[o]&&"LOW"!==e[o]&&"NORMAL"!==e[o])return{code:D.PARAM_ERROR,errorMsg:"androidConfig.".concat(o," value is NORMAL|LOW")}}else if(e[o]&&!i(e[o]))return{code:D.PARAM_ERROR,errorMsg:"androidConfig.".concat(o," type is string")}}return{code:D.SUCCESS}},ee=function(e,t){void 0===t&&(t="utf-8");return"utf-16"===t?te(e):re(e)},te=function(e){for(var t=0,r=0,i=e.length;r<i;r++)t+=e.charCodeAt(r)<=65535?2:4;return t},re=function(e){for(var t,r=0,i=0,n=e.length;i<n;i++)r+=(t=e.charCodeAt(i))<127?1:t<=2047?2:t<=65535?3:4;return r};!function(e){e.L_QS_START_CALL_S="Call-start-S",e.L_QS_ACCEPT_CALL_S="Call-accept-S",e.L_QS_HANGUP_CALL_S="Call-hangup-S",e.L_QS_RECEIVE_CALL_S="Call-recv-S",e.L_QS_ABNORMAL_HANGUP_S="Call-interrupt-S"}(x||(x={}));var ie,ne,oe,ae,_e=function(){function e(e,t){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t})}return Object.defineProperty(e.prototype,"reportStatisticsData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,n,o,a){var _=+new Date,l=i?{mediaType:i.getMediaType(),callType:i.getCallType(),callId:i.getCallId()}:a,s={cr:"unknown",net:"unknown",cod:t,mtp:l.mediaType,ctp:l.callType,cid:l.callId,time:_,uid:this._context.getCurrentId()};n&&Object.assign(s,{ccid:n});var c=null;switch(e){case x.L_QS_RECEIVE_CALL_S:c=m(m({},s),{rf:o});break;case x.L_QS_ABNORMAL_HANGUP_S:c=m({},s);break;default:c=m(m({},s),{dur:_-r})}this._logger.__statistics(e,JSON.stringify(c))}}),e}();!function(e){e.REQUEST="request",e.ACCEPT="accept",e.REFUSE="refuse",e.CANCEL="cancel",e.NOTICE="notice",e.TIMEOUT="timeout"}(ie||(ie={})),function(e){e[e.SWITCH_MEDIA_TYPE=1]="SWITCH_MEDIA_TYPE"}(ne||(ne={})),function(e){e[e.NORMAL=0]="NORMAL",e[e.SECRET=1]="SECRET"}(oe||(oe={})),function(e){e.INVITER="inviter",e.INVITEE="invitee"}(ae||(ae={}));var le,se=function(e){function t(t,r,i,n,o,a,_,l){var s=e.call(this)||this;return Object.defineProperty(s,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(s,"_state",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(s,"_callType",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(s,"_mediaType",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(s,"_startCallerId",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(s,"_callerId",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(s,"_callUsers",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(s,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:l}),Object.defineProperty(s,"_reqMediaType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(s,"_inviterTimerId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(s,"_inviteeTimerId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(s,"_oldDialogData",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(s,"isLocalClientHangup",{enumerable:!0,configurable:!0,writable:!0,value:!1}),s}return N(t,e),Object.defineProperty(t.prototype,"getCallId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callId}}),Object.defineProperty(t.prototype,"getSessionState",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._state}}),Object.defineProperty(t.prototype,"getCallType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callType}}),Object.defineProperty(t.prototype,"getMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._mediaType}}),Object.defineProperty(t.prototype,"getStartCallerId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._startCallerId}}),Object.defineProperty(t.prototype,"getCallerId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callerId}}),Object.defineProperty(t.prototype,"getUserList",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callUsers}}),Object.defineProperty(t.prototype,"getReqMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._reqMediaType}}),Object.defineProperty(t.prototype,"getInviterTimerId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._inviterTimerId}}),Object.defineProperty(t.prototype,"getInviteeTimerId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._inviteeTimerId}}),Object.defineProperty(t.prototype,"getAllTimerIds",{enumerable:!1,configurable:!0,writable:!0,value:function(){return[this._inviterTimerId,this._inviteeTimerId]}}),Object.defineProperty(t.prototype,"setUserDeviceEnable",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){this._logger.info(M.L_INNER_SESSION_SET_USER_DEVICE_ENABLE_O,"userId: ".concat(e,", mediaType: ").concat(t,", enable: ").concat(r),i);var n=this._callUsers.find((function(t){return e===t.userId}));t===G.AUDIO?n.microphoneEnable=r:n.cameraEnable=r}}),Object.defineProperty(t.prototype,"updateUserList",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this,i=[];return e.forEach((function(e){var t=e.userState,n=e.stateTime,o=e.systemState,a=e.userId,_=r._callUsers.findIndex((function(e){return e.userId===a}));if(_<0)return r._callUsers.push(e),void i.push(e);var l,s,c,u,L=r._callUsers[_],d=L.stateTime,E=L.systemState,C=L.userState,T=(l=E,s=o,c=!1,u=[k.INVITED,k.RINGING,k.BUSYLINE_RINGING,k.BUSYLINE_WAIT,k.CONNECTING,k.ONCALL],l===k.ONCALL&&u.includes(s)&&(c=!0),c),I=function(e,t){var r=!1,i=[j.INVITED,j.RINGING,j.BUSYLINE_RINGING,j.BUSYLINE_WAIT,j.CONNECTING,j.ONCALL];return e===j.ONCALL&&i.includes(t)&&(r=!0),r}(C,t),g=o===k.ON_PHONE_END&&E!==k.ON_PHONE&&t!==j.IDLE;n&&d&&n<d||T&&I||(r._callUsers[_]=e,!g&&i.push(e))})),i}}),Object.defineProperty(t.prototype,"setOldDialogData",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._oldDialogData=e}}),Object.defineProperty(t.prototype,"updateSessionState",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._state=e}}),Object.defineProperty(t.prototype,"updateCallType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._callType=e}}),Object.defineProperty(t.prototype,"updateMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._mediaType=e}}),Object.defineProperty(t.prototype,"updateReqMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._reqMediaType=e}}),Object.defineProperty(t.prototype,"updateTimerId",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e===ae.INVITER?this._inviterTimerId=t:this._inviteeTimerId=t}}),Object.defineProperty(t.prototype,"getOldDialogData",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._oldDialogData}}),Object.defineProperty(t.prototype,"setIsLocalClientHangup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.isLocalClientHangup=e}}),Object.defineProperty(t.prototype,"getIsLocalClientHangup",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.isLocalClientHangup}}),t}(n);!function(e){e.START_SINGLE_CALL="startSingleCall",e.START_GROUP_CALL="startGroupCall",e.INVITE_CALL="inviteCall",e.PUB_INVITE_CALL="pubInviteCall",e.RINGING_CALL="ringCall",e.ACCEPT_CALL="acceptCall",e.JOIN_CALL="joinCall",e.HANGUP_CALL="hangupCall",e.STATUS_UP_CALL="statusUpCall",e.STATUS_DOWN_CALL="statusDownCall",e.EVENT_UP_CALL="eventUpCall",e.EVENT_DOWN_CALL="eventDownCall",e.DIALOG_UP_CALL="dialogUpCall",e.DIALOG_DOWN_CALL="dialogDownCall",e.GET_CALL_USER_SESSION_LIST="getCallUSerSessionList",e.SYNC_CALL_LOG="syncCallLog",e.PUB_CALL_LOG="pubCallLog",e.DEL_CALL_LOG="deleteCallLog",e.QRY_CALL_STATE="queryUserHasCall",e.QRY_SRV_TIMESTAMP="getCallSrvTimeStamp",e.GET_CALL_STATE_LIST="getUserCallStateList",e.CLEAR_CALL_LOG="cleanCallLog",e.GET_CALL_SESSION="getCallSession",e.GET_CALL_TIME_INFO="getCallTimeInfo",e.END_ABNORMAL_CALL="endUserAbnormalCalls",e.SYS_STATUS_UP="sysStatusUp",e.UP_CALL_LOG_READED="upCallLogReaded",e.PUB_CALL_LOG_READED="pubCallLogReaded",e.PUB_NACK_SEQ_ID="pubNACKSeqId",e.GET_USER_CALL_SESSION_ID_LIST="getUserCallSessionIdList"}(le||(le={}));var ce,ue,Le,de=function(e,t){return setTimeout(e,t)},Ee=[o.RC_NET_CHANNEL_INVALID,o.RC_NET_UNAVAILABLE,o.RC_MSG_RESP_TIMEOUT,p.SIGNAL_DISCONNECTED,p.REQUEST_FAILED],Ce=function(e){var t=e.asyncFn,r=e.fnArgs,i=e.currentRetryTime,n=void 0===i?Date.now():i,o=e.maxDuration,a=void 0===o?6e4:o,_=e.intervals,l=void 0===_?[2e3,4e3,8e3,16e3,32e3,64e3]:_,s=e.index,c=void 0===s?0:s,u=e.onError;return v(void 0,void 0,void 0,(function(){var e;return y(this,(function(i){switch(i.label){case 0:return[4,t.apply(void 0,U([],P(r),!1))];case 1:return e=i.sent(),2e3,e.code===D.SUCCESS||!Ee.includes(e.code)||Date.now()+2e3-n>a?[3,3]:(u&&u(e.code),[4,(o=2e3,new Promise((function(e){setTimeout(e,o)})))]);case 2:return i.sent(),[2,Ce({asyncFn:t,fnArgs:r,currentRetryTime:n,maxDuration:a,intervals:l,index:c,onError:u})];case 3:return[2,e]}var o}))}))};!function(e){e.onBeforePublish="onBeforePublish",e.onPublishRes="onPublishRes",e.onPubInviteCall="onPubInviteCall",e.onPubInviteCallPullKv="onPubInviteCallPullKv",e.onPubInviteCallMiss="onPubInviteCallMiss"}(ce||(ce={})),function(e){e.NOT_CURRENT_DEVICEID="not current device id",e.SECRET_CALL="secret call",e.NOT_INVITEE="not an invitee"}(ue||(ue={})),function(e){e.PUB_INVITE="pubinvitecall",e.PULL_KV_INVITE="pullkv_invitecall",e.PUSH="system_pubsh"}(Le||(Le={}));var Te,Ie,ge=131072,Se="RC:CallPlusMiss",fe=function(e){function t(t,r,i,n,o,a){var _=e.call(this)||this;return Object.defineProperty(_,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(_,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(_,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(_,"_timeCorrectioner",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(_,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(_,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(_,"_listener",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_needRetryActions",{enumerable:!0,configurable:!0,writable:!0,value:[le.START_SINGLE_CALL,le.START_GROUP_CALL,le.ACCEPT_CALL,le.JOIN_CALL,le.EVENT_UP_CALL]}),Object.defineProperty(_,"_sessionId",{enumerable:!0,configurable:!0,writable:!0,value:""}),_._context.onCallInfo=_._onRecvCallSignal.bind(_),_._context.onconnectionstatechange=_._onIMConnectionStateChange.bind(_),_._context.onmessage=_._onMessage.bind(_),_._sessionId=l(),_}return N(t,e),Object.defineProperty(t.prototype,"_onMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if([Se].includes(e.messageType)){var t=e.content,r=t.callId,i=t.mediaType,n=t.startTime,o=t.callSessionUsers,a=e.targetId,_=e.senderUserId,l=this._context.getCurrentId();if(!localStorage.getItem("missMessageMap-".concat(l,"-").concat(r))){var s={callId:r,callerUserId:_,targetId:a,mediaType:i,firstFrameTime:0,callStartTime:n-this._timeCorrectioner.getLocalDelayTime(),callEndTime:0,hangupReason:o.filter((function(e){return e.userId===l}))[0].sessionStatus};this._logger.info(M.L_SIGNAL_TRANSPORTER_RECEIVE_MISS_MESSAGE_O,"receive miss message: ".concat(JSON.stringify(e)));var c=Object.assign(e,{content:JSON.stringify(s)});this._reportAppEventModule.onReceivedCallPlusSummaryMessage(c),localStorage.setItem("missMessageMap-".concat(l,"-").concat(r),r)}return!0}return!1}}),Object.defineProperty(t.prototype,"getSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._sessionId}}),Object.defineProperty(t.prototype,"registerListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._listener=e}}),Object.defineProperty(t.prototype,"startCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i,n,o,a,_,l,s,c,u,L;return y(this,(function(d){return r=e.clientCallId,i=e.callType,n=e.toUsers,o=e.mediaType,a=e.secretChat,_=e.targetType,l=e.targetId,s=e.nickName,c=e.oldRoomId,u=e.pushExt,L=e.extra,i===w.SINGLE?[2,this.startSingleCall({clientCallId:r,toUserId:n[0].userId,mediaType:o,secretChat:a,targetType:_,targetId:l,oldRoomId:c,toOrgId:n[0].orgId||"",pushExt:u,extra:L},t)]:[2,this.startGroupCall({clientCallId:r,toUsers:n,mediaType:o,targetType:_,targetId:l,nickName:s,oldRoomId:c,pushExt:u,extra:L},t)]}))}))}}),Object.defineProperty(t.prototype,"startSingleCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._logger.info(M.L_SIGNAL_TRANSPORTER_SINGLE_CALL_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(this._context.getCurrentId(),le.START_SINGLE_CALL,e)]}))}))}}),Object.defineProperty(t.prototype,"startGroupCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._logger.info(M.L_SIGNAL_TRANSPORTER_GROUP_CALL_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(this._context.getCurrentId(),le.START_GROUP_CALL,e)]}))}))}}),Object.defineProperty(t.prototype,"inviteCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._logger.info(M.L_SIGNAL_TRANSPORTER_INVITE_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.callId,le.INVITE_CALL,e)]}))}))}}),Object.defineProperty(t.prototype,"ringingCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._logger.info(M.L_SIGNAL_TRANSPORTER_RING_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.callId,le.RINGING_CALL,e)]}))}))}}),Object.defineProperty(t.prototype,"acceptCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._logger.info(M.L_SIGNAL_TRANSPORTER_ACCEPT_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.callId,le.ACCEPT_CALL,e)]}))}))}}),Object.defineProperty(t.prototype,"joinCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._logger.info(M.L_SIGNAL_TRANSPORTER_JOIN_CALL_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.callId,le.JOIN_CALL,e)]}))}))}}),Object.defineProperty(t.prototype,"hangupCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r;return y(this,(function(i){switch(i.label){case 0:return this._logger.info(M.L_SIGNAL_TRANSPORTER_HANGUP_T,"params: ".concat(JSON.stringify(e)),t),[4,this._sendCallSignal(e.callId,le.HANGUP_CALL,e)];case 1:return(r=i.sent().code)===D.NOT_IN_CALL?[2,{code:D.SUCCESS}]:[2,{code:r}]}}))}))}}),Object.defineProperty(t.prototype,"statusUpCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._logger.info(M.L_SIGNAL_TRANSPORTER_CALL_STATUS_UP_T,"call status up params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.callId,le.STATUS_UP_CALL,e)]}))}))}}),Object.defineProperty(t.prototype,"eventUpCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._logger.info(M.L_SIGNAL_TRANSPORTER_CALL_EVENT_UP_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.callId,le.EVENT_UP_CALL,e)]}))}))}}),Object.defineProperty(t.prototype,"dialogUpCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._logger.info(M.L_SIGNAL_TRANSPORTER_CALL_DIALOG_UP_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.callId,le.DIALOG_UP_CALL,e)]}))}))}}),Object.defineProperty(t.prototype,"deleteCallRecord",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return v(this,void 0,void 0,(function(){return y(this,(function(i){return this._logger.info(M.L_SIGNAL_TRANSPORTER_DELETE_CALL_RECORD_T,"callIds: ".concat(JSON.stringify(t)),r),[2,this._sendCallSignal(e,le.DEL_CALL_LOG,{callIds:t})]}))}))}}),Object.defineProperty(t.prototype,"syncCallLog",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._logger.info(M.L_SIGNAL_TRANSPORTER_GET_CALL_RECORD_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.userId,le.SYNC_CALL_LOG,e)]}))}))}}),Object.defineProperty(t.prototype,"queryUserHasCall",{enumerable:!1,configurable:!0,writable:!0,value:function(){return v(this,void 0,void 0,(function(){var e;return y(this,(function(t){return e=this._context.getCurrentId(),[2,this._sendCallSignal(e,le.QRY_CALL_STATE,null)]}))}))}}),Object.defineProperty(t.prototype,"getCallServerTimestamp",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t;return y(this,(function(r){return t=this._context.getCurrentId(),this._logger.info(M.L_SIGNAL_TRANSPORTER_GET_CALL_SERVER_TIME_T,"userId: ".concat(t),e),[2,this._sendCallSignal(t,le.QRY_SRV_TIMESTAMP,null)]}))}))}}),Object.defineProperty(t.prototype,"getCallTimeInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._logger.info(M.L_SIGNAL_TRANSPORTER_GET_CALL_TIME_INFO_T,"callId: ".concat(e),t),[2,this._sendCallSignal(e,le.GET_CALL_TIME_INFO,{callId:e})]}))}))}}),Object.defineProperty(t.prototype,"getUserCallStateList",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t;return y(this,(function(r){return t=this._context.getCurrentId(),this._logger.info(M.L_SIGNAL_TRANSPORTER_GET_AVAILABLE_CALL_LIST_T,"userId: ".concat(t),e),[2,this._sendCallSignal(t,le.GET_CALL_STATE_LIST,null)]}))}))}}),Object.defineProperty(t.prototype,"clearCallRecord",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t;return y(this,(function(r){return t=this._context.getCurrentId(),this._logger.info(M.L_SIGNAL_TRANSPORTER_CLEAR_CALL_RECORD_T,"userId: ".concat(t),e),[2,this._sendCallSignal(t,le.CLEAR_CALL_LOG,null)]}))}))}}),Object.defineProperty(t.prototype,"getCallSession",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._logger.info(M.L_SIGNAL_TRANSPORTER_GET_CALL_INFO_BY_CALLID_T,"callId: ".concat(e.callId),t),[2,this._sendCallSignal(e.callId,le.GET_CALL_SESSION,e)]}))}))}}),Object.defineProperty(t.prototype,"sysStatusUp",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._logger.info(M.L_SIGNAL_TRANSPORTER_USER_SYSTEM_STATE_UP_T,"opts: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.callId,le.SYS_STATUS_UP,e)]}))}))}}),Object.defineProperty(t.prototype,"upCallLogReaded",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t;return y(this,(function(r){return t=this._context.getCurrentId(),[2,this._sendCallSignal(t,le.UP_CALL_LOG_READED,e)]}))}))}}),Object.defineProperty(t.prototype,"endUserAbnormalCalls",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){return y(this,(function(t){return[2,this._sendCallSignal(this._context.getCurrentId(),le.END_ABNORMAL_CALL,e)]}))}))}}),Object.defineProperty(t.prototype,"_onIMConnectionStateChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._logger.createTraceId();this._logger.info(M.L_SIGNAL_TRANSPORTER_IM_STATE_CHANGE_O,"state: ".concat(e),t),this._listener.onIMStateChange(e),e===a.CONNECTED?this._timeCorrectioner.start(t):this._timeCorrectioner.stop(t)}}),Object.defineProperty(t.prototype,"_sendCallSignal",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return v(this,void 0,void 0,(function(){var i,n,a,_,l,s;return y(this,(function(c){switch(c.label){case 0:return i=r?JSON.stringify(m(m({},r),{sessionId:this._sessionId})):"",this._needRetryActions.includes(t)?[4,Ce({asyncFn:this._context.setCallInfo.bind(this._context),fnArgs:[e,t,i]})]:[3,2];case 1:return n=c.sent(),[3,4];case 2:return[4,this._context.setCallInfo(e,t,i)];case 3:n=c.sent(),c.label=4;case 4:return a=n.code,_=n.data,a!==o.SUCCESS?[2,{code:a}]:(l=_.value,s=JSON.parse(l).data,[2,{code:D.SUCCESS,data:s}])}}))}))}}),Object.defineProperty(t.prototype,"_onRecvCallSignal",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,r=this._logger.createTraceId();this._logger.info(M.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_SIGNAL_DATA_O,"data: ".concat(e),r),JSON.parse(e).list.forEach((function(e){var i=e.key,n=JSON.parse(e.value);switch(i){case le.PUB_INVITE_CALL:t._onPubInviteCall(n,r,!0);break;case le.STATUS_DOWN_CALL:t._onStatusDownCall(n,r);break;case le.EVENT_DOWN_CALL:t._onEventDownCall(n,r);break;case le.DIALOG_DOWN_CALL:t._onDialogDownCall(n,r);break;case le.PUB_CALL_LOG:t._onPubCallLog(n,r);break;case le.PUB_CALL_LOG_READED:case le.PUB_NACK_SEQ_ID:break;default:t._onConpensationData(n,r)}}))}}),Object.defineProperty(t.prototype,"_isValidData",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return!!_(e)||!(!i(e)||0!==(null==e?void 0:e.length)&&e!==this._sessionId)}}),Object.defineProperty(t.prototype,"_onPubInviteCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){void 0===r&&(r=!0);try{var i=this._context.getCurrentId(),n=e.callSessionUsers.find((function(e){return e.userId===i})),o=this._context.getConnectionStatus();this._logger.info(M.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,"currentUser: ".concat(JSON.stringify(n),", currentUserId: ").concat(i,", state: ").concat(o),t)}catch(e){this._logger.error(M.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,"error: ".concat(e.message),t)}if(this._isValidData(e.toDeviceId||""))this._listener.onInvite(e,r,t),r?this.emit(ce.onPubInviteCall,Object.assign(e,{extra:JSON.stringify(e)})):this.emit(ce.onPubInviteCallPullKv,Object.assign(e,{extra:JSON.stringify(e)}));else{this._logger.warn(M.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,"not current deviceId -> deviceInfo: ".concat(JSON.stringify({toDeviceId:e.toDeviceId,clientDeviceId:this._sessionId})),t);var a={extra:JSON.stringify(e),reason:ue.NOT_CURRENT_DEVICEID,refer:r?Le.PUB_INVITE:Le.PULL_KV_INVITE};this.emit(ce.onPubInviteCallMiss,Object.assign(e,a))}}}),Object.defineProperty(t.prototype,"_onStatusDownCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(e.callSessionUsers=e.callSessionUsers.filter((function(e){return Boolean(e.changed)})),this._logger.info(M.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O,"",t),!this._isValidData(e.toDeviceId||""))return this._logger.warn(M.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O,"not current deviceId -> deviceInfo: ".concat(JSON.stringify({toDeviceId:e.toDeviceId,clientDeviceId:this._sessionId})),t),void this._listener.onOtherClientStatusDown(e,t);this._listener.onStatusDown(e,t,this._sessionId)}}),Object.defineProperty(t.prototype,"_onEventDownCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._listener.onEventDown(e,t)}}),Object.defineProperty(t.prototype,"_onDialogDownCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.dialogType===ne.SWITCH_MEDIA_TYPE&&this._listener.onSwitchMediaType(e,t)}}),Object.defineProperty(t.prototype,"_onPubCallLog",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(M.L_CALL_ENGINE_RECEIVE_CALL_RECORD_O,"call record: ".concat(JSON.stringify(e)),t),this._listener.onRecvCallEndLog(e,t)}}),Object.defineProperty(t.prototype,"_onConpensationData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;this._logger.info(M.L_CALL_ENGINE_RECEIVE_COMPLEMENTARY_DATA_O,"",t);var i=e.callId,n=e.callType,o=e.mediaType,a=e.secretChat,_=e.duration,l=e.callStatus,s=e.callingUserId,c=e.callSessionUsers,u=e.toDeviceId,L=e.callDialogEntitys,d=e.extra;c.some((function(e){return e.sessionStatus===j.INVITED&&e.userId===r._context.getCurrentId()}))?this._onPubInviteCall({callId:i,toDeviceId:u,callType:n,mediaType:o,inviteUserId:s,callingUserId:s,callSessionUsers:c,secretChat:a,extra:d},t,!0):this._onStatusDownCall({callId:i,toDeviceId:u,callStatus:l,duration:_,callSessionUsers:c},t),L.length>0&&L.forEach((function(e){return r._onDialogDownCall(e,t)}),this)}}),t}(n),pe=function(){var e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));return e="".concat(e.replace(/-/g,""),"0"),(e=function(e){var t="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ+/".split(""),r=t.length+1,i=+e,n=[];do{var o=i%r;i=(i-o)/r,n.unshift(t[o])}while(i);return n.join("")}(e=parseInt(e,16))).length>22&&(e=e.slice(0,22)),e},he=function(){function e(e,t){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_localStore",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._localStore=e.localStorage}return Object.defineProperty(e.prototype,"addAbnormallCallId",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){try{var i=JSON.parse(this._localStore.getItem(e._STORAGE_KEY)||"{}"),n=i[t];n?n.push(r):n=[r],i[t]=n,this._localStore.setItem(e._STORAGE_KEY,JSON.stringify(i))}catch(e){this._logger.error(M.L_ABNORMAL_ADD_CALL_ID_E,e.message),console.error(e)}}}),Object.defineProperty(e.prototype,"removeAbnormalCallIds",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){try{var i=JSON.parse(this._localStore.getItem(e._STORAGE_KEY)||"{}"),n=i[t];n&&((n=n.filter((function(e){return!r.includes(e)}))).length>0?i[t]=n:delete i[t],this._localStore.setItem(e._STORAGE_KEY,JSON.stringify(i)))}catch(e){this._logger.error(M.L_ABNORMAL_REMOVE_CALL_IDS_E,e.message),console.error(e)}}}),Object.defineProperty(e.prototype,"getAbnormalCallIds",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=null;try{var i=JSON.parse(this._localStore.getItem(e._STORAGE_KEY)||"{}")[t];i&&(r=i)}catch(e){this._logger.error(M.L_ABNORMAL_GET_CALL_IDS_E,e.message),console.error(e)}return Promise.resolve(r)}}),Object.defineProperty(e,"_STORAGE_KEY",{enumerable:!0,configurable:!0,writable:!0,value:"CallPlus_AbnormalCall"}),e}();!function(e){e[e.PROMPT=0]="PROMPT",e[e.CALL_DURATION=10]="CALL_DURATION",e[e.FIRST_FRAME=20]="FIRST_FRAME"}(Te||(Te={})),function(e){e[e.SUCCESS=0]="SUCCESS",e[e.INVALID_RESPONSE_TIME=80170]="INVALID_RESPONSE_TIME",e[e.NONOPTIMAL_RES_TIME=80171]="NONOPTIMAL_RES_TIME"}(Ie||(Ie={}));var be,Re,Oe,Ae=function(){function e(e,t,r){Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_singleCallDurationEv",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_RTT",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_validMinRTT",{enumerable:!0,configurable:!0,writable:!0,value:200}),Object.defineProperty(this,"_validMaxRTT",{enumerable:!0,configurable:!0,writable:!0,value:1e3}),Object.defineProperty(this,"_deltaTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_timerId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_interval",{enumerable:!0,configurable:!0,writable:!0,value:2e3}),Object.defineProperty(this,"_maxRetryTimes",{enumerable:!0,configurable:!0,writable:!0,value:8}),Object.defineProperty(this,"_startTimes",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_retryTimesInCall",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_maxRetryTimesInCall",{enumerable:!0,configurable:!0,writable:!0,value:3})}return Object.defineProperty(e.prototype,"getCallClientTimeByServer",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i,n,o,a,_,l;return y(this,(function(s){switch(s.label){case 0:return this._logger.info(M.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_T,"callId: ".concat(e),t),!this._RTT||this._RTT>this._validMinRTT?[4,this._getDeltaTime(t)]:[3,2];case 1:s.sent(),s.label=2;case 2:return this._RTT>this._validMaxRTT&&this._logger.error(M.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,"code: ".concat(Ie.INVALID_RESPONSE_TIME),t),[4,this._callEngine.getCallTimeInfo(e,t)];case 3:return r=s.sent(),i=r.code,n=r.data,i!==D.SUCCESS?(this._logger.error(M.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,"code: ".concat(i),t),[2,{code:i}]):(o=n.startTime,a=Math.floor(o-this._deltaTime),_=Date.now(),(l=(_+this._deltaTime-o)/1e3)<0&&(this._logger.warn(M.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_P,"invalid duration: ".concat(l),t),l=0),l=Math.floor(l),this._RTT>this._validMinRTT&&this._RTT<=this._validMaxRTT&&this._logger.error(M.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,"code: ".concat(Ie.NONOPTIMAL_RES_TIME),t),this._logger.info(M.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime,serverStartTime:o,clientStartTime:a,duration:l}),t),[2,{code:i,duration:l,clientStartTime:o?a:o}])}}))}))}}),Object.defineProperty(e.prototype,"calcClientStartTime",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){if(this._logger.info(M.L_TIME_CORRECT_CALC_CLIENT_START_TIME_T,"callId: ".concat(e,", startTime: ").concat(t),r),this._RTT>this._validMaxRTT)return this._logger.error(M.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R,"code: ".concat(Ie.INVALID_RESPONSE_TIME),r),this._loopCorrectClientTime(e,r),{code:Ie.INVALID_RESPONSE_TIME};var i=Math.floor(t-this._deltaTime);return this._logger.info(M.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime,startT:t,clientStartTime:i}),r),this._RTT>this._validMinRTT&&(this._retryTimesInCall=0,this._loopCorrectClientTime(e,r)),{code:Ie.SUCCESS,clientStartTime:i}}}),Object.defineProperty(e.prototype,"start",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;this._timerId||this._startTimes>=this._maxRetryTimes||(this._logger.info(M.L_TIME_CORRECT_START_O,"timerId: ".concat(this._timerId)),this._startTimes++,this._getDeltaTime(e),this._timerId=de((function(){t._timerId=null,t.start(e)}),this._interval))}}),Object.defineProperty(e.prototype,"stop",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(M.L_TIME_CORRECT_STOP_O,"timerId: ".concat(this._timerId),e),this._timerId&&clearTimeout(this._timerId),this._timerId=null,this._startTimes=0}}),Object.defineProperty(e.prototype,"restart",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(M.L_TIME_CORRECT_RESTART_O,"legal rtt time, RTT: ".concat(this._RTT,", validMinRTT: ").concat(this._validMinRTT),e),this._RTT<this._validMinRTT||(this.stop(e),this.start(e))}}),Object.defineProperty(e.prototype,"getLocalDelayTime",{enumerable:!1,configurable:!0,writable:!0,value:function(){return Math.round(this._deltaTime)}}),Object.defineProperty(e.prototype,"getRTT",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._RTT}}),Object.defineProperty(e.prototype,"_getDeltaTime",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i,n,o,a;return y(this,(function(_){switch(_.label){case 0:return t=Date.now(),[4,this._callEngine.getCallServerTimestamp(e)];case 1:return r=_.sent(),i=r.code,n=r.data,o=Date.now(),i!==D.SUCCESS?[2,{code:i}]:(((a=o-t)<this._RTT||0===this._RTT)&&a<=this._validMaxRTT&&(this._RTT=a),a<this._validMinRTT&&this.stop(e),this._deltaTime=n-t-this._RTT/2,this._logger.info(M.L_TIME_CORRECT_SET_DELTA_TIME_O,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime}),e),[2,{code:i,delayTime:this._deltaTime}])}}))}))}}),Object.defineProperty(e.prototype,"_getDeltaTimeInCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i,n,o,a,_,l,s;return y(this,(function(c){switch(c.label){case 0:return r=Date.now(),[4,this._callEngine.getCallTimeInfo(e,t)];case 1:return i=c.sent(),n=i.code,o=i.data,a=Date.now(),n!==D.SUCCESS?[2,{code:n}]:((_=a-r)<this._RTT&&(this._RTT=_),this._deltaTime=o.syncTime-r-this._RTT/2,this._logger.info(M.L_TIME_CORRECT_SET_DELTA_TIME_O,JSON.stringify({callId:e,rtt:this._RTT,deltaT:this._deltaTime}),t),l=Math.floor(o.startTime-this._deltaTime),s=Math.floor(o.firstFrametime-this._deltaTime),_<this._validMinRTT?[2,{code:Ie.SUCCESS,clientStartTime:l,clientFirstFrameTime:s}]:[2,{code:Ie.INVALID_RESPONSE_TIME,clientStartTime:l,clientFirstFrameTime:s}])}}))}))}}),Object.defineProperty(e.prototype,"_loopCorrectClientTime",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i,n,o,a=this;return y(this,(function(_){switch(_.label){case 0:return this.stop(t),this._logger.info(M.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_T,"callId: ".concat(e),t),[4,this._getDeltaTimeInCall(e,t)];case 1:return r=_.sent(),i=r.code,n=r.clientStartTime,o=r.clientFirstFrameTime,i===Ie.SUCCESS?(this._logger.info(M.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R,"code: ".concat(D.SUCCESS),t),this._singleCallDurationEv(e,n,o,t),[2]):this._retryTimesInCall>this._maxRetryTimesInCall&&i===Ie.INVALID_RESPONSE_TIME?(this._logger.info(M.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R,"code: ".concat(Ie.INVALID_RESPONSE_TIME),t),this._singleCallDurationEv(e,n,o,t),[2]):(this._retryTimesInCall>this._maxRetryTimesInCall||(this._retryTimesInCall++,setTimeout((function(){a._loopCorrectClientTime(e,t)}),this._interval)),[2])}}))}))}}),e}();!function(e){e[e.SOON_AFETER=0]="SOON_AFETER",e[e.CURRENT=1]="CURRENT"}(be||(be={})),function(e){e[e.PUB_INVITE_CALL=0]="PUB_INVITE_CALL",e[e.PULL_KV_INVITE_CALL=1]="PULL_KV_INVITE_CALL",e[e.SYSTEM_PUSH=2]="SYSTEM_PUSH"}(Re||(Re={})),function(e){e[e.OUT=-1]="OUT",e[e.GROUP=0]="GROUP",e[e.IN=1]="IN"}(Oe||(Oe={}));var Ne,me=function(e){function t(t,r,i,n,o){var a=e.call(this)||this;return Object.defineProperty(a,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(a,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(a,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(a,"_mainSession",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(a,"_holdSessions",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(a,"_signalModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"_abnormalModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"_isUpFirstFrameTime",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(a,"_callStartMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(a,"_timeCorrectioner",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"_clientCallId",{enumerable:!0,configurable:!0,writable:!0,value:""}),a._timeCorrectioner=new Ae(a,n,a._onRecvSinCallDuration.bind(a)),a._signalModule=new fe(t,r,i,a._timeCorrectioner,a._logger,a._reportAppEventModule),a._signalModule.registerListener({onInvite:a._onInvite.bind(a),onStatusDown:a._onStatusDown.bind(a),onOtherClientStatusDown:a._onOtherClientStatusDown.bind(a),onEventDown:a._onEventDown.bind(a),onSwitchMediaType:a._onSwitchMediaType.bind(a),onRecvCallEndLog:a._onRecvCallEndLog.bind(a),onIMStateChange:a._onIMStateChange.bind(a)}),a._abnormalModule=new he(r,n),a}return N(t,e),Object.defineProperty(t.prototype,"startCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i,n,o,a,_,l,s,c,u,L,d,E,C,T,I,g,S,f,p,h=this;return y(this,(function(b){switch(b.label){case 0:return r=this._context.getCurrentId(),i=e.callType,n=e.mediaType,o=e.toUsers,a=e.targetId,_=e.targetType,l=e.oldRoomId,s=e.pushConfig,c=e.extra,this._clientCallId=e.callId,u=s?X(s,this._clientCallId):"",[4,this._signalModule.startCall({clientCallId:this._clientCallId,callType:i,mediaType:n,toUsers:o,secretChat:oe.NORMAL,targetType:_,targetId:a,oldRoomId:l,pushExt:u,extra:c},t)];case 1:return L=b.sent(),d=L.code,E=L.data,d!==D.SUCCESS?[2,{code:d}]:(T=(C=E).callId,I=C.busylineUsers,this._abnormalModule.addAbnormallCallId(r,T),this._mainSession=new se(T,V.INVITED,i,n,r,r,[],this._logger),i===w.SINGLE&&(g=this._startTimer(E.callId,j.NO_ANSWER,t),this._mainSession.updateTimerId(ae.INVITER,g)),S={userId:r,userState:j.CALLING,systemState:k.CALLING,targetType:_,targetId:a,cameraEnable:!1,microphoneEnable:!1},f=o.map((function(e){var t=e.userId,r=e.targetType,i=e.targetId;return{userId:t,userState:j.INVITED,systemState:k.INVITED,targetType:r,targetId:i,cameraEnable:!1,microphoneEnable:!1}})),p=[],I&&(p=I.map((function(e){var t=f.find((function(t){return t.userId===e.userId})),r=t.targetType,i=t.targetId;return{userId:e.userId,userState:e.sessionStatus,systemState:k.BUSYLINE_RINGING,targetType:r,targetId:i,cameraEnable:!1,microphoneEnable:!1}})),f=f.filter((function(e){var t=e.userId;return p.every((function(e){return e.userId!==t}))}))),setTimeout((function(){h.updateUsersState(T,U(U([S],P(f),!1),P(p),!1),t)})),[2,{code:d,data:E}])}}))}))}}),Object.defineProperty(t.prototype,"invite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;return v(this,void 0,void 0,(function(){var i,n,o,a,_,l,s,c,u,L;return y(this,(function(d){switch(d.label){case 0:return this._mainSession?(i=e.toUsers,n=e.pushConfig,o=e.extra,a=n?X(n,this._clientCallId):"",_=this._mainSession.getCallId(),[4,this._signalModule.inviteCall({callId:_,toUsers:i,pushExt:a,extra:o},t)]):[2,{code:D.NOT_IN_CALL}];case 1:return l=d.sent(),s=l.code,c=l.data,s===D.SUCCESS&&(this._mainSession.getCallType()===w.SINGLE&&(this._mainSession.updateCallType(w.MULTI),this._onCallTypeChange(this._mainSession.getCallId(),w.MULTI,t)),u=i.map((function(e){var t=e.userId,r=e.targetType,i=e.targetId;return{userId:t,userState:j.INVITED,systemState:k.INVITED,targetType:r,targetId:i,cameraEnable:!1,microphoneEnable:!1}})),L=[],c.busylineUsers&&(L=null===(r=c.busylineUsers)||void 0===r?void 0:r.map((function(e){var t=u.find((function(t){return t.userId===e.userId})),r=t.targetType,i=t.targetId;return{userId:e.userId,userState:e.sessionStatus,systemState:k.BUSYLINE_RINGING,targetType:r,targetId:i,cameraEnable:!1,microphoneEnable:!1}})),u=u.filter((function(e){var t=e.userId;return L.every((function(e){return e.userId!==t}))}))),this.updateUsersState(_,U(U([],P(u),!1),P(L),!1),t)),[2,{code:s,data:c}]}}))}))}}),Object.defineProperty(t.prototype,"clearAllTimer",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;U([this._mainSession],P(this._holdSessions),!1).forEach((function(i){i&&i.getCallId()===e&&i.getAllTimerIds().forEach((function(e){return r._stopTimer.bind(r)(e,t)}))}))}}),Object.defineProperty(t.prototype,"hangup",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i,n,o,a;return y(this,(function(_){switch(_.label){case 0:return r=e.callId,i=e.systemState,n=e.pushConfig,o=n?X(n,this._clientCallId):"",[4,this._signalModule.hangupCall({callId:r,sysStatus:i,pushExt:o},t)];case 1:return a=_.sent().code,this.endCurrentSession(e.systemState,r,t),[2,{code:a}]}}))}))}}),Object.defineProperty(t.prototype,"accept",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i;return y(this,(function(n){switch(n.label){case 0:return this._mainSession?(r=e.callId,[4,this._signalModule.acceptCall({callId:r},t)]):[2,{code:D.NOT_IN_CALL}];case 1:return i=n.sent().code,this._stopTimer(this._mainSession.getInviteeTimerId(),t),i!==D.SUCCESS?[2,{code:i}]:(this._clearMobileOnPhone(e.callId,t),this._mainSession.updateSessionState(V.CONNECTING),[2,{code:i}])}}))}))}}),Object.defineProperty(t.prototype,"joinCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i;return y(this,(function(n){switch(n.label){case 0:return r=this._context.getCurrentId(),this._mainSession&&this._stopTimer(this._mainSession.getInviteeTimerId(),t),[4,this._signalModule.joinCall({callId:e.callId},t)];case 1:return(i=n.sent().code)!==D.SUCCESS?[2,{code:i}]:(this._abnormalModule.addAbnormallCallId(r,e.callId),this._mainSession?[3,3]:[4,this._createSessionByServer(e.callId,t,!0)]);case 2:return n.sent(),[3,4];case 3:this._clearMobileOnPhone(e.callId,t),n.label=4;case 4:return[2,{code:i}]}}))}))}}),Object.defineProperty(t.prototype,"requestChangeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i,n;return y(this,(function(o){switch(o.label){case 0:return this._mainSession?(r={mediaType:e.mediaType},this._mainSession.updateReqMediaType(e.mediaType),i=pe(),[4,this._signalModule.dialogUpCall({transactionId:i,callId:this._mainSession.getCallId(),toUserIds:e.toUserIds,dialogType:ne.SWITCH_MEDIA_TYPE,action:ie.REQUEST,extraKeyVal:r},t)]):[2,{code:D.NOT_IN_CALL}];case 1:return(n=o.sent().code)!==D.SUCCESS?[2,{code:n}]:[2,{code:D.SUCCESS,data:{transactionId:i}}]}}))}))}}),Object.defineProperty(t.prototype,"responseChangeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._mainSession?[2,this._signalModule.dialogUpCall({transactionId:e.transactionId,callId:this._mainSession.getCallId(),dialogType:ne.SWITCH_MEDIA_TYPE,action:e.agree?ie.ACCEPT:ie.REFUSE},t)]:[2,{code:D.NOT_IN_CALL}]}))}))}}),Object.defineProperty(t.prototype,"cancelChangeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._mainSession?[2,this._signalModule.dialogUpCall({transactionId:e.transactionId,callId:this._mainSession.getCallId(),dialogType:ne.SWITCH_MEDIA_TYPE,action:ie.CANCEL},t)]:[2,{code:D.NOT_IN_CALL}]}))}))}}),Object.defineProperty(t.prototype,"getCallLogList",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i,n,o,a,_,l,s;return y(this,(function(c){switch(c.label){case 0:return r=this._context.getCurrentId(),i=e.timestamp,n=e.count,o=e.order,[4,this._signalModule.syncCallLog({userId:r,syncTime:i,count:n,order:o},t)];case 1:return a=c.sent(),_=a.code,l=a.data,_!==D.SUCCESS?[2,{code:_}]:(s=l.callLogList.map((function(e){return J(e)})),[2,{code:D.SUCCESS,data:{hasMore:Boolean(null==l?void 0:l.hasMore),syncTime:0===o?l.maxTime:l.minTime,list:s}}])}}))}))}}),Object.defineProperty(t.prototype,"deleteCallLog",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r;return y(this,(function(i){return r=this._context.getCurrentId(),[2,this._signalModule.deleteCallRecord(r,e,t)]}))}))}}),Object.defineProperty(t.prototype,"getCallServerTimestamp",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i;return y(this,(function(n){switch(n.label){case 0:return[4,this._signalModule.getCallServerTimestamp(e)];case 1:return t=n.sent(),r=t.code,i=t.data,r!==D.SUCCESS?[2,{code:r}]:[2,{code:r,data:i.syncTime}]}}))}))}}),Object.defineProperty(t.prototype,"getCallTimeInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return[2,this._signalModule.getCallTimeInfo(e,t)]}))}))}}),Object.defineProperty(t.prototype,"getOpenCallList",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i,n,o,a=this;return y(this,(function(_){switch(_.label){case 0:return t=this._context.getCurrentId(),[4,this._signalModule.getUserCallStateList(e)];case 1:return r=_.sent(),i=r.code,n=r.data,i!==D.SUCCESS?[2,{code:i}]:(o=n.callStateList.map((function(r){var i=r.callId,n=r.callType,o=r.mediaType,_=r.callingUserId,l=r.callUserIds,s=r.callStatus,c=r.crtTime,u=r.userSessionStatus,L=r.startTime,d=r.syncTime,E=_===t?Oe.OUT:Oe.IN,C=a._timeCorrectioner.calcClientStartTime(i,L,e).clientStartTime,T=void 0===C?L:C;return{callId:i,callType:n,callDirection:E,mediaType:o,callerUserId:_,callUserIds:l,sessionState:s,userState:u,startTimestamp:L,endTimestamp:0,duration:Math.floor((+new Date-T)/1e3),syncTimestamp:d,systemState:0,createTimestamp:c}})),[2,{code:i,data:o}])}}))}))}}),Object.defineProperty(t.prototype,"removeAllCallLog",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){return y(this,(function(t){switch(t.label){case 0:return[4,this._signalModule.clearCallRecord(e)];case 1:return[2,{code:t.sent().code}]}}))}))}}),Object.defineProperty(t.prototype,"getCallSession",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i,n,o,a,_,l,s,c,u,L,d,E,C;return y(this,(function(T){switch(T.label){case 0:return[4,this._signalModule.getCallSession(e,t)];case 1:return r=T.sent(),i=r.code,n=r.data,i!==D.SUCCESS?[2,{code:i}]:(a=(o=n).callId,_=o.callingUserId,l=o.callType,s=o.mediaType,c=o.callStatus,u=o.callSessionUsers,L=o.startTime,d=o.duration,E=o.syncTime,C=u.map((function(e){return{userId:e.userId,userState:e.sessionStatus,systemState:e.sysStatus,targetType:e.targetType,targetId:e.targetId,cameraEnable:!1,microphoneEnable:!1}})),[2,{code:i,data:{callId:a,startCallerId:_,callType:l,mediaType:s,sessionState:c,callSessionUsers:C,startTime:L,duration:d,syncTime:E}}])}}))}))}}),Object.defineProperty(t.prototype,"getHoldSession",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._holdSessions.find((function(t){return t&&t.getCallId()===e}));return t?new B(t,this,this._logger):null}}),Object.defineProperty(t.prototype,"getLocalMainSession",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._mainSession?new B(this._mainSession,this,this._logger):null}}),Object.defineProperty(t.prototype,"updateMainSessionState",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;null===(t=this._mainSession)||void 0===t||t.updateSessionState(e)}}),Object.defineProperty(t.prototype,"setIsLocalClientHangup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;null===(t=this._mainSession)||void 0===t||t.setIsLocalClientHangup(e)}}),Object.defineProperty(t.prototype,"updateUsersState",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._logger.info(M.L_CALL_ENGINE_UPDATE_USERS_STATE_O,"updateUsersState -> users: ".concat(JSON.stringify(t)),r);var i=U([this._mainSession],P(this._holdSessions),!1).find((function(t){return(null==t?void 0:t.getCallId())===e})),n=[];if(i){var o=t.map((function(e){var t=i.getUserList().filter((function(t){return t.userId===e.userId}))[0]||{},r=e.userState===j.IDLE?{cameraEnable:!1,microphoneEnable:!1}:t,n=r.cameraEnable,o=void 0!==n&&n,a=r.microphoneEnable,_=void 0!==a&&a;return m(m({},e),{cameraEnable:o,microphoneEnable:_})}));n.push.apply(n,U([],P(i.updateUserList(o,r)),!1))}else n.push.apply(n,U([],P(t),!1));n.length>0&&this._onUserStateChange(e,n,r)}}),Object.defineProperty(t.prototype,"setUserDeviceEnable",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){var n;null===(n=this._mainSession)||void 0===n||n.setUserDeviceEnable(e,t,r,i)}}),Object.defineProperty(t.prototype,"getCallStaringTime",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return[2,this._timeCorrectioner.getCallClientTimeByServer(e.callId,t)]}))}))}}),Object.defineProperty(t.prototype,"systemStatusUp",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return[2,this._signalModule.sysStatusUp(e,t)]}))}))}}),Object.defineProperty(t.prototype,"upFirstFrameTime",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i,n,o;return y(this,(function(a){switch(a.label){case 0:return!this._mainSession||this._mainSession&&this._mainSession.getCallType()!==w.SINGLE||this._isUpFirstFrameTime?[2,{code:D.SUCCESS}]:(t=Date.now(),r=this._timeCorrectioner.getLocalDelayTime(),i=Math.floor(t+r),this._logger.info(M.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_T,"now: ".concat(t,"; delay: ").concat(r,"; streamReadyTime: ").concat(i),e),this._isUpFirstFrameTime=!0,n=this._mainSession.getCallId(),[4,this._signalModule.eventUpCall({callId:n,eventType:Te.FIRST_FRAME,eventArgs:{streamReadyTime:i},eventTime:Date.now()},e)]);case 1:return o=a.sent().code,this._logger.info(M.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_R,"code: ".concat(o),e),[2,{code:o}]}}))}))}}),Object.defineProperty(t.prototype,"endCurrentSession",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i=this,n=this._context.getCurrentId();if(this._mainSession&&this._mainSession.getCallId()===t){var o=this._mainSession.getUserList().map((function(t){var r=t.userId,o=t.systemState,a=t.targetType,_=t.targetId;return r===n&&(o=e),{userId:r,sessionStatus:j.ENDED,statusTime:Date.now(),duration:0,changed:1,inviteUserId:i._mainSession.getStartCallerId(),sysStatus:o,targetType:a,targetId:_}})),a={callId:this._mainSession.getCallId(),toDeviceId:this._signalModule.getSessionId(),callStatus:V.ENDED,duration:0,callSessionUsers:o};this._onStatusDown(a,r)}}}),Object.defineProperty(t.prototype,"startTimeCorrection",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._timeCorrectioner.restart(e)}}),Object.defineProperty(t.prototype,"getDelayTimeInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return{delayTime:this._timeCorrectioner.getLocalDelayTime(),rtt:this._timeCorrectioner.getRTT()}}}),Object.defineProperty(t.prototype,"upgradeMainSession",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r=this._holdSessions.findIndex((function(t){return t.getCallId()===e}));this._mainSession=null===(t=this._holdSessions.splice(r,1))||void 0===t?void 0:t[0]}}),Object.defineProperty(t.prototype,"endCurrentUserAbnormalCalls",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i,n,o=this;return y(this,(function(a){switch(a.label){case 0:return t=this._context.getCurrentId(),[4,this._abnormalModule.getAbnormalCallIds(t)];case 1:return(r=a.sent())?(i=r.filter((function(e){var t;return e!==(null===(t=o._mainSession)||void 0===t?void 0:t.getCallId())})),[4,this._signalModule.endUserAbnormalCalls({callIds:i,allDevice:e?1:0})]):[2,{code:D.SUCCESS}];case 2:return(n=a.sent().code)===D.SUCCESS&&this._abnormalModule.removeAbnormalCallIds(t,i),[2,{code:n}]}}))}))}}),Object.defineProperty(t.prototype,"_onIMStateChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,r=this._logger.createTraceId(),i=0;e===a.DISCONNECTED&&this._mainSession&&this._mainSession.getSessionState()!==V.ONCALL&&(i=de((function(){var e;t._logger.info(M.L_CALL_ENGINE_IM_STATE_CHANGE_O,"endCurrentSession, IM disconnected for more than 60s",r),t.endCurrentSession(k.CONNECTION_ERR,null===(e=t._mainSession)||void 0===e?void 0:e.getCallId(),r)}),6e4)),e===a.CONNECTED&&(i&&clearTimeout(i),this.endCurrentUserAbnormalCalls(!0))}}),Object.defineProperty(t.prototype,"_handleCallTimeout",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._logger.warn(M.L_CALL_ENGINE_CALL_TIMEOUT_O,"call timeout callId: ".concat(e,", userState: ").concat(t),r);var i=U([this._mainSession],P(this._holdSessions),!1).find((function(t){return t&&t.getCallId()===e}));if(i){var n=this._context.getCurrentId();this._onStatusDown({callId:e,toDeviceId:this._signalModule.getSessionId(),callStatus:V.ENDED,duration:0,callSessionUsers:i.getUserList().map((function(e){var r,o,a=e.userId,_=e.targetType,l=e.targetId,s=e.stateTime;return a===n?(r=t===j.MISSED?k.MISSED:k.NO_ANSWER,o=t===j.MISSED?j.MISSED:j.NO_ANSWER):(r=t===j.MISSED?k.NO_ANSWER:k.MISSED,o=t===j.MISSED?j.NO_ANSWER:j.MISSED),{userId:a,sessionStatus:o,statusTime:s?s+1:Date.now(),duration:0,changed:1,inviteUserId:i.getCallerId(),sysStatus:r,targetType:_,targetId:l}}))},r)}else this._logger.warn(M.L_CALL_ENGINE_CALL_TIMEOUT_O,"handleCallTimeout without session, callId: ".concat(e),r)}}),Object.defineProperty(t.prototype,"_startTimer",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i=this,n=de((function(){i._handleCallTimeout(e,t,r),i._signalModule.statusUpCall({callId:e,sessionStatus:t},r)}),6e4);return this._logger.info(M.L_CALL_ENGINE_START_CALL_TIMER_O,"callId: ".concat(e,", timerId: ").concat(n),r),n}}),Object.defineProperty(t.prototype,"_stopTimer",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){clearTimeout(e),this._logger.info(M.L_CALL_ENGINE_STOP_CALL_TIMER_O,"timerId: ".concat(e),t)}}),Object.defineProperty(t.prototype,"_onInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._clientCallId=s();var i=this._context.getCurrentId(),n=e.callSessionUsers,o=e.secretChat,a=e.extra,_=void 0===a?"{}":a;o!==oe.SECRET?(n.some((function(e){return e.userId===i}))&&this._selfIsInviteeHandle(e,t,r,_),this._othersIsInviteeHandle(e,r)):this.emit(ce.onPubInviteCallMiss,Object.assign(e,{extra:JSON.stringify(e),reason:ue.SECRET_CALL,refer:t?Le.PUB_INVITE:Le.PULL_KV_INVITE}))}}),Object.defineProperty(t.prototype,"_selfIsInviteeHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,i,n){var o=e.callId,a=e.inviteUserId,_=e.callType,l=e.mediaType,s=e.callSessionUsers,c=this._context.getCurrentId();this._abnormalModule.addAbnormallCallId(c,o);var u=new se(o,V.RINGING,_,l,a,a,[],this._logger);this._signalModule.ringingCall({callId:o},i);var L=this._startTimer(o,j.MISSED,i);u.updateTimerId(ae.INVITEE,L),this._mainSession?(this._holdSessions.push(u),this._mainSession.updateSessionState(V.BUSYLINE_WAIT)):this._mainSession=u;var d=new B(u,this,this._logger);this._reportAppEventModule.onReceivedCall(d,i,JSON.parse(n||"{}").extra);var E=r?Re.PUB_INVITE_CALL:Re.PULL_KV_INVITE_CALL;this.emit(t.__INNER_INVITE__,d,E);var C=s.map((function(e){return{userId:e.userId,userState:e.sessionStatus,systemState:e.sysStatus,targetType:e.targetType,targetId:e.targetId,stateTime:e.statusTime,cameraEnable:!1,microphoneEnable:!1}}));this.updateUsersState(o,C,i)}}),Object.defineProperty(t.prototype,"_othersIsInviteeHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,i,n,o=e.callId,a=e.inviteUserId,_=e.callSessionUsers,l=this._context.getCurrentId(),s=_.filter((function(e){return e.userId!==l&&e.userId!==a&&e.sessionStatus===j.INVITED}));if(s.length){(null===(r=this._mainSession)||void 0===r?void 0:r.getCallType())===w.SINGLE&&(null===(i=this._mainSession)||void 0===i?void 0:i.getCallId())===o&&(this._onCallTypeChange(this._mainSession.getCallId(),w.MULTI,t),null===(n=this._mainSession)||void 0===n||n.updateCallType(w.MULTI));var c=[],u=[];s.forEach((function(e){var t=e.userId,r=e.sessionStatus,i=e.sysStatus;c.push({callId:o,userId:t,userState:r}),u.push({userId:t,userState:r,systemState:i,cameraEnable:!1,microphoneEnable:!1})})),this._onOtherMemberInvite(c),this.updateUsersState(o,u,t)}}}),Object.defineProperty(t.prototype,"_onHangup",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i=this;this._mainSession&&e.forEach((function(e){e.callId===i._mainSession.getCallId()&&(e.userState===j.CANCELLED?i._stopTimer(i._mainSession.getInviteeTimerId(),r):i._stopTimer(i._mainSession.getInviterTimerId(),r))}))}}),Object.defineProperty(t.prototype,"_onAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){var i,n,o,a,_=null===(i=this._mainSession)||void 0===i?void 0:i.getSessionState(),l=[V.CONNECTING,V.ONCALL,V.BUSYLINE_WAIT];if((null===(n=this._mainSession)||void 0===n?void 0:n.getCallType())!==w.SINGLE||!_||!l.includes(_)){var s=this._mainSession.getStartCallerId(),c=this._context.getCurrentId();if((null===(o=this._mainSession)||void 0===o?void 0:o.getCallType())===w.SINGLE&&s===c)e.filter((function(e){return e.fromUserId!==c}))&&this.emit(t.__INNER_SESSION_CONNECT__,this.getLocalMainSession().getCallId(),r);null===(a=this._mainSession)||void 0===a||a.updateSessionState(V.CONNECTING),this._stopTimer(this._mainSession.getInviterTimerId(),r)}}}),Object.defineProperty(t.prototype,"_onStatusDown",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,i;return v(this,void 0,void 0,(function(){var n,o,a,_,l,s,c,u,L,d,E,C,T;return y(this,(function(I){return n=e.callStatus,o=e.startTime,(a=e.callId)!==(null===(r=this._mainSession)||void 0===r?void 0:r.getCallId())?[2]:(this._callStartMap[a]=this._callStartMap[a]||{},this._callStartMap[a].isReceiveCallStartTime||n!==V.ONCALL||(this._callStartMap[a].isReceiveCallStartTime=!0,_=this._timeCorrectioner.calcClientStartTime(a,o,t),l=_.code,s=_.clientStartTime,l===Ie.SUCCESS&&(this._callStartMap[a].callStartTime=s,this._reportAppEventModule.onReceivedCallStartTime({callId:a,callStartTime:s},t))),c=!1,u=this._context.getCurrentId(),(L=e.callSessionUsers.map((function(e){return[j.IDLE,j.DECLINED,j.MISSED,j.NO_ANSWER,j.CANCELLED].includes(e.sessionStatus)&&e.sysStatus!==k.CANCELLED&&e.userId===u&&(c=!0),{userId:e.userId,userState:e.sessionStatus,systemState:e.sysStatus,stateTime:e.statusTime,cameraEnable:!1,microphoneEnable:!1}}))).length>0&&this.updateUsersState(a,L,t),this._mainSession||this._holdSessions.length?(d=function(e){var t=e.callId,r=[],i=[],n=[],o=[];return e.callSessionUsers.forEach((function(e){var a=e.userId,_=e.sessionStatus,l=e.sysStatus;switch(_){case j.INVITED:o.push({callId:t,userId:a,userState:_});break;case j.RINGING:r.push({callId:t,fromUserId:a});break;case j.CONNECTING:n.push({fromUserId:a});break;case j.CANCELLED:case j.DECLINED:case j.ENDED:case j.IDLE:i.push({callId:t,fromUserId:a,userState:_,systemState:l})}})),{ringingData:r,hangupData:i,acceptData:n,otherInvitedData:o}}(e),E=d.hangupData,C=d.acceptData,T=d.otherInvitedData,E.length>0&&this._onHangup(E,e.callStatus,t),C.length>0&&this._onAccept(C,t),T.length>0&&(null===(i=this._mainSession)||void 0===i?void 0:i.getCallType())===w.MULTI&&this._onOtherMemberInvite(T),(e.callStatus===V.ENDED||c)&&this._onSessionClose(e,t,c),[2]):[2])}))}))}}),Object.defineProperty(t.prototype,"_onOtherClientStatusDown",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,i,n,o=e.callId,a=e.callSessionUsers,_=this._context.getCurrentId(),l=a.find((function(e){return e.userId===_}));if(l&&(this._mainSession||this._holdSessions.length)){var s=l.userId,c=l.sessionStatus,u=l.statusTime;if(c===j.CONNECTING){var L=[j.ONCALL,j.CONNECTING],d=(null===(r=this._mainSession)||void 0===r?void 0:r.getCallId())===o,E=null===(n=null===(i=this._mainSession)||void 0===i?void 0:i.getUserList().find((function(e){return e.userId===_})))||void 0===n?void 0:n.userState;d&&E&&L.includes(E)||(this.updateUsersState(o,[{userId:s,userState:c,systemState:k.OTHER_CLIENT_ACCEPT,stateTime:u,cameraEnable:!1,microphoneEnable:!1}],t),this._onSessionClose(e,t,!1))}}}}),Object.defineProperty(t.prototype,"_onEventDown",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;return v(this,void 0,void 0,(function(){var i,n,o,a,_,l,s;return y(this,(function(c){return i=e.callId,n=e.eventArgs,o=e.eventType,i!==(null===(r=this._mainSession)||void 0===r?void 0:r.getCallId())||this._mainSession.getSessionState()!==V.ONCALL||o===Te.CALL_DURATION&&(a=n.firstFrameTime,_=this._timeCorrectioner.calcClientStartTime(i,a,t),l=_.code,s=_.clientStartTime,this._logger.info(M.L_CALL_ENGINE_RECEIVE_FIRST_FRAME_TIME_O,"clientFirstFrameTime: ".concat(s),t),l===Ie.SUCCESS&&(this._callStartMap[i].firstFrameTime=s,this._reportAppEventModule.onReceivedCallFirstFrameTime(i,s,t))),[2]}))}))}}),Object.defineProperty(t.prototype,"_onRecvSinCallDuration",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){var n;(null===(n=this._mainSession)||void 0===n?void 0:n.getCallId())===e&&(this._callStartMap[e].callStartTime=t,this._callStartMap[e].firstFrameTime=r,this._reportAppEventModule.onReceivedCallStartTime(m({callId:e},{callStartTime:t}),i),this._reportAppEventModule.onReceivedCallFirstFrameTime(e,r,i))}}),Object.defineProperty(t.prototype,"_onSwitchMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,i,n,o,a,_=e.callId,l=e.action,s=e.extraKeyVal,c=e.transactionId,u=e.promoterId,L=s.mediaType,d=s.reason,E=null===(r=this._mainSession)||void 0===r?void 0:r.getCallId();if(_===E){var C=(null===(i=this._mainSession)||void 0===i?void 0:i.getOldDialogData())||{},T=C.transactionId,I=C.action,g=C.mediaType;if(T!==c||I!==l||g!==L){if(this._logger.info(M.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,"action: ".concat(l,", reason: ").concat(d),t),null===(n=this._mainSession)||void 0===n||n.setOldDialogData({transactionId:c,action:l,mediaType:L}),l===ie.REQUEST)this._onRequestChangeMediaType({transactionId:c,userId:u,mediaType:L},t);else{var S=null;switch(d){case ie.CANCEL:S=H.CANCEL_CHANGE_MEDIA_TYPE;break;case ie.ACCEPT:S=H.SERVER_ALLOW_MEDIA_TYPE,null===(o=this._mainSession)||void 0===o||o.updateMediaType(this._mainSession.getReqMediaType()),null===(a=this._mainSession)||void 0===a||a.updateReqMediaType(null);break;case ie.REFUSE:S=H.REFUSE_CHANGE_MEDIA_TYPE;break;case ie.TIMEOUT:S=H.CHANGE_MEDIA_TYPE_TIMEOUT}H[S]&&this._receiveMediaTypeChangeResult({transactionId:c,userId:u,mediaType:L},S,t)}l!==ie.NOTICE||L!==G.AUDIO||d||this._receiveMediaTypeChangeResult({transactionId:c,userId:u,mediaType:L},H.SERVER_ALLOW_MEDIA_TYPE,t)}else this._logger.info(M.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,"duplicate dialog data",t)}else this._logger.info(M.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,"not current session callId: ".concat(E,", recvCallId: ").concat(_),t)}}),Object.defineProperty(t.prototype,"_onRecvCallEndLog",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=J(e);this._reportAppEventModule.onReceivedCallRecord(r,t)}}),Object.defineProperty(t.prototype,"_onSessionClose",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,i){var n=this,o=e.callId,a=this._context.getCurrentId();this._abnormalModule.removeAbnormalCallIds(a,[o]);var _=U([this._mainSession],P(this._holdSessions),!1).find((function(e){return e&&e.getCallId()===o}));if(_){this._logger.warn(M.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O,"callId: ".concat(o),r),this.emit(t.__INNER_SESSION_CLOSE__,o,r);var l,s=_.getUserList().find((function(e){return e.userId===a}));l=i&&e.toDeviceId!==this._signalModule.getSessionId()?_.getIsLocalClientHangup()?s.systemState:k.OTHER_CLIENT_HANGUP:s.systemState,this._reportAppEventModule.onCallEnded(new B(_,this,this._logger),l,r),this._reportCallPlusSummaryMessage(_,o,l),this._mainSession&&this._mainSession.getCallId()===o&&(this._mainSession.getAllTimerIds().forEach((function(e){return n._stopTimer.bind(n)(e,r)})),_.getCallType()===w.SINGLE&&(this._isUpFirstFrameTime=!1),delete this._callStartMap[o]),this._removeSession(o)}else this._logger.warn(M.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O,"unexpect session callId -> ".concat(o),r)}}),Object.defineProperty(t.prototype,"_reportCallPlusSummaryMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i,n,o,a=this._context.getCurrentId(),_=e.getUserList().filter((function(e){return e.userId!==a}))[0].userId,l=e.getStartCallerId();if(!localStorage.getItem("missMessageMap-".concat(a,"-").concat(t))){var s={callId:t,callerUserId:l,targetId:_,mediaType:e.getMediaType(),firstFrameTime:(null===(i=this._callStartMap[t])||void 0===i?void 0:i.firstFrameTime)||0,callStartTime:(null===(n=this._callStartMap[t])||void 0===n?void 0:n.callStartTime)||0,callEndTime:(null===(o=this._callStartMap[t])||void 0===o?void 0:o.callStartTime)?+new Date-this._timeCorrectioner.getLocalDelayTime():0,hangupReason:r};this._reportAppEventModule.onReceivedCallPlusSummaryMessage({messageType:Se,content:JSON.stringify(s),senderUserId:l,targetId:_,channelId:"",conversationType:c.PRIVATE,sentTime:+new Date-this._timeCorrectioner.getLocalDelayTime(),receivedTime:+new Date-this._timeCorrectioner.getLocalDelayTime(),messageUId:"",messageDirection:l===a?u.SEND:u.RECEIVE,isPersited:!0,isCounted:!1,isOffLineMessage:!1,canIncludeExpansion:!1,receivedStatus:L.READ,isStatusMessage:!1,isMentioned:!1,expansion:null,disableNotification:!1}),localStorage.setItem("missMessageMap-".concat(a,"-").concat(t),t)}}}),Object.defineProperty(t.prototype,"_removeSession",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;if(e===(null===(t=this._mainSession)||void 0===t?void 0:t.getCallId()))this._mainSession=null;else{var r=this._holdSessions.findIndex((function(t){return(null==t?void 0:t.getCallId())===e}));this._holdSessions.splice(r,1)}}}),Object.defineProperty(t.prototype,"_createSessionByServer",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return void 0===r&&(r=!1),v(this,void 0,void 0,(function(){var i,n,o,a,_,l,s,c;return y(this,(function(u){switch(u.label){case 0:return this._logger.info(M.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_T,"callId: ".concat(e),t),[4,this.getCallSession({callId:e},t)];case 1:return i=u.sent(),n=i.code,o=i.data,n!==D.SUCCESS?(this._logger.error(M.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R,"errcode: ".concat(n),t),[2]):(this._logger.info(M.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R,"code: ".concat(n,", data: ").concat(JSON.stringify(o)),t),_=(a=o).callType,l=a.mediaType,s=a.callSessionUsers,c=a.startCallerId,this._mainSession=new se(e,V.CONNECTING,_,l,c,c,[],this._logger),r&&this._clearMobileOnPhone(e,t),this.updateUsersState(e,s,t),[2])}}))}))}}),Object.defineProperty(t.prototype,"_clearMobileOnPhone",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i;return y(this,(function(n){switch(n.label){case 0:return(r=U([this._mainSession],P(this._holdSessions),!1).find((function(t){return(null==t?void 0:t.getCallId())===e})))&&r.getCallType()===w.MULTI?(this._logger.info(M.L_CALL_ENGINE_UP_ON_PHONE_END_T,"callId: ".concat(e),t),[4,this.systemStatusUp({callId:e,sysStatus:k.ON_PHONE_END,forward:be.CURRENT},t)]):[3,2];case 1:(i=n.sent().code)===D.SUCCESS?this._logger.info(M.L_CALL_ENGINE_UP_ON_PHONE_END_R,"callId: ".concat(e),t):this._logger.warn(M.L_CALL_ENGINE_UP_ON_PHONE_END_R,"callId: ".concat(e,", errCode: ").concat(i),t),n.label=2;case 2:return[2]}}))}))}}),Object.defineProperty(t.prototype,"_onUserStateChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,i){var n=this,o=this._context.getCurrentId();r.forEach((function(t){var r=t.userId,a=t.userState,_=t.systemState;r!==o&&n._reportAppEventModule.onRemoteUserStateChanged({callId:e,userId:r,userState:a,reason:_},i)})),r.forEach((function(r){var a=r.userId,_=r.systemState;a===o&&_===k.ABNORMAL_END&&n.emit(t.__INNER_SESSION_CLOSE__,e,i)}))}}),Object.defineProperty(t.prototype,"_onOtherMemberInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;e.forEach((function(e){var r,i=e.userId,n=e.callId,o=null===(r=t.getLocalMainSession())||void 0===r?void 0:r.getInviterUserId();t._reportAppEventModule.onRemoteUserInvited([i],o,n)}))}}),Object.defineProperty(t.prototype,"_onRequestChangeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,i=e.userId,n=e.transactionId,o=e.mediaType;null===(r=this._mainSession)||void 0===r||r.updateReqMediaType(o),this._reportAppEventModule.onReceivedChangeMediaTypeRequest(i,n,o,t)}}),Object.defineProperty(t.prototype,"_receiveMediaTypeChangeResult",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,i){r===H.SERVER_ALLOW_MEDIA_TYPE&&this.emit(t.__INNER_CHANGE_MEDIA_TYPE__,e.mediaType,i),this._reportAppEventModule.onReceivedChangeMediaTypeResult(m(m({},e),{code:r}),i)}}),Object.defineProperty(t.prototype,"_onCallTypeChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._reportAppEventModule.onCallTypeChanged(t,e,r)}}),Object.defineProperty(t,"__INNER_SESSION_CLOSE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-session-close"}),Object.defineProperty(t,"__INNER_SESSION_CONNECT__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-session-connect"}),Object.defineProperty(t,"__INNER_CHANGE_MEDIA_TYPE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-change-media-type"}),Object.defineProperty(t,"__INNER_INVITE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-invite"}),t}(n);!function(e){e.NORMAL="RongCloudRTC",e.SCREEN="ScreenShare"}(Ne||(Ne={}));var ve,ye=function(e){function r(t,r,i,n,o,a){var _=e.call(this)||this;return Object.defineProperty(_,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(_,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(_,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(_,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(_,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(_,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(_,"_rtcClient",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_localTracks",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(_,"_room",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(_,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(_,"_callMediaType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:f.W640_H480,frameRate:S.FPS_15}}),Object.defineProperty(_,"_audioConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(_,"_isPubTiny",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(_,"_audioOutputDeviceId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(_,"_videoConfigIsChange",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(_,"_audioConfigIsChange",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(_,"_userViewMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(_,"_callPlusStatusReportListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(_,"_remoteAudioEnable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),_._rtcClient=null==i?void 0:i.rtcClient,_._isPubTiny=i.isPubTiny||!1,_}return N(r,e),Object.defineProperty(r.prototype,"setCallPlusStatusReportListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._callPlusStatusReportListener=e}}),Object.defineProperty(r.prototype,"getCameraVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i,n,o;return y(this,(function(a){switch(a.label){case 0:return!(t=this.getLocalVideoTrack())||this._videoConfigIsChange?[3,1]:(o={track:t,code:D.SUCCESS},[3,3]);case 1:return[4,this._createVideoTrack(e)];case 2:o=a.sent(),a.label=3;case 3:return i=(r=o).code,n=r.track,this._videoConfigIsChange=!1,i!==D.SUCCESS?[2,{code:i}]:[2,{code:D.SUCCESS,track:n}]}}))}))}}),Object.defineProperty(r.prototype,"getMicrophoneAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i,n,o;return y(this,(function(a){switch(a.label){case 0:return!(t=this.getLocalAudioTrack())||this._audioConfigIsChange?[3,1]:(o={track:t,code:D.SUCCESS},[3,3]);case 1:return[4,this._createAudioTrack(e)];case 2:o=a.sent(),a.label=3;case 3:return i=(r=o).code,n=r.track,this._audioConfigIsChange=!1,i!==D.SUCCESS?[2,{code:i}]:[2,{code:D.SUCCESS,track:n}]}}))}))}}),Object.defineProperty(r.prototype,"createCallMediaTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i;return y(this,(function(n){switch(n.label){case 0:return this._callMediaType=e,[4,this.getMicrophoneAudioTrack(t)];case 1:return(r=n.sent().code)!==D.SUCCESS?[2,{code:r}]:e!==G.AUDIO_VIDEO?[3,3]:[4,this.getCameraVideoTrack(t)];case 2:(i=n.sent().code)!==D.SUCCESS&&this._logger.warn(M.L_RTC_MODULE_CREATE_CALL_MEDIA_TRACKS_P,"get camera video track error code: ".concat(i),t),n.label=3;case 3:return[2,{code:D.SUCCESS}]}}))}))}}),Object.defineProperty(r.prototype,"setVideoConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._videoConfigIsChange=!0,this._videoConfig=e}}),Object.defineProperty(r.prototype,"setAudioConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._audioConfigIsChange=!0,this._audioConfig=e}}),Object.defineProperty(r.prototype,"setAudioOutputDeviceId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){return y(this,(function(t){return"string"!=typeof e||0===e.length?[2,{code:D.PARAM_ERROR}]:(this._audioOutputDeviceId===e||(this._audioOutputDeviceId=e,this._room&&this._room.getRemoteTracks().filter((function(e){return e.isAudioTrack()})).forEach((function(t){t.isSubscribed()&&t.play(void 0,{audioDeviceId:e})}))),[2,{code:D.SUCCESS}])}))}))}}),Object.defineProperty(r.prototype,"destroyAllTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(M.L_RTC_MODULE_DESTROY_ALL_TRACKS_O,"",e),this._localTracks.forEach((function(e){e.destroy()})),this._localTracks.length=0}}),Object.defineProperty(r.prototype,"setAllRemoteAudioEnable",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){return this._logger.info(M.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_T,"enable: ".concat(e),r),t(e)?(this._remoteAudioEnable=e,this._room?(this._room.getRemoteTracks().filter((function(e){return e.isAudioTrack()})).forEach((function(t){e?t.unmute():t.mute()})),this._logger.info(M.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R,"success",r),{code:D.SUCCESS}):{code:D.SUCCESS}):(this._logger.error(M.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R,"param error, enable: type is boolean, value: ".concat(e)),{code:D.PARAM_ERROR})}}),Object.defineProperty(r.prototype,"destroyTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t;return y(this,(function(r){return e.destroy(),t=this._localTracks.findIndex((function(t){return t.getTrackId()===e.getTrackId()})),this._localTracks.splice(t,1),[2]}))}))}}),Object.defineProperty(r.prototype,"sessionConnected",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;return v(this,void 0,void 0,(function(){var i,n,o,a,_;return y(this,(function(l){switch(l.label){case 0:return this._logger.info(M.L_RTC_MODULE_SESSION_CONNECT_T,"callId: ".concat(e),t),this._room?[3,2]:[4,this.joinRTCRoom(e,t)];case 1:if(i=l.sent(),_=i.code,n=i.room,_!==D.SUCCESS)return[2];this._room=n,l.label=2;case 2:return this._callId=e,this._regRTCListeners(),(o=(null===(r=this._room)||void 0===r?void 0:r.getRemoteUserIds())||[]).length>0&&this._onOtherMemJoined(o.map((function(t){return{callId:e,userId:t}})),t),this._localTracks.length>0?(this.emit(ce.onBeforePublish),a=this._isPubTiny?this._localTracks.map((function(e){return e.isVideoTrack()?{track:e,isPubTiny:!0}:e})):this._localTracks,[4,this.publish(a,t)]):[3,4];case 3:return _=l.sent().code,this.emit(ce.onPublishRes,_),[3,5];case 4:this._logger.warn(M.L_RTC_MODULE_SESSION_CONNECT_P,"sessionConnected local tracks is empty",t),l.label=5;case 5:return this._logger.info(M.L_RTC_MODULE_SESSION_CONNECT_R,"code: ".concat(D.SUCCESS),t),[2]}}))}))}}),Object.defineProperty(r.prototype,"sessionClose",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;return v(this,void 0,void 0,(function(){var i,n;return y(this,(function(o){switch(o.label){case 0:return this._logger.info(M.L_RTC_MODULE_SESSION_CLOSE_T,"callId: ".concat(e),t),this.destroyAllTracks(t),i=null===(r=this._room)||void 0===r?void 0:r.getRoomId(),this._room&&e===i?[4,this._rtcClient.leaveRoom(this._room)]:[3,2];case 1:return n=o.sent().code,this._releaseStoredData(),n!==p.SUCCESS?(this._logger.error(M.L_RTC_MODULE_SESSION_CLOSE_R,"leaveRoom failed, code: ".concat(n),t),[2]):(this._logger.info(M.L_RTC_MODULE_SESSION_CLOSE_R,"leaveRoom success",t),[3,3]);case 2:this._logger.warn(M.L_RTC_MODULE_SESSION_CLOSE_R,"leaveRoom throw exception: not in room",t),o.label=3;case 3:return[2]}}))}))}}),Object.defineProperty(r.prototype,"disableVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return v(this,void 0,void 0,(function(){var e;return y(this,(function(t){switch(t.label){case 0:return(e=this.getLocalVideoTrack())?[4,e.mute()]:[2,{code:D.CAMERA_CLOSED}];case 1:return[2,{code:t.sent(),track:e}]}}))}))}}),Object.defineProperty(r.prototype,"enableVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var e;return y(this,(function(t){switch(t.label){case 0:return(e=this.getLocalVideoTrack())?e.isOwnerMuted()?[4,e.unmute()]:[2,{code:D.SUCCESS}]:[2,{code:D.CAMERA_CLOSED}];case 1:return[2,{code:t.sent()}]}}))}))}}),Object.defineProperty(r.prototype,"changeVideoDevice",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i,n,o,a,_,l,s,c;return y(this,(function(u){switch(u.label){case 0:return t=[],r=[],[4,this._rtcClient.createCameraVideoTrack(Ne.NORMAL,this._videoConfig)];case 1:return i=u.sent(),n=i.code,o=i.track,n!==p.SUCCESS?[2,{code:n}]:(a=this._videoConfig,_=a.minBitrate,l=a.maxBitrate,(_||l)&&o.setBitrate(l,_),this._localTracks&&this._localTracks.forEach((function(e){e.isVideoTrack()?(e.destroy(),s=e):r.push(e)})),this._localTracks=this._localTracks.filter((function(e){return s&&e.getTrackId()!==s.getTrackId()})),t.push(o),r.push(o),this._localTracks=r,this._onLocalTrackReady(t,e),this._room?[4,this._room.publish(t)]:[3,3]);case 2:if((c=u.sent().code)!==p.SUCCESS)return[2,{code:c}];u.label=3;case 3:return[2,{code:D.SUCCESS,track:o}]}}))}))}}),Object.defineProperty(r.prototype,"changeAudioDevice",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i,n,o,a,_;return y(this,(function(l){switch(l.label){case 0:return t=[],r=[],i=m(m({},this._audioConfig),{micphoneId:this._audioConfig.microphoneId}),[4,this._rtcClient.createMicrophoneAudioTrack(Ne.NORMAL,i)];case 1:return n=l.sent(),o=n.code,a=n.track,o!==p.SUCCESS?[2,{code:o}]:(this._localTracks&&this._localTracks.forEach((function(e){e.isAudioTrack()||r.push(e)})),t.push(a),r.push(a),this._localTracks=r,this._onLocalTrackReady(t,e),this._room?[4,this._room.publish(t)]:[3,3]);case 2:if((_=l.sent().code)!==p.SUCCESS)return[2,{code:_}];l.label=3;case 3:return[2,{code:D.SUCCESS}]}}))}))}}),Object.defineProperty(r.prototype,"disableAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return v(this,void 0,void 0,(function(){var e;return y(this,(function(t){switch(t.label){case 0:return(e=this.getLocalAudioTrack())?[4,e.mute()]:[2,{code:D.MICROPHONE_CLOSED}];case 1:return[2,{code:t.sent(),track:e}]}}))}))}}),Object.defineProperty(r.prototype,"changeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r;return y(this,(function(i){switch(i.label){case 0:return this._logger.info(M.L_RTC_MODULE_CHANGE_MEDIA_TYPE_T,"mediaType: ".concat(e),t),e!==G.AUDIO_VIDEO?[3,2]:[4,this._upgradeMediaType(t)];case 1:return r=i.sent(),[3,4];case 2:return[4,this._downgradeMediaType(t)];case 3:r=i.sent(),i.label=4;case 4:return r.code===D.SUCCESS&&this._logger.info(M.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,"success",t),[2]}}))}))}}),Object.defineProperty(r.prototype,"_upgradeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i,n,o,a,_,l,s;return y(this,(function(c){switch(c.label){case 0:return(t=this.getLocalVideoTrack())?[3,2]:[4,this._createVideoTrack(e)];case 1:if(r=c.sent(),i=r.code,n=r.track,i!==D.SUCCESS)return this._logger.error(M.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,"create video track errCode: ".concat(i),e),[2,{code:i}];t=n,o=this._videoConfig,a=o.minBitrate,_=o.maxBitrate,(a||_)&&t.setBitrate(_,a),c.label=2;case 2:return l=this._isPubTiny?{track:t,isPubTiny:!0}:t,[4,this.publish([l],e)];case 3:return(s=c.sent().code)!==D.SUCCESS&&this._logger.error(M.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,"publish errCode: ".concat(s),e),[2,{code:s}]}}))}))}}),Object.defineProperty(r.prototype,"_downgradeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r;return y(this,(function(i){switch(i.label){case 0:return(t=this.getLocalVideoTrack())?[4,this._room.unpublish([t])]:[3,2];case 1:if((r=i.sent().code)!==p.SUCCESS)return this._logger.error(M.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,"unpublish errCode: ".concat(r),e),[2,{code:r}];this.destroyTrack(t),i.label=2;case 2:return[2,{code:D.SUCCESS}]}}))}))}}),Object.defineProperty(r.prototype,"joinRTCRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i,n,o;return y(this,(function(a){switch(a.label){case 0:return this._logger.info(M.L_RTC_MODULE_JOIN_RTC_ROOM_T,"call: ".concat(e),t),[4,Ce({asyncFn:this._rtcClient.joinRTCRoomWithOptions.bind(this._rtcClient),fnArgs:[e,{mode:d.CALL}]})];case 1:return r=a.sent(),i=r.code,n=r.room,o=r.tracks,i!==p.SUCCESS?(this._logger.error(M.L_RTC_MODULE_JOIN_RTC_ROOM_R,"callId: ".concat(e,", errCode: ").concat(i),t),this._onRTCMethodFail(k.JOIN_ROOM_ERR,t),[2,{code:i}]):(this._logger.info(M.L_RTC_MODULE_JOIN_RTC_ROOM_R,"success",t),this._room=n,this._onSelfJoined({callId:e,userId:this._context.getCurrentId()},t),(null==o?void 0:o.length)&&this._onRemoteTrackPublish(o),this._callId=e,[2,{code:D.SUCCESS,room:n,tracks:o}])}}))}))}}),Object.defineProperty(r.prototype,"subscribeTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r;return y(this,(function(i){switch(i.label){case 0:return this._logger.info(M.L_RTC_MODULE_SUBSCRIBE_T,JSON.stringify({params:e.map((function(e){var t=e.track,r=e.subTiny;return{trackId:t.getTrackId(),subTiny:r}}))}),t),this._room?[4,Ce({asyncFn:this._room.subscribe.bind(this._room),fnArgs:[e],onError:function(e){}})]:[2,{code:D.SUCCESS}];case 1:return(r=i.sent().code)!==p.SUCCESS?(this._reportAppEventModule.onFetchRemoteMediaError(e,r),this._onRTCMethodFail(k.SUBSCRIBE_ERR,t),this._logger.error(M.L_RTC_MODULE_SUBSCRIBE_R,"errorCode: ".concat(r),t),[2,{code:r}]):(this._logger.info(M.L_RTC_MODULE_SUBSCRIBE_R,"success",t),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(r.prototype,"unsubscribeTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r;return y(this,(function(i){switch(i.label){case 0:return this._logger.info(M.L_RTC_MODULE_UNSUBSCRIBE_T,JSON.stringify({trackIds:e.map((function(e){return e.getTrackId()}))}),t),this._room?[4,this._room.unsubscribe(e)]:[2,{code:D.SUCCESS}];case 1:return(r=i.sent().code)!==p.SUCCESS?(this._logger.error(M.L_RTC_MODULE_UNSUBSCRIBE_R,"errorCode: ".concat(r),t),[2,{code:r}]):(this._logger.info(M.L_RTC_MODULE_UNSUBSCRIBE_R,"success",t),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(r.prototype,"_releaseStoredData",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._room=null,this._remoteAudioEnable=!0,this._userViewMap={}}}),Object.defineProperty(r.prototype,"getRemoteTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t={};return this._room?(this._room.getRemoteUserIds().forEach((function(r){t[r]=e._room.getRemoteTracksByUserId(r)})),t):t}}),Object.defineProperty(r.prototype,"getRemoteTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;return null===(r=this._room)||void 0===r?void 0:r.getRemoteTracksByUserId(e).find((function(e){return t===G.AUDIO?e.isAudioTrack():e.isVideoTrack()}))}}),Object.defineProperty(r.prototype,"getRTCSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._room?this._room.getSessionId():null}}),Object.defineProperty(r.prototype,"_regRTCListeners",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this._room.registerRoomEventListener({onKickOff:function(t,r){e._onKickOff(t,e._room.getRoomId(),r),e._releaseStoredData()},onUserJoin:function(t){var r=t.map((function(t){return{callId:e._callId,userId:t}})),i=e._logger.createTraceId();e._onOtherMemJoined(r,i)},onUserLeave:function(t){t.forEach((function(t){delete e._userViewMap[t]}))},onTrackPublish:this._onRemoteTrackPublish.bind(this),onTrackUnpublish:this._onTrackUnpublish.bind(this),onTrackReady:function(t){e._onRemoteTrackReady([t])},onVideoMuteChange:function(t){e._onVideoMuteChagne({fromUserId:t.getUserId(),muted:t.isOwnerMuted(),trackId:t.getTrackId()})},onAudioMuteChange:function(t){e._onAudioMuteChange({fromUserId:t.getUserId(),muted:t.isOwnerMuted(),trackId:t.getTrackId()})},onRTCPeerConnectionCloseByException:this._onRTCPeerConnectionCloseByException.bind(this)}),this._room.registerReportListener({onStateReport:this._onRTCStateReport.bind(this)}),this._room.onAudioLevelChange((function(t){e._reportAppEventModule.onUserAudioLevelChanged(t)}))}}),Object.defineProperty(r.prototype,"_onLocalTrackReady",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._reportAppEventModule.onUserMediaAvailable(e,t)}}),Object.defineProperty(r.prototype,"_onRemoteTrackReady",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._reportAppEventModule.onUserMediaAvailable(e),this.emit(r.__INNER_RECEIVE_FIRST_FRAME__)}}),Object.defineProperty(r.prototype,"_onKickOff",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,i,n){this._logger.info(M.L_RTC_MODULE_RECEIVE_KICK_OFF_O,"roonId: ".concat(t,", byServer: ").concat(e,", state: ").concat(i,", kickExtra: ").concat(JSON.stringify(n)));var o=k.CONNECTION_ERR;if(e)if(n)o=n.kickReasonCode;else switch(i){case h.SERVER_KICK:o=k.KICKED_BY_SERVER;break;case h.OTHER_KICK:o=k.OTHER_CLIENT_JOINED;break;case h.IM_DISCONNECTED:o=k.CONNECTION_ERR;break;case h.IM_LOGOUT:o=k.LOGOUT;break;case h.OTHER_CLIENT_IM_CONNECTED:o=k.OTHER_CLIENT_LOGIN}this.emit(r.__INNER_ON_KICKOFF__,o,t)}}),Object.defineProperty(r.prototype,"_onRTCPeerConnectionCloseByException",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._logger.createTraceId();this._logger.info(M.L_RTC_MODULE_RECEIVE_PEERCONNECTION_EXCEPT_CLOSE_O,"",e),this.emit(r.__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__,e)}}),Object.defineProperty(r.prototype,"_onSelfJoined",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(i){return this.emit(r.__INNER_ON_SELF_JOINED__,e.callId,t),[2]}))}))}}),Object.defineProperty(r.prototype,"_onRemoteTrackPublish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,r=this._logger.createTraceId();this._onDeviceEnableChange(e,r),this._logger.info(M.L_RTC_MODULE_RECEIVE_TRACK_PUBLISH_O,JSON.stringify({callId:this._callId,trackIds:e.map((function(e){return e.getTrackId()}))}),r);var i=[];e.forEach((function(e){var r,n=e.getUserId();if(e.isAudioTrack())i.push({track:e,subTiny:!1}),t._reportAppEventModule.onRemoteMicrophoneStateChanged(t._callId,e);else if(null===(r=t._userViewMap[n])||void 0===r?void 0:r.videoView){t._reportAppEventModule.onRemoteCameraStateChanged(t._callId,e);var o=t._userViewMap[n].isTiny;i.push({track:e,subTiny:o})}})),i.length&&this.subscribeTracks(i,r)}}),Object.defineProperty(r.prototype,"_onTrackUnpublish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t;return y(this,(function(r){switch(r.label){case 0:return t=this._logger.createTraceId(),this._onDeviceEnableChange(e,t),this._logger.info(M.L_RTC_MODULE_RECEIVE_TRACK_UNPUBLISH_O,JSON.stringify({callId:this._callId,trackIds:e.map((function(e){return e.getTrackId()}))}),t),[4,this.unsubscribeTracks(e,t)];case 1:return r.sent(),[2]}}))}))}}),Object.defineProperty(r.prototype,"_onAudioMuteChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._logger.createTraceId();this._logger.info(M.L_RTC_MODULE_RECEIVE_TRACK_ENABLE_CHANGE_O,JSON.stringify({info:e}),t);var r=this._room.getRemoteTrack(e.trackId);this._onDeviceEnableChange([r],t),this._reportAppEventModule.onRemoteMicrophoneStateChanged(this._callId,r)}}),Object.defineProperty(r.prototype,"_onVideoMuteChagne",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._logger.createTraceId();this._logger.info(M.L_RTC_MODULE_RECEIVE_TRACK_ENABLE_CHANGE_O,JSON.stringify({info:e}),t);var r=this._room.getRemoteTrack(e.trackId);this._onDeviceEnableChange([r],t),this._reportAppEventModule.onRemoteCameraStateChanged(this._callId,r)}}),Object.defineProperty(r.prototype,"_onRTCStateReport",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,r=e.senders,i=e.receivers;r.forEach((function(e){var r,i=e.kind,n=e.packetsLostRate,o=e.rtt;t._callMediaType===G.AUDIO_VIDEO&&"audio"===i||null===(r=t._callPlusStatusReportListener)||void 0===r||r.onSendPacketLoss(n||0,o||0)})),i.forEach((function(e){var r,i=e.trackId,n=e.kind,o=e.packetsLostRate,a=e.bitrate;if(t._callMediaType!==G.AUDIO_VIDEO||"audio"!==n){var _={};_[b.parseTrackId(i).userId]={packetLostRate:o||0,bitRate:a},null===(r=t._callPlusStatusReportListener)||void 0===r||r.onReceivePacketLoss(_)}}))}}),Object.defineProperty(r.prototype,"_onRTCMethodFail",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this.emit(r.__INNER_RTC_PROCESS_FAILED__,e,t)}}),Object.defineProperty(r.prototype,"_onOtherMemJoined",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this.emit(r.__INNER_ON_OTHER_JOINED__,e,t)}}),Object.defineProperty(r.prototype,"_onDeviceEnableChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this.emit(r.__INNER_ON_DEVICE_ENABLE_CHANGE__,e,t)}}),Object.defineProperty(r.prototype,"_createAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i,n,o,a,_;return y(this,(function(l){switch(l.label){case 0:return this._logger.info(M.L_RTC_MODULE_CREATE_AUDIO_TRACK_T,"",e),t=Object.assign(this._audioConfig,{micphoneId:this._audioConfig.microphoneId}),[4,this._rtcClient.createMicrophoneAudioTrack(Ne.NORMAL,t)];case 1:return r=l.sent(),i=r.code,n=r.track,i!==p.SUCCESS?(this._logger.error(M.L_RTC_MODULE_CREATE_AUDIO_TRACK_R,"errCode: ".concat(i),e),[2,{code:i}]):(this._logger.info(M.L_RTC_MODULE_CREATE_AUDIO_TRACK_R,"success",e),o=this._audioConfig,a=o.minBitrate,_=o.maxBitrate,(a||_)&&n.setBitrate(_,a),this._localTracks.push(n),this._onLocalTrackReady([n],e),[2,{code:D.SUCCESS,track:n}])}}))}))}}),Object.defineProperty(r.prototype,"_createVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i,n,o,a;return y(this,(function(_){switch(_.label){case 0:return this._logger.info(M.L_RTC_MODULE_CREATE_VIDEO_TRACK_T,"",e),[4,this._rtcClient.createCameraVideoTrack(Ne.NORMAL,this._videoConfig)];case 1:return t=_.sent(),r=t.code,i=t.track,r!==p.SUCCESS?(this._logger.error(M.L_RTC_MODULE_CREATE_VIDEO_TRACK_R,"errCode: ".concat(r),e),[2,{code:r}]):(this._logger.info(M.L_RTC_MODULE_CREATE_VIDEO_TRACK_R,"success",e),n=this._videoConfig,o=n.minBitrate,a=n.maxBitrate,(o||a)&&i.setBitrate(a,o),this._localTracks.push(i),this._onLocalTrackReady([i],e),[2,{code:D.SUCCESS,track:i}])}}))}))}}),Object.defineProperty(r.prototype,"getLocalVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return this._localTracks&&(e=P(this._localTracks.filter((function(e){return e.isVideoTrack()})),1)[0]),e}}),Object.defineProperty(r.prototype,"getLocalAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return this._localTracks&&(e=P(this._localTracks.filter((function(e){return e.isAudioTrack()})),1)[0]),e}}),Object.defineProperty(r.prototype,"publish",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r;return y(this,(function(i){switch(i.label){case 0:return this._logger.info(M.L_RTC_MODULE_PUBLISH_T,"tracksIds: ".concat(e.map((function(e){return e instanceof R?e.getTrackId():e.track.getTrackId()}))),t),[4,Ce({asyncFn:this._room.publish.bind(this._room),fnArgs:[e],onError:function(e){}})];case 1:return(r=i.sent().code)!==p.SUCCESS?(this._onRTCMethodFail(k.PUBLISH_ERR,t),this._logger.error(M.L_RTC_MODULE_PUBLISH_R,"errCode: ".concat(r),t),[2,{code:r}]):(this._logger.info(M.L_RTC_MODULE_PUBLISH_R,"code: ".concat(D.SUCCESS),t),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(r.prototype,"publishVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.getLocalVideoTrack(),t=this._isPubTiny?{track:e,isPubTiny:!0}:e;return this._room.publish([t])}}),Object.defineProperty(r.prototype,"setVideoView",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this,i=[];e.forEach((function(e){var t=e.userId,n=e.videoElement,o=e.isTiny,a=void 0!==o&&o;if(r._userViewMap[t]={videoView:n,isTiny:a},t!==r._context.getCurrentId()&&r._room){var _=(r.getRemoteTracks()[t]||[]).map((function(e){return{track:e,subTiny:a}})).filter((function(e){return!e.track.isSubscribed()}));i.push.apply(i,U([],P(_),!1))}})),this._logger.info(M.L_RTC_MODULE_SET_VIDEO_VIEW_O,JSON.stringify({userViewMap:Q(this._userViewMap),needSubTrackIds:i.map((function(e){return e.track.getTrackId()}))}),t),i.length&&this.subscribeTracks(i,t)}}),Object.defineProperty(r.prototype,"removeVideoView",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this,i=[];e.forEach((function(e){var t=r.getRemoteTracks()[e];if(t&&t.length){var n=t.filter((function(e){return e.isVideoTrack()}));n.length&&i.push(n[0])}delete r._userViewMap[e]})),this._logger.info(M.L_RTC_MODULE_REMOVE_VIDEO_VIEW_O,JSON.stringify({userViewMap:Q(this._userViewMap),unsubTracks:i.map((function(e){return e.getTrackId()}))}),t),i.length&&this.unsubscribeTracks(i,t)}}),Object.defineProperty(r.prototype,"getUserViewMap",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._userViewMap}}),Object.defineProperty(r.prototype,"playMedia",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){var n;return v(this,void 0,void 0,(function(){var o,a,_,l,s;return y(this,(function(c){switch(c.label){case 0:if(this._logger.info(M.L_RTC_MODULE_PLAY_MEDIA_T,"userId: ".concat(e,", mediaType: ").concat(t,", videoView: ").concat(null==r?void 0:r.nodeName),i),o=this._context.getCurrentId(),e===o&&t===G.AUDIO)return this._logger.error(M.L_RTC_MODULE_PLAY_MEDIA_R,"please avoid playing local audio to prevent echoes.",i),[2,{code:D.PLAY_MEDIA_FAILED}];if(a=null,!(a=e===o?t===G.AUDIO?null:this.getLocalVideoTrack():null===(n=this.getRemoteTracks()[e])||void 0===n?void 0:n.filter((function(e){return t===G.AUDIO?e.isAudioTrack():e.isVideoTrack()}))[0]))return this._logger.error(M.L_RTC_MODULE_PLAY_MEDIA_R,"error code: ".concat(D.MEDIA_RESOURCE_INVALIED),i),[2,{code:D.MEDIA_RESOURCE_INVALIED}];c.label=1;case 1:return c.trys.push([1,6,,7]),a.isAudioTrack()?[4,a.play(void 0,{audioDeviceId:this._audioOutputDeviceId||void 0})]:[3,3];case 2:return l=c.sent(),[3,5];case 3:return[4,a.play(r)];case 4:l=c.sent(),c.label=5;case 5:return _=l.code,a.isAudioTrack()&&!this._remoteAudioEnable&&a.mute(),_!==p.SUCCESS?(this._logger.error(M.L_RTC_MODULE_PLAY_MEDIA_R,"errCode: ".concat(_),i),[2,{code:_}]):(this._logger.info(M.L_RTC_MODULE_PLAY_MEDIA_R,"success",i),[2,{code:D.SUCCESS}]);case 6:return s=c.sent(),this._logger.error(M.L_RTC_MODULE_PLAY_MEDIA_R,"errCode: ".concat(D.PLAY_MEDIA_FAILED,", message: ").concat(s.message,","),i),[2,{code:D.PLAY_MEDIA_FAILED}];case 7:return[2]}}))}))}}),Object.defineProperty(r,"__INNER_RTC_PROCESS_FAILED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-rtc-process-failed"}),Object.defineProperty(r,"__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-rtc-peerconnection-abnormal-close"}),Object.defineProperty(r,"__INNER_ON_SELF_JOINED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-on-self-joined"}),Object.defineProperty(r,"__INNER_ON_OTHER_JOINED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-on-other-joined"}),Object.defineProperty(r,"__INNER_RECEIVE_FIRST_FRAME__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-receive-first-frame"}),Object.defineProperty(r,"__INNER_ON_KICKOFF__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-kickoff-frame"}),Object.defineProperty(r,"__INNER_ON_DEVICE_ENABLE_CHANGE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-on-device-enable-change"}),r}(n),Pe=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,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];return v(this,void 0,void 0,(function(){var i,n;return y(this,(function(o){switch(o.label){case 0:if(!(i=null===(t=this._listener)||void 0===t?void 0:t[e]))return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,i.apply(void 0,U([],P(r),!1))];case 2:return o.sent(),[3,4];case 3:return n=o.sent(),console.error(n),this._logger.error(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({name:n.name,message:n.message})),[3,4];case 4:return[2]}}))}))}}),Object.defineProperty(e.prototype,"onReceivedCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCall",callId:e.getCallId()}),t),this._callAppListener("onReceivedCall",e,r)}}),Object.defineProperty(e.prototype,"onRemoteUserInvited",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteUserInvited",inviteeUserList:e,inviterUserId:t,callId:r})),this._callAppListener("onRemoteUserInvited",e,t,r)}}),Object.defineProperty(e.prototype,"onCallConnected",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallConnected",callId:e.getCallId()})),this._callAppListener("onCallConnected",e)}}),Object.defineProperty(e.prototype,"onCallTypeChanged",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallTypeChanged",callId:t,callType:e}),r),this._callAppListener("onCallTypeChanged",e,t)}}),Object.defineProperty(e.prototype,"onRemoteUserStateChanged",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=e.callId,i=e.userId,n=e.userState,o=e.reason;this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteUserStateChanged",callId:r,userId:i,userState:n,reason:o}),t),this._callAppListener("onRemoteUserStateChanged",r,i,n,o)}}),Object.defineProperty(e.prototype,"onCallEnded",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallEnded",callId:e.getCallId(),closeReason:t}),r),this._callAppListener("onCallEnded",e,t)}}),Object.defineProperty(e.prototype,"onRemoteCameraStateChanged",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteCameraStateChanged",callId:e,trackId:null==t?void 0:t.getTrackId(),enable:null==t?void 0:t.isOwnerMuted()}));var r=null==t?void 0:t.getUserId();this._callAppListener("onRemoteCameraStateChanged",e,r,null==t?void 0:t.isOwnerMuted())}}),Object.defineProperty(e.prototype,"onRemoteMicrophoneStateChanged",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteMicrophoneStateChanged",callId:e,trackId:null==t?void 0:t.getTrackId(),enable:null==t?void 0:t.isOwnerMuted()}));var r=null==t?void 0:t.getUserId();this._callAppListener("onRemoteMicrophoneStateChanged",e,r,null==t?void 0:t.isOwnerMuted())}}),Object.defineProperty(e.prototype,"onReceivedCallRecord",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallRecord",record:e}),t),this._callAppListener("onReceivedCallRecord",e)}}),Object.defineProperty(e.prototype,"onReceivedChangeMediaTypeRequest",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedChangeMediaTypeRequest",userId:e,transactionId:t}),i),this._callAppListener("onReceivedChangeMediaTypeRequest",e,t,r)}}),Object.defineProperty(e.prototype,"onReceivedChangeMediaTypeResult",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=e.userId,i=e.transactionId,n=e.mediaType,o=e.code;this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedChangeMediaTypeResult",userId:r,mediaType:n}),t),this._callAppListener("onReceivedChangeMediaTypeResult",{userId:r,transactionId:i,mediaType:n,code:o})}}),Object.defineProperty(e.prototype,"onReceivedCallStartTime",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallStartTime",info:e}),t),this._callAppListener("onReceivedCallStartTime",e)}}),Object.defineProperty(e.prototype,"onReceivedCallFirstFrameTime",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallFirstFrameTime",callId:e,callFirstFrameTime:t}),r),this._callAppListener("onReceivedCallFirstFrameTime",e,t)}}),Object.defineProperty(e.prototype,"onUserMediaAvailable",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onUserMediaAvailable",trackIds:e.map((function(e){return e.getTrackId()}))}),t),e.forEach((function(e){var t=e.getUserId(),i=e.isAudioTrack()?G.AUDIO:G.VIDEO;r._callAppListener("onUserMediaAvailable",t,i)}))}}),Object.defineProperty(e.prototype,"onFetchRemoteMediaError",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;e.forEach((function(e){var i=e.track.getUserId();r._callAppListener("onFetchRemoteMediaError",i,t)}))}}),Object.defineProperty(e.prototype,"onUserAudioLevelChanged",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;e.forEach((function(e){var r=e.track,i=e.audioLevel,n=r.getUserId();t._callAppListener("onUserAudioLevelChanged",n,i)}))}}),Object.defineProperty(e.prototype,"onReceivedCallPlusSummaryMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._callAppListener("onReceivedCallPlusSummaryMessage",e)}}),e}();!function(e){e[e.UNKNOW_ERR=41e3]="UNKNOW_ERR",e[e.DB_ERR=41001]="DB_ERR",e[e.JSON_ERR=41002]="JSON_ERR",e[e.INVALID_JSON_ERR=41003]="INVALID_JSON_ERR",e[e.MISSING_PARAMS=41004]="MISSING_PARAMS",e[e.PARAMS_REQUIRED=41005]="PARAMS_REQUIRED",e[e.DATA_FORMAT_ERR=41006]="DATA_FORMAT_ERR",e[e.METHOD_NOT_IMPLEMENTED=41007]="METHOD_NOT_IMPLEMENTED",e[e.CALL_NOT_EXIST=41010]="CALL_NOT_EXIST",e[e.SINGAL_EXCEED_TWO_INVITEE=41011]="SINGAL_EXCEED_TWO_INVITEE",e[e.GROUP_EXCEEDS_QUORUM=41012]="GROUP_EXCEEDS_QUORUM",e[e.OPERATION_EXPIRED=41013]="OPERATION_EXPIRED",e[e.DEVICE_IS_CALLING=41014]="DEVICE_IS_CALLING",e[e.REPORT_STREAM_READY_TIME_IS_INVALID=41018]="REPORT_STREAM_READY_TIME_IS_INVALID",e[e.NOT_CALL_YOURSELF=41019]="NOT_CALL_YOURSELF",e[e.SESSION_STATUS_NOT_EXIST=41020]="SESSION_STATUS_NOT_EXIST",e[e.HANGUP_NOT_ALLOW=41021]="HANGUP_NOT_ALLOW",e[e.ACCEPT_NOT_ALLOW=41022]="ACCEPT_NOT_ALLOW",e[e.OPERATION_NOT_ALLOW=41025]="OPERATION_NOT_ALLOW",e[e.TRANSACTION_ID_ERR=41100]="TRANSACTION_ID_ERR",e[e.UP_VIDEO_CANCELED=41050]="UP_VIDEO_CANCELED",e[e.CURRENT_CALL_IS_AUDIO=41051]="CURRENT_CALL_IS_AUDIO",e[e.CURRENT_CALL_IS_VIDEO=41052]="CURRENT_CALL_IS_VIDEO"}(ve||(ve={}));var Ue=function(){function e(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_androidPushConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}})}return Object.defineProperty(e.prototype,"setChannelIdMi",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.channelIdMi=e,this):(this._logger.error(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: channelIdMi type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setMiLargeIconUrl",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._logger.warn(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"`setMiLargeIconUrl` has been deprecated."),this}}),Object.defineProperty(e.prototype,"setChannelIdHW",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.channelIdHW=e,this):(this._logger.error(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: channelIdHW type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setCategoryHW",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.categoryHW=e,this):(this._logger.error(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: categoryHW type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setImportanceHW",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return"LOW"!==e&&"NORMAL"!==e?(this._logger.error(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: importanceHW value is NORMAL|LOW, value: ".concat(e)),this):(this._androidPushConfig.importanceHW=e,this)}}),Object.defineProperty(e.prototype,"setImageUrlHW",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.imageUrlHW=e,this):(this._logger.error(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: imageUrlHW type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setChannelIdOPPO",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.channelIdOPPO=e,this):(this._logger.error(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: channelIdOPPO type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setTypeVivo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.typeVivo=e,this):(this._logger.error(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: typeVivo type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setCategoryVivo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.categoryVivo=e,this):(this._logger.error(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: categoryVivo type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setFcmChannelId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.fcmChannelId=e,this):(this._logger.error(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: fcmChannelId type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setFcmCollapseKey",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.fcmCollapseKey=e,this):(this._logger.error(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: fcmCollapseKey type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setFcmImageUrl",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.fcmImageUrl=e,this):(this._logger.error(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: fcmImageUrl type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setimportanceHonor",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return"LOW"!==e&&"NORMAL"!==e?(this._logger.error(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: importanceHonor value is NORMAL|LOW, value: ".concat(e)),this):(this._androidPushConfig.importanceHonor=e,this)}}),Object.defineProperty(e.prototype,"setimageUrlHonor",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.imageUrlHonor=e,this):(this._logger.error(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: imageUrlHonor type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"build",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._androidPushConfig}}),e}(),Me=function(){function n(e,t,r,i){var n=this;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,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:f.W640_H480,frameRate:S.FPS_15}}),Object.defineProperty(this,"_audioConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_callPlusStatistics",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_clientCallId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_isLaunchHangup",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_needHangupCallId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_rtcModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._reportAppEventModule=new Pe(t),this._callPlusStatistics=new _e(this._logger,this._context),this._callEngine=new me(this._context,this._runtime,this._initOpts,this._logger,this._reportAppEventModule),this._rtcModule=new ye(this._context,this._runtime,this._initOpts,this._logger,this._callEngine,this._reportAppEventModule),this._rtcModule.on(ye.__INNER_RTC_PROCESS_FAILED__,this._rtcProcessFailHandle.bind(this)),this._rtcModule.on(ye.__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__,this._peerConnectionAbnormalClose.bind(this)),this._rtcModule.on(ye.__INNER_ON_SELF_JOINED__,this._selfJoinedHandle.bind(this)),this._rtcModule.on(ye.__INNER_ON_OTHER_JOINED__,this._otherJoinedHandle.bind(this)),this._rtcModule.on(ye.__INNER_RECEIVE_FIRST_FRAME__,this._receiveFirstFrameHandle.bind(this)),this._rtcModule.on(ye.__INNER_ON_KICKOFF__,this._kickoffHandle.bind(this)),this._rtcModule.on(ye.__INNER_ON_DEVICE_ENABLE_CHANGE__,this._receiveDeviceEnableChangeHandle.bind(this)),this._callEngine.on(me.__INNER_SESSION_CONNECT__,this._rtcModule.sessionConnected.bind(this._rtcModule)),this._callEngine.on(me.__INNER_SESSION_CLOSE__,this._sessionCloseHandle.bind(this)),this._callEngine.on(me.__INNER_CHANGE_MEDIA_TYPE__,this._rtcModule.changeMediaType.bind(this._rtcModule)),this._callEngine.on(me.__INNER_INVITE__,(function(e,t){n._callPlusStatistics.reportStatisticsData(x.L_QS_RECEIVE_CALL_S,D.SUCCESS,+new Date,e,"",t)}))}return Object.defineProperty(n.prototype,"_rtcProcessFailHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this._callEngine.getLocalMainSession();if(r){var i=r.getCallId();this._callEngine.systemStatusUp({callId:i,sysStatus:e,forward:be.CURRENT},t),this._callPlusStatistics.reportStatisticsData(x.L_QS_ABNORMAL_HANGUP_S,D.SUCCESS,+new Date,r),this.__innerHangup({callId:i,systemState:e},t)}}}),Object.defineProperty(n.prototype,"_peerConnectionAbnormalClose",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._callEngine.getLocalMainSession();t&&(this._callEngine.systemStatusUp({callId:t.getCallId(),sysStatus:k.CONNECTION_ERR,forward:be.CURRENT},e),this._callEngine.endCurrentSession(k.CONNECTION_ERR,t.getCallId(),e))}}),Object.defineProperty(n.prototype,"_selfJoinedHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i,n,o,a,_,l;return y(this,(function(s){return r=this._context.getCurrentId(),i=this._callEngine.getLocalMainSession(),this._reportAppEventModule.onCallConnected(i),n=this._rtcModule.getLocalVideoTrack(),o=this._rtcModule.getLocalAudioTrack(),a=!!n&&!n.isOwnerMuted(),_=!!o&&!o.isOwnerMuted(),this._callEngine.setUserDeviceEnable(r,G.VIDEO,a,t),this._callEngine.setUserDeviceEnable(r,G.AUDIO,_,t),l=[{userId:r,userState:j.ONCALL,systemState:k.ONCALL,cameraEnable:a,microphoneEnable:_}],this._callEngine.updateUsersState(e,l,t),this._callEngine.startTimeCorrection(t),[2]}))}))}}),Object.defineProperty(n.prototype,"_otherJoinedHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,i="",n=e.map((function(e){return i=e.callId,{userId:e.userId,userState:j.ONCALL,systemState:k.ONCALL,cameraEnable:!1,microphoneEnable:!1}}));this._callEngine.updateUsersState(i,n,t),(null===(r=this._callEngine.getLocalMainSession())||void 0===r?void 0:r.getState())!==V.ONCALL&&this._callEngine.updateMainSessionState(V.ONCALL)}}),Object.defineProperty(n.prototype,"_receiveFirstFrameHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;(null===(t=this._callEngine.getLocalMainSession())||void 0===t?void 0:t.getState())!==V.ONCALL&&this._callEngine.updateMainSessionState(V.ONCALL),this._callEngine.upFirstFrameTime(e)}}),Object.defineProperty(n.prototype,"_kickoffHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){if(e!==k.CONNECTION_ERR){var i=this._callEngine.getLocalMainSession();if(i){var n=i.getCallId();this._callPlusStatistics.reportStatisticsData(x.L_QS_ABNORMAL_HANGUP_S,D.SUCCESS,+new Date,i,this._clientCallId),this._callEngine.systemStatusUp({callId:n,sysStatus:e,forward:be.CURRENT},r),this._callEngine.endCurrentSession(e,t,r)}}else this._callEngine.endCurrentSession(e,t,r)}}),Object.defineProperty(n.prototype,"_receiveDeviceEnableChangeHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;e.forEach((function(e){var i=e.getUserId(),n=e.isAudioTrack()?G.AUDIO:G.VIDEO;r._callEngine.setUserDeviceEnable(i,n,!e.isOwnerMuted(),t)}))}}),Object.defineProperty(n.prototype,"_sessionCloseHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._isLaunchHangup||(this._clientCallId=""),this._isLaunchHangup=!1,this._rtcModule.sessionClose(e,t)}}),Object.defineProperty(n.prototype,"setCallPlusEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(M.L_CALLPLUS_CLIENT_SET_EVENT_LISTENER_O,e?Object.keys(e).join(","):null),this._reportAppEventModule.registerEventListener(e)}}),Object.defineProperty(n.prototype,"setStatusReportListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(M.L_CALLPLUS_CLIENT_SET_STATUS_REPORT_LISTENER_O,e?Object.keys(e).join(","):null),this._rtcModule.setCallPlusStatusReportListener(e)}}),Object.defineProperty(n.prototype,"setVideoView",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r,i,n=this._logger.createTraceId();if(this._logger.info(M.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_T,JSON.stringify({list:e.map((function(e){var t=e.userId,r=e.videoElement,i=e.isTiny;return{userId:t,elementName:null==r?void 0:r.nodeName,isTiny:i}}))}),n),!E(e))return this._logger.error(M.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,"params err, list: not empty array, value: ".concat(JSON.stringify(e)),n),{code:D.PARAM_ERROR};try{for(var o=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e),a=o.next();!a.done;a=o.next()){var _=a.value,l=_.userId,s=_.videoElement;if(!C(l))return this._logger.error(M.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,"params err, userId: not empty string, value: ".concat(l),n),{code:D.PARAM_ERROR};if(!(i=s)||!i.nodeName||"VIDEO"!==i.nodeName.toUpperCase())return this._logger.error(M.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,"params err, videoElement: need a video element, value: ".concat(s instanceof HTMLElement?s.nodeName:s),n),{code:D.PARAM_ERROR}}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return this._logger.info(M.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,"succes",n),this._rtcModule.setVideoView(e,n),{code:D.SUCCESS}}}),Object.defineProperty(n.prototype,"removeVideoView",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._logger.createTraceId();return this._logger.info(M.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_T,JSON.stringify({userIds:e}),t),E(e)&&e.every((function(e){return C(e)}))?(this._logger.info(M.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R,"succes",t),this._rtcModule.removeVideoView(e,t),{code:D.SUCCESS}):(this._logger.error(M.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R,"params err, userIds: not empty array, userId: not empty string, value: ".concat(JSON.stringify(e)),t),{code:D.PARAM_ERROR})}}),Object.defineProperty(n.prototype,"playMedia",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var i,n;return y(this,(function(o){return i=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_PLAY_MEDIA_T,JSON.stringify({userId:e,mediaType:t}),i),C(e)?r(G[t])?(this._logger.error(M.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,"params err, mediaType is illegal, value: ".concat(t),i),[2,{code:D.PARAM_ERROR}]):t===G.AUDIO&&e===this._context.getCurrentId()?(this._logger.info(M.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,"success",i),[2,{code:D.SUCCESS}]):(n=(this._rtcModule.getUserViewMap()[e]||{}).videoView,t===G.AUDIO||n?[2,this._rtcModule.playMedia(e,t,n,i)]:(this._logger.error(M.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,"errCode: ".concat(D.VIDEO_VIEW_NOT_SET,", video view not set"),i),[2,{code:D.VIDEO_VIEW_NOT_SET}])):(this._logger.error(M.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,"params err, userId: not empty string, value: ".concat(e),i),[2,{code:D.PARAM_ERROR}])}))}))}}),Object.defineProperty(n.prototype,"createVideoConfigBuilder",{enumerable:!1,configurable:!0,writable:!0,value:function(){return new Y(this._logger)}}),Object.defineProperty(n.prototype,"setVideoConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(M.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_T,JSON.stringify(e));var t=e.frameRate,r=e.resolution,i=e.maxBitrate,n=e.minBitrate;if(!S[t])return this._logger.error(M.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,"param error, frameRate is illegal, value: ".concat(t)),{code:D.PARAM_ERROR};if(!f[r])return this._logger.error(M.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,"param error, resolution is illegal, value: ".concat(r)),{code:D.PARAM_ERROR};var o=K(n,i),a=o.code,_=o.errorMsg;return a!==D.SUCCESS&&this._logger.error(M.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,_),this._logger.info(M.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,"success"),this._videoConfig=m({},e),this._rtcModule.setVideoConfig(this._videoConfig),{code:D.SUCCESS}}}),Object.defineProperty(n.prototype,"createAudioConfigBuilder",{enumerable:!1,configurable:!0,writable:!0,value:function(){return new F(this._logger)}}),Object.defineProperty(n.prototype,"createAndroidPushConfigBuilder",{enumerable:!1,configurable:!0,writable:!0,value:function(){return new Ue(this._logger)}}),Object.defineProperty(n.prototype,"setAudioConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this._logger.info(M.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_T,JSON.stringify(t));var r=t.sampleRate,i=t.minBitrate,n=t.maxBitrate;if(r&&!e(r))return this._logger.error(M.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,"param error, sampleRate: type is number, value: ".concat(r)),{code:D.PARAM_ERROR};var o=K(i,n),a=o.code,_=o.errorMsg;return a!==D.SUCCESS&&this._logger.error(M.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,_),this._logger.info(M.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,"success"),this._audioConfig=m({},t),this._rtcModule.setAudioConfig(this._audioConfig),{code:D.SUCCESS}}}),Object.defineProperty(n.prototype,"setAudioOutputDeviceId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._logger.info(M.L_CALLPLUS_CLIENT_SET_AUDIO_OUTPUT_DEVICE_ID_O,e),this._rtcModule.setAudioOutputDeviceId(e)}}),Object.defineProperty(n.prototype,"startCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,o,_){return void 0===t&&(t=w.SINGLE),void 0===n&&(n=G.AUDIO_VIDEO),v(this,void 0,void 0,(function(){var l,c,u,L,d,T,I,g,S,f,p;return y(this,(function(h){switch(h.label){case 0:if(this._clientCallId=s(),l=+new Date,c=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_START_CALL_T,"userIds: ".concat(e.join(","),", callType: ").concat(t,", mediaType: ").concat(n,", pushConfig: ").concat(o,", extra: ").concat(_),c),this._context.getConnectionStatus()!==a.CONNECTED)return this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"errCode: ".concat(D.SIGNAL_DISCONNECTED),c),[2,{code:D.SIGNAL_DISCONNECTED}];if(!(u=this._context.getNaviInfo())||!W(u))return this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"errCode: ".concat(D.RTC_SERVICE_UNAVAILABLE),c),[2,{code:D.RTC_SERVICE_UNAVAILABLE}];if(!E(e)||!e.every((function(e){return C(e)})))return this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"params err, userIds: not empty array, userId: not empty string, value: ".concat(JSON.stringify(e)),c),[2,{code:D.PARAM_ERROR}];if(r(w[t]))return this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"params err, callType is illegal, value: ".concat(t),c),[2,{code:D.PARAM_ERROR}];if(r(G[n]))return this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"params err, mediaType is illegal, value: ".concat(n),c),[2,{code:D.PARAM_ERROR}];if(o&&(L=z(o)).code!==D.SUCCESS)return this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"params err, pushConfig is illegal, msg: ".concat(L.errorMsg),c),[2,{code:D.PARAM_ERROR}];if(_){if(!i(_))return this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"params err, extra is illegal, value: ".concat(_),c),[2,{code:D.PARAM_ERROR}];if(ee(_)>ge)return this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"params err, extra max size is 128KB",c),[2,{code:D.PARAM_ERROR}]}return e.length>1&&t===w.SINGLE?(this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"params err, You can only call one person in a single call, userIds: ".concat(e.join(",")),c),[2,{code:D.PARAM_ERROR}]):this._callEngine.getLocalMainSession()?(this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"errCode: ".concat(D.SESSION_EXIST,", session exist"),c),[2,{code:D.SESSION_EXIST}]):[4,this._rtcModule.createCallMediaTracks(n,c)];case 1:return(d=h.sent().code)!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"create meida tracks error code: ".concat(d),c),[2,{code:d}]):[4,this._callEngine.startCall({toUsers:e.map((function(e){return{userId:e}})),callType:t,mediaType:n,callId:this._clientCallId,pushConfig:o,extra:JSON.stringify({userId:this._context.getCurrentId(),extra:_})},c)];case 2:return T=h.sent(),I=T.code,g=T.data,this._callPlusStatistics.reportStatisticsData(x.L_QS_START_CALL_S,I,l,null,this._clientCallId,null,{mediaType:n,callType:t,callId:(null==g?void 0:g.callId)||""}),I!==D.SUCCESS?(this._rtcModule.destroyAllTracks(c),this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"signal error code: ".concat(I),c),[2,{code:I}]):(f=(S=g).callId,p=S.clientCallId,this._needHangupCallId===p?(this._callEngine.clearAllTimer(f,c),this._callEngine.hangup({callId:f,systemState:k.CANCELLED},c),this._logger.info(M.L_CALLPLUS_CLIENT_START_CALL_R,"the ".concat(f," call has been hangup"),c),[2,{code:D.SUCCESS}]):(t===w.MULTI&&this._rtcModule.sessionConnected(f,c),this._logger.info(M.L_CALLPLUS_CLIENT_START_CALL_R,JSON.stringify({data:g,code:I}),c),[2,{code:D.SUCCESS,callId:f}]))}}))}))}}),Object.defineProperty(n.prototype,"joinMultiCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i,n,o,_,l,s,c;return y(this,(function(u){switch(u.label){case 0:return t=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_T,"callId: ".concat(e),t),this._context.getConnectionStatus()!==a.CONNECTED?(this._logger.error(M.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"code: ".concat(D.SIGNAL_DISCONNECTED),t),[2,{code:D.SIGNAL_DISCONNECTED}]):(r=this._context.getNaviInfo())&&W(r)?C(e)?[4,this._callEngine.getCallSession({callId:e},t)]:(this._logger.error(M.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"params err, callId: not empty string, value: ".concat(e),t),[2,{code:D.PARAM_ERROR}]):(this._logger.error(M.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"code: ".concat(D.RTC_SERVICE_UNAVAILABLE),t),[2,{code:D.RTC_SERVICE_UNAVAILABLE}]);case 1:return i=u.sent(),n=i.code,o=i.data,n!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"get call data error, code: ".concat(n),t),[2,{code:n}]):(_=o.mediaType,(l=this._callEngine.getLocalMainSession())&&l.getCallId()!==e?[2,{code:D.SESSION_EXIST}]:[4,this._rtcModule.createCallMediaTracks(_,t)]);case 2:return(s=u.sent().code)!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"create meida tracks error code: ".concat(s),t),[2,{code:s}]):[4,this._callEngine.joinCall({callId:e,mediaType:_},t)];case 3:return(c=u.sent().code)!==D.SUCCESS?(this._rtcModule.destroyAllTracks(t),this._logger.error(M.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"signal error code: ".concat(c),t),[2,{code:c}]):(this._logger.info(M.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"code: ".concat(D.SUCCESS),t),[4,this._rtcModule.sessionConnected(e,t)]);case 4:return u.sent(),[2,{code:D.SUCCESS}]}}))}))}}),Object.defineProperty(n.prototype,"invite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n;return v(this,void 0,void 0,(function(){var o,a,_,l,s,c;return y(this,(function(u){switch(u.label){case 0:if(o=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_INVITE_T,"callId: ".concat(e.join(","),", pushConfig: ").concat(t,", extra: ").concat(r),o),!E(e)||!e.every((function(e){return C(e)})))return this._logger.error(M.L_CALLPLUS_CLIENT_INVITE_R,"params err, userIds: not empty array, userId: not empty string, value: ".concat(JSON.stringify(e)),o),[2,{code:D.PARAM_ERROR}];if(t&&(a=z(t)).code!==D.SUCCESS)return this._logger.error(M.L_CALLPLUS_CLIENT_INVITE_R,"params err, pushConfig is illegal, msg: ".concat(a.errorMsg),o),[2,{code:D.PARAM_ERROR}];if(r){if(!i(r))return this._logger.error(M.L_CALLPLUS_CLIENT_INVITE_R,"params err, extra is illegal, value: ".concat(r),o),[2,{code:D.PARAM_ERROR}];if(ee(r)>ge)return this._logger.error(M.L_CALLPLUS_CLIENT_INVITE_R,"params err, extra max size is 128KB",o),[2,{code:D.PARAM_ERROR}]}return[4,this._callEngine.invite({toUsers:e.map((function(e){return{userId:e}})),pushConfig:t,extra:JSON.stringify({userId:this._context.getCurrentId(),extra:r})},o)];case 1:return _=u.sent(),l=_.code,s=_.data,l!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_INVITE_R,"signal error code: ".concat(l),o),[2,{code:l}]):(c=[],(null===(n=s.busylineUsers)||void 0===n?void 0:n.length)&&c.push.apply(c,U([],P(s.busylineUsers.map((function(e){return{userId:e.userId,state:e.sessionStatus}}))),!1)),this._logger.info(M.L_CALLPLUS_CLIENT_INVITE_R,"success busyUsers: ".concat(JSON.stringify(c)),o),[2,{code:D.SUCCESS,busyUsers:c}])}}))}))}}),Object.defineProperty(n.prototype,"accept",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i,n,o,_,l,s,c,u,L;return y(this,(function(d){switch(d.label){case 0:return r=+new Date,i=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_ACCEPT_T,"callId: ".concat(e,", pushConfig: ").concat(t),i),this._context.getConnectionStatus()!==a.CONNECTED?(this._logger.error(M.L_CALLPLUS_CLIENT_ACCEPT_R,"errCode: ".concat(D.SIGNAL_DISCONNECTED),i),[2,{code:D.SIGNAL_DISCONNECTED}]):(n=this._context.getNaviInfo())&&W(n)?C(e)?t&&(o=z(t)).code!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_ACCEPT_R,"params err, pushConfig is illegal, msg: ".concat(o.errorMsg),i),[2,{code:D.PARAM_ERROR}]):(_=this._callEngine.getLocalMainSession(),l=this._callEngine.getHoldSession(e),_||l?e===(null==l?void 0:l.getCallId())?[4,this.hangup(_.getCallId())]:[3,2]:(this._logger.error(M.L_CALLPLUS_CLIENT_ACCEPT_R,"errCode : ".concat(D.NOT_IN_CALL,", session not exist"),i),[2,{code:D.NOT_IN_CALL}])):(this._logger.error(M.L_CALLPLUS_CLIENT_ACCEPT_R,"params err, callId: not empty string, value: ".concat(e),i),[2,{code:D.PARAM_ERROR}]):(this._logger.error(M.L_CALLPLUS_CLIENT_ACCEPT_R,"errCode: ".concat(D.RTC_SERVICE_UNAVAILABLE),i),[2,{code:D.RTC_SERVICE_UNAVAILABLE}]);case 1:if((s=d.sent().code)!==D.SUCCESS)return this._logger.error(M.L_CALLPLUS_CLIENT_ACCEPT_R,"hangup mainSession error code: ".concat(s),i),[2,{code:s}];this._callEngine.upgradeMainSession(e),_=this._callEngine.getLocalMainSession(),d.label=2;case 2:return c=_.getMediaType(),[4,this._rtcModule.createCallMediaTracks(c,i)];case 3:return(u=d.sent().code)!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_ACCEPT_R,"create meida tracks error code: ".concat(u),i),[2,{code:u}]):[4,this._callEngine.accept({callId:e},i)];case 4:return L=d.sent().code,this._callPlusStatistics.reportStatisticsData(x.L_QS_ACCEPT_CALL_S,L,r,_),L!==D.SUCCESS?(this._rtcModule.destroyAllTracks(i),this._logger.error(M.L_CALLPLUS_CLIENT_ACCEPT_R,"signal error code: ".concat(L),i),[2,{code:L}]):(this._logger.info(M.L_CALLPLUS_CLIENT_ACCEPT_R,"success",i),this._rtcModule.sessionConnected(e,i),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(n.prototype,"__innerHangup",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;return v(this,void 0,void 0,(function(){var i,n;return y(this,(function(o){switch(o.label){case 0:return i=e.callId,this._callEngine.setIsLocalClientHangup(!0),this._callEngine.clearAllTimer(i,t),[4,this._callEngine.hangup(e,t)];case 1:return(n=o.sent().code)===ve.CALL_NOT_EXIST?[2,{code:D.SUCCESS}]:n!==D.SUCCESS||i!==(null===(r=this._callEngine.getLocalMainSession())||void 0===r?void 0:r.getCallId())?[3,3]:[4,this._rtcModule.sessionClose(i,t)];case 2:o.sent(),o.label=3;case 3:return[2,{code:n}]}}))}))}}),Object.defineProperty(n.prototype,"hangup",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,n,o,a,_,l,s,c,u,L,d,E;return y(this,(function(C){switch(C.label){case 0:return r=+new Date,n=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_HANGUP_T,"callId: ".concat(e,", pushConfig: ").concat(t),n),(o=this._callEngine.getLocalMainSession())?e&&!i(e)?(this._logger.error(M.L_CALLPLUS_CLIENT_HANGUP_R,"params err, callId: type is string, value: ".concat(e),n),[2,{code:D.PARAM_ERROR}]):t&&(a=z(t)).code!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_HANGUP_R,"params err, pushConfig is illegal, msg: ".concat(a.errorMsg),n),[2,{code:D.PARAM_ERROR}]):(_=o.getCallId(),e&&e!==_&&!this._callEngine.getHoldSession(e)?(this._logger.error(M.L_CALLPLUS_CLIENT_HANGUP_R,"params err, callId is invalid, value: ".concat(e),n),[2,{code:D.CALL_ID_INVALID}]):(this._isLaunchHangup=!0,this._needHangupCallId=e||_,l=this._callEngine.getHoldSession(this._needHangupCallId),s=l||o,c=this._context.getCurrentId(),u=o.getUserList().filter((function(e){return e.userId===c}))[0].state,L=[o.getCreatorUserId(),o.getInviterUserId()].includes(c),d=function(e,t){var r;switch(e){case j.CALLING:r=k.CANCELLED;break;case j.RINGING:case j.INVITED:r=k.DECLINED;break;case j.CONNECTING:r=t?k.DECLINED:k.CANCELLED;break;case j.ONCALL:r=k.ENDED}return r}(u,L)||k.ENDED,[4,this.__innerHangup({callId:this._needHangupCallId,systemState:d,pushConfig:t},n)])):[2,{code:D.NOT_IN_CALL}];case 1:return E=C.sent().code,this._callPlusStatistics.reportStatisticsData(x.L_QS_HANGUP_CALL_S,E,r,s,this._clientCallId),E!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_HANGUP_R,"signal error code : ".concat(E),n),[2,{code:E}]):(this._needHangupCallId=null,this._logger.info(M.L_CALLPLUS_CLIENT_HANGUP_R,"success",n),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(n.prototype,"requestChangeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,i,n,o,a,_,l,s=this;return y(this,(function(c){switch(c.label){case 0:return t=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_T,"mediaType: ".concat(e),t),r(G[e])?(this._logger.error(M.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,"params err, mediaType is illegal, value: ".concat(e),t),[2,{code:D.PARAM_ERROR}]):(i=this.getCurrentCallSession(),n=null==i?void 0:i.getMediaType(),e===n?(this._logger.error(M.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,"error code: ".concat(D.MEDIATYPE_INVALID),t),[2,{code:D.MEDIATYPE_INVALID}]):this._callEngine.getLocalMainSession()?(o=null==i?void 0:i.getUserList().filter((function(e){return e.userId!==s._context.getCurrentId()})).map((function(e){return e.userId})),[4,this._callEngine.requestChangeMediaType({mediaType:e,toUserIds:o||[]},t)]):(this._logger.error(M.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,"error code : ".concat(D.NOT_IN_CALL,", session not exist"),t),[2,{code:D.NOT_IN_CALL}]));case 1:return a=c.sent(),_=a.code,l=a.data,_!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,"signal error code: ".concat(_),t),[2,{code:_}]):(this._logger.info(M.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,"success transactionId: ".concat(l.transactionId),t),[2,{code:D.SUCCESS,transactionId:l.transactionId}])}}))}))}}),Object.defineProperty(n.prototype,"cancelChangeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r;return y(this,(function(i){switch(i.label){case 0:return t=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_T,"transactionId: ".concat(e),t),C(e)?this._callEngine.getLocalMainSession()?[4,this._callEngine.cancelChangeMediaType({transactionId:e},t)]:(this._logger.error(M.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,"error code : ".concat(D.NOT_IN_CALL,", session not exist"),t),[2,{code:D.NOT_IN_CALL}]):(this._logger.error(M.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,"param error, transactionId: not empty string, value: ".concat(e),t),[2,{code:D.PARAM_ERROR}]);case 1:return(r=i.sent().code)!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,"signal error code: ".concat(r),t),[2,{code:r}]):(this._logger.info(M.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,"success",t),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(n.prototype,"replyChangeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){return v(this,void 0,void 0,(function(){var i,n;return y(this,(function(o){switch(o.label){case 0:return i=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_T,"transactionId: ".concat(e),i),C(e)?t(r)?this._callEngine.getLocalMainSession()?[4,this._callEngine.responseChangeMediaType({transactionId:e,agree:r},i)]:(this._logger.error(M.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"error code : ".concat(D.NOT_IN_CALL,", session not exist"),i),[2,{code:D.NOT_IN_CALL}]):(this._logger.error(M.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"param error, isAgree: type is boolean, value: ".concat(r),i),[2,{code:D.PARAM_ERROR}]):(this._logger.error(M.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"param error, transactionId: not empty string, value: ".concat(e),i),[2,{code:D.PARAM_ERROR}]);case 1:return(n=o.sent().code)!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"signal error: ".concat(n),i),[2,{code:n}]):(this._logger.info(M.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"success",i),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(n.prototype,"getCurrentCallSession",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callEngine.getLocalMainSession()}}),Object.defineProperty(n.prototype,"getAvailableCallRecordsFromServer",{enumerable:!1,configurable:!0,writable:!0,value:function(){return v(this,void 0,void 0,(function(){var e,t,r,i;return y(this,(function(n){switch(n.label){case 0:return e=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_T,"",e),[4,this._callEngine.getOpenCallList(e)];case 1:return t=n.sent(),r=t.code,i=t.data,r!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R,"signal error code: ".concat(r),e),[2,{code:r}]):(this._logger.info(M.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R,"success, data: ".concat(JSON.stringify(i)),e),[2,{code:D.SUCCESS,records:i}])}}))}))}}),Object.defineProperty(n.prototype,"getCallRecords",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return void 0===i&&(i=0),v(this,void 0,void 0,(function(){var n,o,a,_;return y(this,(function(l){switch(l.label){case 0:return n=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_T,"startTimestamp: ".concat(t,", count: ").concat(r),n),e(t)&&t>=0?e(r)&&r>0?[4,this._callEngine.getCallLogList({timestamp:t,count:r,order:i},n)]:(this._logger.error(M.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,"params error, count: is a number >= 0, value: ".concat(r),n),[2,{code:D.PARAM_ERROR}]):(this._logger.error(M.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,"params error, startTimestamp: is a number >= 0, value: ".concat(t),n),[2,{code:D.PARAM_ERROR}]);case 1:return o=l.sent(),a=o.code,_=o.data,a!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,"signal error code: ".concat(a),n),[2,{code:a}]):(this._logger.info(M.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,"success",n),[2,{code:D.SUCCESS,result:_}])}}))}))}}),Object.defineProperty(n.prototype,"deleteCallRecordsFromServer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r;return y(this,(function(i){switch(i.label){case 0:return t=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_T,"callIds: ".concat(e.join(",")),t),E(e)&&e.every((function(e){return C(e)}))?[4,this._callEngine.deleteCallLog(e,t)]:(this._logger.error(M.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,"params err, callIds: not empty array, callId: not empty string, callIds: ".concat(JSON.stringify(e)),t),[2,{code:D.PARAM_ERROR}]);case 1:return(r=i.sent().code)!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,"signal error code: ".concat(r),t),[2,{code:r}]):(this._logger.info(M.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,"success",t),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(n.prototype,"deleteAllCallRecordsFromServer",{enumerable:!1,configurable:!0,writable:!0,value:function(){return v(this,void 0,void 0,(function(){var e,t;return y(this,(function(r){switch(r.label){case 0:return e=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_T,"",e),[4,this._callEngine.removeAllCallLog(e)];case 1:return(t=r.sent().code)!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R,"signal error code: ".concat(t),e),[2,{code:t}]):(this._logger.info(M.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R,"success",e),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(n.prototype,"startCamera",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return v(this,void 0,void 0,(function(){var t,r,i,n,o,a;return y(this,(function(_){switch(_.label){case 0:return t=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_START_CAMERA_T,"",t),[4,this._rtcModule.getCameraVideoTrack(t)];case 1:return r=_.sent(),i=r.code,n=r.track,i!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_START_CAMERA_R,"create video track error code: ".concat(i),t),[2,{code:i}]):(this._callEngine.setUserDeviceEnable(this._context.getCurrentId(),G.VIDEO,!0,t),(null==n?void 0:n.isPublished())||(null===(e=this._callEngine.getLocalMainSession())||void 0===e?void 0:e.getState())!==V.ONCALL?[3,3]:[4,this._rtcModule.publishVideoTrack()]);case 2:return(o=_.sent().code)!==p.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_START_CAMERA_R,"publish error code: ".concat(o),t),[2,{code:o}]):(this._logger.info(M.L_CALLPLUS_CLIENT_START_CAMERA_R,"success",t),[2,{code:D.SUCCESS}]);case 3:return[4,this._rtcModule.enableVideoTrack(t)];case 4:return(a=_.sent().code)!==p.SUCCESS&&a!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_START_CAMERA_R,"signal error code: ".concat(a),t),[2,{code:a}]):(this._logger.info(M.L_CALLPLUS_CLIENT_START_CAMERA_R,"success",t),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(n.prototype,"stopCamera",{enumerable:!1,configurable:!0,writable:!0,value:function(){return v(this,void 0,void 0,(function(){var e,t,r,i;return y(this,(function(n){switch(n.label){case 0:return e=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_STOP_CAMERA_T,"",e),[4,this._rtcModule.disableVideoTrack()];case 1:return t=n.sent(),r=t.code,i=t.track,r!==D.SUCCESS&&r!==p.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_STOP_CAMERA_R,"error code: ".concat(r),e),[2,{code:r}]):(this._rtcModule.destroyTrack(i),this._callEngine.setUserDeviceEnable(this._context.getCurrentId(),G.VIDEO,!1,e),this._logger.info(M.L_CALLPLUS_CLIENT_STOP_CAMERA_R,"success",e),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(n.prototype,"switchCamera",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i;return y(this,(function(n){switch(n.label){case 0:return t=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_SWITCH_CAMERA_T,"cameraId: ".concat(e),t),C(e)?(r=this._callEngine.getLocalMainSession())?r.getMediaType()===G.AUDIO?(this._logger.error(M.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"errCode: ".concat(D.NOT_VIDEO_CALL),t),[2,{code:D.NOT_VIDEO_CALL}]):(this._videoConfig.cameraId=e,this._rtcModule.setVideoConfig(this._videoConfig),[4,this._rtcModule.changeVideoDevice(t)]):(this._logger.error(M.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"errCode: ".concat(D.NOT_IN_CALL),t),[2,{code:D.NOT_IN_CALL}]):(this._logger.error(M.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"param error, cameraId: not empty string, value: ".concat(e),t),[2,{code:D.PARAM_ERROR}]);case 1:return(i=n.sent().code)!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"call client changeVideoDevice error code: ".concat(i),t),[2,{code:i}]):(this._logger.info(M.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"success",t),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(n.prototype,"startMicrophone",{enumerable:!1,configurable:!0,writable:!0,value:function(){return v(this,void 0,void 0,(function(){var e,t,r,i,n;return y(this,(function(o){switch(o.label){case 0:return e=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_START_MICROPHONE_T,"",e),[4,this._rtcModule.getMicrophoneAudioTrack(e)];case 1:return t=o.sent(),r=t.code,i=t.track,r!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"create microphone audio track error code: ".concat(r),e),[2,{code:r}]):(this._callEngine.setUserDeviceEnable(this._context.getCurrentId(),G.AUDIO,!0,e),i.isOwnerMuted()?[4,i.unmute()]:(this._logger.info(M.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"success",e),[2,{code:D.SUCCESS}]));case 2:return(n=o.sent())!==p.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"signal error code: ".concat(r),e),[2,{code:n}]):(this._logger.info(M.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"success",e),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(n.prototype,"stopMicrophone",{enumerable:!1,configurable:!0,writable:!0,value:function(){return v(this,void 0,void 0,(function(){var e,t;return y(this,(function(r){switch(r.label){case 0:return e=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_STOP_MICROPHONE_T,"",e),[4,this._rtcModule.disableAudioTrack()];case 1:return(t=r.sent().code)!==D.SUCCESS&&t!==p.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R,"signal error code: ".concat(t),e),[2,{code:t}]):(this._callEngine.setUserDeviceEnable(this._context.getCurrentId(),G.AUDIO,!1,e),this._logger.info(M.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R,"success",e),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(n.prototype,"isMicrophoneEnabled",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._rtcModule.getLocalAudioTrack();return!!e&&!e.isOwnerMuted()}}),Object.defineProperty(n.prototype,"setAllRemoteAudioEnable",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t;return y(this,(function(r){return t=this._logger.createTraceId(),[2,this._rtcModule.setAllRemoteAudioEnable(e,t)]}))}))}}),Object.defineProperty(n.prototype,"getVersion",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"2.1.7"}}),Object.defineProperty(n.prototype,"getCameras",{enumerable:!1,configurable:!0,writable:!0,value:function(){return v(this,void 0,void 0,(function(){return y(this,(function(e){return[2,O.getCameras()]}))}))}}),Object.defineProperty(n.prototype,"getMicrophones",{enumerable:!1,configurable:!0,writable:!0,value:function(){return v(this,void 0,void 0,(function(){return y(this,(function(e){return[2,O.getMicrophones()]}))}))}}),Object.defineProperty(n.prototype,"getSpeakers",{enumerable:!1,configurable:!0,writable:!0,value:function(){return v(this,void 0,void 0,(function(){return y(this,(function(e){return[2,O.getSpeakers()]}))}))}}),Object.defineProperty(n.prototype,"getRTCSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._rtcModule.getRTCSessionId()}}),Object.defineProperty(n.prototype,"switchMicrophone",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r;return y(this,(function(i){switch(i.label){case 0:return t=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_T,"microphoneId: ".concat(e),t),C(e)?this._callEngine.getLocalMainSession()?(this._audioConfig.microphoneId=e,this._rtcModule.setAudioConfig(this._audioConfig),[4,this._rtcModule.changeAudioDevice(t)]):(this._logger.error(M.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,"errCode: ".concat(D.NOT_IN_CALL),t),[2,{code:D.NOT_IN_CALL}]):(this._logger.error(M.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,"param error, microphoneId: not empty string, value: ".concat(e),t),[2,{code:D.PARAM_ERROR}]);case 1:return(r=i.sent().code)!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,"call client changeAudioDevice error code: ".concat(r),t),[2,{code:r}]):(this._logger.info(M.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,"success",t),[2,{code:D.SUCCESS}])}}))}))}}),n}();I.add("callplus","2.1.7");var De={tag:"RCCallPlus",verify:function(e){return!!I.validEngine("5.8.2")||(console.error("The current engine version '".concat(I.getInfo().engine,"' error, plugin-call-plus required engine version at least '").concat("5.8.2","'.")),!1)},setup:function(e,t,i){var n,o=(n=i)?T(n)?Object.keys(n).includes("rtcClient")?T(n.rtcClient)?{isLegal:!0}:{isLegal:!1,msg:"Initialization 'rtcClient' parameter must be of type 'object'"}:{isLegal:!1,code:D.NOT_INSTALL_RTC_PLUGIN}:{isLegal:!1,msg:"Initialization options must be an object"}:{isLegal:!1,msg:"Initialization missing parameter -> options"};if(!o.isLegal)throw new Error("[CallPlusLib installer steup]".concat(o.msg));var a=e.createLogger("CallPlus","RTC"),_=r(i.logOutputLevel)?g.WARN:i.logOutputLevel;return a.setOutputLevel(_),a.warn(M.L_INDEX_INSTALL_CALL_PLUS_PLUGIN_O,"CallPlus Version: ".concat("2.1.7",", Commit: ").concat("e751d5fe87dac23068a648aa13bc09e3c069f28d")),new Me(e,a,t,i)}};export{F as RCAudioConfigBuilder,Ue as RCCallPlusAndroidPushConfigBuilder,V as RCCallPlusCallState,Me as RCCallPlusClient,D as RCCallPlusCode,G as RCCallPlusMediaType,H as RCCallPlusMediaTypeChangeResult,k as RCCallPlusReason,B as RCCallPlusSession,j as RCCallPlusSessionUserState,w as RCCallPlusType,Y as RCVideoConfigBuilder,De as installer};
|
|
1
|
+
import{isNumber as e,isBoolean as t,isUndefined as r,isString as i,EventEmitter as n,ErrorCode as a,SentStatus as o,RCConnectionStatus as _,isNull as l,getUUID22 as s,getUUID as c,ConversationType as u,MessageDirection as L,ReceivedStatus as d,RTCMode as E,notEmptyArray as C,notEmptyString as T,VersionManage as I,LogL as g}from"@rongcloud/engine";import{RCFrameRate as S,RCResolution as f,RCRTCCode as p,RCKickReason as h,RCLocalTrack as b,device as R,RCRTCClient as O}from"@rongcloud/plugin-rtc";export{RCFrameRate as RCCallPlusFrameRate,RCResolution as RCCallPlusResolution}from"@rongcloud/plugin-rtc";var A=function(e,t){return A=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},A(e,t)};function N(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}A(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var m=function(){return m=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},m.apply(this,arguments)};function v(e,t,r,i){return new(r||(r=Promise))((function(n,a){function o(e){try{l(i.next(e))}catch(e){a(e)}}function _(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,_)}l((i=i.apply(e,t||[])).next())}))}function y(e,t){var r,i,n,a={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=_(0),o.throw=_(1),o.return=_(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function _(_){return function(l){return function(_){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,_[0]&&(a=0)),a;)try{if(r=1,i&&(n=2&_[0]?i.return:_[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,_[1])).done)return n;switch(i=0,n&&(_=[2&_[0],n.value]),_[0]){case 0:case 1:n=_;break;case 4:return a.label++,{value:_[1],done:!1};case 5:a.label++,i=_[1],_=[0];continue;case 7:_=a.ops.pop(),a.trys.pop();continue;default:if(!(n=a.trys,(n=n.length>0&&n[n.length-1])||6!==_[0]&&2!==_[0])){a=0;continue}if(3===_[0]&&(!n||_[1]>n[0]&&_[1]<n[3])){a.label=_[1];break}if(6===_[0]&&a.label<n[1]){a.label=n[1],n=_;break}if(n&&a.label<n[2]){a.label=n[2],a.ops.push(_);break}n[2]&&a.ops.pop(),a.trys.pop();continue}_=t.call(e,a)}catch(e){_=[6,e],i=0}finally{r=n=0}if(5&_[0])throw _[1];return{value:_[0]?_[1]:void 0,done:!0}}([_,l])}}}function P(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var i,n,a=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=a.next()).done;)o.push(i.value)}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return o}function U(e,t,r){if(r||2===arguments.length)for(var i,n=0,a=t.length;n<a;n++)!i&&n in t||(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var M,D={SUCCESS:0,PARAM_ERROR:80001,SESSION_EXIST:80002,NOT_IN_CALL:80003,MEDIATYPE_INVALID:80004,NOT_VIDEO_CALL:80005,RTC_SERVICE_UNAVAILABLE:80006,USER_LIST_INVAILD:80007,CALL_ID_INVALID:80008,TRANSACTION_ID_INVALID:80009,USER_ID_INVALID:80010,SINGLE_CALL_NOT_SUPPORT_MULTI_PERSON:80011,SIGNAL_DISCONNECTED:80012,CAMERA_CLOSED:80100,MICROPHONE_CLOSED:80101,MEDIA_RESOURCE_INVALIED:80102,NOT_INSTALL_RTC_PLUGIN:80103,PLAY_MEDIA_FAILED:80104,VIDEO_VIEW_NOT_SET:80105};!function(e){e.L_INDEX_INSTALL_CALL_PLUS_PLUGIN_O="L-index_install_call_plus_plugin-O",e.L_CALLPLUS_CLIENT_SET_EVENT_LISTENER_O="L-callplus_client_set_event_listener-O",e.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O="L-callplus_client_call_event_listener-O",e.L_CALLPLUS_CLIENT_SET_STATUS_REPORT_LISTENER_O="L-callplus_client_set_status_report_listener-O",e.L_CALLPLUS_CLIENT_CALL_STATUS_REPORT_LISTENER_O="L-callplus_client_call_status_report_listener-O",e.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_T="L-callplus_client_set_video_config-T",e.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R="L-callplus_client_set_video_config-R",e.L_CALLPLUS_VIDEO_CONFIG_SET_FRAME_RATE_O="L-callplus_video_config_set_frame_rate-O",e.L_CALLPLUS_VIDEO_CONFIG_SET_RESOLUTION_O="L-callplus_video_config_set_resolution-O",e.L_CALLPLUS_VIDEO_CONFIG_SET_BITRATE_O="L-callplus_video_config_set_bitrate-O",e.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_T="L-callplus_client_set_audio_config-T",e.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R="L-callplus_client_set_audio_config-R",e.L_CALLPLUS_AUDIO_CONFIG_SET_BITRATE_O="L-callplus_audio_config_set_bitrate-O",e.L_CALLPLUS_AUDIO_CONFIG_SET_SAMPLE_RATE_O="L-callplus_audio_config_set_sample_rate-O",e.L_CALLPLUS_CLIENT_PREVIEW_T="L-callplus_client_preview-T",e.L_CALLPLUS_CLIENT_PREVIEW_R="L-callplus_client_preview-R",e.L_CALLPLUS_CLIENT_START_CALL_T="L-callplus_client_start_call-T",e.L_CALLPLUS_CLIENT_START_CALL_R="L-callplus_client_start_call-R",e.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_T="L-callplus_client_join_multi_call-T",e.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R="L-callplus_client_join_multi_call-R",e.L_CALLPLUS_CLIENT_ACCEPT_T="L-callplus_client_accept-T",e.L_CALLPLUS_CLIENT_ACCEPT_R="L-callplus_client_accept-R",e.L_CALLPLUS_CLIENT_HANGUP_T="L-callplus_client_hangup-T",e.L_CALLPLUS_CLIENT_HANGUP_R="L-callplus_client_hangup-R",e.L_CALLPLUS_CLIENT_INVITE_T="L-callplus_client_invite-T",e.L_CALLPLUS_CLIENT_INVITE_R="L-callplus_client_invite-R",e.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_T="L-callplus_client_request_change_media_type-T",e.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R="L-callplus_client_request_change_media_type-R",e.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_T="L-callplus_client_cancel_change_media_type-T",e.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R="L-callplus_client_cancel_change_media_type-R",e.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_T="L-callplus_client_reply_change_media_type-T",e.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R="L-callplus_client_reply_change_media_type-R",e.L_CALLPLUS_CLIENT_GET_CURRENT_CALL_SESSION_T="L-callplus_client_get_current_call_session-T",e.L_CALLPLUS_CLIENT_GET_CURRENT_CALL_SESSION_R="L-callplus_client_get_current_call_session-R",e.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_T="L-callplus_client_get_available_call_sessions_from_server-T",e.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R="L-callplus_client_get_available_call_sessions_from_server-R",e.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_T="L-callplus_client_get_call_records-T",e.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R="L-callplus_client_get_call_records-R",e.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_T="L-callplus_client_delete_call_records_by_callId-T",e.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R="L-callplus_client_delete_call_records_by_callId-R",e.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_T="L-callplus_client_delete_all_call_records_from_server-T",e.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R="L-callplus_client_delete_all_call_records_from_server-R",e.L_CALLPLUS_CLIENT_START_CAMERA_T="L-callplus_client_start_camera-T",e.L_CALLPLUS_CLIENT_START_CAMERA_R="L-callplus_client_start_camera-R",e.L_CALLPLUS_CLIENT_STOP_CAMERA_T="L-callplus_client_stop_camera-T",e.L_CALLPLUS_CLIENT_STOP_CAMERA_R="L-callplus_client_stop_camera-R",e.L_CALLPLUS_CLIENT_SWITCH_CAMERA_T="L-callplus_client_switch_camera-T",e.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R="L-callplus_client_switch_camera-R",e.L_CALLPLUS_CLIENT_START_MICROPHONE_T="L-callplus_client_start_microphone-T",e.L_CALLPLUS_CLIENT_START_MICROPHONE_R="L-callplus_client_start_microphone-R",e.L_CALLPLUS_CLIENT_STOP_MICROPHONE_T="L-callplus_client_stop_microphone-T",e.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R="L-callplus_client_stop_microphone-R",e.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_T="L-callplus_client_switch_microphone-T",e.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R="L-callplus_client_switch_microphone-R",e.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_T="L-callplus_client_set_video_view-T",e.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R="L-callplus_client_set_video_view-R",e.L_RTC_MODULE_SET_VIDEO_VIEW_O="L-rtc_module_set_video_view-O",e.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_T="L-callplus_client_remove_video_view-T",e.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R="L-callplus_client_remove_video_view-R",e.L_RTC_MODULE_REMOVE_VIDEO_VIEW_O="L-rtc_module_remove_video_view-O",e.L_CALLPLUS_CLIENT_PLAY_MEDIA_T="L-callplus_client_play_media-T",e.L_CALLPLUS_CLIENT_PLAY_MEDIA_R="L-callplus_client_play_media-R",e.L_RTC_MODULE_PLAY_MEDIA_T="L-rtc_module_play_media-T",e.L_RTC_MODULE_PLAY_MEDIA_R="L-rtc_module_play_media-R",e.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_T="L-rtc_module_set_all_remote_audio_enbale-T",e.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R="L-rtc_module_set_all_remote_audio_enable-R",e.L_RTC_MODULE_SUBSCRIBE_T="L-rtc_module_subscribe-T",e.L_RTC_MODULE_SUBSCRIBE_R="L-rtc_module_subscribe-R",e.L_RTC_MODULE_UNSUBSCRIBE_T="L-rtc_module_unsubscribe-T",e.L_RTC_MODULE_UNSUBSCRIBE_R="L-rtc_module_unsubscribe-R",e.L_RTC_MODULE_PUBLISH_T="L-rtc_module_publish-T",e.L_RTC_MODULE_PUBLISH_R="L-rtc_module_publish-R",e.L_RTC_MODULE_UNPUBLISH_T="L-rtc_module_unpublish-T",e.L_RTC_MODULE_UNPUBLISH_R="L-rtc_module_unpublish-R",e.L_RTC_MODULE_DESTROY_ALL_TRACKS_O="L-rtc_module_destroy_all_tracks-O",e.L_RTC_MODULE_SESSION_CONNECT_T="L-rtc_module_session_connect-T",e.L_RTC_MODULE_SESSION_CONNECT_P="L-rtc_module_session_connect-P",e.L_RTC_MODULE_SESSION_CONNECT_R="L-rtc_module_session_connect-R",e.L_RTC_MODULE_SESSION_CLOSE_T="L-rtc_module_session_close-T",e.L_RTC_MODULE_SESSION_CLOSE_P="L-rtc_module_session_close-P",e.L_RTC_MODULE_SESSION_CLOSE_R="L-rtc_module_session_close-R",e.L_RTC_MODULE_CREATE_VIDEO_TRACK_T="L-rtc_module_create_video_track-T",e.L_RTC_MODULE_CREATE_VIDEO_TRACK_R="L-rtc_module_create_video_track-R",e.L_RTC_MODULE_CREATE_AUDIO_TRACK_T="L-rtc_module_create_audio_track-T",e.L_RTC_MODULE_CREATE_AUDIO_TRACK_R="L-rtc_module_create_audio_track-R",e.L_RTC_MODULE_RECEIVE_TRACK_PUBLISH_O="L-rtc_module_receive_track_publish-O",e.L_RTC_MODULE_RECEIVE_TRACK_UNPUBLISH_O="L-rtc_module_receive_track_unpublish-O",e.L_RTC_MODULE_RECEIVE_TRACK_ENABLE_CHANGE_O="L-rtc_module_receive_track_enable_change-O",e.L_RTC_MODULE_RECEIVE_KICK_OFF_O="L-rtc_module_receive_kick_off-O",e.L_RTC_MODULE_RECEIVE_PEERCONNECTION_EXCEPT_CLOSE_O="L-rtc_module_receive_peerconnection_except_close-O",e.L_RTC_MODULE_CHANGE_MEDIA_TYPE_T="L-rtc_module_change_media_type-T",e.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R="L-rtc_module_change_media_type-R",e.L_RTC_MODULE_JOIN_RTC_ROOM_T="L-rtc_module_join_rtc_room-T",e.L_RTC_MODULE_JOIN_RTC_ROOM_R="L-rtc_module_join_rtc_room-R",e.L_RTC_MODULE_QUIT_RTC_ROOM_T="L-rtc_module_quit_rtc_room-T",e.L_RTC_MODULE_QUIT_RTC_ROOM_R="L-rtc_module_quit_rtc_room-R",e.L_RTC_MODULE_CREATE_CALL_MEDIA_TRACKS_P="L-rtc_module_create_call_media_tracks-P",e.L_SIGNAL_TRANSPORTER_SINGLE_CALL_T="L-signal_transporter_single_call-T",e.L_SIGNAL_TRANSPORTER_GROUP_CALL_T="L-signal_transporter_group_call-T",e.L_SIGNAL_TRANSPORTER_INVITE_T="L-signal_transporter_invite-T",e.L_SIGNAL_TRANSPORTER_RING_T="L-signal_transporter_ring-T",e.L_SIGNAL_TRANSPORTER_ACCEPT_T="L-signal_transporter_accept-T",e.L_SIGNAL_TRANSPORTER_ACCEPT_R="L-signal_transporter_accept-R",e.L_SIGNAL_TRANSPORTER_JOIN_CALL_T="L-signal_transporter_join_call-T",e.L_SIGNAL_TRANSPORTER_HANGUP_T="L-signal_transporter_hangup-T",e.L_SIGNAL_TRANSPORTER_CALL_STATUS_UP_T="L-signal_transporter_call_status_up-T",e.L_SIGNAL_TRANSPORTER_CALL_EVENT_UP_T="L-signal_transporter_call_event_up-T",e.L_SIGNAL_TRANSPORTER_CALL_DIALOG_UP_T="L-signal_transporter_call_dialog_up-T",e.L_SIGNAL_TRANSPORTER_DELETE_CALL_RECORD_T="L-signal_transporter_delete_call_record-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_RECORD_T="L-signal_transporter_get_call_record-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_SERVER_TIME_T="L-signal_transporter_get_call_server_time-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_TIME_INFO_T="L-signal_transporter_get_call_time_info-T",e.L_SIGNAL_TRANSPORTER_GET_AVAILABLE_CALL_LIST_T="L-signal_transporter_get_available_call_list-T",e.L_SIGNAL_TRANSPORTER_CLEAR_CALL_RECORD_T="L-signal_transporter_clear_call_record-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_INFO_BY_CALLID_T="L-signal_transporter_get_call_info_by_callId-T",e.L_SIGNAL_TRANSPORTER_USER_SYSTEM_STATE_UP_T="L-signal_transporter_user_system_state_up-T",e.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_SIGNAL_DATA_O="L-signal_transporter_receive_call_signal_data-O",e.L_SIGNAL_TRANSPORTER_IM_STATE_CHANGE_O="L-signal_transporter_im_state_change-O",e.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O="L-signal_transporter_receive_invite-O",e.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O="L-signal_transporter_receive_call_status-O",e.L_SIGNAL_TRANSPORTER_RECEIVE_MISS_MESSAGE_O="L-signal_transporter_receive_miss_message-O",e.L_CALL_ENGINE_UPDATE_USERS_STATE_O="L-call_engine_update_users_state-O",e.L_CALL_ENGINE_IM_STATE_CHANGE_O="L-call_engine_im_state_change-O",e.L_CALL_ENGINE_CALL_TIMEOUT_O="L-call_engine_call_timeout-O",e.L_CALL_ENGINE_START_CALL_TIMER_O="L-call_engine_start_call_timer-O",e.L_CALL_ENGINE_STOP_CALL_TIMER_O="L-call_engine_stop_call_timer-O",e.L_CALL_ENGINE_UP_ON_PHONE_END_T="L-call_engine_up_on_phone_end-T",e.L_CALL_ENGINE_UP_ON_PHONE_END_R="L-call_engine_up_on_phone_end-R",e.L_CALL_ENGINE_RECEIVE_FIRST_FRAME_TIME_O="L-call_engine_receive_first_frame_time-O",e.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O="L-call_engine_receive_mediatype_change-O",e.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O="L-call_engine_receive_close_session-O",e.L_CALL_ENGINE_RECEIVE_CALL_RECORD_O="L-call_engine_receive_call_record-O",e.L_CALL_ENGINE_RECEIVE_COMPLEMENTARY_DATA_O="L-call_engine_receive_complementary_data-O",e.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_T="L-call_engine_create_session_by_server-T",e.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R="L-call_engine_create_session_by_server-R",e.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_T="L-call_engine_up_first_frame_time-T",e.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_R="L-call_engine_up_first_frame_time-R",e.L_TIME_CORRECT_START_O="L-time_correct_start-O",e.L_TIME_CORRECT_STOP_O="L-time_correct_stop-O",e.L_TIME_CORRECT_RESTART_O="L-time_correct_restart-O",e.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_T="L-time_correct_get_call_client_time_by_server-T",e.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_P="L-time_correct_get_call_client_time_by_server-P",e.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R="L-time_correct_get_call_client_time_by_server-R",e.L_TIME_CORRECT_CALC_CLIENT_START_TIME_T="L-time_correct_calc_client_start_time-T",e.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R="L-time_correct_calc_client_start_time-R",e.L_TIME_CORRECT_SET_DELTA_TIME_O="L-time_correct_set_delta_time-O",e.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_T="L-time_correct_loop_correct_client_time-T",e.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R="L-time_correct_loop_correct_client_time-R",e.L_INNER_SESSION_UPDATE_USER_STATE_O="L-inner_session_update_user_state-O",e.L_INNER_SESSION_SET_USER_DEVICE_ENABLE_O="L-inner_session_set_user_device_enable-O",e.L_CALLPLUS_SESSION_GET_CREATE_TIME_T="L-callplus_session_get_create_time-T",e.L_CALLPLUS_SESSION_GET_CREATE_TIME_R="L-callplus_session_get_create_time-R",e.L_CALLPLUS_SESSION_GET_DURATION_T="L-callplus_session_get_duration-T",e.L_CALLPLUS_SESSION_GET_DURATION_R="L-callplus_session_get_duration-R",e.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O="L-callplus_set_android_push_config-O",e.L_ABNORMAL_ADD_CALL_ID_E="L-ABNORMAL_ADD_CALL_ID-E",e.L_ABNORMAL_REMOVE_CALL_IDS_E="L-ABNORMAL_REMOVE_CALL_IDS-E",e.L_ABNORMAL_GET_CALL_IDS_E="L-ABNORMAL_GET_CALL_IDS-E",e.L_CALLPLUS_CLIENT_SET_AUDIO_OUTPUT_DEVICE_ID_O="L-set_audio_output_device_id-O"}(M||(M={}));var w,j,G,V,H,k,B=function(){function e(e,t,r){Object.defineProperty(this,"_session",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_startTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_duration",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:""}),this._callId=this._session.getCallId()}return Object.defineProperty(e.prototype,"getCallId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callId}}),Object.defineProperty(e.prototype,"getState",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._session.getSessionState()}}),Object.defineProperty(e.prototype,"getCallType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._session.getCallType()}}),Object.defineProperty(e.prototype,"getMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._session.getMediaType()}}),Object.defineProperty(e.prototype,"getUserList",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._session.getUserList().map((function(e){return{userId:e.userId,state:e.userState,cameraEnable:e.cameraEnable,microphoneEnable:e.microphoneEnable}}))}}),Object.defineProperty(e.prototype,"getCreatorUserId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._session.getStartCallerId()}}),Object.defineProperty(e.prototype,"getInviterUserId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._session.getCallerId()}}),Object.defineProperty(e.prototype,"getCreateTimestamp",{enumerable:!1,configurable:!0,writable:!0,value:function(){return v(this,void 0,void 0,(function(){var e,t,r,i;return y(this,(function(n){switch(n.label){case 0:return e=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_SESSION_GET_CREATE_TIME_T,"",e),this._startTime?[2,{code:D.SUCCESS,startTime:this._startTime}]:[4,this._callEngine.getCallStaringTime({callId:this._callId},e)];case 1:return t=n.sent(),r=t.code,i=t.clientStartTime,r!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_SESSION_GET_CREATE_TIME_R,"errCode: ".concat(r),e),[2,{code:r}]):(this._logger.info(M.L_CALLPLUS_SESSION_GET_CREATE_TIME_R,"success",e),this._startTime=i,[2,{code:D.SUCCESS,startTime:this._startTime}])}}))}))}}),Object.defineProperty(e.prototype,"getDuration",{enumerable:!1,configurable:!0,writable:!0,value:function(){return v(this,void 0,void 0,(function(){var e,t,r,i;return y(this,(function(n){switch(n.label){case 0:return e=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_SESSION_GET_DURATION_T,"",e),this._duration?(this._logger.info(M.L_CALLPLUS_SESSION_GET_DURATION_R,"code: ".concat(D.SUCCESS,", duration: ").concat(this._duration),e),[2,{code:D.SUCCESS,duration:this._duration}]):[4,this._callEngine.getCallTimeInfo(this._callId,e)];case 1:return t=n.sent(),r=t.code,i=t.data,r!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_SESSION_GET_DURATION_R,"code: ".concat(r),e),[2,{code:r}]):(this._logger.info(M.L_CALLPLUS_SESSION_GET_DURATION_R,"code: ".concat(D.SUCCESS,", duration: ").concat(i.duration),e),this._duration=i.duration,[2,{code:D.SUCCESS,duration:this._duration}])}}))}))}}),Object.defineProperty(e.prototype,"getSyncData",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._session.getSyncData()}}),Object.defineProperty(e.prototype,"isSecret",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._session.isSecret()}}),Object.defineProperty(e.prototype,"getSecretKey",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._session.getSecretKey()}}),e}();!function(e){e[e.SINGLE=0]="SINGLE",e[e.MULTI=1]="MULTI"}(w||(w={})),function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",e[e.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ONPHONE=301]="ONPHONE",e[e.ENDED=1e3]="ENDED",e[e.NO_ANSWER=1001]="NO_ANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELLED=1003]="CANCELLED",e[e.DECLINED=1004]="DECLINED",e[e.ERROR=2e3]="ERROR"}(j||(j={})),function(e){e[e.AUDIO=0]="AUDIO",e[e.AUDIO_VIDEO=1]="AUDIO_VIDEO",e[e.VIDEO=2]="VIDEO"}(G||(G={})),function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",e[e.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ENDED=1e3]="ENDED",e[e.NOANSWER=1001]="NOANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELED=1003]="CANCELED",e[e.DECLINED=1004]="DECLINED",e[e.ERROR=2e3]="ERROR"}(V||(V={})),function(e){e[e.CANCEL_CHANGE_MEDIA_TYPE=0]="CANCEL_CHANGE_MEDIA_TYPE",e[e.REFUSE_CHANGE_MEDIA_TYPE=1]="REFUSE_CHANGE_MEDIA_TYPE",e[e.SERVER_ALLOW_MEDIA_TYPE=2]="SERVER_ALLOW_MEDIA_TYPE",e[e.CHANGE_MEDIA_TYPE_TIMEOUT=3]="CHANGE_MEDIA_TYPE_TIMEOUT"}(H||(H={})),function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",e[e.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ON_PHONE=301]="ON_PHONE",e[e.ON_PHONE_END=302]="ON_PHONE_END",e[e.ON_DEVICE_DISABLE=303]="ON_DEVICE_DISABLE",e[e.ON_DEVICE_ENABLE=304]="ON_DEVICE_ENABLE",e[e.ABNORMAL_END=999]="ABNORMAL_END",e[e.ENDED=1e3]="ENDED",e[e.NO_ANSWER=1001]="NO_ANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELLED=1003]="CANCELLED",e[e.DECLINED=1004]="DECLINED",e[e.OTHER_CLIENT_CALLING=1010]="OTHER_CLIENT_CALLING",e[e.OTHER_CLIENT_ACCEPT=1011]="OTHER_CLIENT_ACCEPT",e[e.JOIN_ROOM_ERR=1105]="JOIN_ROOM_ERR",e[e.PUBLISH_ERR=1106]="PUBLISH_ERR",e[e.SUBSCRIBE_ERR=1107]="SUBSCRIBE_ERR",e[e.ACCEPT_CARRIER=1108]="ACCEPT_CARRIER",e[e.KICKED_BY_SERVER=1109]="KICKED_BY_SERVER",e[e.CONNECTION_ERR=1110]="CONNECTION_ERR",e[e.LOGOUT=1111]="LOGOUT",e[e.OTHER_CLIENT_LOGIN=1112]="OTHER_CLIENT_LOGIN",e[e.OTHER_CLIENT_JOINED=1113]="OTHER_CLIENT_JOINED",e[e.OTHER_CLIENT_IN_ROOM=1114]="OTHER_CLIENT_IN_ROOM",e[e.OTHER_CLIENT_HANGUP=1151]="OTHER_CLIENT_HANGUP",e[e.REMOTE_JOIN_RTC_ERROR=1205]="REMOTE_JOIN_RTC_ERROR",e[e.REMOTE_PUBLISH_ERROR=1206]="REMOTE_PUBLISH_ERROR",e[e.REMOTE_SUBSCRIBE_ERROR=1207]="REMOTE_SUBSCRIBE_ERROR",e[e.REMOTE_KICKED_BY_SERVER=1209]="REMOTE_KICKED_BY_SERVER",e[e.REMOTE_CONNECTION_ERROR=1210]="REMOTE_CONNECTION_ERROR",e[e.REMOTE_LOGOUT=1211]="REMOTE_LOGOUT",e[e.REMOTE_OTHER_CLIENT_LOGIN=1212]="REMOTE_OTHER_CLIENT_LOGIN",e[e.REMOTE_OTHER_JOINED_RTC=1213]="REMOTE_OTHER_JOINED_RTC",e[e.REMOTE_OTHER_CLIENT_IN_RTC=1214]="REMOTE_OTHER_CLIENT_IN_RTC",e[e.ENCRYPT_FAILED=1216]="ENCRYPT_FAILED"}(k||(k={}));var x,F=function(){function t(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_audioConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}})}return Object.defineProperty(t.prototype,"setDefaultMicrophoneId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._audioConfig.microphoneId=e,this}}),Object.defineProperty(t.prototype,"setBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return!e(t)||!e(r)||r<=0||t<=0||r<t?(this._logger.error(M.L_CALLPLUS_AUDIO_CONFIG_SET_BITRATE_O,"params error -> max: ".concat(r,",min: ").concat(t,", max and min is a number > 0, max should > min")),this):(this._audioConfig.minBitrate=t,this._audioConfig.maxBitrate=r,this)}}),Object.defineProperty(t.prototype,"setSampleRate",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e(t)?(this._audioConfig.sampleRate=t,this):(this._logger.error(M.L_CALLPLUS_AUDIO_CONFIG_SET_SAMPLE_RATE_O,"params error -> sampleRate: ".concat(t)),this)}}),Object.defineProperty(t.prototype,"build",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._audioConfig}}),t}(),Y=function(){function t(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:f.W640_H480,frameRate:S.FPS_15}})}return Object.defineProperty(t.prototype,"setFrameRate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return S[e]?(this._videoConfig.frameRate=e,this):(this._logger.error(M.L_CALLPLUS_VIDEO_CONFIG_SET_FRAME_RATE_O,"params error -> fps: ".concat(e)),this)}}),Object.defineProperty(t.prototype,"setVideoResolution",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return f[e]?(this._videoConfig.resolution=e,this):(this._logger.error(M.L_CALLPLUS_VIDEO_CONFIG_SET_RESOLUTION_O,"params error -> resolution: ".concat(e)),this)}}),Object.defineProperty(t.prototype,"setDefaultCameraId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._videoConfig.cameraId=e,this}}),Object.defineProperty(t.prototype,"setBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return!e(t)||!e(r)||r<=0||t<=0||r<t?(this._logger.error(M.L_CALLPLUS_VIDEO_CONFIG_SET_BITRATE_O,"params error -> max: ".concat(r,",min: ").concat(t,", max and min is a number > 0, max should > min")),this):(this._videoConfig.minBitrate=t,this._videoConfig.maxBitrate=r,this)}}),Object.defineProperty(t.prototype,"build",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._videoConfig}}),t}();!function(e){e[e.NORMAL=0]="NORMAL",e[e.SECRET=1]="SECRET"}(x||(x={}));var J,W=function(e){var t=e.callId,r=e.callType,i=e.callDir,n=e.mediaType,a=e.callingUserId,o=e.callUserIds,_=e.callStatus,l=e.sessionStatus,s=e.startTime,c=e.endTime,u=e.duration,L=e.syncTime,d=e.sysStatus,E=e.crtTime,C=e.innerExtra;return{callId:t,callType:r,callDirection:i,mediaType:n,callerUserId:a,callUserIds:o,sessionState:_,userState:l,startTimestamp:s,endTimestamp:c,duration:u,syncTimestamp:L,systemState:d,createTimestamp:E,isSecret:e.secretChat===x.SECRET,syncData:C}},K=function(e){var t=e.voipCallInfo;return!!t&&1===JSON.parse(t).strategy},Q=function(t,r){return!t&&0!==t||e(t)&&!(t<=0)?!r&&0!==r||e(r)&&!(r<=0)?t&&r&&r<t?{code:D.PARAM_ERROR,errorMsg:"params error -> maxBitrate: ".concat(r,", minBitrate: ").concat(t,", maxBitrate should > minBitrate")}:{code:D.SUCCESS}:{code:D.PARAM_ERROR,errorMsg:"params error -> maxBitrate: a number of > 0, value: ".concat(r)}:{code:D.PARAM_ERROR,errorMsg:"params error -> minBitrate: a number of > 0, value: ".concat(t)}},q=function(e){var t=[];for(var r in e){var i=e[r],n=i.videoView,a=i.isTiny;t.push({userId:r,videoView:n.nodeName,isTiny:a})}return t},X=function(e,t,r){void 0===t&&(t={}),void 0===r&&(r={});var i=t.threadId,n=t.apnsCollapseId,a=t.richMediaUri,o=r.channelIdMi,_=r.channelIdHW,l=r.channelIdOPPO,s=r.typeVivo,c=r.fcmChannelId,u=r.fcmCollapseKey,L=r.fcmImageUrl,d=r.importanceHW,E=r.categoryHW,C=r.imageUrlHW,T=r.categoryVivo,I=r.importanceHonor,g=r.imageUrlHonor,S={};i&&(S["thread-id"]=i),S["apns-collapse-id"]=n||e,a&&(S.richMediaUri=a);var f={};_&&(f.channelId=_),C&&(f.image=C),E&&(f.category=E),f.importance=d||"NORMAL";var p,h,b,R,O=[{HW:f},{APNS:S}];return(u||L||c)&&(p={},u&&(p.collapse_key=u),L&&(p.imageUrl=L),c&&(p.channelId=c),O[0].FCM=p),o&&(O[0].MI={channelId:o}),l&&((h={}).channelId=l,O[0].OPPO=h),(s||T)&&(b={},s&&(b.classification=s),T&&(b.category=T),O[0].VIVO=b),(I||g)&&(R={},I&&(R.importance=I),g&&(R.image=g),O[0].HONOR=R),JSON.stringify(O)},z=function(e,r){var i=e.pushTitle,n=void 0===i?"":i,a=e.iOSConfig,o=e.androidConfig,_=e.disablePushTitle,l=e.templateId,s={pushConfigs:X(r,a,o)};return t(_)&&(s.disableTitle=_),n&&(s.title=n),l&&(s.templateId=l),JSON.stringify(s)},Z=function(e){var n=["pushTitle","iOSConfig","androidConfig","disablePushTitle","templateId"],a=Object.keys(e).every((function(e){return n.includes(e)}));if(!a)return{code:D.PARAM_ERROR,errorMsg:"right key: ".concat(n.join(","))};for(var o=0;o<n.length;o++){var _=n[o];if("disablePushTitle"===_){if(!r(e[_])&&!t(e[_]))return{code:D.PARAM_ERROR,errorMsg:"".concat(_," type is boolean")}}else if(("pushTitle"===_||"templateId"===_)&&e[_]&&!i(e[_]))return{code:D.PARAM_ERROR,errorMsg:"".concat(_," type is string")}}var l=e.iOSConfig,s=e.androidConfig,c=$(l||{});if(c.code!==D.SUCCESS)return c;var u=ee(s||{});return u.code!==D.SUCCESS?u:{code:D.SUCCESS}},$=function(e){var t=e||{},r=t.threadId,n=t.richMediaUri;return r&&!i(r)?{code:D.PARAM_ERROR,errorMsg:"iOSConfig.threadId type is string"}:n&&!i(n)?{code:D.PARAM_ERROR,errorMsg:"iOSConfig.richMediaUri type is string"}:{code:D.SUCCESS}},ee=function(e){var t=["channelIdMi","channelIdHW","categoryHW","importanceHW","imageUrlHW","channelIdOPPO","typeVivo","categoryVivo","fcmChannelId","fcmCollapseKey","fcmImageUrl","importanceHonor","imageUrlHonor"],r=Object.keys(e).every((function(e){return t.includes(e)}));if(!r)return{code:D.PARAM_ERROR,errorMsg:"right key: ".concat(t.join(","))};for(var n=0;n<t.length;n++){var a=t[n];if("importanceHW"===a||"importanceHonor"===a){if(e[a]&&"LOW"!==e[a]&&"NORMAL"!==e[a])return{code:D.PARAM_ERROR,errorMsg:"androidConfig.".concat(a," value is NORMAL|LOW")}}else if(e[a]&&!i(e[a]))return{code:D.PARAM_ERROR,errorMsg:"androidConfig.".concat(a," type is string")}}return{code:D.SUCCESS}},te=function(e,t){void 0===t&&(t="utf-8");return"utf-16"===t?re(e):ie(e)},re=function(e){for(var t=0,r=0,i=e.length;r<i;r++)t+=e.charCodeAt(r)<=65535?2:4;return t},ie=function(e){for(var t,r=0,i=0,n=e.length;i<n;i++)r+=(t=e.charCodeAt(i))<127?1:t<=2047?2:t<=65535?3:4;return r};!function(e){e.L_QS_START_CALL_S="Call-start-S",e.L_QS_ACCEPT_CALL_S="Call-accept-S",e.L_QS_HANGUP_CALL_S="Call-hangup-S",e.L_QS_RECEIVE_CALL_S="Call-recv-S",e.L_QS_ABNORMAL_HANGUP_S="Call-interrupt-S"}(J||(J={}));var ne,ae,oe,_e=function(){function e(e,t){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t})}return Object.defineProperty(e.prototype,"reportStatisticsData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,n,a,o){var _=+new Date,l=i?{mediaType:i.getMediaType(),callType:i.getCallType(),callId:i.getCallId()}:o,s={cr:"unknown",net:"unknown",cod:t,mtp:l.mediaType,ctp:l.callType,cid:l.callId,time:_,uid:this._context.getCurrentId()};n&&Object.assign(s,{ccid:n});var c=null;switch(e){case J.L_QS_RECEIVE_CALL_S:c=m(m({},s),{rf:a});break;case J.L_QS_ABNORMAL_HANGUP_S:c=m({},s);break;default:c=m(m({},s),{dur:_-r})}this._logger.__statistics(e,JSON.stringify(c))}}),e}();!function(e){e.REQUEST="request",e.ACCEPT="accept",e.REFUSE="refuse",e.CANCEL="cancel",e.NOTICE="notice",e.TIMEOUT="timeout"}(ne||(ne={})),function(e){e[e.SWITCH_MEDIA_TYPE=1]="SWITCH_MEDIA_TYPE"}(ae||(ae={})),function(e){e.INVITER="inviter",e.INVITEE="invitee"}(oe||(oe={}));var le,se=function(e){function t(t,r,i,n,a,o,_,l,s,c,u){void 0===c&&(c=""),void 0===u&&(u="");var L=e.call(this)||this;return Object.defineProperty(L,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(L,"_state",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(L,"_callType",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(L,"_mediaType",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(L,"_startCallerId",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(L,"_callerId",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(L,"_callUsers",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(L,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:l}),Object.defineProperty(L,"_isSecret",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(L,"_syncData",{enumerable:!0,configurable:!0,writable:!0,value:c}),Object.defineProperty(L,"_secretKey",{enumerable:!0,configurable:!0,writable:!0,value:u}),Object.defineProperty(L,"_reqMediaType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(L,"_inviterTimerId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(L,"_inviteeTimerId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(L,"_oldDialogData",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(L,"isLocalClientHangup",{enumerable:!0,configurable:!0,writable:!0,value:!1}),L}return N(t,e),Object.defineProperty(t.prototype,"getCallId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callId}}),Object.defineProperty(t.prototype,"getSessionState",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._state}}),Object.defineProperty(t.prototype,"getCallType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callType}}),Object.defineProperty(t.prototype,"getMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._mediaType}}),Object.defineProperty(t.prototype,"getStartCallerId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._startCallerId}}),Object.defineProperty(t.prototype,"getCallerId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callerId}}),Object.defineProperty(t.prototype,"getUserList",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callUsers}}),Object.defineProperty(t.prototype,"getReqMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._reqMediaType}}),Object.defineProperty(t.prototype,"getInviterTimerId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._inviterTimerId}}),Object.defineProperty(t.prototype,"getInviteeTimerId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._inviteeTimerId}}),Object.defineProperty(t.prototype,"getAllTimerIds",{enumerable:!1,configurable:!0,writable:!0,value:function(){return[this._inviterTimerId,this._inviteeTimerId]}}),Object.defineProperty(t.prototype,"setUserDeviceEnable",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){this._logger.info(M.L_INNER_SESSION_SET_USER_DEVICE_ENABLE_O,"userId: ".concat(e,", mediaType: ").concat(t,", enable: ").concat(r),i);var n=this._callUsers.find((function(t){return e===t.userId}));t===G.AUDIO?n.microphoneEnable=r:n.cameraEnable=r}}),Object.defineProperty(t.prototype,"updateUserList",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this,i=[];return e.forEach((function(e){var t=e.userState,n=e.stateTime,a=e.systemState,o=e.userId,_=r._callUsers.findIndex((function(e){return e.userId===o}));if(_<0)return r._callUsers.push(e),void i.push(e);var l,s,c,u,L=r._callUsers[_],d=L.stateTime,E=L.systemState,C=L.userState,T=(l=E,s=a,c=!1,u=[k.INVITED,k.RINGING,k.BUSYLINE_RINGING,k.BUSYLINE_WAIT,k.CONNECTING,k.ONCALL],l===k.ONCALL&&u.includes(s)&&(c=!0),c),I=function(e,t){var r=!1,i=[j.INVITED,j.RINGING,j.BUSYLINE_RINGING,j.BUSYLINE_WAIT,j.CONNECTING,j.ONCALL];return e===j.ONCALL&&i.includes(t)&&(r=!0),r}(C,t),g=a===k.ON_PHONE_END&&E!==k.ON_PHONE&&t!==j.IDLE;n&&d&&n<d||T&&I||(r._callUsers[_]=e,!g&&i.push(e))})),i}}),Object.defineProperty(t.prototype,"setOldDialogData",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._oldDialogData=e}}),Object.defineProperty(t.prototype,"updateSessionState",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._state=e}}),Object.defineProperty(t.prototype,"updateCallType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._callType=e}}),Object.defineProperty(t.prototype,"updateMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._mediaType=e}}),Object.defineProperty(t.prototype,"updateReqMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._reqMediaType=e}}),Object.defineProperty(t.prototype,"updateTimerId",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e===oe.INVITER?this._inviterTimerId=t:this._inviteeTimerId=t}}),Object.defineProperty(t.prototype,"getOldDialogData",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._oldDialogData}}),Object.defineProperty(t.prototype,"setIsLocalClientHangup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.isLocalClientHangup=e}}),Object.defineProperty(t.prototype,"getIsLocalClientHangup",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.isLocalClientHangup}}),Object.defineProperty(t.prototype,"getSyncData",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._syncData}}),Object.defineProperty(t.prototype,"isSecret",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._isSecret}}),Object.defineProperty(t.prototype,"getSecretKey",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._secretKey}}),t}(n);!function(e){e.START_SINGLE_CALL="startSingleCall",e.START_GROUP_CALL="startGroupCall",e.INVITE_CALL="inviteCall",e.PUB_INVITE_CALL="pubInviteCall",e.RINGING_CALL="ringCall",e.ACCEPT_CALL="acceptCall",e.JOIN_CALL="joinCall",e.HANGUP_CALL="hangupCall",e.STATUS_UP_CALL="statusUpCall",e.STATUS_DOWN_CALL="statusDownCall",e.EVENT_UP_CALL="eventUpCall",e.EVENT_DOWN_CALL="eventDownCall",e.DIALOG_UP_CALL="dialogUpCall",e.DIALOG_DOWN_CALL="dialogDownCall",e.GET_CALL_USER_SESSION_LIST="getCallUSerSessionList",e.SYNC_CALL_LOG="syncCallLog",e.PUB_CALL_LOG="pubCallLog",e.DEL_CALL_LOG="deleteCallLog",e.QRY_CALL_STATE="queryUserHasCall",e.QRY_SRV_TIMESTAMP="getCallSrvTimeStamp",e.GET_CALL_STATE_LIST="getUserCallStateList",e.CLEAR_CALL_LOG="cleanCallLog",e.GET_CALL_SESSION="getCallSession",e.GET_CALL_TIME_INFO="getCallTimeInfo",e.END_ABNORMAL_CALL="endUserAbnormalCalls",e.SYS_STATUS_UP="sysStatusUp",e.UP_CALL_LOG_READED="upCallLogReaded",e.PUB_CALL_LOG_READED="pubCallLogReaded",e.PUB_NACK_SEQ_ID="pubNACKSeqId",e.GET_USER_CALL_SESSION_ID_LIST="getUserCallSessionIdList"}(le||(le={}));var ce,ue,Le=function(e,t){return setTimeout(e,t)},de=[a.RC_NET_CHANNEL_INVALID,a.RC_NET_UNAVAILABLE,a.RC_MSG_RESP_TIMEOUT,p.SIGNAL_DISCONNECTED,p.REQUEST_FAILED],Ee=function(e){var t=e.asyncFn,r=e.fnArgs,i=e.currentRetryTime,n=void 0===i?Date.now():i,a=e.maxDuration,o=void 0===a?6e4:a,_=e.intervals,l=void 0===_?[2e3,4e3,8e3,16e3,32e3,64e3]:_,s=e.index,c=void 0===s?0:s,u=e.onError;return v(void 0,void 0,void 0,(function(){var e;return y(this,(function(i){switch(i.label){case 0:return[4,t.apply(void 0,U([],P(r),!1))];case 1:return e=i.sent(),e.code===D.SUCCESS||!de.includes(e.code)||Date.now()+2e3-n>o?[3,3]:(u&&u(e.code),[4,(a=2e3,new Promise((function(e){setTimeout(e,a)})))]);case 2:return i.sent(),[2,Ee({asyncFn:t,fnArgs:r,currentRetryTime:n,maxDuration:o,intervals:l,index:c,onError:u})];case 3:return[2,e]}var a}))}))},Ce=131072,Te="RC:CallPlusMiss",Ie=function(e){function t(t,r,i,n){var a=e.call(this)||this;return Object.defineProperty(a,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(a,"_timeCorrectioner",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(a,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"_listener",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"_needRetryActions",{enumerable:!0,configurable:!0,writable:!0,value:[le.START_SINGLE_CALL,le.START_GROUP_CALL,le.ACCEPT_CALL,le.JOIN_CALL,le.EVENT_UP_CALL]}),Object.defineProperty(a,"_sessionId",{enumerable:!0,configurable:!0,writable:!0,value:""}),a._context.onCallInfo=a._onRecvCallSignal.bind(a),a._context.onconnectionstatechange=a._onIMConnectionStateChange.bind(a),a._context.onmessage=a._onMessage.bind(a),a._sessionId=s(),a}return N(t,e),Object.defineProperty(t.prototype,"_onMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if([Te].includes(e.messageType)){var t=e.content,r=t.callId,i=t.mediaType,n=t.startTime,a=t.callSessionUsers,_=t.innerExtra,l=t.secretChat,s=e.targetId,c=e.senderUserId,u=this._context.getCurrentId();if(!localStorage.getItem("missMessageMap-".concat(u,"-").concat(r))){var L=a.filter((function(e){return e.userId===u}))[0],d=L.sysStatus;0===d&&(d=L.sessionStatus);var E={callId:r,callerUserId:c,targetId:s,mediaType:i,firstFrameTime:0,callStartTime:n-this._timeCorrectioner.getLocalDelayTime(),callEndTime:0,hangupReason:d,isSecret:l===x.SECRET,syncData:_,isSelfHangup:!1};this._logger.info(M.L_SIGNAL_TRANSPORTER_RECEIVE_MISS_MESSAGE_O,"receive miss message: ".concat(JSON.stringify(e)));var C=Object.assign(e,{content:E,sentStatus:o.SENT});this._reportAppEventModule.onReceivedCallPlusSummaryMessage(C),localStorage.setItem("missMessageMap-".concat(u,"-").concat(r),r)}return!0}return!1}}),Object.defineProperty(t.prototype,"getSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._sessionId}}),Object.defineProperty(t.prototype,"getDeviceId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return/Electron/.test(navigator.userAgent)?this._context.getDeviceId():this._sessionId}}),Object.defineProperty(t.prototype,"registerListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._listener=e}}),Object.defineProperty(t.prototype,"startCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i,n,a,o,_,l,s,c,u,L,d,E,C,T,I,g;return y(this,(function(S){return r=e.callId,i=e.clientCallId,n=e.callType,a=e.toUsers,o=e.mediaType,_=e.secretChat,l=e.targetType,s=e.targetId,c=e.nickName,u=e.oldRoomId,L=e.pushExt,d=e.extra,E=e.innerExtra,C=e.secretChatKey,T={clientCallId:i,mediaType:o,targetType:l,targetId:s,oldRoomId:u,pushExt:L,extra:d,innerExtra:E,secretChat:_,secretChatKey:C},r&&(T=m(m({},T),{callId:r})),n===w.SINGLE?(I=m(m({},T),{toUserId:a[0].userId,toOrgId:a[0].orgId||""}),[2,this.startSingleCall(I,t)]):(g=m(m({},T),{toUsers:a,nickName:c}),[2,this.startGroupCall(g,t)])}))}))}}),Object.defineProperty(t.prototype,"startSingleCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._logger.info(M.L_SIGNAL_TRANSPORTER_SINGLE_CALL_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(this._context.getCurrentId(),le.START_SINGLE_CALL,e)]}))}))}}),Object.defineProperty(t.prototype,"startGroupCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._logger.info(M.L_SIGNAL_TRANSPORTER_GROUP_CALL_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(this._context.getCurrentId(),le.START_GROUP_CALL,e)]}))}))}}),Object.defineProperty(t.prototype,"inviteCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._logger.info(M.L_SIGNAL_TRANSPORTER_INVITE_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.callId,le.INVITE_CALL,e)]}))}))}}),Object.defineProperty(t.prototype,"ringingCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._logger.info(M.L_SIGNAL_TRANSPORTER_RING_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.callId,le.RINGING_CALL,e)]}))}))}}),Object.defineProperty(t.prototype,"acceptCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._logger.info(M.L_SIGNAL_TRANSPORTER_ACCEPT_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.callId,le.ACCEPT_CALL,e)]}))}))}}),Object.defineProperty(t.prototype,"joinCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._logger.info(M.L_SIGNAL_TRANSPORTER_JOIN_CALL_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.callId,le.JOIN_CALL,e)]}))}))}}),Object.defineProperty(t.prototype,"hangupCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r;return y(this,(function(i){switch(i.label){case 0:return this._logger.info(M.L_SIGNAL_TRANSPORTER_HANGUP_T,"params: ".concat(JSON.stringify(e)),t),[4,this._sendCallSignal(e.callId,le.HANGUP_CALL,e)];case 1:return(r=i.sent().code)===D.NOT_IN_CALL?[2,{code:D.SUCCESS}]:[2,{code:r}]}}))}))}}),Object.defineProperty(t.prototype,"statusUpCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._logger.info(M.L_SIGNAL_TRANSPORTER_CALL_STATUS_UP_T,"call status up params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.callId,le.STATUS_UP_CALL,e)]}))}))}}),Object.defineProperty(t.prototype,"eventUpCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._logger.info(M.L_SIGNAL_TRANSPORTER_CALL_EVENT_UP_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.callId,le.EVENT_UP_CALL,e)]}))}))}}),Object.defineProperty(t.prototype,"dialogUpCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._logger.info(M.L_SIGNAL_TRANSPORTER_CALL_DIALOG_UP_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.callId,le.DIALOG_UP_CALL,e)]}))}))}}),Object.defineProperty(t.prototype,"deleteCallRecord",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return v(this,void 0,void 0,(function(){return y(this,(function(i){return this._logger.info(M.L_SIGNAL_TRANSPORTER_DELETE_CALL_RECORD_T,"callIds: ".concat(JSON.stringify(t)),r),[2,this._sendCallSignal(e,le.DEL_CALL_LOG,{callIds:t})]}))}))}}),Object.defineProperty(t.prototype,"syncCallLog",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._logger.info(M.L_SIGNAL_TRANSPORTER_GET_CALL_RECORD_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.userId,le.SYNC_CALL_LOG,e)]}))}))}}),Object.defineProperty(t.prototype,"queryUserHasCall",{enumerable:!1,configurable:!0,writable:!0,value:function(){return v(this,void 0,void 0,(function(){var e;return y(this,(function(t){return e=this._context.getCurrentId(),[2,this._sendCallSignal(e,le.QRY_CALL_STATE,null)]}))}))}}),Object.defineProperty(t.prototype,"getCallServerTimestamp",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t;return y(this,(function(r){return t=this._context.getCurrentId(),this._logger.info(M.L_SIGNAL_TRANSPORTER_GET_CALL_SERVER_TIME_T,"userId: ".concat(t),e),[2,this._sendCallSignal(t,le.QRY_SRV_TIMESTAMP,null)]}))}))}}),Object.defineProperty(t.prototype,"getCallTimeInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._logger.info(M.L_SIGNAL_TRANSPORTER_GET_CALL_TIME_INFO_T,"callId: ".concat(e),t),[2,this._sendCallSignal(e,le.GET_CALL_TIME_INFO,{callId:e})]}))}))}}),Object.defineProperty(t.prototype,"getUserCallStateList",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t;return y(this,(function(r){return t=this._context.getCurrentId(),this._logger.info(M.L_SIGNAL_TRANSPORTER_GET_AVAILABLE_CALL_LIST_T,"userId: ".concat(t),e),[2,this._sendCallSignal(t,le.GET_CALL_STATE_LIST,null)]}))}))}}),Object.defineProperty(t.prototype,"clearCallRecord",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t;return y(this,(function(r){return t=this._context.getCurrentId(),this._logger.info(M.L_SIGNAL_TRANSPORTER_CLEAR_CALL_RECORD_T,"userId: ".concat(t),e),[2,this._sendCallSignal(t,le.CLEAR_CALL_LOG,null)]}))}))}}),Object.defineProperty(t.prototype,"getCallSession",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._logger.info(M.L_SIGNAL_TRANSPORTER_GET_CALL_INFO_BY_CALLID_T,"callId: ".concat(e.callId),t),[2,this._sendCallSignal(e.callId,le.GET_CALL_SESSION,e)]}))}))}}),Object.defineProperty(t.prototype,"sysStatusUp",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._logger.info(M.L_SIGNAL_TRANSPORTER_USER_SYSTEM_STATE_UP_T,"opts: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.callId,le.SYS_STATUS_UP,e)]}))}))}}),Object.defineProperty(t.prototype,"upCallLogReaded",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t;return y(this,(function(r){return t=this._context.getCurrentId(),[2,this._sendCallSignal(t,le.UP_CALL_LOG_READED,e)]}))}))}}),Object.defineProperty(t.prototype,"endUserAbnormalCalls",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){return y(this,(function(t){return[2,this._sendCallSignal(this._context.getCurrentId(),le.END_ABNORMAL_CALL,e)]}))}))}}),Object.defineProperty(t.prototype,"_onIMConnectionStateChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._logger.createTraceId();this._logger.info(M.L_SIGNAL_TRANSPORTER_IM_STATE_CHANGE_O,"state: ".concat(e),t),this._listener.onIMStateChange(e),e===_.CONNECTED?this._timeCorrectioner.start(t):this._timeCorrectioner.stop(t)}}),Object.defineProperty(t.prototype,"_sendCallSignal",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return v(this,void 0,void 0,(function(){var i,n,o,_,l,s,c;return y(this,(function(u){switch(u.label){case 0:return i=/Electron/.test(navigator.userAgent),n="",r&&(n=i?JSON.stringify(r):JSON.stringify(m(m({},r),{sessionId:this._sessionId}))),this._needRetryActions.includes(t)?[4,Ee({asyncFn:this._context.setCallInfo.bind(this._context),fnArgs:[e,t,n]})]:[3,2];case 1:return o=u.sent(),[3,4];case 2:return[4,this._context.setCallInfo(e,t,n)];case 3:o=u.sent(),u.label=4;case 4:return _=o.code,l=o.data,_!==a.SUCCESS?[2,{code:_}]:(s=l.value,c=JSON.parse(s).data,[2,{code:D.SUCCESS,data:c}])}}))}))}}),Object.defineProperty(t.prototype,"_onRecvCallSignal",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,r=this._logger.createTraceId();this._logger.info(M.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_SIGNAL_DATA_O,"data: ".concat(e),r),JSON.parse(e).list.forEach((function(e){var i=e.key,n=JSON.parse(e.value);switch(i){case le.PUB_INVITE_CALL:t._onPubInviteCall(n,r,!0);break;case le.STATUS_DOWN_CALL:t._onStatusDownCall(n,r);break;case le.EVENT_DOWN_CALL:t._onEventDownCall(n,r);break;case le.DIALOG_DOWN_CALL:t._onDialogDownCall(n,r);break;case le.PUB_CALL_LOG:t._onPubCallLog(n,r);break;case le.PUB_CALL_LOG_READED:case le.PUB_NACK_SEQ_ID:break;default:t._onCompensationData(n,r)}}))}}),Object.defineProperty(t.prototype,"isValidData",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(l(e))return!0;var t=e===this.getDeviceId();return!(!i(e)||0!==(null==e?void 0:e.length)&&!t)}}),Object.defineProperty(t.prototype,"_onPubInviteCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){void 0===r&&(r=!0);try{var i=this._context.getCurrentId(),n=e.callSessionUsers.find((function(e){return e.userId===i})),a=this._context.getConnectionStatus();this._logger.info(M.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,"currentUser: ".concat(JSON.stringify(n),", currentUserId: ").concat(i,", state: ").concat(a),t)}catch(e){this._logger.error(M.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,"error: ".concat(e.message),t)}this.isValidData(e.toDeviceId||"")?this._listener.onInvite(e,r,t):this._logger.warn(M.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,"not current deviceId -> deviceInfo: ".concat(JSON.stringify({toDeviceId:e.toDeviceId,clientDeviceId:this._sessionId})),t)}}),Object.defineProperty(t.prototype,"_onStatusDownCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(e.callSessionUsers=e.callSessionUsers.filter((function(e){return Boolean(e.changed)})),this._logger.info(M.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O,"",t),!this.isValidData(e.toDeviceId||""))return this._logger.warn(M.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O,"not current deviceId -> deviceInfo: ".concat(JSON.stringify({toDeviceId:e.toDeviceId,clientDeviceId:this._sessionId})),t),void this._listener.onOtherClientStatusDown(e,t);this._listener.onStatusDown(e,!0,t)}}),Object.defineProperty(t.prototype,"_onEventDownCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._listener.onEventDown(e,t)}}),Object.defineProperty(t.prototype,"_onDialogDownCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.dialogType===ae.SWITCH_MEDIA_TYPE&&this._listener.onSwitchMediaType(e,t)}}),Object.defineProperty(t.prototype,"_onPubCallLog",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(M.L_CALL_ENGINE_RECEIVE_CALL_RECORD_O,"call record: ".concat(JSON.stringify(e)),t),this._listener.onRecvCallEndLog(e,t)}}),Object.defineProperty(t.prototype,"_onCompensationData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;this._logger.info(M.L_CALL_ENGINE_RECEIVE_COMPLEMENTARY_DATA_O,"",t);var i=e.callId,n=e.callType,a=e.mediaType,o=e.secretChat,_=e.duration,l=e.callStatus,s=e.callingUserId,c=e.callSessionUsers,u=e.toDeviceId,L=e.callDialogEntitys,d=e.extra,E=e.syncTime,C=e.startTime,T=e.innerExtra,I=e.secretChatKey;c.some((function(e){return e.sessionStatus===j.INVITED&&e.userId===r._context.getCurrentId()}))?this._onPubInviteCall({callId:i,toDeviceId:u,callType:n,mediaType:a,inviteUserId:s,callingUserId:s,callSessionUsers:c,secretChat:o,extra:d,innerExtra:T,secretChatKey:I},t,!0):this._onStatusDownCall({callId:i,toDeviceId:u,callStatus:l,duration:_,callSessionUsers:c,syncTime:E,startTime:C},t),L.length>0&&L.forEach((function(e){return r._onDialogDownCall(e,t)}),this)}}),t}(n),ge=function(){var e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));return e="".concat(e.replace(/-/g,""),"0"),(e=function(e){var t="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ+/".split(""),r=t.length+1,i=+e,n=[];do{var a=i%r;i=(i-a)/r,n.unshift(t[a])}while(i);return n.join("")}(e=parseInt(e,16))).length>22&&(e=e.slice(0,22)),e},Se=function(){function e(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e})}return Object.defineProperty(e.prototype,"addAbnormallCallId",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){try{var i=JSON.parse(localStorage.getItem(e._STORAGE_KEY)||"{}"),n=i[t];n?n.push(r):n=[r],i[t]=n,localStorage.setItem(e._STORAGE_KEY,JSON.stringify(i))}catch(e){this._logger.error(M.L_ABNORMAL_ADD_CALL_ID_E,e.message),console.error(e)}}}),Object.defineProperty(e.prototype,"removeAbnormalCallIds",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){try{var i=JSON.parse(localStorage.getItem(e._STORAGE_KEY)||"{}"),n=i[t];n&&((n=n.filter((function(e){return!r.includes(e)}))).length>0?i[t]=n:delete i[t],localStorage.setItem(e._STORAGE_KEY,JSON.stringify(i)))}catch(e){this._logger.error(M.L_ABNORMAL_REMOVE_CALL_IDS_E,e.message),console.error(e)}}}),Object.defineProperty(e.prototype,"getAbnormalCallIds",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=null;try{var i=JSON.parse(localStorage.getItem(e._STORAGE_KEY)||"{}")[t];i&&(r=i)}catch(e){this._logger.error(M.L_ABNORMAL_GET_CALL_IDS_E,e.message),console.error(e)}return Promise.resolve(r)}}),Object.defineProperty(e,"_STORAGE_KEY",{enumerable:!0,configurable:!0,writable:!0,value:"CallPlus_AbnormalCall"}),e}();!function(e){e[e.PROMPT=0]="PROMPT",e[e.CALL_DURATION=10]="CALL_DURATION",e[e.FIRST_FRAME=20]="FIRST_FRAME"}(ce||(ce={})),function(e){e[e.SUCCESS=0]="SUCCESS",e[e.INVALID_RESPONSE_TIME=80170]="INVALID_RESPONSE_TIME",e[e.NONOPTIMAL_RES_TIME=80171]="NONOPTIMAL_RES_TIME"}(ue||(ue={}));var fe,pe,he,be=function(){function e(e,t,r){Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_singleCallDurationEv",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_RTT",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_validMinRTT",{enumerable:!0,configurable:!0,writable:!0,value:200}),Object.defineProperty(this,"_validMaxRTT",{enumerable:!0,configurable:!0,writable:!0,value:1e3}),Object.defineProperty(this,"_deltaTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_timerId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_interval",{enumerable:!0,configurable:!0,writable:!0,value:2e3}),Object.defineProperty(this,"_maxRetryTimes",{enumerable:!0,configurable:!0,writable:!0,value:8}),Object.defineProperty(this,"_startTimes",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_retryTimesInCall",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_maxRetryTimesInCall",{enumerable:!0,configurable:!0,writable:!0,value:3})}return Object.defineProperty(e.prototype,"getCallClientTimeByServer",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i,n,a,o,_,l;return y(this,(function(s){switch(s.label){case 0:return this._logger.info(M.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_T,"callId: ".concat(e),t),!this._RTT||this._RTT>this._validMinRTT?[4,this._getDeltaTime(t)]:[3,2];case 1:s.sent(),s.label=2;case 2:return this._RTT>this._validMaxRTT&&this._logger.error(M.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,"code: ".concat(ue.INVALID_RESPONSE_TIME),t),[4,this._callEngine.getCallTimeInfo(e,t)];case 3:return r=s.sent(),i=r.code,n=r.data,i!==D.SUCCESS?(this._logger.error(M.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,"code: ".concat(i),t),[2,{code:i}]):(a=n.startTime,o=Math.floor(a-this._deltaTime),_=Date.now(),(l=(_+this._deltaTime-a)/1e3)<0&&(this._logger.warn(M.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_P,"invalid duration: ".concat(l),t),l=0),l=Math.floor(l),this._RTT>this._validMinRTT&&this._RTT<=this._validMaxRTT&&this._logger.error(M.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,"code: ".concat(ue.NONOPTIMAL_RES_TIME),t),this._logger.info(M.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime,serverStartTime:a,clientStartTime:o,duration:l}),t),[2,{code:i,duration:l,clientStartTime:a?o:a}])}}))}))}}),Object.defineProperty(e.prototype,"calcClientStartTime",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){if(this._logger.info(M.L_TIME_CORRECT_CALC_CLIENT_START_TIME_T,"callId: ".concat(e,", startTime: ").concat(t),r),this._RTT>this._validMaxRTT)return this._logger.error(M.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R,"code: ".concat(ue.INVALID_RESPONSE_TIME),r),this._loopCorrectClientTime(e,r),{code:ue.INVALID_RESPONSE_TIME};var i=Math.floor(t-this._deltaTime);return this._logger.info(M.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime,startT:t,clientStartTime:i}),r),this._RTT>this._validMinRTT&&(this._retryTimesInCall=0,this._loopCorrectClientTime(e,r)),{code:ue.SUCCESS,clientStartTime:i}}}),Object.defineProperty(e.prototype,"start",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;this._timerId||this._startTimes>=this._maxRetryTimes||(this._logger.info(M.L_TIME_CORRECT_START_O,"timerId: ".concat(this._timerId)),this._startTimes++,this._getDeltaTime(e),this._timerId=Le((function(){t._timerId=null,t.start(e)}),this._interval))}}),Object.defineProperty(e.prototype,"stop",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(M.L_TIME_CORRECT_STOP_O,"timerId: ".concat(this._timerId),e),this._timerId&&clearTimeout(this._timerId),this._timerId=null,this._startTimes=0}}),Object.defineProperty(e.prototype,"restart",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(M.L_TIME_CORRECT_RESTART_O,"legal rtt time, RTT: ".concat(this._RTT,", validMinRTT: ").concat(this._validMinRTT),e),this._RTT<this._validMinRTT||(this.stop(e),this.start(e))}}),Object.defineProperty(e.prototype,"getLocalDelayTime",{enumerable:!1,configurable:!0,writable:!0,value:function(){return Math.round(this._deltaTime)}}),Object.defineProperty(e.prototype,"getRTT",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._RTT}}),Object.defineProperty(e.prototype,"_getDeltaTime",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i,n,a,o;return y(this,(function(_){switch(_.label){case 0:return t=Date.now(),[4,this._callEngine.getCallServerTimestamp(e)];case 1:return r=_.sent(),i=r.code,n=r.data,a=Date.now(),i!==D.SUCCESS?[2,{code:i}]:(((o=a-t)<this._RTT||0===this._RTT)&&o<=this._validMaxRTT&&(this._RTT=o),o<this._validMinRTT&&this.stop(e),this._deltaTime=n-t-this._RTT/2,this._logger.info(M.L_TIME_CORRECT_SET_DELTA_TIME_O,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime}),e),[2,{code:i,delayTime:this._deltaTime}])}}))}))}}),Object.defineProperty(e.prototype,"_getDeltaTimeInCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i,n,a,o,_,l,s;return y(this,(function(c){switch(c.label){case 0:return r=Date.now(),[4,this._callEngine.getCallTimeInfo(e,t)];case 1:return i=c.sent(),n=i.code,a=i.data,o=Date.now(),n!==D.SUCCESS?[2,{code:n}]:((_=o-r)<this._RTT&&(this._RTT=_),this._deltaTime=a.syncTime-r-this._RTT/2,this._logger.info(M.L_TIME_CORRECT_SET_DELTA_TIME_O,JSON.stringify({callId:e,rtt:this._RTT,deltaT:this._deltaTime}),t),l=Math.floor(a.startTime-this._deltaTime),s=Math.floor(a.firstFrametime-this._deltaTime),_<this._validMinRTT?[2,{code:ue.SUCCESS,clientStartTime:l,clientFirstFrameTime:s}]:[2,{code:ue.INVALID_RESPONSE_TIME,clientStartTime:l,clientFirstFrameTime:s}])}}))}))}}),Object.defineProperty(e.prototype,"_loopCorrectClientTime",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i,n,a,o=this;return y(this,(function(_){switch(_.label){case 0:return this.stop(t),this._logger.info(M.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_T,"callId: ".concat(e),t),[4,this._getDeltaTimeInCall(e,t)];case 1:return r=_.sent(),i=r.code,n=r.clientStartTime,a=r.clientFirstFrameTime,i===ue.SUCCESS?(this._logger.info(M.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R,"code: ".concat(D.SUCCESS),t),this._singleCallDurationEv(e,n,a,t),[2]):this._retryTimesInCall>this._maxRetryTimesInCall&&i===ue.INVALID_RESPONSE_TIME?(this._logger.info(M.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R,"code: ".concat(ue.INVALID_RESPONSE_TIME),t),this._singleCallDurationEv(e,n,a,t),[2]):(this._retryTimesInCall>this._maxRetryTimesInCall||(this._retryTimesInCall++,setTimeout((function(){o._loopCorrectClientTime(e,t)}),this._interval)),[2])}}))}))}}),e}();!function(e){e[e.SOON_AFETER=0]="SOON_AFETER",e[e.CURRENT=1]="CURRENT"}(fe||(fe={})),function(e){e[e.PUB_INVITE_CALL=0]="PUB_INVITE_CALL",e[e.PULL_KV_INVITE_CALL=1]="PULL_KV_INVITE_CALL",e[e.SYSTEM_PUSH=2]="SYSTEM_PUSH"}(pe||(pe={})),function(e){e[e.OUT=-1]="OUT",e[e.GROUP=0]="GROUP",e[e.IN=1]="IN"}(he||(he={}));var Re,Oe=function(e){function t(t,r,i){var n=e.call(this)||this;return Object.defineProperty(n,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(n,"_mainSession",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(n,"_holdSessions",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(n,"_signalModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"_abnormalModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"_isUpFirstFrameTime",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(n,"_callStartMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(n,"_timeCorrectioner",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"_clientCallId",{enumerable:!0,configurable:!0,writable:!0,value:""}),n._timeCorrectioner=new be(n,r,n._onRecvSinCallDuration.bind(n)),n._signalModule=new Ie(t,n._timeCorrectioner,n._logger,n._reportAppEventModule),n._signalModule.registerListener({onInvite:n._onInvite.bind(n),onStatusDown:n._onStatusDown.bind(n),onOtherClientStatusDown:n._onOtherClientStatusDown.bind(n),onEventDown:n._onEventDown.bind(n),onSwitchMediaType:n._onSwitchMediaType.bind(n),onRecvCallEndLog:n._onRecvCallEndLog.bind(n),onIMStateChange:n._onIMStateChange.bind(n)}),n._abnormalModule=new Se(r),n}return N(t,e),Object.defineProperty(t.prototype,"startCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i,n,a,o,_,l,s,c,u,L,d,E,C,T,I,g,S,f,p,h,b,R,O,A,N,m=this;return y(this,(function(v){switch(v.label){case 0:return r=this._context.getCurrentId(),i=e.callType,n=e.mediaType,a=e.toUsers,o=e.targetId,_=e.targetType,l=e.oldRoomId,s=e.pushConfig,c=e.extra,u=e.innerExtra,L=e.secretChat,d=e.secretChatKey,E=void 0===d?"":d,C=e.callId,T=e.clientCallId,this._clientCallId=T,I=s?z(s,this._clientCallId):"",[4,this._signalModule.startCall({callId:C,clientCallId:T,callType:i,mediaType:n,toUsers:a,secretChat:L,targetType:_,targetId:o,oldRoomId:l,pushExt:I,extra:c,innerExtra:u,secretChatKey:E},t)];case 1:return g=v.sent(),S=g.code,f=g.data,S!==D.SUCCESS?[2,{code:S}]:(h=(p=f).callId,b=p.busylineUsers,this._abnormalModule.addAbnormallCallId(r,h),this._mainSession=new se(h,V.INVITED,i,n,r,r,[],this._logger,L===x.SECRET,u,E),i===w.SINGLE&&(R=this._startTimer(f.callId,j.NO_ANSWER,t),this._mainSession.updateTimerId(oe.INVITER,R)),O={userId:r,userState:j.CALLING,systemState:k.CALLING,targetType:_,targetId:o,cameraEnable:!1,microphoneEnable:!1},A=a.map((function(e){var t=e.userId,r=e.targetType,i=e.targetId;return{userId:t,userState:j.INVITED,systemState:k.INVITED,targetType:r,targetId:i,cameraEnable:!1,microphoneEnable:!1}})),N=[],b&&(N=b.map((function(e){var t=A.find((function(t){return t.userId===e.userId})),r=t.targetType,i=t.targetId;return{userId:e.userId,userState:e.sessionStatus,systemState:k.BUSYLINE_RINGING,targetType:r,targetId:i,cameraEnable:!1,microphoneEnable:!1}})),A=A.filter((function(e){var t=e.userId;return N.every((function(e){return e.userId!==t}))}))),setTimeout((function(){m.updateUsersState(h,U(U([O],P(A),!1),P(N),!1),t)})),[2,{code:S,data:f}])}}))}))}}),Object.defineProperty(t.prototype,"invite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;return v(this,void 0,void 0,(function(){var i,n,a,o,_,l,s,c,u,L;return y(this,(function(d){switch(d.label){case 0:return this._mainSession?(i=e.toUsers,n=e.pushConfig,a=e.extra,o=n?z(n,this._clientCallId):"",_=this._mainSession.getCallId(),[4,this._signalModule.inviteCall({callId:_,toUsers:i,pushExt:o,extra:a},t)]):[2,{code:D.NOT_IN_CALL}];case 1:return l=d.sent(),s=l.code,c=l.data,s===D.SUCCESS&&(this._mainSession.getCallType()===w.SINGLE&&(this._mainSession.updateCallType(w.MULTI),this._onCallTypeChange(this._mainSession.getCallId(),w.MULTI,t)),u=i.map((function(e){var t=e.userId,r=e.targetType,i=e.targetId;return{userId:t,userState:j.INVITED,systemState:k.INVITED,targetType:r,targetId:i,cameraEnable:!1,microphoneEnable:!1}})),L=[],c.busylineUsers&&(L=null===(r=c.busylineUsers)||void 0===r?void 0:r.map((function(e){var t=u.find((function(t){return t.userId===e.userId})),r=t.targetType,i=t.targetId;return{userId:e.userId,userState:e.sessionStatus,systemState:k.BUSYLINE_RINGING,targetType:r,targetId:i,cameraEnable:!1,microphoneEnable:!1}})),u=u.filter((function(e){var t=e.userId;return L.every((function(e){return e.userId!==t}))}))),this.updateUsersState(_,U(U([],P(u),!1),P(L),!1),t)),[2,{code:s,data:c}]}}))}))}}),Object.defineProperty(t.prototype,"clearAllTimer",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;U([this._mainSession],P(this._holdSessions),!1).forEach((function(i){i&&i.getCallId()===e&&i.getAllTimerIds().forEach((function(e){return r._stopTimer.bind(r)(e,t)}))}))}}),Object.defineProperty(t.prototype,"hangup",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i,n,a,o;return y(this,(function(_){switch(_.label){case 0:return r=e.callId,i=e.systemState,n=e.pushConfig,a=n?z(n,this._clientCallId):"",[4,this._signalModule.hangupCall({callId:r,sysStatus:i,pushExt:a},t)];case 1:return o=_.sent().code,this.endCurrentSession(e.systemState,r,t),[2,{code:o}]}}))}))}}),Object.defineProperty(t.prototype,"accept",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i;return y(this,(function(n){switch(n.label){case 0:return this._mainSession?(r=e.callId,[4,this._signalModule.acceptCall({callId:r},t)]):[2,{code:D.NOT_IN_CALL}];case 1:return i=n.sent().code,this._stopTimer(this._mainSession.getInviteeTimerId(),t),i!==D.SUCCESS?[2,{code:i}]:(this._clearMobileOnPhone(e.callId,t),this._mainSession.updateSessionState(V.CONNECTING),[2,{code:i}])}}))}))}}),Object.defineProperty(t.prototype,"joinCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i;return y(this,(function(n){switch(n.label){case 0:return r=this._context.getCurrentId(),this._mainSession&&this._stopTimer(this._mainSession.getInviteeTimerId(),t),[4,this._signalModule.joinCall({callId:e.callId},t)];case 1:return(i=n.sent().code)!==D.SUCCESS?[2,{code:i}]:(this._abnormalModule.addAbnormallCallId(r,e.callId),this._mainSession?[3,3]:[4,this._createSessionByServer(e.callId,t,!0)]);case 2:return n.sent(),[3,4];case 3:this._clearMobileOnPhone(e.callId,t),n.label=4;case 4:return[2,{code:i}]}}))}))}}),Object.defineProperty(t.prototype,"requestChangeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i,n;return y(this,(function(a){switch(a.label){case 0:return this._mainSession?(r={mediaType:e.mediaType},this._mainSession.updateReqMediaType(e.mediaType),i=ge(),[4,this._signalModule.dialogUpCall({transactionId:i,callId:this._mainSession.getCallId(),toUserIds:e.toUserIds,dialogType:ae.SWITCH_MEDIA_TYPE,action:ne.REQUEST,extraKeyVal:r},t)]):[2,{code:D.NOT_IN_CALL}];case 1:return(n=a.sent().code)!==D.SUCCESS?[2,{code:n}]:[2,{code:D.SUCCESS,data:{transactionId:i}}]}}))}))}}),Object.defineProperty(t.prototype,"responseChangeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._mainSession?[2,this._signalModule.dialogUpCall({transactionId:e.transactionId,callId:this._mainSession.getCallId(),dialogType:ae.SWITCH_MEDIA_TYPE,action:e.agree?ne.ACCEPT:ne.REFUSE},t)]:[2,{code:D.NOT_IN_CALL}]}))}))}}),Object.defineProperty(t.prototype,"cancelChangeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this._mainSession?[2,this._signalModule.dialogUpCall({transactionId:e.transactionId,callId:this._mainSession.getCallId(),dialogType:ae.SWITCH_MEDIA_TYPE,action:ne.CANCEL},t)]:[2,{code:D.NOT_IN_CALL}]}))}))}}),Object.defineProperty(t.prototype,"getCallLogList",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i,n,a,o,_,l,s;return y(this,(function(c){switch(c.label){case 0:return r=this._context.getCurrentId(),i=e.timestamp,n=e.count,a=e.order,[4,this._signalModule.syncCallLog({userId:r,syncTime:i,count:n,order:a},t)];case 1:return o=c.sent(),_=o.code,l=o.data,_!==D.SUCCESS?[2,{code:_}]:(s=l.callLogList.map((function(e){return W(e)})),[2,{code:D.SUCCESS,data:{hasMore:Boolean(null==l?void 0:l.hasMore),syncTime:0===a?l.maxTime:l.minTime,list:s}}])}}))}))}}),Object.defineProperty(t.prototype,"deleteCallLog",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r;return y(this,(function(i){return r=this._context.getCurrentId(),[2,this._signalModule.deleteCallRecord(r,e,t)]}))}))}}),Object.defineProperty(t.prototype,"getCallServerTimestamp",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i;return y(this,(function(n){switch(n.label){case 0:return[4,this._signalModule.getCallServerTimestamp(e)];case 1:return t=n.sent(),r=t.code,i=t.data,r!==D.SUCCESS?[2,{code:r}]:[2,{code:r,data:i.syncTime}]}}))}))}}),Object.defineProperty(t.prototype,"getCallTimeInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return[2,this._signalModule.getCallTimeInfo(e,t)]}))}))}}),Object.defineProperty(t.prototype,"getOpenCallList",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i,n,a,o=this;return y(this,(function(_){switch(_.label){case 0:return t=this._context.getCurrentId(),[4,this._signalModule.getUserCallStateList(e)];case 1:return r=_.sent(),i=r.code,n=r.data,i!==D.SUCCESS?[2,{code:i}]:(a=n.callStateList.map((function(r){var i=r.callId,n=r.callType,a=r.mediaType,_=r.callingUserId,l=r.callUserIds,s=r.callStatus,c=r.crtTime,u=r.userSessionStatus,L=r.startTime,d=r.syncTime,E=r.innerExtra,C=r.secretChat,T=_===t?he.OUT:he.IN,I=o._timeCorrectioner.calcClientStartTime(i,L,e).clientStartTime,g=void 0===I?L:I;return{callId:i,callType:n,callDirection:T,mediaType:a,callerUserId:_,callUserIds:l,sessionState:s,userState:u,startTimestamp:L,endTimestamp:0,duration:Math.floor((+new Date-g)/1e3),syncTimestamp:d,systemState:0,createTimestamp:c,isSecret:C===x.SECRET,syncData:E}})),[2,{code:i,data:a}])}}))}))}}),Object.defineProperty(t.prototype,"removeAllCallLog",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){return y(this,(function(t){switch(t.label){case 0:return[4,this._signalModule.clearCallRecord(e)];case 1:return[2,{code:t.sent().code}]}}))}))}}),Object.defineProperty(t.prototype,"getCallSession",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i,n,a,o,_,l,s,c,u,L,d,E,C,T,I,g;return y(this,(function(S){switch(S.label){case 0:return[4,this._signalModule.getCallSession(e,t)];case 1:return r=S.sent(),i=r.code,n=r.data,i!==D.SUCCESS?[2,{code:i}]:(o=(a=n).callId,_=a.callingUserId,l=a.callType,s=a.mediaType,c=a.callStatus,u=a.callSessionUsers,L=a.startTime,d=a.duration,E=a.syncTime,C=a.innerExtra,T=a.secretChat,I=a.secretChatKey,g=u.map((function(e){return{userId:e.userId,userState:e.sessionStatus,systemState:e.sysStatus,targetType:e.targetType,targetId:e.targetId,cameraEnable:!1,microphoneEnable:!1}})),[2,{code:i,data:{callId:o,startCallerId:_,callType:l,mediaType:s,sessionState:c,callSessionUsers:g,startTime:L,duration:d,syncTime:E,innerExtra:C,secretChat:T,secretChatKey:I}}])}}))}))}}),Object.defineProperty(t.prototype,"getHoldSession",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._holdSessions.find((function(t){return t&&t.getCallId()===e}));return t?new B(t,this,this._logger):null}}),Object.defineProperty(t.prototype,"getLocalMainSession",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._mainSession?new B(this._mainSession,this,this._logger):null}}),Object.defineProperty(t.prototype,"updateMainSessionState",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;null===(t=this._mainSession)||void 0===t||t.updateSessionState(e)}}),Object.defineProperty(t.prototype,"setIsLocalClientHangup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;null===(t=this._mainSession)||void 0===t||t.setIsLocalClientHangup(e)}}),Object.defineProperty(t.prototype,"updateUsersState",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._logger.info(M.L_CALL_ENGINE_UPDATE_USERS_STATE_O,"updateUsersState -> users: ".concat(JSON.stringify(t)),r);var i=U([this._mainSession],P(this._holdSessions),!1).find((function(t){return(null==t?void 0:t.getCallId())===e})),n=[];if(i){var a=t.map((function(e){var t=i.getUserList().filter((function(t){return t.userId===e.userId}))[0]||{},r=e.userState===j.IDLE?{cameraEnable:!1,microphoneEnable:!1}:t,n=r.cameraEnable,a=void 0!==n&&n,o=r.microphoneEnable,_=void 0!==o&&o;return m(m({},e),{cameraEnable:a,microphoneEnable:_})}));n.push.apply(n,U([],P(i.updateUserList(a,r)),!1))}else n.push.apply(n,U([],P(t),!1));n.length>0&&this._onUserStateChange(e,n,r)}}),Object.defineProperty(t.prototype,"setUserDeviceEnable",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){var n;null===(n=this._mainSession)||void 0===n||n.setUserDeviceEnable(e,t,r,i)}}),Object.defineProperty(t.prototype,"getCallStaringTime",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return[2,this._timeCorrectioner.getCallClientTimeByServer(e.callId,t)]}))}))}}),Object.defineProperty(t.prototype,"systemStatusUp",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return[2,this._signalModule.sysStatusUp(e,t)]}))}))}}),Object.defineProperty(t.prototype,"upFirstFrameTime",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i,n,a;return y(this,(function(o){switch(o.label){case 0:return!this._mainSession||this._mainSession&&this._mainSession.getCallType()!==w.SINGLE||this._isUpFirstFrameTime?[2,{code:D.SUCCESS}]:(t=Date.now(),r=this._timeCorrectioner.getLocalDelayTime(),i=Math.floor(t+r),this._logger.info(M.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_T,"now: ".concat(t,"; delay: ").concat(r,"; streamReadyTime: ").concat(i),e),this._isUpFirstFrameTime=!0,n=this._mainSession.getCallId(),this._callStartMap[n]&&!this._callStartMap[n].firstFrameTime&&(this._callStartMap[n].firstFrameTime=i),[4,this._signalModule.eventUpCall({callId:n,eventType:ce.FIRST_FRAME,eventArgs:{streamReadyTime:i},eventTime:Date.now()},e)]);case 1:return a=o.sent().code,this._logger.info(M.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_R,"code: ".concat(a),e),[2,{code:a}]}}))}))}}),Object.defineProperty(t.prototype,"endCurrentSession",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i=this,n=this._context.getCurrentId();if(this._mainSession&&this._mainSession.getCallId()===t){var a=this._mainSession.getUserList().map((function(t){var r=t.userId,a=t.systemState,o=t.targetType,_=t.targetId;return r===n&&(a=e),{userId:r,sessionStatus:j.ENDED,statusTime:Date.now(),duration:0,changed:1,inviteUserId:i._mainSession.getStartCallerId(),sysStatus:a,targetType:o,targetId:_}})),o={callId:this._mainSession.getCallId(),toDeviceId:this._signalModule.getDeviceId(),callStatus:V.ENDED,duration:0,callSessionUsers:a};this._onStatusDown(o,!1,r)}}}),Object.defineProperty(t.prototype,"startTimeCorrection",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._timeCorrectioner.restart(e)}}),Object.defineProperty(t.prototype,"getDelayTimeInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return{delayTime:this._timeCorrectioner.getLocalDelayTime(),rtt:this._timeCorrectioner.getRTT()}}}),Object.defineProperty(t.prototype,"upgradeMainSession",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r=this._holdSessions.findIndex((function(t){return t.getCallId()===e}));this._mainSession=null===(t=this._holdSessions.splice(r,1))||void 0===t?void 0:t[0]}}),Object.defineProperty(t.prototype,"endCurrentUserAbnormalCalls",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i,n,a=this;return y(this,(function(o){switch(o.label){case 0:return t=this._context.getCurrentId(),[4,this._abnormalModule.getAbnormalCallIds(t)];case 1:return(r=o.sent())?(i=r.filter((function(e){var t;return e!==(null===(t=a._mainSession)||void 0===t?void 0:t.getCallId())})),[4,this._signalModule.endUserAbnormalCalls({callIds:i,allDevice:e?1:0})]):[2,{code:D.SUCCESS}];case 2:return(n=o.sent().code)===D.SUCCESS&&this._abnormalModule.removeAbnormalCallIds(t,i),[2,{code:n}]}}))}))}}),Object.defineProperty(t.prototype,"_onIMStateChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,r=this._logger.createTraceId(),i=0;e===_.DISCONNECTED&&this._mainSession&&this._mainSession.getSessionState()!==V.ONCALL&&(i=Le((function(){var e;t._logger.info(M.L_CALL_ENGINE_IM_STATE_CHANGE_O,"endCurrentSession, IM disconnected for more than 60s",r),t.endCurrentSession(k.CONNECTION_ERR,null===(e=t._mainSession)||void 0===e?void 0:e.getCallId(),r)}),6e4)),e===_.CONNECTED&&(i&&clearTimeout(i),this.endCurrentUserAbnormalCalls(!0))}}),Object.defineProperty(t.prototype,"_handleCallTimeout",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._logger.warn(M.L_CALL_ENGINE_CALL_TIMEOUT_O,"call timeout callId: ".concat(e,", userState: ").concat(t),r);var i=U([this._mainSession],P(this._holdSessions),!1).find((function(t){return t&&t.getCallId()===e}));if(i){var n=this._context.getCurrentId();this._onStatusDown({callId:e,toDeviceId:this._signalModule.getDeviceId(),callStatus:V.ENDED,duration:0,callSessionUsers:i.getUserList().map((function(e){var r,a,o=e.userId,_=e.targetType,l=e.targetId,s=e.stateTime;return o===n?(r=t===j.MISSED?k.MISSED:k.NO_ANSWER,a=t===j.MISSED?j.MISSED:j.NO_ANSWER):(r=t===j.MISSED?k.NO_ANSWER:k.MISSED,a=t===j.MISSED?j.NO_ANSWER:j.MISSED),{userId:o,sessionStatus:a,statusTime:s?s+1:Date.now(),duration:0,changed:1,inviteUserId:i.getCallerId(),sysStatus:r,targetType:_,targetId:l}}))},!1,r)}else this._logger.warn(M.L_CALL_ENGINE_CALL_TIMEOUT_O,"handleCallTimeout without session, callId: ".concat(e),r)}}),Object.defineProperty(t.prototype,"_startTimer",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i=this,n=Le((function(){i._handleCallTimeout(e,t,r),i._signalModule.statusUpCall({callId:e,sessionStatus:t},r)}),6e4);return this._logger.info(M.L_CALL_ENGINE_START_CALL_TIMER_O,"callId: ".concat(e,", timerId: ").concat(n),r),n}}),Object.defineProperty(t.prototype,"_stopTimer",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){clearTimeout(e),this._logger.info(M.L_CALL_ENGINE_STOP_CALL_TIMER_O,"timerId: ".concat(e),t)}}),Object.defineProperty(t.prototype,"_onInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._clientCallId=c();var i=this._context.getCurrentId(),n=e.callSessionUsers,a=e.extra,o=void 0===a?"{}":a;n.some((function(e){return e.userId===i}))&&this._selfIsInviteeHandle(e,t,r,o),this._othersIsInviteeHandle(e,r)}}),Object.defineProperty(t.prototype,"_selfIsInviteeHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,i,n){var a=e.callId,o=e.inviteUserId,_=e.callType,l=e.mediaType,s=e.callSessionUsers,c=e.innerExtra,u=e.secretChat,L=e.secretChatKey,d=this._context.getCurrentId();this._abnormalModule.addAbnormallCallId(d,a);var E=new se(a,V.RINGING,_,l,o,o,[],this._logger,u===x.SECRET,c,L);this._signalModule.ringingCall({callId:a},i);var C=this._startTimer(a,j.MISSED,i);E.updateTimerId(oe.INVITEE,C),this._mainSession?(this._holdSessions.push(E),this._mainSession.updateSessionState(V.BUSYLINE_WAIT)):this._mainSession=E;var T=new B(E,this,this._logger);this._reportAppEventModule.onReceivedCall(T,i,JSON.parse(n||"{}").extra);var I=r?pe.PUB_INVITE_CALL:pe.PULL_KV_INVITE_CALL;this.emit(t.__INNER_INVITE__,T,I);var g=s.map((function(e){return{userId:e.userId,userState:e.sessionStatus,systemState:e.sysStatus,targetType:e.targetType,targetId:e.targetId,stateTime:e.statusTime,cameraEnable:!1,microphoneEnable:!1}}));this.updateUsersState(a,g,i)}}),Object.defineProperty(t.prototype,"_othersIsInviteeHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,i,n,a=e.callId,o=e.inviteUserId,_=e.callSessionUsers,l=this._context.getCurrentId(),s=_.filter((function(e){return e.userId!==l&&e.userId!==o&&e.sessionStatus===j.INVITED}));if(s.length){(null===(r=this._mainSession)||void 0===r?void 0:r.getCallType())===w.SINGLE&&(null===(i=this._mainSession)||void 0===i?void 0:i.getCallId())===a&&(this._onCallTypeChange(this._mainSession.getCallId(),w.MULTI,t),null===(n=this._mainSession)||void 0===n||n.updateCallType(w.MULTI));var c=[],u=[];s.forEach((function(e){var t=e.userId,r=e.sessionStatus,i=e.sysStatus;c.push({callId:a,userId:t,userState:r}),u.push({userId:t,userState:r,systemState:i,cameraEnable:!1,microphoneEnable:!1})})),this._onOtherMemberInvite(c),this.updateUsersState(a,u,t)}}}),Object.defineProperty(t.prototype,"_onHangup",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i=this;this._mainSession&&e.forEach((function(e){e.callId===i._mainSession.getCallId()&&(e.userState===j.CANCELLED?i._stopTimer(i._mainSession.getInviteeTimerId(),r):i._stopTimer(i._mainSession.getInviterTimerId(),r))}))}}),Object.defineProperty(t.prototype,"_onAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){var i,n,a,o,_=null===(i=this._mainSession)||void 0===i?void 0:i.getSessionState(),l=[V.CONNECTING,V.ONCALL,V.BUSYLINE_WAIT];if((null===(n=this._mainSession)||void 0===n?void 0:n.getCallType())!==w.SINGLE||!_||!l.includes(_)){var s=this._mainSession.getStartCallerId(),c=this._context.getCurrentId();if((null===(a=this._mainSession)||void 0===a?void 0:a.getCallType())===w.SINGLE&&s===c){var u=e.filter((function(e){return e.fromUserId!==c})),L=this.getLocalMainSession().getCallId(),d=this.getLocalMainSession().isSecret();u&&this.emit(t.__INNER_SESSION_CONNECT__,L,d,r)}null===(o=this._mainSession)||void 0===o||o.updateSessionState(V.CONNECTING),this._stopTimer(this._mainSession.getInviterTimerId(),r)}}}),Object.defineProperty(t.prototype,"_onStatusDown",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i;return v(this,void 0,void 0,(function(){var n,a,o,_,l,s,c,u,L,d,E,C,T,I;return y(this,(function(g){return n=e.callStatus,a=e.startTime,o=e.callId,_=e.syncTime,U([this._mainSession],P(this._holdSessions),!1).some((function(e){return(null==e?void 0:e.getCallId())===o}))?(this._callStartMap[o]=this._callStartMap[o]||{},this._callStartMap[o].isReceiveCallStartTime||n!==V.ONCALL||(this._callStartMap[o].isReceiveCallStartTime=!0,l=this._timeCorrectioner.calcClientStartTime(o,a,r),s=l.code,c=l.clientStartTime,s===ue.SUCCESS&&(this._callStartMap[o].callStartTime=c,this._reportAppEventModule.onReceivedCallStartTime({callId:o,callStartTime:c},r))),u=!1,L=this._context.getCurrentId(),(d=e.callSessionUsers.map((function(e){return[j.IDLE,j.DECLINED,j.MISSED,j.NO_ANSWER,j.CANCELLED].includes(e.sessionStatus)&&e.sysStatus!==k.CANCELLED&&e.userId===L&&(u=!0),{userId:e.userId,userState:e.sessionStatus,systemState:e.sysStatus,stateTime:e.statusTime,cameraEnable:!1,microphoneEnable:!1}}))).length>0&&this.updateUsersState(o,d,r),this._mainSession||this._holdSessions.length?(E=function(e){var t=e.callId,r=[],i=[],n=[],a=[];return e.callSessionUsers.forEach((function(e){var o=e.userId,_=e.sessionStatus,l=e.sysStatus;switch(_){case j.INVITED:a.push({callId:t,userId:o,userState:_});break;case j.RINGING:r.push({callId:t,fromUserId:o});break;case j.CONNECTING:n.push({fromUserId:o});break;case j.CANCELLED:case j.DECLINED:case j.ENDED:case j.IDLE:i.push({callId:t,fromUserId:o,userState:_,systemState:l})}})),{ringingData:r,hangupData:i,acceptData:n,otherInvitedData:a}}(e),C=E.hangupData,T=E.acceptData,I=E.otherInvitedData,C.length>0&&this._onHangup(C,e.callStatus,r),T.length>0&&this._onAccept(T,r),I.length>0&&(null===(i=this._mainSession)||void 0===i?void 0:i.getCallType())===w.MULTI&&this._onOtherMemberInvite(I),(e.callStatus===V.ENDED||u)&&(t&&(this._callStartMap[o].syncTime=_||0),this._onSessionClose(e,r,u)),[2]):[2]):[2]}))}))}}),Object.defineProperty(t.prototype,"_onOtherClientStatusDown",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,i,n,a=e.callId,o=e.callSessionUsers,_=this._context.getCurrentId(),l=o.find((function(e){return e.userId===_}));if(l&&(this._mainSession||this._holdSessions.length)){var s=l.userId,c=l.sessionStatus,u=l.statusTime;if(c===j.CONNECTING){var L=[j.ONCALL,j.CONNECTING],d=(null===(r=this._mainSession)||void 0===r?void 0:r.getCallId())===a,E=null===(n=null===(i=this._mainSession)||void 0===i?void 0:i.getUserList().find((function(e){return e.userId===_})))||void 0===n?void 0:n.userState;d&&E&&L.includes(E)||(this.updateUsersState(a,[{userId:s,userState:c,systemState:k.OTHER_CLIENT_ACCEPT,stateTime:u,cameraEnable:!1,microphoneEnable:!1}],t),this._onSessionClose(e,t,!1))}}}}),Object.defineProperty(t.prototype,"_onEventDown",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;return v(this,void 0,void 0,(function(){var i,n,a,o,_,l,s;return y(this,(function(c){return i=e.callId,n=e.eventArgs,a=e.eventType,i!==(null===(r=this._mainSession)||void 0===r?void 0:r.getCallId())||this._mainSession.getSessionState()!==V.ONCALL||a===ce.CALL_DURATION&&(o=n.firstFrameTime,_=this._timeCorrectioner.calcClientStartTime(i,o,t),l=_.code,s=_.clientStartTime,this._logger.info(M.L_CALL_ENGINE_RECEIVE_FIRST_FRAME_TIME_O,"clientFirstFrameTime: ".concat(s),t),l===ue.SUCCESS&&(this._callStartMap[i].firstFrameTime=s,this._reportAppEventModule.onReceivedCallFirstFrameTime(i,s,t))),[2]}))}))}}),Object.defineProperty(t.prototype,"_onRecvSinCallDuration",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){var n;(null===(n=this._mainSession)||void 0===n?void 0:n.getCallId())===e&&(this._callStartMap[e].callStartTime=t,this._callStartMap[e].firstFrameTime=r,this._reportAppEventModule.onReceivedCallStartTime(m({callId:e},{callStartTime:t}),i),this._reportAppEventModule.onReceivedCallFirstFrameTime(e,r,i))}}),Object.defineProperty(t.prototype,"_onSwitchMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,i,n,a,o,_=e.callId,l=e.action,s=e.extraKeyVal,c=e.transactionId,u=e.promoterId,L=s.mediaType,d=s.reason,E=null===(r=this._mainSession)||void 0===r?void 0:r.getCallId();if(_===E){var C=(null===(i=this._mainSession)||void 0===i?void 0:i.getOldDialogData())||{},T=C.transactionId,I=C.action,g=C.mediaType;if(T!==c||I!==l||g!==L){if(this._logger.info(M.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,"action: ".concat(l,", reason: ").concat(d),t),null===(n=this._mainSession)||void 0===n||n.setOldDialogData({transactionId:c,action:l,mediaType:L}),l===ne.REQUEST)this._onRequestChangeMediaType({transactionId:c,userId:u,mediaType:L},t);else{var S=null;switch(d){case ne.CANCEL:S=H.CANCEL_CHANGE_MEDIA_TYPE;break;case ne.ACCEPT:S=H.SERVER_ALLOW_MEDIA_TYPE,null===(a=this._mainSession)||void 0===a||a.updateMediaType(this._mainSession.getReqMediaType()),null===(o=this._mainSession)||void 0===o||o.updateReqMediaType(null);break;case ne.REFUSE:S=H.REFUSE_CHANGE_MEDIA_TYPE;break;case ne.TIMEOUT:S=H.CHANGE_MEDIA_TYPE_TIMEOUT}H[S]&&this._receiveMediaTypeChangeResult({transactionId:c,userId:u,mediaType:L},S,t)}l!==ne.NOTICE||L!==G.AUDIO||d||this._receiveMediaTypeChangeResult({transactionId:c,userId:u,mediaType:L},H.SERVER_ALLOW_MEDIA_TYPE,t)}else this._logger.info(M.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,"duplicate dialog data",t)}else this._logger.info(M.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,"not current session callId: ".concat(E,", recvCallId: ").concat(_),t)}}),Object.defineProperty(t.prototype,"_onRecvCallEndLog",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=W(e);this._reportAppEventModule.onReceivedCallRecord(r,t)}}),Object.defineProperty(t.prototype,"_onSessionClose",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,i){var n=this,a=e.callId,o=this._context.getCurrentId();this._abnormalModule.removeAbnormalCallIds(o,[a]);var _=U([this._mainSession],P(this._holdSessions),!1).find((function(e){return e&&e.getCallId()===a}));if(_){this._logger.warn(M.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O,"callId: ".concat(a),r),this.emit(t.__INNER_SESSION_CLOSE__,a,r);var l,s=_.getUserList().find((function(e){return e.userId===o}));l=i&&e.toDeviceId!==this._signalModule.getDeviceId()?_.getIsLocalClientHangup()?s.systemState:k.OTHER_CLIENT_HANGUP:s.systemState,this._reportAppEventModule.onCallEnded(new B(_,this,this._logger),l,r),this._reportCallPlusSummaryMessage(_,a,l),this._mainSession&&this._mainSession.getCallId()===a&&(this._mainSession.getAllTimerIds().forEach((function(e){return n._stopTimer.bind(n)(e,r)})),_.getCallType()===w.SINGLE&&(this._isUpFirstFrameTime=!1),delete this._callStartMap[a]),this._removeSession(a)}else this._logger.warn(M.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O,"unexpect session callId -> ".concat(a),r)}}),Object.defineProperty(t.prototype,"_reportCallPlusSummaryMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i,n,a,_,l=this._context.getCurrentId(),s=e.getUserList().filter((function(e){return e.userId!==l}))[0].userId,c=e.getStartCallerId();if(!localStorage.getItem("missMessageMap-".concat(l,"-").concat(t))){var E=null;E=(null===(i=this._callStartMap[t])||void 0===i?void 0:i.callStartTime)?(null===(n=this._callStartMap[t])||void 0===n?void 0:n.syncTime)?this._callStartMap[t].syncTime-this._timeCorrectioner.getLocalDelayTime():+new Date:0;var C={callId:t,callerUserId:c,targetId:s,mediaType:e.getMediaType(),firstFrameTime:(null===(a=this._callStartMap[t])||void 0===a?void 0:a.firstFrameTime)||0,callStartTime:(null===(_=this._callStartMap[t])||void 0===_?void 0:_.callStartTime)||0,callEndTime:E,hangupReason:r,isSecret:e.isSecret(),syncData:e.getSyncData(),isSelfHangup:e.getIsLocalClientHangup()};this._reportAppEventModule.onReceivedCallPlusSummaryMessage({messageType:Te,content:C,senderUserId:c,targetId:s,channelId:"",conversationType:u.PRIVATE,sentTime:+new Date-this._timeCorrectioner.getLocalDelayTime(),receivedTime:+new Date-this._timeCorrectioner.getLocalDelayTime(),messageUId:t,messageDirection:c===l?L.SEND:L.RECEIVE,isPersited:!0,isCounted:!1,isOffLineMessage:!1,canIncludeExpansion:!1,receivedStatus:d.READ,isStatusMessage:!1,isMentioned:!1,expansion:null,disableNotification:!1,sentStatus:o.SENT}),localStorage.setItem("missMessageMap-".concat(l,"-").concat(t),t)}}}),Object.defineProperty(t.prototype,"_removeSession",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;if(e===(null===(t=this._mainSession)||void 0===t?void 0:t.getCallId()))this._mainSession=null;else{var r=this._holdSessions.findIndex((function(t){return(null==t?void 0:t.getCallId())===e}));this._holdSessions.splice(r,1)}}}),Object.defineProperty(t.prototype,"_createSessionByServer",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return void 0===r&&(r=!1),v(this,void 0,void 0,(function(){var i,n,a,o,_,l,s,c,u,L,d;return y(this,(function(E){switch(E.label){case 0:return this._logger.info(M.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_T,"callId: ".concat(e),t),[4,this.getCallSession({callId:e},t)];case 1:return i=E.sent(),n=i.code,a=i.data,n!==D.SUCCESS?(this._logger.error(M.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R,"errcode: ".concat(n),t),[2]):(this._logger.info(M.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R,"code: ".concat(n,", data: ").concat(JSON.stringify(a)),t),_=(o=a).callType,l=o.mediaType,s=o.callSessionUsers,c=o.startCallerId,u=o.innerExtra,L=o.secretChat,d=o.secretChatKey,this._mainSession=new se(e,V.CONNECTING,_,l,c,c,[],this._logger,L===x.SECRET,u,d),r&&this._clearMobileOnPhone(e,t),this.updateUsersState(e,s,t),[2])}}))}))}}),Object.defineProperty(t.prototype,"_clearMobileOnPhone",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i;return y(this,(function(n){switch(n.label){case 0:return(r=U([this._mainSession],P(this._holdSessions),!1).find((function(t){return(null==t?void 0:t.getCallId())===e})))&&r.getCallType()===w.MULTI?(this._logger.info(M.L_CALL_ENGINE_UP_ON_PHONE_END_T,"callId: ".concat(e),t),[4,this.systemStatusUp({callId:e,sysStatus:k.ON_PHONE_END,forward:fe.CURRENT},t)]):[3,2];case 1:(i=n.sent().code)===D.SUCCESS?this._logger.info(M.L_CALL_ENGINE_UP_ON_PHONE_END_R,"callId: ".concat(e),t):this._logger.warn(M.L_CALL_ENGINE_UP_ON_PHONE_END_R,"callId: ".concat(e,", errCode: ").concat(i),t),n.label=2;case 2:return[2]}}))}))}}),Object.defineProperty(t.prototype,"_onUserStateChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,i){var n=this,a=this._context.getCurrentId();r.forEach((function(t){var r=t.userId,o=t.userState,_=t.systemState;r!==a&&n._reportAppEventModule.onRemoteUserStateChanged({callId:e,userId:r,userState:o,reason:_},i)})),r.forEach((function(r){var o=r.userId,_=r.systemState;o===a&&_===k.ABNORMAL_END&&n.emit(t.__INNER_SESSION_CLOSE__,e,i)}))}}),Object.defineProperty(t.prototype,"_onOtherMemberInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;e.forEach((function(e){var r,i=e.userId,n=e.callId,a=null===(r=t.getLocalMainSession())||void 0===r?void 0:r.getInviterUserId();t._reportAppEventModule.onRemoteUserInvited([i],a,n)}))}}),Object.defineProperty(t.prototype,"_onRequestChangeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,i=e.userId,n=e.transactionId,a=e.mediaType;null===(r=this._mainSession)||void 0===r||r.updateReqMediaType(a),this._reportAppEventModule.onReceivedChangeMediaTypeRequest(i,n,a,t)}}),Object.defineProperty(t.prototype,"_receiveMediaTypeChangeResult",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,i){r===H.SERVER_ALLOW_MEDIA_TYPE&&this.emit(t.__INNER_CHANGE_MEDIA_TYPE__,e.mediaType,i),this._reportAppEventModule.onReceivedChangeMediaTypeResult(m(m({},e),{code:r}),i)}}),Object.defineProperty(t.prototype,"_onCallTypeChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._reportAppEventModule.onCallTypeChanged(t,e,r)}}),Object.defineProperty(t,"__INNER_SESSION_CLOSE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-session-close"}),Object.defineProperty(t,"__INNER_SESSION_CONNECT__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-session-connect"}),Object.defineProperty(t,"__INNER_CHANGE_MEDIA_TYPE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-change-media-type"}),Object.defineProperty(t,"__INNER_INVITE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-invite"}),t}(n);!function(e){e.NORMAL="RongCloudRTC",e.SCREEN="ScreenShare"}(Re||(Re={}));var Ae,Ne=function(e){function i(t,r,i,n){var a=e.call(this)||this;return Object.defineProperty(a,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(a,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(a,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"_rtcClient",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"_localTracks",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(a,"_room",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(a,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(a,"_callMediaType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:f.W640_H480,frameRate:S.FPS_15}}),Object.defineProperty(a,"_audioConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(a,"_isPubTiny",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(a,"_audioOutputDeviceId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(a,"_videoConfigIsChange",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(a,"_audioConfigIsChange",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(a,"_userViewMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(a,"_callPlusStatusReportListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(a,"_remoteAudioEnable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),a._rtcClient=r.rtcClient,a._isPubTiny=r.isPubTiny||!1,a}return N(i,e),Object.defineProperty(i.prototype,"setCallPlusStatusReportListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._callPlusStatusReportListener=e}}),Object.defineProperty(i.prototype,"getCameraVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i,n,a;return y(this,(function(o){switch(o.label){case 0:return!(t=this.getLocalVideoTrack())||this._videoConfigIsChange?[3,1]:(a={track:t,code:D.SUCCESS},[3,3]);case 1:return[4,this._createVideoTrack(e)];case 2:a=o.sent(),o.label=3;case 3:return i=(r=a).code,n=r.track,this._videoConfigIsChange=!1,i!==D.SUCCESS?[2,{code:i}]:[2,{code:D.SUCCESS,track:n}]}}))}))}}),Object.defineProperty(i.prototype,"getMicrophoneAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i,n,a;return y(this,(function(o){switch(o.label){case 0:return!(t=this.getLocalAudioTrack())||this._audioConfigIsChange?[3,1]:(a={track:t,code:D.SUCCESS},[3,3]);case 1:return[4,this._createAudioTrack(e)];case 2:a=o.sent(),o.label=3;case 3:return i=(r=a).code,n=r.track,this._audioConfigIsChange=!1,i!==D.SUCCESS?[2,{code:i}]:[2,{code:D.SUCCESS,track:n}]}}))}))}}),Object.defineProperty(i.prototype,"createCallMediaTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i;return y(this,(function(n){switch(n.label){case 0:return this._callMediaType=e,[4,this.getMicrophoneAudioTrack(t)];case 1:return(r=n.sent().code)!==D.SUCCESS?[2,{code:r}]:e!==G.AUDIO_VIDEO?[3,3]:[4,this.getCameraVideoTrack(t)];case 2:(i=n.sent().code)!==D.SUCCESS&&this._logger.warn(M.L_RTC_MODULE_CREATE_CALL_MEDIA_TRACKS_P,"get camera video track error code: ".concat(i),t),n.label=3;case 3:return[2,{code:D.SUCCESS}]}}))}))}}),Object.defineProperty(i.prototype,"setVideoConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._videoConfigIsChange=!0,this._videoConfig=e}}),Object.defineProperty(i.prototype,"setAudioConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._audioConfigIsChange=!0,this._audioConfig=e}}),Object.defineProperty(i.prototype,"setAudioOutputDeviceId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){return y(this,(function(t){return"string"!=typeof e||0===e.length?[2,{code:D.PARAM_ERROR}]:(this._audioOutputDeviceId===e||(this._audioOutputDeviceId=e,this._room&&this._room.getRemoteTracks().filter((function(e){return e.isAudioTrack()})).forEach((function(t){t.isSubscribed()&&t.play(void 0,{audioDeviceId:e})}))),[2,{code:D.SUCCESS}])}))}))}}),Object.defineProperty(i.prototype,"destroyAllTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(M.L_RTC_MODULE_DESTROY_ALL_TRACKS_O,"",e),this._localTracks.forEach((function(e){e.destroy()})),this._localTracks.length=0}}),Object.defineProperty(i.prototype,"setAllRemoteAudioEnable",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){return this._logger.info(M.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_T,"enable: ".concat(e),r),t(e)?(this._remoteAudioEnable=e,this._room?(this._room.getRemoteTracks().filter((function(e){return e.isAudioTrack()})).forEach((function(t){e?t.unmute():t.mute()})),this._logger.info(M.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R,"success",r),{code:D.SUCCESS}):{code:D.SUCCESS}):(this._logger.error(M.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R,"param error, enable: type is boolean, value: ".concat(e)),{code:D.PARAM_ERROR})}}),Object.defineProperty(i.prototype,"destroyTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t;return y(this,(function(r){return e.destroy(),t=this._localTracks.findIndex((function(t){return t.getTrackId()===e.getTrackId()})),this._localTracks.splice(t,1),[2]}))}))}}),Object.defineProperty(i.prototype,"sessionConnected",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i;return v(this,void 0,void 0,(function(){var n,a,o,_,l;return y(this,(function(s){switch(s.label){case 0:return this._logger.info(M.L_RTC_MODULE_SESSION_CONNECT_T,"callId: ".concat(e),r),this._room?[3,2]:[4,this.joinRTCRoom(e,t,r)];case 1:if(n=s.sent(),l=n.code,a=n.room,l!==D.SUCCESS)return[2];this._room=a,s.label=2;case 2:return this._callId=e,this._regRTCListeners(),(o=(null===(i=this._room)||void 0===i?void 0:i.getRemoteUserIds())||[]).length>0&&this._onOtherMemJoined(o.map((function(t){return{callId:e,userId:t}})),r),this._localTracks.length>0?(_=this._isPubTiny?this._localTracks.map((function(e){return e.isVideoTrack()?{track:e,isPubTiny:!0}:e})):this._localTracks,[4,this.publish(_,r)]):[3,4];case 3:return l=s.sent().code,[3,5];case 4:this._logger.warn(M.L_RTC_MODULE_SESSION_CONNECT_P,"sessionConnected local tracks is empty",r),s.label=5;case 5:return this._logger.info(M.L_RTC_MODULE_SESSION_CONNECT_R,"code: ".concat(D.SUCCESS),r),[2]}}))}))}}),Object.defineProperty(i.prototype,"sessionClose",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;return v(this,void 0,void 0,(function(){var i,n;return y(this,(function(a){switch(a.label){case 0:return this._logger.info(M.L_RTC_MODULE_SESSION_CLOSE_T,"callId: ".concat(e),t),i=null===(r=this._room)||void 0===r?void 0:r.getRoomId(),this._room&&i!==e||this.destroyAllTracks(t),this._room&&e===i?[4,this._rtcClient.leaveRoom(this._room)]:[3,2];case 1:return n=a.sent().code,this._releaseStoredData(),n!==p.SUCCESS?(this._logger.error(M.L_RTC_MODULE_SESSION_CLOSE_R,"leaveRoom failed, code: ".concat(n),t),[2]):(this._logger.info(M.L_RTC_MODULE_SESSION_CLOSE_R,"leaveRoom success",t),[3,3]);case 2:this._logger.warn(M.L_RTC_MODULE_SESSION_CLOSE_R,"leaveRoom throw exception: not in room",t),a.label=3;case 3:return[2]}}))}))}}),Object.defineProperty(i.prototype,"disableVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return v(this,void 0,void 0,(function(){var e;return y(this,(function(t){switch(t.label){case 0:return(e=this.getLocalVideoTrack())?[4,e.mute()]:[2,{code:D.CAMERA_CLOSED}];case 1:return[2,{code:t.sent(),track:e}]}}))}))}}),Object.defineProperty(i.prototype,"enableVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var e;return y(this,(function(t){switch(t.label){case 0:return(e=this.getLocalVideoTrack())?e.isOwnerMuted()?[4,e.unmute()]:[2,{code:D.SUCCESS}]:[2,{code:D.CAMERA_CLOSED}];case 1:return[2,{code:t.sent()}]}}))}))}}),Object.defineProperty(i.prototype,"changeVideoDevice",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i,n,a,o,_,l,s,c;return y(this,(function(u){switch(u.label){case 0:return t=[],r=[],[4,this._rtcClient.createCameraVideoTrack(Re.NORMAL,this._videoConfig)];case 1:return i=u.sent(),n=i.code,a=i.track,n!==p.SUCCESS?[2,{code:n}]:(o=this._videoConfig,_=o.minBitrate,l=o.maxBitrate,(_||l)&&a.setBitrate(l,_),this._localTracks&&this._localTracks.forEach((function(e){e.isVideoTrack()?(e.destroy(),s=e):r.push(e)})),this._localTracks=this._localTracks.filter((function(e){return s&&e.getTrackId()!==s.getTrackId()})),t.push(a),r.push(a),this._localTracks=r,this._onLocalTrackReady(t,e),this._room?[4,this._room.publish(t)]:[3,3]);case 2:if((c=u.sent().code)!==p.SUCCESS)return[2,{code:c}];u.label=3;case 3:return[2,{code:D.SUCCESS,track:a}]}}))}))}}),Object.defineProperty(i.prototype,"changeAudioDevice",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i,n,a,o,_;return y(this,(function(l){switch(l.label){case 0:return t=[],r=[],i=m(m({},this._audioConfig),{micphoneId:this._audioConfig.microphoneId}),[4,this._rtcClient.createMicrophoneAudioTrack(Re.NORMAL,i)];case 1:return n=l.sent(),a=n.code,o=n.track,a!==p.SUCCESS?[2,{code:a}]:(this._localTracks&&this._localTracks.forEach((function(e){e.isAudioTrack()?e.destroy():r.push(e)})),t.push(o),r.push(o),this._localTracks=r,this._onLocalTrackReady(t,e),this._room?[4,this._room.publish(t)]:[3,3]);case 2:if((_=l.sent().code)!==p.SUCCESS)return[2,{code:_}];l.label=3;case 3:return[2,{code:D.SUCCESS}]}}))}))}}),Object.defineProperty(i.prototype,"disableAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return v(this,void 0,void 0,(function(){var e;return y(this,(function(t){switch(t.label){case 0:return(e=this.getLocalAudioTrack())?[4,e.mute()]:[2,{code:D.MICROPHONE_CLOSED}];case 1:return[2,{code:t.sent(),track:e}]}}))}))}}),Object.defineProperty(i.prototype,"changeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r;return y(this,(function(i){switch(i.label){case 0:return this._logger.info(M.L_RTC_MODULE_CHANGE_MEDIA_TYPE_T,"mediaType: ".concat(e),t),e!==G.AUDIO_VIDEO?[3,2]:[4,this._upgradeMediaType(t)];case 1:return r=i.sent(),[3,4];case 2:return[4,this._downgradeMediaType(t)];case 3:r=i.sent(),i.label=4;case 4:return r.code===D.SUCCESS&&this._logger.info(M.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,"success",t),[2]}}))}))}}),Object.defineProperty(i.prototype,"_upgradeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i,n,a,o,_,l,s;return y(this,(function(c){switch(c.label){case 0:return(t=this.getLocalVideoTrack())?[3,2]:[4,this._createVideoTrack(e)];case 1:if(r=c.sent(),i=r.code,n=r.track,i!==D.SUCCESS)return this._logger.error(M.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,"create video track errCode: ".concat(i),e),[2,{code:i}];t=n,a=this._videoConfig,o=a.minBitrate,_=a.maxBitrate,(o||_)&&t.setBitrate(_,o),c.label=2;case 2:return l=this._isPubTiny?{track:t,isPubTiny:!0}:t,[4,this.publish([l],e)];case 3:return(s=c.sent().code)!==D.SUCCESS&&this._logger.error(M.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,"publish errCode: ".concat(s),e),[2,{code:s}]}}))}))}}),Object.defineProperty(i.prototype,"_downgradeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r;return y(this,(function(i){switch(i.label){case 0:return(t=this.getLocalVideoTrack())?this._room?[4,this._room.unpublish([t])]:[3,2]:[3,3];case 1:if((r=i.sent().code)!==p.SUCCESS)return this._logger.error(M.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,"unpublish errCode: ".concat(r),e),[2,{code:r}];i.label=2;case 2:this.destroyTrack(t),i.label=3;case 3:return[2,{code:D.SUCCESS}]}}))}))}}),Object.defineProperty(i.prototype,"joinRTCRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return v(this,void 0,void 0,(function(){var i,n,a,o;return y(this,(function(_){switch(_.label){case 0:return this._logger.info(M.L_RTC_MODULE_JOIN_RTC_ROOM_T,"call: ".concat(e),r),[4,Ee({asyncFn:this._rtcClient.joinRTCRoomWithOptions.bind(this._rtcClient),fnArgs:[e,{mode:E.CALL,encrypt:t}]})];case 1:return i=_.sent(),n=i.code,a=i.room,o=i.tracks,n!==p.SUCCESS?(this._logger.error(M.L_RTC_MODULE_JOIN_RTC_ROOM_R,"callId: ".concat(e,", errCode: ").concat(n),r),this._onRTCMethodFail(k.JOIN_ROOM_ERR,r),[2,{code:n}]):(this._logger.info(M.L_RTC_MODULE_JOIN_RTC_ROOM_R,"success",r),this._room=a,this._onSelfJoined({callId:e,userId:this._context.getCurrentId()},r),(null==o?void 0:o.length)&&this._onRemoteTrackPublish(o),this._callId=e,[2,{code:D.SUCCESS,room:a,tracks:o}])}}))}))}}),Object.defineProperty(i.prototype,"subscribeTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r;return y(this,(function(i){switch(i.label){case 0:return this._logger.info(M.L_RTC_MODULE_SUBSCRIBE_T,JSON.stringify({params:e.map((function(e){var t=e.track,r=e.subTiny;return{trackId:t.getTrackId(),subTiny:r}}))}),t),this._room?[4,Ee({asyncFn:this._room.subscribe.bind(this._room),fnArgs:[e],onError:function(e){}})]:[2,{code:D.SUCCESS}];case 1:return(r=i.sent().code)!==p.SUCCESS?(this._reportAppEventModule.onFetchRemoteMediaError(e,r),this._onRTCMethodFail(k.SUBSCRIBE_ERR,t),this._logger.error(M.L_RTC_MODULE_SUBSCRIBE_R,"errorCode: ".concat(r),t),[2,{code:r}]):(this._logger.info(M.L_RTC_MODULE_SUBSCRIBE_R,"success",t),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(i.prototype,"unsubscribeTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r;return y(this,(function(i){switch(i.label){case 0:return this._logger.info(M.L_RTC_MODULE_UNSUBSCRIBE_T,JSON.stringify({trackIds:e.map((function(e){return e.getTrackId()}))}),t),this._room?[4,this._room.unsubscribe(e)]:[2,{code:D.SUCCESS}];case 1:return(r=i.sent().code)!==p.SUCCESS?(this._logger.error(M.L_RTC_MODULE_UNSUBSCRIBE_R,"errorCode: ".concat(r),t),[2,{code:r}]):(this._logger.info(M.L_RTC_MODULE_UNSUBSCRIBE_R,"success",t),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(i.prototype,"_releaseStoredData",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._room=null,this._remoteAudioEnable=!0,this._userViewMap={}}}),Object.defineProperty(i.prototype,"getRemoteTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t={};return this._room?(this._room.getRemoteUserIds().forEach((function(r){t[r]=e._room.getRemoteTracksByUserId(r)})),t):t}}),Object.defineProperty(i.prototype,"getRemoteTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;return null===(r=this._room)||void 0===r?void 0:r.getRemoteTracksByUserId(e).find((function(e){return t===G.AUDIO?e.isAudioTrack():e.isVideoTrack()}))}}),Object.defineProperty(i.prototype,"getRTCSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._room?this._room.getSessionId():null}}),Object.defineProperty(i.prototype,"_regRTCListeners",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this._room.registerRoomEventListener({onKickOff:function(t,r){e._onKickOff(t,e._room.getRoomId(),r),e._releaseStoredData()},onUserJoin:function(t){var r=t.map((function(t){return{callId:e._callId,userId:t}})),i=e._logger.createTraceId();e._onOtherMemJoined(r,i)},onUserLeave:function(t){t.forEach((function(t){delete e._userViewMap[t]}))},onTrackPublish:this._onRemoteTrackPublish.bind(this),onTrackUnpublish:this._onTrackUnpublish.bind(this),onTrackReady:function(t){e._onRemoteTrackReady([t])},onVideoMuteChange:function(t){e._onVideoMuteChagne({fromUserId:t.getUserId(),muted:t.isOwnerMuted(),trackId:t.getTrackId()})},onAudioMuteChange:function(t){e._onAudioMuteChange({fromUserId:t.getUserId(),muted:t.isOwnerMuted(),trackId:t.getTrackId()})},onRTCPeerConnectionCloseByException:this._onRTCPeerConnectionCloseByException.bind(this)}),this._room.registerReportListener({onStateReport:this._onRTCStateReport.bind(this)}),this._room.onAudioLevelChange((function(t){e._reportAppEventModule.onUserAudioLevelChanged(t)}))}}),Object.defineProperty(i.prototype,"_onLocalTrackReady",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._reportAppEventModule.onUserMediaAvailable(e,t)}}),Object.defineProperty(i.prototype,"_onRemoteTrackReady",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._reportAppEventModule.onUserMediaAvailable(e),this.emit(i.__INNER_RECEIVE_FIRST_FRAME__)}}),Object.defineProperty(i.prototype,"_onKickOff",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){this._logger.info(M.L_RTC_MODULE_RECEIVE_KICK_OFF_O,"roonId: ".concat(t,", byServer: ").concat(e,", state: ").concat(r,", kickExtra: ").concat(JSON.stringify(n)));var a=k.CONNECTION_ERR;if(e)if(n)a=n.kickReasonCode;else switch(r){case h.SERVER_KICK:a=k.KICKED_BY_SERVER;break;case h.OTHER_KICK:a=k.OTHER_CLIENT_JOINED;break;case h.IM_DISCONNECTED:a=k.CONNECTION_ERR;break;case h.IM_LOGOUT:a=k.LOGOUT;break;case h.OTHER_CLIENT_IM_CONNECTED:a=k.OTHER_CLIENT_LOGIN}this.emit(i.__INNER_ON_KICKOFF__,a,t)}}),Object.defineProperty(i.prototype,"_onRTCPeerConnectionCloseByException",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._logger.createTraceId();this._logger.info(M.L_RTC_MODULE_RECEIVE_PEERCONNECTION_EXCEPT_CLOSE_O,"",e),this.emit(i.__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__,e)}}),Object.defineProperty(i.prototype,"_onSelfJoined",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(r){return this.emit(i.__INNER_ON_SELF_JOINED__,e.callId,t),[2]}))}))}}),Object.defineProperty(i.prototype,"_onRemoteTrackPublish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,r=this._logger.createTraceId();this._onDeviceEnableChange(e,r),this._logger.info(M.L_RTC_MODULE_RECEIVE_TRACK_PUBLISH_O,JSON.stringify({callId:this._callId,trackIds:e.map((function(e){return e.getTrackId()}))}),r);var i=[];e.forEach((function(e){var r,n=e.getUserId();if(e.isAudioTrack())i.push({track:e,subTiny:!1}),t._reportAppEventModule.onRemoteMicrophoneStateChanged(t._callId,e);else if(null===(r=t._userViewMap[n])||void 0===r?void 0:r.videoView){t._reportAppEventModule.onRemoteCameraStateChanged(t._callId,e);var a=t._userViewMap[n].isTiny;i.push({track:e,subTiny:a})}})),i.length&&this.subscribeTracks(i,r)}}),Object.defineProperty(i.prototype,"_onTrackUnpublish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t;return y(this,(function(r){switch(r.label){case 0:return t=this._logger.createTraceId(),this._onDeviceEnableChange(e,t),this._logger.info(M.L_RTC_MODULE_RECEIVE_TRACK_UNPUBLISH_O,JSON.stringify({callId:this._callId,trackIds:e.map((function(e){return e.getTrackId()}))}),t),[4,this.unsubscribeTracks(e,t)];case 1:return r.sent(),[2]}}))}))}}),Object.defineProperty(i.prototype,"_onAudioMuteChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._logger.createTraceId();this._logger.info(M.L_RTC_MODULE_RECEIVE_TRACK_ENABLE_CHANGE_O,JSON.stringify({info:e}),t);var r=this._room.getRemoteTrack(e.trackId);this._onDeviceEnableChange([r],t),this._reportAppEventModule.onRemoteMicrophoneStateChanged(this._callId,r)}}),Object.defineProperty(i.prototype,"_onVideoMuteChagne",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._logger.createTraceId();this._logger.info(M.L_RTC_MODULE_RECEIVE_TRACK_ENABLE_CHANGE_O,JSON.stringify({info:e}),t);var r=this._room.getRemoteTrack(e.trackId);this._onDeviceEnableChange([r],t),this._reportAppEventModule.onRemoteCameraStateChanged(this._callId,r)}}),Object.defineProperty(i.prototype,"_onRTCStateReport",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,r=e.senders,i=e.receivers;r.forEach((function(e){var r,i=e.kind,n=e.packetsLostRate,a=e.rtt;t._callMediaType===G.AUDIO_VIDEO&&"audio"===i||null===(r=t._callPlusStatusReportListener)||void 0===r||r.onSendPacketLoss(n?Math.round(100*n):0,a||0)})),i.forEach((function(e){var r,i;e.trackId;var n=e.kind,a=e.packetsLostRate,o=e.bitrate,_=e.frameWidth,l=e.frameHeight,s=e.userId;if(t._callMediaType!==G.AUDIO_VIDEO||"audio"!==n){var c={};c[s]={packetLostRate:a?Math.round(100*a):0,bitRate:o},null===(r=t._callPlusStatusReportListener)||void 0===r||r.onReceivePacketLoss(c),_&&l&&(null===(i=t._callPlusStatusReportListener)||void 0===i?void 0:i.onReceiveRemoteVideoInfo)&&t._callPlusStatusReportListener.onReceiveRemoteVideoInfo({width:_,height:l})}}))}}),Object.defineProperty(i.prototype,"_onRTCMethodFail",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this.emit(i.__INNER_RTC_PROCESS_FAILED__,e,t)}}),Object.defineProperty(i.prototype,"_onOtherMemJoined",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this.emit(i.__INNER_ON_OTHER_JOINED__,e,t)}}),Object.defineProperty(i.prototype,"_onDeviceEnableChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this.emit(i.__INNER_ON_DEVICE_ENABLE_CHANGE__,e,t)}}),Object.defineProperty(i.prototype,"_createAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i,n,a,o,_;return y(this,(function(l){switch(l.label){case 0:return this._logger.info(M.L_RTC_MODULE_CREATE_AUDIO_TRACK_T,"",e),t=Object.assign(this._audioConfig,{micphoneId:this._audioConfig.microphoneId}),[4,this._rtcClient.createMicrophoneAudioTrack(Re.NORMAL,t)];case 1:return r=l.sent(),i=r.code,n=r.track,i!==p.SUCCESS?(this._logger.error(M.L_RTC_MODULE_CREATE_AUDIO_TRACK_R,"errCode: ".concat(i),e),[2,{code:i}]):(this._logger.info(M.L_RTC_MODULE_CREATE_AUDIO_TRACK_R,"success",e),a=this._audioConfig,o=a.minBitrate,_=a.maxBitrate,(o||_)&&n.setBitrate(_,o),this._localTracks.push(n),this._onLocalTrackReady([n],e),[2,{code:D.SUCCESS,track:n}])}}))}))}}),Object.defineProperty(i.prototype,"_createVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i,n,a,o;return y(this,(function(_){switch(_.label){case 0:return this._logger.info(M.L_RTC_MODULE_CREATE_VIDEO_TRACK_T,"",e),[4,this._rtcClient.createCameraVideoTrack(Re.NORMAL,this._videoConfig)];case 1:return t=_.sent(),r=t.code,i=t.track,r!==p.SUCCESS?(this._logger.error(M.L_RTC_MODULE_CREATE_VIDEO_TRACK_R,"errCode: ".concat(r),e),[2,{code:r}]):(this._logger.info(M.L_RTC_MODULE_CREATE_VIDEO_TRACK_R,"success",e),n=this._videoConfig,a=n.minBitrate,o=n.maxBitrate,(a||o)&&i.setBitrate(o,a),this._localTracks.push(i),this._onLocalTrackReady([i],e),[2,{code:D.SUCCESS,track:i}])}}))}))}}),Object.defineProperty(i.prototype,"getLocalVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return this._localTracks&&(e=P(this._localTracks.filter((function(e){return e.isVideoTrack()})),1)[0]),e}}),Object.defineProperty(i.prototype,"getLocalAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return this._localTracks&&(e=P(this._localTracks.filter((function(e){return e.isAudioTrack()})),1)[0]),e}}),Object.defineProperty(i.prototype,"publish",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r;return y(this,(function(i){switch(i.label){case 0:return this._logger.info(M.L_RTC_MODULE_PUBLISH_T,"tracksIds: ".concat(e.map((function(e){return e instanceof b?e.getTrackId():e.track.getTrackId()}))),t),[4,Ee({asyncFn:this._room.publish.bind(this._room),fnArgs:[e],onError:function(e){}})];case 1:return(r=i.sent().code)!==p.SUCCESS?(this._onRTCMethodFail(k.PUBLISH_ERR,t),this._logger.error(M.L_RTC_MODULE_PUBLISH_R,"errCode: ".concat(r),t),[2,{code:r}]):(this._logger.info(M.L_RTC_MODULE_PUBLISH_R,"code: ".concat(D.SUCCESS),t),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(i.prototype,"publishVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.getLocalVideoTrack(),t=this._isPubTiny?{track:e,isPubTiny:!0}:e;return this._room.publish([t])}}),Object.defineProperty(i.prototype,"setVideoView",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this,i=[];e.forEach((function(e){var t=e.userId,n=e.videoElement,a=e.isTiny,o=void 0!==a&&a;if(r._userViewMap[t]={videoView:n,isTiny:o},t!==r._context.getCurrentId()&&r._room){var _=(r.getRemoteTracks()[t]||[]).map((function(e){return{track:e,subTiny:o}})).filter((function(e){return!e.track.isSubscribed()}));i.push.apply(i,U([],P(_),!1))}})),this._logger.info(M.L_RTC_MODULE_SET_VIDEO_VIEW_O,JSON.stringify({userViewMap:q(this._userViewMap),needSubTrackIds:i.map((function(e){return e.track.getTrackId()}))}),t),i.length&&this.subscribeTracks(i,t)}}),Object.defineProperty(i.prototype,"removeVideoView",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this,i=[];e.forEach((function(e){var t=r.getRemoteTracks()[e];if(t&&t.length){var n=t.filter((function(e){return e.isVideoTrack()}));n.length&&i.push(n[0])}delete r._userViewMap[e]})),this._logger.info(M.L_RTC_MODULE_REMOVE_VIDEO_VIEW_O,JSON.stringify({userViewMap:q(this._userViewMap),unsubTracks:i.map((function(e){return e.getTrackId()}))}),t),i.length&&this.unsubscribeTracks(i,t)}}),Object.defineProperty(i.prototype,"getUserViewMap",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._userViewMap}}),Object.defineProperty(i.prototype,"playMedia",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,i,n){var a;return v(this,void 0,void 0,(function(){var o,_,l,s,c,u,L;return y(this,(function(d){switch(d.label){case 0:if(o=n.videoView,_=n.volume,this._logger.info(M.L_RTC_MODULE_PLAY_MEDIA_T,"userId: ".concat(e,", mediaType: ").concat(t,", videoView: ").concat(null==o?void 0:o.nodeName,", volume: ").concat(_),i),l=this._context.getCurrentId(),e===l&&t===G.AUDIO)return this._logger.error(M.L_RTC_MODULE_PLAY_MEDIA_R,"please avoid playing local audio to prevent echoes.",i),[2,{code:D.PLAY_MEDIA_FAILED}];if(s=null,!(s=e===l?t===G.AUDIO?null:this.getLocalVideoTrack():null===(a=this.getRemoteTracks()[e])||void 0===a?void 0:a.filter((function(e){return t===G.AUDIO?e.isAudioTrack():e.isVideoTrack()}))[0]))return this._logger.error(M.L_RTC_MODULE_PLAY_MEDIA_R,"error code: ".concat(D.MEDIA_RESOURCE_INVALIED),i),[2,{code:D.MEDIA_RESOURCE_INVALIED}];d.label=1;case 1:return d.trys.push([1,6,,7]),c=void 0,s.isAudioTrack()?[4,s.play(void 0,{audioDeviceId:this._audioOutputDeviceId||void 0,volume:r(_)?100:_})]:[3,3];case 2:return c=d.sent(),[3,5];case 3:return[4,s.play(o)];case 4:c=d.sent(),d.label=5;case 5:return u=c.code,s.isAudioTrack()&&!this._remoteAudioEnable&&s.mute(),u!==p.SUCCESS?(this._logger.error(M.L_RTC_MODULE_PLAY_MEDIA_R,"errCode: ".concat(u),i),[2,{code:u}]):(this._logger.info(M.L_RTC_MODULE_PLAY_MEDIA_R,"success",i),[2,{code:D.SUCCESS}]);case 6:return L=d.sent(),this._logger.error(M.L_RTC_MODULE_PLAY_MEDIA_R,"errCode: ".concat(D.PLAY_MEDIA_FAILED,", message: ").concat(L.message,","),i),[2,{code:D.PLAY_MEDIA_FAILED}];case 7:return[2]}}))}))}}),Object.defineProperty(i,"__INNER_RTC_PROCESS_FAILED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-rtc-process-failed"}),Object.defineProperty(i,"__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-rtc-peerconnection-abnormal-close"}),Object.defineProperty(i,"__INNER_ON_SELF_JOINED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-on-self-joined"}),Object.defineProperty(i,"__INNER_ON_OTHER_JOINED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-on-other-joined"}),Object.defineProperty(i,"__INNER_RECEIVE_FIRST_FRAME__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-receive-first-frame"}),Object.defineProperty(i,"__INNER_ON_KICKOFF__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-kickoff-frame"}),Object.defineProperty(i,"__INNER_ON_DEVICE_ENABLE_CHANGE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-on-device-enable-change"}),i}(n),me=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,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];return v(this,void 0,void 0,(function(){var i,n;return y(this,(function(a){switch(a.label){case 0:if(!(i=null===(t=this._listener)||void 0===t?void 0:t[e]))return[2];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,i.apply(void 0,U([],P(r),!1))];case 2:return a.sent(),[3,4];case 3:return n=a.sent(),console.error(n),this._logger.error(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({name:n.name,message:n.message})),[3,4];case 4:return[2]}}))}))}}),Object.defineProperty(e.prototype,"onReceivedCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCall",callId:e.getCallId()}),t),this._callAppListener("onReceivedCall",e,r)}}),Object.defineProperty(e.prototype,"onRemoteUserInvited",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteUserInvited",inviteeUserList:e,inviterUserId:t,callId:r})),this._callAppListener("onRemoteUserInvited",e,t,r)}}),Object.defineProperty(e.prototype,"onCallConnected",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallConnected",callId:e.getCallId()})),this._callAppListener("onCallConnected",e)}}),Object.defineProperty(e.prototype,"onCallTypeChanged",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallTypeChanged",callId:t,callType:e}),r),this._callAppListener("onCallTypeChanged",e,t)}}),Object.defineProperty(e.prototype,"onRemoteUserStateChanged",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=e.callId,i=e.userId,n=e.userState,a=e.reason;this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteUserStateChanged",callId:r,userId:i,userState:n,reason:a}),t),this._callAppListener("onRemoteUserStateChanged",r,i,n,a)}}),Object.defineProperty(e.prototype,"onCallEnded",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallEnded",callId:e.getCallId(),closeReason:t}),r),this._callAppListener("onCallEnded",e,t)}}),Object.defineProperty(e.prototype,"onRemoteCameraStateChanged",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteCameraStateChanged",callId:e,trackId:null==t?void 0:t.getTrackId(),enable:null==t?void 0:t.isOwnerMuted()}));var r=null==t?void 0:t.getUserId();this._callAppListener("onRemoteCameraStateChanged",e,r,null==t?void 0:t.isOwnerMuted())}}),Object.defineProperty(e.prototype,"onRemoteMicrophoneStateChanged",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteMicrophoneStateChanged",callId:e,trackId:null==t?void 0:t.getTrackId(),enable:null==t?void 0:t.isOwnerMuted()}));var r=null==t?void 0:t.getUserId();this._callAppListener("onRemoteMicrophoneStateChanged",e,r,null==t?void 0:t.isOwnerMuted())}}),Object.defineProperty(e.prototype,"onReceivedCallRecord",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallRecord",record:e}),t),this._callAppListener("onReceivedCallRecord",e)}}),Object.defineProperty(e.prototype,"onReceivedChangeMediaTypeRequest",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedChangeMediaTypeRequest",userId:e,transactionId:t}),i),this._callAppListener("onReceivedChangeMediaTypeRequest",e,t,r)}}),Object.defineProperty(e.prototype,"onReceivedChangeMediaTypeResult",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=e.userId,i=e.transactionId,n=e.mediaType,a=e.code;this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedChangeMediaTypeResult",userId:r,mediaType:n}),t),this._callAppListener("onReceivedChangeMediaTypeResult",{userId:r,transactionId:i,mediaType:n,code:a})}}),Object.defineProperty(e.prototype,"onReceivedCallStartTime",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallStartTime",info:e}),t),this._callAppListener("onReceivedCallStartTime",e)}}),Object.defineProperty(e.prototype,"onReceivedCallFirstFrameTime",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallFirstFrameTime",callId:e,callFirstFrameTime:t}),r),this._callAppListener("onReceivedCallFirstFrameTime",e,t)}}),Object.defineProperty(e.prototype,"onUserMediaAvailable",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;this._logger.info(M.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onUserMediaAvailable",trackIds:e.map((function(e){return e.getTrackId()}))}),t),e.forEach((function(e){var t=e.getUserId(),i=e.isAudioTrack()?G.AUDIO:G.VIDEO;r._callAppListener("onUserMediaAvailable",t,i)}))}}),Object.defineProperty(e.prototype,"onFetchRemoteMediaError",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;e.forEach((function(e){var i=e.track.getUserId();r._callAppListener("onFetchRemoteMediaError",i,t)}))}}),Object.defineProperty(e.prototype,"onUserAudioLevelChanged",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;e.forEach((function(e){var r=e.track,i=e.audioLevel,n=r.getUserId();t._callAppListener("onUserAudioLevelChanged",n,i)}))}}),Object.defineProperty(e.prototype,"onReceivedCallPlusSummaryMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._callAppListener("onReceivedCallPlusSummaryMessage",e)}}),e}();!function(e){e[e.UNKNOW_ERR=41e3]="UNKNOW_ERR",e[e.DB_ERR=41001]="DB_ERR",e[e.JSON_ERR=41002]="JSON_ERR",e[e.INVALID_JSON_ERR=41003]="INVALID_JSON_ERR",e[e.MISSING_PARAMS=41004]="MISSING_PARAMS",e[e.PARAMS_REQUIRED=41005]="PARAMS_REQUIRED",e[e.DATA_FORMAT_ERR=41006]="DATA_FORMAT_ERR",e[e.METHOD_NOT_IMPLEMENTED=41007]="METHOD_NOT_IMPLEMENTED",e[e.CALL_NOT_EXIST=41010]="CALL_NOT_EXIST",e[e.SINGAL_EXCEED_TWO_INVITEE=41011]="SINGAL_EXCEED_TWO_INVITEE",e[e.GROUP_EXCEEDS_QUORUM=41012]="GROUP_EXCEEDS_QUORUM",e[e.OPERATION_EXPIRED=41013]="OPERATION_EXPIRED",e[e.DEVICE_IS_CALLING=41014]="DEVICE_IS_CALLING",e[e.REPORT_STREAM_READY_TIME_IS_INVALID=41018]="REPORT_STREAM_READY_TIME_IS_INVALID",e[e.NOT_CALL_YOURSELF=41019]="NOT_CALL_YOURSELF",e[e.SESSION_STATUS_NOT_EXIST=41020]="SESSION_STATUS_NOT_EXIST",e[e.HANGUP_NOT_ALLOW=41021]="HANGUP_NOT_ALLOW",e[e.ACCEPT_NOT_ALLOW=41022]="ACCEPT_NOT_ALLOW",e[e.OPERATION_NOT_ALLOW=41025]="OPERATION_NOT_ALLOW",e[e.TRANSACTION_ID_ERR=41100]="TRANSACTION_ID_ERR",e[e.UP_VIDEO_CANCELED=41050]="UP_VIDEO_CANCELED",e[e.CURRENT_CALL_IS_AUDIO=41051]="CURRENT_CALL_IS_AUDIO",e[e.CURRENT_CALL_IS_VIDEO=41052]="CURRENT_CALL_IS_VIDEO"}(Ae||(Ae={}));var ve=function(){function e(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_androidPushConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}})}return Object.defineProperty(e.prototype,"setChannelIdMi",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.channelIdMi=e,this):(this._logger.error(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: channelIdMi type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setMiLargeIconUrl",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._logger.warn(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"`setMiLargeIconUrl` has been deprecated."),this}}),Object.defineProperty(e.prototype,"setChannelIdHW",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.channelIdHW=e,this):(this._logger.error(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: channelIdHW type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setCategoryHW",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.categoryHW=e,this):(this._logger.error(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: categoryHW type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setImportanceHW",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return"LOW"!==e&&"NORMAL"!==e?(this._logger.error(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: importanceHW value is NORMAL|LOW, value: ".concat(e)),this):(this._androidPushConfig.importanceHW=e,this)}}),Object.defineProperty(e.prototype,"setImageUrlHW",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.imageUrlHW=e,this):(this._logger.error(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: imageUrlHW type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setChannelIdOPPO",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.channelIdOPPO=e,this):(this._logger.error(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: channelIdOPPO type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setTypeVivo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.typeVivo=e,this):(this._logger.error(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: typeVivo type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setCategoryVivo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.categoryVivo=e,this):(this._logger.error(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: categoryVivo type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setFcmChannelId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.fcmChannelId=e,this):(this._logger.error(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: fcmChannelId type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setFcmCollapseKey",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.fcmCollapseKey=e,this):(this._logger.error(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: fcmCollapseKey type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setFcmImageUrl",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.fcmImageUrl=e,this):(this._logger.error(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: fcmImageUrl type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setimportanceHonor",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return"LOW"!==e&&"NORMAL"!==e?(this._logger.error(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: importanceHonor value is NORMAL|LOW, value: ".concat(e)),this):(this._androidPushConfig.importanceHonor=e,this)}}),Object.defineProperty(e.prototype,"setimageUrlHonor",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.imageUrlHonor=e,this):(this._logger.error(M.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: imageUrlHonor type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"build",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._androidPushConfig}}),e}(),ye=function(){function n(e,t,r){var i=this;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,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:f.W640_H480,frameRate:S.FPS_15}}),Object.defineProperty(this,"_audioConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_callPlusStatistics",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_clientCallId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_isLaunchHangup",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_needHangupCallId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_rtcModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._context.registerMessageType("RC:CallPlusMiss",!0,!1,[]),this._reportAppEventModule=new me(t),this._callPlusStatistics=new _e(this._logger,this._context),this._callEngine=new Oe(this._context,this._logger,this._reportAppEventModule),this._rtcModule=new Ne(this._context,this._initOpts,this._logger,this._reportAppEventModule),this._rtcModule.on(Ne.__INNER_RTC_PROCESS_FAILED__,this._rtcProcessFailHandle.bind(this)),this._rtcModule.on(Ne.__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__,this._peerConnectionAbnormalClose.bind(this)),this._rtcModule.on(Ne.__INNER_ON_SELF_JOINED__,this._selfJoinedHandle.bind(this)),this._rtcModule.on(Ne.__INNER_ON_OTHER_JOINED__,this._otherJoinedHandle.bind(this)),this._rtcModule.on(Ne.__INNER_RECEIVE_FIRST_FRAME__,this._receiveFirstFrameHandle.bind(this)),this._rtcModule.on(Ne.__INNER_ON_KICKOFF__,this._kickoffHandle.bind(this)),this._rtcModule.on(Ne.__INNER_ON_DEVICE_ENABLE_CHANGE__,this._receiveDeviceEnableChangeHandle.bind(this)),this._callEngine.on(Oe.__INNER_SESSION_CONNECT__,this._rtcModule.sessionConnected.bind(this._rtcModule)),this._callEngine.on(Oe.__INNER_SESSION_CLOSE__,this._sessionCloseHandle.bind(this)),this._callEngine.on(Oe.__INNER_CHANGE_MEDIA_TYPE__,this._rtcModule.changeMediaType.bind(this._rtcModule)),this._callEngine.on(Oe.__INNER_INVITE__,(function(e,t){i._callPlusStatistics.reportStatisticsData(J.L_QS_RECEIVE_CALL_S,D.SUCCESS,+new Date,e,"",t)}))}return Object.defineProperty(n.prototype,"_rtcProcessFailHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this._callEngine.getLocalMainSession();if(r){var i=r.getCallId();this._callEngine.systemStatusUp({callId:i,sysStatus:e,forward:fe.CURRENT},t),this._callPlusStatistics.reportStatisticsData(J.L_QS_ABNORMAL_HANGUP_S,D.SUCCESS,+new Date,r),this._innerHangup({callId:i,systemState:e},t)}}}),Object.defineProperty(n.prototype,"_peerConnectionAbnormalClose",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._callEngine.getLocalMainSession();t&&(this._callEngine.systemStatusUp({callId:t.getCallId(),sysStatus:k.CONNECTION_ERR,forward:fe.CURRENT},e),this._callEngine.endCurrentSession(k.CONNECTION_ERR,t.getCallId(),e))}}),Object.defineProperty(n.prototype,"_selfJoinedHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i,n,a,o,_,l;return y(this,(function(s){return r=this._context.getCurrentId(),i=this._callEngine.getLocalMainSession(),this._reportAppEventModule.onCallConnected(i),n=this._rtcModule.getLocalVideoTrack(),a=this._rtcModule.getLocalAudioTrack(),o=!!n&&!n.isOwnerMuted(),_=!!a&&!a.isOwnerMuted(),this._callEngine.setUserDeviceEnable(r,G.VIDEO,o,t),this._callEngine.setUserDeviceEnable(r,G.AUDIO,_,t),l=[{userId:r,userState:j.ONCALL,systemState:k.ONCALL,cameraEnable:o,microphoneEnable:_}],this._callEngine.updateUsersState(e,l,t),this._callEngine.startTimeCorrection(t),[2]}))}))}}),Object.defineProperty(n.prototype,"_otherJoinedHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,i="",n=e.map((function(e){return i=e.callId,{userId:e.userId,userState:j.ONCALL,systemState:k.ONCALL,cameraEnable:!1,microphoneEnable:!1}}));this._callEngine.updateUsersState(i,n,t),(null===(r=this._callEngine.getLocalMainSession())||void 0===r?void 0:r.getState())!==V.ONCALL&&this._callEngine.updateMainSessionState(V.ONCALL)}}),Object.defineProperty(n.prototype,"_receiveFirstFrameHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;(null===(t=this._callEngine.getLocalMainSession())||void 0===t?void 0:t.getState())!==V.ONCALL&&this._callEngine.updateMainSessionState(V.ONCALL),this._callEngine.upFirstFrameTime(e)}}),Object.defineProperty(n.prototype,"_kickoffHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){if(e!==k.CONNECTION_ERR){var i=this._callEngine.getLocalMainSession();if(i){var n=i.getCallId();this._callPlusStatistics.reportStatisticsData(J.L_QS_ABNORMAL_HANGUP_S,D.SUCCESS,+new Date,i,this._clientCallId),this._callEngine.systemStatusUp({callId:n,sysStatus:e,forward:fe.CURRENT},r),this._callEngine.endCurrentSession(e,t,r)}}else this._callEngine.endCurrentSession(e,t,r)}}),Object.defineProperty(n.prototype,"_receiveDeviceEnableChangeHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;e.forEach((function(e){var i=e.getUserId(),n=e.isAudioTrack()?G.AUDIO:G.VIDEO;r._callEngine.setUserDeviceEnable(i,n,!e.isOwnerMuted(),t)}))}}),Object.defineProperty(n.prototype,"_sessionCloseHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._isLaunchHangup||(this._clientCallId=""),this._isLaunchHangup=!1,this._rtcModule.sessionClose(e,t)}}),Object.defineProperty(n.prototype,"setCallPlusEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(M.L_CALLPLUS_CLIENT_SET_EVENT_LISTENER_O,e?Object.keys(e).join(","):null),this._reportAppEventModule.registerEventListener(e)}}),Object.defineProperty(n.prototype,"setStatusReportListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(M.L_CALLPLUS_CLIENT_SET_STATUS_REPORT_LISTENER_O,e?Object.keys(e).join(","):null),this._rtcModule.setCallPlusStatusReportListener(e)}}),Object.defineProperty(n.prototype,"setVideoView",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r,i,n=this._logger.createTraceId();if(this._logger.info(M.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_T,JSON.stringify({list:e.map((function(e){var t=e.userId,r=e.videoElement,i=e.isTiny;return{userId:t,elementName:null==r?void 0:r.nodeName,isTiny:i}}))}),n),!C(e))return this._logger.error(M.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,"params err, list: not empty array, value: ".concat(JSON.stringify(e)),n),{code:D.PARAM_ERROR};try{for(var a=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e),o=a.next();!o.done;o=a.next()){var _=o.value,l=_.userId,s=_.videoElement;if(!T(l))return this._logger.error(M.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,"params err, userId: not empty string, value: ".concat(l),n),{code:D.PARAM_ERROR};if(!(i=s)||!i.nodeName||"VIDEO"!==i.nodeName.toUpperCase())return this._logger.error(M.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,"params err, videoElement: need a video element, value: ".concat(s instanceof HTMLElement?s.nodeName:s),n),{code:D.PARAM_ERROR}}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}return this._logger.info(M.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,"succes",n),this._rtcModule.setVideoView(e,n),{code:D.SUCCESS}}}),Object.defineProperty(n.prototype,"removeVideoView",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._logger.createTraceId();return this._logger.info(M.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_T,JSON.stringify({userIds:e}),t),C(e)&&e.every((function(e){return T(e)}))?(this._logger.info(M.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R,"succes",t),this._rtcModule.removeVideoView(e,t),{code:D.SUCCESS}):(this._logger.error(M.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R,"params err, userIds: not empty array, userId: not empty string, value: ".concat(JSON.stringify(e)),t),{code:D.PARAM_ERROR})}}),Object.defineProperty(n.prototype,"playMedia",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,i){return void 0===i&&(i={}),v(this,void 0,void 0,(function(){var n,a;return y(this,(function(o){return n=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_PLAY_MEDIA_T,JSON.stringify({userId:e,mediaType:t,options:i}),n),T(e)?r(G[t])?(this._logger.error(M.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,"params err, mediaType is illegal, value: ".concat(t),n),[2,{code:D.PARAM_ERROR}]):t===G.AUDIO&&e===this._context.getCurrentId()?(this._logger.info(M.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,"success",n),[2,{code:D.SUCCESS}]):(a=(this._rtcModule.getUserViewMap()[e]||{}).videoView,t===G.AUDIO||a?[2,this._rtcModule.playMedia(e,t,n,{videoView:a,volume:i.volume})]:(this._logger.error(M.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,"errCode: ".concat(D.VIDEO_VIEW_NOT_SET,", video view not set"),n),[2,{code:D.VIDEO_VIEW_NOT_SET}])):(this._logger.error(M.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,"params err, userId: not empty string, value: ".concat(e),n),[2,{code:D.PARAM_ERROR}])}))}))}}),Object.defineProperty(n.prototype,"createVideoConfigBuilder",{enumerable:!1,configurable:!0,writable:!0,value:function(){return new Y(this._logger)}}),Object.defineProperty(n.prototype,"setVideoConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(M.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_T,JSON.stringify(e));var t=e.frameRate,r=e.resolution,i=e.maxBitrate,n=e.minBitrate;if(!S[t])return this._logger.error(M.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,"param error, frameRate is illegal, value: ".concat(t)),{code:D.PARAM_ERROR};if(!f[r])return this._logger.error(M.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,"param error, resolution is illegal, value: ".concat(r)),{code:D.PARAM_ERROR};var a=Q(n,i),o=a.code,_=a.errorMsg;return o!==D.SUCCESS&&this._logger.error(M.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,_),this._logger.info(M.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,"success"),this._videoConfig=m({},e),this._rtcModule.setVideoConfig(this._videoConfig),{code:D.SUCCESS}}}),Object.defineProperty(n.prototype,"createAudioConfigBuilder",{enumerable:!1,configurable:!0,writable:!0,value:function(){return new F(this._logger)}}),Object.defineProperty(n.prototype,"createAndroidPushConfigBuilder",{enumerable:!1,configurable:!0,writable:!0,value:function(){return new ve(this._logger)}}),Object.defineProperty(n.prototype,"setAudioConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this._logger.info(M.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_T,JSON.stringify(t));var r=t.sampleRate,i=t.minBitrate,n=t.maxBitrate;if(r&&!e(r))return this._logger.error(M.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,"param error, sampleRate: type is number, value: ".concat(r)),{code:D.PARAM_ERROR};var a=Q(i,n),o=a.code,_=a.errorMsg;return o!==D.SUCCESS&&this._logger.error(M.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,_),this._logger.info(M.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,"success"),this._audioConfig=m({},t),this._rtcModule.setAudioConfig(this._audioConfig),{code:D.SUCCESS}}}),Object.defineProperty(n.prototype,"setAudioOutputDeviceId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._logger.info(M.L_CALLPLUS_CLIENT_SET_AUDIO_OUTPUT_DEVICE_ID_O,e),this._rtcModule.setAudioOutputDeviceId(e)}}),Object.defineProperty(n.prototype,"startCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,n){return void 0===t&&(t=w.SINGLE),void 0===r&&(r=G.AUDIO_VIDEO),v(this,void 0,void 0,(function(){return y(this,(function(a){return[2,this.startCallWithParams({userIds:e,type:t,mediaType:r,pushConfig:i,extra:n})]}))}))}}),Object.defineProperty(n.prototype,"startCallWithParams",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,n,a,o,l,s,u,L,d,E,I,g,S,f,p,h,b,R,O,A,N,m,v,P;return y(this,(function(y){switch(y.label){case 0:if("object"!=typeof e)return this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"params is invalid."),[2,{code:D.PARAM_ERROR}];if(t=e.userIds,n=e.type,a=void 0===n?w.SINGLE:n,o=e.mediaType,l=void 0===o?G.AUDIO_VIDEO:o,s=e.pushConfig,u=e.extra,L=e.syncData,d=e.encryption,E=e.callId,this._clientCallId=c(),I=+new Date,g=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_START_CALL_T,"userIds: ".concat(t.join(","),", callType: ").concat(a,", mediaType: ").concat(l,", pushConfig: ").concat(s,", extra: ").concat(u),g),this._context.getConnectionStatus()!==_.CONNECTED)return this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"errCode: ".concat(D.SIGNAL_DISCONNECTED),g),[2,{code:D.SIGNAL_DISCONNECTED}];if(!(S=this._context.getNaviInfo())||!K(S))return this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"errCode: ".concat(D.RTC_SERVICE_UNAVAILABLE),g),[2,{code:D.RTC_SERVICE_UNAVAILABLE}];if(E&&!i(E))return this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"params err, callId type is string, value: ".concat(E),g),[2,{code:D.PARAM_ERROR}];if(!C(t)||!t.every((function(e){return T(e)})))return this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"params err, userIds: not empty array, userId: not empty string, value: ".concat(JSON.stringify(t)),g),[2,{code:D.PARAM_ERROR}];if(r(w[a]))return this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"params err, callType is illegal, value: ".concat(a),g),[2,{code:D.PARAM_ERROR}];if(r(G[l]))return this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"params err, mediaType is illegal, value: ".concat(l),g),[2,{code:D.PARAM_ERROR}];if(s&&(f=Z(s)).code!==D.SUCCESS)return this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"params err, pushConfig is illegal, msg: ".concat(f.errorMsg),g),[2,{code:D.PARAM_ERROR}];if(u){if(!i(u))return this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"params err, extra is illegal, value: ".concat(u),g),[2,{code:D.PARAM_ERROR}];if(te(u)>Ce)return this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"params err, extra max size is 128KB",g),[2,{code:D.PARAM_ERROR}]}if(L){if(!i(L))return this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"params err, syncData is illegal",g),[2,{code:D.PARAM_ERROR}];if(te(L)>1024)return this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"params err, syncData max size is 1KB",g),[2,{code:D.PARAM_ERROR}]}return t.length>1&&a===w.SINGLE?(this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"params err, You can only call one person in a single call, userIds: ".concat(t.join(",")),g),[2,{code:D.PARAM_ERROR}]):this._callEngine.getLocalMainSession()?(this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"errCode: ".concat(D.SESSION_EXIST,", session exist"),g),[2,{code:D.SESSION_EXIST}]):[4,this._rtcModule.createCallMediaTracks(l,g)];case 1:return(p=y.sent().code)!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"create meida tracks error code: ".concat(p),g),[2,{code:p}]):(b=(h=d||{isSecret:!1,secretKey:""}).isSecret,R=h.secretKey,[4,this._callEngine.startCall({toUsers:t.map((function(e){return{userId:e}})),callType:a,mediaType:l,callId:E,clientCallId:this._clientCallId,pushConfig:s,extra:JSON.stringify({userId:this._context.getCurrentId(),extra:u}),innerExtra:L,secretChat:b?x.SECRET:x.NORMAL,secretChatKey:R},g)]);case 2:return O=y.sent(),A=O.code,N=O.data,this._callPlusStatistics.reportStatisticsData(J.L_QS_START_CALL_S,A,I,null,this._clientCallId,null,{mediaType:l,callType:a,callId:(null==N?void 0:N.callId)||""}),A!==D.SUCCESS?(this._rtcModule.destroyAllTracks(g),this._logger.error(M.L_CALLPLUS_CLIENT_START_CALL_R,"signal error code: ".concat(A),g),[2,{code:A}]):(v=(m=N).callId,P=m.clientCallId,this._needHangupCallId===P?(this._callEngine.clearAllTimer(v,g),this._callEngine.hangup({callId:v,systemState:k.CANCELLED},g),this._logger.info(M.L_CALLPLUS_CLIENT_START_CALL_R,"the ".concat(v," call has been hangup"),g),[2,{code:D.SUCCESS}]):(a===w.MULTI&&this._rtcModule.sessionConnected(v,b,g),this._logger.info(M.L_CALLPLUS_CLIENT_START_CALL_R,JSON.stringify({data:N,code:A}),g),[2,{code:D.SUCCESS,callId:v}]))}}))}))}}),Object.defineProperty(n.prototype,"joinMultiCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i,n,a,o,l,s,c,u,L,d;return y(this,(function(E){switch(E.label){case 0:return t=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_T,"callId: ".concat(e),t),this._context.getConnectionStatus()!==_.CONNECTED?(this._logger.error(M.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"code: ".concat(D.SIGNAL_DISCONNECTED),t),[2,{code:D.SIGNAL_DISCONNECTED}]):(r=this._context.getNaviInfo())&&K(r)?T(e)?[4,this._callEngine.getCallSession({callId:e},t)]:(this._logger.error(M.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"params err, callId: not empty string, value: ".concat(e),t),[2,{code:D.PARAM_ERROR}]):(this._logger.error(M.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"code: ".concat(D.RTC_SERVICE_UNAVAILABLE),t),[2,{code:D.RTC_SERVICE_UNAVAILABLE}]);case 1:return i=E.sent(),n=i.code,a=i.data,n!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"get call data error, code: ".concat(n),t),[2,{code:n}]):(l=(o=a).mediaType,s=o.secretChat,(c=this._callEngine.getLocalMainSession())&&c.getCallId()!==e?[2,{code:D.SESSION_EXIST}]:[4,this._rtcModule.createCallMediaTracks(l,t)]);case 2:return(u=E.sent().code)!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"create meida tracks error code: ".concat(u),t),[2,{code:u}]):[4,this._callEngine.joinCall({callId:e,mediaType:l},t)];case 3:return(L=E.sent().code)!==D.SUCCESS?(this._rtcModule.destroyAllTracks(t),this._logger.error(M.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"signal error code: ".concat(L),t),[2,{code:L}]):(this._logger.info(M.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"code: ".concat(D.SUCCESS),t),d=s===x.SECRET,[4,this._rtcModule.sessionConnected(e,d,t)]);case 4:return E.sent(),[2,{code:D.SUCCESS}]}}))}))}}),Object.defineProperty(n.prototype,"invite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n;return v(this,void 0,void 0,(function(){var a,o,_,l,s,c;return y(this,(function(u){switch(u.label){case 0:if(a=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_INVITE_T,"callId: ".concat(e.join(","),", pushConfig: ").concat(t,", extra: ").concat(r),a),!C(e)||!e.every((function(e){return T(e)})))return this._logger.error(M.L_CALLPLUS_CLIENT_INVITE_R,"params err, userIds: not empty array, userId: not empty string, value: ".concat(JSON.stringify(e)),a),[2,{code:D.PARAM_ERROR}];if(t&&(o=Z(t)).code!==D.SUCCESS)return this._logger.error(M.L_CALLPLUS_CLIENT_INVITE_R,"params err, pushConfig is illegal, msg: ".concat(o.errorMsg),a),[2,{code:D.PARAM_ERROR}];if(r){if(!i(r))return this._logger.error(M.L_CALLPLUS_CLIENT_INVITE_R,"params err, extra is illegal, value: ".concat(r),a),[2,{code:D.PARAM_ERROR}];if(te(r)>Ce)return this._logger.error(M.L_CALLPLUS_CLIENT_INVITE_R,"params err, extra max size is 128KB",a),[2,{code:D.PARAM_ERROR}]}return[4,this._callEngine.invite({toUsers:e.map((function(e){return{userId:e}})),pushConfig:t,extra:JSON.stringify({userId:this._context.getCurrentId(),extra:r})},a)];case 1:return _=u.sent(),l=_.code,s=_.data,l!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_INVITE_R,"signal error code: ".concat(l),a),[2,{code:l}]):(c=[],(null===(n=s.busylineUsers)||void 0===n?void 0:n.length)&&c.push.apply(c,U([],P(s.busylineUsers.map((function(e){return{userId:e.userId,state:e.sessionStatus}}))),!1)),this._logger.info(M.L_CALLPLUS_CLIENT_INVITE_R,"success busyUsers: ".concat(JSON.stringify(c)),a),[2,{code:D.SUCCESS,busyUsers:c}])}}))}))}}),Object.defineProperty(n.prototype,"accept",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return v(this,void 0,void 0,(function(){var r,i,n,a,o,l,s,c,u,L,d;return y(this,(function(E){switch(E.label){case 0:return r=+new Date,i=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_ACCEPT_T,"callId: ".concat(e,", pushConfig: ").concat(t),i),this._context.getConnectionStatus()!==_.CONNECTED?(this._logger.error(M.L_CALLPLUS_CLIENT_ACCEPT_R,"errCode: ".concat(D.SIGNAL_DISCONNECTED),i),[2,{code:D.SIGNAL_DISCONNECTED}]):(n=this._context.getNaviInfo())&&K(n)?T(e)?t&&(a=Z(t)).code!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_ACCEPT_R,"params err, pushConfig is illegal, msg: ".concat(a.errorMsg),i),[2,{code:D.PARAM_ERROR}]):(o=this._callEngine.getLocalMainSession(),l=this._callEngine.getHoldSession(e),o||l?e===(null==l?void 0:l.getCallId())?[4,this.hangup(o.getCallId())]:[3,2]:(this._logger.error(M.L_CALLPLUS_CLIENT_ACCEPT_R,"errCode : ".concat(D.NOT_IN_CALL,", session not exist"),i),[2,{code:D.NOT_IN_CALL}])):(this._logger.error(M.L_CALLPLUS_CLIENT_ACCEPT_R,"params err, callId: not empty string, value: ".concat(e),i),[2,{code:D.PARAM_ERROR}]):(this._logger.error(M.L_CALLPLUS_CLIENT_ACCEPT_R,"errCode: ".concat(D.RTC_SERVICE_UNAVAILABLE),i),[2,{code:D.RTC_SERVICE_UNAVAILABLE}]);case 1:if((s=E.sent().code)!==D.SUCCESS)return this._logger.error(M.L_CALLPLUS_CLIENT_ACCEPT_R,"hangup mainSession error code: ".concat(s),i),[2,{code:s}];this._callEngine.upgradeMainSession(e),o=this._callEngine.getLocalMainSession(),E.label=2;case 2:return c=o.getMediaType(),[4,this._rtcModule.createCallMediaTracks(c,i)];case 3:return(u=E.sent().code)!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_ACCEPT_R,"create meida tracks error code: ".concat(u),i),[2,{code:u}]):[4,this._callEngine.accept({callId:e},i)];case 4:return L=E.sent().code,this._callPlusStatistics.reportStatisticsData(J.L_QS_ACCEPT_CALL_S,L,r,o),L!==D.SUCCESS?(this._rtcModule.destroyAllTracks(i),this._logger.error(M.L_CALLPLUS_CLIENT_ACCEPT_R,"signal error code: ".concat(L),i),[2,{code:L}]):(this._logger.info(M.L_CALLPLUS_CLIENT_ACCEPT_R,"success",i),d=o.isSecret(),this._rtcModule.sessionConnected(e,d,i),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(n.prototype,"_innerHangup",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;return v(this,void 0,void 0,(function(){var i,n;return y(this,(function(a){switch(a.label){case 0:return i=e.callId,this._callEngine.setIsLocalClientHangup(!0),this._callEngine.clearAllTimer(i,t),[4,this._callEngine.hangup(e,t)];case 1:return(n=a.sent().code)===Ae.CALL_NOT_EXIST?[2,{code:D.SUCCESS}]:n!==D.SUCCESS||i!==(null===(r=this._callEngine.getLocalMainSession())||void 0===r?void 0:r.getCallId())?[3,3]:[4,this._rtcModule.sessionClose(i,t)];case 2:a.sent(),a.label=3;case 3:return[2,{code:n}]}}))}))}}),Object.defineProperty(n.prototype,"hangup",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return v(this,void 0,void 0,(function(){return y(this,(function(i){return[2,this._hangup(e,t,r)]}))}))}}),Object.defineProperty(n.prototype,"_hangup",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n;return v(this,void 0,void 0,(function(){var a,o,_,l,s,c,u,L,d,E,C,T;return y(this,(function(I){switch(I.label){case 0:return a=+new Date,o=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_HANGUP_T,"callId: ".concat(e,", pushConfig: ").concat(t),o),(_=this._callEngine.getLocalMainSession())?e&&!i(e)?(this._logger.error(M.L_CALLPLUS_CLIENT_HANGUP_R,"params err, callId: type is string, value: ".concat(e),o),[2,{code:D.PARAM_ERROR}]):t&&(l=Z(t)).code!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_HANGUP_R,"params err, pushConfig is illegal, msg: ".concat(l.errorMsg),o),[2,{code:D.PARAM_ERROR}]):(s=_.getCallId(),e&&e!==s&&!this._callEngine.getHoldSession(e)?(this._logger.error(M.L_CALLPLUS_CLIENT_HANGUP_R,"params err, callId is invalid, value: ".concat(e),o),[2,{code:D.CALL_ID_INVALID}]):(this._isLaunchHangup=!0,this._needHangupCallId=e||s,c=this._callEngine.getHoldSession(this._needHangupCallId),u=c||_,L=this._context.getCurrentId(),d=_.getUserList().filter((function(e){return e.userId===L}))[0].state,E=[_.getCreatorUserId(),_.getInviterUserId()].includes(L),C=null!==(n=null!=r?r:function(e,t){var r;switch(e){case j.CALLING:r=k.CANCELLED;break;case j.RINGING:case j.INVITED:r=k.DECLINED;break;case j.CONNECTING:r=t?k.DECLINED:k.CANCELLED;break;case j.ONCALL:r=k.ENDED}return r}(d,E))&&void 0!==n?n:k.ENDED,[4,this._innerHangup({callId:this._needHangupCallId,systemState:C,pushConfig:t},o)])):[2,{code:D.NOT_IN_CALL}];case 1:return T=I.sent().code,this._callPlusStatistics.reportStatisticsData(J.L_QS_HANGUP_CALL_S,T,a,u,this._clientCallId),T!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_HANGUP_R,"signal error code : ".concat(T),o),[2,{code:T}]):(this._needHangupCallId=null,this._logger.info(M.L_CALLPLUS_CLIENT_HANGUP_R,"success",o),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(n.prototype,"requestChangeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,i,n,a,o,_,l,s=this;return y(this,(function(c){switch(c.label){case 0:return t=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_T,"mediaType: ".concat(e),t),r(G[e])?(this._logger.error(M.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,"params err, mediaType is illegal, value: ".concat(e),t),[2,{code:D.PARAM_ERROR}]):(i=this.getCurrentCallSession(),n=null==i?void 0:i.getMediaType(),e===n?(this._logger.error(M.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,"error code: ".concat(D.MEDIATYPE_INVALID),t),[2,{code:D.MEDIATYPE_INVALID}]):this._callEngine.getLocalMainSession()?(a=null==i?void 0:i.getUserList().filter((function(e){return e.userId!==s._context.getCurrentId()})).map((function(e){return e.userId})),[4,this._callEngine.requestChangeMediaType({mediaType:e,toUserIds:a||[]},t)]):(this._logger.error(M.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,"error code : ".concat(D.NOT_IN_CALL,", session not exist"),t),[2,{code:D.NOT_IN_CALL}]));case 1:return o=c.sent(),_=o.code,l=o.data,_!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,"signal error code: ".concat(_),t),[2,{code:_}]):(this._logger.info(M.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,"success transactionId: ".concat(l.transactionId),t),[2,{code:D.SUCCESS,transactionId:l.transactionId}])}}))}))}}),Object.defineProperty(n.prototype,"cancelChangeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r;return y(this,(function(i){switch(i.label){case 0:return t=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_T,"transactionId: ".concat(e),t),T(e)?this._callEngine.getLocalMainSession()?[4,this._callEngine.cancelChangeMediaType({transactionId:e},t)]:(this._logger.error(M.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,"error code : ".concat(D.NOT_IN_CALL,", session not exist"),t),[2,{code:D.NOT_IN_CALL}]):(this._logger.error(M.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,"param error, transactionId: not empty string, value: ".concat(e),t),[2,{code:D.PARAM_ERROR}]);case 1:return(r=i.sent().code)!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,"signal error code: ".concat(r),t),[2,{code:r}]):(this._logger.info(M.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,"success",t),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(n.prototype,"replyChangeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){return v(this,void 0,void 0,(function(){var i,n;return y(this,(function(a){switch(a.label){case 0:return i=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_T,"transactionId: ".concat(e),i),T(e)?t(r)?this._callEngine.getLocalMainSession()?[4,this._callEngine.responseChangeMediaType({transactionId:e,agree:r},i)]:(this._logger.error(M.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"error code : ".concat(D.NOT_IN_CALL,", session not exist"),i),[2,{code:D.NOT_IN_CALL}]):(this._logger.error(M.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"param error, isAgree: type is boolean, value: ".concat(r),i),[2,{code:D.PARAM_ERROR}]):(this._logger.error(M.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"param error, transactionId: not empty string, value: ".concat(e),i),[2,{code:D.PARAM_ERROR}]);case 1:return(n=a.sent().code)!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"signal error: ".concat(n),i),[2,{code:n}]):(this._logger.info(M.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"success",i),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(n.prototype,"getCurrentCallSession",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callEngine.getLocalMainSession()}}),Object.defineProperty(n.prototype,"getAvailableCallRecordsFromServer",{enumerable:!1,configurable:!0,writable:!0,value:function(){return v(this,void 0,void 0,(function(){var e,t,r,i;return y(this,(function(n){switch(n.label){case 0:return e=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_T,"",e),[4,this._callEngine.getOpenCallList(e)];case 1:return t=n.sent(),r=t.code,i=t.data,r!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R,"signal error code: ".concat(r),e),[2,{code:r}]):(this._logger.info(M.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R,"success, data: ".concat(JSON.stringify(i)),e),[2,{code:D.SUCCESS,records:i}])}}))}))}}),Object.defineProperty(n.prototype,"getCallRecords",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return void 0===i&&(i=0),v(this,void 0,void 0,(function(){var n,a,o,_;return y(this,(function(l){switch(l.label){case 0:return n=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_T,"startTimestamp: ".concat(t,", count: ").concat(r),n),e(t)&&t>=0?e(r)&&r>0?[4,this._callEngine.getCallLogList({timestamp:t,count:r,order:i},n)]:(this._logger.error(M.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,"params error, count: is a number >= 0, value: ".concat(r),n),[2,{code:D.PARAM_ERROR}]):(this._logger.error(M.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,"params error, startTimestamp: is a number >= 0, value: ".concat(t),n),[2,{code:D.PARAM_ERROR}]);case 1:return a=l.sent(),o=a.code,_=a.data,o!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,"signal error code: ".concat(o),n),[2,{code:o}]):(this._logger.info(M.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,"success",n),[2,{code:D.SUCCESS,result:_}])}}))}))}}),Object.defineProperty(n.prototype,"deleteCallRecordsFromServer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r;return y(this,(function(i){switch(i.label){case 0:return t=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_T,"callIds: ".concat(e.join(",")),t),C(e)&&e.every((function(e){return T(e)}))?[4,this._callEngine.deleteCallLog(e,t)]:(this._logger.error(M.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,"params err, callIds: not empty array, callId: not empty string, callIds: ".concat(JSON.stringify(e)),t),[2,{code:D.PARAM_ERROR}]);case 1:return(r=i.sent().code)!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,"signal error code: ".concat(r),t),[2,{code:r}]):(this._logger.info(M.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,"success",t),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(n.prototype,"deleteAllCallRecordsFromServer",{enumerable:!1,configurable:!0,writable:!0,value:function(){return v(this,void 0,void 0,(function(){var e,t;return y(this,(function(r){switch(r.label){case 0:return e=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_T,"",e),[4,this._callEngine.removeAllCallLog(e)];case 1:return(t=r.sent().code)!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R,"signal error code: ".concat(t),e),[2,{code:t}]):(this._logger.info(M.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R,"success",e),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(n.prototype,"startCamera",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return v(this,void 0,void 0,(function(){var t,r,i,n,a,o;return y(this,(function(_){switch(_.label){case 0:return t=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_START_CAMERA_T,"",t),[4,this._rtcModule.getCameraVideoTrack(t)];case 1:return r=_.sent(),i=r.code,n=r.track,i!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_START_CAMERA_R,"create video track error code: ".concat(i),t),[2,{code:i}]):(this._callEngine.setUserDeviceEnable(this._context.getCurrentId(),G.VIDEO,!0,t),(null==n?void 0:n.isPublished())||(null===(e=this._callEngine.getLocalMainSession())||void 0===e?void 0:e.getState())!==V.ONCALL?[3,3]:[4,this._rtcModule.publishVideoTrack()]);case 2:return(a=_.sent().code)!==p.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_START_CAMERA_R,"publish error code: ".concat(a),t),[2,{code:a}]):(this._logger.info(M.L_CALLPLUS_CLIENT_START_CAMERA_R,"success",t),[2,{code:D.SUCCESS}]);case 3:return[4,this._rtcModule.enableVideoTrack(t)];case 4:return(o=_.sent().code)!==p.SUCCESS&&o!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_START_CAMERA_R,"signal error code: ".concat(o),t),[2,{code:o}]):(this._logger.info(M.L_CALLPLUS_CLIENT_START_CAMERA_R,"success",t),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(n.prototype,"stopCamera",{enumerable:!1,configurable:!0,writable:!0,value:function(){return v(this,void 0,void 0,(function(){var e,t,r,i;return y(this,(function(n){switch(n.label){case 0:return e=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_STOP_CAMERA_T,"",e),[4,this._rtcModule.disableVideoTrack()];case 1:return t=n.sent(),r=t.code,i=t.track,r!==D.SUCCESS&&r!==p.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_STOP_CAMERA_R,"error code: ".concat(r),e),[2,{code:r}]):(this._rtcModule.destroyTrack(i),this._callEngine.setUserDeviceEnable(this._context.getCurrentId(),G.VIDEO,!1,e),this._logger.info(M.L_CALLPLUS_CLIENT_STOP_CAMERA_R,"success",e),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(n.prototype,"switchCamera",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r,i;return y(this,(function(n){switch(n.label){case 0:return t=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_SWITCH_CAMERA_T,"cameraId: ".concat(e),t),T(e)?(r=this._callEngine.getLocalMainSession())?r.getMediaType()===G.AUDIO?(this._logger.error(M.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"errCode: ".concat(D.NOT_VIDEO_CALL),t),[2,{code:D.NOT_VIDEO_CALL}]):(this._videoConfig.cameraId=e,this._rtcModule.setVideoConfig(this._videoConfig),[4,this._rtcModule.changeVideoDevice(t)]):(this._logger.error(M.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"errCode: ".concat(D.NOT_IN_CALL),t),[2,{code:D.NOT_IN_CALL}]):(this._logger.error(M.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"param error, cameraId: not empty string, value: ".concat(e),t),[2,{code:D.PARAM_ERROR}]);case 1:return(i=n.sent().code)!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"call client changeVideoDevice error code: ".concat(i),t),[2,{code:i}]):(this._logger.info(M.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"success",t),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(n.prototype,"startMicrophone",{enumerable:!1,configurable:!0,writable:!0,value:function(){return v(this,void 0,void 0,(function(){var e,t,r,i,n;return y(this,(function(a){switch(a.label){case 0:return e=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_START_MICROPHONE_T,"",e),[4,this._rtcModule.getMicrophoneAudioTrack(e)];case 1:return t=a.sent(),r=t.code,i=t.track,r!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"create microphone audio track error code: ".concat(r),e),[2,{code:r}]):(this._callEngine.setUserDeviceEnable(this._context.getCurrentId(),G.AUDIO,!0,e),i.isOwnerMuted()?[4,i.unmute()]:(this._logger.info(M.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"success",e),[2,{code:D.SUCCESS}]));case 2:return(n=a.sent())!==p.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"signal error code: ".concat(r),e),[2,{code:n}]):(this._logger.info(M.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"success",e),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(n.prototype,"stopMicrophone",{enumerable:!1,configurable:!0,writable:!0,value:function(){return v(this,void 0,void 0,(function(){var e,t;return y(this,(function(r){switch(r.label){case 0:return e=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_STOP_MICROPHONE_T,"",e),[4,this._rtcModule.disableAudioTrack()];case 1:return(t=r.sent().code)!==D.SUCCESS&&t!==p.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R,"signal error code: ".concat(t),e),[2,{code:t}]):(this._callEngine.setUserDeviceEnable(this._context.getCurrentId(),G.AUDIO,!1,e),this._logger.info(M.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R,"success",e),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(n.prototype,"isMicrophoneEnabled",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._rtcModule.getLocalAudioTrack();return!!e&&!e.isOwnerMuted()}}),Object.defineProperty(n.prototype,"setAllRemoteAudioEnable",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t;return y(this,(function(r){return t=this._logger.createTraceId(),[2,this._rtcModule.setAllRemoteAudioEnable(e,t)]}))}))}}),Object.defineProperty(n.prototype,"getVersion",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"2.1.10-enterprise-lz.50"}}),Object.defineProperty(n.prototype,"getCameras",{enumerable:!1,configurable:!0,writable:!0,value:function(){return v(this,void 0,void 0,(function(){return y(this,(function(e){return[2,R.getCameras()]}))}))}}),Object.defineProperty(n.prototype,"getMicrophones",{enumerable:!1,configurable:!0,writable:!0,value:function(){return v(this,void 0,void 0,(function(){return y(this,(function(e){return[2,R.getMicrophones()]}))}))}}),Object.defineProperty(n.prototype,"getSpeakers",{enumerable:!1,configurable:!0,writable:!0,value:function(){return v(this,void 0,void 0,(function(){return y(this,(function(e){return[2,R.getSpeakers()]}))}))}}),Object.defineProperty(n.prototype,"getRTCSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._rtcModule.getRTCSessionId()}}),Object.defineProperty(n.prototype,"switchMicrophone",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return v(this,void 0,void 0,(function(){var t,r;return y(this,(function(i){switch(i.label){case 0:return t=this._logger.createTraceId(),this._logger.info(M.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_T,"microphoneId: ".concat(e),t),T(e)?this._callEngine.getLocalMainSession()?(this._audioConfig.microphoneId=e,this._rtcModule.setAudioConfig(this._audioConfig),[4,this._rtcModule.changeAudioDevice(t)]):(this._logger.error(M.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,"errCode: ".concat(D.NOT_IN_CALL),t),[2,{code:D.NOT_IN_CALL}]):(this._logger.error(M.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,"param error, microphoneId: not empty string, value: ".concat(e),t),[2,{code:D.PARAM_ERROR}]);case 1:return(r=i.sent().code)!==D.SUCCESS?(this._logger.error(M.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,"call client changeAudioDevice error code: ".concat(r),t),[2,{code:r}]):(this._logger.info(M.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,"success",t),[2,{code:D.SUCCESS}])}}))}))}}),Object.defineProperty(n.prototype,"generateCallId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=+new Date,r=BigInt(t-1288834974657)<<BigInt(22),i=Math.abs(function(e){var t=0;if(0===e.length)return t;for(var r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return t}(e)),n=Math.floor(9*Math.random()+1);return(r|BigInt(i)|BigInt(n)).toString()}}),n}();I.add("callplus","2.1.10-enterprise-lz.50");var Pe={tag:"RCCallPlus",verify:function(e){return!!I.validEngine("5.8.2")||(console.error("CallPlus depends on the minimum version of Engine '".concat("5.8.2","', and the current version of Engine is '").concat(I.getInfo().engine,"'.")),!1)},setup:function(e,t,i){!function(e){if(!(null==e?void 0:e.rtcClient))throw new Error("Initialization parameter 'rtcClient' is required");if(!(e.rtcClient instanceof O))throw new Error("Initialization parameter 'rtcClient' must be of type 'RCRTCClient'")}(i);var n=e.createLogger("CallPlus","RTC"),a=r(i.logOutputLevel)?g.WARN:i.logOutputLevel;return n.setOutputLevel(a),n.warn(M.L_INDEX_INSTALL_CALL_PLUS_PLUGIN_O,"CallPlus Version: ".concat("2.1.10-enterprise-lz.50",", Commit: ").concat("cac6a95d458985031e56927c1c02868051de9538")),new ye(e,n,i)}};export{F as RCAudioConfigBuilder,ve as RCCallPlusAndroidPushConfigBuilder,V as RCCallPlusCallState,ye as RCCallPlusClient,D as RCCallPlusCode,G as RCCallPlusMediaType,H as RCCallPlusMediaTypeChangeResult,k as RCCallPlusReason,B as RCCallPlusSession,j as RCCallPlusSessionUserState,w as RCCallPlusType,Y as RCVideoConfigBuilder,Pe as installer};
|