sip-connector 14.1.2-1 → 14.1.2-2

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 (97) hide show
  1. package/dist/SipConnector-DGYQOyHy.cjs +1 -0
  2. package/dist/SipConnector-DTNc5BfW.js +1352 -0
  3. package/dist/doMock.cjs +1 -1
  4. package/dist/doMock.js +1 -1
  5. package/dist/index.cjs +1 -1
  6. package/dist/index.js +85 -86
  7. package/dist/src/SipConnector.d.ts +235 -0
  8. package/dist/{SipConnectorFacade → src/SipConnectorFacade}/SipConnectorFacade.d.ts +1 -1
  9. package/package.json +1 -1
  10. package/dist/SipConnector-CZwqeStw.cjs +0 -1
  11. package/dist/SipConnector-DfaRIKWv.js +0 -1345
  12. package/dist/SipConnector.d.ts +0 -315
  13. package/dist/utils/utils.d.ts +0 -4
  14. /package/dist/{SipConnectorFacade → src/SipConnectorFacade}/index.d.ts +0 -0
  15. /package/dist/{__fixtures__ → src/__fixtures__}/BaseSession.mock.d.ts +0 -0
  16. /package/dist/{__fixtures__ → src/__fixtures__}/RTCPeerConnectionMock.d.ts +0 -0
  17. /package/dist/{__fixtures__ → src/__fixtures__}/RTCRtpSenderMock.d.ts +0 -0
  18. /package/dist/{__fixtures__ → src/__fixtures__}/RTCSessionMock.d.ts +0 -0
  19. /package/dist/{__fixtures__ → src/__fixtures__}/Registrator.mock.d.ts +0 -0
  20. /package/dist/{__fixtures__ → src/__fixtures__}/Request.mock.d.ts +0 -0
  21. /package/dist/{__fixtures__ → src/__fixtures__}/UA.mock.d.ts +0 -0
  22. /package/dist/{__fixtures__ → src/__fixtures__}/WebSocketInterface.mock.d.ts +0 -0
  23. /package/dist/{__fixtures__ → src/__fixtures__}/accountNotify.d.ts +0 -0
  24. /package/dist/{__fixtures__ → src/__fixtures__}/channels.d.ts +0 -0
  25. /package/dist/{__fixtures__ → src/__fixtures__}/channelsNotify.d.ts +0 -0
  26. /package/dist/{__fixtures__ → src/__fixtures__}/conferenceParticipantTokenIssuedNotify.d.ts +0 -0
  27. /package/dist/{__fixtures__ → src/__fixtures__}/delayPromise.d.ts +0 -0
  28. /package/dist/{__fixtures__ → src/__fixtures__}/enterRoom.d.ts +0 -0
  29. /package/dist/{__fixtures__ → src/__fixtures__}/index.d.ts +0 -0
  30. /package/dist/{__fixtures__ → src/__fixtures__}/jssip.mock.d.ts +0 -0
  31. /package/dist/{__fixtures__ → src/__fixtures__}/mediaState.d.ts +0 -0
  32. /package/dist/{__fixtures__ → src/__fixtures__}/participantMoveRequests.d.ts +0 -0
  33. /package/dist/{__fixtures__ → src/__fixtures__}/participantNotify.d.ts +0 -0
  34. /package/dist/{__fixtures__ → src/__fixtures__}/remoteCallerData.d.ts +0 -0
  35. /package/dist/{__fixtures__ → src/__fixtures__}/utils.d.ts +0 -0
  36. /package/dist/{__fixtures__ → src/__fixtures__}/webcastNotify.d.ts +0 -0
  37. /package/dist/{causes.d.ts → src/causes.d.ts} +0 -0
  38. /package/dist/{constants.d.ts → src/constants.d.ts} +0 -0
  39. /package/dist/{doMock.d.ts → src/doMock.d.ts} +0 -0
  40. /package/dist/{eventNames.d.ts → src/eventNames.d.ts} +0 -0
  41. /package/dist/{getExtraHeadersRemoteAddress.d.ts → src/getExtraHeadersRemoteAddress.d.ts} +0 -0
  42. /package/dist/{headers.d.ts → src/headers.d.ts} +0 -0
  43. /package/dist/{index.d.ts → src/index.d.ts} +0 -0
  44. /package/dist/{logger.d.ts → src/logger.d.ts} +0 -0
  45. /package/dist/{setParametersToSender → src/setParametersToSender}/configureDegradationPreference.d.ts +0 -0
  46. /package/dist/{setParametersToSender → src/setParametersToSender}/configureEmptyEncodings.d.ts +0 -0
  47. /package/dist/{setParametersToSender → src/setParametersToSender}/configureEncodings.d.ts +0 -0
  48. /package/dist/{setParametersToSender → src/setParametersToSender}/configureMaxBitrate.d.ts +0 -0
  49. /package/dist/{setParametersToSender → src/setParametersToSender}/configureScaleResolutionDownBy.d.ts +0 -0
  50. /package/dist/{setParametersToSender → src/setParametersToSender}/hasChangedRTCRtpSendParameters.d.ts +0 -0
  51. /package/dist/{setParametersToSender → src/setParametersToSender}/index.d.ts +0 -0
  52. /package/dist/{setParametersToSender → src/setParametersToSender}/resolveHasNeedToUpdateItemEncoding.d.ts +0 -0
  53. /package/dist/{setParametersToSender → src/setParametersToSender}/setParametersToSender.d.ts +0 -0
  54. /package/dist/{tools → src/tools}/__fixtures__/call.d.ts +0 -0
  55. /package/dist/{tools → src/tools}/__fixtures__/connectToServer.d.ts +0 -0
  56. /package/dist/{tools → src/tools}/__fixtures__/hasValidUri.d.ts +0 -0
  57. /package/dist/{tools → src/tools}/__fixtures__/permissions.d.ts +0 -0
  58. /package/dist/{tools → src/tools}/__fixtures__/processRequest.d.ts +0 -0
  59. /package/dist/{tools → src/tools}/__tests-utils__/parseObject.d.ts +0 -0
  60. /package/dist/{tools → src/tools}/__tests-utils__/resolveParseArray.d.ts +0 -0
  61. /package/dist/{tools → src/tools}/error/getLinkError.d.ts +0 -0
  62. /package/dist/{tools → src/tools}/error/getTypeFromError.d.ts +0 -0
  63. /package/dist/{tools → src/tools}/error/getValuesFromError.d.ts +0 -0
  64. /package/dist/{tools → src/tools}/error/index.d.ts +0 -0
  65. /package/dist/{tools → src/tools}/error/stringifyMessage.d.ts +0 -0
  66. /package/dist/{tools → src/tools}/generateSimulcastEncodings.d.ts +0 -0
  67. /package/dist/{tools → src/tools}/getExtraHeaders.d.ts +0 -0
  68. /package/dist/{tools → src/tools}/getUserAgent.d.ts +0 -0
  69. /package/dist/{tools → src/tools}/hasPurgatory.d.ts +0 -0
  70. /package/dist/{tools → src/tools}/index.d.ts +0 -0
  71. /package/dist/{tools → src/tools}/prepareMediaStream.d.ts +0 -0
  72. /package/dist/{tools → src/tools}/resolveUpdateTransceiver.d.ts +0 -0
  73. /package/dist/{tools → src/tools}/sendDTMFAccumulated.d.ts +0 -0
  74. /package/dist/{tools → src/tools}/setVideoTrackContentHints.d.ts +0 -0
  75. /package/dist/{tools → src/tools}/syncMediaState/index.d.ts +0 -0
  76. /package/dist/{tools → src/tools}/syncMediaState/resolveOnStartMainCam.d.ts +0 -0
  77. /package/dist/{tools → src/tools}/syncMediaState/resolveOnStartMic.d.ts +0 -0
  78. /package/dist/{tools → src/tools}/syncMediaState/resolveOnStopMainCam.d.ts +0 -0
  79. /package/dist/{tools → src/tools}/syncMediaState/resolveOnStopMic.d.ts +0 -0
  80. /package/dist/{types.d.ts → src/types.d.ts} +0 -0
  81. /package/dist/{utils → src/utils}/errors.d.ts +0 -0
  82. /package/dist/{utils → src/utils}/findSenderByStream.d.ts +0 -0
  83. /package/dist/{utils → src/utils}/findVideoSender.d.ts +0 -0
  84. /package/dist/{utils → src/utils}/findVideoTrack.d.ts +0 -0
  85. /package/dist/{utils → src/utils}/getCodecFromSender.d.ts +0 -0
  86. /package/dist/{utils → src/utils}/replaceForbiddenSymbolsWithUnderscore.d.ts +0 -0
  87. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/balance.d.ts +0 -0
  88. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/getMaxBitrateByWidth.d.ts +0 -0
  89. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/getMaxBitrateByWidthAndCodec.d.ts +0 -0
  90. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/hasAv1Codec.d.ts +0 -0
  91. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/hasIncludesString.d.ts +0 -0
  92. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/index.d.ts +0 -0
  93. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/processSender.d.ts +0 -0
  94. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/scaleBitrate.d.ts +0 -0
  95. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/scaleBitrateByCodec.d.ts +0 -0
  96. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/scaleResolutionAndBitrate.d.ts +0 -0
  97. /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/setEncodingsToSender.d.ts +0 -0
