sip-connector 20.1.2 → 20.2.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.
Files changed (54) hide show
  1. package/README.md +1 -1
  2. package/dist/@SipConnector-BTqBRDjY.cjs +1 -0
  3. package/dist/{@SipConnector-DoH2gbll.js → @SipConnector-OO78fz6E.js} +493 -372
  4. package/dist/ApiManager/@ApiManager.d.ts +1 -1
  5. package/dist/ApiManager/{eventNames.d.ts → events.d.ts} +1 -0
  6. package/dist/ApiManager/index.d.ts +2 -1
  7. package/dist/AutoConnectorManager/@AutoConnectorManager.d.ts +1 -1
  8. package/dist/AutoConnectorManager/{eventNames.d.ts → events.d.ts} +1 -0
  9. package/dist/AutoConnectorManager/index.d.ts +1 -0
  10. package/dist/CallManager/@CallManager.d.ts +4 -2
  11. package/dist/CallManager/MCUSession.d.ts +2 -1
  12. package/dist/CallManager/RemoteStreamsManager.d.ts +1 -0
  13. package/dist/CallManager/{eventNames.d.ts → events.d.ts} +2 -1
  14. package/dist/CallManager/index.d.ts +2 -3
  15. package/dist/CallManager/types.d.ts +2 -1
  16. package/dist/ConnectionManager/@ConnectionManager.d.ts +1 -1
  17. package/dist/ConnectionManager/ConnectionFlow.d.ts +1 -1
  18. package/dist/ConnectionManager/ConnectionStateMachine.d.ts +8 -8
  19. package/dist/ConnectionManager/RegistrationManager.d.ts +1 -1
  20. package/dist/ConnectionManager/{eventNames.d.ts → events.d.ts} +2 -1
  21. package/dist/ConnectionManager/index.d.ts +3 -3
  22. package/dist/IncomingCallManager/@IncomingCallManager.d.ts +1 -1
  23. package/dist/IncomingCallManager/{eventNames.d.ts → events.d.ts} +2 -1
  24. package/dist/IncomingCallManager/index.d.ts +2 -1
  25. package/dist/MainStreamHealthMonitor/@MainStreamHealthMonitor.d.ts +16 -0
  26. package/dist/MainStreamHealthMonitor/events.d.ts +8 -0
  27. package/dist/MainStreamHealthMonitor/index.d.ts +1 -0
  28. package/dist/MainStreamRecovery/@MainStreamRecovery.d.ts +12 -0
  29. package/dist/MainStreamRecovery/index.d.ts +1 -0
  30. package/dist/PresentationManager/@PresentationManager.d.ts +1 -1
  31. package/dist/PresentationManager/{eventNames.d.ts → events.d.ts} +1 -0
  32. package/dist/PresentationManager/index.d.ts +1 -0
  33. package/dist/SipConnector/@SipConnector.d.ts +5 -2
  34. package/dist/SipConnector/{eventNames.d.ts → events.d.ts} +11 -9
  35. package/dist/SipConnector/index.d.ts +1 -1
  36. package/dist/StatsManager/@StatsManager.d.ts +14 -3
  37. package/dist/StatsManager/events.d.ts +2 -0
  38. package/dist/StatsManager/index.d.ts +1 -1
  39. package/dist/StatsPeerConnection/@StatsPeerConnection.d.ts +1 -1
  40. package/dist/StatsPeerConnection/{eventNames.d.ts → events.d.ts} +1 -0
  41. package/dist/StatsPeerConnection/index.d.ts +4 -3
  42. package/dist/StatsPeerConnection/types.d.ts +2 -0
  43. package/dist/VideoSendingBalancerManager/@VideoSendingBalancerManager.d.ts +1 -1
  44. package/dist/VideoSendingBalancerManager/{eventNames.d.ts → events.d.ts} +1 -0
  45. package/dist/VideoSendingBalancerManager/index.d.ts +2 -2
  46. package/dist/__fixtures__/RTCSessionMock.d.ts +1 -0
  47. package/dist/doMock.cjs +1 -1
  48. package/dist/doMock.js +10 -9
  49. package/dist/index.cjs +1 -1
  50. package/dist/index.js +2 -2
  51. package/dist/tools/index.d.ts +1 -1
  52. package/package.json +12 -9
  53. package/dist/@SipConnector-DCCDA9jO.cjs +0 -1
  54. package/dist/StatsManager/eventNames.d.ts +0 -2
@@ -1,18 +1,19 @@
1
- import { TypedEvents as O } from "events-constructor";
2
- import G from "debug";
3
- import { CancelableRequest as x, isCanceledError as Oe } from "@krivega/cancelable-promise";
4
- import { resolveRequesterByTimeout as be, requesterByTimeoutsWithFailCalls as ye, DelayRequester as De, hasCanceledError as we, SetTimeoutRequest as se } from "@krivega/timeout-requester";
5
- import { hasCanceledError as Ue, repeatedCallsAsync as ie } from "repeated-calls";
6
- import { setup as Le, createActor as Be } from "xstate";
7
- import { createStackPromises as re, isPromiseIsNotActualError as Fe } from "stack-promises";
1
+ import x from "debug";
2
+ import { TypedEvents as M } from "events-constructor";
3
+ import { CancelableRequest as k, isCanceledError as be } from "@krivega/cancelable-promise";
4
+ import { resolveRequesterByTimeout as ye, requesterByTimeoutsWithFailCalls as De, DelayRequester as we, hasCanceledError as Ue, SetTimeoutRequest as se } from "@krivega/timeout-requester";
5
+ import { hasCanceledError as Le, repeatedCallsAsync as ie } from "repeated-calls";
6
+ import { setup as Fe, createActor as Be } from "xstate";
7
+ import { createStackPromises as re, isPromiseIsNotActualError as ke } from "stack-promises";
8
8
  import "ua-parser-js";
9
9
  import "sequent-promises";
