sip-connector 14.1.0-alpha.1 → 14.1.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/{SipConnector-CK3GgjXE.js → @SipConnector-C-ThpS1P.js} +459 -680
  2. package/dist/@SipConnector-Xh6_JpUI.cjs +1 -0
  3. package/dist/ApiManager/@ApiManager.d.ts +2 -2
  4. package/dist/ApiManager/constants.d.ts +1 -1
  5. package/dist/ApiManager/eventNames.d.ts +1 -1
  6. package/dist/ApiManager/index.d.ts +1 -0
  7. package/dist/CallManager/causes.d.ts +2 -1
  8. package/dist/CallManager/eventNames.d.ts +1 -1
  9. package/dist/CallManager/index.d.ts +2 -0
  10. package/dist/CallManager/types.d.ts +1 -1
  11. package/dist/ConnectionManager/@ConnectionManager.d.ts +3 -2
  12. package/dist/ConnectionManager/ConnectionFlow.d.ts +3 -2
  13. package/dist/ConnectionManager/ConnectionStateMachine.d.ts +1 -1
  14. package/dist/ConnectionManager/RegistrationManager.d.ts +1 -1
  15. package/dist/ConnectionManager/eventNames.d.ts +1 -1
  16. package/dist/IncomingCallManager/@IncomingCallManager.d.ts +3 -2
  17. package/dist/PresentationManager/@PresentationManager.d.ts +2 -2
  18. package/dist/PresentationManager/eventNames.d.ts +1 -1
  19. package/dist/PresentationManager/index.d.ts +1 -0
  20. package/dist/{SipConnector.d.ts → SipConnector/@SipConnector.d.ts} +19 -30
  21. package/dist/SipConnector/eventNames.d.ts +4 -0
  22. package/dist/SipConnector/index.d.ts +2 -0
  23. package/dist/SipConnectorFacade/SipConnectorFacade.d.ts +10 -28
  24. package/dist/__fixtures__/BaseSession.mock.d.ts +5 -5
  25. package/dist/__fixtures__/RTCPeerConnectionMock.d.ts +6 -0
  26. package/dist/__fixtures__/RTCSessionMock.d.ts +5 -5
  27. package/dist/__fixtures__/UA.mock.d.ts +1 -1
  28. package/dist/{eventNames.d.ts → __fixtures__/eventNames.d.ts} +1 -1
  29. package/dist/doMock.cjs +1 -1
  30. package/dist/doMock.d.ts +1 -1
  31. package/dist/doMock.js +219 -137
  32. package/dist/index.cjs +1 -1
  33. package/dist/index.d.ts +9 -8
  34. package/dist/index.js +512 -546
  35. package/dist/tools/__fixtures__/processRequest.d.ts +1 -1
  36. package/dist/tools/error/getLinkError.d.ts +1 -1
  37. package/dist/tools/error/getTypeFromError.d.ts +1 -1
  38. package/dist/tools/error/getValuesFromError.d.ts +1 -1
  39. package/dist/tools/prepareMediaStream.d.ts +1 -1
  40. package/dist/tools/setVideoTrackContentHints.d.ts +1 -1
  41. package/dist/tools/syncMediaState/index.d.ts +1 -1
  42. package/dist/tools/syncMediaState/resolveOnStartMainCam.d.ts +1 -1
  43. package/dist/tools/syncMediaState/resolveOnStartMic.d.ts +1 -1
  44. package/dist/tools/syncMediaState/resolveOnStopMainCam.d.ts +1 -1
  45. package/dist/tools/syncMediaState/resolveOnStopMic.d.ts +1 -1
  46. package/dist/types.d.ts +0 -46
  47. package/dist/videoSendingBalancer/balance.d.ts +1 -1
  48. package/dist/videoSendingBalancer/index.d.ts +1 -1
  49. package/dist/videoSendingBalancer/processSender.d.ts +1 -1
  50. package/package.json +3 -3
  51. package/dist/SipConnector-CwI8aFEA.cjs +0 -1
  52. package/dist/causes.d.ts +0 -23
  53. package/dist/headers.d.ts +0 -37
  54. /package/dist/{getExtraHeadersRemoteAddress.d.ts → ConnectionManager/getExtraHeadersRemoteAddress.d.ts} +0 -0
  55. /package/dist/{constants.d.ts → __fixtures__/constants.d.ts} +0 -0
@@ -1,206 +1,10 @@
1
- import D from "events-constructor";
1
+ import { Events as O } from "events-constructor";
2
2
  import "@krivega/cancelable-promise";
3
- import W from "debug";
4
- import { hasCanceledError as ht, repeatedCallsAsync as G } from "repeated-calls";
5
- import { setup as lt, createActor as Ct } from "xstate";
6
- const Nt = "Connection Error", At = "Request Timeout", _t = "SIP Failure Code", ut = "Internal Error", It = "Busy", Rt = "Rejected", Mt = "Redirected", Ot = "Unavailable", pt = "Not Found", Pt = "Address Incomplete", mt = "Incompatible SDP", ft = "Missing SDP", Dt = "Authentication Error", vt = "Terminated", yt = "WebRTC Error", Ut = "Canceled", bt = "No Answer", wt = "Expires", Lt = "No ACK", Ft = "Dialog Error", $t = "User Denied Media Access", Wt = "Bad Media Description", kt = "RTP Timeout", yn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7
- __proto__: null,
8
- ADDRESS_INCOMPLETE: Pt,
9
- AUTHENTICATION_ERROR: Dt,
10
- BAD_MEDIA_DESCRIPTION: Wt,
11
- BUSY: It,
12
- BYE: vt,
13
- CANCELED: Ut,
14
- CONNECTION_ERROR: Nt,
15
- DIALOG_ERROR: Ft,
16
- EXPIRES: wt,
17
- INCOMPATIBLE_SDP: mt,
18
- INTERNAL_ERROR: ut,
19
- MISSING_SDP: ft,
20
- NOT_FOUND: pt,
21
- NO_ACK: Lt,
22
- NO_ANSWER: bt,
23
- REDIRECTED: Mt,
24
- REJECTED: Rt,
25
- REQUEST_TIMEOUT: At,
26
- RTP_TIMEOUT: kt,
27
- SIP_FAILURE_CODE: _t,
28
- UNAVAILABLE: Ot,
29
- USER_DENIED_MEDIA_ACCESS: $t,
30
- WEBRTC_ERROR: yt
31
- }, Symbol.toStringTag, { value: "Module" })), H = "incomingCall", B = "declinedIncomingCall", Y = "failedIncomingCall", q = "terminatedIncomingCall", k = "connecting", x = "connected", Q = "disconnected", z = "newRTCSession", J = "registered", X = "unregistered", j = "registrationFailed", K = "newMessage", Z = "sipEvent", ee = "availableSecondRemoteStream", te = "notAvailableSecondRemoteStream", ne = "mustStopPresentation", se = "shareState", ie = "enterRoom", re = "useLicense", ae = "peerconnection:confirmed", oe = "peerconnection:ontrack", ce = "channels", Te = "channels:notify", Ee = "ended:fromserver", ge = "main-cam-control", Se = "admin-stop-main-cam", de = "admin-start-main-cam", he = "admin-stop-mic", le = "admin-start-mic", Ce = "admin-force-sync-media-state", Ne = "participant:added-to-list-moderators", Ae = "participant:removed-from-list-moderators", _e = "participant:move-request-to-stream", ue = "participant:move-request-to-spectators", Ie = "participant:move-request-to-participants", Re = "participation:accepting-word-request", Me = "participation:cancelling-word-request", Oe = "webcast:started", pe = "webcast:stopped", Pe = "account:changed", me = "account:deleted", fe = "conference:participant-token-issued", De = "ended", ve = "sending", ye = "reinvite", Ue = "replaces", be = "refer", we = "progress", Le = "accepted", Fe = "confirmed", $e = "peerconnection", We = "failed", ke = "muted", Ve = "unmuted", Ge = "newDTMF", He = "newInfo", Be = "hold", Ye = "unhold", qe = "update", xe = "sdp", Qe = "icecandidate", ze = "getusermediafailed", Je = "peerconnection:createofferfailed", Xe = "peerconnection:createanswerfailed", je = "peerconnection:setlocaldescriptionfailed", Ke = "peerconnection:setremotedescriptionfailed", Ze = "presentation:start", et = "presentation:started", tt = "presentation:end", nt = "presentation:ended", st = "presentation:failed", Vt = "SPECTATOR", Gt = "PARTICIPANT", Ht = 1e6;
32
- var it = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))(it || {});
33
- const Un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
34
- __proto__: null,
35
- ACCEPTED: Le,
36
- ACCOUNT_CHANGED: Pe,
37
- ACCOUNT_DELETED: me,
38
- ADMIN_FORCE_SYNC_MEDIA_STATE: Ce,
39
- ADMIN_START_MAIN_CAM: de,
40
- ADMIN_START_MIC: le,
41
- ADMIN_STOP_MAIN_CAM: Se,
42
- ADMIN_STOP_MIC: he,
43
- AVAILABLE_SECOND_REMOTE_STREAM_EVENT: ee,
44
- CHANNELS: ce,
45
- CHANNELS_NOTIFY: Te,
46
- CONFERENCE_PARTICIPANT_TOKEN_ISSUED: fe,
47
- CONFIRMED: Fe,
48
- CONNECTED: x,
49
- CONNECTING: k,
50
- DECLINED_INCOMING_CALL: B,
51
- DISCONNECTED: Q,
52
- ENDED: De,
53
- ENDED_FROM_SERVER: Ee,
54
- ENTER_ROOM: ie,
55
- FAILED: We,
56
- FAILED_INCOMING_CALL: Y,
57
- GET_USER_MEDIA_FAILED: ze,
58
- HOLD: Be,
59
- ICE_CANDIDATE: Qe,
60
- INCOMING_CALL: H,
61
- MAIN_CAM_CONTROL: ge,
62
- MUST_STOP_PRESENTATION_EVENT: ne,
63
- MUTED: ke,
64
- NEW_DTMF: Ge,
65
- NEW_INFO: He,
66
- NEW_MESSAGE: K,
67
- NEW_RTC_SESSION: z,
68
- NOT_AVAILABLE_SECOND_REMOTE_STREAM_EVENT: te,
69
- ONE_MEGABIT_IN_BITS: Ht,
70
- Originator: it,
71
- PARTICIPANT: Gt,
72
- PARTICIPANT_ADDED_TO_LIST_MODERATORS: Ne,
73
- PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS: Ie,
74
- PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS: ue,
75
- PARTICIPANT_MOVE_REQUEST_TO_STREAM: _e,
76
- PARTICIPANT_REMOVED_FROM_LIST_MODERATORS: Ae,
77
- PARTICIPATION_ACCEPTING_WORD_REQUEST: Re,
78
- PARTICIPATION_CANCELLING_WORD_REQUEST: Me,
79
- PEER_CONNECTION: $e,
80
- PEER_CONNECTION_CONFIRMED: ae,
81
- PEER_CONNECTION_CREATE_ANSWER_FAILED: Xe,
82
- PEER_CONNECTION_CREATE_OFFER_FAILED: Je,
83
- PEER_CONNECTION_ONTRACK: oe,
84
- PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED: je,
85
- PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED: Ke,
86
- PRESENTATION_END: tt,
87
- PRESENTATION_ENDED: nt,
88
- PRESENTATION_FAILED: st,
89
- PRESENTATION_START: Ze,
90
- PRESENTATION_STARTED: et,
91
- PROGRESS: we,
92
- REFER: be,
93
- REGISTERED: J,
94
- REGISTRATION_FAILED: j,
95
- REINVITE: ye,
96
- REPLACES: Ue,
97
- SDP: xe,
98
- SENDING: ve,
99
- SHARE_STATE: se,
100
- SIP_EVENT: Z,
101
- SPECTATOR: Vt,
102
- TERMINATED_INCOMING_CALL: q,
103
- UNHOLD: Ye,
104
- UNMUTED: Ve,
105
- UNREGISTERED: X,
106
- UPDATE: qe,
107
- USE_LICENSE: re,
108
- WEBCAST_STARTED: Oe,
109
- WEBCAST_STOPPED: pe
110
- }, Symbol.toStringTag, { value: "Module" })), rt = [
111
- H,
112
- B,
113
- q,
114
- Y,
115
- Re,
116
- Me,
117
- _e,
118
- Te,
119
- fe,
120
- Pe,
121
- me,
122
- Oe,
123
- pe,
124
- Ne,
125
- Ae
126
- ], at = [
127
- k,
128
- x,
129
- Q,
130
- z,
131
- J,
132
- X,
133
- j,
134
- K,
135
- Z
136
- ], ot = [
137
- ee,
138
- te,
139
- ne,
140
- se,
141
- ie,
142
- re,
143
- ae,
144
- oe,
145
- ce,
146
- Ee,
147
- ge,
148
- de,
149
- Se,
150
- he,
151
- le,
152
- Ce,
153
- ue,
154
- Ie
155
- ], ct = [
156
- De,
157
- k,
158
- ve,
159
- ye,
160
- Ue,
161
- be,
162
- we,
163
- Le,
164
- Fe,
165
- $e,
166
- We,
167
- ke,
168
- Ve,
169
- Ge,
170
- He,
171
- Be,
172
- Ye,
173
- qe,
174
- xe,
175
- Qe,
176
- ze,
177
- Je,
178
- Xe,
179
- je,
180
- Ke,
181
- Ze,
182
- et,
183
- tt,
184
- nt,
185
- st
186
- ], Bt = [...at, ...rt], Yt = [
187
- ...ct,
188
- ...ot
189
- ], bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
190
- __proto__: null,
191
- SESSION_EVENT_NAMES: Yt,
192
- SESSION_JSSIP_EVENT_NAMES: ct,
193
- SESSION_SYNTHETICS_EVENT_NAMES: ot,
194
- UA_EVENT_NAMES: Bt,
195
- UA_JSSIP_EVENT_NAMES: at,
196
- UA_SYNTHETICS_EVENT_NAMES: rt
197
- }, Symbol.toStringTag, { value: "Module" })), V = "sip-connector", P = W(V), wn = () => {
198
- W.enable(V);
199
- }, Ln = () => {
200
- W.enable(`-${V}`);
201
- };
3
+ import k from "debug";
4
+ import { hasCanceledError as K, repeatedCallsAsync as V } from "repeated-calls";
5
+ import { setup as j, createActor as Z } from "xstate";
202
6
  var N = /* @__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))(N || {}), U = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))(U || {});
203
- const Tt = [
7
+ const H = [
204
8
  "peerconnection",
205
9
  "connecting",
206
10
  "sending",
@@ -227,21 +31,21 @@ const Tt = [
227
31
  "peerconnection:createanswerfailed",
228
32
  "peerconnection:setlocaldescriptionfailed",
229
33
  "peerconnection:setremotedescriptionfailed"
230
- ], qt = [
34
+ ], ee = [
231
35
  "peerconnection:confirmed",
232
36
  "peerconnection:ontrack",
233
37
  "ended:fromserver"
234
- ], xt = [
235
- ...Tt,
236
- ...qt
38
+ ], G = [
39
+ ...H,
40
+ ...ee
237
41
  ];
238
- function Qt(n) {
42
+ function te(n) {
239
43
  return (e) => `sip:${e}@${n}`;
240
44
  }
241
- const zt = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, Et = (n) => n.trim().replaceAll(" ", "_"), Jt = zt(1e5, 99999999), Xt = (n) => n.some((t) => {
45
+ const ne = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, B = (n) => n.trim().replaceAll(" ", "_"), se = ne(1e5, 99999999), ie = (n) => n.some((t) => {
242
46
  const { kind: s } = t;
243
47
  return s === "video";
244
- }), jt = (n, e) => {
48
+ }), re = (n, e) => {
245
49
  n.getVideoTracks().forEach((s) => {
246
50
  "contentHint" in s && s.contentHint !== e && (s.contentHint = e);
247
51
  });
@@ -253,9 +57,9 @@ const zt = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, Et = (n) =>
253
57
  if (!n || e === "recvonly" && t === "recvonly")
254
58
  return;
255
59
  const i = t === "recvonly" ? [] : n.getAudioTracks(), r = e === "recvonly" ? [] : n.getVideoTracks(), a = [...i, ...r], o = new MediaStream(a);
256
- return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && jt(o, s), o;
60
+ return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && re(o, s), o;
257
61
  };
258
- class Kt {
62
+ class ae {
259
63
  isPendingCall = !1;
260
64
  isPendingAnswer = !1;
261
65
  rtcSession;
@@ -266,8 +70,8 @@ class Kt {
266
70
  this.events = e;
267
71
  }
268
72
  }
269
- var gt = /* @__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))(gt || {});
270
- class Zt {
73
+ var x = /* @__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))(x || {});
74
+ class oe {
271
75
  remoteStreams = {};
272
76
  reset() {
273
77
  this.remoteStreams = {};
@@ -296,8 +100,8 @@ class Zt {
296
100
  return e.map((t) => this.generateAudioStream(t));
297
101
  }
298
102
  }
299
- class en extends Kt {
300
- remoteStreamsManager = new Zt();
103
+ class ce extends ae {
104
+ remoteStreamsManager = new oe();
301
105
  disposers = /* @__PURE__ */ new Set();
