@vkontakte/calls-sdk 2.8.13-dev.5c559492.0 → 2.8.13-dev.6834d8f4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/calls-sdk.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * @vkontakte/calls-sdk v2.8.13-dev.5c559492.0
3
- * Fri, 02 Oct 2026 12:29:14 GMT
2
+ * @vkontakte/calls-sdk v2.8.13-dev.6834d8f4.0
3
+ * Wed, 14 Oct 2026 07:52:37 GMT
4
4
  * https://calls-sdk.cdn-vk.ru/doc/latest/index.html
5
5
  */
6
6
 
@@ -121,7 +121,6 @@ var v = new class {
121
121
  t.objectStore(g).clear(), t.objectStore(_).clear(), await this.txDone(t).catch((e) => console.warn("Failed to clear debug log storage", e));
122
122
  }
123
123
  }
124
- this.close();
125
124
  }
126
125
  async getAllSessions() {
127
126
  let e = await this.open();
@@ -2182,7 +2181,7 @@ var xn = bn.getInstance(), N = class e {
2182
2181
  return 1.1;
2183
2182
  }
2184
2183
  static get sdkVersion() {
2185
- return "2.8.13-dev.5c559492.0";
2184
+ return "2.8.13-dev.6834d8f4.0";
2186
2185
  }
2187
2186
  static get debug() {
2188
2187
  return e._params.debug;
@@ -2310,6 +2309,9 @@ var xn = bn.getInstance(), N = class e {
2310
2309
  static get signalingReconnectMaxCount() {
2311
2310
  return e._params.signalingReconnectMaxCount;
2312
2311
  }
2312
+ static get signalingReconnectMaxDuration() {
2313
+ return e._params.signalingReconnectMaxDuration;
2314
+ }
2313
2315
  static get waitConnectionDelay() {
2314
2316
  return e._params.waitConnectionDelay;
2315
2317
  }
@@ -2448,6 +2450,9 @@ var xn = bn.getInstance(), N = class e {
2448
2450
  static get callStatReportEnabled() {
2449
2451
  return e._params.callStatReportEnabled;
2450
2452
  }
2453
+ static get iceCandidateErrorStatEnabled() {
2454
+ return e._params.iceCandidateErrorStatEnabled;
2455
+ }
2451
2456
  static get enableLogPerfStatReport() {
2452
2457
  return e._params.enableLogPerfStatReport;
2453
2458
  }
@@ -2612,6 +2617,7 @@ var xn = bn.getInstance(), N = class e {
2612
2617
  videoSuspend: e._params.videoSuspend,
2613
2618
  debugLog: e._params.debugLog,
2614
2619
  callStatReportEnabled: e._params.callStatReportEnabled,
2620
+ iceCandidateErrorStatEnabled: e._params.iceCandidateErrorStatEnabled,
2615
2621
  joinFromMultipleDevices: e._params.joinFromMultipleDevices,
2616
2622
  movieShare: e._params.movieShare,
2617
2623
  clientType: e._params.clientType,
@@ -2654,6 +2660,7 @@ h(N, "_params", {
2654
2660
  signalingReconnectDelay: 1e3,
2655
2661
  signalingReconnectMaxDelay: 5e3,
2656
2662
  signalingReconnectMaxCount: 10,
2663
+ signalingReconnectMaxDuration: 6e4,
2657
2664
  waitConnectionDelay: 1e4,
2658
2665
  waitResponseDelay: 1e4,
2659
2666
  waitMessageDelay: 15e3,
@@ -2687,6 +2694,7 @@ h(N, "_params", {
2687
2694
  networkStatisticsInterval: 2e4,
2688
2695
  perfStatReportEnabled: !0,
2689
2696
  callStatReportEnabled: !1,
2697
+ iceCandidateErrorStatEnabled: !1,
2690
2698
  enableLogPerfStatReport: !1,
2691
2699
  voiceParams: {
2692
2700
  smoothing: .8,
@@ -3023,7 +3031,12 @@ var Cn;
3023
3031
  }
3024
3032
  e.onStatistics = Ue;
3025
3033
  function We(e) {
3026
- F("onClientStats", e);
3034
+ let t = N.get("onClientStats");
3035
+ if (typeof t == "function") try {
3036
+ t(e);
3037
+ } catch (e) {
3038
+ z.error("[CallsSDK] onClientStats callback failed", e);
3039
+ }
3027
3040
  }
3028
3041
  e.onClientStats = We;
3029
3042
  function Ge() {
@@ -3634,7 +3647,7 @@ var Bn = 0, Vn = 1, Hn = 2, Un = 3, Wn = 4, Gn = 5, Kn = 6, qn = 7, Jn = 0, Yn =
3634
3647
  };
3635
3648
  }
3636
3649
  }, 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;
3650
+ 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
3651
  }(U || {}), nr = 1e3;
3639
3652
  function W(e, t, n = 0) {
3640
3653
  return t in e && e[t] ? e[t] : n;
@@ -3886,11 +3899,11 @@ var Nr = {
3886
3899
  pranswer: U.SDP_SET_REMOTE_PRANSWER,
3887
3900
  answer: U.SDP_SET_REMOTE_ANSWER,
3888
3901
  rollback: U.SDP_SET_REMOTE_ROLLBACK
3889
- }, Ir = {
3902
+ }, Ir = 120 * 1e3, Lr = {
3890
3903
  local_address: null,
3891
3904
  remote_address: null,
3892
3905
  transport: null
3893
- }, Lr = class {
3906
+ }, Rr = class {
3894
3907
  constructor(e) {
3895
3908
  h(this, "_statAggregator", void 0), h(this, "_pc", null), h(this, "_gatheringStartedAt", 0), h(this, "_remoteSdpReceivedAt", 0), h(this, "_handleGatheringStateChange", () => {
3896
3909
  this._pc?.iceGatheringState === "gathering" && (this._gatheringStartedAt = Date.now());
@@ -3907,14 +3920,14 @@ var Nr = {
3907
3920
  name: U.SDP_GENERATED,
3908
3921
  value: 0,
3909
3922
  string_value: e,
3910
- ...Ir
3923
+ ...Lr
3911
3924
  });
3912
3925
  }
3913
3926
  logCandidateGenerated(e) {
3914
- let t = zr(e.candidate);
3927
+ let t = Br(e.candidate);
3915
3928
  t && this._log({
3916
3929
  name: U.SDP_GENERATED,
3917
- value: Math.max(0, Date.now() - this._gatheringStartedAt),
3930
+ value: this._intervalSince(this._gatheringStartedAt),
3918
3931
  string_value: t.type,
3919
3932
  local_address: t.address,
3920
3933
  remote_address: null,
@@ -3926,14 +3939,14 @@ var Nr = {
3926
3939
  name: U.SDP_RECEIVED,
3927
3940
  value: 0,
3928
3941
  string_value: e,
3929
- ...Ir
3942
+ ...Lr
3930
3943
  });
3931
3944
  }
3932
3945
  logCandidateReceived(e) {
3933
- let t = zr(e.candidate);
3946
+ let t = Br(e.candidate);
3934
3947
  t && this._log({
3935
3948
  name: U.SDP_RECEIVED,
3936
- value: this._remoteSdpReceivedAt > 0 ? Math.max(0, Date.now() - this._remoteSdpReceivedAt) : 0,
3949
+ value: this._remoteSdpReceivedAt > 0 ? this._intervalSince(this._remoteSdpReceivedAt) : 0,
3937
3950
  string_value: t.type,
3938
3951
  local_address: null,
3939
3952
  remote_address: t.address,
@@ -3959,49 +3972,120 @@ var Nr = {
3959
3972
  destroy() {
3960
3973
  this.stop();
3961
3974
  }
3975
+ _intervalSince(e) {
3976
+ return Math.min(Ir, Math.max(0, Date.now() - e));
3977
+ }
3962
3978
  _logFailure(e, t, n) {
3963
3979
  this._log({
3964
3980
  name: e,
3965
3981
  value: 0,
3966
3982
  string_value: JSON.stringify({
3967
3983
  error: t instanceof Error ? t.message : String(t),
3968
- local: Rr(n.local),
3969
- remote: Rr(n.remote)
3984
+ local: zr(n.local),
3985
+ remote: zr(n.remote)
3970
3986
  }),
3971
- ...Ir
3987
+ ...Lr
3972
3988
  });
3973
3989
  }
3974
3990
  _log(e) {
3975
3991
  this._statAggregator?.logEventualStat(e);
3976
3992
  }
3977
3993
  };
3978
- function Rr(e) {
3994
+ function zr(e) {
3979
3995
  return e ? {
3980
3996
  type: e.type,
3981
3997
  sdp: e.sdp
3982
3998
  } : void 0;
3983
3999
  }
3984
- function zr(e) {
4000
+ function Br(e) {
3985
4001
  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 : {
4002
+ return r === void 0 || i === void 0 || a === void 0 || !Ur(i) ? null : {
3987
4003
  protocol: r,
3988
4004
  address: i,
3989
4005
  type: a
3990
4006
  };
3991
4007
  }
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);
4008
+ var Vr = /^\d{1,3}(\.\d{1,3}){3}$/, Hr = /^[0-9a-f:]+$/i;
4009
+ function Ur(e) {
4010
+ return Vr.test(e) || e.includes(":") && Hr.test(e);
3995
4011
  }
3996
4012
  //#endregion
3997
- //#region src/classes/stat/FirstMediaSentProbe.ts
3998
- var Ur = 200;
3999
- function Wr(e) {
4013
+ //#region src/classes/stat/PeerConnectionStats.ts
4014
+ var Wr = /[?&]transport=(tcp|udp)/i, Gr = {
4015
+ stable: "stable",
4016
+ "have-local-offer": "have.local.offer",
4017
+ "have-local-pranswer": "have.local.answer",
4018
+ "have-remote-offer": "have.remote.offer",
4019
+ "have-remote-pranswer": "have.remote.answer",
4020
+ closed: "closed"
4021
+ }, Kr = class {
4022
+ constructor(e) {
4023
+ h(this, "_statAggregator", void 0), h(this, "_pc", null), h(this, "_lastSignalingStateChange", 0), h(this, "_lastGatheringStateChange", 0), h(this, "_lastConnectionState", null), h(this, "_handleConnectionStateChange", () => {
4024
+ this._pc && this._logConnectionState(this._pc.connectionState);
4025
+ }), h(this, "_handleSignalingStateChange", () => {
4026
+ let e = this._pc?.signalingState;
4027
+ this._log({
4028
+ name: U.SIGNALING_STATE_CHANGED,
4029
+ value: this._sinceLastChange("_lastSignalingStateChange"),
4030
+ string_value: e ? Gr[e] : void 0
4031
+ });
4032
+ }), h(this, "_handleGatheringStateChange", () => {
4033
+ let e = this._pc?.iceGatheringState, t = this._sinceLastChange("_lastGatheringStateChange");
4034
+ this._log({
4035
+ name: U.GATHERING_STATE_CHANGED,
4036
+ value: e === "new" ? 0 : t,
4037
+ string_value: e
4038
+ });
4039
+ }), h(this, "_handleIceCandidateError", (e) => {
4040
+ if (!N.iceCandidateErrorStatEnabled) return;
4041
+ let t = e;
4042
+ this._log({
4043
+ name: U.ICE_CANDIDATE_GATHERING_FAILED,
4044
+ value: t.errorCode,
4045
+ string_value: t.errorText,
4046
+ local_address: t.address ?? "",
4047
+ remote_url: t.url,
4048
+ transport: Wr.exec(t.url ?? "")?.[1]?.toLowerCase() ?? null
4049
+ });
4050
+ }), this._statAggregator = e;
4051
+ }
4052
+ observe(e) {
4053
+ 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);
4054
+ }
4055
+ stop() {
4056
+ 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);
4057
+ }
4058
+ logIceRestart() {
4059
+ this._log({ name: U.ICE_RESTART });
4060
+ }
4061
+ logIceCandidateAddFailed(e, t) {
4062
+ this._log({
4063
+ name: U.ICE_CANDIDATE_ADD_FAILED,
4064
+ value: t instanceof DOMException ? t.code : 0,
4065
+ string_value: t instanceof Error ? `${t.name}: ${t.message}` : String(t),
4066
+ remote_url: e.candidate
4067
+ });
4068
+ }
4069
+ _sinceLastChange(e) {
4070
+ let t = Date.now(), n = this[e] === 0 ? 0 : t - this[e];
4071
+ return this[e] = t, n;
4072
+ }
4073
+ _logConnectionState(e) {
4074
+ e !== this._lastConnectionState && (this._lastConnectionState = e, this._log({
4075
+ name: U.CONNECTION_STATE_CHANGED,
4076
+ connection_state: e
4077
+ }));
4078
+ }
4079
+ _log(e) {
4080
+ this._statAggregator?.logEventualStat(e);
4081
+ }
4082
+ }, qr = 200;
4083
+ function Jr(e) {
4000
4084
  for (let t of e.values()) if (t.type === "outbound-rtp" && (t.packetsSent ?? 0) > 0) return !0;
4001
4085
  return !1;
4002
4086
  }
4003
- var Gr = class {
4004
- constructor(e, t, n = Ur) {
4087
+ var Yr = class {
4088
+ constructor(e, t, n = qr) {
4005
4089
  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
4090
  }
4007
4091
  start() {
@@ -4024,7 +4108,7 @@ var Gr = class {
4024
4108
  try {
4025
4109
  let e = await this._getStatsReports();
4026
4110
  if (this._state !== "polling") return;
4027
- if (e.some(Wr)) {
4111
+ if (e.some(Jr)) {
4028
4112
  this._state = "stopped", this._onFirstMediaSent();
4029
4113
  return;
4030
4114
  }
@@ -4037,7 +4121,7 @@ var Gr = class {
4037
4121
  this._timer = null, this._poll();
4038
4122
  }, this._pollIntervalMs));
4039
4123
  }
4040
- }, Kr = class extends b {
4124
+ }, Xr = class extends b {
4041
4125
  constructor(e, t, n = null) {
4042
4126
  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
4127
  }
@@ -4048,12 +4132,12 @@ var Gr = class {
4048
4132
  this._firstMediaSentProbeStopped = !0, this._disposeFirstMediaSentProbe();
4049
4133
  }
4050
4134
  _startFirstMediaSentProbe() {
4051
- this._disposeFirstMediaSentProbe(), !(!this._pc || !this._onFirstMediaSent || this._firstMediaSentProbeStopped) && (this._firstMediaSentProbe = new Gr(this._pc, this._onFirstMediaSent), this._firstMediaSentProbe.start());
4135
+ this._disposeFirstMediaSentProbe(), !(!this._pc || !this._onFirstMediaSent || this._firstMediaSentProbeStopped) && (this._firstMediaSentProbe = new Yr(this._pc, this._onFirstMediaSent), this._firstMediaSentProbe.start());
4052
4136
  }
4053
4137
  _disposeFirstMediaSentProbe() {
4054
4138
  this._firstMediaSentProbe?.destroy(), this._firstMediaSentProbe = null;
4055
4139
  }
4056
- }, qr = class {
4140
+ }, Zr = class {
4057
4141
  constructor(e, t = null) {
4058
4142
  h(this, "weightUp", void 0), h(this, "weightDown", void 0), h(this, "value", NaN), this.weightUp = e, this.weightDown = t ?? e;
4059
4143
  }
@@ -4071,7 +4155,7 @@ var Gr = class {
4071
4155
  getValue() {
4072
4156
  return this.value;
4073
4157
  }
4074
- }, Jr = .25, Yr = .35, Xr = 85, Zr = .1, Qr = 1.5, $r = .1, ei = 1, ti = .6, ni = .3, ri = class extends b {
4158
+ }, Qr = .25, $r = .35, ei = 85, ti = .1, ni = 1.5, ri = .1, ii = 1, ai = .6, oi = .3, si = class extends b {
4075
4159
  constructor(e, t = z) {
4076
4160
  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
4161
  badNet: {
@@ -4083,8 +4167,8 @@ var Gr = class {
4083
4167
  rtt: 600
4084
4168
  }
4085
4169
  }), 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),
4170
+ rtt: new Zr(Qr, Qr),
4171
+ loss: new Zr($r, $r),
4088
4172
  bitrate: 0
4089
4173
  }, this._remoteNetworkStat = {
4090
4174
  rtt: 0,
@@ -4099,20 +4183,20 @@ var Gr = class {
4099
4183
  _calcRttRating(e) {
4100
4184
  let t = typeof e == "number" ? e : e.getValue(), n = 1;
4101
4185
  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;
4186
+ let r = Math.round((t - this._networkLimits.goodNet.rtt) / ei);
4187
+ for (let e = 0; e < r; e++) n *= 1 - ti;
4104
4188
  return n;
4105
4189
  }
4106
4190
  _calcLossRating(e) {
4107
4191
  let t = typeof e == "number" ? e : e.getValue(), n = 1;
4108
4192
  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;
4193
+ let r = Math.round((t - this._networkLimits.goodNet.loss) / ni);
4194
+ for (let e = 0; e < r; e++) n *= 1 - ri;
4111
4195
  return n;
4112
4196
  }
4113
4197
  _calcBitrateRating(e, t) {
4114
4198
  if (!e || !t) return 1;
4115
- let n = 1 - (1 - Math.min(e, t) / Math.max(e, t)) * ei;
4199
+ let n = 1 - (1 - Math.min(e, t) / Math.max(e, t)) * ii;
4116
4200
  return Math.min(n, 1);
4117
4201
  }
4118
4202
  _calcUDPRating({ rtt: e, loss: t }) {
@@ -4122,7 +4206,7 @@ var Gr = class {
4122
4206
  return n ? this._calcBitrateRating(e.bitrate, t.bitrate) : this._calcUDPRating(e) * this._calcUDPRating(t);
4123
4207
  }
4124
4208
  _getNetworkState(e) {
4125
- return isNaN(e) || e >= ti ? "good" : e >= ni ? "medium" : "bad";
4209
+ return isNaN(e) || e >= ai ? "good" : e >= oi ? "medium" : "bad";
4126
4210
  }
4127
4211
  updateSettings(e) {
4128
4212
  Object.assign(this._networkLimits.badNet, e?.badNet || {}), Object.assign(this._networkLimits.goodNet, e?.goodNet || {});
@@ -4146,7 +4230,7 @@ var Gr = class {
4146
4230
  let { rtt: t, loss: n, bitrate: r } = e || {};
4147
4231
  this._remoteNetworkStat.rtt = t || 0, this._remoteNetworkStat.loss = n || 0, this._remoteNetworkStat.bitrate = r || 0;
4148
4232
  }
4149
- }, ii = 30 * 1e3, ai = class e extends Kr {
4233
+ }, ci = 30 * 1e3, li = class e extends Xr {
4150
4234
  constructor(e, t, n, r, i, a = z, o = null, s = null, c = null, l = null) {
4151
4235
  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
4236
  bad: {
@@ -4161,7 +4245,7 @@ var Gr = class {
4161
4245
  worst: 320,
4162
4246
  bad: 640,
4163
4247
  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));
4248
+ }), 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
4249
  try {
4166
4250
  this._pc = this._createPeerConnection();
4167
4251
  } catch (e) {
@@ -4265,12 +4349,12 @@ var Gr = class {
4265
4349
  iceServers: N.iceServers,
4266
4350
  iceTransportPolicy: N.forceRelayPolicy ? "relay" : "all"
4267
4351
  });
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) => {
4352
+ 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
4353
  this._animojiDataChannel = e, this._animojiDataChannel.binaryType = "arraybuffer", this._animojiReceiver?.setDataChannel(this._animojiDataChannel), this._animojiSender?.setDataChannel(this._animojiDataChannel);
4270
4354
  }), e;
4271
4355
  }
4272
4356
  _disposePeerConnection() {
4273
- if (this._disposeFirstMediaSentProbe(), this._sdpStats.stop(), this._lastStat = null, this._remoteStream) {
4357
+ if (this._disposeFirstMediaSentProbe(), this._sdpStats.stop(), this._peerConnectionStats.stop(), this._lastStat = null, this._remoteStream) {
4274
4358
  let e = this._remoteStream;
4275
4359
  e.getTracks().forEach((t) => {
4276
4360
  t.stop(), this._triggerEvent(Y.REMOTE_TRACK_REMOVED, e, t);
@@ -4319,7 +4403,7 @@ var Gr = class {
4319
4403
  try {
4320
4404
  await this._pc.addIceCandidate(new RTCIceCandidate(t));
4321
4405
  } catch (e) {
4322
- throw this._logger?.log(C.ERROR, "addIceCandidate-direct"), this._debug.error("Unable to add remote ice candidate", e, {
4406
+ throw this._logger?.log(C.ERROR, "addIceCandidate-direct"), this._peerConnectionStats.logIceCandidateAddFailed(t, e), this._debug.error("Unable to add remote ice candidate", e, {
4323
4407
  participantId: this._participantId,
4324
4408
  candidate: t
4325
4409
  }), e;
@@ -4438,7 +4522,7 @@ var Gr = class {
4438
4522
  this._reconnectionTimeout && (clearTimeout(this._reconnectionTimeout), this._reconnectionTimeout = null), this._iceRestartTimeout && (clearTimeout(this._iceRestartTimeout), this._iceRestartTimeout = null);
4439
4523
  }
4440
4524
  _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(() => {
4525
+ 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
4526
  this._iceRestartTimeout = null, this._debug.error("Ice restart failed", { participantId: this._participantId }), this._logger?.log(C.ERROR, "iceRestart-direct"), this._requestTopologySwitch(N.switchTopologyOnReconnectFromAnySide);
4443
4527
  }, N.iceRestartWaitTime);
4444
4528
  }
@@ -4560,7 +4644,7 @@ var Gr = class {
4560
4644
  async _checkPPTNetwork(e) {
4561
4645
  if (!N.switchVideoAtBadNetwork || !e.inbound.transport.averageNetStat) return;
4562
4646
  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;
4647
+ 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
4648
  let s = this._serverSettings.camera;
4565
4649
  if (!s || !await this._isSVCSupported(e, o)) return;
4566
4650
  this._debug.debug("Switch outbound video frame size and scalabilityMode", {
@@ -4625,9 +4709,9 @@ var Gr = class {
4625
4709
  }, n(r)) : this._debug.error(`[${t}] data channel open failed, state [${e}]`);
4626
4710
  };
4627
4711
  }
4628
- }, oi = /* @__PURE__ */ function(e) {
4712
+ }, ui = /* @__PURE__ */ function(e) {
4629
4713
  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 {
4714
+ }({}), di = 16, fi = class e {
4631
4715
  constructor(e, t, n, r = z) {
4632
4716
  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
4717
  }
@@ -4641,7 +4725,7 @@ var Gr = class {
4641
4725
  ssrc: a,
4642
4726
  timestamp: o,
4643
4727
  duration: s,
4644
- data: e.slice(si)
4728
+ data: e.slice(di)
4645
4729
  };
4646
4730
  }
4647
4731
  _onDataChannelMessage(t) {
@@ -4661,7 +4745,7 @@ var Gr = class {
4661
4745
  destroy() {
4662
4746
  this._datachannel.onmessage = null;
4663
4747
  }
4664
- }, li, ui = class {
4748
+ }, pi, mi = class {
4665
4749
  constructor() {
4666
4750
  h(this, "_value", 1);
4667
4751
  }
@@ -4672,10 +4756,10 @@ var Gr = class {
4672
4756
  this._value = e;
4673
4757
  }
4674
4758
  };
4675
- li = ui, h(ui, "_instance", null), h(ui, "getInstance", () => (li._instance || (li._instance = new li()), li._instance));
4759
+ pi = mi, h(mi, "_instance", null), h(mi, "getInstance", () => (pi._instance || (pi._instance = new pi()), pi._instance));
4676
4760
  //#endregion
4677
4761
  //#region src/classes/ParticipantIdRegistry.ts
4678
- var di = class {
4762
+ var hi = class {
4679
4763
  constructor(e = z) {
4680
4764
  h(this, "streamDescriptionByCompactId", /* @__PURE__ */ new Map()), h(this, "compactIdByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_debug", void 0), this._debug = e;
4681
4765
  }
@@ -4791,7 +4875,7 @@ var di = class {
4791
4875
  this._debug.error("unexpected null sequenceNumber", e, r);
4792
4876
  continue;
4793
4877
  }
4794
- let l = oi.PARTICIPANT_AGNOSTIC_TRACK_PREFIX + "-" + e, u = i ? i >>> 0 : null;
4878
+ let l = ui.PARTICIPANT_AGNOSTIC_TRACK_PREFIX + "-" + e, u = i ? i >>> 0 : null;
4795
4879
  n.push({
4796
4880
  participantStreamDescription: c,
4797
4881
  streamId: l,
@@ -4807,9 +4891,9 @@ var di = class {
4807
4891
  participantUpdateInfos: n
4808
4892
  };
4809
4893
  }
4810
- }, fi = /* @__PURE__ */ function(e) {
4894
+ }, gi = /* @__PURE__ */ function(e) {
4811
4895
  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 {
4896
+ }({}), _i = class {
4813
4897
  constructor(e = z, t = null) {
4814
4898
  h(this, "_worker", null), h(this, "_debug", void 0), h(this, "_logger", void 0), this._debug = e, this._logger = t;
4815
4899
  }
@@ -4825,7 +4909,7 @@ var di = class {
4825
4909
  return;
4826
4910
  }
4827
4911
  t({
4828
- type: fi.FRAME,
4912
+ type: gi.FRAME,
4829
4913
  error: e
4830
4914
  });
4831
4915
  };
@@ -4835,23 +4919,23 @@ var di = class {
4835
4919
  e.preventDefault?.(), m(this._formatWorkerMessageError(e));
4836
4920
  }, f.onmessage = (e) => {
4837
4921
  switch (e.data.type) {
4838
- case fi.READY:
4922
+ case gi.READY:
4839
4923
  s = !0, c || (c = !0, a());
4840
4924
  break;
4841
- case fi.ERROR:
4925
+ case gi.ERROR:
4842
4926
  s ? m(e.data.error) : p(e.data.error);
4843
4927
  break;
4844
- case fi.FRAME:
4928
+ case gi.FRAME:
4845
4929
  t(e.data);
4846
4930
  break;
4847
- case fi.DEBUG:
4931
+ case gi.DEBUG:
4848
4932
  this._debug.debug(e.data.message);
4849
4933
  break;
4850
- case fi.LOG_ERROR:
4934
+ case gi.LOG_ERROR:
4851
4935
  this._logger?.log(C.ERROR, e.data.message);
4852
4936
  break;
4853
4937
  }
4854
- }, this._sendToWorker(fi.INIT, r, i);
4938
+ }, this._sendToWorker(gi.INIT, r, i);
4855
4939
  });
4856
4940
  }
4857
4941
  _removeWorker() {
@@ -4874,7 +4958,7 @@ var di = class {
4874
4958
  static isBrowserSupported() {
4875
4959
  throw Error("Not implemented");
4876
4960
  }
4877
- }, mi = class extends pi {
4961
+ }, vi = class extends _i {
4878
4962
  constructor(e = z, t = null) {
4879
4963
  super(e, t);
4880
4964
  }
@@ -4884,7 +4968,7 @@ var di = class {
4884
4968
  }, [c, c.getUrl]);
4885
4969
  }
4886
4970
  decodeFrame(e, t, n, r) {
4887
- this._sendToWorker(fi.FRAME, {
4971
+ this._sendToWorker(gi.FRAME, {
4888
4972
  timestamp: e,
4889
4973
  data: t.buffer,
4890
4974
  isVP9: n,
@@ -4898,7 +4982,7 @@ var di = class {
4898
4982
  static isBrowserSupported() {
4899
4983
  return "WebAssembly" in window && "Worker" in window;
4900
4984
  }
4901
- }, hi = class extends pi {
4985
+ }, yi = class extends _i {
4902
4986
  constructor(e = z, t = null) {
4903
4987
  super(e, t);
4904
4988
  }
@@ -4908,7 +4992,7 @@ var di = class {
4908
4992
  }, [!0]);
4909
4993
  }
4910
4994
  decodeFrame(e, t, n, r = !1) {
4911
- this._sendToWorker(fi.FRAME, {
4995
+ this._sendToWorker(gi.FRAME, {
4912
4996
  timestamp: e,
4913
4997
  data: t.buffer,
4914
4998
  isVP9: n,
@@ -4921,7 +5005,7 @@ var di = class {
4921
5005
  static isBrowserSupported() {
4922
5006
  return "VideoDecoder" in window && "Worker" in window && "VideoFrame" in window && !E.isBrokenVP9Decoder() && E.browserName() !== "Firefox";
4923
5007
  }
4924
- }, gi = class {
5008
+ }, bi = class {
4925
5009
  constructor(e = null, t = 0) {
4926
5010
  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
5011
  }
@@ -4935,7 +5019,7 @@ var di = class {
4935
5019
  destroy() {
4936
5020
  window.clearInterval(this._interval), this._interval = 0;
4937
5021
  }
4938
- }, _i = class {
5022
+ }, xi = class {
4939
5023
  constructor(e, t) {
4940
5024
  h(this, "_participantId", void 0), h(this, "_statAggregator", void 0), h(this, "_firstFrameReceived", !1), this._participantId = e, this._statAggregator = t;
4941
5025
  }
@@ -4950,14 +5034,14 @@ var di = class {
4950
5034
  height: t
4951
5035
  });
4952
5036
  }
4953
- }, vi = 65536, yi = "MARK_SCREENSHARE_FREEZE_DURATION", bi = class e {
5037
+ }, Si = 65536, Ci = "MARK_SCREENSHARE_FREEZE_DURATION", wi = class e {
4954
5038
  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;
5039
+ 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
5040
  }
4957
5041
  appendChunk(t) {
4958
5042
  let n = this._chunks.length;
4959
5043
  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) {
5044
+ else if (!n || (this._chunks[n - 1].sequence + 1) % Si !== t.sequence) {
4961
5045
  this._debug.warn("[FrameBuilder] Got incorrect chunk");
4962
5046
  return;
4963
5047
  }
@@ -4974,7 +5058,7 @@ var di = class {
4974
5058
  }
4975
5059
  }
4976
5060
  destroy() {
4977
- G.clearMark(yi), G.clearMark(G.getMarkNameScreenshareFirstFrame(this._participantId)), this._chunks = [];
5061
+ G.clearMark(Ci), G.clearMark(G.getMarkNameScreenshareFirstFrame(this._participantId)), this._chunks = [];
4978
5062
  }
4979
5063
  _processFrameData() {
4980
5064
  let e = this._chunks;
@@ -4997,13 +5081,13 @@ var di = class {
4997
5081
  }
4998
5082
  _measureFreezeDuration(e) {
4999
5083
  if (e) {
5000
- G.setMark(yi);
5084
+ G.setMark(Ci);
5001
5085
  return;
5002
5086
  }
5003
- let t = G.measureMark(yi);
5087
+ let t = G.measureMark(Ci);
5004
5088
  t !== null && t > 1e3 && this._onStat({ freeze_duration: t });
5005
5089
  }
5006
- }, xi = class {
5090
+ }, Ti = class {
5007
5091
  constructor(e) {
5008
5092
  h(this, "_onStream", void 0), this._onStream = e;
5009
5093
  }
@@ -5016,7 +5100,7 @@ var di = class {
5016
5100
  static isBrowserSupported() {
5017
5101
  throw Error("Method `isBrowserSupported` is not implemented");
5018
5102
  }
5019
- }, Si = class extends xi {
5103
+ }, Ei = class extends Ti {
5020
5104
  constructor(e, t = z) {
5021
5105
  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
5106
  }
@@ -5076,7 +5160,7 @@ var di = class {
5076
5160
  static isBrowserSupported() {
5077
5161
  return ("CanvasCaptureMediaStream" in window || "CanvasCaptureMediaStreamTrack" in window) && !(E.browserName() === "Safari" && Number(E.browserVersion()) === 15);
5078
5162
  }
5079
- }, Ci = class extends xi {
5163
+ }, Di = class extends Ti {
5080
5164
  constructor(e, t = z) {
5081
5165
  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
5166
  }
@@ -5087,9 +5171,9 @@ var di = class {
5087
5171
  this._writer.releaseLock(), this._generator.writable.close().then(() => this._generator.stop()), this._debug.debug("TrackGeneratorRenderer destroyed");
5088
5172
  }
5089
5173
  static isBrowserSupported() {
5090
- return "VideoFrame" in window && "MediaStreamTrackGenerator" in window && hi.isBrowserSupported();
5174
+ return "VideoFrame" in window && "MediaStreamTrackGenerator" in window && yi.isBrowserSupported();
5091
5175
  }
5092
- }, wi = class extends bi {
5176
+ }, Oi = class extends wi {
5093
5177
  constructor(e, t, n, r, i, a = z, o = null) {
5094
5178
  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
5179
  }
@@ -5097,16 +5181,16 @@ var di = class {
5097
5181
  e.keyframe && (this._decoderQueue = []), this._decoderQueue.push(e), this._decodeQueue();
5098
5182
  }
5099
5183
  _initFpsMeter() {
5100
- this._fpsMeter = new gi((e) => this._debug.log(`[StreamBuilder][${this._participantId}] fps: ${e}`), 2e4);
5184
+ this._fpsMeter = new bi((e) => this._debug.log(`[StreamBuilder][${this._participantId}] fps: ${e}`), 2e4);
5101
5185
  }
5102
5186
  _initRenderer(e = !1) {
5103
- e || !Ci.isBrowserSupported() ? this._renderer = new Si(this._onStream, this._debug) : this._renderer = new Ci(this._onStream, this._debug);
5187
+ e || !Di.isBrowserSupported() ? this._renderer = new Ei(this._onStream, this._debug) : this._renderer = new Di(this._onStream, this._debug);
5104
5188
  }
5105
5189
  _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) => {
5190
+ 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
5191
  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
5192
  }, (e) => {
5109
- if (this._decoderBusy = !1, this._decoder instanceof hi && typeof e == "string" && e.includes("EncodingError")) {
5193
+ if (this._decoderBusy = !1, this._decoder instanceof yi && typeof e == "string" && e.includes("EncodingError")) {
5110
5194
  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
5195
  return;
5112
5196
  }
@@ -5114,7 +5198,7 @@ var di = class {
5114
5198
  }, this._onKeyFrameRequested).then(() => {
5115
5199
  this._decoderReady = !0, this._decodeQueue();
5116
5200
  }).catch((e) => {
5117
- this._debug.warn("StreamBuilder decoder init failed", e), this._decoder instanceof hi && this._switchToLibVPXDecoder();
5201
+ this._debug.warn("StreamBuilder decoder init failed", e), this._decoder instanceof yi && this._switchToLibVPXDecoder();
5118
5202
  });
5119
5203
  }
5120
5204
  _switchToLibVPXDecoder() {
@@ -5129,20 +5213,20 @@ var di = class {
5129
5213
  super.destroy(), this._fpsMeter.destroy(), this._decoder.destroy(), this._renderer.destroy(), this._debug.debug(`StreamBuilder destroyed for participant ${this._participantId}`);
5130
5214
  }
5131
5215
  static isBrowserSupported() {
5132
- return Si.isBrowserSupported() || Ci.isBrowserSupported();
5216
+ return Ei.isBrowserSupported() || Di.isBrowserSupported();
5133
5217
  }
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) {
5218
+ }, ki = 1, Ai = 1, ji = 2, Mi = 0, Ni = 1, Pi = 2, Fi = 4, Ii = 8;
5219
+ function Li(e, t, n, r, i, a, o) {
5136
5220
  let s = 0;
5137
- t && (s |= ki), n && (s |= Ai), r && (s |= ji), o || (s |= Mi);
5221
+ t && (s |= Ni), n && (s |= Pi), r && (s |= Fi), o || (s |= Ii);
5138
5222
  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;
5223
+ 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
5224
  let u = new Uint8Array(c.byteLength + o.byteLength);
5141
5225
  return u.set(new Uint8Array(c), 0), u.set(new Uint8Array(o), c.byteLength), u.buffer;
5142
5226
  }
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}`);
5227
+ function Ri(e) {
5228
+ 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);
5229
+ if (n !== ki) throw Error(`Unexpected protocol version. Got ${n}, expected ${ki}`);
5146
5230
  return {
5147
5231
  timestamp: i,
5148
5232
  start: c,
@@ -5155,26 +5239,26 @@ function Pi(e) {
5155
5239
  data: e.slice(11)
5156
5240
  };
5157
5241
  }
5158
- function Fi(e) {
5242
+ function zi(e) {
5159
5243
  if (!e || !e.byteLength || e.byteLength !== 4) return !1;
5160
5244
  let t = new DataView(e);
5161
- return !(t.getUint8(0) !== Ti || t.getUint8(1) !== Ei || t.getUint16(2) !== Oi);
5245
+ return !(t.getUint8(0) !== ki || t.getUint8(1) !== Ai || t.getUint16(2) !== Mi);
5162
5246
  }
5163
- function Ii(e) {
5247
+ function Bi(e) {
5164
5248
  if (!e || !e.byteLength || e.byteLength !== 10) return null;
5165
5249
  let t = new DataView(e);
5166
- return t.getUint8(0) !== Ti || t.getUint8(1) !== Di || t.getUint16(2) !== Oi ? null : {
5250
+ return t.getUint8(0) !== ki || t.getUint8(1) !== ji || t.getUint16(2) !== Mi ? null : {
5167
5251
  seq: t.getUint16(4),
5168
5252
  ts2: t.getUint32(6)
5169
5253
  };
5170
5254
  }
5171
- function Li(e) {
5255
+ function Vi(e) {
5172
5256
  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;
5257
+ return n.setUint8(0, ki), n.setUint8(1, Ai), n.setUint16(2, e), t;
5174
5258
  }
5175
5259
  //#endregion
5176
5260
  //#region src/classes/screenshare/WebmBuilder.ts
5177
- var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5261
+ var Hi = 2 ** 15 - 1, Ui = 1, Wi = 5, Gi = 5, Ki = class e {
5178
5262
  constructor(e, t = z) {
5179
5263
  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
5264
  let n = () => {
@@ -5217,8 +5301,8 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5217
5301
  this._mediaSource?.readyState === "open" && this._sourceBuffer?.abort();
5218
5302
  let e = this._sourceBuffer?.buffered, t = e?.length;
5219
5303
  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);
5304
+ let n = e.start(0), r = Math.max(0, e.end(t - 1) - Wi);
5305
+ r - n > Gi && (this._clearBufferTill = r);
5222
5306
  }
5223
5307
  destroy() {
5224
5308
  this._queue = [], this._mediaSource.readyState === "open" && (this._sourceBuffer?.abort(), this._mediaSource.endOfStream()), this._sourceBuffer = null, this._clearBufferTill = 0;
@@ -5232,7 +5316,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5232
5316
  get buffered() {
5233
5317
  return this._sourceBuffer?.buffered;
5234
5318
  }
5235
- }, Ui = class e extends bi {
5319
+ }, qi = class e extends wi {
5236
5320
  constructor(e, t, n, r, i = z) {
5237
5321
  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
5322
  }
@@ -5256,8 +5340,8 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5256
5340
  u.element(u.ID.MuxingApp, u.string("vk-webm-builder")),
5257
5341
  u.element(u.ID.WritingApp, u.string("vk-webm-builder"))
5258
5342
  ]), 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)),
5343
+ u.element(u.ID.TrackNumber, u.number(Ui)),
5344
+ u.element(u.ID.TrackUID, u.number(Ui)),
5261
5345
  u.element(u.ID.TrackType, u.number(1)),
5262
5346
  u.element(u.ID.FlagLacing, u.number(0)),
5263
5347
  u.element(u.ID.DefaultDuration, u.number(1e9)),
@@ -5270,7 +5354,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5270
5354
  return u.unknownSizeElement(u.ID.Cluster, [u.element(u.ID.Timecode, u.number(Math.round(e)))]);
5271
5355
  }
5272
5356
  _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);
5357
+ 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
5358
  let t = () => {
5275
5359
  if (this._video?.src) {
5276
5360
  this._debug.warn(`[WebmBuilder] Video paused for participant [${this._participantId}], try to play again`);
@@ -5297,13 +5381,13 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5297
5381
  this._mediaBuffer?.append(a);
5298
5382
  }
5299
5383
  let i = Math.round(r - this._clusterStartTime);
5300
- if (i > Ri && (this._clusterStartTime = r, i = 0), i === 0) {
5384
+ if (i > Hi && (this._clusterStartTime = r, i = 0), i === 0) {
5301
5385
  this._debug.debug(`[WebmBuilder] Cluster header for participant [${this._participantId}]`);
5302
5386
  let t = e._genClusterHeader(this._clusterStartTime);
5303
5387
  this._mediaBuffer?.append(t);
5304
5388
  }
5305
5389
  let a = u.element(u.ID.SimpleBlock, [
5306
- u.vintEncodedNumber(zi),
5390
+ u.vintEncodedNumber(Ui),
5307
5391
  u.bytes(e._intToU16BE(i)),
5308
5392
  u.number(!!t.keyframe << 7),
5309
5393
  u.bytes(t.frameData)
@@ -5316,12 +5400,12 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5316
5400
  static isBrowserSupported() {
5317
5401
  return "captureStream" in window.HTMLVideoElement?.prototype && window.MediaSource?.isTypeSupported("video/webm; codecs=\"vp8\"") && window.MediaSource?.isTypeSupported("video/webm; codecs=\"vp9\"");
5318
5402
  }
5319
- }, Wi = class {
5403
+ }, Ji = class {
5320
5404
  constructor(e, t, n, r, i, a = null, o = z, s = null) {
5321
5405
  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
5406
  }
5323
5407
  _onDataChannelMessage(e) {
5324
- let t = Pi(e), n = this._participantIdRegistry?.getStreamDescription(t.ssrc)?.participantId;
5408
+ let t = Ri(e), n = this._participantIdRegistry?.getStreamDescription(t.ssrc)?.participantId;
5325
5409
  if (!n) {
5326
5410
  this._debug.warn(`Participant id for ssrc ${t.ssrc} not found in registry`);
5327
5411
  return;
@@ -5333,7 +5417,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5333
5417
  let r = this._streamBuilders[n];
5334
5418
  if (!r) {
5335
5419
  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, () => {
5420
+ r = N.screenShareWebmBuilder && qi.isBrowserSupported() ? new qi(n, e, this._onStat, this._statAggregator, this._debug) : new Oi(n, e, this._onStat, this._statAggregator, () => {
5337
5421
  this._requestKeyFrame(t.ssrc);
5338
5422
  }, this._debug, this._logger), this._streamBuilders[n] = r;
5339
5423
  }
@@ -5341,7 +5425,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5341
5425
  }
5342
5426
  _requestKeyFrame(e) {
5343
5427
  if (!(!this._datachannel || this._datachannel.readyState !== "open")) try {
5344
- let t = Li(e);
5428
+ let t = Vi(e);
5345
5429
  this._datachannel.send(t), this._debug.debug(`ScreenCaptureReceiver request for keyframe for ssrc ${e}`);
5346
5430
  } catch (e) {
5347
5431
  this._debug.warn("Failed to send keyframe request", e);
@@ -5354,7 +5438,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5354
5438
  destroy() {
5355
5439
  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
5440
  }
5357
- }, Gi = class {
5441
+ }, Yi = class {
5358
5442
  constructor(e, t, n) {
5359
5443
  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
5444
  }
@@ -5373,7 +5457,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5373
5457
  get data() {
5374
5458
  return this._data;
5375
5459
  }
5376
- }, Ki = class {
5460
+ }, Xi = class {
5377
5461
  constructor() {
5378
5462
  h(this, "_head", null), h(this, "_tail", null), h(this, "_length", 0);
5379
5463
  }
@@ -5381,7 +5465,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5381
5465
  return this._length;
5382
5466
  }
5383
5467
  push(...e) {
5384
- for (let t of e) this._tail = new Gi(t, this._tail, null), this._head || (this._head = this._tail), this._length++;
5468
+ for (let t of e) this._tail = new Yi(t, this._tail, null), this._head || (this._head = this._tail), this._length++;
5385
5469
  }
5386
5470
  merge(e) {
5387
5471
  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 +5495,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5411
5495
  for (; t !== null;) e.push(t.data), t = t.next;
5412
5496
  return e.length ? JSON.stringify(e, (e, t) => t instanceof Error ? String(t) : t) : "";
5413
5497
  }
5414
- }, qi = 1e3, Ji = class extends pi {
5498
+ }, Zi = 1e3, Qi = class extends _i {
5415
5499
  constructor(e, t, n, r, i = z, a = null) {
5416
5500
  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
5501
  }
@@ -5480,7 +5564,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5480
5564
  }
5481
5565
  _encode(e, t) {
5482
5566
  let n = e.data.buffer;
5483
- this._sendToWorker(fi.FRAME, {
5567
+ this._sendToWorker(gi.FRAME, {
5484
5568
  width: e.width,
5485
5569
  height: e.height,
5486
5570
  imageData: n,
@@ -5497,7 +5581,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5497
5581
  let t = this._drawFrameData(this._lastFrame);
5498
5582
  this._encode(t, e);
5499
5583
  } else this._onFrame(null);
5500
- }, qi), this._getFrameBitmap().then((t) => {
5584
+ }, Zi), this._getFrameBitmap().then((t) => {
5501
5585
  window.clearTimeout(this._frameReadTimeout), this._lastFrame?.close(), this._lastFrame = t;
5502
5586
  let n = this._drawFrameData(t);
5503
5587
  this._encode(n, e);
@@ -5507,7 +5591,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5507
5591
  this._useImageCapture ? this._requestFrameBitmap(e) : this._requestFrameVideo(e);
5508
5592
  }
5509
5593
  setBitrate(e, t, n) {
5510
- this._sendToWorker(fi.SET_BITRATE, {
5594
+ this._sendToWorker(gi.SET_BITRATE, {
5511
5595
  bitrate: e,
5512
5596
  useCbr: t
5513
5597
  });
@@ -5518,7 +5602,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5518
5602
  destroy() {
5519
5603
  this._removeWorker(), this._removeStream(), this._removeDom(), this._debug.debug("LibVPxEncoder destroyed");
5520
5604
  }
5521
- }, Yi = class extends pi {
5605
+ }, $i = class extends _i {
5522
5606
  constructor(e, t, n, r, i, a, o = z, s = null) {
5523
5607
  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
5608
  }
@@ -5546,10 +5630,10 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5546
5630
  }, [n]);
5547
5631
  }
5548
5632
  requestFrame(e = !1) {
5549
- this._sendToWorker(fi.FRAME, { keyFrame: e });
5633
+ this._sendToWorker(gi.FRAME, { keyFrame: e });
5550
5634
  }
5551
5635
  setBitrate(e, t, n) {
5552
- this._sendToWorker(fi.SET_BITRATE, {
5636
+ this._sendToWorker(gi.SET_BITRATE, {
5553
5637
  bitrate: e,
5554
5638
  useCbr: t,
5555
5639
  fps: n
@@ -5564,11 +5648,11 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5564
5648
  static isBrowserSupported() {
5565
5649
  return "VideoEncoder" in window && "Worker" in window && "EncodedVideoChunk" in window && "MediaStreamTrackProcessor" in window;
5566
5650
  }
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) {
5651
+ }, 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
5652
  return e[e.NONE = 0] = "NONE", e[e.UP = 1] = "UP", e[e.DOWN = 2] = "DOWN", e;
5569
- }(oa || {}), sa = class {
5653
+ }(ua || {}), da = class {
5570
5654
  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;
5655
+ 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
5656
  let c = Date.now();
5573
5657
  this._lastDown = 0, this._lastUp = c, this._lastProbing = c, this._lastCheckDelay = 0, this._lastFpsCalcMs = 0;
5574
5658
  }
@@ -5578,27 +5662,27 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5578
5662
  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
5663
  s || c ? i = 2 : Math.abs(a) < 40 && o < 10 && !c && (i = 1);
5580
5664
  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}`);
5665
+ 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
5666
  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;
5667
+ if (i === 2 && d > ia) {
5668
+ this._probing && (this._upPenalty = Math.min(++this._upPenalty, ca), this._probing = !1);
5669
+ let n = ra * u * 1e3;
5670
+ if (n >= this._targetBitrate && (n = this._targetBitrate * ra), n = Math.max(n, this._minBitrate), n < this._targetBitrate) {
5671
+ let r = Math.round(n / 1e3), s = Math.round(this._upPenalty * oa / 1e3);
5672
+ 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
5673
  }
5590
5674
  this._lastDown = r;
5591
5675
  }
5592
- let f = r - this._lastUp, p = ta + this._upPenalty * na;
5676
+ let f = r - this._lastUp, p = aa + this._upPenalty * oa;
5593
5677
  if (i === 1 && f > p && d > p) {
5594
- let n = Math.min(this._targetBitrate * Qi, this._maxBitrate);
5678
+ let n = Math.min(this._targetBitrate * na, this._maxBitrate);
5595
5679
  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;
5680
+ let s = Math.round(n / 1e3), c = Math.round(this._targetBitrate / 1e3), l = Math.round(this._upPenalty * oa / 1e3);
5681
+ 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
5682
  }
5599
5683
  }
5600
5684
  let m = r - this._lastProbing;
5601
- this._probing && m > ra && (this._probing = !1);
5685
+ this._probing && m > sa && (this._probing = !1);
5602
5686
  let ee = r - this._lastDown;
5603
5687
  this._upPenalty > 0 && ee > 3 * p && (this._debug.log(`#${e}: cc: UP reset penalty: oldPenalty=${this._upPenalty}`), this._upPenalty = 0);
5604
5688
  }
@@ -5609,7 +5693,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5609
5693
  }
5610
5694
  _calcDelay(e, t) {
5611
5695
  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) {
5696
+ 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
5697
  let e = t - this._lastCheckDelay;
5614
5698
  this._largeDelayDuration += e;
5615
5699
  }
@@ -5638,7 +5722,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5638
5722
  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
5723
  }
5640
5724
  }
5641
- }, ca = class {
5725
+ }, fa = class {
5642
5726
  constructor(e) {
5643
5727
  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
5728
  }
@@ -5712,11 +5796,11 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5712
5796
  clear() {
5713
5797
  this._buffer.fill(void 0), this._size = 0, this._head = 0, this._tail = 0;
5714
5798
  }
5715
- }, la = 65536, ua = 50, da = 400, fa = 1e6, pa = 3e5, ma = 3e4, ha = 2e3, ga = 5, _a = 0, va = class {
5799
+ }, pa = 65536, ma = 50, ha = 400, ga = 1e6, _a = 3e5, va = 3e4, ya = 2e3, ba = 5, xa = 0, Sa = class {
5716
5800
  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;
5801
+ 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
5802
  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);
5803
+ 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
5804
  let u = (e, t) => {
5721
5805
  if (this._destroyed) return;
5722
5806
  if (!e) {
@@ -5727,23 +5811,23 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5727
5811
  let n = this._sliceFrame(e);
5728
5812
  this._queue.merge(n), this._handleQueue(), this._sendSharingStat();
5729
5813
  };
5730
- if (Yi.isBrowserSupported()) {
5814
+ if ($i.isBrowserSupported()) {
5731
5815
  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);
5816
+ this._encoder = new $i(e, u, this._congestionControlEnabled, c, t, o, this._debug, this._logger);
5817
+ } else this._encoder = new Qi(e, u, this._congestionControlEnabled, c, this._debug, this._logger);
5734
5818
  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);
5819
+ zi(e.data) && (this._debug.debug(`[${this._datachannel.label}] Requested keyframe`), this._needKeyframe = !0);
5820
+ let t = Bi(e.data);
5737
5821
  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);
5822
+ }, 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
5823
  }
5740
5824
  _handleQueue() {
5741
5825
  if (this._destroyed) return;
5742
5826
  let e = this._queue.shift();
5743
5827
  if (!e) {
5744
- if ((this._lastSentFrameSeq - this._lastDeliveredFrameSeq + la) % la > ga && this._lastFrameDelay > this._maxFrameDelay) {
5828
+ if ((this._lastSentFrameSeq - this._lastDeliveredFrameSeq + pa) % pa > ba && this._lastFrameDelay > this._maxFrameDelay) {
5745
5829
  let e = Date.now();
5746
- e - this._lastFramerateReduced > ha && (this._lastFramerateReduced = e, this._debug.debug(`[ScreenCaptureSender] reduce framerate: delay=${this._lastFrameDelay} maxDelay=${this._maxFrameDelay}`));
5830
+ e - this._lastFramerateReduced > ya && (this._lastFramerateReduced = e, this._debug.debug(`[ScreenCaptureSender] reduce framerate: delay=${this._lastFrameDelay} maxDelay=${this._maxFrameDelay}`));
5747
5831
  } else this._requestFrame();
5748
5832
  return;
5749
5833
  }
@@ -5769,7 +5853,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5769
5853
  this._destroyed || (this._encoder.requestFrame(this._needKeyframe), this._needKeyframe = !1);
5770
5854
  }
5771
5855
  _sliceFrame(e) {
5772
- let t = e.type === "key", n = e.data.byteLength, r = new Ki();
5856
+ let t = e.type === "key", n = e.data.byteLength, r = new Xi();
5773
5857
  for (let i = 0; i < n; i += this.DATA_SIZE) {
5774
5858
  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
5859
  r.push({
@@ -5785,11 +5869,11 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5785
5869
  return r;
5786
5870
  }
5787
5871
  _wrapHeader(e, t, n, r, i) {
5788
- let a = Ni(e, t, n, r, _a, this._encoder.isVP9(), i), o = {
5789
- sequence: _a,
5872
+ let a = Li(e, t, n, r, xa, this._encoder.isVP9(), i), o = {
5873
+ sequence: xa,
5790
5874
  data: a
5791
5875
  };
5792
- return _a = (_a + 1) % la, o;
5876
+ return xa = (xa + 1) % pa, o;
5793
5877
  }
5794
5878
  _stopPacket() {
5795
5879
  return this._wrapHeader(Date.now(), !1, !1, !1, null).data;
@@ -5806,7 +5890,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5806
5890
  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
5891
  }
5808
5892
  static isBrowserSupported() {
5809
- return Yi.isBrowserSupported() || Ji.isBrowserSupported();
5893
+ return $i.isBrowserSupported() || Qi.isBrowserSupported();
5810
5894
  }
5811
5895
  _onCongestionCallback(e, t, n) {
5812
5896
  this._encoder.setBitrate(e, t, n);
@@ -5819,8 +5903,8 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5819
5903
  (e === void 0 || e < 640) && (e = 640), (t === void 0 || t < 360) && (t = 360);
5820
5904
  let n = e * t / 256;
5821
5905
  return {
5822
- minBitrate: Math.max(pa, Math.min(fa, Math.round(n * ua))),
5823
- maxBitrate: Math.round(n * da)
5906
+ minBitrate: Math.max(_a, Math.min(ga, Math.round(n * ma))),
5907
+ maxBitrate: Math.round(n * ha)
5824
5908
  };
5825
5909
  }
5826
5910
  _checkCcFeedback(e) {
@@ -5834,14 +5918,14 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5834
5918
  }
5835
5919
  _sendSharingStat() {
5836
5920
  let e = Date.now();
5837
- if (e - this._lastSharingStat > ma) {
5921
+ if (e - this._lastSharingStat > va) {
5838
5922
  let t = this._congestionControl.getStat();
5839
5923
  t !== null && (this._debug.debug(`cc: send stats: ${JSON.stringify(t)}`), this._signaling.reportSharingStat(t).catch((e) => {
5840
5924
  !(e instanceof En) && !(e instanceof Dn) && this._debug.warn("Unable to send sharing stats", e);
5841
5925
  })), this._lastSharingStat = e;
5842
5926
  }
5843
5927
  }
5844
- }, ya = class {
5928
+ }, Ca = class {
5845
5929
  constructor(e, t, n, r = z, i = null) {
5846
5930
  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
5931
  }
@@ -5973,9 +6057,9 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
5973
6057
  if (!(e instanceof Dn)) throw e;
5974
6058
  }
5975
6059
  }
5976
- }, ba = 90, xa = 4294967295, Sa = class e extends Kr {
6060
+ }, wa = 90, Ta = 4294967295, Ea = class e extends Xr {
5977
6061
  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");
6062
+ 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
6063
  }
5980
6064
  updateStatisticsInterval() {
5981
6065
  this._stopStatInterval();
@@ -6014,10 +6098,10 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6014
6098
  await this._simulcast.sync();
6015
6099
  }
6016
6100
  _createPerfStatsReporter() {
6017
- this._perfStatReporter?.destroy(), this._perfStatReporter = new Da(this, this._signaling, this._statAggregator, !1, this._debug);
6101
+ this._perfStatReporter?.destroy(), this._perfStatReporter = new Ma(this, this._signaling, this._statAggregator, !1, this._debug);
6018
6102
  }
6019
6103
  _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);
6104
+ 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
6105
  }
6022
6106
  static _closeDataChannel(e) {
6023
6107
  e && (e.onopen = null, e.onmessage = null, e.onerror = null, e.close());
@@ -6043,14 +6127,14 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6043
6127
  }
6044
6128
  this._pc.ontrack = this._onAddTrack.bind(this, this._pc), this._pc.onconnectionstatechange = M.debounce((e) => {
6045
6129
  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) => {
6130
+ }, 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
6131
  this._producerNotification = e, this._producerNotification.binaryType = "arraybuffer", this._signaling.setProducerNotificationDataChannel(e);
6048
6132
  }), this._signaling.useCommandDataChannel(!0), this._createDataChannel(this._pc, Tr.producerCommand, (e) => {
6049
6133
  this._producerCommand = e, this._signaling.setProducerCommandDataChannel(e);
6050
6134
  }), this._createDataChannel(this._pc, Tr.producerScreenShare, (e) => {
6051
6135
  this._producerScreen = e, this._producerScreen.binaryType = "arraybuffer", this._createCaptureReceiver();
6052
6136
  }), 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) => {
6137
+ this._asr = e, this._asr.binaryType = "arraybuffer", this._removeAsrTrack(), this._asrTrack = new fi(e, this._participantIdRegistry, (e) => {
6054
6138
  this._onAsrTranscription(e);
6055
6139
  }, this._debug);
6056
6140
  }), N.vmoji && this._createDataChannel(this._pc, Tr.animoji, (e) => {
@@ -6071,8 +6155,8 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6071
6155
  _removeAsrTrack() {
6072
6156
  this._asrTrack?.destroy(), this._asrTrack = null;
6073
6157
  }
6074
- _reconnect() {
6075
- this.getState() !== q.OPENED && (this._setState(q.RECONNECTING), this._closeConnection(), this._openConnection(!0));
6158
+ _reconnect(e = !1) {
6159
+ this.getState() !== q.OPENED && (e && this._peerConnectionStats.logIceRestart(), this._setState(q.RECONNECTING), this._closeConnection(), this._openConnection(!0));
6076
6160
  }
6077
6161
  _signalActiveParticipants(e) {
6078
6162
  this._triggerEvent(Y.SIGNALLED_ACTIVE_PARTICIPANTS, e);
@@ -6088,19 +6172,19 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6088
6172
  }
6089
6173
  _updateSSRCMap(e) {
6090
6174
  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);
6175
+ 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
6176
  n && (this._ssrcMap[n[1]] = n[3]);
6093
6177
  }));
6094
6178
  }
6095
6179
  _createCaptureSender(e) {
6096
6180
  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));
6181
+ !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
6182
  }
6099
6183
  _removeCaptureSender() {
6100
6184
  this._captureSender?.destroy(), this._captureSender = null;
6101
6185
  }
6102
6186
  _createCaptureReceiver() {
6103
- this._producerScreen && (this._captureReceiver && this._removeCaptureReceiver(), this._captureReceiver = new Wi(this._producerScreen, this._participantIdRegistry, (e, t) => {
6187
+ this._producerScreen && (this._captureReceiver && this._removeCaptureReceiver(), this._captureReceiver = new Ji(this._producerScreen, this._participantIdRegistry, (e, t) => {
6104
6188
  this._triggerEvent(Y.REMOTE_STREAM_SECOND, e, t);
6105
6189
  }, (e) => {
6106
6190
  this._triggerEvent(Y.REMOTE_STREAM_SECOND, e, null);
@@ -6210,7 +6294,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6210
6294
  _detectStaleTracks(e) {
6211
6295
  let t = e.rtps.find((e) => e.type === "inbound-rtp" && e.kind === "audio" && this._ssrcMap[e.ssrc] === "mix");
6212
6296
  if (!t) return;
6213
- let n = oi.AUDIO_MIX, r = this._statBytes[n], i = !1;
6297
+ let n = ui.AUDIO_MIX, r = this._statBytes[n], i = !1;
6214
6298
  if (r) {
6215
6299
  let e = t.bytesReceived - r.bytesReceived;
6216
6300
  e >= 0 && e <= 5 && (i = !0), r.stalled !== i && this._triggerEvent(Y.AUDIO_MIX_STALL, i);
@@ -6222,7 +6306,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6222
6306
  }
6223
6307
  _allocateConsumer() {
6224
6308
  if (!this._signaling.ready) return;
6225
- let e = Na.get();
6309
+ let e = Ra.get();
6226
6310
  !N.videoTracksCount && !this._observer && this._debug.warn("Setting videoTracksCount to 0 is deprecated"), this._signaling.allocateConsumer(null, e).catch((e) => {
6227
6311
  e instanceof En || this._debug.warn("ServerTransport: Unable to allocate consumer", e);
6228
6312
  });
@@ -6355,7 +6439,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6355
6439
  _onConnectionStateChange(e, t) {
6356
6440
  switch (this._debug.debug("[single] connection state changed", { state: e.connectionState }, t), this._logger?.log(C.ICE_CONNECTION_STATE, e.connectionState), e.connectionState) {
6357
6441
  case "failed":
6358
- this._reconnectionPrevented ? this.close(/* @__PURE__ */ Error("Ice connection failed")) : this._reconnect();
6442
+ this._reconnectionPrevented ? this.close(/* @__PURE__ */ Error("Ice connection failed")) : this._reconnect(!0);
6359
6443
  break;
6360
6444
  case "connecting":
6361
6445
  let t = this.getState();
@@ -6398,11 +6482,11 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6398
6482
  if (!r || !r.length) return this._debug.log(`Cannot get stream waiting time, ${e} receiver has no synchronization sources`), 0;
6399
6483
  let i = r[0].rtpTimestamp;
6400
6484
  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);
6485
+ let a = t - i & Ta, o = Math.ceil(a / wa);
6402
6486
  return Math.min(100, Math.max(0, o));
6403
6487
  }
6404
6488
  async _monitorRtpShare() {
6405
- let e = ui.getInstance().value;
6489
+ let e = mi.getInstance().value;
6406
6490
  if (!this._mediaSource.mediaSettings.isFastScreenSharingEnabled || !N.consumerFastScreenShare || e < .6) return;
6407
6491
  let t = this._pc?.getSenders().find((e) => e.track?.kind === A.video && e.track?.contentHint === "motion");
6408
6492
  t && (await t.getStats()).forEach((e) => {
@@ -6433,7 +6517,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6433
6517
  }
6434
6518
  }, Y = /* @__PURE__ */ function(e) {
6435
6519
  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 {
6520
+ }({}), Da = class extends b {
6437
6521
  constructor(e, t, n, r, i = z, a = null, o = null, s = null, c = null) {
6438
6522
  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
6523
  this._vadController?.setSendTrack(this._mediaSource.getSendAudioTrack());
@@ -6554,11 +6638,11 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6554
6638
  }
6555
6639
  }
6556
6640
  _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());
6641
+ let n = new li(e, t, this._signaling, this._mediaSource, this._serverSettings, this._debug, this._logger, this._statAggregator, this._codecStatsAggregator, this._getFirstMediaSentCallback());
6558
6642
  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
6643
  }
6560
6644
  _createServerTransport() {
6561
- let e = new Sa(this._signaling, this._mediaSource, this._serverSettings, this._debug, this._logger, this._statAggregator, this._codecStatsAggregator, this._getFirstMediaSentCallback());
6645
+ let e = new Ea(this._signaling, this._mediaSource, this._serverSettings, this._debug, this._logger, this._statAggregator, this._codecStatsAggregator, this._getFirstMediaSentCallback());
6562
6646
  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
6647
  }
6564
6648
  _releaseDirectTransport() {
@@ -6650,20 +6734,20 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6650
6734
  getStreamWaitingTimeMs(e, t) {
6651
6735
  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
6736
  }
6653
- }, wa = "videochat-epi", Ta = 5e3, Ea = 500, Da = class extends b {
6737
+ }, Oa = "videochat-epi", ka = 5e3, Aa = 500, ja = 120 * 1e3, Ma = class extends b {
6654
6738
  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) => {
6739
+ 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
6740
  this._screenShareStats.push(e);
6657
6741
  }), h(this, "_handleTransportStateChanged", (e) => {
6658
6742
  (this._directTopology && e === q.CONNECTED || !this._directTopology && e === q.OPENED) && (this._previousNetworkStatReportTimestamp = Date.now(), this._previousCallStatReportTimestamp = Date.now(), this._previousRemoteInboundRtps.clear());
6659
6743
  }), 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
6744
  }
6661
6745
  destroy() {
6662
- this._previousRemoteInboundRtps.clear(), this.unsubscribe();
6746
+ this._previousRemoteInboundRtps.clear(), this._previousCandidatePair = null, this.unsubscribe();
6663
6747
  }
6664
6748
  static getEstimatedPerformanceIndex() {
6665
6749
  try {
6666
- let e = parseInt(localStorage.getItem(wa) || "", 10);
6750
+ let e = parseInt(localStorage.getItem(Oa) || "", 10);
6667
6751
  return isNaN(e) ? 0 : e;
6668
6752
  } catch {
6669
6753
  return 0;
@@ -6672,9 +6756,9 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6672
6756
  async _handleStats(e) {
6673
6757
  if (!e.inbound || !e.inbound.rtps) return;
6674
6758
  let t = Date.now();
6675
- !this._directTopology && N.perfStatReportEnabled && this._previousPerfStatReportTimestamp + Ta <= t && (await this.reportPerfStats(e), this._previousPerfStatReportTimestamp = t);
6759
+ !this._directTopology && N.perfStatReportEnabled && this._previousPerfStatReportTimestamp + ka <= t && (await this.reportPerfStats(e), this._previousPerfStatReportTimestamp = t);
6676
6760
  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);
6761
+ !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
6762
  }
6679
6763
  async reportPerfStats(e) {
6680
6764
  let t = e.inbound.rtps.reduce((e, t) => (t.kind === "video" && (e.framesDecoded += t.framesDecoded || 0, e.framesReceived += t.framesReceived || 0), e), {
@@ -6683,7 +6767,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6683
6767
  });
6684
6768
  if (t.framesDecoded) try {
6685
6769
  let e = await this._signaling.reportPerfStat(t);
6686
- localStorage.setItem(wa, e.estimatedPerformanceIndex);
6770
+ localStorage.setItem(Oa, e.estimatedPerformanceIndex);
6687
6771
  } catch {}
6688
6772
  }
6689
6773
  async reportNetworkStats(e) {
@@ -6723,11 +6807,11 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6723
6807
  rtt: Math.round(e.inbound.transport.currentRoundTripTime * 1e3),
6724
6808
  ss_freeze_count: 0,
6725
6809
  ss_total_freezes_duration: 0,
6726
- local_address: ka(e.inbound.transport.local),
6810
+ local_address: Pa(e.inbound.transport.local),
6727
6811
  local_connection_type: e.inbound.transport.local?.type,
6728
6812
  network_type: e.inbound.transport.local?.networkType,
6729
6813
  transport: e.inbound.transport.local?.protocol,
6730
- remote_address: ka(e.inbound.transport.remote),
6814
+ remote_address: Pa(e.inbound.transport.remote),
6731
6815
  remote_connection_type: e.inbound.transport.remote?.type
6732
6816
  };
6733
6817
  this._previousCallStatReport || (this._previousCallStatReport = Object.assign({}, t));
@@ -6738,7 +6822,7 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6738
6822
  }
6739
6823
  let i = {
6740
6824
  call_topology: t.call_topology,
6741
- stat_time_delta: Math.max(0, Date.now() - this._previousCallStatReportTimestamp),
6825
+ stat_time_delta: Math.min(ja, Math.max(0, Date.now() - this._previousCallStatReportTimestamp)),
6742
6826
  nack_sent: Math.max(0, t.nack_sent - this._previousCallStatReport.nack_sent),
6743
6827
  nack_received: Math.max(0, t.nack_received - this._previousCallStatReport.nack_received),
6744
6828
  pli_sent: Math.max(0, t.pli_sent - this._previousCallStatReport.pli_sent),
@@ -6748,14 +6832,28 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6748
6832
  frames_dropped: Math.max(0, t.frames_dropped - this._previousCallStatReport.frames_dropped),
6749
6833
  rtt: Math.max(0, t.rtt)
6750
6834
  };
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)) {
6835
+ 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
6836
  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;
6837
+ 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
6838
  }
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);
6839
+ 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
6840
  let a = this._calculatePacketLoss(e.remoteInbound.rtps);
6757
6841
  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
6842
  }
6843
+ _reportCandidatePair(e, t) {
6844
+ if (!e?.address || !t?.address) return;
6845
+ let n = JSON.stringify({
6846
+ local: e,
6847
+ remote: t
6848
+ });
6849
+ n !== this._previousCandidatePair && (this._previousCandidatePair = n, this._statAggregator?.logEventualStat({
6850
+ name: U.ICE_CANDIDATES_CHANGED,
6851
+ string_value: n,
6852
+ local_address: Pa(e),
6853
+ remote_address: Pa(t),
6854
+ transport: e.protocol
6855
+ }));
6856
+ }
6759
6857
  _calculatePacketLoss(e) {
6760
6858
  let t = /* @__PURE__ */ new Map(), n = {
6761
6859
  audio: {
@@ -6784,26 +6882,26 @@ var Ri = 2 ** 15 - 1, zi = 1, Bi = 5, Vi = 5, Hi = class e {
6784
6882
  return r;
6785
6883
  }
6786
6884
  };
6787
- function Oa(e, ...t) {
6885
+ function Na(e, ...t) {
6788
6886
  for (let n of t) if (!Object.hasOwn(e, n) || e[n] === void 0) return !1;
6789
6887
  return !0;
6790
6888
  }
6791
- function ka(e, t = !1) {
6889
+ function Pa(e, t = !1) {
6792
6890
  if (e?.address) return e.address + (t ? `:${e.port}` : "");
6793
6891
  }
6794
- function Aa(e) {
6892
+ function Fa(e) {
6795
6893
  return e === void 0;
6796
6894
  }
6797
- function ja(e) {
6895
+ function Ia(e) {
6798
6896
  return Number.isNaN(e) ? 0 : e;
6799
6897
  }
6800
6898
  //#endregion
6801
6899
  //#region src/static/Capabilities.ts
6802
- var Ma;
6900
+ var La;
6803
6901
  (function(e) {
6804
6902
  function t() {
6805
6903
  return {
6806
- estimatedPerformanceIndex: Da.getEstimatedPerformanceIndex(),
6904
+ estimatedPerformanceIndex: Ma.getEstimatedPerformanceIndex(),
6807
6905
  audioMix: !0,
6808
6906
  consumerUpdate: !0,
6809
6907
  producerNotificationDataChannelVersion: 8,
@@ -6829,8 +6927,8 @@ var Ma;
6829
6927
  };
6830
6928
  }
6831
6929
  e.get = t;
6832
- })(Ma || (Ma = {}));
6833
- var Na = Ma, Pa = {
6930
+ })(La || (La = {}));
6931
+ var Ra = La, za = {
6834
6932
  producerScreenTrack: () => !0,
6835
6933
  videoTracksCount: () => N.videoTracksCount > 0,
6836
6934
  waitingHall: () => !0,
@@ -6850,28 +6948,28 @@ var Na = Ma, Pa = {
6850
6948
  p2pRelay: () => !1,
6851
6949
  waitForAdmin: () => N.waitForAdminInGroupCalls,
6852
6950
  hold: () => N.hold
6853
- }, Fa = class {
6951
+ }, Ba = class {
6854
6952
  static getFlags() {
6855
- let e = Object.values(Pa), t = 0;
6953
+ let e = Object.values(za), t = 0;
6856
6954
  for (let n = 0; n < e.length; n++) e[n]() && (t |= 1 << n);
6857
6955
  return t.toString(16).toUpperCase();
6858
6956
  }
6859
6957
  static parseCapabilities(e) {
6860
6958
  let t = parseInt(e || "0", 16);
6861
- return Object.keys(Pa).reduce((e, n, r) => (e[n] = !!(t & 1 << r), e), {});
6959
+ return Object.keys(za).reduce((e, n, r) => (e[n] = !!(t & 1 << r), e), {});
6862
6960
  }
6863
- }, Ia = 63n, La = 16383n, Ra = 1073741823, za = 4611686018427387903n, Ba = class {
6961
+ }, Va = 63n, Ha = 16383n, Ua = 1073741823, Wa = 4611686018427387903n, Ga = class {
6864
6962
  encode(e) {
6865
6963
  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([
6964
+ if (t <= Va) return new Uint8Array([Number(t)]);
6965
+ if (t <= Ha) return new Uint8Array([64 | Number(t >> 8n), Number(t & 255n)]);
6966
+ if (t <= BigInt(Ua)) return new Uint8Array([
6869
6967
  128 | Number(t >> 24n),
6870
6968
  Number(t >> 16n & 255n),
6871
6969
  Number(t >> 8n & 255n),
6872
6970
  Number(t & 255n)
6873
6971
  ]);
6874
- if (t <= za) return new Uint8Array([
6972
+ if (t <= Wa) return new Uint8Array([
6875
6973
  192 | Number(t >> 56n),
6876
6974
  Number(t >> 48n & 255n),
6877
6975
  Number(t >> 40n & 255n),
@@ -6883,7 +6981,7 @@ var Na = Ma, Pa = {
6883
6981
  ]);
6884
6982
  throw RangeError("Number is too large to encode using varint");
6885
6983
  }
6886
- }, Va = class {
6984
+ }, Ka = class {
6887
6985
  decode(e) {
6888
6986
  let t = this.getNumBytesForLengthInteger(e);
6889
6987
  if (t < 0) throw Error("Invalid length prefix");
@@ -6909,9 +7007,9 @@ var Na = Ma, Pa = {
6909
7007
  let t = e[0] & 192;
6910
7008
  return t === 0 ? 1 : t === 64 ? 2 : t === 128 ? 4 : t === 192 ? 8 : -1;
6911
7009
  }
6912
- }, Ha = class {
7010
+ }, qa = class {
6913
7011
  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;
7012
+ 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
7013
  }
6916
7014
  encode(e) {
6917
7015
  let t = this.encoder.encode(e);
@@ -6928,9 +7026,9 @@ var Na = Ma, Pa = {
6928
7026
  default: return e;
6929
7027
  }
6930
7028
  }
6931
- }, Ua = class {
7029
+ }, Ja = class {
6932
7030
  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;
7031
+ 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
7032
  }
6935
7033
  decode(e) {
6936
7034
  let t = [];
@@ -6960,12 +7058,12 @@ var Na = Ma, Pa = {
6960
7058
  default: return e;
6961
7059
  }
6962
7060
  }
6963
- }, Wa = class {
7061
+ }, Ya = class {
6964
7062
  static isBrowserSupported() {
6965
7063
  return !(!("WebTransport" in window && typeof WebTransport == "function") || E.browserName() === "Safari");
6966
7064
  }
6967
7065
  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();
7066
+ 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
7067
  }
6970
7068
  async send(e) {
6971
7069
  if (this.readyState !== WebSocket.OPEN) {
@@ -7091,11 +7189,11 @@ var Na = Ma, Pa = {
7091
7189
  compression: this.compression
7092
7190
  }, n;
7093
7191
  }
7094
- }, Ga = /* @__PURE__ */ function(e) {
7095
- return e.EMPTY_ENDPOINT = "EMPTY_ENDPOINT", e.NETWORK_ERROR = "NETWORK_ERROR", e.ABORTED = "ABORTED", e;
7096
- }({}), Ka = class {
7192
+ }, Xa = /* @__PURE__ */ function(e) {
7193
+ return e.EMPTY_ENDPOINT = "EMPTY_ENDPOINT", e.NETWORK_ERROR = "NETWORK_ERROR", e.RECONNECT_TIMEOUT = "RECONNECT_TIMEOUT", e.ABORTED = "ABORTED", e;
7194
+ }({}), Za = class {
7097
7195
  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;
7196
+ 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
7197
  }
7100
7198
  get readyState() {
7101
7199
  return this.socket?.readyState ?? null;
@@ -7118,14 +7216,14 @@ var Na = Ma, Pa = {
7118
7216
  setAbortSignal(e) {
7119
7217
  this.abortSignal = e;
7120
7218
  }
7121
- resetReconnectCount() {
7122
- this.reconnectCount = 0;
7219
+ onConnectionRestored() {
7220
+ this.reconnectCount = 0, this._stopReconnectDeadline();
7123
7221
  }
7124
7222
  connect(e) {
7125
7223
  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
7224
  }
7127
7225
  close(e) {
7128
- this.manualClose = !0, this._disconnect(e), window.clearTimeout(this.reconnectTimer), this.reconnectTimer = 0, this.lastStamp = 0;
7226
+ this.manualClose = !0, this._disconnect(e), window.clearTimeout(this.reconnectTimer), this.reconnectTimer = 0, this._stopReconnectDeadline(), this.lastStamp = 0;
7129
7227
  }
7130
7228
  async send(e) {
7131
7229
  await this.socket?.send(e);
@@ -7143,7 +7241,7 @@ var Na = Ma, Pa = {
7143
7241
  return;
7144
7242
  }
7145
7243
  let e = this._buildUrl(this.wtEndpoint, !0);
7146
- this.currentType = Sr.WEBTRANSPORT, this.socket = new Wa(e, { congestionControl: "low-latency" }, this._debug), this._setSocketHandlers();
7244
+ this.currentType = Sr.WEBTRANSPORT, this.socket = new Ya(e, { congestionControl: "low-latency" }, this._debug), this._setSocketHandlers();
7147
7245
  }
7148
7246
  _connectWebSocket() {
7149
7247
  if (!this.endpoint) {
@@ -7166,10 +7264,10 @@ var Na = Ma, Pa = {
7166
7264
  }
7167
7265
  _buildUrl(e, t) {
7168
7266
  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();
7267
+ 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
7268
  }
7171
7269
  _canUseWebTransport() {
7172
- return !this.forceWebSocket && Wa.isBrowserSupported() && this.wtEndpoint !== null && N.webtransport;
7270
+ return !this.forceWebSocket && Ya.isBrowserSupported() && this.wtEndpoint !== null && N.webtransport;
7173
7271
  }
7174
7272
  _onOpen() {
7175
7273
  this._startDoctor(), this.handlers.onOpen();
@@ -7198,20 +7296,32 @@ var Na = Ma, Pa = {
7198
7296
  }
7199
7297
  _scheduleReconnect(e = this._getReconnectDelay()) {
7200
7298
  if (this.reconnectCount >= N.signalingReconnectMaxCount) {
7201
- this.handlers.onFailed({
7299
+ this._stopReconnectDeadline(), this.handlers.onFailed({
7202
7300
  failure: "NETWORK_ERROR",
7203
7301
  message: "Unable to connect to the signaling: reconnect attempts exhausted",
7204
7302
  source: this.currentType
7205
7303
  });
7206
7304
  return;
7207
7305
  }
7208
- this.reconnectCount++, this.handlers.onReconnectScheduled({
7306
+ this._startReconnectDeadline(), this.reconnectCount++, this.handlers.onReconnectScheduled({
7209
7307
  count: this.reconnectCount,
7210
7308
  delay: e
7211
7309
  }), this.reconnectTimer = window.setTimeout(() => {
7212
7310
  this.connectionType = br.RETRY, this._connect();
7213
7311
  }, e);
7214
7312
  }
7313
+ _startReconnectDeadline() {
7314
+ this.reconnectDeadlineTimer || (this.reconnectDeadlineTimer = window.setTimeout(() => {
7315
+ this.reconnectDeadlineTimer = 0, window.clearTimeout(this.reconnectTimer), this.reconnectTimer = 0, this._disconnect(4e3), this.handlers.onFailed({
7316
+ failure: "RECONNECT_TIMEOUT",
7317
+ message: "Unable to connect to the signaling: reconnect timeout",
7318
+ source: this.currentType
7319
+ });
7320
+ }, N.signalingReconnectMaxDuration));
7321
+ }
7322
+ _stopReconnectDeadline() {
7323
+ window.clearTimeout(this.reconnectDeadlineTimer), this.reconnectDeadlineTimer = 0;
7324
+ }
7215
7325
  _getReconnectDelay() {
7216
7326
  return Math.min(N.signalingReconnectMaxDelay, N.signalingReconnectDelay * 2 ** this.reconnectCount);
7217
7327
  }
@@ -7223,31 +7333,31 @@ var Na = Ma, Pa = {
7223
7333
  _stopDoctor() {
7224
7334
  window.clearTimeout(this.doctorTimer), this.doctorTimer = 0;
7225
7335
  }
7226
- }, qa = "open", Ja = 300, Ya = 10, Xa = {
7336
+ }, Qa = "open", $a = 300, eo = 10, to = {
7227
7337
  CONVERSATION_ENDED: "conversation-ended",
7228
7338
  OBSOLETE_CLIENT: "gen.obsoleteClient",
7229
7339
  INVALID_TOKEN: "invalid-token",
7230
7340
  PARTICIPANT_NOT_FOUND: "participant-not-found",
7231
7341
  ILLEGAL_PARTICIPANT_STATE: "illegal-participant-state",
7232
7342
  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"
7343
+ }, no = {
7344
+ [to.CONVERSATION_ENDED]: "conversation-ended",
7345
+ [to.OBSOLETE_CLIENT]: "obsolete-client",
7346
+ [to.INVALID_TOKEN]: "invalid-token",
7347
+ [to.PARTICIPANT_NOT_FOUND]: "participant-not-found",
7348
+ [to.ILLEGAL_PARTICIPANT_STATE]: "illegal-participant-state",
7349
+ [to.SERVICE_UNAVAILABLE]: "service-unavailable"
7240
7350
  };
7241
- function Qa(e, t) {
7351
+ function ro(e, t) {
7242
7352
  return e.errorMessage ?? e.message ?? e.error ?? t;
7243
7353
  }
7244
- var $a = new Set([
7354
+ var io = new Set([
7245
7355
  O.CALLER_IS_BLOCKED,
7246
7356
  O.ENDED,
7247
7357
  O.NOT_FOUND,
7248
7358
  O.PARTICIPANT_LIMIT_REACHED,
7249
7359
  O.SERVICE_UNAVAILABLE
7250
- ]), eo = class e extends On {
7360
+ ]), ao = class e extends On {
7251
7361
  static get WAIT_CONNECTION_DELAY() {
7252
7362
  return N.waitConnectionDelay;
7253
7363
  }
@@ -7258,7 +7368,7 @@ var $a = new Set([
7258
7368
  return !this.disposed && this.transport.readyState !== null;
7259
7369
  }
7260
7370
  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, {
7371
+ 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
7372
  onConnecting: this._onTransportConnecting.bind(this),
7263
7373
  onOpen: this._onOpen.bind(this),
7264
7374
  onMessage: this._onMessage.bind(this),
@@ -7345,20 +7455,20 @@ var $a = new Set([
7345
7455
  return this._send(V.TRANSMIT_DATA, {
7346
7456
  participantId: e,
7347
7457
  data: r
7348
- }, !0, Ya);
7458
+ }, !0, eo);
7349
7459
  }
7350
7460
  async acceptCall(e) {
7351
7461
  return this._send(V.ACCEPT_CALL, { mediaSettings: e });
7352
7462
  }
7353
7463
  async changeMediaSettings(e) {
7354
- return this._send(V.CHANGE_MEDIA_SETTINGS, { mediaSettings: e }, !0, Ya);
7464
+ return this._send(V.CHANGE_MEDIA_SETTINGS, { mediaSettings: e }, !0, eo);
7355
7465
  }
7356
7466
  async changeParticipantState(e, t) {
7357
7467
  let n = { participantState: { state: e } };
7358
7468
  return t && (n.participantId = t), this._sendRaw(V.CHANGE_PARTICIPANT_STATE, n);
7359
7469
  }
7360
7470
  async hold(e) {
7361
- let t = Na.get();
7471
+ let t = Ra.get();
7362
7472
  return this._send(V.HOLD, {
7363
7473
  hold: e,
7364
7474
  capabilities: e ? void 0 : t
@@ -7590,7 +7700,7 @@ var $a = new Set([
7590
7700
  if (this.disposed) throw new En(e);
7591
7701
  switch (t.route) {
7592
7702
  case "producer":
7593
- this.datachannelCommandsQueue.push(t), this.producerCommandDataChannel?.readyState === qa && this._handleCommandsQueue(this.datachannelCommandsQueue);
7703
+ this.datachannelCommandsQueue.push(t), this.producerCommandDataChannel?.readyState === Qa && this._handleCommandsQueue(this.datachannelCommandsQueue);
7594
7704
  break;
7595
7705
  case "websocket":
7596
7706
  if (this.transport.readyState === null) {
@@ -7640,7 +7750,7 @@ var $a = new Set([
7640
7750
  _handleMessage(e) {
7641
7751
  switch (e.type) {
7642
7752
  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, {
7753
+ 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
7754
  type: "notification",
7645
7755
  notification: K.TOPOLOGY_CHANGED,
7646
7756
  topology: e.conversation.topology
@@ -7660,9 +7770,9 @@ var $a = new Set([
7660
7770
  }
7661
7771
  _handleErrorMessage(e) {
7662
7772
  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");
7773
+ let t = this._getSocketType(), n = e.error ? this._createSignalingCallError(e.error, e.errorCode, t) : void 0, r = ro(e, "Unknown signaling error");
7664
7774
  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:
7775
+ case to.SERVICE_UNAVAILABLE:
7666
7776
  let i = new k(O.SERVICE_UNAVAILABLE, {
7667
7777
  callError: n,
7668
7778
  message: r,
@@ -7674,7 +7784,7 @@ var $a = new Set([
7674
7784
  reason: O.SERVICE_UNAVAILABLE
7675
7785
  });
7676
7786
  break;
7677
- case Xa.CONVERSATION_ENDED:
7787
+ case to.CONVERSATION_ENDED:
7678
7788
  this.conversationReject ? this.conversationReject(new k(e.reason || x.SIGNALING_FAILED, {
7679
7789
  callError: n,
7680
7790
  message: r,
@@ -7685,35 +7795,22 @@ var $a = new Set([
7685
7795
  reason: e.reason
7686
7796
  });
7687
7797
  break;
7688
- case Xa.ILLEGAL_PARTICIPANT_STATE:
7689
- case Xa.PARTICIPANT_NOT_FOUND:
7798
+ case to.ILLEGAL_PARTICIPANT_STATE:
7799
+ case to.PARTICIPANT_NOT_FOUND:
7690
7800
  this._throwError(new k(x.SIGNALING_FAILED, {
7691
7801
  callError: n,
7692
7802
  message: r,
7693
7803
  remote: !0
7694
7804
  }));
7695
7805
  break;
7696
- case Xa.OBSOLETE_CLIENT:
7806
+ case to.OBSOLETE_CLIENT:
7697
7807
  this.conversationReject?.(new k(e.reason || O.OBSOLETE_CLIENT, {
7698
7808
  callError: n,
7699
7809
  message: r,
7700
7810
  remote: !0
7701
7811
  }));
7702
7812
  break;
7703
- case Xa.INVALID_TOKEN: {
7704
- if (e.sequence || t === Sr.WEBTRANSPORT) break;
7705
- R.onTokenExpired(), this._stopWaitConnectionMessage(), this.transport.close();
7706
- let i = new k(e.reason || x.SIGNALING_FAILED, {
7707
- callError: n ?? {
7708
- scope: "unknown",
7709
- description: "signaling-unrecognized-error"
7710
- },
7711
- message: r,
7712
- remote: !0
7713
- });
7714
- this.connected ? this._throwError(i) : this.conversationReject?.(i);
7715
- break;
7716
- }
7813
+ case to.INVALID_TOKEN:
7717
7814
  default:
7718
7815
  if (e.sequence || t === Sr.WEBTRANSPORT) break;
7719
7816
  if (this.connected) this._throwError(new k(e.reason || x.SIGNALING_FAILED, {
@@ -7752,7 +7849,7 @@ var $a = new Set([
7752
7849
  }
7753
7850
  _describeErrorEvent(e) {
7754
7851
  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;
7755
- return (i ? `${i}: ${r}` : r).slice(0, Ja);
7852
+ return (i ? `${i}: ${r}` : r).slice(0, $a);
7756
7853
  }
7757
7854
  _onClose(e) {
7758
7855
  this._logger?.log(C.SOCKET_ACTION, "closed"), this._debug.debug("[signaling] connection closed", {
@@ -7807,13 +7904,13 @@ var $a = new Set([
7807
7904
  let r = this.responseHandlers[n.sequence];
7808
7905
  window.clearTimeout(r.responseTimer);
7809
7906
  let i = G.measureMark(r.statMarkName);
7810
- 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);
7907
+ 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);
7811
7908
  }
7812
7909
  _handleCommandsQueue(e) {
7813
7910
  for (; e.length > 0;) {
7814
7911
  let t = e.shift();
7815
7912
  if (this._debug.debug(`[signaling] command send [${t.sequence}]`, `'${t.name}'`, t.params), t.route === "producer") {
7816
- if (this.producerCommandDataChannel?.readyState !== qa) {
7913
+ if (this.producerCommandDataChannel?.readyState !== Qa) {
7817
7914
  t.reject(/* @__PURE__ */ Error(`Invalid data channel state: ${this.producerCommandDataChannel?.readyState}`));
7818
7915
  return;
7819
7916
  }
@@ -7898,7 +7995,7 @@ var $a = new Set([
7898
7995
  }
7899
7996
  _onTransportFailed(e) {
7900
7997
  switch (e.failure) {
7901
- case Ga.EMPTY_ENDPOINT:
7998
+ case Xa.EMPTY_ENDPOINT:
7902
7999
  this.conversationReject?.(new k(x.SIGNALING_FAILED, {
7903
8000
  callError: {
7904
8001
  scope: "internal",
@@ -7909,7 +8006,7 @@ var $a = new Set([
7909
8006
  remote: e.remote
7910
8007
  }));
7911
8008
  break;
7912
- case Ga.NETWORK_ERROR:
8009
+ case Xa.NETWORK_ERROR:
7913
8010
  this._logReconnectTimeout(), this._fail(new k(O.NETWORK_ERROR, { callError: {
7914
8011
  scope: "network",
7915
8012
  source: e.source,
@@ -7917,7 +8014,15 @@ var $a = new Set([
7917
8014
  description: "connection-failed"
7918
8015
  } }));
7919
8016
  break;
7920
- case Ga.ABORTED:
8017
+ case Xa.RECONNECT_TIMEOUT:
8018
+ this._logReconnectTimeout(), this._fail(new k(O.NETWORK_ERROR, { callError: {
8019
+ scope: "network",
8020
+ source: e.source,
8021
+ code: "reconnect-timeout",
8022
+ description: "connection-failed"
8023
+ } }));
8024
+ break;
8025
+ case Xa.ABORTED:
7921
8026
  this._debug.debug("[signaling] aborted reconnect"), this._fail(new k(O.CANCELED));
7922
8027
  break;
7923
8028
  }
@@ -7932,19 +8037,19 @@ var $a = new Set([
7932
8037
  this._debug.warn("[signaling] socket is dead, trying to reconnect"), this._logTransportStatSinceMark(Cr.FAILED_PINGS);
7933
8038
  }
7934
8039
  _attachNotificationCallError(e) {
7935
- e.callError || !e.reason || e.reason === O.FAILED || e.reason === O.UNKNOWN_ERROR || !$a.has(e.reason) && !e.errorCode || (e.callError = {
8040
+ e.callError || !e.reason || e.reason === O.FAILED || e.reason === O.UNKNOWN_ERROR || !io.has(e.reason) && !e.errorCode || (e.callError = {
7936
8041
  scope: "server",
7937
8042
  source: this._getSocketType(),
7938
- code: e.errorCode || String(e.reason),
8043
+ code: e.errorCode || "protocol",
7939
8044
  description: String(e.reason)
7940
8045
  });
7941
8046
  }
7942
8047
  _createSignalingCallError(e, t, n) {
7943
- let r = Za[e];
8048
+ let r = no[e];
7944
8049
  if (r) return {
7945
8050
  scope: "server",
7946
8051
  source: n,
7947
- code: t ?? r,
8052
+ code: t ?? "protocol",
7948
8053
  description: r
7949
8054
  };
7950
8055
  }
@@ -7966,39 +8071,39 @@ var $a = new Set([
7966
8071
  let t = this._getSocketType(), n = wr[e][t];
7967
8072
  this._statAggregator?.logEventualStatSinceMark({ name: n });
7968
8073
  }
7969
- }, to = /* @__PURE__ */ function(e) {
8074
+ }, oo = /* @__PURE__ */ function(e) {
7970
8075
  return e.INCOMING = "INCOMING", e.OUTGOING = "OUTGOING", e.JOINING = "JOINING", e;
7971
- }(to || {}), no = /* @__PURE__ */ function(e) {
8076
+ }(oo || {}), so = /* @__PURE__ */ function(e) {
7972
8077
  return e.USER = "USER", e.GROUP = "GROUP", e.CHAT = "CHAT", e;
7973
- }(no || {}), ro = /* @__PURE__ */ function(e) {
8078
+ }(so || {}), co = /* @__PURE__ */ function(e) {
7974
8079
  return e.ATTENDEE = "ATTENDEE", e.HAND_UP = "HAND_UP", e;
7975
- }(ro || {}), io = /* @__PURE__ */ function(e) {
8080
+ }(co || {}), lo = /* @__PURE__ */ function(e) {
7976
8081
  return e.ADD_PARTICIPANT = "ADD_PARTICIPANT", e.RECORD = "RECORD", e.MOVIE_SHARE = "MOVIE_SHARE", e;
7977
- }(io || {}), ao = /* @__PURE__ */ function(e) {
8082
+ }(lo || {}), uo = /* @__PURE__ */ function(e) {
7978
8083
  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;
7979
- }(ao || {});
7980
- function oo(e, t) {
8084
+ }(uo || {});
8085
+ function fo(e, t) {
7981
8086
  if (e.length !== t.length) return !1;
7982
8087
  for (let n of e) if (!t.includes(n)) return !1;
7983
8088
  return !0;
7984
8089
  }
7985
- function so(e, t) {
8090
+ function po(e, t) {
7986
8091
  let n = new Set(e);
7987
8092
  for (let [e, r] of Object.entries(t)) r ? n.add(e) : n.delete(e);
7988
8093
  return Array.from(n);
7989
8094
  }
7990
8095
  //#endregion
7991
8096
  //#region src/enums/MuteState.ts
7992
- var co = /* @__PURE__ */ function(e) {
8097
+ var mo = /* @__PURE__ */ function(e) {
7993
8098
  return e.UNMUTE = "UNMUTE", e.MUTE = "MUTE", e.MUTE_PERMANENT = "MUTE_PERMANENT", e;
7994
- }(co || {}), X = /* @__PURE__ */ function(e) {
8099
+ }(mo || {}), X = /* @__PURE__ */ function(e) {
7995
8100
  return e.CALLED = "CALLED", e.ACCEPTED = "ACCEPTED", e.REJECTED = "REJECTED", e.HUNGUP = "HUNGUP", e;
7996
- }(X || {}), lo = /* @__PURE__ */ function(e) {
8101
+ }(X || {}), ho = /* @__PURE__ */ function(e) {
7997
8102
  return e.UPDATE = "UPDATE", e.REMOVE = "REMOVE", e.ACTIVATE = "ACTIVATE", e.TIMEOUT = "TIMEOUT", e;
7998
- }(lo || {}), uo = /* @__PURE__ */ function(e) {
8103
+ }(ho || {}), go = /* @__PURE__ */ function(e) {
7999
8104
  return e.NO_AVAILABLE_TRACKS = "no-available-tracks", e.UNKNOWN_ERROR = "unknown-error", e;
8000
- }(uo || {});
8001
- function fo(e) {
8105
+ }(go || {});
8106
+ function _o(e) {
8002
8107
  switch (e) {
8003
8108
  case 1: return "no-available-tracks";
8004
8109
  default: return "unknown-error";
@@ -8006,17 +8111,17 @@ function fo(e) {
8006
8111
  }
8007
8112
  //#endregion
8008
8113
  //#region src/enums/UserRole.ts
8009
- var po = /* @__PURE__ */ function(e) {
8114
+ var vo = /* @__PURE__ */ function(e) {
8010
8115
  return e.CREATOR = "CREATOR", e.ADMIN = "ADMIN", e;
8011
- }(po || {});
8012
- function mo(e, t) {
8116
+ }(vo || {});
8117
+ function yo(e, t) {
8013
8118
  if (e.length !== t.length) return !1;
8014
8119
  for (let n of e) if (!t.includes(n)) return !1;
8015
8120
  return !0;
8016
8121
  }
8017
8122
  //#endregion
8018
8123
  //#region src/static/ParticipantConnectionStatusUtils.ts
8019
- var ho;
8124
+ var bo;
8020
8125
  (function(e) {
8021
8126
  function t(e) {
8022
8127
  let t = e?.transport ?? e?.lastEffective ?? P.WAITING, n = {
@@ -8068,8 +8173,8 @@ var ho;
8068
8173
  shouldNotify: !0
8069
8174
  });
8070
8175
  }
8071
- })(ho || (ho = {}));
8072
- var go = ho, _o = /* @__PURE__ */ function(e) {
8176
+ })(bo || (bo = {}));
8177
+ var xo = bo, So = /* @__PURE__ */ function(e) {
8073
8178
  return e.USER = "USER", e.ANONYM = "ANONYM", e.GROUP = "GROUP", e;
8074
8179
  }({}), Z;
8075
8180
  (function(e) {
@@ -8132,7 +8237,7 @@ var go = ho, _o = /* @__PURE__ */ function(e) {
8132
8237
  })(Z || (Z = {}));
8133
8238
  //#endregion
8134
8239
  //#region src/types/WaitingHall.ts
8135
- function vo(e) {
8240
+ function Co(e) {
8136
8241
  try {
8137
8242
  return btoa(JSON.stringify(e));
8138
8243
  } catch (t) {
@@ -8140,7 +8245,7 @@ function vo(e) {
8140
8245
  }
8141
8246
  return null;
8142
8247
  }
8143
- function yo(e) {
8248
+ function wo(e) {
8144
8249
  try {
8145
8250
  return JSON.parse(atob(e));
8146
8251
  } catch (t) {
@@ -8150,12 +8255,12 @@ function yo(e) {
8150
8255
  }
8151
8256
  //#endregion
8152
8257
  //#region src/utils/Conversation.ts
8153
- var bo = (e, t) => M.objectReduce(e, (e, n, r) => (n === t && e.push(r), e), []);
8154
- function xo(e) {
8258
+ var To = (e, t) => M.objectReduce(e, (e, n, r) => (n === t && e.push(r), e), []);
8259
+ function Eo(e) {
8155
8260
  if (e.conversation?.muteStates) return e.conversation.muteStates;
8156
8261
  if (e.muteState && e.muteOptions) return e.muteOptions.reduce((t, n) => (t[n] = e.muteState, t), {});
8157
8262
  }
8158
- function So(e, t) {
8263
+ function Do(e, t) {
8159
8264
  switch (e) {
8160
8265
  case S.AUDIO: return !!t.isAudioEnabled;
8161
8266
  case S.AUDIO_SHARING: return !!t.isAudioSharingEnabled;
@@ -8164,12 +8269,12 @@ function So(e, t) {
8164
8269
  default: return !1;
8165
8270
  }
8166
8271
  }
8167
- function Co(e, t) {
8272
+ function Oo(e, t) {
8168
8273
  return M.objectReduce(e, (e, n, r) => {
8169
8274
  switch (n) {
8170
- case co.MUTE:
8171
- case co.MUTE_PERMANENT:
8172
- So(r, t) || (e[r] = n);
8275
+ case mo.MUTE:
8276
+ case mo.MUTE_PERMANENT:
8277
+ Do(r, t) || (e[r] = n);
8173
8278
  break;
8174
8279
  default:
8175
8280
  e[r] = n;
@@ -8178,19 +8283,19 @@ function Co(e, t) {
8178
8283
  return e;
8179
8284
  }, {});
8180
8285
  }
8181
- function wo(e) {
8286
+ function ko(e) {
8182
8287
  let { muteStates: t = {}, mediaSettings: n } = e;
8183
- return Co(t, n);
8288
+ return Oo(t, n);
8184
8289
  }
8185
- function To(e, t) {
8290
+ function Ao(e, t) {
8186
8291
  let n = e.conversation.participants.find((t) => M.comparePeerId(t.peerId, e.peerId));
8187
8292
  if (!n) return t;
8188
8293
  let { mediaSettings: r } = n;
8189
- return Co(t, r);
8294
+ return Oo(t, r);
8190
8295
  }
8191
8296
  //#endregion
8192
8297
  //#region src/utils/IceServers.ts
8193
- function Eo(e) {
8298
+ function jo(e) {
8194
8299
  if (!e) return null;
8195
8300
  let t = Array.from(new Set((e.urls ?? []).map((e) => e.trim()).filter((e) => e.length > 0)));
8196
8301
  return t.length ? {
@@ -8198,8 +8303,8 @@ function Eo(e) {
8198
8303
  urls: t
8199
8304
  } : null;
8200
8305
  }
8201
- function Do(e, t) {
8202
- let n = [], r = Eo(e), i = Eo(t);
8306
+ function Mo(e, t) {
8307
+ let n = [], r = jo(e), i = jo(t);
8203
8308
  if (r && n.push(r), i) {
8204
8309
  let e = [...i.urls];
8205
8310
  e.push(`${e[e.length - 1]}?transport=tcp`), n.push({
@@ -8211,7 +8316,7 @@ function Do(e, t) {
8211
8316
  }
8212
8317
  //#endregion
8213
8318
  //#region src/utils/Lz4.ts
8214
- function Oo(e, t) {
8319
+ function No(e, t) {
8215
8320
  let n = new Uint8Array(t), r = 0, i = 0;
8216
8321
  for (; r < e.length && i < t;) {
8217
8322
  let a = e[r++], o = a >> 4, s = a & 15;
@@ -8238,7 +8343,7 @@ function Oo(e, t) {
8238
8343
  }
8239
8344
  //#endregion
8240
8345
  //#region src/utils/SerializeLatest.ts
8241
- function ko(e) {
8346
+ function Po(e) {
8242
8347
  let t, n = !1, r, i = async () => {
8243
8348
  let t = !1, i;
8244
8349
  for (; n;) {
@@ -8259,7 +8364,7 @@ function ko(e) {
8259
8364
  }
8260
8365
  //#endregion
8261
8366
  //#region src/classes/AudioFix.ts
8262
- var Ao = class {
8367
+ var Fo = class {
8263
8368
  constructor(e, t = z, n = null) {
8264
8369
  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;
8265
8370
  }
@@ -8297,7 +8402,7 @@ var Ao = class {
8297
8402
  this._debug.warn("[AudioFix] Failed to fix RV (no packets): video restart", e);
8298
8403
  }));
8299
8404
  }
8300
- }, jo = class {
8405
+ }, Io = class {
8301
8406
  constructor(e, t = !1, n = z, r = null) {
8302
8407
  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();
8303
8408
  }
@@ -8400,13 +8505,13 @@ var Ao = class {
8400
8505
  };
8401
8506
  //#endregion
8402
8507
  //#region src/classes/conversation/ConversationResponseValidator.ts
8403
- function Mo(e, t) {
8404
- 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");
8508
+ function Lo(e, t) {
8509
+ 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");
8405
8510
  }
8406
- function No(e) {
8511
+ function Ro(e) {
8407
8512
  return Array.isArray(e?.urls) && e.urls.length > 0;
8408
8513
  }
8409
- function Po(e, t) {
8514
+ function zo(e, t) {
8410
8515
  let n = e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), r = e === "fastStart" || e === "fastJoin";
8411
8516
  throw new k(r ? e === "fastStart" ? O.FAST_START_ERROR : O.FAST_JOIN_ERROR : O.UNKNOWN_ERROR, {
8412
8517
  message: `Invalid ${e} response: ${t}`,
@@ -8425,7 +8530,7 @@ function Po(e, t) {
8425
8530
  }
8426
8531
  //#endregion
8427
8532
  //#region src/classes/DebugInfo.ts
8428
- var Fo = 90, Io = 3, Lo = class extends b {
8533
+ var Bo = 90, Vo = 3, Ho = class extends b {
8429
8534
  constructor(e = z) {
8430
8535
  super(), h(this, "_lastMemoryStat", {
8431
8536
  percent: 0,
@@ -8441,9 +8546,9 @@ var Fo = 90, Io = 3, Lo = class extends b {
8441
8546
  let e = window?.performance?.memory;
8442
8547
  if (!e || !e.usedJSHeapSize || !e.jsHeapSizeLimit) return;
8443
8548
  let t = Number((100 * e.usedJSHeapSize / e.jsHeapSizeLimit).toFixed(2)), n = Number((e.usedJSHeapSize / 1024 / 1024).toFixed(1));
8444
- 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);
8549
+ 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);
8445
8550
  }
8446
- }, Ro = class {
8551
+ }, Uo = class {
8447
8552
  constructor({ api: e, debug: t, getParticipants: n, isMe: r, updateDisplayLayout: i, onNonFatalError: a }) {
8448
8553
  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;
8449
8554
  }
@@ -8558,7 +8663,7 @@ var Fo = 90, Io = 3, Lo = class extends b {
8558
8663
  let n = e, r = t;
8559
8664
  return n.width !== r.width || n.height !== r.height || n.fit !== r.fit || n.priority !== r.priority;
8560
8665
  }
8561
- }, zo = 44100, Bo = class {
8666
+ }, Wo = 44100, Go = class {
8562
8667
  constructor(e, t) {
8563
8668
  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]);
8564
8669
  try {
@@ -8575,7 +8680,7 @@ var Fo = 90, Io = 3, Lo = class extends b {
8575
8680
  _getBins() {
8576
8681
  if (!this._fftBins || !this._analyser) return new Uint8Array();
8577
8682
  this._analyser.getByteFrequencyData(this._fftBins);
8578
- let e = zo / this._fftBins.length, t = Math.ceil(N.voiceParams.minFreq / e), n = Math.floor(N.voiceParams.maxFreq / e);
8683
+ let e = Wo / this._fftBins.length, t = Math.ceil(N.voiceParams.minFreq / e), n = Math.floor(N.voiceParams.maxFreq / e);
8579
8684
  return this._fftBins.subarray(t, n);
8580
8685
  }
8581
8686
  getLevel() {
@@ -8588,7 +8693,7 @@ var Fo = 90, Io = 3, Lo = class extends b {
8588
8693
  destroy() {
8589
8694
  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);
8590
8695
  }
8591
- }, Vo = class extends b {
8696
+ }, Ko = class extends b {
8592
8697
  constructor(e) {
8593
8698
  super(), h(this, "_detector", null), h(this, "_interval", null);
8594
8699
  let t = () => {
@@ -8604,7 +8709,7 @@ var Fo = 90, Io = 3, Lo = class extends b {
8604
8709
  }), this.subscribe(e, qt.SOURCE_READY, n), n();
8605
8710
  }
8606
8711
  init(e) {
8607
- this._stopDetector(), this._detector = new Bo("local", e.clone());
8712
+ this._stopDetector(), this._detector = new Go("local", e.clone());
8608
8713
  }
8609
8714
  _stopDetector() {
8610
8715
  this._detector && (this._detector.track.stop(), this._detector.destroy(), this._detector = null);
@@ -8612,7 +8717,7 @@ var Fo = 90, Io = 3, Lo = class extends b {
8612
8717
  destroy() {
8613
8718
  this.unsubscribe(), this._interval && (window.clearTimeout(this._interval), this._interval = null), this._stopDetector();
8614
8719
  }
8615
- }, Ho = class {
8720
+ }, qo = class {
8616
8721
  constructor(e, t = z) {
8617
8722
  h(this, "processor", void 0), h(this, "queue", []), h(this, "isProcessing", !1), h(this, "_debug", void 0), this.processor = e, this._debug = t;
8618
8723
  }
@@ -8632,9 +8737,9 @@ var Fo = 90, Io = 3, Lo = class extends b {
8632
8737
  this.isProcessing = !1;
8633
8738
  }
8634
8739
  }
8635
- }, Uo = /* @__PURE__ */ function(e) {
8740
+ }, Jo = /* @__PURE__ */ function(e) {
8636
8741
  return e.VOLUMES_DETECTED = "VOLUMES_DETECTED", e;
8637
- }({}), Wo = class extends b {
8742
+ }({}), Yo = class extends b {
8638
8743
  constructor(e) {
8639
8744
  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));
8640
8745
  }
@@ -8642,7 +8747,7 @@ var Fo = 90, Io = 3, Lo = class extends b {
8642
8747
  this._interval && (window.clearTimeout(this._interval), this._interval = null), this.unsubscribe(), this._destroyDetectors();
8643
8748
  }
8644
8749
  _onRemoteTrackAdded(e, t, n) {
8645
- if (n.kind === A.audio && (this._detectors.get(e)?.destroy(), this._detectors.set(e, new Bo(e, n)), !this._interval)) {
8750
+ if (n.kind === A.audio && (this._detectors.get(e)?.destroy(), this._detectors.set(e, new Go(e, n)), !this._interval)) {
8646
8751
  let e = () => {
8647
8752
  this._collectVolumes(), this._interval = window.setTimeout(e, N.voiceParams.interval);
8648
8753
  };
@@ -8673,14 +8778,14 @@ var Fo = 90, Io = 3, Lo = class extends b {
8673
8778
  this._triggerEvent("VOLUMES_DETECTED", e);
8674
8779
  }
8675
8780
  _getAudioTrackLevelByParticipantId(e) {
8676
- let t = this._detectors.get(oi.AUDIO_MIX);
8781
+ let t = this._detectors.get(ui.AUDIO_MIX);
8677
8782
  return t ? t.getLevel() : this._getTransparentAudioLevelByParticipantId(e);
8678
8783
  }
8679
8784
  _getTransparentAudioLevelByParticipantId(e) {
8680
8785
  if (!this._activeParticipants?.includes(e)) return null;
8681
8786
  let t = null;
8682
8787
  return this._detectors.forEach((e, n) => {
8683
- if (!n.startsWith(`${oi.TRANSPARENT_AUDIO_TRACK_PREFIX}-`)) return;
8788
+ if (!n.startsWith(`${ui.TRANSPARENT_AUDIO_TRACK_PREFIX}-`)) return;
8684
8789
  let r = e.getLevel();
8685
8790
  (!t || r.real > t.real) && (t = r);
8686
8791
  }), t;
@@ -8696,11 +8801,11 @@ var Fo = 90, Io = 3, Lo = class extends b {
8696
8801
  e.destroy();
8697
8802
  }), this._detectors.clear();
8698
8803
  }
8699
- }, Go = /* @__PURE__ */ function(e) {
8804
+ }, Xo = /* @__PURE__ */ function(e) {
8700
8805
  return e.SPEAKER_CHANGED = "SPEAKER_CHANGED", e;
8701
- }({}), Ko = class extends b {
8806
+ }({}), Zo = class extends b {
8702
8807
  constructor(e, t, n) {
8703
- 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));
8808
+ 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));
8704
8809
  }
8705
8810
  destroy() {
8706
8811
  this.unsubscribe();
@@ -8722,9 +8827,9 @@ var Fo = 90, Io = 3, Lo = class extends b {
8722
8827
  _onTopologyChanged(e) {
8723
8828
  this._serverSideSpeakerDetection = e === J.SERVER;
8724
8829
  }
8725
- }, qo = 15e3, Jo = 15e3, Yo = class extends b {
8830
+ }, Qo = 15e3, $o = 15e3, es = class extends b {
8726
8831
  constructor(e, t, n, r = z, i = null) {
8727
- 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));
8832
+ 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));
8728
8833
  }
8729
8834
  destroy() {
8730
8835
  this.unsubscribe(), this._connectionTimeout && window.clearTimeout(this._connectionTimeout), this._volumeTimeout && window.clearTimeout(this._volumeTimeout);
@@ -8736,10 +8841,10 @@ var Fo = 90, Io = 3, Lo = class extends b {
8736
8841
  this._connectionTimeout || !this._connectionTimeoutSuppressed || this._reportConnectionTimeout();
8737
8842
  }
8738
8843
  _getConnectionTimeout() {
8739
- return this._transport.getTopology() === J.DIRECT ? qo : N.specListenerParams.connectionTimeout;
8844
+ return this._transport.getTopology() === J.DIRECT ? Qo : N.specListenerParams.connectionTimeout;
8740
8845
  }
8741
8846
  _getVolumeTimeout() {
8742
- return this._transport.getTopology() === J.DIRECT ? Jo : N.specListenerParams.volumeTimeout;
8847
+ return this._transport.getTopology() === J.DIRECT ? $o : N.specListenerParams.volumeTimeout;
8743
8848
  }
8744
8849
  _onTransportStateChanged(e, t) {
8745
8850
  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`));
@@ -8772,15 +8877,15 @@ var Fo = 90, Io = 3, Lo = class extends b {
8772
8877
  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}`));
8773
8878
  }), e.length && this._debug.warn("There is silent participant, send callSpecError"), this._volumeTimeout = 0;
8774
8879
  }
8775
- }, Xo = /* @__PURE__ */ function(e) {
8880
+ }, ts = /* @__PURE__ */ function(e) {
8776
8881
  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;
8777
- }(Xo || {});
8778
- function Zo(e) {
8882
+ }(ts || {});
8883
+ function ns(e) {
8779
8884
  return e === 102 || e === 103 || e === 104;
8780
8885
  }
8781
8886
  //#endregion
8782
8887
  //#region src/classes/stat/StatQueue.ts
8783
- 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 {
8888
+ 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 {
8784
8889
  static isSupported() {
8785
8890
  return e._supported;
8786
8891
  }
@@ -8793,7 +8898,7 @@ var Qo, $o = "ok-calls-sdk-stats", es = 1, ts = "events", ns = 100, rs = 5e3, is
8793
8898
  n.onsuccess = () => e(n.result);
8794
8899
  });
8795
8900
  }).catch((e) => (z.error("[StatQueue] failed to append event", e), null));
8796
- return r === null ? null : (e._appendsSinceEvictCheck += 1, e._appendsSinceEvictCheck >= ns && (e._appendsSinceEvictCheck = 0, await e.evictToLimit(rs)), r);
8901
+ return r === null ? null : (e._appendsSinceEvictCheck += 1, e._appendsSinceEvictCheck >= ss && (e._appendsSinceEvictCheck = 0, await e.evictToLimit(cs)), r);
8797
8902
  }
8798
8903
  static async fillDelta(t, n) {
8799
8904
  if (t.length === 0) return;
@@ -8894,7 +8999,7 @@ var Qo, $o = "ok-calls-sdk-stats", es = 1, ts = "events", ns = 100, rs = 5e3, is
8894
8999
  });
8895
9000
  }
8896
9001
  static async __resetForTests() {
8897
- 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) {
9002
+ 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) {
8898
9003
  let t = await e._open();
8899
9004
  t && await e._runTransaction(t, "readwrite", (e) => {
8900
9005
  e.clear();
@@ -8902,7 +9007,6 @@ var Qo, $o = "ok-calls-sdk-stats", es = 1, ts = "events", ns = 100, rs = 5e3, is
8902
9007
  z.error("[StatQueue] failed to reset storage", e);
8903
9008
  });
8904
9009
  }
8905
- e._close();
8906
9010
  }
8907
9011
  static _checkSupport() {
8908
9012
  return typeof window < "u" && !!window.indexedDB;
@@ -8910,18 +9014,18 @@ var Qo, $o = "ok-calls-sdk-stats", es = 1, ts = "events", ns = 100, rs = 5e3, is
8910
9014
  static _open() {
8911
9015
  if (!e._checkSupport()) return e._supported = !1, Promise.resolve(null);
8912
9016
  if (e._dbPromise) return e._dbPromise;
8913
- if (e._lastOpenFailureAt !== null && Date.now() - e._lastOpenFailureAt < os) return Promise.resolve(null);
9017
+ if (e._lastOpenFailureAt !== null && Date.now() - e._lastOpenFailureAt < ds) return Promise.resolve(null);
8914
9018
  let t = !1, n = new Promise((n) => {
8915
9019
  let r = (r, i) => {
8916
9020
  t || (t = !0, z.error(r, i), e._supported = !1, e._dbPromise = null, e._lastOpenFailureAt = Date.now(), n(null));
8917
9021
  }, i;
8918
9022
  try {
8919
- i = window.indexedDB.open(e._dbName, es);
9023
+ i = window.indexedDB.open(e._dbName, as);
8920
9024
  } catch (e) {
8921
9025
  r("[StatQueue] storage is not accessible", e);
8922
9026
  return;
8923
9027
  }
8924
- let a = window.setTimeout(() => r("[StatQueue] storage opening timed out"), as);
9028
+ let a = window.setTimeout(() => r("[StatQueue] storage opening timed out"), us);
8925
9029
  i.onupgradeneeded = () => {
8926
9030
  e._createSchema(i.result);
8927
9031
  }, i.onsuccess = () => {
@@ -8942,8 +9046,8 @@ var Qo, $o = "ok-calls-sdk-stats", es = 1, ts = "events", ns = 100, rs = 5e3, is
8942
9046
  e._db && (e._db.close(), e._db = null), e._dbPromise = null;
8943
9047
  }
8944
9048
  static _createSchema(e) {
8945
- if (e.objectStoreNames.contains(ts)) return;
8946
- let t = e.createObjectStore(ts, {
9049
+ if (e.objectStoreNames.contains(os)) return;
9050
+ let t = e.createObjectStore(os, {
8947
9051
  keyPath: "id",
8948
9052
  autoIncrement: !0
8949
9053
  });
@@ -8951,8 +9055,8 @@ var Qo, $o = "ok-calls-sdk-stats", es = 1, ts = "events", ns = 100, rs = 5e3, is
8951
9055
  }
8952
9056
  static _runTransaction(e, t, n) {
8953
9057
  return new Promise((r, i) => {
8954
- let a = e.transaction(ts, t), o;
8955
- a.oncomplete = () => r(o), a.onerror = () => i(a.error), a.onabort = () => i(a.error), Promise.resolve(n(a.objectStore(ts))).then((e) => {
9058
+ let a = e.transaction(os, t), o;
9059
+ a.oncomplete = () => r(o), a.onerror = () => i(a.error), a.onabort = () => i(a.error), Promise.resolve(n(a.objectStore(os))).then((e) => {
8956
9060
  o = e;
8957
9061
  }).catch((e) => {
8958
9062
  try {
@@ -8977,18 +9081,18 @@ var Qo, $o = "ok-calls-sdk-stats", es = 1, ts = "events", ns = 100, rs = 5e3, is
8977
9081
  });
8978
9082
  }
8979
9083
  };
8980
- 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);
9084
+ 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);
8981
9085
  //#endregion
8982
9086
  //#region src/static/ApiTransport.ts
8983
- var ss = null, cs = null, ls = 64 * 1024;
8984
- function us() {
8985
- ss = null, cs = null;
9087
+ var fs = null, ps = null, ms = 64 * 1024;
9088
+ function hs() {
9089
+ fs = null, ps = null;
8986
9090
  }
8987
- function ds(e) {
9091
+ function gs(e) {
8988
9092
  return e?.endsWith("/") ? e.slice(0, -1) : e;
8989
9093
  }
8990
- async function fs(e = null, t) {
8991
- let n = ds(e ?? N.apiBaseUrl);
9094
+ async function _s(e = null, t) {
9095
+ let n = gs(e ?? N.apiBaseUrl);
8992
9096
  if (n) return n;
8993
9097
  if ((t ?? N.apiEnv) !== "AUTO") return N.apiEndpoint(t);
8994
9098
  try {
@@ -9003,25 +9107,25 @@ async function fs(e = null, t) {
9003
9107
  return z.warn("Failed to resolve API endpoint using DNS, default is used", e), N.apiEndpoint(t);
9004
9108
  }
9005
9109
  }
9006
- async function ps() {
9007
- return ss || cs || (cs = fs(), ss = await cs, cs = null, ss);
9110
+ async function vs() {
9111
+ return fs || ps || (ps = _s(), fs = await ps, ps = null, fs);
9008
9112
  }
9009
- async function ms(e, t = {}, n = !1) {
9113
+ async function ys(e, t = {}, n = !1) {
9010
9114
  if (!window.Blob || !window.navigator.sendBeacon) return;
9011
- await ps();
9012
- let r = bs(e, t, n), i = new window.Blob([r], { type: "application/x-www-form-urlencoded" });
9013
- window.navigator.sendBeacon(`${ss}/fb.do`, i);
9115
+ await vs();
9116
+ let r = Ts(e, t, n), i = new window.Blob([r], { type: "application/x-www-form-urlencoded" });
9117
+ window.navigator.sendBeacon(`${fs}/fb.do`, i);
9014
9118
  }
9015
- async function hs(e, t = {}, n = !1, r) {
9016
- return await ps(), _s(bs(e, t, n), r);
9119
+ async function bs(e, t = {}, n = !1, r) {
9120
+ return await vs(), Ss(Ts(e, t, n), r);
9017
9121
  }
9018
- async function gs(e, t = {}, n = !1) {
9019
- await ps();
9020
- let r = bs(e, t, n);
9021
- return _s(r, void 0, new Blob([r]).size <= ls);
9122
+ async function xs(e, t = {}, n = !1) {
9123
+ await vs();
9124
+ let r = Ts(e, t, n);
9125
+ return Ss(r, void 0, new Blob([r]).size <= ms);
9022
9126
  }
9023
- async function _s(e, t, n = !1) {
9024
- let r = `${t ?? ss}/fb.do`, i = new AbortController(), a = new k(x.NETWORK, { callError: {
9127
+ async function Ss(e, t, n = !1) {
9128
+ let r = `${t ?? fs}/fb.do`, i = new AbortController(), a = new k(x.NETWORK, { callError: {
9025
9129
  scope: "network",
9026
9130
  source: "api",
9027
9131
  code: "timeout",
@@ -9040,16 +9144,16 @@ async function _s(e, t, n = !1) {
9040
9144
  } catch {
9041
9145
  o = { result: a };
9042
9146
  }
9043
- if (!t.ok && !vs(o)) throw new k(x.API, { callError: {
9147
+ if (!t.ok && !Cs(o)) throw new k(x.API, { callError: {
9044
9148
  scope: "server",
9045
9149
  source: "api",
9046
9150
  code: `http-${t.status}`,
9047
9151
  description: "http-error"
9048
9152
  } });
9049
- if (vs(o)) throw o;
9153
+ if (Cs(o)) throw o;
9050
9154
  return o;
9051
9155
  } catch (e) {
9052
- throw e instanceof k ? e : i.signal.aborted ? a : vs(e) ? e : new k(x.NETWORK, { callError: {
9156
+ throw e instanceof k ? e : i.signal.aborted ? a : Cs(e) ? e : new k(x.NETWORK, { callError: {
9053
9157
  scope: "network",
9054
9158
  source: "api",
9055
9159
  code: "fetch-failed",
@@ -9059,12 +9163,12 @@ async function _s(e, t, n = !1) {
9059
9163
  clearTimeout(o);
9060
9164
  }
9061
9165
  }
9062
- function vs(e) {
9166
+ function Cs(e) {
9063
9167
  if (typeof e != "object" || !e) return !1;
9064
9168
  let t = e;
9065
9169
  return typeof t.error_code == "number" && typeof t.error_msg == "string";
9066
9170
  }
9067
- async function ys(e, t) {
9171
+ async function ws(e, t) {
9068
9172
  try {
9069
9173
  let n = await fetch(e, {
9070
9174
  method: "POST",
@@ -9077,7 +9181,7 @@ async function ys(e, t) {
9077
9181
  throw z.warn("Failed to send form data", e), e;
9078
9182
  }
9079
9183
  }
9080
- function bs(e, t = {}, n = !1) {
9184
+ function Ts(e, t = {}, n = !1) {
9081
9185
  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));
9082
9186
  for (let [e, n] of Object.entries(t)) typeof n == "object" && (t[e] = JSON.stringify(n));
9083
9187
  let r = "";
@@ -9086,7 +9190,7 @@ function bs(e, t = {}, n = !1) {
9086
9190
  }
9087
9191
  //#endregion
9088
9192
  //#region src/static/SessionStore.ts
9089
- var xs = "sessions", Ss = 5, Cs = class e {
9193
+ var Es = "sessions", Ds = 5, Os = class e {
9090
9194
  static remember(t, n) {
9091
9195
  let r = e._read();
9092
9196
  r[String(t)] = {
@@ -9094,7 +9198,7 @@ var xs = "sessions", Ss = 5, Cs = class e {
9094
9198
  savedAt: Date.now()
9095
9199
  };
9096
9200
  let i = Object.keys(r);
9097
- 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);
9201
+ 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);
9098
9202
  }
9099
9203
  static get(t) {
9100
9204
  return e._read()[String(t)] ?? null;
@@ -9110,10 +9214,10 @@ var xs = "sessions", Ss = 5, Cs = class e {
9110
9214
  }), r && e._write(n);
9111
9215
  }
9112
9216
  static currentEndpoint() {
9113
- return String(ds(N.apiBaseUrl) || N.apiEndpoint());
9217
+ return String(gs(N.apiBaseUrl) || N.apiEndpoint());
9114
9218
  }
9115
9219
  static _read() {
9116
- let t = w.get(xs);
9220
+ let t = w.get(Es);
9117
9221
  if (!t || typeof t != "object" || Array.isArray(t)) return {};
9118
9222
  let n = {};
9119
9223
  return Object.entries(t).forEach(([t, r]) => {
@@ -9122,16 +9226,16 @@ var xs = "sessions", Ss = 5, Cs = class e {
9122
9226
  }
9123
9227
  static _write(e) {
9124
9228
  if (Object.keys(e).length === 0) {
9125
- w.remove(xs);
9229
+ w.remove(Es);
9126
9230
  return;
9127
9231
  }
9128
- w.set(xs, e);
9232
+ w.set(Es, e);
9129
9233
  }
9130
9234
  static _isValid(e) {
9131
9235
  let t = e;
9132
9236
  return typeof t == "object" && !!t && typeof t.sessionKey == "string" && t.sessionKey.length > 0 && typeof t.endpoint == "string" && typeof t.savedAt == "number";
9133
9237
  }
9134
- }, ws = 15e3, Ts = class e {
9238
+ }, ks = 15e3, As = class e {
9135
9239
  static setApi(t) {
9136
9240
  e._api = t;
9137
9241
  }
@@ -9142,7 +9246,7 @@ var xs = "sessions", Ss = 5, Cs = class e {
9142
9246
  e._delta === null && e._api && e.get();
9143
9247
  }
9144
9248
  static get() {
9145
- 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(() => {
9249
+ 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(() => {
9146
9250
  e._pending = null;
9147
9251
  })), e._pending) : Promise.resolve(e._delta);
9148
9252
  }
@@ -9172,10 +9276,10 @@ var xs = "sessions", Ss = 5, Cs = class e {
9172
9276
  return e._idsAwaitingDelta = [], await Q.fillDelta(n, t), t;
9173
9277
  }
9174
9278
  };
9175
- h(Ts, "_api", null), h(Ts, "_delta", null), h(Ts, "_pending", null), h(Ts, "_idsAwaitingDelta", []), h(Ts, "_lastFailureAt", null);
9279
+ h(As, "_api", null), h(As, "_delta", null), h(As, "_pending", null), h(As, "_idsAwaitingDelta", []), h(As, "_lastFailureAt", null);
9176
9280
  //#endregion
9177
9281
  //#region src/classes/stat/StatUnloadJournal.ts
9178
- var Es = "okcls-stat-unload.", Ds = class e {
9282
+ var js = "okcls-stat-unload.", Ms = class e {
9179
9283
  static beginTabSession() {
9180
9284
  e._tabKey = null, e._entries = [];
9181
9285
  }
@@ -9183,7 +9287,7 @@ var Es = "okcls-stat-unload.", Ds = class e {
9183
9287
  let n = e._storage();
9184
9288
  if (!n) return !1;
9185
9289
  try {
9186
- 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;
9290
+ 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;
9187
9291
  } catch (e) {
9188
9292
  return z.error("[StatUnloadJournal] failed to write", e), !1;
9189
9293
  }
@@ -9195,7 +9299,7 @@ var Es = "okcls-stat-unload.", Ds = class e {
9195
9299
  try {
9196
9300
  for (let e = 0; e < t.length; e += 1) {
9197
9301
  let r = t.key(e);
9198
- r && r.startsWith(Es) && n.push(r);
9302
+ r && r.startsWith(js) && n.push(r);
9199
9303
  }
9200
9304
  } catch (e) {
9201
9305
  return z.error("[StatUnloadJournal] failed to scan journals", e), 0;
@@ -9238,32 +9342,32 @@ var Es = "okcls-stat-unload.", Ds = class e {
9238
9342
  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;
9239
9343
  }
9240
9344
  };
9241
- h(Ds, "_tabKey", null), h(Ds, "_entries", []);
9345
+ h(Ms, "_tabKey", null), h(Ms, "_entries", []);
9242
9346
  //#endregion
9243
9347
  //#region src/classes/stat/StatDrainScheduler.ts
9244
- var Os = 500, ks = 100, As = 3e4, js = 1e3, Ms = 5e3, Ns = 3e3, Ps = "okcls-stat-drain", Fs = class e {
9348
+ var Ns = 500, Ps = 100, Fs = 3e4, Is = 1e3, Ls = 5e3, Rs = 3e3, zs = "okcls-stat-drain", Bs = class e {
9245
9349
  static setApi(t) {
9246
- e._api = t, Ts.setApi(t);
9350
+ e._api = t, As.setApi(t);
9247
9351
  }
9248
9352
  static start(t) {
9249
- 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));
9353
+ 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));
9250
9354
  }
9251
9355
  static notifyAppended() {
9252
9356
  if (e._api) {
9253
- if (e._localCount += 1, e._localCount >= ks) {
9357
+ if (e._localCount += 1, e._localCount >= Ps) {
9254
9358
  e._drain();
9255
9359
  return;
9256
9360
  }
9257
- e._state === "IDLE" && e._arm(As);
9361
+ e._state === "IDLE" && e._arm(Fs);
9258
9362
  }
9259
9363
  }
9260
9364
  static notifyCallFinished() {
9261
9365
  if (e._api) {
9262
- if (e._directBuffer.length > 0 && e._armDirect(js), e._state === "DRAINING") {
9366
+ if (e._directBuffer.length > 0 && e._armDirect(Is), e._state === "DRAINING") {
9263
9367
  e._callFinishedDuringDrain = !0;
9264
9368
  return;
9265
9369
  }
9266
- e._arm(js);
9370
+ e._arm(Is);
9267
9371
  }
9268
9372
  }
9269
9373
  static drainOnce() {
@@ -9272,7 +9376,7 @@ var Os = 500, ks = 100, As = 3e4, js = 1e3, Ms = 5e3, Ns = 3e3, Ps = "okcls-stat
9272
9376
  if (!t) return !1;
9273
9377
  let n = e._currentUserId(), r = await Q.listUids(), i = !1, a = null;
9274
9378
  for (let o of r) try {
9275
- (o === n ? await e._drainCurrent(t, o) : await e._drainStored(t, o)) === Os && (i = !0);
9379
+ (o === n ? await e._drainCurrent(t, o) : await e._drainStored(t, o)) === Ns && (i = !0);
9276
9380
  } catch (e) {
9277
9381
  a === null && (a = e);
9278
9382
  }
@@ -9286,20 +9390,20 @@ var Os = 500, ks = 100, As = 3e4, js = 1e3, Ms = 5e3, Ns = 3e3, Ps = "okcls-stat
9286
9390
  z.error("[StatDrainScheduler] direct send skipped: event belongs to another user");
9287
9391
  return;
9288
9392
  }
9289
- e._directBuffer.push(t), e._directTimer === null && e._armDirect(Ns);
9393
+ e._directBuffer.push(t), e._directTimer === null && e._armDirect(Rs);
9290
9394
  }
9291
9395
  }
9292
9396
  static __resetForTests() {
9293
- Ts.__resetForTests(), e._clearTimer(), e._clearDirectTimer(), e._directBuffer = [], e._api = null, e._state = "IDLE", e._localCount = 0, e._callFinishedDuringDrain = !1, e._blockedSession = null;
9397
+ As.__resetForTests(), e._clearTimer(), e._clearDirectTimer(), e._directBuffer = [], e._api = null, e._state = "IDLE", e._localCount = 0, e._callFinishedDuringDrain = !1, e._blockedSession = null;
9294
9398
  }
9295
9399
  static _currentUserId() {
9296
9400
  return y.userId;
9297
9401
  }
9298
9402
  static async _drainCurrent(t, n) {
9299
9403
  if (e._isSessionBlocked()) return 0;
9300
- let r = await Q.readOldest(n, Os);
9404
+ let r = await Q.readOldest(n, Ns);
9301
9405
  if (r.length === 0) return 0;
9302
- let i = await Ts.get(), a = r.map((t) => e._toClientStats(t, i)), o = r.map((e) => e.id);
9406
+ let i = await As.get(), a = r.map((t) => e._toClientStats(t, i)), o = r.map((e) => e.id);
9303
9407
  try {
9304
9408
  await t.logClientStats(a);
9305
9409
  } catch (t) {
@@ -9310,25 +9414,25 @@ var Os = 500, ks = 100, As = 3e4, js = 1e3, Ms = 5e3, Ns = 3e3, Ps = "okcls-stat
9310
9414
  return await Q.remove(o), r.length;
9311
9415
  }
9312
9416
  static async _drainStored(t, n) {
9313
- let r = Cs.get(n);
9314
- if (!r || r.endpoint !== Cs.currentEndpoint()) return 0;
9315
- let i = await Q.readOldest(n, Os);
9417
+ let r = Os.get(n);
9418
+ if (!r || r.endpoint !== Os.currentEndpoint()) return 0;
9419
+ let i = await Q.readOldest(n, Ns);
9316
9420
  if (i.length === 0) return 0;
9317
- let a = await Ts.get(), o = i.map((t) => e._toClientStats(t, a)), s = i.map((e) => e.id);
9421
+ let a = await As.get(), o = i.map((t) => e._toClientStats(t, a)), s = i.map((e) => e.id);
9318
9422
  try {
9319
9423
  await t.logClientStatsWith(r.sessionKey, o), z.debug("[StatDrainScheduler] delivered", i.length, "stored events of uid", n);
9320
9424
  } catch (t) {
9321
- if (e._isAuthError(t)) return z.error("[StatDrainScheduler] stored session expired, skipping uid", n), Cs.forget(n), 0;
9425
+ if (e._isAuthError(t)) return z.error("[StatDrainScheduler] stored session expired, skipping uid", n), Os.forget(n), 0;
9322
9426
  if (e._isRetryable(t)) throw t;
9323
9427
  return z.error("[StatDrainScheduler] batch rejected, dropping", t), await Q.remove(s), i.length;
9324
9428
  }
9325
9429
  return await Q.remove(s), i.length;
9326
9430
  }
9327
9431
  static _withLock(e) {
9328
- return typeof navigator > "u" || !navigator.locks ? e() : navigator.locks.request(Ps, e);
9432
+ return typeof navigator > "u" || !navigator.locks ? e() : navigator.locks.request(zs, e);
9329
9433
  }
9330
9434
  static _isSessionError(e) {
9331
- return Zo(e?.error_code);
9435
+ return ns(e?.error_code);
9332
9436
  }
9333
9437
  static _isReauthorizeFailure(e) {
9334
9438
  return e?.error === x.AUTH;
@@ -9341,7 +9445,7 @@ var Os = 500, ks = 100, As = 3e4, js = 1e3, Ms = 5e3, Ns = 3e3, Ps = "okcls-stat
9341
9445
  }
9342
9446
  static _isAuthError(t) {
9343
9447
  let n = t?.error_code;
9344
- return e._isSessionError(t) || n === Xo.AUTH_LOGIN;
9448
+ return e._isSessionError(t) || n === ts.AUTH_LOGIN;
9345
9449
  }
9346
9450
  static _isRetryable(t) {
9347
9451
  if (e._isSessionError(t)) return !0;
@@ -9366,7 +9470,7 @@ var Os = 500, ks = 100, As = 3e4, js = 1e3, Ms = 5e3, Ns = 3e3, Ps = "okcls-stat
9366
9470
  static async _flushDirect() {
9367
9471
  let t = e._api, n = e._directBuffer;
9368
9472
  if (e._directBuffer = [], !(!t || n.length === 0)) try {
9369
- let r = await Ts.get();
9473
+ let r = await As.get();
9370
9474
  await t.logClientStats(n.map((t) => e._toClientStats(t, r)));
9371
9475
  } catch (e) {
9372
9476
  z.error("[StatDrainScheduler] direct send failed, events lost", e);
@@ -9385,28 +9489,28 @@ var Os = 500, ks = 100, As = 3e4, js = 1e3, Ms = 5e3, Ns = 3e3, Ps = "okcls-stat
9385
9489
  e._clearTimer(), e._state = "DRAINING", e._localCount = 0, e._callFinishedDuringDrain = !1;
9386
9490
  try {
9387
9491
  if (await e.drainOnce()) {
9388
- e._arm(Ms);
9492
+ e._arm(Ls);
9389
9493
  return;
9390
9494
  }
9391
9495
  if (e._callFinishedDuringDrain) {
9392
- e._arm(js);
9496
+ e._arm(Is);
9393
9497
  return;
9394
9498
  }
9395
9499
  if (e._localCount > 0) {
9396
- e._arm(As);
9500
+ e._arm(Fs);
9397
9501
  return;
9398
9502
  }
9399
9503
  e._state = "IDLE";
9400
9504
  } catch (t) {
9401
- z.error("[StatDrainScheduler] drain failed", t), e._arm(As);
9505
+ z.error("[StatDrainScheduler] drain failed", t), e._arm(Fs);
9402
9506
  }
9403
9507
  }
9404
9508
  }
9405
9509
  };
9406
- 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);
9510
+ 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);
9407
9511
  //#endregion
9408
9512
  //#region src/classes/StatsLogger.ts
9409
- var Is = class extends f {
9513
+ var Vs = class extends f {
9410
9514
  constructor(e, t, n, r = () => void 0) {
9411
9515
  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();
9412
9516
  }
@@ -9486,7 +9590,7 @@ var Is = class extends f {
9486
9590
  _now() {
9487
9591
  return Date.now() - this._serverTimeDelta;
9488
9592
  }
9489
- }, Ls = class e extends f {
9593
+ }, Hs = class e extends f {
9490
9594
  static __resetForTests() {
9491
9595
  e._pending = [], e._pendingOverflow = !1;
9492
9596
  }
@@ -9502,40 +9606,39 @@ var Is = class extends f {
9502
9606
  return e._pending = [], e._pendingOverflow = !1, t;
9503
9607
  }
9504
9608
  constructor(e, t, n, r = () => void 0) {
9505
- 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);
9609
+ 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);
9506
9610
  }
9507
9611
  log(e, t, n = !1) {
9508
9612
  this._externalLogger && this._externalLogger.log(e, t, n);
9509
9613
  }
9510
9614
  enterUnloadMode() {
9511
- this._legacy || (this._unloadMode = !0, Ds.beginTabSession());
9615
+ this._legacy || (this._unloadMode = !0, Ms.beginTabSession());
9512
9616
  }
9513
9617
  exitUnloadMode() {
9514
- this._legacy || !this._unloadMode || (this._unloadMode = !1, Ds.drainToQueue().then((e) => {
9515
- e > 0 && Fs.notifyAppended();
9618
+ this._legacy || !this._unloadMode || (this._unloadMode = !1, Ms.drainToQueue().then((e) => {
9619
+ e > 0 && Bs.notifyAppended();
9516
9620
  }).catch((e) => z.error("[StatEventCollector] failed to import unload journal", e)));
9517
9621
  }
9518
9622
  logClientStats(t, n = {}) {
9519
- let r = n.conversationId === void 0 ? this._getConversationId() : n.conversationId, i = n.occurredAt === void 0 ? Date.now() : n.occurredAt;
9520
- if (R.onClientStats({
9623
+ let r = n.conversationId === void 0 ? this._getConversationId() : n.conversationId, i = n.occurredAt === void 0 ? Date.now() : n.occurredAt, a = {
9521
9624
  ...t,
9625
+ call_topology: t.call_topology ?? this._getCallTopology()
9626
+ };
9627
+ if (Object.keys(a).forEach((e) => {
9628
+ a[e] === void 0 && delete a[e];
9629
+ }), R.onClientStats({
9630
+ ...a,
9522
9631
  vcid: r,
9523
9632
  ts: i
9524
9633
  }), this._legacy) {
9525
9634
  this._legacy.logClientStats(t, n);
9526
9635
  return;
9527
9636
  }
9528
- let a = {
9529
- ...t,
9530
- call_topology: t.call_topology ?? this._getCallTopology()
9531
- };
9532
- Object.keys(a).forEach((e) => {
9533
- a[e] === void 0 && delete a[e];
9534
- }), Ts.ensure();
9637
+ As.ensure();
9535
9638
  let o = {
9536
9639
  vcid: r,
9537
9640
  ts: i,
9538
- delta: Ts.delta(),
9641
+ delta: As.delta(),
9539
9642
  ev: a
9540
9643
  }, s = y.userId;
9541
9644
  if (s === null) {
@@ -9558,12 +9661,12 @@ var Is = class extends f {
9558
9661
  }
9559
9662
  }
9560
9663
  _store(e) {
9561
- this._unloadMode && Ds.writeSync(e) || Q.append(e).then((t) => {
9664
+ this._unloadMode && Ms.writeSync(e) || Q.append(e).then((t) => {
9562
9665
  if (t !== null) {
9563
- typeof e.delta != "number" && Ts.noteAppended(t), Fs.notifyAppended();
9666
+ typeof e.delta != "number" && As.noteAppended(t), Bs.notifyAppended();
9564
9667
  return;
9565
9668
  }
9566
- z.error("[StatEventCollector] failed to store event, sending directly"), Fs.sendDirect(e);
9669
+ z.error("[StatEventCollector] failed to store event, sending directly"), Bs.sendDirect(e);
9567
9670
  }).catch((e) => z.error("[StatEventCollector] failed to store event", e));
9568
9671
  }
9569
9672
  _getConversationId() {
@@ -9581,10 +9684,10 @@ var Is = class extends f {
9581
9684
  }
9582
9685
  }
9583
9686
  };
9584
- h(Ls, "_pending", []), h(Ls, "_pendingOverflow", !1);
9687
+ h(Hs, "_pending", []), h(Hs, "_pendingOverflow", !1);
9585
9688
  //#endregion
9586
9689
  //#region src/classes/stat/ApiCallStats.ts
9587
- var Rs = class {
9690
+ var Us = class {
9588
9691
  constructor(e) {
9589
9692
  h(this, "_statAggregator", void 0), this._statAggregator = e;
9590
9693
  }
@@ -9596,7 +9699,7 @@ var Rs = class {
9596
9699
  string_value: n
9597
9700
  });
9598
9701
  }
9599
- }, zs = "invalid-error-metadata", Bs = 64, Vs = new Set(Object.values(O)), Hs = new Set(Object.values(x)), Us = {
9702
+ }, Ws = "invalid-error-metadata", Gs = 64, Ks = new Set(Object.values(O)), qs = new Set(Object.values(x)), Js = {
9600
9703
  [O.CANCELED]: {
9601
9704
  type: "semantic",
9602
9705
  reason: "canceled"
@@ -9717,7 +9820,7 @@ var Rs = class {
9717
9820
  type: "semantic",
9718
9821
  reason: "obsolete_client"
9719
9822
  }
9720
- }, Ws = {
9823
+ }, Ys = {
9721
9824
  [x.MIC_CAMERA_PERMISSION]: {
9722
9825
  type: "direct-error",
9723
9826
  error: {
@@ -9806,14 +9909,14 @@ var Rs = class {
9806
9909
  }
9807
9910
  }
9808
9911
  };
9809
- function Gs(e) {
9810
- if (typeof e != "string" && typeof e != "number" || typeof e == "number" && !Number.isFinite(e)) return zs;
9912
+ function Xs(e) {
9913
+ if (typeof e != "string" && typeof e != "number" || typeof e == "number" && !Number.isFinite(e)) return Ws;
9811
9914
  let t = String(e).trim();
9812
- if (!t) return zs;
9915
+ if (!t) return Ws;
9813
9916
  let n = t.toLowerCase().replace(/[\s_:]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
9814
- return !n || !/^[a-z0-9.-]+$/.test(n) ? zs : n.length > Bs ? `${n.slice(0, Bs - 3)}...` : n;
9917
+ return !n || !/^[a-z0-9.-]+$/.test(n) ? Ws : n.length > Gs ? `${n.slice(0, Gs - 3)}...` : n;
9815
9918
  }
9816
- function Ks(e) {
9919
+ function Zs(e) {
9817
9920
  if (!e || typeof e != "object") return !1;
9818
9921
  let t = e;
9819
9922
  switch (t.scope) {
@@ -9825,49 +9928,49 @@ function Ks(e) {
9825
9928
  default: return !1;
9826
9929
  }
9827
9930
  }
9828
- function qs(e) {
9829
- let t = Gs(e.description);
9931
+ function Qs(e) {
9932
+ let t = Xs(e.description);
9830
9933
  if (e.scope === "unknown") return `unknown:${t}`;
9831
- let n = Gs(e.code);
9934
+ let n = Xs(e.code);
9832
9935
  return e.scope === "internal" ? `internal:${n}:${t}` : `${e.scope}:${e.source}:${n}:${t}`;
9833
9936
  }
9834
- function Js(e, t) {
9937
+ function $s(e, t) {
9835
9938
  return t === null ? e.type === "direct-error" ? {
9836
9939
  reason: "error",
9837
- string_value: qs(e.error)
9838
- } : { reason: "failed" } : Ks(t) ? {
9940
+ string_value: Qs(e.error)
9941
+ } : { reason: "failed" } : Zs(t) ? {
9839
9942
  reason: "error",
9840
- string_value: qs(t)
9943
+ string_value: Qs(t)
9841
9944
  } : { reason: "failed" };
9842
9945
  }
9843
- function Ys(e) {
9946
+ function ec(e) {
9844
9947
  if (e.hangup) {
9845
- let t = Us[e.hangup];
9948
+ let t = Js[e.hangup];
9846
9949
  return t ? t.type === "semantic" ? e.hangup === O.OBSOLETE_CLIENT && e.custom_error?.vchat_detailed_api_error.code ? {
9847
9950
  reason: t.reason,
9848
9951
  string_value: e.custom_error.vchat_detailed_api_error.code
9849
- } : { reason: t.reason } : Js(t, e.callError) : { reason: "failed" };
9952
+ } : { reason: t.reason } : $s(t, e.callError) : { reason: "failed" };
9850
9953
  }
9851
9954
  if (e.error) {
9852
- let t = Ws[e.error];
9853
- return t ? Js(t, e.callError) : { reason: "failed" };
9955
+ let t = Ys[e.error];
9956
+ return t ? $s(t, e.callError) : { reason: "failed" };
9854
9957
  }
9855
9958
  return { reason: "failed" };
9856
9959
  }
9857
- function Xs(e) {
9858
- return e instanceof k ? Ys(e) : typeof e == "string" && (Vs.has(e) || Hs.has(e)) ? Ys(new k(e)) : { reason: "failed" };
9960
+ function tc(e) {
9961
+ return e instanceof k ? ec(e) : typeof e == "string" && (Ks.has(e) || qs.has(e)) ? ec(new k(e)) : { reason: "failed" };
9859
9962
  }
9860
9963
  //#endregion
9861
9964
  //#region src/classes/stat/CallLifecycleStats.ts
9862
- var Zs = {
9965
+ var nc = {
9863
9966
  wallNow: () => Date.now(),
9864
9967
  monotonicNow: () => performance.now()
9865
9968
  };
9866
- function Qs(e) {
9969
+ function rc(e) {
9867
9970
  return e === "anonym_join" ? "join" : e;
9868
9971
  }
9869
- var $s = class {
9870
- constructor(e, t = Zs) {
9972
+ var ic = class {
9973
+ constructor(e, t = nc) {
9871
9974
  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;
9872
9975
  }
9873
9976
  get firstMediaSentReported() {
@@ -9879,7 +9982,7 @@ var $s = class {
9879
9982
  markInitializationStarted({ source: e, conversationId: t }) {
9880
9983
  if (this._destroyed || this._callStartLabel !== null) return;
9881
9984
  let n = this._clock.wallNow();
9882
- this._callStartLabel = Qs(e), this._lifecycleStartedAtMonotonic = this._clock.monotonicNow(), t && (this._conversationId = t), this._record({
9985
+ this._callStartLabel = rc(e), this._lifecycleStartedAtMonotonic = this._clock.monotonicNow(), t && (this._conversationId = t), this._record({
9883
9986
  name: U.CALL_INIT,
9884
9987
  source: e
9885
9988
  }, n);
@@ -9907,7 +10010,7 @@ var $s = class {
9907
10010
  !this._canRecord() || this._firstMediaSent || (this._firstMediaSent = !0, this._record({ name: U.FIRST_MEDIA_SENT }));
9908
10011
  }
9909
10012
  markFinished(e) {
9910
- this._finish(Xs(e));
10013
+ this._finish(tc(e));
9911
10014
  }
9912
10015
  markTerminated() {
9913
10016
  this._finish({ reason: "terminated" });
@@ -9958,7 +10061,7 @@ var $s = class {
9958
10061
  ...n && { immediately: !0 }
9959
10062
  });
9960
10063
  }
9961
- }, ec = class {
10064
+ }, ac = class {
9962
10065
  constructor(e, t) {
9963
10066
  h(this, "_logger", void 0), h(this, "_codecUsages", /* @__PURE__ */ new Map()), h(this, "getCurrentTransportTopology", void 0), this._logger = e, this.getCurrentTransportTopology = t;
9964
10067
  }
@@ -10021,7 +10124,7 @@ var $s = class {
10021
10124
  this.report(e);
10022
10125
  }), this._codecUsages.clear();
10023
10126
  }
10024
- }, tc = class {
10127
+ }, oc = class {
10025
10128
  constructor(e) {
10026
10129
  h(this, "_logger", void 0), h(this, "_eventualLogs", /* @__PURE__ */ new Set()), h(this, "_lastCallStatContext", null), this._logger = e;
10027
10130
  }
@@ -10064,7 +10167,7 @@ var $s = class {
10064
10167
  for (let [t, r] of Object.entries(e)) r !== void 0 && (r === null ? delete n[t] : n[t] = r);
10065
10168
  this._logger.logClientStats(n, { occurredAt: t });
10066
10169
  }
10067
- }, nc = class {
10170
+ }, sc = class {
10068
10171
  constructor(e) {
10069
10172
  if (h(this, "q", void 0), h(this, "inits", []), h(this, "n", [
10070
10173
  1,
@@ -10123,7 +10226,7 @@ var $s = class {
10123
10226
  5
10124
10227
  ];
10125
10228
  }
10126
- }, rc = class {
10229
+ }, cc = class {
10127
10230
  constructor() {
10128
10231
  h(this, "n", 0), h(this, "mean", 0);
10129
10232
  }
@@ -10135,9 +10238,9 @@ var $s = class {
10135
10238
  get avg() {
10136
10239
  return this.n ? this.mean : NaN;
10137
10240
  }
10138
- }, ic = class {
10241
+ }, lc = class {
10139
10242
  constructor() {
10140
- 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));
10243
+ 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));
10141
10244
  }
10142
10245
  add(e) {
10143
10246
  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++;
@@ -10155,18 +10258,18 @@ var $s = class {
10155
10258
  get hasData() {
10156
10259
  return this.count > 0;
10157
10260
  }
10158
- }, ac = class {
10261
+ }, uc = 120 * 1e3, dc = class {
10159
10262
  constructor(e) {
10160
10263
  h(this, "_logger", void 0), h(this, "trackerByTransport", {
10161
- ws: new ic(),
10162
- wt: new ic()
10264
+ ws: new lc(),
10265
+ wt: new lc()
10163
10266
  }), h(this, "lastSeen", {}), this._logger = e;
10164
10267
  }
10165
10268
  mark(e) {
10166
10269
  let t = Date.now(), n = this.lastSeen[e];
10167
10270
  if (typeof n == "number") {
10168
10271
  let r = t - n;
10169
- r >= 0 && this.trackerByTransport[e].add(r);
10272
+ r >= 0 && r <= uc && this.trackerByTransport[e].add(r);
10170
10273
  }
10171
10274
  this.lastSeen[e] = t;
10172
10275
  }
@@ -10186,19 +10289,22 @@ var $s = class {
10186
10289
  });
10187
10290
  });
10188
10291
  }
10292
+ resetBaseline() {
10293
+ this.lastSeen = {};
10294
+ }
10189
10295
  destroy() {
10190
10296
  this.trackerByTransport = {
10191
- ws: new ic(),
10192
- wt: new ic()
10297
+ ws: new lc(),
10298
+ wt: new lc()
10193
10299
  }, this.lastSeen = {};
10194
10300
  }
10195
- }, oc = class {
10301
+ }, fc = class {
10196
10302
  constructor(e) {
10197
10303
  h(this, "_logger", void 0), h(this, "trackerByCommand", /* @__PURE__ */ new Map()), this._logger = e;
10198
10304
  }
10199
10305
  mark(e, t, n) {
10200
10306
  let r = `${e}|${n}`, i;
10201
- this.trackerByCommand.has(r) ? i = this.trackerByCommand.get(r) : (i = new ic(), this.trackerByCommand.set(r, i)), i.add(t);
10307
+ this.trackerByCommand.has(r) ? i = this.trackerByCommand.get(r) : (i = new lc(), this.trackerByCommand.set(r, i)), i.add(t);
10202
10308
  }
10203
10309
  logMetrics() {
10204
10310
  for (let [e, t] of this.trackerByCommand.entries()) {
@@ -10220,9 +10326,9 @@ var $s = class {
10220
10326
  destroy() {
10221
10327
  this.trackerByCommand.clear();
10222
10328
  }
10223
- }, sc = class {
10329
+ }, pc = class {
10224
10330
  constructor(e, t, n, r) {
10225
- 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);
10331
+ 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);
10226
10332
  }
10227
10333
  prepareForUnload() {
10228
10334
  N.statQueueEnabled && (this._unloading = !0, this.logger.enterUnloadMode(), this.pings.logMetrics(), this.signalingCommands.logMetrics());
@@ -10230,6 +10336,9 @@ var $s = class {
10230
10336
  restoreAfterUnload() {
10231
10337
  N.statQueueEnabled && (this._unloading = !1, this.logger.exitUnloadMode());
10232
10338
  }
10339
+ resetPingBaseline() {
10340
+ this.pings.resetBaseline();
10341
+ }
10233
10342
  logHangup(e) {
10234
10343
  this.lifecycle.markFinished(e);
10235
10344
  }
@@ -10237,9 +10346,9 @@ var $s = class {
10237
10346
  this.codecStatsAggregator.destroy(), this.pings.logMetrics(), this.pings.destroy(), this.signalingCommands.logMetrics(), this.signalingCommands.destroy();
10238
10347
  }
10239
10348
  destroy() {
10240
- 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();
10349
+ 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();
10241
10350
  }
10242
- }, cc = class {
10351
+ }, mc = class {
10243
10352
  constructor(e) {
10244
10353
  h(this, "_statAggregator", void 0), h(this, "_isCallMarked", !1), h(this, "_isFinished", !1), h(this, "_callType", null), this._statAggregator = e;
10245
10354
  }
@@ -10264,8 +10373,8 @@ var $s = class {
10264
10373
  call_type: this._callType
10265
10374
  }));
10266
10375
  }
10267
- }, lc = 1e3, uc = 1e4;
10268
- function dc(e, t, n, r) {
10376
+ }, hc = 1e3, gc = 1e4;
10377
+ function _c(e, t, n, r) {
10269
10378
  return new k(e, {
10270
10379
  callError: {
10271
10380
  scope: "external",
@@ -10276,11 +10385,11 @@ function dc(e, t, n, r) {
10276
10385
  message: r
10277
10386
  });
10278
10387
  }
10279
- var fc = 15, $ = class e extends b {
10388
+ var vc = 15, $ = class e extends b {
10280
10389
  constructor(e, t) {
10281
- 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, "_invalidTokenRetried", !1), h(this, "_statFirstMediaReceived", void 0), h(this, "_toggleLocalVideo", ko((e) => {
10390
+ 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) => {
10282
10391
  if (this._mediaSource) return this._stats.logger.log(C.MEDIA_STATUS, e ? "video_1" : "video_0"), this._mediaSource.toggleVideo(e);
10283
- })), h(this, "_toggleLocalAudio", ko((e) => {
10392
+ })), h(this, "_toggleLocalAudio", Po((e) => {
10284
10393
  if (this._mediaSource) return this._stats.logger.log(C.MEDIA_STATUS, e ? "audio_1" : "audio_0"), this._mediaSource.toggleAudio(e);
10285
10394
  })), h(this, "_changeMediaSettings", M.debounce(async (e) => {
10286
10395
  if (this._signaling.ready) try {
@@ -10292,7 +10401,7 @@ var fc = 15, $ = class e extends b {
10292
10401
  captureAudio: !1
10293
10402
  });
10294
10403
  }
10295
- }, 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({
10404
+ }, 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({
10296
10405
  api: this._api,
10297
10406
  debug: this._debug,
10298
10407
  getParticipants: () => this._participants,
@@ -10300,16 +10409,18 @@ var fc = 15, $ = class e extends b {
10300
10409
  updateDisplayLayout: (e) => this.updateDisplayLayout(e),
10301
10410
  onNonFatalError: (e) => this._onNonFatalError(e)
10302
10411
  }), this._onUnload = () => {
10303
- this._stopFirstMediaSentProbe(), this._conversation && this._api && this._sendHangupApi(this._conversation.id, this._state === "IDLE" ? O.CANCELED : O.HUNGUP), this._stats.prepareForUnload(), this._stats.destroy();
10412
+ 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();
10304
10413
  }, this._onRestore = () => {
10305
- this._stats.restoreAfterUnload();
10306
- }, 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));
10414
+ this._stats.resetPingBaseline(), this._stats.restoreAfterUnload();
10415
+ }, this._onVisibilityChange = () => {
10416
+ document.visibilityState === "hidden" && this._stats.resetPingBaseline();
10417
+ }, 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));
10307
10418
  }
10308
10419
  static current() {
10309
10420
  return B.getActive() ?? (N.hold ? null : B.getFirst());
10310
10421
  }
10311
10422
  static hangupAfterInit(e) {
10312
- let t = pc;
10423
+ let t = yc;
10313
10424
  if (t) {
10314
10425
  if (typeof e == "function" && (t._onFastHangup = e), t._delayedHangup === !1 && !t._conversation) {
10315
10426
  t._delayedHangup = !0, t._abortController?.abort(new k(O.CANCELED));
@@ -10337,7 +10448,7 @@ var fc = 15, $ = class e extends b {
10337
10448
  return this._state === "HELD";
10338
10449
  }
10339
10450
  get isIncomingRinging() {
10340
- return this._conversation?.direction === to.INCOMING && this._state === "IDLE";
10451
+ return this._conversation?.direction === oo.INCOMING && this._state === "IDLE";
10341
10452
  }
10342
10453
  static debugSessionId() {
10343
10454
  return e.current()?.debugSessionId ?? null;
@@ -10363,7 +10474,7 @@ var fc = 15, $ = class e extends b {
10363
10474
  R.onNonFatalError(Error(e), this.id);
10364
10475
  }
10365
10476
  getIncomingCallerExternalId() {
10366
- return this._conversation?.direction === to.INCOMING ? Object.values(this._participants).find((e) => !this._isMe(e.id))?.externalId ?? null : null;
10477
+ return this._conversation?.direction === oo.INCOMING ? Object.values(this._participants).find((e) => !this._isMe(e.id))?.externalId ?? null : null;
10367
10478
  }
10368
10479
  _buildInternalParams() {
10369
10480
  let e = {
@@ -10373,24 +10484,24 @@ var fc = 15, $ = class e extends b {
10373
10484
  platform: N.platform,
10374
10485
  protocolVersion: N.protocolVersion,
10375
10486
  domainId: N.domain,
10376
- capabilities: Fa.getFlags()
10487
+ capabilities: Ba.getFlags()
10377
10488
  };
10378
10489
  return JSON.stringify(e);
10379
10490
  }
10380
10491
  async onStart({ opponentIds: e, opponentType: t, mediaOptions: n, payload: r = "", joiningAllowed: i = !1, requireAuthToJoin: a = !1, onlyAdminCanShareMovie: o, externalIds: s, onFastStart: c, conversationId: l }) {
10381
- let u = l ?? M.uuid(), d = (e?.length ?? 0) + (s?.length ?? 0), f = t === no.USER && d === 1 ? N.calleeUnavailableWaitingTime : void 0;
10492
+ let u = l ?? M.uuid(), d = (e?.length ?? 0) + (s?.length ?? 0), f = t === so.USER && d === 1 ? N.calleeUnavailableWaitingTime : void 0;
10382
10493
  this._stats.lifecycle.markInitializationStarted({
10383
10494
  source: "outgoing",
10384
10495
  conversationId: u
10385
- }), this._debug.setConversationId(u), pc = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
10496
+ }), this._debug.setConversationId(u), yc = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
10386
10497
  try {
10387
10498
  this._mediaSource = this._createMediaSource(), await this._mediaSource.request(n);
10388
10499
  let l = this._mediaSource.mediaSettings;
10389
- t === no.CHAT || e && e.length > 1 ? this._logWithMediaSettings(C.OUTGOING_MULTIPARTY_CALL, l) : this._logWithMediaSettings(C.OUTGOING_CALL, l);
10500
+ t === so.CHAT || e && e.length > 1 ? this._logWithMediaSettings(C.OUTGOING_MULTIPARTY_CALL, l) : this._logWithMediaSettings(C.OUTGOING_CALL, l);
10390
10501
  let d = await this._startConversation({
10391
10502
  opponentIds: e,
10392
10503
  opponentType: t,
10393
- direction: to.OUTGOING,
10504
+ direction: oo.OUTGOING,
10394
10505
  mediaOptions: n,
10395
10506
  payload: r,
10396
10507
  joiningAllowed: i,
@@ -10414,18 +10525,18 @@ var fc = 15, $ = class e extends b {
10414
10525
  let e = B.get(this._conversation.id);
10415
10526
  e && e !== this && e._close(new k(O.HUNGUP, { remote: !0 }));
10416
10527
  }
10417
- 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(() => {
10528
+ 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(() => {
10418
10529
  this._calleeUnavailableTimer = null, this._close(new k(O.CALLEE_UNAVAILABLE), { signalingReason: O.CANCELED });
10419
10530
  }, f)), this._conversation;
10420
10531
  } catch (e) {
10421
- throw pc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to start conversation" }), e;
10532
+ throw yc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to start conversation" }), e;
10422
10533
  }
10423
10534
  }
10424
10535
  async onJoin(e) {
10425
10536
  this._stats.lifecycle.markInitializationStarted({
10426
10537
  source: e.anonymous ? "anonym_join" : "join",
10427
10538
  conversationId: e.conversationId
10428
- }), 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);
10539
+ }), 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);
10429
10540
  try {
10430
10541
  let t = !!e.observedIds?.length;
10431
10542
  if (t && N.videoTracksCount > 0) throw this._debug.error("Observer mode: please set videoTracksCount=0"), new k(O.UNSUPPORTED, { callError: {
@@ -10442,9 +10553,9 @@ var fc = 15, $ = class e extends b {
10442
10553
  code: "conversation",
10443
10554
  description: "not-initialized-after-join"
10444
10555
  } });
10445
- 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);
10556
+ 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);
10446
10557
  } catch (e) {
10447
- throw pc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
10558
+ throw yc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
10448
10559
  }
10449
10560
  }
10450
10561
  async _onJoinPart2(e, t = !0, n = !1) {
@@ -10459,7 +10570,7 @@ var fc = 15, $ = class e extends b {
10459
10570
  if (this._delayedHangup) throw new k(O.CANCELED);
10460
10571
  this._processConnectionSharedMovieInfo(e), this._processConversationUrlSharingInfo(e), this._processConnectionAsrInfo(e);
10461
10572
  let r = this._extractExternalRoomsData(e.rooms?.rooms, e.rooms?.roomId);
10462
- 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);
10573
+ 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);
10463
10574
  let i = this._extractLocalParticipantFromConnection(e);
10464
10575
  if (i) {
10465
10576
  let e = M.mapParticipantState(i);
@@ -10467,7 +10578,7 @@ var fc = 15, $ = class e extends b {
10467
10578
  }
10468
10579
  return t && this._openTransport(Object.values(this._participants), !1), this._conversation;
10469
10580
  } catch (e) {
10470
- throw pc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
10581
+ throw yc = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
10471
10582
  }
10472
10583
  }
10473
10584
  _extractExternalRooms(e) {
@@ -10487,7 +10598,7 @@ var fc = 15, $ = class e extends b {
10487
10598
  B.reserve(e), this._reservedId = e, a && this._api.setUserId(a), this._stats.lifecycle.markInitializationStarted({
10488
10599
  source: "incoming",
10489
10600
  conversationId: e
10490
- }), this._debug.setConversationId(e), pc = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
10601
+ }), this._debug.setConversationId(e), yc = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
10491
10602
  try {
10492
10603
  let a = await this._prepareConversation(e, t, n, r, i);
10493
10604
  if (this._mediaSource = this._createMediaSource(), !this._conversation) throw new k(O.UNKNOWN_ERROR, { callError: {
@@ -10496,20 +10607,20 @@ var fc = 15, $ = class e extends b {
10496
10607
  description: "incoming-not-initialized"
10497
10608
  } });
10498
10609
  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);
10499
- 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);
10610
+ 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);
10500
10611
  } catch (e) {
10501
- throw pc = null, this._cleanupRegistry(), this._close(e, {
10612
+ throw yc = null, this._cleanupRegistry(), this._close(e, {
10502
10613
  errorText: "Unable to handle inbound call push",
10503
10614
  signalingReason: e instanceof k && e.hangup === O.BUSY ? O.BUSY : void 0
10504
10615
  }), e;
10505
10616
  }
10506
10617
  }
10507
10618
  _isInWaitingHall(e) {
10508
- return !e.conversation || !e.conversation.options.includes(ao.WAITING_HALL) ? !1 : this._isRestricted(e);
10619
+ return !e.conversation || !e.conversation.options.includes(uo.WAITING_HALL) ? !1 : this._isRestricted(e);
10509
10620
  }
10510
10621
  _isWaitForAdmin(e) {
10511
10622
  if (!e.conversation) return !1;
10512
- let t = e.conversation.options.includes(ao.WAIT_FOR_ADMIN), n = e.conversation.options.includes(ao.ADMIN_IS_HERE);
10623
+ let t = e.conversation.options.includes(uo.WAIT_FOR_ADMIN), n = e.conversation.options.includes(uo.ADMIN_IS_HERE);
10513
10624
  return !t || t && n ? !1 : this._isRestricted(e);
10514
10625
  }
10515
10626
  _isRestricted(e) {
@@ -10517,7 +10628,7 @@ var fc = 15, $ = class e extends b {
10517
10628
  return t && t.restricted || !1;
10518
10629
  }
10519
10630
  _isAudienceMode(e) {
10520
- return e.conversation?.options?.includes(ao.AUDIENCE_MODE) || !1;
10631
+ return e.conversation?.options?.includes(uo.AUDIENCE_MODE) || !1;
10521
10632
  }
10522
10633
  _isAudienceModeListener() {
10523
10634
  return this._conversation?.audienceMode && this._conversation?.restricted;
@@ -10547,7 +10658,7 @@ var fc = 15, $ = class e extends b {
10547
10658
  let i = atob(n), a = new Uint8Array(i.length);
10548
10659
  for (let e = 0; e < i.length; e++) a[e] = i.charCodeAt(e);
10549
10660
  try {
10550
- 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);
10661
+ 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);
10551
10662
  return {
10552
10663
  token: i,
10553
10664
  endpoint: l,
@@ -10722,7 +10833,7 @@ var fc = 15, $ = class e extends b {
10722
10833
  this._disposeSignaling(r), this._cleanupMediaSource();
10723
10834
  return;
10724
10835
  }
10725
- this._state = "CLOSE", this._participantState = X.HUNGUP, this._changeFeatureSet(), this._cleanupMediaSource(), this._cleanupParticipants(), this._cleanupParticipantAgnosticStreams(), this._cleanupTransport(), this._cleanupSpeakerDetector(), this._cleanupSpecListener(), this._disposeSignaling(r), this._api.cleanup(), this._api.setAbortSignal(void 0), this._stats.destroy(), this._cleanupRegistry(), this._conversation = null, this._myLastRequestedLayouts = {}, this._displayLayoutRequester.clear(), this._delayedHangup = !1, this._abortController = null, this._invalidTokenRetried = !1, this._emitHangupOnce(e || new k(O.UNKNOWN_ERROR), i);
10836
+ this._state = "CLOSE", this._participantState = X.HUNGUP, this._changeFeatureSet(), this._cleanupMediaSource(), this._cleanupParticipants(), this._cleanupParticipantAgnosticStreams(), this._cleanupTransport(), this._cleanupSpeakerDetector(), this._cleanupSpecListener(), this._disposeSignaling(r), this._api.cleanup(), this._api.setAbortSignal(void 0), this._stats.destroy(), this._cleanupRegistry(), this._conversation = null, this._myLastRequestedLayouts = {}, this._displayLayoutRequester.clear(), this._delayedHangup = !1, this._abortController = null, this._emitHangupOnce(e || new k(O.UNKNOWN_ERROR), i);
10726
10837
  }
10727
10838
  _sendHangup(e, t, n) {
10728
10839
  typeof n == "function" ? n({
@@ -10744,16 +10855,16 @@ var fc = 15, $ = class e extends b {
10744
10855
  if (this._debug.debug("Destroy conversation", { conversationId: t }), this._stopFirstMediaSentProbe(), this._cooldownQueueCleanupTimer !== null && (window.clearInterval(this._cooldownQueueCleanupTimer), this._cooldownQueueCleanupTimer = null), this._state = "CLOSE", this._participantState = X.HUNGUP, this._cleanupMediaSource(), this._cleanupParticipants(), this._cleanupParticipantAgnosticStreams(), this._cleanupTransport(), this._cleanupSpeakerDetector(), this._cleanupSpecListener(), this._disposeSignaling(e), this._delayedHangup && t) try {
10745
10856
  this._sendHangup(t, O.CANCELED, this._onFastHangup);
10746
10857
  } catch {}
10747
- this._api.cleanup(), this._api.setAbortSignal(void 0), this._cleanupListeners(), this._stats.destroy(), this._cleanupRegistry(), this._conversation = null, this._myLastRequestedLayouts = {}, this._displayLayoutRequester.clear(), this._delayedHangup = !1, this._abortController = null, this._invalidTokenRetried = !1;
10858
+ this._api.cleanup(), this._api.setAbortSignal(void 0), this._cleanupListeners(), this._stats.destroy(), this._cleanupRegistry(), this._conversation = null, this._myLastRequestedLayouts = {}, this._displayLayoutRequester.clear(), this._delayedHangup = !1, this._abortController = null;
10748
10859
  }
10749
10860
  async _getConversationParams(e) {
10750
10861
  let t = await this._api.getConversationParams(e);
10751
10862
  this._debug.debug("Api.getConversationParams", t);
10752
10863
  let { turn_server: n, stun_server: r } = t;
10753
- 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;
10864
+ 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;
10754
10865
  }
10755
10866
  _setConversationParams({ turn_server: e, stun_server: t, endpoint: n, wt_endpoint: r, token: i, client_type: a }) {
10756
- N.iceServers = Do(t, e), N.wssBase = n, N.wssToken = i, r && (N.wtsBase = r), a && (N.clientType = a);
10867
+ N.iceServers = Mo(t, e), N.wssBase = n, N.wssToken = i, r && (N.wtsBase = r), a && (N.clientType = a);
10757
10868
  }
10758
10869
  _buildSignalingEndpoint({ baseEndpoint: e, userId: t, type: n, deviceIdx: r, conversationId: i, token: a, conversationParams: o }) {
10759
10870
  let s = new URL(e), c = s.searchParams;
@@ -10785,10 +10896,10 @@ var fc = 15, $ = class e extends b {
10785
10896
  isVideo: f,
10786
10897
  joiningAllowed: a,
10787
10898
  requireAuthToJoin: o
10788
- }, this._abortController?.signal), !e) throw dc(O.FAST_START_ERROR, "invalid-response", "fast-start-response-empty");
10899
+ }, this._abortController?.signal), !e) throw _c(O.FAST_START_ERROR, "invalid-response", "fast-start-response-empty");
10789
10900
  if (!e.internalCallerParams) {
10790
10901
  let t = e.rejectedParticipants[0]?.status;
10791
- throw dc(O.FAST_START_ERROR, t ? "fast-start" : "invalid-response", t ?? "fast-start-internal-caller-params-empty", JSON.stringify(e));
10902
+ throw _c(O.FAST_START_ERROR, t ? "fast-start" : "invalid-response", t ?? "fast-start-internal-caller-params-empty", JSON.stringify(e));
10792
10903
  }
10793
10904
  } catch (e) {
10794
10905
  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) });
@@ -10810,10 +10921,10 @@ var fc = 15, $ = class e extends b {
10810
10921
  token: new URL(t.endpoint).searchParams.get("token") ?? ""
10811
10922
  }, this._debug.debug("FastStart", p), m = "fastStart";
10812
10923
  } catch {
10813
- throw dc(O.FAST_START_ERROR, "invalid-response", "fast-start-internal-caller-params-invalid");
10924
+ throw _c(O.FAST_START_ERROR, "invalid-response", "fast-start-internal-caller-params-invalid");
10814
10925
  }
10815
10926
  } else p = await this._api.startConversation(d, e, t, f, i, a, o, { onlyAdminCanShareMovie: s }, c), this._debug.debug("Api.startConversation", p), m = "startConversation";
10816
- Mo(p, m), this._setConversationParams(p), this._stats.lifecycle.bindConversationId(p.id);
10927
+ Lo(p, m), this._setConversationParams(p), this._stats.lifecycle.bindConversationId(p.id);
10817
10928
  let ee = await this._connectSignaling(br.START, p);
10818
10929
  return this._setConversation(p, ee, n), this._stats.lifecycle.markCallStarted(), ee;
10819
10930
  }
@@ -10838,9 +10949,9 @@ var fc = 15, $ = class e extends b {
10838
10949
  joinLink: i,
10839
10950
  isVideo: c,
10840
10951
  internalParams: this._buildInternalParams()
10841
- }, this._abortController?.signal), !e) throw dc(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-response-empty");
10842
- if (!e.internalCallerParams) throw dc(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-empty", JSON.stringify(e));
10843
- if (!e.conversationId) throw dc(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-conversation-id-empty", JSON.stringify(e));
10952
+ }, this._abortController?.signal), !e) throw _c(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-response-empty");
10953
+ if (!e.internalCallerParams) throw _c(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-empty", JSON.stringify(e));
10954
+ if (!e.conversationId) throw _c(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-conversation-id-empty", JSON.stringify(e));
10844
10955
  } catch (e) {
10845
10956
  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) });
10846
10957
  }
@@ -10858,7 +10969,7 @@ var fc = 15, $ = class e extends b {
10858
10969
  token: new URL(t.endpoint).searchParams.get("token") ?? ""
10859
10970
  }, this._debug.debug("FastJoin", l), u = "fastJoin";
10860
10971
  } catch (e) {
10861
- throw e instanceof k ? e : dc(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-invalid");
10972
+ throw e instanceof k ? e : _c(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-invalid");
10862
10973
  }
10863
10974
  } else if (t) l = await this._api.joinConversation(t, c, r), u = "joinConversation";
10864
10975
  else if (i) l = await this._api.joinConversationByLink(i, c, a, o), u = "joinConversationByLink";
@@ -10867,13 +10978,13 @@ var fc = 15, $ = class e extends b {
10867
10978
  code: "join",
10868
10979
  description: "target-missing"
10869
10980
  } });
10870
- if (this._debug.debug("Api.joinConversation", l), l.id && this._stats.lifecycle.bindConversationId(l.id), Mo(l, u), l.id) {
10981
+ if (this._debug.debug("Api.joinConversation", l), l.id && this._stats.lifecycle.bindConversationId(l.id), Lo(l, u), l.id) {
10871
10982
  if (B.has(l.id)) throw new k(O.HAS_ACTIVE_CALL);
10872
10983
  B.reserve(l.id), this._reservedId = l.id;
10873
10984
  }
10874
10985
  this._setConversationParams(l);
10875
10986
  let d = await this._connectSignaling(br.JOIN, l);
10876
- return this._setConversation(l, d, to.JOINING), this._stats.lifecycle.markCallStarted(), d;
10987
+ return this._setConversation(l, d, oo.JOINING), this._stats.lifecycle.markCallStarted(), d;
10877
10988
  }
10878
10989
  async _prepareConversation(e, t = j.USER, n, r, i) {
10879
10990
  G.setMark(U.SIGNALING_CONNECTED), this._debug.debug("Conversation: push", {
@@ -10935,7 +11046,7 @@ var fc = 15, $ = class e extends b {
10935
11046
  }), l.wt_endpoint = c);
10936
11047
  }
10937
11048
  let u = await this._connectSignaling(br.ACCEPT, l);
10938
- 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);
11049
+ 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);
10939
11050
  }
10940
11051
  _createParticipant(e, t, n = !0) {
10941
11052
  let r = Object.assign({
@@ -10962,7 +11073,7 @@ var fc = 15, $ = class e extends b {
10962
11073
  let e = this._getParticipantId(t ?? r.id);
10963
11074
  e && (r.externalId = e);
10964
11075
  }
10965
- 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;
11076
+ 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;
10966
11077
  }
10967
11078
  _getParticipantId(e) {
10968
11079
  let t = this._api.userId(e);
@@ -11041,40 +11152,15 @@ var fc = 15, $ = class e extends b {
11041
11152
  }
11042
11153
  _createMediaSource() {
11043
11154
  let e = new Yt(this._debug, this._stats.logger);
11044
- 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;
11155
+ 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;
11045
11156
  }
11046
11157
  async _connectSignaling(e, t) {
11047
11158
  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));
11048
- try {
11049
- let n = await this._signaling.connect(e, t);
11050
- return this._stats.statAggregator.logEventualStatSinceMark({ name: U.SIGNALING_CONNECTED }), n;
11051
- } catch (n) {
11052
- if (this._isInvalidTokenError(n) && !this._invalidTokenRetried && t.id && (this._invalidTokenRetried = !0, this._debug.debug("[conversation] invalid-token error, refreshing token and retrying"), await this._refreshSignalingEndpoint(t))) {
11053
- this._signaling.setEndpoint(t.endpoint), this._signaling.setWebTransportEndpoint(t.wt_endpoint ? t.wt_endpoint : null);
11054
- let n = await this._signaling.connect(e, t);
11055
- return this._stats.statAggregator.logEventualStatSinceMark({ name: U.SIGNALING_CONNECTED }), n;
11056
- }
11057
- throw n;
11058
- }
11059
- }
11060
- _isInvalidTokenError(e) {
11061
- return e instanceof k && e.callError?.scope === "server" && e.callError?.description === "invalid-token";
11062
- }
11063
- async _refreshSignalingEndpoint(e) {
11064
- try {
11065
- await this._getConversationParams(e.id);
11066
- let t = new URL(e.endpoint);
11067
- if (t.searchParams.set("token", N.wssToken), e.endpoint = t.toString(), e.wt_endpoint) {
11068
- let t = new URL(e.wt_endpoint);
11069
- t.searchParams.set("token", N.wssToken), e.wt_endpoint = t.toString();
11070
- }
11071
- return !0;
11072
- } catch (e) {
11073
- return this._debug.warn("[conversation] failed to refresh signaling endpoint", e), !1;
11074
- }
11159
+ let n = await this._signaling.connect(e, t);
11160
+ return this._stats.statAggregator.logEventualStatSinceMark({ name: U.SIGNALING_CONNECTED }), n;
11075
11161
  }
11076
11162
  async _processConnection(e) {
11077
- 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);
11163
+ 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);
11078
11164
  }
11079
11165
  _onConversationParticipantListChunk(e) {
11080
11166
  let t = e.participants;
@@ -11143,7 +11229,7 @@ var fc = 15, $ = class e extends b {
11143
11229
  _registerParticipantLocalMuteState({ muteStates: e, unmuteOptions: t }) {
11144
11230
  if (!e) return;
11145
11231
  let n = async () => {
11146
- let n = bo(e, co.MUTE), r = bo(e, co.MUTE_PERMANENT);
11232
+ let n = To(e, mo.MUTE), r = To(e, mo.MUTE_PERMANENT);
11147
11233
  for (let i of [n, r]) i.length && await this._onMuteParticipant({
11148
11234
  muteStates: e,
11149
11235
  unmuteOptions: t,
@@ -11157,8 +11243,8 @@ var fc = 15, $ = class e extends b {
11157
11243
  if (!(!N.enableSessionStateUpdates || this._isMe(e))) return t;
11158
11244
  }
11159
11245
  _buildConnectionStatus(e, t, n, r = !1) {
11160
- return go.create({
11161
- transport: r ? P.ONHOLD : go.fromTransportState(n) ?? P.WAITING,
11246
+ return xo.create({
11247
+ transport: r ? P.ONHOLD : xo.fromTransportState(n) ?? P.WAITING,
11162
11248
  sessionState: this._remoteParticipantSessionState(e, t),
11163
11249
  sessionStateApplicable: this._isParticipantSessionStateApplicable(e)
11164
11250
  });
@@ -11167,12 +11253,12 @@ var fc = 15, $ = class e extends b {
11167
11253
  return N.enableSessionStateUpdates && !this._isMe(e) && this._conversation?.topology === J.SERVER;
11168
11254
  }
11169
11255
  _setTransportStatus(e, t) {
11170
- return go.setTransport(e.connectionStatus, t);
11256
+ return xo.setTransport(e.connectionStatus, t);
11171
11257
  }
11172
11258
  _setSessionState(e, t) {
11173
- let n = go.setSessionStateApplicable(e.connectionStatus, this._isParticipantSessionStateApplicable(e.id));
11259
+ let n = xo.setSessionStateApplicable(e.connectionStatus, this._isParticipantSessionStateApplicable(e.id));
11174
11260
  this._emitParticipantTransition(e, n);
11175
- let r = e.connectionStatus.sessionStateApplicable && e.id === this._activeSpeakerId && e.connectionStatus.transport === P.CONNECTED, i = go.setSessionState(e.connectionStatus, t, r);
11261
+ let r = e.connectionStatus.sessionStateApplicable && e.id === this._activeSpeakerId && e.connectionStatus.transport === P.CONNECTED, i = xo.setSessionState(e.connectionStatus, t, r);
11176
11262
  return this._emitParticipantTransition(e, i), i;
11177
11263
  }
11178
11264
  _emitParticipantTransition(e, t, n = null) {
@@ -11243,11 +11329,11 @@ var fc = 15, $ = class e extends b {
11243
11329
  this._onRoomSwitched(t, !0);
11244
11330
  }
11245
11331
  _processMuteStates(e, t = !1) {
11246
- let n = xo(e);
11332
+ let n = Eo(e);
11247
11333
  this._setMuteStatesForRoomId(n, null);
11248
11334
  for (let t of e.rooms?.rooms ?? []) this._setMuteStatesForRoomId(t.muteStates, t.id);
11249
11335
  let r = this._getMuteStatesForCurrentRoom();
11250
- t && (r = To(e, r));
11336
+ t && (r = Ao(e, r));
11251
11337
  let i = Object.keys(r), a = this._conversation?.roomId;
11252
11338
  i.length && this._onMuteParticipant({
11253
11339
  muteStates: r,
@@ -11267,15 +11353,15 @@ var fc = 15, $ = class e extends b {
11267
11353
  }
11268
11354
  _allocateTransport() {
11269
11355
  if (!this._conversation || !this._mediaSource) return;
11270
- 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));
11271
- let e = this._conversation.direction === to.OUTGOING && !this._conversation.concurrent, t = this._participants;
11356
+ 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));
11357
+ let e = this._conversation.direction === oo.OUTGOING && !this._conversation.concurrent, t = this._participants;
11272
11358
  for (let n of Object.values(t)) (n.state === X.ACCEPTED || n.state === X.CALLED) && this._allocateParticipantTransport(n.id, e);
11273
11359
  }
11274
11360
  _createSpeakerDetector() {
11275
- 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));
11361
+ 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));
11276
11362
  }
11277
11363
  _createSpecListener() {
11278
- this._transport && this._volumesDetector && (this._specListener = new Yo(this._transport, this._volumesDetector, this._participants, this._debug, this._stats.logger));
11364
+ this._transport && this._volumesDetector && (this._specListener = new es(this._transport, this._volumesDetector, this._participants, this._debug, this._stats.logger));
11279
11365
  }
11280
11366
  _logDevices() {
11281
11367
  let e = E.getCameras().length, t = E.getMicrophones().length;
@@ -11295,7 +11381,7 @@ var fc = 15, $ = class e extends b {
11295
11381
  }
11296
11382
  }
11297
11383
  _cleanupListeners() {
11298
- this.unsubscribe(), window.removeEventListener("pagehide", this._onUnload), window.removeEventListener("pageshow", this._onRestore);
11384
+ this.unsubscribe(), window.removeEventListener("pagehide", this._onUnload), window.removeEventListener("pageshow", this._onRestore), document.removeEventListener("visibilitychange", this._onVisibilityChange);
11299
11385
  }
11300
11386
  _cleanupMediaSource() {
11301
11387
  this._mediaSource && (this._mediaSource.destroy(), this._mediaSource = null);
@@ -11374,7 +11460,7 @@ var fc = 15, $ = class e extends b {
11374
11460
  _onRemoveParticipant(e) {
11375
11461
  this._debug.debug(`Remove participant [${e}]`);
11376
11462
  let t = [], n = this._participants;
11377
- for (let r = 0; r <= fc; r++) {
11463
+ for (let r = 0; r <= vc; r++) {
11378
11464
  let i = n[M.compose(e, r)];
11379
11465
  i && t.push(i);
11380
11466
  }
@@ -11464,11 +11550,11 @@ var fc = 15, $ = class e extends b {
11464
11550
  this._waitingHallHoldPending = !1, await this._resumeLocalMedia(t, this._getWaitingForPromotionStatus()), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener();
11465
11551
  return;
11466
11552
  }
11467
- let n = Na.get();
11553
+ let n = Ra.get();
11468
11554
  await this._signaling.hold(!1, n), this._restoreStateAfterHold();
11469
11555
  let r = null;
11470
11556
  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") {
11471
- let e = this._conversation?.direction === to.OUTGOING && !this._conversation.concurrent;
11557
+ let e = this._conversation?.direction === oo.OUTGOING && !this._conversation.concurrent;
11472
11558
  this._openTransport(r ?? Object.values(this._participants), e);
11473
11559
  }
11474
11560
  }
@@ -11591,13 +11677,13 @@ var fc = 15, $ = class e extends b {
11591
11677
  let n = Fn(e), a = i[n.participantId];
11592
11678
  if (a) {
11593
11679
  let e;
11594
- typeof t == "number" ? e = fo(t) : (this._debug.warn(`Unexpected error code ${t} received for participant ${n.participantId}`), e = uo.UNKNOWN_ERROR), r.push({
11680
+ typeof t == "number" ? e = _o(t) : (this._debug.warn(`Unexpected error code ${t} received for participant ${n.participantId}`), e = go.UNKNOWN_ERROR), r.push({
11595
11681
  externalId: a.externalId,
11596
11682
  errorReason: e
11597
11683
  });
11598
11684
  }
11599
11685
  }
11600
- 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);
11686
+ 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);
11601
11687
  }
11602
11688
  async _cleanupCooldownQueue() {
11603
11689
  let e = {}, t = this._cooldownTimestampByStreamDescription.entries();
@@ -11605,7 +11691,7 @@ var fc = 15, $ = class e extends b {
11605
11691
  let n = t.next();
11606
11692
  if (n.done) break;
11607
11693
  let r = n.value;
11608
- if (r[1] + uc > Date.now()) break;
11694
+ if (r[1] + gc > Date.now()) break;
11609
11695
  let i = r[0];
11610
11696
  await this._stopStreaming(i), e[i] = { stopStream: !0 };
11611
11697
  } while (!0);
@@ -11809,10 +11895,10 @@ var fc = 15, $ = class e extends b {
11809
11895
  throw Error("transport is not initialized");
11810
11896
  }
11811
11897
  _isCallAdmin() {
11812
- return this._conversation ? M.includesOneOf(this._conversation.roles, [po.ADMIN, po.CREATOR]) : !1;
11898
+ return this._conversation ? M.includesOneOf(this._conversation.roles, [vo.ADMIN, vo.CREATOR]) : !1;
11813
11899
  }
11814
11900
  _checkAdminRole() {
11815
- if (this._conversation && !M.includesOneOf(this._conversation.roles, [po.ADMIN, po.CREATOR])) throw Error("You don't have the required permission");
11901
+ if (this._conversation && !M.includesOneOf(this._conversation.roles, [vo.ADMIN, vo.CREATOR])) throw Error("You don't have the required permission");
11816
11902
  }
11817
11903
  _isCalledState() {
11818
11904
  return this._participantState === X.CALLED;
@@ -11850,21 +11936,21 @@ var fc = 15, $ = class e extends b {
11850
11936
  async changeOptions(e) {
11851
11937
  if (this._signaling.ready && this._conversation) {
11852
11938
  this._checkAdminRole(), await this._signaling.changeOptions(e);
11853
- let t = so(this._conversation.options, e);
11939
+ let t = po(this._conversation.options, e);
11854
11940
  this._onOptionsChanged(t);
11855
11941
  }
11856
11942
  }
11857
11943
  async getWaitingHall(e, t, n) {
11858
11944
  if (!this._signaling) return Promise.reject();
11859
11945
  let r = null;
11860
- if (e && (r = yo(e), r)) {
11946
+ if (e && (r = wo(e), r)) {
11861
11947
  let e = this._api.getDecorativeIdByInitialId(r.id);
11862
11948
  r.id = e ?? r.id;
11863
11949
  }
11864
11950
  let i = await this._signaling.getWaitingHall(r, t, n);
11865
11951
  if (i.error) return Promise.reject(i.message);
11866
11952
  let a = i.participants || [], { externalIds: o } = this._resolveWaitingHallExternalIds(a, "getWaitingHall"), s = null;
11867
- return a.length && i.hasMore && (s = vo(a[a.length - 1].id)), {
11953
+ return a.length && i.hasMore && (s = Co(a[a.length - 1].id)), {
11868
11954
  participants: o,
11869
11955
  pageMarker: s,
11870
11956
  totalCount: i.totalCount || 0
@@ -11898,7 +11984,7 @@ var fc = 15, $ = class e extends b {
11898
11984
  }
11899
11985
  async promoteParticipant(e, t) {
11900
11986
  if (this._signaling && this._conversation) try {
11901
- 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");
11987
+ 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");
11902
11988
  if (this._checkAdminRole(), !e && t) throw Error("participantId is required");
11903
11989
  await this._signaling.promoteParticipant(e, t);
11904
11990
  } catch (t) {
@@ -12070,7 +12156,7 @@ var fc = 15, $ = class e extends b {
12070
12156
  let a = this._transport?.getState();
12071
12157
  return n.participants.forEach((e) => {
12072
12158
  let t = M.composeId(e), n = r[t];
12073
- 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);
12159
+ 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);
12074
12160
  }), this._participantListChunkToExternalChunk(n);
12075
12161
  }
12076
12162
  async _getInitialParticiapntListChunk() {
@@ -12084,7 +12170,7 @@ var fc = 15, $ = class e extends b {
12084
12170
  _onLocalMediaStreamChanged(e) {
12085
12171
  if (!this._conversation || !this._mediaSource) return;
12086
12172
  let t = this._mediaSource.mediaSettings;
12087
- 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);
12173
+ 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);
12088
12174
  }
12089
12175
  _onScreenSharingStatus(e) {
12090
12176
  let t = this.mediaSettings;
@@ -12214,9 +12300,9 @@ var fc = 15, $ = class e extends b {
12214
12300
  for (let n of e.conversation.participants) {
12215
12301
  let e = M.composeId(n), i = n.roles || [];
12216
12302
  if (this._isMe(e)) {
12217
- mo(this._conversation.roles, i) || this._onRolesChanged(e, i), t = () => {
12303
+ yo(this._conversation.roles, i) || this._onRolesChanged(e, i), t = () => {
12218
12304
  this._registerParticipantLocalMuteState({
12219
- muteStates: wo(n),
12305
+ muteStates: ko(n),
12220
12306
  unmuteOptions: n.unmuteOptions
12221
12307
  });
12222
12308
  };
@@ -12234,7 +12320,7 @@ var fc = 15, $ = class e extends b {
12234
12320
  let t = D(n.mediaSettings);
12235
12321
  Wt(t, a.mediaSettings) || this._changeRemoteMediaSettings(e, t);
12236
12322
  let r = M.mapParticipantState(n), o = a.participantState;
12237
- 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));
12323
+ 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));
12238
12324
  }
12239
12325
  }
12240
12326
  let i = this._participants;
@@ -12259,7 +12345,7 @@ var fc = 15, $ = class e extends b {
12259
12345
  this._close(new k(O.ANOTHER_DEVICE), { errorText: "Call accepted on other device" });
12260
12346
  return;
12261
12347
  }
12262
- this._conversation?.direction === to.OUTGOING && !this._conversation.concurrent && this._stats.lifecycle.markOutgoingAccepted();
12348
+ this._conversation?.direction === oo.OUTGOING && !this._conversation.concurrent && this._stats.lifecycle.markOutgoingAccepted();
12263
12349
  let r = this._getParticipant(t);
12264
12350
  if (!r) {
12265
12351
  let n = this._api.getDecorativeIdByInitialId(t);
@@ -12272,7 +12358,7 @@ var fc = 15, $ = class e extends b {
12272
12358
  let t = Z.fromSignaling(e.externalId, e.deviceIdx);
12273
12359
  r.externalId = t, this._api.cacheExternalId(r.id, t);
12274
12360
  }
12275
- 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);
12361
+ 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);
12276
12362
  let i = Object.keys(r.muteStates);
12277
12363
  if (i.length && this._onMuteParticipant({
12278
12364
  muteStates: r.muteStates,
@@ -12284,7 +12370,7 @@ var fc = 15, $ = class e extends b {
12284
12370
  this._reportMissingExternalIds([t], "ACCEPTED_CALL");
12285
12371
  return;
12286
12372
  }
12287
- R.onAcceptedCall(r.externalId, Fa.parseCapabilities(e.capabilities), this.id);
12373
+ R.onAcceptedCall(r.externalId, Ba.parseCapabilities(e.capabilities), this.id);
12288
12374
  }
12289
12375
  }
12290
12376
  async _onHungup(e) {
@@ -12321,7 +12407,7 @@ var fc = 15, $ = class e extends b {
12321
12407
  return;
12322
12408
  }
12323
12409
  if (e.connected) {
12324
- let e = go.fromTransportState(this._transport?.getState());
12410
+ let e = xo.fromTransportState(this._transport?.getState());
12325
12411
  e && this._setTransportStatus(n, e);
12326
12412
  }
12327
12413
  this._setSessionState(n, { connected: e.connected });
@@ -12398,7 +12484,7 @@ var fc = 15, $ = class e extends b {
12398
12484
  isOnHold: !!r.onHold
12399
12485
  }, i), n = this._getParticipant(t);
12400
12486
  }
12401
- 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);
12487
+ 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);
12402
12488
  let i = Object.keys(n.muteStates);
12403
12489
  i.length && this._onMuteParticipant({
12404
12490
  muteStates: n.muteStates,
@@ -12589,15 +12675,15 @@ var fc = 15, $ = class e extends b {
12589
12675
  R.onAsrTranscription(t, e.text, e.timestamp, e.duration, this.id);
12590
12676
  }
12591
12677
  async _onRolesChanged(e, t) {
12592
- if (this._conversation && this._isMe(e) && !mo(this._conversation.roles, t)) {
12678
+ if (this._conversation && this._isMe(e) && !yo(this._conversation.roles, t)) {
12593
12679
  this._debug.debug(`Local roles changed: ${t}`), this._conversation.roles = t, R.onLocalRolesChanged(t, !1, this.id), this._processMuteState({
12594
- mediaOptions: bo(this._getMuteStatesForCurrentRoom(), co.MUTE_PERMANENT),
12680
+ mediaOptions: To(this._getMuteStatesForCurrentRoom(), mo.MUTE_PERMANENT),
12595
12681
  stateUpdated: !0
12596
- }), M.includesOneOf(t, [po.ADMIN, po.CREATOR]) ? this._refreshRooms(!0) : t.length || this._onRoomSwitched(null);
12682
+ }), M.includesOneOf(t, [vo.ADMIN, vo.CREATOR]) ? this._refreshRooms(!0) : t.length || this._onRoomSwitched(null);
12597
12683
  return;
12598
12684
  }
12599
12685
  let n = this._getParticipant(e);
12600
- 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));
12686
+ 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));
12601
12687
  }
12602
12688
  async _onMuteParticipant(e, t = !1) {
12603
12689
  if (!this._conversation) return;
@@ -12646,7 +12732,7 @@ var fc = 15, $ = class e extends b {
12646
12732
  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);
12647
12733
  for (let [e, i] of d) {
12648
12734
  let a = this._isCallAdmin() && n;
12649
- 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) {
12735
+ 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) {
12650
12736
  case S.VIDEO:
12651
12737
  u.isVideoEnabled && (R.onDeviceSwitched(S.VIDEO, !1, this.id), await this.toggleLocalVideo(!1));
12652
12738
  break;
@@ -12683,7 +12769,7 @@ var fc = 15, $ = class e extends b {
12683
12769
  this._conversation.pinnedParticipantIdByRoom.set(r, t ? null : e);
12684
12770
  }
12685
12771
  _onOptionsChanged(e) {
12686
- 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));
12772
+ 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));
12687
12773
  }
12688
12774
  async _onNetworkStatus(e) {
12689
12775
  if (this._conversation) {
@@ -12693,7 +12779,7 @@ var fc = 15, $ = class e extends b {
12693
12779
  if (this._isMe(r) || r === "") e = this._conversation.networkRating;
12694
12780
  else if (n[r]) e = n[r].networkRating;
12695
12781
  else continue;
12696
- if (e !== i) if (this._isMe(r) || r === "") this._conversation.networkRating = i, ui.getInstance().value = i, R.onLocalNetworkStatusChanged(i, this.id);
12782
+ if (e !== i) if (this._isMe(r) || r === "") this._conversation.networkRating = i, mi.getInstance().value = i, R.onLocalNetworkStatusChanged(i, this.id);
12697
12783
  else {
12698
12784
  let e = n[r];
12699
12785
  e.networkRating = i, t.push({
@@ -12738,7 +12824,7 @@ var fc = 15, $ = class e extends b {
12738
12824
  }
12739
12825
  _changeFeatureSet() {
12740
12826
  if (this._conversation) {
12741
- let e = this._state === "ACTIVE", t = this._conversation.features.includes(io.ADD_PARTICIPANT);
12827
+ let e = this._state === "ACTIVE", t = this._conversation.features.includes(lo.ADD_PARTICIPANT);
12742
12828
  R.onCallState(e, t, this._conversation, this.id);
12743
12829
  }
12744
12830
  }
@@ -12772,7 +12858,7 @@ var fc = 15, $ = class e extends b {
12772
12858
  let n = this._getParticipant(e);
12773
12859
  if (n) {
12774
12860
  if (n.connectionStatus.sessionStateApplicable && n.connectionStatus.sessionState?.connected === !1) {
12775
- let e = go.fromTransportState(this._transport?.getState());
12861
+ let e = xo.fromTransportState(this._transport?.getState());
12776
12862
  e && this._setTransportStatus(n, e), n.connectionStatus.sessionStateConnectedBySpeaker = !0;
12777
12863
  let t = this._setTransportStatus(n, n.connectionStatus.transport);
12778
12864
  this._emitParticipantTransition(n, t);
@@ -12782,7 +12868,7 @@ var fc = 15, $ = class e extends b {
12782
12868
  }
12783
12869
  async _onTransportStateChanged(e, t) {
12784
12870
  this._debug.debug(`Transport state has changed: ${t}`, e);
12785
- let n = go.fromTransportState(t);
12871
+ let n = xo.fromTransportState(t);
12786
12872
  if (!n) return;
12787
12873
  let r = this._participants, i = [], a = e.reduce((e, n) => {
12788
12874
  if (n in r) {
@@ -12816,9 +12902,9 @@ var fc = 15, $ = class e extends b {
12816
12902
  return e.every((e) => t[e]?.isOnHold);
12817
12903
  }
12818
12904
  _onRemoteTrackAdded(e, t, n) {
12819
- if (e.endsWith(oi.AUDIO_MIX)) this._debug.debug("Remote audio mix track added"), this._audioOutput.add(e, n), R.onRemoteMixedAudioStream(t, this.id);
12820
- else if (e.startsWith(oi.TRANSPARENT_AUDIO_TRACK_PREFIX)) this._debug.debug(`Remote transparent audio track added: ${e}`), this._audioOutput.add(e, n);
12821
- else if (e.startsWith(oi.PARTICIPANT_AGNOSTIC_TRACK_PREFIX)) this._debug.debug(`Participant-agnostic track added: ${e}`), this._streamByStreamId.set(e, t);
12905
+ if (e.endsWith(ui.AUDIO_MIX)) this._debug.debug("Remote audio mix track added"), this._audioOutput.add(e, n), R.onRemoteMixedAudioStream(t, this.id);
12906
+ else if (e.startsWith(ui.TRANSPARENT_AUDIO_TRACK_PREFIX)) this._debug.debug(`Remote transparent audio track added: ${e}`), this._audioOutput.add(e, n);
12907
+ else if (e.startsWith(ui.PARTICIPANT_AGNOSTIC_TRACK_PREFIX)) this._debug.debug(`Participant-agnostic track added: ${e}`), this._streamByStreamId.set(e, t);
12822
12908
  else {
12823
12909
  this._debug.debug(`Remote track added on the participant [${e}]`, { kind: n.kind });
12824
12910
  let r = this._getParticipant(e);
@@ -12845,7 +12931,7 @@ var fc = 15, $ = class e extends b {
12845
12931
  }
12846
12932
  }
12847
12933
  async _removeAudioTrack(e, t, n) {
12848
- if (e !== oi.AUDIO_MIX) {
12934
+ if (e !== ui.AUDIO_MIX) {
12849
12935
  let n = this._getParticipant(e);
12850
12936
  if (!n || n.remoteStream && n.remoteStream !== t) return;
12851
12937
  }
@@ -12860,7 +12946,7 @@ var fc = 15, $ = class e extends b {
12860
12946
  if (this._statFirstMediaReceived.markTopologyChanged(e), e === J.DIRECT && (this._onRemoteSignalledStall([]), this._onAudioMixStall(!1)), this._conversation) {
12861
12947
  this._conversation.topology = e;
12862
12948
  for (let e of Object.values(this._participants)) {
12863
- let t = go.setSessionStateApplicable(e.connectionStatus, this._isParticipantSessionStateApplicable(e.id));
12949
+ let t = xo.setSessionStateApplicable(e.connectionStatus, this._isParticipantSessionStateApplicable(e.id));
12864
12950
  this._emitParticipantTransition(e, t);
12865
12951
  }
12866
12952
  this._changeFeatureSet(), this._forceOpenTransportForAloneInCall();
@@ -12916,7 +13002,7 @@ var fc = 15, $ = class e extends b {
12916
13002
  ].includes(t) ? null : this._setTransportStatus(e, t), n);
12917
13003
  }
12918
13004
  _setParticipantsStalled(e, t) {
12919
- this._updateParticipantsStatus(e, (e) => go.setStalled(e.connectionStatus, t));
13005
+ this._updateParticipantsStatus(e, (e) => xo.setStalled(e.connectionStatus, t));
12920
13006
  }
12921
13007
  _updateParticipantsStatus(e, t, n = null) {
12922
13008
  let r = e.reduce((e, n) => {
@@ -12935,7 +13021,7 @@ var fc = 15, $ = class e extends b {
12935
13021
  _onRoomsUpdated(e) {
12936
13022
  if (this._isCalledState()) return;
12937
13023
  let t = {}, n = [], r = [];
12938
- for (let i of Object.keys(lo)) {
13024
+ for (let i of Object.keys(ho)) {
12939
13025
  let a = e.updates[i];
12940
13026
  a && (a?.rooms?.forEach((e) => {
12941
13027
  let { room: t, missingParticipantIds: i } = this._convertRoomToExternal(e);
@@ -12950,7 +13036,7 @@ var fc = 15, $ = class e extends b {
12950
13036
  }
12951
13037
  _onRoomUpdated(e) {
12952
13038
  let { room: t, missingParticipantIds: n } = this._convertRoomToExternal(e.room || null);
12953
- 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));
13039
+ 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));
12954
13040
  }
12955
13041
  _convertRoomToExternal(e) {
12956
13042
  if (!e) return {
@@ -13061,7 +13147,7 @@ var fc = 15, $ = class e extends b {
13061
13147
  n && r.push(n);
13062
13148
  }
13063
13149
  }
13064
- r.length && !this._isCalledState() && R.onRoomsUpdated({ [lo.UPDATE]: { rooms: r } }, this.id);
13150
+ r.length && !this._isCalledState() && R.onRoomsUpdated({ [ho.UPDATE]: { rooms: r } }, this.id);
13065
13151
  }
13066
13152
  _onFeedback(e) {
13067
13153
  let t = [];
@@ -13137,11 +13223,11 @@ var fc = 15, $ = class e extends b {
13137
13223
  _getParticipant(e) {
13138
13224
  return this._participants[e];
13139
13225
  }
13140
- }, pc = null, mc = class e extends Error {
13226
+ }, yc = null, bc = class e extends Error {
13141
13227
  constructor(t, n) {
13142
13228
  super(t), h(this, "participantErrors", void 0), Object.setPrototypeOf(this, e.prototype), this.participantErrors = n;
13143
13229
  }
13144
- }, hc = class {
13230
+ }, xc = class {
13145
13231
  constructor() {
13146
13232
  h(this, "_abortSignal", void 0), h(this, "_apiCallStats", null);
13147
13233
  }
@@ -13186,14 +13272,14 @@ var fc = 15, $ = class e extends b {
13186
13272
  async getInbounds() {
13187
13273
  return [];
13188
13274
  }
13189
- }, gc = class e {
13275
+ }, Sc = class e {
13190
13276
  constructor() {
13191
13277
  h(this, "_participantIdToExternalId", /* @__PURE__ */ new Map()), h(this, "_externalIdToParticipantId", /* @__PURE__ */ new Map()), h(this, "_decorativeIdToInitialId", /* @__PURE__ */ new Map()), h(this, "_initialIdToDecorativeId", /* @__PURE__ */ new Map());
13192
13278
  }
13193
13279
  static _normalizeType(e) {
13194
- return e.type === _o.GROUP ? {
13280
+ return e.type === So.GROUP ? {
13195
13281
  ...e,
13196
- type: _o.USER
13282
+ type: So.USER
13197
13283
  } : e;
13198
13284
  }
13199
13285
  getExternalId(e) {
@@ -13221,27 +13307,27 @@ var fc = 15, $ = class e extends b {
13221
13307
  clear() {
13222
13308
  this._participantIdToExternalId.clear(), this._externalIdToParticipantId.clear(), this._decorativeIdToInitialId.clear(), this._initialIdToDecorativeId.clear();
13223
13309
  }
13224
- }, _c = "anonymLogin:", vc = 700, yc = 3e3;
13225
- function bc(e) {
13310
+ }, Cc = "anonymLogin:", wc = 700, Tc = 3e3;
13311
+ function Ec(e) {
13226
13312
  let t = e.error_code;
13227
13313
  switch (t) {
13228
- case 2: return xc(O.SERVICE_UNAVAILABLE, t, "service-unavailable");
13229
- 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");
13230
- case 300: return xc(O.NOT_FOUND, t, "not-found");
13231
- case 1101: return xc(O.SERVICE_DISABLED, t, "vchat-service-disabled");
13232
- case 1102: return xc(O.CALLEE_IS_OFFLINE, t, "target-user-unavailable");
13233
- case 1103: return xc(O.NOT_FRIENDS, t, "friendship-required");
13234
- case 1104: return Cc(t, "youla-api-error");
13235
- case 1106: return Cc(t, "vk-api-error");
13236
- case 1113: return xc(O.CALLER_IS_REJECTED, t, "caller-is-rejected");
13314
+ case 2: return Dc(O.SERVICE_UNAVAILABLE, t, "service-unavailable");
13315
+ 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");
13316
+ case 300: return Dc(O.NOT_FOUND, t, "not-found");
13317
+ case 1101: return Dc(O.SERVICE_DISABLED, t, "vchat-service-disabled");
13318
+ case 1102: return Dc(O.CALLEE_IS_OFFLINE, t, "target-user-unavailable");
13319
+ case 1103: return Dc(O.NOT_FRIENDS, t, "friendship-required");
13320
+ case 1104: return kc(t, "youla-api-error");
13321
+ case 1106: return kc(t, "vk-api-error");
13322
+ case 1113: return Dc(O.CALLER_IS_REJECTED, t, "caller-is-rejected");
13237
13323
  case 1114: {
13238
13324
  let n = e.custom_error?.vchat_detailed_api_error?.code, r = n?.startsWith("obsolete_client");
13239
- return xc(r ? O.OBSOLETE_CLIENT : O.VCHAT_DETAILED_ERROR, t, n ?? "detailed-error", r ? n : void 0);
13325
+ return Dc(r ? O.OBSOLETE_CLIENT : O.VCHAT_DETAILED_ERROR, t, n ?? "detailed-error", r ? n : void 0);
13240
13326
  }
13241
- default: return xc(x.API, t, "api-error");
13327
+ default: return Dc(x.API, t, "api-error");
13242
13328
  }
13243
13329
  }
13244
- function xc(e, t, n, r) {
13330
+ function Dc(e, t, n, r) {
13245
13331
  return {
13246
13332
  type: e,
13247
13333
  callError: {
@@ -13253,10 +13339,10 @@ function xc(e, t, n, r) {
13253
13339
  message: r
13254
13340
  };
13255
13341
  }
13256
- function Sc(e) {
13342
+ function Oc(e) {
13257
13343
  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);
13258
13344
  }
13259
- function Cc(e, t) {
13345
+ function kc(e, t) {
13260
13346
  return {
13261
13347
  type: O.EXTERNAL_API_ERROR,
13262
13348
  callError: {
@@ -13267,21 +13353,21 @@ function Cc(e, t) {
13267
13353
  }
13268
13354
  };
13269
13355
  }
13270
- var wc = class extends hc {
13356
+ var Ac = class extends xc {
13271
13357
  constructor(...e) {
13272
- super(...e), h(this, "_uuid", void 0), h(this, "_idCache", new gc());
13358
+ super(...e), h(this, "_uuid", void 0), h(this, "_idCache", new Sc());
13273
13359
  }
13274
13360
  async _callUnsafe(e, t = {}, n = !1) {
13275
13361
  let r = async (i) => {
13276
13362
  let a = performance.now();
13277
13363
  try {
13278
- let r = await hs(e, t, n);
13364
+ let r = await bs(e, t, n);
13279
13365
  return this._apiCallStats?.log(e, performance.now() - a), r;
13280
13366
  } catch (t) {
13281
- if (this._apiCallStats?.log(e, performance.now() - a, Sc(t)), !t || typeof t != "object" || !Object.hasOwn(t, "error_msg")) {
13367
+ if (this._apiCallStats?.log(e, performance.now() - a, Oc(t)), !t || typeof t != "object" || !Object.hasOwn(t, "error_msg")) {
13282
13368
  i++;
13283
13369
  let n = t && (typeof t == "object" || typeof t == "function") ? Object.getOwnPropertyNames(t).map((e) => `${e}: ${JSON.stringify(t[e])}`) : [String(t)];
13284
- 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);
13370
+ 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);
13285
13371
  }
13286
13372
  throw z.warn(e, "error", t), t;
13287
13373
  }
@@ -13293,13 +13379,13 @@ var wc = class extends hc {
13293
13379
  return await this._callUnsafe(e, t, n);
13294
13380
  } catch (i) {
13295
13381
  if (z.warn("Api call error", i), i instanceof k) throw i;
13296
- if (Zo(i?.error_code) && r) return await this._reauthorize(), this._call(e, t, n, !1);
13382
+ if (ns(i?.error_code) && r) return await this._reauthorize(), this._call(e, t, n, !1);
13297
13383
  let a = {
13298
13384
  message: i?.error_msg,
13299
13385
  code: i?.error_code
13300
13386
  };
13301
- if (i.custom_error && (a.custom_error = i.custom_error), Tc(i)) {
13302
- let e = bc(i);
13387
+ if (i.custom_error && (a.custom_error = i.custom_error), jc(i)) {
13388
+ let e = Ec(i);
13303
13389
  throw a.callError = e.callError, a.message = e.message ?? a.message, new k(e.type, a);
13304
13390
  }
13305
13391
  throw new k(x.API, a);
@@ -13329,7 +13415,7 @@ var wc = class extends hc {
13329
13415
  return this._anonymLogin(N.authToken).then((e) => {
13330
13416
  this._applyAnonymLogin(e), this._setCachedAnonymLogin(e);
13331
13417
  }).catch((e) => {
13332
- throw e instanceof k ? e : (e?.error_code === Xo.AUTH_LOGIN && (this._removeCachedAnonymLogin(), R.onTokenExpired()), new k(x.AUTH, {
13418
+ throw e instanceof k ? e : (e?.error_code === ts.AUTH_LOGIN && (this._removeCachedAnonymLogin(), R.onTokenExpired()), new k(x.AUTH, {
13333
13419
  message: e?.error_msg,
13334
13420
  code: e?.error_code,
13335
13421
  callError: {
@@ -13351,17 +13437,17 @@ var wc = class extends hc {
13351
13437
  return e && (t.session_data.auth_token = e, t.session_data.version = 3), this._callUnsafe("auth.anonymLogin", t, !0);
13352
13438
  }
13353
13439
  _getAnonymLoginCacheKey() {
13354
- return N.authToken ? `${_c}${N.authToken}` : null;
13440
+ return N.authToken ? `${Cc}${N.authToken}` : null;
13355
13441
  }
13356
13442
  _getCachedAnonymLogin() {
13357
13443
  let e = this._getAnonymLoginCacheKey();
13358
13444
  if (!e) return null;
13359
13445
  let t = w.get(e);
13360
- return Ec(t) ? t : (t && w.remove(e), null);
13446
+ return Mc(t) ? t : (t && w.remove(e), null);
13361
13447
  }
13362
13448
  _setCachedAnonymLogin(e) {
13363
13449
  let t = this._getAnonymLoginCacheKey();
13364
- !t || !Ec(e) || w.set(t, {
13450
+ !t || !Mc(e) || w.set(t, {
13365
13451
  session_key: e.session_key,
13366
13452
  session_secret_key: e.session_secret_key,
13367
13453
  uid: e.uid
@@ -13375,9 +13461,9 @@ var wc = class extends hc {
13375
13461
  return this._removeCachedAnonymLogin(), y.reauthorize(() => this.authorize());
13376
13462
  }
13377
13463
  _applyAnonymLogin(e) {
13378
- 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), {
13464
+ 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), {
13379
13465
  sessionKey: e.session_key,
13380
- endpoint: Cs.currentEndpoint()
13466
+ endpoint: Os.currentEndpoint()
13381
13467
  });
13382
13468
  }
13383
13469
  _buildClientStatsData(e) {
@@ -13396,7 +13482,7 @@ var wc = class extends hc {
13396
13482
  });
13397
13483
  }
13398
13484
  async _sendClientStatsWith(e, t) {
13399
- let n = await hs("vchat.clientStats", {
13485
+ let n = await bs("vchat.clientStats", {
13400
13486
  ...t,
13401
13487
  session_key: e
13402
13488
  }, !0);
@@ -13404,10 +13490,10 @@ var wc = class extends hc {
13404
13490
  }
13405
13491
  async _sendClientStats(e, t, n = !0) {
13406
13492
  try {
13407
- let n = t ? await gs("vchat.clientStats", e) : await hs("vchat.clientStats", e);
13493
+ let n = t ? await xs("vchat.clientStats", e) : await bs("vchat.clientStats", e);
13408
13494
  this._reportClientStatsItemErrors(n);
13409
13495
  } catch (r) {
13410
- if (!n || !Zo(r?.error_code)) throw r;
13496
+ if (!n || !ns(r?.error_code)) throw r;
13411
13497
  await this._reauthorize(), await this._sendClientStats(e, t, !1);
13412
13498
  }
13413
13499
  }
@@ -13431,14 +13517,14 @@ var wc = class extends hc {
13431
13517
  }, a = await this._callUnsafe("vchat.getLogUploadUrl", i), o = new FormData(), s = new Blob([r], { type: "application/json" });
13432
13518
  o.append("file", s, "log.json");
13433
13519
  let c = new URL(a.upload_url);
13434
- return c.searchParams.append("size", s.size.toString()), ys(c.toString(), o);
13520
+ return c.searchParams.append("size", s.size.toString()), ws(c.toString(), o);
13435
13521
  }
13436
13522
  async joinConversation(e, t = !1, n) {
13437
13523
  let r = {
13438
13524
  conversationId: e,
13439
13525
  isVideo: t,
13440
13526
  protocolVersion: N.protocolVersion,
13441
- capabilities: Fa.getFlags()
13527
+ capabilities: Ba.getFlags()
13442
13528
  };
13443
13529
  return n && (r.chatId = n), this._call("vchat.joinConversation", r);
13444
13530
  }
@@ -13470,13 +13556,13 @@ var wc = class extends hc {
13470
13556
  externalIds: l
13471
13557
  });
13472
13558
  if (t && t.length) switch (n) {
13473
- case no.USER:
13559
+ case so.USER:
13474
13560
  u.uids = t.join(",");
13475
13561
  break;
13476
- case no.GROUP:
13562
+ case so.GROUP:
13477
13563
  u.gid = t[0];
13478
13564
  break;
13479
- case no.CHAT:
13565
+ case so.CHAT:
13480
13566
  u.chatId = t[0];
13481
13567
  break;
13482
13568
  }
@@ -13519,7 +13605,7 @@ var wc = class extends hc {
13519
13605
  joinLink: e,
13520
13606
  isVideo: t,
13521
13607
  protocolVersion: N.protocolVersion,
13522
- capabilities: Fa.getFlags()
13608
+ capabilities: Ba.getFlags()
13523
13609
  };
13524
13610
  return n?.length && (i.observedIds = n.join(",")), N.anonymToken && (i.anonymToken = N.anonymToken), r && (i.payload = r), this._call("vchat.joinConversationByLink", i);
13525
13611
  }
@@ -13549,9 +13635,9 @@ var wc = class extends hc {
13549
13635
  return y.userId;
13550
13636
  }
13551
13637
  setUserId(e) {
13552
- y.userId = e, N.statQueueEnabled && y.sessionKey && Cs.remember(Number(e), {
13638
+ y.userId = e, N.statQueueEnabled && y.sessionKey && Os.remember(Number(e), {
13553
13639
  sessionKey: y.sessionKey,
13554
- endpoint: Cs.currentEndpoint()
13640
+ endpoint: Os.currentEndpoint()
13555
13641
  });
13556
13642
  }
13557
13643
  hangupConversation(e, t = O.HUNGUP, n) {
@@ -13559,7 +13645,7 @@ var wc = class extends hc {
13559
13645
  conversationId: e,
13560
13646
  reason: t
13561
13647
  };
13562
- N.anonymToken && (r.anonymToken = N.anonymToken), n?.peerId && (r.peerId = n.peerId), ms("vchat.hangupConversation", r);
13648
+ N.anonymToken && (r.anonymToken = N.anonymToken), n?.peerId && (r.peerId = n.peerId), ys("vchat.hangupConversation", r);
13563
13649
  }
13564
13650
  async removeHistoryRecords(e) {
13565
13651
  await this._call("vchat.removeHistoryRecords", { recordIds: e.join(",") });
@@ -13575,19 +13661,19 @@ var wc = class extends hc {
13575
13661
  return Array.isArray(e?.inbounds) ? e.inbounds : [];
13576
13662
  }
13577
13663
  };
13578
- function Tc(e) {
13664
+ function jc(e) {
13579
13665
  return typeof e == "object" && !!e && "error_code" in e && "error_msg" in e;
13580
13666
  }
13581
- function Ec(e) {
13667
+ function Mc(e) {
13582
13668
  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;
13583
13669
  }
13584
13670
  //#endregion
13585
13671
  //#region src/enums/RecordRole.ts
13586
- var Dc = /* @__PURE__ */ function(e) {
13672
+ var Nc = /* @__PURE__ */ function(e) {
13587
13673
  return e.KING = "KING", e.PAWN = "PAWN", e;
13588
- }(Dc || {}), Oc = /* @__PURE__ */ function(e) {
13674
+ }(Nc || {}), Pc = /* @__PURE__ */ function(e) {
13589
13675
  return e.OFF = "0", e.ON = "1", e;
13590
- }({}), kc = class {
13676
+ }({}), Fc = class {
13591
13677
  constructor(e) {
13592
13678
  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;
13593
13679
  }
@@ -13610,12 +13696,12 @@ var Dc = /* @__PURE__ */ function(e) {
13610
13696
  let e = this._queue[this._readCursor];
13611
13697
  return e && (this._moveReadCursor = !1, this._queue[this._readCursor] = null, this._readCursor = this.nextCursor(this._readCursor), --this._left), e;
13612
13698
  }
13613
- }, Ac = class {
13699
+ }, Ic = class {
13614
13700
  constructor(e, t, n, r = null) {
13615
13701
  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;
13616
13702
  }
13617
13703
  async authorize() {
13618
- let e = await hs("auth.anonymLogin", {
13704
+ let e = await bs("auth.anonymLogin", {
13619
13705
  session_data: {
13620
13706
  device_id: this._uuid,
13621
13707
  client_version: N.apiClientVersion,
@@ -13624,7 +13710,7 @@ var Dc = /* @__PURE__ */ function(e) {
13624
13710
  version: 3
13625
13711
  },
13626
13712
  application_key: this._apiKey
13627
- }, !0, await fs(this._baseApiUrl, this._apiEnv));
13713
+ }, !0, await _s(this._baseApiUrl, this._apiEnv));
13628
13714
  return M.isObject(e) && !("error_msg" in e) ? (this._sessionKey = e.session_key, !0) : !1;
13629
13715
  }
13630
13716
  async hangupConversation(e, t) {
@@ -13634,9 +13720,9 @@ var Dc = /* @__PURE__ */ function(e) {
13634
13720
  application_key: this._apiKey,
13635
13721
  session_key: this._sessionKey
13636
13722
  };
13637
- t?.peerId && (n.peerId = t.peerId), await hs("vchat.hangupConversation", n, !0, await fs(this._baseApiUrl, this._apiEnv));
13723
+ t?.peerId && (n.peerId = t.peerId), await bs("vchat.hangupConversation", n, !0, await _s(this._baseApiUrl, this._apiEnv));
13638
13724
  }
13639
- }, jc, Mc = null, Nc = !1, Pc = {
13725
+ }, Lc, Rc = null, zc = !1, Bc = {
13640
13726
  getCameras: E.getCameras,
13641
13727
  getMicrophones: E.getMicrophones,
13642
13728
  getOutput: E.getOutput,
@@ -13662,27 +13748,27 @@ var Dc = /* @__PURE__ */ function(e) {
13662
13748
  baseChromeVersion: E.baseChromeVersion,
13663
13749
  getAudioContext: E.getAudioContext,
13664
13750
  isAudioShareSupported: E.isAudioShareSupported
13665
- }, Fc = { participantMarkerCompare: M.participantMarkerCompare };
13666
- function Ic(e) {
13667
- Mc = e;
13751
+ }, Vc = { participantMarkerCompare: M.participantMarkerCompare };
13752
+ function Hc(e) {
13753
+ Rc = e;
13668
13754
  }
13669
- function Lc(e) {
13755
+ function Uc(e) {
13670
13756
  N.videoEffects = e;
13671
13757
  }
13672
- function Rc(e) {
13758
+ function Wc(e) {
13673
13759
  N.audioEffects = e;
13674
13760
  }
13675
- function zc(e, t = {}) {
13761
+ function Gc(e, t = {}) {
13676
13762
  N.vad = e, N.vadOptions = t;
13677
13763
  }
13678
- function Bc(e, t = null, n = {}, r = 1) {
13764
+ function Kc(e, t = null, n = {}, r = 1) {
13679
13765
  N.vmoji = e, N.vmojiOptions = {
13680
13766
  protocolVersion: r,
13681
13767
  renderingOptions: n
13682
13768
  }, t && e.setSDK(t);
13683
13769
  }
13684
- async function Vc(t) {
13685
- 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();
13770
+ async function qc(t) {
13771
+ 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();
13686
13772
  let n = E.getBrowserSupportFailure();
13687
13773
  if (n) throw new k(x.UNSUPPORTED, { callError: {
13688
13774
  scope: "internal",
@@ -13691,19 +13777,19 @@ async function Vc(t) {
13691
13777
  } });
13692
13778
  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}`);
13693
13779
  }
13694
- async function Hc(e, t = [S.AUDIO], n = "", r = !1, i = !1, a, o, s) {
13780
+ async function Jc(e, t = [S.AUDIO], n = "", r = !1, i = !1, a, o, s) {
13695
13781
  let c = [];
13696
- return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), Wc([], no.USER, t, n, r, i, a, c, o, s);
13782
+ return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), Xc([], so.USER, t, n, r, i, a, c, o, s);
13697
13783
  }
13698
- function Uc(e, t = []) {
13784
+ function Yc(e, t = []) {
13699
13785
  let n = e.getIncomingCallerExternalId();
13700
13786
  return n ? t.length === 1 && t[0].id === n.id && t[0].type === n.type : !1;
13701
13787
  }
13702
- async function Wc(e, t = no.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
13788
+ async function Xc(e, t = so.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
13703
13789
  if (!N.hold && B.getActive()) throw z.error("There is already active call"), new k(O.HAS_ACTIVE_CALL);
13704
13790
  let u = B.getAll().find((e) => e.isIncomingRinging);
13705
- if (!N.hold && u && !Uc(u, s)) throw z.error("There is already incoming call"), new k(O.HAS_ACTIVE_CALL);
13706
- return new $(new wc(), Mc).onStart({
13791
+ if (!N.hold && u && !Yc(u, s)) throw z.error("There is already incoming call"), new k(O.HAS_ACTIVE_CALL);
13792
+ return new $(new Ac(), Rc).onStart({
13707
13793
  opponentIds: e,
13708
13794
  opponentType: t,
13709
13795
  mediaOptions: n,
@@ -13716,49 +13802,49 @@ async function Wc(e, t = no.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
13716
13802
  conversationId: l
13717
13803
  });
13718
13804
  }
13719
- async function Gc(e, t) {
13720
- return Kc(e, j.USER, void 0, t);
13805
+ async function Zc(e, t) {
13806
+ return Qc(e, j.USER, void 0, t);
13721
13807
  }
13722
- async function Kc(e, t = j.USER, n, r, i, a) {
13808
+ async function Qc(e, t = j.USER, n, r, i, a) {
13723
13809
  if (e === $.id()) throw Error("Push has already been processed");
13724
- return new $(new wc(), Mc).onPush(e, t, n, r, i, a);
13810
+ return new $(new Ac(), Rc).onPush(e, t, n, r, i, a);
13725
13811
  }
13726
- async function qc() {
13727
- return jc.getInbounds();
13812
+ async function $c() {
13813
+ return Lc.getInbounds();
13728
13814
  }
13729
- function Jc() {
13815
+ function el() {
13730
13816
  if (N.statQueueEnabled) {
13731
- if (!jc) {
13817
+ if (!Lc) {
13732
13818
  z.error("[CallsSDK] startStats() called before init()");
13733
13819
  return;
13734
13820
  }
13735
- Nc || (Nc = !0, Fs.start(jc));
13821
+ zc || (zc = !0, Bs.start(Lc));
13736
13822
  }
13737
13823
  }
13738
- async function Yc(e, t) {
13739
- return e && (N.authToken = e), t !== void 0 && N.apiBaseUrl !== t && (N.apiBaseUrl = t, us()), jc.authorize();
13824
+ async function tl(e, t) {
13825
+ return e && (N.authToken = e), t !== void 0 && N.apiBaseUrl !== t && (N.apiBaseUrl = t, hs()), Lc.authorize();
13740
13826
  }
13741
- async function Xc(e = [S.AUDIO], t) {
13742
- return xu(t).accept(e);
13827
+ async function nl(e = [S.AUDIO], t) {
13828
+ return Du(t).accept(e);
13743
13829
  }
13744
- async function Zc(e) {
13745
- let t = vu(e?.conversationId);
13830
+ async function rl(e) {
13831
+ let t = wu(e?.conversationId);
13746
13832
  if (t) return t.decline(e);
13747
13833
  }
13748
- async function Qc(e, t = [S.AUDIO]) {
13749
- return $c(e, t);
13834
+ async function il(e, t = [S.AUDIO]) {
13835
+ return al(e, t);
13750
13836
  }
13751
- async function $c(e, t, n) {
13837
+ async function al(e, t, n) {
13752
13838
  if (!N.hold && B.callsLength > 0) throw z.error("There is already active call"), new k(O.HAS_ACTIVE_CALL);
13753
- return new $(new wc(), Mc).onJoin({
13839
+ return new $(new Ac(), Rc).onJoin({
13754
13840
  conversationId: e,
13755
13841
  mediaOptions: t,
13756
13842
  chatId: n
13757
13843
  });
13758
13844
  }
13759
- async function el(e, t = [S.AUDIO], n, r, i, a) {
13845
+ async function ol(e, t = [S.AUDIO], n, r, i, a) {
13760
13846
  if (!N.hold && B.callsLength > 0) throw z.error("There is already active call"), new k(O.HAS_ACTIVE_CALL);
13761
- return n && (N.anonymToken = n), new $(new wc(), Mc).onJoin({
13847
+ return n && (N.anonymToken = n), new $(new Ac(), Rc).onJoin({
13762
13848
  joinLink: e,
13763
13849
  mediaOptions: t,
13764
13850
  observedIds: r,
@@ -13767,30 +13853,30 @@ async function el(e, t = [S.AUDIO], n, r, i, a) {
13767
13853
  anonymous: !!N.anonymToken
13768
13854
  });
13769
13855
  }
13770
- function tl(e) {
13771
- let t = vu(e?.conversationId);
13856
+ function sl(e) {
13857
+ let t = wu(e?.conversationId);
13772
13858
  return t ? t.hangup(e) : ($.hangupAfterInit(e?.onFastHangup), Promise.resolve());
13773
13859
  }
13774
- async function nl(e, t) {
13860
+ async function cl(e, t) {
13775
13861
  let n = Array.isArray(e) ? e : [e], r = $.current();
13776
13862
  r && await r.addParticipant(n, t);
13777
13863
  }
13778
- async function rl(e, t) {
13864
+ async function ll(e, t) {
13779
13865
  let n = $.current();
13780
13866
  if (n) {
13781
13867
  let r = e.map((e) => M.composeUserId(e));
13782
13868
  await n.addParticipantLegacy(r, t);
13783
13869
  }
13784
13870
  }
13785
- async function il(e, t = !1) {
13786
- let n = Su(e, "removeParticipant");
13871
+ async function ul(e, t = !1) {
13872
+ let n = Ou(e, "removeParticipant");
13787
13873
  if (n) try {
13788
13874
  await n.conversation.removeParticipant(M.decomposeParticipantId(n.participantId).compositeUserId, t);
13789
13875
  } catch (e) {
13790
13876
  z.warn(`Failed to remove participant ${n.participantId}. Perhaps he is no longer on the call. ${e}`);
13791
13877
  }
13792
13878
  }
13793
- async function al(e, t = !1) {
13879
+ async function dl(e, t = !1) {
13794
13880
  let n = $.current();
13795
13881
  if (n) try {
13796
13882
  await n.removeParticipant(M.composeUserId(e), t);
@@ -13798,13 +13884,13 @@ async function al(e, t = !1) {
13798
13884
  z.warn(`Failed to remove participant ${e}. Perhaps he is no longer on the call. ${t}`);
13799
13885
  }
13800
13886
  }
13801
- async function ol(e, t) {
13887
+ async function fl(e, t) {
13802
13888
  let n = $.current();
13803
13889
  if (e === "videoinput" && jt.contains(t)) return N.videoFacingMode = t, n ? (E.isMobile() && n.stopVideoTrack(), n.changeDevice(e)) : void 0;
13804
13890
  if (!await E._saveDeviceId(e, t)) throw Error(`Device not found: ${t}`);
13805
13891
  if (n) return n.changeDevice(e);
13806
13892
  }
13807
- async function sl(e, t) {
13893
+ async function pl(e, t) {
13808
13894
  let n = typeof e == "object" ? {
13809
13895
  ...e,
13810
13896
  fastScreenSharing: e.captureScreen && e.fastScreenSharing,
@@ -13813,40 +13899,40 @@ async function sl(e, t) {
13813
13899
  captureScreen: e,
13814
13900
  fastScreenSharing: !1,
13815
13901
  captureAudio: !1
13816
- }, r = vu(t);
13902
+ }, r = wu(t);
13817
13903
  return r ? r.toggleScreenCapturing(n) : Promise.reject();
13818
13904
  }
13819
- function cl(e) {
13905
+ function ml(e) {
13820
13906
  let t = $.current();
13821
13907
  t && t.toggleAnimojiCapturing(e);
13822
13908
  }
13823
- async function ll(e, t = !1) {
13909
+ async function hl(e, t = !1) {
13824
13910
  let n = $.current();
13825
13911
  n && await n.setVideoStream(e, t);
13826
13912
  }
13827
- async function ul(e, t) {
13828
- let n = vu(t);
13913
+ async function gl(e, t) {
13914
+ let n = wu(t);
13829
13915
  n && await n.toggleLocalVideo(e);
13830
13916
  }
13831
- async function dl(e, t) {
13832
- let n = vu(t);
13917
+ async function _l(e, t) {
13918
+ let n = wu(t);
13833
13919
  n && await n.toggleLocalAudio(e);
13834
13920
  }
13835
- async function fl(e) {
13921
+ async function vl(e) {
13836
13922
  let t = $.current();
13837
13923
  if (t) return t.setLocalResolution(e);
13838
13924
  }
13839
- async function pl(e) {
13925
+ async function yl(e) {
13840
13926
  let t = $.current();
13841
13927
  t && await t.changePriorities(e);
13842
13928
  }
13843
- async function ml(e, t) {
13929
+ async function bl(e, t) {
13844
13930
  let n = $.current();
13845
13931
  if (n) {
13846
13932
  if (t) {
13847
13933
  let r = n.getCachedParticipantIdByExternalId(t);
13848
13934
  if (!r) {
13849
- yu(t, "changeParticipantState", n);
13935
+ Tu(t, "changeParticipantState", n);
13850
13936
  return;
13851
13937
  }
13852
13938
  await n.changeParticipantState(e, r);
@@ -13855,161 +13941,161 @@ async function ml(e, t) {
13855
13941
  await n.changeParticipantState(e);
13856
13942
  }
13857
13943
  }
13858
- async function hl() {
13944
+ async function xl() {
13859
13945
  let e = $.current();
13860
13946
  e && await e.putHandsDown();
13861
13947
  }
13862
- async function gl(e) {
13948
+ async function Sl(e) {
13863
13949
  let t = $.current();
13864
13950
  t && await t.updateDisplayLayout(e);
13865
13951
  }
13866
- async function _l(e) {
13952
+ async function Cl(e) {
13867
13953
  let t = $.current();
13868
13954
  t && await t.requestDisplayLayout(e);
13869
13955
  }
13870
- async function vl(e, t, n = !1) {
13871
- let r = Su(e, "grantRoles");
13956
+ async function wl(e, t, n = !1) {
13957
+ let r = Ou(e, "grantRoles");
13872
13958
  r && await r.conversation.grantRoles(r.participantId, t, n);
13873
13959
  }
13874
- async function yl(e, t, n, r = !1) {
13960
+ async function Tl(e, t, n, r = !1) {
13875
13961
  let i = $.current();
13876
13962
  i && await i.grantRoles(M.composeParticipantId(e, j.USER, t), n, r);
13877
13963
  }
13878
- async function bl({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
13964
+ async function El({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
13879
13965
  if (e) {
13880
- let i = Su(e, "muteParticipant");
13966
+ let i = Ou(e, "muteParticipant");
13881
13967
  return i ? i.conversation.muteParticipant(i.participantId, t, n, r) : void 0;
13882
13968
  }
13883
13969
  let i = $.current();
13884
13970
  i && await i.muteParticipant(null, t, n, r);
13885
13971
  }
13886
- async function xl({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
13972
+ async function Dl({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
13887
13973
  let a = $.current();
13888
13974
  if (a) {
13889
13975
  let o = e ? M.composeParticipantId(e, j.USER, r) : null;
13890
13976
  await a.muteParticipant(o, t, n, i);
13891
13977
  }
13892
13978
  }
13893
- async function Sl(e, t = !1, n = null) {
13894
- let r = Su(e, "pinParticipant");
13979
+ async function Ol(e, t = !1, n = null) {
13980
+ let r = Ou(e, "pinParticipant");
13895
13981
  r && await r.conversation.pinParticipant(r.participantId, t, n);
13896
13982
  }
13897
- async function Cl(e, t = !1, n = 0, r = null) {
13983
+ async function kl(e, t = !1, n = 0, r = null) {
13898
13984
  let i = $.current();
13899
13985
  i && await i.pinParticipant(M.composeParticipantId(e, j.USER, n), t, r);
13900
13986
  }
13901
- async function wl(e) {
13987
+ async function Al(e) {
13902
13988
  let t = $.current();
13903
13989
  t && await t.updateMediaModifiers(e);
13904
13990
  }
13905
- async function Tl(e) {
13991
+ async function jl(e) {
13906
13992
  let t = $.current();
13907
13993
  t && await t.enableVideoSuspend(e);
13908
13994
  }
13909
- async function El(e) {
13995
+ async function Ml(e) {
13910
13996
  let t = $.current();
13911
13997
  t && await t.enableVideoSuspendSuggest(e);
13912
13998
  }
13913
- async function Dl(e) {
13999
+ async function Nl(e) {
13914
14000
  let t = $.current();
13915
14001
  t && await t.changeOptions(e);
13916
14002
  }
13917
- async function Ol(e, t = null) {
14003
+ async function Pl(e, t = null) {
13918
14004
  if (t) {
13919
- let n = Su(t, "chatMessage");
14005
+ let n = Ou(t, "chatMessage");
13920
14006
  return n ? n.conversation.chatMessage(e, M.decomposeParticipantId(n.participantId).compositeUserId) : void 0;
13921
14007
  }
13922
14008
  let n = $.current();
13923
14009
  n && await n.chatMessage(e, null);
13924
14010
  }
13925
- async function kl(e, t = null) {
14011
+ async function Fl(e, t = null) {
13926
14012
  let n = $.current();
13927
14013
  if (n) {
13928
14014
  let r = t ? M.composeUserId(t) : null;
13929
14015
  await n.chatMessage(e, r);
13930
14016
  }
13931
14017
  }
13932
- async function Al(e = 10) {
14018
+ async function Il(e = 10) {
13933
14019
  let t = $.current();
13934
14020
  if (t) return t.chatHistory(e);
13935
14021
  }
13936
- async function jl(e, t = null) {
14022
+ async function Ll(e, t = null) {
13937
14023
  if (t) {
13938
- let n = Su(t, "customData");
14024
+ let n = Ou(t, "customData");
13939
14025
  return n ? n.conversation.customData(e, n.participantId) : void 0;
13940
14026
  }
13941
14027
  let n = $.current();
13942
14028
  n && await n.customData(e, null);
13943
14029
  }
13944
- async function Ml(e, t = null, n = 0) {
14030
+ async function Rl(e, t = null, n = 0) {
13945
14031
  let r = $.current();
13946
14032
  if (r) {
13947
14033
  let i = t ? M.composeParticipantId(t, j.USER, n) : null;
13948
14034
  await r.customData(e, i);
13949
14035
  }
13950
14036
  }
13951
- async function Nl(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
13952
- return (await jc.createConversation(a ?? M.uuid(), e, t, {
14037
+ async function zl(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
14038
+ return (await Lc.createConversation(a ?? M.uuid(), e, t, {
13953
14039
  onlyAdminCanShareMovie: n,
13954
14040
  waitForAdmin: r,
13955
14041
  closedConversation: i
13956
14042
  })).join_link;
13957
14043
  }
13958
- async function Pl(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
14044
+ async function Bl(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
13959
14045
  let a = i.map((e) => Z.fromId(e));
13960
- return (await jc.createConversation(M.uuid(), e, t, {
14046
+ return (await Lc.createConversation(M.uuid(), e, t, {
13961
14047
  onlyAdminCanShareMovie: n,
13962
14048
  audienceMode: !0,
13963
14049
  audioOnly: r
13964
14050
  }, a)).join_link;
13965
14051
  }
13966
- async function Fl() {
14052
+ async function Vl() {
13967
14053
  let e = $.current();
13968
14054
  return e ? e.createJoinLink() : Promise.reject();
13969
14055
  }
13970
- async function Il() {
14056
+ async function Hl() {
13971
14057
  let e = $.current();
13972
14058
  return e ? e.removeJoinLink() : Promise.reject();
13973
14059
  }
13974
- async function Ll(e, t) {
13975
- return jc.getAnonymTokenByLink(e, t);
14060
+ async function Ul(e, t) {
14061
+ return Lc.getAnonymTokenByLink(e, t);
13976
14062
  }
13977
- function Rl(e) {
14063
+ function Wl(e) {
13978
14064
  let t = $.current();
13979
14065
  t && t.setVolume(e);
13980
14066
  }
13981
- function zl(e) {
14067
+ function Gl(e) {
13982
14068
  N.forceRelayPolicy = e;
13983
14069
  }
13984
- async function Bl(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
14070
+ async function Kl(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
13985
14071
  let o = $.current();
13986
14072
  return o ? o.startStream(e, t, n, r, i, a) : Promise.reject();
13987
14073
  }
13988
- async function Vl(e = null, t) {
14074
+ async function ql(e = null, t) {
13989
14075
  let n = $.current();
13990
14076
  return n ? n.stopStream(e, t) : Promise.reject();
13991
14077
  }
13992
- async function Hl(e = null) {
14078
+ async function Jl(e = null) {
13993
14079
  let t = $.current();
13994
14080
  return t ? t.publishStream(e) : Promise.reject();
13995
14081
  }
13996
- async function Ul() {
14082
+ async function Yl() {
13997
14083
  let e = $.current();
13998
14084
  return e ? e.getStreamInfo() : Promise.reject();
13999
14085
  }
14000
- async function Wl(e) {
14086
+ async function Xl(e) {
14001
14087
  let t = $.current();
14002
14088
  return t ? t.addMovie(e) : Promise.reject();
14003
14089
  }
14004
- async function Gl(e) {
14090
+ async function Zl(e) {
14005
14091
  let t = $.current();
14006
14092
  return t ? t.updateMovie(e) : Promise.reject();
14007
14093
  }
14008
- async function Kl(e) {
14094
+ async function Ql(e) {
14009
14095
  let t = $.current();
14010
14096
  return t ? t.removeMovie(e) : Promise.reject();
14011
14097
  }
14012
- async function ql(e, t) {
14098
+ async function $l(e, t) {
14013
14099
  let n = $.current();
14014
14100
  if (n) {
14015
14101
  let r = [], i = [];
@@ -14031,46 +14117,46 @@ async function ql(e, t) {
14031
14117
  });
14032
14118
  }
14033
14119
  if (i.length) {
14034
- bu(i, "updateRooms", n);
14120
+ Eu(i, "updateRooms", n);
14035
14121
  return;
14036
14122
  }
14037
14123
  return n.updateRooms(r, t);
14038
14124
  }
14039
14125
  return Promise.reject();
14040
14126
  }
14041
- async function Jl(e, t) {
14127
+ async function eu(e, t) {
14042
14128
  let n = $.current();
14043
14129
  return n ? n.activateRooms(e, t) : Promise.reject();
14044
14130
  }
14045
- async function Yl(e = null, t = null) {
14131
+ async function tu(e = null, t = null) {
14046
14132
  let n = $.current();
14047
14133
  if (!n) return Promise.reject();
14048
14134
  let r;
14049
14135
  if (t && (r = n.getCachedParticipantIdByExternalId(t) ?? void 0, !r)) {
14050
- yu(t, "switchRoom", n);
14136
+ Tu(t, "switchRoom", n);
14051
14137
  return;
14052
14138
  }
14053
14139
  return n.switchRoom(e, r);
14054
14140
  }
14055
- async function Xl(e) {
14141
+ async function nu(e) {
14056
14142
  let t = $.current();
14057
14143
  return t ? t.removeRooms(e) : Promise.reject();
14058
14144
  }
14059
- function Zl(e) {
14145
+ function ru(e) {
14060
14146
  N.statisticsInterval = e;
14061
14147
  let t = $.current();
14062
14148
  if (t) return t.updateStatisticsInterval();
14063
14149
  }
14064
- function Ql(t) {
14150
+ function iu(t) {
14065
14151
  e.disableLog(!t), z.toggle(t);
14066
14152
  }
14067
- function $l(e, ...t) {
14153
+ function au(e, ...t) {
14068
14154
  N.debugLog && ($.debugMessage(e, "[external]", ...t) || z.send(e, "[external]", ...t));
14069
14155
  }
14070
- function eu(e, t, ...n) {
14156
+ function ou(e, t, ...n) {
14071
14157
  N.debugLog && ($.debugMessageWithContext(e, t, "[external]", ...n) || z.send(e, "[external]", ...n));
14072
14158
  }
14073
- var tu = {
14159
+ var su = {
14074
14160
  list: Ne,
14075
14161
  get: Pe,
14076
14162
  getJson: Fe,
@@ -14078,7 +14164,7 @@ var tu = {
14078
14164
  clear: Le,
14079
14165
  stats: Re
14080
14166
  };
14081
- function nu() {
14167
+ function cu() {
14082
14168
  let e = [
14083
14169
  [`Calls SDK ${N.sdkVersion}`, N.toJSON()],
14084
14170
  ["UserAgent:", navigator.userAgent],
@@ -14096,139 +14182,139 @@ function nu() {
14096
14182
  d: e
14097
14183
  }));
14098
14184
  }
14099
- async function ru() {
14185
+ async function lu() {
14100
14186
  let e = $.id(), t = $.debugSessionId();
14101
14187
  if (!t || !e) throw z.error("[uploadDebugLogs]", "No conversation id found"), Error("No conversation id found");
14102
14188
  let n = await Pe({ sessionId: t });
14103
14189
  if (n.length === 0) throw z.error("[uploadDebugLogs]", "No logs found"), Error("No logs found");
14104
14190
  let r = n[0].t, i = n[n.length - 1].t;
14105
14191
  try {
14106
- return jc?.uploadDebugLogs(e, r, i, JSON.stringify([...nu(), ...n]));
14192
+ return Lc?.uploadDebugLogs(e, r, i, JSON.stringify([...cu(), ...n]));
14107
14193
  } catch (e) {
14108
14194
  throw z.error("[uploadDebugLogs]", "Error while uploading logs", e), Error("Error while uploading logs", { cause: e });
14109
14195
  }
14110
14196
  }
14111
- async function iu(e) {
14197
+ async function uu(e) {
14112
14198
  let t = $.current();
14113
14199
  if (t) return t.videoEffect(e);
14114
14200
  }
14115
- async function au(e, t) {
14201
+ async function du(e, t) {
14116
14202
  let n = $.current();
14117
14203
  if (n) return n.audioEffect(e.length > 0 ? e : null, t);
14118
14204
  }
14119
- async function ou(e) {
14205
+ async function fu(e) {
14120
14206
  let t = $.current();
14121
14207
  t && await t.setAudioStream(e);
14122
14208
  }
14123
- async function su(e, t = null, n = null) {
14209
+ async function pu(e, t = null, n = null) {
14124
14210
  let r = $.current();
14125
14211
  if (!r) return;
14126
14212
  let i = n ?? t?.id, a = null;
14127
14213
  if (t && (a = r.getCachedParticipantIdByExternalId(t), !a)) {
14128
- yu(t, "setVmojiSvg", r);
14214
+ Tu(t, "setVmojiSvg", r);
14129
14215
  return;
14130
14216
  }
14131
14217
  r.setAnimojiSvg(e, a, i);
14132
14218
  }
14133
- function cu(e) {
14219
+ function mu(e) {
14134
14220
  let t = $.current();
14135
14221
  t && t.setAnimojiFill(e);
14136
14222
  }
14137
- async function lu(e = null, t, n = !1) {
14138
- return xu().getWaitingHall(e, t, n);
14223
+ async function hu(e = null, t, n = !1) {
14224
+ return Du().getWaitingHall(e, t, n);
14139
14225
  }
14140
- async function uu() {
14141
- return xu().getAudienceModeHands();
14226
+ async function gu() {
14227
+ return Du().getAudienceModeHands();
14142
14228
  }
14143
- async function du(e, t = !1) {
14144
- let n = xu(), r;
14229
+ async function _u(e, t = !1) {
14230
+ let n = Du(), r;
14145
14231
  if (e) {
14146
14232
  let t = n.getCachedParticipantIdByExternalId(e);
14147
14233
  if (!t) {
14148
- yu(e, "promoteParticipant", n);
14234
+ Tu(e, "promoteParticipant", n);
14149
14235
  return;
14150
14236
  }
14151
14237
  r = M.decomposeParticipantId(t).compositeUserId;
14152
14238
  }
14153
14239
  return n.promoteParticipant(r, t);
14154
14240
  }
14155
- async function fu(e = !1) {
14156
- return xu().requestPromotion(e);
14241
+ async function vu(e = !1) {
14242
+ return Du().requestPromotion(e);
14157
14243
  }
14158
- async function pu(e = !1) {
14159
- return xu().acceptPromotion(e);
14244
+ async function yu(e = !1) {
14245
+ return Du().acceptPromotion(e);
14160
14246
  }
14161
- async function mu(e) {
14162
- return xu().getParticipantListChunk(e);
14247
+ async function bu(e) {
14248
+ return Du().getParticipantListChunk(e);
14163
14249
  }
14164
- async function hu(e) {
14165
- return xu().getParticipants(e);
14250
+ async function xu(e) {
14251
+ return Du().getParticipants(e);
14166
14252
  }
14167
- async function gu(e) {
14168
- return xu().feedback(e);
14253
+ async function Su(e) {
14254
+ return Du().feedback(e);
14169
14255
  }
14170
- async function _u(e, t, n) {
14171
- return xu(n).enableFeatureForRoles(e, t);
14256
+ async function Cu(e, t, n) {
14257
+ return Du(n).enableFeatureForRoles(e, t);
14172
14258
  }
14173
- function vu(e) {
14259
+ function wu(e) {
14174
14260
  return e ? B.get(e) ?? null : $.current() ?? B.getFirst();
14175
14261
  }
14176
- function yu(e, t, n) {
14262
+ function Tu(e, t, n) {
14177
14263
  R.onNonFatalError(/* @__PURE__ */ Error(`Participant ID mapping not found for external ID "${e.id}" while handling ${t}`), n.id);
14178
14264
  }
14179
- function bu(e, t, n) {
14265
+ function Eu(e, t, n) {
14180
14266
  let r = Array.from(new Set(e));
14181
14267
  R.onNonFatalError(/* @__PURE__ */ Error(`Participant ID mapping not found for external IDs "${r.join("\", \"")}" while handling ${t}`), n.id);
14182
14268
  }
14183
- function xu(e) {
14184
- let t = vu(e);
14269
+ function Du(e) {
14270
+ let t = wu(e);
14185
14271
  if (!t) throw Error("Conversation not found");
14186
14272
  return t;
14187
14273
  }
14188
- function Su(e, t) {
14274
+ function Ou(e, t) {
14189
14275
  let n = $.current();
14190
14276
  if (!n) return null;
14191
14277
  let r = n.getCachedParticipantIdByExternalId(e);
14192
14278
  return r ? {
14193
14279
  conversation: n,
14194
14280
  participantId: r
14195
- } : (yu(e, t, n), null);
14281
+ } : (Tu(e, t, n), null);
14196
14282
  }
14197
- async function Cu(e) {
14198
- await jc.removeHistoryRecords(e);
14283
+ async function ku(e) {
14284
+ await Lc.removeHistoryRecords(e);
14199
14285
  }
14200
- async function wu(e) {
14286
+ async function Au(e) {
14201
14287
  let t = $.current() ?? B.getFirst();
14202
14288
  t && await t.startAsr(e);
14203
14289
  }
14204
- async function Tu(e) {
14290
+ async function ju(e) {
14205
14291
  let t = $.current() ?? B.getFirst();
14206
14292
  t && await t.stopAsr(e);
14207
14293
  }
14208
- async function Eu(e) {
14294
+ async function Mu(e) {
14209
14295
  let t = $.current() ?? B.getFirst();
14210
14296
  t && await t.requestAsr(e);
14211
14297
  }
14212
- async function Du(e) {
14298
+ async function Nu(e) {
14213
14299
  let t = $.current();
14214
14300
  return t ? t.startUrlSharing(e) : Promise.reject();
14215
14301
  }
14216
- async function Ou() {
14302
+ async function Pu() {
14217
14303
  let e = $.current();
14218
14304
  return e ? e.stopUrlSharing() : Promise.reject();
14219
14305
  }
14220
- async function ku(e) {
14306
+ async function Fu(e) {
14221
14307
  await B.switchCall(e);
14222
14308
  }
14223
- function Au() {
14309
+ function Iu() {
14224
14310
  return B.getActiveId();
14225
14311
  }
14226
- function ju() {
14312
+ function Lu() {
14227
14313
  return $.getSyncedTime();
14228
14314
  }
14229
- function Mu() {
14315
+ function Ru() {
14230
14316
  return N.sdkVersion;
14231
14317
  }
14232
14318
  typeof window < "u" && (window.__CALLS_SDK = xn);
14233
14319
  //#endregion
14234
- 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 };
14320
+ 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 };