sip-connector 7.0.10 → 8.1.0

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.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { l as o, B as V, N as x, E as B, s as q, S as Qe } from "./SipConnector-3gRIidBJ.js";
2
- import { f as un, g as ln, i as Sn, c as mn, a as dn, d as fn, b as Cn, e as gn, h as Rn } from "./SipConnector-3gRIidBJ.js";
1
+ import { l as o, B as V, N as x, E as B, s as q, S as Qe } from "./SipConnector-C5s0hhzA.js";
2
+ import { f as un, g as ln, i as Sn, c as mn, a as dn, d as fn, b as Cn, e as gn, h as Rn } from "./SipConnector-C5s0hhzA.js";
3
3
  import { debounce as z } from "ts-debounce";
4
4
  import { isCanceledError as J } from "@krivega/cancelable-promise";
5
5
  import { hasCanceledError as Q } from "repeated-calls";
@@ -25,13 +25,13 @@ const $ = "purgatory", N = (e) => e === $, w = (e) => () => (o("getRemoteStreams
25
25
  onSuccessProgressCall: d,
26
26
  onEnterPurgatory: f,
27
27
  onEnterConference: S,
28
- onFailProgressCall: g,
29
- onFinishProgressCall: m,
28
+ onFailProgressCall: m,
29
+ onFinishProgressCall: M,
30
30
  onEndedCall: C
31
- } = n, E = D({
31
+ } = n, R = D({
32
32
  setRemoteStreams: u,
33
33
  getRemoteStreams: w(e)
34
- }), y = G(E);
34
+ }), y = G(R);
35
35
  o("answerIncomingCall", n);
