@vkontakte/calls-sdk 2.8.12 → 2.8.13-beta.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.12
3
- * Wed, 09 Sep 2026 10:07:50 GMT
2
+ * @vkontakte/calls-sdk v2.8.13-beta.0
3
+ * Fri, 11 Sep 2026 06:36:40 GMT
4
4
  * https://calls-sdk.cdn-vk.ru/doc/latest/index.html
5
5
  */
6
6
 
@@ -1029,7 +1029,7 @@ var w;
1029
1029
  function g() {
1030
1030
  if (!yt || yt.readyState === "ended") {
1031
1031
  let e = w.getAudioContext(), t = e.createMediaStreamDestination(), n = e.createGain();
1032
- n.gain.value = 1e-5, n.connect(t), n.connect(e.destination);
1032
+ n.gain.value = 1e-5, n.connect(t), w.browserName() === "Safari" && n.connect(e.destination);
1033
1033
  let r = e.createOscillator();
1034
1034
  r.type = "sine", r.frequency.value = 0, r.connect(n), r.start(), yt = t.stream.getAudioTracks()[0];
1035
1035
  }
@@ -2155,7 +2155,7 @@ var yn = vn.getInstance(), M = class e {
2155
2155
  return 1.1;
2156
2156
  }
2157
2157
  static get sdkVersion() {
2158
- return "2.8.12";
2158
+ return "2.8.13-beta.0";
2159
2159
  }
2160
2160
  static get debug() {
2161
2161
  return e._params.debug;
@@ -3065,6 +3065,10 @@ var xn;
3065
3065
  P("onPeerRegistered", e, t);
3066
3066
  }
3067
3067
  e.onPeerRegistered = ot;
3068
+ function st(e, t) {
3069
+ P("onNonFatalError", e, t);
3070
+ }
3071
+ e.onNonFatalError = st;
3068
3072
  })(xn || (xn = {}));
3069
3073
  var L = xn, Sn = /* @__PURE__ */ function(e) {
3070
3074
  return e.DEBUG = "DEBUG", e.LOG = "LOG", e.WARN = "WARN", e.ERROR = "ERROR", e;
@@ -4916,7 +4920,7 @@ var Qr = class {
4916
4920
  }
4917
4921
  }, ui = class extends oi {
4918
4922
  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();
4923
+ 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
4924
  }
4921
4925
  _processFrame(e) {
4922
4926
  e.keyframe && (this._decoderQueue = []), this._decoderQueue.push(e), this._decodeQueue();
@@ -4931,7 +4935,11 @@ var Qr = class {
4931
4935
  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
4936
  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
4937
  }, (e) => {
4934
- this._decoderBusy = !1, this._decodeQueue(), this._decoder instanceof ti && typeof e == "string" && e.includes("EncodingError") && this._switchToLibVPXDecoder();
4938
+ if (this._decoderBusy = !1, this._decoder instanceof ti && typeof e == "string" && e.includes("EncodingError")) {
4939
+ 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();
4940
+ return;
4941
+ }
4942
+ this._decodeQueue();
4935
4943
  }, this._onKeyFrameRequested).then(() => {
4936
4944
  this._decoderReady = !0, this._decodeQueue();
4937
4945
  }).catch((e) => {
@@ -4939,7 +4947,7 @@ var Qr = class {
4939
4947
  });
4940
4948
  }
4941
4949
  _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);
4950
+ 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
4951
  }
4944
4952
  _decodeQueue() {
4945
4953
  if (!this._decoderReady || this._decoderBusy) return;
@@ -5838,7 +5846,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5838
5846
  this._perfStatReporter?.destroy(), this._perfStatReporter = new pa(this, this._signaling, this._statAggregator, !1, this._debug);
5839
5847
  }
5840
5848
  _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);
5849
+ 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
5850
  }
5843
5851
  static _closeDataChannel(e) {
5844
5852
  e && (e.onopen = null, e.onmessage = null, e.onerror = null, e.close());
@@ -5908,10 +5916,10 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5908
5916
  this._triggerEvent(X.NETWORK_STATUS, e);
5909
5917
  }
5910
5918
  _updateSSRCMap(e) {
5911
- e && ln(e.sdp).forEach((e) => {
5919
+ e && (this._ssrcMap = {}, this._ssrcMapUpdated = !0, ln(e.sdp).forEach((e) => {
5912
5920
  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
- });
5921
+ n && (this._ssrcMap[n[1]] = n[3]);
5922
+ }));
5915
5923
  }
5916
5924
  _createCaptureSender(e) {
5917
5925
  let t = this._mediaSource.mediaSettings;
@@ -8251,8 +8259,8 @@ var bo = 90, xo = 3, So = class extends b {
8251
8259
  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
8260
  }
8253
8261
  }, 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;
8262
+ constructor({ api: e, debug: t, getParticipants: n, isMe: r, updateDisplayLayout: i, onNonFatalError: a }) {
8263
+ 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
8264
  }
