sip-connector 19.8.1 → 19.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,19 @@
1
- import { Events as F, TypedEvents as w } from "events-constructor";
2
- import x from "debug";
3
- import { CancelableRequest as G, isCanceledError as _e } from "@krivega/cancelable-promise";
4
- import { resolveRequesterByTimeout as Me, requesterByTimeoutsWithFailCalls as ve, DelayRequester as fe, hasCanceledError as Pe, SetTimeoutRequest as ee } from "@krivega/timeout-requester";
5
- import { hasCanceledError as Oe, repeatedCallsAsync as te } from "repeated-calls";
6
- import { setup as ye, createActor as De } from "xstate";
7
- import { createStackPromises as ne, isPromiseIsNotActualError as be } from "stack-promises";
1
+ import { TypedEvents as y } from "events-constructor";
2
+ import W from "debug";
3
+ import { CancelableRequest as x, isCanceledError as pe } from "@krivega/cancelable-promise";
4
+ import { resolveRequesterByTimeout as _e, requesterByTimeoutsWithFailCalls as Me, DelayRequester as fe, hasCanceledError as ve, SetTimeoutRequest as Z } from "@krivega/timeout-requester";
5
+ import { hasCanceledError as Pe, repeatedCallsAsync as ee } from "repeated-calls";
6
+ import { setup as Oe, createActor as ye } from "xstate";
7
+ import { createStackPromises as te, isPromiseIsNotActualError as De } from "stack-promises";
8
8
  import "ua-parser-js";
9
9
  import "sequent-promises";