302
106
  constructor(e) {
303
107
  super(e), e.on(N.FAILED, this.handleEnded), e.on(N.ENDED, this.handleEnded);
@@ -321,34 +125,38 @@ class en extends Kt {
321
125
  ontrack: a,
322
126
  iceServers: o,
323
127
  directionVideo: c,
324
- directionAudio: T,
325
- contentHint: S,
326
- offerToReceiveAudio: l = !0,
327
- offerToReceiveVideo: d = !0,
328
- sendEncodings: h,
128
+ directionAudio: g,
129
+ contentHint: d,
130
+ offerToReceiveAudio: S = !0,
131
+ offerToReceiveVideo: l = !0,
132
+ sendEncodings: E,
329
133
  onAddedTransceiver: I
330
- }) => (this.isPendingCall = !0, new Promise((C, O) => {
134
+ }) => (this.isPendingCall = !0, new Promise((C, p) => {
331
135
  this.callConfiguration.number = s, this.callConfiguration.answer = !1, this.handleCall({ ontrack: a }).then(C).catch((b) => {
332
- O(b);
136
+ p(b);
333
137
  }), this.rtcSession = e.call(t(s), {
334
138
  extraHeaders: r,
335
139
  mediaStream: v(i, {
336
140
  directionVideo: c,
337
- directionAudio: T,
338
- contentHint: S
141
+ directionAudio: g,
142
+ contentHint: d
339
143
  }),
144
+ // необходимо передавать в методе call, чтобы подписаться на события peerconnection,
145
+ // так как в методе call создается RTCSession
146
+ // и после создания нет возможности подписаться на события peerconnection через subscribeToSessionEvents
147
+ eventHandlers: this.events.triggers,
340
148
  directionVideo: c,
341
- directionAudio: T,
149
+ directionAudio: g,
342
150
  pcConfig: {
343
151
  iceServers: o
344
152
  },
345
153
  rtcOfferConstraints: {
346
- offerToReceiveAudio: l,
347
- offerToReceiveVideo: d
154
+ offerToReceiveAudio: S,
155
+ offerToReceiveVideo: l
348
156
  },
349
- sendEncodings: h,
157
+ sendEncodings: E,
350
158
  onAddedTransceiver: I
351
- }), this.subscribeToSessionEvents(this.rtcSession);
159
+ });
352
160
  }).finally(() => {
353
161
  this.isPendingCall = !1;
354
162
  }));