8257
8265
  request(e) {
8258
8266
  this._pendingRequests = e.slice(), this._lastRequests = e.slice();
@@ -8288,11 +8296,16 @@ var bo = 90, xo = 3, So = class extends b {
8288
8296
  this._pendingRequests = null, this._pendingPromises = [];
8289
8297
  let r = {};
8290
8298
  try {
8291
- r = this._getRequestLayouts(t);
8292
- let i = this._forceNextFlush || Object.keys(this._uncertainLayouts).length > 0;
8299
+ let i = this._getRequestLayouts(t);
8300
+ if (!i) {
8301
+ n.forEach(({ resolve: e }) => e());
8302
+ return;
8303
+ }
8304
+ r = i;
8305
+ let a = this._forceNextFlush || Object.keys(this._uncertainLayouts).length > 0;
8293
8306
  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());
8307
+ let o = this._getDiff(r, a);
8308
+ o.length && await this._updateDisplayLayout(o), e === this._generation && (this._requestedLayouts = r, this._uncertainLayouts = {}), n.forEach(({ resolve: e }) => e());
8296
8309
  } catch (t) {
8297
8310
  e === this._generation ? (this._uncertainLayouts = {
8298
8311
  ...this._uncertainLayouts,
@@ -8303,30 +8316,30 @@ var bo = 90, xo = 3, So = class extends b {
8303
8316
  }
8304
8317
  }
8305
8318
  _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}`);
8319
+ let t = {}, n = [], r = this._getParticipants();
8320
+ for (let i of e) {
8321
+ let e = typeof i.uid == "object" ? i.uid : Q.fromId(i.uid), a = this._api.getCachedParticipantIdByExternalId(e);
8322
+ if (!a) {
8323
+ this._debug.log(`Unknown participant external ID ${typeof i.uid == "object" ? Q.toString(i.uid) : i.uid}`), n.push(e.id);
8311
8324
  continue;
8312
8325
  }
8313
- if (!n[i] && !this._isMe(i)) continue;
8314
- let a = Mn({
8315
- participantId: i,
8316
- mediaType: r.mediaType,
8317
- streamName: r.streamName
8326
+ if (!r[a] && !this._isMe(a)) continue;
8327
+ let o = Mn({
8328
+ participantId: a,
8329
+ mediaType: i.mediaType,
8330
+ streamName: i.streamName
8318
8331
  });
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 }
8332
+ t[o] = {
8333
+ uid: i.uid,
8334
+ mediaType: i.mediaType,
8335
+ width: i.width,
8336
+ height: i.height,
8337
+ fit: i.cover ? "cv" : "cn",
8338
+ ...i.priority === void 0 ? {} : { priority: i.priority },
8339
+ ...i.streamName === void 0 ? {} : { streamName: i.streamName }
8327
8340
  };
8328
8341
  }
8329
- return t;
8342
+ 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
8343
  }
8331
8344
  _getDiff(e, t = !1) {
8332
8345
  let n = [];
@@ -8365,7 +8378,7 @@ var bo = 90, xo = 3, So = class extends b {
8365
8378
  h(this, "_analyser", null), h(this, "_gainNode", null), h(this, "_fftBins", null), h(this, "_mediaStreamSource", null), h(this, "_lastSmoothedLevel", 0), h(this, "_trackId", void 0), h(this, "_track", void 0), h(this, "_stream", void 0), this._trackId = e, this._track = t, this._stream = new MediaStream([t]);
8366
8379
  try {
8367
8380
  let e = T.getAudioContext();
8368
- this._gainNode = e.createGain(), this._gainNode.gain.value = 1e-5, this._gainNode.connect(e.destination), this._analyser = e.createAnalyser(), this._analyser.fftSize = 1024, this._analyser.smoothingTimeConstant = 0, this._analyser.connect(this._gainNode), this._fftBins = new Uint8Array(this._analyser.frequencyBinCount), this._mediaStreamSource = e.createMediaStreamSource(this._stream), this._mediaStreamSource.connect(this._analyser);
8381
+ this._analyser = e.createAnalyser(), this._analyser.fftSize = 1024, this._analyser.smoothingTimeConstant = 0, T.browserName() === "Safari" && (this._gainNode = e.createGain(), this._gainNode.gain.value = 1e-5, this._gainNode.connect(e.destination), this._analyser.connect(this._gainNode)), this._fftBins = new Uint8Array(this._analyser.frequencyBinCount), this._mediaStreamSource = e.createMediaStreamSource(this._stream), this._mediaStreamSource.connect(this._analyser);
8369
8382
  } catch {}
8370
8383
  }
8371
8384
  get track() {
@@ -9348,7 +9361,8 @@ var ls = 15, $ = class e extends b {
9348
9361
  debug: this._debug,
9349
9362
  getParticipants: () => this._participants,
9350
9363
  isMe: (e) => this._isMe(e),
9351
- updateDisplayLayout: (e) => this.updateDisplayLayout(e)
9364
+ updateDisplayLayout: (e) => this.updateDisplayLayout(e),
9365
+ onNonFatalError: (e) => this._onNonFatalError(e)
9352
9366
  }), this._onUnload = () => {
9353
9367
  this._stopFirstMediaSentProbe(), this._conversation && this._api && this._sendHangupApi(this._conversation.id, this._state === "IDLE" ? D.CANCELED : D.HUNGUP), this._stats.destroy();
9354
9368
  }, 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 +9398,9 @@ var ls = 15, $ = class e extends b {
9384
9398
  get isCallHeld() {
9385
9399
  return this._state === "HELD";
9386
9400
  }
9401
+ get isIncomingRinging() {
9402
+ return this._conversation?.direction === Ba.INCOMING && this._state === "IDLE";
9403
+ }
9387
9404
  static debugSessionId() {
9388
9405
  return e.current()?.debugSessionId ?? null;
9389
9406
  }
@@ -9401,8 +9418,14 @@ var ls = 15, $ = class e extends b {
9401
9418
  get debugSessionId() {
9402
9419
  return this._debug.sessionId;
9403
9420
  }
9404
- getCachedRawOkIdByExternalId(e) {
9405
- return this._api.getCachedRawOkIdByExternalId(e);
9421
+ getCachedParticipantIdByExternalId(e) {
9422
+ return this._api.getCachedParticipantIdByExternalId(e);
9423
+ }
9424
+ _onNonFatalError(e) {
9425
+ L.onNonFatalError(Error(e), this.id);
9426
+ }
9427
+ getIncomingCallerExternalId() {
9428
+ return this._conversation?.direction === Ba.INCOMING ? Object.values(this._participants).find((e) => !this._isMe(e.id))?.externalId ?? null : null;
9406
9429
  }
9407
9430
  _buildInternalParams() {
9408
9431
  let e = {
@@ -9445,11 +9468,15 @@ var ls = 15, $ = class e extends b {
9445
9468
  description: "not-initialized-after-start"
9446
9469
  } });
9447
9470
  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", {
9471
+ if (this._debug.debug("Outgoing call", {
9449
9472
  opponentIds: e,
9450
9473
  opponentType: t,
9451
9474
  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(() => {
9475
+ }), 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) {
9476
+ let e = z.get(this._conversation.id);
9477
+ e && e !== this && e._close(new O(D.HUNGUP, { remote: !0 }));
9478
+ }
9479
+ 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
9480
  this._calleeUnavailableTimer = null, this._close(new O(D.CALLEE_UNAVAILABLE), { signalingReason: D.CANCELED });
9454
9481
  }, f)), this._conversation;
9455
9482
  } catch (e) {
@@ -9506,7 +9533,11 @@ var ls = 15, $ = class e extends b {
9506
9533
  }
9507
9534
  }
9508
9535
  _extractExternalRooms(e) {
9509
- return e.map(this._convertRoomToExternal.bind(this)).filter((e) => !!e);
9536
+ let t = [], n = [];
9537
+ return e.forEach((e) => {
9538
+ let { room: r, missingParticipantIds: i } = this._convertRoomToExternal(e);
9539
+ r && n.push(r), t.push(...i);
9540
+ }), this._reportMissingExternalIds(t, "EXTRACT_EXTERNAL_ROOMS"), n.filter((e) => !!e);
9510
9541
  }
9511
9542
  _extractExternalRoomsData(e, t) {
9512
9543
  if (!e || !e.length) return;
@@ -9731,7 +9762,8 @@ var ls = 15, $ = class e extends b {
9731
9762
  D.CALLEE_IS_OFFLINE,
9732
9763
  D.CALLEE_UNAVAILABLE,
9733
9764
  D.CALLER_IS_BLOCKED,
9734
- D.CALLER_IS_REJECTED
9765
+ D.CALLER_IS_REJECTED,
9766
+ D.HAS_ACTIVE_CALL
9735
9767
  ].indexOf(e.hangup) !== -1 || e.hangup === D.REJECTED && !e.remote) {
9736
9768
  this._emitHangupOnce(e, i), this._destroy(r);
9737
9769
  return;
@@ -9988,19 +10020,17 @@ var ls = 15, $ = class e extends b {
9988
10020
  isInRoom: !1,
9989
10021
  markers: null
9990
10022
  }, 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;
10023
+ if (!i) {
10024
+ let e = this._getParticipantId(t ?? r.id);
10025
+ e && (r.externalId = e);
10026
+ }
10027
+ 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
10028
  }
9993
10029
  _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
- }
10030
+ let t = this._api.userId(e);
10031
+ if (t) return t;
10032
+ let { compositeUserId: n, deviceIdx: r } = j.decomposeParticipantId(e), { id: i, type: a } = j.decomposeId(n);
10033
+ return a === A.GROUP ? Q.fromId(String(i), void 0, r) : null;
10004
10034
  }
10005
10035
  _cacheParticipantExternalIds(e) {
10006
10036
  e.forEach((e) => {
@@ -10008,7 +10038,7 @@ var ls = 15, $ = class e extends b {
10008
10038
  if (n) {
10009
10039
  this._api.cacheExternalId(t, n);
10010
10040
  let r = j.composeDecorativeId(e), i = Q.fromSignalingParticipant(e);
10011
- r && i && (this._api.cacheExternalId(r, i), this._api.mapDecorativeId(e.decorativeUserId, e.id));
10041
+ r && i && (this._api.cacheExternalId(r, i), this._api.mapDecorativeId(r, t));
10012
10042
  }
10013
10043
  });
10014
10044
  }
@@ -10057,7 +10087,11 @@ var ls = 15, $ = class e extends b {
10057
10087
  audienceMode: this._isAudienceMode(t),
10058
10088
  restricted: this._isRestricted(t),
10059
10089
  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();
10090
+ }, 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");
10091
+ let l = z.get(this._conversation.id);
10092
+ if (l && l !== this) this._conversation.concurrent = !0;
10093
+ else if (!M.hold && z.callsLength > 0) throw new O(D.HAS_ACTIVE_CALL);
10094
+ this._changeFeatureSet(), this._changeFeaturesPerRole(), this._logDevices();
10061
10095
  }
10062
10096
  _updateConversation(e) {
10063
10097
  if (!this._conversation) throw new O(D.UNKNOWN_ERROR, { callError: {
@@ -10187,33 +10221,40 @@ var ls = 15, $ = class e extends b {
10187
10221
  _getExistedParticipantByIdOrCreate(e) {
10188
10222
  let t = this._participants[e];
10189
10223
  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);
10224
+ let n = this._api.getDecorativeIdByInitialId(e), r = this._getParticipantId(e), { deviceIdx: i } = j.decomposeParticipantId(e);
10191
10225
  return this._createParticipant({
10192
10226
  id: e,
10193
- externalId: {
10194
- ...i,
10195
- deviceIdx: a
10196
- }
10197
- }, r, !1);
10227
+ externalId: r ? {
10228
+ ...r,
10229
+ deviceIdx: i
10230
+ } : void 0
10231
+ }, n, !1);
10198
10232
  }
10199
10233
  _getExternalIdByParticipantId(e) {
10200
- if (this._isMe(e)) return this._conversation?.externalId;
10234
+ if (this._isMe(e)) return this._conversation?.externalId ?? null;
10201
10235
  if (M.useParticipantListChunk) return this._getExistedParticipantByIdOrCreate(e).externalId;
10202
10236
  let t = this._participants;
10203
10237
  if (t[e]?.externalId) return t[e].externalId;
10204
- {
10205
- let t = this._getParticipantId(e);
10206
- return this._api.cacheExternalId(e, t), t;
10207
- }
10238
+ let n = this._api.getCachedExternalIdByParticipantId(e);
10239
+ if (n) return n;
10240
+ let r = this._getParticipantId(e);
10241
+ return r && this._api.cacheExternalId(e, r), r;
10208
10242
  }
10209
- _getExternalIdsByOkIdsFromCache(e) {
10210
- return e.map((e) => this._api.getCachedExternalIdByOkId(e) ?? Q.fromId(String(e)));
10243
+ _getExternalIdsByParticipantIds(e) {
10244
+ let t = [], n = [];
10245
+ return e.forEach((e) => {
10246
+ let r = this._getExternalIdByParticipantId(e);
10247
+ r ? t.push(r) : n.push(e);
10248
+ }), {
10249
+ externalIds: t,
10250
+ missingIds: n
10251
+ };
10211
10252
  }
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;
10253
+ _reportMissingExternalIds(e, t) {
10254
+ e.length && this._onNonFatalError(`External ID mapping not found for participants "${Array.from(new Set(e)).join("\", \"")}" while handling ${t}`);
10255
+ }
10256
+ _reportMissingExternalIdsById(e, t) {
10257
+ e.length && this._onNonFatalError(`Participant ID mapping not found for external IDs "${Array.from(new Set(e)).join("\", \"")}" while handling ${t}`);
10217
10258
  }
