sip-connector 23.0.0 → 23.1.1

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.
@@ -1,20 +1,20 @@
1
1
  import Z from "debug";
2
2
  import { TypedEvents as R } from "events-constructor";
3
- import { CancelableRequest as Y, isCanceledError as Qe } from "@krivega/cancelable-promise";
4
- import { resolveRequesterByTimeout as Ye, requesterByTimeoutsWithFailCalls as Xe, DelayRequester as Je, hasCanceledError as ze, SetTimeoutRequest as ue } from "@krivega/timeout-requester";
5
- import { hasCanceledError as je, repeatedCallsAsync as Te } from "repeated-calls";
6
- import { createActor as Ke, setup as G, assign as M } from "xstate";
7
- import { createStackPromises as Ee, isPromiseIsNotActualError as Ze } from "stack-promises";
3
+ import { CancelableRequest as Y, isCanceledError as xe } from "@krivega/cancelable-promise";
4
+ import { resolveRequesterByTimeout as Qe, requesterByTimeoutsWithFailCalls as Ye, DelayRequester as Xe, hasCanceledError as Je, SetTimeoutRequest as ge } from "@krivega/timeout-requester";
5
+ import { hasCanceledError as ze, repeatedCallsAsync as ue } from "repeated-calls";
6
+ import { createActor as je, setup as G, assign as M } from "xstate";
7
+ import { createStackPromises as Te, isPromiseIsNotActualError as Ke } from "stack-promises";
8
8
  import "ua-parser-js";
9
9
  import "sequent-promises";
