1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5451],{44:e=>{"use strict";class t extends Error{constructor(e,t){super(),this.code=1,this.name="CONFIGURATION_ERROR",this.parameter=e,this.value=t,this.message=this.value?`Invalid value ${JSON.stringify(this.value)} for parameter "${this.parameter}"`:`Missing parameter: ${this.parameter}`}}class s extends Error{constructor(e){super(),this.code=2,this.name="INVALID_STATE_ERROR",this.status=e,this.message=`Invalid status: ${e}`}}class i extends Error{constructor(e){super(),this.code=3,this.name="NOT_SUPPORTED_ERROR",this.message=e}}class r extends Error{constructor(e){super(),this.code=4,this.name="NOT_READY_ERROR",this.message=e}}e.exports={ConfigurationError:t,InvalidStateError:s,NotSupportedError:i,NotReadyError:r}},507:(e,t,s)=>{"use strict";let i=s(4192);e.exports={USER_AGENT:`${i.title} ${i.version}`,SIP:"sip",SIPS:"sips",causes:{CONNECTION_ERROR:"Connection Error",REQUEST_TIMEOUT:"Request Timeout",SIP_FAILURE_CODE:"SIP Failure Code",INTERNAL_ERROR:"Internal Error",BUSY:"Busy",REJECTED:"Rejected",REDIRECTED:"Redirected",UNAVAILABLE:"Unavailable",NOT_FOUND:"Not Found",ADDRESS_INCOMPLETE:"Address Incomplete",INCOMPATIBLE_SDP:"Incompatible SDP",MISSING_SDP:"Missing SDP",AUTHENTICATION_ERROR:"Authentication Error",BYE:"Terminated",WEBRTC_ERROR:"WebRTC Error",CANCELED:"Canceled",NO_ANSWER:"No Answer",EXPIRES:"Expires",NO_ACK:"No ACK",DIALOG_ERROR:"Dialog Error",USER_DENIED_MEDIA_ACCESS:"User Denied Media Access",BAD_MEDIA_DESCRIPTION:"Bad Media Description",RTP_TIMEOUT:"RTP Timeout"},SIP_ERROR_CAUSES:{REDIRECTED:[300,301,302,305,380],BUSY:[486,600],REJECTED:[403,603],NOT_FOUND:[404,604],UNAVAILABLE:[480,410,408,430],ADDRESS_INCOMPLETE:[484,424],INCOMPATIBLE_SDP:[488,606],AUTHENTICATION_ERROR:[401,407]},ACK:"ACK",BYE:"BYE",CANCEL:"CANCEL",INFO:"INFO",INVITE:"INVITE",MESSAGE:"MESSAGE",NOTIFY:"NOTIFY",OPTIONS:"OPTIONS",REGISTER:"REGISTER",REFER:"REFER",UPDATE:"UPDATE",SUBSCRIBE:"SUBSCRIBE",DTMF_TRANSPORT:{INFO:"INFO",RFC2833:"RFC2833"},REASON_PHRASE:{100:"Trying",180:"Ringing",181:"Call Is Being Forwarded",182:"Queued",183:"Session Progress",199:"Early Dialog Terminated",200:"OK",202:"Accepted",204:"No Notification",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",305:"Use Proxy",380:"Alternative Service",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",410:"Gone",412:"Conditional Request Failed",413:"Request Entity Too Large",414:"Request-URI Too Long",415:"Unsupported Media Type",416:"Unsupported URI Scheme",417:"Unknown Resource-Priority",420:"Bad Extension",421:"Extension Required",422:"Session Interval Too Small",423:"Interval Too Brief",424:"Bad Location Information",428:"Use Identity Header",429:"Provide Referrer Identity",430:"Flow Failed",433:"Anonymity Disallowed",436:"Bad Identity-Info",437:"Unsupported Certificate",438:"Invalid Identity Header",439:"First Hop Lacks Outbound Support",440:"Max-Breadth Exceeded",469:"Bad Info Package",470:"Consent Needed",478:"Unresolvable Destination",480:"Temporarily Unavailable",481:"Call/Transaction Does Not Exist",482:"Loop Detected",483:"Too Many Hops",484:"Address Incomplete",485:"Ambiguous",486:"Busy Here",487:"Request Terminated",488:"Not Acceptable Here",489:"Bad Event",491:"Request Pending",493:"Undecipherable",494:"Security Agreement Required",500:"JsSIP Internal Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Server Time-out",505:"Version Not Supported",513:"Message Too Large",580:"Precondition Failure",600:"Busy Everywhere",603:"Decline",604:"Does Not Exist Anywhere",606:"Not Acceptable"},ALLOWED_METHODS:"INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY,SUBSCRIBE",ACCEPTED_BODY_TYPES:"application/sdp, application/dtmf-relay",MAX_FORWARDS:69,SESSION_EXPIRES:90,MIN_SESSION_EXPIRES:60,CONNECTION_RECOVERY_MAX_INTERVAL:30,CONNECTION_RECOVERY_MIN_INTERVAL:2}},608:e=>{"use strict";var t,s="object"==typeof Reflect?Reflect:null,i=s&&"function"==typeof s.apply?s.apply:function(e,t,s){return Function.prototype.apply.call(e,t,s)};t=s&&"function"==typeof s.ownKeys?s.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var r=Number.isNaN||function(e){return e!=e};function n(){n.init.call(this)}e.exports=n,e.exports.once=function(e,t){return new Promise(function(s,i){var r,n,o;function a(s){e.removeListener(t,h),i(s)}function h(){"function"==typeof e.removeListener&&e.removeListener("error",a),s([].slice.call(arguments))}m(e,t,h,{once:!0}),"error"!==t&&(r=e,n=a,o={once:!0},"function"==typeof r.on&&m(r,"error",n,o))})},n.EventEmitter=n,n.prototype._events=void 0,n.prototype._eventsCount=0,n.prototype._maxListeners=void 0;var o=10;function a(e){if("function"!=typeof e)throw TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function h(e){return void 0===e._maxListeners?n.defaultMaxListeners:e._maxListeners}function c(e,t,s,i){if(a(s),void 0===(n=e._events)?(n=e._events=Object.create(null),e._eventsCount=0):(void 0!==n.newListener&&(e.emit("newListener",t,s.listener?s.listener:s),n=e._events),o=n[t]),void 0===o)o=n[t]=s,++e._eventsCount;else if("function"==typeof o?o=n[t]=i?[s,o]:[o,s]:i?o.unshift(s):o.push(s),(r=h(e))>0&&o.length>r&&!o.warned){o.warned=!0;var r,n,o,c=Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=o.length,console&&console.warn&&console.warn(c)}return e}function u(){if(!this.fired)return(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0==arguments.length)?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _(e,t,s){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:s},r=u.bind(i);return r.listener=s,i.wrapFn=r,r}function l(e,t,s){var i=e._events;if(void 0===i)return[];var r=i[t];return void 0===r?[]:"function"==typeof r?s?[r.listener||r]:[r]:s?function(e){for(var t=Array(e.length),s=0;s<t.length;++s)t[s]=e[s].listener||e[s];return t}(r):p(r,r.length)}function d(e){var t=this._events;if(void 0!==t){var s=t[e];if("function"==typeof s)return 1;if(void 0!==s)return s.length}return 0}function p(e,t){for(var s=Array(t),i=0;i<t;++i)s[i]=e[i];return s}function m(e,t,s,i){if("function"==typeof e.on)i.once?e.once(t,s):e.on(t,s);else if("function"==typeof e.addEventListener)e.addEventListener(t,function r(n){i.once&&e.removeEventListener(t,r),s(n)});else throw TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}Object.defineProperty(n,"defaultMaxListeners",{enumerable:!0,get:function(){return o}
1,set:function(e){if("number"!=typeof e||e<0||r(e))throw RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");o=e}}),n.init=function(){(void 0===this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},n.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||r(e))throw RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},n.prototype.getMaxListeners=function(){return h(this)},n.prototype.emit=function(e){for(var t=[],s=1;s<arguments.length;s++)t.push(arguments[s]);var r="error"===e,n=this._events;if(void 0!==n)r=r&&void 0===n.error;else if(!r)return!1;if(r){if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var o,a=Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var h=n[e];if(void 0===h)return!1;if("function"==typeof h)i(h,this,t);else for(var c=h.length,u=p(h,c),s=0;s<c;++s)i(u[s],this,t);return!0},n.prototype.addListener=function(e,t){return c(this,e,t,!1)},n.prototype.on=n.prototype.addListener,n.prototype.prependListener=function(e,t){return c(this,e,t,!0)},n.prototype.once=function(e,t){return a(t),this.on(e,_(this,e,t)),this},n.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,_(this,e,t)),this},n.prototype.removeListener=function(e,t){var s,i,r,n,o;if(a(t),void 0===(i=this._events)||void 0===(s=i[e]))return this;if(s===t||s.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,s.listener||t));else if("function"!=typeof s){for(r=-1,n=s.length-1;n>=0;n--)if(s[n]===t||s[n].listener===t){o=s[n].listener,r=n;break}if(r<0)return this;0===r?s.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(s,r),1===s.length&&(i[e]=s[0]),void 0!==i.removeListener&&this.emit("removeListener",e,o||t)}return this},n.prototype.off=n.prototype.removeListener,n.prototype.removeAllListeners=function(e){var t,s,i;if(void 0===(s=this._events))return this;if(void 0===s.removeListener)return 0==arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==s[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete s[e]),this;if(0==arguments.length){var r,n=Object.keys(s);for(i=0;i<n.length;++i)"removeListener"!==(r=n[i])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=s[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},n.prototype.listeners=function(e){return l(this,e,!0)},n.prototype.rawListeners=function(e){return l(this,e,!1)},n.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):d.call(e,t)},n.prototype.listenerCount=d,n.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},903:(e,t,s)=>{"use strict";let i=s(608).EventEmitter,r=s(2211),n=s(8166),o=s(507),a=s(44),h=s(8775),c=s(5987),u=s(9308),_=s(1913),l=s(2226),d=s(7914),p=s(7503),m=s(1352),g=s(1736),T=s(3172),f=s(5347),E=new n("RTCSession"),S={STATUS_NULL:0,STATUS_INVITE_SENT:1,STATUS_1XX_RECEIVED:2,STATUS_INVITE_RECEIVED:3,STATUS_WAITING_FOR_ANSWER:4,STATUS_ANSWERED:5,STATUS_WAITING_FOR_ACK:6,STATUS_CANCELED:7,STATUS_TERMINATED:8,STATUS_CONFIRMED:9},R=["audio","video"];e.exports=class e extends i{static get C(){return S}constructor(e){E.debug("new"),super(),this._id=null,this._ua=e,this._status=S.STATUS_NULL,this._dialog=null,this._earlyDialogs={},this._contact=null,this._from_tag=null,this._to_tag=null,this._connection=null,this._connectionPromiseQueue=Promise.resolve(),this._request=null,this._is_canceled=!1,this._cancel_reason="",this._is_confirmed=!1,this._late_sdp=!1,this._rtcOfferConstraints=null,this._rtcAnswerConstraints=null,this._localMediaStream=null,this._localMediaStreamLocallyGenerated=!1,this._rtcReady=!0,this._iceReady=!1,this._timers={ackTimer:null,expiresTimer:null,invite2xxTimer:null,userNoAnswerTimer:null},this._direction=null,this._local_identity=null,this._remote_identity=null,this._start_time=null,this._end_time=null,this._tones=null,this._audioMuted=!1,this._videoMuted=!1,this._localHold=!1,this._remoteHold=!1,this._sessionTimers={enabled:this._ua.configuration.session_timers,refreshMethod:this._ua.configuration.session_timers_refresh_method,defaultExpires:o.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._referSubscribers={},this._data={}}get C(){return S}get causes(){return o.causes}get id(){return this._id}get connection(){return this._connection}get contact(){return this._contact}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}get start_time(){return this._start_time}get end_time(){return this._end_time}get data(){return this._data}set data(e){this._data=e}get status(){return this._status}isInProgress(){switch(this._status){case S.STATUS_NULL:case S.STATUS_INVITE_SENT:case S.STATUS_1XX_RECEIVED:case S.STATUS_INVITE_RECEIVED:case S.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}isEstablished(){switch(this._status){case S.STATUS_ANSWERED:case S.STATUS_WAITING_FOR_ACK:case S.STATUS_CONFIRMED:return!0;default:return!1}}isEnded(){switch(this._status){case S.STATUS_CANCELED:case S.STATUS_TERMINATED:return!0;default:return!1}}isMuted(){return{audio:this._audioMuted,video:this._videoMuted}}isOnHold(){return{local:this._localHold,remote:this._remoteHold}}
1connect(e,t={},s){E.debug("connect()");let i=e,r=c.cloneObject(t.eventHandlers),n=c.cloneArray(t.extraHeaders),h=c.cloneObject(t.mediaConstraints,{audio:!0,video:!0}),u=t.mediaStream||null,l=c.cloneObject(t.pcConfig,{iceServers:[]}),d=t.rtcConstraints||null,p=t.rtcOfferConstraints||null;if(this._rtcOfferConstraints=p,this._rtcAnswerConstraints=t.rtcAnswerConstraints||null,this._data=t.data||this._data,void 0===e)throw TypeError("Not enough arguments");if(this._status!==S.STATUS_NULL)throw new a.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new a.NotSupportedError("WebRTC not supported");if(!(e=this._ua.normalizeTarget(e)))throw TypeError(`Invalid target: ${i}`);for(let e in this._sessionTimers.enabled&&c.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=o.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=o.SESSION_EXPIRES),r)Object.prototype.hasOwnProperty.call(r,e)&&this.on(e,r[e]);this._from_tag=c.newTag();let m=t.anonymous||!1,g={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:m,outbound:!0}),m?(g.from_display_name="Anonymous",g.from_uri=new f("sip","anonymous","anonymous.invalid"),n.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),n.push("Privacy: id")):t.fromUserName&&(g.from_uri=new f("sip",t.fromUserName,this._ua.configuration.uri.host),n.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),t.fromDisplayName&&(g.from_display_name=t.fromDisplayName),n.push(`Contact: ${this._contact}`),n.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&n.push(`Session-Expires: ${this._sessionTimers.defaultExpires}${this._ua.configuration.session_timers_force_refresher?";refresher=uac":""}`),this._request=new _.InitialOutgoingInviteRequest(e,this._ua,g,n),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(l,d),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,s&&s(this),this._newRTCSession("local",this._request),this._sendInitialRequest(h,p,u)}init_incoming(e,t){let s;E.debug("init_incoming()");let i=e.hasHeader("Content-Type")?e.getHeader("Content-Type").toLowerCase():void 0;return e.body&&"application/sdp"!==i?void e.reply(415):(this._status=S.STATUS_INVITE_RECEIVED,this._from_tag=e.from_tag,this._id=e.call_id+this._from_tag,this._request=e,this._contact=this._ua.contact.toString(),e.hasHeader("expires")&&(s=1e3*e.getHeader("expires")),e.to_tag=c.newTag(),this._createDialog(e,"UAS",!0))?void(e.body?this._late_sdp=!1:this._late_sdp=!0,this._status=S.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{e.reply(408),this._failed("local",null,o.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),s&&(this._timers.expiresTimer=setTimeout(()=>{this._status===S.STATUS_WAITING_FOR_ANSWER&&(e.reply(487),this._failed("system",null,o.causes.EXPIRES))},s)),this._direction="incoming",this._local_identity=e.to,this._remote_identity=e.from,t&&t(this),this._newRTCSession("remote",e),this._status!==S.STATUS_TERMINATED&&(e.reply(180,null,[`Contact: ${this._contact}`]),this._progress("local",null))):void e.reply(500,"Missing Contact header field")}answer(e={}){E.debug("answer()");let t=this._request,s=c.cloneArray(e.extraHeaders),i=c.cloneObject(e.mediaConstraints),r=e.mediaStream||null,n=c.cloneObject(e.pcConfig,{iceServers:[]}),h=e.rtcConstraints||null,u=e.rtcAnswerConstraints||null,_=c.cloneObject(e.rtcOfferConstraints),l=!1,d=!1,p=!1,m=!1;if(this._rtcAnswerConstraints=u,this._rtcOfferConstraints=e.rtcOfferConstraints||null,this._data=e.data||this._data,"incoming"!==this._direction)throw new a.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==S.STATUS_WAITING_FOR_ANSWER)throw new a.InvalidStateError(this._status);if(this._sessionTimers.enabled&&c.isDecimal(e.sessionTimersExpires)&&(e.sessionTimersExpires>=o.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=e.sessionTimersExpires:this._sessionTimers.defaultExpires=o.SESSION_EXPIRES),this._status=S.STATUS_ANSWERED,!this._createDialog(t,"UAS"))return void t.reply(500,"Error creating dialog");clearTimeout(this._timers.userNoAnswerTimer),s.unshift(`Contact: ${this._contact}`);let g=t.parseSDP();for(let e of(Array.isArray(g.media)||(g.media=[g.media]),g.media))"audio"===e.type&&(l=!0,e.direction&&"sendrecv"!==e.direction||(p=!0)),"video"===e.type&&(d=!0,e.direction&&"sendrecv"!==e.direction||(m=!0));if(r&&!1===i.audio)for(let e of r.getAudioTracks())r.removeTrack(e);if(r&&!1===i.video)for(let e of r.getVideoTracks())r.removeTrack(e);r||void 0!==i.audio||(i.audio=p),r||void 0!==i.video||(i.video=m),r||l||_.offerToReceiveAudio||(i.audio=!1),r||d||_.offerToReceiveVideo||(i.video=!1),this._createRTCConnection(n,h),Promise.resolve().then(()=>
1r||(i.audio||i.video?(this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(i).catch(e=>{if(this._status===S.STATUS_TERMINATED)throw Error("terminated");throw t.reply(480),this._failed("local",null,o.causes.USER_DENIED_MEDIA_ACCESS),E.warn('emit "getusermediafailed" [error:%o]',e),this.emit("getusermediafailed",e),Error("getUserMedia() failed")})):void 0)).then(e=>{if(this._status===S.STATUS_TERMINATED)throw Error("terminated");this._localMediaStream=e,e&&e.getTracks().forEach(t=>{this._connection.addTrack(t,e)})}).then(()=>{if(this._late_sdp)return;let e={originator:"remote",type:"offer",sdp:t.body};E.debug('emit "sdp"'),this.emit("sdp",e);let s=new RTCSessionDescription({type:"offer",sdp:e.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(s)).catch(e=>{throw t.reply(488),this._failed("system",null,o.causes.WEBRTC_ERROR),E.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),this.emit("peerconnection:setremotedescriptionfailed",e),Error("peerconnection.setRemoteDescription() failed")}),this._connectionPromiseQueue}).then(()=>{if(this._status===S.STATUS_TERMINATED)throw Error("terminated");return(this._connecting(t),this._late_sdp)?this._createLocalDescription("offer",this._rtcOfferConstraints).catch(()=>{throw t.reply(500),Error("_createLocalDescription() failed")}):this._createLocalDescription("answer",u).catch(()=>{throw t.reply(500),Error("_createLocalDescription() failed")})}).then(e=>{if(this._status===S.STATUS_TERMINATED)throw Error("terminated");this._handleSessionTimersInIncomingRequest(t,s),t.reply(200,null,s,e,()=>{this._status=S.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(t,e),this._setACKTimer(),this._accepted("local")},()=>{this._failed("system",null,o.causes.CONNECTION_ERROR)})}).catch(e=>{this._status!==S.STATUS_TERMINATED&&(E.warn(`answer() failed: ${e.message}`),this._failed("system",e.message,o.causes.INTERNAL_ERROR))})}terminate(e={}){let t;E.debug("terminate()");let s=e.cause||o.causes.BYE,i=c.cloneArray(e.extraHeaders),r=e.body,n=e.status_code,u=e.reason_phrase;if(this._status===S.STATUS_TERMINATED)throw new a.InvalidStateError(this._status);switch(this._status){case S.STATUS_NULL:case S.STATUS_INVITE_SENT:case S.STATUS_1XX_RECEIVED:if(E.debug("canceling session"),n&&(n<200||n>=700))throw TypeError(`Invalid status_code: ${n}`);n&&(u=u||o.REASON_PHRASE[n]||"",t=`SIP ;cause=${n} ;text="${u}"`),this._status===S.STATUS_NULL||this._status===S.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=t):this._status===S.STATUS_1XX_RECEIVED&&this._request.cancel(t),this._status=S.STATUS_CANCELED,this._failed("local",null,o.causes.CANCELED);break;case S.STATUS_WAITING_FOR_ANSWER:case S.STATUS_ANSWERED:if(E.debug("rejecting session"),(n=n||480)<300||n>=700)throw TypeError(`Invalid status_code: ${n}`);this._request.reply(n,u,i,r),this._failed("local",null,o.causes.REJECTED);break;case S.STATUS_WAITING_FOR_ACK:case S.STATUS_CONFIRMED:if(E.debug("terminating session"),u=e.reason_phrase||o.REASON_PHRASE[n]||"",n&&(n<200||n>=700))throw TypeError(`Invalid status_code: ${n}`);if(n&&i.push(`Reason: SIP ;cause=${n}; text="${u}"`),this._status===S.STATUS_WAITING_FOR_ACK&&"incoming"===this._direction&&this._request.server_transaction.state!==h.C.STATUS_TERMINATED){let e=this._dialog;this.receiveRequest=({method:t})=>{t===o.ACK&&(this.sendRequest(o.BYE,{extraHeaders:i,body:r}),e.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===h.C.STATUS_TERMINATED&&(this.sendRequest(o.BYE,{extraHeaders:i,body:r}),e.terminate())}),this._ended("local",null,s),this._dialog=e,this._ua.newDialog(e)}else this.sendRequest(o.BYE,{extraHeaders:i,body:r}),this._ended("local",null,s)}}sendDTMF(e,t={}){E.debug("sendDTMF() | tones: %s",e);let s=t.duration||null,i=t.interToneGap||null,r=t.transportType||o.DTMF_TRANSPORT.INFO;if(void 0===e)throw TypeError("Not enough arguments");if(this._status!==S.STATUS_CONFIRMED&&this._status!==S.STATUS_WAITING_FOR_ACK&&this._status!==S.STATUS_1XX_RECEIVED)throw new a.InvalidStateError(this._status);if(r!==o.DTMF_TRANSPORT.INFO&&r!==o.DTMF_TRANSPORT.RFC2833)throw TypeError(`invalid transportType: ${r}`);if("number"==typeof e&&(e=e.toString()),!e||"string"!=typeof e||!e.match(/^[0-9A-DR#*,]+$/i))throw TypeError(`Invalid tones: ${e}`);if(s&&!c.isDecimal(s))throw TypeError(`Invalid tone duration: ${s}`);if(s?s<p.C.MIN_DURATION?(E.debug(`"duration" value is lower than the minimum allowed, setting it to ${p.C.MIN_DURATION} milliseconds`),s=p.C.MIN_DURATION):s>p.C.MAX_DURATION?(E.debug(`"duration" value is greater than the maximum allowed, setting it to ${p.C.MAX_DURATION} milliseconds`),s=p.C.MAX_DURATION):s=Math.abs(s):s=p.C.DEFAULT_DURATION,t.duration=s,i&&!c.isDecimal(i))throw TypeError(`Invalid interToneGap: ${i}`);if(i?i<p.C.MIN_INTER_TONE_GAP?(E.debug(`"interToneGap" value is lower than the minimum allowed, setting it to ${p.C.MIN_INTER_TONE_GAP} milliseconds`),i=p.C.MIN_INTER_TONE_GAP):i=Math.abs(i):i=p.C.DEFAULT_INTER_TONE_GAP,r===o.DTMF_TRANSPORT.RFC2833){let t=this._getDTMFRTPSender();t&&(e=t.toneBuffer+e,t.insertDTMF(e,s,i));return}if(this._tones){this._tones+=e;return}this._tones=e,(function e(){let r;if(this._status===S.STATUS_TERMINATED||!this._tones){this._tones=null;return}let n=this._tones[0];if(this._tones=this._tones.substring(1),","===n)r=2e3;else{let e=new p(this);t.eventHandlers={onFailed:()=>{this._tones=null}},e.send(n,t),r=s+i}setTimeout(e.bind(this),r)}).call(this)}sendInfo(e,t,s={}){if(E.debug("sendInfo()"),this._status!==S.STATUS_CONFIRMED&&this._status!==S.STATUS_WAITING_FOR_ACK&&this._status!==S.STATUS_1XX_RECEIVED)throw new a.InvalidStateError(this._status);new m(this).send(e,t,s)}mute(e={audio:!0,video:!1}){E.debug("mute()");let t=!1,s=!1;!1===this._audioMuted&&e.audio&&(t=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),!1===this._videoMuted&&e.video&&(s=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(!0===t||!0===s)&&this._onmute({audio:t,video:s})}unmute(e={audio:!0,video:!0}){E.debug("unmute()");let t=!1,s=!1;!0===this._audioMuted&&e.audio&&(t=!0,this._audioMuted=!1,!1===this._localHold&&this._toggleMuteAudio(!1)),!0===this._videoMuted&&e.video&&(s=!0,this._videoMuted=!1,!1===this._localHold&&this._toggleMuteVideo(!1)),(!0===t||!0===s)&&this._onunmute({audio:t,video:s})}hold(e={},t){if(E.debug("hold()"),this._status!==S.STATUS_WAITING_FOR_ACK&&this._status!==S.STATUS_CONFIRMED||
1!0===this._localHold||!this.isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");let s={succeeded:()=>{t&&t()},failed:()=>{this.terminate({cause:o.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return e.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:s,extraHeaders:e.extraHeaders}):this._sendReinvite({eventHandlers:s,extraHeaders:e.extraHeaders}),!0}unhold(e={},t){if(E.debug("unhold()"),this._status!==S.STATUS_WAITING_FOR_ACK&&this._status!==S.STATUS_CONFIRMED||!1===this._localHold||!this.isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");let s={succeeded:()=>{t&&t()},failed:()=>{this.terminate({cause:o.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return e.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:s,extraHeaders:e.extraHeaders}):this._sendReinvite({eventHandlers:s,extraHeaders:e.extraHeaders}),!0}renegotiate(e={},t){E.debug("renegotiate()");let s=e.rtcOfferConstraints||null;if(this._status!==S.STATUS_WAITING_FOR_ACK&&this._status!==S.STATUS_CONFIRMED||!this.isReadyToReOffer())return!1;let i={succeeded:()=>{t&&t()},failed:()=>{this.terminate({cause:o.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),e.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:i,rtcOfferConstraints:s,extraHeaders:e.extraHeaders}):this._sendReinvite({eventHandlers:i,rtcOfferConstraints:s,extraHeaders:e.extraHeaders}),!0}refer(e,t){E.debug("refer()");let s=e;if(this._status!==S.STATUS_WAITING_FOR_ACK&&this._status!==S.STATUS_CONFIRMED)return!1;if(!(e=this._ua.normalizeTarget(e)))throw TypeError(`Invalid target: ${s}`);let i=new T(this);i.sendRefer(e,t);let r=i.id;return this._referSubscribers[r]=i,i.on("requestFailed",()=>{delete this._referSubscribers[r]}),i.on("accepted",()=>{delete this._referSubscribers[r]}),i.on("failed",()=>{delete this._referSubscribers[r]}),i.on("authenticated",()=>{delete this._referSubscribers[r],r=i.id,this._referSubscribers[r]=i}),i}sendRequest(e,t){if(E.debug("sendRequest()"),this._dialog)return this._dialog.sendRequest(e,t);{let s=Object.values(this._earlyDialogs);return s.length>0?s[0].sendRequest(e,t):void E.warn("sendRequest() | no valid early dialog found")}}receiveRequest(e){if(E.debug("receiveRequest()"),e.method===o.CANCEL)(this._status===S.STATUS_WAITING_FOR_ANSWER||this._status===S.STATUS_ANSWERED)&&(this._status=S.STATUS_CANCELED,this._request.reply(487),this._failed("remote",e,o.causes.CANCELED));else switch(e.method){case o.ACK:if(this._status!==S.STATUS_WAITING_FOR_ACK)return;if(this._status=S.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!e.body){this.terminate({cause:o.causes.MISSING_SDP,status_code:400});break}let t={originator:"remote",type:"answer",sdp:e.body};E.debug('emit "sdp"'),this.emit("sdp",t);let s=new RTCSessionDescription({type:"answer",sdp:t.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(s)).then(()=>{this._is_confirmed||this._confirmed("remote",e)}).catch(e=>{this.terminate({cause:o.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),E.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),this.emit("peerconnection:setremotedescriptionfailed",e)})}else this._is_confirmed||this._confirmed("remote",e);break;case o.BYE:this._status===S.STATUS_CONFIRMED||this._status===S.STATUS_WAITING_FOR_ACK?(e.reply(200),this._ended("remote",e,o.causes.BYE)):this._status===S.STATUS_INVITE_RECEIVED||this._status===S.STATUS_WAITING_FOR_ANSWER?(e.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",e,o.causes.BYE)):e.reply(403,"Wrong Status");break;case o.INVITE:this._status===S.STATUS_CONFIRMED?e.hasHeader("replaces")?this._receiveReplaces(e):this._receiveReinvite(e):e.reply(403,"Wrong Status");break;case o.INFO:if(this._status===S.STATUS_1XX_RECEIVED||this._status===S.STATUS_WAITING_FOR_ANSWER||this._status===S.STATUS_ANSWERED||this._status===S.STATUS_WAITING_FOR_ACK||this._status===S.STATUS_CONFIRMED){let t=e.hasHeader("Content-Type")?e.getHeader("Content-Type").toLowerCase():void 0;t&&t.match(/^application\/dtmf-relay/i)?new p(this).init_incoming(e):void 0!==t?new m(this).init_incoming(e):e.reply(415)}else e.reply(403,"Wrong Status");break;case o.UPDATE:this._status===S.STATUS_CONFIRMED?this._receiveUpdate(e):e.reply(403,"Wrong Status");break;case o.REFER:this._status===S.STATUS_CONFIRMED?this._receiveRefer(e):e.reply(403,"Wrong Status");break;case o.NOTIFY:this._status===S.STATUS_CONFIRMED?this._receiveNotify(e):e.reply(403,"Wrong Status");break;default:e.reply(501)}}onTransportError(){E.warn("onTransportError()"),this._status!==S.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:o.causes.CONNECTION_ERROR,cause:o.causes.CONNECTION_ERROR})}onRequestTimeout(){E.warn("onRequestTimeout()"),this._status!==S.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:o.causes.REQUEST_TIMEOUT,cause:o.causes.REQUEST_TIMEOUT})}onDialogError(){E.warn("onDialogError()"),this._status!==S.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:o.causes.DIALOG_ERROR,cause:o.causes.DIALOG_ERROR})}
1newDTMF(e){E.debug("newDTMF()"),this.emit("newDTMF",e)}newInfo(e){E.debug("newInfo()"),this.emit("newInfo",e)}isReadyToReOffer(){return this._rtcReady?this._dialog?!0!==this._dialog.uac_pending_reply&&!0!==this._dialog.uas_pending_reply||(E.debug("isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):(E.debug("isReadyToReOffer() | session not established yet"),!1):(E.debug("isReadyToReOffer() | internal WebRTC status not ready"),!1)}_close(){if(E.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(E.debug("close() | closing local MediaStream"),c.closeMediaStream(this._localMediaStream)),this._status!==S.STATUS_TERMINATED){if(this._status=S.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(e){E.warn("close() | error closing the RTCPeerConnection: %o",e)}for(let e in this._timers)Object.prototype.hasOwnProperty.call(this._timers,e)&&clearTimeout(this._timers[e]);for(let e in clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog),this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,e)&&(this._earlyDialogs[e].terminate(),delete this._earlyDialogs[e]);for(let e in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,e)&&delete this._referSubscribers[e];this._ua.destroyRTCSession(this)}}_setInvite2xxTimer(e,t){let s=u.T1;this._timers.invite2xxTimer=setTimeout((function i(){this._status===S.STATUS_WAITING_FOR_ACK&&(e.reply(200,null,[`Contact: ${this._contact}`],t),s<u.T2&&(s*=2)>u.T2&&(s=u.T2),this._timers.invite2xxTimer=setTimeout(i.bind(this),s))}).bind(this),s)}_setACKTimer(){this._timers.ackTimer=setTimeout(()=>{this._status===S.STATUS_WAITING_FOR_ACK&&(E.debug("no ACK received, terminating the session"),clearTimeout(this._timers.invite2xxTimer),this.sendRequest(o.BYE),this._ended("remote",null,o.causes.NO_ACK))},u.TIMER_H)}_createRTCConnection(e,t){this._connection=new RTCPeerConnection(e,t),this._connection.addEventListener("iceconnectionstatechange",()=>{"failed"===this._connection.iceConnectionState&&this.terminate({cause:o.causes.RTP_TIMEOUT,status_code:408,reason_phrase:o.causes.RTP_TIMEOUT})}),E.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}_createLocalDescription(e,t){if(E.debug("createLocalDescription()"),"offer"!==e&&"answer"!==e)throw Error(`createLocalDescription() | invalid type "${e}"`);let s=this._connection;return this._rtcReady=!1,Promise.resolve().then(()=>"offer"===e?s.createOffer(t).catch(e=>(E.warn('emit "peerconnection:createofferfailed" [error:%o]',e),this.emit("peerconnection:createofferfailed",e),Promise.reject(e))):s.createAnswer(t).catch(e=>(E.warn('emit "peerconnection:createanswerfailed" [error:%o]',e),this.emit("peerconnection:createanswerfailed",e),Promise.reject(e)))).then(e=>s.setLocalDescription(e).catch(e=>(this._rtcReady=!0,E.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',e),this.emit("peerconnection:setlocaldescriptionfailed",e),Promise.reject(e)))).then(()=>{let i=t&&t.iceRestart;if("complete"===s.iceGatheringState&&!i||"gathering"===s.iceGatheringState&&this._iceReady){this._rtcReady=!0;let t={originator:"local",type:e,sdp:s.localDescription.sdp};return E.debug('emit "sdp"'),this.emit("sdp",t),Promise.resolve(t.sdp)}return new Promise(t=>{let i,r,n=!1;this._iceReady=!1;let o=()=>{if(n)return;s.removeEventListener("icecandidate",i),s.removeEventListener("icegatheringstatechange",r),n=!0,this._rtcReady=!0,this._iceReady=!0;let o={originator:"local",type:e,sdp:s.localDescription.sdp};E.debug('emit "sdp"'),this.emit("sdp",o),t(o.sdp)};s.addEventListener("icecandidate",i=e=>{let t=e.candidate;t?this.emit("icecandidate",{candidate:t,ready:o}):o()}),s.addEventListener("icegatheringstatechange",r=()=>{"complete"===s.iceGatheringState&&o()})})})}_createDialog(e,t,s){let i="UAS"===t?e.to_tag:e.from_tag,r="UAS"===t?e.from_tag:e.to_tag,n=e.call_id+i+r,a=this._earlyDialogs[n];if(s)if(a)return!0;else return(a=new l(this,e,t,l.C.STATUS_EARLY)).error?(E.debug(a.error),this._failed("remote",e,o.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[n]=a,!0);{if(this._from_tag=e.from_tag,this._to_tag=e.to_tag,a)return a.update(e,t),this._dialog=a,delete this._earlyDialogs[n],!0;let s=new l(this,e,t);return s.error?(E.debug(s.error),this._failed("remote",e,o.causes.INTERNAL_ERROR),!1):(this._dialog=s,!0)}}_receiveReinvite(e){E.debug("receiveReinvite()");let t=e.hasHeader("Content-Type")?e.getHeader("Content-Type").toLowerCase():void 0,s={request:e,callback:void 0,reject:(function(t={}){i=!0;let s=t.status_code||403,r=t.reason_phrase||"",n=c.cloneArray(t.extraHeaders);if(this._status!==S.STATUS_CONFIRMED)return!1;if(s<300||s>=700)throw TypeError(`Invalid status_code: ${s}`);e.reply(s,r,n)}).bind(this)},i=!1;
1if(this.emit("reinvite",s),!i){if(this._late_sdp=!1,!e.body){this._late_sdp=!0,this._remoteHold&&(this._remoteHold=!1,this._onunhold("remote")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",this._rtcOfferConstraints)).then(e=>{r.call(this,e)}).catch(()=>{e.reply(500)});return}if("application/sdp"!==t){E.debug("invalid Content-Type"),e.reply(415);return}this._processInDialogSdpOffer(e).then(e=>{this._status!==S.STATUS_TERMINATED&&r.call(this,e)}).catch(e=>{E.warn(e)})}function r(t){let i=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(e,i),this._late_sdp&&(t=this._mangleOffer(t)),e.reply(200,null,i,t,()=>{this._status=S.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(e,t),this._setACKTimer()}),"function"==typeof s.callback&&s.callback()}}_receiveUpdate(e){E.debug("receiveUpdate()");let t=e.hasHeader("Content-Type")?e.getHeader("Content-Type").toLowerCase():void 0,s={request:e,callback:void 0,reject:(function(t={}){i=!0;let s=t.status_code||403,r=t.reason_phrase||"",n=c.cloneArray(t.extraHeaders);if(this._status!==S.STATUS_CONFIRMED)return!1;if(s<300||s>=700)throw TypeError(`Invalid status_code: ${s}`);e.reply(s,r,n)}).bind(this)},i=!1;if(this.emit("update",s),!i){if(!e.body)return void r.call(this,null);if("application/sdp"!==t){E.debug("invalid Content-Type"),e.reply(415);return}this._processInDialogSdpOffer(e).then(e=>{this._status!==S.STATUS_TERMINATED&&r.call(this,e)}).catch(e=>{E.warn(e)})}function r(t){let i=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(e,i),e.reply(200,null,i,t),"function"==typeof s.callback&&s.callback()}}_processInDialogSdpOffer(e){E.debug("_processInDialogSdpOffer()");let t=e.parseSDP(),s=!1;for(let e of t.media){if(-1===R.indexOf(e.type))continue;let i=e.direction||t.direction||"sendrecv";if("sendonly"===i||"inactive"===i)s=!0;else{s=!1;break}}let i={originator:"remote",type:"offer",sdp:e.body};E.debug('emit "sdp"'),this.emit("sdp",i);let r=new RTCSessionDescription({type:"offer",sdp:i.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._status===S.STATUS_TERMINATED)throw Error("terminated");return this._connection.setRemoteDescription(r).catch(t=>{throw e.reply(488),E.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',t),this.emit("peerconnection:setremotedescriptionfailed",t),t})}).then(()=>{if(this._status===S.STATUS_TERMINATED)throw Error("terminated");!0===this._remoteHold&&!1===s?(this._remoteHold=!1,this._onunhold("remote")):!1===this._remoteHold&&!0===s&&(this._remoteHold=!0,this._onhold("remote"))}).then(()=>{if(this._status===S.STATUS_TERMINATED)throw Error("terminated");return this._createLocalDescription("answer",this._rtcAnswerConstraints).catch(t=>{throw e.reply(500),E.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',t),t})}).catch(e=>{E.warn("_processInDialogSdpOffer() failed [error: %o]",e)}),this._connectionPromiseQueue}_receiveRefer(t){if(E.debug("receiveRefer()"),!t.refer_to){E.debug("no Refer-To header field present in REFER"),t.reply(400);return}if(t.refer_to.uri.scheme!==o.SIP){E.debug("Refer-To header field points to a non-SIP URI scheme"),t.reply(416);return}t.reply(202);let s=new g(this,t.cseq);function i(r,n={}){if(r="function"==typeof r?r:null,this._status!==S.STATUS_WAITING_FOR_ACK&&this._status!==S.STATUS_CONFIRMED)return!1;let o=new e(this._ua);if(o.on("progress",({response:e})=>{s.notify(e.status_code,e.reason_phrase)}),o.on("accepted",({response:e})=>{s.notify(e.status_code,e.reason_phrase)}),o.on("_failed",({message:e,cause:t})=>{e?s.notify(e.status_code,e.reason_phrase):s.notify(487,t)}),t.refer_to.uri.hasHeader("replaces")){let e=decodeURIComponent(t.refer_to.uri.getHeader("replaces"));n.extraHeaders=c.cloneArray(n.extraHeaders),n.extraHeaders.push(`Replaces: ${e}`)}let a=t.refer_to.uri.clone();a.clearHeaders(),o.connect(a,n,r)}function r(){s.notify(603)}E.debug('emit "refer"'),this.emit("refer",{request:t,accept:(e,t)=>{i.call(this,e,t)},reject:()=>{r.call(this)}})}_receiveNotify(e){if(E.debug("receiveNotify()"),e.event||e.reply(400),"refer"===e.event.event){let t,s;if(e.event.params&&e.event.params.id)t=e.event.params.id,s=this._referSubscribers[t];else{if(1!==Object.keys(this._referSubscribers).length)return void e.reply(400,"Missing event id parameter");s=this._referSubscribers[Object.keys(this._referSubscribers)[0]]}if(!s)return void e.reply(481,"Subscription does not exist");s.receiveNotify(e),e.reply(200)}else e.reply(489)}_receiveReplaces(t){function s(s){if(this._status!==S.STATUS_WAITING_FOR_ACK&&this._status!==S.STATUS_CONFIRMED)return!1;let i=new e(this._ua);i.on("confirmed",()=>{this.terminate()}),i.init_incoming(t,s)}function i(){E.debug("Replaced INVITE rejected by the user"),t.reply(486)}
1E.debug("receiveReplaces()"),this.emit("replaces",{request:t,accept:e=>{s.call(this,e)},reject:()=>{i.call(this)}})}_sendInitialRequest(e,t,s){let i=new d(this._ua,this._request,{onRequestTimeout:()=>{this.onRequestTimeout()},onTransportError:()=>{this.onTransportError()},onAuthenticated:e=>{this._request=e},onReceiveResponse:e=>{this._receiveInviteResponse(e)}});Promise.resolve().then(()=>s||(e.audio||e.video?(this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(e).catch(e=>{if(this._status===S.STATUS_TERMINATED)throw Error("terminated");throw this._failed("local",null,o.causes.USER_DENIED_MEDIA_ACCESS),E.warn('emit "getusermediafailed" [error:%o]',e),this.emit("getusermediafailed",e),e})):void 0)).then(e=>{if(this._status===S.STATUS_TERMINATED)throw Error("terminated");return this._localMediaStream=e,e&&e.getTracks().forEach(t=>{this._connection.addTrack(t,e)}),this._connecting(this._request),this._createLocalDescription("offer",t).catch(e=>{throw this._failed("local",null,o.causes.WEBRTC_ERROR),e})}).then(e=>{if(this._is_canceled||this._status===S.STATUS_TERMINATED)throw Error("terminated");this._request.body=e,this._status=S.STATUS_INVITE_SENT,E.debug('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),i.send()}).catch(e=>{this._status!==S.STATUS_TERMINATED&&E.warn(e)})}_getDTMFRTPSender(){let e=this._connection.getSenders().find(e=>e.track&&"audio"===e.track.kind);return e&&e.dtmf?e.dtmf:void E.warn("sendDTMF() | no local audio track to send DTMF with")}_receiveInviteResponse(e){if(E.debug("receiveInviteResponse()"),this._dialog&&e.status_code>=200&&e.status_code<=299)if(this._dialog.id.call_id===e.call_id&&this._dialog.id.local_tag===e.from_tag&&this._dialog.id.remote_tag===e.to_tag)return void this.sendRequest(o.ACK);else{let t=new l(this,e,"UAC");return void 0!==t.error?void E.debug(t.error):(this.sendRequest(o.ACK),void this.sendRequest(o.BYE))}if(this._is_canceled)return void(e.status_code>=100&&e.status_code<200?this._request.cancel(this._cancel_reason):e.status_code>=200&&e.status_code<299&&this._acceptAndTerminate(e));if(this._status===S.STATUS_INVITE_SENT||this._status===S.STATUS_1XX_RECEIVED)switch(!0){case/^100$/.test(e.status_code):this._status=S.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(e.status_code):{if(!e.to_tag){E.debug("1xx response received without to tag");break}if(e.hasHeader("contact")&&!this._createDialog(e,"UAC",!0))break;if(this._status=S.STATUS_1XX_RECEIVED,!e.body){this._progress("remote",e);break}let t={originator:"remote",type:"answer",sdp:e.body};E.debug('emit "sdp"'),this.emit("sdp",t);let s=new RTCSessionDescription({type:"answer",sdp:t.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(s)).then(()=>this._progress("remote",e)).catch(e=>{E.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),this.emit("peerconnection:setremotedescriptionfailed",e)});break}case/^2[0-9]{2}$/.test(e.status_code):{if(this._status=S.STATUS_CONFIRMED,!e.body){this._acceptAndTerminate(e,400,o.causes.MISSING_SDP),this._failed("remote",e,o.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(e,"UAC"))break;let t={originator:"remote",type:"answer",sdp:e.body};E.debug('emit "sdp"'),this.emit("sdp",t);let s=new RTCSessionDescription({type:"answer",sdp:t.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if("stable"===this._connection.signalingState)return this._connection.createOffer(this._rtcOfferConstraints).then(e=>this._connection.setLocalDescription(e)).catch(t=>{this._acceptAndTerminate(e,500,t.toString()),this._failed("local",e,o.causes.WEBRTC_ERROR)})}).then(()=>{this._connection.setRemoteDescription(s).then(()=>{this._handleSessionTimersInIncomingResponse(e),this._accepted("remote",e),this.sendRequest(o.ACK),this._confirmed("local",null)}
1).catch(t=>{this._acceptAndTerminate(e,488,"Not Acceptable Here"),this._failed("remote",e,o.causes.BAD_MEDIA_DESCRIPTION),E.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',t),this.emit("peerconnection:setremotedescriptionfailed",t)})});break}default:{let t=c.sipErrorCause(e.status_code);this._failed("remote",e,t)}}}_sendReinvite(e={}){E.debug("sendReinvite()");let t=c.cloneArray(e.extraHeaders),s=c.cloneObject(e.eventHandlers),i=e.rtcOfferConstraints||this._rtcOfferConstraints||null,r=!1;function n(e){if(this._status===S.STATUS_TERMINATED||(this.sendRequest(o.ACK),r))return;if(this._handleSessionTimersInIncomingResponse(e),!e.body||!e.hasHeader("Content-Type")||"application/sdp"!==e.getHeader("Content-Type").toLowerCase())return void a.call(this);let t={originator:"remote",type:"answer",sdp:e.body};E.debug('emit "sdp"'),this.emit("sdp",t);let i=new RTCSessionDescription({type:"answer",sdp:t.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(i)).then(()=>{s.succeeded&&s.succeeded(e)}).catch(e=>{a.call(this),E.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),this.emit("peerconnection:setremotedescriptionfailed",e)})}function a(e){s.failed&&s.failed(e)}t.push(`Contact: ${this._contact}`),t.push("Content-Type: application/sdp"),this._sessionTimers.running&&t.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",i)).then(e=>{let s={originator:"local",type:"offer",sdp:e=this._mangleOffer(e)};E.debug('emit "sdp"'),this.emit("sdp",s),this.sendRequest(o.INVITE,{extraHeaders:t,body:e,eventHandlers:{onSuccessResponse:e=>{n.call(this,e),r=!0},onErrorResponse:e=>{a.call(this,e)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{a()})}_sendUpdate(e={}){E.debug("sendUpdate()");let t=c.cloneArray(e.extraHeaders),s=c.cloneObject(e.eventHandlers),i=e.rtcOfferConstraints||this._rtcOfferConstraints||null,r=e.sdpOffer||!1,n=!1;function a(e){if(this._status!==S.STATUS_TERMINATED&&!n)if(this._handleSessionTimersInIncomingResponse(e),r){if(!e.body||!e.hasHeader("Content-Type")||"application/sdp"!==e.getHeader("Content-Type").toLowerCase())return void h.call(this);let t={originator:"remote",type:"answer",sdp:e.body};E.debug('emit "sdp"'),this.emit("sdp",t);let i=new RTCSessionDescription({type:"answer",sdp:t.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(i)).then(()=>{s.succeeded&&s.succeeded(e)}).catch(e=>{h.call(this),E.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),this.emit("peerconnection:setremotedescriptionfailed",e)})}else s.succeeded&&s.succeeded(e)}function h(e){s.failed&&s.failed(e)}t.push(`Contact: ${this._contact}`),this._sessionTimers.running&&t.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),r?(t.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",i)).then(e=>{let s={originator:"local",type:"offer",sdp:e=this._mangleOffer(e)};E.debug('emit "sdp"'),this.emit("sdp",s),this.sendRequest(o.UPDATE,{extraHeaders:t,body:e,eventHandlers:{onSuccessResponse:e=>{a.call(this,e),n=!0},onErrorResponse:e=>{h.call(this,e)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{h.call(this)})):this.sendRequest(o.UPDATE,{extraHeaders:t,eventHandlers:{onSuccessResponse:e=>{a.call(this,e)},onErrorResponse:e=>{h.call(this,e)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}_acceptAndTerminate(e,t,s){E.debug("acceptAndTerminate()");let i=[];t&&(s=s||o.REASON_PHRASE[t]||"",i.push(`Reason: SIP ;cause=${t}; text="${s}"`)),(this._dialog||this._createDialog(e,"UAC"))&&(this.sendRequest(o.ACK),this.sendRequest(o.BYE,{extraHeaders:i})),this._status=S.STATUS_TERMINATED}_mangleOffer(e){if(!this._localHold&&!this._remoteHold)return e;if(e=r.parse(e),this._localHold&&!this._remoteHold)for(let t of(E.debug("mangleOffer() | me on hold, mangling offer"),e.media))-1!==R.indexOf(t.type)&&(t.direction?"sendrecv"===t.direction?t.direction="sendonly":"recvonly"===t.direction&&(t.direction="inactive"):t.direction="sendonly");else if(this._localHold&&this._remoteHold)for(let t of(E.debug("mangleOffer() | both on hold, mangling offer"),e.media))-1!==R.indexOf(t.type)&&(t.direction="inactive");else if(this._remoteHold)for(let t of(E.debug("mangleOffer() | remote on hold, mangling offer"),e.media))-1!==R.indexOf(t.type)&&(t.direction?"sendrecv"===t.direction?t.direction="recvonly":"recvonly"===t.direction&&(t.direction="inactive"):t.direction="recvonly");return r.write(e)}_setLocalMediaStatus(){let e=!0,t=!0;(this._localHold||this._remoteHold)&&(e=!1,t=!1),this._audioMuted&&(e=!1),this._videoMuted&&(t=!1),this._toggleMuteAudio(!e),this._toggleMuteVideo(!t)}_handleSessionTimersInIncomingRequest(e,t){let s;this._sessionTimers.enabled&&(e.session_expires&&e.session_expires>=o.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=e.session_expires,s=e.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,s="uas"),t.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${s}`),this._sessionTimers.refresher="uas"===s,this._runSessionTimer())}_handleSessionTimersInIncomingResponse(e){let t;this._sessionTimers.enabled&&(e.session_expires&&e.session_expires>=o.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=e.session_expires,t=e.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,t="uac"),this._sessionTimers.refresher="uac"===t,this._runSessionTimer())}_runSessionTimer(){let e=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(()=>{this._status!==S.STATUS_TERMINATED&&this.isReadyToReOffer()&&(E.debug("runSessionTimer() | sending session refresh request"),this._sessionTimers.refreshMethod===o.UPDATE?this._sendUpdate():this._sendReinvite())},500*e):this._sessionTimers.timer=setTimeout(()=>{this._status!==S.STATUS_TERMINATED&&(E.warn("runSessionTimer() | timer expired, terminating the session"),this.terminate({cause:o.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},1100*e)}_toggleMuteAudio(e){for(let t of this._connection.getSenders().filter(e=>e.track&&"audio"===e.track.kind))t.track.enabled=!e}_toggleMuteVideo(e){for(let t of this._connection.getSenders().filter(e=>e.track&&"video"===e.track.kind))t.track.enabled=!e}_newRTCSession(e,t){E.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:e,session:this,request:t})}_connecting(e){E.debug("session connecting"),E.debug('emit "connecting"'),this.emit
1("connecting",{request:e})}_progress(e,t){E.debug("session progress"),E.debug('emit "progress"'),this.emit("progress",{originator:e,response:t||null})}_accepted(e,t){E.debug("session accepted"),this._start_time=new Date,E.debug('emit "accepted"'),this.emit("accepted",{originator:e,response:t||null})}_confirmed(e,t){E.debug("session confirmed"),this._is_confirmed=!0,E.debug('emit "confirmed"'),this.emit("confirmed",{originator:e,ack:t||null})}_ended(e,t,s){E.debug("session ended"),this._end_time=new Date,this._close(),E.debug('emit "ended"'),this.emit("ended",{originator:e,message:t||null,cause:s})}_failed(e,t,s){E.debug("session failed"),E.debug('emit "_failed"'),this.emit("_failed",{originator:e,message:t||null,cause:s}),this._close(),E.debug('emit "failed"'),this.emit("failed",{originator:e,message:t||null,cause:s})}_onhold(e){E.debug("session onhold"),this._setLocalMediaStatus(),E.debug('emit "hold"'),this.emit("hold",{originator:e})}_onunhold(e){E.debug("session onunhold"),this._setLocalMediaStatus(),E.debug('emit "unhold"'),this.emit("unhold",{originator:e})}_onmute({audio:e,video:t}){E.debug("session onmute"),this._setLocalMediaStatus(),E.debug('emit "muted"'),this.emit("muted",{audio:e,video:t})}_onunmute({audio:e,video:t}){E.debug("session onunmute"),this._setLocalMediaStatus(),E.debug('emit "unmuted"'),this.emit("unmuted",{audio:e,video:t})}}},1236:(e,t,s)=>{"use strict";let i=s(8166),r=s(1447),n=new i("WebSocketInterface");e.exports=class{constructor(e){n.debug('new() [url:"%s"]',e),this._url=e,this._sip_uri=null,this._via_transport=null,this._ws=null;let t=r.parse(e,"absoluteURI");if(-1===t)throw n.warn(`invalid WebSocket URI: ${e}`),TypeError(`Invalid argument: ${e}`);if("wss"!==t.scheme&&"ws"!==t.scheme)throw n.warn(`invalid WebSocket URI scheme: ${t.scheme}`),TypeError(`Invalid argument: ${e}`);this._sip_uri=`sip:${t.host}${t.port?`:${t.port}`:""};transport=ws`,this._via_transport=t.scheme.toUpperCase()}get via_transport(){return this._via_transport}set via_transport(e){this._via_transport=e.toUpperCase()}get sip_uri(){return this._sip_uri}get url(){return this._url}connect(){if(n.debug("connect()"),this.isConnected())return void n.debug(`WebSocket ${this._url} is already connected`);if(this.isConnecting())return void n.debug(`WebSocket ${this._url} is connecting`);this._ws&&this.disconnect(),n.debug(`connecting to WebSocket ${this._url}`);try{this._ws=new WebSocket(this._url,"sip"),this._ws.binaryType="arraybuffer",this._ws.onopen=this._onOpen.bind(this),this._ws.onclose=this._onClose.bind(this),this._ws.onmessage=this._onMessage.bind(this),this._ws.onerror=this._onError.bind(this)}catch(e){this._onError(e)}}disconnect(){n.debug("disconnect()"),this._ws&&(this._ws.onopen=()=>{},this._ws.onclose=()=>{},this._ws.onmessage=()=>{},this._ws.onerror=()=>{},this._ws.close(),this._ws=null)}send(e){return(n.debug("send()"),this.isConnected())?(this._ws.send(e),!0):(n.warn("unable to send message, WebSocket is not open"),!1)}isConnected(){return this._ws&&this._ws.readyState===this._ws.OPEN}isConnecting(){return this._ws&&this._ws.readyState===this._ws.CONNECTING}_onOpen(){n.debug(`WebSocket ${this._url} connected`),this.onconnect()}_onClose({wasClean:e,code:t,reason:s}){n.debug(`WebSocket ${this._url} closed`),!1===e&&n.debug("WebSocket abrupt disconnection"),this.ondisconnect(!e,t,s)}_onMessage({data:e}){n.debug("received WebSocket message"),this.ondata(e)}_onError(e){n.warn(`WebSocket ${this._url} error: `,e)}}},1329:(e,t,s)=>{"use strict";let i=s(608).EventEmitter,r=s(8166),n=s(507),o=s(1913),a=s(5987),h=s(7914),c=s(44),u=s(5347),_=new r("Message");e.exports=class extends i{constructor(e){super(),this._ua=e,this._request=null,this._closed=!1,this._direction=null,this._local_identity=null,this._remote_identity=null,this._is_replied=!1,this._data={}}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}send(e,t,s={}){let i=e;if(void 0===e||void 0===t)throw TypeError("Not enough arguments");if(!(e=this._ua.normalizeTarget(e)))throw TypeError(`Invalid target: ${i}`);let r=a.cloneArray(s.extraHeaders),c=a.cloneObject(s.eventHandlers),_=s.contentType||"text/plain",l={};for(let e in s.fromUserName&&(l.from_uri=new u("sip",s.fromUserName,this._ua.configuration.uri.host),r.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),s.fromDisplayName&&(l.from_display_name=s.fromDisplayName),c)Object.prototype.hasOwnProperty.call(c,e)&&this.on(e,c[e]);r.push(`Content-Type: ${_}`),this._request=new o.OutgoingRequest(n.MESSAGE,e,this._ua,l,r),t&&(this._request.body=t);let d=new h(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:e=>{this._receiveResponse(e)}});this._newMessage("local",this._request),d.send()}init_incoming(e){this._request=e,this._newMessage("remote",e),this._is_replied||(this._is_replied=!0,e.reply(200)),this._close()}accept(e={}){let t=a.cloneArray(e.extraHeaders),s=e.body;if("incoming"!==this._direction)throw new c.NotSupportedError('"accept" not supported for outgoing Message');
1if(this._is_replied)throw Error("incoming Message already replied");this._is_replied=!0,this._request.reply(200,null,t,s)}reject(e={}){let t=e.status_code||480,s=e.reason_phrase,i=a.cloneArray(e.extraHeaders),r=e.body;if("incoming"!==this._direction)throw new c.NotSupportedError('"reject" not supported for outgoing Message');if(this._is_replied)throw Error("incoming Message already replied");if(t<300||t>=700)throw TypeError(`Invalid status_code: ${t}`);this._is_replied=!0,this._request.reply(t,s,i,r)}_receiveResponse(e){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(e.status_code):break;case/^2[0-9]{2}$/.test(e.status_code):this._succeeded("remote",e);break;default:{let t=a.sipErrorCause(e.status_code);this._failed("remote",e,t)}}}_onRequestTimeout(){this._closed||this._failed("system",null,n.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,n.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newMessage(e,t){"remote"===e?(this._direction="incoming",this._local_identity=t.to,this._remote_identity=t.from):"local"===e&&(this._direction="outgoing",this._local_identity=t.from,this._remote_identity=t.to),this._ua.newMessage(this,{originator:e,message:this,request:t})}_failed(e,t,s){_.debug("MESSAGE failed"),this._close(),_.debug('emit "failed"'),this.emit("failed",{originator:e,response:t||null,cause:s})}_succeeded(e,t){_.debug("MESSAGE succeeded"),this._close(),_.debug('emit "succeeded"'),this.emit("succeeded",{originator:e,response:t})}}},1352:(e,t,s)=>{"use strict";let i=s(608).EventEmitter,r=s(507),n=s(44),o=s(5987);e.exports=class extends i{constructor(e){super(),this._session=e,this._direction=null,this._contentType=null,this._body=null}get contentType(){return this._contentType}get body(){return this._body}send(e,t,s={}){if(this._direction="outgoing",void 0===e)throw TypeError("Not enough arguments");if(this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK)throw new n.InvalidStateError(this._session.status);this._contentType=e,this._body=t;let i=o.cloneArray(s.extraHeaders);i.push(`Content-Type: ${e}`),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(r.INFO,{extraHeaders:i,eventHandlers:{onSuccessResponse:e=>{this.emit("succeeded",{originator:"remote",response:e})},onErrorResponse:e=>{this.emit("failed",{originator:"remote",response:e})},onTransportError:()=>{this._session.onTransportError()},onRequestTimeout:()=>{this._session.onRequestTimeout()},onDialogError:()=>{this._session.onDialogError()}},body:t})}init_incoming(e){this._direction="incoming",this.request=e,e.reply(200),this._contentType=e.hasHeader("Content-Type")?e.getHeader("Content-Type").toLowerCase():void 0,this._body=e.body,this._session.newInfo({originator:"remote",info:this,request:e})}}},1736:(e,t,s)=>{"use strict";let i=s(8166),r=s(507),n=new i("RTCSession:ReferNotifier"),o={event_type:"refer",body_type:"message/sipfrag;version=2.0",expires:300};e.exports=class{constructor(e,t,s){this._session=e,this._id=t,this._expires=s||o.expires,this._active=!0,this.notify(100)}notify(e,t){let s;n.debug("notify()"),!1!==this._active&&(t=t||r.REASON_PHRASE[e]||"",s=e>=200?"terminated;reason=noresource":`active;expires=${this._expires}`,this._session.sendRequest(r.NOTIFY,{extraHeaders:[`Event: ${o.event_type};id=${this._id}`,`Subscription-State: ${s}`,`Content-Type: ${o.body_type}`],body:`SIP/2.0 ${e} ${t}`,eventHandlers:{onErrorResponse(){this._active=!1}}}))}}},1913:(e,t,s)=>{"use strict";let i=s(2211),r=s(8166),n=s(507),o=s(5987),a=s(7879),h=s(1447),c=new r("SIPMessage");class u{constructor(e,t,s,i,r,h){let c;if(!e||!t||!s)return null;i=i||{},this.ua=s,this.headers={},this.method=e,this.ruri=t,this.body=h,this.extraHeaders=o.cloneArray(r),this.ua.configuration.extra_headers&&(this.extraHeaders=this.extraHeaders.concat(this.ua.configuration.extra_headers)),i.route_set?this.setHeader("route",i.route_set):s.configuration.use_preloaded_route&&this.setHeader("route",`<${s.transport.sip_uri};lr>`),this.setHeader("via",""),this.setHeader("max-forwards",n.MAX_FORWARDS);let u=i.to_uri||t,_=i.to_tag?{tag:i.to_tag}:null,l=void 0!==i.to_display_name?i.to_display_name:null;this.to=new a(u,l,_),this.setHeader("to",this.to.toString());let d=i.from_uri||s.configuration.uri,p={tag:i.from_tag||o.newTag()};c=void 0!==i.from_display_name?i.from_display_name:s.configuration.display_name?s.configuration.display_name:null,this.from=new a(d,c,p),this.setHeader("from",this.from.toString());
1let m=i.call_id||s.configuration.jssip_id+o.createRandomToken(15);this.call_id=m,this.setHeader("call-id",m);let g=i.cseq||Math.floor(1e4*Math.random());this.cseq=g,this.setHeader("cseq",`${g} ${e}`)}setHeader(e,t){let s=RegExp(`^\\s*${e}\\s*:`,"i");for(let e=0;e<this.extraHeaders.length;e++)s.test(this.extraHeaders[e])&&this.extraHeaders.splice(e,1);this.headers[o.headerize(e)]=Array.isArray(t)?t:[t]}getHeader(e){let t=this.headers[o.headerize(e)];if(t){if(t[0])return t[0]}else{let t=RegExp(`^\\s*${e}\\s*:`,"i");for(let e of this.extraHeaders)if(t.test(e))return e.substring(e.indexOf(":")+1).trim()}}getHeaders(e){let t=this.headers[o.headerize(e)],s=[];if(t){for(let e of t)s.push(e);return s}{let t=RegExp(`^\\s*${e}\\s*:`,"i");for(let e of this.extraHeaders)t.test(e)&&s.push(e.substring(e.indexOf(":")+1).trim());return s}}hasHeader(e){if(this.headers[o.headerize(e)])return!0;{let t=RegExp(`^\\s*${e}\\s*:`,"i");for(let e of this.extraHeaders)if(t.test(e))return!0}return!1}parseSDP(e){return!e&&this.sdp||(this.sdp=i.parse(this.body||"")),this.sdp}toString(){let e=`${this.method} ${this.ruri} SIP/2.0\r 2`;for(let t in this.headers)if(Object.prototype.hasOwnProperty.call(this.headers,t))for(let s of this.headers[t])e+=`${t}: ${s}\r 3`;for(let t of this.extraHeaders)e+=`${t.trim()}\r 4`;let t=[];switch(this.method){case n.REGISTER:t.push("path","gruu");break;case n.INVITE:this.ua.configuration.session_timers&&t.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&t.push("gruu"),t.push("ice","replaces");break;case n.UPDATE:this.ua.configuration.session_timers&&t.push("timer"),t.push("ice")}t.push("outbound");let s=this.ua.configuration.user_agent||n.USER_AGENT;if(e+=`Allow: ${n.ALLOWED_METHODS}\r 5`,e+=`Supported: ${t}\r 6`,e+=`User-Agent: ${s}\r 7`,this.body){let t=o.str_utf8_length(this.body);e+=`Content-Length: ${t}\r 8\r 9`,e+=this.body}else e+="Content-Length: 0\r\n\r\n";return e}clone(){let e=new u(this.method,this.ruri,this.ua);return Object.keys(this.headers).forEach(function(t){e.headers[t]=this.headers[t].slice()},this),e.body=this.body,e.extraHeaders=o.cloneArray(this.extraHeaders),e.to=this.to,e.from=this.from,e.call_id=this.call_id,e.cseq=this.cseq,e}}class _ extends u{constructor(e,t,s,i,r){super(n.INVITE,e,t,s,i,r),this.transaction=null}cancel(e){this.transaction.cancel(e)}clone(){let e=new _(this.ruri,this.ua);return Object.keys(this.headers).forEach(function(t){e.headers[t]=this.headers[t].slice()},this),e.body=this.body,e.extraHeaders=o.cloneArray(this.extraHeaders),e.to=this.to,e.from=this.from,e.call_id=this.call_id,e.cseq=this.cseq,e.transaction=this.transaction,e}}class l{constructor(){this.data=null,this.headers=null,this.method=null,this.via=null,this.via_branch=null,this.call_id=null,this.cseq=null,this.from=null,this.from_tag=null,this.to=null,this.to_tag=null,this.body=null,this.sdp=null}addHeader(e,t){let s={raw:t};e=o.headerize(e),this.headers[e]?this.headers[e].push(s):this.headers[e]=[s]}getHeader(e){let t=this.headers[o.headerize(e)];if(t&&t[0])return t[0].raw}getHeaders(e){let t=this.headers[o.headerize(e)],s=[];if(!t)return[];for(let e of t)s.push(e.raw);return s}hasHeader(e){return!!this.headers[o.headerize(e)]}parseHeader(e,t=0){if(e=o.headerize(e),!this.headers[e])return void c.debug(`header "${e}" not present`);if(t>=this.headers[e].length)return void c.debug(`not so many "${e}" headers present`);let s=this.headers[e][t],i=s.raw;if(s.parsed)return s.parsed;let r=h.parse(i,e.replace(/-/g,"_"));if(-1!==r)return s.parsed=r,r;this.headers[e].splice(t,1),c.debug(`error parsing "${e}" header field with value "${i}"`)}s(e,t){return this.parseHeader(e,t)}setHeader(e,t){this.headers[o.headerize(e)]=[{raw:t}]}parseSDP(e){return!e&&this.sdp||(this.sdp=i.parse(this.body||"")),this.sdp}toString(){return this.data}}class d extends l{constructor(e){super(),this.ua=e,this.headers={},this.ruri=null,this.transport=null,this.server_transaction=null}reply(e,t,s,i,r,a){let h=[],c=this.getHeader("To");if(t=t||null,!(e=e||null)||e<100||e>699)throw TypeError(`Invalid status_code: ${e}`);if(t&&"string"!=typeof t&&!(t instanceof String))throw TypeError(`Invalid reason_phrase: ${t}`);t=t||n.REASON_PHRASE[e]||"",s=o.cloneArray(s),this.ua.configuration.extra_headers&&(s=s.concat(this.ua.configuration.extra_headers));let u=`SIP/2.0 ${e} ${t}\r 10`;if(this.method===n.INVITE&&e>100&&e<=200)for(let e of this.getHeaders("record-route"))u+=`Record-Route: ${e}\r 11`;for(let e of this.getHeaders("via"))u+=`Via: ${e}\r 12`;for(let t of(!this.to_tag&&e>100?c+=`;tag=${o.newTag()}`:this.to_tag&&!this.s("to").hasParam("tag")&&(c+=`;tag=${this.to_tag}`),u+=`To: ${c}\r 13`,u+=`From: ${this.getHeader("From")}\r 14`,u+=`Call-ID: ${this.call_id}\r 15`,u+=`CSeq: ${this.cseq} ${this.method}\r 16`,s))u+=`${t.trim()}\r 17`;switch(this.method){case n.INVITE:this.ua.configuration.session_timers&&h.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&h.push("gruu"),h.push("ice","replaces");break;case n.UPDATE:this.ua.configuration.session_timers&&h.push("timer"),i&&h.push("ice"),h.push("replaces")}if(h.push("outbound"),this.method===n.OPTIONS?(u+=`Allow: ${n.ALLOWED_METHODS}\r 18`,u+=`Accept: ${n.ACCEPTED_BODY_TYPES}\r 19`):405===e?u+=`Allow: ${n.ALLOWED_METHODS}\r 20`:415===e&&(u+=`Accept: ${n.ACCEPTED_BODY_TYPES}\r 21`),u+=`Supported: ${h}\r 22`,i){let e=o.str_utf8_length(i);u+="Content-Type: application/sdp\r\n",u+=`Content-Length: ${e}\r 23\r 24`,u+=i}else u+=`Content-Length: 0\r 25\r 26`;this.server_transaction.receiveResponse(e,u,r,a)}reply_sl(e=null,t=null){let s=this.getHeaders("via");if(!e||e<100||e>699)throw TypeError(`Invalid status_code: ${e}`);if(t&&"string"!=typeof t&&!(t instanceof String))throw TypeError(`Invalid reason_phrase: ${t}`);t=t||n.REASON_PHRASE[e]||"";let i=`SIP/2.0 ${e} ${t}\r 27`;for(let e of s)i+=`Via: ${e}\r 28`;let r=this.getHeader("To");if(!this.to_tag&&e>100?r+=`;tag=${o.newTag()}`:this.to_tag&&!this.s("to").hasParam("tag")&&(r+=`;tag=${this.to_tag}`),i+=`To: ${r}\r 29From: ${this.getHeader("From")}\r 30Call-ID: ${this.call_id}\r 31CSeq: ${this.cseq} ${this.method}\r 32`,this.ua.configuration.extra_headers)for(let e of this.ua.configuration.extra_headers)i+=`${e.trim()}\r 33`;i+=`Content-Length: 0\r 34\r 35`,this.transport.send(i)}}class p extends l{constructor(){super(),this.headers={},this.status_code=null,this.reason_phrase=null}}e.exports={OutgoingRequest:u,InitialOutgoingInviteRequest:_,IncomingRequest:d,IncomingResponse:p}},2068:(e,t,s)=>{"use strict";let i=s(608).EventEmitter,r=s(8166),n=s(507),o=s(1913),a=s(5987),h=s(7914),c=s(44),u=new r("Options");e.exports=class extends i{constructor(e){super(),this._ua=e,this._request=null,this._closed=!1,this._direction=null,this._local_identity=null,this._remote_identity=null,this._is_replied=!1,this._data={}}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}send(e,t,s={}){let i=e;if(void 0===e)throw TypeError("A target is required for OPTIONS");if(!(e=this._ua.normalizeTarget(e)))throw TypeError(`Invalid target: ${i}`);let r=a.cloneArray(s.extraHeaders),c=a.cloneObject(s.eventHandlers),u=s.contentType||"application/sdp";for(let e in c)Object.prototype.hasOwnProperty.call(c,e)&&this.on(e,c[e]);r.push(`Content-Type: ${u}`),this._request=new o.OutgoingRequest(n.OPTIONS,e,this._ua,null,r),t&&(this._request.body=t);let _=new h(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:e=>{this._receiveResponse(e)}});this._newOptions("local",this._request),_.send()}init_incoming(e){this._request=e,this._newOptions("remote",e),this._is_replied||(this._is_replied=!0,e.reply(200)),this._close()}accept(e={}){let t=a.cloneArray(e.extraHeaders),s=e.body;if("incoming"!==this._direction)throw new c.NotSupportedError('"accept" not supported for outgoing Options');if(this._is_replied)throw Error("incoming Options already replied");this._is_replied=!0,this._request.reply(200,null,t,s)}reject(e={}){let t=e.status_code||480,s=e.reason_phrase,i=a.cloneArray(e.extraHeaders),r=e.body;if("incoming"!==this._direction)throw new c.NotSupportedError('"reject" not supported for outgoing Options');if(this._is_replied)throw Error("incoming Options already replied");
35if(t<300||t>=700)throw TypeError(`Invalid status_code: ${t}`);this._is_replied=!0,this._request.reply(t,s,i,r)}_receiveResponse(e){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(e.status_code):break;case/^2[0-9]{2}$/.test(e.status_code):this._succeeded("remote",e);break;default:{let t=a.sipErrorCause(e.status_code);this._failed("remote",e,t)}}}_onRequestTimeout(){this._closed||this._failed("system",null,n.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,n.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newOptions(e,t){"remote"===e?(this._direction="incoming",this._local_identity=t.to,this._remote_identity=t.from):"local"===e&&(this._direction="outgoing",this._local_identity=t.from,this._remote_identity=t.to),this._ua.newOptions(this,{originator:e,message:this,request:t})}_failed(e,t,s){u.debug("OPTIONS failed"),this._close(),u.debug('emit "failed"'),this.emit("failed",{originator:e,response:t||null,cause:s})}_succeeded(e,t){u.debug("OPTIONS succeeded"),this._close(),u.debug('emit "succeeded"'),this.emit("succeeded",{originator:e,response:t})}}},2202:e=>{var t=e.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=(null!=e.raddr?" raddr %s rport %d":"%v%v")+(null!=e.tcptype?" tcptype %s":"%v"),null!=e.generation&&(t+=" generation %d"),t+=(null!=e["network-id"]?" network-id %d":"%v")+(null!=e["network-cost"]?" network-cost %d":"%v")}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","max
35MessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+((null!=e.id?"id=%s %s":"%v%s")+(null!=e.mediaClockValue?"=%s":"")+(null!=e.rateNumerator?" rate=%s":"")+(null!=e.rateDenominator?"/%s":""))}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(t).forEach(function(e){t[e].forEach(function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")})})},2211:(e,t,s)=>{var i=s(3170),r=s(6194);t.grammar=s(2202),t.write=r,t.parse=i.parse,t.parseParams=i.parseParams,t.parseFmtpConfig=i.parseFmtpConfig,t.parsePayloads=i.parsePayloads,t.parseRemoteCandidates=i.parseRemoteCandidates,t.parseImageAttributes=i.parseImageAttributes,t.parseSimulcastStreamList=i.parseSimulcastStreamList},2226:(e,t,s)=>{"use strict";let i=s(8166),r=s(1913),n=s(507),o=s(8775),a=s(6454),h=s(5987),c=new i("Dialog"),u={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};e.exports=class{static get C(){return u}constructor(e,t,s,i=u.STATUS_CONFIRMED){if(this._owner=e,this._ua=e._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,!t.hasHeader("contact"))return{error:"unable to create a Dialog without Contact header field"};t instanceof r.IncomingResponse&&(i=t.status_code<200?u.STATUS_EARLY:u.STATUS_CONFIRMED);let n=t.parseHeader("contact");"UAS"===s?(this._id={call_id:t.call_id,local_tag:t.to_tag,remote_tag:t.from_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=i,this._remote_seqnum=t.cseq,this._local_uri=t.parseHeader("to").uri,this._remote_uri=t.parseHeader("from").uri,this._remote_target=n.uri,this._route_set=t.getHeaders("record-route"),this._incoming_ack_seqnum=t.cseq,this._outgoing_ack_seqnum=null):"UAC"===s&&(this._id={call_id:t.call_id,local_tag:t.from_tag,remote_tag:t.to_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=i,this._local_seqnum=t.cseq,this._local_uri=t.parseHeader("from").uri,this._remote_uri=t.parseHeader("to").uri,this._remote_target=n.uri,this._route_set=t.getHeaders("record-route").reverse(),this._incoming_ack_seqnum=null,this._outgoing_ack_seqnum=this._local_seqnum),this._ua.newDialog(this),c.debug(`new ${s} dialog created with status ${this._state===u.STATUS_EARLY?"EARLY":"CONFIRMED"}`)}get id(){return this._id}get local_seqnum(){return this._local_seqnum}set local_seqnum(e){this._local_seqnum=e}get owner(){return this._owner}get uac_pending_reply(){return this._uac_pending_reply}set uac_pending_reply(e){this._uac_pending_reply=e}get uas_pending_reply(){return this._uas_pending_reply}isTerminated(){return this._status===u.STATUS_TERMINATED}update(e,t){this._state=u.STATUS_CONFIRMED,c.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),"UAC"===t&&(this._route_set=e.getHeaders("record-route").reverse())}terminate(){c.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=u.STATUS_TERMINATED}
35sendRequest(e,t={}){let s=h.cloneArray(t.extraHeaders),i=h.cloneObject(t.eventHandlers),r=t.body||null,o=this._createRequest(e,s,r),c=i.onAuthenticated||(()=>{});return i.onAuthenticated=e=>{this._local_seqnum+=1,o.method===n.INVITE&&(this._outgoing_ack_seqnum=this._local_seqnum),c(e)},new a(this,o,i).send(),o}receiveRequest(e){this._checkInDialogRequest(e)&&(e.method===n.ACK&&null!==this._incoming_ack_seqnum?this._incoming_ack_seqnum=null:e.method===n.INVITE&&(this._incoming_ack_seqnum=e.cseq),this._owner.receiveRequest(e))}_createRequest(e,t,s){t=h.cloneArray(t),this._local_seqnum||(this._local_seqnum=Math.floor(1e4*Math.random()));let i=e===n.CANCEL||e===n.ACK?this._outgoing_ack_seqnum:this._local_seqnum+=1;return e===n.INVITE&&(this._outgoing_ack_seqnum=i),new r.OutgoingRequest(e,this._remote_target,this._ua,{cseq:i,call_id:this._id.call_id,from_uri:this._local_uri,from_tag:this._id.local_tag,to_uri:this._remote_uri,to_tag:this._id.remote_tag,route_set:this._route_set},t,s)}_checkInDialogRequest(e){if(this._remote_seqnum)if(e.cseq<this._remote_seqnum){if(e.method!==n.ACK)return e.reply(500),!1;else if(null===this._incoming_ack_seqnum||e.cseq!==this._incoming_ack_seqnum)return!1}else e.cseq>this._remote_seqnum&&(this._remote_seqnum=e.cseq);else this._remote_seqnum=e.cseq;if(e.method===n.INVITE||e.method===n.UPDATE&&e.body){if(!0===this._uac_pending_reply)e.reply(491);else if(!0===this._uas_pending_reply){let t=(10*Math.random()|0)+1;return e.reply(500,null,[`Retry-After:${t}`]),!1}else{this._uas_pending_reply=!0;let t=()=>{(e.server_transaction.state===o.C.STATUS_ACCEPTED||e.server_transaction.state===o.C.STATUS_COMPLETED||e.server_transaction.state===o.C.STATUS_TERMINATED)&&(e.server_transaction.removeListener("stateChanged",t),this._uas_pending_reply=!1)};e.server_transaction.on("stateChanged",t)}e.hasHeader("contact")&&e.server_transaction.on("stateChanged",()=>{e.server_transaction.state===o.C.STATUS_ACCEPTED&&(this._remote_target=e.parseHeader("contact").uri)})}else e.method===n.NOTIFY&&e.hasHeader("contact")&&e.server_transaction.on("stateChanged",()=>{e.server_transaction.state===o.C.STATUS_COMPLETED&&(this._remote_target=e.parseHeader("contact").uri)});return!0}}},3120:(e,t,s)=>{"use strict";let i=s(608).EventEmitter,r=s(44),n=s(8166),o=s(507),a=s(5987),h=s(2226),c=new n("Notifier"),u={NOTIFY_RESPONSE_TIMEOUT:0,NOTIFY_TRANSPORT_ERROR:1,NOTIFY_NON_OK_RESPONSE:2,NOTIFY_AUTHENTICATION_FAILED:3,FINAL_NOTIFY_SENT:4,UNSUBSCRIBE_RECEIVED:5,SUBSCRIPTION_EXPIRED:6,STATE_PENDING:0,STATE_ACTIVE:1,STATE_TERMINATED:2,DEFAULT_EXPIRES_SEC:900};e.exports=class e extends i{static get C(){return u}static init_incoming(t,s){try{e.checkSubscribe(t)}catch(e){c.warn("Notifier.init_incoming: invalid request. Error: ",e.message),t.reply(405);return}s()}static checkSubscribe(e){if(!e)throw TypeError("Not enough arguments. Missing subscribe request");if(e.method!==o.SUBSCRIBE)throw TypeError("Invalid method for Subscribe request");if(!e.hasHeader("contact"))throw TypeError("Missing Contact header in subscribe request");if(!e.hasHeader("event"))throw TypeError("Missing Event header in subscribe request");let t=e.getHeader("expires");if(t){let e=parseInt(t);if(!a.isDecimal(e)||e<0)throw TypeError("Invalid Expires header field in subscribe request")}}constructor(t,s,i,{extraHeaders:r,allowEvents:n,pending:o,defaultExpires:h}){if(c.debug("new"),super(),!i)throw TypeError("Not enough arguments. Missing contentType");e.checkSubscribe(s);let _=s.getHeader("event");this._ua=t,this._initial_subscribe=s,this._expires_timestamp=null,this._expires_timer=null,this._defaultExpires=h||u.DEFAULT_EXPIRES_SEC,this._state=o?u.STATE_PENDING:u.STATE_ACTIVE,this._content_type=i,this._headers=a.cloneArray(r),this._headers.push(`Event: ${_}`),this._contact=this._headers.find(e=>e.startsWith("Contact")),this._contact||(this._contact=`Contact: ${this._ua._contact.toString()}`,this._headers.push(this._contact)),n&&this._headers.push(`Allow-Events: ${n}`),this._target=s.from.uri.user,s.to_tag=a.newTag(),this._data={}}get C(){return u}get state(){return this._state}get id(){return this._dialog?this._dialog.id:null}get data(){return this._data}set data(e){this._data=e}receiveRequest(e){if(e.method!==o.SUBSCRIBE)return void e.reply(405);this._setExpires(e),this._dialog||(this._dialog=new h(this,e,"UAS")),e.reply(200,null,[`Expires: ${this._expires}`,`${this._contact}`]);let t=e.body,s=e.getHeader("content-type"),i=0===this._expires;i||this._setExpiresTimer(),c.debug('emit "subscribe"'),this.emit
35("subscribe",i,e,t,s),i&&this._terminateDialog(u.UNSUBSCRIBE_RECEIVED)}start(){if(c.debug("start()"),this._state===u.STATE_TERMINATED)throw new r.InvalidStateError(this._state);this.receiveRequest(this._initial_subscribe)}setActiveState(){if(c.debug("setActiveState()"),this._state===u.STATE_TERMINATED)throw new r.InvalidStateError(this._state);this._state===u.STATE_PENDING&&(this._state=u.STATE_ACTIVE)}notify(e=null){if(c.debug("notify()"),this._state===u.STATE_TERMINATED)throw new r.InvalidStateError(this._state);let t=Math.floor((this._expires_timestamp-new Date().getTime())/1e3);t<=0?(this._expires_timer||c.error("expires timer is not set"),clearTimeout(this._expires_timer),this.terminate(e,"timeout")):this._sendNotify([`;expires=${t}`],e)}terminate(e=null,t=null,s=null){if(c.debug("terminate()"),this._state===u.STATE_TERMINATED)return;let i=[];t&&i.push(`;reason=${t}`),null!==s&&i.push(`;retry-after=${s}`),this._sendNotify(i,e,null,"terminated"),this._terminateDialog("timeout"===t?u.SUBSCRIPTION_EXPIRED:u.FINAL_NOTIFY_SENT)}_terminateDialog(e){this._state!==u.STATE_TERMINATED&&(this._state=u.STATE_TERMINATED,clearTimeout(this._expires_timer),this._dialog&&(this._dialog.terminate(),this._dialog=null),c.debug(`emit "terminated" code=${e}`),this.emit("terminated",e))}_setExpires(e){e.hasHeader("expires")?this._expires=parseInt(e.getHeader("expires")):(this._expires=this._defaultExpires,c.debug(`missing Expires header field, default value set: ${this._expires}`))}_sendNotify(e,t=null,s=null,i=null){if(this._state===u.STATE_TERMINATED)return void c.warn("final notify already sent");let r=`Subscription-State: ${i||this._parseState()}`;for(let t of e)r+=t;let n=a.cloneArray(this._headers);n.push(r),s&&(n=n.concat(s)),t&&n.push(`Content-Type: ${this._content_type}`),this._dialog.sendRequest(o.NOTIFY,{body:t,extraHeaders:n,eventHandlers:{onRequestTimeout:()=>{this._terminateDialog(u.NOTIFY_RESPONSE_TIMEOUT)},onTransportError:()=>{this._terminateDialog(u.NOTIFY_TRANSPORT_ERROR)},onErrorResponse:e=>{401===e.status_code||407===e.status_code?this._terminateDialog(u.NOTIFY_AUTHENTICATION_FAILED):this._terminateDialog(u.NOTIFY_NON_OK_RESPONSE)},onDialogError:()=>{this._terminateDialog(u.NOTIFY_NON_OK_RESPONSE)}}})}_setExpiresTimer(){this._expires_timestamp=new Date().getTime()+1e3*this._expires,clearTimeout(this._expires_timer),this._expires_timer=setTimeout(()=>{this._state!==u.STATE_TERMINATED&&(c.debug('emit "expired"'),this.emit("expired"),this.terminate(null,"timeout"))},1e3*this._expires)}_parseState(){switch(this._state){case u.STATE_PENDING:return"pending";case u.STATE_ACTIVE:return"active";case u.STATE_TERMINATED:return"terminated";default:throw TypeError("wrong state value")}}}},3170:(e,t,s)=>{var i=function(e){return String(Number(e))===e?Number(e):e},r=function(e,t,s,r){if(r&&!s)t[r]=i(e[1]);else for(var n=0;n<s.length;n+=1)null!=e[n+1]&&(t[s[n]]=i(e[n+1]))},n=function(e,t,s){var i=e.name&&e.names;e.push&&!t[e.push]?t[e.push]=[]:i&&!t[e.name]&&(t[e.name]={});var n=e.push?{}:i?t[e.name]:t;r(s.match(e.reg),n,e.names,e.name),e.push&&t[e.push].push(n)},o=s(2202),a=RegExp.prototype.test.bind(/^([a-z])=(.*)/);t.parse=function(e){var t={},s=[],i=t;return e.split(/(\r\n|\r|\n)/).filter(a).forEach(function(e){var t=e[0],r=e.slice(2);"m"===t&&(s.push({rtp:[],fmtp:[]}),i=s[s.length-1]);for(var a=0;a<(o[t]||[]).length;a+=1){var h=o[t][a];if(h.reg.test(r))return n(h,i,r)}}),t.media=s,t};var h=function(e,t){var s=t.split(/=(.+)/,2);return 2===s.length?e[s[0]]=i(s[1]):1===s.length&&t.length>1&&(e[s[0]]=void 0),e};t.parseParams=function(e){return e.split(/;\s?/).reduce(h,{})},t.parseFmtpConfig=t.parseParams,t.parsePayloads=function(e){return e.toString().split(" ").map(Number)},t.parseRemoteCandidates=function(e){for(var t=[],s=e.split(" ").map(i),r=0;r<s.length;r+=3)t.push({component:s[r],ip:s[r+1],port:s[r+2]});return t},t.parseImageAttributes=function(e){return e.split(" ").map(function(e){return e.substring(1,e.length-1).split(",").reduce(h,{})})},t.parseSimulcastStreamList=function(e){return e.split(";").map(function(e){return e.split(",").map(function(e){var t,s=!1;return"~"!==e[0]?t=i(e):(t=i(e.substring(1,e.length)),s=!0),{scid:t,paused:s}})})}},3172:(e,t,s)=>{"use strict";let i=s(608).EventEmitter,r=s(8166),n=s(507),o=s(1447),a=s(5987),h=new r("RTCSession:ReferSubscriber");e.exports=class extends i{constructor(e){super(),this._id=null,this._session=e}get id(){return this._id}sendRefer(e,t={}){h.debug("sendRefer()");let s=a.cloneArray(t.extraHeaders),i=a.cloneObject(t.eventHandlers);for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&this.on(e,i[e]);let r=null;
35t.replaces&&(r=encodeURIComponent(r=t.replaces._request.call_id+`;to-tag=${t.replaces._to_tag}`+`;from-tag=${t.replaces._from_tag}`));let o=`Refer-To: <${e}${r?`?Replaces=${r}`:""}>`;if(s.push(o),!s.some(e=>e.toLowerCase().startsWith("referred-by:"))){let e=`Referred-By: <${this._session._ua._configuration.uri._scheme}:${this._session._ua._configuration.uri._user}@${this._session._ua._configuration.uri._host}>`;s.push(e)}s.push(`Contact: ${this._session.contact}`);let c=this._session.sendRequest(n.REFER,{extraHeaders:s,eventHandlers:{onSuccessResponse:e=>{this._requestSucceeded(e)},onErrorResponse:e=>{this._requestFailed(e,n.causes.REJECTED)},onTransportError:()=>{this._requestFailed(null,n.causes.CONNECTION_ERROR)},onRequestTimeout:()=>{this._requestFailed(null,n.causes.REQUEST_TIMEOUT)},onDialogError:()=>{this._requestFailed(null,n.causes.DIALOG_ERROR)},onAuthenticated:e=>{this._id=e.cseq,this.emit("authenticated")}}});this._id=c.cseq}receiveNotify(e){if(h.debug("receiveNotify()"),!e.body)return;let t=o.parse(e.body.trim().split("\r\n",1)[0],"Status_Line");if(-1===t)return void h.debug(`receiveNotify() | error parsing NOTIFY body: "${e.body}"`);switch(!0){case/^100$/.test(t.status_code):this.emit("trying",{request:e,status_line:t});break;case/^1[0-9]{2}$/.test(t.status_code):this.emit("progress",{request:e,status_line:t});break;case/^2[0-9]{2}$/.test(t.status_code):this.emit("accepted",{request:e,status_line:t});break;
35default:this.emit("failed",{request:e,status_line:t})}}_requestSucceeded(e){h.debug("REFER succeeded"),h.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:e})}_requestFailed(e,t){h.debug("REFER failed"),h.debug('emit "requestFailed"'),this.emit("requestFailed",{response:e||null,cause:t})}}},3281:(e,t,s)=>{"use strict";let i=s(8166),r=s(1447),n=s(1913),o=new i("Parser");t.parseMessage=(e,t)=>{let s,i,a=e.indexOf("\r\n");if(-1===a)return void o.warn("parseMessage() | no CRLF found, not a SIP message");let h=e.substring(0,a),c=r.parse(h,"Request_Response");if(-1===c)return void o.warn(`parseMessage() | error parsing first line of SIP message: "${h}"`);c.status_code?((s=new n.IncomingResponse).status_code=c.status_code,s.reason_phrase=c.reason_phrase):((s=new n.IncomingRequest(t)).method=c.method,s.ruri=c.uri),s.data=e;let u=a+2;for(;;){if(-2===(a=function(e,t){let s=t,i=0,r=0;if(e.substring(s,s+2).match(/(^\r\n)/))return -2;for(;0===i;){if(-1===(r=e.indexOf("\r\n",s)))return r;!e.substring(r+2,r+4).match(/(^\r\n)/)&&e.charAt(r+2).match(/(^\s+)/)?s=r+2:i=r}return i}(e,u))){i=u+2;break}if(-1===a)return void o.warn("parseMessage() | malformed message");if(!0!==(c=function(e,t,s,i){let o,a=t.indexOf(":",s),h=t.substring(s,a).trim(),c=t.substring(a+1,i).trim();switch(h.toLowerCase()){case"via":case"v":e.addHeader("via",c),1===e.getHeaders("via").length?(o=e.parseHeader("Via"))&&(e.via=o,e.via_branch=o.branch):o=0;break;case"from":case"f":e.setHeader("from",c),(o=e.parseHeader("from"))&&(e.from=o,e.from_tag=o.getParam("tag"));break;case"to":case"t":e.setHeader("to",c),(o=e.parseHeader("to"))&&(e.to=o,e.to_tag=o.getParam("tag"));break;case"record-route":if(-1===(o=r.parse(c,"Record_Route")))o=void 0;else for(let t of o)e.addHeader("record-route",c.substring(t.possition,t.offset)),e.headers["Record-Route"][e.getHeaders("record-route").length-1].parsed=t.parsed;break;case"call-id":case"i":e.setHeader("call-id",c),(o=e.parseHeader("call-id"))&&(e.call_id=c);break;case"contact":case"m":if(-1===(o=r.parse(c,"Contact")))o=void 0;else for(let t of o)e.addHeader("contact",c.substring(t.possition,t.offset)),e.headers.Contact[e.getHeaders("contact").length-1].parsed=t.parsed;break;case"content-length":case"l":e.setHeader("content-length",c),o=e.parseHeader("content-length");break;case"content-type":case"c":e.setHeader("content-type",c),o=e.parseHeader("content-type");break;case"cseq":e.setHeader("cseq",c),(o=e.parseHeader("cseq"))&&(e.cseq=o.value),e instanceof n.IncomingResponse&&(e.method=o.method);break;case"max-forwards":e.setHeader("max-forwards",c),o=e.parseHeader("max-forwards");break;case"www-authenticate":e.setHeader("www-authenticate",c),o=e.parseHeader("www-authenticate");break;case"proxy-authenticate":e.setHeader("proxy-authenticate",c),o=e.parseHeader("proxy-authenticate");break;case"session-expires":case"x":e.setHeader("session-expires",c),(o=e.parseHeader("session-expires"))&&(e.session_expires=o.expires,e.session_expires_refresher=o.refresher);break;case"refer-to":case"r":e.setHeader("refer-to",c),(o=e.parseHeader("refer-to"))&&(e.refer_to=o);break;case"replaces":e.setHeader("replaces",c),(o=e.parseHeader("replaces"))&&(e.replaces=o);break;case"event":case"o":e.setHeader("event",c),(o=e.parseHeader("event"))&&(e.event=o);break;default:e.addHeader(h,c),o=0}return void 0!==o||{error:`error parsing header "${h}"`}}(s,e,u,a)))return void o.warn("parseMessage() |",c.error);u=a+2}if(s.hasHeader("content-length")){let t=s.getHeader("content-length");s.body=e.substr(i,t)}else s.body=e.substring(i);return s}},3768:(e,t,s)=>{"use strict";let i=s(608).EventEmitter,r=s(8166),n=s(507),o=s(4730),a=s(903),h=s(5228),c=s(3120),u=s(1329),_=s(2068),l=s(8775),d=s(3795),p=s(5987),m=s(44),g=s(5347),T=s(3281),f=s(1913),E=s(4696),S=s(9276),R=new r("UA"),y={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2};function I(e){this.emit("connecting",e)}function C(e){this._status!==y.STATUS_USER_CLOSED&&(this._status=y.STATUS_READY,this._error=null,this.emit("connected",e),this._dynConfiguration.register&&this._registrator.register())}function A(e){for(let e of["nict","ict","nist","ist"])for(let t in this._transactions[e])Object.prototype.hasOwnProperty.call(this._transactions[e],t)&&this._transactions[e][t].onTransportError();
35this.emit("disconnected",e),this._registrator.onTransportClosed(),this._status!==y.STATUS_USER_CLOSED&&(this._status=y.STATUS_NOT_READY,this._error=y.NETWORK_ERROR)}function b(e){let t=e.transport,s=e.message;if((s=T.parseMessage(s,this))&&(this._status!==y.STATUS_USER_CLOSED||!(s instanceof f.IncomingRequest))&&E(s,this,t)){if(s instanceof f.IncomingRequest)s.transport=t,this.receiveRequest(s);else if(s instanceof f.IncomingResponse){let e;switch(s.method){case n.INVITE:(e=this._transactions.ict[s.via_branch])&&e.receiveResponse(s);break;case n.ACK:break;default:(e=this._transactions.nict[s.via_branch])&&e.receiveResponse(s)}}}}e.exports=class extends i{static get C(){return y}constructor(e){if(!e)throw TypeError("Not enough arguments");let t=["password","ha1","authorization_jwt"];R.debug("new() [configuration:%o]",Object.entries(e).filter(([e])=>!t.includes(e))),super(),this._cache={credentials:{}},this._configuration=Object.assign({},S.settings),this._dynConfiguration={},this._dialogs={},this._applicants={},this._sessions={},this._transport=null,this._contact=null,this._status=y.STATUS_INIT,this._error=null,this._transactions={nist:{},nict:{},ist:{},ict:{}},this._data={},this._closeTimer=null;try{this._loadConfig(e)}catch(e){throw this._status=y.STATUS_NOT_READY,this._error=y.CONFIGURATION_ERROR,e}this._registrator=new o(this)}get C(){return y}get status(){return this._status}get contact(){return this._contact}get configuration(){return this._configuration}get transport(){return this._transport}start(){R.debug("start()"),this._status===y.STATUS_INIT?this._transport.connect():this._status===y.STATUS_USER_CLOSED?(R.debug("restarting UA"),null!==this._closeTimer&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=y.STATUS_INIT,this._transport.connect()):this._status===y.STATUS_READY?R.debug("UA is in READY status, not restarted"):R.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this._dynConfiguration.register=this._configuration.register}register(){R.debug("register()"),this._dynConfiguration.register=!0,this._registrator.register()}unregister(e){R.debug("unregister()"),this._dynConfiguration.register=!1,this._registrator.unregister(e)}registrator(){return this._registrator}isRegistered(){return this._registrator.registered}isConnected(){return this._transport.isConnected()}call(e,t){R.debug("call()");let s=new a(this);return s.connect(e,t),s}sendMessage(e,t,s){R.debug("sendMessage()");let i=new u(this);return i.send(e,t,s),i}subscribe(e,t,s,i){return R.debug("subscribe()"),new h(this,e,t,s,i)}notify(e,t,s){return R.debug("notify()"),new c(this,e,t,s)}sendOptions(e,t,s){R.debug("sendOptions()");let i=new _(this);return i.send(e,t,s),i}terminateSessions(e){for(let t in R.debug("terminateSessions()"),this._sessions)this._sessions[t].isEnded()||this._sessions[t].terminate(e)}stop(){if(R.debug("stop()"),this._dynConfiguration={},this._status===y.STATUS_USER_CLOSED)return void R.debug("UA already closed");this._registrator.close();let e=Object.keys(this._sessions).length;for(let e in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,e)){R.debug(`closing session ${e}`);try{this._sessions[e].terminate()}catch(e){}}for(let e in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,e))try{this._applicants[e].close()}catch(e){}this._status=y.STATUS_USER_CLOSED,0===Object.keys(this._transactions.nict).length+Object.keys(this._transactions.nist).length+Object.keys(this._transactions.ict).length+Object.keys(this._transactions.ist).length&&0===e?this._transport.disconnect():this._closeTimer=setTimeout(()=>{this._closeTimer=null,this._transport.disconnect()},2e3)}normalizeTarget(e){return p.normalizeTarget(e,this._configuration.hostport_params)}get(e){switch(e){case"authorization_user":return this._configuration.authorization_user;case"realm":return this._configuration.realm;case"ha1":return this._configuration.ha1;case"authorization_jwt":return this._configuration.authorization_jwt;default:return void R.warn('get() | cannot get "%s" parameter in runtime',e)}}set(e,t){switch(e){case"authorization_user":this._configuration.authorization_user=String(t);break;case"password":this._configuration.password=String(t);break;case"realm":this._configuration.realm=String(t);break;case"ha1":this._configuration.ha1=String(t),this._configuration.password=null;break;case"authorization_jwt":this._configuration.authorization_jwt=String(t);break;case"display_name":this._configuration.display_name=t;break;case"extra_headers":this._configuration.extra_headers=t;break;default:return R.warn('set() | cannot set "%s" parameter in runtime',e),!1}return!0}
35newTransaction(e){this._transactions[e.type][e.id]=e,this.emit("newTransaction",{transaction:e})}destroyTransaction(e){delete this._transactions[e.type][e.id],this.emit("transactionDestroyed",{transaction:e})}newDialog(e){this._dialogs[e.id]=e}destroyDialog(e){delete this._dialogs[e.id]}newMessage(e,t){this._applicants[e]=e,this.emit("newMessage",t)}newOptions(e,t){this._applicants[e]=e,this.emit("newOptions",t)}destroyMessage(e){delete this._applicants[e]}newRTCSession(e,t){this._sessions[e.id]=e,this.emit("newRTCSession",t)}destroyRTCSession(e){delete this._sessions[e.id]}registered(e){this.emit("registered",e)}unregistered(e){this.emit("unregistered",e)}registrationFailed(e){this.emit("registrationFailed",e)}receiveRequest(e){let t,s,i=e.method;if(e.ruri.user!==this._configuration.uri.user&&e.ruri.user!==this._contact.uri.user){R.debug("Request-URI does not point to us"),e.method!==n.ACK&&e.reply_sl(404);return}if(e.ruri.scheme===n.SIPS)return void e.reply_sl(416);if(!l.checkTransaction(this,e)){if(i===n.INVITE?new l.InviteServerTransaction(this,this._transport,e):i!==n.ACK&&i!==n.CANCEL&&new l.NonInviteServerTransaction(this,this._transport,e),i===n.OPTIONS){if(0===this.listeners("newOptions").length)return void e.reply(200);new _(this).init_incoming(e)}else if(i===n.MESSAGE){if(0===this.listeners("newMessage").length)return void e.reply(405);new u(this).init_incoming(e)}else if(i===n.SUBSCRIBE){if(0===this.listeners("newSubscribe").length)return void e.reply(405)}else if(i===n.INVITE&&!e.to_tag&&0===this.listeners("newRTCSession").length)return void e.reply(405);if(e.to_tag)(t=this._findDialog(e.call_id,e.from_tag,e.to_tag))?t.receiveRequest(e):i===n.NOTIFY?(s=this._findSession(e))?s.receiveRequest(e):(R.debug("received NOTIFY request for a non existent subscription"),e.reply(481,"Subscription does not exist")):i!==n.ACK&&e.reply(481);else switch(i){case n.INVITE:if(window.RTCPeerConnection)if(e.hasHeader("replaces")){let i=e.replaces;(t=this._findDialog(i.call_id,i.from_tag,i.to_tag))?(s=t.owner).isEnded()?e.reply(603):s.receiveRequest(e):e.reply(481)}else(s=new a(this)).init_incoming(e);else R.warn("INVITE received but WebRTC is not supported"),e.reply(488);break;case n.BYE:e.reply(481);break;case n.CANCEL:(s=this._findSession(e))?s.receiveRequest(e):R.debug("received CANCEL request for a non existent session");break;case n.ACK:break;case n.NOTIFY:this.emit("sipEvent",{event:e.event,request:e}),e.reply(200);break;case n.SUBSCRIBE:c.init_incoming(e,()=>{this.emit("newSubscribe",{event:e.event,request:e})});break;default:e.reply(405)}}}_findSession({call_id:e,from_tag:t,to_tag:s}){let i=this._sessions[e+t],r=this._sessions[e+s];return i||r||null}_findDialog(e,t,s){let i=e+t+s,r=this._dialogs[i];return r||(i=e+s+t,r=this._dialogs[i])?r:null}_loadConfig(e){S.load(this._configuration,e),0===this._configuration.display_name&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=p.newUUID()),this._configuration.jssip_id=p.createRandomToken(5);let t=this._configuration.uri.clone();t.user=null,this._configuration.hostport_params=t.toString().replace(/^sip:/i,"");try{this._transport=new d(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=I.bind(this),this._transport.onconnect=C.bind(this),this._transport.ondisconnect=A.bind(this),this._transport.ondata=b.bind(this)}catch(e){throw R.warn(e),new m.ConfigurationError("sockets",this._configuration.sockets)}if(delete this._configuration.sockets,this._configuration.authorization_user||(this._configuration.authorization_user=this._configuration.uri.user),!this._configuration.registrar_server){let e=this._configuration.uri.clone();e.user=null,e.clearParams(),e.clearHeaders(),this._configuration.registrar_server=e}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new g("sip",p.createRandomToken(8),this._configuration.via_host,null,{transport:"ws"}),this._contact={pub_gruu:null,temp_gruu:null,uri:this._configuration.contact_uri,toString(e={}){let t=e.anonymous||null,s=e.outbound||null,i="<";return t?i+=this.temp_gruu||"sip:[email protected];transport=ws":i+=this.pub_gruu||this.uri.toString(),!s||(t?this.temp_gruu:this.pub_gruu)||(i+=";ob"),i+=">"}};let s=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register","extra_headers"];for(let e in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,e)&&(-1!==s.indexOf(e)?Object.defineProperty(this._configuration,e,{writable:!0,configurable:!1}
35):Object.defineProperty(this._configuration,e,{writable:!1,configurable:!1}));for(let e in R.debug("configuration parameters after validation:"),this._configuration)if(Object.prototype.hasOwnProperty.call(S.settings,e))switch(e){case"uri":case"registrar_server":R.debug(`- ${e}: ${this._configuration[e]}`);break;case"password":case"ha1":case"authorization_jwt":R.debug(`- ${e}: NOT SHOWN`);break;default:R.debug(`- ${e}: ${JSON.stringify(this._configuration[e])}`)}}}},3795:(e,t,s)=>{"use strict";let i=s(8166),r=s(4255),n=s(507),o=new i("Transport"),a={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:n.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:n.CONNECTION_RECOVERY_MAX_INTERVAL}};e.exports=class{constructor(e,t=a.recovery_options){o.debug("new()"),this.status=a.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=t,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1;try{this.textDecoder=new TextDecoder("utf8")}catch(e){o.warn(`cannot use TextDecoder: ${e}`)}if(void 0===e)throw TypeError("Invalid argument. undefined 'sockets' argument");e instanceof Array||(e=[e]),e.forEach(function(e){if(!r.isSocket(e.socket))throw TypeError("Invalid argument. invalid 'JsSIP.Socket' instance");if(e.weight&&!Number(e.weight))throw TypeError("Invalid argument. 'weight' attribute is not a number");this.sockets.push({socket:e.socket,weight:e.weight||0,status:a.SOCKET_STATUS_READY})},this),this._getSocket()}get via_transport(){return this.socket.via_transport}get url(){return this.socket.url}get sip_uri(){return this.socket.sip_uri}connect(){return(o.debug("connect()"),this.isConnected())?void o.debug("Transport is already connected"):this.isConnecting()?void o.debug("Transport is connecting"):void(this.close_requested=!1,this.status=a.STATUS_CONNECTING,this.onconnecting({socket:this.socket,attempts:this.recover_attempts}),!this.close_requested&&(this.socket.onconnect=this._onConnect.bind(this),this.socket.ondisconnect=this._onDisconnect.bind(this),this.socket.ondata=this._onData.bind(this),this.socket.connect()))}disconnect(){o.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=a.STATUS_DISCONNECTED,null!==this.recovery_timer&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.socket.onconnect=()=>{},this.socket.ondisconnect=()=>{},this.socket.ondata=()=>{},this.socket.disconnect(),this.ondisconnect({socket:this.socket,error:!1})}send(e){if(o.debug("send()"),!this.isConnected())return o.warn("unable to send message, transport is not connected"),!1;let t=e.toString();return o.debug(`sending message: 36 37${t} 38`),this.socket.send(t)}isConnected(){return this.status===a.STATUS_CONNECTED}isConnecting(){return this.status===a.STATUS_CONNECTING}_reconnect(){this.recover_attempts+=1;let e=Math.floor(Math.random()*Math.pow(2,this.recover_attempts)+1);e<this.recovery_options.min_interval?e=this.recovery_options.min_interval:e>this.recovery_options.max_interval&&(e=this.recovery_options.max_interval),o.debug(`reconnection attempt: ${this.recover_attempts}. next connection attempt in ${e} seconds`),this.recovery_timer=setTimeout(()=>{this.close_requested||this.isConnected()||this.isConnecting()||(this._getSocket(),this.connect())},1e3*e)}_getSocket(){let e=[];
38if(this.sockets.forEach(t=>{t.status!==a.SOCKET_STATUS_ERROR&&(0===e.length?e.push(t):t.weight>e[0].weight?e=[t]:t.weight===e[0].weight&&e.push(t))}),0===e.length){this.sockets.forEach(e=>{e.status=a.SOCKET_STATUS_READY}),this._getSocket();return}let t=Math.floor(Math.random()*e.length);this.socket=e[t].socket}_onConnect(){this.recover_attempts=0,this.status=a.STATUS_CONNECTED,null!==this.recovery_timer&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}_onDisconnect(e,t,s){this.status=a.STATUS_DISCONNECTED,this.ondisconnect({socket:this.socket,error:e,code:t,reason:s}),this.close_requested||(this.sockets.forEach(function(e){this.socket===e.socket&&(e.status=a.SOCKET_STATUS_ERROR)},this),this._reconnect(e))}_onData(e){if("\r\n\r\n"===e){o.debug("received message with double-CRLF Keep Alive request");try{this.socket.send("\r\n")}catch(e){o.warn(`error sending Keep Alive response: ${e}`)}return}if("\r\n"===e)return void o.debug("received message with CRLF Keep Alive response");if("string"!=typeof e){try{e=this.textDecoder?this.textDecoder.decode(e):String.fromCharCode.apply(null,new Uint8Array(e))}catch(e){o.debug(`received binary message failed to be converted into string: ${e}`);return}o.debug(`received binary message: 39 40${e} 41`)}else o.debug(`received text message: 42 43${e} 44`);this.ondata({transport:this,message:e})}}},4192:e=>{"use strict";e.exports=JSON.parse('{"name":"jssip","title":"JsSIP","description":"The Javascript SIP library","version":"3.13.8","homepage":"https://jssip.net","contributors":["Jos\xe9 Luis Mill\xe1n <[email protected]> (https://github.com/jmillan)","I\xf1aki Baz Castillo <[email protected]> (https://inakibaz.me)"],"types":"lib/JsSIP.d.ts","main":"lib/JsSIP.js","keywords":["sip","websocket","webrtc","node","browser","library"],"license":"MIT","repository":{"type":"git","url":"https://github.com/versatica/JsSIP.git"},"bugs":{"url":"https://github.com/versatica/JsSIP/issues"},"files":["LICENSE","README.md","npm-scripts.mjs","lib"],"scripts":{"lint":"node npm-scripts.mjs lint","lint:fix":"node npm-scripts.mjs lint:fix","test":"node npm-scripts.mjs test","coverage":"node npm-scripts.mjs coverage","build":"node npm-scripts.mjs build","typescript:build":"node npm-scripts.mjs typescript:build","release":"node npm-scripts.mjs release","docs":"node npm-scripts.mjs docs","docs:watch":"node npm-scripts.mjs docs:watch","docs:check":"node npm-scripts.mjs docs:check"},"dependencies":{"debug":"^4.3.1","events":"^3.3.0","sdp-transform":"^2.14.1"},"devDependencies":{"@eslint/eslintrc":"^3.3.3","@eslint/js":"^9.39.2","@types/debug":"^4.1.12","@types/events":"^3.0.3","@types/jest":"^30.0.0","@types/node":"^25.0.10","cpx":"^1.5.0","esbuild":"^0.27.2","eslint":"^9.39.1","eslint-config-prettier":"^10.1.8","eslint-plugin-jest":"^29.12.1","eslint-plugin-prettier":"^5.5.5","globals":"^17.0.0","jest":"^30.2.0","open-cli":"^8.0.0","pegjs":"^0.7.0","prettier":"^3.8.1","ts-jest":"^29.4.6","typedoc":"^0.28.16","typescript":"^5.9.3","typescript-eslint":"^8.53.1"}}')},4255:(e,t,s)=>{"use strict";let i=s(8166),r=s(5987),n=s(1447),o=new i("Socket");t.isSocket=e=>{if(Array.isArray(e))return!1;if(void 0===e)return o.warn("undefined JsSIP.Socket instance"),!1;try{if(!r.isString(e.url))throw o.warn("missing or invalid JsSIP.Socket url property"),Error("Missing or invalid JsSIP.Socket url property");if(!r.isString(e.via_transport))throw o.warn("missing or invalid JsSIP.Socket via_transport property"),Error("Missing or invalid JsSIP.Socket via_transport property");if(-1===n.parse(e.sip_uri,"SIP_URI"))throw o.warn("missing or invalid JsSIP.Socket sip_uri property"),Error("missing or invalid JsSIP.Socket sip_uri property")}catch(e){return!1}try{["connect","disconnect","send"].forEach(t=>{if(!r.isFunction(e[t]))throw o.warn(`missing or invalid JsSIP.Socket method: ${t}`),Error(`Missing or invalid JsSIP.Socket method: ${t}`)})}catch(e){return!1}return!0}},4696:(e,t,s)=>{"use strict";let i,r,n,o=s(8166),a=s(507),h=s(1913),c=s(5987),u=new o("sanityCheck"),_=[function(){for(let e of["from","to","call_id","cseq","via"])if(!i.hasHeader(e))return u.debug(`missing mandatory header field : ${e}, dropping the response`),!1}],l=[function(){if("sip"!==i.s("to").uri.scheme)return p(416),!1},function(){if(!i.to_tag&&i.call_id.substr(0,5)===r.configuration.jssi
44p_id)return p(482),!1},function(){if(c.str_utf8_length(i.body)<i.getHeader("content-length"))return p(400),!1},function(){let e,t=i.from_tag,s=i.call_id,n=i.cseq;if(!i.to_tag)if(i.method===a.INVITE){if(r._transactions.ist[i.via_branch])return!1;else for(let i in r._transactions.ist)if(Object.prototype.hasOwnProperty.call(r._transactions.ist,i)&&(e=r._transactions.ist[i]).request.from_tag===t&&e.request.call_id===s&&e.request.cseq===n)return p(482),!1}else{if(r._transactions.nist[i.via_branch])return!1;for(let i in r._transactions.nist)if(Object.prototype.hasOwnProperty.call(r._transactions.nist,i)&&(e=r._transactions.nist[i]).request.from_tag===t&&e.request.call_id===s&&e.request.cseq===n)return p(482),!1}}],d=[function(){if(i.getHeaders("via").length>1)return u.debug("more than one Via header field present in the response, dropping the response"),!1},function(){if(c.str_utf8_length(i.body)<i.getHeader("content-length"))return u.debug("message body length is lower than the value in Content-Length header field, dropping the response"),!1}];function p(e){let t,s=i.getHeaders("via"),r=`SIP/2.0 ${e} ${a.REASON_PHRASE[e]}\r 45`;for(let e of s)r+=`Via: ${e}\r 46`;t=i.getHeader("To"),i.to_tag||(t+=`;tag=${c.newTag()}`),r+=`To: ${t}\r 47From: ${i.getHeader("From")}\r 48Call-ID: ${i.call_id}\r 49CSeq: ${i.cseq} ${i.method}\r 50\r 51`,n.send(r)}e.exports=(e,t,s)=>{for(let o of(i=e,r=t,n=s,_))if(!1===o())return!1;if(i instanceof h.IncomingRequest){for(let e of l)if(!1===e())return!1}else if(i instanceof h.IncomingResponse){for(let e of d)if(!1===e())return!1}return!0}},4730:(e,t,s)=>{"use strict";let i=s(8166),r=s(5987),n=s(507),o=s(1913),a=s(7914),h=new i("Registrator");e.exports=class{constructor(e,t){this._reg_id=1,this._ua=e,this._transport=t,this._registrar=e.configuration.registrar_server,this._expires=e.configuration.register_expires,this._call_id=r.createRandomToken(22),this._cseq=0,this._to_uri=e.configuration.uri,this._registrationTimer=null,this._registering=!1,this._registered=!1,this._contact=this._ua.contact.toString(),this._contact+=";+sip.ice",this._extraHeaders=[],this._extraContactParams="",this._sipInstance=`"<urn:uuid:${this._ua.configuration.instance_id}>"`,this._contact+=`;reg-id=${this._reg_id}`,this._contact+=`;+sip.instance=${this._sipInstance}`}get registered(){return this._registered}setExtraHeaders(e){Array.isArray(e)||(e=[]),this._extraHeaders=e.slice()}setExtraContactParams(e){for(let t in e instanceof Object||(e={}),this._extraContactParams="",e)if(Object.prototype.hasOwnProperty.call(e,t)){let s=e[t];this._extraContactParams+=`;${t}`,s&&(this._extraContactParams+=`=${s}`)}}register(){let e;if(this._registering)return void h.debug("Register request in progress...");let t=r.cloneArray(this._extraHeaders);this._expires?(e=`${this._contact};expires=${this._expires}${this._extraContactParams}`,t.push(`Expires: ${this._expires}`)):e=`${this._contact}${this._extraContactParams}`,t.push(`Contact: ${e}`);let s=r.newTag();this._ua.configuration.register_from_tag_trail&&("function"==typeof this._ua.configuration.register_from_tag_trail?s+=this._ua.configuration.register_from_tag_trail():s+=this._ua.configuration.register_from_tag_trail);let i=new o.OutgoingRequest(n.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1,from_tag:s},t),c=new a(this._ua,i,{onRequestTimeout:()=>{this._registrationFailure(null,n.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._registrationFailure(null,n.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:e=>{if(e.cseq===this._cseq)switch(null!==this._registrationTimer&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(e.status_code):break;case/^2[0-9]{2}$/.test(e.status_code):{if(this._registering=!1,!e.hasHeader("Contact")){h.debug("no Contact header in response to REGISTER, response ignored");break}let t=e.headers.Contact.reduce((e,t)=>e.concat(t.parsed),[]),s=t.find(e=>this._sipInstance===e.getParam("+sip.instance")&&this._reg_id===parseInt(e.getParam("reg-id")));if(s||(s=t.find(e=>e.uri.user===this._ua.contact.uri.user)),!s){h.debug("no Contact header pointing to us, response ignored");break}let i=s.getParam("expires");!i&&e.hasHeader("expires")&&(i=e.getHeader("expires")),i||(i=this._expires),(i=Number(i))<10&&(i=10);let r=i>64?1e3*i/2+Math.floor((i/2-32)*1e3*Math.random()):1e3*i-5e3;this._registrationTimer=setTimeout(()=>{this._registrationTimer=null,0===this._ua.listeners("registrationExpiring").length?this.register():this._ua.emit("registrationExpiring")},r),s.hasParam("temp-gruu")&&(this._ua.contact.temp_gruu=s.getParam("temp-gruu").replace(/"/g,"")),s.hasParam("pub-gruu")&&(this._ua.contact.pub_gruu=s.getParam("pub-gruu").replace(/"/g,"")),this._registered||(this._registered=!0,this._ua.registered({response:e}));break}case/^423$/.test(e.status_code):e.hasHeader("min-expires")?(this._expires=Number(e.getHeader("min-expires")),this._expires<10&&(this._expires=10),this._registering=!1,this.register()):(h.debug("423 response received for REGISTER without Min-Expires"),this._registrationFailure(e,n.causes.SIP_FAILURE_CODE));break;default:{let t=r.sipErrorCause(e.status_code);this._registrationFailure(e,t)}}}});this._registering=!0,c.send()}unregister(e={}){if(!this._registered)return void h.debug("already unregistered");this._registered=!1,null!==this._registrationTimer&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);let t=r.cloneArray(this._extraHeaders);e.all?t.push(`Contact: *${this._extraContactParams}`):t.push(`Contact: ${this._contact};expires=0${this._extraContactParams}
51`),t.push("Expires: 0");let s=new o.OutgoingRequest(n.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},t);new a(this._ua,s,{onRequestTimeout:()=>{this._unregistered(null,n.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._unregistered(null,n.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:e=>{switch(!0){case/^1[0-9]{2}$/.test(e.status_code):break;case/^2[0-9]{2}$/.test(e.status_code):this._unregistered(e);break;default:{let t=r.sipErrorCause(e.status_code);this._unregistered(e,t)}}}}).send()}close(){this._registered&&this.unregister()}onTransportClosed(){this._registering=!1,null!==this._registrationTimer&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),this._registered&&(this._registered=!1,this._ua.unregistered({}))}_registrationFailure(e,t){this._registering=!1,this._ua.registrationFailed({response:e||null,cause:t}),this._registered&&(this._registered=!1,this._ua.unregistered({response:e||null,cause:t}))}_unregistered(e,t){this._registering=!1,this._registered=!1,this._ua.unregistered({response:e||null,cause:t||null})}}},5228:(e,t,s)=>{"use strict";let i=s(608).EventEmitter,r=s(44),n=s(8166),o=s(507),a=s(5987),h=s(1447),c=s(1913),u=s(7914),_=s(2226),l=new n("Subscriber"),d={SUBSCRIBE_RESPONSE_TIMEOUT:0,SUBSCRIBE_TRANSPORT_ERROR:1,SUBSCRIBE_NON_OK_RESPONSE:2,SUBSCRIBE_WRONG_OK_RESPONSE:3,SUBSCRIBE_AUTHENTICATION_FAILED:4,UNSUBSCRIBE_TIMEOUT:5,FINAL_NOTIFY_RECEIVED:6,WRONG_NOTIFY_RECEIVED:7,STATE_PENDING:0,STATE_ACTIVE:1,STATE_TERMINATED:2,STATE_INIT:3,STATE_WAITING_NOTIFY:4,DEFAULT_EXPIRES_SEC:900};e.exports=class extends i{static get C(){return d}constructor(e,t,s,i,{expires:r,contentType:n,allowEvents:o,params:c,extraHeaders:u}){if(l.debug("new"),super(),!t)throw TypeError("Not enough arguments: Missing target");if(!s)throw TypeError("Not enough arguments: Missing eventName");if(!i)throw TypeError("Not enough arguments: Missing accept");let _=h.parse(s,"Event");if(-1===_)throw TypeError("Missing Event header field");this._ua=e,this._target=t,(!a.isDecimal(r)||r<=0)&&(r=d.DEFAULT_EXPIRES_SEC),this._expires=r,this._content_type=n,this._params=a.cloneObject(c),this._params.from_uri||(this._params.from_uri=this._ua.configuration.uri),this._params.from_tag=a.newTag(),this._params.to_tag=null,this._params.call_id=a.createRandomToken(20),void 0===this._params.cseq&&(this._params.cseq=Math.floor(1e4*Math.random()+1)),this._state=d.STATE_INIT,this._dialog=null,this._expires_timer=null,this._expires_timestamp=null,this._terminated=!1,this._event_name=_.event,this._event_id=_.params&&_.params.id;let p=this._event_name;if(this._event_id&&(p+=`;id=${this._event_id}`),this._headers=a.cloneArray(u),this._headers=this._headers.concat([`Event: ${p}`,`Expires: ${this._expires}`,`Accept: ${i}`]),!this._headers.find(e=>e.startsWith("Contact"))){let e=`Contact: ${this._ua._contact.toString()}`;this._headers.push(e)}o&&this._headers.push(`Allow-Events: ${o}`),this._queue=[],this._data={}}get C(){return d}get state(){return this._state}get id(){return this._dialog?this._dialog.id:null}get data(){return this._data}set data(e){this._data=e}onRequestTimeout(){this._terminateDialog(d.SUBSCRIBE_RESPONSE_TIMEOUT)}onTransportError(){this._terminateDialog(d.SUBSCRIBE_TRANSPORT_ERROR)}receiveRequest(e){if(e.method!==o.NOTIFY){l.warn("received non-NOTIFY request"),e.reply(405);return}let t=e.parseHeader("Event");if(!t){l.warn("missing Event header"),e.reply(400),this._terminateDialog(d.WRONG_NOTIFY_RECEIVED);return}let s=t.event,i=t.params&&t.params.id;if(s!==this._event_name||i!==this._event_id){l.warn("Event header does not match the one in SUBSCRIBE request"),e.reply(489),this._terminateDialog(d.WRONG_NOTIFY_RECEIVED);return}let r=e.parseHeader("subscription-state");if(!r){l.warn("missing Subscription-State header"),e.reply(400),this._terminateDialog(d.WRONG_NOTIFY_RECEIVED);return}let n=this._parseSubscriptionState(r.state);if(void 0===n){l.warn(`Invalid Subscription-State header value: ${r.state}`),e.reply(400),this._terminateDialog(d.WRONG_NOTIFY_RECEIVED);return}e.reply(200);let a=this._state;if(a!==d.STATE_TERMINATED&&n!==d.STATE_TERMINATED&&(this._state=n,void 0!==r.expires)){let e=r.expires,t=new Date().getTime()+1e3*e;this._expires_timestamp-t>2e3&&(l.debug("update sending re-SUBSCRIBE time"),this._scheduleSubscribe(e))}a!==d.STATE_PENDING&&n===d.STATE_PENDING?(l.debug('emit "pending"'),this.emit
51("pending")):a!==d.STATE_ACTIVE&&n===d.STATE_ACTIVE&&(l.debug('emit "active"'),this.emit("active"));let h=e.body,c=n===d.STATE_TERMINATED;if(h){let t=e.getHeader("content-type");l.debug('emit "notify"'),this.emit("notify",c,e,h,t)}if(c){let e,t=r.reason;r.params&&void 0!==r.params["retry-after"]&&(e=parseInt(r.params["retry-after"])),this._terminateDialog(d.FINAL_NOTIFY_RECEIVED,t,e)}}subscribe(e=null){l.debug("subscribe()"),this._state===d.STATE_INIT?this._sendInitialSubscribe(e,this._headers):this._sendSubsequentSubscribe(e,this._headers)}terminate(e=null){if(l.debug("terminate()"),this._state===d.STATE_INIT)throw new r.InvalidStateError(this._state);if(this._terminated)return;this._terminated=!0;let t=this._headers.map(e=>e.startsWith("Expires")?"Expires: 0":e);this._sendSubsequentSubscribe(e,t)}_terminateDialog(e,t,s){this._state!==d.STATE_TERMINATED&&(this._state=d.STATE_TERMINATED,clearTimeout(this._expires_timer),this._dialog&&(this._dialog.terminate(),this._dialog=null),l.debug(`emit "terminated" code=${e}`),this.emit("terminated",e,t,s))}_sendInitialSubscribe(e,t){if(e){if(!this._content_type)throw TypeError("content_type is undefined");(t=a.cloneArray(t)).push(`Content-Type: ${this._content_type}`)}this._state=d.STATE_WAITING_NOTIFY;let s=new c.OutgoingRequest(o.SUBSCRIBE,this._ua.normalizeTarget(this._target),this._ua,this._params,t,e);new u(this._ua,s,{onRequestTimeout:()=>{this.onRequestTimeout()},onTransportError:()=>{this.onTransportError()},onReceiveResponse:e=>{this._receiveSubscribeResponse(e)}}).send()}_sendSubsequentSubscribe(e,t){if(this._state!==d.STATE_TERMINATED){if(!this._dialog){l.debug("enqueue subscribe"),this._queue.push({body:e,headers:a.cloneArray(t)});return}if(e){if(!this._content_type)throw TypeError("content_type is undefined");(t=a.cloneArray(t)).push(`Content-Type: ${this._content_type}`)}this._dialog.sendRequest(o.SUBSCRIBE,{body:e,extraHeaders:t,eventHandlers:{onRequestTimeout:()=>{this.onRequestTimeout()},onTransportError:()=>{this.onTransportError()},onSuccessResponse:e=>{this._receiveSubscribeResponse(e)},onErrorResponse:e=>{this._receiveSubscribeResponse(e)},onDialogError:e=>{this._receiveSubscribeResponse(e)}}})}}_receiveSubscribeResponse(e){if(this._state!==d.STATE_TERMINATED)if(e.status_code>=200&&e.status_code<300){if(null===this._dialog){let t=new _(this,e,"UAC");if(t.error){l.warn(t.error),this._terminateDialog(d.SUBSCRIBE_WRONG_OK_RESPONSE);return}for(let e of(this._dialog=t,l.debug('emit "accepted"'),this.emit("accepted"),this._queue))l.debug("dequeue subscribe"),this._sendSubsequentSubscribe(e.body,e.headers)}let t=parseInt(e.getHeader("expires"));(!a.isDecimal(t)||t<=0)&&(l.warn(`response without Expires header, setting a default value of ${d.DEFAULT_EXPIRES_SEC}`),t=d.DEFAULT_EXPIRES_SEC),t>0&&this._scheduleSubscribe(t)}else 401===e.status_code||407===e.status_code?this._terminateDialog(d.SUBSCRIBE_AUTHENTICATION_FAILED):e.status_code>=300&&this._terminateDialog(d.SUBSCRIBE_NON_OK_RESPONSE)}_scheduleSubscribe(e){let t=e>=140?1e3*e/2+Math.floor((e/2-70)*1e3*Math.random()):1e3*e-5e3;this._expires_timestamp=new Date().getTime()+1e3*e,l.debug(`next SUBSCRIBE will be sent in ${Math.floor(t/1e3)} sec`),clearTimeout(this._expires_timer),this._expires_timer=setTimeout(()=>{this._expires_timer=null,this._sendSubsequentSubscribe(null,this._headers)},t)}_parseSubscriptionState(e){switch(e){case"pending":return d.STATE_PENDING;case"active":return d.STATE_ACTIVE;case"terminated":return d.STATE_TERMINATED;case"init":return d.STATE_INIT;case"notify_wait":return d.STATE_WAITING_NOTIFY;default:return}}}},5347:(e,t,s)=>{"use strict";let i=s(507),r=s(5987),n=s(1447);e.exports=class e{static parse(e){return -1!==(e=n.parse(e,"SIP_URI"))?e:void 0}constructor(e,t,s,r,n={},o={}){if(!s)throw TypeError('missing or invalid "host" parameter');for(let o in this._parameters={},this._headers={},this._scheme=e||i.SIP,this._user=t,this._host=s,this._port=r,n)Object.prototype.hasOwnProperty.call(n,o)&&this.setParam(o,n[o]);for(let e in o)Object.prototype.hasOwnProperty.call(o,e)&&this.setHeader(e,o[e])}get scheme(){return this._scheme}set scheme(e){this._scheme=e.toLowerCase()}get user(){return this._user}set user(e){this._user=e}get host(){return this._host}set host(e){this._host=e.toLowerCase()}get port(){return this._port}set port(e){this._port=0===e?e:parseInt(e,10)||null}setParam(e,t){e&&(this._parameters[e.toLowerCase()]=null==t?null:t.toString())}getParam(e){if(e)return this._parameters[e.toLowerCase()]}hasParam(e){if(e)return this._parameters.hasOwnProperty(e.toLowerCase())&&!0||!1}deleteParam(e){if(e=e.toLowerCase(),this._parameters.hasOwnProperty(e)){let t=this._parameters[e];return delete this._parameters[e],t}}clearParams(){this._parameters={}}setHeader(e,t){this._headers[r.headerize(e)]=Array.isArray(t)?t:[t]}getHeader(e){if(e)return this._headers[r.headerize(e)]}hasHeader(e){if(e)return this._headers.hasOwnProperty(r.headerize(e))&&!0||!1}deleteHeader(e){if(e=r.headerize(e),this._headers.hasOwnProperty(e)){let t=this._headers[e];return delete this._headers[e],t}}clearHeaders(){this._headers={}}clone(){return new e(this._scheme,this._user,this._host,this._port,JSON.parse(JSON.stringify(this._parameters)),JSON.parse(JSON.stringify(this._headers)))}toString(){let e=[],t=`${this._scheme}:`;for(let e in this._user&&(t+=`${r.escapeUser(this._user)}@`),t+=this._host,(this._port||0===this._port)&&(t+=`:${this._port}`),this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,e)&&(t+=`;${e}`,null!==this._parameters[e]&&(t+=`=${this._parameters[e]}`));for(let t in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,t))for(let s of this._headers[t])e.pu
51sh(`${t}=${s}`);return e.length>0&&(t+=`?${e.join("&")}`),t}toAor(e){let t=`${this._scheme}:`;return this._user&&(t+=`${r.escapeUser(this._user)}@`),t+=this._host,e&&(this._port||0===this._port)&&(t+=`:${this._port}`),t}}},5451:(e,t,s)=>{"use strict";let i=s(4192),r=s(507),n=s(44),o=s(5987),a=s(3768),h=s(5347),c=s(7879),u=s(1447),_=s(1236),l=s(9941)("JsSIP"),d=s(903);l("version %s",i.version),e.exports={C:r,Exceptions:n,Utils:o,UA:a,URI:h,NameAddrHeader:c,WebSocketInterface:_,Grammar:u,RTCSession:d,debug:s(9941),get name(){return i.title},get version(){return i.version}}},5919:e=>{function t(e,t,s,i){return Math.round(e/s)+" "+i+(t>=1.5*s?"s":"")}e.exports=function(e,s){s=s||{};var i,r,n,o,a=typeof e;if("string"===a&&e.length>0){var h=e;if(!((h=String(h)).length>100)){var c=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(h);if(c){var u=parseFloat(c[1]);switch((c[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*u;case"weeks":case"week":case"w":return 6048e5*u;case"days":case"day":case"d":return 864e5*u;case"hours":case"hour":case"hrs":case"hr":case"h":return 36e5*u;case"minutes":case"minute":case"mins":case"min":case"m":return 6e4*u;case"seconds":case"second":case"secs":case"sec":case"s":return 1e3*u;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return u;default:break}}}return}if("number"===a&&isFinite(e)){return s.long?(r=Math.abs(i=e))>=864e5?t(i,r,864e5,"day"):r>=36e5?t(i,r,36e5,"hour"):r>=6e4?t(i,r,6e4,"minute"):r>=1e3?t(i,r,1e3,"second"):i+" ms":(o=Math.abs(n=e))>=864e5?Math.round(n/864e5)+"d":o>=36e5?Math.round(n/36e5)+"h":o>=6e4?Math.round(n/6e4)+"m":o>=1e3?Math.round(n/1e3)+"s":n+"ms"}throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},5987:(e,t,s)=>{"use strict";let i=s(507),r=s(5347),n=s(1447);t.str_utf8_length=e=>unescape(encodeURIComponent(e)).length;let o=t.isFunction=e=>void 0!==e&&"[object Function]"===Object.prototype.toString.call(e);t.isString=e=>void 0!==e&&"[object String]"===Object.prototype.toString.call(e),t.isDecimal=e=>!isNaN(e)&&parseFloat(e)===parseInt(e,10),t.isEmpty=e=>null===e||""===e||void 0===e||Array.isArray(e)&&0===e.length||"number"==typeof e&&isNaN(e),t.hasMethods=function(e,...t){for(let s of t)if(o(e[s]))return!1;return!0};let a=t.createRandomToken=(e,t=32)=>{let s,i="";for(s=0;s<e;s++)i+=(Math.random()*t|0).toString(t);return i};t.newTag=()=>a(10),t.newUUID=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),t.hostType=e=>{if(e&&-1!==(e=n.parse(e,"host")))return e.host_type};let h=t.escapeUser=e=>encodeURIComponent(decodeURIComponent(e)).replace(/%3A/gi,":").replace(/%2B/gi,"+").replace(/%3F/gi,"?").replace(/%2F/gi,"/");t.normalizeTarget=(e,t)=>{if(e){if(e instanceof r)return e;if("string"==typeof e){let s,n,o,a=e.split("@");switch(a.length){case 1:if(!t)return;s=e,n=t;break;case 2:s=a[0],n=a[1];break;default:s=a.slice(0,a.length-1).join("@"),n=a[a.length-1]}return(s=s.replace(/^(sips?|tel):/i,""),/^[-.()]*\+?[0-9\-.()]+$/.test(s)&&(s=s.replace(/[-.()]/g,"")),e=`${i.SIP}:${h(s)}@${n}`,o=r.parse(e))?o:void 0}}},t.headerize=e=>{let t,s={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},i=e.toLowerCase().replace(/_/g,"-").split("-"),r="",n=i.length;for(t=0;t<n;t++)0!==t&&(r+="-"),r+=i[t].charAt(0).toUpperCase()+i[t].substring(1);return s[r]&&(r=s[r]),r},t.sipErrorCause=e=>{for(let t in i.SIP_ERROR_CAUSES)if(-1!==i.SIP_ERROR_CAUSES[t].indexOf(e))return i.causes[t];return i.causes.SIP_FAILURE_CODE},t.getRandomTestNetIP=()=>{var e;return`192.0.2.${e=0,Math.floor(254*Math.random()+1)}`},t.calculateMD5=e=>{let t,s,i,r,n,o,a,h,c;function u(e,t){return e<<t|e>>>32-t}
51function _(e,t){let s=0x80000000&e,i=0x80000000&t,r=0x40000000&e,n=0x40000000&t,o=(0x3fffffff&e)+(0x3fffffff&t);return r&n?0x80000000^o^s^i:r|n?0x40000000&o?0xc0000000^o^s^i:0x40000000^o^s^i:o^s^i}function l(e,t,s,i,r,n,o){return e=_(e,_(_(t&s|~t&i,r),o)),_(u(e,n),t)}function d(e,t,s,i,r,n,o){return e=_(e,_(_(t&i|s&~i,r),o)),_(u(e,n),t)}function p(e,t,s,i,r,n,o){return e=_(e,_(_(t^s^i,r),o)),_(u(e,n),t)}function m(e,t,s,i,r,n,o){return e=_(e,_(_(s^(t|~i),r),o)),_(u(e,n),t)}function g(e){let t="",s="",i,r;for(r=0;r<=3;r++)i=e>>>8*r&255,t+=(s=`0${i.toString(16)}`).substr(s.length-2,2);return t}let T=[];for(t=0,T=function(e){let t,s=e.length,i=s+8,r=((i-i%64)/64+1)*16,n=Array(r-1),o=0,a=0;for(;a<s;)t=(a-a%4)/4,o=a%4*8,n[t]=n[t]|e.charCodeAt(a)<<o,a++;return t=(a-a%4)/4,o=a%4*8,n[t]=n[t]|128<<o,n[r-2]=s<<3,n[r-1]=s>>>29,n}(e=function(e){let t="";for(let s=0;s<e.length;s++){let i=e.charCodeAt(s);i<128?t+=String.fromCharCode(i):(i>127&&i<2048?t+=String.fromCharCode(i>>6|192):(t+=String.fromCharCode(i>>12|224),t+=String.fromCharCode(i>>6&63|128)),t+=String.fromCharCode(63&i|128))}return t}(e)),o=0x67452301,a=0xefcdab89,h=0x98badcfe,c=0x10325476;t<T.length;t+=16)s=o,i=a,r=h,n=c,o=l(o,a,h,c,T[t+0],7,0xd76aa478),c=l(c,o,a,h,T[t+1],12,0xe8c7b756),h=l(h,c,o,a,T[t+2],17,0x242070db),a=l(a,h,c,o,T[t+3],22,0xc1bdceee),o=l(o,a,h,c,T[t+4],7,0xf57c0faf),c=l(c,o,a,h,T[t+5],12,0x4787c62a),h=l(h,c,o,a,T[t+6],17,0xa8304613),a=l(a,h,c,o,T[t+7],22,0xfd469501),o=l(o,a,h,c,T[t+8],7,0x698098d8),c=l(c,o,a,h,T[t+9],12,0x8b44f7af),h=l(h,c,o,a,T[t+10],17,0xffff5bb1),a=l(a,h,c,o,T[t+11],22,0x895cd7be),o=l(o,a,h,c,T[t+12],7,0x6b901122),c=l(c,o,a,h,T[t+13],12,0xfd987193),h=l(h,c,o,a,T[t+14],17,0xa679438e),a=l(a,h,c,o,T[t+15],22,0x49b40821),o=d(o,a,h,c,T[t+1],5,0xf61e2562),c=d(c,o,a,h,T[t+6],9,0xc040b340),h=d(h,c,o,a,T[t+11],14,0x265e5a51),a=d(a,h,c,o,T[t+0],20,0xe9b6c7aa),o=d(o,a,h,c,T[t+5],5,0xd62f105d),c=d(c,o,a,h,T[t+10],9,0x2441453),h=d(h,c,o,a,T[t+15],14,0xd8a1e681),a=d(a,h,c,o,T[t+4],20,0xe7d3fbc8),o=d(o,a,h,c,T[t+9],5,0x21e1cde6),c=d(c,o,a,h,T[t+14],9,0xc33707d6),h=d(h,c,o,a,T[t+3],14,0xf4d50d87),a=d(a,h,c,o,T[t+8],20,0x455a14ed),o=d(o,a,h,c,T[t+13],5,0xa9e3e905),c=d(c,o,a,h,T[t+2],9,0xfcefa3f8),h=d(h,c,o,a,T[t+7],14,0x676f02d9),a=d(a,h,c,o,T[t+12],20,0x8d2a4c8a),o=p(o,a,h,c,T[t+5],4,0xfffa3942),c=p(c,o,a,h,T[t+8],11,0x8771f681),h=p(h,c,o,a,T[t+11],16,0x6d9d6122),a=p(a,h,c,o,T[t+14],23,0xfde5380c),o=p(o,a,h,c,T[t+1],4,0xa4beea44),c=p(c,o,a,h,T[t+4],11,0x4bdecfa9),h=p(h,c,o,a,T[t+7],16,0xf6bb4b60),a=p(a,h,c,o,T[t+10],23,0xbebfbc70),o=p(o,a,h,c,T[t+13],4,0x289b7ec6),c=p(c,o,a,h,T[t+0],11,0xeaa127fa),h=p(h,c,o,a,T[t+3],16,0xd4ef3085),a=p(a,h,c,o,T[t+6],23,0x4881d05),o=p(o,a,h,c,T[t+9],4,0xd9d4d039),c=p(c,o,a,h,T[t+12],11,0xe6db99e5),h=p(h,c,o,a,T[t+15],16,0x1fa27cf8),a=p(a,h,c,o,T[t+2],23,0xc4ac5665),o=m(o,a,h,c,T[t+0],6,0xf4292244),c=m(c,o,a,h,T[t+7],10,0x432aff97),h=m(h,c,o,a,T[t+14],15,0xab9423a7),a=m(a,h,c,o,T[t+5],21,0xfc93a039),o=m(o,a,h,c,T[t+12],6,0x655b59c3),c=m(c,o,a,h,T[t+3],10,0x8f0ccc92),h=m(h,c,o,a,T[t+10],15,0xffeff47d),a=m(a,h,c,o,T[t+1],21,0x85845dd1),o=m(o,a,h,c,T[t+8],6,0x6fa87e4f),c=m(c,o,a,h,T[t+15],10,0xfe2ce6e0),h=m(h,c,o,a,T[t+6],15,0xa3014314),a=m(a,h,c,o,T[t+13],21,0x4e0811a1),o=m(o,a,h,c,T[t+4],6,0xf7537e82),c=m(c,o,a,h,T[t+11],10,0xbd3af235),h=m(h,c,o,a,T[t+2],15,0x2ad7d2bb),a=m(a,h,c,o,T[t+9],21,0xeb86d391),o=_(o,s),a=_(a,i),h=_(h,r),c=_(c,n);return(g(o)+g(a)+g(h)+g(c)).toLowerCase()},t.closeMediaStream=e=>{if(e)try{if(e.getTracks)for(let t of e.getTracks())t.stop();else{for(let t of e.getAudioTracks())t.stop();for(let t of e.getVideoTracks())t.stop()}}catch(t){("function"==typeof e.stop||"object"==typeof e.stop)&&e.stop()}},t.cloneArray=e=>e&&e.slice()||[],t.cloneObject=(e,t={})=>e&&Object.assign({},e)||t},6194:(e,t,s)=>{var i=s(2202),r=/%[sdv%]/g,n=function(e){var t=1,s=arguments,i=s.length;return e.replace(r,function(e){if(t>=i)return e;var r=s[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(r);case"%d":return Number(r);case"%v":return""}})},o=function(e,t,s){var i=[e+"="+(t.format instanceof Function?t.format(t.push?s:s[t.name]):t.format)];if(t.names)for(var r=0;r<t.names.length;r+=1){var o=t.names[r];t.name?i.push(s[t.name][o]):i.push(s[t.names[r]])}else i.push(s[t.name]);return n.apply(null,i)},a=["v","o","s","i","u","e","p","c","b","t","r","z","a"],h=["i","c","b","a"];e.exports=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEac
51h(function(e){null==e.payloads&&(e.payloads="")});var s=t.outerOrder||a,r=t.innerOrder||h,n=[];return s.forEach(function(t){i[t].forEach(function(s){s.name in e&&null!=e[s.name]?n.push(o(t,s,e)):s.push in e&&null!=e[s.push]&&e[s.push].forEach(function(e){n.push(o(t,s,e))})})}),e.media.forEach(function(e){n.push(o("m",i.m[0],e)),r.forEach(function(t){i[t].forEach(function(s){s.name in e&&null!=e[s.name]?n.push(o(t,s,e)):s.push in e&&null!=e[s.push]&&e[s.push].forEach(function(e){n.push(o(t,s,e))})})})}),n.join("\r\n")+"\r\n"}},6338:(e,t,s)=>{e.exports=function(e){function t(e){let s,r,n,o=null;function a(...e){if(!a.enabled)return;let i=Number(new Date);a.diff=i-(s||i),a.prev=s,a.curr=i,s=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let r=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(s,i)=>{if("%%"===s)return"%";r++;let n=t.formatters[i];if("function"==typeof n){let t=e[r];s=n.call(a,t),e.splice(r,1),r--}return s}),t.formatArgs.call(a,e),(a.log||t.log).apply(a,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=i,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(r!==t.namespaces&&(r=t.namespaces,n=t.enabled(e)),n),set:e=>{o=e}}),"function"==typeof t.init&&t.init(a),a}function i(e,s){let i=t(this.namespace+(void 0===s?":":s)+e);return i.log=this.log,i}function r(e,t){let s=0,i=0,r=-1,n=0;for(;s<e.length;)if(i<t.length&&(t[i]===e[s]||"*"===t[i]))"*"===t[i]?(r=i,n=s):s++,i++;else{if(-1===r)return!1;i=r+1,s=++n}for(;i<t.length&&"*"===t[i];)i++;return i===t.length}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){let e=[...t.names,...t.skips.map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){for(let s of(t.save(e),t.namespaces=e,t.names=[],t.skips=[],("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean)))"-"===s[0]?t.skips.push(s.slice(1)):t.names.push(s)},t.enabled=function(e){for(let s of t.skips)if(r(e,s))return!1;for(let s of t.names)if(r(e,s))return!0;return!1},t.humanize=s(5919),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(s=>{t[s]=e[s]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let s=0;for(let t=0;t<e.length;t++)s=(s<<5)-s+e.charCodeAt(t)|0;return t.colors[Math.abs(s)%t.colors.length]},t.enable(t.load()),t}},6454:(e,t,s)=>{"use strict";let i=s(507),r=s(8775),n=s(7914),o={onRequestTimeout:()=>{},onTransportError:()=>{},onSuccessResponse:()=>{},onErrorResponse:()=>{},onAuthenticated:()=>{},onDialogError:()=>{}};e.exports=class{constructor(e,t,s){for(let i in this._dialog=e,this._ua=e._ua,this._request=t,this._eventHandlers=s,this._reattempt=!1,this._reattemptTimer=null,o)Object.prototype.hasOwnProperty.call(o,i)&&!this._eventHandlers[i]&&(this._eventHandlers[i]=o[i])}get request(){return this._request}send(){let e=new n(this._ua,this._request,{onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onAuthenticated:e=>{this._eventHandlers.onAuthenticated(e)},onReceiveResponse:e=>{this._receiveResponse(e)}});if(e.send(),(this._request.method===i.INVITE||this._request.method===i.UPDATE&&this._request.body)&&e.clientTransaction.state!==r.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;let t=()=>{(e.clientTransaction.state===r.C.STATUS_ACCEPTED||e.clientTransaction.state===r.C.STATUS_COMPLETED||e.clientTransaction.state===r.C.STATUS_TERMINATED)&&(e.clientTransaction.removeListener("stateChanged",t),this._dialog.uac_pending_reply=!1)};e.clientTransaction.on("stateChanged",t)}}_receiveResponse(e){408===e.status_code||481===e.status_code?this._eventHandlers.onDialogError(e):e.method===i.INVITE&&491===e.status_code?this._reattempt?this._eventHandlers.onErrorResponse(e):(this._request.cseq=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout(()=>{this._dialog.isTerminated()||(this._reattempt=!0,this.send())},1e3)):e.status_code>=200&&e.status_code<300?this._eventHandlers.onSuccessResponse(e):e.status_code>=300&&this._eventHandlers.onErrorResponse(e)}}}
51,7503:(e,t,s)=>{"use strict";let i=s(608).EventEmitter,r=s(8166),n=s(507),o=s(44),a=s(5987),h=new r("RTCSession:DTMF"),c={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};e.exports=class extends i{constructor(e){super(),this._session=e,this._direction=null,this._tone=null,this._duration=null,this._request=null}get tone(){return this._tone}get duration(){return this._duration}send(e,t={}){if(void 0===e)throw TypeError("Not enough arguments");if(this._direction="outgoing",this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK&&this._session.status!==this._session.C.STATUS_1XX_RECEIVED)throw new o.InvalidStateError(this._session.status);let s=a.cloneArray(t.extraHeaders);if(this.eventHandlers=a.cloneObject(t.eventHandlers),"string"==typeof e)e=e.toUpperCase();else if("number"==typeof e)e=e.toString();else throw TypeError(`Invalid tone: ${e}`);if(e.match(/^[0-9A-DR#*]$/))this._tone=e;else throw TypeError(`Invalid tone: ${e}`);this._duration=t.duration,s.push("Content-Type: application/dtmf-relay");let i=`Signal=${this._tone}\r 52`;i+=`Duration=${this._duration}`,this._session.newDTMF({originator:"local",dtmf:this,request:this._request}),this._session.sendRequest(n.INFO,{extraHeaders:s,eventHandlers:{onSuccessResponse:e=>{this.emit("succeeded",{originator:"remote",response:e})},onErrorResponse:e=>{this.eventHandlers.onFailed&&this.eventHandlers.onFailed(),this.emit("failed",{originator:"remote",response:e})},onRequestTimeout:()=>{this._session.onRequestTimeout()},onTransportError:()=>{this._session.onTransportError()},onDialogError:()=>{this._session.onDialogError()}},body:i})}init_incoming(e){let t=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,s=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;if(this._direction="incoming",this._request=e,e.reply(200),e.body){let i=e.body.split("\n");i.length>=1&&t.test(i[0])&&(this._tone=i[0].replace(t,"$2")),i.length>=2&&s.test(i[1])&&(this._duration=parseInt(i[1].replace(s,"$2"),10))}this._duration||(this._duration=c.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:e}):h.debug("invalid INFO DTMF received, discarded")}},e.exports.C=c},7879:(e,t,s)=>{"use strict";let i=s(5347),r=s(1447);e.exports=class e{static parse(e){return -1!==(e=r.parse(e,"Name_Addr_Header"))?e:void 0}constructor(e,t,s){if(!e||!(e instanceof i))throw TypeError('missing or invalid "uri" parameter');for(let i in this._uri=e,this._parameters={},this.display_name=t,s)Object.prototype.hasOwnProperty.call(s,i)&&this.setParam(i,s[i])}get uri(){return this._uri}get display_name(){return this._display_name}set display_name(e){this._display_name=0===e?"0":e}setParam(e,t){e&&(this._parameters[e.toLowerCase()]=null==t?null:t.toString())}getParam(e){if(e)return this._parameters[e.toLowerCase()]}hasParam(e){if(e)return this._parameters.hasOwnProperty(e.toLowerCase())&&!0||!1}deleteParam(e){if(e=e.toLowerCase(),this._parameters.hasOwnProperty(e)){let t=this._parameters[e];return delete this._parameters[e],t}}clearParams(){this._parameters={}}clone(){return new e(this._uri.clone(),this._display_name,JSON.parse(JSON.stringify(this._parameters)))}_quote(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}toString(){let e=this._display_name?`"${this._quote(this._display_name)}" `:"";for(let t in e+=`<${this._uri.toString()}>`,this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,t)&&(e+=`;${t}`,null!==this._parameters[t]&&(e+=`=${this._parameters[t]}`));return e}}},7914:(e,t,s)=>{"use strict";let i=s(8166),r=s(507),n=s(9766),o=s(8775),a=new i("RequestSender"),h={onRequestTimeout:()=>{},onTransportError:()=>{},onReceiveResponse:()=>{},onAuthenticated:()=>{}};e.exports=class{constructor(e,t,s){for(let i in this._ua=e,this._eventHandlers=s,this._method=t.method,this._request=t,this._auth=null,this._challenged=!1,this._staled=!1,h)Object.prototype.hasOwnProperty.call(h,i)&&!this._eventHandlers[i]&&(this._eventHandlers[i]=h[i]);e.status===e.C.STATUS_USER_CLOSED&&(this._method!==r.BYE||this._method!==r.ACK)&&this._eventHandlers.onTransportError()}send(){let e={onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onReceiveResponse:e=>{this._receiveResponse(e)}};switch(this._method){case"INVITE":this.clientTransaction=new o.InviteClientTransaction(this._ua,this._ua.transport,this._request,e);break;case"ACK":this.clientTransaction=new o.AckClientTransaction(this._ua,this._ua.transport,this._request,e);break;default:this.clientTransaction=new o.NonInviteClientTransaction(this._ua,this._ua.transport,this._request,e)}this._ua._configuration.authorization_jwt&&this._request.setHeader("Authorization",this._ua._configuration.authorization_jwt),this.clientTransaction.send()}_receiveResponse(e){let t,s,i=e.status_code;if((401===i||407===i)&&(null!==this._ua.configuration.password||null!==this._ua.configuration.ha1)){if(401===e.status_code?(t=e.parseHeader("www-authenticate"),s="authorization"):(t=e.parseHeader("proxy-authenticate"),s="proxy-authorization"),!t){a.debug(`${e.status_code} with wrong or missing challenge, cannot authenticate`),this._eventHandlers.onReceiveResponse(e);return}if(this._challenged&&(this._staled||!0!==t.stale))this._eventHandlers.onReceiveResponse(e);else{if(this._auth||(this._auth=new n({username:this._ua.configuration.authorization_user,password:this._ua.configuration.password,realm:this._ua.configuration.realm,ha1:this._ua.configuration.ha1})),!this._auth.authenticate(this._request,t))return void this._eventHandlers.onReceiveResponse(e);this._challenged=!0,this._ua.set("realm",this._auth.get("realm")),this._ua.set("ha1",this._auth.get("ha1")),t.stale&&(this._staled=!0),this._request=this._request.clone(),this._request.cseq+=1,this._request.setHeader("cseq",`${this._request.cseq} ${this._method}`),this._request.setHeader(s,this._auth.toString()),this._eventHandlers.onAuthenticated(this._request),this.send()}}else this._eventHandlers.onReceiveResponse(e)}}},8166:(e,t,s)=>{"use strict";let i=s(9941),r="JsSIP";e.exports=class{constructor(e){e?(this._debug=i.default(`${r}:${e}`),this._warn=i.default(`${r}:WARN:${e}`),this._error=i.default(`${r}:ERROR:${e}`)):(this._debug=i.default(r),this._warn=i.default(`${r}:WARN`),this._error=i.default(`${r}:ERROR`)),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}
52get debug(){return this._debug}get warn(){return this._warn}get error(){return this._error}}},8775:(e,t,s)=>{"use strict";let i=s(608).EventEmitter,r=s(8166),n=s(507),o=s(1913),a=s(9308),h=new r("NonInviteClientTransaction"),c=new r("InviteClientTransaction"),u=new r("AckClientTransaction"),_=new r("NonInviteServerTransaction"),l=new r("InviteServerTransaction"),d={STATUS_TRYING:1,STATUS_PROCEEDING:2,STATUS_CALLING:3,STATUS_ACCEPTED:4,STATUS_COMPLETED:5,STATUS_TERMINATED:6,STATUS_CONFIRMED:7,NON_INVITE_CLIENT:"nict",NON_INVITE_SERVER:"nist",INVITE_CLIENT:"ict",INVITE_SERVER:"ist"};class p extends i{constructor(e,t,s,i){super(),this.type=d.NON_INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(1e7*Math.random())}`,this.ua=e,this.transport=t,this.request=s,this.eventHandlers=i;let r=`SIP/2.0/${t.via_transport}`;r+=` ${e.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",r),this.ua.newTransaction(this)}get C(){return d}stateChanged(e){this.state=e,this.emit("stateChanged")}send(){this.stateChanged(d.STATUS_TRYING),this.F=setTimeout(()=>{this.timer_F()},a.TIMER_F),this.transport.send(this.request)||this.onTransportError()}onTransportError(){h.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(d.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}timer_F(){h.debug(`Timer F expired for transaction ${this.id}`),this.stateChanged(d.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}timer_K(){this.stateChanged(d.STATUS_TERMINATED),this.ua.destroyTransaction(this)}receiveResponse(e){let t=e.status_code;if(t<200)switch(this.state){case d.STATUS_TRYING:case d.STATUS_PROCEEDING:this.stateChanged(d.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(e)}else switch(this.state){case d.STATUS_TRYING:case d.STATUS_PROCEEDING:this.stateChanged(d.STATUS_COMPLETED),clearTimeout(this.F),408===t?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(e),this.K=setTimeout(()=>{this.timer_K()},a.TIMER_K);case d.STATUS_COMPLETED:}}}class m extends i{constructor(e,t,s,i){super(),this.type=d.INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(1e7*Math.random())}`,this.ua=e,this.transport=t,this.request=s,this.eventHandlers=i,s.transaction=this;let r=`SIP/2.0/${t.via_transport}`;r+=` ${e.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",r),this.ua.newTransaction(this)}get C(){return d}stateChanged(e){this.state=e,this.emit("stateChanged")}send(){this.stateChanged(d.STATUS_CALLING),this.B=setTimeout(()=>{this.timer_B()},a.TIMER_B),this.transport.send(this.request)||this.onTransportError()}onTransportError(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==d.STATUS_ACCEPTED&&(c.debug(`transport error occurred, deleting transaction ${this.id}`),this.eventHandlers.onTransportError()),this.stateChanged(d.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_M(){c.debug(`Timer M expired for transaction ${this.id}`),this.state===d.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(d.STATUS_TERMINATED),this.ua.destroyTransaction(this))}timer_B(){c.debug(`Timer B expired for transaction ${this.id}`),this.state===d.STATUS_CALLING&&(this.stateChanged(d.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}timer_D(){c.debug(`Timer D expired for transaction ${this.id}`),clearTimeout(this.B),this.stateChanged(d.STATUS_TERMINATED),this.ua.destroyTransaction(this)}sendACK(e){let t=new o.OutgoingRequest(n.ACK,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});t.setHeader("from",this.request.getHeader("from")),t.setHeader("via",this.request.getHeader("via")),t.setHeader("to",e.getHeader("to")),this.D=setTimeout(()=>{this.timer_D()},a.TIMER_D),this.transport.send(t)}cancel(e){if(this.state!==d.STATUS_PROCEEDING)return;let t=new o.OutgoingRequest(n.CANCEL,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});t.setHeader("from",this.request.getHeader("from")),t.setHeader("via",this.request.getHeader("via")),t.setHeader("to",this.request.getHeader("to")),e&&t.setHeader("reason",e),this.transport.send(t)}receiveResponse(e){let t=e.status_code;if(t>=100&&t<=199)switch(this.state){case d.STATUS_CALLING:this.stateChanged(d.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(e);break;case d.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(e)}else if(t>=200&&t<=299)switch(this.state){case d.STATUS_CALLING:case d.STATUS_PROCEEDING:this.stateChanged(d.STATUS_ACCEPTED),this.M=setTimeout(()=>{this.timer_M()},a.TIMER_M),this.eventHandlers.onReceiveResponse(e);break;case d.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(e)}else if(t>=300&&t<=699)switch(this.state){case d.STATUS_CALLING:case d.STATUS_PROCEEDING:this.stateChanged(d.STATUS_COMPLETED),this.sendACK(e),this.eventHandlers.onReceiveResponse(e);break;case d.STATUS_COMPLETED:this.sendACK(e)}}}class g extends i{constructor(e,t,s,i){super(),this.id=`z9hG4bK${Math.floor(1e7*Math.random())}`,this.transport=t,this.request=s,this.eventHandlers=i;let r=`SIP/2.0/${t.via_transport}`;r+=` ${e.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",r)}get C(){return d}send(){this.transport.send(this.request)||this.onTransportError()}onTransportError(){u.debug(`transport error occurred for transaction ${this.id}`),this.eventHandlers.onTransportError()}}class T extends i{constructor(e,t,s){super(),this.type=d.NON_INVITE_SERVER,this.id=s.via_branch,this.ua=e,this.transport=t,this.request=s,this.last_response="",s.server_transaction=this,this.state=d.STATUS_TRYING,e.newTransaction(this)}get C(){return d}
52stateChanged(e){this.state=e,this.emit("stateChanged")}timer_J(){_.debug(`Timer J expired for transaction ${this.id}`),this.stateChanged(d.STATUS_TERMINATED),this.ua.destroyTransaction(this)}onTransportError(){this.transportError||(this.transportError=!0,_.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.J),this.stateChanged(d.STATUS_TERMINATED),this.ua.destroyTransaction(this))}receiveResponse(e,t,s,i){if(100===e)switch(this.state){case d.STATUS_TRYING:this.stateChanged(d.STATUS_PROCEEDING),this.transport.send(t)||this.onTransportError();break;case d.STATUS_PROCEEDING:this.last_response=t,this.transport.send(t)?s&&s():(this.onTransportError(),i&&i())}else if(e>=200&&e<=699)switch(this.state){case d.STATUS_TRYING:case d.STATUS_PROCEEDING:this.stateChanged(d.STATUS_COMPLETED),this.last_response=t,this.J=setTimeout(()=>{this.timer_J()},a.TIMER_J),this.transport.send(t)?s&&s():(this.onTransportError(),i&&i());case d.STATUS_COMPLETED:}}}class f extends i{constructor(e,t,s){super(),this.type=d.INVITE_SERVER,this.id=s.via_branch,this.ua=e,this.transport=t,this.request=s,this.last_response="",s.server_transaction=this,this.state=d.STATUS_PROCEEDING,e.newTransaction(this),this.resendProvisionalTimer=null,s.reply(100)}get C(){return d}stateChanged(e){this.state=e,this.emit("stateChanged")}timer_H(){l.debug(`Timer H expired for transaction ${this.id}`),this.state===d.STATUS_COMPLETED&&l.debug("ACK not received, dialog will be terminated"),this.stateChanged(d.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_I(){this.stateChanged(d.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_L(){l.debug(`Timer L expired for transaction ${this.id}`),this.state===d.STATUS_ACCEPTED&&(this.stateChanged(d.STATUS_TERMINATED),this.ua.destroyTransaction(this))}onTransportError(){this.transportError||(this.transportError=!0,l.debug(`transport error occurred, deleting transaction ${this.id}`),null!==this.resendProvisionalTimer&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),clearTimeout(this.L),clearTimeout(this.H),clearTimeout(this.I),this.stateChanged(d.STATUS_TERMINATED),this.ua.destroyTransaction(this))}resend_provisional(){this.transport.send(this.last_response)||this.onTransportError()}receiveResponse(e,t,s,i){if(e>=100&&e<=199&&this.state===d.STATUS_PROCEEDING&&(this.transport.send(t)||this.onTransportError(),this.last_response=t),e>100&&e<=199&&this.state===d.STATUS_PROCEEDING)null===this.resendProvisionalTimer&&(this.resendProvisionalTimer=setInterval(()=>{this.resend_provisional()},a.PROVISIONAL_RESPONSE_INTERVAL));else if(e>=200&&e<=299)switch(this.state){case d.STATUS_PROCEEDING:this.stateChanged(d.STATUS_ACCEPTED),this.last_response=t,this.L=setTimeout(()=>{this.timer_L()},a.TIMER_L),null!==this.resendProvisionalTimer&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case d.STATUS_ACCEPTED:this.transport.send(t)?s&&s():(this.onTransportError(),i&&i())}else e>=300&&e<=699&&this.state===d.STATUS_PROCEEDING&&(null!==this.resendProvisionalTimer&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(t)?(this.stateChanged(d.STATUS_COMPLETED),this.H=setTimeout(()=>{this.timer_H()},a.TIMER_H),s&&s()):(this.onTransportError(),i&&i()))}}e.exports={C:d,NonInviteClientTransaction:p,InviteClientTransaction:m,AckClientTransaction:g,NonInviteServerTransaction:T,InviteServerTransaction:f,checkTransaction:function({_transactions:e},t){let s;switch(t.method){case n.INVITE:if(s=e.ist[t.via_branch]){switch(s.state){case d.STATUS_PROCEEDING:s.transport.send(s.last_response);case d.STATUS_ACCEPTED:}return!0}break;case n.ACK:if(!(s=e.ist[t.via_branch]))return!1;if(s.state===d.STATUS_ACCEPTED)return!1;if(s.state===d.STATUS_COMPLETED)return s.state=d.STATUS_CONFIRMED,s.I=setTimeout(()=>{s.timer_I()},a.TIMER_I),!0;break;case n.CANCEL:if(!(s=e.ist[t.via_branch]))return t.reply_sl(481),!0;if(t.reply_sl(200),s.state===d.STATUS_PROCEEDING)return!1;return!0;default:if(s=e.nist[t.via_branch]){switch(s.state){case d.STATUS_TRYING:break;case d.STATUS_PROCEEDING:case d.STATUS_COMPLETED:s.transport.send(s.last_response)}return!0}}}}},9276:(e,t,s)=>{"use strict";let i=s(5987),r=s(507),n=s(1447),o=s(5347),a=s(4255),h=s(44);t.settings={authorization_user:null,password:null,realm:null,ha1:null,authorization_jwt:null,display_name:null,uri:null,contact_uri:null,instance_id:null,use_preloaded_route:!1,session_timers:!0,session_timers_refresh_method:r.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,register_from_tag_trail:"",registrar_server:null,sockets:null,connection_recovery_max_interval:r.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:r.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:`${i.createRandomToken(12)}.invalid`};let c={mandatory:{sockets(e){let t=[];if(a.isSocket(e))t.push({socket:e});else if(!Array.isArray(e)||!e.length)return;else for(let s of e)Object.prototype.hasOwnProperty.call(s,"socket")&&a.isSocket(s.socket)?t.push(s):a.isSocket(s)&&t.push({socket:s});return t},uri(e){/^sip:/i.test(e)||(e=`${r.SIP}:${e}`);
52let t=o.parse(e);return t&&t.user?t:void 0}},optional:{authorization_user(e){if(-1!==n.parse(`"${e}"`,"quoted_string"))return e},authorization_jwt(e){if("string"==typeof e)return e},user_agent(e){if("string"==typeof e)return e},connection_recovery_max_interval(e){if(i.isDecimal(e)){let t=Number(e);if(t>0)return t}},connection_recovery_min_interval(e){if(i.isDecimal(e)){let t=Number(e);if(t>0)return t}},contact_uri(e){if("string"==typeof e){let t=n.parse(e,"SIP_URI");if(-1!==t)return t}},display_name:e=>e,instance_id(e){if(/^uuid:/i.test(e)&&(e=e.substr(5)),-1!==n.parse(e,"uuid"))return e},no_answer_timeout(e){if(i.isDecimal(e)){let t=Number(e);if(t>0)return t}},session_timers(e){if("boolean"==typeof e)return e},session_timers_refresh_method(e){if("string"==typeof e&&((e=e.toUpperCase())===r.INVITE||e===r.UPDATE))return e},session_timers_force_refresher(e){if("boolean"==typeof e)return e},password:e=>String(e),realm:e=>String(e),ha1:e=>String(e),register(e){if("boolean"==typeof e)return e},register_expires(e){if(i.isDecimal(e)){let t=Number(e);if(t>=0)return t}},register_from_tag_trail:e=>"function"==typeof e?e:String(e),registrar_server(e){/^sip:/i.test(e)||(e=`${r.SIP}:${e}`);let t=o.parse(e);return t?t.user?void 0:t:void 0},use_preloaded_route(e){if("boolean"==typeof e)return e},extra_headers(e){let t=[];if(Array.isArray(e)&&e.length){for(let s of e)"string"==typeof s&&t.push(s);return t}}}};t.load=(e,t)=>{for(let s in c.mandatory)if(t.hasOwnProperty(s)){let i=t[s],r=c.mandatory[s](i);if(void 0!==r)e[s]=r;else throw new h.ConfigurationError(s,i)}else throw new h.ConfigurationError(s);for(let s in c.optional)if(t.hasOwnProperty(s)){let r=t[s];if(i.isEmpty(r))continue;let n=c.optional[s](r);if(void 0!==n)e[s]=n;else throw new h.ConfigurationError(s,r)}}},9308:e=>{"use strict";e.exports={T1:500,T2:4e3,T4:5e3,TIMER_B:32e3,TIMER_D:0,TIMER_F:32e3,TIMER_H:32e3,TIMER_I:0,TIMER_J:0,TIMER_K:0,TIMER_L:32e3,TIMER_M:32e3,PROVISIONAL_RESPONSE_INTERVAL:6e4}},9766:(e,t,s)=>{"use strict";let i=s(8166),r=s(5987),n=new i("DigestAuthentication");e.exports=class{constructor(e){this._credentials=e,this._cnonce=null,this._nc=0,this._ncHex="00000000",this._algorithm=null,this._realm=null,this._nonce=null,this._opaque=null,this._stale=null,this._qop=null,this._method=null,this._uri=null,this._ha1=null,this._response=null}get(e){switch(e){case"realm":return this._realm;case"ha1":return this._ha1;default:return void n.warn('get() | cannot get "%s" parameter',e)}}authenticate({method:e,ruri:t,body:s},i,o=null){let a,h;if(this._algorithm=i.algorithm,this._realm=i.realm,this._nonce=i.nonce,this._opaque=i.opaque,this._stale=i.stale,this._algorithm){if("MD5"!==this._algorithm)return n.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return n.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return n.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return n.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return n.warn('authenticate() | no plain SIP password, and stored `realm` does not match the given `realm`, cannot authenticate [stored:"%s", given:"%s"]',this._credentials.realm,this._realm),!1}if(i.qop)if(i.qop.indexOf("auth-int")>-1)this._qop="auth-int";else{if(!(i.qop.indexOf("auth")>-1))return n.warn('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;this._qop="auth"}else this._qop=null;this._method=e,this._uri=t,this._cnonce=o||r.createRandomToken(12),this._nc+=1;let c=Number(this._nc).toString(16);return this._ncHex="00000000".substr(0,8-c.length)+c,0x100000000===this._nc&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=r.calculateMD5(`${this._credentials.username}:${this._realm}:${this._credentials.password}`):this._ha1=this._credentials.ha1,"auth"===this._qop?(a=`${this._method}:${this._uri}`,h=r.calculateMD5(a),n.debug('authenticate() | using qop=auth [a2:"%s"]',a),this._response=r.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth:${h}`)):"auth-int"===this._qop?(a=`${this._method}:${this._uri}:${r.calculateMD5(s||"")}`,h=r.calculateMD5(a),n.debug('authenticate() | using qop=auth-int [a2:"%s"]',a),this._response=r.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth-int:${h}`)):null===this._qop&&(a=`${this._method}:${this._uri}`,h=r.calculateMD5(a),n.debug('authenticate() | using qop=null [a2:"%s"]',a),this._response=r.calculateMD5(`${this._ha1}:${this._nonce}:${h}`)),n.debug("authenticate() | response generated"),!0}toString(){let e=[];
52if(!this._response)throw Error("response field does not exist, cannot generate Authorization header");return e.push(`algorithm=${this._algorithm}`),e.push(`username="${this._credentials.username}"`),e.push(`realm="${this._realm}"`),e.push(`nonce="${this._nonce}"`),e.push(`uri="${this._uri}"`),e.push(`response="${this._response}"`),this._opaque&&e.push(`opaque="${this._opaque}"`),this._qop&&(e.push(`qop=${this._qop}`),e.push(`cnonce="${this._cnonce}"`),e.push(`nc=${this._ncHex}`)),`Digest ${e.join(", ")}`}}},9941:(e,t,s)=>{var i=s(522);t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;let s="color: "+this.color;t.splice(1,0,s,"color: inherit");let i=0,r=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(i++,"%c"===e&&(r=i))}),t.splice(r,0,s)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}return!e&&void 0!==i&&"env"in i&&(e=i.env.DEBUG),e},t.useColors=function(){let e;return"undefined"!=typeof window&&!!window.process&&("renderer"===window.process.type||!!window.process.__nwjs)||!("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=s(6338)(t);let{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.