goeasy-rtc 0.4.2 → 0.5.0
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/goeasy-rtc.esm.min.js +1 -1
- package/package.json +1 -1
package/goeasy-rtc.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e,t,i,s){return new(i||(i=Promise))((function(n,o){function r(e){try{c(s.next(e))}catch(e){o(e)}}function a(e){try{c(s.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}c((s=s.apply(e,t||[])).next())}))}var t;"function"==typeof SuppressedError&&SuppressedError,function(e){e.RTC_LOST="RTC_LOST",e.RTC_RECONNECT="RTC_RECONNECT",e.RTC_TIMEOUT="RTC_TIMEOUT",e.RTC_ACCEPTED="RTC_ACCEPTED",e.RECEIVED_RTC_REMOTE_FLOW="RECEIVED_RTC_REMOTE_FLOW",e.GOEASY_TIMEOUT="GOEASY_TIMEOUT",e.GOEASY_DISCONNECTED="GOEASY_DISCONNECTED",e.RTC_REMOTE_MIC_CHANGED="RTC_REMOTE_MIC_CHANGED",e.RTC_REMOTE_CAMERA_CHANGED="RTC_REMOTE_CAMERA_CHANGED"}(t||(t={}));var i={exports:{}};!function(e){function t(e){if(e)return function(e){for(var i in t.prototype)e[i]=t.prototype[i];return e}(e)}i.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function i(){this.off(e,i),t.apply(this,arguments)}return i.fn=t,this.on(e,i),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var i,s=this._callbacks["$"+e];if(!s)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var n=0;n<s.length;n++)if((i=s[n])===t||i.fn===t){s.splice(n,1);break}return this},t.prototype.emit=function(e){this._callbacks=this._callbacks||{};var t=[].slice.call(arguments,1),i=this._callbacks["$"+e];if(i)for(var s=0,n=(i=i.slice(0)).length;s<n;++s)i[s].apply(this,t);return this},t.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},t.prototype.hasListeners=function(e){return!!this.listeners(e).length}}();var s=i.exports,n={exports:{}},o="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(o){var r=new Uint8Array(16);n.exports=function(){return o(r),r}}else{var a=new Array(16);n.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),a[t]=e>>>((3&t)<<3)&255;return a}}for(var c=[],l=0;l<256;++l)c[l]=(l+256).toString(16).substr(1);var d,u,h=function(e,t){var i=t||0,s=c;return[s[e[i++]],s[e[i++]],s[e[i++]],s[e[i++]],"-",s[e[i++]],s[e[i++]],"-",s[e[i++]],s[e[i++]],"-",s[e[i++]],s[e[i++]],"-",s[e[i++]],s[e[i++]],s[e[i++]],s[e[i++]],s[e[i++]],s[e[i++]]].join("")},C=n.exports,T=h,m=0,E=0;var p=function(e,t,i){var s=t&&i||0,n=t||[],o=(e=e||{}).node||d,r=void 0!==e.clockseq?e.clockseq:u;if(null==o||null==r){var a=C();null==o&&(o=d=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==r&&(r=u=16383&(a[6]<<8|a[7]))}var c=void 0!==e.msecs?e.msecs:(new Date).getTime(),l=void 0!==e.nsecs?e.nsecs:E+1,h=c-m+(l-E)/1e4;if(h<0&&void 0===e.clockseq&&(r=r+1&16383),(h<0||c>m)&&void 0===e.nsecs&&(l=0),l>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");m=c,E=l,u=r;var p=(1e4*(268435455&(c+=122192928e5))+l)%4294967296;n[s++]=p>>>24&255,n[s++]=p>>>16&255,n[s++]=p>>>8&255,n[s++]=255&p;var R=c/4294967296*1e4&268435455;n[s++]=R>>>8&255,n[s++]=255&R,n[s++]=R>>>24&15|16,n[s++]=R>>>16&255,n[s++]=r>>>8|128,n[s++]=255&r;for(var v=0;v<6;++v)n[s+v]=o[v];return t||T(n)},R=n.exports,v=h;var f=function(e,t,i){var s=t&&i||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var n=(e=e||{}).random||(e.rng||R)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t)for(var o=0;o<16;++o)t[s+o]=n[o];return t||v(n)},g=p,y=f,k=y;k.v1=g,k.v4=y;var w=k;class b{support(){return!0}getParams(){return this.params}setData(e){this.active=e.a,this.data=e.d}preConnect(e){}postConnect(){}}const _=s;class I{constructor(){this.emitter=new _}on(e,t){return this.emitter.on(e,t),this}once(e,t){return this.emitter.once(e,t),this}off(e,t){return this.emitter.off(e,t),this}fire(e,t){return this.emitter.emit(e,t),this}}class A{constructor(){this.eventDriver=new I}on(e,t){this.eventDriver.on(e,t)}off(e,t){this.eventDriver.off(e,t)}fire(e,t){this.eventDriver.fire(e,t)}}let M=new class{isDef(e){return!this.isUndef(e)}isUndef(e){return null==e}isPrimitive(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e||"boolean"==typeof e}isObject(e){return null!==e&&"object"==typeof e}isPlainObject(e){return"[object Object]"===Object.prototype.toString.call(e)}isRegExp(e){return"[object RegExp]"===Object.prototype.toString.call(e)}isValidArrayIndex(e){let t=parseFloat(String(e));return t>=0&&Math.floor(t)===t&&isFinite(e)}isString(e){return"string"==typeof e}isNumber(e){return"number"==typeof e}isStringOrNumber(e){return this.isString(e)||this.isNumber(e)}isArray(e){return"[object Array]"===Object.prototype.toString.call(e)}isEmpty(e){return this.isArray(e)?0===e.length:this.isObject(e)?!this.isDef(e):!this.isNumber(e)&&(this.isString(e)?""===e.trim():!this.isDef(e))}isNative(e){return"function"==typeof e&&/native code/.test(e.toString())}isFunction(e){return"function"==typeof e}isBoolean(e){return"boolean"==typeof e}isTrue(e){return!0===e}isFalse(e){return!1===e}isNull(e){return null===e}};const N=s;class S{constructor(){this.emitter=new N}on(e,t){if(!M.isString(e))throw Error("event require a string.");if(!M.isFunction(t))throw Error("callback must be a function");this.emitter.on(e,t)}fire(e,t){this.emitter.emit(e,t)}off(e,t){this.emitter.off(e,t)}}class D{static init(e,t,i,s,n,o){this.Socket=e,this.N=t,this.Member=i,this.v=s,this.Platform=n,this.GModules=o}}const L=w;class O{static get(){return L.v1().replace(/-/g,"")}}var P,G,U;(G=P||(P={})).WRITE="WRITE",G.READ="READ",G.NONE="NONE";class V{constructor(e){this.permission=P.NONE,this.singleTimeout=0,this.totalTimeout=0,this.startTime=0,this.complete=!1,this.retried=0,this.unique=!1,this.uuid=O.get(),this.name=e.name,this.params=e.params,this.permission=e.permission,this.totalTimeout=e.totalTimeout,this.singleTimeout=e.singleTimeout,e.unique&&(this.unique=e.unique),this.success=t=>{this.complete||(this.end(),e.success(t))},this.fail=t=>{this.complete||(this.end(),e.fail(t))}}start(){this.startTime=Date.now(),this.initAutoTimeout()}end(){this.complete=!0,clearTimeout(this.timeoutHandler)}initAutoTimeout(){this.timeoutHandler=setTimeout((()=>{this.complete||this.fail({resultCode:408,content:"Host unreachable or timeout"})}),this.totalTimeout)}}class j extends A{static init(){this.i=new j}}class q{constructor(){this.callees=new Array}getDuration(){return Math.floor((Date.now()-this.acceptedAt)/1e3)}}class x{constructor(e,t,i){this.micMuted=!1,this.cameraMuted=!1,this.id=e,this.data=t,this.status=i}}class F{constructor(e){this.call=new q,this.call=e}}class K{static init(){this.eventCenter=new S}static on(e,t){this.eventCenter.on(e,t)}static fire(e,t){this.eventCenter.fire(e,t)}static off(e,t){this.eventCenter.off(e,t)}}!function(e){e.RING="RING",e.USER_RANG="USER_RANG",e.USER_QUIT="USER_QUIT",e.USER_ACCEPTED="USER_ACCEPTED",e.CALL_ENDED="CALL_ENDED",e.USER_MIC_CHANGED="USER_MIC_CHANGED",e.USER_CAMERA_CHANGED="USER_CAMERA_CHANGED"}(U||(U={}));class H{static setStatus(e){this.status&&this.status.destroy(),this.status=e,be.callContext.call.status=e.name()}static clearStatus(){this.status&&(this.status.destroy(),this.status=null)}}var B;!function(e){e[e.AUDIO=0]="AUDIO",e[e.VIDEO=1]="VIDEO"}(B||(B={}));class Q extends b{static init(e){e.c(D),this.module=new Q,this.module.name=this.RTC_MODULE_NAME;let t=null;if(this.supportApp()){let e=uni.requireNativePlugin("RTCClientPlugin");e&&(t=e.v())}this.module.params={v:{n:"goeasy-rtc",v:"0.4.2",npv:t}},D.GModules.initModule(this.module)}static check(){if(!this.module)throw new Error("Please init GRTC first.");if(!this.module.active)throw new Error("RTC unavailable. Please confirm if your GoEasy application supports RTC or contact GoEasy team.");if(!this.supportApp()&&!this.supportBrowser())throw new Error("GRTC is only supported in Android and iOS apps developed with UniApp and Browsers");if(!this.supportGoEasyVersion())throw new Error("GRTC is only supported in GoEasy SDK version 2.10.0 or later")}static supportGoEasyVersion(){return D.v.localeCompare("2.10.0",void 0,{numeric:!0,sensitivity:"base"})>=0}static supportApp(){return[D.Platform.type.UNI_ANDROID,D.Platform.type.UNI_IOS].includes(D.Platform.current)}static supportBrowser(){return D.Platform.type.BROWSER===D.Platform.current}static supportWebview(){return"undefined"!=typeof window&&void 0!==window.GRTCBridge}support(){return Q.supportGoEasyVersion()&&(Q.supportApp()||Q.supportBrowser()||Q.supportWebview())}postConnect(){j.init(),K.init(),Ie.init()}}Q.RTC_MODULE_NAME="GRTC";let W=new class{isDef(e){return!this.isUndef(e)}isUndef(e){return null==e}isPrimitive(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e||"boolean"==typeof e}isObject(e){return null!==e&&"object"==typeof e}isString(e){return"string"==typeof e}isNumber(e){return"number"==typeof e}isStringOrNumber(e){return this.isString(e)||this.isNumber(e)}isArray(e){return"[object Array]"===Object.prototype.toString.call(e)}isEmpty(e){return this.isArray(e)?0===e.length:this.isObject(e)?!this.isDef(e):!this.isNumber(e)&&(this.isString(e)?""===e.trim():!this.isDef(e))}isNative(e){return"function"==typeof e&&/native code/.test(e.toString())}isFunction(e){return"function"==typeof e}};const $=new class{validateId(e,t){if(W.isEmpty(e))throw{code:400,content:` ${t} is required.`};if(!W.isStringOrNumber(e))throw{code:400,content:`TypeError: ${t} require string or number.`}}validateNotification(e){if(e){if(!W.isObject(e))throw{code:400,content:"TypeError: notification requires an object."};{if(t(e,"title",32),t(e,"body",50),W.isDef(e.sound)&&!W.isString(e.sound))throw{code:400,content:"notification.sound must be a string"};if(W.isDef(e.badge)&&!W.isString(e.badge))throw{code:400,content:"notification.badge must be a string"};e.badge=e.badge||"0";let s=e.vendorOptions;W.isObject(s)&&(i(s,"huawei","category","string"),i(s,"xiaomi","channel_id","string"),i(s,"oppo","channel_id","string"),i(s,"oppo","category","string"),i(s,"vivo","classification","number"),i(s,"vivo","category","string"))}}function t(e,t,i){if(!(W.isString(e[t])&&e[t].length<=i))throw{code:400,content:`notification.${t} must be a string of no more than ${i} characters`}}function i(e,t,i,s){let n=e[t];if(W.isObject(n)&&W.isDef(n[i])){let e={code:400,content:`notification.vendorOptions.${t}.${i} require a ${s}}`},o=n[i];if("string"===s&&!W.isString(o))throw e;if("number"===s&&!W.isNumber(o))throw e}}}validateObject(e,t){if(W.isUndef(e)||!W.isObject(e))throw{code:400,content:t+" must be an object."}}validateString(e,t){if(W.isUndef(e)||!W.isString(e))throw{code:400,content:t+" must be a string."}}};var Y,J,X,z,Z,ee;!function(e){e.ALL_BUSY="ALL_BUSY",e.DIAL_FAILED="DIAL_FAILED",e.CANCELLED="CANCELLED",e.REJECTED="REJECTED",e.HUNG_UP="HUNG_UP",e.RTC_DISCONNECTED="RTC_DISCONNECTED",e.GOEASY_DISCONNECTED="GOEASY_DISCONNECTED",e.HANDLED_ON_ANOTHER_DEVICE="HANDLED_ON_ANOTHER_DEVICE",e.RING_TIMEOUT="RING_TIMEOUT",e.ACCEPT_FAILED="ACCEPT_FAILED",e.DIAL_TIMEOUT="DIAL_TIMEOUT"}(Y||(Y={}));class te{}class ie{constructor(e,t){this.joined=!1,this.token=t,this.video=e===B.VIDEO,this.userId=D.Socket.user().id}play(e){}initLocal(){}}class se extends ie{constructor(e,i,s){super(i,s),this.client=e,this.token.video=this.video,this.token.userId=this.userId,this.client.createRTCClient(this.token),plus.globalEvent.addEventListener("connectionLost",(()=>{j.i.fire(t.RTC_LOST)})),plus.globalEvent.addEventListener("connectionRecovery",(e=>{j.i.fire(t.RTC_RECONNECT)})),plus.globalEvent.addEventListener("receivedRemoteFlow",(e=>{j.i.fire(t.RECEIVED_RTC_REMOTE_FLOW,e)})),plus.globalEvent.addEventListener("remoteMicChanged",(e=>{j.i.fire(t.RTC_REMOTE_MIC_CHANGED,e)})),plus.globalEvent.addEventListener("remoteCameraChanged",(e=>{j.i.fire(t.RTC_REMOTE_CAMERA_CHANGED,e)}))}destroy(){plus.globalEvent.removeEventListener("connectionLost"),plus.globalEvent.removeEventListener("connectionRecovery"),plus.globalEvent.removeEventListener("receivedRemoteFlow"),plus.globalEvent.removeEventListener("remoteMicChanged"),plus.globalEvent.removeEventListener("remoteCameraChanged"),this.joined&&(this.leave(),this.joined=!1),this.client.destroyEngine()}join(){return new Promise(((e,t)=>{this.client.joinChannel((()=>{this.userId,this.token.callId,this.joined=!0,e()}),(e=>{this.userId,this.token.callId,t({code:400,content:"Failed to join Channel, error code:"+e})}))}))}push(){this.video?this.client.callVideo():this.client.callAudio()}leave(){this.client.leaveChannel()}accept(){return e(this,void 0,void 0,(function*(){yield this.join(),this.push()}))}muteMic(e){this.client.muteMic({enabled:e})}toggleSpeaker(e){this.client.enableSpeaker({enabled:e})}muteCamera(e){this.client.muteCamera({enabled:e})}switchCamera(){this.client.switchCamera()}}class ne extends te{constructor(){super(),this.nativePlugin=uni.requireNativePlugin("RTCClientPlugin"),this.nativePlugin||console.warn("Please configure GoEasy RTC native plugin first: https://www.goeasy.io")}createClient(t,i){return e(this,void 0,void 0,(function*(){return new se(this.nativePlugin,t,i)}))}requestPermission(e){return new Promise(((t,i)=>{B.VIDEO===e?this.nativePlugin.requestVideoCallPermission((e=>{200===e?t():i({code:403,content:"Failed to request video call permission, error code:"+e})})):B.AUDIO===e?this.nativePlugin.requestVoiceCallPermission((e=>{200===e?t():i({code:403,content:"Failed to request voice call permission, error code:"+e})})):i({code:400,content:"Unsupported media type"})}))}}!function(e){e.QN="QN",e.ALI="ALI",e.TX="TX",e.LK="LK"}(J||(J={}));class oe{constructor(e,t){this.userId=e,this.muted=t}}class re extends ie{constructor(e,t){super(e,t),this.localTracks=[],this.remoteTracks=new Map;this.QNRTC=(()=>{try{return require("qnweb-rtc").default||require("qnweb-rtc")}catch(e){throw new Error("Please run npm install qnweb-rtc")}})(),this.QNRTC.setLogLevel("NONE"),this.client=this.QNRTC.createClient(),this.initListeners()}initListeners(){this.client.on("connection-state-changed",((e,i)=>{"RECONNECTED"===e?j.i.fire(t.RTC_RECONNECT):"DISCONNECTED"===e&&j.i.fire(t.RTC_LOST)})),this.client.on("user-published",((e,t)=>{this.subscribe(e,t)}))}listenRemoteTrackMutedChanged(e){e.on("mute-state-changed",(i=>{let s=e.isAudio(),n=e.userID,o=s?t.RTC_REMOTE_MIC_CHANGED:t.RTC_REMOTE_CAMERA_CHANGED;j.i.fire(o,new oe(n,i))}))}subscribe(i,s){return e(this,void 0,void 0,(function*(){const e=yield this.client.subscribe(s);if(e.audioTracks.length>0&&(this.listenRemoteTrackMutedChanged(e.audioTracks[0]),e.audioTracks[0]._isMuted&&be.muteMemberMic(i,!0)),e.videoTracks.length>0&&(this.listenRemoteTrackMutedChanged(e.videoTracks[0]),e.videoTracks[0]._isMuted&&be.muteMemberCamera(i,!0)),this.remoteTracks.set(i,e),j.i.fire(t.RECEIVED_RTC_REMOTE_FLOW,{userId:i}),!1===this.video)this.playRemoteMicrophoneTracks();else{let e=this.getView(i);e&&this.playRemoteTrack(i,e)}}))}initLocal(){return e(this,void 0,void 0,(function*(){yield this.initLocalTracks()}))}join(){return e(this,void 0,void 0,(function*(){const e=this.token.vendorToken.token;yield this.client.join(e),this.joined=!0}))}push(){return e(this,void 0,void 0,(function*(){yield this.client.publish(this.localTracks)}))}accept(){return e(this,void 0,void 0,(function*(){yield this.join(),yield this.push()}))}initLocalTracks(){return e(this,void 0,void 0,(function*(){if(!(this.localTracks.length>0))if(this.video){const e=this.token.vendorToken.videoEncoderConfig;this.localTracks=yield this.QNRTC.createMicrophoneAndCameraTracks({videoConfig:{encoderConfig:{width:e.w,height:e.h,frameRate:e.fps,bitrate:e.br}}})}else this.localTracks=[yield this.QNRTC.createMicrophoneAudioTrack()]}))}play(t){return e(this,void 0,void 0,(function*(){if(this.video){const e=this.getView(t);this.userId===t?(yield this.initLocalTracks(),this.listenCustomAttributes(e),this.playLocalTrack(e)):(this.listenCustomAttributes(e),this.playRemoteTrack(t,e))}else this.playRemoteMicrophoneTracks()}))}getView(e){const t=document.getElementsByClassName("grtc-video");for(let i=0;i<t.length;i++){const s=t[i];if(s.getAttribute("userId")===e)return s}}listenCustomAttributes(e){new MutationObserver((t=>{t.forEach((t=>{const i=t.oldValue,s=e.getAttribute("userId");W.isEmpty(s)||s===i||(this.userId===s?this.playLocalTrack(e):this.playRemoteTrack(s,e))}))})).observe(e,{attributes:!0,attributeOldValue:!0,attributeFilter:["userid"]})}playRemoteMicrophoneTracks(){const e=document.getElementsByClassName("grtc-audio")[0];e&&this.remoteTracks.forEach(((t,i)=>{for(const i of t.audioTracks)i.play(e)}))}playLocalTrack(e){for(const t of this.localTracks)t.isAudio()||t.play(e,{mirror:!0})}playRemoteTrack(e,t){const i=this.remoteTracks.get(e);if(i)for(const e of[...i.videoTracks,...i.audioTracks])e.play(t)}destroy(){this.joined&&this.leave(),this.releaseMediaTracks()}releaseMediaTracks(){for(const e of this.localTracks)e.destroy();this.localTracks=[],this.remoteTracks.clear()}leave(){return e(this,void 0,void 0,(function*(){yield this.client.leave()}))}requestPermission(t){return e(this,void 0,void 0,(function*(){}))}toggleSpeaker(e){throw new Error("not support.")}muteCamera(e){for(const t of this.localTracks)t.isVideo()&&t.setMuted(e)}muteMic(e){for(const t of this.localTracks)t.isAudio()&&t.setMuted(e)}switchCamera(){throw new Error("not support.")}}class ae extends ie{constructor(e,t){super(e,t),this.localTracks=[],this.remoteTracks=new Map,this.isFrontFacing=!0,this.LiveKitRTC=this.loadLiveKitRTC(),this.resolution=this.LiveKitRTC.VideoPresets.h720.resolution;const i=new this.LiveKitRTC.DefaultReconnectPolicy([0,1e3,4e3,9e3,16e3]);this.client=new this.LiveKitRTC.Room({adaptiveStream:!1,dynacast:!1,videoCaptureDefaults:{resolution:this.resolution},reconnectPolicy:i}),this.initListeners()}loadLiveKitRTC(){try{return require("livekit-client")}catch(e){throw new Error("Please run npm install livekit-client@2.5.10")}}initListeners(){this.client.on(this.LiveKitRTC.RoomEvent.Reconnected,(()=>{j.i.fire(t.RTC_RECONNECT)})),this.client.on(this.LiveKitRTC.RoomEvent.Disconnected,(()=>{j.i.fire(t.RTC_LOST)})),this.client.on(this.LiveKitRTC.RoomEvent.TrackPublished,((e,t)=>{t.identity,e.setSubscribed(!0)})),this.client.on(this.LiveKitRTC.RoomEvent.ParticipantConnected,(e=>{e.identity,this.listenRemoteParticipant(e)})),this.client.on(this.LiveKitRTC.RoomEvent.TrackSubscribed,((e,t,i)=>{i.identity,this.handleTrackSubscribed(e,t,i)}))}handleTrackSubscribed(e,i,s){let n=s.identity;if(e.kind===this.LiveKitRTC.Track.Kind.Video||e.kind===this.LiveKitRTC.Track.Kind.Audio)if(this.video?e.kind===this.LiveKitRTC.Track.Kind.Video&&j.i.fire(t.RECEIVED_RTC_REMOTE_FLOW,{userId:n}):j.i.fire(t.RECEIVED_RTC_REMOTE_FLOW,{userId:n}),this.updateRemoteTracks(n,e),this.video){let e=this.getVideoView(n);e&&this.playRemoteTrack(n,e)}else this.playRemoteMicTracks()}updateRemoteTracks(e,t){let i=this.remoteTracks.get(e)||[];i.push(t),this.remoteTracks.set(e,i)}listenRemoteParticipant(e){const t=e.identity;e.on(this.LiveKitRTC.RoomEvent.TrackMuted,(e=>this.onTrackMuted(e,t))),e.on(this.LiveKitRTC.RoomEvent.TrackUnmuted,(e=>this.onTrackUnmuted(e,t)))}onTrackMuted(e,i){let s=e.kind;e.kind,s===this.LiveKitRTC.Track.Kind.Video?j.i.fire(t.RTC_REMOTE_CAMERA_CHANGED,new oe(i,!0)):s===this.LiveKitRTC.Track.Kind.Audio&&j.i.fire(t.RTC_REMOTE_MIC_CHANGED,new oe(i,!0))}onTrackUnmuted(e,i){let s=e.kind;s===this.LiveKitRTC.Track.Kind.Video?j.i.fire(t.RTC_REMOTE_CAMERA_CHANGED,new oe(i,!1)):s===this.LiveKitRTC.Track.Kind.Audio&&j.i.fire(t.RTC_REMOTE_MIC_CHANGED,new oe(i,!1))}initLocal(){return e(this,void 0,void 0,(function*(){yield this.initLocalTracks()}))}join(){return e(this,void 0,void 0,(function*(){const e=this.token.vendorToken;yield this.client.connect(e.url,e.token,{autoSubscribe:!1}),this.joined=!0}))}push(){return e(this,void 0,void 0,(function*(){yield Promise.all(this.localTracks.map((e=>this.client.localParticipant.publishTrack(e,{simulcast:!1})))),this.client.remoteParticipants.forEach((e=>{e.trackPublications.forEach((e=>e.setSubscribed(!0))),this.listenRemoteParticipant(e)}))}))}accept(){return e(this,void 0,void 0,(function*(){yield this.join(),yield this.push()}))}initLocalTracks(){return e(this,void 0,void 0,(function*(){const e=yield this.LiveKitRTC.createLocalAudioTrack({echoCancellation:!0,noiseSuppression:!0});if(this.localTracks.push(e),this.video){const e=yield this.LiveKitRTC.createLocalVideoTrack({facingMode:"user"});this.localTracks.push(e)}}))}play(t){return e(this,void 0,void 0,(function*(){if(this.video){const e=this.getVideoView(t);this.listenCustomAttributes(e),this.userId===t?this.playLocalTrack(e):this.playRemoteTrack(t,e)}else this.playRemoteMicTracks()}))}getVideoView(e){const t=document.getElementsByClassName("grtc-video");for(let i=0;i<t.length;i++){const s=t[i];if(s.getAttribute("userId")===e)return s}}listenCustomAttributes(e){new MutationObserver((t=>{t.forEach((t=>{const i=t.oldValue,s=e.getAttribute("userId");W.isEmpty(s)||s===i||(this.userId===s?this.playLocalTrack(e):this.playRemoteTrack(s,e))}))})).observe(e,{attributes:!0,attributeOldValue:!0,attributeFilter:["userid"]})}playRemoteMicTracks(){const e=document.getElementsByClassName("grtc-audio")[0];if(e)for(const t of this.remoteTracks.values())for(const i of t){let t=i.attach();e.appendChild(t)}}playLocalTrack(e){this.playTrack(this.localTracks,e)}playRemoteTrack(e,t){const i=this.remoteTracks.get(e);i&&this.playTrack(i,t)}playTrack(e,t){for(const i of e){let e,s=i.kind,n=i.attach();s===this.LiveKitRTC.Track.Kind.Video?(n.style.width="100%",n.style.height="100%",n.style.objectFit="cover",e=t.querySelector("video")):s===this.LiveKitRTC.Track.Kind.Audio&&(e=t.querySelector("audio")),e?e.replaceWith(n):t.appendChild(n)}}destroy(){this.joined&&this.leave(),this.releaseMediaTracks()}releaseMediaTracks(){for(const e of this.localTracks)e.detach(),e.stop();this.localTracks=[],this.remoteTracks.clear()}leave(){return e(this,void 0,void 0,(function*(){yield this.client.disconnect()}))}toggleSpeaker(e){throw new Error("not support.")}muteCamera(e){for(const t of this.localTracks)t.kind===this.LiveKitRTC.Track.Kind.Video&&this.client.localParticipant.setCameraEnabled(!e)}muteMic(e){for(const t of this.localTracks)t.kind===this.LiveKitRTC.Track.Kind.Audio&&this.client.localParticipant.setMicrophoneEnabled(!e)}switchCamera(){var e;const t=this.client.localParticipant.getTrackPublication(this.LiveKitRTC.Track.Source.Camera);if(!t)return;this.isFrontFacing=!this.isFrontFacing;const i={resolution:this.resolution,facingMode:this.isFrontFacing?"user":"environment"};null===(e=t.videoTrack)||void 0===e||e.restartTrack(i)}}class ce extends ie{constructor(e,t){super(e,t),this.localTracks=[],this.fired={},this.mcuNotSubscribed=!0;this.DingRTC=(()=>{try{return require("dingrtc").default||require("dingrtc")}catch(e){throw new Error("Please run npm install dingrtc")}})(),this.DingRTC.setLogLevel("none");if(!this.DingRTC.checkSystemRequirements())throw new Error("当前浏览器不支持dingrtc");this.client=this.DingRTC.createClient(),this.initListeners()}initListeners(){this.client.on("connection-state-change",((e,i,s)=>{"reconnecting"===i&&"connected"===e?j.i.fire(t.RTC_RECONNECT):"disconnected"===e&&j.i.fire(t.RTC_LOST)})),this.client.on("user-published",((e,i)=>{e.userId,this.subscribe(e.userId,i),this.fired[e.userId]||(this.fired[e.userId]=!0,e.userId,j.i.fire(t.RECEIVED_RTC_REMOTE_FLOW,{userId:e.userId}))})),this.client.on("user-info-updated",((e,i)=>{const s={"mute-audio":{event:t.RTC_REMOTE_MIC_CHANGED,muted:!0},"unmute-audio":{event:t.RTC_REMOTE_MIC_CHANGED,muted:!1},"mute-video":{event:t.RTC_REMOTE_CAMERA_CHANGED,muted:!0},"unmute-video":{event:t.RTC_REMOTE_CAMERA_CHANGED,muted:!1}}[i];s&&j.i.fire(s.event,new oe(e,s.muted))}))}initLocal(){return e(this,void 0,void 0,(function*(){yield this.initLocalTracks()}))}initLocalTracks(){return e(this,void 0,void 0,(function*(){if(this.localTracks.length>0)return;const e=yield this.DingRTC.createMicrophoneAudioTrack();this.localTracks.push(e);const t=this.token.vendorToken.videoEncoderConfig;if(this.video){const e=yield this.DingRTC.createCameraVideoTrack({dimension:`VD_${t.w}x${t.h}`,frameRate:t.fps});this.localTracks.push(e)}}))}accept(){return e(this,void 0,void 0,(function*(){yield this.join(),yield this.push()}))}join(){return e(this,void 0,void 0,(function*(){const e=this.token.vendorToken,t={appId:e.appId,channel:this.token.callId.toString(),token:e.token,uid:this.userId,userName:this.userId};yield this.client.join(t),this.joined=!0,yield this.subscribeRemoteUser()}))}subscribeRemoteUser(){return e(this,void 0,void 0,(function*(){const e=this.client.remoteUsers;if(!(e.length<=1))for(const i of e){const{userId:e,hasAudio:s,hasVideo:n,audioMuted:o,videoMuted:r}=i;n&&(yield this.subscribe(i.userId,"video")),s&&(yield this.subscribe(i.userId,"audio")),o&&be.muteMemberMic(i.userId,!0),r&&be.muteMemberCamera(i.userId,!0),j.i.fire(t.RECEIVED_RTC_REMOTE_FLOW,{userId:i.userId})}}))}subscribe(t,i){return e(this,void 0,void 0,(function*(){if("video"===i){const e=yield this.client.subscribe(t,"video"),i=this.getView(t);i&&e.play(i)}else if(this.mcuNotSubscribed){this.mcuNotSubscribed=!1;(yield this.client.subscribe("mcu","audio")).play()}}))}push(){return e(this,void 0,void 0,(function*(){yield this.client.publish(this.localTracks)}))}play(t){return e(this,void 0,void 0,(function*(){if(this.video){const e=this.getView(t);this.userId===t?(yield this.initLocalTracks(),this.playLocalVideoTrack(e)):this.playRemoteVideoTrack(t,e)}}))}getView(e){const t=document.getElementsByClassName("grtc-video");for(let i=0;i<t.length;i++){const s=t[i];if(s.getAttribute("userId")===e)return s}}playLocalVideoTrack(e){for(const t of this.localTracks)"video"===t.trackMediaType&&t.play(e,{mirror:!0})}playRemoteVideoTrack(e,t){var i;const s=this.client.remoteUsers.find((t=>t.userId===e));null===(i=null==s?void 0:s.videoTrack)||void 0===i||i.play(t)}destroy(){this.joined&&this.leave(),this.releaseMediaTracks()}releaseMediaTracks(){for(const e of this.localTracks)e.close();this.localTracks=[]}leave(){return e(this,void 0,void 0,(function*(){yield this.client.leave()}))}requestPermission(t){return e(this,void 0,void 0,(function*(){}))}toggleSpeaker(e){throw new Error("not support.")}muteCamera(e){for(const t of this.localTracks)"video"===t.trackMediaType&&t.setMuted(e)}muteMic(e){for(const t of this.localTracks)"audio"===t.trackMediaType&&t.setMuted(e)}switchCamera(){throw new Error("not support.")}}class le extends ie{constructor(e,t){super(e,t),this.videoAvailable={};this.TRTC=(()=>{try{return require("trtc-sdk-v5").default||require("trtc-sdk-v5")}catch(e){throw new Error("Please run npm install trtc-sdk-v5")}})(),this.TRTC.setLogLevel(5),this.client=this.TRTC.create(),this.initListeners()}initListeners(){this.client.on(this.TRTC.EVENT.CONNECTION_STATE_CHANGED,(({prevState:e,state:i})=>{"reconnecting"===e&&"connected"===i?j.i.fire(t.RTC_RECONNECT):"DISCONNECTED"===i&&j.i.fire(t.RTC_LOST)})),this.client.on(this.TRTC.EVENT.REMOTE_USER_ENTER,(({userId:e})=>{this.videoAvailable[e]=!1,be.muteMemberMic(e,!0),be.muteMemberCamera(e,!0),j.i.fire(t.RECEIVED_RTC_REMOTE_FLOW,{userId:e})})),this.client.on(this.TRTC.EVENT.REMOTE_AUDIO_AVAILABLE,(({userId:e})=>{this.client.muteRemoteAudio(e,!1),j.i.fire(t.RTC_REMOTE_MIC_CHANGED,new oe(e,!1))})),this.client.on(this.TRTC.EVENT.REMOTE_AUDIO_UNAVAILABLE,(({userId:e})=>{this.client.muteRemoteAudio(e,!0),j.i.fire(t.RTC_REMOTE_MIC_CHANGED,new oe(e,!0))})),this.client.on(this.TRTC.EVENT.REMOTE_VIDEO_AVAILABLE,(({userId:e,streamType:i})=>{this.videoAvailable[e]=!0;const s=this.getView(e);this.client.startRemoteVideo({userId:e,streamType:i,view:s}),j.i.fire(t.RTC_REMOTE_CAMERA_CHANGED,new oe(e,!1))})),this.client.on(this.TRTC.EVENT.REMOTE_VIDEO_UNAVAILABLE,(({userId:e})=>{this.videoAvailable[e]=!1,j.i.fire(t.RTC_REMOTE_CAMERA_CHANGED,new oe(e,!0))}))}initLocal(){return e(this,void 0,void 0,(function*(){if(!(yield this.TRTC.isSupported()).result)throw new Error("当前浏览器不支持trtc");yield this.initLocalTracks()}))}initLocalTracks(){return e(this,void 0,void 0,(function*(){if(this.client.getAudioTrack()||(yield this.client.startLocalAudio({publish:!1})),this.video){if(!this.client.getVideoTrack()){const e=this.getView(this.userId),t=this.token.vendorToken.videoEncoderConfig;yield this.client.startLocalVideo({view:e,publish:!1,option:{profile:{width:t.w,height:t.h,frameRate:t.fps,bitrate:t.br}}})}}}))}push(){return e(this,void 0,void 0,(function*(){if(yield this.client.updateLocalAudio({publish:!0}),this.video){const e=this.getView(this.userId);yield this.client.updateLocalVideo({view:e,publish:!0})}}))}join(){return e(this,void 0,void 0,(function*(){const e=this.token.vendorToken,t={strRoomId:this.token.callId.toString(),sdkAppId:e.sdkAppId,userId:this.userId,userSig:e.userSig};yield this.client.enterRoom(t),this.joined=!0}))}accept(){return e(this,void 0,void 0,(function*(){yield this.join(),yield this.push()}))}play(t){return e(this,void 0,void 0,(function*(){if(this.video){const e=this.getView(t);this.userId===t?(yield this.initLocalTracks(),yield this.playLocalVideoTrack(e)):yield this.playRemoteVideoTrack(t,e)}}))}getView(e){const t=document.getElementsByClassName("grtc-video");for(let i=0;i<t.length;i++){const s=t[i];if(s.getAttribute("userId")===e)return s}}playLocalVideoTrack(t){return e(this,void 0,void 0,(function*(){yield this.client.updateLocalVideo({view:t})}))}playRemoteVideoTrack(t,i){return e(this,void 0,void 0,(function*(){this.videoAvailable[t]?yield this.client.updateRemoteVideo({view:i,userId:t,streamType:this.TRTC.TYPE.STREAM_TYPE_MAIN}):yield this.client.startRemoteVideo({view:i,userId:t,streamType:this.TRTC.TYPE.STREAM_TYPE_MAIN})}))}destroy(){this.joined&&this.leave(),this.releaseMediaTracks()}releaseMediaTracks(){this.client.stopLocalAudio(),this.video&&this.client.stopLocalVideo(),this.client.stopRemoteVideo({userId:"*"})}leave(){return e(this,void 0,void 0,(function*(){yield this.client.exitRoom()}))}requestPermission(t){return e(this,void 0,void 0,(function*(){}))}toggleSpeaker(e){throw new Error("not support.")}muteCamera(e){this.client.updateLocalVideo({mute:e})}muteMic(e){this.client.updateLocalAudio({mute:e})}switchCamera(){throw new Error("not support.")}}class de extends te{createClient(t,i){return e(this,void 0,void 0,(function*(){let e,s=i.vendor;if(J.QN===s)e=new re(t,i);else if(J.LK===s)e=new ae(t,i);else if(J.ALI===s)e=new ce(t,i);else{if(J.TX!==s)throw new Error("rtc vendor not support");e=new le(t,i)}return yield e.initLocal(),e}))}requestPermission(t){return new Promise(((i,s)=>e(this,void 0,void 0,(function*(){if(navigator.permissions&&navigator.permissions.query){if("denied"===(yield navigator.permissions.query({name:"microphone"})).state&&s({code:403,content:"Failed to request microphone permission"}),t===B.VIDEO){"denied"===(yield navigator.permissions.query({name:"camera"})).state&&s({code:403,content:"Failed to request camera permission"})}}i()}))))}}class ue{constructor(e,t,i){this.name=e,this.callId=t,this.data=i}static createCallCommand(e,t,i){let s={calleeIds:e.callees.map((e=>e.id)),mediaType:i.mediaType,groupId:i.groupId,callId:t};return i.notification&&(s.notification=i.notification),new ue(X.CALL,t,s)}}!function(e){e.CALL="CALL",e.QUIT="QUIT",e.BUSY="BUSY",e.ACCEPT="ACCEPT",e.RANG="RANG",e.HANGUP="HANGUP",e.CANCEL="CANCEL",e.REJECT="REJECT",e.RTC_DISCONNECT="RTC_DISCONNECT",e.GET_TOKEN="GET_TOKEN"}(X||(X={})),function(e){e.RTC_CMD="RTC_CMD",e.RTC_PKT="RTC_PKT"}(z||(z={})),function(e){e[e.connect=3e3]="connect",e[e.reconnectionDelayMax=3e3]="reconnectionDelayMax",e[e.commonQuerySingle=2500]="commonQuerySingle",e[e.commonQueryTotal=12e3]="commonQueryTotal",e[e.commonRequestSingle=1700]="commonRequestSingle",e[e.commonRequestTotal=12e3]="commonRequestTotal",e[e.commonInfiniteSingle=1700]="commonInfiniteSingle",e[e.commonInfiniteTotal=864e5]="commonInfiniteTotal"}(Z||(Z={}));class he extends ie{constructor(e,t){super(e,t),this._gnCallbacks={},this.CALLBACK_PREFIX="grtc_",this.token.video=this.video,this.token.userId=this.userId,window.GRTCBridge.createRTCClient(JSON.stringify(this.token)),window.handleGRTCCallback=this.handleGRTCCallback.bind(this),window.handleGRTCEvent=this.handleGRTCEvent.bind(this),window.addEventListener("beforeunload",(()=>this.cleanup()))}handleGRTCEvent(e,i){const s=JSON.parse(i);switch(e){case"connectionLost":j.i.fire(t.RTC_LOST);break;case"connectionRecovery":j.i.fire(t.RTC_RECONNECT);break;case"receivedRemoteFlow":j.i.fire(t.RECEIVED_RTC_REMOTE_FLOW,s);break;case"remoteMicChanged":j.i.fire(t.RTC_REMOTE_MIC_CHANGED,s);break;case"remoteCameraChanged":j.i.fire(t.RTC_REMOTE_CAMERA_CHANGED,s);break;default:console.warn(`[GRTC] 未处理的事件 ${e}`)}}static requestPermission(e){return new Promise(((t,i)=>{const s=`grtc_${Date.now()}`;window.handleGRTCPermissionCallback=(e,n,o)=>{if(e===s)try{n?i({code:403,content:"Failed to request call permission, error code: "+JSON.parse(n).code}):t()}catch(e){i({code:400,errorMsg:`JSON parse error: ${e.message}`})}finally{delete window.handleGRTCPermissionCallback}},e===B.VIDEO?window.GRTCBridge.requestVideoCallPermission(s):window.GRTCBridge.requestVoiceCallPermission(s)}))}accept(){return e(this,void 0,void 0,(function*(){yield this.join(),this.push()}))}destroy(){window.handleGRTCEvent=null,window.handleGRTCCallback=null,this.joined&&(this.leave(),this.joined=!1),window.GRTCBridge.destroyEngine()}join(){return new Promise(((e,t)=>{const i=this.generateCallbackId();this.gnCallbacks[i]={resolve:()=>{this.joined=!0,this.userId,this.token.callId,e()},reject:e=>{console.warn(`user{${this.userId}} failed to join channel{${this.token.callId}}`,e),t(e)}};try{window.GRTCBridge.joinChannel(i)}catch(e){delete this.gnCallbacks[i],t({code:500,errorMsg:`Native call failed: ${e.message}`})}}))}leave(){window.GRTCBridge.leaveChannel()}muteCamera(e){window.GRTCBridge.muteCamera(e)}muteMic(e){window.GRTCBridge.muteMic(e)}push(){this.video?window.GRTCBridge.callVideo():window.GRTCBridge.callAudio()}switchCamera(){window.GRTCBridge.switchCamera()}toggleSpeaker(e){window.GRTCBridge.enableSpeaker(e)}generateCallbackId(){return`${this.CALLBACK_PREFIX}${Date.now()}_${Math.random().toString(36).substring(2,10)}`}cleanup(){Object.keys(this.gnCallbacks).forEach((e=>{delete this.gnCallbacks[e]}))}get gnCallbacks(){return this._gnCallbacks||(this._gnCallbacks={}),this._gnCallbacks}handleGRTCCallback(e,t,i){var s,n;const o=this.gnCallbacks[e];if(o)try{t?null===(s=o.reject)||void 0===s||s.call(o,JSON.parse(t)):null===(n=o.resolve)||void 0===n||n.call(o,i)}catch(e){o.reject({code:400,errorMsg:`JSON parse error: ${e.message}`})}finally{delete this.gnCallbacks[e]}}}class Ce extends te{createClient(t,i){return e(this,void 0,void 0,(function*(){return this.client=new he(t,i),this.client}))}requestPermission(e){return he.requestPermission(e)}}class Te{static init(){Q.supportApp()?this.rtcPlugin=new ne:void 0!==window.GRTCBridge?this.rtcPlugin=new Ce:this.rtcPlugin=new de}static initClient(t,i){return e(this,void 0,void 0,(function*(){let e=yield this.getNewToken(i);return this.vendorClient=yield this.rtcPlugin.createClient(t,e),e.callId}))}static getNewToken(t){return e(this,void 0,void 0,(function*(){let e={name:X.GET_TOKEN};return t&&(e.callId=t),new Promise(((t,i)=>{let s=new V({name:z.RTC_CMD,params:e,permission:P.WRITE,singleTimeout:Z.commonRequestSingle,totalTimeout:Z.commonRequestTotal,success:e=>{t(e.content)},fail:e=>{i(e)}});D.Socket.e(s)}))}))}}class me{onRTCRemoteFlow(e){}onUserAcceptPacket(e){}onUserRang(t){return e(this,void 0,void 0,(function*(){be.updateMemberStatus(t.callerId,"Ringing");const e=yield D.Member.i.getData(t.callerId),i={id:t.callerId,data:e.get(t.callerId)};K.fire(U.USER_RANG,{user:i})}))}onUserQuit(t){return e(this,void 0,void 0,(function*(){return Promise.resolve()}))}onRTCTimeout(){}onGoEasyDisconnected(){be.destroyWithEvent(Y.GOEASY_DISCONNECTED)}destroy(){}muteMic(e){}toggleSpeaker(e){}switchCamera(){Te.vendorClient.switchCamera()}muteCamera(e){Te.vendorClient.muteCamera(e),be.muteMemberCamera(D.Socket.user().id,e)}play(e){Te.vendorClient.play(e)}onRTCRemoteMicChanged(e){}onRTCRemoteCameraChanged(t){return e(this,void 0,void 0,(function*(){}))}}class Ee{static sendRequest(e){return new Promise(((t,i)=>{let s=new V({name:z.RTC_CMD,params:e,permission:P.WRITE,singleTimeout:Z.commonRequestSingle,totalTimeout:Z.commonRequestTotal,success:e=>{t(e)},fail:e=>{i({code:400,content:e.content})}});D.Socket.e(s)}))}}class pe extends me{constructor(){super(),be.callContext.call.acceptedAt=Date.now()}name(){return"InCall"}accept(){return Promise.reject("The call has already been accepted")}end(){const e=new ue(X.HANGUP,be.callContext.call.id);Ee.sendRequest(e),be.destroyWithEvent(Y.HUNG_UP)}onRTCTimeout(){const e=new ue(X.RTC_DISCONNECT,be.callContext.call.id);Ee.sendRequest(e),be.destroyWithEvent(Y.RTC_DISCONNECTED)}onUserQuit(t){return e(this,void 0,void 0,(function*(){be.updateMemberStatus(t.userId,"Quit");const e=yield D.Member.i.getData(t.userId),i={id:t.userId,data:e.get(t.userId)};!0===t.ended?be.destroyWithEvent(t.reason,i):K.fire(U.USER_QUIT,{user:i,reason:t.reason})}))}onRTCRemoteFlow(t){return e(this,void 0,void 0,(function*(){const e=be.callContext.call;be.updateMemberStatus(t.userId,e.status);const i=yield D.Member.i.getData(t.userId),s={id:t.userId,data:i.get(t.userId)};K.fire(U.USER_ACCEPTED,{user:s})}))}muteMic(e){Te.vendorClient.muteMic(e),be.muteMemberMic(D.Socket.user().id,e)}toggleSpeaker(e){Te.vendorClient.toggleSpeaker(e),be.toggleSpeaker(e)}onRTCRemoteMicChanged(t){return e(this,void 0,void 0,(function*(){let e=t.userId;be.muteMemberMic(e,t.muted);const i={user:{id:e,data:(yield D.Member.i.getData(e)).get(e)},micMuted:t.muted};K.fire(U.USER_MIC_CHANGED,i)}))}onRTCRemoteCameraChanged(t){return e(this,void 0,void 0,(function*(){let e=t.userId;be.muteMemberCamera(e,t.muted);const i={user:{id:e,data:(yield D.Member.i.getData(e)).get(e)},cameraMuted:t.muted};K.fire(U.USER_CAMERA_CHANGED,i)}))}}class Re extends me{constructor(){super(),this.dialTimeoutId=setTimeout((()=>{be.destroyWithEvent(Y.DIAL_TIMEOUT)}),45e3)}name(){return"Dialing"}onUserQuit(t){return e(this,void 0,void 0,(function*(){be.updateMemberStatus(t.userId,"Quit");const e=yield D.Member.i.getData(t.userId),i={id:t.userId,data:e.get(t.userId)};!0===t.ended?be.destroyWithEvent(t.reason,i):K.fire(U.USER_QUIT,{user:i,reason:t.reason})}))}accept(){return Promise.reject("Cannot accept the call during dialing.")}end(){const e=new ue(X.CANCEL,be.callContext.call.id);Ee.sendRequest(e),be.destroyWithEvent(Y.CANCELLED)}onRTCRemoteFlow(t){return e(this,void 0,void 0,(function*(){H.setStatus(new pe),Te.vendorClient.push();const e=be.callContext.call;e.caller.status=e.status,be.updateMemberStatus(t.userId,e.status);const i=yield D.Member.i.getData(t.userId),s={id:t.userId,data:i.get(t.userId)};K.fire(U.USER_ACCEPTED,{user:s})}))}destroy(){clearTimeout(this.dialTimeoutId)}}class ve{static initNotificationAssembler(){D.N.addAssembler({assemble:e=>({callId:e.callId}),support:e=>!!e.callId})}static createLocalNotification(e){const t=D.N.supportAppNotification();let i=e.notification;if(!W.isObject(i)||!t)return;let s={callId:e.callId};D.N.createLocalNotification(i.title,i.body,s,i.sound,i.badge)}}class fe extends me{constructor(){super(),this.startAccept=!1;const e=Date.now()-be.callContext.call.time;e>0&&(this.ringTimeoutId=setTimeout((()=>{be.destroyWithEvent(Y.RING_TIMEOUT)}),45e3-e))}name(){return"Ringing"}accept(){return new Promise(((i,s)=>e(this,void 0,void 0,(function*(){try{if(this.startAccept)return void s("The call has already been accepted.");this.startAccept=!0;let e=be.callContext.call;try{yield Te.rtcPlugin.requestPermission(e.mediaType)}catch(e){return this.end(),void s(e)}const n=()=>{j.i.off(t.RTC_ACCEPTED,n),i()};j.i.on(t.RTC_ACCEPTED,n),yield Te.vendorClient.join(),Te.vendorClient.push()}catch(e){console.warn("accept failed:",e),be.destroyWithEvent(Y.ACCEPT_FAILED),s(e)}}))))}onUserAcceptPacket(e){e.userId===D.Socket.user().id&&be.destroyWithEvent(Y.HANDLED_ON_ANOTHER_DEVICE)}onUserQuit(t){return e(this,void 0,void 0,(function*(){try{yield this.startPromise}catch(e){return void console.warn("ring error",e)}be.updateMemberStatus(t.userId,"Quit");const e=yield D.Member.i.getData(t.userId),i={id:t.userId,data:e.get(t.userId)};t.userId===D.Socket.user().id?be.destroyWithEvent(Y.HANDLED_ON_ANOTHER_DEVICE):!0===t.ended?be.destroyWithEvent(t.reason,i):K.fire(U.USER_QUIT,{user:i,reason:t.reason})}))}end(){const e=new ue(X.REJECT,be.callContext.call.id);Ee.sendRequest(e),be.destroyWithEvent(Y.REJECTED)}onRTCRemoteFlow(i){return e(this,void 0,void 0,(function*(){H.setStatus(new pe);const e=new ue(X.ACCEPT,be.callContext.call.id);yield Ee.sendRequest(e);let s=be.callContext.call;"Quit"!==s.caller.status&&(s.caller.status=s.status),be.updateMemberStatus(D.Socket.user().id,s.status),be.updateMemberStatus(i.userId,s.status),j.i.fire(t.RTC_ACCEPTED)}))}onUserRang(t){return e(this,void 0,void 0,(function*(){}))}destroy(){clearTimeout(this.ringTimeoutId)}startRing(t){this.startPromise=new Promise(((i,s)=>e(this,void 0,void 0,(function*(){try{ve.createLocalNotification(t),yield Te.initClient(t.type,t.callId);const e=H.status.name(),s=be.callContext.call;s.status=e;const n=t.users.map((e=>e.id)),o=yield D.Member.i.getData(t.callerId,...n);s.caller=new x(t.callerId,o.get(t.callerId),e),s.callees=t.users.map((t=>new x(t.id,o.get(t.id),e)));const r=new ue(X.RANG,s.id);yield Ee.sendRequest(r);const a=yield D.Member.i.getData(t.callerId),c={id:t.callerId,data:a.get(t.callerId)};K.fire(U.RING,{user:c}),i()}catch(e){console.warn("Ring failed",e),be.destroy(),s(e)}}))))}}!function(e){e.RING="RING",e.USER_RANG="U_RANG",e.USER_QUIT="U_QUIT",e.USER_ACCEPTED="U_ACCEPTED",e.ENDED="ENDED"}(ee||(ee={}));class ge{onServerPacket(e,t){switch(e){case ee.RING:this.onRing(t);break;case ee.USER_RANG:this.onUserRang(t);break;case ee.USER_ACCEPTED:this.onUserAcceptPacket(t);break;case ee.USER_QUIT:this.onUserQuit(t)}}}class ye extends ge{name(){return"Busy"}accept(){return H.status.accept()}end(){H.status.end(),we.setStatus(new ke)}call(e){return Promise.reject("Another call is in progress.")}onRing(e){const t=new ue(X.BUSY,e.id);Ee.sendRequest(t)}onUserAcceptPacket(e){H.status.onUserAcceptPacket(e)}onUserRang(e){H.status.onUserRang(e)}onUserQuit(e){H.status.onUserQuit(e)}onRTCTimeout(){H.status.onRTCTimeout()}onRTCRemoteFlow(e){H.status.onRTCRemoteFlow(e)}onGoEasyDisconnected(){H.status.onGoEasyDisconnected()}muteMic(e){H.status.muteMic(e)}toggleSpeaker(e){H.status.toggleSpeaker(e)}muteCamera(e){H.status.muteCamera(e)}switchCamera(){H.status.switchCamera()}play(e){H.status.play(e)}onRTCRemoteMicChanged(e){H.status.onRTCRemoteMicChanged(e)}onRTCRemoteCameraChanged(e){H.status.onRTCRemoteCameraChanged(e)}}class ke extends ge{name(){return"Idle"}call(t){if(Q.check(),$.validateNotification(t.notification),!D.Socket.user().id)throw new Error("Dialing failed: `id` is required when connecting to GoEasy.");return new Promise(((i,s)=>e(this,void 0,void 0,(function*(){try{if(we.setStatus(new ye),yield Te.rtcPlugin.requestPermission(t.mediaType),"calleeIds"in t){if(!t.calleeIds.every((e=>"string"==typeof e)))return void s({code:400,content:"calleeIds must contain only strings"});be.initGroupCall(t)}else{if("string"!=typeof t.calleeId)return void s({code:400,content:"calleeId must be a string"});be.initPrivateCall(t)}H.setStatus(new Re);let e=yield Te.initClient(t.mediaType);Te.vendorClient.join();const n=be.callContext.call;n.id=e;const o=H.status.name();n.status=o;const r="calleeIds"in t?t.calleeIds:[t.calleeId],a=yield D.Member.i.getData(...r);n.callees=r.map((e=>new x(e,a.get(e),"Ringing")));const c=ue.createCallCommand(n,e,t);const l=(yield Ee.sendRequest(c)).content.users;n.callees=n.callees.filter((e=>!l.find((t=>t.userId===e.id&&t.busy))));l.every((e=>e.busy))?(be.destroy(),s({code:400,content:"all callees are busy"})):i()}catch(e){console.warn("Call failed",e),be.destroy(),s(e)}}))))}validateOptions(){}onRing(t){return e(this,void 0,void 0,(function*(){we.setStatus(new ye),be.ring(t);let e=new fe;H.setStatus(e),e.startRing(t)}))}accept(){return Promise.reject("No active call to accept.")}end(){}onUserRang(e){}onUserAcceptPacket(e){}onUserQuit(e){}onRTCTimeout(){}onRTCRemoteFlow(e){}onGoEasyDisconnected(){}muteMic(){}toggleSpeaker(){}muteCamera(){}switchCamera(){}play(e){}onRTCRemoteCameraChanged(e){}onRTCRemoteMicChanged(e){}}class we{static setStatus(e){this.status=e}}we.status=new ke;class be{static ring(e){const t=new q;t.id=e.callId,t.time=e.time,t.mediaType=e.type,t.groupId=e.groupId,t.speakerOn=!0,this.callContext=new F(t)}static initPrivateCall(t){return e(this,void 0,void 0,(function*(){const e=new q;e.mediaType=t.mediaType,e.speakerOn=!0,e.caller=new x(D.Socket.user().id,D.Socket.user().data,"Dialing"),this.callContext=new F(e)}))}static initGroupCall(e){if(e.calleeIds.length>8)throw new Error("calleeIds can not more than 8");const t=new q;t.groupId=e.groupId,t.mediaType=e.mediaType,t.speakerOn=!0,t.caller=new x(D.Socket.user().id,D.Socket.user().data,"Dialing"),this.callContext=new F(t)}static updateMemberStatus(e,t){const i=this.callContext.call;[...i.callees,i.caller].find((t=>t.id===e)).status=t}static muteMemberMic(e,t){const i=this.callContext.call,s=[...i.callees,i.caller].find((t=>t.id===e));s.micMuted&&t||!s.micMuted&&!t||(s.micMuted=t)}static muteMemberCamera(e,t){const i=this.callContext.call,s=[...i.callees,i.caller].find((t=>t.id===e));s.cameraMuted&&t||!s.cameraMuted&&!t||(s.cameraMuted=t)}static toggleSpeaker(e){this.callContext.call.speakerOn=e}static isCaller(){return this.callContext.call.caller.id===D.Socket.user().id}static destroyWithEvent(e,t=D.Socket.user()){this.updateMemberStatus(t.id,"Quit"),K.fire(U.USER_QUIT,{user:t,reason:e}),K.fire(U.CALL_ENDED),this.destroy()}static destroy(){var e;null===(e=Te.vendorClient)||void 0===e||e.destroy(),this.callContext=null,H.clearStatus(),we.setStatus(new ke)}}class _e{constructor(){j.i.on(t.RTC_LOST,(()=>this.onRTCLost())),j.i.on(t.RTC_RECONNECT,(()=>this.onRTCReconnect()))}onRTCLost(){be.callContext&&(this.rtcLostTimeoutId=setTimeout((()=>{j.i.fire(t.RTC_TIMEOUT)}),1e4))}onRTCReconnect(){clearTimeout(this.rtcLostTimeoutId)}onGoEasyLost(){this.goeasyLostTimeoutId=setTimeout((()=>{j.i.fire(t.GOEASY_TIMEOUT)}),2e4)}onGoEasyReconnected(){clearTimeout(this.goeasyLostTimeoutId)}}class Ie{static init(){this.instance=new Ie}static i(){if(this.instance)return this.instance;throw new Error("Please connect GoEasy first.")}constructor(){this.rtcStabilizer=new _e,Te.init(),ve.initNotificationAssembler(),D.Socket.onMessage(z.RTC_PKT,this.onServerPacket.bind(this)),j.i.on(t.RECEIVED_RTC_REMOTE_FLOW,this.onRTCRemoteFlow.bind(this)),j.i.on(t.RTC_TIMEOUT,this.onRTCTimeout.bind(this)),j.i.on(t.RTC_REMOTE_MIC_CHANGED,this.onRTCRemoteMicChanged.bind(this)),j.i.on(t.RTC_REMOTE_CAMERA_CHANGED,this.onRTCRemoteCameraChanged.bind(this)),D.Socket.on(D.Socket.EVENT.LOST,this.onGoEasyDisconnected.bind(this)),D.Socket.on(D.Socket.EVENT.DISCONNECT,this.onGoEasyDisconnected.bind(this))}on(e,t){K.on(e.toString(),t)}off(e,t){K.off(e.toString(),t)}call(t){return e(this,void 0,void 0,(function*(){return we.status.call(t)}))}groupCall(t){return e(this,void 0,void 0,(function*(){return we.status.call(t)}))}accept(){return we.status.accept()}getCurrentCall(){var e;return(null===(e=be.callContext)||void 0===e?void 0:e.call)||null}end(){we.status.end()}muteMic(e){we.status.muteMic(e)}toggleSpeaker(e){we.status.toggleSpeaker(e)}muteCamera(e){we.status.muteCamera(e)}switchCamera(){we.status.switchCamera()}play(e){we.status.play(e)}onServerPacket(e){we.status.onServerPacket(e.name,e.data)}onRTCTimeout(){we.status.onRTCTimeout()}onRTCRemoteFlow(e){we.status.onRTCRemoteFlow(e)}onGoEasyDisconnected(){we.status.onGoEasyDisconnected()}onRTCRemoteMicChanged(e){we.status.onRTCRemoteMicChanged(e)}onRTCRemoteCameraChanged(e){we.status.onRTCRemoteCameraChanged(e)}}class Ae{static init(e){Q.init(e)}static call(e){return Ie.i().call(e)}static groupCall(e){return Ie.i().groupCall(e)}static accept(){return Ie.i().accept()}static currentCall(){return Ie.i().getCurrentCall()}static end(){Ie.i().end()}static muteMic(e){Ie.i().muteMic(e)}static toggleSpeaker(e){Ie.i().toggleSpeaker(e)}static muteCamera(e){Ie.i().muteCamera(e)}static switchCamera(){Ie.i().switchCamera()}static play(e){Ie.i().play(e)}static on(e,t){Ie.i().on(e,t)}static off(e,t){Ie.i().off(e,t)}}Ae.EVENT=U;export{Ae as default};
|
|
1
|
+
function e(e,t,i,s){return new(i||(i=Promise))((function(n,o){function r(e){try{c(s.next(e))}catch(e){o(e)}}function a(e){try{c(s.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}c((s=s.apply(e,t||[])).next())}))}var t;"function"==typeof SuppressedError&&SuppressedError,function(e){e.RTC_LOST="RTC_LOST",e.RTC_RECONNECT="RTC_RECONNECT",e.RTC_TIMEOUT="RTC_TIMEOUT",e.RTC_ACCEPTED="RTC_ACCEPTED",e.RECEIVED_RTC_REMOTE_FLOW="RECEIVED_RTC_REMOTE_FLOW",e.GOEASY_TIMEOUT="GOEASY_TIMEOUT",e.GOEASY_DISCONNECTED="GOEASY_DISCONNECTED",e.RTC_REMOTE_MIC_CHANGED="RTC_REMOTE_MIC_CHANGED",e.RTC_REMOTE_CAMERA_CHANGED="RTC_REMOTE_CAMERA_CHANGED"}(t||(t={}));var i={exports:{}};!function(e){function t(e){if(e)return function(e){for(var i in t.prototype)e[i]=t.prototype[i];return e}(e)}i.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function i(){this.off(e,i),t.apply(this,arguments)}return i.fn=t,this.on(e,i),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var i,s=this._callbacks["$"+e];if(!s)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var n=0;n<s.length;n++)if((i=s[n])===t||i.fn===t){s.splice(n,1);break}return this},t.prototype.emit=function(e){this._callbacks=this._callbacks||{};var t=[].slice.call(arguments,1),i=this._callbacks["$"+e];if(i)for(var s=0,n=(i=i.slice(0)).length;s<n;++s)i[s].apply(this,t);return this},t.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},t.prototype.hasListeners=function(e){return!!this.listeners(e).length}}();var s=i.exports,n={exports:{}},o="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(o){var r=new Uint8Array(16);n.exports=function(){return o(r),r}}else{var a=new Array(16);n.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),a[t]=e>>>((3&t)<<3)&255;return a}}for(var c=[],l=0;l<256;++l)c[l]=(l+256).toString(16).substr(1);var d,u,h=function(e,t){var i=t||0,s=c;return[s[e[i++]],s[e[i++]],s[e[i++]],s[e[i++]],"-",s[e[i++]],s[e[i++]],"-",s[e[i++]],s[e[i++]],"-",s[e[i++]],s[e[i++]],"-",s[e[i++]],s[e[i++]],s[e[i++]],s[e[i++]],s[e[i++]],s[e[i++]]].join("")},C=n.exports,T=h,m=0,E=0;var p=function(e,t,i){var s=t&&i||0,n=t||[],o=(e=e||{}).node||d,r=void 0!==e.clockseq?e.clockseq:u;if(null==o||null==r){var a=C();null==o&&(o=d=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==r&&(r=u=16383&(a[6]<<8|a[7]))}var c=void 0!==e.msecs?e.msecs:(new Date).getTime(),l=void 0!==e.nsecs?e.nsecs:E+1,h=c-m+(l-E)/1e4;if(h<0&&void 0===e.clockseq&&(r=r+1&16383),(h<0||c>m)&&void 0===e.nsecs&&(l=0),l>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");m=c,E=l,u=r;var p=(1e4*(268435455&(c+=122192928e5))+l)%4294967296;n[s++]=p>>>24&255,n[s++]=p>>>16&255,n[s++]=p>>>8&255,n[s++]=255&p;var v=c/4294967296*1e4&268435455;n[s++]=v>>>8&255,n[s++]=255&v,n[s++]=v>>>24&15|16,n[s++]=v>>>16&255,n[s++]=r>>>8|128,n[s++]=255&r;for(var R=0;R<6;++R)n[s+R]=o[R];return t||T(n)},v=n.exports,R=h;var f=function(e,t,i){var s=t&&i||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var n=(e=e||{}).random||(e.rng||v)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t)for(var o=0;o<16;++o)t[s+o]=n[o];return t||R(n)},g=p,y=f,_=y;_.v1=g,_.v4=y;var w=_;class k{support(){return!0}getParams(){return this.params}setData(e){this.active=e.a,this.data=e.d}preConnect(e){}postConnect(){}}const b=s;class I{constructor(){this.emitter=new b}on(e,t){return this.emitter.on(e,t),this}once(e,t){return this.emitter.once(e,t),this}off(e,t){return this.emitter.off(e,t),this}fire(e,t){return this.emitter.emit(e,t),this}}class A{constructor(){this.eventDriver=new I}on(e,t){this.eventDriver.on(e,t)}off(e,t){this.eventDriver.off(e,t)}fire(e,t){this.eventDriver.fire(e,t)}}let M=new class{isDef(e){return!this.isUndef(e)}isUndef(e){return null==e}isPrimitive(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e||"boolean"==typeof e}isObject(e){return null!==e&&"object"==typeof e}isPlainObject(e){return"[object Object]"===Object.prototype.toString.call(e)}isRegExp(e){return"[object RegExp]"===Object.prototype.toString.call(e)}isValidArrayIndex(e){let t=parseFloat(String(e));return t>=0&&Math.floor(t)===t&&isFinite(e)}isString(e){return"string"==typeof e}isNumber(e){return"number"==typeof e}isStringOrNumber(e){return this.isString(e)||this.isNumber(e)}isArray(e){return"[object Array]"===Object.prototype.toString.call(e)}isEmpty(e){return this.isArray(e)?0===e.length:this.isObject(e)?!this.isDef(e):!this.isNumber(e)&&(this.isString(e)?""===e.trim():!this.isDef(e))}isNative(e){return"function"==typeof e&&/native code/.test(e.toString())}isFunction(e){return"function"==typeof e}isBoolean(e){return"boolean"==typeof e}isTrue(e){return!0===e}isFalse(e){return!1===e}isNull(e){return null===e}};const N=s;class S{constructor(){this.emitter=new N}on(e,t){if(!M.isString(e))throw Error("event require a string.");if(!M.isFunction(t))throw Error("callback must be a function");this.emitter.on(e,t)}fire(e,t){this.emitter.emit(e,t)}off(e,t){this.emitter.off(e,t)}}class D{static init(e,t,i,s,n,o){this.Socket=e,this.N=t,this.Member=i,this.v=s,this.Platform=n,this.GModules=o}}const L=w;class O{static get(){return L.v1().replace(/-/g,"")}}var P,G,U;(G=P||(P={})).WRITE="WRITE",G.READ="READ",G.NONE="NONE";class V{constructor(e){this.permission=P.NONE,this.singleTimeout=0,this.totalTimeout=0,this.startTime=0,this.complete=!1,this.retried=0,this.unique=!1,this.uuid=O.get(),this.name=e.name,this.params=e.params,this.permission=e.permission,this.totalTimeout=e.totalTimeout,this.singleTimeout=e.singleTimeout,e.unique&&(this.unique=e.unique),this.success=t=>{this.complete||(this.end(),e.success(t))},this.fail=t=>{this.complete||(this.end(),e.fail(t))}}start(){this.startTime=Date.now(),this.initAutoTimeout()}end(){this.complete=!0,clearTimeout(this.timeoutHandler)}initAutoTimeout(){this.timeoutHandler=setTimeout((()=>{this.complete||this.fail({resultCode:408,content:"Host unreachable or timeout"})}),this.totalTimeout)}}class j extends A{static init(){this.i=new j}}class q{constructor(){this.callees=new Array}getDuration(){return Math.floor((Date.now()-this.acceptedAt)/1e3)}}class x{constructor(e,t,i){this.micMuted=!1,this.cameraMuted=!1,this.id=e,this.data=t,this.status=i}}class F{constructor(e){this.call=new q,this.call=e}}class K{static init(){this.eventCenter=new S}static on(e,t){this.eventCenter.on(e,t)}static fire(e,t){this.eventCenter.fire(e,t)}static off(e,t){this.eventCenter.off(e,t)}}!function(e){e.RING="RING",e.USER_RANG="USER_RANG",e.USER_QUIT="USER_QUIT",e.USER_ACCEPTED="USER_ACCEPTED",e.CALL_ENDED="CALL_ENDED",e.USER_MIC_CHANGED="USER_MIC_CHANGED",e.USER_CAMERA_CHANGED="USER_CAMERA_CHANGED"}(U||(U={}));class H{static setStatus(e){this.status&&this.status.destroy(),this.status=e,be.callContext.call.status=e.name()}static clearStatus(){this.status&&(this.status.destroy(),this.status=null)}}var Q;!function(e){e[e.AUDIO=0]="AUDIO",e[e.VIDEO=1]="VIDEO"}(Q||(Q={}));class B extends k{static init(e){e.c(D),this.module=new B,this.module.name=this.RTC_MODULE_NAME;let t=null;if(this.supportApp()){let e=uni.requireNativePlugin("RTCClientPlugin");e&&(t=e.v())}this.module.params={v:{n:"goeasy-rtc",v:"0.5.0",npv:t}},D.GModules.initModule(this.module)}static check(){if(!this.module)throw new Error("Please init GRTC first.");if(!this.module.active)throw new Error("RTC unavailable. Please confirm if your GoEasy application supports RTC or contact GoEasy team.");if(!this.supportApp()&&!this.supportBrowser())throw new Error("GRTC is only supported in Android and iOS apps developed with UniApp and Browsers");if(!this.supportGoEasyVersion())throw new Error("GRTC is only supported in GoEasy SDK version 2.10.0 or later")}static supportGoEasyVersion(){return D.v.localeCompare("2.10.0",void 0,{numeric:!0,sensitivity:"base"})>=0}static supportApp(){return[D.Platform.type.UNI_ANDROID,D.Platform.type.UNI_IOS].includes(D.Platform.current)}static supportBrowser(){return D.Platform.type.BROWSER===D.Platform.current}static supportWebview(){return"undefined"!=typeof window&&void 0!==window.GRTCBridge}support(){return B.supportGoEasyVersion()&&(B.supportApp()||B.supportBrowser()||B.supportWebview())}postConnect(){j.init(),K.init(),Ae.init()}}B.RTC_MODULE_NAME="GRTC";let W=new class{isDef(e){return!this.isUndef(e)}isUndef(e){return null==e}isPrimitive(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e||"boolean"==typeof e}isObject(e){return null!==e&&"object"==typeof e}isString(e){return"string"==typeof e}isNumber(e){return"number"==typeof e}isStringOrNumber(e){return this.isString(e)||this.isNumber(e)}isArray(e){return"[object Array]"===Object.prototype.toString.call(e)}isEmpty(e){return this.isArray(e)?0===e.length:this.isObject(e)?!this.isDef(e):!this.isNumber(e)&&(this.isString(e)?""===e.trim():!this.isDef(e))}isNative(e){return"function"==typeof e&&/native code/.test(e.toString())}isFunction(e){return"function"==typeof e}};const $=new class{validateId(e,t){if(W.isEmpty(e))throw{code:400,content:` ${t} is required.`};if(!W.isStringOrNumber(e))throw{code:400,content:`TypeError: ${t} require string or number.`}}validateNotification(e){if(e){if(!W.isObject(e))throw{code:400,content:"TypeError: notification requires an object."};{if(t(e,"title",32),t(e,"body",50),W.isDef(e.sound)&&!W.isString(e.sound))throw{code:400,content:"notification.sound must be a string"};if(W.isDef(e.badge)&&!W.isString(e.badge))throw{code:400,content:"notification.badge must be a string"};e.badge=e.badge||"0";let s=e.vendorOptions;W.isObject(s)&&(i(s,"huawei","category","string"),i(s,"xiaomi","channel_id","string"),i(s,"oppo","channel_id","string"),i(s,"oppo","category","string"),i(s,"vivo","classification","number"),i(s,"vivo","category","string"))}}function t(e,t,i){if(!(W.isString(e[t])&&e[t].length<=i))throw{code:400,content:`notification.${t} must be a string of no more than ${i} characters`}}function i(e,t,i,s){let n=e[t];if(W.isObject(n)&&W.isDef(n[i])){let e={code:400,content:`notification.vendorOptions.${t}.${i} require a ${s}}`},o=n[i];if("string"===s&&!W.isString(o))throw e;if("number"===s&&!W.isNumber(o))throw e}}}validateObject(e,t){if(W.isUndef(e)||!W.isObject(e))throw{code:400,content:t+" must be an object."}}validateString(e,t){if(W.isUndef(e)||!W.isString(e))throw{code:400,content:t+" must be a string."}}};var Y,J,X,z,Z,ee;!function(e){e.ALL_BUSY="ALL_BUSY",e.DIAL_FAILED="DIAL_FAILED",e.CANCELLED="CANCELLED",e.REJECTED="REJECTED",e.HUNG_UP="HUNG_UP",e.RTC_DISCONNECTED="RTC_DISCONNECTED",e.GOEASY_DISCONNECTED="GOEASY_DISCONNECTED",e.HANDLED_ON_ANOTHER_DEVICE="HANDLED_ON_ANOTHER_DEVICE",e.RING_TIMEOUT="RING_TIMEOUT",e.ACCEPT_FAILED="ACCEPT_FAILED",e.DIAL_TIMEOUT="DIAL_TIMEOUT"}(Y||(Y={}));class te{}class ie{constructor(e,t){this.joined=!1,this.token=t,this.video=e===Q.VIDEO,this.userId=D.Socket.user().id}play(e){}initLocal(){}}class se extends ie{constructor(e,i,s){super(i,s),this.client=e,this.token.video=this.video,this.token.userId=this.userId,this.client.createRTCClient(this.token),plus.globalEvent.addEventListener("connectionLost",(()=>{j.i.fire(t.RTC_LOST)})),plus.globalEvent.addEventListener("connectionRecovery",(e=>{j.i.fire(t.RTC_RECONNECT)})),plus.globalEvent.addEventListener("receivedRemoteFlow",(e=>{j.i.fire(t.RECEIVED_RTC_REMOTE_FLOW,e)})),plus.globalEvent.addEventListener("remoteMicChanged",(e=>{j.i.fire(t.RTC_REMOTE_MIC_CHANGED,e)})),plus.globalEvent.addEventListener("remoteCameraChanged",(e=>{j.i.fire(t.RTC_REMOTE_CAMERA_CHANGED,e)}))}destroy(){plus.globalEvent.removeEventListener("connectionLost"),plus.globalEvent.removeEventListener("connectionRecovery"),plus.globalEvent.removeEventListener("receivedRemoteFlow"),plus.globalEvent.removeEventListener("remoteMicChanged"),plus.globalEvent.removeEventListener("remoteCameraChanged"),this.joined&&(this.leave(),this.joined=!1),this.client.destroyEngine()}join(){return new Promise(((e,t)=>{this.client.joinChannel((()=>{this.userId,this.token.callId,this.joined=!0,e()}),(e=>{this.userId,this.token.callId,t({code:400,content:"Failed to join Channel, error code:"+e})}))}))}push(){this.video?this.client.callVideo():this.client.callAudio()}leave(){this.client.leaveChannel()}accept(){return e(this,void 0,void 0,(function*(){yield this.join(),this.push()}))}muteMic(e){this.client.muteMic({enabled:e})}toggleSpeaker(e){this.client.enableSpeaker({enabled:e})}muteCamera(e){this.client.muteCamera({enabled:e})}switchCamera(){this.client.switchCamera()}}class ne extends te{constructor(){super(),this.nativePlugin=uni.requireNativePlugin("RTCClientPlugin"),this.nativePlugin||console.warn("Please configure GoEasy RTC native plugin first: https://www.goeasy.io")}createClient(t,i){return e(this,void 0,void 0,(function*(){return new se(this.nativePlugin,t,i)}))}requestPermission(e){return new Promise(((t,i)=>{Q.VIDEO===e?this.nativePlugin.requestVideoCallPermission((e=>{200===e?t():i({code:403,content:"Failed to request video call permission, error code:"+e})})):Q.AUDIO===e?this.nativePlugin.requestVoiceCallPermission((e=>{200===e?t():i({code:403,content:"Failed to request voice call permission, error code:"+e})})):i({code:400,content:"Unsupported media type"})}))}}!function(e){e.QN="QN",e.ALI="ALI",e.TX="TX",e.LK="LK"}(J||(J={}));class oe{constructor(e,t){this.userId=e,this.muted=t}}class re extends ie{constructor(e,t){super(e,t),this.viewObservers=new WeakMap}listenCustomAttributes(e){if(this.viewObservers.has(e))return;const t=new MutationObserver((t=>{t.forEach((t=>{const i=t.oldValue,s=e.getAttribute("userId");W.isEmpty(s)||s===i||(this.userId===s?this.playLocal(e):this.playRemote(s,e))}))}));t.observe(e,{attributes:!0,attributeOldValue:!0,attributeFilter:["userid"]}),this.viewObservers.set(e,t)}getView(e){const t=document.getElementsByClassName("grtc-video");for(let i=0;i<t.length;i++){const s=t[i];if(s.getAttribute("userId")===e)return s}}initLocalTracks(){}play(t){return e(this,void 0,void 0,(function*(){if(this.video){const e=this.getView(t);this.userId===t?(yield this.initLocalTracks(),this.listenCustomAttributes(e),yield this.playLocal(e)):(this.listenCustomAttributes(e),yield this.playRemote(t,e))}else this.playRemoteMic()}))}playRemoteMic(){}}class ae extends re{constructor(e,t){super(e,t),this.localTracks=[],this.remoteTracks=new Map;this.QNRTC=(()=>{try{return require("qnweb-rtc").default||require("qnweb-rtc")}catch(e){throw new Error("Please run npm install qnweb-rtc")}})(),this.QNRTC.setLogLevel("NONE"),this.client=this.QNRTC.createClient(),this.initListeners()}initListeners(){this.client.on("connection-state-changed",((e,i)=>{"RECONNECTED"===e?j.i.fire(t.RTC_RECONNECT):"DISCONNECTED"===e&&j.i.fire(t.RTC_LOST)})),this.client.on("user-published",((e,t)=>{this.subscribe(e,t)}))}listenRemoteTrackMutedChanged(e){e.on("mute-state-changed",(i=>{let s=e.isAudio(),n=e.userID,o=s?t.RTC_REMOTE_MIC_CHANGED:t.RTC_REMOTE_CAMERA_CHANGED;j.i.fire(o,new oe(n,i))}))}subscribe(i,s){return e(this,void 0,void 0,(function*(){const e=yield this.client.subscribe(s);if(e.audioTracks.length>0&&(this.listenRemoteTrackMutedChanged(e.audioTracks[0]),e.audioTracks[0]._isMuted&&be.muteMemberMic(i,!0)),e.videoTracks.length>0&&(this.listenRemoteTrackMutedChanged(e.videoTracks[0]),e.videoTracks[0]._isMuted&&be.muteMemberCamera(i,!0)),this.remoteTracks.set(i,e),j.i.fire(t.RECEIVED_RTC_REMOTE_FLOW,{userId:i}),!1===this.video)this.playRemoteMic();else{let e=this.getView(i);e&&this.playRemote(i,e)}}))}initLocal(){return e(this,void 0,void 0,(function*(){yield this.initLocalTracks()}))}join(){return e(this,void 0,void 0,(function*(){const e=this.token.vendorToken.token;yield this.client.join(e),this.joined=!0}))}push(){return e(this,void 0,void 0,(function*(){yield this.client.publish(this.localTracks)}))}accept(){return e(this,void 0,void 0,(function*(){yield this.join(),yield this.push()}))}initLocalTracks(){return e(this,void 0,void 0,(function*(){if(!(this.localTracks.length>0))if(this.video){const e=this.token.vendorToken.videoEncoderConfig;this.localTracks=yield this.QNRTC.createMicrophoneAndCameraTracks({videoConfig:{encoderConfig:{width:e.w,height:e.h,frameRate:e.fps,bitrate:e.br}}})}else this.localTracks=[yield this.QNRTC.createMicrophoneAudioTrack()]}))}playRemoteMic(){const e=document.getElementsByClassName("grtc-audio")[0];e&&this.remoteTracks.forEach(((t,i)=>{for(const i of t.audioTracks)i.play(e)}))}playLocal(e){for(const t of this.localTracks)t.isAudio()||t.play(e,{mirror:!0})}playRemote(e,t){const i=this.remoteTracks.get(e);if(i)for(const e of[...i.videoTracks,...i.audioTracks])e.play(t)}destroy(){this.joined&&this.leave(),this.releaseMediaTracks()}releaseMediaTracks(){for(const e of this.localTracks)e.destroy();this.localTracks=[],this.remoteTracks.clear()}leave(){return e(this,void 0,void 0,(function*(){yield this.client.leave()}))}requestPermission(t){return e(this,void 0,void 0,(function*(){}))}toggleSpeaker(e){throw new Error("not support.")}muteCamera(e){for(const t of this.localTracks)t.isVideo()&&t.setMuted(e)}muteMic(e){for(const t of this.localTracks)t.isAudio()&&t.setMuted(e)}switchCamera(){throw new Error("not support.")}}class ce extends re{constructor(e,t){super(e,t),this.localTracks=[],this.remoteTracks=new Map,this.isFrontFacing=!0,this.LiveKitRTC=this.loadLiveKitRTC(),this.resolution=this.LiveKitRTC.VideoPresets.h720.resolution;const i=new this.LiveKitRTC.DefaultReconnectPolicy([0,1e3,4e3,9e3,16e3]);this.client=new this.LiveKitRTC.Room({adaptiveStream:!1,dynacast:!1,videoCaptureDefaults:{resolution:this.resolution},reconnectPolicy:i}),this.initListeners()}loadLiveKitRTC(){try{return require("livekit-client")}catch(e){throw new Error("Please run npm install livekit-client@2.5.10")}}initListeners(){this.client.on(this.LiveKitRTC.RoomEvent.Reconnected,(()=>{j.i.fire(t.RTC_RECONNECT)})),this.client.on(this.LiveKitRTC.RoomEvent.Disconnected,(()=>{j.i.fire(t.RTC_LOST)})),this.client.on(this.LiveKitRTC.RoomEvent.TrackPublished,((e,t)=>{t.identity,e.setSubscribed(!0)})),this.client.on(this.LiveKitRTC.RoomEvent.ParticipantConnected,(e=>{e.identity,this.listenRemoteParticipant(e)})),this.client.on(this.LiveKitRTC.RoomEvent.TrackSubscribed,((e,t,i)=>{i.identity,this.handleTrackSubscribed(e,t,i)}))}handleTrackSubscribed(e,i,s){let n=s.identity;if(e.kind===this.LiveKitRTC.Track.Kind.Video||e.kind===this.LiveKitRTC.Track.Kind.Audio)if(this.video?e.kind===this.LiveKitRTC.Track.Kind.Video&&j.i.fire(t.RECEIVED_RTC_REMOTE_FLOW,{userId:n}):j.i.fire(t.RECEIVED_RTC_REMOTE_FLOW,{userId:n}),this.updateRemoteTracks(n,e),this.video){let e=this.getView(n);e&&this.playRemote(n,e)}else this.playRemoteMic()}updateRemoteTracks(e,t){let i=this.remoteTracks.get(e)||[];i.push(t),this.remoteTracks.set(e,i)}listenRemoteParticipant(e){const t=e.identity;e.on(this.LiveKitRTC.RoomEvent.TrackMuted,(e=>this.onTrackMuted(e,t))),e.on(this.LiveKitRTC.RoomEvent.TrackUnmuted,(e=>this.onTrackUnmuted(e,t)))}onTrackMuted(e,i){let s=e.kind;e.kind,s===this.LiveKitRTC.Track.Kind.Video?j.i.fire(t.RTC_REMOTE_CAMERA_CHANGED,new oe(i,!0)):s===this.LiveKitRTC.Track.Kind.Audio&&j.i.fire(t.RTC_REMOTE_MIC_CHANGED,new oe(i,!0))}onTrackUnmuted(e,i){let s=e.kind;s===this.LiveKitRTC.Track.Kind.Video?j.i.fire(t.RTC_REMOTE_CAMERA_CHANGED,new oe(i,!1)):s===this.LiveKitRTC.Track.Kind.Audio&&j.i.fire(t.RTC_REMOTE_MIC_CHANGED,new oe(i,!1))}initLocal(){return e(this,void 0,void 0,(function*(){yield this.initLocalTracks()}))}join(){return e(this,void 0,void 0,(function*(){const e=this.token.vendorToken;yield this.client.connect(e.url,e.token,{autoSubscribe:!1}),this.joined=!0}))}push(){return e(this,void 0,void 0,(function*(){yield Promise.all(this.localTracks.map((e=>this.client.localParticipant.publishTrack(e,{simulcast:!1})))),this.client.remoteParticipants.forEach((e=>{e.trackPublications.forEach((e=>e.setSubscribed(!0))),this.listenRemoteParticipant(e)}))}))}accept(){return e(this,void 0,void 0,(function*(){yield this.join(),yield this.push()}))}initLocalTracks(){return e(this,void 0,void 0,(function*(){const e=yield this.LiveKitRTC.createLocalAudioTrack({echoCancellation:!0,noiseSuppression:!0});if(this.localTracks.push(e),this.video){const e=yield this.LiveKitRTC.createLocalVideoTrack({facingMode:"user"});this.localTracks.push(e)}}))}playRemoteMic(){const e=document.getElementsByClassName("grtc-audio")[0];if(e)for(const t of this.remoteTracks.values())for(const i of t){let t=i.attach();e.appendChild(t)}}playLocal(e){this.playTrack(this.localTracks,e)}playRemote(e,t){const i=this.remoteTracks.get(e);i&&this.playTrack(i,t)}playTrack(e,t){for(const i of e){let e,s=i.kind,n=i.attach();s===this.LiveKitRTC.Track.Kind.Video?(n.style.width="100%",n.style.height="100%",n.style.objectFit="cover",e=t.querySelector("video")):s===this.LiveKitRTC.Track.Kind.Audio&&(e=t.querySelector("audio")),e?e.replaceWith(n):t.appendChild(n)}}destroy(){this.joined&&this.leave(),this.releaseMediaTracks()}releaseMediaTracks(){for(const e of this.localTracks)e.detach(),e.stop();this.localTracks=[],this.remoteTracks.clear()}leave(){return e(this,void 0,void 0,(function*(){yield this.client.disconnect()}))}toggleSpeaker(e){throw new Error("not support.")}muteCamera(e){for(const t of this.localTracks)t.kind===this.LiveKitRTC.Track.Kind.Video&&this.client.localParticipant.setCameraEnabled(!e)}muteMic(e){for(const t of this.localTracks)t.kind===this.LiveKitRTC.Track.Kind.Audio&&this.client.localParticipant.setMicrophoneEnabled(!e)}switchCamera(){var e;const t=this.client.localParticipant.getTrackPublication(this.LiveKitRTC.Track.Source.Camera);if(!t)return;this.isFrontFacing=!this.isFrontFacing;const i={resolution:this.resolution,facingMode:this.isFrontFacing?"user":"environment"};null===(e=t.videoTrack)||void 0===e||e.restartTrack(i)}}class le extends re{constructor(e,t){super(e,t),this.localTracks=[],this.fired={},this.mcuNotSubscribed=!0;this.DingRTC=(()=>{try{return require("dingrtc").default||require("dingrtc")}catch(e){throw new Error("Please run npm install dingrtc")}})(),this.DingRTC.setLogLevel("none");if(!this.DingRTC.checkSystemRequirements())throw new Error("当前浏览器不支持dingrtc");this.client=this.DingRTC.createClient(),this.initListeners()}initListeners(){this.client.on("connection-state-change",((e,i,s)=>{"reconnecting"===i&&"connected"===e?j.i.fire(t.RTC_RECONNECT):"disconnected"===e&&j.i.fire(t.RTC_LOST)})),this.client.on("user-published",((e,i)=>{e.userId,this.subscribe(e.userId,i),this.fired[e.userId]||(this.fired[e.userId]=!0,e.userId,j.i.fire(t.RECEIVED_RTC_REMOTE_FLOW,{userId:e.userId}))})),this.client.on("user-info-updated",((e,i)=>{const s={"mute-audio":{event:t.RTC_REMOTE_MIC_CHANGED,muted:!0},"unmute-audio":{event:t.RTC_REMOTE_MIC_CHANGED,muted:!1},"mute-video":{event:t.RTC_REMOTE_CAMERA_CHANGED,muted:!0},"unmute-video":{event:t.RTC_REMOTE_CAMERA_CHANGED,muted:!1}}[i];s&&j.i.fire(s.event,new oe(e,s.muted))}))}initLocal(){return e(this,void 0,void 0,(function*(){yield this.initLocalTracks()}))}initLocalTracks(){return e(this,void 0,void 0,(function*(){if(this.localTracks.length>0)return;const e=yield this.DingRTC.createMicrophoneAudioTrack();this.localTracks.push(e);const t=this.token.vendorToken.videoEncoderConfig;if(this.video){const e=yield this.DingRTC.createCameraVideoTrack({dimension:`VD_${t.w}x${t.h}`,frameRate:t.fps});this.localTracks.push(e)}}))}accept(){return e(this,void 0,void 0,(function*(){yield this.join(),yield this.push()}))}join(){return e(this,void 0,void 0,(function*(){const e=this.token.vendorToken,t={appId:e.appId,channel:this.token.callId.toString(),token:e.token,uid:this.userId,userName:this.userId};yield this.client.join(t),this.joined=!0,yield this.subscribeRemoteUser()}))}subscribeRemoteUser(){return e(this,void 0,void 0,(function*(){const e=this.client.remoteUsers;if(!(e.length<=1))for(const i of e){const{userId:e,hasAudio:s,hasVideo:n,audioMuted:o,videoMuted:r}=i;n&&(yield this.subscribe(i.userId,"video")),s&&(yield this.subscribe(i.userId,"audio")),o&&be.muteMemberMic(i.userId,!0),r&&be.muteMemberCamera(i.userId,!0),j.i.fire(t.RECEIVED_RTC_REMOTE_FLOW,{userId:i.userId})}}))}subscribe(t,i){return e(this,void 0,void 0,(function*(){if("video"===i){const e=yield this.client.subscribe(t,"video"),i=this.getView(t);i&&e.play(i)}else if(this.mcuNotSubscribed){this.mcuNotSubscribed=!1;(yield this.client.subscribe("mcu","audio")).play()}}))}push(){return e(this,void 0,void 0,(function*(){yield this.client.publish(this.localTracks)}))}playLocal(e){for(const t of this.localTracks)"video"===t.trackMediaType&&t.play(e,{mirror:!0})}playRemote(e,t){var i;const s=this.client.remoteUsers.find((t=>t.userId===e));null===(i=null==s?void 0:s.videoTrack)||void 0===i||i.play(t)}destroy(){this.joined&&this.leave(),this.releaseMediaTracks()}releaseMediaTracks(){for(const e of this.localTracks)e.close();this.localTracks=[]}leave(){return e(this,void 0,void 0,(function*(){yield this.client.leave()}))}requestPermission(t){return e(this,void 0,void 0,(function*(){}))}toggleSpeaker(e){throw new Error("not support.")}muteCamera(e){for(const t of this.localTracks)"video"===t.trackMediaType&&t.setMuted(e)}muteMic(e){for(const t of this.localTracks)"audio"===t.trackMediaType&&t.setMuted(e)}switchCamera(){throw new Error("not support.")}}class de extends re{constructor(e,t){super(e,t),this.videoAvailable={},this.audioAvailable={};this.TRTC=(()=>{try{return require("trtc-sdk-v5").default||require("trtc-sdk-v5")}catch(e){throw new Error("Please run npm install trtc-sdk-v5")}})(),this.TRTC.setLogLevel(5),this.client=this.TRTC.create(),this.initListeners()}initListeners(){this.client.on(this.TRTC.EVENT.CONNECTION_STATE_CHANGED,(({prevState:e,state:i})=>{"reconnecting"===e&&"connected"===i?j.i.fire(t.RTC_RECONNECT):"DISCONNECTED"===i&&j.i.fire(t.RTC_LOST)})),this.client.on(this.TRTC.EVENT.REMOTE_AUDIO_AVAILABLE,(({userId:e})=>{void 0===this.audioAvailable[e]?(!1===this.video&&j.i.fire(t.RECEIVED_RTC_REMOTE_FLOW,{userId:e}),this.audioAvailable[e]=!0):(this.audioAvailable[e]=!0,this.client.muteRemoteAudio(e,!1),j.i.fire(t.RTC_REMOTE_MIC_CHANGED,new oe(e,!1)))})),this.client.on(this.TRTC.EVENT.REMOTE_AUDIO_UNAVAILABLE,(({userId:e})=>{this.audioAvailable[e]=!1,this.client.muteRemoteAudio(e,!0),j.i.fire(t.RTC_REMOTE_MIC_CHANGED,new oe(e,!0))})),this.client.on(this.TRTC.EVENT.REMOTE_VIDEO_AVAILABLE,(({userId:e,streamType:i})=>{const s=this.getView(e);this.client.startRemoteVideo({userId:e,streamType:i,view:s}),void 0===this.videoAvailable[e]?(this.videoAvailable[e]=!0,j.i.fire(t.RECEIVED_RTC_REMOTE_FLOW,{userId:e})):(this.videoAvailable[e]=!0,j.i.fire(t.RTC_REMOTE_CAMERA_CHANGED,new oe(e,!1)))})),this.client.on(this.TRTC.EVENT.REMOTE_VIDEO_UNAVAILABLE,(({userId:e})=>{this.videoAvailable[e]=!1,j.i.fire(t.RTC_REMOTE_CAMERA_CHANGED,new oe(e,!0))}))}initLocal(){return e(this,void 0,void 0,(function*(){if(!(yield this.TRTC.isSupported()).result)throw new Error("当前浏览器不支持trtc");yield this.initLocalTracks()}))}initLocalTracks(){return e(this,void 0,void 0,(function*(){if(this.client.getAudioTrack()||(yield this.client.startLocalAudio({publish:!1})),this.video){if(!this.client.getVideoTrack()){const e=this.getView(this.userId),t=this.token.vendorToken.videoEncoderConfig;yield this.client.startLocalVideo({view:e,publish:!1,option:{profile:{width:t.w,height:t.h,frameRate:t.fps,bitrate:t.br}}})}}}))}push(){return e(this,void 0,void 0,(function*(){if(yield this.client.updateLocalAudio({publish:!0}),this.video){const e=this.getView(this.userId);yield this.client.updateLocalVideo({view:e,publish:!0})}}))}join(){return e(this,void 0,void 0,(function*(){const e=this.token.vendorToken,t={strRoomId:this.token.callId.toString(),sdkAppId:e.sdkAppId,userId:this.userId,userSig:e.userSig};yield this.client.enterRoom(t),this.joined=!0}))}accept(){return e(this,void 0,void 0,(function*(){yield this.join(),yield this.push()}))}playLocal(t){return e(this,void 0,void 0,(function*(){yield this.client.updateLocalVideo({view:t})}))}playRemote(t,i){return e(this,void 0,void 0,(function*(){this.videoAvailable[t]?yield this.client.updateRemoteVideo({view:i,userId:t,streamType:this.TRTC.TYPE.STREAM_TYPE_MAIN}):yield this.client.startRemoteVideo({view:i,userId:t,streamType:this.TRTC.TYPE.STREAM_TYPE_MAIN})}))}destroy(){this.joined&&this.leave(),this.releaseMediaTracks()}releaseMediaTracks(){this.client.stopLocalAudio(),this.video&&this.client.stopLocalVideo(),this.client.stopRemoteVideo({userId:"*"})}leave(){return e(this,void 0,void 0,(function*(){yield this.client.exitRoom()}))}requestPermission(t){return e(this,void 0,void 0,(function*(){}))}toggleSpeaker(e){throw new Error("not support.")}muteCamera(e){this.client.updateLocalVideo({mute:e})}muteMic(e){this.client.updateLocalAudio({mute:e})}switchCamera(){throw new Error("not support.")}}class ue extends te{createClient(t,i){return e(this,void 0,void 0,(function*(){let e,s=i.vendor;if(J.QN===s)e=new ae(t,i);else if(J.LK===s)e=new ce(t,i);else if(J.ALI===s)e=new le(t,i);else{if(J.TX!==s)throw new Error("rtc vendor not support");e=new de(t,i)}return yield e.initLocal(),e}))}requestPermission(t){return new Promise(((i,s)=>e(this,void 0,void 0,(function*(){if(navigator.permissions&&navigator.permissions.query){if("denied"===(yield navigator.permissions.query({name:"microphone"})).state&&s({code:403,content:"Failed to request microphone permission"}),t===Q.VIDEO){"denied"===(yield navigator.permissions.query({name:"camera"})).state&&s({code:403,content:"Failed to request camera permission"})}}i()}))))}}class he{constructor(e,t,i){this.name=e,this.callId=t,this.data=i}static createCallCommand(e,t,i){let s={calleeIds:e.callees.map((e=>e.id)),mediaType:i.mediaType,groupId:i.groupId,callId:t};return i.notification&&(s.notification=i.notification),new he(X.CALL,t,s)}}!function(e){e.CALL="CALL",e.QUIT="QUIT",e.BUSY="BUSY",e.ACCEPT="ACCEPT",e.RANG="RANG",e.HANGUP="HANGUP",e.CANCEL="CANCEL",e.REJECT="REJECT",e.RTC_DISCONNECT="RTC_DISCONNECT",e.GET_TOKEN="GET_TOKEN"}(X||(X={})),function(e){e.RTC_CMD="RTC_CMD",e.RTC_PKT="RTC_PKT"}(z||(z={})),function(e){e[e.connect=3e3]="connect",e[e.reconnectionDelayMax=3e3]="reconnectionDelayMax",e[e.commonQuerySingle=2500]="commonQuerySingle",e[e.commonQueryTotal=12e3]="commonQueryTotal",e[e.commonRequestSingle=1700]="commonRequestSingle",e[e.commonRequestTotal=12e3]="commonRequestTotal",e[e.commonInfiniteSingle=1700]="commonInfiniteSingle",e[e.commonInfiniteTotal=864e5]="commonInfiniteTotal"}(Z||(Z={}));class Ce extends ie{constructor(e,t){super(e,t),this._gnCallbacks={},this.CALLBACK_PREFIX="grtc_",this.token.video=this.video,this.token.userId=this.userId,window.GRTCBridge.createRTCClient(JSON.stringify(this.token)),window.handleGRTCCallback=this.handleGRTCCallback.bind(this),window.handleGRTCEvent=this.handleGRTCEvent.bind(this),window.addEventListener("beforeunload",(()=>this.cleanup()))}handleGRTCEvent(e,i){const s=JSON.parse(i);switch(e){case"connectionLost":j.i.fire(t.RTC_LOST);break;case"connectionRecovery":j.i.fire(t.RTC_RECONNECT);break;case"receivedRemoteFlow":j.i.fire(t.RECEIVED_RTC_REMOTE_FLOW,s);break;case"remoteMicChanged":j.i.fire(t.RTC_REMOTE_MIC_CHANGED,s);break;case"remoteCameraChanged":j.i.fire(t.RTC_REMOTE_CAMERA_CHANGED,s);break;default:console.warn(`[GRTC] 未处理的事件 ${e}`)}}static requestPermission(e){return new Promise(((t,i)=>{const s=`grtc_${Date.now()}`;window.handleGRTCPermissionCallback=(e,n,o)=>{if(e===s)try{n?i({code:403,content:"Failed to request call permission, error code: "+JSON.parse(n).code}):t()}catch(e){i({code:400,errorMsg:`JSON parse error: ${e.message}`})}finally{delete window.handleGRTCPermissionCallback}},e===Q.VIDEO?window.GRTCBridge.requestVideoCallPermission(s):window.GRTCBridge.requestVoiceCallPermission(s)}))}accept(){return e(this,void 0,void 0,(function*(){yield this.join(),this.push()}))}destroy(){window.handleGRTCEvent=null,window.handleGRTCCallback=null,this.joined&&(this.leave(),this.joined=!1),window.GRTCBridge.destroyEngine()}join(){return new Promise(((e,t)=>{const i=this.generateCallbackId();this.gnCallbacks[i]={resolve:()=>{this.joined=!0,this.userId,this.token.callId,e()},reject:e=>{console.warn(`user{${this.userId}} failed to join channel{${this.token.callId}}`,e),t(e)}};try{window.GRTCBridge.joinChannel(i)}catch(e){delete this.gnCallbacks[i],t({code:500,errorMsg:`Native call failed: ${e.message}`})}}))}leave(){window.GRTCBridge.leaveChannel()}muteCamera(e){window.GRTCBridge.muteCamera(e)}muteMic(e){window.GRTCBridge.muteMic(e)}push(){this.video?window.GRTCBridge.callVideo():window.GRTCBridge.callAudio()}switchCamera(){window.GRTCBridge.switchCamera()}toggleSpeaker(e){window.GRTCBridge.enableSpeaker(e)}generateCallbackId(){return`${this.CALLBACK_PREFIX}${Date.now()}_${Math.random().toString(36).substring(2,10)}`}cleanup(){Object.keys(this.gnCallbacks).forEach((e=>{delete this.gnCallbacks[e]}))}get gnCallbacks(){return this._gnCallbacks||(this._gnCallbacks={}),this._gnCallbacks}handleGRTCCallback(e,t,i){var s,n;const o=this.gnCallbacks[e];if(o)try{t?null===(s=o.reject)||void 0===s||s.call(o,JSON.parse(t)):null===(n=o.resolve)||void 0===n||n.call(o,i)}catch(e){o.reject({code:400,errorMsg:`JSON parse error: ${e.message}`})}finally{delete this.gnCallbacks[e]}}}class Te extends te{createClient(t,i){return e(this,void 0,void 0,(function*(){return this.client=new Ce(t,i),this.client}))}requestPermission(e){return Ce.requestPermission(e)}}class me{static init(){B.supportApp()?this.rtcPlugin=new ne:void 0!==window.GRTCBridge?this.rtcPlugin=new Te:this.rtcPlugin=new ue}static initClient(t,i){return e(this,void 0,void 0,(function*(){let e=yield this.getNewToken(i);return this.vendorClient=yield this.rtcPlugin.createClient(t,e),e.callId}))}static getNewToken(t){return e(this,void 0,void 0,(function*(){let e={name:X.GET_TOKEN};return t&&(e.callId=t),new Promise(((t,i)=>{let s=new V({name:z.RTC_CMD,params:e,permission:P.WRITE,singleTimeout:Z.commonRequestSingle,totalTimeout:Z.commonRequestTotal,success:e=>{t(e.content)},fail:e=>{i(e)}});D.Socket.e(s)}))}))}}class Ee{onRTCRemoteFlow(e){}onUserAcceptPacket(e){}onUserRang(t){return e(this,void 0,void 0,(function*(){be.updateMemberStatus(t.callerId,"Ringing");const e=yield D.Member.i.getData(t.callerId),i={id:t.callerId,data:e.get(t.callerId)};K.fire(U.USER_RANG,{user:i})}))}onUserQuit(t){return e(this,void 0,void 0,(function*(){return Promise.resolve()}))}onRTCTimeout(){}onGoEasyDisconnected(){be.destroyWithEvent(Y.GOEASY_DISCONNECTED)}destroy(){}muteMic(e){}toggleSpeaker(e){}switchCamera(){me.vendorClient.switchCamera()}muteCamera(e){me.vendorClient.muteCamera(e),be.muteMemberCamera(D.Socket.user().id,e)}play(e){me.vendorClient.play(e)}onRTCRemoteMicChanged(e){}onRTCRemoteCameraChanged(t){return e(this,void 0,void 0,(function*(){}))}}class pe{static sendRequest(e){return new Promise(((t,i)=>{let s=new V({name:z.RTC_CMD,params:e,permission:P.WRITE,singleTimeout:Z.commonRequestSingle,totalTimeout:Z.commonRequestTotal,success:e=>{t(e)},fail:e=>{i({code:400,content:e.content})}});D.Socket.e(s)}))}}class ve extends Ee{constructor(){super(),be.callContext.call.acceptedAt=Date.now()}name(){return"InCall"}accept(){return Promise.reject("The call has already been accepted")}end(){const e=new he(X.HANGUP,be.callContext.call.id);pe.sendRequest(e),be.destroyWithEvent(Y.HUNG_UP)}onRTCTimeout(){const e=new he(X.RTC_DISCONNECT,be.callContext.call.id);pe.sendRequest(e),be.destroyWithEvent(Y.RTC_DISCONNECTED)}onUserQuit(t){return e(this,void 0,void 0,(function*(){be.updateMemberStatus(t.userId,"Quit");const e=yield D.Member.i.getData(t.userId),i={id:t.userId,data:e.get(t.userId)};!0===t.ended?be.destroyWithEvent(t.reason,i):K.fire(U.USER_QUIT,{user:i,reason:t.reason})}))}onRTCRemoteFlow(t){return e(this,void 0,void 0,(function*(){const e=be.callContext.call;be.updateMemberStatus(t.userId,e.status);const i=yield D.Member.i.getData(t.userId),s={id:t.userId,data:i.get(t.userId)};K.fire(U.USER_ACCEPTED,{user:s})}))}muteMic(e){me.vendorClient.muteMic(e),be.muteMemberMic(D.Socket.user().id,e)}toggleSpeaker(e){me.vendorClient.toggleSpeaker(e),be.toggleSpeaker(e)}onRTCRemoteMicChanged(t){return e(this,void 0,void 0,(function*(){let e=t.userId;be.muteMemberMic(e,t.muted);const i={user:{id:e,data:(yield D.Member.i.getData(e)).get(e)},micMuted:t.muted};K.fire(U.USER_MIC_CHANGED,i)}))}onRTCRemoteCameraChanged(t){return e(this,void 0,void 0,(function*(){let e=t.userId;be.muteMemberCamera(e,t.muted);const i={user:{id:e,data:(yield D.Member.i.getData(e)).get(e)},cameraMuted:t.muted};K.fire(U.USER_CAMERA_CHANGED,i)}))}}class Re extends Ee{constructor(){super(),this.dialTimeoutId=setTimeout((()=>{be.destroyWithEvent(Y.DIAL_TIMEOUT)}),45e3)}name(){return"Dialing"}onUserQuit(t){return e(this,void 0,void 0,(function*(){be.updateMemberStatus(t.userId,"Quit");const e=yield D.Member.i.getData(t.userId),i={id:t.userId,data:e.get(t.userId)};!0===t.ended?be.destroyWithEvent(t.reason,i):K.fire(U.USER_QUIT,{user:i,reason:t.reason})}))}accept(){return Promise.reject("Cannot accept the call during dialing.")}end(){const e=new he(X.CANCEL,be.callContext.call.id);pe.sendRequest(e),be.destroyWithEvent(Y.CANCELLED)}onRTCRemoteFlow(t){return e(this,void 0,void 0,(function*(){H.setStatus(new ve),me.vendorClient.push();const e=be.callContext.call;e.caller.status=e.status,be.updateMemberStatus(t.userId,e.status);const i=yield D.Member.i.getData(t.userId),s={id:t.userId,data:i.get(t.userId)};K.fire(U.USER_ACCEPTED,{user:s})}))}destroy(){clearTimeout(this.dialTimeoutId)}}class fe{static initNotificationAssembler(){D.N.addAssembler({assemble:e=>({callId:e.callId}),support:e=>!!e.callId})}static createLocalNotification(e){const t=D.N.supportAppNotification();let i=e.notification;if(!W.isObject(i)||!t)return;let s={callId:e.callId};D.N.createLocalNotification(i.title,i.body,s,i.sound,i.badge)}}class ge extends Ee{constructor(){super(),this.startAccept=!1;const e=Date.now()-be.callContext.call.time,t=e>0?45e3-e:45e3;this.ringTimeoutId=setTimeout((()=>{be.destroyWithEvent(Y.RING_TIMEOUT)}),t)}name(){return"Ringing"}accept(){return new Promise(((i,s)=>e(this,void 0,void 0,(function*(){try{if(this.startAccept)return void s("The call has already been accepted.");this.startAccept=!0;let e=be.callContext.call;try{yield me.rtcPlugin.requestPermission(e.mediaType)}catch(e){return this.end(),void s(e)}const n=()=>{j.i.off(t.RTC_ACCEPTED,n),i()};j.i.on(t.RTC_ACCEPTED,n),yield me.vendorClient.join(),me.vendorClient.push()}catch(e){console.warn("accept failed:",e),be.destroyWithEvent(Y.ACCEPT_FAILED),s(e)}}))))}onUserAcceptPacket(e){e.userId===D.Socket.user().id&&be.destroyWithEvent(Y.HANDLED_ON_ANOTHER_DEVICE)}onUserQuit(t){return e(this,void 0,void 0,(function*(){try{yield this.startPromise}catch(e){return void console.warn("ring error",e)}be.updateMemberStatus(t.userId,"Quit");const e=yield D.Member.i.getData(t.userId),i={id:t.userId,data:e.get(t.userId)};t.userId===D.Socket.user().id?be.destroyWithEvent(Y.HANDLED_ON_ANOTHER_DEVICE):!0===t.ended?be.destroyWithEvent(t.reason,i):K.fire(U.USER_QUIT,{user:i,reason:t.reason})}))}end(){const e=new he(X.REJECT,be.callContext.call.id);pe.sendRequest(e),be.destroyWithEvent(Y.REJECTED)}onRTCRemoteFlow(i){return e(this,void 0,void 0,(function*(){H.setStatus(new ve);const e=new he(X.ACCEPT,be.callContext.call.id);yield pe.sendRequest(e);let s=be.callContext.call;"Quit"!==s.caller.status&&(s.caller.status=s.status),be.updateMemberStatus(D.Socket.user().id,s.status),be.updateMemberStatus(i.userId,s.status),j.i.fire(t.RTC_ACCEPTED)}))}onUserRang(t){return e(this,void 0,void 0,(function*(){}))}destroy(){clearTimeout(this.ringTimeoutId)}startRing(t){this.startPromise=new Promise(((i,s)=>e(this,void 0,void 0,(function*(){try{fe.createLocalNotification(t),yield me.initClient(t.type,t.callId);const e=H.status.name(),s=be.callContext.call;s.status=e;const n=t.users.map((e=>e.id)),o=yield D.Member.i.getData(t.callerId,...n);s.caller=new x(t.callerId,o.get(t.callerId),e),s.callees=t.users.map((t=>new x(t.id,o.get(t.id),e)));const r=new he(X.RANG,s.id);yield pe.sendRequest(r);const a=yield D.Member.i.getData(t.callerId),c={id:t.callerId,data:a.get(t.callerId)};K.fire(U.RING,{user:c}),i()}catch(e){console.warn("Ring failed",e),be.destroy(),s(e)}}))))}}!function(e){e.RING="RING",e.USER_RANG="U_RANG",e.USER_QUIT="U_QUIT",e.USER_ACCEPTED="U_ACCEPTED",e.ENDED="ENDED"}(ee||(ee={}));class ye{onServerPacket(e,t){switch(e){case ee.RING:this.onRing(t);break;case ee.USER_RANG:this.onUserRang(t);break;case ee.USER_ACCEPTED:this.onUserAcceptPacket(t);break;case ee.USER_QUIT:this.onUserQuit(t)}}}class _e extends ye{name(){return"Busy"}accept(){return H.status.accept()}end(){H.status.end(),ke.setStatus(new we)}call(e){return Promise.reject("Another call is in progress.")}onRing(e){const t=new he(X.BUSY,e.id);pe.sendRequest(t)}onUserAcceptPacket(e){H.status.onUserAcceptPacket(e)}onUserRang(e){H.status.onUserRang(e)}onUserQuit(e){H.status.onUserQuit(e)}onRTCTimeout(){H.status.onRTCTimeout()}onRTCRemoteFlow(e){H.status.onRTCRemoteFlow(e)}onGoEasyDisconnected(){H.status.onGoEasyDisconnected()}muteMic(e){H.status.muteMic(e)}toggleSpeaker(e){H.status.toggleSpeaker(e)}muteCamera(e){H.status.muteCamera(e)}switchCamera(){H.status.switchCamera()}play(e){H.status.play(e)}onRTCRemoteMicChanged(e){H.status.onRTCRemoteMicChanged(e)}onRTCRemoteCameraChanged(e){H.status.onRTCRemoteCameraChanged(e)}}class we extends ye{name(){return"Idle"}call(t){if(B.check(),$.validateNotification(t.notification),!D.Socket.user().id)throw new Error("Dialing failed: `id` is required when connecting to GoEasy.");return new Promise(((i,s)=>e(this,void 0,void 0,(function*(){try{if(ke.setStatus(new _e),yield me.rtcPlugin.requestPermission(t.mediaType),"calleeIds"in t){if(!t.calleeIds.every((e=>"string"==typeof e)))return void s({code:400,content:"calleeIds must contain only strings"});be.initGroupCall(t)}else{if("string"!=typeof t.calleeId)return void s({code:400,content:"calleeId must be a string"});be.initPrivateCall(t)}H.setStatus(new Re);let e=yield me.initClient(t.mediaType);me.vendorClient.join();const n=be.callContext.call;n.id=e;const o=H.status.name();n.status=o;const r="calleeIds"in t?t.calleeIds:[t.calleeId],a=yield D.Member.i.getData(...r);n.callees=r.map((e=>new x(e,a.get(e),"Ringing")));const c=he.createCallCommand(n,e,t);const l=(yield pe.sendRequest(c)).content.users;n.callees=n.callees.filter((e=>!l.find((t=>t.userId===e.id&&t.busy))));l.every((e=>e.busy))?(be.destroy(),s({code:400,content:"all callees are busy"})):i()}catch(e){console.warn("Call failed",e),be.destroy(),s(e)}}))))}validateOptions(){}onRing(t){return e(this,void 0,void 0,(function*(){ke.setStatus(new _e),be.ring(t);let e=new ge;H.setStatus(e),e.startRing(t)}))}accept(){return Promise.reject("No active call to accept.")}end(){}onUserRang(e){}onUserAcceptPacket(e){}onUserQuit(e){}onRTCTimeout(){}onRTCRemoteFlow(e){}onGoEasyDisconnected(){}muteMic(){}toggleSpeaker(){}muteCamera(){}switchCamera(){}play(e){}onRTCRemoteCameraChanged(e){}onRTCRemoteMicChanged(e){}}class ke{static setStatus(e){this.status=e}}ke.status=new we;class be{static ring(e){const t=new q;t.id=e.callId,t.time=e.time,t.mediaType=e.type,t.groupId=e.groupId,t.speakerOn=!0,this.callContext=new F(t)}static initPrivateCall(t){return e(this,void 0,void 0,(function*(){const e=new q;e.mediaType=t.mediaType,e.speakerOn=!0,e.caller=new x(D.Socket.user().id,D.Socket.user().data,"Dialing"),this.callContext=new F(e)}))}static initGroupCall(e){if(e.calleeIds.length>8)throw new Error("calleeIds can not more than 8");const t=new q;t.groupId=e.groupId,t.mediaType=e.mediaType,t.speakerOn=!0,t.caller=new x(D.Socket.user().id,D.Socket.user().data,"Dialing"),this.callContext=new F(t)}static updateMemberStatus(e,t){const i=this.callContext.call;[...i.callees,i.caller].find((t=>t.id===e)).status=t}static muteMemberMic(e,t){const i=this.callContext.call,s=[...i.callees,i.caller].find((t=>t.id===e));s.micMuted&&t||!s.micMuted&&!t||(s.micMuted=t)}static muteMemberCamera(e,t){const i=this.callContext.call,s=[...i.callees,i.caller].find((t=>t.id===e));s.cameraMuted&&t||!s.cameraMuted&&!t||(s.cameraMuted=t)}static toggleSpeaker(e){this.callContext.call.speakerOn=e}static isCaller(){return this.callContext.call.caller.id===D.Socket.user().id}static destroyWithEvent(e,t=D.Socket.user()){this.updateMemberStatus(t.id,"Quit"),K.fire(U.USER_QUIT,{user:t,reason:e}),K.fire(U.CALL_ENDED),this.destroy()}static destroy(){var e;null===(e=me.vendorClient)||void 0===e||e.destroy(),this.callContext=null,H.clearStatus(),ke.setStatus(new we)}}class Ie{constructor(){j.i.on(t.RTC_LOST,(()=>this.onRTCLost())),j.i.on(t.RTC_RECONNECT,(()=>this.onRTCReconnect()))}onRTCLost(){be.callContext&&(this.rtcLostTimeoutId=setTimeout((()=>{j.i.fire(t.RTC_TIMEOUT)}),1e4))}onRTCReconnect(){clearTimeout(this.rtcLostTimeoutId)}onGoEasyLost(){this.goeasyLostTimeoutId=setTimeout((()=>{j.i.fire(t.GOEASY_TIMEOUT)}),2e4)}onGoEasyReconnected(){clearTimeout(this.goeasyLostTimeoutId)}}class Ae{static init(){this.instance=new Ae}static i(){if(this.instance)return this.instance;throw new Error("Please connect GoEasy first.")}constructor(){this.rtcStabilizer=new Ie,me.init(),fe.initNotificationAssembler(),D.Socket.onMessage(z.RTC_PKT,this.onServerPacket.bind(this)),j.i.on(t.RECEIVED_RTC_REMOTE_FLOW,this.onRTCRemoteFlow.bind(this)),j.i.on(t.RTC_TIMEOUT,this.onRTCTimeout.bind(this)),j.i.on(t.RTC_REMOTE_MIC_CHANGED,this.onRTCRemoteMicChanged.bind(this)),j.i.on(t.RTC_REMOTE_CAMERA_CHANGED,this.onRTCRemoteCameraChanged.bind(this)),D.Socket.on(D.Socket.EVENT.LOST,this.onGoEasyDisconnected.bind(this)),D.Socket.on(D.Socket.EVENT.DISCONNECT,this.onGoEasyDisconnected.bind(this))}on(e,t){K.on(e.toString(),t)}off(e,t){K.off(e.toString(),t)}call(t){return e(this,void 0,void 0,(function*(){return ke.status.call(t)}))}groupCall(t){return e(this,void 0,void 0,(function*(){return ke.status.call(t)}))}accept(){return ke.status.accept()}getCurrentCall(){var e;return(null===(e=be.callContext)||void 0===e?void 0:e.call)||null}end(){ke.status.end()}muteMic(e){ke.status.muteMic(e)}toggleSpeaker(e){ke.status.toggleSpeaker(e)}muteCamera(e){ke.status.muteCamera(e)}switchCamera(){ke.status.switchCamera()}play(e){ke.status.play(e)}onServerPacket(e){ke.status.onServerPacket(e.name,e.data)}onRTCTimeout(){ke.status.onRTCTimeout()}onRTCRemoteFlow(e){ke.status.onRTCRemoteFlow(e)}onGoEasyDisconnected(){ke.status.onGoEasyDisconnected()}onRTCRemoteMicChanged(e){ke.status.onRTCRemoteMicChanged(e)}onRTCRemoteCameraChanged(e){ke.status.onRTCRemoteCameraChanged(e)}}class Me{static init(e){B.init(e)}static call(e){return Ae.i().call(e)}static groupCall(e){return Ae.i().groupCall(e)}static accept(){return Ae.i().accept()}static currentCall(){return Ae.i().getCurrentCall()}static end(){Ae.i().end()}static muteMic(e){Ae.i().muteMic(e)}static toggleSpeaker(e){Ae.i().toggleSpeaker(e)}static muteCamera(e){Ae.i().muteCamera(e)}static switchCamera(){Ae.i().switchCamera()}static play(e){Ae.i().play(e)}static on(e,t){Ae.i().on(e,t)}static off(e,t){Ae.i().off(e,t)}}Me.EVENT=U;export{Me as default};
|