(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-24e0d2d6"],{"06fc":function(e,t,n){"use strict";function r(e){return r="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&d(e,t)}function s(e){var t=h();return function(){var n,r=_(e);if(t){var l=_(this).constructor;n=Reflect.construct(r,arguments,l)}else n=r.apply(this,arguments);return o(this,n)}}function o(e,t){return!t||"object"!==r(t)&&"function"!==typeof t?u(e):t}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function a(e){var t="function"===typeof Map?new Map:void 0;return a=function(e){if(null===e||!f(e))return e;if("function"!==typeof e)throw new TypeError("Super expression must either be null or a function");if("undefined"!==typeof t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return c(e,arguments,_(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),d(n,e)},a(e)}function c(e,t,n){return c=h()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var l=Function.bind.apply(e,r),i=new l;return n&&d(i,n.prototype),i},c.apply(null,arguments)}function h(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function f(e){return-1!==Function.toString.call(e).indexOf("[native code]")}function d(e,t){return d=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},d(e,t)}function _(e){return _=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},_(e)}var p=function(e){i(n,e);var t=s(n);function n(e,r){var i;return l(this,n),i=t.call(this),i.code=1,i.name="CONFIGURATION_ERROR",i.parameter=e,i.value=r,i.message=i.value?"Invalid value ".concat(JSON.stringify(i.value),' for parameter "').concat(i.parameter,'"'):"Missing parameter: ".concat(i.parameter),i}return n}(a(Error)),m=function(e){i(n,e);var t=s(n);function n(e){var r;return l(this,n),r=t.call(this),r.code=2,r.name="INVALID_STATE_ERROR",r.status=e,r.message="Invalid status: ".concat(e),r}return n}(a(Error)),v=function(e){i(n,e);var t=s(n);function n(e){var r;return l(this,n),r=t.call(this),r.code=3,r.name="NOT_SUPPORTED_ERROR",r.message=e,r}return n}(a(Error)),g=function(e){i(n,e);var t=s(n);function n(e){var r;return l(this,n),r=t.call(this),r.code=4,r.name="NOT_READY_ERROR",r.message=e,r}return n}(a(Error));e.exports={ConfigurationError:p,InvalidStateError:m,NotSupportedError:v,NotReadyError:g}},"0f27":function(e,t,n){"use strict";var r,l="object"===typeof Reflect?Reflect:null,i=l&&"function"===typeof l.apply?l.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};function s(e){console&&console.warn&&console.warn(e)}r=l&&"function"===typeof l.ownKeys?l.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=Number.isNaN||function(e){return e!==e};function u(){u.init.call(this)}e.exports=u,e.exports.once=T,u.EventEmitter=u,u.prototype._events=void 0,u.prototype._eventsCount=0,u.prototype._maxListeners=void 0;var a=10;function c(e){if("function"!==typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function h(e){return void 0===e._maxListeners?u.defaultMaxListeners:e._maxListeners}function f(e,t,n,r){var l,i,o;if(c(n),i=e._events,void 0===i?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),i=e._events),o=i[t]),void 0===o)o=i[t]=n,++e._eventsCount;else if("function"===typeof o?o=i[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),l=h(e),l>0&&o.length>l&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=o.length,s(u)}return e}function d(){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,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},l=d.bind(r);return l.listener=n,r.wrapFn=l,l}function p(e,t,n){var r=e._events;if(void 0===r)return[];var l=r[t];return void 0===l?[]:"function"===typeof l?n?[l.listener||l]:[l]:n?y(l):v(l,l.length)}function m(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"===typeof n)return 1;if(void 0!==n)return n.length}return 0}function v(e,t){for(var n=new Array(t),r=0;r0&&(s=t[0]),s instanceof Error)throw s;var o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var u=l[e];if(void 0===u)return!1;if("function"===typeof u)i(u,this,t);else{var a=u.length,c=v(u,a);for(n=0;n=0;i--)if(n[i]===t||n[i].listener===t){s=n[i].listener,l=i;break}if(l<0)return this;0===l?n.shift():g(n,l),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,s||t)}return this},u.prototype.off=u.prototype.removeListener,u.prototype.removeAllListeners=function(e){var t,n,r;if(n=this._events,void 0===n)return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var l,i=Object.keys(n);for(r=0;r=0;r--)this.removeListener(e,t[r]);return this},u.prototype.listeners=function(e){return p(this,e,!0)},u.prototype.rawListeners=function(e){return p(this,e,!1)},u.listenerCount=function(e,t){return"function"===typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},u.prototype.listenerCount=m,u.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},"11e1":function(e,t,n){"use strict";function r(e){return r="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};y.debug("sendRefer()");var r=g.cloneArray(n.extraHeaders),l=g.cloneObject(n.eventHandlers);for(var i in l)Object.prototype.hasOwnProperty.call(l,i)&&this.on(i,l[i]);var s=null;n.replaces&&(s=n.replaces._request.call_id,s+=";to-tag=".concat(n.replaces._to_tag),s+=";from-tag=".concat(n.replaces._from_tag),s=encodeURIComponent(s));var o="Refer-To: <".concat(e).concat(s?"?Replaces=".concat(s):"",">");if(r.push(o),!r.some((function(e){return e.toLowerCase().startsWith("referred-by:")}))){var u="Referred-By: <".concat(this._session._ua._configuration.uri._scheme,":").concat(this._session._ua._configuration.uri._user,"@").concat(this._session._ua._configuration.uri._host,">");r.push(u)}r.push("Contact: ".concat(this._session.contact));var a=this._session.sendRequest(m.REFER,{extraHeaders:r,eventHandlers:{onSuccessResponse:function(e){t._requestSucceeded(e)},onErrorResponse:function(e){t._requestFailed(e,m.causes.REJECTED)},onTransportError:function(){t._requestFailed(null,m.causes.CONNECTION_ERROR)},onRequestTimeout:function(){t._requestFailed(null,m.causes.REQUEST_TIMEOUT)},onDialogError:function(){t._requestFailed(null,m.causes.DIALOG_ERROR)}}});this._id=a.cseq}},{key:"receiveNotify",value:function(e){if(y.debug("receiveNotify()"),e.body){var t=v.parse(e.body.trim().split("\r\n",1)[0],"Status_Line");if(-1!==t)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;default:this.emit("failed",{request:e,status_line:t});break}else y.debug('receiveNotify() | error parsing NOTIFY body: "'.concat(e.body,'"'))}}},{key:"_requestSucceeded",value:function(e){y.debug("REFER succeeded"),y.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:e})}},{key:"_requestFailed",value:function(e,t){y.debug("REFER failed"),y.debug('emit "requestFailed"'),this.emit("requestFailed",{response:e||null,cause:t})}},{key:"id",get:function(){return this._id}}]),n}(_)},1260:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:null;if(this._algorithm=t.algorithm,this._realm=t.realm,this._nonce=t.nonce,this._opaque=t.opaque,this._stale=t.stale,this._algorithm){if("MD5"!==this._algorithm)return u.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return u.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return u.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return u.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return u.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(t.qop)if(t.qop.indexOf("auth-int")>-1)this._qop="auth-int";else{if(!(t.qop.indexOf("auth")>-1))return u.warn('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;this._qop="auth"}else this._qop=null;this._method=n,this._uri=r,this._cnonce=i||o.createRandomToken(12),this._nc+=1;var s,a,c=Number(this._nc).toString(16);return this._ncHex="00000000".substr(0,8-c.length)+c,4294967296===this._nc&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=o.calculateMD5("".concat(this._credentials.username,":").concat(this._realm,":").concat(this._credentials.password)):this._ha1=this._credentials.ha1,"auth"===this._qop?(s="".concat(this._method,":").concat(this._uri),a=o.calculateMD5(s),u.debug('authenticate() | using qop=auth [a2:"%s"]',s),this._response=o.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(this._ncHex,":").concat(this._cnonce,":auth:").concat(a))):"auth-int"===this._qop?(s="".concat(this._method,":").concat(this._uri,":").concat(o.calculateMD5(l||"")),a=o.calculateMD5(s),u.debug('authenticate() | using qop=auth-int [a2:"%s"]',s),this._response=o.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(this._ncHex,":").concat(this._cnonce,":auth-int:").concat(a))):null===this._qop&&(s="".concat(this._method,":").concat(this._uri),a=o.calculateMD5(s),u.debug('authenticate() | using qop=null [a2:"%s"]',s),this._response=o.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(a))),u.debug("authenticate() | response generated"),!0}},{key:"toString",value:function(){var e=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return e.push("algorithm=".concat(this._algorithm)),e.push('username="'.concat(this._credentials.username,'"')),e.push('realm="'.concat(this._realm,'"')),e.push('nonce="'.concat(this._nonce,'"')),e.push('uri="'.concat(this._uri,'"')),e.push('response="'.concat(this._response,'"')),this._opaque&&e.push('opaque="'.concat(this._opaque,'"')),this._qop&&(e.push("qop=".concat(this._qop)),e.push('cnonce="'.concat(this._cnonce,'"')),e.push("nc=".concat(this._ncHex))),"Digest ".concat(e.join(", "))}}]),e}()},"16d2":function(e,t,n){"use strict";var r=n("037d"),l=n("05a5"),i=n("a143"),s=n("05d7"),o=n("ca7c"),u=n("311e"),a=n("a33e"),c=n("eb5b"),h=n("0761"),f=TypeError,d=h((function(){[].keys().reduce((function(){}),void 0)})),_=!d&&a("reduce",f);r({target:"Iterator",proto:!0,real:!0,forced:d||_},{reduce:function(e){s(this);try{i(e)}catch(h){u(this,"throw",h)}var t=arguments.length<2,n=t?void 0:arguments[1];if(_)return c(_,this,t?[e]:[e,n]);var r=o(this),a=0;if(l(r,(function(r){t?(t=!1,n=r):n=e(n,r,a),a++}),{IS_RECORD:!0}),t)throw new f("Reduce of empty iterator with no initial value");return n}})},1969:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var n=0;n=200?"terminated;reason=noresource":"active;expires=".concat(this._expires),this._session.sendRequest(o.NOTIFY,{extraHeaders:["Event: ".concat(a.event_type,";id=").concat(this._id),"Subscription-State: ".concat(n),"Content-Type: ".concat(a.body_type)],body:"SIP/2.0 ".concat(e," ").concat(t),eventHandlers:{onErrorResponse:function(){this._active=!1}}}))}}]),e}()},"235f":function(e,t,n){"use strict";var r=n("8a18");e.exports={USER_AGENT:"".concat(r.title," ").concat(r.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",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}},"2c5f":function(e,t,n){"use strict";function r(e){return r="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:{},l=e;if(void 0===e)throw new TypeError("A target is required for OPTIONS");if(e=this._ua.normalizeTarget(e),!e)throw new TypeError("Invalid target: ".concat(l));var i=g.cloneArray(r.extraHeaders),s=g.cloneObject(r.eventHandlers),o=r.contentType||"application/sdp";for(var u in s)Object.prototype.hasOwnProperty.call(s,u)&&this.on(u,s[u]);i.push("Content-Type: ".concat(o)),this._request=new v.OutgoingRequest(m.OPTIONS,e,this._ua,null,i),t&&(this._request.body=t);var a=new y(this._ua,this._request,{onRequestTimeout:function(){n._onRequestTimeout()},onTransportError:function(){n._onTransportError()},onReceiveResponse:function(e){n._receiveResponse(e)}});this._newOptions("local",this._request),a.send()}},{key:"init_incoming",value:function(e){this._request=e,this._newOptions("remote",e),this._is_replied||(this._is_replied=!0,e.reply(200)),this._close()}},{key:"accept",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=g.cloneArray(e.extraHeaders),n=e.body;if("incoming"!==this._direction)throw new T.NotSupportedError('"accept" not supported for outgoing Options');if(this._is_replied)throw new Error("incoming Options already replied");this._is_replied=!0,this._request.reply(200,null,t,n)}},{key:"reject",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.status_code||480,n=e.reason_phrase,r=g.cloneArray(e.extraHeaders),l=e.body;if("incoming"!==this._direction)throw new T.NotSupportedError('"reject" not supported for outgoing Options');if(this._is_replied)throw new Error("incoming Options already replied");if(t<300||t>=700)throw new TypeError("Invalid status_code: ".concat(t));this._is_replied=!0,this._request.reply(t,n,r,l)}},{key:"_receiveResponse",value:function(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:var t=g.sipErrorCause(e.status_code);this._failed("remote",e,t);break}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,m.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,m.causes.CONNECTION_ERROR)}},{key:"_close",value:function(){this._closed=!0,this._ua.destroyMessage(this)}},{key:"_newOptions",value:function(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})}},{key:"_failed",value:function(e,t,n){b.debug("OPTIONS failed"),this._close(),b.debug('emit "failed"'),this.emit("failed",{originator:e,response:t||null,cause:n})}},{key:"_succeeded",value:function(e,t){b.debug("OPTIONS succeeded"),this._close(),b.debug('emit "succeeded"'),this.emit("succeeded",{originator:e,response:t})}},{key:"direction",get:function(){return this._direction}},{key:"local_identity",get:function(){return this._local_identity}},{key:"remote_identity",get:function(){return this._remote_identity}}]),n}(_)},"2cfd":function(e,t,n){"use strict";var r=n("2ad9");e.exports=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(r)},"361a":function(e,t,n){"use strict";function r(e){return r="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=e.anonymous||null,n=e.outbound||null,r="<";return r+=t?this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":this.pub_gruu||this.uri.toString(),!n||(t?this.temp_gruu:this.pub_gruu)||(r+=";ob"),r+=">",r}};var r=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register","extra_headers"];for(var l in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,l)&&(-1!==r.indexOf(l)?Object.defineProperty(this._configuration,l,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,l,{writable:!1,configurable:!1}));for(var i in k.debug("configuration parameters after validation:"),this._configuration)if(Object.prototype.hasOwnProperty.call(O.settings,i))switch(i){case"uri":case"registrar_server":k.debug("- ".concat(i,": ").concat(this._configuration[i]));break;case"password":case"ha1":case"authorization_jwt":k.debug("- ".concat(i,": NOT SHOWN"));break;default:k.debug("- ".concat(i,": ").concat(JSON.stringify(this._configuration[i])))}}},{key:"C",get:function(){return N}},{key:"status",get:function(){return this._status}},{key:"contact",get:function(){return this._contact}},{key:"configuration",get:function(){return this._configuration}},{key:"transport",get:function(){return this._transport}}]),n}(_)},3869:function(e,t,n){function r(e){function t(e){let t=0;for(let n=0;n{if("%%"===t)return"%";s++;const i=r.formatters[l];if("function"===typeof i){const r=e[s];t=i.call(n,r),e.splice(s,1),s--}return t}),r.formatArgs.call(n,e);const u=n.log||r.log;u.apply(n,e)}return o.namespace=e,o.useColors=r.useColors(),o.color=r.selectColor(e),o.extend=l,o.destroy=r.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(n!==r.namespaces&&(n=r.namespaces,i=r.enabled(e)),i),set:e=>{s=e}}),"function"===typeof r.init&&r.init(o),o}function l(e,t){const n=r(this.namespace+("undefined"===typeof t?":":t)+e);return n.log=this.log,n}function i(e){r.save(e),r.namespaces=e,r.names=[],r.skips=[];const t=("string"===typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const n of t)"-"===n[0]?r.skips.push(n.slice(1)):r.names.push(n)}function s(e,t){let n=0,r=0,l=-1,i=0;while(n"-"+e)].join(",");return r.enable(""),e}function u(e){for(const t of r.skips)if(s(e,t))return!1;for(const t of r.names)if(s(e,t))return!0;return!1}function a(e){return e instanceof Error?e.stack||e.message:e}function c(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.debug=r,r.default=r,r.coerce=a,r.disable=o,r.enable=i,r.enabled=u,r.humanize=n("f80e"),r.destroy=c,Object.keys(e).forEach(t=>{r[t]=e[t]}),r.names=[],r.skips=[],r.formatters={},r.selectColor=t,r.enable(r.load()),r}e.exports=r},"420e":function(e,t,n){"use strict";var r=n("a67a"),l=n("d578"),i=n("0900"),s=n("7b8e"),o=n("1177"),u=r(s),a=r("".slice),c=Math.ceil,h=function(e){return function(t,n,r){var s,h,f=i(o(t)),d=l(n),_=f.length,p=void 0===r?" ":i(r);return d<=_||""===p?f:(s=d-_,h=u(p,c(s/p.length)),h.length>s&&(h=a(h,0,s)),e?f+h:h+f)}};e.exports={start:h(!1),end:h(!0)}},"44ce":function(e,t){var n=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",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v",t}},{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","maxMessageSize"],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:new 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:new 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",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":"",t}},{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(n).forEach((function(e){var t=n[e];t.forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}))},"455e":function(e,t,n){"use strict";function r(e){return r="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function l(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}function i(e,t){return i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},i(e,t)}function s(e){var t=a();return function(){var n,r=c(e);if(t){var l=c(this).constructor;n=Reflect.construct(r,arguments,l)}else n=r.apply(this,arguments);return o(this,n)}}function o(e,t){return!t||"object"!==r(t)&&"function"!==typeof t?u(e):t}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function a(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}function h(e,t){var n;if("undefined"===typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=f(e))||t&&e&&"number"===typeof e.length){n&&(e=n);var r=0,l=function(){};return{s:l,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:l}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,o=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,i=e},f:function(){try{s||null==n["return"]||n["return"]()}finally{if(o)throw i}}}}function f(e,t){if(e){if("string"===typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(e,t):void 0}}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n")),this.setHeader("via",""),this.setHeader("max-forwards",y.MAX_FORWARDS);var o=l.to_uri||n,u=l.to_tag?{tag:l.to_tag}:null,a="undefined"!==typeof l.to_display_name?l.to_display_name:null;this.to=new b(o,a,u),this.setHeader("to",this.to.toString());var c,h=l.from_uri||r.configuration.uri,f={tag:l.from_tag||T.newTag()};c="undefined"!==typeof l.from_display_name?l.from_display_name:r.configuration.display_name?r.configuration.display_name:null,this.from=new b(h,c,f),this.setHeader("from",this.from.toString());var d=l.call_id||r.configuration.jssip_id+T.createRandomToken(15);this.call_id=d,this.setHeader("call-id",d);var p=l.cseq||Math.floor(1e4*Math.random());this.cseq=p,this.setHeader("cseq","".concat(p," ").concat(t))}return m(e,[{key:"setHeader",value:function(e,t){for(var n=new RegExp("^\\s*".concat(e,"\\s*:"),"i"),r=0;r1&&void 0!==arguments[1]?arguments[1]:0;if(e=T.headerize(e),this.headers[e]){if(!(t>=this.headers[e].length)){var n=this.headers[e][t],r=n.raw;if(n.parsed)return n.parsed;var l=C.parse(r,e.replace(/-/g,"_"));return-1===l?(this.headers[e].splice(t,1),void S.debug('error parsing "'.concat(e,'" header field with value "').concat(r,'"'))):(n.parsed=l,l)}S.debug('not so many "'.concat(e,'" headers present'))}else S.debug('header "'.concat(e,'" not present'))}},{key:"s",value:function(e,t){return this.parseHeader(e,t)}},{key:"setHeader",value:function(e,t){var n={raw:t};this.headers[T.headerize(e)]=[n]}},{key:"parseSDP",value:function(e){return!e&&this.sdp||(this.sdp=v.parse(this.body||"")),this.sdp}},{key:"toString",value:function(){return this.data}}]),e}(),R=function(e){l(n,e);var t=s(n);function n(e){var r;return _(this,n),r=t.call(this),r.ua=e,r.headers={},r.ruri=null,r.transport=null,r.server_transaction=null,r}return m(n,[{key:"reply",value:function(e,t,n,r,l,i){var s=[],o=this.getHeader("To");if(e=e||null,t=t||null,!e||e<100||e>699)throw new TypeError("Invalid status_code: ".concat(e));if(t&&"string"!==typeof t&&!(t instanceof String))throw new TypeError("Invalid reason_phrase: ".concat(t));t=t||y.REASON_PHRASE[e]||"",n=T.cloneArray(n),this.ua.configuration.extra_headers&&(n=n.concat(this.ua.configuration.extra_headers));var u="SIP/2.0 ".concat(e," ").concat(t,"\r\n");if(this.method===y.INVITE&&e>100&&e<=200){var a,c=this.getHeaders("record-route"),f=h(c);try{for(f.s();!(a=f.n()).done;){var d=a.value;u+="Record-Route: ".concat(d,"\r\n")}}catch(E){f.e(E)}finally{f.f()}}var _,p=this.getHeaders("via"),m=h(p);try{for(m.s();!(_=m.n()).done;){var v=_.value;u+="Via: ".concat(v,"\r\n")}}catch(E){m.e(E)}finally{m.f()}!this.to_tag&&e>100?o+=";tag=".concat(T.newTag()):this.to_tag&&!this.s("to").hasParam("tag")&&(o+=";tag=".concat(this.to_tag)),u+="To: ".concat(o,"\r\n"),u+="From: ".concat(this.getHeader("From"),"\r\n"),u+="Call-ID: ".concat(this.call_id,"\r\n"),u+="CSeq: ".concat(this.cseq," ").concat(this.method,"\r\n");var g,b=h(n);try{for(b.s();!(g=b.n()).done;){var C=g.value;u+="".concat(C.trim(),"\r\n")}}catch(E){b.e(E)}finally{b.f()}switch(this.method){case y.INVITE:this.ua.configuration.session_timers&&s.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&s.push("gruu"),s.push("ice","replaces");break;case y.UPDATE:this.ua.configuration.session_timers&&s.push("timer"),r&&s.push("ice"),s.push("replaces")}if(s.push("outbound"),this.method===y.OPTIONS?(u+="Allow: ".concat(y.ALLOWED_METHODS,"\r\n"),u+="Accept: ".concat(y.ACCEPTED_BODY_TYPES,"\r\n")):405===e?u+="Allow: ".concat(y.ALLOWED_METHODS,"\r\n"):415===e&&(u+="Accept: ".concat(y.ACCEPTED_BODY_TYPES,"\r\n")),u+="Supported: ".concat(s,"\r\n"),r){var S=T.str_utf8_length(r);u+="Content-Type: application/sdp\r\n",u+="Content-Length: ".concat(S,"\r\n\r\n"),u+=r}else u+="Content-Length: ".concat(0,"\r\n\r\n");this.server_transaction.receiveResponse(e,u,l,i)}},{key:"reply_sl",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this.getHeaders("via");if(!e||e<100||e>699)throw new TypeError("Invalid status_code: ".concat(e));if(t&&"string"!==typeof t&&!(t instanceof String))throw new TypeError("Invalid reason_phrase: ".concat(t));t=t||y.REASON_PHRASE[e]||"";var r,l="SIP/2.0 ".concat(e," ").concat(t,"\r\n"),i=h(n);try{for(i.s();!(r=i.n()).done;){var s=r.value;l+="Via: ".concat(s,"\r\n")}}catch(f){i.e(f)}finally{i.f()}var o=this.getHeader("To");if(!this.to_tag&&e>100?o+=";tag=".concat(T.newTag()):this.to_tag&&!this.s("to").hasParam("tag")&&(o+=";tag=".concat(this.to_tag)),l+="To: ".concat(o,"\r\n"),l+="From: ".concat(this.getHeader("From"),"\r\n"),l+="Call-ID: ".concat(this.call_id,"\r\n"),l+="CSeq: ".concat(this.cseq," ").concat(this.method,"\r\n"),this.ua.configuration.extra_headers){var u,a=h(this.ua.configuration.extra_headers);try{for(a.s();!(u=a.n()).done;){var c=u.value;l+="".concat(c.trim(),"\r\n")}}catch(f){a.e(f)}finally{a.f()}}l+="Content-Length: ".concat(0,"\r\n\r\n"),this.transport.send(l)}}]),n}(w),I=function(e){l(n,e);var t=s(n);function n(){var e;return _(this,n),e=t.call(this),e.headers={},e.status_code=null,e.reason_phrase=null,e}return n}(w);e.exports={OutgoingRequest:E,InitialOutgoingInviteRequest:A,IncomingRequest:R,IncomingResponse:I}},"5b94":function(e,t,n){"use strict";function r(e,t){var n;if("undefined"===typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=l(e))||t&&e&&"number"===typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,o=!0,u=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){u=!0,s=e},f:function(){try{o||null==n["return"]||n["return"]()}finally{if(u)throw s}}}}function l(e,t){if(e){if("string"===typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n4&&void 0!==arguments[4]?arguments[4]:{},o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};if(s(this,e),!r)throw new TypeError('missing or invalid "host" parameter');for(var u in this._parameters={},this._headers={},this._scheme=t||a.SIP,this._user=n,this._host=r,this._port=l,i)Object.prototype.hasOwnProperty.call(i,u)&&this.setParam(u,i[u]);for(var c in o)Object.prototype.hasOwnProperty.call(o,c)&&this.setHeader(c,o[c])}return u(e,null,[{key:"parse",value:function(e){return e=h.parse(e,"SIP_URI"),-1!==e?e:void 0}}]),u(e,[{key:"setParam",value:function(e,t){e&&(this._parameters[e.toLowerCase()]="undefined"===typeof t||null===t?null:t.toString())}},{key:"getParam",value:function(e){if(e)return this._parameters[e.toLowerCase()]}},{key:"hasParam",value:function(e){if(e)return!!this._parameters.hasOwnProperty(e.toLowerCase())}},{key:"deleteParam",value:function(e){if(e=e.toLowerCase(),this._parameters.hasOwnProperty(e)){var t=this._parameters[e];return delete this._parameters[e],t}}},{key:"clearParams",value:function(){this._parameters={}}},{key:"setHeader",value:function(e,t){this._headers[c.headerize(e)]=Array.isArray(t)?t:[t]}},{key:"getHeader",value:function(e){if(e)return this._headers[c.headerize(e)]}},{key:"hasHeader",value:function(e){if(e)return!!this._headers.hasOwnProperty(c.headerize(e))}},{key:"deleteHeader",value:function(e){if(e=c.headerize(e),this._headers.hasOwnProperty(e)){var t=this._headers[e];return delete this._headers[e],t}}},{key:"clearHeaders",value:function(){this._headers={}}},{key:"clone",value:function(){return new e(this._scheme,this._user,this._host,this._port,JSON.parse(JSON.stringify(this._parameters)),JSON.parse(JSON.stringify(this._headers)))}},{key:"toString",value:function(){var e=[],t="".concat(this._scheme,":");for(var n in this._user&&(t+="".concat(c.escapeUser(this._user),"@")),t+=this._host,(this._port||0===this._port)&&(t+=":".concat(this._port)),this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,n)&&(t+=";".concat(n),null!==this._parameters[n]&&(t+="=".concat(this._parameters[n])));for(var l in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,l)){var i,s=r(this._headers[l]);try{for(s.s();!(i=s.n()).done;){var o=i.value;e.push("".concat(l,"=").concat(o))}}catch(u){s.e(u)}finally{s.f()}}return e.length>0&&(t+="?".concat(e.join("&"))),t}},{key:"toAor",value:function(e){var t="".concat(this._scheme,":");return this._user&&(t+="".concat(c.escapeUser(this._user),"@")),t+=this._host,e&&(this._port||0===this._port)&&(t+=":".concat(this._port)),t}},{key:"scheme",get:function(){return this._scheme},set:function(e){this._scheme=e.toLowerCase()}},{key:"user",get:function(){return this._user},set:function(e){this._user=e}},{key:"host",get:function(){return this._host},set:function(e){this._host=e.toLowerCase()}},{key:"port",get:function(){return this._port},set:function(e){this._port=0===e?e:parseInt(e,10)||null}}]),e}()},"5ef6":function(e,t,n){"use strict";function r(e){return r="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n=100&&n<=199)switch(this.state){case E.STATUS_CALLING:this.stateChanged(E.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(e);break;case E.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(e);break}else if(n>=200&&n<=299)switch(this.state){case E.STATUS_CALLING:case E.STATUS_PROCEEDING:this.stateChanged(E.STATUS_ACCEPTED),this.M=setTimeout((function(){t.timer_M()}),g.TIMER_M),this.eventHandlers.onReceiveResponse(e);break;case E.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(e);break}else if(n>=300&&n<=699)switch(this.state){case E.STATUS_CALLING:case E.STATUS_PROCEEDING:this.stateChanged(E.STATUS_COMPLETED),this.sendACK(e),this.eventHandlers.onReceiveResponse(e);break;case E.STATUS_COMPLETED:this.sendACK(e);break}}},{key:"C",get:function(){return E}}]),n}(_),R=function(e){o(n,e);var t=a(n);function n(e,r,i,s){var o;l(this,n),o=t.call(this),o.id="z9hG4bK".concat(Math.floor(1e7*Math.random())),o.transport=r,o.request=i,o.eventHandlers=s;var u="SIP/2.0/".concat(r.via_transport);return u+=" ".concat(e.configuration.via_host,";branch=").concat(o.id),o.request.setHeader("via",u),o}return s(n,[{key:"send",value:function(){this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){b.debug("transport error occurred for transaction ".concat(this.id)),this.eventHandlers.onTransportError()}},{key:"C",get:function(){return E}}]),n}(_),I=function(e){o(n,e);var t=a(n);function n(e,r,i){var s;return l(this,n),s=t.call(this),s.type=E.NON_INVITE_SERVER,s.id=i.via_branch,s.ua=e,s.transport=r,s.request=i,s.last_response="",i.server_transaction=h(s),s.state=E.STATUS_TRYING,e.newTransaction(h(s)),s}return s(n,[{key:"stateChanged",value:function(e){this.state=e,this.emit("stateChanged")}},{key:"timer_J",value:function(){C.debug("Timer J expired for transaction ".concat(this.id)),this.stateChanged(E.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,C.debug("transport error occurred, deleting transaction ".concat(this.id)),clearTimeout(this.J),this.stateChanged(E.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"receiveResponse",value:function(e,t,n,r){var l=this;if(100===e)switch(this.state){case E.STATUS_TRYING:this.stateChanged(E.STATUS_PROCEEDING),this.transport.send(t)||this.onTransportError();break;case E.STATUS_PROCEEDING:this.last_response=t,this.transport.send(t)?n&&n():(this.onTransportError(),r&&r());break}else if(e>=200&&e<=699)switch(this.state){case E.STATUS_TRYING:case E.STATUS_PROCEEDING:this.stateChanged(E.STATUS_COMPLETED),this.last_response=t,this.J=setTimeout((function(){l.timer_J()}),g.TIMER_J),this.transport.send(t)?n&&n():(this.onTransportError(),r&&r());break;case E.STATUS_COMPLETED:break}}},{key:"C",get:function(){return E}}]),n}(_),O=function(e){o(n,e);var t=a(n);function n(e,r,i){var s;return l(this,n),s=t.call(this),s.type=E.INVITE_SERVER,s.id=i.via_branch,s.ua=e,s.transport=r,s.request=i,s.last_response="",i.server_transaction=h(s),s.state=E.STATUS_PROCEEDING,e.newTransaction(h(s)),s.resendProvisionalTimer=null,i.reply(100),s}return s(n,[{key:"stateChanged",value:function(e){this.state=e,this.emit("stateChanged")}},{key:"timer_H",value:function(){S.debug("Timer H expired for transaction ".concat(this.id)),this.state===E.STATUS_COMPLETED&&S.debug("ACK not received, dialog will be terminated"),this.stateChanged(E.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_I",value:function(){this.stateChanged(E.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_L",value:function(){S.debug("Timer L expired for transaction ".concat(this.id)),this.state===E.STATUS_ACCEPTED&&(this.stateChanged(E.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,S.debug("transport error occurred, deleting transaction ".concat(this.id)),null!==this.resendProvisionalTimer&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),clearTimeout(this.L),clearTimeout(this.H),clearTimeout(this.I),this.stateChanged(E.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"resend_provisional",value:function(){this.transport.send(this.last_response)||this.onTransportError()}},{key:"receiveResponse",value:function(e,t,n,r){var l=this;if(e>=100&&e<=199)switch(this.state){case E.STATUS_PROCEEDING:this.transport.send(t)||this.onTransportError(),this.last_response=t;break}if(e>100&&e<=199&&this.state===E.STATUS_PROCEEDING)null===this.resendProvisionalTimer&&(this.resendProvisionalTimer=setInterval((function(){l.resend_provisional()}),g.PROVISIONAL_RESPONSE_INTERVAL));else if(e>=200&&e<=299)switch(this.state){case E.STATUS_PROCEEDING:this.stateChanged(E.STATUS_ACCEPTED),this.last_response=t,this.L=setTimeout((function(){l.timer_L()}),g.TIMER_L),null!==this.resendProvisionalTimer&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case E.STATUS_ACCEPTED:this.transport.send(t)?n&&n():(this.onTransportError(),r&&r());break}else if(e>=300&&e<=699)switch(this.state){case E.STATUS_PROCEEDING:null!==this.resendProvisionalTimer&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(t)?(this.stateChanged(E.STATUS_COMPLETED),this.H=setTimeout((function(){l.timer_H()}),g.TIMER_H),n&&n()):(this.onTransportError(),r&&r());break}}},{key:"C",get:function(){return E}}]),n}(_);function k(e,t){var n,r=e._transactions;switch(t.method){case m.INVITE:if(n=r.ist[t.via_branch],n){switch(n.state){case E.STATUS_PROCEEDING:n.transport.send(n.last_response);break;case E.STATUS_ACCEPTED:break}return!0}break;case m.ACK:if(n=r.ist[t.via_branch],!n)return!1;if(n.state===E.STATUS_ACCEPTED)return!1;if(n.state===E.STATUS_COMPLETED)return n.state=E.STATUS_CONFIRMED,n.I=setTimeout((function(){n.timer_I()}),g.TIMER_I),!0;break;case m.CANCEL:return n=r.ist[t.via_branch],n?(t.reply_sl(200),n.state!==E.STATUS_PROCEEDING):(t.reply_sl(481),!0);default:if(n=r.nist[t.via_branch],n){switch(n.state){case E.STATUS_TRYING:break;case E.STATUS_PROCEEDING:case E.STATUS_COMPLETED:n.transport.send(n.last_response);break}return!0}break}}e.exports={C:E,NonInviteClientTransaction:A,InviteClientTransaction:w,AckClientTransaction:R,NonInviteServerTransaction:I,InviteServerTransaction:O,checkTransaction:k}},"6d1c":function(e,t,n){"use strict";var r=500,l=4e3,i=5e3;e.exports={T1:r,T2:l,T4:i,TIMER_B:64*r,TIMER_D:0*r,TIMER_F:64*r,TIMER_H:64*r,TIMER_I:0*r,TIMER_J:0*r,TIMER_K:0*i,TIMER_L:64*r,TIMER_M:64*r,PROVISIONAL_RESPONSE_INTERVAL:6e4}},"7b6b":function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:c.recovery_options;r(this,e),a.debug("new()"),this.status=c.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=n,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1;try{this.textDecoder=new TextDecoder("utf8")}catch(l){a.warn("cannot use TextDecoder: ".concat(l))}if("undefined"===typeof t)throw new TypeError("Invalid argument. undefined 'sockets' argument");t instanceof Array||(t=[t]),t.forEach((function(e){if(!o.isSocket(e.socket))throw new TypeError("Invalid argument. invalid 'JsSIP.Socket' instance");if(e.weight&&!Number(e.weight))throw new TypeError("Invalid argument. 'weight' attribute is not a number");this.sockets.push({socket:e.socket,weight:e.weight||0,status:c.SOCKET_STATUS_READY})}),this),this._getSocket()}return i(e,[{key:"connect",value:function(){a.debug("connect()"),this.isConnected()?a.debug("Transport is already connected"):this.isConnecting()?a.debug("Transport is connecting"):(this.close_requested=!1,this.status=c.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()))}},{key:"disconnect",value:function(){a.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=c.STATUS_DISCONNECTED,null!==this.recovery_timer&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.socket.onconnect=function(){},this.socket.ondisconnect=function(){},this.socket.ondata=function(){},this.socket.disconnect(),this.ondisconnect({socket:this.socket,error:!1})}},{key:"send",value:function(e){if(a.debug("send()"),!this.isConnected())return a.warn("unable to send message, transport is not connected"),!1;var t=e.toString();return a.debug("sending message:\n\n".concat(t,"\n")),this.socket.send(t)}},{key:"isConnected",value:function(){return this.status===c.STATUS_CONNECTED}},{key:"isConnecting",value:function(){return this.status===c.STATUS_CONNECTING}},{key:"_reconnect",value:function(){var e=this;this.recover_attempts+=1;var t=Math.floor(Math.random()*Math.pow(2,this.recover_attempts)+1);tthis.recovery_options.max_interval&&(t=this.recovery_options.max_interval),a.debug("reconnection attempt: ".concat(this.recover_attempts,". next connection attempt in ").concat(t," seconds")),this.recovery_timer=setTimeout((function(){e.close_requested||e.isConnected()||e.isConnecting()||(e._getSocket(),e.connect())}),1e3*t)}},{key:"_getSocket",value:function(){var e=[];if(this.sockets.forEach((function(t){t.status!==c.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)return this.sockets.forEach((function(e){e.status=c.SOCKET_STATUS_READY})),void this._getSocket();var t=Math.floor(Math.random()*e.length);this.socket=e[t].socket}},{key:"_onConnect",value:function(){this.recover_attempts=0,this.status=c.STATUS_CONNECTED,null!==this.recovery_timer&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}},{key:"_onDisconnect",value:function(e,t,n){this.status=c.STATUS_DISCONNECTED,this.ondisconnect({socket:this.socket,error:e,code:t,reason:n}),this.close_requested||(this.sockets.forEach((function(e){this.socket===e.socket&&(e.status=c.SOCKET_STATUS_ERROR)}),this),this._reconnect(e))}},{key:"_onData",value:function(e){if("\r\n\r\n"!==e)if("\r\n"!==e){if("string"!==typeof e){try{e=this.textDecoder?this.textDecoder.decode(e):String.fromCharCode.apply(null,new Uint8Array(e))}catch(t){return void a.debug("received binary message failed to be converted into string, message discarded")}a.debug("received binary message:\n\n".concat(e,"\n"))}else a.debug("received text message:\n\n".concat(e,"\n"));this.ondata({transport:this,message:e})}else a.debug("received message with CRLF Keep Alive response");else{a.debug("received message with double-CRLF Keep Alive request");try{this.socket.send("\r\n")}catch(n){a.warn("error sending Keep Alive response: ".concat(n))}}}},{key:"via_transport",get:function(){return this.socket.via_transport}},{key:"url",get:function(){return this.socket.url}},{key:"sip_uri",get:function(){return this.socket.sip_uri}}]),e}()},8011:function(e,t,n){"use strict";function r(e,t){var n;if("undefined"===typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=l(e))||t&&e&&"number"===typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,o=!0,u=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){u=!0,s=e},f:function(){try{o||null==n["return"]||n["return"]()}finally{if(u)throw s}}}}function l(e,t){if(e){if("string"===typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n79&&s<83,a=u||!i("reduce");r({target:"Array",proto:!0,forced:a},{reduce:function(e){var t=arguments.length;return l(this,e,t,t>1?arguments[1]:void 0)}})},8780:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var n=0;n (https://github.com/jmillan)","Iñaki Baz Castillo (https://inakibaz.me)"],"types":"lib/JsSIP.d.ts","main":"lib-es5/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"},"dependencies":{"@types/events":"^3.0.0","@types/debug":"^4.1.7","debug":"^4.3.1","events":"^3.3.0","sdp-transform":"^2.14.1"},"devDependencies":{"@babel/core":"^7.19.6","@babel/preset-env":"^7.19.4","ansi-colors":"^3.2.4","browserify":"^16.5.1","eslint":"^5.16.0","fancy-log":"^1.3.3","gulp":"^4.0.2","gulp-babel":"^8.0.0","gulp-eslint":"^5.0.0","gulp-expect-file":"^1.0.2","gulp-header":"^2.0.9","gulp-nodeunit-runner":"^0.2.2","gulp-plumber":"^1.2.1","gulp-rename":"^1.4.0","gulp-uglify-es":"^1.0.4","pegjs":"^0.7.0","vinyl-buffer":"^1.0.1","vinyl-source-stream":"^2.0.0"},"scripts":{"lint":"node npm-scripts.js lint","test":"node npm-scripts.js test","prepublish":"node npm-scripts.js prepublish","release":"node npm-scripts.js release"},"__npminstall_done":true,"_from":"jssip@3.10.1","_resolved":"https://registry.npmmirror.com/jssip/-/jssip-3.10.1.tgz"}')},"8e65":function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var n=0;n"'),this._contact+=";reg-id=".concat(this._reg_id),this._contact+=";+sip.instance=".concat(this._sipInstance)}return i(e,[{key:"setExtraHeaders",value:function(e){Array.isArray(e)||(e=[]),this._extraHeaders=e.slice()}},{key:"setExtraContactParams",value:function(e){for(var t in e instanceof Object||(e={}),this._extraContactParams="",e)if(Object.prototype.hasOwnProperty.call(e,t)){var n=e[t];this._extraContactParams+=";".concat(t),n&&(this._extraContactParams+="=".concat(n))}}},{key:"register",value:function(){var e=this;if(this._registering)h.debug("Register request in progress...");else{var t=this._extraHeaders.slice();t.push("Contact: ".concat(this._contact,";expires=").concat(this._expires).concat(this._extraContactParams)),t.push("Expires: ".concat(this._expires));var n=new a.OutgoingRequest(u.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},t),r=new c(this._ua,n,{onRequestTimeout:function(){e._registrationFailure(null,u.causes.REQUEST_TIMEOUT)},onTransportError:function(){e._registrationFailure(null,u.causes.CONNECTION_ERROR)},onAuthenticated:function(){e._cseq+=1},onReceiveResponse:function(t){if(t.cseq===e._cseq)switch(null!==e._registrationTimer&&(clearTimeout(e._registrationTimer),e._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(t.status_code):break;case/^2[0-9]{2}$/.test(t.status_code):if(e._registering=!1,!t.hasHeader("Contact")){h.debug("no Contact header in response to REGISTER, response ignored");break}var n=t.headers["Contact"].reduce((function(e,t){return e.concat(t.parsed)}),[]),r=n.find((function(t){return e._sipInstance===t.getParam("+sip.instance")&&e._reg_id===parseInt(t.getParam("reg-id"))}));if(r||(r=n.find((function(t){return t.uri.user===e._ua.contact.uri.user}))),!r){h.debug("no Contact header pointing to us, response ignored");break}var l=r.getParam("expires");!l&&t.hasHeader("expires")&&(l=t.getHeader("expires")),l||(l=e._expires),l=Number(l),l64?1e3*l/2+Math.floor(1e3*(l/2-32)*Math.random()):1e3*l-5e3;e._registrationTimer=setTimeout((function(){e._registrationTimer=null,0===e._ua.listeners("registrationExpiring").length?e.register():e._ua.emit("registrationExpiring")}),i),r.hasParam("temp-gruu")&&(e._ua.contact.temp_gruu=r.getParam("temp-gruu").replace(/"/g,"")),r.hasParam("pub-gruu")&&(e._ua.contact.pub_gruu=r.getParam("pub-gruu").replace(/"/g,"")),e._registered||(e._registered=!0,e._ua.registered({response:t}));break;case/^423$/.test(t.status_code):t.hasHeader("min-expires")?(e._expires=Number(t.getHeader("min-expires")),e._expires0&&void 0!==arguments[0]?arguments[0]:{};if(this._registered){this._registered=!1,null!==this._registrationTimer&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);var n=this._extraHeaders.slice();t.all?n.push("Contact: *".concat(this._extraContactParams)):n.push("Contact: ".concat(this._contact,";expires=0").concat(this._extraContactParams)),n.push("Expires: 0");var r=new a.OutgoingRequest(u.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},n),l=new c(this._ua,r,{onRequestTimeout:function(){e._unregistered(null,u.causes.REQUEST_TIMEOUT)},onTransportError:function(){e._unregistered(null,u.causes.CONNECTION_ERROR)},onAuthenticated:function(){e._cseq+=1},onReceiveResponse:function(t){switch(!0){case/^1[0-9]{2}$/.test(t.status_code):break;case/^2[0-9]{2}$/.test(t.status_code):e._unregistered(t);break;default:var n=o.sipErrorCause(t.status_code);e._unregistered(t,n)}}});l.send()}else h.debug("already unregistered")}},{key:"close",value:function(){this._registered&&this.unregister()}},{key:"onTransportClosed",value:function(){this._registering=!1,null!==this._registrationTimer&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),this._registered&&(this._registered=!1,this._ua.unregistered({}))}},{key:"_registrationFailure",value:function(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}))}},{key:"_unregistered",value:function(e,t){this._registering=!1,this._registered=!1,this._ua.unregistered({response:e||null,cause:t||null})}},{key:"registered",get:function(){return this._registered}}]),e}()},"91af":function(e,t,n){(function(r){function l(){if("undefined"!==typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!==typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"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+)/)}function i(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;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,l=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(r++,"%c"===e&&(l=r))}),t.splice(l,0,n)}function s(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(n){}}function o(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(n){}return!e&&"undefined"!==typeof r&&"env"in r&&(e=Object({NODE_ENV:"production",VUE_APP_BASE_API:"/prod-api",VUE_APP_TITLE:"智慧随访平台",BASE_URL:"/"}).DEBUG),e}function u(){try{return localStorage}catch(e){}}t.formatArgs=i,t.save=s,t.load=o,t.useColors=l,t.storage=u(),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=n("3869")(t);const{formatters:a}=e.exports;a.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}}).call(this,n("0743"))},9354:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var n=0;n3&&void 0!==arguments[3]?arguments[3]:d.STATUS_CONFIRMED;if(r(this,e),this._owner=t,this._ua=t._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,!n.hasHeader("contact"))return{error:"unable to create a Dialog without Contact header field"};n instanceof o.IncomingResponse&&(i=n.status_code<200?d.STATUS_EARLY:d.STATUS_CONFIRMED);var s=n.parseHeader("contact");"UAS"===l?(this._id={call_id:n.call_id,local_tag:n.to_tag,remote_tag:n.from_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=i,this._remote_seqnum=n.cseq,this._local_uri=n.parseHeader("to").uri,this._remote_uri=n.parseHeader("from").uri,this._remote_target=s.uri,this._route_set=n.getHeaders("record-route"),this._ack_seqnum=this._remote_seqnum):"UAC"===l&&(this._id={call_id:n.call_id,local_tag:n.from_tag,remote_tag:n.to_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=i,this._local_seqnum=n.cseq,this._local_uri=n.parseHeader("from").uri,this._remote_uri=n.parseHeader("to").uri,this._remote_target=s.uri,this._route_set=n.getHeaders("record-route").reverse(),this._ack_seqnum=null),this._ua.newDialog(this),f.debug("new ".concat(l," dialog created with status ").concat(this._state===d.STATUS_EARLY?"EARLY":"CONFIRMED"))}return i(e,null,[{key:"C",get:function(){return d}}]),i(e,[{key:"isTerminated",value:function(){return this._status===d.STATUS_TERMINATED}},{key:"update",value:function(e,t){this._state=d.STATUS_CONFIRMED,f.debug("dialog ".concat(this._id.toString()," changed to CONFIRMED state")),"UAC"===t&&(this._route_set=e.getHeaders("record-route").reverse())}},{key:"terminate",value:function(){f.debug("dialog ".concat(this._id.toString()," deleted")),this._ua.destroyDialog(this),this._state=d.STATUS_TERMINATED}},{key:"sendRequest",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=h.cloneArray(n.extraHeaders),l=h.cloneObject(n.eventHandlers),i=n.body||null,s=this._createRequest(e,r,i);l.onAuthenticated=function(){t._local_seqnum+=1};var o=new c(this,s,l);return o.send(),s}},{key:"receiveRequest",value:function(e){this._checkInDialogRequest(e)&&(e.method===u.ACK&&null!==this._ack_seqnum?this._ack_seqnum=null:e.method===u.INVITE&&(this._ack_seqnum=e.cseq),this._owner.receiveRequest(e))}},{key:"_createRequest",value:function(e,t,n){t=h.cloneArray(t),this._local_seqnum||(this._local_seqnum=Math.floor(1e4*Math.random()));var r=e===u.CANCEL||e===u.ACK?this._local_seqnum:this._local_seqnum+=1,l=new o.OutgoingRequest(e,this._remote_target,this._ua,{cseq:r,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,n);return l}},{key:"_checkInDialogRequest",value:function(e){var t=this;if(this._remote_seqnum)if(e.cseqthis._remote_seqnum&&(this._remote_seqnum=e.cseq);else this._remote_seqnum=e.cseq;if(e.method===u.INVITE||e.method===u.UPDATE&&e.body){if(!0===this._uac_pending_reply)e.reply(491);else{if(!0===this._uas_pending_reply){var n=1+(10*Math.random()|0);return e.reply(500,null,["Retry-After:".concat(n)]),!1}this._uas_pending_reply=!0;var r=function n(){e.server_transaction.state!==a.C.STATUS_ACCEPTED&&e.server_transaction.state!==a.C.STATUS_COMPLETED&&e.server_transaction.state!==a.C.STATUS_TERMINATED||(e.server_transaction.removeListener("stateChanged",n),t._uas_pending_reply=!1)};e.server_transaction.on("stateChanged",r)}e.hasHeader("contact")&&e.server_transaction.on("stateChanged",(function(){e.server_transaction.state===a.C.STATUS_ACCEPTED&&(t._remote_target=e.parseHeader("contact").uri)}))}else e.method===u.NOTIFY&&e.hasHeader("contact")&&e.server_transaction.on("stateChanged",(function(){e.server_transaction.state===a.C.STATUS_COMPLETED&&(t._remote_target=e.parseHeader("contact").uri)}));return!0}},{key:"id",get:function(){return this._id}},{key:"local_seqnum",get:function(){return this._local_seqnum},set:function(e){this._local_seqnum=e}},{key:"owner",get:function(){return this._owner}},{key:"uac_pending_reply",get:function(){return this._uac_pending_reply},set:function(e){this._uac_pending_reply=e}},{key:"uas_pending_reply",get:function(){return this._uas_pending_reply}}]),e}()},9519:function(e,t,n){"use strict";var r=n("8a18"),l=n("235f"),i=n("06fc"),s=n("af27"),o=n("361a"),u=n("5b94"),a=n("eca7"),c=n("b9bf"),h=n("b194"),f=n("91af")("JsSIP");f("version %s",r.version),e.exports={C:l,Exceptions:i,Utils:s,UA:o,URI:u,NameAddrHeader:a,WebSocketInterface:h,Grammar:c,debug:n("91af"),get name(){return r.title},get version(){return r.version}}},"9f7f":function(e,t,n){"use strict";function r(e,t){var n;if("undefined"===typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=l(e))||t&&e&&"number"===typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,o=!0,u=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){u=!0,s=e},f:function(){try{o||null==n["return"]||n["return"]()}finally{if(u)throw s}}}}function l(e,t){if(e){if("string"===typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0)return t}},connection_recovery_min_interval:function(e){if(s.isDecimal(e)){var t=Number(e);if(t>0)return t}},contact_uri:function(e){if("string"===typeof e){var t=u.parse(e,"SIP_URI");if(-1!==t)return t}},display_name:function(e){return e},instance_id:function(e){return/^uuid:/i.test(e)&&(e=e.substr(5)),-1===u.parse(e,"uuid")?void 0:e},no_answer_timeout:function(e){if(s.isDecimal(e)){var t=Number(e);if(t>0)return t}},session_timers:function(e){if("boolean"===typeof e)return e},session_timers_refresh_method:function(e){if("string"===typeof e&&(e=e.toUpperCase(),e===o.INVITE||e===o.UPDATE))return e},session_timers_force_refresher:function(e){if("boolean"===typeof e)return e},password:function(e){return String(e)},realm:function(e){return String(e)},ha1:function(e){return String(e)},register:function(e){if("boolean"===typeof e)return e},register_expires:function(e){if(s.isDecimal(e)){var t=Number(e);if(t>0)return t}},registrar_server:function(e){/^sip:/i.test(e)||(e="".concat(o.SIP,":").concat(e));var t=a.parse(e);return t?t.user?void 0:t:void 0},use_preloaded_route:function(e){if("boolean"===typeof e)return e},extra_headers:function(e){var t=[];if(Array.isArray(e)&&e.length){var n,l=r(e);try{for(l.s();!(n=l.n()).done;){var i=n.value;"string"===typeof i&&t.push(i)}}catch(s){l.e(s)}finally{l.f()}return t}}}};t.load=function(e,t){for(var n in f.mandatory){if(!t.hasOwnProperty(n))throw new h.ConfigurationError(n);var r=t[n],l=f.mandatory[n](r);if(void 0===l)throw new h.ConfigurationError(n,r);e[n]=l}for(var i in f.optional)if(t.hasOwnProperty(i)){var o=t[i];if(s.isEmpty(o))continue;var u=f.optional[i](o);if(void 0===u)throw new h.ConfigurationError(i,o);e[i]=u}}},a7d0:function(e,t,n){"use strict";function r(e){return r="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:{};if(this._direction="outgoing",void 0===e)throw new 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 m.InvalidStateError(this._session.status);this._contentType=e,this._body=t;var l=v.cloneArray(r.extraHeaders);l.push("Content-Type: ".concat(e)),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(p.INFO,{extraHeaders:l,eventHandlers:{onSuccessResponse:function(e){n.emit("succeeded",{originator:"remote",response:e})},onErrorResponse:function(e){n.emit("failed",{originator:"remote",response:e})},onTransportError:function(){n._session.onTransportError()},onRequestTimeout:function(){n._session.onRequestTimeout()},onDialogError:function(){n._session.onDialogError()}},body:t})}},{key:"init_incoming",value:function(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})}},{key:"contentType",get:function(){return this._contentType}},{key:"body",get:function(){return this._body}}]),n}(_)},af27:function(e,t,n){"use strict";function r(e){return r="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function l(e,t){var n;if("undefined"===typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=i(e))||t&&e&&"number"===typeof e.length){n&&(e=n);var r=0,l=function(){};return{s:l,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:l}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,o=!0,u=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){u=!0,s=e},f:function(){try{o||null==n["return"]||n["return"]()}finally{if(u)throw s}}}}function i(e,t){if(e){if("string"===typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,t):void 0}}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n1?t-1:0),r=1;r1&&void 0!==arguments[1]?arguments[1]:32,l="";for(t=0;t>>32-t}function n(e,t){var n=2147483648&e,r=2147483648&t,l=1073741824&e,i=1073741824&t,s=(1073741823&e)+(1073741823&t);return l&i?2147483648^s^n^r:l|i?1073741824&s?3221225472^s^n^r:1073741824^s^n^r:s^n^r}function r(e,t,n){return e&t|~e&n}function l(e,t,n){return e&n|t&~n}function i(e,t,n){return e^t^n}function s(e,t,n){return t^(e|~n)}function o(e,l,i,s,o,u,a){return e=n(e,n(n(r(l,i,s),o),a)),n(t(e,u),l)}function u(e,r,i,s,o,u,a){return e=n(e,n(n(l(r,i,s),o),a)),n(t(e,u),r)}function a(e,r,l,s,o,u,a){return e=n(e,n(n(i(r,l,s),o),a)),n(t(e,u),r)}function c(e,r,l,i,o,u,a){return e=n(e,n(n(s(r,l,i),o),a)),n(t(e,u),r)}function h(e){var t,n=e.length,r=n+8,l=(r-r%64)/64,i=16*(l+1),s=new Array(i-1),o=0,u=0;while(u>>29,s}function f(e){var t,n,r="",l="";for(n=0;n<=3;n++)t=e>>>8*n&255,l="0".concat(t.toString(16)),r+=l.substr(l.length-2,2);return r}function d(e){for(var t="",n=0;n127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(63&r|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(63&r|128))}return t}var _,p,m,v,g,y,T,b,C,S=[],E=7,A=12,w=17,R=22,I=5,O=9,k=14,N=20,D=4,x=11,P=16,U=23,q=6,M=10,L=15,H=21;for(e=d(e),S=h(e),y=1732584193,T=4023233417,b=2562383102,C=271733878,_=0;_1&&void 0!==arguments[1]?arguments[1]:{};return e&&Object.assign({},e)||t}},b194:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var n=0;no&&(o=i,u=[]),u.push(e))}function c(){var e;return"\r\n"===t.substr(i,2)?(e="\r\n",i+=2):(e=null,0===s&&a('"\\r\\n"')),e}function h(){var e;return/^[0-9]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&a("[0-9]")),e}function f(){var e;return/^[a-zA-Z]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&a("[a-zA-Z]")),e}function d(){var e;return/^[0-9a-fA-F]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&a("[0-9a-fA-F]")),e}function _(){var e;return e=v(),null===e&&(e=g()),e}function p(){var e;return/^[\0-\xFF]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&a("[\\0-\\xFF]")),e}function m(){var e;return/^["]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&a('["]')),e}function v(){var e;return 32===t.charCodeAt(i)?(e=" ",i++):(e=null,0===s&&a('" "')),e}function g(){var e;return 9===t.charCodeAt(i)?(e="\t",i++):(e=null,0===s&&a('"\\t"')),e}function y(){var e;return/^[a-zA-Z0-9]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&a("[a-zA-Z0-9]")),e}function T(){var e;return 59===t.charCodeAt(i)?(e=";",i++):(e=null,0===s&&a('";"')),null===e&&(47===t.charCodeAt(i)?(e="/",i++):(e=null,0===s&&a('"/"')),null===e&&(63===t.charCodeAt(i)?(e="?",i++):(e=null,0===s&&a('"?"')),null===e&&(58===t.charCodeAt(i)?(e=":",i++):(e=null,0===s&&a('":"')),null===e&&(64===t.charCodeAt(i)?(e="@",i++):(e=null,0===s&&a('"@"')),null===e&&(38===t.charCodeAt(i)?(e="&",i++):(e=null,0===s&&a('"&"')),null===e&&(61===t.charCodeAt(i)?(e="=",i++):(e=null,0===s&&a('"="')),null===e&&(43===t.charCodeAt(i)?(e="+",i++):(e=null,0===s&&a('"+"')),null===e&&(36===t.charCodeAt(i)?(e="$",i++):(e=null,0===s&&a('"$"')),null===e&&(44===t.charCodeAt(i)?(e=",",i++):(e=null,0===s&&a('","'))))))))))),e}function b(){var e;return e=y(),null===e&&(e=C()),e}function C(){var e;return 45===t.charCodeAt(i)?(e="-",i++):(e=null,0===s&&a('"-"')),null===e&&(95===t.charCodeAt(i)?(e="_",i++):(e=null,0===s&&a('"_"')),null===e&&(46===t.charCodeAt(i)?(e=".",i++):(e=null,0===s&&a('"."')),null===e&&(33===t.charCodeAt(i)?(e="!",i++):(e=null,0===s&&a('"!"')),null===e&&(126===t.charCodeAt(i)?(e="~",i++):(e=null,0===s&&a('"~"')),null===e&&(42===t.charCodeAt(i)?(e="*",i++):(e=null,0===s&&a('"*"')),null===e&&(39===t.charCodeAt(i)?(e="'",i++):(e=null,0===s&&a('"\'"')),null===e&&(40===t.charCodeAt(i)?(e="(",i++):(e=null,0===s&&a('"("')),null===e&&(41===t.charCodeAt(i)?(e=")",i++):(e=null,0===s&&a('")"')))))))))),e}function S(){var e,n,r,l,o;return l=i,o=i,37===t.charCodeAt(i)?(e="%",i++):(e=null,0===s&&a('"%"')),null!==e?(n=d(),null!==n?(r=d(),null!==r?e=[e,n,r]:(e=null,i=o)):(e=null,i=o)):(e=null,i=o),null!==e&&(e=function(e,t){return t.join("")}(0,e)),null===e&&(i=l),e}function E(){var e,t,n,r,l,s;r=i,l=i,s=i,e=[],t=_();while(null!==t)e.push(t),t=_();if(null!==e?(t=c(),null!==t?e=[e,t]:(e=null,i=s)):(e=null,i=s),e=null!==e?e:"",null!==e){if(n=_(),null!==n){t=[];while(null!==n)t.push(n),n=_()}else t=null;null!==t?e=[e,t]:(e=null,i=l)}else e=null,i=l;return null!==e&&(e=function(e){return" "}()),null===e&&(i=r),e}function A(){var e;return e=E(),e=null!==e?e:"",e}function w(){var e,n,r,l,o;l=i,o=i,e=[],n=v(),null===n&&(n=g());while(null!==n)e.push(n),n=v(),null===n&&(n=g());return null!==e?(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&a('":"')),null!==n?(r=A(),null!==r?e=[e,n,r]:(e=null,i=o)):(e=null,i=o)):(e=null,i=o),null!==e&&(e=function(e){return":"}()),null===e&&(i=l),e}function R(){var e,n,r,l,s,o,u;if(s=i,o=i,n=I(),null!==n){e=[];while(null!==n)e.push(n),n=I()}else e=null;if(null!==e){n=[],u=i,r=[],l=E();while(null!==l)r.push(l),l=E();null!==r?(l=I(),null!==l?r=[r,l]:(r=null,i=u)):(r=null,i=u);while(null!==r){n.push(r),u=i,r=[],l=E();while(null!==l)r.push(l),l=E();null!==r?(l=I(),null!==l?r=[r,l]:(r=null,i=u)):(r=null,i=u)}null!==n?e=[e,n]:(e=null,i=o)}else e=null,i=o;return null!==e&&(e=function(e){return t.substring(i,e)}(s)),null===e&&(i=s),e}function I(){var e;return/^[!-~]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&a("[!-~]")),null===e&&(e=O()),e}function O(){var e;return/^[\x80-\uFFFF]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&a("[\\x80-\\uFFFF]")),e}function k(){var e;return/^[\x80-\xBF]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&a("[\\x80-\\xBF]")),e}function N(){var e;return e=h(),null===e&&(/^[a-f]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&a("[a-f]"))),e}function D(){var e,n,r;if(r=i,n=y(),null===n&&(45===t.charCodeAt(i)?(n="-",i++):(n=null,0===s&&a('"-"')),null===n&&(46===t.charCodeAt(i)?(n=".",i++):(n=null,0===s&&a('"."')),null===n&&(33===t.charCodeAt(i)?(n="!",i++):(n=null,0===s&&a('"!"')),null===n&&(37===t.charCodeAt(i)?(n="%",i++):(n=null,0===s&&a('"%"')),null===n&&(42===t.charCodeAt(i)?(n="*",i++):(n=null,0===s&&a('"*"')),null===n&&(95===t.charCodeAt(i)?(n="_",i++):(n=null,0===s&&a('"_"')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&a('"+"')),null===n&&(96===t.charCodeAt(i)?(n="`",i++):(n=null,0===s&&a('"`"')),null===n&&(39===t.charCodeAt(i)?(n="'",i++):(n=null,0===s&&a('"\'"')),null===n&&(126===t.charCodeAt(i)?(n="~",i++):(n=null,0===s&&a('"~"')))))))))))),null!==n){e=[];while(null!==n)e.push(n),n=y(),null===n&&(45===t.charCodeAt(i)?(n="-",i++):(n=null,0===s&&a('"-"')),null===n&&(46===t.charCodeAt(i)?(n=".",i++):(n=null,0===s&&a('"."')),null===n&&(33===t.charCodeAt(i)?(n="!",i++):(n=null,0===s&&a('"!"')),null===n&&(37===t.charCodeAt(i)?(n="%",i++):(n=null,0===s&&a('"%"')),null===n&&(42===t.charCodeAt(i)?(n="*",i++):(n=null,0===s&&a('"*"')),null===n&&(95===t.charCodeAt(i)?(n="_",i++):(n=null,0===s&&a('"_"')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&a('"+"')),null===n&&(96===t.charCodeAt(i)?(n="`",i++):(n=null,0===s&&a('"`"')),null===n&&(39===t.charCodeAt(i)?(n="'",i++):(n=null,0===s&&a('"\'"')),null===n&&(126===t.charCodeAt(i)?(n="~",i++):(n=null,0===s&&a('"~"'))))))))))))}else e=null;return null!==e&&(e=function(e){return t.substring(i,e)}(r)),null===e&&(i=r),e}function x(){var e,n,r;if(r=i,n=y(),null===n&&(45===t.charCodeAt(i)?(n="-",i++):(n=null,0===s&&a('"-"')),null===n&&(33===t.charCodeAt(i)?(n="!",i++):(n=null,0===s&&a('"!"')),null===n&&(37===t.charCodeAt(i)?(n="%",i++):(n=null,0===s&&a('"%"')),null===n&&(42===t.charCodeAt(i)?(n="*",i++):(n=null,0===s&&a('"*"')),null===n&&(95===t.charCodeAt(i)?(n="_",i++):(n=null,0===s&&a('"_"')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&a('"+"')),null===n&&(96===t.charCodeAt(i)?(n="`",i++):(n=null,0===s&&a('"`"')),null===n&&(39===t.charCodeAt(i)?(n="'",i++):(n=null,0===s&&a('"\'"')),null===n&&(126===t.charCodeAt(i)?(n="~",i++):(n=null,0===s&&a('"~"'))))))))))),null!==n){e=[];while(null!==n)e.push(n),n=y(),null===n&&(45===t.charCodeAt(i)?(n="-",i++):(n=null,0===s&&a('"-"')),null===n&&(33===t.charCodeAt(i)?(n="!",i++):(n=null,0===s&&a('"!"')),null===n&&(37===t.charCodeAt(i)?(n="%",i++):(n=null,0===s&&a('"%"')),null===n&&(42===t.charCodeAt(i)?(n="*",i++):(n=null,0===s&&a('"*"')),null===n&&(95===t.charCodeAt(i)?(n="_",i++):(n=null,0===s&&a('"_"')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&a('"+"')),null===n&&(96===t.charCodeAt(i)?(n="`",i++):(n=null,0===s&&a('"`"')),null===n&&(39===t.charCodeAt(i)?(n="'",i++):(n=null,0===s&&a('"\'"')),null===n&&(126===t.charCodeAt(i)?(n="~",i++):(n=null,0===s&&a('"~"')))))))))))}else e=null;return null!==e&&(e=function(e){return t.substring(i,e)}(r)),null===e&&(i=r),e}function P(){var e;return 40===t.charCodeAt(i)?(e="(",i++):(e=null,0===s&&a('"("')),null===e&&(41===t.charCodeAt(i)?(e=")",i++):(e=null,0===s&&a('")"')),null===e&&(60===t.charCodeAt(i)?(e="<",i++):(e=null,0===s&&a('"<"')),null===e&&(62===t.charCodeAt(i)?(e=">",i++):(e=null,0===s&&a('">"')),null===e&&(64===t.charCodeAt(i)?(e="@",i++):(e=null,0===s&&a('"@"')),null===e&&(44===t.charCodeAt(i)?(e=",",i++):(e=null,0===s&&a('","')),null===e&&(59===t.charCodeAt(i)?(e=";",i++):(e=null,0===s&&a('";"')),null===e&&(58===t.charCodeAt(i)?(e=":",i++):(e=null,0===s&&a('":"')),null===e&&(92===t.charCodeAt(i)?(e="\\",i++):(e=null,0===s&&a('"\\\\"')),null===e&&(e=m(),null===e&&(47===t.charCodeAt(i)?(e="/",i++):(e=null,0===s&&a('"/"')),null===e&&(91===t.charCodeAt(i)?(e="[",i++):(e=null,0===s&&a('"["')),null===e&&(93===t.charCodeAt(i)?(e="]",i++):(e=null,0===s&&a('"]"')),null===e&&(63===t.charCodeAt(i)?(e="?",i++):(e=null,0===s&&a('"?"')),null===e&&(61===t.charCodeAt(i)?(e="=",i++):(e=null,0===s&&a('"="')),null===e&&(123===t.charCodeAt(i)?(e="{",i++):(e=null,0===s&&a('"{"')),null===e&&(125===t.charCodeAt(i)?(e="}",i++):(e=null,0===s&&a('"}"')),null===e&&(e=v(),null===e&&(e=g())))))))))))))))))),e}function U(){var e,n,r;if(r=i,n=y(),null===n&&(45===t.charCodeAt(i)?(n="-",i++):(n=null,0===s&&a('"-"')),null===n&&(46===t.charCodeAt(i)?(n=".",i++):(n=null,0===s&&a('"."')),null===n&&(33===t.charCodeAt(i)?(n="!",i++):(n=null,0===s&&a('"!"')),null===n&&(37===t.charCodeAt(i)?(n="%",i++):(n=null,0===s&&a('"%"')),null===n&&(42===t.charCodeAt(i)?(n="*",i++):(n=null,0===s&&a('"*"')),null===n&&(95===t.charCodeAt(i)?(n="_",i++):(n=null,0===s&&a('"_"')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&a('"+"')),null===n&&(96===t.charCodeAt(i)?(n="`",i++):(n=null,0===s&&a('"`"')),null===n&&(39===t.charCodeAt(i)?(n="'",i++):(n=null,0===s&&a('"\'"')),null===n&&(126===t.charCodeAt(i)?(n="~",i++):(n=null,0===s&&a('"~"')),null===n&&(40===t.charCodeAt(i)?(n="(",i++):(n=null,0===s&&a('"("')),null===n&&(41===t.charCodeAt(i)?(n=")",i++):(n=null,0===s&&a('")"')),null===n&&(60===t.charCodeAt(i)?(n="<",i++):(n=null,0===s&&a('"<"')),null===n&&(62===t.charCodeAt(i)?(n=">",i++):(n=null,0===s&&a('">"')),null===n&&(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&a('":"')),null===n&&(92===t.charCodeAt(i)?(n="\\",i++):(n=null,0===s&&a('"\\\\"')),null===n&&(n=m(),null===n&&(47===t.charCodeAt(i)?(n="/",i++):(n=null,0===s&&a('"/"')),null===n&&(91===t.charCodeAt(i)?(n="[",i++):(n=null,0===s&&a('"["')),null===n&&(93===t.charCodeAt(i)?(n="]",i++):(n=null,0===s&&a('"]"')),null===n&&(63===t.charCodeAt(i)?(n="?",i++):(n=null,0===s&&a('"?"')),null===n&&(123===t.charCodeAt(i)?(n="{",i++):(n=null,0===s&&a('"{"')),null===n&&(125===t.charCodeAt(i)?(n="}",i++):(n=null,0===s&&a('"}"'))))))))))))))))))))))))),null!==n){e=[];while(null!==n)e.push(n),n=y(),null===n&&(45===t.charCodeAt(i)?(n="-",i++):(n=null,0===s&&a('"-"')),null===n&&(46===t.charCodeAt(i)?(n=".",i++):(n=null,0===s&&a('"."')),null===n&&(33===t.charCodeAt(i)?(n="!",i++):(n=null,0===s&&a('"!"')),null===n&&(37===t.charCodeAt(i)?(n="%",i++):(n=null,0===s&&a('"%"')),null===n&&(42===t.charCodeAt(i)?(n="*",i++):(n=null,0===s&&a('"*"')),null===n&&(95===t.charCodeAt(i)?(n="_",i++):(n=null,0===s&&a('"_"')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&a('"+"')),null===n&&(96===t.charCodeAt(i)?(n="`",i++):(n=null,0===s&&a('"`"')),null===n&&(39===t.charCodeAt(i)?(n="'",i++):(n=null,0===s&&a('"\'"')),null===n&&(126===t.charCodeAt(i)?(n="~",i++):(n=null,0===s&&a('"~"')),null===n&&(40===t.charCodeAt(i)?(n="(",i++):(n=null,0===s&&a('"("')),null===n&&(41===t.charCodeAt(i)?(n=")",i++):(n=null,0===s&&a('")"')),null===n&&(60===t.charCodeAt(i)?(n="<",i++):(n=null,0===s&&a('"<"')),null===n&&(62===t.charCodeAt(i)?(n=">",i++):(n=null,0===s&&a('">"')),null===n&&(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&a('":"')),null===n&&(92===t.charCodeAt(i)?(n="\\",i++):(n=null,0===s&&a('"\\\\"')),null===n&&(n=m(),null===n&&(47===t.charCodeAt(i)?(n="/",i++):(n=null,0===s&&a('"/"')),null===n&&(91===t.charCodeAt(i)?(n="[",i++):(n=null,0===s&&a('"["')),null===n&&(93===t.charCodeAt(i)?(n="]",i++):(n=null,0===s&&a('"]"')),null===n&&(63===t.charCodeAt(i)?(n="?",i++):(n=null,0===s&&a('"?"')),null===n&&(123===t.charCodeAt(i)?(n="{",i++):(n=null,0===s&&a('"{"')),null===n&&(125===t.charCodeAt(i)?(n="}",i++):(n=null,0===s&&a('"}"')))))))))))))))))))))))))}else e=null;return null!==e&&(e=function(e){return t.substring(i,e)}(r)),null===e&&(i=r),e}function q(){var e,n,r,l,o;return l=i,o=i,e=A(),null!==e?(42===t.charCodeAt(i)?(n="*",i++):(n=null,0===s&&a('"*"')),null!==n?(r=A(),null!==r?e=[e,n,r]:(e=null,i=o)):(e=null,i=o)):(e=null,i=o),null!==e&&(e=function(e){return"*"}()),null===e&&(i=l),e}function M(){var e,n,r,l,o;return l=i,o=i,e=A(),null!==e?(47===t.charCodeAt(i)?(n="/",i++):(n=null,0===s&&a('"/"')),null!==n?(r=A(),null!==r?e=[e,n,r]:(e=null,i=o)):(e=null,i=o)):(e=null,i=o),null!==e&&(e=function(e){return"/"}()),null===e&&(i=l),e}function L(){var e,n,r,l,o;return l=i,o=i,e=A(),null!==e?(61===t.charCodeAt(i)?(n="=",i++):(n=null,0===s&&a('"="')),null!==n?(r=A(),null!==r?e=[e,n,r]:(e=null,i=o)):(e=null,i=o)):(e=null,i=o),null!==e&&(e=function(e){return"="}()),null===e&&(i=l),e}function H(){var e,n,r,l,o;return l=i,o=i,e=A(),null!==e?(40===t.charCodeAt(i)?(n="(",i++):(n=null,0===s&&a('"("')),null!==n?(r=A(),null!==r?e=[e,n,r]:(e=null,i=o)):(e=null,i=o)):(e=null,i=o),null!==e&&(e=function(e){return"("}()),null===e&&(i=l),e}function F(){var e,n,r,l,o;return l=i,o=i,e=A(),null!==e?(41===t.charCodeAt(i)?(n=")",i++):(n=null,0===s&&a('")"')),null!==n?(r=A(),null!==r?e=[e,n,r]:(e=null,i=o)):(e=null,i=o)):(e=null,i=o),null!==e&&(e=function(e){return")"}()),null===e&&(i=l),e}function j(){var e,n,r,l;return r=i,l=i,62===t.charCodeAt(i)?(e=">",i++):(e=null,0===s&&a('">"')),null!==e?(n=A(),null!==n?e=[e,n]:(e=null,i=l)):(e=null,i=l),null!==e&&(e=function(e){return">"}()),null===e&&(i=r),e}function G(){var e,n,r,l;return r=i,l=i,e=A(),null!==e?(60===t.charCodeAt(i)?(n="<",i++):(n=null,0===s&&a('"<"')),null!==n?e=[e,n]:(e=null,i=l)):(e=null,i=l),null!==e&&(e=function(e){return"<"}()),null===e&&(i=r),e}function V(){var e,n,r,l,o;return l=i,o=i,e=A(),null!==e?(44===t.charCodeAt(i)?(n=",",i++):(n=null,0===s&&a('","')),null!==n?(r=A(),null!==r?e=[e,n,r]:(e=null,i=o)):(e=null,i=o)):(e=null,i=o),null!==e&&(e=function(e){return","}()),null===e&&(i=l),e}function W(){var e,n,r,l,o;return l=i,o=i,e=A(),null!==e?(59===t.charCodeAt(i)?(n=";",i++):(n=null,0===s&&a('";"')),null!==n?(r=A(),null!==r?e=[e,n,r]:(e=null,i=o)):(e=null,i=o)):(e=null,i=o),null!==e&&(e=function(e){return";"}()),null===e&&(i=l),e}function B(){var e,n,r,l,o;return l=i,o=i,e=A(),null!==e?(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&a('":"')),null!==n?(r=A(),null!==r?e=[e,n,r]:(e=null,i=o)):(e=null,i=o)):(e=null,i=o),null!==e&&(e=function(e){return":"}()),null===e&&(i=l),e}function K(){var e,t,n,r;return n=i,r=i,e=A(),null!==e?(t=m(),null!==t?e=[e,t]:(e=null,i=r)):(e=null,i=r),null!==e&&(e=function(e){return'"'}()),null===e&&(i=n),e}function z(){var e,t,n,r;return n=i,r=i,e=m(),null!==e?(t=A(),null!==t?e=[e,t]:(e=null,i=r)):(e=null,i=r),null!==e&&(e=function(e){return'"'}()),null===e&&(i=n),e}function Y(){var e,t,n,r;if(r=i,e=H(),null!==e){t=[],n=$(),null===n&&(n=Z(),null===n&&(n=Y()));while(null!==n)t.push(n),n=$(),null===n&&(n=Z(),null===n&&(n=Y()));null!==t?(n=F(),null!==n?e=[e,t,n]:(e=null,i=r)):(e=null,i=r)}else e=null,i=r;return e}function $(){var e;return/^[!-']/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&a("[!-']")),null===e&&(/^[*-[]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&a("[*-[]")),null===e&&(/^[\]-~]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&a("[\\]-~]")),null===e&&(e=O(),null===e&&(e=E())))),e}function J(){var e,n,r,l,s,o;if(s=i,o=i,e=A(),null!==e)if(n=m(),null!==n){r=[],l=Q(),null===l&&(l=Z());while(null!==l)r.push(l),l=Q(),null===l&&(l=Z());null!==r?(l=m(),null!==l?e=[e,n,r,l]:(e=null,i=o)):(e=null,i=o)}else e=null,i=o;else e=null,i=o;return null!==e&&(e=function(e){return t.substring(i,e)}(s)),null===e&&(i=s),e}function X(){var e,n,r,l,s,o;if(s=i,o=i,e=A(),null!==e)if(n=m(),null!==n){r=[],l=Q(),null===l&&(l=Z());while(null!==l)r.push(l),l=Q(),null===l&&(l=Z());null!==r?(l=m(),null!==l?e=[e,n,r,l]:(e=null,i=o)):(e=null,i=o)}else e=null,i=o;else e=null,i=o;return null!==e&&(e=function(e){var n=t.substring(i,e).trim();return n.substring(1,n.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(s)),null===e&&(i=s),e}function Q(){var e;return e=E(),null===e&&(33===t.charCodeAt(i)?(e="!",i++):(e=null,0===s&&a('"!"')),null===e&&(/^[#-[]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&a("[#-[]")),null===e&&(/^[\]-~]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&a("[\\]-~]")),null===e&&(e=O())))),e}function Z(){var e,n,r;return r=i,92===t.charCodeAt(i)?(e="\\",i++):(e=null,0===s&&a('"\\\\"')),null!==e?(/^[\0-\t]/.test(t.charAt(i))?(n=t.charAt(i),i++):(n=null,0===s&&a("[\\0-\\t]")),null===n&&(/^[\x0B-\f]/.test(t.charAt(i))?(n=t.charAt(i),i++):(n=null,0===s&&a("[\\x0B-\\f]")),null===n&&(/^[\x0E-]/.test(t.charAt(i))?(n=t.charAt(i),i++):(n=null,0===s&&a("[\\x0E-]")))),null!==n?e=[e,n]:(e=null,i=r)):(e=null,i=r),e}function ee(){var e,n,r,l,o,u;return o=i,u=i,e=ne(),null!==e?(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&a('":"')),null!==n?(r=ie(),r=null!==r?r:"",null!==r?(l=ae(),null!==l?e=[e,n,r,l]:(e=null,i=u)):(e=null,i=u)):(e=null,i=u)):(e=null,i=u),null!==e&&(e=function(e){try{Ar.uri=new Sr(Ar.scheme,Ar.user,Ar.host,Ar.port),delete Ar.scheme,delete Ar.user,delete Ar.host,delete Ar.host_type,delete Ar.port}catch(t){Ar=-1}}()),null===e&&(i=o),e}function te(){var e,n,l,o,u,c,h,f;return h=i,f=i,e=ne(),null!==e?(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&a('":"')),null!==n?(l=ie(),l=null!==l?l:"",null!==l?(o=ae(),null!==o?(u=be(),null!==u?(c=Pe(),c=null!==c?c:"",null!==c?e=[e,n,l,o,u,c]:(e=null,i=f)):(e=null,i=f)):(e=null,i=f)):(e=null,i=f)):(e=null,i=f)):(e=null,i=f),null!==e&&(e=function(e){try{Ar.uri=new Sr(Ar.scheme,Ar.user,Ar.host,Ar.port,Ar.uri_params,Ar.uri_headers),delete Ar.scheme,delete Ar.user,delete Ar.host,delete Ar.host_type,delete Ar.port,delete Ar.uri_params,"SIP_URI"===r&&(Ar=Ar.uri)}catch(t){Ar=-1}}()),null===e&&(i=h),e}function ne(){var e;return e=re(),null===e&&(e=le()),e}function re(){var e,n;return n=i,"sips"===t.substr(i,4).toLowerCase()?(e=t.substr(i,4),i+=4):(e=null,0===s&&a('"sips"')),null!==e&&(e=function(e,t){Ar.scheme=t.toLowerCase()}(0,e)),null===e&&(i=n),e}function le(){var e,n;return n=i,"sip"===t.substr(i,3).toLowerCase()?(e=t.substr(i,3),i+=3):(e=null,0===s&&a('"sip"')),null!==e&&(e=function(e,t){Ar.scheme=t.toLowerCase()}(0,e)),null===e&&(i=n),e}function ie(){var e,n,r,l,o,u;return l=i,o=i,e=se(),null!==e?(u=i,58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&a('":"')),null!==n?(r=ue(),null!==r?n=[n,r]:(n=null,i=u)):(n=null,i=u),n=null!==n?n:"",null!==n?(64===t.charCodeAt(i)?(r="@",i++):(r=null,0===s&&a('"@"')),null!==r?e=[e,n,r]:(e=null,i=o)):(e=null,i=o)):(e=null,i=o),null!==e&&(e=function(e){Ar.user=decodeURIComponent(t.substring(i-1,e))}(l)),null===e&&(i=l),e}function se(){var e,t;if(t=b(),null===t&&(t=S(),null===t&&(t=oe())),null!==t){e=[];while(null!==t)e.push(t),t=b(),null===t&&(t=S(),null===t&&(t=oe()))}else e=null;return e}function oe(){var e;return 38===t.charCodeAt(i)?(e="&",i++):(e=null,0===s&&a('"&"')),null===e&&(61===t.charCodeAt(i)?(e="=",i++):(e=null,0===s&&a('"="')),null===e&&(43===t.charCodeAt(i)?(e="+",i++):(e=null,0===s&&a('"+"')),null===e&&(36===t.charCodeAt(i)?(e="$",i++):(e=null,0===s&&a('"$"')),null===e&&(44===t.charCodeAt(i)?(e=",",i++):(e=null,0===s&&a('","')),null===e&&(59===t.charCodeAt(i)?(e=";",i++):(e=null,0===s&&a('";"')),null===e&&(63===t.charCodeAt(i)?(e="?",i++):(e=null,0===s&&a('"?"')),null===e&&(47===t.charCodeAt(i)?(e="/",i++):(e=null,0===s&&a('"/"'))))))))),e}function ue(){var e,n,r;r=i,e=[],n=b(),null===n&&(n=S(),null===n&&(38===t.charCodeAt(i)?(n="&",i++):(n=null,0===s&&a('"&"')),null===n&&(61===t.charCodeAt(i)?(n="=",i++):(n=null,0===s&&a('"="')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&a('"+"')),null===n&&(36===t.charCodeAt(i)?(n="$",i++):(n=null,0===s&&a('"$"')),null===n&&(44===t.charCodeAt(i)?(n=",",i++):(n=null,0===s&&a('","'))))))));while(null!==n)e.push(n),n=b(),null===n&&(n=S(),null===n&&(38===t.charCodeAt(i)?(n="&",i++):(n=null,0===s&&a('"&"')),null===n&&(61===t.charCodeAt(i)?(n="=",i++):(n=null,0===s&&a('"="')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&a('"+"')),null===n&&(36===t.charCodeAt(i)?(n="$",i++):(n=null,0===s&&a('"$"')),null===n&&(44===t.charCodeAt(i)?(n=",",i++):(n=null,0===s&&a('","'))))))));return null!==e&&(e=function(e){Ar.password=t.substring(i,e)}(r)),null===e&&(i=r),e}function ae(){var e,n,r,l,o;return l=i,e=ce(),null!==e?(o=i,58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&a('":"')),null!==n?(r=Te(),null!==r?n=[n,r]:(n=null,i=o)):(n=null,i=o),n=null!==n?n:"",null!==n?e=[e,n]:(e=null,i=l)):(e=null,i=l),e}function ce(){var e,n;return n=i,e=he(),null===e&&(e=ge(),null===e&&(e=_e())),null!==e&&(e=function(e){return Ar.host=t.substring(i,e).toLowerCase(),Ar.host}(n)),null===e&&(i=n),e}function he(){var e,n,r,l,o,u;l=i,o=i,e=[],u=i,n=fe(),null!==n?(46===t.charCodeAt(i)?(r=".",i++):(r=null,0===s&&a('"."')),null!==r?n=[n,r]:(n=null,i=u)):(n=null,i=u);while(null!==n)e.push(n),u=i,n=fe(),null!==n?(46===t.charCodeAt(i)?(r=".",i++):(r=null,0===s&&a('"."')),null!==r?n=[n,r]:(n=null,i=u)):(n=null,i=u);return null!==e?(n=de(),null!==n?(46===t.charCodeAt(i)?(r=".",i++):(r=null,0===s&&a('"."')),r=null!==r?r:"",null!==r?e=[e,n,r]:(e=null,i=o)):(e=null,i=o)):(e=null,i=o),null!==e&&(e=function(e){return Ar.host_type="domain",t.substring(i,e)}(l)),null===e&&(i=l),e}function fe(){var e,n,r,l;if(l=i,e=y(),null!==e){n=[],r=y(),null===r&&(45===t.charCodeAt(i)?(r="-",i++):(r=null,0===s&&a('"-"')),null===r&&(95===t.charCodeAt(i)?(r="_",i++):(r=null,0===s&&a('"_"'))));while(null!==r)n.push(r),r=y(),null===r&&(45===t.charCodeAt(i)?(r="-",i++):(r=null,0===s&&a('"-"')),null===r&&(95===t.charCodeAt(i)?(r="_",i++):(r=null,0===s&&a('"_"'))));null!==n?e=[e,n]:(e=null,i=l)}else e=null,i=l;return e}function de(){var e,n,r,l;if(l=i,e=f(),null!==e){n=[],r=y(),null===r&&(45===t.charCodeAt(i)?(r="-",i++):(r=null,0===s&&a('"-"')),null===r&&(95===t.charCodeAt(i)?(r="_",i++):(r=null,0===s&&a('"_"'))));while(null!==r)n.push(r),r=y(),null===r&&(45===t.charCodeAt(i)?(r="-",i++):(r=null,0===s&&a('"-"')),null===r&&(95===t.charCodeAt(i)?(r="_",i++):(r=null,0===s&&a('"_"'))));null!==n?e=[e,n]:(e=null,i=l)}else e=null,i=l;return e}function _e(){var e,n,r,l,o;return l=i,o=i,91===t.charCodeAt(i)?(e="[",i++):(e=null,0===s&&a('"["')),null!==e?(n=pe(),null!==n?(93===t.charCodeAt(i)?(r="]",i++):(r=null,0===s&&a('"]"')),null!==r?e=[e,n,r]:(e=null,i=o)):(e=null,i=o)):(e=null,i=o),null!==e&&(e=function(e){return Ar.host_type="IPv6",t.substring(i,e)}(l)),null===e&&(i=l),e}function pe(){var e,n,r,l,o,u,c,h,f,d,_,p,m,v,g,y;return v=i,g=i,e=me(),null!==e?(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&a('":"')),null!==n?(r=me(),null!==r?(58===t.charCodeAt(i)?(l=":",i++):(l=null,0===s&&a('":"')),null!==l?(o=me(),null!==o?(58===t.charCodeAt(i)?(u=":",i++):(u=null,0===s&&a('":"')),null!==u?(c=me(),null!==c?(58===t.charCodeAt(i)?(h=":",i++):(h=null,0===s&&a('":"')),null!==h?(f=me(),null!==f?(58===t.charCodeAt(i)?(d=":",i++):(d=null,0===s&&a('":"')),null!==d?(_=me(),null!==_?(58===t.charCodeAt(i)?(p=":",i++):(p=null,0===s&&a('":"')),null!==p?(m=ve(),null!==m?e=[e,n,r,l,o,u,c,h,f,d,_,p,m]:(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g),null===e&&(g=i,"::"===t.substr(i,2)?(e="::",i+=2):(e=null,0===s&&a('"::"')),null!==e?(n=me(),null!==n?(58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&a('":"')),null!==r?(l=me(),null!==l?(58===t.charCodeAt(i)?(o=":",i++):(o=null,0===s&&a('":"')),null!==o?(u=me(),null!==u?(58===t.charCodeAt(i)?(c=":",i++):(c=null,0===s&&a('":"')),null!==c?(h=me(),null!==h?(58===t.charCodeAt(i)?(f=":",i++):(f=null,0===s&&a('":"')),null!==f?(d=me(),null!==d?(58===t.charCodeAt(i)?(_=":",i++):(_=null,0===s&&a('":"')),null!==_?(p=ve(),null!==p?e=[e,n,r,l,o,u,c,h,f,d,_,p]:(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g),null===e&&(g=i,"::"===t.substr(i,2)?(e="::",i+=2):(e=null,0===s&&a('"::"')),null!==e?(n=me(),null!==n?(58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&a('":"')),null!==r?(l=me(),null!==l?(58===t.charCodeAt(i)?(o=":",i++):(o=null,0===s&&a('":"')),null!==o?(u=me(),null!==u?(58===t.charCodeAt(i)?(c=":",i++):(c=null,0===s&&a('":"')),null!==c?(h=me(),null!==h?(58===t.charCodeAt(i)?(f=":",i++):(f=null,0===s&&a('":"')),null!==f?(d=ve(),null!==d?e=[e,n,r,l,o,u,c,h,f,d]:(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g),null===e&&(g=i,"::"===t.substr(i,2)?(e="::",i+=2):(e=null,0===s&&a('"::"')),null!==e?(n=me(),null!==n?(58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&a('":"')),null!==r?(l=me(),null!==l?(58===t.charCodeAt(i)?(o=":",i++):(o=null,0===s&&a('":"')),null!==o?(u=me(),null!==u?(58===t.charCodeAt(i)?(c=":",i++):(c=null,0===s&&a('":"')),null!==c?(h=ve(),null!==h?e=[e,n,r,l,o,u,c,h]:(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g),null===e&&(g=i,"::"===t.substr(i,2)?(e="::",i+=2):(e=null,0===s&&a('"::"')),null!==e?(n=me(),null!==n?(58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&a('":"')),null!==r?(l=me(),null!==l?(58===t.charCodeAt(i)?(o=":",i++):(o=null,0===s&&a('":"')),null!==o?(u=ve(),null!==u?e=[e,n,r,l,o,u]:(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g),null===e&&(g=i,"::"===t.substr(i,2)?(e="::",i+=2):(e=null,0===s&&a('"::"')),null!==e?(n=me(),null!==n?(58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&a('":"')),null!==r?(l=ve(),null!==l?e=[e,n,r,l]:(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g),null===e&&(g=i,"::"===t.substr(i,2)?(e="::",i+=2):(e=null,0===s&&a('"::"')),null!==e?(n=ve(),null!==n?e=[e,n]:(e=null,i=g)):(e=null,i=g),null===e&&(g=i,"::"===t.substr(i,2)?(e="::",i+=2):(e=null,0===s&&a('"::"')),null!==e?(n=me(),null!==n?e=[e,n]:(e=null,i=g)):(e=null,i=g),null===e&&(g=i,e=me(),null!==e?("::"===t.substr(i,2)?(n="::",i+=2):(n=null,0===s&&a('"::"')),null!==n?(r=me(),null!==r?(58===t.charCodeAt(i)?(l=":",i++):(l=null,0===s&&a('":"')),null!==l?(o=me(),null!==o?(58===t.charCodeAt(i)?(u=":",i++):(u=null,0===s&&a('":"')),null!==u?(c=me(),null!==c?(58===t.charCodeAt(i)?(h=":",i++):(h=null,0===s&&a('":"')),null!==h?(f=me(),null!==f?(58===t.charCodeAt(i)?(d=":",i++):(d=null,0===s&&a('":"')),null!==d?(_=ve(),null!==_?e=[e,n,r,l,o,u,c,h,f,d,_]:(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g),null===e&&(g=i,e=me(),null!==e?(y=i,58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&a('":"')),null!==n?(r=me(),null!==r?n=[n,r]:(n=null,i=y)):(n=null,i=y),n=null!==n?n:"",null!==n?("::"===t.substr(i,2)?(r="::",i+=2):(r=null,0===s&&a('"::"')),null!==r?(l=me(),null!==l?(58===t.charCodeAt(i)?(o=":",i++):(o=null,0===s&&a('":"')),null!==o?(u=me(),null!==u?(58===t.charCodeAt(i)?(c=":",i++):(c=null,0===s&&a('":"')),null!==c?(h=me(),null!==h?(58===t.charCodeAt(i)?(f=":",i++):(f=null,0===s&&a('":"')),null!==f?(d=ve(),null!==d?e=[e,n,r,l,o,u,c,h,f,d]:(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g),null===e&&(g=i,e=me(),null!==e?(y=i,58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&a('":"')),null!==n?(r=me(),null!==r?n=[n,r]:(n=null,i=y)):(n=null,i=y),n=null!==n?n:"",null!==n?(y=i,58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&a('":"')),null!==r?(l=me(),null!==l?r=[r,l]:(r=null,i=y)):(r=null,i=y),r=null!==r?r:"",null!==r?("::"===t.substr(i,2)?(l="::",i+=2):(l=null,0===s&&a('"::"')),null!==l?(o=me(),null!==o?(58===t.charCodeAt(i)?(u=":",i++):(u=null,0===s&&a('":"')),null!==u?(c=me(),null!==c?(58===t.charCodeAt(i)?(h=":",i++):(h=null,0===s&&a('":"')),null!==h?(f=ve(),null!==f?e=[e,n,r,l,o,u,c,h,f]:(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g),null===e&&(g=i,e=me(),null!==e?(y=i,58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&a('":"')),null!==n?(r=me(),null!==r?n=[n,r]:(n=null,i=y)):(n=null,i=y),n=null!==n?n:"",null!==n?(y=i,58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&a('":"')),null!==r?(l=me(),null!==l?r=[r,l]:(r=null,i=y)):(r=null,i=y),r=null!==r?r:"",null!==r?(y=i,58===t.charCodeAt(i)?(l=":",i++):(l=null,0===s&&a('":"')),null!==l?(o=me(),null!==o?l=[l,o]:(l=null,i=y)):(l=null,i=y),l=null!==l?l:"",null!==l?("::"===t.substr(i,2)?(o="::",i+=2):(o=null,0===s&&a('"::"')),null!==o?(u=me(),null!==u?(58===t.charCodeAt(i)?(c=":",i++):(c=null,0===s&&a('":"')),null!==c?(h=ve(),null!==h?e=[e,n,r,l,o,u,c,h]:(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g),null===e&&(g=i,e=me(),null!==e?(y=i,58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&a('":"')),null!==n?(r=me(),null!==r?n=[n,r]:(n=null,i=y)):(n=null,i=y),n=null!==n?n:"",null!==n?(y=i,58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&a('":"')),null!==r?(l=me(),null!==l?r=[r,l]:(r=null,i=y)):(r=null,i=y),r=null!==r?r:"",null!==r?(y=i,58===t.charCodeAt(i)?(l=":",i++):(l=null,0===s&&a('":"')),null!==l?(o=me(),null!==o?l=[l,o]:(l=null,i=y)):(l=null,i=y),l=null!==l?l:"",null!==l?(y=i,58===t.charCodeAt(i)?(o=":",i++):(o=null,0===s&&a('":"')),null!==o?(u=me(),null!==u?o=[o,u]:(o=null,i=y)):(o=null,i=y),o=null!==o?o:"",null!==o?("::"===t.substr(i,2)?(u="::",i+=2):(u=null,0===s&&a('"::"')),null!==u?(c=ve(),null!==c?e=[e,n,r,l,o,u,c]:(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g),null===e&&(g=i,e=me(),null!==e?(y=i,58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&a('":"')),null!==n?(r=me(),null!==r?n=[n,r]:(n=null,i=y)):(n=null,i=y),n=null!==n?n:"",null!==n?(y=i,58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&a('":"')),null!==r?(l=me(),null!==l?r=[r,l]:(r=null,i=y)):(r=null,i=y),r=null!==r?r:"",null!==r?(y=i,58===t.charCodeAt(i)?(l=":",i++):(l=null,0===s&&a('":"')),null!==l?(o=me(),null!==o?l=[l,o]:(l=null,i=y)):(l=null,i=y),l=null!==l?l:"",null!==l?(y=i,58===t.charCodeAt(i)?(o=":",i++):(o=null,0===s&&a('":"')),null!==o?(u=me(),null!==u?o=[o,u]:(o=null,i=y)):(o=null,i=y),o=null!==o?o:"",null!==o?(y=i,58===t.charCodeAt(i)?(u=":",i++):(u=null,0===s&&a('":"')),null!==u?(c=me(),null!==c?u=[u,c]:(u=null,i=y)):(u=null,i=y),u=null!==u?u:"",null!==u?("::"===t.substr(i,2)?(c="::",i+=2):(c=null,0===s&&a('"::"')),null!==c?(h=me(),null!==h?e=[e,n,r,l,o,u,c,h]:(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g),null===e&&(g=i,e=me(),null!==e?(y=i,58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&a('":"')),null!==n?(r=me(),null!==r?n=[n,r]:(n=null,i=y)):(n=null,i=y),n=null!==n?n:"",null!==n?(y=i,58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&a('":"')),null!==r?(l=me(),null!==l?r=[r,l]:(r=null,i=y)):(r=null,i=y),r=null!==r?r:"",null!==r?(y=i,58===t.charCodeAt(i)?(l=":",i++):(l=null,0===s&&a('":"')),null!==l?(o=me(),null!==o?l=[l,o]:(l=null,i=y)):(l=null,i=y),l=null!==l?l:"",null!==l?(y=i,58===t.charCodeAt(i)?(o=":",i++):(o=null,0===s&&a('":"')),null!==o?(u=me(),null!==u?o=[o,u]:(o=null,i=y)):(o=null,i=y),o=null!==o?o:"",null!==o?(y=i,58===t.charCodeAt(i)?(u=":",i++):(u=null,0===s&&a('":"')),null!==u?(c=me(),null!==c?u=[u,c]:(u=null,i=y)):(u=null,i=y),u=null!==u?u:"",null!==u?(y=i,58===t.charCodeAt(i)?(c=":",i++):(c=null,0===s&&a('":"')),null!==c?(h=me(),null!==h?c=[c,h]:(c=null,i=y)):(c=null,i=y),c=null!==c?c:"",null!==c?("::"===t.substr(i,2)?(h="::",i+=2):(h=null,0===s&&a('"::"')),null!==h?e=[e,n,r,l,o,u,c,h]:(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g)):(e=null,i=g))))))))))))))),null!==e&&(e=function(e){return Ar.host_type="IPv6",t.substring(i,e)}(v)),null===e&&(i=v),e}function me(){var e,t,n,r,l;return l=i,e=d(),null!==e?(t=d(),t=null!==t?t:"",null!==t?(n=d(),n=null!==n?n:"",null!==n?(r=d(),r=null!==r?r:"",null!==r?e=[e,t,n,r]:(e=null,i=l)):(e=null,i=l)):(e=null,i=l)):(e=null,i=l),e}function ve(){var e,n,r,l;return l=i,e=me(),null!==e?(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&a('":"')),null!==n?(r=me(),null!==r?e=[e,n,r]:(e=null,i=l)):(e=null,i=l)):(e=null,i=l),null===e&&(e=ge()),e}function ge(){var e,n,r,l,o,u,c,h,f;return h=i,f=i,e=ye(),null!==e?(46===t.charCodeAt(i)?(n=".",i++):(n=null,0===s&&a('"."')),null!==n?(r=ye(),null!==r?(46===t.charCodeAt(i)?(l=".",i++):(l=null,0===s&&a('"."')),null!==l?(o=ye(),null!==o?(46===t.charCodeAt(i)?(u=".",i++):(u=null,0===s&&a('"."')),null!==u?(c=ye(),null!==c?e=[e,n,r,l,o,u,c]:(e=null,i=f)):(e=null,i=f)):(e=null,i=f)):(e=null,i=f)):(e=null,i=f)):(e=null,i=f)):(e=null,i=f),null!==e&&(e=function(e){return Ar.host_type="IPv4",t.substring(i,e)}(h)),null===e&&(i=h),e}function ye(){var e,n,r,l;return l=i,"25"===t.substr(i,2)?(e="25",i+=2):(e=null,0===s&&a('"25"')),null!==e?(/^[0-5]/.test(t.charAt(i))?(n=t.charAt(i),i++):(n=null,0===s&&a("[0-5]")),null!==n?e=[e,n]:(e=null,i=l)):(e=null,i=l),null===e&&(l=i,50===t.charCodeAt(i)?(e="2",i++):(e=null,0===s&&a('"2"')),null!==e?(/^[0-4]/.test(t.charAt(i))?(n=t.charAt(i),i++):(n=null,0===s&&a("[0-4]")),null!==n?(r=h(),null!==r?e=[e,n,r]:(e=null,i=l)):(e=null,i=l)):(e=null,i=l),null===e&&(l=i,49===t.charCodeAt(i)?(e="1",i++):(e=null,0===s&&a('"1"')),null!==e?(n=h(),null!==n?(r=h(),null!==r?e=[e,n,r]:(e=null,i=l)):(e=null,i=l)):(e=null,i=l),null===e&&(l=i,/^[1-9]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&a("[1-9]")),null!==e?(n=h(),null!==n?e=[e,n]:(e=null,i=l)):(e=null,i=l),null===e&&(e=h())))),e}function Te(){var e,t,n,r,l,s,o;return s=i,o=i,e=h(),e=null!==e?e:"",null!==e?(t=h(),t=null!==t?t:"",null!==t?(n=h(),n=null!==n?n:"",null!==n?(r=h(),r=null!==r?r:"",null!==r?(l=h(),l=null!==l?l:"",null!==l?e=[e,t,n,r,l]:(e=null,i=o)):(e=null,i=o)):(e=null,i=o)):(e=null,i=o)):(e=null,i=o),null!==e&&(e=function(e,t){return t=parseInt(t.join("")),Ar.port=t,t}(0,e)),null===e&&(i=s),e}function be(){var e,n,r,l;e=[],l=i,59===t.charCodeAt(i)?(n=";",i++):(n=null,0===s&&a('";"')),null!==n?(r=Ce(),null!==r?n=[n,r]:(n=null,i=l)):(n=null,i=l);while(null!==n)e.push(n),l=i,59===t.charCodeAt(i)?(n=";",i++):(n=null,0===s&&a('";"')),null!==n?(r=Ce(),null!==r?n=[n,r]:(n=null,i=l)):(n=null,i=l);return e}function Ce(){var e;return e=Se(),null===e&&(e=Ee(),null===e&&(e=Ae(),null===e&&(e=we(),null===e&&(e=Re(),null===e&&(e=Ie(),null===e&&(e=Oe())))))),e}function Se(){var e,n,r,l;return r=i,l=i,"transport="===t.substr(i,10).toLowerCase()?(e=t.substr(i,10),i+=10):(e=null,0===s&&a('"transport="')),null!==e?("udp"===t.substr(i,3).toLowerCase()?(n=t.substr(i,3),i+=3):(n=null,0===s&&a('"udp"')),null===n&&("tcp"===t.substr(i,3).toLowerCase()?(n=t.substr(i,3),i+=3):(n=null,0===s&&a('"tcp"')),null===n&&("sctp"===t.substr(i,4).toLowerCase()?(n=t.substr(i,4),i+=4):(n=null,0===s&&a('"sctp"')),null===n&&("tls"===t.substr(i,3).toLowerCase()?(n=t.substr(i,3),i+=3):(n=null,0===s&&a('"tls"')),null===n&&(n=D())))),null!==n?e=[e,n]:(e=null,i=l)):(e=null,i=l),null!==e&&(e=function(e,t){Ar.uri_params||(Ar.uri_params={}),Ar.uri_params["transport"]=t.toLowerCase()}(0,e[1])),null===e&&(i=r),e}function Ee(){var e,n,r,l;return r=i,l=i,"user="===t.substr(i,5).toLowerCase()?(e=t.substr(i,5),i+=5):(e=null,0===s&&a('"user="')),null!==e?("phone"===t.substr(i,5).toLowerCase()?(n=t.substr(i,5),i+=5):(n=null,0===s&&a('"phone"')),null===n&&("ip"===t.substr(i,2).toLowerCase()?(n=t.substr(i,2),i+=2):(n=null,0===s&&a('"ip"')),null===n&&(n=D())),null!==n?e=[e,n]:(e=null,i=l)):(e=null,i=l),null!==e&&(e=function(e,t){Ar.uri_params||(Ar.uri_params={}),Ar.uri_params["user"]=t.toLowerCase()}(0,e[1])),null===e&&(i=r),e}function Ae(){var e,n,r,l;return r=i,l=i,"method="===t.substr(i,7).toLowerCase()?(e=t.substr(i,7),i+=7):(e=null,0===s&&a('"method="')),null!==e?(n=_t(),null!==n?e=[e,n]:(e=null,i=l)):(e=null,i=l),null!==e&&(e=function(e,t){Ar.uri_params||(Ar.uri_params={}),Ar.uri_params["method"]=t}(0,e[1])),null===e&&(i=r),e}function we(){var e,n,r,l;return r=i,l=i,"ttl="===t.substr(i,4).toLowerCase()?(e=t.substr(i,4),i+=4):(e=null,0===s&&a('"ttl="')),null!==e?(n=er(),null!==n?e=[e,n]:(e=null,i=l)):(e=null,i=l),null!==e&&(e=function(e,t){Ar.params||(Ar.params={}),Ar.params["ttl"]=t}(0,e[1])),null===e&&(i=r),e}function Re(){var e,n,r,l;return r=i,l=i,"maddr="===t.substr(i,6).toLowerCase()?(e=t.substr(i,6),i+=6):(e=null,0===s&&a('"maddr="')),null!==e?(n=ce(),null!==n?e=[e,n]:(e=null,i=l)):(e=null,i=l),null!==e&&(e=function(e,t){Ar.uri_params||(Ar.uri_params={}),Ar.uri_params["maddr"]=t}(0,e[1])),null===e&&(i=r),e}function Ie(){var e,n,r,l,o,u;return l=i,o=i,"lr"===t.substr(i,2).toLowerCase()?(e=t.substr(i,2),i+=2):(e=null,0===s&&a('"lr"')),null!==e?(u=i,61===t.charCodeAt(i)?(n="=",i++):(n=null,0===s&&a('"="')),null!==n?(r=D(),null!==r?n=[n,r]:(n=null,i=u)):(n=null,i=u),n=null!==n?n:"",null!==n?e=[e,n]:(e=null,i=o)):(e=null,i=o),null!==e&&(e=function(e){Ar.uri_params||(Ar.uri_params={}),Ar.uri_params["lr"]=void 0}()),null===e&&(i=l),e}function Oe(){var e,n,r,l,o,u;return l=i,o=i,e=ke(),null!==e?(u=i,61===t.charCodeAt(i)?(n="=",i++):(n=null,0===s&&a('"="')),null!==n?(r=Ne(),null!==r?n=[n,r]:(n=null,i=u)):(n=null,i=u),n=null!==n?n:"",null!==n?e=[e,n]:(e=null,i=o)):(e=null,i=o),null!==e&&(e=function(e,t,n){Ar.uri_params||(Ar.uri_params={}),n="undefined"===typeof n?void 0:n[1],Ar.uri_params[t.toLowerCase()]=n}(0,e[0],e[1])),null===e&&(i=l),e}function ke(){var e,t,n;if(n=i,t=De(),null!==t){e=[];while(null!==t)e.push(t),t=De()}else e=null;return null!==e&&(e=function(e,t){return t.join("")}(0,e)),null===e&&(i=n),e}function Ne(){var e,t,n;if(n=i,t=De(),null!==t){e=[];while(null!==t)e.push(t),t=De()}else e=null;return null!==e&&(e=function(e,t){return t.join("")}(0,e)),null===e&&(i=n),e}function De(){var e;return e=xe(),null===e&&(e=b(),null===e&&(e=S())),e}function xe(){var e;return 91===t.charCodeAt(i)?(e="[",i++):(e=null,0===s&&a('"["')),null===e&&(93===t.charCodeAt(i)?(e="]",i++):(e=null,0===s&&a('"]"')),null===e&&(47===t.charCodeAt(i)?(e="/",i++):(e=null,0===s&&a('"/"')),null===e&&(58===t.charCodeAt(i)?(e=":",i++):(e=null,0===s&&a('":"')),null===e&&(38===t.charCodeAt(i)?(e="&",i++):(e=null,0===s&&a('"&"')),null===e&&(43===t.charCodeAt(i)?(e="+",i++):(e=null,0===s&&a('"+"')),null===e&&(36===t.charCodeAt(i)?(e="$",i++):(e=null,0===s&&a('"$"')))))))),e}function Pe(){var e,n,r,l,o,u,c;if(u=i,63===t.charCodeAt(i)?(e="?",i++):(e=null,0===s&&a('"?"')),null!==e)if(n=Ue(),null!==n){r=[],c=i,38===t.charCodeAt(i)?(l="&",i++):(l=null,0===s&&a('"&"')),null!==l?(o=Ue(),null!==o?l=[l,o]:(l=null,i=c)):(l=null,i=c);while(null!==l)r.push(l),c=i,38===t.charCodeAt(i)?(l="&",i++):(l=null,0===s&&a('"&"')),null!==l?(o=Ue(),null!==o?l=[l,o]:(l=null,i=c)):(l=null,i=c);null!==r?e=[e,n,r]:(e=null,i=u)}else e=null,i=u;else e=null,i=u;return e}function Ue(){var e,n,r,l,o;return l=i,o=i,e=qe(),null!==e?(61===t.charCodeAt(i)?(n="=",i++):(n=null,0===s&&a('"="')),null!==n?(r=Me(),null!==r?e=[e,n,r]:(e=null,i=o)):(e=null,i=o)):(e=null,i=o),null!==e&&(e=function(e,t,n){t=t.join("").toLowerCase(),n=n.join(""),Ar.uri_headers||(Ar.uri_headers={}),Ar.uri_headers[t]?Ar.uri_headers[t].push(n):Ar.uri_headers[t]=[n]}(0,e[0],e[2])),null===e&&(i=l),e}function qe(){var e,t;if(t=Le(),null===t&&(t=b(),null===t&&(t=S())),null!==t){e=[];while(null!==t)e.push(t),t=Le(),null===t&&(t=b(),null===t&&(t=S()))}else e=null;return e}function Me(){var e,t;e=[],t=Le(),null===t&&(t=b(),null===t&&(t=S()));while(null!==t)e.push(t),t=Le(),null===t&&(t=b(),null===t&&(t=S()));return e}function Le(){var e;return 91===t.charCodeAt(i)?(e="[",i++):(e=null,0===s&&a('"["')),null===e&&(93===t.charCodeAt(i)?(e="]",i++):(e=null,0===s&&a('"]"')),null===e&&(47===t.charCodeAt(i)?(e="/",i++):(e=null,0===s&&a('"/"')),null===e&&(63===t.charCodeAt(i)?(e="?",i++):(e=null,0===s&&a('"?"')),null===e&&(58===t.charCodeAt(i)?(e=":",i++):(e=null,0===s&&a('":"')),null===e&&(43===t.charCodeAt(i)?(e="+",i++):(e=null,0===s&&a('"+"')),null===e&&(36===t.charCodeAt(i)?(e="$",i++):(e=null,0===s&&a('"$"')))))))),e}function He(){var e;return e=pt(),null===e&&(e=Fe()),e}function Fe(){var e,t,n,r,l,s;return s=i,e=_t(),null!==e?(t=v(),null!==t?(n=je(),null!==n?(r=v(),null!==r?(l=lt(),null!==l?e=[e,t,n,r,l]:(e=null,i=s)):(e=null,i=s)):(e=null,i=s)):(e=null,i=s)):(e=null,i=s),e}function je(){var e;return e=te(),null===e&&(e=Ge()),e}function Ge(){var e,n,r,l;return l=i,e=Ze(),null!==e?(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&a('":"')),null!==n?(r=Ve(),null===r&&(r=Ke()),null!==r?e=[e,n,r]:(e=null,i=l)):(e=null,i=l)):(e=null,i=l),e}function Ve(){var e,n,r,l,o;return l=i,e=We(),null===e&&(e=Be()),null!==e?(o=i,63===t.charCodeAt(i)?(n="?",i++):(n=null,0===s&&a('"?"')),null!==n?(r=rt(),null!==r?n=[n,r]:(n=null,i=o)):(n=null,i=o),n=null!==n?n:"",null!==n?e=[e,n]:(e=null,i=l)):(e=null,i=l),e}function We(){var e,n,r,l;return l=i,"//"===t.substr(i,2)?(e="//",i+=2):(e=null,0===s&&a('"//"')),null!==e?(n=et(),null!==n?(r=Be(),r=null!==r?r:"",null!==r?e=[e,n,r]:(e=null,i=l)):(e=null,i=l)):(e=null,i=l),e}function Be(){var e,n,r;return r=i,47===t.charCodeAt(i)?(e="/",i++):(e=null,0===s&&a('"/"')),null!==e?(n=$e(),null!==n?e=[e,n]:(e=null,i=r)):(e=null,i=r),e}function Ke(){var e,t,n,r;if(r=i,e=Ye(),null!==e){t=[],n=ze();while(null!==n)t.push(n),n=ze();null!==t?e=[e,t]:(e=null,i=r)}else e=null,i=r;return e}function ze(){var e;return e=T(),null===e&&(e=b(),null===e&&(e=S())),e}function Ye(){var e;return e=b(),null===e&&(e=S(),null===e&&(59===t.charCodeAt(i)?(e=";",i++):(e=null,0===s&&a('";"')),null===e&&(63===t.charCodeAt(i)?(e="?",i++):(e=null,0===s&&a('"?"')),null===e&&(58===t.charCodeAt(i)?(e=":",i++):(e=null,0===s&&a('":"')),null===e&&(64===t.charCodeAt(i)?(e="@",i++):(e=null,0===s&&a('"@"')),null===e&&(38===t.charCodeAt(i)?(e="&",i++):(e=null,0===s&&a('"&"')),null===e&&(61===t.charCodeAt(i)?(e="=",i++):(e=null,0===s&&a('"="')),null===e&&(43===t.charCodeAt(i)?(e="+",i++):(e=null,0===s&&a('"+"')),null===e&&(36===t.charCodeAt(i)?(e="$",i++):(e=null,0===s&&a('"$"')),null===e&&(44===t.charCodeAt(i)?(e=",",i++):(e=null,0===s&&a('","')))))))))))),e}function $e(){var e,n,r,l,o,u;if(o=i,e=Je(),null!==e){n=[],u=i,47===t.charCodeAt(i)?(r="/",i++):(r=null,0===s&&a('"/"')),null!==r?(l=Je(),null!==l?r=[r,l]:(r=null,i=u)):(r=null,i=u);while(null!==r)n.push(r),u=i,47===t.charCodeAt(i)?(r="/",i++):(r=null,0===s&&a('"/"')),null!==r?(l=Je(),null!==l?r=[r,l]:(r=null,i=u)):(r=null,i=u);null!==n?e=[e,n]:(e=null,i=o)}else e=null,i=o;return e}function Je(){var e,n,r,l,o,u;o=i,e=[],n=Qe();while(null!==n)e.push(n),n=Qe();if(null!==e){n=[],u=i,59===t.charCodeAt(i)?(r=";",i++):(r=null,0===s&&a('";"')),null!==r?(l=Xe(),null!==l?r=[r,l]:(r=null,i=u)):(r=null,i=u);while(null!==r)n.push(r),u=i,59===t.charCodeAt(i)?(r=";",i++):(r=null,0===s&&a('";"')),null!==r?(l=Xe(),null!==l?r=[r,l]:(r=null,i=u)):(r=null,i=u);null!==n?e=[e,n]:(e=null,i=o)}else e=null,i=o;return e}function Xe(){var e,t;e=[],t=Qe();while(null!==t)e.push(t),t=Qe();return e}function Qe(){var e;return e=b(),null===e&&(e=S(),null===e&&(58===t.charCodeAt(i)?(e=":",i++):(e=null,0===s&&a('":"')),null===e&&(64===t.charCodeAt(i)?(e="@",i++):(e=null,0===s&&a('"@"')),null===e&&(38===t.charCodeAt(i)?(e="&",i++):(e=null,0===s&&a('"&"')),null===e&&(61===t.charCodeAt(i)?(e="=",i++):(e=null,0===s&&a('"="')),null===e&&(43===t.charCodeAt(i)?(e="+",i++):(e=null,0===s&&a('"+"')),null===e&&(36===t.charCodeAt(i)?(e="$",i++):(e=null,0===s&&a('"$"')),null===e&&(44===t.charCodeAt(i)?(e=",",i++):(e=null,0===s&&a('","')))))))))),e}function Ze(){var e,n,r,l,o;if(l=i,o=i,e=f(),null!==e){n=[],r=f(),null===r&&(r=h(),null===r&&(43===t.charCodeAt(i)?(r="+",i++):(r=null,0===s&&a('"+"')),null===r&&(45===t.charCodeAt(i)?(r="-",i++):(r=null,0===s&&a('"-"')),null===r&&(46===t.charCodeAt(i)?(r=".",i++):(r=null,0===s&&a('"."'))))));while(null!==r)n.push(r),r=f(),null===r&&(r=h(),null===r&&(43===t.charCodeAt(i)?(r="+",i++):(r=null,0===s&&a('"+"')),null===r&&(45===t.charCodeAt(i)?(r="-",i++):(r=null,0===s&&a('"-"')),null===r&&(46===t.charCodeAt(i)?(r=".",i++):(r=null,0===s&&a('"."'))))));null!==n?e=[e,n]:(e=null,i=o)}else e=null,i=o;return null!==e&&(e=function(e){Ar.scheme=t.substring(i,e)}(l)),null===e&&(i=l),e}function et(){var e;return e=tt(),null===e&&(e=nt()),e}function tt(){var e,n,r,l;return r=i,l=i,e=ie(),null!==e?(64===t.charCodeAt(i)?(n="@",i++):(n=null,0===s&&a('"@"')),null!==n?e=[e,n]:(e=null,i=l)):(e=null,i=l),e=null!==e?e:"",null!==e?(n=ae(),null!==n?e=[e,n]:(e=null,i=r)):(e=null,i=r),e=null!==e?e:"",e}function nt(){var e,n;if(n=b(),null===n&&(n=S(),null===n&&(36===t.charCodeAt(i)?(n="$",i++):(n=null,0===s&&a('"$"')),null===n&&(44===t.charCodeAt(i)?(n=",",i++):(n=null,0===s&&a('","')),null===n&&(59===t.charCodeAt(i)?(n=";",i++):(n=null,0===s&&a('";"')),null===n&&(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&a('":"')),null===n&&(64===t.charCodeAt(i)?(n="@",i++):(n=null,0===s&&a('"@"')),null===n&&(38===t.charCodeAt(i)?(n="&",i++):(n=null,0===s&&a('"&"')),null===n&&(61===t.charCodeAt(i)?(n="=",i++):(n=null,0===s&&a('"="')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&a('"+"'))))))))))),null!==n){e=[];while(null!==n)e.push(n),n=b(),null===n&&(n=S(),null===n&&(36===t.charCodeAt(i)?(n="$",i++):(n=null,0===s&&a('"$"')),null===n&&(44===t.charCodeAt(i)?(n=",",i++):(n=null,0===s&&a('","')),null===n&&(59===t.charCodeAt(i)?(n=";",i++):(n=null,0===s&&a('";"')),null===n&&(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&a('":"')),null===n&&(64===t.charCodeAt(i)?(n="@",i++):(n=null,0===s&&a('"@"')),null===n&&(38===t.charCodeAt(i)?(n="&",i++):(n=null,0===s&&a('"&"')),null===n&&(61===t.charCodeAt(i)?(n="=",i++):(n=null,0===s&&a('"="')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&a('"+"')))))))))))}else e=null;return e}function rt(){var e,t;e=[],t=ze();while(null!==t)e.push(t),t=ze();return e}function lt(){var e,n,r,l,o,u,c,f;if(c=i,f=i,"sip"===t.substr(i,3).toLowerCase()?(e=t.substr(i,3),i+=3):(e=null,0===s&&a('"SIP"')),null!==e)if(47===t.charCodeAt(i)?(n="/",i++):(n=null,0===s&&a('"/"')),null!==n){if(l=h(),null!==l){r=[];while(null!==l)r.push(l),l=h()}else r=null;if(null!==r)if(46===t.charCodeAt(i)?(l=".",i++):(l=null,0===s&&a('"."')),null!==l){if(u=h(),null!==u){o=[];while(null!==u)o.push(u),u=h()}else o=null;null!==o?e=[e,n,r,l,o]:(e=null,i=f)}else e=null,i=f;else e=null,i=f}else e=null,i=f;else e=null,i=f;return null!==e&&(e=function(e){Ar.sip_version=t.substring(i,e)}(c)),null===e&&(i=c),e}function it(){var e;return"INVITE"===t.substr(i,6)?(e="INVITE",i+=6):(e=null,0===s&&a('"INVITE"')),e}function st(){var e;return"ACK"===t.substr(i,3)?(e="ACK",i+=3):(e=null,0===s&&a('"ACK"')),e}function ot(){var e;return"OPTIONS"===t.substr(i,7)?(e="OPTIONS",i+=7):(e=null,0===s&&a('"OPTIONS"')),e}function ut(){var e;return"BYE"===t.substr(i,3)?(e="BYE",i+=3):(e=null,0===s&&a('"BYE"')),e}function at(){var e;return"CANCEL"===t.substr(i,6)?(e="CANCEL",i+=6):(e=null,0===s&&a('"CANCEL"')),e}function ct(){var e;return"REGISTER"===t.substr(i,8)?(e="REGISTER",i+=8):(e=null,0===s&&a('"REGISTER"')),e}function ht(){var e;return"SUBSCRIBE"===t.substr(i,9)?(e="SUBSCRIBE",i+=9):(e=null,0===s&&a('"SUBSCRIBE"')),e}function ft(){var e;return"NOTIFY"===t.substr(i,6)?(e="NOTIFY",i+=6):(e=null,0===s&&a('"NOTIFY"')),e}function dt(){var e;return"REFER"===t.substr(i,5)?(e="REFER",i+=5):(e=null,0===s&&a('"REFER"')),e}function _t(){var e,n;return n=i,e=it(),null===e&&(e=st(),null===e&&(e=ot(),null===e&&(e=ut(),null===e&&(e=at(),null===e&&(e=ct(),null===e&&(e=ht(),null===e&&(e=ft(),null===e&&(e=dt(),null===e&&(e=D()))))))))),null!==e&&(e=function(e){return Ar.method=t.substring(i,e),Ar.method}(n)),null===e&&(i=n),e}function pt(){var e,t,n,r,l,s;return s=i,e=lt(),null!==e?(t=v(),null!==t?(n=mt(),null!==n?(r=v(),null!==r?(l=gt(),null!==l?e=[e,t,n,r,l]:(e=null,i=s)):(e=null,i=s)):(e=null,i=s)):(e=null,i=s)):(e=null,i=s),e}function mt(){var e,t;return t=i,e=vt(),null!==e&&(e=function(e,t){Ar.status_code=parseInt(t.join(""))}(0,e)),null===e&&(i=t),e}function vt(){var e,t,n,r;return r=i,e=h(),null!==e?(t=h(),null!==t?(n=h(),null!==n?e=[e,t,n]:(e=null,i=r)):(e=null,i=r)):(e=null,i=r),e}function gt(){var e,n,r;r=i,e=[],n=T(),null===n&&(n=b(),null===n&&(n=S(),null===n&&(n=O(),null===n&&(n=k(),null===n&&(n=v(),null===n&&(n=g()))))));while(null!==n)e.push(n),n=T(),null===n&&(n=b(),null===n&&(n=S(),null===n&&(n=O(),null===n&&(n=k(),null===n&&(n=v(),null===n&&(n=g()))))));return null!==e&&(e=function(e){Ar.reason_phrase=t.substring(i,e)}(r)),null===e&&(i=r),e}function yt(){var e,t,n,r,l,s;if(l=i,e=Qt(),null!==e){t=[],s=i,n=V(),null!==n?(r=Qt(),null!==r?n=[n,r]:(n=null,i=s)):(n=null,i=s);while(null!==n)t.push(n),s=i,n=V(),null!==n?(r=Qt(),null!==r?n=[n,r]:(n=null,i=s)):(n=null,i=s);null!==t?e=[e,t]:(e=null,i=l)}else e=null,i=l;return e}function Tt(){var e,n,r,l,o,u;return l=i,o=i,e=U(),null!==e?(u=i,64===t.charCodeAt(i)?(n="@",i++):(n=null,0===s&&a('"@"')),null!==n?(r=U(),null!==r?n=[n,r]:(n=null,i=u)):(n=null,i=u),n=null!==n?n:"",null!==n?e=[e,n]:(e=null,i=o)):(e=null,i=o),null!==e&&(e=function(e){Ar=t.substring(i,e)}(l)),null===e&&(i=l),e}function bt(){var e,t,n,r,l,s,o;if(l=i,e=q(),null===e)if(s=i,e=Ct(),null!==e){t=[],o=i,n=V(),null!==n?(r=Ct(),null!==r?n=[n,r]:(n=null,i=o)):(n=null,i=o);while(null!==n)t.push(n),o=i,n=V(),null!==n?(r=Ct(),null!==r?n=[n,r]:(n=null,i=o)):(n=null,i=o);null!==t?e=[e,t]:(e=null,i=s)}else e=null,i=s;return null!==e&&(e=function(e){var t,n;for(n=Ar.multi_header.length,t=0;t=0:d>_;_+=p)_ in f&&(c=n(c,f[_],_,h));return c}};e.exports={left:a(!1),right:a(!0)}},d46e:function(e,t,n){var r=n("e1bd"),l=n("e314"),i=n("44ce");t.grammar=i,t.write=l,t.parse=r.parse,t.parseParams=r.parseParams,t.parseFmtpConfig=r.parseFmtpConfig,t.parsePayloads=r.parsePayloads,t.parseRemoteCandidates=r.parseRemoteCandidates,t.parseImageAttributes=r.parseImageAttributes,t.parseSimulcastStreamList=r.parseSimulcastStreamList},ddc8:function(e,t,n){"use strict";function r(e){return r="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:{},l=e;if(void 0===e||void 0===t)throw new TypeError("Not enough arguments");if(e=this._ua.normalizeTarget(e),!e)throw new TypeError("Invalid target: ".concat(l));var i=g.cloneArray(r.extraHeaders),s=g.cloneObject(r.eventHandlers),o=r.contentType||"text/plain",u={};for(var a in r.fromUserName&&(u.from_uri=new b("sip",r.fromUserName,this._ua.configuration.uri.host),i.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString()))),r.fromDisplayName&&(u.from_display_name=r.fromDisplayName),s)Object.prototype.hasOwnProperty.call(s,a)&&this.on(a,s[a]);i.push("Content-Type: ".concat(o)),this._request=new v.OutgoingRequest(m.MESSAGE,e,this._ua,u,i),t&&(this._request.body=t);var c=new y(this._ua,this._request,{onRequestTimeout:function(){n._onRequestTimeout()},onTransportError:function(){n._onTransportError()},onReceiveResponse:function(e){n._receiveResponse(e)}});this._newMessage("local",this._request),c.send()}},{key:"init_incoming",value:function(e){this._request=e,this._newMessage("remote",e),this._is_replied||(this._is_replied=!0,e.reply(200)),this._close()}},{key:"accept",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=g.cloneArray(e.extraHeaders),n=e.body;if("incoming"!==this._direction)throw new T.NotSupportedError('"accept" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");this._is_replied=!0,this._request.reply(200,null,t,n)}},{key:"reject",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.status_code||480,n=e.reason_phrase,r=g.cloneArray(e.extraHeaders),l=e.body;if("incoming"!==this._direction)throw new T.NotSupportedError('"reject" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");if(t<300||t>=700)throw new TypeError("Invalid status_code: ".concat(t));this._is_replied=!0,this._request.reply(t,n,r,l)}},{key:"_receiveResponse",value:function(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:var t=g.sipErrorCause(e.status_code);this._failed("remote",e,t);break}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,m.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,m.causes.CONNECTION_ERROR)}},{key:"_close",value:function(){this._closed=!0,this._ua.destroyMessage(this)}},{key:"_newMessage",value:function(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})}},{key:"_failed",value:function(e,t,n){C.debug("MESSAGE failed"),this._close(),C.debug('emit "failed"'),this.emit("failed",{originator:e,response:t||null,cause:n})}},{key:"_succeeded",value:function(e,t){C.debug("MESSAGE succeeded"),this._close(),C.debug('emit "succeeded"'),this.emit("succeeded",{originator:e,response:t})}},{key:"direction",get:function(){return this._direction}},{key:"local_identity",get:function(){return this._local_identity}},{key:"remote_identity",get:function(){return this._remote_identity}}]),n}(_)},de982:function(e,t,n){"use strict";function r(e){return r="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};if(void 0===e)throw new 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)throw new v.InvalidStateError(this._session.status);var r=g.cloneArray(n.extraHeaders);if(this.eventHandlers=g.cloneObject(n.eventHandlers),"string"===typeof e)e=e.toUpperCase();else{if("number"!==typeof e)throw new TypeError("Invalid tone: ".concat(e));e=e.toString()}if(!e.match(/^[0-9A-DR#*]$/))throw new TypeError("Invalid tone: ".concat(e));this._tone=e,this._duration=n.duration,r.push("Content-Type: application/dtmf-relay");var l="Signal=".concat(this._tone,"\r\n");l+="Duration=".concat(this._duration),this._session.newDTMF({originator:"local",dtmf:this,request:this._request}),this._session.sendRequest(m.INFO,{extraHeaders:r,eventHandlers:{onSuccessResponse:function(e){t.emit("succeeded",{originator:"remote",response:e})},onErrorResponse:function(e){t.eventHandlers.onFailed&&t.eventHandlers.onFailed(),t.emit("failed",{originator:"remote",response:e})},onRequestTimeout:function(){t._session.onRequestTimeout()},onTransportError:function(){t._session.onTransportError()},onDialogError:function(){t._session.onDialogError()}},body:l})}},{key:"init_incoming",value:function(e){var t=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,n=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;if(this._direction="incoming",this._request=e,e.reply(200),e.body){var r=e.body.split("\n");r.length>=1&&t.test(r[0])&&(this._tone=r[0].replace(t,"$2")),r.length>=2&&n.test(r[1])&&(this._duration=parseInt(r[1].replace(n,"$2"),10))}this._duration||(this._duration=T.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:e}):y.debug("invalid INFO DTMF received, discarded")}},{key:"tone",get:function(){return this._tone}},{key:"duration",get:function(){return this._duration}}]),n}(_),e.exports.C=T},e1bd:function(e,t,n){var r=function(e){return String(Number(e))===e?Number(e):e},l=function(e,t,n,l){if(l&&!n)t[l]=r(e[1]);else for(var i=0;i1&&(e[n[0]]=void 0),e};t.parseParams=function(e){return e.split(/;\s?/).reduce(u,{})},t.parseFmtpConfig=t.parseParams,t.parsePayloads=function(e){return e.toString().split(" ").map(Number)},t.parseRemoteCandidates=function(e){for(var t=[],n=e.split(" ").map(r),l=0;l=r)return e;var l=n[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(l);case"%d":return Number(l);case"%v":return""}}))},s=function(e,t,n){var r=t.format instanceof Function?t.format(t.push?n:n[t.name]):t.format,l=[e+"="+r];if(t.names)for(var s=0;s1?arguments[1]:void 0)}})},eca7:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var n=0;n"),this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,t)&&(e+=";".concat(t),null!==this._parameters[t]&&(e+="=".concat(this._parameters[t])));return e}},{key:"uri",get:function(){return this._uri}},{key:"display_name",get:function(){return this._display_name},set:function(e){this._display_name=0===e?"0":e}}]),e}()},f368:function(e,t,n){"use strict";function r(e,t){var n;if("undefined"===typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=l(e))||t&&e&&"number"===typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,o=!0,u=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){u=!0,s=e},f:function(){try{o||null==n["return"]||n["return"]()}finally{if(u)throw s}}}}function l(e,t){if(e){if("string"===typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n1)return d.debug("more than one Via header field present in the response, dropping the response"),!1}function C(){var e=f.str_utf8_length(s.body),t=s.getHeader("content-length");if(e100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var u=parseFloat(t[1]),a=(t[2]||"ms").toLowerCase();switch(a){case"years":case"year":case"yrs":case"yr":case"y":return u*o;case"weeks":case"week":case"w":return u*s;case"days":case"day":case"d":return u*i;case"hours":case"hour":case"hrs":case"hr":case"h":return u*l;case"minutes":case"minute":case"mins":case"min":case"m":return u*r;case"seconds":case"second":case"secs":case"sec":case"s":return u*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return u;default:return}}}}function a(e){var t=Math.abs(e);return t>=i?Math.round(e/i)+"d":t>=l?Math.round(e/l)+"h":t>=r?Math.round(e/r)+"m":t>=n?Math.round(e/n)+"s":e+"ms"}function c(e){var t=Math.abs(e);return t>=i?h(e,t,i,"day"):t>=l?h(e,t,l,"hour"):t>=r?h(e,t,r,"minute"):t>=n?h(e,t,n,"second"):e+" ms"}function h(e,t,n,r){var l=t>=1.5*n;return Math.round(e/n)+" "+r+(l?"s":"")}e.exports=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return u(e);if("number"===n&&isFinite(e))return t.long?c(e):a(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},fa17:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var n=0;n=200&&e.status_code<300?this._eventHandlers.onSuccessResponse(e):e.status_code>=300&&this._eventHandlers.onErrorResponse(e):(this._request.cseq=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout((function(){t._dialog.isTerminated()||(t._reattempt=!0,t.send())}),1e3)):e.status_code>=200&&e.status_code<300?this._eventHandlers.onSuccessResponse(e):e.status_code>=300&&this._eventHandlers.onErrorResponse(e)}},{key:"request",get:function(){return this._request}}]),e}()},fc06:function(e,t,n){"use strict";function r(e){return r="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function l(e,t){var n;if("undefined"===typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=i(e))||t&&e&&"number"===typeof e.length){n&&(e=n);var r=0,l=function(){};return{s:l,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:l}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,o=!0,u=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){u=!0,s=e},f:function(){try{o||null==n["return"]||n["return"]()}finally{if(u)throw s}}}}function i(e,t){if(e){if("string"===typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,t):void 0}}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;x.debug("connect()");var r=e,l=S.cloneObject(t.eventHandlers),i=S.cloneArray(t.extraHeaders),s=S.cloneObject(t.mediaConstraints,{audio:!0,video:!0}),o=t.mediaStream||null,u=S.cloneObject(t.pcConfig,{iceServers:[]}),a=t.rtcConstraints||null,c=t.rtcOfferConstraints||null;if(this._rtcOfferConstraints=c,this._rtcAnswerConstraints=t.rtcAnswerConstraints||null,this._data=t.data||this._data,void 0===e)throw new TypeError("Not enough arguments");if(this._status!==P.STATUS_NULL)throw new b.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new b.NotSupportedError("WebRTC not supported");if(e=this._ua.normalizeTarget(e),!e)throw new TypeError("Invalid target: ".concat(r));for(var h in this._sessionTimers.enabled&&S.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=T.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=T.SESSION_EXPIRES),l)Object.prototype.hasOwnProperty.call(l,h)&&this.on(h,l[h]);this._from_tag=S.newTag();var f=t.anonymous||!1,d={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:f,outbound:!0}),f?(d.from_display_name="Anonymous",d.from_uri=new D("sip","anonymous","anonymous.invalid"),i.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString())),i.push("Privacy: id")):t.fromUserName&&(d.from_uri=new D("sip",t.fromUserName,this._ua.configuration.uri.host),i.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString()))),t.fromDisplayName&&(d.from_display_name=t.fromDisplayName),i.push("Contact: ".concat(this._contact)),i.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&i.push("Session-Expires: ".concat(this._sessionTimers.defaultExpires).concat(this._ua.configuration.session_timers_force_refresher?";refresher=uac":"")),this._request=new A.InitialOutgoingInviteRequest(e,this._ua,d,i),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(u,a),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,n&&n(this),this._newRTCSession("local",this._request),this._sendInitialRequest(s,c,o)}},{key:"init_incoming",value:function(e,t){var n,r=this;x.debug("init_incoming()");var l=e.hasHeader("Content-Type")?e.getHeader("Content-Type").toLowerCase():void 0;e.body&&"application/sdp"!==l?e.reply(415):(this._status=P.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")&&(n=1e3*e.getHeader("expires")),e.to_tag=S.newTag(),this._createDialog(e,"UAS",!0)?(e.body?this._late_sdp=!1:this._late_sdp=!0,this._status=P.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout((function(){e.reply(408),r._failed("local",null,T.causes.NO_ANSWER)}),this._ua.configuration.no_answer_timeout),n&&(this._timers.expiresTimer=setTimeout((function(){r._status===P.STATUS_WAITING_FOR_ANSWER&&(e.reply(487),r._failed("system",null,T.causes.EXPIRES))}),n)),this._direction="incoming",this._local_identity=e.to,this._remote_identity=e.from,t&&t(this),this._newRTCSession("remote",e),this._status!==P.STATUS_TERMINATED&&(e.reply(180,null,["Contact: ".concat(this._contact)]),this._progress("local",null))):e.reply(500,"Missing Contact header field"))}},{key:"answer",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};x.debug("answer()");var n,r=this._request,i=S.cloneArray(t.extraHeaders),s=S.cloneObject(t.mediaConstraints),o=t.mediaStream||null,u=S.cloneObject(t.pcConfig,{iceServers:[]}),a=t.rtcConstraints||null,c=t.rtcAnswerConstraints||null,h=S.cloneObject(t.rtcOfferConstraints),f=!1,d=!1,_=!1,p=!1;if(this._rtcAnswerConstraints=c,this._rtcOfferConstraints=t.rtcOfferConstraints||null,this._data=t.data||this._data,"incoming"!==this._direction)throw new b.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==P.STATUS_WAITING_FOR_ANSWER)throw new b.InvalidStateError(this._status);if(this._sessionTimers.enabled&&S.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=T.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=T.SESSION_EXPIRES),this._status=P.STATUS_ANSWERED,this._createDialog(r,"UAS")){clearTimeout(this._timers.userNoAnswerTimer),i.unshift("Contact: ".concat(this._contact));var m=r.parseSDP();Array.isArray(m.media)||(m.media=[m.media]);var v,g=l(m.media);try{for(g.s();!(v=g.n()).done;){var y=v.value;"audio"===y.type&&(f=!0,y.direction&&"sendrecv"!==y.direction||(_=!0)),"video"===y.type&&(d=!0,y.direction&&"sendrecv"!==y.direction||(p=!0))}}catch(O){g.e(O)}finally{g.f()}if(o&&!1===s.audio){n=o.getAudioTracks();var C,E=l(n);try{for(E.s();!(C=E.n()).done;){var A=C.value;o.removeTrack(A)}}catch(O){E.e(O)}finally{E.f()}}if(o&&!1===s.video){n=o.getVideoTracks();var w,R=l(n);try{for(R.s();!(w=R.n()).done;){var I=w.value;o.removeTrack(I)}}catch(O){R.e(O)}finally{R.f()}}o||void 0!==s.audio||(s.audio=_),o||void 0!==s.video||(s.video=p),o||f||h.offerToReceiveAudio||(s.audio=!1),o||d||h.offerToReceiveVideo||(s.video=!1),this._createRTCConnection(u,a),Promise.resolve().then((function(){return o||(s.audio||s.video?(e._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(s)["catch"]((function(t){if(e._status===P.STATUS_TERMINATED)throw new Error("terminated");throw r.reply(480),e._failed("local",null,T.causes.USER_DENIED_MEDIA_ACCESS),x.warn('emit "getusermediafailed" [error:%o]',t),e.emit("getusermediafailed",t),new Error("getUserMedia() failed")}))):void 0)})).then((function(t){if(e._status===P.STATUS_TERMINATED)throw new Error("terminated");e._localMediaStream=t,t&&t.getTracks().forEach((function(n){e._connection.addTrack(n,t)}))})).then((function(){if(!e._late_sdp){var t={originator:"remote",type:"offer",sdp:r.body};x.debug('emit "sdp"'),e.emit("sdp",t);var n=new RTCSessionDescription({type:"offer",sdp:t.sdp});return e._connectionPromiseQueue=e._connectionPromiseQueue.then((function(){return e._connection.setRemoteDescription(n)}))["catch"]((function(t){throw r.reply(488),e._failed("system",null,T.causes.WEBRTC_ERROR),x.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',t),e.emit("peerconnection:setremotedescriptionfailed",t),new Error("peerconnection.setRemoteDescription() failed")})),e._connectionPromiseQueue}})).then((function(){if(e._status===P.STATUS_TERMINATED)throw new Error("terminated");return e._connecting(r),e._late_sdp?e._createLocalDescription("offer",e._rtcOfferConstraints)["catch"]((function(){throw r.reply(500),new Error("_createLocalDescription() failed")})):e._createLocalDescription("answer",c)["catch"]((function(){throw r.reply(500),new Error("_createLocalDescription() failed")}))})).then((function(t){if(e._status===P.STATUS_TERMINATED)throw new Error("terminated");e._handleSessionTimersInIncomingRequest(r,i),r.reply(200,null,i,t,(function(){e._status=P.STATUS_WAITING_FOR_ACK,e._setInvite2xxTimer(r,t),e._setACKTimer(),e._accepted("local")}),(function(){e._failed("system",null,T.causes.CONNECTION_ERROR)}))}))["catch"]((function(t){e._status!==P.STATUS_TERMINATED&&x.warn(t)}))}else r.reply(500,"Error creating dialog")}},{key:"terminate",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};x.debug("terminate()");var n,r=t.cause||T.causes.BYE,l=S.cloneArray(t.extraHeaders),i=t.body,s=t.status_code,o=t.reason_phrase;if(this._status===P.STATUS_TERMINATED)throw new b.InvalidStateError(this._status);switch(this._status){case P.STATUS_NULL:case P.STATUS_INVITE_SENT:case P.STATUS_1XX_RECEIVED:if(x.debug("canceling session"),s&&(s<200||s>=700))throw new TypeError("Invalid status_code: ".concat(s));s&&(o=o||T.REASON_PHRASE[s]||"",n="SIP ;cause=".concat(s,' ;text="').concat(o,'"')),this._status===P.STATUS_NULL||this._status===P.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=n):this._status===P.STATUS_1XX_RECEIVED&&this._request.cancel(n),this._status=P.STATUS_CANCELED,this._failed("local",null,T.causes.CANCELED);break;case P.STATUS_WAITING_FOR_ANSWER:case P.STATUS_ANSWERED:if(x.debug("rejecting session"),s=s||480,s<300||s>=700)throw new TypeError("Invalid status_code: ".concat(s));this._request.reply(s,o,l,i),this._failed("local",null,T.causes.REJECTED);break;case P.STATUS_WAITING_FOR_ACK:case P.STATUS_CONFIRMED:if(x.debug("terminating session"),o=t.reason_phrase||T.REASON_PHRASE[s]||"",s&&(s<200||s>=700))throw new TypeError("Invalid status_code: ".concat(s));if(s&&l.push("Reason: SIP ;cause=".concat(s,'; text="').concat(o,'"')),this._status===P.STATUS_WAITING_FOR_ACK&&"incoming"===this._direction&&this._request.server_transaction.state!==C.C.STATUS_TERMINATED){var u=this._dialog;this.receiveRequest=function(t){var n=t.method;n===T.ACK&&(e.sendRequest(T.BYE,{extraHeaders:l,body:i}),u.terminate())},this._request.server_transaction.on("stateChanged",(function(){e._request.server_transaction.state===C.C.STATUS_TERMINATED&&(e.sendRequest(T.BYE,{extraHeaders:l,body:i}),u.terminate())})),this._ended("local",null,r),this._dialog=u,this._ua.newDialog(u)}else this.sendRequest(T.BYE,{extraHeaders:l,body:i}),this._ended("local",null,r)}}},{key:"sendDTMF",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};x.debug("sendDTMF() | tones: %s",e);var n=0,r=t.duration||null,l=t.interToneGap||null,i=t.transportType||T.DTMF_TRANSPORT.INFO;if(void 0===e)throw new TypeError("Not enough arguments");if(this._status!==P.STATUS_CONFIRMED&&this._status!==P.STATUS_WAITING_FOR_ACK&&this._status!==P.STATUS_1XX_RECEIVED)throw new b.InvalidStateError(this._status);if(i!==T.DTMF_TRANSPORT.INFO&&i!==T.DTMF_TRANSPORT.RFC2833)throw new TypeError("invalid transportType: ".concat(i));if("number"===typeof e&&(e=e.toString()),!e||"string"!==typeof e||!e.match(/^[0-9A-DR#*,]+$/i))throw new TypeError("Invalid tones: ".concat(e));if(r&&!S.isDecimal(r))throw new TypeError("Invalid tone duration: ".concat(r));if(r?rI.C.MAX_DURATION?(x.debug('"duration" value is greater than the maximum allowed, setting it to '.concat(I.C.MAX_DURATION," milliseconds")),r=I.C.MAX_DURATION):r=Math.abs(r):r=I.C.DEFAULT_DURATION,t.duration=r,l&&!S.isDecimal(l))throw new TypeError("Invalid interToneGap: ".concat(l));if(l?l=this._tones.length)this._tones=null;else{var s=this._tones[n];if(n+=1,","===s)e=2e3;else{var u=new I(this);t.eventHandlers={onFailed:function(){i._tones=null}},u.send(s,t),e=r+l}setTimeout(o.bind(this),e)}}}},{key:"sendInfo",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(x.debug("sendInfo()"),this._status!==P.STATUS_CONFIRMED&&this._status!==P.STATUS_WAITING_FOR_ACK&&this._status!==P.STATUS_1XX_RECEIVED)throw new b.InvalidStateError(this._status);var r=new O(this);r.send(e,t,n)}},{key:"mute",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{audio:!0,video:!1};x.debug("mute()");var t=!1,n=!1;!1===this._audioMuted&&e.audio&&(t=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),!1===this._videoMuted&&e.video&&(n=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),!0!==t&&!0!==n||this._onmute({audio:t,video:n})}},{key:"unmute",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{audio:!0,video:!0};x.debug("unmute()");var t=!1,n=!1;!0===this._audioMuted&&e.audio&&(t=!0,this._audioMuted=!1,!1===this._localHold&&this._toggleMuteAudio(!1)),!0===this._videoMuted&&e.video&&(n=!0,this._videoMuted=!1,!1===this._localHold&&this._toggleMuteVideo(!1)),!0!==t&&!0!==n||this._onunmute({audio:t,video:n})}},{key:"hold",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(x.debug("hold()"),this._status!==P.STATUS_WAITING_FOR_ACK&&this._status!==P.STATUS_CONFIRMED)return!1;if(!0===this._localHold)return!1;if(!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");var r={succeeded:function(){n&&n()},failed:function(){e.terminate({cause:T.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:r,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:r,extraHeaders:t.extraHeaders}),!0}},{key:"unhold",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(x.debug("unhold()"),this._status!==P.STATUS_WAITING_FOR_ACK&&this._status!==P.STATUS_CONFIRMED)return!1;if(!1===this._localHold)return!1;if(!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");var r={succeeded:function(){n&&n()},failed:function(){e.terminate({cause:T.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:r,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:r,extraHeaders:t.extraHeaders}),!0}},{key:"renegotiate",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;x.debug("renegotiate()");var r=t.rtcOfferConstraints||null;if(this._status!==P.STATUS_WAITING_FOR_ACK&&this._status!==P.STATUS_CONFIRMED)return!1;if(!this._isReadyToReOffer())return!1;var l={succeeded:function(){n&&n()},failed:function(){e.terminate({cause:T.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:l,rtcOfferConstraints:r,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:l,rtcOfferConstraints:r,extraHeaders:t.extraHeaders}),!0}},{key:"refer",value:function(e,t){var n=this;x.debug("refer()");var r=e;if(this._status!==P.STATUS_WAITING_FOR_ACK&&this._status!==P.STATUS_CONFIRMED)return!1;if(e=this._ua.normalizeTarget(e),!e)throw new TypeError("Invalid target: ".concat(r));var l=new N(this);l.sendRefer(e,t);var i=l.id;return this._referSubscribers[i]=l,l.on("requestFailed",(function(){delete n._referSubscribers[i]})),l.on("accepted",(function(){delete n._referSubscribers[i]})),l.on("failed",(function(){delete n._referSubscribers[i]})),l}},{key:"sendRequest",value:function(e,t){return x.debug("sendRequest()"),this._dialog.sendRequest(e,t)}},{key:"receiveRequest",value:function(e){var t=this;if(x.debug("receiveRequest()"),e.method===T.CANCEL)this._status!==P.STATUS_WAITING_FOR_ANSWER&&this._status!==P.STATUS_ANSWERED||(this._status=P.STATUS_CANCELED,this._request.reply(487),this._failed("remote",e,T.causes.CANCELED));else switch(e.method){case T.ACK:if(this._status!==P.STATUS_WAITING_FOR_ACK)return;if(this._status=P.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!e.body){this.terminate({cause:T.causes.MISSING_SDP,status_code:400});break}var n={originator:"remote",type:"answer",sdp:e.body};x.debug('emit "sdp"'),this.emit("sdp",n);var r=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then((function(){return t._connection.setRemoteDescription(r)})).then((function(){t._is_confirmed||t._confirmed("remote",e)}))["catch"]((function(e){t.terminate({cause:T.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),x.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)}))}else this._is_confirmed||this._confirmed("remote",e);break;case T.BYE:this._status===P.STATUS_CONFIRMED||this._status===P.STATUS_WAITING_FOR_ACK?(e.reply(200),this._ended("remote",e,T.causes.BYE)):this._status===P.STATUS_INVITE_RECEIVED||this._status===P.STATUS_WAITING_FOR_ANSWER?(e.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",e,T.causes.BYE)):e.reply(403,"Wrong Status");break;case T.INVITE:this._status===P.STATUS_CONFIRMED?e.hasHeader("replaces")?this._receiveReplaces(e):this._receiveReinvite(e):e.reply(403,"Wrong Status");break;case T.INFO:if(this._status===P.STATUS_1XX_RECEIVED||this._status===P.STATUS_WAITING_FOR_ANSWER||this._status===P.STATUS_ANSWERED||this._status===P.STATUS_WAITING_FOR_ACK||this._status===P.STATUS_CONFIRMED){var l=e.hasHeader("Content-Type")?e.getHeader("Content-Type").toLowerCase():void 0;l&&l.match(/^application\/dtmf-relay/i)?new I(this).init_incoming(e):void 0!==l?new O(this).init_incoming(e):e.reply(415)}else e.reply(403,"Wrong Status");break;case T.UPDATE:this._status===P.STATUS_CONFIRMED?this._receiveUpdate(e):e.reply(403,"Wrong Status");break;case T.REFER:this._status===P.STATUS_CONFIRMED?this._receiveRefer(e):e.reply(403,"Wrong Status");break;case T.NOTIFY:this._status===P.STATUS_CONFIRMED?this._receiveNotify(e):e.reply(403,"Wrong Status");break;default:e.reply(501)}}},{key:"onTransportError",value:function(){x.warn("onTransportError()"),this._status!==P.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:T.causes.CONNECTION_ERROR,cause:T.causes.CONNECTION_ERROR})}},{key:"onRequestTimeout",value:function(){x.warn("onRequestTimeout()"),this._status!==P.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:T.causes.REQUEST_TIMEOUT,cause:T.causes.REQUEST_TIMEOUT})}},{key:"onDialogError",value:function(){x.warn("onDialogError()"),this._status!==P.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:T.causes.DIALOG_ERROR,cause:T.causes.DIALOG_ERROR})}},{key:"newDTMF",value:function(e){x.debug("newDTMF()"),this.emit("newDTMF",e)}},{key:"newInfo",value:function(e){x.debug("newInfo()"),this.emit("newInfo",e)}},{key:"_isReadyToReOffer",value:function(){return this._rtcReady?this._dialog?!0!==this._dialog.uac_pending_reply&&!0!==this._dialog.uas_pending_reply||(x.debug("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):(x.debug("_isReadyToReOffer() | session not established yet"),!1):(x.debug("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}},{key:"_close",value:function(){if(x.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(x.debug("close() | closing local MediaStream"),S.closeMediaStream(this._localMediaStream)),this._status!==P.STATUS_TERMINATED){if(this._status=P.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(r){x.warn("close() | error closing the RTCPeerConnection: %o",r)}for(var e in this._timers)Object.prototype.hasOwnProperty.call(this._timers,e)&&clearTimeout(this._timers[e]);for(var t in clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog),this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,t)&&(this._earlyDialogs[t].terminate(),delete this._earlyDialogs[t]);for(var n in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,n)&&delete this._referSubscribers[n];this._ua.destroyRTCSession(this)}}},{key:"_setInvite2xxTimer",value:function(e,t){var n=E.T1;function r(){this._status===P.STATUS_WAITING_FOR_ACK&&(e.reply(200,null,["Contact: ".concat(this._contact)],t),nE.T2&&(n=E.T2)),this._timers.invite2xxTimer=setTimeout(r.bind(this),n))}this._timers.invite2xxTimer=setTimeout(r.bind(this),n)}},{key:"_setACKTimer",value:function(){var e=this;this._timers.ackTimer=setTimeout((function(){e._status===P.STATUS_WAITING_FOR_ACK&&(x.debug("no ACK received, terminating the session"),clearTimeout(e._timers.invite2xxTimer),e.sendRequest(T.BYE),e._ended("remote",null,T.causes.NO_ACK))}),E.TIMER_H)}},{key:"_createRTCConnection",value:function(e,t){var n=this;this._connection=new RTCPeerConnection(e,t),this._connection.addEventListener("iceconnectionstatechange",(function(){var e=n._connection.iceConnectionState;"failed"===e&&n.terminate({cause:T.causes.RTP_TIMEOUT,status_code:408,reason_phrase:T.causes.RTP_TIMEOUT})})),x.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}},{key:"_createLocalDescription",value:function(e,t){var n=this;if(x.debug("createLocalDescription()"),"offer"!==e&&"answer"!==e)throw new Error('createLocalDescription() | invalid type "'.concat(e,'"'));var r=this._connection;return this._rtcReady=!1,Promise.resolve().then((function(){return"offer"===e?r.createOffer(t)["catch"]((function(e){return x.warn('emit "peerconnection:createofferfailed" [error:%o]',e),n.emit("peerconnection:createofferfailed",e),Promise.reject(e)})):r.createAnswer(t)["catch"]((function(e){return x.warn('emit "peerconnection:createanswerfailed" [error:%o]',e),n.emit("peerconnection:createanswerfailed",e),Promise.reject(e)}))})).then((function(e){return r.setLocalDescription(e)["catch"]((function(e){return n._rtcReady=!0,x.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',e),n.emit("peerconnection:setlocaldescriptionfailed",e),Promise.reject(e)}))})).then((function(){var l=t&&t.iceRestart;if("complete"===r.iceGatheringState&&!l||"gathering"===r.iceGatheringState&&n._iceReady){n._rtcReady=!0;var i={originator:"local",type:e,sdp:r.localDescription.sdp};return x.debug('emit "sdp"'),n.emit("sdp",i),Promise.resolve(i.sdp)}return new Promise((function(t){var l,i,s=!1;n._iceReady=!1;var o=function(){if(!s){r.removeEventListener("icecandidate",l),r.removeEventListener("icegatheringstatechange",i),s=!0,n._rtcReady=!0,n._iceReady=!0;var o={originator:"local",type:e,sdp:r.localDescription.sdp};x.debug('emit "sdp"'),n.emit("sdp",o),t(o.sdp)}};r.addEventListener("icecandidate",l=function(e){var t=e.candidate;t?n.emit("icecandidate",{candidate:t,ready:o}):o()}),r.addEventListener("icegatheringstatechange",i=function(){"complete"===r.iceGatheringState&&o()})}))}))}},{key:"_createDialog",value:function(e,t,n){var r="UAS"===t?e.to_tag:e.from_tag,l="UAS"===t?e.from_tag:e.to_tag,i=e.call_id+r+l,s=this._earlyDialogs[i];if(n)return!!s||(s=new w(this,e,t,w.C.STATUS_EARLY),s.error?(x.debug(s.error),this._failed("remote",e,T.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[i]=s,!0));if(this._from_tag=e.from_tag,this._to_tag=e.to_tag,s)return s.update(e,t),this._dialog=s,delete this._earlyDialogs[i],!0;var o=new w(this,e,t);return o.error?(x.debug(o.error),this._failed("remote",e,T.causes.INTERNAL_ERROR),!1):(this._dialog=o,!0)}},{key:"_receiveReinvite",value:function(e){var t=this;x.debug("receiveReinvite()");var n=e.hasHeader("Content-Type")?e.getHeader("Content-Type").toLowerCase():void 0,r={request:e,callback:void 0,reject:i.bind(this)},l=!1;function i(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l=!0;var n=t.status_code||403,r=t.reason_phrase||"",i=S.cloneArray(t.extraHeaders);if(this._status!==P.STATUS_CONFIRMED)return!1;if(n<300||n>=700)throw new TypeError("Invalid status_code: ".concat(n));e.reply(n,r,i)}if(this.emit("reinvite",r),!l){if(this._late_sdp=!1,!e.body)return this._late_sdp=!0,this._remoteHold&&(this._remoteHold=!1,this._onunhold("remote")),void(this._connectionPromiseQueue=this._connectionPromiseQueue.then((function(){return t._createLocalDescription("offer",t._rtcOfferConstraints)})).then((function(e){s.call(t,e)}))["catch"]((function(){e.reply(500)})));if("application/sdp"!==n)return x.debug("invalid Content-Type"),void e.reply(415);this._processInDialogSdpOffer(e).then((function(e){t._status!==P.STATUS_TERMINATED&&s.call(t,e)}))["catch"]((function(e){x.warn(e)}))}function s(t){var n=this,l=["Contact: ".concat(this._contact)];this._handleSessionTimersInIncomingRequest(e,l),this._late_sdp&&(t=this._mangleOffer(t)),e.reply(200,null,l,t,(function(){n._status=P.STATUS_WAITING_FOR_ACK,n._setInvite2xxTimer(e,t),n._setACKTimer()})),"function"===typeof r.callback&&r.callback()}}},{key:"_receiveUpdate",value:function(e){var t=this;x.debug("receiveUpdate()");var n=e.hasHeader("Content-Type")?e.getHeader("Content-Type").toLowerCase():void 0,r={request:e,callback:void 0,reject:i.bind(this)},l=!1;function i(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l=!0;var n=t.status_code||403,r=t.reason_phrase||"",i=S.cloneArray(t.extraHeaders);if(this._status!==P.STATUS_CONFIRMED)return!1;if(n<300||n>=700)throw new TypeError("Invalid status_code: ".concat(n));e.reply(n,r,i)}if(this.emit("update",r),!l)if(e.body){if("application/sdp"!==n)return x.debug("invalid Content-Type"),void e.reply(415);this._processInDialogSdpOffer(e).then((function(e){t._status!==P.STATUS_TERMINATED&&s.call(t,e)}))["catch"]((function(e){x.warn(e)}))}else s.call(this,null);function s(t){var n=["Contact: ".concat(this._contact)];this._handleSessionTimersInIncomingRequest(e,n),e.reply(200,null,n,t),"function"===typeof r.callback&&r.callback()}}},{key:"_processInDialogSdpOffer",value:function(e){var t=this;x.debug("_processInDialogSdpOffer()");var n,r=e.parseSDP(),i=!1,s=l(r.media);try{for(s.s();!(n=s.n()).done;){var o=n.value;if(-1!==U.indexOf(o.type)){var u=o.direction||r.direction||"sendrecv";if("sendonly"!==u&&"inactive"!==u){i=!1;break}i=!0}}}catch(h){s.e(h)}finally{s.f()}var a={originator:"remote",type:"offer",sdp:e.body};x.debug('emit "sdp"'),this.emit("sdp",a);var c=new RTCSessionDescription({type:"offer",sdp:a.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then((function(){if(t._status===P.STATUS_TERMINATED)throw new Error("terminated");return t._connection.setRemoteDescription(c)["catch"]((function(n){throw e.reply(488),x.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',n),t.emit("peerconnection:setremotedescriptionfailed",n),n}))})).then((function(){if(t._status===P.STATUS_TERMINATED)throw new Error("terminated");!0===t._remoteHold&&!1===i?(t._remoteHold=!1,t._onunhold("remote")):!1===t._remoteHold&&!0===i&&(t._remoteHold=!0,t._onhold("remote"))})).then((function(){if(t._status===P.STATUS_TERMINATED)throw new Error("terminated");return t._createLocalDescription("answer",t._rtcAnswerConstraints)["catch"]((function(t){throw e.reply(500),x.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',t),t}))}))["catch"]((function(e){x.warn("_processInDialogSdpOffer() failed [error: %o]",e)})),this._connectionPromiseQueue}},{key:"_receiveRefer",value:function(e){var t=this;if(x.debug("receiveRefer()"),!e.refer_to)return x.debug("no Refer-To header field present in REFER"),void e.reply(400);if(e.refer_to.uri.scheme!==T.SIP)return x.debug("Refer-To header field points to a non-SIP URI scheme"),void e.reply(416);e.reply(202);var r=new k(this,e.cseq);function l(t){var l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(t="function"===typeof t?t:null,this._status!==P.STATUS_WAITING_FOR_ACK&&this._status!==P.STATUS_CONFIRMED)return!1;var i=new n(this._ua);if(i.on("progress",(function(e){var t=e.response;r.notify(t.status_code,t.reason_phrase)})),i.on("accepted",(function(e){var t=e.response;r.notify(t.status_code,t.reason_phrase)})),i.on("_failed",(function(e){var t=e.message,n=e.cause;t?r.notify(t.status_code,t.reason_phrase):r.notify(487,n)})),e.refer_to.uri.hasHeader("replaces")){var s=decodeURIComponent(e.refer_to.uri.getHeader("replaces"));l.extraHeaders=S.cloneArray(l.extraHeaders),l.extraHeaders.push("Replaces: ".concat(s))}i.connect(e.refer_to.uri.toAor(),l,t)}function i(){r.notify(603)}x.debug('emit "refer"'),this.emit("refer",{request:e,accept:function(e,n){l.call(t,e,n)},reject:function(){i.call(t)}})}},{key:"_receiveNotify",value:function(e){switch(x.debug("receiveNotify()"),e.event||e.reply(400),e.event.event){case"refer":var t,n;if(e.event.params&&e.event.params.id)t=e.event.params.id,n=this._referSubscribers[t];else{if(1!==Object.keys(this._referSubscribers).length)return void e.reply(400,"Missing event id parameter");n=this._referSubscribers[Object.keys(this._referSubscribers)[0]]}if(!n)return void e.reply(481,"Subscription does not exist");n.receiveNotify(e),e.reply(200);break;default:e.reply(489)}}},{key:"_receiveReplaces",value:function(e){var t=this;function r(t){var r=this;if(this._status!==P.STATUS_WAITING_FOR_ACK&&this._status!==P.STATUS_CONFIRMED)return!1;var l=new n(this._ua);l.on("confirmed",(function(){r.terminate()})),l.init_incoming(e,t)}function l(){x.debug("Replaced INVITE rejected by the user"),e.reply(486)}x.debug("receiveReplaces()"),this.emit("replaces",{request:e,accept:function(e){r.call(t,e)},reject:function(){l.call(t)}})}},{key:"_sendInitialRequest",value:function(e,t,n){var r=this,l=new R(this._ua,this._request,{onRequestTimeout:function(){r.onRequestTimeout()},onTransportError:function(){r.onTransportError()},onAuthenticated:function(e){r._request=e},onReceiveResponse:function(e){r._receiveInviteResponse(e)}});Promise.resolve().then((function(){return n||(e.audio||e.video?(r._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(e)["catch"]((function(e){if(r._status===P.STATUS_TERMINATED)throw new Error("terminated");throw r._failed("local",null,T.causes.USER_DENIED_MEDIA_ACCESS),x.warn('emit "getusermediafailed" [error:%o]',e),r.emit("getusermediafailed",e),e}))):void 0)})).then((function(e){if(r._status===P.STATUS_TERMINATED)throw new Error("terminated");return r._localMediaStream=e,e&&e.getTracks().forEach((function(t){r._connection.addTrack(t,e)})),r._connecting(r._request),r._createLocalDescription("offer",t)["catch"]((function(e){throw r._failed("local",null,T.causes.WEBRTC_ERROR),e}))})).then((function(e){if(r._is_canceled||r._status===P.STATUS_TERMINATED)throw new Error("terminated");r._request.body=e,r._status=P.STATUS_INVITE_SENT,x.debug('emit "sending" [request:%o]',r._request),r.emit("sending",{request:r._request}),l.send()}))["catch"]((function(e){r._status!==P.STATUS_TERMINATED&&x.warn(e)}))}},{key:"_getDTMFRTPSender",value:function(){var e=this._connection.getSenders().find((function(e){return e.track&&"audio"===e.track.kind}));if(e&&e.dtmf)return e.dtmf;x.warn("sendDTMF() | no local audio track to send DTMF with")}},{key:"_receiveInviteResponse",value:function(e){var t=this;if(x.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(T.ACK);var n=new w(this,e,"UAC");return void 0!==n.error?void x.debug(n.error):(this.sendRequest(T.ACK),void this.sendRequest(T.BYE))}if(this._is_canceled)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);else if(this._status===P.STATUS_INVITE_SENT||this._status===P.STATUS_1XX_RECEIVED)switch(!0){case/^100$/.test(e.status_code):this._status=P.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(e.status_code):if(!e.to_tag){x.debug("1xx response received without to tag");break}if(e.hasHeader("contact")&&!this._createDialog(e,"UAC",!0))break;if(this._status=P.STATUS_1XX_RECEIVED,!e.body){this._progress("remote",e);break}var r={originator:"remote",type:"answer",sdp:e.body};x.debug('emit "sdp"'),this.emit("sdp",r);var l=new RTCSessionDescription({type:"answer",sdp:r.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then((function(){return t._connection.setRemoteDescription(l)})).then((function(){return t._progress("remote",e)}))["catch"]((function(e){x.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)}));break;case/^2[0-9]{2}$/.test(e.status_code):if(this._status=P.STATUS_CONFIRMED,!e.body){this._acceptAndTerminate(e,400,T.causes.MISSING_SDP),this._failed("remote",e,T.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(e,"UAC"))break;var i={originator:"remote",type:"answer",sdp:e.body};x.debug('emit "sdp"'),this.emit("sdp",i);var s=new RTCSessionDescription({type:"answer",sdp:i.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then((function(){if("stable"===t._connection.signalingState)return t._connection.createOffer(t._rtcOfferConstraints).then((function(e){return t._connection.setLocalDescription(e)}))["catch"]((function(n){t._acceptAndTerminate(e,500,n.toString()),t._failed("local",e,T.causes.WEBRTC_ERROR)}))})).then((function(){t._connection.setRemoteDescription(s).then((function(){t._handleSessionTimersInIncomingResponse(e),t._accepted("remote",e),t.sendRequest(T.ACK),t._confirmed("local",null)}))["catch"]((function(n){t._acceptAndTerminate(e,488,"Not Acceptable Here"),t._failed("remote",e,T.causes.BAD_MEDIA_DESCRIPTION),x.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',n),t.emit("peerconnection:setremotedescriptionfailed",n)}))}));break;default:var o=S.sipErrorCause(e.status_code);this._failed("remote",e,o)}}},{key:"_sendReinvite",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};x.debug("sendReinvite()");var n=S.cloneArray(t.extraHeaders),r=S.cloneObject(t.eventHandlers),l=t.rtcOfferConstraints||this._rtcOfferConstraints||null,i=!1;function s(e){var t=this;if(this._status!==P.STATUS_TERMINATED&&(this.sendRequest(T.ACK),!i))if(this._handleSessionTimersInIncomingResponse(e),e.body)if(e.hasHeader("Content-Type")&&"application/sdp"===e.getHeader("Content-Type").toLowerCase()){var n={originator:"remote",type:"answer",sdp:e.body};x.debug('emit "sdp"'),this.emit("sdp",n);var l=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then((function(){return t._connection.setRemoteDescription(l)})).then((function(){r.succeeded&&r.succeeded(e)}))["catch"]((function(e){o.call(t),x.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)}))}else o.call(this);else o.call(this)}function o(e){r.failed&&r.failed(e)}n.push("Contact: ".concat(this._contact)),n.push("Content-Type: application/sdp"),this._sessionTimers.running&&n.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(this._sessionTimers.refresher?"uac":"uas")),this._connectionPromiseQueue=this._connectionPromiseQueue.then((function(){return e._createLocalDescription("offer",l)})).then((function(t){t=e._mangleOffer(t);var r={originator:"local",type:"offer",sdp:t};x.debug('emit "sdp"'),e.emit("sdp",r),e.sendRequest(T.INVITE,{extraHeaders:n,body:t,eventHandlers:{onSuccessResponse:function(t){s.call(e,t),i=!0},onErrorResponse:function(t){o.call(e,t)},onTransportError:function(){e.onTransportError()},onRequestTimeout:function(){e.onRequestTimeout()},onDialogError:function(){e.onDialogError()}}})}))["catch"]((function(){o()}))}},{key:"_sendUpdate",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};x.debug("sendUpdate()");var n=S.cloneArray(t.extraHeaders),r=S.cloneObject(t.eventHandlers),l=t.rtcOfferConstraints||this._rtcOfferConstraints||null,i=t.sdpOffer||!1,s=!1;function o(e){var t=this;if(this._status!==P.STATUS_TERMINATED&&!s)if(this._handleSessionTimersInIncomingResponse(e),i){if(!e.body)return void u.call(this);if(!e.hasHeader("Content-Type")||"application/sdp"!==e.getHeader("Content-Type").toLowerCase())return void u.call(this);var n={originator:"remote",type:"answer",sdp:e.body};x.debug('emit "sdp"'),this.emit("sdp",n);var l=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then((function(){return t._connection.setRemoteDescription(l)})).then((function(){r.succeeded&&r.succeeded(e)}))["catch"]((function(e){u.call(t),x.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)}))}else r.succeeded&&r.succeeded(e)}function u(e){r.failed&&r.failed(e)}n.push("Contact: ".concat(this._contact)),this._sessionTimers.running&&n.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(this._sessionTimers.refresher?"uac":"uas")),i?(n.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then((function(){return e._createLocalDescription("offer",l)})).then((function(t){t=e._mangleOffer(t);var r={originator:"local",type:"offer",sdp:t};x.debug('emit "sdp"'),e.emit("sdp",r),e.sendRequest(T.UPDATE,{extraHeaders:n,body:t,eventHandlers:{onSuccessResponse:function(t){o.call(e,t),s=!0},onErrorResponse:function(t){u.call(e,t)},onTransportError:function(){e.onTransportError()},onRequestTimeout:function(){e.onRequestTimeout()},onDialogError:function(){e.onDialogError()}}})}))["catch"]((function(){u.call(e)}))):this.sendRequest(T.UPDATE,{extraHeaders:n,eventHandlers:{onSuccessResponse:function(t){o.call(e,t)},onErrorResponse:function(t){u.call(e,t)},onTransportError:function(){e.onTransportError()},onRequestTimeout:function(){e.onRequestTimeout()},onDialogError:function(){e.onDialogError()}}})}},{key:"_acceptAndTerminate",value:function(e,t,n){x.debug("acceptAndTerminate()");var r=[];t&&(n=n||T.REASON_PHRASE[t]||"",r.push("Reason: SIP ;cause=".concat(t,'; text="').concat(n,'"'))),(this._dialog||this._createDialog(e,"UAC"))&&(this.sendRequest(T.ACK),this.sendRequest(T.BYE,{extraHeaders:r})),this._status=P.STATUS_TERMINATED}},{key:"_mangleOffer",value:function(e){if(!this._localHold&&!this._remoteHold)return e;if(e=g.parse(e),this._localHold&&!this._remoteHold){x.debug("mangleOffer() | me on hold, mangling offer");var t,n=l(e.media);try{for(n.s();!(t=n.n()).done;){var r=t.value;-1!==U.indexOf(r.type)&&(r.direction?"sendrecv"===r.direction?r.direction="sendonly":"recvonly"===r.direction&&(r.direction="inactive"):r.direction="sendonly")}}catch(h){n.e(h)}finally{n.f()}}else if(this._localHold&&this._remoteHold){x.debug("mangleOffer() | both on hold, mangling offer");var i,s=l(e.media);try{for(s.s();!(i=s.n()).done;){var o=i.value;-1!==U.indexOf(o.type)&&(o.direction="inactive")}}catch(h){s.e(h)}finally{s.f()}}else if(this._remoteHold){x.debug("mangleOffer() | remote on hold, mangling offer");var u,a=l(e.media);try{for(a.s();!(u=a.n()).done;){var c=u.value;-1!==U.indexOf(c.type)&&(c.direction?"sendrecv"===c.direction?c.direction="recvonly":"recvonly"===c.direction&&(c.direction="inactive"):c.direction="recvonly")}}catch(h){a.e(h)}finally{a.f()}}return g.write(e)}},{key:"_setLocalMediaStatus",value:function(){var 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)}},{key:"_handleSessionTimersInIncomingRequest",value:function(e,t){var n;this._sessionTimers.enabled&&(e.session_expires&&e.session_expires>=T.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=e.session_expires,n=e.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,n="uas"),t.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(n)),this._sessionTimers.refresher="uas"===n,this._runSessionTimer())}},{key:"_handleSessionTimersInIncomingResponse",value:function(e){var t;this._sessionTimers.enabled&&(e.session_expires&&e.session_expires>=T.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())}},{key:"_runSessionTimer",value:function(){var e=this,t=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout((function(){e._status!==P.STATUS_TERMINATED&&e._isReadyToReOffer()&&(x.debug("runSessionTimer() | sending session refresh request"),e._sessionTimers.refreshMethod===T.UPDATE?e._sendUpdate():e._sendReinvite())}),500*t):this._sessionTimers.timer=setTimeout((function(){e._status!==P.STATUS_TERMINATED&&(x.warn("runSessionTimer() | timer expired, terminating the session"),e.terminate({cause:T.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))}),1100*t)}},{key:"_toggleMuteAudio",value:function(e){var t,n=this._connection.getSenders().filter((function(e){return e.track&&"audio"===e.track.kind})),r=l(n);try{for(r.s();!(t=r.n()).done;){var i=t.value;i.track.enabled=!e}}catch(s){r.e(s)}finally{r.f()}}},{key:"_toggleMuteVideo",value:function(e){var t,n=this._connection.getSenders().filter((function(e){return e.track&&"video"===e.track.kind})),r=l(n);try{for(r.s();!(t=r.n()).done;){var i=t.value;i.track.enabled=!e}}catch(s){r.e(s)}finally{r.f()}}},{key:"_newRTCSession",value:function(e,t){x.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:e,session:this,request:t})}},{key:"_connecting",value:function(e){x.debug("session connecting"),x.debug('emit "connecting"'),this.emit("connecting",{request:e})}},{key:"_progress",value:function(e,t){x.debug("session progress"),x.debug('emit "progress"'),this.emit("progress",{originator:e,response:t||null})}},{key:"_accepted",value:function(e,t){x.debug("session accepted"),this._start_time=new Date,x.debug('emit "accepted"'),this.emit("accepted",{originator:e,response:t||null})}},{key:"_confirmed",value:function(e,t){x.debug("session confirmed"),this._is_confirmed=!0,x.debug('emit "confirmed"'),this.emit("confirmed",{originator:e,ack:t||null})}},{key:"_ended",value:function(e,t,n){x.debug("session ended"),this._end_time=new Date,this._close(),x.debug('emit "ended"'),this.emit("ended",{originator:e,message:t||null,cause:n})}},{key:"_failed",value:function(e,t,n){x.debug("session failed"),x.debug('emit "_failed"'),this.emit("_failed",{originator:e,message:t||null,cause:n}),this._close(),x.debug('emit "failed"'),this.emit("failed",{originator:e,message:t||null,cause:n})}},{key:"_onhold",value:function(e){x.debug("session onhold"),this._setLocalMediaStatus(),x.debug('emit "hold"'),this.emit("hold",{originator:e})}},{key:"_onunhold",value:function(e){x.debug("session onunhold"),this._setLocalMediaStatus(),x.debug('emit "unhold"'),this.emit("unhold",{originator:e})}},{key:"_onmute",value:function(e){var t=e.audio,n=e.video;x.debug("session onmute"),this._setLocalMediaStatus(),x.debug('emit "muted"'),this.emit("muted",{audio:t,video:n})}},{key:"_onunmute",value:function(e){var t=e.audio,n=e.video;x.debug("session onunmute"),this._setLocalMediaStatus(),x.debug('emit "unmuted"'),this.emit("unmuted",{audio:t,video:n})}},{key:"C",get:function(){return P}},{key:"causes",get:function(){return T.causes}},{key:"id",get:function(){return this._id}},{key:"connection",get:function(){return this._connection}},{key:"contact",get:function(){return this._contact}},{key:"direction",get:function(){return this._direction}},{key:"local_identity",get:function(){return this._local_identity}},{key:"remote_identity",get:function(){return this._remote_identity}},{key:"start_time",get:function(){return this._start_time}},{key:"end_time",get:function(){return this._end_time}},{key:"data",get:function(){return this._data},set:function(e){this._data=e}},{key:"status",get:function(){return this._status}}]),n}(v)}}]);