@realsee/live 0.6.14 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/README.md +50 -55
  2. package/dist/index.cjs.js +89 -24
  3. package/dist/index.d.cts +1336 -0
  4. package/dist/index.d.ts +1336 -4
  5. package/dist/index.esm.js +30 -0
  6. package/docs/README.md +435 -0
  7. package/docs/classes/BrowserRTC.md +436 -0
  8. package/docs/classes/BrowserRTC4Chime.md +558 -0
  9. package/docs/classes/CoreRTC.md +448 -0
  10. package/docs/classes/Live.md +797 -0
  11. package/docs/classes/Subscribe.md +211 -0
  12. package/docs/classes/VRWebViewRTC.md +436 -0
  13. package/docs/enumerations/BuiltInRTCType.md +27 -0
  14. package/docs/enumerations/BuiltinActionType.md +81 -0
  15. package/docs/enumerations/BuiltinEventType.md +33 -0
  16. package/docs/enumerations/Command.md +107 -0
  17. package/docs/enumerations/LiveState.md +53 -0
  18. package/docs/enumerations/MemUserStatus.md +67 -0
  19. package/docs/enumerations/MicroStatus.md +33 -0
  20. package/docs/enumerations/RTCJoinedInfoCodeEnum.md +69 -0
  21. package/docs/enumerations/RTCType.md +39 -0
  22. package/docs/enumerations/UserStatus.md +45 -0
  23. package/docs/enumerations/WebSocketCloseError.md +117 -0
  24. package/docs/enumerations/WebSocketErrorType.md +77 -0
  25. package/docs/enumerations/WebSocketState.md +69 -0
  26. package/docs/functions/GetVoiceSignFn.md +27 -0
  27. package/docs/functions/clearLiveInstanceIfNeed.md +17 -0
  28. package/docs/functions/createLive.md +27 -0
  29. package/docs/functions/createLiveReact.md +449 -0
  30. package/docs/functions/parseLiveMsg.md +27 -0
  31. package/docs/functions/parseWSClsErr.md +21 -0
  32. package/docs/globals.md +77 -0
  33. package/docs/interfaces/AttendeeResponse.md +37 -0
  34. package/docs/interfaces/LiveOptions.md +246 -0
  35. package/docs/interfaces/MeetingResponse.md +55 -0
  36. package/docs/interfaces/MeetingSessionConfigurationOptions.md +93 -0
  37. package/docs/interfaces/Permission.md +147 -0
  38. package/docs/interfaces/RTCJoinedInfo.md +67 -0
  39. package/docs/interfaces/RTCProtocol.md +404 -0
  40. package/docs/interfaces/VRWebViewRTCOptions.md +41 -0
  41. package/docs/namespaces/SubscribeMixinType/README.md +17 -0
  42. package/docs/namespaces/SubscribeMixinType/interfaces/emit.md +31 -0
  43. package/docs/namespaces/SubscribeMixinType/interfaces/hasListener.md +25 -0
  44. package/docs/namespaces/SubscribeMixinType/interfaces/off.md +31 -0
  45. package/docs/namespaces/SubscribeMixinType/interfaces/on.md +37 -0
  46. package/docs/namespaces/SubscribeMixinType/interfaces/once.md +35 -0
  47. package/docs/type-aliases/BuiltinMsg.md +41 -0
  48. package/docs/type-aliases/EventMap.md +17 -0
  49. package/docs/type-aliases/EventType.md +19 -0
  50. package/docs/type-aliases/GetVoiceSign.md +15 -0
  51. package/docs/type-aliases/GetVoiceSignParams.md +35 -0
  52. package/docs/type-aliases/GetVoiceSignReturnType.md +41 -0
  53. package/docs/type-aliases/KeyframeEventType.md +19 -0
  54. package/docs/type-aliases/LiveBuiltInData.md +47 -0
  55. package/docs/type-aliases/LiveConnectOptions.md +47 -0
  56. package/docs/type-aliases/LiveEventType.md +165 -0
  57. package/docs/type-aliases/LiveMsg.md +53 -0
  58. package/docs/type-aliases/LiveProviderPropTypes.md +27 -0
  59. package/docs/type-aliases/RTCActionReactCallback.md +13 -0
  60. package/docs/type-aliases/RTCEventType.md +65 -0
  61. package/docs/type-aliases/ReqLiveMsg.md +45 -0
  62. package/docs/type-aliases/RoomInfo.md +55 -0
  63. package/docs/type-aliases/UserInfo.md +77 -0
  64. package/docs/type-aliases/UserInfoExt.md +33 -0
  65. package/docs/type-aliases/UserVolume.md +25 -0
  66. package/docs/type-aliases/WebSocketError.md +31 -0
  67. package/package.json +41 -31
  68. package/dist/index.cjs.js.map +0 -1
  69. package/dist/index.es.js +0 -2179
  70. package/dist/index.es.js.map +0 -1
  71. package/dist/live/controller.d.ts +0 -90
  72. package/dist/live/createLive.d.ts +0 -8
  73. package/dist/live/createLiveReact.d.ts +0 -52
  74. package/dist/live/live.d.ts +0 -182
  75. package/dist/rtc/BrowserRTC.d.ts +0 -39
  76. package/dist/rtc/BrowserRTC4Chime.d.ts +0 -60
  77. package/dist/rtc/CoreRTC.d.ts +0 -23
  78. package/dist/rtc/VRWebViewRTC.d.ts +0 -22
  79. package/dist/rtc/index.d.ts +0 -5
  80. package/dist/typings/chime/AttendeeResponse.d.ts +0 -5
  81. package/dist/typings/chime/MeetingResponse.d.ts +0 -12
  82. package/dist/typings/chime/MeetingSessionConfigurationOptions.d.ts +0 -16
  83. package/dist/typings/chime/index.d.ts +0 -3
  84. package/dist/typings/index.d.ts +0 -4
  85. package/dist/typings/live/EventType.d.ts +0 -74
  86. package/dist/typings/live/GetVoiceSign.d.ts +0 -17
  87. package/dist/typings/live/LiveConnectOptions.d.ts +0 -7
  88. package/dist/typings/live/LiveMsg.d.ts +0 -119
  89. package/dist/typings/live/LiveOptions.d.ts +0 -79
  90. package/dist/typings/live/LiveState.d.ts +0 -15
  91. package/dist/typings/live/RoomInfo.d.ts +0 -13
  92. package/dist/typings/live/UserInfo.d.ts +0 -103
  93. package/dist/typings/live/UserVolume.d.ts +0 -7
  94. package/dist/typings/live/WebSocket.d.ts +0 -82
  95. package/dist/typings/live/index.d.ts +0 -10
  96. package/dist/typings/react/RTCActionReactCallback.d.ts +0 -2
  97. package/dist/typings/react/index.d.ts +0 -1
  98. package/dist/typings/rtc/VRWebViewRTCOptions.d.ts +0 -6
  99. package/dist/typings/rtc/eventType.d.ts +0 -29
  100. package/dist/typings/rtc/index.d.ts +0 -5
  101. package/dist/typings/rtc/joinedInfo.d.ts +0 -34
  102. package/dist/typings/rtc/protocol.d.ts +0 -58
  103. package/dist/typings/rtc/type.d.ts +0 -12
  104. package/dist/utils/RobustWebSocket.d.ts +0 -157
  105. package/dist/utils/appendUri.d.ts +0 -1
  106. package/dist/utils/clientDetector.d.ts +0 -4
  107. package/dist/utils/equal.d.ts +0 -10
  108. package/dist/utils/logger.d.ts +0 -16
  109. package/dist/utils/subscribe.d.ts +0 -75
  110. package/dist/utils/uuid.d.ts +0 -4
  111. package/docs/.nojekyll +0 -1
  112. package/docs/assets/highlight.css +0 -120
  113. package/docs/assets/main.js +0 -58
  114. package/docs/assets/search.js +0 -1
  115. package/docs/assets/style.css +0 -1280
  116. package/docs/classes/BrowserRTC.html +0 -561
  117. package/docs/classes/BrowserRTC4Chime.html +0 -602
  118. package/docs/classes/CoreRTC.html +0 -432
  119. package/docs/classes/VRWebViewRTC.html +0 -448
  120. package/docs/enums/BuiltInRTCType.html +0 -69
  121. package/docs/enums/BuiltinActionType.html +0 -112
  122. package/docs/enums/BuiltinEventType.html +0 -76
  123. package/docs/enums/Command.html +0 -118
  124. package/docs/enums/LiveState.html +0 -89
  125. package/docs/enums/MemUserStatus.html +0 -97
  126. package/docs/enums/MicroStatus.html +0 -72
  127. package/docs/enums/RTCJoinedInfoCodeEnum.html +0 -94
  128. package/docs/enums/RTCType.html +0 -79
  129. package/docs/enums/UserStatus.html +0 -85
  130. package/docs/enums/WebSocketCloseError.html +0 -139
  131. package/docs/enums/WebSocketErrorType.html +0 -104
  132. package/docs/enums/WebSocketState.html +0 -103
  133. package/docs/functions/createLive.html +0 -107
  134. package/docs/functions/createLiveReact.html +0 -575
  135. package/docs/functions/parseLiveMsg.html +0 -105
  136. package/docs/functions/parseWSClsErr.html +0 -99
  137. package/docs/index.html +0 -470
  138. package/docs/interfaces/AttendeeResponse.html +0 -80
  139. package/docs/interfaces/GetVoiceSignReturnType.html +0 -90
  140. package/docs/interfaces/LiveOptions.html +0 -272
  141. package/docs/interfaces/MeetingResponse.html +0 -90
  142. package/docs/interfaces/MeetingSessionConfigurationOptions.html +0 -119
  143. package/docs/interfaces/Permission.html +0 -157
  144. package/docs/interfaces/RTCJoinedInfo.html +0 -104
  145. package/docs/interfaces/RTCProtocol.html +0 -412
  146. package/docs/interfaces/VRWebViewRTCOptions.html +0 -73
  147. package/docs/modules.html +0 -148
  148. package/docs/types/BuiltinMsg.html +0 -108
  149. package/docs/types/EventType.html +0 -97
  150. package/docs/types/GetVoiceSign.html +0 -124
  151. package/docs/types/KeyframeTypes.html +0 -97
  152. package/docs/types/LiveConnectOptions.html +0 -107
  153. package/docs/types/LiveEventType.html +0 -272
  154. package/docs/types/LiveMsg.html +0 -113
  155. package/docs/types/LiveProviderPropTypes.html +0 -102
  156. package/docs/types/RTCActionReactCallback.html +0 -90
  157. package/docs/types/RTCEventType.html +0 -155
  158. package/docs/types/ReqLiveMsg.html +0 -114
  159. package/docs/types/RoomInfo.html +0 -114
  160. package/docs/types/UserInfo.html +0 -135
  161. package/docs/types/UserInfoExt.html +0 -105
  162. package/docs/types/UserVolume.html +0 -99
  163. package/docs/types/WebSocketError.html +0 -101