10218
10259
  _registerParticipantAndSetMarkersIfChunkEnabled(e, t) {
10219
10260
  if (M.useParticipantListChunk) {
@@ -10498,30 +10539,34 @@ var ls = 15, $ = class e extends b {
10498
10539
  async updateDisplayLayout(e) {
10499
10540
  if (e.length < 1 || !this._signaling.ready) return;
10500
10541
  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) {
10542
+ let t = {}, n = [], r = [], i = this._participants;
10543
+ for (let a of e) {
10544
+ let e = typeof a.uid == "object" ? a.uid : Q.fromId(a.uid), o = this._api.getCachedParticipantIdByExternalId(e);
10545
+ if (!o) {
10505
10546
  let t = Q.toString(e);
10506
- this._debug.log(`Unknown participant external ID ${t}`);
10547
+ this._debug.log(`Unknown participant external ID ${t}`), r.push(e.id);
10507
10548
  continue;
10508
10549
  }
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();
10550
+ let s = Mn({
10551
+ participantId: o,
10552
+ mediaType: a.mediaType,
10553
+ streamName: a.streamName
10554
+ }), c = i[o];
10555
+ c ? n.push(() => {
10556
+ c.lastRequestedLayouts[s] = a;
10557
+ }) : this._isMe(o) && n.push(() => {
10558
+ this._myLastRequestedLayouts[s] = a;
10559
+ }), Dn(a) ? (this._isMe(o) && n.push(() => {
10560
+ delete this._myLastRequestedLayouts[s];
10561
+ }), 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));
10562
+ }
10563
+ if (r.length) {
10564
+ this._reportMissingExternalIdsById(r, "updateDisplayLayout");
10565
+ return;
10566
+ }
10567
+ let a = this._cooldownTimestampByStreamDescription.keys();
10523
10568
  for (; this._streamIdByStreamDescription.size > M.videoTracksCount;) {
10524
- let e = i.next();
10569
+ let e = a.next();
10525
10570
  if (e.done) {
10526
10571
  this._debug.error("Cannot accommodate all streaming requests: tracks available " + M.videoTracksCount + "; requested streams: " + Array.from(this._streamIdByStreamDescription.keys()));
10527
10572
  break;
@@ -10613,17 +10658,22 @@ var ls = 15, $ = class e extends b {
10613
10658
  async _onParticipantPromoted(e) {
10614
10659
  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
10660
  }
10616
- async _onChatRoomUpdated(e, t = 0, n = [], r, i) {
10661
+ _onChatRoomUpdated(e, t = 0, n = [], r, i) {
10617
10662
  this._debug.log(`Chat room updated: ${e}`);
10618
- let a = [];
10663
+ let a = [], o = [];
10619
10664
  n.length && n.forEach((e) => {
10620
10665
  if (e.externalId) {
10621
10666
  let t = Q.fromSignaling(e.externalId);
10622
10667
  a.push(t), this._api.cacheExternalId(e.id.id, t);
10623
- } else a.push(this._getOrCacheExternalIdByCompositeId(e.id.id));
10668
+ } else {
10669
+ let t = this._getExternalIdByParticipantId(e.id.id);
10670
+ t ? a.push(t) : o.push(e.id.id);
10671
+ }
10624
10672
  });
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);
10673
+ let { externalIds: s, missingIds: c } = this._getExternalIdsByParticipantIds(r ?? []);
10674
+ o.push(...c);
10675
+ let { externalIds: l, missingIds: u } = this._getExternalIdsByParticipantIds(i ?? []);
10676
+ o.push(...u), this._reportMissingExternalIds(o, "CHAT_ROOM_UPDATED"), L.onChatRoomUpdated(e, t, a, s, l, this.id);
10627
10677
  }
10628
10678
  _onSharedMovieUpdate(e) {
10629
10679
  let t = this._conversation?.externalId;
@@ -10846,34 +10896,37 @@ var ls = 15, $ = class e extends b {
10846
10896
  let r = null;
10847
10897
  if (e && (r = ro(e), r)) {
10848
10898
  let e = this._api.getDecorativeIdByInitialId(r.id);
10849
- r.id = e ? j.composeUserId(e) : r.id;
10899
+ r.id = e ?? r.id;
10850
10900
  }
10851
10901
  let i = await this._signaling.getWaitingHall(r, t, n);
10852
10902
  if (i.error) return Promise.reject(i.message);
10853
- let a = i.participants || [], { externalIds: o } = await this._resolveWaitingHallExternalIds(a), s = null;
10903
+ let a = i.participants || [], { externalIds: o } = this._resolveWaitingHallExternalIds(a, "getWaitingHall"), s = null;
10854
10904
  return a.length && i.hasMore && (s = no(a[a.length - 1].id)), {
10855
10905
  participants: o,
10856
10906
  pageMarker: s,
10857
10907
  totalCount: i.totalCount || 0
10858
10908
  };
10859
10909
  }
10860
- async _resolveWaitingHallExternalIds(e) {
10861
- let t = [], n = [];
10910
+ _resolveWaitingHallExternalIds(e, t) {
10911
+ let n = [], r = [], i = [];
10862
10912
  return e.length && e.forEach((e) => {
10863
10913
  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
10914
+ let t = Q.fromSignaling(e.externalId);
10915
+ n.push(e.id.addedTs), r.push(t), this._api.cacheExternalId(e.id.id, t);
10916
+ } else {
10917
+ let t = this._getExternalIdByParticipantId(e.id.id);
10918
+ t ? (r.push(t), n.push(e.id.addedTs)) : i.push(e.id.id);
10919
+ }
10920
+ }), this._reportMissingExternalIds(i, t), {
10921
+ externalIds: r,
10922
+ timestamps: n
10870
10923
  };
10871
10924
  }
10872
10925
  async getAudienceModeHands() {
10873
10926
  if (!this._signaling.ready) throw Error("Signaling is not ready");
10874
10927
  let e = await this._signaling.getHandQueue();
10875
10928
  if (e.error) return Promise.reject(e.message);
10876
- let t = e.participants || [], { externalIds: n, timestamps: r } = await this._resolveWaitingHallExternalIds(t);
10929
+ let t = e.participants || [], { externalIds: n, timestamps: r } = this._resolveWaitingHallExternalIds(t, "getAudienceModeHands");
10877
10930
  return {
10878
10931
  timestamps: r,
10879
10932
  participants: n,
@@ -11042,7 +11095,7 @@ var ls = 15, $ = class e extends b {
11042
11095
  unmuteOptions: e.unmuteOptions || [],
11043
11096
  observedIds: e.observedIds || [],
11044
11097
  markers: this._denormalizeMarkers(t, e.markers)
11045
- }, e.decorativeUserId);
11098
+ }, j.composeDecorativeId(e));
11046
11099
  }));
11047
11100
  }
11048
11101
  async getParticipantListChunk(e) {
@@ -11088,7 +11141,7 @@ var ls = 15, $ = class e extends b {
11088
11141
  this._warnParticipantNotInConversation(e);
11089
11142
  return;
11090
11143
  }
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);
11144
+ 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
11145
  }
11093
11146
  _extractLocalParticipantFromConnection(e) {
11094
11147
  let t = this._api.getUserId();
@@ -11104,7 +11157,7 @@ var ls = 15, $ = class e extends b {
11104
11157
  this._warnParticipantNotInConversation(e);
11105
11158
  return;
11106
11159
  }
11107
- n.participantState = t || {}, ["ACTIVE", "HELD"].includes(this._state) && L.onRemoteParticipantState(n.externalId, n.participantState, n.markers, this.id);
11160
+ 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
11161
  }
