@vkontakte/calls-sdk 2.8.13-dev.89692622.0 → 2.8.13-dev.8e54394d.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.13-dev.89692622.0
3
- * Fri, 02 Oct 2026 12:19:16 GMT
2
+ * @vkontakte/calls-sdk v2.8.13-dev.8e54394d.0
3
+ * Mon, 12 Oct 2026 12:35:11 GMT
4
4
  * https://calls-sdk.cdn-vk.ru/doc/latest/index.html
5
5
  */
6
6
 
@@ -121,7 +121,6 @@ var v = new class {
121
121
  t.objectStore(g).clear(), t.objectStore(_).clear(), await this.txDone(t).catch((e) => console.warn("Failed to clear debug log storage", e));
122
122
  }
123
123
  }
124
- this.close();
125
124
  }
126
125
  async getAllSessions() {
127
126
  let e = await this.open();
@@ -2182,7 +2181,7 @@ var xn = bn.getInstance(), N = class e {
2182
2181
  return 1.1;
2183
2182
  }
2184
2183
  static get sdkVersion() {
2185
- return "2.8.13-dev.89692622.0";
2184
+ return "2.8.13-dev.8e54394d.0";
2186
2185
  }
2187
2186
  static get debug() {
2188
2187
  return e._params.debug;
@@ -2310,6 +2309,9 @@ var xn = bn.getInstance(), N = class e {
2310
2309
  static get signalingReconnectMaxCount() {
2311
2310
  return e._params.signalingReconnectMaxCount;
2312
2311
  }
2312
+ static get signalingReconnectMaxDuration() {
2313
+ return e._params.signalingReconnectMaxDuration;
2314
+ }
2313
2315
  static get waitConnectionDelay() {
2314
2316
  return e._params.waitConnectionDelay;
2315
2317
  }
@@ -2448,6 +2450,9 @@ var xn = bn.getInstance(), N = class e {
2448
2450
  static get callStatReportEnabled() {
2449
2451
  return e._params.callStatReportEnabled;
2450
2452
  }
2453
+ static get iceCandidateErrorStatEnabled() {
2454
+ return e._params.iceCandidateErrorStatEnabled;
2455
+ }
2451
2456
  static get enableLogPerfStatReport() {
2452
2457
  return e._params.enableLogPerfStatReport;
2453
2458
  }
@@ -2612,6 +2617,7 @@ var xn = bn.getInstance(), N = class e {
2612
2617
  videoSuspend: e._params.videoSuspend,
2613
2618
  debugLog: e._params.debugLog,
2614
2619
  callStatReportEnabled: e._params.callStatReportEnabled,
2620
+ iceCandidateErrorStatEnabled: e._params.iceCandidateErrorStatEnabled,
2615
2621
  joinFromMultipleDevices: e._params.joinFromMultipleDevices,
2616
2622
  movieShare: e._params.movieShare,
2617
2623
  clientType: e._params.clientType,
@@ -2654,6 +2660,7 @@ h(N, "_params", {
2654
2660
  signalingReconnectDelay: 1e3,
2655
2661
  signalingReconnectMaxDelay: 5e3,
2656
2662
  signalingReconnectMaxCount: 10,
2663
+ signalingReconnectMaxDuration: 6e4,
2657
2664
  waitConnectionDelay: 1e4,
2658
2665
  waitResponseDelay: 1e4,
2659
2666
  waitMessageDelay: 15e3,
@@ -2687,6 +2694,7 @@ h(N, "_params", {
2687
2694
  networkStatisticsInterval: 2e4,
2688
2695
  perfStatReportEnabled: !0,
2689
2696
  callStatReportEnabled: !1,
2697
+ iceCandidateErrorStatEnabled: !1,
2690
2698
  enableLogPerfStatReport: !1,
2691
2699
  voiceParams: {
2692
2700
  smoothing: .8,
@@ -3026,98 +3034,107 @@ var Cn;
3026
3034
  F("onClientStats", e);
3027
3035
  }
3028
3036
  e.onClientStats = We;
3029
- function Ge() {
3037
+ function Ge(e) {
3038
+ let t = N.get("onStatsEvent");
3039
+ if (typeof t == "function") try {
3040
+ t(e);
3041
+ } catch (e) {
3042
+ z.error("[CallsSDK] onStatsEvent callback failed", e);
3043
+ }
3044
+ }
3045
+ e.onStatsEvent = Ge;
3046
+ function Ke() {
3030
3047
  F("onAutoplayError");
3031
3048
  }
3032
- e.onAutoplayError = Ge;
3033
- function Ke(e, t, n, r, i, a) {
3049
+ e.onAutoplayError = Ke;
3050
+ function qe(e, t, n, r, i, a) {
3034
3051
  F("onChatRoomUpdated", e, t, n, r, i, a);
3035
3052
  }
3036
- e.onChatRoomUpdated = Ke;
3037
- function qe(e, t) {
3053
+ e.onChatRoomUpdated = qe;
3054
+ function y(e, t) {
3038
3055
  F("onPromoted", e, t);
3039
3056
  }
3040
- e.onPromoted = qe;
3041
- function y(e, t) {
3057
+ e.onPromoted = y;
3058
+ function b(e, t) {
3042
3059
  F("onRemoteMixedAudioStream", e, t);
3043
3060
  }
3044
- e.onRemoteMixedAudioStream = y;
3045
- function b(e, t) {
3061
+ e.onRemoteMixedAudioStream = b;
3062
+ function x(e, t) {
3046
3063
  F("onJoinLinkChanged", e, t);
3047
3064
  }
3048
- e.onJoinLinkChanged = b;
3049
- function x(e, t) {
3065
+ e.onJoinLinkChanged = x;
3066
+ function S(e, t) {
3050
3067
  F("onRoomsUpdated", e, t);
3051
3068
  }
3052
- e.onRoomsUpdated = x;
3053
- function S(e, t, n, r, i) {
3069
+ e.onRoomsUpdated = S;
3070
+ function C(e, t, n, r, i) {
3054
3071
  F("onRoomUpdated", e, t, n, r, i);
3055
3072
  }
3056
- e.onRoomUpdated = S;
3057
- function C(e, t) {
3073
+ e.onRoomUpdated = C;
3074
+ function Je(e, t) {
3058
3075
  F("onRoomParticipantsUpdated", e, t);
3059
3076
  }
3060
- e.onRoomParticipantsUpdated = C;
3061
- function Je(e, t) {
3077
+ e.onRoomParticipantsUpdated = Je;
3078
+ function Ye(e, t) {
3062
3079
  F("onRoomSwitched", e, t);
3063
3080
  }
3064
- e.onRoomSwitched = Je;
3065
- function Ye(e, t) {
3081
+ e.onRoomSwitched = Ye;
3082
+ function Xe(e, t) {
3066
3083
  F("onRoomStart", e, t);
3067
3084
  }
3068
- e.onRoomStart = Ye;
3069
- function Xe(e, t = null, n) {
3085
+ e.onRoomStart = Xe;
3086
+ function Ze(e, t = null, n) {
3070
3087
  F("onFeedback", e, t, n);
3071
3088
  }
3072
- e.onFeedback = Xe;
3073
- function Ze(e, t) {
3089
+ e.onFeedback = Ze;
3090
+ function Qe(e, t) {
3074
3091
  F("onFeaturesPerRoleChanged", e, t);
3075
3092
  }
3076
- e.onFeaturesPerRoleChanged = Ze;
3077
- function Qe(e, t) {
3093
+ e.onFeaturesPerRoleChanged = Qe;
3094
+ function $e(e, t) {
3078
3095
  F("onParticipantVmojiUpdate", e, t);
3079
3096
  }
3080
- e.onParticipantVmojiUpdate = Qe;
3081
- function $e(e, t, n) {
3097
+ e.onParticipantVmojiUpdate = $e;
3098
+ function et(e, t, n) {
3082
3099
  F("onAsrSet", e, t, n);
3083
3100
  }
3084
- e.onAsrSet = $e;
3085
- function et(e, t, n, r) {
3101
+ e.onAsrSet = et;
3102
+ function tt(e, t, n, r) {
3086
3103
  F("onAsrStarted", e, t, n, r);
3087
3104
  }
3088
- e.onAsrStarted = et;
3089
- function tt(e, t) {
3105
+ e.onAsrStarted = tt;
3106
+ function nt(e, t) {
3090
3107
  F("onAsrStopped", e, t);
3091
3108
  }
3092
- e.onAsrStopped = tt;
3093
- function nt(e, t, n, r, i) {
3109
+ e.onAsrStopped = nt;
3110
+ function rt(e, t, n, r, i) {
3094
3111
  F("onAsrTranscription", e, t, n, r, i);
3095
3112
  }
3096
- e.onAsrTranscription = nt;
3097
- function rt(e, t, n) {
3113
+ e.onAsrTranscription = rt;
3114
+ function it(e, t, n) {
3098
3115
  F("onParticipantIdChanged", e, t, n);
3099
3116
  }
3100
- e.onParticipantIdChanged = rt;
3101
- function it(e, t) {
3117
+ e.onParticipantIdChanged = it;
3118
+ function w(e, t) {
3102
3119
  F("onVideoSuspendSuggest", e, t);
3103
3120
  }
3104
- e.onVideoSuspendSuggest = it;
3105
- function w(e) {
3121
+ e.onVideoSuspendSuggest = w;
3122
+ function at(e) {
3106
3123
  F("onSignalingMessage", typeof e == "string" ? e : L(e));
3107
3124
  }
3108
- e.onSignalingMessage = w;
3109
- function at(e, t) {
3125
+ e.onSignalingMessage = at;
3126
+ function ot(e, t) {
3110
3127
  F("onPromotionApproved", e, t);
3111
3128
  }
3112
- e.onPromotionApproved = at;
3113
- function ot(e, t) {
3129
+ e.onPromotionApproved = ot;
3130
+ function st(e, t) {
3114
3131
  F("onPeerRegistered", e, t);
3115
3132
  }
3116
- e.onPeerRegistered = ot;
3117
- function st(e, t) {
3133
+ e.onPeerRegistered = st;
3134
+ function ct(e, t) {
3118
3135
  F("onNonFatalError", e, t);
3119
3136
  }
3120
- e.onNonFatalError = st;
3137
+ e.onNonFatalError = ct;
3121
3138
  })(Cn || (Cn = {}));
3122
3139
  var R = Cn, wn = /* @__PURE__ */ function(e) {
3123
3140
  return e.DEBUG = "DEBUG", e.LOG = "LOG", e.WARN = "WARN", e.ERROR = "ERROR", e;
@@ -3634,7 +3651,7 @@ var Bn = 0, Vn = 1, Hn = 2, Un = 3, Wn = 4, Gn = 5, Kn = 6, qn = 7, Jn = 0, Yn =
3634
3651
  };
3635
3652
  }
3636
3653
  }, U = /* @__PURE__ */ function(e) {
3637
- 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.API_CALL = "api_call", e.SDP_CREATE_OFFER = "sdp_create_offer", e.SDP_CREATE_ANSWER = "sdp_create_answer", e.SDP_SET_LOCAL_OFFER = "sdp_set_local_offer", e.SDP_SET_LOCAL_PRANSWER = "sdp_set_local_pranswer", e.SDP_SET_LOCAL_ANSWER = "sdp_set_local_answer", e.SDP_SET_LOCAL_ROLLBACK = "sdp_set_local_rollback", e.SDP_SET_REMOTE_OFFER = "sdp_set_remote_offer", e.SDP_SET_REMOTE_PRANSWER = "sdp_set_remote_pranswer", e.SDP_SET_REMOTE_ANSWER = "sdp_set_remote_answer", e.SDP_SET_REMOTE_ROLLBACK = "sdp_set_remote_rollback", e.SDP_GENERATED = "sdp_generated", e.SDP_RECEIVED = "sdp_received", 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;
3654
+ 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.API_CALL = "api_call", e.CONNECTION_STATE_CHANGED = "connection_state_changed", e.SIGNALING_STATE_CHANGED = "signaling_state_changed", e.GATHERING_STATE_CHANGED = "gathering_state_changed", e.ICE_RESTART = "ice_restart", e.ICE_CANDIDATES_CHANGED = "ice_candidates_changed", e.ICE_CANDIDATE_GATHERING_FAILED = "ice_candidate_gathering_failed", e.ICE_CANDIDATE_ADD_FAILED = "ice_candidate_add_failed", e.SDP_CREATE_OFFER = "sdp_create_offer", e.SDP_CREATE_ANSWER = "sdp_create_answer", e.SDP_SET_LOCAL_OFFER = "sdp_set_local_offer", e.SDP_SET_LOCAL_PRANSWER = "sdp_set_local_pranswer", e.SDP_SET_LOCAL_ANSWER = "sdp_set_local_answer", e.SDP_SET_LOCAL_ROLLBACK = "sdp_set_local_rollback", e.SDP_SET_REMOTE_OFFER = "sdp_set_remote_offer", e.SDP_SET_REMOTE_PRANSWER = "sdp_set_remote_pranswer", e.SDP_SET_REMOTE_ANSWER = "sdp_set_remote_answer", e.SDP_SET_REMOTE_ROLLBACK = "sdp_set_remote_rollback", e.SDP_GENERATED = "sdp_generated", e.SDP_RECEIVED = "sdp_received", 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;
3638
3655
  }(U || {}), nr = 1e3;
3639
3656
  function W(e, t, n = 0) {
3640
3657
  return t in e && e[t] ? e[t] : n;
@@ -3886,7 +3903,7 @@ var Nr = {
3886
3903
  pranswer: U.SDP_SET_REMOTE_PRANSWER,
3887
3904
  answer: U.SDP_SET_REMOTE_ANSWER,
3888
3905
  rollback: U.SDP_SET_REMOTE_ROLLBACK
3889
- }, Ir = 300 * 1e3, Lr = {
3906
+ }, Ir = 120 * 1e3, Lr = {
3890
3907
  local_address: null,
3891
3908
  remote_address: null,
3892
3909
  transport: null
@@ -3997,14 +4014,82 @@ function Ur(e) {
3997
4014
  return Vr.test(e) || e.includes(":") && Hr.test(e);
3998
4015
  }
3999
4016
  //#endregion
4000
- //#region src/classes/stat/FirstMediaSentProbe.ts
4001
- var Wr = 200;
4002
- function Gr(e) {
4017
+ //#region src/classes/stat/PeerConnectionStats.ts
4018
+ var Wr = /[?&]transport=(tcp|udp)/i, Gr = {
4019
+ stable: "stable",
4020
+ "have-local-offer": "have.local.offer",
4021
+ "have-local-pranswer": "have.local.answer",
4022
+ "have-remote-offer": "have.remote.offer",
4023
+ "have-remote-pranswer": "have.remote.answer",
4024
+ closed: "closed"
4025
+ }, Kr = class {
4026
+ constructor(e) {
4027
+ h(this, "_statAggregator", void 0), h(this, "_pc", null), h(this, "_lastSignalingStateChange", 0), h(this, "_lastGatheringStateChange", 0), h(this, "_lastConnectionState", null), h(this, "_handleConnectionStateChange", () => {
4028
+ this._pc && this._logConnectionState(this._pc.connectionState);
4029
+ }), h(this, "_handleSignalingStateChange", () => {
4030
+ let e = this._pc?.signalingState;
4031
+ this._log({
4032
+ name: U.SIGNALING_STATE_CHANGED,
4033
+ value: this._sinceLastChange("_lastSignalingStateChange"),
4034
+ string_value: e ? Gr[e] : void 0
4035
+ });
4036
+ }), h(this, "_handleGatheringStateChange", () => {
4037
+ let e = this._pc?.iceGatheringState, t = this._sinceLastChange("_lastGatheringStateChange");
4038
+ this._log({
4039
+ name: U.GATHERING_STATE_CHANGED,
4040
+ value: e === "new" ? 0 : t,
4041
+ string_value: e
4042
+ });
4043
+ }), h(this, "_handleIceCandidateError", (e) => {
4044
+ if (!N.iceCandidateErrorStatEnabled) return;
4045
+ let t = e;
4046
+ this._log({
4047
+ name: U.ICE_CANDIDATE_GATHERING_FAILED,
4048
+ value: t.errorCode,
4049
+ string_value: t.errorText,
4050
+ local_address: t.address ?? "",
4051
+ remote_url: t.url,
4052
+ transport: Wr.exec(t.url ?? "")?.[1]?.toLowerCase() ?? null
4053
+ });
4054
+ }), this._statAggregator = e;
4055
+ }
4056
+ observe(e) {
4057
+ this.stop(), this._pc = e, this._lastSignalingStateChange = 0, this._lastGatheringStateChange = 0, this._lastConnectionState = null, e.addEventListener("connectionstatechange", this._handleConnectionStateChange), e.addEventListener("signalingstatechange", this._handleSignalingStateChange), e.addEventListener("icegatheringstatechange", this._handleGatheringStateChange), e.addEventListener("icecandidateerror", this._handleIceCandidateError);
4058
+ }
4059
+ stop() {
4060
+ this._pc && (this._pc.connectionState !== "new" && this._logConnectionState(this._pc.connectionState), this._logConnectionState("closed"), this._pc.removeEventListener("connectionstatechange", this._handleConnectionStateChange), this._pc.removeEventListener("signalingstatechange", this._handleSignalingStateChange), this._pc.removeEventListener("icegatheringstatechange", this._handleGatheringStateChange), this._pc.removeEventListener("icecandidateerror", this._handleIceCandidateError), this._pc = null);
4061
+ }
4062
+ logIceRestart() {
4063
+ this._log({ name: U.ICE_RESTART });
4064
+ }
4065
+ logIceCandidateAddFailed(e, t) {
4066
+ this._log({
4067
+ name: U.ICE_CANDIDATE_ADD_FAILED,
4068
+ value: t instanceof DOMException ? t.code : 0,
4069
+ string_value: t instanceof Error ? `${t.name}: ${t.message}` : String(t),
4070
+ remote_url: e.candidate
4071
+ });
4072
+ }
4073
+ _sinceLastChange(e) {
4074
+ let t = Date.now(), n = this[e] === 0 ? 0 : t - this[e];
4075
+ return this[e] = t, n;
4076
+ }
4077
+ _logConnectionState(e) {
4078
+ e !== this._lastConnectionState && (this._lastConnectionState = e, this._log({
4079
+ name: U.CONNECTION_STATE_CHANGED,
4080
+ connection_state: e
4081
+ }));
4082
+ }
4083
+ _log(e) {
4084
+ this._statAggregator?.logEventualStat(e);
4085
+ }
4086
+ }, qr = 200;
4087
+ function Jr(e) {
4003
4088
  for (let t of e.values()) if (t.type === "outbound-rtp" && (t.packetsSent ?? 0) > 0) return !0;
4004
4089
  return !1;
4005
4090
  }
4006
- var Kr = class {
4007
- constructor(e, t, n = Wr) {
4091
+ var Yr = class {
4092
+ constructor(e, t, n = qr) {
4008
4093
  h(this, "_peerConnection", void 0), h(this, "_onFirstMediaSent", void 0), h(this, "_pollIntervalMs", void 0), h(this, "_timer", null), h(this, "_state", "idle"), this._peerConnection = e, this._onFirstMediaSent = t, this._pollIntervalMs = n;
4009
4094
  }
4010
4095
  start() {
@@ -4027,7 +4112,7 @@ var Kr = class {
4027
4112
  try {
4028
4113
  let e = await this._getStatsReports();
4029
4114
  if (this._state !== "polling") return;
4030
- if (e.some(Gr)) {
4115
+ if (e.some(Jr)) {
4031
4116
  this._state = "stopped", this._onFirstMediaSent();
4032
4117
  return;
4033
4118
  }
@@ -4040,7 +4125,7 @@ var Kr = class {
4040
4125
  this._timer = null, this._poll();
4041
4126
  }, this._pollIntervalMs));
4042
4127
  }
4043
- }, qr = class extends b {
4128
+ }, Xr = class extends b {
4044
4129
  constructor(e, t, n = null) {
4045
4130
  super(), h(this, "_signaling", void 0), h(this, "_mediaSource", void 0), h(this, "_state", q.IDLE), h(this, "_pc", null), h(this, "_onFirstMediaSent", void 0), h(this, "_firstMediaSentProbe", null), h(this, "_firstMediaSentProbeStopped", !1), this._signaling = e, this._mediaSource = t, this._onFirstMediaSent = n;
4046
4131
  }
@@ -4051,12 +4136,12 @@ var Kr = class {
4051
4136
  this._firstMediaSentProbeStopped = !0, this._disposeFirstMediaSentProbe();
4052
4137
  }
4053
4138
  _startFirstMediaSentProbe() {
4054
- this._disposeFirstMediaSentProbe(), !(!this._pc || !this._onFirstMediaSent || this._firstMediaSentProbeStopped) && (this._firstMediaSentProbe = new Kr(this._pc, this._onFirstMediaSent), this._firstMediaSentProbe.start());
4139
+ this._disposeFirstMediaSentProbe(), !(!this._pc || !this._onFirstMediaSent || this._firstMediaSentProbeStopped) && (this._firstMediaSentProbe = new Yr(this._pc, this._onFirstMediaSent), this._firstMediaSentProbe.start());
4055
4140
  }
4056
4141
  _disposeFirstMediaSentProbe() {
4057
4142
  this._firstMediaSentProbe?.destroy(), this._firstMediaSentProbe = null;
4058
4143
  }
4059
- }, Jr = class {
4144
+ }, Zr = class {
4060
4145
  constructor(e, t = null) {
4061
4146
  h(this, "weightUp", void 0), h(this, "weightDown", void 0), h(this, "value", NaN), this.weightUp = e, this.weightDown = t ?? e;
4062
4147
  }
@@ -4074,7 +4159,7 @@ var Kr = class {
4074
4159
  getValue() {
4075
4160
  return this.value;
4076
4161
  }
4077
- }, Yr = .25, Xr = .35, Zr = 85, Qr = .1, $r = 1.5, ei = .1, ti = 1, ni = .6, ri = .3, ii = class extends b {
4162
+ }, Qr = .25, $r = .35, ei = 85, ti = .1, ni = 1.5, ri = .1, ii = 1, ai = .6, oi = .3, si = class extends b {
4078
4163
  constructor(e, t = z) {
4079
4164
  super(), h(this, "_signaling", void 0), h(this, "_localNetworkStat", void 0), h(this, "_remoteNetworkStat", void 0), h(this, "_lastNetworkStat", void 0), h(this, "_networkLimits", {
4080
4165
  badNet: {
@@ -4086,8 +4171,8 @@ var Kr = class {
4086
4171
  rtt: 600
4087
4172
  }
4088
4173
  }), h(this, "_lastStatSentTimestamp", 0), h(this, "_currentState", "good"), h(this, "_debug", void 0), this._debug = t, this._signaling = e, this._localNetworkStat = {
4089
- rtt: new Jr(Yr, Yr),
4090
- loss: new Jr(Xr, Xr),
4174
+ rtt: new Zr(Qr, Qr),
4175
+ loss: new Zr($r, $r),
4091
4176
  bitrate: 0
4092
4177
  }, this._remoteNetworkStat = {
4093
4178
  rtt: 0,
@@ -4102,20 +4187,20 @@ var Kr = class {
4102
4187
  _calcRttRating(e) {
4103
4188
  let t = typeof e == "number" ? e : e.getValue(), n = 1;
4104
4189
  if (isNaN(t)) return n;
4105
- let r = Math.round((t - this._networkLimits.goodNet.rtt) / Zr);
4106
- for (let e = 0; e < r; e++) n *= 1 - Qr;
4190
+ let r = Math.round((t - this._networkLimits.goodNet.rtt) / ei);
4191
+ for (let e = 0; e < r; e++) n *= 1 - ti;
4107
4192
  return n;
4108
4193
  }
4109
4194
  _calcLossRating(e) {
4110
4195
  let t = typeof e == "number" ? e : e.getValue(), n = 1;
4111
4196
  if (isNaN(t)) return n;
4112
- let r = Math.round((t - this._networkLimits.goodNet.loss) / $r);
4113
- for (let e = 0; e < r; e++) n *= 1 - ei;
4197
+ let r = Math.round((t - this._networkLimits.goodNet.loss) / ni);
4198
+ for (let e = 0; e < r; e++) n *= 1 - ri;
4114
4199
  return n;
4115
4200
  }
4116
4201
  _calcBitrateRating(e, t) {
4117
4202
  if (!e || !t) return 1;
4118
- let n = 1 - (1 - Math.min(e, t) / Math.max(e, t)) * ti;
4203
+ let n = 1 - (1 - Math.min(e, t) / Math.max(e, t)) * ii;
4119
4204
  return Math.min(n, 1);
4120
4205
  }
4121
4206
  _calcUDPRating({ rtt: e, loss: t }) {
@@ -4125,7 +4210,7 @@ var Kr = class {
4125
4210
  return n ? this._calcBitrateRating(e.bitrate, t.bitrate) : this._calcUDPRating(e) * this._calcUDPRating(t);
4126
4211
  }
4127
4212
  _getNetworkState(e) {
4128
- return isNaN(e) || e >= ni ? "good" : e >= ri ? "medium" : "bad";
4213
+ return isNaN(e) || e >= ai ? "good" : e >= oi ? "medium" : "bad";
4129
4214
  }
4130
4215
  updateSettings(e) {
4131
4216
  Object.assign(this._networkLimits.badNet, e?.badNet || {}), Object.assign(this._networkLimits.goodNet, e?.goodNet || {});
@@ -4149,7 +4234,7 @@ var Kr = class {
4149
4234
  let { rtt: t, loss: n, bitrate: r } = e || {};
4150
4235
  this._remoteNetworkStat.rtt = t || 0, this._remoteNetworkStat.loss = n || 0, this._remoteNetworkStat.bitrate = r || 0;
4151
4236
  }
4152
- }, ai = 30 * 1e3, oi = class e extends qr {
4237
+ }, ci = 30 * 1e3, li = class e extends Xr {
4153
4238
  constructor(e, t, n, r, i, a = z, o = null, s = null, c = null, l = null) {
4154
4239
  super(n, r, l), h(this, "_participantId", void 0), h(this, "_isMaster", void 0), h(this, "_remoteSDP", {}), h(this, "_remoteCandidates", {}), h(this, "_lastRemoteSDP", null), h(this, "_animojiDataChannel", null), h(this, "_animojiReceiver", null), h(this, "_animojiSender", null), h(this, "_remoteAnimojiVersion", 1), h(this, "_isOpen", !1), h(this, "_remotePeerId", null), h(this, "_statInterval", null), h(this, "_settingsInterval", null), h(this, "_failedOnCreate", null), h(this, "_remoteStream", null), h(this, "_iceRestartTimeout", null), h(this, "_reconnectionTimeout", null), h(this, "_reconnectionPrevented", !1), h(this, "_remoteHold", !1), h(this, "_lastStat", null), h(this, "_fingerprint", null), h(this, "_neverConnected", !0), h(this, "_serverSettings", void 0), h(this, "_prevConsumerSettings", {}), h(this, "_networkLimitsForVideo", {
4155
4240
  bad: {
@@ -4164,7 +4249,7 @@ var Kr = class {
4164
4249
  worst: 320,
4165
4250
  bad: 640,
4166
4251
  good: 1280
4167
- }), h(this, "_lastVideoMaxDimension", this._videoMaxDimensionsForNet.good), h(this, "_lastBadConnection", 0), h(this, "_perfStatReporter", void 0), h(this, "_directStatReporter", void 0), h(this, "_sdpStats", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_codecStatsAggregator", void 0), this._participantId = e, this._isMaster = t, this._serverSettings = i, this._debug = a, this._logger = o, this._statAggregator = s, this._codecStatsAggregator = c, this._perfStatReporter = new ka(this, n, this._statAggregator, !0, this._debug), this._directStatReporter = new ii(n, this._debug), this._sdpStats = new Rr(this._statAggregator), this.subscribe(this._signaling, xr.NOTIFICATION, this._onSignalingNotification.bind(this)), this.subscribe(this._mediaSource, qt.TRACK_REPLACED, this._onReplacedTrack.bind(this)), this.subscribe(this._mediaSource, qt.SOURCE_CHANGED, this._applySettings.bind(this)), this.subscribe(this._directStatReporter, Y.NETWORK_STATUS, this._onNetworkStatus.bind(this));
4252
+ }), h(this, "_lastVideoMaxDimension", this._videoMaxDimensionsForNet.good), h(this, "_lastBadConnection", 0), h(this, "_perfStatReporter", void 0), h(this, "_directStatReporter", void 0), h(this, "_sdpStats", void 0), h(this, "_peerConnectionStats", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_codecStatsAggregator", void 0), this._participantId = e, this._isMaster = t, this._serverSettings = i, this._debug = a, this._logger = o, this._statAggregator = s, this._codecStatsAggregator = c, this._perfStatReporter = new Ma(this, n, this._statAggregator, !0, this._debug), this._directStatReporter = new si(n, this._debug), this._sdpStats = new Rr(this._statAggregator), this._peerConnectionStats = new Kr(this._statAggregator), this.subscribe(this._signaling, xr.NOTIFICATION, this._onSignalingNotification.bind(this)), this.subscribe(this._mediaSource, qt.TRACK_REPLACED, this._onReplacedTrack.bind(this)), this.subscribe(this._mediaSource, qt.SOURCE_CHANGED, this._applySettings.bind(this)), this.subscribe(this._directStatReporter, Y.NETWORK_STATUS, this._onNetworkStatus.bind(this));
4168
4253
  try {
4169
4254
  this._pc = this._createPeerConnection();
4170
4255
  } catch (e) {
@@ -4268,12 +4353,12 @@ var Kr = class {
4268
4353
  iceServers: N.iceServers,
4269
4354
  iceTransportPolicy: N.forceRelayPolicy ? "relay" : "all"
4270
4355
  });
4271
- return e.onicecandidate = this._handleIceCandidate.bind(this), e.ontrack = this._onAddTrack.bind(this), e.oniceconnectionstatechange = this._onIceConnectionStateChange.bind(this), e.onconnectionstatechange = this._onConnectionStateChange.bind(this), e.onsignalingstatechange = this._onSignalingStateChange.bind(this), this._sdpStats.observe(e), this._prevConsumerSettings = {}, N.vmoji && this._createDataChannel(e, Tr.animoji, (e) => {
4356
+ return e.onicecandidate = this._handleIceCandidate.bind(this), e.ontrack = this._onAddTrack.bind(this), e.oniceconnectionstatechange = this._onIceConnectionStateChange.bind(this), e.onconnectionstatechange = this._onConnectionStateChange.bind(this), e.onsignalingstatechange = this._onSignalingStateChange.bind(this), this._sdpStats.observe(e), this._peerConnectionStats.observe(e), this._prevConsumerSettings = {}, N.vmoji && this._createDataChannel(e, Tr.animoji, (e) => {
4272
4357
  this._animojiDataChannel = e, this._animojiDataChannel.binaryType = "arraybuffer", this._animojiReceiver?.setDataChannel(this._animojiDataChannel), this._animojiSender?.setDataChannel(this._animojiDataChannel);
4273
4358
  }), e;
4274
4359
  }
4275
4360
  _disposePeerConnection() {
4276
- if (this._disposeFirstMediaSentProbe(), this._sdpStats.stop(), this._lastStat = null, this._remoteStream) {
4361
+ if (this._disposeFirstMediaSentProbe(), this._sdpStats.stop(), this._peerConnectionStats.stop(), this._lastStat = null, this._remoteStream) {
4277
4362
  let e = this._remoteStream;
4278
4363
  e.getTracks().forEach((t) => {
4279
4364
  t.stop(), this._triggerEvent(Y.REMOTE_TRACK_REMOVED, e, t);
@@ -4322,7 +4407,7 @@ var Kr = class {
4322
4407
  try {
4323
4408
  await this._pc.addIceCandidate(new RTCIceCandidate(t));
4324
4409
  } catch (e) {
4325
- throw this._logger?.log(C.ERROR, "addIceCandidate-direct"), this._debug.error("Unable to add remote ice candidate", e, {
4410
+ throw this._logger?.log(C.ERROR, "addIceCandidate-direct"), this._peerConnectionStats.logIceCandidateAddFailed(t, e), this._debug.error("Unable to add remote ice candidate", e, {
4326
4411
  participantId: this._participantId,
4327
4412
  candidate: t
4328
4413
  }), e;
@@ -4441,7 +4526,7 @@ var Kr = class {
4441
4526
  this._reconnectionTimeout && (clearTimeout(this._reconnectionTimeout), this._reconnectionTimeout = null), this._iceRestartTimeout && (clearTimeout(this._iceRestartTimeout), this._iceRestartTimeout = null);
4442
4527
  }
4443
4528
  _startIceRestart() {
4444
- this._isMaster ? (this._logger?.log(C.ICE_RESTART), this._debug.log("Ice restart", { participantId: this._participantId }), this._createOffer(!0).catch(this.close.bind(this))) : this._debug.debug("Waiting for ice restart...", { participantId: this._participantId }), this._iceRestartTimeout = window.setTimeout(() => {
4529
+ this._isMaster ? (this._peerConnectionStats.logIceRestart(), this._logger?.log(C.ICE_RESTART), this._debug.log("Ice restart", { participantId: this._participantId }), this._createOffer(!0).catch(this.close.bind(this))) : this._debug.debug("Waiting for ice restart...", { participantId: this._participantId }), this._iceRestartTimeout = window.setTimeout(() => {
4445
4530
  this._iceRestartTimeout = null, this._debug.error("Ice restart failed", { participantId: this._participantId }), this._logger?.log(C.ERROR, "iceRestart-direct"), this._requestTopologySwitch(N.switchTopologyOnReconnectFromAnySide);
4446
4531
  }, N.iceRestartWaitTime);
4447
4532
  }
@@ -4563,7 +4648,7 @@ var Kr = class {
4563
4648
  async _checkPPTNetwork(e) {
4564
4649
  if (!N.switchVideoAtBadNetwork || !e.inbound.transport.averageNetStat) return;
4565
4650
  let { averageNetStat: t } = e.inbound.transport, n = t.currentRoundTripTime <= this._networkLimitsForVideo.good.rtt && t.lostPercent <= this._networkLimitsForVideo.good.loss, r = t.currentRoundTripTime >= this._networkLimitsForVideo.bad.rtt || t.lostPercent >= this._networkLimitsForVideo.bad.loss, i = t.currentRoundTripTime < this._networkLimitsForVideo.bad.rtt, a = this._videoMaxDimensionsForNet.good, o = kr.L1T1;
4566
- if (r ? (this._lastBadConnection = Date.now(), i ? (a = this._videoMaxDimensionsForNet.bad, o = kr.L1T2) : (a = this._videoMaxDimensionsForNet.worst, o = kr.L1T3)) : n && (a = this._videoMaxDimensionsForNet.good, o = kr.L1T1), !(a < this._lastVideoMaxDimension || Date.now() - this._lastBadConnection > ai) || this._lastVideoMaxDimension === a) return;
4651
+ if (r ? (this._lastBadConnection = Date.now(), i ? (a = this._videoMaxDimensionsForNet.bad, o = kr.L1T2) : (a = this._videoMaxDimensionsForNet.worst, o = kr.L1T3)) : n && (a = this._videoMaxDimensionsForNet.good, o = kr.L1T1), !(a < this._lastVideoMaxDimension || Date.now() - this._lastBadConnection > ci) || this._lastVideoMaxDimension === a) return;
4567
4652
  let s = this._serverSettings.camera;
4568
4653
  if (!s || !await this._isSVCSupported(e, o)) return;
4569
4654
  this._debug.debug("Switch outbound video frame size and scalabilityMode", {
@@ -4628,9 +4713,9 @@ var Kr = class {
4628
4713
  }, n(r)) : this._debug.error(`[${t}] data channel open failed, state [${e}]`);
4629
4714
  };
4630
4715
  }
4631
- }, si = /* @__PURE__ */ function(e) {
4716
+ }, ui = /* @__PURE__ */ function(e) {
4632
4717
  return e.AUDIO_MIX = "audio-mix", e.PARTICIPANT_AGNOSTIC_TRACK_PREFIX = "pat", e.TRANSPARENT_AUDIO_TRACK_PREFIX = "ta", e;
4633
- }({}), ci = 16, li = class e {
4718
+ }({}), di = 16, fi = class e {
4634
4719
  constructor(e, t, n, r = z) {
4635
4720
  h(this, "_datachannel", void 0), h(this, "_participantIdRegistry", void 0), h(this, "_asrCallback", void 0), h(this, "_textDecoder", void 0), h(this, "_debug", void 0), this._debug = r, this._debug.debug("AsrReceiver started"), this._datachannel = e, this._participantIdRegistry = t, this._asrCallback = n, this._textDecoder = new TextDecoder(), this._datachannel.onmessage = (e) => this._onDataChannelMessage(e.data);
4636
4721
  }
@@ -4644,7 +4729,7 @@ var Kr = class {
4644
4729
  ssrc: a,
4645
4730
  timestamp: o,
4646
4731
  duration: s,
4647
- data: e.slice(ci)
4732
+ data: e.slice(di)
4648
4733
  };
4649
4734
  }
4650
4735
  _onDataChannelMessage(t) {
@@ -4664,7 +4749,7 @@ var Kr = class {
4664
4749
  destroy() {
4665
4750
  this._datachannel.onmessage = null;
4666
4751
  }
4667
- }, ui, di = class {
4752
+ }, pi, mi = class {
4668
4753
  constructor() {
4669
4754
  h(this, "_value", 1);
4670
4755
  }
@@ -4675,10 +4760,10 @@ var Kr = class {
4675
4760
  this._value = e;
4676
4761
  }
4677
4762
  };
4678
- ui = di, h(di, "_instance", null), h(di, "getInstance", () => (ui._instance || (ui._instance = new ui()), ui._instance));
4763
+ pi = mi, h(mi, "_instance", null), h(mi, "getInstance", () => (pi._instance || (pi._instance = new pi()), pi._instance));
4679
4764
  //#endregion
4680
4765
  //#region src/classes/ParticipantIdRegistry.ts
4681
- var fi = class {
4766
+ var hi = class {
4682
4767
  constructor(e = z) {
4683
4768
  h(this, "streamDescriptionByCompactId", /* @__PURE__ */ new Map()), h(this, "compactIdByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_debug", void 0), this._debug = e;
4684
4769
  }
@@ -4794,7 +4879,7 @@ var fi = class {
4794
4879
  this._debug.error("unexpected null sequenceNumber", e, r);
4795
4880
  continue;
4796
4881
  }
4797
- let l = si.PARTICIPANT_AGNOSTIC_TRACK_PREFIX + "-" + e, u = i ? i >>> 0 : null;
4882
+ let l = ui.PARTICIPANT_AGNOSTIC_TRACK_PREFIX + "-" + e, u = i ? i >>> 0 : null;
4798
4883
  n.push({
4799
4884
  participantStreamDescription: c,
4800
4885
  streamId: l,
@@ -4810,9 +4895,9 @@ var fi = class {
4810
4895
  participantUpdateInfos: n
4811
4896
  };
4812
4897
  }
4813
- }, pi = /* @__PURE__ */ function(e) {
4898
+ }, gi = /* @__PURE__ */ function(e) {
4814
4899
  return e.INIT = "init", e.READY = "ready", e.FRAME = "frame", e.SET_BITRATE = "set_bitrate", e.ERROR = "error", e.DEBUG = "debug", e.LOG_ERROR = "log_error", e;
4815
- }({}), mi = class {
4900
+ }({}), _i = class {
4816
4901
  constructor(e = z, t = null) {
4817
4902
  h(this, "_worker", null), h(this, "_debug", void 0), h(this, "_logger", void 0), this._debug = e, this._logger = t;
4818
4903
  }
@@ -4828,7 +4913,7 @@ var fi = class {
4828
4913
  return;
4829
4914
  }
4830
4915
  t({
4831
- type: pi.FRAME,
4916
+ type: gi.FRAME,
4832
4917
  error: e
4833
4918
  });
4834
4919
  };
@@ -4838,23 +4923,23 @@ var fi = class {
4838
4923
  e.preventDefault?.(), m(this._formatWorkerMessageError(e));
4839
4924
  }, f.onmessage = (e) => {
4840
4925
  switch (e.data.type) {
4841
- case pi.READY:
4926
+ case gi.READY:
4842
4927
  s = !0, c || (c = !0, a());
4843
4928
  break;
4844
- case pi.ERROR:
4929
+ case gi.ERROR:
4845
4930
  s ? m(e.data.error) : p(e.data.error);
4846
4931
  break;
4847
- case pi.FRAME:
4932
+ case gi.FRAME:
4848
4933
  t(e.data);
4849
4934
  break;
4850
- case pi.DEBUG:
4935
+ case gi.DEBUG:
4851
4936
  this._debug.debug(e.data.message);
4852
4937
  break;
4853
- case pi.LOG_ERROR:
4938
+ case gi.LOG_ERROR:
4854
4939
  this._logger?.log(C.ERROR, e.data.message);
4855
4940
  break;
4856
4941
  }
4857
- }, this._sendToWorker(pi.INIT, r, i);
4942
+ }, this._sendToWorker(gi.INIT, r, i);
4858
4943
  });
4859
4944
  }
4860
4945
  _removeWorker() {
@@ -4877,7 +4962,7 @@ var fi = class {
4877
4962
  static isBrowserSupported() {
4878
4963
  throw Error("Not implemented");
4879
4964
  }
4880
- }, hi = class extends mi {
4965
+ }, vi = class extends _i {
4881
4966
  constructor(e = z, t = null) {
4882
4967
  super(e, t);
4883
4968
  }
@@ -4887,7 +4972,7 @@ var fi = class {
4887
4972
  }, [c, c.getUrl]);
4888
4973
  }
4889
4974
  decodeFrame(e, t, n, r) {
4890
- this._sendToWorker(pi.FRAME, {
4975
+ this._sendToWorker(gi.FRAME, {
4891
4976
  timestamp: e,
4892
4977
  data: t.buffer,
4893
4978
  isVP9: n,
@@ -4901,7 +4986,7 @@ var fi = class {
4901
4986
  static isBrowserSupported() {
4902
4987
  return "WebAssembly" in window && "Worker" in window;
4903
4988
  }
4904
- }, gi = class extends mi {
4989
+ }, yi = class extends _i {
4905
4990
  constructor(e = z, t = null) {
4906
4991
  super(e, t);
4907
4992
  }
@@ -4911,7 +4996,7 @@ var fi = class {
4911
4996
  }, [!0]);
4912
4997
  }
4913
4998
  decodeFrame(e, t, n, r = !1) {
4914
- this._sendToWorker(pi.FRAME, {
4999
+ this._sendToWorker(gi.FRAME, {
4915
5000
  timestamp: e,
4916
5001
  data: t.buffer,
4917
5002
  isVP9: n,
@@ -4924,7 +5009,7 @@ var fi = class {
4924
5009
  static isBrowserSupported() {
4925
5010
  return "VideoDecoder" in window && "Worker" in window && "VideoFrame" in window && !E.isBrokenVP9Decoder() && E.browserName() !== "Firefox";
4926
5011
  }
4927
- }, _i = class {
5012
+ }, bi = class {
4928
5013
  constructor(e = null, t = 0) {
4929
5014
  h(this, "_counter", 0), h(this, "_interval", 0), h(this, "_lastCalculationTime", Date.now()), h(this, "_onCalculated", null), this._onCalculated = e, t && (this._interval = window.setInterval(() => this.calculate(), t));
4930
5015
  }
@@ -4938,7 +5023,7 @@ var fi = class {
4938
5023
  destroy() {
4939
5024
  window.clearInterval(this._interval), this._interval = 0;
4940
5025
  }
4941
- }, vi = class {
5026
+ }, xi = class {
4942
5027
  constructor(e, t) {
4943
5028
  h(this, "_participantId", void 0), h(this, "_statAggregator", void 0), h(this, "_firstFrameReceived", !1), this._participantId = e, this._statAggregator = t;
4944
5029
  }
@@ -4953,14 +5038,14 @@ var fi = class {
4953
5038
  height: t
4954
5039
  });
4955
5040
  }
4956
- }, yi = 65536, bi = "MARK_SCREENSHARE_FREEZE_DURATION", xi = class e {
5041
+ }, Si = 65536, Ci = "MARK_SCREENSHARE_FREEZE_DURATION", wi = class e {
4957
5042
  constructor(e, t, n, r, i, a = z) {
4958
- h(this, "_participantId", void 0), h(this, "_onStream", void 0), h(this, "_onStat", void 0), h(this, "_onKeyFrameRequested", void 0), h(this, "_statScreenShareFirstFrame", void 0), h(this, "_debug", void 0), h(this, "_chunks", []), this._participantId = e, this._onStream = t, this._onStat = n, this._onKeyFrameRequested = i, this._statScreenShareFirstFrame = new vi(e, r), this._debug = a;
5043
+ h(this, "_participantId", void 0), h(this, "_onStream", void 0), h(this, "_onStat", void 0), h(this, "_onKeyFrameRequested", void 0), h(this, "_statScreenShareFirstFrame", void 0), h(this, "_debug", void 0), h(this, "_chunks", []), this._participantId = e, this._onStream = t, this._onStat = n, this._onKeyFrameRequested = i, this._statScreenShareFirstFrame = new xi(e, r), this._debug = a;
4959
5044
  }
4960
5045
  appendChunk(t) {
4961
5046
  let n = this._chunks.length;
4962
5047
  if (t.start) this._measureFreezeDuration(!1), this._measureFreezeDuration(!0), n && (this._debug.warn("[FrameBuilder] Cleanup buffer", Array.prototype.slice.call(this._chunks)), this._chunks = []);
4963
- else if (!n || (this._chunks[n - 1].sequence + 1) % yi !== t.sequence) {
5048
+ else if (!n || (this._chunks[n - 1].sequence + 1) % Si !== t.sequence) {
4964
5049
  this._debug.warn("[FrameBuilder] Got incorrect chunk");
4965
5050
  return;
4966
5051
  }
@@ -4977,7 +5062,7 @@ var fi = class {
4977
5062
  }
4978
5063
  }
4979
5064
  destroy() {
4980
- G.clearMark(bi), G.clearMark(G.getMarkNameScreenshareFirstFrame(this._participantId)), this._chunks = [];
5065
+ G.clearMark(Ci), G.clearMark(G.getMarkNameScreenshareFirstFrame(this._participantId)), this._chunks = [];
4981
5066
  }
4982
5067
  _processFrameData() {
4983
5068
  let e = this._chunks;
@@ -5000,13 +5085,13 @@ var fi = class {
5000
5085
  }
5001
5086
  _measureFreezeDuration(e) {
5002
5087
  if (e) {
5003
- G.setMark(bi);
5088
+ G.setMark(Ci);
5004
5089
  return;
5005
5090
  }
5006
- let t = G.measureMark(bi);
5091
+ let t = G.measureMark(Ci);
5007
5092
  t !== null && t > 1e3 && this._onStat({ freeze_duration: t });
5008
5093
  }
5009
- }, Si = class {
5094
+ }, Ti = class {
5010
5095
  constructor(e) {
5011
5096
  h(this, "_onStream", void 0), this._onStream = e;
5012
5097
  }
@@ -5019,7 +5104,7 @@ var fi = class {
5019
5104
  static isBrowserSupported() {
5020
5105
  throw Error("Method `isBrowserSupported` is not implemented");
5021
5106
  }
5022
- }, Ci = class extends Si {
5107
+ }, Ei = class extends Ti {
5023
5108
  constructor(e, t = z) {
5024
5109
  super(e), h(this, "_useImageBitmap", void 0), h(this, "_canvas", null), h(this, "_canvasContext", null), h(this, "_stream", null), h(this, "_track", null), h(this, "_debug", void 0), this._debug = t, this._debug.debug("CanvasRenderer started"), this._useImageBitmap = "ImageBitmap" in window;
5025
5110
  }
@@ -5079,7 +5164,7 @@ var fi = class {
5079
5164
  static isBrowserSupported() {
5080
5165
  return ("CanvasCaptureMediaStream" in window || "CanvasCaptureMediaStreamTrack" in window) && !(E.browserName() === "Safari" && Number(E.browserVersion()) === 15);
5081
5166
  }
5082
- }, wi = class extends Si {
5167
+ }, Di = class extends Ti {
5083
5168
  constructor(e, t = z) {
5084
5169
  super(e), h(this, "_generator", void 0), h(this, "_writer", void 0), h(this, "_stream", void 0), h(this, "_debug", void 0), this._debug = t, this._debug.debug("TrackGeneratorRenderer started"), this._generator = new MediaStreamTrackGenerator({ kind: A.video }), this._writer = this._generator.writable.getWriter(), this._stream = new MediaStream([this._generator]), this._onStream(this._stream);
5085
5170
  }
@@ -5090,9 +5175,9 @@ var fi = class {
5090
5175
  this._writer.releaseLock(), this._generator.writable.close().then(() => this._generator.stop()), this._debug.debug("TrackGeneratorRenderer destroyed");
5091
5176
  }
5092
5177
  static isBrowserSupported() {
5093
- return "VideoFrame" in window && "MediaStreamTrackGenerator" in window && gi.isBrowserSupported();
5178
+ return "VideoFrame" in window && "MediaStreamTrackGenerator" in window && yi.isBrowserSupported();
5094
5179
  }
5095
- }, Ti = class extends xi {
5180
+ }, Oi = class extends wi {
5096
5181
  constructor(e, t, n, r, i, a = z, o = null) {
5097
5182
  super(e, t, n, r, i, a), h(this, "_renderer", void 0), h(this, "_decoder", void 0), h(this, "_decoderReady", !1), h(this, "_decoderBusy", !1), h(this, "_decoderQueue", []), h(this, "_webCodecsRetryAttempted", !1), h(this, "_fpsMeter", void 0), h(this, "_logger", void 0), this._logger = o, this._debug.debug(`StreamBuilder started for participant [${e}]`), this._initFpsMeter(), this._initRenderer(), this._initDecoder();
5098
5183
  }
@@ -5100,16 +5185,16 @@ var fi = class {
5100
5185
  e.keyframe && (this._decoderQueue = []), this._decoderQueue.push(e), this._decodeQueue();
5101
5186
  }
5102
5187
  _initFpsMeter() {
5103
- this._fpsMeter = new _i((e) => this._debug.log(`[StreamBuilder][${this._participantId}] fps: ${e}`), 2e4);
5188
+ this._fpsMeter = new bi((e) => this._debug.log(`[StreamBuilder][${this._participantId}] fps: ${e}`), 2e4);
5104
5189
  }
5105
5190
  _initRenderer(e = !1) {
5106
- e || !wi.isBrowserSupported() ? this._renderer = new Ci(this._onStream, this._debug) : this._renderer = new wi(this._onStream, this._debug);
5191
+ e || !Di.isBrowserSupported() ? this._renderer = new Ei(this._onStream, this._debug) : this._renderer = new Di(this._onStream, this._debug);
5107
5192
  }
5108
5193
  _initDecoder(e = !1) {
5109
- e || !gi.isBrowserSupported() ? this._decoder = new hi(this._debug, this._logger) : this._decoder = new gi(this._debug, this._logger), this._decoder.init(async (e) => {
5194
+ e || !yi.isBrowserSupported() ? this._decoder = new vi(this._debug, this._logger) : this._decoder = new yi(this._debug, this._logger), this._decoder.init(async (e) => {
5110
5195
  this._decoderBusy = !1, "VideoFrame" in window && e instanceof VideoFrame ? await this._renderer.drawFrame(e) : await this._renderer.drawImage(e), this._fpsMeter.increment(), this._decodeQueue();
5111
5196
  }, (e) => {
5112
- if (this._decoderBusy = !1, this._decoder instanceof gi && typeof e == "string" && e.includes("EncodingError")) {
5197
+ if (this._decoderBusy = !1, this._decoder instanceof yi && typeof e == "string" && e.includes("EncodingError")) {
5113
5198
  this._decoderQueue = [], !this._webCodecsRetryAttempted && e.includes("reset because error during decoding") ? (this._webCodecsRetryAttempted = !0, this._debug.warn("StreamBuilder retry WebCodecs with software decoder"), this._onKeyFrameRequested?.()) : this._switchToLibVPXDecoder();
5114
5199
  return;
5115
5200
  }
@@ -5117,7 +5202,7 @@ var fi = class {
5117
5202
  }, this._onKeyFrameRequested).then(() => {
5118
5203
  this._decoderReady = !0, this._decodeQueue();
5119
5204
  }).catch((e) => {
5120
- this._debug.warn("StreamBuilder decoder init failed", e), this._decoder instanceof gi && this._switchToLibVPXDecoder();
5205
+ this._debug.warn("StreamBuilder decoder init failed", e), this._decoder instanceof yi && this._switchToLibVPXDecoder();
5121
5206
  });
5122
5207
  }
5123
5208
  _switchToLibVPXDecoder() {
@@ -5132,20 +5217,20 @@ var fi = class {
5132
5217
  super.destroy(), this._fpsMeter.destroy(), this._decoder.destroy(), this._renderer.destroy(), this._debug.debug(`StreamBuilder destroyed for participant ${this._participantId}`);
5133
5218
  }
5134
5219
  static isBrowserSupported() {
5135
- return Ci.isBrowserSupported() || wi.isBrowserSupported();
5220
+ return Ei.isBrowserSupported() || Di.isBrowserSupported();
5136
5221
  }
5137
- }, Ei = 1, Di = 1, Oi = 2, ki = 0, Ai = 1, ji = 2, Mi = 4, Ni = 8;
5138
- function Pi(e, t, n, r, i, a, o) {
5222
+ }, ki = 1, Ai = 1, ji = 2, Mi = 0, Ni = 1, Pi = 2, Fi = 4, Ii = 8;
5223
+ function Li(e, t, n, r, i, a, o) {
5139
5224
  let s = 0;
5140
- t && (s |= Ai), n && (s |= ji), r && (s |= Mi), o || (s |= Ni);
5225
+ t && (s |= Ni), n && (s |= Pi), r && (s |= Fi), o || (s |= Ii);
5141
5226
  let c = /* @__PURE__ */ new ArrayBuffer(11), l = new DataView(c);
5142
- if (l.setUint8(0, Ei), l.setUint16(1, i), l.setUint32(3, e), l.setUint8(7, +!!a), l.setUint16(8, ki), l.setUint8(10, s), !o) return c;
5227
+ if (l.setUint8(0, ki), l.setUint16(1, i), l.setUint32(3, e), l.setUint8(7, +!!a), l.setUint16(8, Mi), l.setUint8(10, s), !o) return c;
5143
5228
  let u = new Uint8Array(c.byteLength + o.byteLength);
5144
5229
  return u.set(new Uint8Array(c), 0), u.set(new Uint8Array(o), c.byteLength), u.buffer;
5145
5230
  }
5146
- function Fi(e) {
5147
- let t = new DataView(e), n = t.getUint8(0), r = t.getUint16(1), i = t.getUint32(3), a = t.getUint8(7) === 1, o = t.getUint16(8), s = t.getUint8(10), c = !!(s & Ai), l = !!(s & ji), u = !!(s & Mi), d = !!(s & Ni);
5148
- if (n !== Ei) throw Error(`Unexpected protocol version. Got ${n}, expected ${Ei}`);
5231
+ function Ri(e) {
5232
+ let t = new DataView(e), n = t.getUint8(0), r = t.getUint16(1), i = t.getUint32(3), a = t.getUint8(7) === 1, o = t.getUint16(8), s = t.getUint8(10), c = !!(s & Ni), l = !!(s & Pi), u = !!(s & Fi), d = !!(s & Ii);
5233
+ if (n !== ki) throw Error(`Unexpected protocol version. Got ${n}, expected ${ki}`);
5149
5234
  return {
5150
5235
  timestamp: i,
5151
5236
  start: c,
@@ -5158,26 +5243,26 @@ function Fi(e) {
5158
5243
  data: e.slice(11)
5159
5244
  };
5160
5245
  }
5161
- function Ii(e) {
5246
+ function zi(e) {
5162
5247
  if (!e || !e.byteLength || e.byteLength !== 4) return !1;
5163
5248
  let t = new DataView(e);
5164
- return !(t.getUint8(0) !== Ei || t.getUint8(1) !== Di || t.getUint16(2) !== ki);
5249
+ return !(t.getUint8(0) !== ki || t.getUint8(1) !== Ai || t.getUint16(2) !== Mi);
5165
5250
  }
5166
- function Li(e) {
5251
+ function Bi(e) {
5167
5252
  if (!e || !e.byteLength || e.byteLength !== 10) return null;
5168
5253
  let t = new DataView(e);
5169
- return t.getUint8(0) !== Ei || t.getUint8(1) !== Oi || t.getUint16(2) !== ki ? null : {
5254
+ return t.getUint8(0) !== ki || t.getUint8(1) !== ji || t.getUint16(2) !== Mi ? null : {
5170
5255
  seq: t.getUint16(4),
5171
5256
  ts2: t.getUint32(6)
5172
5257
  };
5173
5258
  }
5174
- function Ri(e) {
5259
+ function Vi(e) {
5175
5260
  let t = /* @__PURE__ */ new ArrayBuffer(4), n = new DataView(t);
5176
- return n.setUint8(0, Ei), n.setUint8(1, Di), n.setUint16(2, e), t;
5261
+ return n.setUint8(0, ki), n.setUint8(1, Ai), n.setUint16(2, e), t;
5177
5262
  }
5178
5263
  //#endregion
5179
5264
  //#region src/classes/screenshare/WebmBuilder.ts
5180
- var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5265
+ var Hi = 2 ** 15 - 1, Ui = 1, Wi = 5, Gi = 5, Ki = class e {
5181
5266
  constructor(e, t = z) {
5182
5267
  h(this, "_mediaSource", void 0), h(this, "_codec", void 0), h(this, "_sourceBuffer", null), h(this, "_queue", []), h(this, "_clearBufferTill", 0), h(this, "_debug", void 0), this._mediaSource = new MediaSource(), this._codec = e, this._debug = t;
5183
5268
  let n = () => {
@@ -5220,8 +5305,8 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5220
5305
  this._mediaSource?.readyState === "open" && this._sourceBuffer?.abort();
5221
5306
  let e = this._sourceBuffer?.buffered, t = e?.length;
5222
5307
  if (!t) return;
5223
- let n = e.start(0), r = Math.max(0, e.end(t - 1) - Vi);
5224
- r - n > Hi && (this._clearBufferTill = r);
5308
+ let n = e.start(0), r = Math.max(0, e.end(t - 1) - Wi);
5309
+ r - n > Gi && (this._clearBufferTill = r);
5225
5310
  }
5226
5311
  destroy() {
5227
5312
  this._queue = [], this._mediaSource.readyState === "open" && (this._sourceBuffer?.abort(), this._mediaSource.endOfStream()), this._sourceBuffer = null, this._clearBufferTill = 0;
@@ -5235,7 +5320,7 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5235
5320
  get buffered() {
5236
5321
  return this._sourceBuffer?.buffered;
5237
5322
  }
5238
- }, Wi = class e extends xi {
5323
+ }, qi = class e extends wi {
5239
5324
  constructor(e, t, n, r, i = z) {
5240
5325
  super(e, t, n, r, void 0, i), h(this, "_mediaBuffer", null), h(this, "_video", null), h(this, "_stream", null), h(this, "_earliestTimestamp", 0), h(this, "_clusterStartTime", 0), h(this, "_lastFrameTimestamp", 0), this._debug.debug(`[WebmBuilder] started for participant [${e}]`);
5241
5326
  }
@@ -5259,8 +5344,8 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5259
5344
  u.element(u.ID.MuxingApp, u.string("vk-webm-builder")),
5260
5345
  u.element(u.ID.WritingApp, u.string("vk-webm-builder"))
5261
5346
  ]), i = [u.element(u.ID.PixelWidth, u.number(e)), u.element(u.ID.PixelHeight, u.number(t))], a = u.element(u.ID.Tracks, u.element(u.ID.TrackEntry, [
5262
- u.element(u.ID.TrackNumber, u.number(Bi)),
5263
- u.element(u.ID.TrackUID, u.number(Bi)),
5347
+ u.element(u.ID.TrackNumber, u.number(Ui)),
5348
+ u.element(u.ID.TrackUID, u.number(Ui)),
5264
5349
  u.element(u.ID.TrackType, u.number(1)),
5265
5350
  u.element(u.ID.FlagLacing, u.number(0)),
5266
5351
  u.element(u.ID.DefaultDuration, u.number(1e9)),
@@ -5273,7 +5358,7 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5273
5358
  return u.unknownSizeElement(u.ID.Cluster, [u.element(u.ID.Timecode, u.number(Math.round(e)))]);
5274
5359
  }
5275
5360
  _createVideo(e) {
5276
- this._mediaBuffer = new Ui(e, this._debug), this._video = document.createElement("video"), this._video.autoplay = !0, this._video.controls = !1, this._video.muted = !0, this._video.style.pointerEvents = "none", this._video.style.visibility = "hidden", this._video.style.position = "absolute", this._video.style.width = "160px", this._video.style.height = "90px", this._video.style.bottom = "0", this._video.style.right = "0", this._video.style.zIndex = "5000", this._video.src = URL.createObjectURL(this._mediaBuffer.mediaSource), document.body.appendChild(this._video);
5361
+ this._mediaBuffer = new Ki(e, this._debug), this._video = document.createElement("video"), this._video.autoplay = !0, this._video.controls = !1, this._video.muted = !0, this._video.style.pointerEvents = "none", this._video.style.visibility = "hidden", this._video.style.position = "absolute", this._video.style.width = "160px", this._video.style.height = "90px", this._video.style.bottom = "0", this._video.style.right = "0", this._video.style.zIndex = "5000", this._video.src = URL.createObjectURL(this._mediaBuffer.mediaSource), document.body.appendChild(this._video);
5277
5362
  let t = () => {
5278
5363
  if (this._video?.src) {
5279
5364
  this._debug.warn(`[WebmBuilder] Video paused for participant [${this._participantId}], try to play again`);
@@ -5300,13 +5385,13 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5300
5385
  this._mediaBuffer?.append(a);
5301
5386
  }
5302
5387
  let i = Math.round(r - this._clusterStartTime);
5303
- if (i > zi && (this._clusterStartTime = r, i = 0), i === 0) {
5388
+ if (i > Hi && (this._clusterStartTime = r, i = 0), i === 0) {
5304
5389
  this._debug.debug(`[WebmBuilder] Cluster header for participant [${this._participantId}]`);
5305
5390
  let t = e._genClusterHeader(this._clusterStartTime);
5306
5391
  this._mediaBuffer?.append(t);
5307
5392
  }
5308
5393
  let a = u.element(u.ID.SimpleBlock, [
5309
- u.vintEncodedNumber(Bi),
5394
+ u.vintEncodedNumber(Ui),
5310
5395
  u.bytes(e._intToU16BE(i)),
5311
5396
  u.number(!!t.keyframe << 7),
5312
5397
  u.bytes(t.frameData)
@@ -5319,12 +5404,12 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5319
5404
  static isBrowserSupported() {
5320
5405
  return "captureStream" in window.HTMLVideoElement?.prototype && window.MediaSource?.isTypeSupported("video/webm; codecs=\"vp8\"") && window.MediaSource?.isTypeSupported("video/webm; codecs=\"vp9\"");
5321
5406
  }
5322
- }, Gi = class {
5407
+ }, Ji = class {
5323
5408
  constructor(e, t, n, r, i, a = null, o = z, s = null) {
5324
5409
  h(this, "_datachannel", void 0), h(this, "_participantIdRegistry", null), h(this, "_streamBuilders", {}), h(this, "_onStream", () => {}), h(this, "_onEos", () => {}), h(this, "_onStat", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), this._debug = o, this._logger = s, this._statAggregator = a, this._debug.debug("ScreenCaptureReceiver started"), this._datachannel = e, this._participantIdRegistry = t, this._onStream = n, this._onEos = r, this._onStat = i, this._datachannel.onmessage = (e) => this._onDataChannelMessage(e.data);
5325
5410
  }
5326
5411
  _onDataChannelMessage(e) {
5327
- let t = Fi(e), n = this._participantIdRegistry?.getStreamDescription(t.ssrc)?.participantId;
5412
+ let t = Ri(e), n = this._participantIdRegistry?.getStreamDescription(t.ssrc)?.participantId;
5328
5413
  if (!n) {
5329
5414
  this._debug.warn(`Participant id for ssrc ${t.ssrc} not found in registry`);
5330
5415
  return;
@@ -5336,7 +5421,7 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5336
5421
  let r = this._streamBuilders[n];
5337
5422
  if (!r) {
5338
5423
  let e = (e) => this._onStream(n, e);
5339
- r = N.screenShareWebmBuilder && Wi.isBrowserSupported() ? new Wi(n, e, this._onStat, this._statAggregator, this._debug) : new Ti(n, e, this._onStat, this._statAggregator, () => {
5424
+ r = N.screenShareWebmBuilder && qi.isBrowserSupported() ? new qi(n, e, this._onStat, this._statAggregator, this._debug) : new Oi(n, e, this._onStat, this._statAggregator, () => {
5340
5425
  this._requestKeyFrame(t.ssrc);
5341
5426
  }, this._debug, this._logger), this._streamBuilders[n] = r;
5342
5427
  }
@@ -5344,7 +5429,7 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5344
5429
  }
5345
5430
  _requestKeyFrame(e) {
5346
5431
  if (!(!this._datachannel || this._datachannel.readyState !== "open")) try {
5347
- let t = Ri(e);
5432
+ let t = Vi(e);
5348
5433
  this._datachannel.send(t), this._debug.debug(`ScreenCaptureReceiver request for keyframe for ssrc ${e}`);
5349
5434
  } catch (e) {
5350
5435
  this._debug.warn("Failed to send keyframe request", e);
@@ -5357,7 +5442,7 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5357
5442
  destroy() {
5358
5443
  this._datachannel.onbufferedamountlow = null, this._datachannel.onmessage = null, this._onStream = () => {}, Object.values(this._streamBuilders).forEach((e) => e.destroy()), this._streamBuilders = {}, this._participantIdRegistry = null, this._debug.debug("ScreenCaptureReceiver destroyed");
5359
5444
  }
5360
- }, Ki = class {
5445
+ }, Yi = class {
5361
5446
  constructor(e, t, n) {
5362
5447
  h(this, "_prev", void 0), h(this, "_next", void 0), h(this, "_data", void 0), this._next = n, n && (n.prev = this), this._prev = t, t && (t.next = this), this._data = e;
5363
5448
  }
@@ -5376,7 +5461,7 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5376
5461
  get data() {
5377
5462
  return this._data;
5378
5463
  }
5379
- }, qi = class {
5464
+ }, Xi = class {
5380
5465
  constructor() {
5381
5466
  h(this, "_head", null), h(this, "_tail", null), h(this, "_length", 0);
5382
5467
  }
@@ -5384,7 +5469,7 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5384
5469
  return this._length;
5385
5470
  }
5386
5471
  push(...e) {
5387
- for (let t of e) this._tail = new Ki(t, this._tail, null), this._head || (this._head = this._tail), this._length++;
5472
+ for (let t of e) this._tail = new Yi(t, this._tail, null), this._head || (this._head = this._tail), this._length++;
5388
5473
  }
5389
5474
  merge(e) {
5390
5475
  this._tail && (this._tail.next = e._head), this._head || (this._head = e._head), this._tail = e._tail, this._length += e._length, e.clear();
@@ -5414,7 +5499,7 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5414
5499
  for (; t !== null;) e.push(t.data), t = t.next;
5415
5500
  return e.length ? JSON.stringify(e, (e, t) => t instanceof Error ? String(t) : t) : "";
5416
5501
  }
5417
- }, Ji = 1e3, Yi = class extends mi {
5502
+ }, Zi = 1e3, Qi = class extends _i {
5418
5503
  constructor(e, t, n, r, i = z, a = null) {
5419
5504
  super(i, a), h(this, "_sourceTrack", void 0), h(this, "_onFrame", void 0), h(this, "_useCongestionControl", void 0), h(this, "_maxBitrate", void 0), h(this, "_useImageCapture", void 0), h(this, "_video", null), h(this, "_imageCapture", null), h(this, "_canvas", null), h(this, "_canvasCtx", null), h(this, "_frameReadTimeout", 0), h(this, "_lastFrame", null), this._sourceTrack = e, this._onFrame = t, this._useCongestionControl = n, this._maxBitrate = r, this._useImageCapture = "ImageCapture" in window && ImageCapture.prototype.grabFrame !== void 0 && "ImageBitmap" in window, (e.readyState !== "live" || !e.enabled || e.muted) && (this._useImageCapture = !1);
5420
5505
  }
@@ -5483,7 +5568,7 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5483
5568
  }
5484
5569
  _encode(e, t) {
5485
5570
  let n = e.data.buffer;
5486
- this._sendToWorker(pi.FRAME, {
5571
+ this._sendToWorker(gi.FRAME, {
5487
5572
  width: e.width,
5488
5573
  height: e.height,
5489
5574
  imageData: n,
@@ -5500,7 +5585,7 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5500
5585
  let t = this._drawFrameData(this._lastFrame);
5501
5586
  this._encode(t, e);
5502
5587
  } else this._onFrame(null);
5503
- }, Ji), this._getFrameBitmap().then((t) => {
5588
+ }, Zi), this._getFrameBitmap().then((t) => {
5504
5589
  window.clearTimeout(this._frameReadTimeout), this._lastFrame?.close(), this._lastFrame = t;
5505
5590
  let n = this._drawFrameData(t);
5506
5591
  this._encode(n, e);
@@ -5510,7 +5595,7 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5510
5595
  this._useImageCapture ? this._requestFrameBitmap(e) : this._requestFrameVideo(e);
5511
5596
  }
5512
5597
  setBitrate(e, t, n) {
5513
- this._sendToWorker(pi.SET_BITRATE, {
5598
+ this._sendToWorker(gi.SET_BITRATE, {
5514
5599
  bitrate: e,
5515
5600
  useCbr: t
5516
5601
  });
@@ -5521,7 +5606,7 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5521
5606
  destroy() {
5522
5607
  this._removeWorker(), this._removeStream(), this._removeDom(), this._debug.debug("LibVPxEncoder destroyed");
5523
5608
  }
5524
- }, Xi = class extends mi {
5609
+ }, $i = class extends _i {
5525
5610
  constructor(e, t, n, r, i, a, o = z, s = null) {
5526
5611
  super(o, s), h(this, "_sourceTrack", void 0), h(this, "_trackProcessor", void 0), h(this, "_onFrame", void 0), h(this, "_useCongestionControl", void 0), h(this, "_maxBitrate", void 0), h(this, "_useCbr", void 0), h(this, "_frameRate", void 0), this._sourceTrack = e, this._onFrame = t, this._useCongestionControl = n, this._maxBitrate = r, this._useCbr = i, this._frameRate = a, this._trackProcessor = new MediaStreamTrackProcessor({ track: e });
5527
5612
  }
@@ -5549,10 +5634,10 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5549
5634
  }, [n]);
5550
5635
  }
5551
5636
  requestFrame(e = !1) {
5552
- this._sendToWorker(pi.FRAME, { keyFrame: e });
5637
+ this._sendToWorker(gi.FRAME, { keyFrame: e });
5553
5638
  }
5554
5639
  setBitrate(e, t, n) {
5555
- this._sendToWorker(pi.SET_BITRATE, {
5640
+ this._sendToWorker(gi.SET_BITRATE, {
5556
5641
  bitrate: e,
5557
5642
  useCbr: t,
5558
5643
  fps: n
@@ -5567,11 +5652,11 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5567
5652
  static isBrowserSupported() {
5568
5653
  return "VideoEncoder" in window && "Worker" in window && "EncodedVideoChunk" in window && "MediaStreamTrackProcessor" in window;
5569
5654
  }
5570
- }, Zi = 2100, Qi = 600, $i = 1.2, ea = .8, ta = 2e3, na = 8e3, ra = 8e3, ia = 16e3, aa = 4, oa = 2e3, sa = /* @__PURE__ */ function(e) {
5655
+ }, ea = 2100, ta = 600, na = 1.2, ra = .8, ia = 2e3, aa = 8e3, oa = 8e3, sa = 16e3, ca = 4, la = 2e3, ua = /* @__PURE__ */ function(e) {
5571
5656
  return e[e.NONE = 0] = "NONE", e[e.UP = 1] = "UP", e[e.DOWN = 2] = "DOWN", e;
5572
- }(sa || {}), ca = class {
5657
+ }(ua || {}), da = class {
5573
5658
  constructor(e, t, n, r, i, a, o, s = z) {
5574
- h(this, "_onCongestion", void 0), h(this, "_ccEnabled", void 0), h(this, "_fastSharing", void 0), h(this, "_trendDelayThreshold", void 0), h(this, "_highDelayThreshold", void 0), h(this, "_targetFps", void 0), h(this, "_minBitrate", void 0), h(this, "_maxBitrate", void 0), h(this, "_targetBitrate", void 0), h(this, "_lastDown", void 0), h(this, "_lastUp", void 0), h(this, "_lastProbing", void 0), h(this, "_lastCheckDelay", void 0), h(this, "_upPenalty", 0), h(this, "_probing", void 0), h(this, "_delayAvgShort", -1), h(this, "_delayAvgLong", -1), h(this, "_minDelay", Number.MAX_VALUE), h(this, "_maxDelay", 0), h(this, "_largeDelayDuration", 0), h(this, "_lastFpsCalcMs", void 0), h(this, "_frames", 0), h(this, "_fps", 0), h(this, "_debug", void 0), this._onCongestion = e, this._ccEnabled = r, this._debug = s, this._minBitrate = t, this._maxBitrate = n, this._fastSharing = i, this._targetFps = o, a > 0 ? this._highDelayThreshold = a : this._highDelayThreshold = Zi, i && (this._highDelayThreshold = Qi), this._trendDelayThreshold = Math.round(this._highDelayThreshold / 3), this._targetBitrate = this._maxBitrate, this._probing = !1;
5659
+ h(this, "_onCongestion", void 0), h(this, "_ccEnabled", void 0), h(this, "_fastSharing", void 0), h(this, "_trendDelayThreshold", void 0), h(this, "_highDelayThreshold", void 0), h(this, "_targetFps", void 0), h(this, "_minBitrate", void 0), h(this, "_maxBitrate", void 0), h(this, "_targetBitrate", void 0), h(this, "_lastDown", void 0), h(this, "_lastUp", void 0), h(this, "_lastProbing", void 0), h(this, "_lastCheckDelay", void 0), h(this, "_upPenalty", 0), h(this, "_probing", void 0), h(this, "_delayAvgShort", -1), h(this, "_delayAvgLong", -1), h(this, "_minDelay", Number.MAX_VALUE), h(this, "_maxDelay", 0), h(this, "_largeDelayDuration", 0), h(this, "_lastFpsCalcMs", void 0), h(this, "_frames", 0), h(this, "_fps", 0), h(this, "_debug", void 0), this._onCongestion = e, this._ccEnabled = r, this._debug = s, this._minBitrate = t, this._maxBitrate = n, this._fastSharing = i, this._targetFps = o, a > 0 ? this._highDelayThreshold = a : this._highDelayThreshold = ea, i && (this._highDelayThreshold = ta), this._trendDelayThreshold = Math.round(this._highDelayThreshold / 3), this._targetBitrate = this._maxBitrate, this._probing = !1;
5575
5660
  let c = Date.now();
5576
5661
  this._lastDown = 0, this._lastUp = c, this._lastProbing = c, this._lastCheckDelay = 0, this._lastFpsCalcMs = 0;
5577
5662
  }
@@ -5581,27 +5666,27 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5581
5666
  let i = 0, a = this._delayAvgShort - this._delayAvgLong, o = Math.round(Math.abs(a) * 100 / this._delayAvgLong), s = a > 40 && o > 30 && this._delayAvgShort > this._trendDelayThreshold, c = this._delayAvgShort > this._highDelayThreshold;
5582
5667
  s || c ? i = 2 : Math.abs(a) < 40 && o < 10 && !c && (i = 1);
5583
5668
  let l = Math.round(this._targetBitrate / 1e3), u = n;
5584
- e % 20 == 0 && this._debug.debug(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${sa[i]} tr=${l} br=${n}`);
5669
+ e % 20 == 0 && this._debug.debug(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${ua[i]} tr=${l} br=${n}`);
5585
5670
  let d = r - this._lastDown;
5586
- if (i === 2 && d > ta) {
5587
- this._probing && (this._upPenalty = Math.min(++this._upPenalty, aa), this._probing = !1);
5588
- let n = ea * u * 1e3;
5589
- if (n >= this._targetBitrate && (n = this._targetBitrate * ea), n = Math.max(n, this._minBitrate), n < this._targetBitrate) {
5590
- let r = Math.round(n / 1e3), s = Math.round(this._upPenalty * ra / 1e3);
5591
- this._debug.log(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${sa[i]}`), this._debug.log(`#${e}: cc: DOWN delay=${t} bitrate=${u} target=${l} -> newBitrate=${r} penalty=${s}s`), this._setBitrate(n, !0), this._targetBitrate = n;
5671
+ if (i === 2 && d > ia) {
5672
+ this._probing && (this._upPenalty = Math.min(++this._upPenalty, ca), this._probing = !1);
5673
+ let n = ra * u * 1e3;
5674
+ if (n >= this._targetBitrate && (n = this._targetBitrate * ra), n = Math.max(n, this._minBitrate), n < this._targetBitrate) {
5675
+ let r = Math.round(n / 1e3), s = Math.round(this._upPenalty * oa / 1e3);
5676
+ this._debug.log(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${ua[i]}`), this._debug.log(`#${e}: cc: DOWN delay=${t} bitrate=${u} target=${l} -> newBitrate=${r} penalty=${s}s`), this._setBitrate(n, !0), this._targetBitrate = n;
5592
5677
  }
5593
5678
  this._lastDown = r;
5594
5679
  }
5595
- let f = r - this._lastUp, p = na + this._upPenalty * ra;
5680
+ let f = r - this._lastUp, p = aa + this._upPenalty * oa;
5596
5681
  if (i === 1 && f > p && d > p) {
5597
- let n = Math.min(this._targetBitrate * $i, this._maxBitrate);
5682
+ let n = Math.min(this._targetBitrate * na, this._maxBitrate);
5598
5683
  if (n > this._targetBitrate) {
5599
- let s = Math.round(n / 1e3), c = Math.round(this._targetBitrate / 1e3), l = Math.round(this._upPenalty * ra / 1e3);
5600
- this._debug.log(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${sa[i]}`), this._debug.log(`#${e}: cc: UP bitrate=${u} target=${c} -> newBitrate=${s} penalty=${l}s`), this._setBitrate(n, !1), this._targetBitrate = n, this._probing = !0, this._lastProbing = r, this._lastUp = r;
5684
+ let s = Math.round(n / 1e3), c = Math.round(this._targetBitrate / 1e3), l = Math.round(this._upPenalty * oa / 1e3);
5685
+ this._debug.log(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${ua[i]}`), this._debug.log(`#${e}: cc: UP bitrate=${u} target=${c} -> newBitrate=${s} penalty=${l}s`), this._setBitrate(n, !1), this._targetBitrate = n, this._probing = !0, this._lastProbing = r, this._lastUp = r;
5601
5686
  }
5602
5687
  }
5603
5688
  let m = r - this._lastProbing;
5604
- this._probing && m > ia && (this._probing = !1);
5689
+ this._probing && m > sa && (this._probing = !1);
5605
5690
  let ee = r - this._lastDown;
5606
5691
  this._upPenalty > 0 && ee > 3 * p && (this._debug.log(`#${e}: cc: UP reset penalty: oldPenalty=${this._upPenalty}`), this._upPenalty = 0);
5607
5692
  }
@@ -5612,7 +5697,7 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5612
5697
  }
5613
5698
  _calcDelay(e, t) {
5614
5699
  if (!(e <= 0)) {
5615
- if (this._delayAvgShort === -1 && (this._delayAvgShort = e, this._delayAvgLong = e), this._delayAvgShort = Math.round((this._delayAvgShort * 3 + e) / 4), this._delayAvgLong = Math.round((this._delayAvgLong * 23 + e) / 24), e > 0 && e < this._minDelay ? this._minDelay = e : e > this._maxDelay && (this._maxDelay = e), this._lastCheckDelay === 0 && (this._lastCheckDelay = t), e > oa) {
5700
+ if (this._delayAvgShort === -1 && (this._delayAvgShort = e, this._delayAvgLong = e), this._delayAvgShort = Math.round((this._delayAvgShort * 3 + e) / 4), this._delayAvgLong = Math.round((this._delayAvgLong * 23 + e) / 24), e > 0 && e < this._minDelay ? this._minDelay = e : e > this._maxDelay && (this._maxDelay = e), this._lastCheckDelay === 0 && (this._lastCheckDelay = t), e > la) {
5616
5701
  let e = t - this._lastCheckDelay;
5617
5702
  this._largeDelayDuration += e;
5618
5703
  }
@@ -5641,7 +5726,7 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5641
5726
  this._fps === 0 ? this._fps = Math.round(r) : this._fps = Math.round((this._fps * 3 + r) / 4), this._frames = 0, this._fps !== n && this._debug.log(`cc: fps=${this._fps}`);
5642
5727
  }
5643
5728
  }
5644
- }, la = class {
5729
+ }, fa = class {
5645
5730
  constructor(e) {
5646
5731
  h(this, "_maxSize", void 0), h(this, "_size", 0), h(this, "_buffer", void 0), h(this, "_head", 0), h(this, "_tail", 0), this._maxSize = e, this._buffer = Array(e);
5647
5732
  }
@@ -5715,11 +5800,11 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5715
5800
  clear() {
5716
5801
  this._buffer.fill(void 0), this._size = 0, this._head = 0, this._tail = 0;
5717
5802
  }
5718
- }, ua = 65536, da = 50, fa = 400, pa = 1e6, ma = 3e5, ha = 3e4, ga = 2e3, _a = 5, va = 0, ya = class {
5803
+ }, pa = 65536, ma = 50, ha = 400, ga = 1e6, _a = 3e5, va = 3e4, ya = 2e3, ba = 5, xa = 0, Sa = class {
5719
5804
  constructor(e, t, n, r, i = z, a = null) {
5720
- h(this, "_encoder", void 0), h(this, "_datachannel", void 0), h(this, "_signaling", void 0), h(this, "_fastSharing", void 0), h(this, "_destroyed", !1), h(this, "_needKeyframe", !0), h(this, "DATA_SIZE", void 0), h(this, "_congestionControl", void 0), h(this, "_frameNum", 0), h(this, "_width", void 0), h(this, "_height", void 0), h(this, "_feedback", new la(1024)), h(this, "_lastSentFrameSeq", 0), h(this, "_lastDeliveredFrameSeq", 0), h(this, "_lastFrameDelay", 0), h(this, "_lastFramerateReduced", Date.now()), h(this, "_lastSharingStat", Date.now()), h(this, "_congestionControlEnabled", void 0), h(this, "_queue", new qi()), h(this, "_fpsMeter", void 0), h(this, "_maxFrameDelay", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), this._debug = i, this._logger = a, this._debug.debug("ScreenCaptureSender started"), this.DATA_SIZE = N.consumerScreenDataChannelPacketSize - 11, this._datachannel = t, this._signaling = n, this._fastSharing = r, this._congestionControlEnabled = N.screenShareCongestionControl || this._fastSharing, this._width = e.getSettings().width, this._height = e.getSettings().height, this._maxFrameDelay = this._fastSharing ? N.screenShareCongestionControlThreshold : N.screenShareCongestionControlThreshold * 2;
5805
+ h(this, "_encoder", void 0), h(this, "_datachannel", void 0), h(this, "_signaling", void 0), h(this, "_fastSharing", void 0), h(this, "_destroyed", !1), h(this, "_needKeyframe", !0), h(this, "DATA_SIZE", void 0), h(this, "_congestionControl", void 0), h(this, "_frameNum", 0), h(this, "_width", void 0), h(this, "_height", void 0), h(this, "_feedback", new fa(1024)), h(this, "_lastSentFrameSeq", 0), h(this, "_lastDeliveredFrameSeq", 0), h(this, "_lastFrameDelay", 0), h(this, "_lastFramerateReduced", Date.now()), h(this, "_lastSharingStat", Date.now()), h(this, "_congestionControlEnabled", void 0), h(this, "_queue", new Xi()), h(this, "_fpsMeter", void 0), h(this, "_maxFrameDelay", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), this._debug = i, this._logger = a, this._debug.debug("ScreenCaptureSender started"), this.DATA_SIZE = N.consumerScreenDataChannelPacketSize - 11, this._datachannel = t, this._signaling = n, this._fastSharing = r, this._congestionControlEnabled = N.screenShareCongestionControl || this._fastSharing, this._width = e.getSettings().width, this._height = e.getSettings().height, this._maxFrameDelay = this._fastSharing ? N.screenShareCongestionControlThreshold : N.screenShareCongestionControlThreshold * 2;
5721
5806
  let o = N.getScreenFrameRate(this._fastSharing), { minBitrate: s, maxBitrate: c } = this._calcMinMaxBitrate(this._width, this._height), l = this._onCongestionCallback.bind(this);
5722
- this._debug.log(`ScreenCaptureSender: CongestionControl: enabled=${this._congestionControlEnabled} minBitrate=${Math.round(s / 1e3)}k maxBitrate=${Math.round(c / 1e3)}k delayThreshold=${N.screenShareCongestionControlThreshold}`), this._congestionControl = new ca(l, s, c, this._congestionControlEnabled, this._fastSharing, N.screenShareCongestionControlThreshold, o, this._debug);
5807
+ this._debug.log(`ScreenCaptureSender: CongestionControl: enabled=${this._congestionControlEnabled} minBitrate=${Math.round(s / 1e3)}k maxBitrate=${Math.round(c / 1e3)}k delayThreshold=${N.screenShareCongestionControlThreshold}`), this._congestionControl = new da(l, s, c, this._congestionControlEnabled, this._fastSharing, N.screenShareCongestionControlThreshold, o, this._debug);
5723
5808
  let u = (e, t) => {
5724
5809
  if (this._destroyed) return;
5725
5810
  if (!e) {
@@ -5730,23 +5815,23 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5730
5815
  let n = this._sliceFrame(e);
5731
5816
  this._queue.merge(n), this._handleQueue(), this._sendSharingStat();
5732
5817
  };
5733
- if (Xi.isBrowserSupported()) {
5818
+ if ($i.isBrowserSupported()) {
5734
5819
  let t = this._fastSharing;
5735
- this._encoder = new Xi(e, u, this._congestionControlEnabled, c, t, o, this._debug, this._logger);
5736
- } else this._encoder = new Yi(e, u, this._congestionControlEnabled, c, this._debug, this._logger);
5820
+ this._encoder = new $i(e, u, this._congestionControlEnabled, c, t, o, this._debug, this._logger);
5821
+ } else this._encoder = new Qi(e, u, this._congestionControlEnabled, c, this._debug, this._logger);
5737
5822
  this._datachannel.onmessage = (e) => {
5738
- Ii(e.data) && (this._debug.debug(`[${this._datachannel.label}] Requested keyframe`), this._needKeyframe = !0);
5739
- let t = Li(e.data);
5823
+ zi(e.data) && (this._debug.debug(`[${this._datachannel.label}] Requested keyframe`), this._needKeyframe = !0);
5824
+ let t = Bi(e.data);
5740
5825
  t !== null && this._checkCcFeedback(t);
5741
- }, this._encoder.init().then(() => this._handleQueue()).catch((e) => this._debug.warn("ScreenCaptureSender init failed", e)), this._fpsMeter = new _i((e) => this._debug.log(`[ScreenCaptureSender] fps: ${e}`), 5e3);
5826
+ }, this._encoder.init().then(() => this._handleQueue()).catch((e) => this._debug.warn("ScreenCaptureSender init failed", e)), this._fpsMeter = new bi((e) => this._debug.log(`[ScreenCaptureSender] fps: ${e}`), 5e3);
5742
5827
  }
5743
5828
  _handleQueue() {
5744
5829
  if (this._destroyed) return;
5745
5830
  let e = this._queue.shift();
5746
5831
  if (!e) {
5747
- if ((this._lastSentFrameSeq - this._lastDeliveredFrameSeq + ua) % ua > _a && this._lastFrameDelay > this._maxFrameDelay) {
5832
+ if ((this._lastSentFrameSeq - this._lastDeliveredFrameSeq + pa) % pa > ba && this._lastFrameDelay > this._maxFrameDelay) {
5748
5833
  let e = Date.now();
5749
- e - this._lastFramerateReduced > ga && (this._lastFramerateReduced = e, this._debug.debug(`[ScreenCaptureSender] reduce framerate: delay=${this._lastFrameDelay} maxDelay=${this._maxFrameDelay}`));
5834
+ e - this._lastFramerateReduced > ya && (this._lastFramerateReduced = e, this._debug.debug(`[ScreenCaptureSender] reduce framerate: delay=${this._lastFrameDelay} maxDelay=${this._maxFrameDelay}`));
5750
5835
  } else this._requestFrame();
5751
5836
  return;
5752
5837
  }
@@ -5772,7 +5857,7 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5772
5857
  this._destroyed || (this._encoder.requestFrame(this._needKeyframe), this._needKeyframe = !1);
5773
5858
  }
5774
5859
  _sliceFrame(e) {
5775
- let t = e.type === "key", n = e.data.byteLength, r = new qi();
5860
+ let t = e.type === "key", n = e.data.byteLength, r = new Xi();
5776
5861
  for (let i = 0; i < n; i += this.DATA_SIZE) {
5777
5862
  let a = e.data.slice(i, i + this.DATA_SIZE), o = i === 0, s = n <= i + a.byteLength, c = this._wrapHeader(e.timestamp, o, s, t, a);
5778
5863
  r.push({
@@ -5788,11 +5873,11 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5788
5873
  return r;
5789
5874
  }
5790
5875
  _wrapHeader(e, t, n, r, i) {
5791
- let a = Pi(e, t, n, r, va, this._encoder.isVP9(), i), o = {
5792
- sequence: va,
5876
+ let a = Li(e, t, n, r, xa, this._encoder.isVP9(), i), o = {
5877
+ sequence: xa,
5793
5878
  data: a
5794
5879
  };
5795
- return va = (va + 1) % ua, o;
5880
+ return xa = (xa + 1) % pa, o;
5796
5881
  }
5797
5882
  _stopPacket() {
5798
5883
  return this._wrapHeader(Date.now(), !1, !1, !1, null).data;
@@ -5809,7 +5894,7 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5809
5894
  this._queue.clear(), this._fpsMeter.destroy(), this._datachannel.onmessage = null, this._feedback.clear(), this._datachannel.readyState === "open" && this._datachannel.send(this._stopPacket()), this._destroyed = !0, this._encoder.destroy(), this._debug.debug("ScreenCaptureSender destroyed");
5810
5895
  }
5811
5896
  static isBrowserSupported() {
5812
- return Xi.isBrowserSupported() || Yi.isBrowserSupported();
5897
+ return $i.isBrowserSupported() || Qi.isBrowserSupported();
5813
5898
  }
5814
5899
  _onCongestionCallback(e, t, n) {
5815
5900
  this._encoder.setBitrate(e, t, n);
@@ -5822,8 +5907,8 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5822
5907
  (e === void 0 || e < 640) && (e = 640), (t === void 0 || t < 360) && (t = 360);
5823
5908
  let n = e * t / 256;
5824
5909
  return {
5825
- minBitrate: Math.max(ma, Math.min(pa, Math.round(n * da))),
5826
- maxBitrate: Math.round(n * fa)
5910
+ minBitrate: Math.max(_a, Math.min(ga, Math.round(n * ma))),
5911
+ maxBitrate: Math.round(n * ha)
5827
5912
  };
5828
5913
  }
5829
5914
  _checkCcFeedback(e) {
@@ -5837,14 +5922,14 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5837
5922
  }
5838
5923
  _sendSharingStat() {
5839
5924
  let e = Date.now();
5840
- if (e - this._lastSharingStat > ha) {
5925
+ if (e - this._lastSharingStat > va) {
5841
5926
  let t = this._congestionControl.getStat();
5842
5927
  t !== null && (this._debug.debug(`cc: send stats: ${JSON.stringify(t)}`), this._signaling.reportSharingStat(t).catch((e) => {
5843
5928
  !(e instanceof En) && !(e instanceof Dn) && this._debug.warn("Unable to send sharing stats", e);
5844
5929
  })), this._lastSharingStat = e;
5845
5930
  }
5846
5931
  }
5847
- }, ba = class {
5932
+ }, Ca = class {
5848
5933
  constructor(e, t, n, r = z, i = null) {
5849
5934
  h(this, "_pc", null), h(this, "_transceiver", null), h(this, "_currentSimulcastInfo", null), h(this, "_signaling", void 0), h(this, "_mediaSource", void 0), h(this, "_getCameraSettings", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), this._signaling = e, this._mediaSource = t, this._getCameraSettings = n, this._debug = r, this._logger = i;
5850
5935
  }
@@ -5976,9 +6061,9 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
5976
6061
  if (!(e instanceof Dn)) throw e;
5977
6062
  }
5978
6063
  }
5979
- }, xa = 90, Sa = 4294967295, Ca = class e extends qr {
6064
+ }, wa = 90, Ta = 4294967295, Ea = class e extends Xr {
5980
6065
  constructor(e, t, n, r = z, i = null, a = null, o = null, s = null) {
5981
- super(e, t, s), h(this, "_producerNotification", null), h(this, "_producerCommand", null), h(this, "_producerScreen", null), h(this, "_consumerScreen", null), h(this, "_asr", null), h(this, "_animojiDataChannel", null), h(this, "_animojiReceiver", null), h(this, "_animojiSender", null), h(this, "_isOpen", !1), h(this, "_observer", !1), h(this, "_reconnectionPrevented", !1), h(this, "_statInterval", null), h(this, "_settingsInterval", null), h(this, "_monitorRtpShareInterval", null), h(this, "_statBytes", {}), h(this, "_ssrcMap", {}), h(this, "_ssrcMapUpdated", !1), h(this, "_perfStatReporter", void 0), h(this, "_producerOfferIsProcessing", !1), h(this, "_producerNextOffer", null), h(this, "_producerNextSessionId", null), h(this, "_lastStat", null), h(this, "_serverSettings", void 0), h(this, "_prevConsumerSettings", {}), h(this, "_prevConsumerFastSharingSettings", {}), h(this, "_asrTrack", null), h(this, "_captureSender", null), h(this, "_captureReceiver", null), h(this, "_participantIdRegistry", null), h(this, "_disabledSenders", /* @__PURE__ */ new Set()), h(this, "_rtpReceiversByStreamId", {}), h(this, "_producerSessionId", ""), h(this, "_newAudioShareTrack", null), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_sdpStats", void 0), h(this, "_codecStatsAggregator", void 0), h(this, "_simulcast", void 0), this._debug = r, this._logger = i, this._statAggregator = a, this._sdpStats = new Rr(a), this._codecStatsAggregator = o, this._serverSettings = n, this._simulcast = new ba(e, t, () => this._serverSettings.camera, r, i), this.subscribe(this._signaling, xr.NOTIFICATION, this._onSignalingNotification.bind(this)), this.subscribe(this._mediaSource, qt.TRACK_REPLACED, this._onReplacedTrack.bind(this)), this.subscribe(this._mediaSource, qt.SOURCE_CHANGED, this._onSourcesChanged.bind(this)), this.subscribe(this._mediaSource, qt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._createPerfStatsReporter(), this._debug.debug("ServerTransport: Created");
6066
+ super(e, t, s), h(this, "_producerNotification", null), h(this, "_producerCommand", null), h(this, "_producerScreen", null), h(this, "_consumerScreen", null), h(this, "_asr", null), h(this, "_animojiDataChannel", null), h(this, "_animojiReceiver", null), h(this, "_animojiSender", null), h(this, "_isOpen", !1), h(this, "_observer", !1), h(this, "_reconnectionPrevented", !1), h(this, "_statInterval", null), h(this, "_settingsInterval", null), h(this, "_monitorRtpShareInterval", null), h(this, "_statBytes", {}), h(this, "_ssrcMap", {}), h(this, "_ssrcMapUpdated", !1), h(this, "_perfStatReporter", void 0), h(this, "_producerOfferIsProcessing", !1), h(this, "_producerNextOffer", null), h(this, "_producerNextSessionId", null), h(this, "_lastStat", null), h(this, "_serverSettings", void 0), h(this, "_prevConsumerSettings", {}), h(this, "_prevConsumerFastSharingSettings", {}), h(this, "_asrTrack", null), h(this, "_captureSender", null), h(this, "_captureReceiver", null), h(this, "_participantIdRegistry", null), h(this, "_disabledSenders", /* @__PURE__ */ new Set()), h(this, "_rtpReceiversByStreamId", {}), h(this, "_producerSessionId", ""), h(this, "_newAudioShareTrack", null), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_sdpStats", void 0), h(this, "_peerConnectionStats", void 0), h(this, "_codecStatsAggregator", void 0), h(this, "_simulcast", void 0), this._debug = r, this._logger = i, this._statAggregator = a, this._sdpStats = new Rr(a), this._peerConnectionStats = new Kr(a), this._codecStatsAggregator = o, this._serverSettings = n, this._simulcast = new Ca(e, t, () => this._serverSettings.camera, r, i), this.subscribe(this._signaling, xr.NOTIFICATION, this._onSignalingNotification.bind(this)), this.subscribe(this._mediaSource, qt.TRACK_REPLACED, this._onReplacedTrack.bind(this)), this.subscribe(this._mediaSource, qt.SOURCE_CHANGED, this._onSourcesChanged.bind(this)), this.subscribe(this._mediaSource, qt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._createPerfStatsReporter(), this._debug.debug("ServerTransport: Created");
5982
6067
  }
5983
6068
  updateStatisticsInterval() {
5984
6069
  this._stopStatInterval();
@@ -6017,10 +6102,10 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
6017
6102
  await this._simulcast.sync();
6018
6103
  }
6019
6104
  _createPerfStatsReporter() {
6020
- this._perfStatReporter?.destroy(), this._perfStatReporter = new ka(this, this._signaling, this._statAggregator, !1, this._debug);
6105
+ this._perfStatReporter?.destroy(), this._perfStatReporter = new Ma(this, this._signaling, this._statAggregator, !1, this._debug);
6021
6106
  }
6022
6107
  _closeConnection() {
6023
- this._signaling.resetProducerConnection(), this._ssrcMap = {}, this._ssrcMapUpdated = !0, this._disposeFirstMediaSentProbe(), this._stopStatInterval(), this._stopSettingsInterval(), this._stopMonitorRtpShareInterval(), this._removeAsrTrack(), this._removeCaptureSender(), this._removeCaptureReceiver(), this._simulcast.reset(), this._pc && (this._rtpReceiversByStreamId = {}, this._disabledSenders.forEach((e) => e.track?.stop()), this._disabledSenders.clear(), this._pc.ontrack = null, this._pc.onconnectionstatechange = null, this._pc.onsignalingstatechange = null, this._sdpStats.stop(), this._participantIdRegistry = null, e._closeDataChannel(this._producerNotification), e._closeDataChannel(this._producerCommand), e._closeDataChannel(this._producerScreen), e._closeDataChannel(this._consumerScreen), e._closeDataChannel(this._asr), e._closeDataChannel(this._animojiDataChannel), this._pc.close(), this._pc = null, this._producerOfferIsProcessing = !1, this._producerNextOffer = null), this._triggerEvent(Y.PEER_CONNECTION_CLOSED);
6108
+ this._signaling.resetProducerConnection(), this._ssrcMap = {}, this._ssrcMapUpdated = !0, this._disposeFirstMediaSentProbe(), this._stopStatInterval(), this._stopSettingsInterval(), this._stopMonitorRtpShareInterval(), this._removeAsrTrack(), this._removeCaptureSender(), this._removeCaptureReceiver(), this._simulcast.reset(), this._pc && (this._rtpReceiversByStreamId = {}, this._disabledSenders.forEach((e) => e.track?.stop()), this._disabledSenders.clear(), this._pc.ontrack = null, this._pc.onconnectionstatechange = null, this._pc.onsignalingstatechange = null, this._sdpStats.stop(), this._peerConnectionStats.stop(), this._participantIdRegistry = null, e._closeDataChannel(this._producerNotification), e._closeDataChannel(this._producerCommand), e._closeDataChannel(this._producerScreen), e._closeDataChannel(this._consumerScreen), e._closeDataChannel(this._asr), e._closeDataChannel(this._animojiDataChannel), this._pc.close(), this._pc = null, this._producerOfferIsProcessing = !1, this._producerNextOffer = null), this._triggerEvent(Y.PEER_CONNECTION_CLOSED);
6024
6109
  }
6025
6110
  static _closeDataChannel(e) {
6026
6111
  e && (e.onopen = null, e.onmessage = null, e.onerror = null, e.close());
@@ -6046,14 +6131,14 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
6046
6131
  }
6047
6132
  this._pc.ontrack = this._onAddTrack.bind(this, this._pc), this._pc.onconnectionstatechange = M.debounce((e) => {
6048
6133
  this._pc && this._onConnectionStateChange(this._pc, e);
6049
- }, 500), this._pc.onsignalingstatechange = this._onSignalingStateChange.bind(this, this._pc), this._sdpStats.observe(this._pc), this._participantIdRegistry = new fi(this._debug), this._signaling.setParticipantIdRegistry(this._participantIdRegistry), this._createDataChannel(this._pc, Tr.producerNotification, (e) => {
6134
+ }, 500), this._pc.onsignalingstatechange = this._onSignalingStateChange.bind(this, this._pc), this._sdpStats.observe(this._pc), this._peerConnectionStats.observe(this._pc), this._participantIdRegistry = new hi(this._debug), this._signaling.setParticipantIdRegistry(this._participantIdRegistry), this._createDataChannel(this._pc, Tr.producerNotification, (e) => {
6050
6135
  this._producerNotification = e, this._producerNotification.binaryType = "arraybuffer", this._signaling.setProducerNotificationDataChannel(e);
6051
6136
  }), this._signaling.useCommandDataChannel(!0), this._createDataChannel(this._pc, Tr.producerCommand, (e) => {
6052
6137
  this._producerCommand = e, this._signaling.setProducerCommandDataChannel(e);
6053
6138
  }), this._createDataChannel(this._pc, Tr.producerScreenShare, (e) => {
6054
6139
  this._producerScreen = e, this._producerScreen.binaryType = "arraybuffer", this._createCaptureReceiver();
6055
6140
  }), N.asrDataChannel && this._createDataChannel(this._pc, Tr.asr, (e) => {
6056
- this._asr = e, this._asr.binaryType = "arraybuffer", this._removeAsrTrack(), this._asrTrack = new li(e, this._participantIdRegistry, (e) => {
6141
+ this._asr = e, this._asr.binaryType = "arraybuffer", this._removeAsrTrack(), this._asrTrack = new fi(e, this._participantIdRegistry, (e) => {
6057
6142
  this._onAsrTranscription(e);
6058
6143
  }, this._debug);
6059
6144
  }), N.vmoji && this._createDataChannel(this._pc, Tr.animoji, (e) => {
@@ -6074,8 +6159,8 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
6074
6159
  _removeAsrTrack() {
6075
6160
  this._asrTrack?.destroy(), this._asrTrack = null;
6076
6161
  }
6077
- _reconnect() {
6078
- this.getState() !== q.OPENED && (this._setState(q.RECONNECTING), this._closeConnection(), this._openConnection(!0));
6162
+ _reconnect(e = !1) {
6163
+ this.getState() !== q.OPENED && (e && this._peerConnectionStats.logIceRestart(), this._setState(q.RECONNECTING), this._closeConnection(), this._openConnection(!0));
6079
6164
  }
6080
6165
  _signalActiveParticipants(e) {
6081
6166
  this._triggerEvent(Y.SIGNALLED_ACTIVE_PARTICIPANTS, e);
@@ -6091,19 +6176,19 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
6091
6176
  }
6092
6177
  _updateSSRCMap(e) {
6093
6178
  e && (this._ssrcMap = {}, this._ssrcMapUpdated = !0, dn(e.sdp).forEach((e) => {
6094
- let t = `a=ssrc:([0-9]+) label:(audio|video)-((?:[ug]?[\\d]+)|(?:mix)|(?:${si.PARTICIPANT_AGNOSTIC_TRACK_PREFIX}-[0-9]+)|(?:${si.TRANSPARENT_AUDIO_TRACK_PREFIX}-[0-9]+))`, n = new RegExp(t).exec(e);
6179
+ let t = `a=ssrc:([0-9]+) label:(audio|video)-((?:[ug]?[\\d]+)|(?:mix)|(?:${ui.PARTICIPANT_AGNOSTIC_TRACK_PREFIX}-[0-9]+)|(?:${ui.TRANSPARENT_AUDIO_TRACK_PREFIX}-[0-9]+))`, n = new RegExp(t).exec(e);
6095
6180
  n && (this._ssrcMap[n[1]] = n[3]);
6096
6181
  }));
6097
6182
  }
6098
6183
  _createCaptureSender(e) {
6099
6184
  let t = this._mediaSource.mediaSettings;
6100
- !e || !this._consumerScreen || !t.isScreenSharingEnabled || (this._captureSender && this._removeCaptureSender(), this._captureSender = new ya(e, this._consumerScreen, this._signaling, t.isFastScreenSharingEnabled, this._debug, this._logger));
6185
+ !e || !this._consumerScreen || !t.isScreenSharingEnabled || (this._captureSender && this._removeCaptureSender(), this._captureSender = new Sa(e, this._consumerScreen, this._signaling, t.isFastScreenSharingEnabled, this._debug, this._logger));
6101
6186
  }
6102
6187
  _removeCaptureSender() {
6103
6188
  this._captureSender?.destroy(), this._captureSender = null;
6104
6189
  }
6105
6190
  _createCaptureReceiver() {
6106
- this._producerScreen && (this._captureReceiver && this._removeCaptureReceiver(), this._captureReceiver = new Gi(this._producerScreen, this._participantIdRegistry, (e, t) => {
6191
+ this._producerScreen && (this._captureReceiver && this._removeCaptureReceiver(), this._captureReceiver = new Ji(this._producerScreen, this._participantIdRegistry, (e, t) => {
6107
6192
  this._triggerEvent(Y.REMOTE_STREAM_SECOND, e, t);
6108
6193
  }, (e) => {
6109
6194
  this._triggerEvent(Y.REMOTE_STREAM_SECOND, e, null);
@@ -6213,7 +6298,7 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
6213
6298
  _detectStaleTracks(e) {
6214
6299
  let t = e.rtps.find((e) => e.type === "inbound-rtp" && e.kind === "audio" && this._ssrcMap[e.ssrc] === "mix");
6215
6300
  if (!t) return;
6216
- let n = si.AUDIO_MIX, r = this._statBytes[n], i = !1;
6301
+ let n = ui.AUDIO_MIX, r = this._statBytes[n], i = !1;
6217
6302
  if (r) {
6218
6303
  let e = t.bytesReceived - r.bytesReceived;
6219
6304
  e >= 0 && e <= 5 && (i = !0), r.stalled !== i && this._triggerEvent(Y.AUDIO_MIX_STALL, i);
@@ -6225,7 +6310,7 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
6225
6310
  }
6226
6311
  _allocateConsumer() {
6227
6312
  if (!this._signaling.ready) return;
6228
- let e = Fa.get();
6313
+ let e = Ra.get();
6229
6314
  !N.videoTracksCount && !this._observer && this._debug.warn("Setting videoTracksCount to 0 is deprecated"), this._signaling.allocateConsumer(null, e).catch((e) => {
6230
6315
  e instanceof En || this._debug.warn("ServerTransport: Unable to allocate consumer", e);
6231
6316
  });
@@ -6358,7 +6443,7 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
6358
6443
  _onConnectionStateChange(e, t) {
6359
6444
  switch (this._debug.debug("[single] connection state changed", { state: e.connectionState }, t), this._logger?.log(C.ICE_CONNECTION_STATE, e.connectionState), e.connectionState) {
6360
6445
  case "failed":
6361
- this._reconnectionPrevented ? this.close(/* @__PURE__ */ Error("Ice connection failed")) : this._reconnect();
6446
+ this._reconnectionPrevented ? this.close(/* @__PURE__ */ Error("Ice connection failed")) : this._reconnect(!0);
6362
6447
  break;
6363
6448
  case "connecting":
6364
6449
  let t = this.getState();
@@ -6401,11 +6486,11 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
6401
6486
  if (!r || !r.length) return this._debug.log(`Cannot get stream waiting time, ${e} receiver has no synchronization sources`), 0;
6402
6487
  let i = r[0].rtpTimestamp;
6403
6488
  if (!Number.isInteger(i)) return this._logger?.log(C.PAT_WAITING_TIME_ERROR, "timestampNotInteger"), this._debug.error(`Cannot get stream waiting time, ${e} receiver's RTP timestamp is not an integer: ${i}`), 0;
6404
- let a = t - i & Sa, o = Math.ceil(a / xa);
6489
+ let a = t - i & Ta, o = Math.ceil(a / wa);
6405
6490
  return Math.min(100, Math.max(0, o));
6406
6491
  }
6407
6492
  async _monitorRtpShare() {
6408
- let e = di.getInstance().value;
6493
+ let e = mi.getInstance().value;
6409
6494
  if (!this._mediaSource.mediaSettings.isFastScreenSharingEnabled || !N.consumerFastScreenShare || e < .6) return;
6410
6495
  let t = this._pc?.getSenders().find((e) => e.track?.kind === A.video && e.track?.contentHint === "motion");
6411
6496
  t && (await t.getStats()).forEach((e) => {
@@ -6436,7 +6521,7 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
6436
6521
  }
6437
6522
  }, Y = /* @__PURE__ */ function(e) {
6438
6523
  return e.REMOTE_TRACK_ADDED = "REMOTE_TRACK_ADDED", e.REMOTE_TRACK_REMOVED = "REMOTE_TRACK_REMOVED", e.REMOTE_STREAM_SECOND = "REMOTE_STREAM_SECOND", e.AUDIO_MIX_STALL = "AUDIO_MIX_STALL", e.REMOTE_DATA_STATS = "REMOTE_DATA_STATS", e.STATE_CHANGED = "STATE_CHANGED", e.LOCAL_STATE_CHANGED = "LOCAL_STATE_CHANGED", e.SIGNALLED_ACTIVE_PARTICIPANTS = "SIGNALLED_ACTIVE_PARTICIPANTS", e.SIGNALLED_SPEAKER_CHANGED = "SIGNALLED_SPEAKER_CHANGED", e.SIGNALLED_STALLED_PARTICIPANTS = "SIGNALLED_STALLED_PARTICIPANTS", e.TOPOLOGY_CHANGED = "TOPOLOGY_CHANGED", e.NETWORK_STATUS = "NETWORK_STATUS", e.PEER_CONNECTION_CLOSED = "PEER_CONNECTION_CLOSED", e.ASR_TRANSCRIPTION = "ASR_TRANSCRIPTION", e.ANIMOJI_STREAM = "ANIMOJI_STREAM", e.ANIMOJI_ERROR = "ANIMOJI_ERROR", e.SCREEN_SHARING_STAT = "SCREEN_SHARING_STAT", e;
6439
- }({}), wa = class extends b {
6524
+ }({}), Da = class extends b {
6440
6525
  constructor(e, t, n, r, i = z, a = null, o = null, s = null, c = null) {
6441
6526
  super(), h(this, "_signaling", void 0), h(this, "_mediaSource", void 0), h(this, "_topology", void 0), h(this, "_allocated", []), h(this, "_opened", []), h(this, "_directTransport", null), h(this, "_serverTransport", null), h(this, "_serverSettings", void 0), h(this, "_dtListeners", []), h(this, "_stListeners", []), h(this, "_states", {}), h(this, "_localState", q.IDLE), h(this, "_animojiReceiver", null), h(this, "_animojiSender", null), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_codecStatsAggregator", void 0), h(this, "_onFirstMediaSent", void 0), h(this, "_firstMediaSentProbeStopped", !1), h(this, "_vadController", null), h(this, "_updateVadTrack", () => {
6442
6527
  this._vadController?.setSendTrack(this._mediaSource.getSendAudioTrack());
@@ -6557,11 +6642,11 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
6557
6642
  }
6558
6643
  }
6559
6644
  _createDirectTransport(e, t = !1) {
6560
- let n = new oi(e, t, this._signaling, this._mediaSource, this._serverSettings, this._debug, this._logger, this._statAggregator, this._codecStatsAggregator, this._getFirstMediaSentCallback());
6645
+ let n = new li(e, t, this._signaling, this._mediaSource, this._serverSettings, this._debug, this._logger, this._statAggregator, this._codecStatsAggregator, this._getFirstMediaSentCallback());
6561
6646
  return this._dtListeners.length > 0 && this._debug.warn(`The list of direct listeners for the participant [${e}] is not empty`), this._dtListeners = [], this._dtListeners.push(n.addEventListener("REMOTE_TRACK_ADDED", this._onRemoteTrackAdded.bind(this, e)), n.addEventListener("REMOTE_TRACK_REMOVED", this._onRemoteTrackRemoved.bind(this, e)), n.addEventListener("REMOTE_DATA_STATS", this._onRemoteDataStats.bind(this)), n.addEventListener("STATE_CHANGED", this._onDirectTransportChanged.bind(this)), n.addEventListener("NETWORK_STATUS", this._onTransportNetworkStatus.bind(this)), n.addEventListener("PEER_CONNECTION_CLOSED", this._onPeerConnectionClosed.bind(this, J.DIRECT))), this._animojiReceiver && this._animojiSender && n.setAnimojiTransport(this._animojiReceiver, this._animojiSender), n;
6562
6647
  }
6563
6648
  _createServerTransport() {
6564
- let e = new Ca(this._signaling, this._mediaSource, this._serverSettings, this._debug, this._logger, this._statAggregator, this._codecStatsAggregator, this._getFirstMediaSentCallback());
6649
+ let e = new Ea(this._signaling, this._mediaSource, this._serverSettings, this._debug, this._logger, this._statAggregator, this._codecStatsAggregator, this._getFirstMediaSentCallback());
6565
6650
  return this._stListeners.length > 0 && this._debug.warn("The list of server transport listeners is not empty"), this._stListeners = [], this._stListeners.push(e.addEventListener("REMOTE_TRACK_ADDED", this._onRemoteTrackAdded.bind(this)), e.addEventListener("REMOTE_TRACK_REMOVED", this._onRemoteTrackRemoved.bind(this)), e.addEventListener("AUDIO_MIX_STALL", this._onServerAudioMixStall.bind(this)), e.addEventListener("REMOTE_DATA_STATS", this._onRemoteDataStats.bind(this)), e.addEventListener("STATE_CHANGED", this._onServerTransportChanged.bind(this)), e.addEventListener("SIGNALLED_ACTIVE_PARTICIPANTS", this._onTransportActiveParticipants.bind(this)), e.addEventListener("SIGNALLED_SPEAKER_CHANGED", this._onTransportSpeakerChanged.bind(this)), e.addEventListener("SIGNALLED_STALLED_PARTICIPANTS", this._onTransportStalledParticipants.bind(this)), e.addEventListener("NETWORK_STATUS", this._onTransportNetworkStatus.bind(this)), e.addEventListener("REMOTE_STREAM_SECOND", this._onRemoteStreamSecond.bind(this)), e.addEventListener("PEER_CONNECTION_CLOSED", this._onPeerConnectionClosed.bind(this, J.SERVER)), e.addEventListener("ASR_TRANSCRIPTION", this._onAsrTranscription.bind(this))), this._animojiReceiver && this._animojiSender && e.setAnimojiTransport(this._animojiReceiver, this._animojiSender), e;
6566
6651
  }
6567
6652
  _releaseDirectTransport() {
@@ -6653,20 +6738,20 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
6653
6738
  getStreamWaitingTimeMs(e, t) {
6654
6739
  return this._topology === J.SERVER ? this._serverTransport ? this._serverTransport.getStreamWaitingTimeMs(e, t) : (this._logger?.log(C.PAT_WAITING_TIME_ERROR, "noTransport"), this._debug.error("Cannot get stream waiting time, server transport is not initialized"), 0) : (this._logger?.log(C.PAT_WAITING_TIME_ERROR, "wrongTopology"), this._debug.error(`Cannot get stream waiting time, incorrect topology: ${this._topology}`), 0);
6655
6740
  }
6656
- }, Ta = "videochat-epi", Ea = 5e3, Da = 500, Oa = 300 * 1e3, ka = class extends b {
6741
+ }, Oa = "videochat-epi", ka = 5e3, Aa = 500, ja = 120 * 1e3, Ma = class extends b {
6657
6742
  constructor(e, t, n = null, r = !1, i = z) {
6658
- super(), h(this, "_previousPerfStatReportTimestamp", 0), h(this, "_previousNetworkStatReportTimestamp", Date.now()), h(this, "_previousCallStatReportTimestamp", Date.now()), h(this, "_previousCallStatReport", null), h(this, "_previousRemoteInboundRtps", /* @__PURE__ */ new Map()), h(this, "_screenShareStats", []), h(this, "_signaling", void 0), h(this, "_directTopology", void 0), h(this, "_debug", void 0), h(this, "_statAggregator", void 0), h(this, "_handleScreenSharingStat", (e) => {
6743
+ super(), h(this, "_previousPerfStatReportTimestamp", 0), h(this, "_previousNetworkStatReportTimestamp", Date.now()), h(this, "_previousCallStatReportTimestamp", Date.now()), h(this, "_previousCallStatReport", null), h(this, "_previousRemoteInboundRtps", /* @__PURE__ */ new Map()), h(this, "_previousCandidatePair", null), h(this, "_screenShareStats", []), h(this, "_signaling", void 0), h(this, "_directTopology", void 0), h(this, "_debug", void 0), h(this, "_statAggregator", void 0), h(this, "_handleScreenSharingStat", (e) => {
6659
6744
  this._screenShareStats.push(e);
6660
6745
  }), h(this, "_handleTransportStateChanged", (e) => {
6661
6746
  (this._directTopology && e === q.CONNECTED || !this._directTopology && e === q.OPENED) && (this._previousNetworkStatReportTimestamp = Date.now(), this._previousCallStatReportTimestamp = Date.now(), this._previousRemoteInboundRtps.clear());
6662
6747
  }), this._signaling = t, this._directTopology = r, this._debug = i, this._statAggregator = n, this.subscribe(e, Y.REMOTE_DATA_STATS, this._handleStats.bind(this)), this.subscribe(e, Y.SCREEN_SHARING_STAT, this._handleScreenSharingStat.bind(this)), this.subscribe(e, Y.STATE_CHANGED, this._handleTransportStateChanged.bind(this));
6663
6748
  }
6664
6749
  destroy() {
6665
- this._previousRemoteInboundRtps.clear(), this.unsubscribe();
6750
+ this._previousRemoteInboundRtps.clear(), this._previousCandidatePair = null, this.unsubscribe();
6666
6751
  }
6667
6752
  static getEstimatedPerformanceIndex() {
6668
6753
  try {
6669
- let e = parseInt(localStorage.getItem(Ta) || "", 10);
6754
+ let e = parseInt(localStorage.getItem(Oa) || "", 10);
6670
6755
  return isNaN(e) ? 0 : e;
6671
6756
  } catch {
6672
6757
  return 0;
@@ -6675,9 +6760,9 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
6675
6760
  async _handleStats(e) {
6676
6761
  if (!e.inbound || !e.inbound.rtps) return;
6677
6762
  let t = Date.now();
6678
- !this._directTopology && N.perfStatReportEnabled && this._previousPerfStatReportTimestamp + Ea <= t && (await this.reportPerfStats(e), this._previousPerfStatReportTimestamp = t);
6763
+ !this._directTopology && N.perfStatReportEnabled && this._previousPerfStatReportTimestamp + ka <= t && (await this.reportPerfStats(e), this._previousPerfStatReportTimestamp = t);
6679
6764
  let n = e.outbound.transport.local?.protocol === "tcp";
6680
- !this._directTopology && n && this._previousNetworkStatReportTimestamp + Da <= t && (await this.reportNetworkStats(e), this._previousNetworkStatReportTimestamp = t), N.callStatReportEnabled && this._previousCallStatReportTimestamp + N.statisticsInterval <= t && (this._reportCallStats(e), this._previousCallStatReportTimestamp = t);
6765
+ !this._directTopology && n && this._previousNetworkStatReportTimestamp + Aa <= t && (await this.reportNetworkStats(e), this._previousNetworkStatReportTimestamp = t), this._reportCandidatePair(e.inbound.transport.local, e.inbound.transport.remote), N.callStatReportEnabled && this._previousCallStatReportTimestamp + N.statisticsInterval <= t && (this._reportCallStats(e), this._previousCallStatReportTimestamp = t);
6681
6766
  }
6682
6767
  async reportPerfStats(e) {
6683
6768
  let t = e.inbound.rtps.reduce((e, t) => (t.kind === "video" && (e.framesDecoded += t.framesDecoded || 0, e.framesReceived += t.framesReceived || 0), e), {
@@ -6686,7 +6771,7 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
6686
6771
  });
6687
6772
  if (t.framesDecoded) try {
6688
6773
  let e = await this._signaling.reportPerfStat(t);
6689
- localStorage.setItem(Ta, e.estimatedPerformanceIndex);
6774
+ localStorage.setItem(Oa, e.estimatedPerformanceIndex);
6690
6775
  } catch {}
6691
6776
  }
6692
6777
  async reportNetworkStats(e) {
@@ -6726,11 +6811,11 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
6726
6811
  rtt: Math.round(e.inbound.transport.currentRoundTripTime * 1e3),
6727
6812
  ss_freeze_count: 0,
6728
6813
  ss_total_freezes_duration: 0,
6729
- local_address: ja(e.inbound.transport.local),
6814
+ local_address: Pa(e.inbound.transport.local),
6730
6815
  local_connection_type: e.inbound.transport.local?.type,
6731
6816
  network_type: e.inbound.transport.local?.networkType,
6732
6817
  transport: e.inbound.transport.local?.protocol,
6733
- remote_address: ja(e.inbound.transport.remote),
6818
+ remote_address: Pa(e.inbound.transport.remote),
6734
6819
  remote_connection_type: e.inbound.transport.remote?.type
6735
6820
  };
6736
6821
  this._previousCallStatReport || (this._previousCallStatReport = Object.assign({}, t));
@@ -6741,7 +6826,7 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
6741
6826
  }
6742
6827
  let i = {
6743
6828
  call_topology: t.call_topology,
6744
- stat_time_delta: Math.min(Oa, Math.max(0, Date.now() - this._previousCallStatReportTimestamp)),
6829
+ stat_time_delta: Math.min(ja, Math.max(0, Date.now() - this._previousCallStatReportTimestamp)),
6745
6830
  nack_sent: Math.max(0, t.nack_sent - this._previousCallStatReport.nack_sent),
6746
6831
  nack_received: Math.max(0, t.nack_received - this._previousCallStatReport.nack_received),
6747
6832
  pli_sent: Math.max(0, t.pli_sent - this._previousCallStatReport.pli_sent),
@@ -6751,14 +6836,28 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
6751
6836
  frames_dropped: Math.max(0, t.frames_dropped - this._previousCallStatReport.frames_dropped),
6752
6837
  rtt: Math.max(0, t.rtt)
6753
6838
  };
6754
- if (N.simulcast && (i.is_simulcast = !0), navigator.hardwareConcurrency && (i.cpu_hardware_concurrency = navigator.hardwareConcurrency), n && !Ma(t.jitter_video) && (i.jitter_video = Math.round(t.jitter_video)), r && !Ma(t.jitter_audio) && (i.jitter_audio = Math.round(t.jitter_audio)), n && !Ma(t.interframe_delay_variance) && (i.interframe_delay_variance = t.interframe_delay_variance), t.freeze_count && t.total_freezes_duration && (i.freeze_count = t.freeze_count, i.total_freezes_duration = Math.round(t.total_freezes_duration * 1e3)), t.ss_freeze_count && t.ss_total_freezes_duration && (i.ss_freeze_count = t.ss_freeze_count, i.ss_total_freezes_duration = t.ss_total_freezes_duration), r && !Ma(t.total_audio_samples_received)) {
6839
+ if (N.simulcast && (i.is_simulcast = !0), navigator.hardwareConcurrency && (i.cpu_hardware_concurrency = navigator.hardwareConcurrency), n && !Fa(t.jitter_video) && (i.jitter_video = Math.round(t.jitter_video)), r && !Fa(t.jitter_audio) && (i.jitter_audio = Math.round(t.jitter_audio)), n && !Fa(t.interframe_delay_variance) && (i.interframe_delay_variance = t.interframe_delay_variance), t.freeze_count && t.total_freezes_duration && (i.freeze_count = t.freeze_count, i.total_freezes_duration = Math.round(t.total_freezes_duration * 1e3)), t.ss_freeze_count && t.ss_total_freezes_duration && (i.ss_freeze_count = t.ss_freeze_count, i.ss_total_freezes_duration = t.ss_total_freezes_duration), r && !Fa(t.total_audio_samples_received)) {
6755
6840
  let e = Math.max(0, t.total_audio_samples_received - this._previousCallStatReport.total_audio_samples_received), n = Math.max(0, t.inserted_audio_samples_for_deceleration - this._previousCallStatReport.inserted_audio_samples_for_deceleration), r = Math.max(0, t.removed_audio_samples_for_acceleration - this._previousCallStatReport.removed_audio_samples_for_acceleration), a = Math.max(0, t.concealed_audio_samples - this._previousCallStatReport.concealed_audio_samples), o = Math.max(0, t.silent_concealed_audio_samples - this._previousCallStatReport.silent_concealed_audio_samples), s = Math.max(0, t.audio_concealment_events - this._previousCallStatReport.audio_concealment_events);
6756
- i.inserted_audio_samples_for_deceleration = Na(n / e * 1e3), i.removed_audio_samples_for_acceleration = Na(r / e * 1e3), i.concealed_audio_samples = Na(a / e * 1e3), i.concealed_silent_audio_samples = Na(o / e * 1e3), i.concealment_audio_avg_size = Na(a / s), i.total_audio_energy = t.total_audio_energy;
6841
+ i.inserted_audio_samples_for_deceleration = Ia(n / e * 1e3), i.removed_audio_samples_for_acceleration = Ia(r / e * 1e3), i.concealed_audio_samples = Ia(a / e * 1e3), i.concealed_silent_audio_samples = Ia(o / e * 1e3), i.concealment_audio_avg_size = Ia(a / s), i.total_audio_energy = t.total_audio_energy;
6757
6842
  }
6758
- Aa(t, "local_address", "local_connection_type", "network_type", "transport") && (i.local_address = t.local_address, i.local_connection_type = t.local_connection_type, i.network_type = t.network_type, i.transport = t.transport), Aa(t, "remote_address", "remote_connection_type") && (i.remote_address = t.remote_address, i.remote_connection_type = t.remote_connection_type);
6843
+ Na(t, "local_address", "local_connection_type", "network_type", "transport") && (i.local_address = t.local_address, i.local_connection_type = t.local_connection_type, i.network_type = t.network_type, i.transport = t.transport), Na(t, "remote_address", "remote_connection_type") && (i.remote_address = t.remote_address, i.remote_connection_type = t.remote_connection_type);
6759
6844
  let a = this._calculatePacketLoss(e.remoteInbound.rtps);
6760
6845
  a.video !== void 0 && (i.video_loss = a.video), a.audio !== void 0 && (i.audio_loss = a.audio), this._statAggregator?.logCallStat(i), N.enableLogPerfStatReport && this._debug.log("Sent call stats", i), this._previousCallStatReport = t;
6761
6846
  }
6847
+ _reportCandidatePair(e, t) {
6848
+ if (!e?.address || !t?.address) return;
6849
+ let n = JSON.stringify({
6850
+ local: e,
6851
+ remote: t
6852
+ });
6853
+ n !== this._previousCandidatePair && (this._previousCandidatePair = n, this._statAggregator?.logEventualStat({
6854
+ name: U.ICE_CANDIDATES_CHANGED,
6855
+ string_value: n,
6856
+ local_address: Pa(e),
6857
+ remote_address: Pa(t),
6858
+ transport: e.protocol
6859
+ }));
6860
+ }
6762
6861
  _calculatePacketLoss(e) {
6763
6862
  let t = /* @__PURE__ */ new Map(), n = {
6764
6863
  audio: {
@@ -6787,26 +6886,26 @@ var zi = 2 ** 15 - 1, Bi = 1, Vi = 5, Hi = 5, Ui = class e {
6787
6886
  return r;
6788
6887
  }
6789
6888
  };
6790
- function Aa(e, ...t) {
6889
+ function Na(e, ...t) {
6791
6890
  for (let n of t) if (!Object.hasOwn(e, n) || e[n] === void 0) return !1;
6792
6891
  return !0;
6793
6892
  }
6794
- function ja(e, t = !1) {
6893
+ function Pa(e, t = !1) {
6795
6894
  if (e?.address) return e.address + (t ? `:${e.port}` : "");
6796
6895
  }
6797
- function Ma(e) {
6896
+ function Fa(e) {
6798
6897
  return e === void 0;
6799
6898
  }
6800
- function Na(e) {
6899
+ function Ia(e) {
6801
6900
  return Number.isNaN(e) ? 0 : e;
6802
6901
  }
6803
6902
  //#endregion
6804
6903
  //#region src/static/Capabilities.ts
6805
- var Pa;
6904
+ var La;
6806
6905
  (function(e) {
6807
6906
  function t() {
6808
6907
  return {
6809
- estimatedPerformanceIndex: ka.getEstimatedPerformanceIndex(),
6908
+ estimatedPerformanceIndex: Ma.getEstimatedPerformanceIndex(),
6810
6909
  audioMix: !0,
6811
6910
  consumerUpdate: !0,
6812
6911
  producerNotificationDataChannelVersion: 8,
@@ -6832,8 +6931,8 @@ var Pa;
6832
6931
  };
6833
6932
  }
6834
6933
  e.get = t;
6835
- })(Pa || (Pa = {}));
6836
- var Fa = Pa, Ia = {
6934
+ })(La || (La = {}));
6935
+ var Ra = La, za = {
6837
6936
  producerScreenTrack: () => !0,
6838
6937
  videoTracksCount: () => N.videoTracksCount > 0,
6839
6938
  waitingHall: () => !0,
@@ -6853,28 +6952,28 @@ var Fa = Pa, Ia = {
6853
6952
  p2pRelay: () => !1,
6854
6953
  waitForAdmin: () => N.waitForAdminInGroupCalls,
6855
6954
  hold: () => N.hold
6856
- }, La = class {
6955
+ }, Ba = class {
6857
6956
  static getFlags() {
6858
- let e = Object.values(Ia), t = 0;
6957
+ let e = Object.values(za), t = 0;
6859
6958
  for (let n = 0; n < e.length; n++) e[n]() && (t |= 1 << n);
6860
6959
  return t.toString(16).toUpperCase();
6861
6960
  }
6862
6961
  static parseCapabilities(e) {
6863
6962
  let t = parseInt(e || "0", 16);
6864
- return Object.keys(Ia).reduce((e, n, r) => (e[n] = !!(t & 1 << r), e), {});
6963
+ return Object.keys(za).reduce((e, n, r) => (e[n] = !!(t & 1 << r), e), {});
6865
6964
  }
6866
- }, Ra = 63n, za = 16383n, Ba = 1073741823, Va = 4611686018427387903n, Ha = class {
6965
+ }, Va = 63n, Ha = 16383n, Ua = 1073741823, Wa = 4611686018427387903n, Ga = class {
6867
6966
  encode(e) {
6868
6967
  let t = typeof e == "number" ? BigInt(e) : e;
6869
- if (t <= Ra) return new Uint8Array([Number(t)]);
6870
- if (t <= za) return new Uint8Array([64 | Number(t >> 8n), Number(t & 255n)]);
6871
- if (t <= BigInt(Ba)) return new Uint8Array([
6968
+ if (t <= Va) return new Uint8Array([Number(t)]);
6969
+ if (t <= Ha) return new Uint8Array([64 | Number(t >> 8n), Number(t & 255n)]);
6970
+ if (t <= BigInt(Ua)) return new Uint8Array([
6872
6971
  128 | Number(t >> 24n),
6873
6972
  Number(t >> 16n & 255n),
6874
6973
  Number(t >> 8n & 255n),
6875
6974
  Number(t & 255n)
6876
6975
  ]);
6877
- if (t <= Va) return new Uint8Array([
6976
+ if (t <= Wa) return new Uint8Array([
6878
6977
  192 | Number(t >> 56n),
6879
6978
  Number(t >> 48n & 255n),
6880
6979
  Number(t >> 40n & 255n),
@@ -6886,7 +6985,7 @@ var Fa = Pa, Ia = {
6886
6985
  ]);
6887
6986
  throw RangeError("Number is too large to encode using varint");
6888
6987
  }
6889
- }, Ua = class {
6988
+ }, Ka = class {
6890
6989
  decode(e) {
6891
6990
  let t = this.getNumBytesForLengthInteger(e);
6892
6991
  if (t < 0) throw Error("Invalid length prefix");
@@ -6912,9 +7011,9 @@ var Fa = Pa, Ia = {
6912
7011
  let t = e[0] & 192;
6913
7012
  return t === 0 ? 1 : t === 64 ? 2 : t === 128 ? 4 : t === 192 ? 8 : -1;
6914
7013
  }
6915
- }, Wa = class {
7014
+ }, qa = class {
6916
7015
  constructor(e) {
6917
- h(this, "encoder", void 0), h(this, "compression", void 0), h(this, "lengthEncoder", void 0), this.encoder = new TextEncoder(), this.lengthEncoder = new Ha(), this.compression = e ?? null;
7016
+ h(this, "encoder", void 0), h(this, "compression", void 0), h(this, "lengthEncoder", void 0), this.encoder = new TextEncoder(), this.lengthEncoder = new Ga(), this.compression = e ?? null;
6918
7017
  }
6919
7018
  encode(e) {
6920
7019
  let t = this.encoder.encode(e);
@@ -6931,9 +7030,9 @@ var Fa = Pa, Ia = {
6931
7030
  default: return e;
6932
7031
  }
6933
7032
  }
6934
- }, Ga = class {
7033
+ }, Ja = class {
6935
7034
  constructor(e) {
6936
- h(this, "decoder", void 0), h(this, "compression", void 0), h(this, "lengthDecoder", void 0), h(this, "buffer", void 0), h(this, "expectedLength", void 0), h(this, "offset", void 0), h(this, "lengthPrefixLength", void 0), this.decoder = new TextDecoder(), this.lengthDecoder = new Ua(), this.compression = e ?? null, this.buffer = new Uint8Array(), this.expectedLength = null, this.offset = 0;
7035
+ h(this, "decoder", void 0), h(this, "compression", void 0), h(this, "lengthDecoder", void 0), h(this, "buffer", void 0), h(this, "expectedLength", void 0), h(this, "offset", void 0), h(this, "lengthPrefixLength", void 0), this.decoder = new TextDecoder(), this.lengthDecoder = new Ka(), this.compression = e ?? null, this.buffer = new Uint8Array(), this.expectedLength = null, this.offset = 0;
6937
7036
  }
6938
7037
  decode(e) {
6939
7038
  let t = [];
@@ -6963,12 +7062,12 @@ var Fa = Pa, Ia = {
6963
7062
  default: return e;
6964
7063
  }
6965
7064
  }
6966
- }, Ka = class {
7065
+ }, Ya = class {
6967
7066
  static isBrowserSupported() {
6968
7067
  return !(!("WebTransport" in window && typeof WebTransport == "function") || E.browserName() === "Safari");
6969
7068
  }
6970
7069
  constructor(e, t = {}, n = z) {
6971
- h(this, "onopen", null), h(this, "onmessage", null), h(this, "onerror", null), h(this, "onclose", null), h(this, "readyState", WebSocket.CONNECTING), h(this, "webTransport", null), h(this, "writer", null), h(this, "url", void 0), h(this, "options", void 0), h(this, "compression", void 0), h(this, "encoder", void 0), h(this, "decoder", void 0), h(this, "_debug", void 0), this._debug = n, this.url = e, this.options = t, this.compression = this.getCompressionTypeFromUrl(e), this.encoder = new Wa(this.compression), this.decoder = new Ga(this.compression), this.connect();
7070
+ h(this, "onopen", null), h(this, "onmessage", null), h(this, "onerror", null), h(this, "onclose", null), h(this, "readyState", WebSocket.CONNECTING), h(this, "webTransport", null), h(this, "writer", null), h(this, "url", void 0), h(this, "options", void 0), h(this, "compression", void 0), h(this, "encoder", void 0), h(this, "decoder", void 0), h(this, "_debug", void 0), this._debug = n, this.url = e, this.options = t, this.compression = this.getCompressionTypeFromUrl(e), this.encoder = new qa(this.compression), this.decoder = new Ja(this.compression), this.connect();
6972
7071
  }
6973
7072
  async send(e) {
6974
7073
  if (this.readyState !== WebSocket.OPEN) {
@@ -7094,11 +7193,11 @@ var Fa = Pa, Ia = {
7094
7193
  compression: this.compression
7095
7194
  }, n;
7096
7195
  }
7097
- }, qa = /* @__PURE__ */ function(e) {
7098
- return e.EMPTY_ENDPOINT = "EMPTY_ENDPOINT", e.NETWORK_ERROR = "NETWORK_ERROR", e.ABORTED = "ABORTED", e;
7099
- }({}), Ja = class {
7196
+ }, Xa = /* @__PURE__ */ function(e) {
7197
+ return e.EMPTY_ENDPOINT = "EMPTY_ENDPOINT", e.NETWORK_ERROR = "NETWORK_ERROR", e.RECONNECT_TIMEOUT = "RECONNECT_TIMEOUT", e.ABORTED = "ABORTED", e;
7198
+ }({}), Za = class {
7100
7199
  constructor(e = z, t) {
7101
- h(this, "handlers", void 0), h(this, "socket", null), h(this, "endpoint", ""), h(this, "wtEndpoint", null), h(this, "peerId", null), h(this, "lastStamp", 0), h(this, "connectionType", void 0), h(this, "reconnectCount", 0), h(this, "reconnectTimer", 0), h(this, "doctorTimer", 0), h(this, "forceWebSocket", !1), h(this, "abortSignal", void 0), h(this, "manualClose", !1), h(this, "currentType", Sr.WEBSOCKET), h(this, "_debug", void 0), this.handlers = t, this._debug = e;
7200
+ h(this, "handlers", void 0), h(this, "socket", null), h(this, "endpoint", ""), h(this, "wtEndpoint", null), h(this, "peerId", null), h(this, "lastStamp", 0), h(this, "connectionType", void 0), h(this, "reconnectCount", 0), h(this, "reconnectTimer", 0), h(this, "reconnectDeadlineTimer", 0), h(this, "doctorTimer", 0), h(this, "forceWebSocket", !1), h(this, "abortSignal", void 0), h(this, "manualClose", !1), h(this, "currentType", Sr.WEBSOCKET), h(this, "_debug", void 0), this.handlers = t, this._debug = e;
7102
7201
  }
7103
7202
  get readyState() {
7104
7203
  return this.socket?.readyState ?? null;
@@ -7121,14 +7220,14 @@ var Fa = Pa, Ia = {
7121
7220
  setAbortSignal(e) {
7122
7221
  this.abortSignal = e;
7123
7222
  }
7124
- resetReconnectCount() {
7125
- this.reconnectCount = 0;
7223
+ onConnectionRestored() {
7224
+ this.reconnectCount = 0, this._stopReconnectDeadline();
7126
7225
  }
7127
7226
  connect(e) {
7128
7227
  this.socket && this.socket.readyState < WebSocket.CLOSING || (e !== br.RETRY && (this.forceWebSocket = !1, this.reconnectCount = 0), this.manualClose = !1, this.connectionType = e, this._connect());
7129
7228
  }
7130
7229
  close(e) {
7131
- this.manualClose = !0, this._disconnect(e), window.clearTimeout(this.reconnectTimer), this.reconnectTimer = 0, this.lastStamp = 0;
7230
+ this.manualClose = !0, this._disconnect(e), window.clearTimeout(this.reconnectTimer), this.reconnectTimer = 0, this._stopReconnectDeadline(), this.lastStamp = 0;
7132
7231
  }
7133
7232
  async send(e) {
7134
7233
  await this.socket?.send(e);
@@ -7146,7 +7245,7 @@ var Fa = Pa, Ia = {
7146
7245
  return;
7147
7246
  }
7148
7247
  let e = this._buildUrl(this.wtEndpoint, !0);
7149
- this.currentType = Sr.WEBTRANSPORT, this.socket = new Ka(e, { congestionControl: "low-latency" }, this._debug), this._setSocketHandlers();
7248
+ this.currentType = Sr.WEBTRANSPORT, this.socket = new Ya(e, { congestionControl: "low-latency" }, this._debug), this._setSocketHandlers();
7150
7249
  }
7151
7250
  _connectWebSocket() {
7152
7251
  if (!this.endpoint) {
@@ -7169,10 +7268,10 @@ var Fa = Pa, Ia = {
7169
7268
  }
7170
7269
  _buildUrl(e, t) {
7171
7270
  let n = new URL(e), r = n.searchParams;
7172
- return r.set("platform", N.platform), r.set("appVersion", N.appVersion), r.set("version", String(N.protocolVersion)), r.set("device", N.device), r.set("capabilities", La.getFlags()), r.set("clientType", N.clientType), this.connectionType && r.set("tgt", this.connectionType), this.connectionType === br.RETRY && this.lastStamp && r.set("recoverTs", String(this.lastStamp)), N.useParticipantListChunk && (r.set("partIdx", String(N.participantListChunkInitIndex)), N.participantListChunkInitCount !== null && r.set("partCount", String(N.participantListChunkInitCount))), t && (r.set("compression", "deflate-raw"), r.set("ua", navigator.userAgent)), this.peerId !== null && r.set("peerId", String(this.peerId)), n.toString();
7271
+ return r.set("platform", N.platform), r.set("appVersion", N.appVersion), r.set("version", String(N.protocolVersion)), r.set("device", N.device), r.set("capabilities", Ba.getFlags()), r.set("clientType", N.clientType), this.connectionType && r.set("tgt", this.connectionType), this.connectionType === br.RETRY && this.lastStamp && r.set("recoverTs", String(this.lastStamp)), N.useParticipantListChunk && (r.set("partIdx", String(N.participantListChunkInitIndex)), N.participantListChunkInitCount !== null && r.set("partCount", String(N.participantListChunkInitCount))), t && (r.set("compression", "deflate-raw"), r.set("ua", navigator.userAgent)), this.peerId !== null && r.set("peerId", String(this.peerId)), n.toString();
7173
7272
  }
7174
7273
  _canUseWebTransport() {
7175
- return !this.forceWebSocket && Ka.isBrowserSupported() && this.wtEndpoint !== null && N.webtransport;
7274
+ return !this.forceWebSocket && Ya.isBrowserSupported() && this.wtEndpoint !== null && N.webtransport;
7176
7275
  }
7177
7276
  _onOpen() {
7178
7277
  this._startDoctor(), this.handlers.onOpen();
@@ -7201,20 +7300,32 @@ var Fa = Pa, Ia = {
7201
7300
  }
7202
7301
  _scheduleReconnect(e = this._getReconnectDelay()) {
7203
7302
  if (this.reconnectCount >= N.signalingReconnectMaxCount) {
7204
- this.handlers.onFailed({
7303
+ this._stopReconnectDeadline(), this.handlers.onFailed({
7205
7304
  failure: "NETWORK_ERROR",
7206
7305
  message: "Unable to connect to the signaling: reconnect attempts exhausted",
7207
7306
  source: this.currentType
7208
7307
  });
7209
7308
  return;
7210
7309
  }
7211
- this.reconnectCount++, this.handlers.onReconnectScheduled({
7310
+ this._startReconnectDeadline(), this.reconnectCount++, this.handlers.onReconnectScheduled({
7212
7311
  count: this.reconnectCount,
7213
7312
  delay: e
7214
7313
  }), this.reconnectTimer = window.setTimeout(() => {
7215
7314
  this.connectionType = br.RETRY, this._connect();
7216
7315
  }, e);
7217
7316
  }
7317
+ _startReconnectDeadline() {
7318
+ this.reconnectDeadlineTimer || (this.reconnectDeadlineTimer = window.setTimeout(() => {
7319
+ this.reconnectDeadlineTimer = 0, window.clearTimeout(this.reconnectTimer), this.reconnectTimer = 0, this._disconnect(4e3), this.handlers.onFailed({
7320
+ failure: "RECONNECT_TIMEOUT",
7321
+ message: "Unable to connect to the signaling: reconnect timeout",
7322
+ source: this.currentType
7323
+ });
7324
+ }, N.signalingReconnectMaxDuration));
7325
+ }
7326
+ _stopReconnectDeadline() {
7327
+ window.clearTimeout(this.reconnectDeadlineTimer), this.reconnectDeadlineTimer = 0;
7328
+ }
7218
7329
  _getReconnectDelay() {
7219
7330
  return Math.min(N.signalingReconnectMaxDelay, N.signalingReconnectDelay * 2 ** this.reconnectCount);
7220
7331
  }
@@ -7226,31 +7337,31 @@ var Fa = Pa, Ia = {
7226
7337
  _stopDoctor() {
7227
7338
  window.clearTimeout(this.doctorTimer), this.doctorTimer = 0;
7228
7339
  }
7229
- }, Ya = "open", Xa = 300, Za = 10, Qa = {
7340
+ }, Qa = "open", $a = 300, eo = 10, to = {
7230
7341
  CONVERSATION_ENDED: "conversation-ended",
7231
7342
  OBSOLETE_CLIENT: "gen.obsoleteClient",
7232
7343
  INVALID_TOKEN: "invalid-token",
7233
7344
  PARTICIPANT_NOT_FOUND: "participant-not-found",
7234
7345
  ILLEGAL_PARTICIPANT_STATE: "illegal-participant-state",
7235
7346
  SERVICE_UNAVAILABLE: "service-unavailable"
7236
- }, $a = {
7237
- [Qa.CONVERSATION_ENDED]: "conversation-ended",
7238
- [Qa.OBSOLETE_CLIENT]: "obsolete-client",
7239
- [Qa.INVALID_TOKEN]: "invalid-token",
7240
- [Qa.PARTICIPANT_NOT_FOUND]: "participant-not-found",
7241
- [Qa.ILLEGAL_PARTICIPANT_STATE]: "illegal-participant-state",
7242
- [Qa.SERVICE_UNAVAILABLE]: "service-unavailable"
7347
+ }, no = {
7348
+ [to.CONVERSATION_ENDED]: "conversation-ended",
7349
+ [to.OBSOLETE_CLIENT]: "obsolete-client",
7350
+ [to.INVALID_TOKEN]: "invalid-token",
7351
+ [to.PARTICIPANT_NOT_FOUND]: "participant-not-found",
7352
+ [to.ILLEGAL_PARTICIPANT_STATE]: "illegal-participant-state",
7353
+ [to.SERVICE_UNAVAILABLE]: "service-unavailable"
7243
7354
  };
7244
- function eo(e, t) {
7355
+ function ro(e, t) {
7245
7356
  return e.errorMessage ?? e.message ?? e.error ?? t;
7246
7357
  }
7247
- var to = new Set([
7358
+ var io = new Set([
7248
7359
  O.CALLER_IS_BLOCKED,
7249
7360
  O.ENDED,
7250
7361
  O.NOT_FOUND,
7251
7362
  O.PARTICIPANT_LIMIT_REACHED,
7252
7363
  O.SERVICE_UNAVAILABLE
7253
- ]), no = class e extends On {
7364
+ ]), ao = class e extends On {
7254
7365
  static get WAIT_CONNECTION_DELAY() {
7255
7366
  return N.waitConnectionDelay;
7256
7367
  }
@@ -7261,7 +7372,7 @@ var to = new Set([
7261
7372
  return !this.disposed && this.transport.readyState !== null;
7262
7373
  }
7263
7374
  constructor(e = z, t = null, n = null, r = null, i = null) {
7264
- super(), h(this, "transport", void 0), h(this, "sequence", 1), h(this, "lastStamp", 0), h(this, "websocketCommandsQueue", []), h(this, "datachannelCommandsQueue", []), h(this, "incomingCache", []), h(this, "responseHandlers", {}), h(this, "disposed", !1), h(this, "connectionType", void 0), h(this, "conversationResolve", null), h(this, "conversationReject", null), h(this, "connected", !1), h(this, "listenersReady", !1), h(this, "peerId", null), h(this, "reconnectStartedAt", null), h(this, "connectionMessageWaitTimer", 0), h(this, "participantIdRegistry", null), h(this, "producerNotificationDataChannel", null), h(this, "producerCommandDataChannel", null), h(this, "producerCommandDataChannelEnabled", !1), h(this, "producerCommandSerializationService", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_statPings", void 0), h(this, "_statSignalingCommands", void 0), this._debug = e, this._logger = t, this._statAggregator = n, this._statPings = r, this._statSignalingCommands = i, this.producerCommandSerializationService = new tr(e), this.transport = new Ja(e, {
7375
+ super(), h(this, "transport", void 0), h(this, "sequence", 1), h(this, "lastStamp", 0), h(this, "websocketCommandsQueue", []), h(this, "datachannelCommandsQueue", []), h(this, "incomingCache", []), h(this, "responseHandlers", {}), h(this, "disposed", !1), h(this, "connectionType", void 0), h(this, "conversationResolve", null), h(this, "conversationReject", null), h(this, "connected", !1), h(this, "listenersReady", !1), h(this, "peerId", null), h(this, "reconnectStartedAt", null), h(this, "connectionMessageWaitTimer", 0), h(this, "participantIdRegistry", null), h(this, "producerNotificationDataChannel", null), h(this, "producerCommandDataChannel", null), h(this, "producerCommandDataChannelEnabled", !1), h(this, "producerCommandSerializationService", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_statPings", void 0), h(this, "_statSignalingCommands", void 0), this._debug = e, this._logger = t, this._statAggregator = n, this._statPings = r, this._statSignalingCommands = i, this.producerCommandSerializationService = new tr(e), this.transport = new Za(e, {
7265
7376
  onConnecting: this._onTransportConnecting.bind(this),
7266
7377
  onOpen: this._onOpen.bind(this),
7267
7378
  onMessage: this._onMessage.bind(this),
@@ -7348,20 +7459,20 @@ var to = new Set([
7348
7459
  return this._send(V.TRANSMIT_DATA, {
7349
7460
  participantId: e,
7350
7461
  data: r
7351
- }, !0, Za);
7462
+ }, !0, eo);
7352
7463
  }
7353
7464
  async acceptCall(e) {
7354
7465
  return this._send(V.ACCEPT_CALL, { mediaSettings: e });
7355
7466
  }
7356
7467
  async changeMediaSettings(e) {
7357
- return this._send(V.CHANGE_MEDIA_SETTINGS, { mediaSettings: e }, !0, Za);
7468
+ return this._send(V.CHANGE_MEDIA_SETTINGS, { mediaSettings: e }, !0, eo);
7358
7469
  }
7359
7470
  async changeParticipantState(e, t) {
7360
7471
  let n = { participantState: { state: e } };
7361
7472
  return t && (n.participantId = t), this._sendRaw(V.CHANGE_PARTICIPANT_STATE, n);
7362
7473
  }
7363
7474
  async hold(e) {
7364
- let t = Fa.get();
7475
+ let t = Ra.get();
7365
7476
  return this._send(V.HOLD, {
7366
7477
  hold: e,
7367
7478
  capabilities: e ? void 0 : t
@@ -7593,7 +7704,7 @@ var to = new Set([
7593
7704
  if (this.disposed) throw new En(e);
7594
7705
  switch (t.route) {
7595
7706
  case "producer":
7596
- this.datachannelCommandsQueue.push(t), this.producerCommandDataChannel?.readyState === Ya && this._handleCommandsQueue(this.datachannelCommandsQueue);
7707
+ this.datachannelCommandsQueue.push(t), this.producerCommandDataChannel?.readyState === Qa && this._handleCommandsQueue(this.datachannelCommandsQueue);
7597
7708
  break;
7598
7709
  case "websocket":
7599
7710
  if (this.transport.readyState === null) {
@@ -7643,7 +7754,7 @@ var to = new Set([
7643
7754
  _handleMessage(e) {
7644
7755
  switch (e.type) {
7645
7756
  case "notification":
7646
- this._attachNotificationCallError(e), e.notification === "connection" ? (this._debug.debug("[signaling] signaling connected", e), this.connected = !0, this.transport.resetReconnectCount(), this.transport.setEndpoint(e.endpoint), e.peerId && this.peerId !== e.peerId.id && (this.peerId = e.peerId.id, this.transport.setPeerId(e.peerId.id)), this._stopWaitConnectionMessage(), this.conversationResolve ? this.conversationResolve(e) : (this._triggerEvent(xr.RECONNECT, e), e.conversation.topology && this._triggerEvent(xr.NOTIFICATION, {
7757
+ this._attachNotificationCallError(e), e.notification === "connection" ? (this._debug.debug("[signaling] signaling connected", e), this.connected = !0, this.transport.onConnectionRestored(), this.transport.setEndpoint(e.endpoint), e.peerId && this.peerId !== e.peerId.id && (this.peerId = e.peerId.id, this.transport.setPeerId(e.peerId.id)), this._stopWaitConnectionMessage(), this.conversationResolve ? this.conversationResolve(e) : (this._triggerEvent(xr.RECONNECT, e), e.conversation.topology && this._triggerEvent(xr.NOTIFICATION, {
7647
7758
  type: "notification",
7648
7759
  notification: K.TOPOLOGY_CHANGED,
7649
7760
  topology: e.conversation.topology
@@ -7663,9 +7774,9 @@ var to = new Set([
7663
7774
  }
7664
7775
  _handleErrorMessage(e) {
7665
7776
  this._logger?.log(C.SOCKET_ACTION, `error-${e.error}`);
7666
- let t = this._getSocketType(), n = e.error ? this._createSignalingCallError(e.error, e.errorCode, t) : void 0, r = eo(e, "Unknown signaling error");
7777
+ let t = this._getSocketType(), n = e.error ? this._createSignalingCallError(e.error, e.errorCode, t) : void 0, r = ro(e, "Unknown signaling error");
7667
7778
  switch (this._debug.debug(`[signaling] error message [${e.sequence}]`, e), e.sequence && this.responseHandlers[e.sequence] && this._handleCommandResponse(!1, e), e.error) {
7668
- case Qa.SERVICE_UNAVAILABLE:
7779
+ case to.SERVICE_UNAVAILABLE:
7669
7780
  let i = new k(O.SERVICE_UNAVAILABLE, {
7670
7781
  callError: n,
7671
7782
  message: r,
@@ -7677,7 +7788,7 @@ var to = new Set([
7677
7788
  reason: O.SERVICE_UNAVAILABLE
7678
7789
  });
7679
7790
  break;
7680
- case Qa.CONVERSATION_ENDED:
7791
+ case to.CONVERSATION_ENDED:
7681
7792
  this.conversationReject ? this.conversationReject(new k(e.reason || x.SIGNALING_FAILED, {
7682
7793
  callError: n,
7683
7794
  message: r,
@@ -7688,22 +7799,22 @@ var to = new Set([
7688
7799
  reason: e.reason
7689
7800
  });
7690
7801
  break;
7691
- case Qa.ILLEGAL_PARTICIPANT_STATE:
7692
- case Qa.PARTICIPANT_NOT_FOUND:
7802
+ case to.ILLEGAL_PARTICIPANT_STATE:
7803
+ case to.PARTICIPANT_NOT_FOUND:
7693
7804
  this._throwError(new k(x.SIGNALING_FAILED, {
7694
7805
  callError: n,
7695
7806
  message: r,
7696
7807
  remote: !0
7697
7808
  }));
7698
7809
  break;
7699
- case Qa.OBSOLETE_CLIENT:
7810
+ case to.OBSOLETE_CLIENT:
7700
7811
  this.conversationReject?.(new k(e.reason || O.OBSOLETE_CLIENT, {
7701
7812
  callError: n,
7702
7813
  message: r,
7703
7814
  remote: !0
7704
7815
  }));
7705
7816
  break;
7706
- case Qa.INVALID_TOKEN:
7817
+ case to.INVALID_TOKEN:
7707
7818
  default:
7708
7819
  if (e.sequence || t === Sr.WEBTRANSPORT) break;
7709
7820
  if (this.connected) this._throwError(new k(e.reason || x.SIGNALING_FAILED, {
@@ -7742,7 +7853,7 @@ var to = new Set([
7742
7853
  }
7743
7854
  _describeErrorEvent(e) {
7744
7855
  let t = e, n = t.error instanceof Error ? t.error : null, r = [n?.name || t.errorInfo?.name, n?.message || t.errorInfo?.message || t.message].filter(Boolean).join(": ") || "Unknown error", i = t.errorInfo?.phase;
7745
- return (i ? `${i}: ${r}` : r).slice(0, Xa);
7856
+ return (i ? `${i}: ${r}` : r).slice(0, $a);
7746
7857
  }
7747
7858
  _onClose(e) {
7748
7859
  this._logger?.log(C.SOCKET_ACTION, "closed"), this._debug.debug("[signaling] connection closed", {
@@ -7797,13 +7908,13 @@ var to = new Set([
7797
7908
  let r = this.responseHandlers[n.sequence];
7798
7909
  window.clearTimeout(r.responseTimer);
7799
7910
  let i = G.measureMark(r.statMarkName);
7800
- i !== null && this._statSignalingCommands?.mark(r.name, i, this._getSocketType()), this._debug.debug(`[signaling] command response [${n.sequence}]`, n), t ? (delete this.responseHandlers[n.sequence], r.resolve(n)) : n.type === "error" ? (delete this.responseHandlers[n.sequence], this._logger?.log(C.SOCKET_ACTION, "response-error"), r.reject(Error(eo(n, `Response error [${r.name}]`)), !0)) : this.transport.readyState === WebSocket.OPEN ? (delete this.responseHandlers[n.sequence], this._logger?.log(C.SOCKET_ACTION, "response-timeout"), r.reject(Error(eo(n, `Response timeout [${r.name}]`)))) : r.responseTimer = window.setTimeout(() => this._handleCommandResponse(t, n), e.WAIT_RESPONSE_DELAY);
7911
+ i !== null && this._statSignalingCommands?.mark(r.name, i, this._getSocketType()), this._debug.debug(`[signaling] command response [${n.sequence}]`, n), t ? (delete this.responseHandlers[n.sequence], r.resolve(n)) : n.type === "error" ? (delete this.responseHandlers[n.sequence], this._logger?.log(C.SOCKET_ACTION, "response-error"), r.reject(Error(ro(n, `Response error [${r.name}]`)), !0)) : this.transport.readyState === WebSocket.OPEN ? (delete this.responseHandlers[n.sequence], this._logger?.log(C.SOCKET_ACTION, "response-timeout"), r.reject(Error(ro(n, `Response timeout [${r.name}]`)))) : r.responseTimer = window.setTimeout(() => this._handleCommandResponse(t, n), e.WAIT_RESPONSE_DELAY);
7801
7912
  }
7802
7913
  _handleCommandsQueue(e) {
7803
7914
  for (; e.length > 0;) {
7804
7915
  let t = e.shift();
7805
7916
  if (this._debug.debug(`[signaling] command send [${t.sequence}]`, `'${t.name}'`, t.params), t.route === "producer") {
7806
- if (this.producerCommandDataChannel?.readyState !== Ya) {
7917
+ if (this.producerCommandDataChannel?.readyState !== Qa) {
7807
7918
  t.reject(/* @__PURE__ */ Error(`Invalid data channel state: ${this.producerCommandDataChannel?.readyState}`));
7808
7919
  return;
7809
7920
  }
@@ -7888,7 +7999,7 @@ var to = new Set([
7888
7999
  }
7889
8000
  _onTransportFailed(e) {
7890
8001
  switch (e.failure) {
7891
- case qa.EMPTY_ENDPOINT:
8002
+ case Xa.EMPTY_ENDPOINT:
7892
8003
  this.conversationReject?.(new k(x.SIGNALING_FAILED, {
7893
8004
  callError: {
7894
8005
  scope: "internal",
@@ -7899,7 +8010,7 @@ var to = new Set([
7899
8010
  remote: e.remote
7900
8011
  }));
7901
8012
  break;
7902
- case qa.NETWORK_ERROR:
8013
+ case Xa.NETWORK_ERROR:
7903
8014
  this._logReconnectTimeout(), this._fail(new k(O.NETWORK_ERROR, { callError: {
7904
8015
  scope: "network",
7905
8016
  source: e.source,
@@ -7907,7 +8018,15 @@ var to = new Set([
7907
8018
  description: "connection-failed"
7908
8019
  } }));
7909
8020
  break;
7910
- case qa.ABORTED:
8021
+ case Xa.RECONNECT_TIMEOUT:
8022
+ this._logReconnectTimeout(), this._fail(new k(O.NETWORK_ERROR, { callError: {
8023
+ scope: "network",
8024
+ source: e.source,
8025
+ code: "reconnect-timeout",
8026
+ description: "connection-failed"
8027
+ } }));
8028
+ break;
8029
+ case Xa.ABORTED:
7911
8030
  this._debug.debug("[signaling] aborted reconnect"), this._fail(new k(O.CANCELED));
7912
8031
  break;
7913
8032
  }
@@ -7922,7 +8041,7 @@ var to = new Set([
7922
8041
  this._debug.warn("[signaling] socket is dead, trying to reconnect"), this._logTransportStatSinceMark(Cr.FAILED_PINGS);
7923
8042
  }
7924
8043
  _attachNotificationCallError(e) {
7925
- e.callError || !e.reason || e.reason === O.FAILED || e.reason === O.UNKNOWN_ERROR || !to.has(e.reason) && !e.errorCode || (e.callError = {
8044
+ e.callError || !e.reason || e.reason === O.FAILED || e.reason === O.UNKNOWN_ERROR || !io.has(e.reason) && !e.errorCode || (e.callError = {
7926
8045
  scope: "server",
7927
8046
  source: this._getSocketType(),
7928
8047
  code: e.errorCode || "protocol",
@@ -7930,7 +8049,7 @@ var to = new Set([
7930
8049
  });
7931
8050
  }
7932
8051
  _createSignalingCallError(e, t, n) {
7933
- let r = $a[e];
8052
+ let r = no[e];
7934
8053
  if (r) return {
7935
8054
  scope: "server",
7936
8055
  source: n,
@@ -7956,39 +8075,39 @@ var to = new Set([
7956
8075
  let t = this._getSocketType(), n = wr[e][t];
7957
8076
  this._statAggregator?.logEventualStatSinceMark({ name: n });
7958
8077
  }
7959
- }, ro = /* @__PURE__ */ function(e) {
8078
+ }, oo = /* @__PURE__ */ function(e) {
7960
8079
  return e.INCOMING = "INCOMING", e.OUTGOING = "OUTGOING", e.JOINING = "JOINING", e;
7961
- }(ro || {}), io = /* @__PURE__ */ function(e) {
8080
+ }(oo || {}), so = /* @__PURE__ */ function(e) {
7962
8081
  return e.USER = "USER", e.GROUP = "GROUP", e.CHAT = "CHAT", e;
7963
- }(io || {}), ao = /* @__PURE__ */ function(e) {
8082
+ }(so || {}), co = /* @__PURE__ */ function(e) {
7964
8083
  return e.ATTENDEE = "ATTENDEE", e.HAND_UP = "HAND_UP", e;
7965
- }(ao || {}), oo = /* @__PURE__ */ function(e) {
8084
+ }(co || {}), lo = /* @__PURE__ */ function(e) {
7966
8085
  return e.ADD_PARTICIPANT = "ADD_PARTICIPANT", e.RECORD = "RECORD", e.MOVIE_SHARE = "MOVIE_SHARE", e;
7967
- }(oo || {}), so = /* @__PURE__ */ function(e) {
8086
+ }(lo || {}), uo = /* @__PURE__ */ function(e) {
7968
8087
  return e.REQUIRE_AUTH_TO_JOIN = "REQUIRE_AUTH_TO_JOIN", e.AUDIENCE_MODE = "AUDIENCE_MODE", e.WAITING_HALL = "WAITING_HALL", e.WAIT_FOR_ADMIN = "WAIT_FOR_ADMIN", e.ADMIN_IS_HERE = "ADMIN_IS_HERE", e.ASR = "ASR", e.FEEDBACK = "FEEDBACK", e.RECURRING = "RECURRING", e;
7969
- }(so || {});
7970
- function co(e, t) {
8088
+ }(uo || {});
8089
+ function fo(e, t) {
7971
8090
  if (e.length !== t.length) return !1;
7972
8091
  for (let n of e) if (!t.includes(n)) return !1;
7973
8092
  return !0;
7974
8093
  }
7975
- function lo(e, t) {
8094
+ function po(e, t) {
7976
8095
  let n = new Set(e);
7977
8096
  for (let [e, r] of Object.entries(t)) r ? n.add(e) : n.delete(e);
7978
8097
  return Array.from(n);
7979
8098
  }
7980
8099
  //#endregion
7981
8100
  //#region src/enums/MuteState.ts
7982
- var uo = /* @__PURE__ */ function(e) {
8101
+ var mo = /* @__PURE__ */ function(e) {
7983
8102
  return e.UNMUTE = "UNMUTE", e.MUTE = "MUTE", e.MUTE_PERMANENT = "MUTE_PERMANENT", e;
7984
- }(uo || {}), X = /* @__PURE__ */ function(e) {
8103
+ }(mo || {}), X = /* @__PURE__ */ function(e) {
7985
8104
  return e.CALLED = "CALLED", e.ACCEPTED = "ACCEPTED", e.REJECTED = "REJECTED", e.HUNGUP = "HUNGUP", e;
7986
- }(X || {}), fo = /* @__PURE__ */ function(e) {
8105
+ }(X || {}), ho = /* @__PURE__ */ function(e) {
7987
8106
  return e.UPDATE = "UPDATE", e.REMOVE = "REMOVE", e.ACTIVATE = "ACTIVATE", e.TIMEOUT = "TIMEOUT", e;
7988
- }(fo || {}), po = /* @__PURE__ */ function(e) {
8107
+ }(ho || {}), go = /* @__PURE__ */ function(e) {
7989
8108
  return e.NO_AVAILABLE_TRACKS = "no-available-tracks", e.UNKNOWN_ERROR = "unknown-error", e;
7990
- }(po || {});
7991
- function mo(e) {
8109
+ }(go || {});
8110
+ function _o(e) {
7992
8111
  switch (e) {
7993
8112
  case 1: return "no-available-tracks";
7994
8113
  default: return "unknown-error";
@@ -7996,17 +8115,17 @@ function mo(e) {
7996
8115
  }
7997
8116
  //#endregion
7998
8117
  //#region src/enums/UserRole.ts
7999
- var ho = /* @__PURE__ */ function(e) {
8118
+ var vo = /* @__PURE__ */ function(e) {
8000
8119
  return e.CREATOR = "CREATOR", e.ADMIN = "ADMIN", e;
8001
- }(ho || {});
8002
- function go(e, t) {
8120
+ }(vo || {});
8121
+ function yo(e, t) {
8003
8122
  if (e.length !== t.length) return !1;
8004
8123
  for (let n of e) if (!t.includes(n)) return !1;
8005
8124
  return !0;
8006
8125
  }
8007
8126
  //#endregion
8008
8127
  //#region src/static/ParticipantConnectionStatusUtils.ts
8009
- var _o;
8128
+ var bo;
8010
8129
  (function(e) {
8011
8130
  function t(e) {
8012
8131
  let t = e?.transport ?? e?.lastEffective ?? P.WAITING, n = {
@@ -8058,8 +8177,8 @@ var _o;
8058
8177
  shouldNotify: !0
8059
8178
  });
8060
8179
  }
8061
- })(_o || (_o = {}));
8062
- var vo = _o, yo = /* @__PURE__ */ function(e) {
8180
+ })(bo || (bo = {}));
8181
+ var xo = bo, So = /* @__PURE__ */ function(e) {
8063
8182
  return e.USER = "USER", e.ANONYM = "ANONYM", e.GROUP = "GROUP", e;
8064
8183
  }({}), Z;
8065
8184
  (function(e) {
@@ -8122,7 +8241,7 @@ var vo = _o, yo = /* @__PURE__ */ function(e) {
8122
8241
  })(Z || (Z = {}));
8123
8242
  //#endregion
8124
8243
  //#region src/types/WaitingHall.ts
8125
- function bo(e) {
8244
+ function Co(e) {
8126
8245
  try {
8127
8246
  return btoa(JSON.stringify(e));
8128
8247
  } catch (t) {
@@ -8130,7 +8249,7 @@ function bo(e) {
8130
8249
  }
8131
8250
  return null;
8132
8251
  }
8133
- function xo(e) {
8252
+ function wo(e) {
8134
8253
  try {
8135
8254
  return JSON.parse(atob(e));
8136
8255
  } catch (t) {
@@ -8140,12 +8259,12 @@ function xo(e) {
8140
8259
  }
8141
8260
  //#endregion
8142
8261
  //#region src/utils/Conversation.ts
8143
- var So = (e, t) => M.objectReduce(e, (e, n, r) => (n === t && e.push(r), e), []);
8144
- function Co(e) {
8262
+ var To = (e, t) => M.objectReduce(e, (e, n, r) => (n === t && e.push(r), e), []);
8263
+ function Eo(e) {
8145
8264
  if (e.conversation?.muteStates) return e.conversation.muteStates;
8146
8265
  if (e.muteState && e.muteOptions) return e.muteOptions.reduce((t, n) => (t[n] = e.muteState, t), {});
8147
8266
  }
8148
- function wo(e, t) {
8267
+ function Do(e, t) {
8149
8268
  switch (e) {
8150
8269
  case S.AUDIO: return !!t.isAudioEnabled;
8151
8270
  case S.AUDIO_SHARING: return !!t.isAudioSharingEnabled;
@@ -8154,12 +8273,12 @@ function wo(e, t) {
8154
8273
  default: return !1;
8155
8274
  }
8156
8275
  }
8157
- function To(e, t) {
8276
+ function Oo(e, t) {
8158
8277
  return M.objectReduce(e, (e, n, r) => {
8159
8278
  switch (n) {
8160
- case uo.MUTE:
8161
- case uo.MUTE_PERMANENT:
8162
- wo(r, t) || (e[r] = n);
8279
+ case mo.MUTE:
8280
+ case mo.MUTE_PERMANENT:
8281
+ Do(r, t) || (e[r] = n);
8163
8282
  break;
8164
8283
  default:
8165
8284
  e[r] = n;
@@ -8168,19 +8287,19 @@ function To(e, t) {
8168
8287
  return e;
8169
8288
  }, {});
8170
8289
  }
8171
- function Eo(e) {
8290
+ function ko(e) {
8172
8291
  let { muteStates: t = {}, mediaSettings: n } = e;
8173
- return To(t, n);
8292
+ return Oo(t, n);
8174
8293
  }
8175
- function Do(e, t) {
8294
+ function Ao(e, t) {
8176
8295
  let n = e.conversation.participants.find((t) => M.comparePeerId(t.peerId, e.peerId));
8177
8296
  if (!n) return t;
8178
8297
  let { mediaSettings: r } = n;
8179
- return To(t, r);
8298
+ return Oo(t, r);
8180
8299
  }
8181
8300
  //#endregion
8182
8301
  //#region src/utils/IceServers.ts
8183
- function Oo(e) {
8302
+ function jo(e) {
8184
8303
  if (!e) return null;
8185
8304
  let t = Array.from(new Set((e.urls ?? []).map((e) => e.trim()).filter((e) => e.length > 0)));
8186
8305
  return t.length ? {
@@ -8188,8 +8307,8 @@ function Oo(e) {
8188
8307
  urls: t
8189
8308
  } : null;
8190
8309
  }
8191
- function ko(e, t) {
8192
- let n = [], r = Oo(e), i = Oo(t);
8310
+ function Mo(e, t) {
8311
+ let n = [], r = jo(e), i = jo(t);
8193
8312
  if (r && n.push(r), i) {
8194
8313
  let e = [...i.urls];
8195
8314
  e.push(`${e[e.length - 1]}?transport=tcp`), n.push({
@@ -8201,7 +8320,7 @@ function ko(e, t) {
8201
8320
  }
8202
8321
  //#endregion
8203
8322
  //#region src/utils/Lz4.ts
8204
- function Ao(e, t) {
8323
+ function No(e, t) {
8205
8324
  let n = new Uint8Array(t), r = 0, i = 0;
8206
8325
  for (; r < e.length && i < t;) {
8207
8326
  let a = e[r++], o = a >> 4, s = a & 15;
@@ -8228,7 +8347,7 @@ function Ao(e, t) {
8228
8347
  }
8229
8348
  //#endregion
8230
8349
  //#region src/utils/SerializeLatest.ts
8231
- function jo(e) {
8350
+ function Po(e) {
8232
8351
  let t, n = !1, r, i = async () => {
8233
8352
  let t = !1, i;
8234
8353
  for (; n;) {
@@ -8249,7 +8368,7 @@ function jo(e) {
8249
8368
  }
8250
8369
  //#endregion
8251
8370
  //#region src/classes/AudioFix.ts
8252
- var Mo = class {
8371
+ var Fo = class {
8253
8372
  constructor(e, t = z, n = null) {
8254
8373
  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;
8255
8374
  }
@@ -8287,7 +8406,7 @@ var Mo = class {
8287
8406
  this._debug.warn("[AudioFix] Failed to fix RV (no packets): video restart", e);
8288
8407
  }));
8289
8408
  }
8290
- }, No = class {
8409
+ }, Io = class {
8291
8410
  constructor(e, t = !1, n = z, r = null) {
8292
8411
  h(this, "_audioElement", null), h(this, "_debug", void 0), h(this, "_preparedAudioElement", void 0), 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, "_logger", void 0), this._statFirstMediaReceived = e, this._allowMultipleTracks = t, this._debug = n, this._logger = r, this._preparedAudioElement = this._prepareAudioElement();
8293
8412
  }
@@ -8390,13 +8509,13 @@ var Mo = class {
8390
8509
  };
8391
8510
  //#endregion
8392
8511
  //#region src/classes/conversation/ConversationResponseValidator.ts
8393
- function Po(e, t) {
8394
- e || Io(t, "response-empty"), e.id || Io(t, "id-empty"), e.endpoint || Io(t, "endpoint-empty"), !Fo(e.stun_server) && !Fo(e.turn_server) && Io(t, "ice-servers-empty");
8512
+ function Lo(e, t) {
8513
+ e || zo(t, "response-empty"), e.id || zo(t, "id-empty"), e.endpoint || zo(t, "endpoint-empty"), !Ro(e.stun_server) && !Ro(e.turn_server) && zo(t, "ice-servers-empty");
8395
8514
  }
8396
- function Fo(e) {
8515
+ function Ro(e) {
8397
8516
  return Array.isArray(e?.urls) && e.urls.length > 0;
8398
8517
  }
8399
- function Io(e, t) {
8518
+ function zo(e, t) {
8400
8519
  let n = e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), r = e === "fastStart" || e === "fastJoin";
8401
8520
  throw new k(r ? e === "fastStart" ? O.FAST_START_ERROR : O.FAST_JOIN_ERROR : O.UNKNOWN_ERROR, {
8402
8521
  message: `Invalid ${e} response: ${t}`,
@@ -8415,7 +8534,7 @@ function Io(e, t) {
8415
8534
  }
8416
8535
  //#endregion
8417
8536
  //#region src/classes/DebugInfo.ts
8418
- var Lo = 90, Ro = 3, zo = class extends b {
8537
+ var Bo = 90, Vo = 3, Ho = class extends b {
8419
8538
  constructor(e = z) {
8420
8539
  super(), h(this, "_lastMemoryStat", {
8421
8540
  percent: 0,
@@ -8431,9 +8550,9 @@ var Lo = 90, Ro = 3, zo = class extends b {
8431
8550
  let e = window?.performance?.memory;
8432
8551
  if (!e || !e.usedJSHeapSize || !e.jsHeapSizeLimit) return;
8433
8552
  let t = Number((100 * e.usedJSHeapSize / e.jsHeapSizeLimit).toFixed(2)), n = Number((e.usedJSHeapSize / 1024 / 1024).toFixed(1));
8434
- t > Lo ? this._debug.warn(`High memory usage: ${t}% (${n} MiB)`) : (!this._lastMemoryStat.percent || Math.abs(t - this._lastMemoryStat.percent) >= Ro) && (this._debug.debug(`Memory usage: ${t}% (${n} MiB)`), this._lastMemoryStat.percent = t, this._lastMemoryStat.bytes = e.usedJSHeapSize);
8553
+ t > Bo ? this._debug.warn(`High memory usage: ${t}% (${n} MiB)`) : (!this._lastMemoryStat.percent || Math.abs(t - this._lastMemoryStat.percent) >= Vo) && (this._debug.debug(`Memory usage: ${t}% (${n} MiB)`), this._lastMemoryStat.percent = t, this._lastMemoryStat.bytes = e.usedJSHeapSize);
8435
8554
  }
8436
- }, Bo = class {
8555
+ }, Uo = class {
8437
8556
  constructor({ api: e, debug: t, getParticipants: n, isMe: r, updateDisplayLayout: i, onNonFatalError: a }) {
8438
8557
  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, "_onNonFatalError", 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, this._onNonFatalError = a;
8439
8558
  }
@@ -8548,7 +8667,7 @@ var Lo = 90, Ro = 3, zo = class extends b {
8548
8667
  let n = e, r = t;
8549
8668
  return n.width !== r.width || n.height !== r.height || n.fit !== r.fit || n.priority !== r.priority;
8550
8669
  }
8551
- }, Vo = 44100, Ho = class {
8670
+ }, Wo = 44100, Go = class {
8552
8671
  constructor(e, t) {
8553
8672
  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]);
8554
8673
  try {
@@ -8565,7 +8684,7 @@ var Lo = 90, Ro = 3, zo = class extends b {
8565
8684
  _getBins() {
8566
8685
  if (!this._fftBins || !this._analyser) return new Uint8Array();
8567
8686
  this._analyser.getByteFrequencyData(this._fftBins);
8568
- let e = Vo / this._fftBins.length, t = Math.ceil(N.voiceParams.minFreq / e), n = Math.floor(N.voiceParams.maxFreq / e);
8687
+ let e = Wo / this._fftBins.length, t = Math.ceil(N.voiceParams.minFreq / e), n = Math.floor(N.voiceParams.maxFreq / e);
8569
8688
  return this._fftBins.subarray(t, n);
8570
8689
  }
8571
8690
  getLevel() {
@@ -8578,7 +8697,7 @@ var Lo = 90, Ro = 3, zo = class extends b {
8578
8697
  destroy() {
8579
8698
  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);
8580
8699
  }
8581
- }, Uo = class extends b {
8700
+ }, Ko = class extends b {
8582
8701
  constructor(e) {
8583
8702
  super(), h(this, "_detector", null), h(this, "_interval", null);
8584
8703
  let t = () => {
@@ -8594,7 +8713,7 @@ var Lo = 90, Ro = 3, zo = class extends b {
8594
8713
  }), this.subscribe(e, qt.SOURCE_READY, n), n();
8595
8714
  }
8596
8715
  init(e) {
8597
- this._stopDetector(), this._detector = new Ho("local", e.clone());
8716
+ this._stopDetector(), this._detector = new Go("local", e.clone());
8598
8717
  }
8599
8718
  _stopDetector() {
8600
8719
  this._detector && (this._detector.track.stop(), this._detector.destroy(), this._detector = null);
@@ -8602,7 +8721,7 @@ var Lo = 90, Ro = 3, zo = class extends b {
8602
8721
  destroy() {
8603
8722
  this.unsubscribe(), this._interval && (window.clearTimeout(this._interval), this._interval = null), this._stopDetector();
8604
8723
  }
8605
- }, Wo = class {
8724
+ }, qo = class {
8606
8725
  constructor(e, t = z) {
8607
8726
  h(this, "processor", void 0), h(this, "queue", []), h(this, "isProcessing", !1), h(this, "_debug", void 0), this.processor = e, this._debug = t;
8608
8727
  }
@@ -8622,9 +8741,9 @@ var Lo = 90, Ro = 3, zo = class extends b {
8622
8741
  this.isProcessing = !1;
8623
8742
  }
8624
8743
  }
8625
- }, Go = /* @__PURE__ */ function(e) {
8744
+ }, Jo = /* @__PURE__ */ function(e) {
8626
8745
  return e.VOLUMES_DETECTED = "VOLUMES_DETECTED", e;
8627
- }({}), Ko = class extends b {
8746
+ }({}), Yo = class extends b {
8628
8747
  constructor(e) {
8629
8748
  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, Y.REMOTE_TRACK_ADDED, this._onRemoteTrackAdded.bind(this)), this.subscribe(e, Y.REMOTE_TRACK_REMOVED, this._onRemoteTrackRemoved.bind(this)), this.subscribe(e, Y.SIGNALLED_ACTIVE_PARTICIPANTS, this._onSignalledActiveParticipants.bind(this)), this.subscribe(e, Y.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this));
8630
8749
  }
@@ -8632,7 +8751,7 @@ var Lo = 90, Ro = 3, zo = class extends b {
8632
8751
  this._interval && (window.clearTimeout(this._interval), this._interval = null), this.unsubscribe(), this._destroyDetectors();
8633
8752
  }
8634
8753
  _onRemoteTrackAdded(e, t, n) {
8635
- if (n.kind === A.audio && (this._detectors.get(e)?.destroy(), this._detectors.set(e, new Ho(e, n)), !this._interval)) {
8754
+ if (n.kind === A.audio && (this._detectors.get(e)?.destroy(), this._detectors.set(e, new Go(e, n)), !this._interval)) {
8636
8755
  let e = () => {
8637
8756
  this._collectVolumes(), this._interval = window.setTimeout(e, N.voiceParams.interval);
8638
8757
  };
@@ -8663,14 +8782,14 @@ var Lo = 90, Ro = 3, zo = class extends b {
8663
8782
  this._triggerEvent("VOLUMES_DETECTED", e);
8664
8783
  }
8665
8784
  _getAudioTrackLevelByParticipantId(e) {
8666
- let t = this._detectors.get(si.AUDIO_MIX);
8785
+ let t = this._detectors.get(ui.AUDIO_MIX);
8667
8786
  return t ? t.getLevel() : this._getTransparentAudioLevelByParticipantId(e);
8668
8787
  }
8669
8788
  _getTransparentAudioLevelByParticipantId(e) {
8670
8789
  if (!this._activeParticipants?.includes(e)) return null;
8671
8790
  let t = null;
8672
8791
  return this._detectors.forEach((e, n) => {
8673
- if (!n.startsWith(`${si.TRANSPARENT_AUDIO_TRACK_PREFIX}-`)) return;
8792
+ if (!n.startsWith(`${ui.TRANSPARENT_AUDIO_TRACK_PREFIX}-`)) return;
8674
8793
  let r = e.getLevel();
8675
8794
  (!t || r.real > t.real) && (t = r);
8676
8795
  }), t;
@@ -8686,11 +8805,11 @@ var Lo = 90, Ro = 3, zo = class extends b {
8686
8805
  e.destroy();
8687
8806
  }), this._detectors.clear();
8688
8807
  }
8689
- }, qo = /* @__PURE__ */ function(e) {
8808
+ }, Xo = /* @__PURE__ */ function(e) {
8690
8809
  return e.SPEAKER_CHANGED = "SPEAKER_CHANGED", e;
8691
- }({}), Jo = class extends b {
8810
+ }({}), Zo = class extends b {
8692
8811
  constructor(e, t, n) {
8693
- super(), h(this, "_speakerId", null), h(this, "_serverSideSpeakerDetection", !1), this._serverSideSpeakerDetection = n === J.SERVER, this.subscribe(e, Go.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this.subscribe(t, Y.SIGNALLED_SPEAKER_CHANGED, this._onServerSpeakerChanged.bind(this)), this.subscribe(t, Y.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this));
8812
+ super(), h(this, "_speakerId", null), h(this, "_serverSideSpeakerDetection", !1), this._serverSideSpeakerDetection = n === J.SERVER, this.subscribe(e, Jo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this.subscribe(t, Y.SIGNALLED_SPEAKER_CHANGED, this._onServerSpeakerChanged.bind(this)), this.subscribe(t, Y.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this));
8694
8813
  }
8695
8814
  destroy() {
8696
8815
  this.unsubscribe();
@@ -8712,9 +8831,9 @@ var Lo = 90, Ro = 3, zo = class extends b {
8712
8831
  _onTopologyChanged(e) {
8713
8832
  this._serverSideSpeakerDetection = e === J.SERVER;
8714
8833
  }
8715
- }, Yo = 15e3, Xo = 15e3, Zo = class extends b {
8834
+ }, Qo = 15e3, $o = 15e3, es = class extends b {
8716
8835
  constructor(e, t, n, r = z, i = null) {
8717
- 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, Y.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(t, Go.VOLUMES_DETECTED, this._onVolumesDetected.bind(this));
8836
+ 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, Y.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(t, Jo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this));
8718
8837
  }
8719
8838
  destroy() {
8720
8839
  this.unsubscribe(), this._connectionTimeout && window.clearTimeout(this._connectionTimeout), this._volumeTimeout && window.clearTimeout(this._volumeTimeout);
@@ -8726,10 +8845,10 @@ var Lo = 90, Ro = 3, zo = class extends b {
8726
8845
  this._connectionTimeout || !this._connectionTimeoutSuppressed || this._reportConnectionTimeout();
8727
8846
  }
8728
8847
  _getConnectionTimeout() {
8729
- return this._transport.getTopology() === J.DIRECT ? Yo : N.specListenerParams.connectionTimeout;
8848
+ return this._transport.getTopology() === J.DIRECT ? Qo : N.specListenerParams.connectionTimeout;
8730
8849
  }
8731
8850
  _getVolumeTimeout() {
8732
- return this._transport.getTopology() === J.DIRECT ? Xo : N.specListenerParams.volumeTimeout;
8851
+ return this._transport.getTopology() === J.DIRECT ? $o : N.specListenerParams.volumeTimeout;
8733
8852
  }
8734
8853
  _onTransportStateChanged(e, t) {
8735
8854
  t === q.OPENED && (this._connectionTimeout || (this._connectionTimeoutSuppressed = !1, this._connectionTimeout = window.setTimeout(this._onConnectionTimeout.bind(this), this._getConnectionTimeout()))), t === q.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 === q.FAILED && this._connectionTimeout && (this._debug.warn("Transport failed, send callSpecError"), this._logger?.log(C.CALL_SPEC_ERROR, `${this._transport.getTopology()}_CONNECTION_TIMEOUT`));
@@ -8762,15 +8881,15 @@ var Lo = 90, Ro = 3, zo = class extends b {
8762
8881
  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}`));
8763
8882
  }), e.length && this._debug.warn("There is silent participant, send callSpecError"), this._volumeTimeout = 0;
8764
8883
  }
8765
- }, Qo = /* @__PURE__ */ function(e) {
8884
+ }, ts = /* @__PURE__ */ function(e) {
8766
8885
  return e[e.PARAM_SESSION_EXPIRED = 102] = "PARAM_SESSION_EXPIRED", e[e.PARAM_SESSION_KEY = 103] = "PARAM_SESSION_KEY", e[e.PARAM_SIGNATURE = 104] = "PARAM_SIGNATURE", e[e.AUTH_LOGIN = 401] = "AUTH_LOGIN", e;
8767
- }(Qo || {});
8768
- function $o(e) {
8886
+ }(ts || {});
8887
+ function ns(e) {
8769
8888
  return e === 102 || e === 103 || e === 104;
8770
8889
  }
8771
8890
  //#endregion
8772
8891
  //#region src/classes/stat/StatQueue.ts
8773
- var es, ts = "ok-calls-sdk-stats", ns = 1, rs = "events", is = 100, as = 5e3, os = 10080 * 60 * 1e3, ss = 5e3, cs = 6e4, Q = class e {
8892
+ var rs, is = "ok-calls-sdk-stats", as = 1, os = "events", ss = 100, cs = 5e3, ls = 10080 * 60 * 1e3, us = 5e3, ds = 6e4, Q = class e {
8774
8893
  static isSupported() {
8775
8894
  return e._supported;
8776
8895
  }
@@ -8783,7 +8902,7 @@ var es, ts = "ok-calls-sdk-stats", ns = 1, rs = "events", is = 100, as = 5e3, os
8783
8902
  n.onsuccess = () => e(n.result);
8784
8903
  });
8785
8904
  }).catch((e) => (z.error("[StatQueue] failed to append event", e), null));
8786
- return r === null ? null : (e._appendsSinceEvictCheck += 1, e._appendsSinceEvictCheck >= is && (e._appendsSinceEvictCheck = 0, await e.evictToLimit(as)), r);
8905
+ return r === null ? null : (e._appendsSinceEvictCheck += 1, e._appendsSinceEvictCheck >= ss && (e._appendsSinceEvictCheck = 0, await e.evictToLimit(cs)), r);
8787
8906
  }
8788
8907
  static async fillDelta(t, n) {
8789
8908
  if (t.length === 0) return;
@@ -8884,7 +9003,7 @@ var es, ts = "ok-calls-sdk-stats", ns = 1, rs = "events", is = 100, as = 5e3, os
8884
9003
  });
8885
9004
  }
8886
9005
  static async __resetForTests() {
8887
- if (e._appendsSinceEvictCheck = 0, e._lastOpenFailureAt = null, e._supported = e._checkSupport(), e._dbName === ts && (e._dbName = `${ts}-test-${Math.random().toString(36).slice(2)}`, e._close()), e._supported) {
9006
+ if (e._appendsSinceEvictCheck = 0, e._lastOpenFailureAt = null, e._supported = e._checkSupport(), e._dbName === is && (e._dbName = `${is}-test-${Math.random().toString(36).slice(2)}`, e._close()), e._supported) {
8888
9007
  let t = await e._open();
8889
9008
  t && await e._runTransaction(t, "readwrite", (e) => {
8890
9009
  e.clear();
@@ -8892,7 +9011,6 @@ var es, ts = "ok-calls-sdk-stats", ns = 1, rs = "events", is = 100, as = 5e3, os
8892
9011
  z.error("[StatQueue] failed to reset storage", e);
8893
9012
  });
8894
9013
  }
8895
- e._close();
8896
9014
  }
8897
9015
  static _checkSupport() {
8898
9016
  return typeof window < "u" && !!window.indexedDB;
@@ -8900,18 +9018,18 @@ var es, ts = "ok-calls-sdk-stats", ns = 1, rs = "events", is = 100, as = 5e3, os
8900
9018
  static _open() {
8901
9019
  if (!e._checkSupport()) return e._supported = !1, Promise.resolve(null);
8902
9020
  if (e._dbPromise) return e._dbPromise;
8903
- if (e._lastOpenFailureAt !== null && Date.now() - e._lastOpenFailureAt < cs) return Promise.resolve(null);
9021
+ if (e._lastOpenFailureAt !== null && Date.now() - e._lastOpenFailureAt < ds) return Promise.resolve(null);
8904
9022
  let t = !1, n = new Promise((n) => {
8905
9023
  let r = (r, i) => {
8906
9024
  t || (t = !0, z.error(r, i), e._supported = !1, e._dbPromise = null, e._lastOpenFailureAt = Date.now(), n(null));
8907
9025
  }, i;
8908
9026
  try {
8909
- i = window.indexedDB.open(e._dbName, ns);
9027
+ i = window.indexedDB.open(e._dbName, as);
8910
9028
  } catch (e) {
8911
9029
  r("[StatQueue] storage is not accessible", e);
8912
9030
  return;
8913
9031
  }
8914
- let a = window.setTimeout(() => r("[StatQueue] storage opening timed out"), ss);
9032
+ let a = window.setTimeout(() => r("[StatQueue] storage opening timed out"), us);
8915
9033
  i.onupgradeneeded = () => {
8916
9034
  e._createSchema(i.result);
8917
9035
  }, i.onsuccess = () => {
@@ -8932,8 +9050,8 @@ var es, ts = "ok-calls-sdk-stats", ns = 1, rs = "events", is = 100, as = 5e3, os
8932
9050
  e._db && (e._db.close(), e._db = null), e._dbPromise = null;
8933
9051
  }
8934
9052
  static _createSchema(e) {
8935
- if (e.objectStoreNames.contains(rs)) return;
8936
- let t = e.createObjectStore(rs, {
9053
+ if (e.objectStoreNames.contains(os)) return;
9054
+ let t = e.createObjectStore(os, {
8937
9055
  keyPath: "id",
8938
9056
  autoIncrement: !0
8939
9057
  });
@@ -8941,8 +9059,8 @@ var es, ts = "ok-calls-sdk-stats", ns = 1, rs = "events", is = 100, as = 5e3, os
8941
9059
  }
8942
9060
  static _runTransaction(e, t, n) {
8943
9061
  return new Promise((r, i) => {
8944
- let a = e.transaction(rs, t), o;
8945
- a.oncomplete = () => r(o), a.onerror = () => i(a.error), a.onabort = () => i(a.error), Promise.resolve(n(a.objectStore(rs))).then((e) => {
9062
+ let a = e.transaction(os, t), o;
9063
+ a.oncomplete = () => r(o), a.onerror = () => i(a.error), a.onabort = () => i(a.error), Promise.resolve(n(a.objectStore(os))).then((e) => {
8946
9064
  o = e;
8947
9065
  }).catch((e) => {
8948
9066
  try {
@@ -8967,18 +9085,18 @@ var es, ts = "ok-calls-sdk-stats", ns = 1, rs = "events", is = 100, as = 5e3, os
8967
9085
  });
8968
9086
  }
8969
9087
  };
8970
- es = Q, h(Q, "_db", null), h(Q, "_dbPromise", null), h(Q, "_dbName", ts), h(Q, "_supported", es._checkSupport()), h(Q, "_appendsSinceEvictCheck", 0), h(Q, "_lastOpenFailureAt", null);
9088
+ rs = Q, h(Q, "_db", null), h(Q, "_dbPromise", null), h(Q, "_dbName", is), h(Q, "_supported", rs._checkSupport()), h(Q, "_appendsSinceEvictCheck", 0), h(Q, "_lastOpenFailureAt", null);
8971
9089
  //#endregion
8972
9090
  //#region src/static/ApiTransport.ts
8973
- var ls = null, us = null, ds = 64 * 1024;
8974
- function fs() {
8975
- ls = null, us = null;
9091
+ var fs = null, ps = null, ms = 64 * 1024;
9092
+ function hs() {
9093
+ fs = null, ps = null;
8976
9094
  }
8977
- function ps(e) {
9095
+ function gs(e) {
8978
9096
  return e?.endsWith("/") ? e.slice(0, -1) : e;
8979
9097
  }
8980
- async function ms(e = null, t) {
8981
- let n = ps(e ?? N.apiBaseUrl);
9098
+ async function _s(e = null, t) {
9099
+ let n = gs(e ?? N.apiBaseUrl);
8982
9100
  if (n) return n;
8983
9101
  if ((t ?? N.apiEnv) !== "AUTO") return N.apiEndpoint(t);
8984
9102
  try {
@@ -8993,25 +9111,25 @@ async function ms(e = null, t) {
8993
9111
  return z.warn("Failed to resolve API endpoint using DNS, default is used", e), N.apiEndpoint(t);
8994
9112
  }
8995
9113
  }
8996
- async function hs() {
8997
- return ls || us || (us = ms(), ls = await us, us = null, ls);
9114
+ async function vs() {
9115
+ return fs || ps || (ps = _s(), fs = await ps, ps = null, fs);
8998
9116
  }
8999
- async function gs(e, t = {}, n = !1) {
9117
+ async function ys(e, t = {}, n = !1) {
9000
9118
  if (!window.Blob || !window.navigator.sendBeacon) return;
9001
- await hs();
9002
- let r = Ss(e, t, n), i = new window.Blob([r], { type: "application/x-www-form-urlencoded" });
9003
- window.navigator.sendBeacon(`${ls}/fb.do`, i);
9119
+ await vs();
9120
+ let r = Ts(e, t, n), i = new window.Blob([r], { type: "application/x-www-form-urlencoded" });
9121
+ window.navigator.sendBeacon(`${fs}/fb.do`, i);
9004
9122
  }
9005
- async function _s(e, t = {}, n = !1, r) {
9006
- return await hs(), ys(Ss(e, t, n), r);
9123
+ async function bs(e, t = {}, n = !1, r) {
9124
+ return await vs(), Ss(Ts(e, t, n), r);
9007
9125
  }
9008
- async function vs(e, t = {}, n = !1) {
9009
- await hs();
9010
- let r = Ss(e, t, n);
9011
- return ys(r, void 0, new Blob([r]).size <= ds);
9126
+ async function xs(e, t = {}, n = !1) {
9127
+ await vs();
9128
+ let r = Ts(e, t, n);
9129
+ return Ss(r, void 0, new Blob([r]).size <= ms);
9012
9130
  }
9013
- async function ys(e, t, n = !1) {
9014
- let r = `${t ?? ls}/fb.do`, i = new AbortController(), a = new k(x.NETWORK, { callError: {
9131
+ async function Ss(e, t, n = !1) {
9132
+ let r = `${t ?? fs}/fb.do`, i = new AbortController(), a = new k(x.NETWORK, { callError: {
9015
9133
  scope: "network",
9016
9134
  source: "api",
9017
9135
  code: "timeout",
@@ -9030,16 +9148,16 @@ async function ys(e, t, n = !1) {
9030
9148
  } catch {
9031
9149
  o = { result: a };
9032
9150
  }
9033
- if (!t.ok && !bs(o)) throw new k(x.API, { callError: {
9151
+ if (!t.ok && !Cs(o)) throw new k(x.API, { callError: {
9034
9152
  scope: "server",
9035
9153
  source: "api",
9036
9154
  code: `http-${t.status}`,
9037
9155
  description: "http-error"
9038
9156
  } });
9039
- if (bs(o)) throw o;
9157
+ if (Cs(o)) throw o;
9040
9158
  return o;
9041
9159
  } catch (e) {
9042
- throw e instanceof k ? e : i.signal.aborted ? a : bs(e) ? e : new k(x.NETWORK, { callError: {
9160
+ throw e instanceof k ? e : i.signal.aborted ? a : Cs(e) ? e : new k(x.NETWORK, { callError: {
9043
9161
  scope: "network",
9044
9162
  source: "api",
9045
9163
  code: "fetch-failed",
@@ -9049,12 +9167,12 @@ async function ys(e, t, n = !1) {
9049
9167
  clearTimeout(o);
9050
9168
  }
9051
9169
  }
9052
- function bs(e) {
9170
+ function Cs(e) {
9053
9171
  if (typeof e != "object" || !e) return !1;
9054
9172
  let t = e;
9055
9173
  return typeof t.error_code == "number" && typeof t.error_msg == "string";
9056
9174
  }
9057
- async function xs(e, t) {
9175
+ async function ws(e, t) {
9058
9176
  try {
9059
9177
  let n = await fetch(e, {
9060
9178
  method: "POST",
@@ -9067,7 +9185,7 @@ async function xs(e, t) {
9067
9185
  throw z.warn("Failed to send form data", e), e;
9068
9186
  }
9069
9187
  }
9070
- function Ss(e, t = {}, n = !1) {
9188
+ function Ts(e, t = {}, n = !1) {
9071
9189
  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));
9072
9190
  for (let [e, n] of Object.entries(t)) typeof n == "object" && (t[e] = JSON.stringify(n));
9073
9191
  let r = "";
@@ -9076,7 +9194,7 @@ function Ss(e, t = {}, n = !1) {
9076
9194
  }
9077
9195
  //#endregion
9078
9196
  //#region src/static/SessionStore.ts
9079
- var Cs = "sessions", ws = 5, Ts = class e {
9197
+ var Es = "sessions", Ds = 5, Os = class e {
9080
9198
  static remember(t, n) {
9081
9199
  let r = e._read();
9082
9200
  r[String(t)] = {
@@ -9084,7 +9202,7 @@ var Cs = "sessions", ws = 5, Ts = class e {
9084
9202
  savedAt: Date.now()
9085
9203
  };
9086
9204
  let i = Object.keys(r);
9087
- i.length > ws && i.sort((e, t) => r[e].savedAt - r[t].savedAt).slice(0, i.length - ws).forEach((e) => delete r[e]), e._write(r);
9205
+ i.length > Ds && i.sort((e, t) => r[e].savedAt - r[t].savedAt).slice(0, i.length - Ds).forEach((e) => delete r[e]), e._write(r);
9088
9206
  }
9089
9207
  static get(t) {
9090
9208
  return e._read()[String(t)] ?? null;
@@ -9100,10 +9218,10 @@ var Cs = "sessions", ws = 5, Ts = class e {
9100
9218
  }), r && e._write(n);
9101
9219
  }
9102
9220
  static currentEndpoint() {
9103
- return String(ps(N.apiBaseUrl) || N.apiEndpoint());
9221
+ return String(gs(N.apiBaseUrl) || N.apiEndpoint());
9104
9222
  }
9105
9223
  static _read() {
9106
- let t = w.get(Cs);
9224
+ let t = w.get(Es);
9107
9225
  if (!t || typeof t != "object" || Array.isArray(t)) return {};
9108
9226
  let n = {};
9109
9227
  return Object.entries(t).forEach(([t, r]) => {
@@ -9112,16 +9230,16 @@ var Cs = "sessions", ws = 5, Ts = class e {
9112
9230
  }
9113
9231
  static _write(e) {
9114
9232
  if (Object.keys(e).length === 0) {
9115
- w.remove(Cs);
9233
+ w.remove(Es);
9116
9234
  return;
9117
9235
  }
9118
- w.set(Cs, e);
9236
+ w.set(Es, e);
9119
9237
  }
9120
9238
  static _isValid(e) {
9121
9239
  let t = e;
9122
9240
  return typeof t == "object" && !!t && typeof t.sessionKey == "string" && t.sessionKey.length > 0 && typeof t.endpoint == "string" && typeof t.savedAt == "number";
9123
9241
  }
9124
- }, Es = 15e3, Ds = class e {
9242
+ }, ks = 15e3, As = class e {
9125
9243
  static setApi(t) {
9126
9244
  e._api = t;
9127
9245
  }
@@ -9132,7 +9250,7 @@ var Cs = "sessions", ws = 5, Ts = class e {
9132
9250
  e._delta === null && e._api && e.get();
9133
9251
  }
9134
9252
  static get() {
9135
- return e._delta === null ? !e._api || !e._hasCredentials() || e._lastFailureAt !== null && Date.now() - e._lastFailureAt < Es ? Promise.resolve(0) : (e._pending || (e._pending = e._measure().finally(() => {
9253
+ return e._delta === null ? !e._api || !e._hasCredentials() || e._lastFailureAt !== null && Date.now() - e._lastFailureAt < ks ? Promise.resolve(0) : (e._pending || (e._pending = e._measure().finally(() => {
9136
9254
  e._pending = null;
9137
9255
  })), e._pending) : Promise.resolve(e._delta);
9138
9256
  }
@@ -9162,10 +9280,10 @@ var Cs = "sessions", ws = 5, Ts = class e {
9162
9280
  return e._idsAwaitingDelta = [], await Q.fillDelta(n, t), t;
9163
9281
  }
9164
9282
  };
9165
- h(Ds, "_api", null), h(Ds, "_delta", null), h(Ds, "_pending", null), h(Ds, "_idsAwaitingDelta", []), h(Ds, "_lastFailureAt", null);
9283
+ h(As, "_api", null), h(As, "_delta", null), h(As, "_pending", null), h(As, "_idsAwaitingDelta", []), h(As, "_lastFailureAt", null);
9166
9284
  //#endregion
9167
9285
  //#region src/classes/stat/StatUnloadJournal.ts
9168
- var Os = "okcls-stat-unload.", ks = class e {
9286
+ var js = "okcls-stat-unload.", Ms = class e {
9169
9287
  static beginTabSession() {
9170
9288
  e._tabKey = null, e._entries = [];
9171
9289
  }
@@ -9173,7 +9291,7 @@ var Os = "okcls-stat-unload.", ks = class e {
9173
9291
  let n = e._storage();
9174
9292
  if (!n) return !1;
9175
9293
  try {
9176
- return e._tabKey || (e._tabKey = Os + M.uuid()), e._entries.length > 0 && n.getItem(e._tabKey) === null && (e._entries = []), e._entries.push(t), n.setItem(e._tabKey, JSON.stringify(e._entries)), !0;
9294
+ return e._tabKey || (e._tabKey = js + M.uuid()), e._entries.length > 0 && n.getItem(e._tabKey) === null && (e._entries = []), e._entries.push(t), n.setItem(e._tabKey, JSON.stringify(e._entries)), !0;
9177
9295
  } catch (e) {
9178
9296
  return z.error("[StatUnloadJournal] failed to write", e), !1;
9179
9297
  }
@@ -9185,7 +9303,7 @@ var Os = "okcls-stat-unload.", ks = class e {
9185
9303
  try {
9186
9304
  for (let e = 0; e < t.length; e += 1) {
9187
9305
  let r = t.key(e);
9188
- r && r.startsWith(Os) && n.push(r);
9306
+ r && r.startsWith(js) && n.push(r);
9189
9307
  }
9190
9308
  } catch (e) {
9191
9309
  return z.error("[StatUnloadJournal] failed to scan journals", e), 0;
@@ -9228,32 +9346,32 @@ var Os = "okcls-stat-unload.", ks = class e {
9228
9346
  return typeof t == "object" && !!t && typeof t.uid == "number" && (t.vcid === null || typeof t.vcid == "string") && typeof t.ts == "number" && (t.delta === void 0 || t.delta === null || typeof t.delta == "number") && typeof t.ev == "object" && t.ev !== null;
9229
9347
  }
9230
9348
  };
9231
- h(ks, "_tabKey", null), h(ks, "_entries", []);
9349
+ h(Ms, "_tabKey", null), h(Ms, "_entries", []);
9232
9350
  //#endregion
9233
9351
  //#region src/classes/stat/StatDrainScheduler.ts
9234
- var As = 500, js = 100, Ms = 3e4, Ns = 1e3, Ps = 5e3, Fs = 3e3, Is = "okcls-stat-drain", Ls = class e {
9352
+ var Ns = 500, Ps = 100, Fs = 3e4, Is = 1e3, Ls = 5e3, Rs = 3e3, zs = "okcls-stat-drain", Bs = class e {
9235
9353
  static setApi(t) {
9236
- e._api = t, Ds.setApi(t);
9354
+ e._api = t, As.setApi(t);
9237
9355
  }
9238
9356
  static start(t) {
9239
- e.setApi(t), ks.drainToQueue().catch((e) => z.error("[StatDrainScheduler] failed to import unload journal", e)).then(async () => (Ts.prune(), await Q.evictOlderThan(os), await Q.evictToLimit(as), e._drain())).catch((e) => z.error("[StatDrainScheduler] failed to start", e));
9357
+ e.setApi(t), Ms.drainToQueue().catch((e) => z.error("[StatDrainScheduler] failed to import unload journal", e)).then(async () => (Os.prune(), await Q.evictOlderThan(ls), await Q.evictToLimit(cs), e._drain())).catch((e) => z.error("[StatDrainScheduler] failed to start", e));
9240
9358
  }
9241
9359
  static notifyAppended() {
9242
9360
  if (e._api) {
9243
- if (e._localCount += 1, e._localCount >= js) {
9361
+ if (e._localCount += 1, e._localCount >= Ps) {
9244
9362
  e._drain();
9245
9363
  return;
9246
9364
  }
9247
- e._state === "IDLE" && e._arm(Ms);
9365
+ e._state === "IDLE" && e._arm(Fs);
9248
9366
  }
9249
9367
  }
9250
9368
  static notifyCallFinished() {
9251
9369
  if (e._api) {
9252
- if (e._directBuffer.length > 0 && e._armDirect(Ns), e._state === "DRAINING") {
9370
+ if (e._directBuffer.length > 0 && e._armDirect(Is), e._state === "DRAINING") {
9253
9371
  e._callFinishedDuringDrain = !0;
9254
9372
  return;
9255
9373
  }
9256
- e._arm(Ns);
9374
+ e._arm(Is);
9257
9375
  }
9258
9376
  }
9259
9377
  static drainOnce() {
@@ -9262,7 +9380,7 @@ var As = 500, js = 100, Ms = 3e4, Ns = 1e3, Ps = 5e3, Fs = 3e3, Is = "okcls-stat
9262
9380
  if (!t) return !1;
9263
9381
  let n = e._currentUserId(), r = await Q.listUids(), i = !1, a = null;
9264
9382
  for (let o of r) try {
9265
- (o === n ? await e._drainCurrent(t, o) : await e._drainStored(t, o)) === As && (i = !0);
9383
+ (o === n ? await e._drainCurrent(t, o) : await e._drainStored(t, o)) === Ns && (i = !0);
9266
9384
  } catch (e) {
9267
9385
  a === null && (a = e);
9268
9386
  }
@@ -9276,20 +9394,20 @@ var As = 500, js = 100, Ms = 3e4, Ns = 1e3, Ps = 5e3, Fs = 3e3, Is = "okcls-stat
9276
9394
  z.error("[StatDrainScheduler] direct send skipped: event belongs to another user");
9277
9395
  return;
9278
9396
  }
9279
- e._directBuffer.push(t), e._directTimer === null && e._armDirect(Fs);
9397
+ e._directBuffer.push(t), e._directTimer === null && e._armDirect(Rs);
9280
9398
  }
9281
9399
  }
9282
9400
  static __resetForTests() {
9283
- Ds.__resetForTests(), e._clearTimer(), e._clearDirectTimer(), e._directBuffer = [], e._api = null, e._state = "IDLE", e._localCount = 0, e._callFinishedDuringDrain = !1, e._blockedSession = null;
9401
+ As.__resetForTests(), e._clearTimer(), e._clearDirectTimer(), e._directBuffer = [], e._api = null, e._state = "IDLE", e._localCount = 0, e._callFinishedDuringDrain = !1, e._blockedSession = null;
9284
9402
  }
9285
9403
  static _currentUserId() {
9286
9404
  return y.userId;
9287
9405
  }
9288
9406
  static async _drainCurrent(t, n) {
9289
9407
  if (e._isSessionBlocked()) return 0;
9290
- let r = await Q.readOldest(n, As);
9408
+ let r = await Q.readOldest(n, Ns);
9291
9409
  if (r.length === 0) return 0;
9292
- let i = await Ds.get(), a = r.map((t) => e._toClientStats(t, i)), o = r.map((e) => e.id);
9410
+ let i = await As.get(), a = r.map((t) => e._toClientStats(t, i)), o = r.map((e) => e.id);
9293
9411
  try {
9294
9412
  await t.logClientStats(a);
9295
9413
  } catch (t) {
@@ -9300,25 +9418,25 @@ var As = 500, js = 100, Ms = 3e4, Ns = 1e3, Ps = 5e3, Fs = 3e3, Is = "okcls-stat
9300
9418
  return await Q.remove(o), r.length;
9301
9419
  }
9302
9420
  static async _drainStored(t, n) {
9303
- let r = Ts.get(n);
9304
- if (!r || r.endpoint !== Ts.currentEndpoint()) return 0;
9305
- let i = await Q.readOldest(n, As);
9421
+ let r = Os.get(n);
9422
+ if (!r || r.endpoint !== Os.currentEndpoint()) return 0;
9423
+ let i = await Q.readOldest(n, Ns);
9306
9424
  if (i.length === 0) return 0;
9307
- let a = await Ds.get(), o = i.map((t) => e._toClientStats(t, a)), s = i.map((e) => e.id);
9425
+ let a = await As.get(), o = i.map((t) => e._toClientStats(t, a)), s = i.map((e) => e.id);
9308
9426
  try {
9309
9427
  await t.logClientStatsWith(r.sessionKey, o), z.debug("[StatDrainScheduler] delivered", i.length, "stored events of uid", n);
9310
9428
  } catch (t) {
9311
- if (e._isAuthError(t)) return z.error("[StatDrainScheduler] stored session expired, skipping uid", n), Ts.forget(n), 0;
9429
+ if (e._isAuthError(t)) return z.error("[StatDrainScheduler] stored session expired, skipping uid", n), Os.forget(n), 0;
9312
9430
  if (e._isRetryable(t)) throw t;
9313
9431
  return z.error("[StatDrainScheduler] batch rejected, dropping", t), await Q.remove(s), i.length;
9314
9432
  }
9315
9433
  return await Q.remove(s), i.length;
9316
9434
  }
9317
9435
  static _withLock(e) {
9318
- return typeof navigator > "u" || !navigator.locks ? e() : navigator.locks.request(Is, e);
9436
+ return typeof navigator > "u" || !navigator.locks ? e() : navigator.locks.request(zs, e);
9319
9437
  }
9320
9438
  static _isSessionError(e) {
9321
- return $o(e?.error_code);
9439
+ return ns(e?.error_code);
9322
9440
  }
9323
9441
  static _isReauthorizeFailure(e) {
9324
9442
  return e?.error === x.AUTH;
@@ -9331,7 +9449,7 @@ var As = 500, js = 100, Ms = 3e4, Ns = 1e3, Ps = 5e3, Fs = 3e3, Is = "okcls-stat
9331
9449
  }
9332
9450
  static _isAuthError(t) {
9333
9451
  let n = t?.error_code;
9334
- return e._isSessionError(t) || n === Qo.AUTH_LOGIN;
9452
+ return e._isSessionError(t) || n === ts.AUTH_LOGIN;
9335
9453
  }
9336
9454
  static _isRetryable(t) {
9337
9455
  if (e._isSessionError(t)) return !0;
@@ -9356,7 +9474,7 @@ var As = 500, js = 100, Ms = 3e4, Ns = 1e3, Ps = 5e3, Fs = 3e3, Is = "okcls-stat
9356
9474
  static async _flushDirect() {
9357
9475
  let t = e._api, n = e._directBuffer;
9358
9476
  if (e._directBuffer = [], !(!t || n.length === 0)) try {
9359
- let r = await Ds.get();
9477
+ let r = await As.get();
9360
9478
  await t.logClientStats(n.map((t) => e._toClientStats(t, r)));
9361
9479
  } catch (e) {
9362
9480
  z.error("[StatDrainScheduler] direct send failed, events lost", e);
@@ -9375,28 +9493,28 @@ var As = 500, js = 100, Ms = 3e4, Ns = 1e3, Ps = 5e3, Fs = 3e3, Is = "okcls-stat
9375
9493
  e._clearTimer(), e._state = "DRAINING", e._localCount = 0, e._callFinishedDuringDrain = !1;
9376
9494
  try {
9377
9495
  if (await e.drainOnce()) {
9378
- e._arm(Ps);
9496
+ e._arm(Ls);
9379
9497
  return;
9380
9498
  }
9381
9499
  if (e._callFinishedDuringDrain) {
9382
- e._arm(Ns);
9500
+ e._arm(Is);
9383
9501
  return;
9384
9502
  }
9385
9503
  if (e._localCount > 0) {
9386
- e._arm(Ms);
9504
+ e._arm(Fs);
9387
9505
  return;
9388
9506
  }
9389
9507
  e._state = "IDLE";
9390
9508
  } catch (t) {
9391
- z.error("[StatDrainScheduler] drain failed", t), e._arm(Ms);
9509
+ z.error("[StatDrainScheduler] drain failed", t), e._arm(Fs);
9392
9510
  }
9393
9511
  }
9394
9512
  }
9395
9513
  };
9396
- h(Ls, "_api", null), h(Ls, "_state", "IDLE"), h(Ls, "_timer", null), h(Ls, "_localCount", 0), h(Ls, "_callFinishedDuringDrain", !1), h(Ls, "_blockedSession", null), h(Ls, "_directBuffer", []), h(Ls, "_directTimer", null);
9514
+ h(Bs, "_api", null), h(Bs, "_state", "IDLE"), h(Bs, "_timer", null), h(Bs, "_localCount", 0), h(Bs, "_callFinishedDuringDrain", !1), h(Bs, "_blockedSession", null), h(Bs, "_directBuffer", []), h(Bs, "_directTimer", null);
9397
9515
  //#endregion
9398
9516
  //#region src/classes/StatsLogger.ts
9399
- var Rs = class extends f {
9517
+ var Vs = class extends f {
9400
9518
  constructor(e, t, n, r = () => void 0) {
9401
9519
  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();
9402
9520
  }
@@ -9476,7 +9594,13 @@ var Rs = class extends f {
9476
9594
  _now() {
9477
9595
  return Date.now() - this._serverTimeDelta;
9478
9596
  }
9479
- }, zs = class e extends f {
9597
+ };
9598
+ //#endregion
9599
+ //#region src/classes/stat/StatEventCollector.ts
9600
+ function Hs(e) {
9601
+ return Array.isArray(e) ? e.map(Hs) : e && typeof e == "object" ? Object.fromEntries(Object.entries(e).map(([e, t]) => [e, Hs(t)])) : e;
9602
+ }
9603
+ var Us = class e extends f {
9480
9604
  static __resetForTests() {
9481
9605
  e._pending = [], e._pendingOverflow = !1;
9482
9606
  }
@@ -9492,22 +9616,30 @@ var Rs = class extends f {
9492
9616
  return e._pending = [], e._pendingOverflow = !1, t;
9493
9617
  }
9494
9618
  constructor(e, t, n, r = () => void 0) {
9495
- super(), h(this, "_externalLogger", void 0), h(this, "_conversationIdProvider", void 0), h(this, "_topologyProvider", void 0), h(this, "_unloadMode", !1), h(this, "_legacy", void 0), this._externalLogger = t, this._conversationIdProvider = n, this._topologyProvider = r, this._legacy = N.statQueueEnabled ? null : new Rs(e, t, n, r);
9619
+ super(), h(this, "_externalLogger", void 0), h(this, "_conversationIdProvider", void 0), h(this, "_topologyProvider", void 0), h(this, "_unloadMode", !1), h(this, "_legacy", void 0), this._externalLogger = t, this._conversationIdProvider = n, this._topologyProvider = r, this._legacy = N.statQueueEnabled ? null : new Vs(e, t, n, r);
9496
9620
  }
9497
9621
  log(e, t, n = !1) {
9498
9622
  this._externalLogger && this._externalLogger.log(e, t, n);
9499
9623
  }
9500
9624
  enterUnloadMode() {
9501
- this._legacy || (this._unloadMode = !0, ks.beginTabSession());
9625
+ this._legacy || (this._unloadMode = !0, Ms.beginTabSession());
9502
9626
  }
9503
9627
  exitUnloadMode() {
9504
- this._legacy || !this._unloadMode || (this._unloadMode = !1, ks.drainToQueue().then((e) => {
9505
- e > 0 && Ls.notifyAppended();
9628
+ this._legacy || !this._unloadMode || (this._unloadMode = !1, Ms.drainToQueue().then((e) => {
9629
+ e > 0 && Bs.notifyAppended();
9506
9630
  }).catch((e) => z.error("[StatEventCollector] failed to import unload journal", e)));
9507
9631
  }
9508
9632
  logClientStats(t, n = {}) {
9509
- let r = n.conversationId === void 0 ? this._getConversationId() : n.conversationId, i = n.occurredAt === void 0 ? Date.now() : n.occurredAt;
9510
- if (R.onClientStats({
9633
+ let r = n.conversationId === void 0 ? this._getConversationId() : n.conversationId, i = n.occurredAt === void 0 ? Date.now() : n.occurredAt, a = {
9634
+ ...t,
9635
+ call_topology: t.call_topology ?? this._getCallTopology()
9636
+ };
9637
+ if (Object.keys(a).forEach((e) => {
9638
+ a[e] === void 0 && delete a[e];
9639
+ }), typeof a.name == "string" && R.onStatsEvent({
9640
+ type: a.name,
9641
+ payload: Hs(a)
9642
+ }), R.onClientStats({
9511
9643
  ...t,
9512
9644
  vcid: r,
9513
9645
  ts: i
@@ -9515,17 +9647,11 @@ var Rs = class extends f {
9515
9647
  this._legacy.logClientStats(t, n);
9516
9648
  return;
9517
9649
  }
9518
- let a = {
9519
- ...t,
9520
- call_topology: t.call_topology ?? this._getCallTopology()
9521
- };
9522
- Object.keys(a).forEach((e) => {
9523
- a[e] === void 0 && delete a[e];
9524
- }), Ds.ensure();
9650
+ As.ensure();
9525
9651
  let o = {
9526
9652
  vcid: r,
9527
9653
  ts: i,
9528
- delta: Ds.delta(),
9654
+ delta: As.delta(),
9529
9655
  ev: a
9530
9656
  }, s = y.userId;
9531
9657
  if (s === null) {
@@ -9548,12 +9674,12 @@ var Rs = class extends f {
9548
9674
  }
9549
9675
  }
9550
9676
  _store(e) {
9551
- this._unloadMode && ks.writeSync(e) || Q.append(e).then((t) => {
9677
+ this._unloadMode && Ms.writeSync(e) || Q.append(e).then((t) => {
9552
9678
  if (t !== null) {
9553
- typeof e.delta != "number" && Ds.noteAppended(t), Ls.notifyAppended();
9679
+ typeof e.delta != "number" && As.noteAppended(t), Bs.notifyAppended();
9554
9680
  return;
9555
9681
  }
9556
- z.error("[StatEventCollector] failed to store event, sending directly"), Ls.sendDirect(e);
9682
+ z.error("[StatEventCollector] failed to store event, sending directly"), Bs.sendDirect(e);
9557
9683
  }).catch((e) => z.error("[StatEventCollector] failed to store event", e));
9558
9684
  }
9559
9685
  _getConversationId() {
@@ -9571,10 +9697,10 @@ var Rs = class extends f {
9571
9697
  }
9572
9698
  }
9573
9699
  };
9574
- h(zs, "_pending", []), h(zs, "_pendingOverflow", !1);
9700
+ h(Us, "_pending", []), h(Us, "_pendingOverflow", !1);
9575
9701
  //#endregion
9576
9702
  //#region src/classes/stat/ApiCallStats.ts
9577
- var Bs = class {
9703
+ var Ws = class {
9578
9704
  constructor(e) {
9579
9705
  h(this, "_statAggregator", void 0), this._statAggregator = e;
9580
9706
  }
@@ -9586,7 +9712,7 @@ var Bs = class {
9586
9712
  string_value: n
9587
9713
  });
9588
9714
  }
9589
- }, Vs = "invalid-error-metadata", Hs = 64, Us = new Set(Object.values(O)), Ws = new Set(Object.values(x)), Gs = {
9715
+ }, Gs = "invalid-error-metadata", Ks = 64, qs = new Set(Object.values(O)), Js = new Set(Object.values(x)), Ys = {
9590
9716
  [O.CANCELED]: {
9591
9717
  type: "semantic",
9592
9718
  reason: "canceled"
@@ -9707,7 +9833,7 @@ var Bs = class {
9707
9833
  type: "semantic",
9708
9834
  reason: "obsolete_client"
9709
9835
  }
9710
- }, Ks = {
9836
+ }, Xs = {
9711
9837
  [x.MIC_CAMERA_PERMISSION]: {
9712
9838
  type: "direct-error",
9713
9839
  error: {
@@ -9796,14 +9922,14 @@ var Bs = class {
9796
9922
  }
9797
9923
  }
9798
9924
  };
9799
- function qs(e) {
9800
- if (typeof e != "string" && typeof e != "number" || typeof e == "number" && !Number.isFinite(e)) return Vs;
9925
+ function Zs(e) {
9926
+ if (typeof e != "string" && typeof e != "number" || typeof e == "number" && !Number.isFinite(e)) return Gs;
9801
9927
  let t = String(e).trim();
9802
- if (!t) return Vs;
9928
+ if (!t) return Gs;
9803
9929
  let n = t.toLowerCase().replace(/[\s_:]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
9804
- return !n || !/^[a-z0-9.-]+$/.test(n) ? Vs : n.length > Hs ? `${n.slice(0, Hs - 3)}...` : n;
9930
+ return !n || !/^[a-z0-9.-]+$/.test(n) ? Gs : n.length > Ks ? `${n.slice(0, Ks - 3)}...` : n;
9805
9931
  }
9806
- function Js(e) {
9932
+ function Qs(e) {
9807
9933
  if (!e || typeof e != "object") return !1;
9808
9934
  let t = e;
9809
9935
  switch (t.scope) {
@@ -9815,49 +9941,49 @@ function Js(e) {
9815
9941
  default: return !1;
9816
9942
  }
9817
9943
  }
9818
- function Ys(e) {
9819
- let t = qs(e.description);
9944
+ function $s(e) {
9945
+ let t = Zs(e.description);
9820
9946
  if (e.scope === "unknown") return `unknown:${t}`;
9821
- let n = qs(e.code);
9947
+ let n = Zs(e.code);
9822
9948
  return e.scope === "internal" ? `internal:${n}:${t}` : `${e.scope}:${e.source}:${n}:${t}`;
9823
9949
  }
9824
- function Xs(e, t) {
9950
+ function ec(e, t) {
9825
9951
  return t === null ? e.type === "direct-error" ? {
9826
9952
  reason: "error",
9827
- string_value: Ys(e.error)
9828
- } : { reason: "failed" } : Js(t) ? {
9953
+ string_value: $s(e.error)
9954
+ } : { reason: "failed" } : Qs(t) ? {
9829
9955
  reason: "error",
9830
- string_value: Ys(t)
9956
+ string_value: $s(t)
9831
9957
  } : { reason: "failed" };
9832
9958
  }
9833
- function Zs(e) {
9959
+ function tc(e) {
9834
9960
  if (e.hangup) {
9835
- let t = Gs[e.hangup];
9961
+ let t = Ys[e.hangup];
9836
9962
  return t ? t.type === "semantic" ? e.hangup === O.OBSOLETE_CLIENT && e.custom_error?.vchat_detailed_api_error.code ? {
9837
9963
  reason: t.reason,
9838
9964
  string_value: e.custom_error.vchat_detailed_api_error.code
9839
- } : { reason: t.reason } : Xs(t, e.callError) : { reason: "failed" };
9965
+ } : { reason: t.reason } : ec(t, e.callError) : { reason: "failed" };
9840
9966
  }
9841
9967
  if (e.error) {
9842
- let t = Ks[e.error];
9843
- return t ? Xs(t, e.callError) : { reason: "failed" };
9968
+ let t = Xs[e.error];
9969
+ return t ? ec(t, e.callError) : { reason: "failed" };
9844
9970
  }
9845
9971
  return { reason: "failed" };
9846
9972
  }
9847
- function Qs(e) {
9848
- return e instanceof k ? Zs(e) : typeof e == "string" && (Us.has(e) || Ws.has(e)) ? Zs(new k(e)) : { reason: "failed" };
9973
+ function nc(e) {
9974
+ return e instanceof k ? tc(e) : typeof e == "string" && (qs.has(e) || Js.has(e)) ? tc(new k(e)) : { reason: "failed" };
9849
9975
  }
9850
9976
  //#endregion
9851
9977
  //#region src/classes/stat/CallLifecycleStats.ts
9852
- var $s = {
9978
+ var rc = {
9853
9979
  wallNow: () => Date.now(),
9854
9980
  monotonicNow: () => performance.now()
9855
9981
  };
9856
- function ec(e) {
9982
+ function ic(e) {
9857
9983
  return e === "anonym_join" ? "join" : e;
9858
9984
  }
9859
- var tc = class {
9860
- constructor(e, t = $s) {
9985
+ var ac = class {
9986
+ constructor(e, t = rc) {
9861
9987
  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;
9862
9988
  }
9863
9989
  get firstMediaSentReported() {
@@ -9869,7 +9995,7 @@ var tc = class {
9869
9995
  markInitializationStarted({ source: e, conversationId: t }) {
9870
9996
  if (this._destroyed || this._callStartLabel !== null) return;
9871
9997
  let n = this._clock.wallNow();
9872
- this._callStartLabel = ec(e), this._lifecycleStartedAtMonotonic = this._clock.monotonicNow(), t && (this._conversationId = t), this._record({
9998
+ this._callStartLabel = ic(e), this._lifecycleStartedAtMonotonic = this._clock.monotonicNow(), t && (this._conversationId = t), this._record({
9873
9999
  name: U.CALL_INIT,
9874
10000
  source: e
9875
10001
  }, n);
@@ -9897,7 +10023,7 @@ var tc = class {
9897
10023
  !this._canRecord() || this._firstMediaSent || (this._firstMediaSent = !0, this._record({ name: U.FIRST_MEDIA_SENT }));
9898
10024
  }
9899
10025
  markFinished(e) {
9900
- this._finish(Qs(e));
10026
+ this._finish(nc(e));
9901
10027
  }
9902
10028
  markTerminated() {
9903
10029
  this._finish({ reason: "terminated" });
@@ -9948,7 +10074,7 @@ var tc = class {
9948
10074
  ...n && { immediately: !0 }
9949
10075
  });
9950
10076
  }
9951
- }, nc = class {
10077
+ }, oc = class {
9952
10078
  constructor(e, t) {
9953
10079
  h(this, "_logger", void 0), h(this, "_codecUsages", /* @__PURE__ */ new Map()), h(this, "getCurrentTransportTopology", void 0), this._logger = e, this.getCurrentTransportTopology = t;
9954
10080
  }
@@ -10011,7 +10137,7 @@ var tc = class {
10011
10137
  this.report(e);
10012
10138
  }), this._codecUsages.clear();
10013
10139
  }
10014
- }, rc = class {
10140
+ }, sc = class {
10015
10141
  constructor(e) {
10016
10142
  h(this, "_logger", void 0), h(this, "_eventualLogs", /* @__PURE__ */ new Set()), h(this, "_lastCallStatContext", null), this._logger = e;
10017
10143
  }
@@ -10054,7 +10180,7 @@ var tc = class {
10054
10180
  for (let [t, r] of Object.entries(e)) r !== void 0 && (r === null ? delete n[t] : n[t] = r);
10055
10181
  this._logger.logClientStats(n, { occurredAt: t });
10056
10182
  }
10057
- }, ic = class {
10183
+ }, cc = class {
10058
10184
  constructor(e) {
10059
10185
  if (h(this, "q", void 0), h(this, "inits", []), h(this, "n", [
10060
10186
  1,
@@ -10113,7 +10239,7 @@ var tc = class {
10113
10239
  5
10114
10240
  ];
10115
10241
  }
10116
- }, ac = class {
10242
+ }, lc = class {
10117
10243
  constructor() {
10118
10244
  h(this, "n", 0), h(this, "mean", 0);
10119
10245
  }
@@ -10125,9 +10251,9 @@ var tc = class {
10125
10251
  get avg() {
10126
10252
  return this.n ? this.mean : NaN;
10127
10253
  }
10128
- }, oc = class {
10254
+ }, uc = class {
10129
10255
  constructor() {
10130
- h(this, "count", 0), h(this, "minVal", Infinity), h(this, "maxVal", -Infinity), h(this, "mean", new ac()), h(this, "p50", new ic(.5)), h(this, "p95", new ic(.95));
10256
+ h(this, "count", 0), h(this, "minVal", Infinity), h(this, "maxVal", -Infinity), h(this, "mean", new lc()), h(this, "p50", new cc(.5)), h(this, "p95", new cc(.95));
10131
10257
  }
10132
10258
  add(e) {
10133
10259
  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++;
@@ -10145,18 +10271,18 @@ var tc = class {
10145
10271
  get hasData() {
10146
10272
  return this.count > 0;
10147
10273
  }
10148
- }, sc = 300 * 1e3, cc = class {
10274
+ }, dc = 120 * 1e3, fc = class {
10149
10275
  constructor(e) {
10150
10276
  h(this, "_logger", void 0), h(this, "trackerByTransport", {
10151
- ws: new oc(),
10152
- wt: new oc()
10277
+ ws: new uc(),
10278
+ wt: new uc()
10153
10279
  }), h(this, "lastSeen", {}), this._logger = e;
10154
10280
  }
10155
10281
  mark(e) {
10156
10282
  let t = Date.now(), n = this.lastSeen[e];
10157
10283
  if (typeof n == "number") {
10158
10284
  let r = t - n;
10159
- r >= 0 && r <= sc && this.trackerByTransport[e].add(r);
10285
+ r >= 0 && r <= dc && this.trackerByTransport[e].add(r);
10160
10286
  }
10161
10287
  this.lastSeen[e] = t;
10162
10288
  }
@@ -10176,19 +10302,22 @@ var tc = class {
10176
10302
  });
10177
10303
  });
10178
10304
  }
10305
+ resetBaseline() {
10306
+ this.lastSeen = {};
10307
+ }
10179
10308
  destroy() {
10180
10309
  this.trackerByTransport = {
10181
- ws: new oc(),
10182
- wt: new oc()
10310
+ ws: new uc(),
10311
+ wt: new uc()
10183
10312
  }, this.lastSeen = {};
10184
10313
  }
10185
- }, lc = class {
10314
+ }, pc = class {
10186
10315
  constructor(e) {
10187
10316
  h(this, "_logger", void 0), h(this, "trackerByCommand", /* @__PURE__ */ new Map()), this._logger = e;
10188
10317
  }
10189
10318
  mark(e, t, n) {
10190
10319
  let r = `${e}|${n}`, i;
10191
- this.trackerByCommand.has(r) ? i = this.trackerByCommand.get(r) : (i = new oc(), this.trackerByCommand.set(r, i)), i.add(t);
10320
+ this.trackerByCommand.has(r) ? i = this.trackerByCommand.get(r) : (i = new uc(), this.trackerByCommand.set(r, i)), i.add(t);
10192
10321
  }
10193
10322
  logMetrics() {
10194
10323
  for (let [e, t] of this.trackerByCommand.entries()) {
@@ -10210,9 +10339,9 @@ var tc = class {
10210
10339
  destroy() {
10211
10340
  this.trackerByCommand.clear();
10212
10341
  }
10213
- }, uc = class {
10342
+ }, mc = class {
10214
10343
  constructor(e, t, n, r) {
10215
- 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), h(this, "apiCalls", void 0), h(this, "_api", void 0), h(this, "_unloading", !1), this.logger = new zs(e, t, n, r), this.lifecycle = new tc(this.logger), this.statAggregator = new rc(this.logger), this.codecStatsAggregator = new nc(this.logger, r), this.pings = new cc(this.logger), this.signalingCommands = new lc(this.logger), this.apiCalls = new Bs(this.statAggregator), this._api = e, this._api.setApiCallStats(this.apiCalls);
10344
+ 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), h(this, "apiCalls", void 0), h(this, "_api", void 0), h(this, "_unloading", !1), this.logger = new Us(e, t, n, r), this.lifecycle = new ac(this.logger), this.statAggregator = new sc(this.logger), this.codecStatsAggregator = new oc(this.logger, r), this.pings = new fc(this.logger), this.signalingCommands = new pc(this.logger), this.apiCalls = new Ws(this.statAggregator), this._api = e, this._api.setApiCallStats(this.apiCalls);
10216
10345
  }
10217
10346
  prepareForUnload() {
10218
10347
  N.statQueueEnabled && (this._unloading = !0, this.logger.enterUnloadMode(), this.pings.logMetrics(), this.signalingCommands.logMetrics());
@@ -10220,6 +10349,9 @@ var tc = class {
10220
10349
  restoreAfterUnload() {
10221
10350
  N.statQueueEnabled && (this._unloading = !1, this.logger.exitUnloadMode());
10222
10351
  }
10352
+ resetPingBaseline() {
10353
+ this.pings.resetBaseline();
10354
+ }
10223
10355
  logHangup(e) {
10224
10356
  this.lifecycle.markFinished(e);
10225
10357
  }
@@ -10227,9 +10359,9 @@ var tc = class {
10227
10359
  this.codecStatsAggregator.destroy(), this.pings.logMetrics(), this.pings.destroy(), this.signalingCommands.logMetrics(), this.signalingCommands.destroy();
10228
10360
  }
10229
10361
  destroy() {
10230
- this._api.setApiCallStats(null), this.lifecycle.markTerminated(), this.lifecycle.destroy(), this.statAggregator.destroy(), this.codecStatsAggregator.destroy(), this.pings.destroy(), this.signalingCommands.destroy(), this.logger.destroy(), N.statQueueEnabled && !this._unloading && Ls.notifyCallFinished();
10362
+ this._api.setApiCallStats(null), this.lifecycle.markTerminated(), this.lifecycle.destroy(), this.statAggregator.destroy(), this.codecStatsAggregator.destroy(), this.pings.destroy(), this.signalingCommands.destroy(), this.logger.destroy(), N.statQueueEnabled && !this._unloading && Bs.notifyCallFinished();
10231
10363
  }
10232
- }, dc = class {
10364
+ }, hc = class {
10233
10365
  constructor(e) {
10234
10366
  h(this, "_statAggregator", void 0), h(this, "_isCallMarked", !1), h(this, "_isFinished", !1), h(this, "_callType", null), this._statAggregator = e;
10235
10367
  }
@@ -10254,8 +10386,8 @@ var tc = class {
10254
10386
  call_type: this._callType
10255
10387
  }));
10256
10388
  }
10257
- }, fc = 1e3, pc = 1e4;
10258
- function mc(e, t, n, r) {
10389
+ }, gc = 1e3, _c = 1e4;
10390
+ function vc(e, t, n, r) {
10259
10391
  return new k(e, {
10260
10392
  callError: {
10261
10393
  scope: "external",
@@ -10266,11 +10398,11 @@ function mc(e, t, n, r) {
10266
10398
  message: r
10267
10399
  });
10268
10400
  }
10269
- var hc = 15, $ = class e extends b {
10401
+ var yc = 15, $ = class e extends b {
10270
10402
  constructor(e, t) {
10271
- 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", X.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", Mr()), h(this, "_serverTimeOffset", 0), h(this, "_delayedHangup", !1), h(this, "_onFastHangup", void 0), 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, "_onRestore", 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, "_toggleLocalVideo", jo((e) => {
10403
+ 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", X.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", Mr()), h(this, "_serverTimeOffset", 0), h(this, "_delayedHangup", !1), h(this, "_onFastHangup", void 0), 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, "_onRestore", void 0), h(this, "_onVisibilityChange", 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, "_toggleLocalVideo", Po((e) => {
10272
10404
  if (this._mediaSource) return this._stats.logger.log(C.MEDIA_STATUS, e ? "video_1" : "video_0"), this._mediaSource.toggleVideo(e);
10273
- })), h(this, "_toggleLocalAudio", jo((e) => {
10405
+ })), h(this, "_toggleLocalAudio", Po((e) => {
10274
10406
  if (this._mediaSource) return this._stats.logger.log(C.MEDIA_STATUS, e ? "audio_1" : "audio_0"), this._mediaSource.toggleAudio(e);
10275
10407
  })), h(this, "_changeMediaSettings", M.debounce(async (e) => {
10276
10408
  if (this._signaling.ready) try {
@@ -10282,7 +10414,7 @@ var hc = 15, $ = class e extends b {
10282
10414
  captureAudio: !1
10283
10415
  });
10284
10416
  }
10285
- }, 100)), this._stats = new uc(e, t, () => this._conversation?.id || null, () => this._transport?.getTopology() ?? this._conversation?.topology), this._api = e, this._signaling = new no(this._debug, this._stats.logger, this._stats.statAggregator, this._stats.pings, this._stats.signalingCommands), this._signalingActor = new Wo(this._onSignalingNotification.bind(this), this._debug), this._displayLayoutRequester = new Bo({
10417
+ }, 100)), this._stats = new mc(e, t, () => this._conversation?.id || null, () => this._transport?.getTopology() ?? this._conversation?.topology), this._api = e, this._signaling = new ao(this._debug, this._stats.logger, this._stats.statAggregator, this._stats.pings, this._stats.signalingCommands), this._signalingActor = new qo(this._onSignalingNotification.bind(this), this._debug), this._displayLayoutRequester = new Uo({
10286
10418
  api: this._api,
10287
10419
  debug: this._debug,
10288
10420
  getParticipants: () => this._participants,
@@ -10290,16 +10422,18 @@ var hc = 15, $ = class e extends b {
10290
10422
  updateDisplayLayout: (e) => this.updateDisplayLayout(e),
10291
10423
  onNonFatalError: (e) => this._onNonFatalError(e)
10292
10424
  }), this._onUnload = () => {
10293
- this._stopFirstMediaSentProbe(), this._conversation && this._api && this._sendHangupApi(this._conversation.id, this._state === "IDLE" ? O.CANCELED : O.HUNGUP), this._stats.prepareForUnload(), this._stats.destroy();
10425
+ this._stopFirstMediaSentProbe(), this._stats.resetPingBaseline(), this._conversation && this._api && this._sendHangupApi(this._conversation.id, this._state === "IDLE" ? O.CANCELED : O.HUNGUP), this._stats.prepareForUnload(), this._stats.destroy();
10294
10426
  }, this._onRestore = () => {
10295
- this._stats.restoreAfterUnload();
10296
- }, window.addEventListener("pagehide", this._onUnload), window.addEventListener("pageshow", this._onRestore), this._statFirstMediaReceived = new dc(this._stats.statAggregator), this._audioOutput = new No(this._statFirstMediaReceived, N.transparentAudio, this._debug, this._stats.logger), N.videoTracksCount > 0 && (this._cooldownQueueCleanupTimer = window.setInterval(this._cleanupCooldownQueue.bind(this), fc));
10427
+ this._stats.resetPingBaseline(), this._stats.restoreAfterUnload();
10428
+ }, this._onVisibilityChange = () => {
10429
+ document.visibilityState === "hidden" && this._stats.resetPingBaseline();
10430
+ }, window.addEventListener("pagehide", this._onUnload), window.addEventListener("pageshow", this._onRestore), document.addEventListener("visibilitychange", this._onVisibilityChange), this._statFirstMediaReceived = new hc(this._stats.statAggregator), this._audioOutput = new Io(this._statFirstMediaReceived, N.transparentAudio, this._debug, this._stats.logger), N.videoTracksCount > 0 && (this._cooldownQueueCleanupTimer = window.setInterval(this._cleanupCooldownQueue.bind(this), gc));
10297
10431
  }
10298
10432
  static current() {
10299
10433
  return B.getActive() ?? (N.hold ? null : B.getFirst());
10300
10434
  }
10301
10435
  static hangupAfterInit(e) {
10302
- let t = gc;
10436
+ let t = bc;
10303
10437
  if (t) {
10304
10438
  if (typeof e == "function" && (t._onFastHangup = e), t._delayedHangup === !1 && !t._conversation) {
10305
10439
  t._delayedHangup = !0, t._abortController?.abort(new k(O.CANCELED));
@@ -10327,7 +10461,7 @@ var hc = 15, $ = class e extends b {
10327
10461
  return this._state === "HELD";
10328
10462
  }
10329
10463
  get isIncomingRinging() {
10330
- return this._conversation?.direction === ro.INCOMING && this._state === "IDLE";
10464
+ return this._conversation?.direction === oo.INCOMING && this._state === "IDLE";
10331
10465
  }
10332
10466
  static debugSessionId() {
10333
10467
  return e.current()?.debugSessionId ?? null;
@@ -10353,7 +10487,7 @@ var hc = 15, $ = class e extends b {
10353
10487
  R.onNonFatalError(Error(e), this.id);
10354
10488
  }
10355
10489
  getIncomingCallerExternalId() {
10356
- return this._conversation?.direction === ro.INCOMING ? Object.values(this._participants).find((e) => !this._isMe(e.id))?.externalId ?? null : null;
10490
+ return this._conversation?.direction === oo.INCOMING ? Object.values(this._participants).find((e) => !this._isMe(e.id))?.externalId ?? null : null;
10357
10491
  }
10358
10492
  _buildInternalParams() {
10359
10493
  let e = {
@@ -10363,24 +10497,24 @@ var hc = 15, $ = class e extends b {
10363
10497
  platform: N.platform,
10364
10498
  protocolVersion: N.protocolVersion,
10365
10499
  domainId: N.domain,
10366
- capabilities: La.getFlags()
10500
+ capabilities: Ba.getFlags()
10367
10501
  };
10368
10502
  return JSON.stringify(e);
10369
10503
  }
10370
10504
  async onStart({ opponentIds: e, opponentType: t, mediaOptions: n, payload: r = "", joiningAllowed: i = !1, requireAuthToJoin: a = !1, onlyAdminCanShareMovie: o, externalIds: s, onFastStart: c, conversationId: l }) {
10371
- let u = l ?? M.uuid(), d = (e?.length ?? 0) + (s?.length ?? 0), f = t === io.USER && d === 1 ? N.calleeUnavailableWaitingTime : void 0;
10505
+ let u = l ?? M.uuid(), d = (e?.length ?? 0) + (s?.length ?? 0), f = t === so.USER && d === 1 ? N.calleeUnavailableWaitingTime : void 0;
10372
10506
  this._stats.lifecycle.markInitializationStarted({
10373
10507
  source: "outgoing",
10374
10508
  conversationId: u
10375
- }), this._debug.setConversationId(u), gc = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
10509
+ }), this._debug.setConversationId(u), bc = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
10376
10510
  try {
10377
10511
  this._mediaSource = this._createMediaSource(), await this._mediaSource.request(n);
10378
10512
  let l = this._mediaSource.mediaSettings;
10379
- t === io.CHAT || e && e.length > 1 ? this._logWithMediaSettings(C.OUTGOING_MULTIPARTY_CALL, l) : this._logWithMediaSettings(C.OUTGOING_CALL, l);
10513
+ t === so.CHAT || e && e.length > 1 ? this._logWithMediaSettings(C.OUTGOING_MULTIPARTY_CALL, l) : this._logWithMediaSettings(C.OUTGOING_CALL, l);
10380
10514
  let d = await this._startConversation({
10381
10515
  opponentIds: e,
10382
10516
  opponentType: t,
10383
- direction: ro.OUTGOING,
10517
+ direction: oo.OUTGOING,
10384
10518
  mediaOptions: n,
10385
10519
  payload: r,
10386
10520
  joiningAllowed: i,
@@ -10404,18 +10538,18 @@ var hc = 15, $ = class e extends b {
10404
10538
  let e = B.get(this._conversation.id);
10405
10539
  e && e !== this && e._close(new k(O.HUNGUP, { remote: !0 }));
10406
10540
  }
10407
- return B.add(this), await B.setActive(this.id), gc = null, this._conversation.concurrent && await this._acceptConcurrent(), f && !this._registeredPeerReceived && this._state !== "CLOSE" && (this._calleeUnavailableTimer = window.setTimeout(() => {
10541
+ return B.add(this), await B.setActive(this.id), bc = null, this._conversation.concurrent && await this._acceptConcurrent(), f && !this._registeredPeerReceived && this._state !== "CLOSE" && (this._calleeUnavailableTimer = window.setTimeout(() => {
10408
10542
  this._calleeUnavailableTimer = null, this._close(new k(O.CALLEE_UNAVAILABLE), { signalingReason: O.CANCELED });
10409
10543
  }, f)), this._conversation;
10410
10544
  } catch (e) {
10411
- throw gc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to start conversation" }), e;
10545
+ throw bc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to start conversation" }), e;
10412
10546
  }
10413
10547
  }
10414
10548
  async onJoin(e) {
10415
10549
  this._stats.lifecycle.markInitializationStarted({
10416
10550
  source: e.anonymous ? "anonym_join" : "join",
10417
10551
  conversationId: e.conversationId
10418
- }), gc = 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);
10552
+ }), bc = 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);
10419
10553
  try {
10420
10554
  let t = !!e.observedIds?.length;
10421
10555
  if (t && N.videoTracksCount > 0) throw this._debug.error("Observer mode: please set videoTracksCount=0"), new k(O.UNSUPPORTED, { callError: {
@@ -10432,9 +10566,9 @@ var hc = 15, $ = class e extends b {
10432
10566
  code: "conversation",
10433
10567
  description: "not-initialized-after-join"
10434
10568
  } });
10435
- 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), gc = null, this._signaling.readyToSend(), R.onLocalStatus(this._conversation.waitForAdmin ? P.WAIT_FOR_ADMIN : P.WAITING_HALL, this.id), this._conversation) : this._onJoinPart2(r);
10569
+ 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), bc = null, this._signaling.readyToSend(), R.onLocalStatus(this._conversation.waitForAdmin ? P.WAIT_FOR_ADMIN : P.WAITING_HALL, this.id), this._conversation) : this._onJoinPart2(r);
10436
10570
  } catch (e) {
10437
- throw gc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
10571
+ throw bc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
10438
10572
  }
10439
10573
  }
10440
10574
  async _onJoinPart2(e, t = !0, n = !1) {
@@ -10449,7 +10583,7 @@ var hc = 15, $ = class e extends b {
10449
10583
  if (this._delayedHangup) throw new k(O.CANCELED);
10450
10584
  this._processConnectionSharedMovieInfo(e), this._processConversationUrlSharingInfo(e), this._processConnectionAsrInfo(e);
10451
10585
  let r = this._extractExternalRoomsData(e.rooms?.rooms, e.rooms?.roomId);
10452
- 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), gc = null);
10586
+ 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), bc = null);
10453
10587
  let i = this._extractLocalParticipantFromConnection(e);
10454
10588
  if (i) {
10455
10589
  let e = M.mapParticipantState(i);
@@ -10457,7 +10591,7 @@ var hc = 15, $ = class e extends b {
10457
10591
  }
10458
10592
  return t && this._openTransport(Object.values(this._participants), !1), this._conversation;
10459
10593
  } catch (e) {
10460
- throw gc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
10594
+ throw bc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
10461
10595
  }
10462
10596
  }
10463
10597
  _extractExternalRooms(e) {
@@ -10477,7 +10611,7 @@ var hc = 15, $ = class e extends b {
10477
10611
  B.reserve(e), this._reservedId = e, a && this._api.setUserId(a), this._stats.lifecycle.markInitializationStarted({
10478
10612
  source: "incoming",
10479
10613
  conversationId: e
10480
- }), this._debug.setConversationId(e), gc = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
10614
+ }), this._debug.setConversationId(e), bc = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
10481
10615
  try {
10482
10616
  let a = await this._prepareConversation(e, t, n, r, i);
10483
10617
  if (this._mediaSource = this._createMediaSource(), !this._conversation) throw new k(O.UNKNOWN_ERROR, { callError: {
@@ -10486,20 +10620,20 @@ var hc = 15, $ = class e extends b {
10486
10620
  description: "incoming-not-initialized"
10487
10621
  } });
10488
10622
  if (!a.conversation.participants.find((e) => e.state === X.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);
10489
- 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), gc = null, this._delayedHangup) throw new k(O.CANCELED);
10623
+ 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), bc = null, this._delayedHangup) throw new k(O.CANCELED);
10490
10624
  } catch (e) {
10491
- throw gc = null, this._cleanupRegistry(), this._close(e, {
10625
+ throw bc = null, this._cleanupRegistry(), this._close(e, {
10492
10626
  errorText: "Unable to handle inbound call push",
10493
10627
  signalingReason: e instanceof k && e.hangup === O.BUSY ? O.BUSY : void 0
10494
10628
  }), e;
10495
10629
  }
10496
10630
  }
10497
10631
  _isInWaitingHall(e) {
10498
- return !e.conversation || !e.conversation.options.includes(so.WAITING_HALL) ? !1 : this._isRestricted(e);
10632
+ return !e.conversation || !e.conversation.options.includes(uo.WAITING_HALL) ? !1 : this._isRestricted(e);
10499
10633
  }
10500
10634
  _isWaitForAdmin(e) {
10501
10635
  if (!e.conversation) return !1;
10502
- let t = e.conversation.options.includes(so.WAIT_FOR_ADMIN), n = e.conversation.options.includes(so.ADMIN_IS_HERE);
10636
+ let t = e.conversation.options.includes(uo.WAIT_FOR_ADMIN), n = e.conversation.options.includes(uo.ADMIN_IS_HERE);
10503
10637
  return !t || t && n ? !1 : this._isRestricted(e);
10504
10638
  }
10505
10639
  _isRestricted(e) {
@@ -10507,7 +10641,7 @@ var hc = 15, $ = class e extends b {
10507
10641
  return t && t.restricted || !1;
10508
10642
  }
10509
10643
  _isAudienceMode(e) {
10510
- return e.conversation?.options?.includes(so.AUDIENCE_MODE) || !1;
10644
+ return e.conversation?.options?.includes(uo.AUDIENCE_MODE) || !1;
10511
10645
  }
10512
10646
  _isAudienceModeListener() {
10513
10647
  return this._conversation?.audienceMode && this._conversation?.restricted;
@@ -10537,7 +10671,7 @@ var hc = 15, $ = class e extends b {
10537
10671
  let i = atob(n), a = new Uint8Array(i.length);
10538
10672
  for (let e = 0; e < i.length; e++) a[e] = i.charCodeAt(e);
10539
10673
  try {
10540
- let e = Ao(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);
10674
+ let e = No(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);
10541
10675
  return {
10542
10676
  token: i,
10543
10677
  endpoint: l,
@@ -10740,10 +10874,10 @@ var hc = 15, $ = class e extends b {
10740
10874
  let t = await this._api.getConversationParams(e);
10741
10875
  this._debug.debug("Api.getConversationParams", t);
10742
10876
  let { turn_server: n, stun_server: r } = t;
10743
- return N.iceServers = ko(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;
10877
+ return N.iceServers = Mo(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;
10744
10878
  }
10745
10879
  _setConversationParams({ turn_server: e, stun_server: t, endpoint: n, wt_endpoint: r, token: i, client_type: a }) {
10746
- N.iceServers = ko(t, e), N.wssBase = n, N.wssToken = i, r && (N.wtsBase = r), a && (N.clientType = a);
10880
+ N.iceServers = Mo(t, e), N.wssBase = n, N.wssToken = i, r && (N.wtsBase = r), a && (N.clientType = a);
10747
10881
  }
10748
10882
  _buildSignalingEndpoint({ baseEndpoint: e, userId: t, type: n, deviceIdx: r, conversationId: i, token: a, conversationParams: o }) {
10749
10883
  let s = new URL(e), c = s.searchParams;
@@ -10775,10 +10909,10 @@ var hc = 15, $ = class e extends b {
10775
10909
  isVideo: f,
10776
10910
  joiningAllowed: a,
10777
10911
  requireAuthToJoin: o
10778
- }, this._abortController?.signal), !e) throw mc(O.FAST_START_ERROR, "invalid-response", "fast-start-response-empty");
10912
+ }, this._abortController?.signal), !e) throw vc(O.FAST_START_ERROR, "invalid-response", "fast-start-response-empty");
10779
10913
  if (!e.internalCallerParams) {
10780
10914
  let t = e.rejectedParticipants[0]?.status;
10781
- throw mc(O.FAST_START_ERROR, t ? "fast-start" : "invalid-response", t ?? "fast-start-internal-caller-params-empty", JSON.stringify(e));
10915
+ throw vc(O.FAST_START_ERROR, t ? "fast-start" : "invalid-response", t ?? "fast-start-internal-caller-params-empty", JSON.stringify(e));
10782
10916
  }
10783
10917
  } catch (e) {
10784
10918
  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) });
@@ -10800,10 +10934,10 @@ var hc = 15, $ = class e extends b {
10800
10934
  token: new URL(t.endpoint).searchParams.get("token") ?? ""
10801
10935
  }, this._debug.debug("FastStart", p), m = "fastStart";
10802
10936
  } catch {
10803
- throw mc(O.FAST_START_ERROR, "invalid-response", "fast-start-internal-caller-params-invalid");
10937
+ throw vc(O.FAST_START_ERROR, "invalid-response", "fast-start-internal-caller-params-invalid");
10804
10938
  }
10805
10939
  } else p = await this._api.startConversation(d, e, t, f, i, a, o, { onlyAdminCanShareMovie: s }, c), this._debug.debug("Api.startConversation", p), m = "startConversation";
10806
- Po(p, m), this._setConversationParams(p), this._stats.lifecycle.bindConversationId(p.id);
10940
+ Lo(p, m), this._setConversationParams(p), this._stats.lifecycle.bindConversationId(p.id);
10807
10941
  let ee = await this._connectSignaling(br.START, p);
10808
10942
  return this._setConversation(p, ee, n), this._stats.lifecycle.markCallStarted(), ee;
10809
10943
  }
@@ -10828,9 +10962,9 @@ var hc = 15, $ = class e extends b {
10828
10962
  joinLink: i,
10829
10963
  isVideo: c,
10830
10964
  internalParams: this._buildInternalParams()
10831
- }, this._abortController?.signal), !e) throw mc(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-response-empty");
10832
- if (!e.internalCallerParams) throw mc(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-empty", JSON.stringify(e));
10833
- if (!e.conversationId) throw mc(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-conversation-id-empty", JSON.stringify(e));
10965
+ }, this._abortController?.signal), !e) throw vc(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-response-empty");
10966
+ if (!e.internalCallerParams) throw vc(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-empty", JSON.stringify(e));
10967
+ if (!e.conversationId) throw vc(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-conversation-id-empty", JSON.stringify(e));
10834
10968
  } catch (e) {
10835
10969
  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) });
10836
10970
  }
@@ -10848,7 +10982,7 @@ var hc = 15, $ = class e extends b {
10848
10982
  token: new URL(t.endpoint).searchParams.get("token") ?? ""
10849
10983
  }, this._debug.debug("FastJoin", l), u = "fastJoin";
10850
10984
  } catch (e) {
10851
- throw e instanceof k ? e : mc(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-invalid");
10985
+ throw e instanceof k ? e : vc(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-invalid");
10852
10986
  }
10853
10987
  } else if (t) l = await this._api.joinConversation(t, c, r), u = "joinConversation";
10854
10988
  else if (i) l = await this._api.joinConversationByLink(i, c, a, o), u = "joinConversationByLink";
@@ -10857,13 +10991,13 @@ var hc = 15, $ = class e extends b {
10857
10991
  code: "join",
10858
10992
  description: "target-missing"
10859
10993
  } });
10860
- if (this._debug.debug("Api.joinConversation", l), l.id && this._stats.lifecycle.bindConversationId(l.id), Po(l, u), l.id) {
10994
+ if (this._debug.debug("Api.joinConversation", l), l.id && this._stats.lifecycle.bindConversationId(l.id), Lo(l, u), l.id) {
10861
10995
  if (B.has(l.id)) throw new k(O.HAS_ACTIVE_CALL);
10862
10996
  B.reserve(l.id), this._reservedId = l.id;
10863
10997
  }
10864
10998
  this._setConversationParams(l);
10865
10999
  let d = await this._connectSignaling(br.JOIN, l);
10866
- return this._setConversation(l, d, ro.JOINING), this._stats.lifecycle.markCallStarted(), d;
11000
+ return this._setConversation(l, d, oo.JOINING), this._stats.lifecycle.markCallStarted(), d;
10867
11001
  }
10868
11002
  async _prepareConversation(e, t = j.USER, n, r, i) {
10869
11003
  G.setMark(U.SIGNALING_CONNECTED), this._debug.debug("Conversation: push", {
@@ -10925,7 +11059,7 @@ var hc = 15, $ = class e extends b {
10925
11059
  }), l.wt_endpoint = c);
10926
11060
  }
10927
11061
  let u = await this._connectSignaling(br.ACCEPT, l);
10928
- 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, ro.INCOMING, t), u);
11062
+ 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, oo.INCOMING, t), u);
10929
11063
  }
10930
11064
  _createParticipant(e, t, n = !0) {
10931
11065
  let r = Object.assign({
@@ -10952,7 +11086,7 @@ var hc = 15, $ = class e extends b {
10952
11086
  let e = this._getParticipantId(t ?? r.id);
10953
11087
  e && (r.externalId = e);
10954
11088
  }
10955
- return n && i && this._api.cacheExternalId(t ?? r.id, r.externalId), t && this._api.mapDecorativeId(t, r.id), r.observedIds?.length && r.externalId && (r.externalId.observer = !0), e.markers && (r.markers = this._denormalizeMarkers(r.id, e.markers)), r.connectionStatus = vo.create(r.connectionStatus), r;
11089
+ return n && i && this._api.cacheExternalId(t ?? r.id, r.externalId), t && this._api.mapDecorativeId(t, r.id), r.observedIds?.length && r.externalId && (r.externalId.observer = !0), e.markers && (r.markers = this._denormalizeMarkers(r.id, e.markers)), r.connectionStatus = xo.create(r.connectionStatus), r;
10956
11090
  }
10957
11091
  _getParticipantId(e) {
10958
11092
  let t = this._api.userId(e);
@@ -11031,7 +11165,7 @@ var hc = 15, $ = class e extends b {
11031
11165
  }
11032
11166
  _createMediaSource() {
11033
11167
  let e = new Yt(this._debug, this._stats.logger);
11034
- return this.subscribe(e, qt.SOURCE_CHANGED, this._onLocalMediaStreamChanged.bind(this)), this.subscribe(e, qt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._audioFix = new Mo(e, this._debug, this._stats.logger), e;
11168
+ return this.subscribe(e, qt.SOURCE_CHANGED, this._onLocalMediaStreamChanged.bind(this)), this.subscribe(e, qt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._audioFix = new Fo(e, this._debug, this._stats.logger), e;
11035
11169
  }
11036
11170
  async _connectSignaling(e, t) {
11037
11171
  this._signaling.setEndpoint(t.endpoint), this._signaling.setWebTransportEndpoint(t.wt_endpoint ? t.wt_endpoint : null), this.subscribe(this._signaling, xr.NOTIFICATION, (e) => this._signalingActor.add(e)), this.subscribe(this._signaling, xr.FAILED, this._onSignalingFailed.bind(this)), this.subscribe(this._signaling, xr.RECONNECT, this._onSignalingReconnect.bind(this));
@@ -11039,7 +11173,7 @@ var hc = 15, $ = class e extends b {
11039
11173
  return this._stats.statAggregator.logEventualStatSinceMark({ name: U.SIGNALING_CONNECTED }), n;
11040
11174
  }
11041
11175
  async _processConnection(e) {
11042
- await this._registerConnectionParticipants(e), this._processRooms(e), this._processMuteStates(e), this._processRecordInfos(e), this._onOptionsChanged(e.conversation.options), e.chatRoom && e.chatRoom.totalCount && this._onChatRoomUpdated(ao.ATTENDEE, e.chatRoom.totalCount, e.chatRoom.firstParticipants, null, null);
11176
+ await this._registerConnectionParticipants(e), this._processRooms(e), this._processMuteStates(e), this._processRecordInfos(e), this._onOptionsChanged(e.conversation.options), e.chatRoom && e.chatRoom.totalCount && this._onChatRoomUpdated(co.ATTENDEE, e.chatRoom.totalCount, e.chatRoom.firstParticipants, null, null);
11043
11177
  }
11044
11178
  _onConversationParticipantListChunk(e) {
11045
11179
  let t = e.participants;
@@ -11108,7 +11242,7 @@ var hc = 15, $ = class e extends b {
11108
11242
  _registerParticipantLocalMuteState({ muteStates: e, unmuteOptions: t }) {
11109
11243
  if (!e) return;
11110
11244
  let n = async () => {
11111
- let n = So(e, uo.MUTE), r = So(e, uo.MUTE_PERMANENT);
11245
+ let n = To(e, mo.MUTE), r = To(e, mo.MUTE_PERMANENT);
11112
11246
  for (let i of [n, r]) i.length && await this._onMuteParticipant({
11113
11247
  muteStates: e,
11114
11248
  unmuteOptions: t,
@@ -11122,8 +11256,8 @@ var hc = 15, $ = class e extends b {
11122
11256
  if (!(!N.enableSessionStateUpdates || this._isMe(e))) return t;
11123
11257
  }
11124
11258
  _buildConnectionStatus(e, t, n, r = !1) {
11125
- return vo.create({
11126
- transport: r ? P.ONHOLD : vo.fromTransportState(n) ?? P.WAITING,
11259
+ return xo.create({
11260
+ transport: r ? P.ONHOLD : xo.fromTransportState(n) ?? P.WAITING,
11127
11261
  sessionState: this._remoteParticipantSessionState(e, t),
11128
11262
  sessionStateApplicable: this._isParticipantSessionStateApplicable(e)
11129
11263
  });
@@ -11132,12 +11266,12 @@ var hc = 15, $ = class e extends b {
11132
11266
  return N.enableSessionStateUpdates && !this._isMe(e) && this._conversation?.topology === J.SERVER;
11133
11267
  }
11134
11268
  _setTransportStatus(e, t) {
11135
- return vo.setTransport(e.connectionStatus, t);
11269
+ return xo.setTransport(e.connectionStatus, t);
11136
11270
  }
11137
11271
  _setSessionState(e, t) {
11138
- let n = vo.setSessionStateApplicable(e.connectionStatus, this._isParticipantSessionStateApplicable(e.id));
11272
+ let n = xo.setSessionStateApplicable(e.connectionStatus, this._isParticipantSessionStateApplicable(e.id));
11139
11273
  this._emitParticipantTransition(e, n);
11140
- let r = e.connectionStatus.sessionStateApplicable && e.id === this._activeSpeakerId && e.connectionStatus.transport === P.CONNECTED, i = vo.setSessionState(e.connectionStatus, t, r);
11274
+ let r = e.connectionStatus.sessionStateApplicable && e.id === this._activeSpeakerId && e.connectionStatus.transport === P.CONNECTED, i = xo.setSessionState(e.connectionStatus, t, r);
11141
11275
  return this._emitParticipantTransition(e, i), i;
11142
11276
  }
11143
11277
  _emitParticipantTransition(e, t, n = null) {
@@ -11208,11 +11342,11 @@ var hc = 15, $ = class e extends b {
11208
11342
  this._onRoomSwitched(t, !0);
11209
11343
  }
11210
11344
  _processMuteStates(e, t = !1) {
11211
- let n = Co(e);
11345
+ let n = Eo(e);
11212
11346
  this._setMuteStatesForRoomId(n, null);
11213
11347
  for (let t of e.rooms?.rooms ?? []) this._setMuteStatesForRoomId(t.muteStates, t.id);
11214
11348
  let r = this._getMuteStatesForCurrentRoom();
11215
- t && (r = Do(e, r));
11349
+ t && (r = Ao(e, r));
11216
11350
  let i = Object.keys(r), a = this._conversation?.roomId;
11217
11351
  i.length && this._onMuteParticipant({
11218
11352
  muteStates: r,
@@ -11232,15 +11366,15 @@ var hc = 15, $ = class e extends b {
11232
11366
  }
11233
11367
  _allocateTransport() {
11234
11368
  if (!this._conversation || !this._mediaSource) return;
11235
- this._transport = new wa(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 zo(this._debug), this.subscribe(this._transport, Y.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(this._transport, Y.LOCAL_STATE_CHANGED, this._onTransportLocalStateChanged.bind(this)), this.subscribe(this._transport, Y.REMOTE_TRACK_ADDED, this._onRemoteTrackAdded.bind(this)), this.subscribe(this._transport, Y.REMOTE_TRACK_REMOVED, this._onRemoteTrackRemoved.bind(this)), this.subscribe(this._transport, Y.AUDIO_MIX_STALL, this._onAudioMixStall.bind(this)), this.subscribe(this._transport, Y.REMOTE_DATA_STATS, this._onRemoteDataStats.bind(this)), this.subscribe(this._transport, Y.SIGNALLED_STALLED_PARTICIPANTS, this._onRemoteSignalledStall.bind(this)), this.subscribe(this._transport, Y.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this)), this.subscribe(this._transport, Y.NETWORK_STATUS, this._onNetworkStatus.bind(this)), this.subscribe(this._transport, Y.REMOTE_STREAM_SECOND, this._onRemoteStreamSecond.bind(this)), this.subscribe(this._transport, Y.PEER_CONNECTION_CLOSED, this._onPeerConnectionClosed.bind(this)), this.subscribe(this._transport, Y.ASR_TRANSCRIPTION, this._onAsrTranscription.bind(this)), this.subscribe(this._transport, Y.ANIMOJI_STREAM, this._onAnimojiStream.bind(this)), this.subscribe(this._transport, Y.ANIMOJI_ERROR, this._onAnimojiError.bind(this));
11236
- let e = this._conversation.direction === ro.OUTGOING && !this._conversation.concurrent, t = this._participants;
11369
+ this._transport = new Da(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, Y.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(this._transport, Y.LOCAL_STATE_CHANGED, this._onTransportLocalStateChanged.bind(this)), this.subscribe(this._transport, Y.REMOTE_TRACK_ADDED, this._onRemoteTrackAdded.bind(this)), this.subscribe(this._transport, Y.REMOTE_TRACK_REMOVED, this._onRemoteTrackRemoved.bind(this)), this.subscribe(this._transport, Y.AUDIO_MIX_STALL, this._onAudioMixStall.bind(this)), this.subscribe(this._transport, Y.REMOTE_DATA_STATS, this._onRemoteDataStats.bind(this)), this.subscribe(this._transport, Y.SIGNALLED_STALLED_PARTICIPANTS, this._onRemoteSignalledStall.bind(this)), this.subscribe(this._transport, Y.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this)), this.subscribe(this._transport, Y.NETWORK_STATUS, this._onNetworkStatus.bind(this)), this.subscribe(this._transport, Y.REMOTE_STREAM_SECOND, this._onRemoteStreamSecond.bind(this)), this.subscribe(this._transport, Y.PEER_CONNECTION_CLOSED, this._onPeerConnectionClosed.bind(this)), this.subscribe(this._transport, Y.ASR_TRANSCRIPTION, this._onAsrTranscription.bind(this)), this.subscribe(this._transport, Y.ANIMOJI_STREAM, this._onAnimojiStream.bind(this)), this.subscribe(this._transport, Y.ANIMOJI_ERROR, this._onAnimojiError.bind(this));
11370
+ let e = this._conversation.direction === oo.OUTGOING && !this._conversation.concurrent, t = this._participants;
11237
11371
  for (let n of Object.values(t)) (n.state === X.ACCEPTED || n.state === X.CALLED) && this._allocateParticipantTransport(n.id, e);
11238
11372
  }
11239
11373
  _createSpeakerDetector() {
11240
- this._transport && this._conversation && (this._volumesDetector = new Ko(this._transport), this.subscribe(this._volumesDetector, Go.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this._speakerDetector = new Jo(this._volumesDetector, this._transport, this._conversation.topology), this.subscribe(this._speakerDetector, qo.SPEAKER_CHANGED, this._onSpeakerChanged.bind(this)), this._localVolumeDetector = new Uo(this._mediaSource));
11374
+ this._transport && this._conversation && (this._volumesDetector = new Yo(this._transport), this.subscribe(this._volumesDetector, Jo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this._speakerDetector = new Zo(this._volumesDetector, this._transport, this._conversation.topology), this.subscribe(this._speakerDetector, Xo.SPEAKER_CHANGED, this._onSpeakerChanged.bind(this)), this._localVolumeDetector = new Ko(this._mediaSource));
11241
11375
  }
11242
11376
  _createSpecListener() {
11243
- this._transport && this._volumesDetector && (this._specListener = new Zo(this._transport, this._volumesDetector, this._participants, this._debug, this._stats.logger));
11377
+ this._transport && this._volumesDetector && (this._specListener = new es(this._transport, this._volumesDetector, this._participants, this._debug, this._stats.logger));
11244
11378
  }
11245
11379
  _logDevices() {
11246
11380
  let e = E.getCameras().length, t = E.getMicrophones().length;
@@ -11260,7 +11394,7 @@ var hc = 15, $ = class e extends b {
11260
11394
  }
11261
11395
  }
11262
11396
  _cleanupListeners() {
11263
- this.unsubscribe(), window.removeEventListener("pagehide", this._onUnload), window.removeEventListener("pageshow", this._onRestore);
11397
+ this.unsubscribe(), window.removeEventListener("pagehide", this._onUnload), window.removeEventListener("pageshow", this._onRestore), document.removeEventListener("visibilitychange", this._onVisibilityChange);
11264
11398
  }
11265
11399
  _cleanupMediaSource() {
11266
11400
  this._mediaSource && (this._mediaSource.destroy(), this._mediaSource = null);
@@ -11339,7 +11473,7 @@ var hc = 15, $ = class e extends b {
11339
11473
  _onRemoveParticipant(e) {
11340
11474
  this._debug.debug(`Remove participant [${e}]`);
11341
11475
  let t = [], n = this._participants;
11342
- for (let r = 0; r <= hc; r++) {
11476
+ for (let r = 0; r <= yc; r++) {
11343
11477
  let i = n[M.compose(e, r)];
11344
11478
  i && t.push(i);
11345
11479
  }
@@ -11429,11 +11563,11 @@ var hc = 15, $ = class e extends b {
11429
11563
  this._waitingHallHoldPending = !1, await this._resumeLocalMedia(t, this._getWaitingForPromotionStatus()), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener();
11430
11564
  return;
11431
11565
  }
11432
- let n = Fa.get();
11566
+ let n = Ra.get();
11433
11567
  await this._signaling.hold(!1, n), this._restoreStateAfterHold();
11434
11568
  let r = null;
11435
11569
  if (this._state === "IDLE" && this._participantState === X.ACCEPTED && (r = Object.values(this._participants), r.some((e) => e.state === X.ACCEPTED) && (this._state = "ACTIVE", this._changeFeatureSet())), await this._resumeLocalMedia(t, P.WAITING), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), this._state === "ACTIVE") {
11436
- let e = this._conversation?.direction === ro.OUTGOING && !this._conversation.concurrent;
11570
+ let e = this._conversation?.direction === oo.OUTGOING && !this._conversation.concurrent;
11437
11571
  this._openTransport(r ?? Object.values(this._participants), e);
11438
11572
  }
11439
11573
  }
@@ -11556,13 +11690,13 @@ var hc = 15, $ = class e extends b {
11556
11690
  let n = Fn(e), a = i[n.participantId];
11557
11691
  if (a) {
11558
11692
  let e;
11559
- typeof t == "number" ? e = mo(t) : (this._debug.warn(`Unexpected error code ${t} received for participant ${n.participantId}`), e = po.UNKNOWN_ERROR), r.push({
11693
+ typeof t == "number" ? e = _o(t) : (this._debug.warn(`Unexpected error code ${t} received for participant ${n.participantId}`), e = go.UNKNOWN_ERROR), r.push({
11560
11694
  externalId: a.externalId,
11561
11695
  errorReason: e
11562
11696
  });
11563
11697
  }
11564
11698
  }
11565
- if (r && r.length && (this._debug.warn("Could not allocate one or more participants", r), t)) throw new _c("Could not allocate one or more participants", r);
11699
+ if (r && r.length && (this._debug.warn("Could not allocate one or more participants", r), t)) throw new xc("Could not allocate one or more participants", r);
11566
11700
  }
11567
11701
  async _cleanupCooldownQueue() {
11568
11702
  let e = {}, t = this._cooldownTimestampByStreamDescription.entries();
@@ -11570,7 +11704,7 @@ var hc = 15, $ = class e extends b {
11570
11704
  let n = t.next();
11571
11705
  if (n.done) break;
11572
11706
  let r = n.value;
11573
- if (r[1] + pc > Date.now()) break;
11707
+ if (r[1] + _c > Date.now()) break;
11574
11708
  let i = r[0];
11575
11709
  await this._stopStreaming(i), e[i] = { stopStream: !0 };
11576
11710
  } while (!0);
@@ -11774,10 +11908,10 @@ var hc = 15, $ = class e extends b {
11774
11908
  throw Error("transport is not initialized");
11775
11909
  }
11776
11910
  _isCallAdmin() {
11777
- return this._conversation ? M.includesOneOf(this._conversation.roles, [ho.ADMIN, ho.CREATOR]) : !1;
11911
+ return this._conversation ? M.includesOneOf(this._conversation.roles, [vo.ADMIN, vo.CREATOR]) : !1;
11778
11912
  }
11779
11913
  _checkAdminRole() {
11780
- if (this._conversation && !M.includesOneOf(this._conversation.roles, [ho.ADMIN, ho.CREATOR])) throw Error("You don't have the required permission");
11914
+ if (this._conversation && !M.includesOneOf(this._conversation.roles, [vo.ADMIN, vo.CREATOR])) throw Error("You don't have the required permission");
11781
11915
  }
11782
11916
  _isCalledState() {
11783
11917
  return this._participantState === X.CALLED;
@@ -11815,21 +11949,21 @@ var hc = 15, $ = class e extends b {
11815
11949
  async changeOptions(e) {
11816
11950
  if (this._signaling.ready && this._conversation) {
11817
11951
  this._checkAdminRole(), await this._signaling.changeOptions(e);
11818
- let t = lo(this._conversation.options, e);
11952
+ let t = po(this._conversation.options, e);
11819
11953
  this._onOptionsChanged(t);
11820
11954
  }
11821
11955
  }
11822
11956
  async getWaitingHall(e, t, n) {
11823
11957
  if (!this._signaling) return Promise.reject();
11824
11958
  let r = null;
11825
- if (e && (r = xo(e), r)) {
11959
+ if (e && (r = wo(e), r)) {
11826
11960
  let e = this._api.getDecorativeIdByInitialId(r.id);
11827
11961
  r.id = e ?? r.id;
11828
11962
  }
11829
11963
  let i = await this._signaling.getWaitingHall(r, t, n);
11830
11964
  if (i.error) return Promise.reject(i.message);
11831
11965
  let a = i.participants || [], { externalIds: o } = this._resolveWaitingHallExternalIds(a, "getWaitingHall"), s = null;
11832
- return a.length && i.hasMore && (s = bo(a[a.length - 1].id)), {
11966
+ return a.length && i.hasMore && (s = Co(a[a.length - 1].id)), {
11833
11967
  participants: o,
11834
11968
  pageMarker: s,
11835
11969
  totalCount: i.totalCount || 0
@@ -11863,7 +11997,7 @@ var hc = 15, $ = class e extends b {
11863
11997
  }
11864
11998
  async promoteParticipant(e, t) {
11865
11999
  if (this._signaling && this._conversation) try {
11866
- if (!M.includesOneOf(this._conversation.options, [so.WAITING_HALL, so.AUDIENCE_MODE])) throw Error("Unable to promote a participant in the conversation with current options");
12000
+ if (!M.includesOneOf(this._conversation.options, [uo.WAITING_HALL, uo.AUDIENCE_MODE])) throw Error("Unable to promote a participant in the conversation with current options");
11867
12001
  if (this._checkAdminRole(), !e && t) throw Error("participantId is required");
11868
12002
  await this._signaling.promoteParticipant(e, t);
11869
12003
  } catch (t) {
@@ -12035,7 +12169,7 @@ var hc = 15, $ = class e extends b {
12035
12169
  let a = this._transport?.getState();
12036
12170
  return n.participants.forEach((e) => {
12037
12171
  let t = M.composeId(e), n = r[t];
12038
- this._updateParticipantExternalId(n, e), this._setSessionState(n, this._remoteParticipantSessionState(t, e.sessionState)), n.isOnHold || this._setTransportStatus(n, vo.fromTransportState(a) ?? P.WAITING), n.movieShareInfos = e.movieShareInfos, Object.assign(n.mediaSettings, D(e.mediaSettings)), Object.assign(n.muteStates, e.muteStates), n.unmuteOptions = e.unmuteOptions ?? n.unmuteOptions, this._openTransport([n], !0);
12172
+ this._updateParticipantExternalId(n, e), this._setSessionState(n, this._remoteParticipantSessionState(t, e.sessionState)), n.isOnHold || this._setTransportStatus(n, xo.fromTransportState(a) ?? P.WAITING), n.movieShareInfos = e.movieShareInfos, Object.assign(n.mediaSettings, D(e.mediaSettings)), Object.assign(n.muteStates, e.muteStates), n.unmuteOptions = e.unmuteOptions ?? n.unmuteOptions, this._openTransport([n], !0);
12039
12173
  }), this._participantListChunkToExternalChunk(n);
12040
12174
  }
12041
12175
  async _getInitialParticiapntListChunk() {
@@ -12049,7 +12183,7 @@ var hc = 15, $ = class e extends b {
12049
12183
  _onLocalMediaStreamChanged(e) {
12050
12184
  if (!this._conversation || !this._mediaSource) return;
12051
12185
  let t = this._mediaSource.mediaSettings;
12052
- this._debug.debug("Local media stream changed", t), e.kind === A.audio && this._mediaSource && (this._audioFix = new Mo(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);
12186
+ this._debug.debug("Local media stream changed", t), e.kind === A.audio && this._mediaSource && (this._audioFix = new Fo(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);
12053
12187
  }
12054
12188
  _onScreenSharingStatus(e) {
12055
12189
  let t = this.mediaSettings;
@@ -12179,9 +12313,9 @@ var hc = 15, $ = class e extends b {
12179
12313
  for (let n of e.conversation.participants) {
12180
12314
  let e = M.composeId(n), i = n.roles || [];
12181
12315
  if (this._isMe(e)) {
12182
- go(this._conversation.roles, i) || this._onRolesChanged(e, i), t = () => {
12316
+ yo(this._conversation.roles, i) || this._onRolesChanged(e, i), t = () => {
12183
12317
  this._registerParticipantLocalMuteState({
12184
- muteStates: Eo(n),
12318
+ muteStates: ko(n),
12185
12319
  unmuteOptions: n.unmuteOptions
12186
12320
  });
12187
12321
  };
@@ -12199,7 +12333,7 @@ var hc = 15, $ = class e extends b {
12199
12333
  let t = D(n.mediaSettings);
12200
12334
  Wt(t, a.mediaSettings) || this._changeRemoteMediaSettings(e, t);
12201
12335
  let r = M.mapParticipantState(n), o = a.participantState;
12202
- M.isEqualParticipantState(r, o) || await this._changeRemoteParticipantState(e, r), go(i, a.roles) || this._onRolesChanged(a.id, i), !!n.onHold != !!a.isOnHold && (a.isOnHold = !!n.onHold, this._setParticipantsStatus([a], n.onHold ? P.ONHOLD : P.CONNECTED));
12336
+ M.isEqualParticipantState(r, o) || await this._changeRemoteParticipantState(e, r), yo(i, a.roles) || this._onRolesChanged(a.id, i), !!n.onHold != !!a.isOnHold && (a.isOnHold = !!n.onHold, this._setParticipantsStatus([a], n.onHold ? P.ONHOLD : P.CONNECTED));
12203
12337
  }
12204
12338
  }
12205
12339
  let i = this._participants;
@@ -12224,7 +12358,7 @@ var hc = 15, $ = class e extends b {
12224
12358
  this._close(new k(O.ANOTHER_DEVICE), { errorText: "Call accepted on other device" });
12225
12359
  return;
12226
12360
  }
12227
- this._conversation?.direction === ro.OUTGOING && !this._conversation.concurrent && this._stats.lifecycle.markOutgoingAccepted();
12361
+ this._conversation?.direction === oo.OUTGOING && !this._conversation.concurrent && this._stats.lifecycle.markOutgoingAccepted();
12228
12362
  let r = this._getParticipant(t);
12229
12363
  if (!r) {
12230
12364
  let n = this._api.getDecorativeIdByInitialId(t);
@@ -12237,7 +12371,7 @@ var hc = 15, $ = class e extends b {
12237
12371
  let t = Z.fromSignaling(e.externalId, e.deviceIdx);
12238
12372
  r.externalId = t, this._api.cacheExternalId(r.id, t);
12239
12373
  }
12240
- r.state = X.ACCEPTED, r.mediaSettings = D(e.mediaSettings), this._logWithMediaSettings(C.ACCEPTED_OUTGOING, r.mediaSettings), this._conversation && this._conversation.direction === ro.OUTGOING && (this._state === "IDLE" || this._state === "PROCESSING") && (this._state = "ACTIVE", this._changeFeatureSet()), this._state === "ACTIVE" && this._transport && this._transport.open([r.id], n), this._changeRemoteMediaSettings(t, r.mediaSettings), await this._changeRemoteParticipantState(t);
12374
+ r.state = X.ACCEPTED, r.mediaSettings = D(e.mediaSettings), this._logWithMediaSettings(C.ACCEPTED_OUTGOING, r.mediaSettings), this._conversation && this._conversation.direction === oo.OUTGOING && (this._state === "IDLE" || this._state === "PROCESSING") && (this._state = "ACTIVE", this._changeFeatureSet()), this._state === "ACTIVE" && this._transport && this._transport.open([r.id], n), this._changeRemoteMediaSettings(t, r.mediaSettings), await this._changeRemoteParticipantState(t);
12241
12375
  let i = Object.keys(r.muteStates);
12242
12376
  if (i.length && this._onMuteParticipant({
12243
12377
  muteStates: r.muteStates,
@@ -12249,7 +12383,7 @@ var hc = 15, $ = class e extends b {
12249
12383
  this._reportMissingExternalIds([t], "ACCEPTED_CALL");
12250
12384
  return;
12251
12385
  }
12252
- R.onAcceptedCall(r.externalId, La.parseCapabilities(e.capabilities), this.id);
12386
+ R.onAcceptedCall(r.externalId, Ba.parseCapabilities(e.capabilities), this.id);
12253
12387
  }
12254
12388
  }
12255
12389
  async _onHungup(e) {
@@ -12286,7 +12420,7 @@ var hc = 15, $ = class e extends b {
12286
12420
  return;
12287
12421
  }
12288
12422
  if (e.connected) {
12289
- let e = vo.fromTransportState(this._transport?.getState());
12423
+ let e = xo.fromTransportState(this._transport?.getState());
12290
12424
  e && this._setTransportStatus(n, e);
12291
12425
  }
12292
12426
  this._setSessionState(n, { connected: e.connected });
@@ -12363,7 +12497,7 @@ var hc = 15, $ = class e extends b {
12363
12497
  isOnHold: !!r.onHold
12364
12498
  }, i), n = this._getParticipant(t);
12365
12499
  }
12366
- this._conversation && this._conversation.direction === ro.OUTGOING && (this._state === "IDLE" || this._state === "PROCESSING") && (this._state = "ACTIVE", this._changeFeatureSet()), n.state = X.ACCEPTED, n.mediaSettings = D(e.mediaSettings), n.participantState = M.mapParticipantState(e.participant), n.roles = e.participant.roles || [], this._updateParticipantSessionState(n, t, e.participant.sessionState), e.participant.onHold ? (n.isOnHold = !0, this._setParticipantsStatus([n], P.ONHOLD)) : this._transport?.isAllocated(n.id) ? this._setParticipantsStatus([n], P.CONNECTED) : this._setParticipantsStatus([n], P.WAITING), r && this._emitParticipantEffectiveStatusIfSessionOverridesTransport(n), this._state !== "IDLE" && this._transport && (this._transport.isAllocated(n.id) || this._allocateParticipantTransport(n.id, !0), this._transport.open([n.id], null, !!this._conversation?.observer)), R.onParticipantJoined(n.externalId, n.markers, this.id), this._changeRemoteMediaSettings(t, n.mediaSettings), await this._changeRemoteParticipantState(t, n.participantState), this._invokeRolesChangedCallbackIfNeeded(n);
12500
+ this._conversation && this._conversation.direction === oo.OUTGOING && (this._state === "IDLE" || this._state === "PROCESSING") && (this._state = "ACTIVE", this._changeFeatureSet()), n.state = X.ACCEPTED, n.mediaSettings = D(e.mediaSettings), n.participantState = M.mapParticipantState(e.participant), n.roles = e.participant.roles || [], this._updateParticipantSessionState(n, t, e.participant.sessionState), e.participant.onHold ? (n.isOnHold = !0, this._setParticipantsStatus([n], P.ONHOLD)) : this._transport?.isAllocated(n.id) ? this._setParticipantsStatus([n], P.CONNECTED) : this._setParticipantsStatus([n], P.WAITING), r && this._emitParticipantEffectiveStatusIfSessionOverridesTransport(n), this._state !== "IDLE" && this._transport && (this._transport.isAllocated(n.id) || this._allocateParticipantTransport(n.id, !0), this._transport.open([n.id], null, !!this._conversation?.observer)), R.onParticipantJoined(n.externalId, n.markers, this.id), this._changeRemoteMediaSettings(t, n.mediaSettings), await this._changeRemoteParticipantState(t, n.participantState), this._invokeRolesChangedCallbackIfNeeded(n);
12367
12501
  let i = Object.keys(n.muteStates);
12368
12502
  i.length && this._onMuteParticipant({
12369
12503
  muteStates: n.muteStates,
@@ -12554,15 +12688,15 @@ var hc = 15, $ = class e extends b {
12554
12688
  R.onAsrTranscription(t, e.text, e.timestamp, e.duration, this.id);
12555
12689
  }
12556
12690
  async _onRolesChanged(e, t) {
12557
- if (this._conversation && this._isMe(e) && !go(this._conversation.roles, t)) {
12691
+ if (this._conversation && this._isMe(e) && !yo(this._conversation.roles, t)) {
12558
12692
  this._debug.debug(`Local roles changed: ${t}`), this._conversation.roles = t, R.onLocalRolesChanged(t, !1, this.id), this._processMuteState({
12559
- mediaOptions: So(this._getMuteStatesForCurrentRoom(), uo.MUTE_PERMANENT),
12693
+ mediaOptions: To(this._getMuteStatesForCurrentRoom(), mo.MUTE_PERMANENT),
12560
12694
  stateUpdated: !0
12561
- }), M.includesOneOf(t, [ho.ADMIN, ho.CREATOR]) ? this._refreshRooms(!0) : t.length || this._onRoomSwitched(null);
12695
+ }), M.includesOneOf(t, [vo.ADMIN, vo.CREATOR]) ? this._refreshRooms(!0) : t.length || this._onRoomSwitched(null);
12562
12696
  return;
12563
12697
  }
12564
12698
  let n = this._getParticipant(e);
12565
- n && !go(n.roles, t) && (this._debug.debug(`Roles for participant [${e}] changed: ${t}`), n.roles = t, R.onRolesChanged(n.externalId, t, !1, this.id));
12699
+ n && !yo(n.roles, t) && (this._debug.debug(`Roles for participant [${e}] changed: ${t}`), n.roles = t, R.onRolesChanged(n.externalId, t, !1, this.id));
12566
12700
  }
12567
12701
  async _onMuteParticipant(e, t = !1) {
12568
12702
  if (!this._conversation) return;
@@ -12611,7 +12745,7 @@ var hc = 15, $ = class e extends b {
12611
12745
  let { mediaOptions: t = [], muteAll: n, unmute: r, stateUpdated: i, requestedMedia: a, roomId: o = null, unmuteOptions: s = [] } = e, c = e.adminId ? this._getExternalIdByParticipantId(e.adminId) : null, l = Object.assign({}, e.muteStates ?? this._getMuteStatesForRoomId(o)), u = this._mediaSource.mediaSettings, d = Object.entries(l);
12612
12746
  for (let [e, i] of d) {
12613
12747
  let a = this._isCallAdmin() && n;
12614
- if (!(i !== uo.MUTE && i !== uo.MUTE_PERMANENT || a) && (this._isCallAdmin() && i === uo.MUTE_PERMANENT && !n && (l[e] = uo.MUTE), !(!t.includes(e) || r))) switch (e) {
12748
+ if (!(i !== mo.MUTE && i !== mo.MUTE_PERMANENT || a) && (this._isCallAdmin() && i === mo.MUTE_PERMANENT && !n && (l[e] = mo.MUTE), !(!t.includes(e) || r))) switch (e) {
12615
12749
  case S.VIDEO:
12616
12750
  u.isVideoEnabled && (R.onDeviceSwitched(S.VIDEO, !1, this.id), await this.toggleLocalVideo(!1));
12617
12751
  break;
@@ -12648,7 +12782,7 @@ var hc = 15, $ = class e extends b {
12648
12782
  this._conversation.pinnedParticipantIdByRoom.set(r, t ? null : e);
12649
12783
  }
12650
12784
  _onOptionsChanged(e) {
12651
- this._conversation && !co(this._conversation.options, e) && (this._conversation.options = e, R.onOptionsChanged(e, this.id), e.includes(so.ADMIN_IS_HERE) ? this._conversation.restricted && this._conversation.waitingHall && R.onLocalStatus(P.WAITING_HALL, this.id) : e.includes(so.WAIT_FOR_ADMIN) && this._conversation.restricted && R.onLocalStatus(P.WAIT_FOR_ADMIN, this.id));
12785
+ this._conversation && !fo(this._conversation.options, e) && (this._conversation.options = e, R.onOptionsChanged(e, this.id), e.includes(uo.ADMIN_IS_HERE) ? this._conversation.restricted && this._conversation.waitingHall && R.onLocalStatus(P.WAITING_HALL, this.id) : e.includes(uo.WAIT_FOR_ADMIN) && this._conversation.restricted && R.onLocalStatus(P.WAIT_FOR_ADMIN, this.id));
12652
12786
  }
12653
12787
  async _onNetworkStatus(e) {
12654
12788
  if (this._conversation) {
@@ -12658,7 +12792,7 @@ var hc = 15, $ = class e extends b {
12658
12792
  if (this._isMe(r) || r === "") e = this._conversation.networkRating;
12659
12793
  else if (n[r]) e = n[r].networkRating;
12660
12794
  else continue;
12661
- if (e !== i) if (this._isMe(r) || r === "") this._conversation.networkRating = i, di.getInstance().value = i, R.onLocalNetworkStatusChanged(i, this.id);
12795
+ if (e !== i) if (this._isMe(r) || r === "") this._conversation.networkRating = i, mi.getInstance().value = i, R.onLocalNetworkStatusChanged(i, this.id);
12662
12796
  else {
12663
12797
  let e = n[r];
12664
12798
  e.networkRating = i, t.push({
@@ -12703,7 +12837,7 @@ var hc = 15, $ = class e extends b {
12703
12837
  }
12704
12838
  _changeFeatureSet() {
12705
12839
  if (this._conversation) {
12706
- let e = this._state === "ACTIVE", t = this._conversation.features.includes(oo.ADD_PARTICIPANT);
12840
+ let e = this._state === "ACTIVE", t = this._conversation.features.includes(lo.ADD_PARTICIPANT);
12707
12841
  R.onCallState(e, t, this._conversation, this.id);
12708
12842
  }
12709
12843
  }
@@ -12737,7 +12871,7 @@ var hc = 15, $ = class e extends b {
12737
12871
  let n = this._getParticipant(e);
12738
12872
  if (n) {
12739
12873
  if (n.connectionStatus.sessionStateApplicable && n.connectionStatus.sessionState?.connected === !1) {
12740
- let e = vo.fromTransportState(this._transport?.getState());
12874
+ let e = xo.fromTransportState(this._transport?.getState());
12741
12875
  e && this._setTransportStatus(n, e), n.connectionStatus.sessionStateConnectedBySpeaker = !0;
12742
12876
  let t = this._setTransportStatus(n, n.connectionStatus.transport);
12743
12877
  this._emitParticipantTransition(n, t);
@@ -12747,7 +12881,7 @@ var hc = 15, $ = class e extends b {
12747
12881
  }
12748
12882
  async _onTransportStateChanged(e, t) {
12749
12883
  this._debug.debug(`Transport state has changed: ${t}`, e);
12750
- let n = vo.fromTransportState(t);
12884
+ let n = xo.fromTransportState(t);
12751
12885
  if (!n) return;
12752
12886
  let r = this._participants, i = [], a = e.reduce((e, n) => {
12753
12887
  if (n in r) {
@@ -12781,9 +12915,9 @@ var hc = 15, $ = class e extends b {
12781
12915
  return e.every((e) => t[e]?.isOnHold);
12782
12916
  }
12783
12917
  _onRemoteTrackAdded(e, t, n) {
12784
- if (e.endsWith(si.AUDIO_MIX)) this._debug.debug("Remote audio mix track added"), this._audioOutput.add(e, n), R.onRemoteMixedAudioStream(t, this.id);
12785
- else if (e.startsWith(si.TRANSPARENT_AUDIO_TRACK_PREFIX)) this._debug.debug(`Remote transparent audio track added: ${e}`), this._audioOutput.add(e, n);
12786
- else if (e.startsWith(si.PARTICIPANT_AGNOSTIC_TRACK_PREFIX)) this._debug.debug(`Participant-agnostic track added: ${e}`), this._streamByStreamId.set(e, t);
12918
+ if (e.endsWith(ui.AUDIO_MIX)) this._debug.debug("Remote audio mix track added"), this._audioOutput.add(e, n), R.onRemoteMixedAudioStream(t, this.id);
12919
+ else if (e.startsWith(ui.TRANSPARENT_AUDIO_TRACK_PREFIX)) this._debug.debug(`Remote transparent audio track added: ${e}`), this._audioOutput.add(e, n);
12920
+ else if (e.startsWith(ui.PARTICIPANT_AGNOSTIC_TRACK_PREFIX)) this._debug.debug(`Participant-agnostic track added: ${e}`), this._streamByStreamId.set(e, t);
12787
12921
  else {
12788
12922
  this._debug.debug(`Remote track added on the participant [${e}]`, { kind: n.kind });
12789
12923
  let r = this._getParticipant(e);
@@ -12810,7 +12944,7 @@ var hc = 15, $ = class e extends b {
12810
12944
  }
12811
12945
  }
12812
12946
  async _removeAudioTrack(e, t, n) {
12813
- if (e !== si.AUDIO_MIX) {
12947
+ if (e !== ui.AUDIO_MIX) {
12814
12948
  let n = this._getParticipant(e);
12815
12949
  if (!n || n.remoteStream && n.remoteStream !== t) return;
12816
12950
  }
@@ -12825,7 +12959,7 @@ var hc = 15, $ = class e extends b {
12825
12959
  if (this._statFirstMediaReceived.markTopologyChanged(e), e === J.DIRECT && (this._onRemoteSignalledStall([]), this._onAudioMixStall(!1)), this._conversation) {
12826
12960
  this._conversation.topology = e;
12827
12961
  for (let e of Object.values(this._participants)) {
12828
- let t = vo.setSessionStateApplicable(e.connectionStatus, this._isParticipantSessionStateApplicable(e.id));
12962
+ let t = xo.setSessionStateApplicable(e.connectionStatus, this._isParticipantSessionStateApplicable(e.id));
12829
12963
  this._emitParticipantTransition(e, t);
12830
12964
  }
12831
12965
  this._changeFeatureSet(), this._forceOpenTransportForAloneInCall();
@@ -12881,7 +13015,7 @@ var hc = 15, $ = class e extends b {
12881
13015
  ].includes(t) ? null : this._setTransportStatus(e, t), n);
12882
13016
  }
12883
13017
  _setParticipantsStalled(e, t) {
12884
- this._updateParticipantsStatus(e, (e) => vo.setStalled(e.connectionStatus, t));
13018
+ this._updateParticipantsStatus(e, (e) => xo.setStalled(e.connectionStatus, t));
12885
13019
  }
12886
13020
  _updateParticipantsStatus(e, t, n = null) {
12887
13021
  let r = e.reduce((e, n) => {
@@ -12900,7 +13034,7 @@ var hc = 15, $ = class e extends b {
12900
13034
  _onRoomsUpdated(e) {
12901
13035
  if (this._isCalledState()) return;
12902
13036
  let t = {}, n = [], r = [];
12903
- for (let i of Object.keys(fo)) {
13037
+ for (let i of Object.keys(ho)) {
12904
13038
  let a = e.updates[i];
12905
13039
  a && (a?.rooms?.forEach((e) => {
12906
13040
  let { room: t, missingParticipantIds: i } = this._convertRoomToExternal(e);
@@ -12915,7 +13049,7 @@ var hc = 15, $ = class e extends b {
12915
13049
  }
12916
13050
  _onRoomUpdated(e) {
12917
13051
  let { room: t, missingParticipantIds: n } = this._convertRoomToExternal(e.room || null);
12918
- e.events.some((e) => e === fo.UPDATE) && (e.muteStates !== void 0 && this._setMuteStatesForRoomId(e.muteStates, e.roomId), e.recordInfo !== void 0 && this._conversation?.recordsInfoByRoom.set(e.roomId, e.recordInfo), e.asrInfo !== void 0 && this._conversation?.asrInfoByRoom.set(e.roomId, e.asrInfo)), this._isCalledState() || (this._reportMissingExternalIds(n, "ROOM_UPDATED"), R.onRoomUpdated(e.events, e.roomId, t, e.deactivate || null, this.id));
13052
+ e.events.some((e) => e === ho.UPDATE) && (e.muteStates !== void 0 && this._setMuteStatesForRoomId(e.muteStates, e.roomId), e.recordInfo !== void 0 && this._conversation?.recordsInfoByRoom.set(e.roomId, e.recordInfo), e.asrInfo !== void 0 && this._conversation?.asrInfoByRoom.set(e.roomId, e.asrInfo)), this._isCalledState() || (this._reportMissingExternalIds(n, "ROOM_UPDATED"), R.onRoomUpdated(e.events, e.roomId, t, e.deactivate || null, this.id));
12919
13053
  }
12920
13054
  _convertRoomToExternal(e) {
12921
13055
  if (!e) return {
@@ -13026,7 +13160,7 @@ var hc = 15, $ = class e extends b {
13026
13160
  n && r.push(n);
13027
13161
  }
13028
13162
  }
13029
- r.length && !this._isCalledState() && R.onRoomsUpdated({ [fo.UPDATE]: { rooms: r } }, this.id);
13163
+ r.length && !this._isCalledState() && R.onRoomsUpdated({ [ho.UPDATE]: { rooms: r } }, this.id);
13030
13164
  }
13031
13165
  _onFeedback(e) {
13032
13166
  let t = [];
@@ -13102,11 +13236,11 @@ var hc = 15, $ = class e extends b {
13102
13236
  _getParticipant(e) {
13103
13237
  return this._participants[e];
13104
13238
  }
13105
- }, gc = null, _c = class e extends Error {
13239
+ }, bc = null, xc = class e extends Error {
13106
13240
  constructor(t, n) {
13107
13241
  super(t), h(this, "participantErrors", void 0), Object.setPrototypeOf(this, e.prototype), this.participantErrors = n;
13108
13242
  }
13109
- }, vc = class {
13243
+ }, Sc = class {
13110
13244
  constructor() {
13111
13245
  h(this, "_abortSignal", void 0), h(this, "_apiCallStats", null);
13112
13246
  }
@@ -13151,14 +13285,14 @@ var hc = 15, $ = class e extends b {
13151
13285
  async getInbounds() {
13152
13286
  return [];
13153
13287
  }
13154
- }, yc = class e {
13288
+ }, Cc = class e {
13155
13289
  constructor() {
13156
13290
  h(this, "_participantIdToExternalId", /* @__PURE__ */ new Map()), h(this, "_externalIdToParticipantId", /* @__PURE__ */ new Map()), h(this, "_decorativeIdToInitialId", /* @__PURE__ */ new Map()), h(this, "_initialIdToDecorativeId", /* @__PURE__ */ new Map());
13157
13291
  }
13158
13292
  static _normalizeType(e) {
13159
- return e.type === yo.GROUP ? {
13293
+ return e.type === So.GROUP ? {
13160
13294
  ...e,
13161
- type: yo.USER
13295
+ type: So.USER
13162
13296
  } : e;
13163
13297
  }
13164
13298
  getExternalId(e) {
@@ -13186,27 +13320,27 @@ var hc = 15, $ = class e extends b {
13186
13320
  clear() {
13187
13321
  this._participantIdToExternalId.clear(), this._externalIdToParticipantId.clear(), this._decorativeIdToInitialId.clear(), this._initialIdToDecorativeId.clear();
13188
13322
  }
13189
- }, bc = "anonymLogin:", xc = 700, Sc = 3e3;
13190
- function Cc(e) {
13323
+ }, wc = "anonymLogin:", Tc = 700, Ec = 3e3;
13324
+ function Dc(e) {
13191
13325
  let t = e.error_code;
13192
13326
  switch (t) {
13193
- case 2: return wc(O.SERVICE_UNAVAILABLE, t, "service-unavailable");
13194
- case 4: return e.error_msg.includes("participants.limit.exceeded") ? wc(O.PARTICIPANT_LIMIT_REACHED, t, "participants-limit-exceeded") : wc(x.API, t, "request-error");
13195
- case 300: return wc(O.NOT_FOUND, t, "not-found");
13196
- case 1101: return wc(O.SERVICE_DISABLED, t, "vchat-service-disabled");
13197
- case 1102: return wc(O.CALLEE_IS_OFFLINE, t, "target-user-unavailable");
13198
- case 1103: return wc(O.NOT_FRIENDS, t, "friendship-required");
13199
- case 1104: return Ec(t, "youla-api-error");
13200
- case 1106: return Ec(t, "vk-api-error");
13201
- case 1113: return wc(O.CALLER_IS_REJECTED, t, "caller-is-rejected");
13327
+ case 2: return Oc(O.SERVICE_UNAVAILABLE, t, "service-unavailable");
13328
+ case 4: return e.error_msg.includes("participants.limit.exceeded") ? Oc(O.PARTICIPANT_LIMIT_REACHED, t, "participants-limit-exceeded") : Oc(x.API, t, "request-error");
13329
+ case 300: return Oc(O.NOT_FOUND, t, "not-found");
13330
+ case 1101: return Oc(O.SERVICE_DISABLED, t, "vchat-service-disabled");
13331
+ case 1102: return Oc(O.CALLEE_IS_OFFLINE, t, "target-user-unavailable");
13332
+ case 1103: return Oc(O.NOT_FRIENDS, t, "friendship-required");
13333
+ case 1104: return Ac(t, "youla-api-error");
13334
+ case 1106: return Ac(t, "vk-api-error");
13335
+ case 1113: return Oc(O.CALLER_IS_REJECTED, t, "caller-is-rejected");
13202
13336
  case 1114: {
13203
13337
  let n = e.custom_error?.vchat_detailed_api_error?.code, r = n?.startsWith("obsolete_client");
13204
- return wc(r ? O.OBSOLETE_CLIENT : O.VCHAT_DETAILED_ERROR, t, n ?? "detailed-error", r ? n : void 0);
13338
+ return Oc(r ? O.OBSOLETE_CLIENT : O.VCHAT_DETAILED_ERROR, t, n ?? "detailed-error", r ? n : void 0);
13205
13339
  }
13206
- default: return wc(x.API, t, "api-error");
13340
+ default: return Oc(x.API, t, "api-error");
13207
13341
  }
13208
13342
  }
13209
- function wc(e, t, n, r) {
13343
+ function Oc(e, t, n, r) {
13210
13344
  return {
13211
13345
  type: e,
13212
13346
  callError: {
@@ -13218,10 +13352,10 @@ function wc(e, t, n, r) {
13218
13352
  message: r
13219
13353
  };
13220
13354
  }
13221
- function Tc(e) {
13355
+ function kc(e) {
13222
13356
  return e?.error_code === void 0 ? e instanceof k && e.callError && "code" in e.callError ? String(e.callError.code) : e instanceof Error ? e.name : "network" : String(e.error_code);
13223
13357
  }
13224
- function Ec(e, t) {
13358
+ function Ac(e, t) {
13225
13359
  return {
13226
13360
  type: O.EXTERNAL_API_ERROR,
13227
13361
  callError: {
@@ -13232,21 +13366,21 @@ function Ec(e, t) {
13232
13366
  }
13233
13367
  };
13234
13368
  }
13235
- var Dc = class extends vc {
13369
+ var jc = class extends Sc {
13236
13370
  constructor(...e) {
13237
- super(...e), h(this, "_uuid", void 0), h(this, "_idCache", new yc());
13371
+ super(...e), h(this, "_uuid", void 0), h(this, "_idCache", new Cc());
13238
13372
  }
13239
13373
  async _callUnsafe(e, t = {}, n = !1) {
13240
13374
  let r = async (i) => {
13241
13375
  let a = performance.now();
13242
13376
  try {
13243
- let r = await _s(e, t, n);
13377
+ let r = await bs(e, t, n);
13244
13378
  return this._apiCallStats?.log(e, performance.now() - a), r;
13245
13379
  } catch (t) {
13246
- if (this._apiCallStats?.log(e, performance.now() - a, Tc(t)), !t || typeof t != "object" || !Object.hasOwn(t, "error_msg")) {
13380
+ if (this._apiCallStats?.log(e, performance.now() - a, kc(t)), !t || typeof t != "object" || !Object.hasOwn(t, "error_msg")) {
13247
13381
  i++;
13248
13382
  let n = t && (typeof t == "object" || typeof t == "function") ? Object.getOwnPropertyNames(t).map((e) => `${e}: ${JSON.stringify(t[e])}`) : [String(t)];
13249
- 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 * xc, Sc), { signal: this._abortSignal }), r(i);
13383
+ 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 * Tc, Ec), { signal: this._abortSignal }), r(i);
13250
13384
  }
13251
13385
  throw z.warn(e, "error", t), t;
13252
13386
  }
@@ -13258,13 +13392,13 @@ var Dc = class extends vc {
13258
13392
  return await this._callUnsafe(e, t, n);
13259
13393
  } catch (i) {
13260
13394
  if (z.warn("Api call error", i), i instanceof k) throw i;
13261
- if ($o(i?.error_code) && r) return await this._reauthorize(), this._call(e, t, n, !1);
13395
+ if (ns(i?.error_code) && r) return await this._reauthorize(), this._call(e, t, n, !1);
13262
13396
  let a = {
13263
13397
  message: i?.error_msg,
13264
13398
  code: i?.error_code
13265
13399
  };
13266
- if (i.custom_error && (a.custom_error = i.custom_error), Oc(i)) {
13267
- let e = Cc(i);
13400
+ if (i.custom_error && (a.custom_error = i.custom_error), Mc(i)) {
13401
+ let e = Dc(i);
13268
13402
  throw a.callError = e.callError, a.message = e.message ?? a.message, new k(e.type, a);
13269
13403
  }
13270
13404
  throw new k(x.API, a);
@@ -13294,7 +13428,7 @@ var Dc = class extends vc {
13294
13428
  return this._anonymLogin(N.authToken).then((e) => {
13295
13429
  this._applyAnonymLogin(e), this._setCachedAnonymLogin(e);
13296
13430
  }).catch((e) => {
13297
- throw e instanceof k ? e : (e?.error_code === Qo.AUTH_LOGIN && (this._removeCachedAnonymLogin(), R.onTokenExpired()), new k(x.AUTH, {
13431
+ throw e instanceof k ? e : (e?.error_code === ts.AUTH_LOGIN && (this._removeCachedAnonymLogin(), R.onTokenExpired()), new k(x.AUTH, {
13298
13432
  message: e?.error_msg,
13299
13433
  code: e?.error_code,
13300
13434
  callError: {
@@ -13316,17 +13450,17 @@ var Dc = class extends vc {
13316
13450
  return e && (t.session_data.auth_token = e, t.session_data.version = 3), this._callUnsafe("auth.anonymLogin", t, !0);
13317
13451
  }
13318
13452
  _getAnonymLoginCacheKey() {
13319
- return N.authToken ? `${bc}${N.authToken}` : null;
13453
+ return N.authToken ? `${wc}${N.authToken}` : null;
13320
13454
  }
13321
13455
  _getCachedAnonymLogin() {
13322
13456
  let e = this._getAnonymLoginCacheKey();
13323
13457
  if (!e) return null;
13324
13458
  let t = w.get(e);
13325
- return kc(t) ? t : (t && w.remove(e), null);
13459
+ return Nc(t) ? t : (t && w.remove(e), null);
13326
13460
  }
13327
13461
  _setCachedAnonymLogin(e) {
13328
13462
  let t = this._getAnonymLoginCacheKey();
13329
- !t || !kc(e) || w.set(t, {
13463
+ !t || !Nc(e) || w.set(t, {
13330
13464
  session_key: e.session_key,
13331
13465
  session_secret_key: e.session_secret_key,
13332
13466
  uid: e.uid
@@ -13340,9 +13474,9 @@ var Dc = class extends vc {
13340
13474
  return this._removeCachedAnonymLogin(), y.reauthorize(() => this.authorize());
13341
13475
  }
13342
13476
  _applyAnonymLogin(e) {
13343
- e.uid && (y.userId = Number(e.uid)), y.sessionKey = e.session_key, y.sessionSecretKey = e.session_secret_key, N.statQueueEnabled && e.uid && Ts.remember(Number(e.uid), {
13477
+ e.uid && (y.userId = Number(e.uid)), y.sessionKey = e.session_key, y.sessionSecretKey = e.session_secret_key, N.statQueueEnabled && e.uid && Os.remember(Number(e.uid), {
13344
13478
  sessionKey: e.session_key,
13345
- endpoint: Ts.currentEndpoint()
13479
+ endpoint: Os.currentEndpoint()
13346
13480
  });
13347
13481
  }
13348
13482
  _buildClientStatsData(e) {
@@ -13361,7 +13495,7 @@ var Dc = class extends vc {
13361
13495
  });
13362
13496
  }
13363
13497
  async _sendClientStatsWith(e, t) {
13364
- let n = await _s("vchat.clientStats", {
13498
+ let n = await bs("vchat.clientStats", {
13365
13499
  ...t,
13366
13500
  session_key: e
13367
13501
  }, !0);
@@ -13369,10 +13503,10 @@ var Dc = class extends vc {
13369
13503
  }
13370
13504
  async _sendClientStats(e, t, n = !0) {
13371
13505
  try {
13372
- let n = t ? await vs("vchat.clientStats", e) : await _s("vchat.clientStats", e);
13506
+ let n = t ? await xs("vchat.clientStats", e) : await bs("vchat.clientStats", e);
13373
13507
  this._reportClientStatsItemErrors(n);
13374
13508
  } catch (r) {
13375
- if (!n || !$o(r?.error_code)) throw r;
13509
+ if (!n || !ns(r?.error_code)) throw r;
13376
13510
  await this._reauthorize(), await this._sendClientStats(e, t, !1);
13377
13511
  }
13378
13512
  }
@@ -13396,14 +13530,14 @@ var Dc = class extends vc {
13396
13530
  }, a = await this._callUnsafe("vchat.getLogUploadUrl", i), o = new FormData(), s = new Blob([r], { type: "application/json" });
13397
13531
  o.append("file", s, "log.json");
13398
13532
  let c = new URL(a.upload_url);
13399
- return c.searchParams.append("size", s.size.toString()), xs(c.toString(), o);
13533
+ return c.searchParams.append("size", s.size.toString()), ws(c.toString(), o);
13400
13534
  }
13401
13535
  async joinConversation(e, t = !1, n) {
13402
13536
  let r = {
13403
13537
  conversationId: e,
13404
13538
  isVideo: t,
13405
13539
  protocolVersion: N.protocolVersion,
13406
- capabilities: La.getFlags()
13540
+ capabilities: Ba.getFlags()
13407
13541
  };
13408
13542
  return n && (r.chatId = n), this._call("vchat.joinConversation", r);
13409
13543
  }
@@ -13435,13 +13569,13 @@ var Dc = class extends vc {
13435
13569
  externalIds: l
13436
13570
  });
13437
13571
  if (t && t.length) switch (n) {
13438
- case io.USER:
13572
+ case so.USER:
13439
13573
  u.uids = t.join(",");
13440
13574
  break;
13441
- case io.GROUP:
13575
+ case so.GROUP:
13442
13576
  u.gid = t[0];
13443
13577
  break;
13444
- case io.CHAT:
13578
+ case so.CHAT:
13445
13579
  u.chatId = t[0];
13446
13580
  break;
13447
13581
  }
@@ -13484,7 +13618,7 @@ var Dc = class extends vc {
13484
13618
  joinLink: e,
13485
13619
  isVideo: t,
13486
13620
  protocolVersion: N.protocolVersion,
13487
- capabilities: La.getFlags()
13621
+ capabilities: Ba.getFlags()
13488
13622
  };
13489
13623
  return n?.length && (i.observedIds = n.join(",")), N.anonymToken && (i.anonymToken = N.anonymToken), r && (i.payload = r), this._call("vchat.joinConversationByLink", i);
13490
13624
  }
@@ -13514,9 +13648,9 @@ var Dc = class extends vc {
13514
13648
  return y.userId;
13515
13649
  }
13516
13650
  setUserId(e) {
13517
- y.userId = e, N.statQueueEnabled && y.sessionKey && Ts.remember(Number(e), {
13651
+ y.userId = e, N.statQueueEnabled && y.sessionKey && Os.remember(Number(e), {
13518
13652
  sessionKey: y.sessionKey,
13519
- endpoint: Ts.currentEndpoint()
13653
+ endpoint: Os.currentEndpoint()
13520
13654
  });
13521
13655
  }
13522
13656
  hangupConversation(e, t = O.HUNGUP, n) {
@@ -13524,7 +13658,7 @@ var Dc = class extends vc {
13524
13658
  conversationId: e,
13525
13659
  reason: t
13526
13660
  };
13527
- N.anonymToken && (r.anonymToken = N.anonymToken), n?.peerId && (r.peerId = n.peerId), gs("vchat.hangupConversation", r);
13661
+ N.anonymToken && (r.anonymToken = N.anonymToken), n?.peerId && (r.peerId = n.peerId), ys("vchat.hangupConversation", r);
13528
13662
  }
13529
13663
  async removeHistoryRecords(e) {
13530
13664
  await this._call("vchat.removeHistoryRecords", { recordIds: e.join(",") });
@@ -13540,19 +13674,19 @@ var Dc = class extends vc {
13540
13674
  return Array.isArray(e?.inbounds) ? e.inbounds : [];
13541
13675
  }
13542
13676
  };
13543
- function Oc(e) {
13677
+ function Mc(e) {
13544
13678
  return typeof e == "object" && !!e && "error_code" in e && "error_msg" in e;
13545
13679
  }
13546
- function kc(e) {
13680
+ function Nc(e) {
13547
13681
  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;
13548
13682
  }
13549
13683
  //#endregion
13550
13684
  //#region src/enums/RecordRole.ts
13551
- var Ac = /* @__PURE__ */ function(e) {
13685
+ var Pc = /* @__PURE__ */ function(e) {
13552
13686
  return e.KING = "KING", e.PAWN = "PAWN", e;
13553
- }(Ac || {}), jc = /* @__PURE__ */ function(e) {
13687
+ }(Pc || {}), Fc = /* @__PURE__ */ function(e) {
13554
13688
  return e.OFF = "0", e.ON = "1", e;
13555
- }({}), Mc = class {
13689
+ }({}), Ic = class {
13556
13690
  constructor(e) {
13557
13691
  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;
13558
13692
  }
@@ -13575,12 +13709,12 @@ var Ac = /* @__PURE__ */ function(e) {
13575
13709
  let e = this._queue[this._readCursor];
13576
13710
  return e && (this._moveReadCursor = !1, this._queue[this._readCursor] = null, this._readCursor = this.nextCursor(this._readCursor), --this._left), e;
13577
13711
  }
13578
- }, Nc = class {
13712
+ }, Lc = class {
13579
13713
  constructor(e, t, n, r = null) {
13580
13714
  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;
13581
13715
  }
13582
13716
  async authorize() {
13583
- let e = await _s("auth.anonymLogin", {
13717
+ let e = await bs("auth.anonymLogin", {
13584
13718
  session_data: {
13585
13719
  device_id: this._uuid,
13586
13720
  client_version: N.apiClientVersion,
@@ -13589,7 +13723,7 @@ var Ac = /* @__PURE__ */ function(e) {
13589
13723
  version: 3
13590
13724
  },
13591
13725
  application_key: this._apiKey
13592
- }, !0, await ms(this._baseApiUrl, this._apiEnv));
13726
+ }, !0, await _s(this._baseApiUrl, this._apiEnv));
13593
13727
  return M.isObject(e) && !("error_msg" in e) ? (this._sessionKey = e.session_key, !0) : !1;
13594
13728
  }
13595
13729
  async hangupConversation(e, t) {
@@ -13599,9 +13733,9 @@ var Ac = /* @__PURE__ */ function(e) {
13599
13733
  application_key: this._apiKey,
13600
13734
  session_key: this._sessionKey
13601
13735
  };
13602
- t?.peerId && (n.peerId = t.peerId), await _s("vchat.hangupConversation", n, !0, await ms(this._baseApiUrl, this._apiEnv));
13736
+ t?.peerId && (n.peerId = t.peerId), await bs("vchat.hangupConversation", n, !0, await _s(this._baseApiUrl, this._apiEnv));
13603
13737
  }
13604
- }, Pc, Fc = null, Ic = !1, Lc = {
13738
+ }, Rc, zc = null, Bc = !1, Vc = {
13605
13739
  getCameras: E.getCameras,
13606
13740
  getMicrophones: E.getMicrophones,
13607
13741
  getOutput: E.getOutput,
@@ -13627,27 +13761,27 @@ var Ac = /* @__PURE__ */ function(e) {
13627
13761
  baseChromeVersion: E.baseChromeVersion,
13628
13762
  getAudioContext: E.getAudioContext,
13629
13763
  isAudioShareSupported: E.isAudioShareSupported
13630
- }, Rc = { participantMarkerCompare: M.participantMarkerCompare };
13631
- function zc(e) {
13632
- Fc = e;
13764
+ }, Hc = { participantMarkerCompare: M.participantMarkerCompare };
13765
+ function Uc(e) {
13766
+ zc = e;
13633
13767
  }
13634
- function Bc(e) {
13768
+ function Wc(e) {
13635
13769
  N.videoEffects = e;
13636
13770
  }
13637
- function Vc(e) {
13771
+ function Gc(e) {
13638
13772
  N.audioEffects = e;
13639
13773
  }
13640
- function Hc(e, t = {}) {
13774
+ function Kc(e, t = {}) {
13641
13775
  N.vad = e, N.vadOptions = t;
13642
13776
  }
13643
- function Uc(e, t = null, n = {}, r = 1) {
13777
+ function qc(e, t = null, n = {}, r = 1) {
13644
13778
  N.vmoji = e, N.vmojiOptions = {
13645
13779
  protocolVersion: r,
13646
13780
  renderingOptions: n
13647
13781
  }, t && e.setSDK(t);
13648
13782
  }
13649
- async function Wc(t) {
13650
- N.set(t), Pc || (Pc = new Dc()), N.statQueueEnabled && (Ds.setApi(Pc), N.autoStartStats && Zc()), e.disableLog(!N.debug), z.toggle(N.debug), z.log(`Calls SDK ${N.sdkVersion}`, t), await E.init();
13783
+ async function Jc(t) {
13784
+ N.set(t), Rc || (Rc = new jc()), N.statQueueEnabled && (As.setApi(Rc), N.autoStartStats && tl()), e.disableLog(!N.debug), z.toggle(N.debug), z.log(`Calls SDK ${N.sdkVersion}`, t), await E.init();
13651
13785
  let n = E.getBrowserSupportFailure();
13652
13786
  if (n) throw new k(x.UNSUPPORTED, { callError: {
13653
13787
  scope: "internal",
@@ -13656,19 +13790,19 @@ async function Wc(t) {
13656
13790
  } });
13657
13791
  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}`);
13658
13792
  }
13659
- async function Gc(e, t = [S.AUDIO], n = "", r = !1, i = !1, a, o, s) {
13793
+ async function Yc(e, t = [S.AUDIO], n = "", r = !1, i = !1, a, o, s) {
13660
13794
  let c = [];
13661
- return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), qc([], io.USER, t, n, r, i, a, c, o, s);
13795
+ return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), Zc([], so.USER, t, n, r, i, a, c, o, s);
13662
13796
  }
13663
- function Kc(e, t = []) {
13797
+ function Xc(e, t = []) {
13664
13798
  let n = e.getIncomingCallerExternalId();
13665
13799
  return n ? t.length === 1 && t[0].id === n.id && t[0].type === n.type : !1;
13666
13800
  }
13667
- async function qc(e, t = io.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
13801
+ async function Zc(e, t = so.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
13668
13802
  if (!N.hold && B.getActive()) throw z.error("There is already active call"), new k(O.HAS_ACTIVE_CALL);
13669
13803
  let u = B.getAll().find((e) => e.isIncomingRinging);
13670
- if (!N.hold && u && !Kc(u, s)) throw z.error("There is already incoming call"), new k(O.HAS_ACTIVE_CALL);
13671
- return new $(new Dc(), Fc).onStart({
13804
+ if (!N.hold && u && !Xc(u, s)) throw z.error("There is already incoming call"), new k(O.HAS_ACTIVE_CALL);
13805
+ return new $(new jc(), zc).onStart({
13672
13806
  opponentIds: e,
13673
13807
  opponentType: t,
13674
13808
  mediaOptions: n,
@@ -13681,49 +13815,49 @@ async function qc(e, t = io.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
13681
13815
  conversationId: l
13682
13816
  });
13683
13817
  }
13684
- async function Jc(e, t) {
13685
- return Yc(e, j.USER, void 0, t);
13818
+ async function Qc(e, t) {
13819
+ return $c(e, j.USER, void 0, t);
13686
13820
  }
13687
- async function Yc(e, t = j.USER, n, r, i, a) {
13821
+ async function $c(e, t = j.USER, n, r, i, a) {
13688
13822
  if (e === $.id()) throw Error("Push has already been processed");
13689
- return new $(new Dc(), Fc).onPush(e, t, n, r, i, a);
13823
+ return new $(new jc(), zc).onPush(e, t, n, r, i, a);
13690
13824
  }
13691
- async function Xc() {
13692
- return Pc.getInbounds();
13825
+ async function el() {
13826
+ return Rc.getInbounds();
13693
13827
  }
13694
- function Zc() {
13828
+ function tl() {
13695
13829
  if (N.statQueueEnabled) {
13696
- if (!Pc) {
13830
+ if (!Rc) {
13697
13831
  z.error("[CallsSDK] startStats() called before init()");
13698
13832
  return;
13699
13833
  }
13700
- Ic || (Ic = !0, Ls.start(Pc));
13834
+ Bc || (Bc = !0, Bs.start(Rc));
13701
13835
  }
13702
13836
  }
13703
- async function Qc(e, t) {
13704
- return e && (N.authToken = e), t !== void 0 && N.apiBaseUrl !== t && (N.apiBaseUrl = t, fs()), Pc.authorize();
13837
+ async function nl(e, t) {
13838
+ return e && (N.authToken = e), t !== void 0 && N.apiBaseUrl !== t && (N.apiBaseUrl = t, hs()), Rc.authorize();
13705
13839
  }
13706
- async function $c(e = [S.AUDIO], t) {
13707
- return wu(t).accept(e);
13840
+ async function rl(e = [S.AUDIO], t) {
13841
+ return Ou(t).accept(e);
13708
13842
  }
13709
- async function el(e) {
13710
- let t = xu(e?.conversationId);
13843
+ async function il(e) {
13844
+ let t = Tu(e?.conversationId);
13711
13845
  if (t) return t.decline(e);
13712
13846
  }
13713
- async function tl(e, t = [S.AUDIO]) {
13714
- return nl(e, t);
13847
+ async function al(e, t = [S.AUDIO]) {
13848
+ return ol(e, t);
13715
13849
  }
13716
- async function nl(e, t, n) {
13850
+ async function ol(e, t, n) {
13717
13851
  if (!N.hold && B.callsLength > 0) throw z.error("There is already active call"), new k(O.HAS_ACTIVE_CALL);
13718
- return new $(new Dc(), Fc).onJoin({
13852
+ return new $(new jc(), zc).onJoin({
13719
13853
  conversationId: e,
13720
13854
  mediaOptions: t,
13721
13855
  chatId: n
13722
13856
  });
13723
13857
  }
13724
- async function rl(e, t = [S.AUDIO], n, r, i, a) {
13858
+ async function sl(e, t = [S.AUDIO], n, r, i, a) {
13725
13859
  if (!N.hold && B.callsLength > 0) throw z.error("There is already active call"), new k(O.HAS_ACTIVE_CALL);
13726
- return n && (N.anonymToken = n), new $(new Dc(), Fc).onJoin({
13860
+ return n && (N.anonymToken = n), new $(new jc(), zc).onJoin({
13727
13861
  joinLink: e,
13728
13862
  mediaOptions: t,
13729
13863
  observedIds: r,
@@ -13732,30 +13866,30 @@ async function rl(e, t = [S.AUDIO], n, r, i, a) {
13732
13866
  anonymous: !!N.anonymToken
13733
13867
  });
13734
13868
  }
13735
- function il(e) {
13736
- let t = xu(e?.conversationId);
13869
+ function cl(e) {
13870
+ let t = Tu(e?.conversationId);
13737
13871
  return t ? t.hangup(e) : ($.hangupAfterInit(e?.onFastHangup), Promise.resolve());
13738
13872
  }
13739
- async function al(e, t) {
13873
+ async function ll(e, t) {
13740
13874
  let n = Array.isArray(e) ? e : [e], r = $.current();
13741
13875
  r && await r.addParticipant(n, t);
13742
13876
  }
13743
- async function ol(e, t) {
13877
+ async function ul(e, t) {
13744
13878
  let n = $.current();
13745
13879
  if (n) {
13746
13880
  let r = e.map((e) => M.composeUserId(e));
13747
13881
  await n.addParticipantLegacy(r, t);
13748
13882
  }
13749
13883
  }
13750
- async function sl(e, t = !1) {
13751
- let n = Tu(e, "removeParticipant");
13884
+ async function dl(e, t = !1) {
13885
+ let n = ku(e, "removeParticipant");
13752
13886
  if (n) try {
13753
13887
  await n.conversation.removeParticipant(M.decomposeParticipantId(n.participantId).compositeUserId, t);
13754
13888
  } catch (e) {
13755
13889
  z.warn(`Failed to remove participant ${n.participantId}. Perhaps he is no longer on the call. ${e}`);
13756
13890
  }
13757
13891
  }
13758
- async function cl(e, t = !1) {
13892
+ async function fl(e, t = !1) {
13759
13893
  let n = $.current();
13760
13894
  if (n) try {
13761
13895
  await n.removeParticipant(M.composeUserId(e), t);
@@ -13763,13 +13897,13 @@ async function cl(e, t = !1) {
13763
13897
  z.warn(`Failed to remove participant ${e}. Perhaps he is no longer on the call. ${t}`);
13764
13898
  }
13765
13899
  }
13766
- async function ll(e, t) {
13900
+ async function pl(e, t) {
13767
13901
  let n = $.current();
13768
13902
  if (e === "videoinput" && jt.contains(t)) return N.videoFacingMode = t, n ? (E.isMobile() && n.stopVideoTrack(), n.changeDevice(e)) : void 0;
13769
13903
  if (!await E._saveDeviceId(e, t)) throw Error(`Device not found: ${t}`);
13770
13904
  if (n) return n.changeDevice(e);
13771
13905
  }
13772
- async function ul(e, t) {
13906
+ async function ml(e, t) {
13773
13907
  let n = typeof e == "object" ? {
13774
13908
  ...e,
13775
13909
  fastScreenSharing: e.captureScreen && e.fastScreenSharing,
@@ -13778,40 +13912,40 @@ async function ul(e, t) {
13778
13912
  captureScreen: e,
13779
13913
  fastScreenSharing: !1,
13780
13914
  captureAudio: !1
13781
- }, r = xu(t);
13915
+ }, r = Tu(t);
13782
13916
  return r ? r.toggleScreenCapturing(n) : Promise.reject();
13783
13917
  }
13784
- function dl(e) {
13918
+ function hl(e) {
13785
13919
  let t = $.current();
13786
13920
  t && t.toggleAnimojiCapturing(e);
13787
13921
  }
13788
- async function fl(e, t = !1) {
13922
+ async function gl(e, t = !1) {
13789
13923
  let n = $.current();
13790
13924
  n && await n.setVideoStream(e, t);
13791
13925
  }
13792
- async function pl(e, t) {
13793
- let n = xu(t);
13926
+ async function _l(e, t) {
13927
+ let n = Tu(t);
13794
13928
  n && await n.toggleLocalVideo(e);
13795
13929
  }
13796
- async function ml(e, t) {
13797
- let n = xu(t);
13930
+ async function vl(e, t) {
13931
+ let n = Tu(t);
13798
13932
  n && await n.toggleLocalAudio(e);
13799
13933
  }
13800
- async function hl(e) {
13934
+ async function yl(e) {
13801
13935
  let t = $.current();
13802
13936
  if (t) return t.setLocalResolution(e);
13803
13937
  }
13804
- async function gl(e) {
13938
+ async function bl(e) {
13805
13939
  let t = $.current();
13806
13940
  t && await t.changePriorities(e);
13807
13941
  }
13808
- async function _l(e, t) {
13942
+ async function xl(e, t) {
13809
13943
  let n = $.current();
13810
13944
  if (n) {
13811
13945
  if (t) {
13812
13946
  let r = n.getCachedParticipantIdByExternalId(t);
13813
13947
  if (!r) {
13814
- Su(t, "changeParticipantState", n);
13948
+ Eu(t, "changeParticipantState", n);
13815
13949
  return;
13816
13950
  }
13817
13951
  await n.changeParticipantState(e, r);
@@ -13820,161 +13954,161 @@ async function _l(e, t) {
13820
13954
  await n.changeParticipantState(e);
13821
13955
  }
13822
13956
  }
13823
- async function vl() {
13957
+ async function Sl() {
13824
13958
  let e = $.current();
13825
13959
  e && await e.putHandsDown();
13826
13960
  }
13827
- async function yl(e) {
13961
+ async function Cl(e) {
13828
13962
  let t = $.current();
13829
13963
  t && await t.updateDisplayLayout(e);
13830
13964
  }
13831
- async function bl(e) {
13965
+ async function wl(e) {
13832
13966
  let t = $.current();
13833
13967
  t && await t.requestDisplayLayout(e);
13834
13968
  }
13835
- async function xl(e, t, n = !1) {
13836
- let r = Tu(e, "grantRoles");
13969
+ async function Tl(e, t, n = !1) {
13970
+ let r = ku(e, "grantRoles");
13837
13971
  r && await r.conversation.grantRoles(r.participantId, t, n);
13838
13972
  }
13839
- async function Sl(e, t, n, r = !1) {
13973
+ async function El(e, t, n, r = !1) {
13840
13974
  let i = $.current();
13841
13975
  i && await i.grantRoles(M.composeParticipantId(e, j.USER, t), n, r);
13842
13976
  }
13843
- async function Cl({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
13977
+ async function Dl({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
13844
13978
  if (e) {
13845
- let i = Tu(e, "muteParticipant");
13979
+ let i = ku(e, "muteParticipant");
13846
13980
  return i ? i.conversation.muteParticipant(i.participantId, t, n, r) : void 0;
13847
13981
  }
13848
13982
  let i = $.current();
13849
13983
  i && await i.muteParticipant(null, t, n, r);
13850
13984
  }
13851
- async function wl({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
13985
+ async function Ol({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
13852
13986
  let a = $.current();
13853
13987
  if (a) {
13854
13988
  let o = e ? M.composeParticipantId(e, j.USER, r) : null;
13855
13989
  await a.muteParticipant(o, t, n, i);
13856
13990
  }
13857
13991
  }
13858
- async function Tl(e, t = !1, n = null) {
13859
- let r = Tu(e, "pinParticipant");
13992
+ async function kl(e, t = !1, n = null) {
13993
+ let r = ku(e, "pinParticipant");
13860
13994
  r && await r.conversation.pinParticipant(r.participantId, t, n);
13861
13995
  }
13862
- async function El(e, t = !1, n = 0, r = null) {
13996
+ async function Al(e, t = !1, n = 0, r = null) {
13863
13997
  let i = $.current();
13864
13998
  i && await i.pinParticipant(M.composeParticipantId(e, j.USER, n), t, r);
13865
13999
  }
13866
- async function Dl(e) {
14000
+ async function jl(e) {
13867
14001
  let t = $.current();
13868
14002
  t && await t.updateMediaModifiers(e);
13869
14003
  }
13870
- async function Ol(e) {
14004
+ async function Ml(e) {
13871
14005
  let t = $.current();
13872
14006
  t && await t.enableVideoSuspend(e);
13873
14007
  }
13874
- async function kl(e) {
14008
+ async function Nl(e) {
13875
14009
  let t = $.current();
13876
14010
  t && await t.enableVideoSuspendSuggest(e);
13877
14011
  }
13878
- async function Al(e) {
14012
+ async function Pl(e) {
13879
14013
  let t = $.current();
13880
14014
  t && await t.changeOptions(e);
13881
14015
  }
13882
- async function jl(e, t = null) {
14016
+ async function Fl(e, t = null) {
13883
14017
  if (t) {
13884
- let n = Tu(t, "chatMessage");
14018
+ let n = ku(t, "chatMessage");
13885
14019
  return n ? n.conversation.chatMessage(e, M.decomposeParticipantId(n.participantId).compositeUserId) : void 0;
13886
14020
  }
13887
14021
  let n = $.current();
13888
14022
  n && await n.chatMessage(e, null);
13889
14023
  }
13890
- async function Ml(e, t = null) {
14024
+ async function Il(e, t = null) {
13891
14025
  let n = $.current();
13892
14026
  if (n) {
13893
14027
  let r = t ? M.composeUserId(t) : null;
13894
14028
  await n.chatMessage(e, r);
13895
14029
  }
13896
14030
  }
13897
- async function Nl(e = 10) {
14031
+ async function Ll(e = 10) {
13898
14032
  let t = $.current();
13899
14033
  if (t) return t.chatHistory(e);
13900
14034
  }
13901
- async function Pl(e, t = null) {
14035
+ async function Rl(e, t = null) {
13902
14036
  if (t) {
13903
- let n = Tu(t, "customData");
14037
+ let n = ku(t, "customData");
13904
14038
  return n ? n.conversation.customData(e, n.participantId) : void 0;
13905
14039
  }
13906
14040
  let n = $.current();
13907
14041
  n && await n.customData(e, null);
13908
14042
  }
13909
- async function Fl(e, t = null, n = 0) {
14043
+ async function zl(e, t = null, n = 0) {
13910
14044
  let r = $.current();
13911
14045
  if (r) {
13912
14046
  let i = t ? M.composeParticipantId(t, j.USER, n) : null;
13913
14047
  await r.customData(e, i);
13914
14048
  }
13915
14049
  }
13916
- async function Il(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
13917
- return (await Pc.createConversation(a ?? M.uuid(), e, t, {
14050
+ async function Bl(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
14051
+ return (await Rc.createConversation(a ?? M.uuid(), e, t, {
13918
14052
  onlyAdminCanShareMovie: n,
13919
14053
  waitForAdmin: r,
13920
14054
  closedConversation: i
13921
14055
  })).join_link;
13922
14056
  }
13923
- async function Ll(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
14057
+ async function Vl(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
13924
14058
  let a = i.map((e) => Z.fromId(e));
13925
- return (await Pc.createConversation(M.uuid(), e, t, {
14059
+ return (await Rc.createConversation(M.uuid(), e, t, {
13926
14060
  onlyAdminCanShareMovie: n,
13927
14061
  audienceMode: !0,
13928
14062
  audioOnly: r
13929
14063
  }, a)).join_link;
13930
14064
  }
13931
- async function Rl() {
14065
+ async function Hl() {
13932
14066
  let e = $.current();
13933
14067
  return e ? e.createJoinLink() : Promise.reject();
13934
14068
  }
13935
- async function zl() {
14069
+ async function Ul() {
13936
14070
  let e = $.current();
13937
14071
  return e ? e.removeJoinLink() : Promise.reject();
13938
14072
  }
13939
- async function Bl(e, t) {
13940
- return Pc.getAnonymTokenByLink(e, t);
14073
+ async function Wl(e, t) {
14074
+ return Rc.getAnonymTokenByLink(e, t);
13941
14075
  }
13942
- function Vl(e) {
14076
+ function Gl(e) {
13943
14077
  let t = $.current();
13944
14078
  t && t.setVolume(e);
13945
14079
  }
13946
- function Hl(e) {
14080
+ function Kl(e) {
13947
14081
  N.forceRelayPolicy = e;
13948
14082
  }
13949
- async function Ul(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
14083
+ async function ql(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
13950
14084
  let o = $.current();
13951
14085
  return o ? o.startStream(e, t, n, r, i, a) : Promise.reject();
13952
14086
  }
13953
- async function Wl(e = null, t) {
14087
+ async function Jl(e = null, t) {
13954
14088
  let n = $.current();
13955
14089
  return n ? n.stopStream(e, t) : Promise.reject();
13956
14090
  }
13957
- async function Gl(e = null) {
14091
+ async function Yl(e = null) {
13958
14092
  let t = $.current();
13959
14093
  return t ? t.publishStream(e) : Promise.reject();
13960
14094
  }
13961
- async function Kl() {
14095
+ async function Xl() {
13962
14096
  let e = $.current();
13963
14097
  return e ? e.getStreamInfo() : Promise.reject();
13964
14098
  }
13965
- async function ql(e) {
14099
+ async function Zl(e) {
13966
14100
  let t = $.current();
13967
14101
  return t ? t.addMovie(e) : Promise.reject();
13968
14102
  }
13969
- async function Jl(e) {
14103
+ async function Ql(e) {
13970
14104
  let t = $.current();
13971
14105
  return t ? t.updateMovie(e) : Promise.reject();
13972
14106
  }
13973
- async function Yl(e) {
14107
+ async function $l(e) {
13974
14108
  let t = $.current();
13975
14109
  return t ? t.removeMovie(e) : Promise.reject();
13976
14110
  }
13977
- async function Xl(e, t) {
14111
+ async function eu(e, t) {
13978
14112
  let n = $.current();
13979
14113
  if (n) {
13980
14114
  let r = [], i = [];
@@ -13996,46 +14130,46 @@ async function Xl(e, t) {
13996
14130
  });
13997
14131
  }
13998
14132
  if (i.length) {
13999
- Cu(i, "updateRooms", n);
14133
+ Du(i, "updateRooms", n);
14000
14134
  return;
14001
14135
  }
14002
14136
  return n.updateRooms(r, t);
14003
14137
  }
14004
14138
  return Promise.reject();
14005
14139
  }
14006
- async function Zl(e, t) {
14140
+ async function tu(e, t) {
14007
14141
  let n = $.current();
14008
14142
  return n ? n.activateRooms(e, t) : Promise.reject();
14009
14143
  }
14010
- async function Ql(e = null, t = null) {
14144
+ async function nu(e = null, t = null) {
14011
14145
  let n = $.current();
14012
14146
  if (!n) return Promise.reject();
14013
14147
  let r;
14014
14148
  if (t && (r = n.getCachedParticipantIdByExternalId(t) ?? void 0, !r)) {
14015
- Su(t, "switchRoom", n);
14149
+ Eu(t, "switchRoom", n);
14016
14150
  return;
14017
14151
  }
14018
14152
  return n.switchRoom(e, r);
14019
14153
  }
14020
- async function $l(e) {
14154
+ async function ru(e) {
14021
14155
  let t = $.current();
14022
14156
  return t ? t.removeRooms(e) : Promise.reject();
14023
14157
  }
14024
- function eu(e) {
14158
+ function iu(e) {
14025
14159
  N.statisticsInterval = e;
14026
14160
  let t = $.current();
14027
14161
  if (t) return t.updateStatisticsInterval();
14028
14162
  }
14029
- function tu(t) {
14163
+ function au(t) {
14030
14164
  e.disableLog(!t), z.toggle(t);
14031
14165
  }
14032
- function nu(e, ...t) {
14166
+ function ou(e, ...t) {
14033
14167
  N.debugLog && ($.debugMessage(e, "[external]", ...t) || z.send(e, "[external]", ...t));
14034
14168
  }
14035
- function ru(e, t, ...n) {
14169
+ function su(e, t, ...n) {
14036
14170
  N.debugLog && ($.debugMessageWithContext(e, t, "[external]", ...n) || z.send(e, "[external]", ...n));
14037
14171
  }
14038
- var iu = {
14172
+ var cu = {
14039
14173
  list: Ne,
14040
14174
  get: Pe,
14041
14175
  getJson: Fe,
@@ -14043,7 +14177,7 @@ var iu = {
14043
14177
  clear: Le,
14044
14178
  stats: Re
14045
14179
  };
14046
- function au() {
14180
+ function lu() {
14047
14181
  let e = [
14048
14182
  [`Calls SDK ${N.sdkVersion}`, N.toJSON()],
14049
14183
  ["UserAgent:", navigator.userAgent],
@@ -14061,139 +14195,139 @@ function au() {
14061
14195
  d: e
14062
14196
  }));
14063
14197
  }
14064
- async function ou() {
14198
+ async function uu() {
14065
14199
  let e = $.id(), t = $.debugSessionId();
14066
14200
  if (!t || !e) throw z.error("[uploadDebugLogs]", "No conversation id found"), Error("No conversation id found");
14067
14201
  let n = await Pe({ sessionId: t });
14068
14202
  if (n.length === 0) throw z.error("[uploadDebugLogs]", "No logs found"), Error("No logs found");
14069
14203
  let r = n[0].t, i = n[n.length - 1].t;
14070
14204
  try {
14071
- return Pc?.uploadDebugLogs(e, r, i, JSON.stringify([...au(), ...n]));
14205
+ return Rc?.uploadDebugLogs(e, r, i, JSON.stringify([...lu(), ...n]));
14072
14206
  } catch (e) {
14073
14207
  throw z.error("[uploadDebugLogs]", "Error while uploading logs", e), Error("Error while uploading logs", { cause: e });
14074
14208
  }
14075
14209
  }
14076
- async function su(e) {
14210
+ async function du(e) {
14077
14211
  let t = $.current();
14078
14212
  if (t) return t.videoEffect(e);
14079
14213
  }
14080
- async function cu(e, t) {
14214
+ async function fu(e, t) {
14081
14215
  let n = $.current();
14082
14216
  if (n) return n.audioEffect(e.length > 0 ? e : null, t);
14083
14217
  }
14084
- async function lu(e) {
14218
+ async function pu(e) {
14085
14219
  let t = $.current();
14086
14220
  t && await t.setAudioStream(e);
14087
14221
  }
14088
- async function uu(e, t = null, n = null) {
14222
+ async function mu(e, t = null, n = null) {
14089
14223
  let r = $.current();
14090
14224
  if (!r) return;
14091
14225
  let i = n ?? t?.id, a = null;
14092
14226
  if (t && (a = r.getCachedParticipantIdByExternalId(t), !a)) {
14093
- Su(t, "setVmojiSvg", r);
14227
+ Eu(t, "setVmojiSvg", r);
14094
14228
  return;
14095
14229
  }
14096
14230
  r.setAnimojiSvg(e, a, i);
14097
14231
  }
14098
- function du(e) {
14232
+ function hu(e) {
14099
14233
  let t = $.current();
14100
14234
  t && t.setAnimojiFill(e);
14101
14235
  }
14102
- async function fu(e = null, t, n = !1) {
14103
- return wu().getWaitingHall(e, t, n);
14236
+ async function gu(e = null, t, n = !1) {
14237
+ return Ou().getWaitingHall(e, t, n);
14104
14238
  }
14105
- async function pu() {
14106
- return wu().getAudienceModeHands();
14239
+ async function _u() {
14240
+ return Ou().getAudienceModeHands();
14107
14241
  }
14108
- async function mu(e, t = !1) {
14109
- let n = wu(), r;
14242
+ async function vu(e, t = !1) {
14243
+ let n = Ou(), r;
14110
14244
  if (e) {
14111
14245
  let t = n.getCachedParticipantIdByExternalId(e);
14112
14246
  if (!t) {
14113
- Su(e, "promoteParticipant", n);
14247
+ Eu(e, "promoteParticipant", n);
14114
14248
  return;
14115
14249
  }
14116
14250
  r = M.decomposeParticipantId(t).compositeUserId;
14117
14251
  }
14118
14252
  return n.promoteParticipant(r, t);
14119
14253
  }
14120
- async function hu(e = !1) {
14121
- return wu().requestPromotion(e);
14254
+ async function yu(e = !1) {
14255
+ return Ou().requestPromotion(e);
14122
14256
  }
14123
- async function gu(e = !1) {
14124
- return wu().acceptPromotion(e);
14257
+ async function bu(e = !1) {
14258
+ return Ou().acceptPromotion(e);
14125
14259
  }
14126
- async function _u(e) {
14127
- return wu().getParticipantListChunk(e);
14260
+ async function xu(e) {
14261
+ return Ou().getParticipantListChunk(e);
14128
14262
  }
14129
- async function vu(e) {
14130
- return wu().getParticipants(e);
14263
+ async function Su(e) {
14264
+ return Ou().getParticipants(e);
14131
14265
  }
14132
- async function yu(e) {
14133
- return wu().feedback(e);
14266
+ async function Cu(e) {
14267
+ return Ou().feedback(e);
14134
14268
  }
14135
- async function bu(e, t, n) {
14136
- return wu(n).enableFeatureForRoles(e, t);
14269
+ async function wu(e, t, n) {
14270
+ return Ou(n).enableFeatureForRoles(e, t);
14137
14271
  }
14138
- function xu(e) {
14272
+ function Tu(e) {
14139
14273
  return e ? B.get(e) ?? null : $.current() ?? B.getFirst();
14140
14274
  }
14141
- function Su(e, t, n) {
14275
+ function Eu(e, t, n) {
14142
14276
  R.onNonFatalError(/* @__PURE__ */ Error(`Participant ID mapping not found for external ID "${e.id}" while handling ${t}`), n.id);
14143
14277
  }
14144
- function Cu(e, t, n) {
14278
+ function Du(e, t, n) {
14145
14279
  let r = Array.from(new Set(e));
14146
14280
  R.onNonFatalError(/* @__PURE__ */ Error(`Participant ID mapping not found for external IDs "${r.join("\", \"")}" while handling ${t}`), n.id);
14147
14281
  }
14148
- function wu(e) {
14149
- let t = xu(e);
14282
+ function Ou(e) {
14283
+ let t = Tu(e);
14150
14284
  if (!t) throw Error("Conversation not found");
14151
14285
  return t;
14152
14286
  }
14153
- function Tu(e, t) {
14287
+ function ku(e, t) {
14154
14288
  let n = $.current();
14155
14289
  if (!n) return null;
14156
14290
  let r = n.getCachedParticipantIdByExternalId(e);
14157
14291
  return r ? {
14158
14292
  conversation: n,
14159
14293
  participantId: r
14160
- } : (Su(e, t, n), null);
14294
+ } : (Eu(e, t, n), null);
14161
14295
  }
14162
- async function Eu(e) {
14163
- await Pc.removeHistoryRecords(e);
14296
+ async function Au(e) {
14297
+ await Rc.removeHistoryRecords(e);
14164
14298
  }
14165
- async function Du(e) {
14299
+ async function ju(e) {
14166
14300
  let t = $.current() ?? B.getFirst();
14167
14301
  t && await t.startAsr(e);
14168
14302
  }
14169
- async function Ou(e) {
14303
+ async function Mu(e) {
14170
14304
  let t = $.current() ?? B.getFirst();
14171
14305
  t && await t.stopAsr(e);
14172
14306
  }
14173
- async function ku(e) {
14307
+ async function Nu(e) {
14174
14308
  let t = $.current() ?? B.getFirst();
14175
14309
  t && await t.requestAsr(e);
14176
14310
  }
14177
- async function Au(e) {
14311
+ async function Pu(e) {
14178
14312
  let t = $.current();
14179
14313
  return t ? t.startUrlSharing(e) : Promise.reject();
14180
14314
  }
14181
- async function ju() {
14315
+ async function Fu() {
14182
14316
  let e = $.current();
14183
14317
  return e ? e.stopUrlSharing() : Promise.reject();
14184
14318
  }
14185
- async function Mu(e) {
14319
+ async function Iu(e) {
14186
14320
  await B.switchCall(e);
14187
14321
  }
14188
- function Nu() {
14322
+ function Lu() {
14189
14323
  return B.getActiveId();
14190
14324
  }
14191
- function Pu() {
14325
+ function Ru() {
14192
14326
  return $.getSyncedTime();
14193
14327
  }
14194
- function Fu() {
14328
+ function zu() {
14195
14329
  return N.sdkVersion;
14196
14330
  }
14197
14331
  typeof window < "u" && (window.__CALLS_SDK = xn);
14198
14332
  //#endregion
14199
- export { Dc as Api, Nc as ApiExternal, Mc as ArrayDequeue, y as AuthData, f as BaseLogger, ro as CallDirection, io as CallType, ao as ChatRoomEventType, oo as ConversationFeature, so as ConversationOption, wn as DebugMessageType, yo as ExternalIdType, jt as FacingMode, x as FatalError, k as HangupReason, O as HangupType, S as MediaOption, A as MediaTrackKind, H as MediaType, uo as MuteState, X as ParticipantState, jc as ParticipantStateDataValue, P as ParticipantStatus, Ac as RecordRole, fo as RoomsEventType, no as Signaling, V as SignalingCommandType, br as SignalingConnectionType, K as SignalingNotification, U as Stat, J as TransportTopology, ho as UserRole, j as UserType, Ho as VolumeDetector, $c as acceptCall, gu as acceptPromotion, Zl as activateRooms, ql as addMovie, al as addParticipant, ol as addParticipantInternal, Qc as authorize, Lc as browser, qc as callInternal, Gc as callTo, ul as captureScreen, dl as captureVmoji, cu as changeAudioEffect, Al as changeConversationOptions, ll as changeDevice, _l as changeParticipantState, gl as changePriorities, su as changeVideoEffect, Nl as chatHistory, jl as chatMessage, Ml as chatMessageInternal, Rl as createJoinLink, Pl as customData, Fl as customDataInternal, tu as debug, iu as debugLogs, nu as debugMessage, ru as debugMessageWithContext, el as declineCall, bu as enableFeatureForRoles, Ol as enableVideoSuspend, kl as enableVideoSuspendSuggest, yu as feedback, Hl as forceRelayPolicy, Nu as getActiveCallId, Bl as getAnonymTokenByLink, pu as getAudienceModeHands, Xc as getInbounds, _u as getParticipantListChunk, vu as getParticipants, Kl as getStreamInfo, Pu as getSyncedTime, fu as getWaitingHall, xl as grantRoles, Sl as grantRolesInternal, il as hangup, Wc as init, tl as joinCall, rl as joinCallByLink, nl as joinCallInternal, Cl as muteParticipant, wl as muteParticipantInternal, Tl as pinParticipant, El as pinParticipantInternal, Jc as processPush, Yc as processPushInternal, mu as promoteParticipant, Gl as publishStream, vl as putHandsDown, Eu as removeHistoryRecords, zl as removeJoinLink, Yl as removeMovie, sl as removeParticipant, cl as removeParticipantInternal, $l as removeRooms, ku as requestAsr, bl as requestDisplayLayout, hu as requestPromotion, Vc as setAudioEffects, lu as setAudioStream, hl as setLocalResolution, zc as setLogger, Dl as setMediaModifiers, eu as setStatisticsInterval, Hc as setVad, Bc as setVideoEffects, fl as setVideoStream, Uc as setVmoji, du as setVmojiFill, uu as setVmojiSvg, Vl as setVolume, Du as startAsr, Ll as startAudienceConversation, Il as startConversation, Zc as startStats, Ul as startStream, Au as startUrlSharing, Ou as stopAsr, Wl as stopStream, ju as stopUrlSharing, Mu as switchCall, Ql as switchRoom, ml as toggleLocalAudio, pl as toggleLocalVideo, yl as updateDisplayLayout, Jl as updateMovie, Xl as updateRooms, ou as uploadDebugLogs, Rc as utils, Fu as version };
14333
+ export { jc as Api, Lc as ApiExternal, Ic as ArrayDequeue, y as AuthData, f as BaseLogger, oo as CallDirection, so as CallType, co as ChatRoomEventType, lo as ConversationFeature, uo as ConversationOption, wn as DebugMessageType, So as ExternalIdType, jt as FacingMode, x as FatalError, k as HangupReason, O as HangupType, S as MediaOption, A as MediaTrackKind, H as MediaType, mo as MuteState, X as ParticipantState, Fc as ParticipantStateDataValue, P as ParticipantStatus, Pc as RecordRole, ho as RoomsEventType, ao as Signaling, V as SignalingCommandType, br as SignalingConnectionType, K as SignalingNotification, U as Stat, J as TransportTopology, vo as UserRole, j as UserType, Go as VolumeDetector, rl as acceptCall, bu as acceptPromotion, tu as activateRooms, Zl as addMovie, ll as addParticipant, ul as addParticipantInternal, nl as authorize, Vc as browser, Zc as callInternal, Yc as callTo, ml as captureScreen, hl as captureVmoji, fu as changeAudioEffect, Pl as changeConversationOptions, pl as changeDevice, xl as changeParticipantState, bl as changePriorities, du as changeVideoEffect, Ll as chatHistory, Fl as chatMessage, Il as chatMessageInternal, Hl as createJoinLink, Rl as customData, zl as customDataInternal, au as debug, cu as debugLogs, ou as debugMessage, su as debugMessageWithContext, il as declineCall, wu as enableFeatureForRoles, Ml as enableVideoSuspend, Nl as enableVideoSuspendSuggest, Cu as feedback, Kl as forceRelayPolicy, Lu as getActiveCallId, Wl as getAnonymTokenByLink, _u as getAudienceModeHands, el as getInbounds, xu as getParticipantListChunk, Su as getParticipants, Xl as getStreamInfo, Ru as getSyncedTime, gu as getWaitingHall, Tl as grantRoles, El as grantRolesInternal, cl as hangup, Jc as init, al as joinCall, sl as joinCallByLink, ol as joinCallInternal, Dl as muteParticipant, Ol as muteParticipantInternal, kl as pinParticipant, Al as pinParticipantInternal, Qc as processPush, $c as processPushInternal, vu as promoteParticipant, Yl as publishStream, Sl as putHandsDown, Au as removeHistoryRecords, Ul as removeJoinLink, $l as removeMovie, dl as removeParticipant, fl as removeParticipantInternal, ru as removeRooms, Nu as requestAsr, wl as requestDisplayLayout, yu as requestPromotion, Gc as setAudioEffects, pu as setAudioStream, yl as setLocalResolution, Uc as setLogger, jl as setMediaModifiers, iu as setStatisticsInterval, Kc as setVad, Wc as setVideoEffects, gl as setVideoStream, qc as setVmoji, hu as setVmojiFill, mu as setVmojiSvg, Gl as setVolume, ju as startAsr, Vl as startAudienceConversation, Bl as startConversation, tl as startStats, ql as startStream, Pu as startUrlSharing, Mu as stopAsr, Jl as stopStream, Fu as stopUrlSharing, Iu as switchCall, nu as switchRoom, vl as toggleLocalAudio, _l as toggleLocalVideo, Cl as updateDisplayLayout, Ql as updateMovie, eu as updateRooms, uu as uploadDebugLogs, Hc as utils, zu as version };