10
- import et from "lodash";
11
- const ee = "sip-connector", d = Z(ee), oi = () => {
10
+ import Ze from "lodash";
11
+ const ee = "sip-connector", d = Z(ee), di = () => {
12
12
  Z.enable(ee);
13
- }, ci = () => {
13
+ }, hi = () => {
14
14
  Z.enable(`-${ee}`);
15
- }, tt = "Error decline with 603", nt = 1006, st = (n) => typeof n == "object" && n !== null && "code" in n && n.code === nt, it = (n) => n.message === tt;
16
- var W = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(W || {}), y = /* @__PURE__ */ ((n) => (n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.ENTER_ROOM = "application/vinteo.webrtc.roomname", n.MIC = "application/vinteo.webrtc.mic", n.USE_LICENSE = "application/vinteo.webrtc.uselic", n.PARTICIPANT_STATE = "application/vinteo.webrtc.partstate", n.NOTIFY = "application/vinteo.webrtc.notify", n))(y || {}), _ = /* @__PURE__ */ ((n) => (n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.CHANNELS = "application/vinteo.webrtc.channels", n.MEDIA_STATE = "application/vinteo.webrtc.mediastate", n.REFUSAL = "application/vinteo.webrtc.refusal", n.STATS = "application/vinteo.webrtc.stats", n))(_ || {}), f = /* @__PURE__ */ ((n) => (n.PAUSE_MAIN_CAM = "PAUSEMAINCAM", n.RESUME_MAIN_CAM = "RESUMEMAINCAM", n.MAX_MAIN_CAM_RESOLUTION = "MAXMAINCAMRESOLUTION", n.ADMIN_STOP_MAIN_CAM = "ADMINSTOPMAINCAM", n.ADMIN_START_MAIN_CAM = "ADMINSTARTMAINCAM", n))(f || {}), x = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(x || {}), Se = /* @__PURE__ */ ((n) => (n.H264 = "H264", n.VP8 = "VP8", n.VP9 = "VP9", n.AV1 = "AV1", n))(Se || {}), h = /* @__PURE__ */ ((n) => (n.CONTENT_TYPE = "content-type", n.CONTENT_ENTER_ROOM = "x-webrtc-enter-room", n.CONTENT_USE_LICENSE = "X-WEBRTC-USE-LICENSE", n.PARTICIPANT_NAME = "X-WEBRTC-PARTICIPANT-NAME", n.INPUT_CHANNELS = "X-WEBRTC-INPUT-CHANNELS", n.OUTPUT_CHANNELS = "X-WEBRTC-OUTPUT-CHANNELS", n.MAIN_CAM = "X-WEBRTC-MAINCAM", n.MIC = "X-WEBRTC-MIC", n.MEDIA_SYNC = "X-WEBRTC-SYNC", n.MAIN_CAM_RESOLUTION = "X-WEBRTC-MAINCAM-RESOLUTION", n.MEDIA_STATE = "X-WEBRTC-MEDIA-STATE", n.MEDIA_TYPE = "X-Vinteo-Media-Type", n.MAIN_CAM_STATE = "X-Vinteo-MainCam-State", n.MIC_STATE = "X-Vinteo-Mic-State", n.CONTENT_PARTICIPANT_STATE = "X-WEBRTC-PARTSTATE", n.NOTIFY = "X-VINTEO-NOTIFY", n.CONTENT_ENABLE_MEDIA_DEVICE = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", n.CONTENTED_STREAM_STATE = "x-webrtc-share-state", n.CONTENTED_STREAM_CODEC = "x-webrtc-share-codec", n.AVAILABLE_INCOMING_BITRATE = "X-WEBRTC-AVAILABLE-INCOMING-BITRATE", n.AUDIO_TRACK_COUNT = "X-WEBRTC-AUDIO-TRACK-COUNT", n.VIDEO_TRACK_COUNT = "X-WEBRTC-VIDEO-TRACK-COUNT", n.TRACKS_DIRECTION = "X-WEBRTC-TRACKS-DIRECTION", n.AUDIO_ID = "X-WEBRTC-AUDIOID", n))(h || {}), $ = /* @__PURE__ */ ((n) => (n.AVAILABLE_CONTENTED_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_CONTENTED_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))($ || {}), U = /* @__PURE__ */ ((n) => (n.AVAILABLE_CONTENTED_STREAM = "x-webrtc-share-state: YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_CONTENTED_STREAM = "x-webrtc-share-state: CONTENTEND", n.ACK_PERMISSION_TO_START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", n.STOPPED_CLIENT_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", n.ENABLE_MAIN_CAM = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE: LETMESTARTMAINCAM", n))(U || {}), Q = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(Q || {}), Ce = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(Ce || {}), g = /* @__PURE__ */ ((n) => (n.ENTER_ROOM = "enter-room", n.MAIN_CAM_CONTROL = "main-cam-control", n.USE_LICENSE = "use-license", n.NEW_DTMF = "new-dtmf", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "conference:participant-token-issued", n.CONTENTED_STREAM_AVAILABLE = "contented-stream:available", n.CONTENTED_STREAM_NOT_AVAILABLE = "contented-stream:not-available", n.PRESENTATION_MUST_STOP = "presentation:must-stop", n.CHANNELS_ALL = "channels:all", n.CHANNELS_NOTIFY = "channels:notify", n.PARTICIPANT_ADDED_TO_LIST_MODERATORS = "participant:added-to-list-moderators", n.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS = "participant:removed-from-list-moderators", n.PARTICIPANT_MOVE_REQUEST_TO_STREAM = "participant:move-request-to-stream", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS = "participant:move-request-to-spectators", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_SYNTHETIC = "participant:move-request-to-spectators-synthetic", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_WITH_AUDIO_ID = "participant:move-request-to-spectators-with-audio-id", n.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS = "participant:move-request-to-participants", n.PARTICIPATION_ACCEPTING_WORD_REQUEST = "participation:accepting-word-request", n.PARTICIPATION_CANCELLING_WORD_REQUEST = "participation:cancelling-word-request", n.WEBCAST_STARTED = "webcast:started", n.WEBCAST_STOPPED = "webcast:stopped", n.ACCOUNT_CHANGED = "account:changed", n.ACCOUNT_DELETED = "account:deleted", n.ADMIN_START_MAIN_CAM = "admin:start-main-cam", n.ADMIN_STOP_MAIN_CAM = "admin:stop-main-cam", n.ADMIN_START_MIC = "admin:start-mic", n.ADMIN_STOP_MIC = "admin:stop-mic", n.ADMIN_FORCE_SYNC_MEDIA_STATE = "admin:force-sync-media-state", n))(g || {});
17
- const pe = [
15
+ }, et = "Error decline with 603", tt = 1006, nt = (n) => typeof n == "object" && n !== null && "code" in n && n.code === tt, st = (n) => n.message === et;
16
+ var W = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(W || {}), y = /* @__PURE__ */ ((n) => (n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.ENTER_ROOM = "application/vinteo.webrtc.roomname", n.MIC = "application/vinteo.webrtc.mic", n.USE_LICENSE = "application/vinteo.webrtc.uselic", n.PARTICIPANT_STATE = "application/vinteo.webrtc.partstate", n.NOTIFY = "application/vinteo.webrtc.notify", n))(y || {}), _ = /* @__PURE__ */ ((n) => (n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.CHANNELS = "application/vinteo.webrtc.channels", n.MEDIA_STATE = "application/vinteo.webrtc.mediastate", n.REFUSAL = "application/vinteo.webrtc.refusal", n.STATS = "application/vinteo.webrtc.stats", n))(_ || {}), f = /* @__PURE__ */ ((n) => (n.PAUSE_MAIN_CAM = "PAUSEMAINCAM", n.RESUME_MAIN_CAM = "RESUMEMAINCAM", n.MAX_MAIN_CAM_RESOLUTION = "MAXMAINCAMRESOLUTION", n.ADMIN_STOP_MAIN_CAM = "ADMINSTOPMAINCAM", n.ADMIN_START_MAIN_CAM = "ADMINSTARTMAINCAM", n))(f || {}), x = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(x || {}), Ee = /* @__PURE__ */ ((n) => (n.H264 = "H264", n.VP8 = "VP8", n.VP9 = "VP9", n.AV1 = "AV1", n))(Ee || {}), h = /* @__PURE__ */ ((n) => (n.CONTENT_TYPE = "content-type", n.CONTENT_ENTER_ROOM = "x-webrtc-enter-room", n.CONTENT_USE_LICENSE = "X-WEBRTC-USE-LICENSE", n.PARTICIPANT_NAME = "X-WEBRTC-PARTICIPANT-NAME", n.INPUT_CHANNELS = "X-WEBRTC-INPUT-CHANNELS", n.OUTPUT_CHANNELS = "X-WEBRTC-OUTPUT-CHANNELS", n.MAIN_CAM = "X-WEBRTC-MAINCAM", n.MIC = "X-WEBRTC-MIC", n.MEDIA_SYNC = "X-WEBRTC-SYNC", n.MAIN_CAM_RESOLUTION = "X-WEBRTC-MAINCAM-RESOLUTION", n.MEDIA_STATE = "X-WEBRTC-MEDIA-STATE", n.MEDIA_TYPE = "X-Vinteo-Media-Type", n.MAIN_CAM_STATE = "X-Vinteo-MainCam-State", n.MIC_STATE = "X-Vinteo-Mic-State", n.CONTENT_PARTICIPANT_STATE = "X-WEBRTC-PARTSTATE", n.NOTIFY = "X-VINTEO-NOTIFY", n.CONTENT_ENABLE_MEDIA_DEVICE = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", n.CONTENTED_STREAM_STATE = "x-webrtc-share-state", n.CONTENTED_STREAM_CODEC = "x-webrtc-share-codec", n.AVAILABLE_INCOMING_BITRATE = "X-WEBRTC-AVAILABLE-INCOMING-BITRATE", n.AUDIO_TRACK_COUNT = "X-WEBRTC-AUDIO-TRACK-COUNT", n.VIDEO_TRACK_COUNT = "X-WEBRTC-VIDEO-TRACK-COUNT", n.TRACKS_DIRECTION = "X-WEBRTC-TRACKS-DIRECTION", n.AUDIO_ID = "X-WEBRTC-AUDIOID", n))(h || {}), $ = /* @__PURE__ */ ((n) => (n.AVAILABLE_CONTENTED_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_CONTENTED_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))($ || {}), U = /* @__PURE__ */ ((n) => (n.AVAILABLE_CONTENTED_STREAM = "x-webrtc-share-state: YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_CONTENTED_STREAM = "x-webrtc-share-state: CONTENTEND", n.ACK_PERMISSION_TO_START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", n.STOPPED_CLIENT_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", n.ENABLE_MAIN_CAM = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE: LETMESTARTMAINCAM", n))(U || {}), Q = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(Q || {}), Se = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(Se || {}), g = /* @__PURE__ */ ((n) => (n.ENTER_ROOM = "enter-room", n.MAIN_CAM_CONTROL = "main-cam-control", n.USE_LICENSE = "use-license", n.NEW_DTMF = "new-dtmf", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "conference:participant-token-issued", n.CONTENTED_STREAM_AVAILABLE = "contented-stream:available", n.CONTENTED_STREAM_NOT_AVAILABLE = "contented-stream:not-available", n.PRESENTATION_MUST_STOP = "presentation:must-stop", n.CHANNELS_ALL = "channels:all", n.CHANNELS_NOTIFY = "channels:notify", n.PARTICIPANT_ADDED_TO_LIST_MODERATORS = "participant:added-to-list-moderators", n.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS = "participant:removed-from-list-moderators", n.PARTICIPANT_MOVE_REQUEST_TO_STREAM = "participant:move-request-to-stream", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS = "participant:move-request-to-spectators", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_SYNTHETIC = "participant:move-request-to-spectators-synthetic", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_WITH_AUDIO_ID = "participant:move-request-to-spectators-with-audio-id", n.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS = "participant:move-request-to-participants", n.PARTICIPATION_ACCEPTING_WORD_REQUEST = "participation:accepting-word-request", n.PARTICIPATION_CANCELLING_WORD_REQUEST = "participation:cancelling-word-request", n.WEBCAST_STARTED = "webcast:started", n.WEBCAST_STOPPED = "webcast:stopped", n.ACCOUNT_CHANGED = "account:changed", n.ACCOUNT_DELETED = "account:deleted", n.ADMIN_START_MAIN_CAM = "admin:start-main-cam", n.ADMIN_STOP_MAIN_CAM = "admin:stop-main-cam", n.ADMIN_START_MIC = "admin:start-mic", n.ADMIN_STOP_MIC = "admin:stop-mic", n.ADMIN_FORCE_SYNC_MEDIA_STATE = "admin:force-sync-media-state", n))(g || {});
17
+ const Ce = [
18
18
  "enter-room",
19
19
  "main-cam-control",
20
20
  "use-license",
@@ -43,15 +43,15 @@ const pe = [
43
43
  "admin:start-mic",
44
44
  "admin:stop-mic",
45
45
  "admin:force-sync-media-state"
46
- ], rt = () => new R(pe), at = (n) => typeof n == "string" && n.trim().length > 0, L = (n, e) => {
46
+ ], it = () => new R(Ce), rt = (n) => typeof n == "string" && n.trim().length > 0, L = (n, e) => {
47
47
  const t = e.toLowerCase(), s = Object.entries(n).find(([, i]) => typeof i == "string" && i.toLowerCase() === t);
48
48
  return s ? s[1] : void 0;
49
- }, ot = (n) => typeof n == "string" && !Number.isNaN(Number(n)) && Number.isFinite(Number(n)), ct = (n) => {
50
- if (ot(n))
49
+ }, at = (n) => typeof n == "string" && !Number.isNaN(Number(n)) && Number.isFinite(Number(n)), ot = (n) => {
50
+ if (at(n))
51
51
  return Number(n);
52
52
  }, N = (n, e) => {
53
53
  const t = n.getHeader(e);
54
- if (!at(t))
54
+ if (!rt(t))
55
55
  return;
56
56
  const s = t.toLowerCase();
57
57
  switch (e) {
@@ -72,13 +72,13 @@ const pe = [
72
72
  case h.AVAILABLE_INCOMING_BITRATE:
73
73
  case h.AUDIO_TRACK_COUNT:
74
74
  case h.VIDEO_TRACK_COUNT:
75
- return ct(s);
75
+ return ot(s);
76
76
  case h.CONTENTED_STREAM_CODEC:
77
- return L(Se, s);
77
+ return L(Ee, s);
78
78
  case h.CONTENT_TYPE:
79
79
  return L(y, s);
80
80
  case h.CONTENT_USE_LICENSE:
81
- return L(Ce, s);
81
+ return L(Se, s);
82
82
  case h.MAIN_CAM:
83
83
  return L(f, s);
84
84
  case h.MIC:
@@ -94,11 +94,11 @@ const pe = [
94
94
  }
95
95
  };
96
96
  var I = /* @__PURE__ */ ((n) => (n.CHANNELS = "channels", n.WEBCAST_STARTED = "WebcastStarted", n.WEBCAST_STOPPED = "WebcastStopped", n.ACCOUNT_CHANGED = "accountChanged", n.ACCOUNT_DELETED = "accountDeleted", n.ADDED_TO_LIST_MODERATORS = "addedToListModerators", n.REMOVED_FROM_LIST_MODERATORS = "removedFromListModerators", n.ACCEPTING_WORD_REQUEST = "ParticipationRequestAccepted", n.CANCELLING_WORD_REQUEST = "ParticipationRequestRejected", n.MOVE_REQUEST_TO_STREAM = "ParticipantMovedToWebcast", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "ConferenceParticipantTokenIssued", n))(I || {});
97
- class dt {
97
+ class ct {
98
98
  events;
99
99
  callManager;
100
100
  constructor() {
101
- this.events = rt();
101
+ this.events = it();
102
102
  }
103
103
  subscribe({
104
104
  connectionManager: e,
@@ -199,7 +199,7 @@ class dt {
199
199
  ...e,
200
200
  extraHeaders: s
201
201
  }).catch((i) => {
202
- if (it(i))
202
+ if (st(i))
203
203
  throw i;
204
204
  });
205
205
  }
@@ -497,7 +497,7 @@ class V {
497
497
  subscriptions = [];
498
498
  stateChangeListeners = /* @__PURE__ */ new Set();
499
499
  constructor(e) {
500
- this.actor = Ke(e), this.actor.start(), this.addSubscription(
500
+ this.actor = je(e), this.actor.start(), this.addSubscription(
501
501
  this.subscribe((t) => {
502
502
  const s = t.value;
503
503
  this.stateChangeListeners.forEach((i) => {
@@ -539,8 +539,8 @@ class V {
539
539
  return this.subscriptions.push(t), t;
540
540
  }
541
541
  }
542
- var ht = /* @__PURE__ */ ((n) => (n.IDLE = "call:idle", n.CONNECTING = "call:connecting", n.ACCEPTED = "call:accepted", n.IN_CALL = "call:inCall", n.ENDED = "call:ended", n.FAILED = "call:failed", n))(ht || {});
543
- const lt = G({
542
+ var dt = /* @__PURE__ */ ((n) => (n.IDLE = "call:idle", n.CONNECTING = "call:connecting", n.ACCEPTED = "call:accepted", n.IN_CALL = "call:inCall", n.ENDED = "call:ended", n.FAILED = "call:failed", n))(dt || {});
543
+ const ht = G({
544
544
  types: {
545
545
  context: {},
546
546
  events: {}
@@ -623,9 +623,9 @@ const lt = G({
623
623
  }
624
624
  }
625
625
  });
626
- class gt extends V {
626
+ class lt extends V {
627
627
  constructor(e) {
628
- super(lt), this.subscribeToEvents(e);
628
+ super(ht), this.subscribeToEvents(e);
629
629
  }
630
630
  get isIdle() {
631
631
  return this.state === "call:idle";
@@ -690,8 +690,8 @@ class gt extends V {
690
690
  );
691
691
  }
692
692
  }
693
- var S = /* @__PURE__ */ ((n) => (n.PEER_CONNECTION = "peerconnection", n.CONNECTING = "connecting", n.SENDING = "sending", n.PROGRESS = "progress", n.ACCEPTED = "accepted", n.CONFIRMED = "confirmed", n.ENDED = "ended", n.FAILED = "failed", n.NEW_DTMF = "newDTMF", n.NEW_INFO = "newInfo", n.HOLD = "hold", n.UNHOLD = "unhold", n.MUTED = "muted", n.UNMUTED = "unmuted", n.REINVITE = "reinvite", n.UPDATE = "update", n.REFER = "refer", n.REPLACES = "replaces", n.SDP = "sdp", n.ICE_CANDIDATE = "icecandidate", n.GET_USER_MEDIA_FAILED = "getusermediafailed", n.PEER_CONNECTION_CREATE_OFFER_FAILED = "peerconnection:createofferfailed", n.PEER_CONNECTION_CREATE_ANSWER_FAILED = "peerconnection:createanswerfailed", n.PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED = "peerconnection:setlocaldescriptionfailed", n.PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED = "peerconnection:setremotedescriptionfailed", n.START_PRESENTATION = "presentation:start", n.STARTED_PRESENTATION = "presentation:started", n.END_PRESENTATION = "presentation:end", n.ENDED_PRESENTATION = "presentation:ended", n.FAILED_PRESENTATION = "presentation:failed", n.PEER_CONNECTION_CONFIRMED = "peerconnection:confirmed", n.PEER_CONNECTION_ONTRACK = "peerconnection:ontrack", n.ENDED_FROM_SERVER = "ended:fromserver", n.CALL_STATUS_CHANGED = "call-status-changed", n.REMOTE_TRACKS_CHANGED = "remote-tracks-changed", n.REMOTE_STREAMS_CHANGED = "remote-streams-changed", n))(S || {}), ut = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))(ut || {});
694
- const me = [
693
+ var S = /* @__PURE__ */ ((n) => (n.PEER_CONNECTION = "peerconnection", n.CONNECTING = "connecting", n.SENDING = "sending", n.PROGRESS = "progress", n.ACCEPTED = "accepted", n.CONFIRMED = "confirmed", n.ENDED = "ended", n.FAILED = "failed", n.NEW_DTMF = "newDTMF", n.NEW_INFO = "newInfo", n.HOLD = "hold", n.UNHOLD = "unhold", n.MUTED = "muted", n.UNMUTED = "unmuted", n.REINVITE = "reinvite", n.UPDATE = "update", n.REFER = "refer", n.REPLACES = "replaces", n.SDP = "sdp", n.ICE_CANDIDATE = "icecandidate", n.GET_USER_MEDIA_FAILED = "getusermediafailed", n.PEER_CONNECTION_CREATE_OFFER_FAILED = "peerconnection:createofferfailed", n.PEER_CONNECTION_CREATE_ANSWER_FAILED = "peerconnection:createanswerfailed", n.PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED = "peerconnection:setlocaldescriptionfailed", n.PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED = "peerconnection:setremotedescriptionfailed", n.START_PRESENTATION = "presentation:start", n.STARTED_PRESENTATION = "presentation:started", n.END_PRESENTATION = "presentation:end", n.ENDED_PRESENTATION = "presentation:ended", n.FAILED_PRESENTATION = "presentation:failed", n.PEER_CONNECTION_CONFIRMED = "peerconnection:confirmed", n.PEER_CONNECTION_ONTRACK = "peerconnection:ontrack", n.ENDED_FROM_SERVER = "ended:fromserver", n.CALL_STATUS_CHANGED = "call-status-changed", n.REMOTE_TRACKS_CHANGED = "remote-tracks-changed", n.REMOTE_STREAMS_CHANGED = "remote-streams-changed", n))(S || {}), gt = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))(gt || {});
694
+ const pe = [
695
695
  "peerconnection",
696
696
  "connecting",
697
697
  "sending",
@@ -722,17 +722,17 @@ const me = [
722
722
  "peerconnection:createanswerfailed",
723
723
  "peerconnection:setlocaldescriptionfailed",
724
724
  "peerconnection:setremotedescriptionfailed"
725
- ], Tt = [
725
+ ], ut = [
726
726
  "peerconnection:confirmed",
727
727
  "peerconnection:ontrack",
728
728
  "ended:fromserver",
729
729
  "call-status-changed",
730
730
  "remote-tracks-changed",
731
731
  "remote-streams-changed"
732
- ], Ne = [
733
- ...me,
734
- ...Tt
735
- ], Et = () => new R(Ne), St = (n, e) => {
732
+ ], me = [
733
+ ...pe,
734
+ ...ut
735
+ ], Tt = () => new R(me), Et = (n, e) => {
736
736
  n.getVideoTracks().forEach((s) => {
737
737
  "contentHint" in s && s.contentHint !== e && (s.contentHint = e);
738
738
  });
@@ -744,10 +744,10 @@ const me = [
744
744
  if (!n || e === "recvonly" && t === "recvonly")
745
745
  return;
746
746
  const i = t === "recvonly" ? [] : n.getAudioTracks(), r = e === "recvonly" ? [] : n.getVideoTracks(), a = [...i, ...r], o = new MediaStream(a);
747
- return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && St(o, s), o;
747
+ return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && Et(o, s), o;
748
748
  };
749
- var Ae = /* @__PURE__ */ ((n) => (n.BYE = "Terminated", n.WEBRTC_ERROR = "WebRTC Error", n.CANCELED = "Canceled", n.REQUEST_TIMEOUT = "Request Timeout", n.REJECTED = "Rejected", n.REDIRECTED = "Redirected", n.UNAVAILABLE = "Unavailable", n.NOT_FOUND = "Not Found", n.ADDRESS_INCOMPLETE = "Address Incomplete", n.INCOMPATIBLE_SDP = "Incompatible SDP", n.BAD_MEDIA_DESCRIPTION = "Bad Media Description", n))(Ae || {});
750
- class Ct {
749
+ var Ne = /* @__PURE__ */ ((n) => (n.BYE = "Terminated", n.WEBRTC_ERROR = "WebRTC Error", n.CANCELED = "Canceled", n.REQUEST_TIMEOUT = "Request Timeout", n.REJECTED = "Rejected", n.REDIRECTED = "Redirected", n.UNAVAILABLE = "Unavailable", n.NOT_FOUND = "Not Found", n.ADDRESS_INCOMPLETE = "Address Incomplete", n.INCOMPATIBLE_SDP = "Incompatible SDP", n.BAD_MEDIA_DESCRIPTION = "Bad Media Description", n))(Ne || {});
750
+ class St {
751
751
  events;
752
752
  rtcSession;
753
753
  disposers = /* @__PURE__ */ new Set();
@@ -812,7 +812,7 @@ class Ct {
812
812
  const { rtcSession: e } = this;
813
813
  if (e && !e.isEnded())
814
814
  return e.terminateAsync({
815
- cause: Ae.CANCELED
815
+ cause: Ne.CANCELED
816
816
  }).finally(() => {
817
817
  this.reset();
818
818
  });
@@ -899,7 +899,7 @@ class Ct {
899
899
  });
900
900
  subscribeToSessionEvents(e) {
901
901
  this.events.eachTriggers((t, s) => {
902
- const i = me.find((r) => r === s);
902
+ const i = pe.find((r) => r === s);
903
903
  i && (e.on(i, t), this.disposers.add(() => {
904
904
  e.off(i, t);
905
905
  }));
@@ -918,7 +918,7 @@ class Ct {
918
918
  delete this.rtcSession, this.unsubscribeFromSessionEvents(), this.onReset();
919
919
  };
920
920
  }
921
- class pt {
921
+ class Ct {
922
922
  config;
923
923
  tools;
924
924
  connection;
@@ -935,11 +935,15 @@ class pt {
935
935
  this.connection.close();
936
936
  }
937
937
  async call(e) {
938
- const t = this.waitForTracks(), s = await this.createOffer(), i = await this.tools.sendOffer(
938
+ const t = this.waitForTracks();
939
+ await this.renegotiate(e), await t;
940
+ }
941
+ async renegotiate(e) {
942
+ const t = await this.createOffer(), s = await this.tools.sendOffer(
939
943
  { conferenceNumber: e, quality: this.config.quality, audioChannel: this.config.audioChannel },
940
- s
944
+ t
941
945
  );
942
- await this.setRemoteDescription(i), await t;
946
+ return await this.setRemoteDescription(s), !0;
943
947
  }
944
948
  async createOffer() {
945
949
  const e = await this.connection.createOffer();
@@ -967,14 +971,14 @@ class pt {
967
971
  return this.connection.addTransceiver(e, t);
968
972
  }
969
973
  }
970
- const Re = (n) => n.getSettings(), mt = (n, e) => {
971
- const t = Re(n);
974
+ const Ae = (n) => n.getSettings(), pt = (n, e) => {
975
+ const t = Ae(n);
972
976
  let s = e;
973
977
  s ??= n.label;
974
978
  let i = t?.msid;
975
979
  return i ??= s, i ??= n.id, i;
976
- }, Nt = (n, e) => {
977
- const t = Re(n);
980
+ }, mt = (n, e) => {
981
+ const t = Ae(n);
978
982
  let s = e;
979
983
  return s ??= t?.msid, s ??= n.label, (s && s.length > 0 ? s : void 0) ?? n.id;
980
984
  };
@@ -995,7 +999,7 @@ class se {
995
999
  onRemoved: t,
996
1000
  streamHint: s
997
1001
  } = {}) {
998
- const i = Nt(e, s), r = mt(e, s);
1002
+ const i = mt(e, s), r = pt(e, s);
999
1003
  if (this.trackToGroup.has(e.id))
1000
1004
  return { isAddedTrack: !1, isAddedStream: !1 };
1001
1005
  const a = this.getParticipantGroups(i), o = a.get(r), c = !o;
@@ -1065,9 +1069,9 @@ class se {
1065
1069
  }
1066
1070
  const J = {
1067
1071
  type: "participant"
1068
- }, At = {
1072
+ }, Nt = {
1069
1073
  type: "spectator_synthetic"
1070
- }, Rt = (n) => ({
1074
+ }, At = (n) => ({
1071
1075
  type: "spectator",
1072
1076
  recvParams: n
1073
1077
  });
@@ -1093,10 +1097,10 @@ class O {
1093
1097
  this.changeRole(J);
1094
1098
  }
1095
1099
  setCallRoleSpectatorSynthetic() {
1096
- this.changeRole(At);
1100
+ this.changeRole(Nt);
1097
1101
  }
1098
1102
  setCallRoleSpectator(e) {
1099
- this.changeRole(Rt(e));
1103
+ this.changeRole(At(e));
1100
1104
  }
1101
1105
  changeRole(e) {
1102
1106
  const t = this.role;
@@ -1123,13 +1127,13 @@ class O {
1123
1127
  this.role = e, this.onRoleChanged?.({ previous: t, next: e });
1124
1128
  }
1125
1129
  }
1126
- const It = (n, e) => {
1130
+ const Rt = (n, e) => {
1127
1131
  if (!n || !e)
1128
1132
  return n === e;
1129
1133
  const t = n.mainStream?.id, s = e.mainStream?.id, i = n.contentedStream?.id, r = e.contentedStream?.id;
1130
1134
  return t === s && i === r;
1131
1135
  };
1132
- class vt {
1136
+ class It {
1133
1137
  lastEmittedStreams;
1134
1138
  /**
1135
1139
  * Проверяет, изменились ли streams с последнего сохраненного состояния
@@ -1137,7 +1141,7 @@ class vt {
1137
1141
  * @returns true, если streams изменились
1138
1142
  */
1139
1143
  hasChanged(e) {
1140
- return !It(this.lastEmittedStreams, e);
1144
+ return !Rt(this.lastEmittedStreams, e);
1141
1145
  }
1142
1146
  /**
1143
1147
  * Сохраняет текущие streams как последнее эмитнутое состояние
@@ -1160,8 +1164,8 @@ class vt {
1160
1164
  this.lastEmittedStreams = void 0;
1161
1165
  }
1162
1166
  }
1163
- const ft = "default", Mt = "dual", ie = (n) => [...n.getTracks()].some((e) => e.label.includes(Mt));
1164
- class _t {
1167
+ const vt = "default", ft = "dual", Mt = "content_", _t = (n) => `${Mt}${n.toLowerCase()}`, bt = (n) => [...n.getTracks()].some((e) => e.label.includes(ft));
1168
+ class Ot {
1165
1169
  mainRemoteStreamsManager;
1166
1170
  recvRemoteStreamsManager;
1167
1171
  constructor(e, t) {
@@ -1178,7 +1182,7 @@ class _t {
1178
1182
  }) {
1179
1183
  const t = this.mainRemoteStreamsManager;
1180
1184
  return { manager: t, getRemoteStreams: () => {
1181
- const i = t.getStreams(), r = i.find((o) => !ie(o)), a = e.isAvailable ? i.find((o) => ie(o)) : void 0;
1185
+ const i = t.getStreams(), r = i.find((o) => !bt(o)), a = e.isAvailable ? i.find((o) => o !== r) : void 0;
1182
1186
  return { mainStream: r, contentedStream: a };
1183
1187
  } };
1184
1188
  }
@@ -1187,13 +1191,21 @@ class _t {
1187
1191
  }) {
1188
1192
  const t = this.recvRemoteStreamsManager;
1189
1193
  return { manager: t, getRemoteStreams: () => {
1190
- const i = t.getStreams(ft);
1191
- return { mainStream: i[0], contentedStream: e.isAvailable ? i[1] : void 0 };
1194
+ const r = t.getStreams(vt)[0], a = this.getRecvRemoteContentedStream({ stateInfo: e });
1195
+ return { mainStream: r, contentedStream: a };
1192
1196
  } };
1193
1197
  }
1198
+ getRecvRemoteContentedStream({
1199
+ stateInfo: e
1200
+ }) {
1201
+ if (!e.isAvailable || e.codec === void 0)
1202
+ return;
1203
+ const t = _t(e.codec);
1204
+ return this.recvRemoteStreamsManager.getStreams(t)[0];
1205
+ }
1194
1206
  }
1195
- const re = (n) => n.streams[0]?.id;
1196
- class bt {
1207
+ const ie = (n) => n.streams[0]?.id;
1208
+ class Dt {
1197
1209
  events;
1198
1210
  callStateMachine;
1199
1211
  isPendingCall = !1;
@@ -1210,9 +1222,9 @@ class bt {
1210
1222
  mcuSession;
1211
1223
  recvSession;
1212
1224
  disposeRecvSessionTrackListener;
1213
- streamsChangeTracker = new vt();
1225
+ streamsChangeTracker = new It();
1214
1226
  constructor(e, t) {
1215
- this.conferenceStateManager = e, this.contentedStreamManager = t, this.events = Et(), this.mcuSession = new Ct(this.events, { onReset: this.reset }), this.callStateMachine = new gt(this.events), this.streamsManagerProvider = new _t(
1227
+ this.conferenceStateManager = e, this.contentedStreamManager = t, this.events = Tt(), this.mcuSession = new St(this.events, { onReset: this.reset }), this.callStateMachine = new lt(this.events), this.streamsManagerProvider = new Ot(
1216
1228
  this.mainRemoteStreamsManager,
1217
1229
  this.recvRemoteStreamsManager
1218
1230
  ), this.subscribeCallStatusChange(), this.subscribeMcuRemoteTrackEvents(), this.subscribeContentedStreamEvents();
@@ -1262,7 +1274,7 @@ class bt {
1262
1274
  return this.mcuSession.endCall();
1263
1275
  }
1264
1276
  async renegotiate() {
1265
- return this.mcuSession.renegotiate();
1277
+ return this.roleManager.hasSpectator() ? this.renegotiateRecvSession() : this.renegotiateMcuSession();
1266
1278
  }
1267
1279
  answerToIncomingCall = async (e, t) => {
1268
1280
  this.isPendingAnswer = !0;
@@ -1314,7 +1326,7 @@ class bt {
1314
1326
  }
1315
1327
  subscribeMcuRemoteTrackEvents() {
1316
1328
  this.on(S.PEER_CONNECTION_ONTRACK, (e) => {
1317
- this.addRemoteTrack(this.mainRemoteStreamsManager, e.track, re(e));
1329
+ this.addRemoteTrack(this.mainRemoteStreamsManager, e.track, ie(e));
1318
1330
  });
1319
1331
  }
1320
1332
  addRemoteTrack(e, t, s) {
@@ -1367,7 +1379,7 @@ class bt {
1367
1379
  }
1368
1380
  attachRecvSessionTracks(e) {
1369
1381
  const { peerConnection: t } = e, s = (i) => {
1370
- this.addRemoteTrack(this.recvRemoteStreamsManager, i.track, re(i));
1382
+ this.addRemoteTrack(this.recvRemoteStreamsManager, i.track, ie(i));
1371
1383
  };
1372
1384
  t.addEventListener("track", s), this.disposeRecvSessionTrackListener = () => {
1373
1385
  t.removeEventListener("track", s);
@@ -1381,7 +1393,7 @@ class bt {
1381
1393
  const i = {
1382
1394
  quality: "high",
1383
1395
  audioChannel: e
1384
- }, r = new pt(i, { sendOffer: t });
1396
+ }, r = new Ct(i, { sendOffer: t });
1385
1397
  this.recvSession = r, this.recvRemoteStreamsManager.reset(), this.attachRecvSessionTracks(r), r.call(s).catch(() => {
1386
1398
  this.stopRecvSession();
1387
1399
  });
@@ -1405,40 +1417,47 @@ class bt {
1405
1417
  this.emitEventChangedRemoteStreams(this.getRemoteStreams());
1406
1418
  });
1407
1419
  }
1420
+ async renegotiateRecvSession() {
1421
+ const e = this.conferenceStateManager.getNumber();
1422
+ return e === void 0 || this.recvSession === void 0 ? !1 : this.recvSession.renegotiate(e);
1423
+ }
1424
+ async renegotiateMcuSession() {
1425
+ return this.mcuSession.renegotiate();
1426
+ }
1408
1427
  }
1409
- const Ot = (n, e) => (n.degradationPreference = e.degradationPreference, n), Dt = (n, e) => {
1428
+ const Pt = (n, e) => (n.degradationPreference = e.degradationPreference, n), yt = (n, e) => {
1410
1429
  n.encodings ??= [];
1411
1430
  for (let t = n.encodings.length; t < e; t += 1)
1412
1431
  n.encodings.push({});
1413
1432
  return n;
1414
- }, Ie = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, Pt = Ie(), yt = (n, e) => {
1415
- if (Pt(n, e))
1433
+ }, Re = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, Lt = Re(), wt = (n, e) => {
1434
+ if (Lt(n, e))
1416
1435
  return n;
1417
- }, Lt = (n, e) => {
1418
- const t = n.maxBitrate, s = yt(e, t);
1436
+ }, Ut = (n, e) => {
1437
+ const t = n.maxBitrate, s = wt(e, t);
1419
1438
  return s !== void 0 && (n.maxBitrate = s), n;
1420
- }, ve = 1, wt = Ie(
1421
- ve
1422
- ), Ut = (n, e) => {
1423
- const t = n === void 0 ? void 0 : Math.max(n, ve);
1424
- if (t !== void 0 && wt(
1439
+ }, Ie = 1, Ft = Re(
1440
+ Ie
1441
+ ), Bt = (n, e) => {
1442
+ const t = n === void 0 ? void 0 : Math.max(n, Ie);
1443
+ if (t !== void 0 && Ft(
1425
1444
  t,
1426
1445
  e
1427
1446
  ))
1428
1447
  return t;
1429
- }, Ft = (n, e) => {
1430
- const t = n.scaleResolutionDownBy, s = Ut(
1448
+ }, kt = (n, e) => {
1449
+ const t = n.scaleResolutionDownBy, s = Bt(
1431
1450
  e,
1432
1451
  t
1433
1452
  );
1434
1453
  return s !== void 0 && (n.scaleResolutionDownBy = s), n;
1435
- }, Bt = (n, e) => {
1454
+ }, $t = (n, e) => {
1436
1455
  const t = e.encodings?.length ?? 0;
1437
- return Dt(n, t), n.encodings.forEach((s, i) => {
1456
+ return yt(n, t), n.encodings.forEach((s, i) => {
1438
1457
  const r = (e?.encodings ?? [])[i], a = r?.maxBitrate, o = r?.scaleResolutionDownBy;
1439
- Lt(s, a), Ft(s, o);
1458
+ Ut(s, a), kt(s, o);
1440
1459
  }), n;
1441
- }, kt = (n, e) => {
1460
+ }, Gt = (n, e) => {
1442
1461
  if (n.codecs?.length !== e.codecs?.length)
1443
1462
  return !0;
1444
1463
  for (let t = 0; t < (n.codecs?.length ?? 0); t++)
@@ -1455,15 +1474,15 @@ const Ot = (n, e) => (n.degradationPreference = e.degradationPreference, n), Dt
1455
1474
  if (JSON.stringify(n.encodings[t]) !== JSON.stringify(e.encodings[t]))
1456
1475
  return !0;
1457
1476
  return n.rtcp?.cname !== e.rtcp?.cname || n.rtcp?.reducedSize !== e.rtcp?.reducedSize || n.degradationPreference !== e.degradationPreference;
1458
- }, $t = async (n, e) => {
1477
+ }, Vt = async (n, e) => {
1459
1478
  const t = n.getParameters(), s = JSON.parse(
1460
1479
  JSON.stringify(t)
1461
1480
  );
1462
- Bt(t, e), Ot(t, e);
1463
- const i = kt(s, t);
1481
+ $t(t, e), Pt(t, e);
1482
+ const i = Gt(s, t);
1464
1483
  return i && await n.setParameters(t), { parameters: t, isChanged: i };
1465
- }, fe = async (n, e, t) => {
1466
- const { isChanged: s, parameters: i } = await $t(n, {
1484
+ }, ve = async (n, e, t) => {
1485
+ const { isChanged: s, parameters: i } = await Vt(n, {
1467
1486
  encodings: [
1468
1487
  {
1469
1488
  scaleResolutionDownBy: e.scaleResolutionDownBy,
@@ -1472,21 +1491,21 @@ const Ot = (n, e) => (n.degradationPreference = e.degradationPreference, n), Dt
1472
1491
  ]
1473
1492
  });
1474
1493
  return s && t && t(i), { isChanged: s, parameters: i };
1475
- }, Gt = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), Vt = async (n, e, t) => {
1476
- const s = Gt(n, e);
1494
+ }, qt = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), Ht = async (n, e, t) => {
1495
+ const s = qt(n, e);
1477
1496
  if (s)
1478
- return fe(s, { maxBitrate: t });
1497
+ return ve(s, { maxBitrate: t });
1479
1498
  };
1480
1499
  var P = /* @__PURE__ */ ((n) => (n.START_PRESENTATION = "presentation:start", n.STARTED_PRESENTATION = "presentation:started", n.END_PRESENTATION = "presentation:end", n.ENDED_PRESENTATION = "presentation:ended", n.FAILED_PRESENTATION = "presentation:failed", n))(P || {});
1481
- const Me = [
1500
+ const fe = [
1482
1501
  "presentation:start",
1483
1502
  "presentation:started",
1484
1503
  "presentation:end",
1485
1504
  "presentation:ended",
1486
1505
  "presentation:failed"
1487
- ], qt = () => new R(Me);
1488
- var Ht = /* @__PURE__ */ ((n) => (n.IDLE = "presentation:idle", n.STARTING = "presentation:starting", n.ACTIVE = "presentation:active", n.STOPPING = "presentation:stopping", n.FAILED = "presentation:failed", n))(Ht || {});
1489
- const Wt = G({
1506
+ ], Wt = () => new R(fe);
1507
+ var xt = /* @__PURE__ */ ((n) => (n.IDLE = "presentation:idle", n.STARTING = "presentation:starting", n.ACTIVE = "presentation:active", n.STOPPING = "presentation:stopping", n.FAILED = "presentation:failed", n))(xt || {});
1508
+ const Qt = G({
1490
1509
  types: {
1491
1510
  context: {},
1492
1511
  events: {}
@@ -1811,9 +1830,9 @@ const Wt = G({
1811
1830
  }
1812
1831
  }
1813
1832
  });
1814
- class xt extends V {
1833
+ class Yt extends V {
1815
1834
  constructor(e) {
1816
- super(Wt), this.subscribeCallEvents(e);
1835
+ super(Qt), this.subscribeCallEvents(e);
1817
1836
  }
1818
1837
  get isIdle() {
1819
1838
  return this.state === "presentation:idle";
@@ -1883,8 +1902,8 @@ class xt extends V {
1883
1902
  );
1884
1903
  }
1885
1904
  }
1886
- const Qt = 1, di = (n) => je(n);
1887
- class Yt {
1905
+ const Xt = 1, li = (n) => ze(n);
1906
+ class Jt {
1888
1907
  events;
1889
1908
  presentationStateMachine;
1890
1909
  promisePendingStartPresentation;
@@ -1897,7 +1916,7 @@ class Yt {
1897
1916
  callManager: e,
1898
1917
  maxBitrate: t
1899
1918
  }) {
1900
- this.callManager = e, this.maxBitrate = t, this.events = qt(), this.presentationStateMachine = new xt(this.callManager.events), this.subscribe();
1919
+ this.callManager = e, this.maxBitrate = t, this.events = Wt(), this.presentationStateMachine = new Yt(this.callManager.events), this.subscribe();
1901
1920
  }
1902
1921
  get presentationActor() {
1903
1922
  return this.presentationStateMachine.actorRef;
@@ -1995,7 +2014,7 @@ class Yt {
1995
2014
  stream: s,
1996
2015
  presentationOptions: i,
1997
2016
  options: r = {
1998
- callLimit: Qt
2017
+ callLimit: Xt
1999
2018
  }
2000
2019
  }) {
2001
2020
  const a = async () => this.sendPresentation(
@@ -2004,7 +2023,7 @@ class Yt {
2004
2023
  s,
2005
2024
  i
2006
2025
  ), o = () => !!this.streamPresentationCurrent;
2007
- return this.cancelableSendPresentationWithRepeatedCalls = Te({
2026
+ return this.cancelableSendPresentationWithRepeatedCalls = ue({
2008
2027
  targetFunction: a,
2009
2028
  isComplete: o,
2010
2029
  isRejectAsValid: !0,
@@ -2041,7 +2060,7 @@ class Yt {
2041
2060
  if (!e || !t || s === void 0)
2042
2061
  return;
2043
2062
  const i = e.getSenders();
2044
- await Vt(i, t, s);
2063
+ await Ht(i, t, s);
2045
2064
  };
2046
2065
  getRtcSessionProtected = () => {
2047
2066
  const e = this.callManager.getEstablishedRTCSession();
@@ -2062,7 +2081,7 @@ class Yt {
2062
2081
  delete this.streamPresentationCurrent;
2063
2082
  }
2064
2083
  }
2065
- class Xt {
2084
+ class zt {
2066
2085
  data;
2067
2086
  getUa;
2068
2087
  constructor(e) {
@@ -2149,7 +2168,7 @@ class Xt {
2149
2168
  }
2150
2169
  }
2151
2170
  var C = /* @__PURE__ */ ((n) => (n.CONNECTING = "connecting", n.CONNECTED = "connected", n.DISCONNECTED = "disconnected", n.DISCONNECTING = "disconnecting", n.NEW_RTC_SESSION = "newRTCSession", n.REGISTERED = "registered", n.UNREGISTERED = "unregistered", n.REGISTRATION_FAILED = "registrationFailed", n.NEW_MESSAGE = "newMessage", n.SIP_EVENT = "sipEvent", n.CONNECT_STARTED = "connect-started", n.CONNECT_SUCCEEDED = "connect-succeeded", n.CONNECT_FAILED = "connect-failed", n.CONNECT_PARAMETERS_RESOLVE_SUCCESS = "connect-parameters-resolve-success", n.CONNECT_PARAMETERS_RESOLVE_FAILED = "connect-parameters-resolve-failed", n.CONNECTED_WITH_CONFIGURATION = "connected-with-configuration", n))(C || {});
2152
- const _e = [
2171
+ const Me = [
2153
2172
  "connecting",
2154
2173
  "connected",
2155
2174
  "disconnected",
@@ -2159,7 +2178,7 @@ const _e = [
2159
2178
  "registrationFailed",
2160
2179
  "newMessage",
2161
2180
  "sipEvent"
2162
- ], Jt = [
2181
+ ], jt = [
2163
2182
  "disconnecting",
2164
2183
  "connect-started",
2165
2184
  "connect-succeeded",
@@ -2167,12 +2186,12 @@ const _e = [
2167
2186
  "connect-parameters-resolve-success",
2168
2187
  "connect-parameters-resolve-failed",
2169
2188
  "connected-with-configuration"
2170
- ], be = [..._e, ...Jt], zt = () => new R(be);
2171
- function jt(n) {
2189
+ ], _e = [...Me, ...jt], Kt = () => new R(_e);
2190
+ function Zt(n) {
2172
2191
  return (e) => `sip:${e}@${n}`;
2173
2192
  }
2174
- const Kt = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, Oe = (n) => n.trim().replaceAll(" ", "_"), Zt = Kt(1e5, 99999999), en = 3;
2175
- class tn {
2193
+ const en = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, be = (n) => n.trim().replaceAll(" ", "_"), tn = en(1e5, 99999999), nn = 3;
2194
+ class sn {
2176
2195
  cancelableConnectWithRepeatedCalls;
2177
2196
  JsSIP;
2178
2197
  events;
@@ -2198,7 +2217,7 @@ class tn {
2198
2217
  }
2199
2218
  let r = !1;
2200
2219
  const a = this.getConnectionConfiguration();
2201
- e !== void 0 && e !== a?.displayName && (r = i.set("display_name", Oe(e)), this.updateConnectionConfiguration("displayName", e));
2220
+ e !== void 0 && e !== a?.displayName && (r = i.set("display_name", be(e)), this.updateConnectionConfiguration("displayName", e));
2202
2221
  const o = r;
2203
2222
  o ? t(o) : s(new Error("nothing changed"));
2204
2223
  });
@@ -2216,12 +2235,12 @@ class tn {
2216
2235
  cancelRequests() {
2217
2236
  this.cancelConnectWithRepeatedCalls();
2218
2237
  }
2219
- connectWithDuplicatedCalls = async (e, { callLimit: t = en } = {}) => {
2238
+ connectWithDuplicatedCalls = async (e, { callLimit: t = nn } = {}) => {
2220
2239
  const s = async () => this.connectInner(e), i = (r) => {
2221
- const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), l = r != null && !st(r);
2240
+ const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), l = r != null && !nt(r);
2222
2241
  return c || l;
2223
2242
  };
2224
- return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = Te({
2243
+ return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = ue({
2225
2244
  targetFunction: s,
2226
2245
  isComplete: i,
2227
2246
  callLimit: t,
@@ -2326,8 +2345,8 @@ class tn {
2326
2345
  });
2327
2346
  }
2328
2347
  }
2329
- var nn = /* @__PURE__ */ ((n) => (n.IDLE = "connection:idle", n.PREPARING = "connection:preparing", n.CONNECTING = "connection:connecting", n.CONNECTED = "connection:connected", n.REGISTERED = "connection:registered", n.ESTABLISHED = "connection:established", n.DISCONNECTED = "connection:disconnected", n.FAILED = "connection:failed", n))(nn || {}), De = /* @__PURE__ */ ((n) => (n.START_CONNECT = "START_CONNECT", n.START_INIT_UA = "START_INIT_UA", n.UA_CONNECTED = "UA_CONNECTED", n.UA_REGISTERED = "UA_REGISTERED", n.UA_UNREGISTERED = "UA_UNREGISTERED", n.UA_DISCONNECTED = "UA_DISCONNECTED", n.CONNECTION_FAILED = "CONNECTION_FAILED", n.RESET = "RESET", n))(De || {});
2330
- const sn = Object.values(De), rn = G({
2348
+ var rn = /* @__PURE__ */ ((n) => (n.IDLE = "connection:idle", n.PREPARING = "connection:preparing", n.CONNECTING = "connection:connecting", n.CONNECTED = "connection:connected", n.REGISTERED = "connection:registered", n.ESTABLISHED = "connection:established", n.DISCONNECTED = "connection:disconnected", n.FAILED = "connection:failed", n))(rn || {}), Oe = /* @__PURE__ */ ((n) => (n.START_CONNECT = "START_CONNECT", n.START_INIT_UA = "START_INIT_UA", n.UA_CONNECTED = "UA_CONNECTED", n.UA_REGISTERED = "UA_REGISTERED", n.UA_UNREGISTERED = "UA_UNREGISTERED", n.UA_DISCONNECTED = "UA_DISCONNECTED", n.CONNECTION_FAILED = "CONNECTION_FAILED", n.RESET = "RESET", n))(Oe || {});
2349
+ const an = Object.values(Oe), on = G({
2331
2350
  types: {
2332
2351
  context: {},
2333
2352
  events: {}
@@ -2707,11 +2726,11 @@ const sn = Object.values(De), rn = G({
2707
2726
  }
2708
2727
  }
2709
2728
  });
2710
- class an extends V {
2729
+ class cn extends V {
2711
2730
  events;
2712
2731
  unsubscribeFromEvents;
2713
2732
  constructor(e) {
2714
- super(rn), this.events = e, this.subscribeToEvents();
2733
+ super(on), this.events = e, this.subscribeToEvents();
2715
2734
  }
2716
2735
  get isIdle() {
2717
2736
  return this.hasState(
@@ -2793,7 +2812,7 @@ class an extends V {
2793
2812
  return this.getSnapshot().can({ type: e });
2794
2813
  }
2795
2814
  getValidEvents() {
2796
- return sn.filter((e) => this.canTransition(e));
2815
+ return an.filter((e) => this.canTransition(e));
2797
2816
  }
2798
2817
  hasState(e) {
2799
2818
  return this.getSnapshot().matches(e);
@@ -2865,7 +2884,7 @@ class an extends V {
2865
2884
  this.toFailed(e instanceof Error ? e : void 0);
2866
2885
  };
2867
2886
  }
2868
- class on {
2887
+ class dn {
2869
2888
  events;
2870
2889
  getUaProtected;
2871
2890
  constructor(e) {
@@ -2902,7 +2921,7 @@ class on {
2902
2921
  };
2903
2922
  }
2904
2923
  }
2905
- class cn {
2924
+ class hn {
2906
2925
  uaFactory;
2907
2926
  getUaProtected;
2908
2927
  constructor(e) {
@@ -2967,7 +2986,7 @@ class cn {
2967
2986
  });
2968
2987
  }
2969
2988
  }
2970
- const dn = (n) => {
2989
+ const ln = (n) => {
2971
2990
  const e = [];
2972
2991
  return n !== void 0 && n !== "" && e.push(`X-Vinteo-Remote: ${n}`), e;
2973
2992
  };
@@ -2996,10 +3015,10 @@ class F {
2996
3015
  throw new Error("user is required for authorized connection");
2997
3016
  }
2998
3017
  static resolveAuthorizationUser(e, t) {
2999
- return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${Zt()}`;
3018
+ return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${tn()}`;
3000
3019
  }
3001
3020
  static buildExtraHeaders(e, t) {
3002
- const s = e !== void 0 && e !== "" ? dn(e) : [];
3021
+ const s = e !== void 0 && e !== "" ? ln(e) : [];
3003
3022
  return t === void 0 ? s : [...s, ...t];
3004
3023
  }
3005
3024
  createConfiguration({
@@ -3023,13 +3042,13 @@ class F {
3023
3042
  sipServerIp: r,
3024
3043
  sipServerUrl: s
3025
3044
  });
3026
- const E = F.resolveAuthorizationUser(a, e), m = jt(r), D = m(E), A = new this.JsSIP.WebSocketInterface(`wss://${s}/webrtc/wss/`);
3045
+ const E = F.resolveAuthorizationUser(a, e), m = Zt(r), D = m(E), A = new this.JsSIP.WebSocketInterface(`wss://${s}/webrtc/wss/`);
3027
3046
  return {
3028
3047
  configuration: {
3029
3048
  password: t,
3030
3049
  register: a,
3031
3050
  uri: D,
3032
- display_name: Oe(i),
3051
+ display_name: be(i),
3033
3052
  user_agent: u,
3034
3053
  sdpSemantics: "unified-plan",
3035
3054
  sockets: [A],
@@ -3058,13 +3077,13 @@ class F {
3058
3077
  extraHeaders: e.extraHeaders
3059
3078
  });
3060
3079
  return t.eachTriggers((a, o) => {
3061
- const c = _e.find((l) => l === o);
3080
+ const c = Me.find((l) => l === o);
3062
3081
  c && r.on(c, a);
3063
3082
  }), { ua: r, helpers: i };
3064
3083
  }
3065
3084
  }
3066
- const Pe = "Not ready for connection", hn = (n) => n instanceof Error && n.message === Pe, ln = () => new Error(Pe), gn = async (n) => typeof n == "function" ? n() : n;
3067
- class un {
3085
+ const De = "Not ready for connection", gn = (n) => n instanceof Error && n.message === De, un = () => new Error(De), Tn = async (n) => typeof n == "function" ? n() : n;
3086
+ class En {
3068
3087
  events;
3069
3088
  ua;
3070
3089
  socket;
@@ -3076,15 +3095,15 @@ class un {
3076
3095
  configurationManager;
3077
3096
  JsSIP;
3078
3097
  constructor({ JsSIP: e }) {
3079
- this.JsSIP = e, this.events = zt(), this.uaFactory = new F(e), this.registrationManager = new on({
3098
+ this.JsSIP = e, this.events = Kt(), this.uaFactory = new F(e), this.registrationManager = new dn({
3080
3099
  events: this.events,
3081
3100
  getUaProtected: this.getUaProtected
3082
- }), this.stateMachine = new an(this.events), this.configurationManager = new Xt({
3101
+ }), this.stateMachine = new cn(this.events), this.configurationManager = new zt({
3083
3102
  getUa: this.getUa
3084
- }), this.sipOperations = new cn({
3103
+ }), this.sipOperations = new hn({
3085
3104
  uaFactory: this.uaFactory,
3086
3105
  getUaProtected: this.getUaProtected
3087
- }), this.connectionFlow = new tn({
3106
+ }), this.connectionFlow = new sn({
3088
3107
  JsSIP: this.JsSIP,
3089
3108
  events: this.events,
3090
3109
  uaFactory: this.uaFactory,
@@ -3189,7 +3208,7 @@ class un {
3189
3208
  getUa = () => this.ua;
3190
3209
  connectWithProcessError = async (e, t) => {
3191
3210
  if (!(t?.hasReadyForConnection?.() ?? !0))
3192
- throw ln();
3211
+ throw un();
3193
3212
  return this.processConnect(e, t).catch(async (i) => {
3194
3213
  const r = i;
3195
3214
  return this.disconnect().then(() => {
@@ -3199,7 +3218,7 @@ class un {
3199
3218
  });
3200
3219
  });
3201
3220
  };
3202
- processConnect = async (e, t) => (this.events.trigger(C.CONNECT_STARTED, {}), gn(e).then((s) => (this.events.trigger(C.CONNECT_PARAMETERS_RESOLVE_SUCCESS, s), s)).catch((s) => {
3221
+ processConnect = async (e, t) => (this.events.trigger(C.CONNECT_STARTED, {}), Tn(e).then((s) => (this.events.trigger(C.CONNECT_PARAMETERS_RESOLVE_SUCCESS, s), s)).catch((s) => {
3203
3222
  throw this.events.trigger(C.CONNECT_PARAMETERS_RESOLVE_FAILED, s), s;
3204
3223
  }).then(async (s) => this.connectionFlow.connect(s, t)).then((s) => (this.events.trigger(C.CONNECT_SUCCEEDED, {
3205
3224
  ...s
@@ -3208,9 +3227,9 @@ class un {
3208
3227
  throw this.events.trigger(C.CONNECT_FAILED, i), i;
3209
3228
  }));
3210
3229
  }
3211
- class Tn {
3230
+ class Sn {
3212
3231
  connectionManager;
3213
- stackPromises = Ee({
3232
+ stackPromises = Te({
3214
3233
  noRunIsNotActual: !0
3215
3234
  });
3216
3235
  constructor({ connectionManager: e }) {
@@ -3222,11 +3241,11 @@ class Tn {
3222
3241
  this.stackPromises.stop();
3223
3242
  }
3224
3243
  }
3225
- const ae = 0, En = 30;
3226
- class Sn {
3227
- countInner = ae;
3228
- initialCount = ae;
3229
- limitInner = En;
3244
+ const re = 0, Cn = 30;
3245
+ class pn {
3246
+ countInner = re;
3247
+ initialCount = re;
3248
+ limitInner = Cn;
3230
3249
  isInProgress = !1;
3231
3250
  onStatusChange;
3232
3251
  constructor({
@@ -3259,7 +3278,7 @@ class Sn {
3259
3278
  this.countInner = this.initialCount, this.finishAttempt();
3260
3279
  }
3261
3280
  }
3262
- class Cn {
3281
+ class mn {
3263
3282
  connectionManager;
3264
3283
  interval;
3265
3284
  checkTelephonyByTimeout = void 0;
@@ -3275,7 +3294,7 @@ class Cn {
3275
3294
  onSuccessRequest: t,
3276
3295
  onFailRequest: s
3277
3296
  }) {
3278
- this.stop(), this.cancelableBeforeRequest = new Y(e), this.checkTelephonyByTimeout = Ye({
3297
+ this.stop(), this.cancelableBeforeRequest = new Y(e), this.checkTelephonyByTimeout = Qe({
3279
3298
  isDontStopOnFail: !0,
3280
3299
  requestInterval: this.interval,
3281
3300
  request: async () => {
@@ -3296,7 +3315,7 @@ class Cn {
3296
3315
  }
3297
3316
  }
3298
3317
  var v = /* @__PURE__ */ ((n) => (n.BEFORE_ATTEMPT = "before-attempt", n.SUCCESS = "success", n.FAILED_ALL_ATTEMPTS = "failed-all-attempts", n.CANCELLED_ATTEMPTS = "cancelled-attempts", n.CHANGED_ATTEMPT_STATUS = "changed-attempt-status", n.STOP_ATTEMPTS_BY_ERROR = "stop-attempts-by-error", n.LIMIT_REACHED_ATTEMPTS = "limit-reached-attempts", n))(v || {});
3299
- const ye = [
3318
+ const Pe = [
3300
3319
  "before-attempt",
3301
3320
  "success",
3302
3321
  "failed-all-attempts",
@@ -3304,7 +3323,7 @@ const ye = [
3304
3323
  "changed-attempt-status",
3305
3324
  "stop-attempts-by-error",
3306
3325
  "limit-reached-attempts"
3307
- ], pn = () => new R(ye);
3326
+ ], Nn = () => new R(Pe);
3308
3327
  class te {
3309
3328
  callManager;
3310
3329
  disposers = [];
@@ -3330,15 +3349,15 @@ class te {
3330
3349
  this.callManager.isCallActive ? e?.() : t();
3331
3350
  }
3332
3351
  }
3333
- const mn = 15e3, Nn = 2;
3334
- class An {
3352
+ const An = 15e3, Rn = 2;
3353
+ class In {
3335
3354
  connectionManager;
3336
3355
  pingServerByTimeoutWithFailCalls;
3337
3356
  constructor({ connectionManager: e }) {
3338
- this.connectionManager = e, this.pingServerByTimeoutWithFailCalls = Xe(Nn, {
3357
+ this.connectionManager = e, this.pingServerByTimeoutWithFailCalls = Ye(Rn, {
3339
3358
  whenPossibleRequest: async () => {
3340
3359
  },
3341
- requestInterval: mn,
3360
+ requestInterval: An,
3342
3361
  request: async () => (d("ping"), this.connectionManager.ping().then(() => {
3343
3362
  d("ping success");
3344
3363
  }))
@@ -3351,14 +3370,14 @@ class An {
3351
3370
  this.pingServerByTimeoutWithFailCalls.stop();
3352
3371
  }
3353
3372
  }
3354
- class Rn {
3373
+ class vn {
3355
3374
  pingServerRequester;
3356
3375
  notActiveCallSubscriber;
3357
3376
  constructor({
3358
3377
  connectionManager: e,
3359
3378
  callManager: t
3360
3379
  }) {
3361
- this.pingServerRequester = new An({
3380
+ this.pingServerRequester = new In({
3362
3381
  connectionManager: e
3363
3382
  }), this.notActiveCallSubscriber = new te({ callManager: t });
3364
3383
  }
@@ -3379,7 +3398,7 @@ class Rn {
3379
3398
  this.notActiveCallSubscriber.unsubscribe();
3380
3399
  }
3381
3400
  }
3382
- class In {
3401
+ class fn {
3383
3402
  connectionManager;
3384
3403
  isRegistrationFailed = !1;
3385
3404
  disposers = [];
@@ -3415,12 +3434,12 @@ class In {
3415
3434
  this.isRegistrationFailed = !1;
3416
3435
  }
3417
3436
  }
3418
- const vn = 3e3, fn = 15e3, oe = {
3437
+ const Mn = 3e3, _n = 15e3, ae = {
3419
3438
  LIMIT_REACHED: "Limit reached",
3420
3439
  FAILED_TO_RECONNECT: "Failed to reconnect"
3421
- }, Mn = async () => {
3422
- }, _n = (n) => !0;
3423
- class bn {
3440
+ }, bn = async () => {
3441
+ }, On = (n) => !0;
3442
+ class Dn {
3424
3443
  events;
3425
3444
  connectionManager;
3426
3445
  connectionQueueManager;
@@ -3440,20 +3459,20 @@ class bn {
3440
3459
  connectionManager: t,
3441
3460
  callManager: s
3442
3461
  }, i) {
3443
- const r = i?.onBeforeRetry ?? Mn, a = i?.canRetryOnError ?? _n;
3444
- this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.canRetryOnError = a, this.networkInterfacesSubscriber = i?.networkInterfacesSubscriber, this.resumeFromSleepModeSubscriber = i?.resumeFromSleepModeSubscriber, this.events = pn(), this.checkTelephonyRequester = new Cn({
3462
+ const r = i?.onBeforeRetry ?? bn, a = i?.canRetryOnError ?? On;
3463
+ this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.canRetryOnError = a, this.networkInterfacesSubscriber = i?.networkInterfacesSubscriber, this.resumeFromSleepModeSubscriber = i?.resumeFromSleepModeSubscriber, this.events = Nn(), this.checkTelephonyRequester = new mn({
3445
3464
  connectionManager: t,
3446
- interval: i?.checkTelephonyRequestInterval ?? fn
3447
- }), this.pingServerIfNotActiveCallRequester = new Rn({
3465
+ interval: i?.checkTelephonyRequestInterval ?? _n
3466
+ }), this.pingServerIfNotActiveCallRequester = new vn({
3448
3467
  connectionManager: t,
3449
3468
  callManager: s
3450
- }), this.registrationFailedOutOfCallSubscriber = new In({
3469
+ }), this.registrationFailedOutOfCallSubscriber = new fn({
3451
3470
  connectionManager: t,
3452
3471
  callManager: s
3453
- }), this.attemptsState = new Sn({
3472
+ }), this.attemptsState = new pn({
3454
3473
  onStatusChange: this.emitStatusChange
3455
- }), this.cancelableRequestBeforeRetry = new Y(r), this.delayBetweenAttempts = new Je(
3456
- i?.timeoutBetweenAttempts ?? vn
3474
+ }), this.cancelableRequestBeforeRetry = new Y(r), this.delayBetweenAttempts = new Xe(
3475
+ i?.timeoutBetweenAttempts ?? Mn
3457
3476
  ), this.notActiveCallSubscriber = new te({ callManager: s });
3458
3477
  }
3459
3478
  start(e) {
@@ -3519,7 +3538,7 @@ class bn {
3519
3538
  }
3520
3539
  }
3521
3540
  handleConnectionError(e, t) {
3522
- if (hn(e)) {
3541
+ if (gn(e)) {
3523
3542
  this.attemptsState.finishAttempt(), this.events.trigger(v.STOP_ATTEMPTS_BY_ERROR, e);
3524
3543
  return;
3525
3544
  }
@@ -3527,14 +3546,14 @@ class bn {
3527
3546
  d("executeConnectionAttempt: error does not allow retry", e), this.attemptsState.finishAttempt(), this.events.trigger(v.STOP_ATTEMPTS_BY_ERROR, e);
3528
3547
  return;
3529
3548
  }
3530
- if (Ze(e)) {
3549
+ if (Ke(e)) {
3531
3550
  d("executeConnectionAttempt: not actual error", e), this.attemptsState.finishAttempt(), this.events.trigger(v.CANCELLED_ATTEMPTS, e);
3532
3551
  return;
3533
3552
  }
3534
3553
  d("executeConnectionAttempt: error", e), this.scheduleReconnect(t);
3535
3554
  }
3536
3555
  handleLimitReached(e) {
3537
- this.attemptsState.finishAttempt(), this.events.trigger(v.LIMIT_REACHED_ATTEMPTS, new Error(oe.LIMIT_REACHED)), this.startCheckTelephony(e);
3556
+ this.attemptsState.finishAttempt(), this.events.trigger(v.LIMIT_REACHED_ATTEMPTS, new Error(ae.LIMIT_REACHED)), this.startCheckTelephony(e);
3538
3557
  }
3539
3558
  handleSucceededAttempt(e) {
3540
3559
  d("handleSucceededAttempt"), this.subscribeToConnectTriggers(e), this.events.trigger(v.SUCCESS);
@@ -3595,8 +3614,8 @@ class bn {
3595
3614
  }
3596
3615
  scheduleReconnect(e) {
3597
3616
  d("scheduleReconnect"), this.delayBetweenAttempts.request().then(async () => (d("scheduleReconnect: delayBetweenAttempts success"), this.cancelableRequestBeforeRetry.request())).then(async () => (d("scheduleReconnect: onBeforeRetry success"), this.attemptConnection(e))).catch((t) => {
3598
- const s = t instanceof Error ? t : new Error(oe.FAILED_TO_RECONNECT);
3599
- this.attemptsState.finishAttempt(), Qe(t) || ze(t) ? this.events.trigger(v.CANCELLED_ATTEMPTS, s) : this.events.trigger(v.FAILED_ALL_ATTEMPTS, s), d("scheduleReconnect: error", t);
3617
+ const s = t instanceof Error ? t : new Error(ae.FAILED_TO_RECONNECT);
3618
+ this.attemptsState.finishAttempt(), xe(t) || Je(t) ? this.events.trigger(v.CANCELLED_ATTEMPTS, s) : this.events.trigger(v.FAILED_ALL_ATTEMPTS, s), d("scheduleReconnect: error", t);
3600
3619
  });
3601
3620
  }
3602
3621
  isConnectionUnavailable() {
@@ -3608,12 +3627,12 @@ class bn {
3608
3627
  };
3609
3628
  }
3610
3629
  var j = /* @__PURE__ */ ((n) => (n.STATE_CHANGED = "state-changed", n.STATE_RESET = "state-reset", n))(j || {});
3611
- const Le = ["state-changed", "state-reset"], On = () => new R(Le);
3612
- class Dn {
3630
+ const ye = ["state-changed", "state-reset"], Pn = () => new R(ye);
3631
+ class yn {
3613
3632
  events;
3614
3633
  state = {};
3615
3634
  constructor() {
3616
- this.events = On();
3635
+ this.events = Pn();
3617
3636
  }
3618
3637
  getState() {
3619
3638
  return { ...this.state };
@@ -3663,7 +3682,7 @@ class Dn {
3663
3682
  this.events.off(e, t);
3664
3683
  }
3665
3684
  }
3666
- const Pn = G({
3685
+ const Ln = G({
3667
3686
  types: {
3668
3687
  context: {},
3669
3688
  events: {}
@@ -3704,9 +3723,9 @@ const Pn = G({
3704
3723
  }
3705
3724
  }
3706
3725
  });
3707
- class yn extends V {
3726
+ class wn extends V {
3708
3727
  constructor() {
3709
- super(Pn);
3728
+ super(Ln);
3710
3729
  }
3711
3730
  get isAvailable() {
3712
3731
  return this.state === "contented-stream:available";
@@ -3748,16 +3767,16 @@ class yn extends V {
3748
3767
  }
3749
3768
  }
3750
3769
  var K = /* @__PURE__ */ ((n) => (n.AVAILABLE = "available", n.NOT_AVAILABLE = "not-available", n))(K || {});
3751
- const Ln = [
3770
+ const Un = [
3752
3771
  "available",
3753
3772
  "not-available"
3754
3773
  /* NOT_AVAILABLE */
3755
- ], wn = () => new R(Ln);
3756
- class Un {
3774
+ ], Fn = () => new R(Un);
3775
+ class Bn {
3757
3776
  events;
3758
3777
  stateMachine;
3759
3778
  constructor() {
3760
- this.events = wn(), this.stateMachine = new yn(), this.proxyEvents();
3779
+ this.events = Fn(), this.stateMachine = new wn(), this.proxyEvents();
3761
3780
  }
3762
3781
  get isAvailable() {
3763
3782
  return this.stateMachine.isAvailable;
@@ -3791,14 +3810,14 @@ class Un {
3791
3810
  }
3792
3811
  }
3793
3812
  var k = /* @__PURE__ */ ((n) => (n.RINGING = "ringing", n.DECLINED_INCOMING_CALL = "declinedIncomingCall", n.TERMINATED_INCOMING_CALL = "terminatedIncomingCall", n.FAILED_INCOMING_CALL = "failedIncomingCall", n))(k || {});
3794
- const we = [
3813
+ const Le = [
3795
3814
  "ringing",
3796
3815
  "declinedIncomingCall",
3797
3816
  "terminatedIncomingCall",
3798
3817
  "failedIncomingCall"
3799
- ], Fn = () => new R(we);
3800
- var Bn = /* @__PURE__ */ ((n) => (n.IDLE = "incoming:idle", n.RINGING = "incoming:ringing", n.CONSUMED = "incoming:consumed", n.DECLINED = "incoming:declined", n.TERMINATED = "incoming:terminated", n.FAILED = "incoming:failed", n))(Bn || {});
3801
- const kn = G({
3818
+ ], kn = () => new R(Le);
3819
+ var $n = /* @__PURE__ */ ((n) => (n.IDLE = "incoming:idle", n.RINGING = "incoming:ringing", n.CONSUMED = "incoming:consumed", n.DECLINED = "incoming:declined", n.TERMINATED = "incoming:terminated", n.FAILED = "incoming:failed", n))($n || {});
3820
+ const Gn = G({
3802
3821
  types: {
3803
3822
  context: {},
3804
3823
  events: {}
@@ -4130,9 +4149,9 @@ const kn = G({
4130
4149
  }
4131
4150
  }
4132
4151
  });
4133
- class $n extends V {
4152
+ class Vn extends V {
4134
4153
  constructor({ incomingEvents: e, connectionEvents: t }) {
4135
- super(kn), this.subscribeIncomingEvents(e), this.subscribeConnectionEvents(t);
4154
+ super(Gn), this.subscribeIncomingEvents(e), this.subscribeConnectionEvents(t);
4136
4155
  }
4137
4156
  get isIdle() {
4138
4157
  return this.state === "incoming:idle";
@@ -4217,14 +4236,14 @@ class $n extends V {
4217
4236
  this.send({ type: "INCOMING.CLEAR" });
4218
4237
  }
4219
4238
  }
4220
- const Gn = 486, Vn = 487;
4221
- class qn {
4239
+ const qn = 486, Hn = 487;
4240
+ class Wn {
4222
4241
  events;
4223
4242
  incomingStateMachine;
4224
4243
  incomingRTCSession;
4225
4244
  connectionManager;
4226
4245
  constructor(e) {
4227
- this.connectionManager = e, this.events = Fn(), this.incomingStateMachine = new $n({
4246
+ this.connectionManager = e, this.events = kn(), this.incomingStateMachine = new Vn({
4228
4247
  incomingEvents: this.events,
4229
4248
  connectionEvents: this.connectionManager.events
4230
4249
  }), this.start();
@@ -4260,7 +4279,7 @@ class qn {
4260
4279
  return this.incomingStateMachine.toConsumed(), this.removeIncomingSession(), e;
4261
4280
  };
4262
4281
  async declineToIncomingCall({
4263
- statusCode: e = Vn
4282
+ statusCode: e = Hn
4264
4283
  } = {}) {
4265
4284
  return new Promise((t, s) => {
4266
4285
  try {
@@ -4272,7 +4291,7 @@ class qn {
4272
4291
  });
4273
4292
  }
4274
4293
  async busyIncomingCall() {
4275
- return this.declineToIncomingCall({ statusCode: Gn });
4294
+ return this.declineToIncomingCall({ statusCode: qn });
4276
4295
  }
4277
4296
  on(e, t) {
4278
4297
  return this.events.on(e, t);
@@ -4312,26 +4331,26 @@ class qn {
4312
4331
  delete this.incomingRTCSession;
4313
4332
  }
4314
4333
  }
4315
- var Ue = /* @__PURE__ */ ((n) => (n.SNAPSHOT_CHANGED = "snapshot-changed", n))(Ue || {});
4316
- const Fe = ["snapshot-changed"], Hn = () => new R(Fe), Wn = (n, e) => Object.is(n, e), ce = (n) => ({
4334
+ var we = /* @__PURE__ */ ((n) => (n.SNAPSHOT_CHANGED = "snapshot-changed", n))(we || {});
4335
+ const Ue = ["snapshot-changed"], xn = () => new R(Ue), Qn = (n, e) => Object.is(n, e), oe = (n) => ({
4317
4336
  connection: n.connection.getSnapshot(),
4318
4337
  call: n.call.getSnapshot(),
4319
4338
  incoming: n.incoming.getSnapshot(),
4320
4339
  presentation: n.presentation.getSnapshot()
4321
4340
  });
4322
- class xn {
4341
+ class Yn {
4323
4342
  events;
4324
4343
  actors;
4325
4344
  currentSnapshot;
4326
4345
  subscribers = /* @__PURE__ */ new Set();
4327
4346
  actorSubscriptions = [];
4328
4347
  constructor(e) {
4329
- this.events = Hn(), this.actors = {
4348
+ this.events = xn(), this.actors = {
4330
4349
  connection: e.connectionManager.connectionActor,
4331
4350
  call: e.callManager.callActor,
4332
4351
  incoming: e.incomingCallManager.incomingActor,
4333
4352
  presentation: e.presentationManager.presentationActor
4334
- }, this.currentSnapshot = ce(this.actors), this.actorSubscriptions.push(
4353
+ }, this.currentSnapshot = oe(this.actors), this.actorSubscriptions.push(
4335
4354
  this.actors.connection.subscribe(this.notifySubscribers),
4336
4355
  this.actors.call.subscribe(this.notifySubscribers),
4337
4356
  this.actors.incoming.subscribe(this.notifySubscribers),
@@ -4342,7 +4361,7 @@ class xn {
4342
4361
  return this.currentSnapshot;
4343
4362
  }
4344
4363
  subscribe(e, t, s) {
4345
- const i = typeof t == "function", r = i ? e : (T) => T, a = i ? t : e, o = (i ? s : void 0) ?? Wn, c = r(this.currentSnapshot), l = {
4364
+ const i = typeof t == "function", r = i ? e : (T) => T, a = i ? t : e, o = (i ? s : void 0) ?? Qn, c = r(this.currentSnapshot), l = {
4346
4365
  selector: r,
4347
4366
  listener: a,
4348
4367
  equals: o,
@@ -4365,12 +4384,12 @@ class xn {
4365
4384
  }
4366
4385
  notifySubscribers = () => {
4367
4386
  const e = this.currentSnapshot;
4368
- this.currentSnapshot = ce(this.actors);
4387
+ this.currentSnapshot = oe(this.actors);
4369
4388
  for (const t of this.subscribers) {
4370
4389
  const s = t.selector(this.currentSnapshot);
4371
4390
  t.equals(t.current, s) || (t.current = s, t.listener(s));
4372
4391
  }
4373
- this.events.trigger(Ue.SNAPSHOT_CHANGED, {
4392
+ this.events.trigger(we.SNAPSHOT_CHANGED, {
4374
4393
  previous: e,
4375
4394
  current: this.currentSnapshot
4376
4395
  });
@@ -4378,7 +4397,7 @@ class xn {
4378
4397
  }
4379
4398
  const B = 1e3;
4380
4399
  var p = /* @__PURE__ */ ((n) => (n.INBOUND_RTP = "inbound-rtp", n.REMOTE_OUTBOUND_RTP = "remote-outbound-rtp", n.MEDIA_SOURCE = "media-source", n.OUTBOUND_RTP = "outbound-rtp", n.REMOTE_INBOUND_RTP = "remote-inbound-rtp", n.CODEC = "codec", n.CANDIDATE_PAIR = "candidate-pair", n.CERTIFICATE = "certificate", n.TRANSPORT = "transport", n.LOCAL_CANDIDATE = "local-candidate", n.REMOTE_CANDIDATE = "remote-candidate", n))(p || {});
4381
- const Be = ["collected"], Qn = () => new R(Be), Yn = "api/v2/rtp2webrtc/offer", Xn = async ({
4400
+ const Fe = ["collected"], Xn = () => new R(Fe), Jn = "api/v2/rtp2webrtc/offer", zn = async ({
4382
4401
  serverUrl: n,
4383
4402
  conferenceNumber: e,
4384
4403
  quality: t,
@@ -4387,7 +4406,7 @@ const Be = ["collected"], Qn = () => new R(Be), Yn = "api/v2/rtp2webrtc/offer",
4387
4406
  token: r
4388
4407
  }) => {
4389
4408
  const a = new URL(
4390
- `https://${n.replace(/\/$/, "")}/${Yn}/${encodeURIComponent(e)}`
4409
+ `https://${n.replace(/\/$/, "")}/${Jn}/${encodeURIComponent(e)}`
4391
4410
  );
4392
4411
  a.searchParams.set("quality", t), a.searchParams.set("audio", String(s));
4393
4412
  const o = {
@@ -4410,10 +4429,10 @@ const Be = ["collected"], Qn = () => new R(Be), Yn = "api/v2/rtp2webrtc/offer",
4410
4429
  return l;
4411
4430
  }
4412
4431
  };
4413
- }, de = () => "performance" in window ? performance.now() : Date.now(), q = (n) => [...n.keys()].reduce((e, t) => {
4432
+ }, ce = () => "performance" in window ? performance.now() : Date.now(), q = (n) => [...n.keys()].reduce((e, t) => {
4414
4433
  const s = n.get(t);
4415
4434
  return s === void 0 ? e : { ...e, [s.type]: s };
4416
- }, {}), Jn = (n) => {
4435
+ }, {}), jn = (n) => {
4417
4436
  if (!n)
4418
4437
  return {
4419
4438
  outboundRtp: void 0,
@@ -4428,7 +4447,7 @@ const Be = ["collected"], Qn = () => new R(Be), Yn = "api/v2/rtp2webrtc/offer",
4428
4447
  mediaSource: e[p.MEDIA_SOURCE],
4429
4448
  remoteInboundRtp: e[p.REMOTE_INBOUND_RTP]
4430
4449
  };
4431
- }, he = (n) => {
4450
+ }, de = (n) => {
4432
4451
  if (!n)
4433
4452
  return {
4434
4453
  outboundRtp: void 0,
@@ -4443,7 +4462,7 @@ const Be = ["collected"], Qn = () => new R(Be), Yn = "api/v2/rtp2webrtc/offer",
4443
4462
  mediaSource: e[p.MEDIA_SOURCE],
4444
4463
  remoteInboundRtp: e[p.REMOTE_INBOUND_RTP]
4445
4464
  };
4446
- }, le = ({
4465
+ }, he = ({
4447
4466
  videoReceiversStats: n,
4448
4467
  synchronizationSourcesVideo: e
4449
4468
  }) => {
@@ -4459,7 +4478,7 @@ const Be = ["collected"], Qn = () => new R(Be), Yn = "api/v2/rtp2webrtc/offer",
4459
4478
  codec: t[p.CODEC],
4460
4479
  synchronizationSources: e
4461
4480
  };
4462
- }, zn = ({
4481
+ }, Kn = ({
4463
4482
  audioReceiverStats: n,
4464
4483
  synchronizationSourcesAudio: e
4465
4484
  }) => {
@@ -4477,7 +4496,7 @@ const Be = ["collected"], Qn = () => new R(Be), Yn = "api/v2/rtp2webrtc/offer",
4477
4496
  remoteOutboundRtp: t[p.REMOTE_OUTBOUND_RTP],
4478
4497
  synchronizationSources: e
4479
4498
  };
4480
- }, ke = (n) => {
4499
+ }, Be = (n) => {
4481
4500
  if (!n)
4482
4501
  return {
4483
4502
  candidatePair: void 0,
@@ -4494,39 +4513,39 @@ const Be = ["collected"], Qn = () => new R(Be), Yn = "api/v2/rtp2webrtc/offer",
4494
4513
  remoteCandidate: e[p.REMOTE_CANDIDATE],
4495
4514
  transport: e[p.TRANSPORT]
4496
4515
  };
4497
- }, jn = ({
4516
+ }, Zn = ({
4498
4517
  audioSenderStats: n,
4499
4518
  videoSenderFirstStats: e,
4500
4519
  videoSenderSecondStats: t
4501
4520
  }) => ({
4502
- video: he(e),
4503
- secondVideo: he(t),
4504
- audio: Jn(n),
4505
- additional: ke(
4521
+ video: de(e),
4522
+ secondVideo: de(t),
4523
+ audio: jn(n),
4524
+ additional: Be(
4506
4525
  n ?? e ?? t
4507
4526
  )
4508
- }), Kn = ({
4527
+ }), es = ({
4509
4528
  audioReceiverStats: n,
4510
4529
  videoReceiverFirstStats: e,
4511
4530
  videoReceiverSecondStats: t,
4512
4531
  synchronizationSources: s
4513
4532
  }) => ({
4514
- video: le({
4533
+ video: he({
4515
4534
  videoReceiversStats: e,
4516
4535
  synchronizationSourcesVideo: s.video
4517
4536
  }),
4518
- secondVideo: le({
4537
+ secondVideo: he({
4519
4538
  videoReceiversStats: t,
4520
4539
  synchronizationSourcesVideo: s.video
4521
4540
  }),
4522
- audio: zn({
4541
+ audio: Kn({
4523
4542
  audioReceiverStats: n,
4524
4543
  synchronizationSourcesAudio: s.audio
4525
4544
  }),
4526
- additional: ke(
4545
+ additional: Be(
4527
4546
  n ?? e ?? t
4528
4547
  )
4529
- }), Zn = ({
4548
+ }), ts = ({
4530
4549
  audioSenderStats: n,
4531
4550
  videoSenderFirstStats: e,
4532
4551
  videoSenderSecondStats: t,
@@ -4535,11 +4554,11 @@ const Be = ["collected"], Qn = () => new R(Be), Yn = "api/v2/rtp2webrtc/offer",
4535
4554
  videoReceiverSecondStats: r,
4536
4555
  synchronizationSources: a
4537
4556
  }) => {
4538
- const o = jn({
4557
+ const o = Zn({
4539
4558
  audioSenderStats: n,
4540
4559
  videoSenderFirstStats: e,
4541
4560
  videoSenderSecondStats: t
4542
- }), c = Kn({
4561
+ }), c = es({
4543
4562
  audioReceiverStats: s,
4544
4563
  videoReceiverFirstStats: i,
4545
4564
  videoReceiverSecondStats: r,
@@ -4549,7 +4568,7 @@ const Be = ["collected"], Qn = () => new R(Be), Yn = "api/v2/rtp2webrtc/offer",
4549
4568
  outbound: o,
4550
4569
  inbound: c
4551
4570
  };
4552
- }, es = async (n) => {
4571
+ }, ns = async (n) => {
4553
4572
  const e = "audio", t = "video", s = n.getSenders(), i = s.find((E) => E.track?.kind === e), r = s.filter((E) => E.track?.kind === t), a = n.getReceivers(), o = a.find((E) => E.track.kind === e), c = a.filter((E) => E.track.kind === t), l = {
4554
4573
  trackIdentifier: o?.track.id,
4555
4574
  item: o?.getSynchronizationSources()[0]
@@ -4574,7 +4593,7 @@ const Be = ["collected"], Qn = () => new R(Be), Yn = "api/v2/rtp2webrtc/offer",
4574
4593
  A,
4575
4594
  w,
4576
4595
  X,
4577
- xe
4596
+ We
4578
4597
  ] = E;
4579
4598
  return {
4580
4599
  synchronizationSources: u,
@@ -4583,25 +4602,25 @@ const Be = ["collected"], Qn = () => new R(Be), Yn = "api/v2/rtp2webrtc/offer",
4583
4602
  videoSenderSecondStats: A,
4584
4603
  audioReceiverStats: w,
4585
4604
  videoReceiverFirstStats: X,
4586
- videoReceiverSecondStats: xe
4605
+ videoReceiverSecondStats: We
4587
4606
  };
4588
4607
  });
4589
- }, ts = (n) => {
4608
+ }, ss = (n) => {
4590
4609
  d(String(n));
4591
4610
  };
4592
- class ns {
4611
+ class is {
4593
4612
  events;
4594
4613
  setTimeoutRequest;
4595
- requesterAllStatistics = new Y(es);
4614
+ requesterAllStatistics = new Y(ns);
4596
4615
  constructor() {
4597
- this.events = Qn(), this.setTimeoutRequest = new ue();
4616
+ this.events = Xn(), this.setTimeoutRequest = new ge();
4598
4617
  }
4599
4618
  get requested() {
4600
4619
  return this.setTimeoutRequest.requested;
4601
4620
  }
4602
4621
  start(e, {
4603
4622
  interval: t = B,
4604
- onError: s = ts
4623
+ onError: s = ss
4605
4624
  } = {}) {
4606
4625
  this.stop(), this.setTimeoutRequest.request(() => {
4607
4626
  this.collectStatistics(e, {
@@ -4630,10 +4649,10 @@ class ns {
4630
4649
  collectStatistics = (e, {
4631
4650
  onError: t
4632
4651
  }) => {
4633
- const s = de();
4652
+ const s = ce();
4634
4653
  this.requestAllStatistics(e).then((i) => {
4635
- this.events.trigger("collected", Zn(i));
4636
- const a = de() - s;
4654
+ this.events.trigger("collected", ts(i));
4655
+ const a = ce() - s;
4637
4656
  let o = B;
4638
4657
  a > 48 ? o = B * 4 : a > 32 ? o = B * 3 : a > 16 && (o = B * 2), this.start(e, {
4639
4658
  onError: t,
@@ -4650,8 +4669,8 @@ class ns {
4650
4669
  return this.requesterAllStatistics.request(t);
4651
4670
  };
4652
4671
  }
4653
- const ss = 500;
4654
- class is {
4672
+ const rs = 500;
4673
+ class as {
4655
4674
  statsPeerConnection;
4656
4675
  availableStats;
4657
4676
  previousAvailableStats;
@@ -4661,7 +4680,7 @@ class is {
4661
4680
  callManager: e,
4662
4681
  apiManager: t
4663
4682
  }) {
4664
- this.callManager = e, this.apiManager = t, this.statsPeerConnection = new ns(), this.subscribe();
4683
+ this.callManager = e, this.apiManager = t, this.statsPeerConnection = new is(), this.subscribe();
4665
4684
  }
4666
4685
  get events() {
4667
4686
  return this.statsPeerConnection.events;
@@ -4711,7 +4730,7 @@ class is {
4711
4730
  return this.previousInboundRtp?.packetsReceived;
4712
4731
  }
4713
4732
  get isReceivingPackets() {
4714
- const e = this.packetsReceived !== void 0 && this.packetsReceived >= ss, t = this.packetsReceived !== this.previousPacketsReceived;
4733
+ const e = this.packetsReceived !== void 0 && this.packetsReceived >= rs, t = this.packetsReceived !== this.previousPacketsReceived;
4715
4734
  return e && t;
4716
4735
  }
4717
4736
  on(e, t) {
@@ -4751,33 +4770,33 @@ class is {
4751
4770
  });
4752
4771
  }
4753
4772
  }
4754
- const rs = (n, e) => n.filter((s) => e.some((i) => i.clockRate === s.clockRate && i.mimeType === s.mimeType && i.channels === s.channels && i.sdpFmtpLine === s.sdpFmtpLine)), as = (n) => {
4773
+ const os = (n, e) => n.filter((s) => e.some((i) => i.clockRate === s.clockRate && i.mimeType === s.mimeType && i.channels === s.channels && i.sdpFmtpLine === s.sdpFmtpLine)), cs = (n) => {
4755
4774
  const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs, i = t === null ? [] : t.codecs;
4756
- return rs(s, i);
4757
- }, os = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
4775
+ return os(s, i);
4776
+ }, ds = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
4758
4777
  const i = e.indexOf(t.mimeType), r = e.indexOf(s.mimeType), a = i === -1 ? Number.MAX_VALUE : i, o = r === -1 ? Number.MAX_VALUE : r;
4759
4778
  return a - o;
4760
- }), cs = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), ds = (n, {
4779
+ }), hs = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), ls = (n, {
4761
4780
  preferredMimeTypesVideoCodecs: e,
4762
4781
  excludeMimeTypesVideoCodecs: t
4763
4782
  }) => {
4764
4783
  try {
4765
4784
  if (typeof n.setCodecPreferences == "function" && n.sender.track?.kind === "video" && (e !== void 0 && e.length > 0 || t !== void 0 && t.length > 0)) {
4766
- const s = as("video"), i = cs(s, t), r = os(i, e);
4785
+ const s = cs("video"), i = hs(s, t), r = ds(i, e);
4767
4786
  n.setCodecPreferences(r);
4768
4787
  }
4769
4788
  } catch (s) {
4770
4789
  d("setCodecPreferences error", s);
4771
4790
  }
4772
- }, hs = (n) => [...n.keys()].map((e) => n.get(e)), ls = (n, e) => hs(n).find((t) => t?.type === e), gs = async (n) => n.getStats().then((e) => ls(e, "codec")?.mimeType);
4773
- class us {
4791
+ }, gs = (n) => [...n.keys()].map((e) => n.get(e)), us = (n, e) => gs(n).find((t) => t?.type === e), Ts = async (n) => n.getStats().then((e) => us(e, "codec")?.mimeType);
4792
+ class Es {
4774
4793
  // eslint-disable-next-line @typescript-eslint/class-methods-use-this
4775
4794
  async getCodecFromSender(e) {
4776
- return await gs(e) ?? "";
4795
+ return await Ts(e) ?? "";
4777
4796
  }
4778
4797
  }
4779
- class Ts {
4780
- stackPromises = Ee({
4798
+ class Ss {
4799
+ stackPromises = Te({
4781
4800
  noRunIsNotActual: !0
4782
4801
  });
4783
4802
  /**
@@ -4801,30 +4820,30 @@ class Ts {
4801
4820
  });
4802
4821
  }
4803
4822
  }
4804
- class Es {
4823
+ class Cs {
4805
4824
  taskQueue;
4806
4825
  onSetParameters;
4807
4826
  constructor(e) {
4808
- this.onSetParameters = e, this.taskQueue = new Ts();
4827
+ this.onSetParameters = e, this.taskQueue = new Ss();
4809
4828
  }
4810
4829
  async setEncodingsToSender(e, t) {
4811
- return this.taskQueue.add(async () => fe(e, t, this.onSetParameters));
4830
+ return this.taskQueue.add(async () => ve(e, t, this.onSetParameters));
4812
4831
  }
4813
4832
  stop() {
4814
4833
  this.taskQueue.stop();
4815
4834
  }
4816
4835
  }
4817
- const $e = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), Ss = 1e6, b = (n) => n * Ss, Ge = b(0.06), Ve = b(4), Cs = (n) => n <= 64 ? Ge : n <= 128 ? b(0.12) : n <= 256 ? b(0.25) : n <= 384 ? b(0.32) : n <= 426 ? b(0.38) : n <= 640 ? b(0.5) : n <= 848 ? b(0.7) : n <= 1280 ? b(1) : n <= 1920 ? b(2) : Ve, ps = "av1", ms = (n) => $e(n, ps), Ns = 0.6, ne = (n, e) => ms(e) ? n * Ns : n, As = (n) => ne(Ge, n), Rs = (n) => ne(Ve, n), ge = (n, e) => {
4818
- const t = Cs(n);
4836
+ const ke = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), ps = 1e6, b = (n) => n * ps, $e = b(0.06), Ge = b(4), ms = (n) => n <= 64 ? $e : n <= 128 ? b(0.12) : n <= 256 ? b(0.25) : n <= 384 ? b(0.32) : n <= 426 ? b(0.38) : n <= 640 ? b(0.5) : n <= 848 ? b(0.7) : n <= 1280 ? b(1) : n <= 1920 ? b(2) : Ge, Ns = "av1", As = (n) => ke(n, Ns), Rs = 0.6, ne = (n, e) => As(e) ? n * Rs : n, Is = (n) => ne($e, n), vs = (n) => ne(Ge, n), le = (n, e) => {
4837
+ const t = ms(n);
4819
4838
  return ne(t, e);
4820
- }, z = 1, Is = ({
4839
+ }, z = 1, fs = ({
4821
4840
  videoTrack: n,
4822
4841
  targetSize: e
4823
4842
  }) => {
4824
4843
  const t = n.getSettings(), s = t.width, i = t.height, r = s === void 0 ? z : s / e.width, a = i === void 0 ? z : i / e.height;
4825
4844
  return Math.max(r, a, z);
4826
4845
  };
4827
- class vs {
4846
+ class Ms {
4828
4847
  ignoreForCodec;
4829
4848
  senderFinder;
4830
4849
  codecProvider;
@@ -4857,7 +4876,7 @@ class vs {
4857
4876
  if (!i?.track)
4858
4877
  return { ...this.resultNoChanged, sender: i };
4859
4878
  const r = await this.codecProvider.getCodecFromSender(i);
4860
- if ($e(r, this.ignoreForCodec))
4879
+ if (ke(r, this.ignoreForCodec))
4861
4880
  return { ...this.resultNoChanged, sender: i };
4862
4881
  const { mainCam: a, resolutionMainCam: o } = t ?? {};
4863
4882
  return this.processSender(
@@ -4899,7 +4918,7 @@ class vs {
4899
4918
  async downgradeResolutionSender(e) {
4900
4919
  const { sender: t, codec: s } = e, i = {
4901
4920
  scaleResolutionDownBy: 200,
4902
- maxBitrate: As(s)
4921
+ maxBitrate: Is(s)
4903
4922
  };
4904
4923
  return this.parametersSetter.setEncodingsToSender(t, i);
4905
4924
  }
@@ -4909,7 +4928,7 @@ class vs {
4909
4928
  * @returns Promise с результатом
4910
4929
  */
4911
4930
  async setBitrateByTrackResolution(e) {
4912
- const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ? Rs(i) : ge(a, i);
4931
+ const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ? vs(i) : le(a, i);
4913
4932
  return this.parametersSetter.setEncodingsToSender(t, {
4914
4933
  scaleResolutionDownBy: 1,
4915
4934
  maxBitrate: o
@@ -4925,24 +4944,24 @@ class vs {
4925
4944
  const [s, i] = e.split("x"), { sender: r, videoTrack: a, codec: o } = t, c = {
4926
4945
  width: Number(s),
4927
4946
  height: Number(i)
4928
- }, l = Is({
4947
+ }, l = fs({
4929
4948
  videoTrack: a,
4930
4949
  targetSize: c
4931
- }), T = ge(c.width, o), u = {
4950
+ }), T = le(c.width, o), u = {
4932
4951
  scaleResolutionDownBy: l,
4933
4952
  maxBitrate: T
4934
4953
  };
4935
4954
  return this.parametersSetter.setEncodingsToSender(r, u);
4936
4955
  }
4937
4956
  }
4938
- const fs = (n) => n.find((e) => e.track?.kind === "video");
4939
- class Ms {
4957
+ const _s = (n) => n.find((e) => e.track?.kind === "video");
4958
+ class bs {
4940
4959
  // eslint-disable-next-line @typescript-eslint/class-methods-use-this
4941
4960
  findVideoSender(e) {
4942
- return fs(e);
4961
+ return _s(e);
4943
4962
  }
4944
4963
  }
4945
- class _s {
4964
+ class Os {
4946
4965
  currentSender;
4947
4966
  originalReplaceTrack;
4948
4967
  lastWidth;
@@ -4955,7 +4974,7 @@ class _s {
4955
4974
  pollIntervalMs: e = 1e3,
4956
4975
  maxPollIntervalMs: t
4957
4976
  }) {
4958
- this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new ue();
4977
+ this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new ge();
4959
4978
  }
4960
4979
  /**
4961
4980
  * Проверяет актуальный video-sender и (при необходимости) перенастраивает наблюдение.
@@ -5006,7 +5025,7 @@ class _s {
5006
5025
  this.setTimeoutRequest.cancelRequest(), this.lastWidth = void 0, this.lastHeight = void 0;
5007
5026
  }
5008
5027
  }
5009
- class bs {
5028
+ class Ds {
5010
5029
  apiManager;
5011
5030
  currentHandler;
5012
5031
  constructor(e) {
@@ -5026,7 +5045,7 @@ class bs {
5026
5045
  this.currentHandler && (this.apiManager.off("main-cam-control", this.currentHandler), this.currentHandler = void 0);
5027
5046
  }
5028
5047
  }
5029
- class Os {
5048
+ class Ps {
5030
5049
  eventHandler;
5031
5050
  senderBalancer;
5032
5051
  parametersSetterWithQueue;
@@ -5038,16 +5057,16 @@ class Os {
5038
5057
  onSetParameters: i,
5039
5058
  pollIntervalMs: r
5040
5059
  } = {}) {
5041
- this.getConnection = t, this.eventHandler = new bs(e), this.parametersSetterWithQueue = new Es(i), this.senderBalancer = new vs(
5060
+ this.getConnection = t, this.eventHandler = new Ds(e), this.parametersSetterWithQueue = new Cs(i), this.senderBalancer = new Ms(
5042
5061
  {
5043
- senderFinder: new Ms(),
5044
- codecProvider: new us(),
5062
+ senderFinder: new bs(),
5063
+ codecProvider: new Es(),
5045
5064
  parametersSetter: this.parametersSetterWithQueue
5046
5065
  },
5047
5066
  {
5048
5067
  ignoreForCodec: s
5049
5068
  }
5050
- ), this.trackMonitor = new _s({ pollIntervalMs: r });
5069
+ ), this.trackMonitor = new Os({ pollIntervalMs: r });
5051
5070
  }
5052
5071
  /**
5053
5072
  * Подписывается на события управления главной камерой
@@ -5092,13 +5111,13 @@ class Os {
5092
5111
  });
5093
5112
  };
5094
5113
  }
5095
- const qe = [
5114
+ const Ve = [
5096
5115
  "balancing-scheduled",
5097
5116
  "balancing-started",
5098
5117
  "balancing-stopped",
5099
5118
  "parameters-updated"
5100
- ], Ds = () => new R(qe);
5101
- class Ps {
5119
+ ], ys = () => new R(Ve);
5120
+ class Ls {
5102
5121
  isBalancingActive = !1;
5103
5122
  events;
5104
5123
  callManager;
@@ -5106,7 +5125,7 @@ class Ps {
5106
5125
  videoSendingBalancer;
5107
5126
  startBalancingTimer;
5108
5127
  constructor(e, t, s = {}) {
5109
- this.events = Ds(), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new Os(
5128
+ this.events = ys(), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new Ps(
5110
5129
  t,
5111
5130
  () => e.connection,
5112
5131
  {
@@ -5176,13 +5195,13 @@ class Ps {
5176
5195
  this.startBalancingTimer && (clearTimeout(this.startBalancingTimer), this.startBalancingTimer = void 0);
5177
5196
  }
5178
5197
  }
5179
- const He = "no-inbound-frames", We = [He], ys = () => new R(We);
5180
- class Ls {
5198
+ const qe = "no-inbound-frames", He = [qe], ws = () => new R(He);
5199
+ class Us {
5181
5200
  events;
5182
5201
  statsManager;
5183
5202
  callManager;
5184
5203
  constructor(e, t) {
5185
- this.statsManager = e, this.callManager = t, this.events = ys(), this.subscribe();
5204
+ this.statsManager = e, this.callManager = t, this.events = ws(), this.subscribe();
5186
5205
  }
5187
5206
  get mainVideoTrack() {
5188
5207
  return this.callManager.getMainRemoteStream()?.getVideoTracks()[0];
@@ -5195,20 +5214,20 @@ class Ls {
5195
5214
  return this.events.on(e, t);
5196
5215
  }
5197
5216
  handleStatsCollected = () => {
5198
- this.hasNoIncomingFrames() && this.events.trigger(He, {});
5217
+ this.hasNoIncomingFrames() && this.events.trigger(qe, {});
5199
5218
  };
5200
5219
  hasNoIncomingFrames = () => this.statsManager.isInvalidInboundFrames && this.isMutedMainVideoTrack;
5201
5220
  subscribe() {
5202
5221
  this.statsManager.on("collected", this.handleStatsCollected);
5203
5222
  }
5204
5223
  }
5205
- const ws = 3e3;
5206
- class Us {
5224
+ const Fs = 3e3;
5225
+ class Bs {
5207
5226
  renegotiateRequester;
5208
5227
  renegotiateThrottled;
5209
5228
  callManager;
5210
- constructor(e, t = ws) {
5211
- this.callManager = e, this.renegotiateRequester = new Y(e.renegotiate.bind(e)), this.renegotiateThrottled = et.throttle(
5229
+ constructor(e, t = Fs) {
5230
+ this.callManager = e, this.renegotiateRequester = new Y(e.renegotiate.bind(e)), this.renegotiateThrottled = Ze.throttle(
5212
5231
  this.requestRenegotiate.bind(this),
5213
5232
  t
5214
5233
  ), this.subscribe();
@@ -5236,13 +5255,11 @@ class Us {
5236
5255
  d("cancel recover main stream"), this.renegotiateThrottled.cancel(), this.renegotiateRequester.cancelRequest();
5237
5256
  }
5238
5257
  }
5239
- const Fs = 1e6, Bs = ye.map((n) => `auto-connect:${n}`), ks = be.map((n) => `connection:${n}`), $s = Ne.map((n) => `call:${n}`), Gs = Le.map((n) => `conference-state:${n}`), Vs = pe.map((n) => `api:${n}`), qs = we.map((n) => `incoming-call:${n}`), Hs = Me.map((n) => `presentation:${n}`), Ws = Be.map((n) => `stats:${n}`), xs = qe.map((n) => `video-balancer:${n}`), Qs = We.map((n) => `main-stream-health:${n}`), Ys = Fe.map((n) => `session:${n}`), Xs = [
5258
+ const ks = 1e6, $s = Pe.map((n) => `auto-connect:${n}`), Gs = _e.map((n) => `connection:${n}`), Vs = me.map((n) => `call:${n}`), qs = ye.map((n) => `conference-state:${n}`), Hs = Ce.map((n) => `api:${n}`), Ws = Le.map((n) => `incoming-call:${n}`), xs = fe.map((n) => `presentation:${n}`), Qs = Fe.map((n) => `stats:${n}`), Ys = Ve.map((n) => `video-balancer:${n}`), Xs = He.map((n) => `main-stream-health:${n}`), Js = Ue.map((n) => `session:${n}`), zs = [
5240
5259
  "disconnected-from-out-of-call",
5241
5260
  "connected-with-configuration-from-out-of-call",
5242
5261
  "stopped-presentation-by-server-command"
5243
- ], Js = [
5244
- ...Bs,
5245
- ...ks,
5262
+ ], js = [
5246
5263
  ...$s,
5247
5264
  ...Gs,
5248
5265
  ...Vs,
@@ -5252,9 +5269,11 @@ const Fs = 1e6, Bs = ye.map((n) => `auto-connect:${n}`), ks = be.map((n) => `con
5252
5269
  ...xs,
5253
5270
  ...Qs,
5254
5271
  ...Ys,
5255
- ...Xs
5256
- ], zs = () => new R(Js);
5257
- class hi {
5272
+ ...Xs,
5273
+ ...Js,
5274
+ ...zs
5275
+ ], Ks = () => new R(js);
5276
+ class gi {
5258
5277
  events;
5259
5278
  connectionManager;
5260
5279
  connectionQueueManager;
@@ -5278,26 +5297,26 @@ class hi {
5278
5297
  videoBalancerOptions: i,
5279
5298
  autoConnectorOptions: r
5280
5299
  } = {}) {
5281
- this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = zs(), this.apiManager = new dt(), this.connectionManager = new un({ JsSIP: e }), this.connectionQueueManager = new Tn({
5300
+ this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = Ks(), this.apiManager = new ct(), this.connectionManager = new En({ JsSIP: e }), this.connectionQueueManager = new Sn({
5282
5301
  connectionManager: this.connectionManager
5283
- }), this.conferenceStateManager = new Dn(), this.contentedStreamManager = new Un(), this.callManager = new bt(this.conferenceStateManager, this.contentedStreamManager), this.incomingCallManager = new qn(this.connectionManager), this.presentationManager = new Yt({
5302
+ }), this.conferenceStateManager = new yn(), this.contentedStreamManager = new Bn(), this.callManager = new Dt(this.conferenceStateManager, this.contentedStreamManager), this.incomingCallManager = new Wn(this.connectionManager), this.presentationManager = new Jt({
5284
5303
  callManager: this.callManager,
5285
- maxBitrate: Fs
5286
- }), this.statsManager = new is({
5304
+ maxBitrate: ks
5305
+ }), this.statsManager = new as({
5287
5306
  callManager: this.callManager,
5288
5307
  apiManager: this.apiManager
5289
- }), this.autoConnectorManager = new bn(
5308
+ }), this.autoConnectorManager = new Dn(
5290
5309
  {
5291
5310
  connectionQueueManager: this.connectionQueueManager,
5292
5311
  connectionManager: this.connectionManager,
5293
5312
  callManager: this.callManager
5294
5313
  },
5295
5314
  r
5296
- ), this.videoSendingBalancerManager = new Ps(
5315
+ ), this.videoSendingBalancerManager = new Ls(
5297
5316
  this.callManager,
5298
5317
  this.apiManager,
5299
5318
  i
5300
- ), this.mainStreamHealthMonitor = new Ls(this.statsManager, this.callManager), this.mainStreamRecovery = new Us(this.callManager), this.sessionManager = new xn({
5319
+ ), this.mainStreamHealthMonitor = new Us(this.statsManager, this.callManager), this.mainStreamRecovery = new Bs(this.callManager), this.sessionManager = new Yn({
5301
5320
  connectionManager: this.connectionManager,
5302
5321
  callManager: this.callManager,
5303
5322
  incomingCallManager: this.incomingCallManager,
@@ -5504,7 +5523,7 @@ class hi {
5504
5523
  if (i === void 0)
5505
5524
  throw new Error("No sipServerUrl for sendOffer");
5506
5525
  const r = this.conferenceStateManager.getToken();
5507
- return Xn({
5526
+ return zn({
5508
5527
  serverUrl: i,
5509
5528
  offer: t,
5510
5529
  token: r,
@@ -5514,7 +5533,7 @@ class hi {
5514
5533
  });
5515
5534
  };
5516
5535
  setCodecPreferences(e) {
5517
- ds(e, {
5536
+ ls(e, {
5518
5537
  preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
5519
5538
  excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
5520
5539
  });
@@ -5539,24 +5558,24 @@ class hi {
5539
5558
  };
5540
5559
  }
5541
5560
  export {
5542
- Ae as E,
5543
- ut as O,
5544
- hi as S,
5545
- nn as a,
5546
- ht as b,
5547
- Bn as c,
5548
- fe as d,
5549
- $t as e,
5550
- Ce as f,
5551
- ci as g,
5552
- hn as h,
5553
- oi as i,
5554
- di as j,
5561
+ Ne as E,
5562
+ gt as O,
5563
+ gi as S,
5564
+ rn as a,
5565
+ dt as b,
5566
+ $n as c,
5567
+ ve as d,
5568
+ Vt as e,
5569
+ Se as f,
5570
+ hi as g,
5571
+ gn as h,
5572
+ di as i,
5573
+ li as j,
5555
5574
  p as k,
5556
5575
  d as l,
5557
- ns as m,
5558
- gs as n,
5559
- Ht as o,
5576
+ is as m,
5577
+ Ts as n,
5578
+ xt as o,
5560
5579
  H as p,
5561
- Xn as s
5580
+ zn as s
5562
5581
  };