@@ -0,0 +1 @@
1
+ "use strict";var Ot=Object.defineProperty;var mt=(s,e,t)=>e in s?Ot(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var o=(s,e,t)=>mt(s,typeof e!="symbol"?e+"":e,t);const Mt=require("@krivega/cancelable-promise"),we=require("events-constructor"),G=require("repeated-calls"),J=require("debug"),Dt="Connection Error",ke="Request Timeout",pt="SIP Failure Code",vt="Internal Error",yt="Busy",X="Rejected",wt="Redirected",bt="Unavailable",Be="Not Found",Ut="Address Incomplete",Lt="Incompatible SDP",Ht="Missing SDP",Wt="Authentication Error",Fe="Terminated",kt="WebRTC Error",Q="Canceled",Bt="No Answer",Ft="Expires",xt="No ACK",Vt="Dialog Error",Yt="User Denied Media Access",xe="Bad Media Description",qt="RTP Timeout",$t=Object.freeze(Object.defineProperty({__proto__:null,ADDRESS_INCOMPLETE:Ut,AUTHENTICATION_ERROR:Wt,BAD_MEDIA_DESCRIPTION:xe,BUSY:yt,BYE:Fe,CANCELED:Q,CONNECTION_ERROR:Dt,DIALOG_ERROR:Vt,EXPIRES:Ft,INCOMPATIBLE_SDP:Lt,INTERNAL_ERROR:vt,MISSING_SDP:Ht,NOT_FOUND:Be,NO_ACK:xt,NO_ANSWER:Bt,REDIRECTED:wt,REJECTED:X,REQUEST_TIMEOUT:ke,RTP_TIMEOUT:qt,SIP_FAILURE_CODE:pt,UNAVAILABLE:bt,USER_DENIED_MEDIA_ACCESS:Yt,WEBRTC_ERROR:kt},Symbol.toStringTag,{value:"Module"})),z="incomingCall",j="declinedIncomingCall",K="failedIncomingCall",Z="terminatedIncomingCall",F="connecting",P="connected",C="disconnected",y="newRTCSession",O="registered",ee="unregistered",m="registrationFailed",Ve="newMessage",te="sipEvent",ne="availableSecondRemoteStream",se="notAvailableSecondRemoteStream",ie="mustStopPresentation",w="shareState",re="enterRoom",oe="useLicense",ae="peerconnection:confirmed",ce="peerconnection:ontrack",b="channels",Ee="channels:notify",de="ended:fromserver",he="main-cam-control",Se="admin-stop-main-cam",Te="admin-start-main-cam",le="admin-stop-mic",ue="admin-start-mic",U="admin-force-sync-media-state",ge="participant:added-to-list-moderators",Ce="participant:removed-from-list-moderators",_e="participant:move-request-to-stream",x="participant:move-request-to-spectators",V="participant:move-request-to-participants",Ne="participation:accepting-word-request",Ae="participation:cancelling-word-request",Re="webcast:started",fe="webcast:stopped",Ie="account:changed",Pe="account:deleted",Oe="conference:participant-token-issued",M="ended",Ye="sending",qe="reinvite",$e="replaces",Ge="refer",Je="progress",Xe="accepted",L="confirmed",H="peerconnection",A="failed",Qe="muted",ze="unmuted",me="newDTMF",Me="newInfo",je="hold",Ke="unhold",Ze="update",et="sdp",tt="icecandidate",nt="getusermediafailed",st="peerconnection:createofferfailed",it="peerconnection:createanswerfailed",rt="peerconnection:setlocaldescriptionfailed",ot="peerconnection:setremotedescriptionfailed",at="presentation:start",ct="presentation:started",Et="presentation:end",De="presentation:ended",W="presentation:failed",dt="SPECTATOR",ht="PARTICIPANT",St=1e6;var _=(s=>(s.LOCAL="local",s.REMOTE="remote",s.SYSTEM="system",s))(_||{});const Gt=Object.freeze(Object.defineProperty({__proto__:null,ACCEPTED:Xe,ACCOUNT_CHANGED:Ie,ACCOUNT_DELETED:Pe,ADMIN_FORCE_SYNC_MEDIA_STATE:U,ADMIN_START_MAIN_CAM:Te,ADMIN_START_MIC:ue,ADMIN_STOP_MAIN_CAM:Se,ADMIN_STOP_MIC:le,AVAILABLE_SECOND_REMOTE_STREAM_EVENT:ne,CHANNELS:b,CHANNELS_NOTIFY:Ee,CONFERENCE_PARTICIPANT_TOKEN_ISSUED:Oe,CONFIRMED:L,CONNECTED:P,CONNECTING:F,DECLINED_INCOMING_CALL:j,DISCONNECTED:C,ENDED:M,ENDED_FROM_SERVER:de,ENTER_ROOM:re,FAILED:A,FAILED_INCOMING_CALL:K,GET_USER_MEDIA_FAILED:nt,HOLD:je,ICE_CANDIDATE:tt,INCOMING_CALL:z,MAIN_CAM_CONTROL:he,MUST_STOP_PRESENTATION_EVENT:ie,MUTED:Qe,NEW_DTMF:me,NEW_INFO:Me,NEW_MESSAGE:Ve,NEW_RTC_SESSION:y,NOT_AVAILABLE_SECOND_REMOTE_STREAM_EVENT:se,ONE_MEGABIT_IN_BITS:St,Originator:_,PARTICIPANT:ht,PARTICIPANT_ADDED_TO_LIST_MODERATORS:ge,PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS:V,PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS:x,PARTICIPANT_MOVE_REQUEST_TO_STREAM:_e,PARTICIPANT_REMOVED_FROM_LIST_MODERATORS:Ce,PARTICIPATION_ACCEPTING_WORD_REQUEST:Ne,PARTICIPATION_CANCELLING_WORD_REQUEST:Ae,PEER_CONNECTION:H,PEER_CONNECTION_CONFIRMED:ae,PEER_CONNECTION_CREATE_ANSWER_FAILED:it,PEER_CONNECTION_CREATE_OFFER_FAILED:st,PEER_CONNECTION_ONTRACK:ce,PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED:rt,PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED:ot,PRESENTATION_END:Et,PRESENTATION_ENDED:De,PRESENTATION_FAILED:W,PRESENTATION_START:at,PRESENTATION_STARTED:ct,PROGRESS:Je,REFER:Ge,REGISTERED:O,REGISTRATION_FAILED:m,REINVITE:qe,REPLACES:$e,SDP:et,SENDING:Ye,SHARE_STATE:w,SIP_EVENT:te,SPECTATOR:dt,TERMINATED_INCOMING_CALL:Z,UNHOLD:Ke,UNMUTED:ze,UNREGISTERED:ee,UPDATE:Ze,USE_LICENSE:oe,WEBCAST_STARTED:Re,WEBCAST_STOPPED:fe},Symbol.toStringTag,{value:"Module"})),Tt=[z,j,Z,K,Ne,Ae,_e,Ee,Oe,Ie,Pe,Re,fe,ge,Ce],Y=[F,P,C,y,O,ee,m,Ve,te],lt=[ne,se,ie,w,re,oe,ae,ce,b,de,he,Te,Se,le,ue,U,x,V],pe=[M,F,Ye,qe,$e,Ge,Je,Xe,L,H,A,Qe,ze,me,Me,je,Ke,Ze,et,tt,nt,st,it,rt,ot,at,ct,Et,De,W],ut=[...Y,...Tt],ve=[...pe,...lt],Jt=Object.freeze(Object.defineProperty({__proto__:null,SESSION_EVENT_NAMES:ve,SESSION_JSSIP_EVENT_NAMES:pe,SESSION_SYNTHETICS_EVENT_NAMES:lt,UA_EVENT_NAMES:ut,UA_JSSIP_EVENT_NAMES:Y,UA_SYNTHETICS_EVENT_NAMES:Tt},Symbol.toStringTag,{value:"Module"})),ye="sip-connector",v=J(ye),Xt=()=>{J.enable(ye)},Qt=()=>{J.enable(`-${ye}`)},zt=(s,e)=>(s.degradationPreference=e.degradationPreference,s),jt=(s,e)=>{s.encodings===void 0&&(s.encodings=[]);for(let t=s.encodings.length;t<e;t+=1)s.encodings.push({});return s},gt=s=>(e,t)=>t!==void 0&&e!==t||t===void 0&&e!==s,Kt=gt(),Zt=(s,e)=>{if(Kt(s,e))return s},en=(s,e)=>{const t=s.maxBitrate,n=Zt(e,t);return n!==void 0&&(s.maxBitrate=n),s},Ct=1,tn=gt(Ct),nn=(s,e)=>{const t=s===void 0?void 0:Math.max(s,Ct);if(t!==void 0&&tn(t,e))return t},sn=(s,e)=>{const t=s.scaleResolutionDownBy,n=nn(e,t);return n!==void 0&&(s.scaleResolutionDownBy=n),s},rn=(s,e)=>{var n;const t=((n=e.encodings)==null?void 0:n.length)??0;return jt(s,t),s.encodings.forEach((i,r)=>{const a=((e==null?void 0:e.encodings)??[])[r],c=a==null?void 0:a.maxBitrate,E=a==null?void 0:a.scaleResolutionDownBy;en(i,c),sn(i,E)}),s},on=(s,e)=>{var t,n,i,r,a,c,E,d,T,l,S,u;if(((t=s.codecs)==null?void 0:t.length)!==((n=e.codecs)==null?void 0:n.length))return!0;for(let h=0;h<(((i=s.codecs)==null?void 0:i.length)??0);h++)if(JSON.stringify(s.codecs[h])!==JSON.stringify(e.codecs[h]))return!0;if(((r=s.headerExtensions)==null?void 0:r.length)!==((a=e.headerExtensions)==null?void 0:a.length))return!0;for(let h=0;h<(((c=s.headerExtensions)==null?void 0:c.length)??0);h++)if(JSON.stringify(s.headerExtensions[h])!==JSON.stringify(e.headerExtensions[h]))return!0;if(((E=s.encodings)==null?void 0:E.length)!==((d=e.encodings)==null?void 0:d.length))return!0;for(let h=0;h<(s.encodings.length??0);h++)if(JSON.stringify(s.encodings[h])!==JSON.stringify(e.encodings[h]))return!0;return((T=s.rtcp)==null?void 0:T.cname)!==((l=e.rtcp)==null?void 0:l.cname)||((S=s.rtcp)==null?void 0:S.reducedSize)!==((u=e.rtcp)==null?void 0:u.reducedSize)||s.degradationPreference!==e.degradationPreference},_t=async(s,e)=>{const t=s.getParameters(),n=JSON.parse(JSON.stringify(t));rn(t,e),zt(t,e);const i=on(n,t);return i&&await s.setParameters(t),{parameters:t,isChanged:i}};var R=(s=>(s.PAUSE_MAIN_CAM="PAUSEMAINCAM",s.RESUME_MAIN_CAM="RESUMEMAINCAM",s.MAX_MAIN_CAM_RESOLUTION="MAXMAINCAMRESOLUTION",s.ADMIN_STOP_MAIN_CAM="ADMINSTOPMAINCAM",s.ADMIN_START_MAIN_CAM="ADMINSTARTMAINCAM",s))(R||{}),k=(s=>(s.ADMIN_STOP_MIC="ADMINSTOPMIC",s.ADMIN_START_MIC="ADMINSTARTMIC",s))(k||{}),B=(s=>(s.ADMIN_SYNC_FORCED="1",s.ADMIN_SYNC_NOT_FORCED="0",s))(B||{}),Nt=(s=>(s.AUDIO="AUDIO",s.VIDEO="VIDEO",s.AUDIOPLUSPRESENTATION="AUDIOPLUSPRESENTATION",s))(Nt||{}),At=(s=>(s.VP8="video/VP8",s.VP9="video/VP9",s.H264="video/H264",s.AV1="video/AV1",s.rtx="video/rtx",s.red="video/red",s.flexfec03="video/flexfec-03",s))(At||{});const Rt=async(s,e,t)=>{const{isChanged:n,parameters:i}=await _t(s,{encodings:[{scaleResolutionDownBy:e.scaleResolutionDownBy,maxBitrate:e.maxBitrate}]});return n&&t&&t(i),{isChanged:n,parameters:i}};function an(s){return e=>`sip:${e}@${s}`}const cn=(s,e)=>()=>Math.floor(Math.random()*(e-s))+s,be=s=>s.trim().replaceAll(" ","_"),En=cn(1e5,99999999),dn=s=>s.some(t=>{const{kind:n}=t;return n==="video"}),hn=s=>{const e=[];return s!==void 0&&s!==""&&e.push(`X-Vinteo-Remote: ${s}`),e},Sn="content-type",Tn="x-webrtc-enter-room",D="application/vinteo.webrtc.sharedesktop",ln="application/vinteo.webrtc.roomname",un="application/vinteo.webrtc.channels",gn="application/vinteo.webrtc.mediastate",Cn="application/vinteo.webrtc.refusal",Ue="application/vinteo.webrtc.maincam",_n="application/vinteo.webrtc.mic",Nn="application/vinteo.webrtc.uselic",An="X-WEBRTC-USE-LICENSE",Rn="X-WEBRTC-PARTICIPANT-NAME",Le="X-WEBRTC-INPUT-CHANNELS",He="X-WEBRTC-OUTPUT-CHANNELS",fn="X-WEBRTC-MAINCAM",In="X-WEBRTC-MIC",We="X-WEBRTC-SYNC",Pn="X-WEBRTC-MAINCAM-RESOLUTION",On="X-WEBRTC-MEDIA-STATE",mn="X-Vinteo-Media-Type",Mn="X-Vinteo-MainCam-State",Dn="X-Vinteo-Mic-State",pn="application/vinteo.webrtc.partstate",vn="X-WEBRTC-PARTSTATE",yn="application/vinteo.webrtc.notify",wn="X-VINTEO-NOTIFY",f="x-webrtc-share-state",bn=`${f}: LETMESTARTPRESENTATION`,Un=`${f}: STOPPRESENTATION`,ft="YOUCANRECEIVECONTENT",It="CONTENTEND",Pt="YOUMUSTSTOPSENDCONTENT",Ln=`${f}: ${Pt}`,Hn=`${f}: ${ft}`,Wn=`${f}: ${It}`,kn="X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE",Bn=`${kn}: LETMESTARTMAINCAM`,Fn=(s,e)=>{s.getVideoTracks().forEach(n=>{"contentHint"in n&&n.contentHint!==e&&(n.contentHint=e)})},p=(s,{directionVideo:e,directionAudio:t,contentHint:n}={})=>{if(!s||e==="recvonly"&&t==="recvonly")return;const i=t==="recvonly"?[]:s.getAudioTracks(),r=e==="recvonly"?[]:s.getVideoTracks(),a=[...i,...r],c=new MediaStream(a);return c.getTracks=()=>[...c.getAudioTracks(),...c.getVideoTracks()],n&&n!=="none"&&Fn(c,n),c},xn="Error decline with 603",Vn=1006,Yn=s=>typeof s=="object"&&s!==null&&"code"in s&&s.code===Vn,qn=s=>s.message===xn,$n=(s,e)=>s.find(t=>t.track&&e.getTracks().includes(t.track)),Gn=async(s,e,t)=>{const n=$n(s,e);if(n)return Rt(n,{maxBitrate:t})},Jn=486,Xn=487,Qn=3,zn=1,jn=s=>s instanceof Object&&("originator"in s||"cause"in s),Kn=s=>{if(Mt.isCanceledError(s))return!0;if(!jn(s))return!1;const{originator:e,cause:t}=s;return typeof t=="string"?t===ke||t===X||e===_.LOCAL&&(t===Q||t===Fe):!1},Zn=s=>G.hasCanceledError(s),es="channels",ts="WebcastStarted",ns="WebcastStopped",ss="accountChanged",is="accountDeleted",rs="addedToListModerators",os="removedFromListModerators",as="ParticipationRequestAccepted",cs="ParticipationRequestRejected",Es="ParticipantMovedToWebcast",ds="ConferenceParticipantTokenIssued";class hs{constructor({JsSIP:e}){o(this,"promisePendingStartPresentation");o(this,"promisePendingStopPresentation");o(this,"ua");o(this,"rtcSession");o(this,"incomingRTCSession");o(this,"streamPresentationCurrent");o(this,"socket");o(this,"isRegisterConfigInner",!1);o(this,"connectionConfiguration",{});o(this,"remoteStreams",{});o(this,"JsSIP");o(this,"sessionEvents");o(this,"uaEvents");o(this,"cancelableConnectWithRepeatedCalls");o(this,"cancelableSendPresentationWithRepeatedCalls");o(this,"isPendingConnect",!1);o(this,"isPendingInitUa",!1);o(this,"isPendingCall",!1);o(this,"isPendingAnswer",!1);o(this,"connect",async(e,t)=>(this.cancelRequests(),this.connectWithDuplicatedCalls(e,t)));o(this,"hangUp",async()=>(this.cancelRequests(),this.hangUpWithoutCancelRequests()));o(this,"tryRegister",async()=>{if(!this.isRegisterConfig)throw new Error("Config is not registered");this.uaEvents.trigger(F,void 0);try{await this.unregister()}catch(e){v("tryRegister",e)}return this.register()});o(this,"declineToIncomingCall",async({statusCode:e=Xn}={})=>new Promise((t,n)=>{try{const i=this.getIncomingRTCSession(),r=this.remoteCallerData;this.removeIncomingSession(),this.uaEvents.trigger(j,r),i.terminate({status_code:e}),t()}catch(i){n(i)}}));o(this,"busyIncomingCall",async()=>this.declineToIncomingCall({statusCode:Jn}));o(this,"set",async({displayName:e,password:t})=>new Promise((n,i)=>{const{ua:r}=this;if(!r){i(new Error("this.ua is not initialized"));return}let a=!1,c=!1;e!==void 0&&e!==this.connectionConfiguration.displayName&&(a=r.set("display_name",be(e)),this.connectionConfiguration.displayName=e),t!==void 0&&t!==this.connectionConfiguration.password&&(c=r.set("password",t),this.connectionConfiguration.password=t);const E=a||c;c&&this.isRegisterConfig?this.register().then(()=>{n(E)}).catch(d=>{i(d)}):E?n(E):i(new Error("nothing changed"))}));o(this,"disconnect",async()=>{this.off(y,this.handleNewRTCSession);const e=new Promise(n=>{this.once(C,()=>{n()})}),{ua:t}=this;return t?(await this.hangUpWithoutCancelRequests(),t.stop()):this.uaEvents.trigger(C,void 0),e.finally(()=>{delete this.ua})});o(this,"call",async({number:e,mediaStream:t,extraHeaders:n=[],ontrack:i,iceServers:r,directionVideo:a,directionAudio:c,contentHint:E,offerToReceiveAudio:d=!0,offerToReceiveVideo:T=!0,sendEncodings:l,onAddedTransceiver:S})=>(this.isPendingCall=!0,new Promise((u,h)=>{const{ua:g}=this;if(!g){h(new Error("this.ua is not initialized"));return}this.connectionConfiguration.number=e,this.connectionConfiguration.answer=!1,this.handleCall({ontrack:i}).then(u).catch(N=>{h(N)}),this.rtcSession=g.call(this.getSipServerUrl(e),{extraHeaders:n,mediaStream:p(t,{directionVideo:a,directionAudio:c,contentHint:E}),eventHandlers:this.sessionEvents.triggers,directionVideo:a,directionAudio:c,pcConfig:{iceServers:r},rtcOfferConstraints:{offerToReceiveAudio:d,offerToReceiveVideo:T},sendEncodings:l,onAddedTransceiver:S})}).finally(()=>{this.isPendingCall=!1})));o(this,"answerToIncomingCall",async({mediaStream:e,ontrack:t,extraHeaders:n=[],iceServers:i,directionVideo:r,directionAudio:a,offerToReceiveAudio:c,offerToReceiveVideo:E,contentHint:d,sendEncodings:T,onAddedTransceiver:l})=>(this.isPendingAnswer=!0,new Promise((S,u)=>{try{const h=this.getIncomingRTCSession();this.rtcSession=h,this.removeIncomingSession(),this.sessionEvents.eachTriggers((N,q)=>{const I=pe.find($=>$===q);I&&h.on(I,N)}),this.connectionConfiguration.answer=!0,this.connectionConfiguration.number=h.remote_identity.uri.user,this.handleCall({ontrack:t}).then(S).catch(N=>{u(N)});const g=p(e,{directionVideo:r,directionAudio:a,contentHint:d});h.answer({extraHeaders:n,directionVideo:r,directionAudio:a,mediaStream:g,pcConfig:{iceServers:i},rtcOfferConstraints:{offerToReceiveAudio:c,offerToReceiveVideo:E},sendEncodings:T,onAddedTransceiver:l})}catch(h){u(h)}}).finally(()=>{this.isPendingAnswer=!1})));o(this,"sendDTMF",async e=>new Promise((t,n)=>{const{rtcSession:i}=this;if(!i){n(new Error("No rtcSession established"));return}this.onceSession(me,({originator:r})=>{r===_.LOCAL&&t()}),i.sendDTMF(e,{duration:120,interToneGap:600})}));o(this,"removeIncomingSession",()=>{delete this.incomingRTCSession});o(this,"getSipServerUrl",e=>e);o(this,"connectWithDuplicatedCalls",async(e,{callLimit:t=Qn}={})=>{const n=async()=>this.connectInner(e),i=r=>{var d;const c=((d=this.ua)==null?void 0:d.isConnected())===!0&&this.hasEqualConnectionConfiguration(e),E=r!=null&&!Yn(r);return c||E};return this.isPendingConnect=!0,this.cancelableConnectWithRepeatedCalls=G.repeatedCallsAsync({targetFunction:n,isComplete:i,callLimit:t,isRejectAsValid:!0,isCheckBeforeCall:!1}),this.cancelableConnectWithRepeatedCalls.then(r=>{if(r instanceof this.JsSIP.UA)return r;throw r}).finally(()=>{this.isPendingConnect=!1})});o(this,"handleNewRTCSession",({originator:e,session:t})=>{if(e===_.REMOTE){this.incomingRTCSession=t;const n=this.remoteCallerData;t.on(A,i=>{this.removeIncomingSession(),i.originator===_.LOCAL?this.uaEvents.trigger(Z,n):this.uaEvents.trigger(K,n)}),this.uaEvents.trigger(z,n)}});o(this,"connectInner",async e=>this.initUa(e).then(async()=>this.start()));o(this,"initUa",async({user:e,password:t,sipServerUrl:n,sipWebSocketServerURL:i,remoteAddress:r,sessionTimers:a,registerExpires:c,connectionRecoveryMinInterval:E,connectionRecoveryMaxInterval:d,userAgent:T,displayName:l="",register:S=!1,extraHeaders:u=[]})=>{if(!n)throw new Error("sipServerUrl is required");if(!i)throw new Error("sipWebSocketServerURL is required");if(S&&(e===void 0||e===""))throw new Error("user is required for authorized connection");if(S&&(t===void 0||t===""))throw new Error("password is required for authorized connection");this.isPendingInitUa=!0;try{this.connectionConfiguration={sipServerUrl:n,displayName:l,register:S,user:e,password:t};const{configuration:h,helpers:g}=this.createUaConfiguration({user:e,sipServerUrl:n,sipWebSocketServerURL:i,password:t,displayName:l,register:S,sessionTimers:a,registerExpires:c,connectionRecoveryMinInterval:E,connectionRecoveryMaxInterval:d,userAgent:T});return this.getSipServerUrl=g.getSipServerUrl,this.socket=g.socket,this.ua&&await this.disconnect(),this.isRegisterConfigInner=!!S,this.ua=this.createUa({...h,remoteAddress:r,extraHeaders:u}),this.uaEvents.eachTriggers((N,q)=>{const I=Y.find($=>$===q);I&&this.ua&&this.ua.on(I,N)}),this.ua}finally{this.isPendingInitUa=!1}});o(this,"createUa",({remoteAddress:e,extraHeaders:t=[],...n})=>{const i=new this.JsSIP.UA(n),a=[...e!==void 0&&e!==""?hn(e):[],...t];return a.length>0&&i.registrator().setExtraHeaders(a),i});o(this,"start",async()=>new Promise((e,t)=>{const{ua:n}=this;if(!n){t(new Error("this.ua is not initialized"));return}const i=()=>{c(),e(n)},r=E=>{c(),t(E)},a=()=>{this.isRegisterConfig?(this.on(O,i),this.on(m,r)):this.on(P,i),this.on(C,r)},c=()=>{this.off(O,i),this.off(m,r),this.off(P,i),this.off(C,r)};a(),this.on(y,this.handleNewRTCSession),n.start()}));o(this,"handleCall",async({ontrack:e})=>new Promise((t,n)=>{const i=()=>{this.onSession(H,T),this.onSession(L,l)},r=()=>{this.offSession(H,T),this.offSession(L,l)},a=()=>{this.onSession(A,E),this.onSession(M,E)},c=()=>{this.offSession(A,E),this.offSession(M,E)},E=S=>{r(),c(),n(S)};let d;const T=({peerconnection:S})=>{d=S,d.ontrack=u=>{this.sessionEvents.trigger(ce,d),e&&e(u)}},l=()=>{d!==void 0&&this.sessionEvents.trigger(ae,d),r(),c(),t(d)};i(),a()}));o(this,"restoreSession",()=>{this.cancelRequestsAndResetPresentation(),delete this.connectionConfiguration.number,delete this.rtcSession,this.remoteStreams={}});o(this,"hangUpWithoutCancelRequests",async()=>{if(this.ua&&this.rtcSession){const{rtcSession:e}=this;if(this.streamPresentationCurrent)try{await this.stopPresentation()}catch(t){v("error stop presentation: ",t)}if(this.restoreSession(),!e.isEnded())return e.terminateAsync({cause:Q})}});o(this,"handleShareState",e=>{switch(e){case ft:{this.sessionEvents.trigger(ne,void 0);break}case It:{this.sessionEvents.trigger(se,void 0);break}case Pt:{this.sessionEvents.trigger(ie,void 0);break}}});o(this,"maybeTriggerChannels",e=>{const t=e.getHeader(Le),n=e.getHeader(He);if(t&&n){const i={inputChannels:t,outputChannels:n};this.sessionEvents.trigger(b,i)}});o(this,"handleNotify",e=>{switch(e.cmd){case es:{const t=e;this.triggerChannelsNotify(t);break}case ts:{const t=e;this.triggerWebcastStartedNotify(t);break}case ns:{const t=e;this.triggerWebcastStoppedNotify(t);break}case rs:{const t=e;this.triggerAddedToListModeratorsNotify(t);break}case os:{const t=e;this.triggerRemovedFromListModeratorsNotify(t);break}case as:{const t=e;this.triggerParticipationAcceptingWordRequest(t);break}case cs:{const t=e;this.triggerParticipationCancellingWordRequest(t);break}case Es:{const t=e;this.triggerParticipantMoveRequestToStream(t);break}case ss:{this.triggerAccountChangedNotify();break}case is:{this.triggerAccountDeletedNotify();break}case ds:{const t=e;this.triggerConferenceParticipantTokenIssued(t);break}default:v("unknown cmd",e.cmd)}});o(this,"triggerRemovedFromListModeratorsNotify",({conference:e})=>{const t={conference:e};this.uaEvents.trigger(Ce,t)});o(this,"triggerAddedToListModeratorsNotify",({conference:e})=>{const t={conference:e};this.uaEvents.trigger(ge,t)});o(this,"triggerWebcastStartedNotify",({body:{conference:e,type:t}})=>{const n={conference:e,type:t};this.uaEvents.trigger(Re,n)});o(this,"triggerWebcastStoppedNotify",({body:{conference:e,type:t}})=>{const n={conference:e,type:t};this.uaEvents.trigger(fe,n)});o(this,"triggerAccountChangedNotify",()=>{this.uaEvents.trigger(Ie,void 0)});o(this,"triggerAccountDeletedNotify",()=>{this.uaEvents.trigger(Pe,void 0)});o(this,"triggerConferenceParticipantTokenIssued",({body:{conference:e,participant:t,jwt:n}})=>{const i={conference:e,participant:t,jwt:n};this.uaEvents.trigger(Oe,i)});o(this,"triggerChannelsNotify",e=>{const t=e.input,n=e.output,i={inputChannels:t,outputChannels:n};this.uaEvents.trigger(Ee,i)});o(this,"triggerParticipationAcceptingWordRequest",({body:{conference:e}})=>{const t={conference:e};this.uaEvents.trigger(Ne,t)});o(this,"triggerParticipationCancellingWordRequest",({body:{conference:e}})=>{const t={conference:e};this.uaEvents.trigger(Ae,t)});o(this,"triggerParticipantMoveRequestToStream",({body:{conference:e}})=>{const t={conference:e};this.uaEvents.trigger(_e,t)});o(this,"triggerEnterRoom",e=>{const t=e.getHeader(Tn),n=e.getHeader(Rn);this.sessionEvents.trigger(re,{room:t,participantName:n})});o(this,"triggerShareState",e=>{const t=e.getHeader(f);this.sessionEvents.trigger(w,t)});o(this,"maybeTriggerParticipantMoveRequest",e=>{const t=e.getHeader(vn);t===dt&&this.sessionEvents.trigger(x,void 0),t===ht&&this.sessionEvents.trigger(V,void 0)});o(this,"triggerMainCamControl",e=>{const t=e.getHeader(fn),n=e.getHeader(We),i=n===B.ADMIN_SYNC_FORCED;if(t===R.ADMIN_START_MAIN_CAM){this.sessionEvents.trigger(Te,{isSyncForced:i});return}if(t===R.ADMIN_STOP_MAIN_CAM){this.sessionEvents.trigger(Se,{isSyncForced:i});return}(t===R.RESUME_MAIN_CAM||t===R.PAUSE_MAIN_CAM)&&n!==void 0&&this.sessionEvents.trigger(U,{isSyncForced:i});const r=e.getHeader(Pn);this.sessionEvents.trigger(he,{mainCam:t,resolutionMainCam:r})});o(this,"triggerMicControl",e=>{const t=e.getHeader(In),i=e.getHeader(We)===B.ADMIN_SYNC_FORCED;t===k.ADMIN_START_MIC?this.sessionEvents.trigger(ue,{isSyncForced:i}):t===k.ADMIN_STOP_MIC&&this.sessionEvents.trigger(le,{isSyncForced:i})});o(this,"triggerUseLicense",e=>{const t=e.getHeader(An);this.sessionEvents.trigger(oe,t)});o(this,"handleNewInfo",e=>{const{originator:t}=e;if(t!==_.REMOTE)return;const{request:n}=e,i=n.getHeader(Sn);if(i)switch(i){case ln:{this.triggerEnterRoom(n),this.maybeTriggerChannels(n);break}case yn:{this.maybeHandleNotify(n);break}case D:{this.triggerShareState(n);break}case Ue:{this.triggerMainCamControl(n);break}case _n:{this.triggerMicControl(n);break}case Nn:{this.triggerUseLicense(n);break}case pn:{this.maybeTriggerParticipantMoveRequest(n);break}}});o(this,"handleSipEvent",({request:e})=>{this.maybeHandleNotify(e)});o(this,"maybeHandleNotify",e=>{const t=e.getHeader(wn);if(t){const n=JSON.parse(t);this.handleNotify(n)}});o(this,"handleEnded",e=>{const{originator:t}=e;t===_.REMOTE&&this.sessionEvents.trigger(de,e),this.restoreSession()});this.JsSIP=e,this.sessionEvents=new we(ve),this.uaEvents=new we(ut),this.onSession(w,this.handleShareState),this.onSession(Me,this.handleNewInfo),this.on(te,this.handleSipEvent),this.onSession(A,this.handleEnded),this.onSession(M,this.handleEnded)}get connection(){var t;return(t=this.rtcSession)==null?void 0:t.connection}get remoteCallerData(){var e,t,n;return{displayName:(e=this.incomingRTCSession)==null?void 0:e.remote_identity.display_name,host:(t=this.incomingRTCSession)==null?void 0:t.remote_identity.uri.host,incomingNumber:(n=this.incomingRTCSession)==null?void 0:n.remote_identity.uri.user,rtcSession:this.incomingRTCSession}}get requested(){return this.isPendingInitUa||this.isPendingConnect||this.isPendingCall||this.isPendingAnswer}get establishedRTCSession(){var e;return((e=this.rtcSession)==null?void 0:e.isEstablished())===!0?this.rtcSession:void 0}get isRegistered(){return!!this.ua&&this.ua.isRegistered()}get isRegisterConfig(){return!!this.ua&&this.isRegisterConfigInner}get isCallActive(){return!!(this.ua&&this.rtcSession)}get isAvailableIncomingCall(){return!!this.incomingRTCSession}get isPendingPresentation(){return!!this.promisePendingStartPresentation||!!this.promisePendingStopPresentation}async register(){return new Promise((e,t)=>{this.isRegisterConfig&&this.ua?(this.ua.on(O,e),this.ua.on(m,t),this.ua.register()):t(new Error("Config is not registered"))})}async unregister(){return new Promise((e,t)=>{this.isRegistered&&this.ua?(this.ua.on(ee,e),this.ua.unregister()):t(new Error("ua is not registered"))})}async sendOptions(e,t,n){if(!this.ua)throw new Error("is not connected");return new Promise((i,r)=>{try{this.ua.sendOptions(e,t,{extraHeaders:n,eventHandlers:{succeeded:()=>{i()},failed:r}})}catch(a){r(a)}})}async ping(e,t){var i;if(!((i=this.ua)!=null&&i.configuration.uri))throw new Error("is not connected");const n=this.ua.configuration.uri;return this.sendOptions(n,e,t)}async checkTelephony({userAgent:e,displayName:t,sipServerUrl:n,sipWebSocketServerURL:i,remoteAddress:r,extraHeaders:a}){return new Promise((c,E)=>{const{configuration:d}=this.createUaConfiguration({sipWebSocketServerURL:i,displayName:t,userAgent:e,sipServerUrl:n}),T=this.createUa({...d,remoteAddress:r,extraHeaders:a}),l=()=>{const u=new Error("Telephony is not available");E(u)};T.once(C,l);const S=()=>{T.removeAllListeners(),T.once(C,c),T.stop()};T.once(P,S),T.start()})}async replaceMediaStream(e,t){if(!this.rtcSession)throw new Error("No rtcSession established");const{contentHint:n}=t??{},i=p(e,{contentHint:n});if(i===void 0)throw new Error("No preparedMediaStream");return this.rtcSession.replaceMediaStream(i,t)}async askPermissionToEnableCam(e={}){if(!this.rtcSession)throw new Error("No rtcSession established");const t=[Bn];return this.rtcSession.sendInfo(Ue,void 0,{noTerminateWhenError:!0,...e,extraHeaders:t}).catch(n=>{if(qn(n))throw n})}async startPresentation(e,{isNeedReinvite:t,isP2P:n,maxBitrate:i,contentHint:r,sendEncodings:a,onAddedTransceiver:c}={},E){const d=this.establishedRTCSession;if(!d)throw new Error("No rtcSession established");if(this.streamPresentationCurrent)throw new Error("Presentation is already started");return n===!0&&await this.sendMustStopPresentation(),this.sendPresentationWithDuplicatedCalls({rtcSession:d,stream:e,presentationOptions:{isNeedReinvite:t,isP2P:n,maxBitrate:i,contentHint:r,sendEncodings:a,onAddedTransceiver:c},options:E})}async stopPresentation({isP2P:e=!1}={}){this.cancelSendPresentationWithRepeatedCalls();const t=this.streamPresentationCurrent;let n=this.promisePendingStartPresentation??Promise.resolve(void 0);const i=e?[Wn]:[Un],r=this.establishedRTCSession;return r&&t&&(n=n.then(async()=>r.sendInfo(D,void 0,{extraHeaders:i})).then(async()=>r.stopPresentation(t)).catch(a=>{throw this.sessionEvents.trigger(W,a),a})),!r&&t&&this.sessionEvents.trigger(De,t),this.promisePendingStopPresentation=n,n.finally(()=>{this.resetPresentation()})}async updatePresentation(e,{isP2P:t,maxBitrate:n,contentHint:i,sendEncodings:r,onAddedTransceiver:a}={}){const c=this.establishedRTCSession;if(!c)throw new Error("No rtcSession established");if(!this.streamPresentationCurrent)throw new Error("Presentation has not started yet");return this.promisePendingStartPresentation&&await this.promisePendingStartPresentation,this.sendPresentation(c,e,{isP2P:t,maxBitrate:n,contentHint:i,isNeedReinvite:!1,sendEncodings:r,onAddedTransceiver:a})}on(e,t){return this.uaEvents.on(e,t)}once(e,t){return this.uaEvents.once(e,t)}onceRace(e,t){return this.uaEvents.onceRace(e,t)}async wait(e){return this.uaEvents.wait(e)}off(e,t){this.uaEvents.off(e,t)}onSession(e,t){return this.sessionEvents.on(e,t)}onceSession(e,t){return this.sessionEvents.once(e,t)}onceRaceSession(e,t){return this.sessionEvents.onceRace(e,t)}async waitSession(e){return this.sessionEvents.wait(e)}offSession(e,t){this.sessionEvents.off(e,t)}isConfigured(){return!!this.ua}getConnectionConfiguration(){return{...this.connectionConfiguration}}getRemoteStreams(){if(!this.connection)return;const t=this.connection.getReceivers().map(({track:n})=>n);return dn(t)?this.generateStreams(t):this.generateAudioStreams(t)}getIncomingRTCSession(){const{incomingRTCSession:e}=this;if(!e)throw new Error("No incomingRTCSession");return e}cancelSendPresentationWithRepeatedCalls(){var e;(e=this.cancelableSendPresentationWithRepeatedCalls)==null||e.cancel()}async waitChannels(){return this.waitSession(b)}async waitSyncMediaState(){return this.waitSession(U)}async sendChannels({inputChannels:e,outputChannels:t}){if(!this.rtcSession)throw new Error("No rtcSession established");const n=`${Le}: ${e}`,i=`${He}: ${t}`,r=[n,i];return this.rtcSession.sendInfo(un,void 0,{extraHeaders:r})}async sendMediaState({cam:e,mic:t},n={}){if(!this.rtcSession)throw new Error("No rtcSession established");const i=`${On}: currentstate`,r=`${Mn}: ${Number(e)}`,a=`${Dn}: ${Number(t)}`,c=[i,r,a];return this.rtcSession.sendInfo(gn,void 0,{noTerminateWhenError:!0,...n,extraHeaders:c})}async sendRefusalToTurnOn(e,t={}){if(!this.rtcSession)throw new Error("No rtcSession established");const c=[`${mn}: ${e==="mic"?0:1}`];return this.rtcSession.sendInfo(Cn,void 0,{noTerminateWhenError:!0,...t,extraHeaders:c})}async sendRefusalToTurnOnMic(e={}){if(!this.rtcSession)throw new Error("No rtcSession established");return this.sendRefusalToTurnOn("mic",{noTerminateWhenError:!0,...e})}async sendRefusalToTurnOnCam(e={}){if(!this.rtcSession)throw new Error("No rtcSession established");return this.sendRefusalToTurnOn("cam",{noTerminateWhenError:!0,...e})}async sendMustStopPresentation(){const e=this.establishedRTCSession;if(!e)throw new Error("No rtcSession established");await e.sendInfo(D,void 0,{extraHeaders:[Ln]})}async sendPresentationWithDuplicatedCalls({rtcSession:e,stream:t,presentationOptions:n,options:i={callLimit:zn}}){const r=async()=>this.sendPresentation(e,t,n),a=()=>!!this.streamPresentationCurrent;return this.cancelableSendPresentationWithRepeatedCalls=G.repeatedCallsAsync({targetFunction:r,isComplete:a,isRejectAsValid:!0,...i}),this.cancelableSendPresentationWithRepeatedCalls.then(c=>c)}hasEqualConnectionConfiguration(e){var i;const{configuration:t}=this.createUaConfiguration(e),n=(i=this.ua)==null?void 0:i.configuration;return(n==null?void 0:n.password)===t.password&&(n==null?void 0:n.register)===t.register&&n.uri.toString()===t.uri&&n.display_name===t.display_name&&n.user_agent===t.user_agent&&n.sockets===t.sockets&&n.session_timers===t.session_timers&&n.register_expires===t.register_expires&&n.connection_recovery_min_interval===t.connection_recovery_min_interval&&n.connection_recovery_max_interval===t.connection_recovery_max_interval}createUaConfiguration({user:e,password:t,sipWebSocketServerURL:n,displayName:i="",sipServerUrl:r,register:a=!1,sessionTimers:c=!1,registerExpires:E=60*5,connectionRecoveryMinInterval:d=2,connectionRecoveryMaxInterval:T=6,userAgent:l}){if(a&&(t===void 0||t===""))throw new Error("password is required for authorized connection");const S=a&&e!==void 0&&e.trim()!==""?e.trim():`${En()}`,u=an(r),h=u(S),g=new this.JsSIP.WebSocketInterface(n);return{configuration:{password:t,register:a,uri:h,display_name:be(i),user_agent:l,sdp_semantics:"unified-plan",sockets:[g],session_timers:c,register_expires:E,connection_recovery_min_interval:d,connection_recovery_max_interval:T},helpers:{socket:g,getSipServerUrl:u}}}async sendPresentation(e,t,{maxBitrate:n=St,isNeedReinvite:i=!0,isP2P:r=!1,contentHint:a="detail",sendEncodings:c,onAddedTransceiver:E}){const d=p(t,{contentHint:a});if(d===void 0)throw new Error("No streamPresentationCurrent");this.streamPresentationCurrent=d;const T=r?[Hn]:[bn],l=e.sendInfo(D,void 0,{extraHeaders:T}).then(async()=>e.startPresentation(d,i,{sendEncodings:c,onAddedTransceiver:E})).then(async()=>{const{connection:S}=this;if(!S)return;const u=S.getSenders();await Gn(u,t,n)}).then(()=>t).catch(S=>{throw this.removeStreamPresentationCurrent(),this.sessionEvents.trigger(W,S),S});return this.promisePendingStartPresentation=l,l.finally(()=>{this.promisePendingStartPresentation=void 0})}removeStreamPresentationCurrent(){delete this.streamPresentationCurrent}resetPresentation(){this.removeStreamPresentationCurrent(),this.promisePendingStartPresentation=void 0,this.promisePendingStopPresentation=void 0}cancelRequestsAndResetPresentation(){this.cancelSendPresentationWithRepeatedCalls(),this.resetPresentation()}generateStream(e,t){const{id:n}=e,i=this.remoteStreams[n]??new MediaStream;return t&&i.addTrack(t),i.addTrack(e),this.remoteStreams[n]=i,i}generateAudioStream(e){const{id:t}=e,n=this.remoteStreams[t]??new MediaStream;return n.addTrack(e),this.remoteStreams[t]=n,n}generateStreams(e){const t=[];return e.forEach((n,i)=>{if(n.kind==="audio")return;const r=n,a=e[i-1];let c;(a==null?void 0:a.kind)==="audio"&&(c=a);const E=this.generateStream(r,c);t.push(E)}),t}generateAudioStreams(e){return e.map(n=>this.generateAudioStream(n))}cancelRequests(){this.cancelConnectWithRepeatedCalls()}cancelConnectWithRepeatedCalls(){var e;(e=this.cancelableConnectWithRepeatedCalls)==null||e.cancel()}}exports.BAD_MEDIA_DESCRIPTION=xe;exports.EEventsMainCAM=R;exports.EEventsMic=k;exports.EEventsSyncMediaState=B;exports.EMimeTypesVideoCodecs=At;exports.EUseLicense=Nt;exports.NOT_FOUND=Be;exports.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS=V;exports.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS=x;exports.REJECTED=X;exports.SESSION_EVENT_NAMES=ve;exports.SipConnector=hs;exports.UA_JSSIP_EVENT_NAMES=Y;exports.causes=$t;exports.constants=Gt;exports.disableDebug=Qt;exports.enableDebug=Xt;exports.eventNames=Jt;exports.hasCanceledCallError=Kn;exports.hasCanceledStartPresentationError=Zn;exports.logger=v;exports.setEncodingsToSender=Rt;exports.setParametersToSender=_t;