sip-connector 14.0.0 → 14.1.0-alpha.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.
Files changed (130) hide show
  1. package/dist/SipConnector-CK3GgjXE.js +2492 -0
  2. package/dist/SipConnector-CwI8aFEA.cjs +1 -0
  3. package/dist/doMock.cjs +1 -1
  4. package/dist/doMock.js +439 -419
  5. package/dist/index.cjs +1 -1
  6. package/dist/index.js +708 -623
  7. package/dist/src/ApiManager/@ApiManager.d.ts +58 -0
  8. package/dist/src/ApiManager/constants.d.ts +71 -0
  9. package/dist/src/ApiManager/eventNames.d.ts +33 -0
  10. package/dist/src/ApiManager/index.d.ts +2 -0
  11. package/dist/src/ApiManager/types.d.ts +99 -0
  12. package/dist/src/CallManager/@CallManager.d.ts +26 -0
  13. package/dist/src/CallManager/AbstractCallStrategy.d.ts +47 -0
  14. package/dist/src/CallManager/MCUCallStrategy.d.ts +30 -0
  15. package/dist/src/CallManager/RemoteStreamsManager.d.ts +8 -0
  16. package/dist/src/CallManager/causes.d.ts +12 -0
  17. package/dist/src/CallManager/eventNames.d.ts +45 -0
  18. package/dist/src/CallManager/hasCanceledCallError.d.ts +2 -0
  19. package/dist/src/CallManager/index.d.ts +5 -0
  20. package/dist/src/CallManager/types.d.ts +59 -0
  21. package/dist/src/ConnectionManager/@ConnectionManager.d.ts +47 -0
  22. package/dist/src/ConnectionManager/ConfigurationManager.d.ts +60 -0
  23. package/dist/src/ConnectionManager/ConnectionFlow.d.ts +83 -0
  24. package/dist/src/ConnectionManager/ConnectionStateMachine.d.ts +61 -0
  25. package/dist/src/ConnectionManager/RegistrationManager.d.ts +17 -0
  26. package/dist/src/ConnectionManager/SipOperations.d.ts +32 -0
  27. package/dist/src/ConnectionManager/UAFactory.d.ts +50 -0
  28. package/dist/src/ConnectionManager/eventNames.d.ts +16 -0
  29. package/dist/src/ConnectionManager/index.d.ts +3 -0
  30. package/dist/src/IncomingCallManager/@IncomingCallManager.d.ts +36 -0
  31. package/dist/src/IncomingCallManager/eventNames.d.ts +13 -0
  32. package/dist/src/IncomingCallManager/index.d.ts +2 -0
  33. package/dist/src/PresentationManager/@PresentationManager.d.ts +47 -0
  34. package/dist/src/PresentationManager/constants.d.ts +1 -0
  35. package/dist/src/PresentationManager/eventNames.d.ts +11 -0
  36. package/dist/src/PresentationManager/index.d.ts +1 -0
  37. package/dist/src/PresentationManager/types.d.ts +2 -0
  38. package/dist/src/SipConnector.d.ts +107 -0
  39. package/dist/{SipConnectorFacade → src/SipConnectorFacade}/SipConnectorFacade.d.ts +34 -25
  40. package/dist/{__fixtures__ → src/__fixtures__}/BaseSession.mock.d.ts +23 -35
  41. package/dist/{__fixtures__ → src/__fixtures__}/RTCPeerConnectionMock.d.ts +15 -15
  42. package/dist/{__fixtures__ → src/__fixtures__}/RTCRtpSenderMock.d.ts +2 -2
  43. package/dist/src/__fixtures__/RTCSessionMock.d.ts +79 -0
  44. package/dist/src/__fixtures__/UA.mock.d.ts +82 -0
  45. package/dist/{__fixtures__ → src/__fixtures__}/channelsNotify.d.ts +2 -2
  46. package/dist/{__fixtures__ → src/__fixtures__}/index.d.ts +4 -4
  47. package/dist/{__fixtures__ → src/__fixtures__}/jssip.mock.d.ts +4 -4
  48. package/dist/{__fixtures__ → src/__fixtures__}/participantNotify.d.ts +2 -2
  49. package/dist/{constants.d.ts → src/constants.d.ts} +5 -0
  50. package/dist/{doMock.d.ts → src/doMock.d.ts} +1 -0
  51. package/dist/{index.d.ts → src/index.d.ts} +3 -1
  52. package/dist/{tools → src/tools}/__fixtures__/connectToServer.d.ts +2 -2
  53. package/dist/{tools → src/tools}/index.d.ts +2 -2
  54. package/dist/{tools/sendDTMFAccumulated.d.ts → src/tools/sendDtmfFAccumulated.d.ts} +2 -2
  55. package/dist/{types.d.ts → src/types.d.ts} +2 -1
  56. package/package.json +40 -37
  57. package/dist/SipConnector-Cc1z-VjV.js +0 -1335
  58. package/dist/SipConnector-K7IHfEEm.cjs +0 -1
  59. package/dist/SipConnector.d.ts +0 -314
  60. package/dist/__fixtures__/RTCSessionMock.d.ts +0 -78
  61. package/dist/__fixtures__/UA.mock.d.ts +0 -103
  62. package/dist/utils.d.ts +0 -4
  63. /package/dist/{SipConnectorFacade → src/SipConnectorFacade}/index.d.ts +0 -0
  64. /package/dist/{__fixtures__ → src/__fixtures__}/Registrator.mock.d.ts +0 -0
  65. /package/dist/{__fixtures__ → src/__fixtures__}/Request.mock.d.ts +0 -0
  66. /package/dist/{__fixtures__ → src/__fixtures__}/WebSocketInterface.mock.d.ts +0 -0
  67. /package/dist/{__fixtures__ → src/__fixtures__}/accountNotify.d.ts +0 -0
  68. /package/dist/{__fixtures__ → src/__fixtures__}/channels.d.ts +0 -0
  69. /package/dist/{__fixtures__ → src/__fixtures__}/conferenceParticipantTokenIssuedNotify.d.ts +0 -0
  70. /package/dist/{__fixtures__ → src/__fixtures__}/delayPromise.d.ts +0 -0
  71. /package/dist/{__fixtures__ → src/__fixtures__}/enterRoom.d.ts +0 -0
  72. /package/dist/{__fixtures__ → src/__fixtures__}/mediaState.d.ts +0 -0
  73. /package/dist/{__fixtures__ → src/__fixtures__}/participantMoveRequests.d.ts +0 -0
  74. /package/dist/{__fixtures__ → src/__fixtures__}/remoteCallerData.d.ts +0 -0
  75. /package/dist/{__fixtures__ → src/__fixtures__}/utils.d.ts +0 -0
  76. /package/dist/{__fixtures__ → src/__fixtures__}/webcastNotify.d.ts +0 -0
  77. /package/dist/{causes.d.ts → src/causes.d.ts} +0 -0
  78. /package/dist/{eventNames.d.ts → src/eventNames.d.ts} +0 -0
  79. /package/dist/{getExtraHeadersRemoteAddress.d.ts → src/getExtraHeadersRemoteAddress.d.ts} +0 -0
  80. /package/dist/{headers.d.ts → src/headers.d.ts} +0 -0
  81. /package/dist/{logger.d.ts → src/logger.d.ts} +0 -0
  82. /package/dist/{setParametersToSender → src/setParametersToSender}/configureDegradationPreference.d.ts +0 -0
  83. /package/dist/{setParametersToSender → src/setParametersToSender}/configureEmptyEncodings.d.ts +0 -0
  84. /package/dist/{setParametersToSender → src/setParametersToSender}/configureEncodings.d.ts +0 -0
  85. /package/dist/{setParametersToSender → src/setParametersToSender}/configureMaxBitrate.d.ts +0 -0
  86. /package/dist/{setParametersToSender → src/setParametersToSender}/configureScaleResolutionDownBy.d.ts +0 -0
  87. /package/dist/{setParametersToSender → src/setParametersToSender}/hasChangedRTCRtpSendParameters.d.ts +0 -0
  88. /package/dist/{setParametersToSender → src/setParametersToSender}/index.d.ts +0 -0
  89. /package/dist/{setParametersToSender → src/setParametersToSender}/resolveHasNeedToUpdateItemEncoding.d.ts +0 -0
  90. /package/dist/{setParametersToSender → src/setParametersToSender}/setParametersToSender.d.ts +0 -0
  91. /package/dist/{tools → src/tools}/__fixtures__/call.d.ts +0 -0
  92. /package/dist/{tools → src/tools}/__fixtures__/hasValidUri.d.ts +0 -0
  93. /package/dist/{tools → src/tools}/__fixtures__/permissions.d.ts +0 -0
  94. /package/dist/{tools → src/tools}/__fixtures__/processRequest.d.ts +0 -0
  95. /package/dist/{tools → src/tools}/__tests-utils__/parseObject.d.ts +0 -0
  96. /package/dist/{tools → src/tools}/__tests-utils__/resolveParseArray.d.ts +0 -0
  97. /package/dist/{tools → src/tools}/error/getLinkError.d.ts +0 -0
  98. /package/dist/{tools → src/tools}/error/getTypeFromError.d.ts +0 -0
  99. /package/dist/{tools → src/tools}/error/getValuesFromError.d.ts +0 -0
  100. /package/dist/{tools → src/tools}/error/index.d.ts +0 -0
  101. /package/dist/{tools → src/tools}/error/stringifyMessage.d.ts +0 -0
  102. /package/dist/{tools → src/tools}/generateSimulcastEncodings.d.ts +0 -0
  103. /package/dist/{tools → src/tools}/getExtraHeaders.d.ts +0 -0
  104. /package/dist/{tools → src/tools}/getUserAgent.d.ts +0 -0
  105. /package/dist/{tools → src/tools}/hasPurgatory.d.ts +0 -0
  106. /package/dist/{tools → src/tools}/prepareMediaStream.d.ts +0 -0
  107. /package/dist/{tools → src/tools}/resolveUpdateTransceiver.d.ts +0 -0
  108. /package/dist/{tools → src/tools}/setVideoTrackContentHints.d.ts +0 -0
  109. /package/dist/{tools → src/tools}/syncMediaState/index.d.ts +0 -0
  110. /package/dist/{tools → src/tools}/syncMediaState/resolveOnStartMainCam.d.ts +0 -0
  111. /package/dist/{tools → src/tools}/syncMediaState/resolveOnStartMic.d.ts +0 -0
  112. /package/dist/{tools → src/tools}/syncMediaState/resolveOnStopMainCam.d.ts +0 -0
  113. /package/dist/{tools → src/tools}/syncMediaState/resolveOnStopMic.d.ts +0 -0
  114. /package/dist/{utils → src/utils}/errors.d.ts +0 -0
  115. /package/dist/{utils → src/utils}/findSenderByStream.d.ts +0 -0
  116. /package/dist/{utils → src/utils}/findVideoSender.d.ts +0 -0
  117. /package/dist/{utils → src/utils}/findVideoTrack.d.ts +0 -0
  118. /package/dist/{utils → src/utils}/getCodecFromSender.d.ts +0 -0
  119. /package/dist/{utils → src/utils}/replaceForbiddenSymbolsWithUnderscore.d.ts +0 -0
  120. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/balance.d.ts +0 -0
  121. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/getMaxBitrateByWidth.d.ts +0 -0
  122. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/getMaxBitrateByWidthAndCodec.d.ts +0 -0
  123. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/hasAv1Codec.d.ts +0 -0
  124. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/hasIncludesString.d.ts +0 -0
  125. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/index.d.ts +0 -0
  126. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/processSender.d.ts +0 -0
  127. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/scaleBitrate.d.ts +0 -0
  128. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/scaleBitrateByCodec.d.ts +0 -0
  129. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/scaleResolutionAndBitrate.d.ts +0 -0
  130. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/setEncodingsToSender.d.ts +0 -0