@@ -356,7 +164,7 @@ class en extends Kt {
356
164
  const { rtcSession: e } = this;
357
165
  if (e && !e.isEnded())
358
166
  return e.terminateAsync({
359
- cause: gt.CANCELED
167
+ cause: x.CANCELED
360
168
  }).finally(() => {
361
169
  this.reset();
362
170
  });
@@ -370,35 +178,35 @@ class en extends Kt {
370
178
  directionVideo: a,
371
179
  directionAudio: o,
372
180
  offerToReceiveAudio: c,
373
- offerToReceiveVideo: T,
374
- contentHint: S,
375
- sendEncodings: l,
376
- onAddedTransceiver: d
377
- }) => (this.isPendingAnswer = !0, new Promise((h, I) => {
181
+ offerToReceiveVideo: g,
182
+ contentHint: d,
183
+ sendEncodings: S,
184
+ onAddedTransceiver: l
185
+ }) => (this.isPendingAnswer = !0, new Promise((E, I) => {
378
186
  try {
379
187
  const C = e();
380
- this.rtcSession = C, this.subscribeToSessionEvents(C), this.callConfiguration.answer = !0, this.callConfiguration.number = C.remote_identity.uri.user, this.handleCall({ ontrack: s }).then(h).catch((b) => {
188
+ this.rtcSession = C, this.subscribeToSessionEvents(C), this.callConfiguration.answer = !0, this.callConfiguration.number = C.remote_identity.uri.user, this.handleCall({ ontrack: s }).then(E).catch((b) => {
381
189
  I(b);
382
190
  });
383
- const O = v(t, {
191
+ const p = v(t, {
384
192
  directionVideo: a,
385
193
  directionAudio: o,
386
- contentHint: S
194
+ contentHint: d
387
195
  });
388
196
  C.answer({
389
197
  extraHeaders: i,
390
198
  directionVideo: a,
391
199
  directionAudio: o,
392
- mediaStream: O,
200
+ mediaStream: p,
393
201
  pcConfig: {
394
202
  iceServers: r
395
203
  },
396
204
  rtcOfferConstraints: {
397
205
  offerToReceiveAudio: c,
398
- offerToReceiveVideo: T
206
+ offerToReceiveVideo: g
399
207
  },
400
- sendEncodings: l,
401
- onAddedTransceiver: d
208
+ sendEncodings: S,
209
+ onAddedTransceiver: l
402
210
  });
403
211
  } catch (C) {
404
212
  I(C);
@@ -416,7 +224,7 @@ class en extends Kt {
416
224
  if (!this.connection)
417
225
  return;
418
226
  const t = this.connection.getReceivers().map(({ track: s }) => s);
419
- return Xt(t) ? this.remoteStreamsManager.generateStreams(t) : this.remoteStreamsManager.generateAudioStreams(t);
227
+ return ie(t) ? this.remoteStreamsManager.generateStreams(t) : this.remoteStreamsManager.generateAudioStreams(t);
420
228
  }
421
229
  async replaceMediaStream(e, t) {
422
230
  if (!this.rtcSession)
@@ -430,33 +238,33 @@ class en extends Kt {
430
238
  ontrack: e
431
239
  }) => new Promise((t, s) => {
432
240
  const i = () => {
433
- this.events.on(N.PEER_CONNECTION, S), this.events.on(N.CONFIRMED, l);
241
+ this.events.on(N.PEER_CONNECTION, d), this.events.on(N.CONFIRMED, S);
434
242
  }, r = () => {
435
- this.events.off(N.PEER_CONNECTION, S), this.events.off(N.CONFIRMED, l);
243
+ this.events.off(N.PEER_CONNECTION, d), this.events.off(N.CONFIRMED, S);
436
244
  }, a = () => {
437
245
  this.events.on(N.FAILED, c), this.events.on(N.ENDED, c);
438
246
  }, o = () => {
439
247
  this.events.off(N.FAILED, c), this.events.off(N.ENDED, c);
440
- }, c = (d) => {
441
- r(), o(), s(d);
248
+ }, c = (l) => {
249
+ r(), o(), s(l);
442
250
  };
443
- let T;
444
- const S = ({ peerconnection: d }) => {
445
- T = d;
446
- const h = (I) => {
447
- this.events.trigger(N.PEER_CONNECTION_ONTRACK, d), e && e(I);
251
+ let g;
252
+ const d = ({ peerconnection: l }) => {
253
+ g = l;
254
+ const E = (I) => {
255
+ this.events.trigger(N.PEER_CONNECTION_ONTRACK, l), e && e(I);
448
256
  };
449
- d.addEventListener("track", h), this.disposers.add(() => {
450
- d.removeEventListener("track", h);
257
+ l.addEventListener("track", E), this.disposers.add(() => {
258
+ l.removeEventListener("track", E);
451
259
  });
452
- }, l = () => {
453
- T !== void 0 && this.events.trigger(N.PEER_CONNECTION_CONFIRMED, T), r(), o(), t(T);
260
+ }, S = () => {
261
+ g !== void 0 && this.events.trigger(N.PEER_CONNECTION_CONFIRMED, g), r(), o(), t(g);
454
262
  };
455
263
  i(), a();
456
264
  });
457
265
  subscribeToSessionEvents(e) {
458
266
  this.events.eachTriggers((t, s) => {
459
- const i = Tt.find((r) => r === s);
267
+ const i = H.find((r) => r === s);
460
268
  i && (e.on(i, t), this.disposers.add(() => {
461
269
  e.off(i, t);
462
270
  }));
@@ -475,11 +283,11 @@ class en extends Kt {
475
283
  delete this.rtcSession, this.remoteStreamsManager.reset(), this.unsubscribeFromSessionEvents(), this.callConfiguration.number = void 0, this.callConfiguration.answer = !1;
476
284
  };
477
285
  }
478
- class tn {
286
+ class ge {
479
287
  events;
480
288
  strategy;
481
289
  constructor(e) {
482
- this.events = new D(xt), this.strategy = e ?? new en(this.events);
290
+ this.events = new O(G), this.strategy = e ?? new ce(this.events);
483
291
  }
484
292
  get requested() {
485
293
  return this.strategy.requested;
@@ -523,179 +331,13 @@ class tn {
523
331
  getRemoteStreams = () => this.strategy.getRemoteStreams();
524
332
  replaceMediaStream = async (...e) => this.strategy.replaceMediaStream(...e);
525
333
  }
526
- var R = /* @__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))(R || {});
527
- const nn = [
528
- "presentation:start",
529
- "presentation:started",
530
- "presentation:end",
531
- "presentation:ended",
532
- "presentation:failed"
533
- ], sn = 1, Fn = (n) => ht(n);
534
- class rn {
535
- promisePendingStartPresentation;
536
- promisePendingStopPresentation;
537
- streamPresentationCurrent;
538
- events;
539
- cancelableSendPresentationWithRepeatedCalls;
540
- callManager;
541
- constructor({ callManager: e }) {
542
- this.callManager = e, this.events = new D(nn), this.subscribe();
543
- }
544
- get isPendingPresentation() {
545
- return !!this.promisePendingStartPresentation || !!this.promisePendingStopPresentation;
546
- }
547
- // eslint-disable-next-line @typescript-eslint/max-params
548
- async startPresentation(e, t, {
549
- isNeedReinvite: s,
550
- maxBitrate: i,
551
- contentHint: r,
552
- sendEncodings: a,
553
- onAddedTransceiver: o
554
- } = {}, c) {
555
- const T = this.getRtcSessionProtected();
556
- if (this.streamPresentationCurrent)
557
- throw new Error("Presentation is already started");
558
- return this.sendPresentationWithDuplicatedCalls(e, {
559
- rtcSession: T,
560
- stream: t,
561
- presentationOptions: {
562
- isNeedReinvite: s,
563
- maxBitrate: i,
564
- contentHint: r,
565
- sendEncodings: a,
566
- onAddedTransceiver: o
567
- },
568
- options: c
569
- });
570
- }
571
- async stopPresentation(e) {
572
- this.cancelSendPresentationWithRepeatedCalls();
573
- const t = this.streamPresentationCurrent;
574
- let s = this.promisePendingStartPresentation ?? Promise.resolve(void 0);
575
- const i = this.callManager.getEstablishedRTCSession();
576
- return i && t ? s = e().then(async () => i.stopPresentation(t)).catch((r) => {
577
- throw this.events.trigger(R.FAILED_PRESENTATION, r), r;
578
- }) : t && this.events.trigger(R.ENDED_PRESENTATION, t), this.promisePendingStopPresentation = s, s.finally(() => {
579
- this.resetPresentation();
580
- });
581
- }
582
- async updatePresentation(e, t, {
583
- // maxBitrate,
584
- contentHint: s,
585
- sendEncodings: i,
586
- onAddedTransceiver: r
587
- } = {}) {
588
- const a = this.getRtcSessionProtected();
589
- if (!this.streamPresentationCurrent)
590
- throw new Error("Presentation has not started yet");
591
- return this.promisePendingStartPresentation && await this.promisePendingStartPresentation, this.sendPresentation(e, a, t, {
592
- // maxBitrate,
593
- contentHint: s,
594
- isNeedReinvite: !1,
595
- sendEncodings: i,
596
- onAddedTransceiver: r
597
- });
598
- }
599
- cancelSendPresentationWithRepeatedCalls() {
600
- this.cancelableSendPresentationWithRepeatedCalls?.cancel();
601
- }
602
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
603
- on(e, t) {
604
- return this.events.on(e, t);
605
- }
606
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
607
- once(e, t) {
608
- return this.events.once(e, t);
609
- }
610
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
611
- onceRace(e, t) {
612
- return this.events.onceRace(e, t);
613
- }
614
- async wait(e) {
615
- return this.events.wait(e);
616
- }
617
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
618
- off(e, t) {
619
- this.events.off(e, t);
620
- }
621
- subscribe() {
622
- this.callManager.on("presentation:start", (e) => {
623
- this.events.trigger(R.START_PRESENTATION, e);
624
- }), this.callManager.on("presentation:started", (e) => {
625
- this.events.trigger(R.STARTED_PRESENTATION, e);
626
- }), this.callManager.on("presentation:end", (e) => {
627
- this.events.trigger(R.END_PRESENTATION, e);
628
- }), this.callManager.on("presentation:ended", (e) => {
629
- this.events.trigger(R.ENDED_PRESENTATION, e);
630
- }), this.callManager.on("presentation:failed", (e) => {
631
- this.events.trigger(R.FAILED_PRESENTATION, e);
632
- }), this.callManager.on("failed", this.handleEnded), this.callManager.on("ended", this.handleEnded);
633
- }
634
- async sendPresentationWithDuplicatedCalls(e, {
635
- rtcSession: t,
636
- stream: s,
637
- presentationOptions: i,
638
- options: r = {
639
- callLimit: sn
640
- }
641
- }) {
642
- const a = async () => this.sendPresentation(
643
- e,
644
- t,
645
- s,
646
- i
647
- ), o = () => !!this.streamPresentationCurrent;
648
- return this.cancelableSendPresentationWithRepeatedCalls = G({
649
- targetFunction: a,
650
- isComplete: o,
651
- isRejectAsValid: !0,
652
- ...r
653
- }), this.cancelableSendPresentationWithRepeatedCalls.then((c) => c);
654
- }
655
- // eslint-disable-next-line @typescript-eslint/max-params
656
- async sendPresentation(e, t, s, {
657
- // maxBitrate = ONE_MEGABIT_IN_BITS,
658
- isNeedReinvite: i = !0,
659
- contentHint: r = "detail",
660
- sendEncodings: a,
661
- onAddedTransceiver: o
662
- }) {
663
- const c = v(s, { contentHint: r });
664
- if (c === void 0)
665
- throw new Error("No streamPresentationTarget");
666
- this.streamPresentationCurrent = c;
667
- const T = e().then(async () => t.startPresentation(c, i, {
668
- sendEncodings: a,
669
- onAddedTransceiver: o
670
- })).then(() => s).catch((S) => {
671
- throw this.removeStreamPresentationCurrent(), this.events.trigger(R.FAILED_PRESENTATION, S), S;
672
- });
673
- return this.promisePendingStartPresentation = T, T.finally(() => {
674
- this.promisePendingStartPresentation = void 0;
675
- });
676
- }
677
- getRtcSessionProtected = () => {
678
- const e = this.callManager.getEstablishedRTCSession();
679
- if (!e)
680
- throw new Error("No rtcSession established");
681
- return e;
682
- };
683
- handleEnded = () => {
684
- this.reset();
685
- };
686
- reset() {
687
- this.cancelSendPresentationWithRepeatedCalls(), this.resetPresentation();
688
- }
689
- resetPresentation() {
690
- this.removeStreamPresentationCurrent(), this.promisePendingStartPresentation = void 0, this.promisePendingStopPresentation = void 0;
691
- }
692
- removeStreamPresentationCurrent() {
693
- delete this.streamPresentationCurrent;
694
- }
695
- }
696
- const an = "Error decline with 603", on = 1006, cn = (n) => typeof n == "object" && n !== null && "code" in n && n.code === on, Tn = (n) => n.message === an;
697
- var g = /* @__PURE__ */ ((n) => (n.CONTENT_TYPE_NAME = "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))(g || {}), y = /* @__PURE__ */ ((n) => (n.AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(y || {}), w = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(w || {}), M = /* @__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))(M || {}), u = /* @__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))(u || {}), m = /* @__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))(m || {}), L = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(L || {}), F = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(F || {}), E = /* @__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))(E || {});
698
- const En = [
334
+ const W = "sip-connector", P = k(W), He = () => {
335
+ k.enable(W);
336
+ }, Ge = () => {
337
+ k.enable(`-${W}`);
338
+ }, Te = "Error decline with 603", he = 1006, de = (n) => typeof n == "object" && n !== null && "code" in n && n.code === he, le = (n) => n.message === Te;
339
+ var h = /* @__PURE__ */ ((n) => (n.CONTENT_TYPE = "content-type", n.CONTENT_ENTER_ROOM = "x-webrtc-enter-room", n.CONTENT_USE_LICENSE = "X-WEBRTC-USE-LICENSE", n.PARTICIPANT_NAME = "X-WEBRTC-PARTICIPANT-NAME", n.INPUT_CHANNELS = "X-WEBRTC-INPUT-CHANNELS", n.OUTPUT_CHANNELS = "X-WEBRTC-OUTPUT-CHANNELS", n.MAIN_CAM = "X-WEBRTC-MAINCAM", n.MIC = "X-WEBRTC-MIC", n.MEDIA_SYNC = "X-WEBRTC-SYNC", n.MAIN_CAM_RESOLUTION = "X-WEBRTC-MAINCAM-RESOLUTION", n.MEDIA_STATE = "X-WEBRTC-MEDIA-STATE", n.MEDIA_TYPE = "X-Vinteo-Media-Type", n.MAIN_CAM_STATE = "X-Vinteo-MainCam-State", n.MIC_STATE = "X-Vinteo-Mic-State", n.CONTENT_PARTICIPANT_STATE = "X-WEBRTC-PARTSTATE", n.NOTIFY = "X-VINTEO-NOTIFY", n.CONTENT_ENABLE_MEDIA_DEVICE = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", n.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))(h || {}), y = /* @__PURE__ */ ((n) => (n.AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(y || {}), w = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(w || {}), M = /* @__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))(M || {}), _ = /* @__PURE__ */ ((n) => (n.CHANNELS = "application/vinteo.webrtc.channels", n.MEDIA_STATE = "application/vinteo.webrtc.mediastate", n.REFUSAL = "application/vinteo.webrtc.refusal", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n))(_ || {}), 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 || {}), L = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(L || {}), F = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(F || {}), Ee = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(Ee || {}), T = /* @__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))(T || {});
340
+ const q = [
699
341
  "participation:accepting-word-request",
700
342
  "participation:cancelling-word-request",
701
343
  "participant:move-request-to-stream",
@@ -724,8 +366,8 @@ const En = [
724
366
  "mustStopPresentation",
725
367
  "newDTMF"
726
368
  ];
727
- var _ = /* @__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))(_ || {});
728
- class gn {
369
+ var A = /* @__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))(A || {});
370
+ class Se {
729
371
  events;
730
372
  connectionManager;
731
373
  callManager;
@@ -733,13 +375,13 @@ class gn {
733
375
  connectionManager: e,
734
376
  callManager: t
735
377
  }) {
736
- this.connectionManager = e, this.callManager = t, this.events = new D(En), this.subscribe();
378
+ this.connectionManager = e, this.callManager = t, this.events = new O(q), this.subscribe();
737
379
  }
738
380
  async waitChannels() {
739
- return this.wait(E.CHANNELS);
381
+ return this.wait(T.CHANNELS);
740
382
  }
741
383
  async waitSyncMediaState() {
742
- return this.wait(E.ADMIN_FORCE_SYNC_MEDIA_STATE);
384
+ return this.wait(T.ADMIN_FORCE_SYNC_MEDIA_STATE);
743
385
  }
744
386
  async sendDTMF(e) {
745
387
  return new Promise((t, s) => {
@@ -760,22 +402,22 @@ class gn {
760
402
  const s = this.callManager.getEstablishedRTCSession();
761
403
  if (!s)
762
404
  throw new Error("No rtcSession established");
763
- const i = `${g.INPUT_CHANNELS}: ${e}`, r = `${g.OUTPUT_CHANNELS}: ${t}`, a = [
405
+ const i = `${h.INPUT_CHANNELS}: ${e}`, r = `${h.OUTPUT_CHANNELS}: ${t}`, a = [
764
406
  i,
765
407
  r
766
408
  ];
767
- return s.sendInfo(u.CHANNELS, void 0, { extraHeaders: a });
409
+ return s.sendInfo(_.CHANNELS, void 0, { extraHeaders: a });
768
410
  }
769
411
  async sendMediaState({ cam: e, mic: t }, s = {}) {
770
412
  const i = this.callManager.getEstablishedRTCSession();
771
413
  if (!i)
772
414
  throw new Error("No rtcSession established");
773
- const r = `${g.MEDIA_STATE}: currentstate`, a = `${g.MAIN_CAM_STATE}: ${Number(e)}`, o = `${g.MIC_STATE}: ${Number(t)}`, c = [
415
+ const r = `${h.MEDIA_STATE}: currentstate`, a = `${h.MAIN_CAM_STATE}: ${Number(e)}`, o = `${h.MIC_STATE}: ${Number(t)}`, c = [
774
416
  r,
775
417
  a,
776
418
  o
777
419
  ];
778
- return i.sendInfo(u.MEDIA_STATE, void 0, {
420
+ return i.sendInfo(_.MEDIA_STATE, void 0, {
779
421
  noTerminateWhenError: !0,
780
422
  ...s,
781
423
  extraHeaders: c
@@ -785,8 +427,8 @@ class gn {
785
427
  const s = this.callManager.getEstablishedRTCSession();
786
428
  if (!s)
787
429
  throw new Error("No rtcSession established");
788
- const a = e === "mic" ? 0 : 1, c = [`${g.MEDIA_TYPE}: ${a}`];
789
- return s.sendInfo(u.REFUSAL, void 0, {
430
+ const a = e === "mic" ? 0 : 1, c = [`${h.MEDIA_TYPE}: ${a}`];
431
+ return s.sendInfo(_.REFUSAL, void 0, {
790
432
  noTerminateWhenError: !0,
791
433
  ...t,
792
434
  extraHeaders: c
@@ -806,53 +448,53 @@ class gn {
806
448
  const e = this.callManager.getEstablishedRTCSession();
807
449
  if (!e)
808
450
  throw new Error("No rtcSession established");
809
- await e.sendInfo(u.SHARE_STATE, void 0, {
810
- extraHeaders: [g.MUST_STOP_PRESENTATION_P2P]
451
+ await e.sendInfo(_.SHARE_STATE, void 0, {
452
+ extraHeaders: [h.MUST_STOP_PRESENTATION_P2P]
811
453
  });
812
454
  }
813
455
  async sendStoppedPresentationP2P() {
814
456
  const e = this.callManager.getEstablishedRTCSession();
815
457
  if (!e)
816
458
  throw new Error("No rtcSession established");
817
- await e.sendInfo(u.SHARE_STATE, void 0, {
818
- extraHeaders: [g.STOP_PRESENTATION_P2P]
459
+ await e.sendInfo(_.SHARE_STATE, void 0, {
460
+ extraHeaders: [h.STOP_PRESENTATION_P2P]
819
461
  });
820
462
  }
821
463
  async sendStoppedPresentation() {
822
464
  const e = this.callManager.getEstablishedRTCSession();
823
465
  if (!e)
824
466
  throw new Error("No rtcSession established");
825
- await e.sendInfo(u.SHARE_STATE, void 0, {
826
- extraHeaders: [g.STOP_PRESENTATION]
467
+ await e.sendInfo(_.SHARE_STATE, void 0, {
468
+ extraHeaders: [h.STOP_PRESENTATION]
827
469
  });
828
470
  }
829
471
  async askPermissionToStartPresentationP2P() {
830
472
  const e = this.callManager.getEstablishedRTCSession();
831
473
  if (!e)
832
474
  throw new Error("No rtcSession established");
833
- await e.sendInfo(u.SHARE_STATE, void 0, {
834
- extraHeaders: [g.START_PRESENTATION_P2P]
475
+ await e.sendInfo(_.SHARE_STATE, void 0, {
476
+ extraHeaders: [h.START_PRESENTATION_P2P]
835
477
  });
836
478
  }
837
479
  async askPermissionToStartPresentation() {
838
480
  const e = this.callManager.getEstablishedRTCSession();
839
481
  if (!e)
840
482
  throw new Error("No rtcSession established");
841
- await e.sendInfo(u.SHARE_STATE, void 0, {
842
- extraHeaders: [g.START_PRESENTATION]
483
+ await e.sendInfo(_.SHARE_STATE, void 0, {
484
+ extraHeaders: [h.START_PRESENTATION]
843
485
  });
844
486
  }
845
487
  async askPermissionToEnableCam(e = {}) {
846
488
  const t = this.callManager.getEstablishedRTCSession();
847
489
  if (!t)
848
490
  throw new Error("No rtcSession established");
849
- const s = [g.ENABLE_MAIN_CAM];
850
- return t.sendInfo(u.MAIN_CAM, void 0, {
491
+ const s = [h.ENABLE_MAIN_CAM];
492
+ return t.sendInfo(_.MAIN_CAM, void 0, {
851
493
  noTerminateWhenError: !0,
852
494
  ...e,
853
495
  extraHeaders: s
854
496
  }).catch((i) => {
855
- if (Tn(i))
497
+ if (le(i))
856
498
  throw i;
857
499
  });
858
500
  }
@@ -885,7 +527,7 @@ class gn {
885
527
  };
886
528
  maybeHandleNotify = (e) => {
887
529
  try {
888
- const t = e.getHeader(g.NOTIFY);
530
+ const t = e.getHeader(h.NOTIFY);
889
531
  if (t) {
890
532
  const s = JSON.parse(t);
891
533
  this.handleNotify(s);
@@ -896,55 +538,55 @@ class gn {
896
538
  };
897
539
  handleNotify = (e) => {
898
540
  switch (e.cmd) {
899
- case _.CHANNELS: {
541
+ case A.CHANNELS: {
900
542
  const t = e;
901
543
  this.triggerChannelsNotify(t);
902
544
  break;
903
545
  }
904
- case _.WEBCAST_STARTED: {
546
+ case A.WEBCAST_STARTED: {
905
547
  const t = e;
906
548
  this.triggerWebcastStartedNotify(t);
907
549
  break;
908
550
  }
909
- case _.WEBCAST_STOPPED: {
551
+ case A.WEBCAST_STOPPED: {
910
552
  const t = e;
911
553
  this.triggerWebcastStoppedNotify(t);
912
554
  break;
913
555
  }
914
- case _.ADDED_TO_LIST_MODERATORS: {
556
+ case A.ADDED_TO_LIST_MODERATORS: {
915
557
  const t = e;
916
558
  this.triggerAddedToListModeratorsNotify(t);
917
559
  break;
918
560
  }
919
- case _.REMOVED_FROM_LIST_MODERATORS: {
561
+ case A.REMOVED_FROM_LIST_MODERATORS: {
920
562
  const t = e;
921
563
  this.triggerRemovedFromListModeratorsNotify(t);
922
564
  break;
923
565
  }
924
- case _.ACCEPTING_WORD_REQUEST: {
566
+ case A.ACCEPTING_WORD_REQUEST: {
925
567
  const t = e;
926
568
  this.triggerParticipationAcceptingWordRequest(t);
927
569
  break;
928
570
  }
929
- case _.CANCELLING_WORD_REQUEST: {
571
+ case A.CANCELLING_WORD_REQUEST: {
930
572
  const t = e;
931
573
  this.triggerParticipationCancellingWordRequest(t);
932
574
  break;
933
575
  }
934
- case _.MOVE_REQUEST_TO_STREAM: {
576
+ case A.MOVE_REQUEST_TO_STREAM: {
935
577
  const t = e;
936
578
  this.triggerParticipantMoveRequestToStream(t);
937
579
  break;
938
580
  }
939
- case _.ACCOUNT_CHANGED: {
581
+ case A.ACCOUNT_CHANGED: {
940
582
  this.triggerAccountChangedNotify();
941
583
  break;
942
584
  }
943
- case _.ACCOUNT_DELETED: {
585
+ case A.ACCOUNT_DELETED: {
944
586
  this.triggerAccountDeletedNotify();
945
587
  break;
946
588
  }
947
- case _.CONFERENCE_PARTICIPANT_TOKEN_ISSUED: {
589
+ case A.CONFERENCE_PARTICIPANT_TOKEN_ISSUED: {
948
590
  const t = e;
949
591
  this.triggerConferenceParticipantTokenIssued(t);
950
592
  break;
@@ -957,7 +599,7 @@ class gn {
957
599
  const { originator: t } = e;
958
600
  if (t !== U.REMOTE)
959
601
  return;
960
- const { request: s } = e, i = s.getHeader(g.CONTENT_TYPE_NAME);
602
+ const { request: s } = e, i = s.getHeader(h.CONTENT_TYPE);
961
603
  if (i !== void 0)
962
604
  switch (i) {
963
605
  case M.ENTER_ROOM: {
@@ -995,7 +637,7 @@ class gn {
995
637
  inputChannels: t,
996
638
  outputChannels: s
997
639
  };
998
- this.events.trigger(E.CHANNELS_NOTIFY, i);
640
+ this.events.trigger(T.CHANNELS_NOTIFY, i);
999
641
  };
1000
642
  triggerWebcastStartedNotify = ({
1001
643
  body: { conference: e, type: t }
@@ -1004,7 +646,7 @@ class gn {
1004
646
  conference: e,
1005
647
  type: t
1006
648
  };
1007
- this.events.trigger(E.WEBCAST_STARTED, s);
649
+ this.events.trigger(T.WEBCAST_STARTED, s);
1008
650
  };
1009
651
  triggerWebcastStoppedNotify = ({
1010
652
  body: { conference: e, type: t }
@@ -1013,7 +655,7 @@ class gn {
1013
655
  conference: e,
1014
656
  type: t
1015
657
  };
1016
- this.events.trigger(E.WEBCAST_STOPPED, s);
658
+ this.events.trigger(T.WEBCAST_STOPPED, s);
1017
659
  };
1018
660
  triggerAddedToListModeratorsNotify = ({
1019
661
  conference: e
@@ -1022,7 +664,7 @@ class gn {
1022
664
  conference: e
1023
665
  };
1024
666
  this.events.trigger(
1025
- E.PARTICIPANT_ADDED_TO_LIST_MODERATORS,
667
+ T.PARTICIPANT_ADDED_TO_LIST_MODERATORS,
1026
668
  t
1027
669
  );
1028
670
  };
@@ -1033,7 +675,7 @@ class gn {
1033
675
  conference: e
1034
676
  };
1035
677
  this.events.trigger(
1036
- E.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS,
678
+ T.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS,
1037
679
  t
1038
680
  );
1039
681
  };
@@ -1043,7 +685,7 @@ class gn {
1043
685
  const t = {
1044
686
  conference: e
1045
687
  };
1046
- this.events.trigger(E.PARTICIPATION_ACCEPTING_WORD_REQUEST, t);
688
+ this.events.trigger(T.PARTICIPATION_ACCEPTING_WORD_REQUEST, t);
1047
689
  };
1048
690
  triggerParticipationCancellingWordRequest = ({
1049
691
  body: { conference: e }
@@ -1051,7 +693,7 @@ class gn {
1051
693
  const t = {
1052
694
  conference: e
1053
695
  };
1054
- this.events.trigger(E.PARTICIPATION_CANCELLING_WORD_REQUEST, t);
696
+ this.events.trigger(T.PARTICIPATION_CANCELLING_WORD_REQUEST, t);
1055
697
  };
1056
698
  triggerParticipantMoveRequestToStream = ({
1057
699
  body: { conference: e }
@@ -1059,13 +701,13 @@ class gn {
1059
701
  const t = {
1060
702
  conference: e
1061
703
  };
1062
- this.events.trigger(E.PARTICIPANT_MOVE_REQUEST_TO_STREAM, t);
704
+ this.events.trigger(T.PARTICIPANT_MOVE_REQUEST_TO_STREAM, t);
1063
705
  };
1064
706
  triggerAccountChangedNotify = () => {
1065
- this.events.trigger(E.ACCOUNT_CHANGED, void 0);
707
+ this.events.trigger(T.ACCOUNT_CHANGED, void 0);
1066
708
  };
1067
709
  triggerAccountDeletedNotify = () => {
1068
- this.events.trigger(E.ACCOUNT_DELETED, void 0);
710
+ this.events.trigger(T.ACCOUNT_DELETED, void 0);
1069
711
  };
1070
712
  triggerConferenceParticipantTokenIssued = ({
1071
713
  body: { conference: e, participant: t, jwt: s }
@@ -1076,73 +718,243 @@ class gn {
1076
718
  jwt: s
1077
719
  };
1078
720
  this.events.trigger(
1079
- E.CONFERENCE_PARTICIPANT_TOKEN_ISSUED,
721
+ T.CONFERENCE_PARTICIPANT_TOKEN_ISSUED,
1080
722
  i
1081
723
  );
1082
724
  };
1083
725
  maybeTriggerChannels = (e) => {
1084
- const t = e.getHeader(g.INPUT_CHANNELS), s = e.getHeader(g.OUTPUT_CHANNELS);
726
+ const t = e.getHeader(h.INPUT_CHANNELS), s = e.getHeader(h.OUTPUT_CHANNELS);
1085
727
  if (t && s) {
1086
728
  const i = {
1087
729
  inputChannels: t,
1088
730
  outputChannels: s
1089
731
  };
1090
- this.events.trigger(E.CHANNELS, i);
732
+ this.events.trigger(T.CHANNELS, i);
1091
733
  }
1092
734
  };
1093
735
  triggerEnterRoom = (e) => {
1094
- const t = e.getHeader(g.CONTENT_ENTER_ROOM), s = e.getHeader(g.PARTICIPANT_NAME);
1095
- this.events.trigger(E.ENTER_ROOM, { room: t, participantName: s });
736
+ const t = e.getHeader(h.CONTENT_ENTER_ROOM), s = e.getHeader(h.PARTICIPANT_NAME);
737
+ this.events.trigger(T.ENTER_ROOM, { room: t, participantName: s });
1096
738
  };
1097
739
  triggerShareState = (e) => {
1098
- const t = e.getHeader(g.CONTENT_SHARE_STATE);
740
+ const t = e.getHeader(h.CONTENT_SHARE_STATE);
1099
741
  if (t !== void 0)
1100
742
  switch (t) {
1101
743
  case y.AVAILABLE_SECOND_REMOTE_STREAM: {
1102
- this.events.trigger(E.AVAILABLE_SECOND_REMOTE_STREAM, void 0);
744
+ this.events.trigger(T.AVAILABLE_SECOND_REMOTE_STREAM, void 0);
1103
745
  break;
1104
746
  }
1105
747
  case y.NOT_AVAILABLE_SECOND_REMOTE_STREAM: {
1106
- this.events.trigger(E.NOT_AVAILABLE_SECOND_REMOTE_STREAM, void 0);
748
+ this.events.trigger(T.NOT_AVAILABLE_SECOND_REMOTE_STREAM, void 0);
1107
749
  break;
1108
750
  }
1109
751
  case y.MUST_STOP_PRESENTATION: {
1110
- this.events.trigger(E.MUST_STOP_PRESENTATION, void 0);
752
+ this.events.trigger(T.MUST_STOP_PRESENTATION, void 0);
1111
753
  break;
1112
754
  }
1113
755
  }
1114
756
  };
1115
757
  maybeTriggerParticipantMoveRequest = (e) => {
1116
- const t = e.getHeader(g.CONTENT_PARTICIPANT_STATE);
1117
- t === w.SPECTATOR && this.events.trigger(E.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, void 0), t === w.PARTICIPANT && this.events.trigger(E.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS, void 0);
758
+ const t = e.getHeader(h.CONTENT_PARTICIPANT_STATE);
759
+ t === w.SPECTATOR && this.events.trigger(T.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, void 0), t === w.PARTICIPANT && this.events.trigger(T.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS, void 0);
1118
760
  };
1119
761
  triggerMainCamControl = (e) => {
1120
- const t = e.getHeader(g.MAIN_CAM), s = e.getHeader(g.MEDIA_SYNC), i = s === F.ADMIN_SYNC_FORCED;
1121
- if (t === m.ADMIN_START_MAIN_CAM) {
1122
- this.events.trigger(E.ADMIN_START_MAIN_CAM, { isSyncForced: i });
762
+ const t = e.getHeader(h.MAIN_CAM), s = e.getHeader(h.MEDIA_SYNC), i = s === F.ADMIN_SYNC_FORCED;
763
+ if (t === f.ADMIN_START_MAIN_CAM) {
764
+ this.events.trigger(T.ADMIN_START_MAIN_CAM, { isSyncForced: i });
1123
765
  return;
1124
766
  }
1125
- if (t === m.ADMIN_STOP_MAIN_CAM) {
1126
- this.events.trigger(E.ADMIN_STOP_MAIN_CAM, { isSyncForced: i });
767
+ if (t === f.ADMIN_STOP_MAIN_CAM) {
768
+ this.events.trigger(T.ADMIN_STOP_MAIN_CAM, { isSyncForced: i });
1127
769
  return;
1128
770
  }
1129
- (t === m.RESUME_MAIN_CAM || t === m.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(E.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: i });
1130
- const r = e.getHeader(g.MAIN_CAM_RESOLUTION);
1131
- this.events.trigger(E.MAIN_CAM_CONTROL, {
771
+ (t === f.RESUME_MAIN_CAM || t === f.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(T.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: i });
772
+ const r = e.getHeader(h.MAIN_CAM_RESOLUTION);
773
+ this.events.trigger(T.MAIN_CAM_CONTROL, {
1132
774
  mainCam: t,
1133
775
  resolutionMainCam: r
1134
776
  });
1135
777
  };
1136
778
  triggerMicControl = (e) => {
1137
- const t = e.getHeader(g.MIC), i = e.getHeader(g.MEDIA_SYNC) === F.ADMIN_SYNC_FORCED;
1138
- t === L.ADMIN_START_MIC ? this.events.trigger(E.ADMIN_START_MIC, { isSyncForced: i }) : t === L.ADMIN_STOP_MIC && this.events.trigger(E.ADMIN_STOP_MIC, { isSyncForced: i });
779
+ const t = e.getHeader(h.MIC), i = e.getHeader(h.MEDIA_SYNC) === F.ADMIN_SYNC_FORCED;
780
+ t === L.ADMIN_START_MIC ? this.events.trigger(T.ADMIN_START_MIC, { isSyncForced: i }) : t === L.ADMIN_STOP_MIC && this.events.trigger(T.ADMIN_STOP_MIC, { isSyncForced: i });
1139
781
  };
1140
782
  triggerUseLicense = (e) => {
1141
- const t = e.getHeader(g.CONTENT_USE_LICENSE);
1142
- this.events.trigger(E.USE_LICENSE, t);
783
+ const t = e.getHeader(h.CONTENT_USE_LICENSE);
784
+ this.events.trigger(T.USE_LICENSE, t);
785
+ };
786
+ }
787
+ var R = /* @__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))(R || {});
788
+ const Y = [
789
+ "presentation:start",
790
+ "presentation:started",
791
+ "presentation:end",
792
+ "presentation:ended",
793
+ "presentation:failed"
794
+ ], Ce = 1, Be = (n) => K(n);
795
+ class Ne {
796
+ events;
797
+ promisePendingStartPresentation;
798
+ promisePendingStopPresentation;
799
+ streamPresentationCurrent;
800
+ cancelableSendPresentationWithRepeatedCalls;
801
+ callManager;
802
+ constructor({ callManager: e }) {
803
+ this.callManager = e, this.events = new O(Y), this.subscribe();
804
+ }
805
+ get isPendingPresentation() {
806
+ return !!this.promisePendingStartPresentation || !!this.promisePendingStopPresentation;
807
+ }
808
+ // eslint-disable-next-line @typescript-eslint/max-params
809
+ async startPresentation(e, t, {
810
+ isNeedReinvite: s,
811
+ maxBitrate: i,
812
+ contentHint: r,
813
+ sendEncodings: a,
814
+ onAddedTransceiver: o
815
+ } = {}, c) {
816
+ const g = this.getRtcSessionProtected();
817
+ if (this.streamPresentationCurrent)
818
+ throw new Error("Presentation is already started");
819
+ return this.sendPresentationWithDuplicatedCalls(e, {
820
+ rtcSession: g,
821
+ stream: t,
822
+ presentationOptions: {
823
+ isNeedReinvite: s,
824
+ maxBitrate: i,
825
+ contentHint: r,
826
+ sendEncodings: a,
827
+ onAddedTransceiver: o
828
+ },
829
+ options: c
830
+ });
831
+ }
832
+ async stopPresentation(e) {
833
+ this.cancelSendPresentationWithRepeatedCalls();
834
+ const t = this.streamPresentationCurrent;
835
+ let s = this.promisePendingStartPresentation ?? Promise.resolve(void 0);
836
+ const i = this.callManager.getEstablishedRTCSession();
837
+ return i && t ? s = e().then(async () => i.stopPresentation(t)).catch((r) => {
838
+ throw this.events.trigger(R.FAILED_PRESENTATION, r), r;
839
+ }) : t && this.events.trigger(R.ENDED_PRESENTATION, t), this.promisePendingStopPresentation = s, s.finally(() => {
840
+ this.resetPresentation();
841
+ });
842
+ }
843
+ async updatePresentation(e, t, {
844
+ // maxBitrate,
845
+ contentHint: s,
846
+ sendEncodings: i,
847
+ onAddedTransceiver: r
848
+ } = {}) {
849
+ const a = this.getRtcSessionProtected();
850
+ if (!this.streamPresentationCurrent)
851
+ throw new Error("Presentation has not started yet");
852
+ return this.promisePendingStartPresentation && await this.promisePendingStartPresentation, this.sendPresentation(e, a, t, {
853
+ // maxBitrate,
854
+ contentHint: s,
855
+ isNeedReinvite: !1,
856
+ sendEncodings: i,
857
+ onAddedTransceiver: r
858
+ });
859
+ }
860
+ cancelSendPresentationWithRepeatedCalls() {
861
+ this.cancelableSendPresentationWithRepeatedCalls?.cancel();
862
+ }
863
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
864
+ on(e, t) {
865
+ return this.events.on(e, t);
866
+ }
867
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
868
+ once(e, t) {
869
+ return this.events.once(e, t);
870
+ }
871
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
872
+ onceRace(e, t) {
873
+ return this.events.onceRace(e, t);
874
+ }
875
+ async wait(e) {
876
+ return this.events.wait(e);
877
+ }
878
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
879
+ off(e, t) {
880
+ this.events.off(e, t);
881
+ }
882
+ subscribe() {
883
+ this.callManager.on("presentation:start", (e) => {
884
+ this.events.trigger(R.START_PRESENTATION, e);
885
+ }), this.callManager.on("presentation:started", (e) => {
886
+ this.events.trigger(R.STARTED_PRESENTATION, e);
887
+ }), this.callManager.on("presentation:end", (e) => {
888
+ this.events.trigger(R.END_PRESENTATION, e);
889
+ }), this.callManager.on("presentation:ended", (e) => {
890
+ this.events.trigger(R.ENDED_PRESENTATION, e);
891
+ }), this.callManager.on("presentation:failed", (e) => {
892
+ this.events.trigger(R.FAILED_PRESENTATION, e);
893
+ }), this.callManager.on("failed", this.handleEnded), this.callManager.on("ended", this.handleEnded);
894
+ }
895
+ async sendPresentationWithDuplicatedCalls(e, {
896
+ rtcSession: t,
897
+ stream: s,
898
+ presentationOptions: i,
899
+ options: r = {
900
+ callLimit: Ce
901
+ }
902
+ }) {
903
+ const a = async () => this.sendPresentation(
904
+ e,
905
+ t,
906
+ s,
907
+ i
908
+ ), o = () => !!this.streamPresentationCurrent;
909
+ return this.cancelableSendPresentationWithRepeatedCalls = V({
910
+ targetFunction: a,
911
+ isComplete: o,
912
+ isRejectAsValid: !0,
913
+ ...r
914
+ }), this.cancelableSendPresentationWithRepeatedCalls.then((c) => c);
915
+ }
916
+ // eslint-disable-next-line @typescript-eslint/max-params
917
+ async sendPresentation(e, t, s, {
918
+ // maxBitrate = ONE_MEGABIT_IN_BITS,
919
+ isNeedReinvite: i = !0,
920
+ contentHint: r = "detail",
921
+ sendEncodings: a,
922
+ onAddedTransceiver: o
923
+ }) {
924
+ const c = v(s, { contentHint: r });
925
+ if (c === void 0)
926
+ throw new Error("No streamPresentationTarget");
927
+ this.streamPresentationCurrent = c;
928
+ const g = e().then(async () => t.startPresentation(c, i, {
929
+ sendEncodings: a,
930
+ onAddedTransceiver: o
931
+ })).then(() => s).catch((d) => {
932
+ throw this.removeStreamPresentationCurrent(), this.events.trigger(R.FAILED_PRESENTATION, d), d;
933
+ });
934
+ return this.promisePendingStartPresentation = g, g.finally(() => {
935
+ this.promisePendingStartPresentation = void 0;
936
+ });
937
+ }
938
+ getRtcSessionProtected = () => {
939
+ const e = this.callManager.getEstablishedRTCSession();
940
+ if (!e)
941
+ throw new Error("No rtcSession established");
942
+ return e;
1143
943
  };
944
+ handleEnded = () => {
945
+ this.reset();
946
+ };
947
+ reset() {
948
+ this.cancelSendPresentationWithRepeatedCalls(), this.resetPresentation();
949
+ }
950
+ resetPresentation() {
951
+ this.removeStreamPresentationCurrent(), this.promisePendingStartPresentation = void 0, this.promisePendingStopPresentation = void 0;
952
+ }
953
+ removeStreamPresentationCurrent() {
954
+ delete this.streamPresentationCurrent;
955
+ }
1144
956
  }
1145
- class Sn {
957
+ class ue {
1146
958
  data = {};
1147
959
  getUa;
1148
960
  constructor(e) {
@@ -1215,8 +1027,8 @@ class Sn {
1215
1027
  return this.data.register === !0;
1216
1028
  }
1217
1029
  }
1218
- var A = /* @__PURE__ */ ((n) => (n.CONNECTING = "connecting", n.CONNECTED = "connected", n.DISCONNECTED = "disconnected", n.NEW_RTC_SESSION = "newRTCSession", n.REGISTERED = "registered", n.UNREGISTERED = "unregistered", n.REGISTRATION_FAILED = "registrationFailed", n.NEW_MESSAGE = "newMessage", n.SIP_EVENT = "sipEvent", n))(A || {});
1219
- const St = [
1030
+ var u = /* @__PURE__ */ ((n) => (n.CONNECTING = "connecting", n.CONNECTED = "connected", n.DISCONNECTED = "disconnected", n.NEW_RTC_SESSION = "newRTCSession", n.REGISTERED = "registered", n.UNREGISTERED = "unregistered", n.REGISTRATION_FAILED = "registrationFailed", n.NEW_MESSAGE = "newMessage", n.SIP_EVENT = "sipEvent", n))(u || {});
1031
+ const z = [
1220
1032
  "connecting",
1221
1033
  "connected",
1222
1034
  "disconnected",
@@ -1226,8 +1038,8 @@ const St = [
1226
1038
  "registrationFailed",
1227
1039
  "newMessage",
1228
1040
  "sipEvent"
1229
- ], dn = [...St], hn = 3;
1230
- class ln {
1041
+ ], Q = [...z], Ae = 3;
1042
+ class _e {
1231
1043
  cancelableConnectWithRepeatedCalls;
1232
1044
  JsSIP;
1233
1045
  events;
@@ -1253,29 +1065,29 @@ class ln {
1253
1065
  }
1254
1066
  let r = !1;
1255
1067
  const a = this.getConnectionConfiguration();
1256
- e !== void 0 && e !== a.displayName && (r = i.set("display_name", Et(e)), this.updateConnectionConfiguration("displayName", e));
1068
+ e !== void 0 && e !== a.displayName && (r = i.set("display_name", B(e)), this.updateConnectionConfiguration("displayName", e));
1257
1069
  const o = r;
1258
1070
  o ? t(o) : s(new Error("nothing changed"));
1259
1071
  });
1260
1072
  disconnect = async () => {
1261
1073
  const e = new Promise((s) => {
1262
- this.events.once(A.DISCONNECTED, () => {
1074
+ this.events.once(u.DISCONNECTED, () => {
1263
1075
  s();
1264
1076
  });
1265
1077
  }), t = this.getUa();
1266
- return t ? t.stop() : this.events.trigger(A.DISCONNECTED, void 0), e.finally(() => {
1078
+ return t ? t.stop() : this.events.trigger(u.DISCONNECTED, void 0), e.finally(() => {
1267
1079
  this.setUa(void 0), this.stateMachine.reset();
1268
1080
  });
1269
1081
  };
1270
1082
  cancelRequests() {
1271
1083
  this.cancelConnectWithRepeatedCalls();
1272
1084
  }
1273
- connectWithDuplicatedCalls = async (e, { callLimit: t = hn } = {}) => {
1085
+ connectWithDuplicatedCalls = async (e, { callLimit: t = Ae } = {}) => {
1274
1086
  const s = async () => this.connectInner(e), i = (r) => {
1275
- const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), T = r != null && !cn(r);
1276
- return c || T;
1087
+ const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), g = r != null && !de(r);
1088
+ return c || g;
1277
1089
  };
1278
- return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = G({
1090
+ return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = V({
1279
1091
  targetFunction: s,
1280
1092
  isComplete: i,
1281
1093
  callLimit: t,
@@ -1301,38 +1113,38 @@ class ln {
1301
1113
  sessionTimers: a,
1302
1114
  registerExpires: o,
1303
1115
  connectionRecoveryMinInterval: c,
1304
- connectionRecoveryMaxInterval: T,
1305
- userAgent: S,
1306
- displayName: l = "",
1307
- register: d = !1,
1308
- extraHeaders: h = []
1116
+ connectionRecoveryMaxInterval: g,
1117
+ userAgent: d,
1118
+ displayName: S = "",
1119
+ register: l = !1,
1120
+ extraHeaders: E = []
1309
1121
  }) => {
1310
1122
  this.stateMachine.startInitUa(), this.setConnectionConfiguration({
1311
1123
  sipServerUrl: s,
1312
- displayName: l,
1313
- register: d,
1124
+ displayName: S,
1125
+ register: l,
1314
1126
  user: e,
1315
1127
  password: t
1316
1128
  }), this.getUa() && await this.disconnect();
1317
- const { ua: C, helpers: O } = this.uaFactory.createUAWithConfiguration(
1129
+ const { ua: C, helpers: p } = this.uaFactory.createUAWithConfiguration(
1318
1130
  {
1319
1131
  user: e,
1320
1132
  password: t,
1321
1133
  sipServerUrl: s,
1322
1134
  sipWebSocketServerURL: i,
1323
- displayName: l,
1324
- register: d,
1135
+ displayName: S,
1136
+ register: l,
1325
1137
  sessionTimers: a,
1326
1138
  registerExpires: o,
1327
1139
  connectionRecoveryMinInterval: c,
1328
- connectionRecoveryMaxInterval: T,
1329
- userAgent: S,
1140
+ connectionRecoveryMaxInterval: g,
1141
+ userAgent: d,
1330
1142
  remoteAddress: r,
1331
- extraHeaders: h
1143
+ extraHeaders: E
1332
1144
  },
1333
1145
  this.events
1334
1146
  );
1335
- return this.setUa(C), this.setSipServerUrl(O.getSipServerUrl), this.setSocket(O.socket), C;
1147
+ return this.setUa(C), this.setSipServerUrl(p.getSipServerUrl), this.setSocket(p.socket), C;
1336
1148
  };
1337
1149
  start = async () => new Promise((e, t) => {
1338
1150
  const s = this.getUa();
@@ -1341,15 +1153,15 @@ class ln {
1341
1153
  return;
1342
1154
  }
1343
1155
  let i;
1344
- i = ((c, T) => {
1156
+ i = ((c, g) => {
1345
1157
  if (this.getConnectionConfiguration().register === !0)
1346
- return this.registrationManager.subscribeToStartEvents(c, T);
1347
- const l = A.CONNECTED, d = [A.DISCONNECTED];
1348
- return this.events.on(l, c), d.forEach((h) => {
1349
- this.events.on(h, T);
1158
+ return this.registrationManager.subscribeToStartEvents(c, g);
1159
+ const S = u.CONNECTED, l = [u.DISCONNECTED];
1160
+ return this.events.on(S, c), l.forEach((E) => {
1161
+ this.events.on(E, g);
1350
1162
  }), () => {
1351
- this.events.off(l, c), d.forEach((h) => {
1352
- this.events.off(h, T);
1163
+ this.events.off(S, c), l.forEach((E) => {
1164
+ this.events.off(E, g);
1353
1165
  });
1354
1166
  };
1355
1167
  })(() => {
@@ -1362,8 +1174,8 @@ class ln {
1362
1174
  this.cancelableConnectWithRepeatedCalls?.cancel();
1363
1175
  }
1364
1176
  }
1365
- var dt = /* @__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))(dt || {});
1366
- const Cn = lt({
1177
+ var X = /* @__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))(X || {});
1178
+ const Ie = j({
1367
1179
  types: {
1368
1180
  context: {},
1369
1181
  events: {}
@@ -1677,14 +1489,14 @@ const Cn = lt({
1677
1489
  }
1678
1490
  }
1679
1491
  });
1680
- class Nn {
1492
+ class Re {
1681
1493
  actor;
1682
1494
  stateChangeListeners = /* @__PURE__ */ new Set();
1683
1495
  events;
1684
1496
  unsubscribeFromEvents;
1685
1497
  actorSubscription;
1686
1498
  constructor(e) {
1687
- this.events = e, this.actor = Ct(Cn), this.actorSubscription = this.actor.subscribe((t) => {
1499
+ this.events = e, this.actor = Z(Ie), this.actorSubscription = this.actor.subscribe((t) => {
1688
1500
  const s = t.value;
1689
1501
  this.stateChangeListeners.forEach((i) => {
1690
1502
  i(s);
@@ -1770,7 +1582,7 @@ class Nn {
1770
1582
  return this.actor.getSnapshot().can({ type: e });
1771
1583
  }
1772
1584
  getValidEvents() {
1773
- return Object.values(dt).filter((e) => this.canTransition(e));
1585
+ return Object.values(X).filter((e) => this.canTransition(e));
1774
1586
  }
1775
1587
  hasState(e) {
1776
1588
  return this.actor.getSnapshot().matches(e);
@@ -1839,7 +1651,7 @@ class Nn {
1839
1651
  };
1840
1652
  }
1841
1653
  }
1842
- class An {
1654
+ class Me {
1843
1655
  events;
1844
1656
  getUaProtected;
1845
1657
  constructor(e) {
@@ -1848,13 +1660,13 @@ class An {
1848
1660
  async register() {
1849
1661
  const e = this.getUaProtected();
1850
1662
  return new Promise((t, s) => {
1851
- e.on(A.REGISTERED, t), e.on(A.REGISTRATION_FAILED, s), e.register();
1663
+ e.on(u.REGISTERED, t), e.on(u.REGISTRATION_FAILED, s), e.register();
1852
1664
  });
1853
1665
  }
1854
1666
  async unregister() {
1855
1667
  const e = this.getUaProtected();
1856
1668
  return new Promise((t) => {
1857
- e.on(A.UNREGISTERED, t), e.unregister();
1669
+ e.on(u.UNREGISTERED, t), e.unregister();
1858
1670
  });
1859
1671
  }
1860
1672
  async tryRegister() {
@@ -1866,7 +1678,7 @@ class An {
1866
1678
  return this.register();
1867
1679
  }
1868
1680
  subscribeToStartEvents(e, t) {
1869
- const s = A.REGISTERED, i = [A.REGISTRATION_FAILED, A.DISCONNECTED];
1681
+ const s = u.REGISTERED, i = [u.REGISTRATION_FAILED, u.DISCONNECTED];
1870
1682
  return this.events.on(s, e), i.forEach((r) => {
1871
1683
  this.events.on(r, t);
1872
1684
  }), () => {
@@ -1876,7 +1688,7 @@ class An {
1876
1688
  };
1877
1689
  }
1878
1690
  }
1879
- class _n {
1691
+ class pe {
1880
1692
  uaFactory;
1881
1693
  getUaProtected;
1882
1694
  constructor(e) {
@@ -1922,30 +1734,30 @@ class _n {
1922
1734
  extraHeaders: a
1923
1735
  }) {
1924
1736
  return new Promise((o, c) => {
1925
- const { configuration: T } = this.uaFactory.createConfiguration({
1737
+ const { configuration: g } = this.uaFactory.createConfiguration({
1926
1738
  sipWebSocketServerURL: i,
1927
1739
  displayName: t,
1928
1740
  userAgent: e,
1929
1741
  sipServerUrl: s
1930
- }), S = this.uaFactory.createUA({ ...T, remoteAddress: r, extraHeaders: a }), l = () => {
1931
- const h = new Error("Telephony is not available");
1932
- c(h);
1742
+ }), d = this.uaFactory.createUA({ ...g, remoteAddress: r, extraHeaders: a }), S = () => {
1743
+ const E = new Error("Telephony is not available");
1744
+ c(E);
1933
1745
  };
1934
- S.once(A.DISCONNECTED, l);
1935
- const d = () => {
1936
- S.removeAllListeners(), S.once(A.DISCONNECTED, () => {
1746
+ d.once(u.DISCONNECTED, S);
1747
+ const l = () => {
1748
+ d.removeAllListeners(), d.once(u.DISCONNECTED, () => {
1937
1749
  o();
1938
- }), S.stop();
1750
+ }), d.stop();
1939
1751
  };
1940
- S.once(A.CONNECTED, d), S.start();
1752
+ d.once(u.CONNECTED, l), d.start();
1941
1753
  });
1942
1754
  }
1943
1755
  }
1944
- const un = (n) => {
1756
+ const me = (n) => {
1945
1757
  const e = [];
1946
1758
  return n !== void 0 && n !== "" && e.push(`X-Vinteo-Remote: ${n}`), e;
1947
1759
  };
1948
- class p {
1760
+ class m {
1949
1761
  JsSIP;
1950
1762
  constructor(e) {
1951
1763
  this.JsSIP = e;
@@ -1970,10 +1782,10 @@ class p {
1970
1782
  throw new Error("user is required for authorized connection");
1971
1783
  }
1972
1784
  static resolveAuthorizationUser(e, t) {
1973
- return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${Jt()}`;
1785
+ return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${se()}`;
1974
1786
  }
1975
1787
  static buildExtraHeaders(e, t) {
1976
- const s = e !== void 0 && e !== "" ? un(e) : [];
1788
+ const s = e !== void 0 && e !== "" ? me(e) : [];
1977
1789
  return t === void 0 ? s : [...s, ...t];
1978
1790
  }
1979
1791
  createConfiguration({
@@ -1986,40 +1798,40 @@ class p {
1986
1798
  sessionTimers: o = !1,
1987
1799
  registerExpires: c = 300,
1988
1800
  // 5 minutes in sec
1989
- connectionRecoveryMinInterval: T = 2,
1990
- connectionRecoveryMaxInterval: S = 6,
1991
- userAgent: l
1801
+ connectionRecoveryMinInterval: g = 2,
1802
+ connectionRecoveryMaxInterval: d = 6,
1803
+ userAgent: S
1992
1804
  }) {
1993
- p.validateConfiguration({
1805
+ m.validateConfiguration({
1994
1806
  register: a,
1995
1807
  password: t,
1996
1808
  user: e,
1997
1809
  sipServerUrl: r,
1998
1810
  sipWebSocketServerURL: s
1999
1811
  });
2000
- const d = p.resolveAuthorizationUser(a, e), h = Qt(r), I = h(d), C = new this.JsSIP.WebSocketInterface(s);
1812
+ const l = m.resolveAuthorizationUser(a, e), E = te(r), I = E(l), C = new this.JsSIP.WebSocketInterface(s);
2001
1813
  return {
2002
1814
  configuration: {
2003
1815
  password: t,
2004
1816
  register: a,
2005
1817
  uri: I,
2006
- display_name: Et(i),
2007
- user_agent: l,
1818
+ display_name: B(i),
1819
+ user_agent: S,
2008
1820
  sdpSemantics: "unified-plan",
2009
1821
  sockets: [C],
2010
1822
  session_timers: o,
2011
1823
  register_expires: c,
2012
- connection_recovery_min_interval: T,
2013
- connection_recovery_max_interval: S
1824
+ connection_recovery_min_interval: g,
1825
+ connection_recovery_max_interval: d
2014
1826
  },
2015
1827
  helpers: {
2016
1828
  socket: C,
2017
- getSipServerUrl: h
1829
+ getSipServerUrl: E
2018
1830
  }
2019
1831
  };
2020
1832
  }
2021
1833
  createUA({ remoteAddress: e, extraHeaders: t, ...s }) {
2022
- const i = new this.JsSIP.UA(s), r = p.buildExtraHeaders(e, t);
1834
+ const i = new this.JsSIP.UA(s), r = m.buildExtraHeaders(e, t);
2023
1835
  return r.length > 0 && i.registrator().setExtraHeaders(r), i;
2024
1836
  }
2025
1837
  /**
@@ -2032,12 +1844,12 @@ class p {
2032
1844
  extraHeaders: e.extraHeaders
2033
1845
  });
2034
1846
  return t.eachTriggers((a, o) => {
2035
- const c = St.find((T) => T === o);
1847
+ const c = z.find((g) => g === o);
2036
1848
  c && r.on(c, a);
2037
1849
  }), { ua: r, helpers: i };
2038
1850
  }
2039
1851
  }
2040
- class In {
1852
+ class Pe {
2041
1853
  events;
2042
1854
  ua;
2043
1855
  socket;
@@ -2049,15 +1861,15 @@ class In {
2049
1861
  configurationManager;
2050
1862
  JsSIP;
2051
1863
  constructor({ JsSIP: e }) {
2052
- this.JsSIP = e, this.events = new D(dn), this.uaFactory = new p(e), this.registrationManager = new An({
1864
+ this.JsSIP = e, this.events = new O(Q), this.uaFactory = new m(e), this.registrationManager = new Me({
2053
1865
  events: this.events,
2054
1866
  getUaProtected: this.getUaProtected
2055
- }), this.stateMachine = new Nn(this.events), this.configurationManager = new Sn({
1867
+ }), this.stateMachine = new Re(this.events), this.configurationManager = new ue({
2056
1868
  getUa: this.getUa
2057
- }), this.sipOperations = new _n({
1869
+ }), this.sipOperations = new pe({
2058
1870
  uaFactory: this.uaFactory,
2059
1871
  getUaProtected: this.getUaProtected
2060
- }), this.connectionFlow = new ln({
1872
+ }), this.connectionFlow = new _e({
2061
1873
  JsSIP: this.JsSIP,
2062
1874
  events: this.events,
2063
1875
  uaFactory: this.uaFactory,
@@ -2095,7 +1907,7 @@ class In {
2095
1907
  return this.stateMachine.state;
2096
1908
  }
2097
1909
  get isRegistered() {
2098
- return p.isRegisteredUA(this.ua);
1910
+ return m.isRegisteredUA(this.ua);
2099
1911
  }
2100
1912
  get isRegisterConfig() {
2101
1913
  return this.configurationManager.isRegister();
@@ -2148,19 +1960,19 @@ class In {
2148
1960
  };
2149
1961
  getUa = () => this.ua;
2150
1962
  }
2151
- var f = /* @__PURE__ */ ((n) => (n.INCOMING_CALL = "incomingCall", n.DECLINED_INCOMING_CALL = "declinedIncomingCall", n.TERMINATED_INCOMING_CALL = "terminatedIncomingCall", n.FAILED_INCOMING_CALL = "failedIncomingCall", n))(f || {}), $ = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))($ || {});
2152
- const Rn = [
1963
+ var D = /* @__PURE__ */ ((n) => (n.INCOMING_CALL = "incomingCall", n.DECLINED_INCOMING_CALL = "declinedIncomingCall", n.TERMINATED_INCOMING_CALL = "terminatedIncomingCall", n.FAILED_INCOMING_CALL = "failedIncomingCall", n))(D || {}), $ = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))($ || {});
1964
+ const J = [
2153
1965
  "incomingCall",
2154
1966
  "declinedIncomingCall",
2155
1967
  "terminatedIncomingCall",
2156
1968
  "failedIncomingCall"
2157
- ], Mn = 486, On = 487;
2158
- class pn {
1969
+ ], Oe = 486, fe = 487;
1970
+ class De {
1971
+ events;
2159
1972
  incomingRTCSession;
2160
1973
  connectionManager;
2161
- events;
2162
1974
  constructor(e) {
2163
- this.connectionManager = e, this.events = new D(Rn), this.start();
1975
+ this.connectionManager = e, this.events = new O(J), this.start();
2164
1976
  }
2165
1977
  get remoteCallerData() {
2166
1978
  return {
@@ -2190,19 +2002,19 @@ class pn {
2190
2002
  return this.removeIncomingSession(), e;
2191
2003
  };
2192
2004
  async declineToIncomingCall({
2193
- statusCode: e = On
2005
+ statusCode: e = fe
2194
2006
  } = {}) {
2195
2007
  return new Promise((t, s) => {
2196
2008
  try {
2197
2009
  const i = this.getIncomingRTCSession(), r = this.remoteCallerData;
2198
- this.removeIncomingSession(), this.events.trigger(f.DECLINED_INCOMING_CALL, r), i.terminate({ status_code: e }), t();
2010
+ this.removeIncomingSession(), this.events.trigger(D.DECLINED_INCOMING_CALL, r), i.terminate({ status_code: e }), t();
2199
2011
  } catch (i) {
2200
2012
  s(i);
2201
2013
  }
2202
2014
  });
2203
2015
  }
2204
2016
  async busyIncomingCall() {
2205
- return this.declineToIncomingCall({ statusCode: Mn });
2017
+ return this.declineToIncomingCall({ statusCode: Oe });
2206
2018
  }
2207
2019
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2208
2020
  on(e, t) {
@@ -2239,26 +2051,34 @@ class pn {
2239
2051
  this.incomingRTCSession = e;
2240
2052
  const t = this.remoteCallerData;
2241
2053
  e.on("failed", (s) => {
2242
- this.removeIncomingSession(), s.originator === $.LOCAL ? this.events.trigger(f.TERMINATED_INCOMING_CALL, t) : this.events.trigger(f.FAILED_INCOMING_CALL, t);
2243
- }), this.events.trigger(f.INCOMING_CALL, t);
2054
+ this.removeIncomingSession(), s.originator === $.LOCAL ? this.events.trigger(D.TERMINATED_INCOMING_CALL, t) : this.events.trigger(D.FAILED_INCOMING_CALL, t);
2055
+ }), this.events.trigger(D.INCOMING_CALL, t);
2244
2056
  }
2245
2057
  removeIncomingSession() {
2246
2058
  delete this.incomingRTCSession;
2247
2059
  }
2248
2060
  }
2249
- class $n {
2061
+ const ve = Q.map((n) => `connection:${n}`), ye = G.map((n) => `call:${n}`), Ue = q.map((n) => `api:${n}`), be = J.map((n) => `incoming-call:${n}`), we = Y.map((n) => `presentation:${n}`), Le = [
2062
+ ...ve,
2063
+ ...ye,
2064
+ ...Ue,
2065
+ ...be,
2066
+ ...we
2067
+ ];
2068
+ class xe {
2069
+ events;
2250
2070
  connectionManager;
2251
2071
  callManager;
2252
2072
  apiManager;
2253
2073
  incomingCallManager;
2254
2074
  presentationManager;
2255
2075
  constructor({ JsSIP: e }) {
2256
- this.connectionManager = new In({ JsSIP: e }), this.callManager = new tn(), this.apiManager = new gn({
2076
+ this.events = new O(Le), this.connectionManager = new Pe({ JsSIP: e }), this.callManager = new ge(), this.apiManager = new Se({
2257
2077
  connectionManager: this.connectionManager,
2258
2078
  callManager: this.callManager
2259
- }), this.incomingCallManager = new pn(this.connectionManager), this.presentationManager = new rn({
2079
+ }), this.incomingCallManager = new De(this.connectionManager), this.presentationManager = new Ne({
2260
2080
  callManager: this.callManager
2261
- });
2081
+ }), this.subscribe();
2262
2082
  }
2263
2083
  get requestedConnection() {
2264
2084
  return this.connectionManager.requested;
@@ -2299,34 +2119,34 @@ class $n {
2299
2119
  get isAvailableIncomingCall() {
2300
2120
  return this.incomingCallManager.isAvailableIncomingCall;
2301
2121
  }
2302
- connect = async (...e) => this.connectionManager.connect(...e);
2303
- set = async (...e) => this.connectionManager.set(...e);
2304
- disconnect = async () => this.connectionManager.disconnect();
2305
- register = async () => this.connectionManager.register();
2306
- unregister = async () => this.connectionManager.unregister();
2307
- tryRegister = async () => this.connectionManager.tryRegister();
2308
- sendOptions = async (e, t, s) => this.connectionManager.sendOptions(e, t, s);
2309
- ping = async (e, t) => this.connectionManager.ping(e, t);
2310
- checkTelephony = async (e) => this.connectionManager.checkTelephony(e);
2311
2122
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2312
- onConnection(e, t) {
2313
- return this.connectionManager.on(e, t);
2123
+ on(e, t) {
2124
+ return this.events.on(e, t);
2314
2125
  }
2315
2126
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2316
- onceConnection(e, t) {
2317
- return this.connectionManager.once(e, t);
2127
+ once(e, t) {
2128
+ return this.events.once(e, t);
2318
2129
  }
2319
2130
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2320
- onceRaceConnection(e, t) {
2321
- return this.connectionManager.onceRace(e, t);
2131
+ onceRace(e, t) {
2132
+ return this.events.onceRace(e, t);
2322
2133
  }
2323
- async waitConnection(e) {
2324
- return this.connectionManager.wait(e);
2134
+ async wait(e) {
2135
+ return this.events.wait(e);
2325
2136
  }
2326
2137
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2327
- offConnection(e, t) {
2328
- this.connectionManager.off(e, t);
2138
+ off(e, t) {
2139
+ this.events.off(e, t);
2329
2140
  }
2141
+ connect = async (...e) => this.connectionManager.connect(...e);
2142
+ set = async (...e) => this.connectionManager.set(...e);
2143
+ disconnect = async () => this.connectionManager.disconnect();
2144
+ register = async () => this.connectionManager.register();
2145
+ unregister = async () => this.connectionManager.unregister();
2146
+ tryRegister = async () => this.connectionManager.tryRegister();
2147
+ sendOptions = async (e, t, s) => this.connectionManager.sendOptions(e, t, s);
2148
+ ping = async (e, t) => this.connectionManager.ping(e, t);
2149
+ checkTelephony = async (e) => this.connectionManager.checkTelephony(e);
2330
2150
  isConfigured = () => this.connectionManager.isConfigured();
2331
2151
  getConnectionConfiguration = () => this.connectionManager.getConnectionConfiguration();
2332
2152
  getSipServerUrl = (e) => this.connectionManager.getSipServerUrl(e);
@@ -2345,44 +2165,6 @@ class $n {
2345
2165
  getCallConfiguration = () => this.callManager.getCallConfiguration();
2346
2166
  getRemoteStreams = () => this.callManager.getRemoteStreams();
2347
2167
  replaceMediaStream = async (...e) => this.callManager.replaceMediaStream(...e);
2348
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2349
- onCall(e, t) {
2350
- return this.callManager.on(e, t);
2351
- }
2352
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2353
- onceCall(e, t) {
2354
- return this.callManager.once(e, t);
2355
- }
2356
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2357
- onceRaceCall(e, t) {
2358
- return this.callManager.onceRace(e, t);
2359
- }
2360
- async waitCall(e) {
2361
- return this.callManager.wait(e);
2362
- }
2363
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2364
- offIncomingCall(e, t) {
2365
- this.incomingCallManager.off(e, t);
2366
- }
2367
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2368
- onIncomingCall(e, t) {
2369
- return this.incomingCallManager.on(e, t);
2370
- }
2371
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2372
- onceIncomingCall(e, t) {
2373
- return this.incomingCallManager.once(e, t);
2374
- }
2375
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2376
- onceRaceIncomingCall(e, t) {
2377
- return this.incomingCallManager.onceRace(e, t);
2378
- }
2379
- async waitIncomingCall(e) {
2380
- return this.incomingCallManager.wait(e);
2381
- }
2382
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2383
- offCall(e, t) {
2384
- this.callManager.off(e, t);
2385
- }
2386
2168
  async startPresentation(e, t = {}) {
2387
2169
  const { isP2P: s, callLimit: i, ...r } = t;
2388
2170
  return this.presentationManager.startPresentation(
@@ -2452,41 +2234,38 @@ class $n {
2452
2234
  async askPermissionToEnableCam(...e) {
2453
2235
  return this.apiManager.askPermissionToEnableCam(...e);
2454
2236
  }
2455
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2456
- onApi(e, t) {
2457
- return this.apiManager.on(e, t);
2458
- }
2459
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2460
- onceApi(e, t) {
2461
- return this.apiManager.once(e, t);
2462
- }
2463
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2464
- onceRaceApi(e, t) {
2465
- return this.apiManager.onceRace(e, t);
2466
- }
2467
- async waitApi(e) {
2468
- return this.apiManager.wait(e);
2469
- }
2470
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2471
- offApi(e, t) {
2472
- this.apiManager.off(e, t);
2237
+ subscribe() {
2238
+ this.connectionManager.events.eachTriggers((e, t) => {
2239
+ this.connectionManager.on(t, (s) => {
2240
+ this.events.trigger(`connection:${t}`, s);
2241
+ });
2242
+ }), this.callManager.events.eachTriggers((e, t) => {
2243
+ this.callManager.on(t, (s) => {
2244
+ this.events.trigger(`call:${t}`, s);
2245
+ });
2246
+ }), this.apiManager.events.eachTriggers((e, t) => {
2247
+ this.apiManager.on(t, (s) => {
2248
+ this.events.trigger(`api:${t}`, s);
2249
+ });
2250
+ }), this.incomingCallManager.events.eachTriggers((e, t) => {
2251
+ this.incomingCallManager.on(t, (s) => {
2252
+ this.events.trigger(`incoming-call:${t}`, s);
2253
+ });
2254
+ }), this.presentationManager.events.eachTriggers((e, t) => {
2255
+ this.presentationManager.on(t, (s) => {
2256
+ this.events.trigger(`presentation:${t}`, s);
2257
+ });
2258
+ });
2473
2259
  }
2474
2260
  }
2475
2261
  export {
2476
- Wt as B,
2477
- gt as E,
2478
- pt as N,
2479
- it as O,
2480
- Rt as R,
2481
- $n as S,
2482
- at as U,
2483
- Un as a,
2484
- wn as b,
2485
- yn as c,
2486
- Ln as d,
2487
- bn as e,
2488
- Yt as f,
2489
- U as g,
2490
- Fn as h,
2262
+ x as E,
2263
+ U as O,
2264
+ xe as S,
2265
+ f as a,
2266
+ Ee as b,
2267
+ Ge as d,
2268
+ He as e,
2269
+ Be as h,
2491
2270
  P as l
2492
2271
  };