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

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