@hysc/meeting 10.0.11 → 10.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +11 -8
- package/dist/index.d.ts +11 -8
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/package.json +7 -7
- package/umd/boom-core/src/BoomCore/BCClient/clientEventType.d.ts +0 -428
- package/umd/boom-meeting/src/BMChat/BMChatVM.d.ts +0 -26
- package/umd/boom-meeting/src/BMChat/BMMessageInfo.d.ts +0 -31
- package/umd/boom-meeting/src/BMRoom/BMLiveVM.d.ts +0 -35
- package/umd/boom-meeting/src/BMRoom/BMRoomInfo.d.ts +0 -215
- package/umd/boom-meeting/src/BMRoom/BMRoomVM.d.ts +0 -317
- package/umd/boom-meeting/src/BMRoom/RoomEvent.d.ts +0 -1
- package/umd/boom-meeting/src/BMStream/BMSpeaker.d.ts +0 -26
- package/umd/boom-meeting/src/BMStream/BMStreamModel.d.ts +0 -306
- package/umd/boom-meeting/src/BMStream/BMStreamModelVM.d.ts +0 -260
- package/umd/boom-meeting/src/BMStream/getHTMLMediaStreamOptions.d.ts +0 -35
- package/umd/boom-meeting/src/BMStream/sortStream.d.ts +0 -30
- package/umd/boom-meeting/src/BMUser/BMUser.d.ts +0 -156
- package/umd/boom-meeting/src/BMUser/BMUserVM.d.ts +0 -177
- package/umd/boom-meeting/src/SingletonQueue/SingletonQueue.d.ts +0 -26
- package/umd/boom-meeting/src/audioPlay/AudioPlay.d.ts +0 -31
- package/umd/boom-meeting/src/bjy-common/function/debounce.d.ts +0 -9
- package/umd/boom-meeting/src/bjy-common/function/execute.d.ts +0 -9
- package/umd/boom-meeting/src/bjy-common/function/getErrorMessage.d.ts +0 -1
- package/umd/boom-meeting/src/bjy-common/function/isDef.d.ts +0 -1
- package/umd/boom-meeting/src/bjy-common/function/isNative.d.ts +0 -1
- package/umd/boom-meeting/src/bjy-common/function/isUndef.d.ts +0 -1
- package/umd/boom-meeting/src/bjy-common/function/nextTick.d.ts +0 -2
- package/umd/boom-meeting/src/bjy-common/function/throttling.d.ts +0 -9
- package/umd/boom-meeting/src/bjy-common/function/toNumber.d.ts +0 -1
- package/umd/boom-meeting/src/bjy-common/function/toString.d.ts +0 -1
- package/umd/boom-meeting/src/bjy-common/type/api.d.ts +0 -66
- package/umd/boom-meeting/src/bjy-common/type/options.d.ts +0 -7
- package/umd/boom-meeting/src/bjy-common/type/type.d.ts +0 -90
- package/umd/boom-meeting/src/bjy-common/util/CustomEvent.d.ts +0 -30
- package/umd/boom-meeting/src/bjy-common/util/Emitter.d.ts +0 -57
- package/umd/boom-meeting/src/bjy-common/util/NextTask.d.ts +0 -28
- package/umd/boom-meeting/src/bjy-common/util/Sleep.d.ts +0 -14
- package/umd/boom-meeting/src/bjy-common/util/Timer.d.ts +0 -13
- package/umd/boom-meeting/src/bjy-common/util/array.d.ts +0 -96
- package/umd/boom-meeting/src/bjy-common/util/browser.d.ts +0 -6
- package/umd/boom-meeting/src/bjy-common/util/constant.d.ts +0 -50
- package/umd/boom-meeting/src/bjy-common/util/holder.d.ts +0 -6
- package/umd/boom-meeting/src/bjy-common/util/is.d.ts +0 -49
- package/umd/boom-meeting/src/bjy-common/util/keypath.d.ts +0 -41
- package/umd/boom-meeting/src/bjy-common/util/logger.d.ts +0 -42
- package/umd/boom-meeting/src/bjy-common/util/network.d.ts +0 -4
- package/umd/boom-meeting/src/bjy-common/util/object.d.ts +0 -83
- package/umd/boom-meeting/src/bjy-common/util/os.d.ts +0 -14
- package/umd/boom-meeting/src/bjy-common/util/string.d.ts +0 -102
- package/umd/boom-meeting/src/constants.d.ts +0 -129
- package/umd/boom-meeting/src/error/RTCError.d.ts +0 -20
- package/umd/boom-meeting/src/error/errorMap.d.ts +0 -70
- package/umd/boom-meeting/src/error/errorType.d.ts +0 -96
- package/umd/boom-meeting/src/handleEvent/attachEvents.d.ts +0 -48
- package/umd/boom-meeting/src/handleEvent/brtcNetEvent.d.ts +0 -9
- package/umd/boom-meeting/src/handleEvent/customMessageEvent.d.ts +0 -2
- package/umd/boom-meeting/src/handleEvent/handleParticipantEvent.d.ts +0 -24
- package/umd/boom-meeting/src/handleEvent/handleRoomEvent.d.ts +0 -20
- package/umd/boom-meeting/src/handleEvent/messageEvent.d.ts +0 -5
- package/umd/boom-meeting/src/handleEvent/pullUser.d.ts +0 -7
- package/umd/boom-meeting/src/handleEvent/roomErrEvent.d.ts +0 -9
- package/umd/boom-meeting/src/handleEvent/streamEvent.d.ts +0 -22
- package/umd/boom-meeting/src/logger/logger.d.ts +0 -86
- package/umd/boom-meeting/src/type/customStats.d.ts +0 -123
- package/umd/boom-meeting/src/type/index.d.ts +0 -9
- package/umd/boom-meeting/src/type/stream.d.ts +0 -15
- package/umd/boom-meeting/src/type/user.d.ts +0 -9
- package/umd/boom-meeting/src/util/PackLoss.d.ts +0 -7
- package/umd/boom-meeting/src/util/Pqueue.d.ts +0 -62
- package/umd/boom-meeting/src/util/Privileges.d.ts +0 -20
- package/umd/boom-meeting/src/util/ReportCollector.d.ts +0 -22
- package/umd/boom-meeting/src/util/Stutter.d.ts +0 -19
- package/umd/boom-meeting/src/util/Thread.d.ts +0 -12
- package/umd/boom-meeting/src/util/base64.d.ts +0 -4
- package/umd/boom-meeting/src/util/benchmark.d.ts +0 -1
- package/umd/boom-meeting/src/util/checkPermissions.d.ts +0 -1
- package/umd/boom-meeting/src/util/checkSystemRequirements.d.ts +0 -1
- package/umd/boom-meeting/src/util/constant.d.ts +0 -67
- package/umd/boom-meeting/src/util/devices.d.ts +0 -2
- package/umd/boom-meeting/src/util/emitter.d.ts +0 -43
- package/umd/boom-meeting/src/util/formatUserId.d.ts +0 -2
- package/umd/boom-meeting/src/util/is.d.ts +0 -70
- package/umd/boom-meeting/src/util/peerToPeerProbe.d.ts +0 -9
- package/umd/boom-meeting/src/util/request.d.ts +0 -45
- package/umd/boom-meeting/src/util/roomUtils.d.ts +0 -9
- package/umd/boom-meeting/src/util/sortUtils.d.ts +0 -10
- package/umd/boom-meeting/src/util/util.d.ts +0 -78
- package/umd/index.js +0 -29
- package/umd/src/BMChat/BMChatVM.d.ts +0 -26
- package/umd/src/BMChat/BMMessageInfo.d.ts +0 -31
- package/umd/src/BMRoom/BMLiveVM.d.ts +0 -35
- package/umd/src/BMRoom/BMRoom.d.ts +0 -705
- package/umd/src/BMRoom/BMRoomInfo.d.ts +0 -215
- package/umd/src/BMRoom/BMRoomVM.d.ts +0 -317
- package/umd/src/BMRoom/RoomEvent.d.ts +0 -1
- package/umd/src/BMStream/BMSpeaker.d.ts +0 -26
- package/umd/src/BMStream/BMStreamModel.d.ts +0 -307
- package/umd/src/BMStream/BMStreamModelVM.d.ts +0 -259
- package/umd/src/BMStream/getHTMLMediaStreamOptions.d.ts +0 -35
- package/umd/src/BMStream/sortStream.d.ts +0 -30
- package/umd/src/BMUser/BMUser.d.ts +0 -156
- package/umd/src/BMUser/BMUserVM.d.ts +0 -177
- package/umd/src/SingletonQueue/SingletonQueue.d.ts +0 -26
- package/umd/src/audioPlay/AudioPlay.d.ts +0 -31
- package/umd/src/bjy-common/function/debounce.d.ts +0 -9
- package/umd/src/bjy-common/function/execute.d.ts +0 -9
- package/umd/src/bjy-common/function/getErrorMessage.d.ts +0 -1
- package/umd/src/bjy-common/function/isDef.d.ts +0 -1
- package/umd/src/bjy-common/function/isNative.d.ts +0 -1
- package/umd/src/bjy-common/function/isUndef.d.ts +0 -1
- package/umd/src/bjy-common/function/nextTick.d.ts +0 -2
- package/umd/src/bjy-common/function/throttling.d.ts +0 -9
- package/umd/src/bjy-common/function/toNumber.d.ts +0 -1
- package/umd/src/bjy-common/function/toString.d.ts +0 -1
- package/umd/src/bjy-common/type/api.d.ts +0 -66
- package/umd/src/bjy-common/type/options.d.ts +0 -7
- package/umd/src/bjy-common/type/type.d.ts +0 -90
- package/umd/src/bjy-common/util/CustomEvent.d.ts +0 -30
- package/umd/src/bjy-common/util/Emitter.d.ts +0 -57
- package/umd/src/bjy-common/util/NextTask.d.ts +0 -28
- package/umd/src/bjy-common/util/Sleep.d.ts +0 -14
- package/umd/src/bjy-common/util/Timer.d.ts +0 -13
- package/umd/src/bjy-common/util/array.d.ts +0 -96
- package/umd/src/bjy-common/util/browser.d.ts +0 -6
- package/umd/src/bjy-common/util/constant.d.ts +0 -50
- package/umd/src/bjy-common/util/holder.d.ts +0 -6
- package/umd/src/bjy-common/util/is.d.ts +0 -49
- package/umd/src/bjy-common/util/keypath.d.ts +0 -41
- package/umd/src/bjy-common/util/logger.d.ts +0 -42
- package/umd/src/bjy-common/util/network.d.ts +0 -4
- package/umd/src/bjy-common/util/object.d.ts +0 -83
- package/umd/src/bjy-common/util/os.d.ts +0 -14
- package/umd/src/bjy-common/util/string.d.ts +0 -102
- package/umd/src/constants.d.ts +0 -129
- package/umd/src/error/RTCError.d.ts +0 -20
- package/umd/src/error/errorMap.d.ts +0 -70
- package/umd/src/error/errorType.d.ts +0 -96
- package/umd/src/handleEvent/attachEvents.d.ts +0 -47
- package/umd/src/handleEvent/brtcNetEvent.d.ts +0 -9
- package/umd/src/handleEvent/customMessageEvent.d.ts +0 -2
- package/umd/src/handleEvent/handleParticipantEvent.d.ts +0 -24
- package/umd/src/handleEvent/handleRoomEvent.d.ts +0 -20
- package/umd/src/handleEvent/messageEvent.d.ts +0 -5
- package/umd/src/handleEvent/pullUser.d.ts +0 -7
- package/umd/src/handleEvent/roomErrEvent.d.ts +0 -9
- package/umd/src/handleEvent/streamEvent.d.ts +0 -22
- package/umd/src/index.d.ts +0 -4
- package/umd/src/logger/logger.d.ts +0 -86
- package/umd/src/type/customStats.d.ts +0 -123
- package/umd/src/type/index.d.ts +0 -9
- package/umd/src/type/stream.d.ts +0 -12
- package/umd/src/type/user.d.ts +0 -9
- package/umd/src/util/PackLoss.d.ts +0 -7
- package/umd/src/util/Pqueue.d.ts +0 -62
- package/umd/src/util/Privileges.d.ts +0 -20
- package/umd/src/util/ReportCollector.d.ts +0 -22
- package/umd/src/util/Stutter.d.ts +0 -19
- package/umd/src/util/Thread.d.ts +0 -12
- package/umd/src/util/base64.d.ts +0 -4
- package/umd/src/util/checkPermissions.d.ts +0 -1
- package/umd/src/util/checkSystemRequirements.d.ts +0 -1
- package/umd/src/util/constant.d.ts +0 -67
- package/umd/src/util/devices.d.ts +0 -2
- package/umd/src/util/emitter.d.ts +0 -43
- package/umd/src/util/formatUserId.d.ts +0 -2
- package/umd/src/util/is.d.ts +0 -70
- package/umd/src/util/peerToPeerProbe.d.ts +0 -9
- package/umd/src/util/request.d.ts +0 -45
- package/umd/src/util/roomUtils.d.ts +0 -9
- package/umd/src/util/sortUtils.d.ts +0 -10
- package/umd/src/util/util.d.ts +0 -78
- package/umd/utils/BoomError.d.ts +0 -19
- package/umd/utils/ErrorTypes.d.ts +0 -139
- package/umd/utils/index.d.ts +0 -9
package/umd/index.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("events")):"function"==typeof define&&define.amd?define(["exports","events"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).BoomMeeting={},e.events)}(this,(function(exports,events){"use strict";var extendStatics=function(e,t){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},extendStatics(e,t)};function __extends(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function __awaiter(e,t,r,i){return new(r||(r=Promise))((function(s,o){function n(e){try{d(i.next(e))}catch(e){o(e)}}function a(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(n,a)}d((i=i.apply(e,t||[])).next())}))}function __values(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function __read(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var i,s,o=r.call(e),n=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)n.push(i.value)}catch(e){s={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(s)throw s.error}}return n}function __spreadArray(e,t,r){if(r||2===arguments.length)for(var i,s=0,o=t.length;s<o;s++)!i&&s in t||(i||(i=Array.prototype.slice.call(t,0,s)),i[s]=t[s]);return e.concat(i||Array.prototype.slice.call(t))}var ee$2=Object.defineProperty,D$2=(e,t)=>{for(var r in t)ee$2(e,r,{get:t[r],enumerable:!0})},s=class extends Error{constructor(e,t,r){let i;super(),this.boom_error_flag_="__BOOM_ERROR___",this.code=e,i="string"==typeof t?t:JSON.stringify(t),this.message=i,r&&(this.name=r)}toString(){return JSON.stringify({code:this.code,message:this.message})}getCode(){return this.code}getMessage(){return this.message}},ne=(i=ne||{},i[i.BloudLock=28]="BloudLock",i[i.ShareScreenNoPermission=100]="ShareScreenNoPermission",i[i.ShareScreenCanceled=101]="ShareScreenCanceled",i[i.ShareScreenOtherError=102]="ShareScreenOtherError",i[i.ShareScreenContentHintError=103]="ShareScreenContentHintError",i[i.ShareScreenClientJoinedError=104]="ShareScreenClientJoinedError",i[i.BrtcShareSigError=105]="BrtcShareSigError",i[i.ToggleShareScreenError=106]="ToggleShareScreenError",i[i.BrtcCreateStreamError=107]="BrtcCreateStreamError",i[i.BrtcSubscribeError=108]="BrtcSubscribeError",i[i.BrtcPublishError=109]="BrtcPublishError",i[i.BrtcUnsubscribeError=110]="BrtcUnsubscribeError",i[i.BrtcUnPublishError=111]="BrtcUnPublishError",i[i.RepeatJoinError=112]="RepeatJoinError",i[i.ProxiesUrlTypeError=113]="ProxiesUrlTypeError",i[i.getBloudProxiesUrlError=114]="getBloudProxiesUrlError",i[i.JoinUserInfoError=115]="JoinUserInfoError",i[i.JoinTypeError=116]="JoinTypeError",i[i.JoinBrtcError=117]="JoinBrtcError",i[i.JoinBloudError=118]="JoinBloudError",i[i.UpdateCustomStatsError=119]="UpdateCustomStatsError",i[i.CreateBloudError=120]="CreateBloudError",i),Rn=new s(100,"没有打开共享屏幕录制权限","no share permission"),On=new s(101,"取消共享屏幕","cancel share"),yn=e=>new s(102,e),i;new s(103,"设置 共享屏幕视频流的 contentHint 失效","set share video contentHint failed");var Un=new s(104,"共享屏幕brtc client入会失败","share client join failed"),Bn=new s(105,"brtcShareSig为空","brtc share sig is empty"),Dn=e=>new s(106,e,"toggle share has error"),vn=new s(112,"正在 join,请勿重复调用","repeat join error"),_n=new s(113,"proxies url 必须为字符串","get bloud proxies param error"),Ln=e=>new s(114,e,"get bloud proxies error"),In=new s(115,"userinfo传递错误,请检查"),wn=new s(116,"type传递错误,请检查"),Pn=e=>new s(117,e,"join brtc error"),Mn=e=>new s(107,"brtc 创建本地流失败"),kn=e=>new s(109,e,"brtc pub failed"),Jn=e=>new s(110,e,"brtc sub failed"),jn=e=>new s(110,e,"brtc unpub failed"),Vn=e=>new s(119,e,"bloud updateCustomStats failed"),re$1=(a=re$1||{},a[a.BmJoinError=200]="BmJoinError",a[a.BMLeaveError=201]="BMLeaveError",a[a.BmSetRemoteVideoEnable=202]="BmSetRemoteVideoEnable",a[a.BmSetRemoteAudioEnable=203]="BmSetRemoteAudioEnable",a[a.BmSetLocalVideoEnable=204]="BmSetLocalVideoEnable",a[a.BmSetLocalAudioEnable=205]="BmSetLocalAudioEnable",a[a.BmSetLocalSpeakerEnable=206]="BmSetLocalSpeakerEnable",a[a.BmChangeMasterError=207]="BmChangeMasterError",a[a.BmUpdateManagerError=208]="BmUpdateManagerError",a[a.BmEvictUserError=209]="BmEvictUserError",a[a.BmUpdateUserError=210]="BmUpdateUserError",a[a.BmSetAudioOffError=211]="BmSetAudioOffError",a[a.BmSetVideoOffError=212]="BmSetVideoOffError",a[a.BmSetMsgOffError=213]="BmSetMsgOffError",a[a.BmUpdateCustomStatsError=214]="BmUpdateCustomStatsError",a[a.BmChangeVideoProfileError=215]="BmChangeVideoProfileError",a[a.BmChangeAudioProfileError=216]="BmChangeAudioProfileError",a[a.BmCheckDeviceError=217]="BmCheckDeviceError",a),Hn=e=>new s(201,e,"boommeeting leave failed"),Gn=e=>new s(202,e,"开关对端摄像头失败"),$n=e=>new s(203,e,"开关对端麦克风发生失败"),zn=e=>new s(204,e,"开关本地摄像头失败"),Kn=e=>new s(205,e,"开关本地麦克风失败"),Xn=e=>new s(206,e,"开关扬声器失败"),qn=e=>new s(207,e,"转移主持人发生错误"),Qn=e=>new s(208,e,"改变联席主持人发生错误"),Zn=e=>new s(209,e,"踢出用户发生错误"),tr=e=>new s(210,e,"更新用户信息发生错误"),er=e=>new s(211,e,"全员静音发生错误"),nr$1=e=>new s(212,e,"全员禁用摄像头发生错误"),rr=e=>new s(213,e,"全员禁用聊天发生错误"),or=e=>new s(214,e,"更新房间自定义属性状态发生错误"),sr$1=e=>new s(215,e,"远程调节对方视频发生错误"),ir=e=>new s(216,e,"远程调节对方音频发生错误"),cr=e=>new s(217,e,"远程检测对方设备发生错误"),oe$1=(c=oe$1||{},c[c.createStream=1302]="createStream",c[c.noCameraDevice=1303]="noCameraDevice",c[c.noMicroDevice=1304]="noMicroDevice",c[c.noSpeakerDevice=1305]="noSpeakerDevice",c[c.openCamera=1301]="openCamera",c[c.cameraNotAuth=1314]="cameraNotAuth",c[c.cameraOccupy=1315]="cameraOccupy",c[c.openMicro=1302]="openMicro",c[c.micNotAuth=1317]="micNotAuth",c[c.micOccupy=1319]="micOccupy",c[c.streamDisconnected=1320]="streamDisconnected",c[c.syncFail=1321]="syncFail",c[c.getStreamFail=1322]="getStreamFail",c[c.streamConnectError=1323]="streamConnectError",c[c.streamReconnectSuccess=1324]="streamReconnectSuccess",c[c.streamReconnectFailed=1325]="streamReconnectFailed",c[c.shareStreamConnectError=1326]="shareStreamConnectError",c[c.shareStreamConnectSuccess=1327]="shareStreamConnectSuccess",c[c.shareStreamConnectFailed=1328]="shareStreamConnectFailed",c),ar=e=>new s(1302,`采集${e}流失败,请重试`),pr$1=e=>new s(1322,`当前${e}不可用, 请确保您的${e}连接正确, 或更换其他${e}`),mr$1=()=>new s(1301,"打开摄像头失败"),Er$1=()=>new s(1314,"摄像头设备未授权, 无法开启视频, 启动摄像头失败, 请在系统或浏览器“设置-隐私”中允许使用摄像头"),gr$1=()=>new s(1315,"当前摄像头被占用, 请检查或切换其他摄像头"),xr$1=()=>new s(1302,"打开麦克风失败"),Sr$1=()=>new s(1317,"麦克风设备未授权, 无法开启麦克风, 启动麦克风失败, 请在系统或浏览器“设置-隐私”中允许使用麦克风"),Tr$1=()=>new s(1319,"当前麦克风被占用, 请检查或切换其他麦克风"),hr=e=>new s(1320,`${e}连接已断开,正在重试,请稍后`),dr=()=>new s(1321,"状态同步异常,请重试, 麦克风和摄像头已自动关闭"),Nr$1=()=>new s(1323,"网络连接异常,正在重试"),br=()=>new s(1326,"共享屏幕网络连接异常,正在重试"),Rr$1=(e,t)=>{let r="";return e&&t?r="麦克风和摄像头":e?r="麦克风":t&&(r="摄像头"),new s(1324,`网络连接成功, ${r}已自动打开`)},Or$1=()=>new s(1327,"共享屏幕网络连接成功, 已自动打开"),yr$1=()=>new s(1325,"网络连接失败,请检查网络,麦克风和摄像头已自动关闭"),Ar=()=>new s(1325,"共享屏幕网络连接失败,请检查网络,共享屏幕已自动关闭"),c,a;function tt$1(e,t,r,i){let s=[];return r&&s.push(r),i&&s.push(i),`[${(new Date).toLocaleTimeString("chinese",{hour12:!1})}] <${e}> [${s.join("|")}] ${t}`}var se=(r=se||{},r[r.INFO=0]="INFO",r[r.WARN=1]="WARN",r[r.ERROR=2]="ERROR",r[r.CLOSE=3]="CLOSE",r),m$1=class e{static setStorageCallBack(t){e.storageCallBack=t}static setEnableUpload(t){e.enableUpload=t}static setLogLevel(t){e.logLevel=t}static setNamespace(t){e.namespace=t}static info(t,r,i,s=[]){e.logLevel<=0&&(s.unshift(tt$1("INFO",t,r,i)),console.info(...s),e.storageCallBack&&e.storageCallBack(s.join(""),1))}static warn(t,r,i,s=[]){e.logLevel<=1&&(s.unshift(tt$1("WARN",t,r,i)),console.warn(...s),e.storageCallBack&&e.storageCallBack(s.join(""),2))}static error(t,r,i,s=[]){e.logLevel<=2&&(s.unshift(tt$1("ERROR",t,r,i)),console.error(...s),e.storageCallBack&&e.storageCallBack(s.join(""),3))}},r;m$1.enableUpload=!1,m$1.logLevel=0,m$1.namespace="boom-core";var kt$1=m$1,H$1={};D$2(H$1,{CHANGE_MASTER:()=>ct$1,CUSTOM_MESSAGE:()=>ft$2,ERROR:()=>ot$1,EVICTED:()=>gt$2,LEAVE_USERS:()=>St$2,MOVE_USER_ROOM:()=>mt$2,PARTICIPANT_JOINED:()=>et$1,PARTICIPANT_LEFT:()=>nt$1,RECONNECTED:()=>ce,RECONNECTING:()=>ae$1,ROOM_CLOSED:()=>rt$1,ROOM_CONNECTED:()=>me$1,ROOM_SYNCED:()=>Ee$1,SEND_MESSAGE:()=>ut$1,SESSION_CLOED:()=>fe$1,STATE_NOTIFY:()=>le$1,STREAM_PUBLISHED:()=>at$1,STREAM_REMOVED:()=>pt$2,STREAM_UPDATE:()=>Et$1,SYNC_FAILED:()=>ge$1,TIMEOUT:()=>ie$1,TOKEN_EXPIRE:()=>ue$1,TOKEN_WILL_EXPIRE:()=>pe$1,UPDATE_CUSTOM_STATS:()=>lt$1,UPDATE_STATS:()=>st$1,UPDATE_STREAM:()=>Tt,UPDATE_USER:()=>it$1,USER_REJOINED:()=>xt$1});var et$1="participant-joined",nt$1="participant-left",rt$1="room-closed",ot$1="room-error",ie$1="network-error",ce="room-reconnected",ae$1="room-reconnecting",st$1="update-stats",it$1="participant-update",ct$1="change-master",at$1="participant-published",pt$2="participant-unpublished",ut$1="new-message",ft$2="custom-message",lt$1="update-custom-stats",mt$2="move-user-room",Et$1="stream-update",gt$2="participant-evicted",xt$1="user-rejoined",pe$1="token-will-expire",ue$1="token-expire",fe$1="session-close",le$1="state-notify",St$2="leaveUsers",Tt="update-stream",me$1="room-connected",Ee$1="room-synced",ge$1="sync-failed",xe$1={joinUser:et$1,leaveUser:nt$1,roomClosed:rt$1,roomError:ot$1,updateStats:st$1,updateUser:it$1,changeMaster:ct$1,publishStream:at$1,unpublishStream:pt$2,sendMessage:ut$1,customMessage:ft$2,updateCustomStats:lt$1,moveUserRoom:mt$2,streamUpdate:Et$1,evicted:gt$2,userRejoined:xt$1,leaveUsers:St$2,updateStream:Tt},ht$1={};D$2(ht$1,{PLAYER_STATE_CHANGED:()=>Se});var Se="player-state-changed",dt$1={};D$2(dt$1,{BRTC_ROOM_RECONNECTED:()=>ye$1,BRTC_ROOM_ROCONNECTING:()=>Oe$1,BRTC_SYNC_ROOM_COMPLETED:()=>Re$1,CLIENT_BANNED:()=>de$1,ERROR:()=>Te$1,ROOM_CLOSED:()=>be$1,STREAM_PUBLISHED:()=>he,USER_KICKED:()=>Ne$1});var Te$1="error",he="stream-published",de$1="client-banned",Ne$1="user-kicked",be$1="room-closed",Re$1="sync-room-completed",Oe$1="brtc-room-reconnecting",ye$1="brtc-room-reconnected",Nt$1={};D$2(Nt$1,{BRTC_SHARE_SYNC_ROOM_COMPLETED:()=>Ue,JOIN_READY:()=>Ae$1});var Ae$1="join-ready",Ue="brtc-share-sync-room-completed",O$2={};D$2(O$2,{array:()=>N$2,arrayBuffer:()=>Je$1,boolean:()=>We$1,func:()=>h$1,isPlainObject:()=>K$2,number:()=>z$2,numeric:()=>Ot$1,object:()=>S$1,range:()=>ke$1,string:()=>b$2});var g={};D$2(g,{DOCUMENT:()=>Ce$1,EMPTY_ARRAY:()=>bt$1,EMPTY_FUNCTION:()=>$$1,EMPTY_OBJECT:()=>Me$1,EMPTY_STRING:()=>U$1,FALSE:()=>f$1,GLOBAL:()=>G$2,KEYPATH_CURRENT:()=>Fe$1,KEYPATH_PARENT:()=>Pe,MINUS_ONE:()=>I$1,NULL:()=>R$1,RAW_DOT:()=>M$1,RAW_FALSE:()=>De$1,RAW_FUNCTION:()=>P$2,RAW_LENGTH:()=>Le$1,RAW_NULL:()=>ve$1,RAW_SLASH:()=>Ie$1,RAW_TAG:()=>we$1,RAW_THIS:()=>Jt,RAW_TRUE:()=>Be$1,RAW_UNDEFINED:()=>w$2,RAW_VALUE:()=>_e$1,RAW_WILDCARD:()=>jt$1,TRUE:()=>T$2,UNDEFINED:()=>l$1,WINDOW:()=>W$1});var T$2=!0,f$1=!1,R$1=null,l$1=void 0,I$1=-1,Be$1="true",De$1="false",ve$1="null",w$2="undefined",Jt="this",_e$1="value",Le$1="length",P$2="function",jt$1="*",M$1=".",Ie$1="/",we$1="tag",Pe="..",Fe$1=Jt,W$1=typeof window!==w$2?window:void 0,Ce$1=typeof document!==w$2?document:void 0,G$2=typeof global!==w$2?global:W$1,$$1=function(){},Me$1=Object.freeze({}),bt$1=Object.freeze([]),U$1="";function h$1(e){return typeof e===P$2}function N$2(e){return Array.isArray(e)}function S$1(e){return null!==e&&"object"==typeof e}function b$2(e){return"string"==typeof e}function z$2(e){return"number"==typeof e&&!isNaN(e)}function We$1(e){return"boolean"==typeof e}function Ot$1(e){return z$2(e)||b$2(e)&&!isNaN(parseFloat(e))&&isFinite(+e)}var Rt$1={}.hasOwnProperty;function K$2(e){if(!S$1(e)||e.nodeType||e===e.window||e.constructor&&!Rt$1.call(e,"constructor")&&!Rt$1.call(e.constructor.prototype||{},"isPrototypeOf"))return!1;let t;for(t in e);return void 0===t||Rt$1.call(e,t)}function ke$1(e,t,r){return e>=t&&e<=r}function Je$1(e){return e instanceof ArrayBuffer}function Vt(e){if(b$2(e))return e;if(S$1(e)){if(b$2(e.message))return e.message;if(b$2(e.msg))return e.msg;if(h$1(e.toString))return e.toString()}return"unknow"}var J$1={};function k$2(e,t,r){if(h$1(e))return N$2(r)?e.apply(t,r):void 0!==t?e.call(t,r):void 0!==r?e(r):e()}function d$1(e,t,r){if(!e)return;let{length:i}=e;if(i)if(r)for(let r=i-1;r>=0&&!1!==t(e[r],r);r--);else for(let r=0;r<i&&!1!==t(e[r],r);r++);}function je$1(e,t){e[e.length]=t}function Ve$1(e,t){e.unshift(t)}function Yt$1(e,t,r){N$2(t)?d$1(t,(function(t){r(e,t)})):r(e,t)}function yt$2(e,t){Yt$1(e,t,je$1)}function Ye$1(e,t){Yt$1(e,t,Ve$1)}function Ht(e,t,r){let i=-1;return d$1(e,(function(e,s){if(!1===r?e==t:e===t)return i=s,!1})),i}function He$1(e){let{length:t}=e;if(t>0)return e[t-1]}function Ge$1(e){let{length:t}=e;if(t>0)return e.pop()}function $e(e,t,r){let i=0;return d$1(e,(function(s,o){(!1===r?s==t:s===t)&&(e.splice(o,1),i++)}),!0),i}function At$1(e,t,r){return Ht(e,t,r)>=0}function ze$1(e){return N$2(e)?e:k$2(bt$1.slice,e)}function Ke$1(e,t,r){let i={};return d$1(e,(function(e){i[t?e[t]:e]=r||e})),i}function Xe$1(e,t){return e.join(t)}function qe$1(e){return!N$2(e)||!e.length}D$2(J$1,{each:()=>d$1,falsy:()=>qe$1,has:()=>At$1,indexOf:()=>Ht,join:()=>Xe$1,last:()=>He$1,pop:()=>Ge$1,push:()=>yt$2,remove:()=>$e,toArray:()=>ze$1,toObject:()=>Ke$1,unshift:()=>Ye$1});var F$1=class e{constructor(t,r){this.type=t,this.phase=e.PHASE_CURRENT,r&&(this.originalEvent=r)}preventDefault(){let e=this;if(!e.isPrevented){let{originalEvent:t}=e;t&&t.preventDefault(),e.isPrevented=!0}return e}stopPropagation(){let e=this;if(!e.isStoped){let{originalEvent:t}=e;t&&t.stopPropagation(),e.isStoped=!0}return e}prevent(){return this.preventDefault()}stop(){return this.stopPropagation()}};F$1.PHASE_CURRENT=0,F$1.PHASE_UPWARD=1,F$1.PHASE_DOWNWARD=-1;var j$2=F$1,X$2={};function C$2(e,t){return null!=e&&e.toString?e.toString():void 0!==t?t:U$1}function Ut$1(e,t,r){return z$2(r)?t===r?U$1:e.slice(t,r):e.slice(t)}function Bt$1(e,t,r){return e.indexOf(t,void 0!==r?r:0)}function Dt$1(e,t){return Bt$1(e,t)>=0}D$2(X$2,{clear:()=>nn,copy:()=>V$2,diff:()=>$t$1,each:()=>y$1,extend:()=>wt$1,falsy:()=>an,get:()=>on$1,has:()=>cn,keys:()=>Pt$1,merge:()=>rn,param:()=>pn,set:()=>sn,sort:()=>en,toArray:()=>un,update:()=>zt});var _t$1={};function Lt$1(e,t){let r=_t$1.hasOwnProperty(e)?_t$1[e]:_t$1[e]=e.split(M$1);for(let e=0,i=r.length-1;e<=i&&!1!==t(r[e],e===i);e++);}function It$1(e){return void 0!==e}function Pt$1(e){return It$1(e)?Object.keys(e):[]}function Ze$1(e,t){return e.length-t.length}function tn(e,t){return t.length-e.length}function en(e,t){return Pt$1(e).sort(t?tn:Ze$1)}function y$1(e,t){for(let r in e)if(!1===t(e[r],r))break}function nn(e){y$1(e,(function(t,r){delete e[r]}))}function Gt$1(e,t){return S$1(e)?S$1(t)?(y$1(t,(function(t,r){e[r]=t})),e):e:t}function wt$1(e,t,r){return Gt$1(Gt$1(e,t),r)}function rn(e,t){return e&&t?wt$1(wt$1({},e),t):e||t}function V$2(e,t){let r=e;return N$2(e)?t?(r=[],d$1(e,(function(e,i){r[i]=V$2(e,t)}))):r=e.slice():S$1(e)&&(r={},y$1(e,(function(e,i){r[i]=t?V$2(e,t):e}))),r}function on$1(e,t,r){let i;return Lt$1(t,(function(t,r){if(null==e)return i=void 0,!1;{let s=e[t];r?i=void 0!==s?s:void 0:e=s}})),void 0===i&&(i=r),i}function sn(e,t,r,i){Lt$1(t,(function(t,s){if(s)e[t]=r;else if(e[t])e=e[t];else{if(!i)return!1;e=e[t]={}}}))}function cn(e,t){return void 0!==e[t]}function an(e){return!S$1(e)||N$2(e)||!Pt$1(e).length}function $t$1(e,t){let r=[];return y$1(e,((e,i)=>{N$2(e)||K$2(e)?(null==t[i]||$t$1(e,t[i]).length>0)&&r.push(i):e!==t[i]&&r.push(i)})),r}function pn(e){let t=[],r=(e,r)=>{r=h$1(r)?r():null==r?"":r,t[t.length]=encodeURIComponent(e)+"="+encodeURIComponent(r)};return(N$2(e)||K$2(e))&&(N$2(e)?d$1(e,((e,t)=>{r(t,e)})):y$1(e,((e,t)=>{r(t,e)}))),t.join("&").replace(/%20/g,"+")}function un(e){let t=[];return y$1(e,(e=>{t.push(e)})),t}function zt(e,t){if(S$1(e)&&S$1(t))return y$1(t,((r,i)=>{S$1(r)&&S$1(e[i])?zt(e[i],r):e[i]=t[i]})),e}var fn=1,ln=2,Kt=3,Xt$1=5,Y$1=typeof console!==w$2?console:null,mn=/yox/.test(C$2($$1))?ln:Kt,Ft$1=W$1&&/edge|msie|trident/i.test(W$1.navigator.userAgent)?U$1:"%c",En=Y$1?Ft$1?function(e,t,r,i){i?Y$1.log(Ft$1+e,r,t,i):Y$1.log(Ft$1+e,r,t)}:function(e,t,r){r?Y$1.log(e,t,r):Y$1.log(e,t)}:$$1;function qt$1(){if(G$2){let e=G$2.YOX_LOG_LEVEL;if(e>=fn&&e<=Xt$1)return e}return mn}function gn(e){return`background-color:${e};border-radius:12px;color:#fff;font-size:10px;padding:3px 6px;`}function Ct$1(e,t){qt$1()<=Kt&&En(t||"bjy warn",e,gn("#f90"))}function Qt$1(e,t){if(qt$1()<=Xt$1)throw new Error(`[${t||"bjy fatal"}]: ${e}`)}var q$1=class{constructor(e){this.ns=e||!1,this.listeners={}}fire(e,t,r){let i=this,s=b$2(e)?i.parse(e):e,o=i.listeners[s.type],n=!0;if(o){o=V$2(o);let e=t&&t[0]instanceof j$2?t[0]:void 0;d$1(o,(function(a){if(!Mt$1(s.ns,a,!0)||!At$1(o,a)||r&&!r(s,t,a))return;e&&(e.listener=a.fn);let d=k$2(a.fn,a.ctx,t);return e&&(e.listener=void 0),a.num=a.num?a.num+1:1,a.num===a.max&&i.off(s,a.fn),e&&(!1===d?e.prevent().stop():e.isStoped&&(d=!1)),!1===d?n=!1:void 0}))}return n}on(e,t){let r=this,i=r.listeners,s=h$1(t)?{fn:t}:t;if(S$1(s)&&h$1(s.fn)){let t=b$2(e)?r.parse(e):e;s.ns=t.ns,yt$2(i[t.type]||(i[t.type]=[]),s)}else"development"===process.env.NODE_ENV&&Qt$1('emitter.on(types, listener) invoke failed:\n\n"listener" is expected to be a Function or an EmitterOptions.\n');return this}one(e,t){return h$1(t)?t={fn:t,max:1}:t.max=1,this.on(e,t)}off(e,t){let r=this,i=r.listeners;if(e){let s=b$2(e)?r.parse(e):e,o=s.type,n=s.ns,a=Zt(t),d=function(e,t){d$1(e,(function(t,r){a(t)&&e.splice(r,1)}),!0),e.length||delete i[t]};o?i[o]&&d(i[o],o):n&&y$1(i,(function(e,t){d$1(e,(function(t,r){Mt$1(n,t)&&e.splice(r,1)}),!0),e.length||delete i[t]})),"development"===process.env.NODE_ENV&&arguments.length>1&&null==t&&Ct$1(`emitter.off(type, listener) is invoked, but "listener" is ${t}.`)}else r.listeners={},"development"===process.env.NODE_ENV&&arguments.length>0&&Ct$1(`emitter.off(type) is invoked, but "type" is ${e}.`)}has(e,t){let r=this.listeners,i=b$2(e)?this.parse(e):e,s=i.type,o=i.ns,n=!0,a=Zt(t);return s?r[s]&&function(e){d$1(e,(function(e){if(a(e))return n=!1}))}(r[s]):o&&y$1(r,(function(e){return d$1(e,(function(e){if(Mt$1(o,e))return n=!1})),n})),!n}parse(e){let t={type:e,ns:U$1};if(this.ns){let r=Bt$1(e,M$1);r>=0&&(t.type=Ut$1(e,0,r),t.ns=Ut$1(e,r+1))}return t}},Q$2;function Sn(){return!0}function Zt(e){return h$1(e)?function(t){return e===t.fn}:Sn}function Mt$1(e,t,r){let{ns:i}=t;return i&&e?i===e:!!r}function te$2(){return Date.now()}function Tn(e,t){return Ot$1(e)?+e:void 0!==t?t:0}function Wt(e){return h$1(e)&&Dt$1(C$2(e),"[native code]")}typeof setImmediate===P$2&&Wt(setImmediate)&&(Q$2=setImmediate),Q$2=typeof MessageChannel===P$2&&Wt(MessageChannel)?function(e){let t=new MessageChannel;t.port1.onmessage=e,t.port2.postMessage(1)}:setTimeout;var hn=Q$2,global$1="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},freeGlobal="object"==typeof global$1&&global$1&&global$1.Object===Object&&global$1,freeGlobal$1=freeGlobal,freeSelf="object"==typeof self&&self&&self.Object===Object&&self,root=freeGlobal$1||freeSelf||Function("return this")(),root$1=root,Symbol$1=root$1.Symbol,Symbol$2=Symbol$1,objectProto$7=Object.prototype,hasOwnProperty$5=objectProto$7.hasOwnProperty,nativeObjectToString$1=objectProto$7.toString,symToStringTag$1=Symbol$2?Symbol$2.toStringTag:void 0;function getRawTag(e){var t=hasOwnProperty$5.call(e,symToStringTag$1),r=e[symToStringTag$1];try{e[symToStringTag$1]=void 0;var i=!0}catch(e){}var s=nativeObjectToString$1.call(e);return i&&(t?e[symToStringTag$1]=r:delete e[symToStringTag$1]),s}var objectProto$6=Object.prototype,nativeObjectToString=objectProto$6.toString;function objectToString(e){return nativeObjectToString.call(e)}var nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag=Symbol$2?Symbol$2.toStringTag:void 0;function baseGetTag(e){return null==e?void 0===e?undefinedTag:nullTag:symToStringTag&&symToStringTag in Object(e)?getRawTag(e):objectToString(e)}function isObjectLike(e){return null!=e&&"object"==typeof e}var symbolTag="[object Symbol]";function isSymbol(e){return"symbol"==typeof e||isObjectLike(e)&&baseGetTag(e)==symbolTag}var isArray=Array.isArray,isArray$1=isArray,reWhitespace=/\s/;function trimmedEndIndex(e){for(var t=e.length;t--&&reWhitespace.test(e.charAt(t)););return t}var reTrimStart=/^\s+/;function baseTrim(e){return e?e.slice(0,trimmedEndIndex(e)+1).replace(reTrimStart,""):e}function isObject(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var NAN=NaN,reIsBadHex=/^[-+]0x[0-9a-f]+$/i,reIsBinary=/^0b[01]+$/i,reIsOctal=/^0o[0-7]+$/i,freeParseInt=parseInt;function toNumber(e){if("number"==typeof e)return e;if(isSymbol(e))return NAN;if(isObject(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=isObject(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=baseTrim(e);var r=reIsBinary.test(e);return r||reIsOctal.test(e)?freeParseInt(e.slice(2),r?2:8):reIsBadHex.test(e)?NAN:+e}function identity$1(e){return e}var asyncTag="[object AsyncFunction]",funcTag$1="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction$1(e){if(!isObject(e))return!1;var t=baseGetTag(e);return t==funcTag$1||t==genTag||t==asyncTag||t==proxyTag}var coreJsData=root$1["__core-js_shared__"],coreJsData$1=coreJsData,maskSrcKey=(uid=/[^.]+$/.exec(coreJsData$1&&coreJsData$1.keys&&coreJsData$1.keys.IE_PROTO||""),uid?"Symbol(src)_1."+uid:""),uid;function isMasked(e){return!!maskSrcKey&&maskSrcKey in e}var funcProto$1=Function.prototype,funcToString$1=funcProto$1.toString;function toSource(e){if(null!=e){try{return funcToString$1.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reIsHostCtor=/^\[object .+?Constructor\]$/,funcProto=Function.prototype,objectProto$5=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$4=objectProto$5.hasOwnProperty,reIsNative=RegExp("^"+funcToString.call(hasOwnProperty$4).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function baseIsNative(e){return!(!isObject(e)||isMasked(e))&&(isFunction$1(e)?reIsNative:reIsHostCtor).test(toSource(e))}function getValue(e,t){return null==e?void 0:e[t]}function getNative(e,t){var r=getValue(e,t);return baseIsNative(r)?r:void 0}function apply(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}var HOT_COUNT=800,HOT_SPAN=16,nativeNow=Date.now;function shortOut(e){var t=0,r=0;return function(){var i=nativeNow(),s=HOT_SPAN-(i-r);if(r=i,s>0){if(++t>=HOT_COUNT)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function constant(e){return function(){return e}}var defineProperty=function(){try{var e=getNative(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),defineProperty$1=defineProperty,baseSetToString=defineProperty$1?function(e,t){return defineProperty$1(e,"toString",{configurable:!0,enumerable:!1,value:constant(t),writable:!0})}:identity$1,baseSetToString$1=baseSetToString,setToString=shortOut(baseSetToString$1),setToString$1=setToString,MAX_SAFE_INTEGER$1=9007199254740991,reIsUint=/^(?:0|[1-9]\d*)$/;function isIndex(e,t){var r=typeof e;return!!(t=null==t?MAX_SAFE_INTEGER$1:t)&&("number"==r||"symbol"!=r&&reIsUint.test(e))&&e>-1&&e%1==0&&e<t}function eq(e,t){return e===t||e!=e&&t!=t}var nativeMax$1=Math.max;function overRest(e,t,r){return t=nativeMax$1(void 0===t?e.length-1:t,0),function(){for(var i=arguments,s=-1,o=nativeMax$1(i.length-t,0),n=Array(o);++s<o;)n[s]=i[t+s];s=-1;for(var a=Array(t+1);++s<t;)a[s]=i[s];return a[t]=r(n),apply(e,this,a)}}function baseRest(e,t){return setToString$1(overRest(e,t,identity$1),e+"")}var MAX_SAFE_INTEGER=9007199254740991;function isLength(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=MAX_SAFE_INTEGER}function isArrayLike(e){return null!=e&&isLength(e.length)&&!isFunction$1(e)}function isIterateeCall(e,t,r){if(!isObject(r))return!1;var i=typeof t;return!!("number"==i?isArrayLike(r)&&isIndex(t,r.length):"string"==i&&t in r)&&eq(r[t],e)}var objectProto$4=Object.prototype;function isPrototype(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||objectProto$4)}function baseTimes(e,t){for(var r=-1,i=Array(e);++r<e;)i[r]=t(r);return i}var argsTag$1="[object Arguments]";function baseIsArguments(e){return isObjectLike(e)&&baseGetTag(e)==argsTag$1}var objectProto$3=Object.prototype,hasOwnProperty$3=objectProto$3.hasOwnProperty,propertyIsEnumerable=objectProto$3.propertyIsEnumerable,isArguments=baseIsArguments(function(){return arguments}())?baseIsArguments:function(e){return isObjectLike(e)&&hasOwnProperty$3.call(e,"callee")&&!propertyIsEnumerable.call(e,"callee")},isArguments$1=isArguments;function stubFalse(){return!1}var freeExports$1="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule$1=freeExports$1&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports$1=freeModule$1&&freeModule$1.exports===freeExports$1,Buffer=moduleExports$1?root$1.Buffer:void 0,nativeIsBuffer=Buffer?Buffer.isBuffer:void 0,isBuffer=nativeIsBuffer||stubFalse,isBuffer$1=isBuffer,argsTag="[object Arguments]",arrayTag="[object Array]",boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",funcTag="[object Function]",mapTag="[object Map]",numberTag$1="[object Number]",objectTag="[object Object]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag="[object String]",weakMapTag="[object WeakMap]",arrayBufferTag="[object ArrayBuffer]",dataViewTag="[object DataView]",float32Tag="[object Float32Array]",float64Tag="[object Float64Array]",int8Tag="[object Int8Array]",int16Tag="[object Int16Array]",int32Tag="[object Int32Array]",uint8Tag="[object Uint8Array]",uint8ClampedTag="[object Uint8ClampedArray]",uint16Tag="[object Uint16Array]",uint32Tag="[object Uint32Array]",typedArrayTags={};function baseIsTypedArray(e){return isObjectLike(e)&&isLength(e.length)&&!!typedArrayTags[baseGetTag(e)]}function baseUnary(e){return function(t){return e(t)}}typedArrayTags[float32Tag]=typedArrayTags[float64Tag]=typedArrayTags[int8Tag]=typedArrayTags[int16Tag]=typedArrayTags[int32Tag]=typedArrayTags[uint8Tag]=typedArrayTags[uint8ClampedTag]=typedArrayTags[uint16Tag]=typedArrayTags[uint32Tag]=!0,typedArrayTags[argsTag]=typedArrayTags[arrayTag]=typedArrayTags[arrayBufferTag]=typedArrayTags[boolTag]=typedArrayTags[dataViewTag]=typedArrayTags[dateTag]=typedArrayTags[errorTag]=typedArrayTags[funcTag]=typedArrayTags[mapTag]=typedArrayTags[numberTag$1]=typedArrayTags[objectTag]=typedArrayTags[regexpTag]=typedArrayTags[setTag]=typedArrayTags[stringTag]=typedArrayTags[weakMapTag]=!1;var freeExports="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule=freeExports&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports=freeModule&&freeModule.exports===freeExports,freeProcess=moduleExports&&freeGlobal$1.process,nodeUtil=function(){try{var e=freeModule&&freeModule.require&&freeModule.require("util").types;return e||freeProcess&&freeProcess.binding&&freeProcess.binding("util")}catch(e){}}(),nodeUtil$1=nodeUtil,nodeIsTypedArray=nodeUtil$1&&nodeUtil$1.isTypedArray,isTypedArray=nodeIsTypedArray?baseUnary(nodeIsTypedArray):baseIsTypedArray,isTypedArray$1=isTypedArray,objectProto$2=Object.prototype,hasOwnProperty$2=objectProto$2.hasOwnProperty;function arrayLikeKeys(e,t){var r=isArray$1(e),i=!r&&isArguments$1(e),s=!r&&!i&&isBuffer$1(e),o=!r&&!i&&!s&&isTypedArray$1(e),n=r||i||s||o,a=n?baseTimes(e.length,String):[],d=a.length;for(var u in e)!t&&!hasOwnProperty$2.call(e,u)||n&&("length"==u||s&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||isIndex(u,d))||a.push(u);return a}function nativeKeysIn(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}var objectProto$1=Object.prototype,hasOwnProperty$1=objectProto$1.hasOwnProperty;function baseKeysIn(e){if(!isObject(e))return nativeKeysIn(e);var t=isPrototype(e),r=[];for(var i in e)("constructor"!=i||!t&&hasOwnProperty$1.call(e,i))&&r.push(i);return r}function keysIn(e){return isArrayLike(e)?arrayLikeKeys(e,!0):baseKeysIn(e)}var now=function(){return root$1.Date.now()},now$1=now,FUNC_ERROR_TEXT="Expected a function",nativeMax=Math.max,nativeMin=Math.min;function debounce(e,t,r){var i,s,o,n,a,d,u=0,l=!1,c=!1,h=!0;if("function"!=typeof e)throw new TypeError(FUNC_ERROR_TEXT);function m(t){var r=i,o=s;return i=s=void 0,u=t,n=e.apply(o,r)}function p(e){return u=e,a=setTimeout(v,t),l?m(e):n}function f(e){var r=e-d;return void 0===d||r>=t||r<0||c&&e-u>=o}function v(){var e=now$1();if(f(e))return g(e);a=setTimeout(v,function(e){var r=t-(e-d);return c?nativeMin(r,o-(e-u)):r}(e))}function g(e){return a=void 0,h&&i?m(e):(i=s=void 0,n)}function S(){var e=now$1(),r=f(e);if(i=arguments,s=this,d=e,r){if(void 0===a)return p(d);if(c)return clearTimeout(a),a=setTimeout(v,t),m(d)}return void 0===a&&(a=setTimeout(v,t)),n}return t=toNumber(t)||0,isObject(r)&&(l=!!r.leading,o=(c="maxWait"in r)?nativeMax(toNumber(r.maxWait)||0,t):o,h="trailing"in r?!!r.trailing:h),S.cancel=function(){void 0!==a&&clearTimeout(a),u=0,i=d=s=a=void 0},S.flush=function(){return void 0===a?n:g(now$1())},S}var objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty,defaults=baseRest((function(e,t){e=Object(e);var r=-1,i=t.length,s=i>2?t[2]:void 0;for(s&&isIterateeCall(t[0],t[1],s)&&(i=1);++r<i;)for(var o=t[r],n=keysIn(o),a=-1,d=n.length;++a<d;){var u=n[a],l=e[u];(void 0===l||eq(l,objectProto[u])&&!hasOwnProperty.call(e,u))&&(e[u]=o[u])}return e})),pr=defaults,numberTag="[object Number]";function isNumber(e){return"number"==typeof e||isObjectLike(e)&&baseGetTag(e)==numberTag}const BROWSER_ALIASES_MAP={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Electron:"electron",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"},BROWSER_MAP={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",electron:"Electron",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"},PLATFORMS_MAP={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},OS_MAP={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"},ENGINE_MAP={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"};class Utils{static getFirstMatch(e,t){const r=t.match(e);return r&&r.length>0&&r[1]||""}static getSecondMatch(e,t){const r=t.match(e);return r&&r.length>1&&r[2]||""}static matchAndReturnConst(e,t,r){if(e.test(t))return r}static getWindowsVersionName(e){switch(e){case"NT":return"NT";case"XP":case"NT 5.1":return"XP";case"NT 5.0":return"2000";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}}static getMacOSVersionName(e){const t=e.split(".").splice(0,2).map((e=>parseInt(e,10)||0));if(t.push(0),10===t[0])switch(t[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}}static getAndroidVersionName(e){const t=e.split(".").splice(0,2).map((e=>parseInt(e,10)||0));if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0}static getVersionPrecision(e){return e.split(".").length}static compareVersions(e,t,r=!1){const i=Utils.getVersionPrecision(e),s=Utils.getVersionPrecision(t);let o=Math.max(i,s),n=0;const a=Utils.map([e,t],(e=>{const t=o-Utils.getVersionPrecision(e),r=e+new Array(t+1).join(".0");return Utils.map(r.split("."),(e=>new Array(20-e.length).join("0")+e)).reverse()}));for(r&&(n=o-Math.min(i,s)),o-=1;o>=n;){if(a[0][o]>a[1][o])return 1;if(a[0][o]===a[1][o]){if(o===n)return 0;o-=1}else if(a[0][o]<a[1][o])return-1}}static map(e,t){const r=[];let i;if(Array.prototype.map)return Array.prototype.map.call(e,t);for(i=0;i<e.length;i+=1)r.push(t(e[i]));return r}static find(e,t){let r,i;if(Array.prototype.find)return Array.prototype.find.call(e,t);for(r=0,i=e.length;r<i;r+=1){const i=e[r];if(t(i,r))return i}}static assign(e,...t){const r=e;let i,s;if(Object.assign)return Object.assign(e,...t);for(i=0,s=t.length;i<s;i+=1){const e=t[i];if("object"==typeof e&&null!==e){Object.keys(e).forEach((t=>{r[t]=e[t]}))}}return e}static getBrowserAlias(e){return BROWSER_ALIASES_MAP[e]}static getBrowserTypeByAlias(e){return BROWSER_MAP[e]||""}}const commonVersionIdentifier=/version\/(\d+(\.?_?\d+)+)/i,browsersList=[{test:[/googlebot/i],describe(e){const t={name:"Googlebot"},r=Utils.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||Utils.getFirstMatch(commonVersionIdentifier,e);return r&&(t.version=r),t}},{test:[/opera/i],describe(e){const t={name:"Opera"},r=Utils.getFirstMatch(commonVersionIdentifier,e)||Utils.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opr\/|opios/i],describe(e){const t={name:"Opera"},r=Utils.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||Utils.getFirstMatch(commonVersionIdentifier,e);return r&&(t.version=r),t}},{test:[/SamsungBrowser/i],describe(e){const t={name:"Samsung Internet for Android"},r=Utils.getFirstMatch(commonVersionIdentifier,e)||Utils.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Whale/i],describe(e){const t={name:"NAVER Whale Browser"},r=Utils.getFirstMatch(commonVersionIdentifier,e)||Utils.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MZBrowser/i],describe(e){const t={name:"MZ Browser"},r=Utils.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||Utils.getFirstMatch(commonVersionIdentifier,e);return r&&(t.version=r),t}},{test:[/focus/i],describe(e){const t={name:"Focus"},r=Utils.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||Utils.getFirstMatch(commonVersionIdentifier,e);return r&&(t.version=r),t}},{test:[/swing/i],describe(e){const t={name:"Swing"},r=Utils.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||Utils.getFirstMatch(commonVersionIdentifier,e);return r&&(t.version=r),t}},{test:[/coast/i],describe(e){const t={name:"Opera Coast"},r=Utils.getFirstMatch(commonVersionIdentifier,e)||Utils.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe(e){const t={name:"Opera Touch"},r=Utils.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,e)||Utils.getFirstMatch(commonVersionIdentifier,e);return r&&(t.version=r),t}},{test:[/yabrowser/i],describe(e){const t={name:"Yandex Browser"},r=Utils.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||Utils.getFirstMatch(commonVersionIdentifier,e);return r&&(t.version=r),t}},{test:[/ucbrowser/i],describe(e){const t={name:"UC Browser"},r=Utils.getFirstMatch(commonVersionIdentifier,e)||Utils.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Maxthon|mxios/i],describe(e){const t={name:"Maxthon"},r=Utils.getFirstMatch(commonVersionIdentifier,e)||Utils.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/epiphany/i],describe(e){const t={name:"Epiphany"},r=Utils.getFirstMatch(commonVersionIdentifier,e)||Utils.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/puffin/i],describe(e){const t={name:"Puffin"},r=Utils.getFirstMatch(commonVersionIdentifier,e)||Utils.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sleipnir/i],describe(e){const t={name:"Sleipnir"},r=Utils.getFirstMatch(commonVersionIdentifier,e)||Utils.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/k-meleon/i],describe(e){const t={name:"K-Meleon"},r=Utils.getFirstMatch(commonVersionIdentifier,e)||Utils.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/micromessenger/i],describe(e){const t={name:"WeChat"},r=Utils.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||Utils.getFirstMatch(commonVersionIdentifier,e);return r&&(t.version=r),t}},{test:[/qqbrowser/i],describe(e){const t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},r=Utils.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||Utils.getFirstMatch(commonVersionIdentifier,e);return r&&(t.version=r),t}},{test:[/msie|trident/i],describe(e){const t={name:"Internet Explorer"},r=Utils.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/\sedg\//i],describe(e){const t={name:"Microsoft Edge"},r=Utils.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/edg([ea]|ios)/i],describe(e){const t={name:"Microsoft Edge"},r=Utils.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/vivaldi/i],describe(e){const t={name:"Vivaldi"},r=Utils.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/seamonkey/i],describe(e){const t={name:"SeaMonkey"},r=Utils.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sailfish/i],describe(e){const t={name:"Sailfish"},r=Utils.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return r&&(t.version=r),t}},{test:[/silk/i],describe(e){const t={name:"Amazon Silk"},r=Utils.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/phantom/i],describe(e){const t={name:"PhantomJS"},r=Utils.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/slimerjs/i],describe(e){const t={name:"SlimerJS"},r=Utils.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe(e){const t={name:"BlackBerry"},r=Utils.getFirstMatch(commonVersionIdentifier,e)||Utils.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(web|hpw)[o0]s/i],describe(e){const t={name:"WebOS Browser"},r=Utils.getFirstMatch(commonVersionIdentifier,e)||Utils.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/bada/i],describe(e){const t={name:"Bada"},r=Utils.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/tizen/i],describe(e){const t={name:"Tizen"},r=Utils.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||Utils.getFirstMatch(commonVersionIdentifier,e);return r&&(t.version=r),t}},{test:[/qupzilla/i],describe(e){const t={name:"QupZilla"},r=Utils.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||Utils.getFirstMatch(commonVersionIdentifier,e);return r&&(t.version=r),t}},{test:[/firefox|iceweasel|fxios/i],describe(e){const t={name:"Firefox"},r=Utils.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/electron/i],describe(e){const t={name:"Electron"},r=Utils.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MiuiBrowser/i],describe(e){const t={name:"Miui"},r=Utils.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/chromium/i],describe(e){const t={name:"Chromium"},r=Utils.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||Utils.getFirstMatch(commonVersionIdentifier,e);return r&&(t.version=r),t}},{test:[/chrome|crios|crmo/i],describe(e){const t={name:"Chrome"},r=Utils.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/GSA/i],describe(e){const t={name:"Google Search"},r=Utils.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test(e){const t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe(e){const t={name:"Android Browser"},r=Utils.getFirstMatch(commonVersionIdentifier,e);return r&&(t.version=r),t}},{test:[/playstation 4/i],describe(e){const t={name:"PlayStation 4"},r=Utils.getFirstMatch(commonVersionIdentifier,e);return r&&(t.version=r),t}},{test:[/safari|applewebkit/i],describe(e){const t={name:"Safari"},r=Utils.getFirstMatch(commonVersionIdentifier,e);return r&&(t.version=r),t}},{test:[/.*/i],describe(e){const t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:Utils.getFirstMatch(t,e),version:Utils.getSecondMatch(t,e)}}}];var osParsersList=[{test:[/Roku\/DVP/],describe(e){const t=Utils.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:OS_MAP.Roku,version:t}}},{test:[/windows phone/i],describe(e){const t=Utils.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:OS_MAP.WindowsPhone,version:t}}},{test:[/windows /i],describe(e){const t=Utils.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),r=Utils.getWindowsVersionName(t);return{name:OS_MAP.Windows,version:t,versionName:r}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe(e){const t={name:OS_MAP.iOS},r=Utils.getSecondMatch(/(Version\/)(\d[\d.]+)/,e);return r&&(t.version=r),t}},{test:[/macintosh/i],describe(e){const t=Utils.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),r=Utils.getMacOSVersionName(t),i={name:OS_MAP.MacOS,version:t};return r&&(i.versionName=r),i}},{test:[/(ipod|iphone|ipad)/i],describe(e){const t=Utils.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:OS_MAP.iOS,version:t}}},{test(e){const t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe(e){const t=Utils.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),r=Utils.getAndroidVersionName(t),i={name:OS_MAP.Android,version:t};return r&&(i.versionName=r),i}},{test:[/(web|hpw)[o0]s/i],describe(e){const t=Utils.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),r={name:OS_MAP.WebOS};return t&&t.length&&(r.version=t),r}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe(e){const t=Utils.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||Utils.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||Utils.getFirstMatch(/\bbb(\d+)/i,e);return{name:OS_MAP.BlackBerry,version:t}}},{test:[/bada/i],describe(e){const t=Utils.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:OS_MAP.Bada,version:t}}},{test:[/tizen/i],describe(e){const t=Utils.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:OS_MAP.Tizen,version:t}}},{test:[/linux/i],describe:()=>({name:OS_MAP.Linux})},{test:[/CrOS/],describe:()=>({name:OS_MAP.ChromeOS})},{test:[/PlayStation 4/],describe(e){const t=Utils.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:OS_MAP.PlayStation4,version:t}}}],platformParsersList=[{test:[/googlebot/i],describe:()=>({type:"bot",vendor:"Google"})},{test:[/huawei/i],describe(e){const t=Utils.getFirstMatch(/(can-l01)/i,e)&&"Nova",r={type:PLATFORMS_MAP.mobile,vendor:"Huawei"};return t&&(r.model=t),r}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:()=>({type:PLATFORMS_MAP.tablet,vendor:"Nexus"})},{test:[/ipad/i],describe:()=>({type:PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"})},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:()=>({type:PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"})},{test:[/kftt build/i],describe:()=>({type:PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"})},{test:[/silk/i],describe:()=>({type:PLATFORMS_MAP.tablet,vendor:"Amazon"})},{test:[/tablet(?! pc)/i],describe:()=>({type:PLATFORMS_MAP.tablet})},{test(e){const t=e.test(/ipod|iphone/i),r=e.test(/like (ipod|iphone)/i);return t&&!r},describe(e){const t=Utils.getFirstMatch(/(ipod|iphone)/i,e);return{type:PLATFORMS_MAP.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:()=>({type:PLATFORMS_MAP.mobile,vendor:"Nexus"})},{test:[/[^-]mobi/i],describe:()=>({type:PLATFORMS_MAP.mobile})},{test:e=>"blackberry"===e.getBrowserName(!0),describe:()=>({type:PLATFORMS_MAP.mobile,vendor:"BlackBerry"})},{test:e=>"bada"===e.getBrowserName(!0),describe:()=>({type:PLATFORMS_MAP.mobile})},{test:e=>"windows phone"===e.getBrowserName(),describe:()=>({type:PLATFORMS_MAP.mobile,vendor:"Microsoft"})},{test(e){const t=Number(String(e.getOSVersion()).split(".")[0]);return"android"===e.getOSName(!0)&&t>=3},describe:()=>({type:PLATFORMS_MAP.tablet})},{test:e=>"android"===e.getOSName(!0),describe:()=>({type:PLATFORMS_MAP.mobile})},{test:e=>"macos"===e.getOSName(!0),describe:()=>({type:PLATFORMS_MAP.desktop,vendor:"Apple"})},{test:e=>"windows"===e.getOSName(!0),describe:()=>({type:PLATFORMS_MAP.desktop})},{test:e=>"linux"===e.getOSName(!0),describe:()=>({type:PLATFORMS_MAP.desktop})},{test:e=>"playstation 4"===e.getOSName(!0),describe:()=>({type:PLATFORMS_MAP.tv})},{test:e=>"roku"===e.getOSName(!0),describe:()=>({type:PLATFORMS_MAP.tv})}],enginesParsersList=[{test:e=>"microsoft edge"===e.getBrowserName(!0),describe(e){if(/\sedg\//i.test(e))return{name:ENGINE_MAP.Blink};const t=Utils.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:ENGINE_MAP.EdgeHTML,version:t}}},{test:[/trident/i],describe(e){const t={name:ENGINE_MAP.Trident},r=Utils.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:e=>e.test(/presto/i),describe(e){const t={name:ENGINE_MAP.Presto},r=Utils.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test(e){const t=e.test(/gecko/i),r=e.test(/like gecko/i);return t&&!r},describe(e){const t={name:ENGINE_MAP.Gecko},r=Utils.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(apple)?webkit\/537\.36/i],describe:()=>({name:ENGINE_MAP.Blink})},{test:[/(apple)?webkit/i],describe(e){const t={name:ENGINE_MAP.WebKit},r=Utils.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}}];class Parser{constructor(e,t=!1){if(null==e||""===e)throw new Error("UserAgent parameter can't be empty");this._ua=e,this.parsedResult={},!0!==t&&this.parse()}getUA(){return this._ua}test(e){return e.test(this._ua)}parseBrowser(){this.parsedResult.browser={};const e=Utils.find(browsersList,(e=>{if("function"==typeof e.test)return e.test(this);if(e.test instanceof Array)return e.test.some((e=>this.test(e)));throw new Error("Browser's test function is not valid")}));return e&&(this.parsedResult.browser=e.describe(this.getUA())),this.parsedResult.browser}getBrowser(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()}getBrowserName(e){return e?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""}getBrowserVersion(){return this.getBrowser().version}getOS(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()}parseOS(){this.parsedResult.os={};const e=Utils.find(osParsersList,(e=>{if("function"==typeof e.test)return e.test(this);if(e.test instanceof Array)return e.test.some((e=>this.test(e)));throw new Error("Browser's test function is not valid")}));return e&&(this.parsedResult.os=e.describe(this.getUA())),this.parsedResult.os}getOSName(e){const{name:t}=this.getOS();return e?String(t).toLowerCase()||"":t||""}getOSVersion(){return this.getOS().version}getPlatform(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()}getPlatformType(e=!1){const{type:t}=this.getPlatform();return e?String(t).toLowerCase()||"":t||""}parsePlatform(){this.parsedResult.platform={};const e=Utils.find(platformParsersList,(e=>{if("function"==typeof e.test)return e.test(this);if(e.test instanceof Array)return e.test.some((e=>this.test(e)));throw new Error("Browser's test function is not valid")}));return e&&(this.parsedResult.platform=e.describe(this.getUA())),this.parsedResult.platform}getEngine(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()}getEngineName(e){return e?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""}parseEngine(){this.parsedResult.engine={};const e=Utils.find(enginesParsersList,(e=>{if("function"==typeof e.test)return e.test(this);if(e.test instanceof Array)return e.test.some((e=>this.test(e)));throw new Error("Browser's test function is not valid")}));return e&&(this.parsedResult.engine=e.describe(this.getUA())),this.parsedResult.engine}parse(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this}getResult(){return Utils.assign({},this.parsedResult)}satisfies(e){const t={};let r=0;const i={};let s=0;if(Object.keys(e).forEach((o=>{const n=e[o];"string"==typeof n?(i[o]=n,s+=1):"object"==typeof n&&(t[o]=n,r+=1)})),r>0){const e=Object.keys(t),r=Utils.find(e,(e=>this.isOS(e)));if(r){const e=this.satisfies(t[r]);if(void 0!==e)return e}const i=Utils.find(e,(e=>this.isPlatform(e)));if(i){const e=this.satisfies(t[i]);if(void 0!==e)return e}}if(s>0){const e=Object.keys(i),t=Utils.find(e,(e=>this.isBrowser(e,!0)));if(void 0!==t)return this.compareVersion(i[t])}}isBrowser(e,t=!1){const r=this.getBrowserName().toLowerCase();let i=e.toLowerCase();const s=Utils.getBrowserTypeByAlias(i);return t&&s&&(i=s.toLowerCase()),i===r}compareVersion(e){let t=[0],r=e,i=!1;const s=this.getBrowserVersion();if("string"==typeof s)return">"===e[0]||"<"===e[0]?(r=e.substr(1),"="===e[1]?(i=!0,r=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?r=e.substr(1):"~"===e[0]&&(i=!0,r=e.substr(1)),t.indexOf(Utils.compareVersions(s,r,i))>-1}isOS(e){return this.getOSName(!0)===String(e).toLowerCase()}isPlatform(e){return this.getPlatformType(!0)===String(e).toLowerCase()}isEngine(e){return this.getEngineName(!0)===String(e).toLowerCase()}is(e,t=!1){return this.isBrowser(e,t)||this.isOS(e)||this.isPlatform(e)}some(e=[]){return e.some((e=>this.is(e)))}}
|
|
2
|
-
/*!
|
|
3
|
-
* Bowser - a browser detector
|
|
4
|
-
* https://github.com/lancedikson/bowser
|
|
5
|
-
* MIT License | (c) Dustin Diaz 2012-2015
|
|
6
|
-
* MIT License | (c) Denis Demchenko 2015-2019
|
|
7
|
-
*/class Bowser{static getParser(e,t=!1){if("string"!=typeof e)throw new Error("UserAgent should be a string");return new Parser(e,t)}static parse(e){return new Parser(e).getResult()}static get BROWSER_MAP(){return BROWSER_MAP}static get ENGINE_MAP(){return ENGINE_MAP}static get OS_MAP(){return OS_MAP}static get PLATFORMS_MAP(){return PLATFORMS_MAP}}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},specialChar="~",safeSpecialChar="\\x"+("0"+specialChar.charCodeAt(0).toString(16)).slice(-2),escapedSafeSpecialChar="\\"+safeSpecialChar,specialCharRG=new RegExp(safeSpecialChar,"g"),safeSpecialCharRG=new RegExp(escapedSafeSpecialChar,"g"),safeStartWithSpecialCharRG=new RegExp("(?:^|([^\\\\]))"+escapedSafeSpecialChar),indexOf$1=[].indexOf||function(e){for(var t=this.length;t--&&this[t]!==e;);return t},$String=String;
|
|
8
|
-
/*!
|
|
9
|
-
Copyright (C) 2013-2017 by Andrea Giammarchi - @WebReflection
|
|
10
|
-
|
|
11
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
-
in the Software without restriction, including without limitation the rights
|
|
14
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
-
furnished to do so, subject to the following conditions:
|
|
17
|
-
|
|
18
|
-
The above copyright notice and this permission notice shall be included in
|
|
19
|
-
all copies or substantial portions of the Software.
|
|
20
|
-
|
|
21
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
27
|
-
THE SOFTWARE.
|
|
28
|
-
|
|
29
|
-
*/function generateReplacer(e,t,r){var i,s,o=!1,n=!!t,a=[],d=[e],u=[e],l=[r?specialChar:"[Circular]"],c=e,h=1;return n&&(s="object"==typeof t?function(e,r){return""!==e&&t.indexOf(e)<0?void 0:r}:t),function(e,t){return n&&(t=s.call(this,e,t)),o?(c!==this&&(i=h-indexOf$1.call(d,this)-1,h-=i,d.splice(h,d.length),a.splice(h-1,a.length),c=this),"object"==typeof t&&t?(indexOf$1.call(d,t)<0&&d.push(c=t),h=d.length,(i=indexOf$1.call(u,t))<0?(i=u.push(t)-1,r?(a.push((""+e).replace(specialCharRG,safeSpecialChar)),l[i]=specialChar+a.join(specialChar)):l[i]=l[0]):t=l[i]):"string"==typeof t&&r&&(t=t.replace(safeSpecialChar,escapedSafeSpecialChar).replace(specialChar,safeSpecialChar))):o=!0,t}}function retrieveFromPath(e,t){for(var r=0,i=t.length;r<i;e=e[t[r++].replace(safeSpecialCharRG,specialChar)]);return e}function generateReviver(e){return function(t,r){var i="string"==typeof r;return i&&r.charAt(0)===specialChar?new $String(r.slice(1)):(""===t&&(r=regenerate(r,r,{})),i&&(r=r.replace(safeStartWithSpecialCharRG,"$1"+specialChar).replace(escapedSafeSpecialChar,safeSpecialChar)),e?e.call(this,t,r):r)}}function regenerateArray(e,t,r){for(var i=0,s=t.length;i<s;i++)t[i]=regenerate(e,t[i],r);return t}function regenerateObject(e,t,r){for(var i in t)t.hasOwnProperty(i)&&(t[i]=regenerate(e,t[i],r));return t}function regenerate(e,t,r){return t instanceof Array?regenerateArray(e,t,r):t instanceof $String?t.length?r.hasOwnProperty(t)?r[t]:r[t]=retrieveFromPath(e,t.split(specialChar)):e:t instanceof Object?regenerateObject(e,t,r):t}var CircularJSON={stringify:function(e,t,r,i){return CircularJSON.parser.stringify(e,generateReplacer(e,t,!i),r)},parse:function(e,t){return CircularJSON.parser.parse(e,generateReviver(t))},parser:JSON},circularJson_node=CircularJSON;function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}var cachedSetTimeout=defaultSetTimout,cachedClearTimeout=defaultClearTimeout;function runTimeout(e){if(cachedSetTimeout===setTimeout)return setTimeout(e,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(e,0);try{return cachedSetTimeout(e,0)}catch(t){try{return cachedSetTimeout.call(null,e,0)}catch(t){return cachedSetTimeout.call(this,e,0)}}}function runClearTimeout(e){if(cachedClearTimeout===clearTimeout)return clearTimeout(e);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(e);try{return cachedClearTimeout(e)}catch(t){try{return cachedClearTimeout.call(null,e)}catch(t){return cachedClearTimeout.call(this,e)}}}"function"==typeof global$1.setTimeout&&(cachedSetTimeout=setTimeout),"function"==typeof global$1.clearTimeout&&(cachedClearTimeout=clearTimeout);var queue=[],draining=!1,currentQueue,queueIndex=-1;function cleanUpNextTick(){draining&¤tQueue&&(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var e=runTimeout(cleanUpNextTick);draining=!0;for(var t=queue.length;t;){for(currentQueue=queue,queue=[];++queueIndex<t;)currentQueue&¤tQueue[queueIndex].run();queueIndex=-1,t=queue.length}currentQueue=null,draining=!1,runClearTimeout(e)}}function nextTick(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];queue.push(new Item(e,t)),1!==queue.length||draining||runTimeout(drainQueue)}function Item(e,t){this.fun=e,this.array=t}Item.prototype.run=function(){this.fun.apply(null,this.array)};var title="browser",platform="browser",browser=!0,env={},argv=[],version$1="",versions={},release={},config$1={};function noop$1(){}var on=noop$1,addListener=noop$1,once=noop$1,off=noop$1,removeListener=noop$1,removeAllListeners=noop$1,emit=noop$1;function binding(e){throw new Error("process.binding is not supported")}function cwd(){return"/"}function chdir(e){throw new Error("process.chdir is not supported")}function umask(){return 0}var performance=global$1.performance||{},performanceNow=performance.now||performance.mozNow||performance.msNow||performance.oNow||performance.webkitNow||function(){return(new Date).getTime()};function hrtime(e){var t=.001*performanceNow.call(performance),r=Math.floor(t),i=Math.floor(t%1*1e9);return e&&(r-=e[0],(i-=e[1])<0&&(r--,i+=1e9)),[r,i]}var startTime=new Date;function uptime(){return(new Date-startTime)/1e3}var process$1={nextTick:nextTick,title:title,browser:browser,env:env,argv:argv,version:version$1,versions:versions,on:on,addListener:addListener,once:once,off:off,removeListener:removeListener,removeAllListeners:removeAllListeners,emit:emit,binding:binding,cwd:cwd,chdir:chdir,umask:umask,hrtime:hrtime,platform:platform,release:release,config:config$1,uptime:uptime},md5={exports:{}};(function(module){(function(){var ERROR="input is invalid type",WINDOW="object"==typeof window,root=WINDOW?window:{};root.JS_MD5_NO_WINDOW&&(WINDOW=!1);var WEB_WORKER=!WINDOW&&"object"==typeof self,NODE_JS=!root.JS_MD5_NO_NODE_JS&&"object"==typeof process$1&&process$1.versions&&process$1.versions.node;NODE_JS?root=commonjsGlobal:WEB_WORKER&&(root=self);var COMMON_JS=!root.JS_MD5_NO_COMMON_JS&&module.exports,ARRAY_BUFFER=!root.JS_MD5_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,HEX_CHARS="0123456789abcdef".split(""),EXTRA=[128,32768,8388608,-2147483648],SHIFT=[0,8,16,24],OUTPUT_TYPES=["hex","array","digest","buffer","arrayBuffer","base64"],BASE64_ENCODE_CHAR="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),blocks=[],buffer8;if(ARRAY_BUFFER){var buffer=new ArrayBuffer(68);buffer8=new Uint8Array(buffer),blocks=new Uint32Array(buffer)}!root.JS_MD5_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!ARRAY_BUFFER||!root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});var createOutputMethod=function(e){return function(t){return new Md5(!0).update(t)[e]()}},createMethod=function(){var e=createOutputMethod("hex");NODE_JS&&(e=nodeWrap(e)),e.create=function(){return new Md5},e.update=function(t){return e.create().update(t)};for(var t=0;t<OUTPUT_TYPES.length;++t){var r=OUTPUT_TYPES[t];e[r]=createOutputMethod(r)}return e},nodeWrap=function(method){var crypto=eval("require('crypto')"),Buffer=eval("require('buffer').Buffer"),nodeMethod=function(e){if("string"==typeof e)return crypto.createHash("md5").update(e,"utf8").digest("hex");if(null==e)throw ERROR;return e.constructor===ArrayBuffer&&(e=new Uint8Array(e)),Array.isArray(e)||ArrayBuffer.isView(e)||e.constructor===Buffer?crypto.createHash("md5").update(new Buffer(e)).digest("hex"):method(e)};return nodeMethod};function Md5(e){if(e)blocks[0]=blocks[16]=blocks[1]=blocks[2]=blocks[3]=blocks[4]=blocks[5]=blocks[6]=blocks[7]=blocks[8]=blocks[9]=blocks[10]=blocks[11]=blocks[12]=blocks[13]=blocks[14]=blocks[15]=0,this.blocks=blocks,this.buffer8=buffer8;else if(ARRAY_BUFFER){var t=new ArrayBuffer(68);this.buffer8=new Uint8Array(t),this.blocks=new Uint32Array(t)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}Md5.prototype.update=function(e){if(!this.finalized){var t,r=typeof e;if("string"!==r){if("object"!==r)throw ERROR;if(null===e)throw ERROR;if(ARRAY_BUFFER&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||ARRAY_BUFFER&&ArrayBuffer.isView(e)))throw ERROR;t=!0}for(var i,s,o=0,n=e.length,a=this.blocks,d=this.buffer8;o<n;){if(this.hashed&&(this.hashed=!1,a[0]=a[16],a[16]=a[1]=a[2]=a[3]=a[4]=a[5]=a[6]=a[7]=a[8]=a[9]=a[10]=a[11]=a[12]=a[13]=a[14]=a[15]=0),t)if(ARRAY_BUFFER)for(s=this.start;o<n&&s<64;++o)d[s++]=e[o];else for(s=this.start;o<n&&s<64;++o)a[s>>2]|=e[o]<<SHIFT[3&s++];else if(ARRAY_BUFFER)for(s=this.start;o<n&&s<64;++o)(i=e.charCodeAt(o))<128?d[s++]=i:i<2048?(d[s++]=192|i>>6,d[s++]=128|63&i):i<55296||i>=57344?(d[s++]=224|i>>12,d[s++]=128|i>>6&63,d[s++]=128|63&i):(i=65536+((1023&i)<<10|1023&e.charCodeAt(++o)),d[s++]=240|i>>18,d[s++]=128|i>>12&63,d[s++]=128|i>>6&63,d[s++]=128|63&i);else for(s=this.start;o<n&&s<64;++o)(i=e.charCodeAt(o))<128?a[s>>2]|=i<<SHIFT[3&s++]:i<2048?(a[s>>2]|=(192|i>>6)<<SHIFT[3&s++],a[s>>2]|=(128|63&i)<<SHIFT[3&s++]):i<55296||i>=57344?(a[s>>2]|=(224|i>>12)<<SHIFT[3&s++],a[s>>2]|=(128|i>>6&63)<<SHIFT[3&s++],a[s>>2]|=(128|63&i)<<SHIFT[3&s++]):(i=65536+((1023&i)<<10|1023&e.charCodeAt(++o)),a[s>>2]|=(240|i>>18)<<SHIFT[3&s++],a[s>>2]|=(128|i>>12&63)<<SHIFT[3&s++],a[s>>2]|=(128|i>>6&63)<<SHIFT[3&s++],a[s>>2]|=(128|63&i)<<SHIFT[3&s++]);this.lastByteIndex=s,this.bytes+=s-this.start,s>=64?(this.start=s-64,this.hash(),this.hashed=!0):this.start=s}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},Md5.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[t>>2]|=EXTRA[3&t],t>=56&&(this.hashed||this.hash(),e[0]=e[16],e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.bytes<<3,e[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},Md5.prototype.hash=function(){var e,t,r,i,s,o,n=this.blocks;this.first?t=((t=((e=((e=n[0]-680876937)<<7|e>>>25)-271733879<<0)^(r=((r=(-271733879^(i=((i=(-1732584194^2004318071&e)+n[1]-117830708)<<12|i>>>20)+e<<0)&(-271733879^e))+n[2]-1126478375)<<17|r>>>15)+i<<0)&(i^e))+n[3]-1316259209)<<22|t>>>10)+r<<0:(e=this.h0,t=this.h1,r=this.h2,t=((t+=((e=((e+=((i=this.h3)^t&(r^i))+n[0]-680876936)<<7|e>>>25)+t<<0)^(r=((r+=(t^(i=((i+=(r^e&(t^r))+n[1]-389564586)<<12|i>>>20)+e<<0)&(e^t))+n[2]+606105819)<<17|r>>>15)+i<<0)&(i^e))+n[3]-1044525330)<<22|t>>>10)+r<<0),t=((t+=((e=((e+=(i^t&(r^i))+n[4]-176418897)<<7|e>>>25)+t<<0)^(r=((r+=(t^(i=((i+=(r^e&(t^r))+n[5]+1200080426)<<12|i>>>20)+e<<0)&(e^t))+n[6]-1473231341)<<17|r>>>15)+i<<0)&(i^e))+n[7]-45705983)<<22|t>>>10)+r<<0,t=((t+=((e=((e+=(i^t&(r^i))+n[8]+1770035416)<<7|e>>>25)+t<<0)^(r=((r+=(t^(i=((i+=(r^e&(t^r))+n[9]-1958414417)<<12|i>>>20)+e<<0)&(e^t))+n[10]-42063)<<17|r>>>15)+i<<0)&(i^e))+n[11]-1990404162)<<22|t>>>10)+r<<0,t=((t+=((e=((e+=(i^t&(r^i))+n[12]+1804603682)<<7|e>>>25)+t<<0)^(r=((r+=(t^(i=((i+=(r^e&(t^r))+n[13]-40341101)<<12|i>>>20)+e<<0)&(e^t))+n[14]-1502002290)<<17|r>>>15)+i<<0)&(i^e))+n[15]+1236535329)<<22|t>>>10)+r<<0,t=((t+=((i=((i+=(t^r&((e=((e+=(r^i&(t^r))+n[1]-165796510)<<5|e>>>27)+t<<0)^t))+n[6]-1069501632)<<9|i>>>23)+e<<0)^e&((r=((r+=(e^t&(i^e))+n[11]+643717713)<<14|r>>>18)+i<<0)^i))+n[0]-373897302)<<20|t>>>12)+r<<0,t=((t+=((i=((i+=(t^r&((e=((e+=(r^i&(t^r))+n[5]-701558691)<<5|e>>>27)+t<<0)^t))+n[10]+38016083)<<9|i>>>23)+e<<0)^e&((r=((r+=(e^t&(i^e))+n[15]-660478335)<<14|r>>>18)+i<<0)^i))+n[4]-405537848)<<20|t>>>12)+r<<0,t=((t+=((i=((i+=(t^r&((e=((e+=(r^i&(t^r))+n[9]+568446438)<<5|e>>>27)+t<<0)^t))+n[14]-1019803690)<<9|i>>>23)+e<<0)^e&((r=((r+=(e^t&(i^e))+n[3]-187363961)<<14|r>>>18)+i<<0)^i))+n[8]+1163531501)<<20|t>>>12)+r<<0,t=((t+=((i=((i+=(t^r&((e=((e+=(r^i&(t^r))+n[13]-1444681467)<<5|e>>>27)+t<<0)^t))+n[2]-51403784)<<9|i>>>23)+e<<0)^e&((r=((r+=(e^t&(i^e))+n[7]+1735328473)<<14|r>>>18)+i<<0)^i))+n[12]-1926607734)<<20|t>>>12)+r<<0,t=((t+=((o=(i=((i+=((s=t^r)^(e=((e+=(s^i)+n[5]-378558)<<4|e>>>28)+t<<0))+n[8]-2022574463)<<11|i>>>21)+e<<0)^e)^(r=((r+=(o^t)+n[11]+1839030562)<<16|r>>>16)+i<<0))+n[14]-35309556)<<23|t>>>9)+r<<0,t=((t+=((o=(i=((i+=((s=t^r)^(e=((e+=(s^i)+n[1]-1530992060)<<4|e>>>28)+t<<0))+n[4]+1272893353)<<11|i>>>21)+e<<0)^e)^(r=((r+=(o^t)+n[7]-155497632)<<16|r>>>16)+i<<0))+n[10]-1094730640)<<23|t>>>9)+r<<0,t=((t+=((o=(i=((i+=((s=t^r)^(e=((e+=(s^i)+n[13]+681279174)<<4|e>>>28)+t<<0))+n[0]-358537222)<<11|i>>>21)+e<<0)^e)^(r=((r+=(o^t)+n[3]-722521979)<<16|r>>>16)+i<<0))+n[6]+76029189)<<23|t>>>9)+r<<0,t=((t+=((o=(i=((i+=((s=t^r)^(e=((e+=(s^i)+n[9]-640364487)<<4|e>>>28)+t<<0))+n[12]-421815835)<<11|i>>>21)+e<<0)^e)^(r=((r+=(o^t)+n[15]+530742520)<<16|r>>>16)+i<<0))+n[2]-995338651)<<23|t>>>9)+r<<0,t=((t+=((i=((i+=(t^((e=((e+=(r^(t|~i))+n[0]-198630844)<<6|e>>>26)+t<<0)|~r))+n[7]+1126891415)<<10|i>>>22)+e<<0)^((r=((r+=(e^(i|~t))+n[14]-1416354905)<<15|r>>>17)+i<<0)|~e))+n[5]-57434055)<<21|t>>>11)+r<<0,t=((t+=((i=((i+=(t^((e=((e+=(r^(t|~i))+n[12]+1700485571)<<6|e>>>26)+t<<0)|~r))+n[3]-1894986606)<<10|i>>>22)+e<<0)^((r=((r+=(e^(i|~t))+n[10]-1051523)<<15|r>>>17)+i<<0)|~e))+n[1]-2054922799)<<21|t>>>11)+r<<0,t=((t+=((i=((i+=(t^((e=((e+=(r^(t|~i))+n[8]+1873313359)<<6|e>>>26)+t<<0)|~r))+n[15]-30611744)<<10|i>>>22)+e<<0)^((r=((r+=(e^(i|~t))+n[6]-1560198380)<<15|r>>>17)+i<<0)|~e))+n[13]+1309151649)<<21|t>>>11)+r<<0,t=((t+=((i=((i+=(t^((e=((e+=(r^(t|~i))+n[4]-145523070)<<6|e>>>26)+t<<0)|~r))+n[11]-1120210379)<<10|i>>>22)+e<<0)^((r=((r+=(e^(i|~t))+n[2]+718787259)<<15|r>>>17)+i<<0)|~e))+n[9]-343485551)<<21|t>>>11)+r<<0,this.first?(this.h0=e+1732584193<<0,this.h1=t-271733879<<0,this.h2=r-1732584194<<0,this.h3=i+271733878<<0,this.first=!1):(this.h0=this.h0+e<<0,this.h1=this.h1+t<<0,this.h2=this.h2+r<<0,this.h3=this.h3+i<<0)},Md5.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,i=this.h3;return HEX_CHARS[e>>4&15]+HEX_CHARS[15&e]+HEX_CHARS[e>>12&15]+HEX_CHARS[e>>8&15]+HEX_CHARS[e>>20&15]+HEX_CHARS[e>>16&15]+HEX_CHARS[e>>28&15]+HEX_CHARS[e>>24&15]+HEX_CHARS[t>>4&15]+HEX_CHARS[15&t]+HEX_CHARS[t>>12&15]+HEX_CHARS[t>>8&15]+HEX_CHARS[t>>20&15]+HEX_CHARS[t>>16&15]+HEX_CHARS[t>>28&15]+HEX_CHARS[t>>24&15]+HEX_CHARS[r>>4&15]+HEX_CHARS[15&r]+HEX_CHARS[r>>12&15]+HEX_CHARS[r>>8&15]+HEX_CHARS[r>>20&15]+HEX_CHARS[r>>16&15]+HEX_CHARS[r>>28&15]+HEX_CHARS[r>>24&15]+HEX_CHARS[i>>4&15]+HEX_CHARS[15&i]+HEX_CHARS[i>>12&15]+HEX_CHARS[i>>8&15]+HEX_CHARS[i>>20&15]+HEX_CHARS[i>>16&15]+HEX_CHARS[i>>28&15]+HEX_CHARS[i>>24&15]},Md5.prototype.toString=Md5.prototype.hex,Md5.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,i=this.h3;return[255&e,e>>8&255,e>>16&255,e>>24&255,255&t,t>>8&255,t>>16&255,t>>24&255,255&r,r>>8&255,r>>16&255,r>>24&255,255&i,i>>8&255,i>>16&255,i>>24&255]},Md5.prototype.array=Md5.prototype.digest,Md5.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(16),t=new Uint32Array(e);return t[0]=this.h0,t[1]=this.h1,t[2]=this.h2,t[3]=this.h3,e},Md5.prototype.buffer=Md5.prototype.arrayBuffer,Md5.prototype.base64=function(){for(var e,t,r,i="",s=this.array(),o=0;o<15;)e=s[o++],t=s[o++],r=s[o++],i+=BASE64_ENCODE_CHAR[e>>>2]+BASE64_ENCODE_CHAR[63&(e<<4|t>>>4)]+BASE64_ENCODE_CHAR[63&(t<<2|r>>>6)]+BASE64_ENCODE_CHAR[63&r];return e=s[o],i+=BASE64_ENCODE_CHAR[e>>>2]+BASE64_ENCODE_CHAR[e<<4&63]+"=="};var exports=createMethod();COMMON_JS?module.exports=exports:root.md5=exports})()})(md5);var At=md5.exports,st=Object.defineProperty,rt=Object.getOwnPropertySymbols,Ut=Object.getPrototypeOf,qt=Object.prototype.hasOwnProperty,Pt=Object.prototype.propertyIsEnumerable,$t=Reflect.get,it=(e,t,r)=>t in e?st(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,nt=(e,t)=>{for(var r in t||(t={}))qt.call(t,r)&&it(e,r,t[r]);if(rt)for(var r of rt(t))Pt.call(t,r)&&it(e,r,t[r]);return e},be=(e=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(e,{get:(e,t)=>("undefined"!=typeof require?require:e)[t]}):e)((function(e){if("undefined"!=typeof require)return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')})),Bt=(e,t)=>{for(var r in t)st(e,r,{get:t[r],enumerable:!0})},ot=(e,t,r)=>$t(Ut(e),r,t),d=(e,t,r)=>new Promise(((i,s)=>{var o=e=>{try{a(r.next(e))}catch(e){s(e)}},n=e=>{try{a(r.throw(e))}catch(e){s(e)}},a=e=>e.done?i(e.value):Promise.resolve(e.value).then(o,n);a((r=r.apply(e,t)).next())})),oe=class{constructor(e,t,r){this.task=e,this.timeout=t,this.interval=r}start(){let e=this;e.stop();let t=e.timeout,r=e.interval,i=function(){!1!==e.task()&&e.timer?e.timer=setTimeout(i,e.interval):e.stop()};null==t&&(t=r),e.timer=setTimeout(i,t)}stop(){this.timer&&(clearTimeout(this.timer),this.timer=null)}updateInterval(e){this.interval=e}isStarted(){return!!this.timer}destroy(){this.stop(),this.task=this.timeout=this.interval=null}},at="onsend",ct="onreceive",O$1="reconnected",P$1="connected",$="close",_$1="error",E$1="timeout",B="reconnecting",ae="binary",k$1="notify",W="request",F=0,x$1=1,C$1=2,w$1=3,X$1=4,j$1=5,G$1="boom-bloud ",le=typeof console!==g.RAW_UNDEFINED?console:g.NULL,Ft=/bjy/.test(C$2(g.EMPTY_FUNCTION))?C$1:w$1,qe=g.WINDOW&&/edge|msie|trident/i.test(g.WINDOW.navigator.userAgent)?g.EMPTY_STRING:"%c",Z$1=le?qe?function(e,t,r,i){i?le.log(qe+e,r,t,i):le.log(qe+e,r,t)}:function(e,t,r){r?le.log(e,t,r):le.log(e,t)}:g.EMPTY_FUNCTION;function J(){if(g.GLOBAL){let e=g.GLOBAL.BJY_LOG_LEVEL;if(e>=F&&e<=j$1)return e}return Ft}function ee$1(e){return`background-color:${e};border-radius:12px;color:#fff;font-size:10px;padding:3px 6px;`}function lt(e,t){J()<=F&&Z$1(`${t||G$1} trace`,e,ee$1("#999"))}function ut(e,t){J()<=x$1&&Z$1(`${t||G$1} debug`,e,ee$1("#999"))}function ht(e,t){J()<=C$1&&Z$1(`${t||G$1} info`,e,ee$1("#2db7f5"))}function dt(e,t,r){J()<=C$1&&Z$1(`${t||G$1} info`,e,ee$1("#66cdaa"),r)}function mt$1(e,t){J()<=w$1&&Z$1(`${t||G$1} warn`,e,ee$1("#f90"))}function pt$1(e,t){J()<=X$1&&Z$1(`${t||G$1} error`,e,ee$1("#ed4014"))}function ft$1(e,t){if(J()<=j$1)throw new Error(`[${t||G$1} fatal]: ${e}`)}var jt=!0,Gt=w$1;function N$1(){return jt}function gt$1(){return Gt}var m=class e{constructor(e={}){this.TRACE=F,this.DEBUG=x$1,this.INFO=C$1,this.WARN=w$1,this.ERROR=X$1,this.FATAL=j$1,this.options=X$2.extend({uploadLevel:gt$1()},e),this.canUpload=!0}static Log(){return this.instance||(this.instance=new e),this.instance}enableUploadLog(){this.canUpload=!0}disableUploadLog(){this.canUpload=!1}setUploadLevel(e){this.options.uploadLevel=e}fatal(e,t,r=!1){(j$1>=this.options.uploadLevel||r)&&this.canUpload&&this.options.onUpload&&N$1()&&this.options.onUpload(e,j$1,t),ft$1(e,t)}error(e,t,r=!1){pt$1(e,t),(X$1>=this.options.uploadLevel||r)&&this.canUpload&&this.options.onUpload&&N$1()&&this.options.onUpload(e,X$1,t)}warn(e,t,r=!1){mt$1(e,t),(w$1>=this.options.uploadLevel||r)&&this.canUpload&&this.options.onUpload&&N$1()&&this.options.onUpload(e,w$1,t)}info(e,t,r=!1){ht(e,t),(C$1>=this.options.uploadLevel||r)&&this.canUpload&&this.options.onUpload&&N$1()&&this.options.onUpload(e,C$1,t)}call(e,t,r=!1){dt(e,t),(C$1>=this.options.uploadLevel||r)&&this.canUpload&&this.options.onUpload&&N$1()&&this.options.onUpload(e,C$1,t)}debug(e,t,r=!1,i=!1){ut(e,t),!i&&(x$1>=this.options.uploadLevel||r)&&this.canUpload&&this.options.onUpload&&N$1()&&this.options.onUpload(e,x$1,t)}trace(e,t,r=!1){lt(e,t),F>=this.options.uploadLevel&&r&&this.canUpload&&this.options.onUpload&&N$1()&&this.options.onUpload(e,F,t)}log(e,t,r,i=!1){switch(t){case F:this.trace(e,r,i);break;case x$1:this.debug(e,r,i);break;case C$1:this.info(e,r,i);break;case w$1:this.warn(e,r,i);break;case X$1:this.error(e,r,i);break;case j$1:this.fatal(e,r,i);break;default:this.debug(e,r,i)}}},{extend:Qt}=X$2,{func:D$1,string:Yt}=O$2,yt$1="RpcBuilder",Xt={maxRetry:0,requestTimeout:5e3,responseTimeout:5e3,duplicatesTimeout:5e3};function te$1(...e){let t="";for(let r=0;r<e.length;r++)e[r]&&(t+=e[r]);return t}var ue=class extends q$1{constructor(e,t,r={},i){super(!1),this.packer=e,this.options=Qt({},Xt,r),this.requestID=0,this.notifyId=0,this.reqMap=new Map,this.resMap=new Map,this.reqKeyMap=new Map,this.logger=i||new m,this.onmessageHandler=e=>{this.onmessage(e)},t&&this.handlTransport(t)}handlTransport(e){this.transport&&(D$1(this.transport.removeListener)?this.transport.removeListener(this.onmessageHandler):D$1(this.transport.removeEventListener)?this.transport.removeEventListener(this.onmessageHandler):D$1(this.transport.onmessage)&&(this.transport.onmessage=null)),e&&(D$1(e.addListener)?e.addListener("onmessage",this.onmessageHandler):D$1(e.addEventListener)?e.addEventListener("onmessage",this.onmessageHandler):e.onmessage=this.onmessageHandler,this.transport=e)}send(e){D$1(this.transport.send)?this.transport.send(e):D$1(this.transport.write)?this.transport.write(e):D$1(this.transport.postMessage)&&this.transport.postMessage(e)}request(e){return d(this,arguments,(function*(e,t={},r={}){if(!this.transport)throw new Error(`request ${e}, params: ${JSON.stringify(t)} failed, transport has closed or not set`);return new Promise(((i,s)=>{var o,n;if(r.key&&this.reqKeyMap.has(r.key)){let i=this.reqKeyMap.get(r.key);clearTimeout(i.timer),this.logger.warn(`request ${e}, params: ${JSON.stringify(t)} canceled because there is call new request whoes key is same as before`),i.reject(new Error("request canceled because there is call new request which key is same as before")),this.reqMap.delete(te$1(i.id)),this.reqKeyMap.delete(r.key)}let a=this.requestID++;r.dest&&(t.dest=r.dest),this.options.peerId&&(t.from=this.options.peerId);let d={resolve:i,reject:s,id:a,dest:r.dest,timer:null,retryCount:0,maxRetry:null!=(o=r.maxRetry)?o:this.options.maxRetry,errorRetry:null!=(n=r.errorRetry)&&n,method:e,params:t,message:this.packer.pack({method:e,params:t},a),timestamp:te$2(),key:r.key,timeout:r.timeout,timeoutFn:()=>{if(d.retryCount>=d.maxRetry){if(this.reqMap.delete(te$1(d.id)),d.key&&this.reqKeyMap.has(d.key)&&this.reqKeyMap.delete(d.key),this.logger.error(`request ${e}, params: ${JSON.stringify(t)} timeout`),this.sessionId!==t.sessionId)return void this.logger.warn(`sessionId is not same, ignore this time out fn: ${this.sessionId}`);s(new Error("request timeout"))}else d.retryCount++,d.timer=setTimeout(d.timeoutFn,r.timeout||this.options.requestTimeout),this.logger.warn(`retry request ${e}, params: ${JSON.stringify(t)}, count: ${d.retryCount}`),this.send(d.message)},needRetry:r.needRetry};d.timer=setTimeout(d.timeoutFn,r.timeout||this.options.requestTimeout*(d.retryCount+1)),this.reqMap.set(te$1(d.id),d),d.key&&this.reqKeyMap.set(d.key,d),this.send(d.message)}))}))}reply(e,t,r){var i;this.options.peerId&&(t&&(t.from=this.options.peerId),r&&(r.from=this.options.peerId));let s=this.packer.pack({result:t,error:r},e.id),o={id:e.id,message:s,timer:null},n=te$1(e.id,null==(i=e.params)?void 0:i.from);this.options.responseTimeout&&(o.timer=setTimeout((()=>{this.resMap.delete(n)}),this.options.responseTimeout),this.resMap.set(n,o)),this.send(o.message)}notify(e,t={},r){if(!this.transport)throw new Error(`notify ${e}, params: ${JSON.stringify(t)} failed, transport has closed or not set`);let i=this.notifyId++;r&&(t.dest=r),this.options.peerId&&(t.from=this.options.peerId),this.send(this.packer.pack({method:e,params:t,seq:i}))}onmessage(e){var t;if(this.transport)if(It$1(e))if(Yt(e)){let r;try{r=this.packer.unpack(e)}catch(t){return void this.logger.error(`unpack message error, message: ${e}, error: ${Vt(t)}`,yt$1)}let i=r.id,s=r.method,o=null!=(t=r.params)?t:{},n=o.dest;if(o.dest,It$1(this.options.peerId)&&this.options.peerId===n)return void this.logger.warn(`ignored the message which send from me, message: ${e}`);if(It$1(i))if(s){let t=this.resMap.get(te$1(i,n));t?(this.logger.warn(`request: ${e} has replyed in ${this.options.responseTimeout}ms, send same again`),this.send(t.message)):this.fire(W,[r])}else{let t=r.error,n=r.result;if((null==t?void 0:t.dest)!==this.options.peerId||(null==n?void 0:n.dest)!==this.options.peerId)return void this.logger.warn(`ignored the message which not sent for me, message: ${e}`);let a=te$1(i),d=this.reqMap.get(a);if(d){if(clearTimeout(d.timer),t){if(this.logger.error(`[request error] request: ${d.message}, response: ${e}, consume: ${te$2()-d.timestamp}`),d.errorRetry&&d.retryCount<d.maxRetry&&(!d.needRetry||d.needRetry(t)))return d.retryCount++,d.timer=setTimeout(d.timeoutFn,d.timeout||this.options.requestTimeout),this.logger.warn(`retry request ${d.method}, params: ${JSON.stringify(d.params)}, count: ${d.retryCount}`),d.id=this.requestID++,d.message=this.packer.pack({method:s,params:o},d.id),void this.send(d.message);d.reject(t)}else this.logger.debug(`[request success] method: ${d.method}, id: ${d.id}, consume: ${te$2()-d.timestamp}`),d.resolve(n);this.reqMap.delete(a),d.key&&this.reqKeyMap.has(d.key)&&this.reqKeyMap.delete(d.key)}else this.logger.warn(`no request for the response: ${e}`)}else this.fire(k$1,[s,o,r.seq])}else this.fire(ae,[e]);else this.logger.warn("message is not defined",yt$1)}destroy(){this.off(),this.handlTransport(),this.reqMap&&(this.reqMap.forEach((e=>{clearTimeout(e.timer),e.reject("transport closed")})),this.reqMap.clear(),this.reqMap=null),this.reqKeyMap&&(this.reqKeyMap.clear(),this.reqKeyMap=null),this.resMap&&(this.resMap.forEach((e=>{clearTimeout(e.timer)})),this.resMap.clear(),this.resMap=null),this.packer=null,this.transport=null}getPacker(){return this.packer}getTransport(){return this.transport}setTransport(e){this.handlTransport(e)}resetRequest(){this.reqMap&&this.reqMap.forEach((e=>{clearTimeout(e.timer),e.timer=setTimeout(e.timeoutFn,e.timeout||this.options.requestTimeout*(e.retryCount+1)),this.send(e.message)}))}},M={OPEN:"open",CLOSE:"close",ERROR:"error",SEND:"send",MESSAGE:"message",TIMEOUT:"timeout",RECONNECTING:"reconnecting"},Be=class extends q$1{constructor(e){var t;super(!0),X$2.extend(this,e),this.status=0,this.queue=[],this.isReconnect=!1,e.retryCount&&e.retryCount>0&&(this.retryIndex=0),this.logger=m.Log(),this.logLevel=null!=(t=this.logLevel)?t:this.logger.TRACE,this.connectCount=0}isOpen(){return 1===this.status}isConnecting(){return 6===this.status}getStatus(){return this.status}connect(e,t){let r=this;if(this.server=e,this.proxys=t,this.connectCount=0,1===r.status||6===r.status||4===r.status)return;let i=[e];t&&t.length&&(i=i.concat(t));let s=-1,o=function(){r.nextStartTimer=null,6===r.status?function(e,t){r.connectCount++;let i=r.nativeOptions;r.native===WebSocket&&(i=r.nativeOptions.protocols),r.logger.debug(`${r.tag||"Transport"} connecting url: ${e.url}`);let s,o=te$2(),n=new r.native(e.url,i),a=function(r){s&&clearTimeout(s),n.onopen=n.onerror=null,t(n,e,r)};n.onopen=function(e){var t;r.consume=null!=(t=null==e?void 0:e.consume)?t:te$2()-o,a(1)},n.onerror=function(){a(2)},r.timeout>0&&(s=setTimeout((function(){s=null,n.onerror=null,n.onopen=null,O$2.func(n.close)&&n.close(),a(5)}),r.timeout))}(i[++s],(function(e,o,a){if(6===r.status)if(1===a){if(r.url=o.url,r.socket=e,r.status=1,e.onmessage=function(e){1===r.status&&(r.logger.log(`${r.tag||"Transport"} Received: ${O$2.string(e.data)?e.data:"binary"}`,r.logLevel),r.onReceive&&O$2.string(e.data)&&r.onReceive(JSON.parse(e.data)),r.onmessage&&r.onmessage(e.data),r.fire(M.MESSAGE,[e.data]))},e.onclose=function(i){if(r.logger.error("bloud socket closed"),kt$1.error("bloud socket closed"),1===r.status)if(r.connectOnClose&&r.retryCount>0){if(r.status=0,r.onReconnecting&&(r.onReconnecting(),4===r.status||3===r.status))return;r.fire(M.RECONNECTING),r.isReconnect=!0,r.logger.warn(`${r.tag||"Transport"} reconnecting`),kt$1.warn(`${r.tag||"Transport"} reconnecting`),e.clear&&e.clear(),r.connect(o,t)}else r.onClose&&r.onClose(i),r.fire(M.CLOSE,[i])},r.retryCount>0&&(r.retryIndex=0),r.onOpen&&(r.logger.debug(`${r.tag||"Transport"} ${r.isReconnect?"reconnect":"connect"} success`),kt$1.info(`${r.tag||"Transport"} ${r.isReconnect?"reconnect":"connect"} success`),r.onOpen({server:o,reconnect:r.isReconnect})),r.fire(M.OPEN,[{server:o,reconnect:r.isReconnect}]),r.queue.length)for(;r.queue.length;){let t=r.queue.shift(),i=O$2.string(t)||O$2.arrayBuffer(t)?t:JSON.stringify(t);e.send(i),r.logger.log(`${r.tag||"Transport"} Sent: ${O$2.arrayBuffer(t)?"binary":i}`,r.logLevel),r.onSend&&r.onSend(i),r.fire(M.SEND,[i])}}else if(s===i.length-1){if(r.retryCount>0&&r.retryIndex++<r.retryCount-1)return s=-1,void n();switch(r.status=a){case 2:r.logger.error(`${r.tag||"Transport"} ${r.isReconnect?"reconnect":"connect"} error`),kt$1.error(`${r.tag||"Transport"} ${r.isReconnect?"reconnect":"connect"} error`),r.onError&&r.onError({server:o}),r.fire(M.ERROR,[{server:o}]);break;case 5:r.logger.error(`${r.tag||"Transport"} ${r.isReconnect?"reconnect":"connect"} timeout`),kt$1.error(`${r.tag||"Transport"} ${r.isReconnect?"reconnect":"connect"} timeout`),r.onTimeout&&r.onTimeout({server:o}),r.fire(M.TIMEOUT,[{server:o}])}}else n();else if(4===r.status){let t=!1;if(1===a&&r.refreshQueueOnClose&&r.queue.length){for(;r.queue.length;){let t=r.queue.shift(),i=O$2.string(t)||O$2.arrayBuffer(t)?t:JSON.stringify(t);e.send(i),r.logger.log(`${r.tag||"Transport"} Sent: ${O$2.arrayBuffer(t)?"binary":i}`,r.logLevel),r.onSend&&r.onSend(i),r.fire(M.SEND,[i])}t=!0}t?setTimeout((()=>{e.close(),r.status=3}),1e3):(e.close(),r.status=3)}})):4===r.status&&(r.status=3)},n=function(){r.interval>0?r.nextStartTimer=setTimeout(o,r.interval):o()};r.status=6,o()}send(e){if(1!==this.status&&4!==this.status)return this.queueMax>0&&this.queue.length===this.queueMax&&this.queue.shift(),void this.queue.push(e);let t=this.socket;if(t){let r=O$2.string(e)||O$2.arrayBuffer(e)?e:JSON.stringify(e);t.send(r),this.logger.log(`${this.tag||"Transport"} Sent: ${O$2.arrayBuffer(e)?"binary":r}`,this.logLevel),this.onSend&&this.onSend(r),this.fire(M.SEND,[r])}}close(){let e=this.socket;if(this.socket=null,this.status=4,e){let t=!1;if(this.refreshQueueOnClose&&this.queue.length){for(;this.queue.length;)this.send(this.queue.shift());t=!0}e.onmessage=e.onclose=null,t?setTimeout((()=>{e.close(),this.status=3}),1e3):(e.close(),this.status=3)}this.nextStartTimer&&(clearTimeout(this.nextStartTimer),this.nextStartTimer=null)}reconnect(){6!==this.status&&(this.close(),4===this.status?setTimeout((()=>{this.status=3,this.connect(this.server,this.proxys)}),1e3):this.connect(this.server,this.proxys))}getSocket(){return this.socket}getConsume(){return Math.max(this.consume||0,0)}getConnectCount(){return this.connectCount}},St$1=Be,de=class{constructor(){}},me=class extends de{constructor(){super()}pack(e,t){let r={jsonrpc:"2.0"};if(e.method)r.method=e.method,e.params&&(r.params=e.params),It$1(t)&&(r.id=t),e.seq&&(r.seq=e.seq);else if(It$1(t)){if(e.error){if(e.result)throw new TypeError("Both result and error are defined");r.error=e.error}else{if(!e.result)throw new TypeError("No result or error is defined");r.result=e.result}r.id=t}return JSON.stringify(r)}unpack(e){let t=JSON.parse(e);if("2.0"!==t.jsonrpc)throw new TypeError(`Invalid JsonRPC version ${t.jsonrpc}: ${e}`);if(!It$1(t.method)){if(!It$1(t.id))throw new TypeError(`Invalid message: ${e}`);let r=It$1(t.error),i=It$1(t.result);if(i&&r)throw new TypeError(`Both result and error are defined: ${e}`);if(!i&&!r)throw new TypeError(`No result or error is defined: ${e}`)}return t}},{extend:sr}=X$2,nr={heartbeat:15e3,requestTimeout:15e3,maxRetry:3,packer:me,retryInterval:500,connectTimeout:1e4,connectOnClose:!0,requestMaxRetry:0},pe=class extends q$1{constructor(e,t,r,i){var s,o;super(!0),this.server=e,this.proxys=r,this.options=sr({},nr,t),this.logger=m.Log(),this.heartbeatTimer=new oe((()=>{this.heartbeat()}),this.options.heartbeat,this.options.heartbeat),this.packer=new this.options.packer,this.transport=new St$1({native:null!=(s=this.options.transport)?s:WebSocket,onSend:e=>{this.fire(at,[e])},onReceive:e=>{this.fire(ct,[e])},onOpen:e=>{this.fire(e.reconnect?O$1:P$1),this.heartbeatTimer&&this.heartbeatTimer.start()},onClose:()=>{this.fire($),this.heartbeatTimer&&this.heartbeatTimer.stop()},onError:()=>{this.fire(_$1),this.heartbeatTimer&&this.heartbeatTimer.stop()},onTimeout:()=>{this.fire(E$1),this.heartbeatTimer&&this.heartbeatTimer.stop()},onReconnecting:()=>{this.fire(B),this.heartbeatTimer&&this.heartbeatTimer.stop()},connectOnClose:this.options.connectOnClose,retryCount:this.options.maxRetry,nativeOptions:null!=(o=this.options.transportOptions)?o:{},tag:this.options.tag,interval:this.options.retryInterval,timeout:this.options.connectTimeout,logLevel:this.options.logLevel}),this.rpc=new ue(this.packer,this.transport,{requestTimeout:this.options.requestTimeout,responseTimeout:this.options.requestTimeout,peerId:this.options.peerId,maxRetry:this.options.requestMaxRetry},this.logger),this.rpc.on(ae,(e=>{this.fire(ae,[e])})),this.rpc.on(k$1,((e,t,r)=>{this.fire(k$1,[e,t,r])})),this.rpc.on(W,(e=>{this.fire(W,[e])})),hn((()=>{this.transport&&this.transport.connect(this.server,this.proxys)}))}setRPCSessionId(e){this.rpc.sessionId=e}request(e){return d(this,arguments,(function*(e,t={},r){return this.rpc.request(e,t,r)}))}reply(e,t,r){return this.rpc.reply(e,t,r)}notify(e,t={}){return this.rpc.notify(e,t)}sendBinary(e){let t=this.transport.getSocket();t&&t.send(e)}getConsume(){return this.transport?this.transport.getConsume():0}getTransportConnectCount(){return this.transport?this.transport.getConnectCount():0}getTransportStatus(){return this.transport?this.transport.getStatus():0}destroy(){this.off(),this.rpc&&this.rpc.destroy(),this.transport&&this.transport.close(),this.transport=null,this.rpc=null,this.packer=null,this.heartbeatTimer&&this.heartbeatTimer.destroy(),this.heartbeatTimer=null}resetRequest(){this.rpc&&this.rpc.resetRequest()}},ie=class e extends pe{constructor(e,t,r,i){super({url:e},t,void 0,i),this.notified=-1,this.seq=0,this.sessionId=null,this.syncRoomLock=!1,this.retryQueue=[],this.proxy=r}resetTimeout(){this.resetTimer&&clearTimeout(this.resetTimer),this.resetTimer=setTimeout((()=>{this.resetTimer=void 0,this.fire(E$1),this.destroy()}),4*this.options.heartbeat)}syncNotify(){return d(this,null,(function*(){}))}request(t,r,i){return d(this,null,(function*(){let s=this.seq++;return this.syncRoomLock&&"syncRoom"!==t?(this.logger.warn(`session closed, waiting for sync room, method: ${t}, params: ${JSON.stringify(r)}`),new Promise(((e,i)=>{this.retryQueue.push({method:t,params:r,resolve:e,reject:i,id:s})}))):(!this.syncRoomLock&&"syncRoom"===t&&(this.syncRoomLock=!0),r&&"syncRoom"!==t&&!r.sessinId&&(r.sessionId=this.sessionId),r&&"syncRoom"===t&&(r.sid=this.sessionId),ot(e.prototype,this,"request").call(this,t,r,i).then((e=>(this.resetTimeout(),(!this.sessionId&&e.sessionId||this.sessionId!==e.sessionId)&&e.sessionId&&(this.sessionId=e.sessionId,this.setRPCSessionId(this.sessionId)),"syncRoom"===t&&(this.syncRoomLock=!1,this.retryQueue.length&&(this.retryQueue=this.retryQueue.filter((e=>"recover"!==e.method)),this.retryQueue.sort(((e,t)=>e.id-t.id)),J$1.each(this.retryQueue,(e=>{e.params.sessionId=this.sessionId,this.logger.info(`retry the retryQueue request, ${e.method}, params: ${JSON.stringify(e.params)}`),this.request(e.method,e.params).then((t=>{e.resolve(t)})).catch((t=>{e.reject(t)}))})),this.retryQueue=[])),e))).catch((e=>{var i;if("request timeout"!==Vt(e)&&this.resetTimeout(),99===(null==e?void 0:e.code))return this.sessionId&&this.sessionId!==r.sessionId?(this.logger.warn(`the request session has closed but the seesion is update after sync room, retry request again, ${t}, params: ${JSON.stringify(r)}`),r.sessionId=this.sessionId,this.request(t,r)):(this.syncRoomLock||(this.sessionId=null,this.syncRoomLock=!0,this.fire(H$1.SESSION_CLOED)),this.logger.warn(`the session has closed, push the request into retry queue, ${t}, params: ${JSON.stringify(r)}`),kt$1.warn("session closed, close socket to retry reconnect ws, and sync room"),null==(i=this.transport.socket)||i.close(),new Promise(((e,i)=>{this.retryQueue.push({method:t,params:r,resolve:e,reject:i,id:s})})));throw e})))}))}heartbeat(){this.request("ping",{sessionId:this.sessionId}).then((e=>{this.resetTimeout()})).catch((e=>{this.logger.error(`channel heartbeat error: ${JSON.stringify(e)}`)}))}destroy(){this.seq=null,this.notified=null,this.sessionId=null,this.retryQueue=null,this.syncRoomLock=null,this.resetTimer&&(clearTimeout(this.resetTimer),this.resetTimer=null),super.destroy()}getProxy(){return this.proxy}},mr={enableRace:!0,forceWS:!1,forceDC:!1,forceWT:!1},fe=class extends q$1{constructor(e,t,r={},i){super(!1),this.options=X$2.extend({},mr,t),this.closed=!1,this.icefull=!1,this.isConnecting=!1,this.connectCount=0,this.isLeaving=!1,this.rpc=r,this.proxies=e,this.logger=i||new m}getUrl(e){return e.activeUrl=e.url||e.dcurl||e.wturl,this.options.token&&(e.activeUrl+=`?token=${this.options.token}`),e.activeUrl}raceConnect(){return d(this,null,(function*(){let e=this.proxies;if(this.options.forceWS){let t=e.filter((e=>!!e.url));t.length&&(e=t)}this.connectingTimers={};let t=`.connecting${Math.random()}`;return new Promise(((r,i)=>{let s=!1;this.connectCount=0;let o=(e,o)=>{s?e.destroy():this.closed?(X$2.each(this.connectingTimers,(e=>{clearTimeout(e.timer),e.channel&&e.channel.destroy()})),this.connectingTimers={},this.logger.warn("signal open after call close function, reject"),i("signal has already closed")):(s=!0,X$2.each(this.connectingTimers,((e,t)=>{clearTimeout(e.timer),e.channel&&t!=o&&e.channel.destroy()})),this.connectingTimers={},e.off(t),this.connectCount=e.getTransportConnectCount(),r(e))},n=0,a=()=>{++n===e.length&&(X$2.each(this.connectingTimers,(e=>{e.channel&&e.channel.destroy()})),this.connectingTimers={},this.logger.error("connect all proxies failed"),i("connect all proxies failed"))},d=(e,r)=>{let i=new ie(e,{maxRetry:5,transport:void 0,transportOptions:{},tag:"Client",logLevel:x$1},r,this.logger);i.one(P$1+t,(()=>{r.consume=i.getConsume(),this.connectCount=i.getTransportConnectCount(),o(i,e)})).one(O$1+t,(()=>{r.consume=i.getConsume(),this.connectCount=i.getTransportConnectCount(),o(i,e)})).one(_$1+t,(()=>{this.connectCount=i.getTransportConnectCount(),a()})).one(E$1+t,(()=>{this.connectCount=i.getTransportConnectCount(),a()})),this.connectingTimers[e].channel=i};J$1.each(e,(e=>{let t=e.delay?Tn(e.delay):0,r=this.getUrl(e);r&&(this.connectingTimers[r]={timer:setTimeout((()=>{d(r,e)}),t)})}))}))}))}queueConnect(){return d(this,null,(function*(){let e=this.proxies;if(this.options.forceWS){let t=e.filter((e=>!!e.url));t.length&&(e=t)}let t=`.connecting${Math.random()}`;return new Promise(((r,i)=>{let s=0;this.connectCount=0;let o=()=>{this.closed&&i("signal has closed");let n=e[s],a=this.getUrl(n);a||i("url can not be empty!");let d=this.connectingChannel=new ie(a,{maxRetry:3,transport:void 0,transportOptions:{},tag:"Client",logLevel:x$1},n,this.logger);d.one(P$1+t,(()=>{d.off(t),this.connectingChannel=void 0,n.consume=d.getConsume(),this.connectCount+=d.getTransportConnectCount(),r(d)})).one(O$1+t,(()=>{d.off(t),this.connectingChannel=void 0,n.consume=d.getConsume(),this.connectCount+=d.getTransportConnectCount(),r(d)})).one(_$1+t,(()=>{this.connectCount+=d.getTransportConnectCount(),d.destroy(),this.connectingChannel=void 0,this.logger.error(`queue connect proxy: ${s} ${a} error`),this.fire(H$1.STATE_NOTIFY,[{level:this.logger.ERROR,msg:`queue connect proxy: ${s} ${a} error`}]),s++,s>=e.length?(this.logger.error("connect all proxies failed"),s=0,i("connect all proxies failed")):setTimeout((()=>{o()}),1e3)})).one(E$1+t,(()=>{this.connectCount+=d.getTransportConnectCount(),d.destroy(),this.connectingChannel=void 0,this.logger.error(`queue connect proxy: ${s} ${a} timeout`),this.fire(H$1.STATE_NOTIFY,[{level:this.logger.ERROR,msg:`queue connect proxy: ${s} ${a} timeout`}]),s++,s>=e.length?(this.logger.error("connect all proxies failed"),s=0,i("connect all proxies failed")):setTimeout((()=>{o()}),1e3)}))};o()}))}))}connect(){return d(this,null,(function*(){if(!this.proxies.length)return new Error("not has any proxy to connect");this.isConnecting=!0,this.options.enableRace?this.channel=yield this.raceConnect():this.channel=yield this.queueConnect(),this.channel.on(_$1,(()=>{this.logger.error(`proxy connect error, proxy: ${JSON.stringify(this.getProxy())}`),this.fire(_$1)})).on($,(()=>{this.logger.error(`proxy connect close, proxy: ${JSON.stringify(this.getProxy())}`),this.fire($)})).on(E$1,(()=>{this.logger.error(`proxy connect timeout, proxy: ${JSON.stringify(this.getProxy())}`),this.fire(E$1)})).on(P$1,(()=>{this.fire(P$1)})).on(B,(()=>{this.fire(B)})).on(O$1,(()=>{if(this.isLeaving)return;this.fire(O$1),this.channel.syncNotify();let e=this.channel.getProxy();e&&(e.consume=this.channel.getConsume())})).on(k$1,((e,t,r)=>{this.channel.notified=r,this.channel.resetTimeout(),xe$1[e]?this.fire(xe$1[e],[t]):this.fire(k$1,[{method:e,params:t}])})).on(W,(e=>d(this,null,(function*(){if(e.method&&this.rpc[e.method]){this.channel.resetTimeout();let{error:t,result:r}=yield this.rpc[e.method](e);this.channel.reply(e,r,t)}})))).on(H$1.SESSION_CLOED,(()=>{this.fire(H$1.SESSION_CLOED)})),this.isConnecting=!1,this.logger.info(`connect proxy success, proxy: ${JSON.stringify(this.channel.getProxy())}`)}))}request(e,t){return d(this,null,(function*(){return this.channel.request(e,t)}))}join(e){return d(this,null,(function*(){return this.channel.request("joinRoom",e).then((e=>(this.channel.resetTimeout(),this.isLeaving=!1,e)))}))}leave(e){return d(this,null,(function*(){return this.isLeaving=!0,this.channel.request("leaveRoom",e,{timeout:3e3}).then((e=>(this.isLeaving=!1,e)))}))}syncRoom(e,t,r){return d(this,null,(function*(){return this.channel.request("syncRoom",{roomId:e,userId:t,info:r})}))}updateCustomStats(e,t,r,i){return d(this,null,(function*(){return this.channel.request("updateCustomStats",{roomId:e,userId:t,options:r.customStats,replace:i})}))}updateStream(e,t,r){return d(this,null,(function*(){return this.channel.request("updateStream",nt({userId:e,streamId:t},r))}))}releaseRoom(e,t){return d(this,null,(function*(){return this.channel.request("releaseRoom",{roomId:e,userId:t})}))}updateRoom(e,t,r){return d(this,null,(function*(){return this.channel.request("updateRoom",{roomId:e,userId:t,options:r})}))}updateUser(e,t,r){return d(this,null,(function*(){return this.channel.request("updateUser",{roomId:e,userId:t,info:r})}))}evictUser(e,t,r,i){return d(this,null,(function*(){return this.channel.request("evictUser",{roomId:e,userId:t,evictId:r,withoutBlack:i})}))}changeMaster(e,t,r,i){return d(this,null,(function*(){return this.channel.request("changeMaster",{roomId:e,userId:t,master:r,isKeep:i})}))}leaveRoom(e,t,r){return d(this,null,(function*(){return this.channel.request("leaveRoom",{roomId:e,userId:t,desc:r})}))}getUsers(e,t,r,i,s,o){return d(this,null,(function*(){return this.channel.request("getUsers",{roomId:e,userId:t,pagesize:r,index:i,permission:s,waitRoom:o})}))}getUsersList(e,t,r,i){return d(this,null,(function*(){return this.channel.request("getUserList",{pagesize:t,index:e,permission:r,waitRoom:i})}))}queryUsers(e){return d(this,null,(function*(){return this.channel.request("queryUsers",{userIds:e})}))}publishStream(e,t,r,i){return d(this,null,(function*(){return this.channel.request("publishStream",{roomId:e,userId:t,streamId:r,options:i})}))}controlStream(e,t,r,i){return d(this,null,(function*(){return this.channel.request("controlStream",{roomId:e,userId:t,streamId:r,options:i})}))}resetStream(e,t,r,i){return d(this,null,(function*(){return this.channel.request("resetStream",{roomId:e,userId:t,streamId:r,options:i})}))}unpublishStream(e,t,r){return d(this,null,(function*(){return this.channel.request("unpublishStream",{roomId:e,userId:t,streamId:r})}))}getMessages(e,t,r){return d(this,null,(function*(){return this.channel.request("getMessages",{roomId:e,userId:t})}))}sendMessage(e,t,r,i){return d(this,null,(function*(){return this.channel.request("sendMessage",{roomId:e,userId:t,to:r,msg:i})}))}customMessage(e,t,r,i){return d(this,null,(function*(){return this.channel.request("customMessage",{roomId:e,userId:t,to:r,msg:i})}))}startRecord(e,t,r){return d(this,null,(function*(){return this.channel.request("startRecord",{roomId:e,streamId:t,options:r})}))}stopRecord(e,t){return d(this,null,(function*(){return this.channel.request("stopRecord",{roomId:e,streamId:t})}))}searchUsers(e,t,r){return d(this,null,(function*(){return this.channel.request("searchUsers",{nickname:e,pageSize:t,waitRoom:r})}))}syncUser(e){return d(this,null,(function*(){return this.channel.request("syncUser",{pageSize:e})}))}moveUserRoom(e,t,r){return d(this,null,(function*(){return this.channel.request("moveUserRoom",{target:e,toWait:t,autoJoin:r})}))}close(){this.connectingChannel&&this.connectingChannel.destroy(),X$2.keys(this.connectingTimers).length&&(X$2.each(this.connectingTimers,(e=>{clearTimeout(e.timer),e.channel&&e.channel.destroy()})),this.connectingTimers={}),this.channel&&this.channel.destroy(),this.closed=!0,this.off()}getSessionId(){var e;return null==(e=this.channel)?void 0:e.sessionId}getProxy(){var e;return null==(e=this.channel)?void 0:e.getProxy()}getConnectCount(){return this.connectCount}getConnectedProxyConsume(){var e;return null==(e=this.channel)?void 0:e.getConsume()}},We=()=>{let e=Te(),t="none";return null!==e.match("fake")?t="fake":null!==e.match("ios")?t="ios":null!==e.match("android")?t="android":null!==e.match("Firefox")?t="mozilla":null!==e.match("Chrome")?(t="chrome-stable",null!==e.match("Electron")&&(t="electron")):(null!==e.match("Safari")||null!==e.match("AppleWebKit"))&&(t="safari"),t},Te=()=>window.navigator.userAgent,Re=class e{constructor(t){this.permission=t||e.default}getRead(){return this.permission.indexOf("R")>=0}getWrite(){return this.permission.indexOf("W")>=0}getPublish(){return this.permission.indexOf("P")>=0}getSubscribe(){return this.permission.indexOf("S")>=0}getManage(){return this.permission.indexOf("M")>=0}getAudio(){return this.permission.indexOf("A")>=0}getVideo(){return this.permission.indexOf("V")>=0}getOwn(){return this.permission.indexOf("O")>=0}setManage(e){this._update("M",e)}setSubscribe(e){this._update("S",e)}setPublish(e){this._update("P",e)}setWrite(e){this._update("W",e)}setRead(e){this._update("R",e)}setAudio(e){this._update("A",e)}setVideo(e){this._update("V",e)}setOwn(e){this._update("O",e)}set(e){this.permission=e}get(){return this.permission}_update(e,t){t?this.permission.indexOf(e)<0&&(this.permission+=e):this.permission=this.permission.replace(e,"")}};Re.default="RWPSAV";var Fe=Re,A$1=class{constructor(e,t,r){this.streams=new Map,this.local=e,this.userId=t,this.params=r;let i=r.permission;!i&&r.info&&(i=r.info.permission),i||(i=Fe.default),this.permission=new Fe(i)}setID(e){this.userId=e}getID(){return this.userId}getPermission(){return this.permission}getUserInfo(){var e,t;return null!=(t=null!=(e=this.params.userinfo)?e:this.params.info.userinfo)?t:{}}update(e){e.permission&&this.permission.set(e.permission),this.params=pr(e,this.params)}getNickName(){var e,t;return null!=(t=null!=(e=this.params.nickname)?e:this.params.info.nickname)?t:""}getStreams(){return this.streams}getStream(e){return this.streams.get(e)}addStream(e){this.streams.set(e.getID(),e)}removeStream(e){this.streams.delete(e)}},fr=()=>{let e;try{e=be("react-native").Platform}catch(e){}let t="none";return"undefined"!=typeof module&&module.exports?e?"ios"===e.OS?t="ios":"android"===e.OS&&(t="android"):t="fake":t=window.navigator.userAgent,t},gr=()=>{let e;try{e=be("react-native").Platform}catch(e){}let t=!1;return"undefined"!=typeof module&&module.exports&&e&&("ios"===e.OS||"android"===e.OS)&&(t=!0),t},vr=()=>!1,yr={userAgent:fr,isMobile:gr,isElectron:vr},T$1=yr,je={};Bt(je,{CHROME:()=>V$1,ELECTRON:()=>Le,FIREFOX:()=>Ie,INTERNET_EXPLORER:()=>Ce,NWJS:()=>_e,OPERA:()=>Ee,REACT_NATIVE:()=>xe,SAFARI:()=>Oe,UNKNOWN:()=>ge,WECHAT:()=>Me});var V$1="chrome",Ee="opera",Ie="firefox",Ce="iexplorer",Oe="safari",_e="nwjs",Le="electron",xe="react-native",ge="unknown",Me="wechat",ke={Chrome:V$1,Chromium:V$1,Opera:Ee,Firefox:Ie,"Internet Explorer":Ce,Safari:Oe,WeChat:Me},K$1=navigator.userAgent;function Sr(){let e=K$1,t={name:ge,version:void 0};if(e.match(/Chrome/)&&!e.match(/Edge/))if(e.match(/Edg/)){let r=e.match(/Edg\/([\d.]+)/)[1];Number.parseInt(r,10)>72&&(t.name=V$1,t.version=r)}else t.name=V$1,t.version=e.match(/Chrome\/([\d.]+)/)[1];return t}function Tr(){let e=K$1;if(e.match(/Electron/)){let t=e.match(/Electron\/([\d.]+)/)[1];return{name:Le,version:t}}}function Rr(){let e=K$1;if(e.match(/JitsiMeetNW/)){let t=e.match(/JitsiMeetNW\/([\d.]+)/)[1];return{name:_e,version:t}}}function Er(){let e=K$1;if(e.match(/MicroMessenger/)){let t=e.match(/MicroMessenger\/([\d.]+)/)[1];return{name:Me,version:t}}}function Ir(){let e,t=K$1.match(/\b(react[ \t_-]*native)(?:\/(\S+))?/i);if(t||"ReactNative"===navigator.product)return t&&t.length>2&&(e=t[2]),e||(e="unknown"),{name:xe,version:e}}function Cr(e){let t,r=[Ir,Tr,Rr,Er];for(let e=0;e<r.length;e++)if(t=r[e](),t)return t;let i=e.getBrowserName();return i in ke?{name:ke[i],version:e.getBrowserVersion()}:(t=Sr(),t||{name:ge,version:void 0})}navigator.userAgent||(K$1=navigator.product);var H=class{constructor(e){let t,r;if(this.browsers=je,this._bowser=Bowser.getParser(K$1),void 0===e){let e=Cr(this._bowser);t=e.name,r=e.version}else e.name in ke?(t=ke[e.name],r=e.version):(t=ge,r=void 0);this._name=t,this._version=r}getName(){return this._name}isChrome(){return this._name===V$1}isOpera(){return this._name===Ee}isFirefox(){return this._name===Ie}isIExplorer(){return this._name===Ce}isSafari(){return this._name===Oe}isNWJS(){return this._name===_e}isElectron(){return this._name===Le}isReactNative(){return this._name===xe}getVersion(){return this._version}_checkCondition(e){if(this._version)return this._bowser.satisfies(e)}isVersionGreaterThan(e){return this._checkCondition({[this._name]:`>${e}`})}isVersionLessThan(e){return this._checkCondition({[this._name]:`<${e}`})}isVersionEqualTo(e){return this._checkCondition({[this._name]:`~${e}`})}},Or=()=>{let e;try{e=be("react-native-webrtc").mediaDevices}catch(t){e=navigator.mediaDevices}return e},_r=()=>{let e;try{e=be("react-native-webrtc").RTCPeerConnection}catch(t){e=RTCPeerConnection}return e},Lr={mediaDevices:Or,PRTCPeerConnection:_r},Rt=Lr,R=m.Log(),Et=()=>{let e="none";return null!==T$1.userAgent().match("fake")?e="fake":null!==T$1.userAgent().match("ios")?e="ios":null!==T$1.userAgent().match("android")?e="android":null!==T$1.userAgent().match("Firefox")?e="mozilla":null!==T$1.userAgent().match("Chrome")?(e="chrome-stable",null!==T$1.userAgent().match("Electron")&&(e="electron")):(null!==T$1.userAgent().match("Safari")||null!==T$1.userAgent().match("AppleWebKit"))&&(e="safari"),e},xr=()=>window.navigator.userAgent,Mr=(e,t=(()=>{}),r=(()=>{}))=>{let i,s=Rt.mediaDevices(),o=(e,t,r)=>{s.getUserMedia(e).then(t).catch(r)};e.screen?(()=>{switch(R.debug("Screen access requested"),Et()){case"electron":R.debug("Screen sharing in Electron"),i={},i.video=e.video||{},i.video.mandatory=e.video.mandatory||{},i.video.mandatory.chromeMediaSource="desktop",i.video.mandatory.chromeMediaSourceId=e.desktopStreamId,o(i,t,r);break;case"mozilla":case"mozilla":R.debug("Screen sharing in Firefox"),i={},void 0!==e.video?(i.video=e.video,i.video.mediaSource||(i.video.mediaSource="window")):i={audio:e.audio,video:{mediaSource:"window"}},o(i,t,r);break;case"chrome-stable":R.debug("Screen sharing in Chrome"),i={},e.desktopStreamId&&(i.video=e.video||{mandatory:{}},i.video.mandatory=i.video.mandatory||{},i.video.mandatory.chromeMediaSource="desktop",i.video.mandatory.chromeMediaSourceId=e.desktopStreamId,o(i,t,r));break;case"chrome-stable":if(R.debug("Screen sharing in Chrome"),i={},e.desktopStreamId)i.video=e.video||{mandatory:{}},i.video.mandatory=i.video.mandatory||{},i.video.mandatory.chromeMediaSource="desktop",i.video.mandatory.chromeMediaSourceId=e.desktopStreamId,o(i,t,r);else{let s="jbglfdfehfdcpnbhfnciaiokkfocjcjk";e.extensionId&&(R.debug(`extensionId supplied, using ${e.extensionId}`),s=e.extensionId),R.debug("Screen access on chrome stable, looking for extension");try{chrome.runtime.sendMessage(s,{getStream:!0},(s=>{if(void 0===s)return R.error("Access to screen denied"),void r({code:"Access to screen denied"});let n=s.streamId;void 0!==e.video.mandatory?(i.video=e.video||{mandatory:{}},i.video.mandatory.chromeMediaSource="desktop",i.video.mandatory.chromeMediaSourceId=n):i={video:{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:n}}},o(i,t,r)}))}catch(e){R.debug("Screensharing plugin is not accessible "),r({code:"no_plugin_present"})}}break;default:R.error("This browser does not support ScreenSharing")}})():(R.debug("Calling getUserMedia with config",e),o(e,t,r))};function kr(e,t){if(!t)return e;let r=e.getVideoTracks()[0];if(!r||"function"!=typeof r.getCapabilities)return e;let i=r.getConstraints(),s=e.clone();return r=s.getVideoTracks()[0],r?(e.getTracks().forEach((e=>e.stop())),i.width,i.height,i.frameRate=t||i.frameRate,r.applyConstraints(i),s):(s.getTracks().forEach((e=>e.stop())),e)}var wr=e=>new Promise(((t,r)=>{Mr(e,(r=>{(new H).isReactNative()&&t(r),e.fps&&r.clone?t(kr(r,e.fps)):t(r)}),(e=>{r(e)}))})),Nr={GetUserMedia:wr,getBrowser:Et,getUserAgent:xr},It=Nr,Dr={ERR_NOT_INSTALLED:1,ERR_NOT_FOUND:10,ERR_TIMEOUT:11,ERR_STATS:12,ERR_NO_SERVICE:13,ERR_AUTH:14,ERR_INVALID_REQUEST:15,ERR_METHOD:16,ERR_NOT_STARTUP:17,ERR_CUSTOM_AUTH_FAILED:18,ERR_USER_LIMIT:19,ERR_QDTLS:20,ERR_OVEVLOAD:21,ERR_EVICTED:22,ERR_PERMISSION:23,ERR_SENSITIVE_WORD:24,ERR_NOT_AT_ROOM:25,ERR_MEDIA_PIPELINE:26,ERR_NO_STREAM:27,ERR_LOCKED:28,ERR_UNKNOWN:33},we=Dr,Ge=class{constructor(){this._stream=null,this.avaliable=!0}check(){return new Promise(((e,t)=>{chrome.runtime.sendMessage({check:!0},(r=>{""!=r.id&&null!=r.id?e(r.id):t("not plugin")}))}))}detect(e){return new Promise(((t,r)=>{var i=document.createElement("img");i.src="chrome-extension://"+e+"/icon.png",i.onload=function(){t()},i.onerror=function(){r({code:we.ERR_NOT_INSTALLED,error:"not-installed"})}}))}start(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this,r=e.extensionId||"jbglfdfehfdcpnbhfnciaiokkfocjcjk";return this.detect(r).then((()=>new Promise(((i,s)=>{chrome.runtime.sendMessage(r,{getStream:!0},(r=>{if(void 0===r){return m.Log().error("Access to screen denied"),void error({code:"Access to screen denied"})}let o=t._toConstraints(e,r.streamId);It.GetUserMedia(o).then((e=>{t._stream=e,i(t._stream)})).catch((e=>{s(e)}))}))})))).catch((e=>{m.Log().warn("onerror plugin"),reject(e)}))}stop(){this._stream instanceof MediaStream&&(this._stream.getTracks().forEach((e=>e.stop())),this._stream=null)}isScreenShareAvailable(){return this.avaliable}needExtension(){return!this.avaliable}_toConstraints(e,t){let r={video:{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t},optional:[{googTemporalLayeredScreencast:!0}]},audio:!1};return isFinite(e.width)&&(r.video.mandatory.maxWidth=e.width,r.video.mandatory.minWidth=e.width),isFinite(e.height)&&(r.video.mandatory.maxHeight=e.height,r.video.mandatory.minHeight=e.height),isFinite(e.frameRate)&&(r.video.mandatory.maxFrameRate=e.frameRate,r.video.mandatory.minFrameRate=e.frameRate),r}},Je=class{constructor(){this._stream=null}start(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this._toConstraints(e);return navigator.mediaDevices.getDisplayMedia(t).then((e=>(this._stream=e,Promise.resolve(this._stream))))}stop(){this._stream instanceof MediaStream&&(this._stream.getTracks().forEach((e=>e.stop())),this._stream=null)}isScreenShareAvailable(){return!0}needExtension(){return!1}_toConstraints(e){return{video:{frameRate:e.fps},audio:e.audio||!1}}},Ve=class{constructor(){this._stream=null}start(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=this._toConstraints(t),i="boolean"==typeof t.audio&&t.audio;"boolean"==typeof t.isRecord&&t.isRecord,"boolean"==typeof t.isLocalProjection&&t.isLocalProjection;try{e=window.require("electron")}catch(t){e=window.parent.require("electron")}let s,o={types:["window","screen"]};if(e)s=e.desktopCapturer?e.desktopCapturer.getSources(o):e.ipcRenderer.invoke("desktopCapturer:getSources",o);else{let e;e=window.electronAPI?window.electronAPI.desktopCapturerGetSources(o):window.parent.electronAPI.desktopCapturerGetSources(o),s=e}let n=e=>{e.id.startsWith("window");let t=!!i&&{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:e.id,echoCancellation:!0}};return navigator.mediaDevices.getUserMedia({audio:t,video:{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:e.id,minWidth:r.video.mandatory.minWidth,maxWidth:r.video.mandatory.maxWidth,minHeight:r.video.mandatory.minHeight,maxHeight:r.video.mandatory.maxHeight,minFrameRate:r.video.mandatory.minFrameRate,maxFrameRate:r.video.mandatory.maxFrameRate}}}).then((t=>(console.log("ElectronScreenShare:",e.id),this._stream=t,t)))};return s.then((e=>d(this,null,(function*(){console.log("---share name selected:"+t.source_name,t.chromeMediaSourceId);let r=e.find((e=>e.id===t.chromeMediaSourceId));if(r)return n(r);for(let r of e)if(t.source_name===r.name){try{return n(r)}catch(e){console.log("ElectronScreenShare.start.error:",e)}break}if(t.chromeMediaSourceId){let e={id:t.chromeMediaSourceId};return n(e)}return null})))).catch((e=>(console.error("ElectronScreenShare:error",e),Promise.reject(e))))}stop(){this._stream instanceof MediaStream&&(this._stream.getTracks().forEach((e=>e.stop())),this._stream=null)}isScreenShareAvailable(){return!0}needExtension(){return!1}_toConstraints(e){let t={video:{frameRate:e.fps,mandatory:{maxWidth:e.width,minWidth:e.width,maxHeight:e.height,minHeight:e.height}},audio:!1};return m.Log().log("====fps:",e.fps),isFinite(e.width)&&(t.video.mandatory.maxWidth=e.width,t.video.mandatory.minWidth=e.width),isFinite(e.height)&&(t.video.mandatory.minHeight=e.height,t.video.mandatory.maxHeight=e.height),isFinite(e.fps)&&(t.video.mandatory.minFrameRate=e.fps,t.video.mandatory.maxFrameRate=e.fps),void 0===e.width&&(t.video.mandatory.maxWidth=1920,t.video.mandatory.minWidth=1920),void 0===e.height&&(t.video.mandatory.maxHeight=1080,t.video.mandatory.minHeight=1080),void 0===e.fps&&(t.video.mandatory.minFrameRate=15,t.video.mandatory.maxFrameRate=15),t}},z$1,He=class{static create(){if(z$1)return z$1;let e;e=T$1.isMobile()?T$1.userAgent():navigator.userAgent;let t,r=e,i=Bowser.getParser(r),s=i.getEngine();try{t=s.name.toLowerCase()}catch(e){}return(new H).isElectron()?(console.log("===========Client============="),z$1=new Ve):(console.log("===========Browser============="),i.satisfies({chrome:">=72",chromium:">=72"})?z$1=new Je:i.satisfies({chrome:">=55",chromium:">=55"})&&(z$1=new Ge),z$1)}},Ne=He,Ur=Ne.create();m.Log();var U=class{constructor(e,t,r,i,s){this.published=!1,this.audio=s.audio,this.video=s.video,this.audio_enable=s.audio_enable,this.video_enable=s.video_enable,this.screen=s.screen,this.client=e,this.room=t,this.participant=r,this.local=i,this.options=s,this.id=s.id,this.customInfo=s.customInfo,this.roomId=t.getID(),this.userId=r.getID()}audioEnabled(){return this.audio_enable}videoEnabled(){return this.video_enable}setAudioEnabled(e){return this.client.controlStream(this.roomId,this.userId,this.id,{audio_enable:e}).then((()=>{this.audio_enable=e}))}setVideoEnabled(e){return this.client.controlStream(this.roomId,this.userId,this.id,{video_enable:e}).then((()=>{this.video_enable=e}))}isLocal(){return this.local}getID(){return this.id}getParticipant(){return this.participant}publish(e){return d(this,null,(function*(){var t,r;this.audio_enable=null!=(t=e.audio_enable)?t:this.audio_enable,this.video_enable=null!=(r=e.video_enable)?r:this.video_enable,yield this.client.publishStream(this.roomId,this.userId,this.id,{audio_enable:this.audio_enable,video_enable:this.video_enable,video:this.video,audio:this.audio}),this.participant.addStream(this),this.published=!0}))}unpublish(){return d(this,null,(function*(){yield this.client.unpublishStream(this.roomId,this.userId,this.id),this.participant.removeStream(this.getID()),this.published=!1}))}static sharing(){return Ur}},Pr=2,Ct=1,$r=0,Ot=400,Br=15e3,_t=400,Ke=1,Wr=2,Q$1=127,b$1=0,Fr=75,ve=1e-10,jr=10,Gr=3,Ye=15,Lt=(Q$1-b$1+Ye-1)/Ye,xt=5,ze=5,Jr=36e5,Mt=2e3,kt=`.speakerDetector${Math.random()}`;function Vr(e,t){let r=e-t;t<r&&(t=r);let i=1;for(let r=e,s=1;r>t;r--,s++)i=Math.floor(i*r/s);return i}function wt(e,t,r){let i=t.length,s=Math.floor(e.length/i),o=!1;for(let n=0,a=0;n<i;n++){let i=0;for(let t=a+s;a<t;a++)e[a]>r&&i++;t[n]!=i&&(t[n]=i,o=!0)}return o}function Qe(e,t,r,i){let s=Math.log(Vr(t,e))+e*Math.log(r)+(t-e)*Math.log(1-r)-Math.log(i)+i*e;return s<ve&&(s=ve),s}var Xe=class{constructor(e){this.stream=e,this.immediates=new Array(Ke*ze*xt),this.immediateSpeechActivityScore=ve,this.lastLevelChangedTime=(new Date).getTime(),this.levels=new Array(this.immediates.length),this.longs=new Array(Ke),this.longSpeechActivityScore=ve,this.mediums=new Array(Ke*ze),this.mediumSpeechActivityScore=ve,this.minLevel=b$1,this.nextMinLevel=b$1,this.nextMinLevelWindowLength=void 0,this.lastActiveTime=this.lastLevelChangedTime-Mt-1}getStream(){return this.stream}getID(){return this.stream.getID()}computeImmediates(){let e=this.immediates,t=this.levels,r=Math.floor(this.minLevel+Lt),i=!1;for(let s=0;s<e.length;++s){let o=t[s];o<r&&(o=b$1);let n=Math.floor(o/Lt);e[s]!=n&&(e[s]=n,i=!0)}return i}computeLongs(){return wt(this.mediums,this.longs,Wr)}computeMediums(){return wt(this.immediates,this.mediums,Gr)}evaluateImmediateSpeechActivityScore(){this.immediateSpeechActivityScore=Qe(this.immediates[0],Ye,.5,.78)}evaluateLongSpeechActivityScore(){this.longSpeechActivityScore=Qe(this.longs[0],ze,.5,47)}evaluateMediumSpeechActivityScore(){this.mediumSpeechActivityScore=Qe(this.mediums[0],xt,.5,24)}evaluateSpeechActivityScores(){this.computeImmediates()&&(this.evaluateImmediateSpeechActivityScore(),this.computeMediums()&&(this.evaluateMediumSpeechActivityScore(),this.computeLongs()&&this.evaluateLongSpeechActivityScore()))}getLastLevelChangedTime(){return this.lastLevelChangedTime}getLevels(){let e=this.levels,t=new Array(e.length);for(let r=e.length-1,i=0;i<t.length;--r,++i)t[i]=e[r];return t}getSpeechActivityScore(e){switch(e){case 0:return this.immediateSpeechActivityScore;case 1:return this.mediumSpeechActivityScore;default:return this.longSpeechActivityScore}}levelChanged(e,t){if(this.lastLevelChangedTime<=t){let r;this.lastLevelChangedTime=t,r=e<b$1?b$1:e>Q$1?Q$1:e;for(let e=this.levels.length-1;e>0;--e)this.levels[e]=this.levels[e-1];this.levels[0]=r,this.updateMinLevel(r)}e>jr&&(this.lastActiveTime=(new Date).getTime())}levelTimeout(){this.levelChanged(b$1,this.lastLevelChangedTime)}updateMinLevel(e){if(e!=b$1){if(this.minLevel==b$1||this.minLevel>e)return this.minLevel=e,this.nextMinLevel=b$1,void(this.nextMinLevelWindowLength=0);if(this.nextMinLevel==b$1)return this.nextMinLevel=e,void(this.nextMinLevelWindowLength=1);if(this.nextMinLevel>e&&(this.nextMinLevel=e),this.nextMinLevelWindowLength++,this.nextMinLevelWindowLength>=Fr){let e=Math.sqrt(this.minLevel*this.nextMinLevel);e<b$1?e=b$1:e>Q$1&&(e=Q$1),this.minLevel=e,this.nextMinLevel=b$1,this.nextMinLevelWindowLength=0}}}getSilent(){return(new Date).getTime()-this.lastActiveTime>Mt}},Ze=class{constructor(e){this.algorithm=e}run(){let e=this.algorithm.runInDecisionMaker(this);e<0?this.algorithm.decisionMakerExited(this):setTimeout((()=>{this.run()}),e)}},et=class extends events.EventEmitter{constructor(){super(),this.decisionMaker=void 0,this.dominant=void 0,this.lastDecisionTime=0,this.lastLevelChangedTime=0,this.lastLevelIdleTime=0,this.relativeSpeechActivities=[0,0,0],this.speakers=new Map}addStream(e){e&&e.stream?e.stream.on("audio-level"+kt,this.levelChanged.bind(this,e)):console.warn("add stream error")}removeStream(e){e&&e.stream&&e.stream.off(kt),this.speakers.delete(e.getID())}maybeStartDecisionMaker(){!this.decisionMaker&&this.speakers.size>0&&(this.decisionMaker=new Ze(this),this.decisionMaker.run())}decisionMakerExited(e){e==this.decisionMaker&&(this.decisionMaker=void 0)}getDominantSpeaker(){let e=this.speakers.get(this.dominant);if(e)return e.getStream()}getOrCreateSpeaker(e){let t=e.getID(),r=this.speakers.get(t);return r||(r=new Xe(e),this.speakers.set(t,r),this.maybeStartDecisionMaker()),r}levelChanged(e,t){t=Math.min(t*Q$1*2,Q$1);let r=this.getOrCreateSpeaker(e),i=(new Date).getTime();this.lastLevelChangedTime<i&&(this.lastLevelChangedTime=i,this.maybeStartDecisionMaker()),r.levelChanged(t,i)}decisionChoice(){let e=this.speakers.get(this.dominant),t="";e||(e=this.speakers.entries().next().value[1],t=e.getID()),e.evaluateSpeechActivityScores();let r=this.relativeSpeechActivities,i=Ct;for(let[s,o]of this.speakers){if(o==e)continue;o.evaluateSpeechActivityScores();for(let t=0;t<r.length;++t)r[t]=Math.log(o.getSpeechActivityScore(t)/e.getSpeechActivityScore(t));let n=r[0],a=r[1],d=r[2];n>Pr&&a>Ct&&d>$r&&a>i&&(i=a,t=s)}return t}makeDecision(){let e;if(0!=this.speakers.size&&(e=this.decisionChoice()),e&&e!=this.dominant){this.dominant=e;let t=this.speakers.get(this.dominant);t&&!t.getSilent()?this.emit("speaker",t.getStream()):(this.emit("speaker"),this.dominant=void 0)}else if(this.dominant){let e=this.speakers.get(this.dominant);(e&&e.getSilent()||!e)&&(this.dominant=void 0,this.emit("speaker"))}}runInDecisionMaker(e){if(e&&e!=this.decisionMaker||0<this.lastDecisionTime&&this.lastDecisionTime-this.lastLevelChangedTime>=Br)return-1;let t=(new Date).getTime(),r=_t-(t-this.lastLevelIdleTime),i=0;r<=0?(0!=this.lastLevelIdleTime&&this.timeoutIdleLevels(t),this.lastLevelIdleTime=t):i=r;let s=Ot-(t-this.lastDecisionTime);return s<=0&&(this.lastDecisionTime=t,this.makeDecision(),s=Ot-((new Date).getTime()-t)),s>0&&i>s&&(i=s),i}timeoutIdleLevels(e){for(let[t,r]of this.speakers){let i=e-r.getLastLevelChangedTime();Jr<i&&(!this.dominant||r.getID()!=this.dominant)?this.speakers.delete(t):_t<i&&r.levelTimeout()}}},Nt=et,De=class extends events.EventEmitter{constructor(){super(),this._recording=!1}start(e,t){}stop(){}exportRecordedData(){}setMuted(e){}setMicDevice(e){}_getAudioStream(){return navigator.mediaDevices.getUserMedia({audio:!0,video:!1})}isRecording(){return this._recording}},zr=Ne.create(),ye=class extends De{constructor(){super(),this._trackSources=new Map,this._stream=null,this._recordedData=[]}start(e,t){return this._createDesktopStream(t.capture).then((r=>d(this,null,(function*(){try{return this._getMixedAudioTrack(e).then((e=>{e&&(r.addTrack(e),this._stream=r,this._mediaRecorder=this._newMediaRecorder(r,t.record),this._mediaRecorder.ondataavailable=e=>this._saveMediaData(e.data),this._mediaRecorder.start(1e3),this._recording=!0,this.emit("started"))}))}catch(e){throw m.Log().error(circularJson_node.stringify(e)),this._localAudioTrack&&this._localAudioTrack.stop(),r.getTracks().forEach((e=>e.stop())),e}}))))}stop(){return new Promise(((e,t)=>{this._mediaRecorder?(this._mediaRecorder.onstop=e,this._mediaRecorder.stop(),this._mediaRecorder=null,this._localAudioTrack&&(this._localAudioTrack.stop(),this._localAudioStream=null),this._stream&&this._stream.getTracks().forEach((e=>e.stop())),this._trackSources&&(this._trackSources.forEach((e=>e.disconnect(this._audioContextDest))),this._trackSources.clear()),this._recording=!1,this.emit("stopped")):t()}))}exportRecordedData(){return this._recordedData?Promise.resolve({data:this._recordedData,format:"mp4"}):Promise.reject("No video data recorded.")}setMuted(e){this._localAudioTrack&&(this._localAudioTrack.enabled=!e)}setMicDevice(e){return d(this,null,(function*(){if(this._localAudioTrack)try{return this.disconnectTrack(this._localAudioTrack),this._localAudioTrack.stop(),this._getLocalAudioTrack(e).then((e=>{this.connectTrack(e)}))}catch(e){return Promise.reject()}return Promise.reject()}))}_saveMediaData(e){console.log("save media data..., size:",e.size),this._recordedData.push(e)}_createDesktopStream(e){return zr.start(e).then((e=>{let t=e.getVideoTracks()[0];return t&&(t.onended=()=>{this.emit("track-ended")}),e}))}_newMediaRecorder(e,t){let r={bitsPerSecond:(t=t||{}).bitrate?t.bitrate:3e6};if(MediaRecorder.isTypeSupported(t.format))r.mimeType=t.format;else{let e=["video/mp4;codecs=h264","video/mp4;codecs=vp9","video/mp4;codecs=vp8"];for(let t of e)if(MediaRecorder.isTypeSupported(t)){r.mimeType=t;break}}return new MediaRecorder(e,r)}_getLocalAudioTrack(e){return this._getAudioStream().then((e=>{this._localAudioStream=e;let t=this._localAudioStream.getAudioTracks()[0];return this._localAudioTrack=t,t}))}_getMixedAudioTrack(e){return this._getLocalAudioTrack(e).then((()=>{if(this._localAudioStream){let e=new AudioContext,t=e.createMediaStreamSource(this._localAudioStream),r=e.createMediaStreamDestination();return t.connect(r),this._audioContext=e,this._audioContextDest=r,this._trackSources.set(this._localAudioTrack,t),r.stream.getAudioTracks()[0]}}))}connectTrack(e){let t=this._audioContext.createMediaStreamSource(new MediaStream([e]));null==t||t.connect(this._audioContextDest),this._trackSources.set(e,t)}disconnectTrack(e){let t=this._trackSources.get(e);t&&(t.disconnect(this._audioContextDest),this._trackSources.delete(e))}},tt=class extends events.EventEmitter{constructor(e){super(),this._opts=e,this._filename=e.filename,this._adapter=new ye,this._adapter.on("started",this.emit.bind(this,"started")),this._adapter.on("stopped",this.emit.bind(this,"stopped")),this._adapter.on("track-ended",this.emit.bind(this,"track-ended"))}downloadBlob(e,t="recording.webm"){let r=new Blob(e),i=window.URL.createObjectURL(r),s=document.createElement("a");s.style.display="none",s.href=i,s.download=t,document.body.appendChild(s),console.log("a tag to save recorded data..."),s.click(),setTimeout((function(){document.body.removeChild(s),window.URL.revokeObjectURL(i)}),1e3)}start(){return this._adapter.start("0",this._opts)}stop(){return this._adapter.stop().then((()=>(console.log("export recorded data..."),this._adapter.exportRecordedData()))).then((e=>{let{data:t,format:r}=e;console.log("download recorded data..."),this.downloadBlob(t,this._filename)}))}muteAudio(e){this._adapter.isRecording()&&this._adapter.setMuted(e)}addStream(e){let t=e&&e.getAudioTrack();t&&this._adapter.isRecording()&&this._adapter.connectTrack(t)}removeStream(e){let t=e.getAudioTrack();t&&this._adapter.isRecording()&&this._adapter.disconnectTrack(t)}addEventListener(e,t){this.addListener(e,t)}on(e,t){return this.addListener(e,t),this}},Dt=tt,ei={enableRace:!1},Ae=class extends q$1{constructor(e){var t;super(!0),this.switch=!1,this.audiooff=!1,this.selfopenaudio=!0,this.videooff=!1,this.msgoff=!1,this.creator="",this.master="",this.lock=!1,this.getUsersList=(e,t,r,i)=>this.client.getUsersList(e,t,r,i).then((e=>{let t=e.value;return{participants:this.parseGetUser(t),total:e.total,pageIndex:e.index}})),this.searchUsers=(e,t,r)=>this.client.searchUsers(e,t,r).then((e=>{let t=e.value;return{participants:this.parseGetUser(t)}})),this.queryUsers=e=>this.client.queryUsers(e).then((e=>{let t=e.value;return{participants:this.parseGetUser(t)}})),this.options=X$2.extend({},ei,e),this.joined=!1,this.logger=m.Log(),this.roomId=e.room,this.userId=e.user,this.hasSecret=!!this.options.secret,this.connectopts={nickname:this.options.nickname,custom_token:this.options.custom_token,userinfo:this.options.userinfo},this.create=null==(t=e.create)||t,this.nickname=e.nickname,this.localParticipant=new A$1(!0,this.userId,e)}connect(){return d(this,null,(function*(){this.client=new fe(this.options.proxies,{forceWS:this.options.forceWS,enableRace:this.options.enableRace,token:this.options.token},this.getRpc(),this.logger),this.handleEvents(),yield this.client.connect();try{let e=yield this.client.join({roomId:this.roomId,userId:this.userId,info:this.getJoinUserInfo(this.options.userinfo)});this.joined=!0,this.logger.info(`joined: sessionId: ${e.sessionId}, callId: ${e.raw.callId}`);let t=this.parseJoinResponse(e);this.fire(H$1.ROOM_CONNECTED,[t])}catch(e){throw this.logger.error(`join room failed: ${Vt(e)}, proxy: ${JSON.stringify(this.getActiveProxy())}`),this.client.close(),e}}))}leave(){return d(this,null,(function*(){var e;this.client&&(this.logger.info(`leaved: sessionId: ${(null==(e=this.client)?void 0:e.getSessionId())||""}`),yield this.client.leave({roomId:this.roomId,userId:this.userId,sessionId:this.client.getSessionId()||""}),this.client.close(),this.client=void 0,this.joined=!1)}))}request(e,t){return d(this,null,(function*(){var r;return null==(r=this.client)?void 0:r.request(e,t)}))}handleEvents(){this.client.on(_$1,(()=>{this.logger.error("client error"),this.fire(H$1.ERROR)})).on($,(()=>{this.logger.error("client close"),this.fire(H$1.ERROR)})).on(E$1,(()=>{this.logger.error("client timeout"),this.fire(H$1.TIMEOUT,[{msg:"timeout"}])})).on(O$1,(()=>{this.logger.info("client reconnected"),this.fire(H$1.RECONNECTED)})).on(B,(()=>{this.fire(H$1.RECONNECTING)})).on(xe$1.joinUser,(e=>{this.logger.debug("participant joined");let t=new A$1(!1,e.userId,e);this.fire(xe$1.joinUser,[{participant:t,mode:e.mode,data:e}])})).on(xe$1.leaveUser,(e=>{e.userId!==this.userId&&this.fire(xe$1.leaveUser,[{userId:e.userId,mode:e.mode,data:e}])})).on(xe$1.leaveUsers,(e=>{this.fire(xe$1.leaveUsers,[e])})).on(xe$1.roomClosed,(e=>{this.logger.error("room closed"),this.fire(xe$1.roomClosed,[e]),this.destroy()})).on(xe$1.roomError,(()=>{this.logger.error("room error"),this.fire(xe$1.roomError),this.destroy()})).on(xe$1.publishStream,(e=>{if(e.userId===this.userId)return;let t=e.userId,r=e.streamId,i=r.endsWith("_screen"),s=e.customInfo;this.fire(xe$1.publishStream,[{userId:t,streamId:r,video:e.params.video_enable,audio:e.params.audio_enable,isScreen:i,customInfo:s}])})).on(xe$1.updateStream,(e=>{this.fire(xe$1.updateStream,[e])})).on(xe$1.streamUpdate,(e=>{if(e.userId===this.userId)return;let t=e.userId,r=e.streamId,i=r.endsWith("_screen");this.fire(xe$1.streamUpdate,[{userId:t,streamId:r,video:e.params.video_enable,audio:e.params.audio_enable,isScreen:i}])})).on(xe$1.unpublishStream,(e=>{if(e.userId===this.userId)return;let t=e.userId,r=e.streams[0],i=r.endsWith("_screen");this.fire(xe$1.unpublishStream,[{userId:t,streamId:r,isScreen:i}])})).on(xe$1.sendMessage,(e=>{let t={room:e.roomId,user:e.userId,message:e.msg,to:e.to,seq:e.seq};this.fire(xe$1.sendMessage,[t])})).on(xe$1.customMessage,(e=>{let t={room:e.roomId,user:e.userId,message:e.msg,to:e.to};this.fire(xe$1.customMessage,[t])})).on(xe$1.moveUserRoom,(e=>{var t,r;null!=(t=e.info)&&t.master&&(this.master=e.info.master),null!=(r=e.info)&&r.customStats&&(this.customStats=e.info.customStats),this.fire(xe$1.moveUserRoom,[e])})).on(xe$1.evicted,(e=>{this.fire(xe$1.evicted,[{userId:e.userId}])})).on(xe$1.updateStats,(e=>{this.switch=e.stats.switch,this.hasSecret=e.stats.secret,this.audiooff=e.stats.audiooff,this.selfopenaudio=e.stats.selfopenaudio,this.videooff=e.stats.videooff,this.msgoff=e.stats.msgoff,this.lock=e.stats.lock,this.creator=e.stats.creator,this.master=e.stats.master;let t=e.stats.updates,r=Object.keys(t);this.fire(xe$1.updateStats,[{room:this,options:r,stats:e.stats}])})).on(xe$1.updateCustomStats,(e=>{this.customStats=e.customStats||{},this.fire(xe$1.updateCustomStats,[{room:this,customStats:this.customStats,updateKeys:e.updateKeys}])})).on(xe$1.changeMaster,(e=>{this.master=e.master,this.fire(xe$1.changeMaster,[{master:this.master,oldMaster:e.oldmaster,isKeep:e.isKeep,type:e.type,data:e}])})).on(xe$1.updateUser,(e=>{if(e.user===this.getLocalParticipant().getID())this.getLocalParticipant().update(e.info),this.fire(xe$1.updateUser,[{participant:this.getLocalParticipant()}]);else{let t=new A$1(!1,e.user,e.info);this.fire(xe$1.updateUser,[{participant:t}])}})).on(xe$1.userRejoined,(e=>{this.fire(xe$1.userRejoined,[{userId:e.userId,info:e.info}])}))}getRpc(){return{}}getActiveProxy(){return this.client.getProxy()}destroy(){this.client&&(this.client.close(),this.client=void 0),this.joined=!1,this.off()}getJoinUserInfo(e,t=!1){let r={};return r.ua=e.ua?e.ua:Te(),r.device=e.device?e.device:We(),r.platform=e.platform?e.platform:"Web",r.network=e.network?e.network:"unknown",r.role=e.role?e.role:"anchor",r.create=this.options.create,r.secret=this.options.secret?At(`${this.roomId}.${this.options.secret}`):void 0,r.nickname=this.options.nickname,r.userinfo=this.options.userinfo,r.hasWaitRoom=!0,r.permission=t?this.permission:this.options.permission,r.custom_token=this.options.custom_token,r.prefer=this.options.prefer,r.name=this.options.name,r.userinfo.jointime||(r.userinfo.jointime=Math.floor(Date.now()/1e3)),r}getLocalParticipant(){return this.localParticipant}getID(){return this.roomId}getAudioOff(){return this.audiooff}getSelfOpenAudio(){return this.selfopenaudio}getVideoOff(){return this.videooff}getMsgOff(){return this.msgoff}getLock(){return this.lock}setAudioOff(e,t){return this.update({audiooff:e,selfopenaudio:t})}setVideoOff(e){return this.update({videooff:e})}setMsgOff(e){return this.update({msgoff:e})}setSwitch(e){return this.update({switch:e})}setLock(e){return this.update({lock:e})}getSwitch(){return this.switch}setSecret(e){return this.update({secret:e})}getLimits(){return this.limit}getMaster(){return this.master}getCreator(){return this.creator}getName(){return this.name}getMsgSeq(){return this.msgSeq}changeMaster(e,t){if(e!=this.getMaster())return this.client.changeMaster(this.roomId,this.userId,e,t).then((()=>{this.master=e})).catch((e=>{m.Log().error(circularJson_node.stringify(e))}))}syncUser(e){return this.client.syncUser(e).then((e=>(m.Log().info("syncUser success"),e))).catch((e=>{m.Log().error("syncUser error",e)}))}evictUser(e){return this.client.evictUser(this.roomId,this.userId,e)}evictUser2(e,t,r){return e!=this.getMaster()?Promise.reject("not master."):this.client.evictUser(this.roomId,this.userId,t,r)}updateUser(e,t){return this.localParticipant.getID()==this.getMaster()||this.localParticipant.getPermission().getManage()||!t.permission&&e==this.localParticipant.getID()?this.client.updateUser(this.roomId,this.localParticipant.getID(),{info:t,target:e}).then((()=>{e==this.localParticipant.getID()&&this.localParticipant.update(t)})).catch((e=>{m.Log().error(e)})):Promise.reject({code:we.ERR_PERMISSION,error:"permission denied."})}parseStreams(e,t){let r=[];if(t.streams)for(let i=0;i<t.streams.length;i++){let s=t.streams[i].params,o=t.streams[i].streamId,n={id:o,audio:s.audio,video:s.video,audio_enable:s.audio_enable,video_enable:s.video_enable,screen:o.endsWith("_screen"),customInfo:s.customInfo},a=new U(this.client,this,e,!1,n);r.push(a)}return r}parseJoinResponse(e){return this.logger.log(`room-connect耗时: ${e.duration}`),this.total=e.total,this.pagesize=e.pagesize,this.index=e.index,this.startup=e.startup,this.duration=e.duration,this.limit=e.limit,this.switch=e.switch,this.audiooff=e.audiooff,this.selfopenaudio=e.selfopenaudio,this.videooff=e.videooff,this.msgoff=e.msgoff,this.lock=e.lock,this.master=e.master,this.creator=e.creator,this.name=e.name,this.limit=e.limit,this.msgSeq=e.msgSeq,this.sessionId=e.sessionId,this.permission=e.permission,this.customStats=e.customStats,this.getLocalParticipant().getPermission().set(this.permission),{total:this.total,sessionId:this.sessionId,customStats:this.customStats,joinwait:e.joinwait,waitroom:e.waitroom,permission:e.permission,audiooff:e.audiooff}}syncRoom(){let e=this.getJoinUserInfo(this.options.userinfo,!0);return this.client.syncRoom(this.options.room,this.options.user,e).then((e=>{m.Log().log("bloud syncRoom response : "+circularJson_node.stringify(e));let t=this.parseJoinResponse(e);this.fire(H$1.ROOM_SYNCED,[t])})).catch((e=>{throw m.Log().error(e),this.fire(H$1.SYNC_FAILED,[{error:e}]),e}))}update(e={}){return"string"==typeof e.secret&&(e.secret=At(`${this.roomId}.${e.secret}`)),this.client.updateRoom(this.roomId,this.userId,e).then((()=>{"boolean"==typeof e.audiooff&&(this.audiooff=e.audiooff),"boolean"==typeof e.videooff&&(this.videooff=e.videooff),"boolean"==typeof e.msgoff&&(this.msgoff=e.msgoff),"boolean"==typeof e.switch&&(this.switch=e.switch),"string"==typeof e.secret&&(this.secret=e.secret),"boolean"==typeof e.lock&&(this.lock=e.lock),"boolean"==typeof e.selfopenaudio&&(this.selfopenaudio=e.selfopenaudio),m.Log().info(e)})).catch((e=>{throw m.Log().error(e),e}))}updateCustomStats(e,t){return e=e||{},this.client.updateCustomStats(this.roomId,this.userId,e,t).then((()=>{m.Log().info("updateCustomStats:"+circularJson_node.stringify(e))})).catch((e=>{throw m.Log().error(e),e}))}updateStream(e,t,r){return this.client.updateStream(e,t,{customInfo:r})}getMessages(e,t){return this.client.getMessages(this.roomId,this.userId,{startSeq:e,endSeq:t})}parseGetUser(e){let t=[];for(let r=0;r<e.length;r++){if(e[r].userId===this.getLocalParticipant().getID()){t.push(this.getLocalParticipant());continue}let i=new A$1(!1,e[r].userId,e[r]);this.parseStreams(i,e[r]).forEach((e=>i.addStream(e))),t.push(i)}return t}getUsers(e,t,r,i=!1){return this.index=e,this.pagesize=r||this.pagesize,this.client.getUsers(this.roomId,this.userId,this.pagesize,this.index+1,t,i).then((e=>{let t=e.value;this.total=e.total,this.pagesize=e.pagesize,this.index=e.index;let r=this.parseGetUser(t);return this.fire("users-list",[{usersEvent:{participants:r}}]),{participants:r,total:this.total}}))}getTotalUsers(){return this.total}getInfo(e){return e.ua=e.ua?e.ua:Te(),e.device=e.device?e.device:We(),e.platform=e.platform?e.platform:"Web",e.network=e.network?e.network:"unknown",e.role=e.role?e.role:"anchor",e.create=this.create,e.secret=this.secret,e.nickname=this.nickname,e.userinfo=this.userinfo,e.permission=this.permission,e.custom_token=this.custom_token,e.name=this.name,this.create&&(e.limit=this.limit,e.limittime=this.limittime,e.stoptime=this.stoptime),e.pagesize=this.pagesize,e}getCustomStats(){return this.customStats}sendMessage(e,t){return this.client.sendMessage(this.roomId,this.userId,t,e).then((e=>(m.Log().log(circularJson_node.stringify(e)),e))).catch((e=>{throw m.Log().error(e),e}))}customMessage(e,t){return this.client.customMessage(this.roomId,this.userId,t,e).then((e=>(m.Log().log(circularJson_node.stringify(e)),e))).catch((e=>{throw m.Log().error(e),e}))}moveUserRoom(e,t,r){return this.client.moveUserRoom(e,t,r)}release(){return this.client.releaseRoom(this.roomId,this.userId).then((e=>(m.Log().log(circularJson_node.stringify(e)),e))).catch((e=>{throw m.Log().error(e),e}))}close(){this.client&&(this.client.close(),this.client=void 0)}SpeakerDetector(){return new Nt}Recorder(e){var t;let r=new Dt(e);return m.Log().info("create local recorder"),r.addEventListener("started",(()=>{m.Log().info("local recorder started.")})),r.addEventListener("stopped",(()=>{var e,t;m.Log().info("local recorder stopped");let i=null==(e=this.recorders)?void 0:e.indexOf(r);i&&i>=0&&(this.recorders=null==(t=this.recorders)?void 0:t.splice(i,1))})),r.addEventListener("track-ended",(()=>{m.Log().info("local recorder track ended")})),null==(t=this.recorders)||t.push(r),r}removeAllListeners(){this.off()}Stream(e){if(this.client)return new U(this.client,this,this.getLocalParticipant(),!0,e)}},q=Object.defineProperty,N=Object.getOwnPropertySymbols,X=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable,D=(e,t,r)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))X.call(t,r)&&D(e,r,t[r]);if(N)for(var r of N(t))z.call(t,r)&&D(e,r,t[r]);return e},n=(e,t,r)=>new Promise(((i,s)=>{var o=e=>{try{a(r.next(e))}catch(e){s(e)}},n=e=>{try{a(r.throw(e))}catch(e){s(e)}},a=e=>e.done?i(e.value):Promise.resolve(e.value).then(o,n);a((r=r.apply(e,t)).next())})),K={token:""},I=K;function k({url:e,method:t="get",data:r={},contentType:i="application/json",_header:s={},succCB:o,errCB:n,dataType:a,responseType:d}){let u=I.token;t=t.toUpperCase(),s.Authorization="Bearer "+u,-1==e.indexOf("/proxies")&&(s.checkdelay="570ed35e48494f1d6aa7d1bd20d0a2be",s.ch="web",s.os="web",s.p="3",s.delay=(new Date).getTime(),s.version="2.2.7",s.ver="2.2.7",s.lan="zh",s.osv="",s.wh="",s.apn="");let l={headers:s,method:t};if(d&&(l.responseType=d),"GET"===t){if(r){e+="?";for(let t in r)e+=`${t}=${r[t]}&`;e=e.substring(0,e.length-1)}l.cache="no-store"}else if("RESTFUL"===t){e+="/";for(let t of r)e+=t+"/";e=e.substring(0,e.length-1),t="GET",l.method=t,l.cache="no-store"}else l.body="multipart/form-data"===i?r:JSON.stringify(r);return console.log("\n############# getData host==\n"+e+"\n Header=",s,"\n optins=",l),fetch(e,l).then((t=>"blob"===a?t:Q(t,e,r,d))).then((t=>(console.log(`此接口【${e}】返回的data:`,t),"blob"!==a?(t.msg=t.message||t.msg,t):"200"===t.code||200===t.status?("function"==typeof o&&o(t),t):("function"==typeof n&&n(t),void Promise.reject(t))))).catch((t=>(console.log("\n############## err"+t.message,e),t.msg=t.message||t.msg,Promise.reject(t))))}function Q(e,t,r,i){return e.ok?"blob"===i?e.blob():e.json():500===e.status?Promise.reject({code:500,message:"连接服务器失败, 请检查网络重试!",url:t,param:r}):404===e.status?Promise.reject({code:404,message:"404",url:t,param:r}):502===e.status?Promise.reject({code:502,message:"连接服务器失败, 请检查网络重试!",url:t,param:r}):Promise.reject({code:e.status,message:e.status+"",url:t,param:r})}var p=class e{constructor(e){this.userinfo=e.userinfo,this.permission=e.permission,this.stream=e.stream,this.userId=e.userId,this.customInfo=e.customInfo,this.nickname=e.nickname}static toUser(t,r){var i,s;return new e({userinfo:P({},t.getUserInfo()),userId:t.getID(),stream:t.getStreams(),permission:t.getPermission(),customInfo:P({},null==(s=null==(i=t.params)?void 0:i.info)?void 0:s.customInfo),nickname:t.getNickName()})}},Z=e=>e;function ee(e){return e.participant&&(e.user=p.toUser(e.participant,this.type)),e}var te=[H$1.PARTICIPANT_JOINED,H$1.UPDATE_USER],C={};function j(){Object.values(H$1).forEach((e=>{C[e]||(te.includes(e)?C[e]=ee:C[e]=Z)}))}var re=function(){},y=void 0!==typeof console?console:null;function O(e,t,r,i){let s=[];return r&&s.push(r),i&&s.push(i),`[${(new Date).toLocaleTimeString("chinese",{hour12:!1})}] <${e}> [${s.join("|")}] ${t}`}function v(e,t,r,i=[]){i.unshift(O("DEBUG",e,t,r)),y.log.apply(y.log,i)}function h(e,t,r,i=[]){i.unshift(O("INFO",e,t,r)),y.log.apply(y.log,i)}function G(e,t,r,i=[]){i.unshift(O("WARN",e,t,r)),y.warn.apply(y.warn,i)}function l(e,t,r,i=[]){i.unshift(O("ERROR",e,t,r)),y.error.apply(y.error,i)}/BRTC/.test(re.toString());var b=class{static singleModeJoin(e,t){return n(this,null,(function*(){try{let r,i;try{r=yield e._getBloudProxiesUrl(e.token)}catch(e){return l("_getBloudProxiesUrl error","","",[JSON.stringify(e)]),Promise.reject(e)}switch(e.identity){case"5":i="RWPSAVM";break;case"3":case"4":i="RWPS";break;case"6":i="RWPAV"}let s={room:e.roomId,user:e.userId.toString(),enableCollection:!1,enableRace:!0,proxies:r.proxies,nickname:e.userinfo.nickname,custom_token:e.customToken,userinfo:e.userinfo,token:e.token,secret:e.secret,forceWS:!0,name:e.name,create:e.tarCreate,disableMediaEngine:e.disableMediaEngine,permission:i};try{e.client&&e.client.destroy()}catch(e){}e.client=new Ae(s),t(),yield e.client.connect(),h("singleModeJoin==>单一模式加入会议成功",e.userId,1)}catch(t){return l("singleModeJoin==>单一模式加入会议失败",e.userId,1,[JSON.stringify(t)]),e.client=null,Promise.reject(t)}}))}static singleModeLeave(e){return n(this,null,(function*(){if(!e.client)throw new Error("没有 joined");try{yield e.client.leave(),console.log("client leave success",e.userId),e.clearObject()}catch(t){throw console.log("client leave fail",e.userId,[t]),e.clearObject(),new Error(t)}}))}};Object.freeze({}),Object.freeze([]);var Y="c",w=1,V=2,f=window.BRTC,T=class{constructor(e){this.emitters=[],this.name="",this.type=w,this.appId="",this.brtcAppId="",this.roomId="",this.tarCreate=!1,this.userinfo={},this.userId="",this.isJoining=!1,this.collection="",this.limit=0,this.token="",this.customToken="",this.create=!1,this.host="",this.getProxiesUrl="",this.secret="",this.enableRace=!1,this.disableMediaEngine=!1,this.roomType=1,this.brtcClient=null,this.shareBrtcClient=null,this.hasBloudJoined=!1,this.brtcSig="",this.brtcShareSig="",this.shareContentHint="detail",this.identity="",this.isBig="0",this.joinBrtc=()=>new Promise(((e,t)=>{this.brtcClient.join(this.roomId,this.userId,this.sig).then((()=>(h("join brtc succeed"),e(!0)))).catch((e=>(console.log("brtc入会失败01",e),this.isJoining=!1,t(Pn(e.message)))))})),this.joinBloud=()=>new Promise(((e,t)=>{b.singleModeJoin(this,(()=>this.addBloudEvent())).then((()=>(h("join bloud succeed"),this.hasBloudJoined=!0,e(!0)))).catch((e=>(l("bloud入会失败02","",[e]),this.isJoining=!1,t(e))))})),this.handleForceUnpublishBloudStream=()=>{l("bloud share stream unpublish failed, create bloud stream and unpub again"),this.client.client.unpublishStream(this.roomId,this.userId,`${this.userId}_screen`)},this.emitter=new q$1(!0),j()}setShareSig(e){this.brtcShareSig=e}clearObject(){this.client&&(this.client.close(),this.client.removeAllListeners()),this.client=null,this.collection&&(this.collection.close(),this.collection=null)}join(e){return n(this,null,(function*(){return new Promise(((t,r)=>n(this,null,(function*(){if(this.isJoining)return Promise.reject(vn);if(this.client)return Promise.reject(vn);if("string"!=typeof e.getProxiesUrl)return Promise.reject(_n);if(!e.userinfo||e.userinfo&&"object"!=typeof e.userinfo)return Promise.reject(In);if("number"!=typeof e.type||1!==e.type&&2!==e.type)return Promise.reject(wn);if(this.userId=e.userId,this.roomId=e.room,this.roomType=e.roomType,this.collection=e.collection,this.userinfo=e.userinfo,this.getProxiesUrl=e.getProxiesUrl,this.appId=e.appId,this.brtcAppId=e.brtcAppId,this.type=e.type,this.tarCreate=e.create,this.limit=e.limit,this.secret=e.secret,this.enableRace=e.enableRace,this.token=e.token,this.customToken=e.customToken,this.name=e.name,this.brtcSig=e.sig,this.identity=e.identity,this.isBig=e.is_big,this.sig=e.sig,I.token=e.token,this.isJoining=!0,this.type===w&&(yield b.singleModeJoin(this,(()=>this.addBloudEvent()))),this.type===V){this.disableMediaEngine=!0;try{this.brtcClient=f.createClient({codec:"h264",appId:this.brtcAppId,useStringUserId:!0,audioLevelInterval:200,roomType:"big",silence:!0}),this.createShareBrtcClient(),this.addBrtcEvent(),this.fire("brtc-bound",!0),f.setVTRequestTimeout(5),yield this.joinRoom().then((()=>(this.isJoining=!1,this.fire(Nt$1.JOIN_READY),t(!0)))).catch((e=>(l("join room error","",this.userId,[JSON.stringify(e)]),r(e))))}catch(e){return this.isJoining=!1,l("join room error",Y,this.userId,[e]),r(e)}}}))))}))}joinRoom(){return new Promise(((e,t)=>{let r=!1,i=!1;this.joinBloud().then((()=>{if(r=!0,i)return e(!0)})).catch((e=>t(e))),this.joinBrtc().then((()=>{if(i=!0,r)return e(!0)})).catch((e=>t(e)))}))}createShareBrtcClient(){return this.shareBrtcClient||(this.shareBrtcClient=f.createClient({codec:"h264",appId:this.brtcAppId,useStringUserId:!0,roomType:"big",silence:!0}),this.shareBrtcClient.on("error",(e=>{this.fire("share-brtc-error",e)}))),this.shareBrtcClient}_getBloudProxiesUrl(e){return new Promise(((t,r)=>{k({url:`${this.getProxiesUrl}/proxies?token=${e}`}).then((r=>{t({proxies:r.proxies,token:e})})).catch((e=>{r(Ln(e))}))}))}on(e,t){return this.emitter.on(e,{fn:t,ctx:this}),this}fire(e,t){this.emitter&&this.emitter.fire(e,t?[t]:void 0)}changeMaster(e,t=!1){return this.client.changeMaster(e,t)}getMaster(){return this.client.getMaster()}syncUser(e){return this.client.syncUser(e)}getCreator(){return this.client.getCreator()}getName(){return this.client.getName()}close(){return n(this,null,(function*(){var e;this.leaveBrtcRoom(),null==(e=this.client)||e.close(),this.leaveShare()}))}getMsgSeq(){return this.client.getMsgSeq()}evictUser(e,t){return this.client.evictUser2(this.getMaster(),e,t)}updateUser(e,t){return n(this,null,(function*(){yield this.client.updateUser(e,t)}))}getLimits(){return this.client.getLimits()}getSwitch(){return this.client.getSwitch()}syncRoom(){return this.client.syncRoom()}update(e){return this.client.update(e)}getUsers(e,t,r){return n(this,null,(function*(){let{participants:i,total:s}=yield this.client.getUsers(e,t,r),o=new Map;return i.forEach((e=>{let t=p.toUser(e,this.type);o.set(t.userId,t)})),{users:o,total:s}}))}updateStream(e,t,r){return this.client.updateStream(e,t,r)}getUsersList(e,t,r,i){return n(this,null,(function*(){let{participants:s,total:o,pageIndex:n}=yield this.client.getUsersList(e,r,t,i),a=new Map;return s.forEach((e=>{let t=p.toUser(e,this.type);a.set(t.userId,t)})),{users:a,total:o,pageIndex:n}}))}getTotalUsers(){return this.client.getTotalUsers()}sendMessage(e,t){return this.client.sendMessage(e,t)}customMessage(e,t){return this.client.customMessage(e,t)}getMessages(e,t){return this.client.getMessages(e,t)}getLocalParticipant(){var e;return null==(e=this.client)?void 0:e.getLocalParticipant()}getAudioOff(){return this.client.getAudioOff()}getSelfOpenAudio(){return this.client.getSelfOpenAudio()}getVideoOff(){return this.client.getVideoOff()}getMsgOff(){return this.client.getMsgOff()}getLock(){return this.client.getLock()}getRoomInfo(){let e=P({},this.client.options);return delete e.token,e}setAudioOff(e,t){return this.client.setAudioOff(e,t)}setVideoOff(e){return this.client.setVideoOff(e)}setMsgOff(e){return this.client.setMsgOff(e)}setSwitch(e){return this.client.setSwitch(e)}setLock(e){return this.client.setLock(e)}publish(e){return n(this,null,(function*(){return this.brtcClient.publish(e).catch((e=>Promise.reject(kn(JSON.stringify(e)))))}))}unpublish(e){return n(this,null,(function*(){return this.brtcClient.unpublish(e).catch((e=>Promise.reject(jn(JSON.stringify(e)))))}))}subscribe(e){return n(this,arguments,(function*(e,t={audio:!0,video:!0}){return this.brtcClient.subscribe(e,t).catch((e=>Promise.reject(e)))}))}unsubscribe(e){return n(this,null,(function*(){return this.brtcClient.unsubscribe(e).catch((e=>Promise.reject(Jn(JSON.stringify(e)))))}))}addBloudEvent(){let e=this,t=C;let r=Object.values(H$1);J$1.each(r,(r=>{!function(r,i){e.client.on(r,(function(){let r=k$2(t[i],e,J$1.toArray(arguments));e.fire(i,r)}))}(r,r)}))}addBrtcEvent(){let e=this;let t=Object.values(dt$1);J$1.each(t,(t=>{var r;r=t,e.brtcClient.on(r,(t=>{e.fire(r,t)}))}))}clearBrtcEvent(){var e;null==(e=this.brtcClient)||e.off()}leave(){return n(this,null,(function*(){return console.log("离开会议","userId =>",this.userId,"roomId =>",this.roomId,"userInfo =>",this.userinfo),yield b.singleModeLeave(this),this.leaveBrtcRoom()}))}leaveBrtcRoom(){return n(this,null,(function*(){if(console.log("离开brtc调用堆栈!!!!!"),this.brtcClient&&(this.brtcClient.off(),yield this.brtcClient.leave(),yield this.brtcClient.destroy(!0),this.brtcClient=null),this.shareBrtcClient){try{this.shareBrtcClient.off(),yield this.shareBrtcClient.leave()}catch(e){}this.shareBrtcClient.destroy(!0),this.shareBrtcClient=null}}))}leaveShare(){return n(this,null,(function*(){if(this.shareBrtcClient){try{yield this.shareBrtcClient.leave()}catch(e){}this.shareBrtcClient.destroy(!0),this.shareBrtcClient=null}}))}createRecorder(e){return this.client.Recorder(e)}createSpeakerDetector(){return this.client.SpeakerDetector()}createLocalStream(e,t){return n(this,null,(function*(){f.isSmallStreamSupported()?yield this.brtcClient.enableSmallStream():l("simulcast is not supported"),this.brtcClient.setSmallStreamProfile({width:320,height:180,bitrate:100});try{return f.createStream(e)}catch(e){return Promise.reject(e)}}))}createPBLocalStream(e,t){return n(this,null,(function*(){this.brtcClient.setSmallStreamProfile({width:320,height:180,bitrate:100});try{return f.createStream(e)}catch(e){return Promise.reject(Mn(JSON.stringify(e)))}}))}creteBloudLocalStream(e,t){return this.client.Stream({audio:!0,video:!0,audio_enable:e.audio_enable,video_enable:e.video_enable,id:t,screen:!1})}createBloudScreenStream(e,t){return this.client.Stream({screen:!0,audio:!0,video:!0,audio_enable:e.audio_enable,video_enable:e.video_enable,id:t})}updateCustomStats(e,t=!1){return h("updateCustomStats","updateCustomStats","",[" customstats => ",JSON.stringify(e),"replace => ",t]),this.client.updateCustomStats({customStats:e},t)}getCustomStats(){var e;return null==(e=this.client)?void 0:e.getCustomStats()}getDuration(){var e;return null==(e=this.client)?void 0:e.duration}toggleShareScreen(e,t,r){return n(this,null,(function*(){return new Promise(((i,s)=>n(this,null,(function*(){if(e){let e=t.audioHint;try{let t={screen:!0,videoHint:"motion"===this.shareContentHint?"motion":"detail",sourceType:"screen"};e&&(t.audioHint=e),r&&(void 0!==r.video&&(t.video=r.video),void 0!==r.audio&&(t.audio=r.audio),t.videoSource=r.videoSource,t.audioSource=r.audioSource);let s=yield f.createStream(t),o="motion"===this.shareContentHint?{frameRate:15,bitrate:4e3}:{frameRate:5,bitrate:4e3};s.setVideoEncoderConfiguration({width:1920,height:1080,frameRate:o.frameRate,bitrate:o.bitrate});try{yield s.init()}catch(e){throw l("brtc share stream init failed","","",[String(e)]),new Error(e)}yield this.publishShareStream(s),i(!0)}catch(e){String(e).includes("Permission denied by system")?(l("没有打开共享屏幕录制权限","","this.userId"),s(Rn)):String(e).includes("Permission denied")?(h("点击了取消共享屏幕","",this.userId,["nickname =>",this.name]),s(On)):(l("开启共享屏幕失败","","",[String(e)]),s(yn("开启共享屏幕失败,请重试")))}}else yield this.unpublishShareStream(),i(!0)}))))}))}shareHTMLMedia(e,t){return n(this,null,(function*(){if(e&&t)try{let e=f.createStream({screen:!0,audio:t.audio,video:t.video,videoSource:t.videoSource,audioSource:t.audioSource,videoHint:"motion",sourceType:"screen"}),r="motion"===this.shareContentHint?{frameRate:15,bitrate:4e3}:{frameRate:5,bitrate:4e3};e.setVideoEncoderConfiguration({width:1920,height:1080,frameRate:r.frameRate,bitrate:r.bitrate}),yield e.init(),yield this.publishShareStream(e)}catch(e){return Promise.reject(Dn(JSON.stringify(e)))}e||(yield this.unpublishShareStream())}))}publishShareStream(e){return n(this,null,(function*(){if(this.shareBrtcClient||this.createShareBrtcClient(),!this.brtcShareSig)return console.error("brtcShareSig为空"),Promise.reject(Bn);{yield this.shareBrtcClient.join(this.roomId,`${this.userId}_screen`,this.brtcShareSig).catch((e=>(l("共享屏幕入会失败","","",[JSON.stringify(e),this.brtcShareSig]),Promise.reject(Un)))),e.on("video-track-ended",(()=>{this.handleShareStreamEnded()})),yield this.shareBrtcClient.publish(e).catch((t=>(l("共享屏幕流推流失败","","",["err =>",JSON.stringify(t)]),e.destroy(),Promise.reject(yn("共享屏幕流推流失败,请重试"))))),this.shareBrtcClient.on("sync-room-completed",(()=>{this.fire(Nt$1.BRTC_SHARE_SYNC_ROOM_COMPLETED)}));let t=e.getAudioOn(),r=e.getVideoOn();this.shareScreenStream=e,this.createAndPubBloudShareStream(t,r),setTimeout((()=>{Promise.resolve(!0)}),200)}}))}createAndPubBloudShareStream(e,t,r=!0){this.bloudShareScreenStream=this.createBloudScreenStream({audio_enable:e,video_enable:t},`${this.userId}_screen`),r&&this.bloudShareScreenStream.publish({video_enable:t,audio_enable:e})}replaceShareStreamVideoTrack(e){this.shareScreenStream?this.shareScreenStream.replaceTrack(e):l("当前没有开启共享屏幕,无法替换track")}unpublishShareStream(){return n(this,null,(function*(){return new Promise((e=>n(this,null,(function*(){var t,r,i;try{G("unpublish share stream"),this.shareScreenStream&&(yield null==(t=this.shareBrtcClient)?void 0:t.unpublish(this.shareScreenStream).catch((e=>{l("取消共享屏幕出错","","",[JSON.stringify(e)])}))),yield null==(r=this.shareBrtcClient)?void 0:r.leave().catch((e=>{l("shareBrtcClient leave error","","",[JSON.stringify(e)])})),null==(i=this.shareScreenStream)||i.destroy(),this.shareScreenStream=void 0,this.bloudShareScreenStream?yield this.bloudShareScreenStream.unpublish().then((()=>{this.bloudShareScreenStream=void 0})).catch((e=>{l("bloud share stream unpublish failed"),this.handleForceUnpublishBloudStream()})):this.handleForceUnpublishBloudStream()}catch(e){console.log("取消共享兼容处理",e)}e(!0)}))))}))}setShareScreenContentHint(e){this.shareContentHint=e}releaseRoom(){return n(this,null,(function*(){yield this.client.release()}))}handleShareStreamEnded(){setTimeout((()=>{var e;(!this.shareScreenStream||"live"!==(null==(e=this.shareScreenStream.getVideoTrack())?void 0:e.readyState))&&(l("share stream video track ended"),this.fire("toggle-screen-share",!1))}),2e3)}setCustomUrl(e){f.setCustomUrl(e)}bloudReconnect(){return n(this,null,(function*(){yield this.client.leave(),yield b.singleModeJoin(this,(()=>this.addBloudEvent()))}))}searchUsers(e,t,r){return n(this,null,(function*(){let{participants:i}=yield this.client.searchUsers(e,t,r),s=new Map;return i.forEach((e=>{let t=p.toUser(e,this.type);s.set(t.userId,t)})),{users:s}}))}queryUsers(e){return n(this,null,(function*(){let{participants:t}=yield this.client.queryUsers(e),r=new Map;return t.forEach((e=>{let t=p.toUser(e,this.type);r.set(t.userId,t)})),{users:r}}))}handleBloudRejoin(){return n(this,null,(function*(){return b.singleModeJoin(this,(()=>this.addBloudEvent()))}))}},A="bp",x=class extends q$1{constructor(e,t){super(),this.playEvent=()=>{this.videoStatus="PLAYING",h("stream big video playing",A,this.stream.getUserId())},this.pauseEvent=()=>{this.videoStatus="PAUSED",this.fire(ht$1.PLAYER_STATE_CHANGED,[{type:"video",state:this.videoStatus,reason:"pause"}]),h("stream big video pause",A,this.stream.getUserId())},this.stalledEvent=()=>{this.videoStatus="PAUSED",this.fire(ht$1.PLAYER_STATE_CHANGED,[{type:"video",state:this.videoStatus,reason:"stalled"}]),h("stream big video stalled",A,this.stream.getUserId())},this.element=e,this.options=t,this.container=document.createElement("div"),this.container.style.width="100%",this.container.style.height="100%",this.container.style.position="relative",this.container.style.backgroundColor="#202020",this.container.style.overflow="hidden",e.appendChild(this.container)}playVideo(){if(!this.video){if(!this.stream.getVideoTrack())return;this.video=document.createElement("video"),this.video.autoplay=!0,this.video.playsInline=!0,this.video.muted=!!this.options.muted,this.video.style.width="100%",this.video.style.height="100%",this.video.style.position="absolute";let e="";this.options.rotateX&&(e=`rotateX(${this.options.rotateX}deg)`),this.options.rotateY&&(e=`${e} rotateY(${this.options.rotateY}deg)`),e&&(this.video.style.transform=e),this.options.fit&&(this.video.style.objectFit=this.options.fit),this.video.id=`video_${this.stream.getStreamId()}_big`,this.container.appendChild(this.video),this.video.addEventListener("playing",this.playEvent),this.video.addEventListener("pause",this.pauseEvent),this.video.addEventListener("stalled",this.stalledEvent)}let e=new MediaStream;e.addTrack(this.stream.getVideoTrack()),this.video.srcObject=e,this.videoStatus="STOPPED"}play(e){return n(this,null,(function*(){this.stream=e,this.container.id=`player_${e.getStreamId()}_big_container`,this.stream.hasVideo()&&this.playVideo();try{this.video&&(yield this.video.play())}catch(e){l("big player play video failed","","",[JSON.stringify(e)]),this.fire(ht$1.PLAYER_STATE_CHANGED,[{type:"error",reason:e}])}}))}replay(e,t=!0,r=!0){return n(this,null,(function*(){this.stream=e;try{this.stream.hasVideo()&&t&&this.playVideo(),this.stream.hasVideo()&&t&&(yield this.video.play())}catch(e){l("big player replay video failed","","",[JSON.stringify(e)]),this.fire(ht$1.PLAYER_STATE_CHANGED,[{type:"error",reason:e}])}}))}muteVideo(){this.video&&(this.video.srcObject=void 0,this.videoStatus="STOPPED")}unmuteVideo(){if(this.video&&this.stream&&"STOPPED"===this.videoStatus){let e=new MediaStream;e.addTrack(this.stream.getVideoTrack()),this.video.srcObject=e}}destroy(){this.video&&(this.video.removeEventListener("playing",this.playEvent),this.video.removeEventListener("pause",this.pauseEvent),this.video.removeEventListener("stalled",this.stalledEvent),this.video.style.display="none",this.video=null);try{this.container.style.display="none",this.element.removeChild(this.container)}catch(e){}this.container=null,v("stream player destroy",A,this.stream.getUserId())}resume(){return n(this,null,(function*(){this.video&&(yield this.video.play()),v("stream player resume",A,this.stream.getUserId())}))}getVideoFrame(){if(this.video&&"STOPPED"!==this.videoStatus){let e=document.createElement("canvas");return e.width=this.video.videoWidth,e.height=this.video.videoHeight,e.getContext("2d").drawImage(this.video,0,0),e.toDataURL("image/png")}}},S="ap",_=class extends q$1{constructor(e,t){super(),this.sinkId="",this.audioLevel=1,this.playEvent=()=>{this.audioStatus="PLAYING",h("stream audio playing",S,this.stream.getUserId())},this.pauseEvent=()=>{this.audioStatus="PAUSED",this.fire(ht$1.PLAYER_STATE_CHANGED,[{type:"audio",state:this.audioStatus,reason:"pause"}]),h("stream audio pause",S,this.stream.getUserId())},this.stalledEvent=()=>{this.audioStatus="PAUSED",this.fire(ht$1.PLAYER_STATE_CHANGED,[{type:"audio",state:this.audioStatus,reason:"stalled"}]),h("stream audio stalled",S,this.stream.getUserId())},this.element=e,this.options=t}get streamId(){return this.stream.getStreamId()}playAudio(){if(!this.audio){if(!this.stream.getAudioTrack())return;this.audio=document.createElement("audio"),this.audio.autoplay=!0,this.audio.playsInline=!0,this.audio.muted=this.options.muted,this.audio.id=`audio_${this.stream.getStreamId()}_back`,this.element.appendChild(this.audio),this.sinkId&&this.setSinkId(this.sinkId),this.audio.volume=this.audioLevel,this.audio.addEventListener("playing",this.playEvent),this.audio.addEventListener("pause",this.pauseEvent),this.audio.addEventListener("stalled",this.stalledEvent)}let e=new MediaStream;e.addTrack(this.stream.getAudioTrack()),this.audio.srcObject=e,this.audioStatus="STOPPED"}setSinkId(e){return n(this,null,(function*(){this.sinkId=e,this.audio&&O$2.func(this.audio.setSinkId)&&(yield this.audio.setSinkId(e))}))}setVolume(e){this.audio&&(this.audioLevel=e,this.audio.volume=e)}play(e){return n(this,null,(function*(){this.stream=e,this.stream.hasAudio()&&this.playAudio();try{this.audio&&(yield this.audio.play())}catch(e){l("player play audio failed","","",[JSON.stringify(e)]),this.fire(ht$1.PLAYER_STATE_CHANGED,[{type:"error",reason:e}])}}))}replay(e,t=!0,r=!0){return n(this,null,(function*(){this.stream=e;try{this.stream.hasAudio()&&r&&this.playAudio(),this.stream.hasAudio()&&r&&(yield this.audio.play())}catch(e){l("player replay audio failed","","",[JSON.stringify(e)]),this.fire(ht$1.PLAYER_STATE_CHANGED,[{type:"error",reason:e}])}v("audio stream replay",S,this.stream.getUserId())}))}muteAudio(){this.audio&&(this.audio.srcObject=void 0,this.audioStatus="STOPPED")}unmuteAudio(){if(this.audio&&this.stream&&"STOPPED"===this.audioStatus){let e=new MediaStream;e.addTrack(this.stream.getAudioTrack()),this.audio.srcObject=e}}destroy(){var e,t,r;null==(e=this.audio)||e.removeEventListener("playing",this.playEvent),null==(t=this.audio)||t.removeEventListener("pause",this.pauseEvent),null==(r=this.audio)||r.removeEventListener("stalled",this.stalledEvent);try{this.element.removeChild(this.audio)}catch(e){}this.audio=null,v("stream player destroy",S,this.stream.getUserId())}resume(){return n(this,null,(function*(){this.audio?(yield this.audio.play(),h("stream player resume",S,this.stream.getUserId())):l("try resume audio play, but, audio not exits",S,this.stream.getUserId())}))}},E=window.BRTC,mt=E.enumAudioInputDevices,pt=E.enumAudioOutputDevices,gt=E.enumVideoDevices,bt=E.getPermissions,ft=E.checkSystemSupport,yt=E.createStream,St=T;class BoomError extends Error{constructor(e,t,r,i){super(),this.code=e,this.error=r,this.BoomErrorFlag=!0,this.eName=i,this.message=t}static instanceOf(e){return!(!e||!e.BoomErrorFlag)}getCode(){return this.code}}const LOCAL_ERROR=1e3,INVALID_PARAMETER=1001,INVALID_OPERATION=1002,CLIENT_BANNED=4005,USER_NOT_EXIT=9001,DEBUG=1,WARN=3,EMPTY_FUNCTION=function(){};function formatLog(e,t,r,i){let s=[];return r&&s.push(r),i&&s.push(i),`[${(new Date).toLocaleTimeString("chinese",{hour12:!1})}] <${e}> [${s.join("|")}] ${t}`}function info(e,t,r,i=[]){i.unshift(formatLog("INFO",e,t,r)),console.log(...i)}function warn(e,t,r,i=[]){i.unshift(formatLog("WARN",e,t,r)),console.log(...i)}function error$1(e,t,r,i=[]){i.unshift(formatLog("ERROR",e,t,r)),console.log(...i)}function isFunction(e){return"function"==typeof e}function createErrorClass(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}/BRTC/.test(EMPTY_FUNCTION.toString());var UnsubscriptionError=createErrorClass((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function arrRemove(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var Subscription=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var e,t,r,i,s;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var n=__values(o),a=n.next();!a.done;a=n.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}else o.remove(this);var d=this.initialTeardown;if(isFunction(d))try{d()}catch(e){s=e instanceof UnsubscriptionError?e.errors:[e]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var l=__values(u),c=l.next();!c.done;c=l.next()){var h=c.value;try{execFinalizer(h)}catch(e){s=null!=s?s:[],e instanceof UnsubscriptionError?s=__spreadArray(__spreadArray([],__read(s)),__read(e.errors)):s.push(e)}}}catch(e){r={error:e}}finally{try{c&&!c.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}}if(s)throw new UnsubscriptionError(s)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)execFinalizer(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&arrRemove(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&arrRemove(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),EMPTY_SUBSCRIPTION=Subscription.EMPTY;function isSubscription(e){return e instanceof Subscription||e&&"closed"in e&&isFunction(e.remove)&&isFunction(e.add)&&isFunction(e.unsubscribe)}function execFinalizer(e){isFunction(e)?e():e.unsubscribe()}var config={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},timeoutProvider={setTimeout:function(e,t){for(var r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];var s=timeoutProvider.delegate;return(null==s?void 0:s.setTimeout)?s.setTimeout.apply(s,__spreadArray([e,t],__read(r))):setTimeout.apply(void 0,__spreadArray([e,t],__read(r)))},clearTimeout:function(e){var t=timeoutProvider.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function reportUnhandledError(e){timeoutProvider.setTimeout((function(){throw e}))}function noop(){}var context=null;function errorContext(e){if(config.useDeprecatedSynchronousErrorHandling){var t=!context;if(t&&(context={errorThrown:!1,error:null}),e(),t){var r=context,i=r.errorThrown,s=r.error;if(context=null,i)throw s}}else e()}var Subscriber=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,isSubscription(t)&&t.add(r)):r.destination=EMPTY_OBSERVER,r}return __extends(t,e),t.create=function(e,t,r){return new SafeSubscriber(e,t,r)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(Subscription),_bind=Function.prototype.bind;function bind(e,t){return _bind.call(e,t)}var ConsumerObserver=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){handleUnhandledError(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){handleUnhandledError(e)}else handleUnhandledError(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){handleUnhandledError(e)}},e}(),SafeSubscriber=function(e){function t(t,r,i){var s,o,n=e.call(this)||this;isFunction(t)||!t?s={next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=i?i:void 0}:n&&config.useDeprecatedNextContext?((o=Object.create(t)).unsubscribe=function(){return n.unsubscribe()},s={next:t.next&&bind(t.next,o),error:t.error&&bind(t.error,o),complete:t.complete&&bind(t.complete,o)}):s=t;return n.destination=new ConsumerObserver(s),n}return __extends(t,e),t}(Subscriber);function handleUnhandledError(e){reportUnhandledError(e)}function defaultErrorHandler(e){throw e}var EMPTY_OBSERVER={closed:!0,next:noop,error:defaultErrorHandler,complete:noop},observable="function"==typeof Symbol&&Symbol.observable||"@@observable";function identity(e){return e}function pipeFromArray(e){return 0===e.length?identity:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var Observable=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var i=this,s=isSubscriber(e)?e:new SafeSubscriber(e,t,r);return errorContext((function(){var e=i,t=e.operator,r=e.source;s.add(t?t.call(s,r):r?i._subscribe(s):i._trySubscribe(s))})),s},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=getPromiseCtor(t))((function(t,i){var s=new SafeSubscriber({next:function(t){try{e(t)}catch(e){i(e),s.unsubscribe()}},error:i,complete:t});r.subscribe(s)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[observable]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return pipeFromArray(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=getPromiseCtor(e))((function(e,r){var i;t.subscribe((function(e){return i=e}),(function(e){return r(e)}),(function(){return e(i)}))}))},e.create=function(t){return new e(t)},e}();function getPromiseCtor(e){var t;return null!==(t=null!=e?e:config.Promise)&&void 0!==t?t:Promise}function isObserver(e){return e&&isFunction(e.next)&&isFunction(e.error)&&isFunction(e.complete)}function isSubscriber(e){return e&&e instanceof Subscriber||isObserver(e)&&isSubscription(e)}var ObjectUnsubscribedError=createErrorClass((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),Subject=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return __extends(t,e),t.prototype.lift=function(e){var t=new AnonymousSubject(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new ObjectUnsubscribedError},t.prototype.next=function(e){var t=this;errorContext((function(){var r,i;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var s=__values(t.currentObservers),o=s.next();!o.done;o=s.next()){o.value.next(e)}}catch(e){r={error:e}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}}}))},t.prototype.error=function(e){var t=this;errorContext((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var r=t.observers;r.length;)r.shift().error(e)}}))},t.prototype.complete=function(){var e=this;errorContext((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,r=this,i=r.hasError,s=r.isStopped,o=r.observers;return i||s?EMPTY_SUBSCRIPTION:(this.currentObservers=null,o.push(e),new Subscription((function(){t.currentObservers=null,arrRemove(o,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,r=t.hasError,i=t.thrownError,s=t.isStopped;r?e.error(i):s&&e.complete()},t.prototype.asObservable=function(){var e=new Observable;return e.source=this,e},t.create=function(e,t){return new AnonymousSubject(e,t)},t}(Observable),AnonymousSubject=function(e){function t(t,r){var i=e.call(this)||this;return i.destination=t,i.source=r,i}return __extends(t,e),t.prototype.next=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===r||r.call(t,e)},t.prototype.error=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===r||r.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,r;return null!==(r=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==r?r:EMPTY_SUBSCRIPTION},t}(Subject),BehaviorSubject=function(e){function t(t){var r=e.call(this)||this;return r._value=t,r}return __extends(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(t){var r=e.prototype._subscribe.call(this,t);return!r.closed&&t.next(this._value),r},t.prototype.getValue=function(){var e=this,t=e.hasError,r=e.thrownError,i=e._value;if(t)throw r;return this._throwIfClosed(),i},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(Subject);Object.freeze({}),Object.freeze([]);const LOGGER_TAG_CLIENT="c";var MODEL_SORT_ENUM_STAND,MODEL_SORT_ENUM_ZY,STREAM_TYPE;!function(e){e[e.SCREEN_MASTER=0]="SCREEN_MASTER",e[e.SCREEN_MANAGER_AUDIO_VIDEO=1]="SCREEN_MANAGER_AUDIO_VIDEO",e[e.SCREEN_MANAGER_AUDIO=2]="SCREEN_MANAGER_AUDIO",e[e.SCREEN_MANAGER_VIDEO=3]="SCREEN_MANAGER_VIDEO",e[e.SCREEN_MANAGER=4]="SCREEN_MANAGER",e[e.SCREEN_GUEST_AUDIO_VIDEO=5]="SCREEN_GUEST_AUDIO_VIDEO",e[e.SCREEN_GUEST_AUDIO=6]="SCREEN_GUEST_AUDIO",e[e.SCREEN_GUEST_VIDEO=7]="SCREEN_GUEST_VIDEO",e[e.SCREEN_GUEST=8]="SCREEN_GUEST",e[e.SCREEN_COMMONUSER_AUDIO_VIDEO=9]="SCREEN_COMMONUSER_AUDIO_VIDEO",e[e.SCREEN_COMMONUSER_AUDIO=10]="SCREEN_COMMONUSER_AUDIO",e[e.SCREEN_COMMONUSER_VIDEO=11]="SCREEN_COMMONUSER_VIDEO",e[e.SCREEN_OTHER=12]="SCREEN_OTHER",e[e.MASTER=13]="MASTER",e[e.LOCAL=14]="LOCAL",e[e.MANAGER_AUDIO_VIDEO=15]="MANAGER_AUDIO_VIDEO",e[e.MANAGER_AUDIO=16]="MANAGER_AUDIO",e[e.MANAGER_VIDEO=17]="MANAGER_VIDEO",e[e.MANAGER=18]="MANAGER",e[e.RAISE_HAND=19]="RAISE_HAND",e[e.RAISE_AUDIO=20]="RAISE_AUDIO",e[e.RAISE_VIDEO=21]="RAISE_VIDEO",e[e.GUEST_AUDIO_VIDEO=22]="GUEST_AUDIO_VIDEO",e[e.GUEST_AUDIO=23]="GUEST_AUDIO",e[e.GUEST_VIDEO=24]="GUEST_VIDEO",e[e.GUEST=25]="GUEST",e[e.SIGNAL=26]="SIGNAL",e[e.COMMONUSER_AUDIO_VIDEO=27]="COMMONUSER_AUDIO_VIDEO",e[e.COMMONUSER_AUDIO=28]="COMMONUSER_AUDIO",e[e.COMMONUSER_VIDEO=29]="COMMONUSER_VIDEO",e[e.OTHER=30]="OTHER"}(MODEL_SORT_ENUM_STAND||(MODEL_SORT_ENUM_STAND={})),function(e){e[e.SCREEN=0]="SCREEN",e[e.RAISE_AUDIO=1]="RAISE_AUDIO",e[e.RAISE_VIDEO=2]="RAISE_VIDEO",e[e.LOCAL=3]="LOCAL",e[e.MASTER_AUDIO_VIDEO=4]="MASTER_AUDIO_VIDEO",e[e.MANAGER_AUDIO_VIDEO=5]="MANAGER_AUDIO_VIDEO",e[e.AUDIO_VIDEO=6]="AUDIO_VIDEO",e[e.MASTER_AUDIO=7]="MASTER_AUDIO",e[e.MANAGER_AUDIO=8]="MANAGER_AUDIO",e[e.AUDIO=9]="AUDIO",e[e.MASTER_VIDEO=10]="MASTER_VIDEO",e[e.MANAGER_VIDEO=11]="MANAGER_VIDEO",e[e.VIDEO=12]="VIDEO",e[e.MASTER=13]="MASTER",e[e.MANAGER=14]="MANAGER",e[e.GUEST=15]="GUEST",e[e.COMMON_USER=16]="COMMON_USER",e[e.SIGNAL=17]="SIGNAL",e[e.OTHER=18]="OTHER"}(MODEL_SORT_ENUM_ZY||(MODEL_SORT_ENUM_ZY={})),function(e){e[e.SUB_MAIN=0]="SUB_MAIN",e[e.SINGLE=1]="SINGLE",e[e.SHARE=2]="SHARE",e[e.OTHER=3]="OTHER"}(STREAM_TYPE||(STREAM_TYPE={}));const STREAM_SUFFIX_SCREEN="_screen",MOBILE_STREAM_SUFFIX_SCREEN="screen-",SIGNAL_SUFFIX="xinhao_",RECEIVE_SUBSCRIBE_MESSAGE="sub-message",USER_SORT_NUM_CHANGE="user-sort-num-change",BIND_ELEMENT="bind-element",HANDLE_STREAM_CONNECT_ERROR="stream-connect-error",RAISE_HAND="raise-hand",MANUAL_SUBSCRIPTION="manual-subscription",UNSUBSCRIBE_STREAM="unsubscribe-stream",CHANG_IS_GUEST="change-is-guest",BIND_BIG_ELEMENT="bind-big-element",NO_CONTAINER="no-container",MODEL_SORT_NUM_CHANGE="model-sort-num-change",ADD_PULL_USER="add-pull-user",SET_VOLUME="set-volume",ADD_AUDIO_PLAY="add-audio-play";function mitt(e){return{all:e=e||new Map,on:function(t,r){var i=e.get(t);i?i.push(r):e.set(t,[r])},off:function(t,r){var i=e.get(t);i&&(r?i.splice(i.indexOf(r)>>>0,1):e.set(t,[]))},emit:function(t,r){var i=e.get(t);i&&i.slice().map((function(e){e(r)})),(i=e.get("*"))&&i.slice().map((function(e){e(t,r)}))}}}class BoomEmitter{static getInstance(){return BoomEmitter.emitter||(BoomEmitter.emitter=mitt()),BoomEmitter.emitter}}function getSortNum(e){return 2===_selfSortType?sortZY(e):sortStand(e)}function sortStand(e){let t=MODEL_SORT_ENUM_STAND.OTHER;return e.isSharing?(t=e.isMaster?MODEL_SORT_ENUM_STAND.SCREEN_MASTER:e.isManager&&e.audioEnable&&e.videoEnable?MODEL_SORT_ENUM_STAND.SCREEN_MANAGER_AUDIO_VIDEO:e.isManager&&e.audioEnable?MODEL_SORT_ENUM_STAND.SCREEN_MANAGER_AUDIO:e.isManager&&e.videoEnable?MODEL_SORT_ENUM_STAND.SCREEN_MANAGER_VIDEO:e.isManager?MODEL_SORT_ENUM_STAND.SCREEN_MANAGER:e.isCommonUser?e.audioEnable&&e.videoEnable?MODEL_SORT_ENUM_STAND.SCREEN_COMMONUSER_AUDIO_VIDEO:e.audioEnable?MODEL_SORT_ENUM_STAND.SCREEN_COMMONUSER_AUDIO:e.videoEnable?MODEL_SORT_ENUM_STAND.SCREEN_COMMONUSER_VIDEO:MODEL_SORT_ENUM_STAND.SCREEN_OTHER:e.audioEnable&&e.videoEnable?MODEL_SORT_ENUM_STAND.SCREEN_GUEST_AUDIO_VIDEO:e.audioEnable?MODEL_SORT_ENUM_STAND.SCREEN_GUEST_AUDIO:e.videoEnable?MODEL_SORT_ENUM_STAND.SCREEN_GUEST_VIDEO:MODEL_SORT_ENUM_STAND.SCREEN_GUEST,t):(e.isMaster?t=MODEL_SORT_ENUM_STAND.MASTER:e.isLocal?t=MODEL_SORT_ENUM_STAND.LOCAL:e.isManager?t=e.audioEnable&&e.videoEnable?MODEL_SORT_ENUM_STAND.MANAGER_AUDIO_VIDEO:e.audioEnable?MODEL_SORT_ENUM_STAND.MANAGER_AUDIO:e.videoEnable?MODEL_SORT_ENUM_STAND.MANAGER_VIDEO:MODEL_SORT_ENUM_STAND.MANAGER:e.raiseHand?t=MODEL_SORT_ENUM_STAND.RAISE_HAND:e.isCommonUser?e.isSignal?t=MODEL_SORT_ENUM_STAND.SIGNAL:e.isCommonUser&&(t=e.audioEnable&&e.videoEnable?MODEL_SORT_ENUM_STAND.COMMONUSER_AUDIO_VIDEO:e.audioEnable?MODEL_SORT_ENUM_STAND.COMMONUSER_AUDIO:e.videoEnable?MODEL_SORT_ENUM_STAND.COMMONUSER_VIDEO:MODEL_SORT_ENUM_STAND.OTHER):t=e.audioEnable&&e.videoEnable?MODEL_SORT_ENUM_STAND.GUEST_AUDIO_VIDEO:e.audioEnable?MODEL_SORT_ENUM_STAND.GUEST_AUDIO:e.videoEnable?MODEL_SORT_ENUM_STAND.GUEST_VIDEO:MODEL_SORT_ENUM_STAND.GUEST,t)}function sortZY(e){let t;return t=e.isToupingma?MODEL_SORT_ENUM_ZY.SCREEN:e.raiseHand?MODEL_SORT_ENUM_STAND.RAISE_HAND:e.raiseAudioHands?MODEL_SORT_ENUM_ZY.RAISE_AUDIO:e.raiseVideoHands?MODEL_SORT_ENUM_ZY.RAISE_VIDEO:e.isLocal?MODEL_SORT_ENUM_ZY.LOCAL:e.isMaster&&e.audioEnable&&e.videoEnable?MODEL_SORT_ENUM_ZY.MASTER_AUDIO_VIDEO:e.isManager&&e.audioEnable&&e.videoEnable?MODEL_SORT_ENUM_ZY.MANAGER_AUDIO_VIDEO:e.audioEnable&&e.videoEnable?MODEL_SORT_ENUM_ZY.AUDIO_VIDEO:e.isMaster&&e.audioEnable?MODEL_SORT_ENUM_ZY.MASTER_AUDIO:e.isManager&&e.audioEnable?MODEL_SORT_ENUM_ZY.MANAGER_AUDIO:e.audioEnable?MODEL_SORT_ENUM_ZY.AUDIO:e.isMaster&&e.videoEnable?MODEL_SORT_ENUM_ZY.MASTER_VIDEO:e.isManager&&e.videoEnable?MODEL_SORT_ENUM_ZY.MANAGER_VIDEO:e.videoEnable?MODEL_SORT_ENUM_ZY.VIDEO:e.isMaster?MODEL_SORT_ENUM_ZY.MASTER:e.isManager?MODEL_SORT_ENUM_ZY.MANAGER:e.isCommonUser?MODEL_SORT_ENUM_ZY.COMMON_USER:e.isSignal?MODEL_SORT_ENUM_ZY.SIGNAL:MODEL_SORT_ENUM_ZY.GUEST,t}BoomEmitter.emitter=void 0,BoomEmitter.removeEmitter=()=>{var e,t,r,i,s,o,n,a,d,u,l,c,h,m;null===(e=BoomEmitter.emitter)||void 0===e||e.off(RECEIVE_SUBSCRIBE_MESSAGE),null===(t=BoomEmitter.emitter)||void 0===t||t.off(USER_SORT_NUM_CHANGE),null===(r=BoomEmitter.emitter)||void 0===r||r.off(HANDLE_STREAM_CONNECT_ERROR),null===(i=BoomEmitter.emitter)||void 0===i||i.off(RAISE_HAND),null===(s=BoomEmitter.emitter)||void 0===s||s.off(UNSUBSCRIBE_STREAM),null===(o=BoomEmitter.emitter)||void 0===o||o.off(MANUAL_SUBSCRIPTION),null===(n=BoomEmitter.emitter)||void 0===n||n.off(CHANG_IS_GUEST),null===(a=BoomEmitter.emitter)||void 0===a||a.off(BIND_ELEMENT),null===(d=BoomEmitter.emitter)||void 0===d||d.off(BIND_BIG_ELEMENT),null===(u=BoomEmitter.emitter)||void 0===u||u.off(NO_CONTAINER),null===(l=BoomEmitter.emitter)||void 0===l||l.off(MODEL_SORT_NUM_CHANGE),null===(c=BoomEmitter.emitter)||void 0===c||c.off(ADD_PULL_USER),null===(h=BoomEmitter.emitter)||void 0===h||h.off(SET_VOLUME),null===(m=BoomEmitter.emitter)||void 0===m||m.off(ADD_AUDIO_PLAY),BoomEmitter.emitter=void 0};class BMUser{constructor(e,t=!1){var r;this.streamModels=new Map,this.sortNum=100,this.raiseVideoHands=!1,this.raiseAudioHands=!1,this.raiseHand=!1,this.isAudience=!1,this.isCommonUser=!1,this.inBackground=!1,this.raiseHandTime=0,this.userId=e.userId,this.userInfo=e.userInfo,this.nickName=e.nickname,this.isMaster=!!e.isMaster,this.isManager=!!e.isManager,this.isToupingma=!!e.isToupingma,this.isLocal=t,this.hasMultiple=!!e.hasMultiple,this.isCreate=!!e.isCreate,this.hasShare=!!e.hasShare,this.avatar=null===(r=e.userInfo)||void 0===r?void 0:r.avatar,this.permission=e.permission,this.raiseAudioHands=!!e.raiseAudioHands,this.raiseVideoHands=!!e.raiseVideoHands,this.raiseHand=!!e.raiseHand,this.isAudience=!!e.isAudience,this.isCommonUser=!!e.isCommonUser,this.inBackground=!!e.inBackground,this.audienceEnableSpeaking=!!e.audienceEnableSpeaking,this.raiseHandTime=e.raiseHandTime||0;const i={operation:"none",user:this};this.watcher=new BehaviorSubject(i),this.updateSortNum(!1)}get isWeb(){return!(!this.userInfo.pos||!this.userInfo.pos.includes("web")&&!this.userInfo.pos.includes("pc"))}setup(e,t,r){this.isLocal=!0,this.userId=e,this.userInfo=t,this.nickName=r||t.nickname,this.avatar=t.avatar}getMainStreamModel(){return this.streamModels.get(this.userId)}get nickname(){return this.nickName}getShareStreamModel(){return this.streamModels.get(`${this.userId}${STREAM_SUFFIX_SCREEN}`)}get audioEnable(){const e=this.getMainStreamModel();return!!e&&e._audio_enable}get isMixer(){return this.userId.includes("-mixer-")}get videoEnable(){const e=this.getMainStreamModel();return!!e&&e._video_enable}get isSharing(){let e=!1;for(let t of this.streamModels.values())if(t.isShare){e=!0;break}return e}get isSignal(){var e;return!!(null===(e=this.userId)||void 0===e?void 0:e.startsWith(SIGNAL_SUFFIX))}checkLocalHasMaster(){return this.isMaster||this.isManager}addStream(e,t){this.streamModels.set(e,t),this.watcher.next({operation:"changeShare",user:this})}removeStream(e){this.streamModels.delete(e),e.includes(STREAM_SUFFIX_SCREEN)&&info("删除的是共享屏幕的流:","","",["streamId =>",e]),setTimeout((()=>{this.watcher.next({operation:"changeShare",user:this})}),400)}getID(){return this.userId}getNickName(){return this.nickName}getUserInfo(){return this.userInfo}getStreams(){return this.streamModels}updateUserInfo(e,t={},r){var i,s,o,n,a,d;const u=null===(i=null==t?void 0:t.params)||void 0===i?void 0:i.customInfo,l=(null==u?void 0:u.updateKeys)||[];let c=!1,h="none";if(info("updateUserInfo =>","updateUser",e.userId,["updateKeys",l.toString(),"permission",null===(s=e.permission)||void 0===s?void 0:s.permission,"isMaster =>",this.isMaster,"isManager =>",this.isManager]),this.nickName!==e.nickname&&(h="changeNickName"),this.isMaster||!this.isManager||e.permission.getManage()||(h="removeManager",this.isManager=!1),this.isMaster||this.isManager||!e.permission.getManage()||-1!=l.indexOf("changeMaster")||(h="getManager",this.isManager=!0),e.userinfo.pos)this.userInfo=e.userinfo;else{const t=this.userInfo.pos;this.userInfo=e.userinfo,this.userInfo.pos=t}(l.includes("changeMaster")||l.includes("permission"))&&(e.permission=t.getPermission()),l.includes("raiseHandsAudio")&&(this.raiseAudioHands=u.raiseHandsAudio,h="raiseHandsAudio",BoomEmitter.emitter.emit(RAISE_HAND,{status:"raiseHandsAudio",user:this}),c=!0),l.includes("raiseHandsVideo")&&(this.raiseVideoHands=u.raiseHandsVideo,h="raiseHandsVideo",BoomEmitter.emitter.emit(RAISE_HAND,{status:"raiseHandsVideo",user:this}),c=!0),l.includes("raiseHand")&&(this.raiseHand=u.raiseHand,this.raiseHandTime=u.raiseHandTime,h="raiseHand",BoomEmitter.emitter.emit(RAISE_HAND,{status:"raiseHand",user:this}),c=!0),1!==r.conferenceMode&&this.isAudience&&l.includes("permission")&&(-1!==(null===(n=null===(o=t.params)||void 0===o?void 0:o.customInfo)||void 0===n?void 0:n.permission.indexOf("A"))&&(r.enableAudienceSpeakingWatcher.next(!0),this.audienceEnableSpeaking=!0,h="audienceEnableSpeaking",r.bmLiveVM.handleAudienceEnable()),-1===(null===(d=null===(a=t.params)||void 0===a?void 0:a.customInfo)||void 0===d?void 0:d.permission.indexOf("A"))&&(r.enableAudienceSpeakingWatcher.next(!1),this.audienceEnableSpeaking=!1,h="audienceEnableSpeaking",r.bmLiveVM.handleAudienceDisable())),l.includes("inBackground")&&(h="inBackground",this.inBackground=u.inBackground),this.nickName=e.nickname,this.permission=e.permission;let m=!this.isCommonUser;this.isCommonUser=!e.permission.getSubscribe(),m!==!this.isCommonUser&&(info(`身份有发生过变化,从${m?"嘉宾":"普通参会者"} => ${this.isCommonUser?"普通参会者":"嘉宾"}`),BoomEmitter.emitter.emit(CHANG_IS_GUEST,{user:this,isGuest:!this.isCommonUser,preIsGuest:m})),h&&this.watcher.next({operation:h,user:this}),(!c||c&&!this.isLocal)&&this.updateSortNum(!0)}hasManager(){return this.isManager||this.isMaster}getNicknameSuffix(){let e="";return this.isLocal&&this.isMaster?e="(我、主持人)":this.isLocal&&this.isManager?e="(我、联席主持人)":this.isLocal?e="(我)":this.isMaster?e="(主持人)":this.isManager?e="(联席主持人)":this.isSharing&&!this.isToupingma?e="的共享屏幕":this.isSharing&&this.isToupingma&&(e="(仅共享屏幕)"),e}updateSortNum(e=!0,t=!1){let r=getSortNum(this);this.setSortNum(r,e,t)}setSortNum(e,t,r){this.sortNum!==e&&(this.sortNum=e,t&&BoomEmitter.emitter.emit(USER_SORT_NUM_CHANGE,{isCommon:this.isCommonUser,shouldDelay:r}))}}const NULL=null,UNDEFINED=void 0,RAW_FUNCTION="function";Object.freeze({}),Object.freeze([]);const EMPTY_STRING="";function func(e){return typeof e===RAW_FUNCTION}function indexOf(e,t,r){return e.indexOf(t,r!==UNDEFINED?r:0)}function has(e,t){return indexOf(e,t)>=0}function toString(e,t){return e!=NULL&&e.toString?e.toString():t!==UNDEFINED?t:EMPTY_STRING}function isNative(e){return func(e)&&has(toString(e),"[native code]")}typeof setImmediate===RAW_FUNCTION&&isNative(setImmediate)&&setImmediate,typeof MessageChannel===RAW_FUNCTION&&isNative(MessageChannel);const notGetTalkInterval=3e5;function handleTime(e){let t=new Date(e),r=new Date,i=t.getMonth()+1<10?"0"+(t.getMonth()+1):t.getMonth()+1,s=t.getDate()<10?"0"+t.getDate():t.getDate(),o=t.getHours()<10?"0"+t.getHours():t.getHours(),n=t.getMinutes()<10?"0"+t.getMinutes():t.getMinutes();return r.setHours(0,0,0,0)==t.setHours(0,0,0,0)?o+":"+n:i+"月"+s+"日 "+o+":"+n}function sortUsers(e){return e.sort(((e,t)=>e.sortNum===MODEL_SORT_ENUM_STAND.RAISE_HAND&&t.sortNum===MODEL_SORT_ENUM_STAND.RAISE_HAND?e.raiseHandTime-t.raiseHandTime:e.sortNum-t.sortNum))}function sortStreamModels(e){return e.sort(((e,t)=>e.sortNum!==t.sortNum?t.sortNum-e.sortNum:Number(e.getUser().isCommonUser)-Number(t.getUser().isCommonUser)))}function getIsCommonUser(e){return!getPermission(e,"s")}function getIsManager(e){return getPermission(e,"m")}function getIsMaster(e){return getPermission(e,"o")}function getPermission(e,t){return e.toLowerCase().includes(t)}function sleep(e){return new Promise((t=>setTimeout(t,e)))}const ignoreUserId=["-mixer-","-rtmpmixer-","record#","robot_","stt_"],BLOUD_PAGE_SIZE=500,PERMISSION_NOT_COMMON="RWPSAVMO,RWPSAVM,RWPSAV";class BMUserVM{constructor(e,t,r){this.userList=new Map,this.audiencesList=new Map,this.signalList=new Map,this.commonUserList=new Map,this.userListWatcher=new BehaviorSubject(Array.from(this.userList.values())),this.audiencesListWatcher=new BehaviorSubject(Array.from(this.audiencesList.values())),this.commonUserListWatcher=new BehaviorSubject(Array.from(this.commonUserList.values())),this.signalListWatcher=new BehaviorSubject(Array.from(this.signalList.values())),this.masterUserWatcher=new BehaviorSubject(null),this.getForceUserWatcher=new BehaviorSubject(!1),this.commTimer=200,this.addBCUser=(e,t=!1)=>{var r;const i=this.addUser(e);if(!this.room.bmStreamVm.streamModels.get(e.userId)){const t=this.getUser(e.userId);t?this.room.bmStreamVm.createStreamModel(t):error$1(`there is no user named ${e.userId}, and create streamModel failed!!!`)}{const i=this.room.bmStreamVm.streamModels.get(e.userId);i&&(e.stream.size?e.stream.forEach((r=>__awaiter(this,void 0,void 0,(function*(){var s,o,n;const{video_enable:a,audio_enable:d,customInfo:u}=r;if(r.screen){this.room.bmStreamVm.shareBloudStateMap.set(e.userId,{audio:d,video:a,customInfo:u,userId:e.userId,streamId:r.getID(),isScreen:!0});const n={id:i.userId,isScreen:!0,isWeb:i.isWeb};if(t){const t=new Map;t.set(e.userId,n),yield null===(s=this.room)||void 0===s?void 0:s.processUser(t)}else null===(o=this.room)||void 0===o||o.addUser2Queue(n)}else if(i&&(i.updateBloudStream({video:a,audio:d,isScreen:r.screen,customInfo:u},this.room.bmStreamVm),t)){const t={id:i.userId,isScreen:!1,isWeb:i.isWeb},r=new Map;r.set(e.userId,t),null===(n=this.room)||void 0===n||n.processUser(r)}})))):(i.bloudStream&&i.updateBloudStream(void 0,this.room.bmStreamVm),null===(r=this.room)||void 0===r||r.bmStreamVm.removeShareStreamModelByUId(e.userId)))}return i&&i.isMaster&&this.masterUserWatcher.next(i),null==i||i.updateSortNum(!1),i},this.updateAllSort=()=>{this.updateUserSort(),this.updateCommonUserSort()},this.updateSortByType=e=>{var t,r;(null===(t=this.room)||void 0===t?void 0:t.isSingleColumns)||e.isCommon?(null===(r=this.room)||void 0===r?void 0:r.isBig)&&e.shouldDelay?this.updateDelayCommonUserSort():this.updateCommonUserSort():this.updateUserSort()},this.updateUserSort=debounce((()=>{const e=this.sortUsers();this.userListWatcher.next(BMUserVM.filterUsers(e))}),200,{maxWait:1e3}),this.updateCommonUserSort=debounce((()=>{const e=this.sortCommonUsers();this.commonUserListWatcher.next(BMUserVM.filterUsers(e))}),this.commTimer,{maxWait:12e3}),this.updateDelayCommonUserSort=debounce((()=>{const e=this.sortCommonUsers();this.commonUserListWatcher.next(BMUserVM.filterUsers(e))}),12e4,{maxWait:12e4}),this.updateAudienceUserSort=()=>{const e=this.sortAudiences();this.audiencesListWatcher.next(BMUserVM.filterUsers(e))},this.updateSignalUserSort=()=>{const e=this.sortSignalUsers();this.signalListWatcher.next(e)},this.transBloudUsers=(e,t="",r=!1,i=0)=>__awaiter(this,void 0,void 0,(function*(){const s=new Map;yield this.getAllUsers(e,s,t,r).catch((()=>i<3?(error$1("get bloud user error, retry"),i+=1,void this.transBloudUsers(e,t,r,i)):void error$1("get current page of bloud users after 10 times final failed","","",[" page ",e," permission ",t]))),yield this.initUserList(s),s.clear();let o=[];for(let e of this.userList.values())(e.raiseVideoHands||e.raiseAudioHands||e.raiseHand)&&o.push(e);for(let e of this.commonUserList.values())(e.raiseVideoHands||e.raiseAudioHands||e.raiseHand)&&o.push(e);for(let e of this.commonUserList.values())(e.raiseVideoHands||e.raiseAudioHands)&&o.push(e);this.room.roomInfo.setRaiseHandsList(o),this.updateAllSort(),this.room.bmStreamVm.updateModelSort()})),this.boomCore=e,this.localUser=t,this.room=r,BoomEmitter.emitter||error$1("init boom emitter error"),BoomEmitter.emitter.on(CHANG_IS_GUEST,this.handleUserRoleChange.bind(this)),BoomEmitter.emitter.on(USER_SORT_NUM_CHANGE,this.updateSortByType)}handleUserRoleChange(e){var t,r,i;return __awaiter(this,void 0,void 0,(function*(){const{user:s,isGuest:o,preIsGuest:n}=e,a=null===(t=this.room)||void 0===t?void 0:t.roomInfo.isBigRoom;info("handleUserRoleChange","",s.userId,["isGuest =>",o,"preIsGuest =>",n,"isBigRoom =>",a]);if(1===(null===(r=this.room)||void 0===r?void 0:r.userListColumns)||(n?this.userList.delete(s.userId):this.commonUserList.delete(s.userId),o?this.userList.set(s.userId,s):this.commonUserList.set(s.userId,s)),a)if(o)s.isLocal&&(yield this.initUsers());else{const e=null===(i=this.room)||void 0===i?void 0:i.getLocalParticipant().isCommonUser;if(s.isLocal&&(this.handleUnSubCommonUser(),this.handleCommonUserChange(),this.commonUserList.set(s.userId,s)),e){const e=s.getMainStreamModel();e&&e.unSubscribeStream(),s.isLocal||this.commonUserList.delete(s.userId)}}this.updateAllSort()}))}addUser(e){var t;const r=this.getUser(e.userId);if(r)return info("该用户已经加入房间",LOGGER_TAG_CLIENT,e.userId),this.updateUser(r,e),null;let i;return this.boomCore.userId==e.userId?(this.updateUser(this.localUser,e),i=this.localUser):i=this.toBMUser(e),1===(null===(t=this.room)||void 0===t?void 0:t.userListColumns)?this.commonUserList.set(i.userId,i):i.isAudience?this.audiencesList.set(i.userId,i):i.isSignal?this.signalList.set(i.userId,i):i.isCommonUser?this.commonUserList.set(i.userId,i):this.userList.set(i.userId,i),i}removeUser(e){let t=this.userList.delete(e);return t||(t=this.signalList.delete(e)),t||(t=this.audiencesList.delete(e)),t||(t=this.commonUserList.delete(e)),t||warn("userList中未找到该用户, 移除无效",LOGGER_TAG_CLIENT,e),t}videoEnable(e){const t=this.getUser(e);if(t)return t.videoEnable;throw new BoomError(USER_NOT_EXIT,"用户不存在")}audioEnable(e){const t=this.getUser(e);if(t)return t.audioEnable;throw new BoomError(USER_NOT_EXIT,"用户不存在")}checkIsMaster(e){if(!e)return!1;const t=this.boomCore.getMaster();return!!t&&t===e}checkLocalHasMaster(){return this.localUser.isMaster||this.localUser.isManager}checkUserHasMaster(e){const t=this.userList.get(e);return!!t&&t.permission.getManage()}getUser(e){let t;return t=(null==e?void 0:e.startsWith(SIGNAL_SUFFIX))?this.signalList.get(e):this.userList.get(e),t||(t=this.commonUserList.get(e)),t||(t=this.audiencesList.get(e)),t}getAllUsers(e,t,r="",i=!1){return __awaiter(this,void 0,void 0,(function*(){let s;if(i){let{users:t,total:i}=yield this.boomCore.getUsersList(e,r,BLOUD_PAGE_SIZE);s=t}else{let{users:t,total:i}=yield this.boomCore.getUsers(e,r,BLOUD_PAGE_SIZE);s=t}s.forEach((e=>{t.set(e.userId,e)}))}))}initUserList(e){var t,r;return __awaiter(this,void 0,void 0,(function*(){const i=e.get(this.localUser.userId);if(i){const e=this.addUser(i);if(!(null===(t=this.room)||void 0===t?void 0:t.bmStreamVm.getStreamModelByUId(i.userId))){const e=this.getUser(i.userId);e?null===(r=this.room)||void 0===r||r.bmStreamVm.createStreamModel(e):error$1("there is no local streamModel exits, and create failed!!!")}(null==e?void 0:e.isMaster)&&this.masterUserWatcher.next(e)}e.delete(this.localUser.userId),e&&e.size>0&&this.addBcUsersMap(e)}))}addBcUsersMap(e,t=!1){e.forEach((e=>{this.addBCUser(e,t)}))}updateMaster(e,t,r){const i=this.getUser(e);i&&(i.isManager&&(i.isManager=!1),i.isMaster=!0,i.updateSortNum());const s=this.getUser(t);return s&&(s.isMaster=!1,r&&(s.isManager=!0),s.updateSortNum()),i||s||error$1("未找到该用户, updateMaster未生效",LOGGER_TAG_CLIENT,e,["masterId => ",e,"oldMasterId => ",t]),{master:i,oldMaster:s}}managerChangeToGuest(e){const t=this.getUser(e);return t?t.isManager?(t.permission.setManage(!1),t.permission.setSubscribe(!0),this.boomCore.updateUser(e,{customInfo:{permission:t.permission.get()}}),t.watcher.next({operation:"getGuest",user:t}),this.updateAllSort()):error$1("该用户不是管理员,无法设置为嘉宾",LOGGER_TAG_CLIENT,e):error$1("未找到该用户, managerChangeToGuest未生效",LOGGER_TAG_CLIENT,e),t}updateManager(e,t,r=!0){const i=this.getUser(e);return i?(i.permission.setManage(t),i.permission.setSubscribe(t),this.boomCore.updateUser(e,{customInfo:{permission:i.permission.get()}}),i.watcher.next({operation:t?"getManager":"removeManager",user:i}),this.updateAllSort()):error$1("userList中未找到该用户, updateManager未生效",LOGGER_TAG_CLIENT,e),i}getLocalUser(){return this.localUser}updateUser(e,t){var r,i,s,o,n;const a=this.checkIsMaster(t.userId),d=((null===(r=t.permission)||void 0===r?void 0:r.getManage())||getIsManager(null===(i=t.permission)||void 0===i?void 0:i.permission))&&!((null===(s=t.permission)||void 0===s?void 0:s.getOwn())||getIsMaster(null===(o=t.permission)||void 0===o?void 0:o.permission));let u="none";const l=e.isMaster;e.isManager!==d&&(u=d?"getManager":"removeManager"),"none"!==u&&setTimeout((()=>{e.watcher.next({operation:u,user:e})}),10),l!==a&&(u=a?"getMaster":"removeMaster"),"none"!==u&&setTimeout((()=>{e.watcher.next({operation:u,user:e})}),100);const c=e.raiseHand,h=t.customInfo.raiseHand;c!==h&&(!h&&c&&this.room.roomInfo.removeSimpleRaiseHandUser(e.userId),setTimeout((()=>{e.watcher.next({operation:"raiseHand",user:e})}),300));const m=e.raiseVideoHands,p=t.customInfo.raiseHandsVideo;m!==p&&(!p&&m&&this.room.roomInfo.removeVideoRaiseHandUser(e.userId),setTimeout((()=>{e.watcher.next({operation:"raiseHandsVideo",user:e})}),300));const f=e.raiseAudioHands,v=t.customInfo.raiseHandsAudio;f!==v&&(!v&&f&&this.room.roomInfo.removeRaiseHandUser(e.userId),setTimeout((()=>{e.watcher.next({operation:"raiseHandsAudio",user:e})}),300));e.nickname!==t.nickname&&setTimeout((()=>{e.watcher.next({operation:"changeNickName",user:e})}),300),e.userInfo=t.userinfo,e.nickName=t.nickname,e.userId=t.userId,e.permission=t.permission,e.avatar=t.userinfo.avatar,e.isToupingma=t.userinfo.pos.includes("_toupingma"),e.raiseHand=h,e.isMaster=a,e.isCreate=this.boomCore.getCreator()===t.userId,e.isAudience=!t.permission.getAudio(),e.isCommonUser=!t.permission.getSubscribe(),e.isManager=d,e.inBackground=!!(null===(n=null==t?void 0:t.customInfo)||void 0===n?void 0:n.inBackground),e.updateSortNum()}updateLocalUserPermission(e){const t=this.getLocalUser();t.isMaster=getIsMaster(e),t.isManager=!getIsMaster(e)&&getIsManager(e),t.isCommonUser=getIsCommonUser(e),t.watcher.next({operation:"none",user:t})}toBMUser(e){var t,r;let i={};i.userInfo=e.userinfo,i.nickname=e.nickname,i.userId=e.userId,i.streamModels=[],i.permission=e.permission,i.stream=e.stream,i.isToupingma=!(!e.userinfo.pos||!e.userinfo.pos.includes("_toupingma")),i.isMaster=this.checkIsMaster(i.userId),i.isAudience=!e.permission.getAudio(),i.isCommonUser=!e.permission.getSubscribe()||getIsCommonUser(e.permission.permission),i.raiseAudioHands=e.customInfo.raiseHandsAudio,i.raiseVideoHands=e.customInfo.raiseHandsVideo,i.raiseHand=e.customInfo.raiseHand,i.raiseHandTime=e.customInfo.raiseHandTime,i.inBackground=e.customInfo.inBackground,i.isCreate=this.boomCore.getCreator()===e.userId;let s=this.boomCore.getLocalParticipant();if(!s)throw new BoomError(INVALID_PARAMETER,"BCUserVM addUser时未找到本地用户");return s.getID()==i.userId&&(i.isLocal=!0),!(null===(t=i.permission)||void 0===t?void 0:t.getManage())&&!getIsManager(null===(r=i.permission)||void 0===r?void 0:r.permission)||i.isMaster||(i.isManager=!0),new BMUser(i,i.isLocal)}sortUsers(){return sortUsers(Array.from(this.userList.values()))}sortAudiences(){return sortUsers(Array.from(this.audiencesList.values()))}sortCommonUsers(){return sortUsers(Array.from(this.commonUserList.values()))}sortSignalUsers(){return sortUsers(Array.from(this.signalList.values()))}static filterUsers(e){return e.filter((e=>!ignoreUserId.some((t=>e.userId.includes(t)))))}initUsers(){var e;return __awaiter(this,void 0,void 0,(function*(){const t=yield this.getTotalUserNumber();info(`initUsers total users num: ${t}`);const r=Math.ceil(t/BLOUD_PAGE_SIZE);let i=0;const s=[],o=e=>__awaiter(this,void 0,void 0,(function*(){e<r&&(yield this.transBloudUsers(e-1))})),n=e=>__awaiter(this,void 0,void 0,(function*(){for(const t of e)yield t(),yield sleep(50)}));if(this.localUser.isCommonUser&&(null===(e=this.room)||void 0===e?void 0:e.isBig))this.commonUserList.set(this.localUser.userId,this.localUser),yield this.transBloudUsers(-1,PERMISSION_NOT_COMMON,!0);else{for(;i<r;)s.push(o.bind(null,i)),i+=1;n(s)}}))}handleUnSubCommonUser(){this.commonUserList.forEach((e=>{const t=e.getMainStreamModel();(null==t?void 0:t.hasPulled)&&t.unSubscribeStream()}))}handleCommonUserChange(){let e=new Map;this.room.bmStreamVm.streamModels.forEach((t=>{t.getUser().isCommonUser&&!t.isLocal||e.set(t.userId,t)})),this.room.bmStreamVm.streamModels=e,this.commonUserList.clear()}getUsers(e,t,r="RWPAV"){return __awaiter(this,void 0,void 0,(function*(){const{users:i,total:s}=yield this.boomCore.getUsers(e,r,t),o=[];return i.forEach((e=>{const t=this.toBMUser(e);o.push(t)})),{userList:o,total:s}}))}getUsersList(e,t,r="",i=!1){var s,o;return __awaiter(this,void 0,void 0,(function*(){const{users:n,total:a,pageIndex:d}=yield this.boomCore.getUsersList(e,r,t,i),u=[];return n.forEach((e=>{const t=this.toBMUser(e);u.push(t)})),i&&(null===(s=this.room)||void 0===s?void 0:s.roomInfo.totalWaitRoomUserWatcher.value)!==a&&(null===(o=this.room)||void 0===o||o.roomInfo.totalWaitRoomUserWatcher.next(a)),{userList:u,total:a,pageIndex:d}}))}getTotalUserNumber(){return __awaiter(this,void 0,void 0,(function*(){const e=()=>__awaiter(this,void 0,void 0,(function*(){const{total:e}=yield this.boomCore.getUsers(0,"",1);return e})),t=r=>{e().then((e=>{r(e)})).catch((e=>{error$1("getTotalUserNumber error","","",[JSON.stringify(e)]),t(r)}))};return new Promise(((e,r)=>__awaiter(this,void 0,void 0,(function*(){t(e)}))))}))}clearUsers(){this.userList.clear(),this.commonUserList.clear(),this.audiencesList.clear(),this.signalList.clear()}searchUsers(e,t){return __awaiter(this,void 0,void 0,(function*(){try{const{users:r}=yield this.boomCore.searchUsers(e,t,!1);let i=[],s=[];return r.forEach((e=>{const t=this.userList.get(e.userId);if(t)return void i.push(t);const r=this.commonUserList.get(e.userId);r&&s.push(r)})),{userList:i,commonUserList:s}}catch(e){return Promise.reject(new BoomError(LOCAL_ERROR,"boomCore.searchUsers发生错误:"+(null==e?void 0:e.message)))}}))}searchWaitRoomUsers(e,t){return __awaiter(this,void 0,void 0,(function*(){try{const{users:r}=yield this.boomCore.searchUsers(e,t,!0),i=[];return r.forEach((e=>{const t=this.toBMUser(e);i.push(t)})),i}catch(e){return Promise.reject(new BoomError(LOCAL_ERROR,"search wait room users error"))}}))}}class BMMessageInfo{constructor(e){this.isMeetingNotice=!1,this.userId=e.userId,this.message=e.message,this.role=e.role,this.isLocal=e.isLocal,this.avatar=e.avatar,this.nickName=e.nickName,this.to=e.to,this.isDanger=e.isDanger,this.seq=e.seq,this.failed=e.failed;let t=!1;e.isMeetingNotice&&(t=!0),this.isMeetingNotice=t,e.sendTime?(this.timeStamp=e.sendTime,this.time=handleTime(this.timeStamp)):(this.timeStamp=(new Date).getTime(),this.time=handleTime(this.timeStamp))}}function isShareStream(e){const t=e.getStreamId();return e.getUserId().toString().endsWith(STREAM_SUFFIX_SCREEN)||t.startsWith(MOBILE_STREAM_SUFFIX_SCREEN)||e.getType&&"assist"===e.getType()}function checkStreamIsNormal(e){var t,r,i,s;if(e&&!e.isLocal){(e.isDisplay&&e.videoEnable&&(null===(t=e.stream)||void 0===t?void 0:t.getVideoOn())&&!(null===(r=e.stream)||void 0===r?void 0:r.getVideoTrack())||e.audioEnable&&!(null===(s=null===(i=e.stream)||void 0===i?void 0:i.isSubscribed)||void 0===s?void 0:s.call(i)))&&setTimeout((()=>{var t,r,i,s;(e.isDisplay&&e.videoEnable&&(null===(t=e.stream)||void 0===t?void 0:t.getVideoOn())&&!(null===(r=e.stream)||void 0===r?void 0:r.getVideoTrack())||e.audioEnable&&!(null===(s=null===(i=e.stream)||void 0===i?void 0:i.isSubscribed)||void 0===s?void 0:s.call(i)))&&(warn("用户流检测,但是流订阅出现了问题,需要重新订阅","用户流检测",e.userId,[" nickname => ",e.nickname,"isDisplay =>",e.isDisplay]),e.hasPulled=!1,e.pulledStreamType="small",e.sendMessage2Room())}),2e3)}}function handleBloudReconnectStreamEvent(e){var t,r;const i=e.getLocalStreamModel();if(i&&!(null==i?void 0:i.stream))e.bloudStream&&(info("brtc 已经没有流了,bloud 的流要取消掉"),e.bloudStream.unpublish(),i.updateBloudStream(void 0,e),e.bloudStream=null);else if(i&&i.stream){info("brtc 流已经重推上去了,bloud要重新发推流的逻辑");const t=i.stream.getAudioOn(),r=i.stream.getVideoOn();e.publishBloudStream(t,r).then((()=>{info("brtc stream repub success bloud repub success, notify reconnect success"),e.localStreamConnectErrorWatcher.next(Rr$1(t,r))}))}if(e.localIsShare){info("brtc has share stream, and bloud need to republish share stream");const i=null===(t=e.room)||void 0===t?void 0:t.boomCore.shareScreenStream;if(i){const t=i.getAudioOn(),s=i.getVideoOn();try{null===(r=e.room)||void 0===r||r.boomCore.createAndPubBloudShareStream(t,s)}catch(e){error$1("bloud 共享屏幕流,断网重连重推流失败")}}}}const handleReconnectedStream=debounce((e=>{if(e.networkState.bloud&&e.networkState.brtc)try{e.streamQueue.restart()}catch(t){e.streamQueue.setQueueProcessor(e.queueProcessor),e.streamQueue.restart()}}),300);function handleStreamPublished(e,t,r,i){const s=e.stream;if(info("本地推流","本地推流",s.getUserId()),s){const e=t.getLocalStreamModel();if(e&&t.updateStreamModel(e,s),i[dt$1.STREAM_PUBLISHED].next({published:!0,model:e}),1===r.conferenceMode){r.getLocalParticipant().isAudience&&t.getStreamModels().forEach((e=>{e.sendMessage2Room()}))}}else i[dt$1.STREAM_PUBLISHED].next({published:!1})}function handleBloudStreamPublished(e,t,r){info("bloud publish stream"),handleBloudStreamPubAUpdate(e,t,!0),r[H$1.STREAM_PUBLISHED].next(e)}function handleBloudStreamPubAUpdate(e,t,r=!1){var i;info("bloud stream update","","",[JSON.stringify(e)]);const s=e.userId,o=e.isScreen,n=t.streamModels.get(s);if(n)if(o){t.shareBloudStateMap.set(s,e);const r={id:s,isWeb:n.isWeb,isScreen:o};null===(i=t.room)||void 0===i||i.addUser2Queue(r)}else n.updateBloudStream(e,t,r),n.getUser().updateSortNum();else error$1("bloud stream update, but can not get streamModel","",s)}function handleBloudStreamUnPublished(e,t,r){info("bloud unpublish stream","","",[JSON.stringify(e)]),handleBloudStreamUnpublish(e,t),r[H$1.STREAM_REMOVED].next(e)}function handleBloudStreamUpdated(e,t,r){info("bloud stream update","","",[JSON.stringify(e)]);const i=e.streamId,s=e.userId,o=e.params.customInfo;let n;n=i.includes("_screen")?t.shareStreamModels.get(s):t.streamModels.get(s),n?n.updateBloudCustomInfo(o):error$1("bloud stream update, but can not get streamModel","",s,["streamId =>",i]),r[H$1.UPDATE_STREAM].next(e)}function handleBloudStreamUnpublish(e,t){var r,i,s;const o=e.userId;if(e.isScreen){const e=t.shareStreamModels.get(o);if(e){const r=e.stream;r?(r.destroy(),t.remoteStreamUnpublished(r)):t.removeShareStreamModelByUId(o);const i={id:o,isWeb:e.isWeb,isScreen:!0};null===(s=t.room)||void 0===s||s.streamQueue.removeUsers([i])}}else{const e=t.streamModels.get(o);if(e){e.updateBloudStream(void 0,t);const s=e.stream;s&&(null===(r=t.room.audioPlayer)||void 0===r||r.removeStream(s),t.remoteStreamUnpublished(s),s.destroy());const n={id:o,isWeb:e.isWeb,isScreen:!1};null===(i=t.room)||void 0===i||i.streamQueue.removeUsers([n])}}}function handleShareStreamFailed(e,t){setTimeout((()=>__awaiter(this,void 0,void 0,(function*(){info("handle republish share stream");try{const r=e.boomCore.shareScreenStream;if(r){const i=r.getAudioOn(),s=r.getVideoOn();yield e.boomCore.shareBrtcClient.publish(r),e.boomCore.createAndPubBloudShareStream(i,s),info("handle republish share stream success"),t.localShareError.next(Or$1())}else warn("no share stream exist, unpublish share stream, to prevent share stream state error"),t.toggleShareScreen(!1,void 0)}catch(e){error$1("handle republish share stream failed , now unpublish"),t.localShareError.next(Ar()),yield t.toggleShareScreen(!1,void 0)}}))),1e3)}function setupRoomInfo(e,t,r){const i=e.permission,s=e.total;i&&r.updateLocalUserPermission(i),t.isInWaitRoom=e.joinwait;const o=e.waitroom;t.roomInfo.isOpenWaitRoom.next(o),t.roomInfo.totalUserWatcher.next(s);const n=e.audiooff,a=e.selfopenaudio;n===t.roomInfo.audioOff&&a===t.roomInfo.selfopenaudio||null!=n&&null!=a&&t.roomInfo.setAudioOff(n,a)}function handleRoomConnected(e,t,r,i,s=!0){var o;return __awaiter(this,void 0,void 0,(function*(){info("room-connected",t.getLocalParticipant().userId,"room-connected",["roomId =>",t.roomInfo.roomID," local permission => ",e.permission]),t.forceId=null===(o=e.customStats.forceOn)||void 0===o?void 0:o.user,handleInitRoomInfo(e,t),setupRoomInfo(e,t,r),s&&i[H$1.ROOM_CONNECTED].next(e)}))}function handleInitJoinRoomUsers(e){return __awaiter(this,void 0,void 0,(function*(){info("join ready init users"),e.isInWaitRoom||(e.forceId&&(yield e.getForceUser(e.forceId)),yield e.userVM.initUsers())}))}function handleRoomUpdated(e,t){info("update-stats "," ","",["options => ",JSON.stringify(e.options)]),e.options&&"audiooff"==e.options[0]||"selfopenaudio"==e.options[1]?t.roomInfo.setAudioOff(e.room.audiooff,e.room.selfopenaudio):e.options&&"lock"==e.options[0]?t.roomInfo.setlock(e.room.lock):e.options&&"waitroom"==e.options[0]&&t.roomInfo.isOpenWaitRoom.next(e.stats.waitroom)}function handleInitRoomInfo(e,t){t.roomInfo.msgSeq=e.msgSeq,e.customStats&&t.roomInfo.initCustomStats(e.customStats)}function exitUserUpdateStream(e,t,r,i,s){var o;e.updateUser(t,r);const n=r.stream,a=i.streamModels.get(t.userId);if(a||error$1("bmUserVM中存在该用户,但是bmStreamModelVM中不存在该用户,佛了"),!n.size){(null==a?void 0:a.bloudStream)&&(a.updateBloudStream(void 0,i),s.streamQueue.removeUsers([{id:t.userId,isScreen:!1},{id:t.userId,isScreen:!0}]));const e=i.shareStreamModels.get(t.userId);if(e&&!e.isLocal){try{null===(o=e.stream)||void 0===o||o.destroy()}catch(e){}i.removeShareStreamModel(e)}}n.get(`${t.userId}_screen`)&&s.addUser2Queue({id:t.userId,isScreen:!0,isWeb:t.isWeb});const d=n.get(t.userId);d&&(null==a||a.updateBloudStream({audio:d.audio_enable,video:d.video_enable,isScreen:!1},i))}function addUsers(e,t,r,i){e.isSingleColumns?t.commonUserList.forEach((s=>{const o=r.get(s.userId);if(o)return r.delete(s.userId),void exitUserUpdateStream(t,s,o,i,e);t.commonUserList.delete(s.userId),i.streamModels.delete(s.userId),i.shareStreamModels.delete(s.userId)})):t.userList.forEach((s=>{const o=r.get(s.userId);if(o)return exitUserUpdateStream(t,s,o,i,e),void(s.isCommonUser?t.userList.delete(s.userId):r.delete(s.userId));t.userList.delete(s.userId),i.streamModels.delete(s.userId),i.shareStreamModels.delete(s.userId)})),e.userVM.addBcUsersMap(r)}function handleRoomSync(e,t,r,i){return __awaiter(this,void 0,void 0,(function*(){const s=t.getLocalParticipant().userId,{users:o}=yield t.boomCore.queryUsers([s]),n=o.get(s);n&&r.updateUser(r.localUser,n);const a=t.getLocalParticipant().isCommonUser;if(t.isBig&&a){const{users:e}=yield t.boomCore.getUsersList(0,PERMISSION_NOT_COMMON,500);addUsers(t,r,e,i)}else{const e=(yield t.userVM.getTotalUserNumber())/BLOUD_PAGE_SIZE;let s=new Map;for(let r=0;r<e;r++){let{users:e}=yield t.boomCore.getUsers(r-1,"",BLOUD_PAGE_SIZE);e.forEach((e=>{s.set(e.userId,e)}))}addUsers(t,r,s,i)}handleInitRoomInfo(e,t),t.userVM.updateAllSort(),t.bmStreamVm.updateModelSort()}))}function handleBrtcRoomReconnecting(e,t,r){info("brtc room reconnecting"),t.networkState.brtc=!1,t.streamWSReconnectWatcher.next(!1),r[dt$1.BRTC_ROOM_ROCONNECTING].next(e)}function handleBrtcRoomReconnected(e,t,r){info("brtc room reconnected"),t.networkState.brtc=!0,handleReconnectedStream(t),r[dt$1.BRTC_ROOM_RECONNECTED].next(e)}function handleBloudRoomReconnecting(e,t,r){info("bloud room reconnecting"),t.networkState.bloud=!1,t.bloudWSReconnectWatcher.next(!1),r[H$1.RECONNECTING].next(e)}function handleBloudRoomReconnected(e,t,r){return __awaiter(this,void 0,void 0,(function*(){t.hasSyncPermission?(info("bloud room reconnected"),t.bloudWSReconnectWatcher.next(!1),r[H$1.MOVE_USER_ROOM].next(null),yield t.syncRoom().then((()=>{t.hasSyncPermission=!0,r[H$1.ROOM_CONNECTED].next(e)})).catch((e=>{error$1("sync room error",JSON.stringify(e));if(43===e.code)return t.hasSyncPermission=!1,void r[H$1.USER_REJOINED].next(e);t.hasSyncPermission=!1,r[H$1.TIMEOUT].next(e)}))):r[H$1.TIMEOUT].next(e)}))}function handleBloudRoomSync(e,t,r,i,s){return __awaiter(this,void 0,void 0,(function*(){info("bloud sync room completed"),setupRoomInfo(e,r,t),yield handleRoomSync(e,r,t,i),handleBloudReconnectStreamEvent(i),r.networkState.bloud=!0,handleReconnectedStream(r),r.bloudWSReconnectWatcher.next(!0),s[H$1.ROOM_SYNCED].next(e)}))}const{USER_REJOINED:USER_REJOINED,PARTICIPANT_JOINED:PARTICIPANT_JOINED,CHANGE_MASTER:CHANGE_MASTER,EVICTED:EVICTED,UPDATE_USER:UPDATE_USER,PARTICIPANT_LEFT:PARTICIPANT_LEFT,CUSTOM_MESSAGE:CUSTOM_MESSAGE,MOVE_USER_ROOM:MOVE_USER_ROOM}=H$1;function handleParticipantJoin(e,t,r,i,s,o){var n,a,d,u,l,c,h,m,p,f,v,g,S;const b=null===(a=null===(n=null==e?void 0:e.participant)||void 0===n?void 0:n.params)||void 0===a?void 0:a.info.sync,y=e.mode;info("用户入会","用户入会",e.user.userId,["sync => ",b,"mode =>",y]);const _=t.room.isBig&&r.streamModels.size>1e3;let E=!1;if(b){let r=t.userList.get(e.user.userId);if(r||(r=t.commonUserList.get(e.user.userId)),r)return void(r.inBackground!=!!(null===(u=null===(d=e.user)||void 0===d?void 0:d.customInfo)||void 0===u?void 0:u.inBackground)&&(r.inBackground=!!(null===(c=null===(l=e.user)||void 0===l?void 0:l.customInfo)||void 0===c?void 0:c.inBackground),r.watcher.next({operation:"inBackground",user:r})))}1===y&&(null===(h=t.room)||void 0===h?void 0:h.isBig)&&(t.commonUserList.delete(e.user.userId),r.streamModels.delete(e.user.userId));if(getIsCommonUser(e.user.permission.permission)){t.userList.get(e.user.userId)&&(t.userList.delete(e.user.userId),r.streamModels.delete(e.user.userId),E=!0)}else{const i=t.commonUserList.get(e.user.userId);(null===(m=t.room)||void 0===m?void 0:m.isSingleColumns)||i&&(t.commonUserList.delete(e.user.userId),r.streamModels.delete(e.user.userId),E=!0)}let M=t.addBCUser(e.user);if(M){M.inBackground!=!!(null===(f=null===(p=e.user)||void 0===p?void 0:p.customInfo)||void 0===f?void 0:f.inBackground)&&(M.inBackground=!!(null===(g=null===(v=e.user)||void 0===v?void 0:v.customInfo)||void 0===g?void 0:g.inBackground),M.watcher.next({operation:"inBackground",user:M}));let n=!1;if(ignoreUserId.forEach((e=>{(null==M?void 0:M.userId.includes(e))&&(n=!0)})),E?t.updateAllSort():(null===(S=t.room)||void 0===S?void 0:S.isSingleColumns)?t.updateCommonUserSort():M?M.isCommonUser?_?t.updateDelayCommonUserSort():t.updateCommonUserSort():t.updateUserSort():t.updateAllSort(),r.updateModelSort(),!n){if(1!==e.mode){const e=new BMMessageInfo({isMeetingNotice:!0,userId:M.userId,message:M.nickName+"加入"+(2==i.roomType?"直播":"会议")});s.addMessage(e,!0)}o[PARTICIPANT_JOINED].next({user:M,mode:y,data:e})}}}function handleLeaveUsers(e,t,r,i,s,o,n){var a;const d=e.userIds;info("bloud leave users","","",["userIds =>",d]),d.length&&(d.forEach((e=>{const a=leaveUser(e,t,r,s);a&&sendLeveNotification(a,o,n,i,!0,0)})),(null===(a=t.room)||void 0===a?void 0:a.isSingleColumns)?t.updateCommonUserSort():t.updateAllSort(),s.updateModelSort())}function handleParticipantLeft(e,t,r,i,s,o,n){var a;info(`bloud participant left ===>${e.userId}, ${e.mode}`);const d=1===e.mode,u=e.userId,l=r.isBig&&s.streamModels.size>1e3;if(u){const c=leaveUser(u,t,r,s);if((null===(a=t.room)||void 0===a?void 0:a.isSingleColumns)?t.updateCommonUserSort():c?c.isCommonUser?l?t.updateDelayCommonUserSort():t.updateCommonUserSort():t.updateUserSort():t.updateAllSort(),s.updateModelSort(),d)return void i[PARTICIPANT_LEFT].next({user:c,mode:e.mode,data:e});c&&sendLeveNotification(c,o,n,i,1!==e.mode,e.mode)}else warn("participant-left触发=======>但是该用户信息不存在",LOGGER_TAG_CLIENT,null,[e.userId]),i[PARTICIPANT_LEFT].next({user:e.userId,mode:e.mode,data:e})}function sendLeveNotification(e,t,r,i,s,o){let n=!1;if(ignoreUserId.forEach((t=>{(null==e?void 0:e.userId.includes(t))&&(n=!0)})),!n){if(s){const i=new BMMessageInfo({isMeetingNotice:!0,userId:e.userId,message:(null==e?void 0:e.nickName)+"离开"+(2==t.roomType?"直播":"会议")});r.addMessage(i,!0)}i[PARTICIPANT_LEFT].next({user:e,mode:o})}}function leaveUser(e,t,r,i){const s=t.getUser(e);return t.removeUser(e),r.streamQueue.removeUsers([{id:e,isScreen:!1},{id:e,isScreen:!0}]),i.removeStreamModelByUId(e),i.removeShareStreamModelByUId(e),r.roomInfo.removeRaiseHandUser(e),r.roomInfo.removeVideoRaiseHandUser(e),r.roomInfo.removeSimpleRaiseHandUser(e),i.shareBloudStateMap.delete(e),s}function handleChangeMaster(e,t,r,i,s){info("changeMaster =>","changeMaster","",["master: => ",e.master,"oldMaster =>",e.oldMaster]);const o=e.master,n=e.oldMaster,a=e.isKeep;if(o){let d=t.updateMaster(o,n,a);d.master&&(d.master.watcher.next({operation:"getMaster",user:d.master}),r.userVM.masterUserWatcher.next(d.master)),d.oldMaster&&(d.oldMaster.watcher.next({operation:"removeMaster",user:d.oldMaster}),a&&d.oldMaster.watcher.next({operation:"getManager",user:d.oldMaster}));const u=s.getStreamModelByUId(n),l=s.getStreamModelByUId(o);null==u||u.updateSortNum(),null==l||l.updateSortNum(),i[CHANGE_MASTER].next({master:d.master,oldMaster:d.oldMaster,data:e})}else warn("change-master触发=======>但是房间内找不到master",LOGGER_TAG_CLIENT,null,o),i[CHANGE_MASTER].next(null)}function handleEvict(e,t,r,i,s){var o;const n=e.userId,a=t.getUser(n);info("踢出用户 => ","evict ",null==a?void 0:a.userId,["nickname => ",null==a?void 0:a.nickName]);const d=leaveUser(n,t,i,r);(null===(o=t.room)||void 0===o?void 0:o.isSingleColumns)?t.updateCommonUserSort():d?d.isCommonUser?t.updateCommonUserSort():t.updateUserSort():t.updateAllSort(),r.updateModelSort(),s[EVICTED].next(e)}function handleUpdateUser(e,t,r,i,s){var o,n;if(info("用户信息被改变","",null===(o=e.user)||void 0===o?void 0:o.userId),null===(n=e.user)||void 0===n?void 0:n.userId){let o=t.getUser(e.user.userId),n=i.getStreamModelByUId(e.user.userId);o?o.updateUserInfo(e.user,e.participant,r):console.warn("participant-update: bmUser is null"),n&&n.updateSortNum(!0),s[UPDATE_USER].next({bmUser:o,params:e.participant.params})}}const handleUserRejoined=debounce(((e,t)=>{e[USER_REJOINED].next(t)}),1e3);function handleMoveUserRoom(e,t,r,i){return __awaiter(this,void 0,void 0,(function*(){info("bloud move user room","","",[r]);const s=r.toWait;if(e.isInWaitRoom=s,s){e.handleResetOtherStreamStatus(),t.userList.clear(),t.userListWatcher.next([]),t.commonUserList.clear(),t.commonUserListWatcher.next([]),t.getForceUserWatcher.next(!1),e.bmStreamVm.streamModels.clear(),e.bmStreamVm.clearDetector(),e.bmStreamVm.speakerWatcher.next(null),i[CUSTOM_MESSAGE].next(null),e.messageWatcher.next({type:MessageType.INIT,status:!1,isNotCancelRootReport:!1}),e.audioPlayer.destroy();const r=e.bmStreamVm.localModel;r&&e.bmStreamVm.streamModels.set(r.userId,r),e.bmStreamVm.streamModelsWatcher.next([]),e.bmStreamVm.shareStreamModels.clear(),e.bmStreamVm.shareStreamModelsWatcher.next([]),e.roomInfo.raiseHandsWatcher.next([]),e.roomInfo.raiseVideoHandsWatcher.next([]),e.roomInfo.raiseSimpleHandsWatcher.next([]),i[MOVE_USER_ROOM].next(s),Object.values(e.observes).forEach((e=>{e.next(null)}))}else{const{audiooff:o,selfopenaudio:n,lock:a}=r.info;a!==e.roomInfo.lock&&e.roomInfo.setlock(a),o===e.roomInfo.audioOff&&n===e.roomInfo.selfopenaudio||e.roomInfo.setAudioOff(o,n),yield handleRoomConnected(r.info,e,t,i,!0),yield handleInitJoinRoomUsers(e),i[MOVE_USER_ROOM].next(s)}}))}function handleSendMessage(e,t,r,i){var s,o,n,a,d,u,l,c,h;let m=Object.assign({},e);if(m.message){if(m.message="string"==typeof m.message?JSON.parse(m.message):m.message,info("new-message","","",[" method => ",m.message.method]),"send-talk"===m.message.method){const i=m.user===(null===(s=t.getLocalUser())||void 0===s?void 0:s.userId),p=(null===(n=null===(o=m.message)||void 0===o?void 0:o.params)||void 0===n?void 0:n.status)||"",f=null===(u=null===(d=null===(a=m.message)||void 0===a?void 0:a.params)||void 0===d?void 0:d.stream)||void 0===u?void 0:u.avatar,v=e.seq,g=new BMMessageInfo({userId:m.user,message:p,isLocal:i,avatar:f,to:m.to,seq:v,nickName:null===(h=null===(c=null===(l=m.message)||void 0===l?void 0:l.params)||void 0===c?void 0:c.stream)||void 0===h?void 0:h.nickname,sendTime:(new Date).getTime()});r.addMessage(g,!1)}i[H$1.SEND_MESSAGE].next(m)}}function handleCustomMessage(e,t,r){var i,s,o,n,a,d,u,l,c,h,m,p,f;let v=Object.assign({},e);if(v.message)if(v.message="string"==typeof v.message?JSON.parse(v.message):v.message,info("custom-message","","",[" method => ",v.message.method]),"video-force-change"==v.message.method){const e="enabled"==v.message.params.status;info(`远端控制本地摄像头: ${e}`),t.messageWatcher.next({type:MessageType.VIDEO_FORCE_CHANGE,status:e,fromUserId:v.user})}else if("audio-force-change"==v.message.method){let e;e="checkUserAudio"==v.message.params.status?v.message.params.status:"enabled"==v.message.params.status,info(`远端控制本地麦克风: ${e}`),t.messageWatcher.next({type:MessageType.AUDIO_FORCE_CHANGE,status:e,fromUserId:v.user,isNotCancelRootReport:null===(i=v.message.params)||void 0===i?void 0:i.isNotCancelRootReport})}else if("raise-hands"===v.message.method)t.raiseHandleRespWatcher.next(v.message.params);else if("give-like"===v.message.method)null===(s=t.roomVM)||void 0===s||s.giveLikeList.push({userId:v.user,nickName:null===(a=null===(n=null===(o=v.message)||void 0===o?void 0:o.params)||void 0===n?void 0:n.stream)||void 0===a?void 0:a.nickname,time:(new Date).getTime(),type:null===(l=null===(u=null===(d=v.message)||void 0===d?void 0:d.params)||void 0===u?void 0:u.stream)||void 0===l?void 0:l.type}),null===(c=t.roomVM)||void 0===c||c.giveLikeListWatcher.next(null===(h=t.roomVM)||void 0===h?void 0:h.giveLikeList);else if("resp-to-check-devices"===v.message.method)(null===(m=v.message)||void 0===m?void 0:m.params)&&(v.message.params.fromUserId=v.user),r[H$1.CUSTOM_MESSAGE].next(v);else if("usercount"===v.message.method){if(v.message.params){let e=null===(f=null===(p=v.message)||void 0===p?void 0:p.params)||void 0===f?void 0:f.total;e?(e=Number(e),e<0&&(warn("服务返回的usercount为负数,"+e),e=0)):(warn("服务未返回usercount,"+e),e=0),t.roomInfo.totalUserWatcher.next(e)}}else if("waitusercount"===v.message.method){if(v.message.params){const e=v.message.params.total;t.roomInfo.totalWaitRoomUserWatcher.next(e)}}else r[H$1.CUSTOM_MESSAGE].next(v)}let reconnectFailed=0,shareReconnectFailed=0;const NETWORK_ERROR_QUEUE=new Set;function handleBRTCRoomError(e,t,r,i,s){return __awaiter(this,void 0,void 0,(function*(){error$1("brtc error","brtc error","",[(new Date).toLocaleTimeString(),JSON.stringify(e),e.getCode()]);if(4002===e.getCode()){t.BRTCConnectFailed=!0,t.networkState.brtc=!1,warn("brtc 信令通道错误,需要重新走入会","brtc error",""),t.streamWSReconnectWatcher.next(!1);try{yield r.brtcClient.leave("room_close")}catch(e){error$1("brtc 离会失败")}setTimeout((()=>__awaiter(this,void 0,void 0,(function*(){t.handleResetOtherStreamStatus(),yield reconnectBrtcWS(r,t,s,e).catch((t=>{info("brtc断网重连失败, 处理一下退会逻辑","","",[JSON.stringify(t)]),s[dt$1.ERROR].next(e)}))}))),1e3)}else s[dt$1.ERROR].next(e)}))}function reconnectBrtcWS(e,t,r,i){return __awaiter(this,void 0,void 0,(function*(){return new Promise(((s,o)=>{setTimeout((()=>{info("brtc重连"),e.brtcClient.join(e.roomId,e.userId,e.brtcSig).then((()=>__awaiter(this,void 0,void 0,(function*(){info("brtc断网重连成功, 重新处理拉流和推流"),t.networkState.brtc=!0,setTimeout((()=>{t.brtcNetEnableWatcher.next(!0)}),2e3),handleReconnectedStream(t),t.BRTCConnectFailed=!1,reconnectFailed=0,yield t.handleRePushSelf(),t.streamWSReconnectWatcher.next(!0),s(!0)})))).catch((s=>{const n=s.getCode();info("断网重连入会失败","","",[s,n]),reconnectFailed<=10?(reconnectFailed+=1,e.brtcClient.isJoinning=!1,setTimeout((()=>{reconnectBrtcWS(e,t,r,i)}),2e3)):(error$1("brtc断网重连失败,处理一下退会"),reconnectFailed=0,r[dt$1.ERROR].next(i),o(!1))}))}),7e3)}))}))}function reconnectBRTCShareWS(e){return __awaiter(this,void 0,void 0,(function*(){return new Promise(((t,r)=>{setTimeout((()=>{info("共享屏幕重连"),e.shareBrtcClient.join(e.roomId,e.userId,e.brtcSig).then((()=>{shareReconnectFailed=0,t(!0)})).catch((t=>{const r=t.getCode();if(info("共享屏幕断网重连入会失败","","",[t,r]),!(shareReconnectFailed<=3))throw error$1("共享屏幕用户重连失败,处理一下取消共享屏幕"),shareReconnectFailed=0,new Error("共享屏幕重连失败");shareReconnectFailed+=1,reconnectBRTCShareWS(e)}))}),7e3)}))}))}function handleBloudError(e,t,r,i,s){return __awaiter(this,void 0,void 0,(function*(){error$1("network-error","network-error","local-client",["本地链接出现问题","netconnectiong => ",e.netConnecting]),e.netConnecting?yield handleBloudRoomReconnected(i,e,s):s[H$1.TIMEOUT].next(i)}))}function handleCustomStats(e,t,r){let i=null==e?void 0:e.updateKeys;info("update-custom-stats"," "," ",["updateKeys => ",JSON.stringify(i)]),((null==i?void 0:i.includes("chatNotice"))||(null==i?void 0:i.includes("chatNoticeRich"))||(null==i?void 0:i.includes("fileUpdateLook"))||(null==i?void 0:i.includes("fileUpdateDown"))||(null==i?void 0:i.includes("fileUpdateEdit"))||(null==i?void 0:i.includes("fileUpdateModel"))||(null==i?void 0:i.includes("screenShareModel"))||(null==i?void 0:i.includes("onlyOnePersonShare"))||(null==i?void 0:i.includes("chatEnable"))||(null==i?void 0:i.includes("giveLikeEnable"))||(null==i?void 0:i.includes("cloudRecord"))||(null==i?void 0:i.includes("joinAudioEnable"))||(null==i?void 0:i.includes("joinVideoEnable"))||(null==i?void 0:i.includes("userListEnable"))||(null==i?void 0:i.includes("audioEnable"))||(null==i?void 0:i.includes("videoEnable"))||(null==i?void 0:i.includes("modifyNameEnable"))||(null==i?void 0:i.includes("backgroundAIEnable"))||(null==i?void 0:i.includes("recordEnable"))||(null==i?void 0:i.includes("joinMicrophoneDisable"))||(null==i?void 0:i.includes("joinCameraDisable"))||(null==i?void 0:i.includes("raiseHandEnable"))||(null==i?void 0:i.includes("forceOpenUserMic"))||(null==i?void 0:i.includes("forceOpenUserCamera"))||(null==i?void 0:i.includes("joinCueVoice")))&&t.roomInfo.updateOperationPermission(e.customStats),((null==i?void 0:i.includes("chatNotice"))||(null==i?void 0:i.includes("chatNoticeRich")))&&t.roomInfo.chatNoticeWatcher.next(e),r[H$1.UPDATE_CUSTOM_STATS].next(e)}var dist={},eventemitter3={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function i(){}function s(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,i,o,n){if("function"!=typeof i)throw new TypeError("The listener must be a function");var a=new s(i,o||e,n),d=r?r+t:t;return e._events[d]?e._events[d].fn?e._events[d]=[e._events[d],a]:e._events[d].push(a):(e._events[d]=a,e._eventsCount++),e}function n(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function a(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),a.prototype.eventNames=function(){var e,i,s=[];if(0===this._eventsCount)return s;for(i in e=this._events)t.call(e,i)&&s.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(e)):s},a.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var s=0,o=i.length,n=new Array(o);s<o;s++)n[s]=i[s].fn;return n},a.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},a.prototype.emit=function(e,t,i,s,o,n){var a=r?r+e:e;if(!this._events[a])return!1;var d,u,l=this._events[a],c=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),c){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,i),!0;case 4:return l.fn.call(l.context,t,i,s),!0;case 5:return l.fn.call(l.context,t,i,s,o),!0;case 6:return l.fn.call(l.context,t,i,s,o,n),!0}for(u=1,d=new Array(c-1);u<c;u++)d[u-1]=arguments[u];l.fn.apply(l.context,d)}else{var h,m=l.length;for(u=0;u<m;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),c){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,i);break;case 4:l[u].fn.call(l[u].context,t,i,s);break;default:if(!d)for(h=1,d=new Array(c-1);h<c;h++)d[h-1]=arguments[h];l[u].fn.apply(l[u].context,d)}}return!0},a.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},a.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},a.prototype.removeListener=function(e,t,i,s){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return n(this,o),this;var a=this._events[o];if(a.fn)a.fn!==t||s&&!a.once||i&&a.context!==i||n(this,o);else{for(var d=0,u=[],l=a.length;d<l;d++)(a[d].fn!==t||s&&!a[d].once||i&&a[d].context!==i)&&u.push(a[d]);u.length?this._events[o]=1===u.length?u[0]:u:n(this,o)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&n(this,t)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,e.exports=a}(eventemitter3);var pTimeout$1={exports:{}},pFinally$1=(e,t)=>(t=t||(()=>{}),e.then((e=>new Promise((e=>{e(t())})).then((()=>e))),(e=>new Promise((e=>{e(t())})).then((()=>{throw e})))));const pFinally=pFinally$1;class TimeoutError extends Error{constructor(e){super(e),this.name="TimeoutError"}}const pTimeout=(e,t,r)=>new Promise(((i,s)=>{if("number"!=typeof t||t<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(t===1/0)return void i(e);const o=setTimeout((()=>{if("function"==typeof r){try{i(r())}catch(e){s(e)}return}const o=r instanceof Error?r:new TimeoutError("string"==typeof r?r:`Promise timed out after ${t} milliseconds`);"function"==typeof e.cancel&&e.cancel(),s(o)}),t);pFinally(e.then(i,s),(()=>{clearTimeout(o)}))}));pTimeout$1.exports=pTimeout,pTimeout$1.exports.default=pTimeout,pTimeout$1.exports.TimeoutError=TimeoutError;var priorityQueue={},lowerBound$1={};function lowerBound(e,t,r){let i=0,s=e.length;for(;s>0;){const o=s/2|0;let n=i+o;r(e[n],t)<=0?(i=++n,s-=o+1):s=o}return i}Object.defineProperty(lowerBound$1,"__esModule",{value:!0}),lowerBound$1.default=lowerBound,Object.defineProperty(priorityQueue,"__esModule",{value:!0});const lower_bound_1=lowerBound$1;class PriorityQueue{constructor(){Object.defineProperty(this,"_queue",{enumerable:!0,configurable:!0,writable:!0,value:[]})}enqueue(e,t){const r={priority:(t=Object.assign({priority:0},t)).priority,run:e};if(this.size&&this._queue[this.size-1].priority>=t.priority)return void this._queue.push(r);const i=lower_bound_1.default(this._queue,r,((e,t)=>t.priority-e.priority));this._queue.splice(i,0,r)}dequeue(){const e=this._queue.shift();return null==e?void 0:e.run}filter(e){return this._queue.filter((t=>t.priority===e.priority)).map((e=>e.run))}get size(){return this._queue.length}}priorityQueue.default=PriorityQueue,Object.defineProperty(dist,"__esModule",{value:!0});const EventEmitter=eventemitter3.exports,p_timeout_1=pTimeout$1.exports,priority_queue_1=priorityQueue,empty=()=>{},timeoutError=new p_timeout_1.TimeoutError;class PQueue extends EventEmitter{constructor(e){var t,r,i,s;if(super(),Object.defineProperty(this,"_carryoverConcurrencyCount",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_isIntervalIgnored",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_intervalCount",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_intervalCap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_interval",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_intervalEnd",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_intervalId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_timeoutId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_queue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_queueClass",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pendingCount",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_concurrency",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_isPaused",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_resolveEmpty",{enumerable:!0,configurable:!0,writable:!0,value:empty}),Object.defineProperty(this,"_resolveIdle",{enumerable:!0,configurable:!0,writable:!0,value:empty}),Object.defineProperty(this,"_timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_throwOnTimeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),!("number"==typeof(e=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:priority_queue_1.default},e)).intervalCap&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${null!==(r=null===(t=e.intervalCap)||void 0===t?void 0:t.toString())&&void 0!==r?r:""}\` (${typeof e.intervalCap})`);if(void 0===e.interval||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${null!==(s=null===(i=e.interval)||void 0===i?void 0:i.toString())&&void 0!==s?s:""}\` (${typeof e.interval})`);this._carryoverConcurrencyCount=e.carryoverConcurrencyCount,this._isIntervalIgnored=e.intervalCap===1/0||0===e.interval,this._intervalCap=e.intervalCap,this._interval=e.interval,this._queue=new e.queueClass,this._queueClass=e.queueClass,this.concurrency=e.concurrency,this._timeout=e.timeout,this._throwOnTimeout=!0===e.throwOnTimeout,this._isPaused=!1===e.autoStart}get _doesIntervalAllowAnother(){return this._isIntervalIgnored||this._intervalCount<this._intervalCap}get _doesConcurrentAllowAnother(){return this._pendingCount<this._concurrency}_next(){this._pendingCount--,this._tryToStartAnother()}_resolvePromises(){this._resolveEmpty(),this._resolveEmpty=empty,0===this._pendingCount&&(this._resolveIdle(),this._resolveIdle=empty)}_onResumeInterval(){this._onInterval(),this._initializeIntervalIfNeeded(),this._timeoutId=void 0}_isIntervalPaused(){const e=Date.now();if(void 0===this._intervalId){const t=this._intervalEnd-e;if(!(t<0))return void 0===this._timeoutId&&(this._timeoutId=setTimeout((()=>{this._onResumeInterval()}),t)),!0;this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0}return!1}_tryToStartAnother(){if(0===this._queue.size)return this._intervalId&&clearInterval(this._intervalId),this._intervalId=void 0,this._resolvePromises(),!1;if(!this._isPaused){const e=!this._isIntervalPaused();if(this._doesIntervalAllowAnother&&this._doesConcurrentAllowAnother)return this.emit("active"),this._queue.dequeue()(),e&&this._initializeIntervalIfNeeded(),!0}return!1}_initializeIntervalIfNeeded(){this._isIntervalIgnored||void 0!==this._intervalId||(this._intervalId=setInterval((()=>{this._onInterval()}),this._interval),this._intervalEnd=Date.now()+this._interval)}_onInterval(){0===this._intervalCount&&0===this._pendingCount&&this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0,this._processQueue()}_processQueue(){for(;this._tryToStartAnother(););}get concurrency(){return this._concurrency}set concurrency(e){if(!("number"==typeof e&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this._concurrency=e,this._processQueue()}async add(e,t={},r=null){return new Promise(((i,s)=>{this._queue.enqueue((async()=>{this._pendingCount++,this._intervalCount++;try{const o=void 0===this._timeout&&void 0===t.timeout?e():p_timeout_1.default(Promise.resolve(e()),void 0===t.timeout?this._timeout:t.timeout,(()=>{(void 0===t.throwOnTimeout?this._throwOnTimeout:t.throwOnTimeout)&&s(timeoutError),r&&r("resolve-timeout")}));r&&r("resolving"),i(await o),this._isPaused?r&&r("resolve-paused"):r&&r("resolve")}catch(e){this._isPaused?r&&r("resolve-paused"):r&&r("resolve"),s(e)}this._next()}),t),this._tryToStartAnother()}))}async addAll(e,t){return Promise.all(e.map((async e=>this.add(e,t))))}start(){return this._isPaused?(this._isPaused=!1,this._processQueue(),this):this}pause(){this._isPaused=!0}clear(){this._queue=new this._queueClass}async onEmpty(){if(0!==this._queue.size)return new Promise((e=>{const t=this._resolveEmpty;this._resolveEmpty=()=>{t(),e()}}))}async onIdle(){if(0!==this._pendingCount||0!==this._queue.size)return new Promise((e=>{const t=this._resolveIdle;this._resolveIdle=()=>{t(),e()}}))}get size(){return this._queue.size}sizeBy(e){return this._queue.filter(e).length}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}get timeout(){return this._timeout}set timeout(e){this._timeout=e}}var _default=dist.default=PQueue;class Pqueue{constructor(e,t=!0){this.queue=new _default({concurrency:e,autoStart:t,carryoverConcurrencyCount:!0,timeout:3e3,completeAction:e=>{console.log("task complete",e)}}),this.queueArray=[],this.isTaskPending=t}addQueue(e,t,r=0,i=""){this.queue.isPaused&&this.queue.start();let s={};s.taskID=t,s.status="pending",this.queue.add(e,{priority:r,timeout:3e3},(e=>{if(s.status=e,"resolve"===s.status||"resolve-paused"===s.status||"resolve-timeout"===s.status){const e=this.queueArray.findIndex((e=>s.taskID===e.taskID));-1!==e&&this.queueArray.splice(e,1)}})),this.queueArray.push(s)}clearQueue(){this.queue.clear(),this.queueArray=[],this.queue.onEmpty().then((e=>{})),this.queue.onIdle().then((e=>{console.log("clearQueue全部完事")}))}startQueue(){this.queue.start()}pauseQueue(){return this.queue.pause(),console.log(`size:${this.size()}`),this.isTaskPending=!1,this.queue.onEmpty().then((e=>{})),this.queue.onIdle().then((e=>{})),this.queueArray}size(){return this.queue.size}pending(){return this.queue.pending}checkTaskStatus(){return this.isTaskPending}setTaskStatus(e){this.isTaskPending=e}onIdle(){return this.queue.onIdle()}onEmpty(){return this.queue.onEmpty()}}const streamPullQueue=new Pqueue(4),eventQueue=new Pqueue(10);var MessageType,PlayerState;function attachEvents(e,t,r,i,s){info("attachEvents init");let o={};e.on("toggle-screen-share",(()=>{error$1("share stream video track ended, now unpublish share stream"),r.localShareError.next(Ar()),r.toggleShareScreen(!1,void 0).then((()=>{}))})),e.on("client-banned",(()=>__awaiter(this,void 0,void 0,(function*(){yield s.boomCore.leaveShare()})))),e.on("share-brtc-error",(t=>__awaiter(this,void 0,void 0,(function*(){if(4002===t.getCode())try{info("brtc share client disconnected, reconnecting"),yield e.shareBrtcClient.leave("room_close"),reconnectBRTCShareWS(e).then((()=>__awaiter(this,void 0,void 0,(function*(){if(info("brtc share client reconnected, retry repub share stream"),yield sleep(1e3),e.shareScreenStream){const t=e.shareScreenStream.getAudioOn(),r=e.shareScreenStream.getVideoOn();e.shareBrtcClient.publish(e.shareScreenStream),e.createAndPubBloudShareStream(t,r)}})))).catch((e=>{throw new Error("共享屏幕重新入会失败")}))}catch(e){r.toggleShareScreen(!1,void 0).then((()=>{})).catch((e=>{error$1("共享发生错误退会失败","","",[JSON.stringify(e)])}))}}))));let n=[];return n=n.concat(Object.values(H$1)),n=n.concat(Object.values(dt$1)),n=n.concat(Object.values(Nt$1)),n.forEach((e=>{o[e]=new BehaviorSubject(null)})),n.forEach((n=>{switch(n){case dt$1.STREAM_PUBLISHED:e.on(dt$1.STREAM_PUBLISHED,(e=>{eventQueue.addQueue(handleStreamPublished.bind(null,e,r,s,o),dt$1.STREAM_PUBLISHED)}));break;case dt$1.BRTC_SYNC_ROOM_COMPLETED:e.on(dt$1.BRTC_SYNC_ROOM_COMPLETED,(e=>__awaiter(this,void 0,void 0,(function*(){eventQueue.addQueue(s.handleResetOtherStreamStatus.bind(s),dt$1.BRTC_SYNC_ROOM_COMPLETED)}))));break;case Nt$1.BRTC_SHARE_SYNC_ROOM_COMPLETED:e.on(Nt$1.BRTC_SHARE_SYNC_ROOM_COMPLETED,(()=>{info("brtc share client sync completed, retry publish share stream"),eventQueue.addQueue(handleShareStreamFailed.bind(null,s,r),Nt$1.BRTC_SHARE_SYNC_ROOM_COMPLETED)}));break;case dt$1.BRTC_ROOM_ROCONNECTING:e.on(dt$1.BRTC_ROOM_ROCONNECTING,(e=>{eventQueue.addQueue(handleBrtcRoomReconnecting.bind(null,e,s,o),dt$1.BRTC_ROOM_ROCONNECTING)}));break;case dt$1.BRTC_ROOM_RECONNECTED:e.on(dt$1.BRTC_ROOM_RECONNECTED,(e=>__awaiter(this,void 0,void 0,(function*(){eventQueue.addQueue(handleBrtcRoomReconnected.bind(null,e,s,o),dt$1.BRTC_ROOM_RECONNECTED)}))));break;case dt$1.CLIENT_BANNED:e.on(dt$1.CLIENT_BANNED,(e=>{info("brtc client banned"),handleUserRejoined(o,e)}));break;case dt$1.ERROR:e.on(dt$1.ERROR,(t=>__awaiter(this,void 0,void 0,(function*(){s.netConnecting?eventQueue.addQueue(handleBRTCRoomError.bind(null,t,s,e,r,o),dt$1.ERROR):NETWORK_ERROR_QUEUE.add(handleBRTCRoomError.bind(null,t,s,e,r,o))}))));break;case H$1.SYNC_FAILED:e.on(H$1.SYNC_FAILED,(e=>{error$1("bloud sync failed, leave room"),o[H$1.TIMEOUT].next(e)}));break;case H$1.ROOM_CONNECTED:e.on(H$1.ROOM_CONNECTED,(e=>__awaiter(this,void 0,void 0,(function*(){return handleRoomConnected(e,s,t,o)}))));break;case Nt$1.JOIN_READY:e.on(Nt$1.JOIN_READY,(()=>handleInitJoinRoomUsers(s)));break;case H$1.PARTICIPANT_JOINED:e.on(H$1.PARTICIPANT_JOINED,(n=>__awaiter(this,void 0,void 0,(function*(){s.isInWaitRoom||eventQueue.addQueue(handleParticipantJoin.bind(null,n,t,r,e,i,o),H$1.PARTICIPANT_JOINED)}))));break;case H$1.PARTICIPANT_LEFT:e.on(H$1.PARTICIPANT_LEFT,(n=>{s.isInWaitRoom||eventQueue.addQueue(handleParticipantLeft.bind(null,n,t,s,o,r,e,i),H$1.PARTICIPANT_LEFT)}));break;case H$1.LEAVE_USERS:e.on(H$1.LEAVE_USERS,(n=>eventQueue.addQueue(handleLeaveUsers.bind(null,n,t,s,o,r,e,i),H$1.LEAVE_USERS)));break;case H$1.CHANGE_MASTER:e.on(H$1.CHANGE_MASTER,(e=>{eventQueue.addQueue(handleChangeMaster.bind(null,e,t,s,o,r),H$1.CHANGE_MASTER)}));break;case H$1.SEND_MESSAGE:e.on(H$1.SEND_MESSAGE,(e=>{eventQueue.addQueue(handleSendMessage.bind(null,e,t,i,o),H$1.SEND_MESSAGE)}));break;case H$1.CUSTOM_MESSAGE:e.on(H$1.CUSTOM_MESSAGE,(e=>{eventQueue.addQueue(handleCustomMessage.bind(null,e,s,o),H$1.CUSTOM_MESSAGE)}));break;case H$1.EVICTED:e.on(H$1.EVICTED,(e=>__awaiter(this,void 0,void 0,(function*(){eventQueue.addQueue(handleEvict.bind(null,e,t,r,s,o),H$1.EVICTED)}))));break;case H$1.UPDATE_USER:e.on(H$1.UPDATE_USER,(e=>{eventQueue.addQueue(handleUpdateUser.bind(null,e,t,s,r,o),H$1.UPDATE_USER)}));break;case H$1.UPDATE_STATS:e.on(H$1.UPDATE_STATS,(e=>{eventQueue.addQueue(handleRoomUpdated.bind(null,e,s),H$1.UPDATE_STATS)}));break;case H$1.UPDATE_CUSTOM_STATS:e.on(H$1.UPDATE_CUSTOM_STATS,(e=>{eventQueue.addQueue(handleCustomStats.bind(null,e,s,o),H$1.UPDATE_CUSTOM_STATS)}));break;case H$1.TIMEOUT:e.on(H$1.TIMEOUT,(t=>{eventQueue.addQueue(handleBloudError.bind(null,s,e,r,t,o),H$1.TIMEOUT)}));break;case H$1.USER_REJOINED:e.on(H$1.USER_REJOINED,(e=>{info("bloud user rejoined"),handleUserRejoined(o,e)}));break;case H$1.RECONNECTING:e.on(H$1.RECONNECTING,(e=>{eventQueue.addQueue(handleBloudRoomReconnecting.bind(null,e,s,o),H$1.RECONNECTING)}));break;case H$1.RECONNECTED:e.on(H$1.RECONNECTED,(e=>__awaiter(this,void 0,void 0,(function*(){eventQueue.addQueue(handleBloudRoomReconnected.bind(null,e,s,o),H$1.RECONNECTED)}))));break;case H$1.ROOM_SYNCED:e.on(H$1.ROOM_SYNCED,(e=>__awaiter(this,void 0,void 0,(function*(){eventQueue.addQueue(handleBloudRoomSync.bind(null,e,t,s,r,o),H$1.ROOM_SYNCED)}))));break;case H$1.STREAM_PUBLISHED:e.on(H$1.STREAM_PUBLISHED,(e=>__awaiter(this,void 0,void 0,(function*(){eventQueue.addQueue(handleBloudStreamPublished.bind(null,e,r,o),H$1.STREAM_PUBLISHED)}))));break;case H$1.STREAM_REMOVED:e.on(H$1.STREAM_REMOVED,(e=>__awaiter(this,void 0,void 0,(function*(){eventQueue.addQueue(handleBloudStreamUnPublished.bind(null,e,r,o),H$1.STREAM_REMOVED)}))));break;case H$1.UPDATE_STREAM:e.on(H$1.UPDATE_STREAM,(e=>__awaiter(this,void 0,void 0,(function*(){eventQueue.addQueue(handleBloudStreamUpdated.bind(null,e,r,o),H$1.UPDATE_STREAM)}))));case H$1.STREAM_UPDATE:e.on(H$1.STREAM_UPDATE,(e=>__awaiter(this,void 0,void 0,(function*(){eventQueue.addQueue(handleBloudStreamPubAUpdate.bind(null,e,r),H$1.STREAM_UPDATE)}))));break;case H$1.MOVE_USER_ROOM:e.on(H$1.MOVE_USER_ROOM,(e=>__awaiter(this,void 0,void 0,(function*(){eventQueue.addQueue(handleMoveUserRoom.bind(null,s,t,e,o),H$1.MOVE_USER_ROOM)}))));break;default:e.on(n,(e=>o[n].next(e)))}})),o}!function(e){e.INIT="init",e.VIDEO_FORCE_CHANGE="video-force-change",e.AUDIO_FORCE_CHANGE="audio-force-change"}(MessageType||(MessageType={}));class BMRoomVM{constructor(e,t,r){this.room=null,this.tipQueueObj={},this.roomInfo=r,this.userVM=t,this.boomCore=e,this.giveLikeList=[],this.giveLikeListWatcher=new Subject}initWithRoom(e){this.room=e}evictUser(e,t){return __awaiter(this,void 0,void 0,(function*(){if(!e)return Promise.reject(Zn("未传递用户id"));if(!this.userVM.checkLocalHasMaster())return Promise.reject(Zn("只有主持人权限才能踢出用户"));if(this.userVM.checkIsMaster(e))return Promise.reject(Zn("主持人不能被踢出"));try{yield this.boomCore.evictUser(e,t)}catch(e){return Promise.reject(Zn(`踢出用户失败${JSON.stringify(e)}`))}}))}updateUser(e,t){return __awaiter(this,void 0,void 0,(function*(){return e?t?void(yield this.boomCore.updateUser(e,{customInfo:t}).catch((e=>Promise.reject(tr(`boomCore updateUser出错 ${JSON.stringify(e)}`))))):Promise.reject(tr("info为空,请写入要更新的信息")):Promise.reject(tr("未传递目标用户id"))}))}changeMaster(e,t){var r;return __awaiter(this,void 0,void 0,(function*(){if(!e)return Promise.reject(qn("未传递主持人id"));if(!this.userVM.checkLocalHasMaster()&&!(null===(r=this.userVM.getUser(e))||void 0===r?void 0:r.isCreate))return console.error("该用户没有管理员权限, 无法改变主持人",LOGGER_TAG_CLIENT,e),Promise.reject(qn("您没有管理员权限, 无法改变主持人"));try{yield this.boomCore.changeMaster(e,t)}catch(e){return Promise.reject(qn(`boomCore changeMaster error ${e}`))}}))}updateManager(e,t,r=!0){return __awaiter(this,void 0,void 0,(function*(){return e?this.userVM.checkLocalHasMaster()?this.userVM.updateManager(e,t,r):(console.error("该用户没有管理员权限, 无法改变联席主持人",LOGGER_TAG_CLIENT,e),Promise.reject(Qn("该用户没有管理员权限, 无法改变主持人"))):Promise.reject(Qn("未传递联席主持人id"))}))}changeNickName(e,t){return __awaiter(this,void 0,void 0,(function*(){const r={nickname:t};yield this.updateUser(e,r)}))}sendMessageWithMaster(e,t){return __awaiter(this,void 0,void 0,(function*(){if(!this.userVM.checkLocalHasMaster())return Promise.reject($n("您不是主持人,没有该权限"));if(t){if(!this.userVM.getUser(t))return Promise.reject($n(`uid: ${t} 未找到用户`))}try{yield this.boomCore.customMessage(JSON.stringify(e),t)}catch(e){return Promise.reject(e)}}))}setRemoteAudioEnable(e,t,r){return __awaiter(this,void 0,void 0,(function*(){let i=e?"enabled":"disabled";"enabled"==i&&r&&(i="checkUserAudio");let s={domain:"room-control",method:"audio-force-change",params:{status:i,isNotCancelRootReport:r,fromUserId:this.boomCore.getLocalParticipant().getID()}};this.sendMessageWithMaster(s,t).catch((e=>Promise.reject($n(`boomCore.sendMessage发生错误 ${e}`))))}))}setRemoteVideoEnable(e,t){return __awaiter(this,void 0,void 0,(function*(){let r={domain:"room-control",method:"video-force-change",params:{status:e?"enabled":"disabled",fromUserId:this.boomCore.getLocalParticipant().getID()}};this.sendMessageWithMaster(r,t).catch((e=>Promise.reject(Gn(`boomCore.sendMessage发生错误 ${e}`))))}))}closeRemoteShare(e){return __awaiter(this,void 0,void 0,(function*(){let t={domain:"room-control",method:"close-remote-share",params:{fromUserId:this.boomCore.getLocalParticipant().getID()}};this.sendMessageWithMaster(t,e).catch((e=>Promise.reject($n(`boomCore.sendMessage发生错误 ${e}`))))}))}tipUser(e,t,r,i){return __awaiter(this,void 0,void 0,(function*(){let s={domain:"room-control",method:"tip-user",params:{fromUserId:this.boomCore.getLocalParticipant().getID(),message:t,richMsg:r}};i?this.tipQueueObj[e]=setTimeout((()=>{this.sendMessageWithMaster(s,e)}),60*(i.minutes||0)*1e3+1e3*(i.seconds||0)):this.sendMessageWithMaster(s,e).catch((e=>Promise.reject($n(`boomCore.sendMessage发生错误 ${JSON.stringify(e)}`))))}))}raiseHands(e,t){var r;return __awaiter(this,void 0,void 0,(function*(){const i=null===(r=this.room)||void 0===r?void 0:r.getLocalParticipant().getID();let s={};"raiseHand"===e?(s.raiseHand=t,s.raiseHandTime=Math.floor((new Date).getTime()/1e3)):s["audio"===e?"raiseHandsAudio":"raiseHandsVideo"]=t,yield this.updateUser(i,s)}))}handleRaiseHands(e,t,r){var i,s,o;return __awaiter(this,void 0,void 0,(function*(){let n={domain:"user-control",method:"raise-hands",params:{raiseHandsType:e,raiseHands:t}};try{if(r)yield this.boomCore.customMessage(JSON.stringify(n),r);else{const t=null===(i=this.room)||void 0===i?void 0:i.roomInfo.raiseHandsWatcher.getValue(),r=null===(s=this.room)||void 0===s?void 0:s.roomInfo.raiseVideoHandsWatcher.getValue(),a=null===(o=this.room)||void 0===o?void 0:o.roomInfo.raiseSimpleHandsWatcher.getValue();0===e&&(null==t||t.forEach((e=>{this.boomCore.customMessage(JSON.stringify(n),e.userId)})),null==r||r.forEach((e=>{this.boomCore.customMessage(JSON.stringify(n),e.userId)}))),1===e&&(null==t||t.forEach((e=>{this.boomCore.customMessage(JSON.stringify(n),e.userId)}))),2===e&&(null==r||r.forEach((e=>{this.boomCore.customMessage(JSON.stringify(n),e.userId)}))),3===e&&(null==a||a.forEach((e=>{this.boomCore.customMessage(JSON.stringify(n),e.userId)})))}}catch(e){return Promise.reject(new BoomError(LOCAL_ERROR,"boomCore.sendMessage发生错误"))}}))}updateCustomStats(e,t=!1){return __awaiter(this,void 0,void 0,(function*(){yield this.boomCore.updateCustomStats(e,t).catch((t=>Promise.reject(Vn(`${JSON.stringify(e)} - ${JSON.stringify(t)}`))))}))}sendChatNotice(e,t,r){return __awaiter(this,void 0,void 0,(function*(){yield this.updateCustomStats({chatNotice:e,chatNoticeRich:t,showTipNotice:r}).catch((e=>e))}))}giveLikeEnable(e){return __awaiter(this,void 0,void 0,(function*(){yield this.updateCustomStats({giveLikeEnable:e}).catch((e=>e))}))}changeAutoMute(e){return __awaiter(this,void 0,void 0,(function*(){return this.updateCustomStats({autoMute:e})}))}allUserReceiveJoinLeaveMessages(e){return __awaiter(this,void 0,void 0,(function*(){return this.updateCustomStats({allUserReceiveJoinLeaveMessages:e})}))}userJoinMasterVoice(e){return __awaiter(this,void 0,void 0,(function*(){return this.updateCustomStats({userJoinMasterVoice:e})}))}userGiveLike(e){var t,r;return __awaiter(this,void 0,void 0,(function*(){let i=(new Date).getTime(),s={domain:"room-control",method:"give-like",params:{stream:{user:this.userVM.localUser.userId,avatar:this.userVM.localUser.avatar,sendTime:i,nickname:this.userVM.localUser.nickName,type:e||1}}},o=this.userVM.getLocalUser();try{yield this.boomCore.customMessage(JSON.stringify(s),void 0),this.giveLikeList.push({userId:null===(t=this.room)||void 0===t?void 0:t.getLocalParticipant().userId,nickName:null===(r=this.room)||void 0===r?void 0:r.getLocalParticipant().nickName,time:(new Date).getTime(),type:e}),this.giveLikeListWatcher.next(this.giveLikeList)}catch(e){throw error$1(e,LOGGER_TAG_CLIENT,null==o?void 0:o.userId),new BoomError(CLIENT_BANNED,"用户点赞==>sendMessage出错")}}))}chatEnable(e){return __awaiter(this,void 0,void 0,(function*(){yield this.updateCustomStats({chatEnable:e}).catch((e=>e))}))}joinAudioEnable(e){return __awaiter(this,void 0,void 0,(function*(){yield this.updateCustomStats({joinAudioEnable:e}).catch((e=>e))}))}joinVideoEnable(e){return __awaiter(this,void 0,void 0,(function*(){yield this.updateCustomStats({joinVideoEnable:e}).catch((e=>e))}))}userListEnable(e){return __awaiter(this,void 0,void 0,(function*(){yield this.updateCustomStats({userListEnable:e}).catch((e=>e))}))}audioEnable(e){return __awaiter(this,void 0,void 0,(function*(){yield this.updateCustomStats({audioEnable:e}).catch((e=>e))}))}videoEnable(e){return __awaiter(this,void 0,void 0,(function*(){yield this.updateCustomStats({videoEnable:e}).catch((e=>e))}))}modifyNameEnable(e){return __awaiter(this,void 0,void 0,(function*(){yield this.updateCustomStats({modifyNameEnable:e}).catch((e=>e))}))}backgroundAIEnable(e){return __awaiter(this,void 0,void 0,(function*(){yield this.updateCustomStats({backgroundAIEnable:e}).catch((e=>e))}))}forceOpenUserCamera(e){return __awaiter(this,void 0,void 0,(function*(){yield this.updateCustomStats({forceOpenUserCamera:e}).catch((e=>e))}))}forceOpenUserMic(e){return __awaiter(this,void 0,void 0,(function*(){yield this.updateCustomStats({forceOpenUserMic:e}).catch((e=>e))}))}joinCueVoice(e){return __awaiter(this,void 0,void 0,(function*(){yield this.updateCustomStats({joinCueVoice:e}).catch((e=>e))}))}recordEnable(e){return __awaiter(this,void 0,void 0,(function*(){yield this.updateCustomStats({recordEnable:e}).catch((e=>e))}))}raiseHandEnable(e){return __awaiter(this,void 0,void 0,(function*(){yield this.updateCustomStats({raiseHandEnable:e}).catch((e=>e))}))}joinMicrophoneDisable(e){return __awaiter(this,void 0,void 0,(function*(){yield this.updateCustomStats({joinMicrophoneDisable:e}).catch((e=>e))}))}joinCameraDisable(e){return __awaiter(this,void 0,void 0,(function*(){yield this.updateCustomStats({joinCameraDisable:e}).catch((e=>e))}))}changeFileUpdateModelPermission(e){return __awaiter(this,void 0,void 0,(function*(){yield this.updateCustomStats({fileUpdateModel:e}).catch((e=>e))}))}changeFileUpdateLookPermission(e){return __awaiter(this,void 0,void 0,(function*(){yield this.updateCustomStats({fileUpdateLook:e}).catch((e=>e))}))}changeFileUpdateDownPermission(e){return __awaiter(this,void 0,void 0,(function*(){yield this.updateCustomStats({fileUpdateDown:e}).catch((e=>e))}))}changeFileUpdateEditPermission(e){return __awaiter(this,void 0,void 0,(function*(){yield this.updateCustomStats({fileUpdateEdit:e}).catch((e=>e))}))}changeScreenShareModelPermission(e){return __awaiter(this,void 0,void 0,(function*(){yield this.updateCustomStats({screenShareModel:e}).catch((e=>e))}))}changeOnlyOnePersonSharePermission(e){return __awaiter(this,void 0,void 0,(function*(){yield this.updateCustomStats({onlyOnePersonShare:e}).catch((e=>e))}))}setForceOnUser(e){return __awaiter(this,void 0,void 0,(function*(){yield this.updateCustomStats({forceOn:{user:e}}).catch((e=>e))}))}updateHostLayout(e,t=!1){return __awaiter(this,void 0,void 0,(function*(){if(this.userVM.checkLocalHasMaster())return this.updateCustomStats({from:{fromTag:"masterId"},hostLayout:e},t);info("您不是主持人,没有该上报权限",LOGGER_TAG_CLIENT)}))}checkDevices(e){return __awaiter(this,void 0,void 0,(function*(){const t={domain:"user-control",method:"check-devices",params:{fromUserId:this.boomCore.getLocalParticipant().getID()}};this.sendMessageWithMaster(t,e).catch((e=>Promise.reject(cr(`检测对方设备send-message发生错误: ${e}`))))}))}resp2CheckDevices(e,t){return __awaiter(this,void 0,void 0,(function*(){const r={domain:"user-control",method:"resp-to-check-devices",params:Object.assign(Object.assign({},e),{fromUserId:this.boomCore.getLocalParticipant().getID()})};if(!t)return Promise.reject(cr(`响应设备检测: uid: ${t} 未找到用户`));try{yield this.boomCore.customMessage(JSON.stringify(r),t)}catch(e){return Promise.reject(cr(`响应响应设备检测send-message发生错误 ${e}`))}}))}changeRemoteVideoProfile(e,t){return __awaiter(this,void 0,void 0,(function*(){const r={domain:"user-control",method:"change-video-profile",params:Object.assign(Object.assign({},e),{fromUserId:this.boomCore.getLocalParticipant().getID()})};this.sendMessageWithMaster(r,t).catch((e=>Promise.reject(sr$1(`调节对方的视频分辨率send-message发生错误: ${e}`))))}))}resp2ChangeRemoteVideoProfile(e,t,r){return __awaiter(this,void 0,void 0,(function*(){const i={domain:"user-control",method:"resp-to-change-video-profile",params:{status:e,profile:r,fromUserId:this.boomCore.getLocalParticipant().getID()}};if(!t)return Promise.reject(sr$1(`响应调节视频分辨率: uid: ${t} 未找到用户`));try{yield this.boomCore.customMessage(JSON.stringify(i),t)}catch(e){return Promise.reject(sr$1(`响应调节视频分辨率send-message发生错误 ${e}`))}}))}changeRemoteAudioProfile(e,t){return __awaiter(this,void 0,void 0,(function*(){const r={domain:"user-control",method:"change-audio-profile",params:{microphoneDevice:e.microphoneDevice,speakerDevice:e.speakerDevice,echoCancellation:e.echoCancellation,noiseSuppression:e.noiseSuppression,autoGainControl:e.autoGainControl,speakerVolume:e.speakerVolume,microVolume:e.microVolume,fromUserId:this.boomCore.getLocalParticipant().getID()}};this.sendMessageWithMaster(r,t).catch((e=>Promise.reject(ir(`调节音频send-message发生错误 ${JSON.stringify(e)}`))))}))}resp2ChangeRemoteAudioProfile(e,t){return __awaiter(this,void 0,void 0,(function*(){const r={domain:"user-control",method:"resp-to-change-audio-profile",params:{status:e,fromUserId:this.boomCore.getLocalParticipant().getID()}};if(!t)return Promise.reject(ir(`响应调节音频: uid: ${t} 未找到用户`));try{yield this.boomCore.customMessage(JSON.stringify(r),t)}catch(e){return Promise.reject(ir(`响应调节音频send-message发生错误 ${e}`))}}))}}class BMChatVM{constructor(e,t,r){this.messageList=[],this.hasDangerMessageWatcher=new Subject,this.notificationMessageList=debounce((()=>{this.messageListWatcher.next(this.messageList)}),500),this.boomCore=e,this.userVM=t,this.bmRoom=r,this.messageListWatcher=new BehaviorSubject(this.messageList)}sendMessage(e,t,r){return __awaiter(this,void 0,void 0,(function*(){let i=e.replace(/(^\s*)|(\s*$)/g,""),s=(new Date).getTime(),o={domain:"room-control",method:"send-talk",params:{stream:{user:this.userVM.localUser.userId,avatar:this.userVM.localUser.avatar,sendTime:s,nickname:this.userVM.localUser.nickName},status:i}},n=this.userVM.getLocalUser();try{let e,a=!1,d=r;d||(yield this.boomCore.sendMessage(JSON.stringify(o),t).then((t=>{e=t.seq})).catch((e=>{warn("sendmessage 出错","",null==n?void 0:n.userId,[e]),e&&39===e.code&&(a=!0,this.hasDangerMessageWatcher.next(!0))})));const u=new BMMessageInfo({userId:null==n?void 0:n.userId,message:i,isLocal:null==n?void 0:n.isLocal,avatar:null==n?void 0:n.avatar,nickName:null==n?void 0:n.nickName,sendTime:s,to:t,isDanger:a,seq:e,failed:d});return this.addMessage(u,!1),d?Promise.reject(u):Promise.resolve()}catch(e){throw error$1(e,LOGGER_TAG_CLIENT,null==n?void 0:n.userId),new BoomError(CLIENT_BANNED,"发送聊天消息==>sendMessage出错")}}))}addMessage(e,t){if(!t||this.bmRoom.participantNotice){if(0==this.messageList.length||e.timeStamp-this.messageList[this.messageList.length-1].timeStamp>=notGetTalkInterval){const e=new BMMessageInfo({isMeetingNotice:!0,message:""});this.messageList.push(e)}this.messageList.push(e),this.notificationMessageList()}}updateMessageListWatcher(e){this.messageList=e,this.messageListWatcher.next(this.messageList)}getHistoryMessage(){return __awaiter(this,void 0,void 0,(function*(){const e=yield this.boomCore.getMessages(0,this.boomCore.getMsgSeq());let t=[];return e.items.forEach((e=>{if(e.private||e.to)return!1;if(0==e.msg.length||-1==e.msg.indexOf("{"))return!1;const r=JSON.parse(e.msg);if("send-talk"!=r.method)return!1;const i=e.seq;let s=r.params,o=s.stream.user?s.stream.user:e.userId;s.stream.nickname,s.status,(new Date).getTime();const n=new BMMessageInfo({userId:o,message:s.status,nickName:s.stream.nickname,isLocal:o==this.userVM.localUser.userId,avatar:s.stream.avatar,sendTime:s.stream.sendTime,seq:i});t.push(n)})),Promise.resolve(t)}))}}class BMSpeaker{constructor(e,t){this.user=e,this.stream=t}getID(){return this.stream.getStreamId()}getUser(){return this.user}}function getMasterSort(e,t){return 16|~~e<<1|~~t}function getLocalSort(e,t){return 12|~~e<<1|~~t}function getManagerSort(e,t){return 8|~~e<<1|~~t}function getGuestSort(e,t){return 4|~~e<<1|~~t}function getTimestamp(){return Date.now()}function benchmark(){const e=getTimestamp();return function(){return getTimestamp()-e}}!function(e){e[e.NO_CONTAINER=0]="NO_CONTAINER",e[e.NO_PLAYING=1]="NO_PLAYING",e[e.PLAYING=2]="PLAYING"}(PlayerState||(PlayerState={}));const namespace$1=`.streammodel${Math.random()}`;class BMStreamModel{constructor(e,t){this.streamType=STREAM_TYPE.OTHER,this.pullFailedNum=0,this._video_enable=!1,this._audio_enable=!1,this.videoEnableWatcher=new BehaviorSubject(this._video_enable),this.audioEnableWatcher=new BehaviorSubject(this._audio_enable),this.streamUpdateWatcher=new Subject,this.isSubScribedWatcher=new Subject,this.playStateChangeWatcher=new Subject,this.noContainerWatcher=new Subject,this.noBigContainerWatcher=new Subject,this.audioLevelWatcher=new Subject,this.isCurrentDisplay=!1,this.isDisplay=!1,this.isDisplayObserve=new Subject,this.isInBig=!1,this.isInBigObserve=new Subject,this._hasPulled=!1,this.playerId="",this.shouldPull=!1,this.smallPlayFailed=0,this._pulledStreamType="small",this.pulledStreamGoal="small",this.bigPlayerId="",this.isPlayingBig=!1,this.muted=!1,this.checkVideoTimer=null,this.checkCount=0,this.checkFailedCount=0,this.sortNum=-1,this.handleDisplayChange=e=>{var t;this.isDisplay!==e&&(this.isDisplay=e,null===(t=this.stream)||void 0===t||t.stop(),this.isDisplay||(this.checkVideoTimer&&clearTimeout(this.checkVideoTimer),this.checkVideoTimer=null,this.checkCount=0,this.pulledStreamType="small"),this.sendMessage2Room())},this.onPlayerStateChange=e=>{var t,r;"error"===e.type&&e.reason&&"NotAllowedError"===e.reason.name&&(info("播放失败, 需要调用 resume 方法"),this.playStateChangeWatcher.next(this)),"PAUSED"!==e.state&&"pause"!==e.reason||(this.player&&(null===(t=this.player)||void 0===t||t.resume()),null===(r=this.stream)||void 0===r||r.resume())},this.handleStreamConnectError=()=>{info("流出现的connect-error userId","",this.userId,["streamId ==>",this.streamId,"nickname =>",this.nickname,"isLocal => ",this.isLocal]),this.isLocal?BoomEmitter.emitter.emit(HANDLE_STREAM_CONNECT_ERROR,{stream:this,isLocal:!0}):BoomEmitter.emitter.emit(HANDLE_STREAM_CONNECT_ERROR,{stream:this,isLocal:!1})},this.bindElement=e=>{this.playerId=e,(this.isLocal||this.stream&&this.stream.isSubscribed())&&this.sendMessage2Room()},this.bindBigElement=e=>{this.bigPlayerId=e,(this.isLocal||this.stream&&this.stream.isSubscribed())&&this.sendMessage2Room()},this.sendMessage2Room=debounce((()=>{BoomEmitter.emitter.emit(RECEIVE_SUBSCRIBE_MESSAGE,{stream:this})}),300),this.emitBindElement=debounce((()=>{BoomEmitter.emitter.emit(BIND_ELEMENT,{stream:this})}),50),this.emitBindBigElement=debounce((()=>{BoomEmitter.emitter.emit(BIND_BIG_ELEMENT,{stream:this})}),50),this.currentIsPlaying=e=>{const t=document.getElementById(e);if(!t)return PlayerState.NO_CONTAINER;let r,i,s=0;const o=Array.from(t.children);return r=o.length>0,i=o.length,o.forEach((e=>{0===e.children.length&&(s+=1,e.style.display="none",t.removeChild(e))})),r&&i>s?PlayerState.PLAYING:PlayerState.NO_PLAYING},this.play=()=>__awaiter(this,void 0,void 0,(function*(){var e;const t=this.stream;if(t)if(this.isDisplay&&this.videoEnable){const e=this.currentIsPlaying(this.playerId);if(e===PlayerState.NO_CONTAINER)warn("找不到播放器容器","stream play",this.userId,["流 id =>",this.streamId,"nickname =>",this.nickname,"playerId =>",this.playerId]),this.playerId||BoomEmitter.emitter.emit(NO_CONTAINER,{type:this.isShare?"share":"normal",id:this.userId,container:"small"});else if(e===PlayerState.NO_PLAYING)try{info("远端流开始播放","",this.userId);const e=benchmark();yield t.play(this.playerId,{backgroundColor:"#202020",fit:"contain",audio:!1}),info("远端流播放结束",this.userId,this.streamId,[this.nickname]),info(`播放耗时: ${e()}`,"",this.userId),this.smallPlayFailed=0,this.checkSmallVideo()}catch(e){t.stop(),setTimeout((()=>{error$1("播放小流失败, 尝试重新播放","播放",this.userId,[this.streamId,this.stream,"error => ",JSON.stringify(e)]),this.play()}),2e3)}}else try{null===(e=this.stream)||void 0===e||e.stop()}catch(e){}})),this.playInBig=()=>__awaiter(this,void 0,void 0,(function*(){var e;const t=this.stream;if(t){const r=this.currentIsPlaying(this.bigPlayerId);if(this.isInBig&&this.videoEnable&&this.bigPlayerId){if(r===PlayerState.NO_CONTAINER)warn("找不到 bigPlayerId","大流播放",this.userId,["流 id =>",this.streamId]),this.bigPlayerId||BoomEmitter.emitter.emit(NO_CONTAINER,{type:this.isShare?"share":"normal",id:this.userId,container:"big"});else if(r===PlayerState.NO_PLAYING){info("远端流大流开始播放","",this.userId);const e=benchmark();this.initBigPlayer(),this.player&&(yield this.player.play(t),this.isPlayingBig=!0,this.checkBigVideo()),info(`大流播放耗时: ${e()}`,"",this.userId),info("远端流大流播放结束",this.userId,this.streamId,[this.nickname])}}else null===(e=this.player)||void 0===e||e.destroy(),this.player=null,this.isPlayingBig=!1}})),this.collectAudioLevel=()=>{this.stream?(this.stream.off("audio-level"+namespace$1,this.handleAudioLevel),this.stream.on("audio-level"+namespace$1,this.handleAudioLevel)):warn("collection audio level but not have brtc stream")},this.handleAudioLevel=e=>{this.audioLevelWatcher.next(e)},this.checkSmallVideo=()=>__awaiter(this,void 0,void 0,(function*(){if(this.videoEnable&&this.stream&&!this.isShare){if(!!document.getElementById(this.playerId)){const e=`video_${this.stream.getStreamId()}`;if(!!document.getElementById(e))return void this.checkVideoDecodeFrame(e);error$1(`stream is display, but no video element, should replay now: ${this.smallPlayFailed}`),this.smallPlayFailed<3&&(this.smallPlayFailed+=1,yield sleep(1e3),this.stream.stop(),yield this.play())}}})),this.checkBigVideo=debounce((()=>{var e;if(this.videoEnable&&this.stream){const t=`video_${this.stream.getStreamId()}_big`;if(!this.isShare&&this.isDisplay&&this.playerId){const r=!!document.getElementById(t);if(this.isInBig){if(r)return void this.checkVideoDecodeFrame(t);error$1("stream is playing in big, but no video element, replay now"),null===(e=this.player)||void 0===e||e.destroy(),this.playInBig()}}this.isShare&&this.isInBig&&this.bigPlayerId&&this.checkVideoDecodeFrame(t)}}),2e3),this.checkStreamIsPlaying=debounce((()=>{if(this.isDisplay&&this.videoEnable){if(!this.stream)return;if(!document.getElementById(this.playerId))return;this.currentIsPlaying(this.playerId)===PlayerState.NO_PLAYING||(error$1(`${this.userId} - ${this.nickname}: current is ${this.isDisplay}, but there is no player, try play again`),this.play())}}),1e3),this.user=e,this.updateUser(e),this._stream=t,this.isDisplayObserve.subscribe((e=>{this.handleDisplayChange(e)})),this.isInBigObserve.subscribe((e=>{this.handleIsInBig(e)})),this.updateSortNum(!1)}get hasPulled(){return this._hasPulled}set hasPulled(e){this._hasPulled=e}get pulledStreamType(){return this._pulledStreamType}set pulledStreamType(e){this._pulledStreamType=e}get uuid(){return this.isShare?`${this.userId}_share`:this.userId}get isAudience(){return this.user.isAudience}get canShow(){return!this.isAudience||(this.audioEnable||this.videoEnable)}changeMute(e){this.muted!==e&&(this.muted=e,this.handleSpeakerChange())}handleSpeakerChange(){var e,t;this.isLocal||(this.muted?null===(e=this.stream)||void 0===e||e.setAudioVolume(0):null===(t=this.stream)||void 0===t||t.setAudioVolume(1))}get isToupingma(){return this.user.isToupingma}get isMixer(){return this.user.isMixer}get isSignal(){return this.user.isSignal}genReceiveSubMsg(){let e=null;return e=this.isDisplay?{audio:!0,video:!0,streamType:"small"}:{audio:!0,video:!1,streamType:"small"},e}handleIsInBig(e){this.isInBig!==e&&(this.isInBig=e,info("isInBig change","",this.userId,["streamId =>",this.streamId,"isInBig => ",e]),this.isInBig?this.pulledStreamGoal="big":this.pulledStreamGoal="small",this.sendMessage2Room(),this.isShare&&(this.isInBig||(this.checkVideoTimer&&clearTimeout(this.checkVideoTimer),this.checkVideoTimer=null,this.checkCount=0)))}setVideoEnable(e){this._video_enable!==e&&(this._video_enable=e,this.videoEnableWatcher.next(e))}setAudioEnable(e){this._audio_enable!==e&&(this._audio_enable=e,this.audioEnableWatcher.next(e))}updateStream(e,t=!0,r){if(this._stream&&this._stream.off(namespace$1),this._stream=e,e){const i=e.getVideoOn(),s=e.getAudioOn();info("更新用户的流","updateStream",null==e?void 0:e.getUserId(),["nickname =>",this.nickname,"audioOn",s,"videoOn",i,"streamId",e.getStreamId()]),s&&(this.isShare||r.addToDetector(new BMSpeaker(this.user,e)),this.collectAudioLevel()),e.on("player-state-changed"+namespace$1,this.onPlayerStateChange),e.on("connect-error"+namespace$1,this.handleStreamConnectError),e.on("stream-connection-error"+namespace$1,this.handleStreamConnectError),t&&this.sendMessage2Room()}else this.hasPulled=!1,this.pulledStreamType="small",this.streamType=STREAM_TYPE.OTHER}updateBloudStream(e,t,r=!1){var i,s,o,n,a,d;let u=!1,l=!1;if(e){if(this.bloudStream={audio:e.audio,video:e.video,isScreen:e.isScreen},e.customInfo&&(this.bloudStream.customInfo&&(null===(i=this.bloudStream.customInfo)||void 0===i?void 0:i.volume)===e.customInfo.volume||Number.isNaN(e.customInfo.volume)||this.setRemoteAudioLevel(e.customInfo.volume),this.bloudStream.customInfo=e.customInfo),this.stream&&(this.bloudStream.audio?this.isShare||(t.addToDetector(new BMSpeaker(this.user,this.stream)),this.collectAudioLevel()):t.removeFromDetector(this.stream.getStreamId())),this.bloudStream.video!==this._video_enable&&(u=!0),this.bloudStream.audio!=this._audio_enable&&(l=!0),this.setVideoEnable(this.bloudStream.video),this.setAudioEnable(this.bloudStream.audio),r){try{null===(s=this.stream)||void 0===s||s.destroy()}catch(e){}null===(o=this.player)||void 0===o||o.destroy(),this.stream&&(null===(n=t.room.audioPlayer)||void 0===n||n.removeStream(this.stream)),this.updateStream(void 0,!1,t),this._stream=void 0}l&&!this.audioEnable&&this.stream&&(null===(a=t.room.audioPlayer)||void 0===a||a.removeStream(this.stream)),(this.bloudStream.audio||this.bloudStream&&this.isDisplay)&&(!this.stream||r?BoomEmitter.emitter.emit(ADD_PULL_USER,{id:this.userId,isWeb:this.isWeb,isScreen:this.isShare}):(this.isLocal||this.hasPulled&&this.stream.isSubscribed()||this.sendMessage2Room(),u&&this.sendMessage2Room(),!this.isLocal&&l&&this.audioEnable&&this.stream.isSubscribed()&&BoomEmitter.getInstance().emit(ADD_AUDIO_PLAY,{stream:this})))}else this.bloudStream=void 0,this.setVideoEnable(!1),this.setAudioEnable(!1),null===(d=this.player)||void 0===d||d.destroy(),this.stream&&t.removeFromDetector(this.stream.getStreamId());this.updateSortNum(!0),this.streamUpdateWatcher.next(!0)}updateBloudCustomInfo(e){var t;this.bloudStream?(this.bloudStream.customInfo&&(null===(t=this.bloudStream.customInfo)||void 0===t?void 0:t.volume)===e.volume||Number.isNaN(e.volume)||this.setRemoteAudioLevel(e.volume),this.bloudStream.customInfo=e):error$1("updateBloudCustomInfo, but bloudStream is undefined","","",["userId =>",this.userId])}get streamId(){return this._stream?this._stream.getStreamId():this.userId}get bStreamId(){return this.isShare?`${this.userId}_screen`:this.userId}get userId(){return this.user.userId}get stream(){return this._stream}get isLocal(){return this.user.isLocal}get isShare(){var e,t,r;return this.stream?this.user.isWeb?null===(t=null===(e=this.stream)||void 0===e?void 0:e.getUserId().toString())||void 0===t?void 0:t.endsWith(STREAM_SUFFIX_SCREEN):!(!this.stream||!this.stream.getType||"assist"!==this.stream.getType()):!!(null===(r=this.bloudStream)||void 0===r?void 0:r.isScreen)}get isWeb(){return this.user.isWeb}get audioEnable(){return this._audio_enable}get videoEnable(){return this._video_enable}get brtcPlayerId(){return`player_${this.stream.getStreamId()}`}get selfPlayerId(){return`player_${this.stream.getStreamId()}_big_container`}get nickname(){var e;return this.user.isToupingma?`${this.user.nickName}(的投屏)`:(null===(e=this.streamId)||void 0===e?void 0:e.includes(STREAM_SUFFIX_SCREEN))?`${this.user.nickName}(的屏幕共享)`:this.user.nickName}get audioLevel(){var e;return(null===(e=this._stream)||void 0===e?void 0:e.getAudioLevel())||0}getUser(){return this.user}setRemoteAudioLevel(e){if(this.isLocal)throw new Error("不能设置本地流的音量");BoomEmitter.emitter.emit(SET_VOLUME,{streamId:this.streamId,volume:e})}getStats(){var e;return null===(e=this._stream)||void 0===e?void 0:e.getStats()}initBigPlayer(){try{if(this.bigPlayerId){const e=document.querySelector(`#${this.bigPlayerId}`);if(!e)return void console.error("播放大流失败,找不到大流容器",this.userId,this.streamId,this.bigPlayerId);this.player&&this.player.destroy(),this.player=null,this.player=new x(e,{fit:"contain"}),this.player.on("player-state-changed",(e=>{var t;this.stream&&(info("big player state change","","",[JSON.stringify(e)]),"error"===e.type&&e.reason&&"NotAllowedError"===e.reason.name&&this.playStateChangeWatcher.next(this),"PAUSED"===e.state&&(null===(t=this.player)||void 0===t||t.resume()))}))}}catch(e){error$1("初始化大窗口的播放器失败",this.userId,this.streamId,e.message)}}stop(){var e;null===(e=this._stream)||void 0===e||e.stop()}destroy(){var e;null===(e=this._stream)||void 0===e||e.destroy()}isPlaying(){var e;return null===(e=this._stream)||void 0===e?void 0:e.isPlaying()}replay(){var e;return null===(e=this._stream)||void 0===e?void 0:e.replay()}resume(){var e,t;null===(e=this._stream)||void 0===e||e.resume(),null===(t=this.player)||void 0===t||t.resume()}hasAudio(){var e;return(null===(e=this._stream)||void 0===e?void 0:e.hasAudio())||!1}hasVideo(){var e;return(null===(e=this._stream)||void 0===e?void 0:e.hasVideo())||!1}updateUser(e){this.user=e;const t=this.user.userInfo.pos;t?t.includes("web")||t.includes("pc")?this.streamType=STREAM_TYPE.SUB_MAIN:t.includes("_toupingma")?this.streamType=STREAM_TYPE.SHARE:this.streamType=STREAM_TYPE.SINGLE:this.streamType=STREAM_TYPE.SINGLE}updateSortNum(e=!0){const t=this.getSortNum();this.setSortNum(t,e)}setSortNum(e,t){this.sortNum!==e&&(this.sortNum=e,t&&(BoomEmitter.emitter.emit(MODEL_SORT_NUM_CHANGE,null),this.user.updateSortNum(!0)))}getSortNum(){return this.user.isMaster?getMasterSort(this.audioEnable,this.videoEnable):this.user.isLocal?getLocalSort(this.audioEnable,this.videoEnable):this.user.isManager?getManagerSort(this.audioEnable,this.videoEnable):getGuestSort(this.audioEnable,this.videoEnable)}checkVideoDecodeFrame(e){const t=document.getElementById(e);if(this.checkVideoTimer&&clearTimeout(this.checkVideoTimer),!t)return info("黑帧检测没有播放容器",this.userId,"",["streamId =>",this.streamId,"isShare =>",this.isShare,"playerId =>",this.playerId,"bigPlayerId =>",this.bigPlayerId,"isDisplay => ",this.isDisplay,"isInbig =>",this.isInBig]),void(this.isShare&&this.isInBig&&this.bigPlayerId&&(warn("share stream has no video player, retry play"),this.playInBig()));this.checkVideoTimer=setTimeout((()=>{var r,i,s;const o=(null==t?void 0:t.getVideoPlaybackQuality)&&(null===(r=null==t?void 0:t.getVideoPlaybackQuality())||void 0===r?void 0:r.totalVideoFrames)||0;if(!t||t.getVideoPlaybackQuality){if(o>0)return clearTimeout(this.checkVideoTimer),void(this.checkFailedCount=0);if(this.checkCount>10){if(error$1("检测超过了十次,还没有视频流,需要重新拉取","黑帧检测",this.userId,["streamId =>",this.streamId,"nickname =>",this.nickname,"videoContainer => ",e]),this.checkVideoTimer&&clearTimeout(this.checkVideoTimer),this.checkVideoTimer=null,this.checkCount=0,this.checkFailedCount+=1,this.checkFailedCount<=3){this.hasPulled=!1,this.pulledStreamType="small",null===(i=this._stream)||void 0===i||i.off(namespace$1);try{null===(s=this._stream)||void 0===s||s.destroy()}catch(e){}this._stream=void 0,this.sendMessage2Room()}}else this.checkCount+=1,this.checkVideoDecodeFrame(e)}else this.checkVideoTimer&&clearTimeout(this.checkVideoTimer)}),200)}subscribeStream(){this.shouldPull=!0,BoomEmitter.emitter.emit(MANUAL_SUBSCRIPTION,{stream:this})}unSubscribeStream(){this.shouldPull=!1,BoomEmitter.emitter.emit(UNSUBSCRIBE_STREAM,{stream:this})}unAttach(e){var t,r,i,s;info("unattach stream play","",this.userId,["streamId =>",this.streamId,"nickname =>",this.nickname,"type =>",e]),"all"===e?(null===(t=this.stream)||void 0===t||t.stop(),null===(r=this.player)||void 0===r||r.destroy()):"big"===e?null===(i=this.player)||void 0===i||i.destroy():"small"===e&&(null===(s=this.stream)||void 0===s||s.stop())}}function getHTMLMediaStreamOptions(e){let t=null;const r=e.videoElement,i=r.offsetWidth,s=r.offsetHeight;if(r.captureStream?t=r.captureStream():r.mozCaptureStream&&(t=r.mozCaptureStream()),t){const e=t.getVideoTracks()[0],r=t.getAudioTracks()[0];return{video:!!e,audio:!!r,videoSource:e,audioSource:r,width:i,height:s}}return null}function getMediaStreamInfo(e,t){try{const r=e.getVideoTracks()[0],i=e.getAudioTracks()[0];return{video:!!r,audio:!!i,videoSource:r,audioSource:i,width:t.width,height:t.height}}catch(e){return console.log("获取共享音频参数有误",e),null}}function transShareScreen2User(e){return e.split("_")[0]}const namespace=`.streammuteevent${Math.random()}`;class BMStreamModelVM{constructor(){this.streamModels=new Map,this.streamModelsWatcher=new BehaviorSubject(BMStreamModelVM.filterStreamModels(this.sortStreamModels())),this.shareStreamModels=new Map,this.shareStreamModelsWatcher=new BehaviorSubject(Array.from(this.shareStreamModels.values())),this.localStreamErrorWatcher=new Subject,this.localModel=null,this.room=null,this.bloudStream=null,this.videoStream=null,this.audioStream=null,this.audioStats=!1,this.videoStats=!1,this.localIsShare=!1,this.isShareWatcher=new Subject,this._speaker_enable=!0,this.speakerEnableWatcher=new BehaviorSubject(this._speaker_enable),this.mixStreamModelWatcher=new BehaviorSubject(null),this.canvasTimer=null,this._isRecording=!1,this._slicingRecord=!1,this.isRecordingWatcher=new BehaviorSubject(this._isRecording),this._speaker=null,this._speakers=new Map,this.speakerWatcher=new BehaviorSubject(this._speaker),this.noContainerWatcher=new Subject,this.noBigContainerWatcher=new Subject,this.localStreamConnectErrorWatcher=new Subject,this.localShareError=new Subject,this.shareBloudStateMap=new Map,this.updateModelSort=debounce((()=>{const e=this.sortStreamModels();this.streamModelsWatcher.next(BMStreamModelVM.filterStreamModels(e))}),200,{maxWait:500}),this.handleNoContainer=e=>{const{type:t,container:r,id:i}=e;let s;s="share"===t?this.shareStreamModels.get(i):this.streamModels.get(i),s&&("small"===r?this.noContainerWatcher.next(s):this.noBigContainerWatcher.next(s))},this.getHTMLMediaStream=getHTMLMediaStreamOptions,this.getMediaStream=getMediaStreamInfo,this.createCanvas(),setTimeout((()=>{this.canvasDisplay()}),100),BoomEmitter.emitter.on(MODEL_SORT_NUM_CHANGE,this.updateModelSort),BoomEmitter.emitter.on(NO_CONTAINER,this.handleNoContainer)}static filterStreamModels(e){return e.filter((e=>!e.isToupingma)).filter((e=>!ignoreUserId.some((t=>e.userId.includes(t))))).filter((e=>e.canShow))}initWithRoom(e){return this.room=e,this}setSpeakerEnable(e){var t;this._speaker_enable!==e&&(null===(t=this.room.audioPlayer)||void 0===t||t.mute(!e),this._speaker_enable=e,this.speakerEnableWatcher.next(e))}getStreamModels(){return Array.from(this.streamModels.values())}getStreamModelByUId(e){return this.streamModels.get(e)}getShareStreamModelByUId(e){return this.shareStreamModels.get(e)}getLocalStreamModel(){return this.localModel}createStreamModel(e,t){const r=new BMStreamModel(e,void 0);return t&&r.updateStream(t,!0,this),r.isShare?(e.addStream(`${e.userId}${STREAM_SUFFIX_SCREEN}`,r),this.addShareStreamModel(r)):(e.addStream(e.userId,r),this.addStreamModel(r)),r}addStreamModel(e){e&&(e.isLocal?this.localModel||(this.localModel=e,this.streamModels.set(this.localModel.userId,this.localModel)):this.streamModels.set(e.userId,e))}addShareStreamModel(e){e&&(e.isLocal||(this.shareStreamModels.set(e.userId,e),this.shareStreamModelsWatcher.next(Array.from(this.shareStreamModels.values()))))}removeStreamModel(e){if(!e)return;const t=e.getUser();this.streamModels.delete(e.userId),t.removeStream(e.userId)}removeShareStreamModelByUId(e){var t,r,i,s;const o=this.shareStreamModels.get(e);if(o){try{null===(t=o.stream)||void 0===t||t.stop(),null===(r=o.stream)||void 0===r||r.destroy()}catch(e){}o.audioEnable&&o.stream&&(null===(s=null===(i=this.room)||void 0===i?void 0:i.audioPlayer)||void 0===s||s.removeStream(o.stream)),this.removeShareStreamModel(o)}}removeShareStreamModel(e){if(!e)return;const t=e.getUser();this.shareStreamModels.delete(e.userId),t.removeStream(`${e.userId}${STREAM_SUFFIX_SCREEN}`),t.updateSortNum(!0),this.shareStreamModelsWatcher.next(Array.from(this.shareStreamModels.values()))}removeStreamModelByUId(e){var t,r,i;const s=this.getStreamModelByUId(e);if(s){if(s.stream){this.removeFromDetector(s.streamId);try{s.stream.stop(),s.stream.destroy()}catch(e){}}s.audioEnable&&(s.stream?null===(r=null===(t=this.room)||void 0===t?void 0:t.audioPlayer)||void 0===r||r.removeStream(s.stream):null===(i=this.room)||void 0===i||i.audioPlayer.removeStreamByUid(e)),this.removeStreamModel(s)}return s}remoteStreamPublished(e){const t=e.getStreamId(),r=e.getUserId().toString();let i,s=this.getStreamModelByUId(r);if(s||(i=transShareScreen2User(String(r)),s=this.getStreamModelByUId(i)),s){if(isShareStream(e)){let t;if(i&&(t=this.shareStreamModels.get(i)),t){if(t.isLocal)return;t.hasPulled=!1,t.pulledStreamType="small",t.updateStream(e,!0,this),this.shareStreamModelsWatcher.next(Array.from(this.shareStreamModels.values()))}else{const t=this.createStreamModel(s.getUser(),e),r=e.getVideoOn(),i=e.getAudioOn(),o=this.shareBloudStateMap.get(s.userId);o?t.updateBloudStream({audio:o.audio,video:o.video,isScreen:!0,customInfo:o.customInfo},this):t.updateBloudStream({audio:i,video:r,isScreen:!0},this),t.streamType=STREAM_TYPE.SHARE}}else s.hasPulled=!1,s.pulledStreamType="small",this.updateStreamModel(s,e);s.getUser().isMixer&&this.mixStreamModelWatcher.next(s),this.changeSingleStreamSpeaker(s).catch((e=>{error$1("设置单股流的扬声器的播放出现了问题","设置播放音量",null==s?void 0:s.userId)}))}else error$1("brtc有人推流了,但是找不到对应的streamModel, 找不到对应的用户","",r,["streamId => ",t,"types =>",e.getType&&e.getType()])}remoteStreamUnpublished(e){var t,r,i;let s;const o=e.getUserId().toString(),n=e.getStreamId();let a=!1;if(o.includes(STREAM_SUFFIX_SCREEN)){const e=transShareScreen2User(String(o));if(e==(null===(r=null===(t=this.room)||void 0===t?void 0:t.getLocalParticipant())||void 0===r?void 0:r.userId))return info("本地用户取消共享屏幕","取消共享屏幕",o),void this.localModel.getUser().removeStream(o);s=this.getShareStreamModelByUId(e),a=!0}else n.startsWith(MOBILE_STREAM_SUFFIX_SCREEN)||e.getType&&"assist"===e.getType()?(s=this.getShareStreamModelByUId(o),a=!0):s=this.getStreamModelByUId(o);if(this.removeFromDetector(n),this.removeFromRecorder(e),!s)return void error$1("brtc有人取消推流 但是找不到对应的streamModel","取消推流",o,[n]);const d=null===(i=s.stream)||void 0===i?void 0:i.getStreamId();if(d===n)return s.hasPulled=!1,s.pulledStreamType="small",a||s.streamType===STREAM_TYPE.SHARE?(s.updateStream(void 0,!0,this),void this.removeShareStreamModel(s)):(s.updateStream(void 0,!0,this),s);error$1("当前取消推流的和当前绑定的不是同一股流","",o,["streamId =>",n,"streamModel.streamId",d])}sortStreamModels(){return sortStreamModels(Array.from(this.streamModels.values()))}updateStreamModel(e,t){e.updateStream(t,!0,this)}updateShareStreamModel(e,t){e.updateStream(t,!0,this)}setLocalVideoEnable(e,t){var r;return __awaiter(this,void 0,void 0,(function*(){if(!(null===(r=this.room)||void 0===r?void 0:r.networkState.brtc)||!this.room.netConnecting)return void error$1("断网期间开本地摄像头,不与响应");if(!this.room.mediaPermission.camera)return Promise.reject(Er$1());const i=this.getLocalStreamModel();if(info(`开关本地摄像头, 状态 => ${e}`,"本地用户",null==i?void 0:i.userId),i)if(e)if(null==i?void 0:i.stream){if(t)yield i.stream.replaceTrack(t).catch((e=>{error$1("美颜 videoTrack replace 失败","","",JSON.stringify(e))}));else{if("CanvasCaptureMediaStreamTrack"===i.stream.getVideoTrack().constructor.name){const e=yield this.createVideoStream().catch((e=>Promise.reject(e)));yield i.stream.replaceTrack(e).then((()=>{info("replace video track success")})).catch((e=>(error$1("本地视频流更换视频流失败","","",JSON.stringify(e)),this.handleStreamUpdateFailed(),Promise.reject(mr$1()))))}}if(!(yield i.stream.unmuteVideo()))return error$1("brtc unmuteVideo失败"),this.handleStreamUpdateFailed(),Promise.reject(mr$1());info("brtc unmute video success"),yield this.bloudStream.setVideoEnabled(!0).then((()=>{i.updateStream(i.stream,!0,this),i.updateBloudStream({video:!0,audio:i.audioEnable,isScreen:!1},this),i.playInBig()})).catch((e=>{error$1("bloud unmuteVideo失败","本地用户","",[JSON.stringify(e)]),this.handleStreamUpdateFailed()}))}else yield this.createStreamAndPublish(!1,!0,i,t).catch((e=>{var t,r,i,s,o;return error$1("开启本地摄像头失败","","",[JSON.stringify(e)]),null===(r=null===(t=this.localModel)||void 0===t?void 0:t.stream)||void 0===r||r.destroy(),(null===(i=this.bloudStream)||void 0===i?void 0:i.published)&&this.bloudStream.unpublish(),null===(s=this.localModel)||void 0===s||s.updateStream(void 0,!0,this),null===(o=this.localModel)||void 0===o||o.updateBloudStream(void 0,this),Promise.reject(e)}));else{i.stream&&(yield this.muteOrUnpublishStream("video",!0,i).catch((e=>(error$1("关闭本地摄像头失败","","",[e]),Promise.reject(zn(e))))))}}))}handleStreamUpdateFailed(){return __awaiter(this,void 0,void 0,(function*(){error$1("brtc unmute stream failed, now unpublish"),yield this.unpublishStream()}))}setLocalAudioEnable(e){var t;return __awaiter(this,void 0,void 0,(function*(){if(!(null===(t=this.room)||void 0===t?void 0:t.networkState.brtc)||!this.room.netConnecting)return void error$1("断网期间开本地麦克风,不与响应");if(!this.room.mediaPermission.microphone)return Promise.reject(Sr$1());const r=this.getLocalStreamModel();if(info(`开关本地麦克风, 状态 => ${e}`,"本地用户",null==r?void 0:r.userId),r)if(e){if(null==r?void 0:r.stream){const e=yield r.stream.unmuteAudio();if(info(`unmute local stream audio res : ${e}`),!e)return error$1("brtc unmuteAudio失败","本地用户",""),yield this.handleStreamUpdateFailed(),Promise.reject(xr$1());info("unmute audio success"),yield this.bloudStream.setAudioEnabled(!0).then((()=>{info("bloud stream set audio enable"),r.updateStream(r.stream,!1,this),r.updateBloudStream({audio:!0,video:r.videoEnable,isScreen:!1},this)})).catch((e=>{error$1("bloud unmuteAudio失败","本地用户","",[JSON.stringify(e)]),this.handleStreamUpdateFailed()}))}else yield this.createStreamAndPublish(!0,!1,r).catch((e=>{var t,r,i,s,o;return error$1("开启本地麦克风失败","","",[e]),null===(r=null===(t=this.localModel)||void 0===t?void 0:t.stream)||void 0===r||r.destroy(),(null===(i=this.bloudStream)||void 0===i?void 0:i.published)&&this.bloudStream.unpublish(),null===(s=this.localModel)||void 0===s||s.updateStream(void 0,!0,this),null===(o=this.localModel)||void 0===o||o.updateBloudStream(void 0,this),Promise.reject(e)}));(null==r?void 0:r.stream)&&this.addToRecorder(null==r?void 0:r.stream)}else{const e=r.stream;if(e){this.removeFromRecorder(e),this.removeFromDetector(e.getStreamId());try{yield this.muteOrUnpublishStream("audio",!0,r)}catch(e){return error$1("关闭本地麦克风失败","","",[JSON.stringify(e)]),Promise.reject(Kn(e))}}}}))}joinWithAudioAndAudio(e,t){return __awaiter(this,void 0,void 0,(function*(){info("join with audio and video","join publish","",[e,t]);const r=this.getLocalStreamModel();r&&(yield this.createStreamAndPublish(e,t,r).catch((e=>{var t,r,i,s,o;return error$1("join create and publish failed","","",[JSON.stringify(e)]),null===(r=null===(t=this.localModel)||void 0===t?void 0:t.stream)||void 0===r||r.destroy(),(null===(i=this.bloudStream)||void 0===i?void 0:i.published)&&this.bloudStream.unpublish(),null===(s=this.localModel)||void 0===s||s.updateStream(void 0,!0,this),null===(o=this.localModel)||void 0===o||o.updateBloudStream(void 0,this),Promise.reject(e)})))}))}changeSpeaker(e,t=!1){var r,i;return __awaiter(this,void 0,void 0,(function*(){if(info("change speaker","","",[JSON.stringify(e)]),!e.deviceId)throw new s(LOCAL_ERROR,"切换扬声器失败!,原因: 选择的设备没有deviceId"+(null==e?void 0:e.name));try{this.room.setSelectSpeakerDevice(e),null===(i=null===(r=this.room)||void 0===r?void 0:r.audioPlayer)||void 0===i||i.setDevice(e.deviceId,t)}catch(e){throw error$1("切换扬声器失败","","",["error",null==e?void 0:e.message,JSON.stringify(e)]),new s(LOCAL_ERROR,"切换扬声器失败")}}))}changeSingleStreamSpeaker(e){return __awaiter(this,void 0,void 0,(function*(){const t=this.room.selectAudioOutputDevice;t&&(e.isLocal||e.stream&&(yield e.stream.setAudioOutput(t.deviceId)))}))}changeAudioInput(e){var t,r,i;return __awaiter(this,void 0,void 0,(function*(){info("change audio input device","","",[JSON.stringify(e)]);const s=null===(t=this.localModel)||void 0===t?void 0:t.stream;if(null===(r=this.room)||void 0===r||r.setSelectAudioDevice(e),s){return"ended"===(null===(i=s.getAudioTrack())||void 0===i?void 0:i.readyState)?(error$1("try to change audio input device but audio track is ended"),!1):(this.removeFromRecorder(s),yield s.switchDevice("audio",e.deviceId),this.addToRecorder(s),!0)}}))}changeVideoInput(e){var t,r,i,s;return __awaiter(this,void 0,void 0,(function*(){info("change video input device","","",[JSON.stringify(e)]);const o=null===(t=this.localModel)||void 0===t?void 0:t.stream;if(null===(r=this.room)||void 0===r||r.setSelectVideoDevice(e),o){return"ended"===(null===(i=o.getVideoTrack())||void 0===i?void 0:i.readyState)?(error$1("try to change video input device but video track is ended"),!1):(yield o.switchDevice("video",e.deviceId),(null===(s=this.localModel)||void 0===s?void 0:s.isDisplay)&&this.localModel.isInBig&&this.localModel.playInBig(),!0)}}))}muteSpeaker(e){return __awaiter(this,void 0,void 0,(function*(){info("静音扬声器 状态 =>","","",["status =>",e]);try{this.setSpeakerEnable(e)}catch(t){return Promise.reject(Xn(`开关扬声器失败 ${e} error: ${JSON.stringify(t)}`))}}))}createLocalAudioStream(){var e;return __awaiter(this,void 0,void 0,(function*(){this.room.mediaPermission.microphone?(yield this.room.initDevices(),this.room.audioDevices.length?(null===(e=this.audioStream)||void 0===e||e.destroy(),this.audioStream=yield this.room.createSingleLocalStream({video:!1,audio:!0},this.localModel.userId).catch((e=>(error$1("create brtc stream error","","",[JSON.stringify(e)]),Promise.reject(e))))):error$1("there is no audio device exists")):error$1("there is no microphone permission")}))}createStreamAndPublish(e,t,r,i){var s,o,n,a,d,u,l,c;return __awaiter(this,void 0,void 0,(function*(){let h=BMStreamModelVM.getCanvasStream();if(yield this.room.initDevices(),t)null===(a=this.brtcStream)||void 0===a||a.destroy(),(null===(d=this.room)||void 0===d?void 0:d.audioDevices.length)||(error$1("当前电脑中没有音频输入设备,重新获取"),yield null===(u=this.room)||void 0===u?void 0:u.initDevices()),(null===(l=this.room)||void 0===l?void 0:l.videoDevices.length)||(error$1("当前电脑中没有视频输入设备, 重新获取"),yield null===(c=this.room)||void 0===c?void 0:c.initDevices()),this.room.audioDevices.length>0?this.brtcStream=yield this.room.createSingleLocalStream({video:!0,audio:this.room.mediaPermission.microphone},r.userId).catch((e=>(error$1("create brtc audio and video stream failed","","",[JSON.stringify(e)]),Promise.reject(e)))):(error$1("没有音频输入设备,只能创建视频流"),this.brtcStream=yield this.room.createSingleLocalStream({video:!0,audio:!1},r.userId).catch((e=>(error$1("create brtc video stream failed","","",[JSON.stringify(e)]),Promise.reject(e)))));else{const e=h.getVideoTracks()[0];this.audioStream||(this.audioStream=yield this.room.createSingleLocalStream({video:!1,audio:!0},r.userId).catch((e=>(error$1("create brtc stream error","","",[JSON.stringify(e)]),Promise.reject(e)))));const t=null===(s=this.audioStream)||void 0===s?void 0:s.getAudioTrack();if(!t||t&&t.muted)throw null===(o=this.audioStream)||void 0===o||o.destroy(),this.audioStream=null,this.localStreamErrorWatcher.next("audio"),error$1("麦克风设备不可用","","",["muted => ?",null==t?void 0:t.muted]),pr$1("麦克风");null===(n=this.brtcStream)||void 0===n||n.destroy(),this.brtcStream=yield this.room.createSingleLocalStream({video:!0,audio:!0,videoSource:e,audioSource:t},r.userId).catch((e=>Promise.reject(e)))}this.brtcStream&&(t||(yield this.brtcStream.muteVideo()),e||(yield this.brtcStream.muteAudio()),i&&(yield this.brtcStream.replaceTrack(i).catch((e=>{error$1("美颜 videoTrack replace 失败","","",JSON.stringify(e))}))),yield this.room.publish(this.brtcStream).catch((e=>{var t,r;return null===(t=this.brtcStream)||void 0===t||t.destroy(),null===(r=this.localModel)||void 0===r||r.updateBloudStream(void 0,this),Promise.reject(e)})),this.brtcStream.on("video-track-mute"+namespace,this.muteHandler.bind(this,"video")),this.brtcStream.on("video-track-ended"+namespace,this.muteHandler.bind(this,"video")),this.brtcStream.on("audio-track-mute"+namespace,this.muteHandler.bind(this,"audio")),this.brtcStream.on("audio-track-ended"+namespace,this.muteHandler.bind(this,"audio")),yield this.publishBloudStream(e,t))}))}publishBloudStream(e,t){var r;return __awaiter(this,void 0,void 0,(function*(){const i=this.localModel.userId;this.bloudStream=this.room.boomCore.creteBloudLocalStream({audio_enable:e,video_enable:t},i),yield this.bloudStream.publish({video_enable:t,audio_enable:e}),null===(r=this.localModel)||void 0===r||r.updateBloudStream({video:t,audio:e,isScreen:!1},this)}))}muteHandler(e){const t=()=>__awaiter(this,void 0,void 0,(function*(){var e,t,r,i,s,o,n,a,d;(null===(e=this.localModel)||void 0===e?void 0:e.stream)&&(yield null===(t=this.room)||void 0===t?void 0:t.boomCore.unpublish(this.localModel.stream).catch((e=>{error$1("brtc local stream has problem and unpublish failed","","",[String(e)])}))),null===(i=null===(r=this.localModel)||void 0===r?void 0:r.stream)||void 0===i||i.destroy(),null===(s=this.audioStream)||void 0===s||s.destroy(),null===(o=this.videoStream)||void 0===o||o.destroy(),null===(n=this.brtcStream)||void 0===n||n.destroy(),this.brtcStream=void 0,this.audioStream=null,this.videoStream=null,null===(a=this.localModel)||void 0===a||a.updateStream(void 0,!0,this),yield this.bloudStream.unpublish(),this.bloudStream=null,null===(d=this.localModel)||void 0===d||d.updateBloudStream(void 0,this)}));setTimeout((()=>__awaiter(this,void 0,void 0,(function*(){var r,i,s,o,n,a,d,u,l,c,h,m,p,f,v,g,S;if(null===(r=this.localModel)||void 0===r?void 0:r.stream){const r=null===(i=this.localModel)||void 0===i?void 0:i.videoEnable,b=null===(s=this.localModel)||void 0===s?void 0:s.audioEnable;if("video"===e){const i=null===(o=this.localModel.stream.getVideoTrack())||void 0===o?void 0:o.muted,s=null===(n=this.localModel.stream.getVideoTrack())||void 0===n?void 0:n.label,g=null===(a=this.localModel.stream.getVideoTrack())||void 0===a?void 0:a.enabled,S=null===(d=this.localModel.stream.getVideoTrack())||void 0===d?void 0:d.readyState,y="ended"===S;if(info("brtc video track status","","",[i,g,S,s]),!y&&!i&&g)return;info("video track has problem, now try recreate and publish"),error$1("brtc本地流出现异常,需要重新推流处理","","",["videoEnable",r,"audioEnable",b,"type",e]),this.localStreamConnectErrorWatcher.next(hr("摄像头")),(null===(u=this.localModel)||void 0===u?void 0:u.stream)&&(yield null===(l=this.room)||void 0===l?void 0:l.boomCore.unpublish(this.localModel.stream).catch((e=>{error$1("brtc local stream has problem and unpublish failed","","",[String(e)])})),null===(c=this.localModel)||void 0===c||c.updateStream(void 0,!0,this),null===(m=null===(h=this.localModel)||void 0===h?void 0:h.stream)||void 0===m||m.destroy(),null===(p=this.audioStream)||void 0===p||p.destroy(),null===(f=this.brtcStream)||void 0===f||f.destroy(),this.brtcStream=void 0,null===(v=this.videoStream)||void 0===v||v.destroy(),this.audioStream=null,this.videoStream=null),yield this.createStreamAndPublish(b,r,this.localModel).catch((e=>__awaiter(this,void 0,void 0,(function*(){error$1("brtc video stream has problem and republish stream failed","","",[JSON.stringify(e)]),yield t(),this.localStreamConnectErrorWatcher.next(dr())}))))}else{error$1("brtc本地流出现异常,需要重新推流处理","","",["videoEnable",r,"audioEnable",b,"type",e]),this.localStreamConnectErrorWatcher.next(hr("麦克风")),null===(g=this.audioStream)||void 0===g||g.destroy(),this.audioStream=null,this.audioStream=yield this.room.createPBSingleLocalStream({video:!1,audio:!0});const i=null===(S=this.audioStream)||void 0===S?void 0:S.getAudioTrack();i&&!i.muted?this.localModel.stream&&(yield this.localModel.stream.replaceTrack(i).catch((e=>{error$1("本地流出现异常, 重新创建audio stream replace 失败","本地流出现异常","",[JSON.stringify(e)]),this.localStreamConnectErrorWatcher.next(dr()),t()}))):(error$1("recreate audio stream failed, now unpub"),this.localStreamConnectErrorWatcher.next(dr()),t())}}this.localStreamErrorWatcher.next(e)}))),1e3)}unpublishStream(){var e,t,r,i;return __awaiter(this,void 0,void 0,(function*(){info("unpublish stream");const s=this.getLocalStreamModel();if(s){const o=s.stream;o&&(yield null===(e=this.room)||void 0===e?void 0:e.unpublish(o).catch((e=>{error$1("brtc 取消发布失败","取消推流",s.userId,[JSON.stringify(e)])})));try{this.removeFromRecorder(o),null==o||o.destroy(),null===(t=this.videoStream)||void 0===t||t.destroy(),null===(r=this.audioStream)||void 0===r||r.destroy(),null===(i=this.brtcStream)||void 0===i||i.destroy(),this.videoStream=null,this.audioStream=null,this.brtcStream=void 0,s.updateStream(void 0,!0,this),yield this.bloudStream.unpublish().catch((e=>{error$1("bloud unpublish stream failed","bloud unpublish stream",s.userId,[JSON.stringify(e),null==e?void 0:e.code,null==e?void 0:e.message])})),s.updateBloudStream(void 0,this),this.bloudStream=null}catch(e){error$1("stream destroy failed","取消推流",s.userId,[JSON.stringify(e)])}}}))}muteOrUnpublishStream(e,t,r){var i;return __awaiter(this,void 0,void 0,(function*(){const t=r.stream;let s=!0;if("audio"===e?s=t.getVideoOn():"video"===e&&(s=t.getAudioOn()),s){if("audio"===e){(yield t.muteAudio())||error$1("brtc muteAudio失败","关闭本地音频","本地"),yield this.bloudStream.setAudioEnabled(!1).catch((e=>{error$1("bloud setAudioEnabled 失败","关闭本地音频","本地",[JSON.stringify(e)])})),r.updateBloudStream({audio:!1,video:!0,isScreen:!1},this)}else if("video"===e){const e=BMStreamModelVM.getCanvasStream().getVideoTracks()[0];try{yield t.replaceTrack(e),yield t.muteVideo()}catch(e){error$1("关闭本地视频失败","关闭本地视频","本地",[JSON.stringify(e)])}try{null===(i=this.videoStream)||void 0===i||i.destroy(),this.videoStream=null}catch(e){error$1("this.videoStream destroy failed")}yield this.bloudStream.setVideoEnabled(!1).catch((e=>{error$1("bloud setVideoEnabled 失败","关闭本地音频","本地",[JSON.stringify(e)])})),r.updateBloudStream({video:!1,audio:!0,isScreen:!1},this)}}else yield this.unpublishStream()}))}toggleShareScreen(e,t,r){var i,s,o,n,a;return __awaiter(this,void 0,void 0,(function*(){info("开关共享屏幕","","开关共享屏幕",["stats => ",e]),!e&&(null===(i=this.room)||void 0===i?void 0:i.boomCore.shareScreenStream)&&this.removeFromRecorder(null===(s=this.room)||void 0===s?void 0:s.boomCore.shareScreenStream);const d=null===(o=this.room)||void 0===o?void 0:o.voiceMode;return yield this.room.boomCore.toggleShareScreen(e,{audioHint:d},r).then((()=>{if(info("bmStreamVm toggleShareScreen success","切换共享屏幕","",["enable =>",e,"options =>",JSON.stringify(t)]),e){const e=this.room.boomCore.shareScreenStream;e&&this.remoteStreamPublished(e)}else this.localModel.getUser().removeStream(`${this.localModel.userId}_screen`),this.localModel.getUser().updateSortNum(!0)})).catch((r=>(error$1("bmStreamVm toggleShareScreen error","切换共享屏幕","",["enable =>",e,"options =>",t]),Promise.reject(r)))),e&&(null===(n=this.room)||void 0===n?void 0:n.boomCore.shareScreenStream)&&this.addToRecorder(null===(a=this.room)||void 0===a?void 0:a.boomCore.shareScreenStream),this.localIsShare=e,this.isShareWatcher.next(e),Promise.resolve(!0)}))}setShareScreenContentHint(e){var t;null===(t=this.room)||void 0===t||t.boomCore.setShareScreenContentHint(e)}createCanvas(){const e=document.createElement("canvas");e.id="tarCanvas",e.style.width="1px",e.style.height="1px",e.style.position="absolute",e.style.bottom="0",document.body.appendChild(e)}canvasDisplay(){let e=document.getElementById("tarCanvas");if(e){e.width=640,e.height=360;let t=e.getContext("2d");t.fill(),t.beginPath(),t.fillStyle="rgb(0,0,0)",t.fillRect(0,0,e.width,e.height),this.canvasTimer&&clearTimeout(this.canvasTimer),this.canvasTimer=setTimeout((()=>{this.canvasDisplay()}),1e3)}}static getCanvasStream(){return document.getElementById("tarCanvas").captureStream()}createVideoStream(){var e;return __awaiter(this,void 0,void 0,(function*(){return yield this.room.initDevices(),null===(e=this.videoStream)||void 0===e||e.destroy(),this.videoStream=yield this.room.createPBSingleLocalStream({video:!0,audio:!1},this.localModel.userId).catch((e=>Promise.reject(ar("视频")))),this.videoStream.getVideoTrack()}))}startRecord(e){var t;return __awaiter(this,void 0,void 0,(function*(){if(this._recorder)return;this._recorder=null===(t=this.room)||void 0===t?void 0:t.boomCore.createRecorder(e),this._recorder.on("track-ended",(()=>{this.stopRecord(),info("record ended")})),this._recorder.on("started",(()=>{info("record started.")}));let r=!0;try{yield this._recorder.start(),this._isRecording=!0,this.isRecordingWatcher.next(!0),this.shareStreamModels.forEach((e=>{e.stream&&!e.stream.isLocalStream()&&e.stream.isSubscribed()&&this.addToRecorder(e.stream)})),this.streamModels.forEach((e=>{e.stream&&!e.stream.isLocalStream()&&e.stream.isSubscribed()&&this.addToRecorder(e.stream)}))}catch(e){let t=this._recorder;this._recorder=void 0,this._isRecording=!1,this.isRecordingWatcher.next(!1),r=!1,yield t.stop()}return r}))}addToRecorder(e){this._isRecording&&!this._slicingRecord&&(e.on("audio-track-ended",(()=>{this.removeFromRecorder(e)})),this._recorder.addStream(e))}removeFromRecorder(e){this._isRecording&&!this._slicingRecord&&this._recorder.removeStream(e)}stopRecord(){return __awaiter(this,void 0,void 0,(function*(){this._recorder&&(this._isRecording=!1,this.isRecordingWatcher.next(!1),yield this._recorder.stop(),this._recorder=void 0)}))}sliceRecord(e){var t;return __awaiter(this,void 0,void 0,(function*(){if(!this._isRecording)return;let r=this._recorder._opts;this._slicingRecord=!0;try{yield this._recorder.stop()}catch(e){error$1("stop record exception","","",[JSON.stringify(e)])}r.filename=e,this._recorder=null===(t=this.room)||void 0===t?void 0:t.boomCore.createRecorder(r),this._recorder.on("track-ended",(()=>{this.stopRecord(),info("record ended.")})),this._recorder.on("started",(()=>{info("record started.")}));let i=!0;try{yield this._recorder.start(),this._slicingRecord=!1,this.shareStreamModels.forEach((e=>{e.stream&&!e.stream.isLocalStream()&&e.stream.isSubscribed()&&this.addToRecorder(e.stream)})),this.streamModels.forEach((e=>{e.stream&&!e.stream.isLocalStream()&&e.stream.isSubscribed()&&this.addToRecorder(e.stream)}))}catch(e){let t=this._recorder;this._recorder=void 0,this._isRecording=!1,this.isRecordingWatcher.next(!1),this._slicingRecord=!1,i=!1,yield t.stop()}return i}))}startSpeakerDetector(){var e;this._speaker=null,this._speakerDetector=null===(e=this.room)||void 0===e?void 0:e.boomCore.createSpeakerDetector(),this._speakerDetector.on("speaker",(e=>{var t,r,i;let s=!0;e?((null===(t=this._speaker)||void 0===t?void 0:t.getUserInfo().userId)===e.getUser().userId&&(s=!1),this._speaker=e.getUser()):(this._speaker||(s=!1),this._speaker=null),s&&(info("当前讲话人","语音激励",null===(r=this._speaker)||void 0===r?void 0:r.userId,["nickname => ",null===(i=this._speaker)||void 0===i?void 0:i.nickname]),this.speakerWatcher.next(this._speaker))}))}addToDetector(e){this._speakers.set(e.getID(),e),this._speakerDetector&&this._speakerDetector.addStream(e)}removeFromDetector(e){let t=this._speakers.get(e);this._speakerDetector&&t&&(this._speakers.delete(e),this._speakerDetector.removeStream(t))}clearDetector(){const e=[];this._speakers.forEach(((t,r)=>{e.push(r)})),e.forEach((e=>{this.removeFromDetector(e)}))}shareCustomMedia(e,t){var r;return __awaiter(this,void 0,void 0,(function*(){return null===(r=this.room)||void 0===r?void 0:r.boomCore.shareHTMLMedia(e,t)}))}updateBloudStreamCustomStats(e,t,r){var i;return null===(i=this.room)||void 0===i?void 0:i.boomCore.updateStream(e,t,r)}checkStreamStats(e){info("check stream stats","","",[e]),this.streamModels.size<100&&this.streamModels.forEach((e=>{e.checkStreamIsPlaying()}))}clearCache(){var e,t,r,i,s;try{null===(t=null===(e=this.localModel)||void 0===e?void 0:e.stream)||void 0===t||t.destroy(),null===(r=this.videoStream)||void 0===r||r.destroy(),null===(i=this.audioStream)||void 0===i||i.destroy()}catch(e){}this.streamModels.clear(),this.shareStreamModels.clear(),null===(s=this.room)||void 0===s||s.userVM.clearUsers(),this.shareBloudStateMap.clear()}}class BMRoomInfo{constructor(){this.room=null,this._roomName="",this.msgSeq="",this.roomID="",this.audioOff=!1,this.selfopenaudio=!1,this.lock=!1,this.leaveNotice=!1,this.openSelf=!1,this.chatNotice="",this.chatNoticeRich="",this.raiseHandsList=new Map,this.raiseHandsWatcher=new BehaviorSubject(Array.from(this.raiseHandsList.values())),this.raiseVideoHandsList=new Map,this.raiseVideoHandsWatcher=new BehaviorSubject(Array.from(this.raiseVideoHandsList.values())),this.raiseSimpleHandsList=new Map,this.raiseSimpleHandsWatcher=new BehaviorSubject(Array.from(this.raiseSimpleHandsList.values())),this.operationPermissionWatcher=new Subject,this.chatNoticeWatcher=new Subject,this.totalUserWatcher=new BehaviorSubject(0),this.totalWaitRoomUserWatcher=new BehaviorSubject(0),this.isOpenWaitRoom=new Subject,this.audioOffWatcher=new Subject,this.lockWatcher=new BehaviorSubject(this.lock),this.leaveNoticeWatcher=new BehaviorSubject(this.leaveNotice),this.openSelfWatcher=new BehaviorSubject(this.openSelf),this.setRaiseHandsWatcherValue=debounce((()=>{this.raiseHandsWatcher.next(Array.from(this.raiseHandsList.values()))}),1e3),this.setVideoRaiseHandsWatcherValue=debounce((()=>{this.raiseVideoHandsWatcher.next(Array.from(this.raiseVideoHandsList.values()))}),1e3),this.setSimpleRaiseHandsWatcherValue=debounce((()=>{this.raiseSimpleHandsWatcher.next(Array.from(this.raiseSimpleHandsList.values()))}),1e3),BoomEmitter.emitter.on(RAISE_HAND,(e=>{"raiseHandsAudio"===e.status?e.user.raiseAudioHands?this.addRaiseHandUser(e.user):this.removeRaiseHandUser(e.user.userId):"raiseHandsVideo"===e.status?e.user.raiseVideoHands?this.addVideoRaiseHandUser(e.user):this.removeVideoRaiseHandUser(e.user.userId):"raiseHand"===e.status&&(e.user.raiseHand?this.addSimpleRaiseHandUser(e.user):this.removeSimpleRaiseHandUser(e.user.userId))}))}get roomName(){return this._roomName||(this._roomName=this.room.getName()),this._roomName}get isBigRoom(){return this.room.isBig}setup(e){this.roomID=e.room,this.handleInitParams()}bindRoom(e){this.room=e}initCustomStats(e){this.operationPermission=e,void 0!==e.chatNotice&&(this.chatNotice=e.chatNotice),void 0!==e.chatNoticeRich&&(this.chatNoticeRich=e.chatNoticeRich),this.operationPermissionWatcher.next(this.operationPermission)}updateOperationPermission(e){this.operationPermission=Object.assign(Object.assign({},this.operationPermission),e),void 0!==e.chatNotice&&(this.chatNotice=e.chatNotice),void 0!==e.chatNoticeRich&&(this.chatNoticeRich=e.chatNoticeRich),this.operationPermissionWatcher.next(this.operationPermission)}handleInitParams(){const e=this.room.boomCore.getAudioOff(),t=this.room.boomCore.getSelfOpenAudio();this.setAudioOff(e,t)}setAudioOff(e,t){this.audioOff=e,this.selfopenaudio=t,this.audioOffWatcher.next({audioOff:e,selfopenaudio:t})}setlock(e){this.lock=e,this.lockWatcher.next(e)}setLeaveNotice(e){this.leaveNotice=e,this.leaveNoticeWatcher.next(e)}setRaiseHandsList(e){e.forEach((e=>{e.raiseAudioHands&&this.raiseHandsList.set(e.getID(),e),e.raiseVideoHands&&this.raiseVideoHandsList.set(e.getID(),e),e.raiseHand&&this.raiseSimpleHandsList.set(e.getID(),e)})),this.setRaiseHandsWatcherValue(),this.setVideoRaiseHandsWatcherValue(),this.setSimpleRaiseHandsWatcherValue()}addRaiseHandUser(e){this.raiseHandsList.set(e.getID(),e),this.setRaiseHandsWatcherValue()}removeRaiseHandUser(e){this.raiseHandsList.delete(e),this.setRaiseHandsWatcherValue()}addVideoRaiseHandUser(e){this.raiseVideoHandsList.set(e.getID(),e),this.setVideoRaiseHandsWatcherValue()}removeVideoRaiseHandUser(e){this.raiseVideoHandsList.delete(e),this.setVideoRaiseHandsWatcherValue()}addSimpleRaiseHandUser(e){this.raiseSimpleHandsList.set(e.getID(),e),this.setSimpleRaiseHandsWatcherValue()}removeSimpleRaiseHandUser(e){this.raiseSimpleHandsList.delete(e),this.setSimpleRaiseHandsWatcherValue()}}var name="@hysc/meeting",version="10.0.10",description="boom meeting",main="./dist/index.js",module$1="./dist/index.mjs",types="./dist/index.d.ts",files=["dist","umd"],scripts={build:"tsup ./src/index.ts --format cjs,esm --dts --minify",dev:"tsup ./src/index.ts --format esm,cjs --watch --dts"},author="yangliye",license="MIT",dependencies={"@hysc/bloud":"workspace:*","@hysc/core":"workspace:*","lodash-es":"^4.17.21",mitt:"^3.0.0","@hysc/p-queue":"6.3.0",rxjs:"^7.5.5",typescript:"^4.6.3","@hysc/utils":"workspace:*"},peerDependencies={"@hysc/core":"workspace:*"},devDependencies={"@types/lodash-es":"^4.17.6","@hysc/brtc":"workspace:*"},PackageJson={name:name,version:version,description:description,private:!1,main:main,module:module$1,types:types,files:files,scripts:scripts,author:author,license:license,dependencies:dependencies,peerDependencies:peerDependencies,devDependencies:devDependencies};class BMLiveVM{constructor(e){this.room=e}get localBMUser(){return this.room.getLocalParticipant()}get localIsAudience(){return this.room.getLocalParticipant().isAudience}handlePull(e){return __awaiter(this,void 0,void 0,(function*(){this.localIsAudience&&!this.localBMUser.audienceEnableSpeaking?e.isMixer&&(yield this.room.handlePull(e)):yield this.room.handlePull(e)}))}handleChangeStreamType(e){return __awaiter(this,void 0,void 0,(function*(){yield this.room.handleChangeStreamType(e)}))}handlePlay(e,t){return __awaiter(this,void 0,void 0,(function*(){this.localIsAudience&&!this.localBMUser.audienceEnableSpeaking?e.isMixer&&(yield this.room.handlePlay(e,t,!1)):yield this.room.handlePlay(e,t,!0)}))}handleAudienceDisable(){return __awaiter(this,void 0,void 0,(function*(){this.room.bmStreamVm.getStreamModels().forEach((e=>{var t;(null===(t=null==e?void 0:e.stream)||void 0===t?void 0:t.isSubscribed())&&e.hasPulled&&(e.hasPulled=!1,e.pulledStreamType="small",this.room.unsubscribe(e.stream).then((()=>{console.log("观众取消订阅这股流",e.userId,e.nickname,e.isDisplay,e.isCurrentDisplay)})))}));const e=this.room.bmStreamVm.mixStreamModelWatcher.getValue();e&&(yield this.handlePlay(e,!1))}))}handleAudienceEnable(){return __awaiter(this,void 0,void 0,(function*(){const e=this.room.bmStreamVm.mixStreamModelWatcher.getValue();e&&(yield this.handlePlay(e,!1)),this.room.bmStreamVm.getStreamModels().forEach((e=>{streamPullQueue.addQueue(this.room.handleQueueTask.bind(this,e),e.streamId,0,e.nickname)}))}))}}function addBrtcNetEvent(e){var t,r;null===(t=e.brtcClient.client)||void 0===t||t.signal.channel.on("reconnecting",(()=>e.fire(dt$1.BRTC_ROOM_ROCONNECTING))),null===(r=e.brtcClient.client)||void 0===r||r.signal.channel.on("reconnected",(()=>e.fire(dt$1.BRTC_ROOM_RECONNECTED)))}class SingletonQueue{constructor(){return this.pullMap=new Map,SingletonQueue.instance?SingletonQueue.instance:(SingletonQueue.instance=this,this)}addUsers(e){e.forEach((e=>{e.isScreen?this.pullMap.set(`${e.id}_screen`,e):this.pullMap.set(e.id,e)})),this._callback&&this._callback(this.pullMap)}removeUsers(e){e.forEach((e=>{e.isScreen?this.pullMap.delete(`${e.id}_screen`):this.pullMap.delete(e.id)}))}restart(){if(!this._callback)throw error$1("no callback exists in streamQueue please setQueueProcessor first!"),new Error("no callback");this._callback(this.pullMap)}setQueueProcessor(e){this._callback=e}removeQueueProcessor(){this._callback=void 0}}class AudioPlay{constructor(e,t){this.playMap=new WeakSet,this.playerMap=new Map,this.muted=!1,this.playStateChangeWatcher=new Subject;const r=document.getElementById(e);if(!r)throw new Error("no container found, play failed");this.container=r,this.room=t}addStream(e,t=!1){this.room.shouldPlayAudio&&this.room.autoPlayAudio&&e.isSubscribed()&&(this.playMap.has(e)&&!t||(info("add stream to player","",e.getUserId(),["streamId ",e.getStreamId()]),this.playMap.add(e),this.play(e)))}removeStream(e){const t=e.getStreamId();let r=this.playerMap.get(t);r&&(r.off(),r.destroy()),info("remove audio player","","",["streamId =>",t]),this.playerMap.delete(t),this.playMap.delete(e)}removeStreamByUid(e){let t=new Map;this.playerMap.forEach((r=>{isShareStream(r.stream)||r.stream.getUserId()===e&&t.set(r.stream.getStreamId(),r)})),t.forEach(((e,t)=>{e.off(),e.destroy(),this.playerMap.delete(t),this.playMap.delete(e.stream)})),t.clear()}play(e){var t;return __awaiter(this,void 0,void 0,(function*(){if(e.hasAudio()&&this.container){const r=new _(this.container,{});if(this.addPlayerEvent(r),yield r.play(e),this.deviceId&&(yield r.setSinkId(this.deviceId)),this.muted)r.setVolume(0);else{let i;const s=transShareScreen2User(e.getUserId().toString());if(i=isShareStream(e)?this.room.bmStreamVm.shareStreamModels.get(s):this.room.bmStreamVm.streamModels.get(s),i){const e=null===(t=i.bloudStream)||void 0===t?void 0:t.customInfo;e&&e.volume&&(r.audioLevel=e.volume,r.setVolume(e.volume))}}this.playerMap.set(e.getStreamId(),r)}}))}mute(e){this.muted=e,e?this.playerMap.forEach((e=>e.setVolume(0))):this.playerMap.forEach((e=>{e.audioLevel>0?e.setVolume(e.audioLevel):e.setVolume(1)}))}setVolume(e,t){const r=this.playerMap.get(e);if(r){if(r.audioLevel=t,this.muted)return;r.setVolume(t)}else error$1("设置了流的音量,但是没有找到对应的播放器",e)}setDevice(e,t=!1){return __awaiter(this,void 0,void 0,(function*(){this.deviceId=e,t&&(yield sleep(2e3)),this.playerMap.forEach((t=>__awaiter(this,void 0,void 0,(function*(){yield t.setSinkId(e)}))))}))}addPlayerEvent(e){e.on("player-state-changed",(t=>{e.stream&&(info("audio player state change","","",[JSON.stringify(t)]),"error"===t.type&&t.reason&&"NotAllowedError"===t.reason.name&&this.playStateChangeWatcher.next(e),"PAUSED"===t.state&&e.resume())}))}clear(){info("audio play clear"),this.playerMap.forEach((e=>e.destroy())),this.playerMap.clear(),this.playMap=new WeakSet}destroy(){info("audio play destroy"),this.playerMap.forEach((e=>e.destroy())),this.playerMap.clear(),this.playMap=new WeakSet}}let _selfSortType=1;const subscribeOptions={audio:!0,video:!0,streamType:"small",videoEnable:!0,audioEnable:!0};let autoPlayAudio=!0;class BMRoom{constructor({initDevices:e}={initDevices:!0}){this.roomVM=null,this.videoDevices=[],this.audioDevices=[],this.audioOutputDevices=[],this.selectVideoDevice=null,this.selectAudioDevice=null,this.selectAudioOutputDevice=null,this.streamQueue=new SingletonQueue,this.userListColumns=1,this.sortType=1,this.BRTCConnectFailed=!1,this.pubFailedNum=0,this.streamConnectedErrorQueue=[],this.conferenceMode=1,this.isBig=!1,this.selectVideoDeviceWatcher=new BehaviorSubject(this.selectVideoDevice),this.selectAudioDeviceWatcher=new BehaviorSubject(this.selectAudioDevice),this.selectAudioOutputDeviceWatcher=new BehaviorSubject(this.selectAudioOutputDevice),this.audioDevicesWatcher=new Subject,this.videoDevicesWatcher=new Subject,this.audioOutputDevicesWatcher=new Subject,this.raiseHandleRespWatcher=new Subject,this.enableAudienceSpeakingWatcher=new Subject,this.mediaPermission={microphone:!0,camera:!0,screen:!0},this.videoProfile="360p",this.audioProfile=null,this.voiceMode="",this.streamWSReconnectWatcher=new Subject,this.bloudWSReconnectWatcher=new Subject,this.netConnecting=!0,this.netConnectingWatcher=new Subject,this.hasSyncPermission=!0,this.meetingControlOptions={cancelAutoPull:!1},this.forceId="",this.networkState={bloud:!0,brtc:!0},this.brtcNetEnableWatcher=new Subject,this.autoPlayAudio=!0,this.pubFailedTimer=null,this.messageWatcher=new BehaviorSubject({type:MessageType.INIT,status:!1,isNotCancelRootReport:!1}),this.isInWaitRoom=!1,this.shouldPlayAudio=!0,this.handleReprocessStreamError=()=>{this.netConnecting&&this.networkState.brtc&&this.networkState.bloud&&this.streamConnectedErrorQueue.length&&(info("brtc 网络恢复正常,处理重推逻辑","","",this.streamConnectedErrorQueue),this.streamConnectedErrorQueue.forEach((e=>{this.handleStreamConnectError(e)})),this.streamConnectedErrorQueue=[])},this.handleMediaDevicesChange=debounce((()=>__awaiter(this,void 0,void 0,(function*(){const e=this.filterDevice(this.audioDevices);yield this.bmStreamVm.changeAudioInput(e);const t=this.filterDevice(this.audioOutputDevices);yield this.bmStreamVm.changeSpeaker(t,!0)}))),1e3),this.enumVideoDevices=gt,this.enumAudioInputDevices=mt,this.enumAudioOutputDevices=pt,this.getPermissions=bt,this.checkSystemSupport=ft,this.createStream=yt,this.participantNotice=!1,this.handleQueueTask=(e,t=!1)=>__awaiter(this,void 0,void 0,(function*(){this.BRTCConnectFailed||(e.isLocal||!this.meetingControlOptions.cancelAutoPull||e.shouldPull)&&(this.streamModelExits(e)?yield this.handleStreamTask(e,t):warn(`streamModel is not exits, userId: ${e.userId}, isShare: ${e.isShare}, ignore`))})),this.republishLocalStream=debounce((e=>__awaiter(this,void 0,void 0,(function*(){const t=e.getAudioOn()||!1,r=e.getVideoOn()||!1;info("republish local stream ","","",[t,r]),(t||r)&&(yield this.publish(e).then((()=>__awaiter(this,void 0,void 0,(function*(){this.bmStreamVm.bloudStream=null,yield this.bmStreamVm.publishBloudStream(t,r),info("local stream connect error, and republish success, bloud stream republish success","","",["audio =>",t," video => ",r]),this.bmStreamVm.localStreamConnectErrorWatcher.next(Rr$1(t,r))})))).catch((()=>{info("local stream connect error, and republish failed","","",["audio =>",t," video => ",r]),this.bmStreamVm.localStreamConnectErrorWatcher.next(yr$1())})))}))),1e3),this.processUser=e=>__awaiter(this,void 0,void 0,(function*(){const t=new Set;if(e.forEach((e=>{if(e.isScreen){const r=this.bmStreamVm.getShareStreamModelByUId(e.id);r&&r.stream||(e.isWeb?t.add(`${e.id}_screen`):t.add(e.id))}else{let r=this.bmStreamVm.streamModels.get(e.id);r&&!r.stream&&t.add(e.id)}})),info("brtc query streams","","",["queryIds => ",JSON.stringify(Array.from(t))]),t.size)try{const e=yield this.queryBrtcStreams(Array.from(t));if(e&&e.length){const t=e.map((e=>[e.getUserId(),e.getStreamId()]));info("brtc query streams result","","",["streamInfo =>",JSON.stringify(t)]),e&&this.handleAddStreams(e)}}catch(e){error$1("query stream error","","",[JSON.stringify(e)])}})),this.queueProcessor=debounce(this.processUser,500,{maxWait:1e3}),kt$1.setLogLevel(se.INFO),info(`\n******************************************************************************\n* 欢迎使用 BoomCore(${PackageJson.version})\n******************************************************************************\n `),kt$1.info("this is formatted by hysc/logger module");const t=BoomEmitter.getInstance();this.localUser=new BMUser({},!0),this.roomInfo=new BMRoomInfo,this.roomInfo.bindRoom(this),this.bmLiveVM=new BMLiveVM(this),this.bmStreamVm=(new BMStreamModelVM).initWithRoom(this),this.boomCore=new St({}),t.on(RECEIVE_SUBSCRIBE_MESSAGE,(e=>{this.handleSubMessage(e)})),t.on(HANDLE_STREAM_CONNECT_ERROR,(e=>{this.handleStreamConnectError(e)})),t.on(ADD_PULL_USER,(e=>{this.addUser2Queue(e)})),t.on(MANUAL_SUBSCRIPTION,(e=>{this.manualSubscribeStreamModel(e.stream)})),t.on(UNSUBSCRIBE_STREAM,(e=>{this.handleUnsubscribe(e.stream)})),t.on(BIND_ELEMENT,(e=>{this.handleStreamBindElement(e.stream)})),t.on(BIND_BIG_ELEMENT,(e=>{this.handleStreamBindBigElement(e.stream)})),t.on(SET_VOLUME,(e=>{var t;null===(t=this.audioPlayer)||void 0===t||t.setVolume(e.streamId,e.volume)})),t.on(ADD_AUDIO_PLAY,(e=>{const t=e.stream.stream;t&&!t.isLocalStream()&&(this.audioPlayer.playMap.has(t)||this.audioPlayer.addStream(t))})),window.addEventListener("offline",(()=>{this.netConnecting=!1,this.netConnectingWatcher.next(!1)})),window.addEventListener("online",(()=>{this.netConnecting=!0,this.netConnectingWatcher.next(!0),NETWORK_ERROR_QUEUE.forEach((e=>{e()})),NETWORK_ERROR_QUEUE.clear(),this.handleReprocessStreamError()})),window.navigator.mediaDevices&&e&&(window.navigator.mediaDevices.ondevicechange=e=>__awaiter(this,void 0,void 0,(function*(){info("media devices change","","",[JSON.stringify(e)]),yield this.initDevices(),yield this.handleMediaDevicesChange()})),this.initDevices()),this.streamQueue.setQueueProcessor(this.queueProcessor),this.brtcNetEnableWatcher.subscribe((e=>{e&&this.handleReprocessStreamError()})),this.bloudWSReconnectWatcher.subscribe((e=>{e&&this.handleReprocessStreamError()}))}setVoiceMode(e){this.voiceMode=e}get isSingleColumns(){return 1===this.userListColumns}setAutoPlayAudio(e){this.autoPlayAudio=e,autoPlayAudio=e}setMediaPermission(e){this.mediaPermission=Object.assign(Object.assign({},this.mediaPermission),e),info("current media permission is ","","",[JSON.stringify(this.mediaPermission)])}setShouldPlayAudio(e){this.shouldPlayAudio=e}initAudioPlayer(e){info("init audio player"),this.audioPlayer=new AudioPlay(e,this)}setupMeetingControlOptions(e){e&&(this.meetingControlOptions=Object.assign(Object.assign({},this.meetingControlOptions),e))}handleSubMessage(e){streamPullQueue.addQueue(this.handleQueueTask.bind(this,e.stream),`${e.stream.streamId} - 订阅流 - display ${e.stream.isDisplay} - currentDisplay - ${e.stream.isCurrentDisplay}`,0,e.stream.nickname)}setVideoProfile(e){e&&(info(`set video profile ${e} `),this.videoProfile=e)}setUserListColumns(e){const t=toNumber(e);if(!isNumber(t))throw new Error("参数必须是数字");this.userListColumns=t}setSortType(e){const t=toNumber(e);if(t>2||t<1)throw new Error("排序映射只能为 2 或者 1");this.sortType=t,_selfSortType=this.sortType}setAudioProfile(e){this.audioProfile=e}setSig(e){this.boomCore.setShareSig(e)}initDevices(){return __awaiter(this,void 0,void 0,(function*(){return Promise.all([this.enumVideoDevices().then((e=>{this.videoDevices=e,this.videoDevicesWatcher.next(e)})),this.enumAudioInputDevices().then((e=>{this.audioDevices=e,this.audioDevicesWatcher.next(e)})),this.enumAudioOutputDevices().then((e=>{this.audioOutputDevices=e,this.audioOutputDevicesWatcher.next(e)}))]).then((()=>{let e=this.videoDevices.filter((e=>{var t;return e.name==(null===(t=this.selectVideoDevice)||void 0===t?void 0:t.name)}));const t=e[0]?e[0]:this.filterDevice(this.videoDevices);t&&this.setSelectVideoDevice(t);let r=this.audioDevices.filter((e=>{var t;return e.name==(null===(t=this.selectAudioDevice)||void 0===t?void 0:t.name)}));const i=r[0]?r[0]:this.filterDevice(this.audioDevices);i&&this.setSelectAudioDevice(i);let s=this.audioOutputDevices.filter((e=>{var t;return e.name==(null===(t=this.selectAudioOutputDevice)||void 0===t?void 0:t.name)}));const o=s[0]?s[0]:this.filterDevice(this.audioOutputDevices);return o&&this.setSelectSpeakerDevice(o),{videoDevices:this.videoDevices,audioDevices:this.audioDevices,audioOutputDevices:this.audioOutputDevices,selectVideoDevice:this.selectVideoDevice,selectAudioDevice:this.selectAudioDevice,selectAudioOutputDevice:this.selectAudioOutputDevice}}))}))}filterDevice(e){const t=e.filter((e=>e.default))[0];return t||e[0]}setSelectAudioDevice(e){var t;(null===(t=this.selectAudioDevice)||void 0===t?void 0:t.deviceId)!==e.deviceId&&(info("setSelectAudioDevice","","",["deviceId =>",e.deviceId,"name =>",e.name]),this.selectAudioDevice=e,this.selectAudioDeviceWatcher.next(e))}setSelectVideoDevice(e){var t;(null===(t=this.selectVideoDevice)||void 0===t?void 0:t.deviceId)!==e.deviceId&&(info("setSelectVideoDevice","","",["deviceId =>",e.deviceId,"name =>",e.name]),this.selectVideoDevice=e,this.selectVideoDeviceWatcher.next(e))}setSelectSpeakerDevice(e){var t;(null===(t=this.selectAudioOutputDevice)||void 0===t?void 0:t.deviceId)!==e.deviceId&&(info("setSelectSpeakerDevice","","",["deviceId =>",e.deviceId,"name =>",e.name]),this.selectAudioOutputDevice=e,this.selectAudioOutputDeviceWatcher.next(e))}observe(e,t){return this.observes[e].subscribe(t)}join(e){return __awaiter(this,void 0,void 0,(function*(){const t=e.brtc_host;t&&this.setCustomUrl(t);try{if(this.boomCore.client)return error$1("重复 join,请先调用 destroy"),Promise.reject(vn);this.conferenceMode=e.roomType,this.isBig=e.is_big,info("========================","join info",e.userId,["roomId: ",e.room," roomType: ",e.roomType," roomName: ",e.name]),this.localUser.setup(e.userId,e.userinfo,e.nickname),this.bmStreamVm.createStreamModel(this.localUser),this.userVM=new BMUserVM(this.boomCore,this.localUser,this),this.isBig&&(this.userVM.commTimer=1e3),this.roomVM=new BMRoomVM(this.boomCore,this.userVM,this.roomInfo),this.roomVM.initWithRoom(this),this.chatVM=new BMChatVM(this.boomCore,this.userVM,this),this._attachEvents(),yield this.boomCore.join(e).catch((e=>Promise.reject(e))),this.roomInfo.setup(this.boomCore.getRoomInfo());for(let e in this.observes)this.observe(e,(()=>{}));this.bmStreamVm.startSpeakerDetector(),this.roomInfo.setlock(this.boomCore.client.lock),addBrtcNetEvent(this.boomCore)}catch(e){return error$1("join room error","","",[JSON.stringify(e)]),Promise.reject(e)}}))}leave(){var e,t;return __awaiter(this,void 0,void 0,(function*(){try{this.pubFailedTimer&&clearTimeout(this.pubFailedTimer),this.pubFailedNum=0,BoomEmitter.removeEmitter(),autoPlayAudio=!0,null===(e=this.audioPlayer)||void 0===e||e.destroy(),this.bmStreamVm.clearCache(),this.bmStreamVm.canvasTimer&&clearTimeout(this.bmStreamVm.canvasTimer);const r=yield this.boomCore.leave().catch((()=>{error$1("bloud离会失败")}));for(let e in this.observes)null===(t=this.observes[e])||void 0===t||t.unsubscribe();return this.observes={},r}catch(e){return error$1("leave room error","","",[JSON.stringify(e)]),Promise.reject(Hn(JSON.stringify(e)))}}))}releaseRoom(){return __awaiter(this,void 0,void 0,(function*(){yield this.boomCore.releaseRoom()}))}startRecord(e){return __awaiter(this,void 0,void 0,(function*(){return yield this.bmStreamVm.startRecord(e)}))}stopRecord(){return __awaiter(this,void 0,void 0,(function*(){return yield this.bmStreamVm.stopRecord()}))}sliceRecord(e){return __awaiter(this,void 0,void 0,(function*(){return yield this.bmStreamVm.sliceRecord(e)}))}close(){this.bmStreamVm.clearCache(),this.boomCore.close()}setRemoteVideoEnable(e,t){return __awaiter(this,void 0,void 0,(function*(){yield this.roomVM.setRemoteVideoEnable(e,t).catch((e=>Promise.reject(e)))}))}setRemoteAudioEnable(e,t,r){return __awaiter(this,void 0,void 0,(function*(){yield this.roomVM.setRemoteAudioEnable(e,t,r).catch((e=>Promise.reject(e)))}))}setLocalVideoEnable(e,t){return __awaiter(this,void 0,void 0,(function*(){yield this.bmStreamVm.setLocalVideoEnable(e,t).catch((e=>Promise.reject(e)))}))}setLocalAudioEnable(e){return __awaiter(this,void 0,void 0,(function*(){yield this.bmStreamVm.setLocalAudioEnable(e).catch((e=>Promise.reject(e)))}))}setLocalSpeakerEnable(e){return __awaiter(this,void 0,void 0,(function*(){yield this.bmStreamVm.muteSpeaker(e).catch((e=>Promise.reject(e)))}))}_attachEvents(){this.observes=attachEvents(this.boomCore,this.userVM,this.bmStreamVm,this.chatVM,this)}createSingleLocalStream(e={video:!0,audio:!0},t){var r,i;return __awaiter(this,void 0,void 0,(function*(){const s={video:e.video,audio:e.audio,cameraId:null===(r=this.selectVideoDevice)||void 0===r?void 0:r.deviceId,microphoneId:null===(i=this.selectAudioDevice)||void 0===i?void 0:i.deviceId,sourceType:"camera"};e.videoSource&&(s.videoSource=e.videoSource),e.audioSource&&(s.audioSource=e.audioSource),s.echoCancellation=!0,s.noiseSuppression=!0,s.autoGainControl=!0,this.voiceMode&&(s.audioHint=this.voiceMode,s.noiseSuppression=!1);const o=yield this.boomCore.createLocalStream(s,t).catch((t=>(error$1("create brtc stream error","","",[JSON.stringify(t),null==t?void 0:t.message]),Promise.reject(pr$1(e.video?"摄像头":"麦克风")))));e.video&&("720p"===this.videoProfile?o.setVideoEncoderConfiguration({width:1280,height:720,bitrate:1500,frameRate:25}):o.setVideoProfile(this.videoProfile));try{yield o.init()}catch(t){if(error$1("brtc init stream failed","","",[null==t?void 0:t.message]),String(t).includes("Permission denied by system")){if(e.video)return Promise.reject(Er$1());if(e.audio)return Promise.reject(Sr$1())}else{if(String(t).includes("Could not start video source"))return Promise.reject(gr$1());if(String(t).includes("Could not start audio source"))return Promise.reject(Tr$1())}return Promise.reject(ar(e.video?"摄像头":"麦克风"))}return o}))}createPBSingleLocalStream(e={video:!0,audio:!0},t){var r,i;return __awaiter(this,void 0,void 0,(function*(){const s={video:e.video,audio:e.audio,cameraId:null===(r=this.selectVideoDevice)||void 0===r?void 0:r.deviceId,microphoneId:null===(i=this.selectAudioDevice)||void 0===i?void 0:i.deviceId,sourceType:"camera",echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0};this.voiceMode&&(s.audioHint=this.voiceMode,s.noiseSuppression=!1);const o=yield this.boomCore.createPBLocalStream(s,t).catch((e=>Promise.reject(e)));return"720p"===this.videoProfile?o.setVideoEncoderConfiguration({width:1280,height:720,bitrate:1500,frameRate:25}):o.setVideoProfile(this.videoProfile),yield o.init(),o}))}subscribe(e,t){return __awaiter(this,void 0,void 0,(function*(){return this.boomCore.subscribe(e,t)}))}unsubscribe(e){return this.boomCore.unsubscribe(e).catch((e=>Promise.reject(e)))}publish(e){return new Promise(((t,r)=>{this.boomCore.publish(e).then((()=>{info("brtc stream publish success"),t(!0)})).catch((()=>__awaiter(this,void 0,void 0,(function*(){this.pubFailedNum<=3?(this.pubFailedNum+=1,this.pubFailedTimer&&clearTimeout(this.pubFailedTimer),this.pubFailedTimer=setTimeout((()=>(error$1(`local publish stream failed, retry failed num: ${this.pubFailedNum}`),this.publish(e).then(t).catch(r))),3e3)):(error$1("retry publish local stream failed, ubpublish now"),yield this.bmStreamVm.unpublishStream(),r(!1))}))))}))}unpublish(e){return this.boomCore.unpublish(e).catch((e=>Promise.reject(e)))}getUser(e){return this.userVM.getUser(e)}changeMaster(e,t=!1){var r;return __awaiter(this,void 0,void 0,(function*(){return null===(r=this.roomVM)||void 0===r?void 0:r.changeMaster(e,t).catch((e=>e))}))}updateManager(e,t,r=!0){return __awaiter(this,void 0,void 0,(function*(){return this.roomVM.updateManager(e,t,r).catch((e=>e))}))}getMaster(){return this.boomCore.getMaster()}getCreator(){return this.boomCore.getCreator()}getName(){return this.boomCore.getName()}evictUser(e,t){var r;return __awaiter(this,void 0,void 0,(function*(){yield null===(r=this.roomVM)||void 0===r?void 0:r.evictUser(e,t).catch((e=>e))}))}updateUser(e,t){var r;return __awaiter(this,void 0,void 0,(function*(){null===(r=this.roomVM)||void 0===r||r.updateUser(e,t).catch((e=>e))}))}getMsgSeq(){return this.boomCore.getMsgSeq()}getLimits(){return this.boomCore.getLimits()}getSwitch(){return this.boomCore.getSwitch()}syncRoom(){return this.boomCore.syncRoom()}update(e){return this.boomCore.update(e)}getUsers(){return this.userVM.userList}getTotalUsers(){return this.userVM.userList.size}sendMessage(e,t){return this.boomCore.sendMessage(e,t)}customMessage(e,t){return this.boomCore.customMessage(e,t)}getMessages(e,t){return this.boomCore.getMessages(e,t)}getLocalParticipant(){var e;let t=null===(e=this.userVM)||void 0===e?void 0:e.getLocalUser();return t||(t=this.localUser),t}getAudioOff(){return this.boomCore.getAudioOff()}getSelfOpenAudio(){return this.boomCore.getSelfOpenAudio()}getVideoOff(){return this.boomCore.getVideoOff()}getMsgOff(){return this.boomCore.getMsgOff()}getLock(){return this.boomCore.getLock()}getRoomInfo(){return this.roomInfo}setAudioOff(e,t){return __awaiter(this,void 0,void 0,(function*(){return yield this.boomCore.setAudioOff(e,t).catch((e=>Promise.reject(er(`boomCore.setAudioOff error ${JSON.stringify(e)}`))))}))}updateRoom(e){return __awaiter(this,void 0,void 0,(function*(){return this.boomCore.client.update(e)}))}setVideoOff(e){return this.boomCore.setVideoOff(e).catch((e=>Promise.reject(nr$1(`boomCore.setVideoOff error ${JSON.stringify(e)}`))))}setMsgOff(e){return this.boomCore.setMsgOff(e).catch((e=>Promise.reject(rr(`boomCore.setMsgOff error ${JSON.stringify(e)}`))))}setSwitch(e){return this.boomCore.setSwitch(e)}setLock(e){return __awaiter(this,void 0,void 0,(function*(){return yield this.boomCore.setLock(e),this.boomCore.getLock()}))}sendChatMessage(e,t,r){if(!this.chatVM)throw new BoomError(INVALID_OPERATION,"未初始化chatVM, 无法发送聊天信息");return this.chatVM.sendMessage(e,t,r)}getChatMessage(){if(!this.chatVM)throw new BoomError(INVALID_OPERATION,"未初始化chatVM, 无法获取聊天室消息");return this.chatVM.messageList}getHistoryMessage(){return __awaiter(this,void 0,void 0,(function*(){return this.chatVM.getHistoryMessage()}))}updateCustomStats(e){return info("updateCustomStats","","",[JSON.stringify(e)]),this.boomCore.updateCustomStats(Object.assign(Object.assign({},e),{pos:"web"})).catch((e=>Promise.reject(or(`.boomCore.updateCustomStats ${JSON.stringify(e)}`))))}getCustomStats(){return this.boomCore.getCustomStats()}getDuration(){return this.boomCore.getDuration()}checkUserHasMaster(e){return this.userVM.checkUserHasMaster(e)}changeNickName(e,t){var r;return __awaiter(this,void 0,void 0,(function*(){yield null===(r=this.roomVM)||void 0===r?void 0:r.changeNickName(e,t)}))}streamModelExits(e){const t=e.userId;return e.isShare?this.bmStreamVm.shareStreamModels.has(t):this.bmStreamVm.streamModels.has(t)}handleStreamTask(e,t=!1){return __awaiter(this,void 0,void 0,(function*(){this.streamModelExits(e)?e.stream?1===this.conferenceMode?(yield this.handlePull(e),yield this.handlePlay(e,t),yield this.handleChangeStreamType(e)):(yield this.bmLiveVM.handlePull(e),yield this.bmLiveVM.handleChangeStreamType(e),yield this.bmLiveVM.handlePlay(e,t)):((e.isDisplay||e.isInBig)&&e.bloudStream||e.audioEnable)&&(yield this.addUser2Queue({id:e.userId,isScreen:e.isShare,isWeb:e.isWeb})):warn(`streamModel is not exits, userId: ${e.userId}, isShare: ${e.isShare}, ignore`)}))}handlePull(e){var t;return __awaiter(this,void 0,void 0,(function*(){e.isLocal||(e.isMixer&&(yield this.handleSubscribeSteam(e)),(e.isDisplay!==e.isCurrentDisplay||e.isInBig&&e.pulledStreamType!==e.pulledStreamGoal||!e.hasPulled)&&(e.isCurrentDisplay=e.isDisplay,e.checkCount=0,e.isDisplay||e.isInBig||!e.isDisplay&&(e.audioEnable||(null===(t=e.stream)||void 0===t?void 0:t.getAudioOn()))?yield this.handleSubscribeSteam(e):yield this.handleUnsubscribeStream(e)))}))}manualSubscribeStreamModel(e){streamPullQueue.addQueue(this.handleStreamTask.bind(this,e),e.streamId,0,e.nickname)}handleUnsubscribe(e){streamPullQueue.addQueue(this.handleUnsubscribeStream.bind(this,e),e.streamId,0,e.nickname)}handleStreamBindElement(e){streamPullQueue.addQueue(this.handlePlay.bind(this,e,!1,!1),`bindElement-${e.userId}-${e.nickname}`,0,e.nickname)}handleStreamBindBigElement(e){streamPullQueue.addQueue(this.handlePlayInBIg.bind(this,e),`bindElement-${e.userId}-${e.nickname}`,0,e.nickname)}handleUnsubscribeStream(e){var t,r,i;return __awaiter(this,void 0,void 0,(function*(){if(e.stream&&((null===(r=null===(t=e.stream)||void 0===t?void 0:t.isSubscribed)||void 0===r?void 0:r.call(t))||e.hasPulled)){e.hasPulled=!1,e.pulledStreamType="small",e.isInBig=!1;try{null===(i=e.stream)||void 0===i||i.stop()}catch(e){}yield this.unsubscribe(e.stream).then((()=>{var t,r;e.stream&&(null===(t=this.audioPlayer)||void 0===t||t.removeStream(e.stream)),e.isSubScribedWatcher.next(!1),info("取消订阅流成功","",e.userId,[e.nickname,e.isDisplay,e.isCurrentDisplay,null===(r=e.stream)||void 0===r?void 0:r.getStreamId()])})).catch((()=>{error$1("unsubscribe error")}))}}))}handleSubscribeSteam(e){var t,r;return __awaiter(this,void 0,void 0,(function*(){try{e.hasPulled&&e.stream.isSubscribed()?e.isDisplay?null===(t=e.stream)||void 0===t||t.unmuteVideo().then((()=>{info("stream unmute video success","unmute-video",e.userId,["streamId => ",e.streamId])})):null===(r=e.stream)||void 0===r||r.muteVideo().then((()=>{info("stream mute video success","mute-video",e.userId,["streamId => ",e.streamId])})):(info("开始订阅","订阅",e.userId,[e.streamId]),e.hasPulled=!0,yield this.subscribe(e.stream,subscribeOptions).then((()=>{var t,r;info("订阅流结束","订阅",e.userId,[" nickname =>",e.nickname,"streamId =>",e.streamId,"display =>",e.isDisplay]),e.isDisplay||null===(t=e.stream)||void 0===t||t.muteVideo(),e.stream&&e.audioEnable&&(null===(r=this.audioPlayer)||void 0===r||r.addStream(e.stream,!0)),e.pullFailedNum=0,e.isSubScribedWatcher.next(!0),this.bmStreamVm.addToRecorder(e.stream),e.isDisplay&&e.videoEnable&&checkStreamIsNormal(e)})).catch((t=>{var r,i;if(error$1("订阅流失败","订阅",e.userId,[" nickname =>",e.nickname,"streamId =>",e.streamId," error => ",JSON.stringify(t)]),e.hasPulled=!1,e.pulledStreamType="small",e.pullFailedNum+=1,null===(r=e.player)||void 0===r||r.destroy(),e.pullFailedNum<=3)this.handlePulledFailed(e);else{e.pullFailedNum=0;const r=e.isShare;try{null===(i=e.stream)||void 0===i||i.destroy()}catch(t){}e.updateStream(void 0,!1,this.bmStreamVm),info("subscribe stream failed, need to reQuery stream","",e.userId,["streamId =>",e.streamId,"hasStream => ",!!e.stream,"isWeb => ",e.isWeb,"isScreen => ",r,"bloudStreamState =>",JSON.stringify(e.bloudStream)]),e.bloudStream&&this.addUser2Queue({id:e.userId,isWeb:e.isWeb,isScreen:r})}})))}catch(t){e.hasPulled=!1,e.pulledStreamType="small",console.error("订阅流失败","",e.userId,e.nickname,"错误 =>",t)}}))}handleChangeStreamType(e){var t,r;return __awaiter(this,void 0,void 0,(function*(){e.isLocal||e.pulledStreamType!==e.pulledStreamGoal&&(null===(t=e.stream)||void 0===t?void 0:t.isSubscribed())&&((null===(r=e.stream)||void 0===r?void 0:r.isSubscribed())||e.hasPulled)&&(e.pulledStreamType=e.pulledStreamGoal,yield this.boomCore.brtcClient.setRemoteVideoStreamType(e.stream,e.pulledStreamGoal).catch((t=>{error$1("大小流切换失败","",e.userId,["error => ",JSON.stringify(t)])})),info("大小流切换结束","",e.userId,["nickname =>",e.nickname," isInBig => ",e.isInBig," pulledStreamGoal => ",e.pulledStreamGoal,"pulledStreamType => ",e.pulledStreamType]))}))}handlePlay(e,t,r=!0){var i,s,o;return __awaiter(this,void 0,void 0,(function*(){this.streamModelExits(e)&&(e.isLocal?e.isShare||t||(yield e.play(),yield e.playInBig()):e.stream&&(null===(i=e.stream)||void 0===i?void 0:i.isSubscribed())&&(t&&!e.isShare||e.play(),e.stream&&e.audioEnable&&((null===(s=this.audioPlayer)||void 0===s?void 0:s.playMap.has(e.stream))||null===(o=this.audioPlayer)||void 0===o||o.addStream(e.stream)),r&&e.playInBig()))}))}handlePlayInBIg(e){return __awaiter(this,void 0,void 0,(function*(){this.streamModelExits(e)&&(yield e.playInBig())}))}handlePulledFailed(e){const t=e.userId;(e.isShare?this.bmStreamVm.shareStreamModels.has(t):this.bmStreamVm.streamModels.has(t))&&streamPullQueue.addQueue(this.handleQueueTask.bind(this,e),e.streamId,0,e.nickname)}handleStreamConnectError(e){var t,r;return __awaiter(this,void 0,void 0,(function*(){const{stream:i,isLocal:s}=e;info("handleStreamConnectError","","",["nickname =>",i.nickname,"streamId => ",i.streamId,"isShare =>",i.isShare,"isLocal => ",s]),i.stream&&(i.stream.stop(),null===(t=this.audioPlayer)||void 0===t||t.removeStream(i.stream)),null===(r=i.player)||void 0===r||r.destroy(),s?i.stream&&(i.isShare?this.bmStreamVm.localShareError.next(br()):this.bmStreamVm.localStreamConnectErrorWatcher.next(Nr$1()),this.netConnecting&&this.networkState.brtc&&this.networkState.bloud?i.isShare?(info("Local share stream has problem, now ,republish"),handleShareStreamFailed(this,this.bmStreamVm)):(info("brtc 网络正常,重新推流"),i.stream&&(yield this.republishLocalStream(i.stream))):(error$1("brtc 网络还没恢复,等恢复了在重新推流 ","",i.userId,["nickname =>",i.nickname,"streamId => ",i.streamId,"isShare =>",i.isShare]),this.streamConnectedErrorQueue.push(e))):this.netConnecting&&this.networkState.brtc?(i.hasPulled=!1,i.pulledStreamType="small",streamPullQueue.addQueue(this.handleQueueTask.bind(this,i),i.streamId,0,i.nickname)):(error$1("brtc 网络还没恢复,等恢复了在重新拉流 ","",i.userId,["nickname =>",i.nickname]),this.streamConnectedErrorQueue.push(e))}))}toggleAudienceSpeaking(e,t){e.permission.setAudio(t),this.updateUser(e.userId,{permission:e.permission.get()})}updateUserIsGuest(e,t){return __awaiter(this,void 0,void 0,(function*(){e.permission.setSubscribe(t),yield this.updateUser(e.userId,{permission:e.permission.get()})}))}managerChangeToGuest(e){this.userVM.managerChangeToGuest(e)}moveUserRoom(e,t=!1,r=!1){return this.boomCore.client.moveUserRoom(e,t,r)}getParticipantNotice(e){this.participantNotice=e}setCustomUrl(e){this.boomCore.setCustomUrl(e)}handleRePushSelf(){var e,t;return __awaiter(this,void 0,void 0,(function*(){const r=null===(t=null===(e=this.getLocalParticipant())||void 0===e?void 0:e.getMainStreamModel())||void 0===t?void 0:t.stream;r&&(yield this.republishLocalStream(r))}))}handleResetOtherStreamStatus(){info("brtc sync-room-completed"),this.audioPlayer.clear(),this.bmStreamVm.streamModels.forEach((e=>{var t;if(!e.isLocal){e.hasPulled=!1,e.pulledStreamType="small";try{e.stream&&e.stream.stop(),null===(t=e.stream)||void 0===t||t.destroy()}catch(e){}e.updateStream(void 0,!1,this.bmStreamVm)}})),this.bmStreamVm.shareStreamModels.forEach((e=>{var t,r;if(!e.isLocal){e.hasPulled=!1,e.pulledStreamType="small";const i=e.getUser();try{null===(t=e.stream)||void 0===t||t.stop(),null===(r=e.stream)||void 0===r||r.destroy()}catch(e){}i.removeStream(`${e.userId}${STREAM_SUFFIX_SCREEN}`)}})),this.bmStreamVm.shareStreamModels.clear(),this.bmStreamVm.shareStreamModelsWatcher.next(Array.from(this.bmStreamVm.shareStreamModels.values())),this.networkState.brtc=!0,setTimeout((()=>{this.brtcNetEnableWatcher.next(!0),this.streamWSReconnectWatcher.next(!0)}),2e3),handleReconnectedStream(this)}addUser2Queue(e){var t;return __awaiter(this,void 0,void 0,(function*(){if(e.force&&this.processUser(new Map([[e.id,e]])),e.isScreen)this.streamQueue.addUsers([e]);else{const r=this.bmStreamVm.streamModels.get(e.id);r&&!r.isLocal&&(r.stream||r&&((null===(t=r.bloudStream)||void 0===t?void 0:t.audio)||r.bloudStream&&r.isDisplay)&&this.streamQueue.addUsers([e]))}}))}queryBrtcStreams(e){return __awaiter(this,void 0,void 0,(function*(){return yield this.boomCore.brtcClient.queryUsers(e)}))}handleAddStreams(e){e.forEach((e=>{if(isShareStream(e)){const t=this.bmStreamVm.shareStreamModels.get(transShareScreen2User(e.getUserId().toString()));(!t||t&&!t.stream)&&((null==t?void 0:t.player)&&t.player.destroy(),this.bmStreamVm.remoteStreamPublished(e))}else{const t=this.bmStreamVm.streamModels.get(e.getUserId().toString());t&&!t.stream&&((null==t?void 0:t.player)&&t.player.destroy(),this.bmStreamVm.remoteStreamPublished(e))}}))}getForceUser(e){return __awaiter(this,void 0,void 0,(function*(){const{users:t}=yield this.boomCore.queryUsers([e]);this.userVM.addBcUsersMap(t,!0),this.userVM.getForceUserWatcher.next(!0)}))}getVersion(){return PackageJson.version}}window.BoomMeeting=BMRoom,window.BoomError=s,window.BOOMLogger=kt$1,exports.Logger=kt$1,exports.default=BMRoom,Object.defineProperty(exports,"__esModule",{value:!0})}));
|