@vkontakte/calls-sdk 2.8.13-dev.7452edd3.0 → 2.8.13-dev.78098aca.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.7452edd3.0
3
- * Tue, 27 Oct 2026 12:49:56 GMT
2
+ * @vkontakte/calls-sdk v2.8.13-dev.78098aca.0
3
+ * Thu, 12 Nov 2026 11:06:47 GMT
4
4
  * https://calls-sdk.cdn-vk.ru/doc/latest/index.html
5
5
  */
6
6
 
@@ -828,10 +828,18 @@ var mt;
828
828
  }
829
829
  e.remove = r;
830
830
  })(mt || (mt = {}));
831
- var ht = mt, gt = null, _t = null, vt = null, yt = [], bt = [], xt = [], St = [], Ct = null, wt = null, Tt = null, Et = !1, Dt = !1, Ot, kt, At, jt = null, Mt = null, Nt = {}, Pt = /* @__PURE__ */ new Set();
832
- function Ft(e, t) {
831
+ var T = mt, ht = null, gt = null, _t = null, vt = [], yt = [], bt = [], xt = [], St = null, Ct = null, wt = null, Tt = !1, Et = !1, Dt, Ot, kt, At = null, jt = null, Mt = {}, Nt = /* @__PURE__ */ new Set();
832
+ function Pt(e, t) {
833
833
  return Number(t.deviceId === "default") - Number(e.deviceId === "default");
834
834
  }
835
+ function Ft(e, t) {
836
+ let n = T.get(e), r = typeof n == "string" && n.length > 0 ? "explicit" : "default";
837
+ return {
838
+ mode: r,
839
+ device: t,
840
+ deviceId: r === "explicit" ? n : t?.deviceId ?? null
841
+ };
842
+ }
835
843
  var It = /* @__PURE__ */ function(e) {
836
844
  return e.USER = "user", e.ENVIRONMENT = "environment", e;
837
845
  }({});
@@ -851,9 +859,9 @@ var Lt = class {
851
859
  echoCancellation: !0,
852
860
  autoGainControl: !0
853
861
  };
854
- let t = T.getMicrophones(), n, r;
855
- if (wt && (r = wt.groupId, n = wt.deviceId), typeof e == "string") r = t.find((t) => t.deviceId === e)?.groupId, n = e;
856
- else if (!wt && C.os() === "MacOS" && t.find((e) => e.label.includes("iPhone"))) {
862
+ let t = E.getMicrophones(), n, r;
863
+ if (Ct && (r = Ct.groupId, n = Ct.deviceId), typeof e == "string") r = t.find((t) => t.deviceId === e)?.groupId, n = e;
864
+ else if (!Ct && C.os() === "MacOS" && t.find((e) => e.label.includes("iPhone"))) {
857
865
  let e = t.find((e) => !e.label.includes("Virtual") && !e.label.includes("iPhone"));
858
866
  e && (r = e.groupId, n = e.deviceId);
859
867
  }
@@ -875,9 +883,9 @@ var Lt = class {
875
883
  aspectRatio: { ideal: N.videoAspectRatio },
876
884
  frameRate: { ideal: i }
877
885
  };
878
- let e = T.getCameras(), a, s;
879
- if (Ct && (s = Ct.groupId, a = Ct.deviceId), typeof t == "string") s = e.find((e) => e.deviceId === t)?.groupId, a = t;
880
- else if (!Ct && C.os() === "MacOS" && e.find((e) => e.label.includes("iPhone"))) {
886
+ let e = E.getCameras(), a, s;
887
+ if (St && (s = St.groupId, a = St.deviceId), typeof t == "string") s = e.find((e) => e.deviceId === t)?.groupId, a = t;
888
+ else if (!St && C.os() === "MacOS" && e.find((e) => e.label.includes("iPhone"))) {
881
889
  let t = e.find((e) => !e.label.includes("Virtual") && !e.label.includes("iPhone"));
882
890
  t && (s = t.groupId, a = t.deviceId);
883
891
  }
@@ -937,50 +945,49 @@ var Lt = class {
937
945
  };
938
946
  h(zt, "_lockId", 0);
939
947
  async function Bt() {
940
- Dt = !1, Et = !1, gt = null;
948
+ Et = !1, Tt = !1, ht = null;
941
949
  let e = {
942
- camera: T.getSavedCamera(),
943
- microphone: T.getSavedMicrophone(),
944
- output: T.getSavedOutput()
950
+ camera: E.getSavedCamera(),
951
+ microphone: E.getSavedMicrophone(),
952
+ output: E.getSavedOutput()
945
953
  };
946
954
  await Ht(), Vt("devicechange", e), R.onDeviceChange();
947
955
  }
948
956
  function Vt(e, ...t) {
949
- if (Nt[e]) for (let n of Nt[e]) n(...t);
957
+ if (Mt[e]) for (let n of Mt[e]) n(...t);
950
958
  }
951
959
  async function Ht() {
952
- return gt || (!navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices ? [] : (!_t && navigator.mediaDevices.addEventListener && (_t = M.debounce(Bt, N.enumerateDevicesDelay), navigator.mediaDevices.addEventListener("devicechange", _t)), !vt && ct.isSupported() && (vt = new ct(), await vt.init((e, t) => {
960
+ return ht || (!navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices ? [] : (!gt && navigator.mediaDevices.addEventListener && (gt = M.debounce(Bt, N.enumerateDevicesDelay), navigator.mediaDevices.addEventListener("devicechange", gt)), !_t && ct.isSupported() && (_t = new ct(), await _t.init((e, t) => {
953
961
  switch (t) {
954
962
  case "denied":
955
963
  case "prompt":
956
- _t?.();
964
+ gt?.();
957
965
  break;
958
966
  }
959
- })), gt = navigator.mediaDevices.enumerateDevices().then((e) => {
960
- yt = e, z.debug("Devices", e), bt = e.filter((e) => e.kind === "videoinput" ? ((e.label || vt?.getPermissionState("camera") === "granted") && (Et = !0), !0) : !1), bt.sort(Ft), xt = e.filter((e) => e.kind === "audioinput" ? ((e.label || vt?.getPermissionState("microphone") === "granted") && (Dt = !0), !0) : !1), xt.sort(Ft), St = e.filter((e) => e.kind === "audiooutput"), St.sort(Ft);
961
- let t = Ct?.deviceId ?? ht.get("videoinput"), n = wt?.deviceId ?? ht.get("audioinput"), r = Tt?.deviceId ?? ht.get("audiooutput");
962
- return Ct = bt.find((e) => e.deviceId === t) || null, wt = xt.find((e) => e.deviceId === n) || null, Tt = St.find((e) => e.deviceId === r) || St[0] || null, gt = Promise.resolve(e), e;
963
- }).catch(() => (gt = null, []))));
967
+ })), ht = navigator.mediaDevices.enumerateDevices().then((e) => {
968
+ vt = e, z.debug("Devices", e), yt = e.filter((e) => e.kind === "videoinput" ? ((e.label || _t?.getPermissionState("camera") === "granted") && (Tt = !0), !0) : !1), yt.sort(Pt), bt = e.filter((e) => e.kind === "audioinput" ? ((e.label || _t?.getPermissionState("microphone") === "granted") && (Et = !0), !0) : !1), bt.sort(Pt), xt = e.filter((e) => e.kind === "audiooutput"), xt.sort(Pt);
969
+ let t = St?.deviceId ?? T.get("videoinput"), n = Ct?.deviceId ?? T.get("audioinput"), r = T.get("audiooutput") || "default";
970
+ return St = yt.find((e) => e.deviceId === t) || null, Ct = bt.find((e) => e.deviceId === n) || null, wt = xt.find((e) => e.deviceId === r) || null, ht = Promise.resolve(e), e;
971
+ }).catch(() => (ht = null, []))));
964
972
  }
965
973
  function Ut(e) {
966
- if (Ct && wt) return;
967
- let t = (e, t) => {
974
+ let t = T.get("videoinput") !== null, n = T.get("audioinput") !== null, r = (e, t) => {
968
975
  let n = t.getSettings()?.deviceId;
969
976
  return e.find((e) => e.deviceId === n || e.label === t.label) || null;
970
977
  };
971
978
  e?.getTracks().forEach((e) => {
972
- !wt && e.kind === A.audio ? wt = t(T.getMicrophones(), e) : !Ct && e.kind === A.video && (Ct = t(T.getCameras(), e));
979
+ !n && e.kind === A.audio ? Ct = r(E.getMicrophones(), e) : !t && e.kind === A.video && (St = r(E.getCameras(), e));
973
980
  });
974
981
  }
975
982
  async function Wt(e, t, n = z, r = null) {
976
983
  n.debug("Try to get media", JSON.parse(JSON.stringify(e.getNative())));
977
- let i = (!e.isVideo() || T.hasCameraPermission()) && (!e.isAudio() || T.hasMicrophonePermission());
984
+ let i = (!e.isVideo() || E.hasCameraPermission()) && (!e.isAudio() || E.hasMicrophonePermission());
978
985
  !i && !t && R.onPermissionsRequested();
979
986
  let a = new zt();
980
987
  try {
981
988
  a.busy(r);
982
989
  let t = await navigator.mediaDevices.getUserMedia(e.getNative());
983
- return T.releaseFirefoxMicrophonePermissionWarmup(), a.free(), n.debug("Got media", t.getTracks().map((e) => `${e.kind}: ${e.label}`)), i || await Bt(), Ut(t), t;
990
+ return E.releaseFirefoxMicrophonePermissionWarmup(), a.free(), n.debug("Got media", t.getTracks().map((e) => `${e.kind}: ${e.label}`)), i || await Bt(), Ut(t), t;
984
991
  } catch (i) {
985
992
  switch (a.free(), n.error("getUserMedia error", i), i.name) {
986
993
  case "PermissionDeniedError":
@@ -1012,8 +1019,8 @@ async function Wt(e, t, n = z, r = null) {
1012
1019
  }
1013
1020
  }
1014
1021
  async function Gt(e = z) {
1015
- if (!(jt || C.browserName() !== "Firefox" || !navigator.mediaDevices?.getUserMedia)) try {
1016
- T.hasMicrophonePermission() || R.onPermissionsRequested(), jt = await navigator.mediaDevices.getUserMedia({
1022
+ if (!(At || C.browserName() !== "Firefox" || !navigator.mediaDevices?.getUserMedia)) try {
1023
+ E.hasMicrophonePermission() || R.onPermissionsRequested(), At = await navigator.mediaDevices.getUserMedia({
1017
1024
  audio: !0,
1018
1025
  video: !1
1019
1026
  });
@@ -1049,78 +1056,90 @@ async function Kt(e, t = z, n = null) {
1049
1056
  r.free();
1050
1057
  }
1051
1058
  }
1052
- var T;
1059
+ var E;
1053
1060
  (function(e) {
1054
1061
  async function t() {
1055
1062
  await Ht(), await C.initOsVersion(z.warn);
1056
1063
  }
1057
1064
  e.init = t;
1058
1065
  function n() {
1059
- return bt;
1066
+ return yt;
1060
1067
  }
1061
1068
  e.getCameras = n;
1062
1069
  function r() {
1063
- return xt;
1070
+ return bt;
1064
1071
  }
1065
1072
  e.getMicrophones = r;
1066
1073
  function i() {
1067
- return St;
1074
+ return xt;
1068
1075
  }
1069
1076
  e.getOutput = i;
1070
1077
  function a() {
1071
- return bt.length > 0;
1078
+ return yt.length > 0;
1072
1079
  }
1073
1080
  e.hasCamera = a;
1074
1081
  function o() {
1075
- return xt.length > 0;
1082
+ return bt.length > 0;
1076
1083
  }
1077
1084
  e.hasMicrophone = o;
1078
1085
  function s() {
1079
- return Ct;
1086
+ return St;
1080
1087
  }
1081
1088
  e.getSavedCamera = s;
1082
1089
  function c() {
1083
- return wt;
1090
+ return Ct;
1084
1091
  }
1085
1092
  e.getSavedMicrophone = c;
1086
1093
  function l() {
1087
- return Tt;
1094
+ return wt;
1088
1095
  }
1089
1096
  e.getSavedOutput = l;
1090
1097
  function u() {
1091
- let e = T.getSavedOutput();
1092
- return e && e.deviceId === ht.get("audiooutput") ? e : null;
1098
+ return Ft("videoinput", St);
1093
1099
  }
1094
- e.getChosenOutput = u;
1100
+ e.getCameraSelection = u;
1095
1101
  function d() {
1096
- return yt;
1102
+ return Ft("audioinput", Ct);
1097
1103
  }
1098
- e.getDevices = d;
1104
+ e.getMicrophoneSelection = d;
1099
1105
  function f() {
1100
- return N.videoFacingMode;
1106
+ return Ft("audiooutput", wt);
1101
1107
  }
1102
- e.getVideoFacingMode = f;
1108
+ e.getOutputSelection = f;
1103
1109
  function p() {
1104
- return Et;
1110
+ let e = E.getSavedOutput();
1111
+ return e && e.deviceId === T.get("audiooutput") ? e : null;
1105
1112
  }
1106
- e.hasCameraPermission = p;
1113
+ e.getChosenOutput = p;
1107
1114
  function m() {
1108
- return Dt;
1115
+ return vt;
1109
1116
  }
1110
- e.hasMicrophonePermission = m;
1117
+ e.getDevices = m;
1111
1118
  function ee() {
1112
- return vt?.getPermissionState("microphone") ?? null;
1119
+ return N.videoFacingMode;
1113
1120
  }
1114
- e.getMicrophonePermissionState = ee;
1115
- function h(e = !1) {
1116
- return m() ? a() && e ? p() : !0 : !1;
1121
+ e.getVideoFacingMode = ee;
1122
+ function h() {
1123
+ return Tt;
1117
1124
  }
1118
- e.hasPermissions = h;
1125
+ e.hasCameraPermission = h;
1119
1126
  function te() {
1120
- jt && (w(jt), jt = null);
1127
+ return Et;
1121
1128
  }
1122
- e.releaseFirefoxMicrophonePermissionWarmup = te;
1123
- async function ne(e = !1, t = !0, n = !0, r = z, i = null) {
1129
+ e.hasMicrophonePermission = te;
1130
+ function ne() {
1131
+ return _t?.getPermissionState("microphone") ?? null;
1132
+ }
1133
+ e.getMicrophonePermissionState = ne;
1134
+ function re(e = !1) {
1135
+ return te() ? a() && e ? h() : !0 : !1;
1136
+ }
1137
+ e.hasPermissions = re;
1138
+ function ie() {
1139
+ At && (w(At), At = null);
1140
+ }
1141
+ e.releaseFirefoxMicrophonePermissionWarmup = ie;
1142
+ async function ae(e = !1, t = !0, n = !0, r = z, i = null) {
1124
1143
  !e && !t && await Gt(r);
1125
1144
  let s = o() && t, c = a() && e, l;
1126
1145
  if (!s && !c) l = new MediaStream();
@@ -1129,87 +1148,89 @@ var T;
1129
1148
  } catch {
1130
1149
  l = new MediaStream();
1131
1150
  }
1132
- return !l.getVideoTracks().length && n && l.addTrack(T.getBlackMediaTrack()), !l.getAudioTracks().length && n && l.addTrack(T.getSilentMediaTrack()), l;
1151
+ return !l.getVideoTracks().length && n && l.addTrack(E.getBlackMediaTrack()), !l.getAudioTracks().length && n && l.addTrack(E.getSilentMediaTrack()), l;
1133
1152
  }
1134
- e.getUserMedia = ne;
1135
- async function re(e, t, n = z, r = null) {
1153
+ e.getUserMedia = ae;
1154
+ async function oe(e, t, n = z, r = null) {
1136
1155
  return Kt(new Rt(e && !N.consumerFastScreenShare ? N.fastScreenShareWidth : 0, e && !N.consumerFastScreenShare ? N.fastScreenShareHeight : 0, N.getScreenFrameRate(e), t), n, r);
1137
1156
  }
1138
- e.getScreenMedia = re;
1139
- async function ie(e = !1, t, n = z, r = null) {
1157
+ e.getScreenMedia = oe;
1158
+ async function g(e = !1, t, n = z, r = null) {
1140
1159
  return Wt(new Lt(!1, !0, e ? N.videoEffectMaxWidth : N.videoMaxWidth, e ? N.videoEffectMaxHeight : N.videoMaxHeight, t), void 0, n, r);
1141
1160
  }
1142
- e._getUserVideo = ie;
1143
- async function ae(e, t, n = z, r = null) {
1161
+ e._getUserVideo = g;
1162
+ async function se(e, t, n = z, r = null) {
1144
1163
  let i = t?.width || N.videoMaxWidth, a = t?.height || N.videoMaxHeight;
1145
1164
  return Wt(new Lt(!1, e || !0, i, a), void 0, n, r);
1146
1165
  }
1147
- e.getUserVideo = ae;
1148
- async function oe(e, t = z, n = null) {
1166
+ e.getUserVideo = se;
1167
+ async function ce(e, t = z, n = null) {
1149
1168
  return Wt(new Lt(e || !0, !1), void 0, t, n);
1150
1169
  }
1151
- e.getUserAudio = oe;
1152
- async function g(e, t) {
1170
+ e.getUserAudio = ce;
1171
+ async function le(e, t) {
1153
1172
  let [n] = e.getVideoTracks();
1154
1173
  if (!n) throw Error("Video track not found in stream");
1155
1174
  return st(n, t);
1156
1175
  }
1157
- e.setResolution = g;
1158
- async function se(e, t) {
1159
- let n = (await Ht()).find((n) => n.kind === e && n.deviceId === t);
1160
- return n ? (e === "videoinput" ? Ct = n : e === "audioinput" ? wt = n : e === "audiooutput" && (Tt = n), ht.set(e, t), n) : null;
1176
+ e.setResolution = le;
1177
+ async function ue(e, t) {
1178
+ let n = await Ht();
1179
+ if (t === "default" && (e === "videoinput" || e === "audioinput" || e === "audiooutput")) return e === "videoinput" ? St = null : e === "audioinput" ? Ct = null : wt = xt.find((e) => e.deviceId === "default") || null, T.remove(e), n.find((t) => t.kind === e && t.deviceId === "default") || n.find((t) => t.kind === e) || null;
1180
+ let r = n.find((n) => n.kind === e && n.deviceId === t);
1181
+ return r ? (e === "videoinput" ? St = r : e === "audioinput" ? Ct = r : e === "audiooutput" && (wt = r), T.set(e, t), r) : null;
1161
1182
  }
1162
- e._saveDeviceId = se;
1163
- function ce() {
1164
- if (!At || At.readyState === "ended") {
1165
- let e = T.getAudioContext(), t = e.createMediaStreamDestination(), n = e.createGain();
1183
+ e._saveDeviceId = ue;
1184
+ function de() {
1185
+ if (!kt || kt.readyState === "ended") {
1186
+ let e = E.getAudioContext(), t = e.createMediaStreamDestination(), n = e.createGain();
1166
1187
  n.gain.value = 1e-5, n.connect(t), C.browserName() === "Safari" && n.connect(e.destination);
1167
1188
  let r = e.createOscillator();
1168
- r.type = "sine", r.frequency.value = 0, r.connect(n), r.start(), At = t.stream.getAudioTracks()[0];
1189
+ r.type = "sine", r.frequency.value = 0, r.connect(n), r.start(), kt = t.stream.getAudioTracks()[0];
1169
1190
  }
1170
- return Object.assign(At.clone(), { enabled: !1 });
1191
+ return Object.assign(kt.clone(), { enabled: !1 });
1171
1192
  }
1172
- e.getSilentMediaTrack = ce;
1173
- function le(e = N.videoMinWidth, t = N.videoMinHeight) {
1174
- kt || (kt = document.createElement("canvas")), kt.width = e, kt.height = t;
1175
- let n = kt.getContext("2d");
1176
- return n.rect(0, 0, e, t), n.fillStyle = "black", n.fill(), (!Ot || Ot.readyState === "ended") && (Ot = kt.captureStream(N.videoFrameRate).getVideoTracks()[0]), Object.assign(Ot.clone(), { enabled: !1 });
1193
+ e.getSilentMediaTrack = de;
1194
+ function fe(e = N.videoMinWidth, t = N.videoMinHeight) {
1195
+ Ot || (Ot = document.createElement("canvas")), Ot.width = e, Ot.height = t;
1196
+ let n = Ot.getContext("2d");
1197
+ return n.rect(0, 0, e, t), n.fillStyle = "black", n.fill(), (!Dt || Dt.readyState === "ended") && (Dt = Ot.captureStream(N.videoFrameRate).getVideoTracks()[0]), Object.assign(Dt.clone(), { enabled: !1 });
1177
1198
  }
1178
- e.getBlackMediaTrack = le;
1179
- function ue(e) {
1180
- Pt.add(e), Mt && T.getAudioContext();
1199
+ e.getBlackMediaTrack = fe;
1200
+ function pe(e) {
1201
+ Nt.add(e), jt && E.getAudioContext();
1181
1202
  }
1182
- e.retainAudioContext = ue;
1183
- function de(e) {
1184
- Pt.delete(e) && Pt.size === 0 && Mt?.suspend().catch((e) => z.warn("Failed to suspend AudioContext", e));
1203
+ e.retainAudioContext = pe;
1204
+ function me(e) {
1205
+ Nt.delete(e) && Nt.size === 0 && jt?.suspend().catch((e) => z.warn("Failed to suspend AudioContext", e));
1185
1206
  }
1186
- e.releaseAudioContext = de;
1187
- function fe() {
1188
- return Mt || (Mt = new (window.AudioContext || window.webkitAudioContext)()), Mt.resume().catch(() => {
1207
+ e.releaseAudioContext = me;
1208
+ function he() {
1209
+ return jt || (jt = new (window.AudioContext || window.webkitAudioContext)()), jt.resume().catch(() => {
1189
1210
  z.warn("Failed to resume AudioContext");
1190
- }), Mt;
1211
+ }), jt;
1191
1212
  }
1192
- e.getAudioContext = fe;
1193
- function pe(e, t) {
1194
- Nt[e] || (Nt[e] = []), Nt[e].push(t);
1213
+ e.getAudioContext = he;
1214
+ function ge(e, t) {
1215
+ Mt[e] || (Mt[e] = []), Mt[e].push(t);
1195
1216
  }
1196
- e.addEventListener = pe;
1197
- function me(e, t) {
1198
- if (Nt[e]) if (!t) delete Nt[e];
1217
+ e.addEventListener = ge;
1218
+ function _e(e, t) {
1219
+ if (Mt[e]) if (!t) delete Mt[e];
1199
1220
  else {
1200
- let n = Nt[e].indexOf(t);
1201
- n > -1 && Nt[e].splice(n, 1);
1221
+ let n = Mt[e].indexOf(t);
1222
+ n > -1 && Mt[e].splice(n, 1);
1202
1223
  }
1203
1224
  }
1204
- e.removeEventListener = me;
1205
- })(T || (T = {}));
1206
- var E = T;
1225
+ e.removeEventListener = _e;
1226
+ })(E || (E = {}));
1227
+ var D = E;
1207
1228
  //#endregion
1208
1229
  //#region src/types/MediaSettings.ts
1209
1230
  function qt(e, t) {
1210
1231
  return !(e.isAudioEnabled !== t.isAudioEnabled || e.isVideoEnabled !== t.isVideoEnabled || e.isScreenSharingEnabled !== t.isScreenSharingEnabled || e.isFastScreenSharingEnabled !== t.isFastScreenSharingEnabled || e.isAudioSharingEnabled !== t.isAudioSharingEnabled || e.isAnimojiEnabled !== t.isAnimojiEnabled);
1211
1232
  }
1212
- function D(e) {
1233
+ function Jt(e) {
1213
1234
  return Object.assign({
1214
1235
  isAudioEnabled: !1,
1215
1236
  isVideoEnabled: !1,
@@ -1229,9 +1250,9 @@ var O = /* @__PURE__ */ function(e) {
1229
1250
  let r = [];
1230
1251
  this.error && r.push("error"), this.remote && r.push("remote"), this.code && r.push(`code: ${this.code}`), n && n.message && r.push(`message: '${n.message}'`), this.message = t + (r.length ? ` (${r.join(", ")})` : ""), Error.captureStackTrace && Error.captureStackTrace(this, e);
1231
1252
  }
1232
- }, Jt = /* @__PURE__ */ function(e) {
1253
+ }, Yt = /* @__PURE__ */ function(e) {
1233
1254
  return e.FpsLimit = "fps-limit", e;
1234
- }({}), Yt = class extends Ye {
1255
+ }({}), Xt = class extends Ye {
1235
1256
  constructor(e = z) {
1236
1257
  super(), h(this, "FPS_LIMITS", [
1237
1258
  13,
@@ -1271,15 +1292,15 @@ var O = /* @__PURE__ */ function(e) {
1271
1292
  destroy() {
1272
1293
  this._cleanup(), super.unsubscribe();
1273
1294
  }
1274
- }, Xt = /* @__PURE__ */ function(e) {
1295
+ }, Zt = /* @__PURE__ */ function(e) {
1275
1296
  return e.SOURCE_CHANGED = "SOURCE_CHANGED", e.SOURCE_READY = "SOURCE_READY", e.TRACK_REPLACED = "TRACK_REPLACED", e.SCREEN_STATUS = "SCREEN_STATUS", e.ANIMOJI_STATUS = "ANIMOJI_STATUS", e;
1276
1297
  }({}), A = /* @__PURE__ */ function(e) {
1277
1298
  return e.audio = "audio", e.video = "video", e.screen = "screen", e.audioshare = "audioshare", e;
1278
- }({}), Zt = /* @__PURE__ */ function(e) {
1299
+ }({}), Qt = /* @__PURE__ */ function(e) {
1279
1300
  return e[e.CAMERA = 1] = "CAMERA", e[e.SCREEN = 2] = "SCREEN", e;
1280
- }({}), Qt = class extends Ye {
1301
+ }({}), $t = class extends Ye {
1281
1302
  constructor(e = z, t = null) {
1282
- super(), h(this, "_stream", null), h(this, "_screenTrack", null), h(this, "_audioShareTrack", null), h(this, "_screenShareTrack", null), h(this, "_screenCaptureRequest", 0), h(this, "_destroyed", !1), h(this, "_sendVideoTrack", null), h(this, "_cameraVideoTrack", null), h(this, "_micAudioTrack", null), h(this, "_audioEffectsTrack", null), h(this, "_mediaSettings", D()), h(this, "_lastMediaSettings", null), h(this, "_videoStatusOnScreenCapturingEnabled", !1), h(this, "_effect", null), h(this, "_audioEffectParams", null), h(this, "_onDeviceChange", void 0), h(this, "_animojiEnabled", !1), h(this, "_videoEffectsFpsLimiter", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_cameraTrackSetAt", 0), h(this, "_cameraMuteRecoveredAt", 0), h(this, "_micTrackSetAt", 0), h(this, "_micMuteRecoveredAt", 0), h(this, "videoTrackMuteHandler", () => {
1303
+ super(), h(this, "_stream", null), h(this, "_screenTrack", null), h(this, "_audioShareTrack", null), h(this, "_screenShareTrack", null), h(this, "_screenCaptureRequest", 0), h(this, "_destroyed", !1), h(this, "_sendVideoTrack", null), h(this, "_cameraVideoTrack", null), h(this, "_micAudioTrack", null), h(this, "_audioEffectsTrack", null), h(this, "_mediaSettings", Jt()), h(this, "_lastMediaSettings", null), h(this, "_videoStatusOnScreenCapturingEnabled", !1), h(this, "_effect", null), h(this, "_audioEffectParams", null), h(this, "_onDeviceChange", void 0), h(this, "_animojiEnabled", !1), h(this, "_videoEffectsFpsLimiter", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_cameraTrackSetAt", 0), h(this, "_cameraMuteRecoveredAt", 0), h(this, "_micTrackSetAt", 0), h(this, "_micMuteRecoveredAt", 0), h(this, "videoTrackMuteHandler", () => {
1283
1304
  !this._mediaSettings.isVideoEnabled || this._cameraMuteRecoveredAt >= this._cameraTrackSetAt || C.browserName() !== "Safari" || (this._cameraMuteRecoveredAt = Date.now(), this._logger?.log(x.ERROR, "camera_mute_recover"), this._debug.log("[MediaSource] Safari camera mute recovery"), this.toggleVideo(!0).then(() => this._logger?.log(x.ERROR, "camera_mute_recover_success")).catch((e) => {
1284
1305
  this._logger?.log(x.ERROR, "camera_mute_recover_fail"), this._debug.warn("[MediaSource] Camera mute recovery failed", e);
1285
1306
  }));
@@ -1287,7 +1308,7 @@ var O = /* @__PURE__ */ function(e) {
1287
1308
  !this._mediaSettings.isAudioEnabled || this._micMuteRecoveredAt >= this._micTrackSetAt || C.browserName() !== "Safari" || (this._micMuteRecoveredAt = Date.now(), this._logger?.log(x.ERROR, "mic_mute_recover"), this._debug.log("[MediaSource] Safari mic mute recovery"), this.toggleAudio(!0).then(() => this._logger?.log(x.ERROR, "mic_mute_recover_success")).catch((e) => {
1288
1309
  this._logger?.log(x.ERROR, "mic_mute_recover_fail"), this._debug.warn("[MediaSource] Mic mute recovery failed", e);
1289
1310
  }));
1290
- }), this._debug = e, this._logger = t, this._initDeviceChangeListener(), N.audioShare && (this._audioShareTrack = this.getSilentAudioShareTrack()), N.enableVideoEffectsFpsDegradation && (this._videoEffectsFpsLimiter = new Yt(this._debug), this._videoEffectsFpsLimiter.addEventListener(Jt.FpsLimit, this.handleVideoEffectsLowFps.bind(this))), E.retainAudioContext(this);
1311
+ }), this._debug = e, this._logger = t, this._initDeviceChangeListener(), N.audioShare && (this._audioShareTrack = this.getSilentAudioShareTrack()), N.enableVideoEffectsFpsDegradation && (this._videoEffectsFpsLimiter = new Xt(this._debug), this._videoEffectsFpsLimiter.addEventListener(Yt.FpsLimit, this.handleVideoEffectsLowFps.bind(this))), D.retainAudioContext(this);
1291
1312
  }
1292
1313
  get cameraVideoTrack() {
1293
1314
  return this._cameraVideoTrack;
@@ -1304,7 +1325,7 @@ var O = /* @__PURE__ */ function(e) {
1304
1325
  description: a
1305
1326
  } });
1306
1327
  try {
1307
- let e = await E.getUserMedia(n, r, t, this._debug, this._logger);
1328
+ let e = await D.getUserMedia(n, r, t, this._debug, this._logger);
1308
1329
  if (this._destroyed) {
1309
1330
  w(e);
1310
1331
  return;
@@ -1368,14 +1389,14 @@ var O = /* @__PURE__ */ function(e) {
1368
1389
  _initDeviceChangeListener() {
1369
1390
  !navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices || !navigator.mediaDevices.addEventListener || (this._onDeviceChange = async (e) => {
1370
1391
  if (!this._stream) return;
1371
- let t = E.getSavedMicrophone(), n = E.getSavedCamera(), r = this._mediaSettings.isAudioEnabled && t?.groupId !== e.microphone?.groupId, i = this._mediaSettings.isVideoEnabled && n?.groupId !== e.camera?.groupId;
1392
+ let t = D.getSavedMicrophone(), n = D.getSavedCamera(), r = this._mediaSettings.isAudioEnabled && t?.groupId !== e.microphone?.groupId, i = this._mediaSettings.isVideoEnabled && n?.groupId !== e.camera?.groupId;
1372
1393
  try {
1373
1394
  r && await this._changeAudioInput(), i && await this._changeVideoInput();
1374
1395
  } catch {}
1375
- }, E.addEventListener("devicechange", this._onDeviceChange));
1396
+ }, D.addEventListener("devicechange", this._onDeviceChange));
1376
1397
  }
1377
1398
  _destroyDeviceChangeListener() {
1378
- this._onDeviceChange && E.removeEventListener("devicechange", this._onDeviceChange);
1399
+ this._onDeviceChange && D.removeEventListener("devicechange", this._onDeviceChange);
1379
1400
  }
1380
1401
  async _changeVideoInput(e) {
1381
1402
  if (this._destroyed) {
@@ -1383,7 +1404,7 @@ var O = /* @__PURE__ */ function(e) {
1383
1404
  return;
1384
1405
  }
1385
1406
  try {
1386
- let t = e ? "stream" : "video", n = e || await E._getUserVideo(!!this._effect, this._frameRate, this._debug, this._logger);
1407
+ let t = e ? "stream" : "video", n = e || await D._getUserVideo(!!this._effect, this._frameRate, this._debug, this._logger);
1387
1408
  if (this._destroyed) {
1388
1409
  w(n);
1389
1410
  return;
@@ -1411,7 +1432,7 @@ var O = /* @__PURE__ */ function(e) {
1411
1432
  return;
1412
1433
  }
1413
1434
  try {
1414
- let t = e || await E.getUserAudio(void 0, this._debug, this._logger);
1435
+ let t = e || await D.getUserAudio(void 0, this._debug, this._logger);
1415
1436
  if (this._destroyed) {
1416
1437
  w(t);
1417
1438
  return;
@@ -1437,7 +1458,7 @@ var O = /* @__PURE__ */ function(e) {
1437
1458
  return;
1438
1459
  }
1439
1460
  try {
1440
- if (n = n || await E.getScreenMedia(e, t, this._debug, this._logger), r !== this._screenCaptureRequest || this._destroyed) {
1461
+ if (n = n || await D.getScreenMedia(e, t, this._debug, this._logger), r !== this._screenCaptureRequest || this._destroyed) {
1441
1462
  w(n);
1442
1463
  return;
1443
1464
  }
@@ -1482,11 +1503,11 @@ var O = /* @__PURE__ */ function(e) {
1482
1503
  return (!this._audioEffectsTrack || this._audioEffectsTrack.id !== e.id) && (this._audioEffectsTrack = e), this._audioEffectsTrack;
1483
1504
  }
1484
1505
  getSilentAudioShareTrack() {
1485
- let e = E.getSilentMediaTrack();
1506
+ let e = D.getSilentMediaTrack();
1486
1507
  return e.contentHint = "music", e.stop(), e;
1487
1508
  }
1488
1509
  getBlackScreenShareTrack() {
1489
- let e = E.getBlackMediaTrack();
1510
+ let e = D.getBlackMediaTrack();
1490
1511
  return e.contentHint = "motion", e.stop(), e;
1491
1512
  }
1492
1513
  async _replaceLocalTrack(e, t) {
@@ -1528,7 +1549,7 @@ var O = /* @__PURE__ */ function(e) {
1528
1549
  }
1529
1550
  }
1530
1551
  destroy() {
1531
- this._destroyed || (this._destroyed = !0, this._screenCaptureRequest++, this._destroyDeviceChangeListener(), E.releaseFirefoxMicrophonePermissionWarmup(), N.videoEffects && (this._effect = null, N.videoEffects.destroy()), N.audioEffects && N.audioEffects.destroy(), this._stream && (w(this._stream), this._stream = null), this.cameraVideoTrack?.stop(), this._micAudioTrack?.stop(), this._audioEffectsTrack?.stop(), this._disableScreenCapture(), E.releaseAudioContext(this), this._videoEffectsFpsLimiter?.destroy());
1552
+ this._destroyed || (this._destroyed = !0, this._screenCaptureRequest++, this._destroyDeviceChangeListener(), D.releaseFirefoxMicrophonePermissionWarmup(), N.videoEffects && (this._effect = null, N.videoEffects.destroy()), N.audioEffects && N.audioEffects.destroy(), this._stream && (w(this._stream), this._stream = null), this.cameraVideoTrack?.stop(), this._micAudioTrack?.stop(), this._audioEffectsTrack?.stop(), this._disableScreenCapture(), D.releaseAudioContext(this), this._videoEffectsFpsLimiter?.destroy());
1532
1553
  }
1533
1554
  async stopLocalMedia() {
1534
1555
  this._screenCaptureRequest++, (this._screenTrack || this._mediaSettings.isScreenSharingEnabled) && await this.disableScreenCapturing(), this._stream && (this._lastMediaSettings ?? (this._lastMediaSettings = { ...this._mediaSettings }), this._stream.getAudioTracks().length > 0 && await this.toggleAudio(!1), this._stream.getVideoTracks().length > 0 && await this.toggleVideo(!1), this.cameraVideoTrack = null, this._setMicAudioTrack(null));
@@ -1557,13 +1578,13 @@ var O = /* @__PURE__ */ function(e) {
1557
1578
  this.cameraVideoTrack?.stop();
1558
1579
  let t;
1559
1580
  if (e) {
1560
- let e = await E._getUserVideo(!!this._effect, this._frameRate, this._debug, this._logger);
1581
+ let e = await D._getUserVideo(!!this._effect, this._frameRate, this._debug, this._logger);
1561
1582
  if (this._destroyed) {
1562
1583
  w(e);
1563
1584
  return;
1564
1585
  }
1565
1586
  this.cameraVideoTrack = e.getVideoTracks()[0], t = await this._setEffect(this._effect, this.cameraVideoTrack);
1566
- } else t = E.getBlackMediaTrack(N.videoMinWidth, N.videoMinHeight), this._stopEffect();
1587
+ } else t = D.getBlackMediaTrack(N.videoMinWidth, N.videoMinHeight), this._stopEffect();
1567
1588
  if (this._destroyed) {
1568
1589
  t.stop();
1569
1590
  return;
@@ -1583,16 +1604,16 @@ var O = /* @__PURE__ */ function(e) {
1583
1604
  await this._replaceLocalTrack(e), !this._destroyed && (this._mediaSettings.isAudioEnabled = t, this._triggerEvent("SOURCE_CHANGED", { kind: "audio" }));
1584
1605
  };
1585
1606
  if (e) try {
1586
- let e = await E.getUserAudio(void 0, this._debug, this._logger);
1607
+ let e = await D.getUserAudio(void 0, this._debug, this._logger);
1587
1608
  if (this._destroyed) {
1588
1609
  w(e);
1589
1610
  return;
1590
1611
  }
1591
1612
  this._setMicAudioTrack(e.getAudioTracks()[0]), await t(await this._applyAudioEffect(), !0);
1592
1613
  } catch (e) {
1593
- throw this._destroyed ? e : (N.audioEffects?.pause(), await t(E.getSilentMediaTrack(), !1), typeof e == "string" ? Error(e) : e);
1614
+ throw this._destroyed ? e : (N.audioEffects?.pause(), await t(D.getSilentMediaTrack(), !1), typeof e == "string" ? Error(e) : e);
1594
1615
  }
1595
- else N.audioEffects?.pause(), await t(E.getSilentMediaTrack(), !1);
1616
+ else N.audioEffects?.pause(), await t(D.getSilentMediaTrack(), !1);
1596
1617
  }
1597
1618
  toggleAnimojiCapturing(e) {
1598
1619
  this._animojiEnabled = e, this._mediaSettings.isVideoEnabled || this._triggerEvent("ANIMOJI_STATUS", e);
@@ -1649,17 +1670,21 @@ var O = /* @__PURE__ */ function(e) {
1649
1670
  let t = this._audioEffectParams;
1650
1671
  this._audioEffectParams = e;
1651
1672
  try {
1652
- let e = this._micAudioTrack.clone(), t = new MediaStream([e]);
1673
+ let e = this._cloneMicAudioTrack(this._micAudioTrack), t = new MediaStream([e]);
1653
1674
  await this._changeAudioInput(t);
1654
1675
  } catch (e) {
1655
1676
  if (this._destroyed) throw e;
1656
1677
  this._audioEffectParams = t;
1657
- let n = this._micAudioTrack.clone(), r = new MediaStream([n]);
1678
+ let n = this._cloneMicAudioTrack(this._micAudioTrack), r = new MediaStream([n]);
1658
1679
  throw await this._changeAudioInput(r), e;
1659
1680
  }
1660
1681
  }
1661
1682
  }
1662
1683
  }
1684
+ _cloneMicAudioTrack(e) {
1685
+ let t = e.clone();
1686
+ return t.enabled = !0, t;
1687
+ }
1663
1688
  getAudioShareTrack() {
1664
1689
  return this._audioShareTrack;
1665
1690
  }
@@ -1685,12 +1710,12 @@ var O = /* @__PURE__ */ function(e) {
1685
1710
  }
1686
1711
  }, j = /* @__PURE__ */ function(e) {
1687
1712
  return e.USER = "USER", e.GROUP = "GROUP", e;
1688
- }(j || {}), $t = {
1713
+ }(j || {}), en = {
1689
1714
  HEIGHT: 720,
1690
1715
  WIDTH: 1280,
1691
1716
  BITRATE: 1e6,
1692
1717
  FPS: 30
1693
- }, en = 60, tn = "L1T2", nn = 1.35, rn = [
1718
+ }, tn = 60, nn = "L1T2", rn = 1.35, an = [
1694
1719
  {
1695
1720
  dimension: 320,
1696
1721
  bitrate: 18e4
@@ -1724,27 +1749,27 @@ var O = /* @__PURE__ */ function(e) {
1724
1749
  bitrate: 5e6
1725
1750
  }
1726
1751
  ];
1727
- function an(e, t) {
1752
+ function on(e, t) {
1728
1753
  return !e || !t ? e === t : e.streams.length === t.streams.length ? e.streams.every((e, n) => {
1729
1754
  let r = t.streams[n];
1730
1755
  return e.rid === r.rid && e.width === r.width && e.height === r.height && e.fps === r.fps && e.bitrate === r.bitrate;
1731
1756
  }) : !1;
1732
1757
  }
1733
- function on(e, t) {
1758
+ function sn(e, t) {
1734
1759
  for (let n of t) if (e <= n.dimension) return n.bitrate;
1735
- return t.length > 0 ? t[t.length - 1].bitrate : rn[0].bitrate;
1760
+ return t.length > 0 ? t[t.length - 1].bitrate : an[0].bitrate;
1736
1761
  }
1737
- function sn(e) {
1738
- return !Number.isFinite(e) || e <= 0 ? $t.FPS : Math.min(Math.round(e), en);
1762
+ function cn(e) {
1763
+ return !Number.isFinite(e) || e <= 0 ? en.FPS : Math.min(Math.round(e), tn);
1739
1764
  }
1740
- function cn(e = $t.WIDTH, t = $t.HEIGHT, n = rn, r = $t.FPS) {
1741
- let i = Math.max(e, t), a = sn(r), o = 1;
1765
+ function ln(e = en.WIDTH, t = en.HEIGHT, n = an, r = en.FPS) {
1766
+ let i = Math.max(e, t), a = cn(r), o = 1;
1742
1767
  i >= 960 ? o = 3 : i >= 480 && (o = 2);
1743
1768
  let s = [
1744
1769
  "h",
1745
1770
  "m",
1746
1771
  "l"
1747
- ].slice(3 - o), c = [], l = on(i, n);
1772
+ ].slice(3 - o), c = [], l = sn(i, n);
1748
1773
  for (let r = 0; r < o; r++) {
1749
1774
  let i = s[r];
1750
1775
  c.push({
@@ -1753,19 +1778,19 @@ function cn(e = $t.WIDTH, t = $t.HEIGHT, n = rn, r = $t.FPS) {
1753
1778
  height: t,
1754
1779
  fps: a,
1755
1780
  bitrate: l
1756
- }), e = Math.round(e / 2), t = Math.round(t / 2), l = on(Math.max(e, t), n);
1781
+ }), e = Math.round(e / 2), t = Math.round(t / 2), l = sn(Math.max(e, t), n);
1757
1782
  }
1758
1783
  return { streams: c.reverse() };
1759
1784
  }
1760
- function ln(e, t) {
1785
+ function un(e, t) {
1761
1786
  let n = t.streams.findIndex((t) => t.rid === e);
1762
1787
  return n >= 0 ? 2 ** (t.streams.length - n - 1) : 1;
1763
1788
  }
1764
- function un(e, t, n, r) {
1765
- let i = n ? Math.round(n * nn) : Infinity;
1789
+ function dn(e, t, n, r) {
1790
+ let i = n ? Math.round(n * rn) : Infinity;
1766
1791
  if (e.forEach((e) => {
1767
1792
  let n = t.streams.find((t) => t.rid === e.rid);
1768
- e.scaleResolutionDownBy = ln(e.rid, t), e.scalabilityMode = tn, n ? (e.active = n.rid === "l" || Math.max(n.width, n.height) < i, e.maxBitrate = n.bitrate, e.maxFramerate = n.fps) : (e.active = !1, e.maxBitrate = 0, delete e.maxFramerate);
1793
+ e.scaleResolutionDownBy = un(e.rid, t), e.scalabilityMode = nn, n ? (e.active = n.rid === "l" || Math.max(n.width, n.height) < i, e.maxBitrate = n.bitrate, e.maxFramerate = n.fps) : (e.active = !1, e.maxBitrate = 0, delete e.maxFramerate);
1769
1794
  }), r) for (let n = t.streams.length - 1; n >= 0; n--) {
1770
1795
  let { rid: i } = t.streams[n], a = e.find((e) => e.rid === i);
1771
1796
  if (a?.active) {
@@ -1776,13 +1801,13 @@ function un(e, t, n, r) {
1776
1801
  }
1777
1802
  //#endregion
1778
1803
  //#region src/static/Polyfills.ts
1779
- var dn = typeof Object.fromEntries == "function" ? Object.fromEntries : function(e) {
1804
+ var fn = typeof Object.fromEntries == "function" ? Object.fromEntries : function(e) {
1780
1805
  if (!e || !e[Symbol.iterator]) throw Error("Object.fromEntries() requires a single iterable argument");
1781
1806
  let t = {};
1782
1807
  for (let [n, r] of e) t[n] = r;
1783
1808
  return t;
1784
1809
  };
1785
- async function fn(e) {
1810
+ async function pn(e) {
1786
1811
  return new Promise((t, n) => {
1787
1812
  let r = new FileReader();
1788
1813
  r.onload = (e) => {
@@ -1790,16 +1815,16 @@ async function fn(e) {
1790
1815
  }, r.onerror = n, r.readAsArrayBuffer(e);
1791
1816
  });
1792
1817
  }
1793
- var pn = /\r?\n/;
1794
- function mn(e) {
1795
- return e.split(pn);
1796
- }
1818
+ var mn = /\r?\n/;
1797
1819
  function hn(e) {
1820
+ return e.split(mn);
1821
+ }
1822
+ function gn(e) {
1798
1823
  return e.join("\r\n");
1799
1824
  }
1800
1825
  //#endregion
1801
1826
  //#region src/static/Utils.ts
1802
- var gn = 533, _n = "a=fmtp:", vn = "sps-pps-idr-in-keyframe=1", yn;
1827
+ var _n = 533, vn = "a=fmtp:", yn = "sps-pps-idr-in-keyframe=1", bn;
1803
1828
  (function(e) {
1804
1829
  function t(e, t) {
1805
1830
  let n = /* @__PURE__ */ RegExp("a=rtpmap:(\\d+) ([a-zA-Z0-9-]+)\\/\\d+"), r, i = [];
@@ -1824,8 +1849,8 @@ var gn = 533, _n = "a=fmtp:", vn = "sps-pps-idr-in-keyframe=1", yn;
1824
1849
  for (let r = 0; r < e.length; ++r) {
1825
1850
  let i = e[r].match(n);
1826
1851
  if (i && i.length === 2 && t.includes(i[1])) {
1827
- let t = e[r].trim() === _n + i[1] ? " " : ";";
1828
- e[r] += t + vn;
1852
+ let t = e[r].trim() === vn + i[1] ? " " : ";";
1853
+ e[r] += t + yn;
1829
1854
  }
1830
1855
  }
1831
1856
  }
@@ -1895,22 +1920,22 @@ var gn = 533, _n = "a=fmtp:", vn = "sps-pps-idr-in-keyframe=1", yn;
1895
1920
  });
1896
1921
  }
1897
1922
  function f(e, n, i, a, o = !1) {
1898
- let s = mn(e);
1899
- if (d(s), !n && !i && !a && !o) return hn(s);
1923
+ let s = hn(e);
1924
+ if (d(s), !n && !i && !a && !o) return gn(s);
1900
1925
  function f(e) {
1901
1926
  let t = ["a=rtcp-fb:111 nack", "a=rtcp-fb:111 nack pli"], n = e.findIndex((e) => e.startsWith("a=rtcp-fb:111"));
1902
- return ~n && (e[n] = e[n] + "\r\n" + hn(t)), e;
1927
+ return ~n && (e[n] = e[n] + "\r\n" + gn(t)), e;
1903
1928
  }
1904
1929
  function p(e) {
1905
1930
  let n = t(e, "red");
1906
1931
  n.length > 0 && r(e, "audio", [], n);
1907
1932
  }
1908
- return i ? c(s, "H264", "local", "decoder") : l(s, n), a && u(s), p(s), o && f(s), hn(s);
1933
+ return i ? c(s, "H264", "local", "decoder") : l(s, n), a && u(s), p(s), o && f(s), gn(s);
1909
1934
  }
1910
1935
  e.patchLocalSDP = f;
1911
1936
  function p(e, t, n, r, i, o) {
1912
- let s = mn(e);
1913
- return n ? a(s, "H264") : t && l(s, t), i && o ? a(s, "VP9") : i ? c(s, "VP9", "remote", "encoder") : o ? c(s, "VP9", "remote", "decoder") : r && u(s), d(s), hn(s);
1937
+ let s = hn(e);
1938
+ return n ? a(s, "H264") : t && l(s, t), i && o ? a(s, "VP9") : i ? c(s, "VP9", "remote", "encoder") : o ? c(s, "VP9", "remote", "decoder") : r && u(s), d(s), gn(s);
1914
1939
  }
1915
1940
  e.patchRemoteSDP = p;
1916
1941
  function m(e) {
@@ -2023,7 +2048,7 @@ var gn = 533, _n = "a=fmtp:", vn = "sps-pps-idr-in-keyframe=1", yn;
2023
2048
  e.debounce = fe;
2024
2049
  function pe(e) {
2025
2050
  if (!window.BigInt) return null;
2026
- let t = "", n = mn(e);
2051
+ let t = "", n = hn(e);
2027
2052
  for (let e of n) if (e.startsWith("a=fingerprint")) {
2028
2053
  let n = e.split(" ");
2029
2054
  if (n.length === 2) {
@@ -2063,7 +2088,7 @@ var gn = 533, _n = "a=fmtp:", vn = "sps-pps-idr-in-keyframe=1", yn;
2063
2088
  if (!o) return;
2064
2089
  let s = e.maxBitrateK ? e.maxBitrateK * 1024 : null, c = o.width, l = o.height, u = c && l && e.maxDimension ? Math.max(1, Math.max(c, l) / e.maxDimension) : null, d = e.maxFramerate || null;
2065
2090
  if (c && l && e.maxDimension && e.maxDimension > Math.max(c, l)) {
2066
- let e = Math.round(c * l / 256), t = (Math.round(e * gn / 1e4) + 1) * 1e4;
2091
+ let e = Math.round(c * l / 256), t = (Math.round(e * _n / 1e4) + 1) * 1e4;
2067
2092
  s = s === null ? t : Math.min(t, s);
2068
2093
  }
2069
2094
  let f = e.degradationPreference || "balanced", p = r[n.id];
@@ -2079,8 +2104,8 @@ var gn = 533, _n = "a=fmtp:", vn = "sps-pps-idr-in-keyframe=1", yn;
2079
2104
  };
2080
2105
  let m = t.getParameters();
2081
2106
  if (m.encodings || (m.encodings = [{}]), m.encodings.length > 1 && c && l && e.maxDimension) {
2082
- let t = Math.round(e.maxDimension * 1.35), n = e.bitrates?.generic?.length ? e.bitrates.generic : void 0, r = o.frameRate || 30, i = cn(c, l, n, d ? Math.min(r, d) : r);
2083
- a.log(`applyVideoTrackSettings: maxDim=${e.maxDimension} targetDim=${t} track=${c}x${l} sim=${JSON.stringify(i)}`), un(m.encodings, i, e.maxDimension, n ? void 0 : s ?? void 0);
2107
+ let t = Math.round(e.maxDimension * 1.35), n = e.bitrates?.generic?.length ? e.bitrates.generic : void 0, r = o.frameRate || 30, i = ln(c, l, n, d ? Math.min(r, d) : r);
2108
+ a.log(`applyVideoTrackSettings: maxDim=${e.maxDimension} targetDim=${t} track=${c}x${l} sim=${JSON.stringify(i)}`), dn(m.encodings, i, e.maxDimension, n ? void 0 : s ?? void 0);
2084
2109
  } else m.encodings.forEach((t) => {
2085
2110
  e?.scalabilityMode && (t.scalabilityMode = e.scalabilityMode), s ? t.maxBitrate = s : delete t.maxBitrate, u ? t.scaleResolutionDownBy = u : delete t.scaleResolutionDownBy, d ? t.maxFramerate = d : delete t.maxFramerate;
2086
2111
  });
@@ -2166,7 +2191,7 @@ var gn = 533, _n = "a=fmtp:", vn = "sps-pps-idr-in-keyframe=1", yn;
2166
2191
  }
2167
2192
  e.participantMarkerCompare = Ce;
2168
2193
  function we(e, t) {
2169
- return dn(Object.entries(e).filter(([, e]) => Array.isArray(t) ? !t.includes(e) : e !== t));
2194
+ return fn(Object.entries(e).filter(([, e]) => Array.isArray(t) ? !t.includes(e) : e !== t));
2170
2195
  }
2171
2196
  e.objectFilterOutValues = we;
2172
2197
  function Te(e, t, n) {
@@ -2194,18 +2219,18 @@ var gn = 533, _n = "a=fmtp:", vn = "sps-pps-idr-in-keyframe=1", yn;
2194
2219
  return typeof e == "object" && !!e && !Array.isArray(e);
2195
2220
  }
2196
2221
  e.isObject = Ee;
2197
- })(yn || (yn = {}));
2198
- var M = yn, bn = "__CALLS_SDK_DEVTOOLS_", xn = class {
2222
+ })(bn || (bn = {}));
2223
+ var M = bn, xn = "__CALLS_SDK_DEVTOOLS_", Sn = class {
2199
2224
  set(e, t) {
2200
2225
  try {
2201
- this.getStorage().setItem(bn + e, JSON.stringify(t));
2226
+ this.getStorage().setItem(xn + e, JSON.stringify(t));
2202
2227
  } catch (t) {
2203
2228
  z.warn("DevTools: Failed to save option", e, t);
2204
2229
  }
2205
2230
  }
2206
2231
  get(e) {
2207
2232
  try {
2208
- let t = this.getStorage().getItem(bn + e);
2233
+ let t = this.getStorage().getItem(xn + e);
2209
2234
  return t === null ? null : JSON.parse(t);
2210
2235
  } catch (t) {
2211
2236
  return z.warn("DevTools: Failed to read option", e, t), null;
@@ -2213,7 +2238,7 @@ var M = yn, bn = "__CALLS_SDK_DEVTOOLS_", xn = class {
2213
2238
  }
2214
2239
  remove(e) {
2215
2240
  try {
2216
- this.getStorage().removeItem(bn + e);
2241
+ this.getStorage().removeItem(xn + e);
2217
2242
  } catch (t) {
2218
2243
  z.warn("DevTools: Failed to remove option", e, t);
2219
2244
  }
@@ -2221,7 +2246,7 @@ var M = yn, bn = "__CALLS_SDK_DEVTOOLS_", xn = class {
2221
2246
  clear() {
2222
2247
  try {
2223
2248
  let e = this.getStorage(), t = Object.keys(e);
2224
- for (let n of t) n.startsWith(bn) && e.removeItem(n);
2249
+ for (let n of t) n.startsWith(xn) && e.removeItem(n);
2225
2250
  } catch (e) {
2226
2251
  z.warn("DevTools: Failed to clear options", e);
2227
2252
  }
@@ -2229,7 +2254,7 @@ var M = yn, bn = "__CALLS_SDK_DEVTOOLS_", xn = class {
2229
2254
  getAll() {
2230
2255
  try {
2231
2256
  let e = this.getStorage(), t = Object.keys(e), n = {};
2232
- for (let r of t) if (r.startsWith(bn)) {
2257
+ for (let r of t) if (r.startsWith(xn)) {
2233
2258
  let t = r.substring(21), i = e.getItem(r);
2234
2259
  if (i !== null) try {
2235
2260
  n[t] = JSON.parse(i);
@@ -2243,7 +2268,7 @@ var M = yn, bn = "__CALLS_SDK_DEVTOOLS_", xn = class {
2243
2268
  getStorage() {
2244
2269
  return window.localStorage;
2245
2270
  }
2246
- }, Sn = class {
2271
+ }, Cn = class {
2247
2272
  constructor(e) {
2248
2273
  h(this, "storage", void 0), this.storage = e;
2249
2274
  }
@@ -2271,19 +2296,19 @@ var M = yn, bn = "__CALLS_SDK_DEVTOOLS_", xn = class {
2271
2296
  }
2272
2297
  return n;
2273
2298
  }
2274
- }, Cn = class e {
2299
+ }, wn = class e {
2275
2300
  static getInstance() {
2276
2301
  return e.instance || (e.instance = new e()), e.instance;
2277
2302
  }
2278
2303
  constructor() {
2279
- h(this, "params", void 0), h(this, "storage", void 0), this.storage = new xn(), this.params = new Sn(this.storage);
2304
+ h(this, "params", void 0), h(this, "storage", void 0), this.storage = new Sn(), this.params = new Cn(this.storage);
2280
2305
  }
2281
2306
  };
2282
- h(Cn, "instance", null);
2283
- var wn = Cn.getInstance(), N = class e {
2307
+ h(wn, "instance", null);
2308
+ var Tn = wn.getInstance(), N = class e {
2284
2309
  static set(t) {
2285
2310
  Object.hasOwn(t, "voiceParams") && (Object.assign(e._params.voiceParams, t.voiceParams), delete t.voiceParams), Object.hasOwn(t, "specListenerParams") && (Object.assign(e._params.specListenerParams, t.specListenerParams), delete t.specListenerParams), Object.hasOwn(t, "apiAuth") && (v.accessToken = t.apiAuth.accessToken, v.sessionKey = t.apiAuth.sessionKey, v.sessionSecretKey = t.apiAuth.sessionSecretKey, v.selfExternalId = null);
2286
- let n = wn.params.applyOverrides(t);
2311
+ let n = Tn.params.applyOverrides(t);
2287
2312
  Object.assign(e._params, M.objectFilterOutValues(n, void 0));
2288
2313
  }
2289
2314
  static getScreenFrameRate(t) {
@@ -2302,7 +2327,7 @@ var wn = Cn.getInstance(), N = class e {
2302
2327
  return 1.1;
2303
2328
  }
2304
2329
  static get sdkVersion() {
2305
- return "2.8.13-dev.7452edd3.0";
2330
+ return "2.8.13-dev.78098aca.0";
2306
2331
  }
2307
2332
  static get debug() {
2308
2333
  return e._params.debug;
@@ -2427,9 +2452,6 @@ var wn = Cn.getInstance(), N = class e {
2427
2452
  static get signalingReconnectMaxDelay() {
2428
2453
  return e._params.signalingReconnectMaxDelay;
2429
2454
  }
2430
- static get signalingReconnectMaxCount() {
2431
- return e._params.signalingReconnectMaxCount;
2432
- }
2433
2455
  static get signalingReconnectMaxDuration() {
2434
2456
  return e._params.signalingReconnectMaxDuration;
2435
2457
  }
@@ -2780,7 +2802,6 @@ h(N, "_params", {
2780
2802
  wssToken: "",
2781
2803
  signalingReconnectDelay: 1e3,
2782
2804
  signalingReconnectMaxDelay: 5e3,
2783
- signalingReconnectMaxCount: 10,
2784
2805
  signalingReconnectMaxDuration: 6e4,
2785
2806
  waitConnectionDelay: 1e4,
2786
2807
  waitResponseDelay: 1e4,
@@ -2897,10 +2918,10 @@ function I(e, t, ...n) {
2897
2918
  function L(e) {
2898
2919
  return Object.assign({}, e);
2899
2920
  }
2900
- function Tn(e) {
2921
+ function En(e) {
2901
2922
  return e.slice();
2902
2923
  }
2903
- var En;
2924
+ var Dn;
2904
2925
  (function(e) {
2905
2926
  function t(e, t, n) {
2906
2927
  F("onLocalStream", e, L(t), n);
@@ -3039,16 +3060,16 @@ var En;
3039
3060
  }
3040
3061
  e.onDeviceSwitched = _e;
3041
3062
  function _(e, t, n, r = !1, i = !1, a = null, o = null, s, c, l = null, u) {
3042
- let d = c ? Tn(c) : void 0;
3043
- F("onMuteStates", L(e), Tn(t), Tn(n), r, i, a, o, s, d, l, u);
3063
+ let d = c ? En(c) : void 0;
3064
+ F("onMuteStates", L(e), En(t), En(n), r, i, a, o, s, d, l, u);
3044
3065
  }
3045
3066
  e.onMuteStates = _;
3046
3067
  function ve(e, t, n = !1, r) {
3047
- I("onRolesChanged", e, Tn(t), n, r);
3068
+ I("onRolesChanged", e, En(t), n, r);
3048
3069
  }
3049
3070
  e.onRolesChanged = ve;
3050
3071
  function ye(e, t = !1, n) {
3051
- F("onLocalRolesChanged", Tn(e), t, n);
3072
+ F("onLocalRolesChanged", En(e), t, n);
3052
3073
  }
3053
3074
  e.onLocalRolesChanged = ye;
3054
3075
  function be(e, t, n, r, i) {
@@ -3060,7 +3081,7 @@ var En;
3060
3081
  }
3061
3082
  e.onLocalPin = xe;
3062
3083
  function Se(e, t) {
3063
- F("onOptionsChanged", Tn(e), t);
3084
+ F("onOptionsChanged", En(e), t);
3064
3085
  }
3065
3086
  e.onOptionsChanged = Se;
3066
3087
  function Ce(e) {
@@ -3084,7 +3105,7 @@ var En;
3084
3105
  }
3085
3106
  e.onSpeakerChanged = De;
3086
3107
  function Oe(e, t) {
3087
- F("onVolumesDetected", Tn(e), t);
3108
+ F("onVolumesDetected", En(e), t);
3088
3109
  }
3089
3110
  e.onVolumesDetected = Oe;
3090
3111
  function ke(e, t) {
@@ -3256,10 +3277,10 @@ var En;
3256
3277
  F("onNonFatalError", e, t);
3257
3278
  }
3258
3279
  e.onNonFatalError = ct;
3259
- })(En || (En = {}));
3260
- var R = En, Dn = /* @__PURE__ */ function(e) {
3280
+ })(Dn || (Dn = {}));
3281
+ var R = Dn, On = /* @__PURE__ */ function(e) {
3261
3282
  return e.DEBUG = "DEBUG", e.LOG = "LOG", e.WARN = "WARN", e.ERROR = "ERROR", e;
3262
- }({}), On;
3283
+ }({}), kn;
3263
3284
  (function(e) {
3264
3285
  let t = "📞", n = () => ({
3265
3286
  sessionId: null,
@@ -3372,8 +3393,8 @@ var R = En, Dn = /* @__PURE__ */ function(e) {
3372
3393
  e.createSessionLogger = re;
3373
3394
  function ie(e, ...t) {}
3374
3395
  e.test = ie;
3375
- })(On || (On = {}));
3376
- var z = On, B = new class {
3396
+ })(kn || (kn = {}));
3397
+ var z = kn, B = new class {
3377
3398
  constructor() {
3378
3399
  h(this, "_conversations", /* @__PURE__ */ new Map()), h(this, "_pending", /* @__PURE__ */ new Set()), h(this, "_initialIds", /* @__PURE__ */ new Map()), h(this, "_hangups", /* @__PURE__ */ new Map()), h(this, "_activeId", null), h(this, "_selected", null), h(this, "_mutex", !1), h(this, "_pendingRemovals", /* @__PURE__ */ new Map());
3379
3400
  }
@@ -3515,33 +3536,14 @@ var z = On, B = new class {
3515
3536
  this._pendingRemovals.clear();
3516
3537
  }
3517
3538
  }
3518
- }(), kn = class extends Error {
3539
+ }(), An = class extends Error {
3519
3540
  constructor(e) {
3520
3541
  super(e ? `Signaling disposed. Command ${e}` : "Signaling disposed"), this.name = "SignalingDisposedError";
3521
3542
  }
3522
- }, An = class extends Error {
3543
+ }, jn = class extends Error {
3523
3544
  constructor(e) {
3524
3545
  super(e ? `Producer connection closed. Command ${e}` : "Producer connection closed"), this.name = "ProducerConnectionClosedError";
3525
3546
  }
3526
- }, jn = class extends Ye {
3527
- constructor(...e) {
3528
- super(...e), h(this, "_abortSignal", void 0);
3529
- }
3530
- setAbortSignal(e) {
3531
- this._abortSignal = e;
3532
- }
3533
- get ready() {
3534
- return !0;
3535
- }
3536
- setParticipantIdRegistry(e) {}
3537
- requestRealloc() {}
3538
- setEndpoint(e) {}
3539
- setWebTransportEndpoint(e) {}
3540
- readyToSend(e = !0) {}
3541
- async requestTestMode(e, t) {}
3542
- getNextCommandSequenceNumber() {
3543
- return 0;
3544
- }
3545
3547
  }, V = /* @__PURE__ */ function(e) {
3546
3548
  return e.RECOVER = "recover", e.ACCEPT_CALL = "accept-call", e.ADD_PARTICIPANT = "add-participant", e.REMOVE_PARTICIPANT = "remove-participant", e.HANGUP = "hangup", e.TRANSMIT_DATA = "transmit-data", e.ACCEPT_PRODUCER = "accept-producer", e.ALLOCATE_CONSUMER = "allocate-consumer", e.CHANGE_MEDIA_SETTINGS = "change-media-settings", e.CHANGE_PARTICIPANT_STATE = "change-participant-state", e.CHANGE_STREAM_PRIORITIES = "change-streams-priorities", e.UPDATE_DISPLAY_LAYOUT = "update-display-layout", e.REPORT_PERF_STAT = "report-perf-stat", e.REPORT_SHARING_STAT = "report-sharing-stat", e.REPORT_NETWORK_STAT = "report-network-stat", e.RECORD_START = "record-start", e.RECORD_STOP = "record-stop", e.RECORD_PUBLISH = "record-publish", e.RECORD_SET_CONF = "record-set-conf", e.RECORD_GET_STATUS = "record-get-status", e.SWITCH_MICRO = "switch-micro", e.SWITCH_TOPOLOGY = "switch-topology", e.REQUEST_REALLOC = "request-realloc", e.CHAT_MESSAGE = "chat-message", e.CHAT_HISTORY = "chat-history", e.CUSTOM_DATA = "custom-data", e.GRANT_ROLES = "grant-roles", e.MUTE_PARTICIPANT = "mute-participant", e.ENABLE_FEATURE_FOR_ROLES = "enable-feature-for-roles", e.PIN_PARTICIPANT = "pin-participant", e.UPDATE_MEDIA_MODIFIERS = "update-media-modifiers", e.CHANGE_OPTIONS = "change-options", e.GET_WAITING_HALL = "get-waiting-hall", e.GET_PARTICIPANT_LIST_CHUNK = "get-participant-list-chunk", e.GET_PARTICIPANTS = "get-participants", e.PROMOTE_PARTICIPANT = "promote-participant", e.REQUEST_TEST_MODE = "request-test-mode", e.ADD_MOVIE = "add-movie", e.UPDATE_MOVIE = "update-movie", e.REMOVE_MOVIE = "remove-movie", e.START_URL_SHARING = "start-url-sharing", e.STOP_URL_SHARING = "stop-url-sharing", e.GET_ROOMS = "get-rooms", e.UPDATE_ROOMS = "update-rooms", e.ACTIVATE_ROOMS = "activate-rooms", e.REMOVE_ROOMS = "remove-rooms", e.SWITCH_ROOM = "switch-room", e.FEEDBACK = "feedback", e.ASR_START = "asr-start", e.ASR_STOP = "asr-stop", e.REQUEST_ASR = "request-asr", e.REQUEST_PROMOTION = "request-promotion", e.ACCEPT_PROMOTION = "accept-promotion", e.GET_HAND_QUEUE = "get-hand-queue", e.ENABLE_VIDEO_SUSPEND = "enable-video-suspend", e.ENABLE_VIDEO_SUSPEND_SUGGEST = "enable-video-suspend-suggest", e.HOLD = "hold", e.PUT_HANDS_DOWN = "put-hands-down", e.CHANGE_SIMULCAST = "change-simulcast", e;
3547
3549
  }(V || {});
@@ -3771,7 +3773,7 @@ var Un = 0, Wn = 1, Gn = 2, Kn = 3, qn = 4, Jn = 5, Yn = 6, Xn = 7, Zn = 0, Qn =
3771
3773
  }
3772
3774
  async deserializeCommandResponse(e) {
3773
3775
  let t;
3774
- t = e instanceof Blob ? Hn("arrayBuffer" in Blob.prototype ? await e.arrayBuffer() : await fn(e)) : Hn(e);
3776
+ t = e instanceof Blob ? Hn("arrayBuffer" in Blob.prototype ? await e.arrayBuffer() : await pn(e)) : Hn(e);
3775
3777
  let n = i.dec(t), r = i.dec(t);
3776
3778
  if (r !== er) {
3777
3779
  this._debug.warn("Unsupported version for command type: " + n + ", version " + r);
@@ -4443,7 +4445,7 @@ var ei = class {
4443
4445
  worst: 320,
4444
4446
  bad: 640,
4445
4447
  good: 1280
4446
- }), h(this, "_lastVideoMaxDimension", this._videoMaxDimensionsForNet.good), h(this, "_lastBadConnection", 0), h(this, "_perfStatReporter", void 0), h(this, "_directStatReporter", void 0), h(this, "_sdpStats", void 0), h(this, "_peerConnectionStats", void 0), h(this, "_networkAdaptationStats", 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 Ha(this, n, this._statAggregator, !0, this._debug), this._directStatReporter = new fi(n, this._debug), this._sdpStats = new Mr(this._statAggregator), this._peerConnectionStats = new Jr(this._statAggregator), this._networkAdaptationStats = new Zr(this._statAggregator), this.subscribe(this._signaling, wr.NOTIFICATION, this._onSignalingNotification.bind(this)), this.subscribe(this._mediaSource, Xt.TRACK_REPLACED, this._onReplacedTrack.bind(this)), this.subscribe(this._mediaSource, Xt.SOURCE_CHANGED, this._applySettings.bind(this)), this.subscribe(this._directStatReporter, Y.NETWORK_STATUS, this._onNetworkStatus.bind(this));
4448
+ }), h(this, "_lastVideoMaxDimension", this._videoMaxDimensionsForNet.good), h(this, "_lastBadConnection", 0), h(this, "_perfStatReporter", void 0), h(this, "_directStatReporter", void 0), h(this, "_sdpStats", void 0), h(this, "_peerConnectionStats", void 0), h(this, "_networkAdaptationStats", 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 Ha(this, n, this._statAggregator, !0, this._debug), this._directStatReporter = new fi(n, this._debug), this._sdpStats = new Mr(this._statAggregator), this._peerConnectionStats = new Jr(this._statAggregator), this._networkAdaptationStats = new Zr(this._statAggregator), this.subscribe(this._signaling, wr.NOTIFICATION, this._onSignalingNotification.bind(this)), this.subscribe(this._mediaSource, Zt.TRACK_REPLACED, this._onReplacedTrack.bind(this)), this.subscribe(this._mediaSource, Zt.SOURCE_CHANGED, this._applySettings.bind(this)), this.subscribe(this._directStatReporter, Y.NETWORK_STATUS, this._onNetworkStatus.bind(this));
4447
4449
  try {
4448
4450
  this._pc = this._createPeerConnection();
4449
4451
  } catch (e) {
@@ -4716,7 +4718,7 @@ var ei = class {
4716
4718
  this._debug.log("Switch topology DIRECT to SERVER", { participantId: this._participantId });
4717
4719
  let t = e === Yr.CONNECTION_FAILED ? this._connectionLostAt : this._connectionStartedAt;
4718
4720
  this._networkAdaptationStats.logServerTopologyRequested(e, Date.now() - t), e === Yr.NO_CONNECTION_TIMEOUT && (this._serverRequestedOnNoConnection = !0), this._signaling.switchTopology(J.SERVER).catch((e) => {
4719
- e instanceof kn || this._debug.warn("Unable to switch topology DIRECT to SERVER", e);
4721
+ e instanceof An || this._debug.warn("Unable to switch topology DIRECT to SERVER", e);
4720
4722
  });
4721
4723
  }
4722
4724
  }
@@ -6134,7 +6136,7 @@ var qi = 2 ** 15 - 1, Ji = 1, Yi = 5, Xi = 5, Zi = class e {
6134
6136
  if (e - this._lastSharingStat > Ca) {
6135
6137
  let t = this._congestionControl.getStat();
6136
6138
  t !== null && (this._debug.debug(`cc: send stats: ${JSON.stringify(t)}`), this._signaling.reportSharingStat(t).catch((e) => {
6137
- !(e instanceof kn) && !(e instanceof An) && this._debug.warn("Unable to send sharing stats", e);
6139
+ !(e instanceof An) && !(e instanceof jn) && this._debug.warn("Unable to send sharing stats", e);
6138
6140
  })), this._lastSharingStat = e;
6139
6141
  }
6140
6142
  }
@@ -6161,14 +6163,14 @@ var qi = 2 ** 15 - 1, Ji = 1, Yi = 5, Xi = 5, Zi = class e {
6161
6163
  this._pc.getTransceivers().forEach((e) => {
6162
6164
  e.mid === null && e.stop();
6163
6165
  });
6164
- let t = mn(e), n = this._findMediaSection(t, this._transceiver.mid);
6166
+ let t = hn(e), n = this._findMediaSection(t, this._transceiver.mid);
6165
6167
  if (n) {
6166
6168
  for (let e = n.start; e < n.end; e++) if (t[e].startsWith("a=simulcast:send ")) {
6167
6169
  t[e] = t[e].replaceAll("~", "");
6168
6170
  break;
6169
6171
  }
6170
6172
  let e = this._mediaSource.getStream()?.getVideoTracks()[0];
6171
- e && this._getConfig($t.WIDTH, $t.HEIGHT, e.getSettings().frameRate).simulcastInfo.streams.forEach((e) => {
6173
+ e && this._getConfig(en.WIDTH, en.HEIGHT, e.getSettings().frameRate).simulcastInfo.streams.forEach((e) => {
6172
6174
  let r = `a=rid:${e.rid} send`;
6173
6175
  for (let i = n.start; i < n.end; i++) if (t[i] === r || t[i].startsWith(r + " ")) {
6174
6176
  t[i] = `${r} max-width=${e.width};max-height=${e.height};max-fps=${e.fps};max-br=${e.bitrate}`;
@@ -6176,17 +6178,17 @@ var qi = 2 ** 15 - 1, Ji = 1, Yi = 5, Xi = 5, Zi = class e {
6176
6178
  }
6177
6179
  });
6178
6180
  }
6179
- return hn(t);
6181
+ return gn(t);
6180
6182
  }
6181
6183
  async sync({ force: e = !1 } = {}) {
6182
6184
  if (!this._transceiver || !this._currentSimulcastInfo || !this._mediaSource.mediaSettings.isVideoEnabled) return;
6183
6185
  let t = this._mediaSource.getStream()?.getVideoTracks()[0];
6184
6186
  if (!t) return;
6185
6187
  let n = this._getTrackConfig(t);
6186
- if (!e && an(this._currentSimulcastInfo, n.simulcastInfo)) return;
6188
+ if (!e && on(this._currentSimulcastInfo, n.simulcastInfo)) return;
6187
6189
  let r = await this._applyConfig(n, !0);
6188
6190
  r && (this._debug.log(`SimulcastSender: Sync ${n.width}x${n.height} encodings=${JSON.stringify(r.encodings)}`), await this._changeSimulcast({
6189
- mediaSource: Zt.CAMERA,
6191
+ mediaSource: Qt.CAMERA,
6190
6192
  simulcastInfo: n.simulcastInfo
6191
6193
  }));
6192
6194
  }
@@ -6228,21 +6230,21 @@ var qi = 2 ** 15 - 1, Ji = 1, Yi = 5, Xi = 5, Zi = class e {
6228
6230
  return {
6229
6231
  width: e,
6230
6232
  height: t,
6231
- simulcastInfo: cn(e, t, a, i),
6233
+ simulcastInfo: ln(e, t, a, i),
6232
6234
  maxDimension: r?.maxDimension,
6233
6235
  maxBitrate: !a && r?.maxBitrateK ? r.maxBitrateK * 1024 : void 0
6234
6236
  };
6235
6237
  }
6236
6238
  _getTrackConfig(e) {
6237
6239
  let t = e.getSettings();
6238
- return this._getConfig(t.width ?? $t.WIDTH, t.height ?? $t.HEIGHT, t.frameRate);
6240
+ return this._getConfig(t.width ?? en.WIDTH, t.height ?? en.HEIGHT, t.frameRate);
6239
6241
  }
6240
6242
  async _applyConfig(e, t = !1) {
6241
6243
  let n = this._transceiver;
6242
6244
  if (!n) return null;
6243
6245
  let r = n.sender.getParameters();
6244
6246
  if (r.encodings.length <= 1) return null;
6245
- un(r.encodings, e.simulcastInfo, e.maxDimension, e.maxBitrate);
6247
+ dn(r.encodings, e.simulcastInfo, e.maxDimension, e.maxBitrate);
6246
6248
  try {
6247
6249
  await n.sender.setParameters(r);
6248
6250
  } catch (e) {
@@ -6259,7 +6261,7 @@ var qi = 2 ** 15 - 1, Ji = 1, Yi = 5, Xi = 5, Zi = class e {
6259
6261
  async _syncReplacedTrack(e) {
6260
6262
  let t = this._getTrackConfig(e);
6261
6263
  this._currentSimulcastInfo = t.simulcastInfo, await this._changeSimulcast({
6262
- mediaSource: Zt.CAMERA,
6264
+ mediaSource: Qt.CAMERA,
6263
6265
  simulcastInfo: t.simulcastInfo
6264
6266
  });
6265
6267
  }
@@ -6267,12 +6269,12 @@ var qi = 2 ** 15 - 1, Ji = 1, Yi = 5, Xi = 5, Zi = class e {
6267
6269
  try {
6268
6270
  await this._signaling.changeSimulcast(e);
6269
6271
  } catch (e) {
6270
- if (!(e instanceof An)) throw e;
6272
+ if (!(e instanceof jn)) throw e;
6271
6273
  }
6272
6274
  }
6273
6275
  }, ka = 90, Aa = 4294967295, ja = class e extends ti {
6274
6276
  constructor(e, t, n, r = z, i = null, a = null, o = null, s = null) {
6275
- super(e, t, s), h(this, "_producerNotification", null), h(this, "_producerCommand", null), h(this, "_producerScreen", null), h(this, "_consumerScreen", null), h(this, "_asr", null), h(this, "_animojiDataChannel", null), h(this, "_animojiReceiver", null), h(this, "_animojiSender", null), h(this, "_isOpen", !1), h(this, "_observer", !1), h(this, "_reconnectionPrevented", !1), h(this, "_statInterval", null), h(this, "_settingsInterval", null), h(this, "_monitorRtpShareInterval", null), h(this, "_statBytes", {}), h(this, "_ssrcMap", {}), h(this, "_ssrcMapUpdated", !1), h(this, "_perfStatReporter", void 0), h(this, "_producerOfferIsProcessing", !1), h(this, "_producerNextOffer", null), h(this, "_producerNextSessionId", null), h(this, "_lastStat", null), h(this, "_serverSettings", void 0), h(this, "_prevConsumerSettings", {}), h(this, "_prevConsumerFastSharingSettings", {}), h(this, "_asrTrack", null), h(this, "_captureSender", null), h(this, "_captureReceiver", null), h(this, "_participantIdRegistry", null), h(this, "_disabledSenders", /* @__PURE__ */ new Set()), h(this, "_rtpReceiversByStreamId", {}), h(this, "_producerSessionId", ""), h(this, "_newAudioShareTrack", null), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_sdpStats", void 0), h(this, "_peerConnectionStats", void 0), h(this, "_codecStatsAggregator", void 0), h(this, "_simulcast", void 0), this._debug = r, this._logger = i, this._statAggregator = a, this._sdpStats = new Mr(a), this._peerConnectionStats = new Jr(a), this._codecStatsAggregator = o, this._serverSettings = n, this._simulcast = new Oa(e, t, () => this._serverSettings.camera, r, i), this.subscribe(this._signaling, wr.NOTIFICATION, this._onSignalingNotification.bind(this)), this.subscribe(this._mediaSource, Xt.TRACK_REPLACED, this._onReplacedTrack.bind(this)), this.subscribe(this._mediaSource, Xt.SOURCE_CHANGED, this._onSourcesChanged.bind(this)), this.subscribe(this._mediaSource, Xt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._createPerfStatsReporter(), this._debug.debug("ServerTransport: Created");
6277
+ super(e, t, s), h(this, "_producerNotification", null), h(this, "_producerCommand", null), h(this, "_producerScreen", null), h(this, "_consumerScreen", null), h(this, "_asr", null), h(this, "_animojiDataChannel", null), h(this, "_animojiReceiver", null), h(this, "_animojiSender", null), h(this, "_isOpen", !1), h(this, "_observer", !1), h(this, "_reconnectionPrevented", !1), h(this, "_statInterval", null), h(this, "_settingsInterval", null), h(this, "_monitorRtpShareInterval", null), h(this, "_statBytes", {}), h(this, "_ssrcMap", {}), h(this, "_ssrcMapUpdated", !1), h(this, "_perfStatReporter", void 0), h(this, "_producerOfferIsProcessing", !1), h(this, "_producerNextOffer", null), h(this, "_producerNextSessionId", null), h(this, "_lastStat", null), h(this, "_serverSettings", void 0), h(this, "_prevConsumerSettings", {}), h(this, "_prevConsumerFastSharingSettings", {}), h(this, "_asrTrack", null), h(this, "_captureSender", null), h(this, "_captureReceiver", null), h(this, "_participantIdRegistry", null), h(this, "_disabledSenders", /* @__PURE__ */ new Set()), h(this, "_rtpReceiversByStreamId", {}), h(this, "_producerSessionId", ""), h(this, "_newAudioShareTrack", null), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_sdpStats", void 0), h(this, "_peerConnectionStats", void 0), h(this, "_codecStatsAggregator", void 0), h(this, "_simulcast", void 0), this._debug = r, this._logger = i, this._statAggregator = a, this._sdpStats = new Mr(a), this._peerConnectionStats = new Jr(a), this._codecStatsAggregator = o, this._serverSettings = n, this._simulcast = new Oa(e, t, () => this._serverSettings.camera, r, i), this.subscribe(this._signaling, wr.NOTIFICATION, this._onSignalingNotification.bind(this)), this.subscribe(this._mediaSource, Zt.TRACK_REPLACED, this._onReplacedTrack.bind(this)), this.subscribe(this._mediaSource, Zt.SOURCE_CHANGED, this._onSourcesChanged.bind(this)), this.subscribe(this._mediaSource, Zt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._createPerfStatsReporter(), this._debug.debug("ServerTransport: Created");
6276
6278
  }
6277
6279
  updateStatisticsInterval() {
6278
6280
  this._stopStatInterval();
@@ -6384,7 +6386,7 @@ var qi = 2 ** 15 - 1, Ji = 1, Yi = 5, Xi = 5, Zi = class e {
6384
6386
  this._triggerEvent(Y.NETWORK_STATUS, e);
6385
6387
  }
6386
6388
  _updateSSRCMap(e) {
6387
- e && (this._ssrcMap = {}, this._ssrcMapUpdated = !0, mn(e.sdp).forEach((e) => {
6389
+ e && (this._ssrcMap = {}, this._ssrcMapUpdated = !0, hn(e.sdp).forEach((e) => {
6388
6390
  let t = `a=ssrc:([0-9]+) label:(audio|video)-((?:[ug]?[\\d]+)|(?:mix)|(?:${hi.PARTICIPANT_AGNOSTIC_TRACK_PREFIX}-[0-9]+)|(?:${hi.TRANSPARENT_AUDIO_TRACK_PREFIX}-[0-9]+))`, n = new RegExp(t).exec(e);
6389
6391
  n && (this._ssrcMap[n[1]] = n[3]);
6390
6392
  }));
@@ -6416,7 +6418,7 @@ var qi = 2 ** 15 - 1, Ji = 1, Yi = 5, Xi = 5, Zi = class e {
6416
6418
  if (!n.track || n.track.kind !== A.video || n.track.contentHint === "motion") return;
6417
6419
  let r = !this._disabledSenders.has(n), i = e.maxDimension !== 0;
6418
6420
  if (r && !i) {
6419
- this._debug.log("Disabling video upload"), this._disabledSenders.add(n), n.replaceTrack(E.getBlackMediaTrack()).catch((e) => {
6421
+ this._debug.log("Disabling video upload"), this._disabledSenders.add(n), n.replaceTrack(D.getBlackMediaTrack()).catch((e) => {
6420
6422
  this._debug.error("Could not disable video upload", e);
6421
6423
  });
6422
6424
  return;
@@ -6528,7 +6530,7 @@ var qi = 2 ** 15 - 1, Ji = 1, Yi = 5, Xi = 5, Zi = class e {
6528
6530
  if (!this._signaling.ready) return;
6529
6531
  let e = Ja.get();
6530
6532
  !N.videoTracksCount && !this._observer && this._debug.warn("Setting videoTracksCount to 0 is deprecated"), this._signaling.allocateConsumer(null, e).catch((e) => {
6531
- e instanceof kn || this._debug.warn("ServerTransport: Unable to allocate consumer", e);
6533
+ e instanceof An || this._debug.warn("ServerTransport: Unable to allocate consumer", e);
6532
6534
  });
6533
6535
  }
6534
6536
  async _processOffer(e, t) {
@@ -6640,7 +6642,7 @@ var qi = 2 ** 15 - 1, Ji = 1, Yi = 5, Xi = 5, Zi = class e {
6640
6642
  }
6641
6643
  async _onProducerUpdated(e) {
6642
6644
  this._producerSessionId && this._producerSessionId !== e.sessionId && this._reconnect(), N.breakVideoPayloadTypes && (this._debug.log("test mode enabled, video switched off"), this._signaling.requestTestMode("breakVideoPayloadTypes", null).catch((e) => {
6643
- e instanceof kn || this._debug.warn("Unable to enable signaling test mode", e);
6645
+ e instanceof An || this._debug.warn("Unable to enable signaling test mode", e);
6644
6646
  })), this._producerSessionId = e.sessionId, await this._acceptProducer(e.description, e.sessionId);
6645
6647
  }
6646
6648
  _onAddTrack(e, t) {
@@ -6741,7 +6743,7 @@ var qi = 2 ** 15 - 1, Ji = 1, Yi = 5, Xi = 5, Zi = class e {
6741
6743
  constructor(e, t, n, r, i = z, a = null, o = null, s = null, c = null) {
6742
6744
  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", () => {
6743
6745
  this._vadController?.setSendTrack(this._mediaSource.getSendAudioTrack());
6744
- }), this._signaling = t, this._mediaSource = n, this._topology = e, this._serverSettings = r, this._debug = i, this._logger = a, this._statAggregator = o, this._codecStatsAggregator = s, this._onFirstMediaSent = c, this.subscribe(this._signaling, wr.NOTIFICATION, this._onSignalingNotification.bind(this)), this.subscribe(this._mediaSource, Xt.ANIMOJI_STATUS, this._onAnimojiStatus.bind(this)), this.subscribe(this._mediaSource, Xt.SOURCE_CHANGED, this._onSourceChanged.bind(this)), this.subscribe(this._mediaSource, Xt.SOURCE_READY, this._updateVadTrack), this._createVad(), this._createAnimojiTransport(), e === J.SERVER && (this._serverTransport = this._createServerTransport());
6746
+ }), this._signaling = t, this._mediaSource = n, this._topology = e, this._serverSettings = r, this._debug = i, this._logger = a, this._statAggregator = o, this._codecStatsAggregator = s, this._onFirstMediaSent = c, this.subscribe(this._signaling, wr.NOTIFICATION, this._onSignalingNotification.bind(this)), this.subscribe(this._mediaSource, Zt.ANIMOJI_STATUS, this._onAnimojiStatus.bind(this)), this.subscribe(this._mediaSource, Zt.SOURCE_CHANGED, this._onSourceChanged.bind(this)), this.subscribe(this._mediaSource, Zt.SOURCE_READY, this._updateVadTrack), this._createVad(), this._createAnimojiTransport(), e === J.SERVER && (this._serverTransport = this._createServerTransport());
6745
6747
  }
6746
6748
  updateSettings(e) {
6747
6749
  this._debug.log("Update transport settings", e), this._serverSettings = e, this._directTransport && this._directTransport.updateSettings(e), this._serverTransport && this._serverTransport.updateSettings(e);
@@ -7356,21 +7358,15 @@ var Ja = qa, Ya = {
7356
7358
  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 ro(this.compression), this.decoder = new io(this.compression), this.connect();
7357
7359
  }
7358
7360
  async send(e) {
7359
- if (this.readyState !== WebSocket.OPEN) {
7360
- this._debug.warn("[WebTransport] Attempt to send data before webtransport is open");
7361
- return;
7362
- }
7361
+ if (this.readyState !== WebSocket.OPEN) throw this._debug.warn("[WebTransport] Attempt to send data before webtransport is open"), Error("WebTransport is not open");
7363
7362
  let t = this.writer;
7364
- if (!t) {
7365
- this._debug.warn("[WebTransport] Attempt to send data before stream is ready");
7366
- return;
7367
- }
7363
+ if (!t) throw this._debug.warn("[WebTransport] Attempt to send data before stream is ready"), Error("WebTransport stream is not ready");
7368
7364
  try {
7369
7365
  await t.ready;
7370
7366
  let n = this.encoder.encode(e);
7371
7367
  await t.write(n);
7372
7368
  } catch (e) {
7373
- this.handleStreamError("send", e);
7369
+ throw this.handleStreamError("send", e), e;
7374
7370
  }
7375
7371
  }
7376
7372
  close(e = 1e3, t = "") {
@@ -7480,148 +7476,172 @@ var Ja = qa, Ya = {
7480
7476
  }, n;
7481
7477
  }
7482
7478
  }, oo = /* @__PURE__ */ function(e) {
7483
- return e.EMPTY_ENDPOINT = "EMPTY_ENDPOINT", e.NETWORK_ERROR = "NETWORK_ERROR", e.RECONNECT_TIMEOUT = "RECONNECT_TIMEOUT", e.ABORTED = "ABORTED", e;
7479
+ return e.EMPTY_ENDPOINT = "EMPTY_ENDPOINT", e.CONNECTION_TIMEOUT = "CONNECTION_TIMEOUT", e.RECONNECT_TIMEOUT = "RECONNECT_TIMEOUT", e.ABORTED = "ABORTED", e;
7484
7480
  }({}), so = class {
7485
7481
  constructor(e = z, t) {
7486
- h(this, "handlers", void 0), h(this, "socket", null), h(this, "endpoint", ""), h(this, "wtEndpoint", null), h(this, "peerId", null), h(this, "lastStamp", 0), h(this, "connectionType", void 0), h(this, "reconnectCount", 0), h(this, "reconnectTimer", 0), h(this, "reconnectDeadlineTimer", 0), h(this, "doctorTimer", 0), h(this, "forceWebSocket", !1), h(this, "abortSignal", void 0), h(this, "manualClose", !1), h(this, "currentType", Tr.WEBSOCKET), h(this, "_debug", void 0), this.handlers = t, this._debug = e;
7482
+ h(this, "_debug", void 0), h(this, "handlers", void 0), h(this, "socket", null), h(this, "state", "terminal"), 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, "retryTimer", 0), h(this, "connectionDeadlineTimer", 0), h(this, "attemptTimer", 0), h(this, "pingTimer", 0), h(this, "pingTimeoutMs", N.waitMessageDelay), h(this, "reconnectTimeoutMs", N.signalingReconnectMaxDuration), h(this, "forceWebSocket", !1), h(this, "hasEstablished", !1), h(this, "abortSignal", void 0), h(this, "currentType", Tr.WEBSOCKET), h(this, "onAbort", this._onAbort.bind(this)), this._debug = e, this.handlers = t;
7487
7483
  }
7488
- get readyState() {
7489
- return this.socket?.readyState ?? null;
7490
- }
7491
- get type() {
7492
- return this.currentType;
7484
+ get active() {
7485
+ return this.state !== "terminal";
7493
7486
  }
7494
- setEndpoint(e) {
7495
- this.endpoint = e;
7487
+ get established() {
7488
+ return this.state === "established";
7496
7489
  }
7497
- setWebTransportEndpoint(e) {
7498
- this.wtEndpoint = e || null;
7490
+ get canSend() {
7491
+ return this.active && this.socket?.readyState === WebSocket.OPEN;
7499
7492
  }
7500
- setPeerId(e) {
7501
- this.peerId = e;
7493
+ get type() {
7494
+ return this.currentType;
7502
7495
  }
7503
- setLastStamp(e) {
7504
- this.lastStamp = e;
7496
+ getPeerId() {
7497
+ return this.peerId;
7505
7498
  }
7506
7499
  setAbortSignal(e) {
7507
- this.abortSignal = e;
7500
+ this.abortSignal?.removeEventListener("abort", this.onAbort), this.abortSignal = e, e?.addEventListener("abort", this.onAbort), e?.aborted && this.onAbort();
7508
7501
  }
7509
- onConnectionRestored() {
7510
- this.reconnectCount = 0, this._stopReconnectDeadline();
7511
- }
7512
- connect(e) {
7513
- this.socket && this.socket.readyState < WebSocket.CLOSING || (e !== Cr.RETRY && (this.forceWebSocket = !1, this.reconnectCount = 0), this.manualClose = !1, this.connectionType = e, this._connect());
7502
+ connect(e, t) {
7503
+ if (!this.active) {
7504
+ if (this.endpoint = t.endpoint, this.wtEndpoint = t.webTransportEndpoint || null, this.state = "connecting", this.connectionType = e, this.forceWebSocket = !1, this.reconnectCount = 0, this.hasEstablished = !1, this._updateTimeouts(), this.abortSignal?.aborted) {
7505
+ this.onAbort();
7506
+ return;
7507
+ }
7508
+ this._startConnectionDeadlineTimer(), this._connect();
7509
+ }
7514
7510
  }
7515
7511
  close(e) {
7516
- this.manualClose = !0, this._disconnect(e), window.clearTimeout(this.reconnectTimer), this.reconnectTimer = 0, this._stopReconnectDeadline(), this.lastStamp = 0;
7512
+ this.state = "terminal", this._stopRetryTimer(), this._stopConnectionDeadlineTimer(), this._disconnect(e), this.setAbortSignal(void 0), this.lastStamp = 0;
7517
7513
  }
7518
7514
  async send(e) {
7519
- await this.socket?.send(e);
7515
+ let t = this.socket;
7516
+ if (!this.canSend || !t) throw Error("Signaling socket is not open");
7517
+ await t.send(e);
7520
7518
  }
7521
7519
  _connect() {
7522
- if (this._canUseWebTransport()) {
7523
- this._connectWebTransport();
7524
- return;
7525
- }
7526
- this._connectWebSocket();
7527
- }
7528
- _connectWebTransport() {
7529
- if (!this.wtEndpoint) {
7530
- this._connectWebSocket();
7531
- return;
7532
- }
7533
- let e = this._buildUrl(this.wtEndpoint, !0);
7534
- this.currentType = Tr.WEBTRANSPORT, this.socket = new ao(e, { congestionControl: "low-latency" }, this._debug), this._setSocketHandlers();
7535
- }
7536
- _connectWebSocket() {
7537
- if (!this.endpoint) {
7538
- this.handlers.onFailed({
7539
- failure: "EMPTY_ENDPOINT",
7540
- message: "Unable to connect to the signaling: endpoint is not set",
7541
- source: Tr.WEBSOCKET,
7542
- remote: !0
7543
- });
7520
+ this.state = "connecting";
7521
+ let e = !this.forceWebSocket && ao.isBrowserSupported() && this.wtEndpoint !== null && N.webtransport;
7522
+ this.currentType = e ? Tr.WEBTRANSPORT : Tr.WEBSOCKET;
7523
+ let t = e ? this.wtEndpoint : this.endpoint;
7524
+ if (!t) {
7525
+ this._fail("EMPTY_ENDPOINT", "Unable to connect to the signaling: endpoint is not set", !0);
7544
7526
  return;
7545
7527
  }
7546
- let e = this._buildUrl(this.endpoint, !1);
7547
- this.currentType = Tr.WEBSOCKET, this.socket = new WebSocket(e), this._setSocketHandlers();
7548
- }
7549
- _setSocketHandlers() {
7550
- this.socket && (this.handlers.onConnecting({
7528
+ if (this.handlers.onConnecting({
7551
7529
  connectionType: this.connectionType,
7552
7530
  source: this.currentType
7553
- }), this.socket.onopen = this._onOpen.bind(this), this.socket.onmessage = this._onMessage.bind(this), this.socket.onerror = this._onError.bind(this), this.socket.onclose = this._onClose.bind(this), this._startDoctor());
7531
+ }), !this.active) return;
7532
+ let n;
7533
+ try {
7534
+ let r = this._buildUrl(t, e);
7535
+ n = e ? new ao(r, { congestionControl: "low-latency" }, this._debug) : new WebSocket(r);
7536
+ } catch (e) {
7537
+ let t = Object.assign(new Event("error"), { error: e });
7538
+ this.handlers.onError(t), this.active && this._retry();
7539
+ return;
7540
+ }
7541
+ this.socket = n, n.onopen = () => {
7542
+ this.socket !== n || this.state !== "connecting" || (this.state = "awaiting-connection", this._startAttemptTimer(n, N.waitConnectionDelay), this.handlers.onOpen());
7543
+ }, n.onmessage = (e) => {
7544
+ this.socket === n && this.active && this._onMessage(e, n);
7545
+ }, n.onerror = (e) => {
7546
+ this.socket === n && this.active && this.handlers.onError(e);
7547
+ }, n.onclose = (e) => {
7548
+ this.socket === n && this.active && this._retry(e);
7549
+ }, this._startAttemptTimer(n, N.waitMessageDelay);
7554
7550
  }
7555
7551
  _buildUrl(e, t) {
7556
7552
  let n = new URL(e), r = n.searchParams;
7557
7553
  return r.set("platform", N.platform), r.set("appVersion", N.appVersion), r.set("version", String(N.protocolVersion)), r.set("device", N.device), r.set("capabilities", Xa.getFlags()), r.set("clientType", N.clientType), this.connectionType && r.set("tgt", this.connectionType), this.connectionType === Cr.RETRY && this.lastStamp && r.set("recoverTs", String(this.lastStamp)), N.useParticipantListChunk && (r.set("partIdx", String(N.participantListChunkInitIndex)), N.participantListChunkInitCount !== null && r.set("partCount", String(N.participantListChunkInitCount))), t && (r.set("compression", "deflate-raw"), r.set("ua", navigator.userAgent)), this.peerId !== null && r.set("peerId", String(this.peerId)), n.toString();
7558
7554
  }
7559
- _canUseWebTransport() {
7560
- return !this.forceWebSocket && ao.isBrowserSupported() && this.wtEndpoint !== null && N.webtransport;
7561
- }
7562
- _onOpen() {
7563
- this._startDoctor(), this.handlers.onOpen();
7564
- }
7565
- _onMessage(e) {
7566
- this._startDoctor(), this.handlers.onMessage(e);
7555
+ _onMessage(e, t) {
7556
+ if (e.data === "ping") {
7557
+ this.established && this._startPingTimer(), this.handlers.onMessage("ping"), this.canSend && this.send("pong").catch((e) => {
7558
+ this.socket === t && this.active && (this._debug.warn("[signaling] unable to send pong", e), this._retry());
7559
+ });
7560
+ return;
7561
+ }
7562
+ let n;
7563
+ try {
7564
+ if (n = JSON.parse(e.data), typeof n != "object" || !n || Array.isArray(n)) throw Error("Signaling message must be an object");
7565
+ } catch (t) {
7566
+ this.handlers.onParseError(t, e.data);
7567
+ return;
7568
+ }
7569
+ n?.type === "notification" && n.notification === "connection" && (this._updateTimeouts(n.conversationParams?.activityTimeout), this._stopAttemptTimer(), this.state = "established", this.hasEstablished = !0, this.reconnectCount = 0, this.endpoint = n.endpoint, n.peerId && (this.peerId = n.peerId.id), this._stopConnectionDeadlineTimer(), this._startPingTimer());
7570
+ try {
7571
+ this.handlers.onMessage(n);
7572
+ } finally {
7573
+ this.socket === t && this._updateRecoveryStamp(n);
7574
+ }
7567
7575
  }
7568
- _onError(e) {
7569
- this.handlers.onError(e);
7576
+ _updateRecoveryStamp(e) {
7577
+ if (e?.type === "notification" && e.notification === "connection") for (let t of e.recoverMessages ?? []) t.notification === K.ACCEPTED_CALL && t.peerId.id === this.peerId && t.peerId.type === "WEB_TRANSPORT" || this._updateRecoveryStamp(t);
7578
+ e?.stamp && (this.lastStamp = e.stamp);
7570
7579
  }
7571
- _onClose(e) {
7572
- if (this._stopDoctor(), this.handlers.onClose(e), !this.manualClose) {
7573
- if (this.abortSignal?.aborted) {
7574
- this.handlers.onFailed({
7575
- failure: "ABORTED",
7576
- message: "Signaling connection aborted",
7577
- source: this.currentType
7578
- });
7579
- return;
7580
- }
7581
- this.forceWebSocket = !0, this._scheduleReconnect(this.currentType === Tr.WEBTRANSPORT ? 0 : void 0);
7582
- }
7580
+ _onAbort() {
7581
+ this.active && this._fail("ABORTED", "Signaling connection aborted");
7583
7582
  }
7584
- _disconnect(e) {
7585
- this.socket && this.socket.readyState < WebSocket.CLOSING && (this.socket.onopen = null, this.socket.onmessage = null, this.socket.onerror = null, this.socket.onclose = null, this.socket.close(e)), this.socket = null, this._stopDoctor();
7586
- }
7587
- _scheduleReconnect(e = this._getReconnectDelay()) {
7588
- if (this.reconnectCount >= N.signalingReconnectMaxCount) {
7589
- this._stopReconnectDeadline(), this.handlers.onFailed({
7590
- failure: "NETWORK_ERROR",
7591
- message: "Unable to connect to the signaling: reconnect attempts exhausted",
7592
- source: this.currentType
7593
- });
7583
+ _retry(e = new CloseEvent("close", { code: 4e3 }), t = !1) {
7584
+ if (!this.active || (this.state = "waiting-to-retry", this._startConnectionDeadlineTimer(), this._disconnect(4e3), t && this.handlers.onInactive(), this.handlers.onClose(e), !this.active)) return;
7585
+ if (this.abortSignal?.aborted) {
7586
+ this.onAbort();
7594
7587
  return;
7595
7588
  }
7596
- this._startReconnectDeadline(), this.reconnectCount++, this.handlers.onReconnectScheduled({
7589
+ let n = t || this.currentType === Tr.WEBTRANSPORT ? 0 : Math.min(N.signalingReconnectMaxDelay, N.signalingReconnectDelay * 2 ** this.reconnectCount);
7590
+ this.forceWebSocket = !0, this.reconnectCount++, this._startRetryTimer(n), this.handlers.onReconnectScheduled({
7597
7591
  count: this.reconnectCount,
7598
- delay: e
7599
- }), this.reconnectTimer = window.setTimeout(() => {
7600
- this.connectionType = Cr.RETRY, this._connect();
7592
+ delay: n
7593
+ });
7594
+ }
7595
+ _disconnect(e) {
7596
+ this._stopAttemptTimer(), this._stopPingTimer();
7597
+ let t = this.socket;
7598
+ this.socket = null, t && (t.onopen = null, t.onmessage = null, t.onerror = null, t.onclose = null, t.readyState < WebSocket.CLOSING && t.close(e));
7599
+ }
7600
+ _startRetryTimer(e) {
7601
+ this._stopRetryTimer(), this.retryTimer = window.setTimeout(() => {
7602
+ this.retryTimer = 0, this.connectionType = Cr.RETRY, this._connect();
7601
7603
  }, e);
7602
7604
  }
7603
- _startReconnectDeadline() {
7604
- this.reconnectDeadlineTimer || (this.reconnectDeadlineTimer = window.setTimeout(() => {
7605
- this.reconnectDeadlineTimer = 0, window.clearTimeout(this.reconnectTimer), this.reconnectTimer = 0, this._disconnect(4e3), this.handlers.onFailed({
7606
- failure: "RECONNECT_TIMEOUT",
7607
- message: "Unable to connect to the signaling: reconnect timeout",
7608
- source: this.currentType
7609
- });
7610
- }, N.signalingReconnectMaxDuration));
7605
+ _stopRetryTimer() {
7606
+ window.clearTimeout(this.retryTimer), this.retryTimer = 0;
7611
7607
  }
7612
- _stopReconnectDeadline() {
7613
- window.clearTimeout(this.reconnectDeadlineTimer), this.reconnectDeadlineTimer = 0;
7608
+ _startConnectionDeadlineTimer() {
7609
+ this.connectionDeadlineTimer || (this.connectionDeadlineTimer = window.setTimeout(() => {
7610
+ this._fail(this.hasEstablished ? "RECONNECT_TIMEOUT" : "CONNECTION_TIMEOUT", "Unable to connect to the signaling: connection timeout");
7611
+ }, this.hasEstablished ? this.reconnectTimeoutMs : N.signalingReconnectMaxDuration));
7614
7612
  }
7615
- _getReconnectDelay() {
7616
- return Math.min(N.signalingReconnectMaxDelay, N.signalingReconnectDelay * 2 ** this.reconnectCount);
7613
+ _stopConnectionDeadlineTimer() {
7614
+ window.clearTimeout(this.connectionDeadlineTimer), this.connectionDeadlineTimer = 0;
7617
7615
  }
7618
- _startDoctor() {
7619
- this._stopDoctor(), !(this.reconnectCount >= N.signalingReconnectMaxCount) && (this.doctorTimer = window.setTimeout(() => {
7620
- this.handlers.onConnectionDead(), this.forceWebSocket = !0, this._disconnect(4e3), this._scheduleReconnect(0);
7621
- }, N.waitMessageDelay));
7616
+ _startAttemptTimer(e, t) {
7617
+ this._stopAttemptTimer(), this.attemptTimer = window.setTimeout(() => {
7618
+ this.socket === e && this.active && this._retry();
7619
+ }, t);
7622
7620
  }
7623
- _stopDoctor() {
7624
- window.clearTimeout(this.doctorTimer), this.doctorTimer = 0;
7621
+ _stopAttemptTimer() {
7622
+ window.clearTimeout(this.attemptTimer), this.attemptTimer = 0;
7623
+ }
7624
+ _updateTimeouts(e) {
7625
+ typeof e == "number" && Number.isFinite(e) && e > 0 ? (this.pingTimeoutMs = Math.max(Math.min(e / 4, 61e3), 11e3), this.reconnectTimeoutMs = Math.max(e / 2, e - 6e4, 3e4)) : (this.pingTimeoutMs = N.waitMessageDelay, this.reconnectTimeoutMs = N.signalingReconnectMaxDuration);
7626
+ }
7627
+ _startPingTimer() {
7628
+ this._stopPingTimer();
7629
+ let e = this.socket;
7630
+ this.pingTimer = window.setTimeout(() => {
7631
+ this.socket === e && this.established && this._retry(void 0, !0);
7632
+ }, this.pingTimeoutMs);
7633
+ }
7634
+ _stopPingTimer() {
7635
+ window.clearTimeout(this.pingTimer), this.pingTimer = 0;
7636
+ }
7637
+ _fail(e, t, n) {
7638
+ let r = this.currentType;
7639
+ this.close(4e3), this.handlers.onFailed({
7640
+ failure: e,
7641
+ message: t,
7642
+ source: r,
7643
+ ...n === void 0 ? {} : { remote: n }
7644
+ });
7625
7645
  }
7626
7646
  }, co = "open", lo = 300, uo = 10, fo = {
7627
7647
  CONVERSATION_ENDED: "conversation-ended",
@@ -7647,36 +7667,30 @@ var ho = new Set([
7647
7667
  O.NOT_FOUND,
7648
7668
  O.PARTICIPANT_LIMIT_REACHED,
7649
7669
  O.SERVICE_UNAVAILABLE
7650
- ]), go = class e extends jn {
7651
- static get WAIT_CONNECTION_DELAY() {
7652
- return N.waitConnectionDelay;
7653
- }
7670
+ ]), go = class e extends Ye {
7654
7671
  static get WAIT_RESPONSE_DELAY() {
7655
7672
  return N.waitResponseDelay;
7656
7673
  }
7657
7674
  get ready() {
7658
- return !this.disposed && this.transport.readyState !== null;
7675
+ return !this.disposed && this.session.active;
7659
7676
  }
7660
7677
  constructor(e = z, t = null, n = null, r = null, i = null) {
7661
- super(), h(this, "transport", void 0), h(this, "sequence", 1), h(this, "lastStamp", 0), h(this, "websocketCommandsQueue", []), h(this, "datachannelCommandsQueue", []), h(this, "incomingCache", []), h(this, "responseHandlers", {}), h(this, "disposed", !1), h(this, "connectionType", void 0), h(this, "conversationResolve", null), h(this, "conversationReject", null), h(this, "connected", !1), h(this, "listenersReady", !1), h(this, "peerId", null), h(this, "reconnectStartedAt", null), h(this, "connectionMessageWaitTimer", 0), h(this, "participantIdRegistry", null), h(this, "producerNotificationDataChannel", null), h(this, "producerCommandDataChannel", null), h(this, "producerCommandDataChannelEnabled", !1), h(this, "producerCommandSerializationService", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_statPings", void 0), h(this, "_statSignalingCommands", void 0), this._debug = e, this._logger = t, this._statAggregator = n, this._statPings = r, this._statSignalingCommands = i, this.producerCommandSerializationService = new ir(e), this.transport = new so(e, {
7678
+ super(), h(this, "session", void 0), h(this, "sequence", 1), 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, "listenersReady", !1), h(this, "reconnectStartedAt", null), 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 ir(e), this.session = new so(e, {
7662
7679
  onConnecting: this._onTransportConnecting.bind(this),
7663
7680
  onOpen: this._onOpen.bind(this),
7664
7681
  onMessage: this._onMessage.bind(this),
7682
+ onParseError: (e, t) => {
7683
+ this._logger?.log(x.SOCKET_ACTION, "parse_error"), this._debug.error("[signaling] unable to parse message", e, t);
7684
+ },
7665
7685
  onError: this._onError.bind(this),
7666
7686
  onClose: this._onClose.bind(this),
7667
- onFailed: this._onTransportFailed.bind(this),
7668
- onReconnectScheduled: this._onTransportReconnectScheduled.bind(this),
7669
- onConnectionDead: this._onTransportConnectionDead.bind(this)
7687
+ onFailed: this._onSessionFailed.bind(this),
7688
+ onReconnectScheduled: this._onSessionReconnectScheduled.bind(this),
7689
+ onInactive: this._onSessionInactive.bind(this)
7670
7690
  });
7671
7691
  }
7672
7692
  setAbortSignal(e) {
7673
- super.setAbortSignal(e), this.transport.setAbortSignal(e);
7674
- }
7675
- setEndpoint(e) {
7676
- this.transport.setEndpoint(e);
7677
- }
7678
- setWebTransportEndpoint(e) {
7679
- this.transport.setWebTransportEndpoint(e);
7693
+ this.session.setAbortSignal(e);
7680
7694
  }
7681
7695
  setParticipantIdRegistry(e) {
7682
7696
  this.participantIdRegistry = e, this.producerCommandSerializationService.setParticipantIdRegistry(e);
@@ -7700,26 +7714,33 @@ var ho = new Set([
7700
7714
  useCommandDataChannel(e) {
7701
7715
  this.producerCommandDataChannelEnabled = e;
7702
7716
  }
7703
- resetProducerConnection(e = new An()) {
7717
+ resetProducerConnection(e = new jn()) {
7704
7718
  this.producerCommandDataChannelEnabled = !1, this.producerNotificationDataChannel && (this.producerNotificationDataChannel.onmessage = null, this.producerNotificationDataChannel = null), this.producerCommandDataChannel && (this.producerCommandDataChannel.onmessage = null, this.producerCommandDataChannel = null);
7705
7719
  let t = [...this.datachannelCommandsQueue];
7706
7720
  this.datachannelCommandsQueue = [];
7707
7721
  for (let e of Object.values(this.responseHandlers)) e.route === "producer" && (t.push(e), delete this.responseHandlers[e.sequence]);
7708
7722
  t.forEach((t) => {
7709
- window.clearTimeout(t.responseTimer), t.reject(e instanceof An ? new An(t.name) : e, !0);
7723
+ window.clearTimeout(t.responseTimer), t.reject(e instanceof jn ? new jn(t.name) : e, !0);
7710
7724
  });
7711
7725
  }
7712
- async connect(e) {
7713
- return new Promise((t, n) => {
7714
- if (this.transport.readyState !== null && this.transport.readyState < WebSocket.CLOSING) {
7715
- this._logger?.log(x.SOCKET_ACTION, "already_opened"), n(Error("Socket already opened"));
7726
+ async connect(e, t) {
7727
+ return new Promise((n, r) => {
7728
+ if (this.session.active) {
7729
+ this._logger?.log(x.SOCKET_ACTION, "already_opened"), r(Error("Socket already opened"));
7730
+ return;
7731
+ }
7732
+ if (this.disposed) {
7733
+ r(new An());
7716
7734
  return;
7717
7735
  }
7718
7736
  this.conversationResolve = (e) => {
7719
- t(e), this.conversationResolve = null, this.conversationReject = null;
7720
- }, this.conversationReject = (e) => {
7721
7737
  n(e), this.conversationResolve = null, this.conversationReject = null;
7722
- }, this.connectionType = e, this.transport.connect(e);
7738
+ }, this.conversationReject = (e) => {
7739
+ r(e), this.conversationResolve = null, this.conversationReject = null;
7740
+ }, this.connectionType = e, this.reconnectStartedAt = performance.now(), this.session.connect(e, {
7741
+ endpoint: t.endpoint,
7742
+ webTransportEndpoint: t.wt_endpoint ?? null
7743
+ });
7723
7744
  });
7724
7745
  }
7725
7746
  getNextCommandSequenceNumber() {
@@ -7951,7 +7972,7 @@ var ho = new Set([
7951
7972
  async getHandQueue() {
7952
7973
  return this._send(V.GET_HAND_QUEUE);
7953
7974
  }
7954
- dispose(e = new kn()) {
7975
+ dispose(e = new An()) {
7955
7976
  this._terminate(e);
7956
7977
  }
7957
7978
  readyToSend(e = !0) {
@@ -7964,7 +7985,7 @@ var ho = new Set([
7964
7985
  return this._send(V.GET_PARTICIPANTS, { externalIds: e });
7965
7986
  }
7966
7987
  getPeerId() {
7967
- return this.peerId;
7988
+ return this.session.getPeerId();
7968
7989
  }
7969
7990
  async startAsr(e) {
7970
7991
  return this._send(V.ASR_START, e);
@@ -7987,17 +8008,17 @@ var ho = new Set([
7987
8008
  }
7988
8009
  async _sendRaw(e, t = {}, n = !0, r = 0) {
7989
8010
  let i = (t) => {
7990
- if (this.disposed) throw new kn(e);
8011
+ if (this.disposed) throw new An(e);
7991
8012
  switch (t.route) {
7992
8013
  case "producer":
7993
8014
  this.datachannelCommandsQueue.push(t), this.producerCommandDataChannel?.readyState === co && this._handleCommandsQueue(this.datachannelCommandsQueue);
7994
8015
  break;
7995
8016
  case "websocket":
7996
- if (this.transport.readyState === null) {
8017
+ if (!this.session.active) {
7997
8018
  this._logger?.log(x.SOCKET_ACTION, "not_opened"), this._debug.warn("[signaling] socket is not opened"), t.reject(/* @__PURE__ */ Error(`Socket not opened [${e}]`), !0);
7998
8019
  return;
7999
8020
  }
8000
- this.transport.readyState > WebSocket.OPEN && (this._logger?.log(x.SOCKET_ACTION, "invalid_state"), this._debug.warn(`[signaling] socket is not opened, state ${this.transport.readyState}`)), this.websocketCommandsQueue.push(t), this.transport.readyState === WebSocket.OPEN && this._handleCommandsQueue(this.websocketCommandsQueue);
8021
+ this.websocketCommandsQueue.push(t), this.session.canSend && this._handleCommandsQueue(this.websocketCommandsQueue);
8001
8022
  }
8002
8023
  };
8003
8024
  return new Promise((a, o) => {
@@ -8023,30 +8044,34 @@ var ho = new Set([
8023
8044
  return this.producerCommandDataChannelEnabled ? e === V.UPDATE_DISPLAY_LAYOUT || e === V.REPORT_PERF_STAT || e === V.REPORT_SHARING_STAT || e === V.REQUEST_ASR || e === V.ENABLE_VIDEO_SUSPEND || e === V.ENABLE_VIDEO_SUSPEND_SUGGEST || e === V.REPORT_NETWORK_STAT || e === V.CHANGE_SIMULCAST : !1;
8024
8045
  }
8025
8046
  _onOpen() {
8026
- this._debug.debug("[signaling] socket opened"), this._logger?.log(x.SOCKET_ACTION, "opened"), this._waitConnectionMessage(), this._logTransportStatSinceMark(this.connectionType === Cr.RETRY ? Er.RECONNECTED : Er.CONNECTED);
8047
+ this._debug.debug("[signaling] socket opened"), this._logger?.log(x.SOCKET_ACTION, "opened"), this._logTransportStatSinceMark(this.connectionType === Cr.RETRY ? Er.RECONNECTED : Er.CONNECTED);
8027
8048
  }
8028
8049
  _onMessage(e) {
8029
- if (e.data === "ping") {
8030
- this._statPings?.mark(this._getSocketType()), this._markTransportStat(Er.FAILED_PINGS), R.onSignalingMessage(e.data), this.transport.readyState === WebSocket.OPEN && this.transport.send("pong").catch((e) => this._debug.warn("[signaling] unable to send pong", e));
8031
- return;
8032
- }
8033
8050
  try {
8034
- let t = JSON.parse(e.data);
8035
- R.onSignalingMessage(t), this._handleMessage(t);
8036
- } catch (t) {
8037
- this._logger?.log(x.SOCKET_ACTION, "parse_error"), this._debug.error("[signaling] unable to parse message", t, e.data);
8051
+ R.onSignalingMessage(e);
8052
+ } catch (e) {
8053
+ this._debug.error("[signaling] external message hook failed", e);
8038
8054
  }
8055
+ if (e === "ping") {
8056
+ this._statPings?.mark(this._getSocketType()), this._markTransportStat(Er.FAILED_PINGS);
8057
+ return;
8058
+ }
8059
+ this._handleMessage(e);
8039
8060
  }
8040
8061
  _handleMessage(e) {
8041
8062
  switch (e.type) {
8042
8063
  case "notification":
8043
- this._attachNotificationCallError(e), e.notification === "connection" ? (this._debug.debug("[signaling] signaling connected", e), this.connected = !0, this.transport.onConnectionRestored(), this.transport.setEndpoint(e.endpoint), e.peerId && this.peerId !== e.peerId.id && (this.peerId = e.peerId.id, this.transport.setPeerId(e.peerId.id)), this._stopWaitConnectionMessage(), this.conversationResolve ? this.conversationResolve(e) : (this._triggerEvent(wr.RECONNECT, e), e.conversation.topology && this._triggerEvent(wr.NOTIFICATION, {
8044
- type: "notification",
8045
- notification: K.TOPOLOGY_CHANGED,
8046
- topology: e.conversation.topology
8047
- }), this._resolvePendingRecordCommands(e)), this.lastStamp && this._handleCachedMessages(), e.recoverMessages?.forEach((e) => {
8048
- e.notification === K.ACCEPTED_CALL && e.peerId.id === this.peerId && e.peerId.type === "WEB_TRANSPORT" || this._handleMessage(e);
8049
- }), this._handleCommandsQueue(this.websocketCommandsQueue)) : !this.connected || !this.listenersReady ? this.incomingCache.push(e) : this._triggerEvent(wr.NOTIFICATION, e);
8064
+ if (this._attachNotificationCallError(e), e.notification === "connection") {
8065
+ this._debug.debug("[signaling] signaling connected", e);
8066
+ let t = !this.conversationResolve;
8067
+ this.reconnectStartedAt = null, this.conversationResolve ? this.conversationResolve(e) : (this._triggerEvent(wr.RECONNECT, e), e.conversation.topology && this._triggerEvent(wr.NOTIFICATION, {
8068
+ type: "notification",
8069
+ notification: K.TOPOLOGY_CHANGED,
8070
+ topology: e.conversation.topology
8071
+ }), this._resolvePendingRecordCommands(e)), t && this._handleCachedMessages(), e.recoverMessages?.forEach((e) => {
8072
+ e.notification === K.ACCEPTED_CALL && e.peerId.id === this.session.getPeerId() && e.peerId.type === "WEB_TRANSPORT" || this._handleMessage(e);
8073
+ }), this._handleCommandsQueue(this.websocketCommandsQueue);
8074
+ } else !this.session.established || !this.listenersReady ? this.incomingCache.push(e) : this._triggerEvent(wr.NOTIFICATION, e);
8050
8075
  break;
8051
8076
  case "response":
8052
8077
  this._handleCommandResponse(!0, e);
@@ -8056,26 +8081,25 @@ var ho = new Set([
8056
8081
  break;
8057
8082
  default: this._logger?.log(x.SOCKET_ACTION, "unknown_message"), this._debug.warn("[signaling] unhandled message", e);
8058
8083
  }
8059
- e.stamp && (this.lastStamp = e.stamp, this.transport.setLastStamp(e.stamp));
8060
8084
  }
8061
8085
  _handleErrorMessage(e) {
8062
8086
  this._logger?.log(x.SOCKET_ACTION, `error-${e.error}`);
8063
8087
  let t = this._getSocketType(), n = e.error ? this._createSignalingCallError(e.error, e.errorCode, t) : void 0, r = mo(e, "Unknown signaling error");
8064
8088
  switch (this._debug.debug(`[signaling] error message [${e.sequence}]`, e), e.sequence && this.responseHandlers[e.sequence] && this._handleCommandResponse(!1, e), e.error) {
8065
8089
  case fo.SERVICE_UNAVAILABLE:
8066
- let i = new k(O.SERVICE_UNAVAILABLE, {
8090
+ let t = new k(O.SERVICE_UNAVAILABLE, {
8067
8091
  callError: n,
8068
8092
  message: r,
8069
8093
  remote: !0
8070
8094
  });
8071
- this.conversationReject ? this.conversationReject(i) : this._triggerEvent(wr.NOTIFICATION, {
8095
+ this.conversationReject ? this.dispose(t) : this._triggerEvent(wr.NOTIFICATION, {
8072
8096
  notification: K.CLOSED_CONVERSATION,
8073
8097
  callError: n,
8074
8098
  reason: O.SERVICE_UNAVAILABLE
8075
8099
  });
8076
8100
  break;
8077
8101
  case fo.CONVERSATION_ENDED:
8078
- this.conversationReject ? this.conversationReject(new k(e.reason || y.SIGNALING_FAILED, {
8102
+ this.conversationReject ? this.dispose(new k(e.reason || y.SIGNALING_FAILED, {
8079
8103
  callError: n,
8080
8104
  message: r,
8081
8105
  remote: !0
@@ -8094,7 +8118,8 @@ var ho = new Set([
8094
8118
  }));
8095
8119
  break;
8096
8120
  case fo.OBSOLETE_CLIENT:
8097
- this.conversationReject?.(new k(e.reason || O.OBSOLETE_CLIENT, {
8121
+ if (!this.conversationReject) break;
8122
+ this.dispose(new k(e.reason || O.OBSOLETE_CLIENT, {
8098
8123
  callError: n,
8099
8124
  message: r,
8100
8125
  remote: !0
@@ -8102,26 +8127,16 @@ var ho = new Set([
8102
8127
  break;
8103
8128
  case fo.INVALID_TOKEN:
8104
8129
  default:
8105
- if (e.sequence || t === Tr.WEBTRANSPORT) break;
8106
- if (this.connected) this._throwError(new k(e.reason || y.SIGNALING_FAILED, {
8130
+ if (e.sequence) break;
8131
+ let i = new k(e.reason || y.SIGNALING_FAILED, {
8107
8132
  callError: n ?? {
8108
8133
  scope: "unknown",
8109
8134
  description: "signaling-unrecognized-error"
8110
8135
  },
8111
8136
  message: r,
8112
8137
  remote: !0
8113
- }));
8114
- else if (!e.sequence) {
8115
- let t = new k(e.reason || y.SIGNALING_FAILED, {
8116
- callError: n ?? {
8117
- scope: "unknown",
8118
- description: "signaling-unrecognized-error"
8119
- },
8120
- message: r,
8121
- remote: !0
8122
- });
8123
- this.conversationReject?.(t), this.dispose(t);
8124
- }
8138
+ });
8139
+ this.conversationReject ? this.dispose(i) : this._fail(i);
8125
8140
  }
8126
8141
  }
8127
8142
  _handleCachedMessages() {
@@ -8145,18 +8160,18 @@ var ho = new Set([
8145
8160
  this._logger?.log(x.SOCKET_ACTION, "closed"), this._debug.debug("[signaling] connection closed", {
8146
8161
  code: e.code,
8147
8162
  reason: e.reason
8148
- }), this.connected = !1;
8163
+ });
8149
8164
  }
8150
8165
  _terminate(e) {
8151
8166
  if (this.disposed) return !1;
8152
- this.disposed = !0, this.transport.close(), this._stopWaitConnectionMessage();
8167
+ this.disposed = !0, this.session.close();
8153
8168
  let t = [
8154
8169
  ...this.websocketCommandsQueue,
8155
8170
  ...this.datachannelCommandsQueue,
8156
8171
  ...Object.values(this.responseHandlers)
8157
8172
  ], n = this.conversationReject;
8158
- return this.websocketCommandsQueue = [], this.datachannelCommandsQueue = [], this.responseHandlers = {}, this.incomingCache = [], this.conversationResolve = null, this.conversationReject = null, this.connected = !1, this.listenersReady = !1, this.lastStamp = 0, this.producerCommandDataChannelEnabled = !1, this.producerNotificationDataChannel && (this.producerNotificationDataChannel.onmessage = null, this.producerNotificationDataChannel = null), this.producerCommandDataChannel && (this.producerCommandDataChannel.onmessage = null, this.producerCommandDataChannel = null), super.setAbortSignal(void 0), this.transport.setAbortSignal(void 0), t.forEach((t) => {
8159
- window.clearTimeout(t.responseTimer), t.reject(e instanceof kn ? new kn(t.name) : e, !0);
8173
+ return this.websocketCommandsQueue = [], this.datachannelCommandsQueue = [], this.responseHandlers = {}, this.incomingCache = [], this.conversationResolve = null, this.conversationReject = null, this.listenersReady = !1, this.producerCommandDataChannelEnabled = !1, this.producerNotificationDataChannel && (this.producerNotificationDataChannel.onmessage = null, this.producerNotificationDataChannel = null), this.producerCommandDataChannel && (this.producerCommandDataChannel.onmessage = null, this.producerCommandDataChannel = null), t.forEach((t) => {
8174
+ window.clearTimeout(t.responseTimer), t.reject(e instanceof An ? new An(t.name) : e, !0);
8160
8175
  }), n?.(e), !0;
8161
8176
  }
8162
8177
  _fail(e) {
@@ -8194,7 +8209,7 @@ var ho = new Set([
8194
8209
  let r = this.responseHandlers[n.sequence];
8195
8210
  window.clearTimeout(r.responseTimer);
8196
8211
  let i = G.measureMark(r.statMarkName);
8197
- 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(x.SOCKET_ACTION, "response-error"), r.reject(Error(mo(n, `Response error [${r.name}]`)), !0)) : this.transport.readyState === WebSocket.OPEN ? (delete this.responseHandlers[n.sequence], this._logger?.log(x.SOCKET_ACTION, "response-timeout"), r.reject(Error(mo(n, `Response timeout [${r.name}]`)))) : r.responseTimer = window.setTimeout(() => this._handleCommandResponse(t, n), e.WAIT_RESPONSE_DELAY);
8212
+ 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(x.SOCKET_ACTION, "response-error"), r.reject(Error(mo(n, `Response error [${r.name}]`)), !0)) : (r.route === "producer" ? this.session.canSend : this.session.established) ? (delete this.responseHandlers[n.sequence], this._logger?.log(x.SOCKET_ACTION, "response-timeout"), r.reject(Error(mo(n, `Response timeout [${r.name}]`)))) : r.responseTimer = window.setTimeout(() => this._handleCommandResponse(t, n), e.WAIT_RESPONSE_DELAY);
8198
8213
  }
8199
8214
  _handleCommandsQueue(e) {
8200
8215
  for (; e.length > 0;) {
@@ -8208,11 +8223,11 @@ var ho = new Set([
8208
8223
  let e = this._serializeBinary(t);
8209
8224
  e !== null && this.producerCommandDataChannel.send(e);
8210
8225
  } else {
8211
- if (this.transport.readyState !== WebSocket.OPEN) {
8226
+ if (!this.session.canSend) {
8212
8227
  t.reject(/* @__PURE__ */ Error("Invalid state or socket already closed"));
8213
8228
  continue;
8214
8229
  }
8215
- t.needResponse && this._startResponseTimer(t), this.transport.send(this._serializeJson(t)).then(() => {
8230
+ t.needResponse && this._startResponseTimer(t), this.session.send(this._serializeJson(t)).then(() => {
8216
8231
  t.needResponse || this._resolveCommandWithoutResponse(t);
8217
8232
  }, (e) => {
8218
8233
  window.clearTimeout(t.responseTimer), delete this.responseHandlers[t.sequence], t.reject(e, !0);
@@ -8261,32 +8276,14 @@ var ho = new Set([
8261
8276
  for (let e in t) Object.hasOwn(t, e) && (n[e] = Pn(t[e]));
8262
8277
  return { layouts: n };
8263
8278
  }
8264
- _waitConnectionMessage() {
8265
- let t = this._getSocketType();
8266
- this.connectionMessageWaitTimer = window.setTimeout(() => {
8267
- this.conversationReject && this.conversationReject(new k(y.SIGNALING_FAILED, {
8268
- callError: {
8269
- scope: "network",
8270
- source: t,
8271
- code: "timeout",
8272
- description: "connection-timeout"
8273
- },
8274
- message: "Unable to connect to the signaling: connection timeout",
8275
- remote: !0
8276
- }));
8277
- }, e.WAIT_CONNECTION_DELAY);
8278
- }
8279
- _stopWaitConnectionMessage() {
8280
- window.clearTimeout(this.connectionMessageWaitTimer), this.connectionMessageWaitTimer = 0;
8281
- }
8282
8279
  _onTransportConnecting(e) {
8283
8280
  let t = e.connectionType === Cr.RETRY ? Er.RECONNECTED : Er.CONNECTED;
8284
8281
  this._markTransportStat(t, e.source);
8285
8282
  }
8286
- _onTransportFailed(e) {
8283
+ _onSessionFailed(e) {
8287
8284
  switch (e.failure) {
8288
8285
  case oo.EMPTY_ENDPOINT:
8289
- this.conversationReject?.(new k(y.SIGNALING_FAILED, {
8286
+ this.dispose(new k(y.SIGNALING_FAILED, {
8290
8287
  callError: {
8291
8288
  scope: "internal",
8292
8289
  code: "configuration",
@@ -8296,13 +8293,17 @@ var ho = new Set([
8296
8293
  remote: e.remote
8297
8294
  }));
8298
8295
  break;
8299
- case oo.NETWORK_ERROR:
8300
- this._logReconnectTimeout(), this._fail(new k(O.NETWORK_ERROR, { callError: {
8301
- scope: "network",
8302
- source: e.source,
8303
- code: "reconnect-exhausted",
8304
- description: "connection-failed"
8305
- } }));
8296
+ case oo.CONNECTION_TIMEOUT:
8297
+ this._logReconnectTimeout(), this._fail(new k(y.SIGNALING_FAILED, {
8298
+ callError: {
8299
+ scope: "network",
8300
+ source: e.source,
8301
+ code: "timeout",
8302
+ description: "connection-timeout"
8303
+ },
8304
+ message: e.message,
8305
+ remote: !0
8306
+ }));
8306
8307
  break;
8307
8308
  case oo.RECONNECT_TIMEOUT:
8308
8309
  this._logReconnectTimeout(), this._fail(new k(O.NETWORK_ERROR, { callError: {
@@ -8312,18 +8313,21 @@ var ho = new Set([
8312
8313
  description: "connection-failed"
8313
8314
  } }));
8314
8315
  break;
8315
- case oo.ABORTED:
8316
- this._debug.debug("[signaling] aborted reconnect"), this._fail(new k(O.CANCELED));
8316
+ case oo.ABORTED: {
8317
+ this._debug.debug("[signaling] aborted reconnect");
8318
+ let e = new k(O.CANCELED);
8319
+ this.conversationReject ? this.dispose(e) : this._fail(e);
8317
8320
  break;
8321
+ }
8318
8322
  }
8319
8323
  }
8320
- _onTransportReconnectScheduled(e) {
8321
- this.connectionType = Cr.RETRY, this._debug.log(`[signaling] reconnect signaling after ${e.delay}ms (${e.count})`), this._logger?.log(x.SOCKET_ACTION, "reconnect"), e.count === 1 && (this.reconnectStartedAt = performance.now());
8324
+ _onSessionReconnectScheduled(e) {
8325
+ this.connectionType = Cr.RETRY, this._debug.log(`[signaling] reconnect signaling after ${e.delay}ms (${e.count})`), this._logger?.log(x.SOCKET_ACTION, "reconnect"), e.count === 1 && this.reconnectStartedAt === null && (this.reconnectStartedAt = performance.now());
8322
8326
  }
8323
8327
  _logReconnectTimeout() {
8324
8328
  this.reconnectStartedAt !== null && (this._logTransportStat(Er.TIMEOUT, { value: Math.round(performance.now() - this.reconnectStartedAt) }), this.reconnectStartedAt = null);
8325
8329
  }
8326
- _onTransportConnectionDead() {
8330
+ _onSessionInactive() {
8327
8331
  this._debug.warn("[signaling] socket is dead, trying to reconnect"), this._logTransportStatSinceMark(Er.FAILED_PINGS);
8328
8332
  }
8329
8333
  _attachNotificationCallError(e) {
@@ -8344,7 +8348,7 @@ var ho = new Set([
8344
8348
  };
8345
8349
  }
8346
8350
  _getSocketType() {
8347
- return this.transport.type;
8351
+ return this.session.type;
8348
8352
  }
8349
8353
  _markTransportStat(e, t = this._getSocketType()) {
8350
8354
  let n = Dr[e][t];
@@ -8664,7 +8668,7 @@ var Go = class {
8664
8668
  this._fixNoPacketsChecked = !0, this._logger?.log(x.ERROR, `audio_device_recover_${e.bandwidth ? "success" : "fail"}`);
8665
8669
  return;
8666
8670
  }
8667
- !this._fixNoPacketsApplied && !e.bandwidth && e.packetsSent > 0 && (this._fixNoPacketsApplied = !0, this._logger?.log(x.ERROR, "audio_device_recover"), this._debug.log("[AudioFix] Trying to fix RV (no packets)"), this._toggleAudioPromise = this._mediaSource.toggleAudio(E.getMicrophonePermissionState() !== "denied"), this._toggleAudioPromise.catch(() => void 0));
8671
+ !this._fixNoPacketsApplied && !e.bandwidth && e.packetsSent > 0 && (this._fixNoPacketsApplied = !0, this._logger?.log(x.ERROR, "audio_device_recover"), this._debug.log("[AudioFix] Trying to fix RV (no packets)"), this._toggleAudioPromise = this._mediaSource.toggleAudio(D.getMicrophonePermissionState() !== "denied"), this._toggleAudioPromise.catch(() => void 0));
8668
8672
  }
8669
8673
  }
8670
8674
  _fixAudioDeviceTooManyPackets(e) {
@@ -8730,8 +8734,8 @@ var Go = class {
8730
8734
  try {
8731
8735
  if (!this._features.setSinkId) throw Error("Feature \"setSinkId\" is not supported");
8732
8736
  if (!this._audioElement) return;
8733
- let e = E.getSavedOutput();
8734
- e && (await this._audioElement.setSinkId?.(e.deviceId), this._debug.debug("[audio] Output device changed", e));
8737
+ let e = D.getChosenOutput();
8738
+ await this._audioElement.setSinkId?.(e?.deviceId ?? ""), this._debug.debug("[audio] Output device changed", e);
8735
8739
  } catch (e) {
8736
8740
  throw this._logger?.log(x.ERROR, "change_output"), this._debug.error("[audio] Output change failed", e), e;
8737
8741
  }
@@ -8774,7 +8778,7 @@ var Go = class {
8774
8778
  t.onpause = o, t.onstalled = o, t.onerror = o, t.onloadeddata = () => {
8775
8779
  this._statFirstMediaReceived.measure();
8776
8780
  }, this._audioElement = t, a(e);
8777
- let s = E.getChosenOutput();
8781
+ let s = D.getChosenOutput();
8778
8782
  s ? t.setSinkId?.(s.deviceId).then(() => {
8779
8783
  this._debug.debug("[audio] Output device", s);
8780
8784
  }).catch((e) => {
@@ -8975,8 +8979,8 @@ var Xo = 90, Zo = 3, Qo = class extends Ye {
8975
8979
  constructor(e, t) {
8976
8980
  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]);
8977
8981
  try {
8978
- E.retainAudioContext(this);
8979
- let e = E.getAudioContext();
8982
+ D.retainAudioContext(this);
8983
+ let e = D.getAudioContext();
8980
8984
  this._analyser = e.createAnalyser(), this._analyser.fftSize = 1024, this._analyser.smoothingTimeConstant = 0, C.browserName() === "Safari" && (this._gainNode = e.createGain(), this._gainNode.gain.value = 1e-5, this._gainNode.connect(e.destination), this._analyser.connect(this._gainNode)), this._fftBins = new Uint8Array(this._analyser.frequencyBinCount), this._mediaStreamSource = e.createMediaStreamSource(this._stream), this._mediaStreamSource.connect(this._analyser);
8981
8985
  } catch {
8982
8986
  this.destroy();
@@ -9002,7 +9006,7 @@ var Xo = 90, Zo = 3, Qo = class extends Ye {
9002
9006
  };
9003
9007
  }
9004
9008
  destroy() {
9005
- 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), E.releaseAudioContext(this);
9009
+ 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), D.releaseAudioContext(this);
9006
9010
  }
9007
9011
  }, ns = class extends Ye {
9008
9012
  constructor(e) {
@@ -9015,9 +9019,9 @@ var Xo = 90, Zo = 3, Qo = class extends Ye {
9015
9019
  let t = e.getSendAudioTrack();
9016
9020
  t && this.init(t);
9017
9021
  };
9018
- this.subscribe(e, Xt.SOURCE_CHANGED, (t) => {
9022
+ this.subscribe(e, Zt.SOURCE_CHANGED, (t) => {
9019
9023
  t.kind === A.audio && e.mediaSettings.isAudioEnabled && n();
9020
- }), this.subscribe(e, Xt.SOURCE_READY, n), n();
9024
+ }), this.subscribe(e, Zt.SOURCE_READY, n), n();
9021
9025
  }
9022
9026
  init(e) {
9023
9027
  this._stopDetector(), this._detector = new ts("local", e.clone());
@@ -9566,7 +9570,7 @@ var Ls = "sessions", Rs = 5, zs = class e {
9566
9570
  return String(Ds(N.apiBaseUrl) || N.apiEndpoint());
9567
9571
  }
9568
9572
  static _read() {
9569
- let t = ht.get(Ls);
9573
+ let t = T.get(Ls);
9570
9574
  if (!t || typeof t != "object" || Array.isArray(t)) return {};
9571
9575
  let n = {};
9572
9576
  return Object.entries(t).forEach(([t, r]) => {
@@ -9575,10 +9579,10 @@ var Ls = "sessions", Rs = 5, zs = class e {
9575
9579
  }
9576
9580
  static _write(e) {
9577
9581
  if (Object.keys(e).length === 0) {
9578
- ht.remove(Ls);
9582
+ T.remove(Ls);
9579
9583
  return;
9580
9584
  }
9581
- ht.set(Ls, e);
9585
+ T.set(Ls, e);
9582
9586
  }
9583
9587
  static _isValid(e) {
9584
9588
  let t = e;
@@ -9612,18 +9616,6 @@ var Ls = "sessions", Rs = 5, zs = class e {
9612
9616
  this._release(), t !== "missing" && e();
9613
9617
  });
9614
9618
  }
9615
- stop() {
9616
- if (this._status !== "active" && this._status !== "starting") return;
9617
- let e = this._creation === null ? null : this._key;
9618
- if (this._finish(), e === null) {
9619
- this._release();
9620
- return;
9621
- }
9622
- Q.removeTail(e).then(() => this._release());
9623
- }
9624
- abandon() {
9625
- this._status !== "active" && this._status !== "starting" || (this._clearTimer(), this._status = "abandoned", this._release());
9626
- }
9627
9619
  _requestLock() {
9628
9620
  let t = this._key, n = !1;
9629
9621
  if (t !== null) try {
@@ -10067,17 +10059,11 @@ var nc = class extends f {
10067
10059
  return e._pending = [], e._pendingOverflow = !1, t;
10068
10060
  }
10069
10061
  constructor(e, t, n, r = () => void 0) {
10070
- super(), h(this, "_externalLogger", void 0), h(this, "_conversationIdProvider", void 0), h(this, "_topologyProvider", void 0), h(this, "_unloadMode", !1), h(this, "_legacy", void 0), this._externalLogger = t, this._conversationIdProvider = n, this._topologyProvider = r, this._legacy = N.statQueueEnabled ? null : new nc(e, t, n, r);
10062
+ super(), h(this, "_externalLogger", void 0), h(this, "_conversationIdProvider", void 0), h(this, "_topologyProvider", void 0), h(this, "_legacy", void 0), this._externalLogger = t, this._conversationIdProvider = n, this._topologyProvider = r, this._legacy = N.statQueueEnabled ? null : new nc(e, t, n, r);
10071
10063
  }
10072
10064
  log(e, t, n = !1) {
10073
10065
  this._externalLogger && this._externalLogger.log(e, t, n);
10074
10066
  }
10075
- enterUnloadMode() {
10076
- this._legacy || (this._unloadMode = !0);
10077
- }
10078
- exitUnloadMode() {
10079
- this._unloadMode = !1;
10080
- }
10081
10067
  logClientStats(t, n = {}) {
10082
10068
  let r = this._makeEntry(t, n);
10083
10069
  if (R.onClientStats({
@@ -10088,7 +10074,6 @@ var nc = class extends f {
10088
10074
  this._legacy.logClientStats(t, n);
10089
10075
  return;
10090
10076
  }
10091
- if (this._unloadMode) return;
10092
10077
  Ks.ensure();
10093
10078
  let i = v.userId;
10094
10079
  if (i === null) {
@@ -10523,7 +10508,7 @@ var xc = class {
10523
10508
  this._finish({ reason: "terminated" });
10524
10509
  }
10525
10510
  destroy() {
10526
- this._destroyed || (this._tail?.stop(), this._destroyed = !0, this._pendingEvents = []);
10511
+ this._destroyed || (this._destroyed = !0, this._pendingEvents = []);
10527
10512
  }
10528
10513
  _canRecord() {
10529
10514
  return this._callStartLabel !== null && !this._finished && !this._destroyed;
@@ -10898,13 +10883,10 @@ var xc = class {
10898
10883
  }
10899
10884
  }, Mc = class {
10900
10885
  constructor(e, t, n, r, i) {
10901
- h(this, "logger", void 0), h(this, "lifecycle", void 0), h(this, "statAggregator", void 0), h(this, "codecStatsAggregator", void 0), h(this, "pings", void 0), h(this, "signalingCommands", void 0), h(this, "apiCalls", void 0), h(this, "resources", void 0), h(this, "battery", void 0), h(this, "_api", void 0), h(this, "_tail", void 0), h(this, "_unloading", !1), this.logger = new rc(e, t, n, r), this._tail = N.statQueueEnabled && Ws.isSupported() ? new Ws(this.logger, () => this._callSummaries()) : null, this.lifecycle = new xc(this.logger, void 0, this._tail), this.resources = new Cc(i), this.statAggregator = new Tc(this.logger, this.resources), this.codecStatsAggregator = new wc(this.logger, r), this.pings = new Ac(this.logger), this.signalingCommands = new jc(this.logger), this.apiCalls = new ic(this.statAggregator), this._api = e, this._api.setApiCallStats(this.apiCalls), this.battery = new oc(this.logger);
10886
+ h(this, "logger", void 0), h(this, "lifecycle", void 0), h(this, "statAggregator", void 0), h(this, "codecStatsAggregator", void 0), h(this, "pings", void 0), h(this, "signalingCommands", void 0), h(this, "apiCalls", void 0), h(this, "resources", void 0), h(this, "battery", void 0), h(this, "_api", void 0), h(this, "_tail", void 0), this.logger = new rc(e, t, n, r), this._tail = N.statQueueEnabled && Ws.isSupported() ? new Ws(this.logger, () => this._callSummaries()) : null, this.lifecycle = new xc(this.logger, void 0, this._tail), this.resources = new Cc(i), this.statAggregator = new Tc(this.logger, this.resources), this.codecStatsAggregator = new wc(this.logger, r), this.pings = new Ac(this.logger), this.signalingCommands = new jc(this.logger), this.apiCalls = new ic(this.statAggregator), this._api = e, this._api.setApiCallStats(this.apiCalls), this.battery = new oc(this.logger);
10902
10887
  }
10903
- prepareForUnload() {
10904
- N.statQueueEnabled && (this._unloading = !0, this._tail?.abandon(), this.logger.enterUnloadMode(), this.pings.logMetrics(), this.signalingCommands.logMetrics());
10905
- }
10906
- restoreAfterUnload() {
10907
- N.statQueueEnabled && (this._unloading = !1, this.logger.exitUnloadMode());
10888
+ onPageHide() {
10889
+ N.statQueueEnabled || this.destroy();
10908
10890
  }
10909
10891
  resetPingBaseline() {
10910
10892
  this.pings.resetBaseline();
@@ -10916,7 +10898,7 @@ var xc = class {
10916
10898
  this.codecStatsAggregator.destroy(), this.pings.logMetrics(), this.pings.destroy(), this.signalingCommands.logMetrics(), this.signalingCommands.destroy();
10917
10899
  }
10918
10900
  destroy() {
10919
- this._api.setApiCallStats(null), this.lifecycle.markTerminated(), this.lifecycle.destroy(), this.statAggregator.destroy(), this.codecStatsAggregator.destroy(), this.pings.destroy(), this.signalingCommands.destroy(), this.resources.destroy(), this.battery.destroy(), this.logger.destroy(), N.statQueueEnabled && !this._unloading && tc.notifyCallFinished();
10901
+ this._api.setApiCallStats(null), this.lifecycle.markTerminated(), this.lifecycle.destroy(), this.statAggregator.destroy(), this.codecStatsAggregator.destroy(), this.pings.destroy(), this.signalingCommands.destroy(), this.resources.destroy(), this.battery.destroy(), this.logger.destroy(), N.statQueueEnabled && tc.notifyCallFinished();
10920
10902
  }
10921
10903
  _callSummaries() {
10922
10904
  return [
@@ -10991,9 +10973,9 @@ var Lc = 15, $ = class e extends Ye {
10991
10973
  updateDisplayLayout: (e) => this.updateDisplayLayout(e),
10992
10974
  onNonFatalError: (e) => this._onNonFatalError(e)
10993
10975
  }), this._onUnload = () => {
10994
- this._stopFirstMediaSentProbe(), this._stats.resetPingBaseline(), this._conversation && this._api && this._sendHangupApi(this._conversation.id, this._state === "IDLE" ? O.CANCELED : O.HUNGUP), this._stats.prepareForUnload(), this._stats.destroy();
10976
+ this._stopFirstMediaSentProbe(), this._stats.resetPingBaseline(), this._conversation && this._api && this._sendHangupApi(this._conversation.id, this._state === "IDLE" ? O.CANCELED : O.HUNGUP), this._stats.onPageHide();
10995
10977
  }, this._onRestore = () => {
10996
- this._stats.resetPingBaseline(), this._stats.restoreAfterUnload();
10978
+ this._stats.resetPingBaseline();
10997
10979
  }, this._onVisibilityChange = () => {
10998
10980
  document.visibilityState === "hidden" && this._stats.resetPingBaseline();
10999
10981
  }, window.addEventListener("pagehide", this._onUnload), window.addEventListener("pageshow", this._onRestore), document.addEventListener("visibilitychange", this._onVisibilityChange), this._statFirstMediaReceived = new Nc(this._stats.statAggregator), this._audioOutput = new Ko(this._statFirstMediaReceived, N.transparentAudio, this._debug, this._stats.logger), N.videoTracksCount > 0 && (this._cooldownQueueCleanupTimer = window.setInterval(this._cleanupCooldownQueue.bind(this), Pc));
@@ -11309,13 +11291,13 @@ var Lc = 15, $ = class e extends Ye {
11309
11291
  return this._onFastHangup = e?.onFastHangup ?? this._onFastHangup, this._hangupPromise = Promise.resolve().then(async () => {
11310
11292
  let e = [];
11311
11293
  a && e.push(Promise.resolve().then(() => this._signaling.hangup(t)).catch((e) => {
11312
- if (!(e instanceof kn)) throw e;
11294
+ if (!(e instanceof An)) throw e;
11313
11295
  })), i && e.push(this._sendHangup(i, t, this._onFastHangup, o.signal));
11314
11296
  let n = (await this._waitForHangup(Promise.allSettled(e), o)).find((e) => e.status === "rejected");
11315
11297
  if (n?.status === "rejected") throw n.reason;
11316
11298
  }).finally(() => {
11317
11299
  o.abort(), this._signaling.dispose(), B.removeHangup(this._hangupPromise);
11318
- }), B.trackHangup(this, this._hangupPromise), this._hangupReason = n, this._state = "CLOSE", this._participantState = X.HUNGUP, this._resolveSignalingInitialization(!1), this._abortController?.abort(n), this._emitHangupOnce(n, r || null), this._stats.logger.log(x.HANGUP, t), this._finishLifecycle(n), this._stats.flushCallMetrics(), this._cleanupTransport(), this._destroy(void 0, !0), this._hangupPromise;
11300
+ }), B.trackHangup(this, this._hangupPromise), this._hangupReason = n, this._state = "CLOSE", this._participantState = X.HUNGUP, this._resolveSignalingInitialization(!1), a && this._signaling.setAbortSignal(void 0), this._abortController?.abort(n), this._emitHangupOnce(n, r || null), this._stats.logger.log(x.HANGUP, t), this._finishLifecycle(n), this._stats.flushCallMetrics(), this._cleanupTransport(), this._destroy(void 0, !0), this._hangupPromise;
11319
11301
  }
11320
11302
  async _waitForHangup(e, t) {
11321
11303
  let n;
@@ -11661,7 +11643,7 @@ var Lc = 15, $ = class e extends Ye {
11661
11643
  let r = Object.assign({
11662
11644
  id: null,
11663
11645
  externalId: null,
11664
- mediaSettings: D(),
11646
+ mediaSettings: Jt(),
11665
11647
  participantState: {},
11666
11648
  state: X.CALLED,
11667
11649
  connectionStatus: null,
@@ -11798,11 +11780,11 @@ var Lc = 15, $ = class e extends Ye {
11798
11780
  }
11799
11781
  }
11800
11782
  _createMediaSource() {
11801
- let e = new Qt(this._debug, this._stats.logger);
11802
- return this.subscribe(e, Xt.SOURCE_CHANGED, this._onLocalMediaStreamChanged.bind(this)), this.subscribe(e, Xt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._audioFix = new Go(e, this._debug, this._stats.logger), e;
11783
+ let e = new $t(this._debug, this._stats.logger);
11784
+ return this.subscribe(e, Zt.SOURCE_CHANGED, this._onLocalMediaStreamChanged.bind(this)), this.subscribe(e, Zt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._audioFix = new Go(e, this._debug, this._stats.logger), e;
11803
11785
  }
11804
11786
  async _connectSignaling(e, t) {
11805
- this._throwIfClosed(), this._signaling.setEndpoint(t.endpoint), this._signaling.setWebTransportEndpoint(t.wt_endpoint ? t.wt_endpoint : null), this.subscribe(this._signaling, wr.NOTIFICATION, (e) => this._signalingActor.add(e)), this.subscribe(this._signaling, wr.FAILED, this._onSignalingFailed.bind(this)), this.subscribe(this._signaling, wr.RECONNECT, this._onSignalingReconnect.bind(this));
11787
+ this._throwIfClosed(), this.subscribe(this._signaling, wr.NOTIFICATION, (e) => this._signalingActor.add(e)), this.subscribe(this._signaling, wr.FAILED, this._onSignalingFailed.bind(this)), this.subscribe(this._signaling, wr.RECONNECT, this._onSignalingReconnect.bind(this));
11806
11788
  let n = await this._signaling.connect(e, t);
11807
11789
  return this._throwIfClosed(), this._stats.statAggregator.logEventualStatSinceMark({ name: U.SIGNALING_CONNECTED }), n;
11808
11790
  }
@@ -11842,7 +11824,7 @@ var Lc = 15, $ = class e extends Ye {
11842
11824
  return this._createParticipant({
11843
11825
  id: n,
11844
11826
  externalId: Z.fromSignalingParticipant(e, !0, !0),
11845
- mediaSettings: D(e.mediaSettings),
11827
+ mediaSettings: Jt(e.mediaSettings),
11846
11828
  participantState: M.mapParticipantState(e),
11847
11829
  state: e.state,
11848
11830
  roles: e.roles || [],
@@ -11880,7 +11862,7 @@ var Lc = 15, $ = class e extends Ye {
11880
11862
  this._registerParticipant({
11881
11863
  id: e,
11882
11864
  externalId: Z.fromSignalingParticipant(n, !0, !0),
11883
- mediaSettings: D(n.mediaSettings),
11865
+ mediaSettings: Jt(n.mediaSettings),
11884
11866
  participantState: M.mapParticipantState(n),
11885
11867
  state: n.state,
11886
11868
  roles: n.roles || [],
@@ -12035,8 +12017,8 @@ var Lc = 15, $ = class e extends Ye {
12035
12017
  this._transport && this._volumesDetector && (this._specListener = new us(this._transport, this._volumesDetector, this._participants, this._debug, this._stats.logger));
12036
12018
  }
12037
12019
  _logDevices() {
12038
- let e = E.getCameras().length, t = E.getMicrophones().length;
12039
- this._debug.debug("Cameras: " + e + (E.hasCameraPermission() ? "✔" : "✖") + ", Microphones: " + t + (E.hasMicrophonePermission() ? "✔" : "✖")), this._debug.debug("Devices", E.getDevices()), this._stats.logger.log(x.DEVICES, `${e}_${t}`);
12020
+ let e = D.getCameras().length, t = D.getMicrophones().length;
12021
+ this._debug.debug("Cameras: " + e + (D.hasCameraPermission() ? "✔" : "✖") + ", Microphones: " + t + (D.hasMicrophonePermission() ? "✔" : "✖")), this._debug.debug("Devices", D.getDevices()), this._stats.logger.log(x.DEVICES, `${e}_${t}`);
12040
12022
  }
12041
12023
  _logWithMediaSettings(e, t) {
12042
12024
  this._stats.logger.log(e, [t?.isAudioEnabled && "audio", t?.isVideoEnabled && "video"].filter(Boolean).join("_"));
@@ -12099,7 +12081,7 @@ var Lc = 15, $ = class e extends Ye {
12099
12081
  return;
12100
12082
  }
12101
12083
  e.catch((e) => {
12102
- e instanceof kn || this._debug.warn("[signaling] unable to send hangup", e);
12084
+ e instanceof An || this._debug.warn("[signaling] unable to send hangup", e);
12103
12085
  }).finally(() => this._signaling.dispose());
12104
12086
  }
12105
12087
  _onAddParticipant(e, t, n) {
@@ -12116,7 +12098,7 @@ var Lc = 15, $ = class e extends Ye {
12116
12098
  this._registerParticipant({
12117
12099
  id: e,
12118
12100
  externalId: Z.fromSignalingParticipant(t, !0, !0),
12119
- mediaSettings: D(t.mediaSettings),
12101
+ mediaSettings: Jt(t.mediaSettings),
12120
12102
  state: t.state,
12121
12103
  roles: t.roles || [],
12122
12104
  connectionStatus: this._buildConnectionStatus(e, t.sessionState, this._transport?.getState(), t.onHold),
@@ -12225,12 +12207,11 @@ var Lc = 15, $ = class e extends Ye {
12225
12207
  this._waitingHallHoldPending = !1, await this._resumeLocalMedia(t, this._getWaitingForPromotionStatus()), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener();
12226
12208
  return;
12227
12209
  }
12228
- let n = Ja.get();
12229
- await this._signaling.hold(!1, n), this._throwIfClosed(), this._restoreStateAfterHold();
12230
- let r = null;
12231
- if (this._state === "IDLE" && this._participantState === X.ACCEPTED && (r = Object.values(this._participants), r.some((e) => e.state === X.ACCEPTED) && (this._state = "ACTIVE", this._changeFeatureSet())), await this._resumeLocalMedia(t, P.WAITING), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), this._state === "ACTIVE") {
12210
+ await this._signaling.hold(!1), this._throwIfClosed(), this._restoreStateAfterHold();
12211
+ let n = null;
12212
+ if (this._state === "IDLE" && this._participantState === X.ACCEPTED && (n = Object.values(this._participants), n.some((e) => e.state === X.ACCEPTED) && (this._state = "ACTIVE", this._changeFeatureSet())), await this._resumeLocalMedia(t, P.WAITING), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), this._state === "ACTIVE") {
12232
12213
  let e = this._conversation?.direction === _o.OUTGOING && !this._conversation.concurrent;
12233
- this._openTransport(r ?? Object.values(this._participants), e);
12214
+ this._openTransport(n ?? Object.values(this._participants), e);
12234
12215
  }
12235
12216
  }
12236
12217
  async _holdLocally() {
@@ -12814,7 +12795,7 @@ var Lc = 15, $ = class e extends Ye {
12814
12795
  let a = this._transport?.getState();
12815
12796
  return n.participants.forEach((e) => {
12816
12797
  let t = M.composeId(e), n = r[t];
12817
- this._updateParticipantExternalId(n, Z.fromSignalingParticipant(e, !0, !0)), this._setSessionState(n, this._remoteParticipantSessionState(t, e.sessionState)), n.isOnHold || this._setTransportStatus(n, jo.fromTransportState(a) ?? P.WAITING), n.movieShareInfos = e.movieShareInfos, Object.assign(n.mediaSettings, D(e.mediaSettings)), Object.assign(n.muteStates, e.muteStates), n.unmuteOptions = e.unmuteOptions ?? n.unmuteOptions, this._openTransport([n], !0);
12798
+ this._updateParticipantExternalId(n, Z.fromSignalingParticipant(e, !0, !0)), this._setSessionState(n, this._remoteParticipantSessionState(t, e.sessionState)), n.isOnHold || this._setTransportStatus(n, jo.fromTransportState(a) ?? P.WAITING), n.movieShareInfos = e.movieShareInfos, Object.assign(n.mediaSettings, Jt(e.mediaSettings)), Object.assign(n.muteStates, e.muteStates), n.unmuteOptions = e.unmuteOptions ?? n.unmuteOptions, this._openTransport([n], !0);
12818
12799
  }), this._participantListChunkToExternalChunk(n);
12819
12800
  }
12820
12801
  async _getInitialParticiapntListChunk() {
@@ -12970,7 +12951,7 @@ var Lc = 15, $ = class e extends Ye {
12970
12951
  let a = this._getParticipant(e);
12971
12952
  if (a) {
12972
12953
  this._updateParticipantSessionState(a, e, n.sessionState);
12973
- let t = D(n.mediaSettings);
12954
+ let t = Jt(n.mediaSettings);
12974
12955
  qt(t, a.mediaSettings) || this._changeRemoteMediaSettings(e, t);
12975
12956
  let r = M.mapParticipantState(n), o = a.participantState;
12976
12957
  if (!M.isEqualParticipantState(r, o) && (await this._changeRemoteParticipantState(e, r), !this._conversation)) return;
@@ -13009,13 +12990,13 @@ var Lc = 15, $ = class e extends Ye {
13009
12990
  r = this._registerParticipantInCache(this._createParticipant({
13010
12991
  id: t,
13011
12992
  externalId: e.externalId ? Z.fromSignaling(e.externalId, e.deviceIdx) : void 0,
13012
- mediaSettings: D(e.mediaSettings)
12993
+ mediaSettings: Jt(e.mediaSettings)
13013
12994
  }, n));
13014
12995
  } else if (e.externalId) {
13015
12996
  let t = Z.fromSignaling(e.externalId, e.deviceIdx);
13016
12997
  r.externalId = t, this._api.cacheExternalId(r.id, t);
13017
12998
  }
13018
- r.state = X.ACCEPTED, r.mediaSettings = D(e.mediaSettings), this._logWithMediaSettings(x.ACCEPTED_OUTGOING, r.mediaSettings), this._conversation && this._conversation.direction === _o.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);
12999
+ r.state = X.ACCEPTED, r.mediaSettings = Jt(e.mediaSettings), this._logWithMediaSettings(x.ACCEPTED_OUTGOING, r.mediaSettings), this._conversation && this._conversation.direction === _o.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);
13019
13000
  let i = Object.keys(r.muteStates);
13020
13001
  if (i.length && this._onMuteParticipant({
13021
13002
  muteStates: r.muteStates,
@@ -13100,7 +13081,7 @@ var Lc = 15, $ = class e extends Ye {
13100
13081
  this._registerParticipant({
13101
13082
  id: t,
13102
13083
  externalId: Z.fromSignalingParticipant(r, !0, !0),
13103
- mediaSettings: D(r.mediaSettings),
13084
+ mediaSettings: Jt(r.mediaSettings),
13104
13085
  state: r.state,
13105
13086
  participantState: M.mapParticipantState(r),
13106
13087
  roles: r.roles || [],
@@ -13111,7 +13092,7 @@ var Lc = 15, $ = class e extends Ye {
13111
13092
  observedIds: r.observedIds || []
13112
13093
  }, i), n = this._getParticipant(t);
13113
13094
  }
13114
- n.state = X.CALLED, n.mediaSettings = D(e.participant?.mediaSettings), n.participantState = M.mapParticipantState(e.participant), n.roles = e.participant?.roles || [], this._updateParticipantSessionState(n, t, e.participant.sessionState), this._setParticipantsStatus([n], P.WAITING), r && this._emitParticipantEffectiveStatusIfSessionOverridesTransport(n), this._state !== "IDLE" && this._transport && this._allocateParticipantTransport(n.id, !0), R.onParticipantAdded(n.externalId, n.markers, this.id), this._changeRemoteMediaSettings(t, n.mediaSettings), await this._changeRemoteParticipantState(t, n.participantState), this._invokeRolesChangedCallbackIfNeeded(n);
13095
+ n.state = X.CALLED, n.mediaSettings = Jt(e.participant?.mediaSettings), n.participantState = M.mapParticipantState(e.participant), n.roles = e.participant?.roles || [], this._updateParticipantSessionState(n, t, e.participant.sessionState), this._setParticipantsStatus([n], P.WAITING), r && this._emitParticipantEffectiveStatusIfSessionOverridesTransport(n), this._state !== "IDLE" && this._transport && this._allocateParticipantTransport(n.id, !0), R.onParticipantAdded(n.externalId, n.markers, this.id), this._changeRemoteMediaSettings(t, n.mediaSettings), await this._changeRemoteParticipantState(t, n.participantState), this._invokeRolesChangedCallbackIfNeeded(n);
13115
13096
  }
13116
13097
  async _onJoinedParticipant(e) {
13117
13098
  this._debug.debug(`Participant joined [${e.participantId}]`), this._statFirstMediaReceived.markOnJoin(this._transport?.getTopology());
@@ -13127,7 +13108,7 @@ var Lc = 15, $ = class e extends Ye {
13127
13108
  this._registerParticipant({
13128
13109
  id: t,
13129
13110
  externalId: Z.fromSignalingParticipant(r, !0, !0),
13130
- mediaSettings: D(r.mediaSettings),
13111
+ mediaSettings: Jt(r.mediaSettings),
13131
13112
  state: r.state,
13132
13113
  participantState: M.mapParticipantState(r),
13133
13114
  roles: r.roles || [],
@@ -13140,7 +13121,7 @@ var Lc = 15, $ = class e extends Ye {
13140
13121
  isOnHold: !!r.onHold
13141
13122
  }, i), n = this._getParticipant(t);
13142
13123
  }
13143
- this._conversation && this._conversation.direction === _o.OUTGOING && (this._state === "IDLE" || this._state === "PROCESSING") && (this._state = "ACTIVE", this._changeFeatureSet()), n.state = X.ACCEPTED, n.mediaSettings = D(e.mediaSettings), n.participantState = M.mapParticipantState(e.participant), n.roles = e.participant.roles || [], this._updateParticipantSessionState(n, t, e.participant.sessionState), e.participant.onHold ? (n.isOnHold = !0, this._setParticipantsStatus([n], P.ONHOLD)) : this._transport?.isAllocated(n.id) ? this._setParticipantsStatus([n], P.CONNECTED) : this._setParticipantsStatus([n], P.WAITING), r && this._emitParticipantEffectiveStatusIfSessionOverridesTransport(n), this._state !== "IDLE" && this._transport && (this._transport.isAllocated(n.id) || this._allocateParticipantTransport(n.id, !0), this._transport.open([n.id], null, !!this._conversation?.observer)), R.onParticipantJoined(n.externalId, n.markers, this.id), this._changeRemoteMediaSettings(t, n.mediaSettings), await this._changeRemoteParticipantState(t, n.participantState), this._invokeRolesChangedCallbackIfNeeded(n);
13124
+ this._conversation && this._conversation.direction === _o.OUTGOING && (this._state === "IDLE" || this._state === "PROCESSING") && (this._state = "ACTIVE", this._changeFeatureSet()), n.state = X.ACCEPTED, n.mediaSettings = Jt(e.mediaSettings), n.participantState = M.mapParticipantState(e.participant), n.roles = e.participant.roles || [], this._updateParticipantSessionState(n, t, e.participant.sessionState), e.participant.onHold ? (n.isOnHold = !0, this._setParticipantsStatus([n], P.ONHOLD)) : this._transport?.isAllocated(n.id) ? this._setParticipantsStatus([n], P.CONNECTED) : this._setParticipantsStatus([n], P.WAITING), r && this._emitParticipantEffectiveStatusIfSessionOverridesTransport(n), this._state !== "IDLE" && this._transport && (this._transport.isAllocated(n.id) || this._allocateParticipantTransport(n.id, !0), this._transport.open([n.id], null, !!this._conversation?.observer)), R.onParticipantJoined(n.externalId, n.markers, this.id), this._changeRemoteMediaSettings(t, n.mediaSettings), await this._changeRemoteParticipantState(t, n.participantState), this._invokeRolesChangedCallbackIfNeeded(n);
13144
13125
  let i = Object.keys(n.muteStates);
13145
13126
  i.length && this._onMuteParticipant({
13146
13127
  muteStates: n.muteStates,
@@ -13157,7 +13138,7 @@ var Lc = 15, $ = class e extends Ye {
13157
13138
  }
13158
13139
  _onMediaSettingsChanged(e) {
13159
13140
  let t = M.composeMessageId(e);
13160
- this._registerParticipantAndSetMarkersIfChunkEnabled(t, e.markers), this._changeRemoteMediaSettings(t, D(e.mediaSettings));
13141
+ this._registerParticipantAndSetMarkersIfChunkEnabled(t, e.markers), this._changeRemoteMediaSettings(t, Jt(e.mediaSettings));
13161
13142
  }
13162
13143
  async _onParticipantStateChanged(e) {
13163
13144
  let t = M.composeMessageId(e), n = M.mapParticipantState(e);
@@ -13186,7 +13167,7 @@ var Lc = 15, $ = class e extends Ye {
13186
13167
  }
13187
13168
  async _onForceMediaSettingsChange(e) {
13188
13169
  if (!this._mediaSource || this._state === "HELD") return;
13189
- let t = this._mediaSource.mediaSettings, n = D(e.mediaSettings);
13170
+ let t = this._mediaSource.mediaSettings, n = Jt(e.mediaSettings);
13190
13171
  t.isAudioEnabled !== n.isAudioEnabled && await this._mediaSource.toggleAudio(n.isAudioEnabled), t.isVideoEnabled !== n.isVideoEnabled && await this._mediaSource.toggleVideo(n.isVideoEnabled), t.isScreenSharingEnabled !== n.isScreenSharingEnabled && await this._mediaSource.toggleScreenCapturing({
13191
13172
  captureScreen: n.isScreenSharingEnabled,
13192
13173
  fastScreenSharing: n.isFastScreenSharingEnabled,
@@ -13536,7 +13517,7 @@ var Lc = 15, $ = class e extends Ye {
13536
13517
  a.length && (this._updateDisplayLayoutFromCache(i), this._setParticipantsStatus(a, n));
13537
13518
  }
13538
13519
  async _onTransportLocalStateChanged(e) {
13539
- if (this._debug.debug(`Local transport state has changed: ${e}`), e === q.CONNECTED && (E.releaseFirefoxMicrophonePermissionWarmup(), R.onLocalStatus(P.CONNECTED, this.id), this._transport?.getTopology() === J.SERVER)) {
13520
+ if (this._debug.debug(`Local transport state has changed: ${e}`), e === q.CONNECTED && (D.releaseFirefoxMicrophonePermissionWarmup(), R.onLocalStatus(P.CONNECTED, this.id), this._transport?.getTopology() === J.SERVER)) {
13540
13521
  let e = Object.values(this._myLastRequestedLayouts);
13541
13522
  await this.updateDisplayLayout(e), this._displayLayoutRequester.resend();
13542
13523
  }
@@ -13631,10 +13612,10 @@ var Lc = 15, $ = class e extends Ye {
13631
13612
  this._debugInfo && this._debugInfo.onRemoteDataStats(e, this._participants), this._fixAudioDevice(e.outbound.rtps), this._fixVideoDevice(e.outbound.rtps);
13632
13613
  }
13633
13614
  _fixAudioDevice(e) {
13634
- !E.hasMicrophone() || !this._audioFix || !this.mediaSettings?.isAudioEnabled || this._audioFix.fix(e);
13615
+ !D.hasMicrophone() || !this._audioFix || !this.mediaSettings?.isAudioEnabled || this._audioFix.fix(e);
13635
13616
  }
13636
13617
  _fixVideoDevice(e) {
13637
- !E.hasCamera() || !this._audioFix || !this.mediaSettings?.isVideoEnabled || this._audioFix.fixVideo(e);
13618
+ !D.hasCamera() || !this._audioFix || !this.mediaSettings?.isVideoEnabled || this._audioFix.fixVideo(e);
13638
13619
  }
13639
13620
  _toggleJoinAvailability() {
13640
13621
  let e = this._conversation && this._conversation.chatId, t = e && this._state !== "CLOSE" || !1;
@@ -13737,7 +13718,7 @@ var Lc = 15, $ = class e extends Ye {
13737
13718
  return this._createParticipant({
13738
13719
  id: r,
13739
13720
  externalId: Z.fromSignalingParticipant(e, !0, !0),
13740
- mediaSettings: D(e.mediaSettings),
13721
+ mediaSettings: Jt(e.mediaSettings),
13741
13722
  participantState: M.mapParticipantState(e),
13742
13723
  state: e.state,
13743
13724
  roles: e.roles || [],
@@ -14101,8 +14082,8 @@ var Jc = class extends zc {
14101
14082
  _getCachedAnonymLogin() {
14102
14083
  let e = this._getAnonymLoginCacheKey();
14103
14084
  if (!e) return null;
14104
- let t = ht.get(e);
14105
- return Qc(t) ? t : (t && ht.remove(e), null);
14085
+ let t = T.get(e);
14086
+ return Qc(t) ? t : (t && T.remove(e), null);
14106
14087
  }
14107
14088
  _setCachedAnonymLogin(e) {
14108
14089
  let t = this._getAnonymLoginCacheKey();
@@ -14113,11 +14094,11 @@ var Jc = class extends zc {
14113
14094
  uid: e.uid,
14114
14095
  external_user_id: Zc(e)
14115
14096
  };
14116
- ht.set(t, n);
14097
+ T.set(t, n);
14117
14098
  }
14118
14099
  _removeCachedAnonymLogin() {
14119
14100
  let e = this._getAnonymLoginCacheKey();
14120
- e && ht.remove(e);
14101
+ e && T.remove(e);
14121
14102
  }
14122
14103
  _reauthorize() {
14123
14104
  return this._removeCachedAnonymLogin(), v.reauthorize(() => this.authorize());
@@ -14241,8 +14222,8 @@ var Jc = class extends zc {
14241
14222
  }
14242
14223
  _ensureUuid() {
14243
14224
  if (!this._uuid) {
14244
- let e = ht.get("uuid");
14245
- e || (e = M.uuid(), ht.set("uuid", e)), this._uuid = String(e);
14225
+ let e = T.get("uuid");
14226
+ e || (e = M.uuid(), T.set("uuid", e)), this._uuid = String(e);
14246
14227
  }
14247
14228
  }
14248
14229
  deviceId() {
@@ -14401,22 +14382,25 @@ var $c = /* @__PURE__ */ function(e) {
14401
14382
  t?.peerId && (n.peerId = t.peerId), await js("vchat.hangupConversation", n, !0, await Os(this._baseApiUrl, this._apiEnv));
14402
14383
  }
14403
14384
  }, rl, il = null, al = !1, ol = {
14404
- getCameras: E.getCameras,
14405
- getMicrophones: E.getMicrophones,
14406
- getOutput: E.getOutput,
14407
- getVideoFacingMode: E.getVideoFacingMode,
14408
- hasCamera: E.hasCamera,
14409
- hasMicrophone: E.hasMicrophone,
14410
- getSavedCamera: E.getSavedCamera,
14411
- getSavedMicrophone: E.getSavedMicrophone,
14412
- getSavedOutput: E.getSavedOutput,
14413
- hasCameraPermission: E.hasCameraPermission,
14414
- hasMicrophonePermission: E.hasMicrophonePermission,
14415
- hasPermissions: E.hasPermissions,
14416
- getUserMedia: E.getUserMedia,
14417
- getUserVideo: E.getUserVideo,
14418
- getUserAudio: E.getUserAudio,
14419
- setResolution: E.setResolution,
14385
+ getCameras: D.getCameras,
14386
+ getMicrophones: D.getMicrophones,
14387
+ getOutput: D.getOutput,
14388
+ getVideoFacingMode: D.getVideoFacingMode,
14389
+ hasCamera: D.hasCamera,
14390
+ hasMicrophone: D.hasMicrophone,
14391
+ getSavedCamera: D.getSavedCamera,
14392
+ getSavedMicrophone: D.getSavedMicrophone,
14393
+ getSavedOutput: D.getSavedOutput,
14394
+ getCameraSelection: D.getCameraSelection,
14395
+ getMicrophoneSelection: D.getMicrophoneSelection,
14396
+ getOutputSelection: D.getOutputSelection,
14397
+ hasCameraPermission: D.hasCameraPermission,
14398
+ hasMicrophonePermission: D.hasMicrophonePermission,
14399
+ hasPermissions: D.hasPermissions,
14400
+ getUserMedia: D.getUserMedia,
14401
+ getUserVideo: D.getUserVideo,
14402
+ getUserAudio: D.getUserAudio,
14403
+ setResolution: D.setResolution,
14420
14404
  isBrowserSupported: C.isBrowserSupported,
14421
14405
  isScreenCapturingSupported: C.isScreenCapturingSupported,
14422
14406
  canSelectAudioInput: C.canSelectAudioInput,
@@ -14426,7 +14410,7 @@ var $c = /* @__PURE__ */ function(e) {
14426
14410
  browserName: C.browserName,
14427
14411
  browserVersion: C.browserVersion,
14428
14412
  baseChromeVersion: C.baseChromeVersion,
14429
- getAudioContext: E.getAudioContext,
14413
+ getAudioContext: D.getAudioContext,
14430
14414
  isAudioShareSupported: C.isAudioShareSupported
14431
14415
  }, sl = { participantMarkerCompare: M.participantMarkerCompare };
14432
14416
  function cl(e) {
@@ -14448,14 +14432,14 @@ function fl(e, t = null, n = {}, r = 1) {
14448
14432
  }, t && e.setSDK(t);
14449
14433
  }
14450
14434
  async function pl(t) {
14451
- N.set(t), rl || (rl = new Jc()), N.statQueueEnabled && (Ks.setApi(rl), N.autoStartStats && bl()), e.disableLog(!N.debug), z.toggle(N.debug), z.log(`Calls SDK ${N.sdkVersion}`, t), await E.init();
14435
+ N.set(t), rl || (rl = new Jc()), N.statQueueEnabled && (Ks.setApi(rl), N.autoStartStats && bl()), e.disableLog(!N.debug), z.toggle(N.debug), z.log(`Calls SDK ${N.sdkVersion}`, t), await D.init();
14452
14436
  let n = C.getBrowserSupportFailure();
14453
14437
  if (n) throw new k(y.UNSUPPORTED, { callError: {
14454
14438
  scope: "internal",
14455
14439
  code: "environment",
14456
14440
  description: n
14457
14441
  } });
14458
- z.log("UserAgent:", navigator.userAgent), z.log("Screen resolution:", `${window.screen.width}x${window.screen.height}`), z.log("Permissions:", `Camera: ${E.hasCameraPermission()}, Mic: ${E.hasMicrophonePermission()}`), z.log("Simulcast:", `${t.simulcast} => ${N.simulcast}`);
14442
+ z.log("UserAgent:", navigator.userAgent), z.log("Screen resolution:", `${window.screen.width}x${window.screen.height}`), z.log("Permissions:", `Camera: ${D.hasCameraPermission()}, Mic: ${D.hasMicrophonePermission()}`), z.log("Simulcast:", `${t.simulcast} => ${N.simulcast}`);
14459
14443
  }
14460
14444
  async function ml(e, t = [b.AUDIO], n = "", r = !1, i = !1, a, o, s) {
14461
14445
  let c = [];
@@ -14567,7 +14551,7 @@ async function jl(e, t = !1) {
14567
14551
  async function Ml(e, t) {
14568
14552
  let n = $.current();
14569
14553
  if (e === "videoinput" && It.contains(t)) return N.videoFacingMode = t, n ? (C.isMobile() && n.stopVideoTrack(), n.changeDevice(e)) : void 0;
14570
- if (!await E._saveDeviceId(e, t)) throw Error(`Device not found: ${t}`);
14554
+ if (!await D._saveDeviceId(e, t)) throw Error(`Device not found: ${t}`);
14571
14555
  if (n) return n.changeDevice(e);
14572
14556
  }
14573
14557
  async function Nl(e, t) {
@@ -14849,8 +14833,8 @@ function Ou() {
14849
14833
  [`Calls SDK ${N.sdkVersion}`, N.toJSON()],
14850
14834
  ["UserAgent:", navigator.userAgent],
14851
14835
  ["Screen resolution:", `${window.screen.width}x${window.screen.height}`],
14852
- ["Permissions:", `Camera: ${E.hasCameraPermission()}, Mic: ${E.hasMicrophonePermission()}`],
14853
- ["Devices:", E.getDevices()]
14836
+ ["Permissions:", `Camera: ${D.hasCameraPermission()}, Mic: ${D.hasMicrophonePermission()}`],
14837
+ ["Devices:", D.getDevices()]
14854
14838
  ], t = /* @__PURE__ */ new Date(), n = t.getTime(), r = t.toLocaleString("ru-RU", {
14855
14839
  dateStyle: "short",
14856
14840
  timeStyle: "long"
@@ -14858,7 +14842,7 @@ function Ou() {
14858
14842
  return e.map((e) => ({
14859
14843
  h: r,
14860
14844
  t: n,
14861
- l: Dn.LOG,
14845
+ l: On.LOG,
14862
14846
  d: e
14863
14847
  }));
14864
14848
  }
@@ -14995,6 +14979,6 @@ function rd() {
14995
14979
  function id() {
14996
14980
  return N.sdkVersion;
14997
14981
  }
14998
- typeof window < "u" && (window.__CALLS_SDK = wn);
14982
+ typeof window < "u" && (window.__CALLS_SDK = Tn);
14999
14983
  //#endregion
15000
- export { Jc as Api, nl as ApiExternal, tl as ArrayDequeue, v as AuthData, f as BaseLogger, _o as CallDirection, vo as CallType, yo as ChatRoomEventType, bo as ConversationFeature, xo as ConversationOption, Dn as DebugMessageType, Mo as ExternalIdType, It as FacingMode, y as FatalError, k as HangupReason, O as HangupType, b as MediaOption, A as MediaTrackKind, H as MediaType, wo as MuteState, X as ParticipantState, el as ParticipantStateDataValue, P as ParticipantStatus, $c as RecordRole, To as RoomsEventType, go as Signaling, V as SignalingCommandType, Cr as SignalingConnectionType, K as SignalingNotification, U as Stat, J as TransportTopology, Oo as UserRole, j as UserType, ts as VolumeDetector, Sl as acceptCall, zu as acceptPromotion, bu as activateRooms, gu as addMovie, Ol as addParticipant, kl as addParticipantInternal, xl as authorize, ol as browser, gl as callInternal, ml as callTo, Nl as captureScreen, Pl as captureVmoji, ju as changeAudioEffect, $l as changeConversationOptions, Ml as changeDevice, Bl as changeParticipantState, zl as changePriorities, Au as changeVideoEffect, nu as chatHistory, eu as chatMessage, tu as chatMessageInternal, su as createJoinLink, ru as customData, iu as customDataInternal, wu as debug, Du as debugLogs, Tu as debugMessage, Eu as debugMessageWithContext, Cl as declineCall, Uu as enableFeatureForRoles, Zl as enableVideoSuspend, Ql as enableVideoSuspendSuggest, Hu as feedback, du as forceRelayPolicy, nd as getActiveCallId, lu as getAnonymTokenByLink, Iu as getAudienceModeHands, yl as getInbounds, Bu as getParticipantListChunk, Vu as getParticipants, hu as getStreamInfo, rd as getSyncedTime, Fu as getWaitingHall, Wl as grantRoles, Gl as grantRolesInternal, Dl as hangup, pl as init, wl as joinCall, El as joinCallByLink, Tl as joinCallInternal, Kl as muteParticipant, ql as muteParticipantInternal, Jl as pinParticipant, Yl as pinParticipantInternal, _l as processPush, vl as processPushInternal, Lu as promoteParticipant, mu as publishStream, Vl as putHandsDown, Yu as removeHistoryRecords, cu as removeJoinLink, vu as removeMovie, Al as removeParticipant, jl as removeParticipantInternal, Su as removeRooms, Qu as requestAsr, Ul as requestDisplayLayout, Ru as requestPromotion, ul as setAudioEffects, Mu as setAudioStream, Rl as setLocalResolution, cl as setLogger, Xl as setMediaModifiers, Cu as setStatisticsInterval, dl as setVad, ll as setVideoEffects, Fl as setVideoStream, fl as setVmoji, Pu as setVmojiFill, Nu as setVmojiSvg, uu as setVolume, Xu as startAsr, ou as startAudienceConversation, au as startConversation, bl as startStats, fu as startStream, $u as startUrlSharing, Zu as stopAsr, pu as stopStream, ed as stopUrlSharing, td as switchCall, xu as switchRoom, Ll as toggleLocalAudio, Il as toggleLocalVideo, Hl as updateDisplayLayout, _u as updateMovie, yu as updateRooms, ku as uploadDebugLogs, sl as utils, id as version };
14984
+ export { Jc as Api, nl as ApiExternal, tl as ArrayDequeue, v as AuthData, f as BaseLogger, _o as CallDirection, vo as CallType, yo as ChatRoomEventType, bo as ConversationFeature, xo as ConversationOption, On as DebugMessageType, Mo as ExternalIdType, It as FacingMode, y as FatalError, k as HangupReason, O as HangupType, b as MediaOption, A as MediaTrackKind, H as MediaType, wo as MuteState, X as ParticipantState, el as ParticipantStateDataValue, P as ParticipantStatus, $c as RecordRole, To as RoomsEventType, go as Signaling, V as SignalingCommandType, Cr as SignalingConnectionType, K as SignalingNotification, U as Stat, J as TransportTopology, Oo as UserRole, j as UserType, ts as VolumeDetector, Sl as acceptCall, zu as acceptPromotion, bu as activateRooms, gu as addMovie, Ol as addParticipant, kl as addParticipantInternal, xl as authorize, ol as browser, gl as callInternal, ml as callTo, Nl as captureScreen, Pl as captureVmoji, ju as changeAudioEffect, $l as changeConversationOptions, Ml as changeDevice, Bl as changeParticipantState, zl as changePriorities, Au as changeVideoEffect, nu as chatHistory, eu as chatMessage, tu as chatMessageInternal, su as createJoinLink, ru as customData, iu as customDataInternal, wu as debug, Du as debugLogs, Tu as debugMessage, Eu as debugMessageWithContext, Cl as declineCall, Uu as enableFeatureForRoles, Zl as enableVideoSuspend, Ql as enableVideoSuspendSuggest, Hu as feedback, du as forceRelayPolicy, nd as getActiveCallId, lu as getAnonymTokenByLink, Iu as getAudienceModeHands, yl as getInbounds, Bu as getParticipantListChunk, Vu as getParticipants, hu as getStreamInfo, rd as getSyncedTime, Fu as getWaitingHall, Wl as grantRoles, Gl as grantRolesInternal, Dl as hangup, pl as init, wl as joinCall, El as joinCallByLink, Tl as joinCallInternal, Kl as muteParticipant, ql as muteParticipantInternal, Jl as pinParticipant, Yl as pinParticipantInternal, _l as processPush, vl as processPushInternal, Lu as promoteParticipant, mu as publishStream, Vl as putHandsDown, Yu as removeHistoryRecords, cu as removeJoinLink, vu as removeMovie, Al as removeParticipant, jl as removeParticipantInternal, Su as removeRooms, Qu as requestAsr, Ul as requestDisplayLayout, Ru as requestPromotion, ul as setAudioEffects, Mu as setAudioStream, Rl as setLocalResolution, cl as setLogger, Xl as setMediaModifiers, Cu as setStatisticsInterval, dl as setVad, ll as setVideoEffects, Fl as setVideoStream, fl as setVmoji, Pu as setVmojiFill, Nu as setVmojiSvg, uu as setVolume, Xu as startAsr, ou as startAudienceConversation, au as startConversation, bl as startStats, fu as startStream, $u as startUrlSharing, Zu as stopAsr, pu as stopStream, ed as stopUrlSharing, td as switchCall, xu as switchRoom, Ll as toggleLocalAudio, Il as toggleLocalVideo, Hl as updateDisplayLayout, _u as updateMovie, yu as updateRooms, ku as uploadDebugLogs, sl as utils, id as version };