10
- const Q = "sip-connector", c = x(Q), xn = () => {
11
- x.enable(Q);
12
- }, Gn = () => {
13
- x.enable(`-${Q}`);
14
- }, we = "Error decline with 603", Ue = 1006, Le = (n) => typeof n == "object" && n !== null && "code" in n && n.code === Ue, Be = (n) => n.message === we;
15
- var l = /* @__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))(l || {}), L = /* @__PURE__ */ ((n) => (n.AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(L || {}), V = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(V || {}), P = /* @__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.RESTART = "application/vinteo.webrtc.restart", n))(P || {}), p = /* @__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))(p || {}), 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 || {}), W = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(W || {}), Fe = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(Fe || {}), g = /* @__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_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.RESTART = "restart", n))(g || {});
16
- const se = [
10
+ const G = "sip-connector", c = W(G), Wn = () => {
11
+ W.enable(G);
12
+ }, xn = () => {
13
+ W.enable(`-${G}`);
14
+ }, be = "Error decline with 603", we = 1006, Ue = (n) => typeof n == "object" && n !== null && "code" in n && n.code === we, Le = (n) => n.message === be;
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))(u || {}), L = /* @__PURE__ */ ((n) => (n.AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(L || {}), q = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(q || {}), P = /* @__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.RESTART = "application/vinteo.webrtc.restart", n))(P || {}), p = /* @__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))(p || {}), v = /* @__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))(v || {}), V = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(V || {}), H = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(H || {}), Be = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(Be || {}), g = /* @__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_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.RESTART = "restart", n))(g || {});
16
+ const ne = [
17
17
  "participation:accepting-word-request",
18
18
  "participation:cancelling-word-request",
19
19
  "participant:move-request-to-stream",
@@ -44,7 +44,7 @@ const se = [
44
44
  "restart"
45
45
  ];
46
46
  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 || {});
47
- class ke {
47
+ class Fe {
48
48
  events;
49
49
  connectionManager;
50
50
  callManager;
@@ -52,7 +52,7 @@ class ke {
52
52
  connectionManager: e,
53
53
  callManager: t
54
54
  }) {
55
- this.connectionManager = e, this.callManager = t, this.events = new F(se), this.subscribe();
55
+ this.connectionManager = e, this.callManager = t, this.events = new y(ne), this.subscribe();
56
56
  }
57
57
  async waitChannels() {
58
58
  return this.wait(g.CHANNELS);
@@ -62,34 +62,34 @@ class ke {
62
62
  }
63
63
  async sendDTMF(e) {
64
64
  return new Promise((t, s) => {
65
- let i;
65
+ let r;
66
66
  try {
67
- i = this.getEstablishedRTCSessionProtected();
68
- } catch (r) {
69
- s(r);
67
+ r = this.getEstablishedRTCSessionProtected();
68
+ } catch (i) {
69
+ s(i);
70
70
  }
71
- i && (this.callManager.once("newDTMF", ({ originator: r }) => {
72
- r === "local" && t();
73
- }), i.sendDTMF(e, {
71
+ r && (this.callManager.once("newDTMF", ({ originator: i }) => {
72
+ i === "local" && t();
73
+ }), r.sendDTMF(e, {
74
74
  duration: 120,
75
75
  interToneGap: 600
76
76
  }));
77
77
  });
78
78
  }
79
79
  async sendChannels({ inputChannels: e, outputChannels: t }) {
80
- const s = this.getEstablishedRTCSessionProtected(), i = `${l.INPUT_CHANNELS}: ${e}`, r = `${l.OUTPUT_CHANNELS}: ${t}`, a = [
81
- i,
82
- r
80
+ const s = this.getEstablishedRTCSessionProtected(), r = `${u.INPUT_CHANNELS}: ${e}`, i = `${u.OUTPUT_CHANNELS}: ${t}`, a = [
81
+ r,
82
+ i
83
83
  ];
84
84
  return s.sendInfo(p.CHANNELS, void 0, { extraHeaders: a });
85
85
  }
86
86
  async sendMediaState({ cam: e, mic: t }, s = {}) {
87
- const i = this.getEstablishedRTCSessionProtected(), r = `${l.MEDIA_STATE}: currentstate`, a = `${l.MAIN_CAM_STATE}: ${Number(e)}`, o = `${l.MIC_STATE}: ${Number(t)}`, h = [
88
- r,
87
+ const r = this.getEstablishedRTCSessionProtected(), i = `${u.MEDIA_STATE}: currentstate`, a = `${u.MAIN_CAM_STATE}: ${Number(e)}`, o = `${u.MIC_STATE}: ${Number(t)}`, h = [
88
+ i,
89
89
  a,
90
90
  o
91
91
  ];
92
- return i.sendInfo(p.MEDIA_STATE, void 0, {
92
+ return r.sendInfo(p.MEDIA_STATE, void 0, {
93
93
  noTerminateWhenError: !0,
94
94
  ...s,
95
95
  extraHeaders: h
@@ -98,14 +98,14 @@ class ke {
98
98
  async sendStats({
99
99
  availableIncomingBitrate: e
100
100
  }) {
101
- const t = this.getEstablishedRTCSessionProtected(), i = [`${l.AVAILABLE_INCOMING_BITRATE}: ${e}`];
101
+ const t = this.getEstablishedRTCSessionProtected(), r = [`${u.AVAILABLE_INCOMING_BITRATE}: ${e}`];
102
102
  return t.sendInfo(p.STATS, void 0, {
103
103
  noTerminateWhenError: !0,
104
- extraHeaders: i
104
+ extraHeaders: r
105
105
  });
106
106
  }
107
107
  async sendRefusalToTurnOn(e, t = {}) {
108
- const s = this.getEstablishedRTCSessionProtected(), a = e === "mic" ? 0 : 1, h = [`${l.MEDIA_TYPE}: ${a}`];
108
+ const s = this.getEstablishedRTCSessionProtected(), a = e === "mic" ? 0 : 1, h = [`${u.MEDIA_TYPE}: ${a}`];
109
109
  return s.sendInfo(p.REFUSAL, void 0, {
110
110
  noTerminateWhenError: !0,
111
111
  ...t,
@@ -120,56 +120,52 @@ class ke {
120
120
  }
121
121
  async sendMustStopPresentationP2P() {
122
122
  await this.getEstablishedRTCSessionProtected().sendInfo(p.SHARE_STATE, void 0, {
123
- extraHeaders: [l.MUST_STOP_PRESENTATION_P2P]
123
+ extraHeaders: [u.MUST_STOP_PRESENTATION_P2P]
124
124
  });
125
125
  }
126
126
  async sendStoppedPresentationP2P() {
127
127
  await this.getEstablishedRTCSessionProtected().sendInfo(p.SHARE_STATE, void 0, {
128
- extraHeaders: [l.STOP_PRESENTATION_P2P]
128
+ extraHeaders: [u.STOP_PRESENTATION_P2P]
129
129
  });
130
130
  }
131
131
  async sendStoppedPresentation() {
132
132
  await this.getEstablishedRTCSessionProtected().sendInfo(p.SHARE_STATE, void 0, {
133
- extraHeaders: [l.STOP_PRESENTATION]
133
+ extraHeaders: [u.STOP_PRESENTATION]
134
134
  });
135
135
  }
136
136
  async askPermissionToStartPresentationP2P() {
137
137
  await this.getEstablishedRTCSessionProtected().sendInfo(p.SHARE_STATE, void 0, {
138
- extraHeaders: [l.START_PRESENTATION_P2P]
138
+ extraHeaders: [u.START_PRESENTATION_P2P]
139
139
  });
140
140
  }
141
141
  async askPermissionToStartPresentation() {
142
142
  await this.getEstablishedRTCSessionProtected().sendInfo(p.SHARE_STATE, void 0, {
143
- extraHeaders: [l.START_PRESENTATION]
143
+ extraHeaders: [u.START_PRESENTATION]
144
144
  });
145
145
  }
146
146
  async askPermissionToEnableCam(e = {}) {
147
- const t = this.getEstablishedRTCSessionProtected(), s = [l.ENABLE_MAIN_CAM];
147
+ const t = this.getEstablishedRTCSessionProtected(), s = [u.ENABLE_MAIN_CAM];
148
148
  return t.sendInfo(p.MAIN_CAM, void 0, {
149
149
  noTerminateWhenError: !0,
150
150
  ...e,
151
151
  extraHeaders: s
152
- }).catch((i) => {
153
- if (Be(i))
154
- throw i;
152
+ }).catch((r) => {
153
+ if (Le(r))
154
+ throw r;
155
155
  });
156
156
  }
157
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
158
157
  on(e, t) {
159
158
  return this.events.on(e, t);
160
159
  }
161
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
162
160
  once(e, t) {
163
161
  return this.events.once(e, t);
164
162
  }
165
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
166
163
  onceRace(e, t) {
167
164
  return this.events.onceRace(e, t);
168
165
  }
169
166
  async wait(e) {
170
167
  return this.events.wait(e);
171
168
  }
172
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
173
169
  off(e, t) {
174
170
  this.events.off(e, t);
175
171
  }
@@ -189,7 +185,7 @@ class ke {
189
185
  };
190
186
  maybeHandleNotify = (e) => {
191
187
  try {
192
- const t = e.getHeader(l.NOTIFY);
188
+ const t = e.getHeader(u.NOTIFY);
193
189
  if (t) {
194
190
  const s = JSON.parse(t);
195
191
  this.handleNotify(s);
@@ -261,49 +257,49 @@ class ke {
261
257
  const { originator: t } = e;
262
258
  if (t !== "remote")
263
259
  return;
264
- const { request: s } = e, i = s, r = i.getHeader(l.CONTENT_TYPE);
265
- if (r !== void 0)
266
- switch (r) {
260
+ const { request: s } = e, r = s, i = r.getHeader(u.CONTENT_TYPE);
261
+ if (i !== void 0)
262
+ switch (i) {
267
263
  case P.ENTER_ROOM: {
268
- this.triggerEnterRoom(i), this.maybeTriggerChannels(i);
264
+ this.triggerEnterRoom(r), this.maybeTriggerChannels(r);
269
265
  break;
270
266
  }
271
267
  case P.NOTIFY: {
272
- this.maybeHandleNotify(i);
268
+ this.maybeHandleNotify(r);
273
269
  break;
274
270
  }
275
271
  case P.SHARE_STATE: {
276
- this.triggerShareState(i);
272
+ this.triggerShareState(r);
277
273
  break;
278
274
  }
279
275
  case P.MAIN_CAM: {
280
- this.triggerMainCamControl(i);
276
+ this.triggerMainCamControl(r);
281
277
  break;
282
278
  }
283
279
  case P.MIC: {
284
- this.triggerMicControl(i);
280
+ this.triggerMicControl(r);
285
281
  break;
286
282
  }
287
283
  case P.USE_LICENSE: {
288
- this.triggerUseLicense(i);
284
+ this.triggerUseLicense(r);
289
285
  break;
290
286
  }
291
287
  case P.PARTICIPANT_STATE: {
292
- this.maybeTriggerParticipantMoveRequest(i);
288
+ this.maybeTriggerParticipantMoveRequest(r);
293
289
  break;
294
290
  }
295
291
  case P.RESTART: {
296
- this.triggerRestart(i);
292
+ this.triggerRestart(r);
297
293
  break;
298
294
  }
299
295
  }
300
296
  };
301
297
  triggerChannelsNotify = (e) => {
302
- const t = e.input, s = e.output, i = {
298
+ const t = e.input, s = e.output, r = {
303
299
  inputChannels: t,
304
300
  outputChannels: s
305
301
  };
306
- this.events.trigger(g.CHANNELS_NOTIFY, i);
302
+ this.events.trigger(g.CHANNELS_NOTIFY, r);
307
303
  };
308
304
  triggerWebcastStartedNotify = ({
309
305
  body: { conference: e, type: t }
@@ -370,98 +366,98 @@ class ke {
370
366
  this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_STREAM, t);
371
367
  };
372
368
  triggerAccountChangedNotify = () => {
373
- this.events.trigger(g.ACCOUNT_CHANGED, void 0);
369
+ this.events.trigger(g.ACCOUNT_CHANGED, {});
374
370
  };
375
371
  triggerAccountDeletedNotify = () => {
376
- this.events.trigger(g.ACCOUNT_DELETED, void 0);
372
+ this.events.trigger(g.ACCOUNT_DELETED, {});
377
373
  };
378
374
  triggerConferenceParticipantTokenIssued = ({
379
375
  body: { conference: e, participant: t, jwt: s }
380
376
  }) => {
381
- const i = {
377
+ const r = {
382
378
  conference: e,
383
379
  participant: t,
384
380
  jwt: s
385
381
  };
386
382
  this.events.trigger(
387
383
  g.CONFERENCE_PARTICIPANT_TOKEN_ISSUED,
388
- i
384
+ r
389
385
  );
390
386
  };
391
387
  maybeTriggerChannels = (e) => {
392
- const t = e.getHeader(l.INPUT_CHANNELS), s = e.getHeader(l.OUTPUT_CHANNELS);
388
+ const t = e.getHeader(u.INPUT_CHANNELS), s = e.getHeader(u.OUTPUT_CHANNELS);
393
389
  if (t && s) {
394
- const i = {
390
+ const r = {
395
391
  inputChannels: t,
396
392
  outputChannels: s
397
393
  };
398
- this.events.trigger(g.CHANNELS, i);
394
+ this.events.trigger(g.CHANNELS, r);
399
395
  }
400
396
  };
401
397
  triggerEnterRoom = (e) => {
402
- const t = e.getHeader(l.CONTENT_ENTER_ROOM), s = e.getHeader(l.PARTICIPANT_NAME);
398
+ const t = e.getHeader(u.CONTENT_ENTER_ROOM), s = e.getHeader(u.PARTICIPANT_NAME);
403
399
  this.events.trigger(g.ENTER_ROOM, { room: t, participantName: s });
404
400
  };
405
401
  triggerShareState = (e) => {
406
- const t = e.getHeader(l.CONTENT_SHARE_STATE);
402
+ const t = e.getHeader(u.CONTENT_SHARE_STATE);
407
403
  if (t !== void 0)
408
404
  switch (t) {
409
405
  case L.AVAILABLE_SECOND_REMOTE_STREAM: {
410
- this.events.trigger(g.AVAILABLE_SECOND_REMOTE_STREAM, void 0);
406
+ this.events.trigger(g.AVAILABLE_SECOND_REMOTE_STREAM, {});
411
407
  break;
412
408
  }
413
409
  case L.NOT_AVAILABLE_SECOND_REMOTE_STREAM: {
414
- this.events.trigger(g.NOT_AVAILABLE_SECOND_REMOTE_STREAM, void 0);
410
+ this.events.trigger(g.NOT_AVAILABLE_SECOND_REMOTE_STREAM, {});
415
411
  break;
416
412
  }
417
413
  case L.MUST_STOP_PRESENTATION: {
418
- this.events.trigger(g.MUST_STOP_PRESENTATION, void 0);
414
+ this.events.trigger(g.MUST_STOP_PRESENTATION, {});
419
415
  break;
420
416
  }
421
417
  }
422
418
  };
423
419
  maybeTriggerParticipantMoveRequest = (e) => {
424
- const t = e.getHeader(l.CONTENT_PARTICIPANT_STATE);
425
- t === V.SPECTATOR && this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, void 0), t === V.PARTICIPANT && this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS, void 0);
420
+ const t = e.getHeader(u.CONTENT_PARTICIPANT_STATE);
421
+ t === q.SPECTATOR && this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, {}), t === q.PARTICIPANT && this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS, {});
426
422
  };
427
423
  triggerMainCamControl = (e) => {
428
- const t = e.getHeader(l.MAIN_CAM), s = e.getHeader(l.MEDIA_SYNC), i = s === W.ADMIN_SYNC_FORCED;
429
- if (t === f.ADMIN_START_MAIN_CAM) {
430
- this.events.trigger(g.ADMIN_START_MAIN_CAM, { isSyncForced: i });
424
+ const t = e.getHeader(u.MAIN_CAM), s = e.getHeader(u.MEDIA_SYNC), r = s === H.ADMIN_SYNC_FORCED;
425
+ if (t === v.ADMIN_START_MAIN_CAM) {
426
+ this.events.trigger(g.ADMIN_START_MAIN_CAM, { isSyncForced: r });
431
427
  return;
432
428
  }
433
- if (t === f.ADMIN_STOP_MAIN_CAM) {
434
- this.events.trigger(g.ADMIN_STOP_MAIN_CAM, { isSyncForced: i });
429
+ if (t === v.ADMIN_STOP_MAIN_CAM) {
430
+ this.events.trigger(g.ADMIN_STOP_MAIN_CAM, { isSyncForced: r });
435
431
  return;
436
432
  }
437
- (t === f.RESUME_MAIN_CAM || t === f.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(g.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: i });
438
- const r = e.getHeader(l.MAIN_CAM_RESOLUTION);
433
+ (t === v.RESUME_MAIN_CAM || t === v.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(g.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: r });
434
+ const i = e.getHeader(u.MAIN_CAM_RESOLUTION);
439
435
  this.events.trigger(g.MAIN_CAM_CONTROL, {
440
436
  mainCam: t,
441
- resolutionMainCam: r
437
+ resolutionMainCam: i
442
438
  });
443
439
  };
444
440
  triggerMicControl = (e) => {
445
- const t = e.getHeader(l.MIC), i = e.getHeader(l.MEDIA_SYNC) === W.ADMIN_SYNC_FORCED;
446
- t === H.ADMIN_START_MIC ? this.events.trigger(g.ADMIN_START_MIC, { isSyncForced: i }) : t === H.ADMIN_STOP_MIC && this.events.trigger(g.ADMIN_STOP_MIC, { isSyncForced: i });
441
+ const t = e.getHeader(u.MIC), r = e.getHeader(u.MEDIA_SYNC) === H.ADMIN_SYNC_FORCED;
442
+ t === V.ADMIN_START_MIC ? this.events.trigger(g.ADMIN_START_MIC, { isSyncForced: r }) : t === V.ADMIN_STOP_MIC && this.events.trigger(g.ADMIN_STOP_MIC, { isSyncForced: r });
447
443
  };
448
444
  triggerUseLicense = (e) => {
449
- const t = e.getHeader(l.CONTENT_USE_LICENSE);
445
+ const t = e.getHeader(u.CONTENT_USE_LICENSE);
450
446
  this.events.trigger(g.USE_LICENSE, t);
451
447
  };
452
448
  triggerRestart = (e) => {
453
449
  const t = e.getHeader(
454
- l.TRACKS_DIRECTION
450
+ u.TRACKS_DIRECTION
455
451
  ), s = Number(
456
- e.getHeader(l.AUDIO_TRACK_COUNT)
457
- ), i = Number(
458
- e.getHeader(l.VIDEO_TRACK_COUNT)
459
- ), r = { tracksDirection: t, audioTrackCount: s, videoTrackCount: i };
460
- this.events.trigger(g.RESTART, r);
452
+ e.getHeader(u.AUDIO_TRACK_COUNT)
453
+ ), r = Number(
454
+ e.getHeader(u.VIDEO_TRACK_COUNT)
455
+ ), i = { tracksDirection: t, audioTrackCount: s, videoTrackCount: r };
456
+ this.events.trigger(g.RESTART, i);
461
457
  };
462
458
  }
463
- 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))(R || {}), $e = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))($e || {});
464
- const ie = [
459
+ 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))(R || {}), ke = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))(ke || {});
460
+ const se = [
465
461
  "peerconnection",
466
462
  "connecting",
467
463
  "sending",
@@ -488,23 +484,23 @@ const ie = [
488
484
  "peerconnection:createanswerfailed",
489
485
  "peerconnection:setlocaldescriptionfailed",
490
486
  "peerconnection:setremotedescriptionfailed"
491
- ], qe = [
487
+ ], $e = [
492
488
  "peerconnection:confirmed",
493
489
  "peerconnection:ontrack",
494
490
  "ended:fromserver",
495
491
  "call-status-changed"
496
492
  ], re = [
497
- ...ie,
498
- ...qe
493
+ ...se,
494
+ ...$e
499
495
  ];
500
- function Ve(n) {
496
+ function qe(n) {
501
497
  return (e) => `sip:${e}@${n}`;
502
498
  }
503
- const He = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, ae = (n) => n.trim().replaceAll(" ", "_"), We = He(1e5, 99999999), xe = (n) => n.some((t) => {
499
+ const Ve = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, ie = (n) => n.trim().replaceAll(" ", "_"), He = Ve(1e5, 99999999), We = (n) => n.some((t) => {
504
500
  const { kind: s } = t;
505
501
  return s === "video";
506
502
  });
507
- class Ge {
503
+ class xe {
508
504
  isPendingCall = !1;
509
505
  isPendingAnswer = !1;
510
506
  rtcSession;
@@ -515,7 +511,7 @@ class Ge {
515
511
  this.events = e;
516
512
  }
517
513
  }
518
- const Qe = (n, e) => {
514
+ const Ge = (n, e) => {
519
515
  n.getVideoTracks().forEach((s) => {
520
516
  "contentHint" in s && s.contentHint !== e && (s.contentHint = e);
521
517
  });
@@ -526,11 +522,11 @@ const Qe = (n, e) => {
526
522
  } = {}) => {
527
523
  if (!n || e === "recvonly" && t === "recvonly")
528
524
  return;
529
- const i = t === "recvonly" ? [] : n.getAudioTracks(), r = e === "recvonly" ? [] : n.getVideoTracks(), a = [...i, ...r], o = new MediaStream(a);
530
- return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && Qe(o, s), o;
525
+ const r = t === "recvonly" ? [] : n.getAudioTracks(), i = e === "recvonly" ? [] : n.getVideoTracks(), a = [...r, ...i], o = new MediaStream(a);
526
+ return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && Ge(o, s), o;
531
527
  };
532
- var oe = /* @__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))(oe || {});
533
- class Ye {
528
+ var ae = /* @__PURE__ */ ((n) => (n.BYE = "Terminated", n.WEBRTC_ERROR = "WebRTC Error", n.CANCELED = "Canceled", n.REQUEST_TIMEOUT = "Request Timeout", n.REJECTED = "Rejected", n.REDIRECTED = "Redirected", n.UNAVAILABLE = "Unavailable", n.NOT_FOUND = "Not Found", n.ADDRESS_INCOMPLETE = "Address Incomplete", n.INCOMPATIBLE_SDP = "Incompatible SDP", n.BAD_MEDIA_DESCRIPTION = "Bad Media Description", n))(ae || {});
529
+ class Qe {
534
530
  events;
535
531
  rtcSession;
536
532
  disposers = /* @__PURE__ */ new Set();
@@ -547,23 +543,23 @@ class Ye {
547
543
  getEstablishedRTCSession = () => this.rtcSession?.isEstablished() === !0 ? this.rtcSession : void 0;
548
544
  startCall = async (e, t, {
549
545
  number: s,
550
- mediaStream: i,
551
- extraHeaders: r = [],
546
+ mediaStream: r,
547
+ extraHeaders: i = [],
552
548
  ontrack: a,
553
549
  iceServers: o,
554
550
  directionVideo: h,
555
551
  directionAudio: d,
556
552
  contentHint: T,
557
553
  offerToReceiveAudio: S = !0,
558
- offerToReceiveVideo: u = !0,
554
+ offerToReceiveVideo: l = !0,
559
555
  degradationPreference: E,
560
556
  sendEncodings: I,
561
557
  onAddedTransceiver: N
562
- }) => new Promise((M, k) => {
563
- this.handleCall({ ontrack: a }).then(M).catch(($) => {
564
- k($);
558
+ }) => new Promise((M, F) => {
559
+ this.handleCall({ ontrack: a }).then(M).catch((k) => {
560
+ F(k);
565
561
  }), this.rtcSession = e.call(t(s), {
566
- mediaStream: B(i, {
562
+ mediaStream: B(r, {
567
563
  directionVideo: h,
568
564
  directionAudio: d,
569
565
  contentHint: T
@@ -573,13 +569,13 @@ class Ye {
573
569
  },
574
570
  rtcOfferConstraints: {
575
571
  offerToReceiveAudio: S,
576
- offerToReceiveVideo: u
572
+ offerToReceiveVideo: l
577
573
  },
578
574
  // необходимо передавать в методе call, чтобы подписаться на события peerconnection,
579
575
  // так как в методе call создается RTCSession
580
576
  // и после создания нет возможности подписаться на события peerconnection через subscribeToSessionEvents
581
577
  eventHandlers: this.events.triggers,
582
- extraHeaders: r,
578
+ extraHeaders: i,
583
579
  directionVideo: h,
584
580
  directionAudio: d,
585
581
  degradationPreference: E,
@@ -591,7 +587,7 @@ class Ye {
591
587
  const { rtcSession: e } = this;
592
588
  if (e && !e.isEnded())
593
589
  return e.terminateAsync({
594
- cause: oe.CANCELED
590
+ cause: ae.CANCELED
595
591
  }).finally(() => {
596
592
  this.reset();
597
593
  });
@@ -600,15 +596,15 @@ class Ye {
600
596
  answerToIncomingCall = async (e, {
601
597
  mediaStream: t,
602
598
  ontrack: s,
603
- extraHeaders: i = [],
604
- iceServers: r,
599
+ extraHeaders: r = [],
600
+ iceServers: i,
605
601
  directionVideo: a,
606
602
  directionAudio: o,
607
603
  offerToReceiveAudio: h,
608
604
  offerToReceiveVideo: d,
609
605
  contentHint: T,
610
606
  degradationPreference: S,
611
- sendEncodings: u,
607
+ sendEncodings: l,
612
608
  onAddedTransceiver: E
613
609
  }) => new Promise((I, N) => {
614
610
  try {
@@ -616,7 +612,7 @@ class Ye {
616
612
  N(M);
617
613
  }), e.answer({
618
614
  pcConfig: {
619
- iceServers: r
615
+ iceServers: i
620
616
  },
621
617
  rtcOfferConstraints: {
622
618
  offerToReceiveAudio: h,
@@ -627,11 +623,11 @@ class Ye {
627
623
  directionAudio: o,
628
624
  contentHint: T
629
625
  }),
630
- extraHeaders: i,
626
+ extraHeaders: r,
631
627
  directionVideo: a,
632
628
  directionAudio: o,
633
629
  degradationPreference: S,
634
- sendEncodings: u,
630
+ sendEncodings: l,
635
631
  onAddedTransceiver: E
636
632
  });
637
633
  } catch (M) {
@@ -644,10 +640,10 @@ class Ye {
644
640
  async replaceMediaStream(e, t) {
645
641
  if (!this.rtcSession)
646
642
  throw new Error("No rtcSession established");
647
- const { contentHint: s } = t ?? {}, i = B(e, { contentHint: s });
648
- if (i === void 0)
643
+ const { contentHint: s } = t ?? {}, r = B(e, { contentHint: s });
644
+ if (r === void 0)
649
645
  throw new Error("No preparedMediaStream");
650
- return this.rtcSession.replaceMediaStream(i, t);
646
+ return this.rtcSession.replaceMediaStream(r, t);
651
647
  }
652
648
  async restartIce(e) {
653
649
  if (!this.rtcSession)
@@ -662,36 +658,36 @@ class Ye {
662
658
  handleCall = async ({
663
659
  ontrack: e
664
660
  }) => new Promise((t, s) => {
665
- const i = () => {
661
+ const r = () => {
666
662
  this.events.on(R.PEER_CONNECTION, T), this.events.on(R.CONFIRMED, S);
667
- }, r = () => {
663
+ }, i = () => {
668
664
  this.events.off(R.PEER_CONNECTION, T), this.events.off(R.CONFIRMED, S);
669
665
  }, a = () => {
670
666
  this.events.on(R.FAILED, h), this.events.on(R.ENDED, h);
671
667
  }, o = () => {
672
668
  this.events.off(R.FAILED, h), this.events.off(R.ENDED, h);
673
- }, h = (u) => {
674
- r(), o(), s(u);
669
+ }, h = (l) => {
670
+ i(), o(), s(l);
675
671
  };
676
672
  let d;
677
- const T = ({ peerconnection: u }) => {
678
- d = u;
673
+ const T = ({ peerconnection: l }) => {
674
+ d = l;
679
675
  const E = (I) => {
680
676
  this.events.trigger(R.PEER_CONNECTION_ONTRACK, I), e && e(I);
681
677
  };
682
- u.addEventListener("track", E), this.disposers.add(() => {
683
- u.removeEventListener("track", E);
678
+ l.addEventListener("track", E), this.disposers.add(() => {
679
+ l.removeEventListener("track", E);
684
680
  });
685
681
  }, S = () => {
686
- d !== void 0 && this.events.trigger(R.PEER_CONNECTION_CONFIRMED, d), r(), o(), t(d);
682
+ d !== void 0 && this.events.trigger(R.PEER_CONNECTION_CONFIRMED, d), i(), o(), t(d);
687
683
  };
688
- i(), a();
684
+ r(), a();
689
685
  });
690
686
  subscribeToSessionEvents(e) {
691
687
  this.events.eachTriggers((t, s) => {
692
- const i = ie.find((r) => r === s);
693
- i && (e.on(i, t), this.disposers.add(() => {
694
- e.off(i, t);
688
+ const r = se.find((i) => i === s);
689
+ r && (e.on(r, t), this.disposers.add(() => {
690
+ e.off(r, t);
695
691
  }));
696
692
  });
697
693
  }
@@ -708,14 +704,14 @@ class Ye {
708
704
  delete this.rtcSession, this.unsubscribeFromSessionEvents(), this.onReset();
709
705
  };
710
706
  }
711
- class ze {
707
+ class Ye {
712
708
  remoteStreams = {};
713
709
  reset() {
714
710
  this.remoteStreams = {};
715
711
  }
716
712
  generateStream(e, t) {
717
- const { id: s } = e, i = this.remoteStreams[s] ?? new MediaStream();
718
- return t && i.addTrack(t), i.addTrack(e), this.remoteStreams[s] = i, i;
713
+ const { id: s } = e, r = this.remoteStreams[s] ?? new MediaStream();
714
+ return t && r.addTrack(t), r.addTrack(e), this.remoteStreams[s] = r, r;
719
715
  }
720
716
  generateAudioStream(e) {
721
717
  const { id: t } = e, s = this.remoteStreams[t] ?? new MediaStream();
@@ -723,13 +719,13 @@ class ze {
723
719
  }
724
720
  generateStreams(e) {
725
721
  const t = [];
726
- return e.forEach((s, i) => {
722
+ return e.forEach((s, r) => {
727
723
  if (s.kind === "audio")
728
724
  return;
729
- const r = s, a = e[i - 1];
725
+ const i = s, a = e[r - 1];
730
726
  let o;
731
727
  a?.kind === "audio" && (o = a);
732
- const h = this.generateStream(r, o);
728
+ const h = this.generateStream(i, o);
733
729
  t.push(h);
734
730
  }), t;
735
731
  }
@@ -737,11 +733,11 @@ class ze {
737
733
  return e.map((t) => this.generateAudioStream(t));
738
734
  }
739
735
  }
740
- class Xe extends Ge {
741
- remoteStreamsManager = new ze();
736
+ class ze extends xe {
737
+ remoteStreamsManager = new Ye();
742
738
  mcuSession;
743
739
  constructor(e) {
744
- super(e), this.mcuSession = new Ye(e, { onReset: this.reset });
740
+ super(e), this.mcuSession = new Qe(e, { onReset: this.reset });
745
741
  }
746
742
  get requested() {
747
743
  return this.isPendingCall || this.isPendingAnswer;
@@ -772,7 +768,7 @@ class Xe extends Ge {
772
768
  getRemoteStreams() {
773
769
  const e = this.mcuSession.getRemoteTracks();
774
770
  if (e)
775
- return xe(e) ? this.remoteStreamsManager.generateStreams(e) : this.remoteStreamsManager.generateAudioStreams(e);
771
+ return We(e) ? this.remoteStreamsManager.generateStreams(e) : this.remoteStreamsManager.generateAudioStreams(e);
776
772
  }
777
773
  async replaceMediaStream(e, t) {
778
774
  return this.mcuSession.replaceMediaStream(e, t);
@@ -787,11 +783,11 @@ class Xe extends Ge {
787
783
  this.remoteStreamsManager.reset(), this.callConfiguration.number = void 0, this.callConfiguration.answer = !1;
788
784
  };
789
785
  }
790
- class Je {
786
+ class Xe {
791
787
  events;
792
788
  strategy;
793
789
  constructor(e) {
794
- this.events = new w(re), this.strategy = e ?? new Xe(this.events), this.subscribeCallStatusChange();
790
+ this.events = new y(re), this.strategy = e ?? new ze(this.events), this.subscribeCallStatusChange();
795
791
  }
796
792
  get requested() {
797
793
  return this.strategy.requested;
@@ -834,8 +830,8 @@ class Je {
834
830
  restartIce = async (e) => this.strategy.restartIce(e);
835
831
  subscribeCallStatusChange() {
836
832
  let { isCallActive: e } = this;
837
- const { ACCEPTED: t, CONFIRMED: s, ENDED: i, FAILED: r } = R;
838
- this.onRace([t, s, i, r], () => {
833
+ const { ACCEPTED: t, CONFIRMED: s, ENDED: r, FAILED: i } = R;
834
+ this.onRace([t, s, r, i], () => {
839
835
  e = this.maybeTriggerCallStatus(e);
840
836
  });
841
837
  }
@@ -844,39 +840,39 @@ class Je {
844
840
  return t !== e && this.events.trigger(R.CALL_STATUS_CHANGED, { isCallActive: t }), t;
845
841
  }
846
842
  }
847
- const Ke = (n, e) => (n.degradationPreference = e.degradationPreference, n), je = (n, e) => {
843
+ const Je = (n, e) => (n.degradationPreference = e.degradationPreference, n), Ke = (n, e) => {
848
844
  n.encodings ??= [];
849
845
  for (let t = n.encodings.length; t < e; t += 1)
850
846
  n.encodings.push({});
851
847
  return n;
852
- }, ce = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, Ze = ce(), et = (n, e) => {
853
- if (Ze(n, e))
848
+ }, oe = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, je = oe(), Ze = (n, e) => {
849
+ if (je(n, e))
854
850
  return n;
855
- }, tt = (n, e) => {
856
- const t = n.maxBitrate, s = et(e, t);
851
+ }, et = (n, e) => {
852
+ const t = n.maxBitrate, s = Ze(e, t);
857
853
  return s !== void 0 && (n.maxBitrate = s), n;
858
- }, he = 1, nt = ce(
859
- he
860
- ), st = (n, e) => {
861
- const t = n === void 0 ? void 0 : Math.max(n, he);
862
- if (t !== void 0 && nt(
854
+ }, ce = 1, tt = oe(
855
+ ce
856
+ ), nt = (n, e) => {
857
+ const t = n === void 0 ? void 0 : Math.max(n, ce);
858
+ if (t !== void 0 && tt(
863
859
  t,
864
860
  e
865
861
  ))
866
862
  return t;
867
- }, it = (n, e) => {
868
- const t = n.scaleResolutionDownBy, s = st(
863
+ }, st = (n, e) => {
864
+ const t = n.scaleResolutionDownBy, s = nt(
869
865
  e,
870
866
  t
871
867
  );
872
868
  return s !== void 0 && (n.scaleResolutionDownBy = s), n;
873
869
  }, rt = (n, e) => {
874
870
  const t = e.encodings?.length ?? 0;
875
- return je(n, t), n.encodings.forEach((s, i) => {
876
- const r = (e?.encodings ?? [])[i], a = r?.maxBitrate, o = r?.scaleResolutionDownBy;
877
- tt(s, a), it(s, o);
871
+ return Ke(n, t), n.encodings.forEach((s, r) => {
872
+ const i = (e?.encodings ?? [])[r], a = i?.maxBitrate, o = i?.scaleResolutionDownBy;
873
+ et(s, a), st(s, o);
878
874
  }), n;
879
- }, at = (n, e) => {
875
+ }, it = (n, e) => {
880
876
  if (n.codecs?.length !== e.codecs?.length)
881
877
  return !0;
882
878
  for (let t = 0; t < (n.codecs?.length ?? 0); t++)
@@ -893,15 +889,15 @@ const Ke = (n, e) => (n.degradationPreference = e.degradationPreference, n), je
893
889
  if (JSON.stringify(n.encodings[t]) !== JSON.stringify(e.encodings[t]))
894
890
  return !0;
895
891
  return n.rtcp?.cname !== e.rtcp?.cname || n.rtcp?.reducedSize !== e.rtcp?.reducedSize || n.degradationPreference !== e.degradationPreference;
896
- }, ot = async (n, e) => {
892
+ }, at = async (n, e) => {
897
893
  const t = n.getParameters(), s = JSON.parse(
898
894
  JSON.stringify(t)
899
895
  );
900
- rt(t, e), Ke(t, e);
901
- const i = at(s, t);
902
- return i && await n.setParameters(t), { parameters: t, isChanged: i };
903
- }, de = async (n, e, t) => {
904
- const { isChanged: s, parameters: i } = await ot(n, {
896
+ rt(t, e), Je(t, e);
897
+ const r = it(s, t);
898
+ return r && await n.setParameters(t), { parameters: t, isChanged: r };
899
+ }, he = async (n, e, t) => {
900
+ const { isChanged: s, parameters: r } = await at(n, {
905
901
  encodings: [
906
902
  {
907
903
  scaleResolutionDownBy: e.scaleResolutionDownBy,
@@ -909,21 +905,21 @@ const Ke = (n, e) => (n.degradationPreference = e.degradationPreference, n), je
909
905
  }
910
906
  ]
911
907
  });
912
- return s && t && t(i), { isChanged: s, parameters: i };
913
- }, ct = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), ht = async (n, e, t) => {
914
- const s = ct(n, e);
908
+ return s && t && t(r), { isChanged: s, parameters: r };
909
+ }, ot = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), ct = async (n, e, t) => {
910
+ const s = ot(n, e);
915
911
  if (s)
916
- return de(s, { maxBitrate: t });
912
+ return he(s, { maxBitrate: t });
917
913
  };
918
914
  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 || {});
919
- const le = [
915
+ const de = [
920
916
  "presentation:start",
921
917
  "presentation:started",
922
918
  "presentation:end",
923
919
  "presentation:ended",
924
920
  "presentation:failed"
925
- ], dt = 1, Qn = (n) => Oe(n);
926
- class lt {
921
+ ], ht = 1, Gn = (n) => Pe(n);
922
+ class dt {
927
923
  events;
928
924
  promisePendingStartPresentation;
929
925
  promisePendingStopPresentation;
@@ -935,7 +931,7 @@ class lt {
935
931
  callManager: e,
936
932
  maxBitrate: t
937
933
  }) {
938
- this.callManager = e, this.maxBitrate = t, this.events = new F(le), this.subscribe();
934
+ this.callManager = e, this.maxBitrate = t, this.events = new y(de), this.subscribe();
939
935
  }
940
936
  get isPendingPresentation() {
941
937
  return !!this.promisePendingStartPresentation || !!this.promisePendingStopPresentation;
@@ -943,8 +939,8 @@ class lt {
943
939
  // eslint-disable-next-line @typescript-eslint/max-params
944
940
  async startPresentation(e, t, {
945
941
  isNeedReinvite: s,
946
- contentHint: i,
947
- sendEncodings: r,
942
+ contentHint: r,
943
+ sendEncodings: i,
948
944
  onAddedTransceiver: a
949
945
  } = {}, o) {
950
946
  const h = this.getRtcSessionProtected();
@@ -955,8 +951,8 @@ class lt {
955
951
  stream: t,
956
952
  presentationOptions: {
957
953
  isNeedReinvite: s,
958
- contentHint: i,
959
- sendEncodings: r,
954
+ contentHint: r,
955
+ sendEncodings: i,
960
956
  onAddedTransceiver: a
961
957
  },
962
958
  options: o
@@ -968,17 +964,18 @@ class lt {
968
964
  let s = this.promisePendingStartPresentation ?? Promise.resolve(void 0);
969
965
  this.promisePendingStartPresentation && await this.promisePendingStartPresentation.catch(() => {
970
966
  });
971
- const i = this.callManager.getEstablishedRTCSession();
972
- return i && t ? s = e().then(async () => i.stopPresentation(t)).catch((r) => {
973
- throw this.events.trigger(O.FAILED_PRESENTATION, r), r;
967
+ const r = this.callManager.getEstablishedRTCSession();
968
+ return r && t ? s = e().then(async () => r.stopPresentation(t)).catch((i) => {
969
+ const a = i instanceof Error ? i : new Error(String(i));
970
+ throw this.events.trigger(O.FAILED_PRESENTATION, a), i;
974
971
  }) : t && this.events.trigger(O.ENDED_PRESENTATION, t), this.promisePendingStopPresentation = s, s.finally(() => {
975
972
  this.resetPresentation();
976
973
  });
977
974
  }
978
975
  async updatePresentation(e, t, {
979
976
  contentHint: s,
980
- sendEncodings: i,
981
- onAddedTransceiver: r
977
+ sendEncodings: r,
978
+ onAddedTransceiver: i
982
979
  } = {}) {
983
980
  const a = this.getRtcSessionProtected();
984
981
  if (!this.streamPresentationCurrent)
@@ -986,29 +983,25 @@ class lt {
986
983
  return this.promisePendingStartPresentation && await this.promisePendingStartPresentation, this.sendPresentation(e, a, t, {
987
984
  contentHint: s,
988
985
  isNeedReinvite: !1,
989
- sendEncodings: i,
990
- onAddedTransceiver: r
986
+ sendEncodings: r,
987
+ onAddedTransceiver: i
991
988
  }).then(async (o) => (await this.setMaxBitrate(), o));
992
989
  }
993
990
  cancelSendPresentationWithRepeatedCalls() {
994
991
  this.cancelableSendPresentationWithRepeatedCalls?.stopRepeatedCalls();
995
992
  }
996
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
997
993
  on(e, t) {
998
994
  return this.events.on(e, t);
999
995
  }
1000
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
1001
996
  once(e, t) {
1002
997
  return this.events.once(e, t);
1003
998
  }
1004
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
1005
999
  onceRace(e, t) {
1006
1000
  return this.events.onceRace(e, t);
1007
1001
  }
1008
1002
  async wait(e) {
1009
1003
  return this.events.wait(e);
1010
1004
  }
1011
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
1012
1005
  off(e, t) {
1013
1006
  this.events.off(e, t);
1014
1007
  }
@@ -1028,42 +1021,44 @@ class lt {
1028
1021
  async sendPresentationWithDuplicatedCalls(e, {
1029
1022
  rtcSession: t,
1030
1023
  stream: s,
1031
- presentationOptions: i,
1032
- options: r = {
1033
- callLimit: dt
1024
+ presentationOptions: r,
1025
+ options: i = {
1026
+ callLimit: ht
1034
1027
  }
1035
1028
  }) {
1036
1029
  const a = async () => this.sendPresentation(
1037
1030
  e,
1038
1031
  t,
1039
1032
  s,
1040
- i
1033
+ r
1041
1034
  ), o = () => !!this.streamPresentationCurrent;
1042
- return this.cancelableSendPresentationWithRepeatedCalls = te({
1035
+ return this.cancelableSendPresentationWithRepeatedCalls = ee({
1043
1036
  targetFunction: a,
1044
1037
  isComplete: o,
1045
1038
  isRejectAsValid: !0,
1046
- ...r
1039
+ ...i
1047
1040
  }), this.cancelableSendPresentationWithRepeatedCalls.then((h) => h);
1048
1041
  }
1049
1042
  // eslint-disable-next-line @typescript-eslint/max-params
1050
1043
  async sendPresentation(e, t, s, {
1051
- isNeedReinvite: i = !0,
1052
- contentHint: r = "detail",
1044
+ isNeedReinvite: r = !0,
1045
+ contentHint: i = "detail",
1053
1046
  degradationPreference: a,
1054
1047
  sendEncodings: o,
1055
1048
  onAddedTransceiver: h
1056
1049
  }) {
1057
- const d = B(s, { contentHint: r });
1050
+ const d = B(s, { contentHint: i });
1058
1051
  if (d === void 0)
1059
1052
  throw new Error("No streamPresentationTarget");
1060
1053
  this.streamPresentationCurrent = d;
1061
- const T = e().then(async () => t.startPresentation(d, i, {
1054
+ const T = e().then(async () => t.startPresentation(d, r, {
1062
1055
  degradationPreference: a,
1063
1056
  sendEncodings: o,
1064
1057
  onAddedTransceiver: h
1065
1058
  })).then(this.setMaxBitrate).then(() => s).catch((S) => {
1066
- throw this.removeStreamPresentationCurrent(), this.events.trigger(O.FAILED_PRESENTATION, S), S;
1059
+ this.removeStreamPresentationCurrent();
1060
+ const l = S instanceof Error ? S : new Error(String(S));
1061
+ throw this.events.trigger(O.FAILED_PRESENTATION, l), S;
1067
1062
  });
1068
1063
  return this.promisePendingStartPresentation = T, T.finally(() => {
1069
1064
  this.promisePendingStartPresentation = void 0;
@@ -1073,8 +1068,8 @@ class lt {
1073
1068
  const { connection: e } = this.callManager, { streamPresentationCurrent: t } = this, { maxBitrate: s } = this;
1074
1069
  if (!e || !t || s === void 0)
1075
1070
  return;
1076
- const i = e.getSenders();
1077
- await ht(i, t, s);
1071
+ const r = e.getSenders();
1072
+ await ct(r, t, s);
1078
1073
  };
1079
1074
  getRtcSessionProtected = () => {
1080
1075
  const e = this.callManager.getEstablishedRTCSession();
@@ -1095,7 +1090,7 @@ class lt {
1095
1090
  delete this.streamPresentationCurrent;
1096
1091
  }
1097
1092
  }
1098
- class ut {
1093
+ class lt {
1099
1094
  data;
1100
1095
  getUa;
1101
1096
  constructor(e) {
@@ -1176,7 +1171,7 @@ class ut {
1176
1171
  }
1177
1172
  }
1178
1173
  var C = /* @__PURE__ */ ((n) => (n.CONNECTING = "connecting", n.CONNECTED = "connected", n.DISCONNECTED = "disconnected", n.DISCONNECTING = "disconnecting", n.NEW_RTC_SESSION = "newRTCSession", n.REGISTERED = "registered", n.UNREGISTERED = "unregistered", n.REGISTRATION_FAILED = "registrationFailed", n.NEW_MESSAGE = "newMessage", n.SIP_EVENT = "sipEvent", n.CONNECT_STARTED = "connect-started", n.CONNECT_SUCCEEDED = "connect-succeeded", n.CONNECT_FAILED = "connect-failed", n.CONNECT_PARAMETERS_RESOLVE_SUCCESS = "connect-parameters-resolve-success", n.CONNECT_PARAMETERS_RESOLVE_FAILED = "connect-parameters-resolve-failed", n.CONNECTED_WITH_CONFIGURATION = "connected-with-configuration", n))(C || {});
1179
- const ue = [
1174
+ const le = [
1180
1175
  "connecting",
1181
1176
  "connected",
1182
1177
  "disconnected",
@@ -1186,7 +1181,7 @@ const ue = [
1186
1181
  "registrationFailed",
1187
1182
  "newMessage",
1188
1183
  "sipEvent"
1189
- ], gt = [
1184
+ ], ut = [
1190
1185
  "disconnecting",
1191
1186
  "connect-started",
1192
1187
  "connect-succeeded",
@@ -1194,8 +1189,8 @@ const ue = [
1194
1189
  "connect-parameters-resolve-success",
1195
1190
  "connect-parameters-resolve-failed",
1196
1191
  "connected-with-configuration"
1197
- ], ge = [...ue, ...gt], Tt = 3;
1198
- class St {
1192
+ ], ue = [...le, ...ut], gt = 3;
1193
+ class Tt {
1199
1194
  cancelableConnectWithRepeatedCalls;
1200
1195
  JsSIP;
1201
1196
  events;
@@ -1214,15 +1209,15 @@ class St {
1214
1209
  }
1215
1210
  connect = async (e, t) => (this.cancelRequests(), this.connectWithDuplicatedCalls(e, t));
1216
1211
  set = async ({ displayName: e }) => new Promise((t, s) => {
1217
- const i = this.getUa();
1218
- if (!i) {
1212
+ const r = this.getUa();
1213
+ if (!r) {
1219
1214
  s(new Error("this.ua is not initialized"));
1220
1215
  return;
1221
1216
  }
1222
- let r = !1;
1217
+ let i = !1;
1223
1218
  const a = this.getConnectionConfiguration();
1224
- e !== void 0 && e !== a?.displayName && (r = i.set("display_name", ae(e)), this.updateConnectionConfiguration("displayName", e));
1225
- const o = r;
1219
+ e !== void 0 && e !== a?.displayName && (i = r.set("display_name", ie(e)), this.updateConnectionConfiguration("displayName", e));
1220
+ const o = i;
1226
1221
  o ? t(o) : s(new Error("nothing changed"));
1227
1222
  });
1228
1223
  disconnect = async () => {
@@ -1239,26 +1234,26 @@ class St {
1239
1234
  cancelRequests() {
1240
1235
  this.cancelConnectWithRepeatedCalls();
1241
1236
  }
1242
- connectWithDuplicatedCalls = async (e, { callLimit: t = Tt } = {}) => {
1243
- const s = async () => this.connectInner(e), i = (r) => {
1244
- const h = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), d = r != null && !Le(r);
1237
+ connectWithDuplicatedCalls = async (e, { callLimit: t = gt } = {}) => {
1238
+ const s = async () => this.connectInner(e), r = (i) => {
1239
+ const h = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), d = i != null && !Ue(i);
1245
1240
  return h || d;
1246
1241
  };
1247
- return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = te({
1242
+ return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = ee({
1248
1243
  targetFunction: s,
1249
- isComplete: i,
1244
+ isComplete: r,
1250
1245
  callLimit: t,
1251
1246
  isRejectAsValid: !0,
1252
1247
  isCheckBeforeCall: !1
1253
- }), this.cancelableConnectWithRepeatedCalls.then((r) => {
1254
- if ("ua" in r && r.ua instanceof this.JsSIP.UA)
1255
- return r;
1256
- throw r;
1248
+ }), this.cancelableConnectWithRepeatedCalls.then((i) => {
1249
+ if ("ua" in i && i.ua instanceof this.JsSIP.UA)
1250
+ return i;
1251
+ throw i;
1257
1252
  });
1258
1253
  };
1259
1254
  hasEqualConnectionConfiguration(e) {
1260
- const { configuration: t } = this.uaFactory.createConfiguration(e), i = this.getUa()?.configuration;
1261
- return i ? i.password === t.password && i.register === t.register && i.uri.toString() === t.uri && i.display_name === t.display_name && i.user_agent === t.user_agent && i.sockets === t.sockets && i.session_timers === t.session_timers && i.register_expires === t.register_expires && i.connection_recovery_min_interval === t.connection_recovery_min_interval && i.connection_recovery_max_interval === t.connection_recovery_max_interval : !1;
1255
+ const { configuration: t } = this.uaFactory.createConfiguration(e), r = this.getUa()?.configuration;
1256
+ return r ? r.password === t.password && r.register === t.register && r.uri.toString() === t.uri && r.display_name === t.display_name && r.user_agent === t.user_agent && r.sockets === t.sockets && r.session_timers === t.session_timers && r.register_expires === t.register_expires && r.connection_recovery_min_interval === t.connection_recovery_min_interval && r.connection_recovery_max_interval === t.connection_recovery_max_interval : !1;
1262
1257
  }
1263
1258
  connectInner = async (e) => this.initUa(e).then(async () => this.start()).then((t) => {
1264
1259
  const s = this.getConnectionConfiguration();
@@ -1273,21 +1268,21 @@ class St {
1273
1268
  user: e,
1274
1269
  password: t,
1275
1270
  sipServerUrl: s,
1276
- sipWebSocketServerURL: i,
1277
- remoteAddress: r,
1271
+ sipWebSocketServerURL: r,
1272
+ remoteAddress: i,
1278
1273
  sessionTimers: a,
1279
1274
  registerExpires: o,
1280
1275
  connectionRecoveryMinInterval: h,
1281
1276
  connectionRecoveryMaxInterval: d,
1282
1277
  userAgent: T,
1283
1278
  displayName: S = "",
1284
- register: u = !1,
1279
+ register: l = !1,
1285
1280
  extraHeaders: E = []
1286
1281
  }) => {
1287
1282
  this.stateMachine.startInitUa(), this.setConnectionConfiguration({
1288
1283
  sipServerUrl: s,
1289
1284
  displayName: S,
1290
- register: u,
1285
+ register: l,
1291
1286
  user: e,
1292
1287
  password: t
1293
1288
  }), this.getUa() && await this.disconnect();
@@ -1296,15 +1291,15 @@ class St {
1296
1291
  user: e,
1297
1292
  password: t,
1298
1293
  sipServerUrl: s,
1299
- sipWebSocketServerURL: i,
1294
+ sipWebSocketServerURL: r,
1300
1295
  displayName: S,
1301
- register: u,
1296
+ register: l,
1302
1297
  sessionTimers: a,
1303
1298
  registerExpires: o,
1304
1299
  connectionRecoveryMinInterval: h,
1305
1300
  connectionRecoveryMaxInterval: d,
1306
1301
  userAgent: T,
1307
- remoteAddress: r,
1302
+ remoteAddress: i,
1308
1303
  extraHeaders: E
1309
1304
  },
1310
1305
  this.events
@@ -1317,22 +1312,22 @@ class St {
1317
1312
  t(new Error("this.ua is not initialized"));
1318
1313
  return;
1319
1314
  }
1320
- let i;
1321
- i = ((h, d) => {
1315
+ let r;
1316
+ r = ((h, d) => {
1322
1317
  if (this.getConnectionConfiguration()?.register === !0)
1323
1318
  return this.registrationManager.subscribeToStartEvents(h, d);
1324
- const S = C.CONNECTED, u = [C.DISCONNECTED];
1325
- return this.events.on(S, h), u.forEach((E) => {
1319
+ const S = C.CONNECTED, l = [C.DISCONNECTED];
1320
+ return this.events.on(S, h), l.forEach((E) => {
1326
1321
  this.events.on(E, d);
1327
1322
  }), () => {
1328
- this.events.off(S, h), u.forEach((E) => {
1323
+ this.events.off(S, h), l.forEach((E) => {
1329
1324
  this.events.off(E, d);
1330
1325
  });
1331
1326
  };
1332
1327
  })(() => {
1333
- i?.(), e(s);
1328
+ r?.(), e(s);
1334
1329
  }, (h) => {
1335
- i?.(), t(h);
1330
+ r?.(), t(h);
1336
1331
  }), s.start();
1337
1332
  });
1338
1333
  cancelConnectWithRepeatedCalls() {
@@ -1348,8 +1343,8 @@ class St {
1348
1343
  });
1349
1344
  }
1350
1345
  }
1351
- var Te = /* @__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))(Te || {});
1352
- const Ct = ye({
1346
+ var ge = /* @__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))(ge || {});
1347
+ const St = Oe({
1353
1348
  types: {
1354
1349
  context: {},
1355
1350
  events: {}
@@ -1663,17 +1658,17 @@ const Ct = ye({
1663
1658
  }
1664
1659
  }
1665
1660
  });
1666
- class Et {
1661
+ class Ct {
1667
1662
  actor;
1668
1663
  stateChangeListeners = /* @__PURE__ */ new Set();
1669
1664
  events;
1670
1665
  unsubscribeFromEvents;
1671
1666
  actorSubscription;
1672
1667
  constructor(e) {
1673
- this.events = e, this.actor = De(Ct), this.actorSubscription = this.actor.subscribe((t) => {
1668
+ this.events = e, this.actor = ye(St), this.actorSubscription = this.actor.subscribe((t) => {
1674
1669
  const s = t.value;
1675
- this.stateChangeListeners.forEach((i) => {
1676
- i(s);
1670
+ this.stateChangeListeners.forEach((r) => {
1671
+ r(s);
1677
1672
  });
1678
1673
  }), this.actor.start(), this.subscribeToEvents();
1679
1674
  }
@@ -1756,7 +1751,7 @@ class Et {
1756
1751
  return this.actor.getSnapshot().can({ type: e });
1757
1752
  }
1758
1753
  getValidEvents() {
1759
- return Object.values(Te).filter((e) => this.canTransition(e));
1754
+ return Object.values(ge).filter((e) => this.canTransition(e));
1760
1755
  }
1761
1756
  hasState(e) {
1762
1757
  return this.actor.getSnapshot().matches(e);
@@ -1825,7 +1820,7 @@ class Et {
1825
1820
  };
1826
1821
  }
1827
1822
  }
1828
- class At {
1823
+ class Et {
1829
1824
  events;
1830
1825
  getUaProtected;
1831
1826
  constructor(e) {
@@ -1852,17 +1847,17 @@ class At {
1852
1847
  return this.register();
1853
1848
  }
1854
1849
  subscribeToStartEvents(e, t) {
1855
- const s = C.REGISTERED, i = [C.REGISTRATION_FAILED, C.DISCONNECTED];
1856
- return this.events.on(s, e), i.forEach((r) => {
1857
- this.events.on(r, t);
1850
+ const s = C.REGISTERED, r = [C.REGISTRATION_FAILED, C.DISCONNECTED];
1851
+ return this.events.on(s, e), r.forEach((i) => {
1852
+ this.events.on(i, t);
1858
1853
  }), () => {
1859
- this.events.off(s, e), i.forEach((r) => {
1860
- this.events.off(r, t);
1854
+ this.events.off(s, e), r.forEach((i) => {
1855
+ this.events.off(i, t);
1861
1856
  });
1862
1857
  };
1863
1858
  }
1864
1859
  }
1865
- class Rt {
1860
+ class At {
1866
1861
  uaFactory;
1867
1862
  getUaProtected;
1868
1863
  constructor(e) {
@@ -1872,14 +1867,14 @@ class Rt {
1872
1867
  * Отправляет SIP OPTIONS запрос к указанному адресу
1873
1868
  */
1874
1869
  async sendOptions(e, t, s) {
1875
- const i = this.getUaProtected();
1876
- return new Promise((r, a) => {
1870
+ const r = this.getUaProtected();
1871
+ return new Promise((i, a) => {
1877
1872
  try {
1878
- i.sendOptions(e, t, {
1873
+ r.sendOptions(e, t, {
1879
1874
  extraHeaders: s,
1880
1875
  eventHandlers: {
1881
1876
  succeeded: () => {
1882
- r();
1877
+ i();
1883
1878
  },
1884
1879
  failed: a
1885
1880
  }
@@ -1893,8 +1888,8 @@ class Rt {
1893
1888
  * Отправляет SIP OPTIONS запрос к собственному URI (ping)
1894
1889
  */
1895
1890
  async ping(e, t) {
1896
- const i = this.getUaProtected().configuration.uri;
1897
- return this.sendOptions(i, e, t);
1891
+ const r = this.getUaProtected().configuration.uri;
1892
+ return this.sendOptions(r, e, t);
1898
1893
  }
1899
1894
  /**
1900
1895
  * Проверяет доступность телефонии, создавая временное соединение
@@ -1903,35 +1898,35 @@ class Rt {
1903
1898
  userAgent: e,
1904
1899
  displayName: t,
1905
1900
  sipServerUrl: s,
1906
- sipWebSocketServerURL: i,
1907
- remoteAddress: r,
1901
+ sipWebSocketServerURL: r,
1902
+ remoteAddress: i,
1908
1903
  extraHeaders: a
1909
1904
  }) {
1910
1905
  return new Promise((o, h) => {
1911
1906
  const { configuration: d } = this.uaFactory.createConfiguration({
1912
- sipWebSocketServerURL: i,
1907
+ sipWebSocketServerURL: r,
1913
1908
  displayName: t,
1914
1909
  userAgent: e,
1915
1910
  sipServerUrl: s
1916
- }), T = this.uaFactory.createUA({ ...d, remoteAddress: r, extraHeaders: a }), S = () => {
1911
+ }), T = this.uaFactory.createUA({ ...d, remoteAddress: i, extraHeaders: a }), S = () => {
1917
1912
  const E = new Error("Telephony is not available");
1918
1913
  h(E);
1919
1914
  };
1920
1915
  T.once(C.DISCONNECTED, S);
1921
- const u = () => {
1916
+ const l = () => {
1922
1917
  T.removeAllListeners(), T.once(C.DISCONNECTED, () => {
1923
1918
  o();
1924
1919
  }), T.stop();
1925
1920
  };
1926
- T.once(C.CONNECTED, u), T.start();
1921
+ T.once(C.CONNECTED, l), T.start();
1927
1922
  });
1928
1923
  }
1929
1924
  }
1930
- const Nt = (n) => {
1925
+ const Rt = (n) => {
1931
1926
  const e = [];
1932
1927
  return n !== void 0 && n !== "" && e.push(`X-Vinteo-Remote: ${n}`), e;
1933
1928
  };
1934
- class y {
1929
+ class D {
1935
1930
  JsSIP;
1936
1931
  constructor(e) {
1937
1932
  this.JsSIP = e;
@@ -1943,12 +1938,12 @@ class y {
1943
1938
  register: e,
1944
1939
  password: t,
1945
1940
  user: s,
1946
- sipServerUrl: i,
1947
- sipWebSocketServerURL: r
1941
+ sipServerUrl: r,
1942
+ sipWebSocketServerURL: i
1948
1943
  }) {
1949
- if (!i)
1950
- throw new Error("sipServerUrl is required");
1951
1944
  if (!r)
1945
+ throw new Error("sipServerUrl is required");
1946
+ if (!i)
1952
1947
  throw new Error("sipWebSocketServerURL is required");
1953
1948
  if (e && (t === void 0 || t === ""))
1954
1949
  throw new Error("password is required for authorized connection");
@@ -1956,18 +1951,18 @@ class y {
1956
1951
  throw new Error("user is required for authorized connection");
1957
1952
  }
1958
1953
  static resolveAuthorizationUser(e, t) {
1959
- return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${We()}`;
1954
+ return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${He()}`;
1960
1955
  }
1961
1956
  static buildExtraHeaders(e, t) {
1962
- const s = e !== void 0 && e !== "" ? Nt(e) : [];
1957
+ const s = e !== void 0 && e !== "" ? Rt(e) : [];
1963
1958
  return t === void 0 ? s : [...s, ...t];
1964
1959
  }
1965
1960
  createConfiguration({
1966
1961
  user: e,
1967
1962
  password: t,
1968
1963
  sipWebSocketServerURL: s,
1969
- displayName: i = "",
1970
- sipServerUrl: r,
1964
+ displayName: r = "",
1965
+ sipServerUrl: i,
1971
1966
  register: a = !1,
1972
1967
  sessionTimers: o = !1,
1973
1968
  registerExpires: h = 300,
@@ -1976,20 +1971,20 @@ class y {
1976
1971
  connectionRecoveryMaxInterval: T = 6,
1977
1972
  userAgent: S
1978
1973
  }) {
1979
- y.validateParametersConnection({
1974
+ D.validateParametersConnection({
1980
1975
  register: a,
1981
1976
  password: t,
1982
1977
  user: e,
1983
- sipServerUrl: r,
1978
+ sipServerUrl: i,
1984
1979
  sipWebSocketServerURL: s
1985
1980
  });
1986
- const u = y.resolveAuthorizationUser(a, e), E = Ve(r), I = E(u), N = new this.JsSIP.WebSocketInterface(s);
1981
+ const l = D.resolveAuthorizationUser(a, e), E = qe(i), I = E(l), N = new this.JsSIP.WebSocketInterface(s);
1987
1982
  return {
1988
1983
  configuration: {
1989
1984
  password: t,
1990
1985
  register: a,
1991
1986
  uri: I,
1992
- display_name: ae(i),
1987
+ display_name: ie(r),
1993
1988
  user_agent: S,
1994
1989
  sdpSemantics: "unified-plan",
1995
1990
  sockets: [N],
@@ -2005,26 +2000,26 @@ class y {
2005
2000
  };
2006
2001
  }
2007
2002
  createUA({ remoteAddress: e, extraHeaders: t, ...s }) {
2008
- const i = new this.JsSIP.UA(s), r = y.buildExtraHeaders(e, t);
2009
- return r.length > 0 && i.registrator().setExtraHeaders(r), i;
2003
+ const r = new this.JsSIP.UA(s), i = D.buildExtraHeaders(e, t);
2004
+ return i.length > 0 && r.registrator().setExtraHeaders(i), r;
2010
2005
  }
2011
2006
  /**
2012
2007
  * Создает UA с полным жизненным циклом - конфигурация + создание + настройка событий
2013
2008
  */
2014
2009
  createUAWithConfiguration(e, t) {
2015
- const { configuration: s, helpers: i } = this.createConfiguration(e), r = this.createUA({
2010
+ const { configuration: s, helpers: r } = this.createConfiguration(e), i = this.createUA({
2016
2011
  ...s,
2017
2012
  remoteAddress: e.remoteAddress,
2018
2013
  extraHeaders: e.extraHeaders
2019
2014
  });
2020
2015
  return t.eachTriggers((a, o) => {
2021
- const h = ue.find((d) => d === o);
2022
- h && r.on(h, a);
2023
- }), { ua: r, helpers: i };
2016
+ const h = le.find((d) => d === o);
2017
+ h && i.on(h, a);
2018
+ }), { ua: i, helpers: r };
2024
2019
  }
2025
2020
  }
2026
- const Se = "Not ready for connection", mt = (n) => n instanceof Error && n.message === Se, It = () => new Error(Se), pt = async (n) => typeof n == "function" ? n() : n;
2027
- class _t {
2021
+ const Te = "Not ready for connection", Nt = (n) => n instanceof Error && n.message === Te, mt = () => new Error(Te), It = async (n) => typeof n == "function" ? n() : n;
2022
+ class pt {
2028
2023
  events;
2029
2024
  ua;
2030
2025
  socket;
@@ -2036,15 +2031,15 @@ class _t {
2036
2031
  configurationManager;
2037
2032
  JsSIP;
2038
2033
  constructor({ JsSIP: e }) {
2039
- this.JsSIP = e, this.events = new w(ge), this.uaFactory = new y(e), this.registrationManager = new At({
2034
+ this.JsSIP = e, this.events = new y(ue), this.uaFactory = new D(e), this.registrationManager = new Et({
2040
2035
  events: this.events,
2041
2036
  getUaProtected: this.getUaProtected
2042
- }), this.stateMachine = new Et(this.events), this.configurationManager = new ut({
2037
+ }), this.stateMachine = new Ct(this.events), this.configurationManager = new lt({
2043
2038
  getUa: this.getUa
2044
- }), this.sipOperations = new Rt({
2039
+ }), this.sipOperations = new At({
2045
2040
  uaFactory: this.uaFactory,
2046
2041
  getUaProtected: this.getUaProtected
2047
- }), this.connectionFlow = new St({
2042
+ }), this.connectionFlow = new Tt({
2048
2043
  JsSIP: this.JsSIP,
2049
2044
  events: this.events,
2050
2045
  uaFactory: this.uaFactory,
@@ -2091,7 +2086,7 @@ class _t {
2091
2086
  return this.stateMachine.state;
2092
2087
  }
2093
2088
  get isRegistered() {
2094
- return y.isRegisteredUA(this.ua);
2089
+ return D.isRegisteredUA(this.ua);
2095
2090
  }
2096
2091
  get isRegisterConfig() {
2097
2092
  return this.configurationManager.isRegister();
@@ -2146,28 +2141,28 @@ class _t {
2146
2141
  getUa = () => this.ua;
2147
2142
  connectWithProcessError = async (e, t) => {
2148
2143
  if (!(t?.hasReadyForConnection?.() ?? !0))
2149
- throw It();
2150
- return this.processConnect(e, t).catch(async (i) => {
2151
- const r = i;
2144
+ throw mt();
2145
+ return this.processConnect(e, t).catch(async (r) => {
2146
+ const i = r;
2152
2147
  return this.disconnect().then(() => {
2153
- throw r;
2148
+ throw i;
2154
2149
  }).catch(() => {
2155
- throw r;
2150
+ throw i;
2156
2151
  });
2157
2152
  });
2158
2153
  };
2159
- processConnect = async (e, t) => (this.events.trigger(C.CONNECT_STARTED, {}), pt(e).then((s) => (this.events.trigger(C.CONNECT_PARAMETERS_RESOLVE_SUCCESS, s), s)).catch((s) => {
2154
+ processConnect = async (e, t) => (this.events.trigger(C.CONNECT_STARTED, {}), It(e).then((s) => (this.events.trigger(C.CONNECT_PARAMETERS_RESOLVE_SUCCESS, s), s)).catch((s) => {
2160
2155
  throw this.events.trigger(C.CONNECT_PARAMETERS_RESOLVE_FAILED, s), s;
2161
2156
  }).then(async (s) => this.connectionFlow.connect(s, t)).then((s) => (this.events.trigger(C.CONNECT_SUCCEEDED, {
2162
2157
  ...s
2163
2158
  }), s)).catch((s) => {
2164
- const i = s ?? new Error("Failed to connect to server");
2165
- throw this.events.trigger(C.CONNECT_FAILED, i), i;
2159
+ const r = s ?? new Error("Failed to connect to server");
2160
+ throw this.events.trigger(C.CONNECT_FAILED, r), r;
2166
2161
  }));
2167
2162
  }
2168
- class Mt {
2163
+ class _t {
2169
2164
  connectionManager;
2170
- stackPromises = ne({
2165
+ stackPromises = te({
2171
2166
  noRunIsNotActual: !0
2172
2167
  });
2173
2168
  constructor({ connectionManager: e }) {
@@ -2179,11 +2174,11 @@ class Mt {
2179
2174
  this.stackPromises.stop();
2180
2175
  }
2181
2176
  }
2182
- const z = 0, vt = 30;
2177
+ const Y = 0, Mt = 30;
2183
2178
  class ft {
2184
- countInner = z;
2185
- initialCount = z;
2186
- limitInner = vt;
2179
+ countInner = Y;
2180
+ initialCount = Y;
2181
+ limitInner = Mt;
2187
2182
  isInProgress = !1;
2188
2183
  onStatusChange;
2189
2184
  constructor({
@@ -2216,7 +2211,7 @@ class ft {
2216
2211
  this.countInner = this.initialCount, this.finishAttempt();
2217
2212
  }
2218
2213
  }
2219
- class Pt {
2214
+ class vt {
2220
2215
  connectionManager;
2221
2216
  interval;
2222
2217
  checkTelephonyByTimeout = void 0;
@@ -2232,14 +2227,14 @@ class Pt {
2232
2227
  onSuccessRequest: t,
2233
2228
  onFailRequest: s
2234
2229
  }) {
2235
- this.stop(), this.cancelableBeforeRequest = new G(e), this.checkTelephonyByTimeout = Me({
2230
+ this.stop(), this.cancelableBeforeRequest = new x(e), this.checkTelephonyByTimeout = _e({
2236
2231
  isDontStopOnFail: !0,
2237
2232
  requestInterval: this.interval,
2238
2233
  request: async () => {
2239
2234
  if (!this.cancelableBeforeRequest)
2240
2235
  throw new Error("cancelableBeforeRequest is not defined");
2241
- const i = await this.cancelableBeforeRequest.request();
2242
- return this.connectionManager.checkTelephony(i);
2236
+ const r = await this.cancelableBeforeRequest.request();
2237
+ return this.connectionManager.checkTelephony(r);
2243
2238
  }
2244
2239
  }), this.checkTelephonyByTimeout.start(void 0, {
2245
2240
  onFailRequest: s,
@@ -2253,7 +2248,7 @@ class Pt {
2253
2248
  }
2254
2249
  }
2255
2250
  var _ = /* @__PURE__ */ ((n) => (n.BEFORE_ATTEMPT = "before-attempt", n.SUCCESS = "success", n.FAILED_ALL_ATTEMPTS = "failed-all-attempts", n.CANCELLED_ATTEMPTS = "cancelled-attempts", n.CHANGED_ATTEMPT_STATUS = "changed-attempt-status", n.STOP_ATTEMPTS_BY_ERROR = "stop-attempts-by-error", n.LIMIT_REACHED_ATTEMPTS = "limit-reached-attempts", n))(_ || {});
2256
- const Ce = [
2251
+ const Se = [
2257
2252
  "before-attempt",
2258
2253
  "success",
2259
2254
  "failed-all-attempts",
@@ -2261,15 +2256,15 @@ const Ce = [
2261
2256
  "changed-attempt-status",
2262
2257
  "stop-attempts-by-error",
2263
2258
  "limit-reached-attempts"
2264
- ], Ot = 15e3, yt = 2;
2265
- class Dt {
2259
+ ], Pt = 15e3, Ot = 2;
2260
+ class yt {
2266
2261
  connectionManager;
2267
2262
  pingServerByTimeoutWithFailCalls;
2268
2263
  constructor({ connectionManager: e }) {
2269
- this.connectionManager = e, this.pingServerByTimeoutWithFailCalls = ve(yt, {
2264
+ this.connectionManager = e, this.pingServerByTimeoutWithFailCalls = Me(Ot, {
2270
2265
  whenPossibleRequest: async () => {
2271
2266
  },
2272
- requestInterval: Ot,
2267
+ requestInterval: Pt,
2273
2268
  request: async () => (c("ping"), this.connectionManager.ping().then(() => {
2274
2269
  c("ping success");
2275
2270
  }))
@@ -2282,7 +2277,7 @@ class Dt {
2282
2277
  this.pingServerByTimeoutWithFailCalls.stop();
2283
2278
  }
2284
2279
  }
2285
- class bt {
2280
+ class Dt {
2286
2281
  callManager;
2287
2282
  pingServerRequester;
2288
2283
  disposeCallStatusChange;
@@ -2290,7 +2285,7 @@ class bt {
2290
2285
  connectionManager: e,
2291
2286
  callManager: t
2292
2287
  }) {
2293
- this.callManager = t, this.pingServerRequester = new Dt({
2288
+ this.callManager = t, this.pingServerRequester = new yt({
2294
2289
  connectionManager: e
2295
2290
  });
2296
2291
  }
@@ -2309,7 +2304,7 @@ class bt {
2309
2304
  this.callManager.isCallActive ? this.pingServerRequester.stop() : this.pingServerRequester.start({ onFailRequest: e });
2310
2305
  }
2311
2306
  }
2312
- class wt {
2307
+ class bt {
2313
2308
  connectionManager;
2314
2309
  callManager;
2315
2310
  isRegistrationFailed = !1;
@@ -2343,12 +2338,12 @@ class wt {
2343
2338
  this.isRegistrationFailed = !1;
2344
2339
  }
2345
2340
  }
2346
- const Ut = 3e3, Lt = 15e3, X = {
2341
+ const wt = 3e3, Ut = 15e3, z = {
2347
2342
  LIMIT_REACHED: "Limit reached",
2348
2343
  FAILED_TO_RECONNECT: "Failed to reconnect"
2349
- }, Bt = async () => {
2350
- }, Ft = (n) => !0;
2351
- class kt {
2344
+ }, Lt = async () => {
2345
+ }, Bt = (n) => !0;
2346
+ class Ft {
2352
2347
  events;
2353
2348
  connectionManager;
2354
2349
  connectionQueueManager;
@@ -2366,28 +2361,30 @@ class kt {
2366
2361
  connectionQueueManager: e,
2367
2362
  connectionManager: t,
2368
2363
  callManager: s
2369
- }, i) {
2370
- const r = i?.onBeforeRetry ?? Bt, a = i?.canRetryOnError ?? Ft;
2371
- this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.canRetryOnError = a, this.networkInterfacesSubscriber = i?.networkInterfacesSubscriber, this.resumeFromSleepModeSubscriber = i?.resumeFromSleepModeSubscriber, this.events = new w(Ce), this.checkTelephonyRequester = new Pt({
2364
+ }, r) {
2365
+ const i = r?.onBeforeRetry ?? Lt, a = r?.canRetryOnError ?? Bt;
2366
+ this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = i, this.canRetryOnError = a, this.networkInterfacesSubscriber = r?.networkInterfacesSubscriber, this.resumeFromSleepModeSubscriber = r?.resumeFromSleepModeSubscriber, this.events = new y(Se), this.checkTelephonyRequester = new vt({
2372
2367
  connectionManager: t,
2373
- interval: i?.checkTelephonyRequestInterval ?? Lt
2374
- }), this.pingServerIfNotActiveCallRequester = new bt({
2368
+ interval: r?.checkTelephonyRequestInterval ?? Ut
2369
+ }), this.pingServerIfNotActiveCallRequester = new Dt({
2375
2370
  connectionManager: t,
2376
2371
  callManager: s
2377
- }), this.registrationFailedOutOfCallSubscriber = new wt({
2372
+ }), this.registrationFailedOutOfCallSubscriber = new bt({
2378
2373
  connectionManager: t,
2379
2374
  callManager: s
2380
2375
  }), this.attemptsState = new ft({
2381
2376
  onStatusChange: this.emitStatusChange
2382
- }), this.cancelableRequestBeforeRetry = new G(r), this.delayBetweenAttempts = new fe(
2383
- i?.timeoutBetweenAttempts ?? Ut
2377
+ }), this.cancelableRequestBeforeRetry = new x(i), this.delayBetweenAttempts = new fe(
2378
+ r?.timeoutBetweenAttempts ?? wt
2384
2379
  );
2385
2380
  }
2386
2381
  start(e) {
2387
2382
  c("auto connector start"), this.restartConnectionAttempts(e), this.subscribeToHardwareTriggers(e);
2388
2383
  }
2389
2384
  stop() {
2390
- c("auto connector stop"), this.unsubscribeFromHardwareTriggers(), this.stopConnectionFlow();
2385
+ c("auto connector stop"), this.unsubscribeFromHardwareTriggers(), this.stopConnectionFlow().catch((e) => {
2386
+ c("auto connector stop from stop method: error", e);
2387
+ });
2391
2388
  }
2392
2389
  on(e, t) {
2393
2390
  return this.events.on(e, t);
@@ -2405,14 +2402,12 @@ class kt {
2405
2402
  this.events.off(e, t);
2406
2403
  }
2407
2404
  restartConnectionAttempts(e) {
2408
- c("auto connector restart connection attempts"), this.stopConnectionFlow(), this.attemptConnection(e).catch((t) => {
2409
- c("auto connector failed to connect:", t);
2405
+ c("auto connector restart connection attempts"), this.stopConnectionFlow().then(async () => this.attemptConnection(e)).catch((t) => {
2406
+ c("auto connector failed to restart connection attempts:", t);
2410
2407
  });
2411
2408
  }
2412
- stopConnectionFlow() {
2413
- c("stopConnectionFlow"), this.stopAttempts(), this.stopConnectTriggers(), this.connectionQueueManager.disconnect().catch((e) => {
2414
- c("auto connector disconnect: error", e);
2415
- });
2409
+ async stopConnectionFlow() {
2410
+ c("stopConnectionFlow"), this.stopAttempts(), this.stopConnectTriggers(), await this.connectionQueueManager.disconnect();
2416
2411
  }
2417
2412
  stopAttempts() {
2418
2413
  this.attemptsState.isAttemptInProgress && this.connectionQueueManager.stop(), this.delayBetweenAttempts.cancelRequest(), this.cancelableRequestBeforeRetry.cancelRequest(), this.attemptsState.reset();
@@ -2446,7 +2441,7 @@ class kt {
2446
2441
  }
2447
2442
  }
2448
2443
  handleConnectionError(e, t) {
2449
- if (mt(e)) {
2444
+ if (Nt(e)) {
2450
2445
  this.attemptsState.finishAttempt(), this.events.trigger(_.STOP_ATTEMPTS_BY_ERROR, e);
2451
2446
  return;
2452
2447
  }
@@ -2454,14 +2449,14 @@ class kt {
2454
2449
  c("executeConnectionAttempt: error does not allow retry", e), this.attemptsState.finishAttempt(), this.events.trigger(_.STOP_ATTEMPTS_BY_ERROR, e);
2455
2450
  return;
2456
2451
  }
2457
- if (be(e)) {
2452
+ if (De(e)) {
2458
2453
  c("executeConnectionAttempt: not actual error", e), this.attemptsState.finishAttempt(), this.events.trigger(_.CANCELLED_ATTEMPTS, e);
2459
2454
  return;
2460
2455
  }
2461
2456
  c("executeConnectionAttempt: error", e), this.scheduleReconnect(t);
2462
2457
  }
2463
2458
  handleLimitReached(e) {
2464
- this.attemptsState.finishAttempt(), this.events.trigger(_.LIMIT_REACHED_ATTEMPTS, new Error(X.LIMIT_REACHED)), this.startCheckTelephony(e);
2459
+ this.attemptsState.finishAttempt(), this.events.trigger(_.LIMIT_REACHED_ATTEMPTS, new Error(z.LIMIT_REACHED)), this.startCheckTelephony(e);
2465
2460
  }
2466
2461
  handleSucceededAttempt(e) {
2467
2462
  c("handleSucceededAttempt"), this.subscribeToConnectTriggers(e), this.events.trigger(_.SUCCESS);
@@ -2477,7 +2472,12 @@ class kt {
2477
2472
  c("networkInterfacesSubscriber onChange"), this.restartConnectionAttempts(e);
2478
2473
  },
2479
2474
  onUnavailable: () => {
2480
- c("networkInterfacesSubscriber onUnavailable"), this.stopConnectionFlow();
2475
+ c("networkInterfacesSubscriber onUnavailable"), this.stopConnectionFlow().catch((t) => {
2476
+ c(
2477
+ "auto connector stop from networkInterfacesSubscriber onUnavailable: error",
2478
+ t
2479
+ );
2480
+ });
2481
2481
  }
2482
2482
  }), this.resumeFromSleepModeSubscriber?.subscribe({
2483
2483
  onResume: () => {
@@ -2504,8 +2504,8 @@ class kt {
2504
2504
  }
2505
2505
  scheduleReconnect(e) {
2506
2506
  c("scheduleReconnect"), this.delayBetweenAttempts.request().then(async () => (c("scheduleReconnect: delayBetweenAttempts success"), this.cancelableRequestBeforeRetry.request())).then(async () => (c("scheduleReconnect: onBeforeRetry success"), this.attemptConnection(e))).catch((t) => {
2507
- const s = t instanceof Error ? t : new Error(X.FAILED_TO_RECONNECT);
2508
- this.attemptsState.finishAttempt(), _e(t) || Pe(t) ? this.events.trigger(_.CANCELLED_ATTEMPTS, s) : this.events.trigger(_.FAILED_ALL_ATTEMPTS, s), c("scheduleReconnect: error", t);
2507
+ const s = t instanceof Error ? t : new Error(z.FAILED_TO_RECONNECT);
2508
+ this.attemptsState.finishAttempt(), pe(t) || ve(t) ? this.events.trigger(_.CANCELLED_ATTEMPTS, s) : this.events.trigger(_.FAILED_ALL_ATTEMPTS, s), c("scheduleReconnect: error", t);
2509
2509
  });
2510
2510
  }
2511
2511
  isConnectionUnavailable() {
@@ -2516,19 +2516,19 @@ class kt {
2516
2516
  this.events.trigger(_.CHANGED_ATTEMPT_STATUS, { isInProgress: e });
2517
2517
  };
2518
2518
  }
2519
- var b = /* @__PURE__ */ ((n) => (n.INCOMING_CALL = "incomingCall", n.DECLINED_INCOMING_CALL = "declinedIncomingCall", n.TERMINATED_INCOMING_CALL = "terminatedIncomingCall", n.FAILED_INCOMING_CALL = "failedIncomingCall", n))(b || {});
2520
- const Ee = [
2519
+ var w = /* @__PURE__ */ ((n) => (n.INCOMING_CALL = "incomingCall", n.DECLINED_INCOMING_CALL = "declinedIncomingCall", n.TERMINATED_INCOMING_CALL = "terminatedIncomingCall", n.FAILED_INCOMING_CALL = "failedIncomingCall", n))(w || {});
2520
+ const Ce = [
2521
2521
  "incomingCall",
2522
2522
  "declinedIncomingCall",
2523
2523
  "terminatedIncomingCall",
2524
2524
  "failedIncomingCall"
2525
- ], $t = 486, qt = 487;
2526
- class Vt {
2525
+ ], kt = 486, $t = 487;
2526
+ class qt {
2527
2527
  events;
2528
2528
  incomingRTCSession;
2529
2529
  connectionManager;
2530
2530
  constructor(e) {
2531
- this.connectionManager = e, this.events = new F(Ee), this.start();
2531
+ this.connectionManager = e, this.events = new y(Ce), this.start();
2532
2532
  }
2533
2533
  get remoteCallerData() {
2534
2534
  return {
@@ -2558,36 +2558,32 @@ class Vt {
2558
2558
  return this.removeIncomingSession(), e;
2559
2559
  };
2560
2560
  async declineToIncomingCall({
2561
- statusCode: e = qt
2561
+ statusCode: e = $t
2562
2562
  } = {}) {
2563
2563
  return new Promise((t, s) => {
2564
2564
  try {
2565
- const i = this.getIncomingRTCSession(), r = this.remoteCallerData;
2566
- this.removeIncomingSession(), this.events.trigger(b.DECLINED_INCOMING_CALL, r), i.terminate({ status_code: e }), t();
2567
- } catch (i) {
2568
- s(i);
2565
+ const r = this.getIncomingRTCSession(), i = this.remoteCallerData;
2566
+ this.removeIncomingSession(), this.events.trigger(w.DECLINED_INCOMING_CALL, i), r.terminate({ status_code: e }), t();
2567
+ } catch (r) {
2568
+ s(r);
2569
2569
  }
2570
2570
  });
2571
2571
  }
2572
2572
  async busyIncomingCall() {
2573
- return this.declineToIncomingCall({ statusCode: $t });
2573
+ return this.declineToIncomingCall({ statusCode: kt });
2574
2574
  }
2575
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2576
2575
  on(e, t) {
2577
2576
  return this.events.on(e, t);
2578
2577
  }
2579
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2580
2578
  once(e, t) {
2581
2579
  return this.events.once(e, t);
2582
2580
  }
2583
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2584
2581
  onceRace(e, t) {
2585
2582
  return this.events.onceRace(e, t);
2586
2583
  }
2587
2584
  async wait(e) {
2588
2585
  return this.events.wait(e);
2589
2586
  }
2590
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2591
2587
  off(e, t) {
2592
2588
  this.events.off(e, t);
2593
2589
  }
@@ -2607,19 +2603,19 @@ class Vt {
2607
2603
  this.incomingRTCSession = e;
2608
2604
  const t = this.remoteCallerData;
2609
2605
  e.on("failed", (s) => {
2610
- this.removeIncomingSession(), s.originator === "local" ? this.events.trigger(b.TERMINATED_INCOMING_CALL, t) : this.events.trigger(b.FAILED_INCOMING_CALL, t);
2611
- }), this.events.trigger(b.INCOMING_CALL, t);
2606
+ this.removeIncomingSession(), s.originator === "local" ? this.events.trigger(w.TERMINATED_INCOMING_CALL, t) : this.events.trigger(w.FAILED_INCOMING_CALL, t);
2607
+ }), this.events.trigger(w.INCOMING_CALL, t);
2612
2608
  }
2613
2609
  removeIncomingSession() {
2614
2610
  delete this.incomingRTCSession;
2615
2611
  }
2616
2612
  }
2617
- const D = 1e3;
2613
+ const b = 1e3;
2618
2614
  var A = /* @__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))(A || {});
2619
- const Ae = ["collected"], J = () => "performance" in window ? performance.now() : Date.now(), U = (n) => [...n.keys()].reduce((e, t) => {
2615
+ const Ee = ["collected"], X = () => "performance" in window ? performance.now() : Date.now(), U = (n) => [...n.keys()].reduce((e, t) => {
2620
2616
  const s = n.get(t);
2621
2617
  return s === void 0 ? e : { ...e, [s.type]: s };
2622
- }, {}), Ht = (n) => {
2618
+ }, {}), Vt = (n) => {
2623
2619
  if (!n)
2624
2620
  return {
2625
2621
  outboundRtp: void 0,
@@ -2634,7 +2630,7 @@ const Ae = ["collected"], J = () => "performance" in window ? performance.now()
2634
2630
  mediaSource: e[A.MEDIA_SOURCE],
2635
2631
  remoteInboundRtp: e[A.REMOTE_INBOUND_RTP]
2636
2632
  };
2637
- }, K = (n) => {
2633
+ }, J = (n) => {
2638
2634
  if (!n)
2639
2635
  return {
2640
2636
  outboundRtp: void 0,
@@ -2649,7 +2645,7 @@ const Ae = ["collected"], J = () => "performance" in window ? performance.now()
2649
2645
  mediaSource: e[A.MEDIA_SOURCE],
2650
2646
  remoteInboundRtp: e[A.REMOTE_INBOUND_RTP]
2651
2647
  };
2652
- }, j = ({
2648
+ }, K = ({
2653
2649
  videoReceiversStats: n,
2654
2650
  synchronizationSourcesVideo: e
2655
2651
  }) => {
@@ -2665,7 +2661,7 @@ const Ae = ["collected"], J = () => "performance" in window ? performance.now()
2665
2661
  codec: t[A.CODEC],
2666
2662
  synchronizationSources: e
2667
2663
  };
2668
- }, Wt = ({
2664
+ }, Ht = ({
2669
2665
  audioReceiverStats: n,
2670
2666
  synchronizationSourcesAudio: e
2671
2667
  }) => {
@@ -2683,7 +2679,7 @@ const Ae = ["collected"], J = () => "performance" in window ? performance.now()
2683
2679
  remoteOutboundRtp: t[A.REMOTE_OUTBOUND_RTP],
2684
2680
  synchronizationSources: e
2685
2681
  };
2686
- }, Re = (n) => {
2682
+ }, Ae = (n) => {
2687
2683
  if (!n)
2688
2684
  return {
2689
2685
  candidatePair: void 0,
@@ -2700,63 +2696,63 @@ const Ae = ["collected"], J = () => "performance" in window ? performance.now()
2700
2696
  remoteCandidate: e[A.REMOTE_CANDIDATE],
2701
2697
  transport: e[A.TRANSPORT]
2702
2698
  };
2703
- }, xt = ({
2699
+ }, Wt = ({
2704
2700
  audioSenderStats: n,
2705
2701
  videoSenderFirstStats: e,
2706
2702
  videoSenderSecondStats: t
2707
2703
  }) => ({
2708
- video: K(e),
2709
- secondVideo: K(t),
2710
- audio: Ht(n),
2711
- additional: Re(
2704
+ video: J(e),
2705
+ secondVideo: J(t),
2706
+ audio: Vt(n),
2707
+ additional: Ae(
2712
2708
  n ?? e ?? t
2713
2709
  )
2714
- }), Gt = ({
2710
+ }), xt = ({
2715
2711
  audioReceiverStats: n,
2716
2712
  videoReceiverFirstStats: e,
2717
2713
  videoReceiverSecondStats: t,
2718
2714
  synchronizationSources: s
2719
2715
  }) => ({
2720
- video: j({
2716
+ video: K({
2721
2717
  videoReceiversStats: e,
2722
2718
  synchronizationSourcesVideo: s.video
2723
2719
  }),
2724
- secondVideo: j({
2720
+ secondVideo: K({
2725
2721
  videoReceiversStats: t,
2726
2722
  synchronizationSourcesVideo: s.video
2727
2723
  }),
2728
- audio: Wt({
2724
+ audio: Ht({
2729
2725
  audioReceiverStats: n,
2730
2726
  synchronizationSourcesAudio: s.audio
2731
2727
  }),
2732
- additional: Re(
2728
+ additional: Ae(
2733
2729
  n ?? e ?? t
2734
2730
  )
2735
- }), Qt = ({
2731
+ }), Gt = ({
2736
2732
  audioSenderStats: n,
2737
2733
  videoSenderFirstStats: e,
2738
2734
  videoSenderSecondStats: t,
2739
2735
  audioReceiverStats: s,
2740
- videoReceiverFirstStats: i,
2741
- videoReceiverSecondStats: r,
2736
+ videoReceiverFirstStats: r,
2737
+ videoReceiverSecondStats: i,
2742
2738
  synchronizationSources: a
2743
2739
  }) => {
2744
- const o = xt({
2740
+ const o = Wt({
2745
2741
  audioSenderStats: n,
2746
2742
  videoSenderFirstStats: e,
2747
2743
  videoSenderSecondStats: t
2748
- }), h = Gt({
2744
+ }), h = xt({
2749
2745
  audioReceiverStats: s,
2750
- videoReceiverFirstStats: i,
2751
- videoReceiverSecondStats: r,
2746
+ videoReceiverFirstStats: r,
2747
+ videoReceiverSecondStats: i,
2752
2748
  synchronizationSources: a
2753
2749
  });
2754
2750
  return {
2755
2751
  outbound: o,
2756
2752
  inbound: h
2757
2753
  };
2758
- }, Yt = async (n) => {
2759
- const e = "audio", t = "video", s = n.getSenders(), i = s.find((u) => u.track?.kind === e), r = s.filter((u) => u.track?.kind === t), a = n.getReceivers(), o = a.find((u) => u.track.kind === e), h = a.filter((u) => u.track.kind === t), d = {
2754
+ }, Qt = async (n) => {
2755
+ const e = "audio", t = "video", s = n.getSenders(), r = s.find((l) => l.track?.kind === e), i = s.filter((l) => l.track?.kind === t), a = n.getReceivers(), o = a.find((l) => l.track.kind === e), h = a.filter((l) => l.track.kind === t), d = {
2760
2756
  trackIdentifier: o?.track.id,
2761
2757
  item: o?.getSynchronizationSources()[0]
2762
2758
  }, T = {
@@ -2767,47 +2763,47 @@ const Ae = ["collected"], J = () => "performance" in window ? performance.now()
2767
2763
  video: T
2768
2764
  };
2769
2765
  return Promise.all([
2770
- i?.getStats() ?? Promise.resolve(void 0),
2771
- r[0]?.getStats() ?? Promise.resolve(void 0),
2772
- r[1]?.getStats() ?? Promise.resolve(void 0),
2766
+ r?.getStats() ?? Promise.resolve(void 0),
2767
+ i[0]?.getStats() ?? Promise.resolve(void 0),
2768
+ i[1]?.getStats() ?? Promise.resolve(void 0),
2773
2769
  o?.getStats() ?? Promise.resolve(void 0),
2774
2770
  h[0]?.getStats() ?? Promise.resolve(void 0),
2775
2771
  h[1]?.getStats() ?? Promise.resolve(void 0)
2776
- ]).then((u) => {
2772
+ ]).then((l) => {
2777
2773
  const [
2778
2774
  E,
2779
2775
  I,
2780
2776
  N,
2781
2777
  M,
2782
- k,
2783
- $
2784
- ] = u;
2778
+ F,
2779
+ k
2780
+ ] = l;
2785
2781
  return {
2786
2782
  synchronizationSources: S,
2787
2783
  audioSenderStats: E,
2788
2784
  videoSenderFirstStats: I,
2789
2785
  videoSenderSecondStats: N,
2790
2786
  audioReceiverStats: M,
2791
- videoReceiverFirstStats: k,
2792
- videoReceiverSecondStats: $
2787
+ videoReceiverFirstStats: F,
2788
+ videoReceiverSecondStats: k
2793
2789
  };
2794
2790
  });
2795
- }, zt = (n) => {
2791
+ }, Yt = (n) => {
2796
2792
  c(String(n));
2797
2793
  };
2798
- class Xt {
2794
+ class zt {
2799
2795
  events;
2800
2796
  setTimeoutRequest;
2801
- requesterAllStatistics = new G(Yt);
2797
+ requesterAllStatistics = new x(Qt);
2802
2798
  constructor() {
2803
- this.events = new w(Ae), this.setTimeoutRequest = new ee();
2799
+ this.events = new y(Ee), this.setTimeoutRequest = new Z();
2804
2800
  }
2805
2801
  get requested() {
2806
2802
  return this.setTimeoutRequest.requested;
2807
2803
  }
2808
2804
  start(e, {
2809
- interval: t = D,
2810
- onError: s = zt
2805
+ interval: t = b,
2806
+ onError: s = Yt
2811
2807
  } = {}) {
2812
2808
  this.stop(), this.setTimeoutRequest.request(() => {
2813
2809
  this.collectStatistics(e, {
@@ -2836,21 +2832,21 @@ class Xt {
2836
2832
  collectStatistics = (e, {
2837
2833
  onError: t
2838
2834
  }) => {
2839
- const s = J();
2840
- this.requesterAllStatistics.request(e).then((i) => {
2841
- this.events.trigger("collected", Qt(i));
2842
- const a = J() - s;
2843
- let o = D;
2844
- a > 48 ? o = D * 4 : a > 32 ? o = D * 3 : a > 16 && (o = D * 2), this.start(e, {
2835
+ const s = X();
2836
+ this.requesterAllStatistics.request(e).then((r) => {
2837
+ this.events.trigger("collected", Gt(r));
2838
+ const a = X() - s;
2839
+ let o = b;
2840
+ a > 48 ? o = b * 4 : a > 32 ? o = b * 3 : a > 16 && (o = b * 2), this.start(e, {
2845
2841
  onError: t,
2846
2842
  interval: o
2847
2843
  });
2848
- }).catch((i) => {
2849
- t && t(i);
2844
+ }).catch((r) => {
2845
+ t && t(r);
2850
2846
  });
2851
2847
  };
2852
2848
  }
2853
- class Jt {
2849
+ class Xt {
2854
2850
  availableIncomingBitrate;
2855
2851
  statsPeerConnection;
2856
2852
  callManager;
@@ -2860,7 +2856,7 @@ class Jt {
2860
2856
  callManager: e,
2861
2857
  apiManager: t
2862
2858
  }) {
2863
- this.callManager = e, this.apiManager = t, this.statsPeerConnection = new Xt(), this.subscribe();
2859
+ this.callManager = e, this.apiManager = t, this.statsPeerConnection = new zt(), this.subscribe();
2864
2860
  }
2865
2861
  get events() {
2866
2862
  return this.statsPeerConnection.events;
@@ -2902,26 +2898,26 @@ class Jt {
2902
2898
  });
2903
2899
  }
2904
2900
  }
2905
- const Kt = (n, e) => n.filter((s) => e.some((i) => i.clockRate === s.clockRate && i.mimeType === s.mimeType && i.channels === s.channels && i.sdpFmtpLine === s.sdpFmtpLine)), jt = (n) => {
2906
- const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs, i = t === null ? [] : t.codecs;
2907
- return Kt(s, i);
2908
- }, Zt = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
2909
- 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;
2901
+ const Jt = (n, e) => n.filter((s) => e.some((r) => r.clockRate === s.clockRate && r.mimeType === s.mimeType && r.channels === s.channels && r.sdpFmtpLine === s.sdpFmtpLine)), Kt = (n) => {
2902
+ const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs, r = t === null ? [] : t.codecs;
2903
+ return Jt(s, r);
2904
+ }, jt = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
2905
+ const r = e.indexOf(t.mimeType), i = e.indexOf(s.mimeType), a = r === -1 ? Number.MAX_VALUE : r, o = i === -1 ? Number.MAX_VALUE : i;
2910
2906
  return a - o;
2911
- }), en = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), tn = (n, {
2907
+ }), Zt = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), en = (n, {
2912
2908
  preferredMimeTypesVideoCodecs: e,
2913
2909
  excludeMimeTypesVideoCodecs: t
2914
2910
  }) => {
2915
2911
  try {
2916
2912
  if (typeof n.setCodecPreferences == "function" && n.sender.track?.kind === "video" && (e !== void 0 && e.length > 0 || t !== void 0 && t.length > 0)) {
2917
- const s = jt("video"), i = en(s, t), r = Zt(i, e);
2918
- n.setCodecPreferences(r);
2913
+ const s = Kt("video"), r = Zt(s, t), i = jt(r, e);
2914
+ n.setCodecPreferences(i);
2919
2915
  }
2920
2916
  } catch (s) {
2921
2917
  c("setCodecPreferences error", s);
2922
2918
  }
2923
2919
  };
2924
- class nn {
2920
+ class tn {
2925
2921
  /**
2926
2922
  * Хранилище основных transceiver'ов
2927
2923
  */
@@ -2942,8 +2938,8 @@ class nn {
2942
2938
  if (s === "audio")
2943
2939
  this.transceivers.mainAudio ??= e;
2944
2940
  else {
2945
- const { mid: i } = e;
2946
- i === "2" ? this.transceivers.presentationVideo ??= e : this.transceivers.mainVideo ??= e;
2941
+ const { mid: r } = e;
2942
+ r === "2" ? this.transceivers.presentationVideo ??= e : this.transceivers.mainVideo ??= e;
2947
2943
  }
2948
2944
  }
2949
2945
  /**
@@ -3014,8 +3010,8 @@ class nn {
3014
3010
  const { videoTrackCount: t } = e;
3015
3011
  t === 2 && (this.getTransceivers().presentationVideo !== void 0 || await this.callManager.addTransceiver("video", {
3016
3012
  direction: "recvonly"
3017
- }).catch((r) => {
3018
- c("Failed to add presentation video transceiver", r);
3013
+ }).catch((i) => {
3014
+ c("Failed to add presentation video transceiver", i);
3019
3015
  }));
3020
3016
  };
3021
3017
  subscribe() {
@@ -3028,15 +3024,15 @@ class nn {
3028
3024
  this.clear();
3029
3025
  };
3030
3026
  }
3031
- const sn = (n) => [...n.keys()].map((e) => n.get(e)), rn = (n, e) => sn(n).find((t) => t?.type === e), an = async (n) => n.getStats().then((e) => rn(e, "codec")?.mimeType);
3032
- class on {
3027
+ const nn = (n) => [...n.keys()].map((e) => n.get(e)), sn = (n, e) => nn(n).find((t) => t?.type === e), rn = async (n) => n.getStats().then((e) => sn(e, "codec")?.mimeType);
3028
+ class an {
3033
3029
  // eslint-disable-next-line @typescript-eslint/class-methods-use-this
3034
3030
  async getCodecFromSender(e) {
3035
- return await an(e) ?? "";
3031
+ return await rn(e) ?? "";
3036
3032
  }
3037
3033
  }
3038
- class cn {
3039
- stackPromises = ne({
3034
+ class on {
3035
+ stackPromises = te({
3040
3036
  noRunIsNotActual: !0
3041
3037
  });
3042
3038
  /**
@@ -3060,30 +3056,30 @@ class cn {
3060
3056
  });
3061
3057
  }
3062
3058
  }
3063
- class hn {
3059
+ class cn {
3064
3060
  taskQueue;
3065
3061
  onSetParameters;
3066
3062
  constructor(e) {
3067
- this.onSetParameters = e, this.taskQueue = new cn();
3063
+ this.onSetParameters = e, this.taskQueue = new on();
3068
3064
  }
3069
3065
  async setEncodingsToSender(e, t) {
3070
- return this.taskQueue.add(async () => de(e, t, this.onSetParameters));
3066
+ return this.taskQueue.add(async () => he(e, t, this.onSetParameters));
3071
3067
  }
3072
3068
  stop() {
3073
3069
  this.taskQueue.stop();
3074
3070
  }
3075
3071
  }
3076
- const Ne = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), dn = 1e6, v = (n) => n * dn, me = v(0.06), Ie = v(4), ln = (n) => n <= 64 ? me : 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) : Ie, un = "av1", gn = (n) => Ne(n, un), Tn = 0.6, Y = (n, e) => gn(e) ? n * Tn : n, Sn = (n) => Y(me, n), Cn = (n) => Y(Ie, n), Z = (n, e) => {
3077
- const t = ln(n);
3078
- return Y(t, e);
3079
- }, q = 1, En = ({
3072
+ const Re = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), hn = 1e6, f = (n) => n * hn, Ne = f(0.06), me = f(4), dn = (n) => n <= 64 ? Ne : n <= 128 ? f(0.12) : n <= 256 ? f(0.25) : n <= 384 ? f(0.32) : n <= 426 ? f(0.38) : n <= 640 ? f(0.5) : n <= 848 ? f(0.7) : n <= 1280 ? f(1) : n <= 1920 ? f(2) : me, ln = "av1", un = (n) => Re(n, ln), gn = 0.6, Q = (n, e) => un(e) ? n * gn : n, Tn = (n) => Q(Ne, n), Sn = (n) => Q(me, n), j = (n, e) => {
3073
+ const t = dn(n);
3074
+ return Q(t, e);
3075
+ }, $ = 1, Cn = ({
3080
3076
  videoTrack: n,
3081
3077
  targetSize: e
3082
3078
  }) => {
3083
- 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;
3084
- return Math.max(r, a, q);
3079
+ const t = n.getSettings(), s = t.width, r = t.height, i = s === void 0 ? $ : s / e.width, a = r === void 0 ? $ : r / e.height;
3080
+ return Math.max(i, a, $);
3085
3081
  };
3086
- class An {
3082
+ class En {
3087
3083
  ignoreForCodec;
3088
3084
  senderFinder;
3089
3085
  codecProvider;
@@ -3102,8 +3098,8 @@ class An {
3102
3098
  senderFinder: e,
3103
3099
  codecProvider: t,
3104
3100
  parametersSetter: s
3105
- }, i) {
3106
- this.senderFinder = e, this.codecProvider = t, this.parametersSetter = s, this.ignoreForCodec = i.ignoreForCodec;
3101
+ }, r) {
3102
+ this.senderFinder = e, this.codecProvider = t, this.parametersSetter = s, this.ignoreForCodec = r.ignoreForCodec;
3107
3103
  }
3108
3104
  /**
3109
3105
  * Выполняет балансировку на основе заголовков от сервера
@@ -3112,21 +3108,21 @@ class An {
3112
3108
  * @returns Promise с результатом балансировки
3113
3109
  */
3114
3110
  async balance(e, t) {
3115
- const s = e.getSenders(), i = this.senderFinder.findVideoSender(s);
3116
- if (!i?.track)
3117
- return { ...this.resultNoChanged, sender: i };
3118
- const r = await this.codecProvider.getCodecFromSender(i);
3119
- if (Ne(r, this.ignoreForCodec))
3120
- return { ...this.resultNoChanged, sender: i };
3111
+ const s = e.getSenders(), r = this.senderFinder.findVideoSender(s);
3112
+ if (!r?.track)
3113
+ return { ...this.resultNoChanged, sender: r };
3114
+ const i = await this.codecProvider.getCodecFromSender(r);
3115
+ if (Re(i, this.ignoreForCodec))
3116
+ return { ...this.resultNoChanged, sender: r };
3121
3117
  const { mainCam: a, resolutionMainCam: o } = t ?? {};
3122
3118
  return this.processSender(
3123
3119
  { mainCam: a, resolutionMainCam: o },
3124
3120
  {
3125
- sender: i,
3126
- codec: r,
3127
- videoTrack: i.track
3121
+ sender: r,
3122
+ codec: i,
3123
+ videoTrack: r.track
3128
3124
  }
3129
- ).then((h) => ({ ...h, sender: i }));
3125
+ ).then((h) => ({ ...h, sender: r }));
3130
3126
  }
3131
3127
  /**
3132
3128
  * Обрабатывает отправитель в зависимости от команды управления
@@ -3134,16 +3130,16 @@ class An {
3134
3130
  * @returns Promise с результатом обработки
3135
3131
  */
3136
3132
  async processSender(e, t) {
3137
- const { mainCam: s, resolutionMainCam: i } = e;
3133
+ const { mainCam: s, resolutionMainCam: r } = e;
3138
3134
  switch (s) {
3139
- case f.PAUSE_MAIN_CAM:
3135
+ case v.PAUSE_MAIN_CAM:
3140
3136
  return this.downgradeResolutionSender(t);
3141
- case f.RESUME_MAIN_CAM:
3137
+ case v.RESUME_MAIN_CAM:
3142
3138
  return this.setBitrateByTrackResolution(t);
3143
- case f.MAX_MAIN_CAM_RESOLUTION:
3144
- return i !== void 0 ? this.setResolutionSender(i, t) : this.setBitrateByTrackResolution(t);
3145
- case f.ADMIN_STOP_MAIN_CAM:
3146
- case f.ADMIN_START_MAIN_CAM:
3139
+ case v.MAX_MAIN_CAM_RESOLUTION:
3140
+ return r !== void 0 ? this.setResolutionSender(r, t) : this.setBitrateByTrackResolution(t);
3141
+ case v.ADMIN_STOP_MAIN_CAM:
3142
+ case v.ADMIN_START_MAIN_CAM:
3147
3143
  case void 0:
3148
3144
  return this.setBitrateByTrackResolution(t);
3149
3145
  default:
@@ -3156,11 +3152,11 @@ class An {
3156
3152
  * @returns Promise с результатом
3157
3153
  */
3158
3154
  async downgradeResolutionSender(e) {
3159
- const { sender: t, codec: s } = e, i = {
3155
+ const { sender: t, codec: s } = e, r = {
3160
3156
  scaleResolutionDownBy: 200,
3161
- maxBitrate: Sn(s)
3157
+ maxBitrate: Tn(s)
3162
3158
  };
3163
- return this.parametersSetter.setEncodingsToSender(t, i);
3159
+ return this.parametersSetter.setEncodingsToSender(t, r);
3164
3160
  }
3165
3161
  /**
3166
3162
  * Устанавливает битрейт на основе разрешения трека
@@ -3168,7 +3164,7 @@ class An {
3168
3164
  * @returns Promise с результатом
3169
3165
  */
3170
3166
  async setBitrateByTrackResolution(e) {
3171
- const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ? Cn(i) : Z(a, i);
3167
+ const { sender: t, videoTrack: s, codec: r } = e, a = s.getSettings().width, o = a === void 0 ? Sn(r) : j(a, r);
3172
3168
  return this.parametersSetter.setEncodingsToSender(t, {
3173
3169
  scaleResolutionDownBy: 1,
3174
3170
  maxBitrate: o
@@ -3181,27 +3177,27 @@ class An {
3181
3177
  * @returns Promise с результатом
3182
3178
  */
3183
3179
  async setResolutionSender(e, t) {
3184
- const [s, i] = e.split("x"), { sender: r, videoTrack: a, codec: o } = t, h = {
3180
+ const [s, r] = e.split("x"), { sender: i, videoTrack: a, codec: o } = t, h = {
3185
3181
  width: Number(s),
3186
- height: Number(i)
3187
- }, d = En({
3182
+ height: Number(r)
3183
+ }, d = Cn({
3188
3184
  videoTrack: a,
3189
3185
  targetSize: h
3190
- }), T = Z(h.width, o), S = {
3186
+ }), T = j(h.width, o), S = {
3191
3187
  scaleResolutionDownBy: d,
3192
3188
  maxBitrate: T
3193
3189
  };
3194
- return this.parametersSetter.setEncodingsToSender(r, S);
3190
+ return this.parametersSetter.setEncodingsToSender(i, S);
3195
3191
  }
3196
3192
  }
3197
- const Rn = (n) => n.find((e) => e.track?.kind === "video");
3198
- class Nn {
3193
+ const An = (n) => n.find((e) => e.track?.kind === "video");
3194
+ class Rn {
3199
3195
  // eslint-disable-next-line @typescript-eslint/class-methods-use-this
3200
3196
  findVideoSender(e) {
3201
- return Rn(e);
3197
+ return An(e);
3202
3198
  }
3203
3199
  }
3204
- class mn {
3200
+ class Nn {
3205
3201
  currentSender;
3206
3202
  originalReplaceTrack;
3207
3203
  lastWidth;
@@ -3214,7 +3210,7 @@ class mn {
3214
3210
  pollIntervalMs: e = 1e3,
3215
3211
  maxPollIntervalMs: t
3216
3212
  }) {
3217
- this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new ee();
3213
+ this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new Z();
3218
3214
  }
3219
3215
  /**
3220
3216
  * Проверяет актуальный video-sender и (при необходимости) перенастраивает наблюдение.
@@ -3233,8 +3229,8 @@ class mn {
3233
3229
  attachSender(e, t) {
3234
3230
  this.currentSender = e;
3235
3231
  const s = e.replaceTrack.bind(e);
3236
- this.originalReplaceTrack = s, e.replaceTrack = async (i) => {
3237
- await s(i), this.attachTrack(t, i ?? void 0), t();
3232
+ this.originalReplaceTrack = s, e.replaceTrack = async (r) => {
3233
+ await s(r), this.attachTrack(t, r ?? void 0), t();
3238
3234
  }, this.attachTrack(t, e.track);
3239
3235
  }
3240
3236
  detachSender() {
@@ -3243,8 +3239,8 @@ class mn {
3243
3239
  attachTrack(e, t) {
3244
3240
  if (this.detachTrack(), !t)
3245
3241
  return;
3246
- const { width: s, height: i } = t.getSettings();
3247
- this.lastWidth = s, this.lastHeight = i, this.currentPollIntervalMs = this.pollIntervalMs, this.schedulePoll(t, e);
3242
+ const { width: s, height: r } = t.getSettings();
3243
+ this.lastWidth = s, this.lastHeight = r, this.currentPollIntervalMs = this.pollIntervalMs, this.schedulePoll(t, e);
3248
3244
  }
3249
3245
  /**
3250
3246
  * Периодически опрашивает track с экспоненциальной адаптацией частоты.
@@ -3253,8 +3249,8 @@ class mn {
3253
3249
  */
3254
3250
  schedulePoll(e, t) {
3255
3251
  const s = () => {
3256
- const { width: i, height: r } = e.getSettings();
3257
- i !== this.lastWidth || r !== this.lastHeight ? (this.lastWidth = i, this.lastHeight = r, this.currentPollIntervalMs = this.pollIntervalMs, t()) : this.currentPollIntervalMs = Math.min(
3252
+ const { width: r, height: i } = e.getSettings();
3253
+ r !== this.lastWidth || i !== this.lastHeight ? (this.lastWidth = r, this.lastHeight = i, this.currentPollIntervalMs = this.pollIntervalMs, t()) : this.currentPollIntervalMs = Math.min(
3258
3254
  this.currentPollIntervalMs * 2,
3259
3255
  this.maxPollIntervalMs
3260
3256
  ), this.setTimeoutRequest.request(s, this.currentPollIntervalMs);
@@ -3265,7 +3261,7 @@ class mn {
3265
3261
  this.setTimeoutRequest.cancelRequest(), this.lastWidth = void 0, this.lastHeight = void 0;
3266
3262
  }
3267
3263
  }
3268
- class In {
3264
+ class mn {
3269
3265
  apiManager;
3270
3266
  currentHandler;
3271
3267
  constructor(e) {
@@ -3285,7 +3281,7 @@ class In {
3285
3281
  this.currentHandler && (this.apiManager.off("main-cam-control", this.currentHandler), this.currentHandler = void 0);
3286
3282
  }
3287
3283
  }
3288
- class pn {
3284
+ class In {
3289
3285
  eventHandler;
3290
3286
  senderBalancer;
3291
3287
  parametersSetterWithQueue;
@@ -3294,19 +3290,19 @@ class pn {
3294
3290
  trackMonitor;
3295
3291
  constructor(e, t, {
3296
3292
  ignoreForCodec: s,
3297
- onSetParameters: i,
3298
- pollIntervalMs: r
3293
+ onSetParameters: r,
3294
+ pollIntervalMs: i
3299
3295
  } = {}) {
3300
- this.getConnection = t, this.eventHandler = new In(e), this.parametersSetterWithQueue = new hn(i), this.senderBalancer = new An(
3296
+ this.getConnection = t, this.eventHandler = new mn(e), this.parametersSetterWithQueue = new cn(r), this.senderBalancer = new En(
3301
3297
  {
3302
- senderFinder: new Nn(),
3303
- codecProvider: new on(),
3298
+ senderFinder: new Rn(),
3299
+ codecProvider: new an(),
3304
3300
  parametersSetter: this.parametersSetterWithQueue
3305
3301
  },
3306
3302
  {
3307
3303
  ignoreForCodec: s
3308
3304
  }
3309
- ), this.trackMonitor = new mn({ pollIntervalMs: r });
3305
+ ), this.trackMonitor = new Nn({ pollIntervalMs: i });
3310
3306
  }
3311
3307
  /**
3312
3308
  * Подписывается на события управления главной камерой
@@ -3351,13 +3347,13 @@ class pn {
3351
3347
  });
3352
3348
  };
3353
3349
  }
3354
- const pe = [
3350
+ const Ie = [
3355
3351
  "balancing-scheduled",
3356
3352
  "balancing-started",
3357
3353
  "balancing-stopped",
3358
3354
  "parameters-updated"
3359
3355
  ];
3360
- class _n {
3356
+ class pn {
3361
3357
  isBalancingActive = !1;
3362
3358
  events;
3363
3359
  callManager;
@@ -3365,13 +3361,13 @@ class _n {
3365
3361
  videoSendingBalancer;
3366
3362
  startBalancingTimer;
3367
3363
  constructor(e, t, s = {}) {
3368
- this.events = new w(pe), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new pn(
3364
+ this.events = new y(Ie), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new In(
3369
3365
  t,
3370
3366
  () => e.connection,
3371
3367
  {
3372
3368
  ...s,
3373
- onSetParameters: (i) => {
3374
- this.events.trigger("parameters-updated", i), s.onSetParameters?.(i);
3369
+ onSetParameters: (r) => {
3370
+ this.events.trigger("parameters-updated", r), s.onSetParameters?.(r);
3375
3371
  }
3376
3372
  }
3377
3373
  ), this.subscribe();
@@ -3435,17 +3431,17 @@ class _n {
3435
3431
  this.startBalancingTimer && (clearTimeout(this.startBalancingTimer), this.startBalancingTimer = void 0);
3436
3432
  }
3437
3433
  }
3438
- const Mn = 1e6, vn = Ce.map((n) => `auto-connect:${n}`), fn = ge.map((n) => `connection:${n}`), Pn = re.map((n) => `call:${n}`), On = se.map((n) => `api:${n}`), yn = Ee.map((n) => `incoming-call:${n}`), Dn = le.map((n) => `presentation:${n}`), bn = Ae.map((n) => `stats:${n}`), wn = pe.map((n) => `video-balancer:${n}`), Un = [
3439
- ...vn,
3434
+ const _n = 1e6, Mn = Se.map((n) => `auto-connect:${n}`), fn = ue.map((n) => `connection:${n}`), vn = re.map((n) => `call:${n}`), Pn = ne.map((n) => `api:${n}`), On = Ce.map((n) => `incoming-call:${n}`), yn = de.map((n) => `presentation:${n}`), Dn = Ee.map((n) => `stats:${n}`), bn = Ie.map((n) => `video-balancer:${n}`), wn = [
3435
+ ...Mn,
3440
3436
  ...fn,
3437
+ ...vn,
3441
3438
  ...Pn,
3442
3439
  ...On,
3443
3440
  ...yn,
3444
3441
  ...Dn,
3445
- ...bn,
3446
- ...wn
3442
+ ...bn
3447
3443
  ];
3448
- class Yn {
3444
+ class Qn {
3449
3445
  events;
3450
3446
  connectionManager;
3451
3447
  connectionQueueManager;
@@ -3462,34 +3458,34 @@ class Yn {
3462
3458
  constructor({ JsSIP: e }, {
3463
3459
  preferredMimeTypesVideoCodecs: t,
3464
3460
  excludeMimeTypesVideoCodecs: s,
3465
- videoBalancerOptions: i,
3466
- autoConnectorOptions: r
3461
+ videoBalancerOptions: r,
3462
+ autoConnectorOptions: i
3467
3463
  } = {}) {
3468
- this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = new F(Un), this.connectionManager = new _t({ JsSIP: e }), this.connectionQueueManager = new Mt({
3464
+ this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = new y(wn), this.connectionManager = new pt({ JsSIP: e }), this.connectionQueueManager = new _t({
3469
3465
  connectionManager: this.connectionManager
3470
- }), this.callManager = new Je(), this.apiManager = new ke({
3466
+ }), this.callManager = new Xe(), this.apiManager = new Fe({
3471
3467
  connectionManager: this.connectionManager,
3472
3468
  callManager: this.callManager
3473
- }), this.incomingCallManager = new Vt(this.connectionManager), this.presentationManager = new lt({
3469
+ }), this.incomingCallManager = new qt(this.connectionManager), this.presentationManager = new dt({
3474
3470
  callManager: this.callManager,
3475
- maxBitrate: Mn
3476
- }), this.statsManager = new Jt({
3471
+ maxBitrate: _n
3472
+ }), this.statsManager = new Xt({
3477
3473
  callManager: this.callManager,
3478
3474
  apiManager: this.apiManager
3479
- }), this.autoConnectorManager = new kt(
3475
+ }), this.autoConnectorManager = new Ft(
3480
3476
  {
3481
3477
  connectionQueueManager: this.connectionQueueManager,
3482
3478
  connectionManager: this.connectionManager,
3483
3479
  callManager: this.callManager
3484
3480
  },
3485
- r
3486
- ), this.transceiverManager = new nn({
3481
+ i
3482
+ ), this.transceiverManager = new tn({
3487
3483
  callManager: this.callManager,
3488
3484
  apiManager: this.apiManager
3489
- }), this.videoSendingBalancerManager = new _n(
3485
+ }), this.videoSendingBalancerManager = new pn(
3490
3486
  this.callManager,
3491
3487
  this.apiManager,
3492
- i
3488
+ r
3493
3489
  ), this.subscribe();
3494
3490
  }
3495
3491
  get requestedConnection() {
@@ -3528,22 +3524,18 @@ class Yn {
3528
3524
  get isAvailableIncomingCall() {
3529
3525
  return this.incomingCallManager.isAvailableIncomingCall;
3530
3526
  }
3531
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
3532
3527
  on(e, t) {
3533
3528
  return this.events.on(e, t);
3534
3529
  }
3535
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
3536
3530
  once(e, t) {
3537
3531
  return this.events.once(e, t);
3538
3532
  }
3539
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
3540
3533
  onceRace(e, t) {
3541
3534
  return this.events.onceRace(e, t);
3542
3535
  }
3543
3536
  async wait(e) {
3544
3537
  return this.events.wait(e);
3545
3538
  }
3546
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
3547
3539
  off(e, t) {
3548
3540
  this.events.off(e, t);
3549
3541
  }
@@ -3593,7 +3585,7 @@ class Yn {
3593
3585
  getRemoteStreams = () => this.callManager.getRemoteStreams();
3594
3586
  replaceMediaStream = async (...e) => this.callManager.replaceMediaStream(...e);
3595
3587
  async startPresentation(e, t = {}) {
3596
- const { isP2P: s, callLimit: i, onAddedTransceiver: r, ...a } = t;
3588
+ const { isP2P: s, callLimit: r, onAddedTransceiver: i, ...a } = t;
3597
3589
  return this.presentationManager.startPresentation(
3598
3590
  async () => {
3599
3591
  s === !0 ? (await this.apiManager.sendMustStopPresentationP2P(), await this.apiManager.askPermissionToStartPresentationP2P()) : await this.apiManager.askPermissionToStartPresentation();
@@ -3601,9 +3593,9 @@ class Yn {
3601
3593
  e,
3602
3594
  {
3603
3595
  ...a,
3604
- onAddedTransceiver: this.resolveHandleAddTransceiver(r)
3596
+ onAddedTransceiver: this.resolveHandleAddTransceiver(i)
3605
3597
  },
3606
- i === void 0 ? void 0 : { callLimit: i }
3598
+ r === void 0 ? void 0 : { callLimit: r }
3607
3599
  );
3608
3600
  }
3609
3601
  async stopPresentation(e = {}) {
@@ -3613,15 +3605,15 @@ class Yn {
3613
3605
  });
3614
3606
  }
3615
3607
  async updatePresentation(e, t = {}) {
3616
- const { isP2P: s, onAddedTransceiver: i, ...r } = t;
3608
+ const { isP2P: s, onAddedTransceiver: r, ...i } = t;
3617
3609
  return this.presentationManager.updatePresentation(
3618
3610
  async () => {
3619
3611
  s === !0 ? (await this.apiManager.sendMustStopPresentationP2P(), await this.apiManager.askPermissionToStartPresentationP2P()) : await this.apiManager.askPermissionToStartPresentation();
3620
3612
  },
3621
3613
  e,
3622
3614
  {
3623
- ...r,
3624
- onAddedTransceiver: this.resolveHandleAddTransceiver(i)
3615
+ ...i,
3616
+ onAddedTransceiver: this.resolveHandleAddTransceiver(r)
3625
3617
  }
3626
3618
  );
3627
3619
  }
@@ -3668,7 +3660,7 @@ class Yn {
3668
3660
  return this.apiManager.askPermissionToEnableCam(...e);
3669
3661
  }
3670
3662
  setCodecPreferences(e) {
3671
- tn(e, {
3663
+ en(e, {
3672
3664
  preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
3673
3665
  excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
3674
3666
  });
@@ -3677,30 +3669,30 @@ class Yn {
3677
3669
  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);
3678
3670
  }
3679
3671
  bridgeEvents = (e, t) => {
3680
- t.events.eachTriggers((s, i) => {
3681
- t.on(i, (r) => {
3682
- this.events.trigger(`${e}:${i}`, r);
3672
+ t.events.eachTriggers((s, r) => {
3673
+ t.on(r, (i) => {
3674
+ this.events.trigger(`${e}:${r}`, i);
3683
3675
  });
3684
3676
  });
3685
3677
  };
3686
- resolveHandleAddTransceiver = (e) => async (t, s, i) => {
3687
- this.setCodecPreferences(t), await e?.(t, s, i);
3678
+ resolveHandleAddTransceiver = (e) => async (t, s, r) => {
3679
+ this.setCodecPreferences(t), await e?.(t, s, r);
3688
3680
  };
3689
3681
  }
3690
3682
  export {
3691
- oe as E,
3692
- $e as O,
3693
- Yn as S,
3694
- ot as a,
3695
- Fe as b,
3696
- Qn as c,
3697
- Gn as d,
3698
- xn as e,
3683
+ ae as E,
3684
+ ke as O,
3685
+ Qn as S,
3686
+ at as a,
3687
+ Be as b,
3688
+ Gn as c,
3689
+ xn as d,
3690
+ Wn as e,
3699
3691
  A as f,
3700
- Xt as g,
3701
- mt as h,
3702
- an as i,
3692
+ zt as g,
3693
+ Nt as h,
3694
+ rn as i,
3703
3695
  c as l,
3704
3696
  B as p,
3705
- de as s
3697
+ he as s
3706
3698
  };