-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsip-0.9.1.min.js
38 lines (38 loc) · 190 KB
/
sip-0.9.1.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*!
*
* SIP version 0.9.1
* Copyright (c) 2014-2017 Junction Networks, Inc <http://www.onsip.com>
* Homepage: https://sipjs.com
* License: https://sipjs.com/license/
*
*
* ~~~SIP.js contains substantial portions of JsSIP under the following license~~~
* Homepage: http://jssip.net
* Copyright (c) 2012-2013 José Luis Millán - Versatica <http://www.versatica.com>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* ~~~ end JsSIP license ~~~
*
*
*
*
*/
!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()}("undefined"!=typeof self?self:this,function(){return function(e){function t(s){if(i[s])return i[s].exports;var r=i[s]={i:s,l:!1,exports:{}};return e[s].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var i={};return t.m=e,t.c=i,t.d=function(e,i,s){t.o(e,i)||Object.defineProperty(e,i,{configurable:!1,enumerable:!0,get:s})},t.n=function(e){var i=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(i,"a",i),i},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1)}([function(e,t){var i;i=function(){return this}();try{i=i||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(i=window)}e.exports=i},function(e,t,i){"use strict";e.exports=i(2)(i(34))},function(e,t,i){"use strict";e.exports=function(e){var t=i(3),s=t.version,r=t.title,n=Object.defineProperties({},{version:{get:function(){return s}},name:{get:function(){return r}}});return i(4)(n,e),n.LoggerFactory=i(5)(e.console),n.EventEmitter=i(6)(),n.C=i(8)(n.name,n.version),n.Exceptions=i(9),n.Timers=i(10)(e.timers),n.Transport=e.Transport(n,e.WebSocket),i(11)(n),i(12)(n),i(13)(n),i(14)(n),i(15)(n),i(16)(n),i(18)(n),i(19)(n),n.SessionDescriptionHandler=i(20)(n.EventEmitter),i(21)(n),i(22)(n),i(23)(n),i(25)(n),i(26)(n,e),i(28)(n),n.DigestAuthentication=i(29)(n.Utils),n.Grammar=i(30)(n),n.WebRTC={Modifiers:i(32)(n),Simple:i(33)(n)},n}},function(e,t){e.exports={name:"sip.js",title:"SIP.js",description:"A simple, intuitive, and powerful JavaScript signaling library",version:"0.9.1",main:"dist/sip.min.js",browser:{"./src/environment.js":"./src/environment_browser.js"},homepage:"https://sipjs.com",author:"OnSIP <developer@onsip.com> (https://sipjs.com/aboutus/)",contributors:[{url:"https://github.com/onsip/SIP.js/blob/master/THANKS.md"}],repository:{type:"git",url:"https://github.com/onsip/SIP.js.git"},keywords:["sip","websocket","webrtc","library","javascript"],devDependencies:{"babel-core":"^6.26.0","babel-loader":"^7.1.2","babel-preset-env":"^1.6.1",eslint:"^4.9.0","jasmine-core":"^2.8.0",karma:"^1.7.1","karma-cli":"^1.0.1","karma-jasmine":"^1.1.0","karma-jasmine-html-reporter":"^0.2.2","karma-mocha-reporter":"^2.2.5","karma-phantomjs-launcher":"^1.0.4","karma-webpack":"^2.0.6",pegjs:"^0.10.0","pegjs-loader":"^0.5.4","uglifyjs-webpack-plugin":"^1.0.1",webpack:"^3.8.1"},engines:{node:">=4.0"},license:"MIT",scripts:{prebuild:"eslint src/*.js src/**/*.js",build:"webpack --progress && cp dist/sip.js dist/sip-$npm_package_version.js && cp dist/sip.min.js dist/sip-$npm_package_version.min.js",browserTest:"sleep 2 && open http://0.0.0.0:9876/debug.html & karma start --reporters kjhtml --no-single-run",commandLineTest:"karma start --reporters mocha --browsers PhantomJS --single-run",buildAndTest:"npm run build && npm run commandLineTest"},dependencies:{ws:"^1.0.1"},optionalDependencies:{promiscuous:"^0.6.0"}}},function(e,t,i){"use strict";e.exports=function(e,t){var i;i={Promise:t.Promise,defer:function(){var e={};return e.promise=new i.Promise(function(t,i){e.resolve=t,e.reject=i}),e},reducePromises:function(t,i){return t.reduce(function(e,t){return e=e.then(t)},e.Utils.Promise.resolve(i))},augment:function(e,t,i,s){var r,n;n=t.prototype;for(r in n)(s||void 0===e[r])&&(e[r]=n[r]);t.apply(e,i)},optionsOverride:function(e,t,i,s,r,n){s&&e[i]&&r.warn(i+" is deprecated, please use "+t+" instead"),e[t]&&e[i]&&r.warn(t+" overriding "+i),e[t]=e[t]||e[i]||n},str_utf8_length:function(e){return encodeURIComponent(e).replace(/%[A-F\d]{2}/g,"U").length},generateFakeSDP:function(e){if(e){var t=e.indexOf("o="),i=e.indexOf("\r\n",t);return"v=0\r\n"+e.slice(t,i)+"\r\ns=-\r\nt=0 0\r\nc=IN IP4 0.0.0.0"}},isFunction:function(e){return void 0!==e&&"[object Function]"===Object.prototype.toString.call(e)},isDecimal:function(e){return!isNaN(e)&&parseFloat(e)===parseInt(e,10)},createRandomToken:function(e,t){var i,s="";for(t=t||32,i=0;i<e;i++)s+=(Math.random()*t|0).toString(t);return s},newTag:function(){return e.Utils.createRandomToken(e.UA.C.TAG_LENGTH)},newUUID:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},hostType:function(t){if(t)return-1!==(t=e.Grammar.parse(t,"host"))?t.host_type:void 0},normalizeTarget:function(t,i){var s,r,n;if(t){if(t instanceof e.URI)return t;if("string"==typeof t){switch((s=t.split("@")).length){case 1:if(!i)return;r=t,n=i;break;case 2:r=s[0],n=s[1];break;default:r=s.slice(0,s.length-1).join("@"),n=s[s.length-1]}return r=r.replace(/^(sips?|tel):/i,""),/^[\-\.\(\)]*\+?[0-9\-\.\(\)]+$/.test(r)&&(r=r.replace(/[\-\.\(\)]/g,"")),t=e.C.SIP+":"+e.Utils.escapeUser(r)+"@"+n,e.URI.parse(t)}}else;},escapeUser:function(e){return encodeURIComponent(decodeURIComponent(e)).replace(/%3A/gi,":").replace(/%2B/gi,"+").replace(/%3F/gi,"?").replace(/%2F/gi,"/")},headerize:function(e){var t,i={"Call-Id":"Call-ID",Cseq:"CSeq","Min-Se":"Min-SE",Rack:"RAck",Rseq:"RSeq","Www-Authenticate":"WWW-Authenticate"},s=e.toLowerCase().replace(/_/g,"-").split("-"),r="",n=s.length;for(t=0;t<n;t++)0!==t&&(r+="-"),r+=s[t].charAt(0).toUpperCase()+s[t].substring(1);return i[r]&&(r=i[r]),r},sipErrorCause:function(t){var i;for(i in e.C.SIP_ERROR_CAUSES)if(-1!==e.C.SIP_ERROR_CAUSES[i].indexOf(t))return e.C.causes[i];return e.C.causes.SIP_FAILURE_CODE},getReasonPhrase:function(t,i){return i||e.C.REASON_PHRASE[t]||""},getReasonHeaderValue:function(t,i){return i=e.Utils.getReasonPhrase(t,i),"SIP ;cause="+t+' ;text="'+i+'"'},getCancelReason:function(t,i){if(t&&t<200||t>699)throw new TypeError("Invalid status_code: "+t);if(t)return e.Utils.getReasonHeaderValue(t,i)},buildStatusLine:function(e,t){if(e=e||null,t=t||null,!e||e<100||e>699)throw new TypeError("Invalid status_code: "+e);if(t&&"string"!=typeof t&&!(t instanceof String))throw new TypeError("Invalid reason_phrase: "+t);return t=i.getReasonPhrase(e,t),"SIP/2.0 "+e+" "+t+"\r\n"},getRandomTestNetIP:function(){return"192.0.2."+function(e,t){return Math.floor(Math.random()*(t-e+1)+e)}(1,254)},calculateMD5:function(e){function t(e,t){return e<<t|e>>>32-t}function i(e,t){var i,s,r,n,o;return r=2147483648&e,n=2147483648&t,i=1073741824&e,s=1073741824&t,o=(1073741823&e)+(1073741823&t),i&s?2147483648^o^r^n:i|s?1073741824&o?3221225472^o^r^n:1073741824^o^r^n:o^r^n}function s(e,s,r,n,o,a,c){return e=i(e,i(i(function(e,t,i){return e&t|~e&i}(s,r,n),o),c)),i(t(e,a),s)}function r(e,s,r,n,o,a,c){return e=i(e,i(i(function(e,t,i){return e&i|t&~i}(s,r,n),o),c)),i(t(e,a),s)}function n(e,s,r,n,o,a,c){return e=i(e,i(i(function(e,t,i){return e^t^i}(s,r,n),o),c)),i(t(e,a),s)}function o(e,s,r,n,o,a,c){return e=i(e,i(i(function(e,t,i){return t^(e|~i)}(s,r,n),o),c)),i(t(e,a),s)}function a(e){var t,i="",s="";for(t=0;t<=3;t++)i+=(s="0"+(e>>>8*t&255).toString(16)).substr(s.length-2,2);return i}var c,h,u,l,d,p,g,f,T,m=[];for(m=function(e){for(var t,i=e.length,s=i+8,r=16*((s-s%64)/64+1),n=Array(r-1),o=0,a=0;a<i;)o=a%4*8,n[t=(a-a%4)/4]=n[t]|e.charCodeAt(a)<<o,a++;return t=(a-a%4)/4,o=a%4*8,n[t]=n[t]|128<<o,n[r-2]=i<<3,n[r-1]=i>>>29,n}(e=function(e){e=e.replace(/\r\n/g,"\n");for(var t="",i=0;i<e.length;i++){var s=e.charCodeAt(i);s<128?t+=String.fromCharCode(s):s>127&&s<2048?(t+=String.fromCharCode(s>>6|192),t+=String.fromCharCode(63&s|128)):(t+=String.fromCharCode(s>>12|224),t+=String.fromCharCode(s>>6&63|128),t+=String.fromCharCode(63&s|128))}return t}(e)),p=1732584193,g=4023233417,f=2562383102,T=271733878,c=0;c<m.length;c+=16)h=p,u=g,l=f,d=T,g=o(g=o(g=o(g=o(g=n(g=n(g=n(g=n(g=r(g=r(g=r(g=r(g=s(g=s(g=s(g=s(g,f=s(f,T=s(T,p=s(p,g,f,T,m[c+0],7,3614090360),g,f,m[c+1],12,3905402710),p,g,m[c+2],17,606105819),T,p,m[c+3],22,3250441966),f=s(f,T=s(T,p=s(p,g,f,T,m[c+4],7,4118548399),g,f,m[c+5],12,1200080426),p,g,m[c+6],17,2821735955),T,p,m[c+7],22,4249261313),f=s(f,T=s(T,p=s(p,g,f,T,m[c+8],7,1770035416),g,f,m[c+9],12,2336552879),p,g,m[c+10],17,4294925233),T,p,m[c+11],22,2304563134),f=s(f,T=s(T,p=s(p,g,f,T,m[c+12],7,1804603682),g,f,m[c+13],12,4254626195),p,g,m[c+14],17,2792965006),T,p,m[c+15],22,1236535329),f=r(f,T=r(T,p=r(p,g,f,T,m[c+1],5,4129170786),g,f,m[c+6],9,3225465664),p,g,m[c+11],14,643717713),T,p,m[c+0],20,3921069994),f=r(f,T=r(T,p=r(p,g,f,T,m[c+5],5,3593408605),g,f,m[c+10],9,38016083),p,g,m[c+15],14,3634488961),T,p,m[c+4],20,3889429448),f=r(f,T=r(T,p=r(p,g,f,T,m[c+9],5,568446438),g,f,m[c+14],9,3275163606),p,g,m[c+3],14,4107603335),T,p,m[c+8],20,1163531501),f=r(f,T=r(T,p=r(p,g,f,T,m[c+13],5,2850285829),g,f,m[c+2],9,4243563512),p,g,m[c+7],14,1735328473),T,p,m[c+12],20,2368359562),f=n(f,T=n(T,p=n(p,g,f,T,m[c+5],4,4294588738),g,f,m[c+8],11,2272392833),p,g,m[c+11],16,1839030562),T,p,m[c+14],23,4259657740),f=n(f,T=n(T,p=n(p,g,f,T,m[c+1],4,2763975236),g,f,m[c+4],11,1272893353),p,g,m[c+7],16,4139469664),T,p,m[c+10],23,3200236656),f=n(f,T=n(T,p=n(p,g,f,T,m[c+13],4,681279174),g,f,m[c+0],11,3936430074),p,g,m[c+3],16,3572445317),T,p,m[c+6],23,76029189),f=n(f,T=n(T,p=n(p,g,f,T,m[c+9],4,3654602809),g,f,m[c+12],11,3873151461),p,g,m[c+15],16,530742520),T,p,m[c+2],23,3299628645),f=o(f,T=o(T,p=o(p,g,f,T,m[c+0],6,4096336452),g,f,m[c+7],10,1126891415),p,g,m[c+14],15,2878612391),T,p,m[c+5],21,4237533241),f=o(f,T=o(T,p=o(p,g,f,T,m[c+12],6,1700485571),g,f,m[c+3],10,2399980690),p,g,m[c+10],15,4293915773),T,p,m[c+1],21,2240044497),f=o(f,T=o(T,p=o(p,g,f,T,m[c+8],6,1873313359),g,f,m[c+15],10,4264355552),p,g,m[c+6],15,2734768916),T,p,m[c+13],21,1309151649),f=o(f,T=o(T,p=o(p,g,f,T,m[c+4],6,4149444226),g,f,m[c+11],10,3174756917),p,g,m[c+2],15,718787259),T,p,m[c+9],21,3951481745),p=i(p,h),g=i(g,u),f=i(f,l),T=i(T,d);return(a(p)+a(g)+a(f)+a(T)).toLowerCase()}},e.Utils=i}},function(e,t,i){"use strict";var s={error:0,warn:1,log:2,debug:3};e.exports=function(e){function t(e,t,i){this.logger=e,this.category=t,this.label=i}var i=function(){var e,t=2,i=!0,r=null;this.loggers={},e=this.getLogger("sip.loggerfactory"),Object.defineProperties(this,{builtinEnabled:{get:function(){return i},set:function(t){"boolean"==typeof t?i=t:e.error('invalid "builtinEnabled" parameter value: '+JSON.stringify(t))}},level:{get:function(){return t},set:function(i){i>=0&&i<=3?t=i:i>3?t=3:s.hasOwnProperty(i)?t=s[i]:e.error('invalid "level" parameter value: '+JSON.stringify(i))}},connector:{get:function(){return r},set:function(t){null===t||""===t||void 0===t?r=null:"function"==typeof t?r=t:e.error('invalid "connector" parameter value: '+JSON.stringify(t))}}})};return i.prototype.print=function(t,i,s,r){if("string"==typeof r){var n=[new Date,i];s&&n.push(s),r=n.concat(r).join(" | ")}t.call(e,r)},Object.keys(s).forEach(function(r){t.prototype[r]=function(e){this.logger[r](this.category,this.label,e)},i.prototype[r]=function(t,i,n){this.level>=s[r]&&(this.builtinEnabled&&this.print(e[r],t,i,n),this.connector&&this.connector(r,t,i,n))}}),i.prototype.getLogger=function(e,i){var s;return i&&3===this.level?new t(this,e,i):this.loggers[e]?this.loggers[e]:(s=new t(this,e),this.loggers[e]=s,s)},i}},function(e,t,i){"use strict";var s=i(7).EventEmitter;e.exports=function(){function e(){s.call(this)}return e.prototype=Object.create(s.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),e}},function(e,t){function i(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function s(e){return"function"==typeof e}function r(e){return"object"==typeof e&&null!==e}function n(e){return void 0===e}e.exports=i,i.EventEmitter=i,i.prototype._events=void 0,i.prototype._maxListeners=void 0,i.defaultMaxListeners=10,i.prototype.setMaxListeners=function(e){if(!function(e){return"number"==typeof e}(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},i.prototype.emit=function(e){var t,i,o,a,c,h;if(this._events||(this._events={}),"error"===e&&(!this._events.error||r(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var u=new Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}if(i=this._events[e],n(i))return!1;if(s(i))switch(arguments.length){case 1:i.call(this);break;case 2:i.call(this,arguments[1]);break;case 3:i.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),i.apply(this,a)}else if(r(i))for(a=Array.prototype.slice.call(arguments,1),o=(h=i.slice()).length,c=0;c<o;c++)h[c].apply(this,a);return!0},i.prototype.addListener=function(e,t){var o;if(!s(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,s(t.listener)?t.listener:t),this._events[e]?r(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,r(this._events[e])&&!this._events[e].warned&&(o=n(this._maxListeners)?i.defaultMaxListeners:this._maxListeners)&&o>0&&this._events[e].length>o&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},i.prototype.on=i.prototype.addListener,i.prototype.once=function(e,t){function i(){this.removeListener(e,i),r||(r=!0,t.apply(this,arguments))}if(!s(t))throw TypeError("listener must be a function");var r=!1;return i.listener=t,this.on(e,i),this},i.prototype.removeListener=function(e,t){var i,n,o,a;if(!s(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(i=this._events[e],o=i.length,n=-1,i===t||s(i.listener)&&i.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(r(i)){for(a=o;a-- >0;)if(i[a]===t||i[a].listener&&i[a].listener===t){n=a;break}if(n<0)return this;1===i.length?(i.length=0,delete this._events[e]):i.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},i.prototype.removeAllListeners=function(e){var t,i;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i=this._events[e],s(i))this.removeListener(e,i);else if(i)for(;i.length;)this.removeListener(e,i[i.length-1]);return delete this._events[e],this},i.prototype.listeners=function(e){return this._events&&this._events[e]?s(this._events[e])?[this._events[e]]:this._events[e].slice():[]},i.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(s(t))return 1;if(t)return t.length}return 0},i.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t,i){"use strict";e.exports=function(e,t){return{USER_AGENT:e+"/"+t,SIP:"sip",SIPS:"sips",causes:{CONNECTION_ERROR:"Connection Error",REQUEST_TIMEOUT:"Request Timeout",SIP_FAILURE_CODE:"SIP Failure Code",INTERNAL_ERROR:"Internal Error",BUSY:"Busy",REJECTED:"Rejected",REDIRECTED:"Redirected",UNAVAILABLE:"Unavailable",NOT_FOUND:"Not Found",ADDRESS_INCOMPLETE:"Address Incomplete",INCOMPATIBLE_SDP:"Incompatible SDP",AUTHENTICATION_ERROR:"Authentication Error",DIALOG_ERROR:"Dialog Error",WEBRTC_NOT_SUPPORTED:"WebRTC Not Supported",WEBRTC_ERROR:"WebRTC Error",CANCELED:"Canceled",NO_ANSWER:"No Answer",EXPIRES:"Expires",NO_ACK:"No ACK",NO_PRACK:"No PRACK",USER_DENIED_MEDIA_ACCESS:"User Denied Media Access",BAD_MEDIA_DESCRIPTION:"Bad Media Description",RTP_TIMEOUT:"RTP Timeout"},supported:{UNSUPPORTED:"none",SUPPORTED:"supported",REQUIRED:"required"},SIP_ERROR_CAUSES:{REDIRECTED:[300,301,302,305,380],BUSY:[486,600],REJECTED:[403,603],NOT_FOUND:[404,604],UNAVAILABLE:[480,410,408,430],ADDRESS_INCOMPLETE:[484],INCOMPATIBLE_SDP:[488,606],AUTHENTICATION_ERROR:[401,407]},ACK:"ACK",BYE:"BYE",CANCEL:"CANCEL",INFO:"INFO",INVITE:"INVITE",MESSAGE:"MESSAGE",NOTIFY:"NOTIFY",OPTIONS:"OPTIONS",REGISTER:"REGISTER",UPDATE:"UPDATE",SUBSCRIBE:"SUBSCRIBE",REFER:"REFER",PRACK:"PRACK",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"},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,t,i){"use strict";e.exports={ConfigurationError:function(){var e=function(e,t){this.code=1,this.name="CONFIGURATION_ERROR",this.parameter=e,this.value=t,this.message=this.value?"Invalid value "+JSON.stringify(this.value)+' for parameter "'+this.parameter+'"':"Missing parameter: "+this.parameter};return e.prototype=new Error,e}(),InvalidStateError:function(){var e=function(e){this.code=2,this.name="INVALID_STATE_ERROR",this.status=e,this.message="Invalid status: "+e};return e.prototype=new Error,e}(),NotSupportedError:function(){var e=function(e){this.code=3,this.name="NOT_SUPPORTED_ERROR",this.message=e};return e.prototype=new Error,e}(),GetDescriptionError:function(){var e=function(e){this.code=4,this.name="GET_DESCRIPTION_ERROR",this.message=e};return e.prototype=new Error,e}(),RenegotiationError:function(){var e=function(e){this.code=5,this.name="RENEGOTIATION_ERROR",this.message=e};return e.prototype=new Error,e}()}},function(e,t,i){"use strict";e.exports=function(e){var t={T1:500,T2:4e3,T4:5e3,TIMER_B:32e3,TIMER_D:0,TIMER_F:32e3,TIMER_H:32e3,TIMER_I:0,TIMER_J:0,TIMER_K:0,TIMER_L:32e3,TIMER_M:32e3,TIMER_N:32e3,PROVISIONAL_RESPONSE_INTERVAL:6e4};return["setTimeout","clearTimeout","setInterval","clearInterval"].forEach(function(i){t[i]=function(){return e[i].apply(e,arguments)}}),t}},function(e,t,i){"use strict";e.exports=function(e){function t(e,t){var i=t,s=0,r=0;if(e.substring(i,i+2).match(/(^\r\n)/))return-2;for(;0===s;){if(-1===(r=e.indexOf("\r\n",i)))return r;!e.substring(r+2,r+4).match(/(^\r\n)/)&&e.charAt(r+2).match(/(^\s+)/)?i=r+2:s=r}return s}function i(t,i,s,r){var n,o,a,c,h=i.indexOf(":",s),u=i.substring(s,h).trim(),l=i.substring(h+1,r).trim();switch(u.toLowerCase()){case"via":case"v":t.addHeader("via",l),1===t.getHeaders("via").length?(c=t.parseHeader("Via"))&&(t.via=c,t.via_branch=c.branch):c=0;break;case"from":case"f":t.setHeader("from",l),(c=t.parseHeader("from"))&&(t.from=c,t.from_tag=c.getParam("tag"));break;case"to":case"t":t.setHeader("to",l),(c=t.parseHeader("to"))&&(t.to=c,t.to_tag=c.getParam("tag"));break;case"record-route":if(-1===(c=e.Grammar.parse(l,"Record_Route"))){c=void 0;break}for(a=c.length,o=0;o<a;o++)n=c[o],t.addHeader("record-route",l.substring(n.position,n.offset)),t.headers["Record-Route"][t.getHeaders("record-route").length-1].parsed=n.parsed;break;case"call-id":case"i":t.setHeader("call-id",l),(c=t.parseHeader("call-id"))&&(t.call_id=l);break;case"contact":case"m":if(-1===(c=e.Grammar.parse(l,"Contact"))){c=void 0;break}for(a=c.length,o=0;o<a;o++)n=c[o],t.addHeader("contact",l.substring(n.position,n.offset)),t.headers.Contact[t.getHeaders("contact").length-1].parsed=n.parsed;break;case"content-length":case"l":t.setHeader("content-length",l),c=t.parseHeader("content-length");break;case"content-type":case"c":t.setHeader("content-type",l),c=t.parseHeader("content-type");break;case"cseq":t.setHeader("cseq",l),(c=t.parseHeader("cseq"))&&(t.cseq=c.value),t instanceof e.IncomingResponse&&(t.method=c.method);break;case"max-forwards":t.setHeader("max-forwards",l),c=t.parseHeader("max-forwards");break;case"www-authenticate":t.setHeader("www-authenticate",l),c=t.parseHeader("www-authenticate");break;case"proxy-authenticate":t.setHeader("proxy-authenticate",l),c=t.parseHeader("proxy-authenticate");break;case"refer-to":case"r":t.setHeader("refer-to",l),(c=t.parseHeader("refer-to"))&&(t.refer_to=c);break;default:t.setHeader(u,l),c=0}return void 0!==c||{error:'error parsing header "'+u+'"'}}var s;(s={}).parseMessage=function(s,r){var n,o,a,c,h,u=0,l=s.indexOf("\r\n"),d=r.getLogger("sip.parser");if(-1!==l){if(o=s.substring(0,l),-1!==(h=e.Grammar.parse(o,"Request_Response"))){for(h.status_code?((n=new e.IncomingResponse(r)).status_code=h.status_code,n.reason_phrase=h.reason_phrase):((n=new e.IncomingRequest(r)).method=h.method,n.ruri=h.uri),n.data=s,u=l+2;;){if(-2===(l=t(s,u))){c=u+2;break}if(-1===l)return void d.error("malformed message");if(!0!==(h=i(n,s,u,l)))return void d.error(h.error);u=l+2}return n.hasHeader("content-length")?(a=n.getHeader("content-length"),n.body=s.substr(c,a)):n.body=s.substring(c),n}d.warn('error parsing first line of SIP message: "'+o+'"')}else d.warn("no CRLF found, not a SIP message, discarded")},e.Parser=s}},function(e,t,i){"use strict";e.exports=function(e){function t(t){var i=t.ua.configuration.hackAllowUnregisteredOptionTags,s=[],r={};return t.method===e.C.REGISTER?s.push("path","gruu"):t.method===e.C.INVITE&&(t.ua.contact.pub_gruu||t.ua.contact.temp_gruu)&&s.push("gruu"),t.ua.configuration.rel100===e.C.supported.SUPPORTED&&s.push("100rel"),t.ua.configuration.replaces===e.C.supported.SUPPORTED&&s.push("replaces"),s.push("outbound"),s=s.concat(t.ua.configuration.extraSupported),"Supported: "+(s=s.filter(function(t){var s=e.C.OPTION_TAGS[t],n=!r[t];return r[t]=!0,(s||i)&&n})).join(", ")+"\r\n"}var i,s,r,n;(i=function(t,i,s,r,n,o){var a,c,h,u,l,d;if(r=r||{},!t||!i||!s)return null;this.logger=s.getLogger("sip.sipmessage"),this.ua=s,this.headers={},this.method=t,this.ruri=i,this.body=o,this.extraHeaders=(n||[]).slice(),this.statusCode=r.status_code,this.reasonPhrase=r.reason_phrase,r.route_set?this.setHeader("route",r.route_set):s.configuration.usePreloadedRoute&&this.setHeader("route",s.transport.server.sip_uri),this.setHeader("via",""),this.setHeader("max-forwards",e.UA.C.MAX_FORWARDS),l=r.to_uri||i,a=r.to_displayName||0===r.to_displayName?'"'+r.to_displayName+'" ':"",a+="<"+(l&&l.toRaw?l.toRaw():l)+">",a+=r.to_tag?";tag="+r.to_tag:"",this.to=new e.NameAddrHeader.parse(a),this.setHeader("to",a),d=r.from_uri||s.configuration.uri,c=r.from_displayName||0===r.from_displayName?'"'+r.from_displayName+'" ':s.configuration.displayName?'"'+s.configuration.displayName+'" ':"",c+="<"+(d&&d.toRaw?d.toRaw():d)+">;tag=",c+=r.from_tag||e.Utils.newTag(),this.from=new e.NameAddrHeader.parse(c),this.setHeader("from",c),h=r.call_id||s.configuration.sipjsId+e.Utils.createRandomToken(15),this.call_id=h,this.setHeader("call-id",h),u=r.cseq||Math.floor(1e4*Math.random()),this.cseq=u,this.setHeader("cseq",u+" "+t)}).prototype={setHeader:function(t,i){this.headers[e.Utils.headerize(t)]=i instanceof Array?i:[i]},getHeader:function(t){var i,s,r=this.extraHeaders.length,n=this.headers[e.Utils.headerize(t)];if(n){if(n[0])return n[0]}else for(i=new RegExp("^\\s*"+t+"\\s*:","i"),s=0;s<r;s++)if(n=this.extraHeaders[s],i.test(n))return n.substring(n.indexOf(":")+1).trim()},getHeaders:function(t){var i,s,r,n=this.headers[e.Utils.headerize(t)],o=[];if(n){for(s=n.length,i=0;i<s;i++)o.push(n[i]);return o}for(s=this.extraHeaders.length,r=new RegExp("^\\s*"+t+"\\s*:","i"),i=0;i<s;i++)n=this.extraHeaders[i],r.test(n)&&o.push(n.substring(n.indexOf(":")+1).trim());return o},hasHeader:function(t){var i,s,r=this.extraHeaders.length;if(this.headers[e.Utils.headerize(t)])return!0;for(i=new RegExp("^\\s*"+t+"\\s*:","i"),s=0;s<r;s++)if(i.test(this.extraHeaders[s]))return!0;return!1},toString:function(){var i,s,r,n="";n+=this.method+" "+(this.ruri.toRaw?this.ruri.toRaw():this.ruri)+" SIP/2.0\r\n";for(i in this.headers)for(s=this.headers[i].length,r=0;r<s;r++)n+=i+": "+this.headers[i][r]+"\r\n";for(s=this.extraHeaders.length,r=0;r<s;r++)n+=this.extraHeaders[r].trim()+"\r\n";return n+=t(this),n+="User-Agent: "+this.ua.configuration.userAgentString+"\r\n",this.body?"string"==typeof this.body?(n+="Content-Length: "+(s=e.Utils.str_utf8_length(this.body))+"\r\n\r\n",n+=this.body):this.body.body&&this.body.contentType?(s=e.Utils.str_utf8_length(this.body.body),n+="Content-Type: "+this.body.contentType+"\r\n",n+="Content-Length: "+s+"\r\n\r\n",n+=this.body.body):n+="Content-Length: 0\r\n\r\n":n+="Content-Length: 0\r\n\r\n",n}},(s=function(){this.data=null,this.headers=null,this.method=null,this.via=null,this.via_branch=null,this.call_id=null,this.cseq=null,this.from=null,this.from_tag=null,this.to=null,this.to_tag=null,this.body=null}).prototype={addHeader:function(t,i){var s={raw:i};t=e.Utils.headerize(t),this.headers[t]?this.headers[t].push(s):this.headers[t]=[s]},getHeader:function(t){var i=this.headers[e.Utils.headerize(t)];if(i)return i[0]?i[0].raw:void 0},getHeaders:function(t){var i,s,r=this.headers[e.Utils.headerize(t)],n=[];if(!r)return[];for(s=r.length,i=0;i<s;i++)n.push(r[i].raw);return n},hasHeader:function(t){return!!this.headers[e.Utils.headerize(t)]},parseHeader:function(t,i){var s,r,n;if(t=e.Utils.headerize(t),i=i||0,this.headers[t]){if(!(i>=this.headers[t].length))return s=this.headers[t][i],r=s.raw,s.parsed?s.parsed:-1===(n=e.Grammar.parse(r,t.replace(/-/g,"_")))?(this.headers[t].splice(i,1),void this.logger.warn('error parsing "'+t+'" header field with value "'+r+'"')):(s.parsed=n,n);this.logger.log('not so many "'+t+'" headers present')}else this.logger.log('header "'+t+'" not present')},s:function(e,t){return this.parseHeader(e,t)},setHeader:function(t,i){var s={raw:i};this.headers[e.Utils.headerize(t)]=[s]},toString:function(){return this.data}},((r=function(e){this.logger=e.getLogger("sip.sipmessage"),this.ua=e,this.headers={},this.ruri=null,this.transport=null,this.server_transaction=null}).prototype=new s).reply=function(i,s,r,n,o,a){var c,h,u,l,d,p=this.getHeader("To"),g=0,f=0;if(d=e.Utils.buildStatusLine(i,s),r=(r||[]).slice(),this.method===e.C.INVITE&&i>100&&i<=200)for(u=(c=this.getHeaders("record-route")).length;g<u;g++)d+="Record-Route: "+c[g]+"\r\n";for(u=(h=this.getHeaders("via")).length;f<u;f++)d+="Via: "+h[f]+"\r\n";for(!this.to_tag&&i>100?p+=";tag="+e.Utils.newTag():this.to_tag&&!this.s("to").hasParam("tag")&&(p+=";tag="+this.to_tag),d+="To: "+p+"\r\n",d+="From: "+this.getHeader("From")+"\r\n",d+="Call-ID: "+this.call_id+"\r\n",d+="CSeq: "+this.cseq+" "+this.method+"\r\n",u=r.length,l=0;l<u;l++)d+=r[l].trim()+"\r\n";return d+=t(this),d+="User-Agent: "+this.ua.configuration.userAgentString+"\r\n",n?"string"==typeof n?(d+="Content-Type: application/sdp\r\n",d+="Content-Length: "+(u=e.Utils.str_utf8_length(n))+"\r\n\r\n",d+=n):n.body&&n.contentType?(u=e.Utils.str_utf8_length(n.body),d+="Content-Type: "+n.contentType+"\r\n",d+="Content-Length: "+u+"\r\n\r\n",d+=n.body):d+="Content-Length: 0\r\n\r\n":d+="Content-Length: 0\r\n\r\n",this.server_transaction.receiveResponse(i,d).then(o,a),d},r.prototype.reply_sl=function(t,i){var s,r,n=0,o=this.getHeaders("via"),a=o.length;for(r=e.Utils.buildStatusLine(t,i);n<a;n++)r+="Via: "+o[n]+"\r\n";s=this.getHeader("To"),!this.to_tag&&t>100?s+=";tag="+e.Utils.newTag():this.to_tag&&!this.s("to").hasParam("tag")&&(s+=";tag="+this.to_tag),r+="To: "+s+"\r\n",r+="From: "+this.getHeader("From")+"\r\n",r+="Call-ID: "+this.call_id+"\r\n",r+="CSeq: "+this.cseq+" "+this.method+"\r\n",r+="User-Agent: "+this.ua.configuration.userAgentString+"\r\n",r+="Content-Length: 0\r\n\r\n",this.transport.send(r)},(n=function(e){this.logger=e.getLogger("sip.sipmessage"),this.headers={},this.status_code=null,this.reason_phrase=null}).prototype=new s,e.OutgoingRequest=i,e.IncomingRequest=r,e.IncomingResponse=n}},function(e,t,i){"use strict";e.exports=function(e){var t;(t=function(t,i,s,r,n,o){var a,c,h,u;if(!s)throw new TypeError('missing or invalid "host" parameter');t=t||e.C.SIP,this.parameters={},this.headers={};for(a in n)this.setParam(a,n[a]);for(c in o)this.setHeader(c,o[c]);h={scheme:t,user:i,host:s,port:r},u={scheme:t.toLowerCase(),user:i,host:s.toLowerCase(),port:r},Object.defineProperties(this,{_normal:{get:function(){return u}},_raw:{get:function(){return h}},scheme:{get:function(){return u.scheme},set:function(e){h.scheme=e,u.scheme=e.toLowerCase()}},user:{get:function(){return u.user},set:function(e){u.user=h.user=e}},host:{get:function(){return u.host},set:function(e){h.host=e,u.host=e.toLowerCase()}},aor:{get:function(){return u.user+"@"+u.host}},port:{get:function(){return u.port},set:function(e){u.port=h.port=0===e?e:parseInt(e,10)||null}}})}).prototype={setParam:function(e,t){e&&(this.parameters[e.toLowerCase()]=void 0===t||null===t?null:t.toString().toLowerCase())},getParam:function(e){if(e)return this.parameters[e.toLowerCase()]},hasParam:function(e){if(e)return!!this.parameters.hasOwnProperty(e.toLowerCase())},deleteParam:function(e){var t;if(e=e.toLowerCase(),this.parameters.hasOwnProperty(e))return t=this.parameters[e],delete this.parameters[e],t},clearParams:function(){this.parameters={}},setHeader:function(t,i){this.headers[e.Utils.headerize(t)]=i instanceof Array?i:[i]},getHeader:function(t){if(t)return this.headers[e.Utils.headerize(t)]},hasHeader:function(t){if(t)return!!this.headers.hasOwnProperty(e.Utils.headerize(t))},deleteHeader:function(t){var i;if(t=e.Utils.headerize(t),this.headers.hasOwnProperty(t))return i=this.headers[t],delete this.headers[t],i},clearHeaders:function(){this.headers={}},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)))},toRaw:function(){return this._toString(this._raw)},toString:function(){return this._toString(this._normal)},_toString:function(t){var i,s,r,n,o=[];n=t.scheme+":",t.scheme.toLowerCase().match("^sips?$")||(n+="//"),t.user&&(n+=e.Utils.escapeUser(t.user)+"@"),n+=t.host,(t.port||0===t.port)&&(n+=":"+t.port);for(s in this.parameters)n+=";"+s,null!==this.parameters[s]&&(n+="="+this.parameters[s]);for(i in this.headers)for(r in this.headers[i])o.push(i+"="+this.headers[i][r]);return o.length>0&&(n+="?"+o.join("&")),n}},t.parse=function(t){return-1!==(t=e.Grammar.parse(t,"SIP_URI"))?t:void 0},e.URI=t}},function(e,t,i){"use strict";e.exports=function(e){var t;(t=function(t,i,s){var r;if(!(t&&t instanceof e.URI))throw new TypeError('missing or invalid "uri" parameter');this.uri=t,this.parameters={};for(r in s)this.setParam(r,s[r]);Object.defineProperties(this,{friendlyName:{get:function(){return this.displayName||t.aor}},displayName:{get:function(){return i},set:function(e){i=0===e?"0":e}}})}).prototype={setParam:function(e,t){e&&(this.parameters[e.toLowerCase()]=void 0===t||null===t?null:t.toString())},getParam:e.URI.prototype.getParam,hasParam:e.URI.prototype.hasParam,deleteParam:e.URI.prototype.deleteParam,clearParams:e.URI.prototype.clearParams,clone:function(){return new t(this.uri.clone(),this.displayName,JSON.parse(JSON.stringify(this.parameters)))},toString:function(){var e,t;e=this.displayName||0===this.displayName?'"'+this.displayName+'" ':"",e+="<"+this.uri.toString()+">";for(t in this.parameters)e+=";"+t,null!==this.parameters[t]&&(e+="="+this.parameters[t]);return e}},t.parse=function(t){return-1!==(t=e.Grammar.parse(t,"Name_Addr_Header"))?t:void 0},e.NameAddrHeader=t}},function(e,t,i){"use strict";e.exports=function(e){function t(e,t,i){var s;return s="SIP/2.0/"+(e.ua.configuration.hackViaTcp?"TCP":t.server.scheme),s+=" "+e.ua.configuration.viaHost+";branch="+i,e.ua.configuration.forceRport&&(s+=";rport"),s}var i={STATUS_TRYING:1,STATUS_PROCEEDING:2,STATUS_CALLING:3,STATUS_ACCEPTED:4,STATUS_COMPLETED:5,STATUS_TERMINATED:6,STATUS_CONFIRMED:7,NON_INVITE_CLIENT:"nict",NON_INVITE_SERVER:"nist",INVITE_CLIENT:"ict",INVITE_SERVER:"ist"},s=function(e,s,r){var n;this.type=i.NON_INVITE_CLIENT,this.transport=r,this.id="z9hG4bK"+Math.floor(1e7*Math.random()),this.request_sender=e,this.request=s,this.logger=e.ua.getLogger("sip.transaction.nict",this.id),n=t(e,r,this.id),this.request.setHeader("via",n),this.request_sender.ua.newTransaction(this)};(s.prototype=Object.create(e.EventEmitter.prototype)).stateChanged=function(e){this.state=e,this.emit("stateChanged")},s.prototype.send=function(){this.stateChanged(i.STATUS_TRYING),this.F=e.Timers.setTimeout(this.timer_F.bind(this),e.Timers.TIMER_F),this.transport.send(this.request)||this.onTransportError()},s.prototype.onTransportError=function(){this.logger.log("transport error occurred, deleting non-INVITE client transaction "+this.id),e.Timers.clearTimeout(this.F),e.Timers.clearTimeout(this.K),this.stateChanged(i.STATUS_TERMINATED),this.request_sender.ua.destroyTransaction(this),this.request_sender.onTransportError()},s.prototype.timer_F=function(){this.logger.debug("Timer F expired for non-INVITE client transaction "+this.id),this.stateChanged(i.STATUS_TERMINATED),this.request_sender.ua.destroyTransaction(this),this.request_sender.onRequestTimeout()},s.prototype.timer_K=function(){this.stateChanged(i.STATUS_TERMINATED),this.request_sender.ua.destroyTransaction(this)},s.prototype.receiveResponse=function(t){var s=t.status_code;if(s<200)switch(this.state){case i.STATUS_TRYING:case i.STATUS_PROCEEDING:this.stateChanged(i.STATUS_PROCEEDING),this.request_sender.receiveResponse(t)}else switch(this.state){case i.STATUS_TRYING:case i.STATUS_PROCEEDING:this.stateChanged(i.STATUS_COMPLETED),e.Timers.clearTimeout(this.F),408===s?this.request_sender.onRequestTimeout():this.request_sender.receiveResponse(t),this.K=e.Timers.setTimeout(this.timer_K.bind(this),e.Timers.TIMER_K)}};var r=function(e,s,r){var n,o=this;this.type=i.INVITE_CLIENT,this.transport=r,this.id="z9hG4bK"+Math.floor(1e7*Math.random()),this.request_sender=e,this.request=s,this.logger=e.ua.getLogger("sip.transaction.ict",this.id),n=t(e,r,this.id),this.request.setHeader("via",n),this.request_sender.ua.newTransaction(this),this.request.cancel=function(e,t){for(var i=(t=(t||[]).slice()).length,s=null,r=0;r<i;r++)s=(s||"")+t[r].trim()+"\r\n";o.cancel_request(o,e,s)}};(r.prototype=Object.create(e.EventEmitter.prototype)).stateChanged=function(e){this.state=e,this.emit("stateChanged")},r.prototype.send=function(){this.stateChanged(i.STATUS_CALLING),this.B=e.Timers.setTimeout(this.timer_B.bind(this),e.Timers.TIMER_B),this.transport.send(this.request)||this.onTransportError()},r.prototype.onTransportError=function(){this.logger.log("transport error occurred, deleting INVITE client transaction "+this.id),e.Timers.clearTimeout(this.B),e.Timers.clearTimeout(this.D),e.Timers.clearTimeout(this.M),this.stateChanged(i.STATUS_TERMINATED),this.request_sender.ua.destroyTransaction(this),this.state!==i.STATUS_ACCEPTED&&this.request_sender.onTransportError()},r.prototype.timer_M=function(){this.logger.debug("Timer M expired for INVITE client transaction "+this.id),this.state===i.STATUS_ACCEPTED&&(e.Timers.clearTimeout(this.B),this.stateChanged(i.STATUS_TERMINATED),this.request_sender.ua.destroyTransaction(this))},r.prototype.timer_B=function(){this.logger.debug("Timer B expired for INVITE client transaction "+this.id),this.state===i.STATUS_CALLING&&(this.stateChanged(i.STATUS_TERMINATED),this.request_sender.ua.destroyTransaction(this),this.request_sender.onRequestTimeout())},r.prototype.timer_D=function(){this.logger.debug("Timer D expired for INVITE client transaction "+this.id),e.Timers.clearTimeout(this.B),this.stateChanged(i.STATUS_TERMINATED),this.request_sender.ua.destroyTransaction(this)},r.prototype.sendACK=function(t){var i,s=this;t=t||{},i=this.response.getHeader("contact")?this.response.parseHeader("contact").uri:this.request.ruri;var r=new e.OutgoingRequest("ACK",i,this.request.ua,{cseq:this.response.cseq,call_id:this.response.call_id,from_uri:this.response.from.uri,from_tag:this.response.from_tag,to_uri:this.response.to.uri,to_tag:this.response.to_tag,route_set:this.response.getHeaders("record-route").reverse()},t.extraHeaders||[],t.body);return this.ackSender=new e.RequestSender({request:r,onRequestTimeout:this.request_sender.applicant.applicant?this.request_sender.applicant.applicant.onRequestTimeout:function(){s.logger.warn("ACK Request timed out")},onTransportError:this.request_sender.applicant.applicant?this.request_sender.applicant.applicant.onRequestTransportError:function(){s.loigger.warn("ACK Request had a transport error")},receiveResponse:t.receiveResponse||function(){s.logger.warn("Received a response to an ACK which was unexpected. Dropping Response.")}},this.request.ua).send(),r},r.prototype.cancel_request=function(t,s,r){var n=t.request;this.cancel=e.C.CANCEL+" "+n.ruri+" SIP/2.0\r\n",this.cancel+="Via: "+n.headers.Via.toString()+"\r\n",this.request.headers.Route&&(this.cancel+="Route: "+n.headers.Route.toString()+"\r\n"),this.cancel+="To: "+n.headers.To.toString()+"\r\n",this.cancel+="From: "+n.headers.From.toString()+"\r\n",this.cancel+="Call-ID: "+n.headers["Call-ID"].toString()+"\r\n",this.cancel+="CSeq: "+n.headers.CSeq.toString().split(" ")[0]+" CANCEL\r\n",s&&(this.cancel+="Reason: "+s+"\r\n"),r&&(this.cancel+=r),this.cancel+="Content-Length: 0\r\n\r\n",this.state===i.STATUS_PROCEEDING&&this.transport.send(this.cancel)},r.prototype.receiveResponse=function(t){var s=t.status_code;if(t.transaction=this,this.response&&this.response.status_code===t.status_code&&this.response.cseq===t.cseq)return this.logger.debug("ICT Received a retransmission for cseq: "+t.cseq),void(this.ackSender&&this.ackSender.send());if(this.response=t,s>=100&&s<=199)switch(this.state){case i.STATUS_CALLING:this.stateChanged(i.STATUS_PROCEEDING),this.request_sender.receiveResponse(t),this.cancel&&this.transport.send(this.cancel);break;case i.STATUS_PROCEEDING:this.request_sender.receiveResponse(t)}else if(s>=200&&s<=299)switch(this.state){case i.STATUS_CALLING:case i.STATUS_PROCEEDING:this.stateChanged(i.STATUS_ACCEPTED),this.M=e.Timers.setTimeout(this.timer_M.bind(this),e.Timers.TIMER_M),this.request_sender.receiveResponse(t);break;case i.STATUS_ACCEPTED:this.request_sender.receiveResponse(t)}else if(s>=300&&s<=699)switch(this.state){case i.STATUS_CALLING:case i.STATUS_PROCEEDING:this.stateChanged(i.STATUS_COMPLETED),this.sendACK(),this.request_sender.receiveResponse(t);break;case i.STATUS_COMPLETED:this.sendACK()}};var n=function(e,i,s){var r;this.transport=s,this.id="z9hG4bK"+Math.floor(1e7*Math.random()),this.request_sender=e,this.request=i,this.logger=e.ua.getLogger("sip.transaction.nict",this.id),r=t(e,s,this.id),this.request.setHeader("via",r)};(n.prototype=Object.create(e.EventEmitter.prototype)).send=function(){this.transport.send(this.request)||this.onTransportError()},n.prototype.onTransportError=function(){this.logger.log("transport error occurred, for an ACK client transaction "+this.id),this.request_sender.onTransportError()};var o=function(e,t){this.type=i.NON_INVITE_SERVER,this.id=e.via_branch,this.request=e,this.transport=e.transport,this.ua=t,this.last_response="",e.server_transaction=this,this.logger=t.getLogger("sip.transaction.nist",this.id),this.state=i.STATUS_TRYING,t.newTransaction(this)};(o.prototype=Object.create(e.EventEmitter.prototype)).stateChanged=function(e){this.state=e,this.emit("stateChanged")},o.prototype.timer_J=function(){this.logger.debug("Timer J expired for non-INVITE server transaction "+this.id),this.stateChanged(i.STATUS_TERMINATED),this.ua.destroyTransaction(this)},o.prototype.onTransportError=function(){this.transportError||(this.transportError=!0,this.logger.log("transport error occurred, deleting non-INVITE server transaction "+this.id),e.Timers.clearTimeout(this.J),this.stateChanged(i.STATUS_TERMINATED),this.ua.destroyTransaction(this))},o.prototype.receiveResponse=function(t,s){var r=e.Utils.defer();if(100===t)switch(this.state){case i.STATUS_TRYING:this.stateChanged(i.STATUS_PROCEEDING),this.transport.send(s)||this.onTransportError();break;case i.STATUS_PROCEEDING:this.last_response=s,this.transport.send(s)?r.resolve():(this.onTransportError(),r.reject())}else if(t>=200&&t<=699)switch(this.state){case i.STATUS_TRYING:case i.STATUS_PROCEEDING:this.stateChanged(i.STATUS_COMPLETED),this.last_response=s,this.J=e.Timers.setTimeout(this.timer_J.bind(this),e.Timers.TIMER_J),this.transport.send(s)?r.resolve():(this.onTransportError(),r.reject())}return r.promise};var a=function(e,t){this.type=i.INVITE_SERVER,this.id=e.via_branch,this.request=e,this.transport=e.transport,this.ua=t,this.last_response="",e.server_transaction=this,this.logger=t.getLogger("sip.transaction.ist",this.id),this.state=i.STATUS_PROCEEDING,t.newTransaction(this),this.resendProvisionalTimer=null,e.reply(100)};(a.prototype=Object.create(e.EventEmitter.prototype)).stateChanged=function(e){this.state=e,this.emit("stateChanged")},a.prototype.timer_H=function(){this.logger.debug("Timer H expired for INVITE server transaction "+this.id),this.state===i.STATUS_COMPLETED&&this.logger.warn("transactions","ACK for INVITE server transaction was never received, call will be terminated"),this.stateChanged(i.STATUS_TERMINATED),this.ua.destroyTransaction(this)},a.prototype.timer_I=function(){this.stateChanged(i.STATUS_TERMINATED),this.ua.destroyTransaction(this)},a.prototype.timer_L=function(){this.logger.debug("Timer L expired for INVITE server transaction "+this.id),this.state===i.STATUS_ACCEPTED&&(this.stateChanged(i.STATUS_TERMINATED),this.ua.destroyTransaction(this))},a.prototype.onTransportError=function(){this.transportError||(this.transportError=!0,this.logger.log("transport error occurred, deleting INVITE server transaction "+this.id),null!==this.resendProvisionalTimer&&(e.Timers.clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),e.Timers.clearTimeout(this.L),e.Timers.clearTimeout(this.H),e.Timers.clearTimeout(this.I),this.stateChanged(i.STATUS_TERMINATED),this.ua.destroyTransaction(this))},a.prototype.resend_provisional=function(){this.transport.send(this.last_response)||this.onTransportError()},a.prototype.receiveResponse=function(t,s){var r=e.Utils.defer();if(t>=100&&t<=199)switch(this.state){case i.STATUS_PROCEEDING:this.transport.send(s)||this.onTransportError(),this.last_response=s}if(t>100&&t<=199&&this.state===i.STATUS_PROCEEDING)null===this.resendProvisionalTimer&&(this.resendProvisionalTimer=e.Timers.setInterval(this.resend_provisional.bind(this),e.Timers.PROVISIONAL_RESPONSE_INTERVAL));else if(t>=200&&t<=299)switch(this.state){case i.STATUS_PROCEEDING:this.stateChanged(i.STATUS_ACCEPTED),this.last_response=s,this.L=e.Timers.setTimeout(this.timer_L.bind(this),e.Timers.TIMER_L),null!==this.resendProvisionalTimer&&(e.Timers.clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case i.STATUS_ACCEPTED:this.transport.send(s)?r.resolve():(this.onTransportError(),r.reject())}else if(t>=300&&t<=699)switch(this.state){case i.STATUS_PROCEEDING:null!==this.resendProvisionalTimer&&(e.Timers.clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(s)?(this.stateChanged(i.STATUS_COMPLETED),this.H=e.Timers.setTimeout(this.timer_H.bind(this),e.Timers.TIMER_H),r.resolve()):(this.onTransportError(),r.reject())}return r.promise};e.Transactions={C:i,checkTransaction:function(t,s){var r;switch(s.method){case e.C.INVITE:if(r=t.transactions.ist[s.via_branch]){switch(r.state){case i.STATUS_PROCEEDING:r.transport.send(r.last_response)}return!0}break;case e.C.ACK:if(!(r=t.transactions.ist[s.via_branch]))return!1;if(r.state===i.STATUS_ACCEPTED)return!1;if(r.state===i.STATUS_COMPLETED)return r.stateChanged(i.STATUS_CONFIRMED),r.I=e.Timers.setTimeout(r.timer_I.bind(r),e.Timers.TIMER_I),!0;break;case e.C.CANCEL:return(r=t.transactions.ist[s.via_branch])?(s.reply_sl(200),r.state!==i.STATUS_PROCEEDING):(s.reply_sl(481),!0);default:if(r=t.transactions.nist[s.via_branch]){switch(r.state){case i.STATUS_TRYING:break;case i.STATUS_PROCEEDING:case i.STATUS_COMPLETED:r.transport.send(r.last_response)}return!0}}},NonInviteClientTransaction:s,InviteClientTransaction:r,AckClientTransaction:n,NonInviteServerTransaction:o,InviteServerTransaction:a}}},function(e,t,i){"use strict";e.exports=function(e){var t,s=i(17)(e),r={STATUS_EARLY:1,STATUS_CONFIRMED:2};(t=function(t,i,s,n){var o;if(this.uac_pending_reply=!1,this.uas_pending_reply=!1,!i.hasHeader("contact"))return{error:"unable to create a Dialog without Contact header field"};n=i instanceof e.IncomingResponse?i.status_code<200?r.STATUS_EARLY:r.STATUS_CONFIRMED:n||r.STATUS_CONFIRMED,o=i.parseHeader("contact"),"UAS"===s?(this.id={call_id:i.call_id,local_tag:i.to_tag,remote_tag:i.from_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this.state=n,this.remote_seqnum=i.cseq,this.local_uri=i.parseHeader("to").uri,this.remote_uri=i.parseHeader("from").uri,this.remote_target=o.uri,this.route_set=i.getHeaders("record-route"),this.invite_seqnum=i.cseq,this.local_seqnum=i.cseq):"UAC"===s&&(this.id={call_id:i.call_id,local_tag:i.from_tag,remote_tag:i.to_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this.state=n,this.invite_seqnum=i.cseq,this.local_seqnum=i.cseq,this.local_uri=i.parseHeader("from").uri,this.pracked=[],this.remote_uri=i.parseHeader("to").uri,this.remote_target=o.uri,this.route_set=i.getHeaders("record-route").reverse()),this.logger=t.ua.getLogger("sip.dialog",this.id.toString()),this.owner=t,t.ua.dialogs[this.id.toString()]=this,this.logger.log("new "+s+" dialog created with status "+(this.state===r.STATUS_EARLY?"EARLY":"CONFIRMED")),t.emit("dialog",this)}).prototype={update:function(e,t){this.state=r.STATUS_CONFIRMED,this.logger.log("dialog "+this.id.toString()+" changed to CONFIRMED state"),"UAC"===t&&(this.route_set=e.getHeaders("record-route").reverse())},terminate:function(){this.logger.log("dialog "+this.id.toString()+" deleted"),this.sessionDescriptionHandler&&this.state!==r.STATUS_CONFIRMED&&this.sessionDescriptionHandler.close(),delete this.owner.ua.dialogs[this.id.toString()]},createRequest:function(t,i,s){var r,n;return i=(i||[]).slice(),this.local_seqnum||(this.local_seqnum=Math.floor(1e4*Math.random())),r=t===e.C.CANCEL||t===e.C.ACK?this.invite_seqnum:this.local_seqnum+=1,n=new e.OutgoingRequest(t,this.remote_target,this.owner.ua,{cseq:r,call_id:this.id.call_id,from_uri:this.local_uri,from_tag:this.id.local_tag,to_uri:this.remote_uri,to_tag:this.id.remote_tag,route_set:this.route_set},i,s),n.dialog=this,n},checkInDialogRequest:function(t){var i=this;if(this.remote_seqnum){if(t.cseq<this.remote_seqnum)return t.method!==e.C.ACK&&t.reply(500),t.cseq===this.invite_seqnum}else this.remote_seqnum=t.cseq;switch(t.method){case e.C.INVITE:if(!0===this.uac_pending_reply)t.reply(491);else{if(!0===this.uas_pending_reply&&t.cseq>this.remote_seqnum){var s=1+(10*Math.random()|0);return t.reply(500,null,["Retry-After:"+s]),this.remote_seqnum=t.cseq,!1}this.uas_pending_reply=!0,t.server_transaction.on("stateChanged",function t(){this.state!==e.Transactions.C.STATUS_ACCEPTED&&this.state!==e.Transactions.C.STATUS_COMPLETED&&this.state!==e.Transactions.C.STATUS_TERMINATED||(this.removeListener("stateChanged",t),i.uas_pending_reply=!1)})}t.hasHeader("contact")&&t.server_transaction.on("stateChanged",function(){this.state===e.Transactions.C.STATUS_ACCEPTED&&(i.remote_target=t.parseHeader("contact").uri)});break;case e.C.NOTIFY:t.hasHeader("contact")&&t.server_transaction.on("stateChanged",function(){this.state===e.Transactions.C.STATUS_COMPLETED&&(i.remote_target=t.parseHeader("contact").uri)})}return t.cseq>this.remote_seqnum&&(this.remote_seqnum=t.cseq),!0},sendRequest:function(e,t,i){var r=((i=i||{}).extraHeaders||[]).slice(),n=null;i.body&&(i.body.body?n=i.body:((n={}).body=i.body,i.contentType&&(n.contentType=i.contentType)));var o=this.createRequest(t,r,n);return new s(this,e,o).send(),o},receiveRequest:function(e){this.checkInDialogRequest(e)&&this.owner.receiveRequest(e)}},t.C=r,e.Dialog=t}},function(e,t,i){"use strict";e.exports=function(e){var t;return t=function(e,t,i){this.dialog=e,this.applicant=t,this.request=i,this.reattempt=!1,this.reattemptTimer=null},t.prototype={send:function(){var t=this,i=new e.RequestSender(this,this.dialog.owner.ua);i.send(),this.request.method===e.C.INVITE&&i.clientTransaction.state!==e.Transactions.C.STATUS_TERMINATED&&(this.dialog.uac_pending_reply=!0,i.clientTransaction.on("stateChanged",function i(){this.state!==e.Transactions.C.STATUS_ACCEPTED&&this.state!==e.Transactions.C.STATUS_COMPLETED&&this.state!==e.Transactions.C.STATUS_TERMINATED||(this.removeListener("stateChanged",i),t.dialog.uac_pending_reply=!1)}))},onRequestTimeout:function(){this.applicant.onRequestTimeout()},onTransportError:function(){this.applicant.onTransportError()},receiveResponse:function(t){var i=this;408===t.status_code||481===t.status_code?this.applicant.onDialogError(t):t.method===e.C.INVITE&&491===t.status_code?this.reattempt?this.applicant.receiveResponse(t):(this.request.cseq.value=this.dialog.local_seqnum+=1,this.reattemptTimer=e.Timers.setTimeout(function(){i.applicant.owner.status!==e.Session.C.STATUS_TERMINATED&&(i.reattempt=!0,i.request_sender.send())},this.getReattemptTimeout())):this.applicant.receiveResponse(t)}},t}},function(e,t,i){"use strict";e.exports=function(e){var t;(t=function(t,i){this.logger=i.getLogger("sip.requestsender"),this.ua=i,this.applicant=t,this.method=t.request.method,this.request=t.request,this.credentials=null,this.challenged=!1,this.staled=!1,i.status!==e.UA.C.STATUS_USER_CLOSED||this.method===e.C.BYE&&this.method===e.C.ACK||this.onTransportError()}).prototype={send:function(){switch(this.method){case"INVITE":this.clientTransaction=new e.Transactions.InviteClientTransaction(this,this.request,this.ua.transport);break;case"ACK":this.clientTransaction=new e.Transactions.AckClientTransaction(this,this.request,this.ua.transport);break;default:this.clientTransaction=new e.Transactions.NonInviteClientTransaction(this,this.request,this.ua.transport)}return this.clientTransaction.send(),this.clientTransaction},onRequestTimeout:function(){this.applicant.onRequestTimeout()},onTransportError:function(){this.applicant.onTransportError()},receiveResponse:function(t){var i,s,r,n=t.status_code;if(401===n||407===n){if(401===t.status_code?(s=t.parseHeader("www-authenticate"),r="authorization"):(s=t.parseHeader("proxy-authenticate"),r="proxy-authorization"),!s)return this.logger.warn(t.status_code+" with wrong or missing challenge, cannot authenticate"),void this.applicant.receiveResponse(t);if(!this.challenged||!this.staled&&!0===s.stale){if(this.credentials||(this.credentials=this.ua.configuration.authenticationFactory(this.ua)),!this.credentials.authenticate(this.request,s))return void this.applicant.receiveResponse(t);this.challenged=!0,s.stale&&(this.staled=!0),t.method===e.C.REGISTER?i=this.applicant.cseq+=1:this.request.dialog?i=this.request.dialog.local_seqnum+=1:(i=this.request.cseq+1,this.request.cseq=i),this.request.setHeader("cseq",i+" "+this.method),this.request.setHeader(r,this.credentials.toString()),this.send()}else this.applicant.receiveResponse(t)}else this.applicant.receiveResponse(t)}},e.RequestSender=t}},function(e,t,i){"use strict";e.exports=function(e){var t;(t=function(t){var i={};this.registrar=t.configuration.registrarServer,this.expires=t.configuration.registerExpires,this.contact=t.contact.toString(),this.contact+=";reg-id=1",this.contact+=';+sip.instance="<urn:uuid:'+t.configuration.instanceId+'>"',this.call_id=e.Utils.createRandomToken(22),this.cseq=Math.floor(1e4*Math.random()),this.to_uri=t.configuration.uri,i.to_uri=this.to_uri,i.to_displayName=t.configuration.displayName,i.call_id=this.call_id,i.cseq=this.cseq,e.Utils.augment(this,e.ClientContext,[t,"REGISTER",this.registrar,{params:i}]),this.registrationTimer=null,this.registrationExpiredTimer=null,this.registered=!1,this.logger=t.getLogger("sip.registercontext")}).prototype={register:function(t){var i,s=this;this.options=t||{},(i=(this.options.extraHeaders||[]).slice()).push("Contact: "+this.contact+";expires="+this.expires),i.push("Allow: "+e.UA.C.ALLOWED_METHODS.toString()),this.closeHeaders=this.options.closeWithHeaders?(this.options.extraHeaders||[]).slice():[],this.receiveResponse=function(t){var i,r,n,o=t.getHeaders("contact").length;if(t.cseq===this.cseq)switch(null!==this.registrationTimer&&(e.Timers.clearTimeout(this.registrationTimer),this.registrationTimer=null),!0){case/^1[0-9]{2}$/.test(t.status_code):this.emit("progress",t);break;case/^2[0-9]{2}$/.test(t.status_code):if(this.emit("accepted",t),t.hasHeader("expires")&&(r=t.getHeader("expires")),null!==this.registrationExpiredTimer&&(e.Timers.clearTimeout(this.registrationExpiredTimer),this.registrationExpiredTimer=null),!o){this.logger.warn("no Contact header in response to REGISTER, response ignored");break}for(;o--;){if((i=t.parseHeader("contact",o)).uri.user===this.ua.contact.uri.user){r=i.getParam("expires");break}i=null}if(!i){this.logger.warn("no Contact header pointing to us, response ignored");break}r||(r=this.expires),this.registrationTimer=e.Timers.setTimeout(function(){s.registrationTimer=null,s.register(s.options)},1e3*r-3e3),this.registrationExpiredTimer=e.Timers.setTimeout(function(){s.logger.warn("registration expired"),s.registered&&s.unregistered(null,e.C.causes.EXPIRES)},1e3*r),i.hasParam("temp-gruu")&&(this.ua.contact.temp_gruu=e.URI.parse(i.getParam("temp-gruu").replace(/"/g,""))),i.hasParam("pub-gruu")&&(this.ua.contact.pub_gruu=e.URI.parse(i.getParam("pub-gruu").replace(/"/g,""))),this.registered=!0,this.emit("registered",t||null);break;case/^423$/.test(t.status_code):t.hasHeader("min-expires")?(this.expires=t.getHeader("min-expires"),this.register(this.options)):(this.logger.warn("423 response received for REGISTER without Min-Expires"),this.registrationFailure(t,e.C.causes.SIP_FAILURE_CODE));break;default:n=e.Utils.sipErrorCause(t.status_code),this.registrationFailure(t,n)}},this.onRequestTimeout=function(){this.registrationFailure(null,e.C.causes.REQUEST_TIMEOUT)},this.onTransportError=function(){this.registrationFailure(null,e.C.causes.CONNECTION_ERROR)},this.cseq++,this.request.cseq=this.cseq,this.request.setHeader("cseq",this.cseq+" REGISTER"),this.request.extraHeaders=i,this.send()},registrationFailure:function(e,t){this.emit("failed",e||null,t||null)},onTransportClosed:function(){this.registered_before=this.registered,null!==this.registrationTimer&&(e.Timers.clearTimeout(this.registrationTimer),this.registrationTimer=null),null!==this.registrationExpiredTimer&&(e.Timers.clearTimeout(this.registrationExpiredTimer),this.registrationExpiredTimer=null),this.registered&&this.unregistered(null,e.C.causes.CONNECTION_ERROR)},onTransportConnected:function(){this.register(this.options)},close:function(){var e={all:!1,extraHeaders:this.closeHeaders};this.registered_before=this.registered,this.registered&&this.unregister(e)},unregister:function(t){var i;t=t||{},this.registered||t.all||this.logger.warn("Already unregistered, but sending an unregister anyways."),i=(t.extraHeaders||[]).slice(),this.registered=!1,null!==this.registrationTimer&&(e.Timers.clearTimeout(this.registrationTimer),this.registrationTimer=null),t.all?(i.push("Contact: *"),i.push("Expires: 0")):i.push("Contact: "+this.contact+";expires=0"),this.receiveResponse=function(t){var i;switch(!0){case/^1[0-9]{2}$/.test(t.status_code):this.emit("progress",t);break;case/^2[0-9]{2}$/.test(t.status_code):this.emit("accepted",t),null!==this.registrationExpiredTimer&&(e.Timers.clearTimeout(this.registrationExpiredTimer),this.registrationExpiredTimer=null),this.unregistered(t);break;default:i=e.Utils.sipErrorCause(t.status_code),this.unregistered(t,i)}},this.onRequestTimeout=function(){},this.onTransportError=function(){},this.cseq++,this.request.cseq=this.cseq,this.request.setHeader("cseq",this.cseq+" REGISTER"),this.request.extraHeaders=i,this.send()},unregistered:function(e,t){this.registered=!1,this.emit("unregistered",e||null,t||null)}},e.RegisterContext=t}},function(e,t,i){"use strict";e.exports=function(e){var t=function(e,t){};return t.prototype=Object.create(e.prototype,{close:{value:function(){}},getDescription:{value:function(e,t){}},hasDescription:{value:function(e){}},holdModifier:{value:function(e){}},setDescription:{value:function(e,t,i){}}}),t}},function(e,t,i){"use strict";e.exports=function(e){var t;((t=function(t,i,s,r){var n=s;if(void 0===s)throw new TypeError("Not enough arguments");if(this.ua=t,this.logger=t.getLogger("sip.clientcontext"),this.method=i,!(s=t.normalizeTarget(s)))throw new TypeError("Invalid target: "+n);(r=Object.create(r||Object.prototype)).extraHeaders=(r.extraHeaders||[]).slice(),this.request=new e.OutgoingRequest(this.method,s,this.ua,r.params,r.extraHeaders),r.body&&(this.body={},this.body.body=r.body,r.contentType&&(this.body.contentType=r.contentType),this.request.body=this.body),this.localIdentity=this.request.from,this.remoteIdentity=this.request.to,this.data={}}).prototype=Object.create(e.EventEmitter.prototype)).send=function(){return new e.RequestSender(this,this.ua).send(),this},t.prototype.cancel=function(t){(t=t||{}).extraHeaders=(t.extraHeaders||[]).slice();var i=e.Utils.getCancelReason(t.status_code,t.reason_phrase);this.request.cancel(i,t.extraHeaders),this.emit("cancel")},t.prototype.receiveResponse=function(t){var i=e.Utils.getReasonPhrase(t.status_code);switch(!0){case/^1[0-9]{2}$/.test(t.status_code):this.emit("progress",t,i);break;case/^2[0-9]{2}$/.test(t.status_code):this.ua.applicants[this]&&delete this.ua.applicants[this],this.emit("accepted",t,i);break;default:this.ua.applicants[this]&&delete this.ua.applicants[this],this.emit("rejected",t,i),this.emit("failed",t,i)}},t.prototype.onRequestTimeout=function(){this.emit("failed",null,e.C.causes.REQUEST_TIMEOUT)},t.prototype.onTransportError=function(){this.emit("failed",null,e.C.causes.CONNECTION_ERROR)},e.ClientContext=t}},function(e,t,i){"use strict";e.exports=function(e){var t;((t=function(t,i){this.ua=t,this.logger=t.getLogger("sip.servercontext"),this.request=i,i.method===e.C.INVITE?this.transaction=new e.Transactions.InviteServerTransaction(i,t):this.transaction=new e.Transactions.NonInviteServerTransaction(i,t),i.body&&(this.body=i.body),i.hasHeader("Content-Type")&&(this.contentType=i.getHeader("Content-Type")),this.method=i.method,this.data={},this.localIdentity=i.to,this.remoteIdentity=i.from}).prototype=Object.create(e.EventEmitter.prototype)).progress=function(e){return(e=Object.create(e||Object.prototype)).statusCode||(e.statusCode=180),e.minCode=100,e.maxCode=199,e.events=["progress"],this.reply(e)},t.prototype.accept=function(e){return(e=Object.create(e||Object.prototype)).statusCode||(e.statusCode=200),e.minCode=200,e.maxCode=299,e.events=["accepted"],this.reply(e)},t.prototype.reject=function(e){return(e=Object.create(e||Object.prototype)).statusCode||(e.statusCode=480),e.minCode=300,e.maxCode=699,e.events=["rejected","failed"],this.reply(e)},t.prototype.reply=function(t){var i,s=(t=t||{}).statusCode||100,r=t.minCode||100,n=t.maxCode||699,o=e.Utils.getReasonPhrase(s,t.reasonPhrase),a=t.extraHeaders||[],c=t.body,h=t.events||[];if(s<r||s>n)throw new TypeError("Invalid statusCode: "+s);return i=this.request.reply(s,o,a,c),h.forEach(function(e){this.emit(e,i,o)},this),this},t.prototype.onRequestTimeout=function(){this.emit("failed",null,e.C.causes.REQUEST_TIMEOUT)},t.prototype.onTransportError=function(){this.emit("failed",null,e.C.causes.CONNECTION_ERROR)},e.ServerContext=t}},function(e,t,i){"use strict";e.exports=function(e){var t,s,r,n,o,a=i(24)(e),c={STATUS_NULL:0,STATUS_INVITE_SENT:1,STATUS_1XX_RECEIVED:2,STATUS_INVITE_RECEIVED:3,STATUS_WAITING_FOR_ANSWER:4,STATUS_ANSWERED:5,STATUS_WAITING_FOR_PRACK:6,STATUS_WAITING_FOR_ACK:7,STATUS_CANCELED:8,STATUS_TERMINATED:9,STATUS_ANSWERED_WAITING_FOR_PRACK:10,STATUS_EARLY_MEDIA:11,STATUS_CONFIRMED:12};(t=function(t){if(this.status=c.STATUS_NULL,this.dialog=null,this.pendingReinvite=!1,this.earlyDialogs={},!t)throw new e.Exceptions.SessionDescriptionHandlerMissing("A session description handler is required for the session to function");this.sessionDescriptionHandlerFactory=t,this.hasOffer=!1,this.hasAnswer=!1,this.timers={ackTimer:null,expiresTimer:null,invite2xxTimer:null,userNoAnswerTimer:null,rel1xxTimer:null,prackTimer:null},this.startTime=null,this.endTime=null,this.tones=null,this.local_hold=!1,this.disableRenegotiation=!1,this.early_sdp=null,this.rel100=e.C.supported.UNSUPPORTED}).prototype={dtmf:function(t,i){var s=[],r=this;if(i=i||{},void 0===t)throw new TypeError("Not enough arguments");if(this.status!==c.STATUS_CONFIRMED&&this.status!==c.STATUS_WAITING_FOR_ACK)throw new e.Exceptions.InvalidStateError(this.status);if("string"!=typeof t&&"number"!=typeof t||!t.toString().match(/^[0-9A-D#*,]+$/i))throw new TypeError("Invalid tones: "+t);for(t=t.toString().split("");t.length>0;)s.push(new a(this,t.shift(),i));if(this.tones)return this.tones=this.tones.concat(s),this;return this.tones=s,function t(){var s,n;if(r.status===c.STATUS_TERMINATED||!r.tones||0===r.tones.length)return r.tones=null,this;(s=r.tones.shift()).on("failed",function(){r.tones=null}),s.send(i),n=s.duration+s.interToneGap,e.Timers.setTimeout(t,n)}(),this},bye:function(t){var i=(t=Object.create(t||Object.prototype)).statusCode;if(this.status===c.STATUS_TERMINATED)return this.logger.error("Error: Attempted to send BYE in a terminated session."),this;if(this.logger.log("terminating Session"),i&&(i<200||i>=700))throw new TypeError("Invalid statusCode: "+i);return t.receiveResponse=function(){},this.sendRequest(e.C.BYE,t).terminated()},refer:function(t,i){if(i=i||{},this.status!==c.STATUS_CONFIRMED)throw new e.Exceptions.InvalidStateError(this.status);this.referContext=new e.ReferClientContext(this.ua,this,t,i),this.emit("referRequested",this.referContext),this.referContext.refer()},sendRequest:function(t,i){i=i||{};var s=this,r=new e.OutgoingRequest(t,this.dialog.remote_target,this.ua,{cseq:i.cseq||(this.dialog.local_seqnum+=1),call_id:this.dialog.id.call_id,from_uri:this.dialog.local_uri,from_tag:this.dialog.id.local_tag,to_uri:this.dialog.remote_uri,to_tag:this.dialog.id.remote_tag,route_set:this.dialog.route_set,statusCode:i.statusCode,reasonPhrase:i.reasonPhrase},i.extraHeaders||[],i.body);return new e.RequestSender({request:r,onRequestTimeout:function(){s.onRequestTimeout()},onTransportError:function(){s.onTransportError()},receiveResponse:i.receiveResponse||function(e){s.receiveNonInviteResponse(e)}},this.ua).send(),this.emit(t.toLowerCase(),r),this},close:function(){var t;if(this.status===c.STATUS_TERMINATED)return this;this.logger.log("closing INVITE session "+this.id),this.sessionDescriptionHandler&&this.sessionDescriptionHandler.close();for(t in this.timers)e.Timers.clearTimeout(this.timers[t]);this.dialog&&(this.dialog.terminate(),delete this.dialog);for(t in this.earlyDialogs)this.earlyDialogs[t].terminate(),delete this.earlyDialogs[t];return this.status=c.STATUS_TERMINATED,delete this.ua.sessions[this.id],this},createDialog:function(t,i,s){var r,n,o=t["UAS"===i?"to_tag":"from_tag"],a=t["UAS"===i?"from_tag":"to_tag"],c=t.call_id+o+a;if(n=this.earlyDialogs[c],s)return!!n||((n=new e.Dialog(this,t,i,e.Dialog.C.STATUS_EARLY)).error?(this.logger.error(n.error),this.failed(t,e.C.causes.INTERNAL_ERROR),!1):(this.earlyDialogs[c]=n,!0));if(n){n.update(t,i),this.dialog=n,delete this.earlyDialogs[c];for(var h in this.earlyDialogs)this.earlyDialogs[h].terminate(),delete this.earlyDialogs[h];return!0}return(r=new e.Dialog(this,t,i)).error?(this.logger.error(r.error),this.failed(t,e.C.causes.INTERNAL_ERROR),!1):(this.to_tag=t.to_tag,this.dialog=r,!0)},hold:function(t,i){if(this.status!==c.STATUS_WAITING_FOR_ACK&&this.status!==c.STATUS_CONFIRMED)throw new e.Exceptions.InvalidStateError(this.status);this.local_hold?this.logger.log("Session is already on hold, cannot put it on hold again"):((t=t||{}).modifiers=i||[],t.modifiers.push(this.sessionDescriptionHandler.holdModifier),this.local_hold=!0,this.sendReinvite(t))},unhold:function(t,i){if(this.status!==c.STATUS_WAITING_FOR_ACK&&this.status!==c.STATUS_CONFIRMED)throw new e.Exceptions.InvalidStateError(this.status);this.local_hold?(t=t||{},i&&(t.modifiers=i),this.local_hold=!1,this.sendReinvite(t)):this.logger.log("Session is not on hold, cannot unhold it")},reinvite:function(e,t){return e=e||{},t&&(e.modifiers=t),this.sendReinvite(e)},receiveReinvite:function(t){var i,s=this;if(s.emit("reinvite",this),"0"!==t.getHeader("Content-Length")||t.getHeader("Content-Type")){if(!this.sessionDescriptionHandler.hasDescription(t.getHeader("Content-Type")))return t.reply(415),void this.emit("reinviteFailed",s);i=this.sessionDescriptionHandler.setDescription(t.body,this.sessionDescriptionHandlerOptions,this.modifiers).then(this.sessionDescriptionHandler.getDescription.bind(this.sessionDescriptionHandler,this.sessionDescriptionHandlerOptions,this.modifiers))}else i=this.sessionDescriptionHandler.getDescription(this.sessionDescriptionHandlerOptions,this.modifiers);var r=this.receiveRequest;this.receiveRequest=function(t){t.method===e.C.ACK&&this.status===c.STATUS_WAITING_FOR_ACK&&this.sessionDescriptionHandler.hasDescription(t.getHeader("Content-Type"))?(this.hasAnswer=!0,this.sessionDescriptionHandler.setDescription(t.body,this.sessionDescriptionHandlerOptions,this.modifiers).then(function(){e.Timers.clearTimeout(this.timers.ackTimer),e.Timers.clearTimeout(this.timers.invite2xxTimer),this.status=c.STATUS_CONFIRMED,this.emit("confirmed",t)}.bind(this))):r.call(this,t)}.bind(this),i.catch(function(i){var r;i instanceof e.Exceptions.GetDescriptionError?r=500:i instanceof e.Exceptions.RenegotiationError?(s.emit("renegotiationError",i),s.logger.warn(i),r=488):(s.logger.error(i),r=488),t.reply(r),s.emit("reinviteFailed",s)}).then(function(e){var i=["Contact: "+s.contact];t.reply(200,null,i,e,function(){s.status=c.STATUS_WAITING_FOR_ACK,s.setACKTimer(),s.emit("reinviteAccepted",s)})})},sendReinvite:function(t){if(this.pendingReinvite)this.logger.warn("Reinvite in progress. Please wait until complete, then try again.");else{this.pendingReinvite=!0,(t=t||{}).modifiers=t.modifiers||[];var i=this,s=(t.extraHeaders||[]).slice();s.push("Contact: "+this.contact),s.push("Allow: "+e.UA.C.ALLOWED_METHODS.toString()),this.sessionDescriptionHandler.getDescription(t.sessionDescriptionHandlerOptions,t.modifiers).then(function(t){i.sendRequest(e.C.INVITE,{extraHeaders:s,body:t,receiveResponse:i.receiveReinviteResponse.bind(i)})}).catch(function(t){if(t instanceof e.Exceptions.RenegotiationError)return i.pendingReinvite=!1,i.emit("renegotiationError",t),i.logger.warn("Renegotiation Error"),void i.logger.warn(t);i.logger.error("sessionDescriptionHandler error"),i.logger.error(t)})}},receiveRequest:function(t){switch(t.method){case e.C.BYE:t.reply(200),this.status===c.STATUS_CONFIRMED&&(this.emit("bye",t),this.terminated(t,e.C.causes.BYE));break;case e.C.INVITE:this.status===c.STATUS_CONFIRMED&&(this.logger.log("re-INVITE received"),this.receiveReinvite(t));break;case e.C.INFO:if(this.status===c.STATUS_CONFIRMED||this.status===c.STATUS_WAITING_FOR_ACK){if(this.onInfo)return this.onInfo(t);var i,s,r,n=t.getHeader("content-type"),o=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,h=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;n&&(n.match(/^application\/dtmf-relay/i)?(t.body&&2===(i=t.body.split("\r\n",2)).length&&(o.test(i[0])&&(s=i[0].replace(o,"$2")),h.test(i[1])&&(r=parseInt(i[1].replace(h,"$2"),10))),new a(this,s,{duration:r}).init_incoming(t)):t.reply(415,null,["Accept: application/dtmf-relay"]))}break;case e.C.REFER:if(this.status===c.STATUS_CONFIRMED){this.logger.log("REFER received"),this.referContext=new e.ReferServerContext(this.ua,t);if(this.listeners("referRequested").length)this.emit("referRequested",this.referContext);else{this.logger.log("No referRequested listeners, automatically accepting and following the refer");var u={followRefer:!0};this.passedOptions&&(u.inviteOptions=this.passedOptions),this.referContext.accept(u,this.modifiers)}}break;case e.C.NOTIFY:if(this.referContext&&this.referContext instanceof e.ReferClientContext&&t.hasHeader("event")&&"refer"===t.getHeader("event"))return void this.referContext.receiveNotify(t);t.reply(200,"OK"),this.emit("notify",t)}},receiveReinviteResponse:function(t){var i=this;if(this.status!==c.STATUS_TERMINATED)switch(!0){case/^1[0-9]{2}$/.test(t.status_code):break;case/^2[0-9]{2}$/.test(t.status_code):if(this.status=c.STATUS_CONFIRMED,this.emit("ack",t.transaction.sendACK()),this.pendingReinvite=!1,e.Timers.clearTimeout(i.timers.invite2xxTimer),!this.sessionDescriptionHandler.hasDescription(t.getHeader("Content-Type"))){this.logger.error("2XX response received to re-invite but did not have a description"),this.emit("renegotiationError",new e.Exceptions.RenegotiationError("2XX response received to re-invite but did not have a description"));break}this.sessionDescriptionHandler.setDescription(t.body,this.sessionDescriptionHandlerOptions,this.modifiers).catch(function(t){i.logger.error("Could not set the description in 2XX response"),i.logger.error(t),i.emit("renegotiationError",t),i.sendRequest(e.C.BYE,{extraHeaders:[e.Utils.getReasonHeaderValue(488,"Not Acceptable Here")]})});break;default:this.disableRenegotiation=!0,this.pendingReinvite=!1,this.logger.log("Received a non 1XX or 2XX response to a re-invite"),this.emit("renegotiationError",new e.Exceptions.RenegotiationError("Invalid response to a re-invite"))}},acceptAndTerminate:function(t,i,s){var r=[];return i&&r.push("Reason: "+e.Utils.getReasonHeaderValue(i,s)),(this.dialog||this.createDialog(t,"UAC"))&&(this.emit("ack",t.transaction.sendACK()),this.sendRequest(e.C.BYE,{extraHeaders:r})),this},setInvite2xxTimer:function(t,i){var s=this,r=e.Timers.T1;this.timers.invite2xxTimer=e.Timers.setTimeout(function n(){if(s.status===c.STATUS_WAITING_FOR_ACK){s.logger.log("no ACK received, attempting to retransmit OK");var o=["Contact: "+s.contact];t.reply(200,null,o,i),r=Math.min(2*r,e.Timers.T2),s.timers.invite2xxTimer=e.Timers.setTimeout(n,r)}},r)},setACKTimer:function(){var t=this;this.timers.ackTimer=e.Timers.setTimeout(function(){t.status===c.STATUS_WAITING_FOR_ACK&&(t.logger.log("no ACK received for an extended period of time, terminating the call"),e.Timers.clearTimeout(t.timers.invite2xxTimer),t.sendRequest(e.C.BYE),t.terminated(null,e.C.causes.NO_ACK))},e.Timers.TIMER_H)},onTransportError:function(){this.status!==c.STATUS_CONFIRMED&&this.status!==c.STATUS_TERMINATED&&this.failed(null,e.C.causes.CONNECTION_ERROR)},onRequestTimeout:function(){this.status===c.STATUS_CONFIRMED?this.terminated(null,e.C.causes.REQUEST_TIMEOUT):this.status!==c.STATUS_TERMINATED&&(this.failed(null,e.C.causes.REQUEST_TIMEOUT),this.terminated(null,e.C.causes.REQUEST_TIMEOUT))},onDialogError:function(t){this.status===c.STATUS_CONFIRMED?this.terminated(t,e.C.causes.DIALOG_ERROR):this.status!==c.STATUS_TERMINATED&&(this.failed(t,e.C.causes.DIALOG_ERROR),this.terminated(t,e.C.causes.DIALOG_ERROR))},failed:function(e,t){return this.status===c.STATUS_TERMINATED?this:(this.emit("failed",e||null,t||null),this)},rejected:function(e,t){return this.emit("rejected",e||null,t||null),this},canceled:function(){return this.emit("cancel"),this},accepted:function(t,i){return i=e.Utils.getReasonPhrase(t&&t.status_code,i),this.startTime=new Date,this.replacee&&(this.replacee.emit("replaced",this),this.replacee.terminate()),this.emit("accepted",t,i),this},terminated:function(e,t){return this.status===c.STATUS_TERMINATED?this:(this.endTime=new Date,this.close(),this.emit("terminated",e||null,t||null),this)},connecting:function(e){return this.emit("connecting",{request:e}),this}},t.C=c,e.Session=t,(s=function(t,i){function s(e,t){i.hasHeader(e)&&i.getHeader(e).toLowerCase().indexOf("100rel")>=0&&(n.rel100=t)}var r,n=this,o=i.getHeader("Content-Type"),a=i.parseHeader("Content-Disposition");if(e.Utils.augment(this,e.ServerContext,[t,i]),e.Utils.augment(this,e.Session,[t.configuration.sessionDescriptionHandlerFactory]),a&&"render"===a.type&&(this.renderbody=i.body,this.rendertype=o),this.status=c.STATUS_INVITE_RECEIVED,this.from_tag=i.from_tag,this.id=i.call_id+this.from_tag,this.request=i,this.contact=this.ua.contact.toString(),this.receiveNonInviteResponse=function(){},this.logger=t.getLogger("sip.inviteservercontext",this.id),this.ua.sessions[this.id]=this,i.hasHeader("expires")&&(r=1e3*i.getHeader("expires")),s("require",e.C.supported.REQUIRED),s("supported",e.C.supported.SUPPORTED),i.to_tag=e.Utils.newTag(),this.createDialog(i,"UAS",!0)){var h={extraHeaders:["Contact: "+n.contact]};n.rel100!==e.C.supported.REQUIRED&&n.progress(h),n.status=c.STATUS_WAITING_FOR_ANSWER,n.timers.userNoAnswerTimer=e.Timers.setTimeout(function(){i.reply(408),n.failed(i,e.C.causes.NO_ANSWER),n.terminated(i,e.C.causes.NO_ANSWER)},n.ua.configuration.noAnswerTimeout),r&&(n.timers.expiresTimer=e.Timers.setTimeout(function(){n.status===c.STATUS_WAITING_FOR_ANSWER&&(i.reply(487),n.failed(i,e.C.causes.EXPIRES),n.terminated(i,e.C.causes.EXPIRES))},r))}else i.reply(500,"Missing Contact header field")}).prototype={reject:function(t){if(this.status===c.STATUS_TERMINATED)throw new e.Exceptions.InvalidStateError(this.status);return this.logger.log("rejecting RTCSession"),e.ServerContext.prototype.reject.call(this,t),this.terminated()},terminate:function(t){var i,s=((t=t||{}).extraHeaders||[]).slice(),r=t.body,n=this;return this.status===c.STATUS_WAITING_FOR_ACK&&this.request.server_transaction.state!==e.Transactions.C.STATUS_TERMINATED?(i=this.dialog,this.receiveRequest=function(t){t.method===e.C.ACK&&(this.sendRequest(e.C.BYE,{extraHeaders:s,body:r}),i.terminate())},this.request.server_transaction.on("stateChanged",function(){this.state===e.Transactions.C.STATUS_TERMINATED&&this.dialog&&(this.request=new e.OutgoingRequest(e.C.BYE,this.dialog.remote_target,this.ua,{cseq:this.dialog.local_seqnum+=1,call_id:this.dialog.id.call_id,from_uri:this.dialog.local_uri,from_tag:this.dialog.id.local_tag,to_uri:this.dialog.remote_uri,to_tag:this.dialog.id.remote_tag,route_set:this.dialog.route_set},s,r),new e.RequestSender({request:this.request,onRequestTimeout:function(){n.onRequestTimeout()},onTransportError:function(){n.onTransportError()},receiveResponse:function(){}},this.ua).send(),i.terminate())}),this.emit("bye",this.request),this.terminated(),this.dialog=i,this.ua.dialogs[i.id.toString()]=i):this.status===c.STATUS_CONFIRMED?this.bye(t):this.reject(t),this},progress:function(t){function i(){r=t.statusCode||183,this.status=c.STATUS_WAITING_FOR_PRACK,o.push("Contact: "+this.contact),o.push("Require: 100rel"),o.push("RSeq: "+Math.floor(1e4*Math.random())),this.sessionDescriptionHandler.getDescription(t.sessionDescriptionHandlerOptions,t.modifiers).then(function(t){if(!this.isCanceled&&this.status!==c.STATUS_TERMINATED){this.early_sdp=t.body,this[this.hasOffer?"hasAnswer":"hasOffer"]=!0;var i=e.Timers.T1;this.timers.rel1xxTimer=e.Timers.setTimeout(function s(){this.request.reply(r,null,o,t),i*=2,this.timers.rel1xxTimer=e.Timers.setTimeout(s.bind(this),i)}.bind(this),i),this.timers.prackTimer=e.Timers.setTimeout(function(){this.status===c.STATUS_WAITING_FOR_PRACK&&(this.logger.log("no PRACK received, rejecting the call"),e.Timers.clearTimeout(this.timers.rel1xxTimer),this.request.reply(504),this.terminated(null,e.C.causes.NO_PRACK))}.bind(this),64*e.Timers.T1),s=this.request.reply(r,n,o,t),this.emit("progress",s,n)}}.bind(this),function(){this.request.reply(480),this.failed(null,e.C.causes.WEBRTC_ERROR),this.terminated(null,e.C.causes.WEBRTC_ERROR)}.bind(this))}var s,r=(t=t||{}).statusCode||180,n=t.reasonPhrase,o=(t.extraHeaders||[]).slice(),a=t.body;if(r<100||r>199)throw new TypeError("Invalid statusCode: "+r);return this.isCanceled||this.status===c.STATUS_TERMINATED?this:(100!==t.statusCode&&(this.rel100===e.C.supported.REQUIRED||this.rel100===e.C.supported.SUPPORTED&&t.rel100||this.rel100===e.C.supported.SUPPORTED&&this.ua.configuration.rel100===e.C.supported.REQUIRED)?(this.sessionDescriptionHandler=this.setupSessionDescriptionHandler(),this.sessionDescriptionHandler.hasDescription(this.request.getHeader("Content-Type"))?(this.hasOffer=!0,this.sessionDescriptionHandler.setDescription(this.request.body,t.sessionDescriptionHandlerOptions,t.modifiers).then(i.apply(this)).catch(function(t){this.logger.warn("invalid description"),this.logger.warn(t),this.failed(null,e.C.causes.WEBRTC_ERROR),this.terminated(null,e.C.causes.WEBRTC_ERROR)}.bind(this))):i.apply(this)):function(){s=this.request.reply(r,n,o,a),this.emit("progress",s,n)}.apply(this),this)},accept:function(t){t=t||{},this.onInfo=t.onInfo;var i=this,s=this.request,r=(t.extraHeaders||[]).slice(),n=function(t){var n;r.push("Contact: "+i.contact),r.push("Allow: "+e.UA.C.ALLOWED_METHODS.toString()),i.hasOffer?i.hasAnswer=!0:i.hasOffer=!0,n=s.reply(200,null,r,t,function(){i.status=c.STATUS_WAITING_FOR_ACK,i.setInvite2xxTimer(s,t),i.setACKTimer()},function(){i.failed(null,e.C.causes.CONNECTION_ERROR),i.terminated(null,e.C.causes.CONNECTION_ERROR)}),i.status!==c.STATUS_TERMINATED&&i.accepted(n,e.Utils.getReasonPhrase(200))},o=function(){i.status!==c.STATUS_TERMINATED&&(i.request.reply(480),i.failed(null,e.C.causes.WEBRTC_ERROR),i.terminated(null,e.C.causes.WEBRTC_ERROR))};if(this.status===c.STATUS_WAITING_FOR_PRACK)return this.status=c.STATUS_ANSWERED_WAITING_FOR_PRACK,this;if(this.status===c.STATUS_WAITING_FOR_ANSWER)this.status=c.STATUS_ANSWERED;else if(this.status!==c.STATUS_EARLY_MEDIA)throw new e.Exceptions.InvalidStateError(this.status);if(!this.createDialog(s,"UAS"))return s.reply(500,"Missing Contact header field"),this;if(e.Timers.clearTimeout(this.timers.userNoAnswerTimer),this.status===c.STATUS_EARLY_MEDIA)n({});else if(this.sessionDescriptionHandler=this.setupSessionDescriptionHandler(),"0"!==this.request.getHeader("Content-Length")||this.request.getHeader("Content-Type")){if(!this.sessionDescriptionHandler.hasDescription(this.request.getHeader("Content-Type")))return void this.request.reply(415);this.hasOffer=!0,this.sessionDescriptionHandler.setDescription(this.request.body,t.sessionDescriptionHandlerOptions,t.modifiers).then(function(){return this.sessionDescriptionHandler.getDescription(t.sessionDescriptionHandlerOptions,t.modifiers)}.bind(this)).catch(o).then(n)}else this.sessionDescriptionHandler.getDescription(t.sessionDescriptionHandlerOptions,t.modifiers).catch(o).then(n);return this},receiveRequest:function(i){function s(){var t,s;e.Timers.clearTimeout(this.timers.ackTimer),e.Timers.clearTimeout(this.timers.invite2xxTimer),this.status=c.STATUS_CONFIRMED,t=i.getHeader("Content-Type"),(s=i.getHeader("Content-Disposition"))&&"render"===s.type&&(this.renderbody=i.body,this.rendertype=t),this.emit("confirmed",i)}switch(i.method){case e.C.CANCEL:this.status!==c.STATUS_WAITING_FOR_ANSWER&&this.status!==c.STATUS_WAITING_FOR_PRACK&&this.status!==c.STATUS_ANSWERED_WAITING_FOR_PRACK&&this.status!==c.STATUS_EARLY_MEDIA&&this.status!==c.STATUS_ANSWERED||(this.status=c.STATUS_CANCELED,this.request.reply(487),this.canceled(i),this.rejected(i,e.C.causes.CANCELED),this.failed(i,e.C.causes.CANCELED),this.terminated(i,e.C.causes.CANCELED));break;case e.C.ACK:this.status===c.STATUS_WAITING_FOR_ACK&&(this.sessionDescriptionHandler.hasDescription(i.getHeader("Content-Type"))?(this.hasAnswer=!0,this.sessionDescriptionHandler.setDescription(i.body,this.sessionDescriptionHandlerOptions,this.modifiers).then(s.bind(this),function(t){this.logger.warn(t),this.terminate({statusCode:"488",reasonPhrase:"Bad Media Description"}),this.failed(i,e.C.causes.BAD_MEDIA_DESCRIPTION),this.terminated(i,e.C.causes.BAD_MEDIA_DESCRIPTION)}.bind(this))):s.apply(this));break;case e.C.PRACK:this.status===c.STATUS_WAITING_FOR_PRACK||this.status===c.STATUS_ANSWERED_WAITING_FOR_PRACK?this.hasAnswer?(e.Timers.clearTimeout(this.timers.rel1xxTimer),e.Timers.clearTimeout(this.timers.prackTimer),i.reply(200),this.status===c.STATUS_ANSWERED_WAITING_FOR_PRACK&&(this.status=c.STATUS_EARLY_MEDIA,this.accept()),this.status=c.STATUS_EARLY_MEDIA):(this.sessionDescriptionHandler=this.setupSessionDescriptionHandler(),this.sessionDescriptionHandler.hasDescription(i.getHeader("Content-Type"))?(this.hasAnswer=!0,this.sessionDescriptionHandler.setDescription(i.body,this.sessionDescriptionHandlerOptions,this.modifiers).then(function(){e.Timers.clearTimeout(this.timers.rel1xxTimer),e.Timers.clearTimeout(this.timers.prackTimer),i.reply(200),this.status===c.STATUS_ANSWERED_WAITING_FOR_PRACK&&(this.status=c.STATUS_EARLY_MEDIA,this.accept()),this.status=c.STATUS_EARLY_MEDIA}.bind(this),function(t){this.logger.warn(t),this.terminate({statusCode:"488",reasonPhrase:"Bad Media Description"}),this.failed(i,e.C.causes.BAD_MEDIA_DESCRIPTION),this.terminated(i,e.C.causes.BAD_MEDIA_DESCRIPTION)}.bind(this))):(this.terminate({statusCode:"488",reasonPhrase:"Bad Media Description"}),this.failed(i,e.C.causes.BAD_MEDIA_DESCRIPTION),this.terminated(i,e.C.causes.BAD_MEDIA_DESCRIPTION))):this.status===c.STATUS_EARLY_MEDIA&&i.reply(200);break;default:t.prototype.receiveRequest.apply(this,[i])}},setupSessionDescriptionHandler:function(){return this.sessionDescriptionHandler?this.sessionDescriptionHandler:this.sessionDescriptionHandlerFactory(this,this.ua.configuration.sessionDescriptionHandlerFactoryOptions)},onTransportError:function(){this.status!==c.STATUS_CONFIRMED&&this.status!==c.STATUS_TERMINATED&&this.failed(null,e.C.causes.CONNECTION_ERROR)},onRequestTimeout:function(){this.status===c.STATUS_CONFIRMED?this.terminated(null,e.C.causes.REQUEST_TIMEOUT):this.status!==c.STATUS_TERMINATED&&(this.failed(null,e.C.causes.REQUEST_TIMEOUT),this.terminated(null,e.C.causes.REQUEST_TIMEOUT))}},e.InviteServerContext=s,(r=function(t,i,s,r){s=s||{},this.passedOptions=s,s.params=Object.create(s.params||Object.prototype);var n=(s.extraHeaders||[]).slice(),o=t.configuration.sessionDescriptionHandlerFactory;if(this.sessionDescriptionHandlerFactoryOptions=t.configuration.sessionDescriptionHandlerFactoryOptions||{},this.sessionDescriptionHandlerOptions=s.sessionDescriptionHandlerOptions||{},this.modifiers=r,this.inviteWithoutSdp=s.inviteWithoutSdp||!1,this.anonymous=s.anonymous||!1,this.renderbody=s.renderbody||null,this.rendertype=s.rendertype||"text/plain",this.from_tag=e.Utils.newTag(),s.params.from_tag=this.from_tag,this.contact=t.contact.toString({anonymous:this.anonymous,outbound:this.anonymous?!t.contact.temp_gruu:!t.contact.pub_gruu}),this.anonymous&&(s.params.from_displayName="Anonymous",s.params.from_uri="sip:anonymous@anonymous.invalid",n.push("P-Preferred-Identity: "+t.configuration.uri.toString()),n.push("Privacy: id")),n.push("Contact: "+this.contact),n.push("Allow: "+e.UA.C.ALLOWED_METHODS.toString()),this.inviteWithoutSdp&&this.renderbody&&(n.push("Content-Type: "+this.rendertype),n.push("Content-Disposition: render;handling=optional")),t.configuration.rel100===e.C.supported.REQUIRED&&n.push("Require: 100rel"),t.configuration.replaces===e.C.supported.REQUIRED&&n.push("Require: replaces"),s.extraHeaders=n,e.Utils.augment(this,e.ClientContext,[t,e.C.INVITE,i,s]),e.Utils.augment(this,e.Session,[o]),this.status!==c.STATUS_NULL)throw new e.Exceptions.InvalidStateError(this.status);this.isCanceled=!1,this.received_100=!1,this.method=e.C.INVITE,this.receiveNonInviteResponse=this.receiveResponse,this.receiveResponse=this.receiveInviteResponse,this.logger=t.getLogger("sip.inviteclientcontext"),t.applicants[this]=this,this.id=this.request.call_id+this.from_tag,this.onInfo=s.onInfo}).prototype={invite:function(){var t=this;return this.ua.sessions[this.id]=this,this.inviteWithoutSdp?(this.request.body=t.renderbody,this.status=c.STATUS_INVITE_SENT,this.send()):(this.sessionDescriptionHandler=this.sessionDescriptionHandlerFactory(this,this.sessionDescriptionHandlerFactoryOptions),this.sessionDescriptionHandler.getDescription(this.sessionDescriptionHandlerOptions,this.modifiers).then(function(e){t.isCanceled||t.status===c.STATUS_TERMINATED||(t.hasOffer=!0,t.request.body=e,t.status=c.STATUS_INVITE_SENT,t.send())},function(){t.status!==c.STATUS_TERMINATED&&(t.failed(null,e.C.causes.WEBRTC_ERROR),t.terminated(null,e.C.causes.WEBRTC_ERROR))})),this},receiveInviteResponse:function(t){var i,s=this,r=t.call_id+t.from_tag+t.to_tag,n=[],o={};if(this.status!==c.STATUS_TERMINATED&&t.method===e.C.INVITE){if(this.dialog&&t.status_code>=200&&t.status_code<=299){if(r!==this.dialog.id.toString()){if(!this.createDialog(t,"UAC",!0))return;return this.emit("ack",t.transaction.sendACK({body:e.Utils.generateFakeSDP(t.body)})),this.earlyDialogs[r].sendRequest(this,e.C.BYE),void(this.status!==c.STATUS_CONFIRMED&&(this.failed(t,e.C.causes.WEBRTC_ERROR),this.terminated(t,e.C.causes.WEBRTC_ERROR)))}if(this.status===c.STATUS_CONFIRMED)return void this.emit("ack",t.transaction.sendACK());if(!this.hasAnswer)return}if(this.dialog&&t.status_code<200){if(-1!==this.dialog.pracked.indexOf(t.getHeader("rseq"))||this.dialog.pracked[this.dialog.pracked.length-1]>=t.getHeader("rseq")&&this.dialog.pracked.length>0)return;if(!this.earlyDialogs[r]&&!this.createDialog(t,"UAC",!0))return;if(-1!==this.earlyDialogs[r].pracked.indexOf(t.getHeader("rseq"))||this.earlyDialogs[r].pracked[this.earlyDialogs[r].pracked.length-1]>=t.getHeader("rseq")&&this.earlyDialogs[r].pracked.length>0)return;return n.push("RAck: "+t.getHeader("rseq")+" "+t.getHeader("cseq")),this.earlyDialogs[r].pracked.push(t.getHeader("rseq")),void this.earlyDialogs[r].sendRequest(this,e.C.PRACK,{extraHeaders:n,body:e.Utils.generateFakeSDP(t.body)})}if(this.isCanceled)t.status_code>=100&&t.status_code<200?(this.request.cancel(this.cancelReason,n),this.canceled(null)):t.status_code>=200&&t.status_code<299?(this.acceptAndTerminate(t),this.emit("bye",this.request)):t.status_code>=300&&(i=e.C.REASON_PHRASE[t.status_code]||e.C.causes.CANCELED,this.rejected(t,i),this.failed(t,i),this.terminated(t,i));else switch(!0){case/^100$/.test(t.status_code):this.received_100=!0,this.emit("progress",t);break;case/^1[0-9]{2}$/.test(t.status_code):if(!t.to_tag){this.logger.warn("1xx response received without to tag");break}if(t.hasHeader("contact")&&!this.createDialog(t,"UAC",!0))break;if(this.status=c.STATUS_1XX_RECEIVED,t.hasHeader("require")&&-1!==t.getHeader("require").indexOf("100rel")){if(this.dialog||!this.earlyDialogs[r])break;if(-1!==this.earlyDialogs[r].pracked.indexOf(t.getHeader("rseq"))||this.earlyDialogs[r].pracked[this.earlyDialogs[r].pracked.length-1]>=t.getHeader("rseq")&&this.earlyDialogs[r].pracked.length>0)return;if(this.sessionDescriptionHandler=this.sessionDescriptionHandlerFactory(this,this.sessionDescriptionHandlerFactoryOptions),this.sessionDescriptionHandler.hasDescription(t.getHeader("Content-Type")))if(this.hasOffer){if(!this.createDialog(t,"UAC"))break;this.hasAnswer=!0,this.dialog.pracked.push(t.getHeader("rseq")),this.sessionDescriptionHandler.setDescription(t.body,this.sessionDescriptionHandlerOptions,this.modifiers).then(function(){n.push("RAck: "+t.getHeader("rseq")+" "+t.getHeader("cseq")),s.sendRequest(e.C.PRACK,{extraHeaders:n,receiveResponse:function(){}}),s.status=c.STATUS_EARLY_MEDIA,s.emit("progress",t)},function(i){s.logger.warn(i),s.acceptAndTerminate(t,488,"Not Acceptable Here"),s.failed(t,e.C.causes.BAD_MEDIA_DESCRIPTION)})}else{var a=this.earlyDialogs[r],h=a.sessionDescriptionHandler=this.sessionDescriptionHandlerFactory(this,this.sessionDescriptionHandlerOptions);a.pracked.push(t.getHeader("rseq")),h.setDescription(t.body,s.sessionDescriptionHandlerOptions,s.modifers).then(h.getDescription.bind(h,s.sessionDescriptionHandlerOptions,s.modifiers)).then(function(i){n.push("RAck: "+t.getHeader("rseq")+" "+t.getHeader("cseq")),a.sendRequest(s,e.C.PRACK,{extraHeaders:n,body:i}),s.status=c.STATUS_EARLY_MEDIA,s.emit("progress",t)}).catch(function(i){if(i instanceof e.Exceptions.GetDescriptionError){if(a.pracked.push(t.getHeader("rseq")),s.status===c.STATUS_TERMINATED)return;s.failed(null,e.C.causes.WEBRTC_ERROR),s.terminated(null,e.C.causes.WEBRTC_ERROR)}else a.pracked.splice(a.pracked.indexOf(t.getHeader("rseq")),1),s.logger.warn("invalid description"),s.logger.warn(i)})}else n.push("RAck: "+t.getHeader("rseq")+" "+t.getHeader("cseq")),this.earlyDialogs[r].pracked.push(t.getHeader("rseq")),this.earlyDialogs[r].sendRequest(this,e.C.PRACK,{extraHeaders:n}),this.emit("progress",t)}else this.emit("progress",t);break;case/^2[0-9]{2}$/.test(t.status_code):if(this.request.cseq+" "+this.request.method!==t.getHeader("cseq"))break;if(this.status===c.STATUS_EARLY_MEDIA&&this.dialog){this.status=c.STATUS_CONFIRMED,o={},this.renderbody&&(n.push("Content-Type: "+this.rendertype),o.extraHeaders=n,o.body=this.renderbody),this.emit("ack",t.transaction.sendACK(o)),this.accepted(t);break}if(this.dialog)break;if(this.hasOffer)if(this.hasAnswer)this.renderbody&&(n.push("Content-Type: "+s.rendertype),o.extraHeaders=n,o.body=this.renderbody),this.emit("ack",t.transaction.sendACK(o));else{if(!this.sessionDescriptionHandler.hasDescription(t.getHeader("Content-Type"))){this.acceptAndTerminate(t,400,"Missing session description"),this.failed(t,e.C.causes.BAD_MEDIA_DESCRIPTION);break}if(!this.createDialog(t,"UAC"))break;this.hasAnswer=!0,this.sessionDescriptionHandler.setDescription(t.body,this.sessionDescriptionHandlerOptions,this.modifiers).then(function(){var e={};s.status=c.STATUS_CONFIRMED,s.renderbody&&(n.push("Content-Type: "+s.rendertype),e.extraHeaders=n,e.body=s.renderbody),s.emit("ack",t.transaction.sendACK(e)),s.accepted(t)},function(i){s.logger.warn(i),s.acceptAndTerminate(t,488,"Not Acceptable Here"),s.failed(t,e.C.causes.BAD_MEDIA_DESCRIPTION)})}else if(this.earlyDialogs[r]&&this.earlyDialogs[r].sessionDescriptionHandler){if(this.hasOffer=!0,this.hasAnswer=!0,this.sessionDescriptionHandler=this.earlyDialogs[r].sessionDescriptionHandler,!this.createDialog(t,"UAC"))break;this.status=c.STATUS_CONFIRMED,this.emit("ack",t.transaction.sendACK()),this.accepted(t)}else{if(this.sessionDescriptionHandler=this.sessionDescriptionHandlerFactory(this,this.sessionDescriptionHandlerFactoryOptions),!this.sessionDescriptionHandler.hasDescription(t.getHeader("Content-Type"))){this.acceptAndTerminate(t,400,"Missing session description"),this.failed(t,e.C.causes.BAD_MEDIA_DESCRIPTION);break}if(!this.createDialog(t,"UAC"))break;this.hasOffer=!0,this.sessionDescriptionHandler.setDescription(t.body,this.sessionDescriptionHandlerOptions,this.modifiers).then(this.sessionDescriptionHandler.getDescription.bind(this.sessionDescriptionHandler,this.sessionDescriptionHandlerOptions,this.modifiers)).then(function(e){s.isCanceled||s.status===c.STATUS_TERMINATED||(s.status=c.STATUS_CONFIRMED,s.hasAnswer=!0,s.emit("ack",t.transaction.sendACK({body:e})),s.accepted(t))}).catch(function(i){i instanceof e.Exceptions.GetDescriptionError?s.logger.warn("there was a problem"):(s.logger.warn("invalid description"),s.logger.warn(i),s.acceptAndTerminate(t,488,"Invalid session description"),s.failed(t,e.C.causes.BAD_MEDIA_DESCRIPTION))})}break;default:i=e.Utils.sipErrorCause(t.status_code),this.rejected(t,i),this.failed(t,i),this.terminated(t,i)}}},cancel:function(t){if(t=t||{},t.extraHeaders=(t.extraHeaders||[]).slice(),this.status===c.STATUS_TERMINATED||this.status===c.STATUS_CONFIRMED)throw new e.Exceptions.InvalidStateError(this.status);this.logger.log("canceling RTCSession");var i=e.Utils.getCancelReason(t.status_code,t.reason_phrase);return this.status===c.STATUS_NULL||this.status===c.STATUS_INVITE_SENT&&!this.received_100?(this.isCanceled=!0,this.cancelReason=i):this.status!==c.STATUS_INVITE_SENT&&this.status!==c.STATUS_1XX_RECEIVED&&this.status!==c.STATUS_EARLY_MEDIA||this.request.cancel(i,t.extraHeaders),this.canceled()},terminate:function(e){return this.status===c.STATUS_TERMINATED?this:(this.status===c.STATUS_WAITING_FOR_ACK||this.status===c.STATUS_CONFIRMED?this.bye(e):this.cancel(e),this)},receiveRequest:function(i){return i.method,e.C.CANCEL,i.method===e.C.ACK&&this.status===c.STATUS_WAITING_FOR_ACK&&(e.Timers.clearTimeout(this.timers.ackTimer),e.Timers.clearTimeout(this.timers.invite2xxTimer),this.status=c.STATUS_CONFIRMED,this.accepted()),t.prototype.receiveRequest.apply(this,[i])},onTransportError:function(){this.status!==c.STATUS_CONFIRMED&&this.status!==c.STATUS_TERMINATED&&this.failed(null,e.C.causes.CONNECTION_ERROR)},onRequestTimeout:function(){this.status===c.STATUS_CONFIRMED?this.terminated(null,e.C.causes.REQUEST_TIMEOUT):this.status!==c.STATUS_TERMINATED&&(this.failed(null,e.C.causes.REQUEST_TIMEOUT),this.terminated(null,e.C.causes.REQUEST_TIMEOUT))}},e.InviteClientContext=r,(o=function(t,i,s,r){if(this.options=r||{},this.extraHeaders=(this.options.extraHeaders||[]).slice(),void 0===t||void 0===i||void 0===s)throw new TypeError("Not enough arguments");e.Utils.augment(this,e.ClientContext,[t,e.C.REFER,i.remoteIdentity.uri.toString(),r]),this.applicant=i;if(s instanceof e.InviteServerContext||s instanceof e.InviteClientContext)this.target='"'+s.remoteIdentity.friendlyName+'" <'+s.dialog.remote_target.toString()+"?Replaces="+s.dialog.id.call_id+"%3Bto-tag%3D"+s.dialog.id.remote_tag+"%3Bfrom-tag%3D"+s.dialog.id.local_tag+">";else{try{this.target=e.Grammar.parse(s,"Refer_To").uri||s}catch(e){this.logger.debug(".refer() cannot parse Refer_To from",s),this.logger.debug("...falling through to normalizeTarget()")}if(this.target=this.ua.normalizeTarget(this.target),!this.target)throw new TypeError("Invalid target: "+s)}this.ua&&this.extraHeaders.push("Referred-By: <"+this.ua.configuration.uri+">"),this.extraHeaders.push("Contact: "+i.contact),this.extraHeaders.push("Allow: "+e.UA.C.ALLOWED_METHODS.toString()),this.extraHeaders.push("Refer-To: "+this.target)}).prototype={refer:function(t){t=t||{};var i=(this.extraHeaders||[]).slice();return t.extraHeaders&&i.concat(t.extraHeaders),this.applicant.sendRequest(e.C.REFER,{extraHeaders:this.extraHeaders,receiveResponse:function(e){/^1[0-9]{2}$/.test(e.status_code)?this.emit("referRequestProgress",this):/^2[0-9]{2}$/.test(e.status_code)?this.emit("referRequestAccepted",this):/^[4-6][0-9]{2}$/.test(e.status_code)&&this.emit("referRequestRejected",this),t.receiveResponse&&t.receiveResponse(e)}.bind(this)}),this},receiveNotify:function(t){if(t.hasHeader("Content-Type")&&-1!==t.getHeader("Content-Type").search(/^message\/sipfrag/)){var i=e.Grammar.parse(t.body,"sipfrag");if(-1===i)return void t.reply(489,"Bad Event");switch(!0){case/^1[0-9]{2}$/.test(i.status_code):this.emit("referProgress",this);break;case/^2[0-9]{2}$/.test(i.status_code):this.emit("referAccepted",this),!this.options.activeAfterTransfer&&this.applicant.terminate&&this.applicant.terminate();break;default:this.emit("referRejected",this)}return t.reply(200),void this.emit("notify",t)}t.reply(489,"Bad Event")}},e.ReferClientContext=o,(n=function(t,i){if(e.Utils.augment(this,e.ServerContext,[t,i]),this.ua=t,this.status=c.STATUS_INVITE_RECEIVED,this.from_tag=i.from_tag,this.id=i.call_id+this.from_tag,this.request=i,this.contact=this.ua.contact.toString(),this.logger=t.getLogger("sip.referservercontext",this.id),!this.request.hasHeader("refer-to"))return this.logger.warn("Invalid REFER packet. A refer-to header is required. Rejecting refer."),void this.reject();this.referTo=this.request.parseHeader("refer-to"),this.referredSession=this.ua.findSession(i),this.cseq=Math.floor(1e4*Math.random()),this.call_id=this.request.call_id,this.from_uri=this.request.to.uri,this.from_tag=this.request.to.parameters.tag,this.remote_target=this.request.headers.Contact[0].parsed.uri,this.to_uri=this.request.from.uri,this.to_tag=this.request.from_tag,this.route_set=this.request.getHeaders("record-route"),this.receiveNonInviteResponse=function(){},this.request.hasHeader("referred-by")&&(this.referredBy=this.request.getHeader("referred-by")),this.referTo.uri.hasHeader("replaces")&&(this.replaces=this.referTo.uri.getHeader("replaces")),this.status=c.STATUS_WAITING_FOR_ANSWER}).prototype={progress:function(){if(this.status!==c.STATUS_WAITING_FOR_ANSWER)throw new e.Exceptions.InvalidStateError(this.status);this.request.reply(100)},reject:function(t){if(this.status===c.STATUS_TERMINATED)throw new e.Exceptions.InvalidStateError(this.status);this.logger.log("Rejecting refer"),this.status=c.STATUS_TERMINATED,e.ServerContext.prototype.reject.call(this,t),this.emit("referRequestRejected",this)},accept:function(t,i){if(t=t||{},this.status!==c.STATUS_WAITING_FOR_ANSWER)throw new e.Exceptions.InvalidStateError(this.status);if(this.status=c.STATUS_ANSWERED,this.request.reply(202,"Accepted"),this.emit("referRequestAccepted",this),t.followRefer){this.logger.log("Accepted refer, attempting to automatically follow it");var s=this.referTo.uri;if(!s.scheme.match("^sips?$"))return this.logger.error("SIP.js can only automatically follow SIP refer target"),void this.reject();var r=t.inviteOptions||{},n=(r.extraHeaders||[]).slice();this.replaces&&n.push("Replaces: "+decodeURIComponent(this.replaces)),this.referredBy&&n.push("Referred-By: "+this.referredBy),r.extraHeaders=n,s.clearHeaders(),this.targetSession=this.ua.invite(s,r,i),this.emit("referInviteSent",this),this.targetSession.once("progress",function(){this.sendNotify("SIP/2.0 100 Trying"),this.emit("referProgress",this),this.referredSession&&this.referredSession.emit("referProgress",this)}.bind(this)),this.targetSession.once("accepted",function(){this.logger.log("Successfully followed the refer"),this.sendNotify("SIP/2.0 200 OK"),this.emit("referAccepted",this),this.referredSession&&this.referredSession.emit("referAccepted",this)}.bind(this));var o=function(e){if(this.status!==c.STATUS_TERMINATED){if(this.logger.log("Refer was not successful. Resuming session"),e&&429===e.status_code)return this.logger.log("Alerting referrer that identity is required."),void this.sendNotify("SIP/2.0 429 Provide Referrer Identity");this.sendNotify("SIP/2.0 603 Declined"),this.status=c.STATUS_TERMINATED,this.emit("referRejected",this),this.referredSession&&this.referredSession.emit("referRejected")}};this.targetSession.once("rejected",o.bind(this)),this.targetSession.once("failed",o.bind(this))}else this.logger.log("Accepted refer, but did not automatically follow it"),this.sendNotify("SIP/2.0 200 OK"),this.emit("referAccepted",this),this.referredSession&&this.referredSession.emit("referAccepted",this)},sendNotify:function(t){if(this.status!==c.STATUS_ANSWERED)throw new e.Exceptions.InvalidStateError(this.status);if(-1===e.Grammar.parse(t,"sipfrag"))throw new Error("sipfrag body is required to send notify for refer");var i=new e.OutgoingRequest(e.C.NOTIFY,this.remote_target,this.ua,{cseq:this.cseq+=1,call_id:this.call_id,from_uri:this.from_uri,from_tag:this.from_tag,to_uri:this.to_uri,to_tag:this.to_tag,route_set:this.route_set},["Event: refer","Subscription-State: terminated","Content-Type: message/sipfrag"],t);new e.RequestSender({request:i,onRequestTimeout:function(){},onTransportError:function(){},receiveResponse:function(){}},this.ua).send()}},e.ReferServerContext=n}},function(e,t,i){"use strict";e.exports=function(e){var t;return t=function(i,s,r){var n,o;if(void 0===s)throw new TypeError("Not enough arguments");if(this.logger=i.ua.getLogger("sip.invitecontext.dtmf",i.id),this.owner=i,this.direction=null,r=r||{},n=r.duration||null,o=r.interToneGap||null,"string"==typeof s)s=s.toUpperCase();else{if("number"!=typeof s)throw new TypeError("Invalid tone: "+s);s=s.toString()}if(!s.match(/^[0-9A-D#*]$/))throw new TypeError("Invalid tone: "+s);if(this.tone=s,n&&!e.Utils.isDecimal(n))throw new TypeError("Invalid tone duration: "+n);if(n?n<t.C.MIN_DURATION?(this.logger.warn('"duration" value is lower than the minimum allowed, setting it to '+t.C.MIN_DURATION+" milliseconds"),n=t.C.MIN_DURATION):n>t.C.MAX_DURATION?(this.logger.warn('"duration" value is greater than the maximum allowed, setting it to '+t.C.MAX_DURATION+" milliseconds"),n=t.C.MAX_DURATION):n=Math.abs(n):n=t.C.DEFAULT_DURATION,this.duration=n,o&&!e.Utils.isDecimal(o))throw new TypeError("Invalid interToneGap: "+o);o?o<t.C.MIN_INTER_TONE_GAP?(this.logger.warn('"interToneGap" value is lower than the minimum allowed, setting it to '+t.C.MIN_INTER_TONE_GAP+" milliseconds"),o=t.C.MIN_INTER_TONE_GAP):o=Math.abs(o):o=t.C.DEFAULT_INTER_TONE_GAP,this.interToneGap=o},t.prototype=Object.create(e.EventEmitter.prototype),t.prototype.send=function(t){var i,s={};if(this.direction="outgoing",this.owner.status!==e.Session.C.STATUS_CONFIRMED&&this.owner.status!==e.Session.C.STATUS_WAITING_FOR_ACK)throw new e.Exceptions.InvalidStateError(this.owner.status);i=(t=t||{}).extraHeaders?t.extraHeaders.slice():[],s.contentType="application/dtmf-relay",s.body="Signal= "+this.tone+"\r\n",s.body+="Duration= "+this.duration,this.request=this.owner.dialog.sendRequest(this,e.C.INFO,{extraHeaders:i,body:s}),this.owner.emit("dtmf",this.request,this)},t.prototype.receiveResponse=function(t){var i;switch(!0){case/^1[0-9]{2}$/.test(t.status_code):break;case/^2[0-9]{2}$/.test(t.status_code):this.emit("succeeded",{originator:"remote",response:t});break;default:i=e.Utils.sipErrorCause(t.status_code),this.emit("failed",t,i)}},t.prototype.onRequestTimeout=function(){this.emit("failed",null,e.C.causes.REQUEST_TIMEOUT),this.owner.onRequestTimeout()},t.prototype.onTransportError=function(){this.emit("failed",null,e.C.causes.CONNECTION_ERROR),this.owner.onTransportError()},t.prototype.onDialogError=function(t){this.emit("failed",t,e.C.causes.DIALOG_ERROR),this.owner.onDialogError(t)},t.prototype.init_incoming=function(e){this.direction="incoming",this.request=e,e.reply(200),this.tone&&this.duration?this.owner.emit("dtmf",e,this):this.logger.warn("invalid INFO DTMF received, discarded")},t.C={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500},t}},function(e,t,i){"use strict";e.exports=function(e){e.Subscription=function(t,i,s,r){if(r=Object.create(r||Object.prototype),this.extraHeaders=r.extraHeaders=(r.extraHeaders||[]).slice(),this.id=null,this.state="init",!s)throw new TypeError("Event necessary to create a subscription.");this.event=s,"number"!=typeof r.expires?(t.logger.warn("expires must be a number. Using default of 3600."),this.expires=3600):this.expires=r.expires,this.requestedExpires=this.expires,r.extraHeaders.push("Event: "+this.event),r.extraHeaders.push("Expires: "+this.expires),r.body&&(this.body=r.body),this.contact=t.contact.toString(),r.extraHeaders.push("Contact: "+this.contact),r.extraHeaders.push("Allow: "+e.UA.C.ALLOWED_METHODS.toString()),e.Utils.augment(this,e.ClientContext,[t,e.C.SUBSCRIBE,i,r]),this.logger=t.getLogger("sip.subscription"),this.dialog=null,this.timers={N:null,sub_duration:null},this.errorCodes=[404,405,410,416,480,481,482,483,484,485,489,501,604]},e.Subscription.prototype={subscribe:function(){return"active"===this.state?(this.refresh(),this):"notify_wait"===this.state?this:(e.Timers.clearTimeout(this.timers.sub_duration),e.Timers.clearTimeout(this.timers.N),this.timers.N=e.Timers.setTimeout(this.timer_fire.bind(this),e.Timers.TIMER_N),this.ua.earlySubscriptions[this.request.call_id+this.request.from.parameters.tag+this.event]=this,this.send(),this.state="notify_wait",this)},refresh:function(){"terminated"!==this.state&&"pending"!==this.state&&"notify_wait"!==this.state&&this.dialog.sendRequest(this,e.C.SUBSCRIBE,{extraHeaders:this.extraHeaders,body:this.body})},receiveResponse:function(t){var i,s=e.Utils.getReasonPhrase(t.status_code);"notify_wait"===this.state&&t.status_code>=300||"notify_wait"!==this.state&&-1!==this.errorCodes.indexOf(t.status_code)?this.failed(t,null):/^2[0-9]{2}$/.test(t.status_code)?(this.emit("accepted",t,s),(i=t.getHeader("Expires"))&&i<=this.requestedExpires?(this.expires=i,this.timers.sub_duration=e.Timers.setTimeout(this.refresh.bind(this),900*i)):i?(this.logger.warn("Expires header in a 200-class response to SUBSCRIBE with a higher value than the one in the request"),this.failed(t,e.C.INVALID_EXPIRES_HEADER)):(this.logger.warn("Expires header missing in a 200-class response to SUBSCRIBE"),this.failed(t,e.C.EXPIRES_HEADER_MISSING))):t.statusCode>300&&(this.emit("failed",t,s),this.emit("rejected",t,s))},unsubscribe:function(){var t=[];this.state="terminated",t.push("Event: "+this.event),t.push("Expires: 0"),t.push("Contact: "+this.contact),t.push("Allow: "+e.UA.C.ALLOWED_METHODS.toString()),this.receiveResponse=function(){},this.dialog.sendRequest(this,this.method,{extraHeaders:t,body:this.body}),e.Timers.clearTimeout(this.timers.sub_duration),e.Timers.clearTimeout(this.timers.N),this.timers.N=e.Timers.setTimeout(this.timer_fire.bind(this),e.Timers.TIMER_N)},timer_fire:function(){"terminated"===this.state?(this.terminateDialog(),e.Timers.clearTimeout(this.timers.N),e.Timers.clearTimeout(this.timers.sub_duration),delete this.ua.subscriptions[this.id]):"notify_wait"===this.state||"pending"===this.state?this.close():this.refresh()},close:function(){"notify_wait"===this.state?(this.state="terminated",e.Timers.clearTimeout(this.timers.N),e.Timers.clearTimeout(this.timers.sub_duration),this.receiveResponse=function(){},delete this.ua.earlySubscriptions[this.request.call_id+this.request.from.parameters.tag+this.event]):"terminated"!==this.state&&this.unsubscribe()},createConfirmedDialog:function(t,i){var s;return this.terminateDialog(),s=new e.Dialog(this,t,i),s.invite_seqnum=this.request.cseq,s.local_seqnum=this.request.cseq,!s.error&&(this.dialog=s,!0)},terminateDialog:function(){this.dialog&&(delete this.ua.subscriptions[this.id],this.dialog.terminate(),delete this.dialog)},receiveRequest:function(t){function i(){s.expires&&(e.Timers.clearTimeout(r.timers.sub_duration),s.expires=Math.min(r.expires,Math.max(s.expires,0)),r.timers.sub_duration=e.Timers.setTimeout(r.refresh.bind(r),900*s.expires))}var s,r=this;if(this.matchEvent(t))if(this.dialog||this.createConfirmedDialog(t,"UAS")&&(this.id=this.dialog.id.toString(),delete this.ua.earlySubscriptions[this.request.call_id+this.request.from.parameters.tag+this.event],this.ua.subscriptions[this.id]=this),s=t.parseHeader("Subscription-State"),t.reply(200,e.C.REASON_200),e.Timers.clearTimeout(this.timers.N),this.emit("notify",{request:t}),"terminated"!==this.state)switch(s.state){case"active":this.state="active",i();break;case"pending":"notify_wait"===this.state&&i(),this.state="pending";break;case"terminated":if(e.Timers.clearTimeout(this.timers.sub_duration),s.reason)switch(this.logger.log("terminating subscription with reason "+s.reason),s.reason){case"deactivated":case"timeout":return void this.subscribe();case"probation":case"giveup":return void(s.params&&s.params["retry-after"]?this.timers.sub_duration=e.Timers.setTimeout(r.subscribe.bind(r),s.params["retry-after"]):this.subscribe())}this.close()}else"terminated"===s.state&&(this.terminateDialog(),e.Timers.clearTimeout(this.timers.N),e.Timers.clearTimeout(this.timers.sub_duration),delete this.ua.subscriptions[this.id]);else t.reply(489)},failed:function(e,t){return this.close(),this.emit("failed",e,t),this.emit("rejected",e,t),this},onDialogError:function(t){this.failed(t,e.C.causes.DIALOG_ERROR)},matchEvent:function(e){var t;return e.hasHeader("Event")?e.hasHeader("Subscription-State")?(t=e.parseHeader("event").event,this.event===t||(this.logger.warn("event match failed"),e.reply(481,"Event Match Failed"),!1)):(this.logger.warn("missing Subscription-State header"),!1):(this.logger.warn("missing Event header"),!1)}}}},function(e,t,i){"use strict";(function(t){var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};e.exports=function(e,r){function n(t){if(t instanceof Function)return t.initialize||(t.initialize=function(){return e.Utils.Promise.resolve()}),t}var o,a={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};((o=function(t){function i(e){return s.emit.bind(s,e)}var s=this;a.ACCEPTED_BODY_TYPES=a.ACCEPTED_BODY_TYPES.toString(),this.log=new e.LoggerFactory,this.logger=this.getLogger("sip.ua"),this.cache={credentials:{}},this.configuration={},this.dialogs={},this.applicants={},this.data={},this.sessions={},this.subscriptions={},this.earlySubscriptions={},this.transport=null,this.contact=null,this.status=a.STATUS_INIT,this.error=null,this.transactions={nist:{},nict:{},ist:{},ict:{}},this.transportRecoverAttempts=0,this.transportRecoveryTimer=null,Object.defineProperties(this,{transactionsCount:{get:function(){var e,t=["nist","nict","ist","ict"],i=0;for(e in t)i+=Object.keys(this.transactions[t[e]]).length;return i}},nictTransactionsCount:{get:function(){return Object.keys(this.transactions.nict).length}},nistTransactionsCount:{get:function(){return Object.keys(this.transactions.nist).length}},ictTransactionsCount:{get:function(){return Object.keys(this.transactions.ict).length}},istTransactionsCount:{get:function(){return Object.keys(this.transactions.ist).length}}}),void 0===t?t={}:("string"==typeof t||t instanceof String)&&(t={uri:t}),t.log&&(t.log.hasOwnProperty("builtinEnabled")&&(this.log.builtinEnabled=t.log.builtinEnabled),t.log.hasOwnProperty("level")&&(this.log.level=t.log.level),t.log.hasOwnProperty("connector")&&(this.log.connector=t.log.connector));try{this.loadConfig(t)}catch(e){throw this.status=a.STATUS_NOT_READY,this.error=a.CONFIGURATION_ERROR,e}this.registerContext=new e.RegisterContext(this),this.registerContext.on("failed",i("registrationFailed")),this.registerContext.on("registered",i("registered")),this.registerContext.on("unregistered",i("unregistered")),this.configuration.autostart&&this.start()}).prototype=Object.create(e.EventEmitter.prototype)).register=function(e){return this.configuration.register=!0,this.registerContext.register(e),this},o.prototype.unregister=function(e){this.configuration.register=!1;var t=this.registerContext;return this.afterConnected(t.unregister.bind(t,e)),this},o.prototype.isRegistered=function(){return this.registerContext.registered},o.prototype.isConnected=function(){return!!this.transport&&this.transport.connected},o.prototype.afterConnected=function(e){this.isConnected()?e():this.once("connected",e)},o.prototype.waitForConnected=function(){return new e.Utils.Promise(function(e){this.afterConnected(e)}.bind(this))},o.prototype.invite=function(t,i,s){var r=new e.InviteClientContext(this,t,i,s);return this.waitForConnected().then(function(){r.invite(),this.emit("inviteSent",r)}.bind(this)),r},o.prototype.subscribe=function(t,i,s){var r=new e.Subscription(this,t,i,s);return this.afterConnected(r.subscribe.bind(r)),r},o.prototype.message=function(t,i,s){if(void 0===i)throw new TypeError("Not enough arguments");return(s=Object.create(s||Object.prototype)).contentType||(s.contentType="text/plain"),s.body=i,this.request(e.C.MESSAGE,t,s)},o.prototype.request=function(t,i,s){var r=new e.ClientContext(this,t,i,s);return this.afterConnected(r.send.bind(r)),r},o.prototype.stop=function(){function i(){0===c.nistTransactionsCount&&0===c.nictTransactionsCount&&(c.removeListener("transactionDestroyed",i),c.transport.disconnect())}var s,n,o,c=this;if(this.logger.log("user requested closure..."),this.status===a.STATUS_USER_CLOSED)return this.logger.warn("UA already closed"),this;e.Timers.clearTimeout(this.transportRecoveryTimer),this.logger.log("closing registerContext"),this.registerContext.close();for(s in this.sessions)this.logger.log("closing session "+s),this.sessions[s].terminate();for(n in this.subscriptions)this.logger.log("unsubscribing from subscription "+n),this.subscriptions[n].close();for(n in this.earlySubscriptions)this.logger.log("unsubscribing from early subscription "+n),this.earlySubscriptions[n].close();for(o in this.applicants)this.applicants[o].close();return this.status=a.STATUS_USER_CLOSED,0===this.nistTransactionsCount&&0===this.nictTransactionsCount?this.transport.disconnect():this.on("transactionDestroyed",i),"function"==typeof r.removeEventListener&&(t.chrome&&t.chrome.app&&t.chrome.app.runtime||r.removeEventListener("unload",this.environListener)),this},o.prototype.start=function(){var i;return this.logger.log("user requested startup..."),this.status===a.STATUS_INIT?(i=this.getNextWsServer(),this.status=a.STATUS_STARTING,new e.Transport(this,i)):this.status===a.STATUS_USER_CLOSED?(this.logger.log("resuming"),this.status=a.STATUS_READY,this.transport.connect()):this.status===a.STATUS_STARTING?this.logger.log("UA is in STARTING status, not opening new connection"):this.status===a.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.configuration.autostop&&"function"==typeof r.addEventListener&&(t.chrome&&t.chrome.app&&t.chrome.app.runtime||(this.environListener=this.stop.bind(this),r.addEventListener("unload",this.environListener))),this},o.prototype.normalizeTarget=function(t){return e.Utils.normalizeTarget(t,this.configuration.hostportParams)},o.prototype.saveCredentials=function(e){return this.cache.credentials[e.realm]=this.cache.credentials[e.realm]||{},this.cache.credentials[e.realm][e.uri]=e,this},o.prototype.getCredentials=function(e){var t,i;return t=e.ruri.host,this.cache.credentials[t]&&this.cache.credentials[t][e.ruri]&&((i=this.cache.credentials[t][e.ruri]).method=e.method),i},o.prototype.getLogger=function(e,t){return this.log.getLogger(e,t)},o.prototype.onTransportClosed=function(t){var i,s,r,n=["nict","ict","nist","ist"];for(t.server.status=e.Transport.C.STATUS_DISCONNECTED,this.logger.log("connection state set to "+e.Transport.C.STATUS_DISCONNECTED),r=n.length,i=0;i<r;i++)for(s in this.transactions[n[i]])this.transactions[n[i]][s].onTransportError();this.contact.pub_gruu||this.closeSessionsOnTransportError()},o.prototype.onTransportError=function(t){var i;this.logger.log("transport "+t.server.ws_uri+" failed | connection state set to "+e.Transport.C.STATUS_ERROR),t.server.status=e.Transport.C.STATUS_ERROR,this.emit("disconnected",{transport:t}),this.status!==a.STATUS_USER_CLOSED&&((i=this.getNextWsServer())?new e.Transport(this,i):(this.closeSessionsOnTransportError(),this.error&&this.error===a.NETWORK_ERROR||(this.status=a.STATUS_NOT_READY,this.error=a.NETWORK_ERROR),this.recoverTransport()))},o.prototype.onTransportConnected=function(t){this.transport=t,this.transportRecoverAttempts=0,t.server.status=e.Transport.C.STATUS_READY,this.logger.log("connection state set to "+e.Transport.C.STATUS_READY),this.status!==a.STATUS_USER_CLOSED&&(this.status=a.STATUS_READY,this.error=null,this.configuration.register&&this.configuration.authenticationFactory.initialize().then(function(){this.registerContext.onTransportConnected()}.bind(this)),this.emit("connected",{transport:t}))},o.prototype.onTransportConnecting=function(e,t){this.emit("connecting",{transport:e,attempts:t})},o.prototype.newTransaction=function(e){this.transactions[e.type][e.id]=e,this.emit("newTransaction",{transaction:e})},o.prototype.destroyTransaction=function(e){delete this.transactions[e.type][e.id],this.emit("transactionDestroyed",{transaction:e})},o.prototype.receiveRequest=function(t){function i(e){return e&&e.user===t.ruri.user}var s,r,n,o,c,h,u=t.method;if(!(i(this.configuration.uri)||i(this.contact.uri)||i(this.contact.pub_gruu)||i(this.contact.temp_gruu)))return this.logger.warn("Request-URI does not point to us"),void(t.method!==e.C.ACK&&t.reply_sl(404));if(t.ruri.scheme!==e.C.SIPS){if(!e.Transactions.checkTransaction(this,t))if(u===e.C.OPTIONS?(new e.Transactions.NonInviteServerTransaction(t,this),t.reply(200,null,["Allow: "+e.UA.C.ALLOWED_METHODS.toString(),"Accept: "+a.ACCEPTED_BODY_TYPES])):u===e.C.MESSAGE?((n=new e.ServerContext(this,t)).body=t.body,n.content_type=t.getHeader("Content-Type")||"text/plain",t.reply(200,null),this.emit("message",n)):u!==e.C.INVITE&&u!==e.C.ACK&&new e.ServerContext(this,t),t.to_tag)(s=this.findDialog(t))?(u===e.C.INVITE&&new e.Transactions.InviteServerTransaction(t,this),s.receiveRequest(t)):u===e.C.NOTIFY?(r=this.findSession(t),o=this.findEarlySubscription(t),r?r.receiveRequest(t):o?o.receiveRequest(t):(this.logger.warn("received NOTIFY request for a non existent session or subscription"),t.reply(481,"Subscription does not exist"))):u!==e.C.ACK&&t.reply(481);else switch(u){case e.C.INVITE:if(c=this.configuration.replaces!==e.C.supported.UNSUPPORTED&&t.parseHeader("replaces")){if(!(h=this.dialogs[c.call_id+c.replaces_to_tag+c.replaces_from_tag]))return void t.reply_sl(481,null);if(h.owner.status===e.Session.C.STATUS_TERMINATED)return void t.reply_sl(603,null);if(h.state===e.Dialog.C.STATUS_CONFIRMED&&c.early_only)return void t.reply_sl(486,null)}(r=new e.InviteServerContext(this,t)).replacee=h&&h.owner,this.emit("invite",r);break;case e.C.BYE:t.reply(481);break;case e.C.CANCEL:(r=this.findSession(t))?r.receiveRequest(t):this.logger.warn("received CANCEL request for a non existent session");break;case e.C.ACK:break;case e.C.NOTIFY:this.configuration.allowLegacyNotifications&&this.listeners("notify").length>0?(t.reply(200,null),this.emit("notify",{request:t})):t.reply(481,"Subscription does not exist");break;case e.C.REFER:if(this.logger.log("Received an out of dialog refer"),this.configuration.allowOutOfDialogRefers){this.logger.log("Allow out of dialog refers is enabled on the UA");var l=new e.ReferServerContext(this,t);this.listeners("outOfDialogReferRequested").length?this.emit("outOfDialogReferRequested",l):(this.logger.log("No outOfDialogReferRequest listeners, automatically accepting and following the out of dialog refer"),l.accept({followRefer:!0}));break}t.reply(405);break;default:t.reply(405)}}else t.reply_sl(416)},o.prototype.findSession=function(e){return this.sessions[e.call_id+e.from_tag]||this.sessions[e.call_id+e.to_tag]||null},o.prototype.findDialog=function(e){return this.dialogs[e.call_id+e.from_tag+e.to_tag]||this.dialogs[e.call_id+e.to_tag+e.from_tag]||null},o.prototype.findEarlySubscription=function(e){return this.earlySubscriptions[e.call_id+e.to_tag+e.getHeader("event")]||null},o.prototype.getNextWsServer=function(){var t,i,s,r=[];for(i=this.configuration.wsServers.length,t=0;t<i;t++)(s=this.configuration.wsServers[t]).status!==e.Transport.C.STATUS_ERROR&&(0===r.length?r.push(s):s.weight>r[0].weight?r=[s]:s.weight===r[0].weight&&r.push(s));return t=Math.floor(Math.random()*r.length),r[t]},o.prototype.closeSessionsOnTransportError=function(){var e;for(e in this.sessions)this.sessions[e].onTransportError();this.registerContext.onTransportClosed()},o.prototype.recoverTransport=function(t){var i,s,r,n,o;for(n=(t=t||this).transportRecoverAttempts,s=t.configuration.wsServers.length,i=0;i<s;i++)t.configuration.wsServers[i].status=0;o=t.getNextWsServer(),(r=Math.floor(Math.random()*Math.pow(2,n)+1)*t.configuration.connectionRecoveryMinInterval)>t.configuration.connectionRecoveryMaxInterval&&(this.logger.log("time for next connection attempt exceeds connectionRecoveryMaxInterval, resetting counter"),r=t.configuration.connectionRecoveryMinInterval,n=0),this.logger.log("next connection attempt in "+r+" seconds"),this.transportRecoveryTimer=e.Timers.setTimeout(function(){t.transportRecoverAttempts=n+1,new e.Transport(t,o)},1e3*r)},o.prototype.loadConfig=function(t){function s(e,i){var s=e.replace(/([a-z][A-Z])/g,function(e){return e[0]+"_"+e[1].toLowerCase()});if(e!==s){var r=t.hasOwnProperty(e);t.hasOwnProperty(s)&&(i.warn(s+" is deprecated, please use "+e),r&&i.warn(e+" overriding "+s)),t[e]=r?t[e]:t[s]}}var r,o,a,c,h,u={viaHost:e.Utils.createRandomToken(12)+".invalid",uri:new e.URI("sip","anonymous."+e.Utils.createRandomToken(6),"anonymous.invalid",null,null),wsServers:[{scheme:"WSS",sip_uri:"<sip:edge.sip.onsip.com;transport=ws;lr>",status:0,weight:0,ws_uri:"wss://edge.sip.onsip.com"}],custom:{},displayName:"",password:null,registerExpires:600,register:!0,registrarServer:null,wsServerMaxReconnection:3,wsServerReconnectionTimeout:4,connectionRecoveryMinInterval:2,connectionRecoveryMaxInterval:30,keepAliveInterval:0,extraSupported:[],usePreloadedRoute:!1,userAgentString:e.C.USER_AGENT,noAnswerTimeout:60,traceSip:!1,hackViaTcp:!1,hackIpInContact:!1,hackWssInTransport:!1,hackAllowUnregisteredOptionTags:!1,sessionDescriptionHandlerFactoryOptions:{constraints:{},peerConnectionOptions:{}},contactName:e.Utils.createRandomToken(8),contactTransport:"ws",forceRport:!1,autostart:!0,autostop:!0,rel100:e.C.supported.UNSUPPORTED,replaces:e.C.supported.UNSUPPORTED,sessionDescriptionHandlerFactory:i(27)(e).defaultFactory,authenticationFactory:n(function(t){return new e.DigestAuthentication(t)}),allowLegacyNotifications:!1,allowOutOfDialogRefers:!1},l=this.getConfigurationCheck();for(r in l.mandatory){if(s(r,this.logger),!t.hasOwnProperty(r))throw new e.Exceptions.ConfigurationError(r);if(o=t[r],void 0===(a=l.mandatory[r](o)))throw new e.Exceptions.ConfigurationError(r,o);u[r]=a}for(r in l.optional)if(s(r,this.logger),t.hasOwnProperty(r)){if((o=t[r])instanceof Array&&0===o.length)continue;if(null===o||""===o||void 0===o)continue;if("number"==typeof o&&isNaN(o))continue;if(void 0===(a=l.optional[r](o)))throw new e.Exceptions.ConfigurationError(r,o);u[r]=a}if(u.connectionRecoveryMaxInterval<u.connectionRecoveryMinInterval)throw new e.Exceptions.ConfigurationError("connectionRecoveryMaxInterval",u.connectionRecoveryMaxInterval);0===u.displayName&&(u.displayName="0"),u.instanceId||(u.instanceId=e.Utils.newUUID()),u.sipjsId=e.Utils.createRandomToken(5),(c=u.uri.clone()).user=null,u.hostportParams=c.toRaw().replace(/^sip:/i,""),u.authorizationUser||(u.authorizationUser=u.uri.user),u.registrarServer||((h=u.uri.clone()).user=null,u.registrarServer=h),u.noAnswerTimeout=1e3*u.noAnswerTimeout,u.hackIpInContact&&("boolean"==typeof u.hackIpInContact?u.viaHost=e.Utils.getRandomTestNetIP():"string"==typeof u.hackIpInContact&&(u.viaHost=u.hackIpInContact)),u.hackWssInTransport&&(u.contactTransport="wss"),this.contact={pub_gruu:null,temp_gruu:null,uri:new e.URI("sip",u.contactName,u.viaHost,null,{transport:u.contactTransport}),toString:function(e){var t=(e=e||{}).anonymous||null,i=e.outbound||null,s="<";return s+=t?(this.temp_gruu||"sip:anonymous@anonymous.invalid;transport="+u.contactTransport).toString():(this.pub_gruu||this.uri).toString(),i&&(s+=";ob"),s+=">"}};var d={};for(r in u)d[r]={value:u[r],writable:"register"===r||"custom"===r,configurable:!1};Object.defineProperties(this.configuration,d),this.logger.log("configuration parameters after validation:");for(r in u)switch(r){case"uri":case"registrarServer":case"sessionDescriptionHandlerFactory":this.logger.log("\xb7 "+r+": "+u[r]);break;case"password":this.logger.log("\xb7 "+r+": NOT SHOWN");break;default:this.logger.log("\xb7 "+r+": "+JSON.stringify(u[r]))}},o.prototype.getConfigurationCheck=function(){return{mandatory:{},optional:{uri:function(t){var i;return/^sip:/i.test(t)||(t=e.C.SIP+":"+t),(i=e.URI.parse(t))&&i.user?i:void 0},wsServers:function(t){var i,s,r;if("string"==typeof t)t=[{ws_uri:t}];else{if(!(t instanceof Array))return;for(s=t.length,i=0;i<s;i++)"string"==typeof t[i]&&(t[i]={ws_uri:t[i]})}if(0===t.length)return!1;for(s=t.length,i=0;i<s;i++){if(!t[i].ws_uri)return;if(t[i].weight&&!Number(t[i].weight))return;if(-1===(r=e.Grammar.parse(t[i].ws_uri,"absoluteURI")))return;if(["wss","ws","udp"].indexOf(r.scheme)<0)return;t[i].sip_uri="<sip:"+r.host+(r.port?":"+r.port:"")+";transport="+r.scheme.replace(/^wss$/i,"ws")+";lr>",t[i].weight||(t[i].weight=0),t[i].status=0,t[i].scheme=r.scheme.toUpperCase()}return t},authorizationUser:function(t){return-1===e.Grammar.parse('"'+t+'"',"quoted_string")?void 0:t},connectionRecoveryMaxInterval:function(t){var i;if(e.Utils.isDecimal(t)&&(i=Number(t))>0)return i},connectionRecoveryMinInterval:function(t){var i;if(e.Utils.isDecimal(t)&&(i=Number(t))>0)return i},displayName:function(t){return-1===e.Grammar.parse('"'+t+'"',"displayName")?void 0:t},hackViaTcp:function(e){if("boolean"==typeof e)return e},hackIpInContact:function(t){return"boolean"==typeof t?t:"string"==typeof t&&-1!==e.Grammar.parse(t,"host")?t:void 0},hackWssInTransport:function(e){if("boolean"==typeof e)return e},hackAllowUnregisteredOptionTags:function(e){if("boolean"==typeof e)return e},contactTransport:function(e){if("string"==typeof e)return e},forceRport:function(e){if("boolean"==typeof e)return e},instanceId:function(t){if("string"==typeof t)return/^uuid:/i.test(t)&&(t=t.substr(5)),-1===e.Grammar.parse(t,"uuid")?void 0:t},keepAliveInterval:function(t){var i;if(e.Utils.isDecimal(t)&&(i=Number(t))>0)return i},extraSupported:function(e){var t,i;if(e instanceof Array){for(i=e.length,t=0;t<i;t++)if("string"!=typeof e[t])return;return e}},noAnswerTimeout:function(t){var i;if(e.Utils.isDecimal(t)&&(i=Number(t))>0)return i},password:function(e){return String(e)},rel100:function(t){return t===e.C.supported.REQUIRED?e.C.supported.REQUIRED:t===e.C.supported.SUPPORTED?e.C.supported.SUPPORTED:e.C.supported.UNSUPPORTED},replaces:function(t){return t===e.C.supported.REQUIRED?e.C.supported.REQUIRED:t===e.C.supported.SUPPORTED?e.C.supported.SUPPORTED:e.C.supported.UNSUPPORTED},register:function(e){if("boolean"==typeof e)return e},registerExpires:function(t){var i;if(e.Utils.isDecimal(t)&&(i=Number(t))>0)return i},registrarServer:function(t){var i;if("string"==typeof t)return/^sip:/i.test(t)||(t=e.C.SIP+":"+t),(i=e.URI.parse(t))?i.user?void 0:i:void 0},traceSip:function(e){if("boolean"==typeof e)return e},userAgentString:function(e){if("string"==typeof e)return e},usePreloadedRoute:function(e){if("boolean"==typeof e)return e},wsServerMaxReconnection:function(t){var i;if(e.Utils.isDecimal(t)&&(i=Number(t))>0)return i},wsServerReconnectionTimeout:function(t){var i;if(e.Utils.isDecimal(t)&&(i=Number(t))>0)return i},autostart:function(e){if("boolean"==typeof e)return e},autostop:function(e){if("boolean"==typeof e)return e},sessionDescriptionHandlerFactory:function(e){if(e instanceof Function)return e},sessionDescriptionHandlerFactoryOptions:function(e){if("object"===(void 0===e?"undefined":s(e)))return e},authenticationFactory:n,allowLegacyNotifications:function(e){if("boolean"==typeof e)return e},custom:function(e){if("object"===(void 0===e?"undefined":s(e)))return e},contactName:function(e){if("string"==typeof e)return e}}}},o.C=a,e.UA=o}}).call(t,i(0))},function(e,t,i){"use strict";(function(t){e.exports=function(e){var i=function(e,i){this.options=i||{},this.logger=e.ua.getLogger("sip.invitecontext.sessionDescriptionHandler",e.id),this.session=e,this.CONTENT_TYPE="application/sdp",this.modifiers=this.options.modifiers||[],Array.isArray(this.modifiers)||(this.modifiers=[this.modifiers]);var s=t.window||t;this.WebRTC={MediaStream:s.MediaStream,getUserMedia:s.navigator.mediaDevices.getUserMedia.bind(s.navigator.mediaDevices),RTCPeerConnection:s.RTCPeerConnection,RTCSessionDescription:s.RTCSessionDescription},this.iceGatheringDeferred=null,this.iceGatheringTimeout=!1,this.iceGatheringTimer=null,this.initPeerConnection(this.options.peerConnectionOptions),this.constraints=this.checkAndDefaultConstraints(this.options.constraints),this.session.emit("SessionDescriptionHandler-created",this)};return i.defaultFactory=function(e,t){return new i(e,t)},i.prototype=Object.create(e.SessionDescriptionHandler.prototype,{close:{writable:!0,value: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())}},getDescription:{writable:!0,value:function(t,i){var s=this,r=!0;if(this.session.disableRenegotiation)return this.logger.warn('The flag "disableRenegotiation" is set to true for this session description handler. We will not try to renegotiate.'),e.Utils.Promise.reject(new e.Exceptions.RenegotiationError("disableRenegotiation flag set to true for this session description handler"));(t=t||{}).peerConnectionOptions&&this.initPeerConnection(t.peerConnectionOptions);var n=Object.assign({},this.constraints,t.constraints);return n=this.checkAndDefaultConstraints(n),JSON.stringify(n)!==JSON.stringify(this.constraints)?this.constraints=n:r=!1,i=i||[],Array.isArray(i)||(i=[i]),i=i.concat(this.modifiers),!r&&this.peerConnection.localDescription&&this.peerConnection.localDescription.sdp&&""!==this.peerConnection.localDescription.sdp?this.createOfferOrAnswer(t.RTCOfferOptions,i).then(function(e){return{body:e,contentType:s.CONTENT_TYPE}}):(s.logger.log("acquiring local media"),this.acquire(s.constraints).then(function(e){return s.logger.log("acquired local media streams"),e},function(e){throw s.logger.error("unable to acquire streams"),s.logger.error(e),e}).then(function(t){try{(t=[].concat(t)).forEach(function(e){s.peerConnection.addTrack?e.getTracks().forEach(function(t){s.peerConnection.addTrack(t,e)}):s.peerConnection.addStream(e)},this)}catch(t){return s.logger.error("error adding stream"),s.logger.error(t),e.Utils.Promise.reject(t)}return e.Utils.Promise.resolve()}).then(function(){return s.createOfferOrAnswer(t.RTCOfferOptions,i)}).then(function(e){return{body:e,contentType:s.CONTENT_TYPE}}).catch(function(e){throw this.session.disableRenegotiation=!0,e}))}},hasDescription:{writable:!0,value:function(e){return e===this.CONTENT_TYPE}},holdModifier:{writable:!0,value:function(t){return/a=(sendrecv|sendonly|recvonly|inactive)/.test(t.sdp)?(t.sdp=t.sdp.replace(/a=sendrecv\r\n/g,"a=sendonly\r\n"),t.sdp=t.sdp.replace(/a=recvonly\r\n/g,"a=inactive\r\n")):t.sdp=t.sdp.replace(/(m=[^\r]*\r\n)/g,"$1a=sendonly\r\n"),e.Utils.Promise.resolve(t)}},setDescription:{writable:!0,value:function(t,i,s){var r=this,n="undefined"!=typeof InstallTrigger;if(!this.session.disableRenegotiation&&n&&this.peerConnection&&this.isVideoHold(t)&&(this.session.disableRenegotiation=!0),this.session.disableRenegotiation)return this.logger.warn('The flag "disableRenegotiation" is set to true for this session description handler. We will not try to renegotiate.'),e.Utils.Promise.reject(new e.Exceptions.RenegotiationError("disableRenegotiation flag set to true for this session description handler"));(i=i||{}).peerConnectionOptions&&this.initPeerConnection(i.peerConnectionOptions),this.constraints=Object.assign({},this.constraints,i.constraints),this.constraints=this.checkAndDefaultConstraints(this.constraints),s=s||[],Array.isArray(s)||(s=[s]),s=s.concat(this.modifiers);var o={type:this.hasOffer("local")?"answer":"offer",sdp:t};return e.Utils.reducePromises(s,o).catch(function(e){throw r.logger.error("The modifiers did not resolve successfully"),r.logger.error(e),e}).then(function(e){return r.emit("setDescription",e),r.peerConnection.setRemoteDescription(new r.WebRTC.RTCSessionDescription(e))}).catch(function(e){throw r.session.disableRenegotiation=!0,r.logger.error(e),r.emit("peerConnection-setRemoteDescriptionFailed",e),e}).then(function(){r.peerConnection.getReceivers?r.emit("setRemoteDescription",r.peerConnection.getReceivers()):r.emit("setRemoteDescription",r.peerConnection.getRemoteStreams()),r.emit("confirmed",r)})}},createOfferOrAnswer:{writable:!0,value:function(t,i){var s,r=this,n=this.peerConnection;return t=t||{},s=r.hasOffer("remote")?"createAnswer":"createOffer",n[s](t).catch(function(e){throw r.emit("peerConnection-"+s+"Failed",e),e}).then(function(t){return e.Utils.reducePromises(i,t)}).then(function(e){return r.logger.log(e),n.setLocalDescription(e)}).catch(function(e){throw r.emit("peerConnection-SetLocalDescriptionFailed",e),e}).then(function(){return r.waitForIceGatheringComplete()}).then(function(){var t=r.peerConnection.localDescription;return e.Utils.reducePromises(i,t)}).then(function(e){return r.emit("getDescription",e),e.sdp}).catch(function(t){throw r.logger.error(t),new e.Exceptions.GetDescriptionError(t)})}},addDefaultIceCheckingTimeout:{writable:!0,value:function(e){return void 0===e.iceCheckingTimeout&&(e.iceCheckingTimeout=5e3),e}},addDefaultIceServers:{writable:!0,value:function(e){return e.iceServers||(e.iceServers=[{urls:"stun:stun.l.google.com:19302"}]),e}},checkAndDefaultConstraints:{writable:!0,value:function(e){var t={audio:!0,video:!0};return e=e||t,0===Object.keys(e).length&&e.constructor===Object?t:e}},initPeerConnection:{writable:!0,value:function(t){var i=this;t=t||{},(t=this.addDefaultIceCheckingTimeout(t)).rtcConfiguration=t.rtcConfiguration||{},t.rtcConfiguration=this.addDefaultIceServers(t.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 this.WebRTC.RTCPeerConnection(t.rtcConfiguration),this.logger.log("New peer connection created"),this.session.emit("peerConnection-created",this.peerConnection),this.peerConnection.ontrack=function(e){i.logger.log("track added"),i.emit("addTrack",e)},this.peerConnection.onaddstream=function(e){i.logger.warn("Using deprecated stream API"),i.logger.log("stream added"),i.emit("addStream",e)},this.peerConnection.onremovestream=function(e){i.logger.log("stream removed: "+e.stream.id)},this.peerConnection.onicecandidate=function(e){i.emit("iceCandidate",e),e.candidate&&i.logger.log("ICE candidate received: "+(null===e.candidate.candidate?null:e.candidate.candidate.trim()))},this.peerConnection.onicegatheringstatechange=function(){switch(i.logger.log("RTCIceGatheringState changed: "+this.iceGatheringState),this.iceGatheringState){case"gathering":i.emit("iceGathering",this),!i.iceGatheringTimer&&t.iceCheckingTimeout&&(i.iceGatheringTimeout=!1,i.iceGatheringTimer=e.Timers.setTimeout(function(){i.logger.log("RTCIceChecking Timeout Triggered after "+t.iceCheckingTimeout+" milliseconds"),i.iceGatheringTimeout=!0,i.triggerIceGatheringComplete()},t.iceCheckingTimeout));break;case"complete":i.triggerIceGatheringComplete()}},this.peerConnection.oniceconnectionstatechange=function(){var e;switch(this.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 i.logger.warn("Unknown iceConnection state:",this.iceConnectionState)}i.emit(e,this)}}},acquire:{writable:!0,value:function(t){return t=this.checkAndDefaultConstraints(t),new e.Utils.Promise(function(e,i){this.emit("userMediaRequest",t);var s=function(e,t){var i=Array.prototype.slice.call(arguments,2),s=[e].concat(i);return this.emit.apply(this,s),t.apply(null,i)}.bind(this);t.audio||t.video?this.WebRTC.getUserMedia(t).then(s.bind(this,"userMedia",function(t){e(t)}),s.bind(this,"userMediaFailed",function(e){throw i(e),e})):e([])}.bind(this))}},isVideoHold:{writable:!0,value:function(e){return-1!==e.search(/^(m=video.*?)[\s\S]*^(a=sendonly?)/gm)}},hasOffer:{writable:!0,value:function(e){var t="have-"+e+"-offer";return this.peerConnection.signalingState===t}},isIceGatheringComplete:{writable:!0,value:function(){return"complete"===this.peerConnection.iceGatheringState||this.iceGatheringTimeout}},resetIceGatheringComplete:{writable:!0,value:function(){this.iceGatheringTimeout=!1,this.iceGatheringTimer&&(e.Timers.clearTimeout(this.iceGatheringTimer),this.iceGatheringTimer=null),this.iceGatheringDeferred&&(this.iceGatheringDeferred.reject(),this.iceGatheringDeferred=null)}},triggerIceGatheringComplete:{writable:!0,value:function(){this.isIceGatheringComplete()&&(this.emit("iceGatheringComplete",this),this.iceGatheringTimer&&(e.Timers.clearTimeout(this.iceGatheringTimer),this.iceGatheringTimer=null),this.iceGatheringDeferred&&(this.iceGatheringDeferred.resolve(),this.iceGatheringDeferred=null))}},waitForIceGatheringComplete:{writable:!0,value:function(){return this.isIceGatheringComplete()?e.Utils.Promise.resolve():(this.isIceGatheringDeferred||(this.iceGatheringDeferred=e.Utils.defer()),this.iceGatheringDeferred.promise)}}}),i}}).call(t,i(0))},function(e,t,i){"use strict";e.exports=function(e){function t(t,i,s){for(var r,n=e.Utils.buildStatusLine(t),o=i.getHeaders("via"),a=o.length,c=0;c<a;c++)n+="Via: "+o[c]+"\r\n";r=i.getHeader("To"),i.to_tag||(r+=";tag="+e.Utils.newTag()),n+="To: "+r+"\r\n",n+="From: "+i.getHeader("From")+"\r\n",n+="Call-ID: "+i.call_id+"\r\n",n+="CSeq: "+i.cseq+" "+i.method+"\r\n",n+="\r\n",s.send(n)}var i,s=[],r=[],n=[];s.push(function(e,i,s){if(!e.ruri||"sip"!==e.ruri.scheme)return t(416,e,s),!1}),s.push(function(e,i,s){if(!e.to_tag&&e.call_id.substr(0,5)===i.configuration.sipjsId)return t(482,e,s),!1}),s.push(function(i,s,r){if(e.Utils.str_utf8_length(i.body)<i.getHeader("content-length"))return t(400,i,r),!1}),s.push(function(i,s,r){var n,o,a=i.from_tag,c=i.call_id,h=i.cseq;if(!i.to_tag)if(i.method===e.C.INVITE){if(n=s.transactions.ist[i.via_branch])return;for(o in s.transactions.ist)if((n=s.transactions.ist[o]).request.from_tag===a&&n.request.call_id===c&&n.request.cseq===h)return t(482,i,r),!1}else{if(n=s.transactions.nist[i.via_branch])return;for(o in s.transactions.nist)if((n=s.transactions.nist[o]).request.from_tag===a&&n.request.call_id===c&&n.request.cseq===h)return t(482,i,r),!1}}),r.push(function(e,t){if(e.getHeaders("via").length>1)return t.getLogger("sip.sanitycheck").warn("More than one Via header field present in the response. Dropping the response"),!1}),r.push(function(e,t){var i=t.configuration.viaHost;if(e.via.host!==i||void 0!==e.via.port)return t.getLogger("sip.sanitycheck").warn("Via sent-by in the response does not match UA Via host value. Dropping the response"),!1}),r.push(function(t,i){if(e.Utils.str_utf8_length(t.body)<t.getHeader("content-length"))return i.getLogger("sip.sanitycheck").warn("Message body length is lower than the value in Content-Length header field. Dropping the response"),!1}),n.push(function(e,t){for(var i=["from","to","call_id","cseq","via"],s=i.length;s--;)if(!e.hasHeader(i[s]))return t.getLogger("sip.sanitycheck").warn("Missing mandatory header field : "+i[s]+". Dropping the response"),!1}),i=function(t,i,o){var a;for(a=n.length;a--;)if(!1===n[a](t,i,o))return!1;if(t instanceof e.IncomingRequest){for(a=s.length;a--;)if(!1===s[a](t,i,o))return!1}else if(t instanceof e.IncomingResponse)for(a=r.length;a--;)if(!1===r[a](t,i,o))return!1;return!0},e.sanityCheck=i}},function(e,t,i){"use strict";e.exports=function(e){var t;return t=function(e){this.logger=e.getLogger("sipjs.digestauthentication"),this.username=e.configuration.authorizationUser,this.password=e.configuration.password,this.cnonce=null,this.nc=0,this.ncHex="00000000",this.response=null},t.prototype.authenticate=function(t,i){if(this.algorithm=i.algorithm,this.realm=i.realm,this.nonce=i.nonce,this.opaque=i.opaque,this.stale=i.stale,this.algorithm){if("MD5"!==this.algorithm)return 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(i.qop)if(i.qop.indexOf("auth")>-1)this.qop="auth";else{if(!(i.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=null;return this.method=t.method,this.uri=t.ruri,this.cnonce=e.createRandomToken(12),this.nc+=1,this.updateNcHex(),4294967296===this.nc&&(this.nc=1,this.ncHex="00000001"),this.calculateResponse(),!0},t.prototype.calculateResponse=function(){var t,i;t=e.calculateMD5(this.username+":"+this.realm+":"+this.password),"auth"===this.qop?(i=e.calculateMD5(this.method+":"+this.uri),this.response=e.calculateMD5(t+":"+this.nonce+":"+this.ncHex+":"+this.cnonce+":auth:"+i)):"auth-int"===this.qop?(i=e.calculateMD5(this.method+":"+this.uri+":"+e.calculateMD5(this.body?this.body:"")),this.response=e.calculateMD5(t+":"+this.nonce+":"+this.ncHex+":"+this.cnonce+":auth-int:"+i)):null===this.qop&&(i=e.calculateMD5(this.method+":"+this.uri),this.response=e.calculateMD5(t+":"+this.nonce+":"+i))},t.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(", ")},t.prototype.updateNcHex=function(){var e=Number(this.nc).toString(16);this.ncHex="00000000".substr(0,8-e.length)+e},t}},function(e,t,i){"use strict";var s=i(31);e.exports=function(e){return{parse:function(t,i){var r={startRule:i,SIP:e};try{s.parse(t,r)}catch(e){r.data=-1}return r.data}}}},function(e,t,i){"use strict";function s(e,t,i,r){this.message=e,this.expected=t,this.found=i,this.location=r,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,s)}!function(e,t){function i(){this.constructor=e}i.prototype=t.prototype,e.prototype=new i}(s,Error),s.buildMessage=function(e,t){function i(e){return e.charCodeAt(0).toString(16).toUpperCase()}function s(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"+i(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+i(e)})}function r(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"+i(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+i(e)})}function n(e){return o[e.type](e)}var o={literal:function(e){return'"'+s(e.text)+'"'},class:function(e){var t,i="";for(t=0;t<e.parts.length;t++)i+=e.parts[t]instanceof Array?r(e.parts[t][0])+"-"+r(e.parts[t][1]):r(e.parts[t]);return"["+(e.inverted?"^":"")+i+"]"},any:function(e){return"any character"},end:function(e){return"end of input"},other:function(e){return e.description}};return"Expected "+function(e){var t,i,s=new Array(e.length);for(t=0;t<e.length;t++)s[t]=n(e[t]);if(s.sort(),s.length>0){for(t=1,i=1;t<s.length;t++)s[t-1]!==s[t]&&(s[i]=s[t],i++);s.length=i}switch(s.length){case 1:return s[0];case 2:return s[0]+" or "+s[1];default:return s.slice(0,-1).join(", ")+", or "+s[s.length-1]}}(e)+" but "+function(e){return e?'"'+s(e)+'"':"end of input"}(t)+" found."},e.exports={SyntaxError:s,parse:function(e,t){function i(){return e.substring(S,E)}function r(){return c(S,E)}function n(e,t){return{type:"literal",text:e,ignoreCase:t}}function o(e,t,i){return{type:"class",parts:e,inverted:t,ignoreCase:i}}function a(t){var i,s=C[t];if(s)return s;for(i=t-1;!C[i];)i--;for(s={line:(s=C[i]).line,column:s.column};i<t;)10===e.charCodeAt(i)?(s.line++,s.column=1):s.column++,i++;return C[t]=s,s}function c(e,t){var i=a(e),s=a(t);return{start:{offset:e,line:i.line,column:i.column},end:{offset:t,line:s.line,column:s.column}}}function h(e){E<R||(E>R&&(R=E,v=[]),v.push(e))}function u(e,t,i){return new s(s.buildMessage(e,t),e,t,i)}function l(e){var t,i=new Array(e.length);for(t=0;t<e.length;t++)i[t]=e.charCodeAt(t)-32;return i}function d(t){for(var i,s,r=_[t],n=0,o=[],a=r.length,c=[],u=[];;){for(;n<a;)switch(r[n]){case 0:u.push(m[r[n+1]]),n+=2;break;case 1:u.push(void 0),n++;break;case 2:u.push(null),n++;break;case 3:u.push(g),n++;break;case 4:u.push([]),n++;break;case 5:u.push(E),n++;break;case 6:u.pop(),n++;break;case 7:E=u.pop(),n++;break;case 8:u.length-=r[n+1],n+=2;break;case 9:u.splice(-2,1),n++;break;case 10:u[u.length-2].push(u.pop()),n++;break;case 11:u.push(u.splice(u.length-r[n+1],r[n+1])),n+=2;break;case 12:u.push(e.substring(u.pop(),E)),n++;break;case 13:c.push(a),o.push(n+3+r[n+1]+r[n+2]),u[u.length-1]?(a=n+3+r[n+1],n+=3):(a=n+3+r[n+1]+r[n+2],n+=3+r[n+1]);break;case 14:c.push(a),o.push(n+3+r[n+1]+r[n+2]),u[u.length-1]===g?(a=n+3+r[n+1],n+=3):(a=n+3+r[n+1]+r[n+2],n+=3+r[n+1]);break;case 15:c.push(a),o.push(n+3+r[n+1]+r[n+2]),u[u.length-1]!==g?(a=n+3+r[n+1],n+=3):(a=n+3+r[n+1]+r[n+2],n+=3+r[n+1]);break;case 16:u[u.length-1]!==g?(c.push(a),o.push(n),a=n+2+r[n+1],n+=2):n+=2+r[n+1];break;case 17:c.push(a),o.push(n+3+r[n+1]+r[n+2]),e.length>E?(a=n+3+r[n+1],n+=3):(a=n+3+r[n+1]+r[n+2],n+=3+r[n+1]);break;case 18:c.push(a),o.push(n+4+r[n+2]+r[n+3]),e.substr(E,m[r[n+1]].length)===m[r[n+1]]?(a=n+4+r[n+2],n+=4):(a=n+4+r[n+2]+r[n+3],n+=4+r[n+2]);break;case 19:c.push(a),o.push(n+4+r[n+2]+r[n+3]),e.substr(E,m[r[n+1]].length).toLowerCase()===m[r[n+1]]?(a=n+4+r[n+2],n+=4):(a=n+4+r[n+2]+r[n+3],n+=4+r[n+2]);break;case 20:c.push(a),o.push(n+4+r[n+2]+r[n+3]),m[r[n+1]].test(e.charAt(E))?(a=n+4+r[n+2],n+=4):(a=n+4+r[n+2]+r[n+3],n+=4+r[n+2]);break;case 21:u.push(e.substr(E,r[n+1])),E+=r[n+1],n+=2;break;case 22:u.push(m[r[n+1]]),E+=m[r[n+1]].length,n+=2;break;case 23:u.push(g),0===A&&h(m[r[n+1]]),n+=2;break;case 24:S=u[u.length-1-r[n+1]],n+=2;break;case 25:S=E,n++;break;case 26:for(i=r.slice(n+4,n+4+r[n+3]),s=0;s<r[n+3];s++)i[s]=u[u.length-1-i[s]];u.splice(u.length-r[n+2],r[n+2],m[r[n+1]].apply(null,i)),n+=4+r[n+3];break;case 27:u.push(d(r[n+1])),n+=2;break;case 28:A++,n++;break;case 29:A--,n++;break;default:throw new Error("Invalid opcode: "+r[n]+".")}if(!(c.length>0))break;a=c.pop(),n=o.pop()}return u[0]}t=void 0!==t?t:{};var p,g={},f={Contact:118,Name_Addr_Header:155,Record_Route:175,Request_Response:81,SIP_URI:45,Subscription_State:185,Supported:190,Require:181,Via:193,absoluteURI:84,Call_ID:117,Content_Disposition:129,Content_Length:134,Content_Type:135,CSeq:145,displayName:121,Event:148,From:150,host:52,Max_Forwards:153,Min_SE:212,Proxy_Authenticate:156,quoted_string:40,Refer_To:177,Replaces:178,Session_Expires:209,stun_URI:216,To:191,turn_URI:222,uuid:225,WWW_Authenticate:208,challenge:157,sipfrag:229,Referred_By:230},T=118,m=["\r\n",n("\r\n",!1),/^[0-9]/,o([["0","9"]],!1,!1),/^[a-zA-Z]/,o([["a","z"],["A","Z"]],!1,!1),/^[0-9a-fA-F]/,o([["0","9"],["a","f"],["A","F"]],!1,!1),/^[\0-\xFF]/,o([["\0","\xff"]],!1,!1),/^["]/,o(['"'],!1,!1)," ",n(" ",!1),"\t",n("\t",!1),/^[a-zA-Z0-9]/,o([["a","z"],["A","Z"],["0","9"]],!1,!1),";",n(";",!1),"/",n("/",!1),"?",n("?",!1),":",n(":",!1),"@",n("@",!1),"&",n("&",!1),"=",n("=",!1),"+",n("+",!1),"$",n("$",!1),",",n(",",!1),"-",n("-",!1),"_",n("_",!1),".",n(".",!1),"!",n("!",!1),"~",n("~",!1),"*",n("*",!1),"'",n("'",!1),"(",n("(",!1),")",n(")",!1),"%",n("%",!1),function(){return" "},function(){return":"},/^[!-~]/,o([["!","~"]],!1,!1),/^[\x80-\uFFFF]/,o([["\x80","\uffff"]],!1,!1),/^[\x80-\xBF]/,o([["\x80","\xbf"]],!1,!1),/^[a-f]/,o([["a","f"]],!1,!1),"`",n("`",!1),"<",n("<",!1),">",n(">",!1),"\\",n("\\",!1),"[",n("[",!1),"]",n("]",!1),"{",n("{",!1),"}",n("}",!1),function(){return"*"},function(){return"/"},function(){return"="},function(){return"("},function(){return")"},function(){return">"},function(){return"<"},function(){return","},function(){return";"},function(){return":"},function(){return'"'},/^[!-']/,o([["!","'"]],!1,!1),/^[*-[]/,o([["*","["]],!1,!1),/^[\]-~]/,o([["]","~"]],!1,!1),function(e){return e},/^[#-[]/,o([["#","["]],!1,!1),/^[\0-\t]/,o([["\0","\t"]],!1,!1),/^[\x0B-\f]/,o([["\v","\f"]],!1,!1),/^[\x0E-\x7F]/,o([["\x0e","\x7f"]],!1,!1),function(){t.data.uri=new t.SIP.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.data.uri=new t.SIP.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",n("sips",!0),"sip",n("sip",!0),function(e){t.data.scheme=e},function(){t.data.user=decodeURIComponent(i().slice(0,-1))},function(){t.data.password=i()},function(){return t.data.host=i(),t.data.host},function(){return t.data.host_type="domain",i()},/^[a-zA-Z0-9_\-]/,o([["a","z"],["A","Z"],["0","9"],"_","-"],!1,!1),/^[a-zA-Z0-9\-]/,o([["a","z"],["A","Z"],["0","9"],"-"],!1,!1),function(){return t.data.host_type="IPv6",i()},"::",n("::",!1),function(){return t.data.host_type="IPv6",i()},function(){return t.data.host_type="IPv4",i()},"25",n("25",!1),/^[0-5]/,o([["0","5"]],!1,!1),"2",n("2",!1),/^[0-4]/,o([["0","4"]],!1,!1),"1",n("1",!1),/^[1-9]/,o([["1","9"]],!1,!1),function(e){return e=parseInt(e.join("")),t.data.port=e,e},"transport=",n("transport=",!0),"udp",n("udp",!0),"tcp",n("tcp",!0),"sctp",n("sctp",!0),"tls",n("tls",!0),function(e){t.data.uri_params||(t.data.uri_params={}),t.data.uri_params.transport=e.toLowerCase()},"user=",n("user=",!0),"phone",n("phone",!0),"ip",n("ip",!0),function(e){t.data.uri_params||(t.data.uri_params={}),t.data.uri_params.user=e.toLowerCase()},"method=",n("method=",!0),function(e){t.data.uri_params||(t.data.uri_params={}),t.data.uri_params.method=e},"ttl=",n("ttl=",!0),function(e){t.data.params||(t.data.params={}),t.data.params.ttl=e},"maddr=",n("maddr=",!0),function(e){t.data.uri_params||(t.data.uri_params={}),t.data.uri_params.maddr=e},"lr",n("lr",!0),function(){t.data.uri_params||(t.data.uri_params={}),t.data.uri_params.lr=void 0},function(e,i){t.data.uri_params||(t.data.uri_params={}),i=null===i?void 0:i[1],t.data.uri_params[e.toLowerCase()]=i&&i.toLowerCase()},function(e,i){e=e.join("").toLowerCase(),i=i.join(""),t.data.uri_headers||(t.data.uri_headers={}),t.data.uri_headers[e]?t.data.uri_headers[e].push(i):t.data.uri_headers[e]=[i]},function(){"Refer_To"===t.startRule&&(t.data.uri=new t.SIP.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)},"//",n("//",!1),function(){t.data.scheme=i()},n("SIP",!0),function(){t.data.sip_version=i()},"INVITE",n("INVITE",!1),"ACK",n("ACK",!1),"VXACH",n("VXACH",!1),"OPTIONS",n("OPTIONS",!1),"BYE",n("BYE",!1),"CANCEL",n("CANCEL",!1),"REGISTER",n("REGISTER",!1),"SUBSCRIBE",n("SUBSCRIBE",!1),"NOTIFY",n("NOTIFY",!1),"REFER",n("REFER",!1),function(){return t.data.method=i(),t.data.method},function(e){t.data.status_code=parseInt(e.join(""))},function(){t.data.reason_phrase=i()},function(){t.data=i()},function(){var e,i;for(i=t.data.multi_header.length,e=0;e<i;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.data.multi_header||(t.data.multi_header=[]);try{e=new t.SIP.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:E,offset:r().start.offset,parsed:e})},function(e){'"'===(e=i().trim())[0]&&(e=e.substring(1,e.length-1)),t.data.displayName=e},"q",n("q",!0),function(e){t.data.params||(t.data.params={}),t.data.params.q=e},"expires",n("expires",!0),function(e){t.data.params||(t.data.params={}),t.data.params.expires=e},function(e){return parseInt(e.join(""))},"0",n("0",!1),function(){return parseFloat(i())},function(e,i){t.data.params||(t.data.params={}),i=null===i?void 0:i[1],t.data.params[e.toLowerCase()]=i},"render",n("render",!0),"session",n("session",!0),"icon",n("icon",!0),"alert",n("alert",!0),function(){"Content_Disposition"===t.startRule&&(t.data.type=i().toLowerCase())},"handling",n("handling",!0),"optional",n("optional",!0),"required",n("required",!0),function(e){t.data=parseInt(e.join(""))},function(){t.data=i()},"text",n("text",!0),"image",n("image",!0),"audio",n("audio",!0),"video",n("video",!0),"application",n("application",!0),"message",n("message",!0),"multipart",n("multipart",!0),"x-",n("x-",!0),function(e){t.data.value=parseInt(e.join(""))},function(e){t.data=e},function(e){t.data.event=e.toLowerCase()},function(){var e=t.data.tag;t.data=new t.SIP.NameAddrHeader(t.data.uri,t.data.displayName,t.data.params),e&&t.data.setParam("tag",e)},"tag",n("tag",!0),function(e){t.data.tag=e},function(e){t.data=parseInt(e.join(""))},function(e){t.data=e},function(){t.data=new t.SIP.NameAddrHeader(t.data.uri,t.data.displayName,t.data.params)},"digest",n("Digest",!0),"realm",n("realm",!0),function(e){t.data.realm=e},"domain",n("domain",!0),"nonce",n("nonce",!0),function(e){t.data.nonce=e},"opaque",n("opaque",!0),function(e){t.data.opaque=e},"stale",n("stale",!0),"true",n("true",!0),function(){t.data.stale=!0},"false",n("false",!0),function(){t.data.stale=!1},"algorithm",n("algorithm",!0),"md5",n("MD5",!0),"md5-sess",n("MD5-sess",!0),function(e){t.data.algorithm=e.toUpperCase()},"qop",n("qop",!0),"auth-int",n("auth-int",!0),"auth",n("auth",!0),function(e){t.data.qop||(t.data.qop=[]),t.data.qop.push(e.toLowerCase())},function(e){t.data.value=parseInt(e.join(""))},function(){var e,i;for(i=t.data.multi_header.length,e=0;e<i;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.data.multi_header||(t.data.multi_header=[]);try{e=new t.SIP.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:E,offset:r().start.offset,parsed:e})},function(){t.data=new t.SIP.NameAddrHeader(t.data.uri,t.data.displayName,t.data.params)},function(){t.data.replaces_from_tag&&t.data.replaces_to_tag||(t.data=-1)},function(){t.data={call_id:t.data}},"from-tag",n("from-tag",!0),function(e){t.data.replaces_from_tag=e},"to-tag",n("to-tag",!0),function(e){t.data.replaces_to_tag=e},"early-only",n("early-only",!0),function(){t.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.startRule&&(t.data=e||[])},function(e){t.data.value=parseInt(e.join(""))},"active",n("active",!0),"pending",n("pending",!0),"terminated",n("terminated",!0),function(){t.data.state=i()},"reason",n("reason",!0),function(e){void 0!==e&&(t.data.reason=e)},function(e){void 0!==e&&(t.data.expires=e)},"retry_after",n("retry_after",!0),function(e){void 0!==e&&(t.data.retry_after=e)},"deactivated",n("deactivated",!0),"probation",n("probation",!0),"rejected",n("rejected",!0),"timeout",n("timeout",!0),"giveup",n("giveup",!0),"noresource",n("noresource",!0),"invariant",n("invariant",!0),function(e){"Supported"===t.startRule&&(t.data=e||[])},function(){var e=t.data.tag;t.data=new t.SIP.NameAddrHeader(t.data.uri,t.data.displayName,t.data.params),e&&t.data.setParam("tag",e)},"ttl",n("ttl",!0),function(e){t.data.ttl=e},"maddr",n("maddr",!0),function(e){t.data.maddr=e},"received",n("received",!0),function(e){t.data.received=e},"branch",n("branch",!0),function(e){t.data.branch=e},"rport",n("rport",!0),function(){"undefined"!=typeof response_port&&(t.data.rport=response_port.join(""))},function(e){t.data.protocol=e},n("UDP",!0),n("TCP",!0),n("TLS",!0),n("SCTP",!0),function(e){t.data.transport=e},function(){t.data.host=i()},function(e){t.data.port=parseInt(e.join(""))},function(e){return parseInt(e.join(""))},function(e){"Session_Expires"===t.startRule&&(t.data.deltaSeconds=e)},"refresher",n("refresher",!1),"uas",n("uas",!1),"uac",n("uac",!1),function(e){"Session_Expires"===t.startRule&&(t.data.refresher=e)},function(e){"Min_SE"===t.startRule&&(t.data=e)},"stuns",n("stuns",!0),"stun",n("stun",!0),function(e){t.data.scheme=e},function(e){t.data.host=e},"?transport=",n("?transport=",!1),"turns",n("turns",!0),"turn",n("turn",!0),function(){t.data.transport=transport},function(){t.data=i()},"Referred-By",n("Referred-By",!1),"b",n("b",!1),"cid",n("cid",!1)],_=[l('2 ""6 7!'),l('4"""5!7#'),l('4$""5!7%'),l('4&""5!7\''),l(";'.# &;("),l('4(""5!7)'),l('4*""5!7+'),l('2,""6,7-'),l('2.""6.7/'),l('40""5!71'),l('22""6273.\x89 &24""6475.} &26""6677.q &28""6879.e &2:""6:7;.Y &2<""6<7=.M &2>""6>7?.A &2@""6@7A.5 &2B""6B7C.) &2D""6D7E'),l(";).# &;,"),l('2F""6F7G.} &2H""6H7I.q &2J""6J7K.e &2L""6L7M.Y &2N""6N7O.M &2P""6P7Q.A &2R""6R7S.5 &2T""6T7U.) &2V""6V7W'),l('%%2X""6X7Y/5#;#/,$;#/#$+#)(#\'#("\'#&\'#/"!&,)'),l('%%$;$0#*;$&/,#; /#$+")("\'#&\'#." &"/=#$;$/�#*;$&&&#/\'$8":Z" )("\'#&\'#'),l(';.." &"'),l("%$;'.# &;(0)*;'.# &;(&/?#28\"\"6879/0$;//'$8#:[# )(#'#(\"'#&'#"),l('%%$;2/�#*;2&&&#/g#$%$;.0#*;.&/,#;2/#$+")("\'#&\'#0=*%$;.0#*;.&/,#;2/#$+")("\'#&\'#&/#$+")("\'#&\'#/"!&,)'),l('4\\""5!7].# &;3'),l('4^""5!7_'),l('4`""5!7a'),l(';!.) &4b""5!7c'),l('%$;).\x95 &2F""6F7G.\x89 &2J""6J7K.} &2L""6L7M.q &2X""6X7Y.e &2P""6P7Q.Y &2H""6H7I.M &2@""6@7A.A &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@""6@7A.A &2d""6d7e.5 &2R""6R7S.) &2N""6N7O&&&#/"!&,)'),l('%$;).\x89 &2F""6F7G.} &2L""6L7M.q &2X""6X7Y.e &2P""6P7Q.Y &2H""6H7I.M &2@""6@7A.A &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@""6@7A.A &2d""6d7e.5 &2R""6R7S.) &2N""6N7O&&&#/"!&,)'),l('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.) &;\'.# &;('),l('%$;).\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&&&#/"!&,)'),l("%;//?#2P\"\"6P7Q/0$;//'$8#:t# )(#'#(\"'#&'#"),l("%;//?#24\"\"6475/0$;//'$8#:u# )(#'#(\"'#&'#"),l("%;//?#2>\"\"6>7?/0$;//'$8#:v# )(#'#(\"'#&'#"),l("%;//?#2T\"\"6T7U/0$;//'$8#:w# )(#'#(\"'#&'#"),l("%;//?#2V\"\"6V7W/0$;//'$8#:x# )(#'#(\"'#&'#"),l('%2h""6h7i/0#;//\'$8":y" )("\'#&\'#'),l('%;//6#2f""6f7g/\'$8":z" )("\'#&\'#'),l("%;//?#2D\"\"6D7E/0$;//'$8#:{# )(#'#(\"'#&'#"),l("%;//?#22\"\"6273/0$;//'$8#:|# )(#'#(\"'#&'#"),l("%;//?#28\"\"6879/0$;//'$8#:}# )(#'#(\"'#&'#"),l("%;//0#;&/'$8\":~\" )(\"'#&'#"),l("%;&/0#;//'$8\":~\" )(\"'#&'#"),l("%;=/T#$;G.) &;K.# &;F0/*;G.) &;K.# &;F&/,$;>/#$+#)(#'#(\"'#&'#"),l('4\x7f""5!7\x80.A &4\x81""5!7\x82.5 &4\x83""5!7\x84.) &;3.# &;.'),l("%%;//Q#;&/H$$;J.# &;K0)*;J.# &;K&/,$;&/#$+$)($'#(#'#(\"'#&'#/\"!&,)"),l("%;//]#;&/T$%$;J.# &;K0)*;J.# &;K&/\"!&,)/1$;&/($8$:\x85$!!)($'#(#'#(\"'#&'#"),l(';..G &2L""6L7M.; &4\x86""5!7\x87./ &4\x83""5!7\x84.# &;3'),l('%2j""6j7k/J#4\x88""5!7\x89.5 &4\x8a""5!7\x8b.) &4\x8c""5!7\x8d/#$+")("\'#&\'#'),l("%;N/M#28\"\"6879/>$;O.\" &\"/0$;S/'$8$:\x8e$ )($'#(#'#(\"'#&'#"),l("%;N/d#28\"\"6879/U$;O.\" &\"/G$;S/>$;_/5$;l.\" &\"/'$8&:\x8f& )(&'#(%'#($'#(#'#(\"'#&'#"),l('%3\x90""5$7\x91.) &3\x92""5#7\x93/\' 8!:\x94!! )'),l('%;P/]#%28""6879/,#;R/#$+")("\'#&\'#." &"/6$2:""6:7;/\'$8#:\x95# )(#\'#("\'#&\'#'),l("$;+.) &;-.# &;Q/2#0/*;+.) &;-.# &;Q&&&#"),l('2<""6<7=.q &2>""6>7?.e &2@""6@7A.Y &2B""6B7C.M &2D""6D7E.A &22""6273.5 &26""6677.) &24""6475'),l('%$;+._ &;-.Y &2<""6<7=.M &2>""6>7?.A &2@""6@7A.5 &2B""6B7C.) &2D""6D7E0e*;+._ &;-.Y &2<""6<7=.M &2>""6>7?.A &2@""6@7A.5 &2B""6B7C.) &2D""6D7E&/& 8!:\x96! )'),l('%;T/J#%28""6879/,#;^/#$+")("\'#&\'#." &"/#$+")("\'#&\'#'),l("%;U.) &;\\.# &;X/& 8!:\x97! )"),l('%$%;V/2#2J""6J7K/#$+")("\'#&\'#0<*%;V/2#2J""6J7K/#$+")("\'#&\'#&/D#;W/;$2J""6J7K." &"/\'$8#:\x98# )(#\'#("\'#&\'#'),l('$4\x99""5!7\x9a/,#0)*4\x99""5!7\x9a&&&#'),l('%4$""5!7%/?#$4\x9b""5!7\x9c0)*4\x9b""5!7\x9c&/#$+")("\'#&\'#'),l('%2l""6l7m/?#;Y/6$2n""6n7o/\'$8#:\x9d# )(#\'#("\'#&\'#'),l('%%;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! )'),l('%;#/M#;#." &"/?$;#." &"/1$;#." &"/#$+$)($\'#(#\'#("\'#&\'#'),l("%;Z/;#28\"\"6879/,$;Z/#$+#)(#'#(\"'#&'#.# &;\\"),l("%;]/o#2J\"\"6J7K/`$;]/W$2J\"\"6J7K/H$;]/?$2J\"\"6J7K/0$;]/'$8':\xa1' )(''#(&'#(%'#($'#(#'#(\"'#&'#"),l('%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/,#;!/#$+")("\'#&\'#.# &;!'),l('%%;!." &"/[#;!." &"/M$;!." &"/?$;!." &"/1$;!." &"/#$+%)(%\'#($\'#(#\'#("\'#&\'#/\' 8!:\xae!! )'),l('$%22""6273/,#;`/#$+")("\'#&\'#0<*%22""6273/,#;`/#$+")("\'#&\'#&'),l(";a.A &;b.; &;c.5 &;d./ &;e.) &;f.# &;g"),l('%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"! )("\'#&\'#'),l('%3\xba""5%7\xbb/I#3\xbc""5%7\xbd./ &3\xbe""5"7\xbf.# &;6/($8":\xc0"! )("\'#&\'#'),l('%3\xc1""5\'7\xc2/1#;\x8f/($8":\xc3"! )("\'#&\'#'),l('%3\xc4""5$7\xc5/1#;\xef/($8":\xc6"! )("\'#&\'#'),l('%3\xc7""5&7\xc8/1#;T/($8":\xc9"! )("\'#&\'#'),l('%3\xca""5"7\xcb/N#%2>""6>7?/,#;6/#$+")("\'#&\'#." &"/\'$8":\xcc" )("\'#&\'#'),l('%;h/P#%2>""6>7?/,#;i/#$+")("\'#&\'#." &"/)$8":\xcd""! )("\'#&\'#'),l('%$;j/�#*;j&&&#/"!&,)'),l('%$;j/�#*;j&&&#/"!&,)'),l(";k.) &;+.# &;-"),l('2l""6l7m.e &2n""6n7o.Y &24""6475.M &28""6879.A &2<""6<7=.5 &2@""6@7A.) &2B""6B7C'),l('%26""6677/n#;m/e$$%2<""6<7=/,#;m/#$+")("\'#&\'#0<*%2<""6<7=/,#;m/#$+")("\'#&\'#&/#$+#)(#\'#("\'#&\'#'),l('%;n/A#2>""6>7?/2$;o/)$8#:\xce#"" )(#\'#("\'#&\'#'),l("$;p.) &;+.# &;-/2#0/*;p.) &;+.# &;-&&&#"),l("$;p.) &;+.# &;-0/*;p.) &;+.# &;-&"),l('2l""6l7m.e &2n""6n7o.Y &24""6475.M &26""6677.A &28""6879.5 &2@""6@7A.) &2B""6B7C'),l(";\x90.# &;r"),l("%;\x8f/G#;'/>$;s/5$;'/,$;\x84/#$+%)(%'#($'#(#'#(\"'#&'#"),l(";M.# &;t"),l("%;\x7f/E#28\"\"6879/6$;u.# &;x/'$8#:\xcf# )(#'#(\"'#&'#"),l('%;v.# &;w/J#%26""6677/,#;\x83/#$+")("\'#&\'#." &"/#$+")("\'#&\'#'),l('%2\xd0""6\xd07\xd1/:#;\x80/1$;w." &"/#$+#)(#\'#("\'#&\'#'),l('%24""6475/,#;{/#$+")("\'#&\'#'),l("%;z/3#$;y0#*;y&/#$+\")(\"'#&'#"),l(";*.) &;+.# &;-"),l(';+.\x8f &;-.\x89 &22""6273.} &26""6677.q &28""6879.e &2:""6:7;.Y &2<""6<7=.M &2>""6>7?.A &2@""6@7A.5 &2B""6B7C.) &2D""6D7E'),l('%;|/e#$%24""6475/,#;|/#$+")("\'#&\'#0<*%24""6475/,#;|/#$+")("\'#&\'#&/#$+")("\'#&\'#'),l('%$;~0#*;~&/e#$%22""6273/,#;}/#$+")("\'#&\'#0<*%22""6273/,#;}/#$+")("\'#&\'#&/#$+")("\'#&\'#'),l("$;~0#*;~&"),l(';+.w &;-.q &28""6879.e &2:""6:7;.Y &2<""6<7=.M &2>""6>7?.A &2@""6@7A.5 &2B""6B7C.) &2D""6D7E'),l('%%;"/\x87#$;".G &;!.A &2@""6@7A.5 &2F""6F7G.) &2J""6J7K0M*;".G &;!.A &2@""6@7A.5 &2F""6F7G.) &2J""6J7K&/#$+")("\'#&\'#/& 8!:\xd2! )'),l(";\x81.# &;\x82"),l('%%;O/2#2:""6:7;/#$+")("\'#&\'#." &"/,#;S/#$+")("\'#&\'#." &"'),l('$;+.\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&&&#'),l("$;y0#*;y&"),l('%3\x92""5#7\xd3/q#24""6475/b$$;!/�#*;!&&&#/L$2J""6J7K/=$$;!/�#*;!&&&#/\'$8%:\xd4% )(%\'#($\'#(#\'#("\'#&\'#'),l('2\xd5""6\xd57\xd6'),l('2\xd7""6\xd77\xd8'),l('2\xd9""6\xd97\xda'),l('2\xdb""6\xdb7\xdc'),l('2\xdd""6\xdd7\xde'),l('2\xdf""6\xdf7\xe0'),l('2\xe1""6\xe17\xe2'),l('2\xe3""6\xe37\xe4'),l('2\xe5""6\xe57\xe6'),l('2\xe7""6\xe77\xe8'),l("%;\x85.S &;\x86.M &;\x88.G &;\x89.A &;\x8a.; &;\x8b.5 &;\x8c./ &;\x8d.) &;\x8e.# &;6/& 8!:\xe9! )"),l("%;\x84/G#;'/>$;\x91/5$;'/,$;\x93/#$+%)(%'#($'#(#'#(\"'#&'#"),l("%;\x92/' 8!:\xea!! )"),l("%;!/5#;!/,$;!/#$+#)(#'#(\"'#&'#"),l("%$;*.A &;+.; &;-.5 &;3./ &;4.) &;'.# &;(0G*;*.A &;+.; &;-.5 &;3./ &;4.) &;'.# &;(&/& 8!:\xeb! )"),l("%;\xb5/Y#$%;A/,#;\xb5/#$+\")(\"'#&'#06*%;A/,#;\xb5/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),l('%;9/N#%2:""6:7;/,#;9/#$+")("\'#&\'#." &"/\'$8":\xec" )("\'#&\'#'),l("%;:.c &%;\x97/Y#$%;A/,#;\x97/#$+\")(\"'#&'#06*%;A/,#;\x97/#$+\")(\"'#&'#&/#$+\")(\"'#&'#/& 8!:\xed! )"),l("%;L.# &;\x98/]#$%;B/,#;\x9a/#$+\")(\"'#&'#06*%;B/,#;\x9a/#$+\")(\"'#&'#&/'$8\":\xee\" )(\"'#&'#"),l("%;\x99.\" &\"/>#;@/5$;M/,$;?/#$+$)($'#(#'#(\"'#&'#"),l("%%;6/Y#$%;./,#;6/#$+\")(\"'#&'#06*%;./,#;6/#$+\")(\"'#&'#&/#$+\")(\"'#&'#.# &;H/' 8!:\xef!! )"),l(";\x9b.) &;\x9c.# &;\x9f"),l("%3\xf0\"\"5!7\xf1/:#;</1$;\x9e/($8#:\xf2#! )(#'#(\"'#&'#"),l("%3\xf3\"\"5'7\xf4/:#;</1$;\x9d/($8#:\xf5#! )(#'#(\"'#&'#"),l("%$;!/�#*;!&&&#/' 8!:\xf6!! )"),l('%2\xf7""6\xf77\xf8/o#%2J""6J7K/M#;!." &"/?$;!." &"/1$;!." &"/#$+$)($\'#(#\'#("\'#&\'#." &"/\'$8":\xf9" )("\'#&\'#'),l('%;6/J#%;</,#;\xa0/#$+")("\'#&\'#." &"/)$8":\xfa""! )("\'#&\'#'),l(";6.) &;T.# &;H"),l("%;\xa2/Y#$%;B/,#;\xa3/#$+\")(\"'#&'#06*%;B/,#;\xa3/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),l('%3\xfb""5&7\xfc.G &3\xfd""5\'7\xfe.; &3\xff""5$7\u0100./ &3\u0101""5%7\u0102.# &;6/& 8!:\u0103! )'),l(";\xa4.# &;\x9f"),l('%3\u0104""5(7\u0105/M#;</D$3\u0106""5(7\u0107./ &3\u0108""5(7\u0109.# &;6/#$+#)(#\'#("\'#&\'#'),l("%;6/Y#$%;A/,#;6/#$+\")(\"'#&'#06*%;A/,#;6/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),l("%$;!/�#*;!&&&#/' 8!:\u010a!! )"),l("%;\xa8/& 8!:\u010b! )"),l("%;\xa9/k#;;/b$;\xae/Y$$%;B/,#;\xaf/#$+\")(\"'#&'#06*%;B/,#;\xaf/#$+\")(\"'#&'#&/#$+$)($'#(#'#(\"'#&'#"),l(";\xaa.# &;\xab"),l('3\u010c""5$7\u010d.S &3\u010e""5%7\u010f.G &3\u0110""5%7\u0111.; &3\u0112""5%7\u0113./ &3\u0114""5+7\u0115.# &;\xac'),l('3\u0116""5\'7\u0117./ &3\u0118""5)7\u0119.# &;\xac'),l(";6.# &;\xad"),l('%3\u011a""5"7\u011b/,#;6/#$+")("\'#&\'#'),l(";\xac.# &;6"),l("%;6/5#;</,$;\xb0/#$+#)(#'#(\"'#&'#"),l(";6.# &;H"),l("%;\xb2/5#;./,$;\x8f/#$+#)(#'#(\"'#&'#"),l("%$;!/�#*;!&&&#/' 8!:\u011c!! )"),l("%;\x9d/' 8!:\u011d!! )"),l('%;\xb5/^#$%;B/,#;\x9f/#$+")("\'#&\'#06*%;B/,#;\x9f/#$+")("\'#&\'#&/($8":\u011e"!!)("\'#&\'#'),l('%%;7/e#$%2J""6J7K/,#;7/#$+")("\'#&\'#0<*%2J""6J7K/,#;7/#$+")("\'#&\'#&/#$+")("\'#&\'#/"!&,)'),l("%;L.# &;\x98/]#$%;B/,#;\xb7/#$+\")(\"'#&'#06*%;B/,#;\xb7/#$+\")(\"'#&'#&/'$8\":\u011f\" )(\"'#&'#"),l(";\xb8.# &;\x9f"),l("%3\u0120\"\"5#7\u0121/:#;</1$;6/($8#:\u0122#! )(#'#(\"'#&'#"),l("%$;!/�#*;!&&&#/' 8!:\u0123!! )"),l("%;\x9d/' 8!:\u0124!! )"),l("%$;\x990#*;\x99&/x#;@/o$;M/f$;?/]$$%;B/,#;\x9f/#$+\")(\"'#&'#06*%;B/,#;\x9f/#$+\")(\"'#&'#&/'$8%:\u0125% )(%'#($'#(#'#(\"'#&'#"),l(";\xbd"),l("%3\u0126\"\"5&7\u0127/k#;./b$;\xc0/Y$$%;A/,#;\xc0/#$+\")(\"'#&'#06*%;A/,#;\xc0/#$+\")(\"'#&'#&/#$+$)($'#(#'#(\"'#&'#.# &;\xbe"),l("%;6/k#;./b$;\xbf/Y$$%;A/,#;\xbf/#$+\")(\"'#&'#06*%;A/,#;\xbf/#$+\")(\"'#&'#&/#$+$)($'#(#'#(\"'#&'#"),l("%;6/;#;</2$;6.# &;H/#$+#)(#'#(\"'#&'#"),l(";\xc1.G &;\xc3.A &;\xc5.; &;\xc7.5 &;\xc8./ &;\xc9.) &;\xca.# &;\xbf"),l("%3\u0128\"\"5%7\u0129/5#;</,$;\xc2/#$+#)(#'#(\"'#&'#"),l("%;I/' 8!:\u012a!! )"),l("%3\u012b\"\"5&7\u012c/\x97#;</\x8e$;D/\x85$;\xc4/|$$%$;'/�#*;'&&&#/,#;\xc4/#$+\")(\"'#&'#0C*%$;'/�#*;'&&&#/,#;\xc4/#$+\")(\"'#&'#&/,$;E/#$+&)(&'#(%'#($'#(#'#(\"'#&'#"),l(";t.# &;w"),l("%3\u012d\"\"5%7\u012e/5#;</,$;\xc6/#$+#)(#'#(\"'#&'#"),l("%;I/' 8!:\u012f!! )"),l("%3\u0130\"\"5&7\u0131/:#;</1$;I/($8#:\u0132#! )(#'#(\"'#&'#"),l('%3\u0133""5%7\u0134/]#;</T$%3\u0135""5$7\u0136/& 8!:\u0137! ).4 &%3\u0138""5%7\u0139/& 8!:\u013a! )/#$+#)(#\'#("\'#&\'#'),l('%3\u013b""5)7\u013c/R#;</I$3\u013d""5#7\u013e./ &3\u013f""5(7\u0140.# &;6/($8#:\u0141#! )(#\'#("\'#&\'#'),l('%3\u0142""5#7\u0143/\x93#;</\x8a$;D/\x81$%;\xcb/e#$%2D""6D7E/,#;\xcb/#$+")("\'#&\'#0<*%2D""6D7E/,#;\xcb/#$+")("\'#&\'#&/#$+")("\'#&\'#/,$;E/#$+%)(%\'#($\'#(#\'#("\'#&\'#'),l('%3\u0144""5(7\u0145./ &3\u0146""5$7\u0147.# &;6/\' 8!:\u0148!! )'),l("%;6/Y#$%;A/,#;6/#$+\")(\"'#&'#06*%;A/,#;6/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),l("%;\xce/G#;./>$;\xce/5$;./,$;\x8f/#$+%)(%'#($'#(#'#(\"'#&'#"),l("%$;!/�#*;!&&&#/' 8!:\u0149!! )"),l("%;\xd0/]#$%;A/,#;\xd0/#$+\")(\"'#&'#06*%;A/,#;\xd0/#$+\")(\"'#&'#&/'$8\":\u014a\" )(\"'#&'#"),l("%;\x98/]#$%;B/,#;\x9f/#$+\")(\"'#&'#06*%;B/,#;\x9f/#$+\")(\"'#&'#&/'$8\":\u014b\" )(\"'#&'#"),l('%;L.O &;\x98.I &%;@." &"/:#;t/1$;?." &"/#$+#)(#\'#("\'#&\'#/]#$%;B/,#;\x9f/#$+")("\'#&\'#06*%;B/,#;\x9f/#$+")("\'#&\'#&/\'$8":\u014c" )("\'#&\'#'),l("%;\xd3/]#$%;B/,#;\xd4/#$+\")(\"'#&'#06*%;B/,#;\xd4/#$+\")(\"'#&'#&/'$8\":\u014d\" )(\"'#&'#"),l("%;\x95/& 8!:\u014e! )"),l('%3\u014f""5(7\u0150/:#;</1$;6/($8#:\u0151#! )(#\'#("\'#&\'#.g &%3\u0152""5&7\u0153/:#;</1$;6/($8#:\u0154#! )(#\'#("\'#&\'#.: &%3\u0155""5*7\u0156/& 8!:\u0157! ).# &;\x9f'),l('%%;6/k#$%;A/2#;6/)$8":\u0158""$ )("\'#&\'#0<*%;A/2#;6/)$8":\u0158""$ )("\'#&\'#&/)$8":\u0159""! )("\'#&\'#." &"/\' 8!:\u015a!! )'),l("%;\xd7/Y#$%;A/,#;\xd7/#$+\")(\"'#&'#06*%;A/,#;\xd7/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),l("%;\x98/Y#$%;B/,#;\x9f/#$+\")(\"'#&'#06*%;B/,#;\x9f/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),l("%$;!/�#*;!&&&#/' 8!:\u015b!! )"),l("%;\xda/Y#$%;B/,#;\xdb/#$+\")(\"'#&'#06*%;B/,#;\xdb/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),l('%3\u015c""5&7\u015d.; &3\u015e""5\'7\u015f./ &3\u0160""5*7\u0161.# &;6/& 8!:\u0162! )'),l("%3\u0163\"\"5&7\u0164/:#;</1$;\xdc/($8#:\u0165#! )(#'#(\"'#&'#.} &%3\xf3\"\"5'7\xf4/:#;</1$;\x9d/($8#:\u0166#! )(#'#(\"'#&'#.P &%3\u0167\"\"5+7\u0168/:#;</1$;\x9d/($8#:\u0169#! )(#'#(\"'#&'#.# &;\x9f"),l('3\u016a""5+7\u016b.k &3\u016c""5)7\u016d._ &3\u016e""5(7\u016f.S &3\u0170""5\'7\u0171.G &3\u0172""5&7\u0173.; &3\u0174""5*7\u0175./ &3\u0176""5)7\u0177.# &;6'),l(';1." &"'),l('%%;6/k#$%;A/2#;6/)$8":\u0158""$ )("\'#&\'#0<*%;A/2#;6/)$8":\u0158""$ )("\'#&\'#&/)$8":\u0159""! )("\'#&\'#." &"/\' 8!:\u0178!! )'),l("%;L.# &;\x98/]#$%;B/,#;\xe0/#$+\")(\"'#&'#06*%;B/,#;\xe0/#$+\")(\"'#&'#&/'$8\":\u0179\" )(\"'#&'#"),l(";\xb8.# &;\x9f"),l("%;\xe2/Y#$%;A/,#;\xe2/#$+\")(\"'#&'#06*%;A/,#;\xe2/#$+\")(\"'#&'#&/#$+\")(\"'#&'#"),l("%;\xe9/k#;./b$;\xec/Y$$%;B/,#;\xe3/#$+\")(\"'#&'#06*%;B/,#;\xe3/#$+\")(\"'#&'#&/#$+$)($'#(#'#(\"'#&'#"),l(";\xe4.; &;\xe5.5 &;\xe6./ &;\xe7.) &;\xe8.# &;\x9f"),l("%3\u017a\"\"5#7\u017b/:#;</1$;\xef/($8#:\u017c#! )(#'#(\"'#&'#"),l("%3\u017d\"\"5%7\u017e/:#;</1$;T/($8#:\u017f#! )(#'#(\"'#&'#"),l("%3\u0180\"\"5(7\u0181/@#;</7$;\\.# &;Y/($8#:\u0182#! )(#'#(\"'#&'#"),l("%3\u0183\"\"5&7\u0184/:#;</1$;6/($8#:\u0185#! )(#'#(\"'#&'#"),l('%3\u0186""5%7\u0187/O#%;</3#$;!0#*;!&/#$+")("\'#&\'#." &"/\'$8":\u0188" )("\'#&\'#'),l("%;\xea/G#;;/>$;6/5$;;/,$;\xeb/#$+%)(%'#($'#(#'#(\"'#&'#"),l('%3\x92""5#7\xd3.# &;6/\' 8!:\u0189!! )'),l('%3\xb1""5#7\u018a.G &3\xb3""5#7\u018b.; &3\xb7""5#7\u018c./ &3\xb5""5$7\u018d.# &;6/\' 8!:\u018e!! )'),l('%;\xed/D#%;C/,#;\xee/#$+")("\'#&\'#." &"/#$+")("\'#&\'#'),l("%;U.) &;\\.# &;X/& 8!:\u018f! )"),l('%%;!." &"/[#;!." &"/M$;!." &"/?$;!." &"/1$;!." &"/#$+%)(%\'#($\'#(#\'#("\'#&\'#/\' 8!:\u0190!! )'),l('%%;!/?#;!." &"/1$;!." &"/#$+#)(#\'#("\'#&\'#/\' 8!:\u0191!! )'),l(";\xbd"),l('%;\x9d/^#$%;B/,#;\xf2/#$+")("\'#&\'#06*%;B/,#;\xf2/#$+")("\'#&\'#&/($8":\u0192"!!)("\'#&\'#'),l(";\xf3.# &;\x9f"),l('%2\u0193""6\u01937\u0194/L#;</C$2\u0195""6\u01957\u0196.) &2\u0197""6\u01977\u0198/($8#:\u0199#! )(#\'#("\'#&\'#'),l('%;\x9d/^#$%;B/,#;\x9f/#$+")("\'#&\'#06*%;B/,#;\x9f/#$+")("\'#&\'#&/($8":\u019a"!!)("\'#&\'#'),l("%;6/5#;0/,$;\xf6/#$+#)(#'#(\"'#&'#"),l("$;2.) &;4.# &;.0/*;2.) &;4.# &;.&"),l("$;%0#*;%&"),l("%;\xf9/;#28\"\"6879/,$;\xfa/#$+#)(#'#(\"'#&'#"),l('%3\u019b""5%7\u019c.) &3\u019d""5$7\u019e/\' 8!:\u019f!! )'),l('%;\xfb/J#%28""6879/,#;^/#$+")("\'#&\'#." &"/#$+")("\'#&\'#'),l("%;\\.) &;X.# &;\x82/' 8!:\u01a0!! )"),l(';".S &;!.M &2F""6F7G.A &2J""6J7K.5 &2H""6H7I.) &2N""6N7O'),l('2L""6L7M.\x95 &2B""6B7C.\x89 &2<""6<7=.} &2R""6R7S.q &2T""6T7U.e &2V""6V7W.Y &2P""6P7Q.M &2@""6@7A.A &2D""6D7E.5 &22""6273.) &2>""6>7?'),l('%;\xff/b#28""6879/S$;\xfa/J$%2\u01a1""6\u01a17\u01a2/,#;\xeb/#$+")("\'#&\'#." &"/#$+$)($\'#(#\'#("\'#&\'#'),l('%3\u01a3""5%7\u01a4.) &3\u01a5""5$7\u01a6/\' 8!:\u019f!! )'),l('%;\xeb/O#3\xb1""5#7\xb2.6 &3\xb3""5#7\xb4.* &$;+0#*;+&/\'$8":\u01a7" )("\'#&\'#'),l("%;\u0103/\x87#2F\"\"6F7G/x$;\u0102/o$2F\"\"6F7G/`$;\u0102/W$2F\"\"6F7G/H$;\u0102/?$2F\"\"6F7G/0$;\u0104/'$8):\u01a8) )()'#(('#(''#(&'#(%'#($'#(#'#(\"'#&'#"),l("%;#/>#;#/5$;#/,$;#/#$+$)($'#(#'#(\"'#&'#"),l("%;\u0102/,#;\u0102/#$+\")(\"'#&'#"),l("%;\u0102/5#;\u0102/,$;\u0102/#$+#)(#'#(\"'#&'#"),l("%;\x84/U#;'/L$;\x91/C$;'/:$;\x8f/1$; .\" &\"/#$+&)(&'#(%'#($'#(#'#(\"'#&'#"),l('%2\u01a9""6\u01a97\u01aa.) &2\u01ab""6\u01ab7\u01ac/w#;0/n$;\u0107/e$$%;B/2#;\u0108.# &;\x9f/#$+")("\'#&\'#0<*%;B/2#;\u0108.# &;\x9f/#$+")("\'#&\'#&/#$+$)($\'#(#\'#("\'#&\'#'),l(";\x98.# &;L"),l("%2\u01ad\"\"6\u01ad7\u01ae/5#;</,$;\u0109/#$+#)(#'#(\"'#&'#"),l("%;D/S#;,/J$2:\"\"6:7;/;$;,.# &;T/,$;E/#$+%)(%'#($'#(#'#(\"'#&'#")],E=0,S=0,C=[{line:1,column:1}],R=0,v=[],A=0;if("startRule"in t){if(!(t.startRule in f))throw new Error("Can't start parsing from rule \""+t.startRule+'".');T=f[t.startRule]}if(t.data={},(p=d(T))!==g&&E===e.length)return p;throw p!==g&&E<e.length&&h({type:"end"}),u(v,R<e.length?e.charAt(R):null,R<e.length?c(R,R+1):c(R,R))}}},function(e,t,i){"use strict";e.exports=function(e){return{stripTcpCandidates:function(t){return t.sdp=t.sdp.replace(/^a=candidate:\d+ \d+ tcp .*?\r\n/gim,""),e.Utils.Promise.resolve(t)},stripTelephoneEvent:function(t){return t.sdp=t.sdp.replace(/^a=rtpmap:\d+ telephone-event\/d+/gim,""),e.Utils.Promise.resolve(t)},cleanJitsiSdpImageattr:function(t){return t.sdp=t.sdp.replace(/^(a=imageattr:.*?)(x|y)=\[0-/gm,"$1$2=[1:"),e.Utils.Promise.resolve(t)},stripG722:function(t){var i=t.sdp.match(/^m=audio.*$/gm);if(i){var s=i[0];s=s.split(" ");for(var r=3;r<s.length;r+=1)if("9"===s[r]){s.splice(r,1);var n=parseInt(s[1],10);n-=1,s[1]=n.toString()}s=s.join(" "),t.sdp=t.sdp.replace(/^m=audio.*$/gm,s),t.sdp=t.sdp.replace(/^a=rtpmap:.*G722\/8000\r\n?/gm,"").replace()}return e.Utils.Promise.resolve(t)}}}},function(e,t,i){"use strict";(function(t){e.exports=function(e){var i={STATUS_NULL:0,STATUS_NEW:1,STATUS_CONNECTING:2,STATUS_CONNECTED:3,STATUS_COMPLETED:4},s=function(s){if(s.media.remote.video?this.video=!0:this.video=!1,s.media.remote.audio?this.audio=!0:this.audio=!1,!this.audio&&!this.video)throw new Error("At least one remote audio or video element is required for Simple.");this.options=s;var r=t.navigator.userAgent.toLowerCase(),n=!1;r.indexOf("safari")>-1&&r.indexOf("chrome")<0&&(n=!0);var o={};return n&&(o.modifiers=[e.WebRTC.Modifiers.stripG722]),this.options.ua.uri||(this.anonymous=!0),this.ua=new e.UA({wsServers:this.options.ua.wsServers,uri:this.options.ua.uri,authorizationUser:this.options.ua.authorizationUser,password:this.options.ua.password,displayName:this.options.ua.displayName,traceSip:this.options.ua.traceSip,userAgentString:this.options.ua.userAgentString,register:!0,sessionDescriptionHandlerFactoryOptions:o}),this.state=i.STATUS_NULL,this.logger=this.ua.getLogger("sip.simple"),this.ua.on("registered",function(){this.emit("registered",this.ua)}.bind(this)),this.ua.on("unregistered",function(){this.emit("unregistered",this.ua)}.bind(this)),this.ua.on("failed",function(){this.emit("unregistered",this.ua)}.bind(this)),this.ua.on("invite",function(e){if(this.state!==i.STATUS_NULL&&this.state!==i.STATUS_COMPLETED)return this.logger.warn("Rejecting incoming call. Simple only supports 1 call at a time"),void e.reject();this.session=e,this.setupSession(),this.emit("ringing",this.session)}.bind(this)),this.ua.on("message",function(e){this.emit("message",e)}.bind(this)),this};return s.prototype=Object.create(e.EventEmitter.prototype),s.C=i,s.prototype.call=function(e){if(this.ua&&this.checkRegistration()){if(this.state===i.STATUS_NULL||this.state===i.STATUS_COMPLETED)return this.options.media.remote.audio&&(this.options.media.remote.audio.autoplay=!0),this.options.media.remote.video&&(this.options.media.remote.video.autoplay=!0),this.options.media.local&&this.options.media.local.video&&(this.options.media.local.video.autoplay=!0,this.options.media.local.video.volume=0),this.session=this.ua.invite(e,{sessionDescriptionHandlerOptions:{constraints:{audio:this.audio,video:this.video}}}),this.setupSession(),this.session;this.logger.warn("Cannot make more than a single call with Simple")}else this.logger.warn("A registered UA is required for calling")},s.prototype.answer=function(){if(this.state===i.STATUS_NEW||this.state===i.STATUS_CONNECTING)return this.options.media.remote.audio&&(this.options.media.remote.audio.autoplay=!0),this.options.media.remote.video&&(this.options.media.remote.video.autoplay=!0),this.session.accept({sessionDescriptionHandlerOptions:{constraints:{audio:this.audio,video:this.video}}});this.logger.warn("No call to answer")},s.prototype.reject=function(){if(this.state===i.STATUS_NEW||this.state===i.STATUS_CONNECTING)return this.session.reject();this.logger.warn("Call is already answered")},s.prototype.hangup=function(){if(this.state===i.STATUS_CONNECTED||this.state===i.STATUS_CONNECTING||this.state===i.STATUS_NEW)return this.state!==i.STATUS_CONNECTED?this.session.cancel():this.session.bye();this.logger.warn("No active call to hang up on")},s.prototype.hold=function(){if(this.state===i.STATUS_CONNECTED&&!this.session.local_hold)return this.mute(),this.logger.log("Placing session on hold"),this.session.hold();this.logger.warn("Cannot put call on hold")},s.prototype.unhold=function(){if(this.state===i.STATUS_CONNECTED&&this.session.local_hold)return this.unmute(),this.logger.log("Placing call off hold"),this.session.unhold();this.logger.warn("Cannot unhold a call that is not on hold")},s.prototype.mute=function(){this.state===i.STATUS_CONNECTED?(this.logger.log("Muting Audio"),this.toggleMute(!0)):this.logger.warn("An acitve call is required to mute audio")},s.prototype.unmute=function(){this.state===i.STATUS_CONNECTED?(this.logger.log("Unmuting Audio"),this.toggleMute(!1)):this.logger.warn("An active call is required to unmute audio")},s.prototype.sendDTMF=function(e){this.state===i.STATUS_CONNECTED?(this.logger.log("Sending DTMF tone: "+e),this.session.dtmf(e)):this.logger.warn("An active call is required to send a DTMF tone")},s.prototype.message=function(e,t){this.ua&&this.checkRegistration()?e&&t?this.ua.message(e,t):this.logger.warn("A destination and message are required to send a message"):this.logger.warn("A registered UA is required to send a message")},s.prototype.checkRegistration=function(){return this.anonymous||this.ua&&this.ua.isRegistered()},s.prototype.setupRemoteMedia=function(){var e,i=this.session.sessionDescriptionHandler.peerConnection;i.getReceivers?(e=new t.window.MediaStream,i.getReceivers().forEach(function(t){var i=t.track;i&&e.addTrack(i)})):e=i.getRemoteStreams()[0],this.video?(this.options.media.remote.video.srcObject=e,this.options.media.remote.video.play().catch(function(){this.logger.log("play was rejected")}.bind(this))):this.audio&&(this.options.media.remote.audio.srcObject=e,this.options.media.remote.audio.play().catch(function(){this.logger.log("play was rejected")}.bind(this)))},s.prototype.setupLocalMedia=function(){if(this.video&&this.options.media.local&&this.options.media.local.video){var e,i=this.session.sessionDescriptionHandler.peerConnection;i.getSenders?(e=new t.window.MediaStream,i.getSenders().forEach(function(t){var i=t.track;i&&"video"===i.kind&&e.addTrack(i)})):e=i.getLocalStreams()[0],this.options.media.local.video.srcObject=e,this.options.media.local.video.volume=0,this.options.media.local.video.play()}},s.prototype.cleanupMedia=function(){this.video&&(this.options.media.remote.video.srcObject=null,this.options.media.remote.video.pause(),this.options.media.local&&this.options.media.local.video&&(this.options.media.local.video.srcObject=null,this.options.media.local.video.pause())),this.audio&&(this.options.media.remote.audio.srcObject=null,this.options.media.remote.audio.pause())},s.prototype.setupSession=function(){this.state=i.STATUS_NEW,this.emit("new",this.session),this.session.on("progress",this.onProgress.bind(this)),this.session.on("accepted",this.onAccepted.bind(this)),this.session.on("rejected",this.onEnded.bind(this)),this.session.on("failed",this.onFailed.bind(this)),this.session.on("terminated",this.onEnded.bind(this))},s.prototype.destroyMedia=function(){this.session.sessionDescriptionHandler.close()},s.prototype.toggleMute=function(e){var t=this.session.sessionDescriptionHandler.peerConnection;t.getSenders?t.getSenders().forEach(function(t){t.track&&(t.track.enabled=!e)}):t.getLocalStreams().forEach(function(t){t.getAudioTracks().forEach(function(t){t.enabled=!e}),t.getVideoTracks().forEach(function(t){t.enabled=!e})})},s.prototype.onAccepted=function(){this.state=i.STATUS_CONNECTED,this.emit("connected",this.session),this.setupLocalMedia(),this.setupRemoteMedia(),this.session.sessionDescriptionHandler.on("addTrack",function(){this.logger.log("A track has been added, triggering new remoteMedia setup"),this.setupRemoteMedia()}.bind(this)),this.session.sessionDescriptionHandler.on("addStream",function(){this.logger.log("A stream has been added, trigger new remoteMedia setup"),this.setupRemoteMedia()}.bind(this)),this.session.on("hold",function(){this.emit("hold",this.session)}.bind(this)),this.session.on("unhold",function(){this.emit("unhold",this.session)}.bind(this)),this.session.on("dtmf",function(e){this.emit("dtmf",e)}.bind(this)),this.session.on("bye",this.onEnded.bind(this))},s.prototype.onProgress=function(){this.state=i.STATUS_CONNECTING,this.emit("connecting",this.session)},s.prototype.onFailed=function(){this.onEnded()},s.prototype.onEnded=function(){this.state=i.STATUS_COMPLETED,this.emit("ended",this.session),this.cleanupMedia()},s}}).call(t,i(0))},function(e,t,i){"use strict";(function(t){function s(e,t){if(null!=e){var i=t.charAt(0).toUpperCase()+t.slice(1),s=[t,"webkit"+i,"moz"+i];for(var r in s){var n=e[s[r]];if(n)return n.bind(e)}}}var r=t.window||t;e.exports={WebSocket:r.WebSocket,Transport:i(35),open:r.open,Promise:r.Promise,timers:r,console:r.console||{debug:function(){},log:function(){},warn:function(){},error:function(){}},addEventListener:s(r,"addEventListener"),removeEventListener:s(r,"removeEventListener")}}).call(t,i(0))},function(e,t,i){"use strict";e.exports=function(e,t){var i;return i=function(e,t){this.logger=e.getLogger("sip.transport"),this.ua=e,this.ws=null,this.server=t,this.reconnection_attempts=0,this.closed=!1,this.connected=!1,this.reconnectTimer=null,this.lastTransportError={},this.keepAliveInterval=e.configuration.keepAliveInterval,this.keepAliveTimeout=null,this.keepAliveTimer=null,this.ua.transport=this,this.connect()},i.prototype={send:function(e){var i=e.toString();return this.ws&&this.ws.readyState===t.OPEN?(!0===this.ua.configuration.traceSip&&this.logger.log("sending WebSocket message:\n\n"+i+"\n"),this.ws.send(i),!0):(this.logger.warn("unable to send message, WebSocket is not open"),!1)},sendKeepAlive:function(){if(!this.keepAliveTimeout)return this.keepAliveTimeout=e.Timers.setTimeout(function(){this.ua.emit("keepAliveTimeout")}.bind(this),1e4),this.send("\r\n\r\n")},startSendingKeepAlives:function(){this.keepAliveInterval&&!this.keepAliveTimer&&(this.keepAliveTimer=e.Timers.setTimeout(function(){this.sendKeepAlive(),this.keepAliveTimer=null,this.startSendingKeepAlives()}.bind(this),function(e){var t=.8*e;return 1e3*(Math.random()*(e-t)+t)}(this.keepAliveInterval)))},stopSendingKeepAlives:function(){e.Timers.clearTimeout(this.keepAliveTimer),e.Timers.clearTimeout(this.keepAliveTimeout),this.keepAliveTimer=null,this.keepAliveTimeout=null},disconnect:function(){this.ws&&(e.Timers.clearTimeout(this.reconnectTimer),this.stopSendingKeepAlives(),this.closed=!0,this.logger.log("closing WebSocket "+this.server.ws_uri),this.ws.close(),this.ws=null),null!==this.reconnectTimer&&(e.Timers.clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.ua.emit("disconnected",{transport:this,code:this.lastTransportError.code,reason:this.lastTransportError.reason}))},connect:function(){var e=this;if(this.ws&&(this.ws.readyState===t.OPEN||this.ws.readyState===t.CONNECTING))return this.logger.log("WebSocket "+this.server.ws_uri+" is already connected"),!1;this.ws&&(this.ws.close(),this.ws=null),this.logger.log("connecting to WebSocket "+this.server.ws_uri),this.ua.onTransportConnecting(this,0===this.reconnection_attempts?1:this.reconnection_attempts);try{this.ws=new t(this.server.ws_uri,"sip")}catch(e){this.logger.warn("error connecting to WebSocket "+this.server.ws_uri+": "+e)}this.ws.binaryType="arraybuffer",this.ws.onopen=function(){e.onOpen()},this.ws.onclose=function(t){e.onClose(t),this.onopen=null,this.onclose=null,this.onmessage=null,this.onerror=null},this.ws.onmessage=function(t){e.onMessage(t)},this.ws.onerror=function(t){e.onError(t)}},onOpen:function(){this.connected=!0,this.logger.log("WebSocket "+this.server.ws_uri+" connected"),null!==this.reconnectTimer&&(e.Timers.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.reconnection_attempts=0,this.closed=!1,this.ua.onTransportConnected(this),this.startSendingKeepAlives()},onClose:function(e){var t=this.connected;this.lastTransportError.code=e.code,this.lastTransportError.reason=e.reason,this.stopSendingKeepAlives(),this.reconnection_attempts>0?(this.logger.log("Reconnection attempt "+this.reconnection_attempts+" failed (code: "+e.code+(e.reason?"| reason: "+e.reason:"")+")"),this.reconnect()):(this.connected=!1,this.logger.log("WebSocket disconnected (code: "+e.code+(e.reason?"| reason: "+e.reason:"")+")"),!1===e.wasClean&&this.logger.warn("WebSocket abrupt disconnection"),!0===t?(this.ua.onTransportClosed(this),this.closed?this.ua.emit("disconnected",{transport:this,code:this.lastTransportError.code,reason:this.lastTransportError.reason}):this.reconnect()):this.ua.onTransportError(this))},onMessage:function(t){var i,s,r=t.data;if("\r\n"===r)return e.Timers.clearTimeout(this.keepAliveTimeout),this.keepAliveTimeout=null,void(!0===this.ua.configuration.traceSip&&this.logger.log("received WebSocket message with CRLF Keep Alive response"));if("string"!=typeof r){try{r=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.ua.configuration.traceSip&&this.logger.log("received WebSocket binary message:\n\n"+r+"\n")}else!0===this.ua.configuration.traceSip&&this.logger.log("received WebSocket text message:\n\n"+r+"\n");if((i=e.Parser.parseMessage(r,this.ua))&&!(this.ua.status===e.UA.C.STATUS_USER_CLOSED&&i instanceof e.IncomingRequest)&&e.sanityCheck(i,this.ua,this))if(i instanceof e.IncomingRequest)i.transport=this,this.ua.receiveRequest(i);else if(i instanceof e.IncomingResponse)switch(i.method){case e.C.INVITE:(s=this.ua.transactions.ict[i.via_branch])&&s.receiveResponse(i);break;case e.C.ACK:break;default:(s=this.ua.transactions.nict[i.via_branch])&&s.receiveResponse(i)}},onError:function(e){this.logger.warn("WebSocket connection error: "),this.logger.warn(e)},reconnect:function(){var t=this;this.reconnection_attempts+=1,this.reconnection_attempts>this.ua.configuration.wsServerMaxReconnection?(this.logger.warn("maximum reconnection attempts for WebSocket "+this.server.ws_uri),this.ua.onTransportError(this)):1===this.reconnection_attempts?(this.logger.log("Connection to WebSocket "+this.server.ws_uri+" severed, attempting first reconnect"),t.connect()):(this.logger.log("trying to reconnect to WebSocket "+this.server.ws_uri+" (reconnection attempt "+this.reconnection_attempts+")"),this.reconnectTimer=e.Timers.setTimeout(function(){t.connect(),t.reconnectTimer=null},1e3*this.ua.configuration.wsServerReconnectionTimeout))}},i.C={STATUS_READY:0,STATUS_DISCONNECTED:1,STATUS_ERROR:2},i}}])});