package/dist/index.es.js DELETED
@@ -1,2179 +0,0 @@
1
- var Vt = Object.defineProperty;
2
- var $t = (r, o, e) => o in r ? Vt(r, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[o] = e;
3
- var s = (r, o, e) => ($t(r, typeof o != "symbol" ? o + "" : o, e), e);
4
- import xt from "@realsee/jsbridge-x";
5
- import Ne from "trtc-js-sdk";
6
- import { ConsoleLogger as Ut, LogLevel as Ft, DefaultDeviceController as Bt, MeetingSessionConfiguration as Wt, DefaultMeetingSession as Kt, DefaultModality as tt, MeetingSessionStatusCode as qt } from "amazon-chime-sdk-js";
7
- import D, { createContext as Gt } from "react";
8
- const ce = Symbol("$$REALSEE_LIVE_EVENT$$");
9
- function pe(r) {
10
- return r[ce] || (r[ce] = {}), r[ce];
11
- }
12
- function Yt(r) {
13
- r[ce] || delete r[ce];
14
- }
15
- class ue {
16
- /**
17
- * 判断是否注册了事件
18
- * @param name 事件类型
19
- */
20
- hasListener(o) {
21
- const e = pe(this);
22
- return e && e[o] && e[o].length > 0;
23
- }
24
- /**
25
- * 注册事件
26
- * @param name 事件类型
27
- * @param callback 事件回调函数
28
- * @param once 是否只执行一次
29
- * @returns 解除事件
30
- * @template K 预设的监听事件名称
31
- * @template C 回调函数函数上下文
32
- */
33
- on(o, e, i) {
34
- const n = pe(this);
35
- return n[o] || (n[o] = []), n[o].push([e, i || !1]), () => this.off(o, e);
36
- }
37
- /**
38
- * 注册事件(是否只执行一次)
39
- * @param name 事件类型
40
- * @param callback 事件回调函数
41
- * @returns 解除事件
42
- * @template K 预设的监听事件名称
43
- * @template C 回调函数函数上下文
44
- */
45
- once(o, e) {
46
- return this.on(o, e, !0);
47
- }
48
- /**
49
- * 解除事件
50
- *
51
- * 如果 name 不传的话解除对应所有事件
52
- * 如果 name, callback 不传的话解除所有name的所有事件
53
- * @param name 事件类型
54
- * @param callback 事件回调函数
55
- * @template K 预设的监听事件名称
56
- */
57
- off(o, e) {
58
- if (o === void 0) {
59
- Yt(this);
60
- return;
61
- }
62
- const i = pe(this);
63
- if (i[o] || (i[o] = []), e === void 0) {
64
- i[o].length = 0;
65
- return;
66
- }
67
- let n = 0;
68
- for (; n < i[o].length && i[o][n][0] !== e; n++)
69
- ;
70
- n < i[o].length && i[o].splice(n, 1);
71
- }
72
- /**
73
- * 触发事件
74
- * @param name 事件类型
75
- * @param data 触发事件的数据
76
- * @returns canceled 是否被触发取消
77
- * @template K 预设的监听事件名称
78
- */
79
- emit(o, ...e) {
80
- let i = !1;
81
- const c = pe(this)[o] || [];
82
- for (let u of c.slice()) {
83
- const [d, g = !1] = u, v = d(...e);
84
- g && this.off(o, d), v === !1 && (i = !0);
85
- }
86
- return i;
87
- }
88
- }
89
- class Me extends ue {
90
- }
91
- var Q = /* @__PURE__ */ ((r) => (r.RealseeBrowserRTC = "RealseeBrowserRTC", r.RealseeVRWebViewRTC = "RealseeVRWebViewRTC", r.RealseeBrowserChimeRTC = "RealseeBrowserChimeRTC", r))(Q || {}), ut = /* @__PURE__ */ ((r) => (r.RealseeXTRTC = "trtc", r.RealseeXChimeRTC = "chime", r))(ut || {});
92
- const Ht = () => {
93
- const r = new Date(), o = r.getFullYear(), e = (r.getMonth() + 1).toString().padStart(2, "0"), i = r.getDate().toString().padStart(2, "0"), n = r.getHours().toString().padStart(2, "0"), c = r.getMinutes().toString().padStart(2, "0"), u = r.getSeconds().toString().padStart(2, "0"), d = r.getMilliseconds();
94
- return `[${o}-${e}-${i} ${n}:${c}:${u}.${d}]`;
95
- }, be = (r, o = []) => {
96
- switch (o.unshift(`Realsee Live ${Ht()} <${r}> `), r) {
97
- case "INFO":
98
- return console.info(...o);
99
- case "ERROR":
100
- return console.error(...o);
101
- case "WARN":
102
- return console.warn(...o);
103
- default:
104
- return console.log(...o);
105
- }
106
- }, Jt = (...r) => be("LOG", r), zt = (...r) => be("INFO", r), Xt = (...r) => be("ERROR", r), Zt = (...r) => be("WARN", r), Qt = {
107
- log: Jt,
108
- info: zt,
109
- error: Xt,
110
- warn: Zt
111
- }, O = Qt;
112
- function X() {
113
- return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
114
- }
115
- function Ee() {
116
- return (X() + X() + "-" + X() + "-4" + X().substr(0, 3) + "-" + X() + "-" + X() + X() + X()).toLowerCase();
117
- }
118
- class rt extends Me {
119
- constructor(e) {
120
- super();
121
- s(this, "type", Q.RealseeBrowserRTC);
122
- s(this, "joined", !1);
123
- s(this, "micro", !1);
124
- s(this, "voiceId", "");
125
- s(this, "_getVoiceSign", () => {
126
- throw new Error("方法 getVoiceSign 未实现");
127
- });
128
- s(this, "_autoPlayConfirm");
129
- s(this, "checkRequirement", () => Ne.checkSystemRequirements());
130
- s(this, "$dom", document.createElement("div"));
131
- s(this, "_trtc", {
132
- client: null,
133
- stream: null
134
- });
135
- s(this, "join", async (e) => {
136
- var c;
137
- this.emit("joinWillStart");
138
- const i = await this._getVoiceSign({
139
- voiceId: e.voiceId,
140
- roomId: e.roomId,
141
- userId: e.userId
142
- });
143
- this._trtc.client = Ne.createClient({
144
- mode: "rtc",
145
- ...i,
146
- enableAutoPlayDialog: typeof this._autoPlayConfirm != "function"
147
- }), (c = this._trtc.client) == null || c.enableAudioVolumeEvaluation(), this._registerRtcEvent();
148
- let n = await new Promise((u) => {
149
- var d;
150
- (d = this._trtc.client) == null || d.join({ roomId: Number(e.voiceId) }).then(() => u(!0)).catch(() => u(!1));
151
- });
152
- return this.joined = n, n ? (this._trtc.stream = Ne.createStream({
153
- userId: i.userId,
154
- audio: !0,
155
- video: !1
156
- }), n = await new Promise((u) => {
157
- var d;
158
- (d = this._trtc.stream) == null || d.initialize().then(() => u(!0)).catch(() => u(!1));
159
- }), n = await new Promise((u) => {
160
- var d;
161
- (d = this._trtc.client) == null || d.publish(this._trtc.stream).then(() => u(!0)).catch(() => u(!1));
162
- }), this.joined = n, this.joined && this.emit("joined"), n) : !1;
163
- });
164
- s(this, "_handleStreamAdded", (e) => {
165
- var n;
166
- const i = e.stream;
167
- console.log("远端流增加: " + i.getId()), (n = this._trtc.client) == null || n.subscribe(i);
168
- });
169
- s(this, "_handleStreamSubscribed", (e) => {
170
- const i = e.stream;
171
- console.log("远端流订阅成功:" + i.getId());
172
- const c = `rs-rtc-remote_stream-${i.getId()}`, u = document.createElement("div");
173
- u.id = c, this.$dom.appendChild(u), typeof this._autoPlayConfirm == "function" ? (i.play(c).catch((d) => {
174
- }), i.on("error", (d) => {
175
- if (d.getCode() === 16451) {
176
- const v = () => i.resume();
177
- this._autoPlayConfirm({ onConfirm: v });
178
- }
179
- })) : i.play(c);
180
- });
181
- this._getVoiceSign = e.getVoiceSign, this._autoPlayConfirm = e.autoPlayConfirm, this._initParentDom();
182
- }
183
- _initParentDom() {
184
- this.$dom.id = `rs-rtc-${Ee()}`, this.$dom.style.display = "none", document.body.appendChild(this.$dom);
185
- }
186
- quit() {
187
- return new Promise(async (e) => {
188
- var i, n;
189
- this.joined = !1, this._trtc.stream && (await ((i = this._trtc.client) == null ? void 0 : i.unpublish(this._trtc.stream)), this._trtc.stream.stop(), this._trtc.stream.close(), this._trtc.stream = null), (n = this._trtc.client) == null || n.leave().then(() => this._trtc.client = null).then(() => e(!0)).catch(() => e(!1)), e(!0);
190
- });
191
- }
192
- detectMicro() {
193
- return new Promise((e) => {
194
- const i = { audio: !0, video: !1 };
195
- try {
196
- navigator.mediaDevices.getUserMedia(i).then(() => e(!0)).catch((n) => {
197
- O.error(n.message), e(!1);
198
- });
199
- } catch (n) {
200
- console.error(n), e(!1);
201
- }
202
- });
203
- }
204
- toggleMicro(e) {
205
- var i, n, c, u;
206
- return Promise.resolve(
207
- (e ? (n = (i = this._trtc) == null ? void 0 : i.stream) == null ? void 0 : n.unmuteAudio() : (u = (c = this._trtc) == null ? void 0 : c.stream) == null ? void 0 : u.muteAudio()) || !1
208
- );
209
- }
210
- shock() {
211
- throw new Error("Method not implemented.");
212
- }
213
- _registerRtcEvent() {
214
- var e, i, n, c;
215
- (e = this._trtc.client) == null || e.on("stream-added", this._handleStreamAdded), (i = this._trtc.client) == null || i.on("stream-subscribed", this._handleStreamSubscribed), (n = this._trtc.client) == null || n.on(
216
- "audio-volume",
217
- (u) => this.emit(
218
- "userVolumes",
219
- u.result.map(({ userId: d, audioVolume: g }) => ({
220
- userId: d,
221
- audioVolume: g
222
- }))
223
- )
224
- ), (c = this._trtc.client) == null || c.on("error", (u) => this.emit("error", u));
225
- }
226
- }
227
- class it extends Me {
228
- constructor(e) {
229
- super();
230
- s(this, "type", Q.RealseeBrowserChimeRTC);
231
- s(this, "joined", !1);
232
- s(this, "micro", !1);
233
- s(this, "voiceId", "");
234
- s(this, "userId", "");
235
- s(this, "logger");
236
- s(this, "deviceController");
237
- s(this, "meetingSession");
238
- s(this, "audioInput");
239
- s(this, "audioOutput");
240
- s(this, "deviceChangeObserver", {});
241
- s(this, "audioVideoObserver", {});
242
- s(this, "audioMixObserver");
243
- s(this, "_getVoiceSign", () => {
244
- throw new Error("方法 getVoiceSign 未实现");
245
- });
246
- s(this, "_autoPlayConfirm");
247
- s(this, "$dom", document.createElement("div"));
248
- s(this, "$audio", document.createElement("audio"));
249
- /**
250
- * 对audio标签初始化
251
- */
252
- s(this, "_initDom", () => {
253
- this.$audio.id = `rs-rtc-${Ee()}`, this.$dom.id = `rs-rtc-${Ee()}`, this.$dom.appendChild(this.$audio), document.body.appendChild(this.$dom);
254
- });
255
- /**
256
- * 初始化事件监听器
257
- */
258
- s(this, "initObservers", () => {
259
- this.deviceChangeObserver = {
260
- audioInputsChanged: (e) => {
261
- this.logger.info(`audioInputsChanged ${typeof e}`), e == null || e.forEach((i) => {
262
- this.logger.info(`Device ID: ${i.deviceId} Microphone: ${i.label}`);
263
- });
264
- },
265
- audioOutputsChanged: (e) => {
266
- this.logger.info(`audioOutputsChanged ${typeof e}`), e == null || e.forEach((i) => {
267
- this.logger.info(`Device ID: ${i.deviceId} Speaker: ${i.label}`);
268
- });
269
- },
270
- // videoInputsChanged: (freshVideoInputDeviceList: any) => {
271
- // this.logger.info(`Video inputs updated: ${freshVideoInputDeviceList}`);
272
- // },
273
- audioInputMuteStateChanged: (e, i) => {
274
- this.logger.info(`Device ${e.toString()} ${i ? "is muted in hardware" : "is not muted"}`);
275
- }
276
- }, this.audioVideoObserver = {
277
- audioVideoDidStart: () => {
278
- this.logger.info("Started");
279
- },
280
- audioVideoDidStop: (e) => {
281
- this.logger.info(`Stopped with a session status code: ${e.statusCode()}`);
282
- },
283
- audioVideoDidStartConnecting: (e) => {
284
- e && this.logger.info("Attempting to reconnect");
285
- }
286
- }, this.audioMixObserver = {
287
- meetingAudioStreamBecameActive: (e) => {
288
- if (this.$audio.paused) {
289
- const i = () => this.$audio.play().then(() => {
290
- }).catch((n) => {
291
- if (O.error("播放远端流失败!", n), typeof this._autoPlayConfirm == "function") {
292
- const c = () => i();
293
- this._autoPlayConfirm({ onConfirm: c });
294
- }
295
- });
296
- i();
297
- }
298
- },
299
- meetingAudioStreamBecameInactive: (e) => {
300
- }
301
- };
302
- });
303
- /**
304
- * 注册rtc事件
305
- */
306
- s(this, "_registerRtcEvent", () => {
307
- var i, n, c, u, d, g;
308
- const e = ((c = (n = (i = this.meetingSession) == null ? void 0 : i.configuration) == null ? void 0 : n.credentials) == null ? void 0 : c.attendeeId) || "";
309
- if (e) {
310
- const v = /* @__PURE__ */ new Map(), E = () => {
311
- const y = [];
312
- return v.forEach((I, _) => {
313
- y.push({
314
- userId: I.userId,
315
- volume: I.muted || I.signalStrength === 0 || !Boolean(I.volume) ? 0 : I.volume
316
- });
317
- }), y;
318
- };
319
- (u = this.meetingSession) == null || u.audioVideo.realtimeSubscribeToAttendeeIdPresence(
320
- (y, I, _) => {
321
- var V;
322
- if (!I) {
323
- v.delete(y), this.emit("userVolumes", E());
324
- return;
325
- }
326
- (V = this.meetingSession) == null || V.audioVideo.realtimeSubscribeToVolumeIndicator(
327
- y,
328
- (C, k, U, P) => {
329
- new tt(C).base() === C && (v.set(C, {
330
- userId: _ || C,
331
- volume: k,
332
- muted: U,
333
- signalStrength: P
334
- }), this.emit("userVolumes", E()));
335
- }
336
- );
337
- }
338
- ), (d = this.meetingSession) == null || d.audioVideo.realtimeSubscribeToVolumeIndicator(
339
- e,
340
- (y, I, _, V) => {
341
- new tt(y).base() === y && V !== null && V !== 1 && this.emit("weakNetwork");
342
- }
343
- ), (g = this.meetingSession) == null || g.audioVideo.realtimeSubscribeToFatalError((y) => this.emit("error", y));
344
- }
345
- });
346
- this._getVoiceSign = e.getVoiceSign, this._autoPlayConfirm = e.autoPlayConfirm, this._initDom(), this.logger = new Ut("WebRTCLogger", e.logLevel || Ft.INFO), this.deviceController = new Bt(this.logger), this.initObservers();
347
- }
348
- /**
349
- * 加入语音会议
350
- * @param options
351
- * @returns
352
- */
353
- async join(e) {
354
- return new Promise(async (i, n) => {
355
- var c, u;
356
- this.emit("joinWillStart");
357
- try {
358
- const { sdkAppId: d, userId: g, roomId: v, userSig: E } = await this._getVoiceSign({
359
- ...e,
360
- roomId: e.roomId || 0
361
- });
362
- this.userId = g;
363
- const { attendence: y, vendor_wrapper: I } = JSON.parse(
364
- decodeURIComponent(E)
365
- ), _ = new Wt(
366
- {
367
- Meeting: I
368
- },
369
- {
370
- Attendee: {
371
- ExternalUserId: y.external_user_id,
372
- AttendeeId: y.attendee_id,
373
- JoinToken: y.join_token
374
- }
375
- }
376
- );
377
- this.meetingSession = new Kt(_, this.logger, this.deviceController), this._registerRtcEvent(), this.meetingSession.audioVideo.addDeviceChangeObserver(this.deviceChangeObserver), this.meetingSession.audioVideo.addObserver(this.audioVideoObserver), this.meetingSession.audioVideo.bindAudioElement(this.$audio);
378
- const V = {
379
- audioVideoDidStart: () => {
380
- var C;
381
- (C = this.meetingSession) == null || C.audioVideo.realtimeMuteLocalAudio(), this.joined = !0, this.emit("joined"), i(!0);
382
- },
383
- audioVideoDidStop: () => {
384
- this.joined = !1, i(!1);
385
- }
386
- };
387
- this.meetingSession.audioVideo.addObserver(V), this.audioMixObserver && this.meetingSession.audioVideo.addAudioMixObserver(this.audioMixObserver), this.meetingSession.audioVideo.setDeviceLabelTrigger(
388
- async () => await navigator.mediaDevices.getUserMedia({ audio: !0, video: !1 })
389
- );
390
- try {
391
- const C = await this.meetingSession.audioVideo.listAudioInputDevices();
392
- O.info("audioInputDevices ===>", C);
393
- const k = ((c = C[0]) == null ? void 0 : c.deviceId) || "default";
394
- await this.meetingSession.audioVideo.startAudioInput(k);
395
- } catch (C) {
396
- O.error(`设置语音输入设备失败:${C.message}`);
397
- }
398
- try {
399
- const C = await this.meetingSession.audioVideo.listAudioOutputDevices();
400
- O.info("audioOutputDevices ===>", C);
401
- const k = ((u = C[0]) == null ? void 0 : u.deviceId) || "default";
402
- await this.meetingSession.audioVideo.chooseAudioOutput(k);
403
- } catch (C) {
404
- O.error(`设置语音输出设备失败:${C.message}`);
405
- }
406
- this.meetingSession.audioVideo.start();
407
- } catch (d) {
408
- this.emit("error", d), this.logger.error(d.message), i(!1);
409
- }
410
- });
411
- }
412
- quit() {
413
- return this.joined ? new Promise((e, i) => {
414
- var c, u;
415
- this.joined = !1;
416
- const n = {
417
- audioVideoDidStop: async (d) => {
418
- var v;
419
- const g = d.statusCode();
420
- (v = this.meetingSession) == null || v.deviceController.destroy(), g === qt.Left ? (this.logger.info("You left the session"), e(!0)) : (this.logger.info(`Stopped with a session status code: ${g}`), e(!0));
421
- }
422
- };
423
- (c = this.meetingSession) == null || c.audioVideo.addObserver(n), (u = this.meetingSession) == null || u.audioVideo.stop();
424
- }) : Promise.resolve(!0);
425
- }
426
- async detectMicro() {
427
- return new Promise((e) => {
428
- const i = { audio: !0, video: !1 };
429
- try {
430
- navigator.mediaDevices.getUserMedia(i).then(() => e(!0)).catch(() => e(!1));
431
- } catch (n) {
432
- this.logger.error(n.message), e(!1);
433
- }
434
- });
435
- }
436
- async toggleMicro(e) {
437
- var n, c, u;
438
- e ? (n = this.meetingSession) == null || n.audioVideo.realtimeUnmuteLocalAudio() : (c = this.meetingSession) == null || c.audioVideo.realtimeMuteLocalAudio();
439
- const i = (u = this.meetingSession) == null ? void 0 : u.audioVideo.realtimeIsLocalAudioMuted();
440
- return i !== void 0 ? e !== i : !1;
441
- }
442
- shock() {
443
- throw new Error("Method not implemented.");
444
- }
445
- }
446
- var lt = /* @__PURE__ */ ((r) => (r[r.Success = 0] = "Success", r[r.Failure = 1] = "Failure", r[r.ReJoin = 2] = "ReJoin", r[r.NoMicroPermission = 3] = "NoMicroPermission", r))(lt || {});
447
- class nt extends Me {
448
- constructor({ jsBridge: e, getVoiceSign: i }) {
449
- super();
450
- s(this, "type", Q.RealseeVRWebViewRTC);
451
- s(this, "joined", !1);
452
- s(this, "micro", !1);
453
- s(this, "voiceId", "");
454
- s(this, "options");
455
- this.options = { jsBridge: e, getVoiceSign: i }, this.jsBridge.webViewType !== "WxMiniProgramWebView" && this.jsBridge.callAndListen("live/userVolumes", (n) => {
456
- this.emit("userVolumes", n);
457
- }), this.jsBridge.callAndListen("live/weakNetwork", (n) => {
458
- n && this.emit("weakNetwork");
459
- });
460
- }
461
- get jsBridge() {
462
- return this.options.jsBridge;
463
- }
464
- async join(e) {
465
- try {
466
- this.emit("joinWillStart");
467
- const { sdkAppId: i, userId: n, userSig: c } = await this.options.getVoiceSign(e);
468
- if (!(Boolean(i) && Boolean(n) && Boolean(c)))
469
- return this.emit("error", new Error("加入房间失败:rtc 签名请求异常")), this.joined = !1, this.joined;
470
- this.type = e.type;
471
- const [u, d] = await this.jsBridge.callAndBackfeed(
472
- `live/join?sdkAppID=${i}&userID=${n}&roomID=${Number(e.voiceId)}&userSig=${c}`
473
- );
474
- return u === !0 ? (this.emit("joined"), this.joined = !0) : u ? u.code === lt.Success ? (this.emit("joined"), this.joined = !0) : (this.emit("error", u), this.joined = !1) : (this.emit("error", d || new Error("加入房间失败:未知异常。")), this.joined = !1), this.joined;
475
- } catch (i) {
476
- return this.emit("error", new Error("加入房间失败:" + i.message)), this.joined = !1, this.joined;
477
- }
478
- }
479
- async quit() {
480
- const [e, i] = await this.jsBridge.callAndBackfeed("live/quit");
481
- return e === null && this.emit("error", i || new Error("退出房间失败:未知异常。")), this.joined = !1, !!e;
482
- }
483
- async detectMicro() {
484
- const [e, i] = await this.jsBridge.detectMicro();
485
- return e === null ? (this.emit("error", i || new Error("麦克风监测异常!")), !1) : e;
486
- }
487
- async toggleMicro(e) {
488
- const [i, n] = await this.jsBridge.callAndBackfeed(`live/toggleMicro?flag=${e ? 1 : 0}`);
489
- return i === null ? (this.emit("error", n || new Error("麦克风监测异常!")), !1) : (this.micro = i, i);
490
- }
491
- shock() {
492
- this.jsBridge.shock(1);
493
- }
494
- }
495
- var K = /* @__PURE__ */ ((r) => (r.SelfUserInfo = "SELF_USER_INFO", r.RoomInfo = "ROOM_INFO", r.RTCInfo = "RTC_INFO", r.UserList = "USER_LIST", r.BuiltinMsg = "BUILTIN_MSG", r.CustomEvent = "CUSTOM_EVENT", r.KeyframeSync = "KEYFRAME_SYNC", r.UserKickOut = "USER_KICK_OUT", r))(K || {}), q = /* @__PURE__ */ ((r) => (r.UserChange = "user_change", r.RoomChange = "room_change", r))(q || {}), H = /* @__PURE__ */ ((r) => (r.UserMicroStatus = "change_micro_status", r.UserMicroStatusSync = "sync_micro_status", r.UserPermission = "change_permission", r.UserStatus = "change_status", r.UserInfo = "change_info", r.RoomClose = "close", r))(H || {}), Z = /* @__PURE__ */ ((r) => (r.OPEN = "OPEN", r.CLOSE = "CLOSE", r))(Z || {});
496
- function Nr(r) {
497
- try {
498
- const o = JSON.parse(r), e = {
499
- code: o.code,
500
- message: o.message,
501
- command: o.command,
502
- roomCode: o.room_code,
503
- appID: o.app_id,
504
- requestId: o.request_id,
505
- frontRequestId: o.front_request_id,
506
- triggerUserID: o.trigger_user_id,
507
- data: o.data || {}
508
- }, i = Object.keys(e).filter(
509
- (n) => e[n] === void 0
510
- );
511
- return i.length > 0 && console.warn(`推送数据格式异常:${i.join(" ")} 值不存在!`), e;
512
- } catch (o) {
513
- return !1;
514
- }
515
- }
516
- var x = /* @__PURE__ */ ((r) => (r[r.NOTINITIALIZED = -1] = "NOTINITIALIZED", r[r.CONNECTING = 0] = "CONNECTING", r[r.OPEN = 1] = "OPEN", r[r.CLOSED = 3] = "CLOSED", r))(x || {}), er = /* @__PURE__ */ ((r) => (r[r.Normal = 0] = "Normal", r[r.Removed = 1] = "Removed", r[r.Replaced = 2] = "Replaced", r))(er || {}), tr = /* @__PURE__ */ ((r) => (r.WAIT_ENTER = "WAIT_ENTER", r.ONLINE = "ONLINE", r.LEAVE = "LEAVE", r.KICK_OUT = "KICK_OUT", r.BE_REPLACE = "BE_REPLACE", r.EXCEPTION = "EXCEPTION", r))(tr || {}), Le = /* @__PURE__ */ ((r) => (r[r.NOTINITIALIZED = -1] = "NOTINITIALIZED", r[r.CONNECTING = 0] = "CONNECTING", r[r.OPEN = 1] = "OPEN", r[r.CLOSING = 2] = "CLOSING", r[r.CLOSED = 3] = "CLOSED", r))(Le || {}), rr = /* @__PURE__ */ ((r) => (r.Error = "Error", r.Close = "Close", r.MicroAuth = "MicroAuth", r.DuplicateConnect = "DuplicateConnect", r.IllegalURL = "IllegalURL", r.Unknown = "Unknown", r.IllegalArgs = "IllegalArgs", r))(rr || {}), ir = /* @__PURE__ */ ((r) => (r.Err_1000 = "CLOSE_NORMAL", r.Err_1001 = "CLOSE_GOING_AWAY", r.Err_1002 = "CLOSE_PROTOCOL_ERROR", r.Err_1003 = "CLOSE_UNSUPPORTED", r.Err_1006 = "CLOSE_ABNORMAL", r.Err_1007 = "Unsupported Data", r.Err_1008 = "Policy Violation", r.Err_1009 = "CLOSE_TOO_LARGE", r.Err_unknown = "unknown", r))(ir || {});
517
- function nr(r) {
518
- switch (r) {
519
- case 1e3:
520
- return "CLOSE_NORMAL";
521
- case 1001:
522
- return "CLOSE_GOING_AWAY";
523
- case 1002:
524
- return "CLOSE_PROTOCOL_ERROR";
525
- case 1003:
526
- return "CLOSE_UNSUPPORTED";
527
- case 1006:
528
- return "CLOSE_ABNORMAL";
529
- case 1007:
530
- return "Unsupported Data";
531
- case 1008:
532
- return "Policy Violation";
533
- case 1009:
534
- return "CLOSE_TOO_LARGE";
535
- }
536
- return "unknown";
537
- }
538
- function sr(r) {
539
- return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
540
- }
541
- var ft = {};
542
- (function(r) {
543
- Object.defineProperty(r, "__esModule", { value: !0 }), r.LogLevel = void 0;
544
- var o;
545
- (function(e) {
546
- e[e.DEBUG = 0] = "DEBUG", e[e.INFO = 1] = "INFO", e[e.WARN = 2] = "WARN", e[e.ERROR = 3] = "ERROR", e[e.OFF = 4] = "OFF";
547
- })(o = r.LogLevel || (r.LogLevel = {})), r.default = o;
548
- })(ft);
549
- const st = /* @__PURE__ */ sr(ft);
550
- function or(r, o = {}) {
551
- const e = r.indexOf("?") !== -1, i = Object.keys(o).reduce(
552
- (n, c, u) => `${n}${u === 0 && !e ? "?" : "&"}${c}=${o[c]}`,
553
- ""
554
- );
555
- return r + i;
556
- }
557
- const le = globalThis.navigator.userAgent, ar = /android/gi.test(le), cr = /iPhone|iPad\s+OS/gi.test(le), ur = /MicroMessenger/gi.test(le) && /miniProgram/gi.test(le), lr = /realsee/gi.test(le);
558
- function ye(r) {
559
- return Object.prototype.toString.call(r) === "[object Object]";
560
- }
561
- function Se(r, o) {
562
- return r === o ? !0 : typeof r != typeof o ? !1 : !!(Number.isNaN(r) && Number.isNaN(o));
563
- }
564
- function fr(r, o) {
565
- const e = Object.getOwnPropertyNames(r), i = Object.getOwnPropertyNames(o);
566
- if (e.length !== i.length)
567
- return !1;
568
- for (let n = 0, c = e.length; n < c; n++) {
569
- const u = e[n];
570
- if (!Se(r[u], o[u]))
571
- return !1;
572
- }
573
- return !0;
574
- }
575
- function dr(r, o) {
576
- if (r.length !== o.length)
577
- return !1;
578
- for (let e = 0, i = r.length; e < i; e++)
579
- if (!Se(r[e], o[e]))
580
- return !1;
581
- return !0;
582
- }
583
- function hr(r, o) {
584
- return Se(r, o) ? !0 : ye(r) && ye(o) ? fr(r, o) : Array.isArray(r) && Array.isArray(o) ? dr(r, o) : !1;
585
- }
586
- function De(r, o) {
587
- return Se(r, o) ? !0 : ye(r) && ye(o) ? gr(r, o) : Array.isArray(r) && Array.isArray(o) ? _r(r, o) : !1;
588
- }
589
- function _r(r, o) {
590
- if (r.length !== o.length)
591
- return !1;
592
- for (let e = 0, i = r.length; e < i; e++)
593
- if (!De(r[e], o[e]))
594
- return !1;
595
- return !0;
596
- }
597
- function gr(r, o) {
598
- const e = Object.getOwnPropertyNames(r), i = Object.getOwnPropertyNames(o);
599
- if (e.length !== i.length)
600
- return !1;
601
- for (let n = 0, c = e.length; n < c; n++) {
602
- const u = e[n];
603
- if (!De(r[u], o[u]))
604
- return !1;
605
- }
606
- return !0;
607
- }
608
- function ot(r, o, e = { deep: !1 }) {
609
- return e.deep ? De(r, o) : hr(r, o);
610
- }
611
- class mr extends ue {
612
- constructor(e) {
613
- super();
614
- s(this, "_realWebSocket");
615
- s(this, "_url");
616
- s(this, "_protocols");
617
- s(this, "_readyState", Le.NOTINITIALIZED);
618
- s(this, "_options", {
619
- timeout: 1e4,
620
- shouldReconnect: (e, i) => {
621
- if (!(e.code === 1008 || e.code === 1011))
622
- return [0, 1e3, 2e3][i.attempts % 3];
623
- },
624
- should1000Reconnect: !1,
625
- ignoreConnectivityEvents: !1,
626
- automaticOpen: !1
627
- });
628
- s(this, "_connectTimeout");
629
- s(this, "_attempts", 0);
630
- s(this, "_reconnects", -1);
631
- s(this, "_reconnectWhenOnlineAgain", !1);
632
- s(this, "_explicitlyClosed", !1);
633
- s(this, "_pendingReconnect");
634
- s(this, "_connectivityEventsAttached", !1);
635
- s(this, "_heathCheckTimer");
636
- /**
637
- * 做一个健康检查
638
- */
639
- s(this, "_healthCheck", async () => {
640
- this._realWebSocket && this._realWebSocket.readyState !== this._readyState && (this._readyState = this._realWebSocket.readyState, this._readyState === Le.CLOSING && this.emit("closing")), await new Promise((e) => setTimeout(e, 2e3)), this._heathCheckTimer = requestAnimationFrame(this._healthCheck);
641
- });
642
- /**
643
- * 清理超时计时器
644
- */
645
- s(this, "_clearConnectTimeoutIfNeed", () => {
646
- this._connectTimeout && (clearTimeout(this._connectTimeout), this._connectTimeout = void 0);
647
- });
648
- /**
649
- * 清理健康检查
650
- */
651
- s(this, "_clearHeathCheckIfNeed", () => {
652
- this._heathCheckTimer && (cancelAnimationFrame(this._heathCheckTimer), this._heathCheckTimer = void 0);
653
- });
654
- /**
655
- * 开启健康检查
656
- */
657
- s(this, "_startHealthCheck", () => {
658
- this._clearHeathCheckIfNeed(), this._heathCheckTimer = requestAnimationFrame(this._healthCheck);
659
- });
660
- /**
661
- * 停止健康检查
662
- */
663
- s(this, "_stopHealthCheck", () => {
664
- this._clearHeathCheckIfNeed();
665
- });
666
- /**
667
- * 清理连接中的请求
668
- */
669
- s(this, "_clearPendingReconnectIfNeeded", () => {
670
- this._pendingReconnect && (clearTimeout(this._pendingReconnect), this._pendingReconnect = void 0);
671
- });
672
- /**
673
- * 当网页连接上网络进行重连
674
- * @param event
675
- */
676
- s(this, "_online", (e) => {
677
- this._reconnectWhenOnlineAgain && (this._clearPendingReconnectIfNeeded(), this._reconnect(e));
678
- });
679
- /**
680
- * 当网页断开网络进行关闭
681
- */
682
- s(this, "_offline", () => {
683
- var e;
684
- this._reconnectWhenOnlineAgain = !0, (e = this._realWebSocket) == null || e.close(1e3, "offline");
685
- });
686
- /**
687
- * 解除网络监听事件
688
- */
689
- s(this, "_detachConnectivityEvents", () => {
690
- this._connectivityEventsAttached && (globalThis == null || globalThis.removeEventListener("online", this._online), globalThis == null || globalThis.removeEventListener("offline", this._offline), this._connectivityEventsAttached = !1);
691
- });
692
- /**
693
- * 注册网络监听事件
694
- */
695
- s(this, "_attachConnectivityEvents", () => {
696
- this._connectivityEventsAttached || (globalThis == null || globalThis.addEventListener("online", this._online), globalThis == null || globalThis.addEventListener("offline", this._offline), this._connectivityEventsAttached = !0);
697
- });
698
- /**
699
- * 发送消息
700
- * @param data
701
- * @returns
702
- */
703
- s(this, "send", (e) => {
704
- var i, n, c;
705
- ((i = this._realWebSocket) == null ? void 0 : i.readyState) === ((n = this._realWebSocket) == null ? void 0 : n.OPEN) && ((c = this._realWebSocket) == null || c.send(e));
706
- });
707
- /**
708
- * 关闭连接
709
- * @param code 代码
710
- * @param reason 原因
711
- * @returns
712
- */
713
- s(this, "close", (e, i) => {
714
- var n;
715
- return typeof e != "number" && (i = e, e = 1e3), this._clearPendingReconnectIfNeeded(), this._reconnectWhenOnlineAgain = !1, this._explicitlyClosed = !0, this._detachConnectivityEvents(), (n = this._realWebSocket) == null ? void 0 : n.close(e, i);
716
- });
717
- /**
718
- * 进行ws连接
719
- */
720
- s(this, "open", (e) => {
721
- var i, n;
722
- e && (this._url = e), ((i = this._realWebSocket) == null ? void 0 : i.readyState) !== WebSocket.OPEN && ((n = this._realWebSocket) == null ? void 0 : n.readyState) !== WebSocket.CONNECTING && (this._clearPendingReconnectIfNeeded(), this._reconnectWhenOnlineAgain = !1, this._explicitlyClosed = !1, this._createWebSocket());
723
- });
724
- /**
725
- * 创建ws连接
726
- */
727
- s(this, "_createWebSocket", () => {
728
- var n, c, u;
729
- const e = typeof this._url == "string" ? this._url : (n = this._url) == null ? void 0 : n.call(this, this);
730
- if (!e)
731
- return;
732
- this._clearConnectTimeoutIfNeed(), this._clearPendingReconnectIfNeeded(), this._removeWebSocketEvent(), this._realWebSocket = new WebSocket(e, this._protocols || void 0), this._attempts = this._attempts + 1, this.emit(
733
- "connecting",
734
- new CustomEvent("connecting", {
735
- detail: { attempts: this._attempts, reconnects: this._reconnects }
736
- })
737
- );
738
- const i = () => {
739
- this._connectTimeout = void 0, this._detachConnectivityEvents(), this.emit(
740
- "timeout",
741
- new CustomEvent("timeout", {
742
- detail: {
743
- attempts: this._attempts,
744
- reconnects: this._reconnects
745
- }
746
- })
747
- );
748
- };
749
- this._connectTimeout = setTimeout(i, (c = this._options) == null ? void 0 : c.timeout), this._dispatchWebSocketEvent(), (u = this._options) != null && u.ignoreConnectivityEvents || this._attachConnectivityEvents();
750
- });
751
- /**
752
- * 断开ws事件
753
- */
754
- s(this, "_removeWebSocketEvent", () => {
755
- var e, i, n, c;
756
- (e = this._realWebSocket) == null || e.removeEventListener("open", this._webSocketOpenHandler), (i = this._realWebSocket) == null || i.removeEventListener("close", this._webSocketCloseHandler), (n = this._realWebSocket) == null || n.removeEventListener("error", this._webSocketErrorHandler), (c = this._realWebSocket) == null || c.removeEventListener("message", this._webSocketMessageHandler);
757
- });
758
- /**
759
- * 分发ws事件
760
- */
761
- s(this, "_dispatchWebSocketEvent", () => {
762
- var e, i, n, c;
763
- (e = this._realWebSocket) == null || e.addEventListener("open", this._webSocketOpenHandler), (i = this._realWebSocket) == null || i.addEventListener("close", this._webSocketCloseHandler), (n = this._realWebSocket) == null || n.addEventListener("error", this._webSocketErrorHandler), (c = this._realWebSocket) == null || c.addEventListener("message", this._webSocketMessageHandler);
764
- });
765
- /**
766
- * ws连接事件
767
- * @returns
768
- */
769
- s(this, "_webSocketOpenHandler", (e) => {
770
- this._connectTimeout && (clearTimeout(this._connectTimeout), this._connectTimeout = void 0);
771
- const i = ++this._reconnects, n = this._attempts;
772
- return this._attempts = 0, this._reconnectWhenOnlineAgain = !1, this._startHealthCheck(), this.emit("open", Object.assign(e, { detail: { reconnects: i, attempts: n } }));
773
- });
774
- /**
775
- * ws 关闭事件
776
- * @param event
777
- * @returns
778
- */
779
- s(this, "_webSocketCloseHandler", (e) => (this._reconnect(e), this._stopHealthCheck(), this.emit("close", e)));
780
- /**
781
- * ws 异常
782
- * @param event
783
- * @returns
784
- */
785
- s(this, "_webSocketErrorHandler", (e) => this.emit("error", new CustomEvent("error", { detail: { error: e } })));
786
- /**
787
- * ws消息
788
- * @param event
789
- * @returns
790
- */
791
- s(this, "_webSocketMessageHandler", (e) => this.emit("message", e));
792
- e && this.setOptions(e), this._startHealthCheck();
793
- }
794
- get attempts() {
795
- return this._attempts;
796
- }
797
- setOptions(e) {
798
- if (!e)
799
- return;
800
- this._url = e.url, this._protocols = e.protocols;
801
- const i = Object.assign(this._options, e.robustOptions || {});
802
- if (typeof (i == null ? void 0 : i.timeout) != "number")
803
- throw new Error("timeout must be the number of milliseconds to timeout a connection attempt");
804
- if (typeof (i == null ? void 0 : i.shouldReconnect) != "function")
805
- throw new Error(
806
- "shouldReconnect must be a function that returns the number of milliseconds to wait for a reconnect attempt, or null or undefined to not reconnect."
807
- );
808
- this._options = i, this._options.automaticOpen && this._createWebSocket();
809
- }
810
- /**
811
- * 进行重连
812
- * @param event
813
- * @returns
814
- */
815
- _reconnect(e) {
816
- var n, c, u, d;
817
- if (!((n = this._options) != null && n.should1000Reconnect) && e.code === 1e3 || this._explicitlyClosed) {
818
- this._attempts = 0;
819
- return;
820
- }
821
- if (this._connectivityEventsAttached && ((c = globalThis == null ? void 0 : globalThis.navigator) == null ? void 0 : c.onLine) === !1) {
822
- this._reconnectWhenOnlineAgain = !0;
823
- return;
824
- }
825
- const i = (d = (u = this._options) == null ? void 0 : u.shouldReconnect) == null ? void 0 : d.call(u, e, this);
826
- typeof i == "number" && (this._pendingReconnect = setTimeout(this._createWebSocket, i));
827
- }
828
- }
829
- class vr extends ue {
830
- constructor() {
831
- super();
832
- /**
833
- * ws代理器
834
- */
835
- s(this, "_ws", new mr({
836
- url: "",
837
- robustOptions: { should1000Reconnect: !0, ignoreConnectivityEvents: !0 }
838
- }));
839
- /**
840
- * 带看连接状态
841
- */
842
- s(this, "_state", x.NOTINITIALIZED);
843
- /**
844
- * 添加事件监听
845
- */
846
- s(this, "_addWebSocketEventListeners", () => {
847
- this._ws.on("close", this._handleCloseEvent), this._ws.on("closing", this._handleClosingEvent), this._ws.on("connecting", this._handleConnectingEvent), this._ws.on("error", this._handleErrorEvent), this._ws.on("message", this._handleMessageEvent), this._ws.on("open", this._handleOpenEvent), this._ws.on("timeout", this._handleTimeoutEvent);
848
- });
849
- /**
850
- * 移除事件监听
851
- */
852
- s(this, "_removeWebSocketEventListeners", () => {
853
- this._ws.off("close", this._handleCloseEvent), this._ws.off("closing", this._handleClosingEvent), this._ws.off("connecting", this._handleConnectingEvent), this._ws.off("error", this._handleErrorEvent), this._ws.off("message", this._handleMessageEvent), this._ws.off("open", this._handleOpenEvent), this._ws.off("timeout", this._handleTimeoutEvent);
854
- });
855
- /**
856
- * 处理房间关闭事件
857
- * @param event
858
- */
859
- s(this, "_handleCloseEvent", (e) => {
860
- O.info(
861
- `live room closed bacause of ${e.code}-${e.reason || nr(e.code)}`
862
- ), this.state = x.CLOSED;
863
- });
864
- /**
865
- * 处理房间正在关闭事件(这个时候可能是断网了)
866
- */
867
- s(this, "_handleClosingEvent", () => {
868
- var e;
869
- O.info("live room is closing, onLine:", (e = globalThis == null ? void 0 : globalThis.navigator) == null ? void 0 : e.onLine), this.state = x.CLOSED;
870
- });
871
- /**
872
- * 连接中
873
- * @param event
874
- */
875
- s(this, "_handleConnectingEvent", () => {
876
- O.info("live room is connecting"), this.state = x.CONNECTING;
877
- });
878
- /**
879
- * 连接发送异常
880
- * @param event
881
- */
882
- s(this, "_handleErrorEvent", (e) => {
883
- O.error("live room error", e), this.state = x.CLOSED;
884
- });
885
- /**
886
- * 接收到消息
887
- * @param event
888
- */
889
- s(this, "_handleMessageEvent", (e) => {
890
- let i = (() => {
891
- try {
892
- return JSON.parse(e.data);
893
- } catch (n) {
894
- return e.data;
895
- }
896
- })();
897
- this.emit("message", i);
898
- });
899
- /**
900
- * 连接建立成功
901
- * @param event
902
- */
903
- s(this, "_handleOpenEvent", (e) => {
904
- O.info("live room open", e.detail), this.state = x.OPEN, e.detail.reconnects > 0 && this.emit("reconnected", e.detail);
905
- });
906
- /**
907
- * 处理超时
908
- * @param event
909
- */
910
- s(this, "_handleTimeoutEvent", (e) => {
911
- O.error("live room connect timeout!", e.detail), this.state = x.CLOSED;
912
- });
913
- /**
914
- * 释放资源,释放之后需要重新实例化
915
- * @returns
916
- */
917
- s(this, "dispose", async () => (this._removeWebSocketEventListeners(), await this.close("live room close by controller disposed!")));
918
- /**
919
- * 开启房间链接
920
- * @param url 房间链接
921
- * @returns
922
- */
923
- s(this, "open", (e) => this._ws.open(e));
924
- /**
925
- * 关闭房间
926
- * @param code
927
- * @param reason
928
- */
929
- s(this, "close", (e, i) => new Promise((n) => {
930
- this._ws.once("close", () => n(!0)), this._ws.close(e, i);
931
- }));
932
- this._addWebSocketEventListeners();
933
- }
934
- set state(e) {
935
- const i = JSON.parse(JSON.stringify(this._state));
936
- this._state = e, this.emit("stateChange", this.state, i);
937
- }
938
- get state() {
939
- return this._state;
940
- }
941
- /**
942
- * 发送数据
943
- * @param data
944
- */
945
- sendMessage(e = "") {
946
- if (e == null || e === "")
947
- throw new Error("live message is empty!");
948
- if (this.state === x.OPEN)
949
- return this._ws.send(JSON.stringify(e));
950
- throw new Error("live has not yet been initialized!");
951
- }
952
- /**
953
- * 准备关闭带看
954
- */
955
- readyClose() {
956
- this._ws && (this._ws._explicitlyClosed = !0);
957
- }
958
- }
959
- const pr = (r) => Promise.reject("unimplemented method GetVoiceSign"), je = (r, o = {}, e = []) => ({
960
- command: r,
961
- front_request_id: Ee(),
962
- data: {
963
- ...o,
964
- to_user_ids: Array.isArray(e) ? e : [e]
965
- }
966
- }), Er = () => {
967
- var r, o;
968
- window != null && window.__Realsee_Live__ && ((o = (r = window == null ? void 0 : window.__Realsee_Live__) == null ? void 0 : r.dispose) == null || o.call(r), window.__Realsee_Live__ = null);
969
- };
970
- class yr extends ue {
971
- constructor(e) {
972
- var i;
973
- super();
974
- /**
975
- * 带看的配置
976
- */
977
- s(this, "_options", {});
978
- /**
979
- * 帧数据监听
980
- */
981
- s(this, "keyframes", new ue());
982
- /**
983
- * 内置的一些数据
984
- */
985
- s(this, "_buildInData", {
986
- keyframes: {}
987
- });
988
- /**
989
- * 根据键值取帧数据
990
- * @param key 帧数据的键值
991
- * @returns
992
- */
993
- s(this, "getFramesByKey", (e) => this.snapshot[e]);
994
- /**
995
- * 发送帧数据(需要能够被序列化)
996
- * @param key 帧数据键值
997
- * @param frame 帧数据本体
998
- * @returns
999
- */
1000
- s(this, "sendKeyframe", (e, i) => {
1001
- if (this.state !== x.OPEN)
1002
- return !1;
1003
- this._buildInData.keyframes = {
1004
- ...this._buildInData.keyframes,
1005
- [e]: i
1006
- };
1007
- const n = je(K.KeyframeSync, this.snapshot);
1008
- try {
1009
- return this._controller.sendMessage(n), !0;
1010
- } catch (c) {
1011
- return O.error(c), !1;
1012
- }
1013
- });
1014
- /**
1015
- * 带看控制器
1016
- */
1017
- s(this, "_controller", new vr());
1018
- /**
1019
- * 添加带看控制的事件监听
1020
- */
1021
- s(this, "_addLiveControllerEventListeners", () => {
1022
- this._controller.on("stateChange", this._handleStateChange), this._controller.on("message", this._handleMessage);
1023
- });
1024
- /**
1025
- * 移除带看控制的事件监听
1026
- */
1027
- s(this, "_removeLiveControllerEventListeners", () => {
1028
- this._controller.off("stateChange", this._handleStateChange), this._controller.off("message", this._handleMessage);
1029
- });
1030
- /**
1031
- * 带看状态变化
1032
- * @param state
1033
- * @returns
1034
- */
1035
- s(this, "_handleStateChange", (e, i) => this.emit("stateChange", e, i));
1036
- /**
1037
- * 消息接收
1038
- * @param liveMsg
1039
- */
1040
- s(this, "_handleMessage", async (e) => {
1041
- var i, n, c, u, d;
1042
- if (typeof e == "object") {
1043
- const { command: g, data: v = {}, frontRequestId: E, code: y, message: I } = e;
1044
- if (y === "SUCCESS")
1045
- switch (g) {
1046
- case K.SelfUserInfo: {
1047
- const _ = v;
1048
- ot(this.selfInfo, _, { deep: !0 }) || (this._buildInData.selfInfo = _, this.emit("selfInfoUpdate", this._buildInData.selfInfo, E));
1049
- break;
1050
- }
1051
- case K.RoomInfo: {
1052
- const _ = v;
1053
- this._buildInData.roomInfo = Object.assign({}, _), this.emit("readyKeyframeSync", _.last_frame || {});
1054
- break;
1055
- }
1056
- case K.RTCInfo: {
1057
- const { voice_id: _, type: V } = v;
1058
- if (this._buildInData.rtcInfo = { voiceId: _, type: V }, (i = this.$RTC) != null && i.joined)
1059
- O.warn("已加入语音房间,无需重复加入!");
1060
- else if (await ((u = this.$RTC) == null ? void 0 : u.join({
1061
- voiceId: _,
1062
- userId: ((n = this.selfInfo) == null ? void 0 : n.id) || "",
1063
- roomId: (c = this.roomInfo) == null ? void 0 : c.info.room_code,
1064
- type: V
1065
- }))) {
1066
- const k = (d = this._options.initialMicroStatus) != null ? d : Z.OPEN;
1067
- await this.toggleMicro(k === Z.OPEN);
1068
- } else
1069
- O.error("加入语音房间失败");
1070
- break;
1071
- }
1072
- case K.UserList: {
1073
- const _ = v;
1074
- this._buildInData.userList = _, this.emit("userListUpdate", this.userList, E);
1075
- break;
1076
- }
1077
- case K.CustomEvent: {
1078
- const _ = v;
1079
- this.emit("broadcast", _, E);
1080
- break;
1081
- }
1082
- case K.KeyframeSync: {
1083
- const _ = v, V = Object.keys(_).reduce(
1084
- (C, k) => {
1085
- if (ot(_[k], this._buildInData.keyframes[k], {
1086
- deep: !0
1087
- }))
1088
- return C;
1089
- const U = [_[k], this._buildInData.keyframes[k], E], P = k;
1090
- return this.keyframes.emit(
1091
- P,
1092
- ...U
1093
- ), this._buildInData.keyframes[k] = _[k], C[k] = _[k], C;
1094
- },
1095
- {}
1096
- );
1097
- this.emit("keyframes", V, E);
1098
- break;
1099
- }
1100
- case K.BuiltinMsg: {
1101
- const _ = v;
1102
- this.emit("builtinEvent", _), _.event_type === q.UserChange && this.emit("userChange", _), _.event_type === q.RoomChange && this.emit("roomChange", _), _.event_type === q.UserChange && _.action === H.UserMicroStatus && await this.toggleMicro(_.data.status === Z.OPEN), _.event_type === q.RoomChange && _.action === H.RoomClose && await this._exit();
1103
- break;
1104
- }
1105
- case K.UserKickOut: {
1106
- this.emit("kickOut");
1107
- break;
1108
- }
1109
- default:
1110
- console.warn("unknown command: ", g);
1111
- }
1112
- else
1113
- this.emit("error", e);
1114
- }
1115
- });
1116
- /**
1117
- * 清理带看缓存的数据
1118
- */
1119
- s(this, "_clearLiveData", () => {
1120
- this._buildInData = { keyframes: {} };
1121
- });
1122
- /**
1123
- * 连接带看
1124
- * @param options
1125
- * @returns
1126
- */
1127
- s(this, "connect", async (e = {}) => {
1128
- var u, d, g, v;
1129
- if (this._options.url = (d = (u = e.url) != null ? u : this._options.url) != null ? d : "", this._options.getTicket = (g = e.getTicket) != null ? g : this._options.getTicket, this._options.initialMicroStatus = (v = e.rtcMicStatus) != null ? v : this._options.initialMicroStatus, !/^ws(s):\/\//.test(this._options.url) || typeof this._options.getTicket != "function")
1130
- return /^ws(s):\/\//.test(this._options.url) ? typeof this._options.getTicket != "function" ? new Error("getTicket muse be function") : !1 : new Error("Illegal realsee live room link");
1131
- const { force: i = !1 } = e;
1132
- if (this._options.rtc && !await this._options.rtc.detectMicro())
1133
- return new Error("Failed to obtain microphone authorization");
1134
- const n = this.state;
1135
- if (n === x.CONNECTING || n === x.OPEN)
1136
- if (i)
1137
- try {
1138
- await this._controller.close("force close by connect");
1139
- } catch (E) {
1140
- console.warn(E);
1141
- }
1142
- else
1143
- return new Error("已有Live实例正在连接中,请勿重复连接!");
1144
- this._clearLiveData();
1145
- const c = or(this._options.url, {
1146
- ticket: await this._options.getTicket(),
1147
- force: Number(!!i)
1148
- });
1149
- return this._controller.open(c), !0;
1150
- });
1151
- /**
1152
- * 退出带看
1153
- * @returns
1154
- */
1155
- s(this, "_exit", async () => {
1156
- var e;
1157
- this._clearLiveData();
1158
- try {
1159
- await ((e = this.$RTC) == null ? void 0 : e.quit());
1160
- } catch (i) {
1161
- O.warn(i);
1162
- }
1163
- return this.state !== x.OPEN ? !0 : await this._controller.close();
1164
- });
1165
- /**
1166
- * 退出带看
1167
- * @returns
1168
- */
1169
- s(this, "exit", async () => this.close());
1170
- /**
1171
- * 关闭带看房间
1172
- * @param code
1173
- * @param reason
1174
- * @returns
1175
- */
1176
- s(this, "close", async () => {
1177
- var e;
1178
- await this._controller.readyClose();
1179
- try {
1180
- await ((e = this.$RTC) == null ? void 0 : e.quit());
1181
- } catch (i) {
1182
- O.warn(i);
1183
- }
1184
- await this.updateStatus(q.RoomChange, H.RoomClose, {});
1185
- });
1186
- /**
1187
- * 销毁带看
1188
- * @returns
1189
- */
1190
- s(this, "dispose", async () => (this._removeLiveControllerEventListeners(), this._clearLiveData(), await this._controller.dispose()));
1191
- /**
1192
- * 设置自己的用户信息
1193
- * @param userInfo
1194
- * @returns
1195
- */
1196
- s(this, "setSelfInfo", async (e) => await this.updateStatus(q.UserChange, H.UserInfo, e));
1197
- // 仅用于用户自己的麦克风控制
1198
- s(this, "toggleMicro", async (e) => {
1199
- var n, c, u;
1200
- if (!((c = (n = this.selfInfo) == null ? void 0 : n.permission) != null && c.control_own_micro))
1201
- return !1;
1202
- const i = await ((u = this.$RTC) == null ? void 0 : u.toggleMicro(e));
1203
- return i && await this.updateStatus(
1204
- q.UserChange,
1205
- H.UserMicroStatus,
1206
- {
1207
- status: e ? Z.OPEN : Z.CLOSE
1208
- },
1209
- []
1210
- ), i;
1211
- });
1212
- /**
1213
- * 控制别人的麦
1214
- * @param microStatus
1215
- * @param toUserIds
1216
- * @returns
1217
- */
1218
- s(this, "forbidMicro", async (e, i) => {
1219
- var n, c;
1220
- return typeof this._options.canForbidUserMicro == "function" && !this._options.canForbidUserMicro(i) || !((c = (n = this.selfInfo) == null ? void 0 : n.permission) != null && c.control_other_micro) ? !1 : await this.updateStatus(
1221
- q.UserChange,
1222
- H.UserMicroStatus,
1223
- {
1224
- status: e
1225
- },
1226
- i
1227
- );
1228
- });
1229
- /**
1230
- * 控制别人的同步全量帧数据权限
1231
- * @param sync
1232
- * @param toUserIds
1233
- * @returns
1234
- */
1235
- s(this, "forbidSync", async (e, i) => {
1236
- var n, c;
1237
- return typeof this._options.canForbidUserSync == "function" && !this._options.canForbidUserSync(i) || !((c = (n = this.selfInfo) == null ? void 0 : n.permission) != null && c.control_other_sync) ? !1 : await this.updateStatus(
1238
- q.UserChange,
1239
- H.UserPermission,
1240
- { sync_frame: e },
1241
- i
1242
- );
1243
- });
1244
- /**
1245
- * 把用户踢出带看
1246
- * @param toUserIds
1247
- * @returns
1248
- */
1249
- s(this, "kick", async (e) => {
1250
- var i, n;
1251
- return typeof this._options.canForbidUserKick == "function" && !this._options.canForbidUserKick(e) || !((n = (i = this.selfInfo) == null ? void 0 : i.permission) != null && n.change_other_status) ? !1 : await this.updateStatus(
1252
- q.UserChange,
1253
- H.UserStatus,
1254
- {
1255
- status: "KICK_OUT"
1256
- },
1257
- e
1258
- );
1259
- });
1260
- this._addLiveControllerEventListeners(), this._options = Object.assign({ initialMicroStatus: Z.OPEN }, e), this._options.jsBridge = (() => {
1261
- if (e.jsBridge)
1262
- return e.jsBridge;
1263
- if (e.useBuiltInJsBridge)
1264
- return new xt();
1265
- })(), this._options.getVoiceSign = (i = e.getVoiceSign) != null ? i : pr, this._options.autoPlayConfirm = e.autoPlayConfirm, this._options.rtc = (() => {
1266
- if (e.rtc)
1267
- return e.rtc;
1268
- if (e.rtcType)
1269
- switch (e.getVoiceSign || O.error("GetVoiceSign method must be passed when using built-in RTC instances"), e.rtcType) {
1270
- case Q.RealseeVRWebViewRTC: {
1271
- if (this._options.jsBridge)
1272
- return new nt({
1273
- jsBridge: this._options.jsBridge,
1274
- getVoiceSign: this._options.getVoiceSign
1275
- });
1276
- O.error("JsBridge instance must be passed when using built-in VRWebViewRTC instances");
1277
- return;
1278
- }
1279
- case Q.RealseeBrowserChimeRTC:
1280
- return new it({
1281
- getVoiceSign: this._options.getVoiceSign,
1282
- logLevel: e.__debug__ ? st.DEBUG : st.INFO
1283
- });
1284
- case Q.RealseeBrowserRTC:
1285
- return this._options.autoPlayConfirm || O.error("autoPlayConfirm method must be passed when using built-in RealseeBrowserRTC instances"), new rt({
1286
- getVoiceSign: this._options.getVoiceSign,
1287
- autoPlayConfirm: this._options.autoPlayConfirm
1288
- });
1289
- default: {
1290
- O.error("unknown built-in RTC type");
1291
- return;
1292
- }
1293
- }
1294
- if (e.useBuiltInRTC) {
1295
- if (e.getVoiceSign || O.error("GetVoiceSign method must be passed when using built-in RTC instances"), this._options.jsBridge)
1296
- return lr && (ar || cr) || ur ? new nt({
1297
- jsBridge: this._options.jsBridge,
1298
- getVoiceSign: this._options.getVoiceSign
1299
- }) : e.builtInRTCType === ut.RealseeXChimeRTC ? new it({
1300
- getVoiceSign: this._options.getVoiceSign
1301
- }) : new rt({
1302
- getVoiceSign: this._options.getVoiceSign,
1303
- autoPlayConfirm: this._options.autoPlayConfirm
1304
- });
1305
- O.error("jsBridge instance must be passed when using built-in RTC instances");
1306
- return;
1307
- }
1308
- })(), this._options.rtc || O.warn("unused rtc"), this._options.url && this._options.getTicket && this.connect(), this._options.__debug__ && Object.assign(window, { $liveController: this._controller, $live: this });
1309
- }
1310
- get options() {
1311
- return Object.freeze(this._options || {});
1312
- }
1313
- /**
1314
- * 带看状态
1315
- */
1316
- get state() {
1317
- return this._controller.state;
1318
- }
1319
- /**
1320
- * 兼容老逻辑
1321
- * @deprecated 请直接读取 state 属性字段,未来将移除该属性
1322
- */
1323
- get readyState() {
1324
- return this._controller.state;
1325
- }
1326
- /**
1327
- * 获取当前WebSocket连接的URL。(注意:这个是WebSocket连接的完整连接,附带一些query参数)。
1328
- * @deprecated 带看不需要关注底层ws的相关信息,未来将移除
1329
- */
1330
- get url() {
1331
- return this.options.url;
1332
- }
1333
- /**
1334
- * 获取当前live使用的RTC实例
1335
- */
1336
- get $RTC() {
1337
- return this._options.rtc;
1338
- }
1339
- /**
1340
- * 获取当前live使用的jsBridge实例
1341
- */
1342
- get jsBridge() {
1343
- return this._options.jsBridge;
1344
- }
1345
- /**
1346
- * 当前帧数据快照
1347
- */
1348
- get snapshot() {
1349
- return this._buildInData.keyframes;
1350
- }
1351
- /**
1352
- * 当前用户信息
1353
- */
1354
- get selfInfo() {
1355
- return this._buildInData.selfInfo;
1356
- }
1357
- /**
1358
- * 当前用户列表
1359
- */
1360
- get userList() {
1361
- return this._buildInData.userList || [];
1362
- }
1363
- /**
1364
- * 当前带看房间信息
1365
- */
1366
- get roomInfo() {
1367
- return this._buildInData.roomInfo;
1368
- }
1369
- /**
1370
- * 修改状态
1371
- * @param evtType
1372
- * @param atnType
1373
- * @param status
1374
- * @param toUserIds
1375
- * @returns
1376
- */
1377
- async updateStatus(e, i, n, c) {
1378
- if (this.state !== x.OPEN)
1379
- return !1;
1380
- const u = Object.assign({ event_type: e, action: i }, { data: n }), d = je(K.BuiltinMsg, u, c);
1381
- try {
1382
- return this._controller.sendMessage(d), !0;
1383
- } catch (g) {
1384
- return O.error(g), !1;
1385
- }
1386
- }
1387
- /**
1388
- * 自定义广播
1389
- * @param request 广播请求的数据
1390
- * @param toUserIds
1391
- * @param timeout
1392
- * @returns
1393
- */
1394
- broadcast(e, i, n) {
1395
- return this.state !== x.OPEN ? !1 : new Promise((c, u) => {
1396
- const d = je(K.CustomEvent, e, i), g = d.front_request_id, v = n ? setTimeout(() => {
1397
- u(new Error("RESPONSE TIMEOUT")), this.off("broadcast", E);
1398
- }, n) : void 0, E = (y, I) => {
1399
- I === g && (v && clearTimeout(v), this.off("broadcast", E), c(y));
1400
- };
1401
- this.on("broadcast", E);
1402
- try {
1403
- this._controller.sendMessage(d);
1404
- } catch (y) {
1405
- u(y);
1406
- }
1407
- });
1408
- }
1409
- }
1410
- const br = (r) => (Er(), new yr(r));
1411
- var Ae = {}, Sr = {
1412
- get exports() {
1413
- return Ae;
1414
- },
1415
- set exports(r) {
1416
- Ae = r;
1417
- }
1418
- }, oe = {};
1419
- /**
1420
- * @license React
1421
- * react-jsx-runtime.production.min.js
1422
- *
1423
- * Copyright (c) Facebook, Inc. and its affiliates.
1424
- *
1425
- * This source code is licensed under the MIT license found in the
1426
- * LICENSE file in the root directory of this source tree.
1427
- */
1428
- var at;
1429
- function Cr() {
1430
- if (at)
1431
- return oe;
1432
- at = 1;
1433
- var r = D, o = Symbol.for("react.element"), e = Symbol.for("react.fragment"), i = Object.prototype.hasOwnProperty, n = r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, c = { key: !0, ref: !0, __self: !0, __source: !0 };
1434
- function u(d, g, v) {
1435
- var E, y = {}, I = null, _ = null;
1436
- v !== void 0 && (I = "" + v), g.key !== void 0 && (I = "" + g.key), g.ref !== void 0 && (_ = g.ref);
1437
- for (E in g)
1438
- i.call(g, E) && !c.hasOwnProperty(E) && (y[E] = g[E]);
1439
- if (d && d.defaultProps)
1440
- for (E in g = d.defaultProps, g)
1441
- y[E] === void 0 && (y[E] = g[E]);
1442
- return { $$typeof: o, type: d, key: I, ref: _, props: y, _owner: n.current };
1443
- }
1444
- return oe.Fragment = e, oe.jsx = u, oe.jsxs = u, oe;
1445
- }
1446
- var ae = {};
1447
- /**
1448
- * @license React
1449
- * react-jsx-runtime.development.js
1450
- *
1451
- * Copyright (c) Facebook, Inc. and its affiliates.
1452
- *
1453
- * This source code is licensed under the MIT license found in the
1454
- * LICENSE file in the root directory of this source tree.
1455
- */
1456
- var ct;
1457
- function wr() {
1458
- return ct || (ct = 1, process.env.NODE_ENV !== "production" && function() {
1459
- var r = D, o = Symbol.for("react.element"), e = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), n = Symbol.for("react.strict_mode"), c = Symbol.for("react.profiler"), u = Symbol.for("react.provider"), d = Symbol.for("react.context"), g = Symbol.for("react.forward_ref"), v = Symbol.for("react.suspense"), E = Symbol.for("react.suspense_list"), y = Symbol.for("react.memo"), I = Symbol.for("react.lazy"), _ = Symbol.for("react.offscreen"), V = Symbol.iterator, C = "@@iterator";
1460
- function k(t) {
1461
- if (t === null || typeof t != "object")
1462
- return null;
1463
- var a = V && t[V] || t[C];
1464
- return typeof a == "function" ? a : null;
1465
- }
1466
- var U = r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
1467
- function P(t) {
1468
- {
1469
- for (var a = arguments.length, l = new Array(a > 1 ? a - 1 : 0), h = 1; h < a; h++)
1470
- l[h - 1] = arguments[h];
1471
- fe("error", t, l);
1472
- }
1473
- }
1474
- function fe(t, a, l) {
1475
- {
1476
- var h = U.ReactDebugCurrentFrame, b = h.getStackAddendum();
1477
- b !== "" && (a += "%s", l = l.concat([b]));
1478
- var R = l.map(function(p) {
1479
- return String(p);
1480
- });
1481
- R.unshift("Warning: " + a), Function.prototype.apply.call(console[t], console, R);
1482
- }
1483
- }
1484
- var f = !1, w = !1, A = !1, S = !1, N = !1, M;
1485
- M = Symbol.for("react.module.reference");
1486
- function F(t) {
1487
- return !!(typeof t == "string" || typeof t == "function" || t === i || t === c || N || t === n || t === v || t === E || S || t === _ || f || w || A || typeof t == "object" && t !== null && (t.$$typeof === I || t.$$typeof === y || t.$$typeof === u || t.$$typeof === d || t.$$typeof === g || // This needs to include all possible module reference object
1488
- // types supported by any Flight configuration anywhere since
1489
- // we don't know which Flight build this will end up being used
1490
- // with.
1491
- t.$$typeof === M || t.getModuleId !== void 0));
1492
- }
1493
- function J(t, a, l) {
1494
- var h = t.displayName;
1495
- if (h)
1496
- return h;
1497
- var b = a.displayName || a.name || "";
1498
- return b !== "" ? l + "(" + b + ")" : l;
1499
- }
1500
- function ne(t) {
1501
- return t.displayName || "Context";
1502
- }
1503
- function G(t) {
1504
- if (t == null)
1505
- return null;
1506
- if (typeof t.tag == "number" && P("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof t == "function")
1507
- return t.displayName || t.name || null;
1508
- if (typeof t == "string")
1509
- return t;
1510
- switch (t) {
1511
- case i:
1512
- return "Fragment";
1513
- case e:
1514
- return "Portal";
1515
- case c:
1516
- return "Profiler";
1517
- case n:
1518
- return "StrictMode";
1519
- case v:
1520
- return "Suspense";
1521
- case E:
1522
- return "SuspenseList";
1523
- }
1524
- if (typeof t == "object")
1525
- switch (t.$$typeof) {
1526
- case d:
1527
- var a = t;
1528
- return ne(a) + ".Consumer";
1529
- case u:
1530
- var l = t;
1531
- return ne(l._context) + ".Provider";
1532
- case g:
1533
- return J(t, t.render, "ForwardRef");
1534
- case y:
1535
- var h = t.displayName || null;
1536
- return h !== null ? h : G(t.type) || "Memo";
1537
- case I: {
1538
- var b = t, R = b._payload, p = b._init;
1539
- try {
1540
- return G(p(R));
1541
- } catch (m) {
1542
- return null;
1543
- }
1544
- }
1545
- }
1546
- return null;
1547
- }
1548
- var z = Object.assign, ee = 0, T, B, te, de, Ve, $e, xe;
1549
- function Ue() {
1550
- }
1551
- Ue.__reactDisabledLog = !0;
1552
- function dt() {
1553
- {
1554
- if (ee === 0) {
1555
- T = console.log, B = console.info, te = console.warn, de = console.error, Ve = console.group, $e = console.groupCollapsed, xe = console.groupEnd;
1556
- var t = {
1557
- configurable: !0,
1558
- enumerable: !0,
1559
- value: Ue,
1560
- writable: !0
1561
- };
1562
- Object.defineProperties(console, {
1563
- info: t,
1564
- log: t,
1565
- warn: t,
1566
- error: t,
1567
- group: t,
1568
- groupCollapsed: t,
1569
- groupEnd: t
1570
- });
1571
- }
1572
- ee++;
1573
- }
1574
- }
1575
- function ht() {
1576
- {
1577
- if (ee--, ee === 0) {
1578
- var t = {
1579
- configurable: !0,
1580
- enumerable: !0,
1581
- writable: !0
1582
- };
1583
- Object.defineProperties(console, {
1584
- log: z({}, t, {
1585
- value: T
1586
- }),
1587
- info: z({}, t, {
1588
- value: B
1589
- }),
1590
- warn: z({}, t, {
1591
- value: te
1592
- }),
1593
- error: z({}, t, {
1594
- value: de
1595
- }),
1596
- group: z({}, t, {
1597
- value: Ve
1598
- }),
1599
- groupCollapsed: z({}, t, {
1600
- value: $e
1601
- }),
1602
- groupEnd: z({}, t, {
1603
- value: xe
1604
- })
1605
- });
1606
- }
1607
- ee < 0 && P("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
1608
- }
1609
- }
1610
- var Ce = U.ReactCurrentDispatcher, we;
1611
- function he(t, a, l) {
1612
- {
1613
- if (we === void 0)
1614
- try {
1615
- throw Error();
1616
- } catch (b) {
1617
- var h = b.stack.trim().match(/\n( *(at )?)/);
1618
- we = h && h[1] || "";
1619
- }
1620
- return `
1621
- ` + we + t;
1622
- }
1623
- }
1624
- var Re = !1, _e;
1625
- {
1626
- var _t = typeof WeakMap == "function" ? WeakMap : Map;
1627
- _e = new _t();
1628
- }
1629
- function Fe(t, a) {
1630
- if (!t || Re)
1631
- return "";
1632
- {
1633
- var l = _e.get(t);
1634
- if (l !== void 0)
1635
- return l;
1636
- }
1637
- var h;
1638
- Re = !0;
1639
- var b = Error.prepareStackTrace;
1640
- Error.prepareStackTrace = void 0;
1641
- var R;
1642
- R = Ce.current, Ce.current = null, dt();
1643
- try {
1644
- if (a) {
1645
- var p = function() {
1646
- throw Error();
1647
- };
1648
- if (Object.defineProperty(p.prototype, "props", {
1649
- set: function() {
1650
- throw Error();
1651
- }
1652
- }), typeof Reflect == "object" && Reflect.construct) {
1653
- try {
1654
- Reflect.construct(p, []);
1655
- } catch (Y) {
1656
- h = Y;
1657
- }
1658
- Reflect.construct(t, [], p);
1659
- } else {
1660
- try {
1661
- p.call();
1662
- } catch (Y) {
1663
- h = Y;
1664
- }
1665
- t.call(p.prototype);
1666
- }
1667
- } else {
1668
- try {
1669
- throw Error();
1670
- } catch (Y) {
1671
- h = Y;
1672
- }
1673
- t();
1674
- }
1675
- } catch (Y) {
1676
- if (Y && h && typeof Y.stack == "string") {
1677
- for (var m = Y.stack.split(`
1678
- `), $ = h.stack.split(`
1679
- `), j = m.length - 1, L = $.length - 1; j >= 1 && L >= 0 && m[j] !== $[L]; )
1680
- L--;
1681
- for (; j >= 1 && L >= 0; j--, L--)
1682
- if (m[j] !== $[L]) {
1683
- if (j !== 1 || L !== 1)
1684
- do
1685
- if (j--, L--, L < 0 || m[j] !== $[L]) {
1686
- var W = `
1687
- ` + m[j].replace(" at new ", " at ");
1688
- return t.displayName && W.includes("<anonymous>") && (W = W.replace("<anonymous>", t.displayName)), typeof t == "function" && _e.set(t, W), W;
1689
- }
1690
- while (j >= 1 && L >= 0);
1691
- break;
1692
- }
1693
- }
1694
- } finally {
1695
- Re = !1, Ce.current = R, ht(), Error.prepareStackTrace = b;
1696
- }
1697
- var ie = t ? t.displayName || t.name : "", et = ie ? he(ie) : "";
1698
- return typeof t == "function" && _e.set(t, et), et;
1699
- }
1700
- function gt(t, a, l) {
1701
- return Fe(t, !1);
1702
- }
1703
- function mt(t) {
1704
- var a = t.prototype;
1705
- return !!(a && a.isReactComponent);
1706
- }
1707
- function ge(t, a, l) {
1708
- if (t == null)
1709
- return "";
1710
- if (typeof t == "function")
1711
- return Fe(t, mt(t));
1712
- if (typeof t == "string")
1713
- return he(t);
1714
- switch (t) {
1715
- case v:
1716
- return he("Suspense");
1717
- case E:
1718
- return he("SuspenseList");
1719
- }
1720
- if (typeof t == "object")
1721
- switch (t.$$typeof) {
1722
- case g:
1723
- return gt(t.render);
1724
- case y:
1725
- return ge(t.type, a, l);
1726
- case I: {
1727
- var h = t, b = h._payload, R = h._init;
1728
- try {
1729
- return ge(R(b), a, l);
1730
- } catch (p) {
1731
- }
1732
- }
1733
- }
1734
- return "";
1735
- }
1736
- var me = Object.prototype.hasOwnProperty, Be = {}, We = U.ReactDebugCurrentFrame;
1737
- function ve(t) {
1738
- if (t) {
1739
- var a = t._owner, l = ge(t.type, t._source, a ? a.type : null);
1740
- We.setExtraStackFrame(l);
1741
- } else
1742
- We.setExtraStackFrame(null);
1743
- }
1744
- function vt(t, a, l, h, b) {
1745
- {
1746
- var R = Function.call.bind(me);
1747
- for (var p in t)
1748
- if (R(t, p)) {
1749
- var m = void 0;
1750
- try {
1751
- if (typeof t[p] != "function") {
1752
- var $ = Error((h || "React class") + ": " + l + " type `" + p + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof t[p] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
1753
- throw $.name = "Invariant Violation", $;
1754
- }
1755
- m = t[p](a, p, h, l, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
1756
- } catch (j) {
1757
- m = j;
1758
- }
1759
- m && !(m instanceof Error) && (ve(b), P("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", h || "React class", l, p, typeof m), ve(null)), m instanceof Error && !(m.message in Be) && (Be[m.message] = !0, ve(b), P("Failed %s type: %s", l, m.message), ve(null));
1760
- }
1761
- }
1762
- }
1763
- var pt = Array.isArray;
1764
- function Oe(t) {
1765
- return pt(t);
1766
- }
1767
- function Et(t) {
1768
- {
1769
- var a = typeof Symbol == "function" && Symbol.toStringTag, l = a && t[Symbol.toStringTag] || t.constructor.name || "Object";
1770
- return l;
1771
- }
1772
- }
1773
- function yt(t) {
1774
- try {
1775
- return Ke(t), !1;
1776
- } catch (a) {
1777
- return !0;
1778
- }
1779
- }
1780
- function Ke(t) {
1781
- return "" + t;
1782
- }
1783
- function qe(t) {
1784
- if (yt(t))
1785
- return P("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Et(t)), Ke(t);
1786
- }
1787
- var se = U.ReactCurrentOwner, bt = {
1788
- key: !0,
1789
- ref: !0,
1790
- __self: !0,
1791
- __source: !0
1792
- }, Ge, Ye, Ie;
1793
- Ie = {};
1794
- function St(t) {
1795
- if (me.call(t, "ref")) {
1796
- var a = Object.getOwnPropertyDescriptor(t, "ref").get;
1797
- if (a && a.isReactWarning)
1798
- return !1;
1799
- }
1800
- return t.ref !== void 0;
1801
- }
1802
- function Ct(t) {
1803
- if (me.call(t, "key")) {
1804
- var a = Object.getOwnPropertyDescriptor(t, "key").get;
1805
- if (a && a.isReactWarning)
1806
- return !1;
1807
- }
1808
- return t.key !== void 0;
1809
- }
1810
- function wt(t, a) {
1811
- if (typeof t.ref == "string" && se.current && a && se.current.stateNode !== a) {
1812
- var l = G(se.current.type);
1813
- Ie[l] || (P('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', G(se.current.type), t.ref), Ie[l] = !0);
1814
- }
1815
- }
1816
- function Rt(t, a) {
1817
- {
1818
- var l = function() {
1819
- Ge || (Ge = !0, P("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", a));
1820
- };
1821
- l.isReactWarning = !0, Object.defineProperty(t, "key", {
1822
- get: l,
1823
- configurable: !0
1824
- });
1825
- }
1826
- }
1827
- function Ot(t, a) {
1828
- {
1829
- var l = function() {
1830
- Ye || (Ye = !0, P("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", a));
1831
- };
1832
- l.isReactWarning = !0, Object.defineProperty(t, "ref", {
1833
- get: l,
1834
- configurable: !0
1835
- });
1836
- }
1837
- }
1838
- var It = function(t, a, l, h, b, R, p) {
1839
- var m = {
1840
- // This tag allows us to uniquely identify this as a React Element
1841
- $$typeof: o,
1842
- // Built-in properties that belong on the element
1843
- type: t,
1844
- key: a,
1845
- ref: l,
1846
- props: p,
1847
- // Record the component responsible for creating this element.
1848
- _owner: R
1849
- };
1850
- return m._store = {}, Object.defineProperty(m._store, "validated", {
1851
- configurable: !1,
1852
- enumerable: !1,
1853
- writable: !0,
1854
- value: !1
1855
- }), Object.defineProperty(m, "_self", {
1856
- configurable: !1,
1857
- enumerable: !1,
1858
- writable: !1,
1859
- value: h
1860
- }), Object.defineProperty(m, "_source", {
1861
- configurable: !1,
1862
- enumerable: !1,
1863
- writable: !1,
1864
- value: b
1865
- }), Object.freeze && (Object.freeze(m.props), Object.freeze(m)), m;
1866
- };
1867
- function Tt(t, a, l, h, b) {
1868
- {
1869
- var R, p = {}, m = null, $ = null;
1870
- l !== void 0 && (qe(l), m = "" + l), Ct(a) && (qe(a.key), m = "" + a.key), St(a) && ($ = a.ref, wt(a, b));
1871
- for (R in a)
1872
- me.call(a, R) && !bt.hasOwnProperty(R) && (p[R] = a[R]);
1873
- if (t && t.defaultProps) {
1874
- var j = t.defaultProps;
1875
- for (R in j)
1876
- p[R] === void 0 && (p[R] = j[R]);
1877
- }
1878
- if (m || $) {
1879
- var L = typeof t == "function" ? t.displayName || t.name || "Unknown" : t;
1880
- m && Rt(p, L), $ && Ot(p, L);
1881
- }
1882
- return It(t, m, $, b, h, se.current, p);
1883
- }
1884
- }
1885
- var Te = U.ReactCurrentOwner, He = U.ReactDebugCurrentFrame;
1886
- function re(t) {
1887
- if (t) {
1888
- var a = t._owner, l = ge(t.type, t._source, a ? a.type : null);
1889
- He.setExtraStackFrame(l);
1890
- } else
1891
- He.setExtraStackFrame(null);
1892
- }
1893
- var ke;
1894
- ke = !1;
1895
- function Pe(t) {
1896
- return typeof t == "object" && t !== null && t.$$typeof === o;
1897
- }
1898
- function Je() {
1899
- {
1900
- if (Te.current) {
1901
- var t = G(Te.current.type);
1902
- if (t)
1903
- return `
1904
-
1905
- Check the render method of \`` + t + "`.";
1906
- }
1907
- return "";
1908
- }
1909
- }
1910
- function kt(t) {
1911
- {
1912
- if (t !== void 0) {
1913
- var a = t.fileName.replace(/^.*[\\\/]/, ""), l = t.lineNumber;
1914
- return `
1915
-
1916
- Check your code at ` + a + ":" + l + ".";
1917
- }
1918
- return "";
1919
- }
1920
- }
1921
- var ze = {};
1922
- function Pt(t) {
1923
- {
1924
- var a = Je();
1925
- if (!a) {
1926
- var l = typeof t == "string" ? t : t.displayName || t.name;
1927
- l && (a = `
1928
-
1929
- Check the top-level render call using <` + l + ">.");
1930
- }
1931
- return a;
1932
- }
1933
- }
1934
- function Xe(t, a) {
1935
- {
1936
- if (!t._store || t._store.validated || t.key != null)
1937
- return;
1938
- t._store.validated = !0;
1939
- var l = Pt(a);
1940
- if (ze[l])
1941
- return;
1942
- ze[l] = !0;
1943
- var h = "";
1944
- t && t._owner && t._owner !== Te.current && (h = " It was passed a child from " + G(t._owner.type) + "."), re(t), P('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', l, h), re(null);
1945
- }
1946
- }
1947
- function Ze(t, a) {
1948
- {
1949
- if (typeof t != "object")
1950
- return;
1951
- if (Oe(t))
1952
- for (var l = 0; l < t.length; l++) {
1953
- var h = t[l];
1954
- Pe(h) && Xe(h, a);
1955
- }
1956
- else if (Pe(t))
1957
- t._store && (t._store.validated = !0);
1958
- else if (t) {
1959
- var b = k(t);
1960
- if (typeof b == "function" && b !== t.entries)
1961
- for (var R = b.call(t), p; !(p = R.next()).done; )
1962
- Pe(p.value) && Xe(p.value, a);
1963
- }
1964
- }
1965
- }
1966
- function Nt(t) {
1967
- {
1968
- var a = t.type;
1969
- if (a == null || typeof a == "string")
1970
- return;
1971
- var l;
1972
- if (typeof a == "function")
1973
- l = a.propTypes;
1974
- else if (typeof a == "object" && (a.$$typeof === g || // Note: Memo only checks outer props here.
1975
- // Inner props are checked in the reconciler.
1976
- a.$$typeof === y))
1977
- l = a.propTypes;
1978
- else
1979
- return;
1980
- if (l) {
1981
- var h = G(a);
1982
- vt(l, t.props, "prop", h, t);
1983
- } else if (a.PropTypes !== void 0 && !ke) {
1984
- ke = !0;
1985
- var b = G(a);
1986
- P("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", b || "Unknown");
1987
- }
1988
- typeof a.getDefaultProps == "function" && !a.getDefaultProps.isReactClassApproved && P("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
1989
- }
1990
- }
1991
- function jt(t) {
1992
- {
1993
- for (var a = Object.keys(t.props), l = 0; l < a.length; l++) {
1994
- var h = a[l];
1995
- if (h !== "children" && h !== "key") {
1996
- re(t), P("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", h), re(null);
1997
- break;
1998
- }
1999
- }
2000
- t.ref !== null && (re(t), P("Invalid attribute `ref` supplied to `React.Fragment`."), re(null));
2001
- }
2002
- }
2003
- function Qe(t, a, l, h, b, R) {
2004
- {
2005
- var p = F(t);
2006
- if (!p) {
2007
- var m = "";
2008
- (t === void 0 || typeof t == "object" && t !== null && Object.keys(t).length === 0) && (m += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
2009
- var $ = kt(b);
2010
- $ ? m += $ : m += Je();
2011
- var j;
2012
- t === null ? j = "null" : Oe(t) ? j = "array" : t !== void 0 && t.$$typeof === o ? (j = "<" + (G(t.type) || "Unknown") + " />", m = " Did you accidentally export a JSX literal instead of a component?") : j = typeof t, P("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", j, m);
2013
- }
2014
- var L = Tt(t, a, l, b, R);
2015
- if (L == null)
2016
- return L;
2017
- if (p) {
2018
- var W = a.children;
2019
- if (W !== void 0)
2020
- if (h)
2021
- if (Oe(W)) {
2022
- for (var ie = 0; ie < W.length; ie++)
2023
- Ze(W[ie], t);
2024
- Object.freeze && Object.freeze(W);
2025
- } else
2026
- P("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
2027
- else
2028
- Ze(W, t);
2029
- }
2030
- return t === i ? jt(L) : Nt(L), L;
2031
- }
2032
- }
2033
- function Lt(t, a, l) {
2034
- return Qe(t, a, l, !0);
2035
- }
2036
- function At(t, a, l) {
2037
- return Qe(t, a, l, !1);
2038
- }
2039
- var Mt = At, Dt = Lt;
2040
- ae.Fragment = i, ae.jsx = Mt, ae.jsxs = Dt;
2041
- }()), ae;
2042
- }
2043
- (function(r) {
2044
- process.env.NODE_ENV === "production" ? r.exports = Cr() : r.exports = wr();
2045
- })(Sr);
2046
- const Rr = Ae.jsx;
2047
- function jr(r) {
2048
- const o = Gt(null), e = br(r), i = e.jsBridge, n = (f) => /* @__PURE__ */ Rr(o.Provider, { value: e, children: f.children }), c = () => {
2049
- const f = D.useContext(o);
2050
- if (!f)
2051
- throw new Error("LiveProvider never found.");
2052
- return f;
2053
- }, u = () => e, d = () => e.$RTC, g = () => d(), v = () => async (f) => await e.connect(f);
2054
- function E(f, w, A = []) {
2055
- const S = c(), N = [S, name, ...A], M = () => S.keyframes.off(f, w);
2056
- return D.useEffect(() => (S.keyframes.on(f, w), M), N), M;
2057
- }
2058
- function y() {
2059
- const f = c();
2060
- return {
2061
- connect: async (T) => await f.connect(T),
2062
- broadcast: async (T, B, te = 0) => await f.broadcast(T, B, te),
2063
- exit: async () => await f.exit(),
2064
- kick: async (T) => await f.kick(T),
2065
- toggleMicro: (T) => f.toggleMicro(T),
2066
- forbidMicro: async (T, B = []) => await f.forbidMicro(T, B),
2067
- forbidSync: (T, B = []) => f.forbidSync(T, B),
2068
- sendKeyframe: (T, B) => f.sendKeyframe(T, B),
2069
- getFramesByKey: (T) => f.getFramesByKey(T),
2070
- setSelfInfo: (T) => f.setSelfInfo(T),
2071
- updateStatus: (T, B, te, de) => f.updateStatus(T, B, te, de)
2072
- };
2073
- }
2074
- function I(f) {
2075
- const w = c(), [A, S] = D.useState(w.getFramesByKey(f));
2076
- D.useEffect(() => {
2077
- const M = (ne) => S(ne), F = f, J = M;
2078
- return w.keyframes.on(F, J), () => w.keyframes.off(F, J);
2079
- }, [w]);
2080
- const N = D.useCallback(
2081
- (M) => w.sendKeyframe(f, M),
2082
- [w]
2083
- );
2084
- return [A, N];
2085
- }
2086
- function _(f, w, A = []) {
2087
- const S = c(), N = () => S.off(f, w), M = [S, f, ...A];
2088
- return D.useEffect(() => (S.on(f, w), N), M), N;
2089
- }
2090
- function V() {
2091
- const f = c(), [w, A] = D.useState(f.state);
2092
- return D.useEffect(() => {
2093
- const S = (N) => A(N);
2094
- return f.on("stateChange", S), () => f.off("stateChange", S);
2095
- }, [f]), w;
2096
- }
2097
- function C() {
2098
- const f = c();
2099
- return {
2100
- join: (F) => f.$RTC.join(F),
2101
- quit: () => f.$RTC.quit(),
2102
- shock: () => {
2103
- var F, J;
2104
- return (J = (F = f.$RTC).shock) == null ? void 0 : J.call(F);
2105
- },
2106
- toggleMicro: (F) => f.$RTC.toggleMicro(F),
2107
- detectMicro: () => f.$RTC.detectMicro()
2108
- };
2109
- }
2110
- function k(f, w, A = []) {
2111
- const S = c(), N = () => S.$RTC.off(f, w), M = [S, f, ...A];
2112
- return D.useEffect(() => (S.$RTC.on(f, w), N), M), N;
2113
- }
2114
- function U() {
2115
- const f = c(), [w, A] = D.useState(
2116
- f.selfInfo || {}
2117
- ), S = (M) => A(M);
2118
- D.useEffect(() => (f.on("selfInfoUpdate", S), () => f.off("selfInfoUpdate", S)), [f]);
2119
- const N = D.useCallback(
2120
- async (M) => await f.setSelfInfo(M),
2121
- [f]
2122
- );
2123
- return [w, N];
2124
- }
2125
- function P() {
2126
- const f = c(), [w, A] = D.useState(
2127
- f.snapshot
2128
- );
2129
- return D.useEffect(() => {
2130
- const S = (N) => A(N);
2131
- return f.on("keyframes", S), () => f.off("keyframes", S);
2132
- }), w;
2133
- }
2134
- function fe() {
2135
- const f = c(), [w, A] = D.useState(f.userList), S = (N) => A(N);
2136
- return D.useEffect(() => (f.on("userListUpdate", S), () => f.off("userListUpdate", S)), [f]), w;
2137
- }
2138
- return {
2139
- live: e,
2140
- jsBridge: i,
2141
- LiveProvider: n,
2142
- unsafe__useLiveInstance: u,
2143
- unsafe__useRTCInstance: g,
2144
- useConnect: v,
2145
- useKeyframe: I,
2146
- useKeyframeUpdateCallback: E,
2147
- useLiveAction: y,
2148
- useLiveEventCallback: _,
2149
- useLiveState: V,
2150
- useRTCAction: C,
2151
- useRTCEventCallback: k,
2152
- useSelfInfo: U,
2153
- useKeyframesSnapshot: P,
2154
- useUserList: fe
2155
- };
2156
- }
2157
- export {
2158
- rt as BrowserRTC,
2159
- it as BrowserRTC4Chime,
2160
- ut as BuiltInRTCType,
2161
- H as BuiltinActionType,
2162
- q as BuiltinEventType,
2163
- K as Command,
2164
- Me as CoreRTC,
2165
- x as LiveState,
2166
- tr as MemUserStatus,
2167
- Z as MicroStatus,
2168
- lt as RTCJoinedInfoCodeEnum,
2169
- Q as RTCType,
2170
- er as UserStatus,
2171
- nt as VRWebViewRTC,
2172
- ir as WebSocketCloseError,
2173
- rr as WebSocketErrorType,
2174
- Le as WebSocketState,
2175
- br as createLive,
2176
- jr as createLiveReact,
2177
- Nr as parseLiveMsg,
2178
- nr as parseWSClsErr
2179
- };