@rongcloud/plugin-call 5.2.10 → 5.2.12
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 +2 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.esm.js +2 -2
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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 o=function(){return o=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},o.apply(this,arguments)};function n(e,t,r,o){return new(r||(r=Promise))((function(n,i){function
|
|
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 o=function(){return o=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},o.apply(this,arguments)};function n(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))}function i(e,t){var r,o,n,i,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[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,o&&(n=2&a[0]?o.return:a[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,a[1])).done)return n;switch(o=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,o=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){s.label=a[1];break}if(6===a[0]&&s.label<n[1]){s.label=n[1],n=a;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(a);break}n[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],o=0}finally{r=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}}function s(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var o,n,i=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(o=i.next()).done;)s.push(o.value)}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return s}function a(e,t,r){if(r||2===arguments.length)for(var o,n=0,i=t.length;n<i;n++)!o&&n in t||(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var l,c,u,d,C=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,o=+e,n=[];do{var i=o%r;o=(o-i)/r,n.unshift(t[i])}while(o);return n.join("")}(e=parseInt(e,16))).length>22&&(e=e.slice(0,22)),e},_=function(){var e=Math.floor(1e3*Math.random()),t=C();return[t=t.replace(/\//g,"0"),Date.now(),e].join("_")},h=new e.EventEmitter,f=function(e){var t="RCCallDeviceId",r=e.sessionStorage.getItem(t);return r||(r=C(),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"}(l||(l={})),exports.RCCallErrorCode=void 0,(c=exports.RCCallErrorCode||(exports.RCCallErrorCode={}))[c.SUCCESS=1e4]="SUCCESS",c[c.STATE_MACHINE_EXIT=53200]="STATE_MACHINE_EXIT",c[c.SEND_MSG_ERROR=53201]="SEND_MSG_ERROR",c[c.REJECTED_BY_BLACKLIST=53202]="REJECTED_BY_BLACKLIST",c[c.NOT_IN_GROUP=53203]="NOT_IN_GROUP",c[c.GET_LOCAL_AUDIO_TRACK_ERROR=53301]="GET_LOCAL_AUDIO_TRACK_ERROR",c[c.GET_LOCAL_VIDEO_TRACK_ERROR=53302]="GET_LOCAL_VIDEO_TRACK_ERROR",c[c.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR=53303]="GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR",c[c.JOIN_ROOM_ERROR=53304]="JOIN_ROOM_ERROR",c[c.AUDIO_PUBLISH_ERROR=53305]="AUDIO_PUBLISH_ERROR",c[c.VIDEO_PUBLISH_ERROR=53306]="VIDEO_PUBLISH_ERROR",c[c.AUDIO_AND_VIDEO_PUBLISH_ERROR=53307]="AUDIO_AND_VIDEO_PUBLISH_ERROR",c[c.QUERY_JOINED_USER_INFO_ERROR=53308]="QUERY_JOINED_USER_INFO_ERROR",c[c.MISSING_VIDEO_TRACK_ERROR=53309]="MISSING_VIDEO_TRACK_ERROR",c[c.UNPUBLISH_VIDEO_ERROR=53310]="UNPUBLISH_VIDEO_ERROR",c[c.CONVERSATION_NOT_GROUP_ERROR=53311]="CONVERSATION_NOT_GROUP_ERROR",c[c.NOT_IN_ROOM_ERROR=53312]="NOT_IN_ROOM_ERROR",c[c.PARAM_ERROR=53313]="PARAM_ERROR",c[c.MISSING_AUDIO_TRACK_ERROR=53314]="MISSING_AUDIO_TRACK_ERROR",c[c.SESSION_ENDED=53315]="SESSION_ENDED",exports.RCCallEndReason=void 0,(d=exports.RCCallEndReason||(exports.RCCallEndReason={}))[d.CANCEL=1]="CANCEL",d[d.REJECT=2]="REJECT",d[d.HANGUP=3]="HANGUP",d[d.BUSY_LINE=4]="BUSY_LINE",d[d.NO_RESPONSE=5]="NO_RESPONSE",d[d.ENGINE_UNSUPPORTED=6]="ENGINE_UNSUPPORTED",d[d.NETWORK_ERROR=7]="NETWORK_ERROR",d[d.GET_MEDIA_RESOURCES_ERROR=8]="GET_MEDIA_RESOURCES_ERROR",d[d.PUBLISH_ERROR=9]="PUBLISH_ERROR",d[d.SUBSCRIBE_ERROR=10]="SUBSCRIBE_ERROR",d[d.REMOTE_CANCEL=11]="REMOTE_CANCEL",d[d.REMOTE_REJECT=12]="REMOTE_REJECT",d[d.REMOTE_HANGUP=13]="REMOTE_HANGUP",d[d.REMOTE_BUSY_LINE=14]="REMOTE_BUSY_LINE",d[d.REMOTE_NO_RESPONSE=15]="REMOTE_NO_RESPONSE",d[d.REMOTE_ENGINE_UNSUPPORTED=16]="REMOTE_ENGINE_UNSUPPORTED",d[d.REMOTE_NETWORK_ERROR=17]="REMOTE_NETWORK_ERROR",d[d.REMOTE_GET_MEDIA_RESOURCE_ERROR=18]="REMOTE_GET_MEDIA_RESOURCE_ERROR",d[d.REMOTE_PUBLISH_ERROR=19]="REMOTE_PUBLISH_ERROR",d[d.REMOTE_SUBSCRIBE_ERROR=20]="REMOTE_SUBSCRIBE_ERROR",d[d.OTHER_CLIENT_JOINED_CALL=21]="OTHER_CLIENT_JOINED_CALL",d[d.OTHER_CLIENT_IN_CALL=22]="OTHER_CLIENT_IN_CALL",d[d.KICKED_BY_SERVER=23]="KICKED_BY_SERVER",d[d.ACCEPT_SYSTEM_CALL=24]="ACCEPT_SYSTEM_CALL",d[d.REMOTE_OTHER_CLIENT_JOINED_CALL=31]="REMOTE_OTHER_CLIENT_JOINED_CALL",d[d.REMOTE_OTHER_CLIENT_IN_CALL=32]="REMOTE_OTHER_CLIENT_IN_CALL",d[d.REMOTE_KICKED_BY_SERVER=33]="REMOTE_KICKED_BY_SERVER",d[d.REMOTE_ACCEPT_SYSTEM_CALL=34]="REMOTE_ACCEPT_SYSTEM_CALL",d[d.ACCEPT_BY_OTHER_CLIENT=101]="ACCEPT_BY_OTHER_CLIENT",d[d.HANGUP_BY_OTHER_CLIENT=102]="HANGUP_BY_OTHER_CLIENT",d[d.ADDED_TO_BLACKLIST=103]="ADDED_TO_BLACKLIST",d[d.SERVICE_NOT_OPENED=104]="SERVICE_NOT_OPENED";var p,R,g,b,E=((u={})[exports.RCCallEndReason.CANCEL]=exports.RCCallEndReason.REMOTE_CANCEL,u[exports.RCCallEndReason.REJECT]=exports.RCCallEndReason.REMOTE_REJECT,u[exports.RCCallEndReason.HANGUP]=exports.RCCallEndReason.REMOTE_HANGUP,u[exports.RCCallEndReason.BUSY_LINE]=exports.RCCallEndReason.REMOTE_BUSY_LINE,u[exports.RCCallEndReason.NO_RESPONSE]=exports.RCCallEndReason.REMOTE_NO_RESPONSE,u[exports.RCCallEndReason.ENGINE_UNSUPPORTED]=exports.RCCallEndReason.REMOTE_ENGINE_UNSUPPORTED,u[exports.RCCallEndReason.NETWORK_ERROR]=exports.RCCallEndReason.REMOTE_NETWORK_ERROR,u[exports.RCCallEndReason.GET_MEDIA_RESOURCES_ERROR]=exports.RCCallEndReason.REMOTE_GET_MEDIA_RESOURCE_ERROR,u[exports.RCCallEndReason.PUBLISH_ERROR]=exports.RCCallEndReason.REMOTE_PUBLISH_ERROR,u[exports.RCCallEndReason.SUBSCRIBE_ERROR]=exports.RCCallEndReason.REMOTE_SUBSCRIBE_ERROR,u[exports.RCCallEndReason.OTHER_CLIENT_JOINED_CALL]=exports.RCCallEndReason.REMOTE_OTHER_CLIENT_JOINED_CALL,u[exports.RCCallEndReason.OTHER_CLIENT_IN_CALL]=exports.RCCallEndReason.REMOTE_OTHER_CLIENT_IN_CALL,u[exports.RCCallEndReason.KICKED_BY_SERVER]=exports.RCCallEndReason.REMOTE_KICKED_BY_SERVER,u[exports.RCCallEndReason.REMOTE_NO_RESPONSE]=exports.RCCallEndReason.NO_RESPONSE,u[exports.RCCallEndReason.ACCEPT_SYSTEM_CALL]=exports.RCCallEndReason.REMOTE_ACCEPT_SYSTEM_CALL,u);!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,(R=exports.RCCallSessionState||(exports.RCCallSessionState={}))[R.WAITING=0]="WAITING",R[R.KEEPING=1]="KEEPING",R[R.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
2
|
/*!
|
|
3
3
|
同App通话
|
|
4
4
|
*/
|
|
@@ -6,4 +6,4 @@ e[e.RCCallRoomTypeNormalCall=0]="RCCallRoomTypeNormalCall",
|
|
|
6
6
|
/*!
|
|
7
7
|
跨App通话
|
|
8
8
|
*/
|
|
9
|
-
e[e.RCCallRoomTypeAcrossCall=7]="RCCallRoomTypeAcrossCall"}(b||(b={}));var I,y,m,v=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}(),O=function(){function t(e,t,r,o,n,i,a,s,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:o}),Object.defineProperty(this,"_channelId",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_conversationType",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_targetId",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"_mediaType",{enumerable:!0,configurable:!0,writable:!0,value:s}),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&&(h.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,o=r.user,n=r.reason,i=e.messageType;for(var a in this._userInfo[t]={userId:t,state:exports.RCCallUserState.NONE,isCaller:!1,isRemote:!1},this._userTimers)this._clearTimerById(a);var s=exports.RCCallEndReason.ACCEPT_BY_OTHER_CLIENT;i===p.VCHangup&&(s=n===exports.RCCallEndReason.BUSY_LINE?exports.RCCallEndReason.OTHER_CLIENT_IN_CALL:n===exports.RCCallEndReason.NO_RESPONSE?exports.RCCallEndReason.NO_RESPONSE:exports.RCCallEndReason.HANGUP_BY_OTHER_CLIENT),Object.assign(this._userInfo[t],o),this._notifyUserStateChange(this._userInfo[t],s),this._notifyStateChange(exports.RCCallSessionState.END,s)}}),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,n=r.user,i=r.deviceId,a=this._isCrossAppkey?t.split("_")[1]:t;this._isRemoteInvalidMsg(a,i)?this._logger.debug("_","[RCCallStateMachine] onRinging -> not the remote device that is currently talking"):this._context.getCurrentId()!==a&&this._watchers.onRinging(o({userId:a},n))}}),Object.defineProperty(t.prototype,"_onAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=this,o=t.senderUserId,n=t.content,i=n.user,a=n.deviceId;t.sentTime;var s=this._isCrossAppkey?o.split("_")[1]:o,l=this._context.getCurrentId();this._isRemoteInvalidMsg(s,a)?this._logger.debug("_","[RCCallStateMachine] _onAccept -> not the remote device that is currently talking"):l!==s?(this._userTimers[s]&&this._clearTimerById(s),(this._conversationType===e.ConversationType.PRIVATE?[l,s]:[s]).forEach((function(e){var t=e===l;r._userInfo[e]={userId:e,state:exports.RCCallUserState.KEEPING,isCaller:t,isRemote:t,deviceId:t?f(r._runtime):a},t||(r._beginTimestamp=Date.now(),Object.assign(r._userInfo[s],i)),r._notifyUserStateChange(r._userInfo[e])})),this.getCallerId()===l&&this._notifyStateChange(exports.RCCallSessionState.KEEPING),this._watchers.onAccept({userId:s})):this._otherClientHandle(t)}}),Object.defineProperty(t.prototype,"_onMediaModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,r=e.content,n=r.mediaType,i=r.user,a=r.deviceId;this._isRemoteInvalidMsg(t,a)?this._logger.debug("_","[RCCallStateMachine] _onMediaModify -> not the remote device that is currently talking"):this._context.getCurrentId()!==t&&(this._mediaType=n,this._watchers.onMediaModify({sender:o({userId:t},i),mediaType:n}))}}),Object.defineProperty(t.prototype,"_onHungup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,r=e.content,n=this._isCrossAppkey?t.split("_")[1]:t,i=r,a=i.reason,s=i.user,l=i.deviceId,c=this._context.getCurrentId();if(this._isRemoteInvalidMsg(n,l))this._logger.debug("_","[RCCallStateMachine] _onHungup -> not the remote device that is currently talking");else if(c!==n)if(this._sessionState!==exports.RCCallSessionState.END){this._userInfo[n]&&(this._userInfo[n].state=exports.RCCallUserState.NONE,this._endTimestamp=Date.now(),Object.assign(this._userInfo[n],s),this._notifyUserStateChange(this._userInfo[n],E[a]),delete this._userInfo[n]),E[a]===exports.RCCallEndReason.REMOTE_CANCEL?this.getRemoteUserIds().length<1&&this._clearTimerById(c):this.getInviterId()===c?this._clearTimerById(n):this.getRemoteUserIds().length<1&&this._clearTimerById(c);var u=Object.keys(this._userInfo).length<2,d=this._inviterId===n,C=Object.values(this._userInfo).every((function(e){return e.state!==exports.RCCallUserState.KEEPING}));(u||d&&C)&&this._notifyStateChange(exports.RCCallSessionState.END,E[a]),this._watchers.onHungup(o({userId:n},s),E[a])}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,o=this,n=e.senderUserId,i=e.content,l=e.sentTime,c=i,u=c.inviteUserIds,d=c.user,C=c.deviceId;c.roomType===b.RCCallRoomTypeAcrossCall?(t=a(n.split("_"),2),r=t[1],this._watchers.crossAppkey(!0),this._isCrossAppkey=!0):r=n;var _=this._context.getCurrentId();if(this._isRemoteInvalidMsg(r,C))this._logger.debug("_","[RCCallStateMachine] __onInvite -> not the remote device that is currently talking");else if(_!==r){this._callerId=this._inviterId=r;var h=s([n],a(u),!1);this._callMsgHandler.sendRinging({conversationType:this._conversationType,targetId:this._targetId,channelId:this._channelId,callId:this._callId,userIds:h.filter((function(e){return o._isCrossAppkey?e.split("_")[1]!==_:e!==_}))});var f=this._isCrossAppkey?[u[0].split("_")[1]]:u;s([r],a(f),!1).forEach((function(e){o._userInfo[e]={userId:e,state:exports.RCCallUserState.WAITING,isCaller:e===r,isRemote:e!==_},e===r&&Object.assign(o._userInfo[e],d,{deviceId:C}),o._notifyUserStateChange(o._userInfo[e]),e!==r&&(o._userTimers[e]=new v((function(){var t=e===_?exports.RCCallEndReason.NO_RESPONSE:exports.RCCallEndReason.REMOTE_NO_RESPONSE;e===_?o._hungupHandle(t,!1):(o._userInfo[e]&&(o._userInfo[e].state=exports.RCCallUserState.NONE),o._notifyUserStateChange(o._userInfo[e]),o._watchers.onHungup(o._userInfo[e],t),delete o._userInfo[e]),o._clearTimerById(e)}),o._getTimeout(l)))})),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,n=e.content,i=e.sentTime,a=n,s=a.user,c=a.existedUserPofiles,u=a.caller,d=a.deviceId,C=a.inviteUserIds,_=a.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:l.INCOMING})})),C.includes(h)){var f=[];c.forEach((function(e){e.userId!==h&&f.push(e.userId)})),this._callMsgHandler.sendRinging({conversationType:this._conversationType,targetId:this._targetId,channelId:this._channelId,callId:this._callId,userIds:f}),this._notifyStateChange(exports.RCCallSessionState.WAITING)}else this._watchers.onMemberModify({sender:o({userId:r},s),invitedUsers:C.map((function(e){return{userId:e}}))});c.forEach((function(e){var o=e.userId,n=e.callStatus;if(n!==l.IDLE&&(t._userInfo[o]={userId:o,state:n!==l.CONNECTED?exports.RCCallUserState.WAITING:exports.RCCallUserState.KEEPING,isCaller:r===o,isRemote:h!==o},o===r&&Object.assign(t._userInfo[o],s,{deviceId:d}),t._notifyUserStateChange(t._userInfo[o]),n!==l.CONNECTED&&!t._userTimers[o])){if(!C.includes(o))return;t._userTimers[o]=new v((function(){t._userInfo[o]&&(t._userInfo[o].state=exports.RCCallUserState.NONE);var e=o===h?exports.RCCallEndReason.NO_RESPONSE:exports.RCCallEndReason.REMOTE_NO_RESPONSE;t._notifyUserStateChange(t._userInfo[o],e);try{t._watchers.onHungup(t._userInfo[o],e)}catch(e){t._logger.error("_","[RCCallStateMachine] call onhungup error -> ".concat(null==e?void 0:e.stack))}delete t._userInfo[o],(Object.keys(t._userInfo).length<2||o===h)&&t._notifyStateChange(exports.RCCallSessionState.END,e),t._clearTimerById(o)}),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,o){return void 0===t&&(t=""),void 0===o&&(o=!1),n(this,void 0,void 0,(function(){var n,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))),n=this._callerId=this._inviterId=this._context.getCurrentId(),[4,this._callMsgHandler.sendInvite({roomType:o?b.RCCallRoomTypeAcrossCall:b.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!==n}))})];case 1:return l=i.sent(),c=l.code,u=l.message,this._isCrossAppkey=o,c===exports.RCCallErrorCode.SUCCESS?(d=u.sentTime,s([n],o?[e[0].split("_")[1]]:a(e),!1).forEach((function(e){var t=e===n;_._userInfo[e]={userId:e,state:exports.RCCallUserState.WAITING,isCaller:t,isRemote:!t},_._notifyUserStateChange(_._userInfo[e]),t||(_._userTimers[e]=new v((function(){_._userInfo[e]&&(_._userInfo[e].state=exports.RCCallUserState.NONE),_._notifyUserStateChange(_._userInfo[e],exports.RCCallEndReason.REMOTE_NO_RESPONSE),_._watchers.onHungup(_._userInfo[e],exports.RCCallEndReason.REMOTE_NO_RESPONSE),delete _._userInfo[e],Object.keys(_._userInfo).length<2&&_._notifyStateChange(exports.RCCallSessionState.END,exports.RCCallEndReason.REMOTE_NO_RESPONSE),0===_.getRemoteUserIds().length&&_._userInfo[n].state!==exports.RCCallUserState.KEEPING&&_._hungupHandle(exports.RCCallEndReason.REMOTE_NO_RESPONSE)}),_._getTimeout(d)))})),this._notifyStateChange(exports.RCCallSessionState.WAITING)):(C=c===exports.RCCallErrorCode.REJECTED_BY_BLACKLIST?exports.RCCallEndReason.ADDED_TO_BLACKLIST:exports.RCCallEndReason.NETWORK_ERROR,this._notifyStateChange(exports.RCCallSessionState.END,C)),[2,{code:c}]}}))}))}}),Object.defineProperty(t.prototype,"accept",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e,t,r,o,n;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,o=t.message,this._clearTimerById(e),r===exports.RCCallErrorCode.SUCCESS?(o.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]),n=r===exports.RCCallErrorCode.REJECTED_BY_BLACKLIST?exports.RCCallEndReason.ADDED_TO_BLACKLIST:exports.RCCallEndReason.NETWORK_ERROR,this._notifyStateChange(exports.RCCallSessionState.END,n)),[2,{code:r}]}}))}))}}),Object.defineProperty(t.prototype,"invite",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return void 0===r&&(r={}),n(this,void 0,void 0,(function(){var o,n,c,u,d,C,_,h,f,p,R,g=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.info("_","[RCCallStateMachine] invite -> userIds: ".concat(JSON.stringify(t))),o=this._context.getCurrentId(),n=Object.keys(this._userInfo),0===(c=t.filter((function(e){return e!==o&&!n.includes(e)}))).length?(this._logger.warn("_","[RCCallStateMachine] invite -> all userId is in calling now!"),[2,{code:exports.RCCallErrorCode.PARAM_ERROR}]):(u=n.map((function(e){var t=l.CONNECTED;return g._userInfo[e].state===exports.RCCallUserState.WAITING&&(t=l.RINGING),{userId:e,mediaType:g._mediaType,callStatus:t,mediaId:e}})),d=r.extra,C=void 0===d?"":d,_=r.pushConfig,[4,this._callMsgHandler.sendMemeberModify({channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,extra:C,pushConfig:_,mediaType:this._mediaType,inviteUserIds:c,callerId:this.getCallerId(),existedUserPofiles:u,directionalUserIdList:s(s([],a(n),!1),a(c),!1).filter((function(e){return e!==o}))})]));case 1:return h=i.sent(),f=h.code,p=h.message,f===exports.RCCallErrorCode.SUCCESS?(R=p.sentTime,c.forEach((function(e){g._userInfo[e]={userId:e,state:exports.RCCallUserState.WAITING,isCaller:!1,isRemote:!0},g._notifyUserStateChange(g._userInfo[e]),g._userTimers[e]=new v((function(){g._userInfo[e]&&(g._userInfo[e].state=exports.RCCallUserState.NONE),g._notifyUserStateChange(g._userInfo[e],exports.RCCallEndReason.REMOTE_NO_RESPONSE),g._watchers.onHungup(g._userInfo[e],exports.RCCallEndReason.REMOTE_NO_RESPONSE),delete g._userInfo[e],Object.keys(g._userInfo).length<2&&g._notifyStateChange(exports.RCCallSessionState.END,exports.RCCallEndReason.REMOTE_NO_RESPONSE)}),g._getTimeout(R))}))):c.forEach((function(e){g._userInfo[e]={userId:e,state:exports.RCCallUserState.NONE,isCaller:!1,isRemote:!0};var t=f===exports.RCCallErrorCode.REJECTED_BY_BLACKLIST?exports.RCCallEndReason.ADDED_TO_BLACKLIST:exports.RCCallEndReason.NETWORK_ERROR;g._notifyUserStateChange(g._userInfo[e],t)})),[2,{code:f}]}}))}))}}),Object.defineProperty(t.prototype,"_hungupHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===t&&(t=!0),n(this,void 0,void 0,(function(){var r,o,n,a,s;return i(this,(function(i){switch(i.label){case 0:return r=this._context.getCurrentId(),o=exports.RCCallErrorCode.SUCCESS,t?(n={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(n),[3,3])):[3,3];case 1:return[4,this._callMsgHandler.sendHungup(n)];case 2:a=i.sent().code,o=a,i.label=3;case 3:for(s in this._endTimestamp=Date.now(),this._userInfo)this._userInfo[s].state=exports.RCCallUserState.NONE,s===r?this._notifyUserStateChange(this._userInfo[s],e):this._notifyUserStateChange(this._userInfo[s]),delete this._userInfo[s];return Object.keys(this._userInfo).length<2&&this._notifyStateChange(exports.RCCallSessionState.END,e),[2,{code:o}]}}))}))}}),Object.defineProperty(t.prototype,"hungup",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e,t,r;return i(this,(function(o){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 n(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 v((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 o={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(o))),o}}),t}();exports.RCCallMediaType=void 0,(I=exports.RCCallMediaType||(exports.RCCallMediaType={}))[I.AUDIO=1]="AUDIO",I[I.AUDIO_VIDEO=2]="AUDIO_VIDEO",function(e){e[e.ADD=1]="ADD",e[e.REMOVE=2]="REMOVE"}(y||(y={})),function(e){e.WEB="Web",e.IOS="iOS",e.ANDROID="Android"}(m||(m={}));var T,S,M=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,o=e.targetId,n=e.senderUserId,i=e.content,a=i.callId,s=i.mediaType;this._channelId=t,this._conversationType=r,this._targetId=o,this._callId=a,this._mediaType=s;this._inviterId=n,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,o=e.senderUserId,n=t.reason,i=o===this._context.getCurrentId();this._endReason=i?n:E[n],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}(),x=["RC:VCAccept","RC:VCRinging","RC:VCSummary","RC:VCHangup","RC:VCInvite","RC:VCModifyMedia","RC:VCModifyMem"],P=((T={})[e.ErrorCode.REJECTED_BY_BLACKLIST]=exports.RCCallErrorCode.REJECTED_BY_BLACKLIST,T[e.ErrorCode.NOT_IN_GROUP]=exports.RCCallErrorCode.NOT_IN_GROUP,T),w=function(t){function o(e,r,o,n,i){void 0===n&&(n=6e4);var a=t.call(this)||this;return Object.defineProperty(a,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(a,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(a,"_offlineMsgItv",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"_getStateMachine",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(a,"_watchers",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(a,"_userInfo",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(a,"_msgBufferList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(a,"_hadHandleMsgTimer",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(a,"_offlineRecorder",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"_deviceId",{enumerable:!0,configurable:!0,writable:!0,value:""}),a._deviceId=f(r),a._context.onmessage=a._onMessage.bind(a),a._offlineRecorder=new M(a._context,a._logger,(function(e){a._logger.info("_","[CallMessageHandler] offlineRecorder -> ".concat(JSON.stringify(e))),a._watchers.onOfflineRecord&&a._watchers.onOfflineRecord(e)})),a}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 o(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}(o,t),Object.defineProperty(o.prototype,"_onMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(x.includes(e.messageType)){this._logger.debug("_","[CallMessageHandler] _onMessage -> call message: ".concat(JSON.stringify(e)));try{var t=Date.now(),r=e.sentTime,o=0;this._msgBufferList.forEach((function(e,t){var n=e.msg.sentTime;r>=n&&(o=t+1)})),this._msgBufferList.splice(o,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(o.prototype,"_onRecvOnlineCallMsg",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=e.content.callId;switch(this._logger.info("_","recv -> senderId: ".concat(e.senderUserId,", type: ").concat(e.messageType,", callId: ").concat(r)),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("_","recv -> unexpected message: ".concat(e.messageType))}}}),Object.defineProperty(o.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(),o=t._msgBufferList.filter((function(e){return r-e.markTime>=200}));if(t._logger.debug("_","[CallMessageHandler] handleBufferMsgs -> lists over 200ms : ".concat(JSON.stringify(o.map((function(e){var t=e.msg;return{messageUId:t.messageUId,isOffLineMessage:t.isOffLineMessage,callId:t.content.callId}}))))),0===o.length)return t._hadHandleMsgTimer=!1,void t._handleBufferMsgs();if(o[0].msg.isOffLineMessage){var n=t._msgBufferList.filter((function(e){return e.msg.isOffLineMessage})),i=function(){var r=n[0].msg,o=r.conversationType,i=r.messageType,l=r.sentTime,c=r.senderUserId,u=r.content,d=u.callId,C=u.inviteUserIds,_=[p.VCInvite,p.VCModifyMem].includes(i),h=t._context.getServerTime()-l,f=h<t._offlineMsgItv;if(f||t._logger.warn("_","offline msg delayTime: ".concat(h,"ms")),_){for(var R=[],g=0;g<n.length;g++){var b=n[g].msg;if(d!==b.content.callId)break;R.push(b)}if(t._logger.warn("_","taskMsgList length: ".concat(R.length)),R.length>0){var E=t._msgBufferList.findIndex((function(e){return e.msg.messageUId===R[R.length-1].messageUId}));t._msgBufferList=t._msgBufferList.slice(E+1);var I=n.findIndex((function(e){return e.msg.messageUId===R[R.length-1].messageUId}));n=n.slice(I+1)}var y=function(){if(o!==e.ConversationType.PRIVATE)return!1;var t=1===R.length,r=R.every((function(e){return[p.VCInvite,p.VCModifyMedia,p.VCRinging].includes(e.messageType)}));return t||r}(),m=function(){if(o!==e.ConversationType.GROUP)return!1;for(var r=!1,n=!0,i=s([c],a(C),!1),l=!1,u=function(e){var r=R[e],o=r.senderUserId,a=r.messageType;if(a===p.VCHangup&&o===t._context.getCurrentId())return"break";a===p.VCHangup&&(l=c===o,i=i.filter((function(e){return o!==e}))),a===p.VCAccept&&(n=!1)},d=0;d<R.length;d++){if("break"===u(d))break}return n&&l||!(i.length>1)||(r=!0),r}();f&&(y||m)&&R.forEach(t._onRecvOnlineCallMsg,t),t._offlineRecorder.onRecvOfflineMsgs(R)}else f&&t._getStateMachine(d)?t._onRecvOnlineCallMsg(n[0].msg):t._logger.debug("_","[CallMessageHandler] unexcepted offline msg -> ".concat(JSON.stringify(n[0].msg))),n.shift(),t._msgBufferList.shift()};do{i()}while(n.length>0)}else{o.forEach((function(e){var r=e.msg;t._onRecvOnlineCallMsg(r)}));var l=o.length;t._msgBufferList.splice(0,l),t._logger.debug("_","timer online msg handle -> delCount: ".concat(l," msgBufferList: ").concat(t._msgBufferList.length))}t._hadHandleMsgTimer=!1,t._handleBufferMsgs()}),20))}}),Object.defineProperty(o.prototype,"registerEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){Object.assign(this._watchers,e)}}),Object.defineProperty(o.prototype,"registerStateMachineEvent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,o){var n=e+r;t.prototype.on.call(this,n,o)}}),Object.defineProperty(o.prototype,"unregisterStateMachineEvent",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=this;["onRinging","onAccept","onHungup","onMediaModify"].forEach((function(o){var n=e+o;t.prototype.removeAll.call(r,n)}))}}),Object.defineProperty(o.prototype,"registerUserInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._userInfo=e}}),Object.defineProperty(o.prototype,"_sendCallMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return n(this,void 0,void 0,(function(){var r,o,n,a,s,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,o=t.conversationType,n=t.targetId,a=t.content,s=t.messageType,l=t.directionalUserIdList,c=t.pushConfig,u={channelId:r,messageType:s,content:a,directionalUserIdList:l},[p.VCInvite,p.VCModifyMem,p.VCHangup].includes(s)&&((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:a.callId}),d.disablePushTitle=!1,d.forceShowDetailContent=!1,u.pushConfig=d),[4,this._context.sendMessage(o,n,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:P[_]||exports.RCCallErrorCode.SEND_MSG_ERROR}]):[2,{code:exports.RCCallErrorCode.SUCCESS,message:h}]}}))}))}}),Object.defineProperty(o.prototype,"sendInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return n(this,void 0,void 0,(function(){var r,o,n,a,s,l,c,u,d,C;return i(this,(function(i){return r=t.roomType,o=t.channelId,n=t.conversationType,a=t.targetId,s=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:s}),C={platform:m.WEB,deviceId:this._deviceId,callId:s,roomType:r,extra:u,engineType:4,channelInfo:{Id:s,Key:""},mediaType:l,inviteUserIds:c,observerUserIds:[],user:this._userInfo},d&&(d.pushData=JSON.stringify({mediaType:l,userIdList:c,callId:s})),[2,this._sendCallMessage({channelId:o,conversationType:n,targetId:a,content:C,messageType:p.VCInvite,directionalUserIdList:n===e.ConversationType.GROUP?c:void 0,pushConfig:d})]}))}))}}),Object.defineProperty(o.prototype,"sendMemeberModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return n(this,void 0,void 0,(function(){var t,r,o,n,a,s,l,c,u,d,C,_;return i(this,(function(i){return t=e.channelId,r=e.conversationType,o=e.targetId,n=e.callId,a=e.mediaType,s=e.inviteUserIds,l=e.callerId,c=e.existedUserPofiles,u=e.directionalUserIdList,d=e.extra,C=e.pushConfig,_={platform:m.WEB,deviceId:this._deviceId,callId:n,extra:d,engineType:4,channelInfo:{Id:n,Key:""},mediaType:a,inviteUserIds:s,observerUserIds:[],user:this._userInfo,caller:l,modifyMemType:y.ADD,existedUserPofiles:c},C&&(C.pushData=JSON.stringify({mediaType:a,userIdList:s,callId:n})),[2,this._sendCallMessage({channelId:t,conversationType:r,targetId:o,content:_,messageType:p.VCModifyMem,directionalUserIdList:u,pushConfig:C})]}))}))}}),Object.defineProperty(o.prototype,"sendRinging",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=t.channelId,o=t.conversationType,n=t.targetId,i=t.callId,a=t.userIds,s={platform:m.WEB,deviceId:this._deviceId,callId:i,user:this._userInfo};return this._sendCallMessage({channelId:r,conversationType:o,targetId:n,content:s,messageType:p.VCRinging,directionalUserIdList:o===e.ConversationType.GROUP?a:void 0})}}),Object.defineProperty(o.prototype,"sendAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=t.channelId,o=t.conversationType,n=t.targetId,i=t.callId,a=t.mediaType,s=t.userIds,l={platform:m.WEB,deviceId:this._deviceId,callId:i,mediaType:a,user:this._userInfo};return this._sendCallMessage({channelId:r,conversationType:o,targetId:n,content:l,messageType:p.VCAccept,directionalUserIdList:o===e.ConversationType.GROUP?s:void 0})}}),Object.defineProperty(o.prototype,"sendHungup",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=t.channelId,o=t.conversationType,n=t.targetId,i=t.callId,a=t.reason,s=t.userIds,l=t.pushConfig,c={platform:m.WEB,deviceId:this._deviceId,callId:i,reason:a,user:this._userInfo};return l&&(l.pushData=JSON.stringify({callId:i,reason:a})),this._sendCallMessage({channelId:r,conversationType:o,targetId:n,content:c,messageType:p.VCHangup,pushConfig:l,directionalUserIdList:o===e.ConversationType.GROUP?s:void 0})}}),Object.defineProperty(o.prototype,"sendMediaModify",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=t.channelId,o=t.conversationType,n=t.targetId,i=t.callId,a=t.mediaType,s=t.userIds,l={platform:m.WEB,deviceId:this._deviceId,callId:i,mediaType:a,user:this._userInfo};return this._sendCallMessage({channelId:r,conversationType:o,targetId:n,content:l,messageType:p.VCModifyMedia,directionalUserIdList:o===e.ConversationType.GROUP?s:void 0})}}),o}(e.EventEmitter);exports.RCCallLanguage=void 0,(S=exports.RCCallLanguage||(exports.RCCallLanguage={})).ZH="zh",S.EN="en";var A,N={PushTitle:{AUDIO:"You have a voice call",VIDEO:"You have a video call"}},U={PushTitle:{AUDIO:"您有一条音频通话",VIDEO:"您有一条视频通话"}},L=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:U}}),Object.defineProperty(e,"_lang",{enumerable:!0,configurable:!0,writable:!0,value:exports.RCCallLanguage.ZH}),e}(),j=function(){function t(e,t,r,o,n){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:o}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:n}),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.10"," CommitId: ").concat("b49ac7f3aef4e11e35cd5c4bd12be262e2779937")),f(t),this._callMsgHandler=new w(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}),h.on("onStateMachineClose",(function(e){delete i._stateMachine[e]})),L.set(n.lang)}return Object.defineProperty(t.prototype,"_onInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.channelId,r=e.conversationType,o=e.targetId,n=e.content,i=e.messageType,s=e.senderUserId;e.pushConfig;var l,c=n,u=c.mediaType,d=c.callId,C=c.extra;l=c.roomType!==b.RCCallRoomTypeAcrossCall?s:a(s.split("_"),2)[1];var _=this._context.getCurrentId();if(this._context.getCurrentId()!==l){if(i===p.VCModifyMem)if(n.existedUserPofiles.some((function(e){return e.userId===_}))&&!this._stateMachine[d])return;if(this._stateMachine[d])i===p.VCModifyMem&&this._stateMachine[d].__onMemberModify(e);else this._stateMachine[d]=new O(this._context,this._runtime,this._logger,this._callMsgHandler,t,r,o,u,d),this._logger.info("_","[RCCallEngine] RCCallStateMachine successfully created -> callId: ".concat(d)),i===p.VCInvite?this._stateMachine[d].__onInvite(e):i===p.VCModifyMem&&this._stateMachine[d].__onMemberModify(e),this._watchers.onInvite(this._stateMachine[d],C),Object.keys(this._stateMachine).filter((function(e){return d!==e})).length>0&&!this._options.isAllowAcceptNewCall&&this._stateMachine[d].__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,o,a,s,l){return void 0===a&&(a=""),void 0===l&&(l=!1),n(this,void 0,void 0,(function(){var n,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:o,extra:a,pushConfig:s}))),n=_(),Object.keys(this._stateMachine).length>0?[2,{code:exports.RCCallErrorCode.STATE_MACHINE_EXIT}]:(this._stateMachine[n]=new O(this._context,this._runtime,this._logger,this._callMsgHandler,t,e.ConversationType.PRIVATE,r,o,n),[4,this._stateMachine[n].__call([r],a,s,l)]);case 1:return(c=i.sent().code)===exports.RCCallErrorCode.SUCCESS?[2,{code:exports.RCCallErrorCode.SUCCESS,stateMachine:this._stateMachine[n]}]:[2,{code:c}]}}))}))}}),Object.defineProperty(t.prototype,"callInGroup",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,o,a,s,l){return void 0===s&&(s=""),n(this,void 0,void 0,(function(){var n,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:o}))),n=_(),Object.keys(this._stateMachine).length>0?[2,{code:exports.RCCallErrorCode.STATE_MACHINE_EXIT}]:(this._stateMachine[n]=new O(this._context,this._runtime,this._logger,this._callMsgHandler,t,e.ConversationType.GROUP,r,o,n),[4,this._stateMachine[n].__call(a,s,l)]);case 1:return(c=i.sent().code)===exports.RCCallErrorCode.SUCCESS?[2,{code:exports.RCCallErrorCode.SUCCESS,stateMachine:this._stateMachine[n]}]:[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"}(A||(A={}));var k=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,o=function(n){r.off(e,o),t.call(r,n)};o.fun=t,this.on(e,o)}}),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 o=void 0,n=0,i=r.length;n<i;n++)if((o=r[n])===t||o.fun===t){r.splice(n,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,o=s([],a(this.list[e]),!1);if(!o||0===o.length)return!1;o.forEach((function(e){e.call(r,t)}))}}),e}());var D=function(t){if(!t)return{ok:!1,msg:"Initialization missing parameter -> options"};if("object"!=typeof t)return{ok:!1,msg:"Initialization options must be an object"};var r,o=Object.keys(t),n=[];return["rtcClient","onSession","onSessionClose"].forEach((function(e){o.includes(e)||n.push(e)})),n.length?{ok:!1,msg:'Initialization missing parameter -> "'.concat(n.join(","),'"')}:"object"!=typeof t.rtcClient?{ok:!1,msg:"Initialization 'rtcClient' parameter must be of type 'object'"}:"function"!=typeof t.onSession?{ok:!1,msg:"Initialization 'onSession' parameter must be of type 'function'"}:"function"!=typeof t.onSessionClose?{ok:!1,msg:"Initialization 'onSessionClose' parameter must be of type 'function'"}:void 0!==t.isAllowSubscribeRetry&&"boolean"!=typeof t.isAllowSubscribeRetry?{ok:!1,msg:"Initialization 'isAllowSubscribeRetry' parameter must be of type 'boolean'"}:void 0!==t.isAllowPublishRetry&&"boolean"!=typeof t.isAllowPublishRetry?{ok:!1,msg:"Initialization 'isAllowPublishRetry' parameter must be of type 'boolean'"}:void 0!==t.isOffCameraWhenVideoDisable&&"boolean"!=typeof t.isOffCameraWhenVideoDisable?{ok:!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?{ok:!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)?{ok:!0}:{ok:!1,msg:"Initialization 'logOutputLevel' parameter must be of type correct type"}:{ok:!1,msg:"Initialization 'lang' parameter must be of type correct type"}:{ok:!1,msg:"Initialization 'joinType' parameter must be of type correct type"}},H=function(e){if(!e)return{ok:!1,msg:"missing parameter -> listener"};if("object"!=typeof e)return{ok:!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?{ok:!1,msg:'missing parameter -> "'.concat(r.join(","),'"')}:"function"!=typeof e.onRinging?{ok:!1,msg:"'onRinging' parameter must be of type 'function'"}:"function"!=typeof e.onAccept?{ok:!1,msg:"'onAccept' parameter must be of type 'function'"}:"function"!=typeof e.onHungup?{ok:!1,msg:"'onHungup' parameter must be of type 'function'"}:"function"!=typeof e.onTrackReady?{ok:!1,msg:"'onTrackReady' parameter must be of type 'function'"}:{ok:!0}},V=function(e){return e&&"string"==typeof e?{ok:!0}:{ok:!1,msg:"'targetId' parameter is required, must be of type 'string'"}},G=function(e){return e===exports.RCCallMediaType.AUDIO||e===exports.RCCallMediaType.AUDIO_VIDEO?{ok:!0}:{ok:!1,msg:"'mediaType' parameter is required, must be of type 'RCCallMediaType'"}},B=function(e){return"string"==typeof e?{ok:!0}:{ok:!1,msg:"'extra' parameter must be of type 'string'"}},K=function(t){var r=["pushTitle","pushContent","pushData","iOSConfig","androidConfig","disablePushTitle","templateId"],o=Object.keys(t).every((function(e){return r.includes(e)}));if(!o)return{code:exports.RCCallErrorCode.PARAM_ERROR,errorMsg:"right key: ".concat(r.join(","))};for(var n=0;n<r.length;n++){var i=r[n];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 a=t.iOSConfig,s=t.androidConfig,l=J(a||{});if(l.code!==exports.RCCallErrorCode.SUCCESS)return l;var c=W(s||{});return c.code!==exports.RCCallErrorCode.SUCCESS?c:{code:exports.RCCallErrorCode.SUCCESS}},J=function(t){var r=t||{},o=r.threadId,n=r.richMediaUri;return o&&!e.isString(o)?{code:exports.RCCallErrorCode.PARAM_ERROR,errorMsg:"iOSConfig.threadId type is string"}:n&&!e.isString(n)?{code:exports.RCCallErrorCode.PARAM_ERROR,errorMsg:"iOSConfig.richMediaUri type is string"}:{code:exports.RCCallErrorCode.SUCCESS}},W=function(t){var r=["notificationId","channelIdMi","channelIdHW","categoryHW","importanceHW","imageUrlHW","channelIdOPPO","typeVivo","categoryVivo","fcmChannelId","fcmCollapseKey","fcmImageUrl","importanceHonor","imageUrlHonor"],o=Object.keys(t).every((function(e){return r.includes(e)}));if(!o)return{code:exports.RCCallErrorCode.PARAM_ERROR,errorMsg:"right key: ".concat(r.join(","))};for(var n=0;n<r.length;n++){var i=r[n];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}},Y=function(e){return Array.isArray(e)&&e.length?e.every((function(e){return"string"==typeof e&&e.length>0}))?{ok:!0}:{ok:!1,msg:"'userIds' parameter is required"}:{ok:!1,msg:"'userIds' parameter is required, must be of type 'string[]'"}};var F=function(e){return e&&e.audio&&void 0!==e.audio.micphoneId&&"string"!=typeof e.audio.micphoneId?{ok:!1,msg:"'constraints.audio.micphoneId' must be of type 'string'"}:e&&e.audio&&void 0!==e.audio.sampleRate&&"number"!=typeof e.audio.sampleRate?{ok:!1,msg:"'constraints.audio.sampleRate' must be of type 'number'"}:e&&e.video&&void 0!==e.video.cameraId&&"string"!=typeof e.video.cameraId?{ok:!1,msg:"'constraints.video.cameraId' must be of type 'string'"}:e&&e.video&&void 0!==e.video.frameRate&&"string"!=typeof e.video.frameRate?{ok:!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))?{ok:!1,msg:"'frameRate' value is out of range"}:e&&e.video&&void 0!==e.video.resolution&&"string"!=typeof e.video.resolution?{ok:!1,msg:"'constraints.video.frameRate' must be of type 'string'"}:e&&e.video&&void 0!==e.video.resolution&&(o=e.video.resolution,!t.RCResolution[o])?{ok:!1,msg:"'resolution' value is out of range"}:!e||!e.video||e.video.frameRate&&e.video.resolution?{ok:!0}:{ok:!1,msg:"'resolution' and 'resolution' is required"};var r,o},z=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}(),q=function(){function r(e,t,r,o){void 0===o&&(o={});var a=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:o}),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;a._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 n(a,void 0,void 0,(function(){var t,r,o,n,a;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];o=this._stateMachine.getCallId(),this._logger.info("_","[RCCallSession onStateChange] roomId: ".concat(o)),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this._joinRoom(o)];case 2:return i.sent(),[3,4];case 3:return n=i.sent(),this._exceptionClose(exports.RCCallEndReason.NETWORK_ERROR),this._logger.error("_","[RCCallSession onStateChange] joinRoom throw exception roomId -> ".concat(o)),console.error(n),[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),a=this._stateMachine.getSummary(),k.emit("sessionClose",{session:this,summaryInfo:a}),[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){a._logger.info("_","[RCCallSession onRinging]sender: sender.userId -> ".concat(e.userId));try{a._listener.onRinging(e,a)}catch(e){a._logger.error("_","[RCCallSession onRinging] method exception -> onRinging"),console.error(e)}},onAccept:function(e){a._logger.info("_","[RCCallSession onAccept]sender: sender.userId -> ".concat(e.userId));try{a._listener.onAccept(e,a)}catch(e){a._logger.error("_","[RCCallSession onAccept] method exception -> onAccept"),console.error(e)}},onHungup:function(e,t){a._logger.info("_","[RCCallSession onHungup]sender: sender.userId -> ".concat(e.userId," reason->").concat(t));try{a._listener.onHungup(e,t,a)}catch(e){a._logger.error("_","[RCCallSession onHungup] method exception -> onHungup"),console.error(e)}},onMemberModify:function(e){var t=e.sender,r=e.invitedUsers;a._logger.info("_","[RCCallSession onMemberModify] sender.userId -> ".concat(t.userId));try{a._listener.onMemberModify(t,r,a)}catch(e){a._logger.error("_","[RCCallSession onMemberModify] method exception -> onMemberModify"),console.error(e)}},onMediaModify:function(e){var t=e.sender,r=e.mediaType;a._logger.info("_","[RCCallSession onMediaModify]sender: sender.userId -> ".concat(t.userId," mediaType: ").concat(r)),r===exports.RCCallMediaType.AUDIO&&a._setMediaTypeToAudio();try{a._listener.onMediaModify(t,r,a)}catch(e){a._logger.error("_","[RCCallSession onMediaModify] method exception -> onMediaModify"),console.error(e)}},crossAppkey:function(e){a._logger.info("_","[RCCallSession crossAppkey] 是否跨 appkey: ".concat(e)),a._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 n(this,void 0,void 0,(function(){var o,n,a,s,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 o=i.sent(),[3,4];case 2:return[4,this._rtcClient.joinRTCRoom(r,this._options.joinType)];case 3:o=i.sent(),i.label=4;case 4:return n=o.code,a=o.userIds,s=o.room,n!==t.RCRTCCode.SUCCESS?(n===t.RCRTCCode.NOT_OPEN_VIDEO_AUDIO_SERVER&&this._exceptionClose(exports.RCCallEndReason.SERVICE_NOT_OPENED),n===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(n)),[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(s)]);case 5:return i.sent(),this._room=null,[2,{code:exports.RCCallErrorCode.SUCCESS}];case 6:return a.length<1&&(this.joinRoomTimer=new z((function(){d._exceptionClose(exports.RCCallEndReason.REMOTE_NETWORK_ERROR)}),6e4)),this._room=s,[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 n(this,void 0,void 0,(function(){var e,r;return i(this,(function(o){switch(o.label){case 0:return(e=this._room.getRemoteTracks()).length?[4,this._subscribeRetry(e,this._options.isAllowSubscribeRetry,this._RETRYCOUNT)]:[3,2];case 1:(r=o.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))),o.label=2;case 2:return[2]}}))}))}}),Object.defineProperty(r.prototype,"_subscribeRetry",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,o){return void 0===r&&(r=!1),void 0===o&&(o=0),n(this,void 0,void 0,(function(){var n;return i(this,(function(i){switch(i.label){case 0:return[4,this._room.subscribe(e)];case 1:if((n=i.sent().code)!==t.RCRTCCode.SUCCESS){try{this._listener.onTrackSubscribeFail&&this._listener.onTrackSubscribeFail(n,this)}catch(e){this._logger.error("_","[RCCallSession] _listener.onTrackSubscribeFail exception"),console.error(e)}if(!r)return[2,{code:n}];if(o>0)return o--,[2,this._subscribeRetry(e,r,o)]}return[2,{code:n}]}}))}))}}),Object.defineProperty(r.prototype,"_publish",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e,r;return i(this,(function(o){switch(o.label){case 0:return e=this._options.localTracks,[4,this._publishRetry(e,this._options.isAllowPublishRetry,this._RETRYCOUNT)];case 1:return(r=o.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===A.CALLEE&&this._notifyTrackReady(e),[2])}}))}))}}),Object.defineProperty(r.prototype,"_publishRetry",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,o){return void 0===r&&(r=!1),void 0===o&&(o=0),n(this,void 0,void 0,(function(){var n;return i(this,(function(i){switch(i.label){case 0:return[4,this._room.publish(e)];case 1:if((n=i.sent().code)!==t.RCRTCCode.SUCCESS){try{this._listener.onTrackPublishFail&&this._listener.onTrackPublishFail(n,this)}catch(e){this._logger.error("_","[RCCallSession] _listener.onTrackPublishFail exception"),console.error(e)}if(!r)return[2,{code:n}];if(o>0)return o--,[2,this._publishRetry(e,r,o)]}return[2,{code:n}]}}))}))}}),Object.defineProperty(r.prototype,"_leaveRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e,t,r;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,3,4]),[4,this._rtcClient.leaveRoom(this._room)];case 1:return e=o.sent(),this._logger.info("_","[RCCallSession _leaveRoom] Successfully exited the room code: ".concat(e.code)),[3,4];case 2:return t=o.sent(),this._logger.error("_","[RCCallSession _leaveRoom] leaveRoom throw exception"),console.error(t),[3,4];case 3:return r=this._stateMachine.getSummary(),k.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=H(e);if(!t.ok)throw new Error("[RCCallSession registerSessionListener] ".concat(t.msg));this._listener=o({},e)}}),Object.defineProperty(r.prototype,"_getLocalTrackCore",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){return n(this,void 0,void 0,(function(){var n,a,s,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&&o({},r.audio))];case 1:return n=i.sent(),a=n.code,s=n.track,a!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession _getLocalTrackCore] get Audio local tracks failed RCT code -> ".concat(a)),[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:[s]}]);case 2:return[4,this._rtcClient.createMicrophoneAndCameraTracks("RongCloudRTC",r&&o({},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 n(this,void 0,void 0,(function(){var r,o,n,a,s,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(),o=r.code,n=r.tracks,o===exports.RCCallErrorCode.SUCCESS?[3,3]:[4,this._getLocalTrackCore(exports.RCCallMediaType.AUDIO,t)];case 2:return a=i.sent(),s=a.code,l=a.tracks,s!==exports.RCCallErrorCode.SUCCESS?(this._exceptionClose(exports.RCCallEndReason.GET_MEDIA_RESOURCES_ERROR),[2,{code:s}]):[2,{code:s,tracks:l}];case 3:return[2,{code:o,tracks:n}];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 n(this,void 0,void 0,(function(){var r,o,n,a,s;return i(this,(function(i){switch(i.label){case 0:return r=[],o=[],[4,this._rtcClient.createMicrophoneAudioTrack("RongCloudRTC",e)];case 1:return n=i.sent(),a=n.code,s=n.track,a!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession changeDevice] get local Audio tracks failed RCTLib code -> ".concat(a)),[2,{code:exports.RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR}]):(this._options.localTracks&&this._options.localTracks.forEach((function(e){e.isAudioTrack()||o.push(e)})),r.push(s),o.push(s),this._options.localTracks=o,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={}),n(this,void 0,void 0,(function(){var r,o,n,a,s,l,c,u;return i(this,(function(i){switch(i.label){case 0:if(r=t.extra,o=void 0===r?"":r,n=this._options.callPushConfig?this._options.callPushConfig:t.pushConfig,a=[Y(e),B(o)],n&&(s=K(n),l=s.code,c=s.errorMsg,l!==exports.RCCallErrorCode.SUCCESS))return this._logger.error("_","[RCCallSession invite] param error, errorMsg: ".concat(c)),[2,{code:l}];if(u=[],!a.every((function(e){return!e.ok&&u.push(e.msg),e.ok})))throw new Error("[RCCallClient invite] ".concat(u.join("\n")));return[4,this._stateMachine.invite(e,{extra:o,pushConfig:n})];case 1:return[2,{code:i.sent().code}]}}))}))}}),Object.defineProperty(r.prototype,"accept",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return n(this,void 0,void 0,(function(){var t,r,o,n,a,s;return i(this,(function(i){switch(i.label){case 0:if(!(t=F(e)).ok)throw new Error("[RCCallSession accept] ".concat(t.msg));return k.emit("hungupOtherSession",{session:this}),r=this._stateMachine.getMediaType(),[4,this._getLocalTrack(r,e)];case 1:return o=i.sent(),n=o.code,a=o.tracks,n!==exports.RCCallErrorCode.SUCCESS?[2,{code:n}]:(this._options.localTracks=a,[4,this._stateMachine.accept()]);case 2:return(s=i.sent().code)!==exports.RCCallErrorCode.SUCCESS?(this._logger.error("_","[RCCallSession accept]Send accept message failed -> code: ".concat(s)),[2,{code:s}]):[2,{code:s}]}}))}))}}),Object.defineProperty(r.prototype,"hungup",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(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 n(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 n(this,void 0,void 0,(function(){var e,r,o;return i(this,(function(n){switch(n.label){case 0:return[4,this._rtcClient.createCameraVideoTrack()];case 1:return e=n.sent(),r=e.code,o=e.track,r!==t.RCRTCCode.SUCCESS?[2,{code:exports.RCCallErrorCode.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR}]:[4,this._room.publish([o])];case 2:return n.sent().code!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession _enableVideo] Resource publishing failed: RCRTCCode -> ".concat(r)),[2]):(this._notifyTrackReady([o]),this._changeMediaType(exports.RCCallMediaType.AUDIO_VIDEO),[2])}}))}))}}),Object.defineProperty(r.prototype,"_setMediaTypeToAudio",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e,r;return i(this,(function(o){switch(o.label){case 0:return(e=this._getLocalVideoTracks()).length?(e.forEach((function(e){e.mute()})),[4,this._room.unpublish(e)]):[3,2];case 1:(r=o.sent().code)!==t.RCRTCCode.SUCCESS&&this._logger.error("_","[RCCallSession disableVideo] unpublish failed -> ".concat(r)),this._destroyTracks(e),o.label=2;case 2:return[2]}}))}))}}),Object.defineProperty(r.prototype,"descendAbility",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(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 n(this,void 0,void 0,(function(){var e,r;return i(this,(function(o){switch(o.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=o.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 n(this,void 0,void 0,(function(){var e,r,o,n,a;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(),o=r.code,n=r.track,o!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession EnableVideoTrack] Get Resource failed: RCRTCCode -> ".concat(o)),[2,{code:exports.RCCallErrorCode.GET_LOCAL_VIDEO_TRACK_ERROR}]):(a=[],this._options.localTracks&&this._options.localTracks.forEach((function(e){e.isVideoTrack()?e.destroy():a.push(e)})),a.push(n),this._options.localTracks=a,n.mute(),[4,this._room.publish([n])]);case 2:return i.sent().code!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession EnableVideoTrack] Resource publishing failed: RCRTCCode -> ".concat(o)),[2,{code:exports.RCCallErrorCode.VIDEO_PUBLISH_ERROR}]):(n.unmute(),this._notifyTrackReady([n]),[2,{code:exports.RCCallErrorCode.SUCCESS}])}}))}))}}),Object.defineProperty(r.prototype,"disableAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e,r;return i(this,(function(o){switch(o.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=o.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 n(this,void 0,void 0,(function(){var e,r;return i(this,(function(o){switch(o.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=o.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,o){var n=e._rtcClient.getCurrentId();e._stateMachine.userLeave([n]),r?(o===t.RCKickReason.SERVER_KICK&&e._exceptionClose(exports.RCCallEndReason.KICKED_BY_SERVER),o===t.RCKickReason.OTHER_KICK&&e._exceptionClose(exports.RCCallEndReason.OTHER_CLIENT_JOINED_CALL)):e._exceptionClose(exports.RCCallEndReason.NETWORK_ERROR)},onMessageReceive:function(e,t,r,o){},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 n(e,void 0,void 0,(function(){var e;return i(this,(function(o){switch(o.label){case 0:return this._room?[4,this._room.subscribe(r)]:[3,2];case 1:(e=o.sent().code)!==t.RCRTCCode.SUCCESS&&this._logger.error("_","[RCCallSession onTrackPublish] subscribe failed RTCCode ->".concat(e)),o.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){var r,o;try{null===(o=null===(r=e._listener)||void 0===r?void 0:r.onPing)||void 0===o||o.call(r,t,e)}catch(e){console.error(e)}}})}}),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,o;try{null===(o=null===(r=e._listener)||void 0===r?void 0:r.onICEConnectionStateChange)||void 0===o||o.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}(),X=function(){function r(t,r,n,i){var a=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:n}),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=o({isAllowPublishRetry:!1,isAllowSubscribeRetry:!1,isOffCameraWhenVideoDisable:!0,joinType:e.RTCJoinType.COEXIST,isAllowDemotionGetStream:!1,lang:exports.RCCallLanguage.ZH},i),this._callEngine=new j(this._context,r,this._logger,{onInvite:this._onInvite.bind(this),onOfflineRecord:this._onOfflineRecord.bind(this)},{lang:this._options.lang||exports.RCCallLanguage.ZH}),k.on("sessionClose",(function(e){var t=e.session,r=e.summaryInfo;a._removeSession(t);try{a._options.onSessionClose(t,r)}catch(e){a._logger.error("_","[RCCCallClient] options.onSessionClose exception"),console.log(e)}})),k.on("hungupOtherSession",(function(e){var t=e.session.getSessionId();a._logger.info("_","[RCCallClient hungupOtherSession] sessionId ready to accept -> ".concat(t)),a._logger.info("_","[RCCallClient hungupOtherSession] sessionList ->".concat(a._sessionList.map((function(e){return e.getSessionId()})).join(",")));for(var r=0;a._sessionList.length>1;)a._sessionList[r].getSessionId()!==t?(a._sessionList[r].hungup(),a._sessionList.splice(r,1)):r++;a._logger.info("_","[RCCallClient hungupOtherSession] current sessionList length ->".concat(a._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 q(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:A.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 o=H(r._listener);if(!o.ok)throw new Error(o.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,o=void 0===r?exports.RCCallMediaType.AUDIO:r,a=e.listener,s=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,f=void 0===h?"":h,p=e.bitrate;return n(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.__call({targetId:t,mediaType:o,listener:a,constraints:s,channelId:c,extra:d,pushTitle:_,pushContent:f,bitrate:p,isCrossAppkey:!0})]}))}))}}),Object.defineProperty(r.prototype,"call",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.targetId,r=e.mediaType,o=void 0===r?exports.RCCallMediaType.AUDIO:r,a=e.listener,s=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,f=void 0===h?"":h,p=e.bitrate;return n(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.__call({targetId:t,mediaType:o,listener:a,constraints:s,channelId:c,extra:d,pushTitle:_,pushContent:f,bitrate:p})]}))}))}}),Object.defineProperty(r.prototype,"__call",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.targetId,r=e.mediaType,o=void 0===r?exports.RCCallMediaType.AUDIO:r,a=e.listener,s=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,f=void 0===h?"":h,p=e.bitrate,R=e.isCrossAppkey,g=void 0!==R&&R;return n(this,void 0,void 0,(function(){var e,r,n,l,u,C,h,R,b,E,I,y,m,v;return i(this,(function(i){switch(i.label){case 0:return e=this._callPushConfig?this._callPushConfig:{pushTitle:_,pushContent:f},this._logger.info("_","[RCCallClient call] targetId: ".concat(t,", mediaType: ").concat(o)),t===this._context.getCurrentId()?(this._logger.error("_","[RCCallClient call] targetId is equal to currentId"),[2,{code:exports.RCCallErrorCode.PARAM_ERROR}]):(r=[V(t),G(o),H(a),B(d)],n=[],r.every((function(e){return!e.ok&&n.push(e.msg),e.ok}))?(l=K(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(o,s)])):(console.error(n.join("\n")),[2,{code:exports.RCCallErrorCode.PARAM_ERROR}]));case 1:return R=i.sent(),b=R.code,E=R.tracks,b!==exports.RCCallErrorCode.SUCCESS?[2,{code:b}]:((h=E).forEach((function(e){var t,r,o;e.isAudioTrack()&&(null==p?void 0:p.audio)&&e.setBitrate(null==p?void 0:p.audio),e.isVideoTrack()&&(null==p?void 0:p.video)&&e.setBitrate(null===(t=null==p?void 0:p.video)||void 0===t?void 0:t.max,null===(r=null==p?void 0:p.video)||void 0===r?void 0:r.min,null===(o=null==p?void 0:p.video)||void 0===o?void 0:o.start),a.onTrackReady(e)})),[4,this._callEngine.call(c,t,o,d,e,g)]);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 q(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:A.CALLER,isCrossAppkey:g,callPushConfig:this._callPushConfig,hungupPushConfig:this._hungupPushConfig})).registerSessionListener(a),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,o=e.mediaType,a=void 0===o?exports.RCCallMediaType.AUDIO:o,s=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===_?"":_,f=e.pushContent,p=void 0===f?"":f,R=e.bitrate;return n(this,void 0,void 0,(function(){var e,o,n,c,d,_,f,g,b,E,I,y,m,v,O;return i(this,(function(i){switch(i.label){case 0:return e=this._callPushConfig?this._callPushConfig:{pushTitle:h,pushContent:p},o=[V(t),Y(r),G(a),H(s),B(C)],n=[],c=o.every((function(e){return!e.ok&&n.push(e.msg),e.ok})),r.includes(this._context.getCurrentId())?(console.error("[RCCallClient callInGroup] userIds includes currentId"),[2,{code:exports.RCCallErrorCode.PARAM_ERROR}]):c?(d=K(e),_=d.code,f=d.errorMsg,_!==exports.RCCallErrorCode.SUCCESS?(this._logger.error("_","[RCCallClient call] param error, errorMsg: ".concat(f)),[2,{code:_}]):(g=[],[4,this._getLocalTrack(a,l)])):(console.error("[RCCallClient callInGroup] ".concat(n.join("\n"))),[2,{code:exports.RCCallErrorCode.PARAM_ERROR}]);case 1:return b=i.sent(),E=b.code,I=b.tracks,E!==exports.RCCallErrorCode.SUCCESS?[2,{code:E}]:((g=I).forEach((function(e){var t,r,o;e.isAudioTrack()&&(null==R?void 0:R.audio)&&e.setBitrate(null==R?void 0:R.audio),e.isVideoTrack()&&(null==R?void 0:R.video)&&e.setBitrate(null===(t=null==R?void 0:R.video)||void 0===t?void 0:t.max,null===(r=null==R?void 0:R.video)||void 0===r?void 0:r.min,null===(o=null==R?void 0:R.video)||void 0===o?void 0:o.start),s.onTrackReady(e)})),[4,this._callEngine.callInGroup(u,t,a,r,C,e)]);case 2:return y=i.sent(),m=y.code,v=y.stateMachine,m===exports.RCCallErrorCode.SUCCESS&&v?(this._logger.info("_","[RCCallClient callInGroup] successfully created state machine"),(O=new q(v,this._rtcClient,this._logger,{localTracks:g,isAllowSubscribeRetry:this._options.isAllowSubscribeRetry,isAllowPublishRetry:this._options.isAllowPublishRetry,isOffCameraWhenVideoDisable:this._options.isOffCameraWhenVideoDisable,joinType:this._options.joinType,isAllowDemotionGetStream:this._options.isAllowDemotionGetStream,produceType:A.CALLER,callPushConfig:this._callPushConfig,hungupPushConfig:this._hungupPushConfig})).registerSessionListener(s),this._sessionList.push(O),this._logger.info("_","[RCCallClient callInGroup] successfully created session object, sessionId: ".concat(O.getSessionId())),[2,{code:m,session:O}]):(this._logger.info("_","[RCCallClient callInGroup] callInGroup failed code -> ".concat(m)),g.forEach((function(e){e.mute(),e.destroy()})),[2,{code:m}])}}))}))}}),Object.defineProperty(r.prototype,"_getLocalTrackCore",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){return n(this,void 0,void 0,(function(){var n,a,s,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&&o({},r.audio))];case 1:return n=i.sent(),a=n.code,s=n.track,a!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallClient _getTrack] get Audio local tracks failed RCT code -> ".concat(a)),[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:[s]}]);case 2:return[4,this._rtcClient.createMicrophoneAndCameraTracks("RongCloudRTC",r&&o({},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 n(this,void 0,void 0,(function(){var r,o,n,a,s,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(),o=r.code,n=r.tracks,o===exports.RCCallErrorCode.SUCCESS?[3,3]:[4,this._getLocalTrackCore(exports.RCCallMediaType.AUDIO,t)];case 2:return a=i.sent(),s=a.code,l=a.tracks,s!==exports.RCCallErrorCode.SUCCESS?[2,{code:s}]:[2,{code:s,tracks:l}];case 3:return[2,{code:o,tracks:n}];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 n(this,void 0,void 0,(function(){var t,r,o;return i(this,(function(n){switch(n.label){case 0:return[4,this._context.getRTCJoinedUserInfo(this._context.getCurrentId())];case 1:return t=n.sent(),r=t.code,o=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:o}]}}))}))}}),Object.defineProperty(r.prototype,"setPushConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,o,n=[e,t].map((function(e){return K(e)}));try{for(var i=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],o=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(n),a=i.next();!a.done;a=i.next()){var s=a.value,l=s.code,c=s.errorMsg;if(l!==exports.RCCallErrorCode.SUCCESS)return this._logger.error("_","[RCCallClient setPushConfig] param error, errorMsg: ".concat(c)),{code:l}}}catch(e){r={error:e}}finally{try{a&&!a.done&&(o=i.return)&&o.call(i)}finally{if(r)throw r.error}}this._callPushConfig=e,this._hungupPushConfig=t}}),r}();e.VersionManage.add("calllib","5.2.10");var Z={tag:"RCCall",verify:function(e){return"browser"===e.tag},setup:function(t,r,o){var n=D(o);if(!n.ok)throw new Error("[RCCallLib installer steup]".concat(n.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 o.logOutputLevel&&i.setOutputLevel(o.logOutputLevel),void 0!==o.logLevel&&i.warn("_","The 'logLevel' parameter is deprecated, please use 'logOutputLevel' instead."),i.warn("_","RCCall Version: ".concat("5.2.10",", Commit: ").concat("b49ac7f3aef4e11e35cd5c4bd12be262e2779937")),new X(t,r,i,o)}};exports.RCCallClient=X,exports.RCCallSession=q,exports.installer=Z;
|
|
9
|
+
e[e.RCCallRoomTypeAcrossCall=7]="RCCallRoomTypeAcrossCall"}(b||(b={}));var I,y,v,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}(),O=function(){function t(e,t,r,o,n,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:o}),Object.defineProperty(this,"_channelId",{enumerable:!0,configurable:!0,writable:!0,value:n}),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&&(h.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,o=r.user,n=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=n===exports.RCCallEndReason.BUSY_LINE?exports.RCCallEndReason.OTHER_CLIENT_IN_CALL:n===exports.RCCallEndReason.NO_RESPONSE?exports.RCCallEndReason.NO_RESPONSE:exports.RCCallEndReason.HANGUP_BY_OTHER_CLIENT),Object.assign(this._userInfo[t],o),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,n=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(o({userId:s},n))}}),Object.defineProperty(t.prototype,"_onAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=this,o=t.senderUserId,n=t.content,i=n.user,s=n.deviceId;t.sentTime;var a=this._isCrossAppkey?o.split("_")[1]:o,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?f(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,n=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=n,this._watchers.onMediaModify({sender:o({userId:t},i),mediaType:n}))}}),Object.defineProperty(t.prototype,"_onHungup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,r=e.content,n=this._isCrossAppkey?t.split("_")[1]:t,i=r,s=i.reason,a=i.user,l=i.deviceId,c=this._context.getCurrentId();if(this._isRemoteInvalidMsg(n,l))this._logger.debug("_","[RCCallStateMachine] _onHungup -> not the remote device that is currently talking");else if(c!==n)if(this._sessionState!==exports.RCCallSessionState.END){this._userInfo[n]&&(this._userInfo[n].state=exports.RCCallUserState.NONE,this._endTimestamp=Date.now(),Object.assign(this._userInfo[n],a),this._notifyUserStateChange(this._userInfo[n],E[s]),delete this._userInfo[n]),E[s]===exports.RCCallEndReason.REMOTE_CANCEL?this.getRemoteUserIds().length<1&&this._clearTimerById(c):this.getInviterId()===c?this._clearTimerById(n):this.getRemoteUserIds().length<1&&this._clearTimerById(c);var u=Object.keys(this._userInfo).length<2,d=this._inviterId===n,C=Object.values(this._userInfo).every((function(e){return e.state!==exports.RCCallUserState.KEEPING}));(u||d&&C)&&this._notifyStateChange(exports.RCCallSessionState.END,E[s]),this._watchers.onHungup(o({userId:n},a),E[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,o=this,n=e.senderUserId,i=e.content,l=e.sentTime,c=i,u=c.inviteUserIds,d=c.user,C=c.deviceId;c.roomType===b.RCCallRoomTypeAcrossCall?(t=s(n.split("_"),2),r=t[1],this._watchers.crossAppkey(!0),this._isCrossAppkey=!0):r=n;var _=this._context.getCurrentId();if(this._isRemoteInvalidMsg(r,C))this._logger.debug("_","[RCCallStateMachine] __onInvite -> not the remote device that is currently talking");else if(_!==r){this._callerId=this._inviterId=r;var h=a([n],s(u),!1);this._callMsgHandler.sendRinging({conversationType:this._conversationType,targetId:this._targetId,channelId:this._channelId,callId:this._callId,userIds:h.filter((function(e){return o._isCrossAppkey?e.split("_")[1]!==_:e!==_}))});var f=this._isCrossAppkey?[u[0].split("_")[1]]:u;a([r],s(f),!1).forEach((function(e){o._userInfo[e]={userId:e,state:exports.RCCallUserState.WAITING,isCaller:e===r,isRemote:e!==_},e===r&&Object.assign(o._userInfo[e],d,{deviceId:C}),o._notifyUserStateChange(o._userInfo[e]),e!==r&&(o._userTimers[e]=new m((function(){var t=e===_?exports.RCCallEndReason.NO_RESPONSE:exports.RCCallEndReason.REMOTE_NO_RESPONSE;e===_?o._hungupHandle(t,!1):(o._userInfo[e]&&(o._userInfo[e].state=exports.RCCallUserState.NONE),o._notifyUserStateChange(o._userInfo[e]),o._watchers.onHungup(o._userInfo[e],t),delete o._userInfo[e]),o._clearTimerById(e)}),o._getTimeout(l)))})),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,n=e.content,i=e.sentTime,s=n,a=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:l.INCOMING})})),C.includes(h)){var f=[];c.forEach((function(e){e.userId!==h&&f.push(e.userId)})),this._callMsgHandler.sendRinging({conversationType:this._conversationType,targetId:this._targetId,channelId:this._channelId,callId:this._callId,userIds:f}),this._notifyStateChange(exports.RCCallSessionState.WAITING)}else this._watchers.onMemberModify({sender:o({userId:r},a),invitedUsers:C.map((function(e){return{userId:e}}))});c.forEach((function(e){var o=e.userId,n=e.callStatus;if(n!==l.IDLE&&(t._userInfo[o]={userId:o,state:n!==l.CONNECTED?exports.RCCallUserState.WAITING:exports.RCCallUserState.KEEPING,isCaller:r===o,isRemote:h!==o},o===r&&Object.assign(t._userInfo[o],a,{deviceId:d}),t._notifyUserStateChange(t._userInfo[o]),n!==l.CONNECTED&&!t._userTimers[o])){if(!C.includes(o))return;t._userTimers[o]=new m((function(){t._userInfo[o]&&(t._userInfo[o].state=exports.RCCallUserState.NONE);var e=o===h?exports.RCCallEndReason.NO_RESPONSE:exports.RCCallEndReason.REMOTE_NO_RESPONSE;t._notifyUserStateChange(t._userInfo[o],e);try{t._watchers.onHungup(t._userInfo[o],e)}catch(e){t._logger.error("_","[RCCallStateMachine] call onhungup error -> ".concat(null==e?void 0:e.stack))}delete t._userInfo[o],(Object.keys(t._userInfo).length<2||o===h)&&t._notifyStateChange(exports.RCCallSessionState.END,e),t._clearTimerById(o)}),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,o){return void 0===t&&(t=""),void 0===o&&(o=!1),n(this,void 0,void 0,(function(){var n,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))),n=this._callerId=this._inviterId=this._context.getCurrentId(),[4,this._callMsgHandler.sendInvite({roomType:o?b.RCCallRoomTypeAcrossCall:b.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!==n}))})];case 1:return l=i.sent(),c=l.code,u=l.message,this._isCrossAppkey=o,c===exports.RCCallErrorCode.SUCCESS?(d=u.sentTime,a([n],o?[e[0].split("_")[1]]:s(e),!1).forEach((function(e){var t=e===n;_._userInfo[e]={userId:e,state:exports.RCCallUserState.WAITING,isCaller:t,isRemote:!t},_._notifyUserStateChange(_._userInfo[e]),t||(_._userTimers[e]=new m((function(){_._userInfo[e]&&(_._userInfo[e].state=exports.RCCallUserState.NONE),_._notifyUserStateChange(_._userInfo[e],exports.RCCallEndReason.REMOTE_NO_RESPONSE),_._watchers.onHungup(_._userInfo[e],exports.RCCallEndReason.REMOTE_NO_RESPONSE),delete _._userInfo[e],Object.keys(_._userInfo).length<2&&_._notifyStateChange(exports.RCCallSessionState.END,exports.RCCallEndReason.REMOTE_NO_RESPONSE),0===_.getRemoteUserIds().length&&_._userInfo[n].state!==exports.RCCallUserState.KEEPING&&_._hungupHandle(exports.RCCallEndReason.REMOTE_NO_RESPONSE)}),_._getTimeout(d)))})),this._notifyStateChange(exports.RCCallSessionState.WAITING)):(C=c===exports.RCCallErrorCode.REJECTED_BY_BLACKLIST?exports.RCCallEndReason.ADDED_TO_BLACKLIST:exports.RCCallEndReason.NETWORK_ERROR,this._notifyStateChange(exports.RCCallSessionState.END,C)),[2,{code:c}]}}))}))}}),Object.defineProperty(t.prototype,"accept",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e,t,r,o,n;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,o=t.message,this._clearTimerById(e),r===exports.RCCallErrorCode.SUCCESS?(o.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]),n=r===exports.RCCallErrorCode.REJECTED_BY_BLACKLIST?exports.RCCallEndReason.ADDED_TO_BLACKLIST:exports.RCCallEndReason.NETWORK_ERROR,this._notifyStateChange(exports.RCCallSessionState.END,n)),[2,{code:r}]}}))}))}}),Object.defineProperty(t.prototype,"invite",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return void 0===r&&(r={}),n(this,void 0,void 0,(function(){var o,n,c,u,d,C,_,h,f,p,R,g=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.info("_","[RCCallStateMachine] invite -> userIds: ".concat(JSON.stringify(t))),o=this._context.getCurrentId(),n=Object.keys(this._userInfo),0===(c=t.filter((function(e){return e!==o&&!n.includes(e)}))).length?(this._logger.warn("_","[RCCallStateMachine] invite -> all userId is in calling now!"),[2,{code:exports.RCCallErrorCode.PARAM_ERROR}]):(u=n.map((function(e){var t=l.CONNECTED;return g._userInfo[e].state===exports.RCCallUserState.WAITING&&(t=l.RINGING),{userId:e,mediaType:g._mediaType,callStatus:t,mediaId:e}})),d=r.extra,C=void 0===d?"":d,_=r.pushConfig,[4,this._callMsgHandler.sendMemeberModify({channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,extra:C,pushConfig:_,mediaType:this._mediaType,inviteUserIds:c,callerId:this.getCallerId(),existedUserPofiles:u,directionalUserIdList:a(a([],s(n),!1),s(c),!1).filter((function(e){return e!==o}))})]));case 1:return h=i.sent(),f=h.code,p=h.message,f===exports.RCCallErrorCode.SUCCESS?(R=p.sentTime,c.forEach((function(e){g._userInfo[e]={userId:e,state:exports.RCCallUserState.WAITING,isCaller:!1,isRemote:!0},g._notifyUserStateChange(g._userInfo[e]),g._userTimers[e]=new m((function(){g._userInfo[e]&&(g._userInfo[e].state=exports.RCCallUserState.NONE),g._notifyUserStateChange(g._userInfo[e],exports.RCCallEndReason.REMOTE_NO_RESPONSE),g._watchers.onHungup(g._userInfo[e],exports.RCCallEndReason.REMOTE_NO_RESPONSE),delete g._userInfo[e],Object.keys(g._userInfo).length<2&&g._notifyStateChange(exports.RCCallSessionState.END,exports.RCCallEndReason.REMOTE_NO_RESPONSE)}),g._getTimeout(R))}))):c.forEach((function(e){g._userInfo[e]={userId:e,state:exports.RCCallUserState.NONE,isCaller:!1,isRemote:!0};var t=f===exports.RCCallErrorCode.REJECTED_BY_BLACKLIST?exports.RCCallEndReason.ADDED_TO_BLACKLIST:exports.RCCallEndReason.NETWORK_ERROR;g._notifyUserStateChange(g._userInfo[e],t)})),[2,{code:f}]}}))}))}}),Object.defineProperty(t.prototype,"_hungupHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===t&&(t=!0),n(this,void 0,void 0,(function(){var r,o,n,s,a;return i(this,(function(i){switch(i.label){case 0:return r=this._context.getCurrentId(),o=exports.RCCallErrorCode.SUCCESS,t?(n={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(n),[3,3])):[3,3];case 1:return[4,this._callMsgHandler.sendHungup(n)];case 2:s=i.sent().code,o=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:o}]}}))}))}}),Object.defineProperty(t.prototype,"hungup",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e,t,r;return i(this,(function(o){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 n(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,"userOffline",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;this._logger.debug("_","[RCCallStateMachine] userOffline -> userIds: ".concat(JSON.stringify(e))),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_NETWORK_ERROR),t._watchers.onHungup(r,exports.RCCallEndReason.REMOTE_NETWORK_ERROR),delete t._userInfo[e]),Object.keys(t._userInfo).length<2&&t._sessionState!==exports.RCCallSessionState.END&&(t._endTimestamp=Date.now(),t._notifyStateChange(exports.RCCallSessionState.END,exports.RCCallEndReason.REMOTE_NETWORK_ERROR))}))}}),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 o={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(o))),o}}),t}();exports.RCCallMediaType=void 0,(I=exports.RCCallMediaType||(exports.RCCallMediaType={}))[I.AUDIO=1]="AUDIO",I[I.AUDIO_VIDEO=2]="AUDIO_VIDEO",function(e){e[e.ADD=1]="ADD",e[e.REMOVE=2]="REMOVE"}(y||(y={})),function(e){e.WEB="Web",e.IOS="iOS",e.ANDROID="Android"}(v||(v={}));var S,T,M=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,o=e.targetId,n=e.senderUserId,i=e.content,s=i.callId,a=i.mediaType;this._channelId=t,this._conversationType=r,this._targetId=o,this._callId=s,this._mediaType=a;this._inviterId=n,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,o=e.senderUserId,n=t.reason,i=o===this._context.getCurrentId();this._endReason=i?n:E[n],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}(),x=["RC:VCAccept","RC:VCRinging","RC:VCSummary","RC:VCHangup","RC:VCInvite","RC:VCModifyMedia","RC:VCModifyMem"],P=((S={})[e.ErrorCode.REJECTED_BY_BLACKLIST]=exports.RCCallErrorCode.REJECTED_BY_BLACKLIST,S[e.ErrorCode.NOT_IN_GROUP]=exports.RCCallErrorCode.NOT_IN_GROUP,S),w=function(t){function o(e,r,o,n,i){void 0===n&&(n=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:o}),Object.defineProperty(s,"_offlineMsgItv",{enumerable:!0,configurable:!0,writable:!0,value:n}),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=f(r),s._context.onmessage=s._onMessage.bind(s),s._offlineRecorder=new M(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 o(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}(o,t),Object.defineProperty(o.prototype,"_onMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(x.includes(e.messageType)){this._logger.debug("_","[CallMessageHandler] _onMessage -> call message: ".concat(JSON.stringify(e)));try{var t=Date.now(),r=e.sentTime,o=0;this._msgBufferList.forEach((function(e,t){var n=e.msg.sentTime;r>=n&&(o=t+1)})),this._msgBufferList.splice(o,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(o.prototype,"_onRecvOnlineCallMsg",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=e.content.callId;switch(this._logger.info("_","recv -> senderId: ".concat(e.senderUserId,", type: ").concat(e.messageType,", callId: ").concat(r)),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("_","recv -> unexpected message: ".concat(e.messageType))}}}),Object.defineProperty(o.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(),o=t._msgBufferList.filter((function(e){return r-e.markTime>=200}));if(t._logger.debug("_","[CallMessageHandler] handleBufferMsgs -> lists over 200ms : ".concat(JSON.stringify(o.map((function(e){var t=e.msg;return{messageUId:t.messageUId,isOffLineMessage:t.isOffLineMessage,callId:t.content.callId}}))))),0===o.length)return t._hadHandleMsgTimer=!1,void t._handleBufferMsgs();if(o[0].msg.isOffLineMessage){var n=t._msgBufferList.filter((function(e){return e.msg.isOffLineMessage})),i=function(){var r=n[0].msg,o=r.conversationType,i=r.messageType,l=r.sentTime,c=r.senderUserId,u=r.content,d=u.callId,C=u.inviteUserIds,_=[p.VCInvite,p.VCModifyMem].includes(i),h=t._context.getServerTime()-l,f=h<t._offlineMsgItv;if(f||t._logger.warn("_","offline msg delayTime: ".concat(h,"ms")),_){for(var R=[],g=0;g<n.length;g++){var b=n[g].msg;if(d!==b.content.callId)break;R.push(b)}if(t._logger.warn("_","taskMsgList length: ".concat(R.length)),R.length>0){var E=t._msgBufferList.findIndex((function(e){return e.msg.messageUId===R[R.length-1].messageUId}));t._msgBufferList=t._msgBufferList.slice(E+1);var I=n.findIndex((function(e){return e.msg.messageUId===R[R.length-1].messageUId}));n=n.slice(I+1)}var y=function(){if(o!==e.ConversationType.PRIVATE)return!1;var t=1===R.length,r=R.every((function(e){return[p.VCInvite,p.VCModifyMedia,p.VCRinging].includes(e.messageType)}));return t||r}(),v=function(){if(o!==e.ConversationType.GROUP)return!1;for(var r=!1,n=!0,i=a([c],s(C),!1),l=!1,u=function(e){var r=R[e],o=r.senderUserId,s=r.messageType;if(s===p.VCHangup&&o===t._context.getCurrentId())return"break";s===p.VCHangup&&(l=c===o,i=i.filter((function(e){return o!==e}))),s===p.VCAccept&&(n=!1)},d=0;d<R.length;d++){if("break"===u(d))break}return n&&l||!(i.length>1)||(r=!0),r}();f&&(y||v)&&R.forEach(t._onRecvOnlineCallMsg,t),t._offlineRecorder.onRecvOfflineMsgs(R)}else f&&t._getStateMachine(d)?t._onRecvOnlineCallMsg(n[0].msg):t._logger.debug("_","[CallMessageHandler] unexcepted offline msg -> ".concat(JSON.stringify(n[0].msg))),n.shift(),t._msgBufferList.shift()};do{i()}while(n.length>0)}else{o.forEach((function(e){var r=e.msg;t._onRecvOnlineCallMsg(r)}));var l=o.length;t._msgBufferList.splice(0,l),t._logger.debug("_","timer online msg handle -> delCount: ".concat(l," msgBufferList: ").concat(t._msgBufferList.length))}t._hadHandleMsgTimer=!1,t._handleBufferMsgs()}),20))}}),Object.defineProperty(o.prototype,"registerEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){Object.assign(this._watchers,e)}}),Object.defineProperty(o.prototype,"registerStateMachineEvent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,o){var n=e+r;t.prototype.on.call(this,n,o)}}),Object.defineProperty(o.prototype,"unregisterStateMachineEvent",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=this;["onRinging","onAccept","onHungup","onMediaModify"].forEach((function(o){var n=e+o;t.prototype.removeAll.call(r,n)}))}}),Object.defineProperty(o.prototype,"registerUserInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._userInfo=e}}),Object.defineProperty(o.prototype,"_sendCallMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return n(this,void 0,void 0,(function(){var r,o,n,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,o=t.conversationType,n=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(o,n,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:P[_]||exports.RCCallErrorCode.SEND_MSG_ERROR}]):[2,{code:exports.RCCallErrorCode.SUCCESS,message:h}]}}))}))}}),Object.defineProperty(o.prototype,"sendInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return n(this,void 0,void 0,(function(){var r,o,n,s,a,l,c,u,d,C;return i(this,(function(i){return r=t.roomType,o=t.channelId,n=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:v.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:o,conversationType:n,targetId:s,content:C,messageType:p.VCInvite,directionalUserIdList:n===e.ConversationType.GROUP?c:void 0,pushConfig:d})]}))}))}}),Object.defineProperty(o.prototype,"sendMemeberModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return n(this,void 0,void 0,(function(){var t,r,o,n,s,a,l,c,u,d,C,_;return i(this,(function(i){return t=e.channelId,r=e.conversationType,o=e.targetId,n=e.callId,s=e.mediaType,a=e.inviteUserIds,l=e.callerId,c=e.existedUserPofiles,u=e.directionalUserIdList,d=e.extra,C=e.pushConfig,_={platform:v.WEB,deviceId:this._deviceId,callId:n,extra:d,engineType:4,channelInfo:{Id:n,Key:""},mediaType:s,inviteUserIds:a,observerUserIds:[],user:this._userInfo,caller:l,modifyMemType:y.ADD,existedUserPofiles:c},C&&(C.pushData=JSON.stringify({mediaType:s,userIdList:a,callId:n})),[2,this._sendCallMessage({channelId:t,conversationType:r,targetId:o,content:_,messageType:p.VCModifyMem,directionalUserIdList:u,pushConfig:C})]}))}))}}),Object.defineProperty(o.prototype,"sendRinging",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=t.channelId,o=t.conversationType,n=t.targetId,i=t.callId,s=t.userIds,a={platform:v.WEB,deviceId:this._deviceId,callId:i,user:this._userInfo};return this._sendCallMessage({channelId:r,conversationType:o,targetId:n,content:a,messageType:p.VCRinging,directionalUserIdList:o===e.ConversationType.GROUP?s:void 0})}}),Object.defineProperty(o.prototype,"sendAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=t.channelId,o=t.conversationType,n=t.targetId,i=t.callId,s=t.mediaType,a=t.userIds,l={platform:v.WEB,deviceId:this._deviceId,callId:i,mediaType:s,user:this._userInfo};return this._sendCallMessage({channelId:r,conversationType:o,targetId:n,content:l,messageType:p.VCAccept,directionalUserIdList:o===e.ConversationType.GROUP?a:void 0})}}),Object.defineProperty(o.prototype,"sendHungup",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=t.channelId,o=t.conversationType,n=t.targetId,i=t.callId,s=t.reason,a=t.userIds,l=t.pushConfig,c={platform:v.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:o,targetId:n,content:c,messageType:p.VCHangup,pushConfig:l,directionalUserIdList:o===e.ConversationType.GROUP?a:void 0})}}),Object.defineProperty(o.prototype,"sendMediaModify",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=t.channelId,o=t.conversationType,n=t.targetId,i=t.callId,s=t.mediaType,a=t.userIds,l={platform:v.WEB,deviceId:this._deviceId,callId:i,mediaType:s,user:this._userInfo};return this._sendCallMessage({channelId:r,conversationType:o,targetId:n,content:l,messageType:p.VCModifyMedia,directionalUserIdList:o===e.ConversationType.GROUP?a:void 0})}}),o}(e.EventEmitter);exports.RCCallLanguage=void 0,(T=exports.RCCallLanguage||(exports.RCCallLanguage={})).ZH="zh",T.EN="en";var N,A={PushTitle:{AUDIO:"You have a voice call",VIDEO:"You have a video call"}},U={PushTitle:{AUDIO:"您有一条音频通话",VIDEO:"您有一条视频通话"}},L=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?A:U}}),Object.defineProperty(e,"_lang",{enumerable:!0,configurable:!0,writable:!0,value:exports.RCCallLanguage.ZH}),e}(),j=function(){function t(e,t,r,o,n){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:o}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:n}),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.12"," CommitId: ").concat("8a43e2bc64278418f888658b54363c97d7bf7bc1")),f(t),this._callMsgHandler=new w(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}),h.on("onStateMachineClose",(function(e){delete i._stateMachine[e]})),L.set(n.lang)}return Object.defineProperty(t.prototype,"_onInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.channelId,r=e.conversationType,o=e.targetId,n=e.content,i=e.messageType,a=e.senderUserId;e.pushConfig;var l,c=n,u=c.mediaType,d=c.callId,C=c.extra;l=c.roomType!==b.RCCallRoomTypeAcrossCall?a:s(a.split("_"),2)[1];var _=this._context.getCurrentId();if(this._context.getCurrentId()!==l){if(i===p.VCModifyMem)if(n.existedUserPofiles.some((function(e){return e.userId===_}))&&!this._stateMachine[d])return;if(this._stateMachine[d])i===p.VCModifyMem&&this._stateMachine[d].__onMemberModify(e);else this._stateMachine[d]=new O(this._context,this._runtime,this._logger,this._callMsgHandler,t,r,o,u,d),this._logger.info("_","[RCCallEngine] RCCallStateMachine successfully created -> callId: ".concat(d)),i===p.VCInvite?this._stateMachine[d].__onInvite(e):i===p.VCModifyMem&&this._stateMachine[d].__onMemberModify(e),this._watchers.onInvite(this._stateMachine[d],C),Object.keys(this._stateMachine).filter((function(e){return d!==e})).length>0&&!this._options.isAllowAcceptNewCall&&this._stateMachine[d].__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,o,s,a,l){return void 0===s&&(s=""),void 0===l&&(l=!1),n(this,void 0,void 0,(function(){var n,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:o,extra:s,pushConfig:a}))),n=_(),Object.keys(this._stateMachine).length>0?[2,{code:exports.RCCallErrorCode.STATE_MACHINE_EXIT}]:(this._stateMachine[n]=new O(this._context,this._runtime,this._logger,this._callMsgHandler,t,e.ConversationType.PRIVATE,r,o,n),[4,this._stateMachine[n].__call([r],s,a,l)]);case 1:return(c=i.sent().code)===exports.RCCallErrorCode.SUCCESS?[2,{code:exports.RCCallErrorCode.SUCCESS,stateMachine:this._stateMachine[n]}]:[2,{code:c}]}}))}))}}),Object.defineProperty(t.prototype,"callInGroup",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,o,s,a,l){return void 0===a&&(a=""),n(this,void 0,void 0,(function(){var n,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:o}))),n=_(),Object.keys(this._stateMachine).length>0?[2,{code:exports.RCCallErrorCode.STATE_MACHINE_EXIT}]:(this._stateMachine[n]=new O(this._context,this._runtime,this._logger,this._callMsgHandler,t,e.ConversationType.GROUP,r,o,n),[4,this._stateMachine[n].__call(s,a,l)]);case 1:return(c=i.sent().code)===exports.RCCallErrorCode.SUCCESS?[2,{code:exports.RCCallErrorCode.SUCCESS,stateMachine:this._stateMachine[n]}]:[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"}(N||(N={}));var k=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,o=function(n){r.off(e,o),t.call(r,n)};o.fun=t,this.on(e,o)}}),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 o=void 0,n=0,i=r.length;n<i;n++)if((o=r[n])===t||o.fun===t){r.splice(n,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,o=a([],s(this.list[e]),!1);if(!o||0===o.length)return!1;o.forEach((function(e){e.call(r,t)}))}}),e}());var D=function(t){if(!t)return{ok:!1,msg:"Initialization missing parameter -> options"};if("object"!=typeof t)return{ok:!1,msg:"Initialization options must be an object"};var r,o=Object.keys(t),n=[];return["rtcClient","onSession","onSessionClose"].forEach((function(e){o.includes(e)||n.push(e)})),n.length?{ok:!1,msg:'Initialization missing parameter -> "'.concat(n.join(","),'"')}:"object"!=typeof t.rtcClient?{ok:!1,msg:"Initialization 'rtcClient' parameter must be of type 'object'"}:"function"!=typeof t.onSession?{ok:!1,msg:"Initialization 'onSession' parameter must be of type 'function'"}:"function"!=typeof t.onSessionClose?{ok:!1,msg:"Initialization 'onSessionClose' parameter must be of type 'function'"}:void 0!==t.isAllowSubscribeRetry&&"boolean"!=typeof t.isAllowSubscribeRetry?{ok:!1,msg:"Initialization 'isAllowSubscribeRetry' parameter must be of type 'boolean'"}:void 0!==t.isAllowPublishRetry&&"boolean"!=typeof t.isAllowPublishRetry?{ok:!1,msg:"Initialization 'isAllowPublishRetry' parameter must be of type 'boolean'"}:void 0!==t.isOffCameraWhenVideoDisable&&"boolean"!=typeof t.isOffCameraWhenVideoDisable?{ok:!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?{ok:!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)?{ok:!0}:{ok:!1,msg:"Initialization 'logOutputLevel' parameter must be of type correct type"}:{ok:!1,msg:"Initialization 'lang' parameter must be of type correct type"}:{ok:!1,msg:"Initialization 'joinType' parameter must be of type correct type"}},H=function(e){if(!e)return{ok:!1,msg:"missing parameter -> listener"};if("object"!=typeof e)return{ok:!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?{ok:!1,msg:'missing parameter -> "'.concat(r.join(","),'"')}:"function"!=typeof e.onRinging?{ok:!1,msg:"'onRinging' parameter must be of type 'function'"}:"function"!=typeof e.onAccept?{ok:!1,msg:"'onAccept' parameter must be of type 'function'"}:"function"!=typeof e.onHungup?{ok:!1,msg:"'onHungup' parameter must be of type 'function'"}:"function"!=typeof e.onTrackReady?{ok:!1,msg:"'onTrackReady' parameter must be of type 'function'"}:{ok:!0}},V=function(e){return e&&"string"==typeof e?{ok:!0}:{ok:!1,msg:"'targetId' parameter is required, must be of type 'string'"}},G=function(e){return e===exports.RCCallMediaType.AUDIO||e===exports.RCCallMediaType.AUDIO_VIDEO?{ok:!0}:{ok:!1,msg:"'mediaType' parameter is required, must be of type 'RCCallMediaType'"}},B=function(e){return"string"==typeof e?{ok:!0}:{ok:!1,msg:"'extra' parameter must be of type 'string'"}},K=function(t){var r=["pushTitle","pushContent","pushData","iOSConfig","androidConfig","disablePushTitle","templateId"],o=Object.keys(t).every((function(e){return r.includes(e)}));if(!o)return{code:exports.RCCallErrorCode.PARAM_ERROR,errorMsg:"right key: ".concat(r.join(","))};for(var n=0;n<r.length;n++){var i=r[n];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=J(s||{});if(l.code!==exports.RCCallErrorCode.SUCCESS)return l;var c=W(a||{});return c.code!==exports.RCCallErrorCode.SUCCESS?c:{code:exports.RCCallErrorCode.SUCCESS}},J=function(t){var r=t||{},o=r.threadId,n=r.richMediaUri;return o&&!e.isString(o)?{code:exports.RCCallErrorCode.PARAM_ERROR,errorMsg:"iOSConfig.threadId type is string"}:n&&!e.isString(n)?{code:exports.RCCallErrorCode.PARAM_ERROR,errorMsg:"iOSConfig.richMediaUri type is string"}:{code:exports.RCCallErrorCode.SUCCESS}},W=function(t){var r=["notificationId","channelIdMi","channelIdHW","categoryHW","importanceHW","imageUrlHW","channelIdOPPO","typeVivo","categoryVivo","fcmChannelId","fcmCollapseKey","fcmImageUrl","importanceHonor","imageUrlHonor"],o=Object.keys(t).every((function(e){return r.includes(e)}));if(!o)return{code:exports.RCCallErrorCode.PARAM_ERROR,errorMsg:"right key: ".concat(r.join(","))};for(var n=0;n<r.length;n++){var i=r[n];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}},Y=function(e){return Array.isArray(e)&&e.length?e.every((function(e){return"string"==typeof e&&e.length>0}))?{ok:!0}:{ok:!1,msg:"'userIds' parameter is required"}:{ok:!1,msg:"'userIds' parameter is required, must be of type 'string[]'"}};var F=function(e){return e&&e.audio&&void 0!==e.audio.micphoneId&&"string"!=typeof e.audio.micphoneId?{ok:!1,msg:"'constraints.audio.micphoneId' must be of type 'string'"}:e&&e.audio&&void 0!==e.audio.sampleRate&&"number"!=typeof e.audio.sampleRate?{ok:!1,msg:"'constraints.audio.sampleRate' must be of type 'number'"}:e&&e.video&&void 0!==e.video.cameraId&&"string"!=typeof e.video.cameraId?{ok:!1,msg:"'constraints.video.cameraId' must be of type 'string'"}:e&&e.video&&void 0!==e.video.frameRate&&"string"!=typeof e.video.frameRate?{ok:!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))?{ok:!1,msg:"'frameRate' value is out of range"}:e&&e.video&&void 0!==e.video.resolution&&"string"!=typeof e.video.resolution?{ok:!1,msg:"'constraints.video.frameRate' must be of type 'string'"}:e&&e.video&&void 0!==e.video.resolution&&(o=e.video.resolution,!t.RCResolution[o])?{ok:!1,msg:"'resolution' value is out of range"}:!e||!e.video||e.video.frameRate&&e.video.resolution?{ok:!0}:{ok:!1,msg:"'resolution' and 'resolution' is required"};var r,o},z=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}(),q=function(){function r(e,t,r,o){void 0===o&&(o={});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:o}),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 n(s,void 0,void 0,(function(){var t,r,o,n,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];o=this._stateMachine.getCallId(),this._logger.info("_","[RCCallSession onStateChange] roomId: ".concat(o)),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this._joinRoom(o)];case 2:return i.sent(),[3,4];case 3:return n=i.sent(),this._exceptionClose(exports.RCCallEndReason.NETWORK_ERROR),this._logger.error("_","[RCCallSession onStateChange] joinRoom throw exception roomId -> ".concat(o)),console.error(n),[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(),k.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 n(this,void 0,void 0,(function(){var o,n,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 o=i.sent(),[3,4];case 2:return[4,this._rtcClient.joinRTCRoom(r,this._options.joinType)];case 3:o=i.sent(),i.label=4;case 4:return n=o.code,s=o.userIds,a=o.room,n!==t.RCRTCCode.SUCCESS?(n===t.RCRTCCode.NOT_OPEN_VIDEO_AUDIO_SERVER&&this._exceptionClose(exports.RCCallEndReason.SERVICE_NOT_OPENED),n===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(n)),[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 z((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 n(this,void 0,void 0,(function(){var e,r;return i(this,(function(o){switch(o.label){case 0:return(e=this._room.getRemoteTracks()).length?[4,this._subscribeRetry(e,this._options.isAllowSubscribeRetry,this._RETRYCOUNT)]:[3,2];case 1:(r=o.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))),o.label=2;case 2:return[2]}}))}))}}),Object.defineProperty(r.prototype,"_subscribeRetry",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,o){return void 0===r&&(r=!1),void 0===o&&(o=0),n(this,void 0,void 0,(function(){var n;return i(this,(function(i){switch(i.label){case 0:return[4,this._room.subscribe(e)];case 1:if((n=i.sent().code)!==t.RCRTCCode.SUCCESS){try{this._listener.onTrackSubscribeFail&&this._listener.onTrackSubscribeFail(n,this)}catch(e){this._logger.error("_","[RCCallSession] _listener.onTrackSubscribeFail exception"),console.error(e)}if(!r)return[2,{code:n}];if(o>0)return o--,[2,this._subscribeRetry(e,r,o)]}return[2,{code:n}]}}))}))}}),Object.defineProperty(r.prototype,"_publish",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e,r;return i(this,(function(o){switch(o.label){case 0:return e=this._options.localTracks,[4,this._publishRetry(e,this._options.isAllowPublishRetry,this._RETRYCOUNT)];case 1:return(r=o.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===N.CALLEE&&this._notifyTrackReady(e),[2])}}))}))}}),Object.defineProperty(r.prototype,"_publishRetry",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,o){return void 0===r&&(r=!1),void 0===o&&(o=0),n(this,void 0,void 0,(function(){var n;return i(this,(function(i){switch(i.label){case 0:return[4,this._room.publish(e)];case 1:if((n=i.sent().code)!==t.RCRTCCode.SUCCESS){try{this._listener.onTrackPublishFail&&this._listener.onTrackPublishFail(n,this)}catch(e){this._logger.error("_","[RCCallSession] _listener.onTrackPublishFail exception"),console.error(e)}if(!r)return[2,{code:n}];if(o>0)return o--,[2,this._publishRetry(e,r,o)]}return[2,{code:n}]}}))}))}}),Object.defineProperty(r.prototype,"_leaveRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e,t,r;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,3,4]),[4,this._rtcClient.leaveRoom(this._room)];case 1:return e=o.sent(),this._logger.info("_","[RCCallSession _leaveRoom] Successfully exited the room code: ".concat(e.code)),[3,4];case 2:return t=o.sent(),this._logger.error("_","[RCCallSession _leaveRoom] leaveRoom throw exception"),console.error(t),[3,4];case 3:return r=this._stateMachine.getSummary(),k.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=H(e);if(!t.ok)throw new Error("[RCCallSession registerSessionListener] ".concat(t.msg));this._listener=o({},e)}}),Object.defineProperty(r.prototype,"_getLocalTrackCore",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){return n(this,void 0,void 0,(function(){var n,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&&o({},r.audio))];case 1:return n=i.sent(),s=n.code,a=n.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&&o({},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 n(this,void 0,void 0,(function(){var r,o,n,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(),o=r.code,n=r.tracks,o===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:o,tracks:n}];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 n(this,void 0,void 0,(function(){var r,o,n,s,a;return i(this,(function(i){switch(i.label){case 0:return r=[],o=[],[4,this._rtcClient.createMicrophoneAudioTrack("RongCloudRTC",e)];case 1:return n=i.sent(),s=n.code,a=n.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()||o.push(e)})),r.push(a),o.push(a),this._options.localTracks=o,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={}),n(this,void 0,void 0,(function(){var r,o,n,s,a,l,c,u;return i(this,(function(i){switch(i.label){case 0:if(r=t.extra,o=void 0===r?"":r,n=this._options.callPushConfig?this._options.callPushConfig:t.pushConfig,s=[Y(e),B(o)],n&&(a=K(n),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.ok&&u.push(e.msg),e.ok})))throw new Error("[RCCallClient invite] ".concat(u.join("\n")));return[4,this._stateMachine.invite(e,{extra:o,pushConfig:n})];case 1:return[2,{code:i.sent().code}]}}))}))}}),Object.defineProperty(r.prototype,"accept",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return n(this,void 0,void 0,(function(){var t,r,o,n,s,a;return i(this,(function(i){switch(i.label){case 0:if(!(t=F(e)).ok)throw new Error("[RCCallSession accept] ".concat(t.msg));return k.emit("hungupOtherSession",{session:this}),r=this._stateMachine.getMediaType(),[4,this._getLocalTrack(r,e)];case 1:return o=i.sent(),n=o.code,s=o.tracks,n!==exports.RCCallErrorCode.SUCCESS?[2,{code:n}]:this._stateMachine.getState()===exports.RCCallSessionState.END?(this._destroyTracks(s),[2,{code:exports.RCCallErrorCode.SESSION_ENDED}]):(this._options.localTracks=s,[4,this._stateMachine.accept()]);case 2:return a=i.sent().code,this._stateMachine.getState()===exports.RCCallSessionState.END?(this._destroyTracks(s),[2,{code:exports.RCCallErrorCode.SESSION_ENDED}]):a!==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 n(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 n(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 n(this,void 0,void 0,(function(){var e,r,o;return i(this,(function(n){switch(n.label){case 0:return[4,this._rtcClient.createCameraVideoTrack()];case 1:return e=n.sent(),r=e.code,o=e.track,r!==t.RCRTCCode.SUCCESS?[2,{code:exports.RCCallErrorCode.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR}]:[4,this._room.publish([o])];case 2:return n.sent().code!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession _enableVideo] Resource publishing failed: RCRTCCode -> ".concat(r)),[2]):(this._notifyTrackReady([o]),this._changeMediaType(exports.RCCallMediaType.AUDIO_VIDEO),[2])}}))}))}}),Object.defineProperty(r.prototype,"_setMediaTypeToAudio",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e,r;return i(this,(function(o){switch(o.label){case 0:return(e=this._getLocalVideoTracks()).length?(e.forEach((function(e){e.mute()})),[4,this._room.unpublish(e)]):[3,2];case 1:(r=o.sent().code)!==t.RCRTCCode.SUCCESS&&this._logger.error("_","[RCCallSession disableVideo] unpublish failed -> ".concat(r)),this._destroyTracks(e),o.label=2;case 2:return[2]}}))}))}}),Object.defineProperty(r.prototype,"descendAbility",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(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 n(this,void 0,void 0,(function(){var e,r;return i(this,(function(o){switch(o.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=o.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 n(this,void 0,void 0,(function(){var e,r,o,n,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(),o=r.code,n=r.track,o!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession EnableVideoTrack] Get Resource failed: RCRTCCode -> ".concat(o)),[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(n),this._options.localTracks=s,n.mute(),[4,this._room.publish([n])]);case 2:return i.sent().code!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession EnableVideoTrack] Resource publishing failed: RCRTCCode -> ".concat(o)),[2,{code:exports.RCCallErrorCode.VIDEO_PUBLISH_ERROR}]):(n.unmute(),this._notifyTrackReady([n]),[2,{code:exports.RCCallErrorCode.SUCCESS}])}}))}))}}),Object.defineProperty(r.prototype,"disableAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e,r;return i(this,(function(o){switch(o.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=o.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 n(this,void 0,void 0,(function(){var e,r;return i(this,(function(o){switch(o.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=o.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,o){var n=e._rtcClient.getCurrentId();e._stateMachine.userLeave([n]),r?(o===t.RCKickReason.SERVER_KICK&&e._exceptionClose(exports.RCCallEndReason.KICKED_BY_SERVER),o===t.RCKickReason.OTHER_KICK&&e._exceptionClose(exports.RCCallEndReason.OTHER_CLIENT_JOINED_CALL)):e._exceptionClose(exports.RCCallEndReason.NETWORK_ERROR)},onMessageReceive:function(e,t,r,o){},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 n(e,void 0,void 0,(function(){var e;return i(this,(function(o){switch(o.label){case 0:return this._room?[4,this._room.subscribe(r)]:[3,2];case 1:(e=o.sent().code)!==t.RCRTCCode.SUCCESS&&this._logger.error("_","[RCCallSession onTrackPublish] subscribe failed RTCCode ->".concat(e)),o.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)},onUserOffline:function(t){e._logger.info("_","[RCCallSession onUserOffline] listening onUserOffline userIds -> ".concat(null==t?void 0:t.join(","))),e._stateMachine.userOffline(t)},onPing:function(t){var r,o;try{null===(o=null===(r=e._listener)||void 0===r?void 0:r.onPing)||void 0===o||o.call(r,t,e)}catch(e){console.error(e)}}})}}),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,o;try{null===(o=null===(r=e._listener)||void 0===r?void 0:r.onICEConnectionStateChange)||void 0===o||o.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}(),X=function(){function r(t,r,n,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:n}),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=o({isAllowPublishRetry:!1,isAllowSubscribeRetry:!1,isOffCameraWhenVideoDisable:!0,joinType:e.RTCJoinType.COEXIST,isAllowDemotionGetStream:!1,lang:exports.RCCallLanguage.ZH},i),this._callEngine=new j(this._context,r,this._logger,{onInvite:this._onInvite.bind(this),onOfflineRecord:this._onOfflineRecord.bind(this)},{lang:this._options.lang||exports.RCCallLanguage.ZH}),k.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)}})),k.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 q(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:N.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 o=H(r._listener);if(!o.ok)throw new Error(o.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,o=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,f=void 0===h?"":h,p=e.bitrate;return n(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.__call({targetId:t,mediaType:o,listener:s,constraints:a,channelId:c,extra:d,pushTitle:_,pushContent:f,bitrate:p,isCrossAppkey:!0})]}))}))}}),Object.defineProperty(r.prototype,"call",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.targetId,r=e.mediaType,o=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,f=void 0===h?"":h,p=e.bitrate;return n(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.__call({targetId:t,mediaType:o,listener:s,constraints:a,channelId:c,extra:d,pushTitle:_,pushContent:f,bitrate:p})]}))}))}}),Object.defineProperty(r.prototype,"__call",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.targetId,r=e.mediaType,o=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,f=void 0===h?"":h,p=e.bitrate,R=e.isCrossAppkey,g=void 0!==R&&R;return n(this,void 0,void 0,(function(){var e,r,n,l,u,C,h,R,b,E,I,y,v,m;return i(this,(function(i){switch(i.label){case 0:return e=this._callPushConfig?this._callPushConfig:{pushTitle:_,pushContent:f},this._logger.info("_","[RCCallClient call] targetId: ".concat(t,", mediaType: ").concat(o)),t===this._context.getCurrentId()?(this._logger.error("_","[RCCallClient call] targetId is equal to currentId"),[2,{code:exports.RCCallErrorCode.PARAM_ERROR}]):(r=[V(t),G(o),H(s),B(d)],n=[],r.every((function(e){return!e.ok&&n.push(e.msg),e.ok}))?(l=K(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(o,a)])):(console.error(n.join("\n")),[2,{code:exports.RCCallErrorCode.PARAM_ERROR}]));case 1:return R=i.sent(),b=R.code,E=R.tracks,b!==exports.RCCallErrorCode.SUCCESS?[2,{code:b}]:((h=E).forEach((function(e){var t,r,o;e.isAudioTrack()&&(null==p?void 0:p.audio)&&e.setBitrate(null==p?void 0:p.audio),e.isVideoTrack()&&(null==p?void 0:p.video)&&e.setBitrate(null===(t=null==p?void 0:p.video)||void 0===t?void 0:t.max,null===(r=null==p?void 0:p.video)||void 0===r?void 0:r.min,null===(o=null==p?void 0:p.video)||void 0===o?void 0:o.start),s.onTrackReady(e)})),[4,this._callEngine.call(c,t,o,d,e,g)]);case 2:return I=i.sent(),y=I.code,v=I.stateMachine,y===exports.RCCallErrorCode.SUCCESS&&v?(this._logger.info("_","[RCCallClient call] successfully created state machine"),(m=new q(v,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:N.CALLER,isCrossAppkey:g,callPushConfig:this._callPushConfig,hungupPushConfig:this._hungupPushConfig})).registerSessionListener(s),this._sessionList.push(m),this._logger.info("_","[RCCallClient call] successfully created session object, sessionId: ".concat(m.getSessionId())),[2,{code:y,session:m}]):(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,o=e.mediaType,s=void 0===o?exports.RCCallMediaType.AUDIO:o,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===_?"":_,f=e.pushContent,p=void 0===f?"":f,R=e.bitrate;return n(this,void 0,void 0,(function(){var e,o,n,c,d,_,f,g,b,E,I,y,v,m,O;return i(this,(function(i){switch(i.label){case 0:return e=this._callPushConfig?this._callPushConfig:{pushTitle:h,pushContent:p},o=[V(t),Y(r),G(s),H(a),B(C)],n=[],c=o.every((function(e){return!e.ok&&n.push(e.msg),e.ok})),r.includes(this._context.getCurrentId())?(console.error("[RCCallClient callInGroup] userIds includes currentId"),[2,{code:exports.RCCallErrorCode.PARAM_ERROR}]):c?(d=K(e),_=d.code,f=d.errorMsg,_!==exports.RCCallErrorCode.SUCCESS?(this._logger.error("_","[RCCallClient call] param error, errorMsg: ".concat(f)),[2,{code:_}]):(g=[],[4,this._getLocalTrack(s,l)])):(console.error("[RCCallClient callInGroup] ".concat(n.join("\n"))),[2,{code:exports.RCCallErrorCode.PARAM_ERROR}]);case 1:return b=i.sent(),E=b.code,I=b.tracks,E!==exports.RCCallErrorCode.SUCCESS?[2,{code:E}]:((g=I).forEach((function(e){var t,r,o;e.isAudioTrack()&&(null==R?void 0:R.audio)&&e.setBitrate(null==R?void 0:R.audio),e.isVideoTrack()&&(null==R?void 0:R.video)&&e.setBitrate(null===(t=null==R?void 0:R.video)||void 0===t?void 0:t.max,null===(r=null==R?void 0:R.video)||void 0===r?void 0:r.min,null===(o=null==R?void 0:R.video)||void 0===o?void 0:o.start),a.onTrackReady(e)})),[4,this._callEngine.callInGroup(u,t,s,r,C,e)]);case 2:return y=i.sent(),v=y.code,m=y.stateMachine,v===exports.RCCallErrorCode.SUCCESS&&m?(this._logger.info("_","[RCCallClient callInGroup] successfully created state machine"),(O=new q(m,this._rtcClient,this._logger,{localTracks:g,isAllowSubscribeRetry:this._options.isAllowSubscribeRetry,isAllowPublishRetry:this._options.isAllowPublishRetry,isOffCameraWhenVideoDisable:this._options.isOffCameraWhenVideoDisable,joinType:this._options.joinType,isAllowDemotionGetStream:this._options.isAllowDemotionGetStream,produceType:N.CALLER,callPushConfig:this._callPushConfig,hungupPushConfig:this._hungupPushConfig})).registerSessionListener(a),this._sessionList.push(O),this._logger.info("_","[RCCallClient callInGroup] successfully created session object, sessionId: ".concat(O.getSessionId())),[2,{code:v,session:O}]):(this._logger.info("_","[RCCallClient callInGroup] callInGroup failed code -> ".concat(v)),g.forEach((function(e){e.mute(),e.destroy()})),[2,{code:v}])}}))}))}}),Object.defineProperty(r.prototype,"_getLocalTrackCore",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){return n(this,void 0,void 0,(function(){var n,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&&o({},r.audio))];case 1:return n=i.sent(),s=n.code,a=n.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&&o({},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 n(this,void 0,void 0,(function(){var r,o,n,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(),o=r.code,n=r.tracks,o===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:o,tracks:n}];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 n(this,void 0,void 0,(function(){var t,r,o;return i(this,(function(n){switch(n.label){case 0:return[4,this._context.getRTCJoinedUserInfo(this._context.getCurrentId())];case 1:return t=n.sent(),r=t.code,o=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:o}]}}))}))}}),Object.defineProperty(r.prototype,"setPushConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,o,n=[e,t].map((function(e){return K(e)}));try{for(var i=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],o=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(n),s=i.next();!s.done;s=i.next()){var a=s.value,l=a.code,c=a.errorMsg;if(l!==exports.RCCallErrorCode.SUCCESS)return this._logger.error("_","[RCCallClient setPushConfig] param error, errorMsg: ".concat(c)),{code:l}}}catch(e){r={error:e}}finally{try{s&&!s.done&&(o=i.return)&&o.call(i)}finally{if(r)throw r.error}}this._callPushConfig=e,this._hungupPushConfig=t}}),r}();e.VersionManage.add("calllib","5.2.12");var Z={tag:"RCCall",verify:function(e){return"browser"===e.tag},setup:function(t,r,o){var n=D(o);if(!n.ok)throw new Error("[RCCallLib installer steup]".concat(n.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 o.logOutputLevel&&i.setOutputLevel(o.logOutputLevel),void 0!==o.logLevel&&i.warn("_","The 'logLevel' parameter is deprecated, please use 'logOutputLevel' instead."),i.warn("_","RCCall Version: ".concat("5.2.12",", Commit: ").concat("8a43e2bc64278418f888658b54363c97d7bf7bc1")),new X(t,r,i,o)}};exports.RCCallClient=X,exports.RCCallSession=q,exports.installer=Z;
|
package/dist/index.d.ts
CHANGED
|
@@ -92,7 +92,11 @@ declare enum RCCallErrorCode {
|
|
|
92
92
|
/**
|
|
93
93
|
* 缺少本地音频流
|
|
94
94
|
*/
|
|
95
|
-
MISSING_AUDIO_TRACK_ERROR = 53314
|
|
95
|
+
MISSING_AUDIO_TRACK_ERROR = 53314,
|
|
96
|
+
/**
|
|
97
|
+
* 通话已结束
|
|
98
|
+
*/
|
|
99
|
+
SESSION_ENDED = 53315
|
|
96
100
|
}
|
|
97
101
|
|
|
98
102
|
/**
|
|
@@ -1451,6 +1455,10 @@ declare class RCCallStateMachine {
|
|
|
1451
1455
|
* 通话中远端用户挂断,挂断消息未到,但是监听到 rtc userLeave 同样补偿更新用户、房间状态
|
|
1452
1456
|
*/
|
|
1453
1457
|
userLeave(userIds: string[]): void;
|
|
1458
|
+
/**
|
|
1459
|
+
* 远端人员离线通知
|
|
1460
|
+
*/
|
|
1461
|
+
userOffline(userIds: string[]): void;
|
|
1454
1462
|
/**
|
|
1455
1463
|
* Call 层己方异常失败后调用的方法
|
|
1456
1464
|
* 触发时机:音视频服务异常、获取资源失败、加入 RTC 房间失败、发布|订阅失败
|
|
@@ -1629,7 +1637,7 @@ declare class RCCallClient {
|
|
|
1629
1637
|
* @description callLib 会内置 IPushConfig 中 pushData 的赋值,业务层无需关注 pushData 字段值
|
|
1630
1638
|
*/
|
|
1631
1639
|
setPushConfig(callPushConfig: IPushConfig, hungupPushConfig: IPushConfig): {
|
|
1632
|
-
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;
|
|
1640
|
+
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 | RCCallErrorCode.SESSION_ENDED;
|
|
1633
1641
|
} | undefined;
|
|
1634
1642
|
}
|
|
1635
1643
|
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{EventEmitter as e,ConversationType as t,ErrorCode as n,isUndefined as r,isBoolean as i,isString as o,RTCJoinType as
|
|
1
|
+
import{EventEmitter as e,ConversationType as t,ErrorCode as n,isUndefined as r,isBoolean as i,isString as o,RTCJoinType as s,LogL as a,VersionManage as l}from"@rongcloud/engine";import{RCResolution as c,RCKickReason as u,RCRTCCode as d}from"@rongcloud/plugin-rtc";var _=function(e,t){return _=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},_(e,t)};var f=function(){return f=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},f.apply(this,arguments)};function h(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{l(r.next(e))}catch(e){o(e)}}function a(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((r=r.apply(e,t||[])).next())}))}function g(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(l){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}}function p(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function b(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var C,R,I,E,m=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(""),n=t.length+1,r=+e,i=[];do{var o=r%n;r=(r-o)/n,i.unshift(t[o])}while(r);return i.join("")}(e=parseInt(e,16))).length>22&&(e=e.slice(0,22)),e},y=function(){var e=Math.floor(1e3*Math.random()),t=m();return[t=t.replace(/\//g,"0"),Date.now(),e].join("_")},v=new e,O=function(e){var t="RCCallDeviceId",n=e.sessionStorage.getItem(t);return n||(n=m(),e.sessionStorage.setItem(t,n)),n};!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"}(C||(C={})),function(e){e[e.SUCCESS=1e4]="SUCCESS",e[e.STATE_MACHINE_EXIT=53200]="STATE_MACHINE_EXIT",e[e.SEND_MSG_ERROR=53201]="SEND_MSG_ERROR",e[e.REJECTED_BY_BLACKLIST=53202]="REJECTED_BY_BLACKLIST",e[e.NOT_IN_GROUP=53203]="NOT_IN_GROUP",e[e.GET_LOCAL_AUDIO_TRACK_ERROR=53301]="GET_LOCAL_AUDIO_TRACK_ERROR",e[e.GET_LOCAL_VIDEO_TRACK_ERROR=53302]="GET_LOCAL_VIDEO_TRACK_ERROR",e[e.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR=53303]="GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR",e[e.JOIN_ROOM_ERROR=53304]="JOIN_ROOM_ERROR",e[e.AUDIO_PUBLISH_ERROR=53305]="AUDIO_PUBLISH_ERROR",e[e.VIDEO_PUBLISH_ERROR=53306]="VIDEO_PUBLISH_ERROR",e[e.AUDIO_AND_VIDEO_PUBLISH_ERROR=53307]="AUDIO_AND_VIDEO_PUBLISH_ERROR",e[e.QUERY_JOINED_USER_INFO_ERROR=53308]="QUERY_JOINED_USER_INFO_ERROR",e[e.MISSING_VIDEO_TRACK_ERROR=53309]="MISSING_VIDEO_TRACK_ERROR",e[e.UNPUBLISH_VIDEO_ERROR=53310]="UNPUBLISH_VIDEO_ERROR",e[e.CONVERSATION_NOT_GROUP_ERROR=53311]="CONVERSATION_NOT_GROUP_ERROR",e[e.NOT_IN_ROOM_ERROR=53312]="NOT_IN_ROOM_ERROR",e[e.PARAM_ERROR=53313]="PARAM_ERROR",e[e.MISSING_AUDIO_TRACK_ERROR=53314]="MISSING_AUDIO_TRACK_ERROR",e[e.SESSION_ENDED=53315]="SESSION_ENDED"}(R||(R={})),function(e){e[e.CANCEL=1]="CANCEL",e[e.REJECT=2]="REJECT",e[e.HANGUP=3]="HANGUP",e[e.BUSY_LINE=4]="BUSY_LINE",e[e.NO_RESPONSE=5]="NO_RESPONSE",e[e.ENGINE_UNSUPPORTED=6]="ENGINE_UNSUPPORTED",e[e.NETWORK_ERROR=7]="NETWORK_ERROR",e[e.GET_MEDIA_RESOURCES_ERROR=8]="GET_MEDIA_RESOURCES_ERROR",e[e.PUBLISH_ERROR=9]="PUBLISH_ERROR",e[e.SUBSCRIBE_ERROR=10]="SUBSCRIBE_ERROR",e[e.REMOTE_CANCEL=11]="REMOTE_CANCEL",e[e.REMOTE_REJECT=12]="REMOTE_REJECT",e[e.REMOTE_HANGUP=13]="REMOTE_HANGUP",e[e.REMOTE_BUSY_LINE=14]="REMOTE_BUSY_LINE",e[e.REMOTE_NO_RESPONSE=15]="REMOTE_NO_RESPONSE",e[e.REMOTE_ENGINE_UNSUPPORTED=16]="REMOTE_ENGINE_UNSUPPORTED",e[e.REMOTE_NETWORK_ERROR=17]="REMOTE_NETWORK_ERROR",e[e.REMOTE_GET_MEDIA_RESOURCE_ERROR=18]="REMOTE_GET_MEDIA_RESOURCE_ERROR",e[e.REMOTE_PUBLISH_ERROR=19]="REMOTE_PUBLISH_ERROR",e[e.REMOTE_SUBSCRIBE_ERROR=20]="REMOTE_SUBSCRIBE_ERROR",e[e.OTHER_CLIENT_JOINED_CALL=21]="OTHER_CLIENT_JOINED_CALL",e[e.OTHER_CLIENT_IN_CALL=22]="OTHER_CLIENT_IN_CALL",e[e.KICKED_BY_SERVER=23]="KICKED_BY_SERVER",e[e.ACCEPT_SYSTEM_CALL=24]="ACCEPT_SYSTEM_CALL",e[e.REMOTE_OTHER_CLIENT_JOINED_CALL=31]="REMOTE_OTHER_CLIENT_JOINED_CALL",e[e.REMOTE_OTHER_CLIENT_IN_CALL=32]="REMOTE_OTHER_CLIENT_IN_CALL",e[e.REMOTE_KICKED_BY_SERVER=33]="REMOTE_KICKED_BY_SERVER",e[e.REMOTE_ACCEPT_SYSTEM_CALL=34]="REMOTE_ACCEPT_SYSTEM_CALL",e[e.ACCEPT_BY_OTHER_CLIENT=101]="ACCEPT_BY_OTHER_CLIENT",e[e.HANGUP_BY_OTHER_CLIENT=102]="HANGUP_BY_OTHER_CLIENT",e[e.ADDED_TO_BLACKLIST=103]="ADDED_TO_BLACKLIST",e[e.SERVICE_NOT_OPENED=104]="SERVICE_NOT_OPENED"}(E||(E={}));var T,S,M,P,w=((I={})[E.CANCEL]=E.REMOTE_CANCEL,I[E.REJECT]=E.REMOTE_REJECT,I[E.HANGUP]=E.REMOTE_HANGUP,I[E.BUSY_LINE]=E.REMOTE_BUSY_LINE,I[E.NO_RESPONSE]=E.REMOTE_NO_RESPONSE,I[E.ENGINE_UNSUPPORTED]=E.REMOTE_ENGINE_UNSUPPORTED,I[E.NETWORK_ERROR]=E.REMOTE_NETWORK_ERROR,I[E.GET_MEDIA_RESOURCES_ERROR]=E.REMOTE_GET_MEDIA_RESOURCE_ERROR,I[E.PUBLISH_ERROR]=E.REMOTE_PUBLISH_ERROR,I[E.SUBSCRIBE_ERROR]=E.REMOTE_SUBSCRIBE_ERROR,I[E.OTHER_CLIENT_JOINED_CALL]=E.REMOTE_OTHER_CLIENT_JOINED_CALL,I[E.OTHER_CLIENT_IN_CALL]=E.REMOTE_OTHER_CLIENT_IN_CALL,I[E.KICKED_BY_SERVER]=E.REMOTE_KICKED_BY_SERVER,I[E.REMOTE_NO_RESPONSE]=E.NO_RESPONSE,I[E.ACCEPT_SYSTEM_CALL]=E.REMOTE_ACCEPT_SYSTEM_CALL,I);!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"}(T||(T={})),function(e){e[e.WAITING=0]="WAITING",e[e.KEEPING=1]="KEEPING",e[e.END=2]="END"}(S||(S={})),function(e){e[e.NONE=0]="NONE",e[e.WAITING=1]="WAITING",e[e.KEEPING=2]="KEEPING"}(M||(M={})),function(e){
|
|
2
2
|
/*!
|
|
3
3
|
同App通话
|
|
4
4
|
*/
|
|
@@ -6,4 +6,4 @@ e[e.RCCallRoomTypeNormalCall=0]="RCCallRoomTypeNormalCall",
|
|
|
6
6
|
/*!
|
|
7
7
|
跨App通话
|
|
8
8
|
*/
|
|
9
|
-
e[e.RCCallRoomTypeAcrossCall=7]="RCCallRoomTypeAcrossCall"}(P||(P={}));var A,N,U,L=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}(),j=function(){function e(e,t,n,r,i,o,a,s,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:n}),Object.defineProperty(this,"_callMsgHandler",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_channelId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_conversationType",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_targetId",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"_mediaType",{enumerable:!0,configurable:!0,writable:!0,value:s}),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(e.prototype,"_getTimeout",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._context.getServerTime()-e;t<0&&(t=500);var n=this._callTimeout-t;return this._logger.warn("_","_getTimeout -> timeout: ".concat(n)),n}}),Object.defineProperty(e.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(e.prototype,"_notifyStateChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n;this._logger.warn("_","[RCCallStateMachine] notifyStateChange -> info: ".concat(JSON.stringify({state:e,reason:t}))),this._endReason=t||null,this._sessionState!==e&&(this._sessionState=e,null===(n=this._watchers)||void 0===n||n.onStateChange({state:e,reason:t})),e===S.END&&(E.emit("onStateMachineClose",this._callId),this._callMsgHandler.unregisterStateMachineEvent(this._callId))}}),Object.defineProperty(e.prototype,"_notifyUserStateChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n;this._logger.warn("_","[RCCallStateMachine] notifyUserStateChange -> info: ".concat(JSON.stringify({user:e,reason:t}))),null===(n=this._watchers)||void 0===n||n.onUserStateChange({user:e,reason:t})}}),Object.defineProperty(e.prototype,"_otherClientHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,n=e.content,r=n.user,i=n.reason,o=e.messageType;for(var a in this._userInfo[t]={userId:t,state:M.NONE,isCaller:!1,isRemote:!1},this._userTimers)this._clearTimerById(a);var s=m.ACCEPT_BY_OTHER_CLIENT;o===T.VCHangup&&(s=i===m.BUSY_LINE?m.OTHER_CLIENT_IN_CALL:i===m.NO_RESPONSE?m.NO_RESPONSE:m.HANGUP_BY_OTHER_CLIENT),Object.assign(this._userInfo[t],r),this._notifyUserStateChange(this._userInfo[t],s),this._notifyStateChange(S.END,s)}}),Object.defineProperty(e.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===M.KEEPING&&this._userInfo[e].deviceId!==t))}}),Object.defineProperty(e.prototype,"_onRinging",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,n=e.content,r=n.user,i=n.deviceId,o=this._isCrossAppkey?t.split("_")[1]:t;this._isRemoteInvalidMsg(o,i)?this._logger.debug("_","[RCCallStateMachine] onRinging -> not the remote device that is currently talking"):this._context.getCurrentId()!==o&&this._watchers.onRinging(h({userId:o},r))}}),Object.defineProperty(e.prototype,"_onAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n=this,r=e.senderUserId,i=e.content,o=i.user,a=i.deviceId;e.sentTime;var s=this._isCrossAppkey?r.split("_")[1]:r,l=this._context.getCurrentId();this._isRemoteInvalidMsg(s,a)?this._logger.debug("_","[RCCallStateMachine] _onAccept -> not the remote device that is currently talking"):l!==s?(this._userTimers[s]&&this._clearTimerById(s),(this._conversationType===t.PRIVATE?[l,s]:[s]).forEach((function(e){var t=e===l;n._userInfo[e]={userId:e,state:M.KEEPING,isCaller:t,isRemote:t,deviceId:t?O(n._runtime):a},t||(n._beginTimestamp=Date.now(),Object.assign(n._userInfo[s],o)),n._notifyUserStateChange(n._userInfo[e])})),this.getCallerId()===l&&this._notifyStateChange(S.KEEPING),this._watchers.onAccept({userId:s})):this._otherClientHandle(e)}}),Object.defineProperty(e.prototype,"_onMediaModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,n=e.content,r=n.mediaType,i=n.user,o=n.deviceId;this._isRemoteInvalidMsg(t,o)?this._logger.debug("_","[RCCallStateMachine] _onMediaModify -> not the remote device that is currently talking"):this._context.getCurrentId()!==t&&(this._mediaType=r,this._watchers.onMediaModify({sender:h({userId:t},i),mediaType:r}))}}),Object.defineProperty(e.prototype,"_onHungup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,n=e.content,r=this._isCrossAppkey?t.split("_")[1]:t,i=n,o=i.reason,a=i.user,s=i.deviceId,l=this._context.getCurrentId();if(this._isRemoteInvalidMsg(r,s))this._logger.debug("_","[RCCallStateMachine] _onHungup -> not the remote device that is currently talking");else if(l!==r)if(this._sessionState!==S.END){this._userInfo[r]&&(this._userInfo[r].state=M.NONE,this._endTimestamp=Date.now(),Object.assign(this._userInfo[r],a),this._notifyUserStateChange(this._userInfo[r],w[o]),delete this._userInfo[r]),w[o]===m.REMOTE_CANCEL?this.getRemoteUserIds().length<1&&this._clearTimerById(l):this.getInviterId()===l?this._clearTimerById(r):this.getRemoteUserIds().length<1&&this._clearTimerById(l);var c=Object.keys(this._userInfo).length<2,u=this._inviterId===r,d=Object.values(this._userInfo).every((function(e){return e.state!==M.KEEPING}));(c||u&&d)&&this._notifyStateChange(S.END,w[o]),this._watchers.onHungup(h({userId:r},a),w[o])}else this._logger.info("_","[RCCallStateMachine] Invalid hang up message, current room status has ended -> sessionState: ".concat(this._sessionState));else this._otherClientHandle(e)}}),Object.defineProperty(e.prototype,"registerEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._watchers=e}}),Object.defineProperty(e.prototype,"__onInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,n,r=this,i=e.senderUserId,o=e.content,a=e.sentTime,s=o,l=s.inviteUserIds,c=s.user,u=s.deviceId;s.roomType===P.RCCallRoomTypeAcrossCall?(t=p(i.split("_"),2),n=t[1],this._watchers.crossAppkey(!0),this._isCrossAppkey=!0):n=i;var d=this._context.getCurrentId();if(this._isRemoteInvalidMsg(n,u))this._logger.debug("_","[RCCallStateMachine] __onInvite -> not the remote device that is currently talking");else if(d!==n){this._callerId=this._inviterId=n;var _=b([i],p(l),!1);this._callMsgHandler.sendRinging({conversationType:this._conversationType,targetId:this._targetId,channelId:this._channelId,callId:this._callId,userIds:_.filter((function(e){return r._isCrossAppkey?e.split("_")[1]!==d:e!==d}))});var h=this._isCrossAppkey?[l[0].split("_")[1]]:l;b([n],p(h),!1).forEach((function(e){r._userInfo[e]={userId:e,state:M.WAITING,isCaller:e===n,isRemote:e!==d},e===n&&Object.assign(r._userInfo[e],c,{deviceId:u}),r._notifyUserStateChange(r._userInfo[e]),e!==n&&(r._userTimers[e]=new L((function(){var t=e===d?m.NO_RESPONSE:m.REMOTE_NO_RESPONSE;e===d?r._hungupHandle(t,!1):(r._userInfo[e]&&(r._userInfo[e].state=M.NONE),r._notifyUserStateChange(r._userInfo[e]),r._watchers.onHungup(r._userInfo[e],t),delete r._userInfo[e]),r._clearTimerById(e)}),r._getTimeout(a)))})),this._notifyStateChange(S.WAITING)}}}),Object.defineProperty(e.prototype,"__onMemberModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,n=e.senderUserId,r=e.content,i=e.sentTime,o=r,a=o.user,s=o.existedUserPofiles,l=o.caller,c=o.deviceId,u=o.inviteUserIds,d=o.mediaType,_=this._context.getCurrentId();if(this._isRemoteInvalidMsg(n,c))this._logger.debug("_","[RCCallStateMachine] __onMemberModify -> not the remote device that is currently talking");else if(_!==n){if(this._callerId=l,this._inviterId=n,u.forEach((function(e){s.push({userId:e,mediaType:d,callStatus:C.INCOMING})})),u.includes(_)){var f=[];s.forEach((function(e){e.userId!==_&&f.push(e.userId)})),this._callMsgHandler.sendRinging({conversationType:this._conversationType,targetId:this._targetId,channelId:this._channelId,callId:this._callId,userIds:f}),this._notifyStateChange(S.WAITING)}else this._watchers.onMemberModify({sender:h({userId:n},a),invitedUsers:u.map((function(e){return{userId:e}}))});s.forEach((function(e){var r=e.userId,o=e.callStatus;if(o!==C.IDLE&&(t._userInfo[r]={userId:r,state:o!==C.CONNECTED?M.WAITING:M.KEEPING,isCaller:n===r,isRemote:_!==r},r===n&&Object.assign(t._userInfo[r],a,{deviceId:c}),t._notifyUserStateChange(t._userInfo[r]),o!==C.CONNECTED&&!t._userTimers[r])){if(!u.includes(r))return;t._userTimers[r]=new L((function(){t._userInfo[r]&&(t._userInfo[r].state=M.NONE);var e=r===_?m.NO_RESPONSE:m.REMOTE_NO_RESPONSE;t._notifyUserStateChange(t._userInfo[r],e);try{t._watchers.onHungup(t._userInfo[r],e)}catch(e){t._logger.error("_","[RCCallStateMachine] call onhungup error -> ".concat(null==e?void 0:e.stack))}delete t._userInfo[r],(Object.keys(t._userInfo).length<2||r===_)&&t._notifyStateChange(S.END,e),t._clearTimerById(r)}),t._getTimeout(i))}}))}}}),Object.defineProperty(e.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=M.NONE),this._notifyUserStateChange(this._userInfo[e]),this._clearTimerById(e);this._notifyStateChange(S.END,m.BUSY_LINE),this._callMsgHandler.sendHungup({channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,reason:m.BUSY_LINE,userIds:this.getRemoteUserIds()})}}),Object.defineProperty(e.prototype,"__call",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){return void 0===t&&(t=""),void 0===r&&(r=!1),f(this,void 0,void 0,(function(){var i,o,a,s,l,c,u=this;return g(this,(function(d){switch(d.label){case 0:return this._logger.debug("_","[RCCallStateMachine] invite -> userIds: ".concat(JSON.stringify(e))),i=this._callerId=this._inviterId=this._context.getCurrentId(),[4,this._callMsgHandler.sendInvite({roomType:r?P.RCCallRoomTypeAcrossCall:P.RCCallRoomTypeNormalCall,channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,extra:t,pushConfig:n,mediaType:this._mediaType,inviteUserIds:e.filter((function(e){return e!==i}))})];case 1:return o=d.sent(),a=o.code,s=o.message,this._isCrossAppkey=r,a===R.SUCCESS?(l=s.sentTime,b([i],r?[e[0].split("_")[1]]:p(e),!1).forEach((function(e){var t=e===i;u._userInfo[e]={userId:e,state:M.WAITING,isCaller:t,isRemote:!t},u._notifyUserStateChange(u._userInfo[e]),t||(u._userTimers[e]=new L((function(){u._userInfo[e]&&(u._userInfo[e].state=M.NONE),u._notifyUserStateChange(u._userInfo[e],m.REMOTE_NO_RESPONSE),u._watchers.onHungup(u._userInfo[e],m.REMOTE_NO_RESPONSE),delete u._userInfo[e],Object.keys(u._userInfo).length<2&&u._notifyStateChange(S.END,m.REMOTE_NO_RESPONSE),0===u.getRemoteUserIds().length&&u._userInfo[i].state!==M.KEEPING&&u._hungupHandle(m.REMOTE_NO_RESPONSE)}),u._getTimeout(l)))})),this._notifyStateChange(S.WAITING)):(c=a===R.REJECTED_BY_BLACKLIST?m.ADDED_TO_BLACKLIST:m.NETWORK_ERROR,this._notifyStateChange(S.END,c)),[2,{code:a}]}}))}))}}),Object.defineProperty(e.prototype,"accept",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){var e,t,n,r,i;return g(this,(function(o){switch(o.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=o.sent(),n=t.code,r=t.message,this._clearTimerById(e),n===R.SUCCESS?(r.sentTime,this._userInfo[e]&&(this._userInfo[e].state=M.KEEPING),this._beginTimestamp=Date.now(),this._notifyUserStateChange(this._userInfo[e]),this._notifyStateChange(S.KEEPING)):(this._userInfo[e]&&(this._userInfo[e].state=M.NONE),this._notifyUserStateChange(this._userInfo[e]),i=n===R.REJECTED_BY_BLACKLIST?m.ADDED_TO_BLACKLIST:m.NETWORK_ERROR,this._notifyStateChange(S.END,i)),[2,{code:n}]}}))}))}}),Object.defineProperty(e.prototype,"invite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,n){return void 0===n&&(n={}),f(this,void 0,void 0,(function(){var r,i,o,a,s,l,c,u,d,_,h,f=this;return g(this,(function(g){switch(g.label){case 0:return this._conversationType!==t.GROUP?[2,{code:R.CONVERSATION_NOT_GROUP_ERROR}]:(this._logger.info("_","[RCCallStateMachine] invite -> userIds: ".concat(JSON.stringify(e))),r=this._context.getCurrentId(),i=Object.keys(this._userInfo),0===(o=e.filter((function(e){return e!==r&&!i.includes(e)}))).length?(this._logger.warn("_","[RCCallStateMachine] invite -> all userId is in calling now!"),[2,{code:R.PARAM_ERROR}]):(a=i.map((function(e){var t=C.CONNECTED;return f._userInfo[e].state===M.WAITING&&(t=C.RINGING),{userId:e,mediaType:f._mediaType,callStatus:t,mediaId:e}})),s=n.extra,l=void 0===s?"":s,c=n.pushConfig,[4,this._callMsgHandler.sendMemeberModify({channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,extra:l,pushConfig:c,mediaType:this._mediaType,inviteUserIds:o,callerId:this.getCallerId(),existedUserPofiles:a,directionalUserIdList:b(b([],p(i),!1),p(o),!1).filter((function(e){return e!==r}))})]));case 1:return u=g.sent(),d=u.code,_=u.message,d===R.SUCCESS?(h=_.sentTime,o.forEach((function(e){f._userInfo[e]={userId:e,state:M.WAITING,isCaller:!1,isRemote:!0},f._notifyUserStateChange(f._userInfo[e]),f._userTimers[e]=new L((function(){f._userInfo[e]&&(f._userInfo[e].state=M.NONE),f._notifyUserStateChange(f._userInfo[e],m.REMOTE_NO_RESPONSE),f._watchers.onHungup(f._userInfo[e],m.REMOTE_NO_RESPONSE),delete f._userInfo[e],Object.keys(f._userInfo).length<2&&f._notifyStateChange(S.END,m.REMOTE_NO_RESPONSE)}),f._getTimeout(h))}))):o.forEach((function(e){f._userInfo[e]={userId:e,state:M.NONE,isCaller:!1,isRemote:!0};var t=d===R.REJECTED_BY_BLACKLIST?m.ADDED_TO_BLACKLIST:m.NETWORK_ERROR;f._notifyUserStateChange(f._userInfo[e],t)})),[2,{code:d}]}}))}))}}),Object.defineProperty(e.prototype,"_hungupHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===t&&(t=!0),f(this,void 0,void 0,(function(){var n,r,i,o,a;return g(this,(function(s){switch(s.label){case 0:return n=this._context.getCurrentId(),r=R.SUCCESS,t?(i={channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,reason:e,userIds:this.getRemoteUserIds(),pushConfig:this._hungupPushConfig},e!==m.OTHER_CLIENT_JOINED_CALL?[3,1]:(this._callMsgHandler.sendHungup(i),[3,3])):[3,3];case 1:return[4,this._callMsgHandler.sendHungup(i)];case 2:o=s.sent().code,r=o,s.label=3;case 3:for(a in this._endTimestamp=Date.now(),this._userInfo)this._userInfo[a].state=M.NONE,a===n?this._notifyUserStateChange(this._userInfo[a],e):this._notifyUserStateChange(this._userInfo[a]),delete this._userInfo[a];return Object.keys(this._userInfo).length<2&&this._notifyStateChange(S.END,e),[2,{code:r}]}}))}))}}),Object.defineProperty(e.prototype,"hungup",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){var e,t,n;return g(this,(function(r){for(n in this._logger.debug("_","[RCCallStateMachine] hungup"),e=this._context.getCurrentId(),t=m.HANGUP,Object.keys(this._userTimers).length>0&&(this._userInfo[e].isCaller?t=m.CANCEL:this._userInfo[e].state===M.WAITING&&(t=m.REJECT)),this._userTimers)this._clearTimerById(n);return[2,this._hungupHandle(t)]}))}))}}),Object.defineProperty(e.prototype,"changeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return f(this,void 0,void 0,(function(){var t;return g(this,(function(n){switch(n.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=n.sent().code)===R.SUCCESS&&(this._mediaType=e),[2,{code:t}]}}))}))}}),Object.defineProperty(e.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 n=t._userInfo[e];n&&n.state!==M.KEEPING&&(n.state=M.KEEPING,t._notifyUserStateChange(n)),t._sessionState!==S.KEEPING&&t._notifyStateChange(S.KEEPING),t._clearTimerById(e)}))}),300)}}),Object.defineProperty(e.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 n=t._userInfo[e];n&&n.state!==M.NONE&&(n.state=M.NONE,t._notifyUserStateChange(n,m.REMOTE_HANGUP),t._watchers.onHungup(n,m.REMOTE_HANGUP),delete t._userInfo[e]),new L((function(){var e=t.getRemoteUsers();1===e.length&&1===e[0].state&&t._hungupHandle(m.REMOTE_NETWORK_ERROR)}),6e4),Object.keys(t._userInfo).length<2&&t._sessionState!==S.END&&(t._endTimestamp=Date.now(),t._notifyStateChange(S.END,m.REMOTE_HANGUP))}))}),300)}}),Object.defineProperty(e.prototype,"close",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._hungupHandle(e)}}),Object.defineProperty(e.prototype,"setHungupPushConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._hungupPushConfig=e}}),Object.defineProperty(e.prototype,"getCallId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callId}}),Object.defineProperty(e.prototype,"getChannelId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._channelId}}),Object.defineProperty(e.prototype,"getTargetId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._targetId}}),Object.defineProperty(e.prototype,"getConversationType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._conversationType}}),Object.defineProperty(e.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(e.prototype,"getRemoteUsers",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=[],t=this._context.getCurrentId();for(var n in this._userInfo){this._userInfo[n].userId!==t&&e.push(this._userInfo[n])}return e}}),Object.defineProperty(e.prototype,"getState",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null===this._sessionState?S.END:this._sessionState}}),Object.defineProperty(e.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(e.prototype,"getCallerId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callerId}}),Object.defineProperty(e.prototype,"getInviterId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._inviterId}}),Object.defineProperty(e.prototype,"getMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._mediaType}}),Object.defineProperty(e.prototype,"getSummary",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._beginTimestamp,t=this._endTimestamp,n=0;t>e&&0!==e&&(n=t-e);var r={conversationType:this._conversationType,channelId:this._channelId,targetId:this._targetId,mediaType:this._mediaType,beginTimestamp:e,endTimestamp:t,duration:n,endReason:this._endReason};return this._logger.debug("_","[RCCallStateMachine] getSummary -> summary: ".concat(JSON.stringify(r))),r}}),e}();!function(e){e[e.AUDIO=1]="AUDIO",e[e.AUDIO_VIDEO=2]="AUDIO_VIDEO"}(A||(A={})),function(e){e[e.ADD=1]="ADD",e[e.REMOVE=2]="REMOVE"}(N||(N={})),function(e){e.WEB="Web",e.IOS="iOS",e.ANDROID="Android"}(U||(U={}));var k,D,H=function(){function e(e,t,n){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_onRecord",{enumerable:!0,configurable:!0,writable:!0,value:n}),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,n=e.conversationType,r=e.targetId,i=e.senderUserId,o=e.content,a=o.callId,s=o.mediaType;this._channelId=t,this._conversationType=n,this._targetId=r,this._callId=a,this._mediaType=s;this._inviterId=i,this._endReason=m.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=m.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,n=e.sentTime,r=e.senderUserId,i=t.reason,o=r===this._context.getCurrentId();this._endReason=o?i:w[i],this._endTimestamp=n,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;[m.HANGUP,m.REMOTE_HANGUP,m.OTHER_CLIENT_JOINED_CALL,m.REMOTE_OTHER_CLIENT_JOINED_CALL,m.KICKED_BY_SERVER,m.REMOTE_KICKED_BY_SERVER,m.ACCEPT_SYSTEM_CALL,m.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(),n=t.messageType;switch(t.content.callId,n){case T.VCInvite:this._doInvite(t);break;case T.VCRinging:this._doRinging(t);break;case T.VCAccept:this._doAccept(t);break;case T.VCModifyMem:this._doMemberModify(t);break;case T.VCModifyMedia:this._doMediaModify(t);break;case T.VCHangup:this._doHungup(t);break;default:this._logger.debug("_","[OfflineRecorder] onRecvOfflineMsgs -> unexpected message: ".concat(JSON.stringify(t)))}}while(this._messages.length>0)}}),e}(),V=["RC:VCAccept","RC:VCRinging","RC:VCSummary","RC:VCHangup","RC:VCInvite","RC:VCModifyMedia","RC:VCModifyMem"],G=((k={})[n.REJECTED_BY_BLACKLIST]=R.REJECTED_BY_BLACKLIST,k[n.NOT_IN_GROUP]=R.NOT_IN_GROUP,k),x=function(e){function r(t,n,r,i,o){void 0===i&&(i=6e4);var a=e.call(this)||this;return Object.defineProperty(a,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(a,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"_offlineMsgItv",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(a,"_getStateMachine",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(a,"_watchers",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(a,"_userInfo",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(a,"_msgBufferList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(a,"_hadHandleMsgTimer",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(a,"_offlineRecorder",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"_deviceId",{enumerable:!0,configurable:!0,writable:!0,value:""}),a._deviceId=O(n),a._context.onmessage=a._onMessage.bind(a),a._offlineRecorder=new H(a._context,a._logger,(function(e){a._logger.info("_","[CallMessageHandler] offlineRecorder -> ".concat(JSON.stringify(e))),a._watchers.onOfflineRecord&&a._watchers.onOfflineRecord(e)})),a}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}_(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(r,e),Object.defineProperty(r.prototype,"_onMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(V.includes(e.messageType)){this._logger.debug("_","[CallMessageHandler] _onMessage -> call message: ".concat(JSON.stringify(e)));try{var t=Date.now(),n=e.sentTime,r=0;this._msgBufferList.forEach((function(e,t){var i=e.msg.sentTime;n>=i&&(r=t+1)})),this._msgBufferList.splice(r,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(r.prototype,"_onRecvOnlineCallMsg",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=t.content.callId;switch(this._logger.info("_","recv -> senderId: ".concat(t.senderUserId,", type: ").concat(t.messageType,", callId: ").concat(n)),t.messageType){case T.VCInvite:this._watchers.onInvite&&this._watchers.onInvite(t);break;case T.VCRinging:e.prototype.emit.call(this,"".concat(n,"onRinging"),t);break;case T.VCAccept:e.prototype.emit.call(this,"".concat(n,"onAccept"),t);break;case T.VCModifyMem:this._watchers.onInvite&&this._watchers.onInvite(t);break;case T.VCModifyMedia:e.prototype.emit.call(this,"".concat(n,"onMediaModify"),t);break;case T.VCHangup:e.prototype.emit.call(this,"".concat(n,"onHungup"),t);break;default:this._logger.warn("_","recv -> unexpected message: ".concat(t.messageType))}}}),Object.defineProperty(r.prototype,"_handleBufferMsgs",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;0===this._msgBufferList.length||this._hadHandleMsgTimer?this._logger.warn("_","_handleBufferMsgs return"):(this._hadHandleMsgTimer=!0,setTimeout((function(){var n=Date.now(),r=e._msgBufferList.filter((function(e){return n-e.markTime>=200}));if(e._logger.debug("_","[CallMessageHandler] handleBufferMsgs -> lists over 200ms : ".concat(JSON.stringify(r.map((function(e){var t=e.msg;return{messageUId:t.messageUId,isOffLineMessage:t.isOffLineMessage,callId:t.content.callId}}))))),0===r.length)return e._hadHandleMsgTimer=!1,void e._handleBufferMsgs();if(r[0].msg.isOffLineMessage){var i=e._msgBufferList.filter((function(e){return e.msg.isOffLineMessage})),o=function(){var n=i[0].msg,r=n.conversationType,o=n.messageType,a=n.sentTime,s=n.senderUserId,l=n.content,c=l.callId,u=l.inviteUserIds,d=[T.VCInvite,T.VCModifyMem].includes(o),_=e._context.getServerTime()-a,h=_<e._offlineMsgItv;if(h||e._logger.warn("_","offline msg delayTime: ".concat(_,"ms")),d){for(var f=[],g=0;g<i.length;g++){var C=i[g].msg;if(c!==C.content.callId)break;f.push(C)}if(e._logger.warn("_","taskMsgList length: ".concat(f.length)),f.length>0){var R=e._msgBufferList.findIndex((function(e){return e.msg.messageUId===f[f.length-1].messageUId}));e._msgBufferList=e._msgBufferList.slice(R+1);var I=i.findIndex((function(e){return e.msg.messageUId===f[f.length-1].messageUId}));i=i.slice(I+1)}var m=function(){if(r!==t.PRIVATE)return!1;var e=1===f.length,n=f.every((function(e){return[T.VCInvite,T.VCModifyMedia,T.VCRinging].includes(e.messageType)}));return e||n}(),y=function(){if(r!==t.GROUP)return!1;for(var n=!1,i=!0,o=b([s],p(u),!1),a=!1,l=function(t){var n=f[t],r=n.senderUserId,l=n.messageType;if(l===T.VCHangup&&r===e._context.getCurrentId())return"break";l===T.VCHangup&&(a=s===r,o=o.filter((function(e){return r!==e}))),l===T.VCAccept&&(i=!1)},c=0;c<f.length;c++){if("break"===l(c))break}return i&&a||!(o.length>1)||(n=!0),n}();h&&(m||y)&&f.forEach(e._onRecvOnlineCallMsg,e),e._offlineRecorder.onRecvOfflineMsgs(f)}else h&&e._getStateMachine(c)?e._onRecvOnlineCallMsg(i[0].msg):e._logger.debug("_","[CallMessageHandler] unexcepted offline msg -> ".concat(JSON.stringify(i[0].msg))),i.shift(),e._msgBufferList.shift()};do{o()}while(i.length>0)}else{r.forEach((function(t){var n=t.msg;e._onRecvOnlineCallMsg(n)}));var a=r.length;e._msgBufferList.splice(0,a),e._logger.debug("_","timer online msg handle -> delCount: ".concat(a," msgBufferList: ").concat(e._msgBufferList.length))}e._hadHandleMsgTimer=!1,e._handleBufferMsgs()}),20))}}),Object.defineProperty(r.prototype,"registerEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){Object.assign(this._watchers,e)}}),Object.defineProperty(r.prototype,"registerStateMachineEvent",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,r){var i=t+n;e.prototype.on.call(this,i,r)}}),Object.defineProperty(r.prototype,"unregisterStateMachineEvent",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this;["onRinging","onAccept","onHungup","onMediaModify"].forEach((function(r){var i=t+r;e.prototype.removeAll.call(n,i)}))}}),Object.defineProperty(r.prototype,"registerUserInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._userInfo=e}}),Object.defineProperty(r.prototype,"_sendCallMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return f(this,void 0,void 0,(function(){var t,r,i,o,a,s,l,c,u,d,_,h;return g(this,(function(f){switch(f.label){case 0:return this._logger.debug("_","CallMessageHandler] sendCallMesage -> message: ".concat(JSON.stringify(e))),t=e.channelId,r=e.conversationType,i=e.targetId,o=e.content,a=e.messageType,s=e.directionalUserIdList,l=e.pushConfig,c={channelId:t,messageType:a,content:o,directionalUserIdList:s},[T.VCInvite,T.VCModifyMem,T.VCHangup].includes(a)&&((u=l||{pushTitle:"",pushContent:"",pushData:""}).androidConfig=Object.assign((null==l?void 0:l.androidConfig)||{},{categoryHW:"VOIP",categoryVivo:"IM"}),u.iOSConfig=Object.assign(u.iOSConfig||{},{apnsCollapseId:o.callId}),u.disablePushTitle=!1,u.forceShowDetailContent=!1,c.pushConfig=u),[4,this._context.sendMessage(r,i,c)];case 1:return d=f.sent(),_=d.code,h=d.data,_!==n.SUCCESS?(this._logger.error("_","CallMessageHandler] sendCallMesage error -> code: ".concat(_)),[2,{code:G[_]||R.SEND_MSG_ERROR}]):[2,{code:R.SUCCESS,message:h}]}}))}))}}),Object.defineProperty(r.prototype,"sendInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return f(this,void 0,void 0,(function(){var n,r,i,o,a,s,l,c,u,d;return g(this,(function(_){return n=e.roomType,r=e.channelId,i=e.conversationType,o=e.targetId,a=e.callId,s=e.mediaType,l=e.inviteUserIds,c=e.extra,u=e.pushConfig,this._logger.warn("_","CallMessageHandler] sendCallMesage sendInvite",JSON.stringify(e)),this._watchers.sendAccept&&this._watchers.sendAccept({callId:a}),d={platform:U.WEB,deviceId:this._deviceId,callId:a,roomType:n,extra:c,engineType:4,channelInfo:{Id:a,Key:""},mediaType:s,inviteUserIds:l,observerUserIds:[],user:this._userInfo},u&&(u.pushData=JSON.stringify({mediaType:s,userIdList:l,callId:a})),[2,this._sendCallMessage({channelId:r,conversationType:i,targetId:o,content:d,messageType:T.VCInvite,directionalUserIdList:i===t.GROUP?l:void 0,pushConfig:u})]}))}))}}),Object.defineProperty(r.prototype,"sendMemeberModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return f(this,void 0,void 0,(function(){var t,n,r,i,o,a,s,l,c,u,d,_;return g(this,(function(h){return t=e.channelId,n=e.conversationType,r=e.targetId,i=e.callId,o=e.mediaType,a=e.inviteUserIds,s=e.callerId,l=e.existedUserPofiles,c=e.directionalUserIdList,u=e.extra,d=e.pushConfig,_={platform:U.WEB,deviceId:this._deviceId,callId:i,extra:u,engineType:4,channelInfo:{Id:i,Key:""},mediaType:o,inviteUserIds:a,observerUserIds:[],user:this._userInfo,caller:s,modifyMemType:N.ADD,existedUserPofiles:l},d&&(d.pushData=JSON.stringify({mediaType:o,userIdList:a,callId:i})),[2,this._sendCallMessage({channelId:t,conversationType:n,targetId:r,content:_,messageType:T.VCModifyMem,directionalUserIdList:c,pushConfig:d})]}))}))}}),Object.defineProperty(r.prototype,"sendRinging",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n=e.channelId,r=e.conversationType,i=e.targetId,o=e.callId,a=e.userIds,s={platform:U.WEB,deviceId:this._deviceId,callId:o,user:this._userInfo};return this._sendCallMessage({channelId:n,conversationType:r,targetId:i,content:s,messageType:T.VCRinging,directionalUserIdList:r===t.GROUP?a:void 0})}}),Object.defineProperty(r.prototype,"sendAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n=e.channelId,r=e.conversationType,i=e.targetId,o=e.callId,a=e.mediaType,s=e.userIds,l={platform:U.WEB,deviceId:this._deviceId,callId:o,mediaType:a,user:this._userInfo};return this._sendCallMessage({channelId:n,conversationType:r,targetId:i,content:l,messageType:T.VCAccept,directionalUserIdList:r===t.GROUP?s:void 0})}}),Object.defineProperty(r.prototype,"sendHungup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n=e.channelId,r=e.conversationType,i=e.targetId,o=e.callId,a=e.reason,s=e.userIds,l=e.pushConfig,c={platform:U.WEB,deviceId:this._deviceId,callId:o,reason:a,user:this._userInfo};return l&&(l.pushData=JSON.stringify({callId:o,reason:a})),this._sendCallMessage({channelId:n,conversationType:r,targetId:i,content:c,messageType:T.VCHangup,pushConfig:l,directionalUserIdList:r===t.GROUP?s:void 0})}}),Object.defineProperty(r.prototype,"sendMediaModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n=e.channelId,r=e.conversationType,i=e.targetId,o=e.callId,a=e.mediaType,s=e.userIds,l={platform:U.WEB,deviceId:this._deviceId,callId:o,mediaType:a,user:this._userInfo};return this._sendCallMessage({channelId:n,conversationType:r,targetId:i,content:l,messageType:T.VCModifyMedia,directionalUserIdList:r===t.GROUP?s:void 0})}}),r}(e);!function(e){e.ZH="zh",e.EN="en"}(D||(D={}));var B,K={PushTitle:{AUDIO:"You have a voice call",VIDEO:"You have a video call"}},J={PushTitle:{AUDIO:"您有一条音频通话",VIDEO:"您有一条视频通话"}},W=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===D.EN?K:J}}),Object.defineProperty(e,"_lang",{enumerable:!0,configurable:!0,writable:!0,value:D.ZH}),e}(),Y=function(){function e(e,t,n,r,i){var o=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:n}),Object.defineProperty(this,"_watchers",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:i}),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.10"," CommitId: ").concat("b49ac7f3aef4e11e35cd5c4bd12be262e2779937")),O(t),this._callMsgHandler=new x(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}),E.on("onStateMachineClose",(function(e){delete o._stateMachine[e]})),W.set(i.lang)}return Object.defineProperty(e.prototype,"_onInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.channelId,n=e.conversationType,r=e.targetId,i=e.content,o=e.messageType,a=e.senderUserId;e.pushConfig;var s,l=i,c=l.mediaType,u=l.callId,d=l.extra;s=l.roomType!==P.RCCallRoomTypeAcrossCall?a:p(a.split("_"),2)[1];var _=this._context.getCurrentId();if(this._context.getCurrentId()!==s){if(o===T.VCModifyMem)if(i.existedUserPofiles.some((function(e){return e.userId===_}))&&!this._stateMachine[u])return;if(this._stateMachine[u])o===T.VCModifyMem&&this._stateMachine[u].__onMemberModify(e);else this._stateMachine[u]=new j(this._context,this._runtime,this._logger,this._callMsgHandler,t,n,r,c,u),this._logger.info("_","[RCCallEngine] RCCallStateMachine successfully created -> callId: ".concat(u)),o===T.VCInvite?this._stateMachine[u].__onInvite(e):o===T.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(e.prototype,"_handleSendAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this._options.isAllowAcceptNewCall){var t=e.callId;for(var n in this._stateMachine)t!==n&&(this._stateMachine[n].hungup(),delete this._stateMachine[n])}}}),Object.defineProperty(e.prototype,"_getStateMachine",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._stateMachine[e]}}),Object.defineProperty(e.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(e.prototype,"call",{enumerable:!1,configurable:!0,writable:!0,value:function(e,n,r,i,o,a){return void 0===i&&(i=""),void 0===a&&(a=!1),f(this,void 0,void 0,(function(){var s,l;return g(this,(function(c){switch(c.label){case 0:return this._logger.debug("_","[RCCallEngine] call -> args: ".concat(JSON.stringify({channelId:e,targetId:n,mediaType:r,extra:i,pushConfig:o}))),s=v(),Object.keys(this._stateMachine).length>0?[2,{code:R.STATE_MACHINE_EXIT}]:(this._stateMachine[s]=new j(this._context,this._runtime,this._logger,this._callMsgHandler,e,t.PRIVATE,n,r,s),[4,this._stateMachine[s].__call([n],i,o,a)]);case 1:return(l=c.sent().code)===R.SUCCESS?[2,{code:R.SUCCESS,stateMachine:this._stateMachine[s]}]:[2,{code:l}]}}))}))}}),Object.defineProperty(e.prototype,"callInGroup",{enumerable:!1,configurable:!0,writable:!0,value:function(e,n,r,i,o,a){return void 0===o&&(o=""),f(this,void 0,void 0,(function(){var s,l;return g(this,(function(c){switch(c.label){case 0:return this._logger.debug("_","[RCCallEngine] callInGroup -> args: ".concat(JSON.stringify({channelId:e,targetId:n,mediaType:r}))),s=v(),Object.keys(this._stateMachine).length>0?[2,{code:R.STATE_MACHINE_EXIT}]:(this._stateMachine[s]=new j(this._context,this._runtime,this._logger,this._callMsgHandler,e,t.GROUP,n,r,s),[4,this._stateMachine[s].__call(i,o,a)]);case 1:return(l=c.sent().code)===R.SUCCESS?[2,{code:R.SUCCESS,stateMachine:this._stateMachine[s]}]:[2,{code:l}]}}))}))}}),Object.defineProperty(e.prototype,"destroy",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._logger.debug("_","[RCCallEngine] destroy"),this._stateMachine={}}}),e}();!function(e){e[e.CALLER=1]="CALLER",e[e.CALLEE=2]="CALLEE"}(B||(B={}));var F=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 n=this,r=function(i){n.off(e,r),t.call(n,i)};r.fun=t,this.on(e,r)}}),Object.defineProperty(e.prototype,"off",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this.list[e];if(!n)return!1;if(t){for(var r=void 0,i=0,o=n.length;i<o;i++)if((r=n[i])===t||r.fun===t){n.splice(i,1);break}}else n&&(n.length=0)}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this,r=b([],p(this.list[e]),!1);if(!r||0===r.length)return!1;r.forEach((function(e){e.call(n,t)}))}}),e}());var z=function(e){if(!e)return{ok:!1,msg:"Initialization missing parameter -> options"};if("object"!=typeof e)return{ok:!1,msg:"Initialization options must be an object"};var t,n=Object.keys(e),r=[];return["rtcClient","onSession","onSessionClose"].forEach((function(e){n.includes(e)||r.push(e)})),r.length?{ok:!1,msg:'Initialization missing parameter -> "'.concat(r.join(","),'"')}:"object"!=typeof e.rtcClient?{ok:!1,msg:"Initialization 'rtcClient' parameter must be of type 'object'"}:"function"!=typeof e.onSession?{ok:!1,msg:"Initialization 'onSession' parameter must be of type 'function'"}:"function"!=typeof e.onSessionClose?{ok:!1,msg:"Initialization 'onSessionClose' parameter must be of type 'function'"}:void 0!==e.isAllowSubscribeRetry&&"boolean"!=typeof e.isAllowSubscribeRetry?{ok:!1,msg:"Initialization 'isAllowSubscribeRetry' parameter must be of type 'boolean'"}:void 0!==e.isAllowPublishRetry&&"boolean"!=typeof e.isAllowPublishRetry?{ok:!1,msg:"Initialization 'isAllowPublishRetry' parameter must be of type 'boolean'"}:void 0!==e.isOffCameraWhenVideoDisable&&"boolean"!=typeof e.isOffCameraWhenVideoDisable?{ok:!1,msg:"Initialization 'isOffCameraWhenVideoDisable' parameter must be of type 'boolean'"}:void 0===e.joinType||(t=e.joinType,Object.values(a).includes(t))?void 0!==e.isAllowDemotionGetStream&&"boolean"!=typeof e.isAllowDemotionGetStream?{ok:!1,msg:"Initialization 'isAllowDemotionGetStream' parameter must be of type 'boolean'"}:void 0===e.lang||function(e){return Object.values(D).includes(e)}(e.lang)?void 0===e.logOutputLevel||function(e){return[s.DEBUG,s.INFO,s.WARN,s.ERROR].includes(e)}(e.logOutputLevel)?{ok:!0}:{ok:!1,msg:"Initialization 'logOutputLevel' parameter must be of type correct type"}:{ok:!1,msg:"Initialization 'lang' parameter must be of type correct type"}:{ok:!1,msg:"Initialization 'joinType' parameter must be of type correct type"}},q=function(e){if(!e)return{ok:!1,msg:"missing parameter -> listener"};if("object"!=typeof e)return{ok:!1,msg:"listener must be an object"};var t=Object.keys(e),n=[];return["onRinging","onAccept","onHungup","onTrackReady"].forEach((function(e){t.includes(e)||n.push(e)})),n.length?{ok:!1,msg:'missing parameter -> "'.concat(n.join(","),'"')}:"function"!=typeof e.onRinging?{ok:!1,msg:"'onRinging' parameter must be of type 'function'"}:"function"!=typeof e.onAccept?{ok:!1,msg:"'onAccept' parameter must be of type 'function'"}:"function"!=typeof e.onHungup?{ok:!1,msg:"'onHungup' parameter must be of type 'function'"}:"function"!=typeof e.onTrackReady?{ok:!1,msg:"'onTrackReady' parameter must be of type 'function'"}:{ok:!0}},X=function(e){return e&&"string"==typeof e?{ok:!0}:{ok:!1,msg:"'targetId' parameter is required, must be of type 'string'"}},Z=function(e){return e===A.AUDIO||e===A.AUDIO_VIDEO?{ok:!0}:{ok:!1,msg:"'mediaType' parameter is required, must be of type 'RCCallMediaType'"}},Q=function(e){return"string"==typeof e?{ok:!0}:{ok:!1,msg:"'extra' parameter must be of type 'string'"}},$=function(e){var t=["pushTitle","pushContent","pushData","iOSConfig","androidConfig","disablePushTitle","templateId"],n=Object.keys(e).every((function(e){return t.includes(e)}));if(!n)return{code:R.PARAM_ERROR,errorMsg:"right key: ".concat(t.join(","))};for(var a=0;a<t.length;a++){var s=t[a];if("disablePushTitle"===s){if(!r(e[s])&&!i(e[s]))return{code:R.PARAM_ERROR,errorMsg:"".concat(s," type is boolean")}}else if(("pushTitle"===s||"templateId"===s)&&e[s]&&!o(e[s]))return{code:R.PARAM_ERROR,errorMsg:"".concat(s," type is string")}}var l=e.iOSConfig,c=e.androidConfig,u=ee(l||{});if(u.code!==R.SUCCESS)return u;var d=te(c||{});return d.code!==R.SUCCESS?d:{code:R.SUCCESS}},ee=function(e){var t=e||{},n=t.threadId,r=t.richMediaUri;return n&&!o(n)?{code:R.PARAM_ERROR,errorMsg:"iOSConfig.threadId type is string"}:r&&!o(r)?{code:R.PARAM_ERROR,errorMsg:"iOSConfig.richMediaUri type is string"}:{code:R.SUCCESS}},te=function(e){var t=["notificationId","channelIdMi","channelIdHW","categoryHW","importanceHW","imageUrlHW","channelIdOPPO","typeVivo","categoryVivo","fcmChannelId","fcmCollapseKey","fcmImageUrl","importanceHonor","imageUrlHonor"],n=Object.keys(e).every((function(e){return t.includes(e)}));if(!n)return{code:R.PARAM_ERROR,errorMsg:"right key: ".concat(t.join(","))};for(var r=0;r<t.length;r++){var i=t[r];if("importanceHW"===i||"importanceHonor"===i){if(e[i]&&"LOW"!==e[i]&&"NORMAL"!==e[i])return{code:R.PARAM_ERROR,errorMsg:"androidConfig.".concat(i," value is NORMAL|LOW")}}else if(e[i]&&!o(e[i]))return{code:R.PARAM_ERROR,errorMsg:"androidConfig.".concat(i," type is string")}}return{code:R.SUCCESS}},ne=function(e){return Array.isArray(e)&&e.length?e.every((function(e){return"string"==typeof e&&e.length>0}))?{ok:!0}:{ok:!1,msg:"'userIds' parameter is required"}:{ok:!1,msg:"'userIds' parameter is required, must be of type 'string[]'"}};var re=function(e){return e&&e.audio&&void 0!==e.audio.micphoneId&&"string"!=typeof e.audio.micphoneId?{ok:!1,msg:"'constraints.audio.micphoneId' must be of type 'string'"}:e&&e.audio&&void 0!==e.audio.sampleRate&&"number"!=typeof e.audio.sampleRate?{ok:!1,msg:"'constraints.audio.sampleRate' must be of type 'number'"}:e&&e.video&&void 0!==e.video.cameraId&&"string"!=typeof e.video.cameraId?{ok:!1,msg:"'constraints.video.cameraId' must be of type 'string'"}:e&&e.video&&void 0!==e.video.frameRate&&"string"!=typeof e.video.frameRate?{ok:!1,msg:"'constraints.video.frameRate' must be of type 'string'"}:e&&e.video&&void 0!==e.video.frameRate&&(t=e.video.frameRate,!["FPS_10","FPS_15","FPS_24","FPS_30"].includes(t))?{ok:!1,msg:"'frameRate' value is out of range"}:e&&e.video&&void 0!==e.video.resolution&&"string"!=typeof e.video.resolution?{ok:!1,msg:"'constraints.video.frameRate' must be of type 'string'"}:e&&e.video&&void 0!==e.video.resolution&&(n=e.video.resolution,!c[n])?{ok:!1,msg:"'resolution' value is out of range"}:!e||!e.video||e.video.frameRate&&e.video.resolution?{ok:!0}:{ok:!1,msg:"'resolution' and 'resolution' is required"};var t,n},ie=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}(),oe=function(){function e(e,t,n,r){void 0===r&&(r={});var i=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:n}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:r}),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,n=e.reason;i._logger.info("_","[RCCallSession onUserStateChange] userId->".concat(null==t?void 0:t.userId," state->").concat(null==t?void 0:t.state," reason->").concat(n))},onStateChange:function(e){return f(i,void 0,void 0,(function(){var t,n,r,i,o;return g(this,(function(a){switch(a.label){case 0:if(t=e.state,n=e.reason,this._logger.info("_","[RCCallSession onStateChange] : state->".concat(t," reason->").concat(n)),t!==S.KEEPING)return[3,5];r=this._stateMachine.getCallId(),this._logger.info("_","[RCCallSession onStateChange] roomId: ".concat(r)),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this._joinRoom(r)];case 2:return a.sent(),[3,4];case 3:return i=a.sent(),this._exceptionClose(m.NETWORK_ERROR),this._logger.error("_","[RCCallSession onStateChange] joinRoom throw exception roomId -> ".concat(r)),console.error(i),[3,4];case 4:return[3,6];case 5:if(t===S.END){if(!this._room)return this._options.localTracks&&this._destroyTracks(this._options.localTracks),o=this._stateMachine.getSummary(),F.emit("sessionClose",{session:this,summaryInfo:o}),[2];this._options.localTracks&&this._destroyTracks(this._options.localTracks),this._logger.info("_","[RCCallSession onStateChange] localTracks destroyed"),this._leaveRoom(),this._room=null}a.label=6;case 6:return[2]}}))}))},onRinging:function(e){i._logger.info("_","[RCCallSession onRinging]sender: sender.userId -> ".concat(e.userId));try{i._listener.onRinging(e,i)}catch(e){i._logger.error("_","[RCCallSession onRinging] method exception -> onRinging"),console.error(e)}},onAccept:function(e){i._logger.info("_","[RCCallSession onAccept]sender: sender.userId -> ".concat(e.userId));try{i._listener.onAccept(e,i)}catch(e){i._logger.error("_","[RCCallSession onAccept] method exception -> onAccept"),console.error(e)}},onHungup:function(e,t){i._logger.info("_","[RCCallSession onHungup]sender: sender.userId -> ".concat(e.userId," reason->").concat(t));try{i._listener.onHungup(e,t,i)}catch(e){i._logger.error("_","[RCCallSession onHungup] method exception -> onHungup"),console.error(e)}},onMemberModify:function(e){var t=e.sender,n=e.invitedUsers;i._logger.info("_","[RCCallSession onMemberModify] sender.userId -> ".concat(t.userId));try{i._listener.onMemberModify(t,n,i)}catch(e){i._logger.error("_","[RCCallSession onMemberModify] method exception -> onMemberModify"),console.error(e)}},onMediaModify:function(e){var t=e.sender,n=e.mediaType;i._logger.info("_","[RCCallSession onMediaModify]sender: sender.userId -> ".concat(t.userId," mediaType: ").concat(n)),n===A.AUDIO&&i._setMediaTypeToAudio();try{i._listener.onMediaModify(t,n,i)}catch(e){i._logger.error("_","[RCCallSession onMediaModify] method exception -> onMediaModify"),console.error(e)}},crossAppkey:function(e){i._logger.info("_","[RCCallSession crossAppkey] 是否跨 appkey: ".concat(e)),i._options.isCrossAppkey=e}}),this._stateMachine.setHungupPushConfig(this._options.hungupPushConfig||{pushTitle:"",pushContent:""})}return Object.defineProperty(e.prototype,"_joinRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return f(this,void 0,void 0,(function(){var n,r,i,o,a,s,l,c=this;return g(this,(function(u){switch(u.label){case 0:return u.trys.push([0,7,,8]),this._options.isCrossAppkey?[4,this._rtcClient.joinCrossRTCRoom(e,this._options.joinType)]:[3,2];case 1:return n=u.sent(),[3,4];case 2:return[4,this._rtcClient.joinRTCRoom(e,this._options.joinType)];case 3:n=u.sent(),u.label=4;case 4:return r=n.code,i=n.userIds,o=n.room,r!==d.SUCCESS?(r===d.NOT_OPEN_VIDEO_AUDIO_SERVER&&this._exceptionClose(m.SERVICE_NOT_OPENED),r===d.SIGNAL_JOIN_RTC_ROOM_REFUSED?this._exceptionClose(m.OTHER_CLIENT_IN_CALL):this._exceptionClose(m.NETWORK_ERROR),this._logger.info("_","[RCCallClient _joinRoom] join room failed: roomId -> ".concat(e," RCRTCCode -> ").concat(r)),[2,{code:R.JOIN_ROOM_ERROR}]):(this._stateMachine.getConversationType()===t.GROUP&&this._stateMachine.userJoin([this._rtcClient.getCurrentId()]),this._stateMachine.getState()!==S.END?[3,6]:[4,this._rtcClient.leaveRoom(o)]);case 5:return u.sent(),this._room=null,[2,{code:R.SUCCESS}];case 6:return i.length<1&&(this.joinRoomTimer=new ie((function(){c._exceptionClose(m.REMOTE_NETWORK_ERROR)}),6e4)),this._room=o,[3,8];case 7:return a=u.sent(),this._exceptionClose(m.NETWORK_ERROR),this._logger.error("_","[RCCallSession _joinRoom] _rtcClient.joinRTCRoom throw exception roomId -> ".concat(e)),console.error(a),[2,{code:R.JOIN_ROOM_ERROR}];case 8:this._registerRoomEventListener(),this._registerReportListener(),u.label=9;case 9:return u.trys.push([9,11,,12]),[4,this._subscribeInRoomRemoteTrack()];case 10:return u.sent(),[3,12];case 11:return s=u.sent(),this._exceptionClose(m.SUBSCRIBE_ERROR),this._logger.error("_","[RCCallSession _joinRoom] _subscribeInRoomRemoteTrack Exception roomId -> ".concat(e)),console.error(s),[2,{code:R.JOIN_ROOM_ERROR}];case 12:return u.trys.push([12,14,,15]),[4,this._publish()];case 13:return u.sent(),[3,15];case 14:return l=u.sent(),this._exceptionClose(m.PUBLISH_ERROR),this._logger.error("_","[RCCallSession _joinRoom] _publish Exception roomId -> ".concat(e)),console.error(l),[2,{code:R.JOIN_ROOM_ERROR}];case 15:return[2,{code:R.SUCCESS}]}}))}))}}),Object.defineProperty(e.prototype,"_subscribeInRoomRemoteTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){var e,t;return g(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:(t=n.sent().code)!==d.SUCCESS&&(this._exceptionClose(m.SUBSCRIBE_ERROR),this._logger.error("_","[RCCallSession _subscribeInRoomRemoteTrack] Resource subscription failed roomId -> ".concat(this._stateMachine.getCallId()," RTC code -> ").concat(t))),n.label=2;case 2:return[2]}}))}))}}),Object.defineProperty(e.prototype,"_subscribeRetry",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){return void 0===t&&(t=!1),void 0===n&&(n=0),f(this,void 0,void 0,(function(){var r;return g(this,(function(i){switch(i.label){case 0:return[4,this._room.subscribe(e)];case 1:if((r=i.sent().code)!==d.SUCCESS){try{this._listener.onTrackSubscribeFail&&this._listener.onTrackSubscribeFail(r,this)}catch(e){this._logger.error("_","[RCCallSession] _listener.onTrackSubscribeFail exception"),console.error(e)}if(!t)return[2,{code:r}];if(n>0)return n--,[2,this._subscribeRetry(e,t,n)]}return[2,{code:r}]}}))}))}}),Object.defineProperty(e.prototype,"_publish",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){var e,t;return g(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(t=n.sent().code)!==d.SUCCESS?(this._exceptionClose(m.PUBLISH_ERROR),this._logger.info("_","[RCCallSession _publist] Resource publishing failed: roomId -> ".concat(this._stateMachine.getCallId()," RCRTCCode -> ").concat(t)),[2]):(this._options.produceType===B.CALLEE&&this._notifyTrackReady(e),[2])}}))}))}}),Object.defineProperty(e.prototype,"_publishRetry",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){return void 0===t&&(t=!1),void 0===n&&(n=0),f(this,void 0,void 0,(function(){var r;return g(this,(function(i){switch(i.label){case 0:return[4,this._room.publish(e)];case 1:if((r=i.sent().code)!==d.SUCCESS){try{this._listener.onTrackPublishFail&&this._listener.onTrackPublishFail(r,this)}catch(e){this._logger.error("_","[RCCallSession] _listener.onTrackPublishFail exception"),console.error(e)}if(!t)return[2,{code:r}];if(n>0)return n--,[2,this._publishRetry(e,t,n)]}return[2,{code:r}]}}))}))}}),Object.defineProperty(e.prototype,"_leaveRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){var e,t,n;return g(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,3,4]),[4,this._rtcClient.leaveRoom(this._room)];case 1:return e=r.sent(),this._logger.info("_","[RCCallSession _leaveRoom] Successfully exited the room code: ".concat(e.code)),[3,4];case 2:return t=r.sent(),this._logger.error("_","[RCCallSession _leaveRoom] leaveRoom throw exception"),console.error(t),[3,4];case 3:return n=this._stateMachine.getSummary(),F.emit("sessionClose",{session:this,summaryInfo:n}),[7];case 4:return[2]}}))}))}}),Object.defineProperty(e.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(e.prototype,"registerSessionListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=q(e);if(!t.ok)throw new Error("[RCCallSession registerSessionListener] ".concat(t.msg));this._listener=h({},e)}}),Object.defineProperty(e.prototype,"_getLocalTrackCore",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return f(this,void 0,void 0,(function(){var n,r,i,o,a,s;return g(this,(function(l){switch(l.label){case 0:return e!==A.AUDIO?[3,2]:[4,this._rtcClient.createMicrophoneAudioTrack("RongCloudRTC",t&&t.audio&&h({},t.audio))];case 1:return n=l.sent(),r=n.code,i=n.track,r!==d.SUCCESS?(this._logger.error("_","[RCCallSession _getLocalTrackCore] get Audio local tracks failed RCT code -> ".concat(r)),[2,{code:R.GET_LOCAL_AUDIO_TRACK_ERROR}]):(this._logger.info("_","[RCCallSession _getLocalTrackCore] successfully get Audio local tracks"),[2,{code:R.SUCCESS,tracks:[i]}]);case 2:return[4,this._rtcClient.createMicrophoneAndCameraTracks("RongCloudRTC",t&&h({},t))];case 3:return o=l.sent(),a=o.code,s=o.tracks,a!==d.SUCCESS?(this._logger.error("_","[RCCallSession _getLocalTrackCore] get Audio and Video local tracks failed RCT code -> ".concat(a)),[2,{code:R.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR}]):(this._logger.info("_","[RCCallSession _getLocalTrackCore] successfully get audio and video local tracks"),[2,{code:R.SUCCESS,tracks:s}])}}))}))}}),Object.defineProperty(e.prototype,"_getLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return f(this,void 0,void 0,(function(){var n,r,i,o,a,s,l,c,u;return g(this,(function(d){switch(d.label){case 0:return this._options.isAllowDemotionGetStream&&e===A.AUDIO_VIDEO?[4,this._getLocalTrackCore(A.AUDIO_VIDEO,t)]:[3,4];case 1:return n=d.sent(),r=n.code,i=n.tracks,r===R.SUCCESS?[3,3]:[4,this._getLocalTrackCore(A.AUDIO,t)];case 2:return o=d.sent(),a=o.code,s=o.tracks,a!==R.SUCCESS?(this._exceptionClose(m.GET_MEDIA_RESOURCES_ERROR),[2,{code:a}]):[2,{code:a,tracks:s}];case 3:return[2,{code:r,tracks:i}];case 4:return[4,this._getLocalTrackCore(e,t)];case 5:return l=d.sent(),c=l.code,u=l.tracks,c!==R.SUCCESS?(this._exceptionClose(m.GET_MEDIA_RESOURCES_ERROR),[2,{code:c}]):[2,{code:c,tracks:u}]}}))}))}}),Object.defineProperty(e.prototype,"changeAudioDevice",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return f(this,void 0,void 0,(function(){var t,n,r,i,o;return g(this,(function(a){switch(a.label){case 0:return t=[],n=[],[4,this._rtcClient.createMicrophoneAudioTrack("RongCloudRTC",e)];case 1:return r=a.sent(),i=r.code,o=r.track,i!==d.SUCCESS?(this._logger.error("_","[RCCallSession changeDevice] get local Audio tracks failed RCTLib code -> ".concat(i)),[2,{code:R.GET_LOCAL_AUDIO_TRACK_ERROR}]):(this._options.localTracks&&this._options.localTracks.forEach((function(e){e.isAudioTrack()||n.push(e)})),t.push(o),n.push(o),this._options.localTracks=n,this._notifyTrackReady(t),this._room?[4,this._room.publish(t)]:[3,3]);case 2:if(a.sent().code!==d.SUCCESS)return[2,{code:R.AUDIO_PUBLISH_ERROR}];a.label=3;case 3:return[2,{code:R.SUCCESS}]}}))}))}}),Object.defineProperty(e.prototype,"invite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===t&&(t={}),f(this,void 0,void 0,(function(){var n,r,i,o,a,s,l,c;return g(this,(function(u){switch(u.label){case 0:if(n=t.extra,r=void 0===n?"":n,i=this._options.callPushConfig?this._options.callPushConfig:t.pushConfig,o=[ne(e),Q(r)],i&&(a=$(i),s=a.code,l=a.errorMsg,s!==R.SUCCESS))return this._logger.error("_","[RCCallSession invite] param error, errorMsg: ".concat(l)),[2,{code:s}];if(c=[],!o.every((function(e){return!e.ok&&c.push(e.msg),e.ok})))throw new Error("[RCCallClient invite] ".concat(c.join("\n")));return[4,this._stateMachine.invite(e,{extra:r,pushConfig:i})];case 1:return[2,{code:u.sent().code}]}}))}))}}),Object.defineProperty(e.prototype,"accept",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return f(this,void 0,void 0,(function(){var t,n,r,i,o,a;return g(this,(function(s){switch(s.label){case 0:if(!(t=re(e)).ok)throw new Error("[RCCallSession accept] ".concat(t.msg));return F.emit("hungupOtherSession",{session:this}),n=this._stateMachine.getMediaType(),[4,this._getLocalTrack(n,e)];case 1:return r=s.sent(),i=r.code,o=r.tracks,i!==R.SUCCESS?[2,{code:i}]:(this._options.localTracks=o,[4,this._stateMachine.accept()]);case 2:return(a=s.sent().code)!==R.SUCCESS?(this._logger.error("_","[RCCallSession accept]Send accept message failed -> code: ".concat(a)),[2,{code:a}]):[2,{code:a}]}}))}))}}),Object.defineProperty(e.prototype,"hungup",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){return g(this,(function(e){return[2,this._stateMachine.hungup()]}))}))}}),Object.defineProperty(e.prototype,"_changeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return f(this,void 0,void 0,(function(){var t;return g(this,(function(n){switch(n.label){case 0:return[4,this._stateMachine.changeMediaType(e)];case 1:return(t=n.sent().code)!==R.SUCCESS&&this._logger.error("_","[RCCallSession _changeMediaType] change media type fail code-> ".concat(t)),[2,{code:t}]}}))}))}}),Object.defineProperty(e.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(e.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(e.prototype,"_setMediaTypeToAudioAndVideo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){var e,t,n;return g(this,(function(r){switch(r.label){case 0:return[4,this._rtcClient.createCameraVideoTrack()];case 1:return e=r.sent(),t=e.code,n=e.track,t!==d.SUCCESS?[2,{code:R.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR}]:[4,this._room.publish([n])];case 2:return r.sent().code!==d.SUCCESS?(this._logger.error("_","[RCCallSession _enableVideo] Resource publishing failed: RCRTCCode -> ".concat(t)),[2]):(this._notifyTrackReady([n]),this._changeMediaType(A.AUDIO_VIDEO),[2])}}))}))}}),Object.defineProperty(e.prototype,"_setMediaTypeToAudio",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){var e,t;return g(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:(t=n.sent().code)!==d.SUCCESS&&this._logger.error("_","[RCCallSession disableVideo] unpublish failed -> ".concat(t)),this._destroyTracks(e),n.label=2;case 2:return[2]}}))}))}}),Object.defineProperty(e.prototype,"descendAbility",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){var e;return g(this,(function(t){switch(t.label){case 0:return[4,this._changeMediaType(A.AUDIO)];case 1:return(e=t.sent().code)===R.SUCCESS&&this._setMediaTypeToAudio(),[2,{code:e}]}}))}))}}),Object.defineProperty(e.prototype,"disableVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){var e,t;return g(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:R.SUCCESS}]):(this._logger.error("_","[RCCallSession disableVideoTrack] Room missing video track -> ".concat(R.MISSING_VIDEO_TRACK_ERROR)),[2,{code:R.MISSING_VIDEO_TRACK_ERROR}]):(this._logger.error("_","[RCCallSession disableVideoTrack] Not in room"),[2,{code:R.NOT_IN_ROOM_ERROR}]);case 1:return(t=n.sent().code)!==d.SUCCESS?(this._logger.error("_","[RCCallSession disableVideo] unpublish failed -> ".concat(t)),[2,{code:R.UNPUBLISH_VIDEO_ERROR}]):(e.forEach((function(e){e.destroy()})),[2,{code:R.SUCCESS}])}}))}))}}),Object.defineProperty(e.prototype,"enableVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){var e,t,n,r,i;return g(this,(function(o){switch(o.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:R.SUCCESS}]):(this._logger.error("_","[RCCallSession enableVideoTrack] Room missing video track -> ".concat(R.MISSING_VIDEO_TRACK_ERROR)),[2,{code:R.MISSING_VIDEO_TRACK_ERROR}]):(this._logger.error("_","[RCCallSession enableVideoTrack] Not in room -> ".concat(R.NOT_IN_ROOM_ERROR)),[2,{code:R.NOT_IN_ROOM_ERROR}]);case 1:return t=o.sent(),n=t.code,r=t.track,n!==d.SUCCESS?(this._logger.error("_","[RCCallSession EnableVideoTrack] Get Resource failed: RCRTCCode -> ".concat(n)),[2,{code:R.GET_LOCAL_VIDEO_TRACK_ERROR}]):(i=[],this._options.localTracks&&this._options.localTracks.forEach((function(e){e.isVideoTrack()?e.destroy():i.push(e)})),i.push(r),this._options.localTracks=i,r.mute(),[4,this._room.publish([r])]);case 2:return o.sent().code!==d.SUCCESS?(this._logger.error("_","[RCCallSession EnableVideoTrack] Resource publishing failed: RCRTCCode -> ".concat(n)),[2,{code:R.VIDEO_PUBLISH_ERROR}]):(r.unmute(),this._notifyTrackReady([r]),[2,{code:R.SUCCESS}])}}))}))}}),Object.defineProperty(e.prototype,"disableAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){var e,t;return g(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(R.MISSING_AUDIO_TRACK_ERROR)),[2,{code:R.MISSING_AUDIO_TRACK_ERROR}]):(this._logger.warn("_","[RCCallSession disableAudioTrack] Not in room -> ".concat(R.NOT_IN_ROOM_ERROR)),[2,{code:R.NOT_IN_ROOM_ERROR}]);case 1:return(t=n.sent())!==d.SUCCESS&&this._logger.warn("_","[RCCallSession disableAudioTrack] mute failed -> ".concat(t)),[2,{code:t}]}}))}))}}),Object.defineProperty(e.prototype,"enableAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){var e,t;return g(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(R.MISSING_AUDIO_TRACK_ERROR)),[2,{code:R.MISSING_VIDEO_TRACK_ERROR}]):(this._logger.error("_","[RCCallSession enableAudioTrack] Not in room -> ".concat(R.NOT_IN_ROOM_ERROR)),[2,{code:R.NOT_IN_ROOM_ERROR}]);case 1:return(t=n.sent())!==d.SUCCESS&&this._logger.error("_","[RCCallSession enableAudioTrack] unmute failed -> ".concat(t)),[2,{code:t}]}}))}))}}),Object.defineProperty(e.prototype,"_destroyTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){e.forEach((function(e){e.destroy()}))}}),Object.defineProperty(e.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(e.prototype,"_registerRoomEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this._room.registerRoomEventListener({onKickOff:function(t,n){var r=e._rtcClient.getCurrentId();e._stateMachine.userLeave([r]),t?(n===u.SERVER_KICK&&e._exceptionClose(m.KICKED_BY_SERVER),n===u.OTHER_KICK&&e._exceptionClose(m.OTHER_CLIENT_JOINED_CALL)):e._exceptionClose(m.NETWORK_ERROR)},onMessageReceive:function(e,t,n,r){},onRoomAttributeChange:function(e,t){},onAudioMuteChange:function(t){e._logger.info("_","[RCCallSession onAudioMuteChange] userId->".concat(t.getUserId()," muted -> ").concat(t.isOwnerMuted()));var n={userId:t.getUserId(),muted:t.isOwnerMuted(),kind:"audio",trackId:t.getTrackId()};try{e._listener.onAudioMuteChange(n,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 n={userId:t.getUserId(),muted:t.isOwnerMuted(),kind:"video",trackId:t.getTrackId()};try{e._listener.onVideoMuteChange(n,e)}catch(t){e._logger.error("_","[RCCallSession onVideoMuteChange] Missing listening method -> onVideoMuteChange"),console.error(t)}},onTrackPublish:function(t){return f(e,void 0,void 0,(function(){var e;return g(this,(function(n){switch(n.label){case 0:return this._room?[4,this._room.subscribe(t)]:[3,2];case 1:(e=n.sent().code)!==d.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()===A.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){var n,r;try{null===(r=null===(n=e._listener)||void 0===n?void 0:n.onPing)||void 0===r||r.call(n,t,e)}catch(e){console.error(e)}}})}}),Object.defineProperty(e.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 n,r;try{null===(r=null===(n=e._listener)||void 0===n?void 0:n.onICEConnectionStateChange)||void 0===r||r.call(n,t,e)}catch(t){e._logger.error("_","[RCCallSession onICEConnectionStateChange] onICEConnectionStateChange exception"),console.error(t)}}})}}),Object.defineProperty(e.prototype,"getSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getCallId()}}),Object.defineProperty(e.prototype,"getRTCSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._room?this._room.getSessionId():null}}),Object.defineProperty(e.prototype,"getTargetId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getTargetId()}}),Object.defineProperty(e.prototype,"getConversationType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getConversationType()}}),Object.defineProperty(e.prototype,"getChannelId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getChannelId()}}),Object.defineProperty(e.prototype,"getRemoteUsers",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getRemoteUsers()}}),Object.defineProperty(e.prototype,"getUsers",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getRemoteUsers()}}),Object.defineProperty(e.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(e.prototype,"getState",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getState()}}),Object.defineProperty(e.prototype,"getCallerId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getCallerId()}}),Object.defineProperty(e.prototype,"getMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getMediaType()}}),e}(),ae=function(){function e(e,t,n,r){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:n}),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=r.rtcClient,this._options=h({isAllowPublishRetry:!1,isAllowSubscribeRetry:!1,isOffCameraWhenVideoDisable:!0,joinType:a.COEXIST,isAllowDemotionGetStream:!1,lang:D.ZH},r),this._callEngine=new Y(this._context,t,this._logger,{onInvite:this._onInvite.bind(this),onOfflineRecord:this._onOfflineRecord.bind(this)},{lang:this._options.lang||D.ZH}),F.on("sessionClose",(function(e){var t=e.session,n=e.summaryInfo;i._removeSession(t);try{i._options.onSessionClose(t,n)}catch(e){i._logger.error("_","[RCCCallClient] options.onSessionClose exception"),console.log(e)}})),F.on("hungupOtherSession",(function(e){var t=e.session.getSessionId();i._logger.info("_","[RCCallClient hungupOtherSession] sessionId ready to accept -> ".concat(t)),i._logger.info("_","[RCCallClient hungupOtherSession] sessionList ->".concat(i._sessionList.map((function(e){return e.getSessionId()})).join(",")));for(var n=0;i._sessionList.length>1;)i._sessionList[n].getSessionId()!==t?(i._sessionList[n].hungup(),i._sessionList.splice(n,1)):n++;i._logger.info("_","[RCCallClient hungupOtherSession] current sessionList length ->".concat(i._sessionList.length))}))}return Object.defineProperty(e.prototype,"_onInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info("_","[RCCallClient _onInvite] Received invite message");var n=new oe(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:B.CALLEE,callPushConfig:this._callPushConfig,hungupPushConfig:this._hungupPushConfig});this._logger.info("_","[RCCallClient _onInvite] Received invite message, successfully created session"),this._sessionList.push(n);try{this._options.onSession(n,t)}catch(e){this._logger.error("_","[RCCallClient _options.onSession] onSession exception"),console.log(e)}if(!n._listener)throw this._logger.error("_","[RCCallClient _options.onSession] session Must Have Listener"),new Error("[RCCallSession _options.onSession] session Must Have Listener");var r=q(n._listener);if(!r.ok)throw new Error(r.msg)}}),Object.defineProperty(e.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(e.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(e.prototype,"startCrossCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.targetId,n=e.mediaType,r=void 0===n?A.AUDIO:n,i=e.listener,o=e.constraints,a=e.channelId,s=void 0===a?"":a,l=e.extra,c=void 0===l?"":l,u=e.pushTitle,d=void 0===u?"":u,_=e.pushContent,h=void 0===_?"":_,p=e.bitrate;return f(this,void 0,void 0,(function(){return g(this,(function(e){return[2,this.__call({targetId:t,mediaType:r,listener:i,constraints:o,channelId:s,extra:c,pushTitle:d,pushContent:h,bitrate:p,isCrossAppkey:!0})]}))}))}}),Object.defineProperty(e.prototype,"call",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.targetId,n=e.mediaType,r=void 0===n?A.AUDIO:n,i=e.listener,o=e.constraints,a=e.channelId,s=void 0===a?"":a,l=e.extra,c=void 0===l?"":l,u=e.pushTitle,d=void 0===u?"":u,_=e.pushContent,h=void 0===_?"":_,p=e.bitrate;return f(this,void 0,void 0,(function(){return g(this,(function(e){return[2,this.__call({targetId:t,mediaType:r,listener:i,constraints:o,channelId:s,extra:c,pushTitle:d,pushContent:h,bitrate:p})]}))}))}}),Object.defineProperty(e.prototype,"__call",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.targetId,n=e.mediaType,r=void 0===n?A.AUDIO:n,i=e.listener,o=e.constraints,a=e.channelId,s=void 0===a?"":a,l=e.extra,c=void 0===l?"":l,u=e.pushTitle,d=void 0===u?"":u,_=e.pushContent,h=void 0===_?"":_,p=e.bitrate,b=e.isCrossAppkey,C=void 0!==b&&b;return f(this,void 0,void 0,(function(){var e,n,a,l,u,_,f,b,I,m,y,v,E,O;return g(this,(function(g){switch(g.label){case 0:return e=this._callPushConfig?this._callPushConfig:{pushTitle:d,pushContent:h},this._logger.info("_","[RCCallClient call] targetId: ".concat(t,", mediaType: ").concat(r)),t===this._context.getCurrentId()?(this._logger.error("_","[RCCallClient call] targetId is equal to currentId"),[2,{code:R.PARAM_ERROR}]):(n=[X(t),Z(r),q(i),Q(c)],a=[],n.every((function(e){return!e.ok&&a.push(e.msg),e.ok}))?(l=$(e),u=l.code,_=l.errorMsg,u!==R.SUCCESS?(this._logger.error("_","[RCCallClient call] param error, errorMsg: ".concat(_)),[2,{code:u}]):(f=[],[4,this._getLocalTrack(r,o)])):(console.error(a.join("\n")),[2,{code:R.PARAM_ERROR}]));case 1:return b=g.sent(),I=b.code,m=b.tracks,I!==R.SUCCESS?[2,{code:I}]:((f=m).forEach((function(e){var t,n,r;e.isAudioTrack()&&(null==p?void 0:p.audio)&&e.setBitrate(null==p?void 0:p.audio),e.isVideoTrack()&&(null==p?void 0:p.video)&&e.setBitrate(null===(t=null==p?void 0:p.video)||void 0===t?void 0:t.max,null===(n=null==p?void 0:p.video)||void 0===n?void 0:n.min,null===(r=null==p?void 0:p.video)||void 0===r?void 0:r.start),i.onTrackReady(e)})),[4,this._callEngine.call(s,t,r,c,e,C)]);case 2:return y=g.sent(),v=y.code,E=y.stateMachine,v===R.SUCCESS&&E?(this._logger.info("_","[RCCallClient call] successfully created state machine"),(O=new oe(E,this._rtcClient,this._logger,{localTracks:f,isAllowSubscribeRetry:this._options.isAllowSubscribeRetry,isAllowPublishRetry:this._options.isAllowPublishRetry,isOffCameraWhenVideoDisable:this._options.isOffCameraWhenVideoDisable,joinType:this._options.joinType,isAllowDemotionGetStream:this._options.isAllowDemotionGetStream,produceType:B.CALLER,isCrossAppkey:C,callPushConfig:this._callPushConfig,hungupPushConfig:this._hungupPushConfig})).registerSessionListener(i),this._sessionList.push(O),this._logger.info("_","[RCCallClient call] successfully created session object, sessionId: ".concat(O.getSessionId())),[2,{code:v,session:O}]):(this._logger.error("_","[RCCallClient call] call failed code ->: ".concat(v)),f.forEach((function(e){e.mute(),e.destroy()})),[2,{code:v}])}}))}))}}),Object.defineProperty(e.prototype,"callInGroup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.targetId,n=e.userIds,r=e.mediaType,i=void 0===r?A.AUDIO:r,o=e.listener,a=e.constraints,s=e.channelId,l=void 0===s?"":s,c=e.extra,u=void 0===c?"":c,d=e.pushTitle,_=void 0===d?"":d,h=e.pushContent,p=void 0===h?"":h,b=e.bitrate;return f(this,void 0,void 0,(function(){var e,r,s,c,d,h,f,C,I,m,y,v,E,O,T;return g(this,(function(g){switch(g.label){case 0:return e=this._callPushConfig?this._callPushConfig:{pushTitle:_,pushContent:p},r=[X(t),ne(n),Z(i),q(o),Q(u)],s=[],c=r.every((function(e){return!e.ok&&s.push(e.msg),e.ok})),n.includes(this._context.getCurrentId())?(console.error("[RCCallClient callInGroup] userIds includes currentId"),[2,{code:R.PARAM_ERROR}]):c?(d=$(e),h=d.code,f=d.errorMsg,h!==R.SUCCESS?(this._logger.error("_","[RCCallClient call] param error, errorMsg: ".concat(f)),[2,{code:h}]):(C=[],[4,this._getLocalTrack(i,a)])):(console.error("[RCCallClient callInGroup] ".concat(s.join("\n"))),[2,{code:R.PARAM_ERROR}]);case 1:return I=g.sent(),m=I.code,y=I.tracks,m!==R.SUCCESS?[2,{code:m}]:((C=y).forEach((function(e){var t,n,r;e.isAudioTrack()&&(null==b?void 0:b.audio)&&e.setBitrate(null==b?void 0:b.audio),e.isVideoTrack()&&(null==b?void 0:b.video)&&e.setBitrate(null===(t=null==b?void 0:b.video)||void 0===t?void 0:t.max,null===(n=null==b?void 0:b.video)||void 0===n?void 0:n.min,null===(r=null==b?void 0:b.video)||void 0===r?void 0:r.start),o.onTrackReady(e)})),[4,this._callEngine.callInGroup(l,t,i,n,u,e)]);case 2:return v=g.sent(),E=v.code,O=v.stateMachine,E===R.SUCCESS&&O?(this._logger.info("_","[RCCallClient callInGroup] successfully created state machine"),(T=new oe(O,this._rtcClient,this._logger,{localTracks:C,isAllowSubscribeRetry:this._options.isAllowSubscribeRetry,isAllowPublishRetry:this._options.isAllowPublishRetry,isOffCameraWhenVideoDisable:this._options.isOffCameraWhenVideoDisable,joinType:this._options.joinType,isAllowDemotionGetStream:this._options.isAllowDemotionGetStream,produceType:B.CALLER,callPushConfig:this._callPushConfig,hungupPushConfig:this._hungupPushConfig})).registerSessionListener(o),this._sessionList.push(T),this._logger.info("_","[RCCallClient callInGroup] successfully created session object, sessionId: ".concat(T.getSessionId())),[2,{code:E,session:T}]):(this._logger.info("_","[RCCallClient callInGroup] callInGroup failed code -> ".concat(E)),C.forEach((function(e){e.mute(),e.destroy()})),[2,{code:E}])}}))}))}}),Object.defineProperty(e.prototype,"_getLocalTrackCore",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return f(this,void 0,void 0,(function(){var n,r,i,o,a,s;return g(this,(function(l){switch(l.label){case 0:return e!==A.AUDIO?[3,2]:[4,this._rtcClient.createMicrophoneAudioTrack("RongCloudRTC",t&&t.audio&&h({},t.audio))];case 1:return n=l.sent(),r=n.code,i=n.track,r!==d.SUCCESS?(this._logger.error("_","[RCCallClient _getTrack] get Audio local tracks failed RCT code -> ".concat(r)),[2,{code:R.GET_LOCAL_AUDIO_TRACK_ERROR}]):(this._logger.info("_","[RCCallClient _getTrack] successfully get Audio local tracks"),[2,{code:R.SUCCESS,tracks:[i]}]);case 2:return[4,this._rtcClient.createMicrophoneAndCameraTracks("RongCloudRTC",t&&h({},t))];case 3:return o=l.sent(),a=o.code,s=o.tracks,a!==d.SUCCESS?(this._logger.error("_","[RCCallClient _getTrack] get Audio and Video local tracks failed RCT code -> ".concat(a)),[2,{code:R.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR}]):(this._logger.info("_","[RCCallClient _getTrack] successfully get audio and video local tracks"),[2,{code:R.SUCCESS,tracks:s}])}}))}))}}),Object.defineProperty(e.prototype,"_getLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return f(this,void 0,void 0,(function(){var n,r,i,o,a,s,l,c,u;return g(this,(function(d){switch(d.label){case 0:return this._options.isAllowDemotionGetStream&&e===A.AUDIO_VIDEO?[4,this._getLocalTrackCore(A.AUDIO_VIDEO,t)]:[3,4];case 1:return n=d.sent(),r=n.code,i=n.tracks,r===R.SUCCESS?[3,3]:[4,this._getLocalTrackCore(A.AUDIO,t)];case 2:return o=d.sent(),a=o.code,s=o.tracks,a!==R.SUCCESS?[2,{code:a}]:[2,{code:a,tracks:s}];case 3:return[2,{code:r,tracks:i}];case 4:return[4,this._getLocalTrackCore(e,t)];case 5:return l=d.sent(),c=l.code,u=l.tracks,c!==R.SUCCESS?[2,{code:c}]:[2,{code:c,tracks:u}]}}))}))}}),Object.defineProperty(e.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(e.prototype,"getJoinedRoomInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){var e,t,r;return g(this,(function(i){switch(i.label){case 0:return[4,this._context.getRTCJoinedUserInfo(this._context.getCurrentId())];case 1:return e=i.sent(),t=e.code,r=e.data,t!==n.SUCCESS?(this._logger.error("_","getJoinedUserInfo error code: ".concat(t)),[2,{code:R.QUERY_JOINED_USER_INFO_ERROR}]):[2,{code:R.SUCCESS,data:r}]}}))}))}}),Object.defineProperty(e.prototype,"setPushConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n,r,i=[e,t].map((function(e){return $(e)}));try{for(var o=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(i),a=o.next();!a.done;a=o.next()){var s=a.value,l=s.code,c=s.errorMsg;if(l!==R.SUCCESS)return this._logger.error("_","[RCCallClient setPushConfig] param error, errorMsg: ".concat(c)),{code:l}}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}this._callPushConfig=e,this._hungupPushConfig=t}}),e}();l.add("calllib","5.2.10");var se={tag:"RCCall",verify:function(e){return"browser"===e.tag},setup:function(e,t,n){var r=z(n);if(!r.ok)throw new Error("[RCCallLib installer steup]".concat(r.msg));if(!l.validEngine("5.9.0"))throw new Error("The current engine version '".concat(l.getInfo().engine,"' error, plugin-call required engine version at least '").concat("5.9.0","'."));var i=e.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.10",", Commit: ").concat("b49ac7f3aef4e11e35cd5c4bd12be262e2779937")),new ae(e,t,i,n)}};export{ae as RCCallClient,m as RCCallEndReason,R as RCCallErrorCode,D as RCCallLanguage,A as RCCallMediaType,oe as RCCallSession,S as RCCallSessionState,M as RCCallUserState,se as installer};
|
|
9
|
+
e[e.RCCallRoomTypeAcrossCall=7]="RCCallRoomTypeAcrossCall"}(P||(P={}));var N,A,U,L=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}(),j=function(){function e(e,t,n,r,i,o,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:n}),Object.defineProperty(this,"_callMsgHandler",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_channelId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_conversationType",{enumerable:!0,configurable:!0,writable:!0,value:o}),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(e.prototype,"_getTimeout",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._context.getServerTime()-e;t<0&&(t=500);var n=this._callTimeout-t;return this._logger.warn("_","_getTimeout -> timeout: ".concat(n)),n}}),Object.defineProperty(e.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(e.prototype,"_notifyStateChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n;this._logger.warn("_","[RCCallStateMachine] notifyStateChange -> info: ".concat(JSON.stringify({state:e,reason:t}))),this._endReason=t||null,this._sessionState!==e&&(this._sessionState=e,null===(n=this._watchers)||void 0===n||n.onStateChange({state:e,reason:t})),e===S.END&&(v.emit("onStateMachineClose",this._callId),this._callMsgHandler.unregisterStateMachineEvent(this._callId))}}),Object.defineProperty(e.prototype,"_notifyUserStateChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n;this._logger.warn("_","[RCCallStateMachine] notifyUserStateChange -> info: ".concat(JSON.stringify({user:e,reason:t}))),null===(n=this._watchers)||void 0===n||n.onUserStateChange({user:e,reason:t})}}),Object.defineProperty(e.prototype,"_otherClientHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,n=e.content,r=n.user,i=n.reason,o=e.messageType;for(var s in this._userInfo[t]={userId:t,state:M.NONE,isCaller:!1,isRemote:!1},this._userTimers)this._clearTimerById(s);var a=E.ACCEPT_BY_OTHER_CLIENT;o===T.VCHangup&&(a=i===E.BUSY_LINE?E.OTHER_CLIENT_IN_CALL:i===E.NO_RESPONSE?E.NO_RESPONSE:E.HANGUP_BY_OTHER_CLIENT),Object.assign(this._userInfo[t],r),this._notifyUserStateChange(this._userInfo[t],a),this._notifyStateChange(S.END,a)}}),Object.defineProperty(e.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===M.KEEPING&&this._userInfo[e].deviceId!==t))}}),Object.defineProperty(e.prototype,"_onRinging",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,n=e.content,r=n.user,i=n.deviceId,o=this._isCrossAppkey?t.split("_")[1]:t;this._isRemoteInvalidMsg(o,i)?this._logger.debug("_","[RCCallStateMachine] onRinging -> not the remote device that is currently talking"):this._context.getCurrentId()!==o&&this._watchers.onRinging(f({userId:o},r))}}),Object.defineProperty(e.prototype,"_onAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n=this,r=e.senderUserId,i=e.content,o=i.user,s=i.deviceId;e.sentTime;var a=this._isCrossAppkey?r.split("_")[1]:r,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===t.PRIVATE?[l,a]:[a]).forEach((function(e){var t=e===l;n._userInfo[e]={userId:e,state:M.KEEPING,isCaller:t,isRemote:t,deviceId:t?O(n._runtime):s},t||(n._beginTimestamp=Date.now(),Object.assign(n._userInfo[a],o)),n._notifyUserStateChange(n._userInfo[e])})),this.getCallerId()===l&&this._notifyStateChange(S.KEEPING),this._watchers.onAccept({userId:a})):this._otherClientHandle(e)}}),Object.defineProperty(e.prototype,"_onMediaModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,n=e.content,r=n.mediaType,i=n.user,o=n.deviceId;this._isRemoteInvalidMsg(t,o)?this._logger.debug("_","[RCCallStateMachine] _onMediaModify -> not the remote device that is currently talking"):this._context.getCurrentId()!==t&&(this._mediaType=r,this._watchers.onMediaModify({sender:f({userId:t},i),mediaType:r}))}}),Object.defineProperty(e.prototype,"_onHungup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,n=e.content,r=this._isCrossAppkey?t.split("_")[1]:t,i=n,o=i.reason,s=i.user,a=i.deviceId,l=this._context.getCurrentId();if(this._isRemoteInvalidMsg(r,a))this._logger.debug("_","[RCCallStateMachine] _onHungup -> not the remote device that is currently talking");else if(l!==r)if(this._sessionState!==S.END){this._userInfo[r]&&(this._userInfo[r].state=M.NONE,this._endTimestamp=Date.now(),Object.assign(this._userInfo[r],s),this._notifyUserStateChange(this._userInfo[r],w[o]),delete this._userInfo[r]),w[o]===E.REMOTE_CANCEL?this.getRemoteUserIds().length<1&&this._clearTimerById(l):this.getInviterId()===l?this._clearTimerById(r):this.getRemoteUserIds().length<1&&this._clearTimerById(l);var c=Object.keys(this._userInfo).length<2,u=this._inviterId===r,d=Object.values(this._userInfo).every((function(e){return e.state!==M.KEEPING}));(c||u&&d)&&this._notifyStateChange(S.END,w[o]),this._watchers.onHungup(f({userId:r},s),w[o])}else this._logger.info("_","[RCCallStateMachine] Invalid hang up message, current room status has ended -> sessionState: ".concat(this._sessionState));else this._otherClientHandle(e)}}),Object.defineProperty(e.prototype,"registerEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._watchers=e}}),Object.defineProperty(e.prototype,"__onInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,n,r=this,i=e.senderUserId,o=e.content,s=e.sentTime,a=o,l=a.inviteUserIds,c=a.user,u=a.deviceId;a.roomType===P.RCCallRoomTypeAcrossCall?(t=p(i.split("_"),2),n=t[1],this._watchers.crossAppkey(!0),this._isCrossAppkey=!0):n=i;var d=this._context.getCurrentId();if(this._isRemoteInvalidMsg(n,u))this._logger.debug("_","[RCCallStateMachine] __onInvite -> not the remote device that is currently talking");else if(d!==n){this._callerId=this._inviterId=n;var _=b([i],p(l),!1);this._callMsgHandler.sendRinging({conversationType:this._conversationType,targetId:this._targetId,channelId:this._channelId,callId:this._callId,userIds:_.filter((function(e){return r._isCrossAppkey?e.split("_")[1]!==d:e!==d}))});var f=this._isCrossAppkey?[l[0].split("_")[1]]:l;b([n],p(f),!1).forEach((function(e){r._userInfo[e]={userId:e,state:M.WAITING,isCaller:e===n,isRemote:e!==d},e===n&&Object.assign(r._userInfo[e],c,{deviceId:u}),r._notifyUserStateChange(r._userInfo[e]),e!==n&&(r._userTimers[e]=new L((function(){var t=e===d?E.NO_RESPONSE:E.REMOTE_NO_RESPONSE;e===d?r._hungupHandle(t,!1):(r._userInfo[e]&&(r._userInfo[e].state=M.NONE),r._notifyUserStateChange(r._userInfo[e]),r._watchers.onHungup(r._userInfo[e],t),delete r._userInfo[e]),r._clearTimerById(e)}),r._getTimeout(s)))})),this._notifyStateChange(S.WAITING)}}}),Object.defineProperty(e.prototype,"__onMemberModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,n=e.senderUserId,r=e.content,i=e.sentTime,o=r,s=o.user,a=o.existedUserPofiles,l=o.caller,c=o.deviceId,u=o.inviteUserIds,d=o.mediaType,_=this._context.getCurrentId();if(this._isRemoteInvalidMsg(n,c))this._logger.debug("_","[RCCallStateMachine] __onMemberModify -> not the remote device that is currently talking");else if(_!==n){if(this._callerId=l,this._inviterId=n,u.forEach((function(e){a.push({userId:e,mediaType:d,callStatus:C.INCOMING})})),u.includes(_)){var h=[];a.forEach((function(e){e.userId!==_&&h.push(e.userId)})),this._callMsgHandler.sendRinging({conversationType:this._conversationType,targetId:this._targetId,channelId:this._channelId,callId:this._callId,userIds:h}),this._notifyStateChange(S.WAITING)}else this._watchers.onMemberModify({sender:f({userId:n},s),invitedUsers:u.map((function(e){return{userId:e}}))});a.forEach((function(e){var r=e.userId,o=e.callStatus;if(o!==C.IDLE&&(t._userInfo[r]={userId:r,state:o!==C.CONNECTED?M.WAITING:M.KEEPING,isCaller:n===r,isRemote:_!==r},r===n&&Object.assign(t._userInfo[r],s,{deviceId:c}),t._notifyUserStateChange(t._userInfo[r]),o!==C.CONNECTED&&!t._userTimers[r])){if(!u.includes(r))return;t._userTimers[r]=new L((function(){t._userInfo[r]&&(t._userInfo[r].state=M.NONE);var e=r===_?E.NO_RESPONSE:E.REMOTE_NO_RESPONSE;t._notifyUserStateChange(t._userInfo[r],e);try{t._watchers.onHungup(t._userInfo[r],e)}catch(e){t._logger.error("_","[RCCallStateMachine] call onhungup error -> ".concat(null==e?void 0:e.stack))}delete t._userInfo[r],(Object.keys(t._userInfo).length<2||r===_)&&t._notifyStateChange(S.END,e),t._clearTimerById(r)}),t._getTimeout(i))}}))}}}),Object.defineProperty(e.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=M.NONE),this._notifyUserStateChange(this._userInfo[e]),this._clearTimerById(e);this._notifyStateChange(S.END,E.BUSY_LINE),this._callMsgHandler.sendHungup({channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,reason:E.BUSY_LINE,userIds:this.getRemoteUserIds()})}}),Object.defineProperty(e.prototype,"__call",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){return void 0===t&&(t=""),void 0===r&&(r=!1),h(this,void 0,void 0,(function(){var i,o,s,a,l,c,u=this;return g(this,(function(d){switch(d.label){case 0:return this._logger.debug("_","[RCCallStateMachine] invite -> userIds: ".concat(JSON.stringify(e))),i=this._callerId=this._inviterId=this._context.getCurrentId(),[4,this._callMsgHandler.sendInvite({roomType:r?P.RCCallRoomTypeAcrossCall:P.RCCallRoomTypeNormalCall,channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,extra:t,pushConfig:n,mediaType:this._mediaType,inviteUserIds:e.filter((function(e){return e!==i}))})];case 1:return o=d.sent(),s=o.code,a=o.message,this._isCrossAppkey=r,s===R.SUCCESS?(l=a.sentTime,b([i],r?[e[0].split("_")[1]]:p(e),!1).forEach((function(e){var t=e===i;u._userInfo[e]={userId:e,state:M.WAITING,isCaller:t,isRemote:!t},u._notifyUserStateChange(u._userInfo[e]),t||(u._userTimers[e]=new L((function(){u._userInfo[e]&&(u._userInfo[e].state=M.NONE),u._notifyUserStateChange(u._userInfo[e],E.REMOTE_NO_RESPONSE),u._watchers.onHungup(u._userInfo[e],E.REMOTE_NO_RESPONSE),delete u._userInfo[e],Object.keys(u._userInfo).length<2&&u._notifyStateChange(S.END,E.REMOTE_NO_RESPONSE),0===u.getRemoteUserIds().length&&u._userInfo[i].state!==M.KEEPING&&u._hungupHandle(E.REMOTE_NO_RESPONSE)}),u._getTimeout(l)))})),this._notifyStateChange(S.WAITING)):(c=s===R.REJECTED_BY_BLACKLIST?E.ADDED_TO_BLACKLIST:E.NETWORK_ERROR,this._notifyStateChange(S.END,c)),[2,{code:s}]}}))}))}}),Object.defineProperty(e.prototype,"accept",{enumerable:!1,configurable:!0,writable:!0,value:function(){return h(this,void 0,void 0,(function(){var e,t,n,r,i;return g(this,(function(o){switch(o.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=o.sent(),n=t.code,r=t.message,this._clearTimerById(e),n===R.SUCCESS?(r.sentTime,this._userInfo[e]&&(this._userInfo[e].state=M.KEEPING),this._beginTimestamp=Date.now(),this._notifyUserStateChange(this._userInfo[e]),this._notifyStateChange(S.KEEPING)):(this._userInfo[e]&&(this._userInfo[e].state=M.NONE),this._notifyUserStateChange(this._userInfo[e]),i=n===R.REJECTED_BY_BLACKLIST?E.ADDED_TO_BLACKLIST:E.NETWORK_ERROR,this._notifyStateChange(S.END,i)),[2,{code:n}]}}))}))}}),Object.defineProperty(e.prototype,"invite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,n){return void 0===n&&(n={}),h(this,void 0,void 0,(function(){var r,i,o,s,a,l,c,u,d,_,f,h=this;return g(this,(function(g){switch(g.label){case 0:return this._conversationType!==t.GROUP?[2,{code:R.CONVERSATION_NOT_GROUP_ERROR}]:(this._logger.info("_","[RCCallStateMachine] invite -> userIds: ".concat(JSON.stringify(e))),r=this._context.getCurrentId(),i=Object.keys(this._userInfo),0===(o=e.filter((function(e){return e!==r&&!i.includes(e)}))).length?(this._logger.warn("_","[RCCallStateMachine] invite -> all userId is in calling now!"),[2,{code:R.PARAM_ERROR}]):(s=i.map((function(e){var t=C.CONNECTED;return h._userInfo[e].state===M.WAITING&&(t=C.RINGING),{userId:e,mediaType:h._mediaType,callStatus:t,mediaId:e}})),a=n.extra,l=void 0===a?"":a,c=n.pushConfig,[4,this._callMsgHandler.sendMemeberModify({channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,extra:l,pushConfig:c,mediaType:this._mediaType,inviteUserIds:o,callerId:this.getCallerId(),existedUserPofiles:s,directionalUserIdList:b(b([],p(i),!1),p(o),!1).filter((function(e){return e!==r}))})]));case 1:return u=g.sent(),d=u.code,_=u.message,d===R.SUCCESS?(f=_.sentTime,o.forEach((function(e){h._userInfo[e]={userId:e,state:M.WAITING,isCaller:!1,isRemote:!0},h._notifyUserStateChange(h._userInfo[e]),h._userTimers[e]=new L((function(){h._userInfo[e]&&(h._userInfo[e].state=M.NONE),h._notifyUserStateChange(h._userInfo[e],E.REMOTE_NO_RESPONSE),h._watchers.onHungup(h._userInfo[e],E.REMOTE_NO_RESPONSE),delete h._userInfo[e],Object.keys(h._userInfo).length<2&&h._notifyStateChange(S.END,E.REMOTE_NO_RESPONSE)}),h._getTimeout(f))}))):o.forEach((function(e){h._userInfo[e]={userId:e,state:M.NONE,isCaller:!1,isRemote:!0};var t=d===R.REJECTED_BY_BLACKLIST?E.ADDED_TO_BLACKLIST:E.NETWORK_ERROR;h._notifyUserStateChange(h._userInfo[e],t)})),[2,{code:d}]}}))}))}}),Object.defineProperty(e.prototype,"_hungupHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===t&&(t=!0),h(this,void 0,void 0,(function(){var n,r,i,o,s;return g(this,(function(a){switch(a.label){case 0:return n=this._context.getCurrentId(),r=R.SUCCESS,t?(i={channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,reason:e,userIds:this.getRemoteUserIds(),pushConfig:this._hungupPushConfig},e!==E.OTHER_CLIENT_JOINED_CALL?[3,1]:(this._callMsgHandler.sendHungup(i),[3,3])):[3,3];case 1:return[4,this._callMsgHandler.sendHungup(i)];case 2:o=a.sent().code,r=o,a.label=3;case 3:for(s in this._endTimestamp=Date.now(),this._userInfo)this._userInfo[s].state=M.NONE,s===n?this._notifyUserStateChange(this._userInfo[s],e):this._notifyUserStateChange(this._userInfo[s]),delete this._userInfo[s];return Object.keys(this._userInfo).length<2&&this._notifyStateChange(S.END,e),[2,{code:r}]}}))}))}}),Object.defineProperty(e.prototype,"hungup",{enumerable:!1,configurable:!0,writable:!0,value:function(){return h(this,void 0,void 0,(function(){var e,t,n;return g(this,(function(r){for(n in this._logger.debug("_","[RCCallStateMachine] hungup"),e=this._context.getCurrentId(),t=E.HANGUP,Object.keys(this._userTimers).length>0&&(this._userInfo[e].isCaller?t=E.CANCEL:this._userInfo[e].state===M.WAITING&&(t=E.REJECT)),this._userTimers)this._clearTimerById(n);return[2,this._hungupHandle(t)]}))}))}}),Object.defineProperty(e.prototype,"changeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return h(this,void 0,void 0,(function(){var t;return g(this,(function(n){switch(n.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=n.sent().code)===R.SUCCESS&&(this._mediaType=e),[2,{code:t}]}}))}))}}),Object.defineProperty(e.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 n=t._userInfo[e];n&&n.state!==M.KEEPING&&(n.state=M.KEEPING,t._notifyUserStateChange(n)),t._sessionState!==S.KEEPING&&t._notifyStateChange(S.KEEPING),t._clearTimerById(e)}))}),300)}}),Object.defineProperty(e.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 n=t._userInfo[e];n&&n.state!==M.NONE&&(n.state=M.NONE,t._notifyUserStateChange(n,E.REMOTE_HANGUP),t._watchers.onHungup(n,E.REMOTE_HANGUP),delete t._userInfo[e]),new L((function(){var e=t.getRemoteUsers();1===e.length&&1===e[0].state&&t._hungupHandle(E.REMOTE_NETWORK_ERROR)}),6e4),Object.keys(t._userInfo).length<2&&t._sessionState!==S.END&&(t._endTimestamp=Date.now(),t._notifyStateChange(S.END,E.REMOTE_HANGUP))}))}),300)}}),Object.defineProperty(e.prototype,"userOffline",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;this._logger.debug("_","[RCCallStateMachine] userOffline -> userIds: ".concat(JSON.stringify(e))),e.forEach((function(e){var n=t._userInfo[e];n&&n.state!==M.NONE&&(n.state=M.NONE,t._notifyUserStateChange(n,E.REMOTE_NETWORK_ERROR),t._watchers.onHungup(n,E.REMOTE_NETWORK_ERROR),delete t._userInfo[e]),Object.keys(t._userInfo).length<2&&t._sessionState!==S.END&&(t._endTimestamp=Date.now(),t._notifyStateChange(S.END,E.REMOTE_NETWORK_ERROR))}))}}),Object.defineProperty(e.prototype,"close",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._hungupHandle(e)}}),Object.defineProperty(e.prototype,"setHungupPushConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._hungupPushConfig=e}}),Object.defineProperty(e.prototype,"getCallId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callId}}),Object.defineProperty(e.prototype,"getChannelId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._channelId}}),Object.defineProperty(e.prototype,"getTargetId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._targetId}}),Object.defineProperty(e.prototype,"getConversationType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._conversationType}}),Object.defineProperty(e.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(e.prototype,"getRemoteUsers",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=[],t=this._context.getCurrentId();for(var n in this._userInfo){this._userInfo[n].userId!==t&&e.push(this._userInfo[n])}return e}}),Object.defineProperty(e.prototype,"getState",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null===this._sessionState?S.END:this._sessionState}}),Object.defineProperty(e.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(e.prototype,"getCallerId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callerId}}),Object.defineProperty(e.prototype,"getInviterId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._inviterId}}),Object.defineProperty(e.prototype,"getMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._mediaType}}),Object.defineProperty(e.prototype,"getSummary",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._beginTimestamp,t=this._endTimestamp,n=0;t>e&&0!==e&&(n=t-e);var r={conversationType:this._conversationType,channelId:this._channelId,targetId:this._targetId,mediaType:this._mediaType,beginTimestamp:e,endTimestamp:t,duration:n,endReason:this._endReason};return this._logger.debug("_","[RCCallStateMachine] getSummary -> summary: ".concat(JSON.stringify(r))),r}}),e}();!function(e){e[e.AUDIO=1]="AUDIO",e[e.AUDIO_VIDEO=2]="AUDIO_VIDEO"}(N||(N={})),function(e){e[e.ADD=1]="ADD",e[e.REMOVE=2]="REMOVE"}(A||(A={})),function(e){e.WEB="Web",e.IOS="iOS",e.ANDROID="Android"}(U||(U={}));var k,D,H=function(){function e(e,t,n){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_onRecord",{enumerable:!0,configurable:!0,writable:!0,value:n}),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,n=e.conversationType,r=e.targetId,i=e.senderUserId,o=e.content,s=o.callId,a=o.mediaType;this._channelId=t,this._conversationType=n,this._targetId=r,this._callId=s,this._mediaType=a;this._inviterId=i,this._endReason=E.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=E.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,n=e.sentTime,r=e.senderUserId,i=t.reason,o=r===this._context.getCurrentId();this._endReason=o?i:w[i],this._endTimestamp=n,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;[E.HANGUP,E.REMOTE_HANGUP,E.OTHER_CLIENT_JOINED_CALL,E.REMOTE_OTHER_CLIENT_JOINED_CALL,E.KICKED_BY_SERVER,E.REMOTE_KICKED_BY_SERVER,E.ACCEPT_SYSTEM_CALL,E.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(),n=t.messageType;switch(t.content.callId,n){case T.VCInvite:this._doInvite(t);break;case T.VCRinging:this._doRinging(t);break;case T.VCAccept:this._doAccept(t);break;case T.VCModifyMem:this._doMemberModify(t);break;case T.VCModifyMedia:this._doMediaModify(t);break;case T.VCHangup:this._doHungup(t);break;default:this._logger.debug("_","[OfflineRecorder] onRecvOfflineMsgs -> unexpected message: ".concat(JSON.stringify(t)))}}while(this._messages.length>0)}}),e}(),V=["RC:VCAccept","RC:VCRinging","RC:VCSummary","RC:VCHangup","RC:VCInvite","RC:VCModifyMedia","RC:VCModifyMem"],G=((k={})[n.REJECTED_BY_BLACKLIST]=R.REJECTED_BY_BLACKLIST,k[n.NOT_IN_GROUP]=R.NOT_IN_GROUP,k),x=function(e){function r(t,n,r,i,o){void 0===i&&(i=6e4);var s=e.call(this)||this;return Object.defineProperty(s,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(s,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(s,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(s,"_offlineMsgItv",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(s,"_getStateMachine",{enumerable:!0,configurable:!0,writable:!0,value:o}),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=O(n),s._context.onmessage=s._onMessage.bind(s),s._offlineRecorder=new H(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}_(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(r,e),Object.defineProperty(r.prototype,"_onMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(V.includes(e.messageType)){this._logger.debug("_","[CallMessageHandler] _onMessage -> call message: ".concat(JSON.stringify(e)));try{var t=Date.now(),n=e.sentTime,r=0;this._msgBufferList.forEach((function(e,t){var i=e.msg.sentTime;n>=i&&(r=t+1)})),this._msgBufferList.splice(r,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(r.prototype,"_onRecvOnlineCallMsg",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=t.content.callId;switch(this._logger.info("_","recv -> senderId: ".concat(t.senderUserId,", type: ").concat(t.messageType,", callId: ").concat(n)),t.messageType){case T.VCInvite:this._watchers.onInvite&&this._watchers.onInvite(t);break;case T.VCRinging:e.prototype.emit.call(this,"".concat(n,"onRinging"),t);break;case T.VCAccept:e.prototype.emit.call(this,"".concat(n,"onAccept"),t);break;case T.VCModifyMem:this._watchers.onInvite&&this._watchers.onInvite(t);break;case T.VCModifyMedia:e.prototype.emit.call(this,"".concat(n,"onMediaModify"),t);break;case T.VCHangup:e.prototype.emit.call(this,"".concat(n,"onHungup"),t);break;default:this._logger.warn("_","recv -> unexpected message: ".concat(t.messageType))}}}),Object.defineProperty(r.prototype,"_handleBufferMsgs",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;0===this._msgBufferList.length||this._hadHandleMsgTimer?this._logger.warn("_","_handleBufferMsgs return"):(this._hadHandleMsgTimer=!0,setTimeout((function(){var n=Date.now(),r=e._msgBufferList.filter((function(e){return n-e.markTime>=200}));if(e._logger.debug("_","[CallMessageHandler] handleBufferMsgs -> lists over 200ms : ".concat(JSON.stringify(r.map((function(e){var t=e.msg;return{messageUId:t.messageUId,isOffLineMessage:t.isOffLineMessage,callId:t.content.callId}}))))),0===r.length)return e._hadHandleMsgTimer=!1,void e._handleBufferMsgs();if(r[0].msg.isOffLineMessage){var i=e._msgBufferList.filter((function(e){return e.msg.isOffLineMessage})),o=function(){var n=i[0].msg,r=n.conversationType,o=n.messageType,s=n.sentTime,a=n.senderUserId,l=n.content,c=l.callId,u=l.inviteUserIds,d=[T.VCInvite,T.VCModifyMem].includes(o),_=e._context.getServerTime()-s,f=_<e._offlineMsgItv;if(f||e._logger.warn("_","offline msg delayTime: ".concat(_,"ms")),d){for(var h=[],g=0;g<i.length;g++){var C=i[g].msg;if(c!==C.content.callId)break;h.push(C)}if(e._logger.warn("_","taskMsgList length: ".concat(h.length)),h.length>0){var R=e._msgBufferList.findIndex((function(e){return e.msg.messageUId===h[h.length-1].messageUId}));e._msgBufferList=e._msgBufferList.slice(R+1);var I=i.findIndex((function(e){return e.msg.messageUId===h[h.length-1].messageUId}));i=i.slice(I+1)}var E=function(){if(r!==t.PRIVATE)return!1;var e=1===h.length,n=h.every((function(e){return[T.VCInvite,T.VCModifyMedia,T.VCRinging].includes(e.messageType)}));return e||n}(),m=function(){if(r!==t.GROUP)return!1;for(var n=!1,i=!0,o=b([a],p(u),!1),s=!1,l=function(t){var n=h[t],r=n.senderUserId,l=n.messageType;if(l===T.VCHangup&&r===e._context.getCurrentId())return"break";l===T.VCHangup&&(s=a===r,o=o.filter((function(e){return r!==e}))),l===T.VCAccept&&(i=!1)},c=0;c<h.length;c++){if("break"===l(c))break}return i&&s||!(o.length>1)||(n=!0),n}();f&&(E||m)&&h.forEach(e._onRecvOnlineCallMsg,e),e._offlineRecorder.onRecvOfflineMsgs(h)}else f&&e._getStateMachine(c)?e._onRecvOnlineCallMsg(i[0].msg):e._logger.debug("_","[CallMessageHandler] unexcepted offline msg -> ".concat(JSON.stringify(i[0].msg))),i.shift(),e._msgBufferList.shift()};do{o()}while(i.length>0)}else{r.forEach((function(t){var n=t.msg;e._onRecvOnlineCallMsg(n)}));var s=r.length;e._msgBufferList.splice(0,s),e._logger.debug("_","timer online msg handle -> delCount: ".concat(s," msgBufferList: ").concat(e._msgBufferList.length))}e._hadHandleMsgTimer=!1,e._handleBufferMsgs()}),20))}}),Object.defineProperty(r.prototype,"registerEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){Object.assign(this._watchers,e)}}),Object.defineProperty(r.prototype,"registerStateMachineEvent",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,r){var i=t+n;e.prototype.on.call(this,i,r)}}),Object.defineProperty(r.prototype,"unregisterStateMachineEvent",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this;["onRinging","onAccept","onHungup","onMediaModify"].forEach((function(r){var i=t+r;e.prototype.removeAll.call(n,i)}))}}),Object.defineProperty(r.prototype,"registerUserInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._userInfo=e}}),Object.defineProperty(r.prototype,"_sendCallMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return h(this,void 0,void 0,(function(){var t,r,i,o,s,a,l,c,u,d,_,f;return g(this,(function(h){switch(h.label){case 0:return this._logger.debug("_","CallMessageHandler] sendCallMesage -> message: ".concat(JSON.stringify(e))),t=e.channelId,r=e.conversationType,i=e.targetId,o=e.content,s=e.messageType,a=e.directionalUserIdList,l=e.pushConfig,c={channelId:t,messageType:s,content:o,directionalUserIdList:a},[T.VCInvite,T.VCModifyMem,T.VCHangup].includes(s)&&((u=l||{pushTitle:"",pushContent:"",pushData:""}).androidConfig=Object.assign((null==l?void 0:l.androidConfig)||{},{categoryHW:"VOIP",categoryVivo:"IM"}),u.iOSConfig=Object.assign(u.iOSConfig||{},{apnsCollapseId:o.callId}),u.disablePushTitle=!1,u.forceShowDetailContent=!1,c.pushConfig=u),[4,this._context.sendMessage(r,i,c)];case 1:return d=h.sent(),_=d.code,f=d.data,_!==n.SUCCESS?(this._logger.error("_","CallMessageHandler] sendCallMesage error -> code: ".concat(_)),[2,{code:G[_]||R.SEND_MSG_ERROR}]):[2,{code:R.SUCCESS,message:f}]}}))}))}}),Object.defineProperty(r.prototype,"sendInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return h(this,void 0,void 0,(function(){var n,r,i,o,s,a,l,c,u,d;return g(this,(function(_){return n=e.roomType,r=e.channelId,i=e.conversationType,o=e.targetId,s=e.callId,a=e.mediaType,l=e.inviteUserIds,c=e.extra,u=e.pushConfig,this._logger.warn("_","CallMessageHandler] sendCallMesage sendInvite",JSON.stringify(e)),this._watchers.sendAccept&&this._watchers.sendAccept({callId:s}),d={platform:U.WEB,deviceId:this._deviceId,callId:s,roomType:n,extra:c,engineType:4,channelInfo:{Id:s,Key:""},mediaType:a,inviteUserIds:l,observerUserIds:[],user:this._userInfo},u&&(u.pushData=JSON.stringify({mediaType:a,userIdList:l,callId:s})),[2,this._sendCallMessage({channelId:r,conversationType:i,targetId:o,content:d,messageType:T.VCInvite,directionalUserIdList:i===t.GROUP?l:void 0,pushConfig:u})]}))}))}}),Object.defineProperty(r.prototype,"sendMemeberModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,o,s,a,l,c,u,d,_;return g(this,(function(f){return t=e.channelId,n=e.conversationType,r=e.targetId,i=e.callId,o=e.mediaType,s=e.inviteUserIds,a=e.callerId,l=e.existedUserPofiles,c=e.directionalUserIdList,u=e.extra,d=e.pushConfig,_={platform:U.WEB,deviceId:this._deviceId,callId:i,extra:u,engineType:4,channelInfo:{Id:i,Key:""},mediaType:o,inviteUserIds:s,observerUserIds:[],user:this._userInfo,caller:a,modifyMemType:A.ADD,existedUserPofiles:l},d&&(d.pushData=JSON.stringify({mediaType:o,userIdList:s,callId:i})),[2,this._sendCallMessage({channelId:t,conversationType:n,targetId:r,content:_,messageType:T.VCModifyMem,directionalUserIdList:c,pushConfig:d})]}))}))}}),Object.defineProperty(r.prototype,"sendRinging",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n=e.channelId,r=e.conversationType,i=e.targetId,o=e.callId,s=e.userIds,a={platform:U.WEB,deviceId:this._deviceId,callId:o,user:this._userInfo};return this._sendCallMessage({channelId:n,conversationType:r,targetId:i,content:a,messageType:T.VCRinging,directionalUserIdList:r===t.GROUP?s:void 0})}}),Object.defineProperty(r.prototype,"sendAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n=e.channelId,r=e.conversationType,i=e.targetId,o=e.callId,s=e.mediaType,a=e.userIds,l={platform:U.WEB,deviceId:this._deviceId,callId:o,mediaType:s,user:this._userInfo};return this._sendCallMessage({channelId:n,conversationType:r,targetId:i,content:l,messageType:T.VCAccept,directionalUserIdList:r===t.GROUP?a:void 0})}}),Object.defineProperty(r.prototype,"sendHungup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n=e.channelId,r=e.conversationType,i=e.targetId,o=e.callId,s=e.reason,a=e.userIds,l=e.pushConfig,c={platform:U.WEB,deviceId:this._deviceId,callId:o,reason:s,user:this._userInfo};return l&&(l.pushData=JSON.stringify({callId:o,reason:s})),this._sendCallMessage({channelId:n,conversationType:r,targetId:i,content:c,messageType:T.VCHangup,pushConfig:l,directionalUserIdList:r===t.GROUP?a:void 0})}}),Object.defineProperty(r.prototype,"sendMediaModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n=e.channelId,r=e.conversationType,i=e.targetId,o=e.callId,s=e.mediaType,a=e.userIds,l={platform:U.WEB,deviceId:this._deviceId,callId:o,mediaType:s,user:this._userInfo};return this._sendCallMessage({channelId:n,conversationType:r,targetId:i,content:l,messageType:T.VCModifyMedia,directionalUserIdList:r===t.GROUP?a:void 0})}}),r}(e);!function(e){e.ZH="zh",e.EN="en"}(D||(D={}));var B,K={PushTitle:{AUDIO:"You have a voice call",VIDEO:"You have a video call"}},J={PushTitle:{AUDIO:"您有一条音频通话",VIDEO:"您有一条视频通话"}},W=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===D.EN?K:J}}),Object.defineProperty(e,"_lang",{enumerable:!0,configurable:!0,writable:!0,value:D.ZH}),e}(),Y=function(){function e(e,t,n,r,i){var o=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:n}),Object.defineProperty(this,"_watchers",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:i}),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.12"," CommitId: ").concat("8a43e2bc64278418f888658b54363c97d7bf7bc1")),O(t),this._callMsgHandler=new x(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}),v.on("onStateMachineClose",(function(e){delete o._stateMachine[e]})),W.set(i.lang)}return Object.defineProperty(e.prototype,"_onInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.channelId,n=e.conversationType,r=e.targetId,i=e.content,o=e.messageType,s=e.senderUserId;e.pushConfig;var a,l=i,c=l.mediaType,u=l.callId,d=l.extra;a=l.roomType!==P.RCCallRoomTypeAcrossCall?s:p(s.split("_"),2)[1];var _=this._context.getCurrentId();if(this._context.getCurrentId()!==a){if(o===T.VCModifyMem)if(i.existedUserPofiles.some((function(e){return e.userId===_}))&&!this._stateMachine[u])return;if(this._stateMachine[u])o===T.VCModifyMem&&this._stateMachine[u].__onMemberModify(e);else this._stateMachine[u]=new j(this._context,this._runtime,this._logger,this._callMsgHandler,t,n,r,c,u),this._logger.info("_","[RCCallEngine] RCCallStateMachine successfully created -> callId: ".concat(u)),o===T.VCInvite?this._stateMachine[u].__onInvite(e):o===T.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(e.prototype,"_handleSendAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this._options.isAllowAcceptNewCall){var t=e.callId;for(var n in this._stateMachine)t!==n&&(this._stateMachine[n].hungup(),delete this._stateMachine[n])}}}),Object.defineProperty(e.prototype,"_getStateMachine",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._stateMachine[e]}}),Object.defineProperty(e.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(e.prototype,"call",{enumerable:!1,configurable:!0,writable:!0,value:function(e,n,r,i,o,s){return void 0===i&&(i=""),void 0===s&&(s=!1),h(this,void 0,void 0,(function(){var a,l;return g(this,(function(c){switch(c.label){case 0:return this._logger.debug("_","[RCCallEngine] call -> args: ".concat(JSON.stringify({channelId:e,targetId:n,mediaType:r,extra:i,pushConfig:o}))),a=y(),Object.keys(this._stateMachine).length>0?[2,{code:R.STATE_MACHINE_EXIT}]:(this._stateMachine[a]=new j(this._context,this._runtime,this._logger,this._callMsgHandler,e,t.PRIVATE,n,r,a),[4,this._stateMachine[a].__call([n],i,o,s)]);case 1:return(l=c.sent().code)===R.SUCCESS?[2,{code:R.SUCCESS,stateMachine:this._stateMachine[a]}]:[2,{code:l}]}}))}))}}),Object.defineProperty(e.prototype,"callInGroup",{enumerable:!1,configurable:!0,writable:!0,value:function(e,n,r,i,o,s){return void 0===o&&(o=""),h(this,void 0,void 0,(function(){var a,l;return g(this,(function(c){switch(c.label){case 0:return this._logger.debug("_","[RCCallEngine] callInGroup -> args: ".concat(JSON.stringify({channelId:e,targetId:n,mediaType:r}))),a=y(),Object.keys(this._stateMachine).length>0?[2,{code:R.STATE_MACHINE_EXIT}]:(this._stateMachine[a]=new j(this._context,this._runtime,this._logger,this._callMsgHandler,e,t.GROUP,n,r,a),[4,this._stateMachine[a].__call(i,o,s)]);case 1:return(l=c.sent().code)===R.SUCCESS?[2,{code:R.SUCCESS,stateMachine:this._stateMachine[a]}]:[2,{code:l}]}}))}))}}),Object.defineProperty(e.prototype,"destroy",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._logger.debug("_","[RCCallEngine] destroy"),this._stateMachine={}}}),e}();!function(e){e[e.CALLER=1]="CALLER",e[e.CALLEE=2]="CALLEE"}(B||(B={}));var F=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 n=this,r=function(i){n.off(e,r),t.call(n,i)};r.fun=t,this.on(e,r)}}),Object.defineProperty(e.prototype,"off",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this.list[e];if(!n)return!1;if(t){for(var r=void 0,i=0,o=n.length;i<o;i++)if((r=n[i])===t||r.fun===t){n.splice(i,1);break}}else n&&(n.length=0)}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this,r=b([],p(this.list[e]),!1);if(!r||0===r.length)return!1;r.forEach((function(e){e.call(n,t)}))}}),e}());var z=function(e){if(!e)return{ok:!1,msg:"Initialization missing parameter -> options"};if("object"!=typeof e)return{ok:!1,msg:"Initialization options must be an object"};var t,n=Object.keys(e),r=[];return["rtcClient","onSession","onSessionClose"].forEach((function(e){n.includes(e)||r.push(e)})),r.length?{ok:!1,msg:'Initialization missing parameter -> "'.concat(r.join(","),'"')}:"object"!=typeof e.rtcClient?{ok:!1,msg:"Initialization 'rtcClient' parameter must be of type 'object'"}:"function"!=typeof e.onSession?{ok:!1,msg:"Initialization 'onSession' parameter must be of type 'function'"}:"function"!=typeof e.onSessionClose?{ok:!1,msg:"Initialization 'onSessionClose' parameter must be of type 'function'"}:void 0!==e.isAllowSubscribeRetry&&"boolean"!=typeof e.isAllowSubscribeRetry?{ok:!1,msg:"Initialization 'isAllowSubscribeRetry' parameter must be of type 'boolean'"}:void 0!==e.isAllowPublishRetry&&"boolean"!=typeof e.isAllowPublishRetry?{ok:!1,msg:"Initialization 'isAllowPublishRetry' parameter must be of type 'boolean'"}:void 0!==e.isOffCameraWhenVideoDisable&&"boolean"!=typeof e.isOffCameraWhenVideoDisable?{ok:!1,msg:"Initialization 'isOffCameraWhenVideoDisable' parameter must be of type 'boolean'"}:void 0===e.joinType||(t=e.joinType,Object.values(s).includes(t))?void 0!==e.isAllowDemotionGetStream&&"boolean"!=typeof e.isAllowDemotionGetStream?{ok:!1,msg:"Initialization 'isAllowDemotionGetStream' parameter must be of type 'boolean'"}:void 0===e.lang||function(e){return Object.values(D).includes(e)}(e.lang)?void 0===e.logOutputLevel||function(e){return[a.DEBUG,a.INFO,a.WARN,a.ERROR].includes(e)}(e.logOutputLevel)?{ok:!0}:{ok:!1,msg:"Initialization 'logOutputLevel' parameter must be of type correct type"}:{ok:!1,msg:"Initialization 'lang' parameter must be of type correct type"}:{ok:!1,msg:"Initialization 'joinType' parameter must be of type correct type"}},q=function(e){if(!e)return{ok:!1,msg:"missing parameter -> listener"};if("object"!=typeof e)return{ok:!1,msg:"listener must be an object"};var t=Object.keys(e),n=[];return["onRinging","onAccept","onHungup","onTrackReady"].forEach((function(e){t.includes(e)||n.push(e)})),n.length?{ok:!1,msg:'missing parameter -> "'.concat(n.join(","),'"')}:"function"!=typeof e.onRinging?{ok:!1,msg:"'onRinging' parameter must be of type 'function'"}:"function"!=typeof e.onAccept?{ok:!1,msg:"'onAccept' parameter must be of type 'function'"}:"function"!=typeof e.onHungup?{ok:!1,msg:"'onHungup' parameter must be of type 'function'"}:"function"!=typeof e.onTrackReady?{ok:!1,msg:"'onTrackReady' parameter must be of type 'function'"}:{ok:!0}},X=function(e){return e&&"string"==typeof e?{ok:!0}:{ok:!1,msg:"'targetId' parameter is required, must be of type 'string'"}},Z=function(e){return e===N.AUDIO||e===N.AUDIO_VIDEO?{ok:!0}:{ok:!1,msg:"'mediaType' parameter is required, must be of type 'RCCallMediaType'"}},Q=function(e){return"string"==typeof e?{ok:!0}:{ok:!1,msg:"'extra' parameter must be of type 'string'"}},$=function(e){var t=["pushTitle","pushContent","pushData","iOSConfig","androidConfig","disablePushTitle","templateId"],n=Object.keys(e).every((function(e){return t.includes(e)}));if(!n)return{code:R.PARAM_ERROR,errorMsg:"right key: ".concat(t.join(","))};for(var s=0;s<t.length;s++){var a=t[s];if("disablePushTitle"===a){if(!r(e[a])&&!i(e[a]))return{code:R.PARAM_ERROR,errorMsg:"".concat(a," type is boolean")}}else if(("pushTitle"===a||"templateId"===a)&&e[a]&&!o(e[a]))return{code:R.PARAM_ERROR,errorMsg:"".concat(a," type is string")}}var l=e.iOSConfig,c=e.androidConfig,u=ee(l||{});if(u.code!==R.SUCCESS)return u;var d=te(c||{});return d.code!==R.SUCCESS?d:{code:R.SUCCESS}},ee=function(e){var t=e||{},n=t.threadId,r=t.richMediaUri;return n&&!o(n)?{code:R.PARAM_ERROR,errorMsg:"iOSConfig.threadId type is string"}:r&&!o(r)?{code:R.PARAM_ERROR,errorMsg:"iOSConfig.richMediaUri type is string"}:{code:R.SUCCESS}},te=function(e){var t=["notificationId","channelIdMi","channelIdHW","categoryHW","importanceHW","imageUrlHW","channelIdOPPO","typeVivo","categoryVivo","fcmChannelId","fcmCollapseKey","fcmImageUrl","importanceHonor","imageUrlHonor"],n=Object.keys(e).every((function(e){return t.includes(e)}));if(!n)return{code:R.PARAM_ERROR,errorMsg:"right key: ".concat(t.join(","))};for(var r=0;r<t.length;r++){var i=t[r];if("importanceHW"===i||"importanceHonor"===i){if(e[i]&&"LOW"!==e[i]&&"NORMAL"!==e[i])return{code:R.PARAM_ERROR,errorMsg:"androidConfig.".concat(i," value is NORMAL|LOW")}}else if(e[i]&&!o(e[i]))return{code:R.PARAM_ERROR,errorMsg:"androidConfig.".concat(i," type is string")}}return{code:R.SUCCESS}},ne=function(e){return Array.isArray(e)&&e.length?e.every((function(e){return"string"==typeof e&&e.length>0}))?{ok:!0}:{ok:!1,msg:"'userIds' parameter is required"}:{ok:!1,msg:"'userIds' parameter is required, must be of type 'string[]'"}};var re=function(e){return e&&e.audio&&void 0!==e.audio.micphoneId&&"string"!=typeof e.audio.micphoneId?{ok:!1,msg:"'constraints.audio.micphoneId' must be of type 'string'"}:e&&e.audio&&void 0!==e.audio.sampleRate&&"number"!=typeof e.audio.sampleRate?{ok:!1,msg:"'constraints.audio.sampleRate' must be of type 'number'"}:e&&e.video&&void 0!==e.video.cameraId&&"string"!=typeof e.video.cameraId?{ok:!1,msg:"'constraints.video.cameraId' must be of type 'string'"}:e&&e.video&&void 0!==e.video.frameRate&&"string"!=typeof e.video.frameRate?{ok:!1,msg:"'constraints.video.frameRate' must be of type 'string'"}:e&&e.video&&void 0!==e.video.frameRate&&(t=e.video.frameRate,!["FPS_10","FPS_15","FPS_24","FPS_30"].includes(t))?{ok:!1,msg:"'frameRate' value is out of range"}:e&&e.video&&void 0!==e.video.resolution&&"string"!=typeof e.video.resolution?{ok:!1,msg:"'constraints.video.frameRate' must be of type 'string'"}:e&&e.video&&void 0!==e.video.resolution&&(n=e.video.resolution,!c[n])?{ok:!1,msg:"'resolution' value is out of range"}:!e||!e.video||e.video.frameRate&&e.video.resolution?{ok:!0}:{ok:!1,msg:"'resolution' and 'resolution' is required"};var t,n},ie=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}(),oe=function(){function e(e,t,n,r){void 0===r&&(r={});var i=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:n}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:r}),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,n=e.reason;i._logger.info("_","[RCCallSession onUserStateChange] userId->".concat(null==t?void 0:t.userId," state->").concat(null==t?void 0:t.state," reason->").concat(n))},onStateChange:function(e){return h(i,void 0,void 0,(function(){var t,n,r,i,o;return g(this,(function(s){switch(s.label){case 0:if(t=e.state,n=e.reason,this._logger.info("_","[RCCallSession onStateChange] : state->".concat(t," reason->").concat(n)),t!==S.KEEPING)return[3,5];r=this._stateMachine.getCallId(),this._logger.info("_","[RCCallSession onStateChange] roomId: ".concat(r)),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._joinRoom(r)];case 2:return s.sent(),[3,4];case 3:return i=s.sent(),this._exceptionClose(E.NETWORK_ERROR),this._logger.error("_","[RCCallSession onStateChange] joinRoom throw exception roomId -> ".concat(r)),console.error(i),[3,4];case 4:return[3,6];case 5:if(t===S.END){if(!this._room)return this._options.localTracks&&this._destroyTracks(this._options.localTracks),o=this._stateMachine.getSummary(),F.emit("sessionClose",{session:this,summaryInfo:o}),[2];this._options.localTracks&&this._destroyTracks(this._options.localTracks),this._logger.info("_","[RCCallSession onStateChange] localTracks destroyed"),this._leaveRoom(),this._room=null}s.label=6;case 6:return[2]}}))}))},onRinging:function(e){i._logger.info("_","[RCCallSession onRinging]sender: sender.userId -> ".concat(e.userId));try{i._listener.onRinging(e,i)}catch(e){i._logger.error("_","[RCCallSession onRinging] method exception -> onRinging"),console.error(e)}},onAccept:function(e){i._logger.info("_","[RCCallSession onAccept]sender: sender.userId -> ".concat(e.userId));try{i._listener.onAccept(e,i)}catch(e){i._logger.error("_","[RCCallSession onAccept] method exception -> onAccept"),console.error(e)}},onHungup:function(e,t){i._logger.info("_","[RCCallSession onHungup]sender: sender.userId -> ".concat(e.userId," reason->").concat(t));try{i._listener.onHungup(e,t,i)}catch(e){i._logger.error("_","[RCCallSession onHungup] method exception -> onHungup"),console.error(e)}},onMemberModify:function(e){var t=e.sender,n=e.invitedUsers;i._logger.info("_","[RCCallSession onMemberModify] sender.userId -> ".concat(t.userId));try{i._listener.onMemberModify(t,n,i)}catch(e){i._logger.error("_","[RCCallSession onMemberModify] method exception -> onMemberModify"),console.error(e)}},onMediaModify:function(e){var t=e.sender,n=e.mediaType;i._logger.info("_","[RCCallSession onMediaModify]sender: sender.userId -> ".concat(t.userId," mediaType: ").concat(n)),n===N.AUDIO&&i._setMediaTypeToAudio();try{i._listener.onMediaModify(t,n,i)}catch(e){i._logger.error("_","[RCCallSession onMediaModify] method exception -> onMediaModify"),console.error(e)}},crossAppkey:function(e){i._logger.info("_","[RCCallSession crossAppkey] 是否跨 appkey: ".concat(e)),i._options.isCrossAppkey=e}}),this._stateMachine.setHungupPushConfig(this._options.hungupPushConfig||{pushTitle:"",pushContent:""})}return Object.defineProperty(e.prototype,"_joinRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return h(this,void 0,void 0,(function(){var n,r,i,o,s,a,l,c=this;return g(this,(function(u){switch(u.label){case 0:return u.trys.push([0,7,,8]),this._options.isCrossAppkey?[4,this._rtcClient.joinCrossRTCRoom(e,this._options.joinType)]:[3,2];case 1:return n=u.sent(),[3,4];case 2:return[4,this._rtcClient.joinRTCRoom(e,this._options.joinType)];case 3:n=u.sent(),u.label=4;case 4:return r=n.code,i=n.userIds,o=n.room,r!==d.SUCCESS?(r===d.NOT_OPEN_VIDEO_AUDIO_SERVER&&this._exceptionClose(E.SERVICE_NOT_OPENED),r===d.SIGNAL_JOIN_RTC_ROOM_REFUSED?this._exceptionClose(E.OTHER_CLIENT_IN_CALL):this._exceptionClose(E.NETWORK_ERROR),this._logger.info("_","[RCCallClient _joinRoom] join room failed: roomId -> ".concat(e," RCRTCCode -> ").concat(r)),[2,{code:R.JOIN_ROOM_ERROR}]):(this._stateMachine.getConversationType()===t.GROUP&&this._stateMachine.userJoin([this._rtcClient.getCurrentId()]),this._stateMachine.getState()!==S.END?[3,6]:[4,this._rtcClient.leaveRoom(o)]);case 5:return u.sent(),this._room=null,[2,{code:R.SUCCESS}];case 6:return i.length<1&&(this.joinRoomTimer=new ie((function(){c._exceptionClose(E.REMOTE_NETWORK_ERROR)}),6e4)),this._room=o,[3,8];case 7:return s=u.sent(),this._exceptionClose(E.NETWORK_ERROR),this._logger.error("_","[RCCallSession _joinRoom] _rtcClient.joinRTCRoom throw exception roomId -> ".concat(e)),console.error(s),[2,{code:R.JOIN_ROOM_ERROR}];case 8:this._registerRoomEventListener(),this._registerReportListener(),u.label=9;case 9:return u.trys.push([9,11,,12]),[4,this._subscribeInRoomRemoteTrack()];case 10:return u.sent(),[3,12];case 11:return a=u.sent(),this._exceptionClose(E.SUBSCRIBE_ERROR),this._logger.error("_","[RCCallSession _joinRoom] _subscribeInRoomRemoteTrack Exception roomId -> ".concat(e)),console.error(a),[2,{code:R.JOIN_ROOM_ERROR}];case 12:return u.trys.push([12,14,,15]),[4,this._publish()];case 13:return u.sent(),[3,15];case 14:return l=u.sent(),this._exceptionClose(E.PUBLISH_ERROR),this._logger.error("_","[RCCallSession _joinRoom] _publish Exception roomId -> ".concat(e)),console.error(l),[2,{code:R.JOIN_ROOM_ERROR}];case 15:return[2,{code:R.SUCCESS}]}}))}))}}),Object.defineProperty(e.prototype,"_subscribeInRoomRemoteTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return h(this,void 0,void 0,(function(){var e,t;return g(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:(t=n.sent().code)!==d.SUCCESS&&(this._exceptionClose(E.SUBSCRIBE_ERROR),this._logger.error("_","[RCCallSession _subscribeInRoomRemoteTrack] Resource subscription failed roomId -> ".concat(this._stateMachine.getCallId()," RTC code -> ").concat(t))),n.label=2;case 2:return[2]}}))}))}}),Object.defineProperty(e.prototype,"_subscribeRetry",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){return void 0===t&&(t=!1),void 0===n&&(n=0),h(this,void 0,void 0,(function(){var r;return g(this,(function(i){switch(i.label){case 0:return[4,this._room.subscribe(e)];case 1:if((r=i.sent().code)!==d.SUCCESS){try{this._listener.onTrackSubscribeFail&&this._listener.onTrackSubscribeFail(r,this)}catch(e){this._logger.error("_","[RCCallSession] _listener.onTrackSubscribeFail exception"),console.error(e)}if(!t)return[2,{code:r}];if(n>0)return n--,[2,this._subscribeRetry(e,t,n)]}return[2,{code:r}]}}))}))}}),Object.defineProperty(e.prototype,"_publish",{enumerable:!1,configurable:!0,writable:!0,value:function(){return h(this,void 0,void 0,(function(){var e,t;return g(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(t=n.sent().code)!==d.SUCCESS?(this._exceptionClose(E.PUBLISH_ERROR),this._logger.info("_","[RCCallSession _publist] Resource publishing failed: roomId -> ".concat(this._stateMachine.getCallId()," RCRTCCode -> ").concat(t)),[2]):(this._options.produceType===B.CALLEE&&this._notifyTrackReady(e),[2])}}))}))}}),Object.defineProperty(e.prototype,"_publishRetry",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){return void 0===t&&(t=!1),void 0===n&&(n=0),h(this,void 0,void 0,(function(){var r;return g(this,(function(i){switch(i.label){case 0:return[4,this._room.publish(e)];case 1:if((r=i.sent().code)!==d.SUCCESS){try{this._listener.onTrackPublishFail&&this._listener.onTrackPublishFail(r,this)}catch(e){this._logger.error("_","[RCCallSession] _listener.onTrackPublishFail exception"),console.error(e)}if(!t)return[2,{code:r}];if(n>0)return n--,[2,this._publishRetry(e,t,n)]}return[2,{code:r}]}}))}))}}),Object.defineProperty(e.prototype,"_leaveRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(){return h(this,void 0,void 0,(function(){var e,t,n;return g(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,3,4]),[4,this._rtcClient.leaveRoom(this._room)];case 1:return e=r.sent(),this._logger.info("_","[RCCallSession _leaveRoom] Successfully exited the room code: ".concat(e.code)),[3,4];case 2:return t=r.sent(),this._logger.error("_","[RCCallSession _leaveRoom] leaveRoom throw exception"),console.error(t),[3,4];case 3:return n=this._stateMachine.getSummary(),F.emit("sessionClose",{session:this,summaryInfo:n}),[7];case 4:return[2]}}))}))}}),Object.defineProperty(e.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(e.prototype,"registerSessionListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=q(e);if(!t.ok)throw new Error("[RCCallSession registerSessionListener] ".concat(t.msg));this._listener=f({},e)}}),Object.defineProperty(e.prototype,"_getLocalTrackCore",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return h(this,void 0,void 0,(function(){var n,r,i,o,s,a;return g(this,(function(l){switch(l.label){case 0:return e!==N.AUDIO?[3,2]:[4,this._rtcClient.createMicrophoneAudioTrack("RongCloudRTC",t&&t.audio&&f({},t.audio))];case 1:return n=l.sent(),r=n.code,i=n.track,r!==d.SUCCESS?(this._logger.error("_","[RCCallSession _getLocalTrackCore] get Audio local tracks failed RCT code -> ".concat(r)),[2,{code:R.GET_LOCAL_AUDIO_TRACK_ERROR}]):(this._logger.info("_","[RCCallSession _getLocalTrackCore] successfully get Audio local tracks"),[2,{code:R.SUCCESS,tracks:[i]}]);case 2:return[4,this._rtcClient.createMicrophoneAndCameraTracks("RongCloudRTC",t&&f({},t))];case 3:return o=l.sent(),s=o.code,a=o.tracks,s!==d.SUCCESS?(this._logger.error("_","[RCCallSession _getLocalTrackCore] get Audio and Video local tracks failed RCT code -> ".concat(s)),[2,{code:R.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR}]):(this._logger.info("_","[RCCallSession _getLocalTrackCore] successfully get audio and video local tracks"),[2,{code:R.SUCCESS,tracks:a}])}}))}))}}),Object.defineProperty(e.prototype,"_getLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return h(this,void 0,void 0,(function(){var n,r,i,o,s,a,l,c,u;return g(this,(function(d){switch(d.label){case 0:return this._options.isAllowDemotionGetStream&&e===N.AUDIO_VIDEO?[4,this._getLocalTrackCore(N.AUDIO_VIDEO,t)]:[3,4];case 1:return n=d.sent(),r=n.code,i=n.tracks,r===R.SUCCESS?[3,3]:[4,this._getLocalTrackCore(N.AUDIO,t)];case 2:return o=d.sent(),s=o.code,a=o.tracks,s!==R.SUCCESS?(this._exceptionClose(E.GET_MEDIA_RESOURCES_ERROR),[2,{code:s}]):[2,{code:s,tracks:a}];case 3:return[2,{code:r,tracks:i}];case 4:return[4,this._getLocalTrackCore(e,t)];case 5:return l=d.sent(),c=l.code,u=l.tracks,c!==R.SUCCESS?(this._exceptionClose(E.GET_MEDIA_RESOURCES_ERROR),[2,{code:c}]):[2,{code:c,tracks:u}]}}))}))}}),Object.defineProperty(e.prototype,"changeAudioDevice",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,o;return g(this,(function(s){switch(s.label){case 0:return t=[],n=[],[4,this._rtcClient.createMicrophoneAudioTrack("RongCloudRTC",e)];case 1:return r=s.sent(),i=r.code,o=r.track,i!==d.SUCCESS?(this._logger.error("_","[RCCallSession changeDevice] get local Audio tracks failed RCTLib code -> ".concat(i)),[2,{code:R.GET_LOCAL_AUDIO_TRACK_ERROR}]):(this._options.localTracks&&this._options.localTracks.forEach((function(e){e.isAudioTrack()||n.push(e)})),t.push(o),n.push(o),this._options.localTracks=n,this._notifyTrackReady(t),this._room?[4,this._room.publish(t)]:[3,3]);case 2:if(s.sent().code!==d.SUCCESS)return[2,{code:R.AUDIO_PUBLISH_ERROR}];s.label=3;case 3:return[2,{code:R.SUCCESS}]}}))}))}}),Object.defineProperty(e.prototype,"invite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===t&&(t={}),h(this,void 0,void 0,(function(){var n,r,i,o,s,a,l,c;return g(this,(function(u){switch(u.label){case 0:if(n=t.extra,r=void 0===n?"":n,i=this._options.callPushConfig?this._options.callPushConfig:t.pushConfig,o=[ne(e),Q(r)],i&&(s=$(i),a=s.code,l=s.errorMsg,a!==R.SUCCESS))return this._logger.error("_","[RCCallSession invite] param error, errorMsg: ".concat(l)),[2,{code:a}];if(c=[],!o.every((function(e){return!e.ok&&c.push(e.msg),e.ok})))throw new Error("[RCCallClient invite] ".concat(c.join("\n")));return[4,this._stateMachine.invite(e,{extra:r,pushConfig:i})];case 1:return[2,{code:u.sent().code}]}}))}))}}),Object.defineProperty(e.prototype,"accept",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return h(this,void 0,void 0,(function(){var t,n,r,i,o,s;return g(this,(function(a){switch(a.label){case 0:if(!(t=re(e)).ok)throw new Error("[RCCallSession accept] ".concat(t.msg));return F.emit("hungupOtherSession",{session:this}),n=this._stateMachine.getMediaType(),[4,this._getLocalTrack(n,e)];case 1:return r=a.sent(),i=r.code,o=r.tracks,i!==R.SUCCESS?[2,{code:i}]:this._stateMachine.getState()===S.END?(this._destroyTracks(o),[2,{code:R.SESSION_ENDED}]):(this._options.localTracks=o,[4,this._stateMachine.accept()]);case 2:return s=a.sent().code,this._stateMachine.getState()===S.END?(this._destroyTracks(o),[2,{code:R.SESSION_ENDED}]):s!==R.SUCCESS?(this._logger.error("_","[RCCallSession accept]Send accept message failed -> code: ".concat(s)),[2,{code:s}]):[2,{code:s}]}}))}))}}),Object.defineProperty(e.prototype,"hungup",{enumerable:!1,configurable:!0,writable:!0,value:function(){return h(this,void 0,void 0,(function(){return g(this,(function(e){return[2,this._stateMachine.hungup()]}))}))}}),Object.defineProperty(e.prototype,"_changeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return h(this,void 0,void 0,(function(){var t;return g(this,(function(n){switch(n.label){case 0:return[4,this._stateMachine.changeMediaType(e)];case 1:return(t=n.sent().code)!==R.SUCCESS&&this._logger.error("_","[RCCallSession _changeMediaType] change media type fail code-> ".concat(t)),[2,{code:t}]}}))}))}}),Object.defineProperty(e.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(e.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(e.prototype,"_setMediaTypeToAudioAndVideo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return h(this,void 0,void 0,(function(){var e,t,n;return g(this,(function(r){switch(r.label){case 0:return[4,this._rtcClient.createCameraVideoTrack()];case 1:return e=r.sent(),t=e.code,n=e.track,t!==d.SUCCESS?[2,{code:R.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR}]:[4,this._room.publish([n])];case 2:return r.sent().code!==d.SUCCESS?(this._logger.error("_","[RCCallSession _enableVideo] Resource publishing failed: RCRTCCode -> ".concat(t)),[2]):(this._notifyTrackReady([n]),this._changeMediaType(N.AUDIO_VIDEO),[2])}}))}))}}),Object.defineProperty(e.prototype,"_setMediaTypeToAudio",{enumerable:!1,configurable:!0,writable:!0,value:function(){return h(this,void 0,void 0,(function(){var e,t;return g(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:(t=n.sent().code)!==d.SUCCESS&&this._logger.error("_","[RCCallSession disableVideo] unpublish failed -> ".concat(t)),this._destroyTracks(e),n.label=2;case 2:return[2]}}))}))}}),Object.defineProperty(e.prototype,"descendAbility",{enumerable:!1,configurable:!0,writable:!0,value:function(){return h(this,void 0,void 0,(function(){var e;return g(this,(function(t){switch(t.label){case 0:return[4,this._changeMediaType(N.AUDIO)];case 1:return(e=t.sent().code)===R.SUCCESS&&this._setMediaTypeToAudio(),[2,{code:e}]}}))}))}}),Object.defineProperty(e.prototype,"disableVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return h(this,void 0,void 0,(function(){var e,t;return g(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:R.SUCCESS}]):(this._logger.error("_","[RCCallSession disableVideoTrack] Room missing video track -> ".concat(R.MISSING_VIDEO_TRACK_ERROR)),[2,{code:R.MISSING_VIDEO_TRACK_ERROR}]):(this._logger.error("_","[RCCallSession disableVideoTrack] Not in room"),[2,{code:R.NOT_IN_ROOM_ERROR}]);case 1:return(t=n.sent().code)!==d.SUCCESS?(this._logger.error("_","[RCCallSession disableVideo] unpublish failed -> ".concat(t)),[2,{code:R.UNPUBLISH_VIDEO_ERROR}]):(e.forEach((function(e){e.destroy()})),[2,{code:R.SUCCESS}])}}))}))}}),Object.defineProperty(e.prototype,"enableVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return h(this,void 0,void 0,(function(){var e,t,n,r,i;return g(this,(function(o){switch(o.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:R.SUCCESS}]):(this._logger.error("_","[RCCallSession enableVideoTrack] Room missing video track -> ".concat(R.MISSING_VIDEO_TRACK_ERROR)),[2,{code:R.MISSING_VIDEO_TRACK_ERROR}]):(this._logger.error("_","[RCCallSession enableVideoTrack] Not in room -> ".concat(R.NOT_IN_ROOM_ERROR)),[2,{code:R.NOT_IN_ROOM_ERROR}]);case 1:return t=o.sent(),n=t.code,r=t.track,n!==d.SUCCESS?(this._logger.error("_","[RCCallSession EnableVideoTrack] Get Resource failed: RCRTCCode -> ".concat(n)),[2,{code:R.GET_LOCAL_VIDEO_TRACK_ERROR}]):(i=[],this._options.localTracks&&this._options.localTracks.forEach((function(e){e.isVideoTrack()?e.destroy():i.push(e)})),i.push(r),this._options.localTracks=i,r.mute(),[4,this._room.publish([r])]);case 2:return o.sent().code!==d.SUCCESS?(this._logger.error("_","[RCCallSession EnableVideoTrack] Resource publishing failed: RCRTCCode -> ".concat(n)),[2,{code:R.VIDEO_PUBLISH_ERROR}]):(r.unmute(),this._notifyTrackReady([r]),[2,{code:R.SUCCESS}])}}))}))}}),Object.defineProperty(e.prototype,"disableAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return h(this,void 0,void 0,(function(){var e,t;return g(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(R.MISSING_AUDIO_TRACK_ERROR)),[2,{code:R.MISSING_AUDIO_TRACK_ERROR}]):(this._logger.warn("_","[RCCallSession disableAudioTrack] Not in room -> ".concat(R.NOT_IN_ROOM_ERROR)),[2,{code:R.NOT_IN_ROOM_ERROR}]);case 1:return(t=n.sent())!==d.SUCCESS&&this._logger.warn("_","[RCCallSession disableAudioTrack] mute failed -> ".concat(t)),[2,{code:t}]}}))}))}}),Object.defineProperty(e.prototype,"enableAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return h(this,void 0,void 0,(function(){var e,t;return g(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(R.MISSING_AUDIO_TRACK_ERROR)),[2,{code:R.MISSING_VIDEO_TRACK_ERROR}]):(this._logger.error("_","[RCCallSession enableAudioTrack] Not in room -> ".concat(R.NOT_IN_ROOM_ERROR)),[2,{code:R.NOT_IN_ROOM_ERROR}]);case 1:return(t=n.sent())!==d.SUCCESS&&this._logger.error("_","[RCCallSession enableAudioTrack] unmute failed -> ".concat(t)),[2,{code:t}]}}))}))}}),Object.defineProperty(e.prototype,"_destroyTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){e.forEach((function(e){e.destroy()}))}}),Object.defineProperty(e.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(e.prototype,"_registerRoomEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this._room.registerRoomEventListener({onKickOff:function(t,n){var r=e._rtcClient.getCurrentId();e._stateMachine.userLeave([r]),t?(n===u.SERVER_KICK&&e._exceptionClose(E.KICKED_BY_SERVER),n===u.OTHER_KICK&&e._exceptionClose(E.OTHER_CLIENT_JOINED_CALL)):e._exceptionClose(E.NETWORK_ERROR)},onMessageReceive:function(e,t,n,r){},onRoomAttributeChange:function(e,t){},onAudioMuteChange:function(t){e._logger.info("_","[RCCallSession onAudioMuteChange] userId->".concat(t.getUserId()," muted -> ").concat(t.isOwnerMuted()));var n={userId:t.getUserId(),muted:t.isOwnerMuted(),kind:"audio",trackId:t.getTrackId()};try{e._listener.onAudioMuteChange(n,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 n={userId:t.getUserId(),muted:t.isOwnerMuted(),kind:"video",trackId:t.getTrackId()};try{e._listener.onVideoMuteChange(n,e)}catch(t){e._logger.error("_","[RCCallSession onVideoMuteChange] Missing listening method -> onVideoMuteChange"),console.error(t)}},onTrackPublish:function(t){return h(e,void 0,void 0,(function(){var e;return g(this,(function(n){switch(n.label){case 0:return this._room?[4,this._room.subscribe(t)]:[3,2];case 1:(e=n.sent().code)!==d.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()===N.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)},onUserOffline:function(t){e._logger.info("_","[RCCallSession onUserOffline] listening onUserOffline userIds -> ".concat(null==t?void 0:t.join(","))),e._stateMachine.userOffline(t)},onPing:function(t){var n,r;try{null===(r=null===(n=e._listener)||void 0===n?void 0:n.onPing)||void 0===r||r.call(n,t,e)}catch(e){console.error(e)}}})}}),Object.defineProperty(e.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 n,r;try{null===(r=null===(n=e._listener)||void 0===n?void 0:n.onICEConnectionStateChange)||void 0===r||r.call(n,t,e)}catch(t){e._logger.error("_","[RCCallSession onICEConnectionStateChange] onICEConnectionStateChange exception"),console.error(t)}}})}}),Object.defineProperty(e.prototype,"getSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getCallId()}}),Object.defineProperty(e.prototype,"getRTCSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._room?this._room.getSessionId():null}}),Object.defineProperty(e.prototype,"getTargetId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getTargetId()}}),Object.defineProperty(e.prototype,"getConversationType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getConversationType()}}),Object.defineProperty(e.prototype,"getChannelId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getChannelId()}}),Object.defineProperty(e.prototype,"getRemoteUsers",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getRemoteUsers()}}),Object.defineProperty(e.prototype,"getUsers",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getRemoteUsers()}}),Object.defineProperty(e.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(e.prototype,"getState",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getState()}}),Object.defineProperty(e.prototype,"getCallerId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getCallerId()}}),Object.defineProperty(e.prototype,"getMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getMediaType()}}),e}(),se=function(){function e(e,t,n,r){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:n}),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=r.rtcClient,this._options=f({isAllowPublishRetry:!1,isAllowSubscribeRetry:!1,isOffCameraWhenVideoDisable:!0,joinType:s.COEXIST,isAllowDemotionGetStream:!1,lang:D.ZH},r),this._callEngine=new Y(this._context,t,this._logger,{onInvite:this._onInvite.bind(this),onOfflineRecord:this._onOfflineRecord.bind(this)},{lang:this._options.lang||D.ZH}),F.on("sessionClose",(function(e){var t=e.session,n=e.summaryInfo;i._removeSession(t);try{i._options.onSessionClose(t,n)}catch(e){i._logger.error("_","[RCCCallClient] options.onSessionClose exception"),console.log(e)}})),F.on("hungupOtherSession",(function(e){var t=e.session.getSessionId();i._logger.info("_","[RCCallClient hungupOtherSession] sessionId ready to accept -> ".concat(t)),i._logger.info("_","[RCCallClient hungupOtherSession] sessionList ->".concat(i._sessionList.map((function(e){return e.getSessionId()})).join(",")));for(var n=0;i._sessionList.length>1;)i._sessionList[n].getSessionId()!==t?(i._sessionList[n].hungup(),i._sessionList.splice(n,1)):n++;i._logger.info("_","[RCCallClient hungupOtherSession] current sessionList length ->".concat(i._sessionList.length))}))}return Object.defineProperty(e.prototype,"_onInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info("_","[RCCallClient _onInvite] Received invite message");var n=new oe(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:B.CALLEE,callPushConfig:this._callPushConfig,hungupPushConfig:this._hungupPushConfig});this._logger.info("_","[RCCallClient _onInvite] Received invite message, successfully created session"),this._sessionList.push(n);try{this._options.onSession(n,t)}catch(e){this._logger.error("_","[RCCallClient _options.onSession] onSession exception"),console.log(e)}if(!n._listener)throw this._logger.error("_","[RCCallClient _options.onSession] session Must Have Listener"),new Error("[RCCallSession _options.onSession] session Must Have Listener");var r=q(n._listener);if(!r.ok)throw new Error(r.msg)}}),Object.defineProperty(e.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(e.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(e.prototype,"startCrossCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.targetId,n=e.mediaType,r=void 0===n?N.AUDIO:n,i=e.listener,o=e.constraints,s=e.channelId,a=void 0===s?"":s,l=e.extra,c=void 0===l?"":l,u=e.pushTitle,d=void 0===u?"":u,_=e.pushContent,f=void 0===_?"":_,p=e.bitrate;return h(this,void 0,void 0,(function(){return g(this,(function(e){return[2,this.__call({targetId:t,mediaType:r,listener:i,constraints:o,channelId:a,extra:c,pushTitle:d,pushContent:f,bitrate:p,isCrossAppkey:!0})]}))}))}}),Object.defineProperty(e.prototype,"call",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.targetId,n=e.mediaType,r=void 0===n?N.AUDIO:n,i=e.listener,o=e.constraints,s=e.channelId,a=void 0===s?"":s,l=e.extra,c=void 0===l?"":l,u=e.pushTitle,d=void 0===u?"":u,_=e.pushContent,f=void 0===_?"":_,p=e.bitrate;return h(this,void 0,void 0,(function(){return g(this,(function(e){return[2,this.__call({targetId:t,mediaType:r,listener:i,constraints:o,channelId:a,extra:c,pushTitle:d,pushContent:f,bitrate:p})]}))}))}}),Object.defineProperty(e.prototype,"__call",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.targetId,n=e.mediaType,r=void 0===n?N.AUDIO:n,i=e.listener,o=e.constraints,s=e.channelId,a=void 0===s?"":s,l=e.extra,c=void 0===l?"":l,u=e.pushTitle,d=void 0===u?"":u,_=e.pushContent,f=void 0===_?"":_,p=e.bitrate,b=e.isCrossAppkey,C=void 0!==b&&b;return h(this,void 0,void 0,(function(){var e,n,s,l,u,_,h,b,I,E,m,y,v,O;return g(this,(function(g){switch(g.label){case 0:return e=this._callPushConfig?this._callPushConfig:{pushTitle:d,pushContent:f},this._logger.info("_","[RCCallClient call] targetId: ".concat(t,", mediaType: ").concat(r)),t===this._context.getCurrentId()?(this._logger.error("_","[RCCallClient call] targetId is equal to currentId"),[2,{code:R.PARAM_ERROR}]):(n=[X(t),Z(r),q(i),Q(c)],s=[],n.every((function(e){return!e.ok&&s.push(e.msg),e.ok}))?(l=$(e),u=l.code,_=l.errorMsg,u!==R.SUCCESS?(this._logger.error("_","[RCCallClient call] param error, errorMsg: ".concat(_)),[2,{code:u}]):(h=[],[4,this._getLocalTrack(r,o)])):(console.error(s.join("\n")),[2,{code:R.PARAM_ERROR}]));case 1:return b=g.sent(),I=b.code,E=b.tracks,I!==R.SUCCESS?[2,{code:I}]:((h=E).forEach((function(e){var t,n,r;e.isAudioTrack()&&(null==p?void 0:p.audio)&&e.setBitrate(null==p?void 0:p.audio),e.isVideoTrack()&&(null==p?void 0:p.video)&&e.setBitrate(null===(t=null==p?void 0:p.video)||void 0===t?void 0:t.max,null===(n=null==p?void 0:p.video)||void 0===n?void 0:n.min,null===(r=null==p?void 0:p.video)||void 0===r?void 0:r.start),i.onTrackReady(e)})),[4,this._callEngine.call(a,t,r,c,e,C)]);case 2:return m=g.sent(),y=m.code,v=m.stateMachine,y===R.SUCCESS&&v?(this._logger.info("_","[RCCallClient call] successfully created state machine"),(O=new oe(v,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:B.CALLER,isCrossAppkey:C,callPushConfig:this._callPushConfig,hungupPushConfig:this._hungupPushConfig})).registerSessionListener(i),this._sessionList.push(O),this._logger.info("_","[RCCallClient call] successfully created session object, sessionId: ".concat(O.getSessionId())),[2,{code:y,session:O}]):(this._logger.error("_","[RCCallClient call] call failed code ->: ".concat(y)),h.forEach((function(e){e.mute(),e.destroy()})),[2,{code:y}])}}))}))}}),Object.defineProperty(e.prototype,"callInGroup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.targetId,n=e.userIds,r=e.mediaType,i=void 0===r?N.AUDIO:r,o=e.listener,s=e.constraints,a=e.channelId,l=void 0===a?"":a,c=e.extra,u=void 0===c?"":c,d=e.pushTitle,_=void 0===d?"":d,f=e.pushContent,p=void 0===f?"":f,b=e.bitrate;return h(this,void 0,void 0,(function(){var e,r,a,c,d,f,h,C,I,E,m,y,v,O,T;return g(this,(function(g){switch(g.label){case 0:return e=this._callPushConfig?this._callPushConfig:{pushTitle:_,pushContent:p},r=[X(t),ne(n),Z(i),q(o),Q(u)],a=[],c=r.every((function(e){return!e.ok&&a.push(e.msg),e.ok})),n.includes(this._context.getCurrentId())?(console.error("[RCCallClient callInGroup] userIds includes currentId"),[2,{code:R.PARAM_ERROR}]):c?(d=$(e),f=d.code,h=d.errorMsg,f!==R.SUCCESS?(this._logger.error("_","[RCCallClient call] param error, errorMsg: ".concat(h)),[2,{code:f}]):(C=[],[4,this._getLocalTrack(i,s)])):(console.error("[RCCallClient callInGroup] ".concat(a.join("\n"))),[2,{code:R.PARAM_ERROR}]);case 1:return I=g.sent(),E=I.code,m=I.tracks,E!==R.SUCCESS?[2,{code:E}]:((C=m).forEach((function(e){var t,n,r;e.isAudioTrack()&&(null==b?void 0:b.audio)&&e.setBitrate(null==b?void 0:b.audio),e.isVideoTrack()&&(null==b?void 0:b.video)&&e.setBitrate(null===(t=null==b?void 0:b.video)||void 0===t?void 0:t.max,null===(n=null==b?void 0:b.video)||void 0===n?void 0:n.min,null===(r=null==b?void 0:b.video)||void 0===r?void 0:r.start),o.onTrackReady(e)})),[4,this._callEngine.callInGroup(l,t,i,n,u,e)]);case 2:return y=g.sent(),v=y.code,O=y.stateMachine,v===R.SUCCESS&&O?(this._logger.info("_","[RCCallClient callInGroup] successfully created state machine"),(T=new oe(O,this._rtcClient,this._logger,{localTracks:C,isAllowSubscribeRetry:this._options.isAllowSubscribeRetry,isAllowPublishRetry:this._options.isAllowPublishRetry,isOffCameraWhenVideoDisable:this._options.isOffCameraWhenVideoDisable,joinType:this._options.joinType,isAllowDemotionGetStream:this._options.isAllowDemotionGetStream,produceType:B.CALLER,callPushConfig:this._callPushConfig,hungupPushConfig:this._hungupPushConfig})).registerSessionListener(o),this._sessionList.push(T),this._logger.info("_","[RCCallClient callInGroup] successfully created session object, sessionId: ".concat(T.getSessionId())),[2,{code:v,session:T}]):(this._logger.info("_","[RCCallClient callInGroup] callInGroup failed code -> ".concat(v)),C.forEach((function(e){e.mute(),e.destroy()})),[2,{code:v}])}}))}))}}),Object.defineProperty(e.prototype,"_getLocalTrackCore",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return h(this,void 0,void 0,(function(){var n,r,i,o,s,a;return g(this,(function(l){switch(l.label){case 0:return e!==N.AUDIO?[3,2]:[4,this._rtcClient.createMicrophoneAudioTrack("RongCloudRTC",t&&t.audio&&f({},t.audio))];case 1:return n=l.sent(),r=n.code,i=n.track,r!==d.SUCCESS?(this._logger.error("_","[RCCallClient _getTrack] get Audio local tracks failed RCT code -> ".concat(r)),[2,{code:R.GET_LOCAL_AUDIO_TRACK_ERROR}]):(this._logger.info("_","[RCCallClient _getTrack] successfully get Audio local tracks"),[2,{code:R.SUCCESS,tracks:[i]}]);case 2:return[4,this._rtcClient.createMicrophoneAndCameraTracks("RongCloudRTC",t&&f({},t))];case 3:return o=l.sent(),s=o.code,a=o.tracks,s!==d.SUCCESS?(this._logger.error("_","[RCCallClient _getTrack] get Audio and Video local tracks failed RCT code -> ".concat(s)),[2,{code:R.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR}]):(this._logger.info("_","[RCCallClient _getTrack] successfully get audio and video local tracks"),[2,{code:R.SUCCESS,tracks:a}])}}))}))}}),Object.defineProperty(e.prototype,"_getLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return h(this,void 0,void 0,(function(){var n,r,i,o,s,a,l,c,u;return g(this,(function(d){switch(d.label){case 0:return this._options.isAllowDemotionGetStream&&e===N.AUDIO_VIDEO?[4,this._getLocalTrackCore(N.AUDIO_VIDEO,t)]:[3,4];case 1:return n=d.sent(),r=n.code,i=n.tracks,r===R.SUCCESS?[3,3]:[4,this._getLocalTrackCore(N.AUDIO,t)];case 2:return o=d.sent(),s=o.code,a=o.tracks,s!==R.SUCCESS?[2,{code:s}]:[2,{code:s,tracks:a}];case 3:return[2,{code:r,tracks:i}];case 4:return[4,this._getLocalTrackCore(e,t)];case 5:return l=d.sent(),c=l.code,u=l.tracks,c!==R.SUCCESS?[2,{code:c}]:[2,{code:c,tracks:u}]}}))}))}}),Object.defineProperty(e.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(e.prototype,"getJoinedRoomInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return h(this,void 0,void 0,(function(){var e,t,r;return g(this,(function(i){switch(i.label){case 0:return[4,this._context.getRTCJoinedUserInfo(this._context.getCurrentId())];case 1:return e=i.sent(),t=e.code,r=e.data,t!==n.SUCCESS?(this._logger.error("_","getJoinedUserInfo error code: ".concat(t)),[2,{code:R.QUERY_JOINED_USER_INFO_ERROR}]):[2,{code:R.SUCCESS,data:r}]}}))}))}}),Object.defineProperty(e.prototype,"setPushConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n,r,i=[e,t].map((function(e){return $(e)}));try{for(var o=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(i),s=o.next();!s.done;s=o.next()){var a=s.value,l=a.code,c=a.errorMsg;if(l!==R.SUCCESS)return this._logger.error("_","[RCCallClient setPushConfig] param error, errorMsg: ".concat(c)),{code:l}}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}this._callPushConfig=e,this._hungupPushConfig=t}}),e}();l.add("calllib","5.2.12");var ae={tag:"RCCall",verify:function(e){return"browser"===e.tag},setup:function(e,t,n){var r=z(n);if(!r.ok)throw new Error("[RCCallLib installer steup]".concat(r.msg));if(!l.validEngine("5.9.0"))throw new Error("The current engine version '".concat(l.getInfo().engine,"' error, plugin-call required engine version at least '").concat("5.9.0","'."));var i=e.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.12",", Commit: ").concat("8a43e2bc64278418f888658b54363c97d7bf7bc1")),new se(e,t,i,n)}};export{se as RCCallClient,E as RCCallEndReason,R as RCCallErrorCode,D as RCCallLanguage,N as RCCallMediaType,oe as RCCallSession,S as RCCallSessionState,M as RCCallUserState,ae as installer};
|
package/package.json
CHANGED
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"license": "LGPL 2.1",
|
|
27
27
|
"description": "@rongcloud/plugin-call",
|
|
28
28
|
"homepage": "https://www.rongcloud.cn",
|
|
29
|
-
"version": "5.2.
|
|
29
|
+
"version": "5.2.12",
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@rongcloud/engine": "^5.9.0",
|
|
32
|
-
"@rongcloud/plugin-rtc": "^5.
|
|
32
|
+
"@rongcloud/plugin-rtc": "^5.7.4"
|
|
33
33
|
}
|
|
34
34
|
}
|