@vkontakte/calls-sdk 2.8.13-beta.6 → 2.8.13-beta.8

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-beta.6
3
- * Thu, 01 Oct 2026 12:01:14 GMT
2
+ * @vkontakte/calls-sdk v2.8.13-beta.8
3
+ * Mon, 12 Oct 2026 06:23:17 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-beta.6";
2184
+ return "2.8.13-beta.8";
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,
@@ -3634,7 +3642,7 @@ var Bn = 0, Vn = 1, Hn = 2, Un = 3, Wn = 4, Gn = 5, Kn = 6, qn = 7, Jn = 0, Yn =
3634
3642
  };
3635
3643
  }
3636
3644
  }, 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;
3645
+ 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
3646
  }(U || {}), nr = 1e3;
3639
3647
  function W(e, t, n = 0) {
3640
3648
  return t in e && e[t] ? e[t] : n;
@@ -3886,11 +3894,11 @@ var Nr = {
3886
3894
  pranswer: U.SDP_SET_REMOTE_PRANSWER,
3887
3895
  answer: U.SDP_SET_REMOTE_ANSWER,
3888
3896
  rollback: U.SDP_SET_REMOTE_ROLLBACK
3889
- }, Ir = {
3897
+ }, Ir = 120 * 1e3, Lr = {
3890
3898
  local_address: null,
3891
3899
  remote_address: null,
3892
3900
  transport: null
3893
- }, Lr = class {
3901
+ }, Rr = class {
3894
3902
  constructor(e) {
3895
3903
  h(this, "_statAggregator", void 0), h(this, "_pc", null), h(this, "_gatheringStartedAt", 0), h(this, "_remoteSdpReceivedAt", 0), h(this, "_handleGatheringStateChange", () => {
3896
3904
  this._pc?.iceGatheringState === "gathering" && (this._gatheringStartedAt = Date.now());
@@ -3907,14 +3915,14 @@ var Nr = {
3907
3915
  name: U.SDP_GENERATED,
3908
3916
  value: 0,
3909
3917
  string_value: e,
3910
- ...Ir
3918
+ ...Lr
3911
3919
  });
3912
3920
  }
3913
3921
  logCandidateGenerated(e) {
3914
- let t = zr(e.candidate);
3922
+ let t = Br(e.candidate);
3915
3923
  t && this._log({
3916
3924
  name: U.SDP_GENERATED,
3917
- value: Math.max(0, Date.now() - this._gatheringStartedAt),
3925
+ value: this._intervalSince(this._gatheringStartedAt),
3918
3926
  string_value: t.type,
3919
3927
  local_address: t.address,
3920
3928
  remote_address: null,
@@ -3926,14 +3934,14 @@ var Nr = {
3926
3934
  name: U.SDP_RECEIVED,
3927
3935
  value: 0,
3928
3936
  string_value: e,
3929
- ...Ir
3937
+ ...Lr
3930
3938
  });
3931
3939
  }
3932
3940
  logCandidateReceived(e) {
3933
- let t = zr(e.candidate);
3941
+ let t = Br(e.candidate);
3934
3942
  t && this._log({
3935
3943
  name: U.SDP_RECEIVED,
3936
- value: this._remoteSdpReceivedAt > 0 ? Math.max(0, Date.now() - this._remoteSdpReceivedAt) : 0,
3944
+ value: this._remoteSdpReceivedAt > 0 ? this._intervalSince(this._remoteSdpReceivedAt) : 0,
3937
3945
  string_value: t.type,
3938
3946
  local_address: null,
3939
3947
  remote_address: t.address,
@@ -3959,49 +3967,120 @@ var Nr = {
3959
3967
  destroy() {
3960
3968
  this.stop();
3961
3969
  }
3970
+ _intervalSince(e) {
3971
+ return Math.min(Ir, Math.max(0, Date.now() - e));
3972
+ }
3962
3973
  _logFailure(e, t, n) {
3963
3974
  this._log({
3964
3975
  name: e,
3965
3976
  value: 0,
3966
3977
  string_value: JSON.stringify({
3967
3978
  error: t instanceof Error ? t.message : String(t),
3968
- local: Rr(n.local),
3969
- remote: Rr(n.remote)
3979
+ local: zr(n.local),
3980
+ remote: zr(n.remote)
3970
3981
  }),
3971
- ...Ir
3982
+ ...Lr
3972
3983
  });
3973
3984
  }
3974
3985
  _log(e) {
3975
3986
  this._statAggregator?.logEventualStat(e);
3976
3987
  }
3977
3988
  };
3978
- function Rr(e) {
3989
+ function zr(e) {
3979
3990
  return e ? {
3980
3991
  type: e.type,
3981
3992
  sdp: e.sdp
3982
3993
  } : void 0;
3983
3994
  }
3984
- function zr(e) {
3995
+ function Br(e) {
3985
3996
  let t = e?.split(" ") ?? [], n = t.indexOf("typ"), r = t[2]?.toLowerCase(), i = t[4], a = n === -1 ? void 0 : t[n + 1];
3986
- return r === void 0 || i === void 0 || a === void 0 || !Hr(i) ? null : {
3997
+ return r === void 0 || i === void 0 || a === void 0 || !Ur(i) ? null : {
3987
3998
  protocol: r,
3988
3999
  address: i,
3989
4000
  type: a
3990
4001
  };
3991
4002
  }
3992
- var Br = /^\d{1,3}(\.\d{1,3}){3}$/, Vr = /^[0-9a-f:]+$/i;
3993
- function Hr(e) {
3994
- return Br.test(e) || e.includes(":") && Vr.test(e);
4003
+ var Vr = /^\d{1,3}(\.\d{1,3}){3}$/, Hr = /^[0-9a-f:]+$/i;
4004
+ function Ur(e) {
4005
+ return Vr.test(e) || e.includes(":") && Hr.test(e);
3995
4006
  }
3996
4007
  //#endregion
3997
- //#region src/classes/stat/FirstMediaSentProbe.ts
3998
- var Ur = 200;
3999
- function Wr(e) {
4008
+ //#region src/classes/stat/PeerConnectionStats.ts
4009
+ var Wr = /[?&]transport=(tcp|udp)/i, Gr = {
4010
+ stable: "stable",
4011
+ "have-local-offer": "have.local.offer",
4012
+ "have-local-pranswer": "have.local.answer",
4013
+ "have-remote-offer": "have.remote.offer",
4014
+ "have-remote-pranswer": "have.remote.answer",
4015
+ closed: "closed"
4016
+ }, Kr = class {
4017
+ constructor(e) {
4018
+ h(this, "_statAggregator", void 0), h(this, "_pc", null), h(this, "_lastSignalingStateChange", 0), h(this, "_lastGatheringStateChange", 0), h(this, "_lastConnectionState", null), h(this, "_handleConnectionStateChange", () => {
4019
+ this._pc && this._logConnectionState(this._pc.connectionState);
4020
+ }), h(this, "_handleSignalingStateChange", () => {
4021
+ let e = this._pc?.signalingState;
4022
+ this._log({
4023
+ name: U.SIGNALING_STATE_CHANGED,
4024
+ value: this._sinceLastChange("_lastSignalingStateChange"),
4025
+ string_value: e ? Gr[e] : void 0
4026
+ });
4027
+ }), h(this, "_handleGatheringStateChange", () => {
4028
+ let e = this._pc?.iceGatheringState, t = this._sinceLastChange("_lastGatheringStateChange");
4029
+ this._log({
4030
+ name: U.GATHERING_STATE_CHANGED,
4031
+ value: e === "new" ? 0 : t,
4032
+ string_value: e
4033
+ });
4034
+ }), h(this, "_handleIceCandidateError", (e) => {
4035
+ if (!N.iceCandidateErrorStatEnabled) return;
4036
+ let t = e;
4037
+ this._log({
4038
+ name: U.ICE_CANDIDATE_GATHERING_FAILED,
4039
+ value: t.errorCode,
4040
+ string_value: t.errorText,
4041
+ local_address: t.address ?? "",
4042
+ remote_url: t.url,
4043
+ transport: Wr.exec(t.url ?? "")?.[1]?.toLowerCase() ?? null
4044
+ });
4045
+ }), this._statAggregator = e;
4046
+ }
4047
+ observe(e) {
4048
+ 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);
4049
+ }
4050
+ stop() {
4051
+ 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);
4052
+ }
4053
+ logIceRestart() {
4054
+ this._log({ name: U.ICE_RESTART });
4055
+ }
4056
+ logIceCandidateAddFailed(e, t) {
4057
+ this._log({
4058
+ name: U.ICE_CANDIDATE_ADD_FAILED,
4059
+ value: t instanceof DOMException ? t.code : 0,
4060
+ string_value: t instanceof Error ? `${t.name}: ${t.message}` : String(t),
4061
+ remote_url: e.candidate
4062
+ });
4063
+ }
4064
+ _sinceLastChange(e) {
4065
+ let t = Date.now(), n = this[e] === 0 ? 0 : t - this[e];
4066
+ return this[e] = t, n;
4067
+ }
4068
+ _logConnectionState(e) {
4069
+ e !== this._lastConnectionState && (this._lastConnectionState = e, this._log({
4070
+ name: U.CONNECTION_STATE_CHANGED,
4071
+ connection_state: e
4072
+ }));
4073
+ }
4074
+ _log(e) {
4075
+ this._statAggregator?.logEventualStat(e);
4076
+ }
4077
+ }, qr = 200;
4078
+ function Jr(e) {
4000
4079
  for (let t of e.values()) if (t.type === "outbound-rtp" && (t.packetsSent ?? 0) > 0) return !0;
4001
4080
  return !1;
4002
4081
  }
4003
- var Gr = class {
4004
- constructor(e, t, n = Ur) {
4082
+ var Yr = class {
4083
+ constructor(e, t, n = qr) {
4005
4084
  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;
4006
4085
  }
4007
4086
  start() {
@@ -4024,7 +4103,7 @@ var Gr = class {
4024
4103
  try {
4025
4104
  let e = await this._getStatsReports();
4026
4105
  if (this._state !== "polling") return;
4027
- if (e.some(Wr)) {
4106
+ if (e.some(Jr)) {
4028
4107
  this._state = "stopped", this._onFirstMediaSent();
4029
4108
  return;
4030
4109
  }
@@ -4037,7 +4116,7 @@ var Gr = class {
4037
4116
  this._timer = null, this._poll();
4038
4117
  }, this._pollIntervalMs));
4039
4118
  }
4040
- }, Kr = class extends b {
4119
+ }, Xr = class extends b {
4041
4120
  constructor(e, t, n = null) {
4042
4121
  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;
4043
4122
  }
@@ -4048,12 +4127,12 @@ var Gr = class {
4048
4127
  this._firstMediaSentProbeStopped = !0, this._disposeFirstMediaSentProbe();
4049
4128
  }
4050
4129
  _startFirstMediaSentProbe() {
4051
- this._disposeFirstMediaSentProbe(), !(!this._pc || !this._onFirstMediaSent || this._firstMediaSentProbeStopped) && (this._firstMediaSentProbe = new Gr(this._pc, this._onFirstMediaSent), this._firstMediaSentProbe.start());
4130
+ this._disposeFirstMediaSentProbe(), !(!this._pc || !this._onFirstMediaSent || this._firstMediaSentProbeStopped) && (this._firstMediaSentProbe = new Yr(this._pc, this._onFirstMediaSent), this._firstMediaSentProbe.start());
4052
4131
  }
4053
4132
  _disposeFirstMediaSentProbe() {
4054
4133
  this._firstMediaSentProbe?.destroy(), this._firstMediaSentProbe = null;
4055
4134
  }
4056
- }, qr = class {
4135
+ }, Zr = class {
4057
4136
  constructor(e, t = null) {
4058
4137
  h(this, "weightUp", void 0), h(this, "weightDown", void 0), h(this, "value", NaN), this.weightUp = e, this.weightDown = t ?? e;
4059
4138
  }
@@ -4071,7 +4150,7 @@ var Gr = class {
4071
4150
  getValue() {
4072
4151
  return this.value;
4073
4152
  }
4074
- }, Jr = .25, Yr = .35, Xr = 85, Zr = .1, Qr = 1.5, $r = .1, ei = 1, ti = .6, ni = .3, ri = class extends b {
4153
+ }, Qr = .25, $r = .35, ei = 85, ti = .1, ni = 1.5, ri = .1, ii = 1, ai = .6, oi = .3, si = class extends b {
4075
4154
  constructor(e, t = z) {
4076
4155
  super(), h(this, "_signaling", void 0), h(this, "_localNetworkStat", void 0), h(this, "_remoteNetworkStat", void 0), h(this, "_lastNetworkStat", void 0), h(this, "_networkLimits", {
4077
4156
  badNet: {
@@ -4083,8 +4162,8 @@ var Gr = class {
4083
4162
  rtt: 600
4084
4163
  }
4085
4164
  }), h(this, "_lastStatSentTimestamp", 0), h(this, "_currentState", "good"), h(this, "_debug", void 0), this._debug = t, this._signaling = e, this._localNetworkStat = {
4086
- rtt: new qr(Jr, Jr),
4087
- loss: new qr(Yr, Yr),
4165
+ rtt: new Zr(Qr, Qr),
4166
+ loss: new Zr($r, $r),
4088
4167
  bitrate: 0
4089
4168
  }, this._remoteNetworkStat = {
4090
4169
  rtt: 0,
@@ -4099,20 +4178,20 @@ var Gr = class {
4099
4178
  _calcRttRating(e) {
4100
4179
  let t = typeof e == "number" ? e : e.getValue(), n = 1;
4101
4180
  if (isNaN(t)) return n;
4102
- let r = Math.round((t - this._networkLimits.goodNet.rtt) / Xr);
4103
- for (let e = 0; e < r; e++) n *= 1 - Zr;
4181
+ let r = Math.round((t - this._networkLimits.goodNet.rtt) / ei);
4182
+ for (let e = 0; e < r; e++) n *= 1 - ti;
4104
4183
  return n;
4105
4184
  }
4106
4185
  _calcLossRating(e) {
4107
4186
  let t = typeof e == "number" ? e : e.getValue(), n = 1;
4108
4187
  if (isNaN(t)) return n;
4109
- let r = Math.round((t - this._networkLimits.goodNet.loss) / Qr);
4110
- for (let e = 0; e < r; e++) n *= 1 - $r;
4188
+ let r = Math.round((t - this._networkLimits.goodNet.loss) / ni);
4189
+ for (let e = 0; e < r; e++) n *= 1 - ri;
4111
4190
  return n;
4112
4191
  }
4113
4192
  _calcBitrateRating(e, t) {
4114
4193
  if (!e || !t) return 1;
4115
- let n = 1 - (1 - Math.min(e, t) / Math.max(e, t)) * ei;
4194
+ let n = 1 - (1 - Math.min(e, t) / Math.max(e, t)) * ii;
4116
4195
  return Math.min(n, 1);
4117
4196
  }
4118
4197
  _calcUDPRating({ rtt: e, loss: t }) {
@@ -4122,7 +4201,7 @@ var Gr = class {
4122
4201
  return n ? this._calcBitrateRating(e.bitrate, t.bitrate) : this._calcUDPRating(e) * this._calcUDPRating(t);
4123
4202
  }
4124
4203
  _getNetworkState(e) {
4125
- return isNaN(e) || e >= ti ? "good" : e >= ni ? "medium" : "bad";
4204
+ return isNaN(e) || e >= ai ? "good" : e >= oi ? "medium" : "bad";
4126
4205
  }
4127
4206
  updateSettings(e) {
4128
4207
  Object.assign(this._networkLimits.badNet, e?.badNet || {}), Object.assign(this._networkLimits.goodNet, e?.goodNet || {});
@@ -4146,7 +4225,7 @@ var Gr = class {
4146
4225
  let { rtt: t, loss: n, bitrate: r } = e || {};
4147
4226
  this._remoteNetworkStat.rtt = t || 0, this._remoteNetworkStat.loss = n || 0, this._remoteNetworkStat.bitrate = r || 0;
4148
4227
  }
4149
- }, ii = 30 * 1e3, ai = class e extends Kr {
4228
+ }, ci = 30 * 1e3, li = class e extends Xr {
4150
4229
  constructor(e, t, n, r, i, a = z, o = null, s = null, c = null, l = null) {
4151
4230
  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", {
4152
4231
  bad: {
@@ -4161,7 +4240,7 @@ var Gr = class {
4161
4240
  worst: 320,
4162
4241
  bad: 640,
4163
4242
  good: 1280
4164
- }), 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 Da(this, n, this._statAggregator, !0, this._debug), this._directStatReporter = new ri(n, this._debug), this._sdpStats = new Lr(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));
4243
+ }), 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));
4165
4244
  try {
4166
4245
  this._pc = this._createPeerConnection();
4167
4246
  } catch (e) {
@@ -4265,12 +4344,12 @@ var Gr = class {
4265
4344
  iceServers: N.iceServers,
4266
4345
  iceTransportPolicy: N.forceRelayPolicy ? "relay" : "all"
4267
4346
  });
4268
- 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) => {
4347
+ 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) => {
4269
4348
  this._animojiDataChannel = e, this._animojiDataChannel.binaryType = "arraybuffer", this._animojiReceiver?.setDataChannel(this._animojiDataChannel), this._animojiSender?.setDataChannel(this._animojiDataChannel);
4270
4349
  }), e;
4271
4350
  }
4272
4351
  _disposePeerConnection() {
4273
- if (this._disposeFirstMediaSentProbe(), this._sdpStats.stop(), this._lastStat = null, this._remoteStream) {
4352
+ if (this._disposeFirstMediaSentProbe(), this._sdpStats.stop(), this._peerConnectionStats.stop(), this._lastStat = null, this._remoteStream) {
4274
4353
  let e = this._remoteStream;
4275
4354
  e.getTracks().forEach((t) => {
4276
4355
  t.stop(), this._triggerEvent(Y.REMOTE_TRACK_REMOVED, e, t);
@@ -4319,7 +4398,7 @@ var Gr = class {
4319
4398
  try {
4320
4399
  await this._pc.addIceCandidate(new RTCIceCandidate(t));
4321
4400
  } catch (e) {
4322
- throw this._logger?.log(C.ERROR, "addIceCandidate-direct"), this._debug.error("Unable to add remote ice candidate", e, {
4401
+ throw this._logger?.log(C.ERROR, "addIceCandidate-direct"), this._peerConnectionStats.logIceCandidateAddFailed(t, e), this._debug.error("Unable to add remote ice candidate", e, {
4323
4402
  participantId: this._participantId,
4324
4403
  candidate: t
4325
4404
  }), e;
@@ -4438,7 +4517,7 @@ var Gr = class {
4438
4517
  this._reconnectionTimeout && (clearTimeout(this._reconnectionTimeout), this._reconnectionTimeout = null), this._iceRestartTimeout && (clearTimeout(this._iceRestartTimeout), this._iceRestartTimeout = null);
4439
4518
  }
4440
4519
  _startIceRestart() {
4441
- 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(() => {
4520
+ 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(() => {
4442
4521
  this._iceRestartTimeout = null, this._debug.error("Ice restart failed", { participantId: this._participantId }), this._logger?.log(C.ERROR, "iceRestart-direct"), this._requestTopologySwitch(N.switchTopologyOnReconnectFromAnySide);
4443
4522
  }, N.iceRestartWaitTime);
4444
4523
  }
@@ -4560,7 +4639,7 @@ var Gr = class {
4560
4639
  async _checkPPTNetwork(e) {
4561
4640
  if (!N.switchVideoAtBadNetwork || !e.inbound.transport.averageNetStat) return;
4562
4641
  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;
4563
- 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 > ii) || this._lastVideoMaxDimension === a) return;
4642
+ 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;
4564
4643
  let s = this._serverSettings.camera;
4565
4644
  if (!s || !await this._isSVCSupported(e, o)) return;
4566
4645
  this._debug.debug("Switch outbound video frame size and scalabilityMode", {
@@ -4625,9 +4704,9 @@ var Gr = class {
4625
4704
  }, n(r)) : this._debug.error(`[${t}] data channel open failed, state [${e}]`);
4626
4705
  };
4627
4706
  }
4628
- }, oi = /* @__PURE__ */ function(e) {
4707
+ }, ui = /* @__PURE__ */ function(e) {
4629
4708
  return e.AUDIO_MIX = "audio-mix", e.PARTICIPANT_AGNOSTIC_TRACK_PREFIX = "pat", e.TRANSPARENT_AUDIO_TRACK_PREFIX = "ta", e;
4630
- }({}), si = 16, ci = class e {
4709
+ }({}), di = 16, fi = class e {
4631
4710
  constructor(e, t, n, r = z) {
4632
4711
  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);
4633
4712
  }
@@ -4641,7 +4720,7 @@ var Gr = class {
4641
4720
  ssrc: a,
4642
4721
  timestamp: o,
4643
4722
  duration: s,
4644
- data: e.slice(si)
4723
+ data: e.slice(di)
4645
4724
  };
4646
4725
  }
4647
4726
  _onDataChannelMessage(t) {
@@ -4661,7 +4740,7 @@ var Gr = class {
4661
4740
  destroy() {
4662
4741
  this._datachannel.onmessage = null;
4663
4742
  }
4664
- }, li, ui = class {
4743
+ }, pi, mi = class {
4665
4744
  constructor() {
4666
4745
  h(this, "_value", 1);
4667
4746
  }
@@ -4672,10 +4751,10 @@ var Gr = class {
4672
4751
  this._value = e;
4673
4752
  }
4674
4753
  };
4675
- li = ui, h(ui, "_instance", null), h(ui, "getInstance", () => (li._instance || (li._instance = new li()), li._instance));
4754
+ pi = mi, h(mi, "_instance", null), h(mi, "getInstance", () => (pi._instance || (pi._instance = new pi()), pi._instance));
4676
4755
  //#endregion
4677
4756
  //#region src/classes/ParticipantIdRegistry.ts
4678
- var di = class {
4757
+ var hi = class {
4679
4758
  constructor(e = z) {
4680
4759
  h(this, "streamDescriptionByCompactId", /* @__PURE__ */ new Map()), h(this, "compactIdByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_debug", void 0), this._debug = e;
4681
4760
  }
@@ -4791,7 +4870,7 @@ var di = class {
4791
4870
  this._debug.error("unexpected null sequenceNumber", e, r);
4792
4871
  continue;
4793
4872
  }
4794
- let l = oi.PARTICIPANT_AGNOSTIC_TRACK_PREFIX + "-" + e, u = i ? i >>> 0 : null;
4873
+ let l = ui.PARTICIPANT_AGNOSTIC_TRACK_PREFIX + "-" + e, u = i ? i >>> 0 : null;
4795
4874
  n.push({
4796
4875
  participantStreamDescription: c,
4797
4876
  streamId: l,
@@ -4807,9 +4886,9 @@ var di = class {
4807
4886
  participantUpdateInfos: n
4808
4887
  };
4809
4888
  }
4810
- }, fi = /* @__PURE__ */ function(e) {
4889
+ }, gi = /* @__PURE__ */ function(e) {
4811
4890
  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;
4812
- }({}), pi = class {
4891
+ }({}), _i = class {
4813
4892
  constructor(e = z, t = null) {
4814
4893
  h(this, "_worker", null), h(this, "_debug", void 0), h(this, "_logger", void 0), this._debug = e, this._logger = t;
4815
4894
  }
@@ -4825,7 +4904,7 @@ var di = class {
4825
4904
  return;
4826
4905
  }
4827
4906
  t({
4828
- type: fi.FRAME,
4907
+ type: gi.FRAME,
4829
4908
  error: e
4830
4909
  });
4831
4910
  };
@@ -4835,23 +4914,23 @@ var di = class {
4835
4914
  e.preventDefault?.(), m(this._formatWorkerMessageError(e));
4836
4915
  }, f.onmessage = (e) => {
4837
4916
  switch (e.data.type) {
4838
- case fi.READY:
4917
+ case gi.READY:
4839
4918
  s = !0, c || (c = !0, a());
4840
4919
  break;
4841
- case fi.ERROR:
4920
+ case gi.ERROR:
4842
4921
  s ? m(e.data.error) : p(e.data.error);
4843
4922
  break;
4844
- case fi.FRAME:
4923
+ case gi.FRAME:
4845
4924
  t(e.data);
4846
4925
  break;
4847
- case fi.DEBUG:
4926
+ case gi.DEBUG:
4848
4927
  this._debug.debug(e.data.message);
4849
4928
  break;
4850
- case fi.LOG_ERROR:
4929
+ case gi.LOG_ERROR:
4851
4930
  this._logger?.log(C.ERROR, e.data.message);
4852
4931
  break;
4853
4932
  }
4854
- }, this._sendToWorker(fi.INIT, r, i);
4933
+ }, this._sendToWorker(gi.INIT, r, i);
4855
4934
  });
4856
4935
  }
4857
4936
  _removeWorker() {
@@ -4874,7 +4953,7 @@ var di = class {
4874
4953
  static isBrowserSupported() {
4875
4954
  throw Error("Not implemented");
4876
4955
  }
4877
- }, mi = class extends pi {
4956
+ }, vi = class extends _i {
4878
4957
  constructor(e = z, t = null) {
4879
4958
  super(e, t);
4880
4959
  }
@@ -4884,7 +4963,7 @@ var di = class {
4884
4963
  }, [c, c.getUrl]);
4885
4964
  }
4886
4965
  decodeFrame(e, t, n, r) {
4887
- this._sendToWorker(fi.FRAME, {
4966
+ this._sendToWorker(gi.FRAME, {
4888
4967
  timestamp: e,
4889
4968
  data: t.buffer,
4890
4969
  isVP9: n,
@@ -4898,7 +4977,7 @@ var di = class {
4898
4977
  static isBrowserSupported() {
4899
4978
  return "WebAssembly" in window && "Worker" in window;
4900
4979
  }
4901
- }, hi = class extends pi {
4980
+ }, yi = class extends _i {
4902
4981
  constructor(e = z, t = null) {
4903
4982
  super(e, t);
4904
4983
  }
@@ -4908,7 +4987,7 @@ var di = class {
4908
4987
  }, [!0]);
4909
4988
  }
4910
4989
  decodeFrame(e, t, n, r = !1) {
4911
- this._sendToWorker(fi.FRAME, {
4990
+ this._sendToWorker(gi.FRAME, {
4912
4991
  timestamp: e,
4913
4992
  data: t.buffer,
4914
4993
  isVP9: n,
@@ -4921,7 +5000,7 @@ var di = class {
4921
5000
  static isBrowserSupported() {
4922
5001
  return "VideoDecoder" in window && "Worker" in window && "VideoFrame" in window && !E.isBrokenVP9Decoder() && E.browserName() !== "Firefox";
4923
5002
  }
4924
- }, gi = class {
5003
+ }, bi = class {
4925
5004
  constructor(e = null, t = 0) {
4926
5005
  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));
4927
5006
  }
@@ -4935,7 +5014,7 @@ var di = class {
4935
5014
  destroy() {
4936
5015
  window.clearInterval(this._interval), this._interval = 0;
4937
5016
  }
4938
- }, _i = class {
5017
+ }, xi = class {
4939
5018
  constructor(e, t) {
4940
5019
  h(this, "_participantId", void 0), h(this, "_statAggregator", void 0), h(this, "_firstFrameReceived", !1), this._participantId = e, this._statAggregator = t;
4941
5020
  }
@@ -4950,14 +5029,14 @@ var di = class {
4950
5029
  height: t
4951
5030
  });
4952
5031
  }
4953
- }, vi = 65536, yi = "MARK_SCREENSHARE_FREEZE_DURATION", bi = class e {
5032
+ }, Si = 65536, Ci = "MARK_SCREENSHARE_FREEZE_DURATION", wi = class e {
4954
5033
  constructor(e, t, n, r, i, a = z) {
4955
- 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 _i(e, r), this._debug = a;
5034
+ 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;
4956
5035
  }
4957
5036
  appendChunk(t) {
4958
5037
  let n = this._chunks.length;
4959
5038
  if (t.start) this._measureFreezeDuration(!1), this._measureFreezeDuration(!0), n && (this._debug.warn("[FrameBuilder] Cleanup buffer", Array.prototype.slice.call(this._chunks)), this._chunks = []);
4960
- else if (!n || (this._chunks[n - 1].sequence + 1) % vi !== t.sequence) {
5039
+ else if (!n || (this._chunks[n - 1].sequence + 1) % Si !== t.sequence) {
4961
5040
  this._debug.warn("[FrameBuilder] Got incorrect chunk");
4962
5041
  return;
4963
5042
  }
@@ -4974,7 +5053,7 @@ var di = class {
4974
5053
  }
4975
5054
  }
4976
5055
  destroy() {
4977
- G.clearMark(yi), G.clearMark(G.getMarkNameScreenshareFirstFrame(this._participantId)), this._chunks = [];
5056
+ G.clearMark(Ci), G.clearMark(G.getMarkNameScreenshareFirstFrame(this._participantId)), this._chunks = [];
4978
5057
  }
4979
5058
  _processFrameData() {
4980
5059
  let e = this._chunks;
@@ -4997,13 +5076,13 @@ var di = class {
4997
5076
  }
4998
5077
  _measureFreezeDuration(e) {
4999
5078
  if (e) {
5000
- G.setMark(yi);
5079
+ G.setMark(Ci);
5001
5080
  return;
5002
5081
  }
5003
- let t = G.measureMark(yi);
5082
+ let t = G.measureMark(Ci);
5004
5083
  t !== null && t > 1e3 && this._onStat({ freeze_duration: t });
5005
5084
  }
5006
- }, xi = class {
5085
+ }, Ti = class {
5007
5086
  constructor(e) {
5008
5087
  h(this, "_onStream", void 0), this._onStream = e;
5009
5088
  }
@@ -5016,7 +5095,7 @@ var di = class {
5016
5095
  static isBrowserSupported() {
5017
5096
  throw Error("Method `isBrowserSupported` is not implemented");
5018
5097
  }
5019
- }, Si = class extends xi {
5098
+ }, Ei = class extends Ti {
5020
5099
  constructor(e, t = z) {
5021
5100
  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;
5022
5101
  }
@@ -5076,7 +5155,7 @@ var di = class {
5076
5155
  static isBrowserSupported() {
5077
5156
  return ("CanvasCaptureMediaStream" in window || "CanvasCaptureMediaStreamTrack" in window) && !(E.browserName() === "Safari" && Number(E.browserVersion()) === 15);
5078
5157
  }
5079
- }, Ci = class extends xi {
5158
+ }, Di = class extends Ti {
5080
5159
  constructor(e, t = z) {
5081
5160
  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);
5082
5161
  }
@@ -5087,9 +5166,9 @@ var di = class {
5087
5166
  this._writer.releaseLock(), this._generator.writable.close().then(() => this._generator.stop()), this._debug.debug("TrackGeneratorRenderer destroyed");
5088
5167
  }
5089
5168
  static isBrowserSupported() {
5090
- return "VideoFrame" in window && "MediaStreamTrackGenerator" in window && hi.isBrowserSupported();
5169
+ return "VideoFrame" in window && "MediaStreamTrackGenerator" in window && yi.isBrowserSupported();
5091
5170
  }
5092
- }, wi = class extends bi {
5171
+ }, Oi = class extends wi {
5093
5172
  constructor(e, t, n, r, i, a = z, o = null) {
5094
5173
  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();
5095
5174
  }
@@ -5097,16 +5176,16 @@ var di = class {
5097
5176
  e.keyframe && (this._decoderQueue = []), this._decoderQueue.push(e), this._decodeQueue();
5098
5177
  }
5099
5178
  _initFpsMeter() {
5100
- this._fpsMeter = new gi((e) => this._debug.log(`[StreamBuilder][${this._participantId}] fps: ${e}`), 2e4);
5179
+ this._fpsMeter = new bi((e) => this._debug.log(`[StreamBuilder][${this._participantId}] fps: ${e}`), 2e4);
5101
5180
  }
5102
5181
  _initRenderer(e = !1) {
5103
- e || !Ci.isBrowserSupported() ? this._renderer = new Si(this._onStream, this._debug) : this._renderer = new Ci(this._onStream, this._debug);
5182
+ e || !Di.isBrowserSupported() ? this._renderer = new Ei(this._onStream, this._debug) : this._renderer = new Di(this._onStream, this._debug);
5104
5183
  }
5105
5184
  _initDecoder(e = !1) {
5106
- e || !hi.isBrowserSupported() ? this._decoder = new mi(this._debug, this._logger) : this._decoder = new hi(this._debug, this._logger), this._decoder.init(async (e) => {
5185
+ e || !yi.isBrowserSupported() ? this._decoder = new vi(this._debug, this._logger) : this._decoder = new yi(this._debug, this._logger), this._decoder.init(async (e) => {
5107
5186
  this._decoderBusy = !1, "VideoFrame" in window && e instanceof VideoFrame ? await this._renderer.drawFrame(e) : await this._renderer.drawImage(e), this._fpsMeter.increment(), this._decodeQueue();
5108
5187
  }, (e) => {
5109
- if (this._decoderBusy = !1, this._decoder instanceof hi && typeof e == "string" && e.includes("EncodingError")) {
5188
+ if (this._decoderBusy = !1, this._decoder instanceof yi && typeof e == "string" && e.includes("EncodingError")) {
5110
5189
  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();
5111
5190
  return;
5112
5191
  }
@@ -5114,7 +5193,7 @@ var di = class {
5114
5193
  }, this._onKeyFrameRequested).then(() => {
5115
5194
  this._decoderReady = !0, this._decodeQueue();
5116
5195
  }).catch((e) => {
5117
- this._debug.warn("StreamBuilder decoder init failed", e), this._decoder instanceof hi && this._switchToLibVPXDecoder();
5196
+ this._debug.warn("StreamBuilder decoder init failed", e), this._decoder instanceof yi && this._switchToLibVPXDecoder();
5118
5197
  });
5119
5198
  }
5120
5199
  _switchToLibVPXDecoder() {
@@ -5129,20 +5208,20 @@ var di = class {
5129
5208
  super.destroy(), this._fpsMeter.destroy(), this._decoder.destroy(), this._renderer.destroy(), this._debug.debug(`StreamBuilder destroyed for participant ${this._participantId}`);
5130
5209
  }
5131
5210
  static isBrowserSupported() {
5132
- return Si.isBrowserSupported() || Ci.isBrowserSupported();
5211
+ return Ei.isBrowserSupported() || Di.isBrowserSupported();
5133
5212
  }
5134
- }, Ti = 1, Ei = 1, Di = 2, Oi = 0, ki = 1, Ai = 2, ji = 4, Mi = 8;
5135
- function Ni(e, t, n, r, i, a, o) {
5213
+ }, ki = 1, Ai = 1, ji = 2, Mi = 0, Ni = 1, Pi = 2, Fi = 4, Ii = 8;
5214
+ function Li(e, t, n, r, i, a, o) {
5136
5215
  let s = 0;
5137
- t && (s |= ki), n && (s |= Ai), r && (s |= ji), o || (s |= Mi);
5216
+ t && (s |= Ni), n && (s |= Pi), r && (s |= Fi), o || (s |= Ii);
5138
5217
  let c = /* @__PURE__ */ new ArrayBuffer(11), l = new DataView(c);
5139
- if (l.setUint8(0, Ti), l.setUint16(1, i), l.setUint32(3, e), l.setUint8(7, +!!a), l.setUint16(8, Oi), l.setUint8(10, s), !o) return c;
5218
+ 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;
5140
5219
  let u = new Uint8Array(c.byteLength + o.byteLength);
5141
5220
  return u.set(new Uint8Array(c), 0), u.set(new Uint8Array(o), c.byteLength), u.buffer;
5142
5221
  }
5143
- function Pi(e) {
5144
- 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 & ki), l = !!(s & Ai), u = !!(s & ji), d = !!(s & Mi);
5145
- if (n !== Ti) throw Error(`Unexpected protocol version. Got ${n}, expected ${Ti}`);
5222
+ function Ri(e) {
5223
+ 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);
5224
+ if (n !== ki) throw Error(`Unexpected protocol version. Got ${n}, expected ${ki}`);
5146
5225
  return {
5147
5226
  timestamp: i,
5148
5227
  start: c,
@@ -5155,26 +5234,26 @@ function Pi(e) {
5155
5234
  data: e.slice(11)
5156
5235
  };
5157
5236
  }
5158
- function Fi(e) {
5237
+ function zi(e) {
5159
5238
  if (!e || !e.byteLength || e.byteLength !== 4) return !1;
5160
5239
  let t = new DataView(e);
5161
- return !(t.getUint8(0) !== Ti || t.getUint8(1) !== Ei || t.getUint16(2) !== Oi);
5240
+ return !(t.getUint8(0) !== ki || t.getUint8(1) !== Ai || t.getUint16(2) !== Mi);
5162
5241
  }
5163
- function Ii(e) {
5242
+ function Bi(e) {
5164
5243
  if (!e || !e.byteLength || e.byteLength !== 10) return null;
5165
5244
  let t = new DataView(e);
5166
- return t.getUint8(0) !== Ti || t.getUint8(1) !== Di || t.getUint16(2) !== Oi ? null : {
5245
+ return t.getUint8(0) !== ki || t.getUint8(1) !== ji || t.getUint16(2) !== Mi ? null : {
5167
5246
  seq: t.getUint16(4),
5168
5247
  ts2: t.getUint32(6)
5169
5248
  };
5170
5249
  }
5171
- function Li(e) {
5250
+ function Vi(e) {
5172
5251
  let t = /* @__PURE__ */ new ArrayBuffer(4), n = new DataView(t);
5173
- return n.setUint8(0, Ti), n.setUint8(1, Ei), n.setUint16(2, e), t;
5252
+ return n.setUint8(0, ki), n.setUint8(1, Ai), n.setUint16(2, e), t;
5174
5253
  }
5175
5254
  //#endregion
5176
5255
  //#region src/classes/screenshare/WebmBuilder.ts
5177
- var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5256
+ var Hi = 2 ** 15 - 1, Ui = 1, Wi = 5, Gi = 5, Ki = class e {
5178
5257
  constructor(e, t = z) {
5179
5258
  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;
5180
5259
  let n = () => {
@@ -5217,8 +5296,8 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5217
5296
  this._mediaSource?.readyState === "open" && this._sourceBuffer?.abort();
5218
5297
  let e = this._sourceBuffer?.buffered, t = e?.length;
5219
5298
  if (!t) return;
5220
- let n = e.start(0), r = Math.max(0, e.end(t - 1) - Bi);
5221
- r - n > Vi && (this._clearBufferTill = r);
5299
+ let n = e.start(0), r = Math.max(0, e.end(t - 1) - Wi);
5300
+ r - n > Gi && (this._clearBufferTill = r);
5222
5301
  }
5223
5302
  destroy() {
5224
5303
  this._queue = [], this._mediaSource.readyState === "open" && (this._sourceBuffer?.abort(), this._mediaSource.endOfStream()), this._sourceBuffer = null, this._clearBufferTill = 0;
@@ -5232,7 +5311,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5232
5311
  get buffered() {
5233
5312
  return this._sourceBuffer?.buffered;
5234
5313
  }
5235
- }, Ui = class e extends bi {
5314
+ }, qi = class e extends wi {
5236
5315
  constructor(e, t, n, r, i = z) {
5237
5316
  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}]`);
5238
5317
  }
@@ -5256,8 +5335,8 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5256
5335
  u.element(u.ID.MuxingApp, u.string("vk-webm-builder")),
5257
5336
  u.element(u.ID.WritingApp, u.string("vk-webm-builder"))
5258
5337
  ]), 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, [
5259
- u.element(u.ID.TrackNumber, u.number(zi)),
5260
- u.element(u.ID.TrackUID, u.number(zi)),
5338
+ u.element(u.ID.TrackNumber, u.number(Ui)),
5339
+ u.element(u.ID.TrackUID, u.number(Ui)),
5261
5340
  u.element(u.ID.TrackType, u.number(1)),
5262
5341
  u.element(u.ID.FlagLacing, u.number(0)),
5263
5342
  u.element(u.ID.DefaultDuration, u.number(1e9)),
@@ -5270,7 +5349,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5270
5349
  return u.unknownSizeElement(u.ID.Cluster, [u.element(u.ID.Timecode, u.number(Math.round(e)))]);
5271
5350
  }
5272
5351
  _createVideo(e) {
5273
- this._mediaBuffer = new Hi(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);
5352
+ 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);
5274
5353
  let t = () => {
5275
5354
  if (this._video?.src) {
5276
5355
  this._debug.warn(`[WebmBuilder] Video paused for participant [${this._participantId}], try to play again`);
@@ -5297,13 +5376,13 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5297
5376
  this._mediaBuffer?.append(a);
5298
5377
  }
5299
5378
  let i = Math.round(r - this._clusterStartTime);
5300
- if (i > Ri && (this._clusterStartTime = r, i = 0), i === 0) {
5379
+ if (i > Hi && (this._clusterStartTime = r, i = 0), i === 0) {
5301
5380
  this._debug.debug(`[WebmBuilder] Cluster header for participant [${this._participantId}]`);
5302
5381
  let t = e._genClusterHeader(this._clusterStartTime);
5303
5382
  this._mediaBuffer?.append(t);
5304
5383
  }
5305
5384
  let a = u.element(u.ID.SimpleBlock, [
5306
- u.vintEncodedNumber(zi),
5385
+ u.vintEncodedNumber(Ui),
5307
5386
  u.bytes(e._intToU16BE(i)),
5308
5387
  u.number(!!t.keyframe << 7),
5309
5388
  u.bytes(t.frameData)
@@ -5316,12 +5395,12 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5316
5395
  static isBrowserSupported() {
5317
5396
  return "captureStream" in window.HTMLVideoElement?.prototype && window.MediaSource?.isTypeSupported("video/webm; codecs=\"vp8\"") && window.MediaSource?.isTypeSupported("video/webm; codecs=\"vp9\"");
5318
5397
  }
5319
- }, Wi = class {
5398
+ }, Ji = class {
5320
5399
  constructor(e, t, n, r, i, a = null, o = z, s = null) {
5321
5400
  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);
5322
5401
  }
5323
5402
  _onDataChannelMessage(e) {
5324
- let t = Pi(e), n = this._participantIdRegistry?.getStreamDescription(t.ssrc)?.participantId;
5403
+ let t = Ri(e), n = this._participantIdRegistry?.getStreamDescription(t.ssrc)?.participantId;
5325
5404
  if (!n) {
5326
5405
  this._debug.warn(`Participant id for ssrc ${t.ssrc} not found in registry`);
5327
5406
  return;
@@ -5333,7 +5412,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5333
5412
  let r = this._streamBuilders[n];
5334
5413
  if (!r) {
5335
5414
  let e = (e) => this._onStream(n, e);
5336
- r = N.screenShareWebmBuilder && Ui.isBrowserSupported() ? new Ui(n, e, this._onStat, this._statAggregator, this._debug) : new wi(n, e, this._onStat, this._statAggregator, () => {
5415
+ r = N.screenShareWebmBuilder && qi.isBrowserSupported() ? new qi(n, e, this._onStat, this._statAggregator, this._debug) : new Oi(n, e, this._onStat, this._statAggregator, () => {
5337
5416
  this._requestKeyFrame(t.ssrc);
5338
5417
  }, this._debug, this._logger), this._streamBuilders[n] = r;
5339
5418
  }
@@ -5341,7 +5420,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5341
5420
  }
5342
5421
  _requestKeyFrame(e) {
5343
5422
  if (!(!this._datachannel || this._datachannel.readyState !== "open")) try {
5344
- let t = Li(e);
5423
+ let t = Vi(e);
5345
5424
  this._datachannel.send(t), this._debug.debug(`ScreenCaptureReceiver request for keyframe for ssrc ${e}`);
5346
5425
  } catch (e) {
5347
5426
  this._debug.warn("Failed to send keyframe request", e);
@@ -5354,7 +5433,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5354
5433
  destroy() {
5355
5434
  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");
5356
5435
  }
5357
- }, Gi = class {
5436
+ }, Yi = class {
5358
5437
  constructor(e, t, n) {
5359
5438
  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;
5360
5439
  }
@@ -5373,7 +5452,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5373
5452
  get data() {
5374
5453
  return this._data;
5375
5454
  }
5376
- }, Ki = class {
5455
+ }, Xi = class {
5377
5456
  constructor() {
5378
5457
  h(this, "_head", null), h(this, "_tail", null), h(this, "_length", 0);
5379
5458
  }
@@ -5381,7 +5460,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5381
5460
  return this._length;
5382
5461
  }
5383
5462
  push(...e) {
5384
- for (let t of e) this._tail = new Gi(t, this._tail, null), this._head || (this._head = this._tail), this._length++;
5463
+ for (let t of e) this._tail = new Yi(t, this._tail, null), this._head || (this._head = this._tail), this._length++;
5385
5464
  }
5386
5465
  merge(e) {
5387
5466
  this._tail && (this._tail.next = e._head), this._head || (this._head = e._head), this._tail = e._tail, this._length += e._length, e.clear();
@@ -5411,7 +5490,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5411
5490
  for (; t !== null;) e.push(t.data), t = t.next;
5412
5491
  return e.length ? JSON.stringify(e, (e, t) => t instanceof Error ? String(t) : t) : "";
5413
5492
  }
5414
- }, qi = 1e3, Ji = class extends pi {
5493
+ }, Zi = 1e3, Qi = class extends _i {
5415
5494
  constructor(e, t, n, r, i = z, a = null) {
5416
5495
  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);
5417
5496
  }
@@ -5480,7 +5559,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5480
5559
  }
5481
5560
  _encode(e, t) {
5482
5561
  let n = e.data.buffer;
5483
- this._sendToWorker(fi.FRAME, {
5562
+ this._sendToWorker(gi.FRAME, {
5484
5563
  width: e.width,
5485
5564
  height: e.height,
5486
5565
  imageData: n,
@@ -5497,7 +5576,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5497
5576
  let t = this._drawFrameData(this._lastFrame);
5498
5577
  this._encode(t, e);
5499
5578
  } else this._onFrame(null);
5500
- }, qi), this._getFrameBitmap().then((t) => {
5579
+ }, Zi), this._getFrameBitmap().then((t) => {
5501
5580
  window.clearTimeout(this._frameReadTimeout), this._lastFrame?.close(), this._lastFrame = t;
5502
5581
  let n = this._drawFrameData(t);
5503
5582
  this._encode(n, e);
@@ -5507,7 +5586,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5507
5586
  this._useImageCapture ? this._requestFrameBitmap(e) : this._requestFrameVideo(e);
5508
5587
  }
5509
5588
  setBitrate(e, t, n) {
5510
- this._sendToWorker(fi.SET_BITRATE, {
5589
+ this._sendToWorker(gi.SET_BITRATE, {
5511
5590
  bitrate: e,
5512
5591
  useCbr: t
5513
5592
  });
@@ -5518,7 +5597,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5518
5597
  destroy() {
5519
5598
  this._removeWorker(), this._removeStream(), this._removeDom(), this._debug.debug("LibVPxEncoder destroyed");
5520
5599
  }
5521
- }, Yi = class extends pi {
5600
+ }, $i = class extends _i {
5522
5601
  constructor(e, t, n, r, i, a, o = z, s = null) {
5523
5602
  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 });
5524
5603
  }
@@ -5546,10 +5625,10 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5546
5625
  }, [n]);
5547
5626
  }
5548
5627
  requestFrame(e = !1) {
5549
- this._sendToWorker(fi.FRAME, { keyFrame: e });
5628
+ this._sendToWorker(gi.FRAME, { keyFrame: e });
5550
5629
  }
5551
5630
  setBitrate(e, t, n) {
5552
- this._sendToWorker(fi.SET_BITRATE, {
5631
+ this._sendToWorker(gi.SET_BITRATE, {
5553
5632
  bitrate: e,
5554
5633
  useCbr: t,
5555
5634
  fps: n
@@ -5564,11 +5643,11 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5564
5643
  static isBrowserSupported() {
5565
5644
  return "VideoEncoder" in window && "Worker" in window && "EncodedVideoChunk" in window && "MediaStreamTrackProcessor" in window;
5566
5645
  }
5567
- }, Xi = 2100, Zi = 600, Qi = 1.2, $i = .8, ea = 2e3, ta = 8e3, na = 8e3, ra = 16e3, ia = 4, aa = 2e3, oa = /* @__PURE__ */ function(e) {
5646
+ }, 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) {
5568
5647
  return e[e.NONE = 0] = "NONE", e[e.UP = 1] = "UP", e[e.DOWN = 2] = "DOWN", e;
5569
- }(oa || {}), sa = class {
5648
+ }(ua || {}), da = class {
5570
5649
  constructor(e, t, n, r, i, a, o, s = z) {
5571
- 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 = Xi, i && (this._highDelayThreshold = Zi), this._trendDelayThreshold = Math.round(this._highDelayThreshold / 3), this._targetBitrate = this._maxBitrate, this._probing = !1;
5650
+ 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;
5572
5651
  let c = Date.now();
5573
5652
  this._lastDown = 0, this._lastUp = c, this._lastProbing = c, this._lastCheckDelay = 0, this._lastFpsCalcMs = 0;
5574
5653
  }
@@ -5578,27 +5657,27 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5578
5657
  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;
5579
5658
  s || c ? i = 2 : Math.abs(a) < 40 && o < 10 && !c && (i = 1);
5580
5659
  let l = Math.round(this._targetBitrate / 1e3), u = n;
5581
- e % 20 == 0 && this._debug.debug(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${oa[i]} tr=${l} br=${n}`);
5660
+ 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}`);
5582
5661
  let d = r - this._lastDown;
5583
- if (i === 2 && d > ea) {
5584
- this._probing && (this._upPenalty = Math.min(++this._upPenalty, ia), this._probing = !1);
5585
- let n = $i * u * 1e3;
5586
- if (n >= this._targetBitrate && (n = this._targetBitrate * $i), n = Math.max(n, this._minBitrate), n < this._targetBitrate) {
5587
- let r = Math.round(n / 1e3), s = Math.round(this._upPenalty * na / 1e3);
5588
- this._debug.log(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${oa[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;
5662
+ if (i === 2 && d > ia) {
5663
+ this._probing && (this._upPenalty = Math.min(++this._upPenalty, ca), this._probing = !1);
5664
+ let n = ra * u * 1e3;
5665
+ if (n >= this._targetBitrate && (n = this._targetBitrate * ra), n = Math.max(n, this._minBitrate), n < this._targetBitrate) {
5666
+ let r = Math.round(n / 1e3), s = Math.round(this._upPenalty * oa / 1e3);
5667
+ 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;
5589
5668
  }
5590
5669
  this._lastDown = r;
5591
5670
  }
5592
- let f = r - this._lastUp, p = ta + this._upPenalty * na;
5671
+ let f = r - this._lastUp, p = aa + this._upPenalty * oa;
5593
5672
  if (i === 1 && f > p && d > p) {
5594
- let n = Math.min(this._targetBitrate * Qi, this._maxBitrate);
5673
+ let n = Math.min(this._targetBitrate * na, this._maxBitrate);
5595
5674
  if (n > this._targetBitrate) {
5596
- let s = Math.round(n / 1e3), c = Math.round(this._targetBitrate / 1e3), l = Math.round(this._upPenalty * na / 1e3);
5597
- this._debug.log(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${oa[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;
5675
+ let s = Math.round(n / 1e3), c = Math.round(this._targetBitrate / 1e3), l = 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: 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;
5598
5677
  }
5599
5678
  }
5600
5679
  let m = r - this._lastProbing;
5601
- this._probing && m > ra && (this._probing = !1);
5680
+ this._probing && m > sa && (this._probing = !1);
5602
5681
  let ee = r - this._lastDown;
5603
5682
  this._upPenalty > 0 && ee > 3 * p && (this._debug.log(`#${e}: cc: UP reset penalty: oldPenalty=${this._upPenalty}`), this._upPenalty = 0);
5604
5683
  }
@@ -5609,7 +5688,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5609
5688
  }
5610
5689
  _calcDelay(e, t) {
5611
5690
  if (!(e <= 0)) {
5612
- 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 > aa) {
5691
+ 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) {
5613
5692
  let e = t - this._lastCheckDelay;
5614
5693
  this._largeDelayDuration += e;
5615
5694
  }
@@ -5638,7 +5717,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5638
5717
  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}`);
5639
5718
  }
5640
5719
  }
5641
- }, ca = class {
5720
+ }, fa = class {
5642
5721
  constructor(e) {
5643
5722
  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);
5644
5723
  }
@@ -5712,11 +5791,11 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5712
5791
  clear() {
5713
5792
  this._buffer.fill(void 0), this._size = 0, this._head = 0, this._tail = 0;
5714
5793
  }
5715
- }, la = 65536, ua = 50, da = 400, fa = 1e6, pa = 3e5, ma = 3e4, ha = 2e3, ga = 5, _a = 0, va = class {
5794
+ }, pa = 65536, ma = 50, ha = 400, ga = 1e6, _a = 3e5, va = 3e4, ya = 2e3, ba = 5, xa = 0, Sa = class {
5716
5795
  constructor(e, t, n, r, i = z, a = null) {
5717
- 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 ca(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 Ki()), 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;
5796
+ 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;
5718
5797
  let o = N.getScreenFrameRate(this._fastSharing), { minBitrate: s, maxBitrate: c } = this._calcMinMaxBitrate(this._width, this._height), l = this._onCongestionCallback.bind(this);
5719
- 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 sa(l, s, c, this._congestionControlEnabled, this._fastSharing, N.screenShareCongestionControlThreshold, o, this._debug);
5798
+ 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);
5720
5799
  let u = (e, t) => {
5721
5800
  if (this._destroyed) return;
5722
5801
  if (!e) {
@@ -5727,23 +5806,23 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5727
5806
  let n = this._sliceFrame(e);
5728
5807
  this._queue.merge(n), this._handleQueue(), this._sendSharingStat();
5729
5808
  };
5730
- if (Yi.isBrowserSupported()) {
5809
+ if ($i.isBrowserSupported()) {
5731
5810
  let t = this._fastSharing;
5732
- this._encoder = new Yi(e, u, this._congestionControlEnabled, c, t, o, this._debug, this._logger);
5733
- } else this._encoder = new Ji(e, u, this._congestionControlEnabled, c, this._debug, this._logger);
5811
+ this._encoder = new $i(e, u, this._congestionControlEnabled, c, t, o, this._debug, this._logger);
5812
+ } else this._encoder = new Qi(e, u, this._congestionControlEnabled, c, this._debug, this._logger);
5734
5813
  this._datachannel.onmessage = (e) => {
5735
- Fi(e.data) && (this._debug.debug(`[${this._datachannel.label}] Requested keyframe`), this._needKeyframe = !0);
5736
- let t = Ii(e.data);
5814
+ zi(e.data) && (this._debug.debug(`[${this._datachannel.label}] Requested keyframe`), this._needKeyframe = !0);
5815
+ let t = Bi(e.data);
5737
5816
  t !== null && this._checkCcFeedback(t);
5738
- }, this._encoder.init().then(() => this._handleQueue()).catch((e) => this._debug.warn("ScreenCaptureSender init failed", e)), this._fpsMeter = new gi((e) => this._debug.log(`[ScreenCaptureSender] fps: ${e}`), 5e3);
5817
+ }, 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);
5739
5818
  }
5740
5819
  _handleQueue() {
5741
5820
  if (this._destroyed) return;
5742
5821
  let e = this._queue.shift();
5743
5822
  if (!e) {
5744
- if ((this._lastSentFrameSeq - this._lastDeliveredFrameSeq + la) % la > ga && this._lastFrameDelay > this._maxFrameDelay) {
5823
+ if ((this._lastSentFrameSeq - this._lastDeliveredFrameSeq + pa) % pa > ba && this._lastFrameDelay > this._maxFrameDelay) {
5745
5824
  let e = Date.now();
5746
- e - this._lastFramerateReduced > ha && (this._lastFramerateReduced = e, this._debug.debug(`[ScreenCaptureSender] reduce framerate: delay=${this._lastFrameDelay} maxDelay=${this._maxFrameDelay}`));
5825
+ e - this._lastFramerateReduced > ya && (this._lastFramerateReduced = e, this._debug.debug(`[ScreenCaptureSender] reduce framerate: delay=${this._lastFrameDelay} maxDelay=${this._maxFrameDelay}`));
5747
5826
  } else this._requestFrame();
5748
5827
  return;
5749
5828
  }
@@ -5769,7 +5848,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5769
5848
  this._destroyed || (this._encoder.requestFrame(this._needKeyframe), this._needKeyframe = !1);
5770
5849
  }
5771
5850
  _sliceFrame(e) {
5772
- let t = e.type === "key", n = e.data.byteLength, r = new Ki();
5851
+ let t = e.type === "key", n = e.data.byteLength, r = new Xi();
5773
5852
  for (let i = 0; i < n; i += this.DATA_SIZE) {
5774
5853
  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);
5775
5854
  r.push({
@@ -5785,11 +5864,11 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5785
5864
  return r;
5786
5865
  }
5787
5866
  _wrapHeader(e, t, n, r, i) {
5788
- let a = Ni(e, t, n, r, _a, this._encoder.isVP9(), i), o = {
5789
- sequence: _a,
5867
+ let a = Li(e, t, n, r, xa, this._encoder.isVP9(), i), o = {
5868
+ sequence: xa,
5790
5869
  data: a
5791
5870
  };
5792
- return _a = (_a + 1) % la, o;
5871
+ return xa = (xa + 1) % pa, o;
5793
5872
  }
5794
5873
  _stopPacket() {
5795
5874
  return this._wrapHeader(Date.now(), !1, !1, !1, null).data;
@@ -5806,7 +5885,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5806
5885
  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");
5807
5886
  }
5808
5887
  static isBrowserSupported() {
5809
- return Yi.isBrowserSupported() || Ji.isBrowserSupported();
5888
+ return $i.isBrowserSupported() || Qi.isBrowserSupported();
5810
5889
  }
5811
5890
  _onCongestionCallback(e, t, n) {
5812
5891
  this._encoder.setBitrate(e, t, n);
@@ -5819,8 +5898,8 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5819
5898
  (e === void 0 || e < 640) && (e = 640), (t === void 0 || t < 360) && (t = 360);
5820
5899
  let n = e * t / 256;
5821
5900
  return {
5822
- minBitrate: Math.max(pa, Math.min(fa, Math.round(n * ua))),
5823
- maxBitrate: Math.round(n * da)
5901
+ minBitrate: Math.max(_a, Math.min(ga, Math.round(n * ma))),
5902
+ maxBitrate: Math.round(n * ha)
5824
5903
  };
5825
5904
  }
5826
5905
  _checkCcFeedback(e) {
@@ -5834,14 +5913,14 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5834
5913
  }
5835
5914
  _sendSharingStat() {
5836
5915
  let e = Date.now();
5837
- if (e - this._lastSharingStat > ma) {
5916
+ if (e - this._lastSharingStat > va) {
5838
5917
  let t = this._congestionControl.getStat();
5839
5918
  t !== null && (this._debug.debug(`cc: send stats: ${JSON.stringify(t)}`), this._signaling.reportSharingStat(t).catch((e) => {
5840
5919
  !(e instanceof En) && !(e instanceof Dn) && this._debug.warn("Unable to send sharing stats", e);
5841
5920
  })), this._lastSharingStat = e;
5842
5921
  }
5843
5922
  }
5844
- }, ya = class {
5923
+ }, Ca = class {
5845
5924
  constructor(e, t, n, r = z, i = null) {
5846
5925
  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;
5847
5926
  }
@@ -5973,9 +6052,9 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5973
6052
  if (!(e instanceof Dn)) throw e;
5974
6053
  }
5975
6054
  }
5976
- }, ba = 90, xa = 4294967295, Sa = class e extends Kr {
6055
+ }, wa = 90, Ta = 4294967295, Ea = class e extends Xr {
5977
6056
  constructor(e, t, n, r = z, i = null, a = null, o = null, s = null) {
5978
- 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 Lr(a), this._codecStatsAggregator = o, this._serverSettings = n, this._simulcast = new ya(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");
6057
+ 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");
5979
6058
  }
5980
6059
  updateStatisticsInterval() {
5981
6060
  this._stopStatInterval();
@@ -6014,10 +6093,10 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6014
6093
  await this._simulcast.sync();
6015
6094
  }
6016
6095
  _createPerfStatsReporter() {
6017
- this._perfStatReporter?.destroy(), this._perfStatReporter = new Da(this, this._signaling, this._statAggregator, !1, this._debug);
6096
+ this._perfStatReporter?.destroy(), this._perfStatReporter = new Ma(this, this._signaling, this._statAggregator, !1, this._debug);
6018
6097
  }
6019
6098
  _closeConnection() {
6020
- 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);
6099
+ 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);
6021
6100
  }
6022
6101
  static _closeDataChannel(e) {
6023
6102
  e && (e.onopen = null, e.onmessage = null, e.onerror = null, e.close());
@@ -6043,14 +6122,14 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6043
6122
  }
6044
6123
  this._pc.ontrack = this._onAddTrack.bind(this, this._pc), this._pc.onconnectionstatechange = M.debounce((e) => {
6045
6124
  this._pc && this._onConnectionStateChange(this._pc, e);
6046
- }, 500), this._pc.onsignalingstatechange = this._onSignalingStateChange.bind(this, this._pc), this._sdpStats.observe(this._pc), this._participantIdRegistry = new di(this._debug), this._signaling.setParticipantIdRegistry(this._participantIdRegistry), this._createDataChannel(this._pc, Tr.producerNotification, (e) => {
6125
+ }, 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) => {
6047
6126
  this._producerNotification = e, this._producerNotification.binaryType = "arraybuffer", this._signaling.setProducerNotificationDataChannel(e);
6048
6127
  }), this._signaling.useCommandDataChannel(!0), this._createDataChannel(this._pc, Tr.producerCommand, (e) => {
6049
6128
  this._producerCommand = e, this._signaling.setProducerCommandDataChannel(e);
6050
6129
  }), this._createDataChannel(this._pc, Tr.producerScreenShare, (e) => {
6051
6130
  this._producerScreen = e, this._producerScreen.binaryType = "arraybuffer", this._createCaptureReceiver();
6052
6131
  }), N.asrDataChannel && this._createDataChannel(this._pc, Tr.asr, (e) => {
6053
- this._asr = e, this._asr.binaryType = "arraybuffer", this._removeAsrTrack(), this._asrTrack = new ci(e, this._participantIdRegistry, (e) => {
6132
+ this._asr = e, this._asr.binaryType = "arraybuffer", this._removeAsrTrack(), this._asrTrack = new fi(e, this._participantIdRegistry, (e) => {
6054
6133
  this._onAsrTranscription(e);
6055
6134
  }, this._debug);
6056
6135
  }), N.vmoji && this._createDataChannel(this._pc, Tr.animoji, (e) => {
@@ -6071,8 +6150,8 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6071
6150
  _removeAsrTrack() {
6072
6151
  this._asrTrack?.destroy(), this._asrTrack = null;
6073
6152
  }
6074
- _reconnect() {
6075
- this.getState() !== q.OPENED && (this._setState(q.RECONNECTING), this._closeConnection(), this._openConnection(!0));
6153
+ _reconnect(e = !1) {
6154
+ this.getState() !== q.OPENED && (e && this._peerConnectionStats.logIceRestart(), this._setState(q.RECONNECTING), this._closeConnection(), this._openConnection(!0));
6076
6155
  }
6077
6156
  _signalActiveParticipants(e) {
6078
6157
  this._triggerEvent(Y.SIGNALLED_ACTIVE_PARTICIPANTS, e);
@@ -6088,19 +6167,19 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6088
6167
  }
6089
6168
  _updateSSRCMap(e) {
6090
6169
  e && (this._ssrcMap = {}, this._ssrcMapUpdated = !0, dn(e.sdp).forEach((e) => {
6091
- let t = `a=ssrc:([0-9]+) label:(audio|video)-((?:[ug]?[\\d]+)|(?:mix)|(?:${oi.PARTICIPANT_AGNOSTIC_TRACK_PREFIX}-[0-9]+)|(?:${oi.TRANSPARENT_AUDIO_TRACK_PREFIX}-[0-9]+))`, n = new RegExp(t).exec(e);
6170
+ 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);
6092
6171
  n && (this._ssrcMap[n[1]] = n[3]);
6093
6172
  }));
6094
6173
  }
6095
6174
  _createCaptureSender(e) {
6096
6175
  let t = this._mediaSource.mediaSettings;
6097
- !e || !this._consumerScreen || !t.isScreenSharingEnabled || (this._captureSender && this._removeCaptureSender(), this._captureSender = new va(e, this._consumerScreen, this._signaling, t.isFastScreenSharingEnabled, this._debug, this._logger));
6176
+ !e || !this._consumerScreen || !t.isScreenSharingEnabled || (this._captureSender && this._removeCaptureSender(), this._captureSender = new Sa(e, this._consumerScreen, this._signaling, t.isFastScreenSharingEnabled, this._debug, this._logger));
6098
6177
  }
6099
6178
  _removeCaptureSender() {
6100
6179
  this._captureSender?.destroy(), this._captureSender = null;
6101
6180
  }
6102
6181
  _createCaptureReceiver() {
6103
- this._producerScreen && (this._captureReceiver && this._removeCaptureReceiver(), this._captureReceiver = new Wi(this._producerScreen, this._participantIdRegistry, (e, t) => {
6182
+ this._producerScreen && (this._captureReceiver && this._removeCaptureReceiver(), this._captureReceiver = new Ji(this._producerScreen, this._participantIdRegistry, (e, t) => {
6104
6183
  this._triggerEvent(Y.REMOTE_STREAM_SECOND, e, t);
6105
6184
  }, (e) => {
6106
6185
  this._triggerEvent(Y.REMOTE_STREAM_SECOND, e, null);
@@ -6210,7 +6289,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6210
6289
  _detectStaleTracks(e) {
6211
6290
  let t = e.rtps.find((e) => e.type === "inbound-rtp" && e.kind === "audio" && this._ssrcMap[e.ssrc] === "mix");
6212
6291
  if (!t) return;
6213
- let n = oi.AUDIO_MIX, r = this._statBytes[n], i = !1;
6292
+ let n = ui.AUDIO_MIX, r = this._statBytes[n], i = !1;
6214
6293
  if (r) {
6215
6294
  let e = t.bytesReceived - r.bytesReceived;
6216
6295
  e >= 0 && e <= 5 && (i = !0), r.stalled !== i && this._triggerEvent(Y.AUDIO_MIX_STALL, i);
@@ -6222,7 +6301,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6222
6301
  }
6223
6302
  _allocateConsumer() {
6224
6303
  if (!this._signaling.ready) return;
6225
- let e = Na.get();
6304
+ let e = Ra.get();
6226
6305
  !N.videoTracksCount && !this._observer && this._debug.warn("Setting videoTracksCount to 0 is deprecated"), this._signaling.allocateConsumer(null, e).catch((e) => {
6227
6306
  e instanceof En || this._debug.warn("ServerTransport: Unable to allocate consumer", e);
6228
6307
  });
@@ -6355,7 +6434,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6355
6434
  _onConnectionStateChange(e, t) {
6356
6435
  switch (this._debug.debug("[single] connection state changed", { state: e.connectionState }, t), this._logger?.log(C.ICE_CONNECTION_STATE, e.connectionState), e.connectionState) {
6357
6436
  case "failed":
6358
- this._reconnectionPrevented ? this.close(/* @__PURE__ */ Error("Ice connection failed")) : this._reconnect();
6437
+ this._reconnectionPrevented ? this.close(/* @__PURE__ */ Error("Ice connection failed")) : this._reconnect(!0);
6359
6438
  break;
6360
6439
  case "connecting":
6361
6440
  let t = this.getState();
@@ -6398,11 +6477,11 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6398
6477
  if (!r || !r.length) return this._debug.log(`Cannot get stream waiting time, ${e} receiver has no synchronization sources`), 0;
6399
6478
  let i = r[0].rtpTimestamp;
6400
6479
  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;
6401
- let a = t - i & xa, o = Math.ceil(a / ba);
6480
+ let a = t - i & Ta, o = Math.ceil(a / wa);
6402
6481
  return Math.min(100, Math.max(0, o));
6403
6482
  }
6404
6483
  async _monitorRtpShare() {
6405
- let e = ui.getInstance().value;
6484
+ let e = mi.getInstance().value;
6406
6485
  if (!this._mediaSource.mediaSettings.isFastScreenSharingEnabled || !N.consumerFastScreenShare || e < .6) return;
6407
6486
  let t = this._pc?.getSenders().find((e) => e.track?.kind === A.video && e.track?.contentHint === "motion");
6408
6487
  t && (await t.getStats()).forEach((e) => {
@@ -6433,7 +6512,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6433
6512
  }
6434
6513
  }, Y = /* @__PURE__ */ function(e) {
6435
6514
  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;
6436
- }({}), Ca = class extends b {
6515
+ }({}), Da = class extends b {
6437
6516
  constructor(e, t, n, r, i = z, a = null, o = null, s = null, c = null) {
6438
6517
  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", () => {
6439
6518
  this._vadController?.setSendTrack(this._mediaSource.getSendAudioTrack());
@@ -6554,11 +6633,11 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6554
6633
  }
6555
6634
  }
6556
6635
  _createDirectTransport(e, t = !1) {
6557
- let n = new ai(e, t, this._signaling, this._mediaSource, this._serverSettings, this._debug, this._logger, this._statAggregator, this._codecStatsAggregator, this._getFirstMediaSentCallback());
6636
+ let n = new li(e, t, this._signaling, this._mediaSource, this._serverSettings, this._debug, this._logger, this._statAggregator, this._codecStatsAggregator, this._getFirstMediaSentCallback());
6558
6637
  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;
6559
6638
  }
6560
6639
  _createServerTransport() {
6561
- let e = new Sa(this._signaling, this._mediaSource, this._serverSettings, this._debug, this._logger, this._statAggregator, this._codecStatsAggregator, this._getFirstMediaSentCallback());
6640
+ let e = new Ea(this._signaling, this._mediaSource, this._serverSettings, this._debug, this._logger, this._statAggregator, this._codecStatsAggregator, this._getFirstMediaSentCallback());
6562
6641
  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;
6563
6642
  }
6564
6643
  _releaseDirectTransport() {
@@ -6650,20 +6729,20 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6650
6729
  getStreamWaitingTimeMs(e, t) {
6651
6730
  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);
6652
6731
  }
6653
- }, wa = "videochat-epi", Ta = 5e3, Ea = 500, Da = class extends b {
6732
+ }, Oa = "videochat-epi", ka = 5e3, Aa = 500, ja = 120 * 1e3, Ma = class extends b {
6654
6733
  constructor(e, t, n = null, r = !1, i = z) {
6655
- 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) => {
6734
+ 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) => {
6656
6735
  this._screenShareStats.push(e);
6657
6736
  }), h(this, "_handleTransportStateChanged", (e) => {
6658
6737
  (this._directTopology && e === q.CONNECTED || !this._directTopology && e === q.OPENED) && (this._previousNetworkStatReportTimestamp = Date.now(), this._previousCallStatReportTimestamp = Date.now(), this._previousRemoteInboundRtps.clear());
6659
6738
  }), 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));
6660
6739
  }
6661
6740
  destroy() {
6662
- this._previousRemoteInboundRtps.clear(), this.unsubscribe();
6741
+ this._previousRemoteInboundRtps.clear(), this._previousCandidatePair = null, this.unsubscribe();
6663
6742
  }
6664
6743
  static getEstimatedPerformanceIndex() {
6665
6744
  try {
6666
- let e = parseInt(localStorage.getItem(wa) || "", 10);
6745
+ let e = parseInt(localStorage.getItem(Oa) || "", 10);
6667
6746
  return isNaN(e) ? 0 : e;
6668
6747
  } catch {
6669
6748
  return 0;
@@ -6672,9 +6751,9 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6672
6751
  async _handleStats(e) {
6673
6752
  if (!e.inbound || !e.inbound.rtps) return;
6674
6753
  let t = Date.now();
6675
- !this._directTopology && N.perfStatReportEnabled && this._previousPerfStatReportTimestamp + Ta <= t && (await this.reportPerfStats(e), this._previousPerfStatReportTimestamp = t);
6754
+ !this._directTopology && N.perfStatReportEnabled && this._previousPerfStatReportTimestamp + ka <= t && (await this.reportPerfStats(e), this._previousPerfStatReportTimestamp = t);
6676
6755
  let n = e.outbound.transport.local?.protocol === "tcp";
6677
- !this._directTopology && n && this._previousNetworkStatReportTimestamp + Ea <= t && (await this.reportNetworkStats(e), this._previousNetworkStatReportTimestamp = t), N.callStatReportEnabled && this._previousCallStatReportTimestamp + N.statisticsInterval <= t && (this._reportCallStats(e), this._previousCallStatReportTimestamp = t);
6756
+ !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);
6678
6757
  }
6679
6758
  async reportPerfStats(e) {
6680
6759
  let t = e.inbound.rtps.reduce((e, t) => (t.kind === "video" && (e.framesDecoded += t.framesDecoded || 0, e.framesReceived += t.framesReceived || 0), e), {
@@ -6683,7 +6762,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6683
6762
  });
6684
6763
  if (t.framesDecoded) try {
6685
6764
  let e = await this._signaling.reportPerfStat(t);
6686
- localStorage.setItem(wa, e.estimatedPerformanceIndex);
6765
+ localStorage.setItem(Oa, e.estimatedPerformanceIndex);
6687
6766
  } catch {}
6688
6767
  }
6689
6768
  async reportNetworkStats(e) {
@@ -6723,11 +6802,11 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6723
6802
  rtt: Math.round(e.inbound.transport.currentRoundTripTime * 1e3),
6724
6803
  ss_freeze_count: 0,
6725
6804
  ss_total_freezes_duration: 0,
6726
- local_address: ka(e.inbound.transport.local),
6805
+ local_address: Pa(e.inbound.transport.local),
6727
6806
  local_connection_type: e.inbound.transport.local?.type,
6728
6807
  network_type: e.inbound.transport.local?.networkType,
6729
6808
  transport: e.inbound.transport.local?.protocol,
6730
- remote_address: ka(e.inbound.transport.remote),
6809
+ remote_address: Pa(e.inbound.transport.remote),
6731
6810
  remote_connection_type: e.inbound.transport.remote?.type
6732
6811
  };
6733
6812
  this._previousCallStatReport || (this._previousCallStatReport = Object.assign({}, t));
@@ -6738,7 +6817,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6738
6817
  }
6739
6818
  let i = {
6740
6819
  call_topology: t.call_topology,
6741
- stat_time_delta: Math.max(0, Date.now() - this._previousCallStatReportTimestamp),
6820
+ stat_time_delta: Math.min(ja, Math.max(0, Date.now() - this._previousCallStatReportTimestamp)),
6742
6821
  nack_sent: Math.max(0, t.nack_sent - this._previousCallStatReport.nack_sent),
6743
6822
  nack_received: Math.max(0, t.nack_received - this._previousCallStatReport.nack_received),
6744
6823
  pli_sent: Math.max(0, t.pli_sent - this._previousCallStatReport.pli_sent),
@@ -6748,14 +6827,28 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6748
6827
  frames_dropped: Math.max(0, t.frames_dropped - this._previousCallStatReport.frames_dropped),
6749
6828
  rtt: Math.max(0, t.rtt)
6750
6829
  };
6751
- if (N.simulcast && (i.is_simulcast = !0), navigator.hardwareConcurrency && (i.cpu_hardware_concurrency = navigator.hardwareConcurrency), n && !Aa(t.jitter_video) && (i.jitter_video = Math.round(t.jitter_video)), r && !Aa(t.jitter_audio) && (i.jitter_audio = Math.round(t.jitter_audio)), n && !Aa(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 && !Aa(t.total_audio_samples_received)) {
6830
+ 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)) {
6752
6831
  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);
6753
- i.inserted_audio_samples_for_deceleration = ja(n / e * 1e3), i.removed_audio_samples_for_acceleration = ja(r / e * 1e3), i.concealed_audio_samples = ja(a / e * 1e3), i.concealed_silent_audio_samples = ja(o / e * 1e3), i.concealment_audio_avg_size = ja(a / s), i.total_audio_energy = t.total_audio_energy;
6832
+ 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;
6754
6833
  }
6755
- Oa(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), Oa(t, "remote_address", "remote_connection_type") && (i.remote_address = t.remote_address, i.remote_connection_type = t.remote_connection_type);
6834
+ 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);
6756
6835
  let a = this._calculatePacketLoss(e.remoteInbound.rtps);
6757
6836
  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;
6758
6837
  }
6838
+ _reportCandidatePair(e, t) {
6839
+ if (!e?.address || !t?.address) return;
6840
+ let n = JSON.stringify({
6841
+ local: e,
6842
+ remote: t
6843
+ });
6844
+ n !== this._previousCandidatePair && (this._previousCandidatePair = n, this._statAggregator?.logEventualStat({
6845
+ name: U.ICE_CANDIDATES_CHANGED,
6846
+ string_value: n,
6847
+ local_address: Pa(e),
6848
+ remote_address: Pa(t),
6849
+ transport: e.protocol
6850
+ }));
6851
+ }
6759
6852
  _calculatePacketLoss(e) {
6760
6853
  let t = /* @__PURE__ */ new Map(), n = {
6761
6854
  audio: {
@@ -6784,26 +6877,26 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6784
6877
  return r;
6785
6878
  }
6786
6879
  };
6787
- function Oa(e, ...t) {
6880
+ function Na(e, ...t) {
6788
6881
  for (let n of t) if (!Object.hasOwn(e, n) || e[n] === void 0) return !1;
6789
6882
  return !0;
6790
6883
  }
6791
- function ka(e, t = !1) {
6884
+ function Pa(e, t = !1) {
6792
6885
  if (e?.address) return e.address + (t ? `:${e.port}` : "");
6793
6886
  }
6794
- function Aa(e) {
6887
+ function Fa(e) {
6795
6888
  return e === void 0;
6796
6889
  }
6797
- function ja(e) {
6890
+ function Ia(e) {
6798
6891
  return Number.isNaN(e) ? 0 : e;
6799
6892
  }
6800
6893
  //#endregion
6801
6894
  //#region src/static/Capabilities.ts
6802
- var Ma;
6895
+ var La;
6803
6896
  (function(e) {
6804
6897
  function t() {
6805
6898
  return {
6806
- estimatedPerformanceIndex: Da.getEstimatedPerformanceIndex(),
6899
+ estimatedPerformanceIndex: Ma.getEstimatedPerformanceIndex(),
6807
6900
  audioMix: !0,
6808
6901
  consumerUpdate: !0,
6809
6902
  producerNotificationDataChannelVersion: 8,
@@ -6829,8 +6922,8 @@ var Ma;
6829
6922
  };
6830
6923
  }
6831
6924
  e.get = t;
6832
- })(Ma || (Ma = {}));
6833
- var Na = Ma, Pa = {
6925
+ })(La || (La = {}));
6926
+ var Ra = La, za = {
6834
6927
  producerScreenTrack: () => !0,
6835
6928
  videoTracksCount: () => N.videoTracksCount > 0,
6836
6929
  waitingHall: () => !0,
@@ -6850,28 +6943,28 @@ var Na = Ma, Pa = {
6850
6943
  p2pRelay: () => !1,
6851
6944
  waitForAdmin: () => N.waitForAdminInGroupCalls,
6852
6945
  hold: () => N.hold
6853
- }, Fa = class {
6946
+ }, Ba = class {
6854
6947
  static getFlags() {
6855
- let e = Object.values(Pa), t = 0;
6948
+ let e = Object.values(za), t = 0;
6856
6949
  for (let n = 0; n < e.length; n++) e[n]() && (t |= 1 << n);
6857
6950
  return t.toString(16).toUpperCase();
6858
6951
  }
6859
6952
  static parseCapabilities(e) {
6860
6953
  let t = parseInt(e || "0", 16);
6861
- return Object.keys(Pa).reduce((e, n, r) => (e[n] = !!(t & 1 << r), e), {});
6954
+ return Object.keys(za).reduce((e, n, r) => (e[n] = !!(t & 1 << r), e), {});
6862
6955
  }
6863
- }, Ia = 63n, La = 16383n, Ra = 1073741823, za = 4611686018427387903n, Ba = class {
6956
+ }, Va = 63n, Ha = 16383n, Ua = 1073741823, Wa = 4611686018427387903n, Ga = class {
6864
6957
  encode(e) {
6865
6958
  let t = typeof e == "number" ? BigInt(e) : e;
6866
- if (t <= Ia) return new Uint8Array([Number(t)]);
6867
- if (t <= La) return new Uint8Array([64 | Number(t >> 8n), Number(t & 255n)]);
6868
- if (t <= BigInt(Ra)) return new Uint8Array([
6959
+ if (t <= Va) return new Uint8Array([Number(t)]);
6960
+ if (t <= Ha) return new Uint8Array([64 | Number(t >> 8n), Number(t & 255n)]);
6961
+ if (t <= BigInt(Ua)) return new Uint8Array([
6869
6962
  128 | Number(t >> 24n),
6870
6963
  Number(t >> 16n & 255n),
6871
6964
  Number(t >> 8n & 255n),
6872
6965
  Number(t & 255n)
6873
6966
  ]);
6874
- if (t <= za) return new Uint8Array([
6967
+ if (t <= Wa) return new Uint8Array([
6875
6968
  192 | Number(t >> 56n),
6876
6969
  Number(t >> 48n & 255n),
6877
6970
  Number(t >> 40n & 255n),
@@ -6883,7 +6976,7 @@ var Na = Ma, Pa = {
6883
6976
  ]);
6884
6977
  throw RangeError("Number is too large to encode using varint");
6885
6978
  }
6886
- }, Va = class {
6979
+ }, Ka = class {
6887
6980
  decode(e) {
6888
6981
  let t = this.getNumBytesForLengthInteger(e);
6889
6982
  if (t < 0) throw Error("Invalid length prefix");
@@ -6909,9 +7002,9 @@ var Na = Ma, Pa = {
6909
7002
  let t = e[0] & 192;
6910
7003
  return t === 0 ? 1 : t === 64 ? 2 : t === 128 ? 4 : t === 192 ? 8 : -1;
6911
7004
  }
6912
- }, Ha = class {
7005
+ }, qa = class {
6913
7006
  constructor(e) {
6914
- h(this, "encoder", void 0), h(this, "compression", void 0), h(this, "lengthEncoder", void 0), this.encoder = new TextEncoder(), this.lengthEncoder = new Ba(), this.compression = e ?? null;
7007
+ 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;
6915
7008
  }
6916
7009
  encode(e) {
6917
7010
  let t = this.encoder.encode(e);
@@ -6928,9 +7021,9 @@ var Na = Ma, Pa = {
6928
7021
  default: return e;
6929
7022
  }
6930
7023
  }
6931
- }, Ua = class {
7024
+ }, Ja = class {
6932
7025
  constructor(e) {
6933
- 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 Va(), this.compression = e ?? null, this.buffer = new Uint8Array(), this.expectedLength = null, this.offset = 0;
7026
+ 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;
6934
7027
  }
6935
7028
  decode(e) {
6936
7029
  let t = [];
@@ -6960,12 +7053,12 @@ var Na = Ma, Pa = {
6960
7053
  default: return e;
6961
7054
  }
6962
7055
  }
6963
- }, Wa = class {
7056
+ }, Ya = class {
6964
7057
  static isBrowserSupported() {
6965
7058
  return !(!("WebTransport" in window && typeof WebTransport == "function") || E.browserName() === "Safari");
6966
7059
  }
6967
7060
  constructor(e, t = {}, n = z) {
6968
- 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 Ha(this.compression), this.decoder = new Ua(this.compression), this.connect();
7061
+ 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();
6969
7062
  }
6970
7063
  async send(e) {
6971
7064
  if (this.readyState !== WebSocket.OPEN) {
@@ -7091,11 +7184,11 @@ var Na = Ma, Pa = {
7091
7184
  compression: this.compression
7092
7185
  }, n;
7093
7186
  }
7094
- }, Ga = /* @__PURE__ */ function(e) {
7095
- return e.EMPTY_ENDPOINT = "EMPTY_ENDPOINT", e.NETWORK_ERROR = "NETWORK_ERROR", e.ABORTED = "ABORTED", e;
7096
- }({}), Ka = class {
7187
+ }, Xa = /* @__PURE__ */ function(e) {
7188
+ return e.EMPTY_ENDPOINT = "EMPTY_ENDPOINT", e.NETWORK_ERROR = "NETWORK_ERROR", e.RECONNECT_TIMEOUT = "RECONNECT_TIMEOUT", e.ABORTED = "ABORTED", e;
7189
+ }({}), Za = class {
7097
7190
  constructor(e = z, t) {
7098
- 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;
7191
+ 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;
7099
7192
  }
7100
7193
  get readyState() {
7101
7194
  return this.socket?.readyState ?? null;
@@ -7118,14 +7211,14 @@ var Na = Ma, Pa = {
7118
7211
  setAbortSignal(e) {
7119
7212
  this.abortSignal = e;
7120
7213
  }
7121
- resetReconnectCount() {
7122
- this.reconnectCount = 0;
7214
+ onConnectionRestored() {
7215
+ this.reconnectCount = 0, this._stopReconnectDeadline();
7123
7216
  }
7124
7217
  connect(e) {
7125
7218
  this.socket && this.socket.readyState < WebSocket.CLOSING || (e !== br.RETRY && (this.forceWebSocket = !1, this.reconnectCount = 0), this.manualClose = !1, this.connectionType = e, this._connect());
7126
7219
  }
7127
7220
  close(e) {
7128
- this.manualClose = !0, this._disconnect(e), window.clearTimeout(this.reconnectTimer), this.reconnectTimer = 0, this.lastStamp = 0;
7221
+ this.manualClose = !0, this._disconnect(e), window.clearTimeout(this.reconnectTimer), this.reconnectTimer = 0, this._stopReconnectDeadline(), this.lastStamp = 0;
7129
7222
  }
7130
7223
  async send(e) {
7131
7224
  await this.socket?.send(e);
@@ -7143,7 +7236,7 @@ var Na = Ma, Pa = {
7143
7236
  return;
7144
7237
  }
7145
7238
  let e = this._buildUrl(this.wtEndpoint, !0);
7146
- this.currentType = Sr.WEBTRANSPORT, this.socket = new Wa(e, { congestionControl: "low-latency" }, this._debug), this._setSocketHandlers();
7239
+ this.currentType = Sr.WEBTRANSPORT, this.socket = new Ya(e, { congestionControl: "low-latency" }, this._debug), this._setSocketHandlers();
7147
7240
  }
7148
7241
  _connectWebSocket() {
7149
7242
  if (!this.endpoint) {
@@ -7166,10 +7259,10 @@ var Na = Ma, Pa = {
7166
7259
  }
7167
7260
  _buildUrl(e, t) {
7168
7261
  let n = new URL(e), r = n.searchParams;
7169
- 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", Fa.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();
7262
+ 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();
7170
7263
  }
7171
7264
  _canUseWebTransport() {
7172
- return !this.forceWebSocket && Wa.isBrowserSupported() && this.wtEndpoint !== null && N.webtransport;
7265
+ return !this.forceWebSocket && Ya.isBrowserSupported() && this.wtEndpoint !== null && N.webtransport;
7173
7266
  }
7174
7267
  _onOpen() {
7175
7268
  this._startDoctor(), this.handlers.onOpen();
@@ -7198,20 +7291,32 @@ var Na = Ma, Pa = {
7198
7291
  }
7199
7292
  _scheduleReconnect(e = this._getReconnectDelay()) {
7200
7293
  if (this.reconnectCount >= N.signalingReconnectMaxCount) {
7201
- this.handlers.onFailed({
7294
+ this._stopReconnectDeadline(), this.handlers.onFailed({
7202
7295
  failure: "NETWORK_ERROR",
7203
7296
  message: "Unable to connect to the signaling: reconnect attempts exhausted",
7204
7297
  source: this.currentType
7205
7298
  });
7206
7299
  return;
7207
7300
  }
7208
- this.reconnectCount++, this.handlers.onReconnectScheduled({
7301
+ this._startReconnectDeadline(), this.reconnectCount++, this.handlers.onReconnectScheduled({
7209
7302
  count: this.reconnectCount,
7210
7303
  delay: e
7211
7304
  }), this.reconnectTimer = window.setTimeout(() => {
7212
7305
  this.connectionType = br.RETRY, this._connect();
7213
7306
  }, e);
7214
7307
  }
7308
+ _startReconnectDeadline() {
7309
+ this.reconnectDeadlineTimer || (this.reconnectDeadlineTimer = window.setTimeout(() => {
7310
+ this.reconnectDeadlineTimer = 0, window.clearTimeout(this.reconnectTimer), this.reconnectTimer = 0, this._disconnect(4e3), this.handlers.onFailed({
7311
+ failure: "RECONNECT_TIMEOUT",
7312
+ message: "Unable to connect to the signaling: reconnect timeout",
7313
+ source: this.currentType
7314
+ });
7315
+ }, N.signalingReconnectMaxDuration));
7316
+ }
7317
+ _stopReconnectDeadline() {
7318
+ window.clearTimeout(this.reconnectDeadlineTimer), this.reconnectDeadlineTimer = 0;
7319
+ }
7215
7320
  _getReconnectDelay() {
7216
7321
  return Math.min(N.signalingReconnectMaxDelay, N.signalingReconnectDelay * 2 ** this.reconnectCount);
7217
7322
  }
@@ -7223,31 +7328,31 @@ var Na = Ma, Pa = {
7223
7328
  _stopDoctor() {
7224
7329
  window.clearTimeout(this.doctorTimer), this.doctorTimer = 0;
7225
7330
  }
7226
- }, qa = "open", Ja = 300, Ya = 10, Xa = {
7331
+ }, Qa = "open", $a = 300, eo = 10, to = {
7227
7332
  CONVERSATION_ENDED: "conversation-ended",
7228
7333
  OBSOLETE_CLIENT: "gen.obsoleteClient",
7229
7334
  INVALID_TOKEN: "invalid-token",
7230
7335
  PARTICIPANT_NOT_FOUND: "participant-not-found",
7231
7336
  ILLEGAL_PARTICIPANT_STATE: "illegal-participant-state",
7232
7337
  SERVICE_UNAVAILABLE: "service-unavailable"
7233
- }, Za = {
7234
- [Xa.CONVERSATION_ENDED]: "conversation-ended",
7235
- [Xa.OBSOLETE_CLIENT]: "obsolete-client",
7236
- [Xa.INVALID_TOKEN]: "invalid-token",
7237
- [Xa.PARTICIPANT_NOT_FOUND]: "participant-not-found",
7238
- [Xa.ILLEGAL_PARTICIPANT_STATE]: "illegal-participant-state",
7239
- [Xa.SERVICE_UNAVAILABLE]: "service-unavailable"
7338
+ }, no = {
7339
+ [to.CONVERSATION_ENDED]: "conversation-ended",
7340
+ [to.OBSOLETE_CLIENT]: "obsolete-client",
7341
+ [to.INVALID_TOKEN]: "invalid-token",
7342
+ [to.PARTICIPANT_NOT_FOUND]: "participant-not-found",
7343
+ [to.ILLEGAL_PARTICIPANT_STATE]: "illegal-participant-state",
7344
+ [to.SERVICE_UNAVAILABLE]: "service-unavailable"
7240
7345
  };
7241
- function Qa(e, t) {
7346
+ function ro(e, t) {
7242
7347
  return e.errorMessage ?? e.message ?? e.error ?? t;
7243
7348
  }
7244
- var $a = new Set([
7349
+ var io = new Set([
7245
7350
  O.CALLER_IS_BLOCKED,
7246
7351
  O.ENDED,
7247
7352
  O.NOT_FOUND,
7248
7353
  O.PARTICIPANT_LIMIT_REACHED,
7249
7354
  O.SERVICE_UNAVAILABLE
7250
- ]), eo = class e extends On {
7355
+ ]), ao = class e extends On {
7251
7356
  static get WAIT_CONNECTION_DELAY() {
7252
7357
  return N.waitConnectionDelay;
7253
7358
  }
@@ -7258,7 +7363,7 @@ var $a = new Set([
7258
7363
  return !this.disposed && this.transport.readyState !== null;
7259
7364
  }
7260
7365
  constructor(e = z, t = null, n = null, r = null, i = null) {
7261
- 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 Ka(e, {
7366
+ 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, {
7262
7367
  onConnecting: this._onTransportConnecting.bind(this),
7263
7368
  onOpen: this._onOpen.bind(this),
7264
7369
  onMessage: this._onMessage.bind(this),
@@ -7345,20 +7450,20 @@ var $a = new Set([
7345
7450
  return this._send(V.TRANSMIT_DATA, {
7346
7451
  participantId: e,
7347
7452
  data: r
7348
- }, !0, Ya);
7453
+ }, !0, eo);
7349
7454
  }
7350
7455
  async acceptCall(e) {
7351
7456
  return this._send(V.ACCEPT_CALL, { mediaSettings: e });
7352
7457
  }
7353
7458
  async changeMediaSettings(e) {
7354
- return this._send(V.CHANGE_MEDIA_SETTINGS, { mediaSettings: e }, !0, Ya);
7459
+ return this._send(V.CHANGE_MEDIA_SETTINGS, { mediaSettings: e }, !0, eo);
7355
7460
  }
7356
7461
  async changeParticipantState(e, t) {
7357
7462
  let n = { participantState: { state: e } };
7358
7463
  return t && (n.participantId = t), this._sendRaw(V.CHANGE_PARTICIPANT_STATE, n);
7359
7464
  }
7360
7465
  async hold(e) {
7361
- let t = Na.get();
7466
+ let t = Ra.get();
7362
7467
  return this._send(V.HOLD, {
7363
7468
  hold: e,
7364
7469
  capabilities: e ? void 0 : t
@@ -7590,7 +7695,7 @@ var $a = new Set([
7590
7695
  if (this.disposed) throw new En(e);
7591
7696
  switch (t.route) {
7592
7697
  case "producer":
7593
- this.datachannelCommandsQueue.push(t), this.producerCommandDataChannel?.readyState === qa && this._handleCommandsQueue(this.datachannelCommandsQueue);
7698
+ this.datachannelCommandsQueue.push(t), this.producerCommandDataChannel?.readyState === Qa && this._handleCommandsQueue(this.datachannelCommandsQueue);
7594
7699
  break;
7595
7700
  case "websocket":
7596
7701
  if (this.transport.readyState === null) {
@@ -7640,7 +7745,7 @@ var $a = new Set([
7640
7745
  _handleMessage(e) {
7641
7746
  switch (e.type) {
7642
7747
  case "notification":
7643
- 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, {
7748
+ 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, {
7644
7749
  type: "notification",
7645
7750
  notification: K.TOPOLOGY_CHANGED,
7646
7751
  topology: e.conversation.topology
@@ -7660,9 +7765,9 @@ var $a = new Set([
7660
7765
  }
7661
7766
  _handleErrorMessage(e) {
7662
7767
  this._logger?.log(C.SOCKET_ACTION, `error-${e.error}`);
7663
- let t = this._getSocketType(), n = e.error ? this._createSignalingCallError(e.error, e.errorCode, t) : void 0, r = Qa(e, "Unknown signaling error");
7768
+ let t = this._getSocketType(), n = e.error ? this._createSignalingCallError(e.error, e.errorCode, t) : void 0, r = ro(e, "Unknown signaling error");
7664
7769
  switch (this._debug.debug(`[signaling] error message [${e.sequence}]`, e), e.sequence && this.responseHandlers[e.sequence] && this._handleCommandResponse(!1, e), e.error) {
7665
- case Xa.SERVICE_UNAVAILABLE:
7770
+ case to.SERVICE_UNAVAILABLE:
7666
7771
  let i = new k(O.SERVICE_UNAVAILABLE, {
7667
7772
  callError: n,
7668
7773
  message: r,
@@ -7674,7 +7779,7 @@ var $a = new Set([
7674
7779
  reason: O.SERVICE_UNAVAILABLE
7675
7780
  });
7676
7781
  break;
7677
- case Xa.CONVERSATION_ENDED:
7782
+ case to.CONVERSATION_ENDED:
7678
7783
  this.conversationReject ? this.conversationReject(new k(e.reason || x.SIGNALING_FAILED, {
7679
7784
  callError: n,
7680
7785
  message: r,
@@ -7685,22 +7790,22 @@ var $a = new Set([
7685
7790
  reason: e.reason
7686
7791
  });
7687
7792
  break;
7688
- case Xa.ILLEGAL_PARTICIPANT_STATE:
7689
- case Xa.PARTICIPANT_NOT_FOUND:
7793
+ case to.ILLEGAL_PARTICIPANT_STATE:
7794
+ case to.PARTICIPANT_NOT_FOUND:
7690
7795
  this._throwError(new k(x.SIGNALING_FAILED, {
7691
7796
  callError: n,
7692
7797
  message: r,
7693
7798
  remote: !0
7694
7799
  }));
7695
7800
  break;
7696
- case Xa.OBSOLETE_CLIENT:
7801
+ case to.OBSOLETE_CLIENT:
7697
7802
  this.conversationReject?.(new k(e.reason || O.OBSOLETE_CLIENT, {
7698
7803
  callError: n,
7699
7804
  message: r,
7700
7805
  remote: !0
7701
7806
  }));
7702
7807
  break;
7703
- case Xa.INVALID_TOKEN:
7808
+ case to.INVALID_TOKEN:
7704
7809
  default:
7705
7810
  if (e.sequence || t === Sr.WEBTRANSPORT) break;
7706
7811
  if (this.connected) this._throwError(new k(e.reason || x.SIGNALING_FAILED, {
@@ -7739,7 +7844,7 @@ var $a = new Set([
7739
7844
  }
7740
7845
  _describeErrorEvent(e) {
7741
7846
  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;
7742
- return (i ? `${i}: ${r}` : r).slice(0, Ja);
7847
+ return (i ? `${i}: ${r}` : r).slice(0, $a);
7743
7848
  }
7744
7849
  _onClose(e) {
7745
7850
  this._logger?.log(C.SOCKET_ACTION, "closed"), this._debug.debug("[signaling] connection closed", {
@@ -7794,13 +7899,13 @@ var $a = new Set([
7794
7899
  let r = this.responseHandlers[n.sequence];
7795
7900
  window.clearTimeout(r.responseTimer);
7796
7901
  let i = G.measureMark(r.statMarkName);
7797
- 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(Qa(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(Qa(n, `Response timeout [${r.name}]`)))) : r.responseTimer = window.setTimeout(() => this._handleCommandResponse(t, n), e.WAIT_RESPONSE_DELAY);
7902
+ 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);
7798
7903
  }
7799
7904
  _handleCommandsQueue(e) {
7800
7905
  for (; e.length > 0;) {
7801
7906
  let t = e.shift();
7802
7907
  if (this._debug.debug(`[signaling] command send [${t.sequence}]`, `'${t.name}'`, t.params), t.route === "producer") {
7803
- if (this.producerCommandDataChannel?.readyState !== qa) {
7908
+ if (this.producerCommandDataChannel?.readyState !== Qa) {
7804
7909
  t.reject(/* @__PURE__ */ Error(`Invalid data channel state: ${this.producerCommandDataChannel?.readyState}`));
7805
7910
  return;
7806
7911
  }
@@ -7885,7 +7990,7 @@ var $a = new Set([
7885
7990
  }
7886
7991
  _onTransportFailed(e) {
7887
7992
  switch (e.failure) {
7888
- case Ga.EMPTY_ENDPOINT:
7993
+ case Xa.EMPTY_ENDPOINT:
7889
7994
  this.conversationReject?.(new k(x.SIGNALING_FAILED, {
7890
7995
  callError: {
7891
7996
  scope: "internal",
@@ -7896,7 +8001,7 @@ var $a = new Set([
7896
8001
  remote: e.remote
7897
8002
  }));
7898
8003
  break;
7899
- case Ga.NETWORK_ERROR:
8004
+ case Xa.NETWORK_ERROR:
7900
8005
  this._logReconnectTimeout(), this._fail(new k(O.NETWORK_ERROR, { callError: {
7901
8006
  scope: "network",
7902
8007
  source: e.source,
@@ -7904,7 +8009,15 @@ var $a = new Set([
7904
8009
  description: "connection-failed"
7905
8010
  } }));
7906
8011
  break;
7907
- case Ga.ABORTED:
8012
+ case Xa.RECONNECT_TIMEOUT:
8013
+ this._logReconnectTimeout(), this._fail(new k(O.NETWORK_ERROR, { callError: {
8014
+ scope: "network",
8015
+ source: e.source,
8016
+ code: "reconnect-timeout",
8017
+ description: "connection-failed"
8018
+ } }));
8019
+ break;
8020
+ case Xa.ABORTED:
7908
8021
  this._debug.debug("[signaling] aborted reconnect"), this._fail(new k(O.CANCELED));
7909
8022
  break;
7910
8023
  }
@@ -7919,7 +8032,7 @@ var $a = new Set([
7919
8032
  this._debug.warn("[signaling] socket is dead, trying to reconnect"), this._logTransportStatSinceMark(Cr.FAILED_PINGS);
7920
8033
  }
7921
8034
  _attachNotificationCallError(e) {
7922
- e.callError || !e.reason || e.reason === O.FAILED || e.reason === O.UNKNOWN_ERROR || !$a.has(e.reason) && !e.errorCode || (e.callError = {
8035
+ e.callError || !e.reason || e.reason === O.FAILED || e.reason === O.UNKNOWN_ERROR || !io.has(e.reason) && !e.errorCode || (e.callError = {
7923
8036
  scope: "server",
7924
8037
  source: this._getSocketType(),
7925
8038
  code: e.errorCode || "protocol",
@@ -7927,7 +8040,7 @@ var $a = new Set([
7927
8040
  });
7928
8041
  }
7929
8042
  _createSignalingCallError(e, t, n) {
7930
- let r = Za[e];
8043
+ let r = no[e];
7931
8044
  if (r) return {
7932
8045
  scope: "server",
7933
8046
  source: n,
@@ -7953,39 +8066,39 @@ var $a = new Set([
7953
8066
  let t = this._getSocketType(), n = wr[e][t];
7954
8067
  this._statAggregator?.logEventualStatSinceMark({ name: n });
7955
8068
  }
7956
- }, to = /* @__PURE__ */ function(e) {
8069
+ }, oo = /* @__PURE__ */ function(e) {
7957
8070
  return e.INCOMING = "INCOMING", e.OUTGOING = "OUTGOING", e.JOINING = "JOINING", e;
7958
- }(to || {}), no = /* @__PURE__ */ function(e) {
8071
+ }(oo || {}), so = /* @__PURE__ */ function(e) {
7959
8072
  return e.USER = "USER", e.GROUP = "GROUP", e.CHAT = "CHAT", e;
7960
- }(no || {}), ro = /* @__PURE__ */ function(e) {
8073
+ }(so || {}), co = /* @__PURE__ */ function(e) {
7961
8074
  return e.ATTENDEE = "ATTENDEE", e.HAND_UP = "HAND_UP", e;
7962
- }(ro || {}), io = /* @__PURE__ */ function(e) {
8075
+ }(co || {}), lo = /* @__PURE__ */ function(e) {
7963
8076
  return e.ADD_PARTICIPANT = "ADD_PARTICIPANT", e.RECORD = "RECORD", e.MOVIE_SHARE = "MOVIE_SHARE", e;
7964
- }(io || {}), ao = /* @__PURE__ */ function(e) {
8077
+ }(lo || {}), uo = /* @__PURE__ */ function(e) {
7965
8078
  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;
7966
- }(ao || {});
7967
- function oo(e, t) {
8079
+ }(uo || {});
8080
+ function fo(e, t) {
7968
8081
  if (e.length !== t.length) return !1;
7969
8082
  for (let n of e) if (!t.includes(n)) return !1;
7970
8083
  return !0;
7971
8084
  }
7972
- function so(e, t) {
8085
+ function po(e, t) {
7973
8086
  let n = new Set(e);
7974
8087
  for (let [e, r] of Object.entries(t)) r ? n.add(e) : n.delete(e);
7975
8088
  return Array.from(n);
7976
8089
  }
7977
8090
  //#endregion
7978
8091
  //#region src/enums/MuteState.ts
7979
- var co = /* @__PURE__ */ function(e) {
8092
+ var mo = /* @__PURE__ */ function(e) {
7980
8093
  return e.UNMUTE = "UNMUTE", e.MUTE = "MUTE", e.MUTE_PERMANENT = "MUTE_PERMANENT", e;
7981
- }(co || {}), X = /* @__PURE__ */ function(e) {
8094
+ }(mo || {}), X = /* @__PURE__ */ function(e) {
7982
8095
  return e.CALLED = "CALLED", e.ACCEPTED = "ACCEPTED", e.REJECTED = "REJECTED", e.HUNGUP = "HUNGUP", e;
7983
- }(X || {}), lo = /* @__PURE__ */ function(e) {
8096
+ }(X || {}), ho = /* @__PURE__ */ function(e) {
7984
8097
  return e.UPDATE = "UPDATE", e.REMOVE = "REMOVE", e.ACTIVATE = "ACTIVATE", e.TIMEOUT = "TIMEOUT", e;
7985
- }(lo || {}), uo = /* @__PURE__ */ function(e) {
8098
+ }(ho || {}), go = /* @__PURE__ */ function(e) {
7986
8099
  return e.NO_AVAILABLE_TRACKS = "no-available-tracks", e.UNKNOWN_ERROR = "unknown-error", e;
7987
- }(uo || {});
7988
- function fo(e) {
8100
+ }(go || {});
8101
+ function _o(e) {
7989
8102
  switch (e) {
7990
8103
  case 1: return "no-available-tracks";
7991
8104
  default: return "unknown-error";
@@ -7993,17 +8106,17 @@ function fo(e) {
7993
8106
  }
7994
8107
  //#endregion
7995
8108
  //#region src/enums/UserRole.ts
7996
- var po = /* @__PURE__ */ function(e) {
8109
+ var vo = /* @__PURE__ */ function(e) {
7997
8110
  return e.CREATOR = "CREATOR", e.ADMIN = "ADMIN", e;
7998
- }(po || {});
7999
- function mo(e, t) {
8111
+ }(vo || {});
8112
+ function yo(e, t) {
8000
8113
  if (e.length !== t.length) return !1;
8001
8114
  for (let n of e) if (!t.includes(n)) return !1;
8002
8115
  return !0;
8003
8116
  }
8004
8117
  //#endregion
8005
8118
  //#region src/static/ParticipantConnectionStatusUtils.ts
8006
- var ho;
8119
+ var bo;
8007
8120
  (function(e) {
8008
8121
  function t(e) {
8009
8122
  let t = e?.transport ?? e?.lastEffective ?? P.WAITING, n = {
@@ -8055,8 +8168,8 @@ var ho;
8055
8168
  shouldNotify: !0
8056
8169
  });
8057
8170
  }
8058
- })(ho || (ho = {}));
8059
- var go = ho, _o = /* @__PURE__ */ function(e) {
8171
+ })(bo || (bo = {}));
8172
+ var xo = bo, So = /* @__PURE__ */ function(e) {
8060
8173
  return e.USER = "USER", e.ANONYM = "ANONYM", e.GROUP = "GROUP", e;
8061
8174
  }({}), Z;
8062
8175
  (function(e) {
@@ -8119,7 +8232,7 @@ var go = ho, _o = /* @__PURE__ */ function(e) {
8119
8232
  })(Z || (Z = {}));
8120
8233
  //#endregion
8121
8234
  //#region src/types/WaitingHall.ts
8122
- function vo(e) {
8235
+ function Co(e) {
8123
8236
  try {
8124
8237
  return btoa(JSON.stringify(e));
8125
8238
  } catch (t) {
@@ -8127,7 +8240,7 @@ function vo(e) {
8127
8240
  }
8128
8241
  return null;
8129
8242
  }
8130
- function yo(e) {
8243
+ function wo(e) {
8131
8244
  try {
8132
8245
  return JSON.parse(atob(e));
8133
8246
  } catch (t) {
@@ -8137,12 +8250,12 @@ function yo(e) {
8137
8250
  }
8138
8251
  //#endregion
8139
8252
  //#region src/utils/Conversation.ts
8140
- var bo = (e, t) => M.objectReduce(e, (e, n, r) => (n === t && e.push(r), e), []);
8141
- function xo(e) {
8253
+ var To = (e, t) => M.objectReduce(e, (e, n, r) => (n === t && e.push(r), e), []);
8254
+ function Eo(e) {
8142
8255
  if (e.conversation?.muteStates) return e.conversation.muteStates;
8143
8256
  if (e.muteState && e.muteOptions) return e.muteOptions.reduce((t, n) => (t[n] = e.muteState, t), {});
8144
8257
  }
8145
- function So(e, t) {
8258
+ function Do(e, t) {
8146
8259
  switch (e) {
8147
8260
  case S.AUDIO: return !!t.isAudioEnabled;
8148
8261
  case S.AUDIO_SHARING: return !!t.isAudioSharingEnabled;
@@ -8151,12 +8264,12 @@ function So(e, t) {
8151
8264
  default: return !1;
8152
8265
  }
8153
8266
  }
8154
- function Co(e, t) {
8267
+ function Oo(e, t) {
8155
8268
  return M.objectReduce(e, (e, n, r) => {
8156
8269
  switch (n) {
8157
- case co.MUTE:
8158
- case co.MUTE_PERMANENT:
8159
- So(r, t) || (e[r] = n);
8270
+ case mo.MUTE:
8271
+ case mo.MUTE_PERMANENT:
8272
+ Do(r, t) || (e[r] = n);
8160
8273
  break;
8161
8274
  default:
8162
8275
  e[r] = n;
@@ -8165,19 +8278,19 @@ function Co(e, t) {
8165
8278
  return e;
8166
8279
  }, {});
8167
8280
  }
8168
- function wo(e) {
8281
+ function ko(e) {
8169
8282
  let { muteStates: t = {}, mediaSettings: n } = e;
8170
- return Co(t, n);
8283
+ return Oo(t, n);
8171
8284
  }
8172
- function To(e, t) {
8285
+ function Ao(e, t) {
8173
8286
  let n = e.conversation.participants.find((t) => M.comparePeerId(t.peerId, e.peerId));
8174
8287
  if (!n) return t;
8175
8288
  let { mediaSettings: r } = n;
8176
- return Co(t, r);
8289
+ return Oo(t, r);
8177
8290
  }
8178
8291
  //#endregion
8179
8292
  //#region src/utils/IceServers.ts
8180
- function Eo(e) {
8293
+ function jo(e) {
8181
8294
  if (!e) return null;
8182
8295
  let t = Array.from(new Set((e.urls ?? []).map((e) => e.trim()).filter((e) => e.length > 0)));
8183
8296
  return t.length ? {
@@ -8185,8 +8298,8 @@ function Eo(e) {
8185
8298
  urls: t
8186
8299
  } : null;
8187
8300
  }
8188
- function Do(e, t) {
8189
- let n = [], r = Eo(e), i = Eo(t);
8301
+ function Mo(e, t) {
8302
+ let n = [], r = jo(e), i = jo(t);
8190
8303
  if (r && n.push(r), i) {
8191
8304
  let e = [...i.urls];
8192
8305
  e.push(`${e[e.length - 1]}?transport=tcp`), n.push({
@@ -8198,7 +8311,7 @@ function Do(e, t) {
8198
8311
  }
8199
8312
  //#endregion
8200
8313
  //#region src/utils/Lz4.ts
8201
- function Oo(e, t) {
8314
+ function No(e, t) {
8202
8315
  let n = new Uint8Array(t), r = 0, i = 0;
8203
8316
  for (; r < e.length && i < t;) {
8204
8317
  let a = e[r++], o = a >> 4, s = a & 15;
@@ -8225,7 +8338,7 @@ function Oo(e, t) {
8225
8338
  }
8226
8339
  //#endregion
8227
8340
  //#region src/utils/SerializeLatest.ts
8228
- function ko(e) {
8341
+ function Po(e) {
8229
8342
  let t, n = !1, r, i = async () => {
8230
8343
  let t = !1, i;
8231
8344
  for (; n;) {
@@ -8246,7 +8359,7 @@ function ko(e) {
8246
8359
  }
8247
8360
  //#endregion
8248
8361
  //#region src/classes/AudioFix.ts
8249
- var Ao = class {
8362
+ var Fo = class {
8250
8363
  constructor(e, t = z, n = null) {
8251
8364
  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;
8252
8365
  }
@@ -8284,7 +8397,7 @@ var Ao = class {
8284
8397
  this._debug.warn("[AudioFix] Failed to fix RV (no packets): video restart", e);
8285
8398
  }));
8286
8399
  }
8287
- }, jo = class {
8400
+ }, Io = class {
8288
8401
  constructor(e, t = !1, n = z, r = null) {
8289
8402
  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();
8290
8403
  }
@@ -8387,13 +8500,13 @@ var Ao = class {
8387
8500
  };
8388
8501
  //#endregion
8389
8502
  //#region src/classes/conversation/ConversationResponseValidator.ts
8390
- function Mo(e, t) {
8391
- e || Po(t, "response-empty"), e.id || Po(t, "id-empty"), e.endpoint || Po(t, "endpoint-empty"), !No(e.stun_server) && !No(e.turn_server) && Po(t, "ice-servers-empty");
8503
+ function Lo(e, t) {
8504
+ 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");
8392
8505
  }
8393
- function No(e) {
8506
+ function Ro(e) {
8394
8507
  return Array.isArray(e?.urls) && e.urls.length > 0;
8395
8508
  }
8396
- function Po(e, t) {
8509
+ function zo(e, t) {
8397
8510
  let n = e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), r = e === "fastStart" || e === "fastJoin";
8398
8511
  throw new k(r ? e === "fastStart" ? O.FAST_START_ERROR : O.FAST_JOIN_ERROR : O.UNKNOWN_ERROR, {
8399
8512
  message: `Invalid ${e} response: ${t}`,
@@ -8412,7 +8525,7 @@ function Po(e, t) {
8412
8525
  }
8413
8526
  //#endregion
8414
8527
  //#region src/classes/DebugInfo.ts
8415
- var Fo = 90, Io = 3, Lo = class extends b {
8528
+ var Bo = 90, Vo = 3, Ho = class extends b {
8416
8529
  constructor(e = z) {
8417
8530
  super(), h(this, "_lastMemoryStat", {
8418
8531
  percent: 0,
@@ -8428,9 +8541,9 @@ var Fo = 90, Io = 3, Lo = class extends b {
8428
8541
  let e = window?.performance?.memory;
8429
8542
  if (!e || !e.usedJSHeapSize || !e.jsHeapSizeLimit) return;
8430
8543
  let t = Number((100 * e.usedJSHeapSize / e.jsHeapSizeLimit).toFixed(2)), n = Number((e.usedJSHeapSize / 1024 / 1024).toFixed(1));
8431
- t > Fo ? this._debug.warn(`High memory usage: ${t}% (${n} MiB)`) : (!this._lastMemoryStat.percent || Math.abs(t - this._lastMemoryStat.percent) >= Io) && (this._debug.debug(`Memory usage: ${t}% (${n} MiB)`), this._lastMemoryStat.percent = t, this._lastMemoryStat.bytes = e.usedJSHeapSize);
8544
+ 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);
8432
8545
  }
8433
- }, Ro = class {
8546
+ }, Uo = class {
8434
8547
  constructor({ api: e, debug: t, getParticipants: n, isMe: r, updateDisplayLayout: i, onNonFatalError: a }) {
8435
8548
  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;
8436
8549
  }
@@ -8545,7 +8658,7 @@ var Fo = 90, Io = 3, Lo = class extends b {
8545
8658
  let n = e, r = t;
8546
8659
  return n.width !== r.width || n.height !== r.height || n.fit !== r.fit || n.priority !== r.priority;
8547
8660
  }
8548
- }, zo = 44100, Bo = class {
8661
+ }, Wo = 44100, Go = class {
8549
8662
  constructor(e, t) {
8550
8663
  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]);
8551
8664
  try {
@@ -8562,7 +8675,7 @@ var Fo = 90, Io = 3, Lo = class extends b {
8562
8675
  _getBins() {
8563
8676
  if (!this._fftBins || !this._analyser) return new Uint8Array();
8564
8677
  this._analyser.getByteFrequencyData(this._fftBins);
8565
- let e = zo / this._fftBins.length, t = Math.ceil(N.voiceParams.minFreq / e), n = Math.floor(N.voiceParams.maxFreq / e);
8678
+ let e = Wo / this._fftBins.length, t = Math.ceil(N.voiceParams.minFreq / e), n = Math.floor(N.voiceParams.maxFreq / e);
8566
8679
  return this._fftBins.subarray(t, n);
8567
8680
  }
8568
8681
  getLevel() {
@@ -8575,7 +8688,7 @@ var Fo = 90, Io = 3, Lo = class extends b {
8575
8688
  destroy() {
8576
8689
  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);
8577
8690
  }
8578
- }, Vo = class extends b {
8691
+ }, Ko = class extends b {
8579
8692
  constructor(e) {
8580
8693
  super(), h(this, "_detector", null), h(this, "_interval", null);
8581
8694
  let t = () => {
@@ -8591,7 +8704,7 @@ var Fo = 90, Io = 3, Lo = class extends b {
8591
8704
  }), this.subscribe(e, qt.SOURCE_READY, n), n();
8592
8705
  }
8593
8706
  init(e) {
8594
- this._stopDetector(), this._detector = new Bo("local", e.clone());
8707
+ this._stopDetector(), this._detector = new Go("local", e.clone());
8595
8708
  }
8596
8709
  _stopDetector() {
8597
8710
  this._detector && (this._detector.track.stop(), this._detector.destroy(), this._detector = null);
@@ -8599,7 +8712,7 @@ var Fo = 90, Io = 3, Lo = class extends b {
8599
8712
  destroy() {
8600
8713
  this.unsubscribe(), this._interval && (window.clearTimeout(this._interval), this._interval = null), this._stopDetector();
8601
8714
  }
8602
- }, Ho = class {
8715
+ }, qo = class {
8603
8716
  constructor(e, t = z) {
8604
8717
  h(this, "processor", void 0), h(this, "queue", []), h(this, "isProcessing", !1), h(this, "_debug", void 0), this.processor = e, this._debug = t;
8605
8718
  }
@@ -8619,9 +8732,9 @@ var Fo = 90, Io = 3, Lo = class extends b {
8619
8732
  this.isProcessing = !1;
8620
8733
  }
8621
8734
  }
8622
- }, Uo = /* @__PURE__ */ function(e) {
8735
+ }, Jo = /* @__PURE__ */ function(e) {
8623
8736
  return e.VOLUMES_DETECTED = "VOLUMES_DETECTED", e;
8624
- }({}), Wo = class extends b {
8737
+ }({}), Yo = class extends b {
8625
8738
  constructor(e) {
8626
8739
  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));
8627
8740
  }
@@ -8629,7 +8742,7 @@ var Fo = 90, Io = 3, Lo = class extends b {
8629
8742
  this._interval && (window.clearTimeout(this._interval), this._interval = null), this.unsubscribe(), this._destroyDetectors();
8630
8743
  }
8631
8744
  _onRemoteTrackAdded(e, t, n) {
8632
- if (n.kind === A.audio && (this._detectors.get(e)?.destroy(), this._detectors.set(e, new Bo(e, n)), !this._interval)) {
8745
+ if (n.kind === A.audio && (this._detectors.get(e)?.destroy(), this._detectors.set(e, new Go(e, n)), !this._interval)) {
8633
8746
  let e = () => {
8634
8747
  this._collectVolumes(), this._interval = window.setTimeout(e, N.voiceParams.interval);
8635
8748
  };
@@ -8660,14 +8773,14 @@ var Fo = 90, Io = 3, Lo = class extends b {
8660
8773
  this._triggerEvent("VOLUMES_DETECTED", e);
8661
8774
  }
8662
8775
  _getAudioTrackLevelByParticipantId(e) {
8663
- let t = this._detectors.get(oi.AUDIO_MIX);
8776
+ let t = this._detectors.get(ui.AUDIO_MIX);
8664
8777
  return t ? t.getLevel() : this._getTransparentAudioLevelByParticipantId(e);
8665
8778
  }
8666
8779
  _getTransparentAudioLevelByParticipantId(e) {
8667
8780
  if (!this._activeParticipants?.includes(e)) return null;
8668
8781
  let t = null;
8669
8782
  return this._detectors.forEach((e, n) => {
8670
- if (!n.startsWith(`${oi.TRANSPARENT_AUDIO_TRACK_PREFIX}-`)) return;
8783
+ if (!n.startsWith(`${ui.TRANSPARENT_AUDIO_TRACK_PREFIX}-`)) return;
8671
8784
  let r = e.getLevel();
8672
8785
  (!t || r.real > t.real) && (t = r);
8673
8786
  }), t;
@@ -8683,11 +8796,11 @@ var Fo = 90, Io = 3, Lo = class extends b {
8683
8796
  e.destroy();
8684
8797
  }), this._detectors.clear();
8685
8798
  }
8686
- }, Go = /* @__PURE__ */ function(e) {
8799
+ }, Xo = /* @__PURE__ */ function(e) {
8687
8800
  return e.SPEAKER_CHANGED = "SPEAKER_CHANGED", e;
8688
- }({}), Ko = class extends b {
8801
+ }({}), Zo = class extends b {
8689
8802
  constructor(e, t, n) {
8690
- super(), h(this, "_speakerId", null), h(this, "_serverSideSpeakerDetection", !1), this._serverSideSpeakerDetection = n === J.SERVER, this.subscribe(e, Uo.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));
8803
+ 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));
8691
8804
  }
8692
8805
  destroy() {
8693
8806
  this.unsubscribe();
@@ -8709,9 +8822,9 @@ var Fo = 90, Io = 3, Lo = class extends b {
8709
8822
  _onTopologyChanged(e) {
8710
8823
  this._serverSideSpeakerDetection = e === J.SERVER;
8711
8824
  }
8712
- }, qo = 15e3, Jo = 15e3, Yo = class extends b {
8825
+ }, Qo = 15e3, $o = 15e3, es = class extends b {
8713
8826
  constructor(e, t, n, r = z, i = null) {
8714
- 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, Uo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this));
8827
+ 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));
8715
8828
  }
8716
8829
  destroy() {
8717
8830
  this.unsubscribe(), this._connectionTimeout && window.clearTimeout(this._connectionTimeout), this._volumeTimeout && window.clearTimeout(this._volumeTimeout);
@@ -8723,10 +8836,10 @@ var Fo = 90, Io = 3, Lo = class extends b {
8723
8836
  this._connectionTimeout || !this._connectionTimeoutSuppressed || this._reportConnectionTimeout();
8724
8837
  }
8725
8838
  _getConnectionTimeout() {
8726
- return this._transport.getTopology() === J.DIRECT ? qo : N.specListenerParams.connectionTimeout;
8839
+ return this._transport.getTopology() === J.DIRECT ? Qo : N.specListenerParams.connectionTimeout;
8727
8840
  }
8728
8841
  _getVolumeTimeout() {
8729
- return this._transport.getTopology() === J.DIRECT ? Jo : N.specListenerParams.volumeTimeout;
8842
+ return this._transport.getTopology() === J.DIRECT ? $o : N.specListenerParams.volumeTimeout;
8730
8843
  }
8731
8844
  _onTransportStateChanged(e, t) {
8732
8845
  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`));
@@ -8759,15 +8872,15 @@ var Fo = 90, Io = 3, Lo = class extends b {
8759
8872
  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}`));
8760
8873
  }), e.length && this._debug.warn("There is silent participant, send callSpecError"), this._volumeTimeout = 0;
8761
8874
  }
8762
- }, Xo = /* @__PURE__ */ function(e) {
8875
+ }, ts = /* @__PURE__ */ function(e) {
8763
8876
  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;
8764
- }(Xo || {});
8765
- function Zo(e) {
8877
+ }(ts || {});
8878
+ function ns(e) {
8766
8879
  return e === 102 || e === 103 || e === 104;
8767
8880
  }
8768
8881
  //#endregion
8769
8882
  //#region src/classes/stat/StatQueue.ts
8770
- var Qo, $o = "ok-calls-sdk-stats", es = 1, ts = "events", ns = 100, rs = 5e3, is = 10080 * 60 * 1e3, as = 5e3, os = 6e4, Q = class e {
8883
+ 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 {
8771
8884
  static isSupported() {
8772
8885
  return e._supported;
8773
8886
  }
@@ -8780,7 +8893,7 @@ var Qo, $o = "ok-calls-sdk-stats", es = 1, ts = "events", ns = 100, rs = 5e3, is
8780
8893
  n.onsuccess = () => e(n.result);
8781
8894
  });
8782
8895
  }).catch((e) => (z.error("[StatQueue] failed to append event", e), null));
8783
- return r === null ? null : (e._appendsSinceEvictCheck += 1, e._appendsSinceEvictCheck >= ns && (e._appendsSinceEvictCheck = 0, await e.evictToLimit(rs)), r);
8896
+ return r === null ? null : (e._appendsSinceEvictCheck += 1, e._appendsSinceEvictCheck >= ss && (e._appendsSinceEvictCheck = 0, await e.evictToLimit(cs)), r);
8784
8897
  }
8785
8898
  static async fillDelta(t, n) {
8786
8899
  if (t.length === 0) return;
@@ -8881,7 +8994,7 @@ var Qo, $o = "ok-calls-sdk-stats", es = 1, ts = "events", ns = 100, rs = 5e3, is
8881
8994
  });
8882
8995
  }
8883
8996
  static async __resetForTests() {
8884
- if (e._appendsSinceEvictCheck = 0, e._lastOpenFailureAt = null, e._supported = e._checkSupport(), e._dbName === $o && (e._dbName = `${$o}-test-${Math.random().toString(36).slice(2)}`, e._close()), e._supported) {
8997
+ 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) {
8885
8998
  let t = await e._open();
8886
8999
  t && await e._runTransaction(t, "readwrite", (e) => {
8887
9000
  e.clear();
@@ -8889,7 +9002,6 @@ var Qo, $o = "ok-calls-sdk-stats", es = 1, ts = "events", ns = 100, rs = 5e3, is
8889
9002
  z.error("[StatQueue] failed to reset storage", e);
8890
9003
  });
8891
9004
  }
8892
- e._close();
8893
9005
  }
8894
9006
  static _checkSupport() {
8895
9007
  return typeof window < "u" && !!window.indexedDB;
@@ -8897,18 +9009,18 @@ var Qo, $o = "ok-calls-sdk-stats", es = 1, ts = "events", ns = 100, rs = 5e3, is
8897
9009
  static _open() {
8898
9010
  if (!e._checkSupport()) return e._supported = !1, Promise.resolve(null);
8899
9011
  if (e._dbPromise) return e._dbPromise;
8900
- if (e._lastOpenFailureAt !== null && Date.now() - e._lastOpenFailureAt < os) return Promise.resolve(null);
9012
+ if (e._lastOpenFailureAt !== null && Date.now() - e._lastOpenFailureAt < ds) return Promise.resolve(null);
8901
9013
  let t = !1, n = new Promise((n) => {
8902
9014
  let r = (r, i) => {
8903
9015
  t || (t = !0, z.error(r, i), e._supported = !1, e._dbPromise = null, e._lastOpenFailureAt = Date.now(), n(null));
8904
9016
  }, i;
8905
9017
  try {
8906
- i = window.indexedDB.open(e._dbName, es);
9018
+ i = window.indexedDB.open(e._dbName, as);
8907
9019
  } catch (e) {
8908
9020
  r("[StatQueue] storage is not accessible", e);
8909
9021
  return;
8910
9022
  }
8911
- let a = window.setTimeout(() => r("[StatQueue] storage opening timed out"), as);
9023
+ let a = window.setTimeout(() => r("[StatQueue] storage opening timed out"), us);
8912
9024
  i.onupgradeneeded = () => {
8913
9025
  e._createSchema(i.result);
8914
9026
  }, i.onsuccess = () => {
@@ -8929,8 +9041,8 @@ var Qo, $o = "ok-calls-sdk-stats", es = 1, ts = "events", ns = 100, rs = 5e3, is
8929
9041
  e._db && (e._db.close(), e._db = null), e._dbPromise = null;
8930
9042
  }
8931
9043
  static _createSchema(e) {
8932
- if (e.objectStoreNames.contains(ts)) return;
8933
- let t = e.createObjectStore(ts, {
9044
+ if (e.objectStoreNames.contains(os)) return;
9045
+ let t = e.createObjectStore(os, {
8934
9046
  keyPath: "id",
8935
9047
  autoIncrement: !0
8936
9048
  });
@@ -8938,8 +9050,8 @@ var Qo, $o = "ok-calls-sdk-stats", es = 1, ts = "events", ns = 100, rs = 5e3, is
8938
9050
  }
8939
9051
  static _runTransaction(e, t, n) {
8940
9052
  return new Promise((r, i) => {
8941
- let a = e.transaction(ts, t), o;
8942
- a.oncomplete = () => r(o), a.onerror = () => i(a.error), a.onabort = () => i(a.error), Promise.resolve(n(a.objectStore(ts))).then((e) => {
9053
+ let a = e.transaction(os, t), o;
9054
+ a.oncomplete = () => r(o), a.onerror = () => i(a.error), a.onabort = () => i(a.error), Promise.resolve(n(a.objectStore(os))).then((e) => {
8943
9055
  o = e;
8944
9056
  }).catch((e) => {
8945
9057
  try {
@@ -8964,18 +9076,18 @@ var Qo, $o = "ok-calls-sdk-stats", es = 1, ts = "events", ns = 100, rs = 5e3, is
8964
9076
  });
8965
9077
  }
8966
9078
  };
8967
- Qo = Q, h(Q, "_db", null), h(Q, "_dbPromise", null), h(Q, "_dbName", $o), h(Q, "_supported", Qo._checkSupport()), h(Q, "_appendsSinceEvictCheck", 0), h(Q, "_lastOpenFailureAt", null);
9079
+ 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);
8968
9080
  //#endregion
8969
9081
  //#region src/static/ApiTransport.ts
8970
- var ss = null, cs = null, ls = 64 * 1024;
8971
- function us() {
8972
- ss = null, cs = null;
9082
+ var fs = null, ps = null, ms = 64 * 1024;
9083
+ function hs() {
9084
+ fs = null, ps = null;
8973
9085
  }
8974
- function ds(e) {
9086
+ function gs(e) {
8975
9087
  return e?.endsWith("/") ? e.slice(0, -1) : e;
8976
9088
  }
8977
- async function fs(e = null, t) {
8978
- let n = ds(e ?? N.apiBaseUrl);
9089
+ async function _s(e = null, t) {
9090
+ let n = gs(e ?? N.apiBaseUrl);
8979
9091
  if (n) return n;
8980
9092
  if ((t ?? N.apiEnv) !== "AUTO") return N.apiEndpoint(t);
8981
9093
  try {
@@ -8990,25 +9102,25 @@ async function fs(e = null, t) {
8990
9102
  return z.warn("Failed to resolve API endpoint using DNS, default is used", e), N.apiEndpoint(t);
8991
9103
  }
8992
9104
  }
8993
- async function ps() {
8994
- return ss || cs || (cs = fs(), ss = await cs, cs = null, ss);
9105
+ async function vs() {
9106
+ return fs || ps || (ps = _s(), fs = await ps, ps = null, fs);
8995
9107
  }
8996
- async function ms(e, t = {}, n = !1) {
9108
+ async function ys(e, t = {}, n = !1) {
8997
9109
  if (!window.Blob || !window.navigator.sendBeacon) return;
8998
- await ps();
8999
- let r = bs(e, t, n), i = new window.Blob([r], { type: "application/x-www-form-urlencoded" });
9000
- window.navigator.sendBeacon(`${ss}/fb.do`, i);
9110
+ await vs();
9111
+ let r = Ts(e, t, n), i = new window.Blob([r], { type: "application/x-www-form-urlencoded" });
9112
+ window.navigator.sendBeacon(`${fs}/fb.do`, i);
9001
9113
  }
9002
- async function hs(e, t = {}, n = !1, r) {
9003
- return await ps(), _s(bs(e, t, n), r);
9114
+ async function bs(e, t = {}, n = !1, r) {
9115
+ return await vs(), Ss(Ts(e, t, n), r);
9004
9116
  }
9005
- async function gs(e, t = {}, n = !1) {
9006
- await ps();
9007
- let r = bs(e, t, n);
9008
- return _s(r, void 0, new Blob([r]).size <= ls);
9117
+ async function xs(e, t = {}, n = !1) {
9118
+ await vs();
9119
+ let r = Ts(e, t, n);
9120
+ return Ss(r, void 0, new Blob([r]).size <= ms);
9009
9121
  }
9010
- async function _s(e, t, n = !1) {
9011
- let r = `${t ?? ss}/fb.do`, i = new AbortController(), a = new k(x.NETWORK, { callError: {
9122
+ async function Ss(e, t, n = !1) {
9123
+ let r = `${t ?? fs}/fb.do`, i = new AbortController(), a = new k(x.NETWORK, { callError: {
9012
9124
  scope: "network",
9013
9125
  source: "api",
9014
9126
  code: "timeout",
@@ -9027,16 +9139,16 @@ async function _s(e, t, n = !1) {
9027
9139
  } catch {
9028
9140
  o = { result: a };
9029
9141
  }
9030
- if (!t.ok && !vs(o)) throw new k(x.API, { callError: {
9142
+ if (!t.ok && !Cs(o)) throw new k(x.API, { callError: {
9031
9143
  scope: "server",
9032
9144
  source: "api",
9033
9145
  code: `http-${t.status}`,
9034
9146
  description: "http-error"
9035
9147
  } });
9036
- if (vs(o)) throw o;
9148
+ if (Cs(o)) throw o;
9037
9149
  return o;
9038
9150
  } catch (e) {
9039
- throw e instanceof k ? e : i.signal.aborted ? a : vs(e) ? e : new k(x.NETWORK, { callError: {
9151
+ throw e instanceof k ? e : i.signal.aborted ? a : Cs(e) ? e : new k(x.NETWORK, { callError: {
9040
9152
  scope: "network",
9041
9153
  source: "api",
9042
9154
  code: "fetch-failed",
@@ -9046,12 +9158,12 @@ async function _s(e, t, n = !1) {
9046
9158
  clearTimeout(o);
9047
9159
  }
9048
9160
  }
9049
- function vs(e) {
9161
+ function Cs(e) {
9050
9162
  if (typeof e != "object" || !e) return !1;
9051
9163
  let t = e;
9052
9164
  return typeof t.error_code == "number" && typeof t.error_msg == "string";
9053
9165
  }
9054
- async function ys(e, t) {
9166
+ async function ws(e, t) {
9055
9167
  try {
9056
9168
  let n = await fetch(e, {
9057
9169
  method: "POST",
@@ -9064,7 +9176,7 @@ async function ys(e, t) {
9064
9176
  throw z.warn("Failed to send form data", e), e;
9065
9177
  }
9066
9178
  }
9067
- function bs(e, t = {}, n = !1) {
9179
+ function Ts(e, t = {}, n = !1) {
9068
9180
  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));
9069
9181
  for (let [e, n] of Object.entries(t)) typeof n == "object" && (t[e] = JSON.stringify(n));
9070
9182
  let r = "";
@@ -9073,7 +9185,7 @@ function bs(e, t = {}, n = !1) {
9073
9185
  }
9074
9186
  //#endregion
9075
9187
  //#region src/static/SessionStore.ts
9076
- var xs = "sessions", Ss = 5, Cs = class e {
9188
+ var Es = "sessions", Ds = 5, Os = class e {
9077
9189
  static remember(t, n) {
9078
9190
  let r = e._read();
9079
9191
  r[String(t)] = {
@@ -9081,7 +9193,7 @@ var xs = "sessions", Ss = 5, Cs = class e {
9081
9193
  savedAt: Date.now()
9082
9194
  };
9083
9195
  let i = Object.keys(r);
9084
- i.length > Ss && i.sort((e, t) => r[e].savedAt - r[t].savedAt).slice(0, i.length - Ss).forEach((e) => delete r[e]), e._write(r);
9196
+ 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);
9085
9197
  }
9086
9198
  static get(t) {
9087
9199
  return e._read()[String(t)] ?? null;
@@ -9097,10 +9209,10 @@ var xs = "sessions", Ss = 5, Cs = class e {
9097
9209
  }), r && e._write(n);
9098
9210
  }
9099
9211
  static currentEndpoint() {
9100
- return String(ds(N.apiBaseUrl) || N.apiEndpoint());
9212
+ return String(gs(N.apiBaseUrl) || N.apiEndpoint());
9101
9213
  }
9102
9214
  static _read() {
9103
- let t = w.get(xs);
9215
+ let t = w.get(Es);
9104
9216
  if (!t || typeof t != "object" || Array.isArray(t)) return {};
9105
9217
  let n = {};
9106
9218
  return Object.entries(t).forEach(([t, r]) => {
@@ -9109,16 +9221,16 @@ var xs = "sessions", Ss = 5, Cs = class e {
9109
9221
  }
9110
9222
  static _write(e) {
9111
9223
  if (Object.keys(e).length === 0) {
9112
- w.remove(xs);
9224
+ w.remove(Es);
9113
9225
  return;
9114
9226
  }
9115
- w.set(xs, e);
9227
+ w.set(Es, e);
9116
9228
  }
9117
9229
  static _isValid(e) {
9118
9230
  let t = e;
9119
9231
  return typeof t == "object" && !!t && typeof t.sessionKey == "string" && t.sessionKey.length > 0 && typeof t.endpoint == "string" && typeof t.savedAt == "number";
9120
9232
  }
9121
- }, ws = 15e3, Ts = class e {
9233
+ }, ks = 15e3, As = class e {
9122
9234
  static setApi(t) {
9123
9235
  e._api = t;
9124
9236
  }
@@ -9129,7 +9241,7 @@ var xs = "sessions", Ss = 5, Cs = class e {
9129
9241
  e._delta === null && e._api && e.get();
9130
9242
  }
9131
9243
  static get() {
9132
- return e._delta === null ? !e._api || !e._hasCredentials() || e._lastFailureAt !== null && Date.now() - e._lastFailureAt < ws ? Promise.resolve(0) : (e._pending || (e._pending = e._measure().finally(() => {
9244
+ 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(() => {
9133
9245
  e._pending = null;
9134
9246
  })), e._pending) : Promise.resolve(e._delta);
9135
9247
  }
@@ -9159,10 +9271,10 @@ var xs = "sessions", Ss = 5, Cs = class e {
9159
9271
  return e._idsAwaitingDelta = [], await Q.fillDelta(n, t), t;
9160
9272
  }
9161
9273
  };
9162
- h(Ts, "_api", null), h(Ts, "_delta", null), h(Ts, "_pending", null), h(Ts, "_idsAwaitingDelta", []), h(Ts, "_lastFailureAt", null);
9274
+ h(As, "_api", null), h(As, "_delta", null), h(As, "_pending", null), h(As, "_idsAwaitingDelta", []), h(As, "_lastFailureAt", null);
9163
9275
  //#endregion
9164
9276
  //#region src/classes/stat/StatUnloadJournal.ts
9165
- var Es = "okcls-stat-unload.", Ds = class e {
9277
+ var js = "okcls-stat-unload.", Ms = class e {
9166
9278
  static beginTabSession() {
9167
9279
  e._tabKey = null, e._entries = [];
9168
9280
  }
@@ -9170,7 +9282,7 @@ var Es = "okcls-stat-unload.", Ds = class e {
9170
9282
  let n = e._storage();
9171
9283
  if (!n) return !1;
9172
9284
  try {
9173
- return e._tabKey || (e._tabKey = Es + 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;
9285
+ 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;
9174
9286
  } catch (e) {
9175
9287
  return z.error("[StatUnloadJournal] failed to write", e), !1;
9176
9288
  }
@@ -9182,7 +9294,7 @@ var Es = "okcls-stat-unload.", Ds = class e {
9182
9294
  try {
9183
9295
  for (let e = 0; e < t.length; e += 1) {
9184
9296
  let r = t.key(e);
9185
- r && r.startsWith(Es) && n.push(r);
9297
+ r && r.startsWith(js) && n.push(r);
9186
9298
  }
9187
9299
  } catch (e) {
9188
9300
  return z.error("[StatUnloadJournal] failed to scan journals", e), 0;
@@ -9225,32 +9337,32 @@ var Es = "okcls-stat-unload.", Ds = class e {
9225
9337
  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;
9226
9338
  }
9227
9339
  };
9228
- h(Ds, "_tabKey", null), h(Ds, "_entries", []);
9340
+ h(Ms, "_tabKey", null), h(Ms, "_entries", []);
9229
9341
  //#endregion
9230
9342
  //#region src/classes/stat/StatDrainScheduler.ts
9231
- var Os = 500, ks = 100, As = 3e4, js = 1e3, Ms = 5e3, Ns = 3e3, Ps = "okcls-stat-drain", Fs = class e {
9343
+ var Ns = 500, Ps = 100, Fs = 3e4, Is = 1e3, Ls = 5e3, Rs = 3e3, zs = "okcls-stat-drain", Bs = class e {
9232
9344
  static setApi(t) {
9233
- e._api = t, Ts.setApi(t);
9345
+ e._api = t, As.setApi(t);
9234
9346
  }
9235
9347
  static start(t) {
9236
- e.setApi(t), Ds.drainToQueue().catch((e) => z.error("[StatDrainScheduler] failed to import unload journal", e)).then(async () => (Cs.prune(), await Q.evictOlderThan(is), await Q.evictToLimit(rs), e._drain())).catch((e) => z.error("[StatDrainScheduler] failed to start", e));
9348
+ 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));
9237
9349
  }
9238
9350
  static notifyAppended() {
9239
9351
  if (e._api) {
9240
- if (e._localCount += 1, e._localCount >= ks) {
9352
+ if (e._localCount += 1, e._localCount >= Ps) {
9241
9353
  e._drain();
9242
9354
  return;
9243
9355
  }
9244
- e._state === "IDLE" && e._arm(As);
9356
+ e._state === "IDLE" && e._arm(Fs);
9245
9357
  }
9246
9358
  }
9247
9359
  static notifyCallFinished() {
9248
9360
  if (e._api) {
9249
- if (e._directBuffer.length > 0 && e._armDirect(js), e._state === "DRAINING") {
9361
+ if (e._directBuffer.length > 0 && e._armDirect(Is), e._state === "DRAINING") {
9250
9362
  e._callFinishedDuringDrain = !0;
9251
9363
  return;
9252
9364
  }
9253
- e._arm(js);
9365
+ e._arm(Is);
9254
9366
  }
9255
9367
  }
9256
9368
  static drainOnce() {
@@ -9259,7 +9371,7 @@ var Os = 500, ks = 100, As = 3e4, js = 1e3, Ms = 5e3, Ns = 3e3, Ps = "okcls-stat
9259
9371
  if (!t) return !1;
9260
9372
  let n = e._currentUserId(), r = await Q.listUids(), i = !1, a = null;
9261
9373
  for (let o of r) try {
9262
- (o === n ? await e._drainCurrent(t, o) : await e._drainStored(t, o)) === Os && (i = !0);
9374
+ (o === n ? await e._drainCurrent(t, o) : await e._drainStored(t, o)) === Ns && (i = !0);
9263
9375
  } catch (e) {
9264
9376
  a === null && (a = e);
9265
9377
  }
@@ -9273,20 +9385,20 @@ var Os = 500, ks = 100, As = 3e4, js = 1e3, Ms = 5e3, Ns = 3e3, Ps = "okcls-stat
9273
9385
  z.error("[StatDrainScheduler] direct send skipped: event belongs to another user");
9274
9386
  return;
9275
9387
  }
9276
- e._directBuffer.push(t), e._directTimer === null && e._armDirect(Ns);
9388
+ e._directBuffer.push(t), e._directTimer === null && e._armDirect(Rs);
9277
9389
  }
9278
9390
  }
9279
9391
  static __resetForTests() {
9280
- Ts.__resetForTests(), e._clearTimer(), e._clearDirectTimer(), e._directBuffer = [], e._api = null, e._state = "IDLE", e._localCount = 0, e._callFinishedDuringDrain = !1, e._blockedSession = null;
9392
+ As.__resetForTests(), e._clearTimer(), e._clearDirectTimer(), e._directBuffer = [], e._api = null, e._state = "IDLE", e._localCount = 0, e._callFinishedDuringDrain = !1, e._blockedSession = null;
9281
9393
  }
9282
9394
  static _currentUserId() {
9283
9395
  return y.userId;
9284
9396
  }
9285
9397
  static async _drainCurrent(t, n) {
9286
9398
  if (e._isSessionBlocked()) return 0;
9287
- let r = await Q.readOldest(n, Os);
9399
+ let r = await Q.readOldest(n, Ns);
9288
9400
  if (r.length === 0) return 0;
9289
- let i = await Ts.get(), a = r.map((t) => e._toClientStats(t, i)), o = r.map((e) => e.id);
9401
+ let i = await As.get(), a = r.map((t) => e._toClientStats(t, i)), o = r.map((e) => e.id);
9290
9402
  try {
9291
9403
  await t.logClientStats(a);
9292
9404
  } catch (t) {
@@ -9297,25 +9409,25 @@ var Os = 500, ks = 100, As = 3e4, js = 1e3, Ms = 5e3, Ns = 3e3, Ps = "okcls-stat
9297
9409
  return await Q.remove(o), r.length;
9298
9410
  }
9299
9411
  static async _drainStored(t, n) {
9300
- let r = Cs.get(n);
9301
- if (!r || r.endpoint !== Cs.currentEndpoint()) return 0;
9302
- let i = await Q.readOldest(n, Os);
9412
+ let r = Os.get(n);
9413
+ if (!r || r.endpoint !== Os.currentEndpoint()) return 0;
9414
+ let i = await Q.readOldest(n, Ns);
9303
9415
  if (i.length === 0) return 0;
9304
- let a = await Ts.get(), o = i.map((t) => e._toClientStats(t, a)), s = i.map((e) => e.id);
9416
+ let a = await As.get(), o = i.map((t) => e._toClientStats(t, a)), s = i.map((e) => e.id);
9305
9417
  try {
9306
9418
  await t.logClientStatsWith(r.sessionKey, o), z.debug("[StatDrainScheduler] delivered", i.length, "stored events of uid", n);
9307
9419
  } catch (t) {
9308
- if (e._isAuthError(t)) return z.error("[StatDrainScheduler] stored session expired, skipping uid", n), Cs.forget(n), 0;
9420
+ if (e._isAuthError(t)) return z.error("[StatDrainScheduler] stored session expired, skipping uid", n), Os.forget(n), 0;
9309
9421
  if (e._isRetryable(t)) throw t;
9310
9422
  return z.error("[StatDrainScheduler] batch rejected, dropping", t), await Q.remove(s), i.length;
9311
9423
  }
9312
9424
  return await Q.remove(s), i.length;
9313
9425
  }
9314
9426
  static _withLock(e) {
9315
- return typeof navigator > "u" || !navigator.locks ? e() : navigator.locks.request(Ps, e);
9427
+ return typeof navigator > "u" || !navigator.locks ? e() : navigator.locks.request(zs, e);
9316
9428
  }
9317
9429
  static _isSessionError(e) {
9318
- return Zo(e?.error_code);
9430
+ return ns(e?.error_code);
9319
9431
  }
9320
9432
  static _isReauthorizeFailure(e) {
9321
9433
  return e?.error === x.AUTH;
@@ -9328,7 +9440,7 @@ var Os = 500, ks = 100, As = 3e4, js = 1e3, Ms = 5e3, Ns = 3e3, Ps = "okcls-stat
9328
9440
  }
9329
9441
  static _isAuthError(t) {
9330
9442
  let n = t?.error_code;
9331
- return e._isSessionError(t) || n === Xo.AUTH_LOGIN;
9443
+ return e._isSessionError(t) || n === ts.AUTH_LOGIN;
9332
9444
  }
9333
9445
  static _isRetryable(t) {
9334
9446
  if (e._isSessionError(t)) return !0;
@@ -9353,7 +9465,7 @@ var Os = 500, ks = 100, As = 3e4, js = 1e3, Ms = 5e3, Ns = 3e3, Ps = "okcls-stat
9353
9465
  static async _flushDirect() {
9354
9466
  let t = e._api, n = e._directBuffer;
9355
9467
  if (e._directBuffer = [], !(!t || n.length === 0)) try {
9356
- let r = await Ts.get();
9468
+ let r = await As.get();
9357
9469
  await t.logClientStats(n.map((t) => e._toClientStats(t, r)));
9358
9470
  } catch (e) {
9359
9471
  z.error("[StatDrainScheduler] direct send failed, events lost", e);
@@ -9372,28 +9484,28 @@ var Os = 500, ks = 100, As = 3e4, js = 1e3, Ms = 5e3, Ns = 3e3, Ps = "okcls-stat
9372
9484
  e._clearTimer(), e._state = "DRAINING", e._localCount = 0, e._callFinishedDuringDrain = !1;
9373
9485
  try {
9374
9486
  if (await e.drainOnce()) {
9375
- e._arm(Ms);
9487
+ e._arm(Ls);
9376
9488
  return;
9377
9489
  }
9378
9490
  if (e._callFinishedDuringDrain) {
9379
- e._arm(js);
9491
+ e._arm(Is);
9380
9492
  return;
9381
9493
  }
9382
9494
  if (e._localCount > 0) {
9383
- e._arm(As);
9495
+ e._arm(Fs);
9384
9496
  return;
9385
9497
  }
9386
9498
  e._state = "IDLE";
9387
9499
  } catch (t) {
9388
- z.error("[StatDrainScheduler] drain failed", t), e._arm(As);
9500
+ z.error("[StatDrainScheduler] drain failed", t), e._arm(Fs);
9389
9501
  }
9390
9502
  }
9391
9503
  }
9392
9504
  };
9393
- h(Fs, "_api", null), h(Fs, "_state", "IDLE"), h(Fs, "_timer", null), h(Fs, "_localCount", 0), h(Fs, "_callFinishedDuringDrain", !1), h(Fs, "_blockedSession", null), h(Fs, "_directBuffer", []), h(Fs, "_directTimer", null);
9505
+ 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);
9394
9506
  //#endregion
9395
9507
  //#region src/classes/StatsLogger.ts
9396
- var Is = class extends f {
9508
+ var Vs = class extends f {
9397
9509
  constructor(e, t, n, r = () => void 0) {
9398
9510
  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();
9399
9511
  }
@@ -9473,7 +9585,7 @@ var Is = class extends f {
9473
9585
  _now() {
9474
9586
  return Date.now() - this._serverTimeDelta;
9475
9587
  }
9476
- }, Ls = class e extends f {
9588
+ }, Hs = class e extends f {
9477
9589
  static __resetForTests() {
9478
9590
  e._pending = [], e._pendingOverflow = !1;
9479
9591
  }
@@ -9489,17 +9601,17 @@ var Is = class extends f {
9489
9601
  return e._pending = [], e._pendingOverflow = !1, t;
9490
9602
  }
9491
9603
  constructor(e, t, n, r = () => void 0) {
9492
- 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 Is(e, t, n, r);
9604
+ 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);
9493
9605
  }
9494
9606
  log(e, t, n = !1) {
9495
9607
  this._externalLogger && this._externalLogger.log(e, t, n);
9496
9608
  }
9497
9609
  enterUnloadMode() {
9498
- this._legacy || (this._unloadMode = !0, Ds.beginTabSession());
9610
+ this._legacy || (this._unloadMode = !0, Ms.beginTabSession());
9499
9611
  }
9500
9612
  exitUnloadMode() {
9501
- this._legacy || !this._unloadMode || (this._unloadMode = !1, Ds.drainToQueue().then((e) => {
9502
- e > 0 && Fs.notifyAppended();
9613
+ this._legacy || !this._unloadMode || (this._unloadMode = !1, Ms.drainToQueue().then((e) => {
9614
+ e > 0 && Bs.notifyAppended();
9503
9615
  }).catch((e) => z.error("[StatEventCollector] failed to import unload journal", e)));
9504
9616
  }
9505
9617
  logClientStats(t, n = {}) {
@@ -9518,11 +9630,11 @@ var Is = class extends f {
9518
9630
  };
9519
9631
  Object.keys(a).forEach((e) => {
9520
9632
  a[e] === void 0 && delete a[e];
9521
- }), Ts.ensure();
9633
+ }), As.ensure();
9522
9634
  let o = {
9523
9635
  vcid: r,
9524
9636
  ts: i,
9525
- delta: Ts.delta(),
9637
+ delta: As.delta(),
9526
9638
  ev: a
9527
9639
  }, s = y.userId;
9528
9640
  if (s === null) {
@@ -9545,12 +9657,12 @@ var Is = class extends f {
9545
9657
  }
9546
9658
  }
9547
9659
  _store(e) {
9548
- this._unloadMode && Ds.writeSync(e) || Q.append(e).then((t) => {
9660
+ this._unloadMode && Ms.writeSync(e) || Q.append(e).then((t) => {
9549
9661
  if (t !== null) {
9550
- typeof e.delta != "number" && Ts.noteAppended(t), Fs.notifyAppended();
9662
+ typeof e.delta != "number" && As.noteAppended(t), Bs.notifyAppended();
9551
9663
  return;
9552
9664
  }
9553
- z.error("[StatEventCollector] failed to store event, sending directly"), Fs.sendDirect(e);
9665
+ z.error("[StatEventCollector] failed to store event, sending directly"), Bs.sendDirect(e);
9554
9666
  }).catch((e) => z.error("[StatEventCollector] failed to store event", e));
9555
9667
  }
9556
9668
  _getConversationId() {
@@ -9568,10 +9680,10 @@ var Is = class extends f {
9568
9680
  }
9569
9681
  }
9570
9682
  };
9571
- h(Ls, "_pending", []), h(Ls, "_pendingOverflow", !1);
9683
+ h(Hs, "_pending", []), h(Hs, "_pendingOverflow", !1);
9572
9684
  //#endregion
9573
9685
  //#region src/classes/stat/ApiCallStats.ts
9574
- var Rs = class {
9686
+ var Us = class {
9575
9687
  constructor(e) {
9576
9688
  h(this, "_statAggregator", void 0), this._statAggregator = e;
9577
9689
  }
@@ -9583,7 +9695,7 @@ var Rs = class {
9583
9695
  string_value: n
9584
9696
  });
9585
9697
  }
9586
- }, zs = "invalid-error-metadata", Bs = 64, Vs = new Set(Object.values(O)), Hs = new Set(Object.values(x)), Us = {
9698
+ }, Ws = "invalid-error-metadata", Gs = 64, Ks = new Set(Object.values(O)), qs = new Set(Object.values(x)), Js = {
9587
9699
  [O.CANCELED]: {
9588
9700
  type: "semantic",
9589
9701
  reason: "canceled"
@@ -9704,7 +9816,7 @@ var Rs = class {
9704
9816
  type: "semantic",
9705
9817
  reason: "obsolete_client"
9706
9818
  }
9707
- }, Ws = {
9819
+ }, Ys = {
9708
9820
  [x.MIC_CAMERA_PERMISSION]: {
9709
9821
  type: "direct-error",
9710
9822
  error: {
@@ -9793,14 +9905,14 @@ var Rs = class {
9793
9905
  }
9794
9906
  }
9795
9907
  };
9796
- function Gs(e) {
9797
- if (typeof e != "string" && typeof e != "number" || typeof e == "number" && !Number.isFinite(e)) return zs;
9908
+ function Xs(e) {
9909
+ if (typeof e != "string" && typeof e != "number" || typeof e == "number" && !Number.isFinite(e)) return Ws;
9798
9910
  let t = String(e).trim();
9799
- if (!t) return zs;
9911
+ if (!t) return Ws;
9800
9912
  let n = t.toLowerCase().replace(/[\s_:]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
9801
- return !n || !/^[a-z0-9.-]+$/.test(n) ? zs : n.length > Bs ? `${n.slice(0, Bs - 3)}...` : n;
9913
+ return !n || !/^[a-z0-9.-]+$/.test(n) ? Ws : n.length > Gs ? `${n.slice(0, Gs - 3)}...` : n;
9802
9914
  }
9803
- function Ks(e) {
9915
+ function Zs(e) {
9804
9916
  if (!e || typeof e != "object") return !1;
9805
9917
  let t = e;
9806
9918
  switch (t.scope) {
@@ -9812,49 +9924,49 @@ function Ks(e) {
9812
9924
  default: return !1;
9813
9925
  }
9814
9926
  }
9815
- function qs(e) {
9816
- let t = Gs(e.description);
9927
+ function Qs(e) {
9928
+ let t = Xs(e.description);
9817
9929
  if (e.scope === "unknown") return `unknown:${t}`;
9818
- let n = Gs(e.code);
9930
+ let n = Xs(e.code);
9819
9931
  return e.scope === "internal" ? `internal:${n}:${t}` : `${e.scope}:${e.source}:${n}:${t}`;
9820
9932
  }
9821
- function Js(e, t) {
9933
+ function $s(e, t) {
9822
9934
  return t === null ? e.type === "direct-error" ? {
9823
9935
  reason: "error",
9824
- string_value: qs(e.error)
9825
- } : { reason: "failed" } : Ks(t) ? {
9936
+ string_value: Qs(e.error)
9937
+ } : { reason: "failed" } : Zs(t) ? {
9826
9938
  reason: "error",
9827
- string_value: qs(t)
9939
+ string_value: Qs(t)
9828
9940
  } : { reason: "failed" };
9829
9941
  }
9830
- function Ys(e) {
9942
+ function ec(e) {
9831
9943
  if (e.hangup) {
9832
- let t = Us[e.hangup];
9944
+ let t = Js[e.hangup];
9833
9945
  return t ? t.type === "semantic" ? e.hangup === O.OBSOLETE_CLIENT && e.custom_error?.vchat_detailed_api_error.code ? {
9834
9946
  reason: t.reason,
9835
9947
  string_value: e.custom_error.vchat_detailed_api_error.code
9836
- } : { reason: t.reason } : Js(t, e.callError) : { reason: "failed" };
9948
+ } : { reason: t.reason } : $s(t, e.callError) : { reason: "failed" };
9837
9949
  }
9838
9950
  if (e.error) {
9839
- let t = Ws[e.error];
9840
- return t ? Js(t, e.callError) : { reason: "failed" };
9951
+ let t = Ys[e.error];
9952
+ return t ? $s(t, e.callError) : { reason: "failed" };
9841
9953
  }
9842
9954
  return { reason: "failed" };
9843
9955
  }
9844
- function Xs(e) {
9845
- return e instanceof k ? Ys(e) : typeof e == "string" && (Vs.has(e) || Hs.has(e)) ? Ys(new k(e)) : { reason: "failed" };
9956
+ function tc(e) {
9957
+ return e instanceof k ? ec(e) : typeof e == "string" && (Ks.has(e) || qs.has(e)) ? ec(new k(e)) : { reason: "failed" };
9846
9958
  }
9847
9959
  //#endregion
9848
9960
  //#region src/classes/stat/CallLifecycleStats.ts
9849
- var Zs = {
9961
+ var nc = {
9850
9962
  wallNow: () => Date.now(),
9851
9963
  monotonicNow: () => performance.now()
9852
9964
  };
9853
- function Qs(e) {
9965
+ function rc(e) {
9854
9966
  return e === "anonym_join" ? "join" : e;
9855
9967
  }
9856
- var $s = class {
9857
- constructor(e, t = Zs) {
9968
+ var ic = class {
9969
+ constructor(e, t = nc) {
9858
9970
  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;
9859
9971
  }
9860
9972
  get firstMediaSentReported() {
@@ -9866,7 +9978,7 @@ var $s = class {
9866
9978
  markInitializationStarted({ source: e, conversationId: t }) {
9867
9979
  if (this._destroyed || this._callStartLabel !== null) return;
9868
9980
  let n = this._clock.wallNow();
9869
- this._callStartLabel = Qs(e), this._lifecycleStartedAtMonotonic = this._clock.monotonicNow(), t && (this._conversationId = t), this._record({
9981
+ this._callStartLabel = rc(e), this._lifecycleStartedAtMonotonic = this._clock.monotonicNow(), t && (this._conversationId = t), this._record({
9870
9982
  name: U.CALL_INIT,
9871
9983
  source: e
9872
9984
  }, n);
@@ -9894,7 +10006,7 @@ var $s = class {
9894
10006
  !this._canRecord() || this._firstMediaSent || (this._firstMediaSent = !0, this._record({ name: U.FIRST_MEDIA_SENT }));
9895
10007
  }
9896
10008
  markFinished(e) {
9897
- this._finish(Xs(e));
10009
+ this._finish(tc(e));
9898
10010
  }
9899
10011
  markTerminated() {
9900
10012
  this._finish({ reason: "terminated" });
@@ -9945,7 +10057,7 @@ var $s = class {
9945
10057
  ...n && { immediately: !0 }
9946
10058
  });
9947
10059
  }
9948
- }, ec = class {
10060
+ }, ac = class {
9949
10061
  constructor(e, t) {
9950
10062
  h(this, "_logger", void 0), h(this, "_codecUsages", /* @__PURE__ */ new Map()), h(this, "getCurrentTransportTopology", void 0), this._logger = e, this.getCurrentTransportTopology = t;
9951
10063
  }
@@ -10008,7 +10120,7 @@ var $s = class {
10008
10120
  this.report(e);
10009
10121
  }), this._codecUsages.clear();
10010
10122
  }
10011
- }, tc = class {
10123
+ }, oc = class {
10012
10124
  constructor(e) {
10013
10125
  h(this, "_logger", void 0), h(this, "_eventualLogs", /* @__PURE__ */ new Set()), h(this, "_lastCallStatContext", null), this._logger = e;
10014
10126
  }
@@ -10051,7 +10163,7 @@ var $s = class {
10051
10163
  for (let [t, r] of Object.entries(e)) r !== void 0 && (r === null ? delete n[t] : n[t] = r);
10052
10164
  this._logger.logClientStats(n, { occurredAt: t });
10053
10165
  }
10054
- }, nc = class {
10166
+ }, sc = class {
10055
10167
  constructor(e) {
10056
10168
  if (h(this, "q", void 0), h(this, "inits", []), h(this, "n", [
10057
10169
  1,
@@ -10110,7 +10222,7 @@ var $s = class {
10110
10222
  5
10111
10223
  ];
10112
10224
  }
10113
- }, rc = class {
10225
+ }, cc = class {
10114
10226
  constructor() {
10115
10227
  h(this, "n", 0), h(this, "mean", 0);
10116
10228
  }
@@ -10122,9 +10234,9 @@ var $s = class {
10122
10234
  get avg() {
10123
10235
  return this.n ? this.mean : NaN;
10124
10236
  }
10125
- }, ic = class {
10237
+ }, lc = class {
10126
10238
  constructor() {
10127
- h(this, "count", 0), h(this, "minVal", Infinity), h(this, "maxVal", -Infinity), h(this, "mean", new rc()), h(this, "p50", new nc(.5)), h(this, "p95", new nc(.95));
10239
+ h(this, "count", 0), h(this, "minVal", Infinity), h(this, "maxVal", -Infinity), h(this, "mean", new cc()), h(this, "p50", new sc(.5)), h(this, "p95", new sc(.95));
10128
10240
  }
10129
10241
  add(e) {
10130
10242
  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++;
@@ -10142,18 +10254,18 @@ var $s = class {
10142
10254
  get hasData() {
10143
10255
  return this.count > 0;
10144
10256
  }
10145
- }, ac = class {
10257
+ }, uc = 120 * 1e3, dc = class {
10146
10258
  constructor(e) {
10147
10259
  h(this, "_logger", void 0), h(this, "trackerByTransport", {
10148
- ws: new ic(),
10149
- wt: new ic()
10260
+ ws: new lc(),
10261
+ wt: new lc()
10150
10262
  }), h(this, "lastSeen", {}), this._logger = e;
10151
10263
  }
10152
10264
  mark(e) {
10153
10265
  let t = Date.now(), n = this.lastSeen[e];
10154
10266
  if (typeof n == "number") {
10155
10267
  let r = t - n;
10156
- r >= 0 && this.trackerByTransport[e].add(r);
10268
+ r >= 0 && r <= uc && this.trackerByTransport[e].add(r);
10157
10269
  }
10158
10270
  this.lastSeen[e] = t;
10159
10271
  }
@@ -10173,19 +10285,22 @@ var $s = class {
10173
10285
  });
10174
10286
  });
10175
10287
  }
10288
+ resetBaseline() {
10289
+ this.lastSeen = {};
10290
+ }
10176
10291
  destroy() {
10177
10292
  this.trackerByTransport = {
10178
- ws: new ic(),
10179
- wt: new ic()
10293
+ ws: new lc(),
10294
+ wt: new lc()
10180
10295
  }, this.lastSeen = {};
10181
10296
  }
10182
- }, oc = class {
10297
+ }, fc = class {
10183
10298
  constructor(e) {
10184
10299
  h(this, "_logger", void 0), h(this, "trackerByCommand", /* @__PURE__ */ new Map()), this._logger = e;
10185
10300
  }
10186
10301
  mark(e, t, n) {
10187
10302
  let r = `${e}|${n}`, i;
10188
- this.trackerByCommand.has(r) ? i = this.trackerByCommand.get(r) : (i = new ic(), this.trackerByCommand.set(r, i)), i.add(t);
10303
+ this.trackerByCommand.has(r) ? i = this.trackerByCommand.get(r) : (i = new lc(), this.trackerByCommand.set(r, i)), i.add(t);
10189
10304
  }
10190
10305
  logMetrics() {
10191
10306
  for (let [e, t] of this.trackerByCommand.entries()) {
@@ -10207,9 +10322,9 @@ var $s = class {
10207
10322
  destroy() {
10208
10323
  this.trackerByCommand.clear();
10209
10324
  }
10210
- }, sc = class {
10325
+ }, pc = class {
10211
10326
  constructor(e, t, n, r) {
10212
- 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 Ls(e, t, n, r), this.lifecycle = new $s(this.logger), this.statAggregator = new tc(this.logger), this.codecStatsAggregator = new ec(this.logger, r), this.pings = new ac(this.logger), this.signalingCommands = new oc(this.logger), this.apiCalls = new Rs(this.statAggregator), this._api = e, this._api.setApiCallStats(this.apiCalls);
10327
+ 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 Hs(e, t, n, r), this.lifecycle = new ic(this.logger), this.statAggregator = new oc(this.logger), this.codecStatsAggregator = new ac(this.logger, r), this.pings = new dc(this.logger), this.signalingCommands = new fc(this.logger), this.apiCalls = new Us(this.statAggregator), this._api = e, this._api.setApiCallStats(this.apiCalls);
10213
10328
  }
10214
10329
  prepareForUnload() {
10215
10330
  N.statQueueEnabled && (this._unloading = !0, this.logger.enterUnloadMode(), this.pings.logMetrics(), this.signalingCommands.logMetrics());
@@ -10217,6 +10332,9 @@ var $s = class {
10217
10332
  restoreAfterUnload() {
10218
10333
  N.statQueueEnabled && (this._unloading = !1, this.logger.exitUnloadMode());
10219
10334
  }
10335
+ resetPingBaseline() {
10336
+ this.pings.resetBaseline();
10337
+ }
10220
10338
  logHangup(e) {
10221
10339
  this.lifecycle.markFinished(e);
10222
10340
  }
@@ -10224,9 +10342,9 @@ var $s = class {
10224
10342
  this.codecStatsAggregator.destroy(), this.pings.logMetrics(), this.pings.destroy(), this.signalingCommands.logMetrics(), this.signalingCommands.destroy();
10225
10343
  }
10226
10344
  destroy() {
10227
- 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 && Fs.notifyCallFinished();
10345
+ 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();
10228
10346
  }
10229
- }, cc = class {
10347
+ }, mc = class {
10230
10348
  constructor(e) {
10231
10349
  h(this, "_statAggregator", void 0), h(this, "_isCallMarked", !1), h(this, "_isFinished", !1), h(this, "_callType", null), this._statAggregator = e;
10232
10350
  }
@@ -10251,8 +10369,8 @@ var $s = class {
10251
10369
  call_type: this._callType
10252
10370
  }));
10253
10371
  }
10254
- }, lc = 1e3, uc = 1e4;
10255
- function dc(e, t, n, r) {
10372
+ }, hc = 1e3, gc = 1e4;
10373
+ function _c(e, t, n, r) {
10256
10374
  return new k(e, {
10257
10375
  callError: {
10258
10376
  scope: "external",
@@ -10263,11 +10381,11 @@ function dc(e, t, n, r) {
10263
10381
  message: r
10264
10382
  });
10265
10383
  }
10266
- var fc = 15, $ = class e extends b {
10384
+ var vc = 15, $ = class e extends b {
10267
10385
  constructor(e, t) {
10268
- 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", ko((e) => {
10386
+ 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) => {
10269
10387
  if (this._mediaSource) return this._stats.logger.log(C.MEDIA_STATUS, e ? "video_1" : "video_0"), this._mediaSource.toggleVideo(e);
10270
- })), h(this, "_toggleLocalAudio", ko((e) => {
10388
+ })), h(this, "_toggleLocalAudio", Po((e) => {
10271
10389
  if (this._mediaSource) return this._stats.logger.log(C.MEDIA_STATUS, e ? "audio_1" : "audio_0"), this._mediaSource.toggleAudio(e);
10272
10390
  })), h(this, "_changeMediaSettings", M.debounce(async (e) => {
10273
10391
  if (this._signaling.ready) try {
@@ -10279,7 +10397,7 @@ var fc = 15, $ = class e extends b {
10279
10397
  captureAudio: !1
10280
10398
  });
10281
10399
  }
10282
- }, 100)), this._stats = new sc(e, t, () => this._conversation?.id || null, () => this._transport?.getTopology() ?? this._conversation?.topology), this._api = e, this._signaling = new eo(this._debug, this._stats.logger, this._stats.statAggregator, this._stats.pings, this._stats.signalingCommands), this._signalingActor = new Ho(this._onSignalingNotification.bind(this), this._debug), this._displayLayoutRequester = new Ro({
10400
+ }, 100)), this._stats = new pc(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({
10283
10401
  api: this._api,
10284
10402
  debug: this._debug,
10285
10403
  getParticipants: () => this._participants,
@@ -10287,16 +10405,18 @@ var fc = 15, $ = class e extends b {
10287
10405
  updateDisplayLayout: (e) => this.updateDisplayLayout(e),
10288
10406
  onNonFatalError: (e) => this._onNonFatalError(e)
10289
10407
  }), this._onUnload = () => {
10290
- this._stopFirstMediaSentProbe(), this._conversation && this._api && this._sendHangupApi(this._conversation.id, this._state === "IDLE" ? O.CANCELED : O.HUNGUP), this._stats.prepareForUnload(), this._stats.destroy();
10408
+ 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();
10291
10409
  }, this._onRestore = () => {
10292
- this._stats.restoreAfterUnload();
10293
- }, window.addEventListener("pagehide", this._onUnload), window.addEventListener("pageshow", this._onRestore), this._statFirstMediaReceived = new cc(this._stats.statAggregator), this._audioOutput = new jo(this._statFirstMediaReceived, N.transparentAudio, this._debug, this._stats.logger), N.videoTracksCount > 0 && (this._cooldownQueueCleanupTimer = window.setInterval(this._cleanupCooldownQueue.bind(this), lc));
10410
+ this._stats.resetPingBaseline(), this._stats.restoreAfterUnload();
10411
+ }, this._onVisibilityChange = () => {
10412
+ document.visibilityState === "hidden" && this._stats.resetPingBaseline();
10413
+ }, window.addEventListener("pagehide", this._onUnload), window.addEventListener("pageshow", this._onRestore), document.addEventListener("visibilitychange", this._onVisibilityChange), this._statFirstMediaReceived = new mc(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), hc));
10294
10414
  }
10295
10415
  static current() {
10296
10416
  return B.getActive() ?? (N.hold ? null : B.getFirst());
10297
10417
  }
10298
10418
  static hangupAfterInit(e) {
10299
- let t = pc;
10419
+ let t = yc;
10300
10420
  if (t) {
10301
10421
  if (typeof e == "function" && (t._onFastHangup = e), t._delayedHangup === !1 && !t._conversation) {
10302
10422
  t._delayedHangup = !0, t._abortController?.abort(new k(O.CANCELED));
@@ -10324,7 +10444,7 @@ var fc = 15, $ = class e extends b {
10324
10444
  return this._state === "HELD";
10325
10445
  }
10326
10446
  get isIncomingRinging() {
10327
- return this._conversation?.direction === to.INCOMING && this._state === "IDLE";
10447
+ return this._conversation?.direction === oo.INCOMING && this._state === "IDLE";
10328
10448
  }
10329
10449
  static debugSessionId() {
10330
10450
  return e.current()?.debugSessionId ?? null;
@@ -10350,7 +10470,7 @@ var fc = 15, $ = class e extends b {
10350
10470
  R.onNonFatalError(Error(e), this.id);
10351
10471
  }
10352
10472
  getIncomingCallerExternalId() {
10353
- return this._conversation?.direction === to.INCOMING ? Object.values(this._participants).find((e) => !this._isMe(e.id))?.externalId ?? null : null;
10473
+ return this._conversation?.direction === oo.INCOMING ? Object.values(this._participants).find((e) => !this._isMe(e.id))?.externalId ?? null : null;
10354
10474
  }
10355
10475
  _buildInternalParams() {
10356
10476
  let e = {
@@ -10360,24 +10480,24 @@ var fc = 15, $ = class e extends b {
10360
10480
  platform: N.platform,
10361
10481
  protocolVersion: N.protocolVersion,
10362
10482
  domainId: N.domain,
10363
- capabilities: Fa.getFlags()
10483
+ capabilities: Ba.getFlags()
10364
10484
  };
10365
10485
  return JSON.stringify(e);
10366
10486
  }
10367
10487
  async onStart({ opponentIds: e, opponentType: t, mediaOptions: n, payload: r = "", joiningAllowed: i = !1, requireAuthToJoin: a = !1, onlyAdminCanShareMovie: o, externalIds: s, onFastStart: c, conversationId: l }) {
10368
- let u = l ?? M.uuid(), d = (e?.length ?? 0) + (s?.length ?? 0), f = t === no.USER && d === 1 ? N.calleeUnavailableWaitingTime : void 0;
10488
+ let u = l ?? M.uuid(), d = (e?.length ?? 0) + (s?.length ?? 0), f = t === so.USER && d === 1 ? N.calleeUnavailableWaitingTime : void 0;
10369
10489
  this._stats.lifecycle.markInitializationStarted({
10370
10490
  source: "outgoing",
10371
10491
  conversationId: u
10372
- }), this._debug.setConversationId(u), pc = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
10492
+ }), this._debug.setConversationId(u), yc = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
10373
10493
  try {
10374
10494
  this._mediaSource = this._createMediaSource(), await this._mediaSource.request(n);
10375
10495
  let l = this._mediaSource.mediaSettings;
10376
- t === no.CHAT || e && e.length > 1 ? this._logWithMediaSettings(C.OUTGOING_MULTIPARTY_CALL, l) : this._logWithMediaSettings(C.OUTGOING_CALL, l);
10496
+ t === so.CHAT || e && e.length > 1 ? this._logWithMediaSettings(C.OUTGOING_MULTIPARTY_CALL, l) : this._logWithMediaSettings(C.OUTGOING_CALL, l);
10377
10497
  let d = await this._startConversation({
10378
10498
  opponentIds: e,
10379
10499
  opponentType: t,
10380
- direction: to.OUTGOING,
10500
+ direction: oo.OUTGOING,
10381
10501
  mediaOptions: n,
10382
10502
  payload: r,
10383
10503
  joiningAllowed: i,
@@ -10401,18 +10521,18 @@ var fc = 15, $ = class e extends b {
10401
10521
  let e = B.get(this._conversation.id);
10402
10522
  e && e !== this && e._close(new k(O.HUNGUP, { remote: !0 }));
10403
10523
  }
10404
- return B.add(this), await B.setActive(this.id), pc = null, this._conversation.concurrent && await this._acceptConcurrent(), f && !this._registeredPeerReceived && this._state !== "CLOSE" && (this._calleeUnavailableTimer = window.setTimeout(() => {
10524
+ return B.add(this), await B.setActive(this.id), yc = null, this._conversation.concurrent && await this._acceptConcurrent(), f && !this._registeredPeerReceived && this._state !== "CLOSE" && (this._calleeUnavailableTimer = window.setTimeout(() => {
10405
10525
  this._calleeUnavailableTimer = null, this._close(new k(O.CALLEE_UNAVAILABLE), { signalingReason: O.CANCELED });
10406
10526
  }, f)), this._conversation;
10407
10527
  } catch (e) {
10408
- throw pc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to start conversation" }), e;
10528
+ throw yc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to start conversation" }), e;
10409
10529
  }
10410
10530
  }
10411
10531
  async onJoin(e) {
10412
10532
  this._stats.lifecycle.markInitializationStarted({
10413
10533
  source: e.anonymous ? "anonym_join" : "join",
10414
10534
  conversationId: e.conversationId
10415
- }), pc = 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);
10535
+ }), yc = 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);
10416
10536
  try {
10417
10537
  let t = !!e.observedIds?.length;
10418
10538
  if (t && N.videoTracksCount > 0) throw this._debug.error("Observer mode: please set videoTracksCount=0"), new k(O.UNSUPPORTED, { callError: {
@@ -10429,9 +10549,9 @@ var fc = 15, $ = class e extends b {
10429
10549
  code: "conversation",
10430
10550
  description: "not-initialized-after-join"
10431
10551
  } });
10432
- 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), pc = null, this._signaling.readyToSend(), R.onLocalStatus(this._conversation.waitForAdmin ? P.WAIT_FOR_ADMIN : P.WAITING_HALL, this.id), this._conversation) : this._onJoinPart2(r);
10552
+ 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), yc = null, this._signaling.readyToSend(), R.onLocalStatus(this._conversation.waitForAdmin ? P.WAIT_FOR_ADMIN : P.WAITING_HALL, this.id), this._conversation) : this._onJoinPart2(r);
10433
10553
  } catch (e) {
10434
- throw pc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
10554
+ throw yc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
10435
10555
  }
10436
10556
  }
10437
10557
  async _onJoinPart2(e, t = !0, n = !1) {
@@ -10446,7 +10566,7 @@ var fc = 15, $ = class e extends b {
10446
10566
  if (this._delayedHangup) throw new k(O.CANCELED);
10447
10567
  this._processConnectionSharedMovieInfo(e), this._processConversationUrlSharingInfo(e), this._processConnectionAsrInfo(e);
10448
10568
  let r = this._extractExternalRoomsData(e.rooms?.rooms, e.rooms?.roomId);
10449
- 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), pc = null);
10569
+ 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), yc = null);
10450
10570
  let i = this._extractLocalParticipantFromConnection(e);
10451
10571
  if (i) {
10452
10572
  let e = M.mapParticipantState(i);
@@ -10454,7 +10574,7 @@ var fc = 15, $ = class e extends b {
10454
10574
  }
10455
10575
  return t && this._openTransport(Object.values(this._participants), !1), this._conversation;
10456
10576
  } catch (e) {
10457
- throw pc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
10577
+ throw yc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
10458
10578
  }
10459
10579
  }
10460
10580
  _extractExternalRooms(e) {
@@ -10474,7 +10594,7 @@ var fc = 15, $ = class e extends b {
10474
10594
  B.reserve(e), this._reservedId = e, a && this._api.setUserId(a), this._stats.lifecycle.markInitializationStarted({
10475
10595
  source: "incoming",
10476
10596
  conversationId: e
10477
- }), this._debug.setConversationId(e), pc = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
10597
+ }), this._debug.setConversationId(e), yc = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
10478
10598
  try {
10479
10599
  let a = await this._prepareConversation(e, t, n, r, i);
10480
10600
  if (this._mediaSource = this._createMediaSource(), !this._conversation) throw new k(O.UNKNOWN_ERROR, { callError: {
@@ -10483,20 +10603,20 @@ var fc = 15, $ = class e extends b {
10483
10603
  description: "incoming-not-initialized"
10484
10604
  } });
10485
10605
  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);
10486
- 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), pc = null, this._delayedHangup) throw new k(O.CANCELED);
10606
+ 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), yc = null, this._delayedHangup) throw new k(O.CANCELED);
10487
10607
  } catch (e) {
10488
- throw pc = null, this._cleanupRegistry(), this._close(e, {
10608
+ throw yc = null, this._cleanupRegistry(), this._close(e, {
10489
10609
  errorText: "Unable to handle inbound call push",
10490
10610
  signalingReason: e instanceof k && e.hangup === O.BUSY ? O.BUSY : void 0
10491
10611
  }), e;
10492
10612
  }
10493
10613
  }
10494
10614
  _isInWaitingHall(e) {
10495
- return !e.conversation || !e.conversation.options.includes(ao.WAITING_HALL) ? !1 : this._isRestricted(e);
10615
+ return !e.conversation || !e.conversation.options.includes(uo.WAITING_HALL) ? !1 : this._isRestricted(e);
10496
10616
  }
10497
10617
  _isWaitForAdmin(e) {
10498
10618
  if (!e.conversation) return !1;
10499
- let t = e.conversation.options.includes(ao.WAIT_FOR_ADMIN), n = e.conversation.options.includes(ao.ADMIN_IS_HERE);
10619
+ let t = e.conversation.options.includes(uo.WAIT_FOR_ADMIN), n = e.conversation.options.includes(uo.ADMIN_IS_HERE);
10500
10620
  return !t || t && n ? !1 : this._isRestricted(e);
10501
10621
  }
10502
10622
  _isRestricted(e) {
@@ -10504,7 +10624,7 @@ var fc = 15, $ = class e extends b {
10504
10624
  return t && t.restricted || !1;
10505
10625
  }
10506
10626
  _isAudienceMode(e) {
10507
- return e.conversation?.options?.includes(ao.AUDIENCE_MODE) || !1;
10627
+ return e.conversation?.options?.includes(uo.AUDIENCE_MODE) || !1;
10508
10628
  }
10509
10629
  _isAudienceModeListener() {
10510
10630
  return this._conversation?.audienceMode && this._conversation?.restricted;
@@ -10534,7 +10654,7 @@ var fc = 15, $ = class e extends b {
10534
10654
  let i = atob(n), a = new Uint8Array(i.length);
10535
10655
  for (let e = 0; e < i.length; e++) a[e] = i.charCodeAt(e);
10536
10656
  try {
10537
- let e = Oo(a, r).reduce((e, t) => (e += String.fromCharCode(t), e), ""), { srcp: t, stne: n, tkn: i, trne: o, trnp: s, trnu: c, wse: l, wte: u } = JSON.parse(e);
10657
+ 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);
10538
10658
  return {
10539
10659
  token: i,
10540
10660
  endpoint: l,
@@ -10737,10 +10857,10 @@ var fc = 15, $ = class e extends b {
10737
10857
  let t = await this._api.getConversationParams(e);
10738
10858
  this._debug.debug("Api.getConversationParams", t);
10739
10859
  let { turn_server: n, stun_server: r } = t;
10740
- return N.iceServers = Do(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;
10860
+ 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;
10741
10861
  }
10742
10862
  _setConversationParams({ turn_server: e, stun_server: t, endpoint: n, wt_endpoint: r, token: i, client_type: a }) {
10743
- N.iceServers = Do(t, e), N.wssBase = n, N.wssToken = i, r && (N.wtsBase = r), a && (N.clientType = a);
10863
+ N.iceServers = Mo(t, e), N.wssBase = n, N.wssToken = i, r && (N.wtsBase = r), a && (N.clientType = a);
10744
10864
  }
10745
10865
  _buildSignalingEndpoint({ baseEndpoint: e, userId: t, type: n, deviceIdx: r, conversationId: i, token: a, conversationParams: o }) {
10746
10866
  let s = new URL(e), c = s.searchParams;
@@ -10772,10 +10892,10 @@ var fc = 15, $ = class e extends b {
10772
10892
  isVideo: f,
10773
10893
  joiningAllowed: a,
10774
10894
  requireAuthToJoin: o
10775
- }, this._abortController?.signal), !e) throw dc(O.FAST_START_ERROR, "invalid-response", "fast-start-response-empty");
10895
+ }, this._abortController?.signal), !e) throw _c(O.FAST_START_ERROR, "invalid-response", "fast-start-response-empty");
10776
10896
  if (!e.internalCallerParams) {
10777
10897
  let t = e.rejectedParticipants[0]?.status;
10778
- throw dc(O.FAST_START_ERROR, t ? "fast-start" : "invalid-response", t ?? "fast-start-internal-caller-params-empty", JSON.stringify(e));
10898
+ throw _c(O.FAST_START_ERROR, t ? "fast-start" : "invalid-response", t ?? "fast-start-internal-caller-params-empty", JSON.stringify(e));
10779
10899
  }
10780
10900
  } catch (e) {
10781
10901
  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) });
@@ -10797,10 +10917,10 @@ var fc = 15, $ = class e extends b {
10797
10917
  token: new URL(t.endpoint).searchParams.get("token") ?? ""
10798
10918
  }, this._debug.debug("FastStart", p), m = "fastStart";
10799
10919
  } catch {
10800
- throw dc(O.FAST_START_ERROR, "invalid-response", "fast-start-internal-caller-params-invalid");
10920
+ throw _c(O.FAST_START_ERROR, "invalid-response", "fast-start-internal-caller-params-invalid");
10801
10921
  }
10802
10922
  } else p = await this._api.startConversation(d, e, t, f, i, a, o, { onlyAdminCanShareMovie: s }, c), this._debug.debug("Api.startConversation", p), m = "startConversation";
10803
- Mo(p, m), this._setConversationParams(p), this._stats.lifecycle.bindConversationId(p.id);
10923
+ Lo(p, m), this._setConversationParams(p), this._stats.lifecycle.bindConversationId(p.id);
10804
10924
  let ee = await this._connectSignaling(br.START, p);
10805
10925
  return this._setConversation(p, ee, n), this._stats.lifecycle.markCallStarted(), ee;
10806
10926
  }
@@ -10825,9 +10945,9 @@ var fc = 15, $ = class e extends b {
10825
10945
  joinLink: i,
10826
10946
  isVideo: c,
10827
10947
  internalParams: this._buildInternalParams()
10828
- }, this._abortController?.signal), !e) throw dc(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-response-empty");
10829
- if (!e.internalCallerParams) throw dc(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-empty", JSON.stringify(e));
10830
- if (!e.conversationId) throw dc(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-conversation-id-empty", JSON.stringify(e));
10948
+ }, this._abortController?.signal), !e) throw _c(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-response-empty");
10949
+ if (!e.internalCallerParams) throw _c(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-empty", JSON.stringify(e));
10950
+ if (!e.conversationId) throw _c(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-conversation-id-empty", JSON.stringify(e));
10831
10951
  } catch (e) {
10832
10952
  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) });
10833
10953
  }
@@ -10845,7 +10965,7 @@ var fc = 15, $ = class e extends b {
10845
10965
  token: new URL(t.endpoint).searchParams.get("token") ?? ""
10846
10966
  }, this._debug.debug("FastJoin", l), u = "fastJoin";
10847
10967
  } catch (e) {
10848
- throw e instanceof k ? e : dc(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-invalid");
10968
+ throw e instanceof k ? e : _c(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-invalid");
10849
10969
  }
10850
10970
  } else if (t) l = await this._api.joinConversation(t, c, r), u = "joinConversation";
10851
10971
  else if (i) l = await this._api.joinConversationByLink(i, c, a, o), u = "joinConversationByLink";
@@ -10854,13 +10974,13 @@ var fc = 15, $ = class e extends b {
10854
10974
  code: "join",
10855
10975
  description: "target-missing"
10856
10976
  } });
10857
- if (this._debug.debug("Api.joinConversation", l), l.id && this._stats.lifecycle.bindConversationId(l.id), Mo(l, u), l.id) {
10977
+ if (this._debug.debug("Api.joinConversation", l), l.id && this._stats.lifecycle.bindConversationId(l.id), Lo(l, u), l.id) {
10858
10978
  if (B.has(l.id)) throw new k(O.HAS_ACTIVE_CALL);
10859
10979
  B.reserve(l.id), this._reservedId = l.id;
10860
10980
  }
10861
10981
  this._setConversationParams(l);
10862
10982
  let d = await this._connectSignaling(br.JOIN, l);
10863
- return this._setConversation(l, d, to.JOINING), this._stats.lifecycle.markCallStarted(), d;
10983
+ return this._setConversation(l, d, oo.JOINING), this._stats.lifecycle.markCallStarted(), d;
10864
10984
  }
10865
10985
  async _prepareConversation(e, t = j.USER, n, r, i) {
10866
10986
  G.setMark(U.SIGNALING_CONNECTED), this._debug.debug("Conversation: push", {
@@ -10922,7 +11042,7 @@ var fc = 15, $ = class e extends b {
10922
11042
  }), l.wt_endpoint = c);
10923
11043
  }
10924
11044
  let u = await this._connectSignaling(br.ACCEPT, l);
10925
- 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, to.INCOMING, t), u);
11045
+ 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);
10926
11046
  }
10927
11047
  _createParticipant(e, t, n = !0) {
10928
11048
  let r = Object.assign({
@@ -10949,7 +11069,7 @@ var fc = 15, $ = class e extends b {
10949
11069
  let e = this._getParticipantId(t ?? r.id);
10950
11070
  e && (r.externalId = e);
10951
11071
  }
10952
- 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 = go.create(r.connectionStatus), r;
11072
+ 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;
10953
11073
  }
10954
11074
  _getParticipantId(e) {
10955
11075
  let t = this._api.userId(e);
@@ -11028,7 +11148,7 @@ var fc = 15, $ = class e extends b {
11028
11148
  }
11029
11149
  _createMediaSource() {
11030
11150
  let e = new Yt(this._debug, this._stats.logger);
11031
- return this.subscribe(e, qt.SOURCE_CHANGED, this._onLocalMediaStreamChanged.bind(this)), this.subscribe(e, qt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._audioFix = new Ao(e, this._debug, this._stats.logger), e;
11151
+ 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;
11032
11152
  }
11033
11153
  async _connectSignaling(e, t) {
11034
11154
  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));
@@ -11036,7 +11156,7 @@ var fc = 15, $ = class e extends b {
11036
11156
  return this._stats.statAggregator.logEventualStatSinceMark({ name: U.SIGNALING_CONNECTED }), n;
11037
11157
  }
11038
11158
  async _processConnection(e) {
11039
- 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(ro.ATTENDEE, e.chatRoom.totalCount, e.chatRoom.firstParticipants, null, null);
11159
+ 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);
11040
11160
  }
11041
11161
  _onConversationParticipantListChunk(e) {
11042
11162
  let t = e.participants;
@@ -11105,7 +11225,7 @@ var fc = 15, $ = class e extends b {
11105
11225
  _registerParticipantLocalMuteState({ muteStates: e, unmuteOptions: t }) {
11106
11226
  if (!e) return;
11107
11227
  let n = async () => {
11108
- let n = bo(e, co.MUTE), r = bo(e, co.MUTE_PERMANENT);
11228
+ let n = To(e, mo.MUTE), r = To(e, mo.MUTE_PERMANENT);
11109
11229
  for (let i of [n, r]) i.length && await this._onMuteParticipant({
11110
11230
  muteStates: e,
11111
11231
  unmuteOptions: t,
@@ -11119,8 +11239,8 @@ var fc = 15, $ = class e extends b {
11119
11239
  if (!(!N.enableSessionStateUpdates || this._isMe(e))) return t;
11120
11240
  }
11121
11241
  _buildConnectionStatus(e, t, n, r = !1) {
11122
- return go.create({
11123
- transport: r ? P.ONHOLD : go.fromTransportState(n) ?? P.WAITING,
11242
+ return xo.create({
11243
+ transport: r ? P.ONHOLD : xo.fromTransportState(n) ?? P.WAITING,
11124
11244
  sessionState: this._remoteParticipantSessionState(e, t),
11125
11245
  sessionStateApplicable: this._isParticipantSessionStateApplicable(e)
11126
11246
  });
@@ -11129,12 +11249,12 @@ var fc = 15, $ = class e extends b {
11129
11249
  return N.enableSessionStateUpdates && !this._isMe(e) && this._conversation?.topology === J.SERVER;
11130
11250
  }
11131
11251
  _setTransportStatus(e, t) {
11132
- return go.setTransport(e.connectionStatus, t);
11252
+ return xo.setTransport(e.connectionStatus, t);
11133
11253
  }
11134
11254
  _setSessionState(e, t) {
11135
- let n = go.setSessionStateApplicable(e.connectionStatus, this._isParticipantSessionStateApplicable(e.id));
11255
+ let n = xo.setSessionStateApplicable(e.connectionStatus, this._isParticipantSessionStateApplicable(e.id));
11136
11256
  this._emitParticipantTransition(e, n);
11137
- let r = e.connectionStatus.sessionStateApplicable && e.id === this._activeSpeakerId && e.connectionStatus.transport === P.CONNECTED, i = go.setSessionState(e.connectionStatus, t, r);
11257
+ let r = e.connectionStatus.sessionStateApplicable && e.id === this._activeSpeakerId && e.connectionStatus.transport === P.CONNECTED, i = xo.setSessionState(e.connectionStatus, t, r);
11138
11258
  return this._emitParticipantTransition(e, i), i;
11139
11259
  }
11140
11260
  _emitParticipantTransition(e, t, n = null) {
@@ -11205,11 +11325,11 @@ var fc = 15, $ = class e extends b {
11205
11325
  this._onRoomSwitched(t, !0);
11206
11326
  }
11207
11327
  _processMuteStates(e, t = !1) {
11208
- let n = xo(e);
11328
+ let n = Eo(e);
11209
11329
  this._setMuteStatesForRoomId(n, null);
11210
11330
  for (let t of e.rooms?.rooms ?? []) this._setMuteStatesForRoomId(t.muteStates, t.id);
11211
11331
  let r = this._getMuteStatesForCurrentRoom();
11212
- t && (r = To(e, r));
11332
+ t && (r = Ao(e, r));
11213
11333
  let i = Object.keys(r), a = this._conversation?.roomId;
11214
11334
  i.length && this._onMuteParticipant({
11215
11335
  muteStates: r,
@@ -11229,15 +11349,15 @@ var fc = 15, $ = class e extends b {
11229
11349
  }
11230
11350
  _allocateTransport() {
11231
11351
  if (!this._conversation || !this._mediaSource) return;
11232
- this._transport = new Ca(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 Lo(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));
11233
- let e = this._conversation.direction === to.OUTGOING && !this._conversation.concurrent, t = this._participants;
11352
+ 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));
11353
+ let e = this._conversation.direction === oo.OUTGOING && !this._conversation.concurrent, t = this._participants;
11234
11354
  for (let n of Object.values(t)) (n.state === X.ACCEPTED || n.state === X.CALLED) && this._allocateParticipantTransport(n.id, e);
11235
11355
  }
11236
11356
  _createSpeakerDetector() {
11237
- this._transport && this._conversation && (this._volumesDetector = new Wo(this._transport), this.subscribe(this._volumesDetector, Uo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this._speakerDetector = new Ko(this._volumesDetector, this._transport, this._conversation.topology), this.subscribe(this._speakerDetector, Go.SPEAKER_CHANGED, this._onSpeakerChanged.bind(this)), this._localVolumeDetector = new Vo(this._mediaSource));
11357
+ 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));
11238
11358
  }
11239
11359
  _createSpecListener() {
11240
- this._transport && this._volumesDetector && (this._specListener = new Yo(this._transport, this._volumesDetector, this._participants, this._debug, this._stats.logger));
11360
+ this._transport && this._volumesDetector && (this._specListener = new es(this._transport, this._volumesDetector, this._participants, this._debug, this._stats.logger));
11241
11361
  }
11242
11362
  _logDevices() {
11243
11363
  let e = E.getCameras().length, t = E.getMicrophones().length;
@@ -11257,7 +11377,7 @@ var fc = 15, $ = class e extends b {
11257
11377
  }
11258
11378
  }
11259
11379
  _cleanupListeners() {
11260
- this.unsubscribe(), window.removeEventListener("pagehide", this._onUnload), window.removeEventListener("pageshow", this._onRestore);
11380
+ this.unsubscribe(), window.removeEventListener("pagehide", this._onUnload), window.removeEventListener("pageshow", this._onRestore), document.removeEventListener("visibilitychange", this._onVisibilityChange);
11261
11381
  }
11262
11382
  _cleanupMediaSource() {
11263
11383
  this._mediaSource && (this._mediaSource.destroy(), this._mediaSource = null);
@@ -11336,7 +11456,7 @@ var fc = 15, $ = class e extends b {
11336
11456
  _onRemoveParticipant(e) {
11337
11457
  this._debug.debug(`Remove participant [${e}]`);
11338
11458
  let t = [], n = this._participants;
11339
- for (let r = 0; r <= fc; r++) {
11459
+ for (let r = 0; r <= vc; r++) {
11340
11460
  let i = n[M.compose(e, r)];
11341
11461
  i && t.push(i);
11342
11462
  }
@@ -11426,11 +11546,11 @@ var fc = 15, $ = class e extends b {
11426
11546
  this._waitingHallHoldPending = !1, await this._resumeLocalMedia(t, this._getWaitingForPromotionStatus()), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener();
11427
11547
  return;
11428
11548
  }
11429
- let n = Na.get();
11549
+ let n = Ra.get();
11430
11550
  await this._signaling.hold(!1, n), this._restoreStateAfterHold();
11431
11551
  let r = null;
11432
11552
  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") {
11433
- let e = this._conversation?.direction === to.OUTGOING && !this._conversation.concurrent;
11553
+ let e = this._conversation?.direction === oo.OUTGOING && !this._conversation.concurrent;
11434
11554
  this._openTransport(r ?? Object.values(this._participants), e);
11435
11555
  }
11436
11556
  }
@@ -11553,13 +11673,13 @@ var fc = 15, $ = class e extends b {
11553
11673
  let n = Fn(e), a = i[n.participantId];
11554
11674
  if (a) {
11555
11675
  let e;
11556
- typeof t == "number" ? e = fo(t) : (this._debug.warn(`Unexpected error code ${t} received for participant ${n.participantId}`), e = uo.UNKNOWN_ERROR), r.push({
11676
+ typeof t == "number" ? e = _o(t) : (this._debug.warn(`Unexpected error code ${t} received for participant ${n.participantId}`), e = go.UNKNOWN_ERROR), r.push({
11557
11677
  externalId: a.externalId,
11558
11678
  errorReason: e
11559
11679
  });
11560
11680
  }
11561
11681
  }
11562
- if (r && r.length && (this._debug.warn("Could not allocate one or more participants", r), t)) throw new mc("Could not allocate one or more participants", r);
11682
+ if (r && r.length && (this._debug.warn("Could not allocate one or more participants", r), t)) throw new bc("Could not allocate one or more participants", r);
11563
11683
  }
11564
11684
  async _cleanupCooldownQueue() {
11565
11685
  let e = {}, t = this._cooldownTimestampByStreamDescription.entries();
@@ -11567,7 +11687,7 @@ var fc = 15, $ = class e extends b {
11567
11687
  let n = t.next();
11568
11688
  if (n.done) break;
11569
11689
  let r = n.value;
11570
- if (r[1] + uc > Date.now()) break;
11690
+ if (r[1] + gc > Date.now()) break;
11571
11691
  let i = r[0];
11572
11692
  await this._stopStreaming(i), e[i] = { stopStream: !0 };
11573
11693
  } while (!0);
@@ -11771,10 +11891,10 @@ var fc = 15, $ = class e extends b {
11771
11891
  throw Error("transport is not initialized");
11772
11892
  }
11773
11893
  _isCallAdmin() {
11774
- return this._conversation ? M.includesOneOf(this._conversation.roles, [po.ADMIN, po.CREATOR]) : !1;
11894
+ return this._conversation ? M.includesOneOf(this._conversation.roles, [vo.ADMIN, vo.CREATOR]) : !1;
11775
11895
  }
11776
11896
  _checkAdminRole() {
11777
- if (this._conversation && !M.includesOneOf(this._conversation.roles, [po.ADMIN, po.CREATOR])) throw Error("You don't have the required permission");
11897
+ if (this._conversation && !M.includesOneOf(this._conversation.roles, [vo.ADMIN, vo.CREATOR])) throw Error("You don't have the required permission");
11778
11898
  }
11779
11899
  _isCalledState() {
11780
11900
  return this._participantState === X.CALLED;
@@ -11812,21 +11932,21 @@ var fc = 15, $ = class e extends b {
11812
11932
  async changeOptions(e) {
11813
11933
  if (this._signaling.ready && this._conversation) {
11814
11934
  this._checkAdminRole(), await this._signaling.changeOptions(e);
11815
- let t = so(this._conversation.options, e);
11935
+ let t = po(this._conversation.options, e);
11816
11936
  this._onOptionsChanged(t);
11817
11937
  }
11818
11938
  }
11819
11939
  async getWaitingHall(e, t, n) {
11820
11940
  if (!this._signaling) return Promise.reject();
11821
11941
  let r = null;
11822
- if (e && (r = yo(e), r)) {
11942
+ if (e && (r = wo(e), r)) {
11823
11943
  let e = this._api.getDecorativeIdByInitialId(r.id);
11824
11944
  r.id = e ?? r.id;
11825
11945
  }
11826
11946
  let i = await this._signaling.getWaitingHall(r, t, n);
11827
11947
  if (i.error) return Promise.reject(i.message);
11828
11948
  let a = i.participants || [], { externalIds: o } = this._resolveWaitingHallExternalIds(a, "getWaitingHall"), s = null;
11829
- return a.length && i.hasMore && (s = vo(a[a.length - 1].id)), {
11949
+ return a.length && i.hasMore && (s = Co(a[a.length - 1].id)), {
11830
11950
  participants: o,
11831
11951
  pageMarker: s,
11832
11952
  totalCount: i.totalCount || 0
@@ -11860,7 +11980,7 @@ var fc = 15, $ = class e extends b {
11860
11980
  }
11861
11981
  async promoteParticipant(e, t) {
11862
11982
  if (this._signaling && this._conversation) try {
11863
- if (!M.includesOneOf(this._conversation.options, [ao.WAITING_HALL, ao.AUDIENCE_MODE])) throw Error("Unable to promote a participant in the conversation with current options");
11983
+ 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");
11864
11984
  if (this._checkAdminRole(), !e && t) throw Error("participantId is required");
11865
11985
  await this._signaling.promoteParticipant(e, t);
11866
11986
  } catch (t) {
@@ -12032,7 +12152,7 @@ var fc = 15, $ = class e extends b {
12032
12152
  let a = this._transport?.getState();
12033
12153
  return n.participants.forEach((e) => {
12034
12154
  let t = M.composeId(e), n = r[t];
12035
- this._updateParticipantExternalId(n, e), this._setSessionState(n, this._remoteParticipantSessionState(t, e.sessionState)), n.isOnHold || this._setTransportStatus(n, go.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);
12155
+ 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);
12036
12156
  }), this._participantListChunkToExternalChunk(n);
12037
12157
  }
12038
12158
  async _getInitialParticiapntListChunk() {
@@ -12046,7 +12166,7 @@ var fc = 15, $ = class e extends b {
12046
12166
  _onLocalMediaStreamChanged(e) {
12047
12167
  if (!this._conversation || !this._mediaSource) return;
12048
12168
  let t = this._mediaSource.mediaSettings;
12049
- this._debug.debug("Local media stream changed", t), e.kind === A.audio && this._mediaSource && (this._audioFix = new Ao(this._mediaSource, this._debug, this._stats.logger)), R.onLocalStreamUpdate(t, e.kind, this.id), !this._conversation?.waitingHall && !this._conversation?.observer && !this._isAudienceModeListener() && this._changeMediaSettings(t);
12169
+ 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);
12050
12170
  }
12051
12171
  _onScreenSharingStatus(e) {
12052
12172
  let t = this.mediaSettings;
@@ -12176,9 +12296,9 @@ var fc = 15, $ = class e extends b {
12176
12296
  for (let n of e.conversation.participants) {
12177
12297
  let e = M.composeId(n), i = n.roles || [];
12178
12298
  if (this._isMe(e)) {
12179
- mo(this._conversation.roles, i) || this._onRolesChanged(e, i), t = () => {
12299
+ yo(this._conversation.roles, i) || this._onRolesChanged(e, i), t = () => {
12180
12300
  this._registerParticipantLocalMuteState({
12181
- muteStates: wo(n),
12301
+ muteStates: ko(n),
12182
12302
  unmuteOptions: n.unmuteOptions
12183
12303
  });
12184
12304
  };
@@ -12196,7 +12316,7 @@ var fc = 15, $ = class e extends b {
12196
12316
  let t = D(n.mediaSettings);
12197
12317
  Wt(t, a.mediaSettings) || this._changeRemoteMediaSettings(e, t);
12198
12318
  let r = M.mapParticipantState(n), o = a.participantState;
12199
- M.isEqualParticipantState(r, o) || await this._changeRemoteParticipantState(e, r), mo(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));
12319
+ 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));
12200
12320
  }
12201
12321
  }
12202
12322
  let i = this._participants;
@@ -12221,7 +12341,7 @@ var fc = 15, $ = class e extends b {
12221
12341
  this._close(new k(O.ANOTHER_DEVICE), { errorText: "Call accepted on other device" });
12222
12342
  return;
12223
12343
  }
12224
- this._conversation?.direction === to.OUTGOING && !this._conversation.concurrent && this._stats.lifecycle.markOutgoingAccepted();
12344
+ this._conversation?.direction === oo.OUTGOING && !this._conversation.concurrent && this._stats.lifecycle.markOutgoingAccepted();
12225
12345
  let r = this._getParticipant(t);
12226
12346
  if (!r) {
12227
12347
  let n = this._api.getDecorativeIdByInitialId(t);
@@ -12234,7 +12354,7 @@ var fc = 15, $ = class e extends b {
12234
12354
  let t = Z.fromSignaling(e.externalId, e.deviceIdx);
12235
12355
  r.externalId = t, this._api.cacheExternalId(r.id, t);
12236
12356
  }
12237
- r.state = X.ACCEPTED, r.mediaSettings = D(e.mediaSettings), this._logWithMediaSettings(C.ACCEPTED_OUTGOING, r.mediaSettings), this._conversation && this._conversation.direction === to.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);
12357
+ 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);
12238
12358
  let i = Object.keys(r.muteStates);
12239
12359
  if (i.length && this._onMuteParticipant({
12240
12360
  muteStates: r.muteStates,
@@ -12246,7 +12366,7 @@ var fc = 15, $ = class e extends b {
12246
12366
  this._reportMissingExternalIds([t], "ACCEPTED_CALL");
12247
12367
  return;
12248
12368
  }
12249
- R.onAcceptedCall(r.externalId, Fa.parseCapabilities(e.capabilities), this.id);
12369
+ R.onAcceptedCall(r.externalId, Ba.parseCapabilities(e.capabilities), this.id);
12250
12370
  }
12251
12371
  }
12252
12372
  async _onHungup(e) {
@@ -12283,7 +12403,7 @@ var fc = 15, $ = class e extends b {
12283
12403
  return;
12284
12404
  }
12285
12405
  if (e.connected) {
12286
- let e = go.fromTransportState(this._transport?.getState());
12406
+ let e = xo.fromTransportState(this._transport?.getState());
12287
12407
  e && this._setTransportStatus(n, e);
12288
12408
  }
12289
12409
  this._setSessionState(n, { connected: e.connected });
@@ -12360,7 +12480,7 @@ var fc = 15, $ = class e extends b {
12360
12480
  isOnHold: !!r.onHold
12361
12481
  }, i), n = this._getParticipant(t);
12362
12482
  }
12363
- this._conversation && this._conversation.direction === to.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);
12483
+ 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);
12364
12484
  let i = Object.keys(n.muteStates);
12365
12485
  i.length && this._onMuteParticipant({
12366
12486
  muteStates: n.muteStates,
@@ -12551,15 +12671,15 @@ var fc = 15, $ = class e extends b {
12551
12671
  R.onAsrTranscription(t, e.text, e.timestamp, e.duration, this.id);
12552
12672
  }
12553
12673
  async _onRolesChanged(e, t) {
12554
- if (this._conversation && this._isMe(e) && !mo(this._conversation.roles, t)) {
12674
+ if (this._conversation && this._isMe(e) && !yo(this._conversation.roles, t)) {
12555
12675
  this._debug.debug(`Local roles changed: ${t}`), this._conversation.roles = t, R.onLocalRolesChanged(t, !1, this.id), this._processMuteState({
12556
- mediaOptions: bo(this._getMuteStatesForCurrentRoom(), co.MUTE_PERMANENT),
12676
+ mediaOptions: To(this._getMuteStatesForCurrentRoom(), mo.MUTE_PERMANENT),
12557
12677
  stateUpdated: !0
12558
- }), M.includesOneOf(t, [po.ADMIN, po.CREATOR]) ? this._refreshRooms(!0) : t.length || this._onRoomSwitched(null);
12678
+ }), M.includesOneOf(t, [vo.ADMIN, vo.CREATOR]) ? this._refreshRooms(!0) : t.length || this._onRoomSwitched(null);
12559
12679
  return;
12560
12680
  }
12561
12681
  let n = this._getParticipant(e);
12562
- n && !mo(n.roles, t) && (this._debug.debug(`Roles for participant [${e}] changed: ${t}`), n.roles = t, R.onRolesChanged(n.externalId, t, !1, this.id));
12682
+ 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));
12563
12683
  }
12564
12684
  async _onMuteParticipant(e, t = !1) {
12565
12685
  if (!this._conversation) return;
@@ -12608,7 +12728,7 @@ var fc = 15, $ = class e extends b {
12608
12728
  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);
12609
12729
  for (let [e, i] of d) {
12610
12730
  let a = this._isCallAdmin() && n;
12611
- if (!(i !== co.MUTE && i !== co.MUTE_PERMANENT || a) && (this._isCallAdmin() && i === co.MUTE_PERMANENT && !n && (l[e] = co.MUTE), !(!t.includes(e) || r))) switch (e) {
12731
+ 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) {
12612
12732
  case S.VIDEO:
12613
12733
  u.isVideoEnabled && (R.onDeviceSwitched(S.VIDEO, !1, this.id), await this.toggleLocalVideo(!1));
12614
12734
  break;
@@ -12645,7 +12765,7 @@ var fc = 15, $ = class e extends b {
12645
12765
  this._conversation.pinnedParticipantIdByRoom.set(r, t ? null : e);
12646
12766
  }
12647
12767
  _onOptionsChanged(e) {
12648
- this._conversation && !oo(this._conversation.options, e) && (this._conversation.options = e, R.onOptionsChanged(e, this.id), e.includes(ao.ADMIN_IS_HERE) ? this._conversation.restricted && this._conversation.waitingHall && R.onLocalStatus(P.WAITING_HALL, this.id) : e.includes(ao.WAIT_FOR_ADMIN) && this._conversation.restricted && R.onLocalStatus(P.WAIT_FOR_ADMIN, this.id));
12768
+ 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));
12649
12769
  }
12650
12770
  async _onNetworkStatus(e) {
12651
12771
  if (this._conversation) {
@@ -12655,7 +12775,7 @@ var fc = 15, $ = class e extends b {
12655
12775
  if (this._isMe(r) || r === "") e = this._conversation.networkRating;
12656
12776
  else if (n[r]) e = n[r].networkRating;
12657
12777
  else continue;
12658
- if (e !== i) if (this._isMe(r) || r === "") this._conversation.networkRating = i, ui.getInstance().value = i, R.onLocalNetworkStatusChanged(i, this.id);
12778
+ if (e !== i) if (this._isMe(r) || r === "") this._conversation.networkRating = i, mi.getInstance().value = i, R.onLocalNetworkStatusChanged(i, this.id);
12659
12779
  else {
12660
12780
  let e = n[r];
12661
12781
  e.networkRating = i, t.push({
@@ -12700,7 +12820,7 @@ var fc = 15, $ = class e extends b {
12700
12820
  }
12701
12821
  _changeFeatureSet() {
12702
12822
  if (this._conversation) {
12703
- let e = this._state === "ACTIVE", t = this._conversation.features.includes(io.ADD_PARTICIPANT);
12823
+ let e = this._state === "ACTIVE", t = this._conversation.features.includes(lo.ADD_PARTICIPANT);
12704
12824
  R.onCallState(e, t, this._conversation, this.id);
12705
12825
  }
12706
12826
  }
@@ -12734,7 +12854,7 @@ var fc = 15, $ = class e extends b {
12734
12854
  let n = this._getParticipant(e);
12735
12855
  if (n) {
12736
12856
  if (n.connectionStatus.sessionStateApplicable && n.connectionStatus.sessionState?.connected === !1) {
12737
- let e = go.fromTransportState(this._transport?.getState());
12857
+ let e = xo.fromTransportState(this._transport?.getState());
12738
12858
  e && this._setTransportStatus(n, e), n.connectionStatus.sessionStateConnectedBySpeaker = !0;
12739
12859
  let t = this._setTransportStatus(n, n.connectionStatus.transport);
12740
12860
  this._emitParticipantTransition(n, t);
@@ -12744,7 +12864,7 @@ var fc = 15, $ = class e extends b {
12744
12864
  }
12745
12865
  async _onTransportStateChanged(e, t) {
12746
12866
  this._debug.debug(`Transport state has changed: ${t}`, e);
12747
- let n = go.fromTransportState(t);
12867
+ let n = xo.fromTransportState(t);
12748
12868
  if (!n) return;
12749
12869
  let r = this._participants, i = [], a = e.reduce((e, n) => {
12750
12870
  if (n in r) {
@@ -12778,9 +12898,9 @@ var fc = 15, $ = class e extends b {
12778
12898
  return e.every((e) => t[e]?.isOnHold);
12779
12899
  }
12780
12900
  _onRemoteTrackAdded(e, t, n) {
12781
- if (e.endsWith(oi.AUDIO_MIX)) this._debug.debug("Remote audio mix track added"), this._audioOutput.add(e, n), R.onRemoteMixedAudioStream(t, this.id);
12782
- else if (e.startsWith(oi.TRANSPARENT_AUDIO_TRACK_PREFIX)) this._debug.debug(`Remote transparent audio track added: ${e}`), this._audioOutput.add(e, n);
12783
- else if (e.startsWith(oi.PARTICIPANT_AGNOSTIC_TRACK_PREFIX)) this._debug.debug(`Participant-agnostic track added: ${e}`), this._streamByStreamId.set(e, t);
12901
+ if (e.endsWith(ui.AUDIO_MIX)) this._debug.debug("Remote audio mix track added"), this._audioOutput.add(e, n), R.onRemoteMixedAudioStream(t, this.id);
12902
+ else if (e.startsWith(ui.TRANSPARENT_AUDIO_TRACK_PREFIX)) this._debug.debug(`Remote transparent audio track added: ${e}`), this._audioOutput.add(e, n);
12903
+ else if (e.startsWith(ui.PARTICIPANT_AGNOSTIC_TRACK_PREFIX)) this._debug.debug(`Participant-agnostic track added: ${e}`), this._streamByStreamId.set(e, t);
12784
12904
  else {
12785
12905
  this._debug.debug(`Remote track added on the participant [${e}]`, { kind: n.kind });
12786
12906
  let r = this._getParticipant(e);
@@ -12807,7 +12927,7 @@ var fc = 15, $ = class e extends b {
12807
12927
  }
12808
12928
  }
12809
12929
  async _removeAudioTrack(e, t, n) {
12810
- if (e !== oi.AUDIO_MIX) {
12930
+ if (e !== ui.AUDIO_MIX) {
12811
12931
  let n = this._getParticipant(e);
12812
12932
  if (!n || n.remoteStream && n.remoteStream !== t) return;
12813
12933
  }
@@ -12822,7 +12942,7 @@ var fc = 15, $ = class e extends b {
12822
12942
  if (this._statFirstMediaReceived.markTopologyChanged(e), e === J.DIRECT && (this._onRemoteSignalledStall([]), this._onAudioMixStall(!1)), this._conversation) {
12823
12943
  this._conversation.topology = e;
12824
12944
  for (let e of Object.values(this._participants)) {
12825
- let t = go.setSessionStateApplicable(e.connectionStatus, this._isParticipantSessionStateApplicable(e.id));
12945
+ let t = xo.setSessionStateApplicable(e.connectionStatus, this._isParticipantSessionStateApplicable(e.id));
12826
12946
  this._emitParticipantTransition(e, t);
12827
12947
  }
12828
12948
  this._changeFeatureSet(), this._forceOpenTransportForAloneInCall();
@@ -12878,7 +12998,7 @@ var fc = 15, $ = class e extends b {
12878
12998
  ].includes(t) ? null : this._setTransportStatus(e, t), n);
12879
12999
  }
12880
13000
  _setParticipantsStalled(e, t) {
12881
- this._updateParticipantsStatus(e, (e) => go.setStalled(e.connectionStatus, t));
13001
+ this._updateParticipantsStatus(e, (e) => xo.setStalled(e.connectionStatus, t));
12882
13002
  }
12883
13003
  _updateParticipantsStatus(e, t, n = null) {
12884
13004
  let r = e.reduce((e, n) => {
@@ -12897,7 +13017,7 @@ var fc = 15, $ = class e extends b {
12897
13017
  _onRoomsUpdated(e) {
12898
13018
  if (this._isCalledState()) return;
12899
13019
  let t = {}, n = [], r = [];
12900
- for (let i of Object.keys(lo)) {
13020
+ for (let i of Object.keys(ho)) {
12901
13021
  let a = e.updates[i];
12902
13022
  a && (a?.rooms?.forEach((e) => {
12903
13023
  let { room: t, missingParticipantIds: i } = this._convertRoomToExternal(e);
@@ -12912,7 +13032,7 @@ var fc = 15, $ = class e extends b {
12912
13032
  }
12913
13033
  _onRoomUpdated(e) {
12914
13034
  let { room: t, missingParticipantIds: n } = this._convertRoomToExternal(e.room || null);
12915
- e.events.some((e) => e === lo.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));
13035
+ 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));
12916
13036
  }
12917
13037
  _convertRoomToExternal(e) {
12918
13038
  if (!e) return {
@@ -13023,7 +13143,7 @@ var fc = 15, $ = class e extends b {
13023
13143
  n && r.push(n);
13024
13144
  }
13025
13145
  }
13026
- r.length && !this._isCalledState() && R.onRoomsUpdated({ [lo.UPDATE]: { rooms: r } }, this.id);
13146
+ r.length && !this._isCalledState() && R.onRoomsUpdated({ [ho.UPDATE]: { rooms: r } }, this.id);
13027
13147
  }
13028
13148
  _onFeedback(e) {
13029
13149
  let t = [];
@@ -13099,11 +13219,11 @@ var fc = 15, $ = class e extends b {
13099
13219
  _getParticipant(e) {
13100
13220
  return this._participants[e];
13101
13221
  }
13102
- }, pc = null, mc = class e extends Error {
13222
+ }, yc = null, bc = class e extends Error {
13103
13223
  constructor(t, n) {
13104
13224
  super(t), h(this, "participantErrors", void 0), Object.setPrototypeOf(this, e.prototype), this.participantErrors = n;
13105
13225
  }
13106
- }, hc = class {
13226
+ }, xc = class {
13107
13227
  constructor() {
13108
13228
  h(this, "_abortSignal", void 0), h(this, "_apiCallStats", null);
13109
13229
  }
@@ -13148,14 +13268,14 @@ var fc = 15, $ = class e extends b {
13148
13268
  async getInbounds() {
13149
13269
  return [];
13150
13270
  }
13151
- }, gc = class e {
13271
+ }, Sc = class e {
13152
13272
  constructor() {
13153
13273
  h(this, "_participantIdToExternalId", /* @__PURE__ */ new Map()), h(this, "_externalIdToParticipantId", /* @__PURE__ */ new Map()), h(this, "_decorativeIdToInitialId", /* @__PURE__ */ new Map()), h(this, "_initialIdToDecorativeId", /* @__PURE__ */ new Map());
13154
13274
  }
13155
13275
  static _normalizeType(e) {
13156
- return e.type === _o.GROUP ? {
13276
+ return e.type === So.GROUP ? {
13157
13277
  ...e,
13158
- type: _o.USER
13278
+ type: So.USER
13159
13279
  } : e;
13160
13280
  }
13161
13281
  getExternalId(e) {
@@ -13183,27 +13303,27 @@ var fc = 15, $ = class e extends b {
13183
13303
  clear() {
13184
13304
  this._participantIdToExternalId.clear(), this._externalIdToParticipantId.clear(), this._decorativeIdToInitialId.clear(), this._initialIdToDecorativeId.clear();
13185
13305
  }
13186
- }, _c = "anonymLogin:", vc = 700, yc = 3e3;
13187
- function bc(e) {
13306
+ }, Cc = "anonymLogin:", wc = 700, Tc = 3e3;
13307
+ function Ec(e) {
13188
13308
  let t = e.error_code;
13189
13309
  switch (t) {
13190
- case 2: return xc(O.SERVICE_UNAVAILABLE, t, "service-unavailable");
13191
- case 4: return e.error_msg.includes("participants.limit.exceeded") ? xc(O.PARTICIPANT_LIMIT_REACHED, t, "participants-limit-exceeded") : xc(x.API, t, "request-error");
13192
- case 300: return xc(O.NOT_FOUND, t, "not-found");
13193
- case 1101: return xc(O.SERVICE_DISABLED, t, "vchat-service-disabled");
13194
- case 1102: return xc(O.CALLEE_IS_OFFLINE, t, "target-user-unavailable");
13195
- case 1103: return xc(O.NOT_FRIENDS, t, "friendship-required");
13196
- case 1104: return Cc(t, "youla-api-error");
13197
- case 1106: return Cc(t, "vk-api-error");
13198
- case 1113: return xc(O.CALLER_IS_REJECTED, t, "caller-is-rejected");
13310
+ case 2: return Dc(O.SERVICE_UNAVAILABLE, t, "service-unavailable");
13311
+ case 4: return e.error_msg.includes("participants.limit.exceeded") ? Dc(O.PARTICIPANT_LIMIT_REACHED, t, "participants-limit-exceeded") : Dc(x.API, t, "request-error");
13312
+ case 300: return Dc(O.NOT_FOUND, t, "not-found");
13313
+ case 1101: return Dc(O.SERVICE_DISABLED, t, "vchat-service-disabled");
13314
+ case 1102: return Dc(O.CALLEE_IS_OFFLINE, t, "target-user-unavailable");
13315
+ case 1103: return Dc(O.NOT_FRIENDS, t, "friendship-required");
13316
+ case 1104: return kc(t, "youla-api-error");
13317
+ case 1106: return kc(t, "vk-api-error");
13318
+ case 1113: return Dc(O.CALLER_IS_REJECTED, t, "caller-is-rejected");
13199
13319
  case 1114: {
13200
13320
  let n = e.custom_error?.vchat_detailed_api_error?.code, r = n?.startsWith("obsolete_client");
13201
- return xc(r ? O.OBSOLETE_CLIENT : O.VCHAT_DETAILED_ERROR, t, n ?? "detailed-error", r ? n : void 0);
13321
+ return Dc(r ? O.OBSOLETE_CLIENT : O.VCHAT_DETAILED_ERROR, t, n ?? "detailed-error", r ? n : void 0);
13202
13322
  }
13203
- default: return xc(x.API, t, "api-error");
13323
+ default: return Dc(x.API, t, "api-error");
13204
13324
  }
13205
13325
  }
13206
- function xc(e, t, n, r) {
13326
+ function Dc(e, t, n, r) {
13207
13327
  return {
13208
13328
  type: e,
13209
13329
  callError: {
@@ -13215,10 +13335,10 @@ function xc(e, t, n, r) {
13215
13335
  message: r
13216
13336
  };
13217
13337
  }
13218
- function Sc(e) {
13338
+ function Oc(e) {
13219
13339
  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);
13220
13340
  }
13221
- function Cc(e, t) {
13341
+ function kc(e, t) {
13222
13342
  return {
13223
13343
  type: O.EXTERNAL_API_ERROR,
13224
13344
  callError: {
@@ -13229,21 +13349,21 @@ function Cc(e, t) {
13229
13349
  }
13230
13350
  };
13231
13351
  }
13232
- var wc = class extends hc {
13352
+ var Ac = class extends xc {
13233
13353
  constructor(...e) {
13234
- super(...e), h(this, "_uuid", void 0), h(this, "_idCache", new gc());
13354
+ super(...e), h(this, "_uuid", void 0), h(this, "_idCache", new Sc());
13235
13355
  }
13236
13356
  async _callUnsafe(e, t = {}, n = !1) {
13237
13357
  let r = async (i) => {
13238
13358
  let a = performance.now();
13239
13359
  try {
13240
- let r = await hs(e, t, n);
13360
+ let r = await bs(e, t, n);
13241
13361
  return this._apiCallStats?.log(e, performance.now() - a), r;
13242
13362
  } catch (t) {
13243
- if (this._apiCallStats?.log(e, performance.now() - a, Sc(t)), !t || typeof t != "object" || !Object.hasOwn(t, "error_msg")) {
13363
+ if (this._apiCallStats?.log(e, performance.now() - a, Oc(t)), !t || typeof t != "object" || !Object.hasOwn(t, "error_msg")) {
13244
13364
  i++;
13245
13365
  let n = t && (typeof t == "object" || typeof t == "function") ? Object.getOwnPropertyNames(t).map((e) => `${e}: ${JSON.stringify(t[e])}`) : [String(t)];
13246
- 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 * vc, yc), { signal: this._abortSignal }), r(i);
13366
+ 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 * wc, Tc), { signal: this._abortSignal }), r(i);
13247
13367
  }
13248
13368
  throw z.warn(e, "error", t), t;
13249
13369
  }
@@ -13255,13 +13375,13 @@ var wc = class extends hc {
13255
13375
  return await this._callUnsafe(e, t, n);
13256
13376
  } catch (i) {
13257
13377
  if (z.warn("Api call error", i), i instanceof k) throw i;
13258
- if (Zo(i?.error_code) && r) return await this._reauthorize(), this._call(e, t, n, !1);
13378
+ if (ns(i?.error_code) && r) return await this._reauthorize(), this._call(e, t, n, !1);
13259
13379
  let a = {
13260
13380
  message: i?.error_msg,
13261
13381
  code: i?.error_code
13262
13382
  };
13263
- if (i.custom_error && (a.custom_error = i.custom_error), Tc(i)) {
13264
- let e = bc(i);
13383
+ if (i.custom_error && (a.custom_error = i.custom_error), jc(i)) {
13384
+ let e = Ec(i);
13265
13385
  throw a.callError = e.callError, a.message = e.message ?? a.message, new k(e.type, a);
13266
13386
  }
13267
13387
  throw new k(x.API, a);
@@ -13291,7 +13411,7 @@ var wc = class extends hc {
13291
13411
  return this._anonymLogin(N.authToken).then((e) => {
13292
13412
  this._applyAnonymLogin(e), this._setCachedAnonymLogin(e);
13293
13413
  }).catch((e) => {
13294
- throw e instanceof k ? e : (e?.error_code === Xo.AUTH_LOGIN && (this._removeCachedAnonymLogin(), R.onTokenExpired()), new k(x.AUTH, {
13414
+ throw e instanceof k ? e : (e?.error_code === ts.AUTH_LOGIN && (this._removeCachedAnonymLogin(), R.onTokenExpired()), new k(x.AUTH, {
13295
13415
  message: e?.error_msg,
13296
13416
  code: e?.error_code,
13297
13417
  callError: {
@@ -13313,17 +13433,17 @@ var wc = class extends hc {
13313
13433
  return e && (t.session_data.auth_token = e, t.session_data.version = 3), this._callUnsafe("auth.anonymLogin", t, !0);
13314
13434
  }
13315
13435
  _getAnonymLoginCacheKey() {
13316
- return N.authToken ? `${_c}${N.authToken}` : null;
13436
+ return N.authToken ? `${Cc}${N.authToken}` : null;
13317
13437
  }
13318
13438
  _getCachedAnonymLogin() {
13319
13439
  let e = this._getAnonymLoginCacheKey();
13320
13440
  if (!e) return null;
13321
13441
  let t = w.get(e);
13322
- return Ec(t) ? t : (t && w.remove(e), null);
13442
+ return Mc(t) ? t : (t && w.remove(e), null);
13323
13443
  }
13324
13444
  _setCachedAnonymLogin(e) {
13325
13445
  let t = this._getAnonymLoginCacheKey();
13326
- !t || !Ec(e) || w.set(t, {
13446
+ !t || !Mc(e) || w.set(t, {
13327
13447
  session_key: e.session_key,
13328
13448
  session_secret_key: e.session_secret_key,
13329
13449
  uid: e.uid
@@ -13337,9 +13457,9 @@ var wc = class extends hc {
13337
13457
  return this._removeCachedAnonymLogin(), y.reauthorize(() => this.authorize());
13338
13458
  }
13339
13459
  _applyAnonymLogin(e) {
13340
- e.uid && (y.userId = Number(e.uid)), y.sessionKey = e.session_key, y.sessionSecretKey = e.session_secret_key, N.statQueueEnabled && e.uid && Cs.remember(Number(e.uid), {
13460
+ 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), {
13341
13461
  sessionKey: e.session_key,
13342
- endpoint: Cs.currentEndpoint()
13462
+ endpoint: Os.currentEndpoint()
13343
13463
  });
13344
13464
  }
13345
13465
  _buildClientStatsData(e) {
@@ -13358,7 +13478,7 @@ var wc = class extends hc {
13358
13478
  });
13359
13479
  }
13360
13480
  async _sendClientStatsWith(e, t) {
13361
- let n = await hs("vchat.clientStats", {
13481
+ let n = await bs("vchat.clientStats", {
13362
13482
  ...t,
13363
13483
  session_key: e
13364
13484
  }, !0);
@@ -13366,10 +13486,10 @@ var wc = class extends hc {
13366
13486
  }
13367
13487
  async _sendClientStats(e, t, n = !0) {
13368
13488
  try {
13369
- let n = t ? await gs("vchat.clientStats", e) : await hs("vchat.clientStats", e);
13489
+ let n = t ? await xs("vchat.clientStats", e) : await bs("vchat.clientStats", e);
13370
13490
  this._reportClientStatsItemErrors(n);
13371
13491
  } catch (r) {
13372
- if (!n || !Zo(r?.error_code)) throw r;
13492
+ if (!n || !ns(r?.error_code)) throw r;
13373
13493
  await this._reauthorize(), await this._sendClientStats(e, t, !1);
13374
13494
  }
13375
13495
  }
@@ -13393,14 +13513,14 @@ var wc = class extends hc {
13393
13513
  }, a = await this._callUnsafe("vchat.getLogUploadUrl", i), o = new FormData(), s = new Blob([r], { type: "application/json" });
13394
13514
  o.append("file", s, "log.json");
13395
13515
  let c = new URL(a.upload_url);
13396
- return c.searchParams.append("size", s.size.toString()), ys(c.toString(), o);
13516
+ return c.searchParams.append("size", s.size.toString()), ws(c.toString(), o);
13397
13517
  }
13398
13518
  async joinConversation(e, t = !1, n) {
13399
13519
  let r = {
13400
13520
  conversationId: e,
13401
13521
  isVideo: t,
13402
13522
  protocolVersion: N.protocolVersion,
13403
- capabilities: Fa.getFlags()
13523
+ capabilities: Ba.getFlags()
13404
13524
  };
13405
13525
  return n && (r.chatId = n), this._call("vchat.joinConversation", r);
13406
13526
  }
@@ -13432,13 +13552,13 @@ var wc = class extends hc {
13432
13552
  externalIds: l
13433
13553
  });
13434
13554
  if (t && t.length) switch (n) {
13435
- case no.USER:
13555
+ case so.USER:
13436
13556
  u.uids = t.join(",");
13437
13557
  break;
13438
- case no.GROUP:
13558
+ case so.GROUP:
13439
13559
  u.gid = t[0];
13440
13560
  break;
13441
- case no.CHAT:
13561
+ case so.CHAT:
13442
13562
  u.chatId = t[0];
13443
13563
  break;
13444
13564
  }
@@ -13481,7 +13601,7 @@ var wc = class extends hc {
13481
13601
  joinLink: e,
13482
13602
  isVideo: t,
13483
13603
  protocolVersion: N.protocolVersion,
13484
- capabilities: Fa.getFlags()
13604
+ capabilities: Ba.getFlags()
13485
13605
  };
13486
13606
  return n?.length && (i.observedIds = n.join(",")), N.anonymToken && (i.anonymToken = N.anonymToken), r && (i.payload = r), this._call("vchat.joinConversationByLink", i);
13487
13607
  }
@@ -13511,9 +13631,9 @@ var wc = class extends hc {
13511
13631
  return y.userId;
13512
13632
  }
13513
13633
  setUserId(e) {
13514
- y.userId = e, N.statQueueEnabled && y.sessionKey && Cs.remember(Number(e), {
13634
+ y.userId = e, N.statQueueEnabled && y.sessionKey && Os.remember(Number(e), {
13515
13635
  sessionKey: y.sessionKey,
13516
- endpoint: Cs.currentEndpoint()
13636
+ endpoint: Os.currentEndpoint()
13517
13637
  });
13518
13638
  }
13519
13639
  hangupConversation(e, t = O.HUNGUP, n) {
@@ -13521,7 +13641,7 @@ var wc = class extends hc {
13521
13641
  conversationId: e,
13522
13642
  reason: t
13523
13643
  };
13524
- N.anonymToken && (r.anonymToken = N.anonymToken), n?.peerId && (r.peerId = n.peerId), ms("vchat.hangupConversation", r);
13644
+ N.anonymToken && (r.anonymToken = N.anonymToken), n?.peerId && (r.peerId = n.peerId), ys("vchat.hangupConversation", r);
13525
13645
  }
13526
13646
  async removeHistoryRecords(e) {
13527
13647
  await this._call("vchat.removeHistoryRecords", { recordIds: e.join(",") });
@@ -13537,19 +13657,19 @@ var wc = class extends hc {
13537
13657
  return Array.isArray(e?.inbounds) ? e.inbounds : [];
13538
13658
  }
13539
13659
  };
13540
- function Tc(e) {
13660
+ function jc(e) {
13541
13661
  return typeof e == "object" && !!e && "error_code" in e && "error_msg" in e;
13542
13662
  }
13543
- function Ec(e) {
13663
+ function Mc(e) {
13544
13664
  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;
13545
13665
  }
13546
13666
  //#endregion
13547
13667
  //#region src/enums/RecordRole.ts
13548
- var Dc = /* @__PURE__ */ function(e) {
13668
+ var Nc = /* @__PURE__ */ function(e) {
13549
13669
  return e.KING = "KING", e.PAWN = "PAWN", e;
13550
- }(Dc || {}), Oc = /* @__PURE__ */ function(e) {
13670
+ }(Nc || {}), Pc = /* @__PURE__ */ function(e) {
13551
13671
  return e.OFF = "0", e.ON = "1", e;
13552
- }({}), kc = class {
13672
+ }({}), Fc = class {
13553
13673
  constructor(e) {
13554
13674
  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;
13555
13675
  }
@@ -13572,12 +13692,12 @@ var Dc = /* @__PURE__ */ function(e) {
13572
13692
  let e = this._queue[this._readCursor];
13573
13693
  return e && (this._moveReadCursor = !1, this._queue[this._readCursor] = null, this._readCursor = this.nextCursor(this._readCursor), --this._left), e;
13574
13694
  }
13575
- }, Ac = class {
13695
+ }, Ic = class {
13576
13696
  constructor(e, t, n, r = null) {
13577
13697
  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;
13578
13698
  }
13579
13699
  async authorize() {
13580
- let e = await hs("auth.anonymLogin", {
13700
+ let e = await bs("auth.anonymLogin", {
13581
13701
  session_data: {
13582
13702
  device_id: this._uuid,
13583
13703
  client_version: N.apiClientVersion,
@@ -13586,7 +13706,7 @@ var Dc = /* @__PURE__ */ function(e) {
13586
13706
  version: 3
13587
13707
  },
13588
13708
  application_key: this._apiKey
13589
- }, !0, await fs(this._baseApiUrl, this._apiEnv));
13709
+ }, !0, await _s(this._baseApiUrl, this._apiEnv));
13590
13710
  return M.isObject(e) && !("error_msg" in e) ? (this._sessionKey = e.session_key, !0) : !1;
13591
13711
  }
13592
13712
  async hangupConversation(e, t) {
@@ -13596,9 +13716,9 @@ var Dc = /* @__PURE__ */ function(e) {
13596
13716
  application_key: this._apiKey,
13597
13717
  session_key: this._sessionKey
13598
13718
  };
13599
- t?.peerId && (n.peerId = t.peerId), await hs("vchat.hangupConversation", n, !0, await fs(this._baseApiUrl, this._apiEnv));
13719
+ t?.peerId && (n.peerId = t.peerId), await bs("vchat.hangupConversation", n, !0, await _s(this._baseApiUrl, this._apiEnv));
13600
13720
  }
13601
- }, jc, Mc = null, Nc = !1, Pc = {
13721
+ }, Lc, Rc = null, zc = !1, Bc = {
13602
13722
  getCameras: E.getCameras,
13603
13723
  getMicrophones: E.getMicrophones,
13604
13724
  getOutput: E.getOutput,
@@ -13624,27 +13744,27 @@ var Dc = /* @__PURE__ */ function(e) {
13624
13744
  baseChromeVersion: E.baseChromeVersion,
13625
13745
  getAudioContext: E.getAudioContext,
13626
13746
  isAudioShareSupported: E.isAudioShareSupported
13627
- }, Fc = { participantMarkerCompare: M.participantMarkerCompare };
13628
- function Ic(e) {
13629
- Mc = e;
13747
+ }, Vc = { participantMarkerCompare: M.participantMarkerCompare };
13748
+ function Hc(e) {
13749
+ Rc = e;
13630
13750
  }
13631
- function Lc(e) {
13751
+ function Uc(e) {
13632
13752
  N.videoEffects = e;
13633
13753
  }
13634
- function Rc(e) {
13754
+ function Wc(e) {
13635
13755
  N.audioEffects = e;
13636
13756
  }
13637
- function zc(e, t = {}) {
13757
+ function Gc(e, t = {}) {
13638
13758
  N.vad = e, N.vadOptions = t;
13639
13759
  }
13640
- function Bc(e, t = null, n = {}, r = 1) {
13760
+ function Kc(e, t = null, n = {}, r = 1) {
13641
13761
  N.vmoji = e, N.vmojiOptions = {
13642
13762
  protocolVersion: r,
13643
13763
  renderingOptions: n
13644
13764
  }, t && e.setSDK(t);
13645
13765
  }
13646
- async function Vc(t) {
13647
- N.set(t), jc || (jc = new wc()), N.statQueueEnabled && (Ts.setApi(jc), N.autoStartStats && Jc()), e.disableLog(!N.debug), z.toggle(N.debug), z.log(`Calls SDK ${N.sdkVersion}`, t), await E.init();
13766
+ async function qc(t) {
13767
+ N.set(t), Lc || (Lc = new Ac()), N.statQueueEnabled && (As.setApi(Lc), N.autoStartStats && el()), e.disableLog(!N.debug), z.toggle(N.debug), z.log(`Calls SDK ${N.sdkVersion}`, t), await E.init();
13648
13768
  let n = E.getBrowserSupportFailure();
13649
13769
  if (n) throw new k(x.UNSUPPORTED, { callError: {
13650
13770
  scope: "internal",
@@ -13653,19 +13773,19 @@ async function Vc(t) {
13653
13773
  } });
13654
13774
  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}`);
13655
13775
  }
13656
- async function Hc(e, t = [S.AUDIO], n = "", r = !1, i = !1, a, o, s) {
13776
+ async function Jc(e, t = [S.AUDIO], n = "", r = !1, i = !1, a, o, s) {
13657
13777
  let c = [];
13658
- return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), Wc([], no.USER, t, n, r, i, a, c, o, s);
13778
+ return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), Xc([], so.USER, t, n, r, i, a, c, o, s);
13659
13779
  }
13660
- function Uc(e, t = []) {
13780
+ function Yc(e, t = []) {
13661
13781
  let n = e.getIncomingCallerExternalId();
13662
13782
  return n ? t.length === 1 && t[0].id === n.id && t[0].type === n.type : !1;
13663
13783
  }
13664
- async function Wc(e, t = no.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
13784
+ async function Xc(e, t = so.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
13665
13785
  if (!N.hold && B.getActive()) throw z.error("There is already active call"), new k(O.HAS_ACTIVE_CALL);
13666
13786
  let u = B.getAll().find((e) => e.isIncomingRinging);
13667
- if (!N.hold && u && !Uc(u, s)) throw z.error("There is already incoming call"), new k(O.HAS_ACTIVE_CALL);
13668
- return new $(new wc(), Mc).onStart({
13787
+ if (!N.hold && u && !Yc(u, s)) throw z.error("There is already incoming call"), new k(O.HAS_ACTIVE_CALL);
13788
+ return new $(new Ac(), Rc).onStart({
13669
13789
  opponentIds: e,
13670
13790
  opponentType: t,
13671
13791
  mediaOptions: n,
@@ -13678,49 +13798,49 @@ async function Wc(e, t = no.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
13678
13798
  conversationId: l
13679
13799
  });
13680
13800
  }
13681
- async function Gc(e, t) {
13682
- return Kc(e, j.USER, void 0, t);
13801
+ async function Zc(e, t) {
13802
+ return Qc(e, j.USER, void 0, t);
13683
13803
  }
13684
- async function Kc(e, t = j.USER, n, r, i, a) {
13804
+ async function Qc(e, t = j.USER, n, r, i, a) {
13685
13805
  if (e === $.id()) throw Error("Push has already been processed");
13686
- return new $(new wc(), Mc).onPush(e, t, n, r, i, a);
13806
+ return new $(new Ac(), Rc).onPush(e, t, n, r, i, a);
13687
13807
  }
13688
- async function qc() {
13689
- return jc.getInbounds();
13808
+ async function $c() {
13809
+ return Lc.getInbounds();
13690
13810
  }
13691
- function Jc() {
13811
+ function el() {
13692
13812
  if (N.statQueueEnabled) {
13693
- if (!jc) {
13813
+ if (!Lc) {
13694
13814
  z.error("[CallsSDK] startStats() called before init()");
13695
13815
  return;
13696
13816
  }
13697
- Nc || (Nc = !0, Fs.start(jc));
13817
+ zc || (zc = !0, Bs.start(Lc));
13698
13818
  }
13699
13819
  }
13700
- async function Yc(e, t) {
13701
- return e && (N.authToken = e), t !== void 0 && N.apiBaseUrl !== t && (N.apiBaseUrl = t, us()), jc.authorize();
13820
+ async function tl(e, t) {
13821
+ return e && (N.authToken = e), t !== void 0 && N.apiBaseUrl !== t && (N.apiBaseUrl = t, hs()), Lc.authorize();
13702
13822
  }
13703
- async function Xc(e = [S.AUDIO], t) {
13704
- return xu(t).accept(e);
13823
+ async function nl(e = [S.AUDIO], t) {
13824
+ return Du(t).accept(e);
13705
13825
  }
13706
- async function Zc(e) {
13707
- let t = vu(e?.conversationId);
13826
+ async function rl(e) {
13827
+ let t = wu(e?.conversationId);
13708
13828
  if (t) return t.decline(e);
13709
13829
  }
13710
- async function Qc(e, t = [S.AUDIO]) {
13711
- return $c(e, t);
13830
+ async function il(e, t = [S.AUDIO]) {
13831
+ return al(e, t);
13712
13832
  }
13713
- async function $c(e, t, n) {
13833
+ async function al(e, t, n) {
13714
13834
  if (!N.hold && B.callsLength > 0) throw z.error("There is already active call"), new k(O.HAS_ACTIVE_CALL);
13715
- return new $(new wc(), Mc).onJoin({
13835
+ return new $(new Ac(), Rc).onJoin({
13716
13836
  conversationId: e,
13717
13837
  mediaOptions: t,
13718
13838
  chatId: n
13719
13839
  });
13720
13840
  }
13721
- async function el(e, t = [S.AUDIO], n, r, i, a) {
13841
+ async function ol(e, t = [S.AUDIO], n, r, i, a) {
13722
13842
  if (!N.hold && B.callsLength > 0) throw z.error("There is already active call"), new k(O.HAS_ACTIVE_CALL);
13723
- return n && (N.anonymToken = n), new $(new wc(), Mc).onJoin({
13843
+ return n && (N.anonymToken = n), new $(new Ac(), Rc).onJoin({
13724
13844
  joinLink: e,
13725
13845
  mediaOptions: t,
13726
13846
  observedIds: r,
@@ -13729,30 +13849,30 @@ async function el(e, t = [S.AUDIO], n, r, i, a) {
13729
13849
  anonymous: !!N.anonymToken
13730
13850
  });
13731
13851
  }
13732
- function tl(e) {
13733
- let t = vu(e?.conversationId);
13852
+ function sl(e) {
13853
+ let t = wu(e?.conversationId);
13734
13854
  return t ? t.hangup(e) : ($.hangupAfterInit(e?.onFastHangup), Promise.resolve());
13735
13855
  }
13736
- async function nl(e, t) {
13856
+ async function cl(e, t) {
13737
13857
  let n = Array.isArray(e) ? e : [e], r = $.current();
13738
13858
  r && await r.addParticipant(n, t);
13739
13859
  }
13740
- async function rl(e, t) {
13860
+ async function ll(e, t) {
13741
13861
  let n = $.current();
13742
13862
  if (n) {
13743
13863
  let r = e.map((e) => M.composeUserId(e));
13744
13864
  await n.addParticipantLegacy(r, t);
13745
13865
  }
13746
13866
  }
13747
- async function il(e, t = !1) {
13748
- let n = Su(e, "removeParticipant");
13867
+ async function ul(e, t = !1) {
13868
+ let n = Ou(e, "removeParticipant");
13749
13869
  if (n) try {
13750
13870
  await n.conversation.removeParticipant(M.decomposeParticipantId(n.participantId).compositeUserId, t);
13751
13871
  } catch (e) {
13752
13872
  z.warn(`Failed to remove participant ${n.participantId}. Perhaps he is no longer on the call. ${e}`);
13753
13873
  }
13754
13874
  }
13755
- async function al(e, t = !1) {
13875
+ async function dl(e, t = !1) {
13756
13876
  let n = $.current();
13757
13877
  if (n) try {
13758
13878
  await n.removeParticipant(M.composeUserId(e), t);
@@ -13760,13 +13880,13 @@ async function al(e, t = !1) {
13760
13880
  z.warn(`Failed to remove participant ${e}. Perhaps he is no longer on the call. ${t}`);
13761
13881
  }
13762
13882
  }
13763
- async function ol(e, t) {
13883
+ async function fl(e, t) {
13764
13884
  let n = $.current();
13765
13885
  if (e === "videoinput" && jt.contains(t)) return N.videoFacingMode = t, n ? (E.isMobile() && n.stopVideoTrack(), n.changeDevice(e)) : void 0;
13766
13886
  if (!await E._saveDeviceId(e, t)) throw Error(`Device not found: ${t}`);
13767
13887
  if (n) return n.changeDevice(e);
13768
13888
  }
13769
- async function sl(e, t) {
13889
+ async function pl(e, t) {
13770
13890
  let n = typeof e == "object" ? {
13771
13891
  ...e,
13772
13892
  fastScreenSharing: e.captureScreen && e.fastScreenSharing,
@@ -13775,40 +13895,40 @@ async function sl(e, t) {
13775
13895
  captureScreen: e,
13776
13896
  fastScreenSharing: !1,
13777
13897
  captureAudio: !1
13778
- }, r = vu(t);
13898
+ }, r = wu(t);
13779
13899
  return r ? r.toggleScreenCapturing(n) : Promise.reject();
13780
13900
  }
13781
- function cl(e) {
13901
+ function ml(e) {
13782
13902
  let t = $.current();
13783
13903
  t && t.toggleAnimojiCapturing(e);
13784
13904
  }
13785
- async function ll(e, t = !1) {
13905
+ async function hl(e, t = !1) {
13786
13906
  let n = $.current();
13787
13907
  n && await n.setVideoStream(e, t);
13788
13908
  }
13789
- async function ul(e, t) {
13790
- let n = vu(t);
13909
+ async function gl(e, t) {
13910
+ let n = wu(t);
13791
13911
  n && await n.toggleLocalVideo(e);
13792
13912
  }
13793
- async function dl(e, t) {
13794
- let n = vu(t);
13913
+ async function _l(e, t) {
13914
+ let n = wu(t);
13795
13915
  n && await n.toggleLocalAudio(e);
13796
13916
  }
13797
- async function fl(e) {
13917
+ async function vl(e) {
13798
13918
  let t = $.current();
13799
13919
  if (t) return t.setLocalResolution(e);
13800
13920
  }
13801
- async function pl(e) {
13921
+ async function yl(e) {
13802
13922
  let t = $.current();
13803
13923
  t && await t.changePriorities(e);
13804
13924
  }
13805
- async function ml(e, t) {
13925
+ async function bl(e, t) {
13806
13926
  let n = $.current();
13807
13927
  if (n) {
13808
13928
  if (t) {
13809
13929
  let r = n.getCachedParticipantIdByExternalId(t);
13810
13930
  if (!r) {
13811
- yu(t, "changeParticipantState", n);
13931
+ Tu(t, "changeParticipantState", n);
13812
13932
  return;
13813
13933
  }
13814
13934
  await n.changeParticipantState(e, r);
@@ -13817,161 +13937,161 @@ async function ml(e, t) {
13817
13937
  await n.changeParticipantState(e);
13818
13938
  }
13819
13939
  }
13820
- async function hl() {
13940
+ async function xl() {
13821
13941
  let e = $.current();
13822
13942
  e && await e.putHandsDown();
13823
13943
  }
13824
- async function gl(e) {
13944
+ async function Sl(e) {
13825
13945
  let t = $.current();
13826
13946
  t && await t.updateDisplayLayout(e);
13827
13947
  }
13828
- async function _l(e) {
13948
+ async function Cl(e) {
13829
13949
  let t = $.current();
13830
13950
  t && await t.requestDisplayLayout(e);
13831
13951
  }
13832
- async function vl(e, t, n = !1) {
13833
- let r = Su(e, "grantRoles");
13952
+ async function wl(e, t, n = !1) {
13953
+ let r = Ou(e, "grantRoles");
13834
13954
  r && await r.conversation.grantRoles(r.participantId, t, n);
13835
13955
  }
13836
- async function yl(e, t, n, r = !1) {
13956
+ async function Tl(e, t, n, r = !1) {
13837
13957
  let i = $.current();
13838
13958
  i && await i.grantRoles(M.composeParticipantId(e, j.USER, t), n, r);
13839
13959
  }
13840
- async function bl({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
13960
+ async function El({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
13841
13961
  if (e) {
13842
- let i = Su(e, "muteParticipant");
13962
+ let i = Ou(e, "muteParticipant");
13843
13963
  return i ? i.conversation.muteParticipant(i.participantId, t, n, r) : void 0;
13844
13964
  }
13845
13965
  let i = $.current();
13846
13966
  i && await i.muteParticipant(null, t, n, r);
13847
13967
  }
13848
- async function xl({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
13968
+ async function Dl({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
13849
13969
  let a = $.current();
13850
13970
  if (a) {
13851
13971
  let o = e ? M.composeParticipantId(e, j.USER, r) : null;
13852
13972
  await a.muteParticipant(o, t, n, i);
13853
13973
  }
13854
13974
  }
13855
- async function Sl(e, t = !1, n = null) {
13856
- let r = Su(e, "pinParticipant");
13975
+ async function Ol(e, t = !1, n = null) {
13976
+ let r = Ou(e, "pinParticipant");
13857
13977
  r && await r.conversation.pinParticipant(r.participantId, t, n);
13858
13978
  }
13859
- async function Cl(e, t = !1, n = 0, r = null) {
13979
+ async function kl(e, t = !1, n = 0, r = null) {
13860
13980
  let i = $.current();
13861
13981
  i && await i.pinParticipant(M.composeParticipantId(e, j.USER, n), t, r);
13862
13982
  }
13863
- async function wl(e) {
13983
+ async function Al(e) {
13864
13984
  let t = $.current();
13865
13985
  t && await t.updateMediaModifiers(e);
13866
13986
  }
13867
- async function Tl(e) {
13987
+ async function jl(e) {
13868
13988
  let t = $.current();
13869
13989
  t && await t.enableVideoSuspend(e);
13870
13990
  }
13871
- async function El(e) {
13991
+ async function Ml(e) {
13872
13992
  let t = $.current();
13873
13993
  t && await t.enableVideoSuspendSuggest(e);
13874
13994
  }
13875
- async function Dl(e) {
13995
+ async function Nl(e) {
13876
13996
  let t = $.current();
13877
13997
  t && await t.changeOptions(e);
13878
13998
  }
13879
- async function Ol(e, t = null) {
13999
+ async function Pl(e, t = null) {
13880
14000
  if (t) {
13881
- let n = Su(t, "chatMessage");
14001
+ let n = Ou(t, "chatMessage");
13882
14002
  return n ? n.conversation.chatMessage(e, M.decomposeParticipantId(n.participantId).compositeUserId) : void 0;
13883
14003
  }
13884
14004
  let n = $.current();
13885
14005
  n && await n.chatMessage(e, null);
13886
14006
  }
13887
- async function kl(e, t = null) {
14007
+ async function Fl(e, t = null) {
13888
14008
  let n = $.current();
13889
14009
  if (n) {
13890
14010
  let r = t ? M.composeUserId(t) : null;
13891
14011
  await n.chatMessage(e, r);
13892
14012
  }
13893
14013
  }
13894
- async function Al(e = 10) {
14014
+ async function Il(e = 10) {
13895
14015
  let t = $.current();
13896
14016
  if (t) return t.chatHistory(e);
13897
14017
  }
13898
- async function jl(e, t = null) {
14018
+ async function Ll(e, t = null) {
13899
14019
  if (t) {
13900
- let n = Su(t, "customData");
14020
+ let n = Ou(t, "customData");
13901
14021
  return n ? n.conversation.customData(e, n.participantId) : void 0;
13902
14022
  }
13903
14023
  let n = $.current();
13904
14024
  n && await n.customData(e, null);
13905
14025
  }
13906
- async function Ml(e, t = null, n = 0) {
14026
+ async function Rl(e, t = null, n = 0) {
13907
14027
  let r = $.current();
13908
14028
  if (r) {
13909
14029
  let i = t ? M.composeParticipantId(t, j.USER, n) : null;
13910
14030
  await r.customData(e, i);
13911
14031
  }
13912
14032
  }
13913
- async function Nl(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
13914
- return (await jc.createConversation(a ?? M.uuid(), e, t, {
14033
+ async function zl(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
14034
+ return (await Lc.createConversation(a ?? M.uuid(), e, t, {
13915
14035
  onlyAdminCanShareMovie: n,
13916
14036
  waitForAdmin: r,
13917
14037
  closedConversation: i
13918
14038
  })).join_link;
13919
14039
  }
13920
- async function Pl(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
14040
+ async function Bl(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
13921
14041
  let a = i.map((e) => Z.fromId(e));
13922
- return (await jc.createConversation(M.uuid(), e, t, {
14042
+ return (await Lc.createConversation(M.uuid(), e, t, {
13923
14043
  onlyAdminCanShareMovie: n,
13924
14044
  audienceMode: !0,
13925
14045
  audioOnly: r
13926
14046
  }, a)).join_link;
13927
14047
  }
13928
- async function Fl() {
14048
+ async function Vl() {
13929
14049
  let e = $.current();
13930
14050
  return e ? e.createJoinLink() : Promise.reject();
13931
14051
  }
13932
- async function Il() {
14052
+ async function Hl() {
13933
14053
  let e = $.current();
13934
14054
  return e ? e.removeJoinLink() : Promise.reject();
13935
14055
  }
13936
- async function Ll(e, t) {
13937
- return jc.getAnonymTokenByLink(e, t);
14056
+ async function Ul(e, t) {
14057
+ return Lc.getAnonymTokenByLink(e, t);
13938
14058
  }
13939
- function Rl(e) {
14059
+ function Wl(e) {
13940
14060
  let t = $.current();
13941
14061
  t && t.setVolume(e);
13942
14062
  }
13943
- function zl(e) {
14063
+ function Gl(e) {
13944
14064
  N.forceRelayPolicy = e;
13945
14065
  }
13946
- async function Bl(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
14066
+ async function Kl(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
13947
14067
  let o = $.current();
13948
14068
  return o ? o.startStream(e, t, n, r, i, a) : Promise.reject();
13949
14069
  }
13950
- async function Vl(e = null, t) {
14070
+ async function ql(e = null, t) {
13951
14071
  let n = $.current();
13952
14072
  return n ? n.stopStream(e, t) : Promise.reject();
13953
14073
  }
13954
- async function Hl(e = null) {
14074
+ async function Jl(e = null) {
13955
14075
  let t = $.current();
13956
14076
  return t ? t.publishStream(e) : Promise.reject();
13957
14077
  }
13958
- async function Ul() {
14078
+ async function Yl() {
13959
14079
  let e = $.current();
13960
14080
  return e ? e.getStreamInfo() : Promise.reject();
13961
14081
  }
13962
- async function Wl(e) {
14082
+ async function Xl(e) {
13963
14083
  let t = $.current();
13964
14084
  return t ? t.addMovie(e) : Promise.reject();
13965
14085
  }
13966
- async function Gl(e) {
14086
+ async function Zl(e) {
13967
14087
  let t = $.current();
13968
14088
  return t ? t.updateMovie(e) : Promise.reject();
13969
14089
  }
13970
- async function Kl(e) {
14090
+ async function Ql(e) {
13971
14091
  let t = $.current();
13972
14092
  return t ? t.removeMovie(e) : Promise.reject();
13973
14093
  }
13974
- async function ql(e, t) {
14094
+ async function $l(e, t) {
13975
14095
  let n = $.current();
13976
14096
  if (n) {
13977
14097
  let r = [], i = [];
@@ -13993,46 +14113,46 @@ async function ql(e, t) {
13993
14113
  });
13994
14114
  }
13995
14115
  if (i.length) {
13996
- bu(i, "updateRooms", n);
14116
+ Eu(i, "updateRooms", n);
13997
14117
  return;
13998
14118
  }
13999
14119
  return n.updateRooms(r, t);
14000
14120
  }
14001
14121
  return Promise.reject();
14002
14122
  }
14003
- async function Jl(e, t) {
14123
+ async function eu(e, t) {
14004
14124
  let n = $.current();
14005
14125
  return n ? n.activateRooms(e, t) : Promise.reject();
14006
14126
  }
14007
- async function Yl(e = null, t = null) {
14127
+ async function tu(e = null, t = null) {
14008
14128
  let n = $.current();
14009
14129
  if (!n) return Promise.reject();
14010
14130
  let r;
14011
14131
  if (t && (r = n.getCachedParticipantIdByExternalId(t) ?? void 0, !r)) {
14012
- yu(t, "switchRoom", n);
14132
+ Tu(t, "switchRoom", n);
14013
14133
  return;
14014
14134
  }
14015
14135
  return n.switchRoom(e, r);
14016
14136
  }
14017
- async function Xl(e) {
14137
+ async function nu(e) {
14018
14138
  let t = $.current();
14019
14139
  return t ? t.removeRooms(e) : Promise.reject();
14020
14140
  }
14021
- function Zl(e) {
14141
+ function ru(e) {
14022
14142
  N.statisticsInterval = e;
14023
14143
  let t = $.current();
14024
14144
  if (t) return t.updateStatisticsInterval();
14025
14145
  }
14026
- function Ql(t) {
14146
+ function iu(t) {
14027
14147
  e.disableLog(!t), z.toggle(t);
14028
14148
  }
14029
- function $l(e, ...t) {
14149
+ function au(e, ...t) {
14030
14150
  N.debugLog && ($.debugMessage(e, "[external]", ...t) || z.send(e, "[external]", ...t));
14031
14151
  }
14032
- function eu(e, t, ...n) {
14152
+ function ou(e, t, ...n) {
14033
14153
  N.debugLog && ($.debugMessageWithContext(e, t, "[external]", ...n) || z.send(e, "[external]", ...n));
14034
14154
  }
14035
- var tu = {
14155
+ var su = {
14036
14156
  list: Ne,
14037
14157
  get: Pe,
14038
14158
  getJson: Fe,
@@ -14040,7 +14160,7 @@ var tu = {
14040
14160
  clear: Le,
14041
14161
  stats: Re
14042
14162
  };
14043
- function nu() {
14163
+ function cu() {
14044
14164
  let e = [
14045
14165
  [`Calls SDK ${N.sdkVersion}`, N.toJSON()],
14046
14166
  ["UserAgent:", navigator.userAgent],
@@ -14058,139 +14178,139 @@ function nu() {
14058
14178
  d: e
14059
14179
  }));
14060
14180
  }
14061
- async function ru() {
14181
+ async function lu() {
14062
14182
  let e = $.id(), t = $.debugSessionId();
14063
14183
  if (!t || !e) throw z.error("[uploadDebugLogs]", "No conversation id found"), Error("No conversation id found");
14064
14184
  let n = await Pe({ sessionId: t });
14065
14185
  if (n.length === 0) throw z.error("[uploadDebugLogs]", "No logs found"), Error("No logs found");
14066
14186
  let r = n[0].t, i = n[n.length - 1].t;
14067
14187
  try {
14068
- return jc?.uploadDebugLogs(e, r, i, JSON.stringify([...nu(), ...n]));
14188
+ return Lc?.uploadDebugLogs(e, r, i, JSON.stringify([...cu(), ...n]));
14069
14189
  } catch (e) {
14070
14190
  throw z.error("[uploadDebugLogs]", "Error while uploading logs", e), Error("Error while uploading logs", { cause: e });
14071
14191
  }
14072
14192
  }
14073
- async function iu(e) {
14193
+ async function uu(e) {
14074
14194
  let t = $.current();
14075
14195
  if (t) return t.videoEffect(e);
14076
14196
  }
14077
- async function au(e, t) {
14197
+ async function du(e, t) {
14078
14198
  let n = $.current();
14079
14199
  if (n) return n.audioEffect(e.length > 0 ? e : null, t);
14080
14200
  }
14081
- async function ou(e) {
14201
+ async function fu(e) {
14082
14202
  let t = $.current();
14083
14203
  t && await t.setAudioStream(e);
14084
14204
  }
14085
- async function su(e, t = null, n = null) {
14205
+ async function pu(e, t = null, n = null) {
14086
14206
  let r = $.current();
14087
14207
  if (!r) return;
14088
14208
  let i = n ?? t?.id, a = null;
14089
14209
  if (t && (a = r.getCachedParticipantIdByExternalId(t), !a)) {
14090
- yu(t, "setVmojiSvg", r);
14210
+ Tu(t, "setVmojiSvg", r);
14091
14211
  return;
14092
14212
  }
14093
14213
  r.setAnimojiSvg(e, a, i);
14094
14214
  }
14095
- function cu(e) {
14215
+ function mu(e) {
14096
14216
  let t = $.current();
14097
14217
  t && t.setAnimojiFill(e);
14098
14218
  }
14099
- async function lu(e = null, t, n = !1) {
14100
- return xu().getWaitingHall(e, t, n);
14219
+ async function hu(e = null, t, n = !1) {
14220
+ return Du().getWaitingHall(e, t, n);
14101
14221
  }
14102
- async function uu() {
14103
- return xu().getAudienceModeHands();
14222
+ async function gu() {
14223
+ return Du().getAudienceModeHands();
14104
14224
  }
14105
- async function du(e, t = !1) {
14106
- let n = xu(), r;
14225
+ async function _u(e, t = !1) {
14226
+ let n = Du(), r;
14107
14227
  if (e) {
14108
14228
  let t = n.getCachedParticipantIdByExternalId(e);
14109
14229
  if (!t) {
14110
- yu(e, "promoteParticipant", n);
14230
+ Tu(e, "promoteParticipant", n);
14111
14231
  return;
14112
14232
  }
14113
14233
  r = M.decomposeParticipantId(t).compositeUserId;
14114
14234
  }
14115
14235
  return n.promoteParticipant(r, t);
14116
14236
  }
14117
- async function fu(e = !1) {
14118
- return xu().requestPromotion(e);
14237
+ async function vu(e = !1) {
14238
+ return Du().requestPromotion(e);
14119
14239
  }
14120
- async function pu(e = !1) {
14121
- return xu().acceptPromotion(e);
14240
+ async function yu(e = !1) {
14241
+ return Du().acceptPromotion(e);
14122
14242
  }
14123
- async function mu(e) {
14124
- return xu().getParticipantListChunk(e);
14243
+ async function bu(e) {
14244
+ return Du().getParticipantListChunk(e);
14125
14245
  }
14126
- async function hu(e) {
14127
- return xu().getParticipants(e);
14246
+ async function xu(e) {
14247
+ return Du().getParticipants(e);
14128
14248
  }
14129
- async function gu(e) {
14130
- return xu().feedback(e);
14249
+ async function Su(e) {
14250
+ return Du().feedback(e);
14131
14251
  }
14132
- async function _u(e, t, n) {
14133
- return xu(n).enableFeatureForRoles(e, t);
14252
+ async function Cu(e, t, n) {
14253
+ return Du(n).enableFeatureForRoles(e, t);
14134
14254
  }
14135
- function vu(e) {
14255
+ function wu(e) {
14136
14256
  return e ? B.get(e) ?? null : $.current() ?? B.getFirst();
14137
14257
  }
14138
- function yu(e, t, n) {
14258
+ function Tu(e, t, n) {
14139
14259
  R.onNonFatalError(/* @__PURE__ */ Error(`Participant ID mapping not found for external ID "${e.id}" while handling ${t}`), n.id);
14140
14260
  }
14141
- function bu(e, t, n) {
14261
+ function Eu(e, t, n) {
14142
14262
  let r = Array.from(new Set(e));
14143
14263
  R.onNonFatalError(/* @__PURE__ */ Error(`Participant ID mapping not found for external IDs "${r.join("\", \"")}" while handling ${t}`), n.id);
14144
14264
  }
14145
- function xu(e) {
14146
- let t = vu(e);
14265
+ function Du(e) {
14266
+ let t = wu(e);
14147
14267
  if (!t) throw Error("Conversation not found");
14148
14268
  return t;
14149
14269
  }
14150
- function Su(e, t) {
14270
+ function Ou(e, t) {
14151
14271
  let n = $.current();
14152
14272
  if (!n) return null;
14153
14273
  let r = n.getCachedParticipantIdByExternalId(e);
14154
14274
  return r ? {
14155
14275
  conversation: n,
14156
14276
  participantId: r
14157
- } : (yu(e, t, n), null);
14277
+ } : (Tu(e, t, n), null);
14158
14278
  }
14159
- async function Cu(e) {
14160
- await jc.removeHistoryRecords(e);
14279
+ async function ku(e) {
14280
+ await Lc.removeHistoryRecords(e);
14161
14281
  }
14162
- async function wu(e) {
14282
+ async function Au(e) {
14163
14283
  let t = $.current() ?? B.getFirst();
14164
14284
  t && await t.startAsr(e);
14165
14285
  }
14166
- async function Tu(e) {
14286
+ async function ju(e) {
14167
14287
  let t = $.current() ?? B.getFirst();
14168
14288
  t && await t.stopAsr(e);
14169
14289
  }
14170
- async function Eu(e) {
14290
+ async function Mu(e) {
14171
14291
  let t = $.current() ?? B.getFirst();
14172
14292
  t && await t.requestAsr(e);
14173
14293
  }
14174
- async function Du(e) {
14294
+ async function Nu(e) {
14175
14295
  let t = $.current();
14176
14296
  return t ? t.startUrlSharing(e) : Promise.reject();
14177
14297
  }
14178
- async function Ou() {
14298
+ async function Pu() {
14179
14299
  let e = $.current();
14180
14300
  return e ? e.stopUrlSharing() : Promise.reject();
14181
14301
  }
14182
- async function ku(e) {
14302
+ async function Fu(e) {
14183
14303
  await B.switchCall(e);
14184
14304
  }
14185
- function Au() {
14305
+ function Iu() {
14186
14306
  return B.getActiveId();
14187
14307
  }
14188
- function ju() {
14308
+ function Lu() {
14189
14309
  return $.getSyncedTime();
14190
14310
  }
14191
- function Mu() {
14311
+ function Ru() {
14192
14312
  return N.sdkVersion;
14193
14313
  }
14194
14314
  typeof window < "u" && (window.__CALLS_SDK = xn);
14195
14315
  //#endregion
14196
- export { wc as Api, Ac as ApiExternal, kc as ArrayDequeue, y as AuthData, f as BaseLogger, to as CallDirection, no as CallType, ro as ChatRoomEventType, io as ConversationFeature, ao as ConversationOption, wn as DebugMessageType, _o as ExternalIdType, jt as FacingMode, x as FatalError, k as HangupReason, O as HangupType, S as MediaOption, A as MediaTrackKind, H as MediaType, co as MuteState, X as ParticipantState, Oc as ParticipantStateDataValue, P as ParticipantStatus, Dc as RecordRole, lo as RoomsEventType, eo as Signaling, V as SignalingCommandType, br as SignalingConnectionType, K as SignalingNotification, U as Stat, J as TransportTopology, po as UserRole, j as UserType, Bo as VolumeDetector, Xc as acceptCall, pu as acceptPromotion, Jl as activateRooms, Wl as addMovie, nl as addParticipant, rl as addParticipantInternal, Yc as authorize, Pc as browser, Wc as callInternal, Hc as callTo, sl as captureScreen, cl as captureVmoji, au as changeAudioEffect, Dl as changeConversationOptions, ol as changeDevice, ml as changeParticipantState, pl as changePriorities, iu as changeVideoEffect, Al as chatHistory, Ol as chatMessage, kl as chatMessageInternal, Fl as createJoinLink, jl as customData, Ml as customDataInternal, Ql as debug, tu as debugLogs, $l as debugMessage, eu as debugMessageWithContext, Zc as declineCall, _u as enableFeatureForRoles, Tl as enableVideoSuspend, El as enableVideoSuspendSuggest, gu as feedback, zl as forceRelayPolicy, Au as getActiveCallId, Ll as getAnonymTokenByLink, uu as getAudienceModeHands, qc as getInbounds, mu as getParticipantListChunk, hu as getParticipants, Ul as getStreamInfo, ju as getSyncedTime, lu as getWaitingHall, vl as grantRoles, yl as grantRolesInternal, tl as hangup, Vc as init, Qc as joinCall, el as joinCallByLink, $c as joinCallInternal, bl as muteParticipant, xl as muteParticipantInternal, Sl as pinParticipant, Cl as pinParticipantInternal, Gc as processPush, Kc as processPushInternal, du as promoteParticipant, Hl as publishStream, hl as putHandsDown, Cu as removeHistoryRecords, Il as removeJoinLink, Kl as removeMovie, il as removeParticipant, al as removeParticipantInternal, Xl as removeRooms, Eu as requestAsr, _l as requestDisplayLayout, fu as requestPromotion, Rc as setAudioEffects, ou as setAudioStream, fl as setLocalResolution, Ic as setLogger, wl as setMediaModifiers, Zl as setStatisticsInterval, zc as setVad, Lc as setVideoEffects, ll as setVideoStream, Bc as setVmoji, cu as setVmojiFill, su as setVmojiSvg, Rl as setVolume, wu as startAsr, Pl as startAudienceConversation, Nl as startConversation, Jc as startStats, Bl as startStream, Du as startUrlSharing, Tu as stopAsr, Vl as stopStream, Ou as stopUrlSharing, ku as switchCall, Yl as switchRoom, dl as toggleLocalAudio, ul as toggleLocalVideo, gl as updateDisplayLayout, Gl as updateMovie, ql as updateRooms, ru as uploadDebugLogs, Fc as utils, Mu as version };
14316
+ export { Ac as Api, Ic as ApiExternal, Fc 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, Pc as ParticipantStateDataValue, P as ParticipantStatus, Nc 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, nl as acceptCall, yu as acceptPromotion, eu as activateRooms, Xl as addMovie, cl as addParticipant, ll as addParticipantInternal, tl as authorize, Bc as browser, Xc as callInternal, Jc as callTo, pl as captureScreen, ml as captureVmoji, du as changeAudioEffect, Nl as changeConversationOptions, fl as changeDevice, bl as changeParticipantState, yl as changePriorities, uu as changeVideoEffect, Il as chatHistory, Pl as chatMessage, Fl as chatMessageInternal, Vl as createJoinLink, Ll as customData, Rl as customDataInternal, iu as debug, su as debugLogs, au as debugMessage, ou as debugMessageWithContext, rl as declineCall, Cu as enableFeatureForRoles, jl as enableVideoSuspend, Ml as enableVideoSuspendSuggest, Su as feedback, Gl as forceRelayPolicy, Iu as getActiveCallId, Ul as getAnonymTokenByLink, gu as getAudienceModeHands, $c as getInbounds, bu as getParticipantListChunk, xu as getParticipants, Yl as getStreamInfo, Lu as getSyncedTime, hu as getWaitingHall, wl as grantRoles, Tl as grantRolesInternal, sl as hangup, qc as init, il as joinCall, ol as joinCallByLink, al as joinCallInternal, El as muteParticipant, Dl as muteParticipantInternal, Ol as pinParticipant, kl as pinParticipantInternal, Zc as processPush, Qc as processPushInternal, _u as promoteParticipant, Jl as publishStream, xl as putHandsDown, ku as removeHistoryRecords, Hl as removeJoinLink, Ql as removeMovie, ul as removeParticipant, dl as removeParticipantInternal, nu as removeRooms, Mu as requestAsr, Cl as requestDisplayLayout, vu as requestPromotion, Wc as setAudioEffects, fu as setAudioStream, vl as setLocalResolution, Hc as setLogger, Al as setMediaModifiers, ru as setStatisticsInterval, Gc as setVad, Uc as setVideoEffects, hl as setVideoStream, Kc as setVmoji, mu as setVmojiFill, pu as setVmojiSvg, Wl as setVolume, Au as startAsr, Bl as startAudienceConversation, zl as startConversation, el as startStats, Kl as startStream, Nu as startUrlSharing, ju as stopAsr, ql as stopStream, Pu as stopUrlSharing, Fu as switchCall, tu as switchRoom, _l as toggleLocalAudio, gl as toggleLocalVideo, Sl as updateDisplayLayout, Zl as updateMovie, $l as updateRooms, lu as uploadDebugLogs, Vc as utils, Ru as version };