@@ -0,0 +1,2492 @@
1
+ import D from "events-constructor";
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
+ };
202
+ 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 = [
204
+ "peerconnection",
205
+ "connecting",
206
+ "sending",
207
+ "progress",
208
+ "accepted",
209
+ "confirmed",
210
+ "ended",
211
+ "failed",
212
+ "newInfo",
213
+ "newDTMF",
214
+ "presentation:start",
215
+ "presentation:started",
216
+ "presentation:end",
217
+ "presentation:ended",
218
+ "presentation:failed",
219
+ "reinvite",
220
+ "update",
221
+ "refer",
222
+ "replaces",
223
+ "sdp",
224
+ "icecandidate",
225
+ "getusermediafailed",
226
+ "peerconnection:createofferfailed",
227
+ "peerconnection:createanswerfailed",
228
+ "peerconnection:setlocaldescriptionfailed",
229
+ "peerconnection:setremotedescriptionfailed"
230
+ ], qt = [
231
+ "peerconnection:confirmed",
232
+ "peerconnection:ontrack",
233
+ "ended:fromserver"
234
+ ], xt = [
235
+ ...Tt,
236
+ ...qt
237
+ ];
238
+ function Qt(n) {
239
+ return (e) => `sip:${e}@${n}`;
240
+ }
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) => {
242
+ const { kind: s } = t;
243
+ return s === "video";
244
+ }), jt = (n, e) => {
245
+ n.getVideoTracks().forEach((s) => {
246
+ "contentHint" in s && s.contentHint !== e && (s.contentHint = e);
247
+ });
248
+ }, v = (n, {
249
+ directionVideo: e,
250
+ directionAudio: t,
251
+ contentHint: s
252
+ } = {}) => {
253
+ if (!n || e === "recvonly" && t === "recvonly")
254
+ return;
255
+ 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;
257
+ };
258
+ class Kt {
259
+ isPendingCall = !1;
260
+ isPendingAnswer = !1;
261
+ rtcSession;
262
+ remoteStreams = {};
263
+ events;
264
+ callConfiguration = {};
265
+ constructor(e) {
266
+ this.events = e;
267
+ }
268
+ }
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 {
271
+ remoteStreams = {};
272
+ reset() {
273
+ this.remoteStreams = {};
274
+ }
275
+ generateStream(e, t) {
276
+ const { id: s } = e, i = this.remoteStreams[s] ?? new MediaStream();
277
+ return t && i.addTrack(t), i.addTrack(e), this.remoteStreams[s] = i, i;
278
+ }
279
+ generateAudioStream(e) {
280
+ const { id: t } = e, s = this.remoteStreams[t] ?? new MediaStream();
281
+ return s.addTrack(e), this.remoteStreams[t] = s, s;
282
+ }
283
+ generateStreams(e) {
284
+ const t = [];
285
+ return e.forEach((s, i) => {
286
+ if (s.kind === "audio")
287
+ return;
288
+ const r = s, a = e[i - 1];
289
+ let o;
290
+ a?.kind === "audio" && (o = a);
291
+ const c = this.generateStream(r, o);
292
+ t.push(c);
293
+ }), t;
294
+ }
295
+ generateAudioStreams(e) {
296
+ return e.map((t) => this.generateAudioStream(t));
297
+ }
298
+ }
299
+ class en extends Kt {
300
+ remoteStreamsManager = new Zt();
301
+ disposers = /* @__PURE__ */ new Set();
302
+ constructor(e) {
303
+ super(e), e.on(N.FAILED, this.handleEnded), e.on(N.ENDED, this.handleEnded);
304
+ }
305
+ get requested() {
306
+ return this.isPendingCall || this.isPendingAnswer;
307
+ }
308
+ get connection() {
309
+ return this.rtcSession?.connection;
310
+ }
311
+ get isCallActive() {
312
+ return this.rtcSession?.isEstablished() === !0;
313
+ }
314
+ get establishedRTCSession() {
315
+ return this.rtcSession?.isEstablished() === !0 ? this.rtcSession : void 0;
316
+ }
317
+ startCall = async (e, t, {
318
+ number: s,
319
+ mediaStream: i,
320
+ extraHeaders: r = [],
321
+ ontrack: a,
322
+ iceServers: o,
323
+ directionVideo: c,
324
+ directionAudio: T,
325
+ contentHint: S,
326
+ offerToReceiveAudio: l = !0,
327
+ offerToReceiveVideo: d = !0,
328
+ sendEncodings: h,
329
+ onAddedTransceiver: I
330
+ }) => (this.isPendingCall = !0, new Promise((C, O) => {
331
+ this.callConfiguration.number = s, this.callConfiguration.answer = !1, this.handleCall({ ontrack: a }).then(C).catch((b) => {
332
+ O(b);
333
+ }), this.rtcSession = e.call(t(s), {
334
+ extraHeaders: r,
335
+ mediaStream: v(i, {
336
+ directionVideo: c,
337
+ directionAudio: T,
338
+ contentHint: S
339
+ }),
340
+ directionVideo: c,
341
+ directionAudio: T,
342
+ pcConfig: {
343
+ iceServers: o
344
+ },
345
+ rtcOfferConstraints: {
346
+ offerToReceiveAudio: l,
347
+ offerToReceiveVideo: d
348
+ },
349
+ sendEncodings: h,
350
+ onAddedTransceiver: I
351
+ }), this.subscribeToSessionEvents(this.rtcSession);
352
+ }).finally(() => {
353
+ this.isPendingCall = !1;
354
+ }));
355
+ async endCall() {
356
+ const { rtcSession: e } = this;
357
+ if (e && !e.isEnded())
358
+ return e.terminateAsync({
359
+ cause: gt.CANCELED
360
+ }).finally(() => {
361
+ this.reset();
362
+ });
363
+ this.reset();
364
+ }
365
+ answerToIncomingCall = async (e, {
366
+ mediaStream: t,
367
+ ontrack: s,
368
+ extraHeaders: i = [],
369
+ iceServers: r,
370
+ directionVideo: a,
371
+ directionAudio: o,
372
+ offerToReceiveAudio: c,
373
+ offerToReceiveVideo: T,
374
+ contentHint: S,
375
+ sendEncodings: l,
376
+ onAddedTransceiver: d
377
+ }) => (this.isPendingAnswer = !0, new Promise((h, I) => {
378
+ try {
379
+ 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) => {
381
+ I(b);
382
+ });
383
+ const O = v(t, {
384
+ directionVideo: a,
385
+ directionAudio: o,
386
+ contentHint: S
387
+ });
388
+ C.answer({
389
+ extraHeaders: i,
390
+ directionVideo: a,
391
+ directionAudio: o,
392
+ mediaStream: O,
393
+ pcConfig: {
394
+ iceServers: r
395
+ },
396
+ rtcOfferConstraints: {
397
+ offerToReceiveAudio: c,
398
+ offerToReceiveVideo: T
399
+ },
400
+ sendEncodings: l,
401
+ onAddedTransceiver: d
402
+ });
403
+ } catch (C) {
404
+ I(C);
405
+ }
406
+ }).finally(() => {
407
+ this.isPendingAnswer = !1;
408
+ }));
409
+ getEstablishedRTCSession() {
410
+ return this.rtcSession?.isEstablished() === !0 ? this.rtcSession : void 0;
411
+ }
412
+ getCallConfiguration() {
413
+ return { ...this.callConfiguration };
414
+ }
415
+ getRemoteStreams() {
416
+ if (!this.connection)
417
+ return;
418
+ const t = this.connection.getReceivers().map(({ track: s }) => s);
419
+ return Xt(t) ? this.remoteStreamsManager.generateStreams(t) : this.remoteStreamsManager.generateAudioStreams(t);
420
+ }
421
+ async replaceMediaStream(e, t) {
422
+ if (!this.rtcSession)
423
+ throw new Error("No rtcSession established");
424
+ const { contentHint: s } = t ?? {}, i = v(e, { contentHint: s });
425
+ if (i === void 0)
426
+ throw new Error("No preparedMediaStream");
427
+ return this.rtcSession.replaceMediaStream(i, t);
428
+ }
429
+ handleCall = async ({
430
+ ontrack: e
431
+ }) => new Promise((t, s) => {
432
+ const i = () => {
433
+ this.events.on(N.PEER_CONNECTION, S), this.events.on(N.CONFIRMED, l);
434
+ }, r = () => {
435
+ this.events.off(N.PEER_CONNECTION, S), this.events.off(N.CONFIRMED, l);
436
+ }, a = () => {
437
+ this.events.on(N.FAILED, c), this.events.on(N.ENDED, c);
438
+ }, o = () => {
439
+ this.events.off(N.FAILED, c), this.events.off(N.ENDED, c);
440
+ }, c = (d) => {
441
+ r(), o(), s(d);
442
+ };
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);
448
+ };
449
+ d.addEventListener("track", h), this.disposers.add(() => {
450
+ d.removeEventListener("track", h);
451
+ });
452
+ }, l = () => {
453
+ T !== void 0 && this.events.trigger(N.PEER_CONNECTION_CONFIRMED, T), r(), o(), t(T);
454
+ };
455
+ i(), a();
456
+ });
457
+ subscribeToSessionEvents(e) {
458
+ this.events.eachTriggers((t, s) => {
459
+ const i = Tt.find((r) => r === s);
460
+ i && (e.on(i, t), this.disposers.add(() => {
461
+ e.off(i, t);
462
+ }));
463
+ });
464
+ }
465
+ unsubscribeFromSessionEvents() {
466
+ this.disposers.forEach((e) => {
467
+ e();
468
+ }), this.disposers.clear();
469
+ }
470
+ handleEnded = (e) => {
471
+ const { originator: t } = e;
472
+ t === U.REMOTE && this.events.trigger(N.ENDED_FROM_SERVER, e), this.reset();
473
+ };
474
+ reset = () => {
475
+ delete this.rtcSession, this.remoteStreamsManager.reset(), this.unsubscribeFromSessionEvents(), this.callConfiguration.number = void 0, this.callConfiguration.answer = !1;
476
+ };
477
+ }
478
+ class tn {
479
+ events;
480
+ strategy;
481
+ constructor(e) {
482
+ this.events = new D(xt), this.strategy = e ?? new en(this.events);
483
+ }
484
+ get requested() {
485
+ return this.strategy.requested;
486
+ }
487
+ get connection() {
488
+ return this.strategy.connection;
489
+ }
490
+ get establishedRTCSession() {
491
+ return this.strategy.establishedRTCSession;
492
+ }
493
+ get isCallActive() {
494
+ return this.strategy.isCallActive;
495
+ }
496
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
497
+ on(e, t) {
498
+ return this.events.on(e, t);
499
+ }
500
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
501
+ once(e, t) {
502
+ return this.events.once(e, t);
503
+ }
504
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
505
+ onceRace(e, t) {
506
+ return this.events.onceRace(e, t);
507
+ }
508
+ async wait(e) {
509
+ return this.events.wait(e);
510
+ }
511
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
512
+ off(e, t) {
513
+ this.events.off(e, t);
514
+ }
515
+ setStrategy(e) {
516
+ this.strategy = e;
517
+ }
518
+ startCall = async (...e) => this.strategy.startCall(...e);
519
+ endCall = async () => this.strategy.endCall();
520
+ answerToIncomingCall = async (...e) => this.strategy.answerToIncomingCall(...e);
521
+ getEstablishedRTCSession = () => this.strategy.getEstablishedRTCSession();
522
+ getCallConfiguration = () => this.strategy.getCallConfiguration();
523
+ getRemoteStreams = () => this.strategy.getRemoteStreams();
524
+ replaceMediaStream = async (...e) => this.strategy.replaceMediaStream(...e);
525
+ }
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 = [
699
+ "participation:accepting-word-request",
700
+ "participation:cancelling-word-request",
701
+ "participant:move-request-to-stream",
702
+ "channels:notify",
703
+ "conference:participant-token-issued",
704
+ "account:changed",
705
+ "account:deleted",
706
+ "webcast:started",
707
+ "webcast:stopped",
708
+ "participant:added-to-list-moderators",
709
+ "participant:removed-from-list-moderators",
710
+ "participant:move-request-to-spectators",
711
+ "participant:move-request-to-participants",
712
+ "channels",
713
+ "enterRoom",
714
+ "shareState",
715
+ "main-cam-control",
716
+ "useLicense",
717
+ "admin-start-main-cam",
718
+ "admin-stop-main-cam",
719
+ "admin-start-mic",
720
+ "admin-stop-mic",
721
+ "admin-force-sync-media-state",
722
+ "availableSecondRemoteStream",
723
+ "notAvailableSecondRemoteStream",
724
+ "mustStopPresentation",
725
+ "newDTMF"
726
+ ];
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 {
729
+ events;
730
+ connectionManager;
731
+ callManager;
732
+ constructor({
733
+ connectionManager: e,
734
+ callManager: t
735
+ }) {
736
+ this.connectionManager = e, this.callManager = t, this.events = new D(En), this.subscribe();
737
+ }
738
+ async waitChannels() {
739
+ return this.wait(E.CHANNELS);
740
+ }
741
+ async waitSyncMediaState() {
742
+ return this.wait(E.ADMIN_FORCE_SYNC_MEDIA_STATE);
743
+ }
744
+ async sendDTMF(e) {
745
+ return new Promise((t, s) => {
746
+ const i = this.callManager.getEstablishedRTCSession();
747
+ if (!i) {
748
+ s(new Error("No rtcSession established"));
749
+ return;
750
+ }
751
+ this.callManager.once("newDTMF", ({ originator: r }) => {
752
+ r === U.LOCAL && t();
753
+ }), i.sendDTMF(e, {
754
+ duration: 120,
755
+ interToneGap: 600
756
+ });
757
+ });
758
+ }
759
+ async sendChannels({ inputChannels: e, outputChannels: t }) {
760
+ const s = this.callManager.getEstablishedRTCSession();
761
+ if (!s)
762
+ throw new Error("No rtcSession established");
763
+ const i = `${g.INPUT_CHANNELS}: ${e}`, r = `${g.OUTPUT_CHANNELS}: ${t}`, a = [
764
+ i,
765
+ r
766
+ ];
767
+ return s.sendInfo(u.CHANNELS, void 0, { extraHeaders: a });
768
+ }
769
+ async sendMediaState({ cam: e, mic: t }, s = {}) {
770
+ const i = this.callManager.getEstablishedRTCSession();
771
+ if (!i)
772
+ 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 = [
774
+ r,
775
+ a,
776
+ o
777
+ ];
778
+ return i.sendInfo(u.MEDIA_STATE, void 0, {
779
+ noTerminateWhenError: !0,
780
+ ...s,
781
+ extraHeaders: c
782
+ });
783
+ }
784
+ async sendRefusalToTurnOn(e, t = {}) {
785
+ const s = this.callManager.getEstablishedRTCSession();
786
+ if (!s)
787
+ 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, {
790
+ noTerminateWhenError: !0,
791
+ ...t,
792
+ extraHeaders: c
793
+ });
794
+ }
795
+ async sendRefusalToTurnOnMic(e = {}) {
796
+ if (!this.callManager.getEstablishedRTCSession())
797
+ throw new Error("No rtcSession established");
798
+ return this.sendRefusalToTurnOn("mic", { noTerminateWhenError: !0, ...e });
799
+ }
800
+ async sendRefusalToTurnOnCam(e = {}) {
801
+ if (!this.callManager.getEstablishedRTCSession())
802
+ throw new Error("No rtcSession established");
803
+ return this.sendRefusalToTurnOn("cam", { noTerminateWhenError: !0, ...e });
804
+ }
805
+ async sendMustStopPresentationP2P() {
806
+ const e = this.callManager.getEstablishedRTCSession();
807
+ if (!e)
808
+ throw new Error("No rtcSession established");
809
+ await e.sendInfo(u.SHARE_STATE, void 0, {
810
+ extraHeaders: [g.MUST_STOP_PRESENTATION_P2P]
811
+ });
812
+ }
813
+ async sendStoppedPresentationP2P() {
814
+ const e = this.callManager.getEstablishedRTCSession();
815
+ if (!e)
816
+ throw new Error("No rtcSession established");
817
+ await e.sendInfo(u.SHARE_STATE, void 0, {
818
+ extraHeaders: [g.STOP_PRESENTATION_P2P]
819
+ });
820
+ }
821
+ async sendStoppedPresentation() {
822
+ const e = this.callManager.getEstablishedRTCSession();
823
+ if (!e)
824
+ throw new Error("No rtcSession established");
825
+ await e.sendInfo(u.SHARE_STATE, void 0, {
826
+ extraHeaders: [g.STOP_PRESENTATION]
827
+ });
828
+ }
829
+ async askPermissionToStartPresentationP2P() {
830
+ const e = this.callManager.getEstablishedRTCSession();
831
+ if (!e)
832
+ throw new Error("No rtcSession established");
833
+ await e.sendInfo(u.SHARE_STATE, void 0, {
834
+ extraHeaders: [g.START_PRESENTATION_P2P]
835
+ });
836
+ }
837
+ async askPermissionToStartPresentation() {
838
+ const e = this.callManager.getEstablishedRTCSession();
839
+ if (!e)
840
+ throw new Error("No rtcSession established");
841
+ await e.sendInfo(u.SHARE_STATE, void 0, {
842
+ extraHeaders: [g.START_PRESENTATION]
843
+ });
844
+ }
845
+ async askPermissionToEnableCam(e = {}) {
846
+ const t = this.callManager.getEstablishedRTCSession();
847
+ if (!t)
848
+ throw new Error("No rtcSession established");
849
+ const s = [g.ENABLE_MAIN_CAM];
850
+ return t.sendInfo(u.MAIN_CAM, void 0, {
851
+ noTerminateWhenError: !0,
852
+ ...e,
853
+ extraHeaders: s
854
+ }).catch((i) => {
855
+ if (Tn(i))
856
+ throw i;
857
+ });
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.connectionManager.on("sipEvent", this.handleSipEvent), this.callManager.on("newInfo", this.handleNewInfo), this.callManager.on("newDTMF", (e) => {
880
+ this.events.trigger("newDTMF", e);
881
+ });
882
+ }
883
+ handleSipEvent = ({ request: e }) => {
884
+ this.maybeHandleNotify(e);
885
+ };
886
+ maybeHandleNotify = (e) => {
887
+ try {
888
+ const t = e.getHeader(g.NOTIFY);
889
+ if (t) {
890
+ const s = JSON.parse(t);
891
+ this.handleNotify(s);
892
+ }
893
+ } catch (t) {
894
+ P("error parse notify", t);
895
+ }
896
+ };
897
+ handleNotify = (e) => {
898
+ switch (e.cmd) {
899
+ case _.CHANNELS: {
900
+ const t = e;
901
+ this.triggerChannelsNotify(t);
902
+ break;
903
+ }
904
+ case _.WEBCAST_STARTED: {
905
+ const t = e;
906
+ this.triggerWebcastStartedNotify(t);
907
+ break;
908
+ }
909
+ case _.WEBCAST_STOPPED: {
910
+ const t = e;
911
+ this.triggerWebcastStoppedNotify(t);
912
+ break;
913
+ }
914
+ case _.ADDED_TO_LIST_MODERATORS: {
915
+ const t = e;
916
+ this.triggerAddedToListModeratorsNotify(t);
917
+ break;
918
+ }
919
+ case _.REMOVED_FROM_LIST_MODERATORS: {
920
+ const t = e;
921
+ this.triggerRemovedFromListModeratorsNotify(t);
922
+ break;
923
+ }
924
+ case _.ACCEPTING_WORD_REQUEST: {
925
+ const t = e;
926
+ this.triggerParticipationAcceptingWordRequest(t);
927
+ break;
928
+ }
929
+ case _.CANCELLING_WORD_REQUEST: {
930
+ const t = e;
931
+ this.triggerParticipationCancellingWordRequest(t);
932
+ break;
933
+ }
934
+ case _.MOVE_REQUEST_TO_STREAM: {
935
+ const t = e;
936
+ this.triggerParticipantMoveRequestToStream(t);
937
+ break;
938
+ }
939
+ case _.ACCOUNT_CHANGED: {
940
+ this.triggerAccountChangedNotify();
941
+ break;
942
+ }
943
+ case _.ACCOUNT_DELETED: {
944
+ this.triggerAccountDeletedNotify();
945
+ break;
946
+ }
947
+ case _.CONFERENCE_PARTICIPANT_TOKEN_ISSUED: {
948
+ const t = e;
949
+ this.triggerConferenceParticipantTokenIssued(t);
950
+ break;
951
+ }
952
+ default:
953
+ P("unknown cmd", e);
954
+ }
955
+ };
956
+ handleNewInfo = (e) => {
957
+ const { originator: t } = e;
958
+ if (t !== U.REMOTE)
959
+ return;
960
+ const { request: s } = e, i = s.getHeader(g.CONTENT_TYPE_NAME);
961
+ if (i !== void 0)
962
+ switch (i) {
963
+ case M.ENTER_ROOM: {
964
+ this.triggerEnterRoom(s), this.maybeTriggerChannels(s);
965
+ break;
966
+ }
967
+ case M.NOTIFY: {
968
+ this.maybeHandleNotify(s);
969
+ break;
970
+ }
971
+ case M.SHARE_STATE: {
972
+ this.triggerShareState(s);
973
+ break;
974
+ }
975
+ case M.MAIN_CAM: {
976
+ this.triggerMainCamControl(s);
977
+ break;
978
+ }
979
+ case M.MIC: {
980
+ this.triggerMicControl(s);
981
+ break;
982
+ }
983
+ case M.USE_LICENSE: {
984
+ this.triggerUseLicense(s);
985
+ break;
986
+ }
987
+ case M.PARTICIPANT_STATE: {
988
+ this.maybeTriggerParticipantMoveRequest(s);
989
+ break;
990
+ }
991
+ }
992
+ };
993
+ triggerChannelsNotify = (e) => {
994
+ const t = e.input, s = e.output, i = {
995
+ inputChannels: t,
996
+ outputChannels: s
997
+ };
998
+ this.events.trigger(E.CHANNELS_NOTIFY, i);
999
+ };
1000
+ triggerWebcastStartedNotify = ({
1001
+ body: { conference: e, type: t }
1002
+ }) => {
1003
+ const s = {
1004
+ conference: e,
1005
+ type: t
1006
+ };
1007
+ this.events.trigger(E.WEBCAST_STARTED, s);
1008
+ };
1009
+ triggerWebcastStoppedNotify = ({
1010
+ body: { conference: e, type: t }
1011
+ }) => {
1012
+ const s = {
1013
+ conference: e,
1014
+ type: t
1015
+ };
1016
+ this.events.trigger(E.WEBCAST_STOPPED, s);
1017
+ };
1018
+ triggerAddedToListModeratorsNotify = ({
1019
+ conference: e
1020
+ }) => {
1021
+ const t = {
1022
+ conference: e
1023
+ };
1024
+ this.events.trigger(
1025
+ E.PARTICIPANT_ADDED_TO_LIST_MODERATORS,
1026
+ t
1027
+ );
1028
+ };
1029
+ triggerRemovedFromListModeratorsNotify = ({
1030
+ conference: e
1031
+ }) => {
1032
+ const t = {
1033
+ conference: e
1034
+ };
1035
+ this.events.trigger(
1036
+ E.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS,
1037
+ t
1038
+ );
1039
+ };
1040
+ triggerParticipationAcceptingWordRequest = ({
1041
+ body: { conference: e }
1042
+ }) => {
1043
+ const t = {
1044
+ conference: e
1045
+ };
1046
+ this.events.trigger(E.PARTICIPATION_ACCEPTING_WORD_REQUEST, t);
1047
+ };
1048
+ triggerParticipationCancellingWordRequest = ({
1049
+ body: { conference: e }
1050
+ }) => {
1051
+ const t = {
1052
+ conference: e
1053
+ };
1054
+ this.events.trigger(E.PARTICIPATION_CANCELLING_WORD_REQUEST, t);
1055
+ };
1056
+ triggerParticipantMoveRequestToStream = ({
1057
+ body: { conference: e }
1058
+ }) => {
1059
+ const t = {
1060
+ conference: e
1061
+ };
1062
+ this.events.trigger(E.PARTICIPANT_MOVE_REQUEST_TO_STREAM, t);
1063
+ };
1064
+ triggerAccountChangedNotify = () => {
1065
+ this.events.trigger(E.ACCOUNT_CHANGED, void 0);
1066
+ };
1067
+ triggerAccountDeletedNotify = () => {
1068
+ this.events.trigger(E.ACCOUNT_DELETED, void 0);
1069
+ };
1070
+ triggerConferenceParticipantTokenIssued = ({
1071
+ body: { conference: e, participant: t, jwt: s }
1072
+ }) => {
1073
+ const i = {
1074
+ conference: e,
1075
+ participant: t,
1076
+ jwt: s
1077
+ };
1078
+ this.events.trigger(
1079
+ E.CONFERENCE_PARTICIPANT_TOKEN_ISSUED,
1080
+ i
1081
+ );
1082
+ };
1083
+ maybeTriggerChannels = (e) => {
1084
+ const t = e.getHeader(g.INPUT_CHANNELS), s = e.getHeader(g.OUTPUT_CHANNELS);
1085
+ if (t && s) {
1086
+ const i = {
1087
+ inputChannels: t,
1088
+ outputChannels: s
1089
+ };
1090
+ this.events.trigger(E.CHANNELS, i);
1091
+ }
1092
+ };
1093
+ 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 });
1096
+ };
1097
+ triggerShareState = (e) => {
1098
+ const t = e.getHeader(g.CONTENT_SHARE_STATE);
1099
+ if (t !== void 0)
1100
+ switch (t) {
1101
+ case y.AVAILABLE_SECOND_REMOTE_STREAM: {
1102
+ this.events.trigger(E.AVAILABLE_SECOND_REMOTE_STREAM, void 0);
1103
+ break;
1104
+ }
1105
+ case y.NOT_AVAILABLE_SECOND_REMOTE_STREAM: {
1106
+ this.events.trigger(E.NOT_AVAILABLE_SECOND_REMOTE_STREAM, void 0);
1107
+ break;
1108
+ }
1109
+ case y.MUST_STOP_PRESENTATION: {
1110
+ this.events.trigger(E.MUST_STOP_PRESENTATION, void 0);
1111
+ break;
1112
+ }
1113
+ }
1114
+ };
1115
+ 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);
1118
+ };
1119
+ 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 });
1123
+ return;
1124
+ }
1125
+ if (t === m.ADMIN_STOP_MAIN_CAM) {
1126
+ this.events.trigger(E.ADMIN_STOP_MAIN_CAM, { isSyncForced: i });
1127
+ return;
1128
+ }
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, {
1132
+ mainCam: t,
1133
+ resolutionMainCam: r
1134
+ });
1135
+ };
1136
+ 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 });
1139
+ };
1140
+ triggerUseLicense = (e) => {
1141
+ const t = e.getHeader(g.CONTENT_USE_LICENSE);
1142
+ this.events.trigger(E.USE_LICENSE, t);
1143
+ };
1144
+ }
1145
+ class Sn {
1146
+ data = {};
1147
+ getUa;
1148
+ constructor(e) {
1149
+ this.getUa = e.getUa;
1150
+ }
1151
+ /**
1152
+ * Проверяет, настроено ли соединение
1153
+ */
1154
+ isConfigured() {
1155
+ return this.getUa() !== void 0;
1156
+ }
1157
+ /**
1158
+ * Получает текущую конфигурацию подключения
1159
+ */
1160
+ get() {
1161
+ return { ...this.data };
1162
+ }
1163
+ /**
1164
+ * Устанавливает конфигурацию подключения
1165
+ */
1166
+ set(e) {
1167
+ this.data = { ...e };
1168
+ }
1169
+ /**
1170
+ * Обновляет конфигурацию подключения
1171
+ */
1172
+ update(e, t) {
1173
+ this.data[e] = t;
1174
+ }
1175
+ /**
1176
+ * Очищает конфигурацию
1177
+ */
1178
+ clear() {
1179
+ this.data = {};
1180
+ }
1181
+ /**
1182
+ * Проверяет, включена ли регистрация в конфигурации
1183
+ */
1184
+ isRegister() {
1185
+ return this.data.register === !0;
1186
+ }
1187
+ /**
1188
+ * Получает SIP сервер URL из конфигурации
1189
+ */
1190
+ getSipServerUrl() {
1191
+ return this.data.sipServerUrl;
1192
+ }
1193
+ /**
1194
+ * Получает display name из конфигурации
1195
+ */
1196
+ getDisplayName() {
1197
+ return this.data.displayName;
1198
+ }
1199
+ /**
1200
+ * Получает пользователя из конфигурации
1201
+ */
1202
+ getUser() {
1203
+ return this.data.user;
1204
+ }
1205
+ /**
1206
+ * Получает пароль из конфигурации
1207
+ */
1208
+ getPassword() {
1209
+ return this.data.password;
1210
+ }
1211
+ /**
1212
+ * Проверяет, включена ли регистрация
1213
+ */
1214
+ isRegisterEnabled() {
1215
+ return this.data.register === !0;
1216
+ }
1217
+ }
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 = [
1220
+ "connecting",
1221
+ "connected",
1222
+ "disconnected",
1223
+ "newRTCSession",
1224
+ "registered",
1225
+ "unregistered",
1226
+ "registrationFailed",
1227
+ "newMessage",
1228
+ "sipEvent"
1229
+ ], dn = [...St], hn = 3;
1230
+ class ln {
1231
+ cancelableConnectWithRepeatedCalls;
1232
+ JsSIP;
1233
+ events;
1234
+ uaFactory;
1235
+ stateMachine;
1236
+ registrationManager;
1237
+ getUa;
1238
+ setUa;
1239
+ getConnectionConfiguration;
1240
+ setConnectionConfiguration;
1241
+ updateConnectionConfiguration;
1242
+ setSipServerUrl;
1243
+ setSocket;
1244
+ constructor(e) {
1245
+ this.JsSIP = e.JsSIP, this.events = e.events, this.uaFactory = e.uaFactory, this.stateMachine = e.stateMachine, this.registrationManager = e.registrationManager, this.getUa = e.getUa, this.setUa = e.setUa, this.getConnectionConfiguration = e.getConnectionConfiguration, this.setConnectionConfiguration = e.setConnectionConfiguration, this.updateConnectionConfiguration = e.updateConnectionConfiguration, this.setSipServerUrl = e.setSipServerUrl, this.setSocket = e.setSocket;
1246
+ }
1247
+ connect = async (e, t) => (this.cancelRequests(), this.connectWithDuplicatedCalls(e, t));
1248
+ set = async ({ displayName: e }) => new Promise((t, s) => {
1249
+ const i = this.getUa();
1250
+ if (!i) {
1251
+ s(new Error("this.ua is not initialized"));
1252
+ return;
1253
+ }
1254
+ let r = !1;
1255
+ const a = this.getConnectionConfiguration();
1256
+ e !== void 0 && e !== a.displayName && (r = i.set("display_name", Et(e)), this.updateConnectionConfiguration("displayName", e));
1257
+ const o = r;
1258
+ o ? t(o) : s(new Error("nothing changed"));
1259
+ });
1260
+ disconnect = async () => {
1261
+ const e = new Promise((s) => {
1262
+ this.events.once(A.DISCONNECTED, () => {
1263
+ s();
1264
+ });
1265
+ }), t = this.getUa();
1266
+ return t ? t.stop() : this.events.trigger(A.DISCONNECTED, void 0), e.finally(() => {
1267
+ this.setUa(void 0), this.stateMachine.reset();
1268
+ });
1269
+ };
1270
+ cancelRequests() {
1271
+ this.cancelConnectWithRepeatedCalls();
1272
+ }
1273
+ connectWithDuplicatedCalls = async (e, { callLimit: t = hn } = {}) => {
1274
+ 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;
1277
+ };
1278
+ return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = G({
1279
+ targetFunction: s,
1280
+ isComplete: i,
1281
+ callLimit: t,
1282
+ isRejectAsValid: !0,
1283
+ isCheckBeforeCall: !1
1284
+ }), this.cancelableConnectWithRepeatedCalls.then((r) => {
1285
+ if (r instanceof this.JsSIP.UA)
1286
+ return r;
1287
+ throw r;
1288
+ });
1289
+ };
1290
+ hasEqualConnectionConfiguration(e) {
1291
+ const { configuration: t } = this.uaFactory.createConfiguration(e), i = this.getUa()?.configuration;
1292
+ return i ? i.password === t.password && i.register === t.register && i.uri.toString() === t.uri && i.display_name === t.display_name && i.user_agent === t.user_agent && i.sockets === t.sockets && i.session_timers === t.session_timers && i.register_expires === t.register_expires && i.connection_recovery_min_interval === t.connection_recovery_min_interval && i.connection_recovery_max_interval === t.connection_recovery_max_interval : !1;
1293
+ }
1294
+ connectInner = async (e) => this.initUa(e).then(async () => this.start());
1295
+ initUa = async ({
1296
+ user: e,
1297
+ password: t,
1298
+ sipServerUrl: s,
1299
+ sipWebSocketServerURL: i,
1300
+ remoteAddress: r,
1301
+ sessionTimers: a,
1302
+ registerExpires: o,
1303
+ connectionRecoveryMinInterval: c,
1304
+ connectionRecoveryMaxInterval: T,
1305
+ userAgent: S,
1306
+ displayName: l = "",
1307
+ register: d = !1,
1308
+ extraHeaders: h = []
1309
+ }) => {
1310
+ this.stateMachine.startInitUa(), this.setConnectionConfiguration({
1311
+ sipServerUrl: s,
1312
+ displayName: l,
1313
+ register: d,
1314
+ user: e,
1315
+ password: t
1316
+ }), this.getUa() && await this.disconnect();
1317
+ const { ua: C, helpers: O } = this.uaFactory.createUAWithConfiguration(
1318
+ {
1319
+ user: e,
1320
+ password: t,
1321
+ sipServerUrl: s,
1322
+ sipWebSocketServerURL: i,
1323
+ displayName: l,
1324
+ register: d,
1325
+ sessionTimers: a,
1326
+ registerExpires: o,
1327
+ connectionRecoveryMinInterval: c,
1328
+ connectionRecoveryMaxInterval: T,
1329
+ userAgent: S,
1330
+ remoteAddress: r,
1331
+ extraHeaders: h
1332
+ },
1333
+ this.events
1334
+ );
1335
+ return this.setUa(C), this.setSipServerUrl(O.getSipServerUrl), this.setSocket(O.socket), C;
1336
+ };
1337
+ start = async () => new Promise((e, t) => {
1338
+ const s = this.getUa();
1339
+ if (!s) {
1340
+ t(new Error("this.ua is not initialized"));
1341
+ return;
1342
+ }
1343
+ let i;
1344
+ i = ((c, T) => {
1345
+ 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);
1350
+ }), () => {
1351
+ this.events.off(l, c), d.forEach((h) => {
1352
+ this.events.off(h, T);
1353
+ });
1354
+ };
1355
+ })(() => {
1356
+ i?.(), e(s);
1357
+ }, (c) => {
1358
+ i?.(), t(c);
1359
+ }), s.start();
1360
+ });
1361
+ cancelConnectWithRepeatedCalls() {
1362
+ this.cancelableConnectWithRepeatedCalls?.cancel();
1363
+ }
1364
+ }
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({
1367
+ types: {
1368
+ context: {},
1369
+ events: {}
1370
+ },
1371
+ actions: {
1372
+ logTransition: (n, e) => {
1373
+ P(`State transition: ${e.from} -> ${e.to} (${e.event})`);
1374
+ },
1375
+ logStateChange: (n, e) => {
1376
+ P("ConnectionStateMachine state changed", e.state);
1377
+ }
1378
+ }
1379
+ }).createMachine({
1380
+ id: "connection",
1381
+ initial: "idle",
1382
+ context: {},
1383
+ states: {
1384
+ idle: {
1385
+ entry: {
1386
+ type: "logStateChange",
1387
+ params: {
1388
+ state: "idle"
1389
+ /* IDLE */
1390
+ }
1391
+ },
1392
+ on: {
1393
+ START_CONNECT: {
1394
+ target: "connecting",
1395
+ actions: {
1396
+ type: "logTransition",
1397
+ params: {
1398
+ from: "idle",
1399
+ to: "connecting",
1400
+ event: "START_CONNECT"
1401
+ /* START_CONNECT */
1402
+ }
1403
+ }
1404
+ }
1405
+ }
1406
+ },
1407
+ connecting: {
1408
+ entry: {
1409
+ type: "logStateChange",
1410
+ params: {
1411
+ state: "connecting"
1412
+ /* CONNECTING */
1413
+ }
1414
+ },
1415
+ on: {
1416
+ START_INIT_UA: {
1417
+ target: "initializing",
1418
+ actions: {
1419
+ type: "logTransition",
1420
+ params: {
1421
+ from: "connecting",
1422
+ to: "initializing",
1423
+ event: "START_INIT_UA"
1424
+ /* START_INIT_UA */
1425
+ // TODO: remove
1426
+ }
1427
+ }
1428
+ },
1429
+ UA_DISCONNECTED: {
1430
+ target: "disconnected",
1431
+ actions: {
1432
+ type: "logTransition",
1433
+ params: {
1434
+ from: "connecting",
1435
+ to: "disconnected",
1436
+ event: "UA_DISCONNECTED"
1437
+ /* UA_DISCONNECTED */
1438
+ }
1439
+ }
1440
+ },
1441
+ CONNECTION_FAILED: {
1442
+ target: "failed",
1443
+ actions: {
1444
+ type: "logTransition",
1445
+ params: {
1446
+ from: "connecting",
1447
+ to: "failed",
1448
+ event: "CONNECTION_FAILED"
1449
+ /* CONNECTION_FAILED */
1450
+ }
1451
+ }
1452
+ }
1453
+ }
1454
+ },
1455
+ initializing: {
1456
+ entry: {
1457
+ type: "logStateChange",
1458
+ params: {
1459
+ state: "initializing"
1460
+ /* INITIALIZING */
1461
+ }
1462
+ },
1463
+ on: {
1464
+ UA_CONNECTED: {
1465
+ target: "connected",
1466
+ actions: {
1467
+ type: "logTransition",
1468
+ params: {
1469
+ from: "initializing",
1470
+ to: "connected",
1471
+ event: "UA_CONNECTED"
1472
+ /* UA_CONNECTED */
1473
+ }
1474
+ }
1475
+ },
1476
+ UA_REGISTERED: {
1477
+ target: "registered",
1478
+ actions: {
1479
+ type: "logTransition",
1480
+ params: {
1481
+ from: "initializing",
1482
+ to: "registered",
1483
+ event: "UA_REGISTERED"
1484
+ /* UA_REGISTERED */
1485
+ }
1486
+ }
1487
+ },
1488
+ UA_DISCONNECTED: {
1489
+ target: "disconnected",
1490
+ actions: {
1491
+ type: "logTransition",
1492
+ params: {
1493
+ from: "initializing",
1494
+ to: "disconnected",
1495
+ event: "UA_DISCONNECTED"
1496
+ /* UA_DISCONNECTED */
1497
+ }
1498
+ }
1499
+ },
1500
+ CONNECTION_FAILED: {
1501
+ target: "failed",
1502
+ actions: {
1503
+ type: "logTransition",
1504
+ params: {
1505
+ from: "initializing",
1506
+ to: "failed",
1507
+ event: "CONNECTION_FAILED"
1508
+ /* CONNECTION_FAILED */
1509
+ }
1510
+ }
1511
+ }
1512
+ }
1513
+ },
1514
+ connected: {
1515
+ entry: {
1516
+ type: "logStateChange",
1517
+ params: {
1518
+ state: "connected"
1519
+ /* CONNECTED */
1520
+ }
1521
+ },
1522
+ on: {
1523
+ UA_REGISTERED: {
1524
+ target: "registered",
1525
+ actions: {
1526
+ type: "logTransition",
1527
+ params: {
1528
+ from: "connected",
1529
+ to: "registered",
1530
+ event: "UA_REGISTERED"
1531
+ /* UA_REGISTERED */
1532
+ }
1533
+ }
1534
+ },
1535
+ UA_DISCONNECTED: {
1536
+ target: "disconnected",
1537
+ actions: {
1538
+ type: "logTransition",
1539
+ params: {
1540
+ from: "connected",
1541
+ to: "disconnected",
1542
+ event: "UA_DISCONNECTED"
1543
+ /* UA_DISCONNECTED */
1544
+ }
1545
+ }
1546
+ },
1547
+ CONNECTION_FAILED: {
1548
+ target: "failed",
1549
+ actions: {
1550
+ type: "logTransition",
1551
+ params: {
1552
+ from: "connected",
1553
+ to: "failed",
1554
+ event: "CONNECTION_FAILED"
1555
+ /* CONNECTION_FAILED */
1556
+ }
1557
+ }
1558
+ }
1559
+ }
1560
+ },
1561
+ registered: {
1562
+ entry: {
1563
+ type: "logStateChange",
1564
+ params: {
1565
+ state: "registered"
1566
+ /* REGISTERED */
1567
+ }
1568
+ },
1569
+ on: {
1570
+ UA_UNREGISTERED: {
1571
+ target: "connected",
1572
+ actions: {
1573
+ type: "logTransition",
1574
+ params: {
1575
+ from: "registered",
1576
+ to: "connected",
1577
+ event: "UA_UNREGISTERED"
1578
+ /* UA_UNREGISTERED */
1579
+ }
1580
+ }
1581
+ },
1582
+ UA_DISCONNECTED: {
1583
+ target: "disconnected",
1584
+ actions: {
1585
+ type: "logTransition",
1586
+ params: {
1587
+ from: "registered",
1588
+ to: "disconnected",
1589
+ event: "UA_DISCONNECTED"
1590
+ /* UA_DISCONNECTED */
1591
+ }
1592
+ }
1593
+ },
1594
+ CONNECTION_FAILED: {
1595
+ target: "failed",
1596
+ actions: {
1597
+ type: "logTransition",
1598
+ params: {
1599
+ from: "registered",
1600
+ to: "failed",
1601
+ event: "CONNECTION_FAILED"
1602
+ /* CONNECTION_FAILED */
1603
+ }
1604
+ }
1605
+ }
1606
+ }
1607
+ },
1608
+ disconnected: {
1609
+ entry: {
1610
+ type: "logStateChange",
1611
+ params: {
1612
+ state: "disconnected"
1613
+ /* DISCONNECTED */
1614
+ }
1615
+ },
1616
+ on: {
1617
+ RESET: {
1618
+ target: "idle",
1619
+ actions: {
1620
+ type: "logTransition",
1621
+ params: {
1622
+ from: "disconnected",
1623
+ to: "idle",
1624
+ event: "RESET"
1625
+ /* RESET */
1626
+ }
1627
+ }
1628
+ },
1629
+ START_CONNECT: {
1630
+ target: "connecting",
1631
+ actions: {
1632
+ type: "logTransition",
1633
+ params: {
1634
+ from: "disconnected",
1635
+ to: "connecting",
1636
+ event: "START_CONNECT"
1637
+ /* START_CONNECT */
1638
+ }
1639
+ }
1640
+ }
1641
+ }
1642
+ },
1643
+ failed: {
1644
+ entry: {
1645
+ type: "logStateChange",
1646
+ params: {
1647
+ state: "failed"
1648
+ /* FAILED */
1649
+ }
1650
+ },
1651
+ on: {
1652
+ RESET: {
1653
+ target: "idle",
1654
+ actions: {
1655
+ type: "logTransition",
1656
+ params: {
1657
+ from: "failed",
1658
+ to: "idle",
1659
+ event: "RESET"
1660
+ /* RESET */
1661
+ }
1662
+ }
1663
+ },
1664
+ START_CONNECT: {
1665
+ target: "connecting",
1666
+ actions: {
1667
+ type: "logTransition",
1668
+ params: {
1669
+ from: "failed",
1670
+ to: "connecting",
1671
+ event: "START_CONNECT"
1672
+ /* START_CONNECT */
1673
+ }
1674
+ }
1675
+ }
1676
+ }
1677
+ }
1678
+ }
1679
+ });
1680
+ class Nn {
1681
+ actor;
1682
+ stateChangeListeners = /* @__PURE__ */ new Set();
1683
+ events;
1684
+ unsubscribeFromEvents;
1685
+ actorSubscription;
1686
+ constructor(e) {
1687
+ this.events = e, this.actor = Ct(Cn), this.actorSubscription = this.actor.subscribe((t) => {
1688
+ const s = t.value;
1689
+ this.stateChangeListeners.forEach((i) => {
1690
+ i(s);
1691
+ });
1692
+ }), this.actor.start(), this.subscribeToEvents();
1693
+ }
1694
+ get state() {
1695
+ return this.actor.getSnapshot().value;
1696
+ }
1697
+ get isIdle() {
1698
+ return this.hasState(
1699
+ "idle"
1700
+ /* IDLE */
1701
+ );
1702
+ }
1703
+ get isConnecting() {
1704
+ return this.hasState(
1705
+ "connecting"
1706
+ /* CONNECTING */
1707
+ );
1708
+ }
1709
+ get isInitializing() {
1710
+ return this.hasState(
1711
+ "initializing"
1712
+ /* INITIALIZING */
1713
+ );
1714
+ }
1715
+ get isConnected() {
1716
+ return this.hasState(
1717
+ "connected"
1718
+ /* CONNECTED */
1719
+ );
1720
+ }
1721
+ get isRegistered() {
1722
+ return this.hasState(
1723
+ "registered"
1724
+ /* REGISTERED */
1725
+ );
1726
+ }
1727
+ get isDisconnected() {
1728
+ return this.hasState(
1729
+ "disconnected"
1730
+ /* DISCONNECTED */
1731
+ );
1732
+ }
1733
+ get isFailed() {
1734
+ return this.hasState(
1735
+ "failed"
1736
+ /* FAILED */
1737
+ );
1738
+ }
1739
+ get isPending() {
1740
+ return this.isConnecting || this.isInitializing;
1741
+ }
1742
+ get isPendingConnect() {
1743
+ return this.isConnecting;
1744
+ }
1745
+ get isPendingInitUa() {
1746
+ return this.isInitializing;
1747
+ }
1748
+ get isActiveConnection() {
1749
+ return this.isConnected || this.isRegistered;
1750
+ }
1751
+ // Публичные методы для уведомления о начале операций
1752
+ startConnect() {
1753
+ this.toStartConnect();
1754
+ }
1755
+ startInitUa() {
1756
+ this.toStartInitUa();
1757
+ }
1758
+ reset() {
1759
+ this.toIdle();
1760
+ }
1761
+ destroy() {
1762
+ this.unsubscribeFromEvents?.(), this.actorSubscription?.unsubscribe(), this.actor.stop();
1763
+ }
1764
+ onStateChange(e) {
1765
+ return this.stateChangeListeners.add(e), () => {
1766
+ this.stateChangeListeners.delete(e);
1767
+ };
1768
+ }
1769
+ canTransition(e) {
1770
+ return this.actor.getSnapshot().can({ type: e });
1771
+ }
1772
+ getValidEvents() {
1773
+ return Object.values(dt).filter((e) => this.canTransition(e));
1774
+ }
1775
+ hasState(e) {
1776
+ return this.actor.getSnapshot().matches(e);
1777
+ }
1778
+ sendEvent(e) {
1779
+ const t = this.actor.getSnapshot(), s = { type: e };
1780
+ if (!t.can(s)) {
1781
+ P(
1782
+ `Invalid transition: ${s.type} from ${this.state}. Event cannot be processed in current state.`
1783
+ );
1784
+ return;
1785
+ }
1786
+ this.actor.send(s);
1787
+ }
1788
+ toStartConnect = () => {
1789
+ this.sendEvent(
1790
+ "START_CONNECT"
1791
+ /* START_CONNECT */
1792
+ );
1793
+ };
1794
+ toStartInitUa = () => {
1795
+ this.sendEvent(
1796
+ "START_INIT_UA"
1797
+ /* START_INIT_UA */
1798
+ );
1799
+ };
1800
+ toConnected = () => {
1801
+ this.sendEvent(
1802
+ "UA_CONNECTED"
1803
+ /* UA_CONNECTED */
1804
+ );
1805
+ };
1806
+ toRegistered = () => {
1807
+ this.sendEvent(
1808
+ "UA_REGISTERED"
1809
+ /* UA_REGISTERED */
1810
+ );
1811
+ };
1812
+ toUnregistered = () => {
1813
+ this.sendEvent(
1814
+ "UA_UNREGISTERED"
1815
+ /* UA_UNREGISTERED */
1816
+ );
1817
+ };
1818
+ toDisconnected = () => {
1819
+ this.sendEvent(
1820
+ "UA_DISCONNECTED"
1821
+ /* UA_DISCONNECTED */
1822
+ );
1823
+ };
1824
+ toFailed = () => {
1825
+ this.sendEvent(
1826
+ "CONNECTION_FAILED"
1827
+ /* CONNECTION_FAILED */
1828
+ );
1829
+ };
1830
+ toIdle = () => {
1831
+ this.sendEvent(
1832
+ "RESET"
1833
+ /* RESET */
1834
+ );
1835
+ };
1836
+ subscribeToEvents() {
1837
+ this.events.on("connected", this.toConnected), this.events.on("registered", this.toRegistered), this.events.on("unregistered", this.toUnregistered), this.events.on("disconnected", this.toDisconnected), this.events.on("registrationFailed", this.toFailed), this.unsubscribeFromEvents = () => {
1838
+ this.events.off("connected", this.toConnected), this.events.off("registered", this.toRegistered), this.events.off("unregistered", this.toUnregistered), this.events.off("disconnected", this.toDisconnected), this.events.off("registrationFailed", this.toFailed);
1839
+ };
1840
+ }
1841
+ }
1842
+ class An {
1843
+ events;
1844
+ getUaProtected;
1845
+ constructor(e) {
1846
+ this.events = e.events, this.getUaProtected = e.getUaProtected;
1847
+ }
1848
+ async register() {
1849
+ const e = this.getUaProtected();
1850
+ return new Promise((t, s) => {
1851
+ e.on(A.REGISTERED, t), e.on(A.REGISTRATION_FAILED, s), e.register();
1852
+ });
1853
+ }
1854
+ async unregister() {
1855
+ const e = this.getUaProtected();
1856
+ return new Promise((t) => {
1857
+ e.on(A.UNREGISTERED, t), e.unregister();
1858
+ });
1859
+ }
1860
+ async tryRegister() {
1861
+ try {
1862
+ await this.unregister();
1863
+ } catch (e) {
1864
+ P("tryRegister", e);
1865
+ }
1866
+ return this.register();
1867
+ }
1868
+ subscribeToStartEvents(e, t) {
1869
+ const s = A.REGISTERED, i = [A.REGISTRATION_FAILED, A.DISCONNECTED];
1870
+ return this.events.on(s, e), i.forEach((r) => {
1871
+ this.events.on(r, t);
1872
+ }), () => {
1873
+ this.events.off(s, e), i.forEach((r) => {
1874
+ this.events.off(r, t);
1875
+ });
1876
+ };
1877
+ }
1878
+ }
1879
+ class _n {
1880
+ uaFactory;
1881
+ getUaProtected;
1882
+ constructor(e) {
1883
+ this.uaFactory = e.uaFactory, this.getUaProtected = e.getUaProtected;
1884
+ }
1885
+ /**
1886
+ * Отправляет SIP OPTIONS запрос к указанному адресу
1887
+ */
1888
+ async sendOptions(e, t, s) {
1889
+ const i = this.getUaProtected();
1890
+ return new Promise((r, a) => {
1891
+ try {
1892
+ i.sendOptions(e, t, {
1893
+ extraHeaders: s,
1894
+ eventHandlers: {
1895
+ succeeded: () => {
1896
+ r();
1897
+ },
1898
+ failed: a
1899
+ }
1900
+ });
1901
+ } catch (o) {
1902
+ a(o);
1903
+ }
1904
+ });
1905
+ }
1906
+ /**
1907
+ * Отправляет SIP OPTIONS запрос к собственному URI (ping)
1908
+ */
1909
+ async ping(e, t) {
1910
+ const i = this.getUaProtected().configuration.uri;
1911
+ return this.sendOptions(i, e, t);
1912
+ }
1913
+ /**
1914
+ * Проверяет доступность телефонии, создавая временное соединение
1915
+ */
1916
+ async checkTelephony({
1917
+ userAgent: e,
1918
+ displayName: t,
1919
+ sipServerUrl: s,
1920
+ sipWebSocketServerURL: i,
1921
+ remoteAddress: r,
1922
+ extraHeaders: a
1923
+ }) {
1924
+ return new Promise((o, c) => {
1925
+ const { configuration: T } = this.uaFactory.createConfiguration({
1926
+ sipWebSocketServerURL: i,
1927
+ displayName: t,
1928
+ userAgent: e,
1929
+ 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);
1933
+ };
1934
+ S.once(A.DISCONNECTED, l);
1935
+ const d = () => {
1936
+ S.removeAllListeners(), S.once(A.DISCONNECTED, () => {
1937
+ o();
1938
+ }), S.stop();
1939
+ };
1940
+ S.once(A.CONNECTED, d), S.start();
1941
+ });
1942
+ }
1943
+ }
1944
+ const un = (n) => {
1945
+ const e = [];
1946
+ return n !== void 0 && n !== "" && e.push(`X-Vinteo-Remote: ${n}`), e;
1947
+ };
1948
+ class p {
1949
+ JsSIP;
1950
+ constructor(e) {
1951
+ this.JsSIP = e;
1952
+ }
1953
+ static isRegisteredUA(e) {
1954
+ return !!e && e.isRegistered();
1955
+ }
1956
+ static validateConfiguration({
1957
+ register: e,
1958
+ password: t,
1959
+ user: s,
1960
+ sipServerUrl: i,
1961
+ sipWebSocketServerURL: r
1962
+ }) {
1963
+ if (!i)
1964
+ throw new Error("sipServerUrl is required");
1965
+ if (!r)
1966
+ throw new Error("sipWebSocketServerURL is required");
1967
+ if (e && (t === void 0 || t === ""))
1968
+ throw new Error("password is required for authorized connection");
1969
+ if (e && (s === void 0 || s === ""))
1970
+ throw new Error("user is required for authorized connection");
1971
+ }
1972
+ static resolveAuthorizationUser(e, t) {
1973
+ return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${Jt()}`;
1974
+ }
1975
+ static buildExtraHeaders(e, t) {
1976
+ const s = e !== void 0 && e !== "" ? un(e) : [];
1977
+ return t === void 0 ? s : [...s, ...t];
1978
+ }
1979
+ createConfiguration({
1980
+ user: e,
1981
+ password: t,
1982
+ sipWebSocketServerURL: s,
1983
+ displayName: i = "",
1984
+ sipServerUrl: r,
1985
+ register: a = !1,
1986
+ sessionTimers: o = !1,
1987
+ registerExpires: c = 300,
1988
+ // 5 minutes in sec
1989
+ connectionRecoveryMinInterval: T = 2,
1990
+ connectionRecoveryMaxInterval: S = 6,
1991
+ userAgent: l
1992
+ }) {
1993
+ p.validateConfiguration({
1994
+ register: a,
1995
+ password: t,
1996
+ user: e,
1997
+ sipServerUrl: r,
1998
+ sipWebSocketServerURL: s
1999
+ });
2000
+ const d = p.resolveAuthorizationUser(a, e), h = Qt(r), I = h(d), C = new this.JsSIP.WebSocketInterface(s);
2001
+ return {
2002
+ configuration: {
2003
+ password: t,
2004
+ register: a,
2005
+ uri: I,
2006
+ display_name: Et(i),
2007
+ user_agent: l,
2008
+ sdpSemantics: "unified-plan",
2009
+ sockets: [C],
2010
+ session_timers: o,
2011
+ register_expires: c,
2012
+ connection_recovery_min_interval: T,
2013
+ connection_recovery_max_interval: S
2014
+ },
2015
+ helpers: {
2016
+ socket: C,
2017
+ getSipServerUrl: h
2018
+ }
2019
+ };
2020
+ }
2021
+ createUA({ remoteAddress: e, extraHeaders: t, ...s }) {
2022
+ const i = new this.JsSIP.UA(s), r = p.buildExtraHeaders(e, t);
2023
+ return r.length > 0 && i.registrator().setExtraHeaders(r), i;
2024
+ }
2025
+ /**
2026
+ * Создает UA с полным жизненным циклом - конфигурация + создание + настройка событий
2027
+ */
2028
+ createUAWithConfiguration(e, t) {
2029
+ const { configuration: s, helpers: i } = this.createConfiguration(e), r = this.createUA({
2030
+ ...s,
2031
+ remoteAddress: e.remoteAddress,
2032
+ extraHeaders: e.extraHeaders
2033
+ });
2034
+ return t.eachTriggers((a, o) => {
2035
+ const c = St.find((T) => T === o);
2036
+ c && r.on(c, a);
2037
+ }), { ua: r, helpers: i };
2038
+ }
2039
+ }
2040
+ class In {
2041
+ events;
2042
+ ua;
2043
+ socket;
2044
+ uaFactory;
2045
+ registrationManager;
2046
+ stateMachine;
2047
+ connectionFlow;
2048
+ sipOperations;
2049
+ configurationManager;
2050
+ JsSIP;
2051
+ constructor({ JsSIP: e }) {
2052
+ this.JsSIP = e, this.events = new D(dn), this.uaFactory = new p(e), this.registrationManager = new An({
2053
+ events: this.events,
2054
+ getUaProtected: this.getUaProtected
2055
+ }), this.stateMachine = new Nn(this.events), this.configurationManager = new Sn({
2056
+ getUa: this.getUa
2057
+ }), this.sipOperations = new _n({
2058
+ uaFactory: this.uaFactory,
2059
+ getUaProtected: this.getUaProtected
2060
+ }), this.connectionFlow = new ln({
2061
+ JsSIP: this.JsSIP,
2062
+ events: this.events,
2063
+ uaFactory: this.uaFactory,
2064
+ stateMachine: this.stateMachine,
2065
+ registrationManager: this.registrationManager,
2066
+ getUa: this.getUa,
2067
+ getConnectionConfiguration: this.getConnectionConfiguration,
2068
+ setConnectionConfiguration: (t) => {
2069
+ this.configurationManager.set(t);
2070
+ },
2071
+ updateConnectionConfiguration: (t, s) => {
2072
+ this.configurationManager.update(t, s);
2073
+ },
2074
+ setUa: (t) => {
2075
+ this.ua = t;
2076
+ },
2077
+ setSipServerUrl: (t) => {
2078
+ this.getSipServerUrl = t;
2079
+ },
2080
+ setSocket: (t) => {
2081
+ this.socket = t;
2082
+ }
2083
+ });
2084
+ }
2085
+ get requested() {
2086
+ return this.stateMachine.isPending;
2087
+ }
2088
+ get isPendingConnect() {
2089
+ return this.stateMachine.isPendingConnect;
2090
+ }
2091
+ get isPendingInitUa() {
2092
+ return this.stateMachine.isPendingInitUa;
2093
+ }
2094
+ get connectionState() {
2095
+ return this.stateMachine.state;
2096
+ }
2097
+ get isRegistered() {
2098
+ return p.isRegisteredUA(this.ua);
2099
+ }
2100
+ get isRegisterConfig() {
2101
+ return this.configurationManager.isRegister();
2102
+ }
2103
+ connect = async (e, t) => this.connectionFlow.connect(e, t);
2104
+ set = async ({ displayName: e }) => this.connectionFlow.set({ displayName: e });
2105
+ disconnect = async () => this.connectionFlow.disconnect();
2106
+ async register() {
2107
+ return this.registrationManager.register();
2108
+ }
2109
+ async unregister() {
2110
+ return this.registrationManager.unregister();
2111
+ }
2112
+ tryRegister = async () => this.registrationManager.tryRegister();
2113
+ sendOptions = async (e, t, s) => this.sipOperations.sendOptions(e, t, s);
2114
+ ping = async (e, t) => this.sipOperations.ping(e, t);
2115
+ checkTelephony = async (e) => this.sipOperations.checkTelephony(e);
2116
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2117
+ on(e, t) {
2118
+ return this.events.on(e, t);
2119
+ }
2120
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2121
+ once(e, t) {
2122
+ return this.events.once(e, t);
2123
+ }
2124
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2125
+ onceRace(e, t) {
2126
+ return this.events.onceRace(e, t);
2127
+ }
2128
+ async wait(e) {
2129
+ return this.events.wait(e);
2130
+ }
2131
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2132
+ off(e, t) {
2133
+ this.events.off(e, t);
2134
+ }
2135
+ isConfigured() {
2136
+ return this.configurationManager.isConfigured();
2137
+ }
2138
+ getConnectionConfiguration = () => this.configurationManager.get();
2139
+ destroy() {
2140
+ this.stateMachine.destroy();
2141
+ }
2142
+ // eslint-disable-next-line class-methods-use-this
2143
+ getSipServerUrl = (e) => e;
2144
+ getUaProtected = () => {
2145
+ if (!this.ua)
2146
+ throw new Error("UA not initialized");
2147
+ return this.ua;
2148
+ };
2149
+ getUa = () => this.ua;
2150
+ }
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 = [
2153
+ "incomingCall",
2154
+ "declinedIncomingCall",
2155
+ "terminatedIncomingCall",
2156
+ "failedIncomingCall"
2157
+ ], Mn = 486, On = 487;
2158
+ class pn {
2159
+ incomingRTCSession;
2160
+ connectionManager;
2161
+ events;
2162
+ constructor(e) {
2163
+ this.connectionManager = e, this.events = new D(Rn), this.start();
2164
+ }
2165
+ get remoteCallerData() {
2166
+ return {
2167
+ displayName: this.incomingRTCSession?.remote_identity.display_name,
2168
+ host: this.incomingRTCSession?.remote_identity.uri.host,
2169
+ incomingNumber: this.incomingRTCSession?.remote_identity.uri.user,
2170
+ rtcSession: this.incomingRTCSession
2171
+ };
2172
+ }
2173
+ get isAvailableIncomingCall() {
2174
+ return !!this.incomingRTCSession;
2175
+ }
2176
+ start() {
2177
+ this.subscribe();
2178
+ }
2179
+ stop() {
2180
+ this.unsubscribe(), this.removeIncomingSession();
2181
+ }
2182
+ getIncomingRTCSession = () => {
2183
+ const { incomingRTCSession: e } = this;
2184
+ if (!e)
2185
+ throw new Error("No incomingRTCSession");
2186
+ return e;
2187
+ };
2188
+ extractIncomingRTCSession = () => {
2189
+ const e = this.getIncomingRTCSession();
2190
+ return this.removeIncomingSession(), e;
2191
+ };
2192
+ async declineToIncomingCall({
2193
+ statusCode: e = On
2194
+ } = {}) {
2195
+ return new Promise((t, s) => {
2196
+ try {
2197
+ const i = this.getIncomingRTCSession(), r = this.remoteCallerData;
2198
+ this.removeIncomingSession(), this.events.trigger(f.DECLINED_INCOMING_CALL, r), i.terminate({ status_code: e }), t();
2199
+ } catch (i) {
2200
+ s(i);
2201
+ }
2202
+ });
2203
+ }
2204
+ async busyIncomingCall() {
2205
+ return this.declineToIncomingCall({ statusCode: Mn });
2206
+ }
2207
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2208
+ on(e, t) {
2209
+ return this.events.on(e, t);
2210
+ }
2211
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2212
+ once(e, t) {
2213
+ return this.events.once(e, t);
2214
+ }
2215
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2216
+ onceRace(e, t) {
2217
+ return this.events.onceRace(e, t);
2218
+ }
2219
+ async wait(e) {
2220
+ return this.events.wait(e);
2221
+ }
2222
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2223
+ off(e, t) {
2224
+ this.events.off(e, t);
2225
+ }
2226
+ subscribe() {
2227
+ this.connectionManager.on("newRTCSession", this.handleNewRTCSession);
2228
+ }
2229
+ unsubscribe() {
2230
+ this.connectionManager.off("newRTCSession", this.handleNewRTCSession);
2231
+ }
2232
+ handleNewRTCSession = ({
2233
+ originator: e,
2234
+ session: t
2235
+ }) => {
2236
+ e === $.REMOTE && this.setIncomingSession(t);
2237
+ };
2238
+ setIncomingSession(e) {
2239
+ this.incomingRTCSession = e;
2240
+ const t = this.remoteCallerData;
2241
+ 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);
2244
+ }
2245
+ removeIncomingSession() {
2246
+ delete this.incomingRTCSession;
2247
+ }
2248
+ }
2249
+ class $n {
2250
+ connectionManager;
2251
+ callManager;
2252
+ apiManager;
2253
+ incomingCallManager;
2254
+ presentationManager;
2255
+ constructor({ JsSIP: e }) {
2256
+ this.connectionManager = new In({ JsSIP: e }), this.callManager = new tn(), this.apiManager = new gn({
2257
+ connectionManager: this.connectionManager,
2258
+ callManager: this.callManager
2259
+ }), this.incomingCallManager = new pn(this.connectionManager), this.presentationManager = new rn({
2260
+ callManager: this.callManager
2261
+ });
2262
+ }
2263
+ get requestedConnection() {
2264
+ return this.connectionManager.requested;
2265
+ }
2266
+ get isPendingConnect() {
2267
+ return this.connectionManager.isPendingConnect;
2268
+ }
2269
+ get isPendingInitUa() {
2270
+ return this.connectionManager.isPendingInitUa;
2271
+ }
2272
+ get connectionState() {
2273
+ return this.connectionManager.connectionState;
2274
+ }
2275
+ get isRegistered() {
2276
+ return this.connectionManager.isRegistered;
2277
+ }
2278
+ get isRegisterConfig() {
2279
+ return this.connectionManager.isRegisterConfig;
2280
+ }
2281
+ get socket() {
2282
+ return this.connectionManager.socket;
2283
+ }
2284
+ get requestedCall() {
2285
+ return this.callManager.requested;
2286
+ }
2287
+ get connection() {
2288
+ return this.callManager.connection;
2289
+ }
2290
+ get establishedRTCSession() {
2291
+ return this.callManager.establishedRTCSession;
2292
+ }
2293
+ get isCallActive() {
2294
+ return this.callManager.isCallActive;
2295
+ }
2296
+ get remoteCallerData() {
2297
+ return this.incomingCallManager.remoteCallerData;
2298
+ }
2299
+ get isAvailableIncomingCall() {
2300
+ return this.incomingCallManager.isAvailableIncomingCall;
2301
+ }
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
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2312
+ onConnection(e, t) {
2313
+ return this.connectionManager.on(e, t);
2314
+ }
2315
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2316
+ onceConnection(e, t) {
2317
+ return this.connectionManager.once(e, t);
2318
+ }
2319
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2320
+ onceRaceConnection(e, t) {
2321
+ return this.connectionManager.onceRace(e, t);
2322
+ }
2323
+ async waitConnection(e) {
2324
+ return this.connectionManager.wait(e);
2325
+ }
2326
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2327
+ offConnection(e, t) {
2328
+ this.connectionManager.off(e, t);
2329
+ }
2330
+ isConfigured = () => this.connectionManager.isConfigured();
2331
+ getConnectionConfiguration = () => this.connectionManager.getConnectionConfiguration();
2332
+ getSipServerUrl = (e) => this.connectionManager.getSipServerUrl(e);
2333
+ call = async (e) => this.callManager.startCall(
2334
+ this.connectionManager.getUaProtected(),
2335
+ this.getSipServerUrl,
2336
+ e
2337
+ );
2338
+ hangUp = async () => this.callManager.endCall();
2339
+ answerToIncomingCall = async (e) => this.callManager.answerToIncomingCall(
2340
+ this.incomingCallManager.extractIncomingRTCSession,
2341
+ e
2342
+ );
2343
+ declineToIncomingCall = async (...e) => this.incomingCallManager.declineToIncomingCall(...e);
2344
+ getEstablishedRTCSession = () => this.callManager.getEstablishedRTCSession();
2345
+ getCallConfiguration = () => this.callManager.getCallConfiguration();
2346
+ getRemoteStreams = () => this.callManager.getRemoteStreams();
2347
+ 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
+ async startPresentation(e, t = {}) {
2387
+ const { isP2P: s, callLimit: i, ...r } = t;
2388
+ return this.presentationManager.startPresentation(
2389
+ async () => {
2390
+ s === !0 ? (await this.apiManager.sendMustStopPresentationP2P(), await this.apiManager.askPermissionToStartPresentationP2P()) : await this.apiManager.askPermissionToStartPresentation();
2391
+ },
2392
+ e,
2393
+ r,
2394
+ i === void 0 ? void 0 : { callLimit: i }
2395
+ );
2396
+ }
2397
+ async stopPresentation(e = {}) {
2398
+ const { isP2P: t } = e;
2399
+ return this.presentationManager.stopPresentation(async () => {
2400
+ t === !0 ? await this.apiManager.sendMustStopPresentationP2P() : await this.apiManager.sendStoppedPresentation();
2401
+ });
2402
+ }
2403
+ async updatePresentation(e, t = {}) {
2404
+ const { isP2P: s, ...i } = t;
2405
+ return this.presentationManager.updatePresentation(
2406
+ async () => {
2407
+ s === !0 ? (await this.apiManager.sendMustStopPresentationP2P(), await this.apiManager.askPermissionToStartPresentationP2P()) : await this.apiManager.askPermissionToStartPresentation();
2408
+ },
2409
+ e,
2410
+ i
2411
+ );
2412
+ }
2413
+ async waitChannels(...e) {
2414
+ return this.apiManager.waitChannels(...e);
2415
+ }
2416
+ async waitSyncMediaState(...e) {
2417
+ return this.apiManager.waitSyncMediaState(...e);
2418
+ }
2419
+ async sendDTMF(...e) {
2420
+ return this.apiManager.sendDTMF(...e);
2421
+ }
2422
+ async sendChannels(...e) {
2423
+ return this.apiManager.sendChannels(...e);
2424
+ }
2425
+ async sendMediaState(...e) {
2426
+ return this.apiManager.sendMediaState(...e);
2427
+ }
2428
+ async sendRefusalToTurnOn(...e) {
2429
+ return this.apiManager.sendRefusalToTurnOn(...e);
2430
+ }
2431
+ async sendRefusalToTurnOnMic(...e) {
2432
+ return this.apiManager.sendRefusalToTurnOnMic(...e);
2433
+ }
2434
+ async sendRefusalToTurnOnCam(...e) {
2435
+ return this.apiManager.sendRefusalToTurnOnCam(...e);
2436
+ }
2437
+ async sendMustStopPresentationP2P(...e) {
2438
+ return this.apiManager.sendMustStopPresentationP2P(...e);
2439
+ }
2440
+ async sendStoppedPresentationP2P(...e) {
2441
+ return this.apiManager.sendStoppedPresentationP2P(...e);
2442
+ }
2443
+ async sendStoppedPresentation(...e) {
2444
+ return this.apiManager.sendStoppedPresentation(...e);
2445
+ }
2446
+ async askPermissionToStartPresentationP2P(...e) {
2447
+ return this.apiManager.askPermissionToStartPresentationP2P(...e);
2448
+ }
2449
+ async askPermissionToStartPresentation(...e) {
2450
+ return this.apiManager.askPermissionToStartPresentation(...e);
2451
+ }
2452
+ async askPermissionToEnableCam(...e) {
2453
+ return this.apiManager.askPermissionToEnableCam(...e);
2454
+ }
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);
2473
+ }
2474
+ }
2475
+ 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,
2491
+ P as l
2492
+ };