10
- const Q = "sip-connector", h = G(Q), jn = () => {
11
- G.enable(Q);
12
- }, Zn = () => {
13
- G.enable(`-${Q}`);
14
- }, ke = "Error decline with 603", $e = 1006, qe = (n) => typeof n == "object" && n !== null && "code" in n && n.code === $e, We = (n) => n.message === ke;
15
- var u = /* @__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.CONTENT_SHARE_STATE = "x-webrtc-share-state", n.MUST_STOP_PRESENTATION_P2P = "x-webrtc-share-state: YOUMUSTSTOPSENDCONTENT", n.START_PRESENTATION_P2P = "x-webrtc-share-state: YOUCANRECEIVECONTENT", n.STOP_PRESENTATION_P2P = "x-webrtc-share-state: CONTENTEND", n.STOP_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", n.START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", n.ENABLE_MAIN_CAM = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE: LETMESTARTMAINCAM", 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))(u || {}), B = /* @__PURE__ */ ((n) => (n.AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(B || {}), W = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(W || {}), b = /* @__PURE__ */ ((n) => (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.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n))(b || {}), m = /* @__PURE__ */ ((n) => (n.CHANNELS = "application/vinteo.webrtc.channels", n.MEDIA_STATE = "application/vinteo.webrtc.mediastate", n.REFUSAL = "application/vinteo.webrtc.refusal", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.STATS = "application/vinteo.webrtc.stats", n))(m || {}), 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 || {}), H = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(H || {}), V = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(V || {}), He = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(He || {}), l = /* @__PURE__ */ ((n) => (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.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "conference:participant-token-issued", n.CHANNELS = "channels", n.ENTER_ROOM = "enterRoom", n.SHARE_STATE = "shareState", n.MAIN_CAM_CONTROL = "main-cam-control", n.USE_LICENSE = "useLicense", 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.AVAILABLE_SECOND_REMOTE_STREAM = "availableSecondRemoteStream", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "notAvailableSecondRemoteStream", n.MUST_STOP_PRESENTATION = "mustStopPresentation", n.NEW_DTMF = "newDTMF", n))(l || {});
10
+ import $e from "lodash";
11
+ const Q = "sip-connector", h = x(Q), Cs = () => {
12
+ x.enable(Q);
13
+ }, Es = () => {
14
+ x.enable(`-${Q}`);
15
+ }, qe = "Error decline with 603", Ve = 1006, He = (n) => typeof n == "object" && n !== null && "code" in n && n.code === Ve, We = (n) => n.message === qe;
16
+ var u = /* @__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.CONTENT_SHARE_STATE = "x-webrtc-share-state", n.MUST_STOP_PRESENTATION_P2P = "x-webrtc-share-state: YOUMUSTSTOPSENDCONTENT", n.START_PRESENTATION_P2P = "x-webrtc-share-state: YOUCANRECEIVECONTENT", n.STOP_PRESENTATION_P2P = "x-webrtc-share-state: CONTENTEND", n.STOP_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", n.START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", n.ENABLE_MAIN_CAM = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE: LETMESTARTMAINCAM", 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))(u || {}), F = /* @__PURE__ */ ((n) => (n.AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(F || {}), H = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(H || {}), b = /* @__PURE__ */ ((n) => (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.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n))(b || {}), N = /* @__PURE__ */ ((n) => (n.CHANNELS = "application/vinteo.webrtc.channels", n.MEDIA_STATE = "application/vinteo.webrtc.mediastate", n.REFUSAL = "application/vinteo.webrtc.refusal", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.STATS = "application/vinteo.webrtc.stats", n))(N || {}), _ = /* @__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))(_ || {}), W = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(W || {}), G = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(G || {}), Ge = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(Ge || {}), l = /* @__PURE__ */ ((n) => (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.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "conference:participant-token-issued", n.CHANNELS = "channels", n.ENTER_ROOM = "enterRoom", n.SHARE_STATE = "shareState", n.MAIN_CAM_CONTROL = "main-cam-control", n.USE_LICENSE = "useLicense", 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.AVAILABLE_SECOND_REMOTE_STREAM = "availableSecondRemoteStream", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "notAvailableSecondRemoteStream", n.MUST_STOP_PRESENTATION = "mustStopPresentation", n.NEW_DTMF = "newDTMF", n))(l || {});
16
17
  const ae = [
17
18
  "participation:accepting-word-request",
18
19
  "participation:cancelling-word-request",
@@ -43,9 +44,9 @@ const ae = [
43
44
  "notAvailableSecondRemoteStream",
44
45
  "mustStopPresentation",
45
46
  "newDTMF"
46
- ];
47
- var N = /* @__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))(N || {});
48
- class Ve {
47
+ ], xe = () => new M(ae);
48
+ var m = /* @__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))(m || {});
49
+ class Qe {
49
50
  events;
50
51
  connectionManager;
51
52
  callManager;
@@ -53,7 +54,7 @@ class Ve {
53
54
  connectionManager: e,
54
55
  callManager: t
55
56
  }) {
56
- this.connectionManager = e, this.callManager = t, this.events = new O(ae), this.subscribe();
57
+ this.connectionManager = e, this.callManager = t, this.events = xe(), this.subscribe();
57
58
  }
58
59
  async waitChannels() {
59
60
  return this.wait(l.CHANNELS);
@@ -82,7 +83,7 @@ class Ve {
82
83
  i,
83
84
  r
84
85
  ];
85
- return s.sendInfo(m.CHANNELS, void 0, { extraHeaders: a });
86
+ return s.sendInfo(N.CHANNELS, void 0, { extraHeaders: a });
86
87
  }
87
88
  async sendMediaState({ cam: e, mic: t }, s = {}) {
88
89
  const i = this.getEstablishedRTCSessionProtected(), r = `${u.MEDIA_STATE}: currentstate`, a = `${u.MAIN_CAM_STATE}: ${Number(e)}`, o = `${u.MIC_STATE}: ${Number(t)}`, c = [
@@ -90,7 +91,7 @@ class Ve {
90
91
  a,
91
92
  o
92
93
  ];
93
- return i.sendInfo(m.MEDIA_STATE, void 0, {
94
+ return i.sendInfo(N.MEDIA_STATE, void 0, {
94
95
  noTerminateWhenError: !0,
95
96
  ...s,
96
97
  extraHeaders: c
@@ -100,14 +101,14 @@ class Ve {
100
101
  availableIncomingBitrate: e
101
102
  }) {
102
103
  const t = this.getEstablishedRTCSessionProtected(), i = [`${u.AVAILABLE_INCOMING_BITRATE}: ${e}`];
103
- return t.sendInfo(m.STATS, void 0, {
104
+ return t.sendInfo(N.STATS, void 0, {
104
105
  noTerminateWhenError: !0,
105
106
  extraHeaders: i
106
107
  });
107
108
  }
108
109
  async sendRefusalToTurnOn(e, t = {}) {
109
110
  const s = this.getEstablishedRTCSessionProtected(), a = e === "mic" ? 0 : 1, c = [`${u.MEDIA_TYPE}: ${a}`];
110
- return s.sendInfo(m.REFUSAL, void 0, {
111
+ return s.sendInfo(N.REFUSAL, void 0, {
111
112
  noTerminateWhenError: !0,
112
113
  ...t,
113
114
  extraHeaders: c
@@ -120,33 +121,33 @@ class Ve {
120
121
  return this.sendRefusalToTurnOn("cam", { noTerminateWhenError: !0, ...e });
121
122
  }
122
123
  async sendMustStopPresentationP2P() {
123
- await this.getEstablishedRTCSessionProtected().sendInfo(m.SHARE_STATE, void 0, {
124
+ await this.getEstablishedRTCSessionProtected().sendInfo(N.SHARE_STATE, void 0, {
124
125
  extraHeaders: [u.MUST_STOP_PRESENTATION_P2P]
125
126
  });
126
127
  }
127
128
  async sendStoppedPresentationP2P() {
128
- await this.getEstablishedRTCSessionProtected().sendInfo(m.SHARE_STATE, void 0, {
129
+ await this.getEstablishedRTCSessionProtected().sendInfo(N.SHARE_STATE, void 0, {
129
130
  extraHeaders: [u.STOP_PRESENTATION_P2P]
130
131
  });
131
132
  }
132
133
  async sendStoppedPresentation() {
133
- await this.getEstablishedRTCSessionProtected().sendInfo(m.SHARE_STATE, void 0, {
134
+ await this.getEstablishedRTCSessionProtected().sendInfo(N.SHARE_STATE, void 0, {
134
135
  extraHeaders: [u.STOP_PRESENTATION]
135
136
  });
136
137
  }
137
138
  async askPermissionToStartPresentationP2P() {
138
- await this.getEstablishedRTCSessionProtected().sendInfo(m.SHARE_STATE, void 0, {
139
+ await this.getEstablishedRTCSessionProtected().sendInfo(N.SHARE_STATE, void 0, {
139
140
  extraHeaders: [u.START_PRESENTATION_P2P]
140
141
  });
141
142
  }
142
143
  async askPermissionToStartPresentation() {
143
- await this.getEstablishedRTCSessionProtected().sendInfo(m.SHARE_STATE, void 0, {
144
+ await this.getEstablishedRTCSessionProtected().sendInfo(N.SHARE_STATE, void 0, {
144
145
  extraHeaders: [u.START_PRESENTATION]
145
146
  });
146
147
  }
147
148
  async askPermissionToEnableCam(e = {}) {
148
149
  const t = this.getEstablishedRTCSessionProtected(), s = [u.ENABLE_MAIN_CAM];
149
- return t.sendInfo(m.MAIN_CAM, void 0, {
150
+ return t.sendInfo(N.MAIN_CAM, void 0, {
150
151
  noTerminateWhenError: !0,
151
152
  ...e,
152
153
  extraHeaders: s
@@ -197,55 +198,55 @@ class Ve {
197
198
  };
198
199
  handleNotify = (e) => {
199
200
  switch (e.cmd) {
200
- case N.CHANNELS: {
201
+ case m.CHANNELS: {
201
202
  const t = e;
202
203
  this.triggerChannelsNotify(t);
203
204
  break;
204
205
  }
205
- case N.WEBCAST_STARTED: {
206
+ case m.WEBCAST_STARTED: {
206
207
  const t = e;
207
208
  this.triggerWebcastStartedNotify(t);
208
209
  break;
209
210
  }
210
- case N.WEBCAST_STOPPED: {
211
+ case m.WEBCAST_STOPPED: {
211
212
  const t = e;
212
213
  this.triggerWebcastStoppedNotify(t);
213
214
  break;
214
215
  }
215
- case N.ADDED_TO_LIST_MODERATORS: {
216
+ case m.ADDED_TO_LIST_MODERATORS: {
216
217
  const t = e;
217
218
  this.triggerAddedToListModeratorsNotify(t);
218
219
  break;
219
220
  }
220
- case N.REMOVED_FROM_LIST_MODERATORS: {
221
+ case m.REMOVED_FROM_LIST_MODERATORS: {
221
222
  const t = e;
222
223
  this.triggerRemovedFromListModeratorsNotify(t);
223
224
  break;
224
225
  }
225
- case N.ACCEPTING_WORD_REQUEST: {
226
+ case m.ACCEPTING_WORD_REQUEST: {
226
227
  const t = e;
227
228
  this.triggerParticipationAcceptingWordRequest(t);
228
229
  break;
229
230
  }
230
- case N.CANCELLING_WORD_REQUEST: {
231
+ case m.CANCELLING_WORD_REQUEST: {
231
232
  const t = e;
232
233
  this.triggerParticipationCancellingWordRequest(t);
233
234
  break;
234
235
  }
235
- case N.MOVE_REQUEST_TO_STREAM: {
236
+ case m.MOVE_REQUEST_TO_STREAM: {
236
237
  const t = e;
237
238
  this.triggerParticipantMoveRequestToStream(t);
238
239
  break;
239
240
  }
240
- case N.ACCOUNT_CHANGED: {
241
+ case m.ACCOUNT_CHANGED: {
241
242
  this.triggerAccountChangedNotify();
242
243
  break;
243
244
  }
244
- case N.ACCOUNT_DELETED: {
245
+ case m.ACCOUNT_DELETED: {
245
246
  this.triggerAccountDeletedNotify();
246
247
  break;
247
248
  }
248
- case N.CONFERENCE_PARTICIPANT_TOKEN_ISSUED: {
249
+ case m.CONFERENCE_PARTICIPANT_TOKEN_ISSUED: {
249
250
  const t = e;
250
251
  this.triggerConferenceParticipantTokenIssued(t);
251
252
  break;
@@ -399,15 +400,15 @@ class Ve {
399
400
  const t = e.getHeader(u.CONTENT_SHARE_STATE);
400
401
  if (t !== void 0)
401
402
  switch (t) {
402
- case B.AVAILABLE_SECOND_REMOTE_STREAM: {
403
+ case F.AVAILABLE_SECOND_REMOTE_STREAM: {
403
404
  this.events.trigger(l.AVAILABLE_SECOND_REMOTE_STREAM, {});
404
405
  break;
405
406
  }
406
- case B.NOT_AVAILABLE_SECOND_REMOTE_STREAM: {
407
+ case F.NOT_AVAILABLE_SECOND_REMOTE_STREAM: {
407
408
  this.events.trigger(l.NOT_AVAILABLE_SECOND_REMOTE_STREAM, {});
408
409
  break;
409
410
  }
410
- case B.MUST_STOP_PRESENTATION: {
411
+ case F.MUST_STOP_PRESENTATION: {
411
412
  this.events.trigger(l.MUST_STOP_PRESENTATION, {});
412
413
  break;
413
414
  }
@@ -415,24 +416,24 @@ class Ve {
415
416
  };
416
417
  maybeTriggerParticipantMoveRequest = (e) => {
417
418
  const t = e.getHeader(u.CONTENT_PARTICIPANT_STATE), s = e.getHeader(u.AUDIO_ID);
418
- t === W.SPECTATOR && (s ? (this.events.trigger(l.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_WITH_AUDIO_ID, {
419
+ t === H.SPECTATOR && (s ? (this.events.trigger(l.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_WITH_AUDIO_ID, {
419
420
  audioId: s
420
421
  }), this.events.trigger(l.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, {
421
422
  isSynthetic: !1,
422
423
  audioId: s
423
- })) : (this.events.trigger(l.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_SYNTHETIC, {}), this.events.trigger(l.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, { isSynthetic: !0 }))), t === W.PARTICIPANT && this.events.trigger(l.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS, {});
424
+ })) : (this.events.trigger(l.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_SYNTHETIC, {}), this.events.trigger(l.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, { isSynthetic: !0 }))), t === H.PARTICIPANT && this.events.trigger(l.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS, {});
424
425
  };
425
426
  triggerMainCamControl = (e) => {
426
- const t = e.getHeader(u.MAIN_CAM), s = e.getHeader(u.MEDIA_SYNC), i = s === V.ADMIN_SYNC_FORCED;
427
- if (t === f.ADMIN_START_MAIN_CAM) {
427
+ const t = e.getHeader(u.MAIN_CAM), s = e.getHeader(u.MEDIA_SYNC), i = s === G.ADMIN_SYNC_FORCED;
428
+ if (t === _.ADMIN_START_MAIN_CAM) {
428
429
  this.events.trigger(l.ADMIN_START_MAIN_CAM, { isSyncForced: i });
429
430
  return;
430
431
  }
431
- if (t === f.ADMIN_STOP_MAIN_CAM) {
432
+ if (t === _.ADMIN_STOP_MAIN_CAM) {
432
433
  this.events.trigger(l.ADMIN_STOP_MAIN_CAM, { isSyncForced: i });
433
434
  return;
434
435
  }
435
- (t === f.RESUME_MAIN_CAM || t === f.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(l.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: i });
436
+ (t === _.RESUME_MAIN_CAM || t === _.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(l.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: i });
436
437
  const r = e.getHeader(u.MAIN_CAM_RESOLUTION);
437
438
  this.events.trigger(l.MAIN_CAM_CONTROL, {
438
439
  mainCam: t,
@@ -440,15 +441,15 @@ class Ve {
440
441
  });
441
442
  };
442
443
  triggerMicControl = (e) => {
443
- const t = e.getHeader(u.MIC), i = e.getHeader(u.MEDIA_SYNC) === V.ADMIN_SYNC_FORCED;
444
- t === H.ADMIN_START_MIC ? this.events.trigger(l.ADMIN_START_MIC, { isSyncForced: i }) : t === H.ADMIN_STOP_MIC && this.events.trigger(l.ADMIN_STOP_MIC, { isSyncForced: i });
444
+ const t = e.getHeader(u.MIC), i = e.getHeader(u.MEDIA_SYNC) === G.ADMIN_SYNC_FORCED;
445
+ t === W.ADMIN_START_MIC ? this.events.trigger(l.ADMIN_START_MIC, { isSyncForced: i }) : t === W.ADMIN_STOP_MIC && this.events.trigger(l.ADMIN_STOP_MIC, { isSyncForced: i });
445
446
  };
446
447
  triggerUseLicense = (e) => {
447
448
  const t = e.getHeader(u.CONTENT_USE_LICENSE);
448
449
  this.events.trigger(l.USE_LICENSE, t);
449
450
  };
450
451
  }
451
- var R = /* @__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_STREAMS_CHANGED = "remote-streams-changed", n))(R || {}), Ge = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))(Ge || {});
452
+ var R = /* @__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_STREAMS_CHANGED = "remote-streams-changed", n))(R || {}), Ye = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))(Ye || {});
452
453
  const oe = [
453
454
  "peerconnection",
454
455
  "connecting",
@@ -476,7 +477,7 @@ const oe = [
476
477
  "peerconnection:createanswerfailed",
477
478
  "peerconnection:setlocaldescriptionfailed",
478
479
  "peerconnection:setremotedescriptionfailed"
479
- ], xe = [
480
+ ], ze = [
480
481
  "peerconnection:confirmed",
481
482
  "peerconnection:ontrack",
482
483
  "ended:fromserver",
@@ -484,12 +485,12 @@ const oe = [
484
485
  "remote-streams-changed"
485
486
  ], ce = [
486
487
  ...oe,
487
- ...xe
488
- ], Qe = (n, e) => {
488
+ ...ze
489
+ ], Xe = () => new M(ce), Je = (n, e) => {
489
490
  n.getVideoTracks().forEach((s) => {
490
491
  "contentHint" in s && s.contentHint !== e && (s.contentHint = e);
491
492
  });
492
- }, F = (n, {
493
+ }, B = (n, {
493
494
  directionVideo: e,
494
495
  directionAudio: t,
495
496
  contentHint: s
@@ -497,10 +498,10 @@ const oe = [
497
498
  if (!n || e === "recvonly" && t === "recvonly")
498
499
  return;
499
500
  const i = t === "recvonly" ? [] : n.getAudioTracks(), r = e === "recvonly" ? [] : n.getVideoTracks(), a = [...i, ...r], o = new MediaStream(a);
500
- return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && Qe(o, s), o;
501
+ return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && Je(o, s), o;
501
502
  };
502
503
  var he = /* @__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))(he || {});
503
- class Ye {
504
+ class Ke {
504
505
  events;
505
506
  rtcSession;
506
507
  disposers = /* @__PURE__ */ new Set();
@@ -515,6 +516,11 @@ class Ye {
515
516
  return this.rtcSession?.isEstablished() === !0;
516
517
  }
517
518
  getEstablishedRTCSession = () => this.rtcSession?.isEstablished() === !0 ? this.rtcSession : void 0;
519
+ async renegotiate() {
520
+ if (this.rtcSession === void 0)
521
+ throw new Error("No rtcSession established");
522
+ return this.rtcSession.renegotiate();
523
+ }
518
524
  startCall = async (e, t, {
519
525
  number: s,
520
526
  mediaStream: i,
@@ -527,12 +533,12 @@ class Ye {
527
533
  offerToReceiveVideo: g = !0,
528
534
  degradationPreference: T,
529
535
  sendEncodings: p,
530
- onAddedTransceiver: v
536
+ onAddedTransceiver: P
531
537
  }) => new Promise((A, y) => {
532
- this.handleCall().then(A).catch((k) => {
533
- y(k);
538
+ this.handleCall().then(A).catch(($) => {
539
+ y($);
534
540
  }), this.rtcSession = e.call(t(s), {
535
- mediaStream: F(i, {
541
+ mediaStream: B(i, {
536
542
  directionVideo: o,
537
543
  directionAudio: c,
538
544
  contentHint: d
@@ -553,7 +559,7 @@ class Ye {
553
559
  directionAudio: c,
554
560
  degradationPreference: T,
555
561
  sendEncodings: p,
556
- onAddedTransceiver: v
562
+ onAddedTransceiver: P
557
563
  });
558
564
  });
559
565
  async endCall() {
@@ -578,10 +584,10 @@ class Ye {
578
584
  degradationPreference: S,
579
585
  sendEncodings: g,
580
586
  onAddedTransceiver: T
581
- }) => new Promise((p, v) => {
587
+ }) => new Promise((p, P) => {
582
588
  try {
583
589
  this.rtcSession = e, this.subscribeToSessionEvents(e), this.handleCall().then(p).catch((A) => {
584
- v(A);
590
+ P(A);
585
591
  }), e.answer({
586
592
  pcConfig: {
587
593
  iceServers: i
@@ -590,7 +596,7 @@ class Ye {
590
596
  offerToReceiveAudio: o,
591
597
  offerToReceiveVideo: c
592
598
  },
593
- mediaStream: F(t, {
599
+ mediaStream: B(t, {
594
600
  directionVideo: r,
595
601
  directionAudio: a,
596
602
  contentHint: d
@@ -603,13 +609,13 @@ class Ye {
603
609
  onAddedTransceiver: T
604
610
  });
605
611
  } catch (A) {
606
- v(A);
612
+ P(A);
607
613
  }
608
614
  });
609
615
  async replaceMediaStream(e, t) {
610
616
  if (!this.rtcSession)
611
617
  throw new Error("No rtcSession established");
612
- const { contentHint: s } = t ?? {}, i = F(e, { contentHint: s });
618
+ const { contentHint: s } = t ?? {}, i = B(e, { contentHint: s });
613
619
  if (i === void 0)
614
620
  throw new Error("No preparedMediaStream");
615
621
  return this.rtcSession.replaceMediaStream(i, t);
@@ -666,7 +672,7 @@ class Ye {
666
672
  delete this.rtcSession, this.unsubscribeFromSessionEvents(), this.onReset();
667
673
  };
668
674
  }
669
- class ze {
675
+ class je {
670
676
  config;
671
677
  tools;
672
678
  connection;
@@ -715,13 +721,13 @@ class ze {
715
721
  return this.connection.addTransceiver(e, t);
716
722
  }
717
723
  }
718
- const de = (n) => n.getSettings(), Xe = (n, e) => {
724
+ const de = (n) => n.getSettings(), Ze = (n, e) => {
719
725
  const t = de(n);
720
726
  let s = e;
721
727
  s ??= n.label;
722
728
  let i = t?.msid;
723
729
  return i ??= s, i ??= n.id, i;
724
- }, Je = (n, e) => {
730
+ }, et = (n, e) => {
725
731
  const t = de(n);
726
732
  let s = e;
727
733
  return s ??= t?.msid, s ??= n.label, (s && s.length > 0 ? s : void 0) ?? n.id;
@@ -730,6 +736,10 @@ class X {
730
736
  participantGroups = /* @__PURE__ */ new Map();
731
737
  trackToGroup = /* @__PURE__ */ new Map();
732
738
  trackDisposers = /* @__PURE__ */ new Map();
739
+ get mainStream() {
740
+ const e = this.getStreams(), [t] = e;
741
+ return t;
742
+ }
733
743
  reset() {
734
744
  this.participantGroups.clear(), this.trackToGroup.clear(), this.trackDisposers.forEach((e) => {
735
745
  e();
@@ -739,7 +749,7 @@ class X {
739
749
  onRemoved: t,
740
750
  streamHint: s
741
751
  } = {}) {
742
- const i = Je(e, s), r = Xe(e, s);
752
+ const i = et(e, s), r = Ze(e, s);
743
753
  if (this.trackToGroup.has(e.id))
744
754
  return { isAdded: !1 };
745
755
  const a = this.getParticipantGroups(i);
@@ -799,16 +809,16 @@ class X {
799
809
  return this.participantGroups.set(e, s), s;
800
810
  }
801
811
  }
802
- const $ = {
812
+ const q = {
803
813
  type: "participant"
804
- }, Ke = {
814
+ }, tt = {
805
815
  type: "spectator_synthetic"
806
- }, je = (n) => ({
816
+ }, nt = (n) => ({
807
817
  type: "spectator",
808
818
  recvParams: n
809
819
  });
810
- class M {
811
- role = $;
820
+ class f {
821
+ role = q;
812
822
  mainManager;
813
823
  recvManager;
814
824
  onRoleChanged;
@@ -831,13 +841,13 @@ class M {
831
841
  return this.role;
832
842
  }
833
843
  setCallRoleParticipant() {
834
- this.changeRole($);
844
+ this.changeRole(q);
835
845
  }
836
846
  setCallRoleSpectatorSynthetic() {
837
- this.changeRole(Ke);
847
+ this.changeRole(tt);
838
848
  }
839
849
  setCallRoleSpectator(e) {
840
- this.changeRole(je(e));
850
+ this.changeRole(nt(e));
841
851
  }
842
852
  changeRole(e) {
843
853
  const t = this.role;
@@ -845,22 +855,22 @@ class M {
845
855
  this.setRole(e);
846
856
  return;
847
857
  }
848
- M.hasSpectator(e) && M.hasSpectator(t) && t.recvParams.audioId !== e.recvParams.audioId && this.setRole(e);
858
+ f.hasSpectator(e) && f.hasSpectator(t) && t.recvParams.audioId !== e.recvParams.audioId && this.setRole(e);
849
859
  }
850
860
  reset() {
851
- this.role = $, this.recvManager.reset();
861
+ this.role = q, this.recvManager.reset();
852
862
  }
853
863
  getActiveManager() {
854
864
  return this.hasSpectator() ? this.recvManager : this.mainManager;
855
865
  }
856
866
  hasParticipant() {
857
- return M.hasParticipant(this.role);
867
+ return f.hasParticipant(this.role);
858
868
  }
859
869
  hasSpectatorSynthetic() {
860
- return M.hasSpectatorSynthetic(this.role);
870
+ return f.hasSpectatorSynthetic(this.role);
861
871
  }
862
872
  hasSpectator() {
863
- return M.hasSpectator(this.role);
873
+ return f.hasSpectator(this.role);
864
874
  }
865
875
  setRole(e) {
866
876
  const t = this.role;
@@ -868,7 +878,7 @@ class M {
868
878
  }
869
879
  }
870
880
  const J = (n) => n.streams[0]?.id;
871
- class Ze {
881
+ class st {
872
882
  events;
873
883
  isPendingCall = !1;
874
884
  isPendingAnswer = !1;
@@ -876,7 +886,7 @@ class Ze {
876
886
  callConfiguration = {};
877
887
  mainRemoteStreamsManager = new X();
878
888
  recvRemoteStreamsManager = new X();
879
- roleManager = new M(
889
+ roleManager = new f(
880
890
  { mainManager: this.mainRemoteStreamsManager, recvManager: this.recvRemoteStreamsManager },
881
891
  (e) => {
882
892
  this.onRoleChanged(e);
@@ -886,7 +896,7 @@ class Ze {
886
896
  recvSession;
887
897
  disposeRecvSessionTrackListener;
888
898
  constructor() {
889
- this.events = new O(ce), this.mcuSession = new Ye(this.events, { onReset: this.reset }), this.subscribeCallStatusChange(), this.subscribeMcuRemoteTrackEvents();
899
+ this.events = Xe(), this.mcuSession = new Ke(this.events, { onReset: this.reset }), this.subscribeCallStatusChange(), this.subscribeMcuRemoteTrackEvents();
890
900
  }
891
901
  get requested() {
892
902
  return this.isPendingCall || this.isPendingAnswer;
@@ -922,6 +932,9 @@ class Ze {
922
932
  async endCall() {
923
933
  return this.mcuSession.endCall();
924
934
  }
935
+ async renegotiate() {
936
+ return this.mcuSession.renegotiate();
937
+ }
925
938
  answerToIncomingCall = async (e, t) => {
926
939
  this.isPendingAnswer = !0;
927
940
  const s = e();
@@ -932,6 +945,9 @@ class Ze {
932
945
  getCallConfiguration() {
933
946
  return { ...this.callConfiguration };
934
947
  }
948
+ getMainStream() {
949
+ return this.getActiveStreamsManager().mainStream;
950
+ }
935
951
  getRemoteStreams() {
936
952
  return this.getActiveStreamsManager().getStreams();
937
953
  }
@@ -1015,7 +1031,7 @@ class Ze {
1015
1031
  const i = {
1016
1032
  quality: "high",
1017
1033
  audioChannel: e
1018
- }, r = new ze(i, { sendOffer: t });
1034
+ }, r = new je(i, { sendOffer: t });
1019
1035
  this.recvSession = r, this.recvRemoteStreamsManager.reset(), this.attachRecvSessionTracks(r), r.call(s).catch(() => {
1020
1036
  this.stopRecvSession();
1021
1037
  });
@@ -1027,45 +1043,45 @@ class Ze {
1027
1043
  previous: e,
1028
1044
  next: t
1029
1045
  }) => {
1030
- if (M.hasSpectator(e) && !M.hasSpectator(t) && this.stopRecvSession(), M.hasSpectator(t)) {
1046
+ if (f.hasSpectator(e) && !f.hasSpectator(t) && this.stopRecvSession(), f.hasSpectator(t)) {
1031
1047
  const s = t.recvParams;
1032
1048
  this.startRecvSession(s.audioId, s.sendOffer);
1033
1049
  }
1034
1050
  };
1035
1051
  }
1036
- const et = (n, e) => (n.degradationPreference = e.degradationPreference, n), tt = (n, e) => {
1052
+ const it = (n, e) => (n.degradationPreference = e.degradationPreference, n), rt = (n, e) => {
1037
1053
  n.encodings ??= [];
1038
1054
  for (let t = n.encodings.length; t < e; t += 1)
1039
1055
  n.encodings.push({});
1040
1056
  return n;
1041
- }, le = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, nt = le(), st = (n, e) => {
1042
- if (nt(n, e))
1057
+ }, le = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, at = le(), ot = (n, e) => {
1058
+ if (at(n, e))
1043
1059
  return n;
1044
- }, it = (n, e) => {
1045
- const t = n.maxBitrate, s = st(e, t);
1060
+ }, ct = (n, e) => {
1061
+ const t = n.maxBitrate, s = ot(e, t);
1046
1062
  return s !== void 0 && (n.maxBitrate = s), n;
1047
- }, ue = 1, rt = le(
1063
+ }, ue = 1, ht = le(
1048
1064
  ue
1049
- ), at = (n, e) => {
1065
+ ), dt = (n, e) => {
1050
1066
  const t = n === void 0 ? void 0 : Math.max(n, ue);
1051
- if (t !== void 0 && rt(
1067
+ if (t !== void 0 && ht(
1052
1068
  t,
1053
1069
  e
1054
1070
  ))
1055
1071
  return t;
1056
- }, ot = (n, e) => {
1057
- const t = n.scaleResolutionDownBy, s = at(
1072
+ }, lt = (n, e) => {
1073
+ const t = n.scaleResolutionDownBy, s = dt(
1058
1074
  e,
1059
1075
  t
1060
1076
  );
1061
1077
  return s !== void 0 && (n.scaleResolutionDownBy = s), n;
1062
- }, ct = (n, e) => {
1078
+ }, ut = (n, e) => {
1063
1079
  const t = e.encodings?.length ?? 0;
1064
- return tt(n, t), n.encodings.forEach((s, i) => {
1080
+ return rt(n, t), n.encodings.forEach((s, i) => {
1065
1081
  const r = (e?.encodings ?? [])[i], a = r?.maxBitrate, o = r?.scaleResolutionDownBy;
1066
- it(s, a), ot(s, o);
1082
+ ct(s, a), lt(s, o);
1067
1083
  }), n;
1068
- }, ht = (n, e) => {
1084
+ }, gt = (n, e) => {
1069
1085
  if (n.codecs?.length !== e.codecs?.length)
1070
1086
  return !0;
1071
1087
  for (let t = 0; t < (n.codecs?.length ?? 0); t++)
@@ -1082,15 +1098,15 @@ const et = (n, e) => (n.degradationPreference = e.degradationPreference, n), tt
1082
1098
  if (JSON.stringify(n.encodings[t]) !== JSON.stringify(e.encodings[t]))
1083
1099
  return !0;
1084
1100
  return n.rtcp?.cname !== e.rtcp?.cname || n.rtcp?.reducedSize !== e.rtcp?.reducedSize || n.degradationPreference !== e.degradationPreference;
1085
- }, dt = async (n, e) => {
1101
+ }, Tt = async (n, e) => {
1086
1102
  const t = n.getParameters(), s = JSON.parse(
1087
1103
  JSON.stringify(t)
1088
1104
  );
1089
- ct(t, e), et(t, e);
1090
- const i = ht(s, t);
1105
+ ut(t, e), it(t, e);
1106
+ const i = gt(s, t);
1091
1107
  return i && await n.setParameters(t), { parameters: t, isChanged: i };
1092
1108
  }, ge = async (n, e, t) => {
1093
- const { isChanged: s, parameters: i } = await dt(n, {
1109
+ const { isChanged: s, parameters: i } = await Tt(n, {
1094
1110
  encodings: [
1095
1111
  {
1096
1112
  scaleResolutionDownBy: e.scaleResolutionDownBy,
@@ -1099,20 +1115,20 @@ const et = (n, e) => (n.degradationPreference = e.degradationPreference, n), tt
1099
1115
  ]
1100
1116
  });
1101
1117
  return s && t && t(i), { isChanged: s, parameters: i };
1102
- }, lt = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), ut = async (n, e, t) => {
1103
- const s = lt(n, e);
1118
+ }, St = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), Ct = async (n, e, t) => {
1119
+ const s = St(n, e);
1104
1120
  if (s)
1105
1121
  return ge(s, { maxBitrate: t });
1106
1122
  };
1107
- 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 || {});
1123
+ var O = /* @__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))(O || {});
1108
1124
  const Te = [
1109
1125
  "presentation:start",
1110
1126
  "presentation:started",
1111
1127
  "presentation:end",
1112
1128
  "presentation:ended",
1113
1129
  "presentation:failed"
1114
- ], gt = 1, es = (n) => Ue(n);
1115
- class Tt {
1130
+ ], Et = () => new M(Te), pt = 1, ps = (n) => Le(n);
1131
+ class Rt {
1116
1132
  events;
1117
1133
  promisePendingStartPresentation;
1118
1134
  promisePendingStopPresentation;
@@ -1124,7 +1140,7 @@ class Tt {
1124
1140
  callManager: e,
1125
1141
  maxBitrate: t
1126
1142
  }) {
1127
- this.callManager = e, this.maxBitrate = t, this.events = new O(Te), this.subscribe();
1143
+ this.callManager = e, this.maxBitrate = t, this.events = Et(), this.subscribe();
1128
1144
  }
1129
1145
  get isPendingPresentation() {
1130
1146
  return !!this.promisePendingStartPresentation || !!this.promisePendingStopPresentation;
@@ -1160,8 +1176,8 @@ class Tt {
1160
1176
  const i = this.callManager.getEstablishedRTCSession();
1161
1177
  return i && t ? s = e().then(async () => i.stopPresentation(t)).catch((r) => {
1162
1178
  const a = r instanceof Error ? r : new Error(String(r));
1163
- throw this.events.trigger(P.FAILED_PRESENTATION, a), r;
1164
- }) : t && this.events.trigger(P.ENDED_PRESENTATION, t), this.promisePendingStopPresentation = s, s.finally(() => {
1179
+ throw this.events.trigger(O.FAILED_PRESENTATION, a), r;
1180
+ }) : t && this.events.trigger(O.ENDED_PRESENTATION, t), this.promisePendingStopPresentation = s, s.finally(() => {
1165
1181
  this.resetPresentation();
1166
1182
  });
1167
1183
  }
@@ -1200,15 +1216,15 @@ class Tt {
1200
1216
  }
1201
1217
  subscribe() {
1202
1218
  this.callManager.on("presentation:start", (e) => {
1203
- this.events.trigger(P.START_PRESENTATION, e);
1219
+ this.events.trigger(O.START_PRESENTATION, e);
1204
1220
  }), this.callManager.on("presentation:started", (e) => {
1205
- this.events.trigger(P.STARTED_PRESENTATION, e);
1221
+ this.events.trigger(O.STARTED_PRESENTATION, e);
1206
1222
  }), this.callManager.on("presentation:end", (e) => {
1207
- this.events.trigger(P.END_PRESENTATION, e);
1223
+ this.events.trigger(O.END_PRESENTATION, e);
1208
1224
  }), this.callManager.on("presentation:ended", (e) => {
1209
- this.events.trigger(P.ENDED_PRESENTATION, e);
1225
+ this.events.trigger(O.ENDED_PRESENTATION, e);
1210
1226
  }), this.callManager.on("presentation:failed", (e) => {
1211
- this.events.trigger(P.FAILED_PRESENTATION, e);
1227
+ this.events.trigger(O.FAILED_PRESENTATION, e);
1212
1228
  }), this.callManager.on("failed", this.handleEnded), this.callManager.on("ended", this.handleEnded);
1213
1229
  }
1214
1230
  async sendPresentationWithDuplicatedCalls(e, {
@@ -1216,7 +1232,7 @@ class Tt {
1216
1232
  stream: s,
1217
1233
  presentationOptions: i,
1218
1234
  options: r = {
1219
- callLimit: gt
1235
+ callLimit: pt
1220
1236
  }
1221
1237
  }) {
1222
1238
  const a = async () => this.sendPresentation(
@@ -1240,7 +1256,7 @@ class Tt {
1240
1256
  sendEncodings: o,
1241
1257
  onAddedTransceiver: c
1242
1258
  }) {
1243
- const d = F(s, { contentHint: r });
1259
+ const d = B(s, { contentHint: r });
1244
1260
  if (d === void 0)
1245
1261
  throw new Error("No streamPresentationTarget");
1246
1262
  this.streamPresentationCurrent = d;
@@ -1251,7 +1267,7 @@ class Tt {
1251
1267
  })).then(this.setMaxBitrate).then(() => s).catch((g) => {
1252
1268
  this.removeStreamPresentationCurrent();
1253
1269
  const T = g instanceof Error ? g : new Error(String(g));
1254
- throw this.events.trigger(P.FAILED_PRESENTATION, T), g;
1270
+ throw this.events.trigger(O.FAILED_PRESENTATION, T), g;
1255
1271
  });
1256
1272
  return this.promisePendingStartPresentation = S, S.finally(() => {
1257
1273
  this.promisePendingStartPresentation = void 0;
@@ -1262,7 +1278,7 @@ class Tt {
1262
1278
  if (!e || !t || s === void 0)
1263
1279
  return;
1264
1280
  const i = e.getSenders();
1265
- await ut(i, t, s);
1281
+ await Ct(i, t, s);
1266
1282
  };
1267
1283
  getRtcSessionProtected = () => {
1268
1284
  const e = this.callManager.getEstablishedRTCSession();
@@ -1283,7 +1299,7 @@ class Tt {
1283
1299
  delete this.streamPresentationCurrent;
1284
1300
  }
1285
1301
  }
1286
- class St {
1302
+ class At {
1287
1303
  data;
1288
1304
  getUa;
1289
1305
  constructor(e) {
@@ -1380,7 +1396,7 @@ const Se = [
1380
1396
  "registrationFailed",
1381
1397
  "newMessage",
1382
1398
  "sipEvent"
1383
- ], Ct = [
1399
+ ], mt = [
1384
1400
  "disconnecting",
1385
1401
  "connect-started",
1386
1402
  "connect-succeeded",
@@ -1388,12 +1404,12 @@ const Se = [
1388
1404
  "connect-parameters-resolve-success",
1389
1405
  "connect-parameters-resolve-failed",
1390
1406
  "connected-with-configuration"
1391
- ], Ce = [...Se, ...Ct];
1392
- function Et(n) {
1407
+ ], Ce = [...Se, ...mt], Nt = () => new M(Ce);
1408
+ function It(n) {
1393
1409
  return (e) => `sip:${e}@${n}`;
1394
1410
  }
1395
- const pt = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, Ee = (n) => n.trim().replaceAll(" ", "_"), Rt = pt(1e5, 99999999), At = 3;
1396
- class Nt {
1411
+ const vt = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, Ee = (n) => n.trim().replaceAll(" ", "_"), _t = vt(1e5, 99999999), ft = 3;
1412
+ class Mt {
1397
1413
  cancelableConnectWithRepeatedCalls;
1398
1414
  JsSIP;
1399
1415
  events;
@@ -1437,9 +1453,9 @@ class Nt {
1437
1453
  cancelRequests() {
1438
1454
  this.cancelConnectWithRepeatedCalls();
1439
1455
  }
1440
- connectWithDuplicatedCalls = async (e, { callLimit: t = At } = {}) => {
1456
+ connectWithDuplicatedCalls = async (e, { callLimit: t = ft } = {}) => {
1441
1457
  const s = async () => this.connectInner(e), i = (r) => {
1442
- const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), d = r != null && !qe(r);
1458
+ const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), d = r != null && !He(r);
1443
1459
  return c || d;
1444
1460
  };
1445
1461
  return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = ie({
@@ -1548,7 +1564,7 @@ class Nt {
1548
1564
  }
1549
1565
  }
1550
1566
  var pe = /* @__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))(pe || {});
1551
- const mt = Le({
1567
+ const Pt = Object.values(pe), Ot = Fe({
1552
1568
  types: {
1553
1569
  context: {},
1554
1570
  events: {}
@@ -1563,25 +1579,25 @@ const mt = Le({
1563
1579
  }
1564
1580
  }).createMachine({
1565
1581
  id: "connection",
1566
- initial: "idle",
1582
+ initial: "connection:idle",
1567
1583
  context: {},
1568
1584
  states: {
1569
- idle: {
1585
+ "connection:idle": {
1570
1586
  entry: {
1571
1587
  type: "logStateChange",
1572
1588
  params: {
1573
- state: "idle"
1589
+ state: "connection:idle"
1574
1590
  /* IDLE */
1575
1591
  }
1576
1592
  },
1577
1593
  on: {
1578
1594
  START_CONNECT: {
1579
- target: "connecting",
1595
+ target: "connection:connecting",
1580
1596
  actions: {
1581
1597
  type: "logTransition",
1582
1598
  params: {
1583
- from: "idle",
1584
- to: "connecting",
1599
+ from: "connection:idle",
1600
+ to: "connection:connecting",
1585
1601
  event: "START_CONNECT"
1586
1602
  /* START_CONNECT */
1587
1603
  }
@@ -1589,22 +1605,22 @@ const mt = Le({
1589
1605
  }
1590
1606
  }
1591
1607
  },
1592
- connecting: {
1608
+ "connection:connecting": {
1593
1609
  entry: {
1594
1610
  type: "logStateChange",
1595
1611
  params: {
1596
- state: "connecting"
1612
+ state: "connection:connecting"
1597
1613
  /* CONNECTING */
1598
1614
  }
1599
1615
  },
1600
1616
  on: {
1601
1617
  START_INIT_UA: {
1602
- target: "initializing",
1618
+ target: "connection:initializing",
1603
1619
  actions: {
1604
1620
  type: "logTransition",
1605
1621
  params: {
1606
- from: "connecting",
1607
- to: "initializing",
1622
+ from: "connection:connecting",
1623
+ to: "connection:initializing",
1608
1624
  event: "START_INIT_UA"
1609
1625
  /* START_INIT_UA */
1610
1626
  // TODO: remove
@@ -1612,24 +1628,24 @@ const mt = Le({
1612
1628
  }
1613
1629
  },
1614
1630
  UA_DISCONNECTED: {
1615
- target: "disconnected",
1631
+ target: "connection:disconnected",
1616
1632
  actions: {
1617
1633
  type: "logTransition",
1618
1634
  params: {
1619
- from: "connecting",
1620
- to: "disconnected",
1635
+ from: "connection:connecting",
1636
+ to: "connection:disconnected",
1621
1637
  event: "UA_DISCONNECTED"
1622
1638
  /* UA_DISCONNECTED */
1623
1639
  }
1624
1640
  }
1625
1641
  },
1626
1642
  CONNECTION_FAILED: {
1627
- target: "failed",
1643
+ target: "connection:failed",
1628
1644
  actions: {
1629
1645
  type: "logTransition",
1630
1646
  params: {
1631
- from: "connecting",
1632
- to: "failed",
1647
+ from: "connection:connecting",
1648
+ to: "connection:failed",
1633
1649
  event: "CONNECTION_FAILED"
1634
1650
  /* CONNECTION_FAILED */
1635
1651
  }
@@ -1637,58 +1653,58 @@ const mt = Le({
1637
1653
  }
1638
1654
  }
1639
1655
  },
1640
- initializing: {
1656
+ "connection:initializing": {
1641
1657
  entry: {
1642
1658
  type: "logStateChange",
1643
1659
  params: {
1644
- state: "initializing"
1660
+ state: "connection:initializing"
1645
1661
  /* INITIALIZING */
1646
1662
  }
1647
1663
  },
1648
1664
  on: {
1649
1665
  UA_CONNECTED: {
1650
- target: "connected",
1666
+ target: "connection:connected",
1651
1667
  actions: {
1652
1668
  type: "logTransition",
1653
1669
  params: {
1654
- from: "initializing",
1655
- to: "connected",
1670
+ from: "connection:initializing",
1671
+ to: "connection:connected",
1656
1672
  event: "UA_CONNECTED"
1657
1673
  /* UA_CONNECTED */
1658
1674
  }
1659
1675
  }
1660
1676
  },
1661
1677
  UA_REGISTERED: {
1662
- target: "registered",
1678
+ target: "connection:registered",
1663
1679
  actions: {
1664
1680
  type: "logTransition",
1665
1681
  params: {
1666
- from: "initializing",
1667
- to: "registered",
1682
+ from: "connection:initializing",
1683
+ to: "connection:registered",
1668
1684
  event: "UA_REGISTERED"
1669
1685
  /* UA_REGISTERED */
1670
1686
  }
1671
1687
  }
1672
1688
  },
1673
1689
  UA_DISCONNECTED: {
1674
- target: "disconnected",
1690
+ target: "connection:disconnected",
1675
1691
  actions: {
1676
1692
  type: "logTransition",
1677
1693
  params: {
1678
- from: "initializing",
1679
- to: "disconnected",
1694
+ from: "connection:initializing",
1695
+ to: "connection:disconnected",
1680
1696
  event: "UA_DISCONNECTED"
1681
1697
  /* UA_DISCONNECTED */
1682
1698
  }
1683
1699
  }
1684
1700
  },
1685
1701
  CONNECTION_FAILED: {
1686
- target: "failed",
1702
+ target: "connection:failed",
1687
1703
  actions: {
1688
1704
  type: "logTransition",
1689
1705
  params: {
1690
- from: "initializing",
1691
- to: "failed",
1706
+ from: "connection:initializing",
1707
+ to: "connection:failed",
1692
1708
  event: "CONNECTION_FAILED"
1693
1709
  /* CONNECTION_FAILED */
1694
1710
  }
@@ -1696,46 +1712,46 @@ const mt = Le({
1696
1712
  }
1697
1713
  }
1698
1714
  },
1699
- connected: {
1715
+ "connection:connected": {
1700
1716
  entry: {
1701
1717
  type: "logStateChange",
1702
1718
  params: {
1703
- state: "connected"
1719
+ state: "connection:connected"
1704
1720
  /* CONNECTED */
1705
1721
  }
1706
1722
  },
1707
1723
  on: {
1708
1724
  UA_REGISTERED: {
1709
- target: "registered",
1725
+ target: "connection:registered",
1710
1726
  actions: {
1711
1727
  type: "logTransition",
1712
1728
  params: {
1713
- from: "connected",
1714
- to: "registered",
1729
+ from: "connection:connected",
1730
+ to: "connection:registered",
1715
1731
  event: "UA_REGISTERED"
1716
1732
  /* UA_REGISTERED */
1717
1733
  }
1718
1734
  }
1719
1735
  },
1720
1736
  UA_DISCONNECTED: {
1721
- target: "disconnected",
1737
+ target: "connection:disconnected",
1722
1738
  actions: {
1723
1739
  type: "logTransition",
1724
1740
  params: {
1725
- from: "connected",
1726
- to: "disconnected",
1741
+ from: "connection:connected",
1742
+ to: "connection:disconnected",
1727
1743
  event: "UA_DISCONNECTED"
1728
1744
  /* UA_DISCONNECTED */
1729
1745
  }
1730
1746
  }
1731
1747
  },
1732
1748
  CONNECTION_FAILED: {
1733
- target: "failed",
1749
+ target: "connection:failed",
1734
1750
  actions: {
1735
1751
  type: "logTransition",
1736
1752
  params: {
1737
- from: "connected",
1738
- to: "failed",
1753
+ from: "connection:connected",
1754
+ to: "connection:failed",
1739
1755
  event: "CONNECTION_FAILED"
1740
1756
  /* CONNECTION_FAILED */
1741
1757
  }
@@ -1743,46 +1759,46 @@ const mt = Le({
1743
1759
  }
1744
1760
  }
1745
1761
  },
1746
- registered: {
1762
+ "connection:registered": {
1747
1763
  entry: {
1748
1764
  type: "logStateChange",
1749
1765
  params: {
1750
- state: "registered"
1766
+ state: "connection:registered"
1751
1767
  /* REGISTERED */
1752
1768
  }
1753
1769
  },
1754
1770
  on: {
1755
1771
  UA_UNREGISTERED: {
1756
- target: "connected",
1772
+ target: "connection:connected",
1757
1773
  actions: {
1758
1774
  type: "logTransition",
1759
1775
  params: {
1760
- from: "registered",
1761
- to: "connected",
1776
+ from: "connection:registered",
1777
+ to: "connection:connected",
1762
1778
  event: "UA_UNREGISTERED"
1763
1779
  /* UA_UNREGISTERED */
1764
1780
  }
1765
1781
  }
1766
1782
  },
1767
1783
  UA_DISCONNECTED: {
1768
- target: "disconnected",
1784
+ target: "connection:disconnected",
1769
1785
  actions: {
1770
1786
  type: "logTransition",
1771
1787
  params: {
1772
- from: "registered",
1773
- to: "disconnected",
1788
+ from: "connection:registered",
1789
+ to: "connection:disconnected",
1774
1790
  event: "UA_DISCONNECTED"
1775
1791
  /* UA_DISCONNECTED */
1776
1792
  }
1777
1793
  }
1778
1794
  },
1779
1795
  CONNECTION_FAILED: {
1780
- target: "failed",
1796
+ target: "connection:failed",
1781
1797
  actions: {
1782
1798
  type: "logTransition",
1783
1799
  params: {
1784
- from: "registered",
1785
- to: "failed",
1800
+ from: "connection:registered",
1801
+ to: "connection:failed",
1786
1802
  event: "CONNECTION_FAILED"
1787
1803
  /* CONNECTION_FAILED */
1788
1804
  }
@@ -1790,34 +1806,34 @@ const mt = Le({
1790
1806
  }
1791
1807
  }
1792
1808
  },
1793
- disconnected: {
1809
+ "connection:disconnected": {
1794
1810
  entry: {
1795
1811
  type: "logStateChange",
1796
1812
  params: {
1797
- state: "disconnected"
1813
+ state: "connection:disconnected"
1798
1814
  /* DISCONNECTED */
1799
1815
  }
1800
1816
  },
1801
1817
  on: {
1802
1818
  RESET: {
1803
- target: "idle",
1819
+ target: "connection:idle",
1804
1820
  actions: {
1805
1821
  type: "logTransition",
1806
1822
  params: {
1807
- from: "disconnected",
1808
- to: "idle",
1823
+ from: "connection:disconnected",
1824
+ to: "connection:idle",
1809
1825
  event: "RESET"
1810
1826
  /* RESET */
1811
1827
  }
1812
1828
  }
1813
1829
  },
1814
1830
  START_CONNECT: {
1815
- target: "connecting",
1831
+ target: "connection:connecting",
1816
1832
  actions: {
1817
1833
  type: "logTransition",
1818
1834
  params: {
1819
- from: "disconnected",
1820
- to: "connecting",
1835
+ from: "connection:disconnected",
1836
+ to: "connection:connecting",
1821
1837
  event: "START_CONNECT"
1822
1838
  /* START_CONNECT */
1823
1839
  }
@@ -1825,34 +1841,34 @@ const mt = Le({
1825
1841
  }
1826
1842
  }
1827
1843
  },
1828
- failed: {
1844
+ "connection:failed": {
1829
1845
  entry: {
1830
1846
  type: "logStateChange",
1831
1847
  params: {
1832
- state: "failed"
1848
+ state: "connection:failed"
1833
1849
  /* FAILED */
1834
1850
  }
1835
1851
  },
1836
1852
  on: {
1837
1853
  RESET: {
1838
- target: "idle",
1854
+ target: "connection:idle",
1839
1855
  actions: {
1840
1856
  type: "logTransition",
1841
1857
  params: {
1842
- from: "failed",
1843
- to: "idle",
1858
+ from: "connection:failed",
1859
+ to: "connection:idle",
1844
1860
  event: "RESET"
1845
1861
  /* RESET */
1846
1862
  }
1847
1863
  }
1848
1864
  },
1849
1865
  START_CONNECT: {
1850
- target: "connecting",
1866
+ target: "connection:connecting",
1851
1867
  actions: {
1852
1868
  type: "logTransition",
1853
1869
  params: {
1854
- from: "failed",
1855
- to: "connecting",
1870
+ from: "connection:failed",
1871
+ to: "connection:connecting",
1856
1872
  event: "START_CONNECT"
1857
1873
  /* START_CONNECT */
1858
1874
  }
@@ -1862,14 +1878,14 @@ const mt = Le({
1862
1878
  }
1863
1879
  }
1864
1880
  });
1865
- class It {
1881
+ class bt {
1866
1882
  actor;
1867
1883
  stateChangeListeners = /* @__PURE__ */ new Set();
1868
1884
  events;
1869
1885
  unsubscribeFromEvents;
1870
1886
  actorSubscription;
1871
1887
  constructor(e) {
1872
- this.events = e, this.actor = Be(mt), this.actorSubscription = this.actor.subscribe((t) => {
1888
+ this.events = e, this.actor = Be(Ot), this.actorSubscription = this.actor.subscribe((t) => {
1873
1889
  const s = t.value;
1874
1890
  this.stateChangeListeners.forEach((i) => {
1875
1891
  i(s);
@@ -1881,43 +1897,43 @@ class It {
1881
1897
  }
1882
1898
  get isIdle() {
1883
1899
  return this.hasState(
1884
- "idle"
1900
+ "connection:idle"
1885
1901
  /* IDLE */
1886
1902
  );
1887
1903
  }
1888
1904
  get isConnecting() {
1889
1905
  return this.hasState(
1890
- "connecting"
1906
+ "connection:connecting"
1891
1907
  /* CONNECTING */
1892
1908
  );
1893
1909
  }
1894
1910
  get isInitializing() {
1895
1911
  return this.hasState(
1896
- "initializing"
1912
+ "connection:initializing"
1897
1913
  /* INITIALIZING */
1898
1914
  );
1899
1915
  }
1900
1916
  get isConnected() {
1901
1917
  return this.hasState(
1902
- "connected"
1918
+ "connection:connected"
1903
1919
  /* CONNECTED */
1904
1920
  );
1905
1921
  }
1906
1922
  get isRegistered() {
1907
1923
  return this.hasState(
1908
- "registered"
1924
+ "connection:registered"
1909
1925
  /* REGISTERED */
1910
1926
  );
1911
1927
  }
1912
1928
  get isDisconnected() {
1913
1929
  return this.hasState(
1914
- "disconnected"
1930
+ "connection:disconnected"
1915
1931
  /* DISCONNECTED */
1916
1932
  );
1917
1933
  }
1918
1934
  get isFailed() {
1919
1935
  return this.hasState(
1920
- "failed"
1936
+ "connection:failed"
1921
1937
  /* FAILED */
1922
1938
  );
1923
1939
  }
@@ -1955,7 +1971,7 @@ class It {
1955
1971
  return this.actor.getSnapshot().can({ type: e });
1956
1972
  }
1957
1973
  getValidEvents() {
1958
- return Object.values(pe).filter((e) => this.canTransition(e));
1974
+ return Pt.filter((e) => this.canTransition(e));
1959
1975
  }
1960
1976
  hasState(e) {
1961
1977
  return this.actor.getSnapshot().matches(e);
@@ -2024,7 +2040,7 @@ class It {
2024
2040
  };
2025
2041
  }
2026
2042
  }
2027
- class _t {
2043
+ class yt {
2028
2044
  events;
2029
2045
  getUaProtected;
2030
2046
  constructor(e) {
@@ -2061,7 +2077,7 @@ class _t {
2061
2077
  };
2062
2078
  }
2063
2079
  }
2064
- class ft {
2080
+ class Dt {
2065
2081
  uaFactory;
2066
2082
  getUaProtected;
2067
2083
  constructor(e) {
@@ -2126,7 +2142,7 @@ class ft {
2126
2142
  });
2127
2143
  }
2128
2144
  }
2129
- const Mt = (n) => {
2145
+ const wt = (n) => {
2130
2146
  const e = [];
2131
2147
  return n !== void 0 && n !== "" && e.push(`X-Vinteo-Remote: ${n}`), e;
2132
2148
  };
@@ -2155,10 +2171,10 @@ class D {
2155
2171
  throw new Error("user is required for authorized connection");
2156
2172
  }
2157
2173
  static resolveAuthorizationUser(e, t) {
2158
- return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${Rt()}`;
2174
+ return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${_t()}`;
2159
2175
  }
2160
2176
  static buildExtraHeaders(e, t) {
2161
- const s = e !== void 0 && e !== "" ? Mt(e) : [];
2177
+ const s = e !== void 0 && e !== "" ? wt(e) : [];
2162
2178
  return t === void 0 ? s : [...s, ...t];
2163
2179
  }
2164
2180
  createConfiguration({
@@ -2182,12 +2198,12 @@ class D {
2182
2198
  sipServerIp: r,
2183
2199
  sipServerUrl: s
2184
2200
  });
2185
- const T = D.resolveAuthorizationUser(a, e), p = Et(r), v = p(T), A = new this.JsSIP.WebSocketInterface(`wss://${s}/webrtc/wss/`);
2201
+ const T = D.resolveAuthorizationUser(a, e), p = It(r), P = p(T), A = new this.JsSIP.WebSocketInterface(`wss://${s}/webrtc/wss/`);
2186
2202
  return {
2187
2203
  configuration: {
2188
2204
  password: t,
2189
2205
  register: a,
2190
- uri: v,
2206
+ uri: P,
2191
2207
  display_name: Ee(i),
2192
2208
  user_agent: g,
2193
2209
  sdpSemantics: "unified-plan",
@@ -2222,8 +2238,8 @@ class D {
2222
2238
  }), { ua: r, helpers: i };
2223
2239
  }
2224
2240
  }
2225
- const Re = "Not ready for connection", vt = (n) => n instanceof Error && n.message === Re, Pt = () => new Error(Re), Ot = async (n) => typeof n == "function" ? n() : n;
2226
- class bt {
2241
+ const Re = "Not ready for connection", Ut = (n) => n instanceof Error && n.message === Re, Lt = () => new Error(Re), Ft = async (n) => typeof n == "function" ? n() : n;
2242
+ class Bt {
2227
2243
  events;
2228
2244
  ua;
2229
2245
  socket;
@@ -2235,15 +2251,15 @@ class bt {
2235
2251
  configurationManager;
2236
2252
  JsSIP;
2237
2253
  constructor({ JsSIP: e }) {
2238
- this.JsSIP = e, this.events = new O(Ce), this.uaFactory = new D(e), this.registrationManager = new _t({
2254
+ this.JsSIP = e, this.events = Nt(), this.uaFactory = new D(e), this.registrationManager = new yt({
2239
2255
  events: this.events,
2240
2256
  getUaProtected: this.getUaProtected
2241
- }), this.stateMachine = new It(this.events), this.configurationManager = new St({
2257
+ }), this.stateMachine = new bt(this.events), this.configurationManager = new At({
2242
2258
  getUa: this.getUa
2243
- }), this.sipOperations = new ft({
2259
+ }), this.sipOperations = new Dt({
2244
2260
  uaFactory: this.uaFactory,
2245
2261
  getUaProtected: this.getUaProtected
2246
- }), this.connectionFlow = new Nt({
2262
+ }), this.connectionFlow = new Mt({
2247
2263
  JsSIP: this.JsSIP,
2248
2264
  events: this.events,
2249
2265
  uaFactory: this.uaFactory,
@@ -2345,7 +2361,7 @@ class bt {
2345
2361
  getUa = () => this.ua;
2346
2362
  connectWithProcessError = async (e, t) => {
2347
2363
  if (!(t?.hasReadyForConnection?.() ?? !0))
2348
- throw Pt();
2364
+ throw Lt();
2349
2365
  return this.processConnect(e, t).catch(async (i) => {
2350
2366
  const r = i;
2351
2367
  return this.disconnect().then(() => {
@@ -2355,7 +2371,7 @@ class bt {
2355
2371
  });
2356
2372
  });
2357
2373
  };
2358
- processConnect = async (e, t) => (this.events.trigger(C.CONNECT_STARTED, {}), Ot(e).then((s) => (this.events.trigger(C.CONNECT_PARAMETERS_RESOLVE_SUCCESS, s), s)).catch((s) => {
2374
+ processConnect = async (e, t) => (this.events.trigger(C.CONNECT_STARTED, {}), Ft(e).then((s) => (this.events.trigger(C.CONNECT_PARAMETERS_RESOLVE_SUCCESS, s), s)).catch((s) => {
2359
2375
  throw this.events.trigger(C.CONNECT_PARAMETERS_RESOLVE_FAILED, s), s;
2360
2376
  }).then(async (s) => this.connectionFlow.connect(s, t)).then((s) => (this.events.trigger(C.CONNECT_SUCCEEDED, {
2361
2377
  ...s
@@ -2364,7 +2380,7 @@ class bt {
2364
2380
  throw this.events.trigger(C.CONNECT_FAILED, i), i;
2365
2381
  }));
2366
2382
  }
2367
- class yt {
2383
+ class kt {
2368
2384
  connectionManager;
2369
2385
  stackPromises = re({
2370
2386
  noRunIsNotActual: !0
@@ -2378,11 +2394,11 @@ class yt {
2378
2394
  this.stackPromises.stop();
2379
2395
  }
2380
2396
  }
2381
- const K = 0, Dt = 30;
2382
- class wt {
2397
+ const K = 0, $t = 30;
2398
+ class qt {
2383
2399
  countInner = K;
2384
2400
  initialCount = K;
2385
- limitInner = Dt;
2401
+ limitInner = $t;
2386
2402
  isInProgress = !1;
2387
2403
  onStatusChange;
2388
2404
  constructor({
@@ -2415,7 +2431,7 @@ class wt {
2415
2431
  this.countInner = this.initialCount, this.finishAttempt();
2416
2432
  }
2417
2433
  }
2418
- class Ut {
2434
+ class Vt {
2419
2435
  connectionManager;
2420
2436
  interval;
2421
2437
  checkTelephonyByTimeout = void 0;
@@ -2431,7 +2447,7 @@ class Ut {
2431
2447
  onSuccessRequest: t,
2432
2448
  onFailRequest: s
2433
2449
  }) {
2434
- this.stop(), this.cancelableBeforeRequest = new x(e), this.checkTelephonyByTimeout = be({
2450
+ this.stop(), this.cancelableBeforeRequest = new k(e), this.checkTelephonyByTimeout = ye({
2435
2451
  isDontStopOnFail: !0,
2436
2452
  requestInterval: this.interval,
2437
2453
  request: async () => {
@@ -2460,7 +2476,7 @@ const Ae = [
2460
2476
  "changed-attempt-status",
2461
2477
  "stop-attempts-by-error",
2462
2478
  "limit-reached-attempts"
2463
- ];
2479
+ ], Ht = () => new M(Ae);
2464
2480
  class Y {
2465
2481
  callManager;
2466
2482
  disposers = [];
@@ -2486,15 +2502,15 @@ class Y {
2486
2502
  this.callManager.isCallActive ? e?.() : t();
2487
2503
  }
2488
2504
  }
2489
- const Lt = 15e3, Bt = 2;
2490
- class Ft {
2505
+ const Wt = 15e3, Gt = 2;
2506
+ class xt {
2491
2507
  connectionManager;
2492
2508
  pingServerByTimeoutWithFailCalls;
2493
2509
  constructor({ connectionManager: e }) {
2494
- this.connectionManager = e, this.pingServerByTimeoutWithFailCalls = ye(Bt, {
2510
+ this.connectionManager = e, this.pingServerByTimeoutWithFailCalls = De(Gt, {
2495
2511
  whenPossibleRequest: async () => {
2496
2512
  },
2497
- requestInterval: Lt,
2513
+ requestInterval: Wt,
2498
2514
  request: async () => (h("ping"), this.connectionManager.ping().then(() => {
2499
2515
  h("ping success");
2500
2516
  }))
@@ -2507,14 +2523,14 @@ class Ft {
2507
2523
  this.pingServerByTimeoutWithFailCalls.stop();
2508
2524
  }
2509
2525
  }
2510
- class kt {
2526
+ class Qt {
2511
2527
  pingServerRequester;
2512
2528
  notActiveCallSubscriber;
2513
2529
  constructor({
2514
2530
  connectionManager: e,
2515
2531
  callManager: t
2516
2532
  }) {
2517
- this.pingServerRequester = new Ft({
2533
+ this.pingServerRequester = new xt({
2518
2534
  connectionManager: e
2519
2535
  }), this.notActiveCallSubscriber = new Y({ callManager: t });
2520
2536
  }
@@ -2535,7 +2551,7 @@ class kt {
2535
2551
  this.notActiveCallSubscriber.unsubscribe();
2536
2552
  }
2537
2553
  }
2538
- class $t {
2554
+ class Yt {
2539
2555
  connectionManager;
2540
2556
  isRegistrationFailed = !1;
2541
2557
  disposers = [];
@@ -2571,12 +2587,12 @@ class $t {
2571
2587
  this.isRegistrationFailed = !1;
2572
2588
  }
2573
2589
  }
2574
- const qt = 3e3, Wt = 15e3, j = {
2590
+ const zt = 3e3, Xt = 15e3, j = {
2575
2591
  LIMIT_REACHED: "Limit reached",
2576
2592
  FAILED_TO_RECONNECT: "Failed to reconnect"
2577
- }, Ht = async () => {
2578
- }, Vt = (n) => !0;
2579
- class Gt {
2593
+ }, Jt = async () => {
2594
+ }, Kt = (n) => !0;
2595
+ class jt {
2580
2596
  events;
2581
2597
  connectionManager;
2582
2598
  connectionQueueManager;
@@ -2596,20 +2612,20 @@ class Gt {
2596
2612
  connectionManager: t,
2597
2613
  callManager: s
2598
2614
  }, i) {
2599
- const r = i?.onBeforeRetry ?? Ht, a = i?.canRetryOnError ?? Vt;
2600
- this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.canRetryOnError = a, this.networkInterfacesSubscriber = i?.networkInterfacesSubscriber, this.resumeFromSleepModeSubscriber = i?.resumeFromSleepModeSubscriber, this.events = new O(Ae), this.checkTelephonyRequester = new Ut({
2615
+ const r = i?.onBeforeRetry ?? Jt, a = i?.canRetryOnError ?? Kt;
2616
+ this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.canRetryOnError = a, this.networkInterfacesSubscriber = i?.networkInterfacesSubscriber, this.resumeFromSleepModeSubscriber = i?.resumeFromSleepModeSubscriber, this.events = Ht(), this.checkTelephonyRequester = new Vt({
2601
2617
  connectionManager: t,
2602
- interval: i?.checkTelephonyRequestInterval ?? Wt
2603
- }), this.pingServerIfNotActiveCallRequester = new kt({
2618
+ interval: i?.checkTelephonyRequestInterval ?? Xt
2619
+ }), this.pingServerIfNotActiveCallRequester = new Qt({
2604
2620
  connectionManager: t,
2605
2621
  callManager: s
2606
- }), this.registrationFailedOutOfCallSubscriber = new $t({
2622
+ }), this.registrationFailedOutOfCallSubscriber = new Yt({
2607
2623
  connectionManager: t,
2608
2624
  callManager: s
2609
- }), this.attemptsState = new wt({
2625
+ }), this.attemptsState = new qt({
2610
2626
  onStatusChange: this.emitStatusChange
2611
- }), this.cancelableRequestBeforeRetry = new x(r), this.delayBetweenAttempts = new De(
2612
- i?.timeoutBetweenAttempts ?? qt
2627
+ }), this.cancelableRequestBeforeRetry = new k(r), this.delayBetweenAttempts = new we(
2628
+ i?.timeoutBetweenAttempts ?? zt
2613
2629
  ), this.notActiveCallSubscriber = new Y({ callManager: s });
2614
2630
  }
2615
2631
  start(e) {
@@ -2675,7 +2691,7 @@ class Gt {
2675
2691
  }
2676
2692
  }
2677
2693
  handleConnectionError(e, t) {
2678
- if (vt(e)) {
2694
+ if (Ut(e)) {
2679
2695
  this.attemptsState.finishAttempt(), this.events.trigger(I.STOP_ATTEMPTS_BY_ERROR, e);
2680
2696
  return;
2681
2697
  }
@@ -2683,7 +2699,7 @@ class Gt {
2683
2699
  h("executeConnectionAttempt: error does not allow retry", e), this.attemptsState.finishAttempt(), this.events.trigger(I.STOP_ATTEMPTS_BY_ERROR, e);
2684
2700
  return;
2685
2701
  }
2686
- if (Fe(e)) {
2702
+ if (ke(e)) {
2687
2703
  h("executeConnectionAttempt: not actual error", e), this.attemptsState.finishAttempt(), this.events.trigger(I.CANCELLED_ATTEMPTS, e);
2688
2704
  return;
2689
2705
  }
@@ -2752,7 +2768,7 @@ class Gt {
2752
2768
  scheduleReconnect(e) {
2753
2769
  h("scheduleReconnect"), this.delayBetweenAttempts.request().then(async () => (h("scheduleReconnect: delayBetweenAttempts success"), this.cancelableRequestBeforeRetry.request())).then(async () => (h("scheduleReconnect: onBeforeRetry success"), this.attemptConnection(e))).catch((t) => {
2754
2770
  const s = t instanceof Error ? t : new Error(j.FAILED_TO_RECONNECT);
2755
- this.attemptsState.finishAttempt(), Oe(t) || we(t) ? this.events.trigger(I.CANCELLED_ATTEMPTS, s) : this.events.trigger(I.FAILED_ALL_ATTEMPTS, s), h("scheduleReconnect: error", t);
2771
+ this.attemptsState.finishAttempt(), be(t) || Ue(t) ? this.events.trigger(I.CANCELLED_ATTEMPTS, s) : this.events.trigger(I.FAILED_ALL_ATTEMPTS, s), h("scheduleReconnect: error", t);
2756
2772
  });
2757
2773
  }
2758
2774
  isConnectionUnavailable() {
@@ -2764,18 +2780,18 @@ class Gt {
2764
2780
  };
2765
2781
  }
2766
2782
  var U = /* @__PURE__ */ ((n) => (n.INCOMING_CALL = "incomingCall", n.DECLINED_INCOMING_CALL = "declinedIncomingCall", n.TERMINATED_INCOMING_CALL = "terminatedIncomingCall", n.FAILED_INCOMING_CALL = "failedIncomingCall", n))(U || {});
2767
- const Ne = [
2783
+ const me = [
2768
2784
  "incomingCall",
2769
2785
  "declinedIncomingCall",
2770
2786
  "terminatedIncomingCall",
2771
2787
  "failedIncomingCall"
2772
- ], xt = 486, Qt = 487;
2773
- class Yt {
2788
+ ], Zt = () => new M(me), en = 486, tn = 487;
2789
+ class nn {
2774
2790
  events;
2775
2791
  incomingRTCSession;
2776
2792
  connectionManager;
2777
2793
  constructor(e) {
2778
- this.connectionManager = e, this.events = new O(Ne), this.start();
2794
+ this.connectionManager = e, this.events = Zt(), this.start();
2779
2795
  }
2780
2796
  get remoteCallerData() {
2781
2797
  return {
@@ -2805,7 +2821,7 @@ class Yt {
2805
2821
  return this.removeIncomingSession(), e;
2806
2822
  };
2807
2823
  async declineToIncomingCall({
2808
- statusCode: e = Qt
2824
+ statusCode: e = tn
2809
2825
  } = {}) {
2810
2826
  return new Promise((t, s) => {
2811
2827
  try {
@@ -2817,7 +2833,7 @@ class Yt {
2817
2833
  });
2818
2834
  }
2819
2835
  async busyIncomingCall() {
2820
- return this.declineToIncomingCall({ statusCode: xt });
2836
+ return this.declineToIncomingCall({ statusCode: en });
2821
2837
  }
2822
2838
  on(e, t) {
2823
2839
  return this.events.on(e, t);
@@ -2859,7 +2875,7 @@ class Yt {
2859
2875
  }
2860
2876
  const w = 1e3;
2861
2877
  var E = /* @__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))(E || {});
2862
- const me = ["collected"], zt = "api/v2/rtp2webrtc/offer", Xt = async ({
2878
+ const Ne = ["collected"], sn = () => new M(Ne), rn = "api/v2/rtp2webrtc/offer", an = async ({
2863
2879
  serverUrl: n,
2864
2880
  conferenceNumber: e,
2865
2881
  quality: t,
@@ -2867,7 +2883,7 @@ const me = ["collected"], zt = "api/v2/rtp2webrtc/offer", Xt = async ({
2867
2883
  offer: i
2868
2884
  }) => {
2869
2885
  const r = new URL(
2870
- `https://${n.replace(/\/$/, "")}/${zt}/${encodeURIComponent(e)}`
2886
+ `https://${n.replace(/\/$/, "")}/${rn}/${encodeURIComponent(e)}`
2871
2887
  );
2872
2888
  r.searchParams.set("quality", t), r.searchParams.set("audio", String(s));
2873
2889
  const a = await fetch(r.toString(), {
@@ -2875,7 +2891,6 @@ const me = ["collected"], zt = "api/v2/rtp2webrtc/offer", Xt = async ({
2875
2891
  headers: {
2876
2892
  "Content-Type": "application/json"
2877
2893
  },
2878
- referrerPolicy: "no-referrer",
2879
2894
  credentials: "same-origin",
2880
2895
  body: JSON.stringify(i)
2881
2896
  });
@@ -2892,7 +2907,7 @@ const me = ["collected"], zt = "api/v2/rtp2webrtc/offer", Xt = async ({
2892
2907
  }, Z = () => "performance" in window ? performance.now() : Date.now(), L = (n) => [...n.keys()].reduce((e, t) => {
2893
2908
  const s = n.get(t);
2894
2909
  return s === void 0 ? e : { ...e, [s.type]: s };
2895
- }, {}), Jt = (n) => {
2910
+ }, {}), on = (n) => {
2896
2911
  if (!n)
2897
2912
  return {
2898
2913
  outboundRtp: void 0,
@@ -2938,7 +2953,7 @@ const me = ["collected"], zt = "api/v2/rtp2webrtc/offer", Xt = async ({
2938
2953
  codec: t[E.CODEC],
2939
2954
  synchronizationSources: e
2940
2955
  };
2941
- }, Kt = ({
2956
+ }, cn = ({
2942
2957
  audioReceiverStats: n,
2943
2958
  synchronizationSourcesAudio: e
2944
2959
  }) => {
@@ -2973,18 +2988,18 @@ const me = ["collected"], zt = "api/v2/rtp2webrtc/offer", Xt = async ({
2973
2988
  remoteCandidate: e[E.REMOTE_CANDIDATE],
2974
2989
  transport: e[E.TRANSPORT]
2975
2990
  };
2976
- }, jt = ({
2991
+ }, hn = ({
2977
2992
  audioSenderStats: n,
2978
2993
  videoSenderFirstStats: e,
2979
2994
  videoSenderSecondStats: t
2980
2995
  }) => ({
2981
2996
  video: ee(e),
2982
2997
  secondVideo: ee(t),
2983
- audio: Jt(n),
2998
+ audio: on(n),
2984
2999
  additional: Ie(
2985
3000
  n ?? e ?? t
2986
3001
  )
2987
- }), Zt = ({
3002
+ }), dn = ({
2988
3003
  audioReceiverStats: n,
2989
3004
  videoReceiverFirstStats: e,
2990
3005
  videoReceiverSecondStats: t,
@@ -2998,14 +3013,14 @@ const me = ["collected"], zt = "api/v2/rtp2webrtc/offer", Xt = async ({
2998
3013
  videoReceiversStats: t,
2999
3014
  synchronizationSourcesVideo: s.video
3000
3015
  }),
3001
- audio: Kt({
3016
+ audio: cn({
3002
3017
  audioReceiverStats: n,
3003
3018
  synchronizationSourcesAudio: s.audio
3004
3019
  }),
3005
3020
  additional: Ie(
3006
3021
  n ?? e ?? t
3007
3022
  )
3008
- }), en = ({
3023
+ }), ln = ({
3009
3024
  audioSenderStats: n,
3010
3025
  videoSenderFirstStats: e,
3011
3026
  videoSenderSecondStats: t,
@@ -3014,11 +3029,11 @@ const me = ["collected"], zt = "api/v2/rtp2webrtc/offer", Xt = async ({
3014
3029
  videoReceiverSecondStats: r,
3015
3030
  synchronizationSources: a
3016
3031
  }) => {
3017
- const o = jt({
3032
+ const o = hn({
3018
3033
  audioSenderStats: n,
3019
3034
  videoSenderFirstStats: e,
3020
3035
  videoSenderSecondStats: t
3021
- }), c = Zt({
3036
+ }), c = dn({
3022
3037
  audioReceiverStats: s,
3023
3038
  videoReceiverFirstStats: i,
3024
3039
  videoReceiverSecondStats: r,
@@ -3028,7 +3043,7 @@ const me = ["collected"], zt = "api/v2/rtp2webrtc/offer", Xt = async ({
3028
3043
  outbound: o,
3029
3044
  inbound: c
3030
3045
  };
3031
- }, tn = async (n) => {
3046
+ }, un = async (n) => {
3032
3047
  const e = "audio", t = "video", s = n.getSenders(), i = s.find((T) => T.track?.kind === e), r = s.filter((T) => T.track?.kind === t), a = n.getReceivers(), o = a.find((T) => T.track.kind === e), c = a.filter((T) => T.track.kind === t), d = {
3033
3048
  trackIdentifier: o?.track.id,
3034
3049
  item: o?.getSynchronizationSources()[0]
@@ -3049,38 +3064,38 @@ const me = ["collected"], zt = "api/v2/rtp2webrtc/offer", Xt = async ({
3049
3064
  ]).then((T) => {
3050
3065
  const [
3051
3066
  p,
3052
- v,
3067
+ P,
3053
3068
  A,
3054
3069
  y,
3055
- k,
3056
- Pe
3070
+ $,
3071
+ Oe
3057
3072
  ] = T;
3058
3073
  return {
3059
3074
  synchronizationSources: g,
3060
3075
  audioSenderStats: p,
3061
- videoSenderFirstStats: v,
3076
+ videoSenderFirstStats: P,
3062
3077
  videoSenderSecondStats: A,
3063
3078
  audioReceiverStats: y,
3064
- videoReceiverFirstStats: k,
3065
- videoReceiverSecondStats: Pe
3079
+ videoReceiverFirstStats: $,
3080
+ videoReceiverSecondStats: Oe
3066
3081
  };
3067
3082
  });
3068
- }, nn = (n) => {
3083
+ }, gn = (n) => {
3069
3084
  h(String(n));
3070
3085
  };
3071
- class sn {
3086
+ class Tn {
3072
3087
  events;
3073
3088
  setTimeoutRequest;
3074
- requesterAllStatistics = new x(tn);
3089
+ requesterAllStatistics = new k(un);
3075
3090
  constructor() {
3076
- this.events = new O(me), this.setTimeoutRequest = new se();
3091
+ this.events = sn(), this.setTimeoutRequest = new se();
3077
3092
  }
3078
3093
  get requested() {
3079
3094
  return this.setTimeoutRequest.requested;
3080
3095
  }
3081
3096
  start(e, {
3082
3097
  interval: t = w,
3083
- onError: s = nn
3098
+ onError: s = gn
3084
3099
  } = {}) {
3085
3100
  this.stop(), this.setTimeoutRequest.request(() => {
3086
3101
  this.collectStatistics(e, {
@@ -3111,7 +3126,7 @@ class sn {
3111
3126
  }) => {
3112
3127
  const s = Z();
3113
3128
  this.requesterAllStatistics.request(e).then((i) => {
3114
- this.events.trigger("collected", en(i));
3129
+ this.events.trigger("collected", ln(i));
3115
3130
  const a = Z() - s;
3116
3131
  let o = w;
3117
3132
  a > 48 ? o = w * 4 : a > 32 ? o = w * 3 : a > 16 && (o = w * 2), this.start(e, {
@@ -3123,21 +3138,56 @@ class sn {
3123
3138
  });
3124
3139
  };
3125
3140
  }
3126
- class rn {
3127
- availableIncomingBitrate;
3141
+ class Sn {
3128
3142
  statsPeerConnection;
3143
+ availableStats;
3144
+ previousAvailableStats;
3129
3145
  callManager;
3130
3146
  apiManager;
3131
- previousAvailableIncomingBitrate;
3132
3147
  constructor({
3133
3148
  callManager: e,
3134
3149
  apiManager: t
3135
3150
  }) {
3136
- this.callManager = e, this.apiManager = t, this.statsPeerConnection = new sn(), this.subscribe();
3151
+ this.callManager = e, this.apiManager = t, this.statsPeerConnection = new Tn(), this.subscribe();
3137
3152
  }
3138
3153
  get events() {
3139
3154
  return this.statsPeerConnection.events;
3140
3155
  }
3156
+ get availableIncomingBitrate() {
3157
+ return this.availableStats?.inbound.additional.candidatePair?.availableIncomingBitrate;
3158
+ }
3159
+ get isNotValidFramesStats() {
3160
+ return !this.isFramesReceived || !this.isFramesDecoded;
3161
+ }
3162
+ get previousAvailableIncomingBitrate() {
3163
+ return this.previousAvailableStats?.inbound.additional.candidatePair?.availableIncomingBitrate;
3164
+ }
3165
+ get previousInboundRtp() {
3166
+ return this.previousAvailableStats?.inbound.video.inboundRtp;
3167
+ }
3168
+ get previousFramesReceived() {
3169
+ return this.previousInboundRtp?.framesReceived;
3170
+ }
3171
+ get previousFramesDecoded() {
3172
+ return this.previousInboundRtp?.framesDecoded;
3173
+ }
3174
+ get inboundRtp() {
3175
+ return this.availableStats?.inbound.video.inboundRtp;
3176
+ }
3177
+ get framesReceived() {
3178
+ return this.inboundRtp?.framesReceived;
3179
+ }
3180
+ get framesDecoded() {
3181
+ return this.inboundRtp?.framesDecoded;
3182
+ }
3183
+ get isFramesReceived() {
3184
+ const e = this.framesReceived !== void 0 && this.framesReceived > 0, t = this.framesReceived !== this.previousFramesReceived;
3185
+ return e && t;
3186
+ }
3187
+ get isFramesDecoded() {
3188
+ const e = this.framesDecoded !== void 0 && this.framesDecoded > 0, t = this.framesDecoded !== this.previousFramesDecoded;
3189
+ return e && t;
3190
+ }
3141
3191
  on(e, t) {
3142
3192
  return this.statsPeerConnection.on(e, t);
3143
3193
  }
@@ -3161,13 +3211,13 @@ class rn {
3161
3211
  this.callManager.on("peerconnection:confirmed", this.handleStarted), this.callManager.on("failed", this.handleEnded), this.callManager.on("ended", this.handleEnded), this.statsPeerConnection.on("collected", this.handleStatsCollected);
3162
3212
  }
3163
3213
  handleStatsCollected = (e) => {
3164
- this.previousAvailableIncomingBitrate = this.availableIncomingBitrate, this.availableIncomingBitrate = e.inbound.additional.candidatePair?.availableIncomingBitrate, this.maybeSendStats();
3214
+ this.previousAvailableStats = this.availableStats, this.availableStats = e, this.maybeSendStats();
3165
3215
  };
3166
3216
  handleStarted = (e) => {
3167
3217
  this.statsPeerConnection.start(e);
3168
3218
  };
3169
3219
  handleEnded = () => {
3170
- this.statsPeerConnection.stop(), this.availableIncomingBitrate = void 0, this.previousAvailableIncomingBitrate = void 0;
3220
+ this.statsPeerConnection.stop(), this.availableStats = void 0, this.previousAvailableStats = void 0;
3171
3221
  };
3172
3222
  maybeSendStats() {
3173
3223
  this.availableIncomingBitrate !== void 0 && this.hasAvailableIncomingBitrateChangedQuarter() && this.apiManager.sendStats({ availableIncomingBitrate: this.availableIncomingBitrate }).catch((e) => {
@@ -3175,32 +3225,32 @@ class rn {
3175
3225
  });
3176
3226
  }
3177
3227
  }
3178
- const an = (n, e) => n.filter((s) => e.some((i) => i.clockRate === s.clockRate && i.mimeType === s.mimeType && i.channels === s.channels && i.sdpFmtpLine === s.sdpFmtpLine)), on = (n) => {
3228
+ const Cn = (n, e) => n.filter((s) => e.some((i) => i.clockRate === s.clockRate && i.mimeType === s.mimeType && i.channels === s.channels && i.sdpFmtpLine === s.sdpFmtpLine)), En = (n) => {
3179
3229
  const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs, i = t === null ? [] : t.codecs;
3180
- return an(s, i);
3181
- }, cn = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
3230
+ return Cn(s, i);
3231
+ }, pn = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
3182
3232
  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;
3183
3233
  return a - o;
3184
- }), hn = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), dn = (n, {
3234
+ }), Rn = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), An = (n, {
3185
3235
  preferredMimeTypesVideoCodecs: e,
3186
3236
  excludeMimeTypesVideoCodecs: t
3187
3237
  }) => {
3188
3238
  try {
3189
3239
  if (typeof n.setCodecPreferences == "function" && n.sender.track?.kind === "video" && (e !== void 0 && e.length > 0 || t !== void 0 && t.length > 0)) {
3190
- const s = on("video"), i = hn(s, t), r = cn(i, e);
3240
+ const s = En("video"), i = Rn(s, t), r = pn(i, e);
3191
3241
  n.setCodecPreferences(r);
3192
3242
  }
3193
3243
  } catch (s) {
3194
3244
  h("setCodecPreferences error", s);
3195
3245
  }
3196
- }, ln = (n) => [...n.keys()].map((e) => n.get(e)), un = (n, e) => ln(n).find((t) => t?.type === e), gn = async (n) => n.getStats().then((e) => un(e, "codec")?.mimeType);
3197
- class Tn {
3246
+ }, mn = (n) => [...n.keys()].map((e) => n.get(e)), Nn = (n, e) => mn(n).find((t) => t?.type === e), In = async (n) => n.getStats().then((e) => Nn(e, "codec")?.mimeType);
3247
+ class vn {
3198
3248
  // eslint-disable-next-line @typescript-eslint/class-methods-use-this
3199
3249
  async getCodecFromSender(e) {
3200
- return await gn(e) ?? "";
3250
+ return await In(e) ?? "";
3201
3251
  }
3202
3252
  }
3203
- class Sn {
3253
+ class _n {
3204
3254
  stackPromises = re({
3205
3255
  noRunIsNotActual: !0
3206
3256
  });
@@ -3225,11 +3275,11 @@ class Sn {
3225
3275
  });
3226
3276
  }
3227
3277
  }
3228
- class Cn {
3278
+ class fn {
3229
3279
  taskQueue;
3230
3280
  onSetParameters;
3231
3281
  constructor(e) {
3232
- this.onSetParameters = e, this.taskQueue = new Sn();
3282
+ this.onSetParameters = e, this.taskQueue = new _n();
3233
3283
  }
3234
3284
  async setEncodingsToSender(e, t) {
3235
3285
  return this.taskQueue.add(async () => ge(e, t, this.onSetParameters));
@@ -3238,17 +3288,17 @@ class Cn {
3238
3288
  this.taskQueue.stop();
3239
3289
  }
3240
3290
  }
3241
- const _e = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), En = 1e6, _ = (n) => n * En, fe = _(0.06), Me = _(4), pn = (n) => n <= 64 ? fe : n <= 128 ? _(0.12) : n <= 256 ? _(0.25) : n <= 384 ? _(0.32) : n <= 426 ? _(0.38) : n <= 640 ? _(0.5) : n <= 848 ? _(0.7) : n <= 1280 ? _(1) : n <= 1920 ? _(2) : Me, Rn = "av1", An = (n) => _e(n, Rn), Nn = 0.6, z = (n, e) => An(e) ? n * Nn : n, mn = (n) => z(fe, n), In = (n) => z(Me, n), ne = (n, e) => {
3242
- const t = pn(n);
3291
+ const ve = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), Mn = 1e6, v = (n) => n * Mn, _e = v(0.06), fe = v(4), Pn = (n) => n <= 64 ? _e : n <= 128 ? v(0.12) : n <= 256 ? v(0.25) : n <= 384 ? v(0.32) : n <= 426 ? v(0.38) : n <= 640 ? v(0.5) : n <= 848 ? v(0.7) : n <= 1280 ? v(1) : n <= 1920 ? v(2) : fe, On = "av1", bn = (n) => ve(n, On), yn = 0.6, z = (n, e) => bn(e) ? n * yn : n, Dn = (n) => z(_e, n), wn = (n) => z(fe, n), ne = (n, e) => {
3292
+ const t = Pn(n);
3243
3293
  return z(t, e);
3244
- }, q = 1, _n = ({
3294
+ }, V = 1, Un = ({
3245
3295
  videoTrack: n,
3246
3296
  targetSize: e
3247
3297
  }) => {
3248
- const t = n.getSettings(), s = t.width, i = t.height, r = s === void 0 ? q : s / e.width, a = i === void 0 ? q : i / e.height;
3249
- return Math.max(r, a, q);
3298
+ const t = n.getSettings(), s = t.width, i = t.height, r = s === void 0 ? V : s / e.width, a = i === void 0 ? V : i / e.height;
3299
+ return Math.max(r, a, V);
3250
3300
  };
3251
- class fn {
3301
+ class Ln {
3252
3302
  ignoreForCodec;
3253
3303
  senderFinder;
3254
3304
  codecProvider;
@@ -3281,7 +3331,7 @@ class fn {
3281
3331
  if (!i?.track)
3282
3332
  return { ...this.resultNoChanged, sender: i };
3283
3333
  const r = await this.codecProvider.getCodecFromSender(i);
3284
- if (_e(r, this.ignoreForCodec))
3334
+ if (ve(r, this.ignoreForCodec))
3285
3335
  return { ...this.resultNoChanged, sender: i };
3286
3336
  const { mainCam: a, resolutionMainCam: o } = t ?? {};
3287
3337
  return this.processSender(
@@ -3301,14 +3351,14 @@ class fn {
3301
3351
  async processSender(e, t) {
3302
3352
  const { mainCam: s, resolutionMainCam: i } = e;
3303
3353
  switch (s) {
3304
- case f.PAUSE_MAIN_CAM:
3354
+ case _.PAUSE_MAIN_CAM:
3305
3355
  return this.downgradeResolutionSender(t);
3306
- case f.RESUME_MAIN_CAM:
3356
+ case _.RESUME_MAIN_CAM:
3307
3357
  return this.setBitrateByTrackResolution(t);
3308
- case f.MAX_MAIN_CAM_RESOLUTION:
3358
+ case _.MAX_MAIN_CAM_RESOLUTION:
3309
3359
  return i !== void 0 ? this.setResolutionSender(i, t) : this.setBitrateByTrackResolution(t);
3310
- case f.ADMIN_STOP_MAIN_CAM:
3311
- case f.ADMIN_START_MAIN_CAM:
3360
+ case _.ADMIN_STOP_MAIN_CAM:
3361
+ case _.ADMIN_START_MAIN_CAM:
3312
3362
  case void 0:
3313
3363
  return this.setBitrateByTrackResolution(t);
3314
3364
  default:
@@ -3323,7 +3373,7 @@ class fn {
3323
3373
  async downgradeResolutionSender(e) {
3324
3374
  const { sender: t, codec: s } = e, i = {
3325
3375
  scaleResolutionDownBy: 200,
3326
- maxBitrate: mn(s)
3376
+ maxBitrate: Dn(s)
3327
3377
  };
3328
3378
  return this.parametersSetter.setEncodingsToSender(t, i);
3329
3379
  }
@@ -3333,7 +3383,7 @@ class fn {
3333
3383
  * @returns Promise с результатом
3334
3384
  */
3335
3385
  async setBitrateByTrackResolution(e) {
3336
- const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ? In(i) : ne(a, i);
3386
+ const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ? wn(i) : ne(a, i);
3337
3387
  return this.parametersSetter.setEncodingsToSender(t, {
3338
3388
  scaleResolutionDownBy: 1,
3339
3389
  maxBitrate: o
@@ -3349,7 +3399,7 @@ class fn {
3349
3399
  const [s, i] = e.split("x"), { sender: r, videoTrack: a, codec: o } = t, c = {
3350
3400
  width: Number(s),
3351
3401
  height: Number(i)
3352
- }, d = _n({
3402
+ }, d = Un({
3353
3403
  videoTrack: a,
3354
3404
  targetSize: c
3355
3405
  }), S = ne(c.width, o), g = {
@@ -3359,14 +3409,14 @@ class fn {
3359
3409
  return this.parametersSetter.setEncodingsToSender(r, g);
3360
3410
  }
3361
3411
  }
3362
- const Mn = (n) => n.find((e) => e.track?.kind === "video");
3363
- class vn {
3412
+ const Fn = (n) => n.find((e) => e.track?.kind === "video");
3413
+ class Bn {
3364
3414
  // eslint-disable-next-line @typescript-eslint/class-methods-use-this
3365
3415
  findVideoSender(e) {
3366
- return Mn(e);
3416
+ return Fn(e);
3367
3417
  }
3368
3418
  }
3369
- class Pn {
3419
+ class kn {
3370
3420
  currentSender;
3371
3421
  originalReplaceTrack;
3372
3422
  lastWidth;
@@ -3430,7 +3480,7 @@ class Pn {
3430
3480
  this.setTimeoutRequest.cancelRequest(), this.lastWidth = void 0, this.lastHeight = void 0;
3431
3481
  }
3432
3482
  }
3433
- class On {
3483
+ class $n {
3434
3484
  apiManager;
3435
3485
  currentHandler;
3436
3486
  constructor(e) {
@@ -3450,7 +3500,7 @@ class On {
3450
3500
  this.currentHandler && (this.apiManager.off("main-cam-control", this.currentHandler), this.currentHandler = void 0);
3451
3501
  }
3452
3502
  }
3453
- class bn {
3503
+ class qn {
3454
3504
  eventHandler;
3455
3505
  senderBalancer;
3456
3506
  parametersSetterWithQueue;
@@ -3462,16 +3512,16 @@ class bn {
3462
3512
  onSetParameters: i,
3463
3513
  pollIntervalMs: r
3464
3514
  } = {}) {
3465
- this.getConnection = t, this.eventHandler = new On(e), this.parametersSetterWithQueue = new Cn(i), this.senderBalancer = new fn(
3515
+ this.getConnection = t, this.eventHandler = new $n(e), this.parametersSetterWithQueue = new fn(i), this.senderBalancer = new Ln(
3466
3516
  {
3467
- senderFinder: new vn(),
3468
- codecProvider: new Tn(),
3517
+ senderFinder: new Bn(),
3518
+ codecProvider: new vn(),
3469
3519
  parametersSetter: this.parametersSetterWithQueue
3470
3520
  },
3471
3521
  {
3472
3522
  ignoreForCodec: s
3473
3523
  }
3474
- ), this.trackMonitor = new Pn({ pollIntervalMs: r });
3524
+ ), this.trackMonitor = new kn({ pollIntervalMs: r });
3475
3525
  }
3476
3526
  /**
3477
3527
  * Подписывается на события управления главной камерой
@@ -3516,13 +3566,13 @@ class bn {
3516
3566
  });
3517
3567
  };
3518
3568
  }
3519
- const ve = [
3569
+ const Me = [
3520
3570
  "balancing-scheduled",
3521
3571
  "balancing-started",
3522
3572
  "balancing-stopped",
3523
3573
  "parameters-updated"
3524
- ];
3525
- class yn {
3574
+ ], Vn = () => new M(Me);
3575
+ class Hn {
3526
3576
  isBalancingActive = !1;
3527
3577
  events;
3528
3578
  callManager;
@@ -3530,7 +3580,7 @@ class yn {
3530
3580
  videoSendingBalancer;
3531
3581
  startBalancingTimer;
3532
3582
  constructor(e, t, s = {}) {
3533
- this.events = new O(ve), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new bn(
3583
+ this.events = Vn(), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new qn(
3534
3584
  t,
3535
3585
  () => e.connection,
3536
3586
  {
@@ -3600,21 +3650,82 @@ class yn {
3600
3650
  this.startBalancingTimer && (clearTimeout(this.startBalancingTimer), this.startBalancingTimer = void 0);
3601
3651
  }
3602
3652
  }
3603
- const Dn = 1e6, wn = Ae.map((n) => `auto-connect:${n}`), Un = Ce.map((n) => `connection:${n}`), Ln = ce.map((n) => `call:${n}`), Bn = ae.map((n) => `api:${n}`), Fn = Ne.map((n) => `incoming-call:${n}`), kn = Te.map((n) => `presentation:${n}`), $n = me.map((n) => `stats:${n}`), qn = ve.map((n) => `video-balancer:${n}`), Wn = [
3653
+ const Pe = "no-inbound-frames", Wn = [Pe], Gn = () => new M(Wn);
3654
+ class xn {
3655
+ events;
3656
+ statsManager;
3657
+ callManager;
3658
+ constructor(e, t) {
3659
+ this.statsManager = e, this.callManager = t, this.events = Gn(), this.subscribe();
3660
+ }
3661
+ get mainVideoTrack() {
3662
+ return this.callManager.getMainStream()?.getVideoTracks()[0];
3663
+ }
3664
+ get isMutedMainVideoTrack() {
3665
+ const { mainVideoTrack: e } = this;
3666
+ return e === void 0 ? !1 : e.muted;
3667
+ }
3668
+ on(e, t) {
3669
+ return this.events.on(e, t);
3670
+ }
3671
+ handleStatsCollected = () => {
3672
+ this.hasNoIncomingFrames() && this.events.trigger(Pe, {});
3673
+ };
3674
+ hasNoIncomingFrames = () => this.statsManager.isNotValidFramesStats && this.isMutedMainVideoTrack;
3675
+ subscribe() {
3676
+ this.statsManager.on("collected", this.handleStatsCollected);
3677
+ }
3678
+ }
3679
+ const Qn = 3e3;
3680
+ class Yn {
3681
+ renegotiateRequester;
3682
+ renegotiateThrottled;
3683
+ callManager;
3684
+ constructor(e, t = Qn) {
3685
+ this.callManager = e, this.renegotiateRequester = new k(e.renegotiate.bind(e)), this.renegotiateThrottled = $e.throttle(
3686
+ this.requestRenegotiate.bind(this),
3687
+ t
3688
+ ), this.subscribe();
3689
+ }
3690
+ recover() {
3691
+ h("trying to recover main stream"), this.renegotiateThrottled();
3692
+ }
3693
+ requestRenegotiate = () => {
3694
+ if (h("trying to renegotiate"), this.renegotiateRequester.requested) {
3695
+ h("previous renegotiate is not finished yet");
3696
+ return;
3697
+ }
3698
+ this.renegotiateRequester.request().then(() => {
3699
+ h("renegotiate has successful");
3700
+ }).catch((e) => {
3701
+ h("failed to renegotiate main media stream", e);
3702
+ });
3703
+ };
3704
+ subscribe() {
3705
+ this.callManager.on("ended", () => {
3706
+ this.cancel();
3707
+ });
3708
+ }
3709
+ cancel() {
3710
+ h("cancel recover main stream"), this.renegotiateThrottled.cancel(), this.renegotiateRequester.cancelRequest();
3711
+ }
3712
+ }
3713
+ const zn = 1e6, Xn = Ae.map((n) => `auto-connect:${n}`), Jn = Ce.map((n) => `connection:${n}`), Kn = ce.map((n) => `call:${n}`), jn = ae.map((n) => `api:${n}`), Zn = me.map((n) => `incoming-call:${n}`), es = Te.map((n) => `presentation:${n}`), ts = Ne.map((n) => `stats:${n}`), ns = Me.map((n) => `video-balancer:${n}`), ss = [
3604
3714
  "disconnected-from-out-of-call",
3605
- "connected-with-configuration-from-out-of-call"
3606
- ], Hn = [
3607
- ...wn,
3608
- ...Un,
3609
- ...Ln,
3610
- ...Bn,
3611
- ...Fn,
3612
- ...kn,
3613
- ...$n,
3614
- ...qn,
3615
- ...Wn
3616
- ];
3617
- class ts {
3715
+ "connected-with-configuration-from-out-of-call",
3716
+ "stopped-presentation-by-server-command"
3717
+ ], is = [
3718
+ ...Xn,
3719
+ ...Jn,
3720
+ ...Kn,
3721
+ ...jn,
3722
+ ...Zn,
3723
+ ...es,
3724
+ ...ts,
3725
+ ...ns,
3726
+ ...ss
3727
+ ], rs = () => new M(is);
3728
+ class Rs {
3618
3729
  events;
3619
3730
  connectionManager;
3620
3731
  connectionQueueManager;
@@ -3625,6 +3736,8 @@ class ts {
3625
3736
  presentationManager;
3626
3737
  statsManager;
3627
3738
  videoSendingBalancerManager;
3739
+ mainStreamHealthMonitor;
3740
+ mainStreamRecovery;
3628
3741
  preferredMimeTypesVideoCodecs;
3629
3742
  excludeMimeTypesVideoCodecs;
3630
3743
  constructor({ JsSIP: e }, {
@@ -3633,29 +3746,29 @@ class ts {
3633
3746
  videoBalancerOptions: i,
3634
3747
  autoConnectorOptions: r
3635
3748
  } = {}) {
3636
- this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = new O(Hn), this.connectionManager = new bt({ JsSIP: e }), this.connectionQueueManager = new yt({
3749
+ this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = rs(), this.connectionManager = new Bt({ JsSIP: e }), this.connectionQueueManager = new kt({
3637
3750
  connectionManager: this.connectionManager
3638
- }), this.callManager = new Ze(), this.apiManager = new Ve({
3751
+ }), this.callManager = new st(), this.apiManager = new Qe({
3639
3752
  connectionManager: this.connectionManager,
3640
3753
  callManager: this.callManager
3641
- }), this.incomingCallManager = new Yt(this.connectionManager), this.presentationManager = new Tt({
3754
+ }), this.incomingCallManager = new nn(this.connectionManager), this.presentationManager = new Rt({
3642
3755
  callManager: this.callManager,
3643
- maxBitrate: Dn
3644
- }), this.statsManager = new rn({
3756
+ maxBitrate: zn
3757
+ }), this.statsManager = new Sn({
3645
3758
  callManager: this.callManager,
3646
3759
  apiManager: this.apiManager
3647
- }), this.autoConnectorManager = new Gt(
3760
+ }), this.autoConnectorManager = new jt(
3648
3761
  {
3649
3762
  connectionQueueManager: this.connectionQueueManager,
3650
3763
  connectionManager: this.connectionManager,
3651
3764
  callManager: this.callManager
3652
3765
  },
3653
3766
  r
3654
- ), this.videoSendingBalancerManager = new yn(
3767
+ ), this.videoSendingBalancerManager = new Hn(
3655
3768
  this.callManager,
3656
3769
  this.apiManager,
3657
3770
  i
3658
- ), this.subscribe();
3771
+ ), this.mainStreamHealthMonitor = new xn(this.statsManager, this.callManager), this.mainStreamRecovery = new Yn(this.callManager), this.subscribe();
3659
3772
  }
3660
3773
  get requestedConnection() {
3661
3774
  return this.connectionManager.requested;
@@ -3834,22 +3947,25 @@ class ts {
3834
3947
  this.isCallActive || this.events.trigger("connected-with-configuration-from-out-of-call", e);
3835
3948
  });
3836
3949
  }
3837
- subscribeChangeRole() {
3950
+ subscribeToApiEvents() {
3838
3951
  this.apiManager.on("participant:move-request-to-participants", () => {
3839
3952
  this.callManager.setCallRoleParticipant();
3840
3953
  }), this.apiManager.on("participant:move-request-to-spectators-synthetic", () => {
3841
3954
  this.callManager.setCallRoleSpectatorSynthetic(), this.stopPresentation().catch(() => {
3842
- });
3955
+ }), this.events.trigger("stopped-presentation-by-server-command", {});
3843
3956
  }), this.apiManager.on("participant:move-request-to-spectators-with-audio-id", ({ audioId: e }) => {
3844
3957
  this.callManager.setCallRoleSpectator({ audioId: e, sendOffer: this.sendOffer }), this.stopPresentation().catch(() => {
3845
- });
3958
+ }), this.events.trigger("stopped-presentation-by-server-command", {});
3959
+ }), this.apiManager.on("mustStopPresentation", () => {
3960
+ this.stopPresentation().catch(() => {
3961
+ }), this.events.trigger("stopped-presentation-by-server-command", {});
3846
3962
  });
3847
3963
  }
3848
3964
  sendOffer = async (e, t) => {
3849
3965
  const i = this.connectionManager.getConnectionConfiguration()?.sipServerUrl;
3850
3966
  if (i === void 0)
3851
3967
  throw new Error("No sipServerUrl for sendOffer");
3852
- return Xt({
3968
+ return an({
3853
3969
  serverUrl: i,
3854
3970
  offer: t,
3855
3971
  conferenceNumber: e.conferenceNumber,
@@ -3858,13 +3974,18 @@ class ts {
3858
3974
  });
3859
3975
  };
3860
3976
  setCodecPreferences(e) {
3861
- dn(e, {
3977
+ An(e, {
3862
3978
  preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
3863
3979
  excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
3864
3980
  });
3865
3981
  }
3866
3982
  subscribe() {
3867
- this.bridgeEvents("auto-connect", this.autoConnectorManager), this.bridgeEvents("connection", this.connectionManager), this.bridgeEvents("call", this.callManager), this.bridgeEvents("api", this.apiManager), this.bridgeEvents("incoming-call", this.incomingCallManager), this.bridgeEvents("presentation", this.presentationManager), this.bridgeEvents("stats", this.statsManager), this.bridgeEvents("video-balancer", this.videoSendingBalancerManager), this.subscribeChangeRole(), this.subscribeDisconnectedFromOutOfCall(), this.subscribeConnectedWithConfigurationFromOutOfCall();
3983
+ this.bridgeEvents("auto-connect", this.autoConnectorManager), this.bridgeEvents("connection", this.connectionManager), this.bridgeEvents("call", this.callManager), this.bridgeEvents("api", this.apiManager), this.bridgeEvents("incoming-call", this.incomingCallManager), this.bridgeEvents("presentation", this.presentationManager), this.bridgeEvents("stats", this.statsManager), this.bridgeEvents("video-balancer", this.videoSendingBalancerManager), this.subscribeToApiEvents(), this.subscribeDisconnectedFromOutOfCall(), this.subscribeConnectedWithConfigurationFromOutOfCall(), this.subscribeToMainStreamHealthMonitorEvents();
3984
+ }
3985
+ subscribeToMainStreamHealthMonitorEvents() {
3986
+ this.mainStreamHealthMonitor.on("no-inbound-frames", () => {
3987
+ this.mainStreamRecovery.recover();
3988
+ });
3868
3989
  }
3869
3990
  bridgeEvents = (e, t) => {
3870
3991
  t.events.eachTriggers((s, i) => {
@@ -3879,19 +4000,19 @@ class ts {
3879
4000
  }
3880
4001
  export {
3881
4002
  he as E,
3882
- Ge as O,
3883
- ts as S,
4003
+ Ye as O,
4004
+ Rs as S,
3884
4005
  ge as a,
3885
- dt as b,
3886
- He as c,
3887
- Zn as d,
3888
- jn as e,
3889
- es as f,
4006
+ Tt as b,
4007
+ Ge as c,
4008
+ Es as d,
4009
+ Cs as e,
4010
+ ps as f,
3890
4011
  E as g,
3891
- vt as h,
3892
- sn as i,
3893
- gn as j,
4012
+ Ut as h,
4013
+ Tn as i,
4014
+ In as j,
3894
4015
  h as l,
3895
- F as p,
3896
- Xt as s
4016
+ B as p,
4017
+ an as s
3897
4018
  };