@vkontakte/calls-sdk 2.8.13-dev.ab19d582.0 → 2.8.13-dev.da97cd25.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.ab19d582.0
3
- * Wed, 09 Sep 2026 14:22:53 GMT
2
+ * @vkontakte/calls-sdk v2.8.13-dev.da97cd25.0
3
+ * Fri, 18 Sep 2026 10:02:42 GMT
4
4
  * https://calls-sdk.cdn-vk.ru/doc/latest/index.html
5
5
  */
6
6
 
@@ -2152,10 +2152,13 @@ var yn = vn.getInstance(), M = class e {
2152
2152
  return "ok.calls.sdk.js";
2153
2153
  }
2154
2154
  static get appVersion() {
2155
+ return e._params.appVersion;
2156
+ }
2157
+ static get apiClientVersion() {
2155
2158
  return 1.1;
2156
2159
  }
2157
2160
  static get sdkVersion() {
2158
- return "2.8.13-dev.ab19d582.0";
2161
+ return "2.8.13-dev.da97cd25.0";
2159
2162
  }
2160
2163
  static get debug() {
2161
2164
  return e._params.debug;
@@ -2410,6 +2413,9 @@ var yn = vn.getInstance(), M = class e {
2410
2413
  static get callStatReportEnabled() {
2411
2414
  return e._params.callStatReportEnabled;
2412
2415
  }
2416
+ static get iceCandidateErrorStatEnabled() {
2417
+ return e._params.iceCandidateErrorStatEnabled;
2418
+ }
2413
2419
  static get enableLogPerfStatReport() {
2414
2420
  return e._params.enableLogPerfStatReport;
2415
2421
  }
@@ -2574,10 +2580,12 @@ var yn = vn.getInstance(), M = class e {
2574
2580
  videoSuspend: e._params.videoSuspend,
2575
2581
  debugLog: e._params.debugLog,
2576
2582
  callStatReportEnabled: e._params.callStatReportEnabled,
2583
+ iceCandidateErrorStatEnabled: e._params.iceCandidateErrorStatEnabled,
2577
2584
  joinFromMultipleDevices: e._params.joinFromMultipleDevices,
2578
2585
  movieShare: e._params.movieShare,
2579
2586
  clientType: e._params.clientType,
2580
2587
  clientStatsPlatform: e._params.clientStatsPlatform,
2588
+ appVersion: e._params.appVersion,
2581
2589
  consumerScreenDataChannelPacketSize: e._params.consumerScreenDataChannelPacketSize,
2582
2590
  switchVideoAtBadNetwork: e._params.switchVideoAtBadNetwork,
2583
2591
  simulcast: e._params.simulcast,
@@ -2593,6 +2601,7 @@ var yn = vn.getInstance(), M = class e {
2593
2601
  h(M, "_params", {
2594
2602
  platform: "WEB",
2595
2603
  clientStatsPlatform: "",
2604
+ appVersion: "0.0.0",
2596
2605
  clientType: "PORTAL",
2597
2606
  externalUserType: "",
2598
2607
  device: "browser",
@@ -2642,6 +2651,7 @@ h(M, "_params", {
2642
2651
  networkStatisticsInterval: 2e4,
2643
2652
  perfStatReportEnabled: !0,
2644
2653
  callStatReportEnabled: !1,
2654
+ iceCandidateErrorStatEnabled: !1,
2645
2655
  enableLogPerfStatReport: !1,
2646
2656
  voiceParams: {
2647
2657
  smoothing: .8,
@@ -3065,6 +3075,10 @@ var xn;
3065
3075
  P("onPeerRegistered", e, t);
3066
3076
  }
3067
3077
  e.onPeerRegistered = ot;
3078
+ function st(e, t) {
3079
+ P("onNonFatalError", e, t);
3080
+ }
3081
+ e.onNonFatalError = st;
3068
3082
  })(xn || (xn = {}));
3069
3083
  var L = xn, Sn = /* @__PURE__ */ function(e) {
3070
3084
  return e.DEBUG = "DEBUG", e.LOG = "LOG", e.WARN = "WARN", e.ERROR = "ERROR", e;
@@ -3581,7 +3595,7 @@ var Rn = 0, zn = 1, Bn = 2, Vn = 3, Hn = 4, Un = 5, Wn = 6, Gn = 7, Kn = 0, qn =
3581
3595
  };
3582
3596
  }
3583
3597
  }, H = /* @__PURE__ */ function(e) {
3584
- return e.CALL_INIT = "call_init", e.CALL_START = "call_start", e.CALL_ACCEPTED_OUTGOING = "call_accepted_outgoing", e.CALL_ACCEPTED_INCOMING = "call_accepted_incoming", e.FIRST_MEDIA_SENT = "first_media_sent", e.CALL_FINISH = "call_finish", e.CODEC_USAGE = "codec_usage", e.SIGNALING_CONNECTED = "signaling_connected", e.SCREENSHARE_FIRST_FRAME = "screen_share_first_frame", e.FIRST_MEDIA_RECEIVED = "first_media_received", e.CALL_DECLINED_OR_HANGED_LOCALLY = "CallDeclinedOrHangedLocally", e.USER_FEEDBACK_RECEIVED = "UserFeedbackReceived", e.SIGNALING_PING_SUMMARY = "signaling_ping_summary", e.SIGNALING_COMMAND_SUMMARY = "signaling_command_summary", e.WEBSOCKET_CONNECTED = "websocket_connected", e.WEBSOCKET_RECONNECTED = "websocket_reconnected", e.WEBSOCKET_FAILED_PINGS = "websocket_failed_pings", e.WEBSOCKET_FAILED_EXCEPTION = "websocket_failed_exception", e.WEBSOCKET_TIMEOUT = "websocket_timeout", e.WEBSOCKET_RESTART = "websocket_restart", e.WEBTRANSPORT_CONNECTED = "webtransport_connected", e.WEBTRANSPORT_RECONNECTED = "webtransport_reconnected", e.WEBTRANSPORT_FAILED_PINGS = "webtransport_failed_pings", e.WEBTRANSPORT_FAILED_EXCEPTION = "webtransport_failed_exception", e.WEBTRANSPORT_TIMEOUT = "webtransport_timeout", e.WEBTRANSPORT_RESTART = "webtransport_restart", e;
3598
+ 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.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.WEBSOCKET_CONNECTED = "websocket_connected", e.WEBSOCKET_RECONNECTED = "websocket_reconnected", e.WEBSOCKET_FAILED_PINGS = "websocket_failed_pings", e.WEBSOCKET_FAILED_EXCEPTION = "websocket_failed_exception", e.WEBSOCKET_TIMEOUT = "websocket_timeout", e.WEBSOCKET_RESTART = "websocket_restart", e.WEBTRANSPORT_CONNECTED = "webtransport_connected", e.WEBTRANSPORT_RECONNECTED = "webtransport_reconnected", e.WEBTRANSPORT_FAILED_PINGS = "webtransport_failed_pings", e.WEBTRANSPORT_FAILED_EXCEPTION = "webtransport_failed_exception", e.WEBTRANSPORT_TIMEOUT = "webtransport_timeout", e.WEBTRANSPORT_RESTART = "webtransport_restart", e;
3585
3599
  }(H || {}), er = 1e3;
3586
3600
  function U(e, t, n = 0) {
3587
3601
  return t in e && e[t] ? e[t] : n;
@@ -3819,14 +3833,83 @@ function kr() {
3819
3833
  };
3820
3834
  }
3821
3835
  //#endregion
3822
- //#region src/classes/stat/FirstMediaSentProbe.ts
3823
- var Ar = 200;
3824
- function jr(e) {
3836
+ //#region src/classes/stat/PeerConnectionStats.ts
3837
+ var Ar = /[?&]transport=(tcp|udp)/i, jr = {
3838
+ stable: "stable",
3839
+ "have-local-offer": "have.local.offer",
3840
+ "have-local-pranswer": "have.local.answer",
3841
+ "have-remote-offer": "have.remote.offer",
3842
+ "have-remote-pranswer": "have.remote.answer",
3843
+ closed: "closed"
3844
+ }, Mr = class {
3845
+ constructor(e) {
3846
+ h(this, "_statAggregator", void 0), h(this, "_pc", null), h(this, "_lastSignalingStateChange", 0), h(this, "_lastGatheringStateChange", 0), h(this, "_handleConnectionStateChange", () => {
3847
+ this._log({
3848
+ name: H.CONNECTION_STATE_CHANGED,
3849
+ value: 0,
3850
+ connection_state: this._pc?.connectionState
3851
+ });
3852
+ }), h(this, "_handleSignalingStateChange", () => {
3853
+ let e = this._pc?.signalingState;
3854
+ this._log({
3855
+ name: H.SIGNALING_STATE_CHANGED,
3856
+ value: this._sinceLastChange("_lastSignalingStateChange"),
3857
+ string_value: e ? jr[e] : void 0
3858
+ });
3859
+ }), h(this, "_handleGatheringStateChange", () => {
3860
+ let e = this._pc?.iceGatheringState, t = this._sinceLastChange("_lastGatheringStateChange");
3861
+ this._log({
3862
+ name: H.GATHERING_STATE_CHANGED,
3863
+ value: e === "new" ? 0 : t,
3864
+ string_value: e
3865
+ });
3866
+ }), h(this, "_handleIceCandidateError", (e) => {
3867
+ if (!M.iceCandidateErrorStatEnabled) return;
3868
+ let t = e;
3869
+ this._log({
3870
+ name: H.ICE_CANDIDATE_GATHERING_FAILED,
3871
+ value: t.errorCode,
3872
+ string_value: t.errorText,
3873
+ local_address: t.address ?? void 0,
3874
+ remote_url: t.url,
3875
+ transport: Ar.exec(t.url ?? "")?.[1]?.toLowerCase()
3876
+ });
3877
+ }), this._statAggregator = e;
3878
+ }
3879
+ observe(e) {
3880
+ this.stop(), this._pc = e, this._lastSignalingStateChange = 0, this._lastGatheringStateChange = 0, e.addEventListener("connectionstatechange", this._handleConnectionStateChange), e.addEventListener("signalingstatechange", this._handleSignalingStateChange), e.addEventListener("icegatheringstatechange", this._handleGatheringStateChange), e.addEventListener("icecandidateerror", this._handleIceCandidateError);
3881
+ }
3882
+ stop() {
3883
+ this._pc && (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);
3884
+ }
3885
+ logIceRestart() {
3886
+ this._log({
3887
+ name: H.ICE_RESTART,
3888
+ value: 0
3889
+ });
3890
+ }
3891
+ logIceCandidateAddFailed(e, t) {
3892
+ this._log({
3893
+ name: H.ICE_CANDIDATE_ADD_FAILED,
3894
+ value: t instanceof DOMException ? t.code : 0,
3895
+ string_value: t instanceof Error ? `${t.name}: ${t.message}` : String(t),
3896
+ remote_url: e.candidate
3897
+ });
3898
+ }
3899
+ _sinceLastChange(e) {
3900
+ let t = Date.now(), n = this[e] === 0 ? 0 : t - this[e];
3901
+ return this[e] = t, n;
3902
+ }
3903
+ _log(e) {
3904
+ this._statAggregator?.logEventualStat(e);
3905
+ }
3906
+ }, Nr = 200;
3907
+ function Pr(e) {
3825
3908
  for (let t of e.values()) if (t.type === "outbound-rtp" && (t.packetsSent ?? 0) > 0) return !0;
3826
3909
  return !1;
3827
3910
  }
3828
- var Mr = class {
3829
- constructor(e, t, n = Ar) {
3911
+ var Fr = class {
3912
+ constructor(e, t, n = Nr) {
3830
3913
  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;
3831
3914
  }
3832
3915
  start() {
@@ -3849,7 +3932,7 @@ var Mr = class {
3849
3932
  try {
3850
3933
  let e = await this._getStatsReports();
3851
3934
  if (this._state !== "polling") return;
3852
- if (e.some(jr)) {
3935
+ if (e.some(Pr)) {
3853
3936
  this._state = "stopped", this._onFirstMediaSent();
3854
3937
  return;
3855
3938
  }
@@ -3862,7 +3945,7 @@ var Mr = class {
3862
3945
  this._timer = null, this._poll();
3863
3946
  }, this._pollIntervalMs));
3864
3947
  }
3865
- }, Nr = class extends b {
3948
+ }, Ir = class extends b {
3866
3949
  constructor(e, t, n = null) {
3867
3950
  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;
3868
3951
  }
@@ -3873,12 +3956,12 @@ var Mr = class {
3873
3956
  this._firstMediaSentProbeStopped = !0, this._disposeFirstMediaSentProbe();
3874
3957
  }
3875
3958
  _startFirstMediaSentProbe() {
3876
- this._disposeFirstMediaSentProbe(), !(!this._pc || !this._onFirstMediaSent || this._firstMediaSentProbeStopped) && (this._firstMediaSentProbe = new Mr(this._pc, this._onFirstMediaSent), this._firstMediaSentProbe.start());
3959
+ this._disposeFirstMediaSentProbe(), !(!this._pc || !this._onFirstMediaSent || this._firstMediaSentProbeStopped) && (this._firstMediaSentProbe = new Fr(this._pc, this._onFirstMediaSent), this._firstMediaSentProbe.start());
3877
3960
  }
3878
3961
  _disposeFirstMediaSentProbe() {
3879
3962
  this._firstMediaSentProbe?.destroy(), this._firstMediaSentProbe = null;
3880
3963
  }
3881
- }, Pr = class {
3964
+ }, Lr = class {
3882
3965
  constructor(e, t = null) {
3883
3966
  h(this, "weightUp", void 0), h(this, "weightDown", void 0), h(this, "value", NaN), this.weightUp = e, this.weightDown = t ?? e;
3884
3967
  }
@@ -3896,7 +3979,7 @@ var Mr = class {
3896
3979
  getValue() {
3897
3980
  return this.value;
3898
3981
  }
3899
- }, Fr = .25, Ir = .35, Lr = 85, Rr = .1, zr = 1.5, Br = .1, Vr = 1, Hr = .6, Ur = .3, Wr = class extends b {
3982
+ }, Rr = .25, zr = .35, Br = 85, Vr = .1, Hr = 1.5, Ur = .1, Wr = 1, Gr = .6, Kr = .3, qr = class extends b {
3900
3983
  constructor(e, t = R) {
3901
3984
  super(), h(this, "_signaling", void 0), h(this, "_localNetworkStat", void 0), h(this, "_remoteNetworkStat", void 0), h(this, "_lastNetworkStat", void 0), h(this, "_networkLimits", {
3902
3985
  badNet: {
@@ -3908,8 +3991,8 @@ var Mr = class {
3908
3991
  rtt: 600
3909
3992
  }
3910
3993
  }), h(this, "_lastStatSentTimestamp", 0), h(this, "_currentState", "good"), h(this, "_debug", void 0), this._debug = t, this._signaling = e, this._localNetworkStat = {
3911
- rtt: new Pr(Fr, Fr),
3912
- loss: new Pr(Ir, Ir),
3994
+ rtt: new Lr(Rr, Rr),
3995
+ loss: new Lr(zr, zr),
3913
3996
  bitrate: 0
3914
3997
  }, this._remoteNetworkStat = {
3915
3998
  rtt: 0,
@@ -3924,20 +4007,20 @@ var Mr = class {
3924
4007
  _calcRttRating(e) {
3925
4008
  let t = typeof e == "number" ? e : e.getValue(), n = 1;
3926
4009
  if (isNaN(t)) return n;
3927
- let r = Math.round((t - this._networkLimits.goodNet.rtt) / Lr);
3928
- for (let e = 0; e < r; e++) n *= 1 - Rr;
4010
+ let r = Math.round((t - this._networkLimits.goodNet.rtt) / Br);
4011
+ for (let e = 0; e < r; e++) n *= 1 - Vr;
3929
4012
  return n;
3930
4013
  }
3931
4014
  _calcLossRating(e) {
3932
4015
  let t = typeof e == "number" ? e : e.getValue(), n = 1;
3933
4016
  if (isNaN(t)) return n;
3934
- let r = Math.round((t - this._networkLimits.goodNet.loss) / zr);
3935
- for (let e = 0; e < r; e++) n *= 1 - Br;
4017
+ let r = Math.round((t - this._networkLimits.goodNet.loss) / Hr);
4018
+ for (let e = 0; e < r; e++) n *= 1 - Ur;
3936
4019
  return n;
3937
4020
  }
3938
4021
  _calcBitrateRating(e, t) {
3939
4022
  if (!e || !t) return 1;
3940
- let n = 1 - (1 - Math.min(e, t) / Math.max(e, t)) * Vr;
4023
+ let n = 1 - (1 - Math.min(e, t) / Math.max(e, t)) * Wr;
3941
4024
  return Math.min(n, 1);
3942
4025
  }
3943
4026
  _calcUDPRating({ rtt: e, loss: t }) {
@@ -3947,7 +4030,7 @@ var Mr = class {
3947
4030
  return n ? this._calcBitrateRating(e.bitrate, t.bitrate) : this._calcUDPRating(e) * this._calcUDPRating(t);
3948
4031
  }
3949
4032
  _getNetworkState(e) {
3950
- return isNaN(e) || e >= Hr ? "good" : e >= Ur ? "medium" : "bad";
4033
+ return isNaN(e) || e >= Gr ? "good" : e >= Kr ? "medium" : "bad";
3951
4034
  }
3952
4035
  updateSettings(e) {
3953
4036
  Object.assign(this._networkLimits.badNet, e?.badNet || {}), Object.assign(this._networkLimits.goodNet, e?.goodNet || {});
@@ -3971,7 +4054,7 @@ var Mr = class {
3971
4054
  let { rtt: t, loss: n, bitrate: r } = e || {};
3972
4055
  this._remoteNetworkStat.rtt = t || 0, this._remoteNetworkStat.loss = n || 0, this._remoteNetworkStat.bitrate = r || 0;
3973
4056
  }
3974
- }, Gr = 30 * 1e3, Kr = class e extends Nr {
4057
+ }, Jr = 30 * 1e3, Yr = class e extends Ir {
3975
4058
  constructor(e, t, n, r, i, a = R, o = null, s = null, c = null, l = null) {
3976
4059
  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", {
3977
4060
  bad: {
@@ -3986,7 +4069,7 @@ var Mr = class {
3986
4069
  worst: 320,
3987
4070
  bad: 640,
3988
4071
  good: 1280
3989
- }), h(this, "_lastVideoMaxDimension", this._videoMaxDimensionsForNet.good), h(this, "_lastBadConnection", 0), h(this, "_perfStatReporter", void 0), h(this, "_directStatReporter", 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 pa(this, n, this._statAggregator, !0, this._debug), this._directStatReporter = new Wr(n, this._debug), this.subscribe(this._signaling, G.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, X.NETWORK_STATUS, this._onNetworkStatus.bind(this));
4072
+ }), h(this, "_lastVideoMaxDimension", this._videoMaxDimensionsForNet.good), h(this, "_lastBadConnection", 0), h(this, "_perfStatReporter", void 0), h(this, "_directStatReporter", 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 ga(this, n, this._statAggregator, !0, this._debug), this._directStatReporter = new qr(n, this._debug), this._peerConnectionStats = new Mr(this._statAggregator), this.subscribe(this._signaling, G.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, X.NETWORK_STATUS, this._onNetworkStatus.bind(this));
3990
4073
  try {
3991
4074
  this._pc = this._createPeerConnection();
3992
4075
  } catch (e) {
@@ -4090,12 +4173,12 @@ var Mr = class {
4090
4173
  iceServers: M.iceServers,
4091
4174
  iceTransportPolicy: M.forceRelayPolicy ? "relay" : "all"
4092
4175
  });
4093
- 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._prevConsumerSettings = {}, M.vmoji && this._createDataChannel(e, Sr.animoji, (e) => {
4176
+ 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._peerConnectionStats.observe(e), this._prevConsumerSettings = {}, M.vmoji && this._createDataChannel(e, Sr.animoji, (e) => {
4094
4177
  this._animojiDataChannel = e, this._animojiDataChannel.binaryType = "arraybuffer", this._animojiReceiver?.setDataChannel(this._animojiDataChannel), this._animojiSender?.setDataChannel(this._animojiDataChannel);
4095
4178
  }), e;
4096
4179
  }
4097
4180
  _disposePeerConnection() {
4098
- if (this._disposeFirstMediaSentProbe(), this._lastStat = null, this._remoteStream) {
4181
+ if (this._disposeFirstMediaSentProbe(), this._peerConnectionStats.stop(), this._lastStat = null, this._remoteStream) {
4099
4182
  let e = this._remoteStream;
4100
4183
  e.getTracks().forEach((t) => {
4101
4184
  t.stop(), this._triggerEvent(X.REMOTE_TRACK_REMOVED, e, t);
@@ -4144,7 +4227,7 @@ var Mr = class {
4144
4227
  try {
4145
4228
  await this._pc.addIceCandidate(new RTCIceCandidate(t));
4146
4229
  } catch (e) {
4147
- throw this._logger?.log(C.ERROR, "addIceCandidate-direct"), this._debug.error("Unable to add remote ice candidate", e, {
4230
+ throw this._logger?.log(C.ERROR, "addIceCandidate-direct"), this._peerConnectionStats.logIceCandidateAddFailed(t, e), this._debug.error("Unable to add remote ice candidate", e, {
4148
4231
  participantId: this._participantId,
4149
4232
  candidate: t
4150
4233
  }), e;
@@ -4263,7 +4346,7 @@ var Mr = class {
4263
4346
  this._reconnectionTimeout && (clearTimeout(this._reconnectionTimeout), this._reconnectionTimeout = null), this._iceRestartTimeout && (clearTimeout(this._iceRestartTimeout), this._iceRestartTimeout = null);
4264
4347
  }
4265
4348
  _startIceRestart() {
4266
- 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(() => {
4349
+ 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(() => {
4267
4350
  this._iceRestartTimeout = null, this._debug.error("Ice restart failed", { participantId: this._participantId }), this._logger?.log(C.ERROR, "iceRestart-direct"), this._requestTopologySwitch();
4268
4351
  }, M.iceRestartWaitTime);
4269
4352
  }
@@ -4385,7 +4468,7 @@ var Mr = class {
4385
4468
  async _checkPPTNetwork(e) {
4386
4469
  if (!M.switchVideoAtBadNetwork || !e.inbound.transport.averageNetStat) return;
4387
4470
  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 = Er.L1T1;
4388
- if (r ? (this._lastBadConnection = Date.now(), i ? (a = this._videoMaxDimensionsForNet.bad, o = Er.L1T2) : (a = this._videoMaxDimensionsForNet.worst, o = Er.L1T3)) : n && (a = this._videoMaxDimensionsForNet.good, o = Er.L1T1), !(a < this._lastVideoMaxDimension || Date.now() - this._lastBadConnection > Gr) || this._lastVideoMaxDimension === a) return;
4471
+ if (r ? (this._lastBadConnection = Date.now(), i ? (a = this._videoMaxDimensionsForNet.bad, o = Er.L1T2) : (a = this._videoMaxDimensionsForNet.worst, o = Er.L1T3)) : n && (a = this._videoMaxDimensionsForNet.good, o = Er.L1T1), !(a < this._lastVideoMaxDimension || Date.now() - this._lastBadConnection > Jr) || this._lastVideoMaxDimension === a) return;
4389
4472
  let s = this._serverSettings.camera;
4390
4473
  if (!s || !await this._isSVCSupported(e, o)) return;
4391
4474
  this._debug.debug("Switch outbound video frame size and scalabilityMode", {
@@ -4450,9 +4533,9 @@ var Mr = class {
4450
4533
  }, n(r)) : this._debug.error(`[${t}] data channel open failed, state [${e}]`);
4451
4534
  };
4452
4535
  }
4453
- }, qr = /* @__PURE__ */ function(e) {
4536
+ }, Xr = /* @__PURE__ */ function(e) {
4454
4537
  return e.AUDIO_MIX = "audio-mix", e.PARTICIPANT_AGNOSTIC_TRACK_PREFIX = "pat", e.TRANSPARENT_AUDIO_TRACK_PREFIX = "ta", e;
4455
- }({}), Jr = 16, Yr = class e {
4538
+ }({}), Zr = 16, Qr = class e {
4456
4539
  constructor(e, t, n, r = R) {
4457
4540
  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);
4458
4541
  }
@@ -4466,7 +4549,7 @@ var Mr = class {
4466
4549
  ssrc: a,
4467
4550
  timestamp: o,
4468
4551
  duration: s,
4469
- data: e.slice(Jr)
4552
+ data: e.slice(Zr)
4470
4553
  };
4471
4554
  }
4472
4555
  _onDataChannelMessage(t) {
@@ -4486,7 +4569,7 @@ var Mr = class {
4486
4569
  destroy() {
4487
4570
  this._datachannel.onmessage = null;
4488
4571
  }
4489
- }, Xr, Zr = class {
4572
+ }, $r, ei = class {
4490
4573
  constructor() {
4491
4574
  h(this, "_value", 1);
4492
4575
  }
@@ -4497,10 +4580,10 @@ var Mr = class {
4497
4580
  this._value = e;
4498
4581
  }
4499
4582
  };
4500
- Xr = Zr, h(Zr, "_instance", null), h(Zr, "getInstance", () => (Xr._instance || (Xr._instance = new Xr()), Xr._instance));
4583
+ $r = ei, h(ei, "_instance", null), h(ei, "getInstance", () => ($r._instance || ($r._instance = new $r()), $r._instance));
4501
4584
  //#endregion
4502
4585
  //#region src/classes/ParticipantIdRegistry.ts
4503
- var Qr = class {
4586
+ var ti = class {
4504
4587
  constructor(e = R) {
4505
4588
  h(this, "streamDescriptionByCompactId", /* @__PURE__ */ new Map()), h(this, "compactIdByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_debug", void 0), this._debug = e;
4506
4589
  }
@@ -4616,7 +4699,7 @@ var Qr = class {
4616
4699
  this._debug.error("unexpected null sequenceNumber", e, r);
4617
4700
  continue;
4618
4701
  }
4619
- let l = qr.PARTICIPANT_AGNOSTIC_TRACK_PREFIX + "-" + e, u = i ? i >>> 0 : null;
4702
+ let l = Xr.PARTICIPANT_AGNOSTIC_TRACK_PREFIX + "-" + e, u = i ? i >>> 0 : null;
4620
4703
  n.push({
4621
4704
  participantStreamDescription: c,
4622
4705
  streamId: l,
@@ -4634,7 +4717,7 @@ var Qr = class {
4634
4717
  }
4635
4718
  }, Y = /* @__PURE__ */ function(e) {
4636
4719
  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;
4637
- }({}), $r = class {
4720
+ }({}), ni = class {
4638
4721
  constructor(e = R, t = null) {
4639
4722
  h(this, "_worker", null), h(this, "_debug", void 0), h(this, "_logger", void 0), this._debug = e, this._logger = t;
4640
4723
  }
@@ -4699,7 +4782,7 @@ var Qr = class {
4699
4782
  static isBrowserSupported() {
4700
4783
  throw Error("Not implemented");
4701
4784
  }
4702
- }, ei = class extends $r {
4785
+ }, ri = class extends ni {
4703
4786
  constructor(e = R, t = null) {
4704
4787
  super(e, t);
4705
4788
  }
@@ -4723,7 +4806,7 @@ var Qr = class {
4723
4806
  static isBrowserSupported() {
4724
4807
  return "WebAssembly" in window && "Worker" in window;
4725
4808
  }
4726
- }, ti = class extends $r {
4809
+ }, ii = class extends ni {
4727
4810
  constructor(e = R, t = null) {
4728
4811
  super(e, t);
4729
4812
  }
@@ -4746,7 +4829,7 @@ var Qr = class {
4746
4829
  static isBrowserSupported() {
4747
4830
  return "VideoDecoder" in window && "Worker" in window && "VideoFrame" in window && !T.isBrokenVP9Decoder() && T.browserName() !== "Firefox";
4748
4831
  }
4749
- }, ni = class {
4832
+ }, ai = class {
4750
4833
  constructor(e = null, t = 0) {
4751
4834
  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));
4752
4835
  }
@@ -4760,7 +4843,7 @@ var Qr = class {
4760
4843
  destroy() {
4761
4844
  window.clearInterval(this._interval), this._interval = 0;
4762
4845
  }
4763
- }, ri = class {
4846
+ }, oi = class {
4764
4847
  constructor(e, t) {
4765
4848
  h(this, "_participantId", void 0), h(this, "_statAggregator", void 0), h(this, "_firstFrameReceived", !1), this._participantId = e, this._statAggregator = t;
4766
4849
  }
@@ -4775,14 +4858,14 @@ var Qr = class {
4775
4858
  height: t
4776
4859
  });
4777
4860
  }
4778
- }, ii = 65536, ai = "MARK_SCREENSHARE_FREEZE_DURATION", oi = class e {
4861
+ }, si = 65536, ci = "MARK_SCREENSHARE_FREEZE_DURATION", li = class e {
4779
4862
  constructor(e, t, n, r, i, a = R) {
4780
- 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 ri(e, r), this._debug = a;
4863
+ 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 oi(e, r), this._debug = a;
4781
4864
  }
4782
4865
  appendChunk(t) {
4783
4866
  let n = this._chunks.length;
4784
4867
  if (t.start) this._measureFreezeDuration(!1), this._measureFreezeDuration(!0), n && (this._debug.warn("[FrameBuilder] Cleanup buffer", Array.prototype.slice.call(this._chunks)), this._chunks = []);
4785
- else if (!n || (this._chunks[n - 1].sequence + 1) % ii !== t.sequence) {
4868
+ else if (!n || (this._chunks[n - 1].sequence + 1) % si !== t.sequence) {
4786
4869
  this._debug.warn("[FrameBuilder] Got incorrect chunk");
4787
4870
  return;
4788
4871
  }
@@ -4799,7 +4882,7 @@ var Qr = class {
4799
4882
  }
4800
4883
  }
4801
4884
  destroy() {
4802
- W.clearMark(ai), W.clearMark(W.getMarkNameScreenshareFirstFrame(this._participantId)), this._chunks = [];
4885
+ W.clearMark(ci), W.clearMark(W.getMarkNameScreenshareFirstFrame(this._participantId)), this._chunks = [];
4803
4886
  }
4804
4887
  _processFrameData() {
4805
4888
  let e = this._chunks;
@@ -4822,13 +4905,13 @@ var Qr = class {
4822
4905
  }
4823
4906
  _measureFreezeDuration(e) {
4824
4907
  if (e) {
4825
- W.setMark(ai);
4908
+ W.setMark(ci);
4826
4909
  return;
4827
4910
  }
4828
- let t = W.measureMark(ai);
4911
+ let t = W.measureMark(ci);
4829
4912
  t !== null && t > 1e3 && this._onStat({ freeze_duration: t });
4830
4913
  }
4831
- }, si = class {
4914
+ }, ui = class {
4832
4915
  constructor(e) {
4833
4916
  h(this, "_onStream", void 0), this._onStream = e;
4834
4917
  }
@@ -4841,7 +4924,7 @@ var Qr = class {
4841
4924
  static isBrowserSupported() {
4842
4925
  throw Error("Method `isBrowserSupported` is not implemented");
4843
4926
  }
4844
- }, ci = class extends si {
4927
+ }, di = class extends ui {
4845
4928
  constructor(e, t = R) {
4846
4929
  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;
4847
4930
  }
@@ -4901,7 +4984,7 @@ var Qr = class {
4901
4984
  static isBrowserSupported() {
4902
4985
  return ("CanvasCaptureMediaStream" in window || "CanvasCaptureMediaStreamTrack" in window) && !(T.browserName() === "Safari" && Number(T.browserVersion()) === 15);
4903
4986
  }
4904
- }, li = class extends si {
4987
+ }, fi = class extends ui {
4905
4988
  constructor(e, t = R) {
4906
4989
  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: k.video }), this._writer = this._generator.writable.getWriter(), this._stream = new MediaStream([this._generator]), this._onStream(this._stream);
4907
4990
  }
@@ -4912,34 +4995,38 @@ var Qr = class {
4912
4995
  this._writer.releaseLock(), this._generator.writable.close().then(() => this._generator.stop()), this._debug.debug("TrackGeneratorRenderer destroyed");
4913
4996
  }
4914
4997
  static isBrowserSupported() {
4915
- return "VideoFrame" in window && "MediaStreamTrackGenerator" in window && ti.isBrowserSupported();
4998
+ return "VideoFrame" in window && "MediaStreamTrackGenerator" in window && ii.isBrowserSupported();
4916
4999
  }
4917
- }, ui = class extends oi {
5000
+ }, pi = class extends li {
4918
5001
  constructor(e, t, n, r, i, a = R, o = null) {
4919
- 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, "_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();
5002
+ 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();
4920
5003
  }
4921
5004
  _processFrame(e) {
4922
5005
  e.keyframe && (this._decoderQueue = []), this._decoderQueue.push(e), this._decodeQueue();
4923
5006
  }
4924
5007
  _initFpsMeter() {
4925
- this._fpsMeter = new ni((e) => this._debug.log(`[StreamBuilder][${this._participantId}] fps: ${e}`), 2e4);
5008
+ this._fpsMeter = new ai((e) => this._debug.log(`[StreamBuilder][${this._participantId}] fps: ${e}`), 2e4);
4926
5009
  }
4927
5010
  _initRenderer(e = !1) {
4928
- e || !li.isBrowserSupported() ? this._renderer = new ci(this._onStream, this._debug) : this._renderer = new li(this._onStream, this._debug);
5011
+ e || !fi.isBrowserSupported() ? this._renderer = new di(this._onStream, this._debug) : this._renderer = new fi(this._onStream, this._debug);
4929
5012
  }
4930
5013
  _initDecoder(e = !1) {
4931
- e || !ti.isBrowserSupported() ? this._decoder = new ei(this._debug, this._logger) : this._decoder = new ti(this._debug, this._logger), this._decoder.init(async (e) => {
5014
+ e || !ii.isBrowserSupported() ? this._decoder = new ri(this._debug, this._logger) : this._decoder = new ii(this._debug, this._logger), this._decoder.init(async (e) => {
4932
5015
  this._decoderBusy = !1, "VideoFrame" in window && e instanceof VideoFrame ? await this._renderer.drawFrame(e) : await this._renderer.drawImage(e), this._fpsMeter.increment(), this._decodeQueue();
4933
5016
  }, (e) => {
4934
- this._decoderBusy = !1, this._decodeQueue(), this._decoder instanceof ti && typeof e == "string" && e.includes("EncodingError") && this._switchToLibVPXDecoder();
5017
+ if (this._decoderBusy = !1, this._decoder instanceof ii && typeof e == "string" && e.includes("EncodingError")) {
5018
+ 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();
5019
+ return;
5020
+ }
5021
+ this._decodeQueue();
4935
5022
  }, this._onKeyFrameRequested).then(() => {
4936
5023
  this._decoderReady = !0, this._decodeQueue();
4937
5024
  }).catch((e) => {
4938
- this._debug.warn("StreamBuilder decoder init failed", e), this._decoder instanceof ti && this._switchToLibVPXDecoder();
5025
+ this._debug.warn("StreamBuilder decoder init failed", e), this._decoder instanceof ii && this._switchToLibVPXDecoder();
4939
5026
  });
4940
5027
  }
4941
5028
  _switchToLibVPXDecoder() {
4942
- this._debug.warn("StreamBuilder switch to LibVPX decoder"), this._fpsMeter && this._fpsMeter.destroy(), this._decoder && (this._decoderReady = !1, this._decoderBusy = !1, this._decoder.destroy()), this._renderer && this._renderer.destroy(), this._initFpsMeter(), this._initRenderer(!0), this._initDecoder(!0);
5029
+ this._debug.warn("StreamBuilder switch to LibVPX decoder"), this._decoderQueue = [], this._fpsMeter && this._fpsMeter.destroy(), this._decoder && (this._decoderReady = !1, this._decoderBusy = !1, this._decoder.destroy()), this._renderer && this._renderer.destroy(), this._initFpsMeter(), this._initRenderer(!0), this._initDecoder(!0), this._onKeyFrameRequested?.();
4943
5030
  }
4944
5031
  _decodeQueue() {
4945
5032
  if (!this._decoderReady || this._decoderBusy) return;
@@ -4950,20 +5037,20 @@ var Qr = class {
4950
5037
  super.destroy(), this._fpsMeter.destroy(), this._decoder.destroy(), this._renderer.destroy(), this._debug.debug(`StreamBuilder destroyed for participant ${this._participantId}`);
4951
5038
  }
4952
5039
  static isBrowserSupported() {
4953
- return ci.isBrowserSupported() || li.isBrowserSupported();
5040
+ return di.isBrowserSupported() || fi.isBrowserSupported();
4954
5041
  }
4955
- }, di = 1, fi = 1, pi = 2, mi = 0, hi = 1, gi = 2, _i = 4, vi = 8;
4956
- function yi(e, t, n, r, i, a, o) {
5042
+ }, mi = 1, hi = 1, gi = 2, _i = 0, vi = 1, yi = 2, bi = 4, xi = 8;
5043
+ function Si(e, t, n, r, i, a, o) {
4957
5044
  let s = 0;
4958
- t && (s |= hi), n && (s |= gi), r && (s |= _i), o || (s |= vi);
5045
+ t && (s |= vi), n && (s |= yi), r && (s |= bi), o || (s |= xi);
4959
5046
  let c = /* @__PURE__ */ new ArrayBuffer(11), l = new DataView(c);
4960
- if (l.setUint8(0, di), l.setUint16(1, i), l.setUint32(3, e), l.setUint8(7, +!!a), l.setUint16(8, mi), l.setUint8(10, s), !o) return c;
5047
+ if (l.setUint8(0, mi), l.setUint16(1, i), l.setUint32(3, e), l.setUint8(7, +!!a), l.setUint16(8, _i), l.setUint8(10, s), !o) return c;
4961
5048
  let u = new Uint8Array(c.byteLength + o.byteLength);
4962
5049
  return u.set(new Uint8Array(c), 0), u.set(new Uint8Array(o), c.byteLength), u.buffer;
4963
5050
  }
4964
- function bi(e) {
4965
- 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 & hi), l = !!(s & gi), u = !!(s & _i), d = !!(s & vi);
4966
- if (n !== di) throw Error(`Unexpected protocol version. Got ${n}, expected ${di}`);
5051
+ function Ci(e) {
5052
+ 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 & vi), l = !!(s & yi), u = !!(s & bi), d = !!(s & xi);
5053
+ if (n !== mi) throw Error(`Unexpected protocol version. Got ${n}, expected ${mi}`);
4967
5054
  return {
4968
5055
  timestamp: i,
4969
5056
  start: c,
@@ -4976,26 +5063,26 @@ function bi(e) {
4976
5063
  data: e.slice(11)
4977
5064
  };
4978
5065
  }
4979
- function xi(e) {
5066
+ function wi(e) {
4980
5067
  if (!e || !e.byteLength || e.byteLength !== 4) return !1;
4981
5068
  let t = new DataView(e);
4982
- return !(t.getUint8(0) !== di || t.getUint8(1) !== fi || t.getUint16(2) !== mi);
5069
+ return !(t.getUint8(0) !== mi || t.getUint8(1) !== hi || t.getUint16(2) !== _i);
4983
5070
  }
4984
- function Si(e) {
5071
+ function Ti(e) {
4985
5072
  if (!e || !e.byteLength || e.byteLength !== 10) return null;
4986
5073
  let t = new DataView(e);
4987
- return t.getUint8(0) !== di || t.getUint8(1) !== pi || t.getUint16(2) !== mi ? null : {
5074
+ return t.getUint8(0) !== mi || t.getUint8(1) !== gi || t.getUint16(2) !== _i ? null : {
4988
5075
  seq: t.getUint16(4),
4989
5076
  ts2: t.getUint32(6)
4990
5077
  };
4991
5078
  }
4992
- function Ci(e) {
5079
+ function Ei(e) {
4993
5080
  let t = /* @__PURE__ */ new ArrayBuffer(4), n = new DataView(t);
4994
- return n.setUint8(0, di), n.setUint8(1, fi), n.setUint16(2, e), t;
5081
+ return n.setUint8(0, mi), n.setUint8(1, hi), n.setUint16(2, e), t;
4995
5082
  }
4996
5083
  //#endregion
4997
5084
  //#region src/classes/screenshare/WebmBuilder.ts
4998
- var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5085
+ var Di = 2 ** 15 - 1, Oi = 1, ki = 5, Ai = 5, ji = class e {
4999
5086
  constructor(e, t = R) {
5000
5087
  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;
5001
5088
  let n = () => {
@@ -5038,8 +5125,8 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5038
5125
  this._mediaSource?.readyState === "open" && this._sourceBuffer?.abort();
5039
5126
  let e = this._sourceBuffer?.buffered, t = e?.length;
5040
5127
  if (!t) return;
5041
- let n = e.start(0), r = Math.max(0, e.end(t - 1) - Ei);
5042
- r - n > Di && (this._clearBufferTill = r);
5128
+ let n = e.start(0), r = Math.max(0, e.end(t - 1) - ki);
5129
+ r - n > Ai && (this._clearBufferTill = r);
5043
5130
  }
5044
5131
  destroy() {
5045
5132
  this._queue = [], this._mediaSource.readyState === "open" && (this._sourceBuffer?.abort(), this._mediaSource.endOfStream()), this._sourceBuffer = null, this._clearBufferTill = 0;
@@ -5053,7 +5140,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5053
5140
  get buffered() {
5054
5141
  return this._sourceBuffer?.buffered;
5055
5142
  }
5056
- }, ki = class e extends oi {
5143
+ }, Mi = class e extends li {
5057
5144
  constructor(e, t, n, r, i = R) {
5058
5145
  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}]`);
5059
5146
  }
@@ -5077,8 +5164,8 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5077
5164
  u.element(u.ID.MuxingApp, u.string("vk-webm-builder")),
5078
5165
  u.element(u.ID.WritingApp, u.string("vk-webm-builder"))
5079
5166
  ]), 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, [
5080
- u.element(u.ID.TrackNumber, u.number(Ti)),
5081
- u.element(u.ID.TrackUID, u.number(Ti)),
5167
+ u.element(u.ID.TrackNumber, u.number(Oi)),
5168
+ u.element(u.ID.TrackUID, u.number(Oi)),
5082
5169
  u.element(u.ID.TrackType, u.number(1)),
5083
5170
  u.element(u.ID.FlagLacing, u.number(0)),
5084
5171
  u.element(u.ID.DefaultDuration, u.number(1e9)),
@@ -5091,7 +5178,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5091
5178
  return u.unknownSizeElement(u.ID.Cluster, [u.element(u.ID.Timecode, u.number(Math.round(e)))]);
5092
5179
  }
5093
5180
  _createVideo(e) {
5094
- this._mediaBuffer = new Oi(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);
5181
+ this._mediaBuffer = new ji(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);
5095
5182
  let t = () => {
5096
5183
  if (this._video?.src) {
5097
5184
  this._debug.warn(`[WebmBuilder] Video paused for participant [${this._participantId}], try to play again`);
@@ -5118,13 +5205,13 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5118
5205
  this._mediaBuffer?.append(a);
5119
5206
  }
5120
5207
  let i = Math.round(r - this._clusterStartTime);
5121
- if (i > wi && (this._clusterStartTime = r, i = 0), i === 0) {
5208
+ if (i > Di && (this._clusterStartTime = r, i = 0), i === 0) {
5122
5209
  this._debug.debug(`[WebmBuilder] Cluster header for participant [${this._participantId}]`);
5123
5210
  let t = e._genClusterHeader(this._clusterStartTime);
5124
5211
  this._mediaBuffer?.append(t);
5125
5212
  }
5126
5213
  let a = u.element(u.ID.SimpleBlock, [
5127
- u.vintEncodedNumber(Ti),
5214
+ u.vintEncodedNumber(Oi),
5128
5215
  u.bytes(e._intToU16BE(i)),
5129
5216
  u.number(!!t.keyframe << 7),
5130
5217
  u.bytes(t.frameData)
@@ -5137,12 +5224,12 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5137
5224
  static isBrowserSupported() {
5138
5225
  return "captureStream" in window.HTMLVideoElement?.prototype && window.MediaSource?.isTypeSupported("video/webm; codecs=\"vp8\"") && window.MediaSource?.isTypeSupported("video/webm; codecs=\"vp9\"");
5139
5226
  }
5140
- }, Ai = class {
5227
+ }, Ni = class {
5141
5228
  constructor(e, t, n, r, i, a = null, o = R, s = null) {
5142
5229
  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);
5143
5230
  }
5144
5231
  _onDataChannelMessage(e) {
5145
- let t = bi(e), n = this._participantIdRegistry?.getStreamDescription(t.ssrc)?.participantId;
5232
+ let t = Ci(e), n = this._participantIdRegistry?.getStreamDescription(t.ssrc)?.participantId;
5146
5233
  if (!n) {
5147
5234
  this._debug.warn(`Participant id for ssrc ${t.ssrc} not found in registry`);
5148
5235
  return;
@@ -5154,7 +5241,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5154
5241
  let r = this._streamBuilders[n];
5155
5242
  if (!r) {
5156
5243
  let e = (e) => this._onStream(n, e);
5157
- r = M.screenShareWebmBuilder && ki.isBrowserSupported() ? new ki(n, e, this._onStat, this._statAggregator, this._debug) : new ui(n, e, this._onStat, this._statAggregator, () => {
5244
+ r = M.screenShareWebmBuilder && Mi.isBrowserSupported() ? new Mi(n, e, this._onStat, this._statAggregator, this._debug) : new pi(n, e, this._onStat, this._statAggregator, () => {
5158
5245
  this._requestKeyFrame(t.ssrc);
5159
5246
  }, this._debug, this._logger), this._streamBuilders[n] = r;
5160
5247
  }
@@ -5162,7 +5249,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5162
5249
  }
5163
5250
  _requestKeyFrame(e) {
5164
5251
  if (!(!this._datachannel || this._datachannel.readyState !== "open")) try {
5165
- let t = Ci(e);
5252
+ let t = Ei(e);
5166
5253
  this._datachannel.send(t), this._debug.debug(`ScreenCaptureReceiver request for keyframe for ssrc ${e}`);
5167
5254
  } catch (e) {
5168
5255
  this._debug.warn("Failed to send keyframe request", e);
@@ -5175,7 +5262,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5175
5262
  destroy() {
5176
5263
  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");
5177
5264
  }
5178
- }, ji = class {
5265
+ }, Pi = class {
5179
5266
  constructor(e, t, n) {
5180
5267
  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;
5181
5268
  }
@@ -5194,7 +5281,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5194
5281
  get data() {
5195
5282
  return this._data;
5196
5283
  }
5197
- }, Mi = class {
5284
+ }, Fi = class {
5198
5285
  constructor() {
5199
5286
  h(this, "_head", null), h(this, "_tail", null), h(this, "_length", 0);
5200
5287
  }
@@ -5202,7 +5289,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5202
5289
  return this._length;
5203
5290
  }
5204
5291
  push(...e) {
5205
- for (let t of e) this._tail = new ji(t, this._tail, null), this._head || (this._head = this._tail), this._length++;
5292
+ for (let t of e) this._tail = new Pi(t, this._tail, null), this._head || (this._head = this._tail), this._length++;
5206
5293
  }
5207
5294
  merge(e) {
5208
5295
  this._tail && (this._tail.next = e._head), this._head || (this._head = e._head), this._tail = e._tail, this._length += e._length, e.clear();
@@ -5232,7 +5319,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5232
5319
  for (; t !== null;) e.push(t.data), t = t.next;
5233
5320
  return e.length ? JSON.stringify(e, (e, t) => t instanceof Error ? String(t) : t) : "";
5234
5321
  }
5235
- }, Ni = 1e3, Pi = class extends $r {
5322
+ }, Ii = 1e3, Li = class extends ni {
5236
5323
  constructor(e, t, n, r, i = R, a = null) {
5237
5324
  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);
5238
5325
  }
@@ -5318,7 +5405,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5318
5405
  let t = this._drawFrameData(this._lastFrame);
5319
5406
  this._encode(t, e);
5320
5407
  } else this._onFrame(null);
5321
- }, Ni), this._getFrameBitmap().then((t) => {
5408
+ }, Ii), this._getFrameBitmap().then((t) => {
5322
5409
  window.clearTimeout(this._frameReadTimeout), this._lastFrame?.close(), this._lastFrame = t;
5323
5410
  let n = this._drawFrameData(t);
5324
5411
  this._encode(n, e);
@@ -5339,7 +5426,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5339
5426
  destroy() {
5340
5427
  this._removeWorker(), this._removeStream(), this._removeDom(), this._debug.debug("LibVPxEncoder destroyed");
5341
5428
  }
5342
- }, Fi = class extends $r {
5429
+ }, Ri = class extends ni {
5343
5430
  constructor(e, t, n, r, i, a, o = R, s = null) {
5344
5431
  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 });
5345
5432
  }
@@ -5385,11 +5472,11 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5385
5472
  static isBrowserSupported() {
5386
5473
  return "VideoEncoder" in window && "Worker" in window && "EncodedVideoChunk" in window && "MediaStreamTrackProcessor" in window;
5387
5474
  }
5388
- }, Ii = 2100, Li = 600, Ri = 1.2, zi = .8, Bi = 2e3, Vi = 8e3, Hi = 8e3, Ui = 16e3, Wi = 4, Gi = 2e3, Ki = /* @__PURE__ */ function(e) {
5475
+ }, zi = 2100, Bi = 600, Vi = 1.2, Hi = .8, Ui = 2e3, Wi = 8e3, Gi = 8e3, Ki = 16e3, qi = 4, Ji = 2e3, Yi = /* @__PURE__ */ function(e) {
5389
5476
  return e[e.NONE = 0] = "NONE", e[e.UP = 1] = "UP", e[e.DOWN = 2] = "DOWN", e;
5390
- }(Ki || {}), qi = class {
5477
+ }(Yi || {}), Xi = class {
5391
5478
  constructor(e, t, n, r, i, a, o, s = R) {
5392
- 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 = Ii, i && (this._highDelayThreshold = Li), this._trendDelayThreshold = Math.round(this._highDelayThreshold / 3), this._targetBitrate = this._maxBitrate, this._probing = !1;
5479
+ h(this, "_onCongestion", void 0), h(this, "_ccEnabled", void 0), h(this, "_fastSharing", void 0), h(this, "_trendDelayThreshold", void 0), h(this, "_highDelayThreshold", void 0), h(this, "_targetFps", void 0), h(this, "_minBitrate", void 0), h(this, "_maxBitrate", void 0), h(this, "_targetBitrate", void 0), h(this, "_lastDown", void 0), h(this, "_lastUp", void 0), h(this, "_lastProbing", void 0), h(this, "_lastCheckDelay", void 0), h(this, "_upPenalty", 0), h(this, "_probing", void 0), h(this, "_delayAvgShort", -1), h(this, "_delayAvgLong", -1), h(this, "_minDelay", Number.MAX_VALUE), h(this, "_maxDelay", 0), h(this, "_largeDelayDuration", 0), h(this, "_lastFpsCalcMs", void 0), h(this, "_frames", 0), h(this, "_fps", 0), h(this, "_debug", void 0), this._onCongestion = e, this._ccEnabled = r, this._debug = s, this._minBitrate = t, this._maxBitrate = n, this._fastSharing = i, this._targetFps = o, a > 0 ? this._highDelayThreshold = a : this._highDelayThreshold = zi, i && (this._highDelayThreshold = Bi), this._trendDelayThreshold = Math.round(this._highDelayThreshold / 3), this._targetBitrate = this._maxBitrate, this._probing = !1;
5393
5480
  let c = Date.now();
5394
5481
  this._lastDown = 0, this._lastUp = c, this._lastProbing = c, this._lastCheckDelay = 0, this._lastFpsCalcMs = 0;
5395
5482
  }
@@ -5399,27 +5486,27 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5399
5486
  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;
5400
5487
  s || c ? i = 2 : Math.abs(a) < 40 && o < 10 && !c && (i = 1);
5401
5488
  let l = Math.round(this._targetBitrate / 1e3), u = n;
5402
- e % 20 == 0 && this._debug.debug(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${Ki[i]} tr=${l} br=${n}`);
5489
+ e % 20 == 0 && this._debug.debug(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${Yi[i]} tr=${l} br=${n}`);
5403
5490
  let d = r - this._lastDown;
5404
- if (i === 2 && d > Bi) {
5405
- this._probing && (this._upPenalty = Math.min(++this._upPenalty, Wi), this._probing = !1);
5406
- let n = zi * u * 1e3;
5407
- if (n >= this._targetBitrate && (n = this._targetBitrate * zi), n = Math.max(n, this._minBitrate), n < this._targetBitrate) {
5408
- let r = Math.round(n / 1e3), s = Math.round(this._upPenalty * Hi / 1e3);
5409
- this._debug.log(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${Ki[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;
5491
+ if (i === 2 && d > Ui) {
5492
+ this._probing && (this._upPenalty = Math.min(++this._upPenalty, qi), this._probing = !1);
5493
+ let n = Hi * u * 1e3;
5494
+ if (n >= this._targetBitrate && (n = this._targetBitrate * Hi), n = Math.max(n, this._minBitrate), n < this._targetBitrate) {
5495
+ let r = Math.round(n / 1e3), s = Math.round(this._upPenalty * Gi / 1e3);
5496
+ this._debug.log(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${Yi[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;
5410
5497
  }
5411
5498
  this._lastDown = r;
5412
5499
  }
5413
- let f = r - this._lastUp, p = Vi + this._upPenalty * Hi;
5500
+ let f = r - this._lastUp, p = Wi + this._upPenalty * Gi;
5414
5501
  if (i === 1 && f > p && d > p) {
5415
- let n = Math.min(this._targetBitrate * Ri, this._maxBitrate);
5502
+ let n = Math.min(this._targetBitrate * Vi, this._maxBitrate);
5416
5503
  if (n > this._targetBitrate) {
5417
- let s = Math.round(n / 1e3), c = Math.round(this._targetBitrate / 1e3), l = Math.round(this._upPenalty * Hi / 1e3);
5418
- this._debug.log(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${Ki[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;
5504
+ let s = Math.round(n / 1e3), c = Math.round(this._targetBitrate / 1e3), l = Math.round(this._upPenalty * Gi / 1e3);
5505
+ this._debug.log(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${Yi[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;
5419
5506
  }
5420
5507
  }
5421
5508
  let m = r - this._lastProbing;
5422
- this._probing && m > Ui && (this._probing = !1);
5509
+ this._probing && m > Ki && (this._probing = !1);
5423
5510
  let ee = r - this._lastDown;
5424
5511
  this._upPenalty > 0 && ee > 3 * p && (this._debug.log(`#${e}: cc: UP reset penalty: oldPenalty=${this._upPenalty}`), this._upPenalty = 0);
5425
5512
  }
@@ -5430,7 +5517,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5430
5517
  }
5431
5518
  _calcDelay(e, t) {
5432
5519
  if (!(e <= 0)) {
5433
- 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 > Gi) {
5520
+ 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 > Ji) {
5434
5521
  let e = t - this._lastCheckDelay;
5435
5522
  this._largeDelayDuration += e;
5436
5523
  }
@@ -5459,7 +5546,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5459
5546
  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}`);
5460
5547
  }
5461
5548
  }
5462
- }, Ji = class {
5549
+ }, Zi = class {
5463
5550
  constructor(e) {
5464
5551
  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);
5465
5552
  }
@@ -5533,11 +5620,11 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5533
5620
  clear() {
5534
5621
  this._buffer.fill(void 0), this._size = 0, this._head = 0, this._tail = 0;
5535
5622
  }
5536
- }, Yi = 65536, Xi = 50, Zi = 400, Qi = 1e6, $i = 3e5, ea = 3e4, ta = 2e3, na = 5, ra = 0, ia = class {
5623
+ }, Qi = 65536, $i = 50, ea = 400, ta = 1e6, na = 3e5, ra = 3e4, ia = 2e3, aa = 5, oa = 0, sa = class {
5537
5624
  constructor(e, t, n, r, i = R, a = null) {
5538
- 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 Ji(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 Mi()), 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 = M.consumerScreenDataChannelPacketSize - 11, this._datachannel = t, this._signaling = n, this._fastSharing = r, this._congestionControlEnabled = M.screenShareCongestionControl || this._fastSharing, this._width = e.getSettings().width, this._height = e.getSettings().height, this._maxFrameDelay = this._fastSharing ? M.screenShareCongestionControlThreshold : M.screenShareCongestionControlThreshold * 2;
5625
+ 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 Zi(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 Fi()), 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 = M.consumerScreenDataChannelPacketSize - 11, this._datachannel = t, this._signaling = n, this._fastSharing = r, this._congestionControlEnabled = M.screenShareCongestionControl || this._fastSharing, this._width = e.getSettings().width, this._height = e.getSettings().height, this._maxFrameDelay = this._fastSharing ? M.screenShareCongestionControlThreshold : M.screenShareCongestionControlThreshold * 2;
5539
5626
  let o = M.getScreenFrameRate(this._fastSharing), { minBitrate: s, maxBitrate: c } = this._calcMinMaxBitrate(this._width, this._height), l = this._onCongestionCallback.bind(this);
5540
- this._debug.log(`ScreenCaptureSender: CongestionControl: enabled=${this._congestionControlEnabled} minBitrate=${Math.round(s / 1e3)}k maxBitrate=${Math.round(c / 1e3)}k delayThreshold=${M.screenShareCongestionControlThreshold}`), this._congestionControl = new qi(l, s, c, this._congestionControlEnabled, this._fastSharing, M.screenShareCongestionControlThreshold, o, this._debug);
5627
+ this._debug.log(`ScreenCaptureSender: CongestionControl: enabled=${this._congestionControlEnabled} minBitrate=${Math.round(s / 1e3)}k maxBitrate=${Math.round(c / 1e3)}k delayThreshold=${M.screenShareCongestionControlThreshold}`), this._congestionControl = new Xi(l, s, c, this._congestionControlEnabled, this._fastSharing, M.screenShareCongestionControlThreshold, o, this._debug);
5541
5628
  let u = (e, t) => {
5542
5629
  if (this._destroyed) return;
5543
5630
  if (!e) {
@@ -5548,23 +5635,23 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5548
5635
  let n = this._sliceFrame(e);
5549
5636
  this._queue.merge(n), this._handleQueue(), this._sendSharingStat();
5550
5637
  };
5551
- if (Fi.isBrowserSupported()) {
5638
+ if (Ri.isBrowserSupported()) {
5552
5639
  let t = this._fastSharing;
5553
- this._encoder = new Fi(e, u, this._congestionControlEnabled, c, t, o, this._debug, this._logger);
5554
- } else this._encoder = new Pi(e, u, this._congestionControlEnabled, c, this._debug, this._logger);
5640
+ this._encoder = new Ri(e, u, this._congestionControlEnabled, c, t, o, this._debug, this._logger);
5641
+ } else this._encoder = new Li(e, u, this._congestionControlEnabled, c, this._debug, this._logger);
5555
5642
  this._datachannel.onmessage = (e) => {
5556
- xi(e.data) && (this._debug.debug(`[${this._datachannel.label}] Requested keyframe`), this._needKeyframe = !0);
5557
- let t = Si(e.data);
5643
+ wi(e.data) && (this._debug.debug(`[${this._datachannel.label}] Requested keyframe`), this._needKeyframe = !0);
5644
+ let t = Ti(e.data);
5558
5645
  t !== null && this._checkCcFeedback(t);
5559
- }, this._encoder.init().then(() => this._handleQueue()).catch((e) => this._debug.warn("ScreenCaptureSender init failed", e)), this._fpsMeter = new ni((e) => this._debug.log(`[ScreenCaptureSender] fps: ${e}`), 5e3);
5646
+ }, this._encoder.init().then(() => this._handleQueue()).catch((e) => this._debug.warn("ScreenCaptureSender init failed", e)), this._fpsMeter = new ai((e) => this._debug.log(`[ScreenCaptureSender] fps: ${e}`), 5e3);
5560
5647
  }
5561
5648
  _handleQueue() {
5562
5649
  if (this._destroyed) return;
5563
5650
  let e = this._queue.shift();
5564
5651
  if (!e) {
5565
- if ((this._lastSentFrameSeq - this._lastDeliveredFrameSeq + Yi) % Yi > na && this._lastFrameDelay > this._maxFrameDelay) {
5652
+ if ((this._lastSentFrameSeq - this._lastDeliveredFrameSeq + Qi) % Qi > aa && this._lastFrameDelay > this._maxFrameDelay) {
5566
5653
  let e = Date.now();
5567
- e - this._lastFramerateReduced > ta && (this._lastFramerateReduced = e, this._debug.debug(`[ScreenCaptureSender] reduce framerate: delay=${this._lastFrameDelay} maxDelay=${this._maxFrameDelay}`));
5654
+ e - this._lastFramerateReduced > ia && (this._lastFramerateReduced = e, this._debug.debug(`[ScreenCaptureSender] reduce framerate: delay=${this._lastFrameDelay} maxDelay=${this._maxFrameDelay}`));
5568
5655
  } else this._requestFrame();
5569
5656
  return;
5570
5657
  }
@@ -5590,7 +5677,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5590
5677
  this._destroyed || (this._encoder.requestFrame(this._needKeyframe), this._needKeyframe = !1);
5591
5678
  }
5592
5679
  _sliceFrame(e) {
5593
- let t = e.type === "key", n = e.data.byteLength, r = new Mi();
5680
+ let t = e.type === "key", n = e.data.byteLength, r = new Fi();
5594
5681
  for (let i = 0; i < n; i += this.DATA_SIZE) {
5595
5682
  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);
5596
5683
  r.push({
@@ -5606,11 +5693,11 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5606
5693
  return r;
5607
5694
  }
5608
5695
  _wrapHeader(e, t, n, r, i) {
5609
- let a = yi(e, t, n, r, ra, this._encoder.isVP9(), i), o = {
5610
- sequence: ra,
5696
+ let a = Si(e, t, n, r, oa, this._encoder.isVP9(), i), o = {
5697
+ sequence: oa,
5611
5698
  data: a
5612
5699
  };
5613
- return ra = (ra + 1) % Yi, o;
5700
+ return oa = (oa + 1) % Qi, o;
5614
5701
  }
5615
5702
  _stopPacket() {
5616
5703
  return this._wrapHeader(Date.now(), !1, !1, !1, null).data;
@@ -5627,7 +5714,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5627
5714
  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");
5628
5715
  }
5629
5716
  static isBrowserSupported() {
5630
- return Fi.isBrowserSupported() || Pi.isBrowserSupported();
5717
+ return Ri.isBrowserSupported() || Li.isBrowserSupported();
5631
5718
  }
5632
5719
  _onCongestionCallback(e, t, n) {
5633
5720
  this._encoder.setBitrate(e, t, n);
@@ -5640,8 +5727,8 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5640
5727
  (e === void 0 || e < 640) && (e = 640), (t === void 0 || t < 360) && (t = 360);
5641
5728
  let n = e * t / 256;
5642
5729
  return {
5643
- minBitrate: Math.max($i, Math.min(Qi, Math.round(n * Xi))),
5644
- maxBitrate: Math.round(n * Zi)
5730
+ minBitrate: Math.max(na, Math.min(ta, Math.round(n * $i))),
5731
+ maxBitrate: Math.round(n * ea)
5645
5732
  };
5646
5733
  }
5647
5734
  _checkCcFeedback(e) {
@@ -5655,14 +5742,14 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5655
5742
  }
5656
5743
  _sendSharingStat() {
5657
5744
  let e = Date.now();
5658
- if (e - this._lastSharingStat > ea) {
5745
+ if (e - this._lastSharingStat > ra) {
5659
5746
  let t = this._congestionControl.getStat();
5660
5747
  t !== null && (this._debug.debug(`cc: send stats: ${JSON.stringify(t)}`), this._signaling.reportSharingStat(t).catch((e) => {
5661
5748
  !(e instanceof wn) && !(e instanceof Tn) && this._debug.warn("Unable to send sharing stats", e);
5662
5749
  })), this._lastSharingStat = e;
5663
5750
  }
5664
5751
  }
5665
- }, aa = class {
5752
+ }, ca = class {
5666
5753
  constructor(e, t, n, r = R, i = null) {
5667
5754
  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;
5668
5755
  }
@@ -5794,9 +5881,9 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5794
5881
  if (!(e instanceof Tn)) throw e;
5795
5882
  }
5796
5883
  }
5797
- }, oa = 90, sa = 4294967295, ca = class e extends Nr {
5884
+ }, la = 90, ua = 4294967295, da = class e extends Ir {
5798
5885
  constructor(e, t, n, r = R, i = null, a = null, o = null, s = null) {
5799
- 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, "_codecStatsAggregator", void 0), h(this, "_simulcast", void 0), this._debug = r, this._logger = i, this._statAggregator = a, this._codecStatsAggregator = o, this._serverSettings = n, this._simulcast = new aa(e, t, () => this._serverSettings.camera, r, i), this.subscribe(this._signaling, G.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");
5886
+ 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, "_peerConnectionStats", void 0), h(this, "_codecStatsAggregator", void 0), h(this, "_simulcast", void 0), this._debug = r, this._logger = i, this._statAggregator = a, this._peerConnectionStats = new Mr(a), this._codecStatsAggregator = o, this._serverSettings = n, this._simulcast = new ca(e, t, () => this._serverSettings.camera, r, i), this.subscribe(this._signaling, G.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");
5800
5887
  }
5801
5888
  updateStatisticsInterval() {
5802
5889
  this._stopStatInterval();
@@ -5835,10 +5922,10 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5835
5922
  await this._simulcast.sync();
5836
5923
  }
5837
5924
  _createPerfStatsReporter() {
5838
- this._perfStatReporter?.destroy(), this._perfStatReporter = new pa(this, this._signaling, this._statAggregator, !1, this._debug);
5925
+ this._perfStatReporter?.destroy(), this._perfStatReporter = new ga(this, this._signaling, this._statAggregator, !1, this._debug);
5839
5926
  }
5840
5927
  _closeConnection() {
5841
- this._signaling.resetProducerConnection(), 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._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(X.PEER_CONNECTION_CLOSED);
5928
+ 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._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(X.PEER_CONNECTION_CLOSED);
5842
5929
  }
5843
5930
  static _closeDataChannel(e) {
5844
5931
  e && (e.onopen = null, e.onmessage = null, e.onerror = null, e.close());
@@ -5864,14 +5951,14 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5864
5951
  }
5865
5952
  this._pc.ontrack = this._onAddTrack.bind(this, this._pc), this._pc.onconnectionstatechange = j.debounce((e) => {
5866
5953
  this._pc && this._onConnectionStateChange(this._pc, e);
5867
- }, 500), this._pc.onsignalingstatechange = this._onSignalingStateChange.bind(this, this._pc), this._participantIdRegistry = new Qr(this._debug), this._signaling.setParticipantIdRegistry(this._participantIdRegistry), this._createDataChannel(this._pc, Sr.producerNotification, (e) => {
5954
+ }, 500), this._pc.onsignalingstatechange = this._onSignalingStateChange.bind(this, this._pc), this._peerConnectionStats.observe(this._pc), this._participantIdRegistry = new ti(this._debug), this._signaling.setParticipantIdRegistry(this._participantIdRegistry), this._createDataChannel(this._pc, Sr.producerNotification, (e) => {
5868
5955
  this._producerNotification = e, this._producerNotification.binaryType = "arraybuffer", this._signaling.setProducerNotificationDataChannel(e);
5869
5956
  }), this._signaling.useCommandDataChannel(!0), this._createDataChannel(this._pc, Sr.producerCommand, (e) => {
5870
5957
  this._producerCommand = e, this._signaling.setProducerCommandDataChannel(e);
5871
5958
  }), this._createDataChannel(this._pc, Sr.producerScreenShare, (e) => {
5872
5959
  this._producerScreen = e, this._producerScreen.binaryType = "arraybuffer", this._createCaptureReceiver();
5873
5960
  }), M.asrDataChannel && this._createDataChannel(this._pc, Sr.asr, (e) => {
5874
- this._asr = e, this._asr.binaryType = "arraybuffer", this._removeAsrTrack(), this._asrTrack = new Yr(e, this._participantIdRegistry, (e) => {
5961
+ this._asr = e, this._asr.binaryType = "arraybuffer", this._removeAsrTrack(), this._asrTrack = new Qr(e, this._participantIdRegistry, (e) => {
5875
5962
  this._onAsrTranscription(e);
5876
5963
  }, this._debug);
5877
5964
  }), M.vmoji && this._createDataChannel(this._pc, Sr.animoji, (e) => {
@@ -5908,20 +5995,20 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5908
5995
  this._triggerEvent(X.NETWORK_STATUS, e);
5909
5996
  }
5910
5997
  _updateSSRCMap(e) {
5911
- e && ln(e.sdp).forEach((e) => {
5912
- let t = `a=ssrc:([0-9]+) label:(audio|video)-((?:[ug]?[\\d]+)|(?:mix)|(?:${qr.PARTICIPANT_AGNOSTIC_TRACK_PREFIX}-[0-9]+)|(?:${qr.TRANSPARENT_AUDIO_TRACK_PREFIX}-[0-9]+))`, n = new RegExp(t).exec(e);
5913
- n && (this._ssrcMap[n[1]] = n[3], this._ssrcMapUpdated = !0);
5914
- });
5998
+ e && (this._ssrcMap = {}, this._ssrcMapUpdated = !0, ln(e.sdp).forEach((e) => {
5999
+ let t = `a=ssrc:([0-9]+) label:(audio|video)-((?:[ug]?[\\d]+)|(?:mix)|(?:${Xr.PARTICIPANT_AGNOSTIC_TRACK_PREFIX}-[0-9]+)|(?:${Xr.TRANSPARENT_AUDIO_TRACK_PREFIX}-[0-9]+))`, n = new RegExp(t).exec(e);
6000
+ n && (this._ssrcMap[n[1]] = n[3]);
6001
+ }));
5915
6002
  }
5916
6003
  _createCaptureSender(e) {
5917
6004
  let t = this._mediaSource.mediaSettings;
5918
- !e || !this._consumerScreen || !t.isScreenSharingEnabled || (this._captureSender && this._removeCaptureSender(), this._captureSender = new ia(e, this._consumerScreen, this._signaling, t.isFastScreenSharingEnabled, this._debug, this._logger));
6005
+ !e || !this._consumerScreen || !t.isScreenSharingEnabled || (this._captureSender && this._removeCaptureSender(), this._captureSender = new sa(e, this._consumerScreen, this._signaling, t.isFastScreenSharingEnabled, this._debug, this._logger));
5919
6006
  }
5920
6007
  _removeCaptureSender() {
5921
6008
  this._captureSender?.destroy(), this._captureSender = null;
5922
6009
  }
5923
6010
  _createCaptureReceiver() {
5924
- this._producerScreen && (this._captureReceiver && this._removeCaptureReceiver(), this._captureReceiver = new Ai(this._producerScreen, this._participantIdRegistry, (e, t) => {
6011
+ this._producerScreen && (this._captureReceiver && this._removeCaptureReceiver(), this._captureReceiver = new Ni(this._producerScreen, this._participantIdRegistry, (e, t) => {
5925
6012
  this._triggerEvent(X.REMOTE_STREAM_SECOND, e, t);
5926
6013
  }, (e) => {
5927
6014
  this._triggerEvent(X.REMOTE_STREAM_SECOND, e, null);
@@ -6031,7 +6118,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
6031
6118
  _detectStaleTracks(e) {
6032
6119
  let t = e.rtps.find((e) => e.type === "inbound-rtp" && e.kind === "audio" && this._ssrcMap[e.ssrc] === "mix");
6033
6120
  if (!t) return;
6034
- let n = qr.AUDIO_MIX, r = this._statBytes[n], i = !1;
6121
+ let n = Xr.AUDIO_MIX, r = this._statBytes[n], i = !1;
6035
6122
  if (r) {
6036
6123
  let e = t.bytesReceived - r.bytesReceived;
6037
6124
  e >= 0 && e <= 5 && (i = !0), r.stalled !== i && this._triggerEvent(X.AUDIO_MIX_STALL, i);
@@ -6043,7 +6130,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
6043
6130
  }
6044
6131
  _allocateConsumer() {
6045
6132
  if (!this._signaling.ready) return;
6046
- let e = ya.get();
6133
+ let e = Sa.get();
6047
6134
  !M.videoTracksCount && !this._observer && this._debug.warn("Setting videoTracksCount to 0 is deprecated"), this._signaling.allocateConsumer(null, e).catch((e) => {
6048
6135
  e instanceof wn || this._debug.warn("ServerTransport: Unable to allocate consumer", e);
6049
6136
  });
@@ -6219,11 +6306,11 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
6219
6306
  if (!r || !r.length) return this._debug.log(`Cannot get stream waiting time, ${e} receiver has no synchronization sources`), 0;
6220
6307
  let i = r[0].rtpTimestamp;
6221
6308
  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;
6222
- let a = t - i & sa, o = Math.ceil(a / oa);
6309
+ let a = t - i & ua, o = Math.ceil(a / la);
6223
6310
  return Math.min(100, Math.max(0, o));
6224
6311
  }
6225
6312
  async _monitorRtpShare() {
6226
- let e = Zr.getInstance().value;
6313
+ let e = ei.getInstance().value;
6227
6314
  if (!this._mediaSource.mediaSettings.isFastScreenSharingEnabled || !M.consumerFastScreenShare || e < .6) return;
6228
6315
  let t = this._pc?.getSenders().find((e) => e.track?.kind === k.video && e.track?.contentHint === "motion");
6229
6316
  t && (await t.getStats()).forEach((e) => {
@@ -6254,7 +6341,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
6254
6341
  }
6255
6342
  }, X = /* @__PURE__ */ function(e) {
6256
6343
  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;
6257
- }({}), la = class extends b {
6344
+ }({}), fa = class extends b {
6258
6345
  constructor(e, t, n, r, i = R, a = null, o = null, s = null, c = null) {
6259
6346
  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", () => {
6260
6347
  this._vadController?.setSendTrack(this._mediaSource.getSendAudioTrack());
@@ -6375,11 +6462,11 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
6375
6462
  }
6376
6463
  }
6377
6464
  _createDirectTransport(e, t = !1) {
6378
- let n = new Kr(e, t, this._signaling, this._mediaSource, this._serverSettings, this._debug, this._logger, this._statAggregator, this._codecStatsAggregator, this._getFirstMediaSentCallback());
6465
+ let n = new Yr(e, t, this._signaling, this._mediaSource, this._serverSettings, this._debug, this._logger, this._statAggregator, this._codecStatsAggregator, this._getFirstMediaSentCallback());
6379
6466
  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;
6380
6467
  }
6381
6468
  _createServerTransport() {
6382
- let e = new ca(this._signaling, this._mediaSource, this._serverSettings, this._debug, this._logger, this._statAggregator, this._codecStatsAggregator, this._getFirstMediaSentCallback());
6469
+ let e = new da(this._signaling, this._mediaSource, this._serverSettings, this._debug, this._logger, this._statAggregator, this._codecStatsAggregator, this._getFirstMediaSentCallback());
6383
6470
  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;
6384
6471
  }
6385
6472
  _releaseDirectTransport() {
@@ -6471,20 +6558,20 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
6471
6558
  getStreamWaitingTimeMs(e, t) {
6472
6559
  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);
6473
6560
  }
6474
- }, ua = "videochat-epi", da = 5e3, fa = 500, pa = class extends b {
6561
+ }, pa = "videochat-epi", ma = 5e3, ha = 500, ga = class extends b {
6475
6562
  constructor(e, t, n = null, r = !1, i = R) {
6476
- 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) => {
6563
+ 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) => {
6477
6564
  this._screenShareStats.push(e);
6478
6565
  }), h(this, "_handleTransportStateChanged", (e) => {
6479
6566
  (this._directTopology && e === q.CONNECTED || !this._directTopology && e === q.OPENED) && (this._previousNetworkStatReportTimestamp = Date.now(), this._previousCallStatReportTimestamp = Date.now(), this._previousRemoteInboundRtps.clear());
6480
6567
  }), this._signaling = t, this._directTopology = r, this._debug = i, this._statAggregator = n, this.subscribe(e, X.REMOTE_DATA_STATS, this._handleStats.bind(this)), this.subscribe(e, X.SCREEN_SHARING_STAT, this._handleScreenSharingStat.bind(this)), this.subscribe(e, X.STATE_CHANGED, this._handleTransportStateChanged.bind(this));
6481
6568
  }
6482
6569
  destroy() {
6483
- this._previousRemoteInboundRtps.clear(), this.unsubscribe();
6570
+ this._previousRemoteInboundRtps.clear(), this._previousCandidatePair = null, this.unsubscribe();
6484
6571
  }
6485
6572
  static getEstimatedPerformanceIndex() {
6486
6573
  try {
6487
- let e = parseInt(localStorage.getItem(ua) || "", 10);
6574
+ let e = parseInt(localStorage.getItem(pa) || "", 10);
6488
6575
  return isNaN(e) ? 0 : e;
6489
6576
  } catch {
6490
6577
  return 0;
@@ -6493,9 +6580,9 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
6493
6580
  async _handleStats(e) {
6494
6581
  if (!e.inbound || !e.inbound.rtps) return;
6495
6582
  let t = Date.now();
6496
- !this._directTopology && M.perfStatReportEnabled && this._previousPerfStatReportTimestamp + da <= t && (await this.reportPerfStats(e), this._previousPerfStatReportTimestamp = t);
6583
+ !this._directTopology && M.perfStatReportEnabled && this._previousPerfStatReportTimestamp + ma <= t && (await this.reportPerfStats(e), this._previousPerfStatReportTimestamp = t);
6497
6584
  let n = e.outbound.transport.local?.protocol === "tcp";
6498
- !this._directTopology && n && this._previousNetworkStatReportTimestamp + fa <= t && (await this.reportNetworkStats(e), this._previousNetworkStatReportTimestamp = t), M.callStatReportEnabled && this._previousCallStatReportTimestamp + M.statisticsInterval <= t && (this._reportCallStats(e), this._previousCallStatReportTimestamp = t);
6585
+ !this._directTopology && n && this._previousNetworkStatReportTimestamp + ha <= t && (await this.reportNetworkStats(e), this._previousNetworkStatReportTimestamp = t), this._reportCandidatePair(e.inbound.transport.local, e.inbound.transport.remote), M.callStatReportEnabled && this._previousCallStatReportTimestamp + M.statisticsInterval <= t && (this._reportCallStats(e), this._previousCallStatReportTimestamp = t);
6499
6586
  }
6500
6587
  async reportPerfStats(e) {
6501
6588
  let t = e.inbound.rtps.reduce((e, t) => (t.kind === "video" && (e.framesDecoded += t.framesDecoded || 0, e.framesReceived += t.framesReceived || 0), e), {
@@ -6504,7 +6591,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
6504
6591
  });
6505
6592
  if (t.framesDecoded) try {
6506
6593
  let e = await this._signaling.reportPerfStat(t);
6507
- localStorage.setItem(ua, e.estimatedPerformanceIndex);
6594
+ localStorage.setItem(pa, e.estimatedPerformanceIndex);
6508
6595
  } catch {}
6509
6596
  }
6510
6597
  async reportNetworkStats(e) {
@@ -6544,11 +6631,11 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
6544
6631
  rtt: Math.round(e.inbound.transport.currentRoundTripTime * 1e3),
6545
6632
  ss_freeze_count: 0,
6546
6633
  ss_total_freezes_duration: 0,
6547
- local_address: ha(e.inbound.transport.local),
6634
+ local_address: va(e.inbound.transport.local),
6548
6635
  local_connection_type: e.inbound.transport.local?.type,
6549
6636
  network_type: e.inbound.transport.local?.networkType,
6550
6637
  transport: e.inbound.transport.local?.protocol,
6551
- remote_address: ha(e.inbound.transport.remote),
6638
+ remote_address: va(e.inbound.transport.remote),
6552
6639
  remote_connection_type: e.inbound.transport.remote?.type
6553
6640
  };
6554
6641
  this._previousCallStatReport || (this._previousCallStatReport = Object.assign({}, t));
@@ -6569,14 +6656,29 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
6569
6656
  frames_dropped: Math.max(0, t.frames_dropped - this._previousCallStatReport.frames_dropped),
6570
6657
  rtt: Math.max(0, t.rtt)
6571
6658
  };
6572
- if (M.simulcast && (i.is_simulcast = !0), navigator.hardwareConcurrency && (i.cpu_hardware_concurrency = navigator.hardwareConcurrency), n && !ga(t.jitter_video) && (i.jitter_video = Math.round(t.jitter_video)), r && !ga(t.jitter_audio) && (i.jitter_audio = Math.round(t.jitter_audio)), n && !ga(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 && !ga(t.total_audio_samples_received)) {
6659
+ if (M.simulcast && (i.is_simulcast = !0), navigator.hardwareConcurrency && (i.cpu_hardware_concurrency = navigator.hardwareConcurrency), n && !ya(t.jitter_video) && (i.jitter_video = Math.round(t.jitter_video)), r && !ya(t.jitter_audio) && (i.jitter_audio = Math.round(t.jitter_audio)), n && !ya(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 && !ya(t.total_audio_samples_received)) {
6573
6660
  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);
6574
- i.inserted_audio_samples_for_deceleration = _a(n / e * 1e3), i.removed_audio_samples_for_acceleration = _a(r / e * 1e3), i.concealed_audio_samples = _a(a / e * 1e3), i.concealed_silent_audio_samples = _a(o / e * 1e3), i.concealment_audio_avg_size = _a(a / s), i.total_audio_energy = t.total_audio_energy;
6661
+ i.inserted_audio_samples_for_deceleration = ba(n / e * 1e3), i.removed_audio_samples_for_acceleration = ba(r / e * 1e3), i.concealed_audio_samples = ba(a / e * 1e3), i.concealed_silent_audio_samples = ba(o / e * 1e3), i.concealment_audio_avg_size = ba(a / s), i.total_audio_energy = t.total_audio_energy;
6575
6662
  }
6576
- ma(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), ma(t, "remote_address", "remote_connection_type") && (i.remote_address = t.remote_address, i.remote_connection_type = t.remote_connection_type);
6663
+ _a(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), _a(t, "remote_address", "remote_connection_type") && (i.remote_address = t.remote_address, i.remote_connection_type = t.remote_connection_type);
6577
6664
  let a = this._calculatePacketLoss(e.remoteInbound.rtps);
6578
6665
  a.video !== void 0 && (i.video_loss = a.video), a.audio !== void 0 && (i.audio_loss = a.audio), this._statAggregator?.logCallStat(i), M.enableLogPerfStatReport && this._debug.log("Sent call stats", i), this._previousCallStatReport = t;
6579
6666
  }
6667
+ _reportCandidatePair(e, t) {
6668
+ if (!e?.address || !t?.address) return;
6669
+ let n = JSON.stringify({
6670
+ local: e,
6671
+ remote: t
6672
+ });
6673
+ n !== this._previousCandidatePair && (this._previousCandidatePair = n, this._statAggregator?.logEventualStat({
6674
+ name: H.ICE_CANDIDATES_CHANGED,
6675
+ value: 0,
6676
+ string_value: n,
6677
+ local_address: va(e),
6678
+ remote_address: va(t),
6679
+ transport: e.protocol
6680
+ }));
6681
+ }
6580
6682
  _calculatePacketLoss(e) {
6581
6683
  let t = /* @__PURE__ */ new Map(), n = {
6582
6684
  audio: {
@@ -6605,26 +6707,26 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
6605
6707
  return r;
6606
6708
  }
6607
6709
  };
6608
- function ma(e, ...t) {
6710
+ function _a(e, ...t) {
6609
6711
  for (let n of t) if (!Object.hasOwn(e, n) || e[n] === void 0) return !1;
6610
6712
  return !0;
6611
6713
  }
6612
- function ha(e, t = !1) {
6714
+ function va(e, t = !1) {
6613
6715
  if (e?.address) return e.address + (t ? `:${e.port}` : "");
6614
6716
  }
6615
- function ga(e) {
6717
+ function ya(e) {
6616
6718
  return e === void 0;
6617
6719
  }
6618
- function _a(e) {
6720
+ function ba(e) {
6619
6721
  return Number.isNaN(e) ? 0 : e;
6620
6722
  }
6621
6723
  //#endregion
6622
6724
  //#region src/static/Capabilities.ts
6623
- var va;
6725
+ var xa;
6624
6726
  (function(e) {
6625
6727
  function t() {
6626
6728
  return {
6627
- estimatedPerformanceIndex: pa.getEstimatedPerformanceIndex(),
6729
+ estimatedPerformanceIndex: ga.getEstimatedPerformanceIndex(),
6628
6730
  audioMix: !0,
6629
6731
  consumerUpdate: !0,
6630
6732
  producerNotificationDataChannelVersion: 8,
@@ -6650,8 +6752,8 @@ var va;
6650
6752
  };
6651
6753
  }
6652
6754
  e.get = t;
6653
- })(va || (va = {}));
6654
- var ya = va, ba = {
6755
+ })(xa || (xa = {}));
6756
+ var Sa = xa, Ca = {
6655
6757
  producerScreenTrack: () => !0,
6656
6758
  videoTracksCount: () => M.videoTracksCount > 0,
6657
6759
  waitingHall: () => !0,
@@ -6671,28 +6773,28 @@ var ya = va, ba = {
6671
6773
  p2pRelay: () => !1,
6672
6774
  waitForAdmin: () => M.waitForAdminInGroupCalls,
6673
6775
  hold: () => M.hold
6674
- }, xa = class {
6776
+ }, wa = class {
6675
6777
  static getFlags() {
6676
- let e = Object.values(ba), t = 0;
6778
+ let e = Object.values(Ca), t = 0;
6677
6779
  for (let n = 0; n < e.length; n++) e[n]() && (t |= 1 << n);
6678
6780
  return t.toString(16).toUpperCase();
6679
6781
  }
6680
6782
  static parseCapabilities(e) {
6681
6783
  let t = parseInt(e || "0", 16);
6682
- return Object.keys(ba).reduce((e, n, r) => (e[n] = !!(t & 1 << r), e), {});
6784
+ return Object.keys(Ca).reduce((e, n, r) => (e[n] = !!(t & 1 << r), e), {});
6683
6785
  }
6684
- }, Sa = 63n, Ca = 16383n, wa = 1073741823, Ta = 4611686018427387903n, Ea = class {
6786
+ }, Ta = 63n, Ea = 16383n, Da = 1073741823, Oa = 4611686018427387903n, ka = class {
6685
6787
  encode(e) {
6686
6788
  let t = typeof e == "number" ? BigInt(e) : e;
6687
- if (t <= Sa) return new Uint8Array([Number(t)]);
6688
- if (t <= Ca) return new Uint8Array([64 | Number(t >> 8n), Number(t & 255n)]);
6689
- if (t <= BigInt(wa)) return new Uint8Array([
6789
+ if (t <= Ta) return new Uint8Array([Number(t)]);
6790
+ if (t <= Ea) return new Uint8Array([64 | Number(t >> 8n), Number(t & 255n)]);
6791
+ if (t <= BigInt(Da)) return new Uint8Array([
6690
6792
  128 | Number(t >> 24n),
6691
6793
  Number(t >> 16n & 255n),
6692
6794
  Number(t >> 8n & 255n),
6693
6795
  Number(t & 255n)
6694
6796
  ]);
6695
- if (t <= Ta) return new Uint8Array([
6797
+ if (t <= Oa) return new Uint8Array([
6696
6798
  192 | Number(t >> 56n),
6697
6799
  Number(t >> 48n & 255n),
6698
6800
  Number(t >> 40n & 255n),
@@ -6704,7 +6806,7 @@ var ya = va, ba = {
6704
6806
  ]);
6705
6807
  throw RangeError("Number is too large to encode using varint");
6706
6808
  }
6707
- }, Da = class {
6809
+ }, Aa = class {
6708
6810
  decode(e) {
6709
6811
  let t = this.getNumBytesForLengthInteger(e);
6710
6812
  if (t < 0) throw Error("Invalid length prefix");
@@ -6730,9 +6832,9 @@ var ya = va, ba = {
6730
6832
  let t = e[0] & 192;
6731
6833
  return t === 0 ? 1 : t === 64 ? 2 : t === 128 ? 4 : t === 192 ? 8 : -1;
6732
6834
  }
6733
- }, Oa = class {
6835
+ }, ja = class {
6734
6836
  constructor(e) {
6735
- h(this, "encoder", void 0), h(this, "compression", void 0), h(this, "lengthEncoder", void 0), this.encoder = new TextEncoder(), this.lengthEncoder = new Ea(), this.compression = e ?? null;
6837
+ h(this, "encoder", void 0), h(this, "compression", void 0), h(this, "lengthEncoder", void 0), this.encoder = new TextEncoder(), this.lengthEncoder = new ka(), this.compression = e ?? null;
6736
6838
  }
6737
6839
  encode(e) {
6738
6840
  let t = this.encoder.encode(e);
@@ -6749,9 +6851,9 @@ var ya = va, ba = {
6749
6851
  default: return e;
6750
6852
  }
6751
6853
  }
6752
- }, ka = class {
6854
+ }, Ma = class {
6753
6855
  constructor(e) {
6754
- 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 Da(), this.compression = e ?? null, this.buffer = new Uint8Array(), this.expectedLength = null, this.offset = 0;
6856
+ 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 Aa(), this.compression = e ?? null, this.buffer = new Uint8Array(), this.expectedLength = null, this.offset = 0;
6755
6857
  }
6756
6858
  decode(e) {
6757
6859
  let t = [];
@@ -6781,12 +6883,12 @@ var ya = va, ba = {
6781
6883
  default: return e;
6782
6884
  }
6783
6885
  }
6784
- }, Aa = class {
6886
+ }, Na = class {
6785
6887
  static isBrowserSupported() {
6786
6888
  return !(!("WebTransport" in window && typeof WebTransport == "function") || T.browserName() === "Safari");
6787
6889
  }
6788
6890
  constructor(e, t = {}, n = R) {
6789
- 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 Oa(this.compression), this.decoder = new ka(this.compression), this.connect();
6891
+ 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 ja(this.compression), this.decoder = new Ma(this.compression), this.connect();
6790
6892
  }
6791
6893
  async send(e) {
6792
6894
  if (this.readyState !== WebSocket.OPEN) {
@@ -6912,9 +7014,9 @@ var ya = va, ba = {
6912
7014
  compression: this.compression
6913
7015
  }, n;
6914
7016
  }
6915
- }, ja = /* @__PURE__ */ function(e) {
7017
+ }, Pa = /* @__PURE__ */ function(e) {
6916
7018
  return e.EMPTY_ENDPOINT = "EMPTY_ENDPOINT", e.NETWORK_ERROR = "NETWORK_ERROR", e.ABORTED = "ABORTED", e;
6917
- }({}), Ma = class {
7019
+ }({}), Fa = class {
6918
7020
  constructor(e = R, t) {
6919
7021
  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", yr.WEBSOCKET), h(this, "_debug", void 0), this.handlers = t, this._debug = e;
6920
7022
  }
@@ -6964,7 +7066,7 @@ var ya = va, ba = {
6964
7066
  return;
6965
7067
  }
6966
7068
  let e = this._buildUrl(this.wtEndpoint, !0);
6967
- this.currentType = yr.WEBTRANSPORT, this.socket = new Aa(e, { congestionControl: "low-latency" }, this._debug), this._setSocketHandlers();
7069
+ this.currentType = yr.WEBTRANSPORT, this.socket = new Na(e, { congestionControl: "low-latency" }, this._debug), this._setSocketHandlers();
6968
7070
  }
6969
7071
  _connectWebSocket() {
6970
7072
  if (!this.endpoint) {
@@ -6987,10 +7089,10 @@ var ya = va, ba = {
6987
7089
  }
6988
7090
  _buildUrl(e, t) {
6989
7091
  let n = new URL(e), r = n.searchParams;
6990
- return r.set("platform", M.platform), r.set("appVersion", String(M.appVersion)), r.set("version", String(M.protocolVersion)), r.set("device", M.device), r.set("capabilities", xa.getFlags()), r.set("clientType", M.clientType), this.connectionType && r.set("tgt", this.connectionType), this.connectionType === vr.RETRY && this.lastStamp && r.set("recoverTs", String(this.lastStamp)), M.useParticipantListChunk && (r.set("partIdx", String(M.participantListChunkInitIndex)), M.participantListChunkInitCount !== null && r.set("partCount", String(M.participantListChunkInitCount))), t && (r.set("compression", "deflate-raw"), r.set("ua", navigator.userAgent)), this.peerId !== null && r.set("peerId", String(this.peerId)), n.toString();
7092
+ return r.set("platform", M.platform), r.set("appVersion", M.appVersion), r.set("version", String(M.protocolVersion)), r.set("device", M.device), r.set("capabilities", wa.getFlags()), r.set("clientType", M.clientType), this.connectionType && r.set("tgt", this.connectionType), this.connectionType === vr.RETRY && this.lastStamp && r.set("recoverTs", String(this.lastStamp)), M.useParticipantListChunk && (r.set("partIdx", String(M.participantListChunkInitIndex)), M.participantListChunkInitCount !== null && r.set("partCount", String(M.participantListChunkInitCount))), t && (r.set("compression", "deflate-raw"), r.set("ua", navigator.userAgent)), this.peerId !== null && r.set("peerId", String(this.peerId)), n.toString();
6991
7093
  }
6992
7094
  _canUseWebTransport() {
6993
- return !this.forceWebSocket && Aa.isBrowserSupported() && this.wtEndpoint !== null && M.webtransport;
7095
+ return !this.forceWebSocket && Na.isBrowserSupported() && this.wtEndpoint !== null && M.webtransport;
6994
7096
  }
6995
7097
  _onOpen() {
6996
7098
  this._startDoctor(), this.handlers.onOpen();
@@ -7044,31 +7146,31 @@ var ya = va, ba = {
7044
7146
  _stopDoctor() {
7045
7147
  window.clearTimeout(this.doctorTimer), this.doctorTimer = 0;
7046
7148
  }
7047
- }, Na = "open", Pa = 10, Fa = {
7149
+ }, Ia = "open", La = 10, Ra = {
7048
7150
  CONVERSATION_ENDED: "conversation-ended",
7049
7151
  OBSOLETE_CLIENT: "gen.obsoleteClient",
7050
7152
  INVALID_TOKEN: "invalid-token",
7051
7153
  PARTICIPANT_NOT_FOUND: "participant-not-found",
7052
7154
  ILLEGAL_PARTICIPANT_STATE: "illegal-participant-state",
7053
7155
  SERVICE_UNAVAILABLE: "service-unavailable"
7054
- }, Ia = {
7055
- [Fa.CONVERSATION_ENDED]: "conversation-ended",
7056
- [Fa.OBSOLETE_CLIENT]: "obsolete-client",
7057
- [Fa.INVALID_TOKEN]: "invalid-token",
7058
- [Fa.PARTICIPANT_NOT_FOUND]: "participant-not-found",
7059
- [Fa.ILLEGAL_PARTICIPANT_STATE]: "illegal-participant-state",
7060
- [Fa.SERVICE_UNAVAILABLE]: "service-unavailable"
7156
+ }, za = {
7157
+ [Ra.CONVERSATION_ENDED]: "conversation-ended",
7158
+ [Ra.OBSOLETE_CLIENT]: "obsolete-client",
7159
+ [Ra.INVALID_TOKEN]: "invalid-token",
7160
+ [Ra.PARTICIPANT_NOT_FOUND]: "participant-not-found",
7161
+ [Ra.ILLEGAL_PARTICIPANT_STATE]: "illegal-participant-state",
7162
+ [Ra.SERVICE_UNAVAILABLE]: "service-unavailable"
7061
7163
  };
7062
- function La(e, t) {
7164
+ function Ba(e, t) {
7063
7165
  return e.errorMessage ?? e.message ?? e.error ?? t;
7064
7166
  }
7065
- var Ra = new Set([
7167
+ var Va = new Set([
7066
7168
  D.CALLER_IS_BLOCKED,
7067
7169
  D.ENDED,
7068
7170
  D.NOT_FOUND,
7069
7171
  D.PARTICIPANT_LIMIT_REACHED,
7070
7172
  D.SERVICE_UNAVAILABLE
7071
- ]), za = class e extends En {
7173
+ ]), Ha = class e extends En {
7072
7174
  static get WAIT_CONNECTION_DELAY() {
7073
7175
  return M.waitConnectionDelay;
7074
7176
  }
@@ -7079,7 +7181,7 @@ var Ra = new Set([
7079
7181
  return !this.disposed && this.transport.readyState !== null;
7080
7182
  }
7081
7183
  constructor(e = R, t = null, n = null, r = null, i = null) {
7082
- 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, "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 $n(e), this.transport = new Ma(e, {
7184
+ 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, "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 $n(e), this.transport = new Fa(e, {
7083
7185
  onConnecting: this._onTransportConnecting.bind(this),
7084
7186
  onOpen: this._onOpen.bind(this),
7085
7187
  onMessage: this._onMessage.bind(this),
@@ -7166,20 +7268,20 @@ var Ra = new Set([
7166
7268
  return this._send(B.TRANSMIT_DATA, {
7167
7269
  participantId: e,
7168
7270
  data: r
7169
- }, !0, Pa);
7271
+ }, !0, La);
7170
7272
  }
7171
7273
  async acceptCall(e) {
7172
7274
  return this._send(B.ACCEPT_CALL, { mediaSettings: e });
7173
7275
  }
7174
7276
  async changeMediaSettings(e) {
7175
- return this._send(B.CHANGE_MEDIA_SETTINGS, { mediaSettings: e }, !0, Pa);
7277
+ return this._send(B.CHANGE_MEDIA_SETTINGS, { mediaSettings: e }, !0, La);
7176
7278
  }
7177
7279
  async changeParticipantState(e, t) {
7178
7280
  let n = { participantState: { state: e } };
7179
7281
  return t && (n.participantId = t), this._sendRaw(B.CHANGE_PARTICIPANT_STATE, n);
7180
7282
  }
7181
7283
  async hold(e) {
7182
- let t = ya.get();
7284
+ let t = Sa.get();
7183
7285
  return this._send(B.HOLD, {
7184
7286
  hold: e,
7185
7287
  capabilities: e ? void 0 : t
@@ -7411,7 +7513,7 @@ var Ra = new Set([
7411
7513
  if (this.disposed) throw new wn(e);
7412
7514
  switch (t.route) {
7413
7515
  case "producer":
7414
- this.datachannelCommandsQueue.push(t), this.producerCommandDataChannel?.readyState === Na && this._handleCommandsQueue(this.datachannelCommandsQueue);
7516
+ this.datachannelCommandsQueue.push(t), this.producerCommandDataChannel?.readyState === Ia && this._handleCommandsQueue(this.datachannelCommandsQueue);
7415
7517
  break;
7416
7518
  case "websocket":
7417
7519
  if (this.transport.readyState === null) {
@@ -7481,9 +7583,9 @@ var Ra = new Set([
7481
7583
  }
7482
7584
  _handleErrorMessage(e) {
7483
7585
  this._logger?.log(C.SOCKET_ACTION, `error-${e.error}`);
7484
- let t = this._getSocketType(), n = e.error ? this._createSignalingCallError(e.error, e.errorCode, t) : void 0, r = La(e, "Unknown signaling error");
7586
+ let t = this._getSocketType(), n = e.error ? this._createSignalingCallError(e.error, e.errorCode, t) : void 0, r = Ba(e, "Unknown signaling error");
7485
7587
  switch (this._debug.debug(`[signaling] error message [${e.sequence}]`, e), e.sequence && this.responseHandlers[e.sequence] && this._handleCommandResponse(!1, e), e.error) {
7486
- case Fa.SERVICE_UNAVAILABLE:
7588
+ case Ra.SERVICE_UNAVAILABLE:
7487
7589
  let i = new O(D.SERVICE_UNAVAILABLE, {
7488
7590
  callError: n,
7489
7591
  message: r,
@@ -7495,7 +7597,7 @@ var Ra = new Set([
7495
7597
  reason: D.SERVICE_UNAVAILABLE
7496
7598
  });
7497
7599
  break;
7498
- case Fa.CONVERSATION_ENDED:
7600
+ case Ra.CONVERSATION_ENDED:
7499
7601
  this.conversationReject ? this.conversationReject(new O(e.reason || x.SIGNALING_FAILED, {
7500
7602
  callError: n,
7501
7603
  message: r,
@@ -7506,22 +7608,22 @@ var Ra = new Set([
7506
7608
  reason: e.reason
7507
7609
  });
7508
7610
  break;
7509
- case Fa.ILLEGAL_PARTICIPANT_STATE:
7510
- case Fa.PARTICIPANT_NOT_FOUND:
7611
+ case Ra.ILLEGAL_PARTICIPANT_STATE:
7612
+ case Ra.PARTICIPANT_NOT_FOUND:
7511
7613
  this._throwError(new O(x.SIGNALING_FAILED, {
7512
7614
  callError: n,
7513
7615
  message: r,
7514
7616
  remote: !0
7515
7617
  }));
7516
7618
  break;
7517
- case Fa.OBSOLETE_CLIENT:
7619
+ case Ra.OBSOLETE_CLIENT:
7518
7620
  this.conversationReject?.(new O(e.reason || D.OBSOLETE_CLIENT, {
7519
7621
  callError: n,
7520
7622
  message: r,
7521
7623
  remote: !0
7522
7624
  }));
7523
7625
  break;
7524
- case Fa.INVALID_TOKEN:
7626
+ case Ra.INVALID_TOKEN:
7525
7627
  default:
7526
7628
  if (e.sequence || t === yr.WEBTRANSPORT) break;
7527
7629
  if (this.connected) this._throwError(new O(e.reason || x.SIGNALING_FAILED, {
@@ -7623,13 +7725,13 @@ var Ra = new Set([
7623
7725
  let r = this.responseHandlers[n.sequence];
7624
7726
  window.clearTimeout(r.responseTimer);
7625
7727
  let i = W.measureMark(r.statMarkName);
7626
- 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(La(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(La(n, `Response timeout [${r.name}]`)))) : r.responseTimer = window.setTimeout(() => this._handleCommandResponse(t, n), e.WAIT_RESPONSE_DELAY);
7728
+ 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(Ba(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(Ba(n, `Response timeout [${r.name}]`)))) : r.responseTimer = window.setTimeout(() => this._handleCommandResponse(t, n), e.WAIT_RESPONSE_DELAY);
7627
7729
  }
7628
7730
  _handleCommandsQueue(e) {
7629
7731
  for (; e.length > 0;) {
7630
7732
  let t = e.shift();
7631
7733
  if (this._debug.debug(`[signaling] command send [${t.sequence}]`, `'${t.name}'`, t.params), t.route === "producer") {
7632
- if (this.producerCommandDataChannel?.readyState !== Na) {
7734
+ if (this.producerCommandDataChannel?.readyState !== Ia) {
7633
7735
  t.reject(/* @__PURE__ */ Error(`Invalid data channel state: ${this.producerCommandDataChannel?.readyState}`));
7634
7736
  return;
7635
7737
  }
@@ -7714,7 +7816,7 @@ var Ra = new Set([
7714
7816
  }
7715
7817
  _onTransportFailed(e) {
7716
7818
  switch (e.failure) {
7717
- case ja.EMPTY_ENDPOINT:
7819
+ case Pa.EMPTY_ENDPOINT:
7718
7820
  this.conversationReject?.(new O(x.SIGNALING_FAILED, {
7719
7821
  callError: {
7720
7822
  scope: "internal",
@@ -7725,7 +7827,7 @@ var Ra = new Set([
7725
7827
  remote: e.remote
7726
7828
  }));
7727
7829
  break;
7728
- case ja.NETWORK_ERROR:
7830
+ case Pa.NETWORK_ERROR:
7729
7831
  this._fail(new O(D.NETWORK_ERROR, { callError: {
7730
7832
  scope: "network",
7731
7833
  source: e.source,
@@ -7733,7 +7835,7 @@ var Ra = new Set([
7733
7835
  description: "connection-failed"
7734
7836
  } }));
7735
7837
  break;
7736
- case ja.ABORTED:
7838
+ case Pa.ABORTED:
7737
7839
  this._debug.debug("[signaling] aborted reconnect"), this._fail(new O(D.CANCELED));
7738
7840
  break;
7739
7841
  }
@@ -7745,7 +7847,7 @@ var Ra = new Set([
7745
7847
  this._debug.warn("[signaling] socket is dead, trying to reconnect"), this._logTransportStat(br.FAILED_PINGS);
7746
7848
  }
7747
7849
  _attachNotificationCallError(e) {
7748
- e.callError || !e.reason || e.reason === D.FAILED || e.reason === D.UNKNOWN_ERROR || !Ra.has(e.reason) && !e.errorCode || (e.callError = {
7850
+ e.callError || !e.reason || e.reason === D.FAILED || e.reason === D.UNKNOWN_ERROR || !Va.has(e.reason) && !e.errorCode || (e.callError = {
7749
7851
  scope: "server",
7750
7852
  source: this._getSocketType(),
7751
7853
  code: e.errorCode || "protocol",
@@ -7753,7 +7855,7 @@ var Ra = new Set([
7753
7855
  });
7754
7856
  }
7755
7857
  _createSignalingCallError(e, t, n) {
7756
- let r = Ia[e];
7858
+ let r = za[e];
7757
7859
  if (r) return {
7758
7860
  scope: "server",
7759
7861
  source: n,
@@ -7775,39 +7877,39 @@ var Ra = new Set([
7775
7877
  ...t
7776
7878
  });
7777
7879
  }
7778
- }, Ba = /* @__PURE__ */ function(e) {
7880
+ }, Ua = /* @__PURE__ */ function(e) {
7779
7881
  return e.INCOMING = "INCOMING", e.OUTGOING = "OUTGOING", e.JOINING = "JOINING", e;
7780
- }(Ba || {}), Va = /* @__PURE__ */ function(e) {
7882
+ }(Ua || {}), Wa = /* @__PURE__ */ function(e) {
7781
7883
  return e.USER = "USER", e.GROUP = "GROUP", e.CHAT = "CHAT", e;
7782
- }(Va || {}), Ha = /* @__PURE__ */ function(e) {
7884
+ }(Wa || {}), Ga = /* @__PURE__ */ function(e) {
7783
7885
  return e.ATTENDEE = "ATTENDEE", e.HAND_UP = "HAND_UP", e;
7784
- }(Ha || {}), Ua = /* @__PURE__ */ function(e) {
7886
+ }(Ga || {}), Ka = /* @__PURE__ */ function(e) {
7785
7887
  return e.ADD_PARTICIPANT = "ADD_PARTICIPANT", e.RECORD = "RECORD", e.MOVIE_SHARE = "MOVIE_SHARE", e;
7786
- }(Ua || {}), Wa = /* @__PURE__ */ function(e) {
7888
+ }(Ka || {}), qa = /* @__PURE__ */ function(e) {
7787
7889
  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;
7788
- }(Wa || {});
7789
- function Ga(e, t) {
7890
+ }(qa || {});
7891
+ function Ja(e, t) {
7790
7892
  if (e.length !== t.length) return !1;
7791
7893
  for (let n of e) if (!t.includes(n)) return !1;
7792
7894
  return !0;
7793
7895
  }
7794
- function Ka(e, t) {
7896
+ function Ya(e, t) {
7795
7897
  let n = new Set(e);
7796
7898
  for (let [e, r] of Object.entries(t)) r ? n.add(e) : n.delete(e);
7797
7899
  return Array.from(n);
7798
7900
  }
7799
7901
  //#endregion
7800
7902
  //#region src/enums/MuteState.ts
7801
- var qa = /* @__PURE__ */ function(e) {
7903
+ var Xa = /* @__PURE__ */ function(e) {
7802
7904
  return e.UNMUTE = "UNMUTE", e.MUTE = "MUTE", e.MUTE_PERMANENT = "MUTE_PERMANENT", e;
7803
- }(qa || {}), Z = /* @__PURE__ */ function(e) {
7905
+ }(Xa || {}), Z = /* @__PURE__ */ function(e) {
7804
7906
  return e.CALLED = "CALLED", e.ACCEPTED = "ACCEPTED", e.REJECTED = "REJECTED", e.HUNGUP = "HUNGUP", e;
7805
- }(Z || {}), Ja = /* @__PURE__ */ function(e) {
7907
+ }(Z || {}), Za = /* @__PURE__ */ function(e) {
7806
7908
  return e.UPDATE = "UPDATE", e.REMOVE = "REMOVE", e.ACTIVATE = "ACTIVATE", e.TIMEOUT = "TIMEOUT", e;
7807
- }(Ja || {}), Ya = /* @__PURE__ */ function(e) {
7909
+ }(Za || {}), Qa = /* @__PURE__ */ function(e) {
7808
7910
  return e.NO_AVAILABLE_TRACKS = "no-available-tracks", e.UNKNOWN_ERROR = "unknown-error", e;
7809
- }(Ya || {});
7810
- function Xa(e) {
7911
+ }(Qa || {});
7912
+ function $a(e) {
7811
7913
  switch (e) {
7812
7914
  case 1: return "no-available-tracks";
7813
7915
  default: return "unknown-error";
@@ -7815,17 +7917,17 @@ function Xa(e) {
7815
7917
  }
7816
7918
  //#endregion
7817
7919
  //#region src/enums/UserRole.ts
7818
- var Za = /* @__PURE__ */ function(e) {
7920
+ var eo = /* @__PURE__ */ function(e) {
7819
7921
  return e.CREATOR = "CREATOR", e.ADMIN = "ADMIN", e;
7820
- }(Za || {});
7821
- function Qa(e, t) {
7922
+ }(eo || {});
7923
+ function to(e, t) {
7822
7924
  if (e.length !== t.length) return !1;
7823
7925
  for (let n of e) if (!t.includes(n)) return !1;
7824
7926
  return !0;
7825
7927
  }
7826
7928
  //#endregion
7827
7929
  //#region src/static/ParticipantConnectionStatusUtils.ts
7828
- var $a;
7930
+ var no;
7829
7931
  (function(e) {
7830
7932
  function t(e) {
7831
7933
  let t = e?.transport ?? e?.lastEffective ?? N.WAITING, n = {
@@ -7877,8 +7979,8 @@ var $a;
7877
7979
  shouldNotify: !0
7878
7980
  });
7879
7981
  }
7880
- })($a || ($a = {}));
7881
- var eo = $a, to = /* @__PURE__ */ function(e) {
7982
+ })(no || (no = {}));
7983
+ var ro = no, io = /* @__PURE__ */ function(e) {
7882
7984
  return e.USER = "USER", e.ANONYM = "ANONYM", e.GROUP = "GROUP", e;
7883
7985
  }({}), Q;
7884
7986
  (function(e) {
@@ -7941,7 +8043,7 @@ var eo = $a, to = /* @__PURE__ */ function(e) {
7941
8043
  })(Q || (Q = {}));
7942
8044
  //#endregion
7943
8045
  //#region src/types/WaitingHall.ts
7944
- function no(e) {
8046
+ function ao(e) {
7945
8047
  try {
7946
8048
  return btoa(JSON.stringify(e));
7947
8049
  } catch (t) {
@@ -7949,7 +8051,7 @@ function no(e) {
7949
8051
  }
7950
8052
  return null;
7951
8053
  }
7952
- function ro(e) {
8054
+ function oo(e) {
7953
8055
  try {
7954
8056
  return JSON.parse(atob(e));
7955
8057
  } catch (t) {
@@ -7959,12 +8061,12 @@ function ro(e) {
7959
8061
  }
7960
8062
  //#endregion
7961
8063
  //#region src/utils/Conversation.ts
7962
- var io = (e, t) => j.objectReduce(e, (e, n, r) => (n === t && e.push(r), e), []);
7963
- function ao(e) {
8064
+ var so = (e, t) => j.objectReduce(e, (e, n, r) => (n === t && e.push(r), e), []);
8065
+ function co(e) {
7964
8066
  if (e.conversation?.muteStates) return e.conversation.muteStates;
7965
8067
  if (e.muteState && e.muteOptions) return e.muteOptions.reduce((t, n) => (t[n] = e.muteState, t), {});
7966
8068
  }
7967
- function oo(e, t) {
8069
+ function lo(e, t) {
7968
8070
  switch (e) {
7969
8071
  case S.AUDIO: return !!t.isAudioEnabled;
7970
8072
  case S.AUDIO_SHARING: return !!t.isAudioSharingEnabled;
@@ -7973,12 +8075,12 @@ function oo(e, t) {
7973
8075
  default: return !1;
7974
8076
  }
7975
8077
  }
7976
- function so(e, t) {
8078
+ function uo(e, t) {
7977
8079
  return j.objectReduce(e, (e, n, r) => {
7978
8080
  switch (n) {
7979
- case qa.MUTE:
7980
- case qa.MUTE_PERMANENT:
7981
- oo(r, t) || (e[r] = n);
8081
+ case Xa.MUTE:
8082
+ case Xa.MUTE_PERMANENT:
8083
+ lo(r, t) || (e[r] = n);
7982
8084
  break;
7983
8085
  default:
7984
8086
  e[r] = n;
@@ -7987,19 +8089,19 @@ function so(e, t) {
7987
8089
  return e;
7988
8090
  }, {});
7989
8091
  }
7990
- function co(e) {
8092
+ function fo(e) {
7991
8093
  let { muteStates: t = {}, mediaSettings: n } = e;
7992
- return so(t, n);
8094
+ return uo(t, n);
7993
8095
  }
7994
- function lo(e, t) {
8096
+ function po(e, t) {
7995
8097
  let n = e.conversation.participants.find((t) => j.comparePeerId(t.peerId, e.peerId));
7996
8098
  if (!n) return t;
7997
8099
  let { mediaSettings: r } = n;
7998
- return so(t, r);
8100
+ return uo(t, r);
7999
8101
  }
8000
8102
  //#endregion
8001
8103
  //#region src/utils/IceServers.ts
8002
- function uo(e) {
8104
+ function mo(e) {
8003
8105
  if (!e) return null;
8004
8106
  let t = Array.from(new Set((e.urls ?? []).map((e) => e.trim()).filter((e) => e.length > 0)));
8005
8107
  return t.length ? {
@@ -8007,8 +8109,8 @@ function uo(e) {
8007
8109
  urls: t
8008
8110
  } : null;
8009
8111
  }
8010
- function fo(e, t) {
8011
- let n = [], r = uo(e), i = uo(t);
8112
+ function ho(e, t) {
8113
+ let n = [], r = mo(e), i = mo(t);
8012
8114
  if (r && n.push(r), i) {
8013
8115
  let e = [...i.urls];
8014
8116
  e.push(`${e[e.length - 1]}?transport=tcp`), n.push({
@@ -8020,7 +8122,7 @@ function fo(e, t) {
8020
8122
  }
8021
8123
  //#endregion
8022
8124
  //#region src/utils/Lz4.ts
8023
- function po(e, t) {
8125
+ function go(e, t) {
8024
8126
  let n = new Uint8Array(t), r = 0, i = 0;
8025
8127
  for (; r < e.length && i < t;) {
8026
8128
  let a = e[r++], o = a >> 4, s = a & 15;
@@ -8047,7 +8149,7 @@ function po(e, t) {
8047
8149
  }
8048
8150
  //#endregion
8049
8151
  //#region src/utils/SerializeLatest.ts
8050
- function mo(e) {
8152
+ function _o(e) {
8051
8153
  let t, n = !1, r, i = async () => {
8052
8154
  let t = !1, i;
8053
8155
  for (; n;) {
@@ -8068,7 +8170,7 @@ function mo(e) {
8068
8170
  }
8069
8171
  //#endregion
8070
8172
  //#region src/classes/AudioFix.ts
8071
- var ho = class {
8173
+ var vo = class {
8072
8174
  constructor(e, t = R, n = null) {
8073
8175
  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;
8074
8176
  }
@@ -8106,7 +8208,7 @@ var ho = class {
8106
8208
  this._debug.warn("[AudioFix] Failed to fix RV (no packets): video restart", e);
8107
8209
  }));
8108
8210
  }
8109
- }, go = class {
8211
+ }, yo = class {
8110
8212
  constructor(e, t = !1, n = R, r = null) {
8111
8213
  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();
8112
8214
  }
@@ -8207,13 +8309,13 @@ var ho = class {
8207
8309
  };
8208
8310
  //#endregion
8209
8311
  //#region src/classes/conversation/ConversationResponseValidator.ts
8210
- function _o(e, t) {
8211
- e || yo(t, "response-empty"), e.id || yo(t, "id-empty"), e.endpoint || yo(t, "endpoint-empty"), !vo(e.stun_server) && !vo(e.turn_server) && yo(t, "ice-servers-empty");
8312
+ function bo(e, t) {
8313
+ e || So(t, "response-empty"), e.id || So(t, "id-empty"), e.endpoint || So(t, "endpoint-empty"), !xo(e.stun_server) && !xo(e.turn_server) && So(t, "ice-servers-empty");
8212
8314
  }
8213
- function vo(e) {
8315
+ function xo(e) {
8214
8316
  return Array.isArray(e?.urls) && e.urls.length > 0;
8215
8317
  }
8216
- function yo(e, t) {
8318
+ function So(e, t) {
8217
8319
  let n = e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), r = e === "fastStart" || e === "fastJoin";
8218
8320
  throw new O(r ? e === "fastStart" ? D.FAST_START_ERROR : D.FAST_JOIN_ERROR : D.UNKNOWN_ERROR, {
8219
8321
  message: `Invalid ${e} response: ${t}`,
@@ -8232,7 +8334,7 @@ function yo(e, t) {
8232
8334
  }
8233
8335
  //#endregion
8234
8336
  //#region src/classes/DebugInfo.ts
8235
- var bo = 90, xo = 3, So = class extends b {
8337
+ var Co = 90, wo = 3, To = class extends b {
8236
8338
  constructor(e = R) {
8237
8339
  super(), h(this, "_lastMemoryStat", {
8238
8340
  percent: 0,
@@ -8248,11 +8350,11 @@ var bo = 90, xo = 3, So = class extends b {
8248
8350
  let e = window?.performance?.memory;
8249
8351
  if (!e || !e.usedJSHeapSize || !e.jsHeapSizeLimit) return;
8250
8352
  let t = Number((100 * e.usedJSHeapSize / e.jsHeapSizeLimit).toFixed(2)), n = Number((e.usedJSHeapSize / 1024 / 1024).toFixed(1));
8251
- t > bo ? this._debug.warn(`High memory usage: ${t}% (${n} MiB)`) : (!this._lastMemoryStat.percent || Math.abs(t - this._lastMemoryStat.percent) >= xo) && (this._debug.debug(`Memory usage: ${t}% (${n} MiB)`), this._lastMemoryStat.percent = t, this._lastMemoryStat.bytes = e.usedJSHeapSize);
8353
+ t > Co ? this._debug.warn(`High memory usage: ${t}% (${n} MiB)`) : (!this._lastMemoryStat.percent || Math.abs(t - this._lastMemoryStat.percent) >= wo) && (this._debug.debug(`Memory usage: ${t}% (${n} MiB)`), this._lastMemoryStat.percent = t, this._lastMemoryStat.bytes = e.usedJSHeapSize);
8252
8354
  }
8253
- }, Co = class {
8254
- constructor({ api: e, debug: t, getParticipants: n, isMe: r, updateDisplayLayout: i }) {
8255
- h(this, "_api", void 0), h(this, "_debug", void 0), h(this, "_getParticipants", void 0), h(this, "_isMe", void 0), h(this, "_updateDisplayLayout", void 0), h(this, "_requestedLayouts", {}), h(this, "_uncertainLayouts", {}), h(this, "_pendingRequests", null), h(this, "_pendingPromises", []), h(this, "_lastRequests", null), h(this, "_timer", null), h(this, "_inFlight", !1), h(this, "_lastFlushAt", null), h(this, "_generation", 0), h(this, "_forceNextFlush", !1), this._api = e, this._debug = t, this._getParticipants = n, this._isMe = r, this._updateDisplayLayout = i;
8355
+ }, Eo = class {
8356
+ constructor({ api: e, debug: t, getParticipants: n, isMe: r, updateDisplayLayout: i, onNonFatalError: a }) {
8357
+ 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;
8256
8358
  }
8257
8359
  request(e) {
8258
8360
  this._pendingRequests = e.slice(), this._lastRequests = e.slice();
@@ -8288,11 +8390,16 @@ var bo = 90, xo = 3, So = class extends b {
8288
8390
  this._pendingRequests = null, this._pendingPromises = [];
8289
8391
  let r = {};
8290
8392
  try {
8291
- r = this._getRequestLayouts(t);
8292
- let i = this._forceNextFlush || Object.keys(this._uncertainLayouts).length > 0;
8393
+ let i = this._getRequestLayouts(t);
8394
+ if (!i) {
8395
+ n.forEach(({ resolve: e }) => e());
8396
+ return;
8397
+ }
8398
+ r = i;
8399
+ let a = this._forceNextFlush || Object.keys(this._uncertainLayouts).length > 0;
8293
8400
  this._forceNextFlush = !1;
8294
- let a = this._getDiff(r, i);
8295
- a.length && await this._updateDisplayLayout(a), e === this._generation && (this._requestedLayouts = r, this._uncertainLayouts = {}), n.forEach(({ resolve: e }) => e());
8401
+ let o = this._getDiff(r, a);
8402
+ o.length && await this._updateDisplayLayout(o), e === this._generation && (this._requestedLayouts = r, this._uncertainLayouts = {}), n.forEach(({ resolve: e }) => e());
8296
8403
  } catch (t) {
8297
8404
  e === this._generation ? (this._uncertainLayouts = {
8298
8405
  ...this._uncertainLayouts,
@@ -8303,30 +8410,30 @@ var bo = 90, xo = 3, So = class extends b {
8303
8410
  }
8304
8411
  }
8305
8412
  _getRequestLayouts(e) {
8306
- let t = {}, n = this._getParticipants();
8307
- for (let r of e) {
8308
- let e = typeof r.uid == "object" ? r.uid : Q.fromId(r.uid), i = this._api.getCachedOkIdByExternalId(e);
8309
- if (!i) {
8310
- this._debug.log(`Unknown participant external ID ${typeof r.uid == "object" ? Q.toString(r.uid) : r.uid}`);
8413
+ let t = {}, n = [], r = this._getParticipants();
8414
+ for (let i of e) {
8415
+ let e = typeof i.uid == "object" ? i.uid : Q.fromId(i.uid), a = this._api.getCachedParticipantIdByExternalId(e);
8416
+ if (!a) {
8417
+ this._debug.log(`Unknown participant external ID ${typeof i.uid == "object" ? Q.toString(i.uid) : i.uid}`), n.push(e.id);
8311
8418
  continue;
8312
8419
  }
8313
- if (!n[i] && !this._isMe(i)) continue;
8314
- let a = Mn({
8315
- participantId: i,
8316
- mediaType: r.mediaType,
8317
- streamName: r.streamName
8420
+ if (!r[a] && !this._isMe(a)) continue;
8421
+ let o = Mn({
8422
+ participantId: a,
8423
+ mediaType: i.mediaType,
8424
+ streamName: i.streamName
8318
8425
  });
8319
- t[a] = {
8320
- uid: r.uid,
8321
- mediaType: r.mediaType,
8322
- width: r.width,
8323
- height: r.height,
8324
- fit: r.cover ? "cv" : "cn",
8325
- ...r.priority === void 0 ? {} : { priority: r.priority },
8326
- ...r.streamName === void 0 ? {} : { streamName: r.streamName }
8426
+ t[o] = {
8427
+ uid: i.uid,
8428
+ mediaType: i.mediaType,
8429
+ width: i.width,
8430
+ height: i.height,
8431
+ fit: i.cover ? "cv" : "cn",
8432
+ ...i.priority === void 0 ? {} : { priority: i.priority },
8433
+ ...i.streamName === void 0 ? {} : { streamName: i.streamName }
8327
8434
  };
8328
8435
  }
8329
- return t;
8436
+ return n.length ? (this._onNonFatalError(`Participant ID mapping not found for external IDs "${Array.from(new Set(n)).join("\", \"")}" while handling requestDisplayLayout`), null) : t;
8330
8437
  }
8331
8438
  _getDiff(e, t = !1) {
8332
8439
  let n = [];
@@ -8360,7 +8467,7 @@ var bo = 90, xo = 3, So = class extends b {
8360
8467
  let n = e, r = t;
8361
8468
  return n.width !== r.width || n.height !== r.height || n.fit !== r.fit || n.priority !== r.priority;
8362
8469
  }
8363
- }, wo = 44100, To = class {
8470
+ }, Do = 44100, Oo = class {
8364
8471
  constructor(e, t) {
8365
8472
  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]);
8366
8473
  try {
@@ -8377,7 +8484,7 @@ var bo = 90, xo = 3, So = class extends b {
8377
8484
  _getBins() {
8378
8485
  if (!this._fftBins || !this._analyser) return new Uint8Array();
8379
8486
  this._analyser.getByteFrequencyData(this._fftBins);
8380
- let e = wo / this._fftBins.length, t = Math.ceil(M.voiceParams.minFreq / e), n = Math.floor(M.voiceParams.maxFreq / e);
8487
+ let e = Do / this._fftBins.length, t = Math.ceil(M.voiceParams.minFreq / e), n = Math.floor(M.voiceParams.maxFreq / e);
8381
8488
  return this._fftBins.subarray(t, n);
8382
8489
  }
8383
8490
  getLevel() {
@@ -8390,7 +8497,7 @@ var bo = 90, xo = 3, So = class extends b {
8390
8497
  destroy() {
8391
8498
  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);
8392
8499
  }
8393
- }, Eo = class extends b {
8500
+ }, ko = class extends b {
8394
8501
  constructor(e) {
8395
8502
  super(), h(this, "_detector", null), h(this, "_interval", null);
8396
8503
  let t = () => {
@@ -8406,7 +8513,7 @@ var bo = 90, xo = 3, So = class extends b {
8406
8513
  }), this.subscribe(e, qt.SOURCE_READY, n), n();
8407
8514
  }
8408
8515
  init(e) {
8409
- this._stopDetector(), this._detector = new To("local", e.clone());
8516
+ this._stopDetector(), this._detector = new Oo("local", e.clone());
8410
8517
  }
8411
8518
  _stopDetector() {
8412
8519
  this._detector && (this._detector.track.stop(), this._detector.destroy(), this._detector = null);
@@ -8414,7 +8521,7 @@ var bo = 90, xo = 3, So = class extends b {
8414
8521
  destroy() {
8415
8522
  this.unsubscribe(), this._interval && (window.clearTimeout(this._interval), this._interval = null), this._stopDetector();
8416
8523
  }
8417
- }, Do = class {
8524
+ }, Ao = class {
8418
8525
  constructor(e, t = R) {
8419
8526
  h(this, "processor", void 0), h(this, "queue", []), h(this, "isProcessing", !1), h(this, "_debug", void 0), this.processor = e, this._debug = t;
8420
8527
  }
@@ -8434,9 +8541,9 @@ var bo = 90, xo = 3, So = class extends b {
8434
8541
  this.isProcessing = !1;
8435
8542
  }
8436
8543
  }
8437
- }, Oo = /* @__PURE__ */ function(e) {
8544
+ }, jo = /* @__PURE__ */ function(e) {
8438
8545
  return e.VOLUMES_DETECTED = "VOLUMES_DETECTED", e;
8439
- }({}), ko = class extends b {
8546
+ }({}), Mo = class extends b {
8440
8547
  constructor(e) {
8441
8548
  super(), h(this, "_detectors", /* @__PURE__ */ new Map()), h(this, "_interval", null), h(this, "_activeParticipants", void 0), h(this, "_removedParticipants", void 0), h(this, "_topology", void 0), this._topology = e.getTopology(), this.subscribe(e, X.REMOTE_TRACK_ADDED, this._onRemoteTrackAdded.bind(this)), this.subscribe(e, X.REMOTE_TRACK_REMOVED, this._onRemoteTrackRemoved.bind(this)), this.subscribe(e, X.SIGNALLED_ACTIVE_PARTICIPANTS, this._onSignalledActiveParticipants.bind(this)), this.subscribe(e, X.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this));
8442
8549
  }
@@ -8444,7 +8551,7 @@ var bo = 90, xo = 3, So = class extends b {
8444
8551
  this._interval && (window.clearTimeout(this._interval), this._interval = null), this.unsubscribe(), this._destroyDetectors();
8445
8552
  }
8446
8553
  _onRemoteTrackAdded(e, t, n) {
8447
- if (n.kind === k.audio && (this._detectors.get(e)?.destroy(), this._detectors.set(e, new To(e, n)), !this._interval)) {
8554
+ if (n.kind === k.audio && (this._detectors.get(e)?.destroy(), this._detectors.set(e, new Oo(e, n)), !this._interval)) {
8448
8555
  let e = () => {
8449
8556
  this._collectVolumes(), this._interval = window.setTimeout(e, M.voiceParams.interval);
8450
8557
  };
@@ -8476,14 +8583,14 @@ var bo = 90, xo = 3, So = class extends b {
8476
8583
  }
8477
8584
  _getAudioTrackLevelByParticipantId(e) {
8478
8585
  if (this._isTransparentAudioMode()) return this._getTransparentAudioLevelByParticipantId(e);
8479
- let t = this._detectors.get(qr.AUDIO_MIX);
8586
+ let t = this._detectors.get(Xr.AUDIO_MIX);
8480
8587
  return t ? t.getLevel() : null;
8481
8588
  }
8482
8589
  _getTransparentAudioLevelByParticipantId(e) {
8483
8590
  if (!this._activeParticipants?.includes(e)) return null;
8484
8591
  let t = null;
8485
8592
  return this._detectors.forEach((e, n) => {
8486
- if (!n.startsWith(`${qr.TRANSPARENT_AUDIO_TRACK_PREFIX}-`)) return;
8593
+ if (!n.startsWith(`${Xr.TRANSPARENT_AUDIO_TRACK_PREFIX}-`)) return;
8487
8594
  let r = e.getLevel();
8488
8595
  (!t || r.real > t.real) && (t = r);
8489
8596
  }), t;
@@ -8502,11 +8609,11 @@ var bo = 90, xo = 3, So = class extends b {
8502
8609
  e.destroy();
8503
8610
  }), this._detectors.clear();
8504
8611
  }
8505
- }, Ao = /* @__PURE__ */ function(e) {
8612
+ }, No = /* @__PURE__ */ function(e) {
8506
8613
  return e.SPEAKER_CHANGED = "SPEAKER_CHANGED", e;
8507
- }({}), jo = class extends b {
8614
+ }({}), Po = class extends b {
8508
8615
  constructor(e, t, n) {
8509
- super(), h(this, "_speakerId", null), h(this, "_serverSideSpeakerDetection", !1), this._serverSideSpeakerDetection = n === J.SERVER, this.subscribe(e, Oo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this.subscribe(t, X.SIGNALLED_SPEAKER_CHANGED, this._onServerSpeakerChanged.bind(this)), this.subscribe(t, X.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this));
8616
+ 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, X.SIGNALLED_SPEAKER_CHANGED, this._onServerSpeakerChanged.bind(this)), this.subscribe(t, X.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this));
8510
8617
  }
8511
8618
  destroy() {
8512
8619
  this.unsubscribe();
@@ -8528,9 +8635,9 @@ var bo = 90, xo = 3, So = class extends b {
8528
8635
  _onTopologyChanged(e) {
8529
8636
  this._serverSideSpeakerDetection = e === J.SERVER;
8530
8637
  }
8531
- }, Mo = 15e3, No = 15e3, Po = class extends b {
8638
+ }, Fo = 15e3, Io = 15e3, Lo = class extends b {
8532
8639
  constructor(e, t, n, r = R, i = null) {
8533
- super(), h(this, "_transport", void 0), h(this, "_volumes", {}), h(this, "_participants", {}), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_connectionTimeout", 0), h(this, "_connectionTimeoutSuppressed", !1), h(this, "_volumeTimeout", 0), this._transport = e, this._participants = n, this._debug = r, this._logger = i, this.subscribe(e, X.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(t, Oo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this));
8640
+ super(), h(this, "_transport", void 0), h(this, "_volumes", {}), h(this, "_participants", {}), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_connectionTimeout", 0), h(this, "_connectionTimeoutSuppressed", !1), h(this, "_volumeTimeout", 0), this._transport = e, this._participants = n, this._debug = r, this._logger = i, this.subscribe(e, X.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(t, jo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this));
8534
8641
  }
8535
8642
  destroy() {
8536
8643
  this.unsubscribe(), this._connectionTimeout && window.clearTimeout(this._connectionTimeout), this._volumeTimeout && window.clearTimeout(this._volumeTimeout);
@@ -8542,10 +8649,10 @@ var bo = 90, xo = 3, So = class extends b {
8542
8649
  this._connectionTimeout || !this._connectionTimeoutSuppressed || this._reportConnectionTimeout();
8543
8650
  }
8544
8651
  _getConnectionTimeout() {
8545
- return this._transport.getTopology() === J.DIRECT ? Mo : M.specListenerParams.connectionTimeout;
8652
+ return this._transport.getTopology() === J.DIRECT ? Fo : M.specListenerParams.connectionTimeout;
8546
8653
  }
8547
8654
  _getVolumeTimeout() {
8548
- return this._transport.getTopology() === J.DIRECT ? No : M.specListenerParams.volumeTimeout;
8655
+ return this._transport.getTopology() === J.DIRECT ? Io : M.specListenerParams.volumeTimeout;
8549
8656
  }
8550
8657
  _onTransportStateChanged(e, t) {
8551
8658
  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`));
@@ -8578,7 +8685,7 @@ var bo = 90, xo = 3, So = class extends b {
8578
8685
  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}`));
8579
8686
  }), e.length && this._debug.warn("There is silent participant, send callSpecError"), this._volumeTimeout = 0;
8580
8687
  }
8581
- }, Fo = class extends f {
8688
+ }, Ro = class extends f {
8582
8689
  constructor(e, t, n, r = () => void 0) {
8583
8690
  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();
8584
8691
  }
@@ -8658,7 +8765,7 @@ var bo = 90, xo = 3, So = class extends b {
8658
8765
  _now() {
8659
8766
  return Date.now() - this._serverTimeDelta;
8660
8767
  }
8661
- }, Io = "invalid-error-metadata", Lo = 64, Ro = new Set(Object.values(D)), zo = new Set(Object.values(x)), Bo = {
8768
+ }, zo = "invalid-error-metadata", Bo = 64, Vo = new Set(Object.values(D)), Ho = new Set(Object.values(x)), Uo = {
8662
8769
  [D.CANCELED]: {
8663
8770
  type: "semantic",
8664
8771
  reason: "canceled"
@@ -8779,7 +8886,7 @@ var bo = 90, xo = 3, So = class extends b {
8779
8886
  type: "semantic",
8780
8887
  reason: "obsolete_client"
8781
8888
  }
8782
- }, Vo = {
8889
+ }, Wo = {
8783
8890
  [x.MIC_CAMERA_PERMISSION]: {
8784
8891
  type: "direct-error",
8785
8892
  error: {
@@ -8868,14 +8975,14 @@ var bo = 90, xo = 3, So = class extends b {
8868
8975
  }
8869
8976
  }
8870
8977
  };
8871
- function Ho(e) {
8872
- if (typeof e != "string" && typeof e != "number" || typeof e == "number" && !Number.isFinite(e)) return Io;
8978
+ function Go(e) {
8979
+ if (typeof e != "string" && typeof e != "number" || typeof e == "number" && !Number.isFinite(e)) return zo;
8873
8980
  let t = String(e).trim();
8874
- if (!t) return Io;
8981
+ if (!t) return zo;
8875
8982
  let n = t.toLowerCase().replace(/[\s_:]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
8876
- return !n || !/^[a-z0-9.-]+$/.test(n) ? Io : n.length > Lo ? `${n.slice(0, Lo - 3)}...` : n;
8983
+ return !n || !/^[a-z0-9.-]+$/.test(n) ? zo : n.length > Bo ? `${n.slice(0, Bo - 3)}...` : n;
8877
8984
  }
8878
- function Uo(e) {
8985
+ function Ko(e) {
8879
8986
  if (!e || typeof e != "object") return !1;
8880
8987
  let t = e;
8881
8988
  switch (t.scope) {
@@ -8887,49 +8994,49 @@ function Uo(e) {
8887
8994
  default: return !1;
8888
8995
  }
8889
8996
  }
8890
- function Wo(e) {
8891
- let t = Ho(e.description);
8997
+ function qo(e) {
8998
+ let t = Go(e.description);
8892
8999
  if (e.scope === "unknown") return `unknown:${t}`;
8893
- let n = Ho(e.code);
9000
+ let n = Go(e.code);
8894
9001
  return e.scope === "internal" ? `internal:${n}:${t}` : `${e.scope}:${e.source}:${n}:${t}`;
8895
9002
  }
8896
- function Go(e, t) {
9003
+ function Jo(e, t) {
8897
9004
  return t === null ? e.type === "direct-error" ? {
8898
9005
  reason: "error",
8899
- string_value: Wo(e.error)
8900
- } : { reason: "failed" } : Uo(t) ? {
9006
+ string_value: qo(e.error)
9007
+ } : { reason: "failed" } : Ko(t) ? {
8901
9008
  reason: "error",
8902
- string_value: Wo(t)
9009
+ string_value: qo(t)
8903
9010
  } : { reason: "failed" };
8904
9011
  }
8905
- function Ko(e) {
9012
+ function Yo(e) {
8906
9013
  if (e.hangup) {
8907
- let t = Bo[e.hangup];
9014
+ let t = Uo[e.hangup];
8908
9015
  return t ? t.type === "semantic" ? e.hangup === D.OBSOLETE_CLIENT && e.custom_error?.vchat_detailed_api_error.code ? {
8909
9016
  reason: t.reason,
8910
9017
  string_value: e.custom_error.vchat_detailed_api_error.code
8911
- } : { reason: t.reason } : Go(t, e.callError) : { reason: "failed" };
9018
+ } : { reason: t.reason } : Jo(t, e.callError) : { reason: "failed" };
8912
9019
  }
8913
9020
  if (e.error) {
8914
- let t = Vo[e.error];
8915
- return t ? Go(t, e.callError) : { reason: "failed" };
9021
+ let t = Wo[e.error];
9022
+ return t ? Jo(t, e.callError) : { reason: "failed" };
8916
9023
  }
8917
9024
  return { reason: "failed" };
8918
9025
  }
8919
- function qo(e) {
8920
- return e instanceof O ? Ko(e) : typeof e == "string" && (Ro.has(e) || zo.has(e)) ? Ko(new O(e)) : { reason: "failed" };
9026
+ function Xo(e) {
9027
+ return e instanceof O ? Yo(e) : typeof e == "string" && (Vo.has(e) || Ho.has(e)) ? Yo(new O(e)) : { reason: "failed" };
8921
9028
  }
8922
9029
  //#endregion
8923
9030
  //#region src/classes/stat/CallLifecycleStats.ts
8924
- var Jo = {
9031
+ var Zo = {
8925
9032
  wallNow: () => Date.now(),
8926
9033
  monotonicNow: () => performance.now()
8927
9034
  };
8928
- function Yo(e) {
9035
+ function Qo(e) {
8929
9036
  return e === "anonym_join" ? "join" : e;
8930
9037
  }
8931
- var Xo = class {
8932
- constructor(e, t = Jo) {
9038
+ var $o = class {
9039
+ constructor(e, t = Zo) {
8933
9040
  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;
8934
9041
  }
8935
9042
  get firstMediaSentReported() {
@@ -8941,7 +9048,7 @@ var Xo = class {
8941
9048
  markInitializationStarted({ source: e, conversationId: t }) {
8942
9049
  if (this._destroyed || this._callStartLabel !== null) return;
8943
9050
  let n = this._clock.wallNow();
8944
- this._callStartLabel = Yo(e), this._lifecycleStartedAtMonotonic = this._clock.monotonicNow(), t && (this._conversationId = t), this._record({
9051
+ this._callStartLabel = Qo(e), this._lifecycleStartedAtMonotonic = this._clock.monotonicNow(), t && (this._conversationId = t), this._record({
8945
9052
  name: H.CALL_INIT,
8946
9053
  source: e
8947
9054
  }, n);
@@ -8969,7 +9076,7 @@ var Xo = class {
8969
9076
  !this._canRecord() || this._firstMediaSent || (this._firstMediaSent = !0, this._record({ name: H.FIRST_MEDIA_SENT }));
8970
9077
  }
8971
9078
  markFinished(e) {
8972
- this._finish(qo(e));
9079
+ this._finish(Xo(e));
8973
9080
  }
8974
9081
  markTerminated() {
8975
9082
  this._finish({ reason: "terminated" });
@@ -9020,7 +9127,7 @@ var Xo = class {
9020
9127
  ...n && { immediately: !0 }
9021
9128
  });
9022
9129
  }
9023
- }, Zo = class {
9130
+ }, es = class {
9024
9131
  constructor(e, t) {
9025
9132
  h(this, "_logger", void 0), h(this, "_codecUsages", /* @__PURE__ */ new Map()), h(this, "getCurrentTransportTopology", void 0), this._logger = e, this.getCurrentTransportTopology = t;
9026
9133
  }
@@ -9083,7 +9190,7 @@ var Xo = class {
9083
9190
  this.report(e);
9084
9191
  }), this._codecUsages.clear();
9085
9192
  }
9086
- }, Qo = class {
9193
+ }, ts = class {
9087
9194
  constructor(e) {
9088
9195
  h(this, "_logger", void 0), h(this, "_eventualLogs", /* @__PURE__ */ new Set()), h(this, "_lastCallStatContext", null), this._logger = e;
9089
9196
  }
@@ -9117,11 +9224,11 @@ var Xo = class {
9117
9224
  }
9118
9225
  _logEventualStat({ data: e, occurredAt: t }) {
9119
9226
  this._logger.logClientStats({
9120
- ...e,
9121
- ...this._lastCallStatContext ?? {}
9227
+ ...this._lastCallStatContext ?? {},
9228
+ ...e
9122
9229
  }, { occurredAt: t });
9123
9230
  }
9124
- }, $o = class {
9231
+ }, ns = class {
9125
9232
  constructor(e) {
9126
9233
  if (h(this, "q", void 0), h(this, "inits", []), h(this, "n", [
9127
9234
  1,
@@ -9180,7 +9287,7 @@ var Xo = class {
9180
9287
  5
9181
9288
  ];
9182
9289
  }
9183
- }, es = class {
9290
+ }, rs = class {
9184
9291
  constructor() {
9185
9292
  h(this, "n", 0), h(this, "mean", 0);
9186
9293
  }
@@ -9192,9 +9299,9 @@ var Xo = class {
9192
9299
  get avg() {
9193
9300
  return this.n ? this.mean : NaN;
9194
9301
  }
9195
- }, ts = class {
9302
+ }, is = class {
9196
9303
  constructor() {
9197
- h(this, "count", 0), h(this, "minVal", Infinity), h(this, "maxVal", -Infinity), h(this, "mean", new es()), h(this, "p50", new $o(.5)), h(this, "p95", new $o(.95));
9304
+ h(this, "count", 0), h(this, "minVal", Infinity), h(this, "maxVal", -Infinity), h(this, "mean", new rs()), h(this, "p50", new ns(.5)), h(this, "p95", new ns(.95));
9198
9305
  }
9199
9306
  add(e) {
9200
9307
  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++;
@@ -9212,11 +9319,11 @@ var Xo = class {
9212
9319
  get hasData() {
9213
9320
  return this.count > 0;
9214
9321
  }
9215
- }, ns = class {
9322
+ }, as = class {
9216
9323
  constructor(e) {
9217
9324
  h(this, "_logger", void 0), h(this, "trackerByTransport", {
9218
- ws: new ts(),
9219
- wt: new ts()
9325
+ ws: new is(),
9326
+ wt: new is()
9220
9327
  }), h(this, "lastSeen", {}), this._logger = e;
9221
9328
  }
9222
9329
  mark(e) {
@@ -9245,17 +9352,17 @@ var Xo = class {
9245
9352
  }
9246
9353
  destroy() {
9247
9354
  this.trackerByTransport = {
9248
- ws: new ts(),
9249
- wt: new ts()
9355
+ ws: new is(),
9356
+ wt: new is()
9250
9357
  }, this.lastSeen = {};
9251
9358
  }
9252
- }, rs = class {
9359
+ }, os = class {
9253
9360
  constructor(e) {
9254
9361
  h(this, "_logger", void 0), h(this, "trackerByCommand", /* @__PURE__ */ new Map()), this._logger = e;
9255
9362
  }
9256
9363
  mark(e, t, n) {
9257
9364
  let r = `${e}|${n}`, i;
9258
- this.trackerByCommand.has(r) ? i = this.trackerByCommand.get(r) : (i = new ts(), this.trackerByCommand.set(r, i)), i.add(t);
9365
+ this.trackerByCommand.has(r) ? i = this.trackerByCommand.get(r) : (i = new is(), this.trackerByCommand.set(r, i)), i.add(t);
9259
9366
  }
9260
9367
  logMetrics() {
9261
9368
  for (let [e, t] of this.trackerByCommand.entries()) {
@@ -9277,9 +9384,9 @@ var Xo = class {
9277
9384
  destroy() {
9278
9385
  this.trackerByCommand.clear();
9279
9386
  }
9280
- }, is = class {
9387
+ }, ss = class {
9281
9388
  constructor(e, t, n, r) {
9282
- h(this, "logger", void 0), h(this, "lifecycle", void 0), h(this, "statAggregator", void 0), h(this, "codecStatsAggregator", void 0), h(this, "pings", void 0), h(this, "signalingCommands", void 0), this.logger = new Fo(e, t, n, r), this.lifecycle = new Xo(this.logger), this.statAggregator = new Qo(this.logger), this.codecStatsAggregator = new Zo(this.logger, r), this.pings = new ns(this.logger), this.signalingCommands = new rs(this.logger);
9389
+ h(this, "logger", void 0), h(this, "lifecycle", void 0), h(this, "statAggregator", void 0), h(this, "codecStatsAggregator", void 0), h(this, "pings", void 0), h(this, "signalingCommands", void 0), this.logger = new Ro(e, t, n, r), this.lifecycle = new $o(this.logger), this.statAggregator = new ts(this.logger), this.codecStatsAggregator = new es(this.logger, r), this.pings = new as(this.logger), this.signalingCommands = new os(this.logger);
9283
9390
  }
9284
9391
  logHangup(e) {
9285
9392
  this.lifecycle.markFinished(e);
@@ -9290,7 +9397,7 @@ var Xo = class {
9290
9397
  destroy() {
9291
9398
  this.lifecycle.markTerminated(), this.lifecycle.destroy(), this.statAggregator.destroy(), this.codecStatsAggregator.destroy(), this.pings.destroy(), this.signalingCommands.destroy(), this.logger.destroy();
9292
9399
  }
9293
- }, as = class {
9400
+ }, cs = class {
9294
9401
  constructor(e) {
9295
9402
  h(this, "_statAggregator", void 0), h(this, "_isCallMarked", !1), h(this, "_isFinished", !1), h(this, "_callType", null), this._statAggregator = e;
9296
9403
  }
@@ -9315,8 +9422,8 @@ var Xo = class {
9315
9422
  call_type: this._callType
9316
9423
  }));
9317
9424
  }
9318
- }, os = 1e3, ss = 1e4;
9319
- function cs(e, t, n, r) {
9425
+ }, ls = 1e3, us = 1e4;
9426
+ function ds(e, t, n, r) {
9320
9427
  return new O(e, {
9321
9428
  callError: {
9322
9429
  scope: "external",
@@ -9327,11 +9434,11 @@ function cs(e, t, n, r) {
9327
9434
  message: r
9328
9435
  });
9329
9436
  }
9330
- var ls = 15, $ = class e extends b {
9437
+ var fs = 15, $ = class e extends b {
9331
9438
  constructor(e, t) {
9332
- super(), h(this, "_api", void 0), h(this, "_signaling", void 0), h(this, "_signalingActor", void 0), h(this, "_displayLayoutRequester", void 0), h(this, "_mediaSource", null), h(this, "_conversation", null), h(this, "_myLastRequestedLayouts", {}), h(this, "_state", "IDLE"), h(this, "_previousState", null), h(this, "_waitingHallHoldPending", !1), h(this, "_participantState", Z.CALLED), h(this, "_participants", {}), h(this, "_directTransportIsMaster", void 0), h(this, "_transport", null), h(this, "_debugInfo", null), h(this, "_debug", R.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", kr()), 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, "_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", mo((e) => {
9439
+ super(), h(this, "_api", void 0), h(this, "_signaling", void 0), h(this, "_signalingActor", void 0), h(this, "_displayLayoutRequester", void 0), h(this, "_mediaSource", null), h(this, "_conversation", null), h(this, "_myLastRequestedLayouts", {}), h(this, "_state", "IDLE"), h(this, "_previousState", null), h(this, "_waitingHallHoldPending", !1), h(this, "_participantState", Z.CALLED), h(this, "_participants", {}), h(this, "_directTransportIsMaster", void 0), h(this, "_transport", null), h(this, "_debugInfo", null), h(this, "_debug", R.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", kr()), 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, "_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", _o((e) => {
9333
9440
  if (this._mediaSource) return this._stats.logger.log(C.MEDIA_STATUS, e ? "video_1" : "video_0"), this._mediaSource.toggleVideo(e);
9334
- })), h(this, "_toggleLocalAudio", mo((e) => {
9441
+ })), h(this, "_toggleLocalAudio", _o((e) => {
9335
9442
  if (this._mediaSource) return this._stats.logger.log(C.MEDIA_STATUS, e ? "audio_1" : "audio_0"), this._mediaSource.toggleAudio(e);
9336
9443
  })), h(this, "_changeMediaSettings", j.debounce(async (e) => {
9337
9444
  if (this._signaling.ready) try {
@@ -9343,21 +9450,22 @@ var ls = 15, $ = class e extends b {
9343
9450
  captureAudio: !1
9344
9451
  });
9345
9452
  }
9346
- }, 100)), this._stats = new is(e, t, () => this._conversation?.id || null, () => this._transport?.getTopology() ?? this._conversation?.topology), this._api = e, this._signaling = new za(this._debug, this._stats.logger, this._stats.statAggregator, this._stats.pings, this._stats.signalingCommands), this._signalingActor = new Do(this._onSignalingNotification.bind(this), this._debug), this._displayLayoutRequester = new Co({
9453
+ }, 100)), this._stats = new ss(e, t, () => this._conversation?.id || null, () => this._transport?.getTopology() ?? this._conversation?.topology), this._api = e, this._signaling = new Ha(this._debug, this._stats.logger, this._stats.statAggregator, this._stats.pings, this._stats.signalingCommands), this._signalingActor = new Ao(this._onSignalingNotification.bind(this), this._debug), this._displayLayoutRequester = new Eo({
9347
9454
  api: this._api,
9348
9455
  debug: this._debug,
9349
9456
  getParticipants: () => this._participants,
9350
9457
  isMe: (e) => this._isMe(e),
9351
- updateDisplayLayout: (e) => this.updateDisplayLayout(e)
9458
+ updateDisplayLayout: (e) => this.updateDisplayLayout(e),
9459
+ onNonFatalError: (e) => this._onNonFatalError(e)
9352
9460
  }), this._onUnload = () => {
9353
9461
  this._stopFirstMediaSentProbe(), this._conversation && this._api && this._sendHangupApi(this._conversation.id, this._state === "IDLE" ? D.CANCELED : D.HUNGUP), this._stats.destroy();
9354
- }, window.addEventListener("pagehide", this._onUnload), this._statFirstMediaReceived = new as(this._stats.statAggregator), this._audioOutput = new go(this._statFirstMediaReceived, M.transparentAudio, this._debug, this._stats.logger), M.videoTracksCount > 0 && (this._cooldownQueueCleanupTimer = window.setInterval(this._cleanupCooldownQueue.bind(this), os));
9462
+ }, window.addEventListener("pagehide", this._onUnload), this._statFirstMediaReceived = new cs(this._stats.statAggregator), this._audioOutput = new yo(this._statFirstMediaReceived, M.transparentAudio, this._debug, this._stats.logger), M.videoTracksCount > 0 && (this._cooldownQueueCleanupTimer = window.setInterval(this._cleanupCooldownQueue.bind(this), ls));
9355
9463
  }
9356
9464
  static current() {
9357
9465
  return z.getActive() ?? (M.hold ? null : z.getFirst());
9358
9466
  }
9359
9467
  static hangupAfterInit(e) {
9360
- let t = us;
9468
+ let t = ps;
9361
9469
  if (t) {
9362
9470
  if (typeof e == "function" && (t._onFastHangup = e), t._delayedHangup === !1 && !t._conversation) {
9363
9471
  t._delayedHangup = !0, t._abortController?.abort(new O(D.CANCELED));
@@ -9384,6 +9492,9 @@ var ls = 15, $ = class e extends b {
9384
9492
  get isCallHeld() {
9385
9493
  return this._state === "HELD";
9386
9494
  }
9495
+ get isIncomingRinging() {
9496
+ return this._conversation?.direction === Ua.INCOMING && this._state === "IDLE";
9497
+ }
9387
9498
  static debugSessionId() {
9388
9499
  return e.current()?.debugSessionId ?? null;
9389
9500
  }
@@ -9401,8 +9512,14 @@ var ls = 15, $ = class e extends b {
9401
9512
  get debugSessionId() {
9402
9513
  return this._debug.sessionId;
9403
9514
  }
9404
- getCachedRawOkIdByExternalId(e) {
9405
- return this._api.getCachedRawOkIdByExternalId(e);
9515
+ getCachedParticipantIdByExternalId(e) {
9516
+ return this._api.getCachedParticipantIdByExternalId(e);
9517
+ }
9518
+ _onNonFatalError(e) {
9519
+ L.onNonFatalError(Error(e), this.id);
9520
+ }
9521
+ getIncomingCallerExternalId() {
9522
+ return this._conversation?.direction === Ua.INCOMING ? Object.values(this._participants).find((e) => !this._isMe(e.id))?.externalId ?? null : null;
9406
9523
  }
9407
9524
  _buildInternalParams() {
9408
9525
  let e = {
@@ -9412,24 +9529,24 @@ var ls = 15, $ = class e extends b {
9412
9529
  platform: M.platform,
9413
9530
  protocolVersion: M.protocolVersion,
9414
9531
  domainId: M.domain,
9415
- capabilities: xa.getFlags()
9532
+ capabilities: wa.getFlags()
9416
9533
  };
9417
9534
  return JSON.stringify(e);
9418
9535
  }
9419
9536
  async onStart({ opponentIds: e, opponentType: t, mediaOptions: n, payload: r = "", joiningAllowed: i = !1, requireAuthToJoin: a = !1, onlyAdminCanShareMovie: o, externalIds: s, onFastStart: c, conversationId: l }) {
9420
- let u = l ?? j.uuid(), d = (e?.length ?? 0) + (s?.length ?? 0), f = t === Va.USER && d === 1 ? M.calleeUnavailableWaitingTime : void 0;
9537
+ let u = l ?? j.uuid(), d = (e?.length ?? 0) + (s?.length ?? 0), f = t === Wa.USER && d === 1 ? M.calleeUnavailableWaitingTime : void 0;
9421
9538
  this._stats.lifecycle.markInitializationStarted({
9422
9539
  source: "outgoing",
9423
9540
  conversationId: u
9424
- }), this._debug.setConversationId(u), us = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
9541
+ }), this._debug.setConversationId(u), ps = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
9425
9542
  try {
9426
9543
  this._mediaSource = this._createMediaSource(), await this._mediaSource.request(n);
9427
9544
  let l = this._mediaSource.mediaSettings;
9428
- t === Va.CHAT || e && e.length > 1 ? this._logWithMediaSettings(C.OUTGOING_MULTIPARTY_CALL, l) : this._logWithMediaSettings(C.OUTGOING_CALL, l);
9545
+ t === Wa.CHAT || e && e.length > 1 ? this._logWithMediaSettings(C.OUTGOING_MULTIPARTY_CALL, l) : this._logWithMediaSettings(C.OUTGOING_CALL, l);
9429
9546
  let d = await this._startConversation({
9430
9547
  opponentIds: e,
9431
9548
  opponentType: t,
9432
- direction: Ba.OUTGOING,
9549
+ direction: Ua.OUTGOING,
9433
9550
  mediaOptions: n,
9434
9551
  payload: r,
9435
9552
  joiningAllowed: i,
@@ -9445,22 +9562,26 @@ var ls = 15, $ = class e extends b {
9445
9562
  description: "not-initialized-after-start"
9446
9563
  } });
9447
9564
  if (this._participantState = Z.ACCEPTED, this._changeMediaSettings(l), await this._processConnection(d), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), this._signaling.readyToSend(), this._delayedHangup) throw new O(D.CANCELED);
9448
- return this._debug.debug("Outgoing call", {
9565
+ if (this._debug.debug("Outgoing call", {
9449
9566
  opponentIds: e,
9450
9567
  opponentType: t,
9451
9568
  mediaOptions: n
9452
- }), this._processConnectionSharedMovieInfo(d), this._processConversationUrlSharingInfo(d), L.onLocalStream(this._mediaSource.getStream(), this._mediaSource.mediaSettings, this.id), L.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), void 0, this.id), this._onConversationParticipantListChunk(d), this._processPinnedParticipants(d), L.onLocalStatus(N.WAITING, this.id), this._toggleJoinAvailability(), this._changeFeatureSet(), this._changeNeedRate(), z.add(this), await z.setActive(this.id), us = null, this._conversation.concurrent && await this._acceptConcurrent(), f && !this._registeredPeerReceived && this._state !== "CLOSE" && (this._calleeUnavailableTimer = window.setTimeout(() => {
9569
+ }), this._processConnectionSharedMovieInfo(d), this._processConversationUrlSharingInfo(d), L.onLocalStream(this._mediaSource.getStream(), this._mediaSource.mediaSettings, this.id), L.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), void 0, this.id), this._onConversationParticipantListChunk(d), this._processPinnedParticipants(d), L.onLocalStatus(N.WAITING, this.id), this._toggleJoinAvailability(), this._changeFeatureSet(), this._changeNeedRate(), this._conversation?.concurrent) {
9570
+ let e = z.get(this._conversation.id);
9571
+ e && e !== this && e._close(new O(D.HUNGUP, { remote: !0 }));
9572
+ }
9573
+ return z.add(this), await z.setActive(this.id), ps = null, this._conversation.concurrent && await this._acceptConcurrent(), f && !this._registeredPeerReceived && this._state !== "CLOSE" && (this._calleeUnavailableTimer = window.setTimeout(() => {
9453
9574
  this._calleeUnavailableTimer = null, this._close(new O(D.CALLEE_UNAVAILABLE), { signalingReason: D.CANCELED });
9454
9575
  }, f)), this._conversation;
9455
9576
  } catch (e) {
9456
- throw us = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to start conversation" }), e;
9577
+ throw ps = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to start conversation" }), e;
9457
9578
  }
9458
9579
  }
9459
9580
  async onJoin(e) {
9460
9581
  this._stats.lifecycle.markInitializationStarted({
9461
9582
  source: e.anonymous ? "anonym_join" : "join",
9462
9583
  conversationId: e.conversationId
9463
- }), us = 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);
9584
+ }), ps = 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);
9464
9585
  try {
9465
9586
  let t = !!e.observedIds?.length;
9466
9587
  if (t && M.videoTracksCount > 0) throw this._debug.error("Observer mode: please set videoTracksCount=0"), new O(D.UNSUPPORTED, { callError: {
@@ -9477,9 +9598,9 @@ var ls = 15, $ = class e extends b {
9477
9598
  code: "conversation",
9478
9599
  description: "not-initialized-after-join"
9479
9600
  } });
9480
- return this._conversation.observer = t, L.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"), z.add(this), us = null, this._signaling.readyToSend(), L.onLocalStatus(this._conversation.waitForAdmin ? N.WAIT_FOR_ADMIN : N.WAITING_HALL, this.id), this._conversation) : this._onJoinPart2(r);
9601
+ return this._conversation.observer = t, L.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"), z.add(this), ps = null, this._signaling.readyToSend(), L.onLocalStatus(this._conversation.waitForAdmin ? N.WAIT_FOR_ADMIN : N.WAITING_HALL, this.id), this._conversation) : this._onJoinPart2(r);
9481
9602
  } catch (e) {
9482
- throw us = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
9603
+ throw ps = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
9483
9604
  }
9484
9605
  }
9485
9606
  async _onJoinPart2(e, t = !0, n = !1) {
@@ -9494,7 +9615,7 @@ var ls = 15, $ = class e extends b {
9494
9615
  if (this._delayedHangup) throw new O(D.CANCELED);
9495
9616
  this._processConnectionSharedMovieInfo(e), this._processConversationUrlSharingInfo(e), this._processConnectionAsrInfo(e);
9496
9617
  let r = this._extractExternalRoomsData(e.rooms?.rooms, e.rooms?.roomId);
9497
- L.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), r, this.id), this._onConversationParticipantListChunk(e), this._processPinnedParticipants(e), L.onLocalStatus(N.WAITING, this.id), this._toggleJoinAvailability(), this._changeNeedRate(), t && (this._state = "ACTIVE"), this._changeFeatureSet(), t && (z.add(this), n ? await this._holdLocally() : await z.setActive(this.id), us = null);
9618
+ L.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), r, this.id), this._onConversationParticipantListChunk(e), this._processPinnedParticipants(e), L.onLocalStatus(N.WAITING, this.id), this._toggleJoinAvailability(), this._changeNeedRate(), t && (this._state = "ACTIVE"), this._changeFeatureSet(), t && (z.add(this), n ? await this._holdLocally() : await z.setActive(this.id), ps = null);
9498
9619
  let i = this._extractLocalParticipantFromConnection(e);
9499
9620
  if (i) {
9500
9621
  let e = j.mapParticipantState(i);
@@ -9502,11 +9623,15 @@ var ls = 15, $ = class e extends b {
9502
9623
  }
9503
9624
  return t && this._openTransport(Object.values(this._participants), !1), this._conversation;
9504
9625
  } catch (e) {
9505
- throw us = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
9626
+ throw ps = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
9506
9627
  }
9507
9628
  }
9508
9629
  _extractExternalRooms(e) {
9509
- return e.map(this._convertRoomToExternal.bind(this)).filter((e) => !!e);
9630
+ let t = [], n = [];
9631
+ return e.forEach((e) => {
9632
+ let { room: r, missingParticipantIds: i } = this._convertRoomToExternal(e);
9633
+ r && n.push(r), t.push(...i);
9634
+ }), this._reportMissingExternalIds(t, "EXTRACT_EXTERNAL_ROOMS"), n.filter((e) => !!e);
9510
9635
  }
9511
9636
  _extractExternalRoomsData(e, t) {
9512
9637
  if (!e || !e.length) return;
@@ -9518,7 +9643,7 @@ var ls = 15, $ = class e extends b {
9518
9643
  z.reserve(e), this._reservedId = e, this._stats.lifecycle.markInitializationStarted({
9519
9644
  source: "incoming",
9520
9645
  conversationId: e
9521
- }), this._debug.setConversationId(e), us = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal), a && this._api.setUserId(a);
9646
+ }), this._debug.setConversationId(e), ps = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal), a && this._api.setUserId(a);
9522
9647
  try {
9523
9648
  let a = await this._prepareConversation(e, t, n, r, i);
9524
9649
  if (this._mediaSource = this._createMediaSource(), !this._conversation) throw new O(D.UNKNOWN_ERROR, { callError: {
@@ -9527,20 +9652,20 @@ var ls = 15, $ = class e extends b {
9527
9652
  description: "incoming-not-initialized"
9528
9653
  } });
9529
9654
  if (!a.conversation.participants.find((e) => e.state === Z.CALLED && e.id === this._conversation?.userId)) throw this._debug.log("Push rejected (there is an active call)"), this._stats.logger.log(C.PUSH, "rejected"), new O(D.REJECTED);
9530
- 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"), z.add(this), us = null, this._delayedHangup) throw new O(D.CANCELED);
9655
+ 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"), z.add(this), ps = null, this._delayedHangup) throw new O(D.CANCELED);
9531
9656
  } catch (e) {
9532
- throw us = null, this._cleanupRegistry(), this._close(e, {
9657
+ throw ps = null, this._cleanupRegistry(), this._close(e, {
9533
9658
  errorText: "Unable to handle inbound call push",
9534
9659
  signalingReason: e instanceof O && e.hangup === D.BUSY ? D.BUSY : void 0
9535
9660
  }), e;
9536
9661
  }
9537
9662
  }
9538
9663
  _isInWaitingHall(e) {
9539
- return !e.conversation || !e.conversation.options.includes(Wa.WAITING_HALL) ? !1 : this._isRestricted(e);
9664
+ return !e.conversation || !e.conversation.options.includes(qa.WAITING_HALL) ? !1 : this._isRestricted(e);
9540
9665
  }
9541
9666
  _isWaitForAdmin(e) {
9542
9667
  if (!e.conversation) return !1;
9543
- let t = e.conversation.options.includes(Wa.WAIT_FOR_ADMIN), n = e.conversation.options.includes(Wa.ADMIN_IS_HERE);
9668
+ let t = e.conversation.options.includes(qa.WAIT_FOR_ADMIN), n = e.conversation.options.includes(qa.ADMIN_IS_HERE);
9544
9669
  return !t || t && n ? !1 : this._isRestricted(e);
9545
9670
  }
9546
9671
  _isRestricted(e) {
@@ -9548,7 +9673,7 @@ var ls = 15, $ = class e extends b {
9548
9673
  return t && t.restricted || !1;
9549
9674
  }
9550
9675
  _isAudienceMode(e) {
9551
- return e.conversation?.options?.includes(Wa.AUDIENCE_MODE) || !1;
9676
+ return e.conversation?.options?.includes(qa.AUDIENCE_MODE) || !1;
9552
9677
  }
9553
9678
  _isAudienceModeListener() {
9554
9679
  return this._conversation?.audienceMode && this._conversation?.restricted;
@@ -9578,7 +9703,7 @@ var ls = 15, $ = class e extends b {
9578
9703
  let i = atob(n), a = new Uint8Array(i.length);
9579
9704
  for (let e = 0; e < i.length; e++) a[e] = i.charCodeAt(e);
9580
9705
  try {
9581
- let e = po(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);
9706
+ let e = go(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);
9582
9707
  return {
9583
9708
  token: i,
9584
9709
  endpoint: l,
@@ -9731,7 +9856,8 @@ var ls = 15, $ = class e extends b {
9731
9856
  D.CALLEE_IS_OFFLINE,
9732
9857
  D.CALLEE_UNAVAILABLE,
9733
9858
  D.CALLER_IS_BLOCKED,
9734
- D.CALLER_IS_REJECTED
9859
+ D.CALLER_IS_REJECTED,
9860
+ D.HAS_ACTIVE_CALL
9735
9861
  ].indexOf(e.hangup) !== -1 || e.hangup === D.REJECTED && !e.remote) {
9736
9862
  this._emitHangupOnce(e, i), this._destroy(r);
9737
9863
  return;
@@ -9780,10 +9906,10 @@ var ls = 15, $ = class e extends b {
9780
9906
  let t = await this._api.getConversationParams(e);
9781
9907
  this._debug.debug("Api.getConversationParams", t);
9782
9908
  let { turn_server: n, stun_server: r } = t;
9783
- return M.iceServers = fo(r, n), M.wssBase = t.endpoint, t.wt_endpoint && (M.wtsBase = t.wt_endpoint), M.wssToken = t.token, t.client_type && (M.clientType = t.client_type), t.external_user_type && (M.externalUserType = t.external_user_type), t;
9909
+ return M.iceServers = ho(r, n), M.wssBase = t.endpoint, t.wt_endpoint && (M.wtsBase = t.wt_endpoint), M.wssToken = t.token, t.client_type && (M.clientType = t.client_type), t.external_user_type && (M.externalUserType = t.external_user_type), t;
9784
9910
  }
9785
9911
  _setConversationParams({ turn_server: e, stun_server: t, endpoint: n, wt_endpoint: r, token: i, client_type: a }) {
9786
- M.iceServers = fo(t, e), M.wssBase = n, M.wssToken = i, r && (M.wtsBase = r), a && (M.clientType = a);
9912
+ M.iceServers = ho(t, e), M.wssBase = n, M.wssToken = i, r && (M.wtsBase = r), a && (M.clientType = a);
9787
9913
  }
9788
9914
  _buildSignalingEndpoint({ baseEndpoint: e, userId: t, type: n, deviceIdx: r, conversationId: i, token: a, conversationParams: o }) {
9789
9915
  let s = new URL(e), c = s.searchParams;
@@ -9815,10 +9941,10 @@ var ls = 15, $ = class e extends b {
9815
9941
  isVideo: f,
9816
9942
  joiningAllowed: a,
9817
9943
  requireAuthToJoin: o
9818
- }, this._abortController?.signal), !e) throw cs(D.FAST_START_ERROR, "invalid-response", "fast-start-response-empty");
9944
+ }, this._abortController?.signal), !e) throw ds(D.FAST_START_ERROR, "invalid-response", "fast-start-response-empty");
9819
9945
  if (!e.internalCallerParams) {
9820
9946
  let t = e.rejectedParticipants[0]?.status;
9821
- throw cs(D.FAST_START_ERROR, t ? "fast-start" : "invalid-response", t ?? "fast-start-internal-caller-params-empty", JSON.stringify(e));
9947
+ throw ds(D.FAST_START_ERROR, t ? "fast-start" : "invalid-response", t ?? "fast-start-internal-caller-params-empty", JSON.stringify(e));
9822
9948
  }
9823
9949
  } catch (e) {
9824
9950
  throw this._delayedHangup && this._abortController?.signal.aborted ? new O(D.CANCELED) : e instanceof O ? e : e instanceof Error ? new O(D.FAST_START_ERROR, { message: e.message }) : new O(D.FAST_START_ERROR, { message: String(e) });
@@ -9840,10 +9966,10 @@ var ls = 15, $ = class e extends b {
9840
9966
  token: new URL(t.endpoint).searchParams.get("token") ?? ""
9841
9967
  }, this._debug.debug("FastStart", p), m = "fastStart";
9842
9968
  } catch {
9843
- throw cs(D.FAST_START_ERROR, "invalid-response", "fast-start-internal-caller-params-invalid");
9969
+ throw ds(D.FAST_START_ERROR, "invalid-response", "fast-start-internal-caller-params-invalid");
9844
9970
  }
9845
9971
  } else p = await this._api.startConversation(d, e, t, f, i, a, o, { onlyAdminCanShareMovie: s }, c), this._debug.debug("Api.startConversation", p), m = "startConversation";
9846
- _o(p, m), this._setConversationParams(p), this._stats.lifecycle.bindConversationId(p.id);
9972
+ bo(p, m), this._setConversationParams(p), this._stats.lifecycle.bindConversationId(p.id);
9847
9973
  let ee = await this._connectSignaling(vr.START, p);
9848
9974
  return this._setConversation(p, ee, n), this._stats.lifecycle.markCallStarted(), ee;
9849
9975
  }
@@ -9868,9 +9994,9 @@ var ls = 15, $ = class e extends b {
9868
9994
  joinLink: i,
9869
9995
  isVideo: c,
9870
9996
  internalParams: this._buildInternalParams()
9871
- }, this._abortController?.signal), !e) throw cs(D.FAST_JOIN_ERROR, "invalid-response", "fast-join-response-empty");
9872
- if (!e.internalCallerParams) throw cs(D.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-empty", JSON.stringify(e));
9873
- if (!e.conversationId) throw cs(D.FAST_JOIN_ERROR, "invalid-response", "fast-join-conversation-id-empty", JSON.stringify(e));
9997
+ }, this._abortController?.signal), !e) throw ds(D.FAST_JOIN_ERROR, "invalid-response", "fast-join-response-empty");
9998
+ if (!e.internalCallerParams) throw ds(D.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-empty", JSON.stringify(e));
9999
+ if (!e.conversationId) throw ds(D.FAST_JOIN_ERROR, "invalid-response", "fast-join-conversation-id-empty", JSON.stringify(e));
9874
10000
  } catch (e) {
9875
10001
  throw this._delayedHangup && this._abortController?.signal.aborted ? new O(D.CANCELED) : e instanceof O ? e : e instanceof Error ? new O(D.FAST_JOIN_ERROR, { message: e.message }) : new O(D.FAST_JOIN_ERROR, { message: String(e) });
9876
10002
  }
@@ -9888,7 +10014,7 @@ var ls = 15, $ = class e extends b {
9888
10014
  token: new URL(t.endpoint).searchParams.get("token") ?? ""
9889
10015
  }, this._debug.debug("FastJoin", l), u = "fastJoin";
9890
10016
  } catch (e) {
9891
- throw e instanceof O ? e : cs(D.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-invalid");
10017
+ throw e instanceof O ? e : ds(D.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-invalid");
9892
10018
  }
9893
10019
  } else if (t) l = await this._api.joinConversation(t, c, r), u = "joinConversation";
9894
10020
  else if (i) l = await this._api.joinConversationByLink(i, c, a, o), u = "joinConversationByLink";
@@ -9897,13 +10023,13 @@ var ls = 15, $ = class e extends b {
9897
10023
  code: "join",
9898
10024
  description: "target-missing"
9899
10025
  } });
9900
- if (this._debug.debug("Api.joinConversation", l), l.id && this._stats.lifecycle.bindConversationId(l.id), _o(l, u), l.id) {
10026
+ if (this._debug.debug("Api.joinConversation", l), l.id && this._stats.lifecycle.bindConversationId(l.id), bo(l, u), l.id) {
9901
10027
  if (z.has(l.id)) throw new O(D.HAS_ACTIVE_CALL);
9902
10028
  z.reserve(l.id), this._reservedId = l.id;
9903
10029
  }
9904
10030
  this._setConversationParams(l);
9905
10031
  let d = await this._connectSignaling(vr.JOIN, l);
9906
- return this._setConversation(l, d, Ba.JOINING), this._stats.lifecycle.markCallStarted(), d;
10032
+ return this._setConversation(l, d, Ua.JOINING), this._stats.lifecycle.markCallStarted(), d;
9907
10033
  }
9908
10034
  async _prepareConversation(e, t = A.USER, n, r, i) {
9909
10035
  W.setMark(H.SIGNALING_CONNECTED), this._debug.debug("Conversation: push", {
@@ -9965,7 +10091,7 @@ var ls = 15, $ = class e extends b {
9965
10091
  }), l.wt_endpoint = c);
9966
10092
  }
9967
10093
  let u = await this._connectSignaling(vr.ACCEPT, l);
9968
- return z.callsLength >= M.maxParallelCalls || !M.hold && z.callsLength > 0 ? (this._debug.log("Push rejected (busy)"), this._stats.logger.log(C.PUSH, "busy"), Promise.reject(new O(D.BUSY))) : (this._setConversation(l, u, Ba.INCOMING, t), u);
10094
+ return z.callsLength >= M.maxParallelCalls || !M.hold && z.callsLength > 0 ? (this._debug.log("Push rejected (busy)"), this._stats.logger.log(C.PUSH, "busy"), Promise.reject(new O(D.BUSY))) : (this._setConversation(l, u, Ua.INCOMING, t), u);
9969
10095
  }
9970
10096
  _createParticipant(e, t, n = !0) {
9971
10097
  let r = Object.assign({
@@ -9988,19 +10114,17 @@ var ls = 15, $ = class e extends b {
9988
10114
  isInRoom: !1,
9989
10115
  markers: null
9990
10116
  }, e), i = !!r.externalId;
9991
- return i || (r.externalId = this._getParticipantId(t ?? r.id)), n && i && this._api.cacheExternalId(t ?? r.id, r.externalId), t && this._api.mapDecorativeId(t, r.id), r.observedIds?.length && (r.externalId.observer = !0), e.markers && (r.markers = this._denormalizeMarkers(r.id, e.markers)), r.connectionStatus = eo.create(r.connectionStatus), r;
10117
+ if (!i) {
10118
+ let e = this._getParticipantId(t ?? r.id);
10119
+ e && (r.externalId = e);
10120
+ }
10121
+ 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 = ro.create(r.connectionStatus), r;
9992
10122
  }
9993
10123
  _getParticipantId(e) {
9994
- try {
9995
- return this._api.userId(e);
9996
- } catch (e) {
9997
- throw this._close(e instanceof O ? e : new O(D.NETWORK_ERROR, { callError: {
9998
- scope: "network",
9999
- source: "api",
10000
- code: "fetch-failed",
10001
- description: "request-failed"
10002
- } }), { errorText: e }), e;
10003
- }
10124
+ let t = this._api.userId(e);
10125
+ if (t) return t;
10126
+ let { compositeUserId: n, deviceIdx: r } = j.decomposeParticipantId(e), { id: i, type: a } = j.decomposeId(n);
10127
+ return a === A.GROUP ? Q.fromId(String(i), void 0, r) : null;
10004
10128
  }
10005
10129
  _cacheParticipantExternalIds(e) {
10006
10130
  e.forEach((e) => {
@@ -10008,7 +10132,7 @@ var ls = 15, $ = class e extends b {
10008
10132
  if (n) {
10009
10133
  this._api.cacheExternalId(t, n);
10010
10134
  let r = j.composeDecorativeId(e), i = Q.fromSignalingParticipant(e);
10011
- r && i && (this._api.cacheExternalId(r, i), this._api.mapDecorativeId(e.decorativeUserId, e.id));
10135
+ r && i && (this._api.cacheExternalId(r, i), this._api.mapDecorativeId(r, t));
10012
10136
  }
10013
10137
  });
10014
10138
  }
@@ -10057,7 +10181,11 @@ var ls = 15, $ = class e extends b {
10057
10181
  audienceMode: this._isAudienceMode(t),
10058
10182
  restricted: this._isRestricted(t),
10059
10183
  urlSharingInfoByRoom: /* @__PURE__ */ new Map()
10060
- }, this._debug.setConversationId(t.conversation.id || e.id), e.p2p_forbidden && (M.forceRelayPolicy = e.p2p_forbidden), this._stats.logger.log(C.RELAY_POLICY, M.forceRelayPolicy ? "1" : "0"), this._changeFeatureSet(), this._changeFeaturesPerRole(), this._logDevices();
10184
+ }, this._debug.setConversationId(t.conversation.id || e.id), e.p2p_forbidden && (M.forceRelayPolicy = e.p2p_forbidden), this._stats.logger.log(C.RELAY_POLICY, M.forceRelayPolicy ? "1" : "0");
10185
+ let l = z.get(this._conversation.id);
10186
+ if (l && l !== this) this._conversation.concurrent = !0;
10187
+ else if (!M.hold && z.callsLength > 0) throw new O(D.HAS_ACTIVE_CALL);
10188
+ this._changeFeatureSet(), this._changeFeaturesPerRole(), this._logDevices();
10061
10189
  }
10062
10190
  _updateConversation(e) {
10063
10191
  if (!this._conversation) throw new O(D.UNKNOWN_ERROR, { callError: {
@@ -10069,7 +10197,7 @@ var ls = 15, $ = class e extends b {
10069
10197
  }
10070
10198
  _createMediaSource() {
10071
10199
  let e = new Yt(this._debug, this._stats.logger);
10072
- return this.subscribe(e, qt.SOURCE_CHANGED, this._onLocalMediaStreamChanged.bind(this)), this.subscribe(e, qt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._audioFix = new ho(e, this._debug, this._stats.logger), e;
10200
+ return this.subscribe(e, qt.SOURCE_CHANGED, this._onLocalMediaStreamChanged.bind(this)), this.subscribe(e, qt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._audioFix = new vo(e, this._debug, this._stats.logger), e;
10073
10201
  }
10074
10202
  async _connectSignaling(e, t) {
10075
10203
  this._signaling.setEndpoint(t.endpoint), this._signaling.setWebTransportEndpoint(t.wt_endpoint ? t.wt_endpoint : null), this.subscribe(this._signaling, G.NOTIFICATION, (e) => this._signalingActor.add(e)), this.subscribe(this._signaling, G.FAILED, this._onSignalingFailed.bind(this)), this.subscribe(this._signaling, G.RECONNECT, this._onSignalingReconnect.bind(this));
@@ -10077,7 +10205,7 @@ var ls = 15, $ = class e extends b {
10077
10205
  return this._stats.statAggregator.logEventualStat({ name: H.SIGNALING_CONNECTED }), n;
10078
10206
  }
10079
10207
  async _processConnection(e) {
10080
- 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(Ha.ATTENDEE, e.chatRoom.totalCount, e.chatRoom.firstParticipants, null, null);
10208
+ 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(Ga.ATTENDEE, e.chatRoom.totalCount, e.chatRoom.firstParticipants, null, null);
10081
10209
  }
10082
10210
  _onConversationParticipantListChunk(e) {
10083
10211
  let t = e.participants;
@@ -10146,7 +10274,7 @@ var ls = 15, $ = class e extends b {
10146
10274
  _registerParticipantLocalMuteState({ muteStates: e, unmuteOptions: t }) {
10147
10275
  if (!e) return;
10148
10276
  let n = async () => {
10149
- let n = io(e, qa.MUTE), r = io(e, qa.MUTE_PERMANENT);
10277
+ let n = so(e, Xa.MUTE), r = so(e, Xa.MUTE_PERMANENT);
10150
10278
  for (let i of [n, r]) i.length && await this._onMuteParticipant({
10151
10279
  muteStates: e,
10152
10280
  unmuteOptions: t,
@@ -10160,8 +10288,8 @@ var ls = 15, $ = class e extends b {
10160
10288
  if (!(!M.enableSessionStateUpdates || this._isMe(e))) return t;
10161
10289
  }
10162
10290
  _buildConnectionStatus(e, t, n, r = !1) {
10163
- return eo.create({
10164
- transport: r ? N.ONHOLD : eo.fromTransportState(n) ?? N.WAITING,
10291
+ return ro.create({
10292
+ transport: r ? N.ONHOLD : ro.fromTransportState(n) ?? N.WAITING,
10165
10293
  sessionState: this._remoteParticipantSessionState(e, t),
10166
10294
  sessionStateApplicable: this._isParticipantSessionStateApplicable(e)
10167
10295
  });
@@ -10170,12 +10298,12 @@ var ls = 15, $ = class e extends b {
10170
10298
  return M.enableSessionStateUpdates && !this._isMe(e) && this._conversation?.topology === J.SERVER;
10171
10299
  }
10172
10300
  _setTransportStatus(e, t) {
10173
- return eo.setTransport(e.connectionStatus, t);
10301
+ return ro.setTransport(e.connectionStatus, t);
10174
10302
  }
10175
10303
  _setSessionState(e, t) {
10176
- let n = eo.setSessionStateApplicable(e.connectionStatus, this._isParticipantSessionStateApplicable(e.id));
10304
+ let n = ro.setSessionStateApplicable(e.connectionStatus, this._isParticipantSessionStateApplicable(e.id));
10177
10305
  this._emitParticipantTransition(e, n);
10178
- let r = e.connectionStatus.sessionStateApplicable && e.id === this._activeSpeakerId && e.connectionStatus.transport === N.CONNECTED, i = eo.setSessionState(e.connectionStatus, t, r);
10306
+ let r = e.connectionStatus.sessionStateApplicable && e.id === this._activeSpeakerId && e.connectionStatus.transport === N.CONNECTED, i = ro.setSessionState(e.connectionStatus, t, r);
10179
10307
  return this._emitParticipantTransition(e, i), i;
10180
10308
  }
10181
10309
  _emitParticipantTransition(e, t, n = null) {
@@ -10187,33 +10315,40 @@ var ls = 15, $ = class e extends b {
10187
10315
  _getExistedParticipantByIdOrCreate(e) {
10188
10316
  let t = this._participants[e];
10189
10317
  if (t) return t;
10190
- let n = this._api.getDecorativeIdByInitialId(j.decomposeId(e).id), r = n ? j.composeUserId(n) : void 0, i = this._getParticipantId(e), { deviceIdx: a } = j.decomposeParticipantId(e);
10318
+ let n = this._api.getDecorativeIdByInitialId(e), r = this._getParticipantId(e), { deviceIdx: i } = j.decomposeParticipantId(e);
10191
10319
  return this._createParticipant({
10192
10320
  id: e,
10193
- externalId: {
10194
- ...i,
10195
- deviceIdx: a
10196
- }
10197
- }, r, !1);
10321
+ externalId: r ? {
10322
+ ...r,
10323
+ deviceIdx: i
10324
+ } : void 0
10325
+ }, n, !1);
10198
10326
  }
10199
10327
  _getExternalIdByParticipantId(e) {
10200
- if (this._isMe(e)) return this._conversation?.externalId;
10328
+ if (this._isMe(e)) return this._conversation?.externalId ?? null;
10201
10329
  if (M.useParticipantListChunk) return this._getExistedParticipantByIdOrCreate(e).externalId;
10202
10330
  let t = this._participants;
10203
10331
  if (t[e]?.externalId) return t[e].externalId;
10204
- {
10205
- let t = this._getParticipantId(e);
10206
- return this._api.cacheExternalId(e, t), t;
10207
- }
10332
+ let n = this._api.getCachedExternalIdByParticipantId(e);
10333
+ if (n) return n;
10334
+ let r = this._getParticipantId(e);
10335
+ return r && this._api.cacheExternalId(e, r), r;
10208
10336
  }
10209
- _getExternalIdsByOkIdsFromCache(e) {
10210
- return e.map((e) => this._api.getCachedExternalIdByOkId(e) ?? Q.fromId(String(e)));
10337
+ _getExternalIdsByParticipantIds(e) {
10338
+ let t = [], n = [];
10339
+ return e.forEach((e) => {
10340
+ let r = this._getExternalIdByParticipantId(e);
10341
+ r ? t.push(r) : n.push(e);
10342
+ }), {
10343
+ externalIds: t,
10344
+ missingIds: n
10345
+ };
10211
10346
  }
10212
- _getOrCacheExternalIdByCompositeId(e) {
10213
- let t = j.extractOkId(e), n = this._api.getCachedExternalIdByOkId(t);
10214
- if (n) return n;
10215
- let r = Q.fromId(String(t));
10216
- return this._api.cacheExternalId(e, r), r;
10347
+ _reportMissingExternalIds(e, t) {
10348
+ e.length && this._onNonFatalError(`External ID mapping not found for participants "${Array.from(new Set(e)).join("\", \"")}" while handling ${t}`);
10349
+ }
10350
+ _reportMissingExternalIdsById(e, t) {
10351
+ e.length && this._onNonFatalError(`Participant ID mapping not found for external IDs "${Array.from(new Set(e)).join("\", \"")}" while handling ${t}`);
10217
10352
  }
10218
10353
  _registerParticipantAndSetMarkersIfChunkEnabled(e, t) {
10219
10354
  if (M.useParticipantListChunk) {
@@ -10239,11 +10374,11 @@ var ls = 15, $ = class e extends b {
10239
10374
  this._onRoomSwitched(t, !0);
10240
10375
  }
10241
10376
  _processMuteStates(e, t = !1) {
10242
- let n = ao(e);
10377
+ let n = co(e);
10243
10378
  this._setMuteStatesForRoomId(n, null);
10244
10379
  for (let t of e.rooms?.rooms ?? []) this._setMuteStatesForRoomId(t.muteStates, t.id);
10245
10380
  let r = this._getMuteStatesForCurrentRoom();
10246
- t && (r = lo(e, r));
10381
+ t && (r = po(e, r));
10247
10382
  let i = Object.keys(r), a = this._conversation?.roomId;
10248
10383
  i.length && this._onMuteParticipant({
10249
10384
  muteStates: r,
@@ -10263,15 +10398,15 @@ var ls = 15, $ = class e extends b {
10263
10398
  }
10264
10399
  _allocateTransport() {
10265
10400
  if (!this._conversation || !this._mediaSource) return;
10266
- this._transport = new la(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 So(this._debug), this.subscribe(this._transport, X.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(this._transport, X.LOCAL_STATE_CHANGED, this._onTransportLocalStateChanged.bind(this)), this.subscribe(this._transport, X.REMOTE_TRACK_ADDED, this._onRemoteTrackAdded.bind(this)), this.subscribe(this._transport, X.REMOTE_TRACK_REMOVED, this._onRemoteTrackRemoved.bind(this)), this.subscribe(this._transport, X.AUDIO_MIX_STALL, this._onAudioMixStall.bind(this)), this.subscribe(this._transport, X.REMOTE_DATA_STATS, this._onRemoteDataStats.bind(this)), this.subscribe(this._transport, X.SIGNALLED_STALLED_PARTICIPANTS, this._onRemoteSignalledStall.bind(this)), this.subscribe(this._transport, X.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this)), this.subscribe(this._transport, X.NETWORK_STATUS, this._onNetworkStatus.bind(this)), this.subscribe(this._transport, X.REMOTE_STREAM_SECOND, this._onRemoteStreamSecond.bind(this)), this.subscribe(this._transport, X.PEER_CONNECTION_CLOSED, this._onPeerConnectionClosed.bind(this)), this.subscribe(this._transport, X.ASR_TRANSCRIPTION, this._onAsrTranscription.bind(this)), this.subscribe(this._transport, X.ANIMOJI_STREAM, this._onAnimojiStream.bind(this)), this.subscribe(this._transport, X.ANIMOJI_ERROR, this._onAnimojiError.bind(this));
10267
- let e = this._conversation.direction === Ba.OUTGOING && !this._conversation.concurrent, t = this._participants;
10401
+ this._transport = new fa(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 To(this._debug), this.subscribe(this._transport, X.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(this._transport, X.LOCAL_STATE_CHANGED, this._onTransportLocalStateChanged.bind(this)), this.subscribe(this._transport, X.REMOTE_TRACK_ADDED, this._onRemoteTrackAdded.bind(this)), this.subscribe(this._transport, X.REMOTE_TRACK_REMOVED, this._onRemoteTrackRemoved.bind(this)), this.subscribe(this._transport, X.AUDIO_MIX_STALL, this._onAudioMixStall.bind(this)), this.subscribe(this._transport, X.REMOTE_DATA_STATS, this._onRemoteDataStats.bind(this)), this.subscribe(this._transport, X.SIGNALLED_STALLED_PARTICIPANTS, this._onRemoteSignalledStall.bind(this)), this.subscribe(this._transport, X.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this)), this.subscribe(this._transport, X.NETWORK_STATUS, this._onNetworkStatus.bind(this)), this.subscribe(this._transport, X.REMOTE_STREAM_SECOND, this._onRemoteStreamSecond.bind(this)), this.subscribe(this._transport, X.PEER_CONNECTION_CLOSED, this._onPeerConnectionClosed.bind(this)), this.subscribe(this._transport, X.ASR_TRANSCRIPTION, this._onAsrTranscription.bind(this)), this.subscribe(this._transport, X.ANIMOJI_STREAM, this._onAnimojiStream.bind(this)), this.subscribe(this._transport, X.ANIMOJI_ERROR, this._onAnimojiError.bind(this));
10402
+ let e = this._conversation.direction === Ua.OUTGOING && !this._conversation.concurrent, t = this._participants;
10268
10403
  for (let n of Object.values(t)) (n.state === Z.ACCEPTED || n.state === Z.CALLED) && this._allocateParticipantTransport(n.id, e);
10269
10404
  }
10270
10405
  _createSpeakerDetector() {
10271
- this._transport && this._conversation && (this._volumesDetector = new ko(this._transport), this.subscribe(this._volumesDetector, Oo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this._speakerDetector = new jo(this._volumesDetector, this._transport, this._conversation.topology), this.subscribe(this._speakerDetector, Ao.SPEAKER_CHANGED, this._onSpeakerChanged.bind(this)), this._localVolumeDetector = new Eo(this._mediaSource));
10406
+ this._transport && this._conversation && (this._volumesDetector = new Mo(this._transport), this.subscribe(this._volumesDetector, jo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this._speakerDetector = new Po(this._volumesDetector, this._transport, this._conversation.topology), this.subscribe(this._speakerDetector, No.SPEAKER_CHANGED, this._onSpeakerChanged.bind(this)), this._localVolumeDetector = new ko(this._mediaSource));
10272
10407
  }
10273
10408
  _createSpecListener() {
10274
- this._transport && this._volumesDetector && (this._specListener = new Po(this._transport, this._volumesDetector, this._participants, this._debug, this._stats.logger));
10409
+ this._transport && this._volumesDetector && (this._specListener = new Lo(this._transport, this._volumesDetector, this._participants, this._debug, this._stats.logger));
10275
10410
  }
10276
10411
  _logDevices() {
10277
10412
  let e = T.getCameras().length, t = T.getMicrophones().length;
@@ -10370,7 +10505,7 @@ var ls = 15, $ = class e extends b {
10370
10505
  _onRemoveParticipant(e) {
10371
10506
  this._debug.debug(`Remove participant [${e}]`);
10372
10507
  let t = [], n = this._participants;
10373
- for (let r = 0; r <= ls; r++) {
10508
+ for (let r = 0; r <= fs; r++) {
10374
10509
  let i = n[j.compose(e, r)];
10375
10510
  i && t.push(i);
10376
10511
  }
@@ -10460,11 +10595,11 @@ var ls = 15, $ = class e extends b {
10460
10595
  this._waitingHallHoldPending = !1, await this._resumeLocalMedia(t, this._getWaitingForPromotionStatus()), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener();
10461
10596
  return;
10462
10597
  }
10463
- let n = ya.get();
10598
+ let n = Sa.get();
10464
10599
  await this._signaling.hold(!1, n), this._restoreStateAfterHold();
10465
10600
  let r = null;
10466
10601
  if (this._state === "IDLE" && this._participantState === Z.ACCEPTED && (r = Object.values(this._participants), r.some((e) => e.state === Z.ACCEPTED) && (this._state = "ACTIVE", this._changeFeatureSet())), await this._resumeLocalMedia(t, N.WAITING), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), this._state === "ACTIVE") {
10467
- let e = this._conversation?.direction === Ba.OUTGOING && !this._conversation.concurrent;
10602
+ let e = this._conversation?.direction === Ua.OUTGOING && !this._conversation.concurrent;
10468
10603
  this._openTransport(r ?? Object.values(this._participants), e);
10469
10604
  }
10470
10605
  }
@@ -10498,30 +10633,34 @@ var ls = 15, $ = class e extends b {
10498
10633
  async updateDisplayLayout(e) {
10499
10634
  if (e.length < 1 || !this._signaling.ready) return;
10500
10635
  this._debug.log(`Update display layout request [${this._signaling.getNextCommandSequenceNumber()}]`, e);
10501
- let t = {}, n = [], r = this._participants;
10502
- for (let i of e) {
10503
- let e = typeof i.uid == "object" ? i.uid : Q.fromId(i.uid), a = this._api.getCachedOkIdByExternalId(e);
10504
- if (!a) {
10636
+ let t = {}, n = [], r = [], i = this._participants;
10637
+ for (let a of e) {
10638
+ let e = typeof a.uid == "object" ? a.uid : Q.fromId(a.uid), o = this._api.getCachedParticipantIdByExternalId(e);
10639
+ if (!o) {
10505
10640
  let t = Q.toString(e);
10506
- this._debug.log(`Unknown participant external ID ${t}`);
10641
+ this._debug.log(`Unknown participant external ID ${t}`), r.push(e.id);
10507
10642
  continue;
10508
10643
  }
10509
- let o = Mn({
10510
- participantId: a,
10511
- mediaType: i.mediaType,
10512
- streamName: i.streamName
10513
- }), s = r[a];
10514
- s ? n.push(() => {
10515
- s.lastRequestedLayouts[o] = i;
10516
- }) : this._isMe(a) && n.push(() => {
10517
- this._myLastRequestedLayouts[o] = i;
10518
- }), Dn(i) ? (this._isMe(a) && n.push(() => {
10519
- delete this._myLastRequestedLayouts[o];
10520
- }), this._streamIdByStreamDescription.has(o) && !this._cooldownTimestampByStreamDescription.has(o) && this._cooldownTimestampByStreamDescription.set(o, Date.now())) : (this._cooldownTimestampByStreamDescription.delete(o), !this._streamIdByStreamDescription.has(o) && M.videoTracksCount > 0 && this._streamIdByStreamDescription.set(o, null), t[o] = i), i.mediaType === V.SCREEN && !Dn(i) && W.setMark(W.getMarkNameScreenshareFirstFrame(a));
10521
- }
10522
- let i = this._cooldownTimestampByStreamDescription.keys();
10644
+ let s = Mn({
10645
+ participantId: o,
10646
+ mediaType: a.mediaType,
10647
+ streamName: a.streamName
10648
+ }), c = i[o];
10649
+ c ? n.push(() => {
10650
+ c.lastRequestedLayouts[s] = a;
10651
+ }) : this._isMe(o) && n.push(() => {
10652
+ this._myLastRequestedLayouts[s] = a;
10653
+ }), Dn(a) ? (this._isMe(o) && n.push(() => {
10654
+ delete this._myLastRequestedLayouts[s];
10655
+ }), this._streamIdByStreamDescription.has(s) && !this._cooldownTimestampByStreamDescription.has(s) && this._cooldownTimestampByStreamDescription.set(s, Date.now())) : (this._cooldownTimestampByStreamDescription.delete(s), !this._streamIdByStreamDescription.has(s) && M.videoTracksCount > 0 && this._streamIdByStreamDescription.set(s, null), t[s] = a), a.mediaType === V.SCREEN && !Dn(a) && W.setMark(W.getMarkNameScreenshareFirstFrame(o));
10656
+ }
10657
+ if (r.length) {
10658
+ this._reportMissingExternalIdsById(r, "updateDisplayLayout");
10659
+ return;
10660
+ }
10661
+ let a = this._cooldownTimestampByStreamDescription.keys();
10523
10662
  for (; this._streamIdByStreamDescription.size > M.videoTracksCount;) {
10524
- let e = i.next();
10663
+ let e = a.next();
10525
10664
  if (e.done) {
10526
10665
  this._debug.error("Cannot accommodate all streaming requests: tracks available " + M.videoTracksCount + "; requested streams: " + Array.from(this._streamIdByStreamDescription.keys()));
10527
10666
  break;
@@ -10583,13 +10722,13 @@ var ls = 15, $ = class e extends b {
10583
10722
  let n = Nn(e), a = i[n.participantId];
10584
10723
  if (a) {
10585
10724
  let e;
10586
- typeof t == "number" ? e = Xa(t) : (this._debug.warn(`Unexpected error code ${t} received for participant ${n.participantId}`), e = Ya.UNKNOWN_ERROR), r.push({
10725
+ typeof t == "number" ? e = $a(t) : (this._debug.warn(`Unexpected error code ${t} received for participant ${n.participantId}`), e = Qa.UNKNOWN_ERROR), r.push({
10587
10726
  externalId: a.externalId,
10588
10727
  errorReason: e
10589
10728
  });
10590
10729
  }
10591
10730
  }
10592
- if (r && r.length && (this._debug.warn("Could not allocate one or more participants", r), t)) throw new ds("Could not allocate one or more participants", r);
10731
+ if (r && r.length && (this._debug.warn("Could not allocate one or more participants", r), t)) throw new ms("Could not allocate one or more participants", r);
10593
10732
  }
10594
10733
  async _cleanupCooldownQueue() {
10595
10734
  let e = {}, t = this._cooldownTimestampByStreamDescription.entries();
@@ -10597,7 +10736,7 @@ var ls = 15, $ = class e extends b {
10597
10736
  let n = t.next();
10598
10737
  if (n.done) break;
10599
10738
  let r = n.value;
10600
- if (r[1] + ss > Date.now()) break;
10739
+ if (r[1] + us > Date.now()) break;
10601
10740
  let i = r[0];
10602
10741
  await this._stopStreaming(i), e[i] = { stopStream: !0 };
10603
10742
  } while (!0);
@@ -10613,17 +10752,22 @@ var ls = 15, $ = class e extends b {
10613
10752
  async _onParticipantPromoted(e) {
10614
10753
  this._conversation && this._conversation.audienceMode ? (this._debug.log("Promoted in audience mode", !e.demote), this._conversation.restricted = e.demote, this._processRecordInfos(e), !e.demote && this._mediaSource && this._changeMediaSettings(this._mediaSource.mediaSettings)) : (this._debug.log("Promoted in waiting hall", !e.demote), e.demote ? (this._debug.log("Kicked from waiting hall"), this._close(new O(D.REMOVED))) : (this._updateConversation(e), this._waitingHallHoldPending ? (await this._signaling.hold(!0), await this._onJoinPart2(e, !1), this._waitingHallHoldPending = !1) : z.getActive() && M.hold ? (await this._signaling.hold(!0), await this._onJoinPart2(e, !0, !0), this._waitingHallHoldPending = !1) : await this._onJoinPart2(e))), L.onPromoted(e.demote, this.id);
10615
10754
  }
10616
- async _onChatRoomUpdated(e, t = 0, n = [], r, i) {
10755
+ _onChatRoomUpdated(e, t = 0, n = [], r, i) {
10617
10756
  this._debug.log(`Chat room updated: ${e}`);
10618
- let a = [];
10757
+ let a = [], o = [];
10619
10758
  n.length && n.forEach((e) => {
10620
10759
  if (e.externalId) {
10621
10760
  let t = Q.fromSignaling(e.externalId);
10622
10761
  a.push(t), this._api.cacheExternalId(e.id.id, t);
10623
- } else a.push(this._getOrCacheExternalIdByCompositeId(e.id.id));
10762
+ } else {
10763
+ let t = this._getExternalIdByParticipantId(e.id.id);
10764
+ t ? a.push(t) : o.push(e.id.id);
10765
+ }
10624
10766
  });
10625
- let o = r?.map((e) => this._getOrCacheExternalIdByCompositeId(e)) ?? [], s = i?.map((e) => this._getOrCacheExternalIdByCompositeId(e)) ?? [];
10626
- L.onChatRoomUpdated(e, t, a, o, s, this.id);
10767
+ let { externalIds: s, missingIds: c } = this._getExternalIdsByParticipantIds(r ?? []);
10768
+ o.push(...c);
10769
+ let { externalIds: l, missingIds: u } = this._getExternalIdsByParticipantIds(i ?? []);
10770
+ o.push(...u), this._reportMissingExternalIds(o, "CHAT_ROOM_UPDATED"), L.onChatRoomUpdated(e, t, a, s, l, this.id);
10627
10771
  }
10628
10772
  _onSharedMovieUpdate(e) {
10629
10773
  let t = this._conversation?.externalId;
@@ -10796,10 +10940,10 @@ var ls = 15, $ = class e extends b {
10796
10940
  throw Error("transport is not initialized");
10797
10941
  }
10798
10942
  _isCallAdmin() {
10799
- return this._conversation ? j.includesOneOf(this._conversation.roles, [Za.ADMIN, Za.CREATOR]) : !1;
10943
+ return this._conversation ? j.includesOneOf(this._conversation.roles, [eo.ADMIN, eo.CREATOR]) : !1;
10800
10944
  }
10801
10945
  _checkAdminRole() {
10802
- if (this._conversation && !j.includesOneOf(this._conversation.roles, [Za.ADMIN, Za.CREATOR])) throw Error("You don't have the required permission");
10946
+ if (this._conversation && !j.includesOneOf(this._conversation.roles, [eo.ADMIN, eo.CREATOR])) throw Error("You don't have the required permission");
10803
10947
  }
10804
10948
  _isCalledState() {
10805
10949
  return this._participantState === Z.CALLED;
@@ -10837,43 +10981,46 @@ var ls = 15, $ = class e extends b {
10837
10981
  async changeOptions(e) {
10838
10982
  if (this._signaling.ready && this._conversation) {
10839
10983
  this._checkAdminRole(), await this._signaling.changeOptions(e);
10840
- let t = Ka(this._conversation.options, e);
10984
+ let t = Ya(this._conversation.options, e);
10841
10985
  this._onOptionsChanged(t);
10842
10986
  }
10843
10987
  }
10844
10988
  async getWaitingHall(e, t, n) {
10845
10989
  if (!this._signaling) return Promise.reject();
10846
10990
  let r = null;
10847
- if (e && (r = ro(e), r)) {
10991
+ if (e && (r = oo(e), r)) {
10848
10992
  let e = this._api.getDecorativeIdByInitialId(r.id);
10849
- r.id = e ? j.composeUserId(e) : r.id;
10993
+ r.id = e ?? r.id;
10850
10994
  }
10851
10995
  let i = await this._signaling.getWaitingHall(r, t, n);
10852
10996
  if (i.error) return Promise.reject(i.message);
10853
- let a = i.participants || [], { externalIds: o } = await this._resolveWaitingHallExternalIds(a), s = null;
10854
- return a.length && i.hasMore && (s = no(a[a.length - 1].id)), {
10997
+ let a = i.participants || [], { externalIds: o } = this._resolveWaitingHallExternalIds(a, "getWaitingHall"), s = null;
10998
+ return a.length && i.hasMore && (s = ao(a[a.length - 1].id)), {
10855
10999
  participants: o,
10856
11000
  pageMarker: s,
10857
11001
  totalCount: i.totalCount || 0
10858
11002
  };
10859
11003
  }
10860
- async _resolveWaitingHallExternalIds(e) {
10861
- let t = [], n = [];
11004
+ _resolveWaitingHallExternalIds(e, t) {
11005
+ let n = [], r = [], i = [];
10862
11006
  return e.length && e.forEach((e) => {
10863
11007
  if (e.externalId) {
10864
- let r = Q.fromSignaling(e.externalId);
10865
- t.push(e.id.addedTs), n.push(r), this._api.cacheExternalId(e.id.id, r);
10866
- } else n.push(this._getOrCacheExternalIdByCompositeId(e.id.id)), t.push(e.id.addedTs);
10867
- }), {
10868
- externalIds: n,
10869
- timestamps: t
11008
+ let t = Q.fromSignaling(e.externalId);
11009
+ n.push(e.id.addedTs), r.push(t), this._api.cacheExternalId(e.id.id, t);
11010
+ } else {
11011
+ let t = this._getExternalIdByParticipantId(e.id.id);
11012
+ t ? (r.push(t), n.push(e.id.addedTs)) : i.push(e.id.id);
11013
+ }
11014
+ }), this._reportMissingExternalIds(i, t), {
11015
+ externalIds: r,
11016
+ timestamps: n
10870
11017
  };
10871
11018
  }
10872
11019
  async getAudienceModeHands() {
10873
11020
  if (!this._signaling.ready) throw Error("Signaling is not ready");
10874
11021
  let e = await this._signaling.getHandQueue();
10875
11022
  if (e.error) return Promise.reject(e.message);
10876
- let t = e.participants || [], { externalIds: n, timestamps: r } = await this._resolveWaitingHallExternalIds(t);
11023
+ let t = e.participants || [], { externalIds: n, timestamps: r } = this._resolveWaitingHallExternalIds(t, "getAudienceModeHands");
10877
11024
  return {
10878
11025
  timestamps: r,
10879
11026
  participants: n,
@@ -10882,7 +11029,7 @@ var ls = 15, $ = class e extends b {
10882
11029
  }
10883
11030
  async promoteParticipant(e, t) {
10884
11031
  if (this._signaling && this._conversation) try {
10885
- if (!j.includesOneOf(this._conversation.options, [Wa.WAITING_HALL, Wa.AUDIENCE_MODE])) throw Error("Unable to promote a participant in the conversation with current options");
11032
+ if (!j.includesOneOf(this._conversation.options, [qa.WAITING_HALL, qa.AUDIENCE_MODE])) throw Error("Unable to promote a participant in the conversation with current options");
10886
11033
  if (this._checkAdminRole(), !e && t) throw Error("participantId is required");
10887
11034
  await this._signaling.promoteParticipant(e, t);
10888
11035
  } catch (t) {
@@ -11042,7 +11189,7 @@ var ls = 15, $ = class e extends b {
11042
11189
  unmuteOptions: e.unmuteOptions || [],
11043
11190
  observedIds: e.observedIds || [],
11044
11191
  markers: this._denormalizeMarkers(t, e.markers)
11045
- }, e.decorativeUserId);
11192
+ }, j.composeDecorativeId(e));
11046
11193
  }));
11047
11194
  }
11048
11195
  async getParticipantListChunk(e) {
@@ -11054,7 +11201,7 @@ var ls = 15, $ = class e extends b {
11054
11201
  let a = this._transport?.getState();
11055
11202
  return n.participants.forEach((e) => {
11056
11203
  let t = j.composeId(e), n = r[t];
11057
- this._updateParticipantExternalId(n, e), this._setSessionState(n, this._remoteParticipantSessionState(t, e.sessionState)), n.isOnHold || this._setTransportStatus(n, eo.fromTransportState(a) ?? N.WAITING), n.movieShareInfos = e.movieShareInfos, Object.assign(n.mediaSettings, E(e.mediaSettings)), Object.assign(n.muteStates, e.muteStates), n.unmuteOptions = e.unmuteOptions ?? n.unmuteOptions, this._openTransport([n], !0);
11204
+ this._updateParticipantExternalId(n, e), this._setSessionState(n, this._remoteParticipantSessionState(t, e.sessionState)), n.isOnHold || this._setTransportStatus(n, ro.fromTransportState(a) ?? N.WAITING), n.movieShareInfos = e.movieShareInfos, Object.assign(n.mediaSettings, E(e.mediaSettings)), Object.assign(n.muteStates, e.muteStates), n.unmuteOptions = e.unmuteOptions ?? n.unmuteOptions, this._openTransport([n], !0);
11058
11205
  }), this._participantListChunkToExternalChunk(n);
11059
11206
  }
11060
11207
  async _getInitialParticiapntListChunk() {
@@ -11068,7 +11215,7 @@ var ls = 15, $ = class e extends b {
11068
11215
  _onLocalMediaStreamChanged(e) {
11069
11216
  if (!this._conversation || !this._mediaSource) return;
11070
11217
  let t = this._mediaSource.mediaSettings;
11071
- this._debug.debug("Local media stream changed", t), e.kind === k.audio && this._mediaSource && (this._audioFix = new ho(this._mediaSource, this._debug, this._stats.logger)), L.onLocalStreamUpdate(t, e.kind, this.id), !this._conversation?.waitingHall && !this._conversation?.observer && !this._isAudienceModeListener() && this._changeMediaSettings(t);
11218
+ this._debug.debug("Local media stream changed", t), e.kind === k.audio && this._mediaSource && (this._audioFix = new vo(this._mediaSource, this._debug, this._stats.logger)), L.onLocalStreamUpdate(t, e.kind, this.id), !this._conversation?.waitingHall && !this._conversation?.observer && !this._isAudienceModeListener() && this._changeMediaSettings(t);
11072
11219
  }
11073
11220
  _onScreenSharingStatus(e) {
11074
11221
  let t = this.mediaSettings;
@@ -11088,7 +11235,7 @@ var ls = 15, $ = class e extends b {
11088
11235
  this._warnParticipantNotInConversation(e);
11089
11236
  return;
11090
11237
  }
11091
- r.mediaSettings = t, ["ACTIVE", "HELD"].includes(this._state) && L.onRemoteMediaSettings(r.externalId, t, r.markers, this.id), this._specListener && this._specListener.onChangeRemoteMediaSettings(e, t);
11238
+ r.mediaSettings = t, ["ACTIVE", "HELD"].includes(this._state) && (r.externalId ? L.onRemoteMediaSettings(r.externalId, t, r.markers, this.id) : this._reportMissingExternalIds([e], "REMOTE_MEDIA_SETTINGS")), this._specListener && this._specListener.onChangeRemoteMediaSettings(e, t);
11092
11239
  }
11093
11240
  _extractLocalParticipantFromConnection(e) {
11094
11241
  let t = this._api.getUserId();
@@ -11104,7 +11251,7 @@ var ls = 15, $ = class e extends b {
11104
11251
  this._warnParticipantNotInConversation(e);
11105
11252
  return;
11106
11253
  }
11107
- n.participantState = t || {}, ["ACTIVE", "HELD"].includes(this._state) && L.onRemoteParticipantState(n.externalId, n.participantState, n.markers, this.id);
11254
+ n.participantState = t || {}, ["ACTIVE", "HELD"].includes(this._state) && (n.externalId ? L.onRemoteParticipantState(n.externalId, n.participantState, n.markers, this.id) : this._reportMissingExternalIds([e], "REMOTE_PARTICIPANT_STATE"));
11108
11255
  }
11109
11256
  _changeMultipleParticipantState(e, t) {
11110
11257
  this._debug.debug("Multiple participants state changed", e);
@@ -11198,9 +11345,9 @@ var ls = 15, $ = class e extends b {
11198
11345
  for (let n of e.conversation.participants) {
11199
11346
  let e = j.composeId(n), i = n.roles || [];
11200
11347
  if (this._isMe(e)) {
11201
- Qa(this._conversation.roles, i) || this._onRolesChanged(e, i), t = () => {
11348
+ to(this._conversation.roles, i) || this._onRolesChanged(e, i), t = () => {
11202
11349
  this._registerParticipantLocalMuteState({
11203
- muteStates: co(n),
11350
+ muteStates: fo(n),
11204
11351
  unmuteOptions: n.unmuteOptions
11205
11352
  });
11206
11353
  };
@@ -11218,7 +11365,7 @@ var ls = 15, $ = class e extends b {
11218
11365
  let t = E(n.mediaSettings);
11219
11366
  Wt(t, a.mediaSettings) || this._changeRemoteMediaSettings(e, t);
11220
11367
  let r = j.mapParticipantState(n), o = a.participantState;
11221
- j.isEqualParticipantState(r, o) || await this._changeRemoteParticipantState(e, r), Qa(i, a.roles) || this._onRolesChanged(a.id, i), !!n.onHold != !!a.isOnHold && (a.isOnHold = !!n.onHold, this._setParticipantsStatus([a], n.onHold ? N.ONHOLD : N.CONNECTED));
11368
+ j.isEqualParticipantState(r, o) || await this._changeRemoteParticipantState(e, r), to(i, a.roles) || this._onRolesChanged(a.id, i), !!n.onHold != !!a.isOnHold && (a.isOnHold = !!n.onHold, this._setParticipantsStatus([a], n.onHold ? N.ONHOLD : N.CONNECTED));
11222
11369
  }
11223
11370
  }
11224
11371
  let i = this._participants;
@@ -11239,30 +11386,37 @@ var ls = 15, $ = class e extends b {
11239
11386
  async _onAcceptedCall(e) {
11240
11387
  let t = j.composeMessageId(e), n = j.getPeerIdString(e.peerId);
11241
11388
  if (this._debug.debug(`Participant accepted call [${t}]`), this._statFirstMediaReceived.markAcceptedCall(this._transport?.getTopology()), this._conversation && this._isMe(t)) {
11389
+ if (this._conversation.concurrent) return;
11242
11390
  this._close(new O(D.MISSED), { errorText: "Call accepted on other device" });
11243
11391
  return;
11244
11392
  }
11245
- this._conversation?.direction === Ba.OUTGOING && !this._conversation.concurrent && this._stats.lifecycle.markOutgoingAccepted();
11393
+ this._conversation?.direction === Ua.OUTGOING && !this._conversation.concurrent && this._stats.lifecycle.markOutgoingAccepted();
11246
11394
  let r = this._getParticipant(t);
11247
11395
  if (!r) {
11248
- let n = this._api.getDecorativeIdByInitialId(t), i = n ? j.composeUserId(n, e.participantType) : void 0;
11396
+ let n = this._api.getDecorativeIdByInitialId(t);
11249
11397
  r = this._registerParticipantInCache(this._createParticipant({
11250
11398
  id: t,
11251
11399
  externalId: e.externalId ? Q.fromSignaling(e.externalId, e.deviceIdx) : void 0,
11252
11400
  mediaSettings: E(e.mediaSettings)
11253
- }, i));
11401
+ }, n));
11254
11402
  } else if (e.externalId) {
11255
11403
  let t = Q.fromSignaling(e.externalId, e.deviceIdx);
11256
11404
  r.externalId = t, this._api.cacheExternalId(r.id, t);
11257
11405
  }
11258
- r.state = Z.ACCEPTED, r.mediaSettings = E(e.mediaSettings), this._logWithMediaSettings(C.ACCEPTED_OUTGOING, r.mediaSettings), this._conversation && this._conversation.direction === Ba.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);
11406
+ r.state = Z.ACCEPTED, r.mediaSettings = E(e.mediaSettings), this._logWithMediaSettings(C.ACCEPTED_OUTGOING, r.mediaSettings), this._conversation && this._conversation.direction === Ua.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);
11259
11407
  let i = Object.keys(r.muteStates);
11260
- i.length && this._onMuteParticipant({
11408
+ if (i.length && this._onMuteParticipant({
11261
11409
  muteStates: r.muteStates,
11262
11410
  mediaOptions: i,
11263
11411
  stateUpdated: !0,
11264
11412
  participantId: t
11265
- }), ["ACTIVE", "HELD"].includes(this._state) && L.onAcceptedCall(r.externalId, xa.parseCapabilities(e.capabilities), this.id);
11413
+ }), ["ACTIVE", "HELD"].includes(this._state)) {
11414
+ if (!r.externalId) {
11415
+ this._reportMissingExternalIds([t], "ACCEPTED_CALL");
11416
+ return;
11417
+ }
11418
+ L.onAcceptedCall(r.externalId, wa.parseCapabilities(e.capabilities), this.id);
11419
+ }
11266
11420
  }
11267
11421
  async _onHungup(e) {
11268
11422
  this._debug.debug(`Participant hungup [${e.participantId}]`, { reason: e.reason });
@@ -11298,7 +11452,7 @@ var ls = 15, $ = class e extends b {
11298
11452
  return;
11299
11453
  }
11300
11454
  if (e.connected) {
11301
- let e = eo.fromTransportState(this._transport?.getState());
11455
+ let e = ro.fromTransportState(this._transport?.getState());
11302
11456
  e && this._setTransportStatus(n, e);
11303
11457
  }
11304
11458
  this._setSessionState(n, { connected: e.connected });
@@ -11331,7 +11485,7 @@ var ls = 15, $ = class e extends b {
11331
11485
  return;
11332
11486
  }
11333
11487
  if (!n) {
11334
- let { participant: r } = e, i = r.decorativeUserId;
11488
+ let { participant: r } = e, i = j.composeDecorativeId(r);
11335
11489
  this._registerParticipant({
11336
11490
  id: t,
11337
11491
  externalId: Q.fromSignalingParticipant(r, !0, !0),
@@ -11358,7 +11512,7 @@ var ls = 15, $ = class e extends b {
11358
11512
  return;
11359
11513
  }
11360
11514
  if (!n) {
11361
- let { participant: r } = e, i = r.decorativeUserId;
11515
+ let { participant: r } = e, i = j.composeDecorativeId(r);
11362
11516
  this._registerParticipant({
11363
11517
  id: t,
11364
11518
  externalId: Q.fromSignalingParticipant(r, !0, !0),
@@ -11375,7 +11529,7 @@ var ls = 15, $ = class e extends b {
11375
11529
  isOnHold: !!r.onHold
11376
11530
  }, i), n = this._getParticipant(t);
11377
11531
  }
11378
- this._conversation && this._conversation.direction === Ba.OUTGOING && (this._state === "IDLE" || this._state === "PROCESSING") && (this._state = "ACTIVE", this._changeFeatureSet()), n.state = Z.ACCEPTED, n.mediaSettings = E(e.mediaSettings), n.participantState = j.mapParticipantState(e.participant), n.roles = e.participant.roles || [], this._updateParticipantSessionState(n, t, e.participant.sessionState), e.participant.onHold ? (n.isOnHold = !0, this._setParticipantsStatus([n], N.ONHOLD)) : this._transport?.isAllocated(n.id) ? this._setParticipantsStatus([n], N.CONNECTED) : this._setParticipantsStatus([n], N.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)), L.onParticipantJoined(n.externalId, n.markers, this.id), this._changeRemoteMediaSettings(t, n.mediaSettings), await this._changeRemoteParticipantState(t, n.participantState), this._invokeRolesChangedCallbackIfNeeded(n);
11532
+ this._conversation && this._conversation.direction === Ua.OUTGOING && (this._state === "IDLE" || this._state === "PROCESSING") && (this._state = "ACTIVE", this._changeFeatureSet()), n.state = Z.ACCEPTED, n.mediaSettings = E(e.mediaSettings), n.participantState = j.mapParticipantState(e.participant), n.roles = e.participant.roles || [], this._updateParticipantSessionState(n, t, e.participant.sessionState), e.participant.onHold ? (n.isOnHold = !0, this._setParticipantsStatus([n], N.ONHOLD)) : this._transport?.isAllocated(n.id) ? this._setParticipantsStatus([n], N.CONNECTED) : this._setParticipantsStatus([n], N.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)), L.onParticipantJoined(n.externalId, n.markers, this.id), this._changeRemoteMediaSettings(t, n.mediaSettings), await this._changeRemoteParticipantState(t, n.participantState), this._invokeRolesChangedCallbackIfNeeded(n);
11379
11533
  let i = Object.keys(n.muteStates);
11380
11534
  i.length && this._onMuteParticipant({
11381
11535
  muteStates: n.muteStates,
@@ -11401,7 +11555,7 @@ var ls = 15, $ = class e extends b {
11401
11555
  _onParticipantsStateChanged(e) {
11402
11556
  let { participants: t, roomId: n } = e;
11403
11557
  t.map(({ id: e, markers: t }) => this._registerParticipantAndSetMarkersIfChunkEnabled(e, t));
11404
- let r = /* @__PURE__ */ new Map(), i = t.map(({ id: e, participantState: t }) => [e, this._getExternalIdByParticipantId(e) && j.mapParticipantState({ participantState: t })]);
11558
+ let r = /* @__PURE__ */ new Map(), i = t.map(({ id: e, participantState: t }) => [e, this._getExternalIdByParticipantId(e) ? j.mapParticipantState({ participantState: t }) : void 0]);
11405
11559
  try {
11406
11560
  i.forEach(([e, t]) => {
11407
11561
  t && r.set(e, t);
@@ -11566,15 +11720,15 @@ var ls = 15, $ = class e extends b {
11566
11720
  L.onAsrTranscription(t, e.text, e.timestamp, e.duration, this.id);
11567
11721
  }
11568
11722
  async _onRolesChanged(e, t) {
11569
- if (this._conversation && this._isMe(e) && !Qa(this._conversation.roles, t)) {
11723
+ if (this._conversation && this._isMe(e) && !to(this._conversation.roles, t)) {
11570
11724
  this._debug.debug(`Local roles changed: ${t}`), this._conversation.roles = t, L.onLocalRolesChanged(t, !1, this.id), this._processMuteState({
11571
- mediaOptions: io(this._getMuteStatesForCurrentRoom(), qa.MUTE_PERMANENT),
11725
+ mediaOptions: so(this._getMuteStatesForCurrentRoom(), Xa.MUTE_PERMANENT),
11572
11726
  stateUpdated: !0
11573
- }), j.includesOneOf(t, [Za.ADMIN, Za.CREATOR]) ? this._refreshRooms(!0) : t.length || this._onRoomSwitched(null);
11727
+ }), j.includesOneOf(t, [eo.ADMIN, eo.CREATOR]) ? this._refreshRooms(!0) : t.length || this._onRoomSwitched(null);
11574
11728
  return;
11575
11729
  }
11576
11730
  let n = this._getParticipant(e);
11577
- n && !Qa(n.roles, t) && (this._debug.debug(`Roles for participant [${e}] changed: ${t}`), n.roles = t, L.onRolesChanged(n.externalId, t, !1, this.id));
11731
+ n && !to(n.roles, t) && (this._debug.debug(`Roles for participant [${e}] changed: ${t}`), n.roles = t, L.onRolesChanged(n.externalId, t, !1, this.id));
11578
11732
  }
11579
11733
  async _onMuteParticipant(e, t = !1) {
11580
11734
  if (!this._conversation) return;
@@ -11623,7 +11777,7 @@ var ls = 15, $ = class e extends b {
11623
11777
  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);
11624
11778
  for (let [e, i] of d) {
11625
11779
  let a = this._isCallAdmin() && n;
11626
- if (!(i !== qa.MUTE && i !== qa.MUTE_PERMANENT || a) && (this._isCallAdmin() && i === qa.MUTE_PERMANENT && !n && (l[e] = qa.MUTE), !(!t.includes(e) || r))) switch (e) {
11780
+ if (!(i !== Xa.MUTE && i !== Xa.MUTE_PERMANENT || a) && (this._isCallAdmin() && i === Xa.MUTE_PERMANENT && !n && (l[e] = Xa.MUTE), !(!t.includes(e) || r))) switch (e) {
11627
11781
  case S.VIDEO:
11628
11782
  u.isVideoEnabled && (L.onDeviceSwitched(S.VIDEO, !1, this.id), await this.toggleLocalVideo(!1));
11629
11783
  break;
@@ -11660,7 +11814,7 @@ var ls = 15, $ = class e extends b {
11660
11814
  this._conversation.pinnedParticipantIdByRoom.set(r, t ? null : e);
11661
11815
  }
11662
11816
  _onOptionsChanged(e) {
11663
- this._conversation && !Ga(this._conversation.options, e) && (this._conversation.options = e, L.onOptionsChanged(e, this.id), e.includes(Wa.ADMIN_IS_HERE) ? this._conversation.restricted && this._conversation.waitingHall && L.onLocalStatus(N.WAITING_HALL, this.id) : e.includes(Wa.WAIT_FOR_ADMIN) && this._conversation.restricted && L.onLocalStatus(N.WAIT_FOR_ADMIN, this.id));
11817
+ this._conversation && !Ja(this._conversation.options, e) && (this._conversation.options = e, L.onOptionsChanged(e, this.id), e.includes(qa.ADMIN_IS_HERE) ? this._conversation.restricted && this._conversation.waitingHall && L.onLocalStatus(N.WAITING_HALL, this.id) : e.includes(qa.WAIT_FOR_ADMIN) && this._conversation.restricted && L.onLocalStatus(N.WAIT_FOR_ADMIN, this.id));
11664
11818
  }
11665
11819
  async _onNetworkStatus(e) {
11666
11820
  if (this._conversation) {
@@ -11670,7 +11824,7 @@ var ls = 15, $ = class e extends b {
11670
11824
  if (this._isMe(r) || r === "") e = this._conversation.networkRating;
11671
11825
  else if (n[r]) e = n[r].networkRating;
11672
11826
  else continue;
11673
- if (e !== i) if (this._isMe(r) || r === "") this._conversation.networkRating = i, Zr.getInstance().value = i, L.onLocalNetworkStatusChanged(i, this.id);
11827
+ if (e !== i) if (this._isMe(r) || r === "") this._conversation.networkRating = i, ei.getInstance().value = i, L.onLocalNetworkStatusChanged(i, this.id);
11674
11828
  else {
11675
11829
  let e = n[r];
11676
11830
  e.networkRating = i, t.push({
@@ -11715,7 +11869,7 @@ var ls = 15, $ = class e extends b {
11715
11869
  }
11716
11870
  _changeFeatureSet() {
11717
11871
  if (this._conversation) {
11718
- let e = this._state === "ACTIVE", t = this._conversation.features.includes(Ua.ADD_PARTICIPANT);
11872
+ let e = this._state === "ACTIVE", t = this._conversation.features.includes(Ka.ADD_PARTICIPANT);
11719
11873
  L.onCallState(e, t, this._conversation, this.id);
11720
11874
  }
11721
11875
  }
@@ -11749,7 +11903,7 @@ var ls = 15, $ = class e extends b {
11749
11903
  let n = this._getParticipant(e);
11750
11904
  if (n) {
11751
11905
  if (n.connectionStatus.sessionStateApplicable && n.connectionStatus.sessionState?.connected === !1) {
11752
- let e = eo.fromTransportState(this._transport?.getState());
11906
+ let e = ro.fromTransportState(this._transport?.getState());
11753
11907
  e && this._setTransportStatus(n, e), n.connectionStatus.sessionStateConnectedBySpeaker = !0;
11754
11908
  let t = this._setTransportStatus(n, n.connectionStatus.transport);
11755
11909
  this._emitParticipantTransition(n, t);
@@ -11759,7 +11913,7 @@ var ls = 15, $ = class e extends b {
11759
11913
  }
11760
11914
  async _onTransportStateChanged(e, t) {
11761
11915
  this._debug.debug(`Transport state has changed: ${t}`, e);
11762
- let n = eo.fromTransportState(t);
11916
+ let n = ro.fromTransportState(t);
11763
11917
  if (!n) return;
11764
11918
  let r = this._participants, i = [], a = e.reduce((e, n) => {
11765
11919
  if (n in r) {
@@ -11793,15 +11947,15 @@ var ls = 15, $ = class e extends b {
11793
11947
  return e.every((e) => t[e]?.isOnHold);
11794
11948
  }
11795
11949
  _onRemoteTrackAdded(e, t, n) {
11796
- if (e.endsWith(qr.AUDIO_MIX)) this._debug.debug("Remote audio mix track added"), this._audioOutput.add(e, n), L.onRemoteMixedAudioStream(t, this.id);
11797
- else if (e.startsWith(qr.TRANSPARENT_AUDIO_TRACK_PREFIX)) this._debug.debug(`Remote transparent audio track added: ${e}`), this._audioOutput.add(e, n);
11798
- else if (e.startsWith(qr.PARTICIPANT_AGNOSTIC_TRACK_PREFIX)) this._debug.debug(`Participant-agnostic track added: ${e}`), this._streamByStreamId.set(e, t);
11950
+ if (e.endsWith(Xr.AUDIO_MIX)) this._debug.debug("Remote audio mix track added"), this._audioOutput.add(e, n), L.onRemoteMixedAudioStream(t, this.id);
11951
+ else if (e.startsWith(Xr.TRANSPARENT_AUDIO_TRACK_PREFIX)) this._debug.debug(`Remote transparent audio track added: ${e}`), this._audioOutput.add(e, n);
11952
+ else if (e.startsWith(Xr.PARTICIPANT_AGNOSTIC_TRACK_PREFIX)) this._debug.debug(`Participant-agnostic track added: ${e}`), this._streamByStreamId.set(e, t);
11799
11953
  else {
11800
11954
  this._debug.debug(`Remote track added on the participant [${e}]`, { kind: n.kind });
11801
11955
  let r = this._getParticipant(e);
11802
11956
  if (!r) {
11803
- let t = this._api.getDecorativeIdByInitialId(e), n = t ? j.composeUserId(t) : void 0;
11804
- this._debug.warn(`Conversation: track added before participant [id: ${e}, decorativeId: ${n}]`), this._registerParticipant({ id: e }, n), r = this._getParticipant(e), this._setParticipantsStatus([r], N.WAITING), this._activeSpeakerId === e && this._lastSignalledActiveSpeakerId !== e && (L.onSpeakerChanged(r.externalId, this.id), this._lastSignalledActiveSpeakerId = e);
11957
+ let t = this._api.getDecorativeIdByInitialId(e);
11958
+ this._debug.warn(`Conversation: track added before participant [id: ${e}, decorativeId: ${t}]`), this._registerParticipant({ id: e }, t), r = this._getParticipant(e), this._setParticipantsStatus([r], N.WAITING), this._activeSpeakerId === e && this._lastSignalledActiveSpeakerId !== e && (L.onSpeakerChanged(r.externalId, this.id), this._lastSignalledActiveSpeakerId = e);
11805
11959
  }
11806
11960
  if (this._transport && !this._transport.isAllocated(r.id) && this._allocateParticipantTransport(r.id, !1), n.kind === k.audio && (this._audioOutput.add(e, n), M.preserveAudioTracks || (r.remoteAudioTrack = n, t.removeTrack(n))), r.remoteStream !== t && t.getTracks().length) {
11807
11961
  if (r.remoteStream = t, r.secondStream) return;
@@ -11822,7 +11976,7 @@ var ls = 15, $ = class e extends b {
11822
11976
  }
11823
11977
  }
11824
11978
  async _removeAudioTrack(e, t, n) {
11825
- if (e !== qr.AUDIO_MIX) {
11979
+ if (e !== Xr.AUDIO_MIX) {
11826
11980
  let n = this._getParticipant(e);
11827
11981
  if (!n || n.remoteStream && n.remoteStream !== t) return;
11828
11982
  }
@@ -11837,7 +11991,7 @@ var ls = 15, $ = class e extends b {
11837
11991
  if (this._statFirstMediaReceived.markTopologyChanged(e), e === J.DIRECT && (this._onRemoteSignalledStall([]), this._onAudioMixStall(!1)), this._conversation) {
11838
11992
  this._conversation.topology = e;
11839
11993
  for (let e of Object.values(this._participants)) {
11840
- let t = eo.setSessionStateApplicable(e.connectionStatus, this._isParticipantSessionStateApplicable(e.id));
11994
+ let t = ro.setSessionStateApplicable(e.connectionStatus, this._isParticipantSessionStateApplicable(e.id));
11841
11995
  this._emitParticipantTransition(e, t);
11842
11996
  }
11843
11997
  this._changeFeatureSet(), this._forceOpenTransportForAloneInCall();
@@ -11893,7 +12047,7 @@ var ls = 15, $ = class e extends b {
11893
12047
  ].includes(t) ? null : this._setTransportStatus(e, t), n);
11894
12048
  }
11895
12049
  _setParticipantsStalled(e, t) {
11896
- this._updateParticipantsStatus(e, (e) => eo.setStalled(e.connectionStatus, t));
12050
+ this._updateParticipantsStatus(e, (e) => ro.setStalled(e.connectionStatus, t));
11897
12051
  }
11898
12052
  _updateParticipantsStatus(e, t, n = null) {
11899
12053
  let r = e.reduce((e, n) => {
@@ -11911,46 +12065,63 @@ var ls = 15, $ = class e extends b {
11911
12065
  }
11912
12066
  _onRoomsUpdated(e) {
11913
12067
  if (this._isCalledState()) return;
11914
- let t = {};
11915
- for (let n of Object.keys(Ja)) {
11916
- let r = e.updates[n];
11917
- r && (t[n] = {
11918
- rooms: r?.rooms?.map(this._convertRoomToExternal.bind(this)) || [],
11919
- roomIds: r?.roomIds,
11920
- deactivated: r?.deactivated
12068
+ let t = {}, n = [], r = [];
12069
+ for (let i of Object.keys(Za)) {
12070
+ let a = e.updates[i];
12071
+ a && (a?.rooms?.forEach((e) => {
12072
+ let { room: t, missingParticipantIds: i } = this._convertRoomToExternal(e);
12073
+ t && n.push(t), r.push(...i);
12074
+ }), t[i] = {
12075
+ rooms: n,
12076
+ roomIds: a?.roomIds,
12077
+ deactivated: a?.deactivated
11921
12078
  });
11922
12079
  }
11923
- L.onRoomsUpdated(t, this.id);
12080
+ this._reportMissingExternalIds(r, "ROOMS_UPDATED"), L.onRoomsUpdated(t, this.id);
11924
12081
  }
11925
12082
  _onRoomUpdated(e) {
11926
- let t = this._convertRoomToExternal(e.room || null);
11927
- e.events.some((e) => e === Ja.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() || L.onRoomUpdated(e.events, e.roomId, t, e.deactivate || null, this.id);
12083
+ let { room: t, missingParticipantIds: n } = this._convertRoomToExternal(e.room || null);
12084
+ e.events.some((e) => e === Za.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"), L.onRoomUpdated(e.events, e.roomId, t, e.deactivate || null, this.id));
11928
12085
  }
11929
12086
  _convertRoomToExternal(e) {
11930
- if (!e) return null;
11931
- let t = e.participantIds?.map((e) => this._getExternalIdByParticipantId(e)) || [], n = e.addParticipantIds?.map((e) => this._getExternalIdByParticipantId(e)) || [], r = e.removeParticipantIds?.map?.((e) => this._getExternalIdByParticipantId(e)) || [], i = e.pinnedParticipantId ? this._getExternalIdByParticipantId(e.pinnedParticipantId) : void 0;
12087
+ if (!e) return {
12088
+ room: null,
12089
+ missingParticipantIds: []
12090
+ };
12091
+ let t = [], { externalIds: n, missingIds: r } = this._getExternalIdsByParticipantIds(e.participantIds ?? []), { externalIds: i, missingIds: a } = this._getExternalIdsByParticipantIds(e.addParticipantIds ?? []), { externalIds: o, missingIds: s } = this._getExternalIdsByParticipantIds(e.removeParticipantIds ?? []);
12092
+ t.push(...r, ...a, ...s);
12093
+ let c;
12094
+ if (e.pinnedParticipantId) {
12095
+ let n = this._getExternalIdByParticipantId(e.pinnedParticipantId);
12096
+ n ? c = n : t.push(e.pinnedParticipantId);
12097
+ }
11932
12098
  return {
11933
- id: e.id,
11934
- name: e.name,
11935
- participantCount: e.participantCount,
11936
- participantIds: t,
11937
- addParticipantIds: n,
11938
- removeParticipantIds: r,
11939
- participants: e.participants?.participants ? this._participantListChunkToExternalChunk(e.participants) : void 0,
11940
- active: e.active,
11941
- muteStates: e.muteStates,
11942
- pinnedParticipantId: i,
11943
- countdownSec: e.countdownSec,
11944
- timeoutMs: e.timeoutMs
12099
+ room: {
12100
+ id: e.id,
12101
+ name: e.name,
12102
+ participantCount: e.participantCount,
12103
+ participantIds: n,
12104
+ addParticipantIds: i,
12105
+ removeParticipantIds: o,
12106
+ participants: e.participants?.participants ? this._participantListChunkToExternalChunk(e.participants) : void 0,
12107
+ active: e.active,
12108
+ muteStates: e.muteStates,
12109
+ pinnedParticipantId: c,
12110
+ countdownSec: e.countdownSec,
12111
+ timeoutMs: e.timeoutMs
12112
+ },
12113
+ missingParticipantIds: t
11945
12114
  };
11946
12115
  }
11947
12116
  async _onRoomParticipantsUpdated(e) {
11948
- let t = this._transport?.getState(), n = e.roomId ?? null, r = e.addedParticipantIds?.map((e) => j.decomposeId(e).id) || [], i = this._getExternalIdsByOkIdsFromCache(r), a = e.addedParticipants;
11949
- if (i.length && a?.length !== i.length && !this._isCalledState()) {
12117
+ let t = this._transport?.getState(), n = e.roomId ?? null, r = [], { externalIds: i, missingIds: a } = this._getExternalIdsByParticipantIds(e.addedParticipantIds ?? []);
12118
+ r.push(...a);
12119
+ let o = e.addedParticipants;
12120
+ if (i.length && o?.length !== i.length && !this._isCalledState()) {
11950
12121
  let e = this._convertExternalIdsToServerExternalIds(i);
11951
- a = (await this._signaling.getParticipants(e)).participants;
12122
+ o = (await this._signaling.getParticipants(e)).participants;
11952
12123
  }
11953
- let o = a?.map((e) => {
12124
+ let s = o?.map((e) => {
11954
12125
  let r = j.composeId(e);
11955
12126
  return this._createParticipant({
11956
12127
  id: r,
@@ -11966,38 +12137,38 @@ var ls = 15, $ = class e extends b {
11966
12137
  observedIds: e.observedIds || [],
11967
12138
  markers: this._denormalizeMarkers(r, e.markers),
11968
12139
  isInRoom: n !== null
11969
- }, e.decorativeUserId);
11970
- }) || [], s = !1;
11971
- for (let e of o) e.id === this._conversation?.compositeUserId && (s = !0), this._registerParticipantInCache(e);
11972
- this._transport?.getState() === q.IDLE && !this._isCalledState() && this._openTransport(o, !0);
11973
- let c = [];
12140
+ }, j.composeDecorativeId(e));
12141
+ }) || [], c = !1;
12142
+ for (let e of s) e.id === this._conversation?.compositeUserId && (c = !0), this._registerParticipantInCache(e);
12143
+ this._transport?.getState() === q.IDLE && !this._isCalledState() && this._openTransport(s, !0);
12144
+ let l = [];
11974
12145
  if (e?.removedParticipantMarkers) {
11975
12146
  for (let t of e.removedParticipantMarkers) if (t.GRID?.id) {
11976
12147
  let e = this._getExternalIdByParticipantId(t.GRID.id);
11977
- c.push(e);
12148
+ e ? l.push(e) : r.push(t.GRID.id);
11978
12149
  }
11979
12150
  }
11980
- if (s && await this._onRoomSwitched(n), c) {
12151
+ if (this._reportMissingExternalIds(r, "ROOM_PARTICIPANTS_UPDATED"), c && await this._onRoomSwitched(n), l) {
11981
12152
  let e = this._conversation?.pinnedParticipantIdByRoom.get(n);
11982
12153
  if (e) {
11983
12154
  let t = this._getExternalIdByParticipantId(e);
11984
12155
  if (t) {
11985
- for (let e of c) if (Q.compare(t, e)) {
12156
+ for (let e of l) if (Q.compare(t, e)) {
11986
12157
  this._conversation?.pinnedParticipantIdByRoom.delete(n);
11987
12158
  break;
11988
12159
  }
11989
12160
  }
11990
12161
  }
11991
12162
  }
11992
- let l = {
12163
+ let u = {
11993
12164
  roomId: n,
11994
12165
  participantCount: e.participantCount,
11995
12166
  addedParticipantIds: i,
11996
- addedParticipants: j.mapSharedParticipants(o),
12167
+ addedParticipants: j.mapSharedParticipants(s),
11997
12168
  removedParticipantMarkers: e?.removedParticipantMarkers,
11998
- removedParticipantIds: c
12169
+ removedParticipantIds: l
11999
12170
  };
12000
- this._isCalledState() || L.onRoomParticipantsUpdated(l, this.id);
12171
+ this._isCalledState() || L.onRoomParticipantsUpdated(u, this.id);
12001
12172
  }
12002
12173
  async _onRoomSwitched(e, t = !1) {
12003
12174
  if (!this._conversation || this._conversation.roomId === e) return;
@@ -12017,11 +12188,11 @@ var ls = 15, $ = class e extends b {
12017
12188
  if (this._setMuteStatesForRoomId(t.muteStates, n), this._conversation?.recordsInfoByRoom.set(n, t.recordInfo ?? null), this._conversation?.pinnedParticipantIdByRoom.set(n, t.pinnedParticipantId ?? null), t.asrInfo && this._conversation?.asrInfoByRoom.set(n, t.asrInfo), t.urlSharingInfo ? this._conversation?.urlSharingInfoByRoom.set(n, t.urlSharingInfo) : this._conversation?.urlSharingInfoByRoom.delete(n), e) {
12018
12189
  let e = this._participants;
12019
12190
  await this._registerParticipants(t?.participants?.participants?.filter((t) => !e[j.composeId(t)]) || [], !0);
12020
- let n = this._convertRoomToExternal(t);
12191
+ let { room: n } = this._convertRoomToExternal(t);
12021
12192
  n && r.push(n);
12022
12193
  }
12023
12194
  }
12024
- r.length && !this._isCalledState() && L.onRoomsUpdated({ [Ja.UPDATE]: { rooms: r } }, this.id);
12195
+ r.length && !this._isCalledState() && L.onRoomsUpdated({ [Za.UPDATE]: { rooms: r } }, this.id);
12025
12196
  }
12026
12197
  _onFeedback(e) {
12027
12198
  let t = [];
@@ -12051,7 +12222,9 @@ var ls = 15, $ = class e extends b {
12051
12222
  return;
12052
12223
  }
12053
12224
  let o = Q.fromSignaling(r, a.deviceIdx);
12054
- if (L.onParticipantIdChanged(a, o, this.id), this._api.cacheExternalId(n, o), this._api.mapDecorativeId(n, t), i) this._conversation.externalId = o;
12225
+ L.onParticipantIdChanged(a, o, this.id);
12226
+ let s = j.compose(n, a.deviceIdx), c = j.compose(t, a.deviceIdx);
12227
+ if (this._api.cacheExternalId(s, o), this._api.mapDecorativeId(s, c), i) this._conversation.externalId = o;
12055
12228
  else {
12056
12229
  let e = this._participants;
12057
12230
  e[t].externalId = o;
@@ -12095,19 +12268,19 @@ var ls = 15, $ = class e extends b {
12095
12268
  _getParticipant(e) {
12096
12269
  return this._participants[e];
12097
12270
  }
12098
- }, us = null, ds = class e extends Error {
12271
+ }, ps = null, ms = class e extends Error {
12099
12272
  constructor(t, n) {
12100
12273
  super(t), h(this, "participantErrors", void 0), Object.setPrototypeOf(this, e.prototype), this.participantErrors = n;
12101
12274
  }
12102
- }, fs = null, ps = null, ms = 64 * 1024;
12103
- function hs() {
12104
- fs = null, ps = null;
12275
+ }, hs = null, gs = null, _s = 64 * 1024;
12276
+ function vs() {
12277
+ hs = null, gs = null;
12105
12278
  }
12106
- function gs(e) {
12279
+ function ys(e) {
12107
12280
  return e?.endsWith("/") ? e.slice(0, -1) : e;
12108
12281
  }
12109
- async function _s(e = null, t) {
12110
- let n = gs(e ?? M.apiBaseUrl);
12282
+ async function bs(e = null, t) {
12283
+ let n = ys(e ?? M.apiBaseUrl);
12111
12284
  if (n) return n;
12112
12285
  if ((t ?? M.apiEnv) !== "AUTO") return M.apiEndpoint(t);
12113
12286
  try {
@@ -12122,25 +12295,25 @@ async function _s(e = null, t) {
12122
12295
  return R.warn("Failed to resolve API endpoint using DNS, default is used", e), M.apiEndpoint(t);
12123
12296
  }
12124
12297
  }
12125
- async function vs() {
12126
- return fs || ps || (ps = _s(), fs = await ps, ps = null, fs);
12298
+ async function xs() {
12299
+ return hs || gs || (gs = bs(), hs = await gs, gs = null, hs);
12127
12300
  }
12128
- async function ys(e, t = {}, n = !1) {
12301
+ async function Ss(e, t = {}, n = !1) {
12129
12302
  if (!window.Blob || !window.navigator.sendBeacon) return;
12130
- await vs();
12131
- let r = Ts(e, t, n), i = new window.Blob([r], { type: "application/x-www-form-urlencoded" });
12132
- window.navigator.sendBeacon(`${fs}/fb.do`, i);
12303
+ await xs();
12304
+ let r = Os(e, t, n), i = new window.Blob([r], { type: "application/x-www-form-urlencoded" });
12305
+ window.navigator.sendBeacon(`${hs}/fb.do`, i);
12133
12306
  }
12134
- async function bs(e, t = {}, n = !1, r) {
12135
- return await vs(), Ss(Ts(e, t, n), r);
12307
+ async function Cs(e, t = {}, n = !1, r) {
12308
+ return await xs(), Ts(Os(e, t, n), r);
12136
12309
  }
12137
- async function xs(e, t = {}, n = !1) {
12138
- await vs();
12139
- let r = Ts(e, t, n);
12140
- return Ss(r, void 0, new Blob([r]).size <= ms);
12310
+ async function ws(e, t = {}, n = !1) {
12311
+ await xs();
12312
+ let r = Os(e, t, n);
12313
+ return Ts(r, void 0, new Blob([r]).size <= _s);
12141
12314
  }
12142
- async function Ss(e, t, n = !1) {
12143
- let r = `${t ?? fs}/fb.do`, i = new AbortController(), a = new O(x.NETWORK, { callError: {
12315
+ async function Ts(e, t, n = !1) {
12316
+ let r = `${t ?? hs}/fb.do`, i = new AbortController(), a = new O(x.NETWORK, { callError: {
12144
12317
  scope: "network",
12145
12318
  source: "api",
12146
12319
  code: "timeout",
@@ -12159,16 +12332,16 @@ async function Ss(e, t, n = !1) {
12159
12332
  } catch {
12160
12333
  o = { result: a };
12161
12334
  }
12162
- if (!t.ok && !Cs(o)) throw new O(x.API, { callError: {
12335
+ if (!t.ok && !Es(o)) throw new O(x.API, { callError: {
12163
12336
  scope: "server",
12164
12337
  source: "api",
12165
12338
  code: `http-${t.status}`,
12166
12339
  description: "http-error"
12167
12340
  } });
12168
- if (Cs(o)) throw o;
12341
+ if (Es(o)) throw o;
12169
12342
  return o;
12170
12343
  } catch (e) {
12171
- throw e instanceof O ? e : i.signal.aborted ? a : Cs(e) ? e : new O(x.NETWORK, { callError: {
12344
+ throw e instanceof O ? e : i.signal.aborted ? a : Es(e) ? e : new O(x.NETWORK, { callError: {
12172
12345
  scope: "network",
12173
12346
  source: "api",
12174
12347
  code: "fetch-failed",
@@ -12178,12 +12351,12 @@ async function Ss(e, t, n = !1) {
12178
12351
  clearTimeout(o);
12179
12352
  }
12180
12353
  }
12181
- function Cs(e) {
12354
+ function Es(e) {
12182
12355
  if (typeof e != "object" || !e) return !1;
12183
12356
  let t = e;
12184
12357
  return typeof t.error_code == "number" && typeof t.error_msg == "string";
12185
12358
  }
12186
- async function ws(e, t) {
12359
+ async function Ds(e, t) {
12187
12360
  try {
12188
12361
  let n = await fetch(e, {
12189
12362
  method: "POST",
@@ -12196,7 +12369,7 @@ async function ws(e, t) {
12196
12369
  throw R.warn("Failed to send form data", e), e;
12197
12370
  }
12198
12371
  }
12199
- function Ts(e, t = {}, n = !1) {
12372
+ function Os(e, t = {}, n = !1) {
12200
12373
  t.method = e, t.format = "JSON", t.application_key || (t.application_key = M.apiKey), n || (y.sessionKey ? t.session_key = y.sessionKey : y.accessToken && (t.access_token = y.accessToken));
12201
12374
  for (let [e, n] of Object.entries(t)) typeof n == "object" && (t[e] = JSON.stringify(n));
12202
12375
  let r = "";
@@ -12205,7 +12378,7 @@ function Ts(e, t = {}, n = !1) {
12205
12378
  }
12206
12379
  //#endregion
12207
12380
  //#region src/abstract/BaseApi.ts
12208
- var Es = class {
12381
+ var ks = class {
12209
12382
  constructor() {
12210
12383
  h(this, "_abortSignal", void 0);
12211
12384
  }
@@ -12223,22 +12396,16 @@ var Es = class {
12223
12396
  }
12224
12397
  log(e) {}
12225
12398
  logClientStats(e) {}
12226
- getCachedOkIdByExternalId(e) {
12399
+ getCachedParticipantIdByExternalId(e) {
12227
12400
  return null;
12228
12401
  }
12229
- getCachedRawOkIdByExternalId(e) {
12230
- return null;
12231
- }
12232
- getCachedExternalIdByOkId(e) {
12402
+ getCachedExternalIdByParticipantId(e) {
12233
12403
  return null;
12234
12404
  }
12235
12405
  cacheExternalId(e, t) {}
12236
12406
  mapDecorativeId(e, t) {}
12237
12407
  unmapDecorativeId(e) {}
12238
12408
  getDecorativeIdByInitialId(e) {}
12239
- replaceByInitialIdIdIfExists(e) {
12240
- return typeof e == "string" ? parseInt(e, 10) : e;
12241
- }
12242
12409
  hangupConversation(e, t = D.HUNGUP, n) {}
12243
12410
  async removeHistoryRecords(e) {}
12244
12411
  async getServerTime() {
@@ -12248,78 +12415,62 @@ var Es = class {
12248
12415
  async getInbounds() {
12249
12416
  return [];
12250
12417
  }
12251
- }, Ds = class e {
12418
+ }, As = class e {
12252
12419
  constructor() {
12253
- h(this, "_okIdToExternalId", /* @__PURE__ */ new Map()), h(this, "_externalIdToOkId", /* @__PURE__ */ new Map()), h(this, "_decorativeIdToInitialId", /* @__PURE__ */ new Map()), h(this, "_initialIdToDecorativeId", /* @__PURE__ */ new Map());
12420
+ h(this, "_participantIdToExternalId", /* @__PURE__ */ new Map()), h(this, "_externalIdToParticipantId", /* @__PURE__ */ new Map()), h(this, "_decorativeIdToInitialId", /* @__PURE__ */ new Map()), h(this, "_initialIdToDecorativeId", /* @__PURE__ */ new Map());
12254
12421
  }
12255
12422
  static _normalizeType(e) {
12256
- return e.type === to.GROUP ? {
12423
+ return e.type === io.GROUP ? {
12257
12424
  ...e,
12258
- type: to.USER
12425
+ type: io.USER
12259
12426
  } : e;
12260
12427
  }
12261
- getOkId(t) {
12262
- let n = Q.toString(e._normalizeType(t)), r = this._externalIdToOkId.get(n);
12263
- return r == null ? null : this.replaceByInitialIdIdIfExists(r);
12264
- }
12265
12428
  getExternalId(e) {
12266
- let t = this.getDecorativeIdByInitialId(e) ?? e, n = this._okIdToExternalId.get(t);
12429
+ let t = this._initialIdToDecorativeId.get(e) ?? e, n = this._participantIdToExternalId.get(t);
12267
12430
  return n == null ? null : Q.fromString(n);
12268
12431
  }
12269
- hasByExternalId(t) {
12270
- return this._externalIdToOkId.has(Q.toString(e._normalizeType(t)));
12271
- }
12272
- hasByOkId(e) {
12273
- return this._okIdToExternalId.has(e);
12432
+ getParticipantId(t) {
12433
+ let n = Q.toString(e._normalizeType(t)), r = this._externalIdToParticipantId.get(n);
12434
+ return r == null ? null : this._decorativeIdToInitialId.get(r) ?? r;
12274
12435
  }
12275
12436
  cache(t, n) {
12276
- let r = j.extractOkId(t), i = e._normalizeType(n), a = Q.toString(i);
12277
- this._okIdToExternalId.set(r, a), this._externalIdToOkId.set(a, r);
12437
+ let r = e._normalizeType(n), i = Q.toString(r);
12438
+ this._participantIdToExternalId.set(t, i), this._externalIdToParticipantId.set(i, t);
12278
12439
  }
12279
12440
  mapDecorativeId(e, t) {
12280
- let n = j.extractOkId(e), r = j.extractOkId(t);
12281
- this._decorativeIdToInitialId.set(n, r), this._initialIdToDecorativeId.set(r, n);
12441
+ this._decorativeIdToInitialId.set(e, t), this._initialIdToDecorativeId.set(t, e);
12282
12442
  }
12283
12443
  unmapDecorativeId(e) {
12284
- let t = j.extractOkId(e), n = this.getDecorativeIdByInitialId(t);
12285
- n && this._decorativeIdToInitialId.delete(n), this._initialIdToDecorativeId.delete(t);
12444
+ let t = this._initialIdToDecorativeId.get(e);
12445
+ t && this._decorativeIdToInitialId.delete(t), this._initialIdToDecorativeId.delete(e);
12286
12446
  }
12287
12447
  getDecorativeIdByInitialId(e) {
12288
- let t = j.extractOkId(e);
12289
- return this._initialIdToDecorativeId.get(t);
12290
- }
12291
- replaceByInitialIdIdIfExists(e) {
12292
- let t = j.extractOkId(e);
12293
- return this._decorativeIdToInitialId.get(t) ?? t;
12294
- }
12295
- getParticipantIdByExternalId(e) {
12296
- let t = this.getOkId(e);
12297
- return t == null ? null : j.composeParticipantId(t, A.USER, e.deviceIdx ?? 0);
12448
+ return this._initialIdToDecorativeId.get(e);
12298
12449
  }
12299
12450
  clear() {
12300
- this._okIdToExternalId.clear(), this._externalIdToOkId.clear(), this._decorativeIdToInitialId.clear(), this._initialIdToDecorativeId.clear();
12451
+ this._participantIdToExternalId.clear(), this._externalIdToParticipantId.clear(), this._decorativeIdToInitialId.clear(), this._initialIdToDecorativeId.clear();
12301
12452
  }
12302
- }, Os = "anonymLogin:", ks = 700, As = 3e3;
12303
- function js(e) {
12453
+ }, js = "anonymLogin:", Ms = 700, Ns = 3e3;
12454
+ function Ps(e) {
12304
12455
  let t = e.error_code;
12305
12456
  switch (t) {
12306
- case 2: return Ms(D.SERVICE_UNAVAILABLE, t, "service-unavailable");
12307
- case 4: return e.error_msg.includes("participants.limit.exceeded") ? Ms(D.PARTICIPANT_LIMIT_REACHED, t, "participants-limit-exceeded") : Ms(x.API, t, "request-error");
12308
- case 300: return Ms(D.NOT_FOUND, t, "not-found");
12309
- case 1101: return Ms(D.SERVICE_DISABLED, t, "vchat-service-disabled");
12310
- case 1102: return Ms(D.CALLEE_IS_OFFLINE, t, "target-user-unavailable");
12311
- case 1103: return Ms(D.NOT_FRIENDS, t, "friendship-required");
12312
- case 1104: return Ns(t, "youla-api-error");
12313
- case 1106: return Ns(t, "vk-api-error");
12314
- case 1113: return Ms(D.CALLER_IS_REJECTED, t, "caller-is-rejected");
12457
+ case 2: return Fs(D.SERVICE_UNAVAILABLE, t, "service-unavailable");
12458
+ case 4: return e.error_msg.includes("participants.limit.exceeded") ? Fs(D.PARTICIPANT_LIMIT_REACHED, t, "participants-limit-exceeded") : Fs(x.API, t, "request-error");
12459
+ case 300: return Fs(D.NOT_FOUND, t, "not-found");
12460
+ case 1101: return Fs(D.SERVICE_DISABLED, t, "vchat-service-disabled");
12461
+ case 1102: return Fs(D.CALLEE_IS_OFFLINE, t, "target-user-unavailable");
12462
+ case 1103: return Fs(D.NOT_FRIENDS, t, "friendship-required");
12463
+ case 1104: return Is(t, "youla-api-error");
12464
+ case 1106: return Is(t, "vk-api-error");
12465
+ case 1113: return Fs(D.CALLER_IS_REJECTED, t, "caller-is-rejected");
12315
12466
  case 1114: {
12316
12467
  let n = e.custom_error?.vchat_detailed_api_error?.code, r = n?.startsWith("obsolete_client");
12317
- return Ms(r ? D.OBSOLETE_CLIENT : D.VCHAT_DETAILED_ERROR, t, n ?? "detailed-error", r ? n : void 0);
12468
+ return Fs(r ? D.OBSOLETE_CLIENT : D.VCHAT_DETAILED_ERROR, t, n ?? "detailed-error", r ? n : void 0);
12318
12469
  }
12319
- default: return Ms(x.API, t, "api-error");
12470
+ default: return Fs(x.API, t, "api-error");
12320
12471
  }
12321
12472
  }
12322
- function Ms(e, t, n, r) {
12473
+ function Fs(e, t, n, r) {
12323
12474
  return {
12324
12475
  type: e,
12325
12476
  callError: {
@@ -12331,7 +12482,7 @@ function Ms(e, t, n, r) {
12331
12482
  message: r
12332
12483
  };
12333
12484
  }
12334
- function Ns(e, t) {
12485
+ function Is(e, t) {
12335
12486
  return {
12336
12487
  type: D.EXTERNAL_API_ERROR,
12337
12488
  callError: {
@@ -12342,19 +12493,19 @@ function Ns(e, t) {
12342
12493
  }
12343
12494
  };
12344
12495
  }
12345
- var Ps = class extends Es {
12496
+ var Ls = class extends ks {
12346
12497
  constructor(...e) {
12347
- super(...e), h(this, "_uuid", void 0), h(this, "_idCache", new Ds());
12498
+ super(...e), h(this, "_uuid", void 0), h(this, "_idCache", new As());
12348
12499
  }
12349
12500
  async _callUnsafe(e, t = {}, n = !1) {
12350
12501
  let r = async (i) => {
12351
12502
  try {
12352
- return await bs(e, t, n);
12503
+ return await Cs(e, t, n);
12353
12504
  } catch (t) {
12354
12505
  if (!t || typeof t != "object" || !Object.hasOwn(t, "error_msg")) {
12355
12506
  i++;
12356
12507
  let n = t && (typeof t == "object" || typeof t == "function") ? Object.getOwnPropertyNames(t).map((e) => `${e}: ${JSON.stringify(t[e])}`) : [String(t)];
12357
- if (R.debug(`${e} network error, attempt ${i}: ${n.join("\n ")}`), this._abortSignal?.aborted && (R.debug(`${e} aborted`), this._abortSignal.throwIfAborted()), i < M.apiMaxAttempt) return await j.delay(Math.min(i * ks, As), { signal: this._abortSignal }), r(i);
12508
+ if (R.debug(`${e} network error, attempt ${i}: ${n.join("\n ")}`), this._abortSignal?.aborted && (R.debug(`${e} aborted`), this._abortSignal.throwIfAborted()), i < M.apiMaxAttempt) return await j.delay(Math.min(i * Ms, Ns), { signal: this._abortSignal }), r(i);
12358
12509
  }
12359
12510
  throw R.warn(e, "error", t), t;
12360
12511
  }
@@ -12377,16 +12528,19 @@ var Ps = class extends Es {
12377
12528
  message: i?.error_msg,
12378
12529
  code: i?.error_code
12379
12530
  };
12380
- if (i.custom_error && (a.custom_error = i.custom_error), Fs(i)) {
12381
- let e = js(i);
12531
+ if (i.custom_error && (a.custom_error = i.custom_error), Rs(i)) {
12532
+ let e = Ps(i);
12382
12533
  throw a.callError = e.callError, a.message = e.message ?? a.message, new O(e.type, a);
12383
12534
  }
12384
12535
  throw new O(x.API, a);
12385
12536
  }
12386
12537
  }
12387
12538
  userId(e) {
12388
- let { compositeUserId: t } = j.decomposeParticipantId(e), { id: n } = j.decomposeId(t);
12389
- return y.isEmpty() ? Q.fromId(String(n)) : this._idCache.getExternalId(n) || Q.fromId(String(n));
12539
+ if (y.isEmpty()) {
12540
+ let { compositeUserId: t } = j.decomposeParticipantId(e), { id: n } = j.decomposeId(t);
12541
+ return Q.fromId(String(n));
12542
+ }
12543
+ return this._idCache.getExternalId(e);
12390
12544
  }
12391
12545
  async authorize() {
12392
12546
  if (this._ensureUuid(), !M.apiKey) throw new O(x.API, {
@@ -12405,7 +12559,7 @@ var Ps = class extends Es {
12405
12559
  let t = { session_data: {
12406
12560
  version: 2,
12407
12561
  device_id: this._uuid,
12408
- client_version: M.appVersion,
12562
+ client_version: M.apiClientVersion,
12409
12563
  client_type: "SDK_JS"
12410
12564
  } };
12411
12565
  return M.authToken && (t.session_data.auth_token = M.authToken, t.session_data.version = 3), this._callUnsafe("auth.anonymLogin", t, !0).then((e) => {
@@ -12424,17 +12578,17 @@ var Ps = class extends Es {
12424
12578
  });
12425
12579
  }
12426
12580
  _getAnonymLoginCacheKey() {
12427
- return M.authToken ? `${Os}${M.authToken}` : null;
12581
+ return M.authToken ? `${js}${M.authToken}` : null;
12428
12582
  }
12429
12583
  _getCachedAnonymLogin() {
12430
12584
  let e = this._getAnonymLoginCacheKey();
12431
12585
  if (!e) return null;
12432
12586
  let t = at.get(e);
12433
- return Is(t) ? t : (t && at.remove(e), null);
12587
+ return zs(t) ? t : (t && at.remove(e), null);
12434
12588
  }
12435
12589
  _setCachedAnonymLogin(e) {
12436
12590
  let t = this._getAnonymLoginCacheKey();
12437
- !t || !Is(e) || at.set(t, {
12591
+ !t || !zs(e) || at.set(t, {
12438
12592
  session_key: e.session_key,
12439
12593
  session_secret_key: e.session_secret_key,
12440
12594
  uid: e.uid
@@ -12452,7 +12606,7 @@ var Ps = class extends Es {
12452
12606
  }
12453
12607
  async _sendClientStats(e, t = !0) {
12454
12608
  try {
12455
- (await xs("vchat.clientStats", e))?.items_responses?.forEach((e) => {
12609
+ (await ws("vchat.clientStats", e))?.items_responses?.forEach((e) => {
12456
12610
  e.errors && R.error("[vchat.clientStats]", e);
12457
12611
  });
12458
12612
  } catch (n) {
@@ -12463,7 +12617,7 @@ var Ps = class extends Es {
12463
12617
  }
12464
12618
  logClientStats(e) {
12465
12619
  let t = {
12466
- app_version: String(M.appVersion),
12620
+ app_version: M.appVersion,
12467
12621
  sdk_type: "WEB",
12468
12622
  sdk_version: M.sdkVersion,
12469
12623
  version: 1,
@@ -12482,14 +12636,14 @@ var Ps = class extends Es {
12482
12636
  }, a = await this._callUnsafe("vchat.getLogUploadUrl", i), o = new FormData(), s = new Blob([r], { type: "application/json" });
12483
12637
  o.append("file", s, "log.json");
12484
12638
  let c = new URL(a.upload_url);
12485
- return c.searchParams.append("size", s.size.toString()), ws(c.toString(), o);
12639
+ return c.searchParams.append("size", s.size.toString()), Ds(c.toString(), o);
12486
12640
  }
12487
12641
  async joinConversation(e, t = !1, n) {
12488
12642
  let r = {
12489
12643
  conversationId: e,
12490
12644
  isVideo: t,
12491
12645
  protocolVersion: M.protocolVersion,
12492
- capabilities: xa.getFlags()
12646
+ capabilities: wa.getFlags()
12493
12647
  };
12494
12648
  return n && (r.chatId = n), this._call("vchat.joinConversation", r);
12495
12649
  }
@@ -12521,13 +12675,13 @@ var Ps = class extends Es {
12521
12675
  externalIds: l
12522
12676
  });
12523
12677
  if (t && t.length) switch (n) {
12524
- case Va.USER:
12678
+ case Wa.USER:
12525
12679
  u.uids = t.join(",");
12526
12680
  break;
12527
- case Va.GROUP:
12681
+ case Wa.GROUP:
12528
12682
  u.gid = t[0];
12529
12683
  break;
12530
- case Va.CHAT:
12684
+ case Wa.CHAT:
12531
12685
  u.chatId = t[0];
12532
12686
  break;
12533
12687
  }
@@ -12570,17 +12724,14 @@ var Ps = class extends Es {
12570
12724
  joinLink: e,
12571
12725
  isVideo: t,
12572
12726
  protocolVersion: M.protocolVersion,
12573
- capabilities: xa.getFlags()
12727
+ capabilities: wa.getFlags()
12574
12728
  };
12575
12729
  return n?.length && (i.observedIds = n.join(",")), M.anonymToken && (i.anonymToken = M.anonymToken), r && (i.payload = r), this._call("vchat.joinConversationByLink", i);
12576
12730
  }
12577
- getCachedOkIdByExternalId(e) {
12578
- return this._idCache.getParticipantIdByExternalId(e);
12731
+ getCachedParticipantIdByExternalId(e) {
12732
+ return this._idCache.getParticipantId(e);
12579
12733
  }
12580
- getCachedRawOkIdByExternalId(e) {
12581
- return this._idCache.getOkId(e);
12582
- }
12583
- getCachedExternalIdByOkId(e) {
12734
+ getCachedExternalIdByParticipantId(e) {
12584
12735
  return this._idCache.getExternalId(e);
12585
12736
  }
12586
12737
  cacheExternalId(e, t) {
@@ -12595,9 +12746,6 @@ var Ps = class extends Es {
12595
12746
  getDecorativeIdByInitialId(e) {
12596
12747
  return this._idCache.getDecorativeIdByInitialId(e);
12597
12748
  }
12598
- replaceByInitialIdIdIfExists(e) {
12599
- return this._idCache.replaceByInitialIdIdIfExists(e);
12600
- }
12601
12749
  async getConversationParams(e) {
12602
12750
  let t = {};
12603
12751
  return M.anonymToken && (t.anonymToken = M.anonymToken), e && (t.conversationId = e), this._call("vchat.getConversationParams", t);
@@ -12613,7 +12761,7 @@ var Ps = class extends Es {
12613
12761
  conversationId: e,
12614
12762
  reason: t
12615
12763
  };
12616
- M.anonymToken && (r.anonymToken = M.anonymToken), n?.peerId && (r.peerId = n.peerId), ys("vchat.hangupConversation", r);
12764
+ M.anonymToken && (r.anonymToken = M.anonymToken), n?.peerId && (r.peerId = n.peerId), Ss("vchat.hangupConversation", r);
12617
12765
  }
12618
12766
  async removeHistoryRecords(e) {
12619
12767
  await this._call("vchat.removeHistoryRecords", { recordIds: e.join(",") });
@@ -12629,19 +12777,19 @@ var Ps = class extends Es {
12629
12777
  return Array.isArray(e?.inbounds) ? e.inbounds : [];
12630
12778
  }
12631
12779
  };
12632
- function Fs(e) {
12780
+ function Rs(e) {
12633
12781
  return typeof e == "object" && !!e && "error_code" in e && "error_msg" in e;
12634
12782
  }
12635
- function Is(e) {
12783
+ function zs(e) {
12636
12784
  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;
12637
12785
  }
12638
12786
  //#endregion
12639
12787
  //#region src/enums/RecordRole.ts
12640
- var Ls = /* @__PURE__ */ function(e) {
12788
+ var Bs = /* @__PURE__ */ function(e) {
12641
12789
  return e.KING = "KING", e.PAWN = "PAWN", e;
12642
- }(Ls || {}), Rs = /* @__PURE__ */ function(e) {
12790
+ }(Bs || {}), Vs = /* @__PURE__ */ function(e) {
12643
12791
  return e.OFF = "0", e.ON = "1", e;
12644
- }({}), zs = class {
12792
+ }({}), Hs = class {
12645
12793
  constructor(e) {
12646
12794
  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;
12647
12795
  }
@@ -12664,21 +12812,21 @@ var Ls = /* @__PURE__ */ function(e) {
12664
12812
  let e = this._queue[this._readCursor];
12665
12813
  return e && (this._moveReadCursor = !1, this._queue[this._readCursor] = null, this._readCursor = this.nextCursor(this._readCursor), --this._left), e;
12666
12814
  }
12667
- }, Bs = class {
12815
+ }, Us = class {
12668
12816
  constructor(e, t, n, r = null) {
12669
12817
  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 = j.uuid(), this._apiKey = t, this._callToken = n, this._apiEnv = e, this._baseApiUrl = r;
12670
12818
  }
12671
12819
  async authorize() {
12672
- let e = await bs("auth.anonymLogin", {
12820
+ let e = await Cs("auth.anonymLogin", {
12673
12821
  session_data: {
12674
12822
  device_id: this._uuid,
12675
- client_version: M.appVersion,
12823
+ client_version: M.apiClientVersion,
12676
12824
  client_type: "SDK_JS",
12677
12825
  auth_token: this._callToken,
12678
12826
  version: 3
12679
12827
  },
12680
12828
  application_key: this._apiKey
12681
- }, !0, await _s(this._baseApiUrl, this._apiEnv));
12829
+ }, !0, await bs(this._baseApiUrl, this._apiEnv));
12682
12830
  return j.isObject(e) && !("error_msg" in e) ? (this._sessionKey = e.session_key, !0) : !1;
12683
12831
  }
12684
12832
  async hangupConversation(e, t) {
@@ -12688,9 +12836,9 @@ var Ls = /* @__PURE__ */ function(e) {
12688
12836
  application_key: this._apiKey,
12689
12837
  session_key: this._sessionKey
12690
12838
  };
12691
- t?.peerId && (n.peerId = t.peerId), await bs("vchat.hangupConversation", n, !0, await _s(this._baseApiUrl, this._apiEnv));
12839
+ t?.peerId && (n.peerId = t.peerId), await Cs("vchat.hangupConversation", n, !0, await bs(this._baseApiUrl, this._apiEnv));
12692
12840
  }
12693
- }, Vs, Hs = null, Us = {
12841
+ }, Ws, Gs = null, Ks = {
12694
12842
  getCameras: T.getCameras,
12695
12843
  getMicrophones: T.getMicrophones,
12696
12844
  getOutput: T.getOutput,
@@ -12716,27 +12864,27 @@ var Ls = /* @__PURE__ */ function(e) {
12716
12864
  baseChromeVersion: T.baseChromeVersion,
12717
12865
  getAudioContext: T.getAudioContext,
12718
12866
  isAudioShareSupported: T.isAudioShareSupported
12719
- }, Ws = { participantMarkerCompare: j.participantMarkerCompare };
12720
- function Gs(e) {
12721
- Hs = e;
12867
+ }, qs = { participantMarkerCompare: j.participantMarkerCompare };
12868
+ function Js(e) {
12869
+ Gs = e;
12722
12870
  }
12723
- function Ks(e) {
12871
+ function Ys(e) {
12724
12872
  M.videoEffects = e;
12725
12873
  }
12726
- function qs(e) {
12874
+ function Xs(e) {
12727
12875
  M.audioEffects = e;
12728
12876
  }
12729
- function Js(e, t = {}) {
12877
+ function Zs(e, t = {}) {
12730
12878
  M.vad = e, M.vadOptions = t;
12731
12879
  }
12732
- function Ys(e, t = null, n = {}, r = 1) {
12880
+ function Qs(e, t = null, n = {}, r = 1) {
12733
12881
  M.vmoji = e, M.vmojiOptions = {
12734
12882
  protocolVersion: r,
12735
12883
  renderingOptions: n
12736
12884
  }, t && e.setSDK(t);
12737
12885
  }
12738
- async function Xs(t) {
12739
- M.set(t), Vs || (Vs = new Ps()), e.disableLog(!M.debug), R.toggle(M.debug), R.log(`Calls SDK ${M.sdkVersion}`, t), await T.init();
12886
+ async function $s(t) {
12887
+ M.set(t), Ws || (Ws = new Ls()), e.disableLog(!M.debug), R.toggle(M.debug), R.log(`Calls SDK ${M.sdkVersion}`, t), await T.init();
12740
12888
  let n = T.getBrowserSupportFailure();
12741
12889
  if (n) throw new O(x.UNSUPPORTED, { callError: {
12742
12890
  scope: "internal",
@@ -12745,13 +12893,19 @@ async function Xs(t) {
12745
12893
  } });
12746
12894
  R.log("UserAgent:", navigator.userAgent), R.log("Screen resolution:", `${window.screen.width}x${window.screen.height}`), R.log("Permissions:", `Camera: ${T.hasCameraPermission()}, Mic: ${T.hasMicrophonePermission()}`), R.log("Simulcast:", `${t.simulcast} => ${M.simulcast}`);
12747
12895
  }
12748
- async function Zs(e, t = [S.AUDIO], n = "", r = !1, i = !1, a, o, s) {
12896
+ async function ec(e, t = [S.AUDIO], n = "", r = !1, i = !1, a, o, s) {
12749
12897
  let c = [];
12750
- return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), Qs([], Va.USER, t, n, r, i, a, c, o, s);
12898
+ return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), nc([], Wa.USER, t, n, r, i, a, c, o, s);
12751
12899
  }
12752
- async function Qs(e, t = Va.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12753
- if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12754
- return new $(new Ps(), Hs).onStart({
12900
+ function tc(e, t = []) {
12901
+ let n = e.getIncomingCallerExternalId();
12902
+ return n ? t.length === 1 && t[0].id === n.id && t[0].type === n.type : !1;
12903
+ }
12904
+ async function nc(e, t = Wa.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12905
+ if (!M.hold && z.getActive()) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12906
+ let u = z.getAll().find((e) => e.isIncomingRinging);
12907
+ if (!M.hold && u && !tc(u, s)) throw R.error("There is already incoming call"), new O(D.HAS_ACTIVE_CALL);
12908
+ return new $(new Ls(), Gs).onStart({
12755
12909
  opponentIds: e,
12756
12910
  opponentType: t,
12757
12911
  mediaOptions: n,
@@ -12764,40 +12918,40 @@ async function Qs(e, t = Va.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12764
12918
  conversationId: l
12765
12919
  });
12766
12920
  }
12767
- async function $s(e, t) {
12768
- return ec(e, A.USER, void 0, t);
12921
+ async function rc(e, t) {
12922
+ return ic(e, A.USER, void 0, t);
12769
12923
  }
12770
- async function ec(e, t = A.USER, n, r, i, a) {
12924
+ async function ic(e, t = A.USER, n, r, i, a) {
12771
12925
  if (e === $.id()) throw Error("Push has already been processed");
12772
- return new $(new Ps(), Hs).onPush(e, t, n, r, i, a);
12926
+ return new $(new Ls(), Gs).onPush(e, t, n, r, i, a);
12773
12927
  }
12774
- async function tc() {
12775
- return Vs.getInbounds();
12928
+ async function ac() {
12929
+ return Ws.getInbounds();
12776
12930
  }
12777
- async function nc(e, t) {
12778
- return e && (M.authToken = e), t !== void 0 && M.apiBaseUrl !== t && (M.apiBaseUrl = t, hs()), Vs.authorize();
12931
+ async function oc(e, t) {
12932
+ return e && (M.authToken = e), t !== void 0 && M.apiBaseUrl !== t && (M.apiBaseUrl = t, vs()), Ws.authorize();
12779
12933
  }
12780
- async function rc(e = [S.AUDIO], t) {
12781
- return El(t).accept(e);
12934
+ async function sc(e = [S.AUDIO], t) {
12935
+ return Ml(t).accept(e);
12782
12936
  }
12783
- async function ic(e) {
12784
- let t = Tl(e?.conversationId);
12937
+ async function cc(e) {
12938
+ let t = kl(e?.conversationId);
12785
12939
  if (t) return t.decline(e);
12786
12940
  }
12787
- async function ac(e, t = [S.AUDIO]) {
12788
- return oc(e, t);
12941
+ async function lc(e, t = [S.AUDIO]) {
12942
+ return uc(e, t);
12789
12943
  }
12790
- async function oc(e, t, n) {
12944
+ async function uc(e, t, n) {
12791
12945
  if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12792
- return new $(new Ps(), Hs).onJoin({
12946
+ return new $(new Ls(), Gs).onJoin({
12793
12947
  conversationId: e,
12794
12948
  mediaOptions: t,
12795
12949
  chatId: n
12796
12950
  });
12797
12951
  }
12798
- async function sc(e, t = [S.AUDIO], n, r, i, a) {
12952
+ async function dc(e, t = [S.AUDIO], n, r, i, a) {
12799
12953
  if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12800
- return n && (M.anonymToken = n), new $(new Ps(), Hs).onJoin({
12954
+ return n && (M.anonymToken = n), new $(new Ls(), Gs).onJoin({
12801
12955
  joinLink: e,
12802
12956
  mediaOptions: t,
12803
12957
  observedIds: r,
@@ -12806,30 +12960,30 @@ async function sc(e, t = [S.AUDIO], n, r, i, a) {
12806
12960
  anonymous: !!M.anonymToken
12807
12961
  });
12808
12962
  }
12809
- function cc(e) {
12810
- let t = Tl(e?.conversationId);
12963
+ function fc(e) {
12964
+ let t = kl(e?.conversationId);
12811
12965
  return t ? t.hangup(e) : ($.hangupAfterInit(e?.onFastHangup), Promise.resolve());
12812
12966
  }
12813
- async function lc(e, t) {
12967
+ async function pc(e, t) {
12814
12968
  let n = Array.isArray(e) ? e : [e], r = $.current();
12815
12969
  r && await r.addParticipant(n, t);
12816
12970
  }
12817
- async function uc(e, t) {
12971
+ async function mc(e, t) {
12818
12972
  let n = $.current();
12819
12973
  if (n) {
12820
12974
  let r = e.map((e) => j.composeUserId(e));
12821
12975
  await n.addParticipantLegacy(r, t);
12822
12976
  }
12823
12977
  }
12824
- async function dc(e, t = !1) {
12825
- let n = $.current()?.getCachedRawOkIdByExternalId(e) ?? null;
12826
- if (!n) {
12827
- R.warn("removeParticipant: externalId not found in cache", e);
12828
- return;
12978
+ async function hc(e, t = !1) {
12979
+ let n = Nl(e, "removeParticipant");
12980
+ if (n) try {
12981
+ await n.conversation.removeParticipant(j.decomposeParticipantId(n.participantId).compositeUserId, t);
12982
+ } catch (e) {
12983
+ R.warn(`Failed to remove participant ${n.participantId}. Perhaps he is no longer on the call. ${e}`);
12829
12984
  }
12830
- return fc(n, t);
12831
12985
  }
12832
- async function fc(e, t = !1) {
12986
+ async function gc(e, t = !1) {
12833
12987
  let n = $.current();
12834
12988
  if (n) try {
12835
12989
  await n.removeParticipant(j.composeUserId(e), t);
@@ -12837,13 +12991,13 @@ async function fc(e, t = !1) {
12837
12991
  R.warn(`Failed to remove participant ${e}. Perhaps he is no longer on the call. ${t}`);
12838
12992
  }
12839
12993
  }
12840
- async function pc(e, t) {
12994
+ async function _c(e, t) {
12841
12995
  let n = $.current();
12842
12996
  if (e === "videoinput" && jt.contains(t)) return M.videoFacingMode = t, n ? (T.isMobile() && n.stopVideoTrack(), n.changeDevice(e)) : void 0;
12843
12997
  if (!await T._saveDeviceId(e, t)) throw Error(`Device not found: ${t}`);
12844
12998
  if (n) return n.changeDevice(e);
12845
12999
  }
12846
- async function mc(e, t) {
13000
+ async function vc(e, t) {
12847
13001
  let n = typeof e == "object" ? {
12848
13002
  ...e,
12849
13003
  fastScreenSharing: e.captureScreen && e.fastScreenSharing,
@@ -12852,267 +13006,264 @@ async function mc(e, t) {
12852
13006
  captureScreen: e,
12853
13007
  fastScreenSharing: !1,
12854
13008
  captureAudio: !1
12855
- }, r = Tl(t);
13009
+ }, r = kl(t);
12856
13010
  return r ? r.toggleScreenCapturing(n) : Promise.reject();
12857
13011
  }
12858
- function hc(e) {
13012
+ function yc(e) {
12859
13013
  let t = $.current();
12860
13014
  t && t.toggleAnimojiCapturing(e);
12861
13015
  }
12862
- async function gc(e, t = !1) {
13016
+ async function bc(e, t = !1) {
12863
13017
  let n = $.current();
12864
13018
  n && await n.setVideoStream(e, t);
12865
13019
  }
12866
- async function _c(e, t) {
12867
- let n = Tl(t);
13020
+ async function xc(e, t) {
13021
+ let n = kl(t);
12868
13022
  n && await n.toggleLocalVideo(e);
12869
13023
  }
12870
- async function vc(e, t) {
12871
- let n = Tl(t);
13024
+ async function Sc(e, t) {
13025
+ let n = kl(t);
12872
13026
  n && await n.toggleLocalAudio(e);
12873
13027
  }
12874
- async function yc(e) {
13028
+ async function Cc(e) {
12875
13029
  let t = $.current();
12876
13030
  if (t) return t.setLocalResolution(e);
12877
13031
  }
12878
- async function bc(e) {
13032
+ async function wc(e) {
12879
13033
  let t = $.current();
12880
13034
  t && await t.changePriorities(e);
12881
13035
  }
12882
- async function xc(e, t) {
13036
+ async function Tc(e, t) {
12883
13037
  let n = $.current();
12884
13038
  if (n) {
12885
- let r;
12886
13039
  if (t) {
12887
- let e = n.getCachedRawOkIdByExternalId(t);
12888
- if (!e) {
12889
- R.warn("changeParticipantState: externalId not found in cache", t);
13040
+ let r = n.getCachedParticipantIdByExternalId(t);
13041
+ if (!r) {
13042
+ Al(t, "changeParticipantState", n);
12890
13043
  return;
12891
13044
  }
12892
- r = j.composeParticipantId(e, A.USER, t.deviceIdx);
13045
+ await n.changeParticipantState(e, r);
13046
+ return;
12893
13047
  }
12894
- await n.changeParticipantState(e, r);
13048
+ await n.changeParticipantState(e);
12895
13049
  }
12896
13050
  }
12897
- async function Sc() {
13051
+ async function Ec() {
12898
13052
  let e = $.current();
12899
13053
  e && await e.putHandsDown();
12900
13054
  }
12901
- async function Cc(e) {
13055
+ async function Dc(e) {
12902
13056
  let t = $.current();
12903
13057
  t && await t.updateDisplayLayout(e);
12904
13058
  }
12905
- async function wc(e) {
13059
+ async function Oc(e) {
12906
13060
  let t = $.current();
12907
13061
  t && await t.requestDisplayLayout(e);
12908
13062
  }
12909
- async function Tc(e, t, n = !1) {
12910
- let r = $.current()?.getCachedRawOkIdByExternalId(e) ?? null;
12911
- if (!r) {
12912
- R.warn("grantRoles: externalId not found in cache", e);
12913
- return;
12914
- }
12915
- return Ec(r, Q.getDeviceIdx(e), t, n);
13063
+ async function kc(e, t, n = !1) {
13064
+ let r = Nl(e, "grantRoles");
13065
+ r && await r.conversation.grantRoles(r.participantId, t, n);
12916
13066
  }
12917
- async function Ec(e, t, n, r = !1) {
13067
+ async function Ac(e, t, n, r = !1) {
12918
13068
  let i = $.current();
12919
13069
  i && await i.grantRoles(j.composeParticipantId(e, A.USER, t), n, r);
12920
13070
  }
12921
- async function Dc({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
12922
- let i = null;
12923
- return e && (i = $.current()?.getCachedRawOkIdByExternalId(e) ?? null, i || R.warn("muteParticipant: externalId not found in cache", e)), Oc({
12924
- uid: i,
12925
- muteStates: t,
12926
- requestedMedia: n,
12927
- deviceIdx: Q.getDeviceIdx(e),
12928
- roomId: r
12929
- });
13071
+ async function jc({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
13072
+ if (e) {
13073
+ let i = Nl(e, "muteParticipant");
13074
+ return i ? i.conversation.muteParticipant(i.participantId, t, n, r) : void 0;
13075
+ }
13076
+ let i = $.current();
13077
+ i && await i.muteParticipant(null, t, n, r);
12930
13078
  }
12931
- async function Oc({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
13079
+ async function Mc({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
12932
13080
  let a = $.current();
12933
13081
  if (a) {
12934
13082
  let o = e ? j.composeParticipantId(e, A.USER, r) : null;
12935
13083
  await a.muteParticipant(o, t, n, i);
12936
13084
  }
12937
13085
  }
12938
- async function kc(e, t = !1, n = null) {
12939
- let r = $.current()?.getCachedRawOkIdByExternalId(e) ?? null;
12940
- if (!r) {
12941
- R.warn("pinParticipant: externalId not found in cache", e);
12942
- return;
12943
- }
12944
- return Ac(r, t, Q.getDeviceIdx(e), n);
13086
+ async function Nc(e, t = !1, n = null) {
13087
+ let r = Nl(e, "pinParticipant");
13088
+ r && await r.conversation.pinParticipant(r.participantId, t, n);
12945
13089
  }
12946
- async function Ac(e, t = !1, n = 0, r = null) {
13090
+ async function Pc(e, t = !1, n = 0, r = null) {
12947
13091
  let i = $.current();
12948
13092
  i && await i.pinParticipant(j.composeParticipantId(e, A.USER, n), t, r);
12949
13093
  }
12950
- async function jc(e) {
13094
+ async function Fc(e) {
12951
13095
  let t = $.current();
12952
13096
  t && await t.updateMediaModifiers(e);
12953
13097
  }
12954
- async function Mc(e) {
13098
+ async function Ic(e) {
12955
13099
  let t = $.current();
12956
13100
  t && await t.enableVideoSuspend(e);
12957
13101
  }
12958
- async function Nc(e) {
13102
+ async function Lc(e) {
12959
13103
  let t = $.current();
12960
13104
  t && await t.enableVideoSuspendSuggest(e);
12961
13105
  }
12962
- async function Pc(e) {
13106
+ async function Rc(e) {
12963
13107
  let t = $.current();
12964
13108
  t && await t.changeOptions(e);
12965
13109
  }
12966
- async function Fc(e, t = null) {
12967
- let n = null;
12968
- return t && (n = $.current()?.getCachedRawOkIdByExternalId(t) ?? null, n || R.warn("chatMessage: externalId not found in cache", t)), Ic(e, n);
13110
+ async function zc(e, t = null) {
13111
+ if (t) {
13112
+ let n = Nl(t, "chatMessage");
13113
+ return n ? n.conversation.chatMessage(e, j.decomposeParticipantId(n.participantId).compositeUserId) : void 0;
13114
+ }
13115
+ let n = $.current();
13116
+ n && await n.chatMessage(e, null);
12969
13117
  }
12970
- async function Ic(e, t = null) {
13118
+ async function Bc(e, t = null) {
12971
13119
  let n = $.current();
12972
13120
  if (n) {
12973
13121
  let r = t ? j.composeUserId(t) : null;
12974
13122
  await n.chatMessage(e, r);
12975
13123
  }
12976
13124
  }
12977
- async function Lc(e = 10) {
13125
+ async function Vc(e = 10) {
12978
13126
  let t = $.current();
12979
13127
  if (t) return t.chatHistory(e);
12980
13128
  }
12981
- async function Rc(e, t = null) {
12982
- let n = null;
12983
- return t && (n = $.current()?.getCachedRawOkIdByExternalId(t) ?? null, n || R.warn("customData: externalId not found in cache", t)), zc(e, n, Q.getDeviceIdx(t));
13129
+ async function Hc(e, t = null) {
13130
+ if (t) {
13131
+ let n = Nl(t, "customData");
13132
+ return n ? n.conversation.customData(e, n.participantId) : void 0;
13133
+ }
13134
+ let n = $.current();
13135
+ n && await n.customData(e, null);
12984
13136
  }
12985
- async function zc(e, t = null, n = 0) {
13137
+ async function Uc(e, t = null, n = 0) {
12986
13138
  let r = $.current();
12987
13139
  if (r) {
12988
13140
  let i = t ? j.composeParticipantId(t, A.USER, n) : null;
12989
13141
  await r.customData(e, i);
12990
13142
  }
12991
13143
  }
12992
- async function Bc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
12993
- return (await Vs.createConversation(a ?? j.uuid(), e, t, {
13144
+ async function Wc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
13145
+ return (await Ws.createConversation(a ?? j.uuid(), e, t, {
12994
13146
  onlyAdminCanShareMovie: n,
12995
13147
  waitForAdmin: r,
12996
13148
  closedConversation: i
12997
13149
  })).join_link;
12998
13150
  }
12999
- async function Vc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
13151
+ async function Gc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
13000
13152
  let a = i.map((e) => Q.fromId(e));
13001
- return (await Vs.createConversation(j.uuid(), e, t, {
13153
+ return (await Ws.createConversation(j.uuid(), e, t, {
13002
13154
  onlyAdminCanShareMovie: n,
13003
13155
  audienceMode: !0,
13004
13156
  audioOnly: r
13005
13157
  }, a)).join_link;
13006
13158
  }
13007
- async function Hc() {
13159
+ async function Kc() {
13008
13160
  let e = $.current();
13009
13161
  return e ? e.createJoinLink() : Promise.reject();
13010
13162
  }
13011
- async function Uc() {
13163
+ async function qc() {
13012
13164
  let e = $.current();
13013
13165
  return e ? e.removeJoinLink() : Promise.reject();
13014
13166
  }
13015
- async function Wc(e, t) {
13016
- return Vs.getAnonymTokenByLink(e, t);
13167
+ async function Jc(e, t) {
13168
+ return Ws.getAnonymTokenByLink(e, t);
13017
13169
  }
13018
- function Gc(e) {
13170
+ function Yc(e) {
13019
13171
  let t = $.current();
13020
13172
  t && t.setVolume(e);
13021
13173
  }
13022
- function Kc(e) {
13174
+ function Xc(e) {
13023
13175
  M.forceRelayPolicy = e;
13024
13176
  }
13025
- async function qc(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
13177
+ async function Zc(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
13026
13178
  let o = $.current();
13027
13179
  return o ? o.startStream(e, t, n, r, i, a) : Promise.reject();
13028
13180
  }
13029
- async function Jc(e = null, t) {
13181
+ async function Qc(e = null, t) {
13030
13182
  let n = $.current();
13031
13183
  return n ? n.stopStream(e, t) : Promise.reject();
13032
13184
  }
13033
- async function Yc(e = null) {
13185
+ async function $c(e = null) {
13034
13186
  let t = $.current();
13035
13187
  return t ? t.publishStream(e) : Promise.reject();
13036
13188
  }
13037
- async function Xc() {
13189
+ async function el() {
13038
13190
  let e = $.current();
13039
13191
  return e ? e.getStreamInfo() : Promise.reject();
13040
13192
  }
13041
- async function Zc(e) {
13193
+ async function tl(e) {
13042
13194
  let t = $.current();
13043
13195
  return t ? t.addMovie(e) : Promise.reject();
13044
13196
  }
13045
- async function Qc(e) {
13197
+ async function nl(e) {
13046
13198
  let t = $.current();
13047
13199
  return t ? t.updateMovie(e) : Promise.reject();
13048
13200
  }
13049
- async function $c(e) {
13201
+ async function rl(e) {
13050
13202
  let t = $.current();
13051
13203
  return t ? t.removeMovie(e) : Promise.reject();
13052
13204
  }
13053
- async function el(e, t) {
13205
+ async function il(e, t) {
13054
13206
  let n = $.current();
13055
13207
  if (n) {
13056
- let r = [];
13208
+ let r = [], i = [];
13057
13209
  for (let t of e) {
13058
- let e, i;
13210
+ let e, a;
13059
13211
  t.addParticipantIds && (e = [], t.addParticipantIds.forEach((t) => {
13060
- let r = n.getCachedRawOkIdByExternalId(t);
13061
- r ? e.push(j.composeUserId(r)) : R.warn("updateRooms addParticipant: externalId not found in cache", t);
13062
- })), t.removeParticipantIds && (i = [], t.removeParticipantIds.forEach((e) => {
13063
- let t = n.getCachedRawOkIdByExternalId(e);
13064
- t ? i.push(j.composeUserId(t)) : R.warn("updateRooms removeParticipant: externalId not found in cache", e);
13212
+ let r = n.getCachedParticipantIdByExternalId(t);
13213
+ r ? e.push(j.decomposeParticipantId(r).compositeUserId) : i.push(t.id);
13214
+ })), t.removeParticipantIds && (a = [], t.removeParticipantIds.forEach((e) => {
13215
+ let t = n.getCachedParticipantIdByExternalId(e);
13216
+ t ? a.push(j.decomposeParticipantId(t).compositeUserId) : i.push(e.id);
13065
13217
  })), r.push({
13066
13218
  id: t.id,
13067
13219
  name: t.name,
13068
13220
  participantCount: t.participantCount,
13069
13221
  addParticipantIds: e,
13070
- removeParticipantIds: i,
13222
+ removeParticipantIds: a,
13071
13223
  countdownSec: t.countdownSec
13072
13224
  });
13073
13225
  }
13226
+ if (i.length) {
13227
+ jl(i, "updateRooms", n);
13228
+ return;
13229
+ }
13074
13230
  return n.updateRooms(r, t);
13075
13231
  }
13076
13232
  return Promise.reject();
13077
13233
  }
13078
- async function tl(e, t) {
13234
+ async function al(e, t) {
13079
13235
  let n = $.current();
13080
13236
  return n ? n.activateRooms(e, t) : Promise.reject();
13081
13237
  }
13082
- async function nl(e = null, t = null) {
13238
+ async function ol(e = null, t = null) {
13083
13239
  let n = $.current();
13084
13240
  if (!n) return Promise.reject();
13085
13241
  let r;
13086
- if (t) {
13087
- let e = n.getCachedRawOkIdByExternalId(t);
13088
- if (!e) {
13089
- R.warn("switchRoom: externalId not found in cache", t);
13090
- return;
13091
- }
13092
- let i = Q.getDeviceIdx(t);
13093
- r = j.composeParticipantId(e, A.USER, i);
13242
+ if (t && (r = n.getCachedParticipantIdByExternalId(t) ?? void 0, !r)) {
13243
+ Al(t, "switchRoom", n);
13244
+ return;
13094
13245
  }
13095
13246
  return n.switchRoom(e, r);
13096
13247
  }
13097
- async function rl(e) {
13248
+ async function sl(e) {
13098
13249
  let t = $.current();
13099
13250
  return t ? t.removeRooms(e) : Promise.reject();
13100
13251
  }
13101
- function il(e) {
13252
+ function cl(e) {
13102
13253
  M.statisticsInterval = e;
13103
13254
  let t = $.current();
13104
13255
  if (t) return t.updateStatisticsInterval();
13105
13256
  }
13106
- function al(t) {
13257
+ function ll(t) {
13107
13258
  e.disableLog(!t), R.toggle(t);
13108
13259
  }
13109
- function ol(e, ...t) {
13260
+ function ul(e, ...t) {
13110
13261
  M.debugLog && ($.debugMessage(e, "[external]", ...t) || R.send(e, "[external]", ...t));
13111
13262
  }
13112
- function sl(e, t, ...n) {
13263
+ function dl(e, t, ...n) {
13113
13264
  M.debugLog && ($.debugMessageWithContext(e, t, "[external]", ...n) || R.send(e, "[external]", ...n));
13114
13265
  }
13115
- var cl = {
13266
+ var fl = {
13116
13267
  list: Ne,
13117
13268
  get: Pe,
13118
13269
  getJson: Fe,
@@ -13120,7 +13271,7 @@ var cl = {
13120
13271
  clear: Le,
13121
13272
  stats: Re
13122
13273
  };
13123
- function ll() {
13274
+ function pl() {
13124
13275
  let e = [
13125
13276
  [`Calls SDK ${M.sdkVersion}`, M.toJSON()],
13126
13277
  ["UserAgent:", navigator.userAgent],
@@ -13137,124 +13288,139 @@ function ll() {
13137
13288
  d: e
13138
13289
  }));
13139
13290
  }
13140
- async function ul() {
13291
+ async function ml() {
13141
13292
  let e = $.id(), t = $.debugSessionId();
13142
13293
  if (!t || !e) throw R.error("[uploadDebugLogs]", "No conversation id found"), Error("No conversation id found");
13143
13294
  let n = await Pe({ sessionId: t });
13144
13295
  if (n.length === 0) throw R.error("[uploadDebugLogs]", "No logs found"), Error("No logs found");
13145
13296
  let r = n[0].t, i = n[n.length - 1].t;
13146
13297
  try {
13147
- return Vs?.uploadDebugLogs(e, r, i, JSON.stringify([...ll(), ...n]));
13298
+ return Ws?.uploadDebugLogs(e, r, i, JSON.stringify([...pl(), ...n]));
13148
13299
  } catch (e) {
13149
13300
  throw R.error("[uploadDebugLogs]", "Error while uploading logs", e), Error("Error while uploading logs", { cause: e });
13150
13301
  }
13151
13302
  }
13152
- async function dl(e) {
13303
+ async function hl(e) {
13153
13304
  let t = $.current();
13154
13305
  if (t) return t.videoEffect(e);
13155
13306
  }
13156
- async function fl(e, t) {
13307
+ async function gl(e, t) {
13157
13308
  let n = $.current();
13158
13309
  if (n) return n.audioEffect(e.length > 0 ? e : null, t);
13159
13310
  }
13160
- async function pl(e) {
13311
+ async function _l(e) {
13161
13312
  let t = $.current();
13162
13313
  t && await t.setAudioStream(e);
13163
13314
  }
13164
- async function ml(e, t = null, n = null) {
13315
+ async function vl(e, t = null, n = null) {
13165
13316
  let r = $.current();
13166
13317
  if (!r) return;
13167
13318
  let i = n ?? t?.id, a = null;
13168
- if (t) {
13169
- let e = r.getCachedRawOkIdByExternalId(t);
13170
- if (!e) throw Error("Could not get user id to set animoji svg");
13171
- a = j.composeParticipantId(e, A.USER, Q.getDeviceIdx(t));
13319
+ if (t && (a = r.getCachedParticipantIdByExternalId(t), !a)) {
13320
+ Al(t, "setVmojiSvg", r);
13321
+ return;
13172
13322
  }
13173
13323
  r.setAnimojiSvg(e, a, i);
13174
13324
  }
13175
- function hl(e) {
13325
+ function yl(e) {
13176
13326
  let t = $.current();
13177
13327
  t && t.setAnimojiFill(e);
13178
13328
  }
13179
- async function gl(e = null, t, n = !1) {
13180
- return El().getWaitingHall(e, t, n);
13329
+ async function bl(e = null, t, n = !1) {
13330
+ return Ml().getWaitingHall(e, t, n);
13181
13331
  }
13182
- async function _l() {
13183
- return El().getAudienceModeHands();
13332
+ async function xl() {
13333
+ return Ml().getAudienceModeHands();
13184
13334
  }
13185
- async function vl(e, t = !1) {
13186
- let n = El(), r;
13335
+ async function Sl(e, t = !1) {
13336
+ let n = Ml(), r;
13187
13337
  if (e) {
13188
- let t = n.getCachedRawOkIdByExternalId(e);
13338
+ let t = n.getCachedParticipantIdByExternalId(e);
13189
13339
  if (!t) {
13190
- R.warn("promoteParticipant: externalId not found in cache", e);
13340
+ Al(e, "promoteParticipant", n);
13191
13341
  return;
13192
13342
  }
13193
- r = j.composeUserId(t);
13343
+ r = j.decomposeParticipantId(t).compositeUserId;
13194
13344
  }
13195
13345
  return n.promoteParticipant(r, t);
13196
13346
  }
13197
- async function yl(e = !1) {
13198
- return El().requestPromotion(e);
13347
+ async function Cl(e = !1) {
13348
+ return Ml().requestPromotion(e);
13199
13349
  }
13200
- async function bl(e = !1) {
13201
- return El().acceptPromotion(e);
13350
+ async function wl(e = !1) {
13351
+ return Ml().acceptPromotion(e);
13202
13352
  }
13203
- async function xl(e) {
13204
- return El().getParticipantListChunk(e);
13353
+ async function Tl(e) {
13354
+ return Ml().getParticipantListChunk(e);
13205
13355
  }
13206
- async function Sl(e) {
13207
- return El().getParticipants(e);
13356
+ async function El(e) {
13357
+ return Ml().getParticipants(e);
13208
13358
  }
13209
- async function Cl(e) {
13210
- return El().feedback(e);
13359
+ async function Dl(e) {
13360
+ return Ml().feedback(e);
13211
13361
  }
13212
- async function wl(e, t, n) {
13213
- return El(n).enableFeatureForRoles(e, t);
13362
+ async function Ol(e, t, n) {
13363
+ return Ml(n).enableFeatureForRoles(e, t);
13214
13364
  }
13215
- function Tl(e) {
13365
+ function kl(e) {
13216
13366
  return e ? z.get(e) ?? null : $.current() ?? z.getFirst();
13217
13367
  }
13218
- function El(e) {
13219
- let t = Tl(e);
13368
+ function Al(e, t, n) {
13369
+ L.onNonFatalError(/* @__PURE__ */ Error(`Participant ID mapping not found for external ID "${e.id}" while handling ${t}`), n.id);
13370
+ }
13371
+ function jl(e, t, n) {
13372
+ let r = Array.from(new Set(e));
13373
+ L.onNonFatalError(/* @__PURE__ */ Error(`Participant ID mapping not found for external IDs "${r.join("\", \"")}" while handling ${t}`), n.id);
13374
+ }
13375
+ function Ml(e) {
13376
+ let t = kl(e);
13220
13377
  if (!t) throw Error("Conversation not found");
13221
13378
  return t;
13222
13379
  }
13223
- async function Dl(e) {
13224
- await Vs.removeHistoryRecords(e);
13380
+ function Nl(e, t) {
13381
+ let n = $.current();
13382
+ if (!n) return null;
13383
+ let r = n.getCachedParticipantIdByExternalId(e);
13384
+ return r ? {
13385
+ conversation: n,
13386
+ participantId: r
13387
+ } : (Al(e, t, n), null);
13388
+ }
13389
+ async function Pl(e) {
13390
+ await Ws.removeHistoryRecords(e);
13225
13391
  }
13226
- async function Ol(e) {
13392
+ async function Fl(e) {
13227
13393
  let t = $.current() ?? z.getFirst();
13228
13394
  t && await t.startAsr(e);
13229
13395
  }
13230
- async function kl(e) {
13396
+ async function Il(e) {
13231
13397
  let t = $.current() ?? z.getFirst();
13232
13398
  t && await t.stopAsr(e);
13233
13399
  }
13234
- async function Al(e) {
13400
+ async function Ll(e) {
13235
13401
  let t = $.current() ?? z.getFirst();
13236
13402
  t && await t.requestAsr(e);
13237
13403
  }
13238
- async function jl(e) {
13404
+ async function Rl(e) {
13239
13405
  let t = $.current();
13240
13406
  return t ? t.startUrlSharing(e) : Promise.reject();
13241
13407
  }
13242
- async function Ml() {
13408
+ async function zl() {
13243
13409
  let e = $.current();
13244
13410
  return e ? e.stopUrlSharing() : Promise.reject();
13245
13411
  }
13246
- async function Nl(e) {
13412
+ async function Bl(e) {
13247
13413
  await z.switchCall(e);
13248
13414
  }
13249
- function Pl() {
13415
+ function Vl() {
13250
13416
  return z.getActiveId();
13251
13417
  }
13252
- function Fl() {
13418
+ function Hl() {
13253
13419
  return $.getSyncedTime();
13254
13420
  }
13255
- function Il() {
13421
+ function Ul() {
13256
13422
  return M.sdkVersion;
13257
13423
  }
13258
13424
  typeof window < "u" && (window.__CALLS_SDK = yn);
13259
13425
  //#endregion
13260
- export { Ps as Api, Bs as ApiExternal, zs as ArrayDequeue, y as AuthData, f as BaseLogger, Ba as CallDirection, Va as CallType, Ha as ChatRoomEventType, Ua as ConversationFeature, Wa as ConversationOption, Sn as DebugMessageType, to as ExternalIdType, jt as FacingMode, x as FatalError, O as HangupReason, D as HangupType, S as MediaOption, k as MediaTrackKind, V as MediaType, qa as MuteState, Z as ParticipantState, Rs as ParticipantStateDataValue, N as ParticipantStatus, Ls as RecordRole, Ja as RoomsEventType, za as Signaling, B as SignalingCommandType, vr as SignalingConnectionType, K as SignalingNotification, J as TransportTopology, Za as UserRole, A as UserType, To as VolumeDetector, rc as acceptCall, bl as acceptPromotion, tl as activateRooms, Zc as addMovie, lc as addParticipant, uc as addParticipantInternal, nc as authorize, Us as browser, Qs as callInternal, Zs as callTo, mc as captureScreen, hc as captureVmoji, fl as changeAudioEffect, Pc as changeConversationOptions, pc as changeDevice, xc as changeParticipantState, bc as changePriorities, dl as changeVideoEffect, Lc as chatHistory, Fc as chatMessage, Ic as chatMessageInternal, Hc as createJoinLink, Rc as customData, zc as customDataInternal, al as debug, cl as debugLogs, ol as debugMessage, sl as debugMessageWithContext, ic as declineCall, wl as enableFeatureForRoles, Mc as enableVideoSuspend, Nc as enableVideoSuspendSuggest, Cl as feedback, Kc as forceRelayPolicy, Pl as getActiveCallId, Wc as getAnonymTokenByLink, _l as getAudienceModeHands, tc as getInbounds, xl as getParticipantListChunk, Sl as getParticipants, Xc as getStreamInfo, Fl as getSyncedTime, gl as getWaitingHall, Tc as grantRoles, Ec as grantRolesInternal, cc as hangup, Xs as init, ac as joinCall, sc as joinCallByLink, oc as joinCallInternal, Dc as muteParticipant, Oc as muteParticipantInternal, kc as pinParticipant, Ac as pinParticipantInternal, $s as processPush, ec as processPushInternal, vl as promoteParticipant, Yc as publishStream, Sc as putHandsDown, Dl as removeHistoryRecords, Uc as removeJoinLink, $c as removeMovie, dc as removeParticipant, fc as removeParticipantInternal, rl as removeRooms, Al as requestAsr, wc as requestDisplayLayout, yl as requestPromotion, qs as setAudioEffects, pl as setAudioStream, yc as setLocalResolution, Gs as setLogger, jc as setMediaModifiers, il as setStatisticsInterval, Js as setVad, Ks as setVideoEffects, gc as setVideoStream, Ys as setVmoji, hl as setVmojiFill, ml as setVmojiSvg, Gc as setVolume, Ol as startAsr, Vc as startAudienceConversation, Bc as startConversation, qc as startStream, jl as startUrlSharing, kl as stopAsr, Jc as stopStream, Ml as stopUrlSharing, Nl as switchCall, nl as switchRoom, vc as toggleLocalAudio, _c as toggleLocalVideo, Cc as updateDisplayLayout, Qc as updateMovie, el as updateRooms, ul as uploadDebugLogs, Ws as utils, Il as version };
13426
+ export { Ls as Api, Us as ApiExternal, Hs as ArrayDequeue, y as AuthData, f as BaseLogger, Ua as CallDirection, Wa as CallType, Ga as ChatRoomEventType, Ka as ConversationFeature, qa as ConversationOption, Sn as DebugMessageType, io as ExternalIdType, jt as FacingMode, x as FatalError, O as HangupReason, D as HangupType, S as MediaOption, k as MediaTrackKind, V as MediaType, Xa as MuteState, Z as ParticipantState, Vs as ParticipantStateDataValue, N as ParticipantStatus, Bs as RecordRole, Za as RoomsEventType, Ha as Signaling, B as SignalingCommandType, vr as SignalingConnectionType, K as SignalingNotification, J as TransportTopology, eo as UserRole, A as UserType, Oo as VolumeDetector, sc as acceptCall, wl as acceptPromotion, al as activateRooms, tl as addMovie, pc as addParticipant, mc as addParticipantInternal, oc as authorize, Ks as browser, nc as callInternal, ec as callTo, vc as captureScreen, yc as captureVmoji, gl as changeAudioEffect, Rc as changeConversationOptions, _c as changeDevice, Tc as changeParticipantState, wc as changePriorities, hl as changeVideoEffect, Vc as chatHistory, zc as chatMessage, Bc as chatMessageInternal, Kc as createJoinLink, Hc as customData, Uc as customDataInternal, ll as debug, fl as debugLogs, ul as debugMessage, dl as debugMessageWithContext, cc as declineCall, Ol as enableFeatureForRoles, Ic as enableVideoSuspend, Lc as enableVideoSuspendSuggest, Dl as feedback, Xc as forceRelayPolicy, Vl as getActiveCallId, Jc as getAnonymTokenByLink, xl as getAudienceModeHands, ac as getInbounds, Tl as getParticipantListChunk, El as getParticipants, el as getStreamInfo, Hl as getSyncedTime, bl as getWaitingHall, kc as grantRoles, Ac as grantRolesInternal, fc as hangup, $s as init, lc as joinCall, dc as joinCallByLink, uc as joinCallInternal, jc as muteParticipant, Mc as muteParticipantInternal, Nc as pinParticipant, Pc as pinParticipantInternal, rc as processPush, ic as processPushInternal, Sl as promoteParticipant, $c as publishStream, Ec as putHandsDown, Pl as removeHistoryRecords, qc as removeJoinLink, rl as removeMovie, hc as removeParticipant, gc as removeParticipantInternal, sl as removeRooms, Ll as requestAsr, Oc as requestDisplayLayout, Cl as requestPromotion, Xs as setAudioEffects, _l as setAudioStream, Cc as setLocalResolution, Js as setLogger, Fc as setMediaModifiers, cl as setStatisticsInterval, Zs as setVad, Ys as setVideoEffects, bc as setVideoStream, Qs as setVmoji, yl as setVmojiFill, vl as setVmojiSvg, Yc as setVolume, Fl as startAsr, Gc as startAudienceConversation, Wc as startConversation, Zc as startStream, Rl as startUrlSharing, Il as stopAsr, Qc as stopStream, zl as stopUrlSharing, Bl as switchCall, ol as switchRoom, Sc as toggleLocalAudio, xc as toggleLocalVideo, Dc as updateDisplayLayout, nl as updateMovie, il as updateRooms, ml as uploadDebugLogs, qs as utils, Ul as version };