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

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 (46) hide show
  1. package/dist/@SipConnector-Bkm1XX-8.cjs +1 -0
  2. package/dist/{SipConnector-CK3GgjXE.js → @SipConnector-D4tn0Ep5.js} +456 -680
  3. package/dist/ApiManager/@ApiManager.d.ts +2 -2
  4. package/dist/ApiManager/constants.d.ts +1 -1
  5. package/dist/ApiManager/index.d.ts +1 -0
  6. package/dist/CallManager/causes.d.ts +2 -1
  7. package/dist/CallManager/index.d.ts +2 -0
  8. package/dist/CallManager/types.d.ts +1 -1
  9. package/dist/ConnectionManager/@ConnectionManager.d.ts +2 -1
  10. package/dist/ConnectionManager/ConnectionFlow.d.ts +2 -1
  11. package/dist/IncomingCallManager/@IncomingCallManager.d.ts +3 -2
  12. package/dist/PresentationManager/@PresentationManager.d.ts +2 -2
  13. package/dist/PresentationManager/index.d.ts +1 -0
  14. package/dist/{SipConnector.d.ts → SipConnector/@SipConnector.d.ts} +19 -30
  15. package/dist/SipConnector/eventNames.d.ts +4 -0
  16. package/dist/SipConnector/index.d.ts +2 -0
  17. package/dist/SipConnectorFacade/SipConnectorFacade.d.ts +10 -28
  18. package/dist/__fixtures__/BaseSession.mock.d.ts +1 -1
  19. package/dist/{eventNames.d.ts → __fixtures__/eventNames.d.ts} +1 -1
  20. package/dist/doMock.cjs +1 -1
  21. package/dist/doMock.d.ts +1 -1
  22. package/dist/doMock.js +212 -130
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.d.ts +9 -8
  25. package/dist/index.js +512 -546
  26. package/dist/tools/__fixtures__/processRequest.d.ts +1 -1
  27. package/dist/tools/error/getLinkError.d.ts +1 -1
  28. package/dist/tools/error/getTypeFromError.d.ts +1 -1
  29. package/dist/tools/error/getValuesFromError.d.ts +1 -1
  30. package/dist/tools/prepareMediaStream.d.ts +1 -1
  31. package/dist/tools/setVideoTrackContentHints.d.ts +1 -1
  32. package/dist/tools/syncMediaState/index.d.ts +1 -1
  33. package/dist/tools/syncMediaState/resolveOnStartMainCam.d.ts +1 -1
  34. package/dist/tools/syncMediaState/resolveOnStartMic.d.ts +1 -1
  35. package/dist/tools/syncMediaState/resolveOnStopMainCam.d.ts +1 -1
  36. package/dist/tools/syncMediaState/resolveOnStopMic.d.ts +1 -1
  37. package/dist/types.d.ts +0 -46
  38. package/dist/videoSendingBalancer/balance.d.ts +1 -1
  39. package/dist/videoSendingBalancer/index.d.ts +1 -1
  40. package/dist/videoSendingBalancer/processSender.d.ts +1 -1
  41. package/package.json +1 -1
  42. package/dist/SipConnector-CwI8aFEA.cjs +0 -1
  43. package/dist/causes.d.ts +0 -23
  44. package/dist/headers.d.ts +0 -37
  45. /package/dist/{getExtraHeadersRemoteAddress.d.ts → ConnectionManager/getExtraHeadersRemoteAddress.d.ts} +0 -0
  46. /package/dist/{constants.d.ts → __fixtures__/constants.d.ts} +0 -0
@@ -1,206 +1,10 @@
1
- import D from "events-constructor";
1
+ import 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,35 @@ 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
+ eventHandlers: this.events.triggers,
340
145
  directionVideo: c,
341
- directionAudio: T,
146
+ directionAudio: g,
342
147
  pcConfig: {
343
148
  iceServers: o
344
149
  },
345
150
  rtcOfferConstraints: {
346
- offerToReceiveAudio: l,
347
- offerToReceiveVideo: d
151
+ offerToReceiveAudio: S,
152
+ offerToReceiveVideo: l
348
153
  },
349
- sendEncodings: h,
154
+ sendEncodings: E,
350
155
  onAddedTransceiver: I
351
- }), this.subscribeToSessionEvents(this.rtcSession);
156
+ });
352
157
  }).finally(() => {
353
158
  this.isPendingCall = !1;
354
159
  }));
