@vkontakte/calls-sdk 2.8.13-dev.ab19d582.0 → 2.8.13-dev.af6936c9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/calls-sdk.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * @vkontakte/calls-sdk v2.8.13-dev.ab19d582.0
3
- * Wed, 09 Sep 2026 14:22:53 GMT
2
+ * @vkontakte/calls-sdk v2.8.13-dev.af6936c9.0
3
+ * Fri, 18 Sep 2026 12:55:32 GMT
4
4
  * https://calls-sdk.cdn-vk.ru/doc/latest/index.html
5
5
  */
6
6
 
@@ -2152,10 +2152,13 @@ var yn = vn.getInstance(), M = class e {
2152
2152
  return "ok.calls.sdk.js";
2153
2153
  }
2154
2154
  static get appVersion() {
2155
+ return e._params.appVersion;
2156
+ }
2157
+ static get apiClientVersion() {
2155
2158
  return 1.1;
2156
2159
  }
2157
2160
  static get sdkVersion() {
2158
- return "2.8.13-dev.ab19d582.0";
2161
+ return "2.8.13-dev.af6936c9.0";
2159
2162
  }
2160
2163
  static get debug() {
2161
2164
  return e._params.debug;
@@ -2578,6 +2581,7 @@ var yn = vn.getInstance(), M = class e {
2578
2581
  movieShare: e._params.movieShare,
2579
2582
  clientType: e._params.clientType,
2580
2583
  clientStatsPlatform: e._params.clientStatsPlatform,
2584
+ appVersion: e._params.appVersion,
2581
2585
  consumerScreenDataChannelPacketSize: e._params.consumerScreenDataChannelPacketSize,
2582
2586
  switchVideoAtBadNetwork: e._params.switchVideoAtBadNetwork,
2583
2587
  simulcast: e._params.simulcast,
@@ -2593,6 +2597,7 @@ var yn = vn.getInstance(), M = class e {
2593
2597
  h(M, "_params", {
2594
2598
  platform: "WEB",
2595
2599
  clientStatsPlatform: "",
2600
+ appVersion: "0.0.0",
2596
2601
  clientType: "PORTAL",
2597
2602
  externalUserType: "",
2598
2603
  device: "browser",
@@ -3065,6 +3070,10 @@ var xn;
3065
3070
  P("onPeerRegistered", e, t);
3066
3071
  }
3067
3072
  e.onPeerRegistered = ot;
3073
+ function st(e, t) {
3074
+ P("onNonFatalError", e, t);
3075
+ }
3076
+ e.onNonFatalError = st;
3068
3077
  })(xn || (xn = {}));
3069
3078
  var L = xn, Sn = /* @__PURE__ */ function(e) {
3070
3079
  return e.DEBUG = "DEBUG", e.LOG = "LOG", e.WARN = "WARN", e.ERROR = "ERROR", e;
@@ -4916,7 +4925,7 @@ var Qr = class {
4916
4925
  }
4917
4926
  }, ui = class extends oi {
4918
4927
  constructor(e, t, n, r, i, a = R, o = null) {
4919
- super(e, t, n, r, i, a), h(this, "_renderer", void 0), h(this, "_decoder", void 0), h(this, "_decoderReady", !1), h(this, "_decoderBusy", !1), h(this, "_decoderQueue", []), h(this, "_fpsMeter", void 0), h(this, "_logger", void 0), this._logger = o, this._debug.debug(`StreamBuilder started for participant [${e}]`), this._initFpsMeter(), this._initRenderer(), this._initDecoder();
4928
+ super(e, t, n, r, i, a), h(this, "_renderer", void 0), h(this, "_decoder", void 0), h(this, "_decoderReady", !1), h(this, "_decoderBusy", !1), h(this, "_decoderQueue", []), h(this, "_webCodecsRetryAttempted", !1), h(this, "_fpsMeter", void 0), h(this, "_logger", void 0), this._logger = o, this._debug.debug(`StreamBuilder started for participant [${e}]`), this._initFpsMeter(), this._initRenderer(), this._initDecoder();
4920
4929
  }
4921
4930
  _processFrame(e) {
4922
4931
  e.keyframe && (this._decoderQueue = []), this._decoderQueue.push(e), this._decodeQueue();
@@ -4931,7 +4940,11 @@ var Qr = class {
4931
4940
  e || !ti.isBrowserSupported() ? this._decoder = new ei(this._debug, this._logger) : this._decoder = new ti(this._debug, this._logger), this._decoder.init(async (e) => {
4932
4941
  this._decoderBusy = !1, "VideoFrame" in window && e instanceof VideoFrame ? await this._renderer.drawFrame(e) : await this._renderer.drawImage(e), this._fpsMeter.increment(), this._decodeQueue();
4933
4942
  }, (e) => {
4934
- this._decoderBusy = !1, this._decodeQueue(), this._decoder instanceof ti && typeof e == "string" && e.includes("EncodingError") && this._switchToLibVPXDecoder();
4943
+ if (this._decoderBusy = !1, this._decoder instanceof ti && typeof e == "string" && e.includes("EncodingError")) {
4944
+ this._decoderQueue = [], !this._webCodecsRetryAttempted && e.includes("reset because error during decoding") ? (this._webCodecsRetryAttempted = !0, this._debug.warn("StreamBuilder retry WebCodecs with software decoder"), this._onKeyFrameRequested?.()) : this._switchToLibVPXDecoder();
4945
+ return;
4946
+ }
4947
+ this._decodeQueue();
4935
4948
  }, this._onKeyFrameRequested).then(() => {
4936
4949
  this._decoderReady = !0, this._decodeQueue();
4937
4950
  }).catch((e) => {
@@ -4939,7 +4952,7 @@ var Qr = class {
4939
4952
  });
4940
4953
  }
4941
4954
  _switchToLibVPXDecoder() {
4942
- this._debug.warn("StreamBuilder switch to LibVPX decoder"), this._fpsMeter && this._fpsMeter.destroy(), this._decoder && (this._decoderReady = !1, this._decoderBusy = !1, this._decoder.destroy()), this._renderer && this._renderer.destroy(), this._initFpsMeter(), this._initRenderer(!0), this._initDecoder(!0);
4955
+ this._debug.warn("StreamBuilder switch to LibVPX decoder"), this._decoderQueue = [], this._fpsMeter && this._fpsMeter.destroy(), this._decoder && (this._decoderReady = !1, this._decoderBusy = !1, this._decoder.destroy()), this._renderer && this._renderer.destroy(), this._initFpsMeter(), this._initRenderer(!0), this._initDecoder(!0), this._onKeyFrameRequested?.();
4943
4956
  }
4944
4957
  _decodeQueue() {
4945
4958
  if (!this._decoderReady || this._decoderBusy) return;
@@ -5838,7 +5851,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5838
5851
  this._perfStatReporter?.destroy(), this._perfStatReporter = new pa(this, this._signaling, this._statAggregator, !1, this._debug);
5839
5852
  }
5840
5853
  _closeConnection() {
5841
- this._signaling.resetProducerConnection(), this._disposeFirstMediaSentProbe(), this._stopStatInterval(), this._stopSettingsInterval(), this._stopMonitorRtpShareInterval(), this._removeAsrTrack(), this._removeCaptureSender(), this._removeCaptureReceiver(), this._simulcast.reset(), this._pc && (this._rtpReceiversByStreamId = {}, this._disabledSenders.forEach((e) => e.track?.stop()), this._disabledSenders.clear(), this._pc.ontrack = null, this._pc.onconnectionstatechange = null, this._pc.onsignalingstatechange = null, this._participantIdRegistry = null, e._closeDataChannel(this._producerNotification), e._closeDataChannel(this._producerCommand), e._closeDataChannel(this._producerScreen), e._closeDataChannel(this._consumerScreen), e._closeDataChannel(this._asr), e._closeDataChannel(this._animojiDataChannel), this._pc.close(), this._pc = null, this._producerOfferIsProcessing = !1, this._producerNextOffer = null), this._triggerEvent(X.PEER_CONNECTION_CLOSED);
5854
+ this._signaling.resetProducerConnection(), this._ssrcMap = {}, this._ssrcMapUpdated = !0, this._disposeFirstMediaSentProbe(), this._stopStatInterval(), this._stopSettingsInterval(), this._stopMonitorRtpShareInterval(), this._removeAsrTrack(), this._removeCaptureSender(), this._removeCaptureReceiver(), this._simulcast.reset(), this._pc && (this._rtpReceiversByStreamId = {}, this._disabledSenders.forEach((e) => e.track?.stop()), this._disabledSenders.clear(), this._pc.ontrack = null, this._pc.onconnectionstatechange = null, this._pc.onsignalingstatechange = null, this._participantIdRegistry = null, e._closeDataChannel(this._producerNotification), e._closeDataChannel(this._producerCommand), e._closeDataChannel(this._producerScreen), e._closeDataChannel(this._consumerScreen), e._closeDataChannel(this._asr), e._closeDataChannel(this._animojiDataChannel), this._pc.close(), this._pc = null, this._producerOfferIsProcessing = !1, this._producerNextOffer = null), this._triggerEvent(X.PEER_CONNECTION_CLOSED);
5842
5855
  }
5843
5856
  static _closeDataChannel(e) {
5844
5857
  e && (e.onopen = null, e.onmessage = null, e.onerror = null, e.close());
@@ -5908,10 +5921,10 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5908
5921
  this._triggerEvent(X.NETWORK_STATUS, e);
5909
5922
  }
5910
5923
  _updateSSRCMap(e) {
5911
- e && ln(e.sdp).forEach((e) => {
5924
+ e && (this._ssrcMap = {}, this._ssrcMapUpdated = !0, ln(e.sdp).forEach((e) => {
5912
5925
  let t = `a=ssrc:([0-9]+) label:(audio|video)-((?:[ug]?[\\d]+)|(?:mix)|(?:${qr.PARTICIPANT_AGNOSTIC_TRACK_PREFIX}-[0-9]+)|(?:${qr.TRANSPARENT_AUDIO_TRACK_PREFIX}-[0-9]+))`, n = new RegExp(t).exec(e);
5913
- n && (this._ssrcMap[n[1]] = n[3], this._ssrcMapUpdated = !0);
5914
- });
5926
+ n && (this._ssrcMap[n[1]] = n[3]);
5927
+ }));
5915
5928
  }
5916
5929
  _createCaptureSender(e) {
5917
5930
  let t = this._mediaSource.mediaSettings;
@@ -6987,7 +7000,7 @@ var ya = va, ba = {
6987
7000
  }
6988
7001
  _buildUrl(e, t) {
6989
7002
  let n = new URL(e), r = n.searchParams;
6990
- return r.set("platform", M.platform), r.set("appVersion", String(M.appVersion)), r.set("version", String(M.protocolVersion)), r.set("device", M.device), r.set("capabilities", xa.getFlags()), r.set("clientType", M.clientType), this.connectionType && r.set("tgt", this.connectionType), this.connectionType === vr.RETRY && this.lastStamp && r.set("recoverTs", String(this.lastStamp)), M.useParticipantListChunk && (r.set("partIdx", String(M.participantListChunkInitIndex)), M.participantListChunkInitCount !== null && r.set("partCount", String(M.participantListChunkInitCount))), t && (r.set("compression", "deflate-raw"), r.set("ua", navigator.userAgent)), this.peerId !== null && r.set("peerId", String(this.peerId)), n.toString();
7003
+ return r.set("platform", M.platform), r.set("appVersion", M.appVersion), r.set("version", String(M.protocolVersion)), r.set("device", M.device), r.set("capabilities", xa.getFlags()), r.set("clientType", M.clientType), this.connectionType && r.set("tgt", this.connectionType), this.connectionType === vr.RETRY && this.lastStamp && r.set("recoverTs", String(this.lastStamp)), M.useParticipantListChunk && (r.set("partIdx", String(M.participantListChunkInitIndex)), M.participantListChunkInitCount !== null && r.set("partCount", String(M.participantListChunkInitCount))), t && (r.set("compression", "deflate-raw"), r.set("ua", navigator.userAgent)), this.peerId !== null && r.set("peerId", String(this.peerId)), n.toString();
6991
7004
  }
6992
7005
  _canUseWebTransport() {
6993
7006
  return !this.forceWebSocket && Aa.isBrowserSupported() && this.wtEndpoint !== null && M.webtransport;
@@ -8251,8 +8264,8 @@ var bo = 90, xo = 3, So = class extends b {
8251
8264
  t > bo ? this._debug.warn(`High memory usage: ${t}% (${n} MiB)`) : (!this._lastMemoryStat.percent || Math.abs(t - this._lastMemoryStat.percent) >= xo) && (this._debug.debug(`Memory usage: ${t}% (${n} MiB)`), this._lastMemoryStat.percent = t, this._lastMemoryStat.bytes = e.usedJSHeapSize);
8252
8265
  }
8253
8266
  }, Co = class {
8254
- constructor({ api: e, debug: t, getParticipants: n, isMe: r, updateDisplayLayout: i }) {
8255
- h(this, "_api", void 0), h(this, "_debug", void 0), h(this, "_getParticipants", void 0), h(this, "_isMe", void 0), h(this, "_updateDisplayLayout", void 0), h(this, "_requestedLayouts", {}), h(this, "_uncertainLayouts", {}), h(this, "_pendingRequests", null), h(this, "_pendingPromises", []), h(this, "_lastRequests", null), h(this, "_timer", null), h(this, "_inFlight", !1), h(this, "_lastFlushAt", null), h(this, "_generation", 0), h(this, "_forceNextFlush", !1), this._api = e, this._debug = t, this._getParticipants = n, this._isMe = r, this._updateDisplayLayout = i;
8267
+ constructor({ api: e, debug: t, getParticipants: n, isMe: r, updateDisplayLayout: i, onNonFatalError: a }) {
8268
+ h(this, "_api", void 0), h(this, "_debug", void 0), h(this, "_getParticipants", void 0), h(this, "_isMe", void 0), h(this, "_updateDisplayLayout", void 0), h(this, "_onNonFatalError", void 0), h(this, "_requestedLayouts", {}), h(this, "_uncertainLayouts", {}), h(this, "_pendingRequests", null), h(this, "_pendingPromises", []), h(this, "_lastRequests", null), h(this, "_timer", null), h(this, "_inFlight", !1), h(this, "_lastFlushAt", null), h(this, "_generation", 0), h(this, "_forceNextFlush", !1), this._api = e, this._debug = t, this._getParticipants = n, this._isMe = r, this._updateDisplayLayout = i, this._onNonFatalError = a;
8256
8269
  }
8257
8270
  request(e) {
8258
8271
  this._pendingRequests = e.slice(), this._lastRequests = e.slice();
@@ -8288,11 +8301,16 @@ var bo = 90, xo = 3, So = class extends b {
8288
8301
  this._pendingRequests = null, this._pendingPromises = [];
8289
8302
  let r = {};
8290
8303
  try {
8291
- r = this._getRequestLayouts(t);
8292
- let i = this._forceNextFlush || Object.keys(this._uncertainLayouts).length > 0;
8304
+ let i = this._getRequestLayouts(t);
8305
+ if (!i) {
8306
+ n.forEach(({ resolve: e }) => e());
8307
+ return;
8308
+ }
8309
+ r = i;
8310
+ let a = this._forceNextFlush || Object.keys(this._uncertainLayouts).length > 0;
8293
8311
  this._forceNextFlush = !1;
8294
- let a = this._getDiff(r, i);
8295
- a.length && await this._updateDisplayLayout(a), e === this._generation && (this._requestedLayouts = r, this._uncertainLayouts = {}), n.forEach(({ resolve: e }) => e());
8312
+ let o = this._getDiff(r, a);
8313
+ o.length && await this._updateDisplayLayout(o), e === this._generation && (this._requestedLayouts = r, this._uncertainLayouts = {}), n.forEach(({ resolve: e }) => e());
8296
8314
  } catch (t) {
8297
8315
  e === this._generation ? (this._uncertainLayouts = {
8298
8316
  ...this._uncertainLayouts,
@@ -8303,30 +8321,30 @@ var bo = 90, xo = 3, So = class extends b {
8303
8321
  }
8304
8322
  }
8305
8323
  _getRequestLayouts(e) {
8306
- let t = {}, n = this._getParticipants();
8307
- for (let r of e) {
8308
- let e = typeof r.uid == "object" ? r.uid : Q.fromId(r.uid), i = this._api.getCachedOkIdByExternalId(e);
8309
- if (!i) {
8310
- this._debug.log(`Unknown participant external ID ${typeof r.uid == "object" ? Q.toString(r.uid) : r.uid}`);
8324
+ let t = {}, n = [], r = this._getParticipants();
8325
+ for (let i of e) {
8326
+ let e = typeof i.uid == "object" ? i.uid : Q.fromId(i.uid), a = this._api.getCachedParticipantIdByExternalId(e);
8327
+ if (!a) {
8328
+ this._debug.log(`Unknown participant external ID ${typeof i.uid == "object" ? Q.toString(i.uid) : i.uid}`), n.push(e.id);
8311
8329
  continue;
8312
8330
  }
8313
- if (!n[i] && !this._isMe(i)) continue;
8314
- let a = Mn({
8315
- participantId: i,
8316
- mediaType: r.mediaType,
8317
- streamName: r.streamName
8331
+ if (!r[a] && !this._isMe(a)) continue;
8332
+ let o = Mn({
8333
+ participantId: a,
8334
+ mediaType: i.mediaType,
8335
+ streamName: i.streamName
8318
8336
  });
8319
- t[a] = {
8320
- uid: r.uid,
8321
- mediaType: r.mediaType,
8322
- width: r.width,
8323
- height: r.height,
8324
- fit: r.cover ? "cv" : "cn",
8325
- ...r.priority === void 0 ? {} : { priority: r.priority },
8326
- ...r.streamName === void 0 ? {} : { streamName: r.streamName }
8337
+ t[o] = {
8338
+ uid: i.uid,
8339
+ mediaType: i.mediaType,
8340
+ width: i.width,
8341
+ height: i.height,
8342
+ fit: i.cover ? "cv" : "cn",
8343
+ ...i.priority === void 0 ? {} : { priority: i.priority },
8344
+ ...i.streamName === void 0 ? {} : { streamName: i.streamName }
8327
8345
  };
8328
8346
  }
8329
- return t;
8347
+ return n.length ? (this._onNonFatalError(`Participant ID mapping not found for external IDs "${Array.from(new Set(n)).join("\", \"")}" while handling requestDisplayLayout`), null) : t;
8330
8348
  }
8331
8349
  _getDiff(e, t = !1) {
8332
8350
  let n = [];
@@ -8475,9 +8493,8 @@ var bo = 90, xo = 3, So = class extends b {
8475
8493
  this._triggerEvent("VOLUMES_DETECTED", e);
8476
8494
  }
8477
8495
  _getAudioTrackLevelByParticipantId(e) {
8478
- if (this._isTransparentAudioMode()) return this._getTransparentAudioLevelByParticipantId(e);
8479
8496
  let t = this._detectors.get(qr.AUDIO_MIX);
8480
- return t ? t.getLevel() : null;
8497
+ return t ? t.getLevel() : this._getTransparentAudioLevelByParticipantId(e);
8481
8498
  }
8482
8499
  _getTransparentAudioLevelByParticipantId(e) {
8483
8500
  if (!this._activeParticipants?.includes(e)) return null;
@@ -8494,9 +8511,6 @@ var bo = 90, xo = 3, So = class extends b {
8494
8511
  _onTopologyChanged(e) {
8495
8512
  this._topology = e, this._destroyDetectors(), e === J.DIRECT && (this._activeParticipants = null, this._removedParticipants = null);
8496
8513
  }
8497
- _isTransparentAudioMode() {
8498
- return this._topology === J.SERVER && M.transparentAudio;
8499
- }
8500
8514
  _destroyDetectors() {
8501
8515
  this._detectors.forEach((e) => {
8502
8516
  e.destroy();
@@ -9348,7 +9362,8 @@ var ls = 15, $ = class e extends b {
9348
9362
  debug: this._debug,
9349
9363
  getParticipants: () => this._participants,
9350
9364
  isMe: (e) => this._isMe(e),
9351
- updateDisplayLayout: (e) => this.updateDisplayLayout(e)
9365
+ updateDisplayLayout: (e) => this.updateDisplayLayout(e),
9366
+ onNonFatalError: (e) => this._onNonFatalError(e)
9352
9367
  }), this._onUnload = () => {
9353
9368
  this._stopFirstMediaSentProbe(), this._conversation && this._api && this._sendHangupApi(this._conversation.id, this._state === "IDLE" ? D.CANCELED : D.HUNGUP), this._stats.destroy();
9354
9369
  }, window.addEventListener("pagehide", this._onUnload), this._statFirstMediaReceived = new as(this._stats.statAggregator), this._audioOutput = new go(this._statFirstMediaReceived, M.transparentAudio, this._debug, this._stats.logger), M.videoTracksCount > 0 && (this._cooldownQueueCleanupTimer = window.setInterval(this._cleanupCooldownQueue.bind(this), os));
@@ -9384,6 +9399,9 @@ var ls = 15, $ = class e extends b {
9384
9399
  get isCallHeld() {
9385
9400
  return this._state === "HELD";
9386
9401
  }
9402
+ get isIncomingRinging() {
9403
+ return this._conversation?.direction === Ba.INCOMING && this._state === "IDLE";
9404
+ }
9387
9405
  static debugSessionId() {
9388
9406
  return e.current()?.debugSessionId ?? null;
9389
9407
  }
@@ -9401,8 +9419,14 @@ var ls = 15, $ = class e extends b {
9401
9419
  get debugSessionId() {
9402
9420
  return this._debug.sessionId;
9403
9421
  }
9404
- getCachedRawOkIdByExternalId(e) {
9405
- return this._api.getCachedRawOkIdByExternalId(e);
9422
+ getCachedParticipantIdByExternalId(e) {
9423
+ return this._api.getCachedParticipantIdByExternalId(e);
9424
+ }
9425
+ _onNonFatalError(e) {
9426
+ L.onNonFatalError(Error(e), this.id);
9427
+ }
9428
+ getIncomingCallerExternalId() {
9429
+ return this._conversation?.direction === Ba.INCOMING ? Object.values(this._participants).find((e) => !this._isMe(e.id))?.externalId ?? null : null;
9406
9430
  }
9407
9431
  _buildInternalParams() {
9408
9432
  let e = {
@@ -9445,11 +9469,15 @@ var ls = 15, $ = class e extends b {
9445
9469
  description: "not-initialized-after-start"
9446
9470
  } });
9447
9471
  if (this._participantState = Z.ACCEPTED, this._changeMediaSettings(l), await this._processConnection(d), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), this._signaling.readyToSend(), this._delayedHangup) throw new O(D.CANCELED);
9448
- return this._debug.debug("Outgoing call", {
9472
+ if (this._debug.debug("Outgoing call", {
9449
9473
  opponentIds: e,
9450
9474
  opponentType: t,
9451
9475
  mediaOptions: n
9452
- }), this._processConnectionSharedMovieInfo(d), this._processConversationUrlSharingInfo(d), L.onLocalStream(this._mediaSource.getStream(), this._mediaSource.mediaSettings, this.id), L.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), void 0, this.id), this._onConversationParticipantListChunk(d), this._processPinnedParticipants(d), L.onLocalStatus(N.WAITING, this.id), this._toggleJoinAvailability(), this._changeFeatureSet(), this._changeNeedRate(), z.add(this), await z.setActive(this.id), us = null, this._conversation.concurrent && await this._acceptConcurrent(), f && !this._registeredPeerReceived && this._state !== "CLOSE" && (this._calleeUnavailableTimer = window.setTimeout(() => {
9476
+ }), this._processConnectionSharedMovieInfo(d), this._processConversationUrlSharingInfo(d), L.onLocalStream(this._mediaSource.getStream(), this._mediaSource.mediaSettings, this.id), L.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), void 0, this.id), this._onConversationParticipantListChunk(d), this._processPinnedParticipants(d), L.onLocalStatus(N.WAITING, this.id), this._toggleJoinAvailability(), this._changeFeatureSet(), this._changeNeedRate(), this._conversation?.concurrent) {
9477
+ let e = z.get(this._conversation.id);
9478
+ e && e !== this && e._close(new O(D.HUNGUP, { remote: !0 }));
9479
+ }
9480
+ return z.add(this), await z.setActive(this.id), us = null, this._conversation.concurrent && await this._acceptConcurrent(), f && !this._registeredPeerReceived && this._state !== "CLOSE" && (this._calleeUnavailableTimer = window.setTimeout(() => {
9453
9481
  this._calleeUnavailableTimer = null, this._close(new O(D.CALLEE_UNAVAILABLE), { signalingReason: D.CANCELED });
9454
9482
  }, f)), this._conversation;
9455
9483
  } catch (e) {
@@ -9506,7 +9534,11 @@ var ls = 15, $ = class e extends b {
9506
9534
  }
9507
9535
  }
9508
9536
  _extractExternalRooms(e) {
9509
- return e.map(this._convertRoomToExternal.bind(this)).filter((e) => !!e);
9537
+ let t = [], n = [];
9538
+ return e.forEach((e) => {
9539
+ let { room: r, missingParticipantIds: i } = this._convertRoomToExternal(e);
9540
+ r && n.push(r), t.push(...i);
9541
+ }), this._reportMissingExternalIds(t, "EXTRACT_EXTERNAL_ROOMS"), n.filter((e) => !!e);
9510
9542
  }
9511
9543
  _extractExternalRoomsData(e, t) {
9512
9544
  if (!e || !e.length) return;
@@ -9731,7 +9763,8 @@ var ls = 15, $ = class e extends b {
9731
9763
  D.CALLEE_IS_OFFLINE,
9732
9764
  D.CALLEE_UNAVAILABLE,
9733
9765
  D.CALLER_IS_BLOCKED,
9734
- D.CALLER_IS_REJECTED
9766
+ D.CALLER_IS_REJECTED,
9767
+ D.HAS_ACTIVE_CALL
9735
9768
  ].indexOf(e.hangup) !== -1 || e.hangup === D.REJECTED && !e.remote) {
9736
9769
  this._emitHangupOnce(e, i), this._destroy(r);
9737
9770
  return;
@@ -9988,19 +10021,17 @@ var ls = 15, $ = class e extends b {
9988
10021
  isInRoom: !1,
9989
10022
  markers: null
9990
10023
  }, e), i = !!r.externalId;
9991
- return i || (r.externalId = this._getParticipantId(t ?? r.id)), n && i && this._api.cacheExternalId(t ?? r.id, r.externalId), t && this._api.mapDecorativeId(t, r.id), r.observedIds?.length && (r.externalId.observer = !0), e.markers && (r.markers = this._denormalizeMarkers(r.id, e.markers)), r.connectionStatus = eo.create(r.connectionStatus), r;
10024
+ if (!i) {
10025
+ let e = this._getParticipantId(t ?? r.id);
10026
+ e && (r.externalId = e);
10027
+ }
10028
+ return n && i && this._api.cacheExternalId(t ?? r.id, r.externalId), t && this._api.mapDecorativeId(t, r.id), r.observedIds?.length && r.externalId && (r.externalId.observer = !0), e.markers && (r.markers = this._denormalizeMarkers(r.id, e.markers)), r.connectionStatus = eo.create(r.connectionStatus), r;
9992
10029
  }
9993
10030
  _getParticipantId(e) {
9994
- try {
9995
- return this._api.userId(e);
9996
- } catch (e) {
9997
- throw this._close(e instanceof O ? e : new O(D.NETWORK_ERROR, { callError: {
9998
- scope: "network",
9999
- source: "api",
10000
- code: "fetch-failed",
10001
- description: "request-failed"
10002
- } }), { errorText: e }), e;
10003
- }
10031
+ let t = this._api.userId(e);
10032
+ if (t) return t;
10033
+ let { compositeUserId: n, deviceIdx: r } = j.decomposeParticipantId(e), { id: i, type: a } = j.decomposeId(n);
10034
+ return a === A.GROUP ? Q.fromId(String(i), void 0, r) : null;
10004
10035
  }
10005
10036
  _cacheParticipantExternalIds(e) {
10006
10037
  e.forEach((e) => {
@@ -10008,7 +10039,7 @@ var ls = 15, $ = class e extends b {
10008
10039
  if (n) {
10009
10040
  this._api.cacheExternalId(t, n);
10010
10041
  let r = j.composeDecorativeId(e), i = Q.fromSignalingParticipant(e);
10011
- r && i && (this._api.cacheExternalId(r, i), this._api.mapDecorativeId(e.decorativeUserId, e.id));
10042
+ r && i && (this._api.cacheExternalId(r, i), this._api.mapDecorativeId(r, t));
10012
10043
  }
10013
10044
  });
10014
10045
  }
@@ -10057,7 +10088,11 @@ var ls = 15, $ = class e extends b {
10057
10088
  audienceMode: this._isAudienceMode(t),
10058
10089
  restricted: this._isRestricted(t),
10059
10090
  urlSharingInfoByRoom: /* @__PURE__ */ new Map()
10060
- }, this._debug.setConversationId(t.conversation.id || e.id), e.p2p_forbidden && (M.forceRelayPolicy = e.p2p_forbidden), this._stats.logger.log(C.RELAY_POLICY, M.forceRelayPolicy ? "1" : "0"), this._changeFeatureSet(), this._changeFeaturesPerRole(), this._logDevices();
10091
+ }, this._debug.setConversationId(t.conversation.id || e.id), e.p2p_forbidden && (M.forceRelayPolicy = e.p2p_forbidden), this._stats.logger.log(C.RELAY_POLICY, M.forceRelayPolicy ? "1" : "0");
10092
+ let l = z.get(this._conversation.id);
10093
+ if (l && l !== this) this._conversation.concurrent = !0;
10094
+ else if (!M.hold && z.callsLength > 0) throw new O(D.HAS_ACTIVE_CALL);
10095
+ this._changeFeatureSet(), this._changeFeaturesPerRole(), this._logDevices();
10061
10096
  }
10062
10097
  _updateConversation(e) {
10063
10098
  if (!this._conversation) throw new O(D.UNKNOWN_ERROR, { callError: {
@@ -10187,33 +10222,40 @@ var ls = 15, $ = class e extends b {
10187
10222
  _getExistedParticipantByIdOrCreate(e) {
10188
10223
  let t = this._participants[e];
10189
10224
  if (t) return t;
10190
- let n = this._api.getDecorativeIdByInitialId(j.decomposeId(e).id), r = n ? j.composeUserId(n) : void 0, i = this._getParticipantId(e), { deviceIdx: a } = j.decomposeParticipantId(e);
10225
+ let n = this._api.getDecorativeIdByInitialId(e), r = this._getParticipantId(e), { deviceIdx: i } = j.decomposeParticipantId(e);
10191
10226
  return this._createParticipant({
10192
10227
  id: e,
10193
- externalId: {
10194
- ...i,
10195
- deviceIdx: a
10196
- }
10197
- }, r, !1);
10228
+ externalId: r ? {
10229
+ ...r,
10230
+ deviceIdx: i
10231
+ } : void 0
10232
+ }, n, !1);
10198
10233
  }
10199
10234
  _getExternalIdByParticipantId(e) {
10200
- if (this._isMe(e)) return this._conversation?.externalId;
10235
+ if (this._isMe(e)) return this._conversation?.externalId ?? null;
10201
10236
  if (M.useParticipantListChunk) return this._getExistedParticipantByIdOrCreate(e).externalId;
10202
10237
  let t = this._participants;
10203
10238
  if (t[e]?.externalId) return t[e].externalId;
10204
- {
10205
- let t = this._getParticipantId(e);
10206
- return this._api.cacheExternalId(e, t), t;
10207
- }
10239
+ let n = this._api.getCachedExternalIdByParticipantId(e);
10240
+ if (n) return n;
10241
+ let r = this._getParticipantId(e);
10242
+ return r && this._api.cacheExternalId(e, r), r;
10243
+ }
10244
+ _getExternalIdsByParticipantIds(e) {
10245
+ let t = [], n = [];
10246
+ return e.forEach((e) => {
10247
+ let r = this._getExternalIdByParticipantId(e);
10248
+ r ? t.push(r) : n.push(e);
10249
+ }), {
10250
+ externalIds: t,
10251
+ missingIds: n
10252
+ };
10208
10253
  }
10209
- _getExternalIdsByOkIdsFromCache(e) {
10210
- return e.map((e) => this._api.getCachedExternalIdByOkId(e) ?? Q.fromId(String(e)));
10254
+ _reportMissingExternalIds(e, t) {
10255
+ e.length && this._onNonFatalError(`External ID mapping not found for participants "${Array.from(new Set(e)).join("\", \"")}" while handling ${t}`);
10211
10256
  }
10212
- _getOrCacheExternalIdByCompositeId(e) {
10213
- let t = j.extractOkId(e), n = this._api.getCachedExternalIdByOkId(t);
10214
- if (n) return n;
10215
- let r = Q.fromId(String(t));
10216
- return this._api.cacheExternalId(e, r), r;
10257
+ _reportMissingExternalIdsById(e, t) {
10258
+ e.length && this._onNonFatalError(`Participant ID mapping not found for external IDs "${Array.from(new Set(e)).join("\", \"")}" while handling ${t}`);
10217
10259
  }
10218
10260
  _registerParticipantAndSetMarkersIfChunkEnabled(e, t) {
10219
10261
  if (M.useParticipantListChunk) {
@@ -10498,30 +10540,34 @@ var ls = 15, $ = class e extends b {
10498
10540
  async updateDisplayLayout(e) {
10499
10541
  if (e.length < 1 || !this._signaling.ready) return;
10500
10542
  this._debug.log(`Update display layout request [${this._signaling.getNextCommandSequenceNumber()}]`, e);
10501
- let t = {}, n = [], r = this._participants;
10502
- for (let i of e) {
10503
- let e = typeof i.uid == "object" ? i.uid : Q.fromId(i.uid), a = this._api.getCachedOkIdByExternalId(e);
10504
- if (!a) {
10543
+ let t = {}, n = [], r = [], i = this._participants;
10544
+ for (let a of e) {
10545
+ let e = typeof a.uid == "object" ? a.uid : Q.fromId(a.uid), o = this._api.getCachedParticipantIdByExternalId(e);
10546
+ if (!o) {
10505
10547
  let t = Q.toString(e);
10506
- this._debug.log(`Unknown participant external ID ${t}`);
10548
+ this._debug.log(`Unknown participant external ID ${t}`), r.push(e.id);
10507
10549
  continue;
10508
10550
  }
10509
- let o = Mn({
10510
- participantId: a,
10511
- mediaType: i.mediaType,
10512
- streamName: i.streamName
10513
- }), s = r[a];
10514
- s ? n.push(() => {
10515
- s.lastRequestedLayouts[o] = i;
10516
- }) : this._isMe(a) && n.push(() => {
10517
- this._myLastRequestedLayouts[o] = i;
10518
- }), Dn(i) ? (this._isMe(a) && n.push(() => {
10519
- delete this._myLastRequestedLayouts[o];
10520
- }), this._streamIdByStreamDescription.has(o) && !this._cooldownTimestampByStreamDescription.has(o) && this._cooldownTimestampByStreamDescription.set(o, Date.now())) : (this._cooldownTimestampByStreamDescription.delete(o), !this._streamIdByStreamDescription.has(o) && M.videoTracksCount > 0 && this._streamIdByStreamDescription.set(o, null), t[o] = i), i.mediaType === V.SCREEN && !Dn(i) && W.setMark(W.getMarkNameScreenshareFirstFrame(a));
10521
- }
10522
- let i = this._cooldownTimestampByStreamDescription.keys();
10551
+ let s = Mn({
10552
+ participantId: o,
10553
+ mediaType: a.mediaType,
10554
+ streamName: a.streamName
10555
+ }), c = i[o];
10556
+ c ? n.push(() => {
10557
+ c.lastRequestedLayouts[s] = a;
10558
+ }) : this._isMe(o) && n.push(() => {
10559
+ this._myLastRequestedLayouts[s] = a;
10560
+ }), Dn(a) ? (this._isMe(o) && n.push(() => {
10561
+ delete this._myLastRequestedLayouts[s];
10562
+ }), this._streamIdByStreamDescription.has(s) && !this._cooldownTimestampByStreamDescription.has(s) && this._cooldownTimestampByStreamDescription.set(s, Date.now())) : (this._cooldownTimestampByStreamDescription.delete(s), !this._streamIdByStreamDescription.has(s) && M.videoTracksCount > 0 && this._streamIdByStreamDescription.set(s, null), t[s] = a), a.mediaType === V.SCREEN && !Dn(a) && W.setMark(W.getMarkNameScreenshareFirstFrame(o));
10563
+ }
10564
+ if (r.length) {
10565
+ this._reportMissingExternalIdsById(r, "updateDisplayLayout");
10566
+ return;
10567
+ }
10568
+ let a = this._cooldownTimestampByStreamDescription.keys();
10523
10569
  for (; this._streamIdByStreamDescription.size > M.videoTracksCount;) {
10524
- let e = i.next();
10570
+ let e = a.next();
10525
10571
  if (e.done) {
10526
10572
  this._debug.error("Cannot accommodate all streaming requests: tracks available " + M.videoTracksCount + "; requested streams: " + Array.from(this._streamIdByStreamDescription.keys()));
10527
10573
  break;
@@ -10613,17 +10659,22 @@ var ls = 15, $ = class e extends b {
10613
10659
  async _onParticipantPromoted(e) {
10614
10660
  this._conversation && this._conversation.audienceMode ? (this._debug.log("Promoted in audience mode", !e.demote), this._conversation.restricted = e.demote, this._processRecordInfos(e), !e.demote && this._mediaSource && this._changeMediaSettings(this._mediaSource.mediaSettings)) : (this._debug.log("Promoted in waiting hall", !e.demote), e.demote ? (this._debug.log("Kicked from waiting hall"), this._close(new O(D.REMOVED))) : (this._updateConversation(e), this._waitingHallHoldPending ? (await this._signaling.hold(!0), await this._onJoinPart2(e, !1), this._waitingHallHoldPending = !1) : z.getActive() && M.hold ? (await this._signaling.hold(!0), await this._onJoinPart2(e, !0, !0), this._waitingHallHoldPending = !1) : await this._onJoinPart2(e))), L.onPromoted(e.demote, this.id);
10615
10661
  }
10616
- async _onChatRoomUpdated(e, t = 0, n = [], r, i) {
10662
+ _onChatRoomUpdated(e, t = 0, n = [], r, i) {
10617
10663
  this._debug.log(`Chat room updated: ${e}`);
10618
- let a = [];
10664
+ let a = [], o = [];
10619
10665
  n.length && n.forEach((e) => {
10620
10666
  if (e.externalId) {
10621
10667
  let t = Q.fromSignaling(e.externalId);
10622
10668
  a.push(t), this._api.cacheExternalId(e.id.id, t);
10623
- } else a.push(this._getOrCacheExternalIdByCompositeId(e.id.id));
10669
+ } else {
10670
+ let t = this._getExternalIdByParticipantId(e.id.id);
10671
+ t ? a.push(t) : o.push(e.id.id);
10672
+ }
10624
10673
  });
10625
- let o = r?.map((e) => this._getOrCacheExternalIdByCompositeId(e)) ?? [], s = i?.map((e) => this._getOrCacheExternalIdByCompositeId(e)) ?? [];
10626
- L.onChatRoomUpdated(e, t, a, o, s, this.id);
10674
+ let { externalIds: s, missingIds: c } = this._getExternalIdsByParticipantIds(r ?? []);
10675
+ o.push(...c);
10676
+ let { externalIds: l, missingIds: u } = this._getExternalIdsByParticipantIds(i ?? []);
10677
+ o.push(...u), this._reportMissingExternalIds(o, "CHAT_ROOM_UPDATED"), L.onChatRoomUpdated(e, t, a, s, l, this.id);
10627
10678
  }
10628
10679
  _onSharedMovieUpdate(e) {
10629
10680
  let t = this._conversation?.externalId;
@@ -10846,34 +10897,37 @@ var ls = 15, $ = class e extends b {
10846
10897
  let r = null;
10847
10898
  if (e && (r = ro(e), r)) {
10848
10899
  let e = this._api.getDecorativeIdByInitialId(r.id);
10849
- r.id = e ? j.composeUserId(e) : r.id;
10900
+ r.id = e ?? r.id;
10850
10901
  }
10851
10902
  let i = await this._signaling.getWaitingHall(r, t, n);
10852
10903
  if (i.error) return Promise.reject(i.message);
10853
- let a = i.participants || [], { externalIds: o } = await this._resolveWaitingHallExternalIds(a), s = null;
10904
+ let a = i.participants || [], { externalIds: o } = this._resolveWaitingHallExternalIds(a, "getWaitingHall"), s = null;
10854
10905
  return a.length && i.hasMore && (s = no(a[a.length - 1].id)), {
10855
10906
  participants: o,
10856
10907
  pageMarker: s,
10857
10908
  totalCount: i.totalCount || 0
10858
10909
  };
10859
10910
  }
10860
- async _resolveWaitingHallExternalIds(e) {
10861
- let t = [], n = [];
10911
+ _resolveWaitingHallExternalIds(e, t) {
10912
+ let n = [], r = [], i = [];
10862
10913
  return e.length && e.forEach((e) => {
10863
10914
  if (e.externalId) {
10864
- let r = Q.fromSignaling(e.externalId);
10865
- t.push(e.id.addedTs), n.push(r), this._api.cacheExternalId(e.id.id, r);
10866
- } else n.push(this._getOrCacheExternalIdByCompositeId(e.id.id)), t.push(e.id.addedTs);
10867
- }), {
10868
- externalIds: n,
10869
- timestamps: t
10915
+ let t = Q.fromSignaling(e.externalId);
10916
+ n.push(e.id.addedTs), r.push(t), this._api.cacheExternalId(e.id.id, t);
10917
+ } else {
10918
+ let t = this._getExternalIdByParticipantId(e.id.id);
10919
+ t ? (r.push(t), n.push(e.id.addedTs)) : i.push(e.id.id);
10920
+ }
10921
+ }), this._reportMissingExternalIds(i, t), {
10922
+ externalIds: r,
10923
+ timestamps: n
10870
10924
  };
10871
10925
  }
10872
10926
  async getAudienceModeHands() {
10873
10927
  if (!this._signaling.ready) throw Error("Signaling is not ready");
10874
10928
  let e = await this._signaling.getHandQueue();
10875
10929
  if (e.error) return Promise.reject(e.message);
10876
- let t = e.participants || [], { externalIds: n, timestamps: r } = await this._resolveWaitingHallExternalIds(t);
10930
+ let t = e.participants || [], { externalIds: n, timestamps: r } = this._resolveWaitingHallExternalIds(t, "getAudienceModeHands");
10877
10931
  return {
10878
10932
  timestamps: r,
10879
10933
  participants: n,
@@ -11042,7 +11096,7 @@ var ls = 15, $ = class e extends b {
11042
11096
  unmuteOptions: e.unmuteOptions || [],
11043
11097
  observedIds: e.observedIds || [],
11044
11098
  markers: this._denormalizeMarkers(t, e.markers)
11045
- }, e.decorativeUserId);
11099
+ }, j.composeDecorativeId(e));
11046
11100
  }));
11047
11101
  }
11048
11102
  async getParticipantListChunk(e) {
@@ -11088,7 +11142,7 @@ var ls = 15, $ = class e extends b {
11088
11142
  this._warnParticipantNotInConversation(e);
11089
11143
  return;
11090
11144
  }
11091
- r.mediaSettings = t, ["ACTIVE", "HELD"].includes(this._state) && L.onRemoteMediaSettings(r.externalId, t, r.markers, this.id), this._specListener && this._specListener.onChangeRemoteMediaSettings(e, t);
11145
+ r.mediaSettings = t, ["ACTIVE", "HELD"].includes(this._state) && (r.externalId ? L.onRemoteMediaSettings(r.externalId, t, r.markers, this.id) : this._reportMissingExternalIds([e], "REMOTE_MEDIA_SETTINGS")), this._specListener && this._specListener.onChangeRemoteMediaSettings(e, t);
11092
11146
  }
11093
11147
  _extractLocalParticipantFromConnection(e) {
11094
11148
  let t = this._api.getUserId();
@@ -11104,7 +11158,7 @@ var ls = 15, $ = class e extends b {
11104
11158
  this._warnParticipantNotInConversation(e);
11105
11159
  return;
11106
11160
  }
11107
- n.participantState = t || {}, ["ACTIVE", "HELD"].includes(this._state) && L.onRemoteParticipantState(n.externalId, n.participantState, n.markers, this.id);
11161
+ n.participantState = t || {}, ["ACTIVE", "HELD"].includes(this._state) && (n.externalId ? L.onRemoteParticipantState(n.externalId, n.participantState, n.markers, this.id) : this._reportMissingExternalIds([e], "REMOTE_PARTICIPANT_STATE"));
11108
11162
  }
11109
11163
  _changeMultipleParticipantState(e, t) {
11110
11164
  this._debug.debug("Multiple participants state changed", e);
@@ -11239,30 +11293,37 @@ var ls = 15, $ = class e extends b {
11239
11293
  async _onAcceptedCall(e) {
11240
11294
  let t = j.composeMessageId(e), n = j.getPeerIdString(e.peerId);
11241
11295
  if (this._debug.debug(`Participant accepted call [${t}]`), this._statFirstMediaReceived.markAcceptedCall(this._transport?.getTopology()), this._conversation && this._isMe(t)) {
11296
+ if (this._conversation.concurrent) return;
11242
11297
  this._close(new O(D.MISSED), { errorText: "Call accepted on other device" });
11243
11298
  return;
11244
11299
  }
11245
11300
  this._conversation?.direction === Ba.OUTGOING && !this._conversation.concurrent && this._stats.lifecycle.markOutgoingAccepted();
11246
11301
  let r = this._getParticipant(t);
11247
11302
  if (!r) {
11248
- let n = this._api.getDecorativeIdByInitialId(t), i = n ? j.composeUserId(n, e.participantType) : void 0;
11303
+ let n = this._api.getDecorativeIdByInitialId(t);
11249
11304
  r = this._registerParticipantInCache(this._createParticipant({
11250
11305
  id: t,
11251
11306
  externalId: e.externalId ? Q.fromSignaling(e.externalId, e.deviceIdx) : void 0,
11252
11307
  mediaSettings: E(e.mediaSettings)
11253
- }, i));
11308
+ }, n));
11254
11309
  } else if (e.externalId) {
11255
11310
  let t = Q.fromSignaling(e.externalId, e.deviceIdx);
11256
11311
  r.externalId = t, this._api.cacheExternalId(r.id, t);
11257
11312
  }
11258
11313
  r.state = Z.ACCEPTED, r.mediaSettings = E(e.mediaSettings), this._logWithMediaSettings(C.ACCEPTED_OUTGOING, r.mediaSettings), this._conversation && this._conversation.direction === Ba.OUTGOING && (this._state === "IDLE" || this._state === "PROCESSING") && (this._state = "ACTIVE", this._changeFeatureSet()), this._state === "ACTIVE" && this._transport && this._transport.open([r.id], n), this._changeRemoteMediaSettings(t, r.mediaSettings), await this._changeRemoteParticipantState(t);
11259
11314
  let i = Object.keys(r.muteStates);
11260
- i.length && this._onMuteParticipant({
11315
+ if (i.length && this._onMuteParticipant({
11261
11316
  muteStates: r.muteStates,
11262
11317
  mediaOptions: i,
11263
11318
  stateUpdated: !0,
11264
11319
  participantId: t
11265
- }), ["ACTIVE", "HELD"].includes(this._state) && L.onAcceptedCall(r.externalId, xa.parseCapabilities(e.capabilities), this.id);
11320
+ }), ["ACTIVE", "HELD"].includes(this._state)) {
11321
+ if (!r.externalId) {
11322
+ this._reportMissingExternalIds([t], "ACCEPTED_CALL");
11323
+ return;
11324
+ }
11325
+ L.onAcceptedCall(r.externalId, xa.parseCapabilities(e.capabilities), this.id);
11326
+ }
11266
11327
  }
11267
11328
  async _onHungup(e) {
11268
11329
  this._debug.debug(`Participant hungup [${e.participantId}]`, { reason: e.reason });
@@ -11331,7 +11392,7 @@ var ls = 15, $ = class e extends b {
11331
11392
  return;
11332
11393
  }
11333
11394
  if (!n) {
11334
- let { participant: r } = e, i = r.decorativeUserId;
11395
+ let { participant: r } = e, i = j.composeDecorativeId(r);
11335
11396
  this._registerParticipant({
11336
11397
  id: t,
11337
11398
  externalId: Q.fromSignalingParticipant(r, !0, !0),
@@ -11358,7 +11419,7 @@ var ls = 15, $ = class e extends b {
11358
11419
  return;
11359
11420
  }
11360
11421
  if (!n) {
11361
- let { participant: r } = e, i = r.decorativeUserId;
11422
+ let { participant: r } = e, i = j.composeDecorativeId(r);
11362
11423
  this._registerParticipant({
11363
11424
  id: t,
11364
11425
  externalId: Q.fromSignalingParticipant(r, !0, !0),
@@ -11401,7 +11462,7 @@ var ls = 15, $ = class e extends b {
11401
11462
  _onParticipantsStateChanged(e) {
11402
11463
  let { participants: t, roomId: n } = e;
11403
11464
  t.map(({ id: e, markers: t }) => this._registerParticipantAndSetMarkersIfChunkEnabled(e, t));
11404
- let r = /* @__PURE__ */ new Map(), i = t.map(({ id: e, participantState: t }) => [e, this._getExternalIdByParticipantId(e) && j.mapParticipantState({ participantState: t })]);
11465
+ let r = /* @__PURE__ */ new Map(), i = t.map(({ id: e, participantState: t }) => [e, this._getExternalIdByParticipantId(e) ? j.mapParticipantState({ participantState: t }) : void 0]);
11405
11466
  try {
11406
11467
  i.forEach(([e, t]) => {
11407
11468
  t && r.set(e, t);
@@ -11800,8 +11861,8 @@ var ls = 15, $ = class e extends b {
11800
11861
  this._debug.debug(`Remote track added on the participant [${e}]`, { kind: n.kind });
11801
11862
  let r = this._getParticipant(e);
11802
11863
  if (!r) {
11803
- let t = this._api.getDecorativeIdByInitialId(e), n = t ? j.composeUserId(t) : void 0;
11804
- this._debug.warn(`Conversation: track added before participant [id: ${e}, decorativeId: ${n}]`), this._registerParticipant({ id: e }, n), r = this._getParticipant(e), this._setParticipantsStatus([r], N.WAITING), this._activeSpeakerId === e && this._lastSignalledActiveSpeakerId !== e && (L.onSpeakerChanged(r.externalId, this.id), this._lastSignalledActiveSpeakerId = e);
11864
+ let t = this._api.getDecorativeIdByInitialId(e);
11865
+ this._debug.warn(`Conversation: track added before participant [id: ${e}, decorativeId: ${t}]`), this._registerParticipant({ id: e }, t), r = this._getParticipant(e), this._setParticipantsStatus([r], N.WAITING), this._activeSpeakerId === e && this._lastSignalledActiveSpeakerId !== e && (L.onSpeakerChanged(r.externalId, this.id), this._lastSignalledActiveSpeakerId = e);
11805
11866
  }
11806
11867
  if (this._transport && !this._transport.isAllocated(r.id) && this._allocateParticipantTransport(r.id, !1), n.kind === k.audio && (this._audioOutput.add(e, n), M.preserveAudioTracks || (r.remoteAudioTrack = n, t.removeTrack(n))), r.remoteStream !== t && t.getTracks().length) {
11807
11868
  if (r.remoteStream = t, r.secondStream) return;
@@ -11911,46 +11972,63 @@ var ls = 15, $ = class e extends b {
11911
11972
  }
11912
11973
  _onRoomsUpdated(e) {
11913
11974
  if (this._isCalledState()) return;
11914
- let t = {};
11915
- for (let n of Object.keys(Ja)) {
11916
- let r = e.updates[n];
11917
- r && (t[n] = {
11918
- rooms: r?.rooms?.map(this._convertRoomToExternal.bind(this)) || [],
11919
- roomIds: r?.roomIds,
11920
- deactivated: r?.deactivated
11975
+ let t = {}, n = [], r = [];
11976
+ for (let i of Object.keys(Ja)) {
11977
+ let a = e.updates[i];
11978
+ a && (a?.rooms?.forEach((e) => {
11979
+ let { room: t, missingParticipantIds: i } = this._convertRoomToExternal(e);
11980
+ t && n.push(t), r.push(...i);
11981
+ }), t[i] = {
11982
+ rooms: n,
11983
+ roomIds: a?.roomIds,
11984
+ deactivated: a?.deactivated
11921
11985
  });
11922
11986
  }
11923
- L.onRoomsUpdated(t, this.id);
11987
+ this._reportMissingExternalIds(r, "ROOMS_UPDATED"), L.onRoomsUpdated(t, this.id);
11924
11988
  }
11925
11989
  _onRoomUpdated(e) {
11926
- let t = this._convertRoomToExternal(e.room || null);
11927
- e.events.some((e) => e === Ja.UPDATE) && (e.muteStates !== void 0 && this._setMuteStatesForRoomId(e.muteStates, e.roomId), e.recordInfo !== void 0 && this._conversation?.recordsInfoByRoom.set(e.roomId, e.recordInfo), e.asrInfo !== void 0 && this._conversation?.asrInfoByRoom.set(e.roomId, e.asrInfo)), this._isCalledState() || L.onRoomUpdated(e.events, e.roomId, t, e.deactivate || null, this.id);
11990
+ let { room: t, missingParticipantIds: n } = this._convertRoomToExternal(e.room || null);
11991
+ e.events.some((e) => e === Ja.UPDATE) && (e.muteStates !== void 0 && this._setMuteStatesForRoomId(e.muteStates, e.roomId), e.recordInfo !== void 0 && this._conversation?.recordsInfoByRoom.set(e.roomId, e.recordInfo), e.asrInfo !== void 0 && this._conversation?.asrInfoByRoom.set(e.roomId, e.asrInfo)), this._isCalledState() || (this._reportMissingExternalIds(n, "ROOM_UPDATED"), L.onRoomUpdated(e.events, e.roomId, t, e.deactivate || null, this.id));
11928
11992
  }
11929
11993
  _convertRoomToExternal(e) {
11930
- if (!e) return null;
11931
- let t = e.participantIds?.map((e) => this._getExternalIdByParticipantId(e)) || [], n = e.addParticipantIds?.map((e) => this._getExternalIdByParticipantId(e)) || [], r = e.removeParticipantIds?.map?.((e) => this._getExternalIdByParticipantId(e)) || [], i = e.pinnedParticipantId ? this._getExternalIdByParticipantId(e.pinnedParticipantId) : void 0;
11994
+ if (!e) return {
11995
+ room: null,
11996
+ missingParticipantIds: []
11997
+ };
11998
+ let t = [], { externalIds: n, missingIds: r } = this._getExternalIdsByParticipantIds(e.participantIds ?? []), { externalIds: i, missingIds: a } = this._getExternalIdsByParticipantIds(e.addParticipantIds ?? []), { externalIds: o, missingIds: s } = this._getExternalIdsByParticipantIds(e.removeParticipantIds ?? []);
11999
+ t.push(...r, ...a, ...s);
12000
+ let c;
12001
+ if (e.pinnedParticipantId) {
12002
+ let n = this._getExternalIdByParticipantId(e.pinnedParticipantId);
12003
+ n ? c = n : t.push(e.pinnedParticipantId);
12004
+ }
11932
12005
  return {
11933
- id: e.id,
11934
- name: e.name,
11935
- participantCount: e.participantCount,
11936
- participantIds: t,
11937
- addParticipantIds: n,
11938
- removeParticipantIds: r,
11939
- participants: e.participants?.participants ? this._participantListChunkToExternalChunk(e.participants) : void 0,
11940
- active: e.active,
11941
- muteStates: e.muteStates,
11942
- pinnedParticipantId: i,
11943
- countdownSec: e.countdownSec,
11944
- timeoutMs: e.timeoutMs
12006
+ room: {
12007
+ id: e.id,
12008
+ name: e.name,
12009
+ participantCount: e.participantCount,
12010
+ participantIds: n,
12011
+ addParticipantIds: i,
12012
+ removeParticipantIds: o,
12013
+ participants: e.participants?.participants ? this._participantListChunkToExternalChunk(e.participants) : void 0,
12014
+ active: e.active,
12015
+ muteStates: e.muteStates,
12016
+ pinnedParticipantId: c,
12017
+ countdownSec: e.countdownSec,
12018
+ timeoutMs: e.timeoutMs
12019
+ },
12020
+ missingParticipantIds: t
11945
12021
  };
11946
12022
  }
11947
12023
  async _onRoomParticipantsUpdated(e) {
11948
- let t = this._transport?.getState(), n = e.roomId ?? null, r = e.addedParticipantIds?.map((e) => j.decomposeId(e).id) || [], i = this._getExternalIdsByOkIdsFromCache(r), a = e.addedParticipants;
11949
- if (i.length && a?.length !== i.length && !this._isCalledState()) {
12024
+ let t = this._transport?.getState(), n = e.roomId ?? null, r = [], { externalIds: i, missingIds: a } = this._getExternalIdsByParticipantIds(e.addedParticipantIds ?? []);
12025
+ r.push(...a);
12026
+ let o = e.addedParticipants;
12027
+ if (i.length && o?.length !== i.length && !this._isCalledState()) {
11950
12028
  let e = this._convertExternalIdsToServerExternalIds(i);
11951
- a = (await this._signaling.getParticipants(e)).participants;
12029
+ o = (await this._signaling.getParticipants(e)).participants;
11952
12030
  }
11953
- let o = a?.map((e) => {
12031
+ let s = o?.map((e) => {
11954
12032
  let r = j.composeId(e);
11955
12033
  return this._createParticipant({
11956
12034
  id: r,
@@ -11966,38 +12044,38 @@ var ls = 15, $ = class e extends b {
11966
12044
  observedIds: e.observedIds || [],
11967
12045
  markers: this._denormalizeMarkers(r, e.markers),
11968
12046
  isInRoom: n !== null
11969
- }, e.decorativeUserId);
11970
- }) || [], s = !1;
11971
- for (let e of o) e.id === this._conversation?.compositeUserId && (s = !0), this._registerParticipantInCache(e);
11972
- this._transport?.getState() === q.IDLE && !this._isCalledState() && this._openTransport(o, !0);
11973
- let c = [];
12047
+ }, j.composeDecorativeId(e));
12048
+ }) || [], c = !1;
12049
+ for (let e of s) e.id === this._conversation?.compositeUserId && (c = !0), this._registerParticipantInCache(e);
12050
+ this._transport?.getState() === q.IDLE && !this._isCalledState() && this._openTransport(s, !0);
12051
+ let l = [];
11974
12052
  if (e?.removedParticipantMarkers) {
11975
12053
  for (let t of e.removedParticipantMarkers) if (t.GRID?.id) {
11976
12054
  let e = this._getExternalIdByParticipantId(t.GRID.id);
11977
- c.push(e);
12055
+ e ? l.push(e) : r.push(t.GRID.id);
11978
12056
  }
11979
12057
  }
11980
- if (s && await this._onRoomSwitched(n), c) {
12058
+ if (this._reportMissingExternalIds(r, "ROOM_PARTICIPANTS_UPDATED"), c && await this._onRoomSwitched(n), l) {
11981
12059
  let e = this._conversation?.pinnedParticipantIdByRoom.get(n);
11982
12060
  if (e) {
11983
12061
  let t = this._getExternalIdByParticipantId(e);
11984
12062
  if (t) {
11985
- for (let e of c) if (Q.compare(t, e)) {
12063
+ for (let e of l) if (Q.compare(t, e)) {
11986
12064
  this._conversation?.pinnedParticipantIdByRoom.delete(n);
11987
12065
  break;
11988
12066
  }
11989
12067
  }
11990
12068
  }
11991
12069
  }
11992
- let l = {
12070
+ let u = {
11993
12071
  roomId: n,
11994
12072
  participantCount: e.participantCount,
11995
12073
  addedParticipantIds: i,
11996
- addedParticipants: j.mapSharedParticipants(o),
12074
+ addedParticipants: j.mapSharedParticipants(s),
11997
12075
  removedParticipantMarkers: e?.removedParticipantMarkers,
11998
- removedParticipantIds: c
12076
+ removedParticipantIds: l
11999
12077
  };
12000
- this._isCalledState() || L.onRoomParticipantsUpdated(l, this.id);
12078
+ this._isCalledState() || L.onRoomParticipantsUpdated(u, this.id);
12001
12079
  }
12002
12080
  async _onRoomSwitched(e, t = !1) {
12003
12081
  if (!this._conversation || this._conversation.roomId === e) return;
@@ -12017,7 +12095,7 @@ var ls = 15, $ = class e extends b {
12017
12095
  if (this._setMuteStatesForRoomId(t.muteStates, n), this._conversation?.recordsInfoByRoom.set(n, t.recordInfo ?? null), this._conversation?.pinnedParticipantIdByRoom.set(n, t.pinnedParticipantId ?? null), t.asrInfo && this._conversation?.asrInfoByRoom.set(n, t.asrInfo), t.urlSharingInfo ? this._conversation?.urlSharingInfoByRoom.set(n, t.urlSharingInfo) : this._conversation?.urlSharingInfoByRoom.delete(n), e) {
12018
12096
  let e = this._participants;
12019
12097
  await this._registerParticipants(t?.participants?.participants?.filter((t) => !e[j.composeId(t)]) || [], !0);
12020
- let n = this._convertRoomToExternal(t);
12098
+ let { room: n } = this._convertRoomToExternal(t);
12021
12099
  n && r.push(n);
12022
12100
  }
12023
12101
  }
@@ -12051,7 +12129,9 @@ var ls = 15, $ = class e extends b {
12051
12129
  return;
12052
12130
  }
12053
12131
  let o = Q.fromSignaling(r, a.deviceIdx);
12054
- if (L.onParticipantIdChanged(a, o, this.id), this._api.cacheExternalId(n, o), this._api.mapDecorativeId(n, t), i) this._conversation.externalId = o;
12132
+ L.onParticipantIdChanged(a, o, this.id);
12133
+ let s = j.compose(n, a.deviceIdx), c = j.compose(t, a.deviceIdx);
12134
+ if (this._api.cacheExternalId(s, o), this._api.mapDecorativeId(s, c), i) this._conversation.externalId = o;
12055
12135
  else {
12056
12136
  let e = this._participants;
12057
12137
  e[t].externalId = o;
@@ -12223,22 +12303,16 @@ var Es = class {
12223
12303
  }
12224
12304
  log(e) {}
12225
12305
  logClientStats(e) {}
12226
- getCachedOkIdByExternalId(e) {
12227
- return null;
12228
- }
12229
- getCachedRawOkIdByExternalId(e) {
12306
+ getCachedParticipantIdByExternalId(e) {
12230
12307
  return null;
12231
12308
  }
12232
- getCachedExternalIdByOkId(e) {
12309
+ getCachedExternalIdByParticipantId(e) {
12233
12310
  return null;
12234
12311
  }
12235
12312
  cacheExternalId(e, t) {}
12236
12313
  mapDecorativeId(e, t) {}
12237
12314
  unmapDecorativeId(e) {}
12238
12315
  getDecorativeIdByInitialId(e) {}
12239
- replaceByInitialIdIdIfExists(e) {
12240
- return typeof e == "string" ? parseInt(e, 10) : e;
12241
- }
12242
12316
  hangupConversation(e, t = D.HUNGUP, n) {}
12243
12317
  async removeHistoryRecords(e) {}
12244
12318
  async getServerTime() {
@@ -12250,7 +12324,7 @@ var Es = class {
12250
12324
  }
12251
12325
  }, Ds = class e {
12252
12326
  constructor() {
12253
- h(this, "_okIdToExternalId", /* @__PURE__ */ new Map()), h(this, "_externalIdToOkId", /* @__PURE__ */ new Map()), h(this, "_decorativeIdToInitialId", /* @__PURE__ */ new Map()), h(this, "_initialIdToDecorativeId", /* @__PURE__ */ new Map());
12327
+ h(this, "_participantIdToExternalId", /* @__PURE__ */ new Map()), h(this, "_externalIdToParticipantId", /* @__PURE__ */ new Map()), h(this, "_decorativeIdToInitialId", /* @__PURE__ */ new Map()), h(this, "_initialIdToDecorativeId", /* @__PURE__ */ new Map());
12254
12328
  }
12255
12329
  static _normalizeType(e) {
12256
12330
  return e.type === to.GROUP ? {
@@ -12258,46 +12332,30 @@ var Es = class {
12258
12332
  type: to.USER
12259
12333
  } : e;
12260
12334
  }
12261
- getOkId(t) {
12262
- let n = Q.toString(e._normalizeType(t)), r = this._externalIdToOkId.get(n);
12263
- return r == null ? null : this.replaceByInitialIdIdIfExists(r);
12264
- }
12265
12335
  getExternalId(e) {
12266
- let t = this.getDecorativeIdByInitialId(e) ?? e, n = this._okIdToExternalId.get(t);
12336
+ let t = this._initialIdToDecorativeId.get(e) ?? e, n = this._participantIdToExternalId.get(t);
12267
12337
  return n == null ? null : Q.fromString(n);
12268
12338
  }
12269
- hasByExternalId(t) {
12270
- return this._externalIdToOkId.has(Q.toString(e._normalizeType(t)));
12271
- }
12272
- hasByOkId(e) {
12273
- return this._okIdToExternalId.has(e);
12339
+ getParticipantId(t) {
12340
+ let n = Q.toString(e._normalizeType(t)), r = this._externalIdToParticipantId.get(n);
12341
+ return r == null ? null : this._decorativeIdToInitialId.get(r) ?? r;
12274
12342
  }
12275
12343
  cache(t, n) {
12276
- let r = j.extractOkId(t), i = e._normalizeType(n), a = Q.toString(i);
12277
- this._okIdToExternalId.set(r, a), this._externalIdToOkId.set(a, r);
12344
+ let r = e._normalizeType(n), i = Q.toString(r);
12345
+ this._participantIdToExternalId.set(t, i), this._externalIdToParticipantId.set(i, t);
12278
12346
  }
12279
12347
  mapDecorativeId(e, t) {
12280
- let n = j.extractOkId(e), r = j.extractOkId(t);
12281
- this._decorativeIdToInitialId.set(n, r), this._initialIdToDecorativeId.set(r, n);
12348
+ this._decorativeIdToInitialId.set(e, t), this._initialIdToDecorativeId.set(t, e);
12282
12349
  }
12283
12350
  unmapDecorativeId(e) {
12284
- let t = j.extractOkId(e), n = this.getDecorativeIdByInitialId(t);
12285
- n && this._decorativeIdToInitialId.delete(n), this._initialIdToDecorativeId.delete(t);
12351
+ let t = this._initialIdToDecorativeId.get(e);
12352
+ t && this._decorativeIdToInitialId.delete(t), this._initialIdToDecorativeId.delete(e);
12286
12353
  }
12287
12354
  getDecorativeIdByInitialId(e) {
12288
- let t = j.extractOkId(e);
12289
- return this._initialIdToDecorativeId.get(t);
12290
- }
12291
- replaceByInitialIdIdIfExists(e) {
12292
- let t = j.extractOkId(e);
12293
- return this._decorativeIdToInitialId.get(t) ?? t;
12294
- }
12295
- getParticipantIdByExternalId(e) {
12296
- let t = this.getOkId(e);
12297
- return t == null ? null : j.composeParticipantId(t, A.USER, e.deviceIdx ?? 0);
12355
+ return this._initialIdToDecorativeId.get(e);
12298
12356
  }
12299
12357
  clear() {
12300
- this._okIdToExternalId.clear(), this._externalIdToOkId.clear(), this._decorativeIdToInitialId.clear(), this._initialIdToDecorativeId.clear();
12358
+ this._participantIdToExternalId.clear(), this._externalIdToParticipantId.clear(), this._decorativeIdToInitialId.clear(), this._initialIdToDecorativeId.clear();
12301
12359
  }
12302
12360
  }, Os = "anonymLogin:", ks = 700, As = 3e3;
12303
12361
  function js(e) {
@@ -12385,8 +12443,11 @@ var Ps = class extends Es {
12385
12443
  }
12386
12444
  }
12387
12445
  userId(e) {
12388
- let { compositeUserId: t } = j.decomposeParticipantId(e), { id: n } = j.decomposeId(t);
12389
- return y.isEmpty() ? Q.fromId(String(n)) : this._idCache.getExternalId(n) || Q.fromId(String(n));
12446
+ if (y.isEmpty()) {
12447
+ let { compositeUserId: t } = j.decomposeParticipantId(e), { id: n } = j.decomposeId(t);
12448
+ return Q.fromId(String(n));
12449
+ }
12450
+ return this._idCache.getExternalId(e);
12390
12451
  }
12391
12452
  async authorize() {
12392
12453
  if (this._ensureUuid(), !M.apiKey) throw new O(x.API, {
@@ -12405,7 +12466,7 @@ var Ps = class extends Es {
12405
12466
  let t = { session_data: {
12406
12467
  version: 2,
12407
12468
  device_id: this._uuid,
12408
- client_version: M.appVersion,
12469
+ client_version: M.apiClientVersion,
12409
12470
  client_type: "SDK_JS"
12410
12471
  } };
12411
12472
  return M.authToken && (t.session_data.auth_token = M.authToken, t.session_data.version = 3), this._callUnsafe("auth.anonymLogin", t, !0).then((e) => {
@@ -12463,7 +12524,7 @@ var Ps = class extends Es {
12463
12524
  }
12464
12525
  logClientStats(e) {
12465
12526
  let t = {
12466
- app_version: String(M.appVersion),
12527
+ app_version: M.appVersion,
12467
12528
  sdk_type: "WEB",
12468
12529
  sdk_version: M.sdkVersion,
12469
12530
  version: 1,
@@ -12574,13 +12635,10 @@ var Ps = class extends Es {
12574
12635
  };
12575
12636
  return n?.length && (i.observedIds = n.join(",")), M.anonymToken && (i.anonymToken = M.anonymToken), r && (i.payload = r), this._call("vchat.joinConversationByLink", i);
12576
12637
  }
12577
- getCachedOkIdByExternalId(e) {
12578
- return this._idCache.getParticipantIdByExternalId(e);
12579
- }
12580
- getCachedRawOkIdByExternalId(e) {
12581
- return this._idCache.getOkId(e);
12638
+ getCachedParticipantIdByExternalId(e) {
12639
+ return this._idCache.getParticipantId(e);
12582
12640
  }
12583
- getCachedExternalIdByOkId(e) {
12641
+ getCachedExternalIdByParticipantId(e) {
12584
12642
  return this._idCache.getExternalId(e);
12585
12643
  }
12586
12644
  cacheExternalId(e, t) {
@@ -12595,9 +12653,6 @@ var Ps = class extends Es {
12595
12653
  getDecorativeIdByInitialId(e) {
12596
12654
  return this._idCache.getDecorativeIdByInitialId(e);
12597
12655
  }
12598
- replaceByInitialIdIdIfExists(e) {
12599
- return this._idCache.replaceByInitialIdIdIfExists(e);
12600
- }
12601
12656
  async getConversationParams(e) {
12602
12657
  let t = {};
12603
12658
  return M.anonymToken && (t.anonymToken = M.anonymToken), e && (t.conversationId = e), this._call("vchat.getConversationParams", t);
@@ -12672,7 +12727,7 @@ var Ls = /* @__PURE__ */ function(e) {
12672
12727
  let e = await bs("auth.anonymLogin", {
12673
12728
  session_data: {
12674
12729
  device_id: this._uuid,
12675
- client_version: M.appVersion,
12730
+ client_version: M.apiClientVersion,
12676
12731
  client_type: "SDK_JS",
12677
12732
  auth_token: this._callToken,
12678
12733
  version: 3
@@ -12747,10 +12802,16 @@ async function Xs(t) {
12747
12802
  }
12748
12803
  async function Zs(e, t = [S.AUDIO], n = "", r = !1, i = !1, a, o, s) {
12749
12804
  let c = [];
12750
- return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), Qs([], Va.USER, t, n, r, i, a, c, o, s);
12805
+ return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), $s([], Va.USER, t, n, r, i, a, c, o, s);
12751
12806
  }
12752
- async function Qs(e, t = Va.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12753
- if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12807
+ function Qs(e, t = []) {
12808
+ let n = e.getIncomingCallerExternalId();
12809
+ return n ? t.length === 1 && t[0].id === n.id && t[0].type === n.type : !1;
12810
+ }
12811
+ async function $s(e, t = Va.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12812
+ if (!M.hold && z.getActive()) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12813
+ let u = z.getAll().find((e) => e.isIncomingRinging);
12814
+ if (!M.hold && u && !Qs(u, s)) throw R.error("There is already incoming call"), new O(D.HAS_ACTIVE_CALL);
12754
12815
  return new $(new Ps(), Hs).onStart({
12755
12816
  opponentIds: e,
12756
12817
  opponentType: t,
@@ -12764,30 +12825,30 @@ async function Qs(e, t = Va.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12764
12825
  conversationId: l
12765
12826
  });
12766
12827
  }
12767
- async function $s(e, t) {
12768
- return ec(e, A.USER, void 0, t);
12828
+ async function ec(e, t) {
12829
+ return tc(e, A.USER, void 0, t);
12769
12830
  }
12770
- async function ec(e, t = A.USER, n, r, i, a) {
12831
+ async function tc(e, t = A.USER, n, r, i, a) {
12771
12832
  if (e === $.id()) throw Error("Push has already been processed");
12772
12833
  return new $(new Ps(), Hs).onPush(e, t, n, r, i, a);
12773
12834
  }
12774
- async function tc() {
12835
+ async function nc() {
12775
12836
  return Vs.getInbounds();
12776
12837
  }
12777
- async function nc(e, t) {
12838
+ async function rc(e, t) {
12778
12839
  return e && (M.authToken = e), t !== void 0 && M.apiBaseUrl !== t && (M.apiBaseUrl = t, hs()), Vs.authorize();
12779
12840
  }
12780
- async function rc(e = [S.AUDIO], t) {
12781
- return El(t).accept(e);
12841
+ async function ic(e = [S.AUDIO], t) {
12842
+ return kl(t).accept(e);
12782
12843
  }
12783
- async function ic(e) {
12784
- let t = Tl(e?.conversationId);
12844
+ async function ac(e) {
12845
+ let t = El(e?.conversationId);
12785
12846
  if (t) return t.decline(e);
12786
12847
  }
12787
- async function ac(e, t = [S.AUDIO]) {
12788
- return oc(e, t);
12848
+ async function oc(e, t = [S.AUDIO]) {
12849
+ return sc(e, t);
12789
12850
  }
12790
- async function oc(e, t, n) {
12851
+ async function sc(e, t, n) {
12791
12852
  if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12792
12853
  return new $(new Ps(), Hs).onJoin({
12793
12854
  conversationId: e,
@@ -12795,7 +12856,7 @@ async function oc(e, t, n) {
12795
12856
  chatId: n
12796
12857
  });
12797
12858
  }
12798
- async function sc(e, t = [S.AUDIO], n, r, i, a) {
12859
+ async function cc(e, t = [S.AUDIO], n, r, i, a) {
12799
12860
  if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12800
12861
  return n && (M.anonymToken = n), new $(new Ps(), Hs).onJoin({
12801
12862
  joinLink: e,
@@ -12806,30 +12867,30 @@ async function sc(e, t = [S.AUDIO], n, r, i, a) {
12806
12867
  anonymous: !!M.anonymToken
12807
12868
  });
12808
12869
  }
12809
- function cc(e) {
12810
- let t = Tl(e?.conversationId);
12870
+ function lc(e) {
12871
+ let t = El(e?.conversationId);
12811
12872
  return t ? t.hangup(e) : ($.hangupAfterInit(e?.onFastHangup), Promise.resolve());
12812
12873
  }
12813
- async function lc(e, t) {
12874
+ async function uc(e, t) {
12814
12875
  let n = Array.isArray(e) ? e : [e], r = $.current();
12815
12876
  r && await r.addParticipant(n, t);
12816
12877
  }
12817
- async function uc(e, t) {
12878
+ async function dc(e, t) {
12818
12879
  let n = $.current();
12819
12880
  if (n) {
12820
12881
  let r = e.map((e) => j.composeUserId(e));
12821
12882
  await n.addParticipantLegacy(r, t);
12822
12883
  }
12823
12884
  }
12824
- async function dc(e, t = !1) {
12825
- let n = $.current()?.getCachedRawOkIdByExternalId(e) ?? null;
12826
- if (!n) {
12827
- R.warn("removeParticipant: externalId not found in cache", e);
12828
- return;
12885
+ async function fc(e, t = !1) {
12886
+ let n = Al(e, "removeParticipant");
12887
+ if (n) try {
12888
+ await n.conversation.removeParticipant(j.decomposeParticipantId(n.participantId).compositeUserId, t);
12889
+ } catch (e) {
12890
+ R.warn(`Failed to remove participant ${n.participantId}. Perhaps he is no longer on the call. ${e}`);
12829
12891
  }
12830
- return fc(n, t);
12831
12892
  }
12832
- async function fc(e, t = !1) {
12893
+ async function pc(e, t = !1) {
12833
12894
  let n = $.current();
12834
12895
  if (n) try {
12835
12896
  await n.removeParticipant(j.composeUserId(e), t);
@@ -12837,13 +12898,13 @@ async function fc(e, t = !1) {
12837
12898
  R.warn(`Failed to remove participant ${e}. Perhaps he is no longer on the call. ${t}`);
12838
12899
  }
12839
12900
  }
12840
- async function pc(e, t) {
12901
+ async function mc(e, t) {
12841
12902
  let n = $.current();
12842
12903
  if (e === "videoinput" && jt.contains(t)) return M.videoFacingMode = t, n ? (T.isMobile() && n.stopVideoTrack(), n.changeDevice(e)) : void 0;
12843
12904
  if (!await T._saveDeviceId(e, t)) throw Error(`Device not found: ${t}`);
12844
12905
  if (n) return n.changeDevice(e);
12845
12906
  }
12846
- async function mc(e, t) {
12907
+ async function hc(e, t) {
12847
12908
  let n = typeof e == "object" ? {
12848
12909
  ...e,
12849
12910
  fastScreenSharing: e.captureScreen && e.fastScreenSharing,
@@ -12852,151 +12913,149 @@ async function mc(e, t) {
12852
12913
  captureScreen: e,
12853
12914
  fastScreenSharing: !1,
12854
12915
  captureAudio: !1
12855
- }, r = Tl(t);
12916
+ }, r = El(t);
12856
12917
  return r ? r.toggleScreenCapturing(n) : Promise.reject();
12857
12918
  }
12858
- function hc(e) {
12919
+ function gc(e) {
12859
12920
  let t = $.current();
12860
12921
  t && t.toggleAnimojiCapturing(e);
12861
12922
  }
12862
- async function gc(e, t = !1) {
12923
+ async function _c(e, t = !1) {
12863
12924
  let n = $.current();
12864
12925
  n && await n.setVideoStream(e, t);
12865
12926
  }
12866
- async function _c(e, t) {
12867
- let n = Tl(t);
12927
+ async function vc(e, t) {
12928
+ let n = El(t);
12868
12929
  n && await n.toggleLocalVideo(e);
12869
12930
  }
12870
- async function vc(e, t) {
12871
- let n = Tl(t);
12931
+ async function yc(e, t) {
12932
+ let n = El(t);
12872
12933
  n && await n.toggleLocalAudio(e);
12873
12934
  }
12874
- async function yc(e) {
12935
+ async function bc(e) {
12875
12936
  let t = $.current();
12876
12937
  if (t) return t.setLocalResolution(e);
12877
12938
  }
12878
- async function bc(e) {
12939
+ async function xc(e) {
12879
12940
  let t = $.current();
12880
12941
  t && await t.changePriorities(e);
12881
12942
  }
12882
- async function xc(e, t) {
12943
+ async function Sc(e, t) {
12883
12944
  let n = $.current();
12884
12945
  if (n) {
12885
- let r;
12886
12946
  if (t) {
12887
- let e = n.getCachedRawOkIdByExternalId(t);
12888
- if (!e) {
12889
- R.warn("changeParticipantState: externalId not found in cache", t);
12947
+ let r = n.getCachedParticipantIdByExternalId(t);
12948
+ if (!r) {
12949
+ Dl(t, "changeParticipantState", n);
12890
12950
  return;
12891
12951
  }
12892
- r = j.composeParticipantId(e, A.USER, t.deviceIdx);
12952
+ await n.changeParticipantState(e, r);
12953
+ return;
12893
12954
  }
12894
- await n.changeParticipantState(e, r);
12955
+ await n.changeParticipantState(e);
12895
12956
  }
12896
12957
  }
12897
- async function Sc() {
12958
+ async function Cc() {
12898
12959
  let e = $.current();
12899
12960
  e && await e.putHandsDown();
12900
12961
  }
12901
- async function Cc(e) {
12962
+ async function wc(e) {
12902
12963
  let t = $.current();
12903
12964
  t && await t.updateDisplayLayout(e);
12904
12965
  }
12905
- async function wc(e) {
12966
+ async function Tc(e) {
12906
12967
  let t = $.current();
12907
12968
  t && await t.requestDisplayLayout(e);
12908
12969
  }
12909
- async function Tc(e, t, n = !1) {
12910
- let r = $.current()?.getCachedRawOkIdByExternalId(e) ?? null;
12911
- if (!r) {
12912
- R.warn("grantRoles: externalId not found in cache", e);
12913
- return;
12914
- }
12915
- return Ec(r, Q.getDeviceIdx(e), t, n);
12970
+ async function Ec(e, t, n = !1) {
12971
+ let r = Al(e, "grantRoles");
12972
+ r && await r.conversation.grantRoles(r.participantId, t, n);
12916
12973
  }
12917
- async function Ec(e, t, n, r = !1) {
12974
+ async function Dc(e, t, n, r = !1) {
12918
12975
  let i = $.current();
12919
12976
  i && await i.grantRoles(j.composeParticipantId(e, A.USER, t), n, r);
12920
12977
  }
12921
- async function Dc({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
12922
- let i = null;
12923
- return e && (i = $.current()?.getCachedRawOkIdByExternalId(e) ?? null, i || R.warn("muteParticipant: externalId not found in cache", e)), Oc({
12924
- uid: i,
12925
- muteStates: t,
12926
- requestedMedia: n,
12927
- deviceIdx: Q.getDeviceIdx(e),
12928
- roomId: r
12929
- });
12978
+ async function Oc({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
12979
+ if (e) {
12980
+ let i = Al(e, "muteParticipant");
12981
+ return i ? i.conversation.muteParticipant(i.participantId, t, n, r) : void 0;
12982
+ }
12983
+ let i = $.current();
12984
+ i && await i.muteParticipant(null, t, n, r);
12930
12985
  }
12931
- async function Oc({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
12986
+ async function kc({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
12932
12987
  let a = $.current();
12933
12988
  if (a) {
12934
12989
  let o = e ? j.composeParticipantId(e, A.USER, r) : null;
12935
12990
  await a.muteParticipant(o, t, n, i);
12936
12991
  }
12937
12992
  }
12938
- async function kc(e, t = !1, n = null) {
12939
- let r = $.current()?.getCachedRawOkIdByExternalId(e) ?? null;
12940
- if (!r) {
12941
- R.warn("pinParticipant: externalId not found in cache", e);
12942
- return;
12943
- }
12944
- return Ac(r, t, Q.getDeviceIdx(e), n);
12993
+ async function Ac(e, t = !1, n = null) {
12994
+ let r = Al(e, "pinParticipant");
12995
+ r && await r.conversation.pinParticipant(r.participantId, t, n);
12945
12996
  }
12946
- async function Ac(e, t = !1, n = 0, r = null) {
12997
+ async function jc(e, t = !1, n = 0, r = null) {
12947
12998
  let i = $.current();
12948
12999
  i && await i.pinParticipant(j.composeParticipantId(e, A.USER, n), t, r);
12949
13000
  }
12950
- async function jc(e) {
13001
+ async function Mc(e) {
12951
13002
  let t = $.current();
12952
13003
  t && await t.updateMediaModifiers(e);
12953
13004
  }
12954
- async function Mc(e) {
13005
+ async function Nc(e) {
12955
13006
  let t = $.current();
12956
13007
  t && await t.enableVideoSuspend(e);
12957
13008
  }
12958
- async function Nc(e) {
13009
+ async function Pc(e) {
12959
13010
  let t = $.current();
12960
13011
  t && await t.enableVideoSuspendSuggest(e);
12961
13012
  }
12962
- async function Pc(e) {
13013
+ async function Fc(e) {
12963
13014
  let t = $.current();
12964
13015
  t && await t.changeOptions(e);
12965
13016
  }
12966
- async function Fc(e, t = null) {
12967
- let n = null;
12968
- return t && (n = $.current()?.getCachedRawOkIdByExternalId(t) ?? null, n || R.warn("chatMessage: externalId not found in cache", t)), Ic(e, n);
12969
- }
12970
13017
  async function Ic(e, t = null) {
13018
+ if (t) {
13019
+ let n = Al(t, "chatMessage");
13020
+ return n ? n.conversation.chatMessage(e, j.decomposeParticipantId(n.participantId).compositeUserId) : void 0;
13021
+ }
13022
+ let n = $.current();
13023
+ n && await n.chatMessage(e, null);
13024
+ }
13025
+ async function Lc(e, t = null) {
12971
13026
  let n = $.current();
12972
13027
  if (n) {
12973
13028
  let r = t ? j.composeUserId(t) : null;
12974
13029
  await n.chatMessage(e, r);
12975
13030
  }
12976
13031
  }
12977
- async function Lc(e = 10) {
13032
+ async function Rc(e = 10) {
12978
13033
  let t = $.current();
12979
13034
  if (t) return t.chatHistory(e);
12980
13035
  }
12981
- async function Rc(e, t = null) {
12982
- let n = null;
12983
- return t && (n = $.current()?.getCachedRawOkIdByExternalId(t) ?? null, n || R.warn("customData: externalId not found in cache", t)), zc(e, n, Q.getDeviceIdx(t));
13036
+ async function zc(e, t = null) {
13037
+ if (t) {
13038
+ let n = Al(t, "customData");
13039
+ return n ? n.conversation.customData(e, n.participantId) : void 0;
13040
+ }
13041
+ let n = $.current();
13042
+ n && await n.customData(e, null);
12984
13043
  }
12985
- async function zc(e, t = null, n = 0) {
13044
+ async function Bc(e, t = null, n = 0) {
12986
13045
  let r = $.current();
12987
13046
  if (r) {
12988
13047
  let i = t ? j.composeParticipantId(t, A.USER, n) : null;
12989
13048
  await r.customData(e, i);
12990
13049
  }
12991
13050
  }
12992
- async function Bc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
13051
+ async function Vc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
12993
13052
  return (await Vs.createConversation(a ?? j.uuid(), e, t, {
12994
13053
  onlyAdminCanShareMovie: n,
12995
13054
  waitForAdmin: r,
12996
13055
  closedConversation: i
12997
13056
  })).join_link;
12998
13057
  }
12999
- async function Vc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
13058
+ async function Hc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
13000
13059
  let a = i.map((e) => Q.fromId(e));
13001
13060
  return (await Vs.createConversation(j.uuid(), e, t, {
13002
13061
  onlyAdminCanShareMovie: n,
@@ -13004,115 +13063,114 @@ async function Vc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r
13004
13063
  audioOnly: r
13005
13064
  }, a)).join_link;
13006
13065
  }
13007
- async function Hc() {
13066
+ async function Uc() {
13008
13067
  let e = $.current();
13009
13068
  return e ? e.createJoinLink() : Promise.reject();
13010
13069
  }
13011
- async function Uc() {
13070
+ async function Wc() {
13012
13071
  let e = $.current();
13013
13072
  return e ? e.removeJoinLink() : Promise.reject();
13014
13073
  }
13015
- async function Wc(e, t) {
13074
+ async function Gc(e, t) {
13016
13075
  return Vs.getAnonymTokenByLink(e, t);
13017
13076
  }
13018
- function Gc(e) {
13077
+ function Kc(e) {
13019
13078
  let t = $.current();
13020
13079
  t && t.setVolume(e);
13021
13080
  }
13022
- function Kc(e) {
13081
+ function qc(e) {
13023
13082
  M.forceRelayPolicy = e;
13024
13083
  }
13025
- async function qc(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
13084
+ async function Jc(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
13026
13085
  let o = $.current();
13027
13086
  return o ? o.startStream(e, t, n, r, i, a) : Promise.reject();
13028
13087
  }
13029
- async function Jc(e = null, t) {
13088
+ async function Yc(e = null, t) {
13030
13089
  let n = $.current();
13031
13090
  return n ? n.stopStream(e, t) : Promise.reject();
13032
13091
  }
13033
- async function Yc(e = null) {
13092
+ async function Xc(e = null) {
13034
13093
  let t = $.current();
13035
13094
  return t ? t.publishStream(e) : Promise.reject();
13036
13095
  }
13037
- async function Xc() {
13096
+ async function Zc() {
13038
13097
  let e = $.current();
13039
13098
  return e ? e.getStreamInfo() : Promise.reject();
13040
13099
  }
13041
- async function Zc(e) {
13100
+ async function Qc(e) {
13042
13101
  let t = $.current();
13043
13102
  return t ? t.addMovie(e) : Promise.reject();
13044
13103
  }
13045
- async function Qc(e) {
13104
+ async function $c(e) {
13046
13105
  let t = $.current();
13047
13106
  return t ? t.updateMovie(e) : Promise.reject();
13048
13107
  }
13049
- async function $c(e) {
13108
+ async function el(e) {
13050
13109
  let t = $.current();
13051
13110
  return t ? t.removeMovie(e) : Promise.reject();
13052
13111
  }
13053
- async function el(e, t) {
13112
+ async function tl(e, t) {
13054
13113
  let n = $.current();
13055
13114
  if (n) {
13056
- let r = [];
13115
+ let r = [], i = [];
13057
13116
  for (let t of e) {
13058
- let e, i;
13117
+ let e, a;
13059
13118
  t.addParticipantIds && (e = [], t.addParticipantIds.forEach((t) => {
13060
- let r = n.getCachedRawOkIdByExternalId(t);
13061
- r ? e.push(j.composeUserId(r)) : R.warn("updateRooms addParticipant: externalId not found in cache", t);
13062
- })), t.removeParticipantIds && (i = [], t.removeParticipantIds.forEach((e) => {
13063
- let t = n.getCachedRawOkIdByExternalId(e);
13064
- t ? i.push(j.composeUserId(t)) : R.warn("updateRooms removeParticipant: externalId not found in cache", e);
13119
+ let r = n.getCachedParticipantIdByExternalId(t);
13120
+ r ? e.push(j.decomposeParticipantId(r).compositeUserId) : i.push(t.id);
13121
+ })), t.removeParticipantIds && (a = [], t.removeParticipantIds.forEach((e) => {
13122
+ let t = n.getCachedParticipantIdByExternalId(e);
13123
+ t ? a.push(j.decomposeParticipantId(t).compositeUserId) : i.push(e.id);
13065
13124
  })), r.push({
13066
13125
  id: t.id,
13067
13126
  name: t.name,
13068
13127
  participantCount: t.participantCount,
13069
13128
  addParticipantIds: e,
13070
- removeParticipantIds: i,
13129
+ removeParticipantIds: a,
13071
13130
  countdownSec: t.countdownSec
13072
13131
  });
13073
13132
  }
13133
+ if (i.length) {
13134
+ Ol(i, "updateRooms", n);
13135
+ return;
13136
+ }
13074
13137
  return n.updateRooms(r, t);
13075
13138
  }
13076
13139
  return Promise.reject();
13077
13140
  }
13078
- async function tl(e, t) {
13141
+ async function nl(e, t) {
13079
13142
  let n = $.current();
13080
13143
  return n ? n.activateRooms(e, t) : Promise.reject();
13081
13144
  }
13082
- async function nl(e = null, t = null) {
13145
+ async function rl(e = null, t = null) {
13083
13146
  let n = $.current();
13084
13147
  if (!n) return Promise.reject();
13085
13148
  let r;
13086
- if (t) {
13087
- let e = n.getCachedRawOkIdByExternalId(t);
13088
- if (!e) {
13089
- R.warn("switchRoom: externalId not found in cache", t);
13090
- return;
13091
- }
13092
- let i = Q.getDeviceIdx(t);
13093
- r = j.composeParticipantId(e, A.USER, i);
13149
+ if (t && (r = n.getCachedParticipantIdByExternalId(t) ?? void 0, !r)) {
13150
+ Dl(t, "switchRoom", n);
13151
+ return;
13094
13152
  }
13095
13153
  return n.switchRoom(e, r);
13096
13154
  }
13097
- async function rl(e) {
13155
+ async function il(e) {
13098
13156
  let t = $.current();
13099
13157
  return t ? t.removeRooms(e) : Promise.reject();
13100
13158
  }
13101
- function il(e) {
13159
+ function al(e) {
13102
13160
  M.statisticsInterval = e;
13103
13161
  let t = $.current();
13104
13162
  if (t) return t.updateStatisticsInterval();
13105
13163
  }
13106
- function al(t) {
13164
+ function ol(t) {
13107
13165
  e.disableLog(!t), R.toggle(t);
13108
13166
  }
13109
- function ol(e, ...t) {
13167
+ function sl(e, ...t) {
13110
13168
  M.debugLog && ($.debugMessage(e, "[external]", ...t) || R.send(e, "[external]", ...t));
13111
13169
  }
13112
- function sl(e, t, ...n) {
13170
+ function cl(e, t, ...n) {
13113
13171
  M.debugLog && ($.debugMessageWithContext(e, t, "[external]", ...n) || R.send(e, "[external]", ...n));
13114
13172
  }
13115
- var cl = {
13173
+ var ll = {
13116
13174
  list: Ne,
13117
13175
  get: Pe,
13118
13176
  getJson: Fe,
@@ -13120,7 +13178,7 @@ var cl = {
13120
13178
  clear: Le,
13121
13179
  stats: Re
13122
13180
  };
13123
- function ll() {
13181
+ function ul() {
13124
13182
  let e = [
13125
13183
  [`Calls SDK ${M.sdkVersion}`, M.toJSON()],
13126
13184
  ["UserAgent:", navigator.userAgent],
@@ -13137,124 +13195,139 @@ function ll() {
13137
13195
  d: e
13138
13196
  }));
13139
13197
  }
13140
- async function ul() {
13198
+ async function dl() {
13141
13199
  let e = $.id(), t = $.debugSessionId();
13142
13200
  if (!t || !e) throw R.error("[uploadDebugLogs]", "No conversation id found"), Error("No conversation id found");
13143
13201
  let n = await Pe({ sessionId: t });
13144
13202
  if (n.length === 0) throw R.error("[uploadDebugLogs]", "No logs found"), Error("No logs found");
13145
13203
  let r = n[0].t, i = n[n.length - 1].t;
13146
13204
  try {
13147
- return Vs?.uploadDebugLogs(e, r, i, JSON.stringify([...ll(), ...n]));
13205
+ return Vs?.uploadDebugLogs(e, r, i, JSON.stringify([...ul(), ...n]));
13148
13206
  } catch (e) {
13149
13207
  throw R.error("[uploadDebugLogs]", "Error while uploading logs", e), Error("Error while uploading logs", { cause: e });
13150
13208
  }
13151
13209
  }
13152
- async function dl(e) {
13210
+ async function fl(e) {
13153
13211
  let t = $.current();
13154
13212
  if (t) return t.videoEffect(e);
13155
13213
  }
13156
- async function fl(e, t) {
13214
+ async function pl(e, t) {
13157
13215
  let n = $.current();
13158
13216
  if (n) return n.audioEffect(e.length > 0 ? e : null, t);
13159
13217
  }
13160
- async function pl(e) {
13218
+ async function ml(e) {
13161
13219
  let t = $.current();
13162
13220
  t && await t.setAudioStream(e);
13163
13221
  }
13164
- async function ml(e, t = null, n = null) {
13222
+ async function hl(e, t = null, n = null) {
13165
13223
  let r = $.current();
13166
13224
  if (!r) return;
13167
13225
  let i = n ?? t?.id, a = null;
13168
- if (t) {
13169
- let e = r.getCachedRawOkIdByExternalId(t);
13170
- if (!e) throw Error("Could not get user id to set animoji svg");
13171
- a = j.composeParticipantId(e, A.USER, Q.getDeviceIdx(t));
13226
+ if (t && (a = r.getCachedParticipantIdByExternalId(t), !a)) {
13227
+ Dl(t, "setVmojiSvg", r);
13228
+ return;
13172
13229
  }
13173
13230
  r.setAnimojiSvg(e, a, i);
13174
13231
  }
13175
- function hl(e) {
13232
+ function gl(e) {
13176
13233
  let t = $.current();
13177
13234
  t && t.setAnimojiFill(e);
13178
13235
  }
13179
- async function gl(e = null, t, n = !1) {
13180
- return El().getWaitingHall(e, t, n);
13236
+ async function _l(e = null, t, n = !1) {
13237
+ return kl().getWaitingHall(e, t, n);
13181
13238
  }
13182
- async function _l() {
13183
- return El().getAudienceModeHands();
13239
+ async function vl() {
13240
+ return kl().getAudienceModeHands();
13184
13241
  }
13185
- async function vl(e, t = !1) {
13186
- let n = El(), r;
13242
+ async function yl(e, t = !1) {
13243
+ let n = kl(), r;
13187
13244
  if (e) {
13188
- let t = n.getCachedRawOkIdByExternalId(e);
13245
+ let t = n.getCachedParticipantIdByExternalId(e);
13189
13246
  if (!t) {
13190
- R.warn("promoteParticipant: externalId not found in cache", e);
13247
+ Dl(e, "promoteParticipant", n);
13191
13248
  return;
13192
13249
  }
13193
- r = j.composeUserId(t);
13250
+ r = j.decomposeParticipantId(t).compositeUserId;
13194
13251
  }
13195
13252
  return n.promoteParticipant(r, t);
13196
13253
  }
13197
- async function yl(e = !1) {
13198
- return El().requestPromotion(e);
13199
- }
13200
13254
  async function bl(e = !1) {
13201
- return El().acceptPromotion(e);
13255
+ return kl().requestPromotion(e);
13202
13256
  }
13203
- async function xl(e) {
13204
- return El().getParticipantListChunk(e);
13257
+ async function xl(e = !1) {
13258
+ return kl().acceptPromotion(e);
13205
13259
  }
13206
13260
  async function Sl(e) {
13207
- return El().getParticipants(e);
13261
+ return kl().getParticipantListChunk(e);
13208
13262
  }
13209
13263
  async function Cl(e) {
13210
- return El().feedback(e);
13264
+ return kl().getParticipants(e);
13211
13265
  }
13212
- async function wl(e, t, n) {
13213
- return El(n).enableFeatureForRoles(e, t);
13266
+ async function wl(e) {
13267
+ return kl().feedback(e);
13214
13268
  }
13215
- function Tl(e) {
13216
- return e ? z.get(e) ?? null : $.current() ?? z.getFirst();
13269
+ async function Tl(e, t, n) {
13270
+ return kl(n).enableFeatureForRoles(e, t);
13217
13271
  }
13218
13272
  function El(e) {
13219
- let t = Tl(e);
13273
+ return e ? z.get(e) ?? null : $.current() ?? z.getFirst();
13274
+ }
13275
+ function Dl(e, t, n) {
13276
+ L.onNonFatalError(/* @__PURE__ */ Error(`Participant ID mapping not found for external ID "${e.id}" while handling ${t}`), n.id);
13277
+ }
13278
+ function Ol(e, t, n) {
13279
+ let r = Array.from(new Set(e));
13280
+ L.onNonFatalError(/* @__PURE__ */ Error(`Participant ID mapping not found for external IDs "${r.join("\", \"")}" while handling ${t}`), n.id);
13281
+ }
13282
+ function kl(e) {
13283
+ let t = El(e);
13220
13284
  if (!t) throw Error("Conversation not found");
13221
13285
  return t;
13222
13286
  }
13223
- async function Dl(e) {
13287
+ function Al(e, t) {
13288
+ let n = $.current();
13289
+ if (!n) return null;
13290
+ let r = n.getCachedParticipantIdByExternalId(e);
13291
+ return r ? {
13292
+ conversation: n,
13293
+ participantId: r
13294
+ } : (Dl(e, t, n), null);
13295
+ }
13296
+ async function jl(e) {
13224
13297
  await Vs.removeHistoryRecords(e);
13225
13298
  }
13226
- async function Ol(e) {
13299
+ async function Ml(e) {
13227
13300
  let t = $.current() ?? z.getFirst();
13228
13301
  t && await t.startAsr(e);
13229
13302
  }
13230
- async function kl(e) {
13303
+ async function Nl(e) {
13231
13304
  let t = $.current() ?? z.getFirst();
13232
13305
  t && await t.stopAsr(e);
13233
13306
  }
13234
- async function Al(e) {
13307
+ async function Pl(e) {
13235
13308
  let t = $.current() ?? z.getFirst();
13236
13309
  t && await t.requestAsr(e);
13237
13310
  }
13238
- async function jl(e) {
13311
+ async function Fl(e) {
13239
13312
  let t = $.current();
13240
13313
  return t ? t.startUrlSharing(e) : Promise.reject();
13241
13314
  }
13242
- async function Ml() {
13315
+ async function Il() {
13243
13316
  let e = $.current();
13244
13317
  return e ? e.stopUrlSharing() : Promise.reject();
13245
13318
  }
13246
- async function Nl(e) {
13319
+ async function Ll(e) {
13247
13320
  await z.switchCall(e);
13248
13321
  }
13249
- function Pl() {
13322
+ function Rl() {
13250
13323
  return z.getActiveId();
13251
13324
  }
13252
- function Fl() {
13325
+ function zl() {
13253
13326
  return $.getSyncedTime();
13254
13327
  }
13255
- function Il() {
13328
+ function Bl() {
13256
13329
  return M.sdkVersion;
13257
13330
  }
13258
13331
  typeof window < "u" && (window.__CALLS_SDK = yn);
13259
13332
  //#endregion
13260
- export { Ps as Api, Bs as ApiExternal, zs as ArrayDequeue, y as AuthData, f as BaseLogger, Ba as CallDirection, Va as CallType, Ha as ChatRoomEventType, Ua as ConversationFeature, Wa as ConversationOption, Sn as DebugMessageType, to as ExternalIdType, jt as FacingMode, x as FatalError, O as HangupReason, D as HangupType, S as MediaOption, k as MediaTrackKind, V as MediaType, qa as MuteState, Z as ParticipantState, Rs as ParticipantStateDataValue, N as ParticipantStatus, Ls as RecordRole, Ja as RoomsEventType, za as Signaling, B as SignalingCommandType, vr as SignalingConnectionType, K as SignalingNotification, J as TransportTopology, Za as UserRole, A as UserType, To as VolumeDetector, rc as acceptCall, bl as acceptPromotion, tl as activateRooms, Zc as addMovie, lc as addParticipant, uc as addParticipantInternal, nc as authorize, Us as browser, Qs as callInternal, Zs as callTo, mc as captureScreen, hc as captureVmoji, fl as changeAudioEffect, Pc as changeConversationOptions, pc as changeDevice, xc as changeParticipantState, bc as changePriorities, dl as changeVideoEffect, Lc as chatHistory, Fc as chatMessage, Ic as chatMessageInternal, Hc as createJoinLink, Rc as customData, zc as customDataInternal, al as debug, cl as debugLogs, ol as debugMessage, sl as debugMessageWithContext, ic as declineCall, wl as enableFeatureForRoles, Mc as enableVideoSuspend, Nc as enableVideoSuspendSuggest, Cl as feedback, Kc as forceRelayPolicy, Pl as getActiveCallId, Wc as getAnonymTokenByLink, _l as getAudienceModeHands, tc as getInbounds, xl as getParticipantListChunk, Sl as getParticipants, Xc as getStreamInfo, Fl as getSyncedTime, gl as getWaitingHall, Tc as grantRoles, Ec as grantRolesInternal, cc as hangup, Xs as init, ac as joinCall, sc as joinCallByLink, oc as joinCallInternal, Dc as muteParticipant, Oc as muteParticipantInternal, kc as pinParticipant, Ac as pinParticipantInternal, $s as processPush, ec as processPushInternal, vl as promoteParticipant, Yc as publishStream, Sc as putHandsDown, Dl as removeHistoryRecords, Uc as removeJoinLink, $c as removeMovie, dc as removeParticipant, fc as removeParticipantInternal, rl as removeRooms, Al as requestAsr, wc as requestDisplayLayout, yl as requestPromotion, qs as setAudioEffects, pl as setAudioStream, yc as setLocalResolution, Gs as setLogger, jc as setMediaModifiers, il as setStatisticsInterval, Js as setVad, Ks as setVideoEffects, gc as setVideoStream, Ys as setVmoji, hl as setVmojiFill, ml as setVmojiSvg, Gc as setVolume, Ol as startAsr, Vc as startAudienceConversation, Bc as startConversation, qc as startStream, jl as startUrlSharing, kl as stopAsr, Jc as stopStream, Ml as stopUrlSharing, Nl as switchCall, nl as switchRoom, vc as toggleLocalAudio, _c as toggleLocalVideo, Cc as updateDisplayLayout, Qc as updateMovie, el as updateRooms, ul as uploadDebugLogs, Ws as utils, Il as version };
13333
+ export { Ps as Api, Bs as ApiExternal, zs as ArrayDequeue, y as AuthData, f as BaseLogger, Ba as CallDirection, Va as CallType, Ha as ChatRoomEventType, Ua as ConversationFeature, Wa as ConversationOption, Sn as DebugMessageType, to as ExternalIdType, jt as FacingMode, x as FatalError, O as HangupReason, D as HangupType, S as MediaOption, k as MediaTrackKind, V as MediaType, qa as MuteState, Z as ParticipantState, Rs as ParticipantStateDataValue, N as ParticipantStatus, Ls as RecordRole, Ja as RoomsEventType, za as Signaling, B as SignalingCommandType, vr as SignalingConnectionType, K as SignalingNotification, J as TransportTopology, Za as UserRole, A as UserType, To as VolumeDetector, ic as acceptCall, xl as acceptPromotion, nl as activateRooms, Qc as addMovie, uc as addParticipant, dc as addParticipantInternal, rc as authorize, Us as browser, $s as callInternal, Zs as callTo, hc as captureScreen, gc as captureVmoji, pl as changeAudioEffect, Fc as changeConversationOptions, mc as changeDevice, Sc as changeParticipantState, xc as changePriorities, fl as changeVideoEffect, Rc as chatHistory, Ic as chatMessage, Lc as chatMessageInternal, Uc as createJoinLink, zc as customData, Bc as customDataInternal, ol as debug, ll as debugLogs, sl as debugMessage, cl as debugMessageWithContext, ac as declineCall, Tl as enableFeatureForRoles, Nc as enableVideoSuspend, Pc as enableVideoSuspendSuggest, wl as feedback, qc as forceRelayPolicy, Rl as getActiveCallId, Gc as getAnonymTokenByLink, vl as getAudienceModeHands, nc as getInbounds, Sl as getParticipantListChunk, Cl as getParticipants, Zc as getStreamInfo, zl as getSyncedTime, _l as getWaitingHall, Ec as grantRoles, Dc as grantRolesInternal, lc as hangup, Xs as init, oc as joinCall, cc as joinCallByLink, sc as joinCallInternal, Oc as muteParticipant, kc as muteParticipantInternal, Ac as pinParticipant, jc as pinParticipantInternal, ec as processPush, tc as processPushInternal, yl as promoteParticipant, Xc as publishStream, Cc as putHandsDown, jl as removeHistoryRecords, Wc as removeJoinLink, el as removeMovie, fc as removeParticipant, pc as removeParticipantInternal, il as removeRooms, Pl as requestAsr, Tc as requestDisplayLayout, bl as requestPromotion, qs as setAudioEffects, ml as setAudioStream, bc as setLocalResolution, Gs as setLogger, Mc as setMediaModifiers, al as setStatisticsInterval, Js as setVad, Ks as setVideoEffects, _c as setVideoStream, Ys as setVmoji, gl as setVmojiFill, hl as setVmojiSvg, Kc as setVolume, Ml as startAsr, Hc as startAudienceConversation, Vc as startConversation, Jc as startStream, Fl as startUrlSharing, Nl as stopAsr, Yc as stopStream, Il as stopUrlSharing, Ll as switchCall, rl as switchRoom, yc as toggleLocalAudio, vc as toggleLocalVideo, wc as updateDisplayLayout, $c as updateMovie, tl as updateRooms, dl as uploadDebugLogs, Ws as utils, Bl as version };