forked from onsip/SIP.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsip-api.min.js
1 lines (1 loc) · 282 KB
/
sip-api.min.js
1
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.SIP=t():e.SIP=t()}(this,function(){return function(e){var t={};function r(i){if(t[i])return t[i].exports;var n=t[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(i,n,function(t){return e[t]}.bind(null,n));return i},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=111)}([function(e,t,r){"use strict";r.r(t),r.d(t,"__extends",function(){return n}),r.d(t,"__assign",function(){return s}),r.d(t,"__rest",function(){return o}),r.d(t,"__decorate",function(){return a}),r.d(t,"__param",function(){return c}),r.d(t,"__metadata",function(){return u}),r.d(t,"__awaiter",function(){return d}),r.d(t,"__generator",function(){return l}),r.d(t,"__exportStar",function(){return p}),r.d(t,"__values",function(){return h}),r.d(t,"__read",function(){return g}),r.d(t,"__spread",function(){return f}),r.d(t,"__spreadArrays",function(){return v}),r.d(t,"__await",function(){return m}),r.d(t,"__asyncGenerator",function(){return S}),r.d(t,"__asyncDelegator",function(){return y}),r.d(t,"__asyncValues",function(){return T}),r.d(t,"__makeTemplateObject",function(){return b}),r.d(t,"__importStar",function(){return E}),r.d(t,"__importDefault",function(){return _});var i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function n(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var s=function(){return(s=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function o(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(e);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(r[i[n]]=e[i[n]])}return r}function a(e,t,r,i){var n,s=arguments.length,o=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(s<3?n(o):s>3?n(t,r,o):n(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o}function c(e,t){return function(r,i){t(r,i,e)}}function u(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function d(e,t,r,i){return new(r||(r=Promise))(function(n,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){e.done?n(e.value):new r(function(t){t(e.value)}).then(o,a)}c((i=i.apply(e,t||[])).next())})}function l(e,t){var r,i,n,s,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,i&&(n=2&s[0]?i.return:s[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,s[1])).done)return n;switch(i=0,n&&(s=[2&s[0],n.value]),s[0]){case 0:case 1:n=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(n=(n=o.trys).length>0&&n[n.length-1])&&(6===s[0]||2===s[0])){o=0;continue}if(3===s[0]&&(!n||s[1]>n[0]&&s[1]<n[3])){o.label=s[1];break}if(6===s[0]&&o.label<n[1]){o.label=n[1],n=s;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(s);break}n[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],i=0}finally{r=n=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}}function p(e,t){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}function h(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}function g(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var i,n,s=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return o}function f(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(g(arguments[t]));return e}function v(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var i=Array(e),n=0;for(t=0;t<r;t++)for(var s=arguments[t],o=0,a=s.length;o<a;o++,n++)i[n]=s[o];return i}function m(e){return this instanceof m?(this.v=e,this):new m(e)}function S(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,n=r.apply(e,t||[]),s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(e){n[e]&&(i[e]=function(t){return new Promise(function(r,i){s.push([e,t,r,i])>1||a(e,t)})})}function a(e,t){try{(r=n[e](t)).value instanceof m?Promise.resolve(r.value.v).then(c,u):d(s[0][2],r)}catch(e){d(s[0][3],e)}var r}function c(e){a("next",e)}function u(e){a("throw",e)}function d(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function y(e){var t,r;return t={},i("next"),i("throw",function(e){throw e}),i("return"),t[Symbol.iterator]=function(){return this},t;function i(i,n){t[i]=e[i]?function(t){return(r=!r)?{value:m(e[i](t)),done:"return"===i}:n?n(t):t}:n}}function T(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=h(e),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(r){t[r]=e[r]&&function(t){return new Promise(function(i,n){(function(e,t,r,i){Promise.resolve(i).then(function(t){e({value:t,done:r})},t)})(i,n,(t=e[r](t)).done,t.value)})}}}function b(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function E(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function _(e){return e&&e.__esModule?e:{default:e}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0);i.__exportStar(r(22),t),i.__exportStar(r(35),t),i.__exportStar(r(67),t),i.__exportStar(r(68),t),i.__exportStar(r(69),t),i.__exportStar(r(35),t),i.__exportStar(r(25),t),i.__exportStar(r(13),t),i.__exportStar(r(23),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0);i.__exportStar(r(55),t),i.__exportStar(r(57),t),i.__exportStar(r(59),t),i.__exportStar(r(29),t),i.__exportStar(r(19),t),i.__exportStar(r(32),t),i.__exportStar(r(33),t),i.__exportStar(r(20),t),i.__exportStar(r(34),t),i.__exportStar(r(62),t),i.__exportStar(r(21),t),i.__exportStar(r(30),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(2),n=r(1),s=function(){function e(e,t,r,i){this.transactionConstructor=e,this.core=t,this.message=r,this.delegate=i,this.challenged=!1,this.stale=!1,this.logger=this.loggerFactory.getLogger("sip.user-agent-client"),this.init()}return e.prototype.dispose=function(){this.transaction.dispose()},Object.defineProperty(e.prototype,"loggerFactory",{get:function(){return this.core.loggerFactory},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"transaction",{get:function(){if(!this._transaction)throw new Error("Transaction undefined.");return this._transaction},enumerable:!0,configurable:!0}),e.prototype.cancel=function(t,r){var s=this;if(void 0===r&&(r={}),!this.transaction)throw new Error("Transaction undefined.");if(!this.message.to)throw new Error("To undefined.");if(!this.message.from)throw new Error("From undefined.");var o=this.core.makeOutgoingRequestMessage(i.C.CANCEL,this.message.ruri,this.message.from.uri,this.message.to.uri,{toTag:this.message.toTag,fromTag:this.message.fromTag,callId:this.message.callId,cseq:this.message.cseq},r.extraHeaders);if(o.branch=this.message.branch,this.message.headers.Route&&(o.headers.Route=this.message.headers.Route),t&&o.setHeader("Reason",t),this.transaction.state===n.TransactionState.Proceeding)new e(n.NonInviteClientTransaction,this.core,o);else this.transaction.once("stateChanged",function(){if(s.transaction&&s.transaction.state===n.TransactionState.Proceeding)new e(n.NonInviteClientTransaction,s.core,o)});return o},e.prototype.authenticationGuard=function(e){var t,r,i=e.statusCode;if(!i)throw new Error("Response status code undefined.");if(401!==i&&407!==i)return!0;if(401===i?(t=e.parseHeader("www-authenticate"),r="authorization"):(t=e.parseHeader("proxy-authenticate"),r="proxy-authorization"),!t)return this.logger.warn(i+" with wrong or missing challenge, cannot authenticate"),!0;if(this.challenged&&(this.stale||!0!==t.stale))return this.logger.warn(i+" apparently in authentication loop, cannot authenticate"),!0;if(!this.credentials&&(this.credentials=this.core.configuration.authenticationFactory(),!this.credentials))return this.logger.warn("Unable to obtain credentials, cannot authenticate"),!0;if(!this.credentials.authenticate(this.message,t))return!0;this.challenged=!0,t.stale&&(this.stale=!0);var n=this.message.cseq+=1;return this.message.setHeader("cseq",n+" "+this.message.method),this.message.setHeader(r,this.credentials.toString()),this.init(),!1},e.prototype.receiveResponse=function(e){if(this.authenticationGuard(e)){var t=e.statusCode?e.statusCode.toString():"";if(!t)throw new Error("Response status code undefined.");switch(!0){case/^100$/.test(t):this.delegate&&this.delegate.onTrying&&this.delegate.onTrying({message:e});break;case/^1[0-9]{2}$/.test(t):this.delegate&&this.delegate.onProgress&&this.delegate.onProgress({message:e});break;case/^2[0-9]{2}$/.test(t):this.delegate&&this.delegate.onAccept&&this.delegate.onAccept({message:e});break;case/^3[0-9]{2}$/.test(t):this.delegate&&this.delegate.onRedirect&&this.delegate.onRedirect({message:e});break;case/^[4-6][0-9]{2}$/.test(t):this.delegate&&this.delegate.onReject&&this.delegate.onReject({message:e});break;default:throw new Error("Invalid status code "+t)}}},e.prototype.init=function(){var e=this,t={loggerFactory:this.loggerFactory,onRequestTimeout:function(){return e.onRequestTimeout()},onStateChange:function(t){t===n.TransactionState.Terminated&&(e.core.userAgentClients.delete(i),r===e._transaction&&e.dispose())},onTransportError:function(t){return e.onTransportError(t)},receiveResponse:function(t){return e.receiveResponse(t)}},r=new this.transactionConstructor(this.message,this.core.transport,t);this._transaction=r;var i=r.id+r.request.method;this.core.userAgentClients.set(i,this)},e.prototype.onRequestTimeout=function(){this.logger.warn("User agent client request timed out. Generating internal 408 Request Timeout.");var e=new i.IncomingResponseMessage;e.statusCode=408,e.reasonPhrase="Request Timeout",this.receiveResponse(e)},e.prototype.onTransportError=function(e){this.logger.error(e.message),this.logger.error("User agent client request transport error. Generating internal 503 Service Unavailable.");var t=new i.IncomingResponseMessage;t.statusCode=503,t.reasonPhrase="Service Unavailable",this.receiveResponse(t)},e}();t.UserAgentClient=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(16),n=r(2),s=r(12),o=r(1),a=function(){function e(e,t,r,i){this.transactionConstructor=e,this.core=t,this.message=r,this.delegate=i,this.logger=this.loggerFactory.getLogger("sip.user-agent-server"),this.toTag=r.toTag?r.toTag:s.newTag(),this.init()}return e.prototype.dispose=function(){this.transaction.dispose()},Object.defineProperty(e.prototype,"loggerFactory",{get:function(){return this.core.loggerFactory},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"transaction",{get:function(){if(!this._transaction)throw new Error("Transaction undefined.");return this._transaction},enumerable:!0,configurable:!0}),e.prototype.accept=function(e){if(void 0===e&&(e={statusCode:200}),!this.acceptable)throw new i.TransactionStateError(this.message.method+" not acceptable in state "+this.transaction.state+".");var t=e.statusCode;if(t<200||t>299)throw new TypeError("Invalid statusCode: "+t);return this.reply(e)},e.prototype.progress=function(e){if(void 0===e&&(e={statusCode:180}),!this.progressable)throw new i.TransactionStateError(this.message.method+" not progressable in state "+this.transaction.state+".");var t=e.statusCode;if(t<101||t>199)throw new TypeError("Invalid statusCode: "+t);return this.reply(e)},e.prototype.redirect=function(e,t){if(void 0===t&&(t={statusCode:302}),!this.redirectable)throw new i.TransactionStateError(this.message.method+" not redirectable in state "+this.transaction.state+".");var r=t.statusCode;if(r<300||r>399)throw new TypeError("Invalid statusCode: "+r);var n=new Array;return e.forEach(function(e){return n.push("Contact: "+e.toString())}),t.extraHeaders=(t.extraHeaders||[]).concat(n),this.reply(t)},e.prototype.reject=function(e){if(void 0===e&&(e={statusCode:480}),!this.rejectable)throw new i.TransactionStateError(this.message.method+" not rejectable in state "+this.transaction.state+".");var t=e.statusCode;if(t<400||t>699)throw new TypeError("Invalid statusCode: "+t);return this.reply(e)},e.prototype.trying=function(e){if(!this.tryingable)throw new i.TransactionStateError(this.message.method+" not tryingable in state "+this.transaction.state+".");return this.reply({statusCode:100})},e.prototype.receiveCancel=function(e){this.delegate&&this.delegate.onCancel&&this.delegate.onCancel(e)},Object.defineProperty(e.prototype,"acceptable",{get:function(){if(this.transaction instanceof o.InviteServerTransaction)return this.transaction.state===o.TransactionState.Proceeding||this.transaction.state===o.TransactionState.Accepted;if(this.transaction instanceof o.NonInviteServerTransaction)return this.transaction.state===o.TransactionState.Trying||this.transaction.state===o.TransactionState.Proceeding;throw new Error("Unknown transaction type.")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"progressable",{get:function(){if(this.transaction instanceof o.InviteServerTransaction)return this.transaction.state===o.TransactionState.Proceeding;if(this.transaction instanceof o.NonInviteServerTransaction)return!1;throw new Error("Unknown transaction type.")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"redirectable",{get:function(){if(this.transaction instanceof o.InviteServerTransaction)return this.transaction.state===o.TransactionState.Proceeding;if(this.transaction instanceof o.NonInviteServerTransaction)return this.transaction.state===o.TransactionState.Trying||this.transaction.state===o.TransactionState.Proceeding;throw new Error("Unknown transaction type.")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rejectable",{get:function(){if(this.transaction instanceof o.InviteServerTransaction)return this.transaction.state===o.TransactionState.Proceeding;if(this.transaction instanceof o.NonInviteServerTransaction)return this.transaction.state===o.TransactionState.Trying||this.transaction.state===o.TransactionState.Proceeding;throw new Error("Unknown transaction type.")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"tryingable",{get:function(){if(this.transaction instanceof o.InviteServerTransaction)return this.transaction.state===o.TransactionState.Proceeding;if(this.transaction instanceof o.NonInviteServerTransaction)return this.transaction.state===o.TransactionState.Trying;throw new Error("Unknown transaction type.")},enumerable:!0,configurable:!0}),e.prototype.reply=function(e){e.toTag||100===e.statusCode||(e.toTag=this.toTag),e.userAgent=e.userAgent||this.core.configuration.userAgentHeaderFieldValue,e.supported=e.supported||this.core.configuration.supportedOptionTagsResponse;var t=n.constructOutgoingResponse(this.message,e);return this.transaction.receiveResponse(e.statusCode,t.message),t},e.prototype.init=function(){var e=this,t={loggerFactory:this.loggerFactory,onStateChange:function(t){t===o.TransactionState.Terminated&&(e.core.userAgentServers.delete(i),e.dispose())},onTransportError:function(t){e.logger.error(t.message),e.delegate&&e.delegate.onTransportError?e.delegate.onTransportError(t):e.logger.error("User agent server response transport error.")}},r=new this.transactionConstructor(this.message,this.core.transport,t);this._transaction=r;var i=r.id;this.core.userAgentServers.set(r.id,this)},e}();t.UserAgentServer=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0);i.__exportStar(r(17),t),i.__exportStar(r(16),t),i.__exportStar(r(71),t),i.__exportStar(r(2),t),i.__exportStar(r(15),t),i.__exportStar(r(27),t),i.__exportStar(r(1),t),i.__exportStar(r(73),t),i.__exportStar(r(50),t),i.__exportStar(r(6),t),i.__exportStar(r(85),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=500;t.Timers={T1:i,T2:4e3,T4:5e3,TIMER_B:32e3,TIMER_D:0,TIMER_F:32e3,TIMER_H:32e3,TIMER_I:0,TIMER_J:0,TIMER_K:0,TIMER_L:32e3,TIMER_M:32e3,TIMER_N:32e3,PROVISIONAL_RESPONSE_INTERVAL:6e4}},function(e,t,r){"use strict";var i,n="object"==typeof Reflect?Reflect:null,s=n&&"function"==typeof n.apply?n.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};i=n&&"function"==typeof n.ownKeys?n.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 a(){a.init.call(this)}e.exports=a,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var c=10;function u(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function d(e,t,r,i){var n,s,o,a;if("function"!=typeof r)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r);if(void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]),void 0===o)o=s[t]=r,++e._eventsCount;else if("function"==typeof o?o=s[t]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),(n=u(e))>0&&o.length>n&&!o.warned){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=o.length,a=c,console&&console.warn&&console.warn(a)}return e}function l(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},n=function(){for(var e=[],t=0;t<arguments.length;t++)e.push(arguments[t]);this.fired||(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,s(this.listener,this.target,e))}.bind(i);return n.listener=r,i.wrapFn=n,n}function p(e,t,r){var i=e._events;if(void 0===i)return[];var n=i[t];return void 0===n?[]:"function"==typeof n?r?[n.listener||n]:[n]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(n):g(n,n.length)}function h(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function g(e,t){for(var r=new Array(t),i=0;i<t;++i)r[i]=e[i];return r}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");c=e}}),a.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},a.prototype.getMaxListeners=function(){return u(this)},a.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i="error"===e,n=this._events;if(void 0!==n)i=i&&void 0===n.error;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=n[e];if(void 0===c)return!1;if("function"==typeof c)s(c,this,t);else{var u=c.length,d=g(c,u);for(r=0;r<u;++r)s(d[r],this,t)}return!0},a.prototype.addListener=function(e,t){return d(this,e,t,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(e,t){return d(this,e,t,!0)},a.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.on(e,l(this,e,t)),this},a.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.prependListener(e,l(this,e,t)),this},a.prototype.removeListener=function(e,t){var r,i,n,s,o;if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);if(void 0===(i=this._events))return this;if(void 0===(r=i[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(n=-1,s=r.length-1;s>=0;s--)if(r[s]===t||r[s].listener===t){o=r[s].listener,n=s;break}if(n<0)return this;0===n?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,n),1===r.length&&(i[e]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",e,o||t)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(e){var t,r,i;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var n,s=Object.keys(r);for(i=0;i<s.length;++i)"removeListener"!==(n=s[i])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},a.prototype.listeners=function(e){return p(this,e,!0)},a.prototype.rawListeners=function(e){return p(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},a.prototype.listenerCount=h,a.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.STATUS_EARLY=1]="STATUS_EARLY",e[e.STATUS_CONFIRMED=2]="STATUS_CONFIRMED"}(t.DialogStatus||(t.DialogStatus={})),function(e){e[e.STATUS_NULL=0]="STATUS_NULL",e[e.STATUS_INVITE_SENT=1]="STATUS_INVITE_SENT",e[e.STATUS_1XX_RECEIVED=2]="STATUS_1XX_RECEIVED",e[e.STATUS_INVITE_RECEIVED=3]="STATUS_INVITE_RECEIVED",e[e.STATUS_WAITING_FOR_ANSWER=4]="STATUS_WAITING_FOR_ANSWER",e[e.STATUS_ANSWERED=5]="STATUS_ANSWERED",e[e.STATUS_WAITING_FOR_PRACK=6]="STATUS_WAITING_FOR_PRACK",e[e.STATUS_WAITING_FOR_ACK=7]="STATUS_WAITING_FOR_ACK",e[e.STATUS_CANCELED=8]="STATUS_CANCELED",e[e.STATUS_TERMINATED=9]="STATUS_TERMINATED",e[e.STATUS_ANSWERED_WAITING_FOR_PRACK=10]="STATUS_ANSWERED_WAITING_FOR_PRACK",e[e.STATUS_EARLY_MEDIA=11]="STATUS_EARLY_MEDIA",e[e.STATUS_CONFIRMED=12]="STATUS_CONFIRMED"}(t.SessionStatus||(t.SessionStatus={})),function(e){e[e.ClientContext=0]="ClientContext",e[e.ConfigurationError=1]="ConfigurationError",e[e.Dialog=2]="Dialog",e[e.DigestAuthentication=3]="DigestAuthentication",e[e.DTMF=4]="DTMF",e[e.IncomingMessage=5]="IncomingMessage",e[e.IncomingRequest=6]="IncomingRequest",e[e.IncomingResponse=7]="IncomingResponse",e[e.InvalidStateError=8]="InvalidStateError",e[e.InviteClientContext=9]="InviteClientContext",e[e.InviteServerContext=10]="InviteServerContext",e[e.Logger=11]="Logger",e[e.LoggerFactory=12]="LoggerFactory",e[e.MethodParameterError=13]="MethodParameterError",e[e.NameAddrHeader=14]="NameAddrHeader",e[e.NotSupportedError=15]="NotSupportedError",e[e.OutgoingRequest=16]="OutgoingRequest",e[e.Parameters=17]="Parameters",e[e.PublishContext=18]="PublishContext",e[e.ReferClientContext=19]="ReferClientContext",e[e.ReferServerContext=20]="ReferServerContext",e[e.RegisterContext=21]="RegisterContext",e[e.RenegotiationError=22]="RenegotiationError",e[e.RequestSender=23]="RequestSender",e[e.ServerContext=24]="ServerContext",e[e.Session=25]="Session",e[e.SessionDescriptionHandler=26]="SessionDescriptionHandler",e[e.SessionDescriptionHandlerError=27]="SessionDescriptionHandlerError",e[e.SessionDescriptionHandlerObserver=28]="SessionDescriptionHandlerObserver",e[e.Subscription=29]="Subscription",e[e.Transport=30]="Transport",e[e.UA=31]="UA",e[e.URI=32]="URI"}(t.TypeStrings||(t.TypeStrings={})),function(e){e[e.STATUS_INIT=0]="STATUS_INIT",e[e.STATUS_STARTING=1]="STATUS_STARTING",e[e.STATUS_READY=2]="STATUS_READY",e[e.STATUS_USER_CLOSED=3]="STATUS_USER_CLOSED",e[e.STATUS_NOT_READY=4]="STATUS_NOT_READY"}(t.UAStatus||(t.UAStatus={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(10),n=r(29),s=r(30);!function(e){e.defer=function(){var e={};return e.promise=new Promise(function(t,r){e.resolve=t,e.reject=r}),e},e.reducePromises=function(e,t){return e.reduce(function(e,t){return e=e.then(t)},Promise.resolve(t))},e.str_utf8_length=function(e){return encodeURIComponent(e).replace(/%[A-F\d]{2}/g,"U").length},e.generateFakeSDP=function(e){if(e){var t=e.indexOf("o="),r=e.indexOf("\r\n",t);return"v=0\r\n"+e.slice(t,r)+"\r\ns=-\r\nt=0 0\r\nc=IN IP4 0.0.0.0"}},e.isDecimal=function(e){var t=parseInt(e,10);return!isNaN(t)&&parseFloat(e)===t},e.createRandomToken=function(e,t){void 0===t&&(t=32);for(var r="",i=0;i<e;i++)r+=Math.floor(Math.random()*t).toString(t);return r},e.newTag=function(){return e.createRandomToken(10)},e.newUUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=Math.floor(16*Math.random());return("x"===e?t:t%4+8).toString(16)})},e.normalizeTarget=function(t,r){if(t){if(t instanceof s.URI)return t;if("string"==typeof t){var o=t.split("@"),a=void 0,c=void 0;switch(o.length){case 1:if(!r)return;a=t,c=r;break;case 2:a=o[0],c=o[1];break;default:a=o.slice(0,o.length-1).join("@"),c=o[o.length-1]}return a=a.replace(/^(sips?|tel):/i,""),/^[\-\.\(\)]*\+?[0-9\-\.\(\)]+$/.test(a)&&(a=a.replace(/[\-\.\(\)]/g,"")),t=i.C.SIP+":"+e.escapeUser(a)+"@"+c,n.Grammar.URIParse(t)}}},e.escapeUser=function(e){return encodeURIComponent(decodeURIComponent(e)).replace(/%3A/gi,":").replace(/%2B/gi,"+").replace(/%3F/gi,"?").replace(/%2F/gi,"/")},e.headerize=function(e){for(var t={"Call-Id":"Call-ID",Cseq:"CSeq","Min-Se":"Min-SE",Rack:"RAck",Rseq:"RSeq","Www-Authenticate":"WWW-Authenticate"},r=e.toLowerCase().replace(/_/g,"-").split("-"),i=r.length,n="",s=0;s<i;s++)0!==s&&(n+="-"),n+=r[s].charAt(0).toUpperCase()+r[s].substring(1);return t[n]&&(n=t[n]),n},e.sipErrorCause=function(e){for(var t in i.C.SIP_ERROR_CAUSES)if(-1!==i.C.SIP_ERROR_CAUSES[t].indexOf(e))return i.C.causes[t];return i.C.causes.SIP_FAILURE_CODE},e.getReasonPhrase=function(e,t){return t||i.C.REASON_PHRASE[e]||""},e.getReasonHeaderValue=function(t,r){return"SIP;cause="+t+';text="'+(r=e.getReasonPhrase(t,r))+'"'},e.getCancelReason=function(t,r){if(t&&t<200||t>699)throw new TypeError("Invalid statusCode: "+t);if(t)return e.getReasonHeaderValue(t,r)},e.buildStatusLine=function(t,r){if(!t||t<100||t>699)throw new TypeError("Invalid statusCode: "+t);if(r&&"string"!=typeof r&&!(r instanceof String))throw new TypeError("Invalid reason: "+r);return"SIP/2.0 "+t+" "+(r=e.getReasonPhrase(t,r))+"\r\n"},e.fromBodyObj=function(e){var t=e.body,r=e.contentType;return{contentDisposition:function(e){return"application/sdp"===e?"session":"render"}(r),contentType:r,content:t}},e.toBodyObj=function(e){return{body:e.content,contentType:e.contentType}}}(t.Utils||(t.Utils={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e.version="0.15.3",e.USER_AGENT="SIP.js/0.15.3",e.SIP="sip",e.SIPS="sips",function(e){e.CONNECTION_ERROR="Connection Error",e.INTERNAL_ERROR="Internal Error",e.REQUEST_TIMEOUT="Request Timeout",e.SIP_FAILURE_CODE="SIP Failure Code",e.ADDRESS_INCOMPLETE="Address Incomplete",e.AUTHENTICATION_ERROR="Authentication Error",e.BUSY="Busy",e.DIALOG_ERROR="Dialog Error",e.INCOMPATIBLE_SDP="Incompatible SDP",e.NOT_FOUND="Not Found",e.REDIRECTED="Redirected",e.REJECTED="Rejected",e.UNAVAILABLE="Unavailable",e.BAD_MEDIA_DESCRIPTION="Bad Media Description",e.CANCELED="Canceled",e.EXPIRES="Expires",e.NO_ACK="No ACK",e.NO_ANSWER="No Answer",e.NO_PRACK="No PRACK",e.RTP_TIMEOUT="RTP Timeout",e.USER_DENIED_MEDIA_ACCESS="User Denied Media Access",e.WEBRTC_ERROR="WebRTC Error",e.WEBRTC_NOT_SUPPORTED="WebRTC Not Supported"}(e.causes||(e.causes={})),function(e){e.REQUIRED="required",e.SUPPORTED="supported",e.UNSUPPORTED="none"}(e.supported||(e.supported={})),e.SIP_ERROR_CAUSES={ADDRESS_INCOMPLETE:[484],AUTHENTICATION_ERROR:[401,407],BUSY:[486,600],INCOMPATIBLE_SDP:[488,606],NOT_FOUND:[404,604],REDIRECTED:[300,301,302,305,380],REJECTED:[403,603],UNAVAILABLE:[480,410,408,430]},e.ACK="ACK",e.BYE="BYE",e.CANCEL="CANCEL",e.INFO="INFO",e.INVITE="INVITE",e.MESSAGE="MESSAGE",e.NOTIFY="NOTIFY",e.OPTIONS="OPTIONS",e.REGISTER="REGISTER",e.UPDATE="UPDATE",e.SUBSCRIBE="SUBSCRIBE",e.PUBLISH="PUBLISH",e.REFER="REFER",e.PRACK="PRACK",e.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",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:"Internal Server 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"},e.OPTION_TAGS={"100rel":!0,199:!0,answermode:!0,"early-session":!0,eventlist:!0,explicitsub:!0,"from-change":!0,"geolocation-http":!0,"geolocation-sip":!0,gin:!0,gruu:!0,histinfo:!0,ice:!0,join:!0,"multiple-refer":!0,norefersub:!0,nosub:!0,outbound:!0,path:!0,policy:!0,precondition:!0,pref:!0,privacy:!0,"recipient-list-invite":!0,"recipient-list-message":!0,"recipient-list-subscribe":!0,replaces:!0,"resource-priority":!0,"sdp-anat":!0,"sec-agree":!0,tdialog:!0,timer:!0,uui:!0},function(e){e.INFO="info",e.RTP="rtp"}(e.dtmfType||(e.dtmfType={}))}(t.C||(t.C={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(5),s=r(8);!function(e){var t=function(e){function t(){return e.call(this,"The session description handler has closed.")||this}return i.__extends(t,e),t}(n.Exception);e.ClosedSessionDescriptionHandlerError=t;var r=function(e){function t(){return e.call(this,"The session has terminated.")||this}return i.__extends(t,e),t}(n.Exception);e.TerminatedSessionError=r;var s=function(e){function t(t){return e.call(this,t||"Unsupported session description content type.")||this}return i.__extends(t,e),t}(n.Exception);e.UnsupportedSessionDescriptionContentTypeError=s}(t.Exceptions||(t.Exceptions={}));var o=function(e){function t(t,r,i){var n=e.call(this,i)||this;return n.code=t,n.name=r,n.message=i,n}return i.__extends(t,e),t}(n.Exception);!function(e){var t=function(e){function t(t,r){var i=e.call(this,1,"CONFIGURATION_ERROR",r?"Invalid value "+JSON.stringify(r)+" for parameter '"+t+"'":"Missing parameter: "+t)||this;return i.type=s.TypeStrings.ConfigurationError,i.parameter=t,i.value=r,i}return i.__extends(t,e),t}(o);e.ConfigurationError=t;var r=function(e){function t(t){var r=e.call(this,2,"INVALID_STATE_ERROR","Invalid status: "+t)||this;return r.type=s.TypeStrings.InvalidStateError,r.status=t,r}return i.__extends(t,e),t}(o);e.InvalidStateError=r;var n=function(e){function t(t){var r=e.call(this,3,"NOT_SUPPORTED_ERROR",t)||this;return r.type=s.TypeStrings.NotSupportedError,r}return i.__extends(t,e),t}(o);e.NotSupportedError=n;var a=function(e){function t(t){var r=e.call(this,5,"RENEGOTIATION_ERROR",t)||this;return r.type=s.TypeStrings.RenegotiationError,r}return i.__extends(t,e),t}(o);e.RenegotiationError=a;var c=function(e){function t(t,r,i){var n=e.call(this,6,"METHOD_PARAMETER_ERROR",i?"Invalid value "+JSON.stringify(i)+" for parameter '"+r+"'":"Missing parameter: "+r)||this;return n.type=s.TypeStrings.MethodParameterError,n.method=t,n.parameter=r,n.value=i,n}return i.__extends(t,e),t}(o);e.MethodParameterError=c;var u=function(e){function t(t,r,i){var n=e.call(this,8,"SESSION_DESCRIPTION_HANDLER_ERROR",i||"Error with Session Description Handler")||this;return n.type=s.TypeStrings.SessionDescriptionHandlerError,n.method=t,n.error=r,n}return i.__extends(t,e),t}(o);e.SessionDescriptionHandlerError=u}(t.Exceptions||(t.Exceptions={}))},function(e,t,r){"use strict";function i(e,t){void 0===t&&(t=32);for(var r="",i=0;i<e;i++){r+=Math.floor(Math.random()*t).toString(t)}return r}Object.defineProperty(t,"__esModule",{value:!0}),t.createRandomToken=i,t.getReasonPhrase=function(e){return n[e]||""},t.newTag=function(){return i(10)},t.headerize=function(e){for(var t={"Call-Id":"Call-ID",Cseq:"CSeq","Min-Se":"Min-SE",Rack:"RAck",Rseq:"RSeq","Www-Authenticate":"WWW-Authenticate"},r=e.toLowerCase().replace(/_/g,"-").split("-"),i=r.length,n="",s=0;s<i;s++)0!==s&&(n+="-"),n+=r[s].charAt(0).toUpperCase()+r[s].substring(1);return t[n]&&(n=t[n]),n},t.str_utf8_length=function(e){return encodeURIComponent(e).replace(/%[A-F\d]{2}/g,"U").length};var n={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",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:"Internal Server 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"}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.Accepted="Accepted",e.Calling="Calling",e.Completed="Completed",e.Confirmed="Confirmed",e.Proceeding="Proceeding",e.Terminated="Terminated",e.Trying="Trying"}(t.TransactionState||(t.TransactionState={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(2);t.AllowedMethods=[i.C.ACK,i.C.BYE,i.C.CANCEL,i.C.INFO,i.C.INVITE,i.C.MESSAGE,i.C.NOTIFY,i.C.OPTIONS,i.C.PRACK,i.C.REFER,i.C.SUBSCRIBE]},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r(0).__exportStar(r(64),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0);i.__exportStar(r(24),t),i.__exportStar(r(65),t),i.__exportStar(r(66),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0);i.__exportStar(r(18),t),i.__exportStar(r(63),t),i.__exportStar(r(47),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(2),n=function(){function e(e,t){this.core=e,this.dialogState=t,this.core.dialogs.set(this.id,this)}return e.initialDialogStateForUserAgentClient=function(e,t){var r=t.getHeaders("record-route").reverse(),n=t.parseHeader("contact");if(!n)throw new Error("Contact undefined.");if(!(n instanceof i.NameAddrHeader))throw new Error("Contact not instance of NameAddrHeader.");var s=n.uri,o=e.cseq,a=e.callId,c=e.fromTag,u=t.toTag;if(!a)throw new Error("Call id undefined.");if(!c)throw new Error("From tag undefined.");if(!u)throw new Error("To tag undefined.");if(!e.from)throw new Error("From undefined.");if(!e.to)throw new Error("To undefined.");var d=e.from.uri,l=e.to.uri;if(!t.statusCode)throw new Error("Incoming response status code undefined.");return{id:a+c+u,early:t.statusCode<200,callId:a,localTag:c,remoteTag:u,localSequenceNumber:o,remoteSequenceNumber:void 0,localURI:d,remoteURI:l,remoteTarget:s,routeSet:r,secure:!1}},e.initialDialogStateForUserAgentServer=function(e,t,r){void 0===r&&(r=!1);var n=e.getHeaders("record-route"),s=e.parseHeader("contact");if(!s)throw new Error("Contact undefined.");if(!(s instanceof i.NameAddrHeader))throw new Error("Contact not instance of NameAddrHeader.");var o=s.uri,a=e.cseq,c=e.callId,u=t,d=e.fromTag,l=e.from.uri;return{id:c+u+d,early:r,callId:c,localTag:u,remoteTag:d,localSequenceNumber:void 0,remoteSequenceNumber:a,localURI:e.to.uri,remoteURI:l,remoteTarget:o,routeSet:n,secure:!1}},e.prototype.dispose=function(){this.core.dialogs.delete(this.id)},Object.defineProperty(e.prototype,"id",{get:function(){return this.dialogState.id},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"early",{get:function(){return this.dialogState.early},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"callId",{get:function(){return this.dialogState.callId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localTag",{get:function(){return this.dialogState.localTag},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"remoteTag",{get:function(){return this.dialogState.remoteTag},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localSequenceNumber",{get:function(){return this.dialogState.localSequenceNumber},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"remoteSequenceNumber",{get:function(){return this.dialogState.remoteSequenceNumber},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localURI",{get:function(){return this.dialogState.localURI},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"remoteURI",{get:function(){return this.dialogState.remoteURI},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"remoteTarget",{get:function(){return this.dialogState.remoteTarget},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"routeSet",{get:function(){return this.dialogState.routeSet},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"secure",{get:function(){return this.dialogState.secure},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"userAgentCore",{get:function(){return this.core},enumerable:!0,configurable:!0}),e.prototype.confirm=function(){this.dialogState.early=!1},e.prototype.receiveRequest=function(e){if(e.method!==i.C.ACK){if(this.remoteSequenceNumber){if(e.cseq<=this.remoteSequenceNumber)throw new Error("Out of sequence in dialog request. Did you forget to call sequenceGuard()?");this.dialogState.remoteSequenceNumber=e.cseq}this.remoteSequenceNumber||(this.dialogState.remoteSequenceNumber=e.cseq)}},e.prototype.recomputeRouteSet=function(e){this.dialogState.routeSet=e.getHeaders("record-route").reverse()},e.prototype.createOutgoingRequestMessage=function(e,t){var r,i=this.remoteURI,n=this.remoteTag,s=this.localURI,o=this.localTag,a=this.callId;r=t&&t.cseq?t.cseq:this.dialogState.localSequenceNumber?this.dialogState.localSequenceNumber+=1:this.dialogState.localSequenceNumber=1;var c=this.remoteTarget,u=this.routeSet,d=t&&t.extraHeaders,l=t&&t.body;return this.userAgentCore.makeOutgoingRequestMessage(e,c,s,i,{callId:a,cseq:r,fromTag:o,toTag:n,routeSet:u},d,l)},e.prototype.sequenceGuard=function(e){return e.method===i.C.ACK||(!(this.remoteSequenceNumber&&e.cseq<=this.remoteSequenceNumber)||(this.core.replyStateless(e,{statusCode:500}),!1))},e}();t.Dialog=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(29),n=r(12),s=function(){function e(){this.headers={}}return e.prototype.addHeader=function(e,t){var r={raw:t};e=n.headerize(e),this.headers[e]?this.headers[e].push(r):this.headers[e]=[r]},e.prototype.getHeader=function(e){var t=this.headers[n.headerize(e)];if(t)return t[0]?t[0].raw:void 0},e.prototype.getHeaders=function(e){var t=this.headers[n.headerize(e)],r=[];if(!t)return[];for(var i=0,s=t;i<s.length;i++){var o=s[i];r.push(o.raw)}return r},e.prototype.hasHeader=function(e){return!!this.headers[n.headerize(e)]},e.prototype.parseHeader=function(e,t){if(void 0===t&&(t=0),e=n.headerize(e),this.headers[e]&&!(t>=this.headers[e].length)){var r=this.headers[e][t],s=r.raw;if(r.parsed)return r.parsed;var o=i.Grammar.parse(s,e.replace(/-/g,"_"));return-1===o?void this.headers[e].splice(t,1):(r.parsed=o,o)}},e.prototype.s=function(e,t){return void 0===t&&(t=0),this.parseHeader(e,t)},e.prototype.setHeader=function(e,t){this.headers[n.headerize(e)]=[{raw:t}]},e.prototype.toString=function(){return this.data},e}();t.IncomingMessage=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=function(e){function t(t,r,i){var n=e.call(this,i)||this;return n.uri=t,n._displayName=r,n}return i.__extends(t,e),Object.defineProperty(t.prototype,"friendlyName",{get:function(){return this.displayName||this.uri.aor},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"displayName",{get:function(){return this._displayName},set:function(e){this._displayName=e},enumerable:!0,configurable:!0}),t.prototype.clone=function(){return new t(this.uri.clone(),this._displayName,JSON.parse(JSON.stringify(this.parameters)))},t.prototype.toString=function(){var e=this.displayName||"0"===this.displayName?'"'+this.displayName+'" ':"";for(var t in e+="<"+this.uri.toString()+">",this.parameters)this.parameters.hasOwnProperty(t)&&(e+=";"+t,null!==this.parameters[t]&&(e+="="+this.parameters[t]));return e},t}(r(21).Parameters);t.NameAddrHeader=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e){for(var t in this.parameters={},e)e.hasOwnProperty(t)&&this.setParam(t,e[t])}return e.prototype.setParam=function(e,t){e&&(this.parameters[e.toLowerCase()]=null==t?null:t.toString())},e.prototype.getParam=function(e){if(e)return this.parameters[e.toLowerCase()]},e.prototype.hasParam=function(e){return!!e&&!!this.parameters.hasOwnProperty(e.toLowerCase())},e.prototype.deleteParam=function(e){if(e=e.toLowerCase(),this.parameters.hasOwnProperty(e)){var t=this.parameters[e];return delete this.parameters[e],t}},e.prototype.clearParams=function(){this.parameters={}},e}();t.Parameters=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=function(e){function t(r,i,n,s,o){var a=e.call(this,i,n,t.makeId(r),s,o)||this;a._request=r,a.user=n;var c=i.server&&i.server.scheme?i.server.scheme:void 0;return r.setViaHeader(a.id,c),a}return i.__extends(t,e),t.makeId=function(e){if("CANCEL"===e.method){if(!e.branch)throw new Error("Outgoing CANCEL request without a branch.");return e.branch}return"z9hG4bK"+Math.floor(1e7*Math.random())},Object.defineProperty(t.prototype,"request",{get:function(){return this._request},enumerable:!0,configurable:!0}),t.prototype.onRequestTimeout=function(){this.user.onRequestTimeout&&this.user.onRequestTimeout()},t}(r(23).Transaction);t.ClientTransaction=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(7),s=r(16),o=function(e){function t(t,r,i,n,s){var o=e.call(this)||this;return o._transport=t,o._user=r,o._id=i,o._state=n,o.logger=r.loggerFactory.getLogger(s,i),o.logger.debug("Constructing "+o.typeToString()+" with id "+o.id+"."),o}return i.__extends(t,e),t.prototype.dispose=function(){this.logger.debug("Destroyed "+this.typeToString()+" with id "+this.id+".")},Object.defineProperty(t.prototype,"id",{get:function(){return this._id},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"kind",{get:function(){throw new Error("Invalid kind.")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"transport",{get:function(){return this._transport},enumerable:!0,configurable:!0}),t.prototype.on=function(t,r){return e.prototype.on.call(this,t,r)},t.prototype.logTransportError=function(e,t){this.logger.error(e.message),this.logger.error("Transport error occurred in "+this.typeToString()+" with id "+this.id+"."),this.logger.error(t)},t.prototype.send=function(e){var t=this;return this.transport.send(e).catch(function(e){var r;if(!(e instanceof s.TransportError))throw r=e&&"string"==typeof e.message?new s.TransportError(e.message):new s.TransportError,t.onTransportError(r),r;t.onTransportError(e)})},t.prototype.setState=function(e){this.logger.debug('State change to "'+e+'" on '+this.typeToString()+" with id "+this.id+"."),this._state=e,this._user.onStateChange&&this._user.onStateChange(e),this.emit("stateChanged")},t.prototype.typeToString=function(){return"UnknownType"},t}(n.EventEmitter);t.Transaction=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=function(e){function t(t){var r=this.constructor,i=e.call(this,t)||this;return Object.setPrototypeOf(i,r.prototype),i}return i.__extends(t,e),t}(Error);t.Exception=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=function(e){function t(t,r,i,n,s){var o=e.call(this,r,i,t.viaBranch,n,s)||this;return o._request=t,o.user=i,o}return i.__extends(t,e),Object.defineProperty(t.prototype,"request",{get:function(){return this._request},enumerable:!0,configurable:!0}),t}(r(23).Transaction);t.ServerTransaction=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){var s=void 0!==t.userAgentCore?t.userAgentCore:t;return e.call(this,n.NonInviteServerTransaction,s,r,i)||this}return i.__extends(t,e),t}(r(4).UserAgentServer);t.NotifyUserAgentServer=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r(0).__exportStar(r(70),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.error=0]="error",e[e.warn=1]="warn",e[e.log=2]="log",e[e.debug=3]="debug"}(t.Levels||(t.Levels={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0).__importStar(r(58));!function(e){e.parse=function(e,t){var r={startRule:t};try{i.parse(e,r)}catch(e){r.data=-1}return r.data},e.nameAddrHeaderParse=function(t){var r=e.parse(t,"Name_Addr_Header");return-1!==r?r:void 0},e.URIParse=function(t){var r=e.parse(t,"SIP_URI");return-1!==r?r:void 0}}(t.Grammar||(t.Grammar={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=function(e){function t(t,r,i,n,s,o){var a=e.call(this,s)||this;if(a.headers={},!i)throw new TypeError('missing or invalid "host" parameter');for(var c in t=t||"sip",o)o.hasOwnProperty(c)&&a.setHeader(c,o[c]);return a.raw={scheme:t,user:r,host:i,port:n},a.normal={scheme:t.toLowerCase(),user:r,host:i.toLowerCase(),port:n},a}return i.__extends(t,e),Object.defineProperty(t.prototype,"scheme",{get:function(){return this.normal.scheme},set:function(e){this.raw.scheme=e,this.normal.scheme=e.toLowerCase()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"user",{get:function(){return this.normal.user},set:function(e){this.normal.user=this.raw.user=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"host",{get:function(){return this.normal.host},set:function(e){this.raw.host=e,this.normal.host=e.toLowerCase()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"aor",{get:function(){return this.normal.user+"@"+this.normal.host},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"port",{get:function(){return this.normal.port},set:function(e){this.normal.port=this.raw.port=e},enumerable:!0,configurable:!0}),t.prototype.setHeader=function(e,t){this.headers[this.headerize(e)]=t instanceof Array?t:[t]},t.prototype.getHeader=function(e){if(e)return this.headers[this.headerize(e)]},t.prototype.hasHeader=function(e){return!!e&&!!this.headers.hasOwnProperty(this.headerize(e))},t.prototype.deleteHeader=function(e){if(e=this.headerize(e),this.headers.hasOwnProperty(e)){var t=this.headers[e];return delete this.headers[e],t}},t.prototype.clearHeaders=function(){this.headers={}},t.prototype.clone=function(){return new t(this._raw.scheme,this._raw.user||"",this._raw.host,this._raw.port,JSON.parse(JSON.stringify(this.parameters)),JSON.parse(JSON.stringify(this.headers)))},t.prototype.toRaw=function(){return this._toString(this._raw)},t.prototype.toString=function(){return this._toString(this._normal)},Object.defineProperty(t.prototype,"_normal",{get:function(){return this.normal},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"_raw",{get:function(){return this.raw},enumerable:!0,configurable:!0}),t.prototype._toString=function(e){var t=e.scheme+":";for(var r in e.scheme.toLowerCase().match("^sips?$")||(t+="//"),e.user&&(t+=this.escapeUser(e.user)+"@"),t+=e.host,(e.port||0===e.port)&&(t+=":"+e.port),this.parameters)this.parameters.hasOwnProperty(r)&&(t+=";"+r,null!==this.parameters[r]&&(t+="="+this.parameters[r]));var i=[];for(var n in this.headers)if(this.headers.hasOwnProperty(n))for(var s in this.headers[n])this.headers[n].hasOwnProperty(s)&&i.push(n+"="+this.headers[n][s]);return i.length>0&&(t+="?"+i.join("&")),t},t.prototype.escapeUser=function(e){return encodeURIComponent(decodeURIComponent(e)).replace(/%3A/gi,":").replace(/%2B/gi,"+").replace(/%3F/gi,"?").replace(/%2F/gi,"/")},t.prototype.headerize=function(e){for(var t={"Call-Id":"Call-ID",Cseq:"CSeq","Min-Se":"Min-SE",Rack:"RAck",Rseq:"RSeq","Www-Authenticate":"WWW-Authenticate"},r=e.toLowerCase().replace(/_/g,"-").split("-"),i=r.length,n="",s=0;s<i;s++)0!==s&&(n+="-"),n+=r[s].charAt(0).toUpperCase()+r[s].substring(1);return t[n]&&(n=t[n]),n},t}(r(21).Parameters);t.URI=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.Initial="Initial",e.Establishing="Establishing",e.Established="Established",e.Terminating="Terminating",e.Terminated="Terminated"}(t.SessionState||(t.SessionState={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=function(e){function t(){return e.call(this)||this}return i.__extends(t,e),t}(r(19).IncomingMessage);t.IncomingRequestMessage=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=function(e){function t(){return e.call(this)||this}return i.__extends(t,e),t}(r(19).IncomingMessage);t.IncomingResponseMessage=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(20),s=r(12),o=function(){function e(t,r,n,o,a,c,u){this.headers={},this.extraHeaders=[],this.options=e.getDefaultOptions(),a&&(this.options=i.__assign({},this.options,a),this.options.optionTags&&this.options.optionTags.length&&(this.options.optionTags=this.options.optionTags.slice()),this.options.routeSet&&this.options.routeSet.length&&(this.options.routeSet=this.options.routeSet.slice())),c&&c.length&&(this.extraHeaders=c.slice()),u&&(this.body={body:u.content,contentType:u.contentType}),this.method=t,this.ruri=r.clone(),this.fromURI=n.clone(),this.fromTag=this.options.fromTag?this.options.fromTag:s.newTag(),this.from=e.makeNameAddrHeader(this.fromURI,this.options.fromDisplayName,this.fromTag),this.toURI=o.clone(),this.toTag=this.options.toTag,this.to=e.makeNameAddrHeader(this.toURI,this.options.toDisplayName,this.toTag),this.callId=this.options.callId?this.options.callId:this.options.callIdPrefix+s.createRandomToken(15),this.cseq=this.options.cseq,this.setHeader("route",this.options.routeSet),this.setHeader("via",""),this.setHeader("to",this.to.toString()),this.setHeader("from",this.from.toString()),this.setHeader("cseq",this.cseq+" "+this.method),this.setHeader("call-id",this.callId),this.setHeader("max-forwards","70")}return e.getDefaultOptions=function(){return{callId:"",callIdPrefix:"",cseq:1,toDisplayName:"",toTag:"",fromDisplayName:"",fromTag:"",forceRport:!1,hackViaTcp:!1,hackViaWS:!1,optionTags:["outbound"],routeSet:[],userAgentString:"sip.js",viaHost:""}},e.makeNameAddrHeader=function(e,t,r){var i={};return r&&(i.tag=r),new n.NameAddrHeader(e,t,i)},e.prototype.getHeader=function(e){var t=this.headers[s.headerize(e)];if(t){if(t[0])return t[0]}else for(var r=new RegExp("^\\s*"+e+"\\s*:","i"),i=0,n=this.extraHeaders;i<n.length;i++){var o=n[i];if(r.test(o))return o.substring(o.indexOf(":")+1).trim()}},e.prototype.getHeaders=function(e){var t=[],r=this.headers[s.headerize(e)];if(r)for(var i=0,n=r;i<n.length;i++){var o=n[i];t.push(o)}else for(var a=new RegExp("^\\s*"+e+"\\s*:","i"),c=0,u=this.extraHeaders;c<u.length;c++){var d=u[c];a.test(d)&&t.push(d.substring(d.indexOf(":")+1).trim())}return t},e.prototype.hasHeader=function(e){if(this.headers[s.headerize(e)])return!0;for(var t=new RegExp("^\\s*"+e+"\\s*:","i"),r=0,i=this.extraHeaders;r<i.length;r++){var n=i[r];if(t.test(n))return!0}return!1},e.prototype.setHeader=function(e,t){this.headers[s.headerize(e)]=t instanceof Array?t:[t]},e.prototype.setViaHeader=function(e,t){void 0===t&&(t="WSS"),this.options.hackViaTcp?t="TCP":this.options.hackViaWS&&(t="WS");var r="SIP/2.0/"+t;r+=" "+this.options.viaHost+";branch="+e,this.options.forceRport&&(r+=";rport"),this.setHeader("via",r),this.branch=e},e.prototype.toString=function(){var e="";for(var t in e+=this.method+" "+this.ruri.toRaw()+" SIP/2.0\r\n",this.headers)if(this.headers[t])for(var r=0,i=this.headers[t];r<i.length;r++){e+=t+": "+i[r]+"\r\n"}for(var n=0,o=this.extraHeaders;n<o.length;n++){e+=(t=o[n]).trim()+"\r\n"}return e+="Supported: "+this.options.optionTags.join(", ")+"\r\n",e+="User-Agent: "+this.options.userAgentString+"\r\n",this.body?"string"==typeof this.body?(e+="Content-Length: "+s.str_utf8_length(this.body)+"\r\n\r\n",e+=this.body):this.body.body&&this.body.contentType?(e+="Content-Type: "+this.body.contentType+"\r\n",e+="Content-Length: "+s.str_utf8_length(this.body.body)+"\r\n\r\n",e+=this.body.body):e+="Content-Length: 0\r\n\r\n":e+="Content-Length: 0\r\n\r\n",e},e}();t.OutgoingRequestMessage=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(6),s=r(22),o=r(13),a=function(e){function t(t,r,i){var s=e.call(this,t,r,i,o.TransactionState.Calling,"sip.transaction.ict")||this;return s.ackRetransmissionCache=new Map,s.B=setTimeout(function(){return s.timer_B()},n.Timers.TIMER_B),s.send(t.toString()).catch(function(e){s.logTransportError(e,"Failed to send initial outgoing request.")}),s}return i.__extends(t,e),t.prototype.dispose=function(){this.B&&(clearTimeout(this.B),this.B=void 0),this.D&&(clearTimeout(this.D),this.D=void 0),this.M&&(clearTimeout(this.M),this.M=void 0),e.prototype.dispose.call(this)},Object.defineProperty(t.prototype,"kind",{get:function(){return"ict"},enumerable:!0,configurable:!0}),t.prototype.ackResponse=function(e){var t=this,r=e.toTag;if(!r)throw new Error("To tag undefined.");var i="z9hG4bK"+Math.floor(1e7*Math.random()),n=this.transport.server&&this.transport.server.scheme?this.transport.server.scheme:void 0;e.setViaHeader(i,n),this.ackRetransmissionCache.set(r,e),this.send(e.toString()).catch(function(e){t.logTransportError(e,"Failed to send ACK to 2xx response.")})},t.prototype.receiveResponse=function(e){var t=this,r=e.statusCode;if(!r||r<100||r>699)throw new Error("Invalid status code "+r);switch(this.state){case o.TransactionState.Calling:if(r>=100&&r<=199)return this.stateTransition(o.TransactionState.Proceeding),void(this.user.receiveResponse&&this.user.receiveResponse(e));if(r>=200&&r<=299)return this.ackRetransmissionCache.set(e.toTag,void 0),this.stateTransition(o.TransactionState.Accepted),void(this.user.receiveResponse&&this.user.receiveResponse(e));if(r>=300&&r<=699)return this.stateTransition(o.TransactionState.Completed),this.ack(e),void(this.user.receiveResponse&&this.user.receiveResponse(e));break;case o.TransactionState.Proceeding:if(r>=100&&r<=199)return void(this.user.receiveResponse&&this.user.receiveResponse(e));if(r>=200&&r<=299)return this.ackRetransmissionCache.set(e.toTag,void 0),this.stateTransition(o.TransactionState.Accepted),void(this.user.receiveResponse&&this.user.receiveResponse(e));if(r>=300&&r<=699)return this.stateTransition(o.TransactionState.Completed),this.ack(e),void(this.user.receiveResponse&&this.user.receiveResponse(e));break;case o.TransactionState.Accepted:if(r>=200&&r<=299){if(!this.ackRetransmissionCache.has(e.toTag))return this.ackRetransmissionCache.set(e.toTag,void 0),void(this.user.receiveResponse&&this.user.receiveResponse(e));var i=this.ackRetransmissionCache.get(e.toTag);return i?void this.send(i.toString()).catch(function(e){t.logTransportError(e,"Failed to send retransmission of ACK to 2xx response.")}):void 0}break;case o.TransactionState.Completed:if(r>=300&&r<=699)return void this.ack(e);break;case o.TransactionState.Terminated:break;default:throw new Error("Invalid state "+this.state)}var n="Received unexpected "+r+" response while in state "+this.state+".";this.logger.warn(n)},t.prototype.onTransportError=function(e){this.user.onTransportError&&this.user.onTransportError(e),this.stateTransition(o.TransactionState.Terminated,!0)},t.prototype.typeToString=function(){return"INVITE client transaction"},t.prototype.ack=function(e){var t=this,r=this.request.ruri,i=this.request.callId,n=this.request.cseq,s=this.request.getHeader("from"),o=e.getHeader("to"),a=this.request.getHeader("via"),c=this.request.getHeader("route");if(!s)throw new Error("From undefined.");if(!o)throw new Error("To undefined.");if(!a)throw new Error("Via undefined.");var u="ACK "+r+" SIP/2.0\r\n";c&&(u+="Route: "+c+"\r\n"),u+="Via: "+a+"\r\n",u+="To: "+o+"\r\n",u+="From: "+s+"\r\n",u+="Call-ID: "+i+"\r\n",u+="CSeq: "+n+" ACK\r\n",u+="Max-Forwards: 70\r\n",u+="Content-Length: 0\r\n\r\n",this.send(u).catch(function(e){t.logTransportError(e,"Failed to send ACK to non-2xx response.")})},t.prototype.stateTransition=function(e,t){var r=this;void 0===t&&(t=!1);var i=function(){throw new Error("Invalid state transition from "+r.state+" to "+e)};switch(e){case o.TransactionState.Calling:i();break;case o.TransactionState.Proceeding:this.state!==o.TransactionState.Calling&&i();break;case o.TransactionState.Accepted:case o.TransactionState.Completed:this.state!==o.TransactionState.Calling&&this.state!==o.TransactionState.Proceeding&&i();break;case o.TransactionState.Terminated:this.state!==o.TransactionState.Calling&&this.state!==o.TransactionState.Accepted&&this.state!==o.TransactionState.Completed&&(t||i());break;default:i()}this.B&&(clearTimeout(this.B),this.B=void 0),o.TransactionState.Proceeding,e===o.TransactionState.Completed&&(this.D=setTimeout(function(){return r.timer_D()},n.Timers.TIMER_D)),e===o.TransactionState.Accepted&&(this.M=setTimeout(function(){return r.timer_M()},n.Timers.TIMER_M)),e===o.TransactionState.Terminated&&this.dispose(),this.setState(e)},t.prototype.timer_A=function(){},t.prototype.timer_B=function(){this.logger.debug("Timer B expired for INVITE client transaction "+this.id+"."),this.state===o.TransactionState.Calling&&(this.onRequestTimeout(),this.stateTransition(o.TransactionState.Terminated))},t.prototype.timer_D=function(){this.logger.debug("Timer D expired for INVITE client transaction "+this.id+"."),this.state===o.TransactionState.Completed&&this.stateTransition(o.TransactionState.Terminated)},t.prototype.timer_M=function(){this.logger.debug("Timer M expired for INVITE client transaction "+this.id+"."),this.state===o.TransactionState.Accepted&&this.stateTransition(o.TransactionState.Terminated)},t}(s.ClientTransaction);t.InviteClientTransaction=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(2),s=r(1),o=function(e){function t(t,r,i){var o,a=t.createOutgoingRequestMessage(n.C.BYE,i);return o=e.call(this,s.NonInviteClientTransaction,t.userAgentCore,a,r)||this,t.dispose(),o}return i.__extends(t,e),t}(r(3).UserAgentClient);t.ByeUserAgentClient=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){return e.call(this,n.NonInviteServerTransaction,t.userAgentCore,r,i)||this}return i.__extends(t,e),t}(r(4).UserAgentServer);t.ByeUserAgentServer=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(2),s=r(1),o=function(e){function t(t,r,i){var o=t.createOutgoingRequestMessage(n.C.INFO,i);return e.call(this,s.NonInviteClientTransaction,t.userAgentCore,o,r)||this}return i.__extends(t,e),t}(r(3).UserAgentClient);t.InfoUserAgentClient=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){return e.call(this,n.NonInviteServerTransaction,t.userAgentCore,r,i)||this}return i.__extends(t,e),t}(r(4).UserAgentServer);t.InfoUserAgentServer=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(2),s=r(1),o=function(e){function t(t,r,i){var o=t.createOutgoingRequestMessage(n.C.NOTIFY,i);return e.call(this,s.NonInviteClientTransaction,t.userAgentCore,o,r)||this}return i.__extends(t,e),t}(r(3).UserAgentClient);t.NotifyUserAgentClient=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(2),s=r(1),o=function(e){function t(t,r,i){var o,a=t.createOutgoingRequestMessage(n.C.PRACK,i);return o=e.call(this,s.NonInviteClientTransaction,t.userAgentCore,a,r)||this,t.signalingStateTransition(a),o}return i.__extends(t,e),t}(r(3).UserAgentClient);t.PrackUserAgentClient=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){var s=e.call(this,n.NonInviteServerTransaction,t.userAgentCore,r,i)||this;return t.signalingStateTransition(r),s.dialog=t,s}return i.__extends(t,e),t.prototype.accept=function(t){return void 0===t&&(t={statusCode:200}),t.body&&this.dialog.signalingStateTransition(t.body),e.prototype.accept.call(this,t)},t}(r(4).UserAgentServer);t.PrackUserAgentServer=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(2),s=r(1),o=function(e){function t(t,r,i){var o=this,a=t.createOutgoingRequestMessage(n.C.INVITE,i);return(o=e.call(this,s.InviteClientTransaction,t.userAgentCore,a,r)||this).delegate=r,t.signalingStateTransition(a),t.reinviteUserAgentClient=o,o.dialog=t,o}return i.__extends(t,e),t.prototype.receiveResponse=function(e){var t=this,r=e.statusCode?e.statusCode.toString():"";if(!r)throw new Error("Response status code undefined.");switch(!0){case/^100$/.test(r):this.delegate&&this.delegate.onTrying&&this.delegate.onTrying({message:e});break;case/^1[0-9]{2}$/.test(r):this.delegate&&this.delegate.onProgress&&this.delegate.onProgress({message:e,session:this.dialog,prack:function(e){throw new Error("Unimplemented.")}});break;case/^2[0-9]{2}$/.test(r):this.dialog.signalingStateTransition(e),this.delegate&&this.delegate.onAccept&&this.delegate.onAccept({message:e,session:this.dialog,ack:function(e){return t.dialog.ack(e)}});break;case/^3[0-9]{2}$/.test(r):this.delegate&&this.delegate.onRedirect&&this.delegate.onRedirect({message:e});break;case/^[4-6][0-9]{2}$/.test(r):this.delegate&&this.delegate.onReject&&this.delegate.onReject({message:e});break;default:throw new Error("Invalid status code "+r)}},t}(r(3).UserAgentClient);t.ReInviteUserAgentClient=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){var s=e.call(this,n.InviteServerTransaction,t.userAgentCore,r,i)||this;return t.reinviteUserAgentServer=s,s.dialog=t,s}return i.__extends(t,e),t.prototype.accept=function(t){void 0===t&&(t={statusCode:200}),t.extraHeaders=t.extraHeaders||[],t.extraHeaders=t.extraHeaders.concat(this.dialog.routeSet.map(function(e){return"Record-Route: "+e}));var r=e.prototype.accept.call(this,t),n=this.dialog,s=i.__assign({},r,{session:n});return t.body&&this.dialog.signalingStateTransition(t.body),this.dialog.reConfirm(),s},t.prototype.progress=function(t){void 0===t&&(t={statusCode:180});var r=e.prototype.progress.call(this,t),n=this.dialog,s=i.__assign({},r,{session:n});return t.body&&this.dialog.signalingStateTransition(t.body),s},t}(r(4).UserAgentServer);t.ReInviteUserAgentServer=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(2),s=r(1),o=function(e){function t(t,r,i){var o=t.createOutgoingRequestMessage(n.C.REFER,i);return e.call(this,s.NonInviteClientTransaction,t.userAgentCore,o,r)||this}return i.__extends(t,e),t}(r(3).UserAgentClient);t.ReferUserAgentClient=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){var s=void 0!==t.userAgentCore?t.userAgentCore:t;return e.call(this,n.NonInviteServerTransaction,s,r,i)||this}return i.__extends(t,e),t}(r(4).UserAgentServer);t.ReferUserAgentServer=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(2),s=r(27),o=r(6),a=r(14),c=r(26),u=r(48),d=function(e){function t(t,r,i,n,s,o){var a=e.call(this,n,s)||this;return a.delegate=o,a._autoRefresh=!1,a._subscriptionEvent=t,a._subscriptionExpires=r,a._subscriptionExpiresInitial=r,a._subscriptionExpiresLastSet=Math.floor(Date.now()/1e3),a._subscriptionRefresh=void 0,a._subscriptionRefreshLastSet=void 0,a._subscriptionState=i,a.logger=n.loggerFactory.getLogger("sip.subscribe-dialog"),a.logger.log("SUBSCRIBE dialog "+a.id+" constructed"),a}return i.__extends(t,e),t.initialDialogStateForSubscription=function(e,t){var r=t.getHeaders("record-route"),i=t.parseHeader("contact");if(!i)throw new Error("Contact undefined.");if(!(i instanceof n.NameAddrHeader))throw new Error("Contact not instance of NameAddrHeader.");var s=i.uri,o=e.cseq,a=e.callId,c=e.fromTag,u=t.fromTag;if(!a)throw new Error("Call id undefined.");if(!c)throw new Error("From tag undefined.");if(!u)throw new Error("To tag undefined.");if(!e.from)throw new Error("From undefined.");if(!e.to)throw new Error("To undefined.");return{id:a+c+u,early:!1,callId:a,localTag:c,remoteTag:u,localSequenceNumber:o,remoteSequenceNumber:void 0,localURI:e.from.uri,remoteURI:e.to.uri,remoteTarget:s,routeSet:r,secure:!1}},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.N&&(clearTimeout(this.N),this.N=void 0),this.refreshTimerClear(),this.logger.log("SUBSCRIBE dialog "+this.id+" destroyed")},Object.defineProperty(t.prototype,"autoRefresh",{get:function(){return this._autoRefresh},set:function(e){this._autoRefresh=!0,this.refreshTimerSet()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"subscriptionEvent",{get:function(){return this._subscriptionEvent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"subscriptionExpires",{get:function(){var e=Math.floor(Date.now()/1e3)-this._subscriptionExpiresLastSet,t=this._subscriptionExpires-e;return Math.max(t,0)},set:function(e){if(e<0)throw new Error("Expires must be greater than or equal to zero.");if(this._subscriptionExpires=e,this._subscriptionExpiresLastSet=Math.floor(Date.now()/1e3),this.autoRefresh){var t=this.subscriptionRefresh;(void 0===t||t>=e)&&this.refreshTimerSet()}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"subscriptionExpiresInitial",{get:function(){return this._subscriptionExpiresInitial},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"subscriptionRefresh",{get:function(){if(void 0!==this._subscriptionRefresh&&void 0!==this._subscriptionRefreshLastSet){var e=Math.floor(Date.now()/1e3)-this._subscriptionRefreshLastSet,t=this._subscriptionRefresh-e;return Math.max(t,0)}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"subscriptionState",{get:function(){return this._subscriptionState},enumerable:!0,configurable:!0}),t.prototype.receiveRequest=function(t){if(this.logger.log("SUBSCRIBE dialog "+this.id+" received "+t.method+" request"),this.sequenceGuard(t))switch(e.prototype.receiveRequest.call(this,t),t.method){case n.C.NOTIFY:this.onNotify(t);break;default:this.logger.log("SUBSCRIBE dialog "+this.id+" received unimplemented "+t.method+" request"),this.core.replyStateless(t,{statusCode:501})}else this.logger.log("SUBSCRIBE dialog "+this.id+" rejected out of order "+t.method+" request.")},t.prototype.refresh=function(){var e="Allow: "+a.AllowedMethods.toString(),t={};return t.extraHeaders=(t.extraHeaders||[]).slice(),t.extraHeaders.push(e),t.extraHeaders.push("Event: "+this.subscriptionEvent),t.extraHeaders.push("Expires: "+this.subscriptionExpiresInitial),t.extraHeaders.push("Contact: "+this.core.configuration.contact.toString()),this.subscribe(void 0,t)},t.prototype.subscribe=function(e,t){var r=this;if(void 0===t&&(t={}),this.subscriptionState!==s.SubscriptionState.Pending&&this.subscriptionState!==s.SubscriptionState.Active)throw new Error("Invalid state "+this.subscriptionState+'. May only re-subscribe while in state "pending" or "active".');this.logger.log("SUBSCRIBE dialog "+this.id+" sending SUBSCRIBE request");var i=new u.ReSubscribeUserAgentClient(this,e,t);return this.N=setTimeout(function(){return r.timer_N()},o.Timers.TIMER_N),i},t.prototype.terminate=function(){this.stateTransition(s.SubscriptionState.Terminated),this.onTerminated()},t.prototype.unsubscribe=function(){var e="Allow: "+a.AllowedMethods.toString(),t={};return t.extraHeaders=(t.extraHeaders||[]).slice(),t.extraHeaders.push(e),t.extraHeaders.push("Event: "+this.subscriptionEvent),t.extraHeaders.push("Expires: 0"),t.extraHeaders.push("Contact: "+this.core.configuration.contact.toString()),this.subscribe(void 0,t)},t.prototype.onNotify=function(e){var t=e.parseHeader("Event").event;if(t&&t===this.subscriptionEvent){this.N&&(clearTimeout(this.N),this.N=void 0);var r=e.parseHeader("Subscription-State");if(r&&r.state){var i=r.state,n=r.expires?Math.max(r.expires,0):void 0;switch(i){case"pending":this.stateTransition(s.SubscriptionState.Pending,n);break;case"active":this.stateTransition(s.SubscriptionState.Active,n);break;case"terminated":this.stateTransition(s.SubscriptionState.Terminated,n);break;default:this.logger.warn("Unrecognized subscription state.")}var o=new c.NotifyUserAgentServer(this,e);this.delegate&&this.delegate.onNotify?this.delegate.onNotify(o):o.accept()}else this.core.replyStateless(e,{statusCode:489})}else this.core.replyStateless(e,{statusCode:489})},t.prototype.onRefresh=function(e){this.delegate&&this.delegate.onRefresh&&this.delegate.onRefresh(e)},t.prototype.onTerminated=function(){this.delegate&&this.delegate.onTerminated&&this.delegate.onTerminated()},t.prototype.refreshTimerClear=function(){this.refreshTimer&&(clearTimeout(this.refreshTimer),this.refreshTimer=void 0)},t.prototype.refreshTimerSet=function(){var e=this;if(this.refreshTimerClear(),this.autoRefresh&&this.subscriptionExpires>0){var t=900*this.subscriptionExpires;this._subscriptionRefresh=Math.floor(t/1e3),this._subscriptionRefreshLastSet=Math.floor(Date.now()/1e3),this.refreshTimer=setTimeout(function(){e.refreshTimer=void 0,e._subscriptionRefresh=void 0,e._subscriptionRefreshLastSet=void 0,e.onRefresh(e.refresh())},t)}},t.prototype.stateTransition=function(e,t){var r=this,i=function(){r.logger.warn("Invalid subscription state transition from "+r.subscriptionState+" to "+e)};switch(e){case s.SubscriptionState.Initial:case s.SubscriptionState.NotifyWait:return void i();case s.SubscriptionState.Pending:if(this.subscriptionState!==s.SubscriptionState.NotifyWait&&this.subscriptionState!==s.SubscriptionState.Pending)return void i();break;case s.SubscriptionState.Active:case s.SubscriptionState.Terminated:if(this.subscriptionState!==s.SubscriptionState.NotifyWait&&this.subscriptionState!==s.SubscriptionState.Pending&&this.subscriptionState!==s.SubscriptionState.Active)return void i();break;default:return void i()}e===s.SubscriptionState.Pending&&t&&(this.subscriptionExpires=t),e===s.SubscriptionState.Active&&t&&(this.subscriptionExpires=t),e===s.SubscriptionState.Terminated&&this.dispose(),this._subscriptionState=e},t.prototype.timer_N=function(){this.subscriptionState!==s.SubscriptionState.Terminated&&(this.stateTransition(s.SubscriptionState.Terminated),this.onTerminated())},t}(r(18).Dialog);t.SubscriptionDialog=d},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(2),s=r(1),o=function(e){function t(t,r,i){var o=this,a=t.createOutgoingRequestMessage(n.C.SUBSCRIBE,i);return(o=e.call(this,s.NonInviteClientTransaction,t.userAgentCore,a,r)||this).dialog=t,o}return i.__extends(t,e),t.prototype.waitNotifyStop=function(){},t.prototype.receiveResponse=function(t){if(t.statusCode&&t.statusCode>=200&&t.statusCode<300){var r=t.getHeader("Expires");if(r){var i=Number(r);this.dialog.subscriptionExpires>i&&(this.dialog.subscriptionExpires=i)}else this.logger.warn("Expires header missing in a 200-class response to SUBSCRIBE")}if(t.statusCode&&t.statusCode>=400&&t.statusCode<700){[404,405,410,416,480,481,482,483,484,485,489,501,604].includes(t.statusCode)&&this.dialog.terminate()}e.prototype.receiveResponse.call(this,t)},t}(r(3).UserAgentClient);t.ReSubscribeUserAgentClient=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(28),n=function(){function e(e,t,r){this.logger=e,this.category=t,this.label=r}return e.prototype.error=function(e){this.genericLog(i.Levels.error,e)},e.prototype.warn=function(e){this.genericLog(i.Levels.warn,e)},e.prototype.log=function(e){this.genericLog(i.Levels.log,e)},e.prototype.debug=function(e){this.genericLog(i.Levels.debug,e)},e.prototype.genericLog=function(e,t){this.logger.genericLog(e,this.category,this.label,t)},e}();t.Logger=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0);i.__exportStar(r(36),t),i.__exportStar(r(37),t),i.__exportStar(r(75),t),i.__exportStar(r(38),t),i.__exportStar(r(39),t),i.__exportStar(r(76),t),i.__exportStar(r(77),t),i.__exportStar(r(78),t),i.__exportStar(r(79),t),i.__exportStar(r(40),t),i.__exportStar(r(26),t),i.__exportStar(r(80),t),i.__exportStar(r(41),t),i.__exportStar(r(42),t),i.__exportStar(r(43),t),i.__exportStar(r(44),t),i.__exportStar(r(48),t),i.__exportStar(r(81),t),i.__exportStar(r(45),t),i.__exportStar(r(46),t),i.__exportStar(r(82),t),i.__exportStar(r(83),t),i.__exportStar(r(84),t),i.__exportStar(r(3),t),i.__exportStar(r(4),t)},,function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(7),s=r(10),o=r(5),a=r(14),c=r(8),u=r(11),d=r(9),l=r(53),p=r(90),h=r(54),g=r(91),f=r(31),v=function(e){function t(t,r){void 0===r&&(r={});var i=e.call(this)||this;i.type=c.TypeStrings.Session,i.method=s.C.INVITE,i.localHold=!1,i.status=c.SessionStatus.STATUS_NULL,i.rel100=s.C.supported.UNSUPPORTED,i.expiresTimer=void 0,i.userNoAnswerTimer=void 0,i._state=f.SessionState.Initial,i._stateEventEmitter=new n.EventEmitter,i.pendingReinvite=!1,i.tones=void 0,i.userAgent=t,i.delegate=r.delegate,i.logger=t.getLogger("sip.session");var o=i.userAgent.configuration.sessionDescriptionHandlerFactory;if(!o)throw new u.Exceptions.SessionDescriptionHandlerError("A session description handler is required for the session to function.");return i.sessionDescriptionHandlerFactory=o,i.errorListener=i.onTransportError.bind(i),t.transport&&t.transport.on("transportError",i.errorListener),i}return i.__extends(t,e),t.prototype.on=function(t,r){return e.prototype.on.call(this,t,r)},t.prototype.emit=function(t){for(var r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];return e.prototype.emit.apply(this,[t].concat(r))},Object.defineProperty(t.prototype,"sessionDescriptionHandler",{get:function(){return this._sessionDescriptionHandler},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stateChange",{get:function(){return l.makeEmitter(this._stateEventEmitter)},enumerable:!0,configurable:!0}),t.prototype.invite=function(e){var t=this;if(void 0===e&&(e={}),this.logger.log("Session.invite"),this.state!==f.SessionState.Established)return Promise.reject(new Error("Invalid session state "+this.state));if(this.pendingReinvite)return Promise.reject(new Error("Reinvite in progress. Please wait until complete, then try again."));if(!this._sessionDescriptionHandler)throw new Error("Session description handler undefined.");var r={sessionDescriptionHandlerOptions:e.sessionDescriptionHandlerOptions,sessionDescriptionHandlerModifiers:e.sessionDescriptionHandlerModifiers};return this.pendingReinvite=!0,this.getOffer(r).then(function(r){if(!t.dialog)throw new Error("Dialog undefined.");var i={onAccept:function(r){var i=r.ack();t.emit("ack",i.message),t.emit("reinviteAccepted",t),t.pendingReinvite=!1;var n=o.getBody(r.message);if(!n){t.logger.error("Received 2xx final response to re-invite without a description");var s=new Error("Invalid response to a re-invite.");throw t.emit("reinviteFailed",t),t.emit("renegotiationError",s),s}var a={sessionDescriptionHandlerOptions:t.sessionDescriptionHandlerOptions,sessionDescriptionHandlerModifiers:t.sessionDescriptionHandlerModifiers};t.setAnswer(n,a),e.requestDelegate&&e.requestDelegate.onAccept&&e.requestDelegate.onAccept(r)},onProgress:function(e){},onRedirect:function(e){},onReject:function(r){t.logger.error("Received a non-2xx final response to re-invite");var i=new Error("Invalid response to a re-invite.");t.emit("reinviteFailed",t),t.emit("renegotiationError",i),e.requestDelegate&&e.requestDelegate.onReject&&e.requestDelegate.onReject(r)},onTrying:function(e){}},n=e.requestOptions||{};return n.extraHeaders=(n.extraHeaders||[]).slice(),n.extraHeaders.push("Allow: "+a.AllowedMethods.toString()),n.extraHeaders.push("Contact: "+t.contact),n.body=r,t.dialog.invite(i,n)}).catch(function(e){throw t.logger.error(e.message),t.emit("reinviteFailed",t),t.emit("renegotiationError",e),t.pendingReinvite=!1,e})},t.prototype.byePending=function(){this.stateTransition(f.SessionState.Terminating),this.terminated()},t.prototype.byeSent=function(e){this.emit("bye",e.message),this.stateTransition(f.SessionState.Terminated),this.terminated()},t.prototype.bye=function(e,t){var r=this;if(!this.dialog)return Promise.reject(new Error("Session dialog undefined."));var i=this.dialog;switch(i.sessionState){case o.SessionState.Initial:case o.SessionState.Early:throw new Error("Invalid dialog state "+i.sessionState);case o.SessionState.AckWait:return this.byePending(),new Promise(function(n,s){i.delegate={onAck:function(){var s=i.bye(e,t);r.byeSent(s),n(s)},onAckTimeout:function(){var s=i.bye(e,t);r.byeSent(s),n(s)}}});case o.SessionState.Confirmed:var n=i.bye(e,t);return this.byeSent(n),Promise.resolve(n);case o.SessionState.Terminated:throw new Error("Invalid dialog state "+i.sessionState);default:throw new Error("Unrecognized state.")}},t.prototype.info=function(e,t){return this.dialog?Promise.resolve(this.dialog.info(e,t)):Promise.reject(new Error("Session dialog undefined."))},t.prototype.refer=function(e,t,r){return this.dialog?(this.referrer=e,Promise.resolve(this.dialog.refer(t,r))):Promise.reject(new Error("Session dialog undefined."))},t.prototype.close=function(){if(this.status!==c.SessionStatus.STATUS_TERMINATED){if(this.logger.log("closing INVITE session "+this.id),this._sessionDescriptionHandler&&this._sessionDescriptionHandler.close(),this.expiresTimer&&clearTimeout(this.expiresTimer),this.userNoAnswerTimer&&clearTimeout(this.userNoAnswerTimer),this.status=c.SessionStatus.STATUS_TERMINATED,this.userAgent.transport&&this.userAgent.transport.removeListener("transportError",this.errorListener),!this.id)throw new Error("Session id undefined.");delete this.userAgent.sessions[this.id]}},t.prototype.onRequestTimeout=function(){this.status===c.SessionStatus.STATUS_CONFIRMED?this.terminated(void 0,s.C.causes.REQUEST_TIMEOUT):this.status!==c.SessionStatus.STATUS_TERMINATED&&(this.failed(void 0,s.C.causes.REQUEST_TIMEOUT),this.terminated(void 0,s.C.causes.REQUEST_TIMEOUT))},t.prototype.onTransportError=function(){this.status!==c.SessionStatus.STATUS_CONFIRMED&&this.status!==c.SessionStatus.STATUS_TERMINATED&&this.failed(void 0,s.C.causes.CONNECTION_ERROR)},t.prototype.onAckRequest=function(e){var t=this;if(this.logger.log("Session.onAckRequest"),this.state===f.SessionState.Initial||this.state===f.SessionState.Establishing||this.state===f.SessionState.Established||this.state===f.SessionState.Terminating){this.state!==f.SessionState.Initial&&this.state!==f.SessionState.Establishing||this.stateTransition(f.SessionState.Established);var r=this.dialog;if(!r)throw new Error("Dialog undefined.");var i=function(){t.status=c.SessionStatus.STATUS_CONFIRMED,t.emit("confirmed",e.message)},n=o.getBody(e.message);if(n){if("render"===n.contentDisposition)return this.renderbody=n.content,this.rendertype=n.contentType,void i();if("session"===n.contentDisposition){var a={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers};switch(r.signalingState){case o.SignalingState.Initial:throw new Error("Invalid signaling state "+r.signalingState+".");case o.SignalingState.Stable:return void this.setAnswer(n,a).then(function(){return i()}).catch(function(r){t.logger.error(r);var i=["Reason: "+d.Utils.getReasonHeaderValue(488,"Bad Media Description")];throw t.bye(void 0,{extraHeaders:i}),t.failed(e.message,s.C.causes.BAD_MEDIA_DESCRIPTION),t.terminated(e.message,s.C.causes.BAD_MEDIA_DESCRIPTION),r});case o.SignalingState.HaveLocalOffer:case o.SignalingState.HaveRemoteOffer:case o.SignalingState.Closed:default:throw new Error("Invalid signaling state "+r.signalingState+".")}}else i()}else i()}else this.logger.error("ACK received while in state "+this.state+", dropping request")},t.prototype.onByeRequest=function(e){this.logger.log("Session.onByeRequest"),this.state===f.SessionState.Established?(e.accept(),this.stateTransition(f.SessionState.Terminated),this.status===c.SessionStatus.STATUS_CONFIRMED&&(this.emit("bye",e.message),this.terminated(e.message,s.C.BYE))):this.logger.error("BYE received while in state "+this.state+", dropping request")},t.prototype.onInfoRequest=function(e){if(this.logger.log("Session.onInfoRequest"),this.state===f.SessionState.Established)if(this.delegate&&this.delegate.onInfo){var t=new p.Info(e);this.delegate.onInfo(t)}else e.accept();else this.logger.error("INFO received while in state "+this.state+", dropping request")},t.prototype.onInviteRequest=function(e){var t=this;if(this.logger.log("Session.onInviteRequest"),this.state===f.SessionState.Established){if(e.message.hasHeader("P-Asserted-Identity")){var r=e.message.getHeader("P-Asserted-Identity");if(!r)throw new Error("Header undefined.");this.assertedIdentity=o.Grammar.nameAddrHeaderParse(r)}this.emit("reinvite",this,e.message);var i=["Contact: "+this.contact],n={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers};this.generateResponseOfferAnswerInDialog(n).then(function(r){e.accept({statusCode:200,extraHeaders:i,body:r}),t.emit("reinviteAccepted",t),t.delegate&&t.delegate.onReinviteSuccess&&t.delegate.onReinviteSuccess()}).catch(function(r){t.logger.error(r.message),e.reject({statusCode:488}),t.emit("reinviteFailed",t),t.emit("renegotiationError",r),t.delegate&&t.delegate.onReinviteFailure?t.delegate.onReinviteFailure(r):(t.logger.error("A failure occurred processing re-INVITE request with no delegate, terminating session..."),t.bye(void 0,{extraHeaders:["Reason: "+d.Utils.getReasonHeaderValue(488,"Not Acceptable Here")]}))})}else this.logger.error("INVITE received while in state "+this.state+", dropping request")},t.prototype.onNotifyRequest=function(e){if(this.logger.log("Session.onNotifyRequest"),this.state===f.SessionState.Established)if(this.referrer&&this.referrer.delegate&&this.referrer.delegate.onNotify){var t=new h.Notification(e);this.referrer.delegate.onNotify(t)}else{if(this.delegate&&this.delegate.onNotify){t=new h.Notification(e);this.delegate.onNotify(t)}else e.accept();this.emit("notify",e.message)}else this.logger.error("NOTIFY received while in state "+this.state+", dropping request")},t.prototype.onPrackRequest=function(e){if(this.logger.log("Session.onPrackRequest"),this.state===f.SessionState.Established)throw new Error("Unimplemented.");this.logger.error("PRACK received while in state "+this.state+", dropping request")},t.prototype.onReferRequest=function(e){var t=this;if(this.logger.log("Session.onReferRequest"),this.state===f.SessionState.Established){if(this.status===c.SessionStatus.STATUS_CONFIRMED){if(!e.message.hasHeader("refer-to"))return this.logger.warn("Invalid REFER packet. A refer-to header is required. Rejecting."),void e.reject();var r=new g.Referral(e,this);this.delegate&&this.delegate.onRefer?this.delegate.onRefer(r):(this.logger.log("No delegate available to handle REFER, automatically accepting and following."),r.accept().then(function(){return r.makeInviter(t.passedOptions).invite()}).catch(function(e){t.logger.error(e.message)}))}}else this.logger.error("REFER received while in state "+this.state+", dropping request")},t.prototype.accepted=function(e,t){e instanceof o.IncomingResponseMessage&&(t=d.Utils.getReasonPhrase(e.statusCode||0,t)),this.startTime=new Date,this.replacee&&(this.replacee.emit("replaced",this),this.replacee.bye()),this.emit("accepted",e,t)},t.prototype.canceled=function(){this._sessionDescriptionHandler&&this._sessionDescriptionHandler.close(),this.emit("cancel")},t.prototype.connecting=function(e){this.emit("connecting",{request:e})},t.prototype.failed=function(e,t){this.status!==c.SessionStatus.STATUS_TERMINATED&&this.emit("failed",e,t)},t.prototype.rejected=function(e,t){this.emit("rejected",e,t)},t.prototype.terminated=function(e,t){this.status!==c.SessionStatus.STATUS_TERMINATED&&(this.endTime=new Date,this.close(),this.emit("terminated",e,t))},t.prototype.generateResponseOfferAnswer=function(e,t){if(this.dialog)return this.generateResponseOfferAnswerInDialog(t);var r=o.getBody(e.message);return r&&"session"===r.contentDisposition?this.setOfferAndGetAnswer(r,t):this.getOffer(t)},t.prototype.generateResponseOfferAnswerInDialog=function(e){if(!this.dialog)throw new Error("Dialog undefined.");switch(this.dialog.signalingState){case o.SignalingState.Initial:return this.getOffer(e);case o.SignalingState.Stable:case o.SignalingState.HaveLocalOffer:return Promise.resolve(void 0);case o.SignalingState.HaveRemoteOffer:if(!this.dialog.offer)throw new Error("Session offer undefined in signaling state "+this.dialog.signalingState+".");return this.setOfferAndGetAnswer(this.dialog.offer,e);case o.SignalingState.Closed:default:throw new Error("Invalid signaling state "+this.dialog.signalingState+".")}},t.prototype.getOffer=function(e){var t=this.setupSessionDescriptionHandler(),r=e.sessionDescriptionHandlerOptions,i=e.sessionDescriptionHandlerModifiers;return t.getDescription(r,i).then(function(e){return d.Utils.fromBodyObj(e)}).catch(function(e){throw e instanceof Error?e:new Error(e)})},t.prototype.setAnswer=function(e,t){var r=this.setupSessionDescriptionHandler(),i=t.sessionDescriptionHandlerOptions,n=t.sessionDescriptionHandlerModifiers;return r.hasDescription(e.contentType)?r.setDescription(e.content,i,n).catch(function(e){throw e instanceof Error?e:new Error(e)}):Promise.reject(new u.Exceptions.UnsupportedSessionDescriptionContentTypeError)},t.prototype.setOfferAndGetAnswer=function(e,t){var r=this.setupSessionDescriptionHandler(),i=t.sessionDescriptionHandlerOptions,n=t.sessionDescriptionHandlerModifiers;return r.hasDescription(e.contentType)?r.setDescription(e.content,i,n).then(function(){return r.getDescription(i,n)}).then(function(e){return d.Utils.fromBodyObj(e)}).catch(function(e){throw e instanceof Error?e:new Error(e)}):Promise.reject(new u.Exceptions.UnsupportedSessionDescriptionContentTypeError)},t.prototype.setSessionDescriptionHandler=function(e){if(this._sessionDescriptionHandler)throw new Error("Sessionn description handler defined.");this._sessionDescriptionHandler=e},t.prototype.setupSessionDescriptionHandler=function(){return this._sessionDescriptionHandler?this._sessionDescriptionHandler:(this._sessionDescriptionHandler=this.sessionDescriptionHandlerFactory(this,this.userAgent.configuration.sessionDescriptionHandlerFactoryOptions),this.emit("SessionDescriptionHandler-created",this._sessionDescriptionHandler),this._sessionDescriptionHandler)},t.prototype.stateTransition=function(e){var t=this,r=function(){throw new Error("Invalid state transition from "+t._state+" to "+e)};switch(this._state){case f.SessionState.Initial:e!==f.SessionState.Establishing&&e!==f.SessionState.Established&&e!==f.SessionState.Terminating&&e!==f.SessionState.Terminated&&r();break;case f.SessionState.Establishing:e!==f.SessionState.Established&&e!==f.SessionState.Terminating&&e!==f.SessionState.Terminated&&r();break;case f.SessionState.Established:e!==f.SessionState.Terminating&&e!==f.SessionState.Terminated&&r();break;case f.SessionState.Terminating:e!==f.SessionState.Terminated&&r();break;case f.SessionState.Terminated:r();break;default:throw new Error("Unrecognized state.")}this._state=e,this.logger.log("Session "+this.id+" transitioned to state "+this._state),this._stateEventEmitter.emit("event",this._state)},t.C=c.SessionStatus,t}(n.EventEmitter);t.Session=v},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.makeEmitter=function(e,t){return void 0===t&&(t="event"),{on:function(r){e.on(t,r)},off:function(r){e.removeListener(t,r)},once:function(r){e.once(t,r)}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e){this.incomingNotifyRequest=e}return Object.defineProperty(e.prototype,"request",{get:function(){return this.incomingNotifyRequest.message},enumerable:!0,configurable:!0}),e.prototype.accept=function(e){return this.incomingNotifyRequest.accept(e),Promise.resolve()},e.prototype.reject=function(e){return this.incomingNotifyRequest.reject(e),Promise.resolve()},e}();t.Notification=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r(0).__exportStar(r(56),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.ACK="ACK",e.BYE="BYE",e.CANCEL="CANCEL",e.INFO="INFO",e.INVITE="INVITE",e.MESSAGE="MESSAGE",e.NOTIFY="NOTIFY",e.OPTIONS="OPTIONS",e.REGISTER="REGISTER",e.UPDATE="UPDATE",e.SUBSCRIBE="SUBSCRIBE",e.PUBLISH="PUBLISH",e.REFER="REFER",e.PRACK="PRACK"}(t.C||(t.C={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(32),n=r(33),s=r(34);function o(e){return!(!e||"string"!=typeof e.content||"string"!=typeof e.contentType||void 0!==e.contentDisposition)||"string"==typeof e.contentDisposition}function a(e){return"application/sdp"===e?"session":"render"}t.fromBodyLegacy=function(e){var t="string"==typeof e?e:e.body,r="string"==typeof e?"application/sdp":e.contentType;return{contentDisposition:a(r),contentType:r,content:t}},t.getBody=function(e){var t,r,c,u;if(e instanceof i.IncomingRequestMessage&&e.body&&(t=(u=e.parseHeader("Content-Disposition"))?u.type:void 0,r=e.parseHeader("Content-Type"),c=e.body),e instanceof n.IncomingResponseMessage&&e.body&&(t=(u=e.parseHeader("Content-Disposition"))?u.type:void 0,r=e.parseHeader("Content-Type"),c=e.body),e instanceof s.OutgoingRequestMessage&&e.body)if(t=e.getHeader("Content-Disposition"),r=e.getHeader("Content-Type"),"string"==typeof e.body){if(!r)throw new Error("Header content type header does not equal body content type.");c=e.body}else{if(r&&r!==e.body.contentType)throw new Error("Header content type header does not equal body content type.");r=e.body.contentType,c=e.body.body}if(o(e)&&(t=e.contentDisposition,r=e.contentType,c=e.content),c){if(r&&!t&&(t=a(r)),!t)throw new Error("Content disposition undefined.");if(!r)throw new Error("Content type undefined.");return{contentDisposition:t,contentType:r,content:c}}},t.isBody=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(20),s=r(30),o=function(e){function t(r,i,n,s){var o=e.call(this)||this;return o.message=r,o.expected=i,o.found=n,o.location=s,o.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(o,t),o}return i.__extends(t,e),t.buildMessage=function(e,t){function r(e){return e.charCodeAt(0).toString(16).toUpperCase()}function i(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+r(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+r(e)})}function n(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+r(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+r(e)})}function s(e){switch(e.type){case"literal":return'"'+i(e.text)+'"';case"class":var t=e.parts.map(function(e){return Array.isArray(e)?n(e[0])+"-"+n(e[1]):n(e)});return"["+(e.inverted?"^":"")+t+"]";case"any":return"any character";case"end":return"end of input";case"other":return e.description}}return"Expected "+function(e){var t,r,i=e.map(s);if(i.sort(),i.length>0){for(t=1,r=1;t<i.length;t++)i[t-1]!==i[t]&&(i[r]=i[t],r++);i.length=r}switch(i.length){case 1:return i[0];case 2:return i[0]+" or "+i[1];default:return i.slice(0,-1).join(", ")+", or "+i[i.length-1]}}(e)+" but "+((o=t)?'"'+i(o)+'"':"end of input")+" found.";var o},t}(Error);t.SyntaxError=o,t.parse=function(e,t){t=void 0!==t?t:{};var r,i={},a={Contact:119,Name_Addr_Header:156,Record_Route:176,Request_Response:81,SIP_URI:45,Subscription_State:186,Supported:191,Require:182,Via:194,absoluteURI:84,Call_ID:118,Content_Disposition:130,Content_Length:135,Content_Type:136,CSeq:146,displayName:122,Event:149,From:151,host:52,Max_Forwards:154,Min_SE:213,Proxy_Authenticate:157,quoted_string:40,Refer_To:178,Replaces:179,Session_Expires:210,stun_URI:217,To:192,turn_URI:223,uuid:226,WWW_Authenticate:209,challenge:158,sipfrag:230,Referred_By:231},c=119,u=["\r\n",y("\r\n",!1),/^[0-9]/,T([["0","9"]],!1,!1),/^[a-zA-Z]/,T([["a","z"],["A","Z"]],!1,!1),/^[0-9a-fA-F]/,T([["0","9"],["a","f"],["A","F"]],!1,!1),/^[\0-\xFF]/,T([["\0","\xff"]],!1,!1),/^["]/,T(['"'],!1,!1)," ",y(" ",!1),"\t",y("\t",!1),/^[a-zA-Z0-9]/,T([["a","z"],["A","Z"],["0","9"]],!1,!1),";",y(";",!1),"/",y("/",!1),"?",y("?",!1),":",y(":",!1),"@",y("@",!1),"&",y("&",!1),"=",y("=",!1),"+",y("+",!1),"$",y("$",!1),",",y(",",!1),"-",y("-",!1),"_",y("_",!1),".",y(".",!1),"!",y("!",!1),"~",y("~",!1),"*",y("*",!1),"'",y("'",!1),"(",y("(",!1),")",y(")",!1),"%",y("%",!1),function(){return" "},function(){return":"},/^[!-~]/,T([["!","~"]],!1,!1),/^[\x80-\uFFFF]/,T([["\x80","\uffff"]],!1,!1),/^[\x80-\xBF]/,T([["\x80","\xbf"]],!1,!1),/^[a-f]/,T([["a","f"]],!1,!1),"`",y("`",!1),"<",y("<",!1),">",y(">",!1),"\\",y("\\",!1),"[",y("[",!1),"]",y("]",!1),"{",y("{",!1),"}",y("}",!1),function(){return"*"},function(){return"/"},function(){return"="},function(){return"("},function(){return")"},function(){return">"},function(){return"<"},function(){return","},function(){return";"},function(){return":"},function(){return'"'},/^[!-']/,T([["!","'"]],!1,!1),/^[*-[]/,T([["*","["]],!1,!1),/^[\]-~]/,T([["]","~"]],!1,!1),function(e){return e},/^[#-[]/,T([["#","["]],!1,!1),/^[\0-\t]/,T([["\0","\t"]],!1,!1),/^[\x0B-\f]/,T([["\v","\f"]],!1,!1),/^[\x0E-\x7F]/,T([["\x0e","\x7f"]],!1,!1),function(){(t=t||{data:{}}).data.uri=new s.URI(t.data.scheme,t.data.user,t.data.host,t.data.port),delete t.data.scheme,delete t.data.user,delete t.data.host,delete t.data.host_type,delete t.data.port},function(){(t=t||{data:{}}).data.uri=new s.URI(t.data.scheme,t.data.user,t.data.host,t.data.port,t.data.uri_params,t.data.uri_headers),delete t.data.scheme,delete t.data.user,delete t.data.host,delete t.data.host_type,delete t.data.port,delete t.data.uri_params,"SIP_URI"===t.startRule&&(t.data=t.data.uri)},"sips",y("sips",!0),"sip",y("sip",!0),function(e){(t=t||{data:{}}).data.scheme=e},function(){(t=t||{data:{}}).data.user=decodeURIComponent(m().slice(0,-1))},function(){(t=t||{data:{}}).data.password=m()},function(){return(t=t||{data:{}}).data.host=m(),t.data.host},function(){return(t=t||{data:{}}).data.host_type="domain",m()},/^[a-zA-Z0-9_\-]/,T([["a","z"],["A","Z"],["0","9"],"_","-"],!1,!1),/^[a-zA-Z0-9\-]/,T([["a","z"],["A","Z"],["0","9"],"-"],!1,!1),function(){return(t=t||{data:{}}).data.host_type="IPv6",m()},"::",y("::",!1),function(){return(t=t||{data:{}}).data.host_type="IPv6",m()},function(){return(t=t||{data:{}}).data.host_type="IPv4",m()},"25",y("25",!1),/^[0-5]/,T([["0","5"]],!1,!1),"2",y("2",!1),/^[0-4]/,T([["0","4"]],!1,!1),"1",y("1",!1),/^[1-9]/,T([["1","9"]],!1,!1),function(e){return t=t||{data:{}},e=parseInt(e.join("")),t.data.port=e,e},"transport=",y("transport=",!0),"udp",y("udp",!0),"tcp",y("tcp",!0),"sctp",y("sctp",!0),"tls",y("tls",!0),function(e){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),t.data.uri_params.transport=e.toLowerCase()},"user=",y("user=",!0),"phone",y("phone",!0),"ip",y("ip",!0),function(e){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),t.data.uri_params.user=e.toLowerCase()},"method=",y("method=",!0),function(e){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),t.data.uri_params.method=e},"ttl=",y("ttl=",!0),function(e){(t=t||{data:{}}).data.params||(t.data.params={}),t.data.params.ttl=e},"maddr=",y("maddr=",!0),function(e){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),t.data.uri_params.maddr=e},"lr",y("lr",!0),function(){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),t.data.uri_params.lr=void 0},function(e,r){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),r=null===r?void 0:r[1],t.data.uri_params[e.toLowerCase()]=r},function(e,r){e=e.join("").toLowerCase(),r=r.join(""),(t=t||{data:{}}).data.uri_headers||(t.data.uri_headers={}),t.data.uri_headers[e]?t.data.uri_headers[e].push(r):t.data.uri_headers[e]=[r]},function(){"Refer_To"===(t=t||{data:{}}).startRule&&(t.data.uri=new s.URI(t.data.scheme,t.data.user,t.data.host,t.data.port,t.data.uri_params,t.data.uri_headers),delete t.data.scheme,delete t.data.user,delete t.data.host,delete t.data.host_type,delete t.data.port,delete t.data.uri_params)},"//",y("//",!1),function(){(t=t||{data:{}}).data.scheme=m()},y("SIP",!0),function(){(t=t||{data:{}}).data.sip_version=m()},"INVITE",y("INVITE",!1),"ACK",y("ACK",!1),"VXACH",y("VXACH",!1),"OPTIONS",y("OPTIONS",!1),"BYE",y("BYE",!1),"CANCEL",y("CANCEL",!1),"REGISTER",y("REGISTER",!1),"SUBSCRIBE",y("SUBSCRIBE",!1),"NOTIFY",y("NOTIFY",!1),"REFER",y("REFER",!1),"PUBLISH",y("PUBLISH",!1),function(){return(t=t||{data:{}}).data.method=m(),t.data.method},function(e){(t=t||{data:{}}).data.status_code=parseInt(e.join(""))},function(){(t=t||{data:{}}).data.reason_phrase=m()},function(){(t=t||{data:{}}).data=m()},function(){var e,r;for(r=(t=t||{data:{}}).data.multi_header.length,e=0;e<r;e++)if(null===t.data.multi_header[e].parsed){t.data=null;break}null!==t.data?t.data=t.data.multi_header:t.data=-1},function(){var e;(t=t||{data:{}}).data.multi_header||(t.data.multi_header=[]);try{e=new n.NameAddrHeader(t.data.uri,t.data.displayName,t.data.params),delete t.data.uri,delete t.data.displayName,delete t.data.params}catch(t){e=null}t.data.multi_header.push({position:l,offset:S().start.offset,parsed:e})},function(e){'"'===(e=m().trim())[0]&&(e=e.substring(1,e.length-1)),(t=t||{data:{}}).data.displayName=e},"q",y("q",!0),function(e){(t=t||{data:{}}).data.params||(t.data.params={}),t.data.params.q=e},"expires",y("expires",!0),function(e){(t=t||{data:{}}).data.params||(t.data.params={}),t.data.params.expires=e},function(e){return parseInt(e.join(""))},"0",y("0",!1),function(){return parseFloat(m())},function(e,r){(t=t||{data:{}}).data.params||(t.data.params={}),r=null===r?void 0:r[1],t.data.params[e.toLowerCase()]=r},"render",y("render",!0),"session",y("session",!0),"icon",y("icon",!0),"alert",y("alert",!0),function(){"Content_Disposition"===(t=t||{data:{}}).startRule&&(t.data.type=m().toLowerCase())},"handling",y("handling",!0),"optional",y("optional",!0),"required",y("required",!0),function(e){(t=t||{data:{}}).data=parseInt(e.join(""))},function(){(t=t||{data:{}}).data=m()},"text",y("text",!0),"image",y("image",!0),"audio",y("audio",!0),"video",y("video",!0),"application",y("application",!0),"message",y("message",!0),"multipart",y("multipart",!0),"x-",y("x-",!0),function(e){(t=t||{data:{}}).data.value=parseInt(e.join(""))},function(e){(t=t||{data:{}}).data=e},function(e){(t=t||{data:{}}).data.event=e.toLowerCase()},function(){var e=(t=t||{data:{}}).data.tag;t.data=new n.NameAddrHeader(t.data.uri,t.data.displayName,t.data.params),e&&t.data.setParam("tag",e)},"tag",y("tag",!0),function(e){(t=t||{data:{}}).data.tag=e},function(e){(t=t||{data:{}}).data=parseInt(e.join(""))},function(e){(t=t||{data:{}}).data=e},function(){(t=t||{data:{}}).data=new n.NameAddrHeader(t.data.uri,t.data.displayName,t.data.params)},"digest",y("Digest",!0),"realm",y("realm",!0),function(e){(t=t||{data:{}}).data.realm=e},"domain",y("domain",!0),"nonce",y("nonce",!0),function(e){(t=t||{data:{}}).data.nonce=e},"opaque",y("opaque",!0),function(e){(t=t||{data:{}}).data.opaque=e},"stale",y("stale",!0),"true",y("true",!0),function(){(t=t||{data:{}}).data.stale=!0},"false",y("false",!0),function(){(t=t||{data:{}}).data.stale=!1},"algorithm",y("algorithm",!0),"md5",y("MD5",!0),"md5-sess",y("MD5-sess",!0),function(e){(t=t||{data:{}}).data.algorithm=e.toUpperCase()},"qop",y("qop",!0),"auth-int",y("auth-int",!0),"auth",y("auth",!0),function(e){(t=t||{data:{}}).data.qop||(t.data.qop=[]),t.data.qop.push(e.toLowerCase())},function(e){(t=t||{data:{}}).data.value=parseInt(e.join(""))},function(){var e,r;for(r=(t=t||{data:{}}).data.multi_header.length,e=0;e<r;e++)if(null===t.data.multi_header[e].parsed){t.data=null;break}null!==t.data?t.data=t.data.multi_header:t.data=-1},function(){var e;(t=t||{data:{}}).data.multi_header||(t.data.multi_header=[]);try{e=new n.NameAddrHeader(t.data.uri,t.data.displayName,t.data.params),delete t.data.uri,delete t.data.displayName,delete t.data.params}catch(t){e=null}t.data.multi_header.push({position:l,offset:S().start.offset,parsed:e})},function(){(t=t||{data:{}}).data=new n.NameAddrHeader(t.data.uri,t.data.displayName,t.data.params)},function(){(t=t||{data:{}}).data.replaces_from_tag&&t.data.replaces_to_tag||(t.data=-1)},function(){(t=t||{data:{}}).data={call_id:t.data}},"from-tag",y("from-tag",!0),function(e){(t=t||{data:{}}).data.replaces_from_tag=e},"to-tag",y("to-tag",!0),function(e){(t=t||{data:{}}).data.replaces_to_tag=e},"early-only",y("early-only",!0),function(){(t=t||{data:{}}).data.early_only=!0},function(e,t){return t},function(e,t){return function(e,t){return[e].concat(t)}(e,t)},function(e){"Require"===(t=t||{data:{}}).startRule&&(t.data=e||[])},function(e){(t=t||{data:{}}).data.value=parseInt(e.join(""))},"active",y("active",!0),"pending",y("pending",!0),"terminated",y("terminated",!0),function(){(t=t||{data:{}}).data.state=m()},"reason",y("reason",!0),function(e){t=t||{data:{}},void 0!==e&&(t.data.reason=e)},function(e){t=t||{data:{}},void 0!==e&&(t.data.expires=e)},"retry_after",y("retry_after",!0),function(e){t=t||{data:{}},void 0!==e&&(t.data.retry_after=e)},"deactivated",y("deactivated",!0),"probation",y("probation",!0),"rejected",y("rejected",!0),"timeout",y("timeout",!0),"giveup",y("giveup",!0),"noresource",y("noresource",!0),"invariant",y("invariant",!0),function(e){"Supported"===(t=t||{data:{}}).startRule&&(t.data=e||[])},function(){var e=(t=t||{data:{}}).data.tag;t.data=new n.NameAddrHeader(t.data.uri,t.data.displayName,t.data.params),e&&t.data.setParam("tag",e)},"ttl",y("ttl",!0),function(e){(t=t||{data:{}}).data.ttl=e},"maddr",y("maddr",!0),function(e){(t=t||{data:{}}).data.maddr=e},"received",y("received",!0),function(e){(t=t||{data:{}}).data.received=e},"branch",y("branch",!0),function(e){(t=t||{data:{}}).data.branch=e},"rport",y("rport",!0),function(e){t=t||{data:{}},void 0!==e&&(t.data.rport=e.join(""))},function(e){(t=t||{data:{}}).data.protocol=e},y("UDP",!0),y("TCP",!0),y("TLS",!0),y("SCTP",!0),function(e){(t=t||{data:{}}).data.transport=e},function(){(t=t||{data:{}}).data.host=m()},function(e){(t=t||{data:{}}).data.port=parseInt(e.join(""))},function(e){return parseInt(e.join(""))},function(e){"Session_Expires"===(t=t||{data:{}}).startRule&&(t.data.deltaSeconds=e)},"refresher",y("refresher",!1),"uas",y("uas",!1),"uac",y("uac",!1),function(e){"Session_Expires"===(t=t||{data:{}}).startRule&&(t.data.refresher=e)},function(e){"Min_SE"===(t=t||{data:{}}).startRule&&(t.data=e)},"stuns",y("stuns",!0),"stun",y("stun",!0),function(e){(t=t||{data:{}}).data.scheme=e},function(e){(t=t||{data:{}}).data.host=e},"?transport=",y("?transport=",!1),"turns",y("turns",!0),"turn",y("turn",!0),function(e){(t=t||{data:{}}).data.transport=e},function(){(t=t||{data:{}}).data=m()},"Referred-By",y("Referred-By",!1),"b",y("b",!1),"cid",y("cid",!1)],d=[w('2 ""6 7!'),w('4"""5!7#'),w('4$""5!7%'),w('4&""5!7\''),w(";'.# &;("),w('4(""5!7)'),w('4*""5!7+'),w('2,""6,7-'),w('2.""6.7/'),w('40""5!71'),w('22""6273.\x89 &24""6475.} &26""6677.q &28""6879.e &2:""6:7;.Y &2<""6<7=.M &2>""6>7?.A &2@""[email protected] &2B""6B7C.) &2D""6D7E'),w(";).# &;,"),w('2F""6F7G.} &2H""6H7I.q &2J""6J7K.e &2L""6L7M.Y &2N""6N7O.M &2P""6P7Q.A &2R""6R7S.5 &2T""6T7U.) &2V""6V7W'),w('%%2X""6X7Y/5#;#/,$;#/#$+#)(#\'#("\'#&\'#/"!&,)'),w('%%$;$0#*;$&/,#; /#$+")("\'#&\'#." &"/=#$;$/�#*;$&&&#/\'$8":Z" )("\'#&\'#'),w(';.." &"'),w("%$;'.# &;(0)*;'.# &;(&/?#28\"\"6879/0$;//'$8#:[# )(#'#(\"'#&'#"),w('%%$;2/�#*;2&&&#/g#$%$;.0#*;.&/,#;2/#$+")("\'#&\'#0=*%$;.0#*;.&/,#;2/#$+")("\'#&\'#&/#$+")("\'#&\'#/"!&,)'),w('4\\""5!7].# &;3'),w('4^""5!7_'),w('4`""5!7a'),w(';!.) &4b""5!7c'),w('%$;).\x95 &2F""6F7G.\x89 &2J""6J7K.} &2L""6L7M.q &2X""6X7Y.e &2P""6P7Q.Y &2H""6H7I.M &2@""[email protected] &2d""6d7e.5 &2R""6R7S.) &2N""6N7O/\x9e#0\x9b*;).\x95 &2F""6F7G.\x89 &2J""6J7K.} &2L""6L7M.q &2X""6X7Y.e &2P""6P7Q.Y &2H""6H7I.M &2@""[email protected] &2d""6d7e.5 &2R""6R7S.) &2N""6N7O&&&#/"!&,)'),w('%$;).\x89 &2F""6F7G.} &2L""6L7M.q &2X""6X7Y.e &2P""6P7Q.Y &2H""6H7I.M &2@""[email protected] &2d""6d7e.5 &2R""6R7S.) &2N""6N7O/\x92#0\x8f*;).\x89 &2F""6F7G.} &2L""6L7M.q &2X""6X7Y.e &2P""6P7Q.Y &2H""6H7I.M &2@""[email protected] &2d""6d7e.5 &2R""6R7S.) &2N""6N7O&&&#/"!&,)'),w('2T""6T7U.\xe3 &2V""6V7W.\xd7 &2f""6f7g.\xcb &2h""6h7i.\xbf &2:""6:7;.\xb3 &2D""6D7E.\xa7 &22""6273.\x9b &28""6879.\x8f &2j""6j7k.\x83 &;&.} &24""6475.q &2l""6l7m.e &2n""6n7o.Y &26""6677.M &2>""6>7?.A &2p""6p7q.5 &2r""6r7s.) &;\'.# &;('),w('%$;).\u012b &2F""6F7G.\u011f &2J""6J7K.\u0113 &2L""6L7M.\u0107 &2X""6X7Y.\xfb &2P""6P7Q.\xef &2H""6H7I.\xe3 &2@""6@7A.\xd7 &2d""6d7e.\xcb &2R""6R7S.\xbf &2N""6N7O.\xb3 &2T""6T7U.\xa7 &2V""6V7W.\x9b &2f""6f7g.\x8f &2h""6h7i.\x83 &28""6879.w &2j""6j7k.k &;&.e &24""6475.Y &2l""6l7m.M &2n""6n7o.A &26""6677.5 &2p""6p7q.) &2r""6r7s/\u0134#0\u0131*;).\u012b &2F""6F7G.\u011f &2J""6J7K.\u0113 &2L""6L7M.\u0107 &2X""6X7Y.\xfb &2P""6P7Q.\xef &2H""6H7I.\xe3 &2@""6@7A.\xd7 &2d""6d7e.\xcb &2R""6R7S.\xbf &2N""6N7O.\xb3 &2T""6T7U.\xa7 &2V""6V7W.\x9b &2f""6f7g.\x8f &2h""6h7i.\x83 &28""6879.w &2j""6j7k.k &;&.e &24""6475.Y &2l""6l7m.M &2n""6n7o.A &26""6677.5 &2p""6p7q.) &2r""6r7s&&&#/"!&,)'),w("%;//?#2P\"\"6P7Q/0$;//'$8#:t# )(#'#(\"'#&'#"),w("%;//?#24\"\"6475/0$;//'$8#:u# )(#'#(\"'#&'#"),w("%;//?#2>\"\"6>7?/0$;//'$8#:v# )(#'#(\"'#&'#"),w("%;//?#2T\"\"6T7U/0$;//'$8#:w# )(#'#(\"'#&'#"),w("%;//?#2V\"\"6V7W/0$;//'$8#:x# )(#'#(\"'#&'#"),w('%2h""6h7i/0#;//\'$8":y" )("\'#&\'#'),w('%;//6#2f""6f7g/\'$8":z" )("\'#&\'#'),w("%;//?#2D\"\"6D7E/0$;//'$8#:{# )(#'#(\"'#&'#"),w("%;//?#22\"\"6273/0$;//'$8#:|# )(#'#(\"'#&'#"),w("%;//?#28\"\"6879/0$;//'$8#:}# )(#'#(\"'#&'#"),w("%;//0#;&/'$8\":~\" )(\"'#&'#"),w("%;&/0#;//'$8\":~\" )(\"'#&'#"),w("%;=/T#$;G.) &;K.# &;F0/*;G.) &;K.# &;F&/,$;>/#$+#)(#'#(\"'#&'#"),w('4\x7f""5!7\x80.A &4\x81""5!7\x82.5 &4\x83""5!7\x84.) &;3.# &;.'),w("%%;//Q#;&/H$$;J.# &;K0)*;J.# &;K&/,$;&/#$+$)($'#(#'#(\"'#&'#/\"!&,)"),w("%;//]#;&/T$%$;J.# &;K0)*;J.# &;K&/\"!&,)/1$;&/($8$:\x85$!!)($'#(#'#(\"'#&'#"),w(';..G &2L""6L7M.; &4\x86""5!7\x87./ &4\x83""5!7\x84.# &;3'),w('%2j""6j7k/J#4\x88""5!7\x89.5 &4\x8a""5!7\x8b.) &4\x8c""5!7\x8d/#$+")("\'#&\'#'),w("%;N/M#28\"\"6879/>$;O.\" &\"/0$;S/'$8$:\x8e$ )($'#(#'#(\"'#&'#"),w("%;N/d#28\"\"6879/U$;O.\" &\"/G$;S/>$;_/5$;l.\" &\"/'$8&:\x8f& )(&'#(%'#($'#(#'#(\"'#&'#"),w('%3\x90""5$7\x91.) &3\x92""5#7\x93/\' 8!:\x94!! )'),w('%;P/]#%28""6879/,#;R/#$+")("\'#&\'#." &"/6$2:""6:7;/\'$8#:\x95# )(#\'#("\'#&\'#'),w("$;+.) &;-.# &;Q/2#0/*;+.) &;-.# &;Q&&&#"),w('2<""6<7=.q &2>""6>7?.e &2@""[email protected] &2B""6B7C.M &2D""6D7E.A &22""6273.5 &26""6677.) &24""6475'),w('%$;+._ &;-.Y &2<""6<7=.M &2>""6>7?.A &2@""[email protected] &2B""6B7C.) &2D""6D7E0e*;+._ &;-.Y &2<""6<7=.M &2>""6>7?.A &2@""[email protected] &2B""6B7C.) &2D""6D7E&/& 8!:\x96! )'),w('%;T/J#%28""6879/,#;^/#$+")("\'#&\'#." &"/#$+")("\'#&\'#'),w("%;U.) &;\\.# &;X/& 8!:\x97! )"),w('%$%;V/2#2J""6J7K/#$+")("\'#&\'#0<*%;V/2#2J""6J7K/#$+")("\'#&\'#&/D#;W/;$2J""6J7K." &"/\'$8#:\x98# )(#\'#("\'#&\'#'),w('$4\x99""5!7\x9a/,#0)*4\x99""5!7\x9a&&&#'),w('%4$""5!7%/?#$4\x9b""5!7\x9c0)*4\x9b""5!7\x9c&/#$+")("\'#&\'#'),w('%2l""6l7m/?#;Y/6$2n""6n7o/\'$8#:\x9d# )(#\'#("\'#&\'#'),w('%%;Z/\xb3#28""6879/\xa4$;Z/\x9b$28""6879/\x8c$;Z/\x83$28""6879/t$;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+-)(-\'#(,\'#(+\'#(*\'#()\'#((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.\u0790 &%2\x9e""6\x9e7\x9f/\xa4#;Z/\x9b$28""6879/\x8c$;Z/\x83$28""6879/t$;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+,)(,\'#(+\'#(*\'#()\'#((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.\u06f9 &%2\x9e""6\x9e7\x9f/\x8c#;Z/\x83$28""6879/t$;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+*)(*\'#()\'#((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.\u067a &%2\x9e""6\x9e7\x9f/t#;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+()((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.\u0613 &%2\x9e""6\x9e7\x9f/\\#;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+&)(&\'#(%\'#($\'#(#\'#("\'#&\'#.\u05c4 &%2\x9e""6\x9e7\x9f/D#;Z/;$28""6879/,$;[/#$+$)($\'#(#\'#("\'#&\'#.\u058d &%2\x9e""6\x9e7\x9f/,#;[/#$+")("\'#&\'#.\u056e &%2\x9e""6\x9e7\x9f/,#;Z/#$+")("\'#&\'#.\u054f &%;Z/\x9b#2\x9e""6\x9e7\x9f/\x8c$;Z/\x83$28""6879/t$;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$++)(+\'#(*\'#()\'#((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.\u04c7 &%;Z/\xaa#%28""6879/,#;Z/#$+")("\'#&\'#." &"/\x83$2\x9e""6\x9e7\x9f/t$;Z/k$28""6879/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+*)(*\'#()\'#((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.\u0430 &%;Z/\xb9#%28""6879/,#;Z/#$+")("\'#&\'#." &"/\x92$%28""6879/,#;Z/#$+")("\'#&\'#." &"/k$2\x9e""6\x9e7\x9f/\\$;Z/S$28""6879/D$;Z/;$28""6879/,$;[/#$+))()\'#((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.\u038a &%;Z/\xc8#%28""6879/,#;Z/#$+")("\'#&\'#." &"/\xa1$%28""6879/,#;Z/#$+")("\'#&\'#." &"/z$%28""6879/,#;Z/#$+")("\'#&\'#." &"/S$2\x9e""6\x9e7\x9f/D$;Z/;$28""6879/,$;[/#$+()((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.\u02d5 &%;Z/\xd7#%28""6879/,#;Z/#$+")("\'#&\'#." &"/\xb0$%28""6879/,#;Z/#$+")("\'#&\'#." &"/\x89$%28""6879/,#;Z/#$+")("\'#&\'#." &"/b$%28""6879/,#;Z/#$+")("\'#&\'#." &"/;$2\x9e""6\x9e7\x9f/,$;[/#$+\')(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.\u0211 &%;Z/\xfe#%28""6879/,#;Z/#$+")("\'#&\'#." &"/\xd7$%28""6879/,#;Z/#$+")("\'#&\'#." &"/\xb0$%28""6879/,#;Z/#$+")("\'#&\'#." &"/\x89$%28""6879/,#;Z/#$+")("\'#&\'#." &"/b$%28""6879/,#;Z/#$+")("\'#&\'#." &"/;$2\x9e""6\x9e7\x9f/,$;Z/#$+()((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#.\u0126 &%;Z/\u011c#%28""6879/,#;Z/#$+")("\'#&\'#." &"/\xf5$%28""6879/,#;Z/#$+")("\'#&\'#." &"/\xce$%28""6879/,#;Z/#$+")("\'#&\'#." &"/\xa7$%28""6879/,#;Z/#$+")("\'#&\'#." &"/\x80$%28""6879/,#;Z/#$+")("\'#&\'#." &"/Y$%28""6879/,#;Z/#$+")("\'#&\'#." &"/2$2\x9e""6\x9e7\x9f/#$+()((\'#(\'\'#(&\'#(%\'#($\'#(#\'#("\'#&\'#/& 8!:\xa0! )'),w('%;#/M#;#." &"/?$;#." &"/1$;#." &"/#$+$)($\'#(#\'#("\'#&\'#'),w("%;Z/;#28\"\"6879/,$;Z/#$+#)(#'#(\"'#&'#.# &;\\"),w("%;]/o#2J\"\"6J7K/`$;]/W$2J\"\"6J7K/H$;]/?$2J\"\"6J7K/0$;]/'$8':\xa1' )(''#(&'#(%'#($'#(#'#(\"'#&'#"),w('%2\xa2""6\xa27\xa3/2#4\xa4""5!7\xa5/#$+")("\'#&\'#.\x98 &%2\xa6""6\xa67\xa7/;#4\xa8""5!7\xa9/,$;!/#$+#)(#\'#("\'#&\'#.j &%2\xaa""6\xaa7\xab/5#;!/,$;!/#$+#)(#\'#("\'#&\'#.B &%4\xac""5!7\xad/,#;!/#$+")("\'#&\'#.# &;!'),w('%%;!." &"/[#;!." &"/M$;!." &"/?$;!." &"/1$;!." &"/#$+%)(%\'#($\'#(#\'#("\'#&\'#/\' 8!:\xae!! )'),w('$%22""6273/,#;`/#$+")("\'#&\'#0<*%22""6273/,#;`/#$+")("\'#&\'#&'),w(";a.A &;b.; &;c.5 &;d./ &;e.) &;f.# &;g"),w('%3\xaf""5*7\xb0/a#3\xb1""5#7\xb2.G &3\xb3""5#7\xb4.; &3\xb5""5$7\xb6./ &3\xb7""5#7\xb8.# &;6/($8":\xb9"! )("\'#&\'#'),w('%3\xba""5%7\xbb/I#3\xbc""5%7\xbd./ &3\xbe""5"7\xbf.# &;6/($8":\xc0"! )("\'#&\'#'),w('%3\xc1""5\'7\xc2/1#;\x90/($8":\xc3"! )("\'#&\'#'),w('%3\xc4""5$7\xc5/1#;\xf0/($8":\xc6"! )("\'#&\'#'),w('%3\xc7""5&7\xc8/1#;T/($8":\xc9"! )("\'#&\'#'),w('%3\xca""5"7\xcb/N#%2>""6>7?/,#;6/#$+")("\'#&\'#." &"/\'$8":\xcc" )("\'#&\'#'),w('%;h/P#%2>""6>7?/,#;i/#$+")("\'#&\'#." &"/)$8":\xcd""! )("\'#&\'#'),w('%$;j/�#*;j&&&#/"!&,)'),w('%$;j/�#*;j&&&#/"!&,)'),w(";k.) &;+.# &;-"),w('2l""6l7m.e &2n""6n7o.Y &24""6475.M &28""6879.A &2<""6<7=.5 &2@""6@7A.) &2B""6B7C'),w('%26""6677/n#;m/e$$%2<""6<7=/,#;m/#$+")("\'#&\'#0<*%2<""6<7=/,#;m/#$+")("\'#&\'#&/#$+#)(#\'#("\'#&\'#'),w('%;n/A#2>""6>7?/2$;o/)$8#:\xce#"" )(#\'#("\'#&\'#'),w("$;p.) &;+.# &;-/2#0/*;p.) &;+.# &;-&&&#"),w("$;p.) &;+.# &;-0/*;p.) &;+.# &;-&"),w('2l""6l7m.e &2n""6n7o.Y &24""6475.M &26""6677.A &28""6879.5 &2@""6@7A.) &2B""6B7C'),w(";\x91.# &;r"),w("%;\x90/G#;'/>$;s/5$;'/,$;\x84/#$+%)(%'#($'#(#'#(\"'#&'#"),w(";M.# &;t"),w("%;\x7f/E#28\"\"6879/6$;u.# &;x/'$8#:\xcf# )(#'#(\"'#&'#"),w('%;v.# &;w/J#%26""6677/,#;\x83/#$+")("\'#&\'#." &"/#$+")("\'#&\'#'),w('%2\xd0""6\xd07\xd1/:#;\x80/1$;w." &"/#$+#)(#\'#("\'#&\'#'),w('%24""6475/,#;{/#$+")("\'#&\'#'),w("%;z/3#$;y0#*;y&/#$+\")(\"'#&'#"),w(";*.) &;+.# &;-"),w(';+.\x8f &;-.\x89 &22""6273.} &26""6677.q &28""6879.e &2:""6:7;.Y &2<""6<7=.M &2>""6>7?.A &2@""[email protected] &2B""6B7C.) &2D""6D7E'),w('%;|/e#$%24""6475/,#;|/#$+")("\'#&\'#0<*%24""6475/,#;|/#$+")("\'#&\'#&/#$+")("\'#&\'#'),w('%$;~0#*;~&/e#$%22""6273/,#;}/#$+")("\'#&\'#0<*%22""6273/,#;}/#$+")("\'#&\'#&/#$+")("\'#&\'#'),w("$;~0#*;~&"),w(';+.w &;-.q &28""6879.e &2:""6:7;.Y &2<""6<7=.M &2>""6>7?.A &2@""[email protected] &2B""6B7C.) &2D""6D7E'),w('%%;"/\x87#$;".G &;!.A &2@""[email protected] &2F""6F7G.) &2J""6J7K0M*;".G &;!.A &2@""[email protected] &2F""6F7G.) &2J""6J7K&/#$+")("\'#&\'#/& 8!:\xd2! )'),w(";\x81.# &;\x82"),w('%%;O/2#2:""6:7;/#$+")("\'#&\'#." &"/,#;S/#$+")("\'#&\'#." &"'),w('$;+.\x83 &;-.} &2B""6B7C.q &2D""6D7E.e &22""6273.Y &28""6879.M &2:""6:7;.A &2<""6<7=.5 &2>""6>7?.) &2@""6@7A/\x8c#0\x89*;+.\x83 &;-.} &2B""6B7C.q &2D""6D7E.e &22""6273.Y &28""6879.M &2:""6:7;.A &2<""6<7=.5 &2>""6>7?.) &2@""6@7A&&&#'),w("$;y0#*;y&"),w('%3\x92""5#7\xd3/q#24""6475/b$$;!/�#*;!&&&#/L$2J""6J7K/=$$;!/�#*;!&&&#/\'$8%:\xd4% )(%\'#($\'#(#\'#("\'#&\'#'),w('2\xd5""6\xd57\xd6'),w('2\xd7""6\xd77\xd8'),w('2\xd9""6\xd97\xda'),w('2\xdb""6\xdb7\xdc'),w('2\xdd""6\xdd7\xde'),w('2\xdf""6\xdf7\xe0'),w('2\xe1""6\xe17\xe2'),w('2\xe3""6\xe37\xe4'),w('2\xe5""6\xe57\xe6'),w('2\xe7""6\xe77\xe8'),w('2\xe9""6\xe97\xea'),w("%;\x85.Y &;\x86.S &;\x88.M &;\x89.G &;\x8a.A &;\x8b.; &;\x8c.5 &;\x8f./ &;\x8d.) &;\x8e.# &;6/& 8!:\xeb! )"),w("%;\x84/G#;'/>$;\x92/5$;'/,$;\x94/#$+%)(%'#($'#(#'#(\"'#&'#"),w("%;\x93/' 8!:\xec!! )"),w("%;!/5#;!/,$;!/#$+#)(#'#(\"'#&'#"),w("%$;*.A &;+.; &;-.5 &;3./ &;4.) &;'.# &;(0G*;*.A &;+.; &;-.5 &;3./ &;4.) &;'.# &;(&/& 8!:\xed! )"),w("%;\xb6/Y#$%;A/,#;\xb6/#$+\")(\"'#&'#06*%;A/,#;\xb6/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),w('%;9/N#%2:""6:7;/,#;9/#$+")("\'#&\'#." &"/\'$8":\xee" )("\'#&\'#'),w("%;:.c &%;\x98/Y#$%;A/,#;\x98/#$+\")(\"'#&'#06*%;A/,#;\x98/#$+\")(\"'#&'#&/#$+\")(\"'#&'#/& 8!:\xef! )"),w("%;L.# &;\x99/]#$%;B/,#;\x9b/#$+\")(\"'#&'#06*%;B/,#;\x9b/#$+\")(\"'#&'#&/'$8\":\xf0\" )(\"'#&'#"),w("%;\x9a.\" &\"/>#;@/5$;M/,$;?/#$+$)($'#(#'#(\"'#&'#"),w("%%;6/Y#$%;./,#;6/#$+\")(\"'#&'#06*%;./,#;6/#$+\")(\"'#&'#&/#$+\")(\"'#&'#.# &;H/' 8!:\xf1!! )"),w(";\x9c.) &;\x9d.# &;\xa0"),w("%3\xf2\"\"5!7\xf3/:#;</1$;\x9f/($8#:\xf4#! )(#'#(\"'#&'#"),w("%3\xf5\"\"5'7\xf6/:#;</1$;\x9e/($8#:\xf7#! )(#'#(\"'#&'#"),w("%$;!/�#*;!&&&#/' 8!:\xf8!! )"),w('%2\xf9""6\xf97\xfa/o#%2J""6J7K/M#;!." &"/?$;!." &"/1$;!." &"/#$+$)($\'#(#\'#("\'#&\'#." &"/\'$8":\xfb" )("\'#&\'#'),w('%;6/J#%;</,#;\xa1/#$+")("\'#&\'#." &"/)$8":\xfc""! )("\'#&\'#'),w(";6.) &;T.# &;H"),w("%;\xa3/Y#$%;B/,#;\xa4/#$+\")(\"'#&'#06*%;B/,#;\xa4/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),w('%3\xfd""5&7\xfe.G &3\xff""5\'7\u0100.; &3\u0101""5$7\u0102./ &3\u0103""5%7\u0104.# &;6/& 8!:\u0105! )'),w(";\xa5.# &;\xa0"),w('%3\u0106""5(7\u0107/M#;</D$3\u0108""5(7\u0109./ &3\u010a""5(7\u010b.# &;6/#$+#)(#\'#("\'#&\'#'),w("%;6/Y#$%;A/,#;6/#$+\")(\"'#&'#06*%;A/,#;6/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),w("%$;!/�#*;!&&&#/' 8!:\u010c!! )"),w("%;\xa9/& 8!:\u010d! )"),w("%;\xaa/k#;;/b$;\xaf/Y$$%;B/,#;\xb0/#$+\")(\"'#&'#06*%;B/,#;\xb0/#$+\")(\"'#&'#&/#$+$)($'#(#'#(\"'#&'#"),w(";\xab.# &;\xac"),w('3\u010e""5$7\u010f.S &3\u0110""5%7\u0111.G &3\u0112""5%7\u0113.; &3\u0114""5%7\u0115./ &3\u0116""5+7\u0117.# &;\xad'),w('3\u0118""5\'7\u0119./ &3\u011a""5)7\u011b.# &;\xad'),w(";6.# &;\xae"),w('%3\u011c""5"7\u011d/,#;6/#$+")("\'#&\'#'),w(";\xad.# &;6"),w("%;6/5#;</,$;\xb1/#$+#)(#'#(\"'#&'#"),w(";6.# &;H"),w("%;\xb3/5#;./,$;\x90/#$+#)(#'#(\"'#&'#"),w("%$;!/�#*;!&&&#/' 8!:\u011e!! )"),w("%;\x9e/' 8!:\u011f!! )"),w('%;\xb6/^#$%;B/,#;\xa0/#$+")("\'#&\'#06*%;B/,#;\xa0/#$+")("\'#&\'#&/($8":\u0120"!!)("\'#&\'#'),w('%%;7/e#$%2J""6J7K/,#;7/#$+")("\'#&\'#0<*%2J""6J7K/,#;7/#$+")("\'#&\'#&/#$+")("\'#&\'#/"!&,)'),w("%;L.# &;\x99/]#$%;B/,#;\xb8/#$+\")(\"'#&'#06*%;B/,#;\xb8/#$+\")(\"'#&'#&/'$8\":\u0121\" )(\"'#&'#"),w(";\xb9.# &;\xa0"),w("%3\u0122\"\"5#7\u0123/:#;</1$;6/($8#:\u0124#! )(#'#(\"'#&'#"),w("%$;!/�#*;!&&&#/' 8!:\u0125!! )"),w("%;\x9e/' 8!:\u0126!! )"),w("%$;\x9a0#*;\x9a&/x#;@/o$;M/f$;?/]$$%;B/,#;\xa0/#$+\")(\"'#&'#06*%;B/,#;\xa0/#$+\")(\"'#&'#&/'$8%:\u0127% )(%'#($'#(#'#(\"'#&'#"),w(";\xbe"),w("%3\u0128\"\"5&7\u0129/k#;./b$;\xc1/Y$$%;A/,#;\xc1/#$+\")(\"'#&'#06*%;A/,#;\xc1/#$+\")(\"'#&'#&/#$+$)($'#(#'#(\"'#&'#.# &;\xbf"),w("%;6/k#;./b$;\xc0/Y$$%;A/,#;\xc0/#$+\")(\"'#&'#06*%;A/,#;\xc0/#$+\")(\"'#&'#&/#$+$)($'#(#'#(\"'#&'#"),w("%;6/;#;</2$;6.# &;H/#$+#)(#'#(\"'#&'#"),w(";\xc2.G &;\xc4.A &;\xc6.; &;\xc8.5 &;\xc9./ &;\xca.) &;\xcb.# &;\xc0"),w("%3\u012a\"\"5%7\u012b/5#;</,$;\xc3/#$+#)(#'#(\"'#&'#"),w("%;I/' 8!:\u012c!! )"),w("%3\u012d\"\"5&7\u012e/\x97#;</\x8e$;D/\x85$;\xc5/|$$%$;'/�#*;'&&&#/,#;\xc5/#$+\")(\"'#&'#0C*%$;'/�#*;'&&&#/,#;\xc5/#$+\")(\"'#&'#&/,$;E/#$+&)(&'#(%'#($'#(#'#(\"'#&'#"),w(";t.# &;w"),w("%3\u012f\"\"5%7\u0130/5#;</,$;\xc7/#$+#)(#'#(\"'#&'#"),w("%;I/' 8!:\u0131!! )"),w("%3\u0132\"\"5&7\u0133/:#;</1$;I/($8#:\u0134#! )(#'#(\"'#&'#"),w('%3\u0135""5%7\u0136/]#;</T$%3\u0137""5$7\u0138/& 8!:\u0139! ).4 &%3\u013a""5%7\u013b/& 8!:\u013c! )/#$+#)(#\'#("\'#&\'#'),w('%3\u013d""5)7\u013e/R#;</I$3\u013f""5#7\u0140./ &3\u0141""5(7\u0142.# &;6/($8#:\u0143#! )(#\'#("\'#&\'#'),w('%3\u0144""5#7\u0145/\x93#;</\x8a$;D/\x81$%;\xcc/e#$%2D""6D7E/,#;\xcc/#$+")("\'#&\'#0<*%2D""6D7E/,#;\xcc/#$+")("\'#&\'#&/#$+")("\'#&\'#/,$;E/#$+%)(%\'#($\'#(#\'#("\'#&\'#'),w('%3\u0146""5(7\u0147./ &3\u0148""5$7\u0149.# &;6/\' 8!:\u014a!! )'),w("%;6/Y#$%;A/,#;6/#$+\")(\"'#&'#06*%;A/,#;6/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),w("%;\xcf/G#;./>$;\xcf/5$;./,$;\x90/#$+%)(%'#($'#(#'#(\"'#&'#"),w("%$;!/�#*;!&&&#/' 8!:\u014b!! )"),w("%;\xd1/]#$%;A/,#;\xd1/#$+\")(\"'#&'#06*%;A/,#;\xd1/#$+\")(\"'#&'#&/'$8\":\u014c\" )(\"'#&'#"),w("%;\x99/]#$%;B/,#;\xa0/#$+\")(\"'#&'#06*%;B/,#;\xa0/#$+\")(\"'#&'#&/'$8\":\u014d\" )(\"'#&'#"),w('%;L.O &;\x99.I &%;@." &"/:#;t/1$;?." &"/#$+#)(#\'#("\'#&\'#/]#$%;B/,#;\xa0/#$+")("\'#&\'#06*%;B/,#;\xa0/#$+")("\'#&\'#&/\'$8":\u014e" )("\'#&\'#'),w("%;\xd4/]#$%;B/,#;\xd5/#$+\")(\"'#&'#06*%;B/,#;\xd5/#$+\")(\"'#&'#&/'$8\":\u014f\" )(\"'#&'#"),w("%;\x96/& 8!:\u0150! )"),w('%3\u0151""5(7\u0152/:#;</1$;6/($8#:\u0153#! )(#\'#("\'#&\'#.g &%3\u0154""5&7\u0155/:#;</1$;6/($8#:\u0156#! )(#\'#("\'#&\'#.: &%3\u0157""5*7\u0158/& 8!:\u0159! ).# &;\xa0'),w('%%;6/k#$%;A/2#;6/)$8":\u015a""$ )("\'#&\'#0<*%;A/2#;6/)$8":\u015a""$ )("\'#&\'#&/)$8":\u015b""! )("\'#&\'#." &"/\' 8!:\u015c!! )'),w("%;\xd8/Y#$%;A/,#;\xd8/#$+\")(\"'#&'#06*%;A/,#;\xd8/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),w("%;\x99/Y#$%;B/,#;\xa0/#$+\")(\"'#&'#06*%;B/,#;\xa0/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),w("%$;!/�#*;!&&&#/' 8!:\u015d!! )"),w("%;\xdb/Y#$%;B/,#;\xdc/#$+\")(\"'#&'#06*%;B/,#;\xdc/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),w('%3\u015e""5&7\u015f.; &3\u0160""5\'7\u0161./ &3\u0162""5*7\u0163.# &;6/& 8!:\u0164! )'),w("%3\u0165\"\"5&7\u0166/:#;</1$;\xdd/($8#:\u0167#! )(#'#(\"'#&'#.} &%3\xf5\"\"5'7\xf6/:#;</1$;\x9e/($8#:\u0168#! )(#'#(\"'#&'#.P &%3\u0169\"\"5+7\u016a/:#;</1$;\x9e/($8#:\u016b#! )(#'#(\"'#&'#.# &;\xa0"),w('3\u016c""5+7\u016d.k &3\u016e""5)7\u016f._ &3\u0170""5(7\u0171.S &3\u0172""5\'7\u0173.G &3\u0174""5&7\u0175.; &3\u0176""5*7\u0177./ &3\u0178""5)7\u0179.# &;6'),w(';1." &"'),w('%%;6/k#$%;A/2#;6/)$8":\u015a""$ )("\'#&\'#0<*%;A/2#;6/)$8":\u015a""$ )("\'#&\'#&/)$8":\u015b""! )("\'#&\'#." &"/\' 8!:\u017a!! )'),w("%;L.# &;\x99/]#$%;B/,#;\xe1/#$+\")(\"'#&'#06*%;B/,#;\xe1/#$+\")(\"'#&'#&/'$8\":\u017b\" )(\"'#&'#"),w(";\xb9.# &;\xa0"),w("%;\xe3/Y#$%;A/,#;\xe3/#$+\")(\"'#&'#06*%;A/,#;\xe3/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),w("%;\xea/k#;./b$;\xed/Y$$%;B/,#;\xe4/#$+\")(\"'#&'#06*%;B/,#;\xe4/#$+\")(\"'#&'#&/#$+$)($'#(#'#(\"'#&'#"),w(";\xe5.; &;\xe6.5 &;\xe7./ &;\xe8.) &;\xe9.# &;\xa0"),w("%3\u017c\"\"5#7\u017d/:#;</1$;\xf0/($8#:\u017e#! )(#'#(\"'#&'#"),w("%3\u017f\"\"5%7\u0180/:#;</1$;T/($8#:\u0181#! )(#'#(\"'#&'#"),w("%3\u0182\"\"5(7\u0183/F#;</=$;\\.) &;Y.# &;X/($8#:\u0184#! )(#'#(\"'#&'#"),w("%3\u0185\"\"5&7\u0186/:#;</1$;6/($8#:\u0187#! )(#'#(\"'#&'#"),w("%3\u0188\"\"5%7\u0189/A#;</8$$;!0#*;!&/($8#:\u018a#! )(#'#(\"'#&'#"),w("%;\xeb/G#;;/>$;6/5$;;/,$;\xec/#$+%)(%'#($'#(#'#(\"'#&'#"),w('%3\x92""5#7\xd3.# &;6/\' 8!:\u018b!! )'),w('%3\xb1""5#7\u018c.G &3\xb3""5#7\u018d.; &3\xb7""5#7\u018e./ &3\xb5""5$7\u018f.# &;6/\' 8!:\u0190!! )'),w('%;\xee/D#%;C/,#;\xef/#$+")("\'#&\'#." &"/#$+")("\'#&\'#'),w("%;U.) &;\\.# &;X/& 8!:\u0191! )"),w('%%;!." &"/[#;!." &"/M$;!." &"/?$;!." &"/1$;!." &"/#$+%)(%\'#($\'#(#\'#("\'#&\'#/\' 8!:\u0192!! )'),w('%%;!/?#;!." &"/1$;!." &"/#$+#)(#\'#("\'#&\'#/\' 8!:\u0193!! )'),w(";\xbe"),w('%;\x9e/^#$%;B/,#;\xf3/#$+")("\'#&\'#06*%;B/,#;\xf3/#$+")("\'#&\'#&/($8":\u0194"!!)("\'#&\'#'),w(";\xf4.# &;\xa0"),w('%2\u0195""6\u01957\u0196/L#;</C$2\u0197""6\u01977\u0198.) &2\u0199""6\u01997\u019a/($8#:\u019b#! )(#\'#("\'#&\'#'),w('%;\x9e/^#$%;B/,#;\xa0/#$+")("\'#&\'#06*%;B/,#;\xa0/#$+")("\'#&\'#&/($8":\u019c"!!)("\'#&\'#'),w("%;6/5#;0/,$;\xf7/#$+#)(#'#(\"'#&'#"),w("$;2.) &;4.# &;.0/*;2.) &;4.# &;.&"),w("$;%0#*;%&"),w("%;\xfa/;#28\"\"6879/,$;\xfb/#$+#)(#'#(\"'#&'#"),w('%3\u019d""5%7\u019e.) &3\u019f""5$7\u01a0/\' 8!:\u01a1!! )'),w('%;\xfc/J#%28""6879/,#;^/#$+")("\'#&\'#." &"/#$+")("\'#&\'#'),w("%;\\.) &;X.# &;\x82/' 8!:\u01a2!! )"),w(';".S &;!.M &2F""6F7G.A &2J""6J7K.5 &2H""6H7I.) &2N""6N7O'),w('2L""6L7M.\x95 &2B""6B7C.\x89 &2<""6<7=.} &2R""6R7S.q &2T""6T7U.e &2V""6V7W.Y &2P""6P7Q.M &2@""[email protected] &2D""6D7E.5 &22""6273.) &2>""6>7?'),w('%;\u0100/b#28""6879/S$;\xfb/J$%2\u01a3""6\u01a37\u01a4/,#;\xec/#$+")("\'#&\'#." &"/#$+$)($\'#(#\'#("\'#&\'#'),w('%3\u01a5""5%7\u01a6.) &3\u01a7""5$7\u01a8/\' 8!:\u01a1!! )'),w('%3\xb1""5#7\xb2.6 &3\xb3""5#7\xb4.* &$;+0#*;+&/\' 8!:\u01a9!! )'),w("%;\u0104/\x87#2F\"\"6F7G/x$;\u0103/o$2F\"\"6F7G/`$;\u0103/W$2F\"\"6F7G/H$;\u0103/?$2F\"\"6F7G/0$;\u0105/'$8):\u01aa) )()'#(('#(''#(&'#(%'#($'#(#'#(\"'#&'#"),w("%;#/>#;#/5$;#/,$;#/#$+$)($'#(#'#(\"'#&'#"),w("%;\u0103/,#;\u0103/#$+\")(\"'#&'#"),w("%;\u0103/5#;\u0103/,$;\u0103/#$+#)(#'#(\"'#&'#"),w("%;q/T#$;m0#*;m&/D$%; /,#;\xf8/#$+\")(\"'#&'#.\" &\"/#$+#)(#'#(\"'#&'#"),w('%2\u01ab""6\u01ab7\u01ac.) &2\u01ad""6\u01ad7\u01ae/w#;0/n$;\u0108/e$$%;B/2#;\u0109.# &;\xa0/#$+")("\'#&\'#0<*%;B/2#;\u0109.# &;\xa0/#$+")("\'#&\'#&/#$+$)($\'#(#\'#("\'#&\'#'),w(";\x99.# &;L"),w("%2\u01af\"\"6\u01af7\u01b0/5#;</,$;\u010a/#$+#)(#'#(\"'#&'#"),w("%;D/S#;,/J$2:\"\"6:7;/;$;,.# &;T/,$;E/#$+%)(%'#($'#(#'#(\"'#&'#")],l=0,p=0,h=[{line:1,column:1}],g=0,f=[],v=0;if(void 0!==t.startRule){if(!(t.startRule in a))throw new Error("Can't start parsing from rule \""+t.startRule+'".');c=a[t.startRule]}function m(){return e.substring(p,l)}function S(){return E(p,l)}function y(e,t){return{type:"literal",text:e,ignoreCase:t}}function T(e,t,r){return{type:"class",parts:e,inverted:t,ignoreCase:r}}function b(t){var r,i=h[t];if(i)return i;for(r=t-1;!h[r];)r--;for(i={line:(i=h[r]).line,column:i.column};r<t;)10===e.charCodeAt(r)?(i.line++,i.column=1):i.column++,r++;return h[t]=i,i}function E(e,t){var r=b(e),i=b(t);return{start:{offset:e,line:r.line,column:r.column},end:{offset:t,line:i.line,column:i.column}}}function _(e){l<g||(l>g&&(g=l,f=[]),f.push(e))}function R(e,t,r){return new o(o.buildMessage(e,t),e,t,r)}function w(e){return e.split("").map(function(e){return e.charCodeAt(0)-32})}if(t.data={},(r=function t(r){for(var n,s=d[r],o=0,a=[],c=s.length,h=[],g=[];;){for(;o<c;)switch(s[o]){case 0:g.push(u[s[o+1]]),o+=2;break;case 1:g.push(void 0),o++;break;case 2:g.push(null),o++;break;case 3:g.push(i),o++;break;case 4:g.push([]),o++;break;case 5:g.push(l),o++;break;case 6:g.pop(),o++;break;case 7:l=g.pop(),o++;break;case 8:g.length-=s[o+1],o+=2;break;case 9:g.splice(-2,1),o++;break;case 10:g[g.length-2].push(g.pop()),o++;break;case 11:g.push(g.splice(g.length-s[o+1],s[o+1])),o+=2;break;case 12:g.push(e.substring(g.pop(),l)),o++;break;case 13:h.push(c),a.push(o+3+s[o+1]+s[o+2]),g[g.length-1]?(c=o+3+s[o+1],o+=3):(c=o+3+s[o+1]+s[o+2],o+=3+s[o+1]);break;case 14:h.push(c),a.push(o+3+s[o+1]+s[o+2]),g[g.length-1]===i?(c=o+3+s[o+1],o+=3):(c=o+3+s[o+1]+s[o+2],o+=3+s[o+1]);break;case 15:h.push(c),a.push(o+3+s[o+1]+s[o+2]),g[g.length-1]!==i?(c=o+3+s[o+1],o+=3):(c=o+3+s[o+1]+s[o+2],o+=3+s[o+1]);break;case 16:g[g.length-1]!==i?(h.push(c),a.push(o),c=o+2+s[o+1],o+=2):o+=2+s[o+1];break;case 17:h.push(c),a.push(o+3+s[o+1]+s[o+2]),e.length>l?(c=o+3+s[o+1],o+=3):(c=o+3+s[o+1]+s[o+2],o+=3+s[o+1]);break;case 18:h.push(c),a.push(o+4+s[o+2]+s[o+3]),e.substr(l,u[s[o+1]].length)===u[s[o+1]]?(c=o+4+s[o+2],o+=4):(c=o+4+s[o+2]+s[o+3],o+=4+s[o+2]);break;case 19:h.push(c),a.push(o+4+s[o+2]+s[o+3]),e.substr(l,u[s[o+1]].length).toLowerCase()===u[s[o+1]]?(c=o+4+s[o+2],o+=4):(c=o+4+s[o+2]+s[o+3],o+=4+s[o+2]);break;case 20:h.push(c),a.push(o+4+s[o+2]+s[o+3]),u[s[o+1]].test(e.charAt(l))?(c=o+4+s[o+2],o+=4):(c=o+4+s[o+2]+s[o+3],o+=4+s[o+2]);break;case 21:g.push(e.substr(l,s[o+1])),l+=s[o+1],o+=2;break;case 22:g.push(u[s[o+1]]),l+=u[s[o+1]].length,o+=2;break;case 23:g.push(i),0===v&&_(u[s[o+1]]),o+=2;break;case 24:p=g[g.length-1-s[o+1]],o+=2;break;case 25:p=l,o++;break;case 26:n=s.slice(o+4,o+4+s[o+3]).map(function(e){return g[g.length-1-e]}),g.splice(g.length-s[o+2],s[o+2],u[s[o+1]].apply(null,n)),o+=4+s[o+3];break;case 27:g.push(t(s[o+1])),o+=2;break;case 28:v++,o++;break;case 29:v--,o++;break;default:throw new Error("Invalid opcode: "+s[o]+".")}if(!(h.length>0))break;c=h.pop(),o=a.pop()}return g[0]}(c))!==i&&l===e.length)return r;throw r!==i&&l<e.length&&_({type:"end"}),R(f,g<e.length?e.charAt(g):null,g<e.length?E(g,g+1):E(g,g))}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0).__importDefault(r(60)),n=r(12),s=function(){function e(e,t,r){this.logger=e.getLogger("sipjs.digestauthentication"),this.username=t,this.password=r,this.nc=0,this.ncHex="00000000"}return e.prototype.authenticate=function(e,t,r){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 this.logger.warn("challenge with Digest algorithm different than 'MD5', authentication aborted"),!1}else this.algorithm="MD5";if(!this.realm)return this.logger.warn("challenge without Digest realm, authentication aborted"),!1;if(!this.nonce)return this.logger.warn("challenge without Digest nonce, authentication aborted"),!1;if(t.qop)if(t.qop.indexOf("auth")>-1)this.qop="auth";else{if(!(t.qop.indexOf("auth-int")>-1))return this.logger.warn("challenge without Digest qop different than 'auth' or 'auth-int', authentication aborted"),!1;this.qop="auth-int"}else this.qop=void 0;return this.method=e.method,this.uri=e.ruri,this.cnonce=n.createRandomToken(12),this.nc+=1,this.updateNcHex(),4294967296===this.nc&&(this.nc=1,this.ncHex="00000001"),this.calculateResponse(r),!0},e.prototype.toString=function(){var e=[];if(!this.response)throw new Error("response field does not exist, cannot generate Authorization header");return e.push("algorithm="+this.algorithm),e.push('username="'+this.username+'"'),e.push('realm="'+this.realm+'"'),e.push('nonce="'+this.nonce+'"'),e.push('uri="'+this.uri+'"'),e.push('response="'+this.response+'"'),this.opaque&&e.push('opaque="'+this.opaque+'"'),this.qop&&(e.push("qop="+this.qop),e.push('cnonce="'+this.cnonce+'"'),e.push("nc="+this.ncHex)),"Digest "+e.join(", ")},e.prototype.updateNcHex=function(){var e=Number(this.nc).toString(16);this.ncHex="00000000".substr(0,8-e.length)+e},e.prototype.calculateResponse=function(e){var t,r=i.default(this.username+":"+this.realm+":"+this.password);"auth"===this.qop?(t=i.default(this.method+":"+this.uri),this.response=i.default(r+":"+this.nonce+":"+this.ncHex+":"+this.cnonce+":auth:"+t)):"auth-int"===this.qop?(t=i.default(this.method+":"+this.uri+":"+i.default(e||"")),this.response=i.default(r+":"+this.nonce+":"+this.ncHex+":"+this.cnonce+":auth-int:"+t)):void 0===this.qop&&(t=i.default(this.method+":"+this.uri),this.response=i.default(r+":"+this.nonce+":"+t))},e}();t.DigestAuthentication=s},function(e,t,r){var i;e.exports=(i=r(61),function(e){var t=i,r=t.lib,n=r.WordArray,s=r.Hasher,o=t.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=o.MD5=s.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var i=t+r,n=e[i];e[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var s=this._hash.words,o=e[t+0],c=e[t+1],h=e[t+2],g=e[t+3],f=e[t+4],v=e[t+5],m=e[t+6],S=e[t+7],y=e[t+8],T=e[t+9],b=e[t+10],E=e[t+11],_=e[t+12],R=e[t+13],w=e[t+14],C=e[t+15],I=s[0],A=s[1],x=s[2],P=s[3];I=u(I,A,x,P,o,7,a[0]),P=u(P,I,A,x,c,12,a[1]),x=u(x,P,I,A,h,17,a[2]),A=u(A,x,P,I,g,22,a[3]),I=u(I,A,x,P,f,7,a[4]),P=u(P,I,A,x,v,12,a[5]),x=u(x,P,I,A,m,17,a[6]),A=u(A,x,P,I,S,22,a[7]),I=u(I,A,x,P,y,7,a[8]),P=u(P,I,A,x,T,12,a[9]),x=u(x,P,I,A,b,17,a[10]),A=u(A,x,P,I,E,22,a[11]),I=u(I,A,x,P,_,7,a[12]),P=u(P,I,A,x,R,12,a[13]),x=u(x,P,I,A,w,17,a[14]),I=d(I,A=u(A,x,P,I,C,22,a[15]),x,P,c,5,a[16]),P=d(P,I,A,x,m,9,a[17]),x=d(x,P,I,A,E,14,a[18]),A=d(A,x,P,I,o,20,a[19]),I=d(I,A,x,P,v,5,a[20]),P=d(P,I,A,x,b,9,a[21]),x=d(x,P,I,A,C,14,a[22]),A=d(A,x,P,I,f,20,a[23]),I=d(I,A,x,P,T,5,a[24]),P=d(P,I,A,x,w,9,a[25]),x=d(x,P,I,A,g,14,a[26]),A=d(A,x,P,I,y,20,a[27]),I=d(I,A,x,P,R,5,a[28]),P=d(P,I,A,x,h,9,a[29]),x=d(x,P,I,A,S,14,a[30]),I=l(I,A=d(A,x,P,I,_,20,a[31]),x,P,v,4,a[32]),P=l(P,I,A,x,y,11,a[33]),x=l(x,P,I,A,E,16,a[34]),A=l(A,x,P,I,w,23,a[35]),I=l(I,A,x,P,c,4,a[36]),P=l(P,I,A,x,f,11,a[37]),x=l(x,P,I,A,S,16,a[38]),A=l(A,x,P,I,b,23,a[39]),I=l(I,A,x,P,R,4,a[40]),P=l(P,I,A,x,o,11,a[41]),x=l(x,P,I,A,g,16,a[42]),A=l(A,x,P,I,m,23,a[43]),I=l(I,A,x,P,T,4,a[44]),P=l(P,I,A,x,_,11,a[45]),x=l(x,P,I,A,C,16,a[46]),I=p(I,A=l(A,x,P,I,h,23,a[47]),x,P,o,6,a[48]),P=p(P,I,A,x,S,10,a[49]),x=p(x,P,I,A,w,15,a[50]),A=p(A,x,P,I,v,21,a[51]),I=p(I,A,x,P,_,6,a[52]),P=p(P,I,A,x,g,10,a[53]),x=p(x,P,I,A,b,15,a[54]),A=p(A,x,P,I,c,21,a[55]),I=p(I,A,x,P,y,6,a[56]),P=p(P,I,A,x,C,10,a[57]),x=p(x,P,I,A,m,15,a[58]),A=p(A,x,P,I,R,21,a[59]),I=p(I,A,x,P,f,6,a[60]),P=p(P,I,A,x,E,10,a[61]),x=p(x,P,I,A,h,15,a[62]),A=p(A,x,P,I,T,21,a[63]),s[0]=s[0]+I|0,s[1]=s[1]+A|0,s[2]=s[2]+x|0,s[3]=s[3]+P|0},_doFinalize:function(){var t=this._data,r=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;r[n>>>5]|=128<<24-n%32;var s=e.floor(i/4294967296),o=i;r[15+(n+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),r[14+(n+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),t.sigBytes=4*(r.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var d=c[u];c[u]=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8)}return a},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,r,i,n,s,o){var a=e+(t&r|~t&i)+n+o;return(a<<s|a>>>32-s)+t}function d(e,t,r,i,n,s,o){var a=e+(t&i|r&~i)+n+o;return(a<<s|a>>>32-s)+t}function l(e,t,r,i,n,s,o){var a=e+(t^r^i)+n+o;return(a<<s|a>>>32-s)+t}function p(e,t,r,i,n,s,o){var a=e+(r^(t|~i))+n+o;return(a<<s|a>>>32-s)+t}t.MD5=s._createHelper(c),t.HmacMD5=s._createHmacHelper(c)}(Math),i.MD5)},function(e,t,r){var i;e.exports=(i=i||function(e,t){var r=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),i={},n=i.lib={},s=n.Base={extend:function(e){var t=r(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},o=n.WordArray=s.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,r=e.words,i=this.sigBytes,n=e.sigBytes;if(this.clamp(),i%4)for(var s=0;s<n;s++){var o=r[s>>>2]>>>24-s%4*8&255;t[i+s>>>2]|=o<<24-(i+s)%4*8}else for(var s=0;s<n;s+=4)t[i+s>>>2]=r[s>>>2];return this.sigBytes+=n,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=s.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var r,i=[],n=function(t){var t=t,r=987654321,i=4294967295;return function(){var n=((r=36969*(65535&r)+(r>>16)&i)<<16)+(t=18e3*(65535&t)+(t>>16)&i)&i;return n/=4294967296,(n+=.5)*(e.random()>.5?1:-1)}},s=0;s<t;s+=4){var a=n(4294967296*(r||e.random()));r=987654071*a(),i.push(4294967296*a()|0)}return new o.init(i,t)}}),a=i.enc={},c=a.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,i=[],n=0;n<r;n++){var s=t[n>>>2]>>>24-n%4*8&255;i.push((s>>>4).toString(16)),i.push((15&s).toString(16))}return i.join("")},parse:function(e){for(var t=e.length,r=[],i=0;i<t;i+=2)r[i>>>3]|=parseInt(e.substr(i,2),16)<<24-i%8*4;return new o.init(r,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,i=[],n=0;n<r;n++){var s=t[n>>>2]>>>24-n%4*8&255;i.push(String.fromCharCode(s))}return i.join("")},parse:function(e){for(var t=e.length,r=[],i=0;i<t;i++)r[i>>>2]|=(255&e.charCodeAt(i))<<24-i%4*8;return new o.init(r,t)}},d=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},l=n.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=d.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r=this._data,i=r.words,n=r.sigBytes,s=this.blockSize,a=4*s,c=n/a,u=(c=t?e.ceil(c):e.max((0|c)-this._minBufferSize,0))*s,d=e.min(4*u,n);if(u){for(var l=0;l<u;l+=s)this._doProcessBlock(i,l);var p=i.splice(0,u);r.sigBytes-=d}return new o.init(p,d)},clone:function(){var e=s.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),p=(n.Hasher=l.extend({cfg:s.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){e&&this._append(e);var t=this._doFinalize();return t},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new p.HMAC.init(e,r).finalize(t)}}}),i.algo={});return i}(Math),i)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(12);t.constructOutgoingResponse=function(e,t){var r="\r\n";if(t.statusCode<100||t.statusCode>699)throw new TypeError("Invalid statusCode: "+t.statusCode);var n=t.reasonPhrase?t.reasonPhrase:i.getReasonPhrase(t.statusCode),s="SIP/2.0 "+t.statusCode+" "+n+r;t.statusCode>=100&&t.statusCode,t.statusCode;var o="From: "+e.getHeader("From")+r,a="Call-ID: "+e.callId+r,c="CSeq: "+e.cseq+" "+e.method+r,u=e.getHeaders("via").reduce(function(e,t){return e+"Via: "+t+r},""),d="To: "+e.getHeader("to");if(t.statusCode>100&&!e.parseHeader("to").hasParam("tag")){var l=t.toTag;l||(l=i.newTag()),d+=";tag="+l}d+=r;var p="";t.supported&&(p="Supported: "+t.supported.join(", ")+r);var h="";t.userAgent&&(h="User-Agent: "+t.userAgent+r);var g="";return t.extraHeaders&&(g=t.extraHeaders.reduce(function(e,t){return e+t.trim()+r},"")),s+=u,s+=o,s+=d,s+=c,s+=a,s+=p,s+=h,s+=g,t.body?(s+="Content-Type: "+t.body.contentType+r,s+="Content-Length: "+i.str_utf8_length(t.body.content)+r+r,s+=t.body.content):s+="Content-Length: 0\r\n\r\n",{message:s}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(2),s=r(15),o=r(6),a=r(1),c=r(36),u=r(37),d=r(38),l=r(39),p=r(40),h=r(26),g=r(41),f=r(42),v=r(43),m=r(44),S=r(45),y=r(46),T=function(e){function t(t,r,i,n){var o=e.call(this,r,i)||this;return o.initialTransaction=t,o._signalingState=s.SignalingState.Initial,o.ackWait=!1,o.delegate=n,t instanceof a.InviteServerTransaction&&(o.ackWait=!0),o.early||o.start2xxRetransmissionTimer(),o.signalingStateTransition(t.request),o.logger=r.loggerFactory.getLogger("sip.invite-dialog"),o.logger.log("INVITE dialog "+o.id+" constructed"),o}return i.__extends(t,e),t.prototype.dispose=function(){e.prototype.dispose.call(this),this._signalingState=s.SignalingState.Closed,this._offer=void 0,this._answer=void 0,this.invite2xxTimer&&(clearTimeout(this.invite2xxTimer),this.invite2xxTimer=void 0),this.logger.log("INVITE dialog "+this.id+" destroyed")},Object.defineProperty(t.prototype,"sessionState",{get:function(){return this.early?s.SessionState.Early:this.ackWait?s.SessionState.AckWait:this._signalingState===s.SignalingState.Closed?s.SessionState.Terminated:s.SessionState.Confirmed},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"signalingState",{get:function(){return this._signalingState},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"offer",{get:function(){return this._offer},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"answer",{get:function(){return this._answer},enumerable:!0,configurable:!0}),t.prototype.confirm=function(){this.early&&this.start2xxRetransmissionTimer(),e.prototype.confirm.call(this)},t.prototype.reConfirm=function(){this.reinviteUserAgentServer&&this.startReInvite2xxRetransmissionTimer()},t.prototype.ack=function(e){var t;if(void 0===e&&(e={}),this.logger.log("INVITE dialog "+this.id+" sending ACK request"),this.reinviteUserAgentClient){if(!(this.reinviteUserAgentClient.transaction instanceof a.InviteClientTransaction))throw new Error("Transaction not instance of InviteClientTransaction.");t=this.reinviteUserAgentClient.transaction,this.reinviteUserAgentClient=void 0}else{if(!(this.initialTransaction instanceof a.InviteClientTransaction))throw new Error("Initial transaction not instance of InviteClientTransaction.");t=this.initialTransaction}e.cseq=t.request.cseq;var r=this.createOutgoingRequestMessage(n.C.ACK,e);return t.ackResponse(r),this.signalingStateTransition(r),{message:r}},t.prototype.bye=function(e,t){if(this.logger.log("INVITE dialog "+this.id+" sending BYE request"),this.initialTransaction instanceof a.InviteServerTransaction){if(this.early)throw new Error("UAS MUST NOT send a BYE on early dialogs.");if(this.ackWait&&this.initialTransaction.state!==a.TransactionState.Terminated)throw new Error("UAS MUST NOT send a BYE on a confirmed dialog until it has received an ACK for its 2xx response or until the server transaction times out.")}return new c.ByeUserAgentClient(this,e,t)},t.prototype.info=function(e,t){if(this.logger.log("INVITE dialog "+this.id+" sending INFO request"),this.early)throw new Error("Dialog not confirmed.");return new d.InfoUserAgentClient(this,e,t)},t.prototype.invite=function(e,t){if(this.logger.log("INVITE dialog "+this.id+" sending INVITE request"),this.early)throw new Error("Dialog not confirmed.");if(this.reinviteUserAgentClient)throw new Error("There is an ongoing re-INVITE client transaction.");if(this.reinviteUserAgentServer)throw new Error("There is an ongoing re-INVITE server transaction.");return new v.ReInviteUserAgentClient(this,e,t)},t.prototype.notify=function(e,t){if(this.logger.log("INVITE dialog "+this.id+" sending NOTIFY request"),this.early)throw new Error("Dialog not confirmed.");return new p.NotifyUserAgentClient(this,e,t)},t.prototype.prack=function(e,t){return this.logger.log("INVITE dialog "+this.id+" sending PRACK request"),new g.PrackUserAgentClient(this,e,t)},t.prototype.refer=function(e,t){if(this.logger.log("INVITE dialog "+this.id+" sending REFER request"),this.early)throw new Error("Dialog not confirmed.");return new S.ReferUserAgentClient(this,e,t)},t.prototype.receiveRequest=function(t){if(this.logger.log("INVITE dialog "+this.id+" received "+t.method+" request"),t.method===n.C.ACK){if(this.ackWait){if(this.initialTransaction instanceof a.InviteClientTransaction)return void this.logger.warn("INVITE dialog "+this.id+" received unexpected "+t.method+" request, dropping.");if(this.initialTransaction.request.cseq!==t.cseq)return void this.logger.warn("INVITE dialog "+this.id+" received unexpected "+t.method+" request, dropping.");this.ackWait=!1}else{if(!this.reinviteUserAgentServer)return void this.logger.warn("INVITE dialog "+this.id+" received unexpected "+t.method+" request, dropping.");if(this.reinviteUserAgentServer.transaction.request.cseq!==t.cseq)return void this.logger.warn("INVITE dialog "+this.id+" received unexpected "+t.method+" request, dropping.");this.reinviteUserAgentServer=void 0}return this.signalingStateTransition(t),void(this.delegate&&this.delegate.onAck&&this.delegate.onAck({message:t}))}if(this.sequenceGuard(t)){if(t.method===n.C.INVITE){if(this.reinviteUserAgentServer){var r=["Retry-After: "+(Math.floor(10*Math.random())+1)];return void this.core.replyStateless(t,{statusCode:500,extraHeaders:r})}if(this.reinviteUserAgentClient)return void this.core.replyStateless(t,{statusCode:491})}if(e.prototype.receiveRequest.call(this,t),t.method===n.C.INVITE){var i=t.parseHeader("contact");if(!i)throw new Error("Contact undefined.");if(!(i instanceof n.NameAddrHeader))throw new Error("Contact not instance of NameAddrHeader.");this.dialogState.remoteTarget=i.uri}switch(t.method){case n.C.BYE:var s=new u.ByeUserAgentServer(this,t);this.delegate&&this.delegate.onBye?this.delegate.onBye(s):s.accept(),this.dispose();break;case n.C.INFO:s=new l.InfoUserAgentServer(this,t);this.delegate&&this.delegate.onInfo?this.delegate.onInfo(s):s.reject({statusCode:469,extraHeaders:["Recv-Info :"]});break;case n.C.INVITE:s=new m.ReInviteUserAgentServer(this,t);this.signalingStateTransition(t),this.delegate&&this.delegate.onInvite?this.delegate.onInvite(s):s.reject({statusCode:488});break;case n.C.NOTIFY:s=new h.NotifyUserAgentServer(this,t);this.delegate&&this.delegate.onNotify?this.delegate.onNotify(s):s.accept();break;case n.C.PRACK:s=new f.PrackUserAgentServer(this,t);this.delegate&&this.delegate.onPrack?this.delegate.onPrack(s):s.accept();break;case n.C.REFER:s=new y.ReferUserAgentServer(this,t);this.delegate&&this.delegate.onRefer?this.delegate.onRefer(s):s.reject();break;default:this.logger.log("INVITE dialog "+this.id+" received unimplemented "+t.method+" request"),this.core.replyStateless(t,{statusCode:501})}}else this.logger.log("INVITE dialog "+this.id+" rejected out of order "+t.method+" request.")},t.prototype.reliableSequenceGuard=function(e){var t=e.statusCode;if(!t)throw new Error("Status code undefined");if(t>100&&t<200){var r=e.getHeader("require"),i=e.getHeader("rseq"),n=r&&r.includes("100rel")&&i?Number(i):void 0;if(n){if(this.rseq&&this.rseq+1!==n)return!1;this.rseq||(this.rseq=n)}}return!0},t.prototype.signalingStateTransition=function(e){var t=n.getBody(e);if(t&&"session"===t.contentDisposition){if(e instanceof n.IncomingRequestMessage)switch(this._signalingState){case s.SignalingState.Initial:case s.SignalingState.Stable:this._signalingState=s.SignalingState.HaveRemoteOffer,this._offer=t,this._answer=void 0;break;case s.SignalingState.HaveLocalOffer:this._signalingState=s.SignalingState.Stable,this._answer=t;break;case s.SignalingState.HaveRemoteOffer:case s.SignalingState.Closed:break;default:throw new Error("Unexpected signaling state.")}if(e instanceof n.IncomingResponseMessage)switch(this._signalingState){case s.SignalingState.Initial:case s.SignalingState.Stable:this._signalingState=s.SignalingState.HaveRemoteOffer,this._offer=t,this._answer=void 0;break;case s.SignalingState.HaveLocalOffer:this._signalingState=s.SignalingState.Stable,this._answer=t;break;case s.SignalingState.HaveRemoteOffer:case s.SignalingState.Closed:break;default:throw new Error("Unexpected signaling state.")}if(e instanceof n.OutgoingRequestMessage)switch(this._signalingState){case s.SignalingState.Initial:case s.SignalingState.Stable:this._signalingState=s.SignalingState.HaveLocalOffer,this._offer=t,this._answer=void 0;break;case s.SignalingState.HaveLocalOffer:break;case s.SignalingState.HaveRemoteOffer:this._signalingState=s.SignalingState.Stable,this._answer=t;break;case s.SignalingState.Closed:break;default:throw new Error("Unexpected signaling state.")}if(n.isBody(e))switch(this._signalingState){case s.SignalingState.Initial:case s.SignalingState.Stable:this._signalingState=s.SignalingState.HaveLocalOffer,this._offer=t,this._answer=void 0;break;case s.SignalingState.HaveLocalOffer:break;case s.SignalingState.HaveRemoteOffer:this._signalingState=s.SignalingState.Stable,this._answer=t;break;case s.SignalingState.Closed:break;default:throw new Error("Unexpected signaling state.")}}},t.prototype.start2xxRetransmissionTimer=function(){var e=this;if(this.initialTransaction instanceof a.InviteServerTransaction){var t=this.initialTransaction,r=o.Timers.T1,i=function(){e.ackWait?(e.logger.log("No ACK for 2xx response received, attempting retransmission"),t.retransmitAcceptedResponse(),r=Math.min(2*r,o.Timers.T2),e.invite2xxTimer=setTimeout(i,r)):e.invite2xxTimer=void 0};this.invite2xxTimer=setTimeout(i,r);var n=function(){t.state===a.TransactionState.Terminated&&(t.removeListener("stateChanged",n),e.invite2xxTimer&&(clearTimeout(e.invite2xxTimer),e.invite2xxTimer=void 0),e.ackWait&&(e.delegate&&e.delegate.onAckTimeout?e.delegate.onAckTimeout():e.bye()))};t.addListener("stateChanged",n)}},t.prototype.startReInvite2xxRetransmissionTimer=function(){var e=this;if(this.reinviteUserAgentServer&&this.reinviteUserAgentServer.transaction instanceof a.InviteServerTransaction){var t=this.reinviteUserAgentServer.transaction,r=o.Timers.T1,i=function(){e.reinviteUserAgentServer?(e.logger.log("No ACK for 2xx response received, attempting retransmission"),t.retransmitAcceptedResponse(),r=Math.min(2*r,o.Timers.T2),e.invite2xxTimer=setTimeout(i,r)):e.invite2xxTimer=void 0};this.invite2xxTimer=setTimeout(i,r);var n=function(){t.state===a.TransactionState.Terminated&&(t.removeListener("stateChanged",n),e.invite2xxTimer&&(clearTimeout(e.invite2xxTimer),e.invite2xxTimer=void 0),e.reinviteUserAgentServer)};t.addListener("stateChanged",n)}},t}(r(18).Dialog);t.SessionDialog=T},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.Initial="Initial",e.Early="Early",e.AckWait="AckWait",e.Confirmed="Confirmed",e.Terminated="Terminated"}(t.SessionState||(t.SessionState={})),function(e){e.Initial="Initial",e.HaveLocalOffer="HaveLocalOffer",e.HaveRemoteOffer="HaveRemoteOffer",e.Stable="Stable",e.Closed="Closed"}(t.SignalingState||(t.SignalingState={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=function(e){function t(t){return e.call(this,t||"Transaction state error.")||this}return i.__extends(t,e),t}(r(24).Exception);t.TransactionStateError=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=function(e){function t(t){return e.call(this,t||"Unspecified transport error.")||this}return i.__extends(t,e),t}(r(24).Exception);t.TransportError=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(2),s=r(6),o=r(25),a=r(13),c=function(e){function t(t,r,i){return e.call(this,t,r,i,a.TransactionState.Proceeding,"sip.transaction.ist")||this}return i.__extends(t,e),t.prototype.dispose=function(){this.stopProgressExtensionTimer(),this.H&&(clearTimeout(this.H),this.H=void 0),this.I&&(clearTimeout(this.I),this.I=void 0),this.L&&(clearTimeout(this.L),this.L=void 0),e.prototype.dispose.call(this)},Object.defineProperty(t.prototype,"kind",{get:function(){return"ist"},enumerable:!0,configurable:!0}),t.prototype.receiveRequest=function(e){var t=this;switch(this.state){case a.TransactionState.Proceeding:if(e.method===n.C.INVITE)return void(this.lastProvisionalResponse&&this.send(this.lastProvisionalResponse).catch(function(e){t.logTransportError(e,"Failed to send retransmission of provisional response.")}));break;case a.TransactionState.Accepted:if(e.method===n.C.INVITE)return;break;case a.TransactionState.Completed:if(e.method===n.C.INVITE){if(!this.lastFinalResponse)throw new Error("Last final response undefined.");return void this.send(this.lastFinalResponse).catch(function(e){t.logTransportError(e,"Failed to send retransmission of final response.")})}if(e.method===n.C.ACK)return void this.stateTransition(a.TransactionState.Confirmed);break;case a.TransactionState.Confirmed:case a.TransactionState.Terminated:if(e.method===n.C.INVITE||e.method===n.C.ACK)return;break;default:throw new Error("Invalid state "+this.state)}var r="INVITE server transaction received unexpected "+e.method+" request while in state "+this.state+".";this.logger.warn(r)},t.prototype.receiveResponse=function(e,t){var r=this;if(e<100||e>699)throw new Error("Invalid status code "+e);switch(this.state){case a.TransactionState.Proceeding:if(e>=100&&e<=199)return this.lastProvisionalResponse=t,e>100&&this.startProgressExtensionTimer(),void this.send(t).catch(function(e){r.logTransportError(e,"Failed to send 1xx response.")});if(e>=200&&e<=299)return this.lastFinalResponse=t,this.stateTransition(a.TransactionState.Accepted),void this.send(t).catch(function(e){r.logTransportError(e,"Failed to send 2xx response.")});if(e>=300&&e<=699)return this.lastFinalResponse=t,this.stateTransition(a.TransactionState.Completed),void this.send(t).catch(function(e){r.logTransportError(e,"Failed to send non-2xx final response.")});break;case a.TransactionState.Accepted:if(e>=200&&e<=299)return void this.send(t).catch(function(e){r.logTransportError(e,"Failed to send 2xx response.")});break;case a.TransactionState.Completed:case a.TransactionState.Confirmed:case a.TransactionState.Terminated:break;default:throw new Error("Invalid state "+this.state)}var i="INVITE server transaction received unexpected "+e+" response from TU while in state "+this.state+".";throw this.logger.error(i),new Error(i)},t.prototype.retransmitAcceptedResponse=function(){var e=this;this.state===a.TransactionState.Accepted&&this.lastFinalResponse&&this.send(this.lastFinalResponse).catch(function(t){e.logTransportError(t,"Failed to send 2xx response.")})},t.prototype.onTransportError=function(e){this.user.onTransportError&&this.user.onTransportError(e)},t.prototype.typeToString=function(){return"INVITE server transaction"},t.prototype.stateTransition=function(e){var t=this,r=function(){throw new Error("Invalid state transition from "+t.state+" to "+e)};switch(e){case a.TransactionState.Proceeding:r();break;case a.TransactionState.Accepted:case a.TransactionState.Completed:this.state!==a.TransactionState.Proceeding&&r();break;case a.TransactionState.Confirmed:this.state!==a.TransactionState.Completed&&r();break;case a.TransactionState.Terminated:this.state!==a.TransactionState.Accepted&&this.state!==a.TransactionState.Completed&&this.state!==a.TransactionState.Confirmed&&r();break;default:r()}this.stopProgressExtensionTimer(),e===a.TransactionState.Accepted&&(this.L=setTimeout(function(){return t.timer_L()},s.Timers.TIMER_L)),e===a.TransactionState.Completed&&(this.H=setTimeout(function(){return t.timer_H()},s.Timers.TIMER_H)),e===a.TransactionState.Confirmed&&(this.I=setTimeout(function(){return t.timer_I()},s.Timers.TIMER_I)),e===a.TransactionState.Terminated&&this.dispose(),this.setState(e)},t.prototype.startProgressExtensionTimer=function(){var e=this;void 0===this.progressExtensionTimer&&(this.progressExtensionTimer=setInterval(function(){if(e.logger.debug("Progress extension timer expired for INVITE server transaction "+e.id+"."),!e.lastProvisionalResponse)throw new Error("Last provisional response undefined.");e.send(e.lastProvisionalResponse).catch(function(t){e.logTransportError(t,"Failed to send retransmission of provisional response.")})},s.Timers.PROVISIONAL_RESPONSE_INTERVAL))},t.prototype.stopProgressExtensionTimer=function(){void 0!==this.progressExtensionTimer&&(clearInterval(this.progressExtensionTimer),this.progressExtensionTimer=void 0)},t.prototype.timer_G=function(){},t.prototype.timer_H=function(){this.logger.debug("Timer H expired for INVITE server transaction "+this.id+"."),this.state===a.TransactionState.Completed&&(this.logger.warn("ACK to negative final response was never received, terminating transaction."),this.stateTransition(a.TransactionState.Terminated))},t.prototype.timer_I=function(){this.logger.debug("Timer I expired for INVITE server transaction "+this.id+"."),this.stateTransition(a.TransactionState.Terminated)},t.prototype.timer_L=function(){this.logger.debug("Timer L expired for INVITE server transaction "+this.id+"."),this.state===a.TransactionState.Accepted&&this.stateTransition(a.TransactionState.Terminated)},t}(o.ServerTransaction);t.InviteServerTransaction=c},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(6),s=r(22),o=r(13),a=function(e){function t(t,r,i){var s=e.call(this,t,r,i,o.TransactionState.Trying,"sip.transaction.nict")||this;return s.F=setTimeout(function(){return s.timer_F()},n.Timers.TIMER_F),s.send(t.toString()).catch(function(e){s.logTransportError(e,"Failed to send initial outgoing request.")}),s}return i.__extends(t,e),t.prototype.dispose=function(){this.F&&(clearTimeout(this.F),this.F=void 0),this.K&&(clearTimeout(this.K),this.K=void 0),e.prototype.dispose.call(this)},Object.defineProperty(t.prototype,"kind",{get:function(){return"nict"},enumerable:!0,configurable:!0}),t.prototype.receiveResponse=function(e){var t=e.statusCode;if(!t||t<100||t>699)throw new Error("Invalid status code "+t);switch(this.state){case o.TransactionState.Trying:if(t>=100&&t<=199)return this.stateTransition(o.TransactionState.Proceeding),void(this.user.receiveResponse&&this.user.receiveResponse(e));if(t>=200&&t<=699)return this.stateTransition(o.TransactionState.Completed),408===t?void this.onRequestTimeout():void(this.user.receiveResponse&&this.user.receiveResponse(e));break;case o.TransactionState.Proceeding:if(t>=100&&t<=199&&this.user.receiveResponse)return this.user.receiveResponse(e);if(t>=200&&t<=699)return this.stateTransition(o.TransactionState.Completed),408===t?void this.onRequestTimeout():void(this.user.receiveResponse&&this.user.receiveResponse(e));case o.TransactionState.Completed:case o.TransactionState.Terminated:return;default:throw new Error("Invalid state "+this.state)}var r="Non-INVITE client transaction received unexpected "+t+" response while in state "+this.state+".";this.logger.warn(r)},t.prototype.onTransportError=function(e){this.user.onTransportError&&this.user.onTransportError(e),this.stateTransition(o.TransactionState.Terminated,!0)},t.prototype.typeToString=function(){return"non-INVITE client transaction"},t.prototype.stateTransition=function(e,t){var r=this;void 0===t&&(t=!1);var i=function(){throw new Error("Invalid state transition from "+r.state+" to "+e)};switch(e){case o.TransactionState.Trying:i();break;case o.TransactionState.Proceeding:this.state!==o.TransactionState.Trying&&i();break;case o.TransactionState.Completed:this.state!==o.TransactionState.Trying&&this.state!==o.TransactionState.Proceeding&&i();break;case o.TransactionState.Terminated:this.state!==o.TransactionState.Trying&&this.state!==o.TransactionState.Proceeding&&this.state!==o.TransactionState.Completed&&(t||i());break;default:i()}e===o.TransactionState.Completed&&(this.F&&(clearTimeout(this.F),this.F=void 0),this.K=setTimeout(function(){return r.timer_K()},n.Timers.TIMER_K)),e===o.TransactionState.Terminated&&this.dispose(),this.setState(e)},t.prototype.timer_F=function(){this.logger.debug("Timer F expired for non-INVITE client transaction "+this.id+"."),this.state!==o.TransactionState.Trying&&this.state!==o.TransactionState.Proceeding||(this.onRequestTimeout(),this.stateTransition(o.TransactionState.Terminated))},t.prototype.timer_K=function(){this.state===o.TransactionState.Completed&&this.stateTransition(o.TransactionState.Terminated)},t}(s.ClientTransaction);t.NonInviteClientTransaction=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(6),s=r(25),o=r(13),a=function(e){function t(t,r,i){return e.call(this,t,r,i,o.TransactionState.Trying,"sip.transaction.nist")||this}return i.__extends(t,e),t.prototype.dispose=function(){this.J&&(clearTimeout(this.J),this.J=void 0),e.prototype.dispose.call(this)},Object.defineProperty(t.prototype,"kind",{get:function(){return"nist"},enumerable:!0,configurable:!0}),t.prototype.receiveRequest=function(e){var t=this;switch(this.state){case o.TransactionState.Trying:break;case o.TransactionState.Proceeding:if(!this.lastResponse)throw new Error("Last response undefined.");this.send(this.lastResponse).catch(function(e){t.logTransportError(e,"Failed to send retransmission of provisional response.")});break;case o.TransactionState.Completed:if(!this.lastResponse)throw new Error("Last response undefined.");this.send(this.lastResponse).catch(function(e){t.logTransportError(e,"Failed to send retransmission of final response.")});break;case o.TransactionState.Terminated:break;default:throw new Error("Invalid state "+this.state)}},t.prototype.receiveResponse=function(e,t){var r=this;if(e<100||e>699)throw new Error("Invalid status code "+e);if(e>100&&e<=199)throw new Error("Provisional response other than 100 not allowed.");switch(this.state){case o.TransactionState.Trying:if(this.lastResponse=t,e>=100&&e<200)return this.stateTransition(o.TransactionState.Proceeding),void this.send(t).catch(function(e){r.logTransportError(e,"Failed to send provisional response.")});if(e>=200&&e<=699)return this.stateTransition(o.TransactionState.Completed),void this.send(t).catch(function(e){r.logTransportError(e,"Failed to send final response.")});break;case o.TransactionState.Proceeding:if(this.lastResponse=t,e>=200&&e<=699)return this.stateTransition(o.TransactionState.Completed),void this.send(t).catch(function(e){r.logTransportError(e,"Failed to send final response.")});break;case o.TransactionState.Completed:return;case o.TransactionState.Terminated:break;default:throw new Error("Invalid state "+this.state)}var i="Non-INVITE server transaction received unexpected "+e+" response from TU while in state "+this.state+".";throw this.logger.error(i),new Error(i)},t.prototype.onTransportError=function(e){this.user.onTransportError&&this.user.onTransportError(e),this.stateTransition(o.TransactionState.Terminated,!0)},t.prototype.typeToString=function(){return"non-INVITE server transaction"},t.prototype.stateTransition=function(e,t){var r=this;void 0===t&&(t=!1);var i=function(){throw new Error("Invalid state transition from "+r.state+" to "+e)};switch(e){case o.TransactionState.Trying:i();break;case o.TransactionState.Proceeding:this.state!==o.TransactionState.Trying&&i();break;case o.TransactionState.Completed:this.state!==o.TransactionState.Trying&&this.state!==o.TransactionState.Proceeding&&i();break;case o.TransactionState.Terminated:this.state!==o.TransactionState.Proceeding&&this.state!==o.TransactionState.Completed&&(t||i());break;default:i()}e===o.TransactionState.Completed&&(this.J=setTimeout(function(){return r.timer_J()},n.Timers.TIMER_J)),e===o.TransactionState.Terminated&&this.dispose(),this.setState(e)},t.prototype.timer_J=function(){this.logger.debug("Timer J expired for NON-INVITE server transaction "+this.id+"."),this.state===o.TransactionState.Completed&&this.stateTransition(o.TransactionState.Terminated)},t}(s.ServerTransaction);t.NonInviteServerTransaction=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.Initial="Initial",e.NotifyWait="NotifyWait",e.Pending="Pending",e.Active="Active",e.Terminated="Terminated"}(t.SubscriptionState||(t.SubscriptionState={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0);i.__exportStar(r(28),t),i.__exportStar(r(72),t),i.__exportStar(r(49),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(28),n=r(49),s=function(){function e(){this.builtinEnabled=!0,this._level=i.Levels.log,this.loggers={},this.logger=this.getLogger("sip:loggerfactory")}return Object.defineProperty(e.prototype,"level",{get:function(){return this._level},set:function(e){e>=0&&e<=3?this._level=e:e>3?this._level=3:i.Levels.hasOwnProperty(e)?this._level=e:this.logger.error("invalid 'level' parameter value: "+JSON.stringify(e))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"connector",{get:function(){return this._connector},set:function(e){e?"function"==typeof e?this._connector=e:this.logger.error("invalid 'connector' parameter value: "+JSON.stringify(e)):this._connector=void 0},enumerable:!0,configurable:!0}),e.prototype.getLogger=function(e,t){if(t&&3===this.level)return new n.Logger(this,e,t);if(this.loggers[e])return this.loggers[e];var r=new n.Logger(this,e);return this.loggers[e]=r,r},e.prototype.genericLog=function(e,t,r,n){this.level>=e&&this.builtinEnabled&&this.print(e,t,r,n),this.connector&&this.connector(i.Levels[e],t,r,n)},e.prototype.print=function(e,t,r,n){if("string"==typeof n){var s=[new Date,t];r&&s.push(r),n=s.concat(n).join(" | ")}switch(e){case i.Levels.error:console.error(n);break;case i.Levels.warn:console.warn(n);break;case i.Levels.log:console.log(n);break;case i.Levels.debug:console.debug(n)}},e}();t.LoggerFactory=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r(0).__exportStar(r(74),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(2),s=r(1),o=r(50),a=r(14),c=["application/sdp","application/dtmf-relay"],u=function(){function e(e,t){void 0===t&&(t={}),this.userAgentClients=new Map,this.userAgentServers=new Map,this.configuration=e,this.delegate=t,this.dialogs=new Map,this.subscribers=new Map,this.logger=e.loggerFactory.getLogger("sip.user-agent-core")}return e.prototype.dispose=function(){this.reset()},e.prototype.reset=function(){this.dialogs.forEach(function(e){return e.dispose()}),this.dialogs.clear(),this.subscribers.forEach(function(e){return e.dispose()}),this.subscribers.clear(),this.userAgentClients.forEach(function(e){return e.dispose()}),this.userAgentClients.clear(),this.userAgentServers.forEach(function(e){return e.dispose()}),this.userAgentServers.clear()},Object.defineProperty(e.prototype,"loggerFactory",{get:function(){return this.configuration.loggerFactory},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"transport",{get:function(){var e=this.configuration.transportAccessor();if(!e)throw new Error("Transport undefined.");return e},enumerable:!0,configurable:!0}),e.prototype.invite=function(e,t){return new o.InviteUserAgentClient(this,e,t)},e.prototype.message=function(e,t){return new o.MessageUserAgentClient(this,e,t)},e.prototype.publish=function(e,t){return new o.PublishUserAgentClient(this,e,t)},e.prototype.register=function(e,t){return new o.RegisterUserAgentClient(this,e,t)},e.prototype.subscribe=function(e,t){return new o.SubscribeUserAgentClient(this,e,t)},e.prototype.request=function(e,t){return new o.UserAgentClient(s.NonInviteClientTransaction,this,e,t)},e.prototype.makeOutgoingRequestMessage=function(e,t,r,s,o,a,c){var u=this.configuration.sipjsId,d=this.configuration.displayName,l=this.configuration.viaForceRport,p=this.configuration.hackViaTcp,h=this.configuration.hackViaWS,g=this.configuration.supportedOptionTags.slice();e===n.C.REGISTER&&g.push("path","gruu"),e===n.C.INVITE&&(this.configuration.contact.pubGruu||this.configuration.contact.tempGruu)&&g.push("gruu");var f={callIdPrefix:u,forceRport:l,fromDisplayName:d,hackViaTcp:p,hackViaWS:h,optionTags:g,routeSet:this.configuration.routeSet,userAgentString:this.configuration.userAgentHeaderFieldValue,viaHost:this.configuration.viaHost},v=i.__assign({},f,o);return new n.OutgoingRequestMessage(e,t,r,s,v,a,c)},e.prototype.receiveIncomingRequestFromTransport=function(e){this.receiveRequestFromTransport(e)},e.prototype.receiveIncomingResponseFromTransport=function(e){this.receiveResponseFromTransport(e)},e.prototype.replyStateless=function(e,t){var r=this.configuration.userAgentHeaderFieldValue,s=this.configuration.supportedOptionTagsResponse;t=i.__assign({},t,{userAgent:r,supported:s});var o=n.constructOutgoingResponse(e,t);return this.transport.send(o.message),o},e.prototype.receiveRequestFromTransport=function(e){var t=e.viaBranch,r=this.userAgentServers.get(t);e.method===n.C.ACK&&r&&r.transaction.state===s.TransactionState.Accepted&&r instanceof o.InviteUserAgentServer?this.logger.warn("Discarding out of dialog ACK after 2xx response sent on transaction "+t+"."):e.method!==n.C.CANCEL?r?r.transaction.receiveRequest(e):this.receiveRequest(e):r?(this.replyStateless(e,{statusCode:200}),r.transaction instanceof s.InviteServerTransaction&&r.transaction.state===s.TransactionState.Proceeding&&r instanceof o.InviteUserAgentServer&&r.receiveCancel(e)):this.replyStateless(e,{statusCode:481})},e.prototype.receiveRequest=function(e){if(a.AllowedMethods.includes(e.method)){if(!e.ruri)throw new Error("Request-URI undefined.");if("sip"===e.ruri.scheme){var t=e.ruri,r=function(e){return!!e&&e.user===t.user};if(!r(this.configuration.aor)&&!(r(this.configuration.contact.uri)||r(this.configuration.contact.pubGruu)||r(this.configuration.contact.tempGruu)))return this.logger.warn("Request-URI does not point to us."),void(e.method!==n.C.ACK&&this.replyStateless(e,{statusCode:404}));if(e.method!==n.C.INVITE||e.hasHeader("Contact")){if(!e.toTag){var i=e.viaBranch;if(!this.userAgentServers.has(i))if(Array.from(this.userAgentServers.values()).some(function(t){return t.transaction.request.fromTag===e.fromTag&&t.transaction.request.callId===e.callId&&t.transaction.request.cseq===e.cseq}))return void this.replyStateless(e,{statusCode:482})}e.toTag?this.receiveInsideDialogRequest(e):this.receiveOutsideDialogRequest(e)}else this.replyStateless(e,{statusCode:400,reasonPhrase:"Missing Contact Header"})}else this.replyStateless(e,{statusCode:416})}else{var s="Allow: "+a.AllowedMethods.toString();this.replyStateless(e,{statusCode:405,extraHeaders:[s]})}},e.prototype.receiveInsideDialogRequest=function(e){if(e.method===n.C.NOTIFY){var t=e.parseHeader("Event");if(!t||!t.event)return void this.replyStateless(e,{statusCode:489});var r=e.callId+e.toTag+t.event,i=this.subscribers.get(r);if(i){var s=new o.NotifyUserAgentServer(this,e);return void i.onNotify(s)}}var u=e.callId+e.toTag+e.fromTag,d=this.dialogs.get(u);if(d){if(e.method===n.C.OPTIONS){var l="Allow: "+a.AllowedMethods.toString(),p="Accept: "+c.toString();return void this.replyStateless(e,{statusCode:200,extraHeaders:[l,p]})}d.receiveRequest(e)}else e.method!==n.C.ACK&&this.replyStateless(e,{statusCode:481})},e.prototype.receiveOutsideDialogRequest=function(e){switch(e.method){case n.C.ACK:break;case n.C.BYE:this.replyStateless(e,{statusCode:481});break;case n.C.CANCEL:throw new Error("Unexpected out of dialog request method "+e.method+".");case n.C.INFO:this.replyStateless(e,{statusCode:405});break;case n.C.INVITE:var t=new o.InviteUserAgentServer(this,e);this.delegate.onInvite?this.delegate.onInvite(t):t.reject();break;case n.C.MESSAGE:t=new o.MessageUserAgentServer(this,e);this.delegate.onMessage?this.delegate.onMessage(t):t.accept();break;case n.C.NOTIFY:t=new o.NotifyUserAgentServer(this,e);this.delegate.onNotify?this.delegate.onNotify(t):this.replyStateless(e,{statusCode:405});break;case n.C.OPTIONS:var r="Allow: "+a.AllowedMethods.toString(),i="Accept: "+c.toString();this.replyStateless(e,{statusCode:200,extraHeaders:[r,i]});break;case n.C.REFER:t=new o.ReferUserAgentServer(this,e);this.delegate.onRefer?this.delegate.onRefer(t):this.replyStateless(e,{statusCode:405});break;case n.C.SUBSCRIBE:t=new o.SubscribeUserAgentServer(this,e);this.delegate.onSubscribe?this.delegate.onSubscribe(t):t.reject();break;default:throw new Error("Unexpected out of dialog request method "+e.method+".")}},e.prototype.receiveResponseFromTransport=function(e){if(e.getHeaders("via").length>1)this.logger.warn("More than one Via header field present in the response, dropping");else{var t=e.viaBranch+e.method,r=this.userAgentClients.get(t);r?r.transaction.receiveResponse(e):this.logger.warn("Discarding unmatched "+e.statusCode+" response to "+e.method+" "+t+".")}},e}();t.UserAgentCore=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){return e.call(this,n.NonInviteClientTransaction,t,r,i)||this}return i.__extends(t,e),t}(r(3).UserAgentClient);t.CancelUserAgentClient=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(17),s=r(15),o=r(1),a=function(e){function t(t,r,i){var n=e.call(this,o.InviteClientTransaction,t,r,i)||this;return n.confirmedDialogAcks=new Map,n.confirmedDialogs=new Map,n.earlyDialogs=new Map,n.delegate=i,n}return i.__extends(t,e),t.prototype.dispose=function(){this.earlyDialogs.forEach(function(e){return e.dispose()}),this.earlyDialogs.clear(),e.prototype.dispose.call(this)},t.prototype.receiveResponse=function(e){var t=this;if(this.authenticationGuard(e)){var r=e.statusCode?e.statusCode.toString():"";if(!r)throw new Error("Response status code undefined.");switch(!0){case/^100$/.test(r):return void(this.delegate&&this.delegate.onTrying&&this.delegate.onTrying({message:e}));case/^1[0-9]{2}$/.test(r):if(!e.toTag)return void this.logger.warn("Non-100 1xx INVITE response received without a to tag, dropping.");var i=n.Dialog.initialDialogStateForUserAgentClient(this.message,e),a=this.earlyDialogs.get(i.id);if(!a){if(!((d=this.transaction)instanceof o.InviteClientTransaction))throw new Error("Transaction not instance of InviteClientTransaction.");a=new n.SessionDialog(d,this.core,i),this.earlyDialogs.set(a.id,a)}if(!a.reliableSequenceGuard(e))return void this.logger.warn("1xx INVITE reliable response received out of order, dropping.");a.signalingState!==s.SignalingState.Initial&&a.signalingState!==s.SignalingState.HaveLocalOffer||a.signalingStateTransition(e);var c=a;return void(this.delegate&&this.delegate.onProgress&&this.delegate.onProgress({message:e,session:c,prack:function(e){return c.prack(void 0,e)}}));case/^2[0-9]{2}$/.test(r):i=n.Dialog.initialDialogStateForUserAgentClient(this.message,e);var u=this.confirmedDialogs.get(i.id);if(u){if(p=this.confirmedDialogAcks.get(i.id)){if(!((d=this.transaction)instanceof o.InviteClientTransaction))throw new Error("Client transaction not instance of InviteClientTransaction.");d.ackResponse(p.message)}return}if(u=this.earlyDialogs.get(i.id))u.confirm(),u.recomputeRouteSet(e),this.earlyDialogs.delete(u.id),this.confirmedDialogs.set(u.id,u);else{var d;if(!((d=this.transaction)instanceof o.InviteClientTransaction))throw new Error("Transaction not instance of InviteClientTransaction.");u=new n.SessionDialog(d,this.core,i),this.confirmedDialogs.set(u.id,u)}u.signalingState!==s.SignalingState.Initial&&u.signalingState!==s.SignalingState.HaveLocalOffer||u.signalingStateTransition(e);var l=u;if(this.delegate&&this.delegate.onAccept)this.delegate.onAccept({message:e,session:l,ack:function(e){var r=l.ack(e);return t.confirmedDialogAcks.set(l.id,r),r}});else{var p=l.ack();this.confirmedDialogAcks.set(l.id,p)}return;case/^3[0-9]{2}$/.test(r):return this.earlyDialogs.forEach(function(e){return e.dispose()}),this.earlyDialogs.clear(),void(this.delegate&&this.delegate.onRedirect&&this.delegate.onRedirect({message:e}));case/^[4-6][0-9]{2}$/.test(r):return this.earlyDialogs.forEach(function(e){return e.dispose()}),this.earlyDialogs.clear(),void(this.delegate&&this.delegate.onReject&&this.delegate.onReject({message:e}));default:throw new Error("Invalid status code "+r)}throw new Error("Executing what should be an unreachable code path receiving "+r+" response.")}},t}(r(3).UserAgentClient);t.InviteUserAgentClient=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(17),s=r(16),o=r(15),a=r(1),c=r(14),u=function(e){function t(t,r,i){var n=e.call(this,a.InviteServerTransaction,t,r,i)||this;return n.core=t,n}return i.__extends(t,e),t.prototype.dispose=function(){this.earlyDialog&&this.earlyDialog.dispose(),e.prototype.dispose.call(this)},t.prototype.accept=function(t){if(void 0===t&&(t={statusCode:200}),!this.acceptable)throw new s.TransactionStateError(this.message.method+" not acceptable in state "+this.transaction.state+".");if(!this.confirmedDialog)if(this.earlyDialog)this.earlyDialog.confirm(),this.confirmedDialog=this.earlyDialog,this.earlyDialog=void 0;else{var r=this.transaction;if(!(r instanceof a.InviteServerTransaction))throw new Error("Transaction not instance of InviteClientTransaction.");var u=n.Dialog.initialDialogStateForUserAgentServer(this.message,this.toTag);this.confirmedDialog=new n.SessionDialog(r,this.core,u)}var d=this.message.getHeaders("record-route").map(function(e){return"Record-Route: "+e}),l="Contact: "+this.core.configuration.contact.toString(),p="Allow: "+c.AllowedMethods.toString();if(!t.body)if(this.confirmedDialog.signalingState===o.SignalingState.Stable)t.body=this.confirmedDialog.answer;else if(this.confirmedDialog.signalingState===o.SignalingState.Initial||this.confirmedDialog.signalingState===o.SignalingState.HaveRemoteOffer)throw new Error("Response must have a body.");t.statusCode=t.statusCode||200,t.extraHeaders=t.extraHeaders||[],t.extraHeaders=t.extraHeaders.concat(d),t.extraHeaders.push(p),t.extraHeaders.push(l);var h=e.prototype.accept.call(this,t),g=this.confirmedDialog,f=i.__assign({},h,{session:g});return t.body&&this.confirmedDialog.signalingState!==o.SignalingState.Stable&&this.confirmedDialog.signalingStateTransition(t.body),f},t.prototype.progress=function(t){if(void 0===t&&(t={statusCode:180}),!this.progressable)throw new s.TransactionStateError(this.message.method+" not progressable in state "+this.transaction.state+".");if(!this.earlyDialog){var r=this.transaction;if(!(r instanceof a.InviteServerTransaction))throw new Error("Transaction not instance of InviteClientTransaction.");var c=n.Dialog.initialDialogStateForUserAgentServer(this.message,this.toTag,!0);this.earlyDialog=new n.SessionDialog(r,this.core,c)}var u=this.message.getHeaders("record-route").map(function(e){return"Record-Route: "+e}),d="Contact: "+this.core.configuration.contact;t.extraHeaders=t.extraHeaders||[],t.extraHeaders=t.extraHeaders.concat(u),t.extraHeaders.push(d);var l=e.prototype.progress.call(this,t),p=this.earlyDialog,h=i.__assign({},l,{session:p});return t.body&&this.earlyDialog.signalingState!==o.SignalingState.Stable&&this.earlyDialog.signalingStateTransition(t.body),h},t.prototype.redirect=function(t,r){return void 0===r&&(r={statusCode:302}),e.prototype.redirect.call(this,t,r)},t.prototype.reject=function(t){return void 0===t&&(t={statusCode:486}),e.prototype.reject.call(this,t)},t}(r(4).UserAgentServer);t.InviteUserAgentServer=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){return e.call(this,n.NonInviteClientTransaction,t,r,i)||this}return i.__extends(t,e),t}(r(3).UserAgentClient);t.MessageUserAgentClient=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){var s=e.call(this,n.NonInviteServerTransaction,t,r,i)||this;return s.core=t,s}return i.__extends(t,e),t}(r(4).UserAgentServer);t.MessageUserAgentServer=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){return e.call(this,n.NonInviteClientTransaction,t,r,i)||this}return i.__extends(t,e),t}(r(3).UserAgentClient);t.PublishUserAgentClient=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){return e.call(this,n.NonInviteServerTransaction,t.userAgentCore,r,i)||this}return i.__extends(t,e),t}(r(4).UserAgentServer);t.ReSubscribeUserAgentServer=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){return e.call(this,n.NonInviteClientTransaction,t,r,i)||this}return i.__extends(t,e),t}(r(3).UserAgentClient);t.RegisterUserAgentClient=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(47),s=r(27),o=r(6),a=r(1),c=function(e){function t(t,r,i){var n=this,o=r.getHeader("Event");if(!o)throw new Error("Event undefined");var c=r.getHeader("Expires");if(!c)throw new Error("Expires undefined");return(n=e.call(this,a.NonInviteClientTransaction,t,r,i)||this).delegate=i,n.subscriberId=r.callId+r.fromTag+o,n.subscriptionExpiresRequested=n.subscriptionExpires=Number(c),n.subscriptionEvent=o,n.subscriptionState=s.SubscriptionState.NotifyWait,n.waitNotifyStart(),n}return i.__extends(t,e),t.prototype.dispose=function(){e.prototype.dispose.call(this)},t.prototype.onNotify=function(e){var t=e.message.parseHeader("Event").event;if(!t||t!==this.subscriptionEvent)return this.logger.warn("Failed to parse event."),void e.reject({statusCode:489});var r=e.message.parseHeader("Subscription-State");if(!r||!r.state)return this.logger.warn("Failed to parse subscription state."),void e.reject({statusCode:489});var i=r.state;switch(i){case"pending":case"active":case"terminated":break;default:return this.logger.warn("Invalid subscription state "+i),void e.reject({statusCode:489})}if("terminated"!==i&&!e.message.parseHeader("contact"))return this.logger.warn("Failed to parse contact."),void e.reject({statusCode:489});if(this.dialog)throw new Error("Dialog already created. This implementation only supports install of single subscriptions.");switch(this.waitNotifyStop(),this.subscriptionExpires=r.expires?Math.min(this.subscriptionExpires,Math.max(r.expires,0)):this.subscriptionExpires,i){case"pending":this.subscriptionState=s.SubscriptionState.Pending;break;case"active":this.subscriptionState=s.SubscriptionState.Active;break;case"terminated":this.subscriptionState=s.SubscriptionState.Terminated;break;default:throw new Error("Unrecognized state "+i+".")}if(this.subscriptionState!==s.SubscriptionState.Terminated){var o=n.SubscriptionDialog.initialDialogStateForSubscription(this.message,e.message);this.dialog=new n.SubscriptionDialog(this.subscriptionEvent,this.subscriptionExpires,this.subscriptionState,this.core,o)}if(this.delegate&&this.delegate.onNotify){var a=e,c=this.dialog;this.delegate.onNotify({request:a,subscription:c})}else e.accept()},t.prototype.waitNotifyStart=function(){var e=this;this.N||(this.core.subscribers.set(this.subscriberId,this),this.N=setTimeout(function(){return e.timer_N()},o.Timers.TIMER_N))},t.prototype.waitNotifyStop=function(){this.N&&(this.core.subscribers.delete(this.subscriberId),clearTimeout(this.N),this.N=void 0)},t.prototype.receiveResponse=function(t){if(this.authenticationGuard(t)){if(t.statusCode&&t.statusCode>=200&&t.statusCode<300){var r=t.getHeader("Expires");if(r){var i=Number(r);i>this.subscriptionExpiresRequested&&this.logger.warn("Expires header in a 200-class response to SUBSCRIBE with a higher value than the one in the request"),i<this.subscriptionExpires&&(this.subscriptionExpires=i)}else this.logger.warn("Expires header missing in a 200-class response to SUBSCRIBE");this.dialog&&this.dialog.subscriptionExpires>this.subscriptionExpires&&(this.dialog.subscriptionExpires=this.subscriptionExpires)}t.statusCode&&t.statusCode>=300&&t.statusCode<700&&this.waitNotifyStop(),e.prototype.receiveResponse.call(this,t)}},t.prototype.timer_N=function(){this.logger.warn("Timer N expired for SUBSCRIBE user agent client. Timed out waiting for NOTIFY."),this.waitNotifyStop(),this.delegate&&this.delegate.onNotifyTimeout&&this.delegate.onNotifyTimeout()},t}(r(3).UserAgentClient);t.SubscribeUserAgentClient=c},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(1),s=function(e){function t(t,r,i){var s=e.call(this,n.NonInviteServerTransaction,t,r,i)||this;return s.core=t,s}return i.__extends(t,e),t}(r(4).UserAgentServer);t.SubscribeUserAgentServer=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=function(e){function t(t,r){var i=e.call(this)||this;return i.logger=t,i}return i.__extends(t,e),t.prototype.connect=function(e){var t=this;return void 0===e&&(e={}),this.connectPromise(e).then(function(e){e.overrideEvent||t.emit("connected")})},t.prototype.send=function(e,t){var r=this;return void 0===t&&(t={}),this.sendPromise(e).then(function(e){e.overrideEvent||r.emit("messageSent",e.msg)})},t.prototype.disconnect=function(e){var t=this;return void 0===e&&(e={}),this.disconnectPromise(e).then(function(e){e.overrideEvent||t.emit("disconnected")})},t.prototype.afterConnected=function(e){this.isConnected()?e():this.once("connected",e)},t.prototype.waitForConnected=function(){var e=this;return console.warn("DEPRECATION WARNING Transport.waitForConnected(): use afterConnected() instead"),new Promise(function(t){e.afterConnected(t)})},t}(r(7).EventEmitter);t.Transport=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(e,t){for(var r,i=[],n=e.split(/\r\n/),s=0;s<n.length;){var o=n[s];if(/^m=(?:audio|video)/.test(o))r={index:s,stripped:[]},i.push(r);else if(r){var a=/^a=rtpmap:(\d+) ([^/]+)\//.exec(o);if(a&&t===a[2]){n.splice(s,1),r.stripped.push(a[1]);continue}}s++}for(var c=0,u=i;c<u.length;c++){for(var d=u[c],l=n[d.index].split(" "),p=3;p<l.length;)-1===d.stripped.indexOf(l[p])?p++:l.splice(p,1);n[d.index]=l.join(" ")}return n.join("\r\n")},n=function(e,t){var r=new RegExp("m="+t+".*$","gm"),i=new RegExp("^a=group:.*$","gm");if(r.test(e)){var n,s=(e=e.split(/^m=/gm).filter(function(e){if(e.substr(0,t.length)===t){if(n=e.match(/^a=mid:.*$/gm)){var r=n[0].match(/:.+$/g);r&&(n=r[0].substr(1))}return!1}return!0}).join("m=")).match(i);if(s&&1===s.length){var o=s[0],a=new RegExp(" *"+n+"[^ ]*","g");o=o.replace(a,""),e=e.split(i).join(o)}}return e};t.stripTcpCandidates=function(e){return e.sdp=(e.sdp||"").replace(/^a=candidate:\d+ \d+ tcp .*?\r\n/gim,""),Promise.resolve(e)},t.stripTelephoneEvent=function(e){return e.sdp=i(e.sdp||"","telephone-event"),Promise.resolve(e)},t.cleanJitsiSdpImageattr=function(e){return e.sdp=(e.sdp||"").replace(/^(a=imageattr:.*?)(x|y)=\[0-/gm,"$1$2=[1:"),Promise.resolve(e)},t.stripG722=function(e){return e.sdp=i(e.sdp||"","G722"),Promise.resolve(e)},t.stripRtpPayload=function(e){return function(t){return t.sdp=i(t.sdp||"",e),Promise.resolve(t)}},t.stripVideo=function(e){return e.sdp=n(e.sdp||"","video"),Promise.resolve(e)},t.addMidLines=function(e){var t=e.sdp||"";if(-1===t.search(/^a=mid.*$/gm)){var r=t.match(/^m=.*$/gm),i=t.split(/^m=.*$/gm);r&&r.forEach(function(e,t){r[t]=e+"\na=mid:"+t}),i.forEach(function(e,t){r&&r[t]&&(i[t]=e+r[t])}),t=i.join(""),e.sdp=t}return Promise.resolve(e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(5);!function(e){function t(e,t){var r=t,i=0,n=0;if(e.substring(r,r+2).match(/(^\r\n)/))return-2;for(;0===i;){if(-1===(n=e.indexOf("\r\n",r)))return n;!e.substring(n+2,n+4).match(/(^\r\n)/)&&e.charAt(n+2).match(/(^\s+)/)?r=n+2:i=n}return i}function r(e,t,r,n){var s,o=t.indexOf(":",r),a=t.substring(r,o).trim(),c=t.substring(o+1,n).trim();switch(a.toLowerCase()){case"via":case"v":e.addHeader("via",c),1===e.getHeaders("via").length?(s=e.parseHeader("Via"))&&(e.via=s,e.viaBranch=s.branch):s=0;break;case"from":case"f":e.setHeader("from",c),(s=e.parseHeader("from"))&&(e.from=s,e.fromTag=s.getParam("tag"));break;case"to":case"t":e.setHeader("to",c),(s=e.parseHeader("to"))&&(e.to=s,e.toTag=s.getParam("tag"));break;case"record-route":if(-1===(s=i.Grammar.parse(c,"Record_Route"))){s=void 0;break}for(var u in s)s[u]&&(e.addHeader("record-route",c.substring(s[u].position,s[u].offset)),e.headers["Record-Route"][e.getHeaders("record-route").length-1].parsed=s[u].parsed);break;case"call-id":case"i":e.setHeader("call-id",c),(s=e.parseHeader("call-id"))&&(e.callId=c);break;case"contact":case"m":if(-1===(s=i.Grammar.parse(c,"Contact"))){s=void 0;break}if(!(s instanceof Array)){s=void 0;break}s.forEach(function(t){e.addHeader("contact",c.substring(t.position,t.offset)),e.headers.Contact[e.getHeaders("contact").length-1].parsed=t.parsed});break;case"content-length":case"l":e.setHeader("content-length",c),s=e.parseHeader("content-length");break;case"content-type":case"c":e.setHeader("content-type",c),s=e.parseHeader("content-type");break;case"cseq":e.setHeader("cseq",c),(s=e.parseHeader("cseq"))&&(e.cseq=s.value),e instanceof i.IncomingResponseMessage&&(e.method=s.method);break;case"max-forwards":e.setHeader("max-forwards",c),s=e.parseHeader("max-forwards");break;case"www-authenticate":e.setHeader("www-authenticate",c),s=e.parseHeader("www-authenticate");break;case"proxy-authenticate":e.setHeader("proxy-authenticate",c),s=e.parseHeader("proxy-authenticate");break;case"refer-to":case"r":e.setHeader("refer-to",c),(s=e.parseHeader("refer-to"))&&(e.referTo=s);break;default:e.addHeader(a.toLowerCase(),c),s=0}return void 0!==s||{error:"error parsing header '"+a+"'"}}e.getHeader=t,e.parseHeader=r,e.parseMessage=function(e,n){var s=0,o=e.indexOf("\r\n");if(-1!==o){var a,c=e.substring(0,o),u=i.Grammar.parse(c,"Request_Response");if(-1!==u){var d;for(u.status_code?((a=new i.IncomingResponseMessage).statusCode=u.status_code,a.reasonPhrase=u.reason_phrase):((a=new i.IncomingRequestMessage).method=u.method,a.ruri=u.uri),a.data=e,s=o+2;;){if(-2===(o=t(e,s))){d=s+2;break}if(-1===o)return void n.error("malformed message");if(!0!==r(a,e,s,o))return void n.error(u.error);s=o+2}return a.hasHeader("content-length")?a.body=e.substr(d,Number(a.getHeader("content-length"))):a.body=e.substring(d),a}n.warn('error parsing first line of SIP message: "'+c+'"')}else n.warn("no CRLF found, not a SIP message, discarded")}}(t.Parser||(t.Parser={}))},,function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(7),s=r(52),o=r(8),a=r(11),c=r(9),u=i.__importStar(r(86)),d=r(95),l=function(e){function t(t,r,i){var n=e.call(this)||this;return n.type=o.TypeStrings.SessionDescriptionHandler,n.options=i||{},n.logger=t,n.observer=r,n.dtmfSender=void 0,n.shouldAcquireMedia=!0,n.CONTENT_TYPE="application/sdp",n.C={DIRECTION:{NULL:null,SENDRECV:"sendrecv",SENDONLY:"sendonly",RECVONLY:"recvonly",INACTIVE:"inactive"}},n.logger.log("SessionDescriptionHandlerOptions: "+JSON.stringify(n.options)),n.direction=n.C.DIRECTION.NULL,n.modifiers=n.options.modifiers||[],Array.isArray(n.modifiers)||(n.modifiers=[n.modifiers]),n.iceGatheringTimeout=!1,n.initPeerConnection(n.options.peerConnectionOptions),n.constraints=n.checkAndDefaultConstraints(n.options.constraints),n}return i.__extends(t,e),t.defaultFactory=function(e,r){return new t(e instanceof s.Session?e.userAgent.getLogger("sip.sessionDescriptionHandler",e.id):e.ua.getLogger("sip.invitecontext.sessionDescriptionHandler",e.id),new d.SessionDescriptionHandlerObserver(e,r),r)},t.prototype.close=function(){this.logger.log("closing PeerConnection"),this.peerConnection&&"closed"!==this.peerConnection.signalingState&&(this.peerConnection.getSenders?this.peerConnection.getSenders().forEach(function(e){e.track&&e.track.stop()}):(this.logger.warn("Using getLocalStreams which is deprecated"),this.peerConnection.getLocalStreams().forEach(function(e){e.getTracks().forEach(function(e){e.stop()})})),this.peerConnection.getReceivers?this.peerConnection.getReceivers().forEach(function(e){e.track&&e.track.stop()}):(this.logger.warn("Using getRemoteStreams which is deprecated"),this.peerConnection.getRemoteStreams().forEach(function(e){e.getTracks().forEach(function(e){e.stop()})})),this.resetIceGatheringComplete(),this.peerConnection.close())},t.prototype.getDescription=function(e,t){var r=this;void 0===e&&(e={}),void 0===t&&(t=[]),e.peerConnectionOptions&&this.initPeerConnection(e.peerConnectionOptions);var i=Object.assign({},this.constraints,e.constraints);return i=this.checkAndDefaultConstraints(i),JSON.stringify(i)!==JSON.stringify(this.constraints)&&(this.constraints=i,this.shouldAcquireMedia=!0),Array.isArray(t)||(t=[t]),t=t.concat(this.modifiers),Promise.resolve().then(function(){if(r.shouldAcquireMedia)return r.acquire(r.constraints).then(function(){r.shouldAcquireMedia=!1})}).then(function(){return r.createOfferOrAnswer(e.RTCOfferOptions,t)}).then(function(e){if(void 0===e.sdp)throw new a.Exceptions.SessionDescriptionHandlerError("getDescription",void 0,"SDP undefined");return r.emit("getDescription",e),{body:e.sdp,contentType:r.CONTENT_TYPE}})},t.prototype.hasDescription=function(e){return e===this.CONTENT_TYPE},t.prototype.holdModifier=function(e){return e.sdp?(/a=(sendrecv|sendonly|recvonly|inactive)/.test(e.sdp)?(e.sdp=e.sdp.replace(/a=sendrecv\r\n/g,"a=sendonly\r\n"),e.sdp=e.sdp.replace(/a=recvonly\r\n/g,"a=inactive\r\n")):e.sdp=e.sdp.replace(/(m=[^\r]*\r\n)/g,"$1a=sendonly\r\n"),Promise.resolve(e)):Promise.resolve(e)},t.prototype.setDescription=function(e,t,r){var i=this;void 0===t&&(t={}),void 0===r&&(r=[]),t.peerConnectionOptions&&this.initPeerConnection(t.peerConnectionOptions),Array.isArray(r)||(r=[r]),r=r.concat(this.modifiers);var n={type:this.hasOffer("local")?"answer":"offer",sdp:e};return Promise.resolve().then(function(){if(i.shouldAcquireMedia&&i.options.alwaysAcquireMediaFirst)return i.acquire(i.constraints).then(function(){i.shouldAcquireMedia=!1})}).then(function(){return c.Utils.reducePromises(r,n)}).catch(function(e){if(e.type===o.TypeStrings.SessionDescriptionHandlerError)throw e;var t=new a.Exceptions.SessionDescriptionHandlerError("setDescription",e,"The modifiers did not resolve successfully");throw i.logger.error(t.message),i.emit("peerConnection-setRemoteDescriptionFailed",t),t}).then(function(e){return i.emit("setDescription",e),i.peerConnection.setRemoteDescription(e)}).catch(function(n){if(n.type===o.TypeStrings.SessionDescriptionHandlerError)throw n;if(/^m=video.+$/gm.test(e)&&!t.disableAudioFallback)return t.disableAudioFallback=!0,i.setDescription(e,t,[u.stripVideo].concat(r));var s=new a.Exceptions.SessionDescriptionHandlerError("setDescription",n);throw s.error&&i.logger.error(s.error),i.emit("peerConnection-setRemoteDescriptionFailed",s),s}).then(function(){i.peerConnection.getReceivers?i.emit("setRemoteDescription",i.peerConnection.getReceivers()):i.emit("setRemoteDescription",i.peerConnection.getRemoteStreams()),i.emit("confirmed",i)})},t.prototype.sendDtmf=function(e,t){if(void 0===t&&(t={}),!this.dtmfSender&&this.hasBrowserGetSenderSupport()){var r=this.peerConnection.getSenders();r.length>0&&(this.dtmfSender=r[0].dtmf)}if(!this.dtmfSender&&this.hasBrowserTrackSupport()){var i=this.peerConnection.getLocalStreams();if(i.length>0){var n=i[0].getAudioTracks();n.length>0&&(this.dtmfSender=this.peerConnection.createDTMFSender(n[0]))}}if(!this.dtmfSender)return!1;try{this.dtmfSender.insertDTMF(e,t.duration,t.interToneGap)}catch(e){if("InvalidStateError"===e.type||"InvalidCharacterError"===e.type)return this.logger.error(e),!1;throw e}return this.logger.log("DTMF sent via RTP: "+e.toString()),!0},t.prototype.getDirection=function(){return this.direction},t.prototype.on=function(t,r){return e.prototype.on.call(this,t,r)},t.prototype.getMediaStream=function(e){return navigator.mediaDevices.getUserMedia(e)},t.prototype.createOfferOrAnswer=function(e,t){var r=this;void 0===e&&(e={}),void 0===t&&(t=[]);var i=this.hasOffer("remote")?"createAnswer":"createOffer",n=this.peerConnection;return this.logger.log(i),(this.hasOffer("remote")?n.createAnswer:n.createOffer).apply(n,e).catch(function(e){if(e.type===o.TypeStrings.SessionDescriptionHandlerError)throw e;var t=new a.Exceptions.SessionDescriptionHandlerError("createOfferOrAnswer",e,"peerConnection-"+i+"Failed");throw r.emit("peerConnection-"+i+"Failed",t),t}).then(function(e){return c.Utils.reducePromises(t,r.createRTCSessionDescriptionInit(e))}).then(function(e){return r.resetIceGatheringComplete(),r.logger.log("Setting local sdp."),r.logger.log("sdp is "+e.sdp||!1),n.setLocalDescription(e)}).catch(function(e){if(e.type===o.TypeStrings.SessionDescriptionHandlerError)throw e;var t=new a.Exceptions.SessionDescriptionHandlerError("createOfferOrAnswer",e,"peerConnection-SetLocalDescriptionFailed");throw r.emit("peerConnection-SetLocalDescriptionFailed",t),t}).then(function(){return r.waitForIceGatheringComplete()}).then(function(){if(!r.peerConnection.localDescription)throw new a.Exceptions.SessionDescriptionHandlerError("Missing local description");var e=r.createRTCSessionDescriptionInit(r.peerConnection.localDescription);return c.Utils.reducePromises(t,e)}).then(function(e){return r.setDirection(e.sdp||""),e}).catch(function(e){if(e.type===o.TypeStrings.SessionDescriptionHandlerError)throw e;var t=new a.Exceptions.SessionDescriptionHandlerError("createOfferOrAnswer",e);throw r.logger.error(t.toString()),t})},t.prototype.createRTCSessionDescriptionInit=function(e){return{type:e.type,sdp:e.sdp}},t.prototype.addDefaultIceCheckingTimeout=function(e){return void 0===e.iceCheckingTimeout&&(e.iceCheckingTimeout=5e3),e},t.prototype.addDefaultIceServers=function(e){return e.iceServers||(e.iceServers=[{urls:"stun:stun.l.google.com:19302"}]),e},t.prototype.checkAndDefaultConstraints=function(e){var t={audio:!0,video:!this.options.alwaysAcquireMediaFirst};return e=e||t,0===Object.keys(e).length&&e.constructor===Object?t:e},t.prototype.hasBrowserTrackSupport=function(){return Boolean(this.peerConnection.addTrack)},t.prototype.hasBrowserGetSenderSupport=function(){return Boolean(this.peerConnection.getSenders)},t.prototype.initPeerConnection=function(e){var t=this;void 0===e&&(e={}),(e=this.addDefaultIceCheckingTimeout(e)).rtcConfiguration=e.rtcConfiguration||{},e.rtcConfiguration=this.addDefaultIceServers(e.rtcConfiguration),this.logger.log("initPeerConnection"),this.peerConnection&&(this.logger.log("Already have a peer connection for this session. Tearing down."),this.resetIceGatheringComplete(),this.peerConnection.close()),this.peerConnection=new RTCPeerConnection(e.rtcConfiguration),this.logger.log("New peer connection created"),"ontrack"in this.peerConnection?this.peerConnection.addEventListener("track",function(e){t.logger.log("track added"),t.observer.trackAdded(),t.emit("addTrack",e)}):(this.logger.warn("Using onaddstream which is deprecated"),this.peerConnection.onaddstream=function(e){t.logger.log("stream added"),t.emit("addStream",e)}),this.peerConnection.onicecandidate=function(e){t.emit("iceCandidate",e),e.candidate?t.logger.log("ICE candidate received: "+(null===e.candidate.candidate?null:e.candidate.candidate.trim())):null===e.candidate&&(t.logger.log("ICE candidate gathering complete"),t.triggerIceGatheringComplete())},this.peerConnection.onicegatheringstatechange=function(){switch(t.logger.log("RTCIceGatheringState changed: "+t.peerConnection.iceGatheringState),t.peerConnection.iceGatheringState){case"gathering":t.emit("iceGathering",t),!t.iceGatheringTimer&&e.iceCheckingTimeout&&(t.iceGatheringTimeout=!1,t.iceGatheringTimer=setTimeout(function(){t.logger.log("RTCIceChecking Timeout Triggered after "+e.iceCheckingTimeout+" milliseconds"),t.iceGatheringTimeout=!0,t.triggerIceGatheringComplete()},e.iceCheckingTimeout));break;case"complete":t.triggerIceGatheringComplete()}},this.peerConnection.oniceconnectionstatechange=function(){var e;switch(t.peerConnection.iceConnectionState){case"new":e="iceConnection";break;case"checking":e="iceConnectionChecking";break;case"connected":e="iceConnectionConnected";break;case"completed":e="iceConnectionCompleted";break;case"failed":e="iceConnectionFailed";break;case"disconnected":e="iceConnectionDisconnected";break;case"closed":e="iceConnectionClosed";break;default:return void t.logger.warn("Unknown iceConnection state: "+t.peerConnection.iceConnectionState)}t.logger.log("ICE Connection State changed to "+e),t.emit(e,t)}},t.prototype.acquire=function(e){var t=this;return e=this.checkAndDefaultConstraints(e),new Promise(function(r,i){t.logger.log("acquiring local media"),t.emit("userMediaRequest",e),e.audio||e.video?t.getMediaStream(e).then(function(e){t.observer.trackAdded(),t.emit("userMedia",e),r(e)}).catch(function(e){t.emit("userMediaFailed",e),i(e)}):r([])}).catch(function(e){if(e.type===o.TypeStrings.SessionDescriptionHandlerError)throw e;var r=new a.Exceptions.SessionDescriptionHandlerError("acquire",e,"unable to acquire streams");throw t.logger.error(r.message),r.error&&t.logger.error(r.error),r}).then(function(e){return t.logger.log("acquired local media streams"),t.peerConnection.removeTrack&&t.peerConnection.getSenders().forEach(function(e){t.peerConnection.removeTrack(e)}),e}).catch(function(e){if(e.type===o.TypeStrings.SessionDescriptionHandlerError)throw e;var r=new a.Exceptions.SessionDescriptionHandlerError("acquire",e,"error removing streams");throw t.logger.error(r.message),r.error&&t.logger.error(r.error),r}).then(function(e){return[].concat(e).forEach(function(e){t.peerConnection.addTrack?e.getTracks().forEach(function(r){t.peerConnection.addTrack(r,e)}):t.peerConnection.addStream(e)}),Promise.resolve()}).catch(function(e){if(e.type===o.TypeStrings.SessionDescriptionHandlerError)throw e;var r=new a.Exceptions.SessionDescriptionHandlerError("acquire",e,"error adding stream");throw t.logger.error(r.message),r.error&&t.logger.error(r.error),r})},t.prototype.hasOffer=function(e){var t="have-"+e+"-offer";return this.peerConnection.signalingState===t},t.prototype.isIceGatheringComplete=function(){return"complete"===this.peerConnection.iceGatheringState||this.iceGatheringTimeout},t.prototype.resetIceGatheringComplete=function(){this.iceGatheringTimeout=!1,this.logger.log("resetIceGatheringComplete"),this.iceGatheringTimer&&(clearTimeout(this.iceGatheringTimer),this.iceGatheringTimer=void 0),this.iceGatheringDeferred&&(this.iceGatheringDeferred.reject(),this.iceGatheringDeferred=void 0)},t.prototype.setDirection=function(e){var t=e.match(/a=(sendrecv|sendonly|recvonly|inactive)/);if(null===t)return this.direction=this.C.DIRECTION.NULL,void this.observer.directionChanged();var r=t[1];switch(r){case this.C.DIRECTION.SENDRECV:case this.C.DIRECTION.SENDONLY:case this.C.DIRECTION.RECVONLY:case this.C.DIRECTION.INACTIVE:this.direction=r;break;default:this.direction=this.C.DIRECTION.NULL}this.observer.directionChanged()},t.prototype.triggerIceGatheringComplete=function(){this.isIceGatheringComplete()&&(this.emit("iceGatheringComplete",this),this.iceGatheringTimer&&(clearTimeout(this.iceGatheringTimer),this.iceGatheringTimer=void 0),this.iceGatheringDeferred&&(this.iceGatheringDeferred.resolve(),this.iceGatheringDeferred=void 0))},t.prototype.waitForIceGatheringComplete=function(){return this.logger.log("waitForIceGatheringComplete"),this.isIceGatheringComplete()?(this.logger.log("ICE is already complete. Return resolved."),Promise.resolve()):(this.iceGatheringDeferred||(this.iceGatheringDeferred=c.Utils.defer()),this.logger.log("ICE is not complete. Returning promise"),this.iceGatheringDeferred?this.iceGatheringDeferred.promise:Promise.resolve())},t}(n.EventEmitter);t.SessionDescriptionHandler=l},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e){this.incomingInfoRequest=e}return Object.defineProperty(e.prototype,"request",{get:function(){return this.incomingInfoRequest.message},enumerable:!0,configurable:!0}),e.prototype.accept=function(e){return this.incomingInfoRequest.accept(e),Promise.resolve()},e.prototype.reject=function(e){return this.incomingInfoRequest.reject(e),Promise.resolve()},e}();t.Info=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(5),n=function(){function e(e,t){this.incomingReferRequest=e,this.session=t}return Object.defineProperty(e.prototype,"referTo",{get:function(){var e=this.incomingReferRequest.message.parseHeader("refer-to");if(!(e instanceof i.NameAddrHeader))throw new Error("Failed to parse Refer-To header.");return e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"referredBy",{get:function(){return this.incomingReferRequest.message.getHeader("referred-by")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"replaces",{get:function(){return this.referTo.uri.getHeader("replaces")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"request",{get:function(){return this.incomingReferRequest.message},enumerable:!0,configurable:!0}),e.prototype.accept=function(e){return void 0===e&&(e={statusCode:202}),this.incomingReferRequest.accept(e),Promise.resolve()},e.prototype.reject=function(e){return this.incomingReferRequest.reject(e),Promise.resolve()},e.prototype.makeInviter=function(e){if(this.inviter)return this.inviter;var t=this.referTo.uri.clone();t.clearHeaders();var r=((e=e||{}).extraHeaders||[]).slice(),i=this.replaces;i&&r.push("Replaces: "+decodeURIComponent(i));var n=this.referredBy;return n&&r.push("Referred-By: "+n),e.extraHeaders=r,this.inviter=this.session.userAgent.makeInviter(t,e),this.inviter.referred=this.session,this.session.referral=this.inviter,this.inviter},e}();t.Referral=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i,n=r(0),s=r(5),o=r(8),a=r(11),c=r(9);!function(e){e[e.STATUS_CONNECTING=0]="STATUS_CONNECTING",e[e.STATUS_OPEN=1]="STATUS_OPEN",e[e.STATUS_CLOSING=2]="STATUS_CLOSING",e[e.STATUS_CLOSED=3]="STATUS_CLOSED"}(i=t.TransportStatus||(t.TransportStatus={}));var u=function(e){function t(t,r){void 0===r&&(r={});var n=e.call(this,t,r)||this;return n.type=o.TypeStrings.Transport,n.reconnectionAttempts=0,n.status=i.STATUS_CONNECTING,n.configuration=n.loadConfig(r),n.server=n.configuration.wsServers[0],n}return n.__extends(t,e),t.prototype.isConnected=function(){return this.status===i.STATUS_OPEN},t.prototype.sendPromise=function(e,t){if(void 0===t&&(t={}),!this.statusAssert(i.STATUS_OPEN,t.force))return this.onError("unable to send message - WebSocket not open"),Promise.reject();var r=e.toString();return this.ws?(!0===this.configuration.traceSip&&this.logger.log("sending WebSocket message:\n\n"+r+"\n"),this.ws.send(r),Promise.resolve({msg:r})):(this.onError("unable to send message - WebSocket does not exist"),Promise.reject())},t.prototype.disconnectPromise=function(e){var t=this;return void 0===e&&(e={}),this.disconnectionPromise?this.disconnectionPromise:(e.code=e.code||1e3,this.statusTransition(i.STATUS_CLOSING,e.force)?(this.emit("disconnecting"),this.disconnectionPromise=new Promise(function(r,i){t.disconnectDeferredResolve=r,t.reconnectTimer&&(clearTimeout(t.reconnectTimer),t.reconnectTimer=void 0),t.ws?(t.stopSendingKeepAlives(),t.logger.log("closing WebSocket "+t.server.wsUri),t.ws.close(e.code,e.reason)):i("Attempted to disconnect but the websocket doesn't exist")}),this.disconnectionPromise):this.status===i.STATUS_CLOSED?Promise.resolve({overrideEvent:!0}):this.connectionPromise?this.connectionPromise.then(function(){return Promise.reject("The websocket did not disconnect")}).catch(function(){return Promise.resolve({overrideEvent:!0})}):Promise.reject("The websocket did not disconnect"))},t.prototype.connectPromise=function(e){var t=this;return void 0===e&&(e={}),this.status!==i.STATUS_CLOSING||e.force?this.connectionPromise?this.connectionPromise:(this.server=this.server||this.getNextWsServer(e.force),this.connectionPromise=new Promise(function(r,n){if((t.status===i.STATUS_OPEN||t.status===i.STATUS_CLOSING)&&!e.force)return t.logger.warn("WebSocket "+t.server.wsUri+" is already connected"),void n("Failed status check - attempted to open a connection but already open/closing");t.connectDeferredResolve=r,t.connectDeferredReject=n,t.status=i.STATUS_CONNECTING,t.emit("connecting"),t.logger.log("connecting to WebSocket "+t.server.wsUri),t.disposeWs();try{t.ws=new WebSocket(t.server.wsUri,"sip")}catch(e){return t.ws=null,t.statusTransition(i.STATUS_CLOSED,!0),t.onError("error connecting to WebSocket "+t.server.wsUri+":"+e),n("Failed to create a websocket"),t.connectDeferredResolve=void 0,void(t.connectDeferredReject=void 0)}if(!t.ws)return n("Unexpected instance websocket not set"),t.connectDeferredResolve=void 0,void(t.connectDeferredReject=void 0);t.connectionTimeout=setTimeout(function(){t.statusTransition(i.STATUS_CLOSED),t.logger.warn("took too long to connect - exceeded time set in configuration.connectionTimeout: "+t.configuration.connectionTimeout+"s"),t.emit("disconnected",{code:1e3}),t.connectionPromise=void 0,n("Connection timeout"),t.connectDeferredResolve=void 0,t.connectDeferredReject=void 0;var e=t.ws;t.disposeWs(),e.close(1e3)},1e3*t.configuration.connectionTimeout),t.boundOnOpen=t.onOpen.bind(t),t.boundOnMessage=t.onMessage.bind(t),t.boundOnClose=t.onClose.bind(t),t.boundOnError=t.onWebsocketError.bind(t),t.ws.addEventListener("open",t.boundOnOpen),t.ws.addEventListener("message",t.boundOnMessage),t.ws.addEventListener("close",t.boundOnClose),t.ws.addEventListener("error",t.boundOnError)}),this.connectionPromise):Promise.reject("WebSocket "+this.server.wsUri+" is closing")},t.prototype.onMessage=function(e){var t,r=e.data;if(/^(\r\n)+$/.test(r))return this.clearKeepAliveTimeout(),void(!0===this.configuration.traceSip&&this.logger.log("received WebSocket message with CRLF Keep Alive response"));if(r){if("string"!=typeof r){try{t=String.fromCharCode.apply(null,new Uint8Array(r))}catch(e){return void this.logger.warn("received WebSocket binary message failed to be converted into string, message discarded")}!0===this.configuration.traceSip&&this.logger.log("received WebSocket binary message:\n\n"+r+"\n")}else!0===this.configuration.traceSip&&this.logger.log("received WebSocket text message:\n\n"+r+"\n"),t=r;this.emit("message",t)}else this.logger.warn("received empty message, message discarded")},t.prototype.onOpen=function(){if(this.status===i.STATUS_CLOSED){var e=this.ws;return this.disposeWs(),void e.close(1e3)}this.statusTransition(i.STATUS_OPEN,!0),this.emit("connected"),this.connectionTimeout&&(clearTimeout(this.connectionTimeout),this.connectionTimeout=void 0),this.logger.log("WebSocket "+this.server.wsUri+" connected"),void 0!==this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=void 0),this.reconnectionAttempts=0,this.disconnectionPromise=void 0,this.disconnectDeferredResolve=void 0,this.startSendingKeepAlives(),this.connectDeferredResolve?(this.connectDeferredResolve({overrideEvent:!0}),this.connectDeferredResolve=void 0,this.connectDeferredReject=void 0):this.logger.warn("Unexpected websocket.onOpen with no connectDeferredResolve")},t.prototype.onClose=function(e){if(this.logger.log("WebSocket disconnected (code: "+e.code+(e.reason?"| reason: "+e.reason:"")+")"),this.status!==i.STATUS_CLOSING&&(this.logger.warn("WebSocket closed without SIP.js requesting it"),this.emit("transportError")),this.stopSendingKeepAlives(),this.connectionTimeout&&clearTimeout(this.connectionTimeout),this.connectDeferredReject&&this.connectDeferredReject("Websocket Closed"),this.connectionTimeout=void 0,this.connectionPromise=void 0,this.connectDeferredResolve=void 0,this.connectDeferredReject=void 0,this.disconnectDeferredResolve)return this.disconnectDeferredResolve({overrideEvent:!0}),this.statusTransition(i.STATUS_CLOSED),void(this.disconnectDeferredResolve=void 0);this.statusTransition(i.STATUS_CLOSED,!0),this.emit("disconnected",{code:e.code,reason:e.reason}),this.disposeWs(),this.reconnect()},t.prototype.disposeWs=function(){this.ws&&(this.ws.removeEventListener("open",this.boundOnOpen),this.ws.removeEventListener("message",this.boundOnMessage),this.ws.removeEventListener("close",this.boundOnClose),this.ws.removeEventListener("error",this.boundOnError),this.ws=void 0)},t.prototype.onError=function(e){this.logger.warn("Transport error: "+e),this.emit("transportError")},t.prototype.onWebsocketError=function(){this.onError("The Websocket had an error")},t.prototype.reconnect=function(){var e=this;if(this.reconnectionAttempts>0&&this.logger.log("Reconnection attempt "+this.reconnectionAttempts+" failed"),this.noAvailableServers())return this.logger.warn("attempted to get next ws server but there are no available ws servers left"),this.logger.warn("no available ws servers left - going to closed state"),this.statusTransition(i.STATUS_CLOSED,!0),this.emit("closed"),void this.resetServerErrorStatus();this.isConnected()&&(this.logger.warn("attempted to reconnect while connected - forcing disconnect"),this.disconnect({force:!0})),this.reconnectionAttempts+=1,this.reconnectionAttempts>this.configuration.maxReconnectionAttempts?(this.logger.warn("maximum reconnection attempts for WebSocket "+this.server.wsUri),this.logger.log("transport "+this.server.wsUri+" failed | connection state set to 'error'"),this.server.isError=!0,this.emit("transportError"),this.noAvailableServers()||(this.server=this.getNextWsServer()),this.reconnectionAttempts=0,this.reconnect()):(this.logger.log("trying to reconnect to WebSocket "+this.server.wsUri+" (reconnection attempt "+this.reconnectionAttempts+")"),this.reconnectTimer=setTimeout(function(){e.connect(),e.reconnectTimer=void 0},1===this.reconnectionAttempts?0:1e3*this.configuration.reconnectionTimeout))},t.prototype.resetServerErrorStatus=function(){for(var e=0,t=this.configuration.wsServers;e<t.length;e++){t[e].isError=!1}},t.prototype.getNextWsServer=function(e){if(void 0===e&&(e=!1),this.noAvailableServers())throw this.logger.warn("attempted to get next ws server but there are no available ws servers left"),new Error("Attempted to get next ws server, but there are no available ws servers left.");for(var t=[],r=0,i=this.configuration.wsServers;r<i.length;r++){var n=i[r];n.isError&&!e||(0===t.length?t.push(n):n.weight>t[0].weight?t=[n]:n.weight===t[0].weight&&t.push(n))}return t[Math.floor(Math.random()*t.length)]},t.prototype.noAvailableServers=function(){for(var e=0,t=this.configuration.wsServers;e<t.length;e++){if(!t[e].isError)return!1}return!0},t.prototype.sendKeepAlive=function(){var e=this;if(!this.keepAliveDebounceTimeout)return this.keepAliveDebounceTimeout=setTimeout(function(){e.emit("keepAliveDebounceTimeout"),e.clearKeepAliveTimeout()},1e3*this.configuration.keepAliveDebounce),this.send("\r\n\r\n")},t.prototype.clearKeepAliveTimeout=function(){this.keepAliveDebounceTimeout&&clearTimeout(this.keepAliveDebounceTimeout),this.keepAliveDebounceTimeout=void 0},t.prototype.startSendingKeepAlives=function(){var e,t,r=this;this.configuration.keepAliveInterval&&!this.keepAliveInterval&&(this.keepAliveInterval=setInterval(function(){r.sendKeepAlive(),r.startSendingKeepAlives()},(e=this.configuration.keepAliveInterval,t=.8*e,1e3*(Math.random()*(e-t)+t))))},t.prototype.stopSendingKeepAlives=function(){this.keepAliveInterval&&clearInterval(this.keepAliveInterval),this.keepAliveDebounceTimeout&&clearTimeout(this.keepAliveDebounceTimeout),this.keepAliveInterval=void 0,this.keepAliveDebounceTimeout=void 0},t.prototype.statusAssert=function(e,t){return e===this.status||(t?(this.logger.warn("Attempted to assert "+Object.keys(i)[this.status]+" as "+Object.keys(i)[e]+"- continuing with option: 'force'"),!0):(this.logger.warn("Tried to assert "+Object.keys(i)[e]+" but is currently "+Object.keys(i)[this.status]),!1))},t.prototype.statusTransition=function(e,t){return void 0===t&&(t=!1),this.logger.log("Attempting to transition status from "+Object.keys(i)[this.status]+" to "+Object.keys(i)[e]),e===i.STATUS_CONNECTING&&this.statusAssert(i.STATUS_CLOSED,t)||e===i.STATUS_OPEN&&this.statusAssert(i.STATUS_CONNECTING,t)||e===i.STATUS_CLOSING&&this.statusAssert(i.STATUS_OPEN,t)||e===i.STATUS_CLOSED?(this.status=e,!0):(this.logger.warn("Status transition failed - result: no-op - reason: either gave an nonexistent status or attempted illegal transition"),!1)},t.prototype.loadConfig=function(e){var t={wsServers:[{scheme:"WSS",sipUri:"<sip:edge.sip.onsip.com;transport=ws;lr>",weight:0,wsUri:"wss://edge.sip.onsip.com",isError:!1}],connectionTimeout:5,maxReconnectionAttempts:3,reconnectionTimeout:4,keepAliveInterval:0,keepAliveDebounce:10,traceSip:!1},r=this.getConfigurationCheck();for(var i in r.mandatory){if(!e.hasOwnProperty(i))throw new a.Exceptions.ConfigurationError(i);var n=e[i];if(void 0===(s=r.mandatory[i](n)))throw new a.Exceptions.ConfigurationError(i,n);t[i]=s}for(var i in r.optional)if(e.hasOwnProperty(i)){var s;if((n=e[i])instanceof Array&&0===n.length||null===n||""===n||void 0===n||"number"==typeof n&&isNaN(n))continue;if(void 0===(s=r.optional[i](n)))throw new a.Exceptions.ConfigurationError(i,n);t[i]=s}var o={};for(var i in t)t.hasOwnProperty(i)&&(o[i]={value:t[i]});var c=Object.defineProperties({},o);for(var i in this.logger.log("configuration parameters after validation:"),t)t.hasOwnProperty(i)&&this.logger.log("\xb7 "+i+": "+JSON.stringify(t[i]));return c},t.prototype.getConfigurationCheck=function(){return{mandatory:{},optional:{wsServers:function(e){if("string"==typeof e)e=[{wsUri:e}];else{if(!(e instanceof Array))return;for(var t=0;t<e.length;t++)"string"==typeof e[t]&&(e[t]={wsUri:e[t]})}if(0===e.length)return!1;for(var r=0,i=e;r<i.length;r++){var n=i[r];if(!n.wsUri)return;if(n.weight&&!Number(n.weight))return;var o=s.Grammar.parse(n.wsUri,"absoluteURI");if(-1===o)return;if(["wss","ws","udp"].indexOf(o.scheme)<0)return;n.sipUri="<sip:"+o.host+(o.port?":"+o.port:"")+";transport="+o.scheme.replace(/^wss$/i,"ws")+";lr>",n.weight||(n.weight=0),n.isError=!1,n.scheme=o.scheme.toUpperCase()}return e},keepAliveInterval:function(e){if(c.Utils.isDecimal(e)){var t=Number(e);if(t>0)return t}},keepAliveDebounce:function(e){if(c.Utils.isDecimal(e)){var t=Number(e);if(t>0)return t}},traceSip:function(e){if("boolean"==typeof e)return e},connectionTimeout:function(e){if(c.Utils.isDecimal(e)){var t=Number(e);if(t>0)return t}},maxReconnectionAttempts:function(e){if(c.Utils.isDecimal(e)){var t=Number(e);if(t>=0)return t}},reconnectionTimeout:function(e){if(c.Utils.isDecimal(e)){var t=Number(e);if(t>0)return t}}}}},t.C=i,t}(s.Transport);t.Transport=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.Required="Required",e.Supported="Supported",e.Unsupported="Unsupported"}(t.SIPExtension||(t.SIPExtension={})),t.UserAgentRegisteredOptionTags={"100rel":!0,199:!0,answermode:!0,"early-session":!0,eventlist:!0,explicitsub:!0,"from-change":!0,"geolocation-http":!0,"geolocation-sip":!0,gin:!0,gruu:!0,histinfo:!0,ice:!0,join:!0,"multiple-refer":!0,norefersub:!0,nosub:!0,outbound:!0,path:!0,policy:!0,precondition:!0,pref:!0,privacy:!0,"recipient-list-invite":!0,"recipient-list-message":!0,"recipient-list-subscribe":!0,replaces:!0,"resource-priority":!0,"sdp-anat":!0,"sec-agree":!0,tdialog:!0,timer:!0,uui:!0}},,function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(8),n=function(){function e(e,t){this.type=i.TypeStrings.SessionDescriptionHandlerObserver,this.session=e,this.options=t}return e.prototype.trackAdded=function(){this.session.emit("trackAdded")},e.prototype.directionChanged=function(){this.session.emit("directionChanged")},e}();t.SessionDescriptionHandlerObserver=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(10),s=r(5),o=r(8),a=r(11),c=r(9),u=r(52),d=r(31),l=r(93),p=function(e){function t(t,r){var i=e.call(this,t)||this;if(i.incomingInviteRequest=r,i.body=void 0,i._canceled=!1,i.rseq=Math.floor(1e4*Math.random()),i.type=o.TypeStrings.InviteServerContext,i.logger=t.getLogger("sip.invitation",i.id),i.request.body&&(i.body=i.request.body),i.request.hasHeader("Content-Type")&&(i.contentType=i.request.getHeader("Content-Type")),i.localIdentity=i.request.to,i.remoteIdentity=i.request.from,i.request.hasHeader("P-Asserted-Identity")){var a=i.request.getHeader("P-Asserted-Identity");a&&(i.assertedIdentity=s.Grammar.nameAddrHeaderParse(a))}i.contact=i.userAgent.contact.toString(),i.fromTag=i.request.fromTag,i.id=i.request.callId+i.fromTag;var c=i.request.parseHeader("Content-Disposition");c&&"render"===c.type&&(i.renderbody=i.request.body,i.rendertype=i.request.getHeader("Content-Type")),i.logger=t.getLogger("sip.invitation",i.id),i.status=o.SessionStatus.STATUS_INVITE_RECEIVED,i.userAgent.sessions[i.id]=i;var u=i.request,l=function(e,t){u.hasHeader(e)&&u.getHeader(e).toLowerCase().indexOf("100rel")>=0&&(i.rel100=t)};if(l("require",n.C.supported.REQUIRED),l("supported",n.C.supported.SUPPORTED),i.request.toTag=r.toTag,i.status=o.SessionStatus.STATUS_WAITING_FOR_ANSWER,i.userNoAnswerTimer=setTimeout(function(){i.stateTransition(d.SessionState.Terminated),r.reject({statusCode:408}),i.failed(u,n.C.causes.NO_ANSWER),i.terminated(u,n.C.causes.NO_ANSWER)},i.userAgent.configuration.noAnswerTimeout?1e3*i.userAgent.configuration.noAnswerTimeout:6e4),u.hasHeader("expires")){var p=1e3*Number(u.getHeader("expires")||0);i.expiresTimer=setTimeout(function(){i.status===o.SessionStatus.STATUS_WAITING_FOR_ANSWER&&(i.stateTransition(d.SessionState.Terminated),r.reject({statusCode:487}),i.failed(u,n.C.causes.EXPIRES),i.terminated(u,n.C.causes.EXPIRES))},p)}return i}return i.__extends(t,e),Object.defineProperty(t.prototype,"autoSendAnInitialProvisionalResponse",{get:function(){return this.rel100!==n.C.supported.REQUIRED},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"request",{get:function(){return this.incomingInviteRequest.message},enumerable:!0,configurable:!0}),t.prototype.accept=function(e){var t=this;if(void 0===e&&(e={}),this.logger.log("Invitation.accept"),this.state!==d.SessionState.Initial){var r=new Error("Invalid session state "+this.state);return this.logger.error(r.message),Promise.reject(r)}return this.stateTransition(d.SessionState.Establishing),this._accept(e).then(function(e){var r=e.message,i=e.session;i.delegate={onAck:function(e){return t.onAckRequest(e)},onAckTimeout:function(){return t.onAckTimeout()},onBye:function(e){return t.onByeRequest(e)},onInfo:function(e){return t.onInfoRequest(e)},onInvite:function(e){return t.onInviteRequest(e)},onNotify:function(e){return t.onNotifyRequest(e)},onPrack:function(e){return t.onPrackRequest(e)},onRefer:function(e){return t.onReferRequest(e)}},t.dialog=i,t.stateTransition(d.SessionState.Established),t.accepted(r,c.Utils.getReasonPhrase(200))}).catch(function(e){if(t.onContextError(e),!t._canceled)throw e})},t.prototype.progress=function(e){var t=this;if(void 0===e&&(e={}),this.logger.log("Invitation.progress"),this.state!==d.SessionState.Initial){var r=new Error("Invalid session state "+this.state);return this.logger.error(r.message),Promise.reject(r)}var i=e.statusCode||180;if(i<100||i>199)throw new TypeError("Invalid statusCode: "+i);if(this.status===o.SessionStatus.STATUS_TERMINATED)return this.logger.warn("Unexpected call for progress while terminated, ignoring"),Promise.resolve();if(this.status===o.SessionStatus.STATUS_ANSWERED)return this.logger.warn("Unexpected call for progress while answered, ignoring"),Promise.resolve();if(this.status===o.SessionStatus.STATUS_ANSWERED_WAITING_FOR_PRACK)return this.logger.warn("Unexpected call for progress while answered (waiting for prack), ignoring"),Promise.resolve();if(this.status===o.SessionStatus.STATUS_WAITING_FOR_PRACK)return this.logger.warn("Unexpected call for progress while waiting for prack, ignoring"),Promise.resolve();if(100===e.statusCode){try{this.incomingInviteRequest.trying()}catch(r){if(this.onContextError(r),!this._canceled)return Promise.reject(r)}return Promise.resolve()}return this.rel100===n.C.supported.REQUIRED||this.rel100===n.C.supported.SUPPORTED&&e.rel100||this.rel100===n.C.supported.SUPPORTED&&this.userAgent.configuration.sipExtension100rel===l.SIPExtension.Required?this._progressReliableWaitForPrack(e).then(function(e){}).catch(function(e){if(t.onContextError(e),!t._canceled)throw e}):this._progress(e).then(function(e){}).catch(function(e){if(t.onContextError(e),!t._canceled)throw e})},t.prototype.reject=function(e){if(void 0===e&&(e={}),this.logger.log("Invitation.reject"),this.state!==d.SessionState.Initial){var t=new Error("Invalid session state "+this.state);return this.logger.error(t.message),Promise.reject(t)}if(this.stateTransition(d.SessionState.Terminated),this.status===o.SessionStatus.STATUS_TERMINATED)throw new a.Exceptions.InvalidStateError(this.status);this.logger.log("rejecting RTCSession");var r=e.statusCode||480,i=c.Utils.getReasonPhrase(r,e.reasonPhrase),n=e.extraHeaders||[];if(r<300||r>699)throw new TypeError("Invalid statusCode: "+r);var u=e.body?s.fromBodyLegacy(e.body):void 0,l=r<400?this.incomingInviteRequest.redirect([],{statusCode:r,reasonPhrase:i,extraHeaders:n,body:u}):this.incomingInviteRequest.reject({statusCode:r,reasonPhrase:i,extraHeaders:n,body:u});return this.emit("rejected",l.message,i),this.emit("failed",l.message,i),this.terminated(),Promise.resolve()},t.prototype.byePending=function(){this.emit("bye",this.request),e.prototype.byePending.call(this)},t.prototype.onCancel=function(e){this.logger.log("Invitation.onCancel"),this.state===d.SessionState.Initial||this.state===d.SessionState.Establishing?(this.stateTransition(d.SessionState.Terminated),this.incomingInviteRequest.reject({statusCode:487}),this.canceled(),this.rejected(e,n.C.causes.CANCELED),this.failed(e,n.C.causes.CANCELED),this.terminated(e,n.C.causes.CANCELED)):this.logger.error("CANCEL received while in state "+this.state+", dropping request")},t.prototype.canceled=function(){this._canceled=!0,e.prototype.canceled.call(this)},t.prototype.terminated=function(t,r){this.prackNeverArrived(),e.prototype.terminated.call(this,t,r)},t.prototype._accept=function(e){var t=this;return void 0===e&&(e={}),this.onInfo=e.onInfo,this.status===o.SessionStatus.STATUS_WAITING_FOR_PRACK?(this.status=o.SessionStatus.STATUS_ANSWERED_WAITING_FOR_PRACK,this.waitForArrivalOfPrack().then(function(){t.status=o.SessionStatus.STATUS_ANSWERED,clearTimeout(t.userNoAnswerTimer)}).then(function(){return t.generateResponseOfferAnswer(t.incomingInviteRequest,e)}).then(function(e){return t.incomingInviteRequest.accept({statusCode:200,body:e})})):this.status!==o.SessionStatus.STATUS_WAITING_FOR_ANSWER?Promise.reject(new a.Exceptions.InvalidStateError(this.status)):(this.status=o.SessionStatus.STATUS_ANSWERED,this.status=o.SessionStatus.STATUS_ANSWERED,clearTimeout(this.userNoAnswerTimer),this.generateResponseOfferAnswer(this.incomingInviteRequest,e).then(function(e){return t.incomingInviteRequest.accept({statusCode:200,body:e})}))},t.prototype._progress=function(e){void 0===e&&(e={});var t=e.statusCode||180,r=e.reasonPhrase,i=(e.extraHeaders||[]).slice(),n=e.body?s.fromBodyLegacy(e.body):void 0;if(183===t&&!n)return this._progressWithSDP(e);try{var o=this.incomingInviteRequest.progress({statusCode:t,reasonPhrase:r,extraHeaders:i,body:n});return this.emit("progress",o.message,r),this.dialog=o.session,Promise.resolve(o)}catch(e){return Promise.reject(e)}},t.prototype._progressWithSDP=function(e){var t=this;void 0===e&&(e={});var r=e.statusCode||183,i=e.reasonPhrase,n=(e.extraHeaders||[]).slice();return this.generateResponseOfferAnswer(this.incomingInviteRequest,e).then(function(e){return t.incomingInviteRequest.progress({statusCode:r,reasonPhrase:i,extraHeaders:n,body:e})}).then(function(e){return t.emit("progress",e.message,i),t.dialog=e.session,e})},t.prototype._progressReliable=function(e){return void 0===e&&(e={}),e.extraHeaders=(e.extraHeaders||[]).slice(),e.extraHeaders.push("Require: 100rel"),e.extraHeaders.push("RSeq: "+Math.floor(1e4*Math.random())),this._progressWithSDP(e)},t.prototype._progressReliableWaitForPrack=function(e){var t=this;void 0===e&&(e={});var r,i=e.statusCode||183,c=e.reasonPhrase,u=(e.extraHeaders||[]).slice();return u.push("Require: 100rel"),u.push("RSeq: "+this.rseq++),this.status=o.SessionStatus.STATUS_WAITING_FOR_PRACK,new Promise(function(d,l){var p=!0;return t.generateResponseOfferAnswer(t.incomingInviteRequest,e).then(function(e){return r=e,t.incomingInviteRequest.progress({statusCode:i,reasonPhrase:c,extraHeaders:u,body:r})}).then(function(h){var g,f;t.emit("progress",h.message,c),t.dialog=h.session,h.session.delegate={onPrack:function(r){g=r,clearTimeout(v),clearTimeout(y),p&&(p=!1,t.handlePrackOfferAnswer(g,e).then(function(e){try{f=g.accept({statusCode:200,body:e}),t.status===o.SessionStatus.STATUS_WAITING_FOR_PRACK&&(t.status=o.SessionStatus.STATUS_WAITING_FOR_ANSWER),t.prackArrived(),d({prackRequest:g,prackResponse:f,progressResponse:h})}catch(e){l(e)}}))}};var v=setTimeout(function(){if(p){p=!1,t.logger.warn("No PRACK received, rejecting INVITE."),clearTimeout(y);try{t.incomingInviteRequest.reject({statusCode:504}),t.terminated(void 0,n.C.causes.NO_PRACK),l(new a.Exceptions.TerminatedSessionError)}catch(e){l(e)}}},64*s.Timers.T1),m=function(){try{t.incomingInviteRequest.progress({statusCode:i,reasonPhrase:c,extraHeaders:u,body:r})}catch(e){return p=!1,void l(e)}y=setTimeout(m,S*=2)},S=s.Timers.T1,y=setTimeout(m,S)})})},t.prototype.handlePrackOfferAnswer=function(e,t){if(!this.dialog)throw new Error("Dialog undefined.");var r=s.getBody(e.message);if(!r||"session"!==r.contentDisposition)return Promise.resolve(void 0);switch(this.dialog.signalingState){case s.SignalingState.Initial:throw new Error("Invalid signaling state "+this.dialog.signalingState+".");case s.SignalingState.Stable:return this.setAnswer(r,t).then(function(){});case s.SignalingState.HaveLocalOffer:throw new Error("Invalid signaling state "+this.dialog.signalingState+".");case s.SignalingState.HaveRemoteOffer:return this.setOfferAndGetAnswer(r,t);case s.SignalingState.Closed:default:throw new Error("Invalid signaling state "+this.dialog.signalingState+".")}},t.prototype.onAckTimeout=function(){if(this.logger.log("Invitation.onAckTimeout"),!this.dialog)throw new Error("Dialog undefined.");this.logger.log("No ACK received for an extended period of time, terminating session"),this.dialog.bye(),this.terminated(void 0,n.C.causes.NO_ACK)},t.prototype.onContextError=function(e){var t=480;e instanceof s.Exception?e instanceof a.Exceptions.SessionDescriptionHandlerError?(this.logger.error(e.message),e.error&&this.logger.error(e.error)):e instanceof a.Exceptions.TerminatedSessionError?this.logger.warn("Incoming session terminated while waiting for PRACK."):e instanceof a.Exceptions.UnsupportedSessionDescriptionContentTypeError?t=415:e instanceof s.Exception&&this.logger.error(e.message):e instanceof Error?this.logger.error(e.message):(this.logger.error("An error occurred in the session description handler."),this.logger.error(e));try{this.incomingInviteRequest.reject({statusCode:t}),this.failed(this.incomingInviteRequest.message,e.message),this.terminated(this.incomingInviteRequest.message,e.message)}catch(e){return}},t.prototype.prackArrived=function(){this.waitingForPrackResolve&&this.waitingForPrackResolve(),this.waitingForPrackPromise=void 0,this.waitingForPrackResolve=void 0,this.waitingForPrackReject=void 0},t.prototype.prackNeverArrived=function(){this.waitingForPrackReject&&this.waitingForPrackReject(new a.Exceptions.TerminatedSessionError),this.waitingForPrackPromise=void 0,this.waitingForPrackResolve=void 0,this.waitingForPrackReject=void 0},t.prototype.waitForArrivalOfPrack=function(){var e=this;if(this.waitingForPrackPromise)throw new Error("Already waiting for PRACK");return this.waitingForPrackPromise=new Promise(function(t,r){e.waitingForPrackResolve=t,e.waitingForPrackReject=r}),this.waitingForPrackPromise},t}(u.Session);t.Invitation=p},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.Initial="Initial",e.NotifyWait="NotifyWait",e.Subscribed="Subscribed",e.Terminated="Terminated"}(t.SubscriptionState||(t.SubscriptionState={}))},,,,,,function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(10),s=r(5),o=r(8),a=r(11),c=r(9),u=r(52),d=r(31),l=r(93),p=function(e){function t(t,r,i){void 0===i&&(i={});var n=e.call(this,t,i)||this;if(n.body=void 0,n.earlyMediaSessionDescriptionHandlers=new Map,i.params=i.params||{},n.status!==o.SessionStatus.STATUS_NULL)throw new a.Exceptions.InvalidStateError(n.status);n.type=o.TypeStrings.InviteClientContext,n.logger=t.getLogger("sip.inviter"),i.body&&(n.body={body:i.body,contentType:i.contentType?i.contentType:"application/sdp"});var u=i.anonymous||!1;u&&t.configuration.uri&&(i.params.fromDisplayName="Anonymous",i.params.fromUri="sip:[email protected]");var d=c.Utils.newTag(),p=t.contact.toString({anonymous:u,outbound:u?!t.contact.tempGruu:!t.contact.pubGruu}),h=i.params||{};h.fromTag=d;var g=t.userAgentCore.configuration.aor;if(i.params.fromUri&&(g="string"==typeof i.params.fromUri?s.Grammar.URIParse(i.params.fromUri):i.params.fromUri),!g)throw new TypeError("Invalid from URI: "+i.params.fromUri);var f=r;if(i.params.toUri&&(f="string"==typeof i.params.toUri?s.Grammar.URIParse(i.params.toUri):i.params.toUri),!f)throw new TypeError("Invalid to URI: "+i.params.toUri);var v,m=(i.extraHeaders||[]).slice();if(u&&t.configuration.uri&&(m.push("P-Preferred-Identity: "+t.configuration.uri.toString()),m.push("Privacy: id")),m.push("Contact: "+p),m.push("Allow: "+["ACK","CANCEL","INVITE","MESSAGE","BYE","OPTIONS","INFO","NOTIFY","REFER"].toString()),t.configuration.sipExtension100rel===l.SIPExtension.Required&&m.push("Require: 100rel"),t.configuration.sipExtensionReplaces===l.SIPExtension.Required&&m.push("Require: replaces"),n.body&&(v=c.Utils.fromBodyObj(n.body)),n.request=t.userAgentCore.makeOutgoingRequestMessage(n.method,r,g,f,h,m,v),!n.request.from)throw new Error("From undefined.");if(!n.request.to)throw new Error("From undefined.");return n.localIdentity=n.request.from,n.remoteIdentity=n.request.to,i.params=h,i.extraHeaders=m,n.contact=p,n.fromTag=d,n.id=n.request.callId+n.fromTag,n.onInfo=i.onInfo,n.passedOptions=i,n.renderbody=i.renderbody||void 0,n.rendertype=i.rendertype||"text/plain",n.sessionDescriptionHandlerModifiers=i.SessionDescriptionHandlerModifiers||[],n.sessionDescriptionHandlerOptions=i.sessionDescriptionHandlerOptions||{},n.inviteWithoutSdp=i.inviteWithoutSdp||!1,n.isCanceled=!1,n.earlyMedia=i.earlyMedia||!1,t.applicants[n.toString()]=n,n}return i.__extends(t,e),t.prototype.cancel=function(e){if(void 0===e&&(e={}),this.logger.log("Inviter.cancel"),this.state!==d.SessionState.Initial&&this.state!==d.SessionState.Establishing){var t=new Error("Invalid session state "+this.state);return this.logger.error(t.message),Promise.reject(t)}if(this.stateTransition(d.SessionState.Terminating),this.status===o.SessionStatus.STATUS_TERMINATED||this.status===o.SessionStatus.STATUS_CONFIRMED)throw new a.Exceptions.InvalidStateError(this.status);if(this.isCanceled)throw new a.Exceptions.InvalidStateError(o.SessionStatus.STATUS_CANCELED);var r;return this.isCanceled=!0,this.logger.log("Canceling session"),e.statusCode&&e.reasonPhrase&&(r=c.Utils.getCancelReason(e.statusCode,e.reasonPhrase)),e.extraHeaders=(e.extraHeaders||[]).slice(),this.outgoingInviteRequest&&(this.logger.warn("Canceling session before it was created"),this.outgoingInviteRequest.cancel(r,e)),this.canceled(),Promise.resolve()},t.prototype.invite=function(t){var r=this;if(void 0===t&&(t={}),this.logger.log("Inviter.invite"),this.state!==d.SessionState.Initial)return e.prototype.invite.call(this,t);if(!this.id)throw new Error("Session id undefined.");if(this.userAgent.sessions[this.id]=this,this.inviteWithoutSdp)return this.renderbody&&this.rendertype&&(this.request.body={contentType:this.rendertype,body:this.renderbody}),this.stateTransition(d.SessionState.Establishing),this.status=o.SessionStatus.STATUS_INVITE_SENT,Promise.resolve(this.sendInvite(t));var i={sessionDescriptionHandlerOptions:this.sessionDescriptionHandlerOptions,sessionDescriptionHandlerModifiers:this.sessionDescriptionHandlerModifiers};return this.getOffer(i).then(function(e){if(r.isCanceled||r.status===o.SessionStatus.STATUS_TERMINATED)throw new Error("Session was canceled or terminated before INVITE was sent.");return r.stateTransition(d.SessionState.Establishing),r.status=o.SessionStatus.STATUS_INVITE_SENT,r.request.body={body:e.content,contentType:e.contentType},r.sendInvite(t)}).catch(function(e){throw r.logger.log(e.message),r.failed(void 0,n.C.causes.WEBRTC_ERROR),r.terminated(void 0,n.C.causes.WEBRTC_ERROR),e})},t.prototype.sendInvite=function(e){var t=this;return void 0===e&&(e={}),this.outgoingInviteRequest=this.userAgent.userAgentCore.invite(this.request,{onAccept:function(r){if(t.dialog)t.ackAndBye(r);else{if(t.isCanceled)return t.ackAndBye(r),void t.emit("bye",t.request);t.notifyReferer(r),t.onAccept(r).then(function(){t.disposeEarlyMedia()}).catch(function(e){t.disposeEarlyMedia()}).then(function(){e.requestDelegate&&e.requestDelegate.onAccept&&e.requestDelegate.onAccept(r)})}},onProgress:function(r){t.isCanceled||(t.notifyReferer(r),t.onProgress(r).catch(function(e){t.disposeEarlyMedia()}).then(function(){e.requestDelegate&&e.requestDelegate.onProgress&&e.requestDelegate.onProgress(r)}))},onRedirect:function(r){t.notifyReferer(r),t.onRedirect(r),e.requestDelegate&&e.requestDelegate.onRedirect&&e.requestDelegate.onRedirect(r)},onReject:function(r){t.notifyReferer(r),t.onReject(r),e.requestDelegate&&e.requestDelegate.onReject&&e.requestDelegate.onReject(r)},onTrying:function(r){t.notifyReferer(r),t.onTrying(r),e.requestDelegate&&e.requestDelegate.onTrying&&e.requestDelegate.onTrying(r)}}),this.outgoingInviteRequest},t.prototype.ackAndBye=function(e,t,r){var i=[];t&&i.push("Reason: "+c.Utils.getReasonHeaderValue(t,r));var n=e.ack(),s=e.session.bye(void 0,{extraHeaders:i});this.emit("ack",n.message),this.emit("bye",s.message)},t.prototype.disposeEarlyMedia=function(){this.earlyMediaSessionDescriptionHandlers.forEach(function(e){e.close()})},t.prototype.notifyReferer=function(e){var t=this;if(this.referred){if(!(this.referred instanceof u.Session))throw new Error("Referred session not instance of session");if(this.referred.dialog){if(!e.message.statusCode)throw new Error("Status code undefined.");if(!e.message.reasonPhrase)throw new Error("Reason phrase undefined.");var r=("SIP/2.0 "+e.message.statusCode+" "+e.message.reasonPhrase).trim();this.referred.dialog.notify(void 0,{extraHeaders:["Event: refer","Subscription-State: terminated"],body:{contentDisposition:"render",contentType:"message/sipfrag",content:r}}).delegate={onReject:function(){t.referred=void 0}}}}},t.prototype.onAccept=function(e){var t=this;if(this.logger.log("Inviter.onAccept"),this.state!==d.SessionState.Establishing)return this.logger.error("Accept received while in state "+this.state+", dropping response"),Promise.reject(new Error("Invalid session state "+this.state));var r=e.message,i=e.session;r.hasHeader("P-Asserted-Identity")&&(this.assertedIdentity=s.Grammar.nameAddrHeaderParse(r.getHeader("P-Asserted-Identity"))),this.dialog=i,this.dialog.delegate={onAck:function(e){return t.onAckRequest(e)},onBye:function(e){return t.onByeRequest(e)},onInfo:function(e){return t.onInfoRequest(e)},onInvite:function(e){return t.onInviteRequest(e)},onNotify:function(e){return t.onNotifyRequest(e)},onPrack:function(e){return t.onPrackRequest(e)},onRefer:function(e){return t.onReferRequest(e)}};var a=this.sessionDescriptionHandlerOptions,c=this.sessionDescriptionHandlerModifiers;switch(i.signalingState){case s.SignalingState.Initial:case s.SignalingState.HaveLocalOffer:return this.ackAndBye(e,400,"Missing session description"),this.failed(r,n.C.causes.BAD_MEDIA_DESCRIPTION),Promise.reject(new Error(n.C.causes.BAD_MEDIA_DESCRIPTION));case s.SignalingState.HaveRemoteOffer:if(!this.dialog.offer)throw new Error("Session offer undefined in signaling state "+this.dialog.signalingState+".");var u={sessionDescriptionHandlerOptions:a,sessionDescriptionHandlerModifiers:c};return this.setOfferAndGetAnswer(this.dialog.offer,u).then(function(i){t.status=o.SessionStatus.STATUS_CONFIRMED;var n=e.ack({body:i});t.stateTransition(d.SessionState.Established),t.emit("ack",n.message),t.accepted(r)}).catch(function(i){throw t.ackAndBye(e,488,"Invalid session description"),t.failed(r,n.C.causes.BAD_MEDIA_DESCRIPTION),i});case s.SignalingState.Stable:if(this.earlyMediaSessionDescriptionHandlers.size>0){var l=this.earlyMediaSessionDescriptionHandlers.get(i.id);if(!l)throw new Error("Session description handler undefined.");this.setSessionDescriptionHandler(l),this.earlyMediaSessionDescriptionHandlers.delete(i.id),this.status=o.SessionStatus.STATUS_CONFIRMED;var p=e.ack();return this.stateTransition(d.SessionState.Established),this.emit("ack",p.message),this.accepted(r),Promise.resolve()}if(this.earlyMediaDialog){if(this.earlyMediaDialog!==i){if(this.earlyMedia){this.logger.error("You have set the 'earlyMedia' option to 'true' which requires that your INVITE requests do not fork and yet this INVITE request did in fact fork. Consequentially and not surprisingly the end point which accepted the INVITE (confirmed dialog) does not match the end point with which early media has been setup (early dialog) and thus this session is unable to proceed. In accordance with the SIP specifications, the SIP servers your end point is connected to determine if an INVITE forks and the forking behaviour of those servers cannot be controlled by this library. If you wish to use early media with this library you must configure those servers accordingly. Alternatively you may set the 'earlyMedia' to 'false' which will allow this library to function with any INVITE requests which do fork.")}var h=new Error("Early media dialog does not equal confirmed dialog, terminating session");return this.logger.error(h.message),this.ackAndBye(e,488,"Not Acceptable Here"),this.failed(r,n.C.causes.BAD_MEDIA_DESCRIPTION),Promise.reject(h)}this.status=o.SessionStatus.STATUS_CONFIRMED;p=e.ack();return this.stateTransition(d.SessionState.Established),this.emit("ack",p.message),this.accepted(r),Promise.resolve()}var g=i.answer;if(!g)throw new Error("Answer is undefined.");u={sessionDescriptionHandlerOptions:a,sessionDescriptionHandlerModifiers:c};return this.setAnswer(g,u).then(function(){var i;t.renderbody&&t.rendertype&&(i={body:{contentDisposition:"render",contentType:t.rendertype,content:t.renderbody}}),t.status=o.SessionStatus.STATUS_CONFIRMED;var n=e.ack(i);t.stateTransition(d.SessionState.Established),t.emit("ack",n.message),t.accepted(r)}).catch(function(i){throw t.logger.error(i.message),t.ackAndBye(e,488,"Not Acceptable Here"),t.failed(r,n.C.causes.BAD_MEDIA_DESCRIPTION),i});case s.SignalingState.Closed:return Promise.reject(new Error("Terminated."));default:throw new Error("Unknown session signaling state.")}},t.prototype.onProgress=function(e){var t=this;if(this.logger.log("Inviter.onProgress"),this.state!==d.SessionState.Establishing)return this.logger.error("Progress received while in state "+this.state+", dropping response"),Promise.reject(new Error("Invalid session state "+this.state));if(!this.outgoingInviteRequest)throw new Error("Outgoing INVITE request undefined.");var r=e.message,i=e.session;this.status=o.SessionStatus.STATUS_1XX_RECEIVED,r.hasHeader("P-Asserted-Identity")&&(this.assertedIdentity=s.Grammar.nameAddrHeaderParse(r.getHeader("P-Asserted-Identity")));var a=r.getHeader("require"),c=r.getHeader("rseq"),u=!!(a&&a.includes("100rel")&&c?Number(c):void 0),l=[];u&&l.push("RAck: "+r.getHeader("rseq")+" "+r.getHeader("cseq"));var p=this.sessionDescriptionHandlerOptions,h=this.sessionDescriptionHandlerModifiers;switch(i.signalingState){case s.SignalingState.Initial:return u&&(this.logger.warn("First reliable provisional response received MUST contain an offer when INVITE does not contain an offer."),e.prack({extraHeaders:l})),this.emit("progress",r),Promise.resolve();case s.SignalingState.HaveLocalOffer:return u&&e.prack({extraHeaders:l}),this.emit("progress",r),Promise.resolve();case s.SignalingState.HaveRemoteOffer:if(!u)return this.logger.warn("Non-reliable provisional response MUST NOT contain an initial offer, discarding response."),Promise.resolve();var g=this.sessionDescriptionHandlerFactory(this,this.userAgent.configuration.sessionDescriptionHandlerFactoryOptions||{});return this.emit("SessionDescriptionHandler-created",g),this.earlyMediaSessionDescriptionHandlers.set(i.id,g),g.setDescription(r.body,p,h).then(function(){return g.getDescription(p,h)}).then(function(i){var n={contentDisposition:"session",contentType:i.contentType,content:i.body};e.prack({extraHeaders:l,body:n}),t.emit("progress",r)}).catch(function(e){if(t.status===o.SessionStatus.STATUS_TERMINATED)throw e;throw t.failed(void 0,n.C.causes.WEBRTC_ERROR),t.terminated(void 0,n.C.causes.WEBRTC_ERROR),e});case s.SignalingState.Stable:if(u&&e.prack({extraHeaders:l}),this.earlyMedia&&!this.earlyMediaDialog){this.earlyMediaDialog=i;var f=i.answer;if(!f)throw new Error("Answer is undefined.");var v={sessionDescriptionHandlerOptions:p,sessionDescriptionHandlerModifiers:h};return this.setAnswer(f,v).then(function(){t.emit("progress",r)}).catch(function(e){if(t.status===o.SessionStatus.STATUS_TERMINATED)throw e;throw t.failed(void 0,n.C.causes.WEBRTC_ERROR),t.terminated(void 0,n.C.causes.WEBRTC_ERROR),e})}return this.emit("progress",r),Promise.resolve();case s.SignalingState.Closed:return Promise.reject(new Error("Terminated."));default:throw new Error("Unknown session signaling state.")}},t.prototype.onRedirect=function(e){if(this.logger.log("Inviter.onRedirect"),this.state===d.SessionState.Establishing||this.state===d.SessionState.Terminating){this.stateTransition(d.SessionState.Terminated),this.disposeEarlyMedia();var t=e.message,r=t.statusCode,i=c.Utils.sipErrorCause(r||0);this.rejected(t,i),this.failed(t,i),this.terminated(t,i)}else this.logger.error("Redirect received while in state "+this.state+", dropping response")},t.prototype.onReject=function(e){if(this.logger.log("Inviter.onReject"),this.state===d.SessionState.Establishing||this.state===d.SessionState.Terminating){this.stateTransition(d.SessionState.Terminated),this.disposeEarlyMedia();var t=e.message,r=t.statusCode,i=c.Utils.sipErrorCause(r||0);this.rejected(t,i),this.failed(t,i),this.terminated(t,i)}else this.logger.error("Reject received while in state "+this.state+", dropping response")},t.prototype.onTrying=function(e){this.logger.log("Inviter.onTrying"),this.emit("progress",e.message),this.state===d.SessionState.Establishing||this.logger.error("Trying received while in state "+this.state+", dropping response")},t}(u.Session);t.Inviter=p},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e){this.incomingMessageRequest=e}return Object.defineProperty(e.prototype,"request",{get:function(){return this.incomingMessageRequest.message},enumerable:!0,configurable:!0}),e.prototype.accept=function(e){return this.incomingMessageRequest.accept(e),Promise.resolve()},e.prototype.reject=function(e){return this.incomingMessageRequest.reject(e),Promise.resolve()},e}();t.Message=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.Initial="Initial",e.Registered="Registered",e.Unregistered="Unregistered"}(t.RegistererState||(t.RegistererState={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(7),s=r(53),o=r(97),a=function(e){function t(t,r){void 0===r&&(r={});var i=e.call(this)||this;return i._disposed=!1,i._state=o.SubscriptionState.Initial,i._stateEventEmitter=new n.EventEmitter,i._logger=t.getLogger("sip.subscription"),i.userAgent=t,i.delegate=r.delegate,i}return i.__extends(t,e),t.prototype.dispose=function(){this._disposed||(this._disposed=!0,this.stateTransition(o.SubscriptionState.Terminated),this._stateEventEmitter.removeAllListeners())},Object.defineProperty(t.prototype,"disposed",{get:function(){return this._disposed},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stateChange",{get:function(){return s.makeEmitter(this._stateEventEmitter)},enumerable:!0,configurable:!0}),t.prototype.stateTransition=function(e){var t=this,r=function(){throw new Error("Invalid state transition from "+t._state+" to "+e)};switch(this._state){case o.SubscriptionState.Initial:e!==o.SubscriptionState.NotifyWait&&e!==o.SubscriptionState.Terminated&&r();break;case o.SubscriptionState.NotifyWait:e!==o.SubscriptionState.Subscribed&&e!==o.SubscriptionState.Terminated&&r();break;case o.SubscriptionState.Subscribed:e!==o.SubscriptionState.Terminated&&r();break;case o.SubscriptionState.Terminated:r();break;default:throw new Error("Unrecognized state.")}this._state!==e&&(this._state=e,this._logger.log("Subscription "+(this.dialog?this.dialog.id:void 0)+" transitioned to "+this._state),this._stateEventEmitter.emit("event",this._state))},t}(n.EventEmitter);t.Subscription=a},,,,,function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0);i.__exportStar(r(112),t),i.__exportStar(r(53),t),i.__exportStar(r(90),t),i.__exportStar(r(113),t),i.__exportStar(r(96),t),i.__exportStar(r(103),t),i.__exportStar(r(104),t),i.__exportStar(r(114),t),i.__exportStar(r(54),t),i.__exportStar(r(115),t),i.__exportStar(r(91),t),i.__exportStar(r(116),t),i.__exportStar(r(105),t),i.__exportStar(r(117),t),i.__exportStar(r(31),t),i.__exportStar(r(52),t),i.__exportStar(r(118),t),i.__exportStar(r(97),t),i.__exportStar(r(106),t),i.__exportStar(r(93),t),i.__exportStar(r(119),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(96),n=r(31),s=function(){function e(e,t){this._session=e}return Object.defineProperty(e.prototype,"session",{get:function(){return this._session},enumerable:!0,configurable:!0}),e.prototype.bye=function(e){if(void 0===e&&(e={}),this.session.state!==n.SessionState.Established&&this.session.state!==n.SessionState.Terminating){var t="Byer.bye() may only be called if established session.";return this.session.state===n.SessionState.Terminated?t+=" However this session is already terminated.":this.session instanceof i.Invitation?(t+=" However Invitation.accept() has not yet been called.",t+=" Perhaps you should have called Invitation.reject()?"):(t+=" However a dialog does not yet exist.",t+=" Perhaps you should have called Inviter.cancel()?"),this.session.logger.error(t),Promise.reject(new Error("Invalid session state "+this.session.state))}return this.session.bye(e.requestDelegate,e.requestOptions)},e}();t.Byer=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(31),n=function(){function e(e,t){this._session=e}return Object.defineProperty(e.prototype,"session",{get:function(){return this._session},enumerable:!0,configurable:!0}),e.prototype.info=function(e){if(void 0===e&&(e={}),this.session.state!==i.SessionState.Established){return this.session.logger.error("Infoer.info() may only be called if established session."),Promise.reject(new Error("Invalid session state "+this.session.state))}return this.session.info(e.requestDelegate,e.requestOptions)},e}();t.Infoer=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(7),s=r(5),o=function(e){function t(t,r,n,o,a){void 0===o&&(o="text/plain"),void 0===a&&(a={});var c=e.call(this)||this;c._disposed=!1,c.logger=t.getLogger("sip.messager"),a.params=a.params||{};var u=t.userAgentCore.configuration.aor;if(a.params.fromUri&&(u="string"==typeof a.params.fromUri?s.Grammar.URIParse(a.params.fromUri):a.params.fromUri),!u)throw new TypeError("Invalid from URI: "+a.params.fromUri);var d=r;if(a.params.toUri&&(d="string"==typeof a.params.toUri?s.Grammar.URIParse(a.params.toUri):a.params.toUri),!d)throw new TypeError("Invalid to URI: "+a.params.toUri);var l=a.params?i.__assign({},a.params):{},p=(a.extraHeaders||[]).slice(),h={contentDisposition:"render",contentType:o,content:n};return c.request=t.userAgentCore.makeOutgoingRequestMessage(s.C.MESSAGE,r,u,d,l,p,h),c.userAgent=t,c}return i.__extends(t,e),t.prototype.dispose=function(){this._disposed||(this._disposed=!0)},t.prototype.message=function(e){return void 0===e&&(e={}),this.userAgent.userAgentCore.request(this.request,e.requestDelegate),Promise.resolve()},t}(n.EventEmitter);t.Messager=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(7),s=r(10),o=r(11),a=r(9),c=function(e){function t(t,r,i,n){void 0===n&&(n={});var o=e.call(this)||this;n.extraHeaders=(n.extraHeaders||[]).slice(),n.contentType=n.contentType||"text/plain","number"!=typeof n.expires||n.expires%1!=0?n.expires=3600:n.expires=Number(n.expires),"boolean"!=typeof n.unpublishOnClose&&(n.unpublishOnClose=!0),o.target=r,o.event=i,o.options=n,o.pubRequestExpires=o.options.expires,o.logger=t.getLogger("sip.publisher");var a,c=n.params||{},u=c.fromUri?c.fromUri:t.userAgentCore.configuration.aor,d=c.toUri?c.toUri:r;if(n.body&&n.contentType){a={contentDisposition:"render",contentType:n.contentType,content:n.body}}var l=(n.extraHeaders||[]).slice();return o.request=t.userAgentCore.makeOutgoingRequestMessage(s.C.PUBLISH,r,u,d,c,l,a),o.userAgent=t,o}return i.__extends(t,e),t.prototype.close=function(){this.options.unpublishOnClose?this.unpublish():(this.publishRefreshTimer&&(clearTimeout(this.publishRefreshTimer),this.publishRefreshTimer=void 0),this.pubRequestBody=void 0,this.pubRequestExpires=0,this.pubRequestEtag=void 0),this.userAgent.publishers[this.target.toString()+":"+this.event]&&delete this.userAgent.publishers[this.target.toString()+":"+this.event]},t.prototype.publish=function(e,t){void 0===t&&(t={}),this.publishRefreshTimer&&(clearTimeout(this.publishRefreshTimer),this.publishRefreshTimer=void 0),this.options.body=e,this.pubRequestBody=this.options.body,0===this.pubRequestExpires&&(this.pubRequestExpires=this.options.expires,this.pubRequestEtag=void 0),this.userAgent.publishers[this.target.toString()+":"+this.event]||(this.userAgent.publishers[this.target.toString()+":"+this.event]=this),this.sendPublishRequest()},t.prototype.unpublish=function(e){void 0===e&&(e={}),this.publishRefreshTimer&&(clearTimeout(this.publishRefreshTimer),this.publishRefreshTimer=void 0),this.pubRequestBody=void 0,this.pubRequestExpires=0,void 0!==this.pubRequestEtag&&this.sendPublishRequest()},t.prototype.receiveResponse=function(e){var t=this,r=e.statusCode||0,i=a.Utils.getReasonPhrase(r);switch(!0){case/^1[0-9]{2}$/.test(r.toString()):this.emit("progress",e,i);break;case/^2[0-9]{2}$/.test(r.toString()):if(e.hasHeader("SIP-ETag")?this.pubRequestEtag=e.getHeader("SIP-ETag"):this.logger.warn("SIP-ETag header missing in a 200-class response to PUBLISH"),e.hasHeader("Expires")){var n=Number(e.getHeader("Expires"));"number"==typeof n&&n>=0&&n<=this.pubRequestExpires?this.pubRequestExpires=n:this.logger.warn("Bad Expires header in a 200-class response to PUBLISH")}else this.logger.warn("Expires header missing in a 200-class response to PUBLISH");0!==this.pubRequestExpires?(this.publishRefreshTimer=setTimeout(function(){return t.refreshRequest()},900*this.pubRequestExpires),this.emit("published",e,i)):this.emit("unpublished",e,i);break;case/^412$/.test(r.toString()):void 0!==this.pubRequestEtag&&0!==this.pubRequestExpires?(this.logger.warn("412 response to PUBLISH, recovering"),this.pubRequestEtag=void 0,this.emit("progress",e,i),this.publish(this.options.body)):(this.logger.warn("412 response to PUBLISH, recovery failed"),this.pubRequestExpires=0,this.emit("failed",e,i),this.emit("unpublished",e,i));break;case/^423$/.test(r.toString()):if(0!==this.pubRequestExpires&&e.hasHeader("Min-Expires")){var s=Number(e.getHeader("Min-Expires"));"number"==typeof s||s>this.pubRequestExpires?(this.logger.warn("423 code in response to PUBLISH, adjusting the Expires value and trying to recover"),this.pubRequestExpires=s,this.emit("progress",e,i),this.publish(this.options.body)):(this.logger.warn("Bad 423 response Min-Expires header received for PUBLISH"),this.pubRequestExpires=0,this.emit("failed",e,i),this.emit("unpublished",e,i))}else this.logger.warn("423 response to PUBLISH, recovery failed"),this.pubRequestExpires=0,this.emit("failed",e,i),this.emit("unpublished",e,i);break;default:this.pubRequestExpires=0,this.emit("failed",e,i),this.emit("unpublished",e,i)}0===this.pubRequestExpires&&(this.publishRefreshTimer&&(clearTimeout(this.publishRefreshTimer),this.publishRefreshTimer=void 0),this.pubRequestBody=void 0,this.pubRequestEtag=void 0)},t.prototype.send=function(){var e=this;return this.userAgent.userAgentCore.publish(this.request,{onAccept:function(t){return e.receiveResponse(t.message)},onProgress:function(t){return e.receiveResponse(t.message)},onRedirect:function(t){return e.receiveResponse(t.message)},onReject:function(t){return e.receiveResponse(t.message)},onTrying:function(t){return e.receiveResponse(t.message)}}),this},t.prototype.refreshRequest=function(){if(this.publishRefreshTimer&&(clearTimeout(this.publishRefreshTimer),this.publishRefreshTimer=void 0),this.pubRequestBody=void 0,void 0===this.pubRequestEtag)throw new o.Exceptions.MethodParameterError("Publish","Body",void 0);if(0===this.pubRequestExpires)throw new o.Exceptions.MethodParameterError("Publish","Expire",this.pubRequestExpires);this.sendPublishRequest()},t.prototype.sendPublishRequest=function(){var e=Object.create(this.options||Object.prototype);e.extraHeaders=(this.options.extraHeaders||[]).slice(),e.extraHeaders.push("Event: "+this.event),e.extraHeaders.push("Expires: "+this.pubRequestExpires),void 0!==this.pubRequestEtag&&e.extraHeaders.push("SIP-If-Match: "+this.pubRequestEtag);var t,r,i=this.target,n=this.options.params||{};void 0!==this.pubRequestBody&&(t={body:this.pubRequestBody,contentType:this.options.contentType}),t&&(r=a.Utils.fromBodyObj(t)),this.request=this.userAgent.userAgentCore.makeOutgoingRequestMessage(s.C.PUBLISH,i,n.fromUri?n.fromUri:this.userAgent.userAgentCore.configuration.aor,n.toUri?n.toUri:this.target,n,e.extraHeaders,r),this.send()},t}(n.EventEmitter);t.Publisher=c},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(5),n=r(31),s=function(){function e(e,t,r){this._session=e,this._referTo=t}return Object.defineProperty(e.prototype,"session",{get:function(){return this._session},enumerable:!0,configurable:!0}),e.prototype.refer=function(e){if(void 0===e&&(e={}),this.session.state!==n.SessionState.Established){return this.session.logger.error("Referrer.refer() may only be called if established session."),Promise.reject(new Error("Invalid session state "+this.session.state))}var t=e.requestDelegate,r=e.requestOptions||{},i=this.extraHeaders(this.referToString(this._referTo));return r.extraHeaders=r.extraHeaders||[],r.extraHeaders=r.extraHeaders.concat(i),this.session.refer(this,t,r)},e.prototype.extraHeaders=function(e){var t=[];return t.push("Referred-By: <"+this._session.userAgent.configuration.uri+">"),t.push("Contact: "+this._session.contact),t.push("Allow: "+["ACK","CANCEL","INVITE","MESSAGE","BYE","OPTIONS","INFO","NOTIFY","REFER"].toString()),t.push("Refer-To: "+e),t},e.prototype.referToString=function(e){var t;if(e instanceof i.URI)t=e.toString();else{if(!e.dialog)throw new Error("Dialog undefined.");var r=e.remoteIdentity.friendlyName,n=e.dialog.remoteTarget.toString(),s=e.dialog.callId,o=e.dialog.remoteTag,a=e.dialog.localTag;t='"'+r+'" <'+n+"?Replaces="+encodeURIComponent(s+";to-tag="+o+";from-tag="+a)+">"}return t},e}();t.Referrer=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(7),s=r(10),o=r(5),a=r(11),c=r(9),u=r(53),d=r(105);function l(e){var t={expires:600,extraContactHeaderParams:[],instanceId:void 0,params:{},regId:void 0,registrar:void 0},r={mandatory:{},optional:{expires:function(e){if(c.Utils.isDecimal(e)){var t=Number(e);if(t>=0)return t}},extraContactHeaderParams:function(e){if(e instanceof Array)return e.filter(function(e){return"string"==typeof e})},instanceId:function(e){if("string"==typeof e)return/^uuid:/i.test(e)&&(e=e.substr(5)),-1===o.Grammar.parse(e,"uuid")?void 0:e},params:function(e){if("object"==typeof e)return e},regId:function(e){if(c.Utils.isDecimal(e)){var t=Number(e);if(t>=0)return t}},registrar:function(e){if("string"==typeof e){/^sip:/i.test(e)||(e=s.C.SIP+":"+e);var t=o.Grammar.URIParse(e);return t?t.user?void 0:t:void 0}}}};for(var i in r.mandatory){if(!e.hasOwnProperty(i))throw new a.Exceptions.ConfigurationError(i);var n=e[i];if(void 0===(u=r.mandatory[i](n)))throw new a.Exceptions.ConfigurationError(i,n);t[i]=u}for(var i in r.optional)if(e.hasOwnProperty(i)){var u;if((n=e[i])instanceof Array&&0===n.length)continue;if(null===n||""===n||void 0===n||"number"==typeof n&&isNaN(n))continue;if(void 0===(u=r.optional[i](n)))throw new a.Exceptions.ConfigurationError(i,n);t[i]=u}return t}var p=function(e){function t(t,r){void 0===r&&(r={});var i=e.call(this)||this;i._contacts=[],i._state=d.RegistererState.Initial,i._stateEventEmitter=new n.EventEmitter;var o=l(r);if(o.regId&&!o.instanceId?o.instanceId=c.Utils.newUUID():!o.regId&&o.instanceId&&(o.regId=1),o.params.toUri=o.params.toUri||t.configuration.uri,o.params.toDisplayName=o.params.toDisplayName||t.configuration.displayName,o.params.callId=o.params.callId||c.Utils.createRandomToken(22),o.params.cseq=o.params.cseq||Math.floor(1e4*Math.random()),!o.registrar){var a={};"object"==typeof t.configuration.uri?(a=t.configuration.uri.clone()).user=void 0:a=t.configuration.uri,o.registrar=a}i.ua=t,i.logger=t.getLogger("sip.registerer");var u=(r.extraHeaders||[]).slice();for(var p in i.request=t.userAgentCore.makeOutgoingRequestMessage(s.C.REGISTER,o.registrar,o.params.fromUri?o.params.fromUri:t.userAgentCore.configuration.aor,o.params.toUri?o.params.toUri:o.registrar,o.params,u,void 0),i.options=o,i.logger=t.getLogger("sip.registercontext"),i.logger.log("configuration parameters for RegisterContext after validation:"),o)o.hasOwnProperty(p)&&i.logger.log("\xb7 "+p+": "+JSON.stringify(o[p]));return i.expires=o.expires,i.contact=t.contact.toString(),i.registered=!1,t.transport.on("disconnected",function(){return i.onTransportDisconnected()}),i}return i.__extends(t,e),Object.defineProperty(t.prototype,"contacts",{get:function(){return this._contacts.slice()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stateChange",{get:function(){return u.makeEmitter(this._stateEventEmitter)},enumerable:!0,configurable:!0}),t.prototype.register=function(e){var t=this;void 0===e&&(e={}),this.options=i.__assign({},this.options,e);var r=(this.options.extraHeaders||[]).slice();return r.push("Contact: "+this.generateContactHeader(this.expires)),r.push("Allow: "+["ACK","CANCEL","INVITE","MESSAGE","BYE","OPTIONS","INFO","NOTIFY","REFER"].toString()),this.closeHeaders=this.options.closeWithHeaders?(this.options.extraHeaders||[]).slice():[],this.receiveResponse=function(e){if(e.cseq!==t.request.cseq)return Promise.resolve();void 0!==t.registrationTimer&&(clearTimeout(t.registrationTimer),t.registrationTimer=void 0);var r=(e.statusCode||0).toString();switch(!0){case/^1[0-9]{2}$/.test(r):t.emit("progress",e);break;case/^2[0-9]{2}$/.test(r):t.emit("accepted",e);var i=void 0;e.hasHeader("expires")&&(i=Number(e.getHeader("expires"))),void 0!==t.registrationExpiredTimer&&(clearTimeout(t.registrationExpiredTimer),t.registrationExpiredTimer=void 0),t._contacts=e.getHeaders("contact");var n=t._contacts.length;if(!n){t.logger.warn("no Contact header in response to REGISTER, response ignored");break}for(var a=void 0;n--;){if((a=e.parseHeader("contact",n)).uri.user===t.ua.contact.uri.user){i=a.getParam("expires");break}a=void 0}if(!a){t.logger.warn("no Contact header pointing to us, response ignored");break}void 0===i&&(i=t.expires),t.registrationTimer=setTimeout(function(){t.registrationTimer=void 0,t.register(t.options)},1e3*i-3e3),t.registrationExpiredTimer=setTimeout(function(){t.logger.warn("registration expired"),t.registered&&t.unregistered(void 0,s.C.causes.EXPIRES)},1e3*i),a.hasParam("temp-gruu")&&(t.ua.contact.tempGruu=o.Grammar.URIParse(a.getParam("temp-gruu").replace(/"/g,""))),a.hasParam("pub-gruu")&&(t.ua.contact.pubGruu=o.Grammar.URIParse(a.getParam("pub-gruu").replace(/"/g,""))),t._state!==d.RegistererState.Registered&&t.stateTransition(d.RegistererState.Registered),t.registered=!0,t.emit("registered",e||void 0);break;case/^423$/.test(r):e.hasHeader("min-expires")?(t.expires=Number(e.getHeader("min-expires")),t.register(t.options)):(t.logger.warn("423 response received for REGISTER without Min-Expires"),t.registrationFailure(e,s.C.causes.SIP_FAILURE_CODE));break;default:t.registrationFailure(e,c.Utils.sipErrorCause(e.statusCode||0))}},this.request.cseq++,this.request.setHeader("cseq",this.request.cseq+" REGISTER"),this.request.extraHeaders=r,this.send()},t.prototype.unregister=function(e){var t=this;void 0===e&&(e={}),this.registered||e.all||this.logger.warn("Already unregistered, but sending an unregister anyways.");var r=(e.extraHeaders||[]).slice();return this.registered=!1,void 0!==this.registrationTimer&&(clearTimeout(this.registrationTimer),this.registrationTimer=void 0),e.all?(r.push("Contact: *"),r.push("Expires: 0")):r.push("Contact: "+this.generateContactHeader(0)),this.receiveResponse=function(e){var r=e&&e.statusCode?e.statusCode.toString():"";switch(!0){case/^1[0-9]{2}$/.test(r):t.emit("progress",e);break;case/^2[0-9]{2}$/.test(r):t._contacts=e.getHeaders("contact"),t.emit("accepted",e),void 0!==t.registrationExpiredTimer&&(clearTimeout(t.registrationExpiredTimer),t.registrationExpiredTimer=void 0),t.unregistered(e);break;default:t.unregistered(e,c.Utils.sipErrorCause(e.statusCode||0))}},this.request.cseq++,this.request.setHeader("cseq",this.request.cseq+" REGISTER"),this.request.extraHeaders=r,this.send()},t.prototype.close=function(){var e={all:!1,extraHeaders:this.closeHeaders};this.registeredBefore=this.registered,this.registered&&this.unregister(e)},t.prototype.unregistered=function(e,t){this._state!==d.RegistererState.Unregistered&&this.stateTransition(d.RegistererState.Unregistered),this.registered=!1,this.emit("unregistered",e||void 0,t||void 0)},t.prototype.send=function(){var e=this.receiveResponse;if(!e)throw new Error("Receive response undefined.");return this.ua.userAgentCore.register(this.request,{onAccept:function(t){return e(t.message)},onProgress:function(t){return e(t.message)},onRedirect:function(t){return e(t.message)},onReject:function(t){return e(t.message)},onTrying:function(t){return e(t.message)}}),Promise.resolve()},t.prototype.registrationFailure=function(e,t){this._state!==d.RegistererState.Unregistered&&this.stateTransition(d.RegistererState.Unregistered),this.emit("failed",e||void 0,t||void 0)},t.prototype.onTransportDisconnected=function(){this.registeredBefore=this.registered,void 0!==this.registrationTimer&&(clearTimeout(this.registrationTimer),this.registrationTimer=void 0),void 0!==this.registrationExpiredTimer&&(clearTimeout(this.registrationExpiredTimer),this.registrationExpiredTimer=void 0),this.registered&&this.unregistered(void 0,s.C.causes.CONNECTION_ERROR)},t.prototype.generateContactHeader=function(e){void 0===e&&(e=0);var t=this.contact;return this.options.regId&&this.options.instanceId&&(t+=";reg-id="+this.options.regId,t+=';+sip.instance="<urn:uuid:'+this.options.instanceId+'>"'),this.options.extraContactHeaderParams&&this.options.extraContactHeaderParams.forEach(function(e){t+=";"+e}),t+=";expires="+e},t.prototype.stateTransition=function(e){var t=this,r=function(){throw new Error("Invalid state transition from "+t._state+" to "+e)};switch(this._state){case d.RegistererState.Initial:e!==d.RegistererState.Registered&&e!==d.RegistererState.Unregistered&&r();break;case d.RegistererState.Registered:e!==d.RegistererState.Unregistered&&r();break;case d.RegistererState.Unregistered:e!==d.RegistererState.Registered&&r();break;default:throw new Error("Unrecognized state.")}this._state=e,this.logger.log("Registration transitioned to state "+this._state),this._stateEventEmitter.emit("event",this._state)},t}(n.EventEmitter);t.Registerer=p},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(5),s=r(14),o=r(9),a=r(54),c=r(106),u=r(97),d=function(e){function t(t,r,i,n){void 0===n&&(n={});var s=e.call(this,t,n)||this;return s.body=void 0,s.logger=t.getLogger("sip.subscription"),n.body&&(s.body={body:n.body,contentType:n.contentType?n.contentType:"application/sdp"}),s.userAgent=t,s.targetURI=r,s.event=i,void 0===n.expires?s.expires=3600:"number"!=typeof n.expires?(s.logger.warn('Option "expires" must be a number. Using default of 3600.'),s.expires=3600):s.expires=n.expires,s.extraHeaders=(n.extraHeaders||[]).slice(),s.context=s.initContext(),s.request=s.context.message,s.id=s.request.callId+s.request.from.parameters.tag+s.event,s.userAgent.subscriptions[s.id]=s,s}return i.__extends(t,e),t.prototype.dispose=function(){this.disposed||(e.prototype.dispose.call(this),this.retryAfterTimer&&(clearTimeout(this.retryAfterTimer),this.retryAfterTimer=void 0),this.context.dispose(),delete this.userAgent.subscriptions[this.id])},t.prototype.subscribe=function(e){var t=this;switch(void 0===e&&(e={}),this.context.state){case n.SubscriptionState.Initial:this.state===u.SubscriptionState.Initial&&this.stateTransition(u.SubscriptionState.NotifyWait),this.context.subscribe().then(function(e){e.success?(e.success.subscription&&(t.dialog=e.success.subscription,t.dialog.delegate={onNotify:function(e){return t.onNotify(e)},onRefresh:function(e){return t.onRefresh(e)},onTerminated:function(){t.dispose(),t.onTerminated()}}),t.onNotify(e.success.request)):e.failure&&t.onFailed(e.failure.response)});break;case n.SubscriptionState.NotifyWait:case n.SubscriptionState.Pending:break;case n.SubscriptionState.Active:if(this.dialog)this.dialog.refresh().delegate={onAccept:function(e){return t.onAccepted(e)},onRedirect:function(e){return t.onFailed(e)},onReject:function(e){return t.onFailed(e)}};break;case n.SubscriptionState.Terminated:}return Promise.resolve()},t.prototype.unsubscribe=function(e){if(void 0===e&&(e={}),this.disposed)return Promise.resolve();switch(this.context.state){case n.SubscriptionState.Initial:case n.SubscriptionState.NotifyWait:break;case n.SubscriptionState.Pending:case n.SubscriptionState.Active:this.dialog&&this.dialog.unsubscribe();break;case n.SubscriptionState.Terminated:}return this.dispose(),this.onTerminated(),Promise.resolve()},t.prototype.close=function(){return this.unsubscribe()},t.prototype.refresh=function(){return this.context.state===n.SubscriptionState.Active?this.subscribe():Promise.resolve()},t.prototype.on=function(t,r){return e.prototype.on.call(this,t,r)},t.prototype.emit=function(t){for(var r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];return e.prototype.emit.apply(this,[t].concat(r))},t.prototype.onAccepted=function(e){var t=e.message.statusCode?e.message.statusCode:0,r=o.Utils.getReasonPhrase(t);this.emit("accepted",e.message,r)},t.prototype.onFailed=function(e){if(this.close(),e){var t=e.message.statusCode?e.message.statusCode:0,r=o.Utils.getReasonPhrase(t);this.emit("failed",e.message,r),this.emit("rejected",e.message,r)}},t.prototype.onNotify=function(e){var t=this;if(this.emit("notify",{request:e.message}),this.disposed)e.accept();else{if(this.state!==u.SubscriptionState.Subscribed&&this.stateTransition(u.SubscriptionState.Subscribed),this.delegate&&this.delegate.onNotify){var r=new a.Notification(e);this.delegate.onNotify(r)}else e.accept();var i=e.message.parseHeader("Subscription-State");if(i&&i.state)switch(i.state){case"terminated":if(i.reason)switch(this.logger.log("Terminated subscription with reason "+i.reason),i.reason){case"deactivated":case"timeout":return this.initContext(),void this.subscribe();case"probation":case"giveup":return this.initContext(),void(i.params&&i.params["retry-after"]?this.retryAfterTimer=setTimeout(function(){return t.subscribe()},i.params["retry-after"]):this.subscribe())}this.close()}}},t.prototype.onRefresh=function(e){var t=this;e.delegate={onAccept:function(e){return t.onAccepted(e)}}},t.prototype.onTerminated=function(){this.emit("terminated")},t.prototype.initContext=function(){var e=this,t={extraHeaders:this.extraHeaders,body:this.body?o.Utils.fromBodyObj(this.body):void 0};return this.context=new l(this.userAgent.userAgentCore,this.targetURI,this.event,this.expires,t),this.context.delegate={onAccept:function(t){return e.onAccepted(t)}},this.context},t}(c.Subscription);t.Subscriber=d;var l=function(){function e(e,t,r,i,o,a){this.core=e,this.target=t,this.event=r,this.expires=i,this.subscribed=!1,this.logger=e.loggerFactory.getLogger("sip.subscription"),this.delegate=a;var c="Allow: "+s.AllowedMethods.toString(),u=(o&&o.extraHeaders||[]).slice();u.push(c),u.push("Event: "+this.event),u.push("Expires: "+this.expires),u.push("Contact: "+this.core.configuration.contact.toString());var d=o&&o.body;this.message=e.makeOutgoingRequestMessage(n.C.SUBSCRIBE,this.target,this.core.configuration.aor,this.target,{},u,d)}return e.prototype.dispose=function(){this.subscription&&this.subscription.dispose(),this.request&&(this.request.waitNotifyStop(),this.request.dispose())},Object.defineProperty(e.prototype,"state",{get:function(){return this.subscription?this.subscription.subscriptionState:this.subscribed?n.SubscriptionState.NotifyWait:n.SubscriptionState.Initial},enumerable:!0,configurable:!0}),e.prototype.subscribe=function(){var e=this;return this.subscribed?Promise.reject(new Error("Not in initial state. Did you call subscribe more than once?")):(this.subscribed=!0,new Promise(function(t,r){if(!e.message)throw new Error("Message undefined.");e.request=e.core.subscribe(e.message,{onAccept:function(t){e.delegate&&e.delegate.onAccept&&e.delegate.onAccept(t)},onNotify:function(r){e.subscription=r.subscription,e.subscription&&(e.subscription.autoRefresh=!0),t({success:r})},onNotifyTimeout:function(){t({failure:{}})},onRedirect:function(e){t({failure:{response:e}})},onReject:function(e){t({failure:{response:e}})}})}))},e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(7),s=r(10),o=r(5),a=r(8),c=r(87),u=r(9),d=r(89),l=r(92),p=r(96),h=r(103),g=r(104),f=r(54),v=r(31),m=r(93),S=function(e){function t(r){void 0===r&&(r={});var n=e.call(this)||this;if(n.data={},n.applicants={},n.publishers={},n.sessions={},n.subscriptions={},n.status=a.UAStatus.STATUS_INIT,n.loggerFactory=new o.LoggerFactory,n.unloadListener=function(){n.stop()},n.delegate=r.delegate,n.options=i.__assign({},t.defaultOptions,{sipjsId:u.Utils.createRandomToken(5)},{uri:new o.URI("sip","anonymous."+u.Utils.createRandomToken(6),"anonymous.invalid")},{viaHost:u.Utils.createRandomToken(12)+".invalid"},r),n.options.hackIpInContact)if("boolean"==typeof n.options.hackIpInContact&&n.options.hackIpInContact){var s=Math.floor(254*Math.random()+1);n.options.viaHost="192.0.2."+s}else n.options.hackIpInContact&&(n.options.viaHost=n.options.hackIpInContact);switch(n.logger=n.loggerFactory.getLogger("sip.UserAgent"),n.loggerFactory.builtinEnabled=n.options.logBuiltinEnabled,n.loggerFactory.connector=n.options.logConnector,n.options.logLevel){case"error":n.loggerFactory.level=o.Levels.error;break;case"warn":n.loggerFactory.level=o.Levels.warn;break;case"log":n.loggerFactory.level=o.Levels.log;break;case"debug":n.loggerFactory.level=o.Levels.debug}if(n.options.logConfiguration){n.logger.log("Configuration:");for(var c=0,d=Object.entries(n.options);c<d.length;c++){var l=d[c],p=l[0],h=l[1];switch(p){case"uri":case"sessionDescriptionHandlerFactory":n.logger.log("\xb7 "+p+": "+h);break;case"authorizationPassword":n.logger.log("\xb7 "+p+": NOT SHOWN");break;case"transportConstructor":n.logger.log("\xb7 "+p+": "+h.name);break;default:n.logger.log("\xb7 "+p+": "+JSON.stringify(h))}}}return n.transport=new n.options.transportConstructor(n.getLogger("sip.transport"),n.options.transportOptions),n.contact=n.initContact(),n.userAgentCore=n.initCore(),n.options.autoStart&&n.start(),n}return i.__extends(t,e),Object.defineProperty(t.prototype,"configuration",{get:function(){return this.options},enumerable:!0,configurable:!0}),t.prototype.makeTargetURI=function(e){var t=this.options.uri.clone();t.user=void 0;var r=t.toRaw().replace(/^sip:/i,"");return u.Utils.normalizeTarget(e,r)},t.prototype.start=function(){if(this.logger.log("user requested startup..."),this.status===a.UAStatus.STATUS_INIT)return this.status=a.UAStatus.STATUS_STARTING,this.setTransportListeners(),this.transport.connect();if(this.status===a.UAStatus.STATUS_USER_CLOSED)return this.logger.log("resuming"),this.status=a.UAStatus.STATUS_READY,this.transport.connect();if(this.status===a.UAStatus.STATUS_STARTING?this.logger.log("UA is in STARTING status, not opening new connection"):this.status===a.UAStatus.STATUS_READY?this.logger.log("UA is in READY status, not resuming"):this.logger.error("Connection is down. Auto-Recovery system is trying to connect"),this.options.autoStop){var e=!("undefined"==typeof chrome||!chrome.app||!chrome.app.runtime);"undefined"==typeof window||"function"!=typeof window.addEventListener||e||window.addEventListener("unload",this.unloadListener)}return Promise.resolve()},t.prototype.stop=function(){for(var e in this.logger.log("user requested closure..."),this.status===a.UAStatus.STATUS_USER_CLOSED&&this.logger.warn("UA already closed"),this.sessions)if(this.sessions[e]){this.logger.log("closing session "+e);var t=this.sessions[e];switch(t.state){case v.SessionState.Initial:case v.SessionState.Establishing:t instanceof p.Invitation&&t.reject(),t instanceof h.Inviter&&t.cancel();break;case v.SessionState.Established:t.bye();break;case v.SessionState.Terminating:case v.SessionState.Terminated:}}for(var r in this.subscriptions)this.subscriptions[r]&&(this.logger.log("unsubscribe "+r),this.subscriptions[r].unsubscribe());for(var i in this.publishers)this.publishers[i]&&(this.logger.log("unpublish "+i),this.publishers[i].close());for(var n in this.applicants)this.applicants[n]&&this.applicants[n].close();if(this.status=a.UAStatus.STATUS_USER_CLOSED,this.transport.disconnect(),this.userAgentCore.reset(),this.options.autoStop){var s=!("undefined"==typeof chrome||!chrome.app||!chrome.app.runtime);"undefined"!=typeof window&&window.removeEventListener&&!s&&window.removeEventListener("unload",this.unloadListener)}return Promise.resolve()},t.prototype.findSession=function(e){return this.sessions[e.callId+e.fromTag]||this.sessions[e.callId+e.toTag]||void 0},t.prototype.getLogger=function(e,t){return this.loggerFactory.getLogger(e,t)},t.prototype.getLoggerFactory=function(){return this.loggerFactory},t.prototype.getSupportedResponseOptions=function(){var e=[];(this.contact.pubGruu||this.contact.tempGruu)&&e.push("gruu"),this.options.sipExtension100rel===m.SIPExtension.Supported&&e.push("100rel"),this.options.sipExtensionReplaces===m.SIPExtension.Supported&&e.push("replaces"),e.push("outbound"),e=e.concat(this.options.sipExtensionExtraSupported||[]);var t=this.options.hackAllowUnregisteredOptionTags||!1,r={};return e=e.filter(function(e){var i=s.C.OPTION_TAGS[e],n=!r[e];return r[e]=!0,(i||t)&&n})},t.prototype.makeInviter=function(e,t){return new h.Inviter(this,e,t)},t.prototype.on=function(t,r){return e.prototype.on.call(this,t,r)},t.prototype.onTransportError=function(){this.status!==a.UAStatus.STATUS_USER_CLOSED&&(this.error&&this.error===t.C.NETWORK_ERROR||(this.status=a.UAStatus.STATUS_NOT_READY,this.error=t.C.NETWORK_ERROR))},t.prototype.setTransportListeners=function(){var e=this;this.transport.on("connected",function(){return e.onTransportConnected()}),this.transport.on("message",function(t){return e.onTransportReceiveMsg(t)}),this.transport.on("transportError",function(){return e.onTransportError()})},t.prototype.onTransportConnected=function(){},t.prototype.onTransportReceiveMsg=function(e){var t=this,r=c.Parser.parseMessage(e,this.getLogger("sip.parser"));if(r)if(this.status===a.UAStatus.STATUS_USER_CLOSED&&r instanceof o.IncomingRequestMessage)this.logger.warn("UA received message when status = USER_CLOSED - aborting");else{var i=function(){for(var e=0,i=["from","to","call_id","cseq","via"];e<i.length;e++){var n=i[e];if(!r.hasHeader(n))return t.logger.warn("Missing mandatory header field : "+n+"."),!1}return!0};if(r instanceof o.IncomingRequestMessage){if(!i())return void this.logger.warn("Request missing mandatory header field. Dropping.");if(!r.toTag&&r.callId.substr(0,5)===this.options.sipjsId)return void this.userAgentCore.replyStateless(r,{statusCode:482});var n=u.Utils.str_utf8_length(r.body);if((s=r.getHeader("content-length"))&&n<Number(s))return void this.userAgentCore.replyStateless(r,{statusCode:400})}if(r instanceof o.IncomingResponseMessage){if(!i())return void this.logger.warn("Response missing mandatory header field. Dropping.");if(r.getHeaders("via").length>1)return void this.logger.warn("More than one Via header field present in the response. Dropping.");if(r.via.host!==this.options.viaHost||void 0!==r.via.port)return void this.logger.warn("Via sent-by in the response does not match UA Via host value. Dropping.");var s;n=u.Utils.str_utf8_length(r.body);if((s=r.getHeader("content-length"))&&n<Number(s))return void this.logger.warn("Message body length is lower than the value in Content-Length header field. Dropping.")}if(r instanceof o.IncomingRequestMessage)this.userAgentCore.receiveIncomingRequestFromTransport(r);else{if(!(r instanceof o.IncomingResponseMessage))throw new Error("Invalid message type.");this.userAgentCore.receiveIncomingResponseFromTransport(r)}}else this.logger.warn("UA failed to parse incoming SIP message - discarding.")},t.prototype.initContact=function(){var e=this,t=u.Utils.createRandomToken(8),r=this.options.hackWssInTransport?"wss":"ws";return{pubGruu:void 0,tempGruu:void 0,uri:new o.URI("sip",t,this.options.viaHost,void 0,{transport:r}),toString:function(t){void 0===t&&(t={});var i=t.anonymous||!1,n=t.outbound||!1,s="<";return s+=i?e.contact.tempGruu||"sip:[email protected];transport="+r:e.contact.pubGruu||e.contact.uri,n&&(s+=";ob"),s+=">"}}},t.prototype.initCore=function(){var e=this,t=[];t.push("outbound"),this.options.sipExtension100rel===m.SIPExtension.Supported&&t.push("100rel"),this.options.sipExtensionReplaces===m.SIPExtension.Supported&&t.push("replaces"),this.options.sipExtensionExtraSupported&&t.push.apply(t,this.options.sipExtensionExtraSupported),this.options.hackAllowUnregisteredOptionTags||(t=t.filter(function(e){return m.UserAgentRegisteredOptionTags[e]}));var r=(t=Array.from(new Set(t))).slice();(this.contact.pubGruu||this.contact.tempGruu)&&r.push("gruu");var i={aor:this.options.uri,contact:this.contact,displayName:this.options.displayName,loggerFactory:this.loggerFactory,hackViaTcp:this.options.hackViaTcp,hackViaWS:this.options.hackViaWS,routeSet:this.options.usePreloadedRoute&&this.transport.server&&this.transport.server.sipUri?[this.transport.server.sipUri]:[],supportedOptionTags:t,supportedOptionTagsResponse:r,sipjsId:this.options.sipjsId,userAgentHeaderFieldValue:this.options.userAgentString,viaForceRport:this.options.forceRport,viaHost:this.options.viaHost,authenticationFactory:function(){var t=e.options.authorizationUsername?e.options.authorizationUsername:e.options.uri.user,r=e.options.authorizationPassword?e.options.authorizationPassword:void 0;return new o.DigestAuthentication(e.getLoggerFactory(),t,r)},transportAccessor:function(){return e.transport}},n={onInvite:function(t){t.trying(),t.delegate={onCancel:function(e){r.onCancel(e)},onTransportError:function(e){r.onTransportError()}};var r=new p.Invitation(e,t);!function(t,r){if(e.options.sipExtensionReplaces!==m.SIPExtension.Unsupported){var i=r.parseHeader("replaces");if(i){var n=e.sessions[i.call_id+i.replaces_from_tag]||e.sessions[i.call_id+i.replaces_to_tag]||void 0;if(!n)return void e.userAgentCore.replyStateless(r,{statusCode:481});if(n.status===a.SessionStatus.STATUS_TERMINATED)return void e.userAgentCore.replyStateless(r,{statusCode:603});var s=i.call_id+i.replaces_to_tag+i.replaces_from_tag,o=e.userAgentCore.dialogs.get(s);if(!o)return void e.userAgentCore.replyStateless(r,{statusCode:481});if(!o.early&&i.early_only)return void e.userAgentCore.replyStateless(r,{statusCode:486});t.replacee=n}}}(r,t.message),r.autoSendAnInitialProvisionalResponse&&r.progress(),e.delegate&&e.delegate.onInvite&&e.delegate.onInvite(r),e.emit("invite",r)},onMessage:function(t){if(e.delegate&&e.delegate.onMessage){var r=new g.Message(t);e.delegate.onMessage(r)}else t.accept()},onNotify:function(t){if(e.delegate&&e.delegate.onNotify){var r=new f.Notification(t);e.delegate.onNotify(r)}else e.options.allowLegacyNotifications?t.accept():t.reject({statusCode:481});e.options.allowLegacyNotifications&&e.listeners("notify").length>0&&e.emit("notify",{request:t.message})},onRefer:function(t){e.logger.log("Received an out of dialog refer"),e.options.allowOutOfDialogRefers||t.reject({statusCode:405}),e.logger.log("Allow out of dialog refers is enabled on the UA")},onSubscribe:function(t){e.emit("subscribe",t)}};return new o.UserAgentCore(i,n)},t.C={STATUS_INIT:0,STATUS_STARTING:1,STATUS_READY:2,STATUS_USER_CLOSED:3,STATUS_NOT_READY:4,CONFIGURATION_ERROR:1,NETWORK_ERROR:2,ALLOWED_METHODS:["ACK","CANCEL","INVITE","MESSAGE","BYE","OPTIONS","INFO","NOTIFY","REFER"],ACCEPTED_BODY_TYPES:["application/sdp","application/dtmf-relay"],MAX_FORWARDS:70,TAG_LENGTH:10},t.defaultOptions={allowLegacyNotifications:!1,allowOutOfDialogRefers:!1,authorizationPassword:"",authorizationUsername:"",autoStart:!0,autoStop:!0,delegate:{},displayName:"",forceRport:!1,hackAllowUnregisteredOptionTags:!1,hackIpInContact:!1,hackViaTcp:!1,hackViaWS:!1,hackWssInTransport:!1,logBuiltinEnabled:!0,logConfiguration:!0,logConnector:function(){},logLevel:"log",noAnswerTimeout:60,sessionDescriptionHandlerFactory:d.SessionDescriptionHandler.defaultFactory,sessionDescriptionHandlerFactoryOptions:{},sipExtension100rel:m.SIPExtension.Unsupported,sipExtensionReplaces:m.SIPExtension.Unsupported,sipExtensionExtraSupported:[],sipjsId:"",transportConstructor:l.Transport,transportOptions:{},uri:new o.URI("sip","anonymous","anonymous.invalid"),usePreloadedRoute:!1,userAgentString:s.C.USER_AGENT,viaHost:""},t}(n.EventEmitter);t.UserAgent=S}])});