11109
11162
  _changeMultipleParticipantState(e, t) {
11110
11163
  this._debug.debug("Multiple participants state changed", e);
@@ -11239,30 +11292,37 @@ var ls = 15, $ = class e extends b {
11239
11292
  async _onAcceptedCall(e) {
11240
11293
  let t = j.composeMessageId(e), n = j.getPeerIdString(e.peerId);
11241
11294
  if (this._debug.debug(`Participant accepted call [${t}]`), this._statFirstMediaReceived.markAcceptedCall(this._transport?.getTopology()), this._conversation && this._isMe(t)) {
11295
+ if (this._conversation.concurrent) return;
11242
11296
  this._close(new O(D.MISSED), { errorText: "Call accepted on other device" });
11243
11297
  return;
11244
11298
  }
11245
11299
  this._conversation?.direction === Ba.OUTGOING && !this._conversation.concurrent && this._stats.lifecycle.markOutgoingAccepted();
11246
11300
  let r = this._getParticipant(t);
11247
11301
  if (!r) {
11248
- let n = this._api.getDecorativeIdByInitialId(t), i = n ? j.composeUserId(n, e.participantType) : void 0;
11302
+ let n = this._api.getDecorativeIdByInitialId(t);
11249
11303
  r = this._registerParticipantInCache(this._createParticipant({
11250
11304
  id: t,
11251
11305
  externalId: e.externalId ? Q.fromSignaling(e.externalId, e.deviceIdx) : void 0,
11252
11306
  mediaSettings: E(e.mediaSettings)
11253
- }, i));
11307
+ }, n));
11254
11308
  } else if (e.externalId) {
11255
11309
  let t = Q.fromSignaling(e.externalId, e.deviceIdx);
11256
11310
  r.externalId = t, this._api.cacheExternalId(r.id, t);
11257
11311
  }
11258
11312
  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
11313
  let i = Object.keys(r.muteStates);
11260
- i.length && this._onMuteParticipant({
11314
+ if (i.length && this._onMuteParticipant({
11261
11315
  muteStates: r.muteStates,
11262
11316
  mediaOptions: i,
11263
11317
  stateUpdated: !0,
11264
11318
  participantId: t
11265
- }), ["ACTIVE", "HELD"].includes(this._state) && L.onAcceptedCall(r.externalId, xa.parseCapabilities(e.capabilities), this.id);
11319
+ }), ["ACTIVE", "HELD"].includes(this._state)) {
11320
+ if (!r.externalId) {
11321
+ this._reportMissingExternalIds([t], "ACCEPTED_CALL");
11322
+ return;
11323
+ }
11324
+ L.onAcceptedCall(r.externalId, xa.parseCapabilities(e.capabilities), this.id);
11325
+ }
11266
11326
  }