@@ -356,7 +161,7 @@ class en extends Kt {
356
161
  const { rtcSession: e } = this;
357
162
  if (e && !e.isEnded())
358
163
  return e.terminateAsync({
359
- cause: gt.CANCELED
164
+ cause: x.CANCELED
360
165
  }).finally(() => {
361
166
  this.reset();
362
167
  });
@@ -370,35 +175,35 @@ class en extends Kt {
370
175
  directionVideo: a,
371
176
  directionAudio: o,
372
177
  offerToReceiveAudio: c,
373
- offerToReceiveVideo: T,
374
- contentHint: S,
375
- sendEncodings: l,
376
- onAddedTransceiver: d
377
- }) => (this.isPendingAnswer = !0, new Promise((h, I) => {
178
+ offerToReceiveVideo: g,
179
+ contentHint: d,
180
+ sendEncodings: S,
181
+ onAddedTransceiver: l
182
+ }) => (this.isPendingAnswer = !0, new Promise((E, I) => {
378
183
  try {
379
184
  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) => {
185
+ 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
186
  I(b);
382
187
  });
383
- const O = v(t, {
188
+ const p = v(t, {
384
189
  directionVideo: a,
385
190
  directionAudio: o,
386
- contentHint: S
191
+ contentHint: d
387
192
  });
388
193
  C.answer({
389
194
  extraHeaders: i,
390
195
  directionVideo: a,
391
196
  directionAudio: o,
392
- mediaStream: O,
197
+ mediaStream: p,
393
198
  pcConfig: {
394
199
  iceServers: r
395
200
  },
396
201
  rtcOfferConstraints: {
397
202
  offerToReceiveAudio: c,
398
- offerToReceiveVideo: T
203
+ offerToReceiveVideo: g
399
204
  },
400
- sendEncodings: l,
401
- onAddedTransceiver: d
205
+ sendEncodings: S,
206
+ onAddedTransceiver: l
402
207
  });
403
208
  } catch (C) {
404
209
  I(C);
@@ -416,7 +221,7 @@ class en extends Kt {
416
221
  if (!this.connection)
417
222
  return;
418
223
  const t = this.connection.getReceivers().map(({ track: s }) => s);
419
- return Xt(t) ? this.remoteStreamsManager.generateStreams(t) : this.remoteStreamsManager.generateAudioStreams(t);
224
+ return ie(t) ? this.remoteStreamsManager.generateStreams(t) : this.remoteStreamsManager.generateAudioStreams(t);
420
225
  }
421
226
  async replaceMediaStream(e, t) {
422
227
  if (!this.rtcSession)
@@ -430,33 +235,33 @@ class en extends Kt {
430
235
  ontrack: e
431
236
  }) => new Promise((t, s) => {
432
237
  const i = () => {
433
- this.events.on(N.PEER_CONNECTION, S), this.events.on(N.CONFIRMED, l);
238
+ this.events.on(N.PEER_CONNECTION, d), this.events.on(N.CONFIRMED, S);
434
239
  }, r = () => {
435
- this.events.off(N.PEER_CONNECTION, S), this.events.off(N.CONFIRMED, l);
240
+ this.events.off(N.PEER_CONNECTION, d), this.events.off(N.CONFIRMED, S);
436
241
  }, a = () => {
437
242
  this.events.on(N.FAILED, c), this.events.on(N.ENDED, c);
438
243
  }, o = () => {
439
244
  this.events.off(N.FAILED, c), this.events.off(N.ENDED, c);
440
- }, c = (d) => {
441
- r(), o(), s(d);
245
+ }, c = (l) => {
246
+ r(), o(), s(l);
442
247
  };
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);
248
+ let g;
249
+ const d = ({ peerconnection: l }) => {
250
+ g = l;
251
+ const E = (I) => {
252
+ this.events.trigger(N.PEER_CONNECTION_ONTRACK, l), e && e(I);
448
253
  };
449
- d.addEventListener("track", h), this.disposers.add(() => {
450
- d.removeEventListener("track", h);
254
+ l.addEventListener("track", E), this.disposers.add(() => {
255
+ l.removeEventListener("track", E);
451
256
  });
452
- }, l = () => {
453
- T !== void 0 && this.events.trigger(N.PEER_CONNECTION_CONFIRMED, T), r(), o(), t(T);
257
+ }, S = () => {
258
+ g !== void 0 && this.events.trigger(N.PEER_CONNECTION_CONFIRMED, g), r(), o(), t(g);
454
259
  };
455
260
  i(), a();
456
261
  });
457
262
  subscribeToSessionEvents(e) {
458
263
  this.events.eachTriggers((t, s) => {
459
- const i = Tt.find((r) => r === s);
264
+ const i = H.find((r) => r === s);
460
265
  i && (e.on(i, t), this.disposers.add(() => {
461
266
  e.off(i, t);
462
267
  }));
@@ -475,11 +280,11 @@ class en extends Kt {
475
280
  delete this.rtcSession, this.remoteStreamsManager.reset(), this.unsubscribeFromSessionEvents(), this.callConfiguration.number = void 0, this.callConfiguration.answer = !1;
476
281
  };
477
282
  }
478
- class tn {
283
+ class ge {
479
284
  events;
480
285
  strategy;
481
286
  constructor(e) {
482
- this.events = new D(xt), this.strategy = e ?? new en(this.events);
287
+ this.events = new O(G), this.strategy = e ?? new ce(this.events);
483
288
  }
484
289
  get requested() {
485
290
  return this.strategy.requested;
@@ -523,179 +328,13 @@ class tn {
523
328
  getRemoteStreams = () => this.strategy.getRemoteStreams();
524
329
  replaceMediaStream = async (...e) => this.strategy.replaceMediaStream(...e);
525
330
  }
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 = [
331
+ const W = "sip-connector", P = k(W), He = () => {
332
+ k.enable(W);
333
+ }, Ge = () => {
334
+ k.enable(`-${W}`);
335
+ }, 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;
336
+ 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 || {});
337
+ const q = [
699
338
  "participation:accepting-word-request",
700
339
  "participation:cancelling-word-request",
701
340
  "participant:move-request-to-stream",
@@ -724,8 +363,8 @@ const En = [
724
363
  "mustStopPresentation",
725
364
  "newDTMF"
726
365
  ];
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 {
366
+ 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 || {});
367
+ class Se {
729
368
  events;
730
369
  connectionManager;
731
370
  callManager;
@@ -733,13 +372,13 @@ class gn {
733
372
  connectionManager: e,
734
373
  callManager: t
735
374
  }) {
736
- this.connectionManager = e, this.callManager = t, this.events = new D(En), this.subscribe();
375
+ this.connectionManager = e, this.callManager = t, this.events = new O(q), this.subscribe();
737
376
  }
738
377
  async waitChannels() {
739
- return this.wait(E.CHANNELS);
378
+ return this.wait(T.CHANNELS);
740
379
  }
741
380
  async waitSyncMediaState() {
742
- return this.wait(E.ADMIN_FORCE_SYNC_MEDIA_STATE);
381
+ return this.wait(T.ADMIN_FORCE_SYNC_MEDIA_STATE);
743
382
  }
744
383
  async sendDTMF(e) {
745
384
  return new Promise((t, s) => {
@@ -760,22 +399,22 @@ class gn {
760
399
  const s = this.callManager.getEstablishedRTCSession();
761
400
  if (!s)
762
401
  throw new Error("No rtcSession established");
763
- const i = `${g.INPUT_CHANNELS}: ${e}`, r = `${g.OUTPUT_CHANNELS}: ${t}`, a = [
402
+ const i = `${h.INPUT_CHANNELS}: ${e}`, r = `${h.OUTPUT_CHANNELS}: ${t}`, a = [
764
403
  i,
765
404
  r
766
405
  ];
767
- return s.sendInfo(u.CHANNELS, void 0, { extraHeaders: a });
406
+ return s.sendInfo(_.CHANNELS, void 0, { extraHeaders: a });
768
407
  }
769
408
  async sendMediaState({ cam: e, mic: t }, s = {}) {
770
409
  const i = this.callManager.getEstablishedRTCSession();
771
410
  if (!i)
772
411
  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 = [
412
+ const r = `${h.MEDIA_STATE}: currentstate`, a = `${h.MAIN_CAM_STATE}: ${Number(e)}`, o = `${h.MIC_STATE}: ${Number(t)}`, c = [
774
413
  r,
775
414
  a,
776
415
  o
777
416
  ];
778
- return i.sendInfo(u.MEDIA_STATE, void 0, {
417
+ return i.sendInfo(_.MEDIA_STATE, void 0, {
779
418
  noTerminateWhenError: !0,
780
419
  ...s,
781
420
  extraHeaders: c
@@ -785,8 +424,8 @@ class gn {
785
424
  const s = this.callManager.getEstablishedRTCSession();
786
425
  if (!s)
787
426
  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, {
427
+ const a = e === "mic" ? 0 : 1, c = [`${h.MEDIA_TYPE}: ${a}`];
428
+ return s.sendInfo(_.REFUSAL, void 0, {
790
429
  noTerminateWhenError: !0,
791
430
  ...t,
792
431
  extraHeaders: c
@@ -806,53 +445,53 @@ class gn {
806
445
  const e = this.callManager.getEstablishedRTCSession();
807
446
  if (!e)
808
447
  throw new Error("No rtcSession established");
809
- await e.sendInfo(u.SHARE_STATE, void 0, {
810
- extraHeaders: [g.MUST_STOP_PRESENTATION_P2P]
448
+ await e.sendInfo(_.SHARE_STATE, void 0, {
449
+ extraHeaders: [h.MUST_STOP_PRESENTATION_P2P]
811
450
  });
812
451
  }
813
452
  async sendStoppedPresentationP2P() {
814
453
  const e = this.callManager.getEstablishedRTCSession();
815
454
  if (!e)
816
455
  throw new Error("No rtcSession established");
817
- await e.sendInfo(u.SHARE_STATE, void 0, {
818
- extraHeaders: [g.STOP_PRESENTATION_P2P]
456
+ await e.sendInfo(_.SHARE_STATE, void 0, {
457
+ extraHeaders: [h.STOP_PRESENTATION_P2P]
819
458
  });
820
459
  }
821
460
  async sendStoppedPresentation() {
822
461
  const e = this.callManager.getEstablishedRTCSession();
823
462
  if (!e)
824
463
  throw new Error("No rtcSession established");
825
- await e.sendInfo(u.SHARE_STATE, void 0, {
826
- extraHeaders: [g.STOP_PRESENTATION]
464
+ await e.sendInfo(_.SHARE_STATE, void 0, {
465
+ extraHeaders: [h.STOP_PRESENTATION]
827
466
  });
828
467
  }
829
468
  async askPermissionToStartPresentationP2P() {
830
469
  const e = this.callManager.getEstablishedRTCSession();
831
470
  if (!e)
832
471
  throw new Error("No rtcSession established");
833
- await e.sendInfo(u.SHARE_STATE, void 0, {
834
- extraHeaders: [g.START_PRESENTATION_P2P]
472
+ await e.sendInfo(_.SHARE_STATE, void 0, {
473
+ extraHeaders: [h.START_PRESENTATION_P2P]
835
474
  });
836
475
  }
837
476
  async askPermissionToStartPresentation() {
838
477
  const e = this.callManager.getEstablishedRTCSession();
839
478
  if (!e)
840
479
  throw new Error("No rtcSession established");
841
- await e.sendInfo(u.SHARE_STATE, void 0, {
842
- extraHeaders: [g.START_PRESENTATION]
480
+ await e.sendInfo(_.SHARE_STATE, void 0, {
481
+ extraHeaders: [h.START_PRESENTATION]
843
482
  });
844
483
  }
845
484
  async askPermissionToEnableCam(e = {}) {
846
485
  const t = this.callManager.getEstablishedRTCSession();
847
486
  if (!t)
848
487
  throw new Error("No rtcSession established");
849
- const s = [g.ENABLE_MAIN_CAM];
850
- return t.sendInfo(u.MAIN_CAM, void 0, {
488
+ const s = [h.ENABLE_MAIN_CAM];
489
+ return t.sendInfo(_.MAIN_CAM, void 0, {
851
490
  noTerminateWhenError: !0,
852
491
  ...e,
853
492
  extraHeaders: s
854
493
  }).catch((i) => {
855
- if (Tn(i))
494
+ if (le(i))
856
495
  throw i;
857
496
  });
858
497
  }
@@ -885,7 +524,7 @@ class gn {
885
524
  };
886
525
  maybeHandleNotify = (e) => {
887
526
  try {
888
- const t = e.getHeader(g.NOTIFY);
527
+ const t = e.getHeader(h.NOTIFY);
889
528
  if (t) {
890
529
  const s = JSON.parse(t);
891
530
  this.handleNotify(s);
@@ -896,55 +535,55 @@ class gn {
896
535
  };
897
536
  handleNotify = (e) => {
898
537
  switch (e.cmd) {
899
- case _.CHANNELS: {
538
+ case A.CHANNELS: {
900
539
  const t = e;
901
540
  this.triggerChannelsNotify(t);
902
541
  break;
903
542
  }
904
- case _.WEBCAST_STARTED: {
543
+ case A.WEBCAST_STARTED: {
905
544
  const t = e;
906
545
  this.triggerWebcastStartedNotify(t);
907
546
  break;
908
547
  }
909
- case _.WEBCAST_STOPPED: {
548
+ case A.WEBCAST_STOPPED: {
910
549
  const t = e;
911
550
  this.triggerWebcastStoppedNotify(t);
912
551
  break;
913
552
  }
914
- case _.ADDED_TO_LIST_MODERATORS: {
553
+ case A.ADDED_TO_LIST_MODERATORS: {
915
554
  const t = e;
916
555
  this.triggerAddedToListModeratorsNotify(t);
917
556
  break;
918
557
  }
919
- case _.REMOVED_FROM_LIST_MODERATORS: {
558
+ case A.REMOVED_FROM_LIST_MODERATORS: {
920
559
  const t = e;
921
560
  this.triggerRemovedFromListModeratorsNotify(t);
922
561
  break;
923
562
  }
924
- case _.ACCEPTING_WORD_REQUEST: {
563
+ case A.ACCEPTING_WORD_REQUEST: {
925
564
  const t = e;
926
565
  this.triggerParticipationAcceptingWordRequest(t);
927
566
  break;
928
567
  }
929
- case _.CANCELLING_WORD_REQUEST: {
568
+ case A.CANCELLING_WORD_REQUEST: {
930
569
  const t = e;
931
570
  this.triggerParticipationCancellingWordRequest(t);
932
571
  break;
933
572
  }
934
- case _.MOVE_REQUEST_TO_STREAM: {
573
+ case A.MOVE_REQUEST_TO_STREAM: {
935
574
  const t = e;
936
575
  this.triggerParticipantMoveRequestToStream(t);
937
576
  break;
938
577
  }
939
- case _.ACCOUNT_CHANGED: {
578
+ case A.ACCOUNT_CHANGED: {
940
579
  this.triggerAccountChangedNotify();
941
580
  break;
942
581
  }
943
- case _.ACCOUNT_DELETED: {
582
+ case A.ACCOUNT_DELETED: {
944
583
  this.triggerAccountDeletedNotify();
945
584
  break;
946
585
  }
947
- case _.CONFERENCE_PARTICIPANT_TOKEN_ISSUED: {
586
+ case A.CONFERENCE_PARTICIPANT_TOKEN_ISSUED: {
948
587
  const t = e;
949
588
  this.triggerConferenceParticipantTokenIssued(t);
950
589
  break;
@@ -957,7 +596,7 @@ class gn {
957
596
  const { originator: t } = e;
958
597
  if (t !== U.REMOTE)
959
598
  return;
960
- const { request: s } = e, i = s.getHeader(g.CONTENT_TYPE_NAME);
599
+ const { request: s } = e, i = s.getHeader(h.CONTENT_TYPE);
961
600
  if (i !== void 0)
962
601
  switch (i) {
963
602
  case M.ENTER_ROOM: {
@@ -995,7 +634,7 @@ class gn {
995
634
  inputChannels: t,
996
635
  outputChannels: s
997
636
  };
998
- this.events.trigger(E.CHANNELS_NOTIFY, i);
637
+ this.events.trigger(T.CHANNELS_NOTIFY, i);
999
638
  };
1000
639
  triggerWebcastStartedNotify = ({
1001
640
  body: { conference: e, type: t }
@@ -1004,7 +643,7 @@ class gn {
1004
643
  conference: e,
1005
644
  type: t
1006
645
  };
1007
- this.events.trigger(E.WEBCAST_STARTED, s);
646
+ this.events.trigger(T.WEBCAST_STARTED, s);
1008
647
  };
1009
648
  triggerWebcastStoppedNotify = ({
1010
649
  body: { conference: e, type: t }
@@ -1013,7 +652,7 @@ class gn {
1013
652
  conference: e,
1014
653
  type: t
1015
654
  };
1016
- this.events.trigger(E.WEBCAST_STOPPED, s);
655
+ this.events.trigger(T.WEBCAST_STOPPED, s);
1017
656
  };
1018
657
  triggerAddedToListModeratorsNotify = ({
1019
658
  conference: e
@@ -1022,7 +661,7 @@ class gn {
1022
661
  conference: e
1023
662
  };
1024
663
  this.events.trigger(
1025
- E.PARTICIPANT_ADDED_TO_LIST_MODERATORS,
664
+ T.PARTICIPANT_ADDED_TO_LIST_MODERATORS,
1026
665
  t
1027
666
  );
1028
667
  };
@@ -1033,7 +672,7 @@ class gn {
1033
672
  conference: e
1034
673
  };
1035
674
  this.events.trigger(
1036
- E.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS,
675
+ T.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS,
1037
676
  t
1038
677
  );
1039
678
  };
@@ -1043,7 +682,7 @@ class gn {
1043
682
  const t = {
1044
683
  conference: e
1045
684
  };
1046
- this.events.trigger(E.PARTICIPATION_ACCEPTING_WORD_REQUEST, t);
685
+ this.events.trigger(T.PARTICIPATION_ACCEPTING_WORD_REQUEST, t);
1047
686
  };
1048
687
  triggerParticipationCancellingWordRequest = ({
1049
688
  body: { conference: e }
@@ -1051,7 +690,7 @@ class gn {
1051
690
  const t = {
1052
691
  conference: e
1053
692
  };
1054
- this.events.trigger(E.PARTICIPATION_CANCELLING_WORD_REQUEST, t);
693
+ this.events.trigger(T.PARTICIPATION_CANCELLING_WORD_REQUEST, t);
1055
694
  };
1056
695
  triggerParticipantMoveRequestToStream = ({
1057
696
  body: { conference: e }
@@ -1059,13 +698,13 @@ class gn {
1059
698
  const t = {
1060
699
  conference: e
1061
700
  };
1062
- this.events.trigger(E.PARTICIPANT_MOVE_REQUEST_TO_STREAM, t);
701
+ this.events.trigger(T.PARTICIPANT_MOVE_REQUEST_TO_STREAM, t);
1063
702
  };
1064
703
  triggerAccountChangedNotify = () => {
1065
- this.events.trigger(E.ACCOUNT_CHANGED, void 0);
704
+ this.events.trigger(T.ACCOUNT_CHANGED, void 0);
1066
705
  };
1067
706
  triggerAccountDeletedNotify = () => {
1068
- this.events.trigger(E.ACCOUNT_DELETED, void 0);
707
+ this.events.trigger(T.ACCOUNT_DELETED, void 0);
1069
708
  };
1070
709
  triggerConferenceParticipantTokenIssued = ({
1071
710
  body: { conference: e, participant: t, jwt: s }
@@ -1076,73 +715,243 @@ class gn {
1076
715
  jwt: s
1077
716
  };
1078
717
  this.events.trigger(
1079
- E.CONFERENCE_PARTICIPANT_TOKEN_ISSUED,
718
+ T.CONFERENCE_PARTICIPANT_TOKEN_ISSUED,
1080
719
  i
1081
720
  );
1082
721
  };
1083
722
  maybeTriggerChannels = (e) => {
1084
- const t = e.getHeader(g.INPUT_CHANNELS), s = e.getHeader(g.OUTPUT_CHANNELS);
723
+ const t = e.getHeader(h.INPUT_CHANNELS), s = e.getHeader(h.OUTPUT_CHANNELS);
1085
724
  if (t && s) {
1086
725
  const i = {
1087
726
  inputChannels: t,
1088
727
  outputChannels: s
1089
728
  };
1090
- this.events.trigger(E.CHANNELS, i);
729
+ this.events.trigger(T.CHANNELS, i);
1091
730
  }
1092
731
  };
1093
732
  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 });
733
+ const t = e.getHeader(h.CONTENT_ENTER_ROOM), s = e.getHeader(h.PARTICIPANT_NAME);
734
+ this.events.trigger(T.ENTER_ROOM, { room: t, participantName: s });
1096
735
  };
1097
736
  triggerShareState = (e) => {
1098
- const t = e.getHeader(g.CONTENT_SHARE_STATE);
737
+ const t = e.getHeader(h.CONTENT_SHARE_STATE);
1099
738
  if (t !== void 0)
1100
739
  switch (t) {
1101
740
  case y.AVAILABLE_SECOND_REMOTE_STREAM: {
1102
- this.events.trigger(E.AVAILABLE_SECOND_REMOTE_STREAM, void 0);
741
+ this.events.trigger(T.AVAILABLE_SECOND_REMOTE_STREAM, void 0);
1103
742
  break;
1104
743
  }
1105
744
  case y.NOT_AVAILABLE_SECOND_REMOTE_STREAM: {
1106
- this.events.trigger(E.NOT_AVAILABLE_SECOND_REMOTE_STREAM, void 0);
745
+ this.events.trigger(T.NOT_AVAILABLE_SECOND_REMOTE_STREAM, void 0);
1107
746
  break;
1108
747
  }
1109
748
  case y.MUST_STOP_PRESENTATION: {
1110
- this.events.trigger(E.MUST_STOP_PRESENTATION, void 0);
749
+ this.events.trigger(T.MUST_STOP_PRESENTATION, void 0);
1111
750
  break;
1112
751
  }
1113
752
  }
1114
753
  };
1115
754
  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);
755
+ const t = e.getHeader(h.CONTENT_PARTICIPANT_STATE);
756
+ 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
757
  };
1119
758
  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 });
759
+ const t = e.getHeader(h.MAIN_CAM), s = e.getHeader(h.MEDIA_SYNC), i = s === F.ADMIN_SYNC_FORCED;
760
+ if (t === f.ADMIN_START_MAIN_CAM) {
761
+ this.events.trigger(T.ADMIN_START_MAIN_CAM, { isSyncForced: i });
1123
762
  return;
1124
763
  }
1125
- if (t === m.ADMIN_STOP_MAIN_CAM) {
1126
- this.events.trigger(E.ADMIN_STOP_MAIN_CAM, { isSyncForced: i });
764
+ if (t === f.ADMIN_STOP_MAIN_CAM) {
765
+ this.events.trigger(T.ADMIN_STOP_MAIN_CAM, { isSyncForced: i });
1127
766
  return;
1128
767
  }
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, {
768
+ (t === f.RESUME_MAIN_CAM || t === f.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(T.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: i });
769
+ const r = e.getHeader(h.MAIN_CAM_RESOLUTION);
770
+ this.events.trigger(T.MAIN_CAM_CONTROL, {
1132
771
  mainCam: t,
1133
772
  resolutionMainCam: r
1134
773
  });
1135
774
  };
1136
775
  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 });
776
+ const t = e.getHeader(h.MIC), i = e.getHeader(h.MEDIA_SYNC) === F.ADMIN_SYNC_FORCED;
777
+ 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
778
  };
1140
779
  triggerUseLicense = (e) => {
1141
- const t = e.getHeader(g.CONTENT_USE_LICENSE);
1142
- this.events.trigger(E.USE_LICENSE, t);
780
+ const t = e.getHeader(h.CONTENT_USE_LICENSE);
781
+ this.events.trigger(T.USE_LICENSE, t);
782
+ };
783
+ }
784
+ 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 || {});
785
+ const Y = [
786
+ "presentation:start",
787
+ "presentation:started",
788
+ "presentation:end",
789
+ "presentation:ended",
790
+ "presentation:failed"
791
+ ], Ce = 1, Be = (n) => K(n);
792
+ class Ne {
793
+ events;
794
+ promisePendingStartPresentation;
795
+ promisePendingStopPresentation;
796
+ streamPresentationCurrent;
797
+ cancelableSendPresentationWithRepeatedCalls;
798
+ callManager;
799
+ constructor({ callManager: e }) {
800
+ this.callManager = e, this.events = new O(Y), this.subscribe();
801
+ }
802
+ get isPendingPresentation() {
803
+ return !!this.promisePendingStartPresentation || !!this.promisePendingStopPresentation;
804
+ }
805
+ // eslint-disable-next-line @typescript-eslint/max-params
806
+ async startPresentation(e, t, {
807
+ isNeedReinvite: s,
808
+ maxBitrate: i,
809
+ contentHint: r,
810
+ sendEncodings: a,
811
+ onAddedTransceiver: o
812
+ } = {}, c) {
813
+ const g = this.getRtcSessionProtected();
814
+ if (this.streamPresentationCurrent)
815
+ throw new Error("Presentation is already started");
816
+ return this.sendPresentationWithDuplicatedCalls(e, {
817
+ rtcSession: g,
818
+ stream: t,
819
+ presentationOptions: {
820
+ isNeedReinvite: s,
821
+ maxBitrate: i,
822
+ contentHint: r,
823
+ sendEncodings: a,
824
+ onAddedTransceiver: o
825
+ },
826
+ options: c
827
+ });
828
+ }
829
+ async stopPresentation(e) {
830
+ this.cancelSendPresentationWithRepeatedCalls();
831
+ const t = this.streamPresentationCurrent;
832
+ let s = this.promisePendingStartPresentation ?? Promise.resolve(void 0);
833
+ const i = this.callManager.getEstablishedRTCSession();
834
+ return i && t ? s = e().then(async () => i.stopPresentation(t)).catch((r) => {
835
+ throw this.events.trigger(R.FAILED_PRESENTATION, r), r;
836
+ }) : t && this.events.trigger(R.ENDED_PRESENTATION, t), this.promisePendingStopPresentation = s, s.finally(() => {
837
+ this.resetPresentation();
838
+ });
839
+ }
840
+ async updatePresentation(e, t, {
841
+ // maxBitrate,
842
+ contentHint: s,
843
+ sendEncodings: i,
844
+ onAddedTransceiver: r
845
+ } = {}) {
846
+ const a = this.getRtcSessionProtected();
847
+ if (!this.streamPresentationCurrent)
848
+ throw new Error("Presentation has not started yet");
849
+ return this.promisePendingStartPresentation && await this.promisePendingStartPresentation, this.sendPresentation(e, a, t, {
850
+ // maxBitrate,
851
+ contentHint: s,
852
+ isNeedReinvite: !1,
853
+ sendEncodings: i,
854
+ onAddedTransceiver: r
855
+ });
856
+ }
857
+ cancelSendPresentationWithRepeatedCalls() {
858
+ this.cancelableSendPresentationWithRepeatedCalls?.cancel();
859
+ }
860
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
861
+ on(e, t) {
862
+ return this.events.on(e, t);
863
+ }
864
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
865
+ once(e, t) {
866
+ return this.events.once(e, t);
867
+ }
868
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
869
+ onceRace(e, t) {
870
+ return this.events.onceRace(e, t);
871
+ }
872
+ async wait(e) {
873
+ return this.events.wait(e);
874
+ }
875
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
876
+ off(e, t) {
877
+ this.events.off(e, t);
878
+ }
879
+ subscribe() {
880
+ this.callManager.on("presentation:start", (e) => {
881
+ this.events.trigger(R.START_PRESENTATION, e);
882
+ }), this.callManager.on("presentation:started", (e) => {
883
+ this.events.trigger(R.STARTED_PRESENTATION, e);
884
+ }), this.callManager.on("presentation:end", (e) => {
885
+ this.events.trigger(R.END_PRESENTATION, e);
886
+ }), this.callManager.on("presentation:ended", (e) => {
887
+ this.events.trigger(R.ENDED_PRESENTATION, e);
888
+ }), this.callManager.on("presentation:failed", (e) => {
889
+ this.events.trigger(R.FAILED_PRESENTATION, e);
890
+ }), this.callManager.on("failed", this.handleEnded), this.callManager.on("ended", this.handleEnded);
891
+ }
892
+ async sendPresentationWithDuplicatedCalls(e, {
893
+ rtcSession: t,
894
+ stream: s,
895
+ presentationOptions: i,
896
+ options: r = {
897
+ callLimit: Ce
898
+ }
899
+ }) {
900
+ const a = async () => this.sendPresentation(
901
+ e,
902
+ t,
903
+ s,
904
+ i
905
+ ), o = () => !!this.streamPresentationCurrent;
906
+ return this.cancelableSendPresentationWithRepeatedCalls = V({
907
+ targetFunction: a,
908
+ isComplete: o,
909
+ isRejectAsValid: !0,
910
+ ...r
911
+ }), this.cancelableSendPresentationWithRepeatedCalls.then((c) => c);
912
+ }
913
+ // eslint-disable-next-line @typescript-eslint/max-params
914
+ async sendPresentation(e, t, s, {
915
+ // maxBitrate = ONE_MEGABIT_IN_BITS,
916
+ isNeedReinvite: i = !0,
917
+ contentHint: r = "detail",
918
+ sendEncodings: a,
919
+ onAddedTransceiver: o
920
+ }) {
921
+ const c = v(s, { contentHint: r });
922
+ if (c === void 0)
923
+ throw new Error("No streamPresentationTarget");
924
+ this.streamPresentationCurrent = c;
925
+ const g = e().then(async () => t.startPresentation(c, i, {
926
+ sendEncodings: a,
927
+ onAddedTransceiver: o
928
+ })).then(() => s).catch((d) => {
929
+ throw this.removeStreamPresentationCurrent(), this.events.trigger(R.FAILED_PRESENTATION, d), d;
930
+ });
931
+ return this.promisePendingStartPresentation = g, g.finally(() => {
932
+ this.promisePendingStartPresentation = void 0;
933
+ });
934
+ }
935
+ getRtcSessionProtected = () => {
936
+ const e = this.callManager.getEstablishedRTCSession();
937
+ if (!e)
938
+ throw new Error("No rtcSession established");
939
+ return e;
1143
940
  };
941
+ handleEnded = () => {
942
+ this.reset();
943
+ };
944
+ reset() {
945
+ this.cancelSendPresentationWithRepeatedCalls(), this.resetPresentation();
946
+ }
947
+ resetPresentation() {
948
+ this.removeStreamPresentationCurrent(), this.promisePendingStartPresentation = void 0, this.promisePendingStopPresentation = void 0;
949
+ }
950
+ removeStreamPresentationCurrent() {
951
+ delete this.streamPresentationCurrent;
952
+ }
1144
953
  }
1145
- class Sn {
954
+ class ue {
1146
955
  data = {};
1147
956
  getUa;
1148
957
  constructor(e) {
@@ -1215,8 +1024,8 @@ class Sn {
1215
1024
  return this.data.register === !0;
1216
1025
  }
1217
1026
  }
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 = [
1027
+ 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 || {});
1028
+ const z = [
1220
1029
  "connecting",
1221
1030
  "connected",
1222
1031
  "disconnected",
@@ -1226,8 +1035,8 @@ const St = [
1226
1035
  "registrationFailed",
1227
1036
  "newMessage",
1228
1037
  "sipEvent"
1229
- ], dn = [...St], hn = 3;
1230
- class ln {
1038
+ ], Q = [...z], Ae = 3;
1039
+ class _e {
1231
1040
  cancelableConnectWithRepeatedCalls;
1232
1041
  JsSIP;
1233
1042
  events;
@@ -1253,29 +1062,29 @@ class ln {
1253
1062
  }
1254
1063
  let r = !1;
1255
1064
  const a = this.getConnectionConfiguration();
1256
- e !== void 0 && e !== a.displayName && (r = i.set("display_name", Et(e)), this.updateConnectionConfiguration("displayName", e));
1065
+ e !== void 0 && e !== a.displayName && (r = i.set("display_name", B(e)), this.updateConnectionConfiguration("displayName", e));
1257
1066
  const o = r;
1258
1067
  o ? t(o) : s(new Error("nothing changed"));
1259
1068
  });
1260
1069
  disconnect = async () => {
1261
1070
  const e = new Promise((s) => {
1262
- this.events.once(A.DISCONNECTED, () => {
1071
+ this.events.once(u.DISCONNECTED, () => {
1263
1072
  s();
1264
1073
  });
1265
1074
  }), t = this.getUa();
1266
- return t ? t.stop() : this.events.trigger(A.DISCONNECTED, void 0), e.finally(() => {
1075
+ return t ? t.stop() : this.events.trigger(u.DISCONNECTED, void 0), e.finally(() => {
1267
1076
  this.setUa(void 0), this.stateMachine.reset();
1268
1077
  });
1269
1078
  };
1270
1079
  cancelRequests() {
1271
1080
  this.cancelConnectWithRepeatedCalls();
1272
1081
  }
1273
- connectWithDuplicatedCalls = async (e, { callLimit: t = hn } = {}) => {
1082
+ connectWithDuplicatedCalls = async (e, { callLimit: t = Ae } = {}) => {
1274
1083
  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;
1084
+ const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), g = r != null && !de(r);
1085
+ return c || g;
1277
1086
  };
1278
- return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = G({
1087
+ return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = V({
1279
1088
  targetFunction: s,
1280
1089
  isComplete: i,
1281
1090
  callLimit: t,
@@ -1301,38 +1110,38 @@ class ln {
1301
1110
  sessionTimers: a,
1302
1111
  registerExpires: o,
1303
1112
  connectionRecoveryMinInterval: c,
1304
- connectionRecoveryMaxInterval: T,
1305
- userAgent: S,
1306
- displayName: l = "",
1307
- register: d = !1,
1308
- extraHeaders: h = []
1113
+ connectionRecoveryMaxInterval: g,
1114
+ userAgent: d,
1115
+ displayName: S = "",
1116
+ register: l = !1,
1117
+ extraHeaders: E = []
1309
1118
  }) => {
1310
1119
  this.stateMachine.startInitUa(), this.setConnectionConfiguration({
1311
1120
  sipServerUrl: s,
1312
- displayName: l,
1313
- register: d,
1121
+ displayName: S,
1122
+ register: l,
1314
1123
  user: e,
1315
1124
  password: t
1316
1125
  }), this.getUa() && await this.disconnect();
1317
- const { ua: C, helpers: O } = this.uaFactory.createUAWithConfiguration(
1126
+ const { ua: C, helpers: p } = this.uaFactory.createUAWithConfiguration(
1318
1127
  {
1319
1128
  user: e,
1320
1129
  password: t,
1321
1130
  sipServerUrl: s,
1322
1131
  sipWebSocketServerURL: i,
1323
- displayName: l,
1324
- register: d,
1132
+ displayName: S,
1133
+ register: l,
1325
1134
  sessionTimers: a,
1326
1135
  registerExpires: o,
1327
1136
  connectionRecoveryMinInterval: c,
1328
- connectionRecoveryMaxInterval: T,
1329
- userAgent: S,
1137
+ connectionRecoveryMaxInterval: g,
1138
+ userAgent: d,
1330
1139
  remoteAddress: r,
1331
- extraHeaders: h
1140
+ extraHeaders: E
1332
1141
  },
1333
1142
  this.events
1334
1143
  );
1335
- return this.setUa(C), this.setSipServerUrl(O.getSipServerUrl), this.setSocket(O.socket), C;
1144
+ return this.setUa(C), this.setSipServerUrl(p.getSipServerUrl), this.setSocket(p.socket), C;
1336
1145
  };
1337
1146
  start = async () => new Promise((e, t) => {
1338
1147
  const s = this.getUa();
@@ -1341,15 +1150,15 @@ class ln {
1341
1150
  return;
1342
1151
  }
1343
1152
  let i;
1344
- i = ((c, T) => {
1153
+ i = ((c, g) => {
1345
1154
  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);
1155
+ return this.registrationManager.subscribeToStartEvents(c, g);
1156
+ const S = u.CONNECTED, l = [u.DISCONNECTED];
1157
+ return this.events.on(S, c), l.forEach((E) => {
1158
+ this.events.on(E, g);
1350
1159
  }), () => {
1351
- this.events.off(l, c), d.forEach((h) => {
1352
- this.events.off(h, T);
1160
+ this.events.off(S, c), l.forEach((E) => {
1161
+ this.events.off(E, g);
1353
1162
  });
1354
1163
  };
1355
1164
  })(() => {
@@ -1362,8 +1171,8 @@ class ln {
1362
1171
  this.cancelableConnectWithRepeatedCalls?.cancel();
1363
1172
  }
1364
1173
  }
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({
1174
+ 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 || {});
1175
+ const Ie = j({
1367
1176
  types: {
1368
1177
  context: {},
1369
1178
  events: {}
@@ -1677,14 +1486,14 @@ const Cn = lt({
1677
1486
  }
1678
1487
  }
1679
1488
  });
1680
- class Nn {
1489
+ class Re {
1681
1490
  actor;
1682
1491
  stateChangeListeners = /* @__PURE__ */ new Set();
1683
1492
  events;
1684
1493
  unsubscribeFromEvents;
1685
1494
  actorSubscription;
1686
1495
  constructor(e) {
1687
- this.events = e, this.actor = Ct(Cn), this.actorSubscription = this.actor.subscribe((t) => {
1496
+ this.events = e, this.actor = Z(Ie), this.actorSubscription = this.actor.subscribe((t) => {
1688
1497
  const s = t.value;
1689
1498
  this.stateChangeListeners.forEach((i) => {
1690
1499
  i(s);
@@ -1770,7 +1579,7 @@ class Nn {
1770
1579
  return this.actor.getSnapshot().can({ type: e });
1771
1580
  }
1772
1581
  getValidEvents() {
1773
- return Object.values(dt).filter((e) => this.canTransition(e));
1582
+ return Object.values(X).filter((e) => this.canTransition(e));
1774
1583
  }
1775
1584
  hasState(e) {
1776
1585
  return this.actor.getSnapshot().matches(e);
@@ -1839,7 +1648,7 @@ class Nn {
1839
1648
  };
1840
1649
  }
1841
1650
  }
1842
- class An {
1651
+ class Me {
1843
1652
  events;
1844
1653
  getUaProtected;
1845
1654
  constructor(e) {
@@ -1848,13 +1657,13 @@ class An {
1848
1657
  async register() {
1849
1658
  const e = this.getUaProtected();
1850
1659
  return new Promise((t, s) => {
1851
- e.on(A.REGISTERED, t), e.on(A.REGISTRATION_FAILED, s), e.register();
1660
+ e.on(u.REGISTERED, t), e.on(u.REGISTRATION_FAILED, s), e.register();
1852
1661
  });
1853
1662
  }
1854
1663
  async unregister() {
1855
1664
  const e = this.getUaProtected();
1856
1665
  return new Promise((t) => {
1857
- e.on(A.UNREGISTERED, t), e.unregister();
1666
+ e.on(u.UNREGISTERED, t), e.unregister();
1858
1667
  });
1859
1668
  }
1860
1669
  async tryRegister() {
@@ -1866,7 +1675,7 @@ class An {
1866
1675
  return this.register();
1867
1676
  }
1868
1677
  subscribeToStartEvents(e, t) {
1869
- const s = A.REGISTERED, i = [A.REGISTRATION_FAILED, A.DISCONNECTED];
1678
+ const s = u.REGISTERED, i = [u.REGISTRATION_FAILED, u.DISCONNECTED];
1870
1679
  return this.events.on(s, e), i.forEach((r) => {
1871
1680
  this.events.on(r, t);
1872
1681
  }), () => {
@@ -1876,7 +1685,7 @@ class An {
1876
1685
  };
1877
1686
  }
1878
1687
  }
1879
- class _n {
1688
+ class pe {
1880
1689
  uaFactory;
1881
1690
  getUaProtected;
1882
1691
  constructor(e) {
@@ -1922,30 +1731,30 @@ class _n {
1922
1731
  extraHeaders: a
1923
1732
  }) {
1924
1733
  return new Promise((o, c) => {
1925
- const { configuration: T } = this.uaFactory.createConfiguration({
1734
+ const { configuration: g } = this.uaFactory.createConfiguration({
1926
1735
  sipWebSocketServerURL: i,
1927
1736
  displayName: t,
1928
1737
  userAgent: e,
1929
1738
  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);
1739
+ }), d = this.uaFactory.createUA({ ...g, remoteAddress: r, extraHeaders: a }), S = () => {
1740
+ const E = new Error("Telephony is not available");
1741
+ c(E);
1933
1742
  };
1934
- S.once(A.DISCONNECTED, l);
1935
- const d = () => {
1936
- S.removeAllListeners(), S.once(A.DISCONNECTED, () => {
1743
+ d.once(u.DISCONNECTED, S);
1744
+ const l = () => {
1745
+ d.removeAllListeners(), d.once(u.DISCONNECTED, () => {
1937
1746
  o();
1938
- }), S.stop();
1747
+ }), d.stop();
1939
1748
  };
1940
- S.once(A.CONNECTED, d), S.start();
1749
+ d.once(u.CONNECTED, l), d.start();
1941
1750
  });
1942
1751
  }
1943
1752
  }
1944
- const un = (n) => {
1753
+ const me = (n) => {
1945
1754
  const e = [];
1946
1755
  return n !== void 0 && n !== "" && e.push(`X-Vinteo-Remote: ${n}`), e;
1947
1756
  };
1948
- class p {
1757
+ class m {
1949
1758
  JsSIP;
1950
1759
  constructor(e) {
1951
1760
  this.JsSIP = e;
@@ -1970,10 +1779,10 @@ class p {
1970
1779
  throw new Error("user is required for authorized connection");
1971
1780
  }
1972
1781
  static resolveAuthorizationUser(e, t) {
1973
- return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${Jt()}`;
1782
+ return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${se()}`;
1974
1783
  }
1975
1784
  static buildExtraHeaders(e, t) {
1976
- const s = e !== void 0 && e !== "" ? un(e) : [];
1785
+ const s = e !== void 0 && e !== "" ? me(e) : [];
1977
1786
  return t === void 0 ? s : [...s, ...t];
1978
1787
  }
1979
1788
  createConfiguration({
@@ -1986,40 +1795,40 @@ class p {
1986
1795
  sessionTimers: o = !1,
1987
1796
  registerExpires: c = 300,
1988
1797
  // 5 minutes in sec
1989
- connectionRecoveryMinInterval: T = 2,
1990
- connectionRecoveryMaxInterval: S = 6,
1991
- userAgent: l
1798
+ connectionRecoveryMinInterval: g = 2,
1799
+ connectionRecoveryMaxInterval: d = 6,
1800
+ userAgent: S
1992
1801
  }) {
1993
- p.validateConfiguration({
1802
+ m.validateConfiguration({
1994
1803
  register: a,
1995
1804
  password: t,
1996
1805
  user: e,
1997
1806
  sipServerUrl: r,
1998
1807
  sipWebSocketServerURL: s
1999
1808
  });
2000
- const d = p.resolveAuthorizationUser(a, e), h = Qt(r), I = h(d), C = new this.JsSIP.WebSocketInterface(s);
1809
+ const l = m.resolveAuthorizationUser(a, e), E = te(r), I = E(l), C = new this.JsSIP.WebSocketInterface(s);
2001
1810
  return {
2002
1811
  configuration: {
2003
1812
  password: t,
2004
1813
  register: a,
2005
1814
  uri: I,
2006
- display_name: Et(i),
2007
- user_agent: l,
1815
+ display_name: B(i),
1816
+ user_agent: S,
2008
1817
  sdpSemantics: "unified-plan",
2009
1818
  sockets: [C],
2010
1819
  session_timers: o,
2011
1820
  register_expires: c,
2012
- connection_recovery_min_interval: T,
2013
- connection_recovery_max_interval: S
1821
+ connection_recovery_min_interval: g,
1822
+ connection_recovery_max_interval: d
2014
1823
  },
2015
1824
  helpers: {
2016
1825
  socket: C,
2017
- getSipServerUrl: h
1826
+ getSipServerUrl: E
2018
1827
  }
2019
1828
  };
2020
1829
  }
2021
1830
  createUA({ remoteAddress: e, extraHeaders: t, ...s }) {
2022
- const i = new this.JsSIP.UA(s), r = p.buildExtraHeaders(e, t);
1831
+ const i = new this.JsSIP.UA(s), r = m.buildExtraHeaders(e, t);
2023
1832
  return r.length > 0 && i.registrator().setExtraHeaders(r), i;
2024
1833
  }
2025
1834
  /**
@@ -2032,12 +1841,12 @@ class p {
2032
1841
  extraHeaders: e.extraHeaders
2033
1842
  });
2034
1843
  return t.eachTriggers((a, o) => {
2035
- const c = St.find((T) => T === o);
1844
+ const c = z.find((g) => g === o);
2036
1845
  c && r.on(c, a);
2037
1846
  }), { ua: r, helpers: i };
2038
1847
  }
2039
1848
  }
2040
- class In {
1849
+ class Pe {
2041
1850
  events;
2042
1851
  ua;
2043
1852
  socket;
@@ -2049,15 +1858,15 @@ class In {
2049
1858
  configurationManager;
2050
1859
  JsSIP;
2051
1860
  constructor({ JsSIP: e }) {
2052
- this.JsSIP = e, this.events = new D(dn), this.uaFactory = new p(e), this.registrationManager = new An({
1861
+ this.JsSIP = e, this.events = new O(Q), this.uaFactory = new m(e), this.registrationManager = new Me({
2053
1862
  events: this.events,
2054
1863
  getUaProtected: this.getUaProtected
2055
- }), this.stateMachine = new Nn(this.events), this.configurationManager = new Sn({
1864
+ }), this.stateMachine = new Re(this.events), this.configurationManager = new ue({
2056
1865
  getUa: this.getUa
2057
- }), this.sipOperations = new _n({
1866
+ }), this.sipOperations = new pe({
2058
1867
  uaFactory: this.uaFactory,
2059
1868
  getUaProtected: this.getUaProtected
2060
- }), this.connectionFlow = new ln({
1869
+ }), this.connectionFlow = new _e({
2061
1870
  JsSIP: this.JsSIP,
2062
1871
  events: this.events,
2063
1872
  uaFactory: this.uaFactory,
@@ -2095,7 +1904,7 @@ class In {
2095
1904
  return this.stateMachine.state;
2096
1905
  }
2097
1906
  get isRegistered() {
2098
- return p.isRegisteredUA(this.ua);
1907
+ return m.isRegisteredUA(this.ua);
2099
1908
  }
2100
1909
  get isRegisterConfig() {
2101
1910
  return this.configurationManager.isRegister();
@@ -2148,19 +1957,19 @@ class In {
2148
1957
  };
2149
1958
  getUa = () => this.ua;
2150
1959
  }
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 = [
1960
+ 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))($ || {});
1961
+ const J = [
2153
1962
  "incomingCall",
2154
1963
  "declinedIncomingCall",
2155
1964
  "terminatedIncomingCall",
2156
1965
  "failedIncomingCall"
2157
- ], Mn = 486, On = 487;
2158
- class pn {
1966
+ ], Oe = 486, fe = 487;
1967
+ class De {
1968
+ events;
2159
1969
  incomingRTCSession;
2160
1970
  connectionManager;
2161
- events;
2162
1971
  constructor(e) {
2163
- this.connectionManager = e, this.events = new D(Rn), this.start();
1972
+ this.connectionManager = e, this.events = new O(J), this.start();
2164
1973
  }
2165
1974
  get remoteCallerData() {
2166
1975
  return {
@@ -2190,19 +1999,19 @@ class pn {
2190
1999
  return this.removeIncomingSession(), e;
2191
2000
  };
2192
2001
  async declineToIncomingCall({
2193
- statusCode: e = On
2002
+ statusCode: e = fe
2194
2003
  } = {}) {
2195
2004
  return new Promise((t, s) => {
2196
2005
  try {
2197
2006
  const i = this.getIncomingRTCSession(), r = this.remoteCallerData;
2198
- this.removeIncomingSession(), this.events.trigger(f.DECLINED_INCOMING_CALL, r), i.terminate({ status_code: e }), t();
2007
+ this.removeIncomingSession(), this.events.trigger(D.DECLINED_INCOMING_CALL, r), i.terminate({ status_code: e }), t();
2199
2008
  } catch (i) {
2200
2009
  s(i);
2201
2010
  }
2202
2011
  });
2203
2012
  }
2204
2013
  async busyIncomingCall() {
2205
- return this.declineToIncomingCall({ statusCode: Mn });
2014
+ return this.declineToIncomingCall({ statusCode: Oe });
2206
2015
  }
2207
2016
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2208
2017
  on(e, t) {
@@ -2239,26 +2048,34 @@ class pn {
2239
2048
  this.incomingRTCSession = e;
2240
2049
  const t = this.remoteCallerData;
2241
2050
  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);
2051
+ this.removeIncomingSession(), s.originator === $.LOCAL ? this.events.trigger(D.TERMINATED_INCOMING_CALL, t) : this.events.trigger(D.FAILED_INCOMING_CALL, t);
2052
+ }), this.events.trigger(D.INCOMING_CALL, t);
2244
2053
  }
2245
2054
  removeIncomingSession() {
2246
2055
  delete this.incomingRTCSession;
2247
2056
  }
2248
2057
  }
2249
- class $n {
2058
+ 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 = [
2059
+ ...ve,
2060
+ ...ye,
2061
+ ...Ue,
2062
+ ...be,
2063
+ ...we
2064
+ ];
2065
+ class xe {
2066
+ events;
2250
2067
  connectionManager;
2251
2068
  callManager;
2252
2069
  apiManager;
2253
2070
  incomingCallManager;
2254
2071
  presentationManager;
2255
2072
  constructor({ JsSIP: e }) {
2256
- this.connectionManager = new In({ JsSIP: e }), this.callManager = new tn(), this.apiManager = new gn({
2073
+ this.events = new O(Le), this.connectionManager = new Pe({ JsSIP: e }), this.callManager = new ge(), this.apiManager = new Se({
2257
2074
  connectionManager: this.connectionManager,
2258
2075
  callManager: this.callManager
2259
- }), this.incomingCallManager = new pn(this.connectionManager), this.presentationManager = new rn({
2076
+ }), this.incomingCallManager = new De(this.connectionManager), this.presentationManager = new Ne({
2260
2077
  callManager: this.callManager
2261
- });
2078
+ }), this.subscribe();
2262
2079
  }
2263
2080
  get requestedConnection() {
2264
2081
  return this.connectionManager.requested;
@@ -2299,34 +2116,34 @@ class $n {
2299
2116
  get isAvailableIncomingCall() {
2300
2117
  return this.incomingCallManager.isAvailableIncomingCall;
2301
2118
  }
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
2119
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2312
- onConnection(e, t) {
2313
- return this.connectionManager.on(e, t);
2120
+ on(e, t) {
2121
+ return this.events.on(e, t);
2314
2122
  }
2315
2123
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2316
- onceConnection(e, t) {
2317
- return this.connectionManager.once(e, t);
2124
+ once(e, t) {
2125
+ return this.events.once(e, t);
2318
2126
  }
2319
2127
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2320
- onceRaceConnection(e, t) {
2321
- return this.connectionManager.onceRace(e, t);
2128
+ onceRace(e, t) {
2129
+ return this.events.onceRace(e, t);
2322
2130
  }
2323
- async waitConnection(e) {
2324
- return this.connectionManager.wait(e);
2131
+ async wait(e) {
2132
+ return this.events.wait(e);
2325
2133
  }
2326
2134
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2327
- offConnection(e, t) {
2328
- this.connectionManager.off(e, t);
2135
+ off(e, t) {
2136
+ this.events.off(e, t);
2329
2137
  }
2138
+ connect = async (...e) => this.connectionManager.connect(...e);
2139
+ set = async (...e) => this.connectionManager.set(...e);
2140
+ disconnect = async () => this.connectionManager.disconnect();
2141
+ register = async () => this.connectionManager.register();
2142
+ unregister = async () => this.connectionManager.unregister();
2143
+ tryRegister = async () => this.connectionManager.tryRegister();
2144
+ sendOptions = async (e, t, s) => this.connectionManager.sendOptions(e, t, s);
2145
+ ping = async (e, t) => this.connectionManager.ping(e, t);
2146
+ checkTelephony = async (e) => this.connectionManager.checkTelephony(e);
2330
2147
  isConfigured = () => this.connectionManager.isConfigured();
2331
2148
  getConnectionConfiguration = () => this.connectionManager.getConnectionConfiguration();
2332
2149
  getSipServerUrl = (e) => this.connectionManager.getSipServerUrl(e);
@@ -2345,44 +2162,6 @@ class $n {
2345
2162
  getCallConfiguration = () => this.callManager.getCallConfiguration();
2346
2163
  getRemoteStreams = () => this.callManager.getRemoteStreams();
2347
2164
  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
2165
  async startPresentation(e, t = {}) {
2387
2166
  const { isP2P: s, callLimit: i, ...r } = t;
2388
2167
  return this.presentationManager.startPresentation(
@@ -2452,41 +2231,38 @@ class $n {
2452
2231
  async askPermissionToEnableCam(...e) {
2453
2232
  return this.apiManager.askPermissionToEnableCam(...e);
2454
2233
  }
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);
2234
+ subscribe() {
2235
+ this.connectionManager.events.eachTriggers((e, t) => {
2236
+ this.connectionManager.on(t, (s) => {
2237
+ this.events.trigger(`connection:${t}`, s);
2238
+ });
2239
+ }), this.callManager.events.eachTriggers((e, t) => {
2240
+ this.callManager.on(t, (s) => {
2241
+ this.events.trigger(`call:${t}`, s);
2242
+ });
2243
+ }), this.apiManager.events.eachTriggers((e, t) => {
2244
+ this.apiManager.on(t, (s) => {
2245
+ this.events.trigger(`api:${t}`, s);
2246
+ });
2247
+ }), this.incomingCallManager.events.eachTriggers((e, t) => {
2248
+ this.incomingCallManager.on(t, (s) => {
2249
+ this.events.trigger(`incoming-call:${t}`, s);
2250
+ });
2251
+ }), this.presentationManager.events.eachTriggers((e, t) => {
2252
+ this.presentationManager.on(t, (s) => {
2253
+ this.events.trigger(`presentation:${t}`, s);
2254
+ });
2255
+ });
2473
2256
  }
2474
2257
  }
2475
2258
  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,
2259
+ x as E,
2260
+ U as O,
2261
+ xe as S,
2262
+ f as a,
2263
+ Ee as b,
2264
+ Ge as d,
2265
+ He as e,
2266
+ Be as h,
2491
2267
  P as l
2492
2268
  };