@rongcloud/plugin-call 5.2.5 → 5.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +9 -0
- package/dist/index.d.ts +26 -28
- package/dist/index.esm.js +9 -2597
- package/package.json +4 -4
- package/dist/index.umd.js +0 -5
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@rongcloud/engine"),t=require("@rongcloud/plugin-rtc"),r=function(e,t){return r=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])},r(e,t)};var n=function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function o(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{l(n.next(e))}catch(e){i(e)}}function a(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))}function i(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(l){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}}function s(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var a,l,c,u,d=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,n=+e,o=[];do{var i=n%r;n=(n-i)/r,o.unshift(t[i])}while(n);return o.join("")}(e=parseInt(e,16))).length>22&&(e=e.slice(0,22)),e},C=function(){var e=Math.floor(1e3*Math.random()),t=d();return[t=t.replace(/\//g,"0"),Date.now(),e].join("_")},_=new e.EventEmitter,h=function(e){var t="RCCallDeviceId",r=e.sessionStorage.getItem(t);return r||(r=d(),e.sessionStorage.setItem(t,r)),r};!function(e){e[e.OUTGOING=1]="OUTGOING",e[e.INCOMING=2]="INCOMING",e[e.RINGING=3]="RINGING",e[e.CONNECTED=4]="CONNECTED",e[e.IDLE=5]="IDLE",e[e.ACCEPTED=6]="ACCEPTED"}(a||(a={})),exports.RCCallErrorCode=void 0,(l=exports.RCCallErrorCode||(exports.RCCallErrorCode={}))[l.SUCCESS=1e4]="SUCCESS",l[l.STATE_MACHINE_EXIT=53200]="STATE_MACHINE_EXIT",l[l.SEND_MSG_ERROR=53201]="SEND_MSG_ERROR",l[l.REJECTED_BY_BLACKLIST=53202]="REJECTED_BY_BLACKLIST",l[l.NOT_IN_GROUP=53203]="NOT_IN_GROUP",l[l.GET_LOCAL_AUDIO_TRACK_ERROR=53301]="GET_LOCAL_AUDIO_TRACK_ERROR",l[l.GET_LOCAL_VIDEO_TRACK_ERROR=53302]="GET_LOCAL_VIDEO_TRACK_ERROR",l[l.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR=53303]="GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR",l[l.JOIN_ROOM_ERROR=53304]="JOIN_ROOM_ERROR",l[l.AUDIO_PUBLISH_ERROR=53305]="AUDIO_PUBLISH_ERROR",l[l.VIDEO_PUBLISH_ERROR=53306]="VIDEO_PUBLISH_ERROR",l[l.AUDIO_AND_VIDEO_PUBLISH_ERROR=53307]="AUDIO_AND_VIDEO_PUBLISH_ERROR",l[l.QUERY_JOINED_USER_INFO_ERROR=53308]="QUERY_JOINED_USER_INFO_ERROR",l[l.MISSING_VIDEO_TRACK_ERROR=53309]="MISSING_VIDEO_TRACK_ERROR",l[l.UNPUBLISH_VIDEO_ERROR=53310]="UNPUBLISH_VIDEO_ERROR",l[l.CONVERSATION_NOT_GROUP_ERROR=53311]="CONVERSATION_NOT_GROUP_ERROR",l[l.NOT_IN_ROOM_ERROR=53312]="NOT_IN_ROOM_ERROR",l[l.PARAM_ERROR=53313]="PARAM_ERROR",l[l.MISSING_AUDIO_TRACK_ERROR=53314]="MISSING_AUDIO_TRACK_ERROR",exports.RCCallEndReason=void 0,(u=exports.RCCallEndReason||(exports.RCCallEndReason={}))[u.CANCEL=1]="CANCEL",u[u.REJECT=2]="REJECT",u[u.HANGUP=3]="HANGUP",u[u.BUSY_LINE=4]="BUSY_LINE",u[u.NO_RESPONSE=5]="NO_RESPONSE",u[u.ENGINE_UNSUPPORTED=6]="ENGINE_UNSUPPORTED",u[u.NETWORK_ERROR=7]="NETWORK_ERROR",u[u.GET_MEDIA_RESOURCES_ERROR=8]="GET_MEDIA_RESOURCES_ERROR",u[u.PUBLISH_ERROR=9]="PUBLISH_ERROR",u[u.SUBSCRIBE_ERROR=10]="SUBSCRIBE_ERROR",u[u.REMOTE_CANCEL=11]="REMOTE_CANCEL",u[u.REMOTE_REJECT=12]="REMOTE_REJECT",u[u.REMOTE_HANGUP=13]="REMOTE_HANGUP",u[u.REMOTE_BUSY_LINE=14]="REMOTE_BUSY_LINE",u[u.REMOTE_NO_RESPONSE=15]="REMOTE_NO_RESPONSE",u[u.REMOTE_ENGINE_UNSUPPORTED=16]="REMOTE_ENGINE_UNSUPPORTED",u[u.REMOTE_NETWORK_ERROR=17]="REMOTE_NETWORK_ERROR",u[u.REMOTE_GET_MEDIA_RESOURCE_ERROR=18]="REMOTE_GET_MEDIA_RESOURCE_ERROR",u[u.REMOTE_PUBLISH_ERROR=19]="REMOTE_PUBLISH_ERROR",u[u.REMOTE_SUBSCRIBE_ERROR=20]="REMOTE_SUBSCRIBE_ERROR",u[u.OTHER_CLIENT_JOINED_CALL=21]="OTHER_CLIENT_JOINED_CALL",u[u.OTHER_CLIENT_IN_CALL=22]="OTHER_CLIENT_IN_CALL",u[u.KICKED_BY_SERVER=23]="KICKED_BY_SERVER",u[u.ACCEPT_SYSTEM_CALL=24]="ACCEPT_SYSTEM_CALL",u[u.REMOTE_OTHER_CLIENT_JOINED_CALL=31]="REMOTE_OTHER_CLIENT_JOINED_CALL",u[u.REMOTE_OTHER_CLIENT_IN_CALL=32]="REMOTE_OTHER_CLIENT_IN_CALL",u[u.REMOTE_KICKED_BY_SERVER=33]="REMOTE_KICKED_BY_SERVER",u[u.REMOTE_ACCEPT_SYSTEM_CALL=34]="REMOTE_ACCEPT_SYSTEM_CALL",u[u.ACCEPT_BY_OTHER_CLIENT=101]="ACCEPT_BY_OTHER_CLIENT",u[u.HANGUP_BY_OTHER_CLIENT=102]="HANGUP_BY_OTHER_CLIENT",u[u.ADDED_TO_BLACKLIST=103]="ADDED_TO_BLACKLIST",u[u.SERVICE_NOT_OPENED=104]="SERVICE_NOT_OPENED";var p,f,g,R,b=((c={})[exports.RCCallEndReason.CANCEL]=exports.RCCallEndReason.REMOTE_CANCEL,c[exports.RCCallEndReason.REJECT]=exports.RCCallEndReason.REMOTE_REJECT,c[exports.RCCallEndReason.HANGUP]=exports.RCCallEndReason.REMOTE_HANGUP,c[exports.RCCallEndReason.BUSY_LINE]=exports.RCCallEndReason.REMOTE_BUSY_LINE,c[exports.RCCallEndReason.NO_RESPONSE]=exports.RCCallEndReason.REMOTE_NO_RESPONSE,c[exports.RCCallEndReason.ENGINE_UNSUPPORTED]=exports.RCCallEndReason.REMOTE_ENGINE_UNSUPPORTED,c[exports.RCCallEndReason.NETWORK_ERROR]=exports.RCCallEndReason.REMOTE_NETWORK_ERROR,c[exports.RCCallEndReason.GET_MEDIA_RESOURCES_ERROR]=exports.RCCallEndReason.REMOTE_GET_MEDIA_RESOURCE_ERROR,c[exports.RCCallEndReason.PUBLISH_ERROR]=exports.RCCallEndReason.REMOTE_PUBLISH_ERROR,c[exports.RCCallEndReason.SUBSCRIBE_ERROR]=exports.RCCallEndReason.REMOTE_SUBSCRIBE_ERROR,c[exports.RCCallEndReason.OTHER_CLIENT_JOINED_CALL]=exports.RCCallEndReason.REMOTE_OTHER_CLIENT_JOINED_CALL,c[exports.RCCallEndReason.OTHER_CLIENT_IN_CALL]=exports.RCCallEndReason.REMOTE_OTHER_CLIENT_IN_CALL,c[exports.RCCallEndReason.KICKED_BY_SERVER]=exports.RCCallEndReason.REMOTE_KICKED_BY_SERVER,c[exports.RCCallEndReason.REMOTE_NO_RESPONSE]=exports.RCCallEndReason.NO_RESPONSE,c[exports.RCCallEndReason.ACCEPT_SYSTEM_CALL]=exports.RCCallEndReason.REMOTE_ACCEPT_SYSTEM_CALL,c);!function(e){e.VCInvite="RC:VCInvite",e.VCRinging="RC:VCRinging",e.VCAccept="RC:VCAccept",e.VCHangup="RC:VCHangup",e.VCModifyMem="RC:VCModifyMem",e.VCModifyMedia="RC:VCModifyMedia"}(p||(p={})),exports.RCCallSessionState=void 0,(f=exports.RCCallSessionState||(exports.RCCallSessionState={}))[f.WAITING=0]="WAITING",f[f.KEEPING=1]="KEEPING",f[f.END=2]="END",exports.RCCallUserState=void 0,(g=exports.RCCallUserState||(exports.RCCallUserState={}))[g.NONE=0]="NONE",g[g.WAITING=1]="WAITING",g[g.KEEPING=2]="KEEPING",function(e){
|
|
2
|
+
/*!
|
|
3
|
+
同App通话
|
|
4
|
+
*/
|
|
5
|
+
e[e.RCCallRoomTypeNormalCall=0]="RCCallRoomTypeNormalCall",
|
|
6
|
+
/*!
|
|
7
|
+
跨App通话
|
|
8
|
+
*/
|
|
9
|
+
e[e.RCCallRoomTypeAcrossCall=7]="RCCallRoomTypeAcrossCall"}(R||(R={}));var E,I,y,m=function(){function e(e,t){Object.defineProperty(this,"_timerId",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_startTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),e&&(this._timerId=function(e,t){return setTimeout(e,t)}((function(){e()}),t)),this._startTime=Date.now()}return Object.defineProperty(e.prototype,"stop",{enumerable:!1,configurable:!0,writable:!0,value:function(){clearTimeout(this._timerId);var e=Date.now(),t=e-this._startTime;return 0===this._startTime&&(t=0),{startTime:this._startTime,endTime:e,duration:t}}}),Object.defineProperty(e.prototype,"reset",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._startTime=0}}),e}(),v=function(){function t(e,t,r,n,o,i,s,a,l){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_callMsgHandler",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_channelId",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_conversationType",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_targetId",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_mediaType",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:l}),Object.defineProperty(this,"_sessionState",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_userInfo",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_userTimers",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_watchers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_callTimeout",{enumerable:!0,configurable:!0,writable:!0,value:6e4}),Object.defineProperty(this,"_beginTimestamp",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_endTimestamp",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_endReason",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_callerId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_inviterId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_isCrossAppkey",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_hungupPushConfig",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._callMsgHandler.registerStateMachineEvent(this._callId,"onRinging",this._onRinging.bind(this)),this._callMsgHandler.registerStateMachineEvent(this._callId,"onAccept",this._onAccept.bind(this)),this._callMsgHandler.registerStateMachineEvent(this._callId,"onMediaModify",this._onMediaModify.bind(this)),this._callMsgHandler.registerStateMachineEvent(this._callId,"onHungup",this._onHungup.bind(this))}return Object.defineProperty(t.prototype,"_getTimeout",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._context.getServerTime()-e;t<0&&(t=500);var r=this._callTimeout-t;return this._logger.warn("_","_getTimeout -> timeout: ".concat(r)),r}}),Object.defineProperty(t.prototype,"_clearTimerById",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.debug("_","[RCCallStateMachine] before _clearTimerById -> userId: ".concat(e," userTimers: ").concat(JSON.stringify(this._userTimers))),this._userTimers[e]&&(this._userTimers[e].stop(),delete this._userTimers[e]),this._logger.debug("_","[RCCallStateMachine] after _clearTimerById -> userTimers: ".concat(JSON.stringify(this._userTimers)))}}),Object.defineProperty(t.prototype,"_notifyStateChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;this._logger.warn("_","[RCCallStateMachine] notifyStateChange -> info: ".concat(JSON.stringify({state:e,reason:t}))),this._endReason=t||null,this._sessionState!==e&&(this._sessionState=e,null===(r=this._watchers)||void 0===r||r.onStateChange({state:e,reason:t})),e===exports.RCCallSessionState.END&&(_.emit("onStateMachineClose",this._callId),this._callMsgHandler.unregisterStateMachineEvent(this._callId))}}),Object.defineProperty(t.prototype,"_notifyUserStateChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;this._logger.warn("_","[RCCallStateMachine] notifyUserStateChange -> info: ".concat(JSON.stringify({user:e,reason:t}))),null===(r=this._watchers)||void 0===r||r.onUserStateChange({user:e,reason:t})}}),Object.defineProperty(t.prototype,"_otherClientHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,r=e.content,n=r.user,o=r.reason,i=e.messageType;for(var s in this._userInfo[t]={userId:t,state:exports.RCCallUserState.NONE,isCaller:!1,isRemote:!1},this._userTimers)this._clearTimerById(s);var a=exports.RCCallEndReason.ACCEPT_BY_OTHER_CLIENT;i===p.VCHangup&&(a=o===exports.RCCallEndReason.BUSY_LINE?exports.RCCallEndReason.OTHER_CLIENT_IN_CALL:o===exports.RCCallEndReason.NO_RESPONSE?exports.RCCallEndReason.NO_RESPONSE:exports.RCCallEndReason.HANGUP_BY_OTHER_CLIENT),Object.assign(this._userInfo[t],n),this._notifyUserStateChange(this._userInfo[t],a),this._notifyStateChange(exports.RCCallSessionState.END,a)}}),Object.defineProperty(t.prototype,"_isRemoteInvalidMsg",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!!this._userInfo[e]&&(!(!this._userInfo[e].deviceId||!t)&&(this._userInfo[e].state===exports.RCCallUserState.KEEPING&&this._userInfo[e].deviceId!==t))}}),Object.defineProperty(t.prototype,"_onRinging",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,r=e.content,o=r.user,i=r.deviceId,s=this._isCrossAppkey?t.split("_")[1]:t;this._isRemoteInvalidMsg(s,i)?this._logger.debug("_","[RCCallStateMachine] onRinging -> not the remote device that is currently talking"):this._context.getCurrentId()!==s&&this._watchers.onRinging(n({userId:s},o))}}),Object.defineProperty(t.prototype,"_onAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=this,n=t.senderUserId,o=t.content,i=o.user,s=o.deviceId;t.sentTime;var a=this._isCrossAppkey?n.split("_")[1]:n,l=this._context.getCurrentId();this._isRemoteInvalidMsg(a,s)?this._logger.debug("_","[RCCallStateMachine] _onAccept -> not the remote device that is currently talking"):l!==a?(this._userTimers[a]&&this._clearTimerById(a),(this._conversationType===e.ConversationType.PRIVATE?[l,a]:[a]).forEach((function(e){var t=e===l;r._userInfo[e]={userId:e,state:exports.RCCallUserState.KEEPING,isCaller:t,isRemote:t,deviceId:t?h(r._runtime):s},t||(r._beginTimestamp=Date.now(),Object.assign(r._userInfo[a],i)),r._notifyUserStateChange(r._userInfo[e])})),this.getCallerId()===l&&this._notifyStateChange(exports.RCCallSessionState.KEEPING),this._watchers.onAccept({userId:a})):this._otherClientHandle(t)}}),Object.defineProperty(t.prototype,"_onMediaModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,r=e.content,o=r.mediaType,i=r.user,s=r.deviceId;this._isRemoteInvalidMsg(t,s)?this._logger.debug("_","[RCCallStateMachine] _onMediaModify -> not the remote device that is currently talking"):this._context.getCurrentId()!==t&&(this._mediaType=o,this._watchers.onMediaModify({sender:n({userId:t},i),mediaType:o}))}}),Object.defineProperty(t.prototype,"_onHungup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,r=e.content,o=this._isCrossAppkey?t.split("_")[1]:t,i=r,s=i.reason,a=i.user,l=i.deviceId,c=this._context.getCurrentId();if(this._isRemoteInvalidMsg(o,l))this._logger.debug("_","[RCCallStateMachine] _onHungup -> not the remote device that is currently talking");else if(c!==o)if(this._sessionState!==exports.RCCallSessionState.END){this._userInfo[o]&&(this._userInfo[o].state=exports.RCCallUserState.NONE,this._endTimestamp=Date.now(),Object.assign(this._userInfo[o],a),this._notifyUserStateChange(this._userInfo[o],b[s]),delete this._userInfo[o]),b[s]===exports.RCCallEndReason.REMOTE_CANCEL?this.getRemoteUserIds().length<1&&this._clearTimerById(c):this.getInviterId()===c?this._clearTimerById(o):this.getRemoteUserIds().length<1&&this._clearTimerById(c);var u=Object.keys(this._userInfo).length<2,d=this._inviterId===o,C=Object.values(this._userInfo).every((function(e){return e.state!==exports.RCCallUserState.KEEPING}));(u||d&&C)&&this._notifyStateChange(exports.RCCallSessionState.END,b[s]),this._watchers.onHungup(n({userId:o},a),b[s])}else this._logger.info("_","[RCCallStateMachine] Invalid hang up message, current room status has ended -> sessionState: ".concat(this._sessionState));else this._otherClientHandle(e)}}),Object.defineProperty(t.prototype,"registerEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._watchers=e}}),Object.defineProperty(t.prototype,"__onInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r,n=this,o=e.senderUserId,i=e.content,a=e.sentTime,l=i,c=l.inviteUserIds,u=l.user,d=l.deviceId;l.roomType===R.RCCallRoomTypeAcrossCall?(t=o.split("_"),r=t[1],this._watchers.crossAppkey(!0),this._isCrossAppkey=!0):r=o;var C=this._context.getCurrentId();if(this._isRemoteInvalidMsg(r,d))this._logger.debug("_","[RCCallStateMachine] __onInvite -> not the remote device that is currently talking");else if(C!==r){this._callerId=this._inviterId=r;var _=s([o],c,!0);this._callMsgHandler.sendRinging({conversationType:this._conversationType,targetId:this._targetId,channelId:this._channelId,callId:this._callId,userIds:_.filter((function(e){return n._isCrossAppkey?e.split("_")[1]!==C:e!==C}))});var h=this._isCrossAppkey?[c[0].split("_")[1]]:c;s([r],h,!0).forEach((function(e){n._userInfo[e]={userId:e,state:exports.RCCallUserState.WAITING,isCaller:e===r,isRemote:e!==C},e===r&&Object.assign(n._userInfo[e],u,{deviceId:d}),n._notifyUserStateChange(n._userInfo[e]),e!==r&&(n._userTimers[e]=new m((function(){var t=e===C?exports.RCCallEndReason.NO_RESPONSE:exports.RCCallEndReason.REMOTE_NO_RESPONSE;e===C?n._hungupHandle(t,!1):(n._userInfo[e]&&(n._userInfo[e].state=exports.RCCallUserState.NONE),n._notifyUserStateChange(n._userInfo[e]),n._watchers.onHungup(n._userInfo[e],t),delete n._userInfo[e]),n._clearTimerById(e)}),n._getTimeout(a)))})),this._notifyStateChange(exports.RCCallSessionState.WAITING)}}}),Object.defineProperty(t.prototype,"__onMemberModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,r=e.senderUserId,o=e.content,i=e.sentTime,s=o,l=s.user,c=s.existedUserPofiles,u=s.caller,d=s.deviceId,C=s.inviteUserIds,_=s.mediaType,h=this._context.getCurrentId();if(this._isRemoteInvalidMsg(r,d))this._logger.debug("_","[RCCallStateMachine] __onMemberModify -> not the remote device that is currently talking");else if(h!==r){if(this._callerId=u,this._inviterId=r,C.forEach((function(e){c.push({userId:e,mediaType:_,callStatus:a.INCOMING})})),C.includes(h)){var p=[];c.forEach((function(e){e.userId!==h&&p.push(e.userId)})),this._callMsgHandler.sendRinging({conversationType:this._conversationType,targetId:this._targetId,channelId:this._channelId,callId:this._callId,userIds:p}),this._notifyStateChange(exports.RCCallSessionState.WAITING)}else this._watchers.onMemberModify({sender:n({userId:r},l),invitedUsers:C.map((function(e){return{userId:e}}))});c.forEach((function(e){var n=e.userId,o=e.callStatus;if(o!==a.IDLE&&(t._userInfo[n]={userId:n,state:o!==a.CONNECTED?exports.RCCallUserState.WAITING:exports.RCCallUserState.KEEPING,isCaller:r===n,isRemote:h!==n},n===r&&Object.assign(t._userInfo[n],l,{deviceId:d}),t._notifyUserStateChange(t._userInfo[n]),o!==a.CONNECTED&&!t._userTimers[n])){if(!C.includes(n))return;t._userTimers[n]=new m((function(){t._userInfo[n]&&(t._userInfo[n].state=exports.RCCallUserState.NONE);var e=n===h?exports.RCCallEndReason.NO_RESPONSE:exports.RCCallEndReason.REMOTE_NO_RESPONSE;t._notifyUserStateChange(t._userInfo[n],e);try{t._watchers.onHungup(t._userInfo[n],e)}catch(e){t._logger.error("_","[RCCallStateMachine] call onhungup error -> ".concat(null==e?void 0:e.stack))}delete t._userInfo[n],(Object.keys(t._userInfo).length<2||n===h)&&t._notifyStateChange(exports.RCCallSessionState.END,e),t._clearTimerById(n)}),t._getTimeout(i))}}))}}}),Object.defineProperty(t.prototype,"__handleInviteInSession",{enumerable:!1,configurable:!0,writable:!0,value:function(){for(var e in this._logger.info("_","StateMachine -> __handleInviteInSession"),this._userInfo)this._userInfo[e].state&&(this._userInfo[e].state=exports.RCCallUserState.NONE),this._notifyUserStateChange(this._userInfo[e]),this._clearTimerById(e);this._notifyStateChange(exports.RCCallSessionState.END,exports.RCCallEndReason.BUSY_LINE),this._callMsgHandler.sendHungup({channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,reason:exports.RCCallEndReason.BUSY_LINE,userIds:this.getRemoteUserIds()})}}),Object.defineProperty(t.prototype,"__call",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return void 0===t&&(t=""),void 0===n&&(n=!1),o(this,void 0,void 0,(function(){var o,a,l,c,u,d,C=this;return i(this,(function(i){switch(i.label){case 0:return this._logger.debug("_","[RCCallStateMachine] invite -> userIds: ".concat(JSON.stringify(e))),o=this._callerId=this._inviterId=this._context.getCurrentId(),[4,this._callMsgHandler.sendInvite({roomType:n?R.RCCallRoomTypeAcrossCall:R.RCCallRoomTypeNormalCall,channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,extra:t,pushConfig:r,mediaType:this._mediaType,inviteUserIds:e.filter((function(e){return e!==o}))})];case 1:return a=i.sent(),l=a.code,c=a.message,this._isCrossAppkey=n,l===exports.RCCallErrorCode.SUCCESS?(u=c.sentTime,(n?s([o],[e[0].split("_")[1]],!1):s([o],e,!0)).forEach((function(e){var t=e===o;C._userInfo[e]={userId:e,state:exports.RCCallUserState.WAITING,isCaller:t,isRemote:!t},C._notifyUserStateChange(C._userInfo[e]),t||(C._userTimers[e]=new m((function(){C._userInfo[e]&&(C._userInfo[e].state=exports.RCCallUserState.NONE),C._notifyUserStateChange(C._userInfo[e],exports.RCCallEndReason.REMOTE_NO_RESPONSE),C._watchers.onHungup(C._userInfo[e],exports.RCCallEndReason.REMOTE_NO_RESPONSE),delete C._userInfo[e],Object.keys(C._userInfo).length<2&&C._notifyStateChange(exports.RCCallSessionState.END,exports.RCCallEndReason.REMOTE_NO_RESPONSE),0===C.getRemoteUserIds().length&&C._userInfo[o].state!==exports.RCCallUserState.KEEPING&&C._hungupHandle(exports.RCCallEndReason.REMOTE_NO_RESPONSE)}),C._getTimeout(u)))})),this._notifyStateChange(exports.RCCallSessionState.WAITING)):(d=l===exports.RCCallErrorCode.REJECTED_BY_BLACKLIST?exports.RCCallEndReason.ADDED_TO_BLACKLIST:exports.RCCallEndReason.NETWORK_ERROR,this._notifyStateChange(exports.RCCallSessionState.END,d)),[2,{code:l}]}}))}))}}),Object.defineProperty(t.prototype,"accept",{enumerable:!1,configurable:!0,writable:!0,value:function(){return o(this,void 0,void 0,(function(){var e,t,r,n,o;return i(this,(function(i){switch(i.label){case 0:return this._logger.debug("_","[RCCallStateMachine] accept"),e=this._context.getCurrentId(),[4,this._callMsgHandler.sendAccept({channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,mediaType:this._mediaType,userIds:this.getRemoteUserIds()})];case 1:return t=i.sent(),r=t.code,n=t.message,this._clearTimerById(e),r===exports.RCCallErrorCode.SUCCESS?(n.sentTime,this._userInfo[e]&&(this._userInfo[e].state=exports.RCCallUserState.KEEPING),this._beginTimestamp=Date.now(),this._notifyUserStateChange(this._userInfo[e]),this._notifyStateChange(exports.RCCallSessionState.KEEPING)):(this._userInfo[e]&&(this._userInfo[e].state=exports.RCCallUserState.NONE),this._notifyUserStateChange(this._userInfo[e]),o=r===exports.RCCallErrorCode.REJECTED_BY_BLACKLIST?exports.RCCallEndReason.ADDED_TO_BLACKLIST:exports.RCCallEndReason.NETWORK_ERROR,this._notifyStateChange(exports.RCCallSessionState.END,o)),[2,{code:r}]}}))}))}}),Object.defineProperty(t.prototype,"invite",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return void 0===r&&(r={}),o(this,void 0,void 0,(function(){var n,o,l,c,u,d,C,_,h,p,f=this;return i(this,(function(i){switch(i.label){case 0:return this._conversationType!==e.ConversationType.GROUP?[2,{code:exports.RCCallErrorCode.CONVERSATION_NOT_GROUP_ERROR}]:(this._logger.debug("_","[RCCallStateMachine] invite -> userIds: ".concat(JSON.stringify(t))),n=this._context.getCurrentId(),o=Object.keys(this._userInfo),l=o.map((function(e){var r=a.CONNECTED;return(t.includes(e)||f._userInfo[e].state===exports.RCCallUserState.WAITING)&&(r=a.RINGING),{userId:e,mediaType:f._mediaType,callStatus:r,mediaId:e}})),c=r.extra,u=void 0===c?"":c,d=r.pushConfig,[4,this._callMsgHandler.sendMemeberModify({channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,extra:u,pushConfig:d,mediaType:this._mediaType,inviteUserIds:t.filter((function(e){return e!==n})),callerId:this.getCallerId(),existedUserPofiles:l,directionalUserIdList:s(s([],o,!0),t,!0).filter((function(e){return e!==n}))})]);case 1:return C=i.sent(),_=C.code,h=C.message,_===exports.RCCallErrorCode.SUCCESS?(p=h.sentTime,t.forEach((function(e){f._userInfo[e]={userId:e,state:exports.RCCallUserState.WAITING,isCaller:!1,isRemote:!0},f._notifyUserStateChange(f._userInfo[e]),f._userTimers[e]=new m((function(){f._userInfo[e]&&(f._userInfo[e].state=exports.RCCallUserState.NONE),f._notifyUserStateChange(f._userInfo[e],exports.RCCallEndReason.REMOTE_NO_RESPONSE),f._watchers.onHungup(f._userInfo[e],exports.RCCallEndReason.REMOTE_NO_RESPONSE),delete f._userInfo[e],Object.keys(f._userInfo).length<2&&f._notifyStateChange(exports.RCCallSessionState.END,exports.RCCallEndReason.REMOTE_NO_RESPONSE)}),f._getTimeout(p))}))):t.forEach((function(e){f._userInfo[e]={userId:e,state:exports.RCCallUserState.NONE,isCaller:!1,isRemote:!0};var t=_===exports.RCCallErrorCode.REJECTED_BY_BLACKLIST?exports.RCCallEndReason.ADDED_TO_BLACKLIST:exports.RCCallEndReason.NETWORK_ERROR;f._notifyUserStateChange(f._userInfo[e],t)})),[2,{code:_}]}}))}))}}),Object.defineProperty(t.prototype,"_hungupHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===t&&(t=!0),o(this,void 0,void 0,(function(){var r,n,o,s,a;return i(this,(function(i){switch(i.label){case 0:return r=this._context.getCurrentId(),n=exports.RCCallErrorCode.SUCCESS,t?(o={channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,reason:e,userIds:this.getRemoteUserIds(),pushConfig:this._hungupPushConfig},e!==exports.RCCallEndReason.OTHER_CLIENT_JOINED_CALL?[3,1]:(this._callMsgHandler.sendHungup(o),[3,3])):[3,3];case 1:return[4,this._callMsgHandler.sendHungup(o)];case 2:s=i.sent().code,n=s,i.label=3;case 3:for(a in this._endTimestamp=Date.now(),this._userInfo)this._userInfo[a].state=exports.RCCallUserState.NONE,a===r?this._notifyUserStateChange(this._userInfo[a],e):this._notifyUserStateChange(this._userInfo[a]),delete this._userInfo[a];return Object.keys(this._userInfo).length<2&&this._notifyStateChange(exports.RCCallSessionState.END,e),[2,{code:n}]}}))}))}}),Object.defineProperty(t.prototype,"hungup",{enumerable:!1,configurable:!0,writable:!0,value:function(){return o(this,void 0,void 0,(function(){var e,t,r;return i(this,(function(n){for(r in this._logger.debug("_","[RCCallStateMachine] hungup"),e=this._context.getCurrentId(),t=exports.RCCallEndReason.HANGUP,Object.keys(this._userTimers).length>0&&(this._userInfo[e].isCaller?t=exports.RCCallEndReason.CANCEL:this._userInfo[e].state===exports.RCCallUserState.WAITING&&(t=exports.RCCallEndReason.REJECT)),this._userTimers)this._clearTimerById(r);return[2,this._hungupHandle(t)]}))}))}}),Object.defineProperty(t.prototype,"changeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(r){switch(r.label){case 0:return this._logger.debug("_","[RCCallStateMachine] changeMediaType -> mediaType: ".concat(e)),[4,this._callMsgHandler.sendMediaModify({channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,mediaType:e,userIds:this.getRemoteUserIds()})];case 1:return(t=r.sent().code)===exports.RCCallErrorCode.SUCCESS&&(this._mediaType=e),[2,{code:t}]}}))}))}}),Object.defineProperty(t.prototype,"userJoin",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;this._logger.debug("_","[RCCallStateMachine] userJoin -> userIds: ".concat(JSON.stringify(e))),setTimeout((function(){e.forEach((function(e){var r=t._userInfo[e];r&&r.state!==exports.RCCallUserState.KEEPING&&(r.state=exports.RCCallUserState.KEEPING,t._notifyUserStateChange(r)),t._sessionState!==exports.RCCallSessionState.KEEPING&&t._notifyStateChange(exports.RCCallSessionState.KEEPING),t._clearTimerById(e)}))}),300)}}),Object.defineProperty(t.prototype,"userLeave",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;this._logger.debug("_","[RCCallStateMachine] userLeave -> userIds: ".concat(JSON.stringify(e))),setTimeout((function(){e.forEach((function(e){var r=t._userInfo[e];r&&r.state!==exports.RCCallUserState.NONE&&(r.state=exports.RCCallUserState.NONE,t._notifyUserStateChange(r,exports.RCCallEndReason.REMOTE_HANGUP),t._watchers.onHungup(r,exports.RCCallEndReason.REMOTE_HANGUP),delete t._userInfo[e]),new m((function(){var e=t.getRemoteUsers();1===e.length&&1===e[0].state&&t._hungupHandle(exports.RCCallEndReason.REMOTE_NETWORK_ERROR)}),6e4),Object.keys(t._userInfo).length<2&&t._sessionState!==exports.RCCallSessionState.END&&(t._endTimestamp=Date.now(),t._notifyStateChange(exports.RCCallSessionState.END,exports.RCCallEndReason.REMOTE_HANGUP))}))}),300)}}),Object.defineProperty(t.prototype,"close",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._hungupHandle(e)}}),Object.defineProperty(t.prototype,"setHungupPushConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._hungupPushConfig=e}}),Object.defineProperty(t.prototype,"getCallId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callId}}),Object.defineProperty(t.prototype,"getChannelId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._channelId}}),Object.defineProperty(t.prototype,"getTargetId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._targetId}}),Object.defineProperty(t.prototype,"getConversationType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._conversationType}}),Object.defineProperty(t.prototype,"getRemoteUserIds",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;return Object.keys(this._userInfo).filter((function(t){return e._context.getCurrentId()!==t}))}}),Object.defineProperty(t.prototype,"getRemoteUsers",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=[],t=this._context.getCurrentId();for(var r in this._userInfo){this._userInfo[r].userId!==t&&e.push(this._userInfo[r])}return e}}),Object.defineProperty(t.prototype,"getState",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null===this._sessionState?exports.RCCallSessionState.END:this._sessionState}}),Object.defineProperty(t.prototype,"getUserState",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;return null===(t=this._userInfo[e])||void 0===t?void 0:t.state}}),Object.defineProperty(t.prototype,"getCallerId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callerId}}),Object.defineProperty(t.prototype,"getInviterId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._inviterId}}),Object.defineProperty(t.prototype,"getMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._mediaType}}),Object.defineProperty(t.prototype,"getSummary",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._beginTimestamp,t=this._endTimestamp,r=0;t>e&&0!==e&&(r=t-e);var n={conversationType:this._conversationType,channelId:this._channelId,targetId:this._targetId,mediaType:this._mediaType,beginTimestamp:e,endTimestamp:t,duration:r,endReason:this._endReason};return this._logger.debug("_","[RCCallStateMachine] getSummary -> summary: ".concat(JSON.stringify(n))),n}}),t}();exports.RCCallMediaType=void 0,(E=exports.RCCallMediaType||(exports.RCCallMediaType={}))[E.AUDIO=1]="AUDIO",E[E.AUDIO_VIDEO=2]="AUDIO_VIDEO",function(e){e[e.ADD=1]="ADD",e[e.REMOVE=2]="REMOVE"}(I||(I={})),function(e){e.WEB="Web",e.IOS="iOS",e.ANDROID="Android"}(y||(y={}));var O,T,S=function(){function e(e,t,r){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_onRecord",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_messages",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_channelId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_conversationType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_targetId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_mediaType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_callerId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_inviterId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_endReason",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_beginTimestamp",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_endTimestamp",{enumerable:!0,configurable:!0,writable:!0,value:0})}return Object.defineProperty(e.prototype,"_doInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._context.getCurrentId();var t=e.channelId,r=e.conversationType,n=e.targetId,o=e.senderUserId,i=e.content,s=i.callId,a=i.mediaType;this._channelId=t,this._conversationType=r,this._targetId=n,this._callId=s,this._mediaType=a;this._inviterId=o,this._endReason=exports.RCCallEndReason.REMOTE_NO_RESPONSE,this._canGenRecord()}}),Object.defineProperty(e.prototype,"_doMemberModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._doInvite(e)}}),Object.defineProperty(e.prototype,"_doRinging",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._canGenRecord()}}),Object.defineProperty(e.prototype,"_doAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._endReason=exports.RCCallEndReason.HANGUP,this._beginTimestamp=e.sentTime,this._canGenRecord()}}),Object.defineProperty(e.prototype,"_doHungup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.content,r=e.sentTime,n=e.senderUserId,o=t.reason,i=n===this._context.getCurrentId();this._endReason=i?o:b[o],this._endTimestamp=r,this._canGenRecord()}}),Object.defineProperty(e.prototype,"_doMediaModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.content.mediaType;this._mediaType=t,this._canGenRecord()}}),Object.defineProperty(e.prototype,"_canGenRecord",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(0===this._messages.length){var e=0;[exports.RCCallEndReason.HANGUP,exports.RCCallEndReason.REMOTE_HANGUP,exports.RCCallEndReason.OTHER_CLIENT_JOINED_CALL,exports.RCCallEndReason.REMOTE_OTHER_CLIENT_JOINED_CALL,exports.RCCallEndReason.KICKED_BY_SERVER,exports.RCCallEndReason.REMOTE_KICKED_BY_SERVER,exports.RCCallEndReason.ACCEPT_SYSTEM_CALL,exports.RCCallEndReason.REMOTE_ACCEPT_SYSTEM_CALL].includes(this._endReason)&&(e=this._endTimestamp-this._beginTimestamp),this._onRecord({channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,inviterId:this._inviterId,mediaType:this._mediaType,endReason:this._endReason,beginTimestamp:this._beginTimestamp,endTimestamp:this._endTimestamp,duration:e})}}}),Object.defineProperty(e.prototype,"onRecvOfflineMsgs",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._messages=e;do{var t=this._messages.shift(),r=t.messageType;switch(t.content.callId,r){case p.VCInvite:this._doInvite(t);break;case p.VCRinging:this._doRinging(t);break;case p.VCAccept:this._doAccept(t);break;case p.VCModifyMem:this._doMemberModify(t);break;case p.VCModifyMedia:this._doMediaModify(t);break;case p.VCHangup:this._doHungup(t);break;default:this._logger.debug("_","[OfflineRecorder] onRecvOfflineMsgs -> unexpected message: ".concat(JSON.stringify(t)))}}while(this._messages.length>0)}}),e}(),M=["RC:VCAccept","RC:VCRinging","RC:VCSummary","RC:VCHangup","RC:VCInvite","RC:VCModifyMedia","RC:VCModifyMem"],x=((O={})[e.ErrorCode.REJECTED_BY_BLACKLIST]=exports.RCCallErrorCode.REJECTED_BY_BLACKLIST,O[e.ErrorCode.NOT_IN_GROUP]=exports.RCCallErrorCode.NOT_IN_GROUP,O),P=function(t){function n(e,r,n,o,i){void 0===o&&(o=6e4);var s=t.call(this)||this;return Object.defineProperty(s,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(s,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(s,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(s,"_offlineMsgItv",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(s,"_getStateMachine",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(s,"_watchers",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(s,"_userInfo",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(s,"_msgBufferList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(s,"_hadHandleMsgTimer",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(s,"_offlineRecorder",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(s,"_deviceId",{enumerable:!0,configurable:!0,writable:!0,value:""}),s._deviceId=h(r),s._context.onmessage=s._onMessage.bind(s),s._offlineRecorder=new S(s._context,s._logger,(function(e){s._logger.info("_","[CallMessageHandler] offlineRecorder -> ".concat(JSON.stringify(e))),s._watchers.onOfflineRecord&&s._watchers.onOfflineRecord(e)})),s}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(n,t),Object.defineProperty(n.prototype,"_onMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(M.includes(e.messageType)){this._logger.debug("_","[CallMessageHandler] _onMessage -> call message: ".concat(JSON.stringify(e)));try{var t=Date.now(),r=e.sentTime,n=0;this._msgBufferList.forEach((function(e,t){var o=e.msg.sentTime;r>=o&&(n=t+1)})),this._msgBufferList.splice(n,0,{markTime:t,msg:e}),this._logger.warn("_","onMessage -> msgBufferList: ".concat(this._msgBufferList.length))}catch(e){this._logger.error("_","[CallMessageHandler] splice buffer msg error -> ".concat(e.message))}return this._handleBufferMsgs(),!0}return!1}}),Object.defineProperty(n.prototype,"_onRecvOnlineCallMsg",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info("_","onMessage -> _onRecvOnlineCallMsg: ".concat(e.messageType));var r=e.content.callId;switch(e.messageType){case p.VCInvite:this._watchers.onInvite&&this._watchers.onInvite(e);break;case p.VCRinging:t.prototype.emit.call(this,"".concat(r,"onRinging"),e);break;case p.VCAccept:t.prototype.emit.call(this,"".concat(r,"onAccept"),e);break;case p.VCModifyMem:this._watchers.onInvite&&this._watchers.onInvite(e);break;case p.VCModifyMedia:t.prototype.emit.call(this,"".concat(r,"onMediaModify"),e);break;case p.VCHangup:t.prototype.emit.call(this,"".concat(r,"onHungup"),e);break;default:this._logger.warn("_","[CallMessageHandler] onRecvOnlineCallMsg -> unexpected message: ".concat(JSON.stringify(e)))}}}),Object.defineProperty(n.prototype,"_handleBufferMsgs",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=this;0===this._msgBufferList.length||this._hadHandleMsgTimer?this._logger.warn("_","_handleBufferMsgs return"):(this._hadHandleMsgTimer=!0,setTimeout((function(){var r=Date.now(),n=t._msgBufferList.filter((function(e){return r-e.markTime>=200}));if(t._logger.debug("_","[CallMessageHandler] handleBufferMsgs -> lists over 200ms : ".concat(JSON.stringify(n.map((function(e){var t=e.msg;return{messageUId:t.messageUId,isOffLineMessage:t.isOffLineMessage,callId:t.content.callId}}))))),0===n.length)return t._hadHandleMsgTimer=!1,void t._handleBufferMsgs();if(n[0].msg.isOffLineMessage){var o=t._msgBufferList.filter((function(e){return e.msg.isOffLineMessage})),i=function(){var r=o[0].msg,n=r.conversationType,i=r.messageType,a=r.sentTime,l=r.senderUserId,c=r.content,u=c.callId,d=c.inviteUserIds,C=[p.VCInvite,p.VCModifyMem].includes(i),_=t._context.getServerTime()-a,h=_<t._offlineMsgItv;if(h||t._logger.warn("_","offline msg delayTime: ".concat(_,"ms")),C){for(var f=[],g=0;g<o.length;g++){var R=o[g].msg;if(u!==R.content.callId)break;f.push(R)}if(t._logger.warn("_","taskMsgList length: ".concat(f.length)),f.length>0){var b=t._msgBufferList.findIndex((function(e){return e.msg.messageUId===f[f.length-1].messageUId}));t._msgBufferList=t._msgBufferList.slice(b+1);var E=o.findIndex((function(e){return e.msg.messageUId===f[f.length-1].messageUId}));o=o.slice(E+1)}var I=function(){if(n!==e.ConversationType.PRIVATE)return!1;var t=1===f.length,r=f.every((function(e){return[p.VCInvite,p.VCModifyMedia,p.VCRinging].includes(e.messageType)}));return t||r}(),y=function(){if(n!==e.ConversationType.GROUP)return!1;for(var r=!1,o=!0,i=s([l],d,!0),a=!1,c=function(e){var r=f[e],n=r.senderUserId,s=r.messageType;if(s===p.VCHangup&&n===t._context.getCurrentId())return"break";s===p.VCHangup&&(a=l===n,i=i.filter((function(e){return n!==e}))),s===p.VCAccept&&(o=!1)},u=0;u<f.length;u++){if("break"===c(u))break}return o&&a||!(i.length>1)||(r=!0),r}();h&&(I||y)&&f.forEach(t._onRecvOnlineCallMsg,t),t._offlineRecorder.onRecvOfflineMsgs(f)}else h&&t._getStateMachine(u)?t._onRecvOnlineCallMsg(o[0].msg):t._logger.debug("_","[CallMessageHandler] unexcepted offline msg -> ".concat(JSON.stringify(o[0].msg))),o.shift(),t._msgBufferList.shift()};do{i()}while(o.length>0)}else{n.forEach((function(e){var r=e.msg;t._onRecvOnlineCallMsg(r)}));var a=n.length;t._msgBufferList.splice(0,a),t._logger.debug("_","timer online msg handle -> delCount: ".concat(a," msgBufferList: ").concat(t._msgBufferList.length))}t._hadHandleMsgTimer=!1,t._handleBufferMsgs()}),20))}}),Object.defineProperty(n.prototype,"registerEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){Object.assign(this._watchers,e)}}),Object.defineProperty(n.prototype,"registerStateMachineEvent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,n){var o=e+r;t.prototype.on.call(this,o,n)}}),Object.defineProperty(n.prototype,"unregisterStateMachineEvent",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=this;["onRinging","onAccept","onHungup","onMediaModify"].forEach((function(n){var o=e+n;t.prototype.removeAll.call(r,o)}))}}),Object.defineProperty(n.prototype,"registerUserInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._userInfo=e}}),Object.defineProperty(n.prototype,"_sendCallMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return o(this,void 0,void 0,(function(){var r,n,o,s,a,l,c,u,d,C,_,h;return i(this,(function(i){switch(i.label){case 0:return this._logger.debug("_","CallMessageHandler] sendCallMesage -> message: ".concat(JSON.stringify(t))),r=t.channelId,n=t.conversationType,o=t.targetId,s=t.content,a=t.messageType,l=t.directionalUserIdList,c=t.pushConfig,u={channelId:r,messageType:a,content:s,directionalUserIdList:l},[p.VCInvite,p.VCModifyMem,p.VCHangup].includes(a)&&((d=c||{pushTitle:"",pushContent:"",pushData:""}).androidConfig=Object.assign((null==c?void 0:c.androidConfig)||{},{categoryHW:"VOIP",categoryVivo:"IM"}),d.iOSConfig=Object.assign(d.iOSConfig||{},{apnsCollapseId:s.callId}),d.disablePushTitle=!1,d.forceShowDetailContent=!1,u.pushConfig=d),[4,this._context.sendMessage(n,o,u)];case 1:return C=i.sent(),_=C.code,h=C.data,_!==e.ErrorCode.SUCCESS?(this._logger.error("_","CallMessageHandler] sendCallMesage error -> code: ".concat(_)),[2,{code:x[_]||exports.RCCallErrorCode.SEND_MSG_ERROR}]):[2,{code:exports.RCCallErrorCode.SUCCESS,message:h}]}}))}))}}),Object.defineProperty(n.prototype,"sendInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return o(this,void 0,void 0,(function(){var r,n,o,s,a,l,c,u,d,C;return i(this,(function(i){return r=t.roomType,n=t.channelId,o=t.conversationType,s=t.targetId,a=t.callId,l=t.mediaType,c=t.inviteUserIds,u=t.extra,d=t.pushConfig,this._logger.warn("_","CallMessageHandler] sendCallMesage sendInvite",JSON.stringify(t)),this._watchers.sendAccept&&this._watchers.sendAccept({callId:a}),C={platform:y.WEB,deviceId:this._deviceId,callId:a,roomType:r,extra:u,engineType:4,channelInfo:{Id:a,Key:""},mediaType:l,inviteUserIds:c,observerUserIds:[],user:this._userInfo},d&&(d.pushData=JSON.stringify({mediaType:l,userIdList:c,callId:a})),[2,this._sendCallMessage({channelId:n,conversationType:o,targetId:s,content:C,messageType:p.VCInvite,directionalUserIdList:o===e.ConversationType.GROUP?c:void 0,pushConfig:d})]}))}))}}),Object.defineProperty(n.prototype,"sendMemeberModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return o(this,void 0,void 0,(function(){var t,r,n,o,s,a,l,c,u,d,C,_;return i(this,(function(i){return t=e.channelId,r=e.conversationType,n=e.targetId,o=e.callId,s=e.mediaType,a=e.inviteUserIds,l=e.callerId,c=e.existedUserPofiles,u=e.directionalUserIdList,d=e.extra,C=e.pushConfig,_={platform:y.WEB,deviceId:this._deviceId,callId:o,extra:d,engineType:4,channelInfo:{Id:o,Key:""},mediaType:s,inviteUserIds:a,observerUserIds:[],user:this._userInfo,caller:l,modifyMemType:I.ADD,existedUserPofiles:c},C&&(C.pushData=JSON.stringify({mediaType:s,userIdList:a,callId:o})),[2,this._sendCallMessage({channelId:t,conversationType:r,targetId:n,content:_,messageType:p.VCModifyMem,directionalUserIdList:u,pushConfig:C})]}))}))}}),Object.defineProperty(n.prototype,"sendRinging",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=t.channelId,n=t.conversationType,o=t.targetId,i=t.callId,s=t.userIds,a={platform:y.WEB,deviceId:this._deviceId,callId:i,user:this._userInfo};return this._sendCallMessage({channelId:r,conversationType:n,targetId:o,content:a,messageType:p.VCRinging,directionalUserIdList:n===e.ConversationType.GROUP?s:void 0})}}),Object.defineProperty(n.prototype,"sendAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=t.channelId,n=t.conversationType,o=t.targetId,i=t.callId,s=t.mediaType,a=t.userIds,l={platform:y.WEB,deviceId:this._deviceId,callId:i,mediaType:s,user:this._userInfo};return this._sendCallMessage({channelId:r,conversationType:n,targetId:o,content:l,messageType:p.VCAccept,directionalUserIdList:n===e.ConversationType.GROUP?a:void 0})}}),Object.defineProperty(n.prototype,"sendHungup",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=t.channelId,n=t.conversationType,o=t.targetId,i=t.callId,s=t.reason,a=t.userIds,l=t.pushConfig,c={platform:y.WEB,deviceId:this._deviceId,callId:i,reason:s,user:this._userInfo};return l&&(l.pushData=JSON.stringify({callId:i,reason:s})),this._sendCallMessage({channelId:r,conversationType:n,targetId:o,content:c,messageType:p.VCHangup,pushConfig:l,directionalUserIdList:n===e.ConversationType.GROUP?a:void 0})}}),Object.defineProperty(n.prototype,"sendMediaModify",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=t.channelId,n=t.conversationType,o=t.targetId,i=t.callId,s=t.mediaType,a=t.userIds,l={platform:y.WEB,deviceId:this._deviceId,callId:i,mediaType:s,user:this._userInfo};return this._sendCallMessage({channelId:r,conversationType:n,targetId:o,content:l,messageType:p.VCModifyMedia,directionalUserIdList:n===e.ConversationType.GROUP?a:void 0})}}),n}(e.EventEmitter);exports.RCCallLanguage=void 0,(T=exports.RCCallLanguage||(exports.RCCallLanguage={})).ZH="zh",T.EN="en";var w,N={PushTitle:{AUDIO:"You have a voice call",VIDEO:"You have a video call"}},A={PushTitle:{AUDIO:"您有一条音频通话",VIDEO:"您有一条视频通话"}},U=function(){function e(){}return Object.defineProperty(e,"set",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._lang=e}}),Object.defineProperty(e,"get",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._lang===exports.RCCallLanguage.EN?N:A}}),Object.defineProperty(e,"_lang",{enumerable:!0,configurable:!0,writable:!0,value:exports.RCCallLanguage.ZH}),e}(),L=function(){function t(e,t,r,n,o){var i=this;Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_watchers",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_stateMachine",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_callMsgHandler",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._logger.warn("_","RCCallEngine Version: ".concat("5.2.6"," CommitId: ").concat("6761942c405d068867e89ca6c16d888599154bde")),h(t),this._callMsgHandler=new P(this._context,this._runtime,this._logger,this._options.offlineMsgItv,this._getStateMachine.bind(this)),this._callMsgHandler.registerEventListener({onInvite:this._onInvite.bind(this),sendAccept:this._handleSendAccept.bind(this),onOfflineRecord:this._watchers.onOfflineRecord}),_.on("onStateMachineClose",(function(e){delete i._stateMachine[e]})),U.set(o.lang)}return Object.defineProperty(t.prototype,"_onInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.channelId,r=e.conversationType,n=e.targetId,o=e.content,i=e.messageType,s=e.senderUserId;e.pushConfig,this._logger.warn("_","RCCallEngine _onInvite:targetId ".concat(n," senderUserId: ").concat(s));var a,l=o,c=l.mediaType,u=l.callId,d=l.extra;a=l.roomType!==R.RCCallRoomTypeAcrossCall?s:s.split("_")[1];var C=this._context.getCurrentId();if(this._context.getCurrentId()!==a){if(i===p.VCModifyMem)if(o.existedUserPofiles.some((function(e){return e.userId===C}))&&!this._stateMachine[u])return;if(this._stateMachine[u])i===p.VCModifyMem&&this._stateMachine[u].__onMemberModify(e);else this._stateMachine[u]=new v(this._context,this._runtime,this._logger,this._callMsgHandler,t,r,n,c,u),this._logger.info("_","[RCCallEngine] RCCallStateMachine successfully created -> callId: ".concat(u)),i===p.VCInvite?this._stateMachine[u].__onInvite(e):i===p.VCModifyMem&&this._stateMachine[u].__onMemberModify(e),this._watchers.onInvite(this._stateMachine[u],d),Object.keys(this._stateMachine).filter((function(e){return u!==e})).length>0&&!this._options.isAllowAcceptNewCall&&this._stateMachine[u].__handleInviteInSession()}}}),Object.defineProperty(t.prototype,"_handleSendAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this._options.isAllowAcceptNewCall){var t=e.callId;for(var r in this._stateMachine)t!==r&&(this._stateMachine[r].hungup(),delete this._stateMachine[r])}}}),Object.defineProperty(t.prototype,"_getStateMachine",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._stateMachine[e]}}),Object.defineProperty(t.prototype,"registerUserInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.debug("_","[RCCallEngine] registerUserInfo -> userInfo: ".concat(JSON.stringify(e))),this._callMsgHandler.registerUserInfo(e)}}),Object.defineProperty(t.prototype,"call",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,n,s,a,l){return void 0===s&&(s=""),void 0===l&&(l=!1),o(this,void 0,void 0,(function(){var o,c;return i(this,(function(i){switch(i.label){case 0:return this._logger.debug("_","[RCCallEngine] call -> args: ".concat(JSON.stringify({channelId:t,targetId:r,mediaType:n,extra:s,pushConfig:a}))),o=C(),Object.keys(this._stateMachine).length>0?[2,{code:exports.RCCallErrorCode.STATE_MACHINE_EXIT}]:(this._stateMachine[o]=new v(this._context,this._runtime,this._logger,this._callMsgHandler,t,e.ConversationType.PRIVATE,r,n,o),[4,this._stateMachine[o].__call([r],s,a,l)]);case 1:return(c=i.sent().code)===exports.RCCallErrorCode.SUCCESS?[2,{code:exports.RCCallErrorCode.SUCCESS,stateMachine:this._stateMachine[o]}]:[2,{code:c}]}}))}))}}),Object.defineProperty(t.prototype,"callInGroup",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,n,s,a,l){return void 0===a&&(a=""),o(this,void 0,void 0,(function(){var o,c;return i(this,(function(i){switch(i.label){case 0:return this._logger.debug("_","[RCCallEngine] callInGroup -> args: ".concat(JSON.stringify({channelId:t,targetId:r,mediaType:n}))),o=C(),Object.keys(this._stateMachine).length>0?[2,{code:exports.RCCallErrorCode.STATE_MACHINE_EXIT}]:(this._stateMachine[o]=new v(this._context,this._runtime,this._logger,this._callMsgHandler,t,e.ConversationType.GROUP,r,n,o),[4,this._stateMachine[o].__call(s,a,l)]);case 1:return(c=i.sent().code)===exports.RCCallErrorCode.SUCCESS?[2,{code:exports.RCCallErrorCode.SUCCESS,stateMachine:this._stateMachine[o]}]:[2,{code:c}]}}))}))}}),Object.defineProperty(t.prototype,"destroy",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._logger.debug("_","[RCCallEngine] destroy"),this._stateMachine={}}}),t}();!function(e){e[e.CALLER=1]="CALLER",e[e.CALLEE=2]="CALLEE"}(w||(w={}));var j=new(function(){function e(){Object.defineProperty(this,"list",{enumerable:!0,configurable:!0,writable:!0,value:{}})}return Object.defineProperty(e.prototype,"on",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return(this.list[e]||(this.list[e]=[])).push(t),this}}),Object.defineProperty(e.prototype,"once",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this,n=function(o){r.off(e,n),t.call(r,o)};n.fun=t,this.on(e,n)}}),Object.defineProperty(e.prototype,"off",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.list[e];if(!r)return!1;if(t){for(var n=void 0,o=0,i=r.length;o<i;o++)if((n=r[o])===t||n.fun===t){r.splice(o,1);break}}else r&&(r.length=0)}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this,n=s([],this.list[e],!0);if(!n||0===n.length)return!1;n.forEach((function(e){e.call(r,t)}))}}),e}());var D=function(t){if(!t)return{result:!1,msg:"Initialization missing parameter -> options"};if("object"!=typeof t)return{result:!1,msg:"Initialization options must be an object"};var r,n=Object.keys(t),o=[];return["rtcClient","onSession","onSessionClose"].forEach((function(e){n.includes(e)||o.push(e)})),o.length?{result:!1,msg:'Initialization missing parameter -> "'.concat(o.join(","),'"')}:"object"!=typeof t.rtcClient?{result:!1,msg:"Initialization 'rtcClient' parameter must be of type 'object'"}:"function"!=typeof t.onSession?{result:!1,msg:"Initialization 'onSession' parameter must be of type 'function'"}:"function"!=typeof t.onSessionClose?{result:!1,msg:"Initialization 'onSessionClose' parameter must be of type 'function'"}:void 0!==t.isAllowSubscribeRetry&&"boolean"!=typeof t.isAllowSubscribeRetry?{result:!1,msg:"Initialization 'isAllowSubscribeRetry' parameter must be of type 'boolean'"}:void 0!==t.isAllowPublishRetry&&"boolean"!=typeof t.isAllowPublishRetry?{result:!1,msg:"Initialization 'isAllowPublishRetry' parameter must be of type 'boolean'"}:void 0!==t.isOffCameraWhenVideoDisable&&"boolean"!=typeof t.isOffCameraWhenVideoDisable?{result:!1,msg:"Initialization 'isOffCameraWhenVideoDisable' parameter must be of type 'boolean'"}:void 0===t.joinType||(r=t.joinType,Object.values(e.RTCJoinType).includes(r))?void 0!==t.isAllowDemotionGetStream&&"boolean"!=typeof t.isAllowDemotionGetStream?{result:!1,msg:"Initialization 'isAllowDemotionGetStream' parameter must be of type 'boolean'"}:void 0===t.lang||function(e){return Object.values(exports.RCCallLanguage).includes(e)}(t.lang)?void 0===t.logOutputLevel||function(t){return[e.LogL.DEBUG,e.LogL.INFO,e.LogL.WARN,e.LogL.ERROR].includes(t)}(t.logOutputLevel)?{result:!0}:{result:!1,msg:"Initialization 'logOutputLevel' parameter must be of type correct type"}:{result:!1,msg:"Initialization 'lang' parameter must be of type correct type"}:{result:!1,msg:"Initialization 'joinType' parameter must be of type correct type"}},k=function(e){if(!e)return{result:!1,msg:"missing parameter -> listener"};if("object"!=typeof e)return{result:!1,msg:"listener must be an object"};var t=Object.keys(e),r=[];return["onRinging","onAccept","onHungup","onTrackReady"].forEach((function(e){t.includes(e)||r.push(e)})),r.length?{result:!1,msg:'missing parameter -> "'.concat(r.join(","),'"')}:"function"!=typeof e.onRinging?{result:!1,msg:"'onRinging' parameter must be of type 'function'"}:"function"!=typeof e.onAccept?{result:!1,msg:"'onAccept' parameter must be of type 'function'"}:"function"!=typeof e.onHungup?{result:!1,msg:"'onHungup' parameter must be of type 'function'"}:"function"!=typeof e.onTrackReady?{result:!1,msg:"'onTrackReady' parameter must be of type 'function'"}:{result:!0}},H=function(e){return e&&"string"==typeof e?{result:!0}:{result:!1,msg:"'targetId' parameter is required, must be of type 'string'"}},V=function(e){return e===exports.RCCallMediaType.AUDIO||e===exports.RCCallMediaType.AUDIO_VIDEO?{result:!0}:{result:!1,msg:"'mediaType' parameter is required, must be of type 'RCCallMediaType'"}},G=function(e){return"string"==typeof e?{result:!0}:{result:!1,msg:"'extra' parameter must be of type 'string'"}},B=function(t){var r=["pushTitle","pushContent","pushData","iOSConfig","androidConfig","disablePushTitle","templateId"],n=Object.keys(t).every((function(e){return r.includes(e)}));if(!n)return{code:exports.RCCallErrorCode.PARAM_ERROR,errorMsg:"right key: ".concat(r.join(","))};for(var o=0;o<r.length;o++){var i=r[o];if("disablePushTitle"===i){if(!e.isUndefined(t[i])&&!e.isBoolean(t[i]))return{code:exports.RCCallErrorCode.PARAM_ERROR,errorMsg:"".concat(i," type is boolean")}}else if(("pushTitle"===i||"templateId"===i)&&t[i]&&!e.isString(t[i]))return{code:exports.RCCallErrorCode.PARAM_ERROR,errorMsg:"".concat(i," type is string")}}var s=t.iOSConfig,a=t.androidConfig,l=K(s||{});if(l.code!==exports.RCCallErrorCode.SUCCESS)return l;var c=J(a||{});return c.code!==exports.RCCallErrorCode.SUCCESS?c:{code:exports.RCCallErrorCode.SUCCESS}},K=function(t){var r=t||{},n=r.threadId,o=r.richMediaUri;return n&&!e.isString(n)?{code:exports.RCCallErrorCode.PARAM_ERROR,errorMsg:"iOSConfig.threadId type is string"}:o&&!e.isString(o)?{code:exports.RCCallErrorCode.PARAM_ERROR,errorMsg:"iOSConfig.richMediaUri type is string"}:{code:exports.RCCallErrorCode.SUCCESS}},J=function(t){var r=["notificationId","channelIdMi","channelIdHW","categoryHW","importanceHW","imageUrlHW","channelIdOPPO","typeVivo","categoryVivo","fcmChannelId","fcmCollapseKey","fcmImageUrl","importanceHonor","imageUrlHonor"],n=Object.keys(t).every((function(e){return r.includes(e)}));if(!n)return{code:exports.RCCallErrorCode.PARAM_ERROR,errorMsg:"right key: ".concat(r.join(","))};for(var o=0;o<r.length;o++){var i=r[o];if("importanceHW"===i||"importanceHonor"===i){if(t[i]&&"LOW"!==t[i]&&"NORMAL"!==t[i])return{code:exports.RCCallErrorCode.PARAM_ERROR,errorMsg:"androidConfig.".concat(i," value is NORMAL|LOW")}}else if(t[i]&&!e.isString(t[i]))return{code:exports.RCCallErrorCode.PARAM_ERROR,errorMsg:"androidConfig.".concat(i," type is string")}}return{code:exports.RCCallErrorCode.SUCCESS}},W=function(e){return Array.isArray(e)&&e.length?e.every((function(e){return"string"==typeof e&&e.length>0}))?{result:!0}:{result:!1,msg:"'userIds' parameter is required"}:{result:!1,msg:"'userIds' parameter is required, must be of type 'string[]'"}};var Y=function(e){return e&&e.audio&&void 0!==e.audio.micphoneId&&"string"!=typeof e.audio.micphoneId?{result:!1,msg:"'constraints.audio.micphoneId' must be of type 'string'"}:e&&e.audio&&void 0!==e.audio.sampleRate&&"number"!=typeof e.audio.sampleRate?{result:!1,msg:"'constraints.audio.sampleRate' must be of type 'number'"}:e&&e.video&&void 0!==e.video.cameraId&&"string"!=typeof e.video.cameraId?{result:!1,msg:"'constraints.video.cameraId' must be of type 'string'"}:e&&e.video&&void 0!==e.video.frameRate&&"string"!=typeof e.video.frameRate?{result:!1,msg:"'constraints.video.frameRate' must be of type 'string'"}:e&&e.video&&void 0!==e.video.frameRate&&(r=e.video.frameRate,!["FPS_10","FPS_15","FPS_24","FPS_30"].includes(r))?{result:!1,msg:"'frameRate' value is out of range"}:e&&e.video&&void 0!==e.video.resolution&&"string"!=typeof e.video.resolution?{result:!1,msg:"'constraints.video.frameRate' must be of type 'string'"}:e&&e.video&&void 0!==e.video.resolution&&(n=e.video.resolution,!t.RCResolution[n])?{result:!1,msg:"'resolution' value is out of range"}:!e||!e.video||e.video.frameRate&&e.video.resolution?{result:!0}:{result:!1,msg:"'resolution' and 'resolution' is required"};var r,n},F=function(){function e(e,t){Object.defineProperty(this,"_timerId",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_startTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),e&&(this._timerId=function(e,t){return setTimeout(e,t)}((function(){e()}),t)),this._startTime=Date.now()}return Object.defineProperty(e.prototype,"stop",{enumerable:!1,configurable:!0,writable:!0,value:function(){clearTimeout(this._timerId);var e=Date.now(),t=e-this._startTime;return 0===this._startTime&&(t=0),{startTime:this._startTime,endTime:e,duration:t}}}),Object.defineProperty(e.prototype,"reset",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._startTime=0}}),e}(),z=function(){function r(e,t,r,n){void 0===n&&(n={});var s=this;Object.defineProperty(this,"_stateMachine",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_rtcClient",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_room",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_listener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_RETRYCOUNT",{enumerable:!0,configurable:!0,writable:!0,value:2}),Object.defineProperty(this,"joinRoomTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._stateMachine.registerEventListener({onUserStateChange:function(e){var t=e.user,r=e.reason;s._logger.info("_","[RCCallSession onUserStateChange] userId->".concat(null==t?void 0:t.userId," state->").concat(null==t?void 0:t.state," reason->").concat(r))},onStateChange:function(e){return o(s,void 0,void 0,(function(){var t,r,n,o,s;return i(this,(function(i){switch(i.label){case 0:if(t=e.state,r=e.reason,this._logger.info("_","[RCCallSession onStateChange] : state->".concat(t," reason->").concat(r)),t!==exports.RCCallSessionState.KEEPING)return[3,5];n=this._stateMachine.getCallId(),this._logger.info("_","[RCCallSession onStateChange] roomId: ".concat(n)),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this._joinRoom(n)];case 2:return i.sent(),[3,4];case 3:return o=i.sent(),this._exceptionClose(exports.RCCallEndReason.NETWORK_ERROR),this._logger.error("_","[RCCallSession onStateChange] joinRoom throw exception roomId -> ".concat(n)),console.error(o),[3,4];case 4:return[3,6];case 5:if(t===exports.RCCallSessionState.END){if(!this._room)return this._options.localTracks&&this._destroyTracks(this._options.localTracks),s=this._stateMachine.getSummary(),j.emit("sessionClose",{session:this,summaryInfo:s}),[2];this._options.localTracks&&this._destroyTracks(this._options.localTracks),this._logger.info("_","[RCCallSession onStateChange] localTracks destroyed"),this._leaveRoom(),this._room=null}i.label=6;case 6:return[2]}}))}))},onRinging:function(e){s._logger.info("_","[RCCallSession onRinging]sender: sender.userId -> ".concat(e.userId));try{s._listener.onRinging(e,s)}catch(e){s._logger.error("_","[RCCallSession onRinging] method exception -> onRinging"),console.error(e)}},onAccept:function(e){s._logger.info("_","[RCCallSession onAccept]sender: sender.userId -> ".concat(e.userId));try{s._listener.onAccept(e,s)}catch(e){s._logger.error("_","[RCCallSession onAccept] method exception -> onAccept"),console.error(e)}},onHungup:function(e,t){s._logger.info("_","[RCCallSession onHungup]sender: sender.userId -> ".concat(e.userId," reason->").concat(t));try{s._listener.onHungup(e,t,s)}catch(e){s._logger.error("_","[RCCallSession onHungup] method exception -> onHungup"),console.error(e)}},onMemberModify:function(e){var t=e.sender,r=e.invitedUsers;s._logger.info("_","[RCCallSession onMemberModify] sender.userId -> ".concat(t.userId));try{s._listener.onMemberModify(t,r,s)}catch(e){s._logger.error("_","[RCCallSession onMemberModify] method exception -> onMemberModify"),console.error(e)}},onMediaModify:function(e){var t=e.sender,r=e.mediaType;s._logger.info("_","[RCCallSession onMediaModify]sender: sender.userId -> ".concat(t.userId," mediaType: ").concat(r)),r===exports.RCCallMediaType.AUDIO&&s._setMediaTypeToAudio();try{s._listener.onMediaModify(t,r,s)}catch(e){s._logger.error("_","[RCCallSession onMediaModify] method exception -> onMediaModify"),console.error(e)}},crossAppkey:function(e){s._logger.info("_","[RCCallSession crossAppkey] 是否跨 appkey: ".concat(e)),s._options.isCrossAppkey=e}}),this._stateMachine.setHungupPushConfig(this._options.hungupPushConfig||{pushTitle:"",pushContent:""})}return Object.defineProperty(r.prototype,"_joinRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(r){return o(this,void 0,void 0,(function(){var n,o,s,a,l,c,u,d=this;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,7,,8]),this._options.isCrossAppkey?[4,this._rtcClient.joinCrossRTCRoom(r,this._options.joinType)]:[3,2];case 1:return n=i.sent(),[3,4];case 2:return[4,this._rtcClient.joinRTCRoom(r,this._options.joinType)];case 3:n=i.sent(),i.label=4;case 4:return o=n.code,s=n.userIds,a=n.room,o!==t.RCRTCCode.SUCCESS?(o===t.RCRTCCode.NOT_OPEN_VIDEO_AUDIO_SERVER&&this._exceptionClose(exports.RCCallEndReason.SERVICE_NOT_OPENED),o===t.RCRTCCode.SIGNAL_JOIN_RTC_ROOM_REFUSED?this._exceptionClose(exports.RCCallEndReason.OTHER_CLIENT_IN_CALL):this._exceptionClose(exports.RCCallEndReason.NETWORK_ERROR),this._logger.info("_","[RCCallClient _joinRoom] join room failed: roomId -> ".concat(r," RCRTCCode -> ").concat(o)),[2,{code:exports.RCCallErrorCode.JOIN_ROOM_ERROR}]):(this._stateMachine.getConversationType()===e.ConversationType.GROUP&&this._stateMachine.userJoin([this._rtcClient.getCurrentId()]),this._stateMachine.getState()!==exports.RCCallSessionState.END?[3,6]:[4,this._rtcClient.leaveRoom(a)]);case 5:return i.sent(),this._room=null,[2,{code:exports.RCCallErrorCode.SUCCESS}];case 6:return s.length<1&&(this.joinRoomTimer=new F((function(){d._exceptionClose(exports.RCCallEndReason.REMOTE_NETWORK_ERROR)}),6e4)),this._room=a,[3,8];case 7:return l=i.sent(),this._exceptionClose(exports.RCCallEndReason.NETWORK_ERROR),this._logger.error("_","[RCCallSession _joinRoom] _rtcClient.joinRTCRoom throw exception roomId -> ".concat(r)),console.error(l),[2,{code:exports.RCCallErrorCode.JOIN_ROOM_ERROR}];case 8:this._registerRoomEventListener(),this._registerReportListener(),i.label=9;case 9:return i.trys.push([9,11,,12]),[4,this._subscribeInRoomRemoteTrack()];case 10:return i.sent(),[3,12];case 11:return c=i.sent(),this._exceptionClose(exports.RCCallEndReason.SUBSCRIBE_ERROR),this._logger.error("_","[RCCallSession _joinRoom] _subscribeInRoomRemoteTrack Exception roomId -> ".concat(r)),console.error(c),[2,{code:exports.RCCallErrorCode.JOIN_ROOM_ERROR}];case 12:return i.trys.push([12,14,,15]),[4,this._publish()];case 13:return i.sent(),[3,15];case 14:return u=i.sent(),this._exceptionClose(exports.RCCallEndReason.PUBLISH_ERROR),this._logger.error("_","[RCCallSession _joinRoom] _publish Exception roomId -> ".concat(r)),console.error(u),[2,{code:exports.RCCallErrorCode.JOIN_ROOM_ERROR}];case 15:return[2,{code:exports.RCCallErrorCode.SUCCESS}]}}))}))}}),Object.defineProperty(r.prototype,"_subscribeInRoomRemoteTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:return(e=this._room.getRemoteTracks()).length?[4,this._subscribeRetry(e,this._options.isAllowSubscribeRetry,this._RETRYCOUNT)]:[3,2];case 1:(r=n.sent().code)!==t.RCRTCCode.SUCCESS&&(this._exceptionClose(exports.RCCallEndReason.SUBSCRIBE_ERROR),this._logger.error("_","[RCCallSession _subscribeInRoomRemoteTrack] Resource subscription failed roomId -> ".concat(this._stateMachine.getCallId()," RTC code -> ").concat(r))),n.label=2;case 2:return[2]}}))}))}}),Object.defineProperty(r.prototype,"_subscribeRetry",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,n){return void 0===r&&(r=!1),void 0===n&&(n=0),o(this,void 0,void 0,(function(){var o;return i(this,(function(i){switch(i.label){case 0:return[4,this._room.subscribe(e)];case 1:if((o=i.sent().code)!==t.RCRTCCode.SUCCESS){try{this._listener.onTrackSubscribeFail&&this._listener.onTrackSubscribeFail(o,this)}catch(e){this._logger.error("_","[RCCallSession] _listener.onTrackSubscribeFail exception"),console.error(e)}if(!r)return[2,{code:o}];if(n>0)return n--,[2,this._subscribeRetry(e,r,n)]}return[2,{code:o}]}}))}))}}),Object.defineProperty(r.prototype,"_publish",{enumerable:!1,configurable:!0,writable:!0,value:function(){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:return e=this._options.localTracks,[4,this._publishRetry(e,this._options.isAllowPublishRetry,this._RETRYCOUNT)];case 1:return(r=n.sent().code)!==t.RCRTCCode.SUCCESS?(this._exceptionClose(exports.RCCallEndReason.PUBLISH_ERROR),this._logger.info("_","[RCCallSession _publist] Resource publishing failed: roomId -> ".concat(this._stateMachine.getCallId()," RCRTCCode -> ").concat(r)),[2]):(this._options.produceType===w.CALLEE&&this._notifyTrackReady(e),[2])}}))}))}}),Object.defineProperty(r.prototype,"_publishRetry",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,n){return void 0===r&&(r=!1),void 0===n&&(n=0),o(this,void 0,void 0,(function(){var o;return i(this,(function(i){switch(i.label){case 0:return[4,this._room.publish(e)];case 1:if((o=i.sent().code)!==t.RCRTCCode.SUCCESS){try{this._listener.onTrackPublishFail&&this._listener.onTrackPublishFail(o,this)}catch(e){this._logger.error("_","[RCCallSession] _listener.onTrackPublishFail exception"),console.error(e)}if(!r)return[2,{code:o}];if(n>0)return n--,[2,this._publishRetry(e,r,n)]}return[2,{code:o}]}}))}))}}),Object.defineProperty(r.prototype,"_leaveRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(){return o(this,void 0,void 0,(function(){var e,t,r;return i(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,3,4]),[4,this._rtcClient.leaveRoom(this._room)];case 1:return e=n.sent(),this._logger.info("_","[RCCallSession _leaveRoom] Successfully exited the room code: ".concat(e.code)),[3,4];case 2:return t=n.sent(),this._logger.error("_","[RCCallSession _leaveRoom] leaveRoom throw exception"),console.error(t),[3,4];case 3:return r=this._stateMachine.getSummary(),j.emit("sessionClose",{session:this,summaryInfo:r}),[7];case 4:return[2]}}))}))}}),Object.defineProperty(r.prototype,"_exceptionClose",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._options.localTracks&&this._destroyTracks(this._options.localTracks),this._stateMachine.close(e)}}),Object.defineProperty(r.prototype,"registerSessionListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=k(e);if(!t.result)throw new Error("[RCCallSession registerSessionListener] ".concat(t.msg));this._listener=n({},e)}}),Object.defineProperty(r.prototype,"_getLocalTrackCore",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){return o(this,void 0,void 0,(function(){var o,s,a,l,c,u;return i(this,(function(i){switch(i.label){case 0:return e!==exports.RCCallMediaType.AUDIO?[3,2]:[4,this._rtcClient.createMicrophoneAudioTrack("RongCloudRTC",r&&r.audio&&n({},r.audio))];case 1:return o=i.sent(),s=o.code,a=o.track,s!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession _getLocalTrackCore] get Audio local tracks failed RCT code -> ".concat(s)),[2,{code:exports.RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR}]):(this._logger.info("_","[RCCallSession _getLocalTrackCore] successfully get Audio local tracks"),[2,{code:exports.RCCallErrorCode.SUCCESS,tracks:[a]}]);case 2:return[4,this._rtcClient.createMicrophoneAndCameraTracks("RongCloudRTC",r&&n({},r))];case 3:return l=i.sent(),c=l.code,u=l.tracks,c!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession _getLocalTrackCore] get Audio and Video local tracks failed RCT code -> ".concat(c)),[2,{code:exports.RCCallErrorCode.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR}]):(this._logger.info("_","[RCCallSession _getLocalTrackCore] successfully get audio and video local tracks"),[2,{code:exports.RCCallErrorCode.SUCCESS,tracks:u}])}}))}))}}),Object.defineProperty(r.prototype,"_getLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return o(this,void 0,void 0,(function(){var r,n,o,s,a,l,c,u,d;return i(this,(function(i){switch(i.label){case 0:return this._options.isAllowDemotionGetStream&&e===exports.RCCallMediaType.AUDIO_VIDEO?[4,this._getLocalTrackCore(exports.RCCallMediaType.AUDIO_VIDEO,t)]:[3,4];case 1:return r=i.sent(),n=r.code,o=r.tracks,n===exports.RCCallErrorCode.SUCCESS?[3,3]:[4,this._getLocalTrackCore(exports.RCCallMediaType.AUDIO,t)];case 2:return s=i.sent(),a=s.code,l=s.tracks,a!==exports.RCCallErrorCode.SUCCESS?(this._exceptionClose(exports.RCCallEndReason.GET_MEDIA_RESOURCES_ERROR),[2,{code:a}]):[2,{code:a,tracks:l}];case 3:return[2,{code:n,tracks:o}];case 4:return[4,this._getLocalTrackCore(e,t)];case 5:return c=i.sent(),u=c.code,d=c.tracks,u!==exports.RCCallErrorCode.SUCCESS?(this._exceptionClose(exports.RCCallEndReason.GET_MEDIA_RESOURCES_ERROR),[2,{code:u}]):[2,{code:u,tracks:d}]}}))}))}}),Object.defineProperty(r.prototype,"changeAudioDevice",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return o(this,void 0,void 0,(function(){var r,n,o,s,a;return i(this,(function(i){switch(i.label){case 0:return r=[],n=[],[4,this._rtcClient.createMicrophoneAudioTrack("RongCloudRTC",e)];case 1:return o=i.sent(),s=o.code,a=o.track,s!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession changeDevice] get local Audio tracks failed RCTLib code -> ".concat(s)),[2,{code:exports.RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR}]):(this._options.localTracks&&this._options.localTracks.forEach((function(e){e.isAudioTrack()||n.push(e)})),r.push(a),n.push(a),this._options.localTracks=n,this._notifyTrackReady(r),this._room?[4,this._room.publish(r)]:[3,3]);case 2:if(i.sent().code!==t.RCRTCCode.SUCCESS)return[2,{code:exports.RCCallErrorCode.AUDIO_PUBLISH_ERROR}];i.label=3;case 3:return[2,{code:exports.RCCallErrorCode.SUCCESS}]}}))}))}}),Object.defineProperty(r.prototype,"invite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var r,n,o,s,a,l,c,u;return i(this,(function(i){switch(i.label){case 0:if(r=t.extra,n=void 0===r?"":r,o=this._options.callPushConfig?this._options.callPushConfig:t.pushConfig,s=[W(e),G(n)],o&&(a=B(o),l=a.code,c=a.errorMsg,l!==exports.RCCallErrorCode.SUCCESS))return this._logger.error("_","[RCCallSession invite] param error, errorMsg: ".concat(c)),[2,{code:l}];if(u=[],!s.every((function(e){return!e.result&&u.push(e.msg),e.result})))throw new Error("[RCCallClient invite] ".concat(u.join("\n")));return[4,this._stateMachine.invite(e,{extra:n,pushConfig:o})];case 1:return[2,{code:i.sent().code}]}}))}))}}),Object.defineProperty(r.prototype,"accept",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return o(this,void 0,void 0,(function(){var t,r,n,o,s,a;return i(this,(function(i){switch(i.label){case 0:if(!(t=Y(e)).result)throw new Error("[RCCallSession accept] ".concat(t.msg));return j.emit("hungupOtherSession",{session:this}),r=this._stateMachine.getMediaType(),[4,this._getLocalTrack(r,e)];case 1:return n=i.sent(),o=n.code,s=n.tracks,o!==exports.RCCallErrorCode.SUCCESS?[2,{code:o}]:(this._options.localTracks=s,[4,this._stateMachine.accept()]);case 2:return(a=i.sent().code)!==exports.RCCallErrorCode.SUCCESS?(this._logger.error("_","[RCCallSession accept]Send accept message failed -> code: ".concat(a)),[2,{code:a}]):[2,{code:a}]}}))}))}}),Object.defineProperty(r.prototype,"hungup",{enumerable:!1,configurable:!0,writable:!0,value:function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this._stateMachine.hungup()]}))}))}}),Object.defineProperty(r.prototype,"_changeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(r){switch(r.label){case 0:return[4,this._stateMachine.changeMediaType(e)];case 1:return(t=r.sent().code)!==exports.RCCallErrorCode.SUCCESS&&this._logger.error("_","[RCCallSession _changeMediaType] change media type fail code-> ".concat(t)),[2,{code:t}]}}))}))}}),Object.defineProperty(r.prototype,"_getLocalVideoTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=[];return this._room?(this._options.localTracks&&(e=this._options.localTracks.filter((function(e){return e.isVideoTrack()}))),e):e}}),Object.defineProperty(r.prototype,"_getLocalAudioTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=[];return this._room?(this._options.localTracks&&(e=this._options.localTracks.filter((function(e){return e.isAudioTrack()}))),e):e}}),Object.defineProperty(r.prototype,"_setMediaTypeToAudioAndVideo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return o(this,void 0,void 0,(function(){var e,r,n;return i(this,(function(o){switch(o.label){case 0:return[4,this._rtcClient.createCameraVideoTrack()];case 1:return e=o.sent(),r=e.code,n=e.track,r!==t.RCRTCCode.SUCCESS?[2,{code:exports.RCCallErrorCode.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR}]:[4,this._room.publish([n])];case 2:return o.sent().code!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession _enableVideo] Resource publishing failed: RCRTCCode -> ".concat(r)),[2]):(this._notifyTrackReady([n]),this._changeMediaType(exports.RCCallMediaType.AUDIO_VIDEO),[2])}}))}))}}),Object.defineProperty(r.prototype,"_setMediaTypeToAudio",{enumerable:!1,configurable:!0,writable:!0,value:function(){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:return(e=this._getLocalVideoTracks()).length?(e.forEach((function(e){e.mute()})),[4,this._room.unpublish(e)]):[3,2];case 1:(r=n.sent().code)!==t.RCRTCCode.SUCCESS&&this._logger.error("_","[RCCallSession disableVideo] unpublish failed -> ".concat(r)),this._destroyTracks(e),n.label=2;case 2:return[2]}}))}))}}),Object.defineProperty(r.prototype,"descendAbility",{enumerable:!1,configurable:!0,writable:!0,value:function(){return o(this,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,this._changeMediaType(exports.RCCallMediaType.AUDIO)];case 1:return(e=t.sent().code)===exports.RCCallErrorCode.SUCCESS&&this._setMediaTypeToAudio(),[2,{code:e}]}}))}))}}),Object.defineProperty(r.prototype,"disableVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:return this._room?(e=this._getLocalVideoTracks()).length?(e.forEach((function(e){e.mute()})),this._options.isOffCameraWhenVideoDisable?[4,this._room.unpublish(e)]:[2,{code:exports.RCCallErrorCode.SUCCESS}]):(this._logger.error("_","[RCCallSession disableVideoTrack] Room missing video track -> ".concat(exports.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR)),[2,{code:exports.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}]):(this._logger.error("_","[RCCallSession disableVideoTrack] Not in room"),[2,{code:exports.RCCallErrorCode.NOT_IN_ROOM_ERROR}]);case 1:return(r=n.sent().code)!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession disableVideo] unpublish failed -> ".concat(r)),[2,{code:exports.RCCallErrorCode.UNPUBLISH_VIDEO_ERROR}]):(e.forEach((function(e){e.destroy()})),[2,{code:exports.RCCallErrorCode.SUCCESS}])}}))}))}}),Object.defineProperty(r.prototype,"enableVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return o(this,void 0,void 0,(function(){var e,r,n,o,s;return i(this,(function(i){switch(i.label){case 0:return this._room?this._options.isOffCameraWhenVideoDisable?[4,this._rtcClient.createCameraVideoTrack()]:(e=this._getLocalVideoTracks()).length?(e.forEach((function(e){e.unmute()})),[2,{code:exports.RCCallErrorCode.SUCCESS}]):(this._logger.error("_","[RCCallSession enableVideoTrack] Room missing video track -> ".concat(exports.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR)),[2,{code:exports.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}]):(this._logger.error("_","[RCCallSession enableVideoTrack] Not in room -> ".concat(exports.RCCallErrorCode.NOT_IN_ROOM_ERROR)),[2,{code:exports.RCCallErrorCode.NOT_IN_ROOM_ERROR}]);case 1:return r=i.sent(),n=r.code,o=r.track,n!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession EnableVideoTrack] Get Resource failed: RCRTCCode -> ".concat(n)),[2,{code:exports.RCCallErrorCode.GET_LOCAL_VIDEO_TRACK_ERROR}]):(s=[],this._options.localTracks&&this._options.localTracks.forEach((function(e){e.isVideoTrack()?e.destroy():s.push(e)})),s.push(o),this._options.localTracks=s,o.mute(),[4,this._room.publish([o])]);case 2:return i.sent().code!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession EnableVideoTrack] Resource publishing failed: RCRTCCode -> ".concat(n)),[2,{code:exports.RCCallErrorCode.VIDEO_PUBLISH_ERROR}]):(o.unmute(),this._notifyTrackReady([o]),[2,{code:exports.RCCallErrorCode.SUCCESS}])}}))}))}}),Object.defineProperty(r.prototype,"disableAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:return this._room?(e=this._getLocalAudioTracks()[0])?[4,e.mute()]:(this._logger.warn("_","[RCCallSession disableAudioTrack] Room missing audio track -> ".concat(exports.RCCallErrorCode.MISSING_AUDIO_TRACK_ERROR)),[2,{code:exports.RCCallErrorCode.MISSING_AUDIO_TRACK_ERROR}]):(this._logger.warn("_","[RCCallSession disableAudioTrack] Not in room -> ".concat(exports.RCCallErrorCode.NOT_IN_ROOM_ERROR)),[2,{code:exports.RCCallErrorCode.NOT_IN_ROOM_ERROR}]);case 1:return(r=n.sent())!==t.RCRTCCode.SUCCESS&&this._logger.warn("_","[RCCallSession disableAudioTrack] mute failed -> ".concat(r)),[2,{code:r}]}}))}))}}),Object.defineProperty(r.prototype,"enableAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:return this._room?(e=this._getLocalAudioTracks()[0])?[4,e.unmute()]:(this._logger.error("_","[RCCallSession enableAudioTrack] Room missing audio track -> ".concat(exports.RCCallErrorCode.MISSING_AUDIO_TRACK_ERROR)),[2,{code:exports.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}]):(this._logger.error("_","[RCCallSession enableAudioTrack] Not in room -> ".concat(exports.RCCallErrorCode.NOT_IN_ROOM_ERROR)),[2,{code:exports.RCCallErrorCode.NOT_IN_ROOM_ERROR}]);case 1:return(r=n.sent())!==t.RCRTCCode.SUCCESS&&this._logger.error("_","[RCCallSession enableAudioTrack] unmute failed -> ".concat(r)),[2,{code:r}]}}))}))}}),Object.defineProperty(r.prototype,"_destroyTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){e.forEach((function(e){e.destroy()}))}}),Object.defineProperty(r.prototype,"_notifyTrackReady",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;e.forEach((function(e){try{t._listener.onTrackReady(e,t)}catch(e){t._logger.error("_","[RCCallSession _notifyTrackReady] _listener onTrackReady exception"),console.error(e)}}))}}),Object.defineProperty(r.prototype,"_registerRoomEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this._room.registerRoomEventListener({onKickOff:function(r,n){var o=e._rtcClient.getCurrentId();e._stateMachine.userLeave([o]),r?(n===t.RCKickReason.SERVER_KICK&&e._exceptionClose(exports.RCCallEndReason.KICKED_BY_SERVER),n===t.RCKickReason.OTHER_KICK&&e._exceptionClose(exports.RCCallEndReason.OTHER_CLIENT_JOINED_CALL)):e._exceptionClose(exports.RCCallEndReason.NETWORK_ERROR)},onMessageReceive:function(e,t,r,n){},onRoomAttributeChange:function(e,t){},onAudioMuteChange:function(t){e._logger.info("_","[RCCallSession onAudioMuteChange] userId->".concat(t.getUserId()," muted -> ").concat(t.isOwnerMuted()));var r={userId:t.getUserId(),muted:t.isOwnerMuted(),kind:"audio",trackId:t.getTrackId()};try{e._listener.onAudioMuteChange(r,e)}catch(t){e._logger.error("_","[RCCallSession onAudioMuteChange] Missing listening method -> onAudioMuteChange"),console.error(t)}},onVideoMuteChange:function(t){e._logger.info("_","[RCCallSession onVideoMuteChange]userId->".concat(t.getUserId()," muted -> ").concat(t.isOwnerMuted()));var r={userId:t.getUserId(),muted:t.isOwnerMuted(),kind:"video",trackId:t.getTrackId()};try{e._listener.onVideoMuteChange(r,e)}catch(t){e._logger.error("_","[RCCallSession onVideoMuteChange] Missing listening method -> onVideoMuteChange"),console.error(t)}},onTrackPublish:function(r){return o(e,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return this._room?[4,this._room.subscribe(r)]:[3,2];case 1:(e=n.sent().code)!==t.RCRTCCode.SUCCESS&&this._logger.error("_","[RCCallSession onTrackPublish] subscribe failed RTCCode ->".concat(e)),n.label=2;case 2:return[2]}}))}))},onTrackUnpublish:function(e){},onTrackReady:function(t){e._stateMachine.getMediaType()===exports.RCCallMediaType.AUDIO&&t.isVideoTrack()||e._notifyTrackReady([t])},onUserJoin:function(t){e.joinRoomTimer&&e.joinRoomTimer.stop(),e._stateMachine.userJoin(t)},onUserLeave:function(t){e._logger.info("_","[RCCallSession onUserLeave] listening onUserLeave userIds -> ".concat(null==t?void 0:t.join(","))),e._stateMachine.userLeave(t)},onPing:function(t){e._logger.info("_","[RCCallSession onPing]".concat(t));try{e._listener.onPing&&e._listener.onPing(t,e)}catch(t){e._logger.error("_","[RCCallSession onPing] listening onPing exception"),console.error(t)}}})}}),Object.defineProperty(r.prototype,"_registerReportListener",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this._room.registerReportListener({onStateReport:function(t){try{e._listener.onRTCStateReport&&e._listener.onRTCStateReport(t,e)}catch(t){e._logger.error("_","[RCCallSession onStateReport] listener onStateReport exception"),console.error(t)}},onICEConnectionStateChange:function(t){var r,n;try{null===(n=null===(r=e._listener)||void 0===r?void 0:r.onICEConnectionStateChange)||void 0===n||n.call(r,t,e)}catch(t){e._logger.error("_","[RCCallSession onICEConnectionStateChange] onICEConnectionStateChange exception"),console.error(t)}}})}}),Object.defineProperty(r.prototype,"getSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getCallId()}}),Object.defineProperty(r.prototype,"getRTCSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._room?this._room.getSessionId():null}}),Object.defineProperty(r.prototype,"getTargetId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getTargetId()}}),Object.defineProperty(r.prototype,"getConversationType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getConversationType()}}),Object.defineProperty(r.prototype,"getChannelId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getChannelId()}}),Object.defineProperty(r.prototype,"getRemoteUsers",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getRemoteUsers()}}),Object.defineProperty(r.prototype,"getUsers",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getRemoteUsers()}}),Object.defineProperty(r.prototype,"getUserState",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!e||"string"!=typeof e)throw new Error("userId is required, must be of type 'string'");return this._stateMachine.getUserState(e)}}),Object.defineProperty(r.prototype,"getState",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getState()}}),Object.defineProperty(r.prototype,"getCallerId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getCallerId()}}),Object.defineProperty(r.prototype,"getMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getMediaType()}}),r}(),q=function(){function r(t,r,o,i){var s=this;Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_rtcClient",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_sessionList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_callPushConfig",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_hungupPushConfig",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._rtcClient=i.rtcClient,this._options=n({isAllowPublishRetry:!1,isAllowSubscribeRetry:!1,isOffCameraWhenVideoDisable:!0,joinType:e.RTCJoinType.COEXIST,isAllowDemotionGetStream:!1,lang:exports.RCCallLanguage.ZH},i),this._callEngine=new L(this._context,r,this._logger,{onInvite:this._onInvite.bind(this),onOfflineRecord:this._onOfflineRecord.bind(this)},{lang:this._options.lang||exports.RCCallLanguage.ZH}),j.on("sessionClose",(function(e){var t=e.session,r=e.summaryInfo;s._removeSession(t);try{s._options.onSessionClose(t,r)}catch(e){s._logger.error("_","[RCCCallClient] options.onSessionClose exception"),console.log(e)}})),j.on("hungupOtherSession",(function(e){var t=e.session.getSessionId();s._logger.info("_","[RCCallClient hungupOtherSession] sessionId ready to accept -> ".concat(t)),s._logger.info("_","[RCCallClient hungupOtherSession] sessionList ->".concat(s._sessionList.map((function(e){return e.getSessionId()})).join(",")));for(var r=0;s._sessionList.length>1;)s._sessionList[r].getSessionId()!==t?(s._sessionList[r].hungup(),s._sessionList.splice(r,1)):r++;s._logger.info("_","[RCCallClient hungupOtherSession] current sessionList length ->".concat(s._sessionList.length))}))}return Object.defineProperty(r.prototype,"_onInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info("_","[RCCallClient _onInvite] Received invite message");var r=new z(e,this._rtcClient,this._logger,{isAllowSubscribeRetry:this._options.isAllowSubscribeRetry,isAllowPublishRetry:this._options.isAllowPublishRetry,isOffCameraWhenVideoDisable:this._options.isOffCameraWhenVideoDisable,joinType:this._options.joinType,isAllowDemotionGetStream:this._options.isAllowDemotionGetStream,produceType:w.CALLEE,callPushConfig:this._callPushConfig,hungupPushConfig:this._hungupPushConfig});this._logger.info("_","[RCCallClient _onInvite] Received invite message, successfully created session"),this._sessionList.push(r);try{this._options.onSession(r,t)}catch(e){this._logger.error("_","[RCCallClient _options.onSession] onSession exception"),console.log(e)}if(!r._listener)throw this._logger.error("_","[RCCallClient _options.onSession] session Must Have Listener"),new Error("[RCCallSession _options.onSession] session Must Have Listener");var n=k(r._listener);if(!n.result)throw new Error(n.msg)}}),Object.defineProperty(r.prototype,"_onOfflineRecord",{enumerable:!1,configurable:!0,writable:!0,value:function(e){try{this._options.onOfflineRecord&&this._options.onOfflineRecord(e)}catch(e){this._logger.error("_","[RCCallClient _options.onOfflineRecord] onOfflineRecord exception"),console.log(e)}}}),Object.defineProperty(r.prototype,"registerUserInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){void 0===e&&(e={}),this._callEngine.registerUserInfo(e),this._logger.info("_","[RCCallClient registerUserInfo] successfully register user info data")}}),Object.defineProperty(r.prototype,"startCrossCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.targetId,r=e.mediaType,n=void 0===r?exports.RCCallMediaType.AUDIO:r,s=e.listener,a=e.constraints,l=e.channelId,c=void 0===l?"":l,u=e.extra,d=void 0===u?"":u,C=e.pushTitle,_=void 0===C?"":C,h=e.pushContent,p=void 0===h?"":h,f=e.bitrate;return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.__call({targetId:t,mediaType:n,listener:s,constraints:a,channelId:c,extra:d,pushTitle:_,pushContent:p,bitrate:f,isCrossAppkey:!0})]}))}))}}),Object.defineProperty(r.prototype,"call",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.targetId,r=e.mediaType,n=void 0===r?exports.RCCallMediaType.AUDIO:r,s=e.listener,a=e.constraints,l=e.channelId,c=void 0===l?"":l,u=e.extra,d=void 0===u?"":u,C=e.pushTitle,_=void 0===C?"":C,h=e.pushContent,p=void 0===h?"":h,f=e.bitrate;return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.__call({targetId:t,mediaType:n,listener:s,constraints:a,channelId:c,extra:d,pushTitle:_,pushContent:p,bitrate:f})]}))}))}}),Object.defineProperty(r.prototype,"__call",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.targetId,r=e.mediaType,n=void 0===r?exports.RCCallMediaType.AUDIO:r,s=e.listener,a=e.constraints,l=e.channelId,c=void 0===l?"":l,u=e.extra,d=void 0===u?"":u,C=e.pushTitle,_=void 0===C?"":C,h=e.pushContent,p=void 0===h?"":h,f=e.bitrate,g=e.isCrossAppkey,R=void 0!==g&&g;return o(this,void 0,void 0,(function(){var e,r,o,l,u,C,h,g,b,E,I,y,m,v;return i(this,(function(i){switch(i.label){case 0:if(e=this._callPushConfig?this._callPushConfig:{pushTitle:_,pushContent:p},this._logger.info("_","[RCCallClient call] extra->".concat(d," pushConfig->").concat(JSON.stringify(e))),r=[H(t),V(n),k(s),G(d)],o=[],!r.every((function(e){return!e.result&&o.push(e.msg),e.result})))throw new Error("[RCCallClient call] ".concat(o.join("\n")));return l=B(e),u=l.code,C=l.errorMsg,u!==exports.RCCallErrorCode.SUCCESS?(this._logger.error("_","[RCCallClient call] param error, errorMsg: ".concat(C)),[2,{code:u}]):(h=[],[4,this._getLocalTrack(n,a)]);case 1:return g=i.sent(),b=g.code,E=g.tracks,b!==exports.RCCallErrorCode.SUCCESS?[2,{code:b}]:((h=E).forEach((function(e){var t,r,n;e.isAudioTrack()&&(null==f?void 0:f.audio)&&e.setBitrate(null==f?void 0:f.audio),e.isVideoTrack()&&(null==f?void 0:f.video)&&e.setBitrate(null===(t=null==f?void 0:f.video)||void 0===t?void 0:t.max,null===(r=null==f?void 0:f.video)||void 0===r?void 0:r.min,null===(n=null==f?void 0:f.video)||void 0===n?void 0:n.start),s.onTrackReady(e)})),[4,this._callEngine.call(c,t,n,d,e,R)]);case 2:return I=i.sent(),y=I.code,m=I.stateMachine,y===exports.RCCallErrorCode.SUCCESS&&m?(this._logger.info("_","[RCCallClient call] successfully created state machine"),(v=new z(m,this._rtcClient,this._logger,{localTracks:h,isAllowSubscribeRetry:this._options.isAllowSubscribeRetry,isAllowPublishRetry:this._options.isAllowPublishRetry,isOffCameraWhenVideoDisable:this._options.isOffCameraWhenVideoDisable,joinType:this._options.joinType,isAllowDemotionGetStream:this._options.isAllowDemotionGetStream,produceType:w.CALLER,isCrossAppkey:R,callPushConfig:this._callPushConfig,hungupPushConfig:this._hungupPushConfig})).registerSessionListener(s),this._sessionList.push(v),this._logger.info("_","[RCCallClient call] successfully created session object, sessionId: ".concat(v.getSessionId())),[2,{code:y,session:v}]):(this._logger.error("_","[RCCallClient call] call failed code ->: ".concat(y)),h.forEach((function(e){e.mute(),e.destroy()})),[2,{code:y}])}}))}))}}),Object.defineProperty(r.prototype,"callInGroup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.targetId,r=e.userIds,n=e.mediaType,s=void 0===n?exports.RCCallMediaType.AUDIO:n,a=e.listener,l=e.constraints,c=e.channelId,u=void 0===c?"":c,d=e.extra,C=void 0===d?"":d,_=e.pushTitle,h=void 0===_?"":_,p=e.pushContent,f=void 0===p?"":p,g=e.bitrate;return o(this,void 0,void 0,(function(){var e,n,o,c,d,_,p,R,b,E,I,y,m,v;return i(this,(function(i){switch(i.label){case 0:if(e=this._callPushConfig?this._callPushConfig:{pushTitle:h,pushContent:f},n=[H(t),W(r),V(s),k(a),G(C)],o=[],!n.every((function(e){return!e.result&&o.push(e.msg),e.result})))throw new Error("[RCCallClient callInGroup] ".concat(o.join("\n")));return c=B(e),d=c.code,_=c.errorMsg,d!==exports.RCCallErrorCode.SUCCESS?(this._logger.error("_","[RCCallClient call] param error, errorMsg: ".concat(_)),[2,{code:d}]):(p=[],[4,this._getLocalTrack(s,l)]);case 1:return R=i.sent(),b=R.code,E=R.tracks,b!==exports.RCCallErrorCode.SUCCESS?[2,{code:b}]:((p=E).forEach((function(e){var t,r,n;e.isAudioTrack()&&(null==g?void 0:g.audio)&&e.setBitrate(null==g?void 0:g.audio),e.isVideoTrack()&&(null==g?void 0:g.video)&&e.setBitrate(null===(t=null==g?void 0:g.video)||void 0===t?void 0:t.max,null===(r=null==g?void 0:g.video)||void 0===r?void 0:r.min,null===(n=null==g?void 0:g.video)||void 0===n?void 0:n.start),a.onTrackReady(e)})),[4,this._callEngine.callInGroup(u,t,s,r,C,e)]);case 2:return I=i.sent(),y=I.code,m=I.stateMachine,y===exports.RCCallErrorCode.SUCCESS&&m?(this._logger.info("_","[RCCallClient callInGroup] successfully created state machine"),(v=new z(m,this._rtcClient,this._logger,{localTracks:p,isAllowSubscribeRetry:this._options.isAllowSubscribeRetry,isAllowPublishRetry:this._options.isAllowPublishRetry,isOffCameraWhenVideoDisable:this._options.isOffCameraWhenVideoDisable,joinType:this._options.joinType,isAllowDemotionGetStream:this._options.isAllowDemotionGetStream,produceType:w.CALLER,callPushConfig:this._callPushConfig,hungupPushConfig:this._hungupPushConfig})).registerSessionListener(a),this._sessionList.push(v),this._logger.info("_","[RCCallClient callInGroup] successfully created session object, sessionId: ".concat(v.getSessionId())),[2,{code:y,session:v}]):(this._logger.info("_","[RCCallClient callInGroup] callInGroup failed code -> ".concat(y)),p.forEach((function(e){e.mute(),e.destroy()})),[2,{code:y}])}}))}))}}),Object.defineProperty(r.prototype,"_getLocalTrackCore",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){return o(this,void 0,void 0,(function(){var o,s,a,l,c,u;return i(this,(function(i){switch(i.label){case 0:return e!==exports.RCCallMediaType.AUDIO?[3,2]:[4,this._rtcClient.createMicrophoneAudioTrack("RongCloudRTC",r&&r.audio&&n({},r.audio))];case 1:return o=i.sent(),s=o.code,a=o.track,s!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallClient _getTrack] get Audio local tracks failed RCT code -> ".concat(s)),[2,{code:exports.RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR}]):(this._logger.info("_","[RCCallClient _getTrack] successfully get Audio local tracks"),[2,{code:exports.RCCallErrorCode.SUCCESS,tracks:[a]}]);case 2:return[4,this._rtcClient.createMicrophoneAndCameraTracks("RongCloudRTC",r&&n({},r))];case 3:return l=i.sent(),c=l.code,u=l.tracks,c!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallClient _getTrack] get Audio and Video local tracks failed RCT code -> ".concat(c)),[2,{code:exports.RCCallErrorCode.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR}]):(this._logger.info("_","[RCCallClient _getTrack] successfully get audio and video local tracks"),[2,{code:exports.RCCallErrorCode.SUCCESS,tracks:u}])}}))}))}}),Object.defineProperty(r.prototype,"_getLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return o(this,void 0,void 0,(function(){var r,n,o,s,a,l,c,u,d;return i(this,(function(i){switch(i.label){case 0:return this._options.isAllowDemotionGetStream&&e===exports.RCCallMediaType.AUDIO_VIDEO?[4,this._getLocalTrackCore(exports.RCCallMediaType.AUDIO_VIDEO,t)]:[3,4];case 1:return r=i.sent(),n=r.code,o=r.tracks,n===exports.RCCallErrorCode.SUCCESS?[3,3]:[4,this._getLocalTrackCore(exports.RCCallMediaType.AUDIO,t)];case 2:return s=i.sent(),a=s.code,l=s.tracks,a!==exports.RCCallErrorCode.SUCCESS?[2,{code:a}]:[2,{code:a,tracks:l}];case 3:return[2,{code:n,tracks:o}];case 4:return[4,this._getLocalTrackCore(e,t)];case 5:return c=i.sent(),u=c.code,d=c.tracks,u!==exports.RCCallErrorCode.SUCCESS?[2,{code:u}]:[2,{code:u,tracks:d}]}}))}))}}),Object.defineProperty(r.prototype,"_removeSession",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.getSessionId();this._sessionList=this._sessionList.filter((function(e){return e.getSessionId()!==t}))}}),Object.defineProperty(r.prototype,"getJoinedRoomInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return o(this,void 0,void 0,(function(){var t,r,n;return i(this,(function(o){switch(o.label){case 0:return[4,this._context.getRTCJoinedUserInfo(this._context.getCurrentId())];case 1:return t=o.sent(),r=t.code,n=t.data,r!==e.ErrorCode.SUCCESS?(this._logger.error("_","getJoinedUserInfo error code: ".concat(r)),[2,{code:exports.RCCallErrorCode.QUERY_JOINED_USER_INFO_ERROR}]):[2,{code:exports.RCCallErrorCode.SUCCESS,data:n}]}}))}))}}),Object.defineProperty(r.prototype,"setPushConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){for(var r=0,n=[e,t].map((function(e){return B(e)}));r<n.length;r++){var o=n[r],i=o.code,s=o.errorMsg;if(i!==exports.RCCallErrorCode.SUCCESS)return this._logger.error("_","[RCCallClient setPushConfig] param error, errorMsg: ".concat(s)),{code:i}}this._callPushConfig=e,this._hungupPushConfig=t}}),r}();e.VersionManage.add("plugin-call","5.2.6");var X={tag:"RCCall",verify:function(e){return"browser"===e.tag},setup:function(t,r,n){var o=D(n);if(!o.result)throw new Error("[RCCallLib installer steup]".concat(o.msg));if(!e.VersionManage.validEngine("5.9.0"))throw new Error("The current engine version '".concat(e.VersionManage.getInfo().engine,"' error, plugin-call required engine version at least '").concat("5.9.0","'."));var i=t.createLogger("RCCall","RTC");return n.logOutputLevel&&i.setOutputLevel(n.logOutputLevel),void 0!==n.logLevel&&i.warn("_","The 'logLevel' parameter is deprecated, please use 'logOutputLevel' instead."),i.warn("_","RCCall Version: ".concat("5.2.6",", Commit: ").concat("6761942c405d068867e89ca6c16d888599154bde")),new q(t,r,i,n)}};exports.RCCallClient=q,exports.RCCallSession=z,exports.installer=X;
|
package/dist/index.d.ts
CHANGED
|
@@ -88,7 +88,11 @@ declare enum RCCallErrorCode {
|
|
|
88
88
|
/**
|
|
89
89
|
* 参数错误
|
|
90
90
|
*/
|
|
91
|
-
PARAM_ERROR = 53313
|
|
91
|
+
PARAM_ERROR = 53313,
|
|
92
|
+
/**
|
|
93
|
+
* 缺少本地音频流
|
|
94
|
+
*/
|
|
95
|
+
MISSING_AUDIO_TRACK_ERROR = 53314
|
|
92
96
|
}
|
|
93
97
|
|
|
94
98
|
/**
|
|
@@ -462,13 +466,13 @@ declare class RCCallSession {
|
|
|
462
466
|
*/
|
|
463
467
|
disableAudioTrack(): Promise<{
|
|
464
468
|
code: RCCallErrorCode;
|
|
465
|
-
}
|
|
469
|
+
}>;
|
|
466
470
|
/**
|
|
467
471
|
* 启用音频track
|
|
468
472
|
*/
|
|
469
473
|
enableAudioTrack(): Promise<{
|
|
470
474
|
code: RCCallErrorCode;
|
|
471
|
-
}
|
|
475
|
+
}>;
|
|
472
476
|
/**
|
|
473
477
|
* 销毁本地流
|
|
474
478
|
*/
|
|
@@ -639,56 +643,56 @@ interface ISessionListener {
|
|
|
639
643
|
/**
|
|
640
644
|
* 当对方已响铃
|
|
641
645
|
*/
|
|
642
|
-
onRinging
|
|
646
|
+
onRinging(sender: ISender, session: RCCallSession): void;
|
|
643
647
|
/**
|
|
644
648
|
* 当对方已同意
|
|
645
649
|
*/
|
|
646
|
-
onAccept
|
|
650
|
+
onAccept(sender: ISender, session: RCCallSession): void;
|
|
647
651
|
/**
|
|
648
652
|
* 当对方已挂断
|
|
649
653
|
*/
|
|
650
|
-
onHungup
|
|
654
|
+
onHungup(sender: ISender, reason: RCCallEndReason, session: RCCallSession): void;
|
|
651
655
|
/**
|
|
652
656
|
* 群组通话,人员改变
|
|
653
657
|
*/
|
|
654
|
-
onMemberModify
|
|
658
|
+
onMemberModify(sender: ISender, invitedUsers: IInvitedUsers[], session: RCCallSession): void;
|
|
655
659
|
/**
|
|
656
660
|
* 通话降级
|
|
657
661
|
*/
|
|
658
|
-
onMediaModify
|
|
662
|
+
onMediaModify(sender: ISender, mediaType: RCCallMediaType, session: RCCallSession): void;
|
|
659
663
|
/**
|
|
660
664
|
* 当接到流
|
|
661
665
|
*/
|
|
662
|
-
onTrackReady
|
|
666
|
+
onTrackReady(track: RCTrack, session?: RCCallSession): void;
|
|
663
667
|
/**
|
|
664
668
|
* 关闭 或 开启 音频
|
|
665
669
|
*/
|
|
666
|
-
onAudioMuteChange
|
|
670
|
+
onAudioMuteChange(muteUser: IMuteUser, session: RCCallSession): void;
|
|
667
671
|
/**
|
|
668
672
|
* 关闭 或 开启 视频
|
|
669
673
|
*/
|
|
670
|
-
onVideoMuteChange
|
|
674
|
+
onVideoMuteChange(muteUser: IMuteUser, session: RCCallSession): void;
|
|
671
675
|
/**
|
|
672
676
|
* 资源订阅失败
|
|
673
677
|
*/
|
|
674
|
-
onTrackSubscribeFail
|
|
678
|
+
onTrackSubscribeFail?(code: RCRTCCode, session: RCCallSession): void;
|
|
675
679
|
/**
|
|
676
680
|
* 资源发布失败
|
|
677
681
|
*/
|
|
678
|
-
onTrackPublishFail
|
|
682
|
+
onTrackPublishFail?(code: RCRTCCode, session: RCCallSession): void;
|
|
679
683
|
/**
|
|
680
684
|
* 用于接收RTC状态数据报告
|
|
681
685
|
*/
|
|
682
|
-
onRTCStateReport
|
|
686
|
+
onRTCStateReport?(report: IRCRTCStateReport, session: RCCallSession): void;
|
|
683
687
|
/**
|
|
684
688
|
* RTC 每次 Ping 结果
|
|
685
689
|
*/
|
|
686
|
-
onPing
|
|
690
|
+
onPing?(result: RCRTCPingResult, session: RCCallSession): void;
|
|
687
691
|
/**
|
|
688
692
|
* ~ICE 连接状态变更通知~
|
|
689
693
|
* @since version 5.1.5
|
|
690
694
|
*/
|
|
691
|
-
onICEConnectionStateChange
|
|
695
|
+
onICEConnectionStateChange?(state: RTCIceConnectionState, session: RCCallSession): void;
|
|
692
696
|
}
|
|
693
697
|
/**
|
|
694
698
|
* 创建session的options
|
|
@@ -776,10 +780,12 @@ interface IRCCallParams {
|
|
|
776
780
|
extra?: string;
|
|
777
781
|
/**
|
|
778
782
|
* 对方显示通知的标题
|
|
783
|
+
* @deprecated - version 5.1.2
|
|
779
784
|
*/
|
|
780
785
|
pushTitle?: string;
|
|
781
786
|
/**
|
|
782
787
|
* 对方显示的通知内容
|
|
788
|
+
* @deprecated - version 5.1.2
|
|
783
789
|
*/
|
|
784
790
|
pushContent?: string;
|
|
785
791
|
/**
|
|
@@ -823,10 +829,12 @@ interface IRCCallInGroupParams {
|
|
|
823
829
|
extra?: string;
|
|
824
830
|
/**
|
|
825
831
|
* 对方显示通知的标题
|
|
832
|
+
* @deprecated - version 5.1.2
|
|
826
833
|
*/
|
|
827
834
|
pushTitle?: string;
|
|
828
835
|
/**
|
|
829
836
|
* 对方显示的通知内容
|
|
837
|
+
* @deprecated - version 5.1.2
|
|
830
838
|
*/
|
|
831
839
|
pushContent?: string;
|
|
832
840
|
/**
|
|
@@ -837,10 +845,6 @@ interface IRCCallInGroupParams {
|
|
|
837
845
|
audio?: number;
|
|
838
846
|
};
|
|
839
847
|
}
|
|
840
|
-
interface IDeviceChangeParams {
|
|
841
|
-
audio?: IMicphoneAudioProfile;
|
|
842
|
-
video?: ICameraVideoProfile;
|
|
843
|
-
}
|
|
844
848
|
|
|
845
849
|
interface IEndSummary {
|
|
846
850
|
/**
|
|
@@ -1559,8 +1563,6 @@ declare class RCCallClient {
|
|
|
1559
1563
|
* @param params.constraints 获取音频或音视频资源时的参数 可选
|
|
1560
1564
|
* @param params.channelId 组织 Id 可选
|
|
1561
1565
|
* @param params.extra 消息扩展信息
|
|
1562
|
-
* @deprecated 5.1.2 版本废弃 params.pushTitle 通知的标题
|
|
1563
|
-
* @deprecated 5.1.2 版本废弃 params.pushContent 通知的内容
|
|
1564
1566
|
* @param params.bitrate 需要设置的码率参数
|
|
1565
1567
|
*
|
|
1566
1568
|
*/
|
|
@@ -1576,8 +1578,6 @@ declare class RCCallClient {
|
|
|
1576
1578
|
* @param params.constraints 获取音频或音视频资源时的参数 可选
|
|
1577
1579
|
* @param params.channelId 组织 Id 可选
|
|
1578
1580
|
* @param params.extra 消息扩展信息
|
|
1579
|
-
* @deprecated 5.1.2 版本废弃 params.pushTitle 通知的标题
|
|
1580
|
-
* @deprecated 5.1.2 版本废弃 params.pushContent 通知的内容
|
|
1581
1581
|
* @param params.bitrate 需要设置的码率参数
|
|
1582
1582
|
*
|
|
1583
1583
|
*/
|
|
@@ -1595,8 +1595,6 @@ declare class RCCallClient {
|
|
|
1595
1595
|
* @param params.constraints 获取音频或音视频资源时的参数 可选
|
|
1596
1596
|
* @param params.channelId 组织 Id 可选
|
|
1597
1597
|
* @param params.extra 消息扩展信息 可选
|
|
1598
|
-
* @deprecated 5.1.2 版本废弃 params.pushTitle 通知的标题
|
|
1599
|
-
* @deprecated 5.1.2 版本废弃 params.pushContent 通知的内容
|
|
1600
1598
|
* @param params.bitrate 需要设置的码率参数
|
|
1601
1599
|
*/
|
|
1602
1600
|
callInGroup({ targetId, userIds, mediaType, listener, constraints, channelId, extra, pushTitle, pushContent, bitrate, }: IRCCallInGroupParams): Promise<{
|
|
@@ -1626,10 +1624,10 @@ declare class RCCallClient {
|
|
|
1626
1624
|
* @description callLib 会内置 IPushConfig 中 pushData 的赋值,业务层无需关注 pushData 字段值
|
|
1627
1625
|
*/
|
|
1628
1626
|
setPushConfig(callPushConfig: IPushConfig, hungupPushConfig: IPushConfig): {
|
|
1629
|
-
code: RCCallErrorCode.STATE_MACHINE_EXIT | RCCallErrorCode.SEND_MSG_ERROR | RCCallErrorCode.REJECTED_BY_BLACKLIST | RCCallErrorCode.NOT_IN_GROUP | RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR | RCCallErrorCode.GET_LOCAL_VIDEO_TRACK_ERROR | RCCallErrorCode.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR | RCCallErrorCode.JOIN_ROOM_ERROR | RCCallErrorCode.AUDIO_PUBLISH_ERROR | RCCallErrorCode.VIDEO_PUBLISH_ERROR | RCCallErrorCode.AUDIO_AND_VIDEO_PUBLISH_ERROR | RCCallErrorCode.QUERY_JOINED_USER_INFO_ERROR | RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR | RCCallErrorCode.UNPUBLISH_VIDEO_ERROR | RCCallErrorCode.CONVERSATION_NOT_GROUP_ERROR | RCCallErrorCode.NOT_IN_ROOM_ERROR | RCCallErrorCode.PARAM_ERROR;
|
|
1627
|
+
code: RCCallErrorCode.STATE_MACHINE_EXIT | RCCallErrorCode.SEND_MSG_ERROR | RCCallErrorCode.REJECTED_BY_BLACKLIST | RCCallErrorCode.NOT_IN_GROUP | RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR | RCCallErrorCode.GET_LOCAL_VIDEO_TRACK_ERROR | RCCallErrorCode.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR | RCCallErrorCode.JOIN_ROOM_ERROR | RCCallErrorCode.AUDIO_PUBLISH_ERROR | RCCallErrorCode.VIDEO_PUBLISH_ERROR | RCCallErrorCode.AUDIO_AND_VIDEO_PUBLISH_ERROR | RCCallErrorCode.QUERY_JOINED_USER_INFO_ERROR | RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR | RCCallErrorCode.UNPUBLISH_VIDEO_ERROR | RCCallErrorCode.CONVERSATION_NOT_GROUP_ERROR | RCCallErrorCode.NOT_IN_ROOM_ERROR | RCCallErrorCode.PARAM_ERROR | RCCallErrorCode.MISSING_AUDIO_TRACK_ERROR;
|
|
1630
1628
|
} | undefined;
|
|
1631
1629
|
}
|
|
1632
1630
|
|
|
1633
1631
|
declare const installer: IPluginGenerator<RCCallClient, IRCCallInitOptions>;
|
|
1634
1632
|
|
|
1635
|
-
export {
|
|
1633
|
+
export { IEndSummary, IInvitedUsers, IMediaStreamConstraints, IMuteUser, IOfflineRecord, IPushConfig, IRCCallInGroupParams, IRCCallInitOptions, IRCCallParams, ISenderInfo, ISessionListener, RCCallClient, RCCallEndReason, RCCallErrorCode, RCCallLanguage, RCCallMediaType, RCCallSession, RCCallSessionState, RCCallUserState, installer };
|