11267
11327
  async _onHungup(e) {
11268
11328
  this._debug.debug(`Participant hungup [${e.participantId}]`, { reason: e.reason });
@@ -11331,7 +11391,7 @@ var ls = 15, $ = class e extends b {
11331
11391
  return;
11332
11392
  }
11333
11393
  if (!n) {
11334
- let { participant: r } = e, i = r.decorativeUserId;
11394
+ let { participant: r } = e, i = j.composeDecorativeId(r);
11335
11395
  this._registerParticipant({
11336
11396
  id: t,
11337
11397
  externalId: Q.fromSignalingParticipant(r, !0, !0),
@@ -11358,7 +11418,7 @@ var ls = 15, $ = class e extends b {
11358
11418
  return;
11359
11419
  }
11360
11420
  if (!n) {
11361
- let { participant: r } = e, i = r.decorativeUserId;
11421
+ let { participant: r } = e, i = j.composeDecorativeId(r);
11362
11422
  this._registerParticipant({
11363
11423
  id: t,
11364
11424
  externalId: Q.fromSignalingParticipant(r, !0, !0),
@@ -11401,7 +11461,7 @@ var ls = 15, $ = class e extends b {
11401
11461
  _onParticipantsStateChanged(e) {
11402
11462
  let { participants: t, roomId: n } = e;
11403
11463
  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 })]);
11464
+ let r = /* @__PURE__ */ new Map(), i = t.map(({ id: e, participantState: t }) => [e, this._getExternalIdByParticipantId(e) ? j.mapParticipantState({ participantState: t }) : void 0]);
11405
11465
  try {
11406
11466
  i.forEach(([e, t]) => {
11407
11467
  t && r.set(e, t);
@@ -11800,8 +11860,8 @@ var ls = 15, $ = class e extends b {
11800
11860
  this._debug.debug(`Remote track added on the participant [${e}]`, { kind: n.kind });
11801
11861
  let r = this._getParticipant(e);
11802
11862
  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);
11863
+ let t = this._api.getDecorativeIdByInitialId(e);
11864
+ 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
11865
  }
11806
11866
  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
11867
  if (r.remoteStream = t, r.secondStream) return;
@@ -11911,46 +11971,63 @@ var ls = 15, $ = class e extends b {
11911
11971
  }
11912
11972
  _onRoomsUpdated(e) {
11913
11973
  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
11974
+ let t = {}, n = [], r = [];
11975
+ for (let i of Object.keys(Ja)) {
11976
+ let a = e.updates[i];
11977
+ a && (a?.rooms?.forEach((e) => {
11978
+ let { room: t, missingParticipantIds: i } = this._convertRoomToExternal(e);
11979
+ t && n.push(t), r.push(...i);
11980
+ }), t[i] = {
11981
+ rooms: n,
11982
+ roomIds: a?.roomIds,
11983
+ deactivated: a?.deactivated
11921
11984
  });
11922
11985
  }
11923
- L.onRoomsUpdated(t, this.id);
11986
+ this._reportMissingExternalIds(r, "ROOMS_UPDATED"), L.onRoomsUpdated(t, this.id);
11924
11987
  }
11925
11988
  _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);
11989
+ let { room: t, missingParticipantIds: n } = this._convertRoomToExternal(e.room || null);
11990
+ 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
11991
  }
11929
11992
  _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;
11993
+ if (!e) return {
11994
+ room: null,
11995
+ missingParticipantIds: []
11996
+ };
11997
+ 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 ?? []);
11998
+ t.push(...r, ...a, ...s);
11999
+ let c;
12000
+ if (e.pinnedParticipantId) {
12001
+ let n = this._getExternalIdByParticipantId(e.pinnedParticipantId);
12002
+ n ? c = n : t.push(e.pinnedParticipantId);
12003
+ }
11932
12004
  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
12005
+ room: {
12006
+ id: e.id,
12007
+ name: e.name,
12008
+ participantCount: e.participantCount,
12009
+ participantIds: n,
12010
+ addParticipantIds: i,
12011
+ removeParticipantIds: o,
12012
+ participants: e.participants?.participants ? this._participantListChunkToExternalChunk(e.participants) : void 0,
12013
+ active: e.active,
12014
+ muteStates: e.muteStates,
12015
+ pinnedParticipantId: c,
12016
+ countdownSec: e.countdownSec,
12017
+ timeoutMs: e.timeoutMs
12018
+ },
12019
+ missingParticipantIds: t
11945
12020
  };
11946
12021
  }
11947
12022
  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()) {
12023
+ let t = this._transport?.getState(), n = e.roomId ?? null, r = [], { externalIds: i, missingIds: a } = this._getExternalIdsByParticipantIds(e.addedParticipantIds ?? []);
12024
+ r.push(...a);
12025
+ let o = e.addedParticipants;
12026
+ if (i.length && o?.length !== i.length && !this._isCalledState()) {
11950
12027
  let e = this._convertExternalIdsToServerExternalIds(i);
11951
- a = (await this._signaling.getParticipants(e)).participants;
12028
+ o = (await this._signaling.getParticipants(e)).participants;
11952
12029
  }
11953
- let o = a?.map((e) => {
12030
+ let s = o?.map((e) => {
11954
12031
  let r = j.composeId(e);
11955
12032
  return this._createParticipant({
11956
12033
  id: r,
@@ -11966,38 +12043,38 @@ var ls = 15, $ = class e extends b {
11966
12043
  observedIds: e.observedIds || [],
11967
12044
  markers: this._denormalizeMarkers(r, e.markers),
11968
12045
  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 = [];
12046
+ }, j.composeDecorativeId(e));
12047
+ }) || [], c = !1;
12048
+ for (let e of s) e.id === this._conversation?.compositeUserId && (c = !0), this._registerParticipantInCache(e);
12049
+ this._transport?.getState() === q.IDLE && !this._isCalledState() && this._openTransport(s, !0);
12050
+ let l = [];
11974
12051
  if (e?.removedParticipantMarkers) {
11975
12052
  for (let t of e.removedParticipantMarkers) if (t.GRID?.id) {
11976
12053
  let e = this._getExternalIdByParticipantId(t.GRID.id);
11977
- c.push(e);
12054
+ e ? l.push(e) : r.push(t.GRID.id);
11978
12055
  }
11979
12056
  }
11980
- if (s && await this._onRoomSwitched(n), c) {
12057
+ if (this._reportMissingExternalIds(r, "ROOM_PARTICIPANTS_UPDATED"), c && await this._onRoomSwitched(n), l) {
11981
12058
  let e = this._conversation?.pinnedParticipantIdByRoom.get(n);
11982
12059
  if (e) {
11983
12060
  let t = this._getExternalIdByParticipantId(e);
11984
12061
  if (t) {
11985
- for (let e of c) if (Q.compare(t, e)) {
12062
+ for (let e of l) if (Q.compare(t, e)) {
11986
12063
  this._conversation?.pinnedParticipantIdByRoom.delete(n);
11987
12064
  break;
11988
12065
  }
11989
12066
  }
11990
12067
  }
11991
12068
  }
11992
- let l = {
12069
+ let u = {
11993
12070
  roomId: n,
11994
12071
  participantCount: e.participantCount,
11995
12072
  addedParticipantIds: i,
11996
- addedParticipants: j.mapSharedParticipants(o),
12073
+ addedParticipants: j.mapSharedParticipants(s),
11997
12074
  removedParticipantMarkers: e?.removedParticipantMarkers,
11998
- removedParticipantIds: c
12075
+ removedParticipantIds: l
11999
12076
  };
12000
- this._isCalledState() || L.onRoomParticipantsUpdated(l, this.id);
12077
+ this._isCalledState() || L.onRoomParticipantsUpdated(u, this.id);
12001
12078
  }
12002
12079
  async _onRoomSwitched(e, t = !1) {
12003
12080
  if (!this._conversation || this._conversation.roomId === e) return;
@@ -12017,7 +12094,7 @@ var ls = 15, $ = class e extends b {
12017
12094
  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
12095
  let e = this._participants;
12019
12096
  await this._registerParticipants(t?.participants?.participants?.filter((t) => !e[j.composeId(t)]) || [], !0);
12020
- let n = this._convertRoomToExternal(t);
12097
+ let { room: n } = this._convertRoomToExternal(t);
12021
12098
  n && r.push(n);
12022
12099
  }
12023
12100
  }
@@ -12051,7 +12128,9 @@ var ls = 15, $ = class e extends b {
12051
12128
  return;
12052
12129
  }
12053
12130
  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;
12131
+ L.onParticipantIdChanged(a, o, this.id);
12132
+ let s = j.compose(n, a.deviceIdx), c = j.compose(t, a.deviceIdx);
12133
+ if (this._api.cacheExternalId(s, o), this._api.mapDecorativeId(s, c), i) this._conversation.externalId = o;
12055
12134
  else {
12056
12135
  let e = this._participants;
12057
12136
  e[t].externalId = o;
@@ -12223,22 +12302,16 @@ var Es = class {
12223
12302
  }
12224
12303
  log(e) {}
12225
12304
  logClientStats(e) {}
12226
- getCachedOkIdByExternalId(e) {
12305
+ getCachedParticipantIdByExternalId(e) {
12227
12306
  return null;
12228
12307
  }
12229
- getCachedRawOkIdByExternalId(e) {
12230
- return null;
12231
- }
12232
- getCachedExternalIdByOkId(e) {
12308
+ getCachedExternalIdByParticipantId(e) {
12233
12309
  return null;
12234
12310
  }
12235
12311
  cacheExternalId(e, t) {}
12236
12312
  mapDecorativeId(e, t) {}
12237
12313
  unmapDecorativeId(e) {}
12238
12314
  getDecorativeIdByInitialId(e) {}
12239
- replaceByInitialIdIdIfExists(e) {
12240
- return typeof e == "string" ? parseInt(e, 10) : e;
12241
- }
12242
12315
  hangupConversation(e, t = D.HUNGUP, n) {}
12243
12316
  async removeHistoryRecords(e) {}
12244
12317
  async getServerTime() {
@@ -12250,7 +12323,7 @@ var Es = class {
12250
12323
  }
12251
12324
  }, Ds = class e {
12252
12325
  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());
12326
+ 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
12327
  }
12255
12328
  static _normalizeType(e) {
12256
12329
  return e.type === to.GROUP ? {
@@ -12258,46 +12331,30 @@ var Es = class {
12258
12331
  type: to.USER
12259
12332
  } : e;
12260
12333
  }
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
12334
  getExternalId(e) {
12266
- let t = this.getDecorativeIdByInitialId(e) ?? e, n = this._okIdToExternalId.get(t);
12335
+ let t = this._initialIdToDecorativeId.get(e) ?? e, n = this._participantIdToExternalId.get(t);
12267
12336
  return n == null ? null : Q.fromString(n);
12268
12337
  }
12269
- hasByExternalId(t) {
12270
- return this._externalIdToOkId.has(Q.toString(e._normalizeType(t)));
12271
- }
12272
- hasByOkId(e) {
12273
- return this._okIdToExternalId.has(e);
12338
+ getParticipantId(t) {
12339
+ let n = Q.toString(e._normalizeType(t)), r = this._externalIdToParticipantId.get(n);
12340
+ return r == null ? null : this._decorativeIdToInitialId.get(r) ?? r;
12274
12341
  }
12275
12342
  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);
12343
+ let r = e._normalizeType(n), i = Q.toString(r);
12344
+ this._participantIdToExternalId.set(t, i), this._externalIdToParticipantId.set(i, t);
12278
12345
  }
12279
12346
  mapDecorativeId(e, t) {
12280
- let n = j.extractOkId(e), r = j.extractOkId(t);
12281
- this._decorativeIdToInitialId.set(n, r), this._initialIdToDecorativeId.set(r, n);
12347
+ this._decorativeIdToInitialId.set(e, t), this._initialIdToDecorativeId.set(t, e);
12282
12348
  }
12283
12349
  unmapDecorativeId(e) {
12284
- let t = j.extractOkId(e), n = this.getDecorativeIdByInitialId(t);
12285
- n && this._decorativeIdToInitialId.delete(n), this._initialIdToDecorativeId.delete(t);
12350
+ let t = this._initialIdToDecorativeId.get(e);
12351
+ t && this._decorativeIdToInitialId.delete(t), this._initialIdToDecorativeId.delete(e);
12286
12352
  }
12287
12353
  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);
12354
+ return this._initialIdToDecorativeId.get(e);
12298
12355
  }
12299
12356
  clear() {
12300
- this._okIdToExternalId.clear(), this._externalIdToOkId.clear(), this._decorativeIdToInitialId.clear(), this._initialIdToDecorativeId.clear();
12357
+ this._participantIdToExternalId.clear(), this._externalIdToParticipantId.clear(), this._decorativeIdToInitialId.clear(), this._initialIdToDecorativeId.clear();
12301
12358
  }
12302
12359
  }, Os = "anonymLogin:", ks = 700, As = 3e3;
12303
12360
  function js(e) {
@@ -12385,8 +12442,11 @@ var Ps = class extends Es {
12385
12442
  }
12386
12443
  }
12387
12444
  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));
12445
+ if (y.isEmpty()) {
12446
+ let { compositeUserId: t } = j.decomposeParticipantId(e), { id: n } = j.decomposeId(t);
12447
+ return Q.fromId(String(n));
12448
+ }
12449
+ return this._idCache.getExternalId(e);
12390
12450
  }
12391
12451
  async authorize() {
12392
12452
  if (this._ensureUuid(), !M.apiKey) throw new O(x.API, {
@@ -12574,13 +12634,10 @@ var Ps = class extends Es {
12574
12634
  };
12575
12635
  return n?.length && (i.observedIds = n.join(",")), M.anonymToken && (i.anonymToken = M.anonymToken), r && (i.payload = r), this._call("vchat.joinConversationByLink", i);
12576
12636
  }
12577
- getCachedOkIdByExternalId(e) {
12578
- return this._idCache.getParticipantIdByExternalId(e);
12637
+ getCachedParticipantIdByExternalId(e) {
12638
+ return this._idCache.getParticipantId(e);
12579
12639
  }
12580
- getCachedRawOkIdByExternalId(e) {
12581
- return this._idCache.getOkId(e);
12582
- }
12583
- getCachedExternalIdByOkId(e) {
12640
+ getCachedExternalIdByParticipantId(e) {
12584
12641
  return this._idCache.getExternalId(e);
12585
12642
  }
12586
12643
  cacheExternalId(e, t) {
@@ -12595,9 +12652,6 @@ var Ps = class extends Es {
12595
12652
  getDecorativeIdByInitialId(e) {
12596
12653
  return this._idCache.getDecorativeIdByInitialId(e);
12597
12654
  }
12598
- replaceByInitialIdIdIfExists(e) {
12599
- return this._idCache.replaceByInitialIdIdIfExists(e);
12600
- }
12601
12655
  async getConversationParams(e) {
12602
12656
  let t = {};
12603
12657
  return M.anonymToken && (t.anonymToken = M.anonymToken), e && (t.conversationId = e), this._call("vchat.getConversationParams", t);
@@ -12747,10 +12801,16 @@ async function Xs(t) {
12747
12801
  }
12748
12802
  async function Zs(e, t = [S.AUDIO], n = "", r = !1, i = !1, a, o, s) {
12749
12803
  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);
12804
+ return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), $s([], Va.USER, t, n, r, i, a, c, o, s);
12751
12805
  }
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);
12806
+ function Qs(e, t = []) {
12807
+ let n = e.getIncomingCallerExternalId();
12808
+ return n ? t.length === 1 && t[0].id === n.id && t[0].type === n.type : !1;
12809
+ }
12810
+ async function $s(e, t = Va.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12811
+ if (!M.hold && z.getActive()) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12812
+ let u = z.getAll().find((e) => e.isIncomingRinging);
12813
+ if (!M.hold && u && !Qs(u, s)) throw R.error("There is already incoming call"), new O(D.HAS_ACTIVE_CALL);
12754
12814
  return new $(new Ps(), Hs).onStart({
12755
12815
  opponentIds: e,
12756
12816
  opponentType: t,
@@ -12764,30 +12824,30 @@ async function Qs(e, t = Va.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12764
12824
  conversationId: l
12765
12825
  });
12766
12826
  }
12767
- async function $s(e, t) {
12768
- return ec(e, A.USER, void 0, t);
12827
+ async function ec(e, t) {
12828
+ return tc(e, A.USER, void 0, t);
12769
12829
  }
12770
- async function ec(e, t = A.USER, n, r, i, a) {
12830
+ async function tc(e, t = A.USER, n, r, i, a) {
12771
12831
  if (e === $.id()) throw Error("Push has already been processed");
12772
12832
  return new $(new Ps(), Hs).onPush(e, t, n, r, i, a);
12773
12833
  }
12774
- async function tc() {
12834
+ async function nc() {
12775
12835
  return Vs.getInbounds();
12776
12836
  }
12777
- async function nc(e, t) {
12837
+ async function rc(e, t) {
12778
12838
  return e && (M.authToken = e), t !== void 0 && M.apiBaseUrl !== t && (M.apiBaseUrl = t, hs()), Vs.authorize();
12779
12839
  }
12780
- async function rc(e = [S.AUDIO], t) {
12781
- return El(t).accept(e);
12840
+ async function ic(e = [S.AUDIO], t) {
12841
+ return kl(t).accept(e);
12782
12842
  }
12783
- async function ic(e) {
12784
- let t = Tl(e?.conversationId);
12843
+ async function ac(e) {
12844
+ let t = El(e?.conversationId);
12785
12845
  if (t) return t.decline(e);
12786
12846
  }
12787
- async function ac(e, t = [S.AUDIO]) {
12788
- return oc(e, t);
12847
+ async function oc(e, t = [S.AUDIO]) {
12848
+ return sc(e, t);
12789
12849
  }
12790
- async function oc(e, t, n) {
12850
+ async function sc(e, t, n) {
12791
12851
  if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12792
12852
  return new $(new Ps(), Hs).onJoin({
12793
12853
  conversationId: e,
@@ -12795,7 +12855,7 @@ async function oc(e, t, n) {
12795
12855
  chatId: n
12796
12856
  });
12797
12857
  }
12798
- async function sc(e, t = [S.AUDIO], n, r, i, a) {
12858
+ async function cc(e, t = [S.AUDIO], n, r, i, a) {
12799
12859
  if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12800
12860
  return n && (M.anonymToken = n), new $(new Ps(), Hs).onJoin({
12801
12861
  joinLink: e,
@@ -12806,30 +12866,30 @@ async function sc(e, t = [S.AUDIO], n, r, i, a) {
12806
12866
  anonymous: !!M.anonymToken
12807
12867
  });
12808
12868
  }
12809
- function cc(e) {
12810
- let t = Tl(e?.conversationId);
12869
+ function lc(e) {
12870
+ let t = El(e?.conversationId);
12811
12871
  return t ? t.hangup(e) : ($.hangupAfterInit(e?.onFastHangup), Promise.resolve());
12812
12872
  }
12813
- async function lc(e, t) {
12873
+ async function uc(e, t) {
12814
12874
  let n = Array.isArray(e) ? e : [e], r = $.current();
12815
12875
  r && await r.addParticipant(n, t);
12816
12876
  }
12817
- async function uc(e, t) {
12877
+ async function dc(e, t) {
12818
12878
  let n = $.current();
12819
12879
  if (n) {
12820
12880
  let r = e.map((e) => j.composeUserId(e));
12821
12881
  await n.addParticipantLegacy(r, t);
12822
12882
  }
12823
12883
  }
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;
12884
+ async function fc(e, t = !1) {
12885
+ let n = Al(e, "removeParticipant");
12886
+ if (n) try {
12887
+ await n.conversation.removeParticipant(j.decomposeParticipantId(n.participantId).compositeUserId, t);
12888
+ } catch (e) {
12889
+ R.warn(`Failed to remove participant ${n.participantId}. Perhaps he is no longer on the call. ${e}`);
12829
12890
  }
12830
- return fc(n, t);
12831
12891
  }
12832
- async function fc(e, t = !1) {
12892
+ async function pc(e, t = !1) {
12833
12893
  let n = $.current();
12834
12894
  if (n) try {
12835
12895
  await n.removeParticipant(j.composeUserId(e), t);
@@ -12837,13 +12897,13 @@ async function fc(e, t = !1) {
12837
12897
  R.warn(`Failed to remove participant ${e}. Perhaps he is no longer on the call. ${t}`);
12838
12898
  }
12839
12899
  }
12840
- async function pc(e, t) {
12900
+ async function mc(e, t) {
12841
12901
  let n = $.current();
12842
12902
  if (e === "videoinput" && jt.contains(t)) return M.videoFacingMode = t, n ? (T.isMobile() && n.stopVideoTrack(), n.changeDevice(e)) : void 0;
12843
12903
  if (!await T._saveDeviceId(e, t)) throw Error(`Device not found: ${t}`);
12844
12904
  if (n) return n.changeDevice(e);
12845
12905
  }
12846
- async function mc(e, t) {
12906
+ async function hc(e, t) {
12847
12907
  let n = typeof e == "object" ? {
12848
12908
  ...e,
12849
12909
  fastScreenSharing: e.captureScreen && e.fastScreenSharing,
@@ -12852,151 +12912,149 @@ async function mc(e, t) {
12852
12912
  captureScreen: e,
12853
12913
  fastScreenSharing: !1,
12854
12914
  captureAudio: !1
12855
- }, r = Tl(t);
12915
+ }, r = El(t);
12856
12916
  return r ? r.toggleScreenCapturing(n) : Promise.reject();
12857
12917
  }
12858
- function hc(e) {
12918
+ function gc(e) {
12859
12919
  let t = $.current();
12860
12920
  t && t.toggleAnimojiCapturing(e);
12861
12921
  }
12862
- async function gc(e, t = !1) {
12922
+ async function _c(e, t = !1) {
12863
12923
  let n = $.current();
12864
12924
  n && await n.setVideoStream(e, t);
12865
12925
  }
12866
- async function _c(e, t) {
12867
- let n = Tl(t);
12926
+ async function vc(e, t) {
12927
+ let n = El(t);
12868
12928
  n && await n.toggleLocalVideo(e);
12869
12929
  }
12870
- async function vc(e, t) {
12871
- let n = Tl(t);
12930
+ async function yc(e, t) {
12931
+ let n = El(t);
12872
12932
  n && await n.toggleLocalAudio(e);
12873
12933
  }
12874
- async function yc(e) {
12934
+ async function bc(e) {
12875
12935
  let t = $.current();
12876
12936
  if (t) return t.setLocalResolution(e);
12877
12937
  }
12878
- async function bc(e) {
12938
+ async function xc(e) {
12879
12939
  let t = $.current();
12880
12940
  t && await t.changePriorities(e);
12881
12941
  }
12882
- async function xc(e, t) {
12942
+ async function Sc(e, t) {
12883
12943
  let n = $.current();
12884
12944
  if (n) {
12885
- let r;
12886
12945
  if (t) {
12887
- let e = n.getCachedRawOkIdByExternalId(t);
12888
- if (!e) {
12889
- R.warn("changeParticipantState: externalId not found in cache", t);
12946
+ let r = n.getCachedParticipantIdByExternalId(t);
12947
+ if (!r) {
12948
+ Dl(t, "changeParticipantState", n);
12890
12949
  return;
12891
12950
  }
12892
- r = j.composeParticipantId(e, A.USER, t.deviceIdx);
12951
+ await n.changeParticipantState(e, r);
12952
+ return;
12893
12953
  }
12894
- await n.changeParticipantState(e, r);
12954
+ await n.changeParticipantState(e);
12895
12955
  }
12896
12956
  }
12897
- async function Sc() {
12957
+ async function Cc() {
12898
12958
  let e = $.current();
12899
12959
  e && await e.putHandsDown();
12900
12960
  }
12901
- async function Cc(e) {
12961
+ async function wc(e) {
12902
12962
  let t = $.current();
12903
12963
  t && await t.updateDisplayLayout(e);
12904
12964
  }
12905
- async function wc(e) {
12965
+ async function Tc(e) {
12906
12966
  let t = $.current();
12907
12967
  t && await t.requestDisplayLayout(e);
12908
12968
  }
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);
12969
+ async function Ec(e, t, n = !1) {
12970
+ let r = Al(e, "grantRoles");
12971
+ r && await r.conversation.grantRoles(r.participantId, t, n);
12916
12972
  }
12917
- async function Ec(e, t, n, r = !1) {
12973
+ async function Dc(e, t, n, r = !1) {
12918
12974
  let i = $.current();
12919
12975
  i && await i.grantRoles(j.composeParticipantId(e, A.USER, t), n, r);
12920
12976
  }
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
- });
12977
+ async function Oc({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
12978
+ if (e) {
12979
+ let i = Al(e, "muteParticipant");
12980
+ return i ? i.conversation.muteParticipant(i.participantId, t, n, r) : void 0;
12981
+ }
12982
+ let i = $.current();
12983
+ i && await i.muteParticipant(null, t, n, r);
12930
12984
  }
12931
- async function Oc({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
12985
+ async function kc({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
12932
12986
  let a = $.current();
12933
12987
  if (a) {
12934
12988
  let o = e ? j.composeParticipantId(e, A.USER, r) : null;
12935
12989
  await a.muteParticipant(o, t, n, i);
12936
12990
  }
12937
12991
  }
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);
12992
+ async function Ac(e, t = !1, n = null) {
12993
+ let r = Al(e, "pinParticipant");
12994
+ r && await r.conversation.pinParticipant(r.participantId, t, n);
12945
12995
  }
12946
- async function Ac(e, t = !1, n = 0, r = null) {
12996
+ async function jc(e, t = !1, n = 0, r = null) {
12947
12997
  let i = $.current();
12948
12998
  i && await i.pinParticipant(j.composeParticipantId(e, A.USER, n), t, r);
12949
12999
  }
12950
- async function jc(e) {
13000
+ async function Mc(e) {
12951
13001
  let t = $.current();
12952
13002
  t && await t.updateMediaModifiers(e);
12953
13003
  }
12954
- async function Mc(e) {
13004
+ async function Nc(e) {
12955
13005
  let t = $.current();
12956
13006
  t && await t.enableVideoSuspend(e);
12957
13007
  }
12958
- async function Nc(e) {
13008
+ async function Pc(e) {
12959
13009
  let t = $.current();
12960
13010
  t && await t.enableVideoSuspendSuggest(e);
12961
13011
  }
12962
- async function Pc(e) {
13012
+ async function Fc(e) {
12963
13013
  let t = $.current();
12964
13014
  t && await t.changeOptions(e);
12965
13015
  }
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
13016
  async function Ic(e, t = null) {
13017
+ if (t) {
13018
+ let n = Al(t, "chatMessage");
13019
+ return n ? n.conversation.chatMessage(e, j.decomposeParticipantId(n.participantId).compositeUserId) : void 0;
13020
+ }
13021
+ let n = $.current();
13022
+ n && await n.chatMessage(e, null);
13023
+ }
13024
+ async function Lc(e, t = null) {
12971
13025
  let n = $.current();
12972
13026
  if (n) {
12973
13027
  let r = t ? j.composeUserId(t) : null;
12974
13028
  await n.chatMessage(e, r);
12975
13029
  }
12976
13030
  }
12977
- async function Lc(e = 10) {
13031
+ async function Rc(e = 10) {
12978
13032
  let t = $.current();
12979
13033
  if (t) return t.chatHistory(e);
12980
13034
  }
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));
13035
+ async function zc(e, t = null) {
13036
+ if (t) {
13037
+ let n = Al(t, "customData");
13038
+ return n ? n.conversation.customData(e, n.participantId) : void 0;
13039
+ }
13040
+ let n = $.current();
13041
+ n && await n.customData(e, null);
12984
13042
  }
12985
- async function zc(e, t = null, n = 0) {
13043
+ async function Bc(e, t = null, n = 0) {
12986
13044
  let r = $.current();
12987
13045
  if (r) {
12988
13046
  let i = t ? j.composeParticipantId(t, A.USER, n) : null;
12989
13047
  await r.customData(e, i);
12990
13048
  }
12991
13049
  }
12992
- async function Bc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
13050
+ async function Vc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
12993
13051
  return (await Vs.createConversation(a ?? j.uuid(), e, t, {
12994
13052
  onlyAdminCanShareMovie: n,
12995
13053
  waitForAdmin: r,
12996
13054
  closedConversation: i
12997
13055
  })).join_link;
12998
13056
  }
12999
- async function Vc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
13057
+ async function Hc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
13000
13058
  let a = i.map((e) => Q.fromId(e));
13001
13059
  return (await Vs.createConversation(j.uuid(), e, t, {
13002
13060
  onlyAdminCanShareMovie: n,
@@ -13004,115 +13062,114 @@ async function Vc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r
13004
13062
  audioOnly: r
13005
13063
  }, a)).join_link;
13006
13064
  }
13007
- async function Hc() {
13065
+ async function Uc() {
13008
13066
  let e = $.current();
13009
13067
  return e ? e.createJoinLink() : Promise.reject();
13010
13068
  }
13011
- async function Uc() {
13069
+ async function Wc() {
13012
13070
  let e = $.current();
13013
13071
  return e ? e.removeJoinLink() : Promise.reject();
13014
13072
  }
13015
- async function Wc(e, t) {
13073
+ async function Gc(e, t) {
13016
13074
  return Vs.getAnonymTokenByLink(e, t);
13017
13075
  }
13018
- function Gc(e) {
13076
+ function Kc(e) {
13019
13077
  let t = $.current();
13020
13078
  t && t.setVolume(e);
13021
13079
  }
13022
- function Kc(e) {
13080
+ function qc(e) {
13023
13081
  M.forceRelayPolicy = e;
13024
13082
  }
13025
- async function qc(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
13083
+ async function Jc(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
13026
13084
  let o = $.current();
13027
13085
  return o ? o.startStream(e, t, n, r, i, a) : Promise.reject();
13028
13086
  }
13029
- async function Jc(e = null, t) {
13087
+ async function Yc(e = null, t) {
13030
13088
  let n = $.current();
13031
13089
  return n ? n.stopStream(e, t) : Promise.reject();
13032
13090
  }
13033
- async function Yc(e = null) {
13091
+ async function Xc(e = null) {
13034
13092
  let t = $.current();
13035
13093
  return t ? t.publishStream(e) : Promise.reject();
13036
13094
  }
13037
- async function Xc() {
13095
+ async function Zc() {
13038
13096
  let e = $.current();
13039
13097
  return e ? e.getStreamInfo() : Promise.reject();
13040
13098
  }
13041
- async function Zc(e) {
13099
+ async function Qc(e) {
13042
13100
  let t = $.current();
13043
13101
  return t ? t.addMovie(e) : Promise.reject();
13044
13102
  }
13045
- async function Qc(e) {
13103
+ async function $c(e) {
13046
13104
  let t = $.current();
13047
13105
  return t ? t.updateMovie(e) : Promise.reject();
13048
13106
  }
13049
- async function $c(e) {
13107
+ async function el(e) {
13050
13108
  let t = $.current();
13051
13109
  return t ? t.removeMovie(e) : Promise.reject();
13052
13110
  }
13053
- async function el(e, t) {
13111
+ async function tl(e, t) {
13054
13112
  let n = $.current();
13055
13113
  if (n) {
13056
- let r = [];
13114
+ let r = [], i = [];
13057
13115
  for (let t of e) {
13058
- let e, i;
13116
+ let e, a;
13059
13117
  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);
13118
+ let r = n.getCachedParticipantIdByExternalId(t);
13119
+ r ? e.push(j.decomposeParticipantId(r).compositeUserId) : i.push(t.id);
13120
+ })), t.removeParticipantIds && (a = [], t.removeParticipantIds.forEach((e) => {
13121
+ let t = n.getCachedParticipantIdByExternalId(e);
13122
+ t ? a.push(j.decomposeParticipantId(t).compositeUserId) : i.push(e.id);
13065
13123
  })), r.push({
13066
13124
  id: t.id,
13067
13125
  name: t.name,
13068
13126
  participantCount: t.participantCount,
13069
13127
  addParticipantIds: e,
13070
- removeParticipantIds: i,
13128
+ removeParticipantIds: a,
13071
13129
  countdownSec: t.countdownSec
13072
13130
  });
13073
13131
  }
13132
+ if (i.length) {
13133
+ Ol(i, "updateRooms", n);
13134
+ return;
13135
+ }
13074
13136
  return n.updateRooms(r, t);
13075
13137
  }
13076
13138
  return Promise.reject();
13077
13139
  }
13078
- async function tl(e, t) {
13140
+ async function nl(e, t) {
13079
13141
  let n = $.current();
13080
13142
  return n ? n.activateRooms(e, t) : Promise.reject();
13081
13143
  }
13082
- async function nl(e = null, t = null) {
13144
+ async function rl(e = null, t = null) {
13083
13145
  let n = $.current();
13084
13146
  if (!n) return Promise.reject();
13085
13147
  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);
13148
+ if (t && (r = n.getCachedParticipantIdByExternalId(t) ?? void 0, !r)) {
13149
+ Dl(t, "switchRoom", n);
13150
+ return;
13094
13151
  }
13095
13152
  return n.switchRoom(e, r);
13096
13153
  }
13097
- async function rl(e) {
13154
+ async function il(e) {
13098
13155
  let t = $.current();
13099
13156
  return t ? t.removeRooms(e) : Promise.reject();
13100
13157
  }
13101
- function il(e) {
13158
+ function al(e) {
13102
13159
  M.statisticsInterval = e;
13103
13160
  let t = $.current();
13104
13161
  if (t) return t.updateStatisticsInterval();
13105
13162
  }
13106
- function al(t) {
13163
+ function ol(t) {
13107
13164
  e.disableLog(!t), R.toggle(t);
13108
13165
  }
13109
- function ol(e, ...t) {
13166
+ function sl(e, ...t) {
13110
13167
  M.debugLog && ($.debugMessage(e, "[external]", ...t) || R.send(e, "[external]", ...t));
13111
13168
  }
13112
- function sl(e, t, ...n) {
13169
+ function cl(e, t, ...n) {
13113
13170
  M.debugLog && ($.debugMessageWithContext(e, t, "[external]", ...n) || R.send(e, "[external]", ...n));
13114
13171
  }
13115
- var cl = {
13172
+ var ll = {
13116
13173
  list: Ne,
13117
13174
  get: Pe,
13118
13175
  getJson: Fe,
@@ -13120,7 +13177,7 @@ var cl = {
13120
13177
  clear: Le,
13121
13178
  stats: Re
13122
13179
  };
13123
- function ll() {
13180
+ function ul() {
13124
13181
  let e = [
13125
13182
  [`Calls SDK ${M.sdkVersion}`, M.toJSON()],
13126
13183
  ["UserAgent:", navigator.userAgent],
@@ -13137,124 +13194,139 @@ function ll() {
13137
13194
  d: e
13138
13195
  }));
13139
13196
  }
13140
- async function ul() {
13197
+ async function dl() {
13141
13198
  let e = $.id(), t = $.debugSessionId();
13142
13199
  if (!t || !e) throw R.error("[uploadDebugLogs]", "No conversation id found"), Error("No conversation id found");
13143
13200
  let n = await Pe({ sessionId: t });
13144
13201
  if (n.length === 0) throw R.error("[uploadDebugLogs]", "No logs found"), Error("No logs found");
13145
13202
  let r = n[0].t, i = n[n.length - 1].t;
13146
13203
  try {
13147
- return Vs?.uploadDebugLogs(e, r, i, JSON.stringify([...ll(), ...n]));
13204
+ return Vs?.uploadDebugLogs(e, r, i, JSON.stringify([...ul(), ...n]));
13148
13205
  } catch (e) {
13149
13206
  throw R.error("[uploadDebugLogs]", "Error while uploading logs", e), Error("Error while uploading logs", { cause: e });
13150
13207
  }
13151
13208
  }
13152
- async function dl(e) {
13209
+ async function fl(e) {
13153
13210
  let t = $.current();
13154
13211
  if (t) return t.videoEffect(e);
13155
13212
  }
13156
- async function fl(e, t) {
13213
+ async function pl(e, t) {
13157
13214
  let n = $.current();
13158
13215
  if (n) return n.audioEffect(e.length > 0 ? e : null, t);
13159
13216
  }
13160
- async function pl(e) {
13217
+ async function ml(e) {
13161
13218
  let t = $.current();
13162
13219
  t && await t.setAudioStream(e);
13163
13220
  }
13164
- async function ml(e, t = null, n = null) {
13221
+ async function hl(e, t = null, n = null) {
13165
13222
  let r = $.current();
13166
13223
  if (!r) return;
13167
13224
  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));
13225
+ if (t && (a = r.getCachedParticipantIdByExternalId(t), !a)) {
13226
+ Dl(t, "setVmojiSvg", r);
13227
+ return;
13172
13228
  }
13173
13229
  r.setAnimojiSvg(e, a, i);
13174
13230
  }
13175
- function hl(e) {
13231
+ function gl(e) {
13176
13232
  let t = $.current();
13177
13233
  t && t.setAnimojiFill(e);
13178
13234
  }
13179
- async function gl(e = null, t, n = !1) {
13180
- return El().getWaitingHall(e, t, n);
13235
+ async function _l(e = null, t, n = !1) {
13236
+ return kl().getWaitingHall(e, t, n);
13181
13237
  }
13182
- async function _l() {
13183
- return El().getAudienceModeHands();
13238
+ async function vl() {
13239
+ return kl().getAudienceModeHands();
13184
13240
  }
13185
- async function vl(e, t = !1) {
13186
- let n = El(), r;
13241
+ async function yl(e, t = !1) {
13242
+ let n = kl(), r;
13187
13243
  if (e) {
13188
- let t = n.getCachedRawOkIdByExternalId(e);
13244
+ let t = n.getCachedParticipantIdByExternalId(e);
13189
13245
  if (!t) {
13190
- R.warn("promoteParticipant: externalId not found in cache", e);
13246
+ Dl(e, "promoteParticipant", n);
13191
13247
  return;
13192
13248
  }
13193
- r = j.composeUserId(t);
13249
+ r = j.decomposeParticipantId(t).compositeUserId;
13194
13250
  }
13195
13251
  return n.promoteParticipant(r, t);
13196
13252
  }
13197
- async function yl(e = !1) {
13198
- return El().requestPromotion(e);
13199
- }
13200
13253
  async function bl(e = !1) {
13201
- return El().acceptPromotion(e);
13254
+ return kl().requestPromotion(e);
13202
13255
  }
13203
- async function xl(e) {
13204
- return El().getParticipantListChunk(e);
13256
+ async function xl(e = !1) {
13257
+ return kl().acceptPromotion(e);
13205
13258
  }
13206
13259
  async function Sl(e) {
13207
- return El().getParticipants(e);
13260
+ return kl().getParticipantListChunk(e);
13208
13261
  }
13209
13262
  async function Cl(e) {
13210
- return El().feedback(e);
13263
+ return kl().getParticipants(e);
13211
13264
  }
13212
- async function wl(e, t, n) {
13213
- return El(n).enableFeatureForRoles(e, t);
13265
+ async function wl(e) {
13266
+ return kl().feedback(e);
13214
13267
  }
13215
- function Tl(e) {
13216
- return e ? z.get(e) ?? null : $.current() ?? z.getFirst();
13268
+ async function Tl(e, t, n) {
13269
+ return kl(n).enableFeatureForRoles(e, t);
13217
13270
  }
13218
13271
  function El(e) {
13219
- let t = Tl(e);
13272
+ return e ? z.get(e) ?? null : $.current() ?? z.getFirst();
13273
+ }
13274
+ function Dl(e, t, n) {
13275
+ L.onNonFatalError(/* @__PURE__ */ Error(`Participant ID mapping not found for external ID "${e.id}" while handling ${t}`), n.id);
13276
+ }
13277
+ function Ol(e, t, n) {
13278
+ let r = Array.from(new Set(e));
13279
+ L.onNonFatalError(/* @__PURE__ */ Error(`Participant ID mapping not found for external IDs "${r.join("\", \"")}" while handling ${t}`), n.id);
13280
+ }
13281
+ function kl(e) {
13282
+ let t = El(e);
13220
13283
  if (!t) throw Error("Conversation not found");
13221
13284
  return t;
13222
13285
  }
13223
- async function Dl(e) {
13286
+ function Al(e, t) {
13287
+ let n = $.current();
13288
+ if (!n) return null;
13289
+ let r = n.getCachedParticipantIdByExternalId(e);
13290
+ return r ? {
13291
+ conversation: n,
13292
+ participantId: r
13293
+ } : (Dl(e, t, n), null);
13294
+ }
13295
+ async function jl(e) {
13224
13296
  await Vs.removeHistoryRecords(e);
13225
13297
  }
13226
- async function Ol(e) {
13298
+ async function Ml(e) {
13227
13299
  let t = $.current() ?? z.getFirst();
13228
13300
  t && await t.startAsr(e);
13229
13301
  }
13230
- async function kl(e) {
13302
+ async function Nl(e) {
13231
13303
  let t = $.current() ?? z.getFirst();
13232
13304
  t && await t.stopAsr(e);
13233
13305
  }
13234
- async function Al(e) {
13306
+ async function Pl(e) {
13235
13307
  let t = $.current() ?? z.getFirst();
13236
13308
  t && await t.requestAsr(e);
13237
13309
  }
13238
- async function jl(e) {
13310
+ async function Fl(e) {
13239
13311
  let t = $.current();
13240
13312
  return t ? t.startUrlSharing(e) : Promise.reject();
13241
13313
  }
13242
- async function Ml() {
13314
+ async function Il() {
13243
13315
  let e = $.current();
13244
13316
  return e ? e.stopUrlSharing() : Promise.reject();
13245
13317
  }
13246
- async function Nl(e) {
13318
+ async function Ll(e) {
13247
13319
  await z.switchCall(e);
13248
13320
  }
13249
- function Pl() {
13321
+ function Rl() {
13250
13322
  return z.getActiveId();
13251
13323
  }
13252
- function Fl() {
13324
+ function zl() {
13253
13325
  return $.getSyncedTime();
13254
13326
  }
13255
- function Il() {
13327
+ function Bl() {
13256
13328
  return M.sdkVersion;
13257
13329
  }
13258
13330
  typeof window < "u" && (window.__CALLS_SDK = yn);
13259
13331
  //#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 };
13332
+ 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 };