@vkontakte/calls-sdk 2.8.12-beta.12 → 2.8.12-beta.13

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.12-beta.12
3
- * Wed, 26 Aug 2026 14:52:45 GMT
2
+ * @vkontakte/calls-sdk v2.8.12-beta.13
3
+ * Fri, 28 Aug 2026 10:26:17 GMT
4
4
  * https://calls-sdk.cdn-vk.ru/doc/latest/index.html
5
5
  */
6
6
 
@@ -1268,7 +1268,8 @@ var D = /* @__PURE__ */ function(e) {
1268
1268
  return this._sendVideoTrack && !e ? this._sendVideoTrack : this._stream ? this._stream.getVideoTracks()[0] : null;
1269
1269
  }
1270
1270
  getSendAudioTrack() {
1271
- return this._stream?.getAudioTracks().find((e) => !e.contentHint) || null;
1271
+ let e = this._stream?.getAudioTracks().filter((e) => !e.contentHint) ?? [];
1272
+ return e.find((e) => e.enabled) ?? e[0] ?? null;
1272
1273
  }
1273
1274
  get isAnimojiRequested() {
1274
1275
  return this._animojiEnabled && !this._mediaSettings.isVideoEnabled;
@@ -1453,11 +1454,11 @@ var D = /* @__PURE__ */ function(e) {
1453
1454
  };
1454
1455
  if (e) try {
1455
1456
  let e = await T.getUserAudio(void 0, this._debug, this._logger);
1456
- this._micAudioTrack = e.getAudioTracks()[0], t(await this._applyAudioEffect(), !0);
1457
+ this._micAudioTrack = e.getAudioTracks()[0], await t(await this._applyAudioEffect(), !0);
1457
1458
  } catch (e) {
1458
- throw M.audioEffects?.pause(), t(T.getSilentMediaTrack(), !1), typeof e == "string" ? Error(e) : e;
1459
+ throw M.audioEffects?.pause(), await t(T.getSilentMediaTrack(), !1), typeof e == "string" ? Error(e) : e;
1459
1460
  }
1460
- else M.audioEffects?.pause(), t(T.getSilentMediaTrack(), !1);
1461
+ else M.audioEffects?.pause(), await t(T.getSilentMediaTrack(), !1);
1461
1462
  }
1462
1463
  toggleAnimojiCapturing(e) {
1463
1464
  this._animojiEnabled = e, this._mediaSettings.isVideoEnabled || this._triggerEvent("ANIMOJI_STATUS", e);
@@ -2167,7 +2168,7 @@ var hn = mn.getInstance(), M = class e {
2167
2168
  return 1.1;
2168
2169
  }
2169
2170
  static get sdkVersion() {
2170
- return "2.8.12-beta.12";
2171
+ return "2.8.12-beta.13";
2171
2172
  }
2172
2173
  static get debug() {
2173
2174
  return e._params.debug;
@@ -7509,7 +7510,15 @@ var Ma = new Set([
7509
7510
  }
7510
7511
  }
7511
7512
  _handleCommandResponse(t, n) {
7512
- if (!Object.hasOwn(this.responseHandlers, n.sequence)) return;
7513
+ if (!Object.hasOwn(this.responseHandlers, n.sequence)) {
7514
+ if (n.participants) for (let e of n.participants) this._triggerEvent(G.NOTIFICATION, {
7515
+ ...n,
7516
+ notification: K.PARTICIPANT_ADDED,
7517
+ type: "notification",
7518
+ participant: e
7519
+ });
7520
+ return;
7521
+ }
7513
7522
  let r = this.responseHandlers[n.sequence];
7514
7523
  window.clearTimeout(r.responseTimer);
7515
7524
  let i = W.measureMark(r.statMarkName);
@@ -7942,7 +7951,7 @@ var so = class {
7942
7951
  this._fixNoPacketsChecked = !0, this._logger?.log(C.ERROR, `audio_device_recover_${e.bandwidth ? "success" : "fail"}`);
7943
7952
  return;
7944
7953
  }
7945
- !this._fixNoPacketsApplied && !e.bandwidth && (this._fixNoPacketsApplied = !0, this._logger?.log(C.ERROR, "audio_device_recover"), this._debug.log("[AudioFix] Trying to fix RV (no packets)"), this._toggleAudioPromise = this._mediaSource.toggleAudio(T.getMicrophonePermissionState() !== "denied"), this._toggleAudioPromise.catch(() => void 0));
7954
+ !this._fixNoPacketsApplied && !e.bandwidth && e.packetsSent > 0 && (this._fixNoPacketsApplied = !0, this._logger?.log(C.ERROR, "audio_device_recover"), this._debug.log("[AudioFix] Trying to fix RV (no packets)"), this._toggleAudioPromise = this._mediaSource.toggleAudio(T.getMicrophonePermissionState() !== "denied"), this._toggleAudioPromise.catch(() => void 0));
7946
7955
  }
7947
7956
  }
7948
7957
  _fixAudioDeviceTooManyPackets(e) {
@@ -9201,7 +9210,7 @@ var ns = 15, $ = class e extends b {
9201
9210
  isMe: (e) => this._isMe(e),
9202
9211
  updateDisplayLayout: (e) => this.updateDisplayLayout(e)
9203
9212
  }), this._onUnload = () => {
9204
- this._stopFirstMediaSentProbe(), this._conversation && this._api && this._api.hangupConversation(this._conversation.id, this._state === "IDLE" ? D.CANCELED : D.HUNGUP), this._stats.destroy();
9213
+ this._stopFirstMediaSentProbe(), this._conversation && this._api && this._sendHangupApi(this._conversation.id, this._state === "IDLE" ? D.CANCELED : D.HUNGUP), this._stats.destroy();
9205
9214
  }, window.addEventListener("pagehide", this._onUnload), this._statFirstMediaReceived = new Qo(this._stats.statAggregator), this._audioOutput = new co(this._statFirstMediaReceived, M.transparentAudio, this._debug, this._stats.logger), M.videoTracksCount > 0 && (this._cooldownQueueCleanupTimer = window.setInterval(this._cleanupCooldownQueue.bind(this), $o));
9206
9215
  }
9207
9216
  static current() {
@@ -9481,7 +9490,7 @@ var ns = 15, $ = class e extends b {
9481
9490
  let t = e ?? (this._state === "ACTIVE" || this._state === "HELD" ? D.HUNGUP : D.CANCELED), n = new O(t), r = this._conversation?.id ?? null;
9482
9491
  return this._stats.logger.log(C.HANGUP, t), this._finishLifecycle(n), this._hangupPromise = this._signaling.hangup(t).then(() => void 0).catch((e) => {
9483
9492
  if (!(e instanceof bn)) throw e;
9484
- }).finally(() => this._close(n)), this._emitHangupOnce(n, r), this._cleanupTransport(), this._cleanupMediaSource(), this._hangupPromise;
9493
+ }).finally(() => (r != null && this._sendHangupApi(r, t), this._close(n))), this._emitHangupOnce(n, r), this._cleanupTransport(), this._cleanupMediaSource(), this._hangupPromise;
9485
9494
  }
