@vkontakte/calls-sdk 2.8.12-dev.a796d948.0 → 2.8.12-dev.aa3efa18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/calls-sdk.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * @vkontakte/calls-sdk v2.8.12-dev.a796d948.0
3
- * Mon, 17 Aug 2026 10:35:00 GMT
2
+ * @vkontakte/calls-sdk v2.8.12-dev.aa3efa18.0
3
+ * Thu, 20 Aug 2026 05:48:42 GMT
4
4
  * https://calls-sdk.cdn-vk.ru/doc/latest/index.html
5
5
  */
6
6
 
@@ -1254,15 +1254,17 @@ var O = /* @__PURE__ */ function(e) {
1254
1254
  return e[e.CAMERA = 1] = "CAMERA", e[e.SCREEN = 2] = "SCREEN", e;
1255
1255
  }({}), Jt = class extends b {
1256
1256
  constructor(e = z, t = null) {
1257
- super(), h(this, "_stream", null), h(this, "_screenTrack", null), h(this, "_audioShareTrack", null), h(this, "_screenShareTrack", null), h(this, "_sendVideoTrack", null), h(this, "_cameraVideoTrack", null), h(this, "_micAudioTrack", null), h(this, "_audioEffectsTrack", null), h(this, "_mediaSettings", D()), h(this, "_lastMediaSettings", null), h(this, "_videoStatusOnScreenCapturingEnabled", !1), h(this, "_effect", null), h(this, "_audioEffectParams", null), h(this, "_onDeviceChange", void 0), h(this, "_animojiEnabled", !1), h(this, "_videoEffectsFpsLimiter", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "videoTrackMuteHandler", () => {
1258
- this._mediaSettings.isVideoEnabled && this.toggleVideo(!0);
1257
+ super(), h(this, "_stream", null), h(this, "_screenTrack", null), h(this, "_audioShareTrack", null), h(this, "_screenShareTrack", null), h(this, "_sendVideoTrack", null), h(this, "_cameraVideoTrack", null), h(this, "_micAudioTrack", null), h(this, "_audioEffectsTrack", null), h(this, "_mediaSettings", D()), h(this, "_lastMediaSettings", null), h(this, "_videoStatusOnScreenCapturingEnabled", !1), h(this, "_effect", null), h(this, "_audioEffectParams", null), h(this, "_onDeviceChange", void 0), h(this, "_animojiEnabled", !1), h(this, "_videoEffectsFpsLimiter", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_cameraTrackSetAt", 0), h(this, "_cameraMuteRecoveredAt", 0), h(this, "videoTrackMuteHandler", () => {
1258
+ !this._mediaSettings.isVideoEnabled || this._cameraMuteRecoveredAt >= this._cameraTrackSetAt || E.browserName() !== "Safari" || (this._cameraMuteRecoveredAt = Date.now(), this._logger?.log(C.ERROR, "camera_mute_recover"), this._debug.log("[MediaSource] Safari camera mute recovery"), this.toggleVideo(!0).then(() => this._logger?.log(C.ERROR, "camera_mute_recover_success")).catch((e) => {
1259
+ this._logger?.log(C.ERROR, "camera_mute_recover_fail"), this._debug.warn("[MediaSource] Camera mute recovery failed", e);
1260
+ }));
1259
1261
  }), this._debug = e, this._logger = t, this._initDeviceChangeListener(), N.audioShare && (this._audioShareTrack = this.getSilentAudioShareTrack()), N.enableVideoEffectsFpsDegradation && (this._videoEffectsFpsLimiter = new Gt(this._debug), this._videoEffectsFpsLimiter.addEventListener(Wt.FpsLimit, this.handleVideoEffectsLowFps.bind(this)));
1260
1262
  }
1261
1263
  get cameraVideoTrack() {
1262
1264
  return this._cameraVideoTrack;
1263
1265
  }
1264
1266
  set cameraVideoTrack(e) {
1265
- this._cameraVideoTrack && this._cameraVideoTrack.removeEventListener("mute", this.videoTrackMuteHandler), this._cameraVideoTrack = e, this._cameraVideoTrack && this._cameraVideoTrack.addEventListener("mute", this.videoTrackMuteHandler), N.consumerFastScreenShare && (this._screenShareTrack = this.getBlackScreenShareTrack());
1267
+ this._cameraVideoTrack && this._cameraVideoTrack.removeEventListener("mute", this.videoTrackMuteHandler), this._cameraVideoTrack = e, this._cameraVideoTrack && (this._cameraTrackSetAt = Date.now(), this._cameraVideoTrack.addEventListener("mute", this.videoTrackMuteHandler)), N.consumerFastScreenShare && (this._screenShareTrack = this.getBlackScreenShareTrack());
1266
1268
  }
1267
1269
  async request(e = [S.AUDIO], t = !0) {
1268
1270
  if (this._stream) return;
@@ -1403,8 +1405,8 @@ var O = /* @__PURE__ */ function(e) {
1403
1405
  }
1404
1406
  async _replaceLocalTrack(e, t) {
1405
1407
  if (!this._stream) return;
1406
- let n = this._stream.getTracks().find((t) => t.kind === e.kind && t.contentHint === e.contentHint);
1407
- n?.id !== e.id && (n ? (n !== this._audioEffectsTrack && n.stop(), this._stream?.removeTrack(n), this._stream?.addTrack(e), this._triggerEvent("TRACK_REPLACED", e, t)) : (this._stream.addTrack(e), this._triggerEvent("TRACK_REPLACED", e, t)));
1408
+ let n = this._stream.getTracks().filter((t) => t.kind === e.kind), r = n.find((t) => t.contentHint === e.contentHint) ?? n.find((e) => e !== this._audioEffectsTrack);
1409
+ r?.id !== e.id && (r ? (r !== this._audioEffectsTrack && r.stop(), this._stream?.removeTrack(r), this._stream?.addTrack(e), this._triggerEvent("TRACK_REPLACED", e, t)) : (this._stream.addTrack(e), this._triggerEvent("TRACK_REPLACED", e, t)));
1408
1410
  }
1409
1411
  async _setEffect(e, t) {
1410
1412
  if (this._videoEffectsFpsLimiter?.watch(N.videoEffects), !N.videoEffects) return t;
@@ -2183,7 +2185,7 @@ var mn = pn.getInstance(), N = class e {
2183
2185
  return 1.1;
2184
2186
  }
2185
2187
  static get sdkVersion() {
2186
- return "2.8.12-dev.a796d948.0";
2188
+ return "2.8.12-dev.aa3efa18.0";
2187
2189
  }
2188
2190
  static get debug() {
2189
2191
  return e._params.debug;
@@ -3581,7 +3583,7 @@ var Mn = 0, Nn = 1, Pn = 2, Fn = 3, In = 4, Ln = 5, Rn = 6, zn = 7, Bn = 0, Vn =
3581
3583
  };
3582
3584
  }
3583
3585
  }, U = /* @__PURE__ */ function(e) {
3584
- return e.CALL_INIT = "call_init", e.CALL_WARMUP = "call_warmup", e.CALL_START = "call_start", e.CALL_ACCEPTED_OUTGOING = "call_accepted_outgoing", e.CALL_ACCEPTED_INCOMING = "call_accepted_incoming", e.FIRST_MEDIA_SENT = "first_media_sent", e.CALL_FINISH = "call_finish", e.CODEC_USAGE = "codec_usage", e.SIGNALING_CONNECTED = "signaling_connected", e.SCREENSHARE_FIRST_FRAME = "screen_share_first_frame", e.FIRST_MEDIA_RECEIVED = "first_media_received", e.CALL_DECLINED_OR_HANGED_LOCALLY = "CallDeclinedOrHangedLocally", e.USER_FEEDBACK_RECEIVED = "UserFeedbackReceived", e.SIGNALING_PING_SUMMARY = "signaling_ping_summary", e.SIGNALING_COMMAND_SUMMARY = "signaling_command_summary", e.WEBSOCKET_CONNECTED = "websocket_connected", e.WEBSOCKET_RECONNECTED = "websocket_reconnected", e.WEBSOCKET_FAILED_PINGS = "websocket_failed_pings", e.WEBSOCKET_FAILED_EXCEPTION = "websocket_failed_exception", e.WEBSOCKET_TIMEOUT = "websocket_timeout", e.WEBSOCKET_RESTART = "websocket_restart", e.WEBTRANSPORT_CONNECTED = "webtransport_connected", e.WEBTRANSPORT_RECONNECTED = "webtransport_reconnected", e.WEBTRANSPORT_FAILED_PINGS = "webtransport_failed_pings", e.WEBTRANSPORT_FAILED_EXCEPTION = "webtransport_failed_exception", e.WEBTRANSPORT_TIMEOUT = "webtransport_timeout", e.WEBTRANSPORT_RESTART = "webtransport_restart", e;
3586
+ return e.CALL_INIT = "call_init", e.CALL_START = "call_start", e.CALL_ACCEPTED_OUTGOING = "call_accepted_outgoing", e.CALL_ACCEPTED_INCOMING = "call_accepted_incoming", e.FIRST_MEDIA_SENT = "first_media_sent", e.CALL_FINISH = "call_finish", e.CODEC_USAGE = "codec_usage", e.SIGNALING_CONNECTED = "signaling_connected", e.SCREENSHARE_FIRST_FRAME = "screen_share_first_frame", e.FIRST_MEDIA_RECEIVED = "first_media_received", e.CALL_DECLINED_OR_HANGED_LOCALLY = "CallDeclinedOrHangedLocally", e.USER_FEEDBACK_RECEIVED = "UserFeedbackReceived", e.SIGNALING_PING_SUMMARY = "signaling_ping_summary", e.SIGNALING_COMMAND_SUMMARY = "signaling_command_summary", e.WEBSOCKET_CONNECTED = "websocket_connected", e.WEBSOCKET_RECONNECTED = "websocket_reconnected", e.WEBSOCKET_FAILED_PINGS = "websocket_failed_pings", e.WEBSOCKET_FAILED_EXCEPTION = "websocket_failed_exception", e.WEBSOCKET_TIMEOUT = "websocket_timeout", e.WEBSOCKET_RESTART = "websocket_restart", e.WEBTRANSPORT_CONNECTED = "webtransport_connected", e.WEBTRANSPORT_RECONNECTED = "webtransport_reconnected", e.WEBTRANSPORT_FAILED_PINGS = "webtransport_failed_pings", e.WEBTRANSPORT_FAILED_EXCEPTION = "webtransport_failed_exception", e.WEBTRANSPORT_TIMEOUT = "webtransport_timeout", e.WEBTRANSPORT_RESTART = "webtransport_restart", e;
3585
3587
  }(U || {}), Jn = 1e3;
3586
3588
  function W(e, t, n = 0) {
3587
3589
  return t in e && e[t] ? e[t] : n;
@@ -3700,7 +3702,7 @@ function ir(e, t, n = !1) {
3700
3702
  }).filter((e) => !!e);
3701
3703
  }
3702
3704
  function ar(e, t, n = !1) {
3703
- if (!t || !t.rtps || !e.rtps) return e;
3705
+ if (!t || !t.rtps.length || !e.rtps.length) return e;
3704
3706
  let r, i;
3705
3707
  n && (r = Qn("ssrc", e?.remoteRtps || []), i = Qn("ssrc", t?.remoteRtps || []));
3706
3708
  let a = Qn("ssrc", e.rtps), o = Qn("ssrc", t.rtps), s = (e.timestamp - t.timestamp) / 1e3;
@@ -3997,7 +3999,7 @@ var Er = class {
3997
3999
  try {
3998
4000
  this._pc = this._createPeerConnection();
3999
4001
  } catch (e) {
4000
- this._debug.error("Failed to create RTCPeerConnection:", e), this.close(e);
4002
+ this._debug.error("Failed to create RTCPeerConnection:", e), this._failedOnCreate = e;
4001
4003
  return;
4002
4004
  }
4003
4005
  if (this._isMaster) {
@@ -4032,7 +4034,7 @@ var Er = class {
4032
4034
  return;
4033
4035
  }
4034
4036
  if (this._failedOnCreate) {
4035
- this.close(this._failedOnCreate);
4037
+ this._finishClose(this._failedOnCreate);
4036
4038
  return;
4037
4039
  }
4038
4040
  if (this._debug.debug("DirectTransport: Open transport", { participantId: this._participantId }), this._isOpen = !0, this._remotePeerId = e, !this._isMaster) try {
@@ -4117,7 +4119,10 @@ var Er = class {
4117
4119
  }
4118
4120
  }
4119
4121
  close(e) {
4120
- this._isOpen && (this._isOpen = !1, this._stopReconnection(), this._stopStatInterval(), this._stopSettingsInterval(), this._disposePeerConnection(), this._onNetworkStatus(1), this.unsubscribe(), e ? (this._debug.error("DirectTransport: Closed", e, { participantId: this._participantId }), this._setState(J.FAILED)) : (this._debug.debug("DirectTransport: Closed", { participantId: this._participantId }), this._setState(J.CLOSED)), this._triggerEvent(X.PEER_CONNECTION_CLOSED));
4122
+ this._isOpen && this._finishClose(e);
4123
+ }
4124
+ _finishClose(e) {
4125
+ this._isOpen = !1, this._stopReconnection(), this._stopStatInterval(), this._stopSettingsInterval(), this._disposePeerConnection(), this._onNetworkStatus(1), this.unsubscribe(), e ? (this._debug.error("DirectTransport: Closed", e, { participantId: this._participantId }), this._setState(J.FAILED)) : (this._debug.debug("DirectTransport: Closed", { participantId: this._participantId }), this._setState(J.CLOSED)), this._triggerEvent(X.PEER_CONNECTION_CLOSED);
4121
4126
  }
4122
4127
  _setState(e) {
4123
4128
  this._state !== e && (this._debug.debug(`DirectTransport: State changed to ${e}`, { participantId: this._participantId }), this._state = e, this._triggerEvent(X.STATE_CHANGED, e));
@@ -4219,13 +4224,18 @@ var Er = class {
4219
4224
  }
4220
4225
  _onIceConnectionStateChange() {
4221
4226
  switch (this._debug.debug(`DirectTransport: Ice Connection state changed to ${this._pc?.iceConnectionState}`, { participantId: this._participantId }), this._pc?.iceConnectionState) {
4222
- case "checking":
4227
+ case "checking": {
4223
4228
  let e = this.getState();
4224
4229
  e === J.IDLE || e === J.OPENED ? this._setState(J.CONNECTING) : this._setState(J.RECONNECTING);
4225
4230
  break;
4231
+ }
4226
4232
  case "connected":
4227
4233
  case "completed":
4228
- this._pc?.connectionState !== "connected" && this._markConnected();
4234
+ this._pc?.connectionState !== "connected" && (this._debug.warn("DirectTransport: marking connected via iceConnectionState fallback", {
4235
+ participantId: this._participantId,
4236
+ connectionState: this._pc?.connectionState,
4237
+ iceConnectionState: this._pc?.iceConnectionState
4238
+ }), this._logger?.log(C.ERROR, "iceConnectionState-fallback"), this._markConnected());
4229
4239
  break;
4230
4240
  }
4231
4241
  }
@@ -6064,7 +6074,10 @@ var yi = 2 ** 15 - 1, bi = 1, xi = 5, Si = 5, Ci = class e {
6064
6074
  let n = t.streams[0];
6065
6075
  n ? (n.onremovetrack || (n.onremovetrack = (e) => {
6066
6076
  this._triggerEvent(X.REMOTE_TRACK_REMOVED, n.id, n, e.track);
6067
- }), n.getTracks().find((e) => e.id === t.track.id) || n.addTrack(t.track), this._rtpReceiversByStreamId[n.id] = t.receiver, this._triggerEvent(X.REMOTE_TRACK_ADDED, n.id, n, t.track)) : this._debug.error("[single] unable to get media stream from track event");
6077
+ }), n.getTracks().find((e) => e.id === t.track.id) || (this._debug.warn("[single] remote track missing from stream, re-adding", {
6078
+ streamId: n.id,
6079
+ trackId: t.track.id
6080
+ }), this._logger?.log(C.ERROR, "ontrack-empty-stream"), n.addTrack(t.track)), this._rtpReceiversByStreamId[n.id] = t.receiver, this._triggerEvent(X.REMOTE_TRACK_ADDED, n.id, n, t.track)) : this._debug.error("[single] unable to get media stream from track event");
6068
6081
  }
6069
6082
  _onSignalingStateChange(e, t) {
6070
6083
  this._debug.debug("[single] signaling state changed", { state: e.signalingState }, t);
@@ -6129,7 +6142,7 @@ var yi = 2 ** 15 - 1, bi = 1, xi = 5, Si = 5, Ci = class e {
6129
6142
  let a = i.getVideoTracks()[0], o = a.getSettings().width, s = a.getSettings().height, c = tn(o, s, this._serverSettings.camera?.bitrates?.generic), l = t || !$t(this._simulcastInfo, c);
6130
6143
  if (!c.streams.length || !l) return;
6131
6144
  let u = r.sender.getParameters();
6132
- if (u.encodings || (u.encodings = [{}]), !(u.encodings.length <= 1)) {
6145
+ if (u.encodings.length || (u.encodings = [{}]), !(u.encodings.length <= 1)) {
6133
6146
  if (this._debug.log(`_changeSimulcastInfo: ${o}x${s} command: ${JSON.stringify(c)} `), e) {
6134
6147
  let e = 0;
6135
6148
  for (let t of u.encodings) t.scaleResolutionDownBy = nn(t.rid), t.scalabilityMode = Xt, e >= c.streams.length ? (t.maxBitrate = 0, t.active = !1) : (t.active = !0, t.maxBitrate = c.streams[e].bitrate), e++;
@@ -6137,7 +6150,7 @@ var yi = 2 ** 15 - 1, bi = 1, xi = 5, Si = 5, Ci = class e {
6137
6150
  this._debug.error("Failed to set sender parameters", u, e);
6138
6151
  }), this._debug.log(`_changeSimulcastInfo: actual encodings: ${JSON.stringify(u.encodings)} `);
6139
6152
  }
6140
- if (this._simulcastInfo = c, c.streams) {
6153
+ if (this._simulcastInfo = c, c.streams.length) {
6141
6154
  let e = {
6142
6155
  mediaSource: qt.CAMERA,
6143
6156
  simulcastInfo: c
@@ -7096,7 +7109,7 @@ var Ma = new Set([
7096
7109
  description: e.sdp,
7097
7110
  sessionId: n
7098
7111
  };
7099
- return t && (r.ssrcs = t), this._send(V.ACCEPT_PRODUCER, r);
7112
+ return t.length && (r.ssrcs = t), this._send(V.ACCEPT_PRODUCER, r);
7100
7113
  }
7101
7114
  async changePriorities(e) {
7102
7115
  return this._send(V.CHANGE_STREAM_PRIORITIES, { typedPriorities: e }).catch(() => {});
@@ -7861,8 +7874,29 @@ function ro(e, t) {
7861
7874
  return to(t, r);
7862
7875
  }
7863
7876
  //#endregion
7877
+ //#region src/utils/IceServers.ts
7878
+ function io(e) {
7879
+ if (!e) return null;
7880
+ let t = Array.from(new Set((e.urls ?? []).map((e) => e.trim()).filter((e) => e.length > 0)));
7881
+ return t.length ? {
7882
+ ...e,
7883
+ urls: t
7884
+ } : null;
7885
+ }
7886
+ function ao(e, t) {
7887
+ let n = [], r = io(e), i = io(t);
7888
+ if (r && n.push(r), i) {
7889
+ let e = [...i.urls];
7890
+ e.push(`${e[e.length - 1]}?transport=tcp`), n.push({
7891
+ ...i,
7892
+ urls: e
7893
+ });
7894
+ }
7895
+ return n;
7896
+ }
7897
+ //#endregion
7864
7898
  //#region src/utils/Lz4.ts
7865
- function io(e, t) {
7899
+ function oo(e, t) {
7866
7900
  let n = new Uint8Array(t), r = 0, i = 0;
7867
7901
  for (; r < e.length && i < t;) {
7868
7902
  let a = e[r++], o = a >> 4, s = a & 15;
@@ -7889,7 +7923,7 @@ function io(e, t) {
7889
7923
  }
7890
7924
  //#endregion
7891
7925
  //#region src/classes/AudioFix.ts
7892
- var ao = class {
7926
+ var so = class {
7893
7927
  constructor(e, t = z, n = null) {
7894
7928
  h(this, "_fixNoPacketsApplied", !1), h(this, "_fixNoPacketsChecked", !1), h(this, "_fixTooManyPacketsApplied", !1), h(this, "_fixTooManyPacketsSucceeded", !1), h(this, "_fixTooManyPacketsFailed", !1), h(this, "_fixTooManyPacketsTime", void 0), h(this, "_mediaSource", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_lastPacketsSent", void 0), h(this, "_lastPacketsSentTime", void 0), h(this, "_toggleAudioPromise", null), h(this, "_fixNoPacketsAppliedVideo", !1), this._mediaSource = e, this._debug = t, this._logger = n;
7895
7929
  }
@@ -7927,7 +7961,7 @@ var ao = class {
7927
7961
  this._debug.warn("[AudioFix] Failed to fix RV (no packets): video restart", e);
7928
7962
  }));
7929
7963
  }
7930
- }, oo = class {
7964
+ }, co = class {
7931
7965
  constructor(e, t = !1, n = z, r = null) {
7932
7966
  h(this, "_audioElement", null), h(this, "_audioTracks", /* @__PURE__ */ new Map()), h(this, "_allowMultipleTracks", void 0), h(this, "_volume", 1), h(this, "_features", { setSinkId: !!Audio.prototype.setSinkId }), h(this, "_statFirstMediaReceived", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), this._statFirstMediaReceived = e, this._allowMultipleTracks = t, this._debug = n, this._logger = r;
7933
7967
  }
@@ -8015,13 +8049,13 @@ var ao = class {
8015
8049
  };
8016
8050
  //#endregion
8017
8051
  //#region src/classes/conversation/ConversationResponseValidator.ts
8018
- function so(e, t) {
8019
- e || lo(t, "response-empty"), e.id || lo(t, "id-empty"), e.endpoint || lo(t, "endpoint-empty"), !co(e.stun_server) && !co(e.turn_server) && lo(t, "ice-servers-empty");
8052
+ function lo(e, t) {
8053
+ e || fo(t, "response-empty"), e.id || fo(t, "id-empty"), e.endpoint || fo(t, "endpoint-empty"), !uo(e.stun_server) && !uo(e.turn_server) && fo(t, "ice-servers-empty");
8020
8054
  }
8021
- function co(e) {
8055
+ function uo(e) {
8022
8056
  return Array.isArray(e?.urls) && e.urls.length > 0;
8023
8057
  }
8024
- function lo(e, t) {
8058
+ function fo(e, t) {
8025
8059
  let n = e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), r = e === "fastStart" || e === "fastJoin";
8026
8060
  throw new k(r ? e === "fastStart" ? O.FAST_START_ERROR : O.FAST_JOIN_ERROR : O.UNKNOWN_ERROR, {
8027
8061
  message: `Invalid ${e} response: ${t}`,
@@ -8040,7 +8074,7 @@ function lo(e, t) {
8040
8074
  }
8041
8075
  //#endregion
8042
8076
  //#region src/classes/DebugInfo.ts
8043
- var uo = 90, fo = 3, po = class extends b {
8077
+ var po = 90, mo = 3, ho = class extends b {
8044
8078
  constructor(e = z) {
8045
8079
  super(), h(this, "_lastMemoryStat", {
8046
8080
  percent: 0,
@@ -8056,9 +8090,9 @@ var uo = 90, fo = 3, po = class extends b {
8056
8090
  let e = window?.performance?.memory;
8057
8091
  if (!e || !e.usedJSHeapSize || !e.jsHeapSizeLimit) return;
8058
8092
  let t = Number((100 * e.usedJSHeapSize / e.jsHeapSizeLimit).toFixed(2)), n = Number((e.usedJSHeapSize / 1024 / 1024).toFixed(1));
8059
- t > uo ? this._debug.warn(`High memory usage: ${t}% (${n} MiB)`) : (!this._lastMemoryStat.percent || Math.abs(t - this._lastMemoryStat.percent) >= fo) && (this._debug.debug(`Memory usage: ${t}% (${n} MiB)`), this._lastMemoryStat.percent = t, this._lastMemoryStat.bytes = e.usedJSHeapSize);
8093
+ t > po ? this._debug.warn(`High memory usage: ${t}% (${n} MiB)`) : (!this._lastMemoryStat.percent || Math.abs(t - this._lastMemoryStat.percent) >= mo) && (this._debug.debug(`Memory usage: ${t}% (${n} MiB)`), this._lastMemoryStat.percent = t, this._lastMemoryStat.bytes = e.usedJSHeapSize);
8060
8094
  }
8061
- }, mo = class {
8095
+ }, go = class {
8062
8096
  constructor({ api: e, debug: t, getParticipants: n, isMe: r, updateDisplayLayout: i }) {
8063
8097
  h(this, "_api", void 0), h(this, "_debug", void 0), h(this, "_getParticipants", void 0), h(this, "_isMe", void 0), h(this, "_updateDisplayLayout", void 0), h(this, "_requestedLayouts", {}), h(this, "_uncertainLayouts", {}), h(this, "_pendingRequests", null), h(this, "_pendingPromises", []), h(this, "_lastRequests", null), h(this, "_timer", null), h(this, "_inFlight", !1), h(this, "_lastFlushAt", null), h(this, "_generation", 0), h(this, "_forceNextFlush", !1), this._api = e, this._debug = t, this._getParticipants = n, this._isMe = r, this._updateDisplayLayout = i;
8064
8098
  }
@@ -8168,7 +8202,7 @@ var uo = 90, fo = 3, po = class extends b {
8168
8202
  let n = e, r = t;
8169
8203
  return n.width !== r.width || n.height !== r.height || n.fit !== r.fit || n.priority !== r.priority;
8170
8204
  }
8171
- }, ho = 44100, go = class {
8205
+ }, _o = 44100, vo = class {
8172
8206
  constructor(e, t) {
8173
8207
  h(this, "_analyser", null), h(this, "_gainNode", null), h(this, "_fftBins", null), h(this, "_mediaStreamSource", null), h(this, "_lastSmoothedLevel", 0), h(this, "_trackId", void 0), h(this, "_track", void 0), h(this, "_stream", void 0), this._trackId = e, this._track = t, this._stream = new MediaStream([t]);
8174
8208
  try {
@@ -8185,7 +8219,7 @@ var uo = 90, fo = 3, po = class extends b {
8185
8219
  _getBins() {
8186
8220
  if (!this._fftBins || !this._analyser) return new Uint8Array();
8187
8221
  this._analyser.getByteFrequencyData(this._fftBins);
8188
- let e = ho / this._fftBins.length, t = Math.ceil(N.voiceParams.minFreq / e), n = Math.floor(N.voiceParams.maxFreq / e);
8222
+ let e = _o / this._fftBins.length, t = Math.ceil(N.voiceParams.minFreq / e), n = Math.floor(N.voiceParams.maxFreq / e);
8189
8223
  return this._fftBins.subarray(t, n);
8190
8224
  }
8191
8225
  getLevel() {
@@ -8198,7 +8232,7 @@ var uo = 90, fo = 3, po = class extends b {
8198
8232
  destroy() {
8199
8233
  this._mediaStreamSource && (this._mediaStreamSource.disconnect(), this._mediaStreamSource = null), this._gainNode && (this._gainNode.disconnect(), this._gainNode = null), this._analyser && (this._analyser.disconnect(), this._analyser = null, this._fftBins = null, this._lastSmoothedLevel = 0), this._stream.removeTrack(this._track);
8200
8234
  }
8201
- }, _o = class extends b {
8235
+ }, yo = class extends b {
8202
8236
  constructor(e) {
8203
8237
  super(), h(this, "_detector", null), h(this, "_interval", null);
8204
8238
  let t = () => {
@@ -8214,7 +8248,7 @@ var uo = 90, fo = 3, po = class extends b {
8214
8248
  }), this.subscribe(e, Kt.SOURCE_READY, n), n();
8215
8249
  }
8216
8250
  init(e) {
8217
- this._stopDetector(), this._detector = new go("local", e.clone());
8251
+ this._stopDetector(), this._detector = new vo("local", e.clone());
8218
8252
  }
8219
8253
  _stopDetector() {
8220
8254
  this._detector && (this._detector.track.stop(), this._detector.destroy(), this._detector = null);
@@ -8222,7 +8256,7 @@ var uo = 90, fo = 3, po = class extends b {
8222
8256
  destroy() {
8223
8257
  this.unsubscribe(), this._interval && (window.clearTimeout(this._interval), this._interval = null), this._stopDetector();
8224
8258
  }
8225
- }, vo = class {
8259
+ }, bo = class {
8226
8260
  constructor(e, t = z) {
8227
8261
  h(this, "processor", void 0), h(this, "queue", []), h(this, "isProcessing", !1), h(this, "_debug", void 0), this.processor = e, this._debug = t;
8228
8262
  }
@@ -8242,9 +8276,9 @@ var uo = 90, fo = 3, po = class extends b {
8242
8276
  this.isProcessing = !1;
8243
8277
  }
8244
8278
  }
8245
- }, yo = /* @__PURE__ */ function(e) {
8279
+ }, xo = /* @__PURE__ */ function(e) {
8246
8280
  return e.VOLUMES_DETECTED = "VOLUMES_DETECTED", e;
8247
- }({}), bo = class extends b {
8281
+ }({}), So = class extends b {
8248
8282
  constructor(e) {
8249
8283
  super(), h(this, "_detectors", /* @__PURE__ */ new Map()), h(this, "_interval", null), h(this, "_activeParticipants", void 0), h(this, "_removedParticipants", void 0), h(this, "_topology", void 0), this._topology = e.getTopology(), this.subscribe(e, X.REMOTE_TRACK_ADDED, this._onRemoteTrackAdded.bind(this)), this.subscribe(e, X.REMOTE_TRACK_REMOVED, this._onRemoteTrackRemoved.bind(this)), this.subscribe(e, X.SIGNALLED_ACTIVE_PARTICIPANTS, this._onSignalledActiveParticipants.bind(this)), this.subscribe(e, X.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this));
8250
8284
  }
@@ -8252,7 +8286,7 @@ var uo = 90, fo = 3, po = class extends b {
8252
8286
  this._interval && (window.clearTimeout(this._interval), this._interval = null), this.unsubscribe(), this._destroyDetectors();
8253
8287
  }
8254
8288
  _onRemoteTrackAdded(e, t, n) {
8255
- if (n.kind === A.audio && (this._detectors.get(e)?.destroy(), this._detectors.set(e, new go(e, n)), !this._interval)) {
8289
+ if (n.kind === A.audio && (this._detectors.get(e)?.destroy(), this._detectors.set(e, new vo(e, n)), !this._interval)) {
8256
8290
  let e = () => {
8257
8291
  this._collectVolumes(), this._interval = window.setTimeout(e, N.voiceParams.interval);
8258
8292
  };
@@ -8310,11 +8344,11 @@ var uo = 90, fo = 3, po = class extends b {
8310
8344
  e.destroy();
8311
8345
  }), this._detectors.clear();
8312
8346
  }
8313
- }, xo = /* @__PURE__ */ function(e) {
8347
+ }, Co = /* @__PURE__ */ function(e) {
8314
8348
  return e.SPEAKER_CHANGED = "SPEAKER_CHANGED", e;
8315
- }({}), So = class extends b {
8349
+ }({}), wo = class extends b {
8316
8350
  constructor(e, t, n) {
8317
- super(), h(this, "_speakerId", null), h(this, "_serverSideSpeakerDetection", !1), this._serverSideSpeakerDetection = n === Y.SERVER, this.subscribe(e, yo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this.subscribe(t, X.SIGNALLED_SPEAKER_CHANGED, this._onServerSpeakerChanged.bind(this)), this.subscribe(t, X.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this));
8351
+ super(), h(this, "_speakerId", null), h(this, "_serverSideSpeakerDetection", !1), this._serverSideSpeakerDetection = n === Y.SERVER, this.subscribe(e, xo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this.subscribe(t, X.SIGNALLED_SPEAKER_CHANGED, this._onServerSpeakerChanged.bind(this)), this.subscribe(t, X.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this));
8318
8352
  }
8319
8353
  destroy() {
8320
8354
  this.unsubscribe();
@@ -8336,9 +8370,9 @@ var uo = 90, fo = 3, po = class extends b {
8336
8370
  _onTopologyChanged(e) {
8337
8371
  this._serverSideSpeakerDetection = e === Y.SERVER;
8338
8372
  }
8339
- }, Co = 15e3, wo = 15e3, To = class extends b {
8373
+ }, To = 15e3, Eo = 15e3, Do = class extends b {
8340
8374
  constructor(e, t, n, r = z, i = null) {
8341
- super(), h(this, "_transport", void 0), h(this, "_volumes", {}), h(this, "_participants", {}), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_connectionTimeout", 0), h(this, "_connectionTimeoutSuppressed", !1), h(this, "_volumeTimeout", 0), this._transport = e, this._participants = n, this._debug = r, this._logger = i, this.subscribe(e, X.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(t, yo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this));
8375
+ super(), h(this, "_transport", void 0), h(this, "_volumes", {}), h(this, "_participants", {}), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_connectionTimeout", 0), h(this, "_connectionTimeoutSuppressed", !1), h(this, "_volumeTimeout", 0), this._transport = e, this._participants = n, this._debug = r, this._logger = i, this.subscribe(e, X.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(t, xo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this));
8342
8376
  }
8343
8377
  destroy() {
8344
8378
  this.unsubscribe(), this._connectionTimeout && window.clearTimeout(this._connectionTimeout), this._volumeTimeout && window.clearTimeout(this._volumeTimeout);
@@ -8350,10 +8384,10 @@ var uo = 90, fo = 3, po = class extends b {
8350
8384
  this._connectionTimeout || !this._connectionTimeoutSuppressed || this._reportConnectionTimeout();
8351
8385
  }
8352
8386
  _getConnectionTimeout() {
8353
- return this._transport.getTopology() === Y.DIRECT ? Co : N.specListenerParams.connectionTimeout;
8387
+ return this._transport.getTopology() === Y.DIRECT ? To : N.specListenerParams.connectionTimeout;
8354
8388
  }
8355
8389
  _getVolumeTimeout() {
8356
- return this._transport.getTopology() === Y.DIRECT ? wo : N.specListenerParams.volumeTimeout;
8390
+ return this._transport.getTopology() === Y.DIRECT ? Eo : N.specListenerParams.volumeTimeout;
8357
8391
  }
8358
8392
  _onTransportStateChanged(e, t) {
8359
8393
  t === J.OPENED && (this._connectionTimeout || (this._connectionTimeoutSuppressed = !1, this._connectionTimeout = window.setTimeout(this._onConnectionTimeout.bind(this), this._getConnectionTimeout()))), t === J.CONNECTED && (this._volumeTimeout || (this._volumeTimeout = window.setTimeout(this._onVolumeTimeout.bind(this), this._getVolumeTimeout())), this._volumeTimeout && (window.clearTimeout(this._volumeTimeout), this._volumeTimeout = window.setTimeout(this._onVolumeTimeout.bind(this), this._getVolumeTimeout()))), t === J.FAILED && this._connectionTimeout && (this._debug.warn("Transport failed, send callSpecError"), this._logger?.log(C.CALL_SPEC_ERROR, `${this._transport.getTopology()}_CONNECTION_TIMEOUT`));
@@ -8386,7 +8420,7 @@ var uo = 90, fo = 3, po = class extends b {
8386
8420
  r && r.platform && (n = r.platform), e.indexOf(n) < 0 && (e.push(n), this._logger?.log(C.CALL_SPEC_ERROR, `${this._transport.getTopology()}_VOLUME_TIMEOUT_${n}`));
8387
8421
  }), e.length && this._debug.warn("There is silent participant, send callSpecError"), this._volumeTimeout = 0;
8388
8422
  }
8389
- }, Eo = class extends f {
8423
+ }, Oo = class extends f {
8390
8424
  constructor(e, t, n, r = () => void 0) {
8391
8425
  super(), h(this, "_externalLogger", void 0), h(this, "_api", void 0), h(this, "_conversationIdProvider", void 0), h(this, "_topologyProvider", void 0), h(this, "_batchInterval", 3e3), h(this, "_batchedClientStats", []), h(this, "_batchTimeout", null), h(this, "_serverTimeDelta", 0), h(this, "_waitingForServerTime", !0), h(this, "_deferredClientStats", []), this._api = e, this._externalLogger = t, this._conversationIdProvider = n, this._topologyProvider = r, this._calculateServerTimeDelta();
8392
8426
  }
@@ -8466,7 +8500,7 @@ var uo = 90, fo = 3, po = class extends b {
8466
8500
  _now() {
8467
8501
  return Date.now() - this._serverTimeDelta;
8468
8502
  }
8469
- }, Do = "invalid-error-metadata", Oo = 64, ko = new Set(Object.values(O)), Ao = new Set(Object.values(x)), jo = {
8503
+ }, ko = "invalid-error-metadata", Ao = 64, jo = new Set(Object.values(O)), Mo = new Set(Object.values(x)), No = {
8470
8504
  [O.CANCELED]: {
8471
8505
  type: "semantic",
8472
8506
  reason: "canceled"
@@ -8587,7 +8621,7 @@ var uo = 90, fo = 3, po = class extends b {
8587
8621
  type: "semantic",
8588
8622
  reason: "obsolete_client"
8589
8623
  }
8590
- }, Mo = {
8624
+ }, Po = {
8591
8625
  [x.MIC_CAMERA_PERMISSION]: {
8592
8626
  type: "direct-error",
8593
8627
  error: {
@@ -8676,14 +8710,14 @@ var uo = 90, fo = 3, po = class extends b {
8676
8710
  }
8677
8711
  }
8678
8712
  };
8679
- function No(e) {
8680
- if (typeof e != "string" && typeof e != "number" || typeof e == "number" && !Number.isFinite(e)) return Do;
8713
+ function Fo(e) {
8714
+ if (typeof e != "string" && typeof e != "number" || typeof e == "number" && !Number.isFinite(e)) return ko;
8681
8715
  let t = String(e).trim();
8682
- if (!t) return Do;
8716
+ if (!t) return ko;
8683
8717
  let n = t.toLowerCase().replace(/[\s_:]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
8684
- return !n || !/^[a-z0-9.-]+$/.test(n) ? Do : n.length > Oo ? `${n.slice(0, Oo - 3)}...` : n;
8718
+ return !n || !/^[a-z0-9.-]+$/.test(n) ? ko : n.length > Ao ? `${n.slice(0, Ao - 3)}...` : n;
8685
8719
  }
8686
- function Po(e) {
8720
+ function Io(e) {
8687
8721
  if (!e || typeof e != "object") return !1;
8688
8722
  let t = e;
8689
8723
  switch (t.scope) {
@@ -8695,50 +8729,50 @@ function Po(e) {
8695
8729
  default: return !1;
8696
8730
  }
8697
8731
  }
8698
- function Fo(e) {
8699
- let t = No(e.description);
8732
+ function Lo(e) {
8733
+ let t = Fo(e.description);
8700
8734
  if (e.scope === "unknown") return `unknown:${t}`;
8701
- let n = No(e.code);
8735
+ let n = Fo(e.code);
8702
8736
  return e.scope === "internal" ? `internal:${n}:${t}` : `${e.scope}:${e.source}:${n}:${t}`;
8703
8737
  }
8704
- function Io(e, t) {
8738
+ function Ro(e, t) {
8705
8739
  return t === null ? e.type === "direct-error" ? {
8706
8740
  reason: "error",
8707
- string_value: Fo(e.error)
8708
- } : { reason: "failed" } : Po(t) ? {
8741
+ string_value: Lo(e.error)
8742
+ } : { reason: "failed" } : Io(t) ? {
8709
8743
  reason: "error",
8710
- string_value: Fo(t)
8744
+ string_value: Lo(t)
8711
8745
  } : { reason: "failed" };
8712
8746
  }
8713
- function Lo(e) {
8747
+ function zo(e) {
8714
8748
  if (e.hangup) {
8715
- let t = jo[e.hangup];
8749
+ let t = No[e.hangup];
8716
8750
  return t ? t.type === "semantic" ? e.hangup === O.OBSOLETE_CLIENT && e.custom_error?.vchat_detailed_api_error.code ? {
8717
8751
  reason: t.reason,
8718
8752
  string_value: e.custom_error.vchat_detailed_api_error.code
8719
- } : { reason: t.reason } : Io(t, e.callError) : { reason: "failed" };
8753
+ } : { reason: t.reason } : Ro(t, e.callError) : { reason: "failed" };
8720
8754
  }
8721
8755
  if (e.error) {
8722
- let t = Mo[e.error];
8723
- return t ? Io(t, e.callError) : { reason: "failed" };
8756
+ let t = Po[e.error];
8757
+ return t ? Ro(t, e.callError) : { reason: "failed" };
8724
8758
  }
8725
8759
  return { reason: "failed" };
8726
8760
  }
8727
- function Ro(e) {
8728
- return e instanceof k ? Lo(e) : typeof e == "string" && (ko.has(e) || Ao.has(e)) ? Lo(new k(e)) : { reason: "failed" };
8761
+ function Bo(e) {
8762
+ return e instanceof k ? zo(e) : typeof e == "string" && (jo.has(e) || Mo.has(e)) ? zo(new k(e)) : { reason: "failed" };
8729
8763
  }
8730
8764
  //#endregion
8731
8765
  //#region src/classes/stat/CallLifecycleStats.ts
8732
- var zo = {
8766
+ var Vo = {
8733
8767
  wallNow: () => Date.now(),
8734
8768
  monotonicNow: () => performance.now()
8735
8769
  };
8736
- function Bo(e) {
8770
+ function Ho(e) {
8737
8771
  return e === "anonym_join" ? "join" : e;
8738
8772
  }
8739
- var Vo = class {
8740
- constructor(e, t = zo) {
8741
- h(this, "_logger", void 0), h(this, "_clock", void 0), h(this, "_conversationId", null), h(this, "_callStartLabel", null), h(this, "_lifecycleStartedAtMonotonic", 0), h(this, "_warmupStartedAtMonotonic", null), h(this, "_pendingEvents", []), h(this, "_warmupCompleted", !1), h(this, "_callStarted", !1), h(this, "_accepted", !1), h(this, "_firstMediaSent", !1), h(this, "_finished", !1), h(this, "_destroyed", !1), this._logger = e, this._clock = t;
8773
+ var Uo = class {
8774
+ constructor(e, t = Vo) {
8775
+ h(this, "_logger", void 0), h(this, "_clock", void 0), h(this, "_conversationId", null), h(this, "_callStartLabel", null), h(this, "_lifecycleStartedAtMonotonic", 0), h(this, "_pendingEvents", []), h(this, "_callStarted", !1), h(this, "_accepted", !1), h(this, "_firstMediaSent", !1), h(this, "_finished", !1), h(this, "_destroyed", !1), this._logger = e, this._clock = t;
8742
8776
  }
8743
8777
  get firstMediaSentReported() {
8744
8778
  return this._firstMediaSent;
@@ -8749,7 +8783,7 @@ var Vo = class {
8749
8783
  markInitializationStarted({ source: e, conversationId: t }) {
8750
8784
  if (this._destroyed || this._callStartLabel !== null) return;
8751
8785
  let n = this._clock.wallNow();
8752
- this._callStartLabel = Bo(e), this._lifecycleStartedAtMonotonic = this._clock.monotonicNow(), t && (this._conversationId = t), this._record({
8786
+ this._callStartLabel = Ho(e), this._lifecycleStartedAtMonotonic = this._clock.monotonicNow(), t && (this._conversationId = t), this._record({
8753
8787
  name: U.CALL_INIT,
8754
8788
  source: e
8755
8789
  }, n);
@@ -8757,23 +8791,11 @@ var Vo = class {
8757
8791
  bindConversationId(e) {
8758
8792
  this._destroyed || this._conversationId || !e || (this._conversationId = e, this._flushPendingEvents());
8759
8793
  }
8760
- markWarmupStarted() {
8761
- !this._canRecord() || this._warmupStartedAtMonotonic !== null || (this._warmupStartedAtMonotonic = this._clock.monotonicNow());
8762
- }
8763
- markWarmupCompleted() {
8764
- if (!this._canRecord() || this._warmupCompleted || this._warmupStartedAtMonotonic === null) return;
8765
- this._warmupCompleted = !0;
8766
- let e = this._durationSince(this._warmupStartedAtMonotonic);
8767
- this._record({
8768
- name: U.CALL_WARMUP,
8769
- value: e
8770
- });
8771
- }
8772
8794
  markCallStarted() {
8773
8795
  !this._canRecord() || this._callStarted || !this._callStartLabel || (this._callStarted = !0, this._record({
8774
8796
  name: U.CALL_START,
8775
8797
  value: this._durationSince(this._lifecycleStartedAtMonotonic),
8776
- string_value: JSON.stringify({ labels: [this._callStartLabel, "warmup_start"] })
8798
+ string_value: JSON.stringify({ labels: [this._callStartLabel] })
8777
8799
  }));
8778
8800
  }
8779
8801
  markOutgoingAccepted() {
@@ -8789,7 +8811,7 @@ var Vo = class {
8789
8811
  !this._canRecord() || this._firstMediaSent || (this._firstMediaSent = !0, this._record({ name: U.FIRST_MEDIA_SENT }));
8790
8812
  }
8791
8813
  markFinished(e) {
8792
- this._finish(Ro(e));
8814
+ this._finish(Bo(e));
8793
8815
  }
8794
8816
  markTerminated() {
8795
8817
  this._finish({ reason: "terminated" });
@@ -8840,7 +8862,7 @@ var Vo = class {
8840
8862
  ...n && { immediately: !0 }
8841
8863
  });
8842
8864
  }
8843
- }, Ho = class {
8865
+ }, Wo = class {
8844
8866
  constructor(e, t) {
8845
8867
  h(this, "_logger", void 0), h(this, "_codecUsages", /* @__PURE__ */ new Map()), h(this, "getCurrentTransportTopology", void 0), this._logger = e, this.getCurrentTransportTopology = t;
8846
8868
  }
@@ -8903,7 +8925,7 @@ var Vo = class {
8903
8925
  this.report(e);
8904
8926
  }), this._codecUsages.clear();
8905
8927
  }
8906
- }, Uo = class {
8928
+ }, Go = class {
8907
8929
  constructor(e) {
8908
8930
  h(this, "_logger", void 0), h(this, "_eventualLogs", /* @__PURE__ */ new Set()), this._logger = e;
8909
8931
  }
@@ -8928,7 +8950,7 @@ var Vo = class {
8928
8950
  destroy() {
8929
8951
  this._eventualLogs.clear();
8930
8952
  }
8931
- }, Wo = class {
8953
+ }, Ko = class {
8932
8954
  constructor(e) {
8933
8955
  if (h(this, "q", void 0), h(this, "inits", []), h(this, "n", [
8934
8956
  1,
@@ -8987,7 +9009,7 @@ var Vo = class {
8987
9009
  5
8988
9010
  ];
8989
9011
  }
8990
- }, Go = class {
9012
+ }, qo = class {
8991
9013
  constructor() {
8992
9014
  h(this, "n", 0), h(this, "mean", 0);
8993
9015
  }
@@ -8999,9 +9021,9 @@ var Vo = class {
8999
9021
  get avg() {
9000
9022
  return this.n ? this.mean : NaN;
9001
9023
  }
9002
- }, Ko = class {
9024
+ }, Jo = class {
9003
9025
  constructor() {
9004
- h(this, "count", 0), h(this, "minVal", Infinity), h(this, "maxVal", -Infinity), h(this, "mean", new Go()), h(this, "p50", new Wo(.5)), h(this, "p95", new Wo(.95));
9026
+ h(this, "count", 0), h(this, "minVal", Infinity), h(this, "maxVal", -Infinity), h(this, "mean", new qo()), h(this, "p50", new Ko(.5)), h(this, "p95", new Ko(.95));
9005
9027
  }
9006
9028
  add(e) {
9007
9029
  e < this.minVal && (this.minVal = e), e > this.maxVal && (this.maxVal = e), this.mean.add(e), this.p50.add(e), this.p95.add(e), this.count++;
@@ -9019,11 +9041,11 @@ var Vo = class {
9019
9041
  get hasData() {
9020
9042
  return this.count > 0;
9021
9043
  }
9022
- }, qo = class {
9044
+ }, Yo = class {
9023
9045
  constructor(e) {
9024
9046
  h(this, "_logger", void 0), h(this, "trackerByTransport", {
9025
- ws: new Ko(),
9026
- wt: new Ko()
9047
+ ws: new Jo(),
9048
+ wt: new Jo()
9027
9049
  }), h(this, "lastSeen", {}), this._logger = e;
9028
9050
  }
9029
9051
  mark(e) {
@@ -9052,17 +9074,17 @@ var Vo = class {
9052
9074
  }
9053
9075
  destroy() {
9054
9076
  this.trackerByTransport = {
9055
- ws: new Ko(),
9056
- wt: new Ko()
9077
+ ws: new Jo(),
9078
+ wt: new Jo()
9057
9079
  }, this.lastSeen = {};
9058
9080
  }
9059
- }, Jo = class {
9081
+ }, Xo = class {
9060
9082
  constructor(e) {
9061
9083
  h(this, "_logger", void 0), h(this, "trackerByCommand", /* @__PURE__ */ new Map()), this._logger = e;
9062
9084
  }
9063
9085
  mark(e, t, n) {
9064
9086
  let r = `${e}|${n}`, i;
9065
- this.trackerByCommand.has(r) ? i = this.trackerByCommand.get(r) : (i = new Ko(), this.trackerByCommand.set(r, i)), i.add(t);
9087
+ this.trackerByCommand.has(r) ? i = this.trackerByCommand.get(r) : (i = new Jo(), this.trackerByCommand.set(r, i)), i.add(t);
9066
9088
  }
9067
9089
  logMetrics() {
9068
9090
  for (let [e, t] of this.trackerByCommand.entries()) {
@@ -9084,9 +9106,9 @@ var Vo = class {
9084
9106
  destroy() {
9085
9107
  this.trackerByCommand.clear();
9086
9108
  }
9087
- }, Yo = class {
9109
+ }, Zo = class {
9088
9110
  constructor(e, t, n, r) {
9089
- h(this, "logger", void 0), h(this, "lifecycle", void 0), h(this, "statAggregator", void 0), h(this, "codecStatsAggregator", void 0), h(this, "pings", void 0), h(this, "signalingCommands", void 0), this.logger = new Eo(e, t, n, r), this.lifecycle = new Vo(this.logger), this.statAggregator = new Uo(this.logger), this.codecStatsAggregator = new Ho(this.logger, r), this.pings = new qo(this.logger), this.signalingCommands = new Jo(this.logger);
9111
+ h(this, "logger", void 0), h(this, "lifecycle", void 0), h(this, "statAggregator", void 0), h(this, "codecStatsAggregator", void 0), h(this, "pings", void 0), h(this, "signalingCommands", void 0), this.logger = new Oo(e, t, n, r), this.lifecycle = new Uo(this.logger), this.statAggregator = new Go(this.logger), this.codecStatsAggregator = new Wo(this.logger, r), this.pings = new Yo(this.logger), this.signalingCommands = new Xo(this.logger);
9090
9112
  }
9091
9113
  logHangup(e) {
9092
9114
  this.lifecycle.markFinished(e);
@@ -9097,7 +9119,7 @@ var Vo = class {
9097
9119
  destroy() {
9098
9120
  this.lifecycle.markTerminated(), this.lifecycle.destroy(), this.statAggregator.destroy(), this.codecStatsAggregator.destroy(), this.pings.destroy(), this.signalingCommands.destroy(), this.logger.destroy();
9099
9121
  }
9100
- }, Xo = class {
9122
+ }, Qo = class {
9101
9123
  constructor(e) {
9102
9124
  h(this, "_statAggregator", void 0), h(this, "_isCallMarked", !1), h(this, "_isFinished", !1), h(this, "_callType", null), this._statAggregator = e;
9103
9125
  }
@@ -9122,8 +9144,8 @@ var Vo = class {
9122
9144
  call_type: this._callType
9123
9145
  }));
9124
9146
  }
9125
- }, Zo = 1e3, Qo = 1e4;
9126
- function $o(e, t, n, r) {
9147
+ }, $o = 1e3, es = 1e4;
9148
+ function ts(e, t, n, r) {
9127
9149
  return new k(e, {
9128
9150
  callError: {
9129
9151
  scope: "external",
@@ -9134,7 +9156,7 @@ function $o(e, t, n, r) {
9134
9156
  message: r
9135
9157
  });
9136
9158
  }
9137
- var es = 15, $ = class e extends b {
9159
+ var ns = 15, $ = class e extends b {
9138
9160
  constructor(e, t) {
9139
9161
  super(), h(this, "_api", void 0), h(this, "_signaling", void 0), h(this, "_signalingActor", void 0), h(this, "_displayLayoutRequester", void 0), h(this, "_mediaSource", null), h(this, "_conversation", null), h(this, "_myLastRequestedLayouts", {}), h(this, "_state", "IDLE"), h(this, "_previousState", null), h(this, "_waitingHallHoldPending", !1), h(this, "_participantState", Z.CALLED), h(this, "_participants", {}), h(this, "_directTransportIsMaster", void 0), h(this, "_transport", null), h(this, "_debugInfo", null), h(this, "_debug", z.createSessionLogger()), h(this, "_volumesDetector", null), h(this, "_speakerDetector", null), h(this, "_localVolumeDetector", null), h(this, "_specListener", null), h(this, "_activeSpeakerId", null), h(this, "_lastSignalledActiveSpeakerId", null), h(this, "_isRealTimeAsrRequested", !1), h(this, "_serverSettings", Cr()), h(this, "_serverTimeOffset", 0), h(this, "_delayedHangup", !1), h(this, "_hangupEmitted", !1), h(this, "_hangupPromise", null), h(this, "_abortController", null), h(this, "_registeredPeerReceived", !1), h(this, "_calleeUnavailableTimer", null), h(this, "_reservedId", null), h(this, "_onUnload", void 0), h(this, "_audioOutput", void 0), h(this, "_stats", void 0), h(this, "_lastStalled", {}), h(this, "_audioMixStalled", !1), h(this, "_audioFix", null), h(this, "_streamByStreamId", /* @__PURE__ */ new Map()), h(this, "_streamIdByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_streamWaitTimerByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_sequenceNumberByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_cooldownTimestampByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_cooldownQueueCleanupTimer", null), h(this, "_statFirstMediaReceived", void 0), h(this, "_changeMediaSettings", M.debounce(async (e) => {
9140
9162
  if (this._signaling.ready) try {
@@ -9146,7 +9168,7 @@ var es = 15, $ = class e extends b {
9146
9168
  captureAudio: !1
9147
9169
  });
9148
9170
  }
9149
- }, 100)), this._stats = new Yo(e, t, () => this._conversation?.id || null, () => this._transport?.getTopology() ?? this._conversation?.topology), this._api = e, this._signaling = new Na(this._debug, this._stats.logger, this._stats.statAggregator, this._stats.pings, this._stats.signalingCommands), this._signalingActor = new vo(this._onSignalingNotification.bind(this), this._debug), this._displayLayoutRequester = new mo({
9171
+ }, 100)), this._stats = new Zo(e, t, () => this._conversation?.id || null, () => this._transport?.getTopology() ?? this._conversation?.topology), this._api = e, this._signaling = new Na(this._debug, this._stats.logger, this._stats.statAggregator, this._stats.pings, this._stats.signalingCommands), this._signalingActor = new bo(this._onSignalingNotification.bind(this), this._debug), this._displayLayoutRequester = new go({
9150
9172
  api: this._api,
9151
9173
  debug: this._debug,
9152
9174
  getParticipants: () => this._participants,
@@ -9154,13 +9176,13 @@ var es = 15, $ = class e extends b {
9154
9176
  updateDisplayLayout: (e) => this.updateDisplayLayout(e)
9155
9177
  }), this._onUnload = () => {
9156
9178
  this._stopFirstMediaSentProbe(), this._conversation && this._api && this._api.hangupConversation(this._conversation.id, this._state === "IDLE" ? O.CANCELED : O.HUNGUP), this._stats.destroy();
9157
- }, window.addEventListener("pagehide", this._onUnload), this._statFirstMediaReceived = new Xo(this._stats.statAggregator), this._audioOutput = new oo(this._statFirstMediaReceived, N.transparentAudio, this._debug, this._stats.logger), N.videoTracksCount > 0 && (this._cooldownQueueCleanupTimer = window.setInterval(this._cleanupCooldownQueue.bind(this), Zo));
9179
+ }, window.addEventListener("pagehide", this._onUnload), this._statFirstMediaReceived = new Qo(this._stats.statAggregator), this._audioOutput = new co(this._statFirstMediaReceived, N.transparentAudio, this._debug, this._stats.logger), N.videoTracksCount > 0 && (this._cooldownQueueCleanupTimer = window.setInterval(this._cleanupCooldownQueue.bind(this), $o));
9158
9180
  }
9159
9181
  static current() {
9160
9182
  return B.getActive() ?? (N.hold ? null : B.getFirst());
9161
9183
  }
9162
9184
  static hangupAfterInit() {
9163
- let e = ts;
9185
+ let e = rs;
9164
9186
  e && e._delayedHangup === !1 && !e._conversation && (e._delayedHangup = !0, e._abortController?.abort(new k(O.CANCELED)));
9165
9187
  }
9166
9188
  static id() {
@@ -9203,11 +9225,11 @@ var es = 15, $ = class e extends b {
9203
9225
  this._stats.lifecycle.markInitializationStarted({
9204
9226
  source: "outgoing",
9205
9227
  conversationId: u
9206
- }), this._debug.setConversationId(u), ts = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
9228
+ }), this._debug.setConversationId(u), rs = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
9207
9229
  try {
9208
9230
  this._mediaSource = this._createMediaSource(), await this._mediaSource.request(n);
9209
9231
  let l = this._mediaSource.mediaSettings;
9210
- t === Fa.CHAT || e && e.length > 1 ? this._logWithMediaSettings(C.OUTGOING_MULTIPARTY_CALL, l) : this._logWithMediaSettings(C.OUTGOING_CALL, l), this._stats.lifecycle.markWarmupStarted();
9232
+ t === Fa.CHAT || e && e.length > 1 ? this._logWithMediaSettings(C.OUTGOING_MULTIPARTY_CALL, l) : this._logWithMediaSettings(C.OUTGOING_CALL, l);
9211
9233
  let d = await this._startConversation({
9212
9234
  opponentIds: e,
9213
9235
  opponentType: t,
@@ -9231,18 +9253,18 @@ var es = 15, $ = class e extends b {
9231
9253
  opponentIds: e,
9232
9254
  opponentType: t,
9233
9255
  mediaOptions: n
9234
- }), this._processConnectionSharedMovieInfo(d), this._processConversationUrlSharingInfo(d), R.onLocalStream(this._mediaSource.getStream(), this._mediaSource.mediaSettings, this.id), R.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), void 0, this.id), this._onConversationParticipantListChunk(d), this._processPinnedParticipants(d), R.onLocalStatus(P.WAITING, this.id), this._toggleJoinAvailability(), this._changeFeatureSet(), this._changeNeedRate(), B.add(this), await B.setActive(this.id), ts = null, this._conversation.concurrent && await this._acceptConcurrent(), f && !this._registeredPeerReceived && this._state !== "CLOSE" && (this._calleeUnavailableTimer = window.setTimeout(() => {
9256
+ }), this._processConnectionSharedMovieInfo(d), this._processConversationUrlSharingInfo(d), R.onLocalStream(this._mediaSource.getStream(), this._mediaSource.mediaSettings, this.id), R.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), void 0, this.id), this._onConversationParticipantListChunk(d), this._processPinnedParticipants(d), R.onLocalStatus(P.WAITING, this.id), this._toggleJoinAvailability(), this._changeFeatureSet(), this._changeNeedRate(), B.add(this), await B.setActive(this.id), rs = null, this._conversation.concurrent && await this._acceptConcurrent(), f && !this._registeredPeerReceived && this._state !== "CLOSE" && (this._calleeUnavailableTimer = window.setTimeout(() => {
9235
9257
  this._calleeUnavailableTimer = null, this._close(new k(O.CALLEE_UNAVAILABLE), { signalingReason: O.CANCELED });
9236
9258
  }, f)), this._conversation;
9237
9259
  } catch (e) {
9238
- throw ts = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to start conversation" }), e;
9260
+ throw rs = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to start conversation" }), e;
9239
9261
  }
9240
9262
  }
9241
9263
  async onJoin(e) {
9242
9264
  this._stats.lifecycle.markInitializationStarted({
9243
9265
  source: e.anonymous ? "anonym_join" : "join",
9244
9266
  conversationId: e.conversationId
9245
- }), ts = this, this._state = "PROCESSING", this._debug.setConversationId(e.conversationId ?? null), this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
9267
+ }), rs = this, this._state = "PROCESSING", this._debug.setConversationId(e.conversationId ?? null), this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
9246
9268
  try {
9247
9269
  let t = !!e.observedIds?.length;
9248
9270
  if (t && N.videoTracksCount > 0) throw this._debug.error("Observer mode: please set videoTracksCount=0"), new k(O.UNSUPPORTED, { callError: {
@@ -9252,16 +9274,16 @@ var es = 15, $ = class e extends b {
9252
9274
  } });
9253
9275
  this._mediaSource = this._createMediaSource(), await this._mediaSource.request(e.mediaOptions, !t);
9254
9276
  let n = this._mediaSource.mediaSettings;
9255
- this._logWithMediaSettings(C.JOIN_CONVERSATION, n), this._stats.lifecycle.markWarmupStarted();
9277
+ this._logWithMediaSettings(C.JOIN_CONVERSATION, n);
9256
9278
  let r = await this._joinConversation(e);
9257
9279
  if (!this._conversation) throw new k(O.UNKNOWN_ERROR, { callError: {
9258
9280
  scope: "internal",
9259
9281
  code: "conversation",
9260
9282
  description: "not-initialized-after-join"
9261
9283
  } });
9262
- return this._conversation.observer = t, R.onLocalStream(this._mediaSource.getStream(), n, this.id), this._conversation.waitForAdmin || this._conversation.waitingHall ? (this._debug.log(this._conversation.waitForAdmin ? "Wait for admin" : "In waiting hall"), B.add(this), ts = null, this._signaling.readyToSend(), R.onLocalStatus(this._conversation.waitForAdmin ? P.WAIT_FOR_ADMIN : P.WAITING_HALL, this.id), this._conversation) : this._onJoinPart2(r);
9284
+ return this._conversation.observer = t, R.onLocalStream(this._mediaSource.getStream(), n, this.id), this._conversation.waitForAdmin || this._conversation.waitingHall ? (this._debug.log(this._conversation.waitForAdmin ? "Wait for admin" : "In waiting hall"), B.add(this), rs = null, this._signaling.readyToSend(), R.onLocalStatus(this._conversation.waitForAdmin ? P.WAIT_FOR_ADMIN : P.WAITING_HALL, this.id), this._conversation) : this._onJoinPart2(r);
9263
9285
  } catch (e) {
9264
- throw ts = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
9286
+ throw rs = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
9265
9287
  }
9266
9288
  }
9267
9289
  async _onJoinPart2(e, t = !0, n = !1) {
@@ -9276,7 +9298,7 @@ var es = 15, $ = class e extends b {
9276
9298
  if (this._delayedHangup) throw new k(O.CANCELED);
9277
9299
  this._processConnectionSharedMovieInfo(e), this._processConversationUrlSharingInfo(e), this._processConnectionAsrInfo(e);
9278
9300
  let r = this._extractExternalRoomsData(e.rooms?.rooms, e.rooms?.roomId);
9279
- R.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), r, this.id), this._onConversationParticipantListChunk(e), this._processPinnedParticipants(e), R.onLocalStatus(P.WAITING, this.id), this._toggleJoinAvailability(), this._changeNeedRate(), t && (this._state = "ACTIVE"), this._changeFeatureSet(), t && (B.add(this), n ? await this._holdLocally() : await B.setActive(this.id), ts = null);
9301
+ R.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), r, this.id), this._onConversationParticipantListChunk(e), this._processPinnedParticipants(e), R.onLocalStatus(P.WAITING, this.id), this._toggleJoinAvailability(), this._changeNeedRate(), t && (this._state = "ACTIVE"), this._changeFeatureSet(), t && (B.add(this), n ? await this._holdLocally() : await B.setActive(this.id), rs = null);
9280
9302
  let i = this._extractLocalParticipantFromConnection(e);
9281
9303
  if (i) {
9282
9304
  let e = M.mapParticipantState(i);
@@ -9284,7 +9306,7 @@ var es = 15, $ = class e extends b {
9284
9306
  }
9285
9307
  return t && this._openTransport(Object.values(this._participants), !1), this._conversation;
9286
9308
  } catch (e) {
9287
- throw ts = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
9309
+ throw rs = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
9288
9310
  }
9289
9311
  }
9290
9312
  _extractExternalRooms(e) {
@@ -9300,9 +9322,8 @@ var es = 15, $ = class e extends b {
9300
9322
  B.reserve(e), this._reservedId = e, this._stats.lifecycle.markInitializationStarted({
9301
9323
  source: "incoming",
9302
9324
  conversationId: e
9303
- }), this._debug.setConversationId(e), ts = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal), a && this._api.setUserId(a);
9325
+ }), this._debug.setConversationId(e), rs = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal), a && this._api.setUserId(a);
9304
9326
  try {
9305
- this._stats.lifecycle.markWarmupStarted();
9306
9327
  let a = await this._prepareConversation(e, t, n, r, i);
9307
9328
  if (this._mediaSource = this._createMediaSource(), !this._conversation) throw new k(O.UNKNOWN_ERROR, { callError: {
9308
9329
  scope: "internal",
@@ -9310,9 +9331,9 @@ var es = 15, $ = class e extends b {
9310
9331
  description: "incoming-not-initialized"
9311
9332
  } });
9312
9333
  if (!a.conversation.participants.find((e) => e.state === Z.CALLED && e.id === this._conversation?.userId)) throw this._debug.log("Push rejected (there is an active call)"), this._stats.logger.log(C.PUSH, "rejected"), new k(O.REJECTED);
9313
- if (await this._processConnection(a), this._extractConnectionUrlSharingInfo(a), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), this._processPinnedParticipants(a), this._signaling.readyToSend(), this._stats.lifecycle.markCallStarted(), this._stats.logger.log(C.PUSH, "accepted"), B.add(this), ts = null, this._delayedHangup) throw new k(O.CANCELED);
9334
+ if (await this._processConnection(a), this._extractConnectionUrlSharingInfo(a), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), this._processPinnedParticipants(a), this._signaling.readyToSend(), this._stats.lifecycle.markCallStarted(), this._stats.logger.log(C.PUSH, "accepted"), B.add(this), rs = null, this._delayedHangup) throw new k(O.CANCELED);
9314
9335
  } catch (e) {
9315
- throw ts = null, this._cleanupRegistry(), this._close(e, {
9336
+ throw rs = null, this._cleanupRegistry(), this._close(e, {
9316
9337
  errorText: "Unable to handle inbound call push",
9317
9338
  signalingReason: e instanceof k && e.hangup === O.BUSY ? O.BUSY : void 0
9318
9339
  }), e;
@@ -9361,7 +9382,7 @@ var es = 15, $ = class e extends b {
9361
9382
  let i = atob(n), a = new Uint8Array(i.length);
9362
9383
  for (let e = 0; e < i.length; e++) a[e] = i.charCodeAt(e);
9363
9384
  try {
9364
- let e = io(a, r).reduce((e, t) => (e += String.fromCharCode(t), e), ""), { srcp: t, stne: n, tkn: i, trne: o, trnp: s, trnu: c, wse: l, wte: u } = JSON.parse(e);
9385
+ let e = oo(a, r).reduce((e, t) => (e += String.fromCharCode(t), e), ""), { srcp: t, stne: n, tkn: i, trne: o, trnp: s, trnu: c, wse: l, wte: u } = JSON.parse(e);
9365
9386
  return {
9366
9387
  token: i,
9367
9388
  endpoint: l,
@@ -9398,7 +9419,7 @@ var es = 15, $ = class e extends b {
9398
9419
  stateUpdated: !0
9399
9420
  }), this._registerParticipantLocalMuteState({ muteStates: this._conversation.muteStatesPersonal });
9400
9421
  let i = await this._signaling.getRooms(this._isCallAdmin());
9401
- if (i.rooms?.rooms) {
9422
+ if (i.rooms?.rooms?.length) {
9402
9423
  let e = this._participants;
9403
9424
  i.rooms.rooms.forEach((t) => {
9404
9425
  t.participantIds?.forEach((t) => {
@@ -9448,7 +9469,7 @@ var es = 15, $ = class e extends b {
9448
9469
  let n = await this._signaling.addParticipant(e.map(Q.toSignaling), t), r = null;
9449
9470
  n.type === "error" && (r = n.error === "call-unfeasible" ? n.status : O.UNKNOWN_ERROR);
9450
9471
  let i = n.participants;
9451
- if (!i && n.rejectedParticipants) throw Error(n.rejectedParticipants[0].reason);
9472
+ if (!i && n.rejectedParticipants?.length) throw Error(n.rejectedParticipants[0].reason);
9452
9473
  for (let e of i) await this._onAddParticipant(M.composeId(e), e, r);
9453
9474
  }
9454
9475
  async addParticipantLegacy(e, t) {
@@ -9537,28 +9558,11 @@ var es = 15, $ = class e extends b {
9537
9558
  async _getConversationParams(e) {
9538
9559
  let t = await this._api.getConversationParams(e);
9539
9560
  this._debug.debug("Api.getConversationParams", t);
9540
- let n = [], { turn_server: r, stun_server: i } = t;
9541
- if (i && n.push(i), r && r.urls) {
9542
- let e = r.urls.filter((e, t, n) => n.indexOf(e) === t);
9543
- e.push(`${e[e.length - 1]}?transport=tcp`), n.push({
9544
- urls: e,
9545
- username: r.username,
9546
- credential: r.credential
9547
- });
9548
- }
9549
- return N.iceServers = n, N.wssBase = t.endpoint, t.wt_endpoint && (N.wtsBase = t.wt_endpoint), N.wssToken = t.token, t.client_type && (N.clientType = t.client_type), t.external_user_type && (N.externalUserType = t.external_user_type), t;
9561
+ let { turn_server: n, stun_server: r } = t;
9562
+ return N.iceServers = ao(r, n), N.wssBase = t.endpoint, t.wt_endpoint && (N.wtsBase = t.wt_endpoint), N.wssToken = t.token, t.client_type && (N.clientType = t.client_type), t.external_user_type && (N.externalUserType = t.external_user_type), t;
9550
9563
  }
9551
9564
  _setConversationParams({ turn_server: e, stun_server: t, endpoint: n, wt_endpoint: r, token: i, client_type: a }) {
9552
- let o = [];
9553
- if (t && o.push(t), e && e.urls) {
9554
- let t = e.urls.filter((e, t, n) => n.indexOf(e) === t);
9555
- t.push(`${t[t.length - 1]}?transport=tcp`), o.push({
9556
- urls: t,
9557
- username: e.username,
9558
- credential: e.credential
9559
- });
9560
- }
9561
- N.iceServers = o, N.wssBase = n, N.wssToken = i, r && (N.wtsBase = r), a && (N.clientType = a);
9565
+ N.iceServers = ao(t, e), N.wssBase = n, N.wssToken = i, r && (N.wtsBase = r), a && (N.clientType = a);
9562
9566
  }
9563
9567
  _buildSignalingEndpoint({ baseEndpoint: e, userId: t, type: n, deviceIdx: r, conversationId: i, token: a, conversationParams: o }) {
9564
9568
  let s = new URL(e), c = s.searchParams;
@@ -9598,10 +9602,10 @@ var es = 15, $ = class e extends b {
9598
9602
  isVideo: f,
9599
9603
  joiningAllowed: a,
9600
9604
  requireAuthToJoin: o
9601
- }, this._abortController?.signal), !s) throw $o(O.FAST_START_ERROR, "invalid-response", "fast-start-response-empty");
9605
+ }, this._abortController?.signal), !s) throw ts(O.FAST_START_ERROR, "invalid-response", "fast-start-response-empty");
9602
9606
  if (!s.internalCallerParams) {
9603
9607
  let e = s.rejectedParticipants[0]?.status;
9604
- throw $o(O.FAST_START_ERROR, e ? "fast-start" : "invalid-response", e ?? "fast-start-internal-caller-params-empty", JSON.stringify(s));
9608
+ throw ts(O.FAST_START_ERROR, e ? "fast-start" : "invalid-response", e ?? "fast-start-internal-caller-params-empty", JSON.stringify(s));
9605
9609
  }
9606
9610
  } catch (e) {
9607
9611
  throw this._delayedHangup && this._abortController?.signal.aborted ? new k(O.CANCELED) : e instanceof k ? e : e instanceof Error ? new k(O.FAST_START_ERROR, { message: e.message }) : new k(O.FAST_START_ERROR, { message: String(e) });
@@ -9623,10 +9627,10 @@ var es = 15, $ = class e extends b {
9623
9627
  token: new URL(e.endpoint).searchParams.get("token") ?? ""
9624
9628
  }, this._debug.debug("FastStart", p), m = "fastStart";
9625
9629
  } catch {
9626
- throw $o(O.FAST_START_ERROR, "invalid-response", "fast-start-internal-caller-params-invalid");
9630
+ throw ts(O.FAST_START_ERROR, "invalid-response", "fast-start-internal-caller-params-invalid");
9627
9631
  }
9628
9632
  } else p = await this._api.startConversation(d, e, t, f, i, a, o, { onlyAdminCanShareMovie: s }, c), this._debug.debug("Api.startConversation", p), m = "startConversation";
9629
- so(p, m), this._setConversationParams(p), this._stats.lifecycle.bindConversationId(p.id), this._stats.lifecycle.markWarmupCompleted();
9633
+ lo(p, m), this._setConversationParams(p), this._stats.lifecycle.bindConversationId(p.id);
9630
9634
  let ee = await this._connectSignaling(fr.START, p);
9631
9635
  return this._setConversation(p, ee, n), this._stats.lifecycle.markCallStarted(), ee;
9632
9636
  }
@@ -9659,9 +9663,9 @@ var es = 15, $ = class e extends b {
9659
9663
  joinLink: i,
9660
9664
  isVideo: c,
9661
9665
  internalParams: t
9662
- }, this._abortController?.signal), !n) throw $o(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-response-empty");
9663
- if (!n.internalCallerParams) throw $o(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-empty", JSON.stringify(n));
9664
- if (!n.conversationId) throw $o(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-conversation-id-empty", JSON.stringify(n));
9666
+ }, this._abortController?.signal), !n) throw ts(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-response-empty");
9667
+ if (!n.internalCallerParams) throw ts(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-empty", JSON.stringify(n));
9668
+ if (!n.conversationId) throw ts(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-conversation-id-empty", JSON.stringify(n));
9665
9669
  } catch (e) {
9666
9670
  throw this._delayedHangup && this._abortController?.signal.aborted ? new k(O.CANCELED) : e instanceof k ? e : e instanceof Error ? new k(O.FAST_JOIN_ERROR, { message: e.message }) : new k(O.FAST_JOIN_ERROR, { message: String(e) });
9667
9671
  }
@@ -9679,7 +9683,7 @@ var es = 15, $ = class e extends b {
9679
9683
  token: new URL(e.endpoint).searchParams.get("token") ?? ""
9680
9684
  }, this._debug.debug("FastJoin", l), u = "fastJoin";
9681
9685
  } catch (e) {
9682
- throw e instanceof k ? e : $o(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-invalid");
9686
+ throw e instanceof k ? e : ts(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-invalid");
9683
9687
  }
9684
9688
  } else if (t) l = await this._api.joinConversation(t, c, r), u = "joinConversation";
9685
9689
  else if (i) l = await this._api.joinConversationByLink(i, c, a, o), u = "joinConversationByLink";
@@ -9688,11 +9692,11 @@ var es = 15, $ = class e extends b {
9688
9692
  code: "join",
9689
9693
  description: "target-missing"
9690
9694
  } });
9691
- if (this._debug.debug("Api.joinConversation", l), l.id && this._stats.lifecycle.bindConversationId(l.id), so(l, u), l.id) {
9695
+ if (this._debug.debug("Api.joinConversation", l), l.id && this._stats.lifecycle.bindConversationId(l.id), lo(l, u), l.id) {
9692
9696
  if (B.has(l.id)) throw new k(O.HAS_ACTIVE_CALL);
9693
9697
  B.reserve(l.id), this._reservedId = l.id;
9694
9698
  }
9695
- this._setConversationParams(l), this._stats.lifecycle.markWarmupCompleted();
9699
+ this._setConversationParams(l);
9696
9700
  let d = await this._connectSignaling(fr.JOIN, l);
9697
9701
  return this._setConversation(l, d, Pa.JOINING), this._stats.lifecycle.markCallStarted(), d;
9698
9702
  }
@@ -9755,7 +9759,6 @@ var es = 15, $ = class e extends b {
9755
9759
  conversationParams: n
9756
9760
  }), l.wt_endpoint = c);
9757
9761
  }
9758
- this._stats.lifecycle.markWarmupCompleted();
9759
9762
  let u = await this._connectSignaling(fr.ACCEPT, l);
9760
9763
  return B.callsLength >= N.maxParallelCalls || !N.hold && B.callsLength > 0 ? (this._debug.log("Push rejected (busy)"), this._stats.logger.log(C.PUSH, "busy"), Promise.reject(new k(O.BUSY))) : (this._setConversation(l, u, Pa.INCOMING, t), u);
9761
9764
  }
@@ -9861,7 +9864,7 @@ var es = 15, $ = class e extends b {
9861
9864
  }
9862
9865
  _createMediaSource() {
9863
9866
  let e = new Jt(this._debug, this._stats.logger);
9864
- return this.subscribe(e, Kt.SOURCE_CHANGED, this._onLocalMediaStreamChanged.bind(this)), this.subscribe(e, Kt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._audioFix = new ao(e, this._debug, this._stats.logger), e;
9867
+ return this.subscribe(e, Kt.SOURCE_CHANGED, this._onLocalMediaStreamChanged.bind(this)), this.subscribe(e, Kt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._audioFix = new so(e, this._debug, this._stats.logger), e;
9865
9868
  }
9866
9869
  async _connectSignaling(e, t) {
9867
9870
  this._signaling.setEndpoint(t.endpoint), this._signaling.setWebTransportEndpoint(t.wt_endpoint ? t.wt_endpoint : null), this.subscribe(this._signaling, K.NOTIFICATION, (e) => this._signalingActor.add(e)), this.subscribe(this._signaling, K.FAILED, this._onSignalingFailed.bind(this)), this.subscribe(this._signaling, K.RECONNECT, this._onSignalingReconnect.bind(this));
@@ -10055,15 +10058,15 @@ var es = 15, $ = class e extends b {
10055
10058
  }
10056
10059
  _allocateTransport() {
10057
10060
  if (!this._conversation || !this._mediaSource) return;
10058
- this._transport = new ra(this._conversation.topology, this._signaling, this._mediaSource, this._serverSettings, this._debug, this._stats.logger, this._stats.statAggregator, this._stats.codecStatsAggregator, this._getFirstMediaSentCallback()), this._debugInfo = new po(this._debug), this.subscribe(this._transport, X.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(this._transport, X.LOCAL_STATE_CHANGED, this._onTransportLocalStateChanged.bind(this)), this.subscribe(this._transport, X.REMOTE_TRACK_ADDED, this._onRemoteTrackAdded.bind(this)), this.subscribe(this._transport, X.REMOTE_TRACK_REMOVED, this._onRemoteTrackRemoved.bind(this)), this.subscribe(this._transport, X.AUDIO_MIX_STALL, this._onAudioMixStall.bind(this)), this.subscribe(this._transport, X.REMOTE_DATA_STATS, this._onRemoteDataStats.bind(this)), this.subscribe(this._transport, X.SIGNALLED_STALLED_PARTICIPANTS, this._onRemoteSignalledStall.bind(this)), this.subscribe(this._transport, X.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this)), this.subscribe(this._transport, X.NETWORK_STATUS, this._onNetworkStatus.bind(this)), this.subscribe(this._transport, X.REMOTE_STREAM_SECOND, this._onRemoteStreamSecond.bind(this)), this.subscribe(this._transport, X.PEER_CONNECTION_CLOSED, this._onPeerConnectionClosed.bind(this)), this.subscribe(this._transport, X.ASR_TRANSCRIPTION, this._onAsrTranscription.bind(this)), this.subscribe(this._transport, X.ANIMOJI_STREAM, this._onAnimojiStream.bind(this)), this.subscribe(this._transport, X.ANIMOJI_ERROR, this._onAnimojiError.bind(this));
10061
+ this._transport = new ra(this._conversation.topology, this._signaling, this._mediaSource, this._serverSettings, this._debug, this._stats.logger, this._stats.statAggregator, this._stats.codecStatsAggregator, this._getFirstMediaSentCallback()), this._debugInfo = new ho(this._debug), this.subscribe(this._transport, X.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(this._transport, X.LOCAL_STATE_CHANGED, this._onTransportLocalStateChanged.bind(this)), this.subscribe(this._transport, X.REMOTE_TRACK_ADDED, this._onRemoteTrackAdded.bind(this)), this.subscribe(this._transport, X.REMOTE_TRACK_REMOVED, this._onRemoteTrackRemoved.bind(this)), this.subscribe(this._transport, X.AUDIO_MIX_STALL, this._onAudioMixStall.bind(this)), this.subscribe(this._transport, X.REMOTE_DATA_STATS, this._onRemoteDataStats.bind(this)), this.subscribe(this._transport, X.SIGNALLED_STALLED_PARTICIPANTS, this._onRemoteSignalledStall.bind(this)), this.subscribe(this._transport, X.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this)), this.subscribe(this._transport, X.NETWORK_STATUS, this._onNetworkStatus.bind(this)), this.subscribe(this._transport, X.REMOTE_STREAM_SECOND, this._onRemoteStreamSecond.bind(this)), this.subscribe(this._transport, X.PEER_CONNECTION_CLOSED, this._onPeerConnectionClosed.bind(this)), this.subscribe(this._transport, X.ASR_TRANSCRIPTION, this._onAsrTranscription.bind(this)), this.subscribe(this._transport, X.ANIMOJI_STREAM, this._onAnimojiStream.bind(this)), this.subscribe(this._transport, X.ANIMOJI_ERROR, this._onAnimojiError.bind(this));
10059
10062
  let e = this._conversation.direction === Pa.OUTGOING && !this._conversation.concurrent, t = this._participants;
10060
10063
  for (let n of Object.values(t)) (n.state === Z.ACCEPTED || n.state === Z.CALLED) && this._allocateParticipantTransport(n.id, e);
10061
10064
  }
10062
10065
  _createSpeakerDetector() {
10063
- this._transport && this._conversation && (this._volumesDetector = new bo(this._transport), this.subscribe(this._volumesDetector, yo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this._speakerDetector = new So(this._volumesDetector, this._transport, this._conversation.topology), this.subscribe(this._speakerDetector, xo.SPEAKER_CHANGED, this._onSpeakerChanged.bind(this)), this._localVolumeDetector = new _o(this._mediaSource));
10066
+ this._transport && this._conversation && (this._volumesDetector = new So(this._transport), this.subscribe(this._volumesDetector, xo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this._speakerDetector = new wo(this._volumesDetector, this._transport, this._conversation.topology), this.subscribe(this._speakerDetector, Co.SPEAKER_CHANGED, this._onSpeakerChanged.bind(this)), this._localVolumeDetector = new yo(this._mediaSource));
10064
10067
  }
10065
10068
  _createSpecListener() {
10066
- this._transport && this._volumesDetector && (this._specListener = new To(this._transport, this._volumesDetector, this._participants, this._debug, this._stats.logger));
10069
+ this._transport && this._volumesDetector && (this._specListener = new Do(this._transport, this._volumesDetector, this._participants, this._debug, this._stats.logger));
10067
10070
  }
10068
10071
  _logDevices() {
10069
10072
  let e = E.getCameras().length, t = E.getMicrophones().length;
@@ -10162,7 +10165,7 @@ var es = 15, $ = class e extends b {
10162
10165
  _onRemoveParticipant(e) {
10163
10166
  this._debug.debug(`Remove participant [${e}]`);
10164
10167
  let t = [], n = this._participants;
10165
- for (let r = 0; r <= es; r++) {
10168
+ for (let r = 0; r <= ns; r++) {
10166
10169
  let i = n[M.compose(e, r)];
10167
10170
  i && t.push(i);
10168
10171
  }
@@ -10381,7 +10384,7 @@ var es = 15, $ = class e extends b {
10381
10384
  });
10382
10385
  }
10383
10386
  }
10384
- if (r && r.length && (this._debug.warn("Could not allocate one or more participants", r), t)) throw new ns("Could not allocate one or more participants", r);
10387
+ if (r && r.length && (this._debug.warn("Could not allocate one or more participants", r), t)) throw new is("Could not allocate one or more participants", r);
10385
10388
  }
10386
10389
  async _cleanupCooldownQueue() {
10387
10390
  let e = {}, t = this._cooldownTimestampByStreamDescription.entries();
@@ -10389,7 +10392,7 @@ var es = 15, $ = class e extends b {
10389
10392
  let n = t.next();
10390
10393
  if (n.done) break;
10391
10394
  let r = n.value;
10392
- if (r[1] + Qo > Date.now()) break;
10395
+ if (r[1] + es > Date.now()) break;
10393
10396
  let i = r[0];
10394
10397
  await this._stopStreaming(i), e[i] = { stopStream: !0 };
10395
10398
  } while (!0);
@@ -10860,7 +10863,7 @@ var es = 15, $ = class e extends b {
10860
10863
  _onLocalMediaStreamChanged(e) {
10861
10864
  if (!this._conversation || !this._mediaSource) return;
10862
10865
  let t = this._mediaSource.mediaSettings;
10863
- this._debug.debug("Local media stream changed", t), e.kind === A.audio && this._mediaSource && (this._audioFix = new ao(this._mediaSource, this._debug, this._stats.logger)), R.onLocalStreamUpdate(t, e.kind, this.id), !this._conversation?.waitingHall && !this._conversation?.observer && !this._isAudienceModeListener() && this._changeMediaSettings(t);
10866
+ this._debug.debug("Local media stream changed", t), e.kind === A.audio && this._mediaSource && (this._audioFix = new so(this._mediaSource, this._debug, this._stats.logger)), R.onLocalStreamUpdate(t, e.kind, this.id), !this._conversation?.waitingHall && !this._conversation?.observer && !this._isAudienceModeListener() && this._changeMediaSettings(t);
10864
10867
  }
10865
10868
  _onScreenSharingStatus(e) {
10866
10869
  let t = this.mediaSettings;
@@ -11878,19 +11881,19 @@ var es = 15, $ = class e extends b {
11878
11881
  _getParticipant(e) {
11879
11882
  return this._participants[e];
11880
11883
  }
11881
- }, ts = null, ns = class e extends Error {
11884
+ }, rs = null, is = class e extends Error {
11882
11885
  constructor(t, n) {
11883
11886
  super(t), h(this, "participantErrors", void 0), Object.setPrototypeOf(this, e.prototype), this.participantErrors = n;
11884
11887
  }
11885
- }, rs = null, is = null;
11886
- function as() {
11887
- rs = null, is = null;
11888
+ }, as = null, os = null;
11889
+ function ss() {
11890
+ as = null, os = null;
11888
11891
  }
11889
- function os(e) {
11892
+ function cs(e) {
11890
11893
  return e?.endsWith("/") ? e.slice(0, -1) : e;
11891
11894
  }
11892
- async function ss(e = null, t) {
11893
- let n = os(e ?? N.apiBaseUrl);
11895
+ async function ls(e = null, t) {
11896
+ let n = cs(e ?? N.apiBaseUrl);
11894
11897
  if (n) return n;
11895
11898
  if ((t ?? N.apiEnv) !== "AUTO") return N.apiEndpoint(t);
11896
11899
  try {
@@ -11905,20 +11908,20 @@ async function ss(e = null, t) {
11905
11908
  return z.warn("Failed to resolve API endpoint using DNS, default is used", e), N.apiEndpoint(t);
11906
11909
  }
11907
11910
  }
11908
- async function cs() {
11909
- return rs || is || (is = ss(), rs = await is, is = null, rs);
11911
+ async function us() {
11912
+ return as || os || (os = ls(), as = await os, os = null, as);
11910
11913
  }
11911
- async function ls(e, t = {}, n = !1) {
11914
+ async function ds(e, t = {}, n = !1) {
11912
11915
  if (!window.Blob || !window.navigator.sendBeacon) return;
11913
- await cs();
11914
- let r = ms(e, t, n), i = new window.Blob([r], { type: "application/x-www-form-urlencoded" });
11915
- window.navigator.sendBeacon(`${rs}/fb.do`, i);
11916
+ await us();
11917
+ let r = gs(e, t, n), i = new window.Blob([r], { type: "application/x-www-form-urlencoded" });
11918
+ window.navigator.sendBeacon(`${as}/fb.do`, i);
11916
11919
  }
11917
- async function us(e, t = {}, n = !1, r) {
11918
- return await cs(), ds(ms(e, t, n), r);
11920
+ async function fs(e, t = {}, n = !1, r) {
11921
+ return await us(), ps(gs(e, t, n), r);
11919
11922
  }
11920
- async function ds(e, t) {
11921
- let n = `${t ?? rs}/fb.do`, r = new AbortController(), i = new k(x.NETWORK, { callError: {
11923
+ async function ps(e, t) {
11924
+ let n = `${t ?? as}/fb.do`, r = new AbortController(), i = new k(x.NETWORK, { callError: {
11922
11925
  scope: "network",
11923
11926
  source: "api",
11924
11927
  code: "timeout",
@@ -11936,16 +11939,16 @@ async function ds(e, t) {
11936
11939
  } catch {
11937
11940
  a = { result: i };
11938
11941
  }
11939
- if (!t.ok && !fs(a)) throw new k(x.API, { callError: {
11942
+ if (!t.ok && !ms(a)) throw new k(x.API, { callError: {
11940
11943
  scope: "server",
11941
11944
  source: "api",
11942
11945
  code: `http-${t.status}`,
11943
11946
  description: "http-error"
11944
11947
  } });
11945
- if (fs(a)) throw a;
11948
+ if (ms(a)) throw a;
11946
11949
  return a;
11947
11950
  } catch (e) {
11948
- throw e instanceof k ? e : r.signal.aborted ? i : fs(e) ? e : new k(x.NETWORK, { callError: {
11951
+ throw e instanceof k ? e : r.signal.aborted ? i : ms(e) ? e : new k(x.NETWORK, { callError: {
11949
11952
  scope: "network",
11950
11953
  source: "api",
11951
11954
  code: "fetch-failed",
@@ -11955,12 +11958,12 @@ async function ds(e, t) {
11955
11958
  clearTimeout(a);
11956
11959
  }
11957
11960
  }
11958
- function fs(e) {
11961
+ function ms(e) {
11959
11962
  if (typeof e != "object" || !e) return !1;
11960
11963
  let t = e;
11961
11964
  return typeof t.error_code == "number" && typeof t.error_msg == "string";
11962
11965
  }
11963
- async function ps(e, t) {
11966
+ async function hs(e, t) {
11964
11967
  try {
11965
11968
  let n = await fetch(e, {
11966
11969
  method: "POST",
@@ -11973,7 +11976,7 @@ async function ps(e, t) {
11973
11976
  throw z.warn("Failed to send form data", e), e;
11974
11977
  }
11975
11978
  }
11976
- function ms(e, t = {}, n = !1) {
11979
+ function gs(e, t = {}, n = !1) {
11977
11980
  t.method = e, t.format = "JSON", t.application_key || (t.application_key = N.apiKey), n || (y.sessionKey ? t.session_key = y.sessionKey : y.accessToken && (t.access_token = y.accessToken));
11978
11981
  for (let [e, n] of Object.entries(t)) typeof n == "object" && (t[e] = JSON.stringify(n));
11979
11982
  let r = "";
@@ -11982,7 +11985,7 @@ function ms(e, t = {}, n = !1) {
11982
11985
  }
11983
11986
  //#endregion
11984
11987
  //#region src/abstract/BaseApi.ts
11985
- var hs = class {
11988
+ var _s = class {
11986
11989
  constructor() {
11987
11990
  h(this, "_abortSignal", void 0);
11988
11991
  }
@@ -12025,7 +12028,7 @@ var hs = class {
12025
12028
  async getInbounds() {
12026
12029
  return [];
12027
12030
  }
12028
- }, gs = class e {
12031
+ }, vs = class e {
12029
12032
  constructor() {
12030
12033
  h(this, "_okIdToExternalId", /* @__PURE__ */ new Map()), h(this, "_externalIdToOkId", /* @__PURE__ */ new Map()), h(this, "_decorativeIdToInitialId", /* @__PURE__ */ new Map()), h(this, "_initialIdToDecorativeId", /* @__PURE__ */ new Map());
12031
12034
  }
@@ -12076,27 +12079,27 @@ var hs = class {
12076
12079
  clear() {
12077
12080
  this._okIdToExternalId.clear(), this._externalIdToOkId.clear(), this._decorativeIdToInitialId.clear(), this._initialIdToDecorativeId.clear();
12078
12081
  }
12079
- }, _s = "anonymLogin:", vs = 700, ys = 3e3;
12080
- function bs(e) {
12082
+ }, ys = "anonymLogin:", bs = 700, xs = 3e3;
12083
+ function Ss(e) {
12081
12084
  let t = e.error_code;
12082
12085
  switch (t) {
12083
- case 2: return xs(O.SERVICE_UNAVAILABLE, t, "service-unavailable");
12084
- case 4: return e.error_msg.includes("participants.limit.exceeded") ? xs(O.PARTICIPANT_LIMIT_REACHED, t, "participants-limit-exceeded") : xs(x.API, t, "request-error");
12085
- case 300: return xs(O.NOT_FOUND, t, "not-found");
12086
- case 1101: return xs(O.SERVICE_DISABLED, t, "vchat-service-disabled");
12087
- case 1102: return xs(O.CALLEE_IS_OFFLINE, t, "target-user-unavailable");
12088
- case 1103: return xs(O.NOT_FRIENDS, t, "friendship-required");
12089
- case 1104: return Ss(t, "youla-api-error");
12090
- case 1106: return Ss(t, "vk-api-error");
12091
- case 1113: return xs(O.CALLER_IS_REJECTED, t, "caller-is-rejected");
12086
+ case 2: return Cs(O.SERVICE_UNAVAILABLE, t, "service-unavailable");
12087
+ case 4: return e.error_msg.includes("participants.limit.exceeded") ? Cs(O.PARTICIPANT_LIMIT_REACHED, t, "participants-limit-exceeded") : Cs(x.API, t, "request-error");
12088
+ case 300: return Cs(O.NOT_FOUND, t, "not-found");
12089
+ case 1101: return Cs(O.SERVICE_DISABLED, t, "vchat-service-disabled");
12090
+ case 1102: return Cs(O.CALLEE_IS_OFFLINE, t, "target-user-unavailable");
12091
+ case 1103: return Cs(O.NOT_FRIENDS, t, "friendship-required");
12092
+ case 1104: return ws(t, "youla-api-error");
12093
+ case 1106: return ws(t, "vk-api-error");
12094
+ case 1113: return Cs(O.CALLER_IS_REJECTED, t, "caller-is-rejected");
12092
12095
  case 1114: {
12093
12096
  let n = e.custom_error?.vchat_detailed_api_error?.code, r = n?.startsWith("obsolete_client");
12094
- return xs(r ? O.OBSOLETE_CLIENT : O.VCHAT_DETAILED_ERROR, t, n ?? "detailed-error", r ? n : void 0);
12097
+ return Cs(r ? O.OBSOLETE_CLIENT : O.VCHAT_DETAILED_ERROR, t, n ?? "detailed-error", r ? n : void 0);
12095
12098
  }
12096
- default: return xs(x.API, t, "api-error");
12099
+ default: return Cs(x.API, t, "api-error");
12097
12100
  }
12098
12101
  }
12099
- function xs(e, t, n, r) {
12102
+ function Cs(e, t, n, r) {
12100
12103
  return {
12101
12104
  type: e,
12102
12105
  callError: {
@@ -12108,7 +12111,7 @@ function xs(e, t, n, r) {
12108
12111
  message: r
12109
12112
  };
12110
12113
  }
12111
- function Ss(e, t) {
12114
+ function ws(e, t) {
12112
12115
  return {
12113
12116
  type: O.EXTERNAL_API_ERROR,
12114
12117
  callError: {
@@ -12119,19 +12122,19 @@ function Ss(e, t) {
12119
12122
  }
12120
12123
  };
12121
12124
  }
12122
- var Cs = class extends hs {
12125
+ var Ts = class extends _s {
12123
12126
  constructor(...e) {
12124
- super(...e), h(this, "_uuid", void 0), h(this, "_idCache", new gs());
12127
+ super(...e), h(this, "_uuid", void 0), h(this, "_idCache", new vs());
12125
12128
  }
12126
12129
  async _callUnsafe(e, t = {}, n = !1) {
12127
12130
  let r = async (i) => {
12128
12131
  try {
12129
- return await us(e, t, n);
12132
+ return await fs(e, t, n);
12130
12133
  } catch (t) {
12131
12134
  if (!t || typeof t != "object" || !Object.hasOwn(t, "error_msg")) {
12132
12135
  i++;
12133
12136
  let n = t && (typeof t == "object" || typeof t == "function") ? Object.getOwnPropertyNames(t).map((e) => `${e}: ${JSON.stringify(t[e])}`) : [String(t)];
12134
- if (z.debug(`${e} network error, attempt ${i}: ${n.join("\n ")}`), this._abortSignal?.aborted && (z.debug(`${e} aborted`), this._abortSignal.throwIfAborted()), i < N.apiMaxAttempt) return await M.delay(Math.min(i * vs, ys), { signal: this._abortSignal }), r(i);
12137
+ if (z.debug(`${e} network error, attempt ${i}: ${n.join("\n ")}`), this._abortSignal?.aborted && (z.debug(`${e} aborted`), this._abortSignal.throwIfAborted()), i < N.apiMaxAttempt) return await M.delay(Math.min(i * bs, xs), { signal: this._abortSignal }), r(i);
12135
12138
  }
12136
12139
  throw z.warn(e, "error", t), t;
12137
12140
  }
@@ -12154,8 +12157,8 @@ var Cs = class extends hs {
12154
12157
  message: i?.error_msg,
12155
12158
  code: i?.error_code
12156
12159
  };
12157
- if (i.custom_error && (a.custom_error = i.custom_error), ws(i)) {
12158
- let e = bs(i);
12160
+ if (i.custom_error && (a.custom_error = i.custom_error), Es(i)) {
12161
+ let e = Ss(i);
12159
12162
  throw a.callError = e.callError, a.message = e.message ?? a.message, new k(e.type, a);
12160
12163
  }
12161
12164
  throw new k(x.API, a);
@@ -12201,17 +12204,17 @@ var Cs = class extends hs {
12201
12204
  });
12202
12205
  }
12203
12206
  _getAnonymLoginCacheKey() {
12204
- return N.authToken ? `${_s}${N.authToken}` : null;
12207
+ return N.authToken ? `${ys}${N.authToken}` : null;
12205
12208
  }
12206
12209
  _getCachedAnonymLogin() {
12207
12210
  let e = this._getAnonymLoginCacheKey();
12208
12211
  if (!e) return null;
12209
12212
  let t = at.get(e);
12210
- return Ts(t) ? t : (t && at.remove(e), null);
12213
+ return Ds(t) ? t : (t && at.remove(e), null);
12211
12214
  }
12212
12215
  _setCachedAnonymLogin(e) {
12213
12216
  let t = this._getAnonymLoginCacheKey();
12214
- !t || !Ts(e) || at.set(t, {
12217
+ !t || !Ds(e) || at.set(t, {
12215
12218
  session_key: e.session_key,
12216
12219
  session_secret_key: e.session_secret_key,
12217
12220
  uid: e.uid
@@ -12232,7 +12235,7 @@ var Cs = class extends hs {
12232
12235
  version: 1,
12233
12236
  items: e
12234
12237
  };
12235
- N.clientStatsPlatform && (t.platform = N.clientStatsPlatform), ls("vchat.clientStats", { data: JSON.stringify(t) });
12238
+ N.clientStatsPlatform && (t.platform = N.clientStatsPlatform), ds("vchat.clientStats", { data: JSON.stringify(t) });
12236
12239
  }
12237
12240
  async uploadDebugLogs(e, t, n, r) {
12238
12241
  let i = {
@@ -12243,7 +12246,7 @@ var Cs = class extends hs {
12243
12246
  }, a = await this._callUnsafe("vchat.getLogUploadUrl", i), o = new FormData(), s = new Blob([r], { type: "application/json" });
12244
12247
  o.append("file", s, "log.json");
12245
12248
  let c = new URL(a.upload_url);
12246
- return c.searchParams.append("size", s.size.toString()), ps(c.toString(), o);
12249
+ return c.searchParams.append("size", s.size.toString()), hs(c.toString(), o);
12247
12250
  }
12248
12251
  async joinConversation(e, t = !1, n) {
12249
12252
  let r = {
@@ -12374,7 +12377,7 @@ var Cs = class extends hs {
12374
12377
  conversationId: e,
12375
12378
  reason: t
12376
12379
  };
12377
- N.anonymToken && (n.anonymToken = N.anonymToken), ls("vchat.hangupConversation", n);
12380
+ N.anonymToken && (n.anonymToken = N.anonymToken), ds("vchat.hangupConversation", n);
12378
12381
  }
12379
12382
  async removeHistoryRecords(e) {
12380
12383
  await this._call("vchat.removeHistoryRecords", { recordIds: e.join(",") });
@@ -12390,19 +12393,19 @@ var Cs = class extends hs {
12390
12393
  return Array.isArray(e?.inbounds) ? e.inbounds : [];
12391
12394
  }
12392
12395
  };
12393
- function ws(e) {
12396
+ function Es(e) {
12394
12397
  return typeof e == "object" && !!e && "error_code" in e && "error_msg" in e;
12395
12398
  }
12396
- function Ts(e) {
12399
+ function Ds(e) {
12397
12400
  return typeof e == "object" && !!e && "session_key" in e && "session_secret_key" in e && typeof e.session_key == "string" && e.session_key.length > 0 && typeof e.session_secret_key == "string" && e.session_secret_key.length > 0;
12398
12401
  }
12399
12402
  //#endregion
12400
12403
  //#region src/enums/RecordRole.ts
12401
- var Es = /* @__PURE__ */ function(e) {
12404
+ var Os = /* @__PURE__ */ function(e) {
12402
12405
  return e.KING = "KING", e.PAWN = "PAWN", e;
12403
- }(Es || {}), Ds = /* @__PURE__ */ function(e) {
12406
+ }(Os || {}), ks = /* @__PURE__ */ function(e) {
12404
12407
  return e.OFF = "0", e.ON = "1", e;
12405
- }({}), Os = class {
12408
+ }({}), As = class {
12406
12409
  constructor(e) {
12407
12410
  h(this, "_queue", void 0), h(this, "_readCursor", void 0), h(this, "_writeCursor", void 0), h(this, "_moveReadCursor", void 0), h(this, "_left", void 0), this._queue = Array(e).fill(null), this._readCursor = this._writeCursor = this._left = 0, this._moveReadCursor = !1;
12408
12411
  }
@@ -12425,12 +12428,12 @@ var Es = /* @__PURE__ */ function(e) {
12425
12428
  let e = this._queue[this._readCursor];
12426
12429
  return e && (this._moveReadCursor = !1, this._queue[this._readCursor] = null, this._readCursor = this.nextCursor(this._readCursor), --this._left), e;
12427
12430
  }
12428
- }, ks = class {
12431
+ }, js = class {
12429
12432
  constructor(e, t, n, r = null) {
12430
12433
  h(this, "_uuid", void 0), h(this, "_apiKey", void 0), h(this, "_callToken", void 0), h(this, "_apiEnv", void 0), h(this, "_baseApiUrl", void 0), h(this, "_sessionKey", void 0), this._uuid = M.uuid(), this._apiKey = t, this._callToken = n, this._apiEnv = e, this._baseApiUrl = r;
12431
12434
  }
12432
12435
  async authorize() {
12433
- let e = await us("auth.anonymLogin", {
12436
+ let e = await fs("auth.anonymLogin", {
12434
12437
  session_data: {
12435
12438
  device_id: this._uuid,
12436
12439
  client_version: N.appVersion,
@@ -12439,18 +12442,18 @@ var Es = /* @__PURE__ */ function(e) {
12439
12442
  version: 3
12440
12443
  },
12441
12444
  application_key: this._apiKey
12442
- }, !0, await ss(this._baseApiUrl, this._apiEnv));
12445
+ }, !0, await ls(this._baseApiUrl, this._apiEnv));
12443
12446
  return M.isObject(e) && !("error_msg" in e) ? (this._sessionKey = e.session_key, !0) : !1;
12444
12447
  }
12445
12448
  async hangupConversation(e) {
12446
- await us("vchat.hangupConversation", {
12449
+ await fs("vchat.hangupConversation", {
12447
12450
  conversationId: e,
12448
12451
  reason: O.HUNGUP,
12449
12452
  application_key: this._apiKey,
12450
12453
  session_key: this._sessionKey
12451
- }, !0, await ss(this._baseApiUrl, this._apiEnv));
12454
+ }, !0, await ls(this._baseApiUrl, this._apiEnv));
12452
12455
  }
12453
- }, As, js = null, Ms = {
12456
+ }, Ms, Ns = null, Ps = {
12454
12457
  getCameras: E.getCameras,
12455
12458
  getMicrophones: E.getMicrophones,
12456
12459
  getOutput: E.getOutput,
@@ -12476,24 +12479,24 @@ var Es = /* @__PURE__ */ function(e) {
12476
12479
  baseChromeVersion: E.baseChromeVersion,
12477
12480
  getAudioContext: E.getAudioContext,
12478
12481
  isAudioShareSupported: E.isAudioShareSupported
12479
- }, Ns = { participantMarkerCompare: M.participantMarkerCompare };
12480
- function Ps(e) {
12481
- js = e;
12482
+ }, Fs = { participantMarkerCompare: M.participantMarkerCompare };
12483
+ function Is(e) {
12484
+ Ns = e;
12482
12485
  }
12483
- function Fs(e) {
12486
+ function Ls(e) {
12484
12487
  N.videoEffects = e;
12485
12488
  }
12486
- function Is(e) {
12489
+ function Rs(e) {
12487
12490
  N.audioEffects = e;
12488
12491
  }
12489
- function Ls(e, t = null, n = {}, r = 1) {
12492
+ function zs(e, t = null, n = {}, r = 1) {
12490
12493
  N.vmoji = e, N.vmojiOptions = {
12491
12494
  protocolVersion: r,
12492
12495
  renderingOptions: n
12493
12496
  }, t && e.setSDK(t);
12494
12497
  }
12495
- async function Rs(t) {
12496
- N.set(t), As || (As = new Cs()), e.disableLog(!N.debug), z.toggle(N.debug), z.log(`Calls SDK ${N.sdkVersion}`, t), await E.init();
12498
+ async function Bs(t) {
12499
+ N.set(t), Ms || (Ms = new Ts()), e.disableLog(!N.debug), z.toggle(N.debug), z.log(`Calls SDK ${N.sdkVersion}`, t), await E.init();
12497
12500
  let n = E.getBrowserSupportFailure();
12498
12501
  if (n) throw new k(x.UNSUPPORTED, { callError: {
12499
12502
  scope: "internal",
@@ -12502,13 +12505,13 @@ async function Rs(t) {
12502
12505
  } });
12503
12506
  z.log("UserAgent:", navigator.userAgent), z.log("Screen resolution:", `${window.screen.width}x${window.screen.height}`), z.log("Permissions:", `Camera: ${E.hasCameraPermission()}, Mic: ${E.hasMicrophonePermission()}`), z.log("Simulcast:", `${t.simulcast} => ${N.simulcast}`);
12504
12507
  }
12505
- async function zs(e, t = [S.AUDIO], n = "", r = !1, i = !1, a, o, s) {
12508
+ async function Vs(e, t = [S.AUDIO], n = "", r = !1, i = !1, a, o, s) {
12506
12509
  let c = [];
12507
- return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), Bs([], Fa.USER, t, n, r, i, a, c, o, s);
12510
+ return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), Hs([], Fa.USER, t, n, r, i, a, c, o, s);
12508
12511
  }
12509
- async function Bs(e, t = Fa.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12512
+ async function Hs(e, t = Fa.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12510
12513
  if (!N.hold && B.callsLength > 0) throw z.error("There is already active call"), new k(O.HAS_ACTIVE_CALL);
12511
- return new $(new Cs(), js).onStart({
12514
+ return new $(new Ts(), Ns).onStart({
12512
12515
  opponentIds: e,
12513
12516
  opponentType: t,
12514
12517
  mediaOptions: n,
@@ -12521,40 +12524,40 @@ async function Bs(e, t = Fa.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12521
12524
  conversationId: l
12522
12525
  });
12523
12526
  }
12524
- async function Vs(e, t) {
12525
- return Hs(e, j.USER, void 0, t);
12527
+ async function Us(e, t) {
12528
+ return Ws(e, j.USER, void 0, t);
12526
12529
  }
12527
- async function Hs(e, t = j.USER, n, r, i, a) {
12530
+ async function Ws(e, t = j.USER, n, r, i, a) {
12528
12531
  if (e === $.id()) throw Error("Push has already been processed");
12529
- return new $(new Cs(), js).onPush(e, t, n, r, i, a);
12532
+ return new $(new Ts(), Ns).onPush(e, t, n, r, i, a);
12530
12533
  }
12531
- async function Us() {
12532
- return As.getInbounds();
12534
+ async function Gs() {
12535
+ return Ms.getInbounds();
12533
12536
  }
12534
- async function Ws(e, t) {
12535
- return e && (N.authToken = e), t !== void 0 && N.apiBaseUrl !== t && (N.apiBaseUrl = t, as()), As.authorize();
12537
+ async function Ks(e, t) {
12538
+ return e && (N.authToken = e), t !== void 0 && N.apiBaseUrl !== t && (N.apiBaseUrl = t, ss()), Ms.authorize();
12536
12539
  }
12537
- async function Gs(e = [S.AUDIO], t) {
12538
- return ml(t).accept(e);
12540
+ async function qs(e = [S.AUDIO], t) {
12541
+ return gl(t).accept(e);
12539
12542
  }
12540
- async function Ks(e) {
12541
- let t = pl(e);
12543
+ async function Js(e) {
12544
+ let t = hl(e);
12542
12545
  if (t) return t.decline();
12543
12546
  }
12544
- async function qs(e, t = [S.AUDIO]) {
12545
- return Js(e, t);
12547
+ async function Ys(e, t = [S.AUDIO]) {
12548
+ return Xs(e, t);
12546
12549
  }
12547
- async function Js(e, t, n) {
12550
+ async function Xs(e, t, n) {
12548
12551
  if (!N.hold && B.callsLength > 0) throw z.error("There is already active call"), new k(O.HAS_ACTIVE_CALL);
12549
- return new $(new Cs(), js).onJoin({
12552
+ return new $(new Ts(), Ns).onJoin({
12550
12553
  conversationId: e,
12551
12554
  mediaOptions: t,
12552
12555
  chatId: n
12553
12556
  });
12554
12557
  }
12555
- async function Ys(e, t = [S.AUDIO], n, r, i, a) {
12558
+ async function Zs(e, t = [S.AUDIO], n, r, i, a) {
12556
12559
  if (!N.hold && B.callsLength > 0) throw z.error("There is already active call"), new k(O.HAS_ACTIVE_CALL);
12557
- return n && (N.anonymToken = n), new $(new Cs(), js).onJoin({
12560
+ return n && (N.anonymToken = n), new $(new Ts(), Ns).onJoin({
12558
12561
  joinLink: e,
12559
12562
  mediaOptions: t,
12560
12563
  observedIds: r,
@@ -12563,30 +12566,30 @@ async function Ys(e, t = [S.AUDIO], n, r, i, a) {
12563
12566
  anonymous: !!N.anonymToken
12564
12567
  });
12565
12568
  }
12566
- function Xs(e) {
12567
- let t = pl(e);
12569
+ function Qs(e) {
12570
+ let t = hl(e);
12568
12571
  return t ? t.hangup() : ($.hangupAfterInit(), Promise.resolve());
12569
12572
  }
12570
- async function Zs(e, t) {
12573
+ async function $s(e, t) {
12571
12574
  let n = Array.isArray(e) ? e : [e], r = $.current();
12572
12575
  r && await r.addParticipant(n, t);
12573
12576
  }
12574
- async function Qs(e, t) {
12577
+ async function ec(e, t) {
12575
12578
  let n = $.current();
12576
12579
  if (n) {
12577
12580
  let r = e.map((e) => M.composeUserId(e));
12578
12581
  await n.addParticipantLegacy(r, t);
12579
12582
  }
12580
12583
  }
12581
- async function $s(e, t = !1) {
12584
+ async function tc(e, t = !1) {
12582
12585
  let n = $.current()?.getCachedRawOkIdByExternalId(e) ?? null;
12583
12586
  if (!n) {
12584
12587
  z.warn("removeParticipant: externalId not found in cache", e);
12585
12588
  return;
12586
12589
  }
12587
- return ec(n, t);
12590
+ return nc(n, t);
12588
12591
  }
12589
- async function ec(e, t = !1) {
12592
+ async function nc(e, t = !1) {
12590
12593
  let n = $.current();
12591
12594
  if (n) try {
12592
12595
  await n.removeParticipant(M.composeUserId(e), t);
@@ -12594,13 +12597,13 @@ async function ec(e, t = !1) {
12594
12597
  z.warn(`Failed to remove participant ${e}. Perhaps he is no longer on the call. ${t}`);
12595
12598
  }
12596
12599
  }
12597
- async function tc(e, t) {
12600
+ async function rc(e, t) {
12598
12601
  let n = $.current();
12599
12602
  if (e === "videoinput" && At.contains(t)) return N.videoFacingMode = t, n ? (E.isMobile() && n.stopVideoTrack(), n.changeDevice(e)) : void 0;
12600
12603
  if (!await E._saveDeviceId(e, t)) throw Error(`Device not found: ${t}`);
12601
12604
  if (n) return n.changeDevice(e);
12602
12605
  }
12603
- async function nc(e, t) {
12606
+ async function ic(e, t) {
12604
12607
  let n = typeof e == "object" ? {
12605
12608
  ...e,
12606
12609
  fastScreenSharing: e.captureScreen && e.fastScreenSharing,
@@ -12609,34 +12612,34 @@ async function nc(e, t) {
12609
12612
  captureScreen: e,
12610
12613
  fastScreenSharing: !1,
12611
12614
  captureAudio: !1
12612
- }, r = pl(t);
12615
+ }, r = hl(t);
12613
12616
  return r ? r.toggleScreenCapturing(n) : Promise.reject();
12614
12617
  }
12615
- function rc(e) {
12618
+ function ac(e) {
12616
12619
  let t = $.current();
12617
12620
  t && t.toggleAnimojiCapturing(e);
12618
12621
  }
12619
- async function ic(e, t = !1) {
12622
+ async function oc(e, t = !1) {
12620
12623
  let n = $.current();
12621
12624
  n && await n.setVideoStream(e, t);
12622
12625
  }
12623
- async function ac(e, t) {
12624
- let n = pl(t);
12626
+ async function sc(e, t) {
12627
+ let n = hl(t);
12625
12628
  n && await n.toggleLocalVideo(e);
12626
12629
  }
12627
- async function oc(e, t) {
12628
- let n = pl(t);
12630
+ async function cc(e, t) {
12631
+ let n = hl(t);
12629
12632
  n && await n.toggleLocalAudio(e);
12630
12633
  }
12631
- async function sc(e) {
12634
+ async function lc(e) {
12632
12635
  let t = $.current();
12633
12636
  if (t) return t.setLocalResolution(e);
12634
12637
  }
12635
- async function cc(e) {
12638
+ async function uc(e) {
12636
12639
  let t = $.current();
12637
12640
  t && await t.changePriorities(e);
12638
12641
  }
12639
- async function lc(e, t) {
12642
+ async function dc(e, t) {
12640
12643
  let n = $.current();
12641
12644
  if (n) {
12642
12645
  let r;
@@ -12651,33 +12654,33 @@ async function lc(e, t) {
12651
12654
  await n.changeParticipantState(e, r);
12652
12655
  }
12653
12656
  }
12654
- async function uc() {
12657
+ async function fc() {
12655
12658
  let e = $.current();
12656
12659
  e && await e.putHandsDown();
12657
12660
  }
12658
- async function dc(e) {
12661
+ async function pc(e) {
12659
12662
  let t = $.current();
12660
12663
  t && await t.updateDisplayLayout(e);
12661
12664
  }
12662
- async function fc(e) {
12665
+ async function mc(e) {
12663
12666
  let t = $.current();
12664
12667
  t && await t.requestDisplayLayout(e);
12665
12668
  }
12666
- async function pc(e, t, n = !1) {
12669
+ async function hc(e, t, n = !1) {
12667
12670
  let r = $.current()?.getCachedRawOkIdByExternalId(e) ?? null;
12668
12671
  if (!r) {
12669
12672
  z.warn("grantRoles: externalId not found in cache", e);
12670
12673
  return;
12671
12674
  }
12672
- return mc(r, Q.getDeviceIdx(e), t, n);
12675
+ return gc(r, Q.getDeviceIdx(e), t, n);
12673
12676
  }
12674
- async function mc(e, t, n, r = !1) {
12677
+ async function gc(e, t, n, r = !1) {
12675
12678
  let i = $.current();
12676
12679
  i && await i.grantRoles(M.composeParticipantId(e, j.USER, t), n, r);
12677
12680
  }
12678
- async function hc({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
12681
+ async function _c({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
12679
12682
  let i = null;
12680
- return e && (i = $.current()?.getCachedRawOkIdByExternalId(e) ?? null, i || z.warn("muteParticipant: externalId not found in cache", e)), gc({
12683
+ return e && (i = $.current()?.getCachedRawOkIdByExternalId(e) ?? null, i || z.warn("muteParticipant: externalId not found in cache", e)), vc({
12681
12684
  uid: i,
12682
12685
  muteStates: t,
12683
12686
  requestedMedia: n,
@@ -12685,129 +12688,129 @@ async function hc({ externalId: e = null, muteStates: t, requestedMedia: n = [],
12685
12688
  roomId: r
12686
12689
  });
12687
12690
  }
12688
- async function gc({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
12691
+ async function vc({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
12689
12692
  let a = $.current();
12690
12693
  if (a) {
12691
12694
  let o = e ? M.composeParticipantId(e, j.USER, r) : null;
12692
12695
  await a.muteParticipant(o, t, n, i);
12693
12696
  }
12694
12697
  }
12695
- async function _c(e, t = !1, n = null) {
12698
+ async function yc(e, t = !1, n = null) {
12696
12699
  let r = $.current()?.getCachedRawOkIdByExternalId(e) ?? null;
12697
12700
  if (!r) {
12698
12701
  z.warn("pinParticipant: externalId not found in cache", e);
12699
12702
  return;
12700
12703
  }
12701
- return vc(r, t, Q.getDeviceIdx(e), n);
12704
+ return bc(r, t, Q.getDeviceIdx(e), n);
12702
12705
  }
12703
- async function vc(e, t = !1, n = 0, r = null) {
12706
+ async function bc(e, t = !1, n = 0, r = null) {
12704
12707
  let i = $.current();
12705
12708
  i && await i.pinParticipant(M.composeParticipantId(e, j.USER, n), t, r);
12706
12709
  }
12707
- async function yc(e) {
12710
+ async function xc(e) {
12708
12711
  let t = $.current();
12709
12712
  t && await t.updateMediaModifiers(e);
12710
12713
  }
12711
- async function bc(e) {
12714
+ async function Sc(e) {
12712
12715
  let t = $.current();
12713
12716
  t && await t.enableVideoSuspend(e);
12714
12717
  }
12715
- async function xc(e) {
12718
+ async function Cc(e) {
12716
12719
  let t = $.current();
12717
12720
  t && await t.enableVideoSuspendSuggest(e);
12718
12721
  }
12719
- async function Sc(e) {
12722
+ async function wc(e) {
12720
12723
  let t = $.current();
12721
12724
  t && await t.changeOptions(e);
12722
12725
  }
12723
- async function Cc(e, t = null) {
12726
+ async function Tc(e, t = null) {
12724
12727
  let n = null;
12725
- return t && (n = $.current()?.getCachedRawOkIdByExternalId(t) ?? null, n || z.warn("chatMessage: externalId not found in cache", t)), wc(e, n);
12728
+ return t && (n = $.current()?.getCachedRawOkIdByExternalId(t) ?? null, n || z.warn("chatMessage: externalId not found in cache", t)), Ec(e, n);
12726
12729
  }
12727
- async function wc(e, t = null) {
12730
+ async function Ec(e, t = null) {
12728
12731
  let n = $.current();
12729
12732
  if (n) {
12730
12733
  let r = t ? M.composeUserId(t) : null;
12731
12734
  await n.chatMessage(e, r);
12732
12735
  }
12733
12736
  }
12734
- async function Tc(e = 10) {
12737
+ async function Dc(e = 10) {
12735
12738
  let t = $.current();
12736
12739
  if (t) return t.chatHistory(e);
12737
12740
  }
12738
- async function Ec(e, t = null) {
12741
+ async function Oc(e, t = null) {
12739
12742
  let n = null;
12740
- return t && (n = $.current()?.getCachedRawOkIdByExternalId(t) ?? null, n || z.warn("customData: externalId not found in cache", t)), Dc(e, n, Q.getDeviceIdx(t));
12743
+ return t && (n = $.current()?.getCachedRawOkIdByExternalId(t) ?? null, n || z.warn("customData: externalId not found in cache", t)), kc(e, n, Q.getDeviceIdx(t));
12741
12744
  }
12742
- async function Dc(e, t = null, n = 0) {
12745
+ async function kc(e, t = null, n = 0) {
12743
12746
  let r = $.current();
12744
12747
  if (r) {
12745
12748
  let i = t ? M.composeParticipantId(t, j.USER, n) : null;
12746
12749
  await r.customData(e, i);
12747
12750
  }
12748
12751
  }
12749
- async function Oc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
12750
- return (await As.createConversation(a ?? M.uuid(), e, t, {
12752
+ async function Ac(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
12753
+ return (await Ms.createConversation(a ?? M.uuid(), e, t, {
12751
12754
  onlyAdminCanShareMovie: n,
12752
12755
  waitForAdmin: r,
12753
12756
  closedConversation: i
12754
12757
  })).join_link;
12755
12758
  }
12756
- async function kc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
12759
+ async function jc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
12757
12760
  let a = i.map((e) => Q.fromId(e));
12758
- return (await As.createConversation(M.uuid(), e, t, {
12761
+ return (await Ms.createConversation(M.uuid(), e, t, {
12759
12762
  onlyAdminCanShareMovie: n,
12760
12763
  audienceMode: !0,
12761
12764
  audioOnly: r
12762
12765
  }, a)).join_link;
12763
12766
  }
12764
- async function Ac() {
12767
+ async function Mc() {
12765
12768
  let e = $.current();
12766
12769
  return e ? e.createJoinLink() : Promise.reject();
12767
12770
  }
12768
- async function jc() {
12771
+ async function Nc() {
12769
12772
  let e = $.current();
12770
12773
  return e ? e.removeJoinLink() : Promise.reject();
12771
12774
  }
12772
- async function Mc(e, t) {
12773
- return As.getAnonymTokenByLink(e, t);
12775
+ async function Pc(e, t) {
12776
+ return Ms.getAnonymTokenByLink(e, t);
12774
12777
  }
12775
- function Nc(e) {
12778
+ function Fc(e) {
12776
12779
  let t = $.current();
12777
12780
  t && t.setVolume(e);
12778
12781
  }
12779
- function Pc(e) {
12782
+ function Ic(e) {
12780
12783
  N.forceRelayPolicy = e;
12781
12784
  }
12782
- async function Fc(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
12785
+ async function Lc(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
12783
12786
  let o = $.current();
12784
12787
  return o ? o.startStream(e, t, n, r, i, a) : Promise.reject();
12785
12788
  }
12786
- async function Ic(e = null, t) {
12789
+ async function Rc(e = null, t) {
12787
12790
  let n = $.current();
12788
12791
  return n ? n.stopStream(e, t) : Promise.reject();
12789
12792
  }
12790
- async function Lc(e = null) {
12793
+ async function zc(e = null) {
12791
12794
  let t = $.current();
12792
12795
  return t ? t.publishStream(e) : Promise.reject();
12793
12796
  }
12794
- async function Rc() {
12797
+ async function Bc() {
12795
12798
  let e = $.current();
12796
12799
  return e ? e.getStreamInfo() : Promise.reject();
12797
12800
  }
12798
- async function zc(e) {
12801
+ async function Vc(e) {
12799
12802
  let t = $.current();
12800
12803
  return t ? t.addMovie(e) : Promise.reject();
12801
12804
  }
12802
- async function Bc(e) {
12805
+ async function Hc(e) {
12803
12806
  let t = $.current();
12804
12807
  return t ? t.updateMovie(e) : Promise.reject();
12805
12808
  }
12806
- async function Vc(e) {
12809
+ async function Uc(e) {
12807
12810
  let t = $.current();
12808
12811
  return t ? t.removeMovie(e) : Promise.reject();
12809
12812
  }
12810
- async function Hc(e, t) {
12813
+ async function Wc(e, t) {
12811
12814
  let n = $.current();
12812
12815
  if (n) {
12813
12816
  let r = [];
@@ -12832,11 +12835,11 @@ async function Hc(e, t) {
12832
12835
  }
12833
12836
  return Promise.reject();
12834
12837
  }
12835
- async function Uc(e, t) {
12838
+ async function Gc(e, t) {
12836
12839
  let n = $.current();
12837
12840
  return n ? n.activateRooms(e, t) : Promise.reject();
12838
12841
  }
12839
- async function Wc(e = null, t = null) {
12842
+ async function Kc(e = null, t = null) {
12840
12843
  let n = $.current();
12841
12844
  if (!n) return Promise.reject();
12842
12845
  let r;
@@ -12851,25 +12854,25 @@ async function Wc(e = null, t = null) {
12851
12854
  }
12852
12855
  return n.switchRoom(e, r);
12853
12856
  }
12854
- async function Gc(e) {
12857
+ async function qc(e) {
12855
12858
  let t = $.current();
12856
12859
  return t ? t.removeRooms(e) : Promise.reject();
12857
12860
  }
12858
- function Kc(e) {
12861
+ function Jc(e) {
12859
12862
  N.statisticsInterval = e;
12860
12863
  let t = $.current();
12861
12864
  if (t) return t.updateStatisticsInterval();
12862
12865
  }
12863
- function qc(t) {
12866
+ function Yc(t) {
12864
12867
  e.disableLog(!t), z.toggle(t);
12865
12868
  }
12866
- function Jc(e, ...t) {
12869
+ function Xc(e, ...t) {
12867
12870
  N.debugLog && ($.debugMessage(e, "[external]", ...t) || z.send(e, "[external]", ...t));
12868
12871
  }
12869
- function Yc(e, t, ...n) {
12872
+ function Zc(e, t, ...n) {
12870
12873
  N.debugLog && ($.debugMessageWithContext(e, t, "[external]", ...n) || z.send(e, "[external]", ...n));
12871
12874
  }
12872
- var Xc = {
12875
+ var Qc = {
12873
12876
  list: Ne,
12874
12877
  get: Pe,
12875
12878
  getJson: Fe,
@@ -12877,7 +12880,7 @@ var Xc = {
12877
12880
  clear: Le,
12878
12881
  stats: Re
12879
12882
  };
12880
- function Zc() {
12883
+ function $c() {
12881
12884
  let e = [
12882
12885
  [`Calls SDK ${N.sdkVersion}`, N.toJSON()],
12883
12886
  ["UserAgent:", navigator.userAgent],
@@ -12894,31 +12897,31 @@ function Zc() {
12894
12897
  d: e
12895
12898
  }));
12896
12899
  }
12897
- async function Qc() {
12900
+ async function el() {
12898
12901
  let e = $.id(), t = $.debugSessionId();
12899
12902
  if (!t || !e) throw z.error("[uploadDebugLogs]", "No conversation id found"), Error("No conversation id found");
12900
12903
  let n = await Pe({ sessionId: t });
12901
12904
  if (n.length === 0) throw z.error("[uploadDebugLogs]", "No logs found"), Error("No logs found");
12902
12905
  let r = n[0].t, i = n[n.length - 1].t;
12903
12906
  try {
12904
- return As?.uploadDebugLogs(e, r, i, JSON.stringify([...Zc(), ...n]));
12907
+ return Ms?.uploadDebugLogs(e, r, i, JSON.stringify([...$c(), ...n]));
12905
12908
  } catch (e) {
12906
12909
  throw z.error("[uploadDebugLogs]", "Error while uploading logs", e), Error("Error while uploading logs", { cause: e });
12907
12910
  }
12908
12911
  }
12909
- async function $c(e) {
12912
+ async function tl(e) {
12910
12913
  let t = $.current();
12911
12914
  if (t) return t.videoEffect(e);
12912
12915
  }
12913
- async function el(e, t) {
12916
+ async function nl(e, t) {
12914
12917
  let n = $.current();
12915
12918
  if (n) return n.audioEffect(e.length > 0 ? e : null, t);
12916
12919
  }
12917
- async function tl(e) {
12920
+ async function rl(e) {
12918
12921
  let t = $.current();
12919
12922
  t && await t.setAudioStream(e);
12920
12923
  }
12921
- async function nl(e, t = null, n = null) {
12924
+ async function il(e, t = null, n = null) {
12922
12925
  let r = $.current();
12923
12926
  if (!r) return;
12924
12927
  let i = n ?? t?.id, a = null;
@@ -12929,18 +12932,18 @@ async function nl(e, t = null, n = null) {
12929
12932
  }
12930
12933
  r.setAnimojiSvg(e, a, i);
12931
12934
  }
12932
- function rl(e) {
12935
+ function al(e) {
12933
12936
  let t = $.current();
12934
12937
  t && t.setAnimojiFill(e);
12935
12938
  }
12936
- async function il(e = null, t, n = !1) {
12937
- return ml().getWaitingHall(e, t, n);
12939
+ async function ol(e = null, t, n = !1) {
12940
+ return gl().getWaitingHall(e, t, n);
12938
12941
  }
12939
- async function al() {
12940
- return ml().getAudienceModeHands();
12942
+ async function sl() {
12943
+ return gl().getAudienceModeHands();
12941
12944
  }
12942
- async function ol(e, t = !1) {
12943
- let n = ml(), r;
12945
+ async function cl(e, t = !1) {
12946
+ let n = gl(), r;
12944
12947
  if (e) {
12945
12948
  let t = n.getCachedRawOkIdByExternalId(e);
12946
12949
  if (!t) {
@@ -12951,67 +12954,67 @@ async function ol(e, t = !1) {
12951
12954
  }
12952
12955
  return n.promoteParticipant(r, t);
12953
12956
  }
12954
- async function sl(e = !1) {
12955
- return ml().requestPromotion(e);
12957
+ async function ll(e = !1) {
12958
+ return gl().requestPromotion(e);
12956
12959
  }
12957
- async function cl(e = !1) {
12958
- return ml().acceptPromotion(e);
12960
+ async function ul(e = !1) {
12961
+ return gl().acceptPromotion(e);
12959
12962
  }
12960
- async function ll(e) {
12961
- return ml().getParticipantListChunk(e);
12963
+ async function dl(e) {
12964
+ return gl().getParticipantListChunk(e);
12962
12965
  }
12963
- async function ul(e) {
12964
- return ml().getParticipants(e);
12966
+ async function fl(e) {
12967
+ return gl().getParticipants(e);
12965
12968
  }
12966
- async function dl(e) {
12967
- return ml().feedback(e);
12969
+ async function pl(e) {
12970
+ return gl().feedback(e);
12968
12971
  }
12969
- async function fl(e, t, n) {
12970
- return ml(n).enableFeatureForRoles(e, t);
12972
+ async function ml(e, t, n) {
12973
+ return gl(n).enableFeatureForRoles(e, t);
12971
12974
  }
12972
- function pl(e) {
12975
+ function hl(e) {
12973
12976
  return e ? B.get(e) ?? null : $.current() ?? B.getFirst();
12974
12977
  }
12975
- function ml(e) {
12976
- let t = pl(e);
12978
+ function gl(e) {
12979
+ let t = hl(e);
12977
12980
  if (!t) throw Error("Conversation not found");
12978
12981
  return t;
12979
12982
  }
12980
- async function hl(e) {
12981
- await As.removeHistoryRecords(e);
12983
+ async function _l(e) {
12984
+ await Ms.removeHistoryRecords(e);
12982
12985
  }
12983
- async function gl(e) {
12986
+ async function vl(e) {
12984
12987
  let t = $.current() ?? B.getFirst();
12985
12988
  t && await t.startAsr(e);
12986
12989
  }
12987
- async function _l(e) {
12990
+ async function yl(e) {
12988
12991
  let t = $.current() ?? B.getFirst();
12989
12992
  t && await t.stopAsr(e);
12990
12993
  }
12991
- async function vl(e) {
12994
+ async function bl(e) {
12992
12995
  let t = $.current() ?? B.getFirst();
12993
12996
  t && await t.requestAsr(e);
12994
12997
  }
12995
- async function yl(e) {
12998
+ async function xl(e) {
12996
12999
  let t = $.current();
12997
13000
  return t ? t.startUrlSharing(e) : Promise.reject();
12998
13001
  }
12999
- async function bl() {
13002
+ async function Sl() {
13000
13003
  let e = $.current();
13001
13004
  return e ? e.stopUrlSharing() : Promise.reject();
13002
13005
  }
13003
- async function xl(e) {
13006
+ async function Cl(e) {
13004
13007
  await B.switchCall(e);
13005
13008
  }
13006
- function Sl() {
13009
+ function wl() {
13007
13010
  return B.getActiveId();
13008
13011
  }
13009
- function Cl() {
13012
+ function Tl() {
13010
13013
  return $.getSyncedTime();
13011
13014
  }
13012
- function wl() {
13015
+ function El() {
13013
13016
  return N.sdkVersion;
13014
13017
  }
13015
13018
  typeof window < "u" && (window.__CALLS_SDK = mn);
13016
13019
  //#endregion
13017
- export { Cs as Api, ks as ApiExternal, Os as ArrayDequeue, y as AuthData, f as BaseLogger, Pa as CallDirection, Fa as CallType, Ia as ChatRoomEventType, La as ConversationFeature, Ra as ConversationOption, _n as DebugMessageType, Ya as ExternalIdType, At as FacingMode, x as FatalError, k as HangupReason, O as HangupType, S as MediaOption, A as MediaTrackKind, H as MediaType, Va as MuteState, Z as ParticipantState, Ds as ParticipantStateDataValue, P as ParticipantStatus, Es as RecordRole, Ha as RoomsEventType, Na as Signaling, V as SignalingCommandType, fr as SignalingConnectionType, q as SignalingNotification, Y as TransportTopology, Ga as UserRole, j as UserType, go as VolumeDetector, Gs as acceptCall, cl as acceptPromotion, Uc as activateRooms, zc as addMovie, Zs as addParticipant, Qs as addParticipantInternal, Ws as authorize, Ms as browser, Bs as callInternal, zs as callTo, nc as captureScreen, rc as captureVmoji, el as changeAudioEffect, Sc as changeConversationOptions, tc as changeDevice, lc as changeParticipantState, cc as changePriorities, $c as changeVideoEffect, Tc as chatHistory, Cc as chatMessage, wc as chatMessageInternal, Ac as createJoinLink, Ec as customData, Dc as customDataInternal, qc as debug, Xc as debugLogs, Jc as debugMessage, Yc as debugMessageWithContext, Ks as declineCall, fl as enableFeatureForRoles, bc as enableVideoSuspend, xc as enableVideoSuspendSuggest, dl as feedback, Pc as forceRelayPolicy, Sl as getActiveCallId, Mc as getAnonymTokenByLink, al as getAudienceModeHands, Us as getInbounds, ll as getParticipantListChunk, ul as getParticipants, Rc as getStreamInfo, Cl as getSyncedTime, il as getWaitingHall, pc as grantRoles, mc as grantRolesInternal, Xs as hangup, Rs as init, qs as joinCall, Ys as joinCallByLink, Js as joinCallInternal, hc as muteParticipant, gc as muteParticipantInternal, _c as pinParticipant, vc as pinParticipantInternal, Vs as processPush, Hs as processPushInternal, ol as promoteParticipant, Lc as publishStream, uc as putHandsDown, hl as removeHistoryRecords, jc as removeJoinLink, Vc as removeMovie, $s as removeParticipant, ec as removeParticipantInternal, Gc as removeRooms, vl as requestAsr, fc as requestDisplayLayout, sl as requestPromotion, Is as setAudioEffects, tl as setAudioStream, sc as setLocalResolution, Ps as setLogger, yc as setMediaModifiers, Kc as setStatisticsInterval, Fs as setVideoEffects, ic as setVideoStream, Ls as setVmoji, rl as setVmojiFill, nl as setVmojiSvg, Nc as setVolume, gl as startAsr, kc as startAudienceConversation, Oc as startConversation, Fc as startStream, yl as startUrlSharing, _l as stopAsr, Ic as stopStream, bl as stopUrlSharing, xl as switchCall, Wc as switchRoom, oc as toggleLocalAudio, ac as toggleLocalVideo, dc as updateDisplayLayout, Bc as updateMovie, Hc as updateRooms, Qc as uploadDebugLogs, Ns as utils, wl as version };
13020
+ export { Ts as Api, js as ApiExternal, As as ArrayDequeue, y as AuthData, f as BaseLogger, Pa as CallDirection, Fa as CallType, Ia as ChatRoomEventType, La as ConversationFeature, Ra as ConversationOption, _n as DebugMessageType, Ya as ExternalIdType, At as FacingMode, x as FatalError, k as HangupReason, O as HangupType, S as MediaOption, A as MediaTrackKind, H as MediaType, Va as MuteState, Z as ParticipantState, ks as ParticipantStateDataValue, P as ParticipantStatus, Os as RecordRole, Ha as RoomsEventType, Na as Signaling, V as SignalingCommandType, fr as SignalingConnectionType, q as SignalingNotification, Y as TransportTopology, Ga as UserRole, j as UserType, vo as VolumeDetector, qs as acceptCall, ul as acceptPromotion, Gc as activateRooms, Vc as addMovie, $s as addParticipant, ec as addParticipantInternal, Ks as authorize, Ps as browser, Hs as callInternal, Vs as callTo, ic as captureScreen, ac as captureVmoji, nl as changeAudioEffect, wc as changeConversationOptions, rc as changeDevice, dc as changeParticipantState, uc as changePriorities, tl as changeVideoEffect, Dc as chatHistory, Tc as chatMessage, Ec as chatMessageInternal, Mc as createJoinLink, Oc as customData, kc as customDataInternal, Yc as debug, Qc as debugLogs, Xc as debugMessage, Zc as debugMessageWithContext, Js as declineCall, ml as enableFeatureForRoles, Sc as enableVideoSuspend, Cc as enableVideoSuspendSuggest, pl as feedback, Ic as forceRelayPolicy, wl as getActiveCallId, Pc as getAnonymTokenByLink, sl as getAudienceModeHands, Gs as getInbounds, dl as getParticipantListChunk, fl as getParticipants, Bc as getStreamInfo, Tl as getSyncedTime, ol as getWaitingHall, hc as grantRoles, gc as grantRolesInternal, Qs as hangup, Bs as init, Ys as joinCall, Zs as joinCallByLink, Xs as joinCallInternal, _c as muteParticipant, vc as muteParticipantInternal, yc as pinParticipant, bc as pinParticipantInternal, Us as processPush, Ws as processPushInternal, cl as promoteParticipant, zc as publishStream, fc as putHandsDown, _l as removeHistoryRecords, Nc as removeJoinLink, Uc as removeMovie, tc as removeParticipant, nc as removeParticipantInternal, qc as removeRooms, bl as requestAsr, mc as requestDisplayLayout, ll as requestPromotion, Rs as setAudioEffects, rl as setAudioStream, lc as setLocalResolution, Is as setLogger, xc as setMediaModifiers, Jc as setStatisticsInterval, Ls as setVideoEffects, oc as setVideoStream, zs as setVmoji, al as setVmojiFill, il as setVmojiSvg, Fc as setVolume, vl as startAsr, jc as startAudienceConversation, Ac as startConversation, Lc as startStream, xl as startUrlSharing, yl as stopAsr, Rc as stopStream, Sl as stopUrlSharing, Cl as switchCall, Kc as switchRoom, cc as toggleLocalAudio, sc as toggleLocalVideo, pc as updateDisplayLayout, Hc as updateMovie, Wc as updateRooms, el as uploadDebugLogs, Fs as utils, El as version };