36
36
  const h = async () => e.answerToIncomingCall({
37
37
  mediaStream: r,
@@ -43,16 +43,16 @@ const $ = "purgatory", N = (e) => e === $, w = (e) => () => (o("getRemoteStreams
43
43
  const { remoteCallerData: i } = e;
44
44
  return i.incomingNumber;
45
45
  };
46
- let T = !1, M;
46
+ let E = !1, T;
47
47
  const _ = (o("subscribeEnterConference: onEnterConference", S), f ?? S ? e.onSession("enterRoom", (i) => {
48
- o("enterRoom", { _room: i, isSuccessProgressCall: T }), M = i, N(M) ? f && f() : S && S({ isSuccessProgressCall: T });
48
+ o("enterRoom", { _room: i, isSuccessProgressCall: E }), T = i, N(T) ? f && f() : S && S({ isSuccessProgressCall: E });
49
49
  }) : () => {
50
- }), p = (i) => (o("onSuccess"), T = !0, E(), d && d({ isPurgatory: N(M) }), e.onceRaceSession(["ended", "failed"], () => {
50
+ }), p = (i) => (o("onSuccess"), E = !0, R(), d && d({ isPurgatory: N(T) }), e.onceRaceSession(["ended", "failed"], () => {
51
51
  _(), C && C();
52
52
  }), i), O = (i) => {
53
- throw o("onFail"), g && g(), _(), i;
53
+ throw o("onFail"), m && m(), _(), i;
54
54
  }, v = () => {
55
- o("onFinish"), m && m();
55
+ o("onFinish"), M && M();
56
56
  };
57
57
  if (o("onBeforeProgressCall"), l) {
58
58
  const i = b();
@@ -70,10 +70,10 @@ const $ = "purgatory", N = (e) => e === $, w = (e) => () => (o("getRemoteStreams
70
70
  onBeforeProgressCall: d,
71
71
  onSuccessProgressCall: f,
72
72
  onEnterPurgatory: S,
73
- onEnterConference: g,
74
- onFailProgressCall: m,
73
+ onEnterConference: m,
74
+ onFailProgressCall: M,
75
75
  onFinishProgressCall: C,
76
- onEndedCall: E
76
+ onEndedCall: R
77
77
  } = n, y = D({
78
78
  setRemoteStreams: l,
79
79
  getRemoteStreams: w(e)
@@ -87,14 +87,14 @@ const $ = "purgatory", N = (e) => e === $, w = (e) => () => (o("getRemoteStreams
87
87
  number: r,
88
88
  ontrack: h
89
89
  }));
90
- let T = !1, M;
91
- const _ = (o("subscribeEnterConference: onEnterConference", g), S ?? g ? e.onSession("enterRoom", ({ room: i }) => {
92
- o("enterRoom", { _room: i, isSuccessProgressCall: T }), M = i, N(M) ? S && S() : g && g({ isSuccessProgressCall: T });
90
+ let E = !1, T;
91
+ const _ = (o("subscribeEnterConference: onEnterConference", m), S ?? m ? e.onSession("enterRoom", ({ room: i }) => {
92
+ o("enterRoom", { _room: i, isSuccessProgressCall: E }), T = i, N(T) ? S && S() : m && m({ isSuccessProgressCall: E });
93
93
  }) : () => {
94
- }), p = (i) => (o("onSuccess"), T = !0, y(), f && f({ isPurgatory: N(M) }), e.onceRaceSession(["ended", "failed"], () => {
95
- _(), E && E();
94
+ }), p = (i) => (o("onSuccess"), E = !0, y(), f && f({ isPurgatory: N(T) }), e.onceRaceSession(["ended", "failed"], () => {
95
+ _(), R && R();
96
96
  }), i), O = (i) => {
97
- throw o("onFail"), m && m(), _(), i;
97
+ throw o("onFail"), M && M(), _(), i;
98
98
  }, v = () => {
99
99
  o("onFinish"), C && C();
100
100
  };
@@ -113,12 +113,10 @@ const $ = "purgatory", N = (e) => e === $, w = (e) => () => (o("getRemoteStreams
113
113
  name: l,
114
114
  password: d,
115
115
  isRegisteredUser: f,
116
- sdpSemantics: S,
117
- isDisconnectOnFail: g
116
+ isDisconnectOnFail: S
118
117
  } = n;
119
118
  return o("connectToServer", n), e.connect({
120
119
  userAgent: r,
121
- sdpSemantics: S,
122
120
  sipWebSocketServerURL: s,
123
121
  sipServerUrl: a,
124
122
  remoteAddress: c,
@@ -126,7 +124,7 @@ const $ = "purgatory", N = (e) => e === $, w = (e) => () => (o("getRemoteStreams
126
124
  password: d,
127
125
  user: l,
128
126
  register: f
129
- }).then((m) => (o("connectToServer then"), { ua: m, isSuccessful: !0 })).catch(async (m) => (o("connectToServer catch: error", m), g === !0 ? e.disconnect().then(() => I(m)).catch(() => I(m)) : I(m)));
127
+ }).then((m) => (o("connectToServer then"), { ua: m, isSuccessful: !0 })).catch(async (m) => (o("connectToServer catch: error", m), S === !0 ? e.disconnect().then(() => I(m)).catch(() => I(m)) : I(m)));
130
128
  }, oe = (e) => async () => (o("disconnectFromServer"), e.disconnect().then(() => (o("disconnectFromServer: then"), { isSuccessful: !0 })).catch((t) => (o("disconnectFromServer: catch", t), { isSuccessful: !1 }))), F = (e) => {
131
129
  const { url: t, cause: n } = e;
132
130
  let r = t;
@@ -247,12 +245,12 @@ const ae = (e = new Error()) => {
247
245
  const s = Ne(t)(e);
248
246
  return Z(s, n);
249
247
  }, Be = (e) => (n) => (o("onStartMainCam"), e.onSession("admin-start-main-cam", n)), Ie = (e) => (n) => (o("onStartMic"), e.onSession("admin-start-mic", n)), Pe = (e) => (n) => (o("onStopMainCam"), e.onSession("admin-stop-main-cam", n)), we = (e) => (n) => (o("onStopMic"), e.onSession("admin-stop-mic", n)), De = ({ sipConnector: e }) => {
250
- const t = (C, E) => ({ isSyncForced: y = !1 }) => {
248
+ const t = (C, R) => ({ isSyncForced: y = !1 }) => {
251
249
  if (y) {
252
250
  C();
253
251
  return;
254
252
  }
255
- E();
253
+ R();
256
254
  }, n = Be(e), r = Pe(e), s = Ie(e), a = we(e);
257
255
  let c = () => {
258
256
  }, u = () => {
@@ -261,17 +259,17 @@ const ae = (e = new Error()) => {
261
259
  };
262
260
  const f = ({
263
261
  onStartMainCamForced: C,
264
- onStartMainCamNotForced: E,
262
+ onStartMainCamNotForced: R,
265
263
  onStopMainCamForced: y,
266
264
  onStopMainCamNotForced: h,
267
265
  onStartMicForced: b,
268
- onStartMicNotForced: T,
269
- onStopMicForced: M,
266
+ onStartMicNotForced: E,
267
+ onStopMicForced: T,
270
268
  onStopMicNotForced: A
271
269
  }) => {
272
270
  const _ = t(
273
271
  C,
274
- E
272
+ R
275
273
  );
276
274
  c = n(_);
277
275
  const p = t(
@@ -279,9 +277,9 @@ const ae = (e = new Error()) => {
279
277
  h
280
278
  );
281
279
  u = r(p);
282
- const O = t(b, T);
280
+ const O = t(b, E);
283
281
  l = s(O);
284
- const v = t(M, A);
282
+ const v = t(T, A);
285
283
  d = a(v);
286
284
  }, S = () => {
287
285
  c(), u(), l(), d();
@@ -325,7 +323,7 @@ const ae = (e = new Error()) => {
325
323
  }), Le = (e) => e.find((t) => {
326
324
  var n;
327
325
  return ((n = t == null ? void 0 : t.track) == null ? void 0 : n.kind) === "video";
328
- }), W = (e, t) => e !== void 0 && t !== void 0 && e.toLowerCase().includes(t.toLowerCase()), Ve = 1e6, R = (e) => e * Ve, K = R(0.06), xe = R(4), $e = (e) => e <= 64 ? K : e <= 128 ? R(0.12) : e <= 256 ? R(0.25) : e <= 384 ? R(0.32) : e <= 426 ? R(0.38) : e <= 640 ? R(0.5) : e <= 848 ? R(0.7) : e <= 1280 ? R(1) : e <= 1920 ? R(2) : xe, Ge = "av1", Xe = (e) => W(e, Ge), We = 0.6, j = (e, t) => Xe(t) ? e * We : e, Ke = (e) => j(K, e), H = (e, t) => {
326
+ }), W = (e, t) => e !== void 0 && t !== void 0 && e.toLowerCase().includes(t.toLowerCase()), Ve = 1e6, g = (e) => e * Ve, K = g(0.06), xe = g(4), $e = (e) => e <= 64 ? K : e <= 128 ? g(0.12) : e <= 256 ? g(0.25) : e <= 384 ? g(0.32) : e <= 426 ? g(0.38) : e <= 640 ? g(0.5) : e <= 848 ? g(0.7) : e <= 1280 ? g(1) : e <= 1920 ? g(2) : xe, Ge = "av1", Xe = (e) => W(e, Ge), We = 0.6, j = (e, t) => Xe(t) ? e * We : e, Ke = (e) => j(K, e), H = (e, t) => {
329
327
  const n = $e(e);
330
328
  return j(n, t);
331
329
  }, Y = ee(), je = async () => Y().catch((e) => {
@@ -357,12 +355,12 @@ const ae = (e = new Error()) => {
357
355
  resolution: n,
358
356
  codec: r
359
357
  }, s) => {
360
- const a = t.getSettings(), c = a.width, u = a.height, [l, d] = n.split("x"), f = c / Number(l), S = u / Number(d), m = Math.max(f, S, 1), C = H(Number(l), r);
358
+ const a = t.getSettings(), c = a.width, u = a.height, [l, d] = n.split("x"), f = c / Number(l), S = u / Number(d), M = Math.max(f, S, 1), C = H(Number(l), r);
361
359
  return k({
362
360
  sender: e,
363
361
  maxBitrate: C,
364
362
  onSetParameters: s,
365
- scaleResolutionDownBy: m
363
+ scaleResolutionDownBy: M
366
364
  });
367
365
  }, ze = async ({
368
366
  mainCam: e,
@@ -8,7 +8,6 @@ export declare const dataForConnectionWithAuthorization: {
8
8
  remoteAddress: string;
9
9
  sipServerUrl: string;
10
10
  sipWebSocketServerURL: string;
11
- sdpSemantics: "plan-b";
12
11
  userAgent: string;
13
12
  };
14
13
  export declare const dataForConnectionWithAuthorizationWithDisplayName: {
@@ -16,7 +15,6 @@ export declare const dataForConnectionWithAuthorizationWithDisplayName: {
16
15
  remoteAddress: string;
17
16
  sipServerUrl: string;
18
17
  sipWebSocketServerURL: string;
19
- sdpSemantics: "plan-b";
20
18
  userAgent: string;
21
19
  };
22
20
  export declare const dataForConnectionWithoutAuthorization: {
@@ -25,7 +23,6 @@ export declare const dataForConnectionWithoutAuthorization: {
25
23
  remoteAddress: string;
26
24
  sipServerUrl: string;
27
25
  sipWebSocketServerURL: string;
28
- sdpSemantics: "plan-b";
29
26
  userAgent: string;
30
27
  };
31
28
  export declare const dataForConnectionWithoutAuthorizationWithoutDisplayName: {
@@ -34,7 +31,6 @@ export declare const dataForConnectionWithoutAuthorizationWithoutDisplayName: {
34
31
  remoteAddress: string;
35
32
  sipServerUrl: string;
36
33
  sipWebSocketServerURL: string;
37
- sdpSemantics: "plan-b";
38
34
  userAgent: string;
39
35
  };
40
36
  export declare const dataForConnectionWithoutAuthorizationWithSipServerUrlChanged: {
@@ -43,7 +39,6 @@ export declare const dataForConnectionWithoutAuthorizationWithSipServerUrlChange
43
39
  isRegisteredUser: boolean;
44
40
  remoteAddress: string;
45
41
  sipWebSocketServerURL: string;
46
- sdpSemantics: "plan-b";
47
42
  userAgent: string;
48
43
  };
49
44
  export declare const dataForConnectionWithoutAuthorizationWithSipWebSocketServerUrlChanged: {
@@ -53,7 +48,6 @@ export declare const dataForConnectionWithoutAuthorizationWithSipWebSocketServer
53
48
  isRegisteredUser: boolean;
54
49
  remoteAddress: string;
55
50
  sipServerUrl: string;
56
- sdpSemantics: "plan-b";
57
51
  userAgent: string;
58
52
  };
59
53
  export declare const dataForConnectionWithAuthorizationIncorrectUser: {
@@ -63,7 +57,6 @@ export declare const dataForConnectionWithAuthorizationIncorrectUser: {
63
57
  remoteAddress: string;
64
58
  sipServerUrl: string;
65
59
  sipWebSocketServerURL: string;
66
- sdpSemantics: "plan-b";
67
60
  userAgent: string;
68
61
  };
69
62
  export declare const dataForConnectionWithAuthorizationIncorrectPassword: {
@@ -73,7 +66,6 @@ export declare const dataForConnectionWithAuthorizationIncorrectPassword: {
73
66
  remoteAddress: string;
74
67
  sipServerUrl: string;
75
68
  sipWebSocketServerURL: string;
76
- sdpSemantics: "plan-b";
77
69
  userAgent: string;
78
70
  };
79
71
  export declare const withNameChanged: {
@@ -84,7 +76,6 @@ export declare const withNameChanged: {
84
76
  remoteAddress: string;
85
77
  sipServerUrl: string;
86
78
  sipWebSocketServerURL: string;
87
- sdpSemantics: "plan-b";
88
79
  userAgent: string;
89
80
  };
90
81
  export declare const dataForConnectionWithAuthorizationPasswordChanged: {
@@ -95,7 +86,6 @@ export declare const dataForConnectionWithAuthorizationPasswordChanged: {
95
86
  remoteAddress: string;
96
87
  sipServerUrl: string;
97
88
  sipWebSocketServerURL: string;
98
- sdpSemantics: "plan-b";
99
89
  userAgent: string;
100
90
  };
101
91
  export declare const uaConfigurationWithAuthorization: {
@@ -11,7 +11,6 @@ declare const resolveConnectToServer: (sipConnector: SipConnector) => (parameter
11
11
  password?: string;
12
12
  isRegisteredUser?: boolean;
13
13
  isDisconnectOnFail?: boolean;
14
- sdpSemantics: "plan-b" | "unified-plan";
15
14
  }) => Promise<{
16
15
  ua?: UA;
17
16
  isSuccessful: boolean;
package/dist/types.d.ts CHANGED
@@ -41,7 +41,6 @@ export type TParametersCreateUa = {
41
41
  user?: string;
42
42
  register?: boolean;
43
43
  password?: string;
44
- sdpSemantics?: 'plan-b' | 'unified-plan';
45
44
  sessionTimers?: boolean;
46
45
  registerExpires?: number;
47
46
  connectionRecoveryMinInterval?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sip-connector",
3
- "version": "7.0.10",
3
+ "version": "8.1.0",
4
4
  "description": "Module for connect to Vinteo server",
5
5
  "keywords": [
6
6
  "webrtc",
@@ -1 +0,0 @@
1
- "use strict";var Ot=Object.defineProperty;var ft=(r,e,t)=>e in r?Ot(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var i=(r,e,t)=>ft(r,typeof e!="symbol"?e+"":e,t);const N=require("@krivega/cancelable-promise"),ve=require("events-constructor"),pt=require("repeated-calls"),V=require("debug"),Dt="Connection Error",qe="Request Timeout",Pt="SIP Failure Code",Mt="Internal Error",vt="Busy",Y="Rejected",bt="Redirected",yt="Unavailable",We="Not Found",wt="Address Incomplete",Ut="Incompatible SDP",Lt="Missing SDP",Ht="Authentication Error",ke="Terminated",qt="WebRTC Error",Fe="Canceled",Wt="No Answer",kt="Expires",Ft="No ACK",Bt="Dialog Error",Vt="User Denied Media Access",Be="Bad Media Description",Yt="RTP Timeout",xt=Object.freeze(Object.defineProperty({__proto__:null,ADDRESS_INCOMPLETE:wt,AUTHENTICATION_ERROR:Ht,BAD_MEDIA_DESCRIPTION:Be,BUSY:vt,BYE:ke,CANCELED:Fe,CONNECTION_ERROR:Dt,DIALOG_ERROR:Bt,EXPIRES:kt,INCOMPATIBLE_SDP:Ut,INTERNAL_ERROR:Mt,MISSING_SDP:Lt,NOT_FOUND:We,NO_ACK:Ft,NO_ANSWER:Wt,REDIRECTED:bt,REJECTED:Y,REQUEST_TIMEOUT:qe,RTP_TIMEOUT:Yt,SIP_FAILURE_CODE:Pt,UNAVAILABLE:yt,USER_DENIED_MEDIA_ACCESS:Vt,WEBRTC_ERROR:qt},Symbol.toStringTag,{value:"Module"})),x="incomingCall",G="declinedIncomingCall",$="failedIncomingCall",X="terminatedIncomingCall",W="connecting",O="connected",u="disconnected",M="newRTCSession",f="registered",J="unregistered",p="registrationFailed",Ve="newMessage",z="sipEvent",Q="availableSecondRemoteStream",K="notAvailableSecondRemoteStream",j="mustStopPresentation",v="shareState",Z="enterRoom",ee="useLicense",te="peerconnection:confirmed",ne="peerconnection:ontrack",b="channels",se="channels:notify",ie="ended:fromserver",re="main-cam-control",oe="admin-stop-main-cam",ae="admin-start-main-cam",ce="admin-stop-mic",Ee="admin-start-mic",y="admin-force-sync-media-state",_e="participant:added-to-list-moderators",he="participant:removed-from-list-moderators",le="participant:move-request-to-stream",de="participant:move-request-to-spectators",Te="participation:accepting-word-request",Se="participation:cancelling-word-request",ue="webcast:started",Ne="webcast:stopped",Ce="account:changed",ge="account:deleted",Ae="conference:participant-token-issued",D="ended",Ye="sending",xe="reinvite",Ge="replaces",$e="refer",Xe="progress",Je="accepted",w="confirmed",U="peerconnection",g="failed",ze="muted",Qe="unmuted",Re="newDTMF",Ie="newInfo",Ke="hold",je="unhold",Ze="update",et="sdp",tt="icecandidate",nt="getusermediafailed",st="peerconnection:createofferfailed",it="peerconnection:createanswerfailed",rt="peerconnection:setlocaldescriptionfailed",ot="peerconnection:setremotedescriptionfailed",at="presentation:start",ct="presentation:started",Et="presentation:end",me="presentation:ended",L="presentation:failed",_t="SPECTATOR",Gt=Object.freeze(Object.defineProperty({__proto__:null,ACCEPTED:Je,ACCOUNT_CHANGED:Ce,ACCOUNT_DELETED:ge,ADMIN_FORCE_SYNC_MEDIA_STATE:y,ADMIN_START_MAIN_CAM:ae,ADMIN_START_MIC:Ee,ADMIN_STOP_MAIN_CAM:oe,ADMIN_STOP_MIC:ce,AVAILABLE_SECOND_REMOTE_STREAM_EVENT:Q,CHANNELS:b,CHANNELS_NOTIFY:se,CONFERENCE_PARTICIPANT_TOKEN_ISSUED:Ae,CONFIRMED:w,CONNECTED:O,CONNECTING:W,DECLINED_INCOMING_CALL:G,DISCONNECTED:u,ENDED:D,ENDED_FROM_SERVER:ie,ENTER_ROOM:Z,FAILED:g,FAILED_INCOMING_CALL:$,GET_USER_MEDIA_FAILED:nt,HOLD:Ke,ICE_CANDIDATE:tt,INCOMING_CALL:x,MAIN_CAM_CONTROL:re,MUST_STOP_PRESENTATION_EVENT:j,MUTED:ze,NEW_DTMF:Re,NEW_INFO:Ie,NEW_MESSAGE:Ve,NEW_RTC_SESSION:M,NOT_AVAILABLE_SECOND_REMOTE_STREAM_EVENT:K,PARTICIPANT_ADDED_TO_LIST_MODERATORS:_e,PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS:de,PARTICIPANT_MOVE_REQUEST_TO_STREAM:le,PARTICIPANT_REMOVED_FROM_LIST_MODERATORS:he,PARTICIPATION_ACCEPTING_WORD_REQUEST:Te,PARTICIPATION_CANCELLING_WORD_REQUEST:Se,PEER_CONNECTION:U,PEER_CONNECTION_CONFIRMED:te,PEER_CONNECTION_CREATE_ANSWER_FAILED:it,PEER_CONNECTION_CREATE_OFFER_FAILED:st,PEER_CONNECTION_ONTRACK:ne,PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED:rt,PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED:ot,PRESENTATION_END:Et,PRESENTATION_ENDED:me,PRESENTATION_FAILED:L,PRESENTATION_START:at,PRESENTATION_STARTED:ct,PROGRESS:Xe,REFER:$e,REGISTERED:f,REGISTRATION_FAILED:p,REINVITE:xe,REPLACES:Ge,SDP:et,SENDING:Ye,SHARE_STATE:v,SIP_EVENT:z,SPECTATOR:_t,TERMINATED_INCOMING_CALL:X,UNHOLD:je,UNMUTED:Qe,UNREGISTERED:J,UPDATE:Ze,USE_LICENSE:ee,WEBCAST_STARTED:ue,WEBCAST_STOPPED:Ne},Symbol.toStringTag,{value:"Module"})),ht=[x,G,X,$,Te,Se,le,se,Ae,Ce,ge,ue,Ne,_e,he],Oe=[W,O,u,M,f,J,p,Ve,z],lt=[Q,K,j,v,Z,ee,te,ne,b,ie,re,ae,oe,ce,Ee,y,de],fe=[D,W,Ye,xe,Ge,$e,Xe,Je,w,U,g,ze,Qe,Re,Ie,Ke,je,Ze,et,tt,nt,st,it,rt,ot,at,ct,Et,me,L],pe=[...Oe,...ht],De=[...fe,...lt],$t=Object.freeze(Object.defineProperty({__proto__:null,SESSION_EVENT_NAMES:De,SESSION_JSSIP_EVENT_NAMES:fe,SESSION_SYNTHETICS_EVENT_NAMES:lt,UA_EVENT_NAMES:pe,UA_JSSIP_EVENT_NAMES:Oe,UA_SYNTHETICS_EVENT_NAMES:ht},Symbol.toStringTag,{value:"Module"})),Xt=r=>{const e=[];return r&&e.push(`X-Vinteo-Remote: ${r}`),e},Jt="content-type",zt="x-webrtc-enter-room",P="application/vinteo.webrtc.sharedesktop",Qt="application/vinteo.webrtc.roomname",Kt="application/vinteo.webrtc.channels",jt="application/vinteo.webrtc.mediastate",Zt="application/vinteo.webrtc.refusal",be="application/vinteo.webrtc.maincam",en="application/vinteo.webrtc.mic",tn="application/vinteo.webrtc.uselic",nn="X-WEBRTC-USE-LICENSE",sn="X-WEBRTC-PARTICIPANT-NAME",ye="X-WEBRTC-INPUT-CHANNELS",we="X-WEBRTC-OUTPUT-CHANNELS",rn="X-WEBRTC-MAINCAM",on="X-WEBRTC-MIC",Ue="X-WEBRTC-SYNC",an="X-WEBRTC-MAINCAM-RESOLUTION",cn="X-WEBRTC-MEDIA-STATE",En="X-Vinteo-Media-Type",_n="X-Vinteo-MainCam-State",hn="X-Vinteo-Mic-State",ln="application/vinteo.webrtc.partstate",dn="X-WEBRTC-PARTSTATE",Tn="application/vinteo.webrtc.notify",Sn="X-VINTEO-NOTIFY",R="x-webrtc-share-state",un=`${R}: LETMESTARTPRESENTATION`,Nn=`${R}: STOPPRESENTATION`,dt="YOUCANRECEIVECONTENT",Tt="CONTENTEND",St="YOUMUSTSTOPSENDCONTENT",Cn=`${R}: ${St}`,gn=`${R}: ${dt}`,An=`${R}: ${Tt}`,Rn="X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE",In=`${Rn}: LETMESTARTMAINCAM`,Pe="sip-connector",F=V(Pe),mn=()=>{V.enable(Pe)},On=()=>{V.enable(`-${Pe}`)};var A=(r=>(r.PAUSE_MAIN_CAM="PAUSEMAINCAM",r.RESUME_MAIN_CAM="RESUMEMAINCAM",r.MAX_MAIN_CAM_RESOLUTION="MAXMAINCAMRESOLUTION",r.ADMIN_STOP_MAIN_CAM="ADMINSTOPMAINCAM",r.ADMIN_START_MAIN_CAM="ADMINSTARTMAINCAM",r))(A||{}),H=(r=>(r.ADMIN_STOP_MIC="ADMINSTOPMIC",r.ADMIN_START_MIC="ADMINSTARTMIC",r))(H||{}),q=(r=>(r.ADMIN_SYNC_FORCED="1",r.ADMIN_SYNC_NOT_FORCED="0",r))(q||{}),ut=(r=>(r.AUDIO="AUDIO",r.VIDEO="VIDEO",r.AUDIOPLUSPRESENTATION="AUDIOPLUSPRESENTATION",r))(ut||{});function fn(r){return e=>`sip:${e}@${r}`}const pn=(r,e)=>()=>Math.floor(Math.random()*(e-r))+r,Le=r=>r.trim().replaceAll(" ","_"),Dn=pn(1e5,99999999),k=(r,{videoMode:e,audioMode:t}={})=>{if(!r||e==="recvonly"&&t==="recvonly")return;const n=t==="recvonly"?[]:r.getAudioTracks(),s=e==="recvonly"?[]:r.getVideoTracks(),o=[...n,...s],a=new MediaStream(o);return a.getTracks=()=>[...a.getAudioTracks(),...a.getVideoTracks()],a},Pn=r=>r.some(t=>{const{kind:n}=t;return n==="video"}),Mn="Error decline with 603",vn=1006,bn=r=>typeof r=="object"&&r!==null&&"code"in r&&r.code===vn,yn=r=>r.message===Mn,wn=(r,e)=>r.find(t=>t.track&&e.getTracks().includes(t.track)),Nt=1,Ct=r=>(e,t)=>t!==void 0&&e!==t||t===void 0&&e!==r,Un=Ct(Nt),Ln=(r,e)=>{const t=r===void 0?void 0:Math.max(r,Nt);if(t!==void 0&&Un(t,e))return t},Hn=Ct(),qn=(r,e)=>{if(Hn(r,e))return r},gt=async(r,e,t)=>{const n=r.getParameters();(n.encodings===void 0||n.encodings.length===0)&&(n.encodings=[{}]);const[s]=n.encodings,o=s.scaleResolutionDownBy,a=Ln(e.scaleResolutionDownBy,o);let c=!1;a!==void 0&&(n.encodings[0].scaleResolutionDownBy=a,c=!0);const _=s.maxBitrate,E=qn(e.maxBitrate,_);return E!==void 0&&(n.encodings[0].maxBitrate=E,c=!0),c?(t&&t(n),r.setParameters(n).then(()=>({parameters:n,isChanged:c}))):{parameters:n,isChanged:c}},Wn=async(r,e,t)=>{const n=wn(r,e);if(n)return gt(n,{maxBitrate:t})},kn=486,Fn=487,B="local",He="remote",Bn=3,Vn=(r=new Error)=>{const{originator:e,cause:t}=r;return N.isCanceledError(r)?!0:typeof t=="string"?t===qe||t===Y||e===B&&(t===Fe||t===ke):!1},C="SipConnector",Yn="channels",xn="WebcastStarted",Gn="WebcastStopped",$n="accountChanged",Xn="accountDeleted",Jn="addedToListModerators",zn="removedFromListModerators",Qn="ParticipationRequestAccepted",Kn="ParticipationRequestRejected",jn="ParticipantMovedToWebcast",Zn="ConferenceParticipantTokenIssued";class es{constructor({JsSIP:e}){i(this,"_isRegisterConfig",!1);i(this,"_connectionConfiguration",{});i(this,"_remoteStreams",{});i(this,"JsSIP");i(this,"_sessionEvents");i(this,"_uaEvents");i(this,"_cancelableConnect");i(this,"_cancelableConnectWithRepeatedCalls");i(this,"_cancelableInitUa");i(this,"_cancelableDisconnect");i(this,"_cancelableSet");i(this,"_cancelableCall");i(this,"_cancelableAnswer");i(this,"_cancelableSendDTMF");i(this,"getSipServerUrl",e=>e);i(this,"promisePendingStartPresentation");i(this,"promisePendingStopPresentation");i(this,"ua");i(this,"session");i(this,"incomingSession");i(this,"_streamPresentationCurrent");i(this,"socket");i(this,"connect",async(e,t)=>(this._cancelRequests(),this._connectWithDuplicatedCalls(e,t)));i(this,"initUa",async e=>this._cancelableInitUa.request(e));i(this,"set",async e=>this._cancelableSet.request(e));i(this,"call",async e=>this._cancelableCall.request(e));i(this,"disconnect",async()=>(this._cancelRequests(),this._disconnectWithoutCancelRequests()));i(this,"answerToIncomingCall",async e=>this._cancelableAnswer.request(e));i(this,"sendDTMF",async e=>this._cancelableSendDTMF.request(e));i(this,"hangUp",async()=>(this._cancelRequests(),this._hangUpWithoutCancelRequests()));i(this,"tryRegister",async()=>{if(!this.isRegisterConfig)throw new Error("Config is not registered");this._uaEvents.trigger(W,void 0);try{await this.unregister()}catch(e){F("tryRegister",e)}return this.register()});i(this,"declineToIncomingCall",async({statusCode:e=Fn}={})=>new Promise((t,n)=>{if(!this.isAvailableIncomingCall){n(new Error("no incomingSession"));return}const s=this.incomingSession,o=this.remoteCallerData;this._cancelableCall.cancelRequest(),this._cancelableAnswer.cancelRequest(),this.removeIncomingSession(),this._uaEvents.trigger(G,o),t(s.terminate({status_code:e}))}));i(this,"busyIncomingCall",async()=>this.declineToIncomingCall({statusCode:kn}));i(this,"removeIncomingSession",()=>{delete this.incomingSession});i(this,"_connectWithDuplicatedCalls",async(e,{callLimit:t=Bn}={})=>{let n=!0;const s=async()=>(n=!1,this._cancelableConnect.request(e)),o=a=>{var h;const c=!!((h=this.ua)!=null&&h.isConnected()),_=!n&&c&&this.hasEqualConnectionConfiguration(e),E=!!a&&!bn(a);return _||E};return this._cancelableConnectWithRepeatedCalls=pt.repeatedCallsAsync({targetFunction:s,isComplete:o,callLimit:t,isRejectAsValid:!0,onAfterCancel:()=>{this._cancelableConnect.cancelRequest()}}),this._cancelableConnectWithRepeatedCalls.then(a=>{if(a instanceof this.JsSIP.UA)return a;throw a})});i(this,"handleNewRTCSession",({originator:e,session:t})=>{if(e===He){this.incomingSession=t;const n=this.remoteCallerData;t.on(g,s=>{this.removeIncomingSession(),s.originator===B?this._uaEvents.trigger(X,n):this._uaEvents.trigger($,n)}),this._uaEvents.trigger(x,n)}});i(this,"_connect",async e=>this.initUa(e).then(async()=>this._start()));i(this,"_initUa",async({user:e,password:t,sipServerUrl:n,sipWebSocketServerURL:s,remoteAddress:o,sdpSemantics:a,sessionTimers:c,registerExpires:_,connectionRecoveryMinInterval:E,connectionRecoveryMaxInterval:h,userAgent:d,displayName:l="",register:T=!1,extraHeaders:S=[]})=>{if(!n)throw new Error("sipServerUrl is required");if(!s)throw new Error("sipWebSocketServerURL is required");if(T&&!e)throw new Error("user is required for authorized connection");if(T&&!t)throw new Error("password is required for authorized connection");this._connectionConfiguration={sipServerUrl:n,displayName:l,register:T,user:e,password:t};const{configuration:I,helpers:m}=this.createUaConfiguration({user:e,sipServerUrl:n,sipWebSocketServerURL:s,password:t,displayName:l,register:T,sdpSemantics:a,sessionTimers:c,registerExpires:_,connectionRecoveryMinInterval:E,connectionRecoveryMaxInterval:h,userAgent:d});this.getSipServerUrl=m.getSipServerUrl,this.socket=m.socket,this.ua&&await this._disconnectWithoutCancelRequests(),this._isRegisterConfig=!!T,this.ua=this._createUa(I),this._uaEvents.eachTriggers((Rt,It)=>{const Me=Oe.find(mt=>mt===It);Me&&this.ua&&this.ua.on(Me,Rt)});const At=[...Xt(o),...S];return this.ua.registrator().setExtraHeaders(At),this.ua});i(this,"_createUa",e=>new this.JsSIP.UA(e));i(this,"_start",async()=>new Promise((e,t)=>{const{ua:n}=this;if(!n){t(new Error("this.ua is not initialized"));return}const s=()=>{c(),e(n)},o=_=>{c(),t(_)},a=()=>{this.isRegisterConfig?(this.on(f,s),this.on(p,o)):this.on(O,s),this.on(u,o)},c=()=>{this.off(f,s),this.off(p,o),this.off(O,s),this.off(u,o)};a(),this.on(M,this.handleNewRTCSession),n.start()}));i(this,"_set",async({displayName:e,password:t})=>new Promise((n,s)=>{const{ua:o}=this;if(!o){s(new Error("this.ua is not initialized"));return}let a=!1,c=!1;e!==void 0&&e!==this._connectionConfiguration.displayName&&(a=o.set("display_name",Le(e)),this._connectionConfiguration.displayName=e),t!==void 0&&t!==this._connectionConfiguration.password&&(c=o.set("password",t),this._connectionConfiguration.password=t);const _=a||c;c&&this.isRegisterConfig?this.register().then(()=>{n(_)}).catch(E=>{s(E)}):_?n(_):s(new Error("nothing changed"))}));i(this,"_disconnectWithoutCancelRequests",async()=>this._cancelableDisconnect.request());i(this,"_disconnect",async()=>{this.off(M,this.handleNewRTCSession);const e=new Promise(t=>{this.once(u,()=>{delete this.ua,t()})});return this.ua?(await this._hangUpWithoutCancelRequests(),this.ua?this.ua.stop():this._uaEvents.trigger(u,void 0)):this._uaEvents.trigger(u,void 0),e});i(this,"_call",async({number:e,mediaStream:t,extraHeaders:n=[],ontrack:s,iceServers:o,videoMode:a,audioMode:c,degradationPreference:_,offerToReceiveAudio:E=!0,offerToReceiveVideo:h=!0})=>new Promise((d,l)=>{const{ua:T}=this;if(!T){l(new Error("this.ua is not initialized"));return}this._connectionConfiguration.number=e,this._connectionConfiguration.answer=!1,this._handleCall({ontrack:s}).then(d).catch(S=>{l(S)}),this.session=T.call(this.getSipServerUrl(e),{extraHeaders:n,mediaStream:k(t,{videoMode:a,audioMode:c}),eventHandlers:this._sessionEvents.triggers,videoMode:a,audioMode:c,degradationPreference:_,pcConfig:{iceServers:o},rtcOfferConstraints:{offerToReceiveAudio:E,offerToReceiveVideo:h}})}));i(this,"_answer",async({mediaStream:e,ontrack:t,extraHeaders:n=[],iceServers:s,videoMode:o,audioMode:a,degradationPreference:c})=>new Promise((_,E)=>{if(!this.isAvailableIncomingCall){E(new Error("no incomingSession"));return}this.session=this.incomingSession,this.removeIncomingSession();const{session:h}=this;if(!h){E(new Error("No session established"));return}this._sessionEvents.eachTriggers((l,T)=>{const S=fe.find(I=>I===T);S&&h.on(S,l)}),this._connectionConfiguration.answer=!0,this._connectionConfiguration.number=h.remote_identity.uri.user,this._handleCall({ontrack:t}).then(_).catch(l=>{E(l)});const d=k(e,{videoMode:o,audioMode:a});h.answer({extraHeaders:n,videoMode:o,audioMode:a,degradationPreference:c,mediaStream:d,pcConfig:{iceServers:s}})}));i(this,"_handleCall",async({ontrack:e})=>new Promise((t,n)=>{const s=()=>{this.onSession(U,h),this.onSession(w,d)},o=()=>{this.offSession(U,h),this.offSession(w,d)},a=()=>{this.onSession(g,_),this.onSession(D,_)},c=()=>{this.offSession(g,_),this.offSession(D,_)},_=l=>{o(),c(),n(l)};let E;const h=({peerconnection:l})=>{E=l,E.ontrack=T=>{this._sessionEvents.trigger(ne,E),e&&e(T)}},d=()=>{E&&this._sessionEvents.trigger(te,E),o(),c(),t(E)};s(),a()}));i(this,"_restoreSession",()=>{this._resetPresentation(),delete this._connectionConfiguration.number,delete this.session,this._remoteStreams={}});i(this,"_sendDTMF",async e=>new Promise((t,n)=>{const{session:s}=this;if(!s){n(new Error("No session established"));return}this.onceSession(Re,({originator:o})=>{o===B&&t()}),s.sendDTMF(e,{duration:120,interToneGap:600})}));i(this,"_hangUpWithoutCancelRequests",async()=>{if(this.ua&&this.session){const{session:e}=this;if(this._streamPresentationCurrent&&await this.stopPresentation(),this._restoreSession(),!e.isEnded())return e.terminateAsync()}});i(this,"_handleShareState",e=>{switch(e){case dt:{this._sessionEvents.trigger(Q,void 0);break}case Tt:{this._sessionEvents.trigger(K,void 0);break}case St:{this._sessionEvents.trigger(j,void 0);break}}});i(this,"_maybeTriggerChannels",e=>{const t=e.getHeader(ye),n=e.getHeader(we);if(t&&n){const s={inputChannels:t,outputChannels:n};this._sessionEvents.trigger(b,s)}});i(this,"_handleNotify",e=>{switch(e.cmd){case Yn:{const t=e;this._triggerChannelsNotify(t);break}case xn:{const t=e;this._triggerWebcastStartedNotify(t);break}case Gn:{const t=e;this._triggerWebcastStoppedNotify(t);break}case Jn:{const t=e;this._triggerAddedToListModeratorsNotify(t);break}case zn:{const t=e;this._triggerRemovedFromListModeratorsNotify(t);break}case Qn:{const t=e;this._triggerParticipationAcceptingWordRequest(t);break}case Kn:{const t=e;this._triggerParticipationCancellingWordRequest(t);break}case jn:{const t=e;this._triggerParticipantMoveRequestToStream(t);break}case $n:{this._triggerAccountChangedNotify();break}case Xn:{this._triggerAccountDeletedNotify();break}case Zn:{const t=e;this._triggerConferenceParticipantTokenIssued(t);break}default:F("unknown cmd",e.cmd)}});i(this,"_triggerRemovedFromListModeratorsNotify",({conference:e})=>{const t={conference:e};this._uaEvents.trigger(he,t)});i(this,"_triggerAddedToListModeratorsNotify",({conference:e})=>{const t={conference:e};this._uaEvents.trigger(_e,t)});i(this,"_triggerWebcastStartedNotify",({body:{conference:e,type:t}})=>{const n={conference:e,type:t};this._uaEvents.trigger(ue,n)});i(this,"_triggerWebcastStoppedNotify",({body:{conference:e,type:t}})=>{const n={conference:e,type:t};this._uaEvents.trigger(Ne,n)});i(this,"_triggerAccountChangedNotify",()=>{this._uaEvents.trigger(Ce,void 0)});i(this,"_triggerAccountDeletedNotify",()=>{this._uaEvents.trigger(ge,void 0)});i(this,"_triggerConferenceParticipantTokenIssued",({body:{conference:e,participant:t,jwt:n}})=>{const s={conference:e,participant:t,jwt:n};this._uaEvents.trigger(Ae,s)});i(this,"_triggerChannelsNotify",e=>{const t=e.input,n=e.output,s={inputChannels:t,outputChannels:n};this._uaEvents.trigger(se,s)});i(this,"_triggerParticipationAcceptingWordRequest",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(Te,t)});i(this,"_triggerParticipationCancellingWordRequest",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(Se,t)});i(this,"_triggerParticipantMoveRequestToStream",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(le,t)});i(this,"_triggerEnterRoom",e=>{const t=e.getHeader(zt),n=e.getHeader(sn);this._sessionEvents.trigger(Z,{room:t,participantName:n})});i(this,"_triggerShareState",e=>{const t=e.getHeader(R);this._sessionEvents.trigger(v,t)});i(this,"_maybeTriggerParticipantMoveRequestToSpectators",e=>{e.getHeader(dn)===_t&&this._sessionEvents.trigger(de,void 0)});i(this,"_triggerMainCamControl",e=>{const t=e.getHeader(rn),n=e.getHeader(Ue),s=n===q.ADMIN_SYNC_FORCED;if(t===A.ADMIN_START_MAIN_CAM){this._sessionEvents.trigger(ae,{isSyncForced:s});return}if(t===A.ADMIN_STOP_MAIN_CAM){this._sessionEvents.trigger(oe,{isSyncForced:s});return}(t===A.RESUME_MAIN_CAM||t===A.PAUSE_MAIN_CAM)&&n&&this._sessionEvents.trigger(y,{isSyncForced:s});const o=e.getHeader(an);this._sessionEvents.trigger(re,{mainCam:t,resolutionMainCam:o})});i(this,"_triggerMicControl",e=>{const t=e.getHeader(on),s=e.getHeader(Ue)===q.ADMIN_SYNC_FORCED;t===H.ADMIN_START_MIC?this._sessionEvents.trigger(Ee,{isSyncForced:s}):t===H.ADMIN_STOP_MIC&&this._sessionEvents.trigger(ce,{isSyncForced:s})});i(this,"_triggerUseLicense",e=>{const t=e.getHeader(nn);this._sessionEvents.trigger(ee,t)});i(this,"_handleNewInfo",e=>{const{originator:t}=e;if(t!=="remote")return;const{request:n}=e,s=n.getHeader(Jt);if(s)switch(s){case Qt:{this._triggerEnterRoom(n),this._maybeTriggerChannels(n);break}case Tn:{this._maybeHandleNotify(n);break}case P:{this._triggerShareState(n);break}case be:{this._triggerMainCamControl(n);break}case en:{this._triggerMicControl(n);break}case tn:{this._triggerUseLicense(n);break}case ln:{this._maybeTriggerParticipantMoveRequestToSpectators(n);break}}});i(this,"_handleSipEvent",({request:e})=>{this._maybeHandleNotify(e)});i(this,"_maybeHandleNotify",e=>{const t=e.getHeader(Sn);if(t){const n=JSON.parse(t);this._handleNotify(n)}});i(this,"_handleEnded",e=>{const{originator:t}=e;t===He&&this._sessionEvents.trigger(ie,e),this._restoreSession()});this.JsSIP=e,this._sessionEvents=new ve(De),this._uaEvents=new ve(pe),this._cancelableConnect=new N.CancelableRequest(this._connect,{moduleName:C,afterCancelRequest:()=>{this._cancelableInitUa.cancelRequest(),this._cancelableDisconnect.cancelRequest()}}),this._cancelableInitUa=new N.CancelableRequest(this._initUa,{moduleName:C}),this._cancelableDisconnect=new N.CancelableRequest(this._disconnect,{moduleName:C}),this._cancelableSet=new N.CancelableRequest(this._set,{moduleName:C}),this._cancelableCall=new N.CancelableRequest(this._call,{moduleName:C}),this._cancelableAnswer=new N.CancelableRequest(this._answer,{moduleName:C}),this._cancelableSendDTMF=new N.CancelableRequest(this._sendDTMF,{moduleName:C}),this.onSession(v,this._handleShareState),this.onSession(Ie,this._handleNewInfo),this.on(z,this._handleSipEvent),this.onSession(g,this._handleEnded),this.onSession(D,this._handleEnded)}async register(){return new Promise((e,t)=>{this.isRegisterConfig&&this.ua?(this.ua.on(f,e),this.ua.on(p,t),this.ua.register()):t(new Error("Config is not registered"))})}async unregister(){return new Promise((e,t)=>{this.isRegistered&&this.ua?(this.ua.on(J,e),this.ua.unregister()):t(new Error("ua is not registered"))})}async sendOptions(e,t,n){if(!this.ua)throw new Error("is not connected");return new Promise((s,o)=>{try{this.ua.sendOptions(e,t,{extraHeaders:n,eventHandlers:{succeeded:()=>{s()},failed:o}})}catch(a){o(a)}})}async ping(e,t){var s;if(!((s=this.ua)!=null&&s.configuration.uri))throw new Error("is not connected");const n=this.ua.configuration.uri;return this.sendOptions(n,e,t)}async checkTelephony({userAgent:e,displayName:t,sipServerUrl:n,sipWebSocketServerURL:s,sdpSemantics:o}){return new Promise((a,c)=>{const{configuration:_}=this.createUaConfiguration({sipWebSocketServerURL:s,displayName:t,sdpSemantics:o,userAgent:e,sipServerUrl:n}),E=this._createUa(_),h=()=>{const l=new Error("Telephony is not available");c(l)};E.once(u,h);const d=()=>{E.removeAllListeners(),E.once(u,a),E.stop()};E.once(O,d),E.start()})}async replaceMediaStream(e,t){if(!this.session)throw new Error("No session established");return this.session.replaceMediaStream(e,t)}async askPermissionToEnableCam(e={}){if(!this.session)throw new Error("No session established");const t=[In];return this.session.sendInfo(be,void 0,{noTerminateWhenError:!0,...e,extraHeaders:t}).catch(n=>{if(yn(n))throw n})}get isPendingPresentation(){return!!this.promisePendingStartPresentation||!!this.promisePendingStopPresentation}hasEqualConnectionConfiguration(e){var s;const{configuration:t}=this.createUaConfiguration(e),n=(s=this.ua)==null?void 0:s.configuration;return(n==null?void 0:n.password)===t.password&&(n==null?void 0:n.register)===t.register&&(n==null?void 0:n.uri.toString())===t.uri&&(n==null?void 0:n.display_name)===t.display_name&&(n==null?void 0:n.user_agent)===t.user_agent&&(n==null?void 0:n.sdpSemantics)===t.sdp_semantics&&(n==null?void 0:n.sockets)===t.sockets&&(n==null?void 0:n.session_timers)===t.session_timers&&(n==null?void 0:n.register_expires)===t.register_expires&&(n==null?void 0:n.connection_recovery_min_interval)===t.connection_recovery_min_interval&&(n==null?void 0:n.connection_recovery_max_interval)===t.connection_recovery_max_interval}createUaConfiguration({user:e,password:t,sipWebSocketServerURL:n,displayName:s="",sipServerUrl:o,register:a=!1,sdpSemantics:c="plan-b",sessionTimers:_=!1,registerExpires:E=60*5,connectionRecoveryMinInterval:h=2,connectionRecoveryMaxInterval:d=6,userAgent:l}){if(a&&!t)throw new Error("password is required for authorized connection");const T=a&&e?e.trim():`${Dn()}`,S=fn(o),I=S(T),m=new this.JsSIP.WebSocketInterface(n);return{configuration:{password:t,register:a,uri:I,display_name:Le(s),user_agent:l,sdp_semantics:c,sockets:[m],session_timers:_,register_expires:E,connection_recovery_min_interval:h,connection_recovery_max_interval:d},helpers:{socket:m,getSipServerUrl:S}}}async _sendPresentation(e,t,{maxBitrate:n,degradationPreference:s,isNeedReinvite:o=!0,isP2P:a=!1}){const c=k(t);this._streamPresentationCurrent=c;const _=a?[gn]:[un],E=e.sendInfo(P,void 0,{extraHeaders:_}).then(async()=>e.startPresentation(c,o,s)).then(async()=>{const{connection:h}=this;if(!h||n===void 0)return;const d=h.getSenders();await Wn(d,t,n)}).then(()=>t).catch(h=>{throw this._sessionEvents.trigger(L,h),h});return this.promisePendingStartPresentation=E,E.finally(()=>{this.promisePendingStartPresentation=void 0})}async startPresentation(e,{isNeedReinvite:t=!0,isP2P:n=!1,maxBitrate:s,degradationPreference:o}={}){const a=this.establishedSession;if(!a)throw new Error("No session established");if(this._streamPresentationCurrent)throw new Error("Presentation is already started");return n&&await this.sendMustStopPresentation(a),this._sendPresentation(a,e,{isNeedReinvite:t,isP2P:n,maxBitrate:s,degradationPreference:o})}async sendMustStopPresentation(e){await e.sendInfo(P,void 0,{extraHeaders:[Cn]})}async stopPresentation({isP2P:e=!1}={}){const t=this._streamPresentationCurrent;let n=this.promisePendingStartPresentation??Promise.resolve();const s=e?[An]:[Nn],o=this.establishedSession;return o&&t&&(n=n.then(async()=>o.sendInfo(P,void 0,{extraHeaders:s})).then(async()=>o.stopPresentation(t)).catch(a=>{throw this._sessionEvents.trigger(L,a),a})),!o&&t&&this._sessionEvents.trigger(me,t),this.promisePendingStopPresentation=n,n.finally(()=>{this._resetPresentation()})}async updatePresentation(e,{isP2P:t=!1,maxBitrate:n,degradationPreference:s}={}){const o=this.establishedSession;if(!o)throw new Error("No session established");if(!this._streamPresentationCurrent)throw new Error("Presentation has not started yet");return this.promisePendingStartPresentation&&await this.promisePendingStartPresentation,this._sendPresentation(o,e,{isP2P:t,maxBitrate:n,degradationPreference:s,isNeedReinvite:!1})}_resetPresentation(){delete this._streamPresentationCurrent,this.promisePendingStartPresentation=void 0,this.promisePendingStopPresentation=void 0}on(e,t){return this._uaEvents.on(e,t)}once(e,t){return this._uaEvents.once(e,t)}onceRace(e,t){return this._uaEvents.onceRace(e,t)}async wait(e){return this._uaEvents.wait(e)}off(e,t){this._uaEvents.off(e,t)}onSession(e,t){return this._sessionEvents.on(e,t)}onceSession(e,t){return this._sessionEvents.once(e,t)}onceRaceSession(e,t){return this._sessionEvents.onceRace(e,t)}async waitSession(e){return this._sessionEvents.wait(e)}offSession(e,t){this._sessionEvents.off(e,t)}isConfigured(){return!!this.ua}getConnectionConfiguration(){return{...this._connectionConfiguration}}getRemoteStreams(){if(!this.connection)return;const t=this.connection.getReceivers().map(({track:n})=>n);return Pn(t)?this._generateStreams(t):this._generateAudioStreams(t)}get connection(){var t;return(t=this.session)==null?void 0:t.connection}get remoteCallerData(){var e,t,n,s,o,a;return{displayName:(t=(e=this.incomingSession)==null?void 0:e.remote_identity)==null?void 0:t.display_name,host:(s=(n=this.incomingSession)==null?void 0:n.remote_identity)==null?void 0:s.uri.host,incomingNumber:(a=(o=this.incomingSession)==null?void 0:o.remote_identity)==null?void 0:a.uri.user,session:this.incomingSession}}get requested(){return this._cancelableConnect.requested||this._cancelableInitUa.requested||this._cancelableCall.requested||this._cancelableAnswer.requested}get establishedSession(){var e;return(e=this.session)!=null&&e.isEstablished()?this.session:void 0}get isRegistered(){return!!this.ua&&this.ua.isRegistered()}get isRegisterConfig(){return!!this.ua&&this._isRegisterConfig}get isCallActive(){return!!(this.ua&&this.session)}get isAvailableIncomingCall(){return!!this.incomingSession}_generateStream(e,t){const{id:n}=e,s=this._remoteStreams[n]||new MediaStream;return t&&s.addTrack(t),s.addTrack(e),this._remoteStreams[n]=s,s}_generateAudioStream(e){const{id:t}=e,n=this._remoteStreams[t]||new MediaStream;return n.addTrack(e),this._remoteStreams[t]=n,n}_generateStreams(e){const t=[];return e.forEach((n,s)=>{if(n.kind==="audio")return;const o=n,a=e[s-1];let c;a&&a.kind==="audio"&&(c=a);const _=this._generateStream(o,c);t.push(_)}),t}_generateAudioStreams(e){return e.map(n=>this._generateAudioStream(n))}_cancelRequests(){this._cancelActionsRequests(),this._cancelCallRequests(),this._cancelConnectWithRepeatedCalls()}_cancelConnectWithRepeatedCalls(){var e;(e=this._cancelableConnectWithRepeatedCalls)==null||e.cancel()}_cancelCallRequests(){this._cancelableCall.cancelRequest(),this._cancelableAnswer.cancelRequest()}_cancelActionsRequests(){this._cancelableAnswer.cancelRequest(),this._cancelableSendDTMF.cancelRequest()}async waitChannels(){return this.waitSession(b)}async waitSyncMediaState(){return this.waitSession(y)}async sendChannels({inputChannels:e,outputChannels:t}){if(!this.session)throw new Error("No session established");const n=`${ye}: ${e}`,s=`${we}: ${t}`,o=[n,s];return this.session.sendInfo(Kt,void 0,{extraHeaders:o})}async sendMediaState({cam:e,mic:t},n={}){if(!this.session)throw new Error("No session established");const s=`${cn}: currentstate`,o=`${_n}: ${Number(e)}`,a=`${hn}: ${Number(t)}`,c=[s,o,a];return this.session.sendInfo(jt,void 0,{noTerminateWhenError:!0,...n,extraHeaders:c})}async _sendRefusalToTurnOn(e,t={}){if(!this.session)throw new Error("No session established");const c=[`${En}: ${e==="mic"?0:1}`];return this.session.sendInfo(Zt,void 0,{noTerminateWhenError:!0,...t,extraHeaders:c})}async sendRefusalToTurnOnMic(e={}){if(!this.session)throw new Error("No session established");return this._sendRefusalToTurnOn("mic",{noTerminateWhenError:!0,...e})}async sendRefusalToTurnOnCam(e={}){if(!this.session)throw new Error("No session established");return this._sendRefusalToTurnOn("cam",{noTerminateWhenError:!0,...e})}}exports.BAD_MEDIA_DESCRIPTION=Be;exports.EEventsMainCAM=A;exports.EEventsMic=H;exports.EEventsSyncMediaState=q;exports.EUseLicense=ut;exports.NOT_FOUND=We;exports.REJECTED=Y;exports.SESSION_EVENT_NAMES=De;exports.SipConnector=es;exports.UA_EVENT_NAMES=pe;exports.causes=xt;exports.constants=Gt;exports.disableDebug=On;exports.enableDebug=mn;exports.eventNames=$t;exports.hasCanceledCallError=Vn;exports.logger=F;exports.setEncodingsToSender=gt;