9486
9495
  async addParticipant(e, t) {
9487
9496
  if (!this._signaling.ready) {
@@ -9536,6 +9545,10 @@ var ns = 15, $ = class e extends b {
9536
9545
  _emitHangupOnce(e, t) {
9537
9546
  this._hangupEmitted || (this._hangupEmitted = !0, L.onHangup(e, t));
9538
9547
  }
9548
+ _sendHangupApi(e, t) {
9549
+ let n = this._signaling.getPeerId(), r = {};
9550
+ n != null && (r.peerId = String(n)), this._api.hangupConversation(e, t, r);
9551
+ }
9539
9552
  _close(e, t = {}) {
9540
9553
  this._clearCalleeUnavailableWatchdog(), t.errorText && this._debug.error(t.errorText, e), this._debug.debug("Close conversation", e), this._finishLifecycle(e), this._stats.flushCallMetrics();
9541
9554
  let n = t.signalingReason ?? (e.error ? D.FAILED : void 0), r = n && this._signaling.ready ? this._signaling.hangup(n) : void 0;
@@ -9577,7 +9590,7 @@ var ns = 15, $ = class e extends b {
9577
9590
  this._clearCalleeUnavailableWatchdog();
9578
9591
  let t = this._conversation && this._conversation.id;
9579
9592
  if (this._debug.debug("Destroy conversation", { conversationId: t }), this._stopFirstMediaSentProbe(), this._cooldownQueueCleanupTimer !== null && (window.clearInterval(this._cooldownQueueCleanupTimer), this._cooldownQueueCleanupTimer = null), this._state = "CLOSE", this._participantState = Z.HUNGUP, this._cleanupMediaSource(), this._cleanupParticipants(), this._cleanupParticipantAgnosticStreams(), this._cleanupTransport(), this._cleanupSpeakerDetector(), this._cleanupSpecListener(), this._disposeSignaling(e), this._api.cleanup(), this._api.setAbortSignal(void 0), this._delayedHangup && t) try {
9580
- this._api.hangupConversation(t, D.CANCELED);
9593
+ this._sendHangupApi(t, D.CANCELED);
9581
9594
  } catch {}
9582
9595
  this._cleanupListeners(), this._stats.destroy(), this._cleanupRegistry(), this._conversation = null, this._myLastRequestedLayouts = {}, this._displayLayoutRequester.clear(), this._delayedHangup = !1, this._abortController = null;
9583
9596
  }
@@ -10278,13 +10291,13 @@ var ns = 15, $ = class e extends b {
10278
10291
  return;
10279
10292
  }
10280
10293
  if (this._isWaitingForPromotion()) {
10281
- this._waitingHallHoldPending = !1, this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), await this._resumeLocalMedia(t, this._getWaitingForPromotionStatus());
10294
+ this._waitingHallHoldPending = !1, await this._resumeLocalMedia(t, this._getWaitingForPromotionStatus()), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener();
10282
10295
  return;
10283
10296
  }
10284
10297
  let n = pa.get();
10285
10298
  await this._signaling.hold(!1, n), this._restoreStateAfterHold();
10286
10299
  let r = null;
10287
- if (this._state === "IDLE" && this._participantState === Z.ACCEPTED && (r = Object.values(this._participants), r.some((e) => e.state === Z.ACCEPTED) && (this._state = "ACTIVE", this._changeFeatureSet())), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), await this._resumeLocalMedia(t, N.WAITING), this._state === "ACTIVE") {
10300
+ if (this._state === "IDLE" && this._participantState === Z.ACCEPTED && (r = Object.values(this._participants), r.some((e) => e.state === Z.ACCEPTED) && (this._state = "ACTIVE", this._changeFeatureSet())), await this._resumeLocalMedia(t, N.WAITING), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), this._state === "ACTIVE") {
10288
10301
  let e = this._conversation?.direction === Pa.OUTGOING && !this._conversation.concurrent;
10289
10302
  this._openTransport(r ?? Object.values(this._participants), e);
10290
10303
  }
@@ -11069,8 +11082,12 @@ var ns = 15, $ = class e extends b {
11069
11082
  let n = this._api.getDecorativeIdByInitialId(t), i = n ? j.composeUserId(n, e.participantType) : void 0;
11070
11083
  r = this._registerParticipantInCache(this._createParticipant({
11071
11084
  id: t,
11085
+ externalId: e.externalId ? Q.fromSignaling(e.externalId, e.deviceIdx) : void 0,
11072
11086
  mediaSettings: E(e.mediaSettings)
11073
11087
  }, i));
11088
+ } else if (e.externalId) {
11089
+ let t = Q.fromSignaling(e.externalId, e.deviceIdx);
11090
+ r.externalId = t, this._api.cacheExternalId(r.id, t);
11074
11091
  }
11075
11092
  r.state = Z.ACCEPTED, r.mediaSettings = E(e.mediaSettings), this._logWithMediaSettings(C.ACCEPTED_OUTGOING, r.mediaSettings), this._conversation && this._conversation.direction === Pa.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);
11076
11093
  let i = Object.keys(r.muteStates);
@@ -11237,7 +11254,7 @@ var ns = 15, $ = class e extends b {
11237
11254
  this._conversation && (this._conversation.chatId = e.chatId, this._toggleJoinAvailability(), L.onMultipartyChatCreated(this._conversation));
11238
11255
  }
11239
11256
  async _onForceMediaSettingsChange(e) {
11240
- if (!this._mediaSource) return;
11257
+ if (!this._mediaSource || this._state === "HELD") return;
11241
11258
  let t = this._mediaSource.mediaSettings, n = E(e.mediaSettings);
11242
11259
  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({
11243
11260
  captureScreen: n.isScreenSharingEnabled,
@@ -11273,7 +11290,7 @@ var ns = 15, $ = class e extends b {
11273
11290
  async _onPeerRegistered(e) {
11274
11291
  this._registeredPeerReceived = !0, this._clearCalleeUnavailableWatchdog();
11275
11292
  let t = j.composeMessageId(e), n = this._getParticipant(t);
11276
- n && (n.clientType = e.clientType, n.platform = e.platform), L.onPeerRegistered(this.id, [n.externalId]);
11293
+ n && (n.clientType = e.clientType, n.platform = e.platform, L.onPeerRegistered(this.id, [n.externalId]));
11277
11294
  }
11278
11295
  async _onMicSwitched(e) {
11279
11296
  L.onDeviceSwitched(S.AUDIO, !e.mute, this.id), await this.toggleLocalAudio(!e.mute);
@@ -11911,15 +11928,15 @@ var ns = 15, $ = class e extends b {
11911
11928
  constructor(t, n) {
11912
11929
  super(t), h(this, "participantErrors", void 0), Object.setPrototypeOf(this, e.prototype), this.participantErrors = n;
11913
11930
  }
11914
- }, as = null, os = null;
11915
- function ss() {
11931
+ }, as = null, os = null, ss = 64 * 1024;
11932
+ function cs() {
11916
11933
  as = null, os = null;
11917
11934
  }
11918
- function cs(e) {
11935
+ function ls(e) {
11919
11936
  return e?.endsWith("/") ? e.slice(0, -1) : e;
11920
11937
  }
11921
- async function ls(e = null, t) {
11922
- let n = cs(e ?? M.apiBaseUrl);
11938
+ async function us(e = null, t) {
11939
+ let n = ls(e ?? M.apiBaseUrl);
11923
11940
  if (n) return n;
11924
11941
  if ((t ?? M.apiEnv) !== "AUTO") return M.apiEndpoint(t);
11925
11942
  try {
@@ -11934,62 +11951,68 @@ async function ls(e = null, t) {
11934
11951
  return R.warn("Failed to resolve API endpoint using DNS, default is used", e), M.apiEndpoint(t);
11935
11952
  }
11936
11953
  }
11937
- async function us() {
11938
- return as || os || (os = ls(), as = await os, os = null, as);
11954
+ async function ds() {
11955
+ return as || os || (os = us(), as = await os, os = null, as);
11939
11956
  }
11940
- async function ds(e, t = {}, n = !1) {
11957
+ async function fs(e, t = {}, n = !1) {
11941
11958
  if (!window.Blob || !window.navigator.sendBeacon) return;
11942
- await us();
11943
- let r = gs(e, t, n), i = new window.Blob([r], { type: "application/x-www-form-urlencoded" });
11959
+ await ds();
11960
+ let r = vs(e, t, n), i = new window.Blob([r], { type: "application/x-www-form-urlencoded" });
11944
11961
  window.navigator.sendBeacon(`${as}/fb.do`, i);
11945
11962
  }
11946
- async function fs(e, t = {}, n = !1, r) {
11947
- return await us(), ps(gs(e, t, n), r);
11963
+ async function ps(e, t = {}, n = !1, r) {
11964
+ return await ds(), hs(vs(e, t, n), r);
11948
11965
  }
11949
- async function ps(e, t) {
11950
- let n = `${t ?? as}/fb.do`, r = new AbortController(), i = new O(x.NETWORK, { callError: {
11966
+ async function ms(e, t = {}, n = !1) {
11967
+ await ds();
11968
+ let r = vs(e, t, n);
11969
+ return hs(r, void 0, new Blob([r]).size <= ss);
11970
+ }
11971
+ async function hs(e, t, n = !1) {
11972
+ let r = `${t ?? as}/fb.do`, i = new AbortController(), a = new O(x.NETWORK, { callError: {
11951
11973
  scope: "network",
11952
11974
  source: "api",
11953
11975
  code: "timeout",
11954
11976
  description: "request-timeout"
11955
- } }), a = setTimeout(() => r.abort(i), M.apiTimeout);
11977
+ } }), o = setTimeout(() => i.abort(a), M.apiTimeout);
11956
11978
  try {
11957
- let t = await fetch(n, {
11979
+ let t = await fetch(r, {
11958
11980
  method: "POST",
11959
11981
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
11960
11982
  body: e,
11961
- signal: r.signal
11962
- }), i = await t.text(), a;
11983
+ signal: i.signal,
11984
+ ...n && { keepalive: !0 }
11985
+ }), a = await t.text(), o;
11963
11986
  try {
11964
- a = JSON.parse(i);
11987
+ o = JSON.parse(a);
11965
11988
  } catch {
11966
- a = { result: i };
11989
+ o = { result: a };
11967
11990
  }
11968
- if (!t.ok && !ms(a)) throw new O(x.API, { callError: {
11991
+ if (!t.ok && !gs(o)) throw new O(x.API, { callError: {
11969
11992
  scope: "server",
11970
11993
  source: "api",
11971
11994
  code: `http-${t.status}`,
11972
11995
  description: "http-error"
11973
11996
  } });
11974
- if (ms(a)) throw a;
11975
- return a;
11997
+ if (gs(o)) throw o;
11998
+ return o;
11976
11999
  } catch (e) {
11977
- throw e instanceof O ? e : r.signal.aborted ? i : ms(e) ? e : new O(x.NETWORK, { callError: {
12000
+ throw e instanceof O ? e : i.signal.aborted ? a : gs(e) ? e : new O(x.NETWORK, { callError: {
11978
12001
  scope: "network",
11979
12002
  source: "api",
11980
12003
  code: "fetch-failed",
11981
12004
  description: "request-failed"
11982
12005
  } });
11983
12006
  } finally {
11984
- clearTimeout(a);
12007
+ clearTimeout(o);
11985
12008
  }
11986
12009
  }
11987
- function ms(e) {
12010
+ function gs(e) {
11988
12011
  if (typeof e != "object" || !e) return !1;
11989
12012
  let t = e;
11990
12013
  return typeof t.error_code == "number" && typeof t.error_msg == "string";
11991
12014
  }
11992
- async function hs(e, t) {
12015
+ async function _s(e, t) {
11993
12016
  try {
11994
12017
  let n = await fetch(e, {
11995
12018
  method: "POST",
@@ -12002,7 +12025,7 @@ async function hs(e, t) {
12002
12025
  throw R.warn("Failed to send form data", e), e;
12003
12026
  }
12004
12027
  }
12005
- function gs(e, t = {}, n = !1) {
12028
+ function vs(e, t = {}, n = !1) {
12006
12029
  t.method = e, t.format = "JSON", t.application_key || (t.application_key = M.apiKey), n || (y.sessionKey ? t.session_key = y.sessionKey : y.accessToken && (t.access_token = y.accessToken));
12007
12030
  for (let [e, n] of Object.entries(t)) typeof n == "object" && (t[e] = JSON.stringify(n));
12008
12031
  let r = "";
@@ -12011,7 +12034,7 @@ function gs(e, t = {}, n = !1) {
12011
12034
  }
12012
12035
  //#endregion
12013
12036
  //#region src/abstract/BaseApi.ts
12014
- var _s = class {
12037
+ var ys = class {
12015
12038
  constructor() {
12016
12039
  h(this, "_abortSignal", void 0);
12017
12040
  }
@@ -12045,7 +12068,7 @@ var _s = class {
12045
12068
  replaceByInitialIdIdIfExists(e) {
12046
12069
  return typeof e == "string" ? parseInt(e, 10) : e;
12047
12070
  }
12048
- hangupConversation(e, t = D.HUNGUP) {}
12071
+ hangupConversation(e, t = D.HUNGUP, n) {}
12049
12072
  async removeHistoryRecords(e) {}
12050
12073
  async getServerTime() {
12051
12074
  return Date.now();
@@ -12054,7 +12077,7 @@ var _s = class {
12054
12077
  async getInbounds() {
12055
12078
  return [];
12056
12079
  }
12057
- }, vs = class e {
12080
+ }, bs = class e {
12058
12081
  constructor() {
12059
12082
  h(this, "_okIdToExternalId", /* @__PURE__ */ new Map()), h(this, "_externalIdToOkId", /* @__PURE__ */ new Map()), h(this, "_decorativeIdToInitialId", /* @__PURE__ */ new Map()), h(this, "_initialIdToDecorativeId", /* @__PURE__ */ new Map());
12060
12083
  }
@@ -12105,27 +12128,27 @@ var _s = class {
12105
12128
  clear() {
12106
12129
  this._okIdToExternalId.clear(), this._externalIdToOkId.clear(), this._decorativeIdToInitialId.clear(), this._initialIdToDecorativeId.clear();
12107
12130
  }
12108
- }, ys = "anonymLogin:", bs = 700, xs = 3e3;
12109
- function Ss(e) {
12131
+ }, xs = "anonymLogin:", Ss = 700, Cs = 3e3;
12132
+ function ws(e) {
12110
12133
  let t = e.error_code;
12111
12134
  switch (t) {
12112
- case 2: return Cs(D.SERVICE_UNAVAILABLE, t, "service-unavailable");
12113
- case 4: return e.error_msg.includes("participants.limit.exceeded") ? Cs(D.PARTICIPANT_LIMIT_REACHED, t, "participants-limit-exceeded") : Cs(x.API, t, "request-error");
12114
- case 300: return Cs(D.NOT_FOUND, t, "not-found");
12115
- case 1101: return Cs(D.SERVICE_DISABLED, t, "vchat-service-disabled");
12116
- case 1102: return Cs(D.CALLEE_IS_OFFLINE, t, "target-user-unavailable");
12117
- case 1103: return Cs(D.NOT_FRIENDS, t, "friendship-required");
12118
- case 1104: return ws(t, "youla-api-error");
12119
- case 1106: return ws(t, "vk-api-error");
12120
- case 1113: return Cs(D.CALLER_IS_REJECTED, t, "caller-is-rejected");
12135
+ case 2: return Ts(D.SERVICE_UNAVAILABLE, t, "service-unavailable");
12136
+ case 4: return e.error_msg.includes("participants.limit.exceeded") ? Ts(D.PARTICIPANT_LIMIT_REACHED, t, "participants-limit-exceeded") : Ts(x.API, t, "request-error");
12137
+ case 300: return Ts(D.NOT_FOUND, t, "not-found");
12138
+ case 1101: return Ts(D.SERVICE_DISABLED, t, "vchat-service-disabled");
12139
+ case 1102: return Ts(D.CALLEE_IS_OFFLINE, t, "target-user-unavailable");
12140
+ case 1103: return Ts(D.NOT_FRIENDS, t, "friendship-required");
12141
+ case 1104: return Es(t, "youla-api-error");
12142
+ case 1106: return Es(t, "vk-api-error");
12143
+ case 1113: return Ts(D.CALLER_IS_REJECTED, t, "caller-is-rejected");
12121
12144
  case 1114: {
12122
12145
  let n = e.custom_error?.vchat_detailed_api_error?.code, r = n?.startsWith("obsolete_client");
12123
- return Cs(r ? D.OBSOLETE_CLIENT : D.VCHAT_DETAILED_ERROR, t, n ?? "detailed-error", r ? n : void 0);
12146
+ return Ts(r ? D.OBSOLETE_CLIENT : D.VCHAT_DETAILED_ERROR, t, n ?? "detailed-error", r ? n : void 0);
12124
12147
  }
12125
- default: return Cs(x.API, t, "api-error");
12148
+ default: return Ts(x.API, t, "api-error");
12126
12149
  }
12127
12150
  }
12128
- function Cs(e, t, n, r) {
12151
+ function Ts(e, t, n, r) {
12129
12152
  return {
12130
12153
  type: e,
12131
12154
  callError: {
@@ -12137,7 +12160,7 @@ function Cs(e, t, n, r) {
12137
12160
  message: r
12138
12161
  };
12139
12162
  }
12140
- function ws(e, t) {
12163
+ function Es(e, t) {
12141
12164
  return {
12142
12165
  type: D.EXTERNAL_API_ERROR,
12143
12166
  callError: {
@@ -12148,19 +12171,19 @@ function ws(e, t) {
12148
12171
  }
12149
12172
  };
12150
12173
  }
12151
- var Ts = class extends _s {
12174
+ var Ds = class extends ys {
12152
12175
  constructor(...e) {
12153
- super(...e), h(this, "_uuid", void 0), h(this, "_idCache", new vs());
12176
+ super(...e), h(this, "_uuid", void 0), h(this, "_idCache", new bs());
12154
12177
  }
12155
12178
  async _callUnsafe(e, t = {}, n = !1) {
12156
12179
  let r = async (i) => {
12157
12180
  try {
12158
- return await fs(e, t, n);
12181
+ return await ps(e, t, n);
12159
12182
  } catch (t) {
12160
12183
  if (!t || typeof t != "object" || !Object.hasOwn(t, "error_msg")) {
12161
12184
  i++;
12162
12185
  let n = t && (typeof t == "object" || typeof t == "function") ? Object.getOwnPropertyNames(t).map((e) => `${e}: ${JSON.stringify(t[e])}`) : [String(t)];
12163
- if (R.debug(`${e} network error, attempt ${i}: ${n.join("\n ")}`), this._abortSignal?.aborted && (R.debug(`${e} aborted`), this._abortSignal.throwIfAborted()), i < M.apiMaxAttempt) return await j.delay(Math.min(i * bs, xs), { signal: this._abortSignal }), r(i);
12186
+ if (R.debug(`${e} network error, attempt ${i}: ${n.join("\n ")}`), this._abortSignal?.aborted && (R.debug(`${e} aborted`), this._abortSignal.throwIfAborted()), i < M.apiMaxAttempt) return await j.delay(Math.min(i * Ss, Cs), { signal: this._abortSignal }), r(i);
12164
12187
  }
12165
12188
  throw R.warn(e, "error", t), t;
12166
12189
  }
@@ -12177,14 +12200,14 @@ var Ts = class extends _s {
12177
12200
  case 103:
12178
12201
  case 104:
12179
12202
  if (!r) break;
12180
- return this._removeCachedAnonymLogin(), await y.reauthorize(() => this.authorize()), this._call(e, t, n, !1);
12203
+ return await this._reauthorize(), this._call(e, t, n, !1);
12181
12204
  }
12182
12205
  let a = {
12183
12206
  message: i?.error_msg,
12184
12207
  code: i?.error_code
12185
12208
  };
12186
- if (i.custom_error && (a.custom_error = i.custom_error), Es(i)) {
12187
- let e = Ss(i);
12209
+ if (i.custom_error && (a.custom_error = i.custom_error), Os(i)) {
12210
+ let e = ws(i);
12188
12211
  throw a.callError = e.callError, a.message = e.message ?? a.message, new O(e.type, a);
12189
12212
  }
12190
12213
  throw new O(x.API, a);
@@ -12230,17 +12253,17 @@ var Ts = class extends _s {
12230
12253
  });
12231
12254
  }
12232
12255
  _getAnonymLoginCacheKey() {
12233
- return M.authToken ? `${ys}${M.authToken}` : null;
12256
+ return M.authToken ? `${xs}${M.authToken}` : null;
12234
12257
  }
12235
12258
  _getCachedAnonymLogin() {
12236
12259
  let e = this._getAnonymLoginCacheKey();
12237
12260
  if (!e) return null;
12238
12261
  let t = at.get(e);
12239
- return Ds(t) ? t : (t && at.remove(e), null);
12262
+ return ks(t) ? t : (t && at.remove(e), null);
12240
12263
  }
12241
12264
  _setCachedAnonymLogin(e) {
12242
12265
  let t = this._getAnonymLoginCacheKey();
12243
- !t || !Ds(e) || at.set(t, {
12266
+ !t || !ks(e) || at.set(t, {
12244
12267
  session_key: e.session_key,
12245
12268
  session_secret_key: e.session_secret_key,
12246
12269
  uid: e.uid
@@ -12250,9 +12273,23 @@ var Ts = class extends _s {
12250
12273
  let e = this._getAnonymLoginCacheKey();
12251
12274
  e && at.remove(e);
12252
12275
  }
12276
+ _reauthorize() {
12277
+ return this._removeCachedAnonymLogin(), y.reauthorize(() => this.authorize());
12278
+ }
12253
12279
  _applyAnonymLogin(e) {
12254
12280
  e.uid && (y.userId = Number(e.uid)), y.sessionKey = e.session_key, y.sessionSecretKey = e.session_secret_key;
12255
12281
  }
12282
+ async _sendClientStats(e, t = !0) {
12283
+ try {
12284
+ (await ms("vchat.clientStats", e))?.items_responses?.forEach((e) => {
12285
+ e.errors && R.error("[vchat.clientStats]", e);
12286
+ });
12287
+ } catch (n) {
12288
+ let r = n?.error_code === 102 || n?.error_code === 103 || n?.error_code === 104;
12289
+ if (!t || !r) throw n;
12290
+ await this._reauthorize(), await this._sendClientStats(e, !1);
12291
+ }
12292
+ }
12256
12293
  logClientStats(e) {
12257
12294
  let t = {
12258
12295
  app_version: String(M.appVersion),
@@ -12261,7 +12298,9 @@ var Ts = class extends _s {
12261
12298
  version: 1,
12262
12299
  items: e
12263
12300
  };
12264
- M.clientStatsPlatform && (t.platform = M.clientStatsPlatform), ds("vchat.clientStats", { data: JSON.stringify(t) });
12301
+ M.clientStatsPlatform && (t.platform = M.clientStatsPlatform);
12302
+ let n = { data: JSON.stringify(t) };
12303
+ this._sendClientStats(n).catch((e) => R.error("[vchat.clientStats]", e));
12265
12304
  }
12266
12305
  async uploadDebugLogs(e, t, n, r) {
12267
12306
  let i = {
@@ -12272,7 +12311,7 @@ var Ts = class extends _s {
12272
12311
  }, a = await this._callUnsafe("vchat.getLogUploadUrl", i), o = new FormData(), s = new Blob([r], { type: "application/json" });
12273
12312
  o.append("file", s, "log.json");
12274
12313
  let c = new URL(a.upload_url);
12275
- return c.searchParams.append("size", s.size.toString()), hs(c.toString(), o);
12314
+ return c.searchParams.append("size", s.size.toString()), _s(c.toString(), o);
12276
12315
  }
12277
12316
  async joinConversation(e, t = !1, n) {
12278
12317
  let r = {
@@ -12398,12 +12437,12 @@ var Ts = class extends _s {
12398
12437
  setUserId(e) {
12399
12438
  y.userId = e;
12400
12439
  }
12401
- hangupConversation(e, t = D.HUNGUP) {
12402
- let n = {
12440
+ hangupConversation(e, t = D.HUNGUP, n) {
12441
+ let r = {
12403
12442
  conversationId: e,
12404
12443
  reason: t
12405
12444
  };
12406
- M.anonymToken && (n.anonymToken = M.anonymToken), ds("vchat.hangupConversation", n);
12445
+ M.anonymToken && (r.anonymToken = M.anonymToken), n?.peerId && (r.peerId = n.peerId), fs("vchat.hangupConversation", r);
12407
12446
  }
12408
12447
  async removeHistoryRecords(e) {
12409
12448
  await this._call("vchat.removeHistoryRecords", { recordIds: e.join(",") });
@@ -12419,19 +12458,19 @@ var Ts = class extends _s {
12419
12458
  return Array.isArray(e?.inbounds) ? e.inbounds : [];
12420
12459
  }
12421
12460
  };
12422
- function Es(e) {
12461
+ function Os(e) {
12423
12462
  return typeof e == "object" && !!e && "error_code" in e && "error_msg" in e;
12424
12463
  }
12425
- function Ds(e) {
12464
+ function ks(e) {
12426
12465
  return typeof e == "object" && !!e && "session_key" in e && "session_secret_key" in e && typeof e.session_key == "string" && e.session_key.length > 0 && typeof e.session_secret_key == "string" && e.session_secret_key.length > 0;
12427
12466
  }
12428
12467
  //#endregion
12429
12468
  //#region src/enums/RecordRole.ts
12430
- var Os = /* @__PURE__ */ function(e) {
12469
+ var As = /* @__PURE__ */ function(e) {
12431
12470
  return e.KING = "KING", e.PAWN = "PAWN", e;
12432
- }(Os || {}), ks = /* @__PURE__ */ function(e) {
12471
+ }(As || {}), js = /* @__PURE__ */ function(e) {
12433
12472
  return e.OFF = "0", e.ON = "1", e;
12434
- }({}), As = class {
12473
+ }({}), Ms = class {
12435
12474
  constructor(e) {
12436
12475
  h(this, "_queue", void 0), h(this, "_readCursor", void 0), h(this, "_writeCursor", void 0), h(this, "_moveReadCursor", void 0), h(this, "_left", void 0), this._queue = Array(e).fill(null), this._readCursor = this._writeCursor = this._left = 0, this._moveReadCursor = !1;
12437
12476
  }
@@ -12454,12 +12493,12 @@ var Os = /* @__PURE__ */ function(e) {
12454
12493
  let e = this._queue[this._readCursor];
12455
12494
  return e && (this._moveReadCursor = !1, this._queue[this._readCursor] = null, this._readCursor = this.nextCursor(this._readCursor), --this._left), e;
12456
12495
  }
12457
- }, js = class {
12496
+ }, Ns = class {
12458
12497
  constructor(e, t, n, r = null) {
12459
12498
  h(this, "_uuid", void 0), h(this, "_apiKey", void 0), h(this, "_callToken", void 0), h(this, "_apiEnv", void 0), h(this, "_baseApiUrl", void 0), h(this, "_sessionKey", void 0), this._uuid = j.uuid(), this._apiKey = t, this._callToken = n, this._apiEnv = e, this._baseApiUrl = r;
12460
12499
  }
12461
12500
  async authorize() {
12462
- let e = await fs("auth.anonymLogin", {
12501
+ let e = await ps("auth.anonymLogin", {
12463
12502
  session_data: {
12464
12503
  device_id: this._uuid,
12465
12504
  client_version: M.appVersion,
@@ -12468,18 +12507,19 @@ var Os = /* @__PURE__ */ function(e) {
12468
12507
  version: 3
12469
12508
  },
12470
12509
  application_key: this._apiKey
12471
- }, !0, await ls(this._baseApiUrl, this._apiEnv));
12510
+ }, !0, await us(this._baseApiUrl, this._apiEnv));
12472
12511
  return j.isObject(e) && !("error_msg" in e) ? (this._sessionKey = e.session_key, !0) : !1;
12473
12512
  }
12474
- async hangupConversation(e) {
12475
- await fs("vchat.hangupConversation", {
12513
+ async hangupConversation(e, t) {
12514
+ let n = {
12476
12515
  conversationId: e,
12477
12516
  reason: D.HUNGUP,
12478
12517
  application_key: this._apiKey,
12479
12518
  session_key: this._sessionKey
12480
- }, !0, await ls(this._baseApiUrl, this._apiEnv));
12519
+ };
12520
+ t?.peerId && (n.peerId = t.peerId), await ps("vchat.hangupConversation", n, !0, await us(this._baseApiUrl, this._apiEnv));
12481
12521
  }
12482
- }, Ms, Ns = null, Ps = {
12522
+ }, Ps, Fs = null, Is = {
12483
12523
  getCameras: T.getCameras,
12484
12524
  getMicrophones: T.getMicrophones,
12485
12525
  getOutput: T.getOutput,
@@ -12505,27 +12545,27 @@ var Os = /* @__PURE__ */ function(e) {
12505
12545
  baseChromeVersion: T.baseChromeVersion,
12506
12546
  getAudioContext: T.getAudioContext,
12507
12547
  isAudioShareSupported: T.isAudioShareSupported
12508
- }, Fs = { participantMarkerCompare: j.participantMarkerCompare };
12509
- function Is(e) {
12510
- Ns = e;
12548
+ }, Ls = { participantMarkerCompare: j.participantMarkerCompare };
12549
+ function Rs(e) {
12550
+ Fs = e;
12511
12551
  }
12512
- function Ls(e) {
12552
+ function zs(e) {
12513
12553
  M.videoEffects = e;
12514
12554
  }
12515
- function Rs(e) {
12555
+ function Bs(e) {
12516
12556
  M.audioEffects = e;
12517
12557
  }
12518
- function zs(e, t = {}) {
12558
+ function Vs(e, t = {}) {
12519
12559
  M.vad = e, M.vadOptions = t;
12520
12560
  }
12521
- function Bs(e, t = null, n = {}, r = 1) {
12561
+ function Hs(e, t = null, n = {}, r = 1) {
12522
12562
  M.vmoji = e, M.vmojiOptions = {
12523
12563
  protocolVersion: r,
12524
12564
  renderingOptions: n
12525
12565
  }, t && e.setSDK(t);
12526
12566
  }
12527
- async function Vs(t) {
12528
- M.set(t), Ms || (Ms = new Ts()), e.disableLog(!M.debug), R.toggle(M.debug), R.log(`Calls SDK ${M.sdkVersion}`, t), await T.init();
12567
+ async function Us(t) {
12568
+ M.set(t), Ps || (Ps = new Ds()), e.disableLog(!M.debug), R.toggle(M.debug), R.log(`Calls SDK ${M.sdkVersion}`, t), await T.init();
12529
12569
  let n = T.getBrowserSupportFailure();
12530
12570
  if (n) throw new O(x.UNSUPPORTED, { callError: {
12531
12571
  scope: "internal",
@@ -12534,13 +12574,13 @@ async function Vs(t) {
12534
12574
  } });
12535
12575
  R.log("UserAgent:", navigator.userAgent), R.log("Screen resolution:", `${window.screen.width}x${window.screen.height}`), R.log("Permissions:", `Camera: ${T.hasCameraPermission()}, Mic: ${T.hasMicrophonePermission()}`), R.log("Simulcast:", `${t.simulcast} => ${M.simulcast}`);
12536
12576
  }
12537
- async function Hs(e, t = [S.AUDIO], n = "", r = !1, i = !1, a, o, s) {
12577
+ async function Ws(e, t = [S.AUDIO], n = "", r = !1, i = !1, a, o, s) {
12538
12578
  let c = [];
12539
- return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), Us([], Fa.USER, t, n, r, i, a, c, o, s);
12579
+ return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), Gs([], Fa.USER, t, n, r, i, a, c, o, s);
12540
12580
  }
12541
- async function Us(e, t = Fa.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12581
+ async function Gs(e, t = Fa.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12542
12582
  if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12543
- return new $(new Ts(), Ns).onStart({
12583
+ return new $(new Ds(), Fs).onStart({
12544
12584
  opponentIds: e,
12545
12585
  opponentType: t,
12546
12586
  mediaOptions: n,
@@ -12553,40 +12593,40 @@ async function Us(e, t = Fa.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12553
12593
  conversationId: l
12554
12594
  });
12555
12595
  }
12556
- async function Ws(e, t) {
12557
- return Gs(e, A.USER, void 0, t);
12596
+ async function Ks(e, t) {
12597
+ return qs(e, A.USER, void 0, t);
12558
12598
  }
12559
- async function Gs(e, t = A.USER, n, r, i, a) {
12599
+ async function qs(e, t = A.USER, n, r, i, a) {
12560
12600
  if (e === $.id()) throw Error("Push has already been processed");
12561
- return new $(new Ts(), Ns).onPush(e, t, n, r, i, a);
12601
+ return new $(new Ds(), Fs).onPush(e, t, n, r, i, a);
12562
12602
  }
12563
- async function Ks() {
12564
- return Ms.getInbounds();
12603
+ async function Js() {
12604
+ return Ps.getInbounds();
12565
12605
  }
12566
- async function qs(e, t) {
12567
- return e && (M.authToken = e), t !== void 0 && M.apiBaseUrl !== t && (M.apiBaseUrl = t, ss()), Ms.authorize();
12606
+ async function Ys(e, t) {
12607
+ return e && (M.authToken = e), t !== void 0 && M.apiBaseUrl !== t && (M.apiBaseUrl = t, cs()), Ps.authorize();
12568
12608
  }
12569
- async function Js(e = [S.AUDIO], t) {
12570
- return _l(t).accept(e);
12609
+ async function Xs(e = [S.AUDIO], t) {
12610
+ return yl(t).accept(e);
12571
12611
  }
12572
- async function Ys(e, t) {
12573
- let n = gl(e);
12612
+ async function Zs(e, t) {
12613
+ let n = vl(e);
12574
12614
  if (n) return n.decline(t?.reason);
12575
12615
  }
12576
- async function Xs(e, t = [S.AUDIO]) {
12577
- return Zs(e, t);
12616
+ async function Qs(e, t = [S.AUDIO]) {
12617
+ return $s(e, t);
12578
12618
  }
12579
- async function Zs(e, t, n) {
12619
+ async function $s(e, t, n) {
12580
12620
  if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12581
- return new $(new Ts(), Ns).onJoin({
12621
+ return new $(new Ds(), Fs).onJoin({
12582
12622
  conversationId: e,
12583
12623
  mediaOptions: t,
12584
12624
  chatId: n
12585
12625
  });
12586
12626
  }
12587
- async function Qs(e, t = [S.AUDIO], n, r, i, a) {
12627
+ async function ec(e, t = [S.AUDIO], n, r, i, a) {
12588
12628
  if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12589
- return n && (M.anonymToken = n), new $(new Ts(), Ns).onJoin({
12629
+ return n && (M.anonymToken = n), new $(new Ds(), Fs).onJoin({
12590
12630
  joinLink: e,
12591
12631
  mediaOptions: t,
12592
12632
  observedIds: r,
@@ -12595,30 +12635,30 @@ async function Qs(e, t = [S.AUDIO], n, r, i, a) {
12595
12635
  anonymous: !!M.anonymToken
12596
12636
  });
12597
12637
  }
12598
- function $s(e, t) {
12599
- let n = gl(e);
12638
+ function tc(e, t) {
12639
+ let n = vl(e);
12600
12640
  return n ? n.hangup(t?.reason) : ($.hangupAfterInit(), Promise.resolve());
12601
12641
  }
12602
- async function ec(e, t) {
12642
+ async function nc(e, t) {
12603
12643
  let n = Array.isArray(e) ? e : [e], r = $.current();
12604
12644
  r && await r.addParticipant(n, t);
12605
12645
  }
12606
- async function tc(e, t) {
12646
+ async function rc(e, t) {
12607
12647
  let n = $.current();
12608
12648
  if (n) {
12609
12649
  let r = e.map((e) => j.composeUserId(e));
12610
12650
  await n.addParticipantLegacy(r, t);
12611
12651
  }
12612
12652
  }
12613
- async function nc(e, t = !1) {
12653
+ async function ic(e, t = !1) {
12614
12654
  let n = $.current()?.getCachedRawOkIdByExternalId(e) ?? null;
12615
12655
  if (!n) {
12616
12656
  R.warn("removeParticipant: externalId not found in cache", e);
12617
12657
  return;
12618
12658
  }
12619
- return rc(n, t);
12659
+ return ac(n, t);
12620
12660
  }
12621
- async function rc(e, t = !1) {
12661
+ async function ac(e, t = !1) {
12622
12662
  let n = $.current();
12623
12663
  if (n) try {
12624
12664
  await n.removeParticipant(j.composeUserId(e), t);
@@ -12626,13 +12666,13 @@ async function rc(e, t = !1) {
12626
12666
  R.warn(`Failed to remove participant ${e}. Perhaps he is no longer on the call. ${t}`);
12627
12667
  }
12628
12668
  }
12629
- async function ic(e, t) {
12669
+ async function oc(e, t) {
12630
12670
  let n = $.current();
12631
12671
  if (e === "videoinput" && jt.contains(t)) return M.videoFacingMode = t, n ? (T.isMobile() && n.stopVideoTrack(), n.changeDevice(e)) : void 0;
12632
12672
  if (!await T._saveDeviceId(e, t)) throw Error(`Device not found: ${t}`);
12633
12673
  if (n) return n.changeDevice(e);
12634
12674
  }
12635
- async function ac(e, t) {
12675
+ async function sc(e, t) {
12636
12676
  let n = typeof e == "object" ? {
12637
12677
  ...e,
12638
12678
  fastScreenSharing: e.captureScreen && e.fastScreenSharing,
@@ -12641,34 +12681,34 @@ async function ac(e, t) {
12641
12681
  captureScreen: e,
12642
12682
  fastScreenSharing: !1,
12643
12683
  captureAudio: !1
12644
- }, r = gl(t);
12684
+ }, r = vl(t);
12645
12685
  return r ? r.toggleScreenCapturing(n) : Promise.reject();
12646
12686
  }
12647
- function oc(e) {
12687
+ function cc(e) {
12648
12688
  let t = $.current();
12649
12689
  t && t.toggleAnimojiCapturing(e);
12650
12690
  }
12651
- async function sc(e, t = !1) {
12691
+ async function lc(e, t = !1) {
12652
12692
  let n = $.current();
12653
12693
  n && await n.setVideoStream(e, t);
12654
12694
  }
12655
- async function cc(e, t) {
12656
- let n = gl(t);
12695
+ async function uc(e, t) {
12696
+ let n = vl(t);
12657
12697
  n && await n.toggleLocalVideo(e);
12658
12698
  }
12659
- async function lc(e, t) {
12660
- let n = gl(t);
12699
+ async function dc(e, t) {
12700
+ let n = vl(t);
12661
12701
  n && await n.toggleLocalAudio(e);
12662
12702
  }
12663
- async function uc(e) {
12703
+ async function fc(e) {
12664
12704
  let t = $.current();
12665
12705
  if (t) return t.setLocalResolution(e);
12666
12706
  }
12667
- async function dc(e) {
12707
+ async function pc(e) {
12668
12708
  let t = $.current();
12669
12709
  t && await t.changePriorities(e);
12670
12710
  }
12671
- async function fc(e, t) {
12711
+ async function mc(e, t) {
12672
12712
  let n = $.current();
12673
12713
  if (n) {
12674
12714
  let r;
@@ -12683,33 +12723,33 @@ async function fc(e, t) {
12683
12723
  await n.changeParticipantState(e, r);
12684
12724
  }
12685
12725
  }
12686
- async function pc() {
12726
+ async function hc() {
12687
12727
  let e = $.current();
12688
12728
  e && await e.putHandsDown();
12689
12729
  }
12690
- async function mc(e) {
12730
+ async function gc(e) {
12691
12731
  let t = $.current();
12692
12732
  t && await t.updateDisplayLayout(e);
12693
12733
  }
12694
- async function hc(e) {
12734
+ async function _c(e) {
12695
12735
  let t = $.current();
12696
12736
  t && await t.requestDisplayLayout(e);
12697
12737
  }
12698
- async function gc(e, t, n = !1) {
12738
+ async function vc(e, t, n = !1) {
12699
12739
  let r = $.current()?.getCachedRawOkIdByExternalId(e) ?? null;
12700
12740
  if (!r) {
12701
12741
  R.warn("grantRoles: externalId not found in cache", e);
12702
12742
  return;
12703
12743
  }
12704
- return _c(r, Q.getDeviceIdx(e), t, n);
12744
+ return yc(r, Q.getDeviceIdx(e), t, n);
12705
12745
  }
12706
- async function _c(e, t, n, r = !1) {
12746
+ async function yc(e, t, n, r = !1) {
12707
12747
  let i = $.current();
12708
12748
  i && await i.grantRoles(j.composeParticipantId(e, A.USER, t), n, r);
12709
12749
  }
12710
- async function vc({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
12750
+ async function bc({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
12711
12751
  let i = null;
12712
- return e && (i = $.current()?.getCachedRawOkIdByExternalId(e) ?? null, i || R.warn("muteParticipant: externalId not found in cache", e)), yc({
12752
+ return e && (i = $.current()?.getCachedRawOkIdByExternalId(e) ?? null, i || R.warn("muteParticipant: externalId not found in cache", e)), xc({
12713
12753
  uid: i,
12714
12754
  muteStates: t,
12715
12755
  requestedMedia: n,
@@ -12717,129 +12757,129 @@ async function vc({ externalId: e = null, muteStates: t, requestedMedia: n = [],
12717
12757
  roomId: r
12718
12758
  });
12719
12759
  }
12720
- async function yc({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
12760
+ async function xc({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
12721
12761
  let a = $.current();
12722
12762
  if (a) {
12723
12763
  let o = e ? j.composeParticipantId(e, A.USER, r) : null;
12724
12764
  await a.muteParticipant(o, t, n, i);
12725
12765
  }
12726
12766
  }
12727
- async function bc(e, t = !1, n = null) {
12767
+ async function Sc(e, t = !1, n = null) {
12728
12768
  let r = $.current()?.getCachedRawOkIdByExternalId(e) ?? null;
12729
12769
  if (!r) {
12730
12770
  R.warn("pinParticipant: externalId not found in cache", e);
12731
12771
  return;
12732
12772
  }
12733
- return xc(r, t, Q.getDeviceIdx(e), n);
12773
+ return Cc(r, t, Q.getDeviceIdx(e), n);
12734
12774
  }
12735
- async function xc(e, t = !1, n = 0, r = null) {
12775
+ async function Cc(e, t = !1, n = 0, r = null) {
12736
12776
  let i = $.current();
12737
12777
  i && await i.pinParticipant(j.composeParticipantId(e, A.USER, n), t, r);
12738
12778
  }
12739
- async function Sc(e) {
12779
+ async function wc(e) {
12740
12780
  let t = $.current();
12741
12781
  t && await t.updateMediaModifiers(e);
12742
12782
  }
12743
- async function Cc(e) {
12783
+ async function Tc(e) {
12744
12784
  let t = $.current();
12745
12785
  t && await t.enableVideoSuspend(e);
12746
12786
  }
12747
- async function wc(e) {
12787
+ async function Ec(e) {
12748
12788
  let t = $.current();
12749
12789
  t && await t.enableVideoSuspendSuggest(e);
12750
12790
  }
12751
- async function Tc(e) {
12791
+ async function Dc(e) {
12752
12792
  let t = $.current();
12753
12793
  t && await t.changeOptions(e);
12754
12794
  }
12755
- async function Ec(e, t = null) {
12795
+ async function Oc(e, t = null) {
12756
12796
  let n = null;
12757
- return t && (n = $.current()?.getCachedRawOkIdByExternalId(t) ?? null, n || R.warn("chatMessage: externalId not found in cache", t)), Dc(e, n);
12797
+ return t && (n = $.current()?.getCachedRawOkIdByExternalId(t) ?? null, n || R.warn("chatMessage: externalId not found in cache", t)), kc(e, n);
12758
12798
  }
12759
- async function Dc(e, t = null) {
12799
+ async function kc(e, t = null) {
12760
12800
  let n = $.current();
12761
12801
  if (n) {
12762
12802
  let r = t ? j.composeUserId(t) : null;
12763
12803
  await n.chatMessage(e, r);
12764
12804
  }
12765
12805
  }
12766
- async function Oc(e = 10) {
12806
+ async function Ac(e = 10) {
12767
12807
  let t = $.current();
12768
12808
  if (t) return t.chatHistory(e);
12769
12809
  }
12770
- async function kc(e, t = null) {
12810
+ async function jc(e, t = null) {
12771
12811
  let n = null;
12772
- return t && (n = $.current()?.getCachedRawOkIdByExternalId(t) ?? null, n || R.warn("customData: externalId not found in cache", t)), Ac(e, n, Q.getDeviceIdx(t));
12812
+ return t && (n = $.current()?.getCachedRawOkIdByExternalId(t) ?? null, n || R.warn("customData: externalId not found in cache", t)), Mc(e, n, Q.getDeviceIdx(t));
12773
12813
  }
12774
- async function Ac(e, t = null, n = 0) {
12814
+ async function Mc(e, t = null, n = 0) {
12775
12815
  let r = $.current();
12776
12816
  if (r) {
12777
12817
  let i = t ? j.composeParticipantId(t, A.USER, n) : null;
12778
12818
  await r.customData(e, i);
12779
12819
  }
12780
12820
  }
12781
- async function jc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
12782
- return (await Ms.createConversation(a ?? j.uuid(), e, t, {
12821
+ async function Nc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
12822
+ return (await Ps.createConversation(a ?? j.uuid(), e, t, {
12783
12823
  onlyAdminCanShareMovie: n,
12784
12824
  waitForAdmin: r,
12785
12825
  closedConversation: i
12786
12826
  })).join_link;
12787
12827
  }
12788
- async function Mc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
12828
+ async function Pc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
12789
12829
  let a = i.map((e) => Q.fromId(e));
12790
- return (await Ms.createConversation(j.uuid(), e, t, {
12830
+ return (await Ps.createConversation(j.uuid(), e, t, {
12791
12831
  onlyAdminCanShareMovie: n,
12792
12832
  audienceMode: !0,
12793
12833
  audioOnly: r
12794
12834
  }, a)).join_link;
12795
12835
  }
12796
- async function Nc() {
12836
+ async function Fc() {
12797
12837
  let e = $.current();
12798
12838
  return e ? e.createJoinLink() : Promise.reject();
12799
12839
  }
12800
- async function Pc() {
12840
+ async function Ic() {
12801
12841
  let e = $.current();
12802
12842
  return e ? e.removeJoinLink() : Promise.reject();
12803
12843
  }
12804
- async function Fc(e, t) {
12805
- return Ms.getAnonymTokenByLink(e, t);
12844
+ async function Lc(e, t) {
12845
+ return Ps.getAnonymTokenByLink(e, t);
12806
12846
  }
12807
- function Ic(e) {
12847
+ function Rc(e) {
12808
12848
  let t = $.current();
12809
12849
  t && t.setVolume(e);
12810
12850
  }
12811
- function Lc(e) {
12851
+ function zc(e) {
12812
12852
  M.forceRelayPolicy = e;
12813
12853
  }
12814
- async function Rc(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
12854
+ async function Bc(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
12815
12855
  let o = $.current();
12816
12856
  return o ? o.startStream(e, t, n, r, i, a) : Promise.reject();
12817
12857
  }
12818
- async function zc(e = null, t) {
12858
+ async function Vc(e = null, t) {
12819
12859
  let n = $.current();
12820
12860
  return n ? n.stopStream(e, t) : Promise.reject();
12821
12861
  }
12822
- async function Bc(e = null) {
12862
+ async function Hc(e = null) {
12823
12863
  let t = $.current();
12824
12864
  return t ? t.publishStream(e) : Promise.reject();
12825
12865
  }
12826
- async function Vc() {
12866
+ async function Uc() {
12827
12867
  let e = $.current();
12828
12868
  return e ? e.getStreamInfo() : Promise.reject();
12829
12869
  }
12830
- async function Hc(e) {
12870
+ async function Wc(e) {
12831
12871
  let t = $.current();
12832
12872
  return t ? t.addMovie(e) : Promise.reject();
12833
12873
  }
12834
- async function Uc(e) {
12874
+ async function Gc(e) {
12835
12875
  let t = $.current();
12836
12876
  return t ? t.updateMovie(e) : Promise.reject();
12837
12877
  }
12838
- async function Wc(e) {
12878
+ async function Kc(e) {
12839
12879
  let t = $.current();
12840
12880
  return t ? t.removeMovie(e) : Promise.reject();
12841
12881
  }
12842
- async function Gc(e, t) {
12882
+ async function qc(e, t) {
12843
12883
  let n = $.current();
12844
12884
  if (n) {
12845
12885
  let r = [];
@@ -12864,11 +12904,11 @@ async function Gc(e, t) {
12864
12904
  }
12865
12905
  return Promise.reject();
12866
12906
  }
12867
- async function Kc(e, t) {
12907
+ async function Jc(e, t) {
12868
12908
  let n = $.current();
12869
12909
  return n ? n.activateRooms(e, t) : Promise.reject();
12870
12910
  }
12871
- async function qc(e = null, t = null) {
12911
+ async function Yc(e = null, t = null) {
12872
12912
  let n = $.current();
12873
12913
  if (!n) return Promise.reject();
12874
12914
  let r;
@@ -12883,25 +12923,25 @@ async function qc(e = null, t = null) {
12883
12923
  }
12884
12924
  return n.switchRoom(e, r);
12885
12925
  }
12886
- async function Jc(e) {
12926
+ async function Xc(e) {
12887
12927
  let t = $.current();
12888
12928
  return t ? t.removeRooms(e) : Promise.reject();
12889
12929
  }
12890
- function Yc(e) {
12930
+ function Zc(e) {
12891
12931
  M.statisticsInterval = e;
12892
12932
  let t = $.current();
12893
12933
  if (t) return t.updateStatisticsInterval();
12894
12934
  }
12895
- function Xc(t) {
12935
+ function Qc(t) {
12896
12936
  e.disableLog(!t), R.toggle(t);
12897
12937
  }
12898
- function Zc(e, ...t) {
12938
+ function $c(e, ...t) {
12899
12939
  M.debugLog && ($.debugMessage(e, "[external]", ...t) || R.send(e, "[external]", ...t));
12900
12940
  }
12901
- function Qc(e, t, ...n) {
12941
+ function el(e, t, ...n) {
12902
12942
  M.debugLog && ($.debugMessageWithContext(e, t, "[external]", ...n) || R.send(e, "[external]", ...n));
12903
12943
  }
12904
- var $c = {
12944
+ var tl = {
12905
12945
  list: Ne,
12906
12946
  get: Pe,
12907
12947
  getJson: Fe,
@@ -12909,7 +12949,7 @@ var $c = {
12909
12949
  clear: Le,
12910
12950
  stats: Re
12911
12951
  };
12912
- function el() {
12952
+ function nl() {
12913
12953
  let e = [
12914
12954
  [`Calls SDK ${M.sdkVersion}`, M.toJSON()],
12915
12955
  ["UserAgent:", navigator.userAgent],
@@ -12926,31 +12966,31 @@ function el() {
12926
12966
  d: e
12927
12967
  }));
12928
12968
  }
12929
- async function tl() {
12969
+ async function rl() {
12930
12970
  let e = $.id(), t = $.debugSessionId();
12931
12971
  if (!t || !e) throw R.error("[uploadDebugLogs]", "No conversation id found"), Error("No conversation id found");
12932
12972
  let n = await Pe({ sessionId: t });
12933
12973
  if (n.length === 0) throw R.error("[uploadDebugLogs]", "No logs found"), Error("No logs found");
12934
12974
  let r = n[0].t, i = n[n.length - 1].t;
12935
12975
  try {
12936
- return Ms?.uploadDebugLogs(e, r, i, JSON.stringify([...el(), ...n]));
12976
+ return Ps?.uploadDebugLogs(e, r, i, JSON.stringify([...nl(), ...n]));
12937
12977
  } catch (e) {
12938
12978
  throw R.error("[uploadDebugLogs]", "Error while uploading logs", e), Error("Error while uploading logs", { cause: e });
12939
12979
  }
12940
12980
  }
12941
- async function nl(e) {
12981
+ async function il(e) {
12942
12982
  let t = $.current();
12943
12983
  if (t) return t.videoEffect(e);
12944
12984
  }
12945
- async function rl(e, t) {
12985
+ async function al(e, t) {
12946
12986
  let n = $.current();
12947
12987
  if (n) return n.audioEffect(e.length > 0 ? e : null, t);
12948
12988
  }
12949
- async function il(e) {
12989
+ async function ol(e) {
12950
12990
  let t = $.current();
12951
12991
  t && await t.setAudioStream(e);
12952
12992
  }
12953
- async function al(e, t = null, n = null) {
12993
+ async function sl(e, t = null, n = null) {
12954
12994
  let r = $.current();
12955
12995
  if (!r) return;
12956
12996
  let i = n ?? t?.id, a = null;
@@ -12961,18 +13001,18 @@ async function al(e, t = null, n = null) {
12961
13001
  }
12962
13002
  r.setAnimojiSvg(e, a, i);
12963
13003
  }
12964
- function ol(e) {
13004
+ function cl(e) {
12965
13005
  let t = $.current();
12966
13006
  t && t.setAnimojiFill(e);
12967
13007
  }
12968
- async function sl(e = null, t, n = !1) {
12969
- return _l().getWaitingHall(e, t, n);
13008
+ async function ll(e = null, t, n = !1) {
13009
+ return yl().getWaitingHall(e, t, n);
12970
13010
  }
12971
- async function cl() {
12972
- return _l().getAudienceModeHands();
13011
+ async function ul() {
13012
+ return yl().getAudienceModeHands();
12973
13013
  }
12974
- async function ll(e, t = !1) {
12975
- let n = _l(), r;
13014
+ async function dl(e, t = !1) {
13015
+ let n = yl(), r;
12976
13016
  if (e) {
12977
13017
  let t = n.getCachedRawOkIdByExternalId(e);
12978
13018
  if (!t) {
@@ -12983,67 +13023,67 @@ async function ll(e, t = !1) {
12983
13023
  }
12984
13024
  return n.promoteParticipant(r, t);
12985
13025
  }
12986
- async function ul(e = !1) {
12987
- return _l().requestPromotion(e);
13026
+ async function fl(e = !1) {
13027
+ return yl().requestPromotion(e);
12988
13028
  }
12989
- async function dl(e = !1) {
12990
- return _l().acceptPromotion(e);
13029
+ async function pl(e = !1) {
13030
+ return yl().acceptPromotion(e);
12991
13031
  }
12992
- async function fl(e) {
12993
- return _l().getParticipantListChunk(e);
13032
+ async function ml(e) {
13033
+ return yl().getParticipantListChunk(e);
12994
13034
  }
12995
- async function pl(e) {
12996
- return _l().getParticipants(e);
13035
+ async function hl(e) {
13036
+ return yl().getParticipants(e);
12997
13037
  }
12998
- async function ml(e) {
12999
- return _l().feedback(e);
13038
+ async function gl(e) {
13039
+ return yl().feedback(e);
13000
13040
  }
13001
- async function hl(e, t, n) {
13002
- return _l(n).enableFeatureForRoles(e, t);
13041
+ async function _l(e, t, n) {
13042
+ return yl(n).enableFeatureForRoles(e, t);
13003
13043
  }
13004
- function gl(e) {
13044
+ function vl(e) {
13005
13045
  return e ? z.get(e) ?? null : $.current() ?? z.getFirst();
13006
13046
  }
13007
- function _l(e) {
13008
- let t = gl(e);
13047
+ function yl(e) {
13048
+ let t = vl(e);
13009
13049
  if (!t) throw Error("Conversation not found");
13010
13050
  return t;
13011
13051
  }
13012
- async function vl(e) {
13013
- await Ms.removeHistoryRecords(e);
13052
+ async function bl(e) {
13053
+ await Ps.removeHistoryRecords(e);
13014
13054
  }
13015
- async function yl(e) {
13055
+ async function xl(e) {
13016
13056
  let t = $.current() ?? z.getFirst();
13017
13057
  t && await t.startAsr(e);
13018
13058
  }
13019
- async function bl(e) {
13059
+ async function Sl(e) {
13020
13060
  let t = $.current() ?? z.getFirst();
13021
13061
  t && await t.stopAsr(e);
13022
13062
  }
13023
- async function xl(e) {
13063
+ async function Cl(e) {
13024
13064
  let t = $.current() ?? z.getFirst();
13025
13065
  t && await t.requestAsr(e);
13026
13066
  }
13027
- async function Sl(e) {
13067
+ async function wl(e) {
13028
13068
  let t = $.current();
13029
13069
  return t ? t.startUrlSharing(e) : Promise.reject();
13030
13070
  }
13031
- async function Cl() {
13071
+ async function Tl() {
13032
13072
  let e = $.current();
13033
13073
  return e ? e.stopUrlSharing() : Promise.reject();
13034
13074
  }
13035
- async function wl(e) {
13075
+ async function El(e) {
13036
13076
  await z.switchCall(e);
13037
13077
  }
13038
- function Tl() {
13078
+ function Dl() {
13039
13079
  return z.getActiveId();
13040
13080
  }
13041
- function El() {
13081
+ function Ol() {
13042
13082
  return $.getSyncedTime();
13043
13083
  }
13044
- function Dl() {
13084
+ function kl() {
13045
13085
  return M.sdkVersion;
13046
13086
  }
13047
13087
  typeof window < "u" && (window.__CALLS_SDK = hn);
13048
13088
  //#endregion
13049
- export { Ts as Api, js as ApiExternal, As as ArrayDequeue, y as AuthData, f as BaseLogger, Pa as CallDirection, Fa as CallType, Ia as ChatRoomEventType, La as ConversationFeature, Ra as ConversationOption, vn as DebugMessageType, Ya as ExternalIdType, jt as FacingMode, x as FatalError, O as HangupReason, D as HangupType, S as MediaOption, k as MediaTrackKind, V as MediaType, Va as MuteState, Z as ParticipantState, ks as ParticipantStateDataValue, N as ParticipantStatus, Os as RecordRole, Ha as RoomsEventType, Na as Signaling, B as SignalingCommandType, pr as SignalingConnectionType, K as SignalingNotification, J as TransportTopology, Ga as UserRole, A as UserType, vo as VolumeDetector, Js as acceptCall, dl as acceptPromotion, Kc as activateRooms, Hc as addMovie, ec as addParticipant, tc as addParticipantInternal, qs as authorize, Ps as browser, Us as callInternal, Hs as callTo, ac as captureScreen, oc as captureVmoji, rl as changeAudioEffect, Tc as changeConversationOptions, ic as changeDevice, fc as changeParticipantState, dc as changePriorities, nl as changeVideoEffect, Oc as chatHistory, Ec as chatMessage, Dc as chatMessageInternal, Nc as createJoinLink, kc as customData, Ac as customDataInternal, Xc as debug, $c as debugLogs, Zc as debugMessage, Qc as debugMessageWithContext, Ys as declineCall, hl as enableFeatureForRoles, Cc as enableVideoSuspend, wc as enableVideoSuspendSuggest, ml as feedback, Lc as forceRelayPolicy, Tl as getActiveCallId, Fc as getAnonymTokenByLink, cl as getAudienceModeHands, Ks as getInbounds, fl as getParticipantListChunk, pl as getParticipants, Vc as getStreamInfo, El as getSyncedTime, sl as getWaitingHall, gc as grantRoles, _c as grantRolesInternal, $s as hangup, Vs as init, Xs as joinCall, Qs as joinCallByLink, Zs as joinCallInternal, vc as muteParticipant, yc as muteParticipantInternal, bc as pinParticipant, xc as pinParticipantInternal, Ws as processPush, Gs as processPushInternal, ll as promoteParticipant, Bc as publishStream, pc as putHandsDown, vl as removeHistoryRecords, Pc as removeJoinLink, Wc as removeMovie, nc as removeParticipant, rc as removeParticipantInternal, Jc as removeRooms, xl as requestAsr, hc as requestDisplayLayout, ul as requestPromotion, Rs as setAudioEffects, il as setAudioStream, uc as setLocalResolution, Is as setLogger, Sc as setMediaModifiers, Yc as setStatisticsInterval, zs as setVad, Ls as setVideoEffects, sc as setVideoStream, Bs as setVmoji, ol as setVmojiFill, al as setVmojiSvg, Ic as setVolume, yl as startAsr, Mc as startAudienceConversation, jc as startConversation, Rc as startStream, Sl as startUrlSharing, bl as stopAsr, zc as stopStream, Cl as stopUrlSharing, wl as switchCall, qc as switchRoom, lc as toggleLocalAudio, cc as toggleLocalVideo, mc as updateDisplayLayout, Uc as updateMovie, Gc as updateRooms, tl as uploadDebugLogs, Fs as utils, Dl as version };
13089
+ export { Ds as Api, Ns as ApiExternal, Ms as ArrayDequeue, y as AuthData, f as BaseLogger, Pa as CallDirection, Fa as CallType, Ia as ChatRoomEventType, La as ConversationFeature, Ra as ConversationOption, vn as DebugMessageType, Ya as ExternalIdType, jt as FacingMode, x as FatalError, O as HangupReason, D as HangupType, S as MediaOption, k as MediaTrackKind, V as MediaType, Va as MuteState, Z as ParticipantState, js as ParticipantStateDataValue, N as ParticipantStatus, As as RecordRole, Ha as RoomsEventType, Na as Signaling, B as SignalingCommandType, pr as SignalingConnectionType, K as SignalingNotification, J as TransportTopology, Ga as UserRole, A as UserType, vo as VolumeDetector, Xs as acceptCall, pl as acceptPromotion, Jc as activateRooms, Wc as addMovie, nc as addParticipant, rc as addParticipantInternal, Ys as authorize, Is as browser, Gs as callInternal, Ws as callTo, sc as captureScreen, cc as captureVmoji, al as changeAudioEffect, Dc as changeConversationOptions, oc as changeDevice, mc as changeParticipantState, pc as changePriorities, il as changeVideoEffect, Ac as chatHistory, Oc as chatMessage, kc as chatMessageInternal, Fc as createJoinLink, jc as customData, Mc as customDataInternal, Qc as debug, tl as debugLogs, $c as debugMessage, el as debugMessageWithContext, Zs as declineCall, _l as enableFeatureForRoles, Tc as enableVideoSuspend, Ec as enableVideoSuspendSuggest, gl as feedback, zc as forceRelayPolicy, Dl as getActiveCallId, Lc as getAnonymTokenByLink, ul as getAudienceModeHands, Js as getInbounds, ml as getParticipantListChunk, hl as getParticipants, Uc as getStreamInfo, Ol as getSyncedTime, ll as getWaitingHall, vc as grantRoles, yc as grantRolesInternal, tc as hangup, Us as init, Qs as joinCall, ec as joinCallByLink, $s as joinCallInternal, bc as muteParticipant, xc as muteParticipantInternal, Sc as pinParticipant, Cc as pinParticipantInternal, Ks as processPush, qs as processPushInternal, dl as promoteParticipant, Hc as publishStream, hc as putHandsDown, bl as removeHistoryRecords, Ic as removeJoinLink, Kc as removeMovie, ic as removeParticipant, ac as removeParticipantInternal, Xc as removeRooms, Cl as requestAsr, _c as requestDisplayLayout, fl as requestPromotion, Bs as setAudioEffects, ol as setAudioStream, fc as setLocalResolution, Rs as setLogger, wc as setMediaModifiers, Zc as setStatisticsInterval, Vs as setVad, zs as setVideoEffects, lc as setVideoStream, Hs as setVmoji, cl as setVmojiFill, sl as setVmojiSvg, Rc as setVolume, xl as startAsr, Pc as startAudienceConversation, Nc as startConversation, Bc as startStream, wl as startUrlSharing, Sl as stopAsr, Vc as stopStream, Tl as stopUrlSharing, El as switchCall, Yc as switchRoom, dc as toggleLocalAudio, uc as toggleLocalVideo, gc as updateDisplayLayout, Gc as updateMovie, qc as updateRooms, rl as uploadDebugLogs, Ls as utils, kl as version };