diff --git a/CHANGELOG.md b/CHANGELOG.md index c55b6c0c5..8b22b2415 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +Version 3.0.24 (released in 2017-11-5) +-------------------------------------- +* Fix #421. Fire RTCSession 'peerconnection' event as soon as its created + + Version 3.0.23 (released in 2017-10-31) -------------------------------------- * Fix typo. Thanks @michelepra. diff --git a/dist/jssip.js b/dist/jssip.js index eb3f06190..5eed5910d 100644 --- a/dist/jssip.js +++ b/dist/jssip.js @@ -14907,12 +14907,6 @@ module.exports = function (_EventEmitter) { this._connection.addStream(stream); } - debug('emit "peerconnection"'); - - this.emit('peerconnection', { - peerconnection: this._connection - }); - if (!this._late_sdp) { var e = { originator: 'remote', type: 'offer', sdp: request.body }; @@ -15910,6 +15904,12 @@ module.exports = function (_EventEmitter) { }); } }); + + debug('emit "peerconnection"'); + + this.emit('peerconnection', { + peerconnection: this._connection + }); } }, { key: '_createLocalDescription', @@ -16610,14 +16610,6 @@ module.exports = function (_EventEmitter) { this._connection.addStream(stream); } - debug('emit "peerconnection"'); - - // Notify the app with the RTCPeerConnection so it can do stuff on it - // before generating the offer. - this.emit('peerconnection', { - peerconnection: this._connection - }); - this._connecting(this._request); this._createLocalDescription('offer', rtcSucceeded.bind(this), rtcFailed.bind(this), rtcOfferConstraints); } diff --git a/dist/jssip.min.js b/dist/jssip.min.js index 7a84dc6ad..3f5519da6 100644 --- a/dist/jssip.min.js +++ b/dist/jssip.min.js @@ -6,4 +6,4 @@ * License: MIT */ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).JsSIP=e()}}(function(){return function e(t,n,r){function i(a,o){if(!n[a]){if(!t[a]){var l="function"==typeof require&&require;if(!o&&l)return l(a,!0);if(s)return s(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var c=n[a]={exports:{}};t[a][0].call(c.exports,function(e){var n=t[a][1][e];return i(n||e)},c,c.exports,e,t,n,r)}return n[a].exports}for(var s="function"==typeof require&&require,a=0;a0)return t}},connection_recovery_min_interval:function(e){if(r.isDecimal(e)){var t=Number(e);if(t>0)return t}},contact_uri:function(e){if("string"==typeof e){var t=s.parse(e,"SIP_URI");if(-1!==t)return t}},display_name:function(e){return-1===s.parse('"'+e+'"',"display_name")?void 0:e},instance_id:function(e){return/^uuid:/i.test(e)&&(e=e.substr(5)),-1===s.parse(e,"uuid")?void 0:e},no_answer_timeout:function(e){if(r.isDecimal(e)){var t=Number(e);if(t>0)return t}},session_timers:function(e){if("boolean"==typeof e)return e},password:function(e){return String(e)},realm:function(e){return String(e)},ha1:function(e){return String(e)},register:function(e){if("boolean"==typeof e)return e},register_expires:function(e){if(r.isDecimal(e)){var t=Number(e);if(t>0)return t}},registrar_server:function(e){/^sip:/i.test(e)||(e=i.SIP+":"+e);var t=a.parse(e);return t?t.user?void 0:t:void 0},use_preloaded_route:function(e){if("boolean"==typeof e)return e}}};n.load=function(e,t){for(var n in u.mandatory){if(!t.hasOwnProperty(n))throw new l.ConfigurationError(n);var i=t[n],s=u.mandatory[n](i);if(void 0===s)throw new l.ConfigurationError(n,i);e[n]=s}for(var a in u.optional)if(t.hasOwnProperty(a)){var o=t[a];if(r.isEmpty(o))continue;var c=u.optional[a](o);if(void 0===c)throw new l.ConfigurationError(a,o);e[a]=c}}},{"./Constants":2,"./Exceptions":6,"./Grammar":7,"./Socket":20,"./URI":25,"./Utils":26}],2:[function(e,t,n){"use strict";var r=e("../package.json");t.exports={USER_AGENT:r.title+" "+r.version,SIP:"sip",SIPS:"sips",causes:{CONNECTION_ERROR:"Connection Error",REQUEST_TIMEOUT:"Request Timeout",SIP_FAILURE_CODE:"SIP Failure Code",INTERNAL_ERROR:"Internal Error",BUSY:"Busy",REJECTED:"Rejected",REDIRECTED:"Redirected",UNAVAILABLE:"Unavailable",NOT_FOUND:"Not Found",ADDRESS_INCOMPLETE:"Address Incomplete",INCOMPATIBLE_SDP:"Incompatible SDP",MISSING_SDP:"Missing SDP",AUTHENTICATION_ERROR:"Authentication Error",BYE:"Terminated",WEBRTC_ERROR:"WebRTC Error",CANCELED:"Canceled",NO_ANSWER:"No Answer",EXPIRES:"Expires",NO_ACK:"No ACK",DIALOG_ERROR:"Dialog Error",USER_DENIED_MEDIA_ACCESS:"User Denied Media Access",BAD_MEDIA_DESCRIPTION:"Bad Media Description",RTP_TIMEOUT:"RTP Timeout"},SIP_ERROR_CAUSES:{REDIRECTED:[300,301,302,305,380],BUSY:[486,600],REJECTED:[403,603],NOT_FOUND:[404,604],UNAVAILABLE:[480,410,408,430],ADDRESS_INCOMPLETE:[484,424],INCOMPATIBLE_SDP:[488,606],AUTHENTICATION_ERROR:[401,407]},ACK:"ACK",BYE:"BYE",CANCEL:"CANCEL",INFO:"INFO",INVITE:"INVITE",MESSAGE:"MESSAGE",NOTIFY:"NOTIFY",OPTIONS:"OPTIONS",REGISTER:"REGISTER",REFER:"REFER",UPDATE:"UPDATE",SUBSCRIBE:"SUBSCRIBE",REASON_PHRASE:{100:"Trying",180:"Ringing",181:"Call Is Being Forwarded",182:"Queued",183:"Session Progress",199:"Early Dialog Terminated",200:"OK",202:"Accepted",204:"No Notification",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",305:"Use Proxy",380:"Alternative Service",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",410:"Gone",412:"Conditional Request Failed",413:"Request Entity Too Large",414:"Request-URI Too Long",415:"Unsupported Media Type",416:"Unsupported URI Scheme",417:"Unknown Resource-Priority",420:"Bad Extension",421:"Extension Required",422:"Session Interval Too Small",423:"Interval Too Brief",424:"Bad Location Information",428:"Use Identity Header",429:"Provide Referrer Identity",430:"Flow Failed",433:"Anonymity Disallowed",436:"Bad Identity-Info",437:"Unsupported Certificate",438:"Invalid Identity Header",439:"First Hop Lacks Outbound Support",440:"Max-Breadth Exceeded",469:"Bad Info Package",470:"Consent Needed",478:"Unresolvable Destination",480:"Temporarily Unavailable",481:"Call/Transaction Does Not Exist",482:"Loop Detected",483:"Too Many Hops",484:"Address Incomplete",485:"Ambiguous",486:"Busy Here",487:"Request Terminated",488:"Not Acceptable Here",489:"Bad Event",491:"Request Pending",493:"Undecipherable",494:"Security Agreement Required",500:"JsSIP Internal Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Server Time-out",505:"Version Not Supported",513:"Message Too Large",580:"Precondition Failure",600:"Busy Everywhere",603:"Decline",604:"Does Not Exist Anywhere",606:"Not Acceptable"},ALLOWED_METHODS:"INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO",ACCEPTED_BODY_TYPES:"application/sdp, application/dtmf-relay",MAX_FORWARDS:69,SESSION_EXPIRES:90,MIN_SESSION_EXPIRES:60}},{"../package.json":51}],3:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n3&&void 0!==arguments[3]?arguments[3]:d.STATUS_CONFIRMED;if(r(this,e),this._owner=t,this._ua=t._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,!n.hasHeader("contact"))return{error:"unable to create a Dialog without Contact header field"};n instanceof s.IncomingResponse&&(a=n.status_code<200?d.STATUS_EARLY:d.STATUS_CONFIRMED);var o=n.parseHeader("contact");"UAS"===i?(this._id={call_id:n.call_id,local_tag:n.to_tag,remote_tag:n.from_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._remote_seqnum=n.cseq,this._local_uri=n.parseHeader("to").uri,this._remote_uri=n.parseHeader("from").uri,this._remote_target=o.uri,this._route_set=n.getHeaders("record-route"),this._ack_seqnum=this._remote_seqnum):"UAC"===i&&(this._id={call_id:n.call_id,local_tag:n.from_tag,remote_tag:n.to_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._local_seqnum=n.cseq,this._local_uri=n.parseHeader("from").uri,this._remote_uri=n.parseHeader("to").uri,this._remote_target=o.uri,this._route_set=n.getHeaders("record-route").reverse(),this._ack_seqnum=null),this._ua.newDialog(this),c("new "+i+" dialog created with status "+(this._state===d.STATUS_EARLY?"EARLY":"CONFIRMED"))}return i(e,null,[{key:"C",get:function(){return d}}]),i(e,[{key:"update",value:function(e,t){this._state=d.STATUS_CONFIRMED,c("dialog "+this._id.toString()+" changed to CONFIRMED state"),"UAC"===t&&(this._route_set=e.getHeaders("record-route").reverse())}},{key:"terminate",value:function(){c("dialog "+this._id.toString()+" deleted"),this._ua.destroyDialog(this)}},{key:"sendRequest",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=u.cloneArray(n.extraHeaders),i=n.eventHandlers||{},s=n.body||null,a=this._createRequest(e,r,s);return i.onAuthenticated=function(){t._local_seqnum+=1},new l(this,a,i).send(),a}},{key:"receiveRequest",value:function(e){this._checkInDialogRequest(e)&&(e.method===a.ACK&&null!==this._ack_seqnum?this._ack_seqnum=null:e.method===a.INVITE&&(this._ack_seqnum=e.cseq),this._owner.receiveRequest(e))}},{key:"_createRequest",value:function(e,t,n){t=u.cloneArray(t),this._local_seqnum||(this._local_seqnum=Math.floor(1e4*Math.random()));var r=e===a.CANCEL||e===a.ACK?this._local_seqnum:this._local_seqnum+=1;return new s.OutgoingRequest(e,this._remote_target,this._ua,{cseq:r,call_id:this._id.call_id,from_uri:this._local_uri,from_tag:this._id.local_tag,to_uri:this._remote_uri,to_tag:this._id.remote_tag,route_set:this._route_set},t,n)}},{key:"_checkInDialogRequest",value:function(e){var t=this;if(this._remote_seqnum)if(e.cseqthis._remote_seqnum&&(this._remote_seqnum=e.cseq);else this._remote_seqnum=e.cseq;if(e.method===a.INVITE||e.method===a.UPDATE&&e.body){if(!0===this._uac_pending_reply)e.reply(491);else{if(!0===this._uas_pending_reply){var n=1+(10*Math.random()|0);return e.reply(500,null,["Retry-After:"+n]),!1}this._uas_pending_reply=!0;e.server_transaction.on("stateChanged",function n(){e.server_transaction.state!==o.C.STATUS_ACCEPTED&&e.server_transaction.state!==o.C.STATUS_COMPLETED&&e.server_transaction.state!==o.C.STATUS_TERMINATED||(e.server_transaction.removeListener("stateChanged",n),t._uas_pending_reply=!1)})}e.hasHeader("contact")&&e.server_transaction.on("stateChanged",function(){e.server_transaction.state===o.C.STATUS_ACCEPTED&&(t._remote_target=e.parseHeader("contact").uri)})}else e.method===a.NOTIFY&&e.hasHeader("contact")&&e.server_transaction.on("stateChanged",function(){e.server_transaction.state===o.C.STATUS_COMPLETED&&(t._remote_target=e.parseHeader("contact").uri)});return!0}},{key:"id",get:function(){return this._id}},{key:"local_seqnum",get:function(){return this._local_seqnum},set:function(e){this._local_seqnum=e}},{key:"owner",get:function(){return this._owner}},{key:"uac_pending_reply",get:function(){return this._uac_pending_reply},set:function(e){this._uac_pending_reply=e}},{key:"uas_pending_reply",get:function(){return this._uas_pending_reply}}]),e}()},{"./Constants":2,"./Dialog/RequestSender":4,"./SIPMessage":19,"./Transactions":22,"./Utils":26,debug:29}],4:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n=200&&e.status_code<300?this._eventHandlers.onSuccessResponse(e):e.status_code>=300&&this._eventHandlers.onErrorResponse(e):(this._request.cseq.value=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout(function(){t._dialog.owner.status!==o.C.STATUS_TERMINATED&&(t._reattempt=!0,t._request_sender.send())},1e3)):e.status_code>=200&&e.status_code<300?this._eventHandlers.onSuccessResponse(e):e.status_code>=300&&this._eventHandlers.onErrorResponse(e)}},{key:"request",get:function(){return this._request}}]),e}()},{"../Constants":2,"../RTCSession":12,"../RequestSender":18,"../Transactions":22}],5:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n-1)this._qop="auth";else{if(!(t.qop.indexOf("auth-int")>-1))return o('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;this._qop="auth-int"}else this._qop=null;this._method=n,this._uri=r,this._cnonce=s.createRandomToken(12),this._nc+=1;var i=Number(this._nc).toString(16);this._ncHex="00000000".substr(0,8-i.length)+i,4294967296===this._nc&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=s.calculateMD5(this._credentials.username+":"+this._realm+":"+this._credentials.password):this._ha1=this._credentials.ha1;var l=void 0;return"auth"===this._qop?(l=s.calculateMD5(this._method+":"+this._uri),this._response=s.calculateMD5(this._ha1+":"+this._nonce+":"+this._ncHex+":"+this._cnonce+":auth:"+l)):"auth-int"===this._qop?(l=s.calculateMD5(this._method+":"+this._uri+":"+s.calculateMD5(this.body?this.body:"")),this._response=s.calculateMD5(this._ha1+":"+this._nonce+":"+this._ncHex+":"+this._cnonce+":auth-int:"+l)):null===this._qop&&(l=s.calculateMD5(this._method+":"+this._uri),this._response=s.calculateMD5(this._ha1+":"+this._nonce+":"+l)),a("authenticate() | response generated"),!0}},{key:"toString",value:function(){var e=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return e.push("algorithm="+this._algorithm),e.push('username="'+this._credentials.username+'"'),e.push('realm="'+this._realm+'"'),e.push('nonce="'+this._nonce+'"'),e.push('uri="'+this._uri+'"'),e.push('response="'+this._response+'"'),this._opaque&&e.push('opaque="'+this._opaque+'"'),this._qop&&(e.push("qop="+this._qop),e.push('cnonce="'+this._cnonce+'"'),e.push("nc="+this._ncHex)),"Digest "+e.join(", ")}}]),e}()},{"./Utils":26,debug:29}],6:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=function(e){function t(e,n){r(this,t);var s=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return s.code=1,s.name="CONFIGURATION_ERROR",s.parameter=e,s.value=n,s.message=s.value?"Invalid value "+JSON.stringify(s.value)+' for parameter "'+s.parameter+'"':"Missing parameter: "+s.parameter,s}return s(t,Error),t}(),o=function(e){function t(e){r(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.code=2,n.name="INVALID_STATE_ERROR",n.status=e,n.message="Invalid status: "+e,n}return s(t,Error),t}(),l=function(e){function t(e){r(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.code=3,n.name="NOT_SUPPORTED_ERROR",n.message=e,n}return s(t,Error),t}(),u=function(e){function t(e){r(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.code=4,n.name="NOT_READY_ERROR",n.message=e,n}return s(t,Error),t}();t.exports={ConfigurationError:a,InvalidStateError:o,NotSupportedError:l,NotReadyError:u}},{}],7:[function(e,t,n){"use strict";t.exports=function(){function t(e){return'"'+e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var n={parse:function(n,r){function i(e){UnLn&&(Ln=Un,qn=[]),qn.push(e))}function s(){var e;return"\r\n"===n.substr(Un,2)?(e="\r\n",Un+=2):(e=null,0===Mn&&i('"\\r\\n"')),e}function a(){var e;return/^[0-9]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[0-9]")),e}function o(){var e;return/^[a-zA-Z]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[a-zA-Z]")),e}function l(){var e;return/^[0-9a-fA-F]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[0-9a-fA-F]")),e}function u(){var e;return null===(e=h())&&(e=f()),e}function c(){var e;return/^[\0-\xFF]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[\\0-\\xFF]")),e}function d(){var e;return/^["]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i('["]')),e}function h(){var e;return 32===n.charCodeAt(Un)?(e=" ",Un++):(e=null,0===Mn&&i('" "')),e}function f(){var e;return 9===n.charCodeAt(Un)?(e="\t",Un++):(e=null,0===Mn&&i('"\\t"')),e}function p(){var e;return/^[a-zA-Z0-9]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[a-zA-Z0-9]")),e}function _(){var e;return 59===n.charCodeAt(Un)?(e=";",Un++):(e=null,0===Mn&&i('";"')),null===e&&(47===n.charCodeAt(Un)?(e="/",Un++):(e=null,0===Mn&&i('"/"')),null===e&&(63===n.charCodeAt(Un)?(e="?",Un++):(e=null,0===Mn&&i('"?"')),null===e&&(58===n.charCodeAt(Un)?(e=":",Un++):(e=null,0===Mn&&i('":"')),null===e&&(64===n.charCodeAt(Un)?(e="@",Un++):(e=null,0===Mn&&i('"@"')),null===e&&(38===n.charCodeAt(Un)?(e="&",Un++):(e=null,0===Mn&&i('"&"')),null===e&&(61===n.charCodeAt(Un)?(e="=",Un++):(e=null,0===Mn&&i('"="')),null===e&&(43===n.charCodeAt(Un)?(e="+",Un++):(e=null,0===Mn&&i('"+"')),null===e&&(36===n.charCodeAt(Un)?(e="$",Un++):(e=null,0===Mn&&i('"$"')),null===e&&(44===n.charCodeAt(Un)?(e=",",Un++):(e=null,0===Mn&&i('","'))))))))))),e}function m(){var e;return null===(e=p())&&(e=v()),e}function v(){var e;return 45===n.charCodeAt(Un)?(e="-",Un++):(e=null,0===Mn&&i('"-"')),null===e&&(95===n.charCodeAt(Un)?(e="_",Un++):(e=null,0===Mn&&i('"_"')),null===e&&(46===n.charCodeAt(Un)?(e=".",Un++):(e=null,0===Mn&&i('"."')),null===e&&(33===n.charCodeAt(Un)?(e="!",Un++):(e=null,0===Mn&&i('"!"')),null===e&&(126===n.charCodeAt(Un)?(e="~",Un++):(e=null,0===Mn&&i('"~"')),null===e&&(42===n.charCodeAt(Un)?(e="*",Un++):(e=null,0===Mn&&i('"*"')),null===e&&(39===n.charCodeAt(Un)?(e="'",Un++):(e=null,0===Mn&&i('"\'"')),null===e&&(40===n.charCodeAt(Un)?(e="(",Un++):(e=null,0===Mn&&i('"("')),null===e&&(41===n.charCodeAt(Un)?(e=")",Un++):(e=null,0===Mn&&i('")"')))))))))),e}function g(){var e,t,r,s,a;return s=Un,a=Un,37===n.charCodeAt(Un)?(e="%",Un++):(e=null,0===Mn&&i('"%"')),null!==e&&null!==(t=l())&&null!==(r=l())?e=[e,t,r]:(e=null,Un=a),null!==e&&(e=e.join("")),null===e&&(Un=s),e}function y(){var e,t,n,r,i,a;for(r=Un,i=Un,a=Un,e=[],t=u();null!==t;)e.push(t),t=u();if(null!==e&&null!==(t=s())?e=[e,t]:(e=null,Un=a),null!==(e=null!==e?e:"")){if(null!==(n=u()))for(t=[];null!==n;)t.push(n),n=u();else t=null;null!==t?e=[e,t]:(e=null,Un=i)}else e=null,Un=i;return null!==e&&(e=" "),null===e&&(Un=r),e}function T(){var e;return e=y(),e=null!==e?e:""}function C(){var e,t,r,s,a;for(s=Un,a=Un,e=[],null===(t=h())&&(t=f());null!==t;)e.push(t),null===(t=h())&&(t=f());return null!==e?(58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(r=T())?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=":"),null===e&&(Un=s),e}function S(){var e,t,r,i,s,a,o;if(s=Un,a=Un,null!==(t=E()))for(e=[];null!==t;)e.push(t),t=E();else e=null;if(null!==e){for(t=[],o=Un,r=[],i=y();null!==i;)r.push(i),i=y();for(null!==r&&null!==(i=E())?r=[r,i]:(r=null,Un=o);null!==r;){for(t.push(r),o=Un,r=[],i=y();null!==i;)r.push(i),i=y();null!==r&&null!==(i=E())?r=[r,i]:(r=null,Un=o)}null!==t?e=[e,t]:(e=null,Un=a)}else e=null,Un=a;return null!==e&&(e=function(e){return n.substring(Un,e)}(s)),null===e&&(Un=s),e}function E(){var e;return/^[!-~]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[!-~]")),null===e&&(e=b()),e}function b(){var e;return/^[\x80-\uFFFF]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[\\x80-\\uFFFF]")),e}function R(){var e;return/^[\x80-\xBF]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[\\x80-\\xBF]")),e}function A(){var e,t,r;if(r=Un,null===(t=p())&&(45===n.charCodeAt(Un)?(t="-",Un++):(t=null,0===Mn&&i('"-"')),null===t&&(46===n.charCodeAt(Un)?(t=".",Un++):(t=null,0===Mn&&i('"."')),null===t&&(33===n.charCodeAt(Un)?(t="!",Un++):(t=null,0===Mn&&i('"!"')),null===t&&(37===n.charCodeAt(Un)?(t="%",Un++):(t=null,0===Mn&&i('"%"')),null===t&&(42===n.charCodeAt(Un)?(t="*",Un++):(t=null,0===Mn&&i('"*"')),null===t&&(95===n.charCodeAt(Un)?(t="_",Un++):(t=null,0===Mn&&i('"_"')),null===t&&(43===n.charCodeAt(Un)?(t="+",Un++):(t=null,0===Mn&&i('"+"')),null===t&&(96===n.charCodeAt(Un)?(t="`",Un++):(t=null,0===Mn&&i('"`"')),null===t&&(39===n.charCodeAt(Un)?(t="'",Un++):(t=null,0===Mn&&i('"\'"')),null===t&&(126===n.charCodeAt(Un)?(t="~",Un++):(t=null,0===Mn&&i('"~"')))))))))))),null!==t)for(e=[];null!==t;)e.push(t),null===(t=p())&&(45===n.charCodeAt(Un)?(t="-",Un++):(t=null,0===Mn&&i('"-"')),null===t&&(46===n.charCodeAt(Un)?(t=".",Un++):(t=null,0===Mn&&i('"."')),null===t&&(33===n.charCodeAt(Un)?(t="!",Un++):(t=null,0===Mn&&i('"!"')),null===t&&(37===n.charCodeAt(Un)?(t="%",Un++):(t=null,0===Mn&&i('"%"')),null===t&&(42===n.charCodeAt(Un)?(t="*",Un++):(t=null,0===Mn&&i('"*"')),null===t&&(95===n.charCodeAt(Un)?(t="_",Un++):(t=null,0===Mn&&i('"_"')),null===t&&(43===n.charCodeAt(Un)?(t="+",Un++):(t=null,0===Mn&&i('"+"')),null===t&&(96===n.charCodeAt(Un)?(t="`",Un++):(t=null,0===Mn&&i('"`"')),null===t&&(39===n.charCodeAt(Un)?(t="'",Un++):(t=null,0===Mn&&i('"\'"')),null===t&&(126===n.charCodeAt(Un)?(t="~",Un++):(t=null,0===Mn&&i('"~"'))))))))))));else e=null;return null!==e&&(e=function(e){return n.substring(Un,e)}(r)),null===e&&(Un=r),e}function w(){var e,t,r;if(r=Un,null===(t=p())&&(45===n.charCodeAt(Un)?(t="-",Un++):(t=null,0===Mn&&i('"-"')),null===t&&(33===n.charCodeAt(Un)?(t="!",Un++):(t=null,0===Mn&&i('"!"')),null===t&&(37===n.charCodeAt(Un)?(t="%",Un++):(t=null,0===Mn&&i('"%"')),null===t&&(42===n.charCodeAt(Un)?(t="*",Un++):(t=null,0===Mn&&i('"*"')),null===t&&(95===n.charCodeAt(Un)?(t="_",Un++):(t=null,0===Mn&&i('"_"')),null===t&&(43===n.charCodeAt(Un)?(t="+",Un++):(t=null,0===Mn&&i('"+"')),null===t&&(96===n.charCodeAt(Un)?(t="`",Un++):(t=null,0===Mn&&i('"`"')),null===t&&(39===n.charCodeAt(Un)?(t="'",Un++):(t=null,0===Mn&&i('"\'"')),null===t&&(126===n.charCodeAt(Un)?(t="~",Un++):(t=null,0===Mn&&i('"~"'))))))))))),null!==t)for(e=[];null!==t;)e.push(t),null===(t=p())&&(45===n.charCodeAt(Un)?(t="-",Un++):(t=null,0===Mn&&i('"-"')),null===t&&(33===n.charCodeAt(Un)?(t="!",Un++):(t=null,0===Mn&&i('"!"')),null===t&&(37===n.charCodeAt(Un)?(t="%",Un++):(t=null,0===Mn&&i('"%"')),null===t&&(42===n.charCodeAt(Un)?(t="*",Un++):(t=null,0===Mn&&i('"*"')),null===t&&(95===n.charCodeAt(Un)?(t="_",Un++):(t=null,0===Mn&&i('"_"')),null===t&&(43===n.charCodeAt(Un)?(t="+",Un++):(t=null,0===Mn&&i('"+"')),null===t&&(96===n.charCodeAt(Un)?(t="`",Un++):(t=null,0===Mn&&i('"`"')),null===t&&(39===n.charCodeAt(Un)?(t="'",Un++):(t=null,0===Mn&&i('"\'"')),null===t&&(126===n.charCodeAt(Un)?(t="~",Un++):(t=null,0===Mn&&i('"~"')))))))))));else e=null;return null!==e&&(e=function(e){return n.substring(Un,e)}(r)),null===e&&(Un=r),e}function I(){var e,t,r;if(r=Un,null===(t=p())&&(45===n.charCodeAt(Un)?(t="-",Un++):(t=null,0===Mn&&i('"-"')),null===t&&(46===n.charCodeAt(Un)?(t=".",Un++):(t=null,0===Mn&&i('"."')),null===t&&(33===n.charCodeAt(Un)?(t="!",Un++):(t=null,0===Mn&&i('"!"')),null===t&&(37===n.charCodeAt(Un)?(t="%",Un++):(t=null,0===Mn&&i('"%"')),null===t&&(42===n.charCodeAt(Un)?(t="*",Un++):(t=null,0===Mn&&i('"*"')),null===t&&(95===n.charCodeAt(Un)?(t="_",Un++):(t=null,0===Mn&&i('"_"')),null===t&&(43===n.charCodeAt(Un)?(t="+",Un++):(t=null,0===Mn&&i('"+"')),null===t&&(96===n.charCodeAt(Un)?(t="`",Un++):(t=null,0===Mn&&i('"`"')),null===t&&(39===n.charCodeAt(Un)?(t="'",Un++):(t=null,0===Mn&&i('"\'"')),null===t&&(126===n.charCodeAt(Un)?(t="~",Un++):(t=null,0===Mn&&i('"~"')),null===t&&(40===n.charCodeAt(Un)?(t="(",Un++):(t=null,0===Mn&&i('"("')),null===t&&(41===n.charCodeAt(Un)?(t=")",Un++):(t=null,0===Mn&&i('")"')),null===t&&(60===n.charCodeAt(Un)?(t="<",Un++):(t=null,0===Mn&&i('"<"')),null===t&&(62===n.charCodeAt(Un)?(t=">",Un++):(t=null,0===Mn&&i('">"')),null===t&&(58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null===t&&(92===n.charCodeAt(Un)?(t="\\",Un++):(t=null,0===Mn&&i('"\\\\"')),null===t&&null===(t=d())&&(47===n.charCodeAt(Un)?(t="/",Un++):(t=null,0===Mn&&i('"/"')),null===t&&(91===n.charCodeAt(Un)?(t="[",Un++):(t=null,0===Mn&&i('"["')),null===t&&(93===n.charCodeAt(Un)?(t="]",Un++):(t=null,0===Mn&&i('"]"')),null===t&&(63===n.charCodeAt(Un)?(t="?",Un++):(t=null,0===Mn&&i('"?"')),null===t&&(123===n.charCodeAt(Un)?(t="{",Un++):(t=null,0===Mn&&i('"{"')),null===t&&(125===n.charCodeAt(Un)?(t="}",Un++):(t=null,0===Mn&&i('"}"')))))))))))))))))))))))),null!==t)for(e=[];null!==t;)e.push(t),null===(t=p())&&(45===n.charCodeAt(Un)?(t="-",Un++):(t=null,0===Mn&&i('"-"')),null===t&&(46===n.charCodeAt(Un)?(t=".",Un++):(t=null,0===Mn&&i('"."')),null===t&&(33===n.charCodeAt(Un)?(t="!",Un++):(t=null,0===Mn&&i('"!"')),null===t&&(37===n.charCodeAt(Un)?(t="%",Un++):(t=null,0===Mn&&i('"%"')),null===t&&(42===n.charCodeAt(Un)?(t="*",Un++):(t=null,0===Mn&&i('"*"')),null===t&&(95===n.charCodeAt(Un)?(t="_",Un++):(t=null,0===Mn&&i('"_"')),null===t&&(43===n.charCodeAt(Un)?(t="+",Un++):(t=null,0===Mn&&i('"+"')),null===t&&(96===n.charCodeAt(Un)?(t="`",Un++):(t=null,0===Mn&&i('"`"')),null===t&&(39===n.charCodeAt(Un)?(t="'",Un++):(t=null,0===Mn&&i('"\'"')),null===t&&(126===n.charCodeAt(Un)?(t="~",Un++):(t=null,0===Mn&&i('"~"')),null===t&&(40===n.charCodeAt(Un)?(t="(",Un++):(t=null,0===Mn&&i('"("')),null===t&&(41===n.charCodeAt(Un)?(t=")",Un++):(t=null,0===Mn&&i('")"')),null===t&&(60===n.charCodeAt(Un)?(t="<",Un++):(t=null,0===Mn&&i('"<"')),null===t&&(62===n.charCodeAt(Un)?(t=">",Un++):(t=null,0===Mn&&i('">"')),null===t&&(58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null===t&&(92===n.charCodeAt(Un)?(t="\\",Un++):(t=null,0===Mn&&i('"\\\\"')),null===t&&null===(t=d())&&(47===n.charCodeAt(Un)?(t="/",Un++):(t=null,0===Mn&&i('"/"')),null===t&&(91===n.charCodeAt(Un)?(t="[",Un++):(t=null,0===Mn&&i('"["')),null===t&&(93===n.charCodeAt(Un)?(t="]",Un++):(t=null,0===Mn&&i('"]"')),null===t&&(63===n.charCodeAt(Un)?(t="?",Un++):(t=null,0===Mn&&i('"?"')),null===t&&(123===n.charCodeAt(Un)?(t="{",Un++):(t=null,0===Mn&&i('"{"')),null===t&&(125===n.charCodeAt(Un)?(t="}",Un++):(t=null,0===Mn&&i('"}"'))))))))))))))))))))))));else e=null;return null!==e&&(e=function(e){return n.substring(Un,e)}(r)),null===e&&(Un=r),e}function k(){var e,t,r,s,a;return s=Un,a=Un,null!==(e=T())?(42===n.charCodeAt(Un)?(t="*",Un++):(t=null,0===Mn&&i('"*"')),null!==t&&null!==(r=T())?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e="*"),null===e&&(Un=s),e}function O(){var e,t,r,s,a;return s=Un,a=Un,null!==(e=T())?(47===n.charCodeAt(Un)?(t="/",Un++):(t=null,0===Mn&&i('"/"')),null!==t&&null!==(r=T())?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e="/"),null===e&&(Un=s),e}function P(){var e,t,r,s,a;return s=Un,a=Un,null!==(e=T())?(61===n.charCodeAt(Un)?(t="=",Un++):(t=null,0===Mn&&i('"="')),null!==t&&null!==(r=T())?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e="="),null===e&&(Un=s),e}function x(){var e,t,r,s,a;return s=Un,a=Un,null!==(e=T())?(40===n.charCodeAt(Un)?(t="(",Un++):(t=null,0===Mn&&i('"("')),null!==t&&null!==(r=T())?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e="("),null===e&&(Un=s),e}function N(){var e,t,r,s,a;return s=Un,a=Un,null!==(e=T())?(41===n.charCodeAt(Un)?(t=")",Un++):(t=null,0===Mn&&i('")"')),null!==t&&null!==(r=T())?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=")"),null===e&&(Un=s),e}function D(){var e,t,r,s;return r=Un,s=Un,62===n.charCodeAt(Un)?(e=">",Un++):(e=null,0===Mn&&i('">"')),null!==e&&null!==(t=T())?e=[e,t]:(e=null,Un=s),null!==e&&(e=">"),null===e&&(Un=r),e}function U(){var e,t,r,s;return r=Un,s=Un,null!==(e=T())?(60===n.charCodeAt(Un)?(t="<",Un++):(t=null,0===Mn&&i('"<"')),null!==t?e=[e,t]:(e=null,Un=s)):(e=null,Un=s),null!==e&&(e="<"),null===e&&(Un=r),e}function M(){var e,t,r,s,a;return s=Un,a=Un,null!==(e=T())?(44===n.charCodeAt(Un)?(t=",",Un++):(t=null,0===Mn&&i('","')),null!==t&&null!==(r=T())?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=","),null===e&&(Un=s),e}function L(){var e,t,r,s,a;return s=Un,a=Un,null!==(e=T())?(59===n.charCodeAt(Un)?(t=";",Un++):(t=null,0===Mn&&i('";"')),null!==t&&null!==(r=T())?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=";"),null===e&&(Un=s),e}function q(){var e,t,r,s,a;return s=Un,a=Un,null!==(e=T())?(58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(r=T())?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=":"),null===e&&(Un=s),e}function H(){var e,t,n,r;return n=Un,r=Un,null!==(e=T())&&null!==(t=d())?e=[e,t]:(e=null,Un=r),null!==e&&(e='"'),null===e&&(Un=n),e}function F(){var e,t,n,r;return n=Un,r=Un,null!==(e=d())&&null!==(t=T())?e=[e,t]:(e=null,Un=r),null!==e&&(e='"'),null===e&&(Un=n),e}function j(){var e,t,n,r;if(r=Un,null!==(e=x())){for(t=[],null===(n=G())&&null===(n=J())&&(n=j());null!==n;)t.push(n),null===(n=G())&&null===(n=J())&&(n=j());null!==t&&null!==(n=N())?e=[e,t,n]:(e=null,Un=r)}else e=null,Un=r;return e}function G(){var e;return/^[!-']/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[!-']")),null===e&&(/^[*-[]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[*-[]")),null===e&&(/^[\]-~]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[\\]-~]")),null===e&&null===(e=b())&&(e=y()))),e}function B(){var e,t,r,i,s,a;if(s=Un,a=Un,null!==(e=T()))if(null!==(t=d())){for(r=[],null===(i=V())&&(i=J());null!==i;)r.push(i),null===(i=V())&&(i=J());null!==r&&null!==(i=d())?e=[e,t,r,i]:(e=null,Un=a)}else e=null,Un=a;else e=null,Un=a;return null!==e&&(e=function(e){return n.substring(Un,e)}(s)),null===e&&(Un=s),e}function W(){var e,t,r,i,s,a;if(s=Un,a=Un,null!==(e=T()))if(null!==(t=d())){for(r=[],null===(i=V())&&(i=J());null!==i;)r.push(i),null===(i=V())&&(i=J());null!==r&&null!==(i=d())?e=[e,t,r,i]:(e=null,Un=a)}else e=null,Un=a;else e=null,Un=a;return null!==e&&(e=function(e){return n.substring(Un-1,e+1)}(s)),null===e&&(Un=s),e}function V(){var e;return null===(e=y())&&(33===n.charCodeAt(Un)?(e="!",Un++):(e=null,0===Mn&&i('"!"')),null===e&&(/^[#-[]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[#-[]")),null===e&&(/^[\]-~]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[\\]-~]")),null===e&&(e=b())))),e}function J(){var e,t,r;return r=Un,92===n.charCodeAt(Un)?(e="\\",Un++):(e=null,0===Mn&&i('"\\\\"')),null!==e?(/^[\0-\t]/.test(n.charAt(Un))?(t=n.charAt(Un),Un++):(t=null,0===Mn&&i("[\\0-\\t]")),null===t&&(/^[\x0B-\f]/.test(n.charAt(Un))?(t=n.charAt(Un),Un++):(t=null,0===Mn&&i("[\\x0B-\\f]")),null===t&&(/^[\x0E-]/.test(n.charAt(Un))?(t=n.charAt(Un),Un++):(t=null,0===Mn&&i("[\\x0E-]")))),null!==t?e=[e,t]:(e=null,Un=r)):(e=null,Un=r),e}function K(){var e,t,r,s,a,o;return a=Un,o=Un,null!==(e=Y())?(58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(r=null!==(r=Q())?r:"")&&null!==(s=ne())?e=[e,t,r,s]:(e=null,Un=o)):(e=null,Un=o),null!==e&&(e=function(e){try{jn.uri=new Hn(jn.scheme,jn.user,jn.host,jn.port),delete jn.scheme,delete jn.user,delete jn.host,delete jn.host_type,delete jn.port}catch(e){jn=-1}}()),null===e&&(Un=a),e}function z(){var e,t,s,a,o,l,u,c;return u=Un,c=Un,null!==(e=Y())?(58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(s=null!==(s=Q())?s:"")&&null!==(a=ne())&&null!==(o=pe())&&null!==(l=null!==(l=we())?l:"")?e=[e,t,s,a,o,l]:(e=null,Un=c)):(e=null,Un=c),null!==e&&(e=function(e){try{jn.uri=new Hn(jn.scheme,jn.user,jn.host,jn.port,jn.uri_params,jn.uri_headers),delete jn.scheme,delete jn.user,delete jn.host,delete jn.host_type,delete jn.port,delete jn.uri_params,"SIP_URI"===r&&(jn=jn.uri)}catch(e){jn=-1}}()),null===e&&(Un=u),e}function Y(){var e;return null===(e=$())&&(e=X()),e}function $(){var e,t;return t=Un,"sips"===n.substr(Un,4).toLowerCase()?(e=n.substr(Un,4),Un+=4):(e=null,0===Mn&&i('"sips"')),null!==e&&(e=function(e,t){jn.scheme=t.toLowerCase()}(0,e)),null===e&&(Un=t),e}function X(){var e,t;return t=Un,"sip"===n.substr(Un,3).toLowerCase()?(e=n.substr(Un,3),Un+=3):(e=null,0===Mn&&i('"sip"')),null!==e&&(e=function(e,t){jn.scheme=t.toLowerCase()}(0,e)),null===e&&(Un=t),e}function Q(){var e,t,r,s,a,o;return s=Un,a=Un,null!==(e=Z())?(o=Un,58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(r=te())?t=[t,r]:(t=null,Un=o),null!==(t=null!==t?t:"")?(64===n.charCodeAt(Un)?(r="@",Un++):(r=null,0===Mn&&i('"@"')),null!==r?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=function(e){jn.user=decodeURIComponent(n.substring(Un-1,e))}(s)),null===e&&(Un=s),e}function Z(){var e,t;if(null===(t=m())&&null===(t=g())&&(t=ee()),null!==t)for(e=[];null!==t;)e.push(t),null===(t=m())&&null===(t=g())&&(t=ee());else e=null;return e}function ee(){var e;return 38===n.charCodeAt(Un)?(e="&",Un++):(e=null,0===Mn&&i('"&"')),null===e&&(61===n.charCodeAt(Un)?(e="=",Un++):(e=null,0===Mn&&i('"="')),null===e&&(43===n.charCodeAt(Un)?(e="+",Un++):(e=null,0===Mn&&i('"+"')),null===e&&(36===n.charCodeAt(Un)?(e="$",Un++):(e=null,0===Mn&&i('"$"')),null===e&&(44===n.charCodeAt(Un)?(e=",",Un++):(e=null,0===Mn&&i('","')),null===e&&(59===n.charCodeAt(Un)?(e=";",Un++):(e=null,0===Mn&&i('";"')),null===e&&(63===n.charCodeAt(Un)?(e="?",Un++):(e=null,0===Mn&&i('"?"')),null===e&&(47===n.charCodeAt(Un)?(e="/",Un++):(e=null,0===Mn&&i('"/"'))))))))),e}function te(){var e,t,r;for(r=Un,e=[],null===(t=m())&&null===(t=g())&&(38===n.charCodeAt(Un)?(t="&",Un++):(t=null,0===Mn&&i('"&"')),null===t&&(61===n.charCodeAt(Un)?(t="=",Un++):(t=null,0===Mn&&i('"="')),null===t&&(43===n.charCodeAt(Un)?(t="+",Un++):(t=null,0===Mn&&i('"+"')),null===t&&(36===n.charCodeAt(Un)?(t="$",Un++):(t=null,0===Mn&&i('"$"')),null===t&&(44===n.charCodeAt(Un)?(t=",",Un++):(t=null,0===Mn&&i('","')))))));null!==t;)e.push(t),null===(t=m())&&null===(t=g())&&(38===n.charCodeAt(Un)?(t="&",Un++):(t=null,0===Mn&&i('"&"')),null===t&&(61===n.charCodeAt(Un)?(t="=",Un++):(t=null,0===Mn&&i('"="')),null===t&&(43===n.charCodeAt(Un)?(t="+",Un++):(t=null,0===Mn&&i('"+"')),null===t&&(36===n.charCodeAt(Un)?(t="$",Un++):(t=null,0===Mn&&i('"$"')),null===t&&(44===n.charCodeAt(Un)?(t=",",Un++):(t=null,0===Mn&&i('","')))))));return null!==e&&(e=function(e){jn.password=n.substring(Un,e)}(r)),null===e&&(Un=r),e}function ne(){var e,t,r,s,a;return s=Un,null!==(e=re())?(a=Un,58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(r=fe())?t=[t,r]:(t=null,Un=a),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,Un=s)):(e=null,Un=s),e}function re(){var e,t;return t=Un,null===(e=ie())&&null===(e=de())&&(e=oe()),null!==e&&(e=function(e){return jn.host=n.substring(Un,e).toLowerCase(),jn.host}(t)),null===e&&(Un=t),e}function ie(){var e,t,r,s,a,o;for(s=Un,a=Un,e=[],o=Un,null!==(t=se())?(46===n.charCodeAt(Un)?(r=".",Un++):(r=null,0===Mn&&i('"."')),null!==r?t=[t,r]:(t=null,Un=o)):(t=null,Un=o);null!==t;)e.push(t),o=Un,null!==(t=se())?(46===n.charCodeAt(Un)?(r=".",Un++):(r=null,0===Mn&&i('"."')),null!==r?t=[t,r]:(t=null,Un=o)):(t=null,Un=o);return null!==e&&null!==(t=ae())?(46===n.charCodeAt(Un)?(r=".",Un++):(r=null,0===Mn&&i('"."')),null!==(r=null!==r?r:"")?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=function(e){return jn.host_type="domain",n.substring(Un,e)}(s)),null===e&&(Un=s),e}function se(){var e,t,r,s;if(s=Un,null!==(e=p())){for(t=[],null===(r=p())&&(45===n.charCodeAt(Un)?(r="-",Un++):(r=null,0===Mn&&i('"-"')),null===r&&(95===n.charCodeAt(Un)?(r="_",Un++):(r=null,0===Mn&&i('"_"'))));null!==r;)t.push(r),null===(r=p())&&(45===n.charCodeAt(Un)?(r="-",Un++):(r=null,0===Mn&&i('"-"')),null===r&&(95===n.charCodeAt(Un)?(r="_",Un++):(r=null,0===Mn&&i('"_"'))));null!==t?e=[e,t]:(e=null,Un=s)}else e=null,Un=s;return e}function ae(){var e,t,r,s;if(s=Un,null!==(e=o())){for(t=[],null===(r=p())&&(45===n.charCodeAt(Un)?(r="-",Un++):(r=null,0===Mn&&i('"-"')),null===r&&(95===n.charCodeAt(Un)?(r="_",Un++):(r=null,0===Mn&&i('"_"'))));null!==r;)t.push(r),null===(r=p())&&(45===n.charCodeAt(Un)?(r="-",Un++):(r=null,0===Mn&&i('"-"')),null===r&&(95===n.charCodeAt(Un)?(r="_",Un++):(r=null,0===Mn&&i('"_"'))));null!==t?e=[e,t]:(e=null,Un=s)}else e=null,Un=s;return e}function oe(){var e,t,r,s,a;return s=Un,a=Un,91===n.charCodeAt(Un)?(e="[",Un++):(e=null,0===Mn&&i('"["')),null!==e&&null!==(t=le())?(93===n.charCodeAt(Un)?(r="]",Un++):(r=null,0===Mn&&i('"]"')),null!==r?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=function(e){return jn.host_type="IPv6",n.substring(Un,e)}(s)),null===e&&(Un=s),e}function le(){var e,t,r,s,a,o,l,u,c,d,h,f,p,_,m,v;return _=Un,m=Un,null!==(e=ue())?(58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(r=ue())?(58===n.charCodeAt(Un)?(s=":",Un++):(s=null,0===Mn&&i('":"')),null!==s&&null!==(a=ue())?(58===n.charCodeAt(Un)?(o=":",Un++):(o=null,0===Mn&&i('":"')),null!==o&&null!==(l=ue())?(58===n.charCodeAt(Un)?(u=":",Un++):(u=null,0===Mn&&i('":"')),null!==u&&null!==(c=ue())?(58===n.charCodeAt(Un)?(d=":",Un++):(d=null,0===Mn&&i('":"')),null!==d&&null!==(h=ue())?(58===n.charCodeAt(Un)?(f=":",Un++):(f=null,0===Mn&&i('":"')),null!==f&&null!==(p=ce())?e=[e,t,r,s,a,o,l,u,c,d,h,f,p]:(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m),null===e&&(m=Un,"::"===n.substr(Un,2)?(e="::",Un+=2):(e=null,0===Mn&&i('"::"')),null!==e&&null!==(t=ue())?(58===n.charCodeAt(Un)?(r=":",Un++):(r=null,0===Mn&&i('":"')),null!==r&&null!==(s=ue())?(58===n.charCodeAt(Un)?(a=":",Un++):(a=null,0===Mn&&i('":"')),null!==a&&null!==(o=ue())?(58===n.charCodeAt(Un)?(l=":",Un++):(l=null,0===Mn&&i('":"')),null!==l&&null!==(u=ue())?(58===n.charCodeAt(Un)?(c=":",Un++):(c=null,0===Mn&&i('":"')),null!==c&&null!==(d=ue())?(58===n.charCodeAt(Un)?(h=":",Un++):(h=null,0===Mn&&i('":"')),null!==h&&null!==(f=ce())?e=[e,t,r,s,a,o,l,u,c,d,h,f]:(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m),null===e&&(m=Un,"::"===n.substr(Un,2)?(e="::",Un+=2):(e=null,0===Mn&&i('"::"')),null!==e&&null!==(t=ue())?(58===n.charCodeAt(Un)?(r=":",Un++):(r=null,0===Mn&&i('":"')),null!==r&&null!==(s=ue())?(58===n.charCodeAt(Un)?(a=":",Un++):(a=null,0===Mn&&i('":"')),null!==a&&null!==(o=ue())?(58===n.charCodeAt(Un)?(l=":",Un++):(l=null,0===Mn&&i('":"')),null!==l&&null!==(u=ue())?(58===n.charCodeAt(Un)?(c=":",Un++):(c=null,0===Mn&&i('":"')),null!==c&&null!==(d=ce())?e=[e,t,r,s,a,o,l,u,c,d]:(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m),null===e&&(m=Un,"::"===n.substr(Un,2)?(e="::",Un+=2):(e=null,0===Mn&&i('"::"')),null!==e&&null!==(t=ue())?(58===n.charCodeAt(Un)?(r=":",Un++):(r=null,0===Mn&&i('":"')),null!==r&&null!==(s=ue())?(58===n.charCodeAt(Un)?(a=":",Un++):(a=null,0===Mn&&i('":"')),null!==a&&null!==(o=ue())?(58===n.charCodeAt(Un)?(l=":",Un++):(l=null,0===Mn&&i('":"')),null!==l&&null!==(u=ce())?e=[e,t,r,s,a,o,l,u]:(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m),null===e&&(m=Un,"::"===n.substr(Un,2)?(e="::",Un+=2):(e=null,0===Mn&&i('"::"')),null!==e&&null!==(t=ue())?(58===n.charCodeAt(Un)?(r=":",Un++):(r=null,0===Mn&&i('":"')),null!==r&&null!==(s=ue())?(58===n.charCodeAt(Un)?(a=":",Un++):(a=null,0===Mn&&i('":"')),null!==a&&null!==(o=ce())?e=[e,t,r,s,a,o]:(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m),null===e&&(m=Un,"::"===n.substr(Un,2)?(e="::",Un+=2):(e=null,0===Mn&&i('"::"')),null!==e&&null!==(t=ue())?(58===n.charCodeAt(Un)?(r=":",Un++):(r=null,0===Mn&&i('":"')),null!==r&&null!==(s=ce())?e=[e,t,r,s]:(e=null,Un=m)):(e=null,Un=m),null===e&&(m=Un,"::"===n.substr(Un,2)?(e="::",Un+=2):(e=null,0===Mn&&i('"::"')),null!==e&&null!==(t=ce())?e=[e,t]:(e=null,Un=m),null===e&&(m=Un,"::"===n.substr(Un,2)?(e="::",Un+=2):(e=null,0===Mn&&i('"::"')),null!==e&&null!==(t=ue())?e=[e,t]:(e=null,Un=m),null===e&&(m=Un,null!==(e=ue())?("::"===n.substr(Un,2)?(t="::",Un+=2):(t=null,0===Mn&&i('"::"')),null!==t&&null!==(r=ue())?(58===n.charCodeAt(Un)?(s=":",Un++):(s=null,0===Mn&&i('":"')),null!==s&&null!==(a=ue())?(58===n.charCodeAt(Un)?(o=":",Un++):(o=null,0===Mn&&i('":"')),null!==o&&null!==(l=ue())?(58===n.charCodeAt(Un)?(u=":",Un++):(u=null,0===Mn&&i('":"')),null!==u&&null!==(c=ue())?(58===n.charCodeAt(Un)?(d=":",Un++):(d=null,0===Mn&&i('":"')),null!==d&&null!==(h=ce())?e=[e,t,r,s,a,o,l,u,c,d,h]:(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m),null===e&&(m=Un,null!==(e=ue())?(v=Un,58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(r=ue())?t=[t,r]:(t=null,Un=v),null!==(t=null!==t?t:"")?("::"===n.substr(Un,2)?(r="::",Un+=2):(r=null,0===Mn&&i('"::"')),null!==r&&null!==(s=ue())?(58===n.charCodeAt(Un)?(a=":",Un++):(a=null,0===Mn&&i('":"')),null!==a&&null!==(o=ue())?(58===n.charCodeAt(Un)?(l=":",Un++):(l=null,0===Mn&&i('":"')),null!==l&&null!==(u=ue())?(58===n.charCodeAt(Un)?(c=":",Un++):(c=null,0===Mn&&i('":"')),null!==c&&null!==(d=ce())?e=[e,t,r,s,a,o,l,u,c,d]:(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m),null===e&&(m=Un,null!==(e=ue())?(v=Un,58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(r=ue())?t=[t,r]:(t=null,Un=v),null!==(t=null!==t?t:"")?(v=Un,58===n.charCodeAt(Un)?(r=":",Un++):(r=null,0===Mn&&i('":"')),null!==r&&null!==(s=ue())?r=[r,s]:(r=null,Un=v),null!==(r=null!==r?r:"")?("::"===n.substr(Un,2)?(s="::",Un+=2):(s=null,0===Mn&&i('"::"')),null!==s&&null!==(a=ue())?(58===n.charCodeAt(Un)?(o=":",Un++):(o=null,0===Mn&&i('":"')),null!==o&&null!==(l=ue())?(58===n.charCodeAt(Un)?(u=":",Un++):(u=null,0===Mn&&i('":"')),null!==u&&null!==(c=ce())?e=[e,t,r,s,a,o,l,u,c]:(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m),null===e&&(m=Un,null!==(e=ue())?(v=Un,58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(r=ue())?t=[t,r]:(t=null,Un=v),null!==(t=null!==t?t:"")?(v=Un,58===n.charCodeAt(Un)?(r=":",Un++):(r=null,0===Mn&&i('":"')),null!==r&&null!==(s=ue())?r=[r,s]:(r=null,Un=v),null!==(r=null!==r?r:"")?(v=Un,58===n.charCodeAt(Un)?(s=":",Un++):(s=null,0===Mn&&i('":"')),null!==s&&null!==(a=ue())?s=[s,a]:(s=null,Un=v),null!==(s=null!==s?s:"")?("::"===n.substr(Un,2)?(a="::",Un+=2):(a=null,0===Mn&&i('"::"')),null!==a&&null!==(o=ue())?(58===n.charCodeAt(Un)?(l=":",Un++):(l=null,0===Mn&&i('":"')),null!==l&&null!==(u=ce())?e=[e,t,r,s,a,o,l,u]:(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m),null===e&&(m=Un,null!==(e=ue())?(v=Un,58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(r=ue())?t=[t,r]:(t=null,Un=v),null!==(t=null!==t?t:"")?(v=Un,58===n.charCodeAt(Un)?(r=":",Un++):(r=null,0===Mn&&i('":"')),null!==r&&null!==(s=ue())?r=[r,s]:(r=null,Un=v),null!==(r=null!==r?r:"")?(v=Un,58===n.charCodeAt(Un)?(s=":",Un++):(s=null,0===Mn&&i('":"')),null!==s&&null!==(a=ue())?s=[s,a]:(s=null,Un=v),null!==(s=null!==s?s:"")?(v=Un,58===n.charCodeAt(Un)?(a=":",Un++):(a=null,0===Mn&&i('":"')),null!==a&&null!==(o=ue())?a=[a,o]:(a=null,Un=v),null!==(a=null!==a?a:"")?("::"===n.substr(Un,2)?(o="::",Un+=2):(o=null,0===Mn&&i('"::"')),null!==o&&null!==(l=ce())?e=[e,t,r,s,a,o,l]:(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m),null===e&&(m=Un,null!==(e=ue())?(v=Un,58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(r=ue())?t=[t,r]:(t=null,Un=v),null!==(t=null!==t?t:"")?(v=Un,58===n.charCodeAt(Un)?(r=":",Un++):(r=null,0===Mn&&i('":"')),null!==r&&null!==(s=ue())?r=[r,s]:(r=null,Un=v),null!==(r=null!==r?r:"")?(v=Un,58===n.charCodeAt(Un)?(s=":",Un++):(s=null,0===Mn&&i('":"')),null!==s&&null!==(a=ue())?s=[s,a]:(s=null,Un=v),null!==(s=null!==s?s:"")?(v=Un,58===n.charCodeAt(Un)?(a=":",Un++):(a=null,0===Mn&&i('":"')),null!==a&&null!==(o=ue())?a=[a,o]:(a=null,Un=v),null!==(a=null!==a?a:"")?(v=Un,58===n.charCodeAt(Un)?(o=":",Un++):(o=null,0===Mn&&i('":"')),null!==o&&null!==(l=ue())?o=[o,l]:(o=null,Un=v),null!==(o=null!==o?o:"")?("::"===n.substr(Un,2)?(l="::",Un+=2):(l=null,0===Mn&&i('"::"')),null!==l&&null!==(u=ue())?e=[e,t,r,s,a,o,l,u]:(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m),null===e&&(m=Un,null!==(e=ue())?(v=Un,58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(r=ue())?t=[t,r]:(t=null,Un=v),null!==(t=null!==t?t:"")?(v=Un,58===n.charCodeAt(Un)?(r=":",Un++):(r=null,0===Mn&&i('":"')),null!==r&&null!==(s=ue())?r=[r,s]:(r=null,Un=v),null!==(r=null!==r?r:"")?(v=Un,58===n.charCodeAt(Un)?(s=":",Un++):(s=null,0===Mn&&i('":"')),null!==s&&null!==(a=ue())?s=[s,a]:(s=null,Un=v),null!==(s=null!==s?s:"")?(v=Un,58===n.charCodeAt(Un)?(a=":",Un++):(a=null,0===Mn&&i('":"')),null!==a&&null!==(o=ue())?a=[a,o]:(a=null,Un=v),null!==(a=null!==a?a:"")?(v=Un,58===n.charCodeAt(Un)?(o=":",Un++):(o=null,0===Mn&&i('":"')),null!==o&&null!==(l=ue())?o=[o,l]:(o=null,Un=v),null!==(o=null!==o?o:"")?(v=Un,58===n.charCodeAt(Un)?(l=":",Un++):(l=null,0===Mn&&i('":"')),null!==l&&null!==(u=ue())?l=[l,u]:(l=null,Un=v),null!==(l=null!==l?l:"")?("::"===n.substr(Un,2)?(u="::",Un+=2):(u=null,0===Mn&&i('"::"')),null!==u?e=[e,t,r,s,a,o,l,u]:(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m))))))))))))))),null!==e&&(e=function(e){return jn.host_type="IPv6",n.substring(Un,e)}(_)),null===e&&(Un=_),e}function ue(){var e,t,n,r,i;return i=Un,null!==(e=l())&&null!==(t=null!==(t=l())?t:"")&&null!==(n=null!==(n=l())?n:"")&&null!==(r=null!==(r=l())?r:"")?e=[e,t,n,r]:(e=null,Un=i),e}function ce(){var e,t,r,s;return s=Un,null!==(e=ue())?(58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(r=ue())?e=[e,t,r]:(e=null,Un=s)):(e=null,Un=s),null===e&&(e=de()),e}function de(){var e,t,r,s,a,o,l,u,c;return u=Un,c=Un,null!==(e=he())?(46===n.charCodeAt(Un)?(t=".",Un++):(t=null,0===Mn&&i('"."')),null!==t&&null!==(r=he())?(46===n.charCodeAt(Un)?(s=".",Un++):(s=null,0===Mn&&i('"."')),null!==s&&null!==(a=he())?(46===n.charCodeAt(Un)?(o=".",Un++):(o=null,0===Mn&&i('"."')),null!==o&&null!==(l=he())?e=[e,t,r,s,a,o,l]:(e=null,Un=c)):(e=null,Un=c)):(e=null,Un=c)):(e=null,Un=c),null!==e&&(e=function(e){return jn.host_type="IPv4",n.substring(Un,e)}(u)),null===e&&(Un=u),e}function he(){var e,t,r,s;return s=Un,"25"===n.substr(Un,2)?(e="25",Un+=2):(e=null,0===Mn&&i('"25"')),null!==e?(/^[0-5]/.test(n.charAt(Un))?(t=n.charAt(Un),Un++):(t=null,0===Mn&&i("[0-5]")),null!==t?e=[e,t]:(e=null,Un=s)):(e=null,Un=s),null===e&&(s=Un,50===n.charCodeAt(Un)?(e="2",Un++):(e=null,0===Mn&&i('"2"')),null!==e?(/^[0-4]/.test(n.charAt(Un))?(t=n.charAt(Un),Un++):(t=null,0===Mn&&i("[0-4]")),null!==t&&null!==(r=a())?e=[e,t,r]:(e=null,Un=s)):(e=null,Un=s),null===e&&(s=Un,49===n.charCodeAt(Un)?(e="1",Un++):(e=null,0===Mn&&i('"1"')),null!==e&&null!==(t=a())&&null!==(r=a())?e=[e,t,r]:(e=null,Un=s),null===e&&(s=Un,/^[1-9]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[1-9]")),null!==e&&null!==(t=a())?e=[e,t]:(e=null,Un=s),null===e&&(e=a())))),e}function fe(){var e,t,n,r,i,s,o;return s=Un,o=Un,e=a(),null!==(e=null!==e?e:"")&&null!==(t=null!==(t=a())?t:"")&&null!==(n=null!==(n=a())?n:"")&&null!==(r=null!==(r=a())?r:"")&&null!==(i=null!==(i=a())?i:"")?e=[e,t,n,r,i]:(e=null,Un=o),null!==e&&(e=function(e,t){return t=parseInt(t.join("")),jn.port=t,t}(0,e)),null===e&&(Un=s),e}function pe(){var e,t,r,s;for(e=[],s=Un,59===n.charCodeAt(Un)?(t=";",Un++):(t=null,0===Mn&&i('";"')),null!==t&&null!==(r=_e())?t=[t,r]:(t=null,Un=s);null!==t;)e.push(t),s=Un,59===n.charCodeAt(Un)?(t=";",Un++):(t=null,0===Mn&&i('";"')),null!==t&&null!==(r=_e())?t=[t,r]:(t=null,Un=s);return e}function _e(){var e;return null===(e=me())&&null===(e=ve())&&null===(e=ge())&&null===(e=ye())&&null===(e=Te())&&null===(e=Ce())&&(e=Se()),e}function me(){var e,t,r,s;return r=Un,s=Un,"transport="===n.substr(Un,10).toLowerCase()?(e=n.substr(Un,10),Un+=10):(e=null,0===Mn&&i('"transport="')),null!==e?("udp"===n.substr(Un,3).toLowerCase()?(t=n.substr(Un,3),Un+=3):(t=null,0===Mn&&i('"udp"')),null===t&&("tcp"===n.substr(Un,3).toLowerCase()?(t=n.substr(Un,3),Un+=3):(t=null,0===Mn&&i('"tcp"')),null===t&&("sctp"===n.substr(Un,4).toLowerCase()?(t=n.substr(Un,4),Un+=4):(t=null,0===Mn&&i('"sctp"')),null===t&&("tls"===n.substr(Un,3).toLowerCase()?(t=n.substr(Un,3),Un+=3):(t=null,0===Mn&&i('"tls"')),null===t&&(t=A())))),null!==t?e=[e,t]:(e=null,Un=s)):(e=null,Un=s),null!==e&&(e=function(e,t){jn.uri_params||(jn.uri_params={}),jn.uri_params.transport=t.toLowerCase()}(0,e[1])),null===e&&(Un=r),e}function ve(){var e,t,r,s;return r=Un,s=Un,"user="===n.substr(Un,5).toLowerCase()?(e=n.substr(Un,5),Un+=5):(e=null,0===Mn&&i('"user="')),null!==e?("phone"===n.substr(Un,5).toLowerCase()?(t=n.substr(Un,5),Un+=5):(t=null,0===Mn&&i('"phone"')),null===t&&("ip"===n.substr(Un,2).toLowerCase()?(t=n.substr(Un,2),Un+=2):(t=null,0===Mn&&i('"ip"')),null===t&&(t=A())),null!==t?e=[e,t]:(e=null,Un=s)):(e=null,Un=s),null!==e&&(e=function(e,t){jn.uri_params||(jn.uri_params={}),jn.uri_params.user=t.toLowerCase()}(0,e[1])),null===e&&(Un=r),e}function ge(){var e,t,r,s;return r=Un,s=Un,"method="===n.substr(Un,7).toLowerCase()?(e=n.substr(Un,7),Un+=7):(e=null,0===Mn&&i('"method="')),null!==e&&null!==(t=at())?e=[e,t]:(e=null,Un=s),null!==e&&(e=function(e,t){jn.uri_params||(jn.uri_params={}),jn.uri_params.method=t}(0,e[1])),null===e&&(Un=r),e}function ye(){var e,t,r,s;return r=Un,s=Un,"ttl="===n.substr(Un,4).toLowerCase()?(e=n.substr(Un,4),Un+=4):(e=null,0===Mn&&i('"ttl="')),null!==e&&null!==(t=Tn())?e=[e,t]:(e=null,Un=s),null!==e&&(e=function(e,t){jn.params||(jn.params={}),jn.params.ttl=t}(0,e[1])),null===e&&(Un=r),e}function Te(){var e,t,r,s;return r=Un,s=Un,"maddr="===n.substr(Un,6).toLowerCase()?(e=n.substr(Un,6),Un+=6):(e=null,0===Mn&&i('"maddr="')),null!==e&&null!==(t=re())?e=[e,t]:(e=null,Un=s),null!==e&&(e=function(e,t){jn.uri_params||(jn.uri_params={}),jn.uri_params.maddr=t}(0,e[1])),null===e&&(Un=r),e}function Ce(){var e,t,r,s,a,o;return s=Un,a=Un,"lr"===n.substr(Un,2).toLowerCase()?(e=n.substr(Un,2),Un+=2):(e=null,0===Mn&&i('"lr"')),null!==e?(o=Un,61===n.charCodeAt(Un)?(t="=",Un++):(t=null,0===Mn&&i('"="')),null!==t&&null!==(r=A())?t=[t,r]:(t=null,Un=o),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(jn.uri_params||(jn.uri_params={}),e=void(jn.uri_params.lr=void 0)),null===e&&(Un=s),e}function Se(){var e,t,r,s,a,o;return s=Un,a=Un,null!==(e=Ee())?(o=Un,61===n.charCodeAt(Un)?(t="=",Un++):(t=null,0===Mn&&i('"="')),null!==t&&null!==(r=be())?t=[t,r]:(t=null,Un=o),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=function(e,t,n){jn.uri_params||(jn.uri_params={}),n=void 0===n?void 0:n[1],jn.uri_params[t.toLowerCase()]=n}(0,e[0],e[1])),null===e&&(Un=s),e}function Ee(){var e,t,n;if(n=Un,null!==(t=Re()))for(e=[];null!==t;)e.push(t),t=Re();else e=null;return null!==e&&(e=e.join("")),null===e&&(Un=n),e}function be(){var e,t,n;if(n=Un,null!==(t=Re()))for(e=[];null!==t;)e.push(t),t=Re();else e=null;return null!==e&&(e=e.join("")),null===e&&(Un=n),e}function Re(){var e;return null===(e=Ae())&&null===(e=m())&&(e=g()),e}function Ae(){var e;return 91===n.charCodeAt(Un)?(e="[",Un++):(e=null,0===Mn&&i('"["')),null===e&&(93===n.charCodeAt(Un)?(e="]",Un++):(e=null,0===Mn&&i('"]"')),null===e&&(47===n.charCodeAt(Un)?(e="/",Un++):(e=null,0===Mn&&i('"/"')),null===e&&(58===n.charCodeAt(Un)?(e=":",Un++):(e=null,0===Mn&&i('":"')),null===e&&(38===n.charCodeAt(Un)?(e="&",Un++):(e=null,0===Mn&&i('"&"')),null===e&&(43===n.charCodeAt(Un)?(e="+",Un++):(e=null,0===Mn&&i('"+"')),null===e&&(36===n.charCodeAt(Un)?(e="$",Un++):(e=null,0===Mn&&i('"$"')))))))),e}function we(){var e,t,r,s,a,o,l;if(o=Un,63===n.charCodeAt(Un)?(e="?",Un++):(e=null,0===Mn&&i('"?"')),null!==e)if(null!==(t=Ie())){for(r=[],l=Un,38===n.charCodeAt(Un)?(s="&",Un++):(s=null,0===Mn&&i('"&"')),null!==s&&null!==(a=Ie())?s=[s,a]:(s=null,Un=l);null!==s;)r.push(s),l=Un,38===n.charCodeAt(Un)?(s="&",Un++):(s=null,0===Mn&&i('"&"')),null!==s&&null!==(a=Ie())?s=[s,a]:(s=null,Un=l);null!==r?e=[e,t,r]:(e=null,Un=o)}else e=null,Un=o;else e=null,Un=o;return e}function Ie(){var e,t,r,s,a;return s=Un,a=Un,null!==(e=ke())?(61===n.charCodeAt(Un)?(t="=",Un++):(t=null,0===Mn&&i('"="')),null!==t&&null!==(r=Oe())?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=function(e,t,n){t=t.join("").toLowerCase(),n=n.join(""),jn.uri_headers||(jn.uri_headers={}),jn.uri_headers[t]?jn.uri_headers[t].push(n):jn.uri_headers[t]=[n]}(0,e[0],e[2])),null===e&&(Un=s),e}function ke(){var e,t;if(null===(t=Pe())&&null===(t=m())&&(t=g()),null!==t)for(e=[];null!==t;)e.push(t),null===(t=Pe())&&null===(t=m())&&(t=g());else e=null;return e}function Oe(){var e,t;for(e=[],null===(t=Pe())&&null===(t=m())&&(t=g());null!==t;)e.push(t),null===(t=Pe())&&null===(t=m())&&(t=g());return e}function Pe(){var e;return 91===n.charCodeAt(Un)?(e="[",Un++):(e=null,0===Mn&&i('"["')),null===e&&(93===n.charCodeAt(Un)?(e="]",Un++):(e=null,0===Mn&&i('"]"')),null===e&&(47===n.charCodeAt(Un)?(e="/",Un++):(e=null,0===Mn&&i('"/"')),null===e&&(63===n.charCodeAt(Un)?(e="?",Un++):(e=null,0===Mn&&i('"?"')),null===e&&(58===n.charCodeAt(Un)?(e=":",Un++):(e=null,0===Mn&&i('":"')),null===e&&(43===n.charCodeAt(Un)?(e="+",Un++):(e=null,0===Mn&&i('"+"')),null===e&&(36===n.charCodeAt(Un)?(e="$",Un++):(e=null,0===Mn&&i('"$"')))))))),e}function xe(){var e,t,n,r,i,s;return s=Un,null!==(e=at())&&null!==(t=h())&&null!==(n=Ne())&&null!==(r=h())&&null!==(i=$e())?e=[e,t,n,r,i]:(e=null,Un=s),e}function Ne(){var e;return null===(e=z())&&(e=De()),e}function De(){var e,t,r,s;return s=Un,null!==(e=Ve())?(58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t?(null===(r=Ue())&&(r=qe()),null!==r?e=[e,t,r]:(e=null,Un=s)):(e=null,Un=s)):(e=null,Un=s),e}function Ue(){var e,t,r,s,a;return s=Un,null===(e=Me())&&(e=Le()),null!==e?(a=Un,63===n.charCodeAt(Un)?(t="?",Un++):(t=null,0===Mn&&i('"?"')),null!==t&&null!==(r=Ye())?t=[t,r]:(t=null,Un=a),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,Un=s)):(e=null,Un=s),e}function Me(){var e,t,r,s;return s=Un,"//"===n.substr(Un,2)?(e="//",Un+=2):(e=null,0===Mn&&i('"//"')),null!==e&&null!==(t=Je())&&null!==(r=null!==(r=Le())?r:"")?e=[e,t,r]:(e=null,Un=s),e}function Le(){var e,t,r;return r=Un,47===n.charCodeAt(Un)?(e="/",Un++):(e=null,0===Mn&&i('"/"')),null!==e&&null!==(t=je())?e=[e,t]:(e=null,Un=r),e}function qe(){var e,t,n,r;if(r=Un,null!==(e=Fe())){for(t=[],n=He();null!==n;)t.push(n),n=He();null!==t?e=[e,t]:(e=null,Un=r)}else e=null,Un=r;return e}function He(){var e;return null===(e=_())&&null===(e=m())&&(e=g()),e}function Fe(){var e;return null===(e=m())&&null===(e=g())&&(59===n.charCodeAt(Un)?(e=";",Un++):(e=null,0===Mn&&i('";"')),null===e&&(63===n.charCodeAt(Un)?(e="?",Un++):(e=null,0===Mn&&i('"?"')),null===e&&(58===n.charCodeAt(Un)?(e=":",Un++):(e=null,0===Mn&&i('":"')),null===e&&(64===n.charCodeAt(Un)?(e="@",Un++):(e=null,0===Mn&&i('"@"')),null===e&&(38===n.charCodeAt(Un)?(e="&",Un++):(e=null,0===Mn&&i('"&"')),null===e&&(61===n.charCodeAt(Un)?(e="=",Un++):(e=null,0===Mn&&i('"="')),null===e&&(43===n.charCodeAt(Un)?(e="+",Un++):(e=null,0===Mn&&i('"+"')),null===e&&(36===n.charCodeAt(Un)?(e="$",Un++):(e=null,0===Mn&&i('"$"')),null===e&&(44===n.charCodeAt(Un)?(e=",",Un++):(e=null,0===Mn&&i('","'))))))))))),e}function je(){var e,t,r,s,a,o;if(a=Un,null!==(e=Ge())){for(t=[],o=Un,47===n.charCodeAt(Un)?(r="/",Un++):(r=null,0===Mn&&i('"/"')),null!==r&&null!==(s=Ge())?r=[r,s]:(r=null,Un=o);null!==r;)t.push(r),o=Un,47===n.charCodeAt(Un)?(r="/",Un++):(r=null,0===Mn&&i('"/"')),null!==r&&null!==(s=Ge())?r=[r,s]:(r=null,Un=o);null!==t?e=[e,t]:(e=null,Un=a)}else e=null,Un=a;return e}function Ge(){var e,t,r,s,a,o;for(a=Un,e=[],t=We();null!==t;)e.push(t),t=We();if(null!==e){for(t=[],o=Un,59===n.charCodeAt(Un)?(r=";",Un++):(r=null,0===Mn&&i('";"')),null!==r&&null!==(s=Be())?r=[r,s]:(r=null,Un=o);null!==r;)t.push(r),o=Un,59===n.charCodeAt(Un)?(r=";",Un++):(r=null,0===Mn&&i('";"')),null!==r&&null!==(s=Be())?r=[r,s]:(r=null,Un=o);null!==t?e=[e,t]:(e=null,Un=a)}else e=null,Un=a;return e}function Be(){var e,t;for(e=[],t=We();null!==t;)e.push(t),t=We();return e}function We(){var e;return null===(e=m())&&null===(e=g())&&(58===n.charCodeAt(Un)?(e=":",Un++):(e=null,0===Mn&&i('":"')),null===e&&(64===n.charCodeAt(Un)?(e="@",Un++):(e=null,0===Mn&&i('"@"')),null===e&&(38===n.charCodeAt(Un)?(e="&",Un++):(e=null,0===Mn&&i('"&"')),null===e&&(61===n.charCodeAt(Un)?(e="=",Un++):(e=null,0===Mn&&i('"="')),null===e&&(43===n.charCodeAt(Un)?(e="+",Un++):(e=null,0===Mn&&i('"+"')),null===e&&(36===n.charCodeAt(Un)?(e="$",Un++):(e=null,0===Mn&&i('"$"')),null===e&&(44===n.charCodeAt(Un)?(e=",",Un++):(e=null,0===Mn&&i('","'))))))))),e}function Ve(){var e,t,r,s,l;if(s=Un,l=Un,null!==(e=o())){for(t=[],null===(r=o())&&null===(r=a())&&(43===n.charCodeAt(Un)?(r="+",Un++):(r=null,0===Mn&&i('"+"')),null===r&&(45===n.charCodeAt(Un)?(r="-",Un++):(r=null,0===Mn&&i('"-"')),null===r&&(46===n.charCodeAt(Un)?(r=".",Un++):(r=null,0===Mn&&i('"."')))));null!==r;)t.push(r),null===(r=o())&&null===(r=a())&&(43===n.charCodeAt(Un)?(r="+",Un++):(r=null,0===Mn&&i('"+"')),null===r&&(45===n.charCodeAt(Un)?(r="-",Un++):(r=null,0===Mn&&i('"-"')),null===r&&(46===n.charCodeAt(Un)?(r=".",Un++):(r=null,0===Mn&&i('"."')))));null!==t?e=[e,t]:(e=null,Un=l)}else e=null,Un=l;return null!==e&&(e=function(e){jn.scheme=n.substring(Un,e)}(s)),null===e&&(Un=s),e}function Je(){var e;return null===(e=Ke())&&(e=ze()),e}function Ke(){var e,t,r,s;return r=Un,s=Un,null!==(e=Q())?(64===n.charCodeAt(Un)?(t="@",Un++):(t=null,0===Mn&&i('"@"')),null!==t?e=[e,t]:(e=null,Un=s)):(e=null,Un=s),null!==(e=null!==e?e:"")&&null!==(t=ne())?e=[e,t]:(e=null,Un=r),e=null!==e?e:""}function ze(){var e,t;if(null===(t=m())&&null===(t=g())&&(36===n.charCodeAt(Un)?(t="$",Un++):(t=null,0===Mn&&i('"$"')),null===t&&(44===n.charCodeAt(Un)?(t=",",Un++):(t=null,0===Mn&&i('","')),null===t&&(59===n.charCodeAt(Un)?(t=";",Un++):(t=null,0===Mn&&i('";"')),null===t&&(58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null===t&&(64===n.charCodeAt(Un)?(t="@",Un++):(t=null,0===Mn&&i('"@"')),null===t&&(38===n.charCodeAt(Un)?(t="&",Un++):(t=null,0===Mn&&i('"&"')),null===t&&(61===n.charCodeAt(Un)?(t="=",Un++):(t=null,0===Mn&&i('"="')),null===t&&(43===n.charCodeAt(Un)?(t="+",Un++):(t=null,0===Mn&&i('"+"')))))))))),null!==t)for(e=[];null!==t;)e.push(t),null===(t=m())&&null===(t=g())&&(36===n.charCodeAt(Un)?(t="$",Un++):(t=null,0===Mn&&i('"$"')),null===t&&(44===n.charCodeAt(Un)?(t=",",Un++):(t=null,0===Mn&&i('","')),null===t&&(59===n.charCodeAt(Un)?(t=";",Un++):(t=null,0===Mn&&i('";"')),null===t&&(58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null===t&&(64===n.charCodeAt(Un)?(t="@",Un++):(t=null,0===Mn&&i('"@"')),null===t&&(38===n.charCodeAt(Un)?(t="&",Un++):(t=null,0===Mn&&i('"&"')),null===t&&(61===n.charCodeAt(Un)?(t="=",Un++):(t=null,0===Mn&&i('"="')),null===t&&(43===n.charCodeAt(Un)?(t="+",Un++):(t=null,0===Mn&&i('"+"'))))))))));else e=null;return e}function Ye(){var e,t;for(e=[],t=He();null!==t;)e.push(t),t=He();return e}function $e(){var e,t,r,s,o,l,u,c;if(u=Un,c=Un,"sip"===n.substr(Un,3).toLowerCase()?(e=n.substr(Un,3),Un+=3):(e=null,0===Mn&&i('"SIP"')),null!==e)if(47===n.charCodeAt(Un)?(t="/",Un++):(t=null,0===Mn&&i('"/"')),null!==t){if(null!==(s=a()))for(r=[];null!==s;)r.push(s),s=a();else r=null;if(null!==r)if(46===n.charCodeAt(Un)?(s=".",Un++):(s=null,0===Mn&&i('"."')),null!==s){if(null!==(l=a()))for(o=[];null!==l;)o.push(l),l=a();else o=null;null!==o?e=[e,t,r,s,o]:(e=null,Un=c)}else e=null,Un=c;else e=null,Un=c}else e=null,Un=c;else e=null,Un=c;return null!==e&&(e=function(e){jn.sip_version=n.substring(Un,e)}(u)),null===e&&(Un=u),e}function Xe(){var e;return"INVITE"===n.substr(Un,6)?(e="INVITE",Un+=6):(e=null,0===Mn&&i('"INVITE"')),e}function Qe(){var e;return"ACK"===n.substr(Un,3)?(e="ACK",Un+=3):(e=null,0===Mn&&i('"ACK"')),e}function Ze(){var e;return"OPTIONS"===n.substr(Un,7)?(e="OPTIONS",Un+=7):(e=null,0===Mn&&i('"OPTIONS"')),e}function et(){var e;return"BYE"===n.substr(Un,3)?(e="BYE",Un+=3):(e=null,0===Mn&&i('"BYE"')),e}function tt(){var e;return"CANCEL"===n.substr(Un,6)?(e="CANCEL",Un+=6):(e=null,0===Mn&&i('"CANCEL"')),e}function nt(){var e;return"REGISTER"===n.substr(Un,8)?(e="REGISTER",Un+=8):(e=null,0===Mn&&i('"REGISTER"')),e}function rt(){var e;return"SUBSCRIBE"===n.substr(Un,9)?(e="SUBSCRIBE",Un+=9):(e=null,0===Mn&&i('"SUBSCRIBE"')),e}function it(){var e;return"NOTIFY"===n.substr(Un,6)?(e="NOTIFY",Un+=6):(e=null,0===Mn&&i('"NOTIFY"')),e}function st(){var e;return"REFER"===n.substr(Un,5)?(e="REFER",Un+=5):(e=null,0===Mn&&i('"REFER"')),e}function at(){var e,t;return t=Un,null===(e=Xe())&&null===(e=Qe())&&null===(e=Ze())&&null===(e=et())&&null===(e=tt())&&null===(e=nt())&&null===(e=rt())&&null===(e=it())&&null===(e=st())&&(e=A()),null!==e&&(e=function(e){return jn.method=n.substring(Un,e),jn.method}(t)),null===e&&(Un=t),e}function ot(){var e,t,n,r,i,s;return s=Un,null!==(e=$e())&&null!==(t=h())&&null!==(n=lt())&&null!==(r=h())&&null!==(i=ct())?e=[e,t,n,r,i]:(e=null,Un=s),e}function lt(){var e,t;return t=Un,null!==(e=ut())&&(e=function(e,t){jn.status_code=parseInt(t.join(""))}(0,e)),null===e&&(Un=t),e}function ut(){var e,t,n,r;return r=Un,null!==(e=a())&&null!==(t=a())&&null!==(n=a())?e=[e,t,n]:(e=null,Un=r),e}function ct(){var e,t,r;for(r=Un,e=[],null===(t=_())&&null===(t=m())&&null===(t=g())&&null===(t=b())&&null===(t=R())&&null===(t=h())&&(t=f());null!==t;)e.push(t),null===(t=_())&&null===(t=m())&&null===(t=g())&&null===(t=b())&&null===(t=R())&&null===(t=h())&&(t=f());return null!==e&&(e=function(e){jn.reason_phrase=n.substring(Un,e)}(r)),null===e&&(Un=r),e}function dt(){var e,t,n,r,i,s,a;if(i=Un,s=Un,null===(e=K())&&(e=ht()),null!==e){for(t=[],a=Un,null!==(n=L())&&null!==(r=pt())?n=[n,r]:(n=null,Un=a);null!==n;)t.push(n),a=Un,null!==(n=L())&&null!==(r=pt())?n=[n,r]:(n=null,Un=a);null!==t?e=[e,t]:(e=null,Un=s)}else e=null,Un=s;return null!==e&&(e=function(e){var t;jn.multi_header||(jn.multi_header=[]);try{t=new Fn(jn.uri,jn.display_name,jn.params),delete jn.uri,delete jn.display_name,delete jn.params}catch(e){t=null}jn.multi_header.push({possition:Un,offset:e,parsed:t})}(i)),null===e&&(Un=i),e}function ht(){var e,t,n,r,i;return i=Un,e=ft(),null!==(e=null!==e?e:"")&&null!==(t=U())&&null!==(n=z())&&null!==(r=D())?e=[e,t,n,r]:(e=null,Un=i),e}function ft(){var e,t,r,i,s,a,o;if(s=Un,a=Un,null!==(e=A())){for(t=[],o=Un,null!==(r=y())&&null!==(i=A())?r=[r,i]:(r=null,Un=o);null!==r;)t.push(r),o=Un,null!==(r=y())&&null!==(i=A())?r=[r,i]:(r=null,Un=o);null!==t?e=[e,t]:(e=null,Un=a)}else e=null,Un=a;return null===e&&(e=B()),null!==e&&(e=function(e,t){'"'===(t=n.substring(Un,e).trim())[0]&&(t=t.substring(1,t.length-1)),jn.display_name=t}(s,e)),null===e&&(Un=s),e}function pt(){var e;return null===(e=_t())&&null===(e=mt())&&(e=yt()),e}function _t(){var e,t,r,s,a;return s=Un,a=Un,"q"===n.substr(Un,1).toLowerCase()?(e=n.substr(Un,1),Un++):(e=null,0===Mn&&i('"q"')),null!==e&&null!==(t=P())&&null!==(r=gt())?e=[e,t,r]:(e=null,Un=a),null!==e&&(e=function(e,t){jn.params||(jn.params={}),jn.params.q=t}(0,e[2])),null===e&&(Un=s),e}function mt(){var e,t,r,s,a;return s=Un,a=Un,"expires"===n.substr(Un,7).toLowerCase()?(e=n.substr(Un,7),Un+=7):(e=null,0===Mn&&i('"expires"')),null!==e&&null!==(t=P())&&null!==(r=vt())?e=[e,t,r]:(e=null,Un=a),null!==e&&(e=function(e,t){jn.params||(jn.params={}),jn.params.expires=t}(0,e[2])),null===e&&(Un=s),e}function vt(){var e,t,n;if(n=Un,null!==(t=a()))for(e=[];null!==t;)e.push(t),t=a();else e=null;return null!==e&&(e=function(e,t){return parseInt(t.join(""))}(0,e)),null===e&&(Un=n),e}function gt(){var e,t,r,s,o,l,u,c;return l=Un,u=Un,48===n.charCodeAt(Un)?(e="0",Un++):(e=null,0===Mn&&i('"0"')),null!==e?(c=Un,46===n.charCodeAt(Un)?(t=".",Un++):(t=null,0===Mn&&i('"."')),null!==t&&null!==(r=null!==(r=a())?r:"")&&null!==(s=null!==(s=a())?s:"")&&null!==(o=null!==(o=a())?o:"")?t=[t,r,s,o]:(t=null,Un=c),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,Un=u)):(e=null,Un=u),null!==e&&(e=function(e){return parseFloat(n.substring(Un,e))}(l)),null===e&&(Un=l),e}function yt(){var e,t,n,r,i,s;return r=Un,i=Un,null!==(e=A())?(s=Un,null!==(t=P())&&null!==(n=Tt())?t=[t,n]:(t=null,Un=s),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,Un=i)):(e=null,Un=i),null!==e&&(e=function(e,t,n){jn.params||(jn.params={}),n=void 0===n?void 0:n[1],jn.params[t.toLowerCase()]=n}(0,e[0],e[1])),null===e&&(Un=r),e}function Tt(){var e;return null===(e=A())&&null===(e=re())&&(e=B()),e}function Ct(){var e;return"render"===n.substr(Un,6).toLowerCase()?(e=n.substr(Un,6),Un+=6):(e=null,0===Mn&&i('"render"')),null===e&&("session"===n.substr(Un,7).toLowerCase()?(e=n.substr(Un,7),Un+=7):(e=null,0===Mn&&i('"session"')),null===e&&("icon"===n.substr(Un,4).toLowerCase()?(e=n.substr(Un,4),Un+=4):(e=null,0===Mn&&i('"icon"')),null===e&&("alert"===n.substr(Un,5).toLowerCase()?(e=n.substr(Un,5),Un+=5):(e=null,0===Mn&&i('"alert"')),null===e&&(e=A())))),e}function St(){var e;return null===(e=Et())&&(e=yt()),e}function Et(){var e,t,r,s;return s=Un,"handling"===n.substr(Un,8).toLowerCase()?(e=n.substr(Un,8),Un+=8):(e=null,0===Mn&&i('"handling"')),null!==e&&null!==(t=P())?("optional"===n.substr(Un,8).toLowerCase()?(r=n.substr(Un,8),Un+=8):(r=null,0===Mn&&i('"optional"')),null===r&&("required"===n.substr(Un,8).toLowerCase()?(r=n.substr(Un,8),Un+=8):(r=null,0===Mn&&i('"required"')),null===r&&(r=A())),null!==r?e=[e,t,r]:(e=null,Un=s)):(e=null,Un=s),e}function bt(){var e,t,n,r,i,s,a,o;if(a=Un,null!==(e=Rt()))if(null!==(t=O()))if(null!==(n=Ot())){for(r=[],o=Un,null!==(i=L())&&null!==(s=Pt())?i=[i,s]:(i=null,Un=o);null!==i;)r.push(i),o=Un,null!==(i=L())&&null!==(s=Pt())?i=[i,s]:(i=null,Un=o);null!==r?e=[e,t,n,r]:(e=null,Un=a)}else e=null,Un=a;else e=null,Un=a;else e=null,Un=a;return e}function Rt(){var e;return null===(e=At())&&(e=wt()),e}function At(){var e;return"text"===n.substr(Un,4).toLowerCase()?(e=n.substr(Un,4),Un+=4):(e=null,0===Mn&&i('"text"')),null===e&&("image"===n.substr(Un,5).toLowerCase()?(e=n.substr(Un,5),Un+=5):(e=null,0===Mn&&i('"image"')),null===e&&("audio"===n.substr(Un,5).toLowerCase()?(e=n.substr(Un,5),Un+=5):(e=null,0===Mn&&i('"audio"')),null===e&&("video"===n.substr(Un,5).toLowerCase()?(e=n.substr(Un,5),Un+=5):(e=null,0===Mn&&i('"video"')),null===e&&("application"===n.substr(Un,11).toLowerCase()?(e=n.substr(Un,11),Un+=11):(e=null,0===Mn&&i('"application"')),null===e&&(e=It()))))),e}function wt(){var e;return"message"===n.substr(Un,7).toLowerCase()?(e=n.substr(Un,7),Un+=7):(e=null,0===Mn&&i('"message"')),null===e&&("multipart"===n.substr(Un,9).toLowerCase()?(e=n.substr(Un,9),Un+=9):(e=null,0===Mn&&i('"multipart"')),null===e&&(e=It())),e}function It(){var e;return null===(e=A())&&(e=kt()),e}function kt(){var e,t,r;return r=Un,"x-"===n.substr(Un,2).toLowerCase()?(e=n.substr(Un,2),Un+=2):(e=null,0===Mn&&i('"x-"')),null!==e&&null!==(t=A())?e=[e,t]:(e=null,Un=r),e}function Ot(){var e;return null===(e=It())&&(e=A()),e}function Pt(){var e,t,n,r;return r=Un,null!==(e=A())&&null!==(t=P())&&null!==(n=xt())?e=[e,t,n]:(e=null,Un=r),e}function xt(){var e;return null===(e=A())&&(e=B()),e}function Nt(){var e,t,n;if(n=Un,null!==(t=a()))for(e=[];null!==t;)e.push(t),t=a();else e=null;return null!==e&&(e=function(e,t){jn.value=parseInt(t.join(""))}(0,e)),null===e&&(Un=n),e}function Dt(){var e,t,r,s,a,o;if(a=Un,null!==(e=w())){for(t=[],o=Un,46===n.charCodeAt(Un)?(r=".",Un++):(r=null,0===Mn&&i('"."')),null!==r&&null!==(s=w())?r=[r,s]:(r=null,Un=o);null!==r;)t.push(r),o=Un,46===n.charCodeAt(Un)?(r=".",Un++):(r=null,0===Mn&&i('"."')),null!==r&&null!==(s=w())?r=[r,s]:(r=null,Un=o);null!==t?e=[e,t]:(e=null,Un=a)}else e=null,Un=a;return e}function Ut(){var e;return null===(e=Mt())&&(e=yt()),e}function Mt(){var e,t,r,s,a;return s=Un,a=Un,"tag"===n.substr(Un,3).toLowerCase()?(e=n.substr(Un,3),Un+=3):(e=null,0===Mn&&i('"tag"')),null!==e&&null!==(t=P())&&null!==(r=A())?e=[e,t,r]:(e=null,Un=a),null!==e&&(e=function(e,t){jn.tag=t}(0,e[2])),null===e&&(Un=s),e}function Lt(){var e,t,r,s,a,o,l,u;if(l=Un,"digest"===n.substr(Un,6).toLowerCase()?(e=n.substr(Un,6),Un+=6):(e=null,0===Mn&&i('"Digest"')),null!==e)if(null!==(t=y()))if(null!==(r=Ft())){for(s=[],u=Un,null!==(a=M())&&null!==(o=Ft())?a=[a,o]:(a=null,Un=u);null!==a;)s.push(a),u=Un,null!==(a=M())&&null!==(o=Ft())?a=[a,o]:(a=null,Un=u);null!==s?e=[e,t,r,s]:(e=null,Un=l)}else e=null,Un=l;else e=null,Un=l;else e=null,Un=l;return null===e&&(e=qt()),e}function qt(){var e,t,n,r,i,s,a,o;if(a=Un,null!==(e=A()))if(null!==(t=y()))if(null!==(n=Ht())){for(r=[],o=Un,null!==(i=M())&&null!==(s=Ht())?i=[i,s]:(i=null,Un=o);null!==i;)r.push(i),o=Un,null!==(i=M())&&null!==(s=Ht())?i=[i,s]:(i=null,Un=o);null!==r?e=[e,t,n,r]:(e=null,Un=a)}else e=null,Un=a;else e=null,Un=a;else e=null,Un=a;return e}function Ht(){var e,t,n,r;return r=Un,null!==(e=A())&&null!==(t=P())?(null===(n=A())&&(n=B()),null!==n?e=[e,t,n]:(e=null,Un=r)):(e=null,Un=r),e}function Ft(){var e;return null===(e=jt())&&null===(e=Bt())&&null===(e=Vt())&&null===(e=Kt())&&null===(e=zt())&&null===(e=Yt())&&null===(e=$t())&&(e=Ht()),e}function jt(){var e,t,r,s;return s=Un,"realm"===n.substr(Un,5).toLowerCase()?(e=n.substr(Un,5),Un+=5):(e=null,0===Mn&&i('"realm"')),null!==e&&null!==(t=P())&&null!==(r=Gt())?e=[e,t,r]:(e=null,Un=s),e}function Gt(){var e,t;return t=Un,null!==(e=W())&&(e=function(e,t){jn.realm=t}(0,e)),null===e&&(Un=t),e}function Bt(){var e,t,r,s,a,o,l,u,c;if(u=Un,"domain"===n.substr(Un,6).toLowerCase()?(e=n.substr(Un,6),Un+=6):(e=null,0===Mn&&i('"domain"')),null!==e)if(null!==(t=P()))if(null!==(r=H()))if(null!==(s=Wt())){if(a=[],c=Un,null!==(l=h()))for(o=[];null!==l;)o.push(l),l=h();else o=null;for(null!==o&&null!==(l=Wt())?o=[o,l]:(o=null,Un=c);null!==o;){if(a.push(o),c=Un,null!==(l=h()))for(o=[];null!==l;)o.push(l),l=h();else o=null;null!==o&&null!==(l=Wt())?o=[o,l]:(o=null,Un=c)}null!==a&&null!==(o=F())?e=[e,t,r,s,a,o]:(e=null,Un=u)}else e=null,Un=u;else e=null,Un=u;else e=null,Un=u;else e=null,Un=u;return e}function Wt(){var e;return null===(e=De())&&(e=Le()),e}function Vt(){var e,t,r,s;return s=Un,"nonce"===n.substr(Un,5).toLowerCase()?(e=n.substr(Un,5),Un+=5):(e=null,0===Mn&&i('"nonce"')),null!==e&&null!==(t=P())&&null!==(r=Jt())?e=[e,t,r]:(e=null,Un=s),e}function Jt(){var e,t;return t=Un,null!==(e=W())&&(e=function(e,t){jn.nonce=t}(0,e)),null===e&&(Un=t),e}function Kt(){var e,t,r,s,a;return s=Un,a=Un,"opaque"===n.substr(Un,6).toLowerCase()?(e=n.substr(Un,6),Un+=6):(e=null,0===Mn&&i('"opaque"')),null!==e&&null!==(t=P())&&null!==(r=W())?e=[e,t,r]:(e=null,Un=a),null!==e&&(e=function(e,t){jn.opaque=t}(0,e[2])),null===e&&(Un=s),e}function zt(){var e,t,r,s,a;return s=Un,"stale"===n.substr(Un,5).toLowerCase()?(e=n.substr(Un,5),Un+=5):(e=null,0===Mn&&i('"stale"')),null!==e&&null!==(t=P())?(a=Un,"true"===n.substr(Un,4).toLowerCase()?(r=n.substr(Un,4),Un+=4):(r=null,0===Mn&&i('"true"')),null!==r&&(r=void(jn.stale=!0)),null===r&&(Un=a),null===r&&(a=Un,"false"===n.substr(Un,5).toLowerCase()?(r=n.substr(Un,5),Un+=5):(r=null,0===Mn&&i('"false"')),null!==r&&(r=void(jn.stale=!1)),null===r&&(Un=a)),null!==r?e=[e,t,r]:(e=null,Un=s)):(e=null,Un=s),e}function Yt(){var e,t,r,s,a;return s=Un,a=Un,"algorithm"===n.substr(Un,9).toLowerCase()?(e=n.substr(Un,9),Un+=9):(e=null,0===Mn&&i('"algorithm"')),null!==e&&null!==(t=P())?("md5"===n.substr(Un,3).toLowerCase()?(r=n.substr(Un,3),Un+=3):(r=null,0===Mn&&i('"MD5"')),null===r&&("md5-sess"===n.substr(Un,8).toLowerCase()?(r=n.substr(Un,8),Un+=8):(r=null,0===Mn&&i('"MD5-sess"')),null===r&&(r=A())),null!==r?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=function(e,t){jn.algorithm=t.toUpperCase()}(0,e[2])),null===e&&(Un=s),e}function $t(){var e,t,r,s,a,o,l,u,c,d;if(u=Un,"qop"===n.substr(Un,3).toLowerCase()?(e=n.substr(Un,3),Un+=3):(e=null,0===Mn&&i('"qop"')),null!==e)if(null!==(t=P()))if(null!==(r=H())){if(c=Un,null!==(s=Xt())){for(a=[],d=Un,44===n.charCodeAt(Un)?(o=",",Un++):(o=null,0===Mn&&i('","')),null!==o&&null!==(l=Xt())?o=[o,l]:(o=null,Un=d);null!==o;)a.push(o),d=Un,44===n.charCodeAt(Un)?(o=",",Un++):(o=null,0===Mn&&i('","')),null!==o&&null!==(l=Xt())?o=[o,l]:(o=null,Un=d);null!==a?s=[s,a]:(s=null,Un=c)}else s=null,Un=c;null!==s&&null!==(a=F())?e=[e,t,r,s,a]:(e=null,Un=u)}else e=null,Un=u;else e=null,Un=u;else e=null,Un=u;return e}function Xt(){var e,t;return t=Un,"auth-int"===n.substr(Un,8).toLowerCase()?(e=n.substr(Un,8),Un+=8):(e=null,0===Mn&&i('"auth-int"')),null===e&&("auth"===n.substr(Un,4).toLowerCase()?(e=n.substr(Un,4),Un+=4):(e=null,0===Mn&&i('"auth"')),null===e&&(e=A())),null!==e&&(e=function(e,t){jn.qop||(jn.qop=[]),jn.qop.push(t.toLowerCase())}(0,e)),null===e&&(Un=t),e}function Qt(){var e,t,n,r,i,s,a;if(i=Un,s=Un,null!==(e=ht())){for(t=[],a=Un,null!==(n=L())&&null!==(r=yt())?n=[n,r]:(n=null,Un=a);null!==n;)t.push(n),a=Un,null!==(n=L())&&null!==(r=yt())?n=[n,r]:(n=null,Un=a);null!==t?e=[e,t]:(e=null,Un=s)}else e=null,Un=s;return null!==e&&(e=function(e){var t;jn.multi_header||(jn.multi_header=[]);try{t=new Fn(jn.uri,jn.display_name,jn.params),delete jn.uri,delete jn.display_name,delete jn.params}catch(e){t=null}jn.multi_header.push({possition:Un,offset:e,parsed:t})}(i)),null===e&&(Un=i),e}function Zt(){var e;return null===(e=en())&&(e=yt()),e}function en(){var e,t,r,s,o,l;if(o=Un,l=Un,"cause"===n.substr(Un,5).toLowerCase()?(e=n.substr(Un,5),Un+=5):(e=null,0===Mn&&i('"cause"')),null!==e)if(null!==(t=P())){if(null!==(s=a()))for(r=[];null!==s;)r.push(s),s=a();else r=null;null!==r?e=[e,t,r]:(e=null,Un=l)}else e=null,Un=l;else e=null,Un=l;return null!==e&&(e=function(e,t){jn.cause=parseInt(t.join(""))}(0,e[2])),null===e&&(Un=o),e}function tn(){var e,t,n,r,i,s;if(i=Un,null!==(e=ht())){for(t=[],s=Un,null!==(n=L())&&null!==(r=yt())?n=[n,r]:(n=null,Un=s);null!==n;)t.push(n),s=Un,null!==(n=L())&&null!==(r=yt())?n=[n,r]:(n=null,Un=s);null!==t?e=[e,t]:(e=null,Un=i)}else e=null,Un=i;return e}function nn(){var e,t;return t=Un,"active"===n.substr(Un,6).toLowerCase()?(e=n.substr(Un,6),Un+=6):(e=null,0===Mn&&i('"active"')),null===e&&("pending"===n.substr(Un,7).toLowerCase()?(e=n.substr(Un,7),Un+=7):(e=null,0===Mn&&i('"pending"')),null===e&&("terminated"===n.substr(Un,10).toLowerCase()?(e=n.substr(Un,10),Un+=10):(e=null,0===Mn&&i('"terminated"')),null===e&&(e=A()))),null!==e&&(e=function(e){jn.state=n.substring(Un,e)}(t)),null===e&&(Un=t),e}function rn(){var e,t,r,s,a;return s=Un,a=Un,"reason"===n.substr(Un,6).toLowerCase()?(e=n.substr(Un,6),Un+=6):(e=null,0===Mn&&i('"reason"')),null!==e&&null!==(t=P())&&null!==(r=sn())?e=[e,t,r]:(e=null,Un=a),null!==e&&(e=function(e,t){void 0!==t&&(jn.reason=t)}(0,e[2])),null===e&&(Un=s),null===e&&(s=Un,a=Un,"expires"===n.substr(Un,7).toLowerCase()?(e=n.substr(Un,7),Un+=7):(e=null,0===Mn&&i('"expires"')),null!==e&&null!==(t=P())&&null!==(r=vt())?e=[e,t,r]:(e=null,Un=a),null!==e&&(e=function(e,t){void 0!==t&&(jn.expires=t)}(0,e[2])),null===e&&(Un=s),null===e&&(s=Un,a=Un,"retry_after"===n.substr(Un,11).toLowerCase()?(e=n.substr(Un,11),Un+=11):(e=null,0===Mn&&i('"retry_after"')),null!==e&&null!==(t=P())&&null!==(r=vt())?e=[e,t,r]:(e=null,Un=a),null!==e&&(e=function(e,t){void 0!==t&&(jn.retry_after=t)}(0,e[2])),null===e&&(Un=s),null===e&&(e=yt()))),e}function sn(){var e;return"deactivated"===n.substr(Un,11).toLowerCase()?(e=n.substr(Un,11),Un+=11):(e=null,0===Mn&&i('"deactivated"')),null===e&&("probation"===n.substr(Un,9).toLowerCase()?(e=n.substr(Un,9),Un+=9):(e=null,0===Mn&&i('"probation"')),null===e&&("rejected"===n.substr(Un,8).toLowerCase()?(e=n.substr(Un,8),Un+=8):(e=null,0===Mn&&i('"rejected"')),null===e&&("timeout"===n.substr(Un,7).toLowerCase()?(e=n.substr(Un,7),Un+=7):(e=null,0===Mn&&i('"timeout"')),null===e&&("giveup"===n.substr(Un,6).toLowerCase()?(e=n.substr(Un,6),Un+=6):(e=null,0===Mn&&i('"giveup"')),null===e&&("noresource"===n.substr(Un,10).toLowerCase()?(e=n.substr(Un,10),Un+=10):(e=null,0===Mn&&i('"noresource"')),null===e&&("invariant"===n.substr(Un,9).toLowerCase()?(e=n.substr(Un,9),Un+=9):(e=null,0===Mn&&i('"invariant"')),null===e&&(e=A()))))))),e}function an(){var e;return null===(e=Mt())&&(e=yt()),e}function on(){var e,t,n,r,i,s,a,o;if(a=Un,null!==(e=pn()))if(null!==(t=y()))if(null!==(n=vn())){for(r=[],o=Un,null!==(i=L())&&null!==(s=ln())?i=[i,s]:(i=null,Un=o);null!==i;)r.push(i),o=Un,null!==(i=L())&&null!==(s=ln())?i=[i,s]:(i=null,Un=o);null!==r?e=[e,t,n,r]:(e=null,Un=a)}else e=null,Un=a;else e=null,Un=a;else e=null,Un=a;return e}function ln(){var e;return null===(e=un())&&null===(e=cn())&&null===(e=dn())&&null===(e=hn())&&null===(e=fn())&&(e=yt()),e}function un(){var e,t,r,s,a;return s=Un,a=Un,"ttl"===n.substr(Un,3).toLowerCase()?(e=n.substr(Un,3),Un+=3):(e=null,0===Mn&&i('"ttl"')),null!==e&&null!==(t=P())&&null!==(r=Tn())?e=[e,t,r]:(e=null,Un=a),null!==e&&(e=function(e,t){jn.ttl=t}(0,e[2])),null===e&&(Un=s),e}function cn(){var e,t,r,s,a;return s=Un,a=Un,"maddr"===n.substr(Un,5).toLowerCase()?(e=n.substr(Un,5),Un+=5):(e=null,0===Mn&&i('"maddr"')),null!==e&&null!==(t=P())&&null!==(r=re())?e=[e,t,r]:(e=null,Un=a),null!==e&&(e=function(e,t){jn.maddr=t}(0,e[2])),null===e&&(Un=s),e}function dn(){var e,t,r,s,a;return s=Un,a=Un,"received"===n.substr(Un,8).toLowerCase()?(e=n.substr(Un,8),Un+=8):(e=null,0===Mn&&i('"received"')),null!==e&&null!==(t=P())?(null===(r=de())&&(r=le()),null!==r?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=function(e,t){jn.received=t}(0,e[2])),null===e&&(Un=s),e}function hn(){var e,t,r,s,a;return s=Un,a=Un,"branch"===n.substr(Un,6).toLowerCase()?(e=n.substr(Un,6),Un+=6):(e=null,0===Mn&&i('"branch"')),null!==e&&null!==(t=P())&&null!==(r=A())?e=[e,t,r]:(e=null,Un=a),null!==e&&(e=function(e,t){jn.branch=t}(0,e[2])),null===e&&(Un=s),e}function fn(){var e,t,r,s,o,l,u;if(o=Un,l=Un,"rport"===n.substr(Un,5).toLowerCase()?(e=n.substr(Un,5),Un+=5):(e=null,0===Mn&&i('"rport"')),null!==e){if(u=Un,null!==(t=P())){for(r=[],s=a();null!==s;)r.push(s),s=a();null!==r?t=[t,r]:(t=null,Un=u)}else t=null,Un=u;null!==(t=null!==t?t:"")?e=[e,t]:(e=null,Un=l)}else e=null,Un=l;return null!==e&&(e=void("undefined"!=typeof response_port&&(jn.rport=response_port.join("")))),null===e&&(Un=o),e}function pn(){var e,t,n,r,i,s;return s=Un,null!==(e=_n())&&null!==(t=O())&&null!==(n=A())&&null!==(r=O())&&null!==(i=mn())?e=[e,t,n,r,i]:(e=null,Un=s),e}function _n(){var e,t;return t=Un,"sip"===n.substr(Un,3).toLowerCase()?(e=n.substr(Un,3),Un+=3):(e=null,0===Mn&&i('"SIP"')),null===e&&(e=A()),null!==e&&(e=function(e,t){jn.protocol=t}(0,e)),null===e&&(Un=t),e}function mn(){var e,t;return t=Un,"udp"===n.substr(Un,3).toLowerCase()?(e=n.substr(Un,3),Un+=3):(e=null,0===Mn&&i('"UDP"')),null===e&&("tcp"===n.substr(Un,3).toLowerCase()?(e=n.substr(Un,3),Un+=3):(e=null,0===Mn&&i('"TCP"')),null===e&&("tls"===n.substr(Un,3).toLowerCase()?(e=n.substr(Un,3),Un+=3):(e=null,0===Mn&&i('"TLS"')),null===e&&("sctp"===n.substr(Un,4).toLowerCase()?(e=n.substr(Un,4),Un+=4):(e=null,0===Mn&&i('"SCTP"')),null===e&&(e=A())))),null!==e&&(e=function(e,t){jn.transport=t}(0,e)),null===e&&(Un=t),e}function vn(){var e,t,n,r,i;return r=Un,null!==(e=gn())?(i=Un,null!==(t=q())&&null!==(n=yn())?t=[t,n]:(t=null,Un=i),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,Un=r)):(e=null,Un=r),e}function gn(){var e,t;return t=Un,null===(e=de())&&null===(e=oe())&&(e=ie()),null!==e&&(e=function(e){jn.host=n.substring(Un,e)}(t)),null===e&&(Un=t),e}function yn(){var e,t,n,r,i,s,o;return s=Un,o=Un,e=a(),null!==(e=null!==e?e:"")&&null!==(t=null!==(t=a())?t:"")&&null!==(n=null!==(n=a())?n:"")&&null!==(r=null!==(r=a())?r:"")&&null!==(i=null!==(i=a())?i:"")?e=[e,t,n,r,i]:(e=null,Un=o),null!==e&&(e=function(e,t){jn.port=parseInt(t.join(""))}(0,e)),null===e&&(Un=s),e}function Tn(){var e,t,n,r,i;return r=Un,i=Un,null!==(e=a())&&null!==(t=null!==(t=a())?t:"")&&null!==(n=null!==(n=a())?n:"")?e=[e,t,n]:(e=null,Un=i),null!==e&&(e=function(e,t){return parseInt(t.join(""))}(0,e)),null===e&&(Un=r),e}function Cn(){var e,t;return t=Un,null!==(e=vt())&&(e=function(e,t){jn.expires=t}(0,e)),null===e&&(Un=t),e}function Sn(){var e;return null===(e=En())&&(e=yt()),e}function En(){var e,t,r,s,a;return s=Un,a=Un,"refresher"===n.substr(Un,9).toLowerCase()?(e=n.substr(Un,9),Un+=9):(e=null,0===Mn&&i('"refresher"')),null!==e&&null!==(t=P())?("uac"===n.substr(Un,3).toLowerCase()?(r=n.substr(Un,3),Un+=3):(r=null,0===Mn&&i('"uac"')),null===r&&("uas"===n.substr(Un,3).toLowerCase()?(r=n.substr(Un,3),Un+=3):(r=null,0===Mn&&i('"uas"'))),null!==r?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=function(e,t){jn.refresher=t.toLowerCase()}(0,e[2])),null===e&&(Un=s),e}function bn(){var e,t;for(e=[],null===(t=E())&&null===(t=R())&&(t=y());null!==t;)e.push(t),null===(t=E())&&null===(t=R())&&(t=y());return e}function Rn(){var e,t,r,s,a,o,l,u,c,d,h;return d=Un,h=Un,null!==(e=wn())?(45===n.charCodeAt(Un)?(t="-",Un++):(t=null,0===Mn&&i('"-"')),null!==t&&null!==(r=An())?(45===n.charCodeAt(Un)?(s="-",Un++):(s=null,0===Mn&&i('"-"')),null!==s&&null!==(a=An())?(45===n.charCodeAt(Un)?(o="-",Un++):(o=null,0===Mn&&i('"-"')),null!==o&&null!==(l=An())?(45===n.charCodeAt(Un)?(u="-",Un++):(u=null,0===Mn&&i('"-"')),null!==u&&null!==(c=In())?e=[e,t,r,s,a,o,l,u,c]:(e=null,Un=h)):(e=null,Un=h)):(e=null,Un=h)):(e=null,Un=h)):(e=null,Un=h),null!==e&&(e=function(e,t){jn=n.substring(Un+5,e)}(d,e[0])),null===e&&(Un=d),e}function An(){var e,t,n,r,i;return i=Un,null!==(e=l())&&null!==(t=l())&&null!==(n=l())&&null!==(r=l())?e=[e,t,n,r]:(e=null,Un=i),e}function wn(){var e,t,n;return n=Un,null!==(e=An())&&null!==(t=An())?e=[e,t]:(e=null,Un=n),e}function In(){var e,t,n,r;return r=Un,null!==(e=An())&&null!==(t=An())&&null!==(n=An())?e=[e,t,n]:(e=null,Un=r),e}function kn(){var e,t,r,s,a,o;return s=Un,a=Un,null!==(e=I())?(o=Un,64===n.charCodeAt(Un)?(t="@",Un++):(t=null,0===Mn&&i('"@"')),null!==t&&null!==(r=I())?t=[t,r]:(t=null,Un=o),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=function(e){jn.call_id=n.substring(Un,e)}(s)),null===e&&(Un=s),e}function On(){var e;return null===(e=Pn())&&null===(e=xn())&&null===(e=Nn())&&(e=yt()),e}function Pn(){var e,t,r,s,a;return s=Un,a=Un,"to-tag"===n.substr(Un,6)?(e="to-tag",Un+=6):(e=null,0===Mn&&i('"to-tag"')),null!==e&&null!==(t=P())&&null!==(r=A())?e=[e,t,r]:(e=null,Un=a),null!==e&&(e=function(e,t){jn.to_tag=t}(0,e[2])),null===e&&(Un=s),e}function xn(){var e,t,r,s,a;return s=Un,a=Un,"from-tag"===n.substr(Un,8)?(e="from-tag",Un+=8):(e=null,0===Mn&&i('"from-tag"')),null!==e&&null!==(t=P())&&null!==(r=A())?e=[e,t,r]:(e=null,Un=a),null!==e&&(e=function(e,t){jn.from_tag=t}(0,e[2])),null===e&&(Un=s),e}function Nn(){var e,t;return t=Un,"early-only"===n.substr(Un,10)?(e="early-only",Un+=10):(e=null,0===Mn&&i('"early-only"')),null!==e&&(e=void(jn.early_only=!0)),null===e&&(Un=t),e}var Dn={CRLF:s,DIGIT:a,ALPHA:o,HEXDIG:l,WSP:u,OCTET:c,DQUOTE:d,SP:h,HTAB:f,alphanum:p,reserved:_,unreserved:m,mark:v,escaped:g,LWS:y,SWS:T,HCOLON:C,TEXT_UTF8_TRIM:S,TEXT_UTF8char:E,UTF8_NONASCII:b,UTF8_CONT:R,LHEX:function(){var e;return null===(e=a())&&(/^[a-f]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[a-f]"))),e},token:A,token_nodot:w,separators:function(){var e;return 40===n.charCodeAt(Un)?(e="(",Un++):(e=null,0===Mn&&i('"("')),null===e&&(41===n.charCodeAt(Un)?(e=")",Un++):(e=null,0===Mn&&i('")"')),null===e&&(60===n.charCodeAt(Un)?(e="<",Un++):(e=null,0===Mn&&i('"<"')),null===e&&(62===n.charCodeAt(Un)?(e=">",Un++):(e=null,0===Mn&&i('">"')),null===e&&(64===n.charCodeAt(Un)?(e="@",Un++):(e=null,0===Mn&&i('"@"')),null===e&&(44===n.charCodeAt(Un)?(e=",",Un++):(e=null,0===Mn&&i('","')),null===e&&(59===n.charCodeAt(Un)?(e=";",Un++):(e=null,0===Mn&&i('";"')),null===e&&(58===n.charCodeAt(Un)?(e=":",Un++):(e=null,0===Mn&&i('":"')),null===e&&(92===n.charCodeAt(Un)?(e="\\",Un++):(e=null,0===Mn&&i('"\\\\"')),null===e&&null===(e=d())&&(47===n.charCodeAt(Un)?(e="/",Un++):(e=null,0===Mn&&i('"/"')),null===e&&(91===n.charCodeAt(Un)?(e="[",Un++):(e=null,0===Mn&&i('"["')),null===e&&(93===n.charCodeAt(Un)?(e="]",Un++):(e=null,0===Mn&&i('"]"')),null===e&&(63===n.charCodeAt(Un)?(e="?",Un++):(e=null,0===Mn&&i('"?"')),null===e&&(61===n.charCodeAt(Un)?(e="=",Un++):(e=null,0===Mn&&i('"="')),null===e&&(123===n.charCodeAt(Un)?(e="{",Un++):(e=null,0===Mn&&i('"{"')),null===e&&(125===n.charCodeAt(Un)?(e="}",Un++):(e=null,0===Mn&&i('"}"')),null===e&&null===(e=h())&&(e=f())))))))))))))))),e},word:I,STAR:k,SLASH:O,EQUAL:P,LPAREN:x,RPAREN:N,RAQUOT:D,LAQUOT:U,COMMA:M,SEMI:L,COLON:q,LDQUOT:H,RDQUOT:F,comment:j,ctext:G,quoted_string:B,quoted_string_clean:W,qdtext:V,quoted_pair:J,SIP_URI_noparams:K,SIP_URI:z,uri_scheme:Y,uri_scheme_sips:$,uri_scheme_sip:X,userinfo:Q,user:Z,user_unreserved:ee,password:te,hostport:ne,host:re,hostname:ie,domainlabel:se,toplabel:ae,IPv6reference:oe,IPv6address:le,h16:ue,ls32:ce,IPv4address:de,dec_octet:he,port:fe,uri_parameters:pe,uri_parameter:_e,transport_param:me,user_param:ve,method_param:ge,ttl_param:ye,maddr_param:Te,lr_param:Ce,other_param:Se,pname:Ee,pvalue:be,paramchar:Re,param_unreserved:Ae,headers:we,header:Ie,hname:ke,hvalue:Oe,hnv_unreserved:Pe,Request_Response:function(){var e;return null===(e=ot())&&(e=xe()),e},Request_Line:xe,Request_URI:Ne,absoluteURI:De,hier_part:Ue,net_path:Me,abs_path:Le,opaque_part:qe,uric:He,uric_no_slash:Fe,path_segments:je,segment:Ge,param:Be,pchar:We,scheme:Ve,authority:Je,srvr:Ke,reg_name:ze,query:Ye,SIP_Version:$e,INVITEm:Xe,ACKm:Qe,OPTIONSm:Ze,BYEm:et,CANCELm:tt,REGISTERm:nt,SUBSCRIBEm:rt,NOTIFYm:it,REFERm:st,Method:at,Status_Line:ot,Status_Code:lt,extension_code:ut,Reason_Phrase:ct,Allow_Events:function(){var e,t,n,r,i,s;if(i=Un,null!==(e=Dt())){for(t=[],s=Un,null!==(n=M())&&null!==(r=Dt())?n=[n,r]:(n=null,Un=s);null!==n;)t.push(n),s=Un,null!==(n=M())&&null!==(r=Dt())?n=[n,r]:(n=null,Un=s);null!==t?e=[e,t]:(e=null,Un=i)}else e=null,Un=i;return e},Call_ID:function(){var e,t,r,s,a,o;return s=Un,a=Un,null!==(e=I())?(o=Un,64===n.charCodeAt(Un)?(t="@",Un++):(t=null,0===Mn&&i('"@"')),null!==t&&null!==(r=I())?t=[t,r]:(t=null,Un=o),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=function(e){jn=n.substring(Un,e)}(s)),null===e&&(Un=s),e},Contact:function(){var e,t,n,r,i,s,a;if(i=Un,null===(e=k()))if(s=Un,null!==(e=dt())){for(t=[],a=Un,null!==(n=M())&&null!==(r=dt())?n=[n,r]:(n=null,Un=a);null!==n;)t.push(n),a=Un,null!==(n=M())&&null!==(r=dt())?n=[n,r]:(n=null,Un=a);null!==t?e=[e,t]:(e=null,Un=s)}else e=null,Un=s;return null!==e&&(e=function(e){var t,n;for(n=jn.multi_header.length,t=0;t2&&void 0!==arguments[2]?arguments[2]:{},i=e;if(void 0===e||void 0===t)throw new TypeError("Not enough arguments");if(!(e=this._ua.normalizeTarget(e)))throw new TypeError("Invalid target: "+i);var s=c.cloneArray(r.extraHeaders),a=r.eventHandlers||{},o=r.contentType||"text/plain";for(var h in a)Object.prototype.hasOwnProperty.call(a,h)&&this.on(h,a[h]);s.push("Content-Type: "+o),this._request=new u.OutgoingRequest(l.MESSAGE,e,this._ua,null,s),t&&(this._request.body=t);var f=new d(this._ua,this._request,{onRequestTimeout:function(){n._onRequestTimeout()},onTransportError:function(){n._onTransportError()},onReceiveResponse:function(e){n._receiveResponse(e)}});this._newMessage("local",this._request),f.send()}},{key:"init_incoming",value:function(e){this._request=e,this._newMessage("remote",e),this._is_replied||(this._is_replied=!0,e.reply(200)),this._close()}},{key:"accept",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=c.cloneArray(e.extraHeaders),n=e.body;if("incoming"!==this._direction)throw new h.NotSupportedError('"accept" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");this._is_replied=!0,this._request.reply(200,null,t,n)}},{key:"reject",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.status_code||480,n=e.reason_phrase,r=c.cloneArray(e.extraHeaders),i=e.body;if("incoming"!==this._direction)throw new h.NotSupportedError('"reject" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");if(t<300||t>=700)throw new TypeError("Invalid status_code: "+t);this._is_replied=!0,this._request.reply(t,n,r,i)}},{key:"_receiveResponse",value:function(e){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(e.status_code):break;case/^2[0-9]{2}$/.test(e.status_code):this._succeeded("remote",e);break;default:var t=c.sipErrorCause(e.status_code);this._failed("remote",e,t)}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,l.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,l.causes.CONNECTION_ERROR)}},{key:"_close",value:function(){this._closed=!0,this._ua.destroyMessage(this)}},{key:"_newMessage",value:function(e,t){"remote"===e?(this._direction="incoming",this._local_identity=t.to,this._remote_identity=t.from):"local"===e&&(this._direction="outgoing",this._local_identity=t.from,this._remote_identity=t.to),this._ua.newMessage(this,{originator:e,message:this,request:t})}},{key:"_failed",value:function(e,t,n){f("MESSAGE failed"),this._close(),f('emit "failed"'),this.emit("failed",{originator:e,response:t||null,cause:n})}},{key:"_succeeded",value:function(e,t){f("MESSAGE succeeded"),this._close(),f('emit "succeeded"'),this.emit("succeeded",{originator:e,response:t})}},{key:"direction",get:function(){return this._direction}},{key:"local_identity",get:function(){return this._local_identity}},{key:"remote_identity",get:function(){return this._remote_identity}}]),t}()},{"./Constants":2,"./Exceptions":6,"./RequestSender":18,"./SIPMessage":19,"./Utils":26,debug:29,events:31}],10:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n";for(var t in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,t)&&(e+=";"+t,null!==this._parameters[t]&&(e+="="+this._parameters[t]));return e}},{key:"uri",get:function(){return this._uri}},{key:"display_name",get:function(){return this._display_name},set:function(e){this._display_name=0===e?"0":e}}]),e}()},{"./Grammar":7,"./URI":25}],11:[function(e,t,n){"use strict";function r(e,t){var n=t,r=0,i=0;if(e.substring(n,n+2).match(/(^\r\n)/))return-2;for(;0===r;){if(-1===(i=e.indexOf("\r\n",n)))return i;!e.substring(i+2,i+4).match(/(^\r\n)/)&&e.charAt(i+2).match(/(^\s+)/)?n=i+2:r=i}return r}function i(e,t,n,r){var i=void 0,o=t.indexOf(":",n),l=t.substring(n,o).trim(),u=t.substring(o+1,r).trim();switch(l.toLowerCase()){case"via":case"v":e.addHeader("via",u),1===e.getHeaders("via").length?(i=e.parseHeader("Via"))&&(e.via=i,e.via_branch=i.branch):i=0;break;case"from":case"f":e.setHeader("from",u),(i=e.parseHeader("from"))&&(e.from=i,e.from_tag=i.getParam("tag"));break;case"to":case"t":e.setHeader("to",u),(i=e.parseHeader("to"))&&(e.to=i,e.to_tag=i.getParam("tag"));break;case"record-route":if(-1===(i=s.parse(u,"Record_Route")))i=void 0;else{var c=!0,d=!1,h=void 0;try{for(var f,p=i[Symbol.iterator]();!(c=(f=p.next()).done);c=!0){var _=f.value;e.addHeader("record-route",u.substring(_.possition,_.offset)),e.headers["Record-Route"][e.getHeaders("record-route").length-1].parsed=_.parsed}}catch(e){d=!0,h=e}finally{try{!c&&p.return&&p.return()}finally{if(d)throw h}}}break;case"call-id":case"i":e.setHeader("call-id",u),(i=e.parseHeader("call-id"))&&(e.call_id=u);break;case"contact":case"m":if(-1===(i=s.parse(u,"Contact")))i=void 0;else{var m=!0,v=!1,g=void 0;try{for(var y,T=i[Symbol.iterator]();!(m=(y=T.next()).done);m=!0){var C=y.value;e.addHeader("contact",u.substring(C.possition,C.offset)),e.headers.Contact[e.getHeaders("contact").length-1].parsed=C.parsed}}catch(e){v=!0,g=e}finally{try{!m&&T.return&&T.return()}finally{if(v)throw g}}}break;case"content-length":case"l":e.setHeader("content-length",u),i=e.parseHeader("content-length");break;case"content-type":case"c":e.setHeader("content-type",u),i=e.parseHeader("content-type");break;case"cseq":e.setHeader("cseq",u),(i=e.parseHeader("cseq"))&&(e.cseq=i.value),e instanceof a.IncomingResponse&&(e.method=i.method);break;case"max-forwards":e.setHeader("max-forwards",u),i=e.parseHeader("max-forwards");break;case"www-authenticate":e.setHeader("www-authenticate",u),i=e.parseHeader("www-authenticate");break;case"proxy-authenticate":e.setHeader("proxy-authenticate",u),i=e.parseHeader("proxy-authenticate");break;case"session-expires":case"x":e.setHeader("session-expires",u),(i=e.parseHeader("session-expires"))&&(e.session_expires=i.expires,e.session_expires_refresher=i.refresher);break;case"refer-to":case"r":e.setHeader("refer-to",u),(i=e.parseHeader("refer-to"))&&(e.refer_to=i);break;case"replaces":e.setHeader("replaces",u),(i=e.parseHeader("replaces"))&&(e.replaces=i);break;case"event":case"o":e.setHeader("event",u),(i=e.parseHeader("event"))&&(e.event=i);break;default:e.setHeader(l,u),i=0}return void 0!==i||{error:'error parsing header "'+l+'"'}}var s=e("./Grammar"),a=e("./SIPMessage"),o=e("debug")("JsSIP:ERROR:Parser");o.log=console.warn.bind(console),n.parseMessage=function(e,t){var n=void 0,l=void 0,u=e.indexOf("\r\n");if(-1!==u){var c=e.substring(0,u),d=s.parse(c,"Request_Response");if(-1!==d){d.status_code?((n=new a.IncomingResponse).status_code=d.status_code,n.reason_phrase=d.reason_phrase):((n=new a.IncomingRequest(t)).method=d.method,n.ruri=d.uri),n.data=e;for(var h=u+2;;){if(-2===(u=r(e,h))){l=h+2;break}if(-1===u)return void o("parseMessage() | malformed message");if(!0!==(d=i(n,e,h,u)))return void o("parseMessage() |",d.error);h=u+2}if(n.hasHeader("content-length")){var f=n.getHeader("content-length");n.body=e.substr(l,f)}else n.body=e.substring(l);return n}o('parseMessage() | error parsing first line of SIP message: "'+c+'"')}else o("parseMessage() | no CRLF found, not a SIP message")}},{"./Grammar":7,"./SIPMessage":19,debug:29}],12:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a="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},o=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{},n=arguments[2];S("connect()");var r=e,i=t.eventHandlers||{},s=f.cloneArray(t.extraHeaders),a=t.mediaConstraints||{audio:!0,video:!0},o=t.mediaStream||null,l=t.pcConfig||{iceServers:[]},u=t.rtcConstraints||null,h=t.rtcOfferConstraints||null;if(this._rtcOfferConstraints=h,this._rtcAnswerConstraints=t.rtcAnswerConstraints||null,this._data=t.data||this._data,void 0===e)throw new TypeError("Not enough arguments");if(this._status!==b.STATUS_NULL)throw new d.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new d.NotSupportedError("WebRTC not supported");if(!(e=this._ua.normalizeTarget(e)))throw new TypeError("Invalid target: "+r);this._sessionTimers.enabled&&f.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=c.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=c.SESSION_EXPIRES);for(var p in i)Object.prototype.hasOwnProperty.call(i,p)&&this.on(p,i[p]);this._from_tag=f.newTag();var m=t.anonymous||!1,v={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:m,outbound:!0}),m&&(v.from_display_name="Anonymous",v.from_uri="sip:anonymous@anonymous.invalid",s.push("P-Preferred-Identity: "+this._ua.configuration.uri.toString()),s.push("Privacy: id")),s.push("Contact: "+this._contact),s.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&s.push("Session-Expires: "+this._sessionTimers.defaultExpires),this._request=new _.InitialOutgoingInviteRequest(e,this._ua,v,s),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(l,u),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,n&&n(this),this._newRTCSession("local",this._request),this._sendInitialRequest(a,h,o)}},{key:"init_incoming",value:function(e,t){var n=this;S("init_incoming()");var r=void 0,i=e.getHeader("Content-Type");e.body&&"application/sdp"!==i?e.reply(415):(this._status=b.STATUS_INVITE_RECEIVED,this._from_tag=e.from_tag,this._id=e.call_id+this._from_tag,this._request=e,this._contact=this._ua.contact.toString(),e.hasHeader("expires")&&(r=1e3*e.getHeader("expires")),e.to_tag=f.newTag(),this._createDialog(e,"UAS",!0)?(e.body?this._late_sdp=!1:this._late_sdp=!0,this._status=b.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(function(){e.reply(408),n._failed("local",null,c.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),r&&(this._timers.expiresTimer=setTimeout(function(){n._status===b.STATUS_WAITING_FOR_ANSWER&&(e.reply(487),n._failed("system",null,c.causes.EXPIRES))},r)),this._direction="incoming",this._local_identity=e.to,this._remote_identity=e.from,t&&t(this),this._newRTCSession("remote",e),this._status!==b.STATUS_TERMINATED&&(e.reply(180,null,["Contact: "+this._contact]),this._progress("local",null))):e.reply(500,"Missing Contact header field"))}},{key:"answer",value:function(){function e(e){var t=this;if(this._status!==b.STATUS_TERMINATED)if(this._localMediaStream=e,e&&this._connection.addStream(e),S('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection}),this._late_sdp)n.call(this);else{var r={originator:"remote",type:"offer",sdp:o.body};S('emit "sdp"'),this.emit("sdp",r);var i=new RTCSessionDescription({type:"offer",sdp:r.sdp});this._connection.setRemoteDescription(i).then(n.bind(this)).catch(function(e){o.reply(488),t._failed("system",null,c.causes.WEBRTC_ERROR),E('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)})}}function t(){this._status!==b.STATUS_TERMINATED&&(o.reply(480),this._failed("local",null,c.causes.USER_DENIED_MEDIA_ACCESS))}function n(){this._connecting(o),this._late_sdp?this._createLocalDescription("offer",r.bind(this),i.bind(this),this._rtcOfferConstraints):this._createLocalDescription("answer",r.bind(this),i.bind(this),m)}function r(e){this._status!==b.STATUS_TERMINATED&&(this._handleSessionTimersInIncomingRequest(o,l),o.reply(200,null,l,e,function(){this._status=b.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(o,e),this._setACKTimer(),this._accepted("local")}.bind(this),function(){this._failed("system",null,c.causes.CONNECTION_ERROR)}.bind(this)))}function i(){this._status!==b.STATUS_TERMINATED&&(o.reply(500),this._failed("system",null,c.causes.WEBRTC_ERROR))}var s=this,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};S("answer()");var o=this._request,l=f.cloneArray(a.extraHeaders),u=a.mediaConstraints||{},h=a.mediaStream||null,p=a.pcConfig||{iceServers:[]},_=a.rtcConstraints||null,m=a.rtcAnswerConstraints||null,v=void 0,g=!1,y=!1,T=!1,C=!1;if(this._rtcAnswerConstraints=m,this._rtcOfferConstraints=a.rtcOfferConstraints||null,this._data=a.data||this._data,"incoming"!==this._direction)throw new d.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==b.STATUS_WAITING_FOR_ANSWER)throw new d.InvalidStateError(this._status);if(this._sessionTimers.enabled&&f.isDecimal(a.sessionTimersExpires)&&(a.sessionTimersExpires>=c.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=a.sessionTimersExpires:this._sessionTimers.defaultExpires=c.SESSION_EXPIRES),this._status=b.STATUS_ANSWERED,this._createDialog(o,"UAS")){clearTimeout(this._timers.userNoAnswerTimer),l.unshift("Contact: "+this._contact);var R=o.parseSDP();Array.isArray(R.media)||(R.media=[R.media]);var A=!0,w=!1,I=void 0;try{for(var k,O=R.media[Symbol.iterator]();!(A=(k=O.next()).done);A=!0){var P=k.value;"audio"===P.type&&(g=!0,P.direction&&"sendrecv"!==P.direction||(T=!0)),"video"===P.type&&(y=!0,P.direction&&"sendrecv"!==P.direction||(C=!0))}}catch(e){w=!0,I=e}finally{try{!A&&O.return&&O.return()}finally{if(w)throw I}}if(h&&!1===u.audio){v=h.getAudioTracks();var x=!0,N=!1,D=void 0;try{for(var U,M=v[Symbol.iterator]();!(x=(U=M.next()).done);x=!0){var L=U.value;h.removeTrack(L)}}catch(e){N=!0,D=e}finally{try{!x&&M.return&&M.return()}finally{if(N)throw D}}}if(h&&!1===u.video){v=h.getVideoTracks();var q=!0,H=!1,F=void 0;try{for(var j,G=v[Symbol.iterator]();!(q=(j=G.next()).done);q=!0){var B=j.value;h.removeTrack(B)}}catch(e){H=!0,F=e}finally{try{!q&&G.return&&G.return()}finally{if(H)throw F}}}h||void 0!==u.audio||(u.audio=T),h||void 0!==u.video||(u.video=C),h||g||(u.audio=!1),h||y||(u.video=!1),this._createRTCConnection(p,_),h?e(h):u.audio||u.video?(this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(u).then(e.bind(this)).catch(function(e){t.call(s,e),E('emit "getusermediafailed" [error:%o]',e),s.emit("getusermediafailed",e)})):e.call(this,null)}else o.reply(500,"Error creating dialog")}},{key:"terminate",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};S("terminate()");var n=t.cause||c.causes.BYE,r=f.cloneArray(t.extraHeaders),i=t.body,s=void 0,a=t.status_code,o=t.reason_phrase;if(this._status===b.STATUS_TERMINATED)throw new d.InvalidStateError(this._status);switch(this._status){case b.STATUS_NULL:case b.STATUS_INVITE_SENT:case b.STATUS_1XX_RECEIVED:if(S("canceling session"),a&&(a<200||a>=700))throw new TypeError("Invalid status_code: "+a);a&&(s="SIP ;cause="+a+' ;text="'+(o=o||c.REASON_PHRASE[a]||"")+'"'),this._status===b.STATUS_NULL||this._status===b.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=s):this._status===b.STATUS_1XX_RECEIVED&&this._request.cancel(s),this._status=b.STATUS_CANCELED,this._failed("local",null,c.causes.CANCELED);break;case b.STATUS_WAITING_FOR_ANSWER:case b.STATUS_ANSWERED:if(S("rejecting session"),(a=a||480)<300||a>=700)throw new TypeError("Invalid status_code: "+a);this._request.reply(a,o,r,i),this._failed("local",null,c.causes.REJECTED);break;case b.STATUS_WAITING_FOR_ACK:case b.STATUS_CONFIRMED:if(S("terminating session"),o=t.reason_phrase||c.REASON_PHRASE[a]||"",a&&(a<200||a>=700))throw new TypeError("Invalid status_code: "+a);if(a&&r.push("Reason: SIP ;cause="+a+'; text="'+o+'"'),this._status===b.STATUS_WAITING_FOR_ACK&&"incoming"===this._direction&&this._request.server_transaction.state!==h.C.STATUS_TERMINATED){var l=this._dialog;this.receiveRequest=function(t){t.method===c.ACK&&(e.sendRequest(c.BYE,{extraHeaders:r,body:i}),l.terminate())},this._request.server_transaction.on("stateChanged",function(){e._request.server_transaction.state===h.C.STATUS_TERMINATED&&(e.sendRequest(c.BYE,{extraHeaders:r,body:i}),l.terminate())}),this._ended("local",null,n),this._dialog=l,this._ua.newDialog(l)}else this.sendRequest(c.BYE,{extraHeaders:r,body:i}),this._ended("local",null,n)}}},{key:"sendDTMF",value:function(e){function t(){var e=this,a=void 0;if(this._status===b.STATUS_TERMINATED||!this._tones||r>=this._tones.length)this._tones=null;else{var o=this._tones[r];if(r+=1,","===o)a=2e3;else{var l=new g(this);n.eventHandlers={onFailed:function(){e._tones=null}},l.send(o,n),a=i+s}setTimeout(t.bind(this),a)}}var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};S("sendDTMF() | tones: %s",e);var r=0,i=n.duration||null,s=n.interToneGap||null;if(void 0===e)throw new TypeError("Not enough arguments");if(this._status!==b.STATUS_CONFIRMED&&this._status!==b.STATUS_WAITING_FOR_ACK)throw new d.InvalidStateError(this._status);if("number"==typeof e&&(e=e.toString()),!e||"string"!=typeof e||!e.match(/^[0-9A-DR#*,]+$/i))throw new TypeError("Invalid tones: "+e);if(i&&!f.isDecimal(i))throw new TypeError("Invalid tone duration: "+i);if(i?ig.C.MAX_DURATION?(S('"duration" value is greater than the maximum allowed, setting it to '+g.C.MAX_DURATION+" milliseconds"),i=g.C.MAX_DURATION):i=Math.abs(i):i=g.C.DEFAULT_DURATION,n.duration=i,s&&!f.isDecimal(s))throw new TypeError("Invalid interToneGap: "+s);s?s2&&void 0!==arguments[2]?arguments[2]:{};if(S("sendInfo()"),this._status!==b.STATUS_CONFIRMED&&this._status!==b.STATUS_WAITING_FOR_ACK)throw new d.InvalidStateError(this._status);new y(this).send(e,t,n)}},{key:"mute",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{audio:!0,video:!1};S("mute()");var t=!1,n=!1;!1===this._audioMuted&&e.audio&&(t=!0,this._audioMuted=!0,this._toogleMuteAudio(!0)),!1===this._videoMuted&&e.video&&(n=!0,this._videoMuted=!0,this._toogleMuteVideo(!0)),!0!==t&&!0!==n||this._onmute({audio:t,video:n})}},{key:"unmute",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{audio:!0,video:!0};S("unmute()");var t=!1,n=!1;!0===this._audioMuted&&e.audio&&(t=!0,this._audioMuted=!1,!1===this._localHold&&this._toogleMuteAudio(!1)),!0===this._videoMuted&&e.video&&(n=!0,this._videoMuted=!1,!1===this._localHold&&this._toogleMuteVideo(!1)),!0!==t&&!0!==n||this._onunmute({audio:t,video:n})}},{key:"hold",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];if(S("hold()"),this._status!==b.STATUS_WAITING_FOR_ACK&&this._status!==b.STATUS_CONFIRMED)return!1;if(!0===this._localHold)return!1;if(!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");var r={succeeded:function(){n&&n()},failed:function(){e.terminate({cause:c.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:r,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:r,extraHeaders:t.extraHeaders}),!0}},{key:"unhold",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];if(S("unhold()"),this._status!==b.STATUS_WAITING_FOR_ACK&&this._status!==b.STATUS_CONFIRMED)return!1;if(!1===this._localHold)return!1;if(!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");var r={succeeded:function(){n&&n()},failed:function(){e.terminate({cause:c.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:r,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:r,extraHeaders:t.extraHeaders}),!0}},{key:"renegotiate",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];S("renegotiate()");var r=t.rtcOfferConstraints||null;if(this._status!==b.STATUS_WAITING_FOR_ACK&&this._status!==b.STATUS_CONFIRMED)return!1;if(!this._isReadyToReOffer())return!1;var i={succeeded:function(){n&&n()},failed:function(){e.terminate({cause:c.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:i,rtcOfferConstraints:r,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:i,rtcOfferConstraints:r,extraHeaders:t.extraHeaders}),!0}},{key:"refer",value:function(e,t){var n=this;S("refer()");var r=e;if(this._status!==b.STATUS_WAITING_FOR_ACK&&this._status!==b.STATUS_CONFIRMED)return!1;if(!(e=this._ua.normalizeTarget(e)))throw new TypeError("Invalid target: "+r);var i=new C(this);i.sendRefer(e,t);var s=i.id;return this._referSubscribers[s]=i,i.on("requestFailed",function(){delete n._referSubscribers[s]}),i.on("accepted",function(){delete n._referSubscribers[s]}),i.on("failed",function(){delete n._referSubscribers[s]}),i}},{key:"sendRequest",value:function(e,t){return S("sendRequest()"),this._dialog.sendRequest(e,t)}},{key:"receiveRequest",value:function(e){var t=this;if(S("receiveRequest()"),e.method===c.CANCEL)this._status!==b.STATUS_WAITING_FOR_ANSWER&&this._status!==b.STATUS_ANSWERED||(this._status=b.STATUS_CANCELED,this._request.reply(487),this._failed("remote",e,c.causes.CANCELED));else switch(e.method){case c.ACK:if(this._status!==b.STATUS_WAITING_FOR_ACK)return;if(this._status=b.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!e.body){this.terminate({cause:c.causes.MISSING_SDP,status_code:400});break}var n={originator:"remote",type:"answer",sdp:e.body},r=new RTCSessionDescription({type:"answer",sdp:n.sdp});this.emit("sdp",n),this._connection.setRemoteDescription(r).then(function(){t._is_confirmed||t._confirmed("remote",e)}).catch(function(e){t.terminate({cause:c.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),t.emit("peerconnection:setremotedescriptionfailed",e)})}else this._is_confirmed||this._confirmed("remote",e);break;case c.BYE:this._status===b.STATUS_CONFIRMED?(e.reply(200),this._ended("remote",e,c.causes.BYE)):this._status===b.STATUS_INVITE_RECEIVED?(e.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",e,c.causes.BYE)):e.reply(403,"Wrong Status");break;case c.INVITE:this._status===b.STATUS_CONFIRMED?e.hasHeader("replaces")?this._receiveReplaces(e):this._receiveReinvite(e):e.reply(403,"Wrong Status");break;case c.INFO:if(this._status===b.STATUS_1XX_RECEIVED||this._status===b.STATUS_WAITING_FOR_ANSWER||this._status===b.STATUS_ANSWERED||this._status===b.STATUS_WAITING_FOR_ACK||this._status===b.STATUS_CONFIRMED){var i=e.getHeader("content-type");i&&i.match(/^application\/dtmf-relay/i)?new g(this).init_incoming(e):void 0!==i?new y(this).init_incoming(e):e.reply(415)}else e.reply(403,"Wrong Status");break;case c.UPDATE:this._status===b.STATUS_CONFIRMED?this._receiveUpdate(e):e.reply(403,"Wrong Status");break;case c.REFER:this._status===b.STATUS_CONFIRMED?this._receiveRefer(e):e.reply(403,"Wrong Status");break;case c.NOTIFY:this._status===b.STATUS_CONFIRMED?this._receiveNotify(e):e.reply(403,"Wrong Status");break;default:e.reply(501)}}},{key:"onTransportError",value:function(){E("onTransportError()"),this._status!==b.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:c.causes.CONNECTION_ERROR,cause:c.causes.CONNECTION_ERROR})}},{key:"onRequestTimeout",value:function(){E("onRequestTimeout()"),this._status!==b.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:c.causes.REQUEST_TIMEOUT,cause:c.causes.REQUEST_TIMEOUT})}},{key:"onDialogError",value:function(){E("onDialogError()"),this._status!==b.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:c.causes.DIALOG_ERROR,cause:c.causes.DIALOG_ERROR})}},{key:"newDTMF",value:function(e){S("newDTMF()"),this.emit("newDTMF",e)}},{key:"newInfo",value:function(e){S("newInfo()"),this.emit("newInfo",e)}},{key:"_isReadyToReOffer",value:function(){return this._rtcReady?this._dialog?!0!==this._dialog.uac_pending_reply&&!0!==this._dialog.uas_pending_reply||(S("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):(S("_isReadyToReOffer() | session not established yet"),!1):(S("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}},{key:"_close",value:function(){if(S("close()"),this._status!==b.STATUS_TERMINATED){if(this._status=b.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(e){E("close() | error closing the RTCPeerConnection: %o",e)}this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(S("close() | closing local MediaStream"),f.closeMediaStream(this._localMediaStream));for(var e in this._timers)Object.prototype.hasOwnProperty.call(this._timers,e)&&clearTimeout(this._timers[e]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(var t in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,t)&&(this._earlyDialogs[t].terminate(),delete this._earlyDialogs[t]);for(var n in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,n)&&delete this._referSubscribers[n];this._ua.destroyRTCSession(this)}}},{key:"_setInvite2xxTimer",value:function(e,t){function n(){this._status===b.STATUS_WAITING_FOR_ACK&&(e.reply(200,null,["Contact: "+this._contact],t),rp.T2&&(r=p.T2),this._timers.invite2xxTimer=setTimeout(n.bind(this),r))}var r=p.T1;this._timers.invite2xxTimer=setTimeout(n.bind(this),r)}},{key:"_setACKTimer",value:function(){var e=this;this._timers.ackTimer=setTimeout(function(){e._status===b.STATUS_WAITING_FOR_ACK&&(S("no ACK received, terminating the session"),clearTimeout(e._timers.invite2xxTimer),e.sendRequest(c.BYE),e._ended("remote",null,c.causes.NO_ACK))},p.TIMER_H)}},{key:"_createRTCConnection",value:function(e,t){var n=this;this._connection=new RTCPeerConnection(e,t),this._connection.addEventListener("iceconnectionstatechange",function(){"failed"===n._connection.iceConnectionState&&n.terminate({cause:c.causes.RTP_TIMEOUT,status_code:408,reason_phrase:c.causes.RTP_TIMEOUT})})}},{key:"_createLocalDescription",value:function(e,t,n,r){function i(r){var i=this,s=void 0;a.addEventListener("icecandidate",s=function(n){if(!n.candidate){if(a.removeEventListener("icecandidate",s),i._rtcReady=!0,t){var r={originator:"local",type:e,sdp:a.localDescription.sdp};S('emit "sdp"'),i.emit("sdp",r),t(r.sdp)}t=null}}),a.setLocalDescription(r).then(function(){if("complete"===a.iceGatheringState&&(i._rtcReady=!0,t)){var n={originator:"local",type:e,sdp:a.localDescription.sdp};S('emit "sdp"'),i.emit("sdp",n),t(n.sdp),t=null}}).catch(function(e){i._rtcReady=!0,n&&n(e),E('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',e),i.emit("peerconnection:setlocaldescriptionfailed",e)})}var s=this;S("createLocalDescription()");var a=this._connection;if(this._rtcReady=!1,"offer"===e)a.createOffer(r).then(i.bind(this)).catch(function(e){s._rtcReady=!0,n&&n(e),E('emit "peerconnection:createofferfailed" [error:%o]',e),s.emit("peerconnection:createofferfailed",e)});else{if("answer"!==e)throw new Error('createLocalDescription() | type must be "offer" or "answer", but "'+e+'" was given');a.createAnswer(r).then(i.bind(this)).catch(function(e){s._rtcReady=!0,n&&n(e),E('emit "peerconnection:createanswerfailed" [error:%o]',e),s.emit("peerconnection:createanswerfailed",e)})}}},{key:"_createDialog",value:function(e,t,n){var r="UAS"===t?e.to_tag:e.from_tag,i="UAS"===t?e.from_tag:e.to_tag,s=e.call_id+r+i,a=this._earlyDialogs[s];if(n)return!!a||((a=new m(this,e,t,m.C.STATUS_EARLY)).error?(S(a.error),this._failed("remote",e,c.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[s]=a,!0));if(this._from_tag=e.from_tag,this._to_tag=e.to_tag,a)return a.update(e,t),this._dialog=a,delete this._earlyDialogs[s],!0;var o=new m(this,e,t);return o.error?(S(o.error),this._failed("remote",e,c.causes.INTERNAL_ERROR),!1):(this._dialog=o,!0)}},{key:"_receiveReinvite",value:function(e){function t(){var t=this;n.call(this,function(n){var r=["Contact: "+t._contact];t._handleSessionTimersInIncomingRequest(e,r),t._late_sdp&&(n=t._mangleOffer(n)),e.reply(200,null,r,n,function(){t._status=b.STATUS_WAITING_FOR_ACK,t._setInvite2xxTimer(e,n),t._setACKTimer()}),"function"==typeof s.callback&&s.callback()},function(){e.reply(500)})}function n(e,t){this._late_sdp?this._createLocalDescription("offer",e,t,this._rtcOfferConstraints):(!0===this._remoteHold&&!1===a?(this._remoteHold=!1,this._onunhold("remote")):!1===this._remoteHold&&!0===a&&(this._remoteHold=!0,this._onhold("remote")),this._createLocalDescription("answer",e,t,this._rtcAnswerConstraints))}var r=this;S("receiveReinvite()");var i=e.getHeader("Content-Type"),s={request:e,callback:void 0,reject:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o=!0;var n=t.status_code||403,r=t.reason_phrase||"",i=f.cloneArray(t.extraHeaders);if(this._status!==b.STATUS_CONFIRMED)return!1;if(n<300||n>=700)throw new TypeError("Invalid status_code: "+n);e.reply(n,r,i)}.bind(this)},a=!1,o=!1;if(this.emit("reinvite",s),!o)if(e.body){if(this._late_sdp=!1,"application/sdp"!==i)return S("invalid Content-Type"),void e.reply(415);var l=e.parseSDP(),u=!0,c=!1,d=void 0;try{for(var h,p=l.media[Symbol.iterator]();!(u=(h=p.next()).done);u=!0){var _=h.value;if(-1!==R.indexOf(_.type)){var m=_.direction||l.direction||"sendrecv";if("sendonly"!==m&&"inactive"!==m){a=!1;break}a=!0}}}catch(e){c=!0,d=e}finally{try{!u&&p.return&&p.return()}finally{if(c)throw d}}var v={originator:"remote",type:"offer",sdp:e.body},g=new RTCSessionDescription({type:"offer",sdp:v.sdp});this.emit("sdp",v),this._connection.setRemoteDescription(g).then(t.bind(this)).catch(function(t){e.reply(488),E('emit "peerconnection:setremotedescriptionfailed" [error:%o]',t),r.emit("peerconnection:setremotedescriptionfailed",t)})}else this._late_sdp=!0,t.call(this)}},{key:"_receiveUpdate",value:function(e){var t=this;S("receiveUpdate()");var n=e.getHeader("Content-Type"),r={request:e,callback:void 0,reject:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i=!0;var n=t.status_code||403,r=t.reason_phrase||"",s=f.cloneArray(t.extraHeaders);if(this._status!==b.STATUS_CONFIRMED)return!1;if(n<300||n>=700)throw new TypeError("Invalid status_code: "+n);e.reply(n,r,s)}.bind(this)},i=!1,s=!1;if(this.emit("update",r),!i){if(!e.body){var a=[];return this._handleSessionTimersInIncomingRequest(e,a),void e.reply(200,null,a)}if("application/sdp"!==n)return S("invalid Content-Type"),void e.reply(415);var o=e.parseSDP(),l=!0,u=!1,c=void 0;try{for(var d,h=o.media[Symbol.iterator]();!(l=(d=h.next()).done);l=!0){var p=d.value;if(-1!==R.indexOf(p.type)){var _=p.direction||o.direction||"sendrecv";if("sendonly"!==_&&"inactive"!==_){s=!1;break}s=!0}}}catch(e){u=!0,c=e}finally{try{!l&&h.return&&h.return()}finally{if(u)throw c}}var m={originator:"remote",type:"offer",sdp:e.body};S('emit "sdp"'),this.emit("sdp",m);var v=new RTCSessionDescription({type:"offer",sdp:m.sdp});this._connection.setRemoteDescription(v).then(function(){!0===t._remoteHold&&!1===s?(t._remoteHold=!1,t._onunhold("remote")):!1===t._remoteHold&&!0===s&&(t._remoteHold=!0,t._onhold("remote")),t._createLocalDescription("answer",function(n){var i=["Contact: "+t._contact];t._handleSessionTimersInIncomingRequest(e,i),e.reply(200,null,i,n),"function"==typeof r.callback&&r.callback()},function(){e.reply(500)})}).catch(function(n){e.reply(488),E('emit "peerconnection:setremotedescriptionfailed" [error:%o]',n),t.emit("peerconnection:setremotedescriptionfailed",n)})}}},{key:"_receiveRefer",value:function(e){function n(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(n="function"==typeof n?n:null,this._status!==b.STATUS_WAITING_FOR_ACK&&this._status!==b.STATUS_CONFIRMED)return!1;var i=new t(this._ua);if(i.on("progress",function(e){var t=e.response;s.notify(t.status_code,t.reason_phrase)}),i.on("accepted",function(e){var t=e.response;s.notify(t.status_code,t.reason_phrase)}),i.on("failed",function(e){var t=e.message,n=e.cause;t?s.notify(t.status_code,t.reason_phrase):s.notify(487,n)}),e.refer_to.uri.hasHeader("replaces")){var a=decodeURIComponent(e.refer_to.uri.getHeader("replaces"));r.extraHeaders=f.cloneArray(r.extraHeaders),r.extraHeaders.push("Replaces: "+a)}i.connect(e.refer_to.uri.toAor(),r,n)}function r(){s.notify(603)}var i=this;if(S("receiveRefer()"),void 0===a(e.refer_to))return S("no Refer-To header field present in REFER"),void e.reply(400);if(e.refer_to.uri.scheme!==c.SIP)return S("Refer-To header field points to a non-SIP URI scheme"),void e.reply(416);e.reply(202);var s=new T(this,e.cseq);S('emit "refer"'),this.emit("refer",{request:e,accept:function(e,t){n.call(i,e,t)},reject:function(){r.call(i)}})}},{key:"_receiveNotify",value:function(e){switch(S("receiveNotify()"),void 0===a(e.event)&&e.reply(400),e.event.event){case"refer":var t=void 0,n=void 0;if(e.event.params&&e.event.params.id)t=e.event.params.id,n=this._referSubscribers[t];else{if(1!==Object.keys(this._referSubscribers).length)return void e.reply(400,"Missing event id parameter");n=this._referSubscribers[Object.keys(this._referSubscribers)[0]]}if(!n)return void e.reply(481,"Subscription does not exist");n.receiveNotify(e),e.reply(200);break;default:e.reply(489)}}},{key:"_receiveReplaces",value:function(e){function n(n){var r=this;if(this._status!==b.STATUS_WAITING_FOR_ACK&&this._status!==b.STATUS_CONFIRMED)return!1;var i=new t(this._ua);i.on("confirmed",function(){r.terminate()}),i.init_incoming(e,n)}function r(){S("Replaced INVITE rejected by the user"),e.reply(486)}var i=this;S("receiveReplaces()"),this.emit("replaces",{request:e,accept:function(e){n.call(i,e)},reject:function(){r.call(i)}})}},{key:"_sendInitialRequest",value:function(e,t,n){function r(e){this._status!==b.STATUS_TERMINATED&&(this._localMediaStream=e,e&&this._connection.addStream(e),S('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection}),this._connecting(this._request),this._createLocalDescription("offer",s.bind(this),a.bind(this),t))}function i(){this._status!==b.STATUS_TERMINATED&&this._failed("local",null,c.causes.USER_DENIED_MEDIA_ACCESS)}function s(e){this._is_canceled||this._status===b.STATUS_TERMINATED||(this._request.body=e,this._status=b.STATUS_INVITE_SENT,S('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),l.send())}function a(){this._status!==b.STATUS_TERMINATED&&this._failed("system",null,c.causes.WEBRTC_ERROR)}var o=this,l=new v(this._ua,this._request,{onRequestTimeout:function(){o.onRequestTimeout()},onTransportError:function(){o.onTransportError()},onAuthenticated:function(e){o._request=e},onReceiveResponse:function(e){o._receiveInviteResponse(e)}});n?setTimeout(function(){r(n)}):e.audio||e.video?(this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(e).then(r.bind(this)).catch(function(e){i.call(o,e),E('emit "getusermediafailed" [error:%o]',e),o.emit("getusermediafailed",e)})):r.call(this,null)}},{key:"_receiveInviteResponse",value:function(e){var t=this;if(S("receiveInviteResponse()"),this._dialog&&e.status_code>=200&&e.status_code<=299){if(this._dialog.id.call_id===e.call_id&&this._dialog.id.local_tag===e.from_tag&&this._dialog.id.remote_tag===e.to_tag)return void this.sendRequest(c.ACK);var n=new m(this,e,"UAC");return void 0!==n.error?void S(n.error):(this.sendRequest(c.ACK),void this.sendRequest(c.BYE))}if(this._is_canceled)e.status_code>=100&&e.status_code<200?this._request.cancel(this._cancel_reason):e.status_code>=200&&e.status_code<299&&this._acceptAndTerminate(e);else if(this._status===b.STATUS_INVITE_SENT||this._status===b.STATUS_1XX_RECEIVED)switch(!0){case/^100$/.test(e.status_code):this._status=b.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(e.status_code):if(!e.to_tag){S("1xx response received without to tag");break}if(e.hasHeader("contact")&&!this._createDialog(e,"UAC",!0))break;if(this._status=b.STATUS_1XX_RECEIVED,this._progress("remote",e),!e.body)break;var r={originator:"remote",type:"answer",sdp:e.body};S('emit "sdp"'),this.emit("sdp",r);var i=new RTCSessionDescription({type:"answer",sdp:r.sdp});this._connection.setRemoteDescription(i).catch(function(e){E('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)});break;case/^2[0-9]{2}$/.test(e.status_code):if(this._status=b.STATUS_CONFIRMED,!e.body){this._acceptAndTerminate(e,400,c.causes.MISSING_SDP),this._failed("remote",e,c.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(e,"UAC"))break;var s={originator:"remote",type:"answer",sdp:e.body};S('emit "sdp"'),this.emit("sdp",s);var a=new RTCSessionDescription({type:"answer",sdp:s.sdp});Promise.resolve().then(function(){if("stable"===t._connection.signalingState)return t._connection.createOffer().then(function(e){return t._connection.setLocalDescription(e)}).catch(function(n){t._acceptAndTerminate(e,500,n.toString()),t._failed("local",e,c.causes.WEBRTC_ERROR),E('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',n),t.emit("peerconnection:setlocaldescriptionfailed",n)})}).then(function(){t._connection.setRemoteDescription(a).then(function(){t._handleSessionTimersInIncomingResponse(e),t._accepted("remote",e),t.sendRequest(c.ACK),t._confirmed("local",null)}).catch(function(n){t._acceptAndTerminate(e,488,"Not Acceptable Here"),t._failed("remote",e,c.causes.BAD_MEDIA_DESCRIPTION),E('emit "peerconnection:setremotedescriptionfailed" [error:%o]',n),t.emit("peerconnection:setremotedescriptionfailed",n)})});break;default:var o=f.sipErrorCause(e.status_code);this._failed("remote",e,o)}}},{key:"_sendReinvite",value:function(){function e(e){var n=this;if(this._status!==b.STATUS_TERMINATED&&(this.sendRequest(c.ACK),!o))if(this._handleSessionTimersInIncomingResponse(e),e.body)if("application/sdp"===e.getHeader("Content-Type")){var r={originator:"remote",type:"answer",sdp:e.body};S('emit "sdp"'),this.emit("sdp",r);var i=new RTCSessionDescription({type:"answer",sdp:r.sdp});this._connection.setRemoteDescription(i).then(function(){s.succeeded&&s.succeeded(e)}).catch(function(e){t.call(n),E('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),n.emit("peerconnection:setremotedescriptionfailed",e)})}else t.call(this);else t.call(this)}function t(e){s.failed&&s.failed(e)}var n=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};S("sendReinvite()");var i=f.cloneArray(r.extraHeaders),s=r.eventHandlers||{},a=r.rtcOfferConstraints||this._rtcOfferConstraints||null,o=!1;i.push("Contact: "+this._contact),i.push("Content-Type: application/sdp"),this._sessionTimers.running&&i.push("Session-Expires: "+this._sessionTimers.currentExpires+";refresher="+(this._sessionTimers.refresher?"uac":"uas")),this._createLocalDescription("offer",function(r){r=n._mangleOffer(r),n.sendRequest(c.INVITE,{extraHeaders:i,body:r,eventHandlers:{onSuccessResponse:function(t){e.call(n,t),o=!0},onErrorResponse:function(e){t.call(n,e)},onTransportError:function(){n.onTransportError()},onRequestTimeout:function(){n.onRequestTimeout()},onDialogError:function(){n.onDialogError()}}})},function(){t()},a)}},{key:"_sendUpdate",value:function(){function e(e){var n=this;if(this._status!==b.STATUS_TERMINATED&&!l)if(this._handleSessionTimersInIncomingResponse(e),o){if(!e.body)return void t.call(this);if("application/sdp"!==e.getHeader("Content-Type"))return void t.call(this);var r={originator:"remote",type:"answer",sdp:e.body};S('emit "sdp"'),this.emit("sdp",r);var i=new RTCSessionDescription({type:"answer",sdp:r.sdp});this._connection.setRemoteDescription(i).then(function(){s.succeeded&&s.succeeded(e)}).catch(function(e){t.call(n),E('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),n.emit("peerconnection:setremotedescriptionfailed",e)})}else s.succeeded&&s.succeeded(e)}function t(e){s.failed&&s.failed(e)}var n=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};S("sendUpdate()");var i=f.cloneArray(r.extraHeaders),s=r.eventHandlers||{},a=r.rtcOfferConstraints||this._rtcOfferConstraints||null,o=r.sdpOffer||!1,l=!1;i.push("Contact: "+this._contact),this._sessionTimers.running&&i.push("Session-Expires: "+this._sessionTimers.currentExpires+";refresher="+(this._sessionTimers.refresher?"uac":"uas")),o?(i.push("Content-Type: application/sdp"),this._createLocalDescription("offer",function(r){r=n._mangleOffer(r),n.sendRequest(c.UPDATE,{extraHeaders:i,body:r,eventHandlers:{onSuccessResponse:function(t){e.call(n,t),l=!0},onErrorResponse:function(e){t.call(n,e)},onTransportError:function(){n.onTransportError()},onRequestTimeout:function(){n.onRequestTimeout()},onDialogError:function(){n.onDialogError()}}})},function(){t.call(n)},a)):this.sendRequest(c.UPDATE,{extraHeaders:i,eventHandlers:{onSuccessResponse:function(t){e.call(n,t)},onErrorResponse:function(e){t.call(n,e)},onTransportError:function(){n.onTransportError()},onRequestTimeout:function(){n.onRequestTimeout()},onDialogError:function(){n.onDialogError()}}})}},{key:"_acceptAndTerminate",value:function(e,t,n){S("acceptAndTerminate()");var r=[];t&&(n=n||c.REASON_PHRASE[t]||"",r.push("Reason: SIP ;cause="+t+'; text="'+n+'"')),(this._dialog||this._createDialog(e,"UAC"))&&(this.sendRequest(c.ACK),this.sendRequest(c.BYE,{extraHeaders:r})),this._status=b.STATUS_TERMINATED}},{key:"_mangleOffer",value:function(e){if(!this._localHold&&!this._remoteHold)return e;if(e=u.parse(e),this._localHold&&!this._remoteHold){S("mangleOffer() | me on hold, mangling offer");var t=!0,n=!1,r=void 0;try{for(var i,s=e.media[Symbol.iterator]();!(t=(i=s.next()).done);t=!0){var a=i.value;-1!==R.indexOf(a.type)&&(a.direction?"sendrecv"===a.direction?a.direction="sendonly":"recvonly"===a.direction&&(a.direction="inactive"):a.direction="sendonly")}}catch(e){n=!0,r=e}finally{try{!t&&s.return&&s.return()}finally{if(n)throw r}}}else if(this._localHold&&this._remoteHold){S("mangleOffer() | both on hold, mangling offer");var o=!0,l=!1,c=void 0;try{for(var d,h=e.media[Symbol.iterator]();!(o=(d=h.next()).done);o=!0){var f=d.value;-1!==R.indexOf(f.type)&&(f.direction="inactive")}}catch(e){l=!0,c=e}finally{try{!o&&h.return&&h.return()}finally{if(l)throw c}}}else if(this._remoteHold){S("mangleOffer() | remote on hold, mangling offer");var p=!0,_=!1,m=void 0;try{for(var v,g=e.media[Symbol.iterator]();!(p=(v=g.next()).done);p=!0){var y=v.value;-1!==R.indexOf(y.type)&&(y.direction?"sendrecv"===y.direction?y.direction="recvonly":"recvonly"===y.direction&&(y.direction="inactive"):y.direction="recvonly")}}catch(e){_=!0,m=e}finally{try{!p&&g.return&&g.return()}finally{if(_)throw m}}}return u.write(e)}},{key:"_setLocalMediaStatus",value:function(){var e=!0,t=!0;(this._localHold||this._remoteHold)&&(e=!1,t=!1),this._audioMuted&&(e=!1),this._videoMuted&&(t=!1),this._toogleMuteAudio(!e),this._toogleMuteVideo(!t)}},{key:"_handleSessionTimersInIncomingRequest",value:function(e,t){if(this._sessionTimers.enabled){var n=void 0;e.session_expires&&e.session_expires>=c.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=e.session_expires,n=e.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,n="uas"),t.push("Session-Expires: "+this._sessionTimers.currentExpires+";refresher="+n),this._sessionTimers.refresher="uas"===n,this._runSessionTimer()}}},{key:"_handleSessionTimersInIncomingResponse",value:function(e){if(this._sessionTimers.enabled){var t=void 0;e.session_expires&&e.session_expires>=c.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=e.session_expires,t=e.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,t="uac"),this._sessionTimers.refresher="uac"===t,this._runSessionTimer()}}},{key:"_runSessionTimer",value:function(){var e=this,t=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(function(){e._status!==b.STATUS_TERMINATED&&(S("runSessionTimer() | sending session refresh request"),e._sendUpdate({eventHandlers:{succeeded:function(t){e._handleSessionTimersInIncomingResponse(t)}}}))},500*t):this._sessionTimers.timer=setTimeout(function(){e._status!==b.STATUS_TERMINATED&&(E("runSessionTimer() | timer expired, terminating the session"),e.terminate({cause:c.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},1100*t)}},{key:"_toogleMuteAudio",value:function(e){var t=this._connection.getLocalStreams(),n=!0,r=!1,i=void 0;try{for(var s,a=t[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var o=s.value.getAudioTracks(),l=!0,u=!1,c=void 0;try{for(var d,h=o[Symbol.iterator]();!(l=(d=h.next()).done);l=!0)d.value.enabled=!e}catch(e){u=!0,c=e}finally{try{!l&&h.return&&h.return()}finally{if(u)throw c}}}}catch(e){r=!0,i=e}finally{try{!n&&a.return&&a.return()}finally{if(r)throw i}}}},{key:"_toogleMuteVideo",value:function(e){var t=this._connection.getLocalStreams(),n=!0,r=!1,i=void 0;try{for(var s,a=t[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var o=s.value.getVideoTracks(),l=!0,u=!1,c=void 0;try{for(var d,h=o[Symbol.iterator]();!(l=(d=h.next()).done);l=!0)d.value.enabled=!e}catch(e){u=!0,c=e}finally{try{!l&&h.return&&h.return()}finally{if(u)throw c}}}}catch(e){r=!0,i=e}finally{try{!n&&a.return&&a.return()}finally{if(r)throw i}}}},{key:"_newRTCSession",value:function(e,t){S("newRTCSession()"),this._ua.newRTCSession(this,{originator:e,session:this,request:t})}},{key:"_connecting",value:function(e){S("session connecting"),S('emit "connecting"'),this.emit("connecting",{request:e})}},{key:"_progress",value:function(e,t){S("session progress"),S('emit "progress"'),this.emit("progress",{originator:e,response:t||null})}},{key:"_accepted",value:function(e,t){S("session accepted"),this._start_time=new Date,S('emit "accepted"'),this.emit("accepted",{originator:e,response:t||null})}},{key:"_confirmed",value:function(e,t){S("session confirmed"),this._is_confirmed=!0,S('emit "confirmed"'),this.emit("confirmed",{originator:e,ack:t||null})}},{key:"_ended",value:function(e,t,n){S("session ended"),this._end_time=new Date,this._close(),S('emit "ended"'),this.emit("ended",{originator:e,message:t||null,cause:n})}},{key:"_failed",value:function(e,t,n){S("session failed"),this._close(),S('emit "failed"'),this.emit("failed",{originator:e,message:t||null,cause:n})}},{key:"_onhold",value:function(e){S("session onhold"),this._setLocalMediaStatus(),S('emit "hold"'),this.emit("hold",{originator:e})}},{key:"_onunhold",value:function(e){S("session onunhold"),this._setLocalMediaStatus(),S('emit "unhold"'),this.emit("unhold",{originator:e})}},{key:"_onmute",value:function(e){var t=e.audio,n=e.video;S("session onmute"),this._setLocalMediaStatus(),S('emit "muted"'),this.emit("muted",{audio:t,video:n})}},{key:"_onunmute",value:function(e){var t=e.audio,n=e.video;S("session onunmute"),this._setLocalMediaStatus(),S('emit "unmuted"'),this.emit("unmuted",{audio:t,video:n})}},{key:"C",get:function(){return b}},{key:"causes",get:function(){return c.causes}},{key:"id",get:function(){return this._id}},{key:"connection",get:function(){return this._connection}},{key:"direcion",get:function(){return this._direcion}},{key:"local_identity",get:function(){return this._local_identity}},{key:"remote_identity",get:function(){return this._remote_identity}},{key:"start_time",get:function(){return this._start_time}},{key:"end_time",get:function(){return this._end_time}},{key:"data",get:function(){return this._data},set:function(e){this._data=e}},{key:"status",get:function(){return this._status}}]),t}()},{"./Constants":2,"./Dialog":3,"./Exceptions":6,"./RTCSession/DTMF":13,"./RTCSession/Info":14,"./RTCSession/ReferNotifier":15,"./RTCSession/ReferSubscriber":16,"./RequestSender":18,"./SIPMessage":19,"./Timers":21,"./Transactions":22,"./Utils":26,debug:29,events:31,"sdp-transform":36}],13:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};if(void 0===e)throw new TypeError("Not enough arguments");if(this._direction="outgoing",this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK)throw new u.InvalidStateError(this._session.status);var r=c.cloneArray(n.extraHeaders);if(this.eventHandlers=n.eventHandlers||{},"string"==typeof e)e=e.toUpperCase();else{if("number"!=typeof e)throw new TypeError("Invalid tone: "+e);e=e.toString()}if(!e.match(/^[0-9A-DR#*]$/))throw new TypeError("Invalid tone: "+e);this._tone=e,this._duration=n.duration,r.push("Content-Type: application/dtmf-relay");var i="Signal="+this._tone+"\r\n";i+="Duration="+this._duration,this._session.newDTMF({originator:"local",dtmf:this,request:this._request}),this._session.sendRequest(l.INFO,{extraHeaders:r,eventHandlers:{onSuccessResponse:function(e){t.emit("succeeded",{originator:"remote",response:e})},onErrorResponse:function(e){t.eventHandlers.onFailed&&t.eventHandlers.onFailed(),t.emit("failed",{originator:"remote",response:e})},onRequestTimeout:function(){t._session.onRequestTimeout()},onTransportError:function(){t._session.onTransportError()},onDialogError:function(){t._session.onDialogError()}},body:i})}},{key:"init_incoming",value:function(e){var t=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,n=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;if(this._direction="incoming",this._request=e,e.reply(200),e.body){var r=e.body.split("\n");r.length>=1&&t.test(r[0])&&(this._tone=r[0].replace(t,"$2")),r.length>=2&&n.test(r[1])&&(this._duration=parseInt(r[1].replace(n,"$2"),10))}this._duration||(this._duration=h.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:e}):d("invalid INFO DTMF received, discarded")}},{key:"tone",get:function(){return this._tone}},{key:"duration",get:function(){return this._duration}}]),t}(),t.exports.C=h},{"../Constants":2,"../Exceptions":6,"../Utils":26,debug:29,events:31}],14:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=function(){function e(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:{};if(this._direction="outgoing",void 0===e)throw new TypeError("Not enough arguments");if(this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK)throw new u.InvalidStateError(this._session.status);this._contentType=e,this._body=t;var i=c.cloneArray(r.extraHeaders);i.push("Content-Type: "+e),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(this,l.INFO,{extraHeaders:i,eventHandlers:{onSuccessResponse:function(e){n.emit("succeeded",{originator:"remote",response:e})},onErrorResponse:function(e){n.emit("failed",{originator:"remote",response:e})},onTransportError:function(){n._session.onTransportError()},onRequestTimeout:function(){n._session.onRequestTimeout()},onDialogError:function(){n._session.onDialogError()}},body:t})}},{key:"init_incoming",value:function(e){this._direction="incoming",this.request=e,e.reply(200),this._contentType=e.getHeader("content-type"),this._body=e.body,this._session.newInfo({originator:"remote",info:this,request:e})}},{key:"contentType",get:function(){return this._contentType}},{key:"body",get:function(){return this._body}}]),t}()},{"../Constants":2,"../Exceptions":6,"../Utils":26,debug:29,events:31}],15:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n=200?"terminated;reason=noresource":"active;expires="+this._expires,this._session.sendRequest(s.NOTIFY,{extraHeaders:["Event: "+o.event_type+";id="+this._id,"Subscription-State: "+n,"Content-Type: "+o.body_type],body:"SIP/2.0 "+e+" "+t,eventHandlers:{onErrorResponse:function(){this._active=!1}}})}}}]),e}()},{"../Constants":2,debug:29}],16:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};d("sendRefer()");var r=c.cloneArray(n.extraHeaders),i=n.eventHandlers||{};for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&this.on(s,i[s]);var a=null;n.replaces&&(a=n.replaces.request.call_id,a+=";to-tag="+n.replaces.to_tag,a+=";from-tag="+n.replaces.from_tag,a=encodeURIComponent(a));var o="Refer-To: <"+e+(a?"?Replaces="+a:"")+">";r.push(o);var u=this._session.sendRequest(l.REFER,{extraHeaders:r,eventHandlers:{onSuccessResponse:function(e){t._requestSucceeded(e)},onErrorResponse:function(e){t._requestFailed(e,l.causes.REJECTED)},onTransportError:function(){t._requestFailed(null,l.causes.CONNECTION_ERROR)},onRequestTimeout:function(){t._requestFailed(null,l.causes.REQUEST_TIMEOUT)},onDialogError:function(){t._requestFailed(null,l.causes.DIALOG_ERROR)}}});this._id=u.cseq}},{key:"receiveNotify",value:function(e){if(d("receiveNotify()"),e.body){var t=u.parse(e.body,"Status_Line");if(-1!==t)switch(!0){case/^100$/.test(t.status_code):this.emit("trying",{request:e,status_line:t});break;case/^1[0-9]{2}$/.test(t.status_code):this.emit("progress",{request:e,status_line:t});break;case/^2[0-9]{2}$/.test(t.status_code):this.emit("accepted",{request:e,status_line:t});break;default:this.emit("failed",{request:e,status_line:t})}else d('receiveNotify() | error parsing NOTIFY body: "'+e.body+'"')}}},{key:"_requestSucceeded",value:function(e){d("REFER succeeded"),d('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:e})}},{key:"_requestFailed",value:function(e,t){d("REFER failed"),d('emit "requestFailed"'),this.emit("requestFailed",{response:e||null,cause:t})}},{key:"id",get:function(){return this._id}}]),t}()},{"../Constants":2,"../Grammar":7,"../Utils":26,debug:29,events:31}],17:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n"'}return i(e,[{key:"setExtraHeaders",value:function(e){Array.isArray(e)||(e=[]),this._extraHeaders=e.slice()}},{key:"setExtraContactParams",value:function(e){e instanceof Object||(e={}),this._extraContactParams="";for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var n=e[t];this._extraContactParams+=";"+t,n&&(this._extraContactParams+="="+n)}}},{key:"register",value:function(){var e=this;if(this._registering)u("Register request in progress...");else{var t=this._extraHeaders.slice();t.push("Contact: "+this._contact+";expires="+this._expires+this._extraContactParams),t.push("Expires: "+this._expires);var n=new o.OutgoingRequest(a.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},t),r=new l(this._ua,n,{onRequestTimeout:function(){e._registrationFailure(null,a.causes.REQUEST_TIMEOUT)},onTransportError:function(){e._registrationFailure(null,a.causes.CONNECTION_ERROR)},onAuthenticated:function(){e._cseq+=1},onReceiveResponse:function(t){var n=void 0,r=void 0,i=t.getHeaders("contact").length;if(t.cseq===e._cseq)switch(null!==e._registrationTimer&&(clearTimeout(e._registrationTimer),e._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(t.status_code):break;case/^2[0-9]{2}$/.test(t.status_code):if(e._registering=!1,t.hasHeader("expires")&&(r=t.getHeader("expires")),!i){u("no Contact header in response to REGISTER, response ignored");break}for(;i--;){if((n=t.parseHeader("contact",i)).uri.user===e._ua.contact.uri.user){r=n.getParam("expires");break}n=null}if(!n){u("no Contact header pointing to us, response ignored");break}r||(r=e._expires),e._registrationTimer=setTimeout(function(){e._registrationTimer=null,0===e._ua.listeners("registrationExpiring").length?e.register():e._ua.emit("registrationExpiring")},1e3*r-5e3),n.hasParam("temp-gruu")&&(e._ua.contact.temp_gruu=n.getParam("temp-gruu").replace(/"/g,"")),n.hasParam("pub-gruu")&&(e._ua.contact.pub_gruu=n.getParam("pub-gruu").replace(/"/g,"")),e._registered||(e._registered=!0,e._ua.registered({response:t}));break;case/^423$/.test(t.status_code):t.hasHeader("min-expires")?(e._expires=t.getHeader("min-expires"),e.register()):(u("423 response received for REGISTER without Min-Expires"),e._registrationFailure(t,a.causes.SIP_FAILURE_CODE));break;default:var o=s.sipErrorCause(t.status_code);e._registrationFailure(t,o)}}});this._registering=!0,r.send()}}},{key:"unregister",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this._registered){this._registered=!1,null!==this._registrationTimer&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);var n=this._extraHeaders.slice();t.all?n.push("Contact: *"+this._extraContactParams):n.push("Contact: "+this._contact+";expires=0"+this._extraContactParams),n.push("Expires: 0");var r=new o.OutgoingRequest(a.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},n);new l(this._ua,r,{onRequestTimeout:function(){e._unregistered(null,a.causes.REQUEST_TIMEOUT)},onTransportError:function(){e._unregistered(null,a.causes.CONNECTION_ERROR)},onAuthenticated:function(){e._cseq+=1},onReceiveResponse:function(t){switch(!0){case/^1[0-9]{2}$/.test(t.status_code):break;case/^2[0-9]{2}$/.test(t.status_code):e._unregistered(t);break;default:var n=s.sipErrorCause(t.status_code);e._unregistered(t,n)}}}).send()}else u("already unregistered")}},{key:"close",value:function(){this._registered&&this.unregister()}},{key:"onTransportClosed",value:function(){this._registering=!1,null!==this._registrationTimer&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),this._registered&&(this._registered=!1,this._ua.unregistered({}))}},{key:"_registrationFailure",value:function(e,t){this._registering=!1,this._ua.registrationFailed({response:e||null,cause:t}),this._registered&&(this._registered=!1,this._ua.unregistered({response:e||null,cause:t}))}},{key:"_unregistered",value:function(e,t){this._registering=!1,this._registered=!1,this._ua.unregistered({response:e||null,cause:t||null})}}]),e}()},{"./Constants":2,"./RequestSender":18,"./SIPMessage":19,"./Utils":26,debug:29}],18:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n"),this.setHeader("via",""),this.setHeader("max-forwards",l.MAX_FORWARDS);var d=i.to_display_name||0===i.to_display_name?'"'+i.to_display_name+'" ':"";d+="<"+(i.to_uri||n)+">",d+=i.to_tag?";tag="+i.to_tag:"",this.to=c.parse(d),this.setHeader("to",d);var h=void 0;h=i.from_display_name||0===i.from_display_name?'"'+i.from_display_name+'" ':r.configuration.display_name?'"'+r.configuration.display_name+'" ':"",h+="<"+(i.from_uri||r.configuration.uri)+">;tag=",h+=i.from_tag||u.newTag(),this.from=c.parse(h),this.setHeader("from",h);var f=i.call_id||r.configuration.jssip_id+u.createRandomToken(15);this.call_id=f,this.setHeader("call-id",f);var p=i.cseq||Math.floor(1e4*Math.random());this.cseq=p,this.setHeader("cseq",p+" "+t)}return a(e,[{key:"setHeader",value:function(e,t){for(var n=new RegExp("^\\s*"+e+"\\s*:","i"),r=0;r1&&void 0!==arguments[1]?arguments[1]:0;if(e=u.headerize(e),this.headers[e]){if(!(t>=this.headers[e].length)){var n=this.headers[e][t],r=n.raw;if(n.parsed)return n.parsed;var i=d.parse(r,e.replace(/-/g,"_"));return-1===i?(this.headers[e].splice(t,1),void h('error parsing "'+e+'" header field with value "'+r+'"')):(n.parsed=i,i)}h('not so many "'+e+'" headers present')}else h('header "'+e+'" not present')}},{key:"s",value:function(e,t){return this.parseHeader(e,t)}},{key:"setHeader",value:function(e,t){var n={raw:t};this.headers[u.headerize(e)]=[n]}},{key:"parseSDP",value:function(e){return!e&&this.sdp?this.sdp:(this.sdp=o.parse(this.body||""),this.sdp)}},{key:"toString",value:function(){return this.data}}]),e}(),m=function(e){function t(e){s(this,t);var n=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.ua=e,n.headers={},n.ruri=null,n.transport=null,n.server_transaction=null,n}return i(t,_),a(t,[{key:"reply",value:function(e,t,n,r,i,s){var a=[],o=this.getHeader("To");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);t=t||l.REASON_PHRASE[e]||"",n=u.cloneArray(n);var c="SIP/2.0 "+e+" "+t+"\r\n";if(this.method===l.INVITE&&e>100&&e<=200){var d=this.getHeaders("record-route"),h=!0,f=!1,p=void 0;try{for(var _,m=d[Symbol.iterator]();!(h=(_=m.next()).done);h=!0)c+="Record-Route: "+_.value+"\r\n"}catch(e){f=!0,p=e}finally{try{!h&&m.return&&m.return()}finally{if(f)throw p}}}var v=this.getHeaders("via"),g=!0,y=!1,T=void 0;try{for(var C,S=v[Symbol.iterator]();!(g=(C=S.next()).done);g=!0)c+="Via: "+C.value+"\r\n"}catch(e){y=!0,T=e}finally{try{!g&&S.return&&S.return()}finally{if(y)throw T}}!this.to_tag&&e>100?o+=";tag="+u.newTag():this.to_tag&&!this.s("to").hasParam("tag")&&(o+=";tag="+this.to_tag),c+="To: "+o+"\r\n",c+="From: "+this.getHeader("From")+"\r\n",c+="Call-ID: "+this.call_id+"\r\n",c+="CSeq: "+this.cseq+" "+this.method+"\r\n";var E=!0,b=!1,R=void 0;try{for(var A,w=n[Symbol.iterator]();!(E=(A=w.next()).done);E=!0)c+=A.value.trim()+"\r\n"}catch(e){b=!0,R=e}finally{try{!E&&w.return&&w.return()}finally{if(b)throw R}}switch(this.method){case l.INVITE:this.ua.configuration.session_timers&&a.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&a.push("gruu"),a.push("ice","replaces");break;case l.UPDATE:this.ua.configuration.session_timers&&a.push("timer"),r&&a.push("ice"),a.push("replaces")}a.push("outbound"),this.method===l.OPTIONS?(c+="Allow: "+l.ALLOWED_METHODS+"\r\n",c+="Accept: "+l.ACCEPTED_BODY_TYPES+"\r\n"):405===e?c+="Allow: "+l.ALLOWED_METHODS+"\r\n":415===e&&(c+="Accept: "+l.ACCEPTED_BODY_TYPES+"\r\n"),c+="Supported: "+a+"\r\n",r?(c+="Content-Type: application/sdp\r\n",c+="Content-Length: "+u.str_utf8_length(r)+"\r\n\r\n",c+=r):c+="Content-Length: 0\r\n\r\n",this.server_transaction.receiveResponse(e,c,i,s)}},{key:"reply_sl",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this.getHeaders("via");if(!e||e<100||e>699)throw new TypeError("Invalid status_code: "+e);if(t&&"string"!=typeof t&&!(t instanceof String))throw new TypeError("Invalid reason_phrase: "+t);var r="SIP/2.0 "+e+" "+(t=t||l.REASON_PHRASE[e]||"")+"\r\n",i=!0,s=!1,a=void 0;try{for(var o,c=n[Symbol.iterator]();!(i=(o=c.next()).done);i=!0)r+="Via: "+o.value+"\r\n"}catch(e){s=!0,a=e}finally{try{!i&&c.return&&c.return()}finally{if(s)throw a}}var d=this.getHeader("To");!this.to_tag&&e>100?d+=";tag="+u.newTag():this.to_tag&&!this.s("to").hasParam("tag")&&(d+=";tag="+this.to_tag),r+="To: "+d+"\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+="Content-Length: 0\r\n\r\n",this.transport.send(r)}}]),t}(),v=function(e){function t(){s(this,t);var e=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.headers={},e.status_code=null,e.reason_phrase=null,e}return i(t,_),t}();t.exports={OutgoingRequest:f,InitialOutgoingInviteRequest:p,IncomingRequest:m,IncomingResponse:v}},{"./Constants":2,"./Grammar":7,"./NameAddrHeader":10,"./Utils":26,debug:29,"sdp-transform":36}],20:[function(e,t,n){"use strict";var r=e("./Utils"),i=e("./Grammar"),s=e("debug")("JsSIP:ERROR:Socket");s.log=console.warn.bind(console),n.isSocket=function(e){if(Array.isArray(e))return!1;if(void 0===e)return s("undefined JsSIP.Socket instance"),!1;try{if(!r.isString(e.url))throw s("missing or invalid JsSIP.Socket url property"),new Error;if(!r.isString(e.via_transport))throw s("missing or invalid JsSIP.Socket via_transport property"),new Error;if(-1===i.parse(e.sip_uri,"SIP_URI"))throw s("missing or invalid JsSIP.Socket sip_uri property"),new Error}catch(e){return!1}try{["connect","disconnect","send"].forEach(function(t){if(!r.isFunction(e[t]))throw s("missing or invalid JsSIP.Socket method: "+t),new Error})}catch(e){return!1}return!0}},{"./Grammar":7,"./Utils":26,debug:29}],21:[function(e,t,n){"use strict";var r=500;t.exports={T1:r,T2:4e3,T4:5e3,TIMER_B:32e3,TIMER_D:0,TIMER_F:32e3,TIMER_H:32e3,TIMER_I:0,TIMER_J:0,TIMER_K:0,TIMER_L:32e3,TIMER_M:32e3,PROVISIONAL_RESPONSE_INTERVAL:6e4}},{}],22:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=function(){function e(e,t){for(var n=0;n=100&&n<=199)switch(this.state){case m.STATUS_CALLING:this.stateChanged(m.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(e);break;case m.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(e)}else if(n>=200&&n<=299)switch(this.state){case m.STATUS_CALLING:case m.STATUS_PROCEEDING:this.stateChanged(m.STATUS_ACCEPTED),this.M=setTimeout(function(){t.timer_M()},c.TIMER_M),this.eventHandlers.onReceiveResponse(e);break;case m.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(e)}else if(n>=300&&n<=699)switch(this.state){case m.STATUS_CALLING:case m.STATUS_PROCEEDING:this.stateChanged(m.STATUS_COMPLETED),this.sendACK(e),this.eventHandlers.onReceiveResponse(e);break;case m.STATUS_COMPLETED:this.sendACK(e)}}},{key:"C",get:function(){return m}}]),t}(),y=function(e){function t(e,n,s,a){r(this,t);var o=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));o.id="z9hG4bK"+Math.floor(1e7*Math.random()),o.transport=n,o.request=s,o.eventHandlers=a;var l="SIP/2.0/"+n.via_transport;return l+=" "+e.configuration.via_host+";branch="+o.id,o.request.setHeader("via",l),o}return s(t,o),a(t,[{key:"send",value:function(){this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){f("transport error occurred for transaction "+this.id),this.eventHandlers.onTransportError()}},{key:"C",get:function(){return m}}]),t}(),T=function(e){function t(e,n,s){r(this,t);var a=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return a.type=m.NON_INVITE_SERVER,a.id=s.via_branch,a.ua=e,a.transport=n,a.request=s,a.last_response="",s.server_transaction=a,a.state=m.STATUS_TRYING,e.newTransaction(a),a}return s(t,o),a(t,[{key:"stateChanged",value:function(e){this.state=e,this.emit("stateChanged")}},{key:"timer_J",value:function(){p("Timer J expired for transaction "+this.id),this.stateChanged(m.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,p("transport error occurred, deleting transaction "+this.id),clearTimeout(this.J),this.stateChanged(m.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"receiveResponse",value:function(e,t,n,r){var i=this;if(100===e)switch(this.state){case m.STATUS_TRYING:this.stateChanged(m.STATUS_PROCEEDING),this.transport.send(t)||this.onTransportError();break;case m.STATUS_PROCEEDING:this.last_response=t,this.transport.send(t)?n&&n():(this.onTransportError(),r&&r())}else if(e>=200&&e<=699)switch(this.state){case m.STATUS_TRYING:case m.STATUS_PROCEEDING:this.stateChanged(m.STATUS_COMPLETED),this.last_response=t,this.J=setTimeout(function(){i.timer_J()},c.TIMER_J),this.transport.send(t)?n&&n():(this.onTransportError(),r&&r());break;case m.STATUS_COMPLETED:}}},{key:"C",get:function(){return m}}]),t}(),C=function(e){function t(e,n,s){r(this,t);var a=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return a.type=m.INVITE_SERVER,a.id=s.via_branch,a.ua=e,a.transport=n,a.request=s,a.last_response="",s.server_transaction=a,a.state=m.STATUS_PROCEEDING,e.newTransaction(a),a.resendProvisionalTimer=null,s.reply(100),a}return s(t,o),a(t,[{key:"stateChanged",value:function(e){this.state=e,this.emit("stateChanged")}},{key:"timer_H",value:function(){_("Timer H expired for transaction "+this.id),this.state===m.STATUS_COMPLETED&&_("ACK not received, dialog will be terminated"),this.stateChanged(m.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_I",value:function(){this.stateChanged(m.STATUS_TERMINATED)}},{key:"timer_L",value:function(){_("Timer L expired for transaction "+this.id),this.state===m.STATUS_ACCEPTED&&(this.stateChanged(m.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,_("transport error occurred, deleting transaction "+this.id),null!==this.resendProvisionalTimer&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),clearTimeout(this.L),clearTimeout(this.H),clearTimeout(this.I),this.stateChanged(m.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"resend_provisional",value:function(){this.transport.send(this.last_response)||this.onTransportError()}},{key:"receiveResponse",value:function(e,t,n,r){var i=this;if(e>=100&&e<=199)switch(this.state){case m.STATUS_PROCEEDING:this.transport.send(t)||this.onTransportError(),this.last_response=t}if(e>100&&e<=199&&this.state===m.STATUS_PROCEEDING)null===this.resendProvisionalTimer&&(this.resendProvisionalTimer=setInterval(function(){i.resend_provisional()},c.PROVISIONAL_RESPONSE_INTERVAL));else if(e>=200&&e<=299)switch(this.state){case m.STATUS_PROCEEDING:this.stateChanged(m.STATUS_ACCEPTED),this.last_response=t,this.L=setTimeout(function(){i.timer_L()},c.TIMER_L),null!==this.resendProvisionalTimer&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case m.STATUS_ACCEPTED:this.transport.send(t)?n&&n():(this.onTransportError(),r&&r())}else if(e>=300&&e<=699)switch(this.state){case m.STATUS_PROCEEDING:null!==this.resendProvisionalTimer&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(t)?(this.stateChanged(m.STATUS_COMPLETED),this.H=setTimeout(function(){i.timer_H()},c.TIMER_H),n&&n()):(this.onTransportError(),r&&r())}}},{key:"C",get:function(){return m}}]),t}();t.exports={C:m,NonInviteClientTransaction:v,InviteClientTransaction:g,AckClientTransaction:y,NonInviteServerTransaction:T,InviteServerTransaction:C,checkTransaction:function(e,t){var n=e._transactions,r=void 0;switch(t.method){case l.INVITE:if(r=n.ist[t.via_branch]){switch(r.state){case m.STATUS_PROCEEDING:r.transport.send(r.last_response);break;case m.STATUS_ACCEPTED:}return!0}break;case l.ACK:if(!(r=n.ist[t.via_branch]))return!1;if(r.state===m.STATUS_ACCEPTED)return!1;if(r.state===m.STATUS_COMPLETED)return r.state=m.STATUS_CONFIRMED,r.I=setTimeout(function(){r.timer_I()},c.TIMER_I),!0;break;case l.CANCEL:return(r=n.ist[t.via_branch])?(t.reply_sl(200),r.state!==m.STATUS_PROCEEDING):(t.reply_sl(481),!0);default:if(r=n.nist[t.via_branch]){switch(r.state){case m.STATUS_TRYING:break;case m.STATUS_PROCEEDING:case m.STATUS_COMPLETED:r.transport.send(r.last_response)}return!0}}}}},{"./Constants":2,"./SIPMessage":19,"./Timers":21,debug:29,events:31}],23:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:l.recovery_options;if(r(this,e),a("new()"),this.status=l.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=n,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1,void 0===t)throw new TypeError("Invalid argument. undefined 'sockets' argument");t instanceof Array||(t=[t]),t.forEach(function(e){if(!s.isSocket(e.socket))throw new TypeError("Invalid argument. invalid 'JsSIP.Socket' instance");if(e.weight&&!Number(e.weight))throw new TypeError("Invalid argument. 'weight' attribute is not a number");this.sockets.push({socket:e.socket,weight:e.weight||0,status:l.SOCKET_STATUS_READY})},this),this._getSocket()}return i(e,[{key:"connect",value:function(){a("connect()"),this.isConnected()?a("Transport is already connected"):this.isConnecting()?a("Transport is connecting"):(this.close_requested=!1,this.status=l.STATUS_CONNECTING,this.onconnecting({socket:this.socket,attempts:this.recover_attempts}),this.close_requested||(this.socket.onconnect=this._onConnect.bind(this),this.socket.ondisconnect=this._onDisconnect.bind(this),this.socket.ondata=this._onData.bind(this),this.socket.connect()))}},{key:"disconnect",value:function(){a("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=l.STATUS_DISCONNECTED,null!==this.recovery_timer&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.socket.onconnect=function(){},this.socket.ondisconnect=function(){},this.socket.ondata=function(){},this.socket.disconnect(),this.ondisconnect()}},{key:"send",value:function(e){if(a("send()"),!this.isConnected())return o("unable to send message, transport is not connected"),!1;var t=e.toString();return a("sending message:\n\n"+t+"\n"),this.socket.send(t)}},{key:"isConnected",value:function(){return this.status===l.STATUS_CONNECTED}},{key:"isConnecting",value:function(){return this.status===l.STATUS_CONNECTING}},{key:"_reconnect",value:function(){var e=this;this.recover_attempts+=1;var t=Math.floor(Math.random()*Math.pow(2,this.recover_attempts)+1);tthis.recovery_options.max_interval&&(t=this.recovery_options.max_interval),a("reconnection attempt: "+this.recover_attempts+". next connection attempt in "+t+" seconds"),this.recovery_timer=setTimeout(function(){e.close_requested||e.isConnected()||e.isConnecting()||(e._getSocket(),e.connect())},1e3*t)}},{key:"_getSocket",value:function(){var e=[];if(this.sockets.forEach(function(t){t.status!==l.SOCKET_STATUS_ERROR&&(0===e.length?e.push(t):t.weight>e[0].weight?e=[t]:t.weight===e[0].weight&&e.push(t))}),0===e.length)return this.sockets.forEach(function(e){e.status=l.SOCKET_STATUS_READY}),void this._getSocket();var t=Math.floor(Math.random()*e.length);this.socket=e[t].socket}},{key:"_onConnect",value:function(){this.recover_attempts=0,this.status=l.STATUS_CONNECTED,null!==this.recovery_timer&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}},{key:"_onDisconnect",value:function(e,t,n){this.status=l.STATUS_DISCONNECTED,this.ondisconnect({socket:this.socket,error:e,code:t,reason:n}),this.close_requested||(this.sockets.forEach(function(e){this.socket===e.socket&&(e.status=l.SOCKET_STATUS_ERROR)},this),this._reconnect(e))}},{key:"_onData",value:function(e){if("\r\n"!==e){if("string"!=typeof e){try{e=String.fromCharCode.apply(null,new Uint8Array(e))}catch(e){return void a("received binary message failed to be converted into string, message discarded")}a("received binary message:\n\n"+e+"\n")}else a("received text message:\n\n"+e+"\n");this.ondata({transport:this,message:e})}else a("received message with CRLF Keep Alive response")}},{key:"via_transport",get:function(){return this.socket.via_transport}},{key:"url",get:function(){return this.socket.url}},{key:"sip_uri",get:function(){return this.socket.sip_uri}}]),e}()},{"./Socket":20,debug:29}],24:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e){this.emit("connecting",e)}function o(e){this._status!==I.STATUS_USER_CLOSED&&(this._status=I.STATUS_READY,this._error=null,this.emit("connected",e),this._dynConfiguration.register&&this._registrator.register())}function l(e){var t=["nict","ict","nist","ist"],n=!0,r=!1,i=void 0;try{for(var s,a=t[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var o=s.value;for(var l in this._transactions[o])Object.prototype.hasOwnProperty.call(this._transactions[o],l)&&this._transactions[o][l].onTransportError()}}catch(e){r=!0,i=e}finally{try{!n&&a.return&&a.return()}finally{if(r)throw i}}this.emit("disconnected",e),this._registrator.onTransportClosed(),this._status!==I.STATUS_USER_CLOSED&&(this._status=I.STATUS_NOT_READY,this._error=I.NETWORK_ERROR)}function u(e){var t=e.transport,n=e.message;if((n=S.parseMessage(n,this))&&!(this._status===I.STATUS_USER_CLOSED&&n instanceof E.IncomingRequest)&&b(n,this,t))if(n instanceof E.IncomingRequest)n.transport=t,this.receiveRequest(n);else if(n instanceof E.IncomingResponse){var r=void 0;switch(n.method){case h.INVITE:(r=this._transactions.ict[n.via_branch])&&r.receiveResponse(n);break;case h.ACK:break;default:(r=this._transactions.nict[n.via_branch])&&r.receiveResponse(n)}}}var c=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=e.anonymous||null,n=e.outbound||null,r="<";return r+=t?this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":this.pub_gruu||this.uri.toString(),!n||(t?this.temp_gruu:this.pub_gruu)||(r+=";ob"),r+=">"}};var r=["password","realm","ha1","display_name","register"];for(var i in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,i)&&(-1!==r.indexOf(i)?Object.defineProperty(this._configuration,i,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,i,{writable:!1,configurable:!1}));A("configuration parameters after validation:");for(var s in this._configuration)if(Object.prototype.hasOwnProperty.call(R.settings,s))switch(s){case"uri":case"registrar_server":A("- "+s+": "+this._configuration[s]);break;case"password":case"ha1":A("- "+s+": NOT SHOWN");break;default:A("- "+s+": "+JSON.stringify(this._configuration[s]))}}},{key:"C",get:function(){return I}},{key:"status",get:function(){return this._status}},{key:"contact",get:function(){return this._contact}},{key:"configuration",get:function(){return this._configuration}},{key:"transport",get:function(){return this._transport}}]),t}()},{"./Config":1,"./Constants":2,"./Exceptions":6,"./Grammar":7,"./Message":9,"./Parser":11,"./RTCSession":12,"./Registrator":17,"./SIPMessage":19,"./Transactions":22,"./Transport":23,"./URI":25,"./Utils":26,"./sanityCheck":28,debug:29,events:31}],25:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n4&&void 0!==arguments[4]?arguments[4]:{},l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};if(r(this,e),!i)throw new TypeError('missing or invalid "host" parameter');this._parameters={},this._headers={},this._scheme=t||s.SIP,this._user=n,this._host=i,this._port=a;for(var u in o)Object.prototype.hasOwnProperty.call(o,u)&&this.setParam(u,o[u]);for(var c in l)Object.prototype.hasOwnProperty.call(l,c)&&this.setHeader(c,l[c])}return i(e,null,[{key:"parse",value:function(e){return-1!==(e=o.parse(e,"SIP_URI"))?e:void 0}}]),i(e,[{key:"setParam",value:function(e,t){e&&(this._parameters[e.toLowerCase()]=void 0===t||null===t?null:t.toString())}},{key:"getParam",value:function(e){if(e)return this._parameters[e.toLowerCase()]}},{key:"hasParam",value:function(e){if(e)return this._parameters.hasOwnProperty(e.toLowerCase())&&!0||!1}},{key:"deleteParam",value:function(e){if(e=e.toLowerCase(),this._parameters.hasOwnProperty(e)){var t=this._parameters[e];return delete this._parameters[e],t}}},{key:"clearParams",value:function(){this._parameters={}}},{key:"setHeader",value:function(e,t){this._headers[a.headerize(e)]=Array.isArray(t)?t:[t]}},{key:"getHeader",value:function(e){if(e)return this._headers[a.headerize(e)]}},{key:"hasHeader",value:function(e){if(e)return this._headers.hasOwnProperty(a.headerize(e))&&!0||!1}},{key:"deleteHeader",value:function(e){if(e=a.headerize(e),this._headers.hasOwnProperty(e)){var t=this._headers[e];return delete this._headers[e],t}}},{key:"clearHeaders",value:function(){this._headers={}}},{key:"clone",value:function(){return new e(this._scheme,this._user,this._host,this._port,JSON.parse(JSON.stringify(this._parameters)),JSON.parse(JSON.stringify(this._headers)))}},{key:"toString",value:function(){var e=[],t=this._scheme+":";this._user&&(t+=a.escapeUser(this._user)+"@"),t+=this._host,(this._port||0===this._port)&&(t+=":"+this._port);for(var n in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,n)&&(t+=";"+n,null!==this._parameters[n]&&(t+="="+this._parameters[n]));for(var r in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,r)){var i=!0,s=!1,o=void 0;try{for(var l,u=this._headers[r][Symbol.iterator]();!(i=(l=u.next()).done);i=!0){var c=l.value;e.push(r+"="+c)}}catch(e){s=!0,o=e}finally{try{!i&&u.return&&u.return()}finally{if(s)throw o}}}return e.length>0&&(t+="?"+e.join("&")),t}},{key:"toAor",value:function(e){var t=this._scheme+":";return this._user&&(t+=a.escapeUser(this._user)+"@"),t+=this._host,e&&(this._port||0===this._port)&&(t+=":"+this._port),t}},{key:"scheme",get:function(){return this._scheme},set:function(e){this._scheme=e.toLowerCase()}},{key:"user",get:function(){return this._user},set:function(e){this._user=e}},{key:"host",get:function(){return this._host},set:function(e){this._host=e.toLowerCase()}},{key:"port",get:function(){return this._port},set:function(e){this._port=0===e?e:parseInt(e,10)||null}}]),e}()},{"./Constants":2,"./Grammar":7,"./Utils":26}],26:[function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=e("./Constants"),s=e("./URI"),a=e("./Grammar");n.str_utf8_length=function(e){return unescape(encodeURIComponent(e)).length};var o=n.isFunction=function(e){return void 0!==e&&"[object Function]"===Object.prototype.toString.call(e)};n.isString=function(e){return void 0!==e&&"[object String]"===Object.prototype.toString.call(e)},n.isDecimal=function(e){return!isNaN(e)&&parseFloat(e)===parseInt(e,10)},n.isEmpty=function(e){return null===e||""===e||void 0===e||Array.isArray(e)&&0===e.length||"number"==typeof e&&isNaN(e)},n.hasMethods=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r1&&void 0!==arguments[1]?arguments[1]:32,n=void 0,r="";for(n=0;n>>32-t}function n(e,t){var n=2147483648&e,r=2147483648&t,i=1073741824&e,s=1073741824&t,a=(1073741823&e)+(1073741823&t);return i&s?2147483648^a^n^r:i|s?1073741824&a?3221225472^a^n^r:1073741824^a^n^r:a^n^r}function r(e,t,n){return e&t|~e&n}function i(e,t,n){return e&n|t&~n}function s(e,t,n){return e^t^n}function a(e,t,n){return t^(e|~n)}function o(e,i,s,a,o,l,u){return e=n(e,n(n(r(i,s,a),o),u)),n(t(e,l),i)}function l(e,r,s,a,o,l,u){return e=n(e,n(n(i(r,s,a),o),u)),n(t(e,l),r)}function u(e,r,i,a,o,l,u){return e=n(e,n(n(s(r,i,a),o),u)),n(t(e,l),r)}function c(e,r,i,s,o,l,u){return e=n(e,n(n(a(r,i,s),o),u)),n(t(e,l),r)}function d(e){var t="",n="",r=void 0;for(r=0;r<=3;r++)t+=(n="0"+(e>>>8*r&255).toString(16)).substr(n.length-2,2);return t}var h=[],f=void 0,p=void 0,_=void 0,m=void 0,v=void 0,g=void 0,y=void 0,T=void 0,C=void 0;for(h=function(e){for(var t=void 0,n=e.length,r=n+8,i=16*((r-r%64)/64+1),s=new Array(i-1),a=0,o=0;o>>29,s}(e=function(e){e=e.replace(/\r\n/g,"\n");for(var t="",n=0;n127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(63&r|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(63&r|128))}return t}(e)),g=1732584193,y=4023233417,T=2562383102,C=271733878,f=0;f1)return o("more than one Via header field present in the response, dropping the response"),!1},function(){if(a.str_utf8_length(d.body)=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},n.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),n.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],n.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},n.enable(i())}).call(this,e("_process"))},{"./debug":30,_process:33}],30:[function(e,t,n){function r(e){var t,r=0;for(t in e)r=(r<<5)-r+e.charCodeAt(t),r|=0;return n.colors[Math.abs(r)%n.colors.length]}function i(e){function t(){if(t.enabled){var e=t,r=+new Date,s=r-(i||r);e.diff=s,e.prev=i,e.curr=r,i=r;for(var a=new Array(arguments.length),o=0;o0&&this._events[e].length>n&&(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},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}if(!i(t))throw TypeError("listener must be a function");var r=!1;return n.listener=t,this.on(e,n),this},r.prototype.removeListener=function(e,t){var n,r,s,o;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],s=n.length,r=-1,n===t||i(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(a(n)){for(o=s;o-- >0;)if(n[o]===t||n[o].listener&&n[o].listener===t){r=o;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,n;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(n=this._events[e],i(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},{}],32:[function(e,t,n){function r(e){if(!((e=String(e)).length>100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*d;case"days":case"day":case"d":return n*c;case"hours":case"hour":case"hrs":case"hr":case"h":return n*u;case"minutes":case"minute":case"mins":case"min":case"m":return n*l;case"seconds":case"second":case"secs":case"sec":case"s":return n*o;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function i(e){return e>=c?Math.round(e/c)+"d":e>=u?Math.round(e/u)+"h":e>=l?Math.round(e/l)+"m":e>=o?Math.round(e/o)+"s":e+"ms"}function s(e){return a(e,c,"day")||a(e,u,"hour")||a(e,l,"minute")||a(e,o,"second")||e+" ms"}function a(e,t,n){if(!(e0)return r(e);if("number"===n&&!1===isNaN(e))return t.long?s(e):i(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],33:[function(e,t,n){function r(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function s(e){if(d===setTimeout)return setTimeout(e,0);if((d===r||!d)&&setTimeout)return d=setTimeout,setTimeout(e,0);try{return d(e,0)}catch(t){try{return d.call(null,e,0)}catch(t){return d.call(this,e,0)}}}function a(e){if(h===clearTimeout)return clearTimeout(e);if((h===i||!h)&&clearTimeout)return h=clearTimeout,clearTimeout(e);try{return h(e)}catch(t){try{return h.call(null,e)}catch(t){return h.call(this,e)}}}function o(){m&&p&&(m=!1,p.length?_=p.concat(_):v=-1,_.length&&l())}function l(){if(!m){var e=s(o);m=!0;for(var t=_.length;t;){for(p=_,_=[];++v1)for(var n=1;n=14393&&-1===e.indexOf("?transport=udp")}),delete e.url,e.urls=i?r[0]:r,!!r.length}return!1})}function s(e,t){var n={codecs:[],headerExtensions:[],fecMechanisms:[]},r=function(e,t){e=parseInt(e,10);for(var n=0;n0;o--)this._iceGatherers=new e.RTCIceGatherer({iceServers:n.iceServers,gatherPolicy:n.iceTransportPolicy});else n.iceCandidatePoolSize=0;this._config=n,this.transceivers=[],this._sdpSessionId=l.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0};return n.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this.dispatchEvent(e),"function"==typeof this.onicegatheringstatechange&&this.onicegatheringstatechange(e)},n.prototype.getConfiguration=function(){return this._config},n.prototype.getLocalStreams=function(){return this.localStreams},n.prototype.getRemoteStreams=function(){return this.remoteStreams},n.prototype._createTransceiver=function(e){var t=this.transceivers.length>0,n={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:e,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,wantReceive:!0};if(this.usingBundle&&t)n.iceTransport=this.transceivers[0].iceTransport,n.dtlsTransport=this.transceivers[0].dtlsTransport;else{var r=this._createIceAndDtlsTransports();n.iceTransport=r.iceTransport,n.dtlsTransport=r.dtlsTransport}return this.transceivers.push(n),n},n.prototype.addTrack=function(t,n){for(var r,i=0;i=15025)e.getTracks().forEach(function(t){n.addTrack(t,e)});else{var r=e.clone();e.getTracks().forEach(function(e,t){var n=r.getTracks()[t];e.addEventListener("enabled",function(e){n.enabled=e.enabled})}),r.getTracks().forEach(function(e){n.addTrack(e,r)})}},n.prototype.removeStream=function(e){var t=this.localStreams.indexOf(e);t>-1&&(this.localStreams.splice(t,1),this._maybeFireNegotiationNeeded())},n.prototype.getSenders=function(){return this.transceivers.filter(function(e){return!!e.rtpSender}).map(function(e){return e.rtpSender})},n.prototype.getReceivers=function(){return this.transceivers.filter(function(e){return!!e.rtpReceiver}).map(function(e){return e.rtpReceiver})},n.prototype._createIceGatherer=function(t,n){var r=this;if(n&&t>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var i=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(i,"state",{value:"new",writable:!0}),this.transceivers[t].candidates=[],this.transceivers[t].bufferCandidates=function(e){var n=!e.candidate||0===Object.keys(e.candidate).length;i.state=n?"completed":"gathering",null!==r.transceivers[t].candidates&&r.transceivers[t].candidates.push(e.candidate)},i.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),i},n.prototype._gather=function(t,n){var r=this,i=this.transceivers[n].iceGatherer;if(!i.onlocalcandidate){var s=this.transceivers[n].candidates;this.transceivers[n].candidates=null,i.removeEventListener("localcandidate",this.transceivers[n].bufferCandidates),i.onlocalcandidate=function(e){if(!(r.usingBundle&&n>0)){var s=new Event("icecandidate");s.candidate={sdpMid:t,sdpMLineIndex:n};var a=e.candidate,o=!a||0===Object.keys(a).length;o?"new"!==i.state&&"gathering"!==i.state||(i.state="completed"):("new"===i.state&&(i.state="gathering"),a.component=1,s.candidate.candidate=l.writeCandidate(a));var u=l.splitSections(r.localDescription.sdp);u[s.candidate.sdpMLineIndex+1]+=o?"a=end-of-candidates\r\n":"a="+s.candidate.candidate+"\r\n",r.localDescription.sdp=u.join("");var c=r.transceivers.every(function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state});"gathering"!==r.iceGatheringState&&(r.iceGatheringState="gathering",r._emitGatheringStateChange()),o||(r.dispatchEvent(s),"function"==typeof r.onicecandidate&&r.onicecandidate(s)),c&&(r.dispatchEvent(new Event("icecandidate")),"function"==typeof r.onicecandidate&&r.onicecandidate(new Event("icecandidate")),r.iceGatheringState="complete",r._emitGatheringStateChange())}},e.setTimeout(function(){s.forEach(function(e){var t=new Event("RTCIceGatherEvent");t.candidate=e,i.onlocalcandidate(t)})},0)}},n.prototype._createIceAndDtlsTransports=function(){var t=this,n=new e.RTCIceTransport(null);n.onicestatechange=function(){t._updateConnectionState()};var r=new e.RTCDtlsTransport(n);return r.ondtlsstatechange=function(){t._updateConnectionState()},r.onerror=function(){Object.defineProperty(r,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:n,dtlsTransport:r}},n.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var n=this.transceivers[e].iceTransport;n&&(delete n.onicestatechange,delete this.transceivers[e].iceTransport);var r=this.transceivers[e].dtlsTransport;r&&(delete r.ondtlsstatechange,delete r.onerror,delete this.transceivers[e].dtlsTransport)},n.prototype._transceive=function(e,n,r){var i=s(e.localCapabilities,e.remoteCapabilities);n&&e.rtpSender&&(i.encodings=e.sendEncodingParameters,i.rtcp={cname:l.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(i.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(i)),r&&e.rtpReceiver&&i.codecs.length>0&&("video"===e.kind&&e.recvEncodingParameters&&t<15019&&e.recvEncodingParameters.forEach(function(e){delete e.rtx}),i.encodings=e.recvEncodingParameters,i.rtcp={cname:e.rtcpParameters.cname,compound:e.rtcpParameters.compound},e.sendEncodingParameters.length&&(i.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(i))},n.prototype.setLocalDescription=function(e){var t=this,n=arguments;if(!a("setLocalDescription",e.type,this.signalingState))return new Promise(function(r,i){var s=new Error("Can not set local "+e.type+" in state "+t.signalingState);s.name="InvalidStateError",n.length>2&&"function"==typeof n[2]&&n[2].apply(null,[s]),i(s)});var r,i;if("offer"===e.type)r=l.splitSections(e.sdp),i=r.shift(),r.forEach(function(e,n){var r=l.parseRtpParameters(e);t.transceivers[n].localCapabilities=r}),this.transceivers.forEach(function(e,n){t._gather(e.mid,n)});else if("answer"===e.type){r=l.splitSections(t.remoteDescription.sdp),i=r.shift();var o=l.matchPrefix(i,"a=ice-lite").length>0;r.forEach(function(e,n){var r=t.transceivers[n],a=r.iceGatherer,u=r.iceTransport,c=r.dtlsTransport,d=r.localCapabilities,h=r.remoteCapabilities;if(!(l.isRejected(e)&&1===!l.matchPrefix(e,"a=bundle-only").length)&&!r.isDatachannel){var f=l.getIceParameters(e,i),p=l.getDtlsParameters(e,i);o&&(p.role="server"),t.usingBundle&&0!==n||(t._gather(r.mid,n),"new"===u.state&&u.start(a,f,o?"controlling":"controlled"),"new"===c.state&&c.start(p));var _=s(d,h);t._transceive(r,_.codecs.length>0,!1)}})}switch(this.localDescription={type:e.type,sdp:e.sdp},e.type){case"offer":this._updateSignalingState("have-local-offer");break;case"answer":this._updateSignalingState("stable");break;default:throw new TypeError('unsupported type "'+e.type+'"')}var u=arguments.length>1&&"function"==typeof arguments[1]&&arguments[1];return new Promise(function(e){u&&u.apply(null),e()})},n.prototype.setRemoteDescription=function(n){var r=this,i=arguments;if(!a("setRemoteDescription",n.type,this.signalingState))return new Promise(function(e,t){var s=new Error("Can not set remote "+n.type+" in state "+r.signalingState);s.name="InvalidStateError",i.length>2&&"function"==typeof i[2]&&i[2].apply(null,[s]),t(s)});var s={};this.remoteStreams.forEach(function(e){s[e.id]=e});var u=[],c=l.splitSections(n.sdp),d=c.shift(),h=l.matchPrefix(d,"a=ice-lite").length>0,f=l.matchPrefix(d,"a=group:BUNDLE ").length>0;this.usingBundle=f;var p=l.matchPrefix(d,"a=ice-options:")[0];switch(this.canTrickleIceCandidates=!!p&&p.substr(14).split(" ").indexOf("trickle")>=0,c.forEach(function(i,a){var c=l.splitLines(i),p=l.getKind(i),_=l.isRejected(i)&&1===!l.matchPrefix(i,"a=bundle-only").length,m=c[0].substr(2).split(" ")[2],v=l.getDirection(i,d),g=l.parseMsid(i),y=l.getMid(i)||l.generateIdentifier();if("application"!==p||"DTLS/SCTP"!==m){var T,C,S,E,b,R,A,w,I,k,O,P=l.parseRtpParameters(i);_||(k=l.getIceParameters(i,d),(O=l.getDtlsParameters(i,d)).role="client"),A=l.parseRtpEncodingParameters(i);var x=l.parseRtcpParameters(i),N=l.matchPrefix(i,"a=end-of-candidates",d).length>0,D=l.matchPrefix(i,"a=candidate:").map(function(e){return l.parseCandidate(e)}).filter(function(e){return 1===e.component});if(("offer"===n.type||"answer"===n.type)&&!_&&f&&a>0&&r.transceivers[a]&&(r._disposeIceAndDtlsTransports(a),r.transceivers[a].iceGatherer=r.transceivers[0].iceGatherer,r.transceivers[a].iceTransport=r.transceivers[0].iceTransport,r.transceivers[a].dtlsTransport=r.transceivers[0].dtlsTransport,r.transceivers[a].rtpSender&&r.transceivers[a].rtpSender.setTransport(r.transceivers[0].dtlsTransport),r.transceivers[a].rtpReceiver&&r.transceivers[a].rtpReceiver.setTransport(r.transceivers[0].dtlsTransport)),"offer"!==n.type||_)"answer"!==n.type||_||(C=(T=r.transceivers[a]).iceGatherer,S=T.iceTransport,E=T.dtlsTransport,b=T.rtpReceiver,R=T.sendEncodingParameters,w=T.localCapabilities,r.transceivers[a].recvEncodingParameters=A,r.transceivers[a].remoteCapabilities=P,r.transceivers[a].rtcpParameters=x,D.length&&"new"===S.state&&(!h&&!N||f&&0!==a?D.forEach(function(e){o(T.iceTransport,e)}):S.setRemoteCandidates(D)),f&&0!==a||("new"===S.state&&S.start(C,k,"controlling"),"new"===E.state&&E.start(O)),r._transceive(T,"sendrecv"===v||"recvonly"===v,"sendrecv"===v||"sendonly"===v),!b||"sendrecv"!==v&&"sendonly"!==v?delete T.rtpReceiver:(I=b.track,g?(s[g.stream]||(s[g.stream]=new e.MediaStream),s[g.stream].addTrack(I),u.push([I,b,s[g.stream]])):(s.default||(s.default=new e.MediaStream),s.default.addTrack(I),u.push([I,b,s.default]))));else{(T=r.transceivers[a]||r._createTransceiver(p)).mid=y,T.iceGatherer||(T.iceGatherer=r._createIceGatherer(a,f)),D.length&&"new"===T.iceTransport.state&&(!N||f&&0!==a?D.forEach(function(e){o(T.iceTransport,e)}):T.iceTransport.setRemoteCandidates(D)),w=e.RTCRtpReceiver.getCapabilities(p),t<15019&&(w.codecs=w.codecs.filter(function(e){return"rtx"!==e.name})),R=T.sendEncodingParameters||[{ssrc:1001*(2*a+2)}];var U=!1;if(("sendrecv"===v||"sendonly"===v)&&(U=!T.rtpReceiver,b=T.rtpReceiver||new e.RTCRtpReceiver(T.dtlsTransport,p),U)){var M;I=b.track,g?(s[g.stream]||(s[g.stream]=new e.MediaStream,Object.defineProperty(s[g.stream],"id",{get:function(){return g.stream}})),Object.defineProperty(I,"id",{get:function(){return g.track}}),M=s[g.stream]):(s.default||(s.default=new e.MediaStream),M=s.default),M.addTrack(I),u.push([I,b,M])}T.localCapabilities=w,T.remoteCapabilities=P,T.rtpReceiver=b,T.rtcpParameters=x,T.sendEncodingParameters=R,T.recvEncodingParameters=A,r._transceive(r.transceivers[a],!1,U)}}else r.transceivers[a]={mid:y,isDatachannel:!0}}),void 0===this._dtlsRole&&(this._dtlsRole="offer"===n.type?"active":"passive"),this.remoteDescription={type:n.type,sdp:n.sdp},n.type){case"offer":this._updateSignalingState("have-remote-offer");break;case"answer":this._updateSignalingState("stable");break;default:throw new TypeError('unsupported type "'+n.type+'"')}return Object.keys(s).forEach(function(t){var n=s[t];if(n.getTracks().length){if(-1===r.remoteStreams.indexOf(n)){r.remoteStreams.push(n);var i=new Event("addstream");i.stream=n,e.setTimeout(function(){r.dispatchEvent(i),"function"==typeof r.onaddstream&&r.onaddstream(i)})}u.forEach(function(t){var i=t[0],s=t[1];if(n.id===t[2].id){var a=new Event("track");a.track=i,a.receiver=s,a.transceiver={receiver:s},a.streams=[n],e.setTimeout(function(){r.dispatchEvent(a),"function"==typeof r.ontrack&&r.ontrack(a)})}})}}),e.setTimeout(function(){r&&r.transceivers&&r.transceivers.forEach(function(e){e.iceTransport&&"new"===e.iceTransport.state&&e.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),e.iceTransport.addRemoteCandidate({}))})},4e3),new Promise(function(e){i.length>1&&"function"==typeof i[1]&&i[1].apply(null),e()})},n.prototype.close=function(){this.transceivers.forEach(function(e){e.iceTransport&&e.iceTransport.stop(),e.dtlsTransport&&e.dtlsTransport.stop(),e.rtpSender&&e.rtpSender.stop(),e.rtpReceiver&&e.rtpReceiver.stop()}),this._updateSignalingState("closed")},n.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this.dispatchEvent(t),"function"==typeof this.onsignalingstatechange&&this.onsignalingstatechange(t)},n.prototype._maybeFireNegotiationNeeded=function(){var t=this;"stable"===this.signalingState&&!0!==this.needNegotiation&&(this.needNegotiation=!0,e.setTimeout(function(){if(!1!==t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t.dispatchEvent(e),"function"==typeof t.onnegotiationneeded&&t.onnegotiationneeded(e)}},0))},n.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(e){t[e.iceTransport.state]++,t[e.dtlsTransport.state]++}),t.connected+=t.completed,e="new",t.failed>0?e="failed":t.connecting>0||t.checking>0?e="connecting":t.disconnected>0?e="disconnected":t.new>0?e="new":(t.connected>0||t.completed>0)&&(e="connected"),e!==this.iceConnectionState){this.iceConnectionState=e;var n=new Event("iceconnectionstatechange");this.dispatchEvent(n),"function"==typeof this.oniceconnectionstatechange&&this.oniceconnectionstatechange(n)}},n.prototype.createOffer=function(){var n,i=this,s=arguments;1===arguments.length&&"function"!=typeof arguments[0]?n=arguments[0]:3===arguments.length&&(n=arguments[2]);var a=this.transceivers.filter(function(e){return"audio"===e.kind}).length,o=this.transceivers.filter(function(e){return"video"===e.kind}).length;if(n){if(n.mandatory||n.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==n.offerToReceiveAudio&&(a=!0===n.offerToReceiveAudio?1:!1===n.offerToReceiveAudio?0:n.offerToReceiveAudio),void 0!==n.offerToReceiveVideo&&(o=!0===n.offerToReceiveVideo?1:!1===n.offerToReceiveVideo?0:n.offerToReceiveVideo)}for(this.transceivers.forEach(function(e){"audio"===e.kind?--a<0&&(e.wantReceive=!1):"video"===e.kind&&--o<0&&(e.wantReceive=!1)});a>0||o>0;)a>0&&(this._createTransceiver("audio"),a--),o>0&&(this._createTransceiver("video"),o--);var u=l.writeSessionBoilerplate(this._sdpSessionId,this._sdpSessionVersion++);this.transceivers.forEach(function(n,r){var s=n.track,a=n.kind,o=l.generateIdentifier();n.mid=o,n.iceGatherer||(n.iceGatherer=i._createIceGatherer(r,i.usingBundle));var u=e.RTCRtpSender.getCapabilities(a);t<15019&&(u.codecs=u.codecs.filter(function(e){return"rtx"!==e.name})),u.codecs.forEach(function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1")});var c=n.sendEncodingParameters||[{ssrc:1001*(2*r+1)}];s&&t>=15019&&"video"===a&&!c[0].rtx&&(c[0].rtx={ssrc:c[0].ssrc+1}),n.wantReceive&&(n.rtpReceiver=new e.RTCRtpReceiver(n.dtlsTransport,a)),n.localCapabilities=u,n.sendEncodingParameters=c}),"max-compat"!==this._config.bundlePolicy&&(u+="a=group:BUNDLE "+this.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"),u+="a=ice-options:trickle\r\n",this.transceivers.forEach(function(e,t){u+=r(e,e.localCapabilities,"offer",e.stream,i._dtlsRole),u+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===i.iceGatheringState||0!==t&&i.usingBundle||(e.iceGatherer.getLocalCandidates().forEach(function(e){e.component=1,u+="a="+l.writeCandidate(e)+"\r\n"}),"completed"===e.iceGatherer.state&&(u+="a=end-of-candidates\r\n"))});var c=new e.RTCSessionDescription({type:"offer",sdp:u});return new Promise(function(e){if(s.length>0&&"function"==typeof s[0])return s[0].apply(null,[c]),void e();e(c)})},n.prototype.createAnswer=function(){var n=this,i=arguments,a=l.writeSessionBoilerplate(this._sdpSessionId,this._sdpSessionVersion++);this.usingBundle&&(a+="a=group:BUNDLE "+this.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n");var o=l.splitSections(this.remoteDescription.sdp).length-1;this.transceivers.forEach(function(e,i){if(!(i+1>o))if(e.isDatachannel)a+="m=application 0 DTLS/SCTP 5000\r\nc=IN IP4 0.0.0.0\r\na=mid:"+e.mid+"\r\n";else{if(e.stream){var l;"audio"===e.kind?l=e.stream.getAudioTracks()[0]:"video"===e.kind&&(l=e.stream.getVideoTracks()[0]),l&&t>=15019&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1})}var u=s(e.localCapabilities,e.remoteCapabilities);!u.codecs.filter(function(e){return"rtx"===e.name.toLowerCase()}).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,a+=r(e,u,"answer",e.stream,n._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(a+="a=rtcp-rsize\r\n")}});var u=new e.RTCSessionDescription({type:"answer",sdp:a});return new Promise(function(e){if(i.length>0&&"function"==typeof i[0])return i[0].apply(null,[u]),void e();e(u)})},n.prototype.addIceCandidate=function(e){var t,n;if(e&&""!==e.candidate){if(void 0===e.sdpMLineIndex&&!e.sdpMid)throw new TypeError("sdpMLineIndex or sdpMid required");if(this.remoteDescription){var r=e.sdpMLineIndex;if(e.sdpMid)for(var i=0;i0?l.parseCandidate(e.candidate):{};if("tcp"===a.protocol&&(0===a.port||9===a.port))return Promise.resolve();if(a.component&&1!==a.component)return Promise.resolve();if((0===r||r>0&&s.iceTransport!==this.transceivers[0].iceTransport)&&(o(s.iceTransport,a)||((t=new Error("Can not add ICE candidate")).name="OperationError")),!t){var u=e.candidate.trim();0===u.indexOf("a=")&&(u=u.substr(2)),(n=l.splitSections(this.remoteDescription.sdp))[r+1]+="a="+(a.type?u:"end-of-candidates")+"\r\n",this.remoteDescription.sdp=n.join("")}}else(t=new Error("Can not add ICE candidate")).name="OperationError"}else(t=new Error("Can not add ICE candidate without a remote description")).name="InvalidStateError"}else for(var c=0;c2&&"function"==typeof d[2]&&d[2].apply(null,[t]),n(t)):(d.length>1&&"function"==typeof d[1]&&d[1].apply(null),e())})},n.prototype.getStats=function(){var e=[];this.transceivers.forEach(function(t){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(n){t[n]&&e.push(t[n].getStats())})});var t=arguments.length>1&&"function"==typeof arguments[1]&&arguments[1],n=function(e){return{inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};return new Promise(function(r){var i=new Map;Promise.all(e).then(function(e){e.forEach(function(e){Object.keys(e).forEach(function(t){e[t].type=n(e[t]),i.set(t,e[t])})}),t&&t.apply(null,i),r(i)})})},n}},{sdp:39}],35:[function(e,t,n){var r=t.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w\/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-\.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%d trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))? (\S*)(?: (\S*))?/,names:["value","direction","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+" %s"+(e.config?" %s":"")}},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_\/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{push:"invalid",names:["value"]}]};Object.keys(r).forEach(function(e){r[e].forEach(function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")})})},{}],36:[function(e,t,n){var r=e("./parser"),i=e("./writer");n.write=i,n.parse=r.parse,n.parseFmtpConfig=r.parseFmtpConfig,n.parseParams=r.parseParams,n.parsePayloads=r.parsePayloads,n.parseRemoteCandidates=r.parseRemoteCandidates,n.parseImageAttributes=r.parseImageAttributes,n.parseSimulcastStreamList=r.parseSimulcastStreamList},{"./parser":37,"./writer":38}],37:[function(e,t,n){var r=function(e){return String(Number(e))===e?Number(e):e},i=function(e,t,n,i){if(i&&!n)t[i]=r(e[1]);else for(var s=0;s=r)return e;var i=n[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}})},a=function(e,t,n){var r=[e+"="+(t.format instanceof Function?t.format(t.push?n:n[t.name]):t.format)];if(t.names)for(var i=0;i0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},r.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},r.parseFmtp=function(e){for(var t,n={},r=e.substr(e.indexOf(" ")+1).split(";"),i=0;i-1?(n.attribute=e.substr(t+1,r-t-1),n.value=e.substr(r+1)):n.attribute=e.substr(t+1),n},r.getMid=function(e){var t=r.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},r.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},r.getDtlsParameters=function(e,t){return{role:"auto",fingerprints:r.matchPrefix(e+t,"a=fingerprint:").map(r.parseFingerprint)}},r.writeDtlsParameters=function(e,t){var n="a=setup:"+t+"\r\n";return e.fingerprints.forEach(function(e){n+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"}),n},r.getIceParameters=function(e,t){var n=r.splitLines(e);return{usernameFragment:(n=n.concat(r.splitLines(t))).filter(function(e){return 0===e.indexOf("a=ice-ufrag:")})[0].substr(12),password:n.filter(function(e){return 0===e.indexOf("a=ice-pwd:")})[0].substr(10)}},r.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},r.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},n=r.splitLines(e)[0].split(" "),i=3;i0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=t.codecs.map(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType}).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach(function(e){n+=r.writeRtpMap(e),n+=r.writeFmtp(e),n+=r.writeRtcpFb(e)});var i=0;return t.codecs.forEach(function(e){e.maxptime>i&&(i=e.maxptime)}),i>0&&(n+="a=maxptime:"+i+"\r\n"),n+="a=rtcp-mux\r\n",t.headerExtensions.forEach(function(e){n+=r.writeExtmap(e)}),n},r.parseRtpEncodingParameters=function(e){var t,n=[],i=r.parseRtpParameters(e),s=-1!==i.fecMechanisms.indexOf("RED"),a=-1!==i.fecMechanisms.indexOf("ULPFEC"),o=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute}),l=o.length>0&&o[0].ssrc,u=r.matchPrefix(e,"a=ssrc-group:FID").map(function(e){var t=e.split(" ");return t.shift(),t.map(function(e){return parseInt(e,10)})});u.length>0&&u[0].length>1&&u[0][0]===l&&(t=u[0][1]),i.codecs.forEach(function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var r={ssrc:l,codecPayloadType:parseInt(e.parameters.apt,10),rtx:{ssrc:t}};n.push(r),s&&((r=JSON.parse(JSON.stringify(r))).fec={ssrc:t,mechanism:a?"red+ulpfec":"red"},n.push(r))}}),0===n.length&&l&&n.push({ssrc:l});var c=r.matchPrefix(e,"b=");return c.length&&(c=0===c[0].indexOf("b=TIAS:")?parseInt(c[0].substr(7),10):0===c[0].indexOf("b=AS:")?1e3*parseInt(c[0].substr(5),10)*.95-16e3:void 0,n.forEach(function(e){e.maxBitrate=c})),n},r.parseRtcpParameters=function(e){var t={},n=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute})[0];n&&(t.cname=n.value,t.ssrc=n.ssrc);var i=r.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=i.length>0,t.compound=0===i.length;var s=r.matchPrefix(e,"a=rtcp-mux");return t.mux=s.length>0,t},r.parseMsid=function(e){var t,n=r.matchPrefix(e,"a=msid:");if(1===n.length)return t=n[0].substr(7).split(" "),{stream:t[0],track:t[1]};var i=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"msid"===e.attribute});return i.length>0?(t=i[0].value.split(" "),{stream:t[0],track:t[1]}):void 0},r.generateSessionId=function(){return Math.random().toString().substr(2,21)},r.writeSessionBoilerplate=function(e,t){var n=void 0!==t?t:2;return"v=0\r\no=thisisadapterortc "+(e||r.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},r.writeMediaSection=function(e,t,n,i){var s=r.writeRtpDescription(e.kind,t);if(s+=r.writeIceParameters(e.iceGatherer.getLocalParameters()),s+=r.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===n?"actpass":"active"),s+="a=mid:"+e.mid+"\r\n",e.direction?s+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?s+="a=sendrecv\r\n":e.rtpSender?s+="a=sendonly\r\n":e.rtpReceiver?s+="a=recvonly\r\n":s+="a=inactive\r\n",e.rtpSender){var a="msid:"+i.id+" "+e.rtpSender.track.id+"\r\n";s+="a="+a,s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+a,e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+a,s+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+r.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+r.localCName+"\r\n"),s},r.getDirection=function(e,t){for(var n=r.splitLines(e),i=0;i=63)){var s=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=s.apply(this);return e._reverseStreams=e._reverseStreams||{},t.map(function(t){return e._reverseStreams[t.id]})};var a=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var n=this;if(n._streams=n._streams||{},n._reverseStreams=n._reverseStreams||{},t.getTracks().forEach(function(e){if(n.getSenders().find(function(t){return t.track===e}))throw new DOMException("Track already exists.","InvalidAccessError")}),!n._reverseStreams[t.id]){var r=new e.MediaStream(t.getTracks());n._streams[t.id]=r,n._reverseStreams[r.id]=t,t=r}a.apply(n,[t])};var o=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;t._streams=t._streams||{},t._reverseStreams=t._reverseStreams||{},o.apply(t,[t._streams[e.id]||e]),delete t._reverseStreams[t._streams[e.id]?t._streams[e.id].id:e.id],delete t._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,n){var r=this;if("closed"===r.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var i=[].slice.call(arguments,1);if(1!==i.length||!i[0].getTracks().find(function(e){return e===t}))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(r.getSenders().find(function(e){return e.track===t}))throw new DOMException("Track already exists.","InvalidAccessError");r._streams=r._streams||{},r._reverseStreams=r._reverseStreams||{};var s=r._streams[n.id];if(s)s.addTrack(t),Promise.resolve().then(function(){r.dispatchEvent(new Event("negotiationneeded"))});else{var a=new e.MediaStream([t]);r._streams[n.id]=a,r._reverseStreams[a.id]=n,r.addStream(a)}return r.getSenders().find(function(e){return e.track===t})},["createOffer","createAnswer"].forEach(function(n){var r=e.RTCPeerConnection.prototype[n];e.RTCPeerConnection.prototype[n]=function(){var e=this,n=arguments;return arguments.length&&"function"==typeof arguments[0]?r.apply(e,[function(r){var i=t(e,r);n[0].apply(null,[i])},function(e){n[1]&&n[1].apply(null,e)},arguments[2]]):r.apply(e,arguments).then(function(n){return t(e,n)})}});var l=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){var e=this;return arguments.length&&arguments[0].type?(arguments[0]=n(e,arguments[0]),l.apply(e,arguments)):l.apply(e,arguments)};var u=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=this,n=u.get.apply(this);return""===n.type?n:t(e,n)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;if("closed"===t.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(e._pc===t))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");t._streams=t._streams||{};var n;Object.keys(t._streams).forEach(function(r){t._streams[r].getTracks().find(function(t){return e.track===t})&&(n=t._streams[r])}),n&&(1===n.getTracks().length?t.removeStream(t._reverseStreams[n.id]):n.removeTrack(e.track),t.dispatchEvent(new Event("negotiationneeded")))}}},shimPeerConnection:function(e){var t=r.detectBrowser(e);if(e.RTCPeerConnection){var n=e.RTCPeerConnection;e.RTCPeerConnection=function(e,t){if(e&&e.iceServers){for(var i=[],s=0;s0&&"function"==typeof e)return s.apply(this,arguments);if(0===s.length&&(0===arguments.length||"function"!=typeof arguments[0]))return s.apply(this,[]);var a=function(e){var t={};return e.result().forEach(function(e){var n={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach(function(t){n[t]=e.stat(t)}),t[n.id]=n}),t},o=function(e){return new Map(Object.keys(e).map(function(t){return[t,e[t]]}))};if(arguments.length>=2){return s.apply(this,[function(e){i[1](o(a(e)))},arguments[0]])}return new Promise(function(e,t){s.apply(r,[function(t){e(o(a(t)))},t])}).then(t,n)},t.version<51&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){var e=arguments,t=this,r=new Promise(function(r,i){n.apply(t,[e[0],r,i])});return e.length<2?r:r.then(function(){e[1].apply(null,[])},function(t){e.length>=3&&e[2].apply(null,[t])})}}),t.version<52&&["createOffer","createAnswer"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){var e=this;if(arguments.length<1||1===arguments.length&&"object"==typeof arguments[0]){var t=1===arguments.length?arguments[0]:void 0;return new Promise(function(r,i){n.apply(e,[r,i,t])})}return n.apply(this,arguments)}}),["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}});var a=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?a.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}}};t.exports={shimMediaStream:s.shimMediaStream,shimOnTrack:s.shimOnTrack,shimAddTrackRemoveTrack:s.shimAddTrackRemoveTrack,shimGetSendersWithDtmf:s.shimGetSendersWithDtmf,shimSourceObject:s.shimSourceObject,shimPeerConnection:s.shimPeerConnection,shimGetUserMedia:e("./getusermedia")}},{"../utils.js":50,"./getusermedia":43}],43:[function(e,t,n){"use strict";var r=e("../utils.js"),i=r.log;t.exports=function(e){var t=r.detectBrowser(e),n=e&&e.navigator,s=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;var t={};return Object.keys(e).forEach(function(n){if("require"!==n&&"advanced"!==n&&"mediaSource"!==n){var r="object"==typeof e[n]?e[n]:{ideal:e[n]};void 0!==r.exact&&"number"==typeof r.exact&&(r.min=r.max=r.exact);var i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==r.ideal){t.optional=t.optional||[];var s={};"number"==typeof r.ideal?(s[i("min",n)]=r.ideal,t.optional.push(s),(s={})[i("max",n)]=r.ideal,t.optional.push(s)):(s[i("",n)]=r.ideal,t.optional.push(s))}void 0!==r.exact&&"number"!=typeof r.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",n)]=r.exact):["min","max"].forEach(function(e){void 0!==r[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,n)]=r[e])})}}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},a=function(e,r){if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){var a=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])};a((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),a(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=s(e.audio)}if(e&&"object"==typeof e.video){var o=e.video.facingMode;o=o&&("object"==typeof o?o:{ideal:o});var l=t.version<66;if(o&&("user"===o.exact||"environment"===o.exact||"user"===o.ideal||"environment"===o.ideal)&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||l)){delete e.video.facingMode;var u;if("environment"===o.exact||"environment"===o.ideal?u=["back","rear"]:"user"!==o.exact&&"user"!==o.ideal||(u=["front"]),u)return n.mediaDevices.enumerateDevices().then(function(t){var n=(t=t.filter(function(e){return"videoinput"===e.kind})).find(function(e){return u.some(function(t){return-1!==e.label.toLowerCase().indexOf(t)})});return!n&&t.length&&-1!==u.indexOf("back")&&(n=t[t.length-1]),n&&(e.video.deviceId=o.exact?{exact:n.deviceId}:{ideal:n.deviceId}),e.video=s(e.video),i("chrome: "+JSON.stringify(e)),r(e)})}e.video=s(e.video)}return i("chrome: "+JSON.stringify(e)),r(e)},o=function(e){return{name:{PermissionDeniedError:"NotAllowedError",InvalidStateError:"NotReadableError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotReadableError",MediaDeviceKillSwitchOn:"NotReadableError"}[e.name]||e.name,message:e.message,constraint:e.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}};n.getUserMedia=function(e,t,r){a(e,function(e){n.webkitGetUserMedia(e,t,function(e){r&&r(o(e))})})};var l=function(e){return new Promise(function(t,r){n.getUserMedia(e,t,r)})};if(n.mediaDevices||(n.mediaDevices={getUserMedia:l,enumerateDevices:function(){return new Promise(function(t){var n={audio:"audioinput",video:"videoinput"};return e.MediaStreamTrack.getSources(function(e){t(e.map(function(e){return{label:e.label,kind:n[e.kind],deviceId:e.id,groupId:""}}))})})},getSupportedConstraints:function(){return{deviceId:!0,echoCancellation:!0,facingMode:!0,frameRate:!0,height:!0,width:!0}}}),n.mediaDevices.getUserMedia){var u=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(e){return a(e,function(e){return u(e).then(function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach(function(e){e.stop()}),new DOMException("","NotFoundError");return t},function(e){return Promise.reject(o(e))})})}}else n.mediaDevices.getUserMedia=function(e){return l(e)};void 0===n.mediaDevices.addEventListener&&(n.mediaDevices.addEventListener=function(){i("Dummy mediaDevices.addEventListener called.")}),void 0===n.mediaDevices.removeEventListener&&(n.mediaDevices.removeEventListener=function(){i("Dummy mediaDevices.removeEventListener called.")})}},{"../utils.js":50}],44:[function(e,t,n){"use strict";function r(e,t,n){if(e.RTCPeerConnection){var r=e.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(e,r){if(e!==t)return i.apply(this,arguments);var s=function(e){r(n(e))};return this._eventMap=this._eventMap||{},this._eventMap[r]=s,i.apply(this,[e,s])};var s=r.removeEventListener;r.removeEventListener=function(e,n){if(e!==t||!this._eventMap||!this._eventMap[n])return s.apply(this,arguments);var r=this._eventMap[n];return delete this._eventMap[n],s.apply(this,[e,r])},Object.defineProperty(r,"on"+t,{get:function(){return this["_on"+t]},set:function(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)}})}}var i=e("sdp"),s=e("./utils");t.exports={shimRTCIceCandidate:function(e){if(!(e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){"object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2));var n=new t(e),r=i.parseCandidate(e.candidate),s=Object.assign(n,r);return s.toJSON=function(){return{candidate:s.candidate,sdpMid:s.sdpMid,sdpMLineIndex:s.sdpMLineIndex,usernameFragment:s.usernameFragment}},s},r(e,"icecandidate",function(t){return t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t})}},shimCreateObjectURL:function(e){var t=e&&e.URL;if("object"==typeof e&&e.HTMLMediaElement&&"srcObject"in e.HTMLMediaElement.prototype&&t.createObjectURL&&t.revokeObjectURL){var n=t.createObjectURL.bind(t),r=t.revokeObjectURL.bind(t),i=new Map,a=0;t.createObjectURL=function(e){if("getTracks"in e){var t="polyblob:"+ ++a;return i.set(t,e),s.deprecated("URL.createObjectURL(stream)","elem.srcObject = stream"),t}return n(e)},t.revokeObjectURL=function(e){r(e),i.delete(e)};var o=Object.getOwnPropertyDescriptor(e.HTMLMediaElement.prototype,"src");Object.defineProperty(e.HTMLMediaElement.prototype,"src",{get:function(){return o.get.apply(this)},set:function(e){return this.srcObject=i.get(e)||null,o.set.apply(this,[e])}});var l=e.HTMLMediaElement.prototype.setAttribute;e.HTMLMediaElement.prototype.setAttribute=function(){return 2===arguments.length&&"src"===(""+arguments[0]).toLowerCase()&&(this.srcObject=i.get(arguments[1])||null),l.apply(this,arguments)}}}}},{"./utils":50,sdp:39}],45:[function(e,t,n){"use strict";var r=e("../utils"),i=e("rtcpeerconnection-shim");t.exports={shimGetUserMedia:e("./getusermedia"),shimPeerConnection:function(e){var t=r.detectBrowser(e);if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(e){return e}),e.RTCSessionDescription||(e.RTCSessionDescription=function(e){return e}),t.version<15025)){var n=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set:function(e){n.set.call(this,e);var t=new Event("enabled");t.enabled=e,this.dispatchEvent(t)}})}!e.RTCRtpSender||"dtmf"in e.RTCRtpSender.prototype||Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=new e.RTCDtmfSender(this):"video"===this.track.kind&&(this._dtmf=null)),this._dtmf}}),e.RTCPeerConnection=i(e,t.version)},shimReplaceTrack:function(e){!e.RTCRtpSender||"replaceTrack"in e.RTCRtpSender.prototype||(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}}},{"../utils":50,"./getusermedia":46,"rtcpeerconnection-shim":34}],46:[function(e,t,n){"use strict";t.exports=function(e){var t=e&&e.navigator,n=function(e){return{name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString:function(){return this.name}}},r=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return r(e).catch(function(e){return Promise.reject(n(e))})}}},{}],47:[function(e,t,n){"use strict";var r=e("../utils"),i={shimOnTrack:function(e){"object"!=typeof e||!e.RTCPeerConnection||"ontrack"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&(this.removeEventListener("track",this._ontrack),this.removeEventListener("addstream",this._ontrackpoly)),this.addEventListener("track",this._ontrack=e),this.addEventListener("addstream",this._ontrackpoly=function(e){e.stream.getTracks().forEach(function(t){var n=new Event("track");n.track=t,n.receiver={track:t},n.transceiver={receiver:n.receiver},n.streams=[e.stream],this.dispatchEvent(n)}.bind(this))}.bind(this))}}),"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})},shimSourceObject:function(e){"object"==typeof e&&(!e.HTMLMediaElement||"srcObject"in e.HTMLMediaElement.prototype||Object.defineProperty(e.HTMLMediaElement.prototype,"srcObject",{get:function(){return this.mozSrcObject},set:function(e){this.mozSrcObject=e}}))},shimPeerConnection:function(e){var t=r.detectBrowser(e);if("object"==typeof e&&(e.RTCPeerConnection||e.mozRTCPeerConnection)){e.RTCPeerConnection||(e.RTCPeerConnection=function(n,r){if(t.version<38&&n&&n.iceServers){for(var i=[],s=0;s55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){var c=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])},d=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(e){return"object"==typeof e&&"object"==typeof e.audio&&(e=JSON.parse(JSON.stringify(e)),c(e.audio,"autoGainControl","mozAutoGainControl"),c(e.audio,"noiseSuppression","mozNoiseSuppression")),d(e)},s&&s.prototype.getSettings){var h=s.prototype.getSettings;s.prototype.getSettings=function(){var e=h.apply(this,arguments);return c(e,"mozAutoGainControl","autoGainControl"),c(e,"mozNoiseSuppression","noiseSuppression"),e}}if(s&&s.prototype.applyConstraints){var f=s.prototype.applyConstraints;s.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"==typeof e&&(e=JSON.parse(JSON.stringify(e)),c(e,"autoGainControl","mozAutoGainControl"),c(e,"noiseSuppression","mozNoiseSuppression")),f.apply(this,[e])}}}n.getUserMedia=function(e,i,s){if(t.version<44)return o(e,i,s);r.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(e).then(i,s)}}},{"../utils":50}],49:[function(e,t,n){"use strict";var r=e("../utils"),i={shimLocalStreamsAPI:function(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),"getStreamById"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getStreamById=function(e){var t=null;return this._localStreams&&this._localStreams.forEach(function(n){n.id===e&&(t=n)}),this._remoteStreams&&this._remoteStreams.forEach(function(n){n.id===e&&(t=n)}),t}),!("addStream"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),-1===this._localStreams.indexOf(e)&&this._localStreams.push(e);var n=this;e.getTracks().forEach(function(r){t.call(n,r,e)})},e.RTCPeerConnection.prototype.addTrack=function(e,n){n&&(this._localStreams?-1===this._localStreams.indexOf(n)&&this._localStreams.push(n):this._localStreams=[n]),t.call(this,e,n)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);var t=this._localStreams.indexOf(e);if(-1!==t){this._localStreams.splice(t,1);var n=this,r=e.getTracks();this.getSenders().forEach(function(e){-1!==r.indexOf(e.track)&&n.removeTrack(e)})}})}},shimRemoteStreamsAPI:function(e){"object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),"onaddstream"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=function(e){var t=e.streams[0];if(this._remoteStreams||(this._remoteStreams=[]),!(this._remoteStreams.indexOf(t)>=0)){this._remoteStreams.push(t);var n=new Event("addstream");n.stream=e.streams[0],this.dispatchEvent(n)}}.bind(this))}}))},shimCallbacksAPI:function(e){if("object"==typeof e&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype,n=t.createOffer,r=t.createAnswer,i=t.setLocalDescription,s=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){var r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){var n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i};var o=function(e,t,n){var r=i.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r};t.setLocalDescription=o,o=function(e,t,n){var r=s.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.setRemoteDescription=o,o=function(e,t,n){var r=a.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.addIceCandidate=o}},shimGetUserMedia:function(e){var t=e&&e.navigator;t.getUserMedia||(t.webkitGetUserMedia?t.getUserMedia=t.webkitGetUserMedia.bind(t):t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,n,r){t.mediaDevices.getUserMedia(e).then(n,r)}.bind(t)))},shimRTCIceServerUrls:function(e){var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,n){if(e&&e.iceServers){for(var i=[],s=0;s=n&&parseInt(r[n],10)},detectBrowser:function(e){var t=e&&e.navigator,n={};if(n.browser=null,n.version=null,void 0===e||!e.navigator)return n.browser="Not a browser.",n;if(t.mozGetUserMedia)n.browser="firefox",n.version=this.extractVersion(t.userAgent,/Firefox\/(\d+)\./,1);else if(t.webkitGetUserMedia)if(e.webkitRTCPeerConnection)n.browser="chrome",n.version=this.extractVersion(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!t.userAgent.match(/Version\/(\d+).(\d+)/))return n.browser="Unsupported webkit-based browser with GUM support but no WebRTC support.",n;n.browser="safari",n.version=this.extractVersion(t.userAgent,/AppleWebKit\/(\d+)\./,1)}else if(t.mediaDevices&&t.userAgent.match(/Edge\/(\d+).(\d+)$/))n.browser="edge",n.version=this.extractVersion(t.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!t.mediaDevices||!t.userAgent.match(/AppleWebKit\/(\d+)\./))return n.browser="Not a supported browser.",n;n.browser="safari",n.version=this.extractVersion(t.userAgent,/AppleWebKit\/(\d+)\./,1)}return n}};t.exports={log:s.log,deprecated:s.deprecated,disableLog:s.disableLog,disableWarnings:s.disableWarnings,extractVersion:s.extractVersion,shimCreateObjectURL:s.shimCreateObjectURL,detectBrowser:s.detectBrowser.bind(s)}},{}],51:[function(e,t,n){t.exports={name:"jssip",title:"JsSIP",description:"the Javascript SIP library",version:"3.0.23",homepage:"http://jssip.net",author:"José Luis Millán (https://github.com/jmillan)",contributors:["Iñaki Baz Castillo (https://github.com/ibc)","Saúl Ibarra Corretgé (https://github.com/saghul)"],main:"lib/JsSIP.js",keywords:["sip","websocket","webrtc","node","browser","library"],license:"MIT",repository:{type:"git",url:"https://github.com/versatica/JsSIP.git"},bugs:{url:"https://github.com/versatica/JsSIP/issues"},dependencies:{debug:"^3.0.1","sdp-transform":"^2.3.0","webrtc-adapter":"^5.0.0"},browserify:{transform:[["babelify",{presets:["es2015"]}]]},devDependencies:{"babel-preset-es2015":"^6.24.1",babelify:"7.3.0",browserify:"^14.3.0",gulp:"git+https://github.com/gulpjs/gulp.git#4.0","gulp-eslint":"^4.0.0","gulp-expect-file":"0.0.7","gulp-header":"1.8.9","gulp-nodeunit-runner":"^0.2.2","gulp-plumber":"^1.1.0","gulp-rename":"^1.2.2","gulp-uglify":"^3.0.0","gulp-util":"^3.0.8",eslint:"^4.4.1",pegjs:"0.7.0","vinyl-buffer":"^1.0.0","vinyl-source-stream":"^1.1.0"},scripts:{test:"gulp test"}}},{}]},{},[8])(8)}); \ No newline at end of file +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).JsSIP=e()}}(function(){return function e(t,n,r){function i(a,o){if(!n[a]){if(!t[a]){var l="function"==typeof require&&require;if(!o&&l)return l(a,!0);if(s)return s(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var c=n[a]={exports:{}};t[a][0].call(c.exports,function(e){var n=t[a][1][e];return i(n||e)},c,c.exports,e,t,n,r)}return n[a].exports}for(var s="function"==typeof require&&require,a=0;a0)return t}},connection_recovery_min_interval:function(e){if(r.isDecimal(e)){var t=Number(e);if(t>0)return t}},contact_uri:function(e){if("string"==typeof e){var t=s.parse(e,"SIP_URI");if(-1!==t)return t}},display_name:function(e){return-1===s.parse('"'+e+'"',"display_name")?void 0:e},instance_id:function(e){return/^uuid:/i.test(e)&&(e=e.substr(5)),-1===s.parse(e,"uuid")?void 0:e},no_answer_timeout:function(e){if(r.isDecimal(e)){var t=Number(e);if(t>0)return t}},session_timers:function(e){if("boolean"==typeof e)return e},password:function(e){return String(e)},realm:function(e){return String(e)},ha1:function(e){return String(e)},register:function(e){if("boolean"==typeof e)return e},register_expires:function(e){if(r.isDecimal(e)){var t=Number(e);if(t>0)return t}},registrar_server:function(e){/^sip:/i.test(e)||(e=i.SIP+":"+e);var t=a.parse(e);return t?t.user?void 0:t:void 0},use_preloaded_route:function(e){if("boolean"==typeof e)return e}}};n.load=function(e,t){for(var n in u.mandatory){if(!t.hasOwnProperty(n))throw new l.ConfigurationError(n);var i=t[n],s=u.mandatory[n](i);if(void 0===s)throw new l.ConfigurationError(n,i);e[n]=s}for(var a in u.optional)if(t.hasOwnProperty(a)){var o=t[a];if(r.isEmpty(o))continue;var c=u.optional[a](o);if(void 0===c)throw new l.ConfigurationError(a,o);e[a]=c}}},{"./Constants":2,"./Exceptions":6,"./Grammar":7,"./Socket":20,"./URI":25,"./Utils":26}],2:[function(e,t,n){"use strict";var r=e("../package.json");t.exports={USER_AGENT:r.title+" "+r.version,SIP:"sip",SIPS:"sips",causes:{CONNECTION_ERROR:"Connection Error",REQUEST_TIMEOUT:"Request Timeout",SIP_FAILURE_CODE:"SIP Failure Code",INTERNAL_ERROR:"Internal Error",BUSY:"Busy",REJECTED:"Rejected",REDIRECTED:"Redirected",UNAVAILABLE:"Unavailable",NOT_FOUND:"Not Found",ADDRESS_INCOMPLETE:"Address Incomplete",INCOMPATIBLE_SDP:"Incompatible SDP",MISSING_SDP:"Missing SDP",AUTHENTICATION_ERROR:"Authentication Error",BYE:"Terminated",WEBRTC_ERROR:"WebRTC Error",CANCELED:"Canceled",NO_ANSWER:"No Answer",EXPIRES:"Expires",NO_ACK:"No ACK",DIALOG_ERROR:"Dialog Error",USER_DENIED_MEDIA_ACCESS:"User Denied Media Access",BAD_MEDIA_DESCRIPTION:"Bad Media Description",RTP_TIMEOUT:"RTP Timeout"},SIP_ERROR_CAUSES:{REDIRECTED:[300,301,302,305,380],BUSY:[486,600],REJECTED:[403,603],NOT_FOUND:[404,604],UNAVAILABLE:[480,410,408,430],ADDRESS_INCOMPLETE:[484,424],INCOMPATIBLE_SDP:[488,606],AUTHENTICATION_ERROR:[401,407]},ACK:"ACK",BYE:"BYE",CANCEL:"CANCEL",INFO:"INFO",INVITE:"INVITE",MESSAGE:"MESSAGE",NOTIFY:"NOTIFY",OPTIONS:"OPTIONS",REGISTER:"REGISTER",REFER:"REFER",UPDATE:"UPDATE",SUBSCRIBE:"SUBSCRIBE",REASON_PHRASE:{100:"Trying",180:"Ringing",181:"Call Is Being Forwarded",182:"Queued",183:"Session Progress",199:"Early Dialog Terminated",200:"OK",202:"Accepted",204:"No Notification",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",305:"Use Proxy",380:"Alternative Service",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",410:"Gone",412:"Conditional Request Failed",413:"Request Entity Too Large",414:"Request-URI Too Long",415:"Unsupported Media Type",416:"Unsupported URI Scheme",417:"Unknown Resource-Priority",420:"Bad Extension",421:"Extension Required",422:"Session Interval Too Small",423:"Interval Too Brief",424:"Bad Location Information",428:"Use Identity Header",429:"Provide Referrer Identity",430:"Flow Failed",433:"Anonymity Disallowed",436:"Bad Identity-Info",437:"Unsupported Certificate",438:"Invalid Identity Header",439:"First Hop Lacks Outbound Support",440:"Max-Breadth Exceeded",469:"Bad Info Package",470:"Consent Needed",478:"Unresolvable Destination",480:"Temporarily Unavailable",481:"Call/Transaction Does Not Exist",482:"Loop Detected",483:"Too Many Hops",484:"Address Incomplete",485:"Ambiguous",486:"Busy Here",487:"Request Terminated",488:"Not Acceptable Here",489:"Bad Event",491:"Request Pending",493:"Undecipherable",494:"Security Agreement Required",500:"JsSIP Internal Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Server Time-out",505:"Version Not Supported",513:"Message Too Large",580:"Precondition Failure",600:"Busy Everywhere",603:"Decline",604:"Does Not Exist Anywhere",606:"Not Acceptable"},ALLOWED_METHODS:"INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO",ACCEPTED_BODY_TYPES:"application/sdp, application/dtmf-relay",MAX_FORWARDS:69,SESSION_EXPIRES:90,MIN_SESSION_EXPIRES:60}},{"../package.json":51}],3:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n3&&void 0!==arguments[3]?arguments[3]:d.STATUS_CONFIRMED;if(r(this,e),this._owner=t,this._ua=t._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,!n.hasHeader("contact"))return{error:"unable to create a Dialog without Contact header field"};n instanceof s.IncomingResponse&&(a=n.status_code<200?d.STATUS_EARLY:d.STATUS_CONFIRMED);var o=n.parseHeader("contact");"UAS"===i?(this._id={call_id:n.call_id,local_tag:n.to_tag,remote_tag:n.from_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._remote_seqnum=n.cseq,this._local_uri=n.parseHeader("to").uri,this._remote_uri=n.parseHeader("from").uri,this._remote_target=o.uri,this._route_set=n.getHeaders("record-route"),this._ack_seqnum=this._remote_seqnum):"UAC"===i&&(this._id={call_id:n.call_id,local_tag:n.from_tag,remote_tag:n.to_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._local_seqnum=n.cseq,this._local_uri=n.parseHeader("from").uri,this._remote_uri=n.parseHeader("to").uri,this._remote_target=o.uri,this._route_set=n.getHeaders("record-route").reverse(),this._ack_seqnum=null),this._ua.newDialog(this),c("new "+i+" dialog created with status "+(this._state===d.STATUS_EARLY?"EARLY":"CONFIRMED"))}return i(e,null,[{key:"C",get:function(){return d}}]),i(e,[{key:"update",value:function(e,t){this._state=d.STATUS_CONFIRMED,c("dialog "+this._id.toString()+" changed to CONFIRMED state"),"UAC"===t&&(this._route_set=e.getHeaders("record-route").reverse())}},{key:"terminate",value:function(){c("dialog "+this._id.toString()+" deleted"),this._ua.destroyDialog(this)}},{key:"sendRequest",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=u.cloneArray(n.extraHeaders),i=n.eventHandlers||{},s=n.body||null,a=this._createRequest(e,r,s);return i.onAuthenticated=function(){t._local_seqnum+=1},new l(this,a,i).send(),a}},{key:"receiveRequest",value:function(e){this._checkInDialogRequest(e)&&(e.method===a.ACK&&null!==this._ack_seqnum?this._ack_seqnum=null:e.method===a.INVITE&&(this._ack_seqnum=e.cseq),this._owner.receiveRequest(e))}},{key:"_createRequest",value:function(e,t,n){t=u.cloneArray(t),this._local_seqnum||(this._local_seqnum=Math.floor(1e4*Math.random()));var r=e===a.CANCEL||e===a.ACK?this._local_seqnum:this._local_seqnum+=1;return new s.OutgoingRequest(e,this._remote_target,this._ua,{cseq:r,call_id:this._id.call_id,from_uri:this._local_uri,from_tag:this._id.local_tag,to_uri:this._remote_uri,to_tag:this._id.remote_tag,route_set:this._route_set},t,n)}},{key:"_checkInDialogRequest",value:function(e){var t=this;if(this._remote_seqnum)if(e.cseqthis._remote_seqnum&&(this._remote_seqnum=e.cseq);else this._remote_seqnum=e.cseq;if(e.method===a.INVITE||e.method===a.UPDATE&&e.body){if(!0===this._uac_pending_reply)e.reply(491);else{if(!0===this._uas_pending_reply){var n=1+(10*Math.random()|0);return e.reply(500,null,["Retry-After:"+n]),!1}this._uas_pending_reply=!0;e.server_transaction.on("stateChanged",function n(){e.server_transaction.state!==o.C.STATUS_ACCEPTED&&e.server_transaction.state!==o.C.STATUS_COMPLETED&&e.server_transaction.state!==o.C.STATUS_TERMINATED||(e.server_transaction.removeListener("stateChanged",n),t._uas_pending_reply=!1)})}e.hasHeader("contact")&&e.server_transaction.on("stateChanged",function(){e.server_transaction.state===o.C.STATUS_ACCEPTED&&(t._remote_target=e.parseHeader("contact").uri)})}else e.method===a.NOTIFY&&e.hasHeader("contact")&&e.server_transaction.on("stateChanged",function(){e.server_transaction.state===o.C.STATUS_COMPLETED&&(t._remote_target=e.parseHeader("contact").uri)});return!0}},{key:"id",get:function(){return this._id}},{key:"local_seqnum",get:function(){return this._local_seqnum},set:function(e){this._local_seqnum=e}},{key:"owner",get:function(){return this._owner}},{key:"uac_pending_reply",get:function(){return this._uac_pending_reply},set:function(e){this._uac_pending_reply=e}},{key:"uas_pending_reply",get:function(){return this._uas_pending_reply}}]),e}()},{"./Constants":2,"./Dialog/RequestSender":4,"./SIPMessage":19,"./Transactions":22,"./Utils":26,debug:29}],4:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n=200&&e.status_code<300?this._eventHandlers.onSuccessResponse(e):e.status_code>=300&&this._eventHandlers.onErrorResponse(e):(this._request.cseq.value=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout(function(){t._dialog.owner.status!==o.C.STATUS_TERMINATED&&(t._reattempt=!0,t._request_sender.send())},1e3)):e.status_code>=200&&e.status_code<300?this._eventHandlers.onSuccessResponse(e):e.status_code>=300&&this._eventHandlers.onErrorResponse(e)}},{key:"request",get:function(){return this._request}}]),e}()},{"../Constants":2,"../RTCSession":12,"../RequestSender":18,"../Transactions":22}],5:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n-1)this._qop="auth";else{if(!(t.qop.indexOf("auth-int")>-1))return o('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;this._qop="auth-int"}else this._qop=null;this._method=n,this._uri=r,this._cnonce=s.createRandomToken(12),this._nc+=1;var i=Number(this._nc).toString(16);this._ncHex="00000000".substr(0,8-i.length)+i,4294967296===this._nc&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=s.calculateMD5(this._credentials.username+":"+this._realm+":"+this._credentials.password):this._ha1=this._credentials.ha1;var l=void 0;return"auth"===this._qop?(l=s.calculateMD5(this._method+":"+this._uri),this._response=s.calculateMD5(this._ha1+":"+this._nonce+":"+this._ncHex+":"+this._cnonce+":auth:"+l)):"auth-int"===this._qop?(l=s.calculateMD5(this._method+":"+this._uri+":"+s.calculateMD5(this.body?this.body:"")),this._response=s.calculateMD5(this._ha1+":"+this._nonce+":"+this._ncHex+":"+this._cnonce+":auth-int:"+l)):null===this._qop&&(l=s.calculateMD5(this._method+":"+this._uri),this._response=s.calculateMD5(this._ha1+":"+this._nonce+":"+l)),a("authenticate() | response generated"),!0}},{key:"toString",value:function(){var e=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return e.push("algorithm="+this._algorithm),e.push('username="'+this._credentials.username+'"'),e.push('realm="'+this._realm+'"'),e.push('nonce="'+this._nonce+'"'),e.push('uri="'+this._uri+'"'),e.push('response="'+this._response+'"'),this._opaque&&e.push('opaque="'+this._opaque+'"'),this._qop&&(e.push("qop="+this._qop),e.push('cnonce="'+this._cnonce+'"'),e.push("nc="+this._ncHex)),"Digest "+e.join(", ")}}]),e}()},{"./Utils":26,debug:29}],6:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=function(e){function t(e,n){r(this,t);var s=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return s.code=1,s.name="CONFIGURATION_ERROR",s.parameter=e,s.value=n,s.message=s.value?"Invalid value "+JSON.stringify(s.value)+' for parameter "'+s.parameter+'"':"Missing parameter: "+s.parameter,s}return s(t,Error),t}(),o=function(e){function t(e){r(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.code=2,n.name="INVALID_STATE_ERROR",n.status=e,n.message="Invalid status: "+e,n}return s(t,Error),t}(),l=function(e){function t(e){r(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.code=3,n.name="NOT_SUPPORTED_ERROR",n.message=e,n}return s(t,Error),t}(),u=function(e){function t(e){r(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.code=4,n.name="NOT_READY_ERROR",n.message=e,n}return s(t,Error),t}();t.exports={ConfigurationError:a,InvalidStateError:o,NotSupportedError:l,NotReadyError:u}},{}],7:[function(e,t,n){"use strict";t.exports=function(){function t(e){return'"'+e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var n={parse:function(n,r){function i(e){UnLn&&(Ln=Un,qn=[]),qn.push(e))}function s(){var e;return"\r\n"===n.substr(Un,2)?(e="\r\n",Un+=2):(e=null,0===Mn&&i('"\\r\\n"')),e}function a(){var e;return/^[0-9]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[0-9]")),e}function o(){var e;return/^[a-zA-Z]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[a-zA-Z]")),e}function l(){var e;return/^[0-9a-fA-F]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[0-9a-fA-F]")),e}function u(){var e;return null===(e=h())&&(e=f()),e}function c(){var e;return/^[\0-\xFF]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[\\0-\\xFF]")),e}function d(){var e;return/^["]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i('["]')),e}function h(){var e;return 32===n.charCodeAt(Un)?(e=" ",Un++):(e=null,0===Mn&&i('" "')),e}function f(){var e;return 9===n.charCodeAt(Un)?(e="\t",Un++):(e=null,0===Mn&&i('"\\t"')),e}function p(){var e;return/^[a-zA-Z0-9]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[a-zA-Z0-9]")),e}function _(){var e;return 59===n.charCodeAt(Un)?(e=";",Un++):(e=null,0===Mn&&i('";"')),null===e&&(47===n.charCodeAt(Un)?(e="/",Un++):(e=null,0===Mn&&i('"/"')),null===e&&(63===n.charCodeAt(Un)?(e="?",Un++):(e=null,0===Mn&&i('"?"')),null===e&&(58===n.charCodeAt(Un)?(e=":",Un++):(e=null,0===Mn&&i('":"')),null===e&&(64===n.charCodeAt(Un)?(e="@",Un++):(e=null,0===Mn&&i('"@"')),null===e&&(38===n.charCodeAt(Un)?(e="&",Un++):(e=null,0===Mn&&i('"&"')),null===e&&(61===n.charCodeAt(Un)?(e="=",Un++):(e=null,0===Mn&&i('"="')),null===e&&(43===n.charCodeAt(Un)?(e="+",Un++):(e=null,0===Mn&&i('"+"')),null===e&&(36===n.charCodeAt(Un)?(e="$",Un++):(e=null,0===Mn&&i('"$"')),null===e&&(44===n.charCodeAt(Un)?(e=",",Un++):(e=null,0===Mn&&i('","'))))))))))),e}function m(){var e;return null===(e=p())&&(e=v()),e}function v(){var e;return 45===n.charCodeAt(Un)?(e="-",Un++):(e=null,0===Mn&&i('"-"')),null===e&&(95===n.charCodeAt(Un)?(e="_",Un++):(e=null,0===Mn&&i('"_"')),null===e&&(46===n.charCodeAt(Un)?(e=".",Un++):(e=null,0===Mn&&i('"."')),null===e&&(33===n.charCodeAt(Un)?(e="!",Un++):(e=null,0===Mn&&i('"!"')),null===e&&(126===n.charCodeAt(Un)?(e="~",Un++):(e=null,0===Mn&&i('"~"')),null===e&&(42===n.charCodeAt(Un)?(e="*",Un++):(e=null,0===Mn&&i('"*"')),null===e&&(39===n.charCodeAt(Un)?(e="'",Un++):(e=null,0===Mn&&i('"\'"')),null===e&&(40===n.charCodeAt(Un)?(e="(",Un++):(e=null,0===Mn&&i('"("')),null===e&&(41===n.charCodeAt(Un)?(e=")",Un++):(e=null,0===Mn&&i('")"')))))))))),e}function g(){var e,t,r,s,a;return s=Un,a=Un,37===n.charCodeAt(Un)?(e="%",Un++):(e=null,0===Mn&&i('"%"')),null!==e&&null!==(t=l())&&null!==(r=l())?e=[e,t,r]:(e=null,Un=a),null!==e&&(e=e.join("")),null===e&&(Un=s),e}function y(){var e,t,n,r,i,a;for(r=Un,i=Un,a=Un,e=[],t=u();null!==t;)e.push(t),t=u();if(null!==e&&null!==(t=s())?e=[e,t]:(e=null,Un=a),null!==(e=null!==e?e:"")){if(null!==(n=u()))for(t=[];null!==n;)t.push(n),n=u();else t=null;null!==t?e=[e,t]:(e=null,Un=i)}else e=null,Un=i;return null!==e&&(e=" "),null===e&&(Un=r),e}function T(){var e;return e=y(),e=null!==e?e:""}function C(){var e,t,r,s,a;for(s=Un,a=Un,e=[],null===(t=h())&&(t=f());null!==t;)e.push(t),null===(t=h())&&(t=f());return null!==e?(58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(r=T())?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=":"),null===e&&(Un=s),e}function S(){var e,t,r,i,s,a,o;if(s=Un,a=Un,null!==(t=E()))for(e=[];null!==t;)e.push(t),t=E();else e=null;if(null!==e){for(t=[],o=Un,r=[],i=y();null!==i;)r.push(i),i=y();for(null!==r&&null!==(i=E())?r=[r,i]:(r=null,Un=o);null!==r;){for(t.push(r),o=Un,r=[],i=y();null!==i;)r.push(i),i=y();null!==r&&null!==(i=E())?r=[r,i]:(r=null,Un=o)}null!==t?e=[e,t]:(e=null,Un=a)}else e=null,Un=a;return null!==e&&(e=function(e){return n.substring(Un,e)}(s)),null===e&&(Un=s),e}function E(){var e;return/^[!-~]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[!-~]")),null===e&&(e=b()),e}function b(){var e;return/^[\x80-\uFFFF]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[\\x80-\\uFFFF]")),e}function R(){var e;return/^[\x80-\xBF]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[\\x80-\\xBF]")),e}function A(){var e,t,r;if(r=Un,null===(t=p())&&(45===n.charCodeAt(Un)?(t="-",Un++):(t=null,0===Mn&&i('"-"')),null===t&&(46===n.charCodeAt(Un)?(t=".",Un++):(t=null,0===Mn&&i('"."')),null===t&&(33===n.charCodeAt(Un)?(t="!",Un++):(t=null,0===Mn&&i('"!"')),null===t&&(37===n.charCodeAt(Un)?(t="%",Un++):(t=null,0===Mn&&i('"%"')),null===t&&(42===n.charCodeAt(Un)?(t="*",Un++):(t=null,0===Mn&&i('"*"')),null===t&&(95===n.charCodeAt(Un)?(t="_",Un++):(t=null,0===Mn&&i('"_"')),null===t&&(43===n.charCodeAt(Un)?(t="+",Un++):(t=null,0===Mn&&i('"+"')),null===t&&(96===n.charCodeAt(Un)?(t="`",Un++):(t=null,0===Mn&&i('"`"')),null===t&&(39===n.charCodeAt(Un)?(t="'",Un++):(t=null,0===Mn&&i('"\'"')),null===t&&(126===n.charCodeAt(Un)?(t="~",Un++):(t=null,0===Mn&&i('"~"')))))))))))),null!==t)for(e=[];null!==t;)e.push(t),null===(t=p())&&(45===n.charCodeAt(Un)?(t="-",Un++):(t=null,0===Mn&&i('"-"')),null===t&&(46===n.charCodeAt(Un)?(t=".",Un++):(t=null,0===Mn&&i('"."')),null===t&&(33===n.charCodeAt(Un)?(t="!",Un++):(t=null,0===Mn&&i('"!"')),null===t&&(37===n.charCodeAt(Un)?(t="%",Un++):(t=null,0===Mn&&i('"%"')),null===t&&(42===n.charCodeAt(Un)?(t="*",Un++):(t=null,0===Mn&&i('"*"')),null===t&&(95===n.charCodeAt(Un)?(t="_",Un++):(t=null,0===Mn&&i('"_"')),null===t&&(43===n.charCodeAt(Un)?(t="+",Un++):(t=null,0===Mn&&i('"+"')),null===t&&(96===n.charCodeAt(Un)?(t="`",Un++):(t=null,0===Mn&&i('"`"')),null===t&&(39===n.charCodeAt(Un)?(t="'",Un++):(t=null,0===Mn&&i('"\'"')),null===t&&(126===n.charCodeAt(Un)?(t="~",Un++):(t=null,0===Mn&&i('"~"'))))))))))));else e=null;return null!==e&&(e=function(e){return n.substring(Un,e)}(r)),null===e&&(Un=r),e}function w(){var e,t,r;if(r=Un,null===(t=p())&&(45===n.charCodeAt(Un)?(t="-",Un++):(t=null,0===Mn&&i('"-"')),null===t&&(33===n.charCodeAt(Un)?(t="!",Un++):(t=null,0===Mn&&i('"!"')),null===t&&(37===n.charCodeAt(Un)?(t="%",Un++):(t=null,0===Mn&&i('"%"')),null===t&&(42===n.charCodeAt(Un)?(t="*",Un++):(t=null,0===Mn&&i('"*"')),null===t&&(95===n.charCodeAt(Un)?(t="_",Un++):(t=null,0===Mn&&i('"_"')),null===t&&(43===n.charCodeAt(Un)?(t="+",Un++):(t=null,0===Mn&&i('"+"')),null===t&&(96===n.charCodeAt(Un)?(t="`",Un++):(t=null,0===Mn&&i('"`"')),null===t&&(39===n.charCodeAt(Un)?(t="'",Un++):(t=null,0===Mn&&i('"\'"')),null===t&&(126===n.charCodeAt(Un)?(t="~",Un++):(t=null,0===Mn&&i('"~"'))))))))))),null!==t)for(e=[];null!==t;)e.push(t),null===(t=p())&&(45===n.charCodeAt(Un)?(t="-",Un++):(t=null,0===Mn&&i('"-"')),null===t&&(33===n.charCodeAt(Un)?(t="!",Un++):(t=null,0===Mn&&i('"!"')),null===t&&(37===n.charCodeAt(Un)?(t="%",Un++):(t=null,0===Mn&&i('"%"')),null===t&&(42===n.charCodeAt(Un)?(t="*",Un++):(t=null,0===Mn&&i('"*"')),null===t&&(95===n.charCodeAt(Un)?(t="_",Un++):(t=null,0===Mn&&i('"_"')),null===t&&(43===n.charCodeAt(Un)?(t="+",Un++):(t=null,0===Mn&&i('"+"')),null===t&&(96===n.charCodeAt(Un)?(t="`",Un++):(t=null,0===Mn&&i('"`"')),null===t&&(39===n.charCodeAt(Un)?(t="'",Un++):(t=null,0===Mn&&i('"\'"')),null===t&&(126===n.charCodeAt(Un)?(t="~",Un++):(t=null,0===Mn&&i('"~"')))))))))));else e=null;return null!==e&&(e=function(e){return n.substring(Un,e)}(r)),null===e&&(Un=r),e}function I(){var e,t,r;if(r=Un,null===(t=p())&&(45===n.charCodeAt(Un)?(t="-",Un++):(t=null,0===Mn&&i('"-"')),null===t&&(46===n.charCodeAt(Un)?(t=".",Un++):(t=null,0===Mn&&i('"."')),null===t&&(33===n.charCodeAt(Un)?(t="!",Un++):(t=null,0===Mn&&i('"!"')),null===t&&(37===n.charCodeAt(Un)?(t="%",Un++):(t=null,0===Mn&&i('"%"')),null===t&&(42===n.charCodeAt(Un)?(t="*",Un++):(t=null,0===Mn&&i('"*"')),null===t&&(95===n.charCodeAt(Un)?(t="_",Un++):(t=null,0===Mn&&i('"_"')),null===t&&(43===n.charCodeAt(Un)?(t="+",Un++):(t=null,0===Mn&&i('"+"')),null===t&&(96===n.charCodeAt(Un)?(t="`",Un++):(t=null,0===Mn&&i('"`"')),null===t&&(39===n.charCodeAt(Un)?(t="'",Un++):(t=null,0===Mn&&i('"\'"')),null===t&&(126===n.charCodeAt(Un)?(t="~",Un++):(t=null,0===Mn&&i('"~"')),null===t&&(40===n.charCodeAt(Un)?(t="(",Un++):(t=null,0===Mn&&i('"("')),null===t&&(41===n.charCodeAt(Un)?(t=")",Un++):(t=null,0===Mn&&i('")"')),null===t&&(60===n.charCodeAt(Un)?(t="<",Un++):(t=null,0===Mn&&i('"<"')),null===t&&(62===n.charCodeAt(Un)?(t=">",Un++):(t=null,0===Mn&&i('">"')),null===t&&(58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null===t&&(92===n.charCodeAt(Un)?(t="\\",Un++):(t=null,0===Mn&&i('"\\\\"')),null===t&&null===(t=d())&&(47===n.charCodeAt(Un)?(t="/",Un++):(t=null,0===Mn&&i('"/"')),null===t&&(91===n.charCodeAt(Un)?(t="[",Un++):(t=null,0===Mn&&i('"["')),null===t&&(93===n.charCodeAt(Un)?(t="]",Un++):(t=null,0===Mn&&i('"]"')),null===t&&(63===n.charCodeAt(Un)?(t="?",Un++):(t=null,0===Mn&&i('"?"')),null===t&&(123===n.charCodeAt(Un)?(t="{",Un++):(t=null,0===Mn&&i('"{"')),null===t&&(125===n.charCodeAt(Un)?(t="}",Un++):(t=null,0===Mn&&i('"}"')))))))))))))))))))))))),null!==t)for(e=[];null!==t;)e.push(t),null===(t=p())&&(45===n.charCodeAt(Un)?(t="-",Un++):(t=null,0===Mn&&i('"-"')),null===t&&(46===n.charCodeAt(Un)?(t=".",Un++):(t=null,0===Mn&&i('"."')),null===t&&(33===n.charCodeAt(Un)?(t="!",Un++):(t=null,0===Mn&&i('"!"')),null===t&&(37===n.charCodeAt(Un)?(t="%",Un++):(t=null,0===Mn&&i('"%"')),null===t&&(42===n.charCodeAt(Un)?(t="*",Un++):(t=null,0===Mn&&i('"*"')),null===t&&(95===n.charCodeAt(Un)?(t="_",Un++):(t=null,0===Mn&&i('"_"')),null===t&&(43===n.charCodeAt(Un)?(t="+",Un++):(t=null,0===Mn&&i('"+"')),null===t&&(96===n.charCodeAt(Un)?(t="`",Un++):(t=null,0===Mn&&i('"`"')),null===t&&(39===n.charCodeAt(Un)?(t="'",Un++):(t=null,0===Mn&&i('"\'"')),null===t&&(126===n.charCodeAt(Un)?(t="~",Un++):(t=null,0===Mn&&i('"~"')),null===t&&(40===n.charCodeAt(Un)?(t="(",Un++):(t=null,0===Mn&&i('"("')),null===t&&(41===n.charCodeAt(Un)?(t=")",Un++):(t=null,0===Mn&&i('")"')),null===t&&(60===n.charCodeAt(Un)?(t="<",Un++):(t=null,0===Mn&&i('"<"')),null===t&&(62===n.charCodeAt(Un)?(t=">",Un++):(t=null,0===Mn&&i('">"')),null===t&&(58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null===t&&(92===n.charCodeAt(Un)?(t="\\",Un++):(t=null,0===Mn&&i('"\\\\"')),null===t&&null===(t=d())&&(47===n.charCodeAt(Un)?(t="/",Un++):(t=null,0===Mn&&i('"/"')),null===t&&(91===n.charCodeAt(Un)?(t="[",Un++):(t=null,0===Mn&&i('"["')),null===t&&(93===n.charCodeAt(Un)?(t="]",Un++):(t=null,0===Mn&&i('"]"')),null===t&&(63===n.charCodeAt(Un)?(t="?",Un++):(t=null,0===Mn&&i('"?"')),null===t&&(123===n.charCodeAt(Un)?(t="{",Un++):(t=null,0===Mn&&i('"{"')),null===t&&(125===n.charCodeAt(Un)?(t="}",Un++):(t=null,0===Mn&&i('"}"'))))))))))))))))))))))));else e=null;return null!==e&&(e=function(e){return n.substring(Un,e)}(r)),null===e&&(Un=r),e}function k(){var e,t,r,s,a;return s=Un,a=Un,null!==(e=T())?(42===n.charCodeAt(Un)?(t="*",Un++):(t=null,0===Mn&&i('"*"')),null!==t&&null!==(r=T())?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e="*"),null===e&&(Un=s),e}function O(){var e,t,r,s,a;return s=Un,a=Un,null!==(e=T())?(47===n.charCodeAt(Un)?(t="/",Un++):(t=null,0===Mn&&i('"/"')),null!==t&&null!==(r=T())?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e="/"),null===e&&(Un=s),e}function P(){var e,t,r,s,a;return s=Un,a=Un,null!==(e=T())?(61===n.charCodeAt(Un)?(t="=",Un++):(t=null,0===Mn&&i('"="')),null!==t&&null!==(r=T())?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e="="),null===e&&(Un=s),e}function x(){var e,t,r,s,a;return s=Un,a=Un,null!==(e=T())?(40===n.charCodeAt(Un)?(t="(",Un++):(t=null,0===Mn&&i('"("')),null!==t&&null!==(r=T())?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e="("),null===e&&(Un=s),e}function N(){var e,t,r,s,a;return s=Un,a=Un,null!==(e=T())?(41===n.charCodeAt(Un)?(t=")",Un++):(t=null,0===Mn&&i('")"')),null!==t&&null!==(r=T())?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=")"),null===e&&(Un=s),e}function D(){var e,t,r,s;return r=Un,s=Un,62===n.charCodeAt(Un)?(e=">",Un++):(e=null,0===Mn&&i('">"')),null!==e&&null!==(t=T())?e=[e,t]:(e=null,Un=s),null!==e&&(e=">"),null===e&&(Un=r),e}function U(){var e,t,r,s;return r=Un,s=Un,null!==(e=T())?(60===n.charCodeAt(Un)?(t="<",Un++):(t=null,0===Mn&&i('"<"')),null!==t?e=[e,t]:(e=null,Un=s)):(e=null,Un=s),null!==e&&(e="<"),null===e&&(Un=r),e}function M(){var e,t,r,s,a;return s=Un,a=Un,null!==(e=T())?(44===n.charCodeAt(Un)?(t=",",Un++):(t=null,0===Mn&&i('","')),null!==t&&null!==(r=T())?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=","),null===e&&(Un=s),e}function L(){var e,t,r,s,a;return s=Un,a=Un,null!==(e=T())?(59===n.charCodeAt(Un)?(t=";",Un++):(t=null,0===Mn&&i('";"')),null!==t&&null!==(r=T())?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=";"),null===e&&(Un=s),e}function q(){var e,t,r,s,a;return s=Un,a=Un,null!==(e=T())?(58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(r=T())?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=":"),null===e&&(Un=s),e}function H(){var e,t,n,r;return n=Un,r=Un,null!==(e=T())&&null!==(t=d())?e=[e,t]:(e=null,Un=r),null!==e&&(e='"'),null===e&&(Un=n),e}function F(){var e,t,n,r;return n=Un,r=Un,null!==(e=d())&&null!==(t=T())?e=[e,t]:(e=null,Un=r),null!==e&&(e='"'),null===e&&(Un=n),e}function j(){var e,t,n,r;if(r=Un,null!==(e=x())){for(t=[],null===(n=G())&&null===(n=J())&&(n=j());null!==n;)t.push(n),null===(n=G())&&null===(n=J())&&(n=j());null!==t&&null!==(n=N())?e=[e,t,n]:(e=null,Un=r)}else e=null,Un=r;return e}function G(){var e;return/^[!-']/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[!-']")),null===e&&(/^[*-[]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[*-[]")),null===e&&(/^[\]-~]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[\\]-~]")),null===e&&null===(e=b())&&(e=y()))),e}function B(){var e,t,r,i,s,a;if(s=Un,a=Un,null!==(e=T()))if(null!==(t=d())){for(r=[],null===(i=V())&&(i=J());null!==i;)r.push(i),null===(i=V())&&(i=J());null!==r&&null!==(i=d())?e=[e,t,r,i]:(e=null,Un=a)}else e=null,Un=a;else e=null,Un=a;return null!==e&&(e=function(e){return n.substring(Un,e)}(s)),null===e&&(Un=s),e}function W(){var e,t,r,i,s,a;if(s=Un,a=Un,null!==(e=T()))if(null!==(t=d())){for(r=[],null===(i=V())&&(i=J());null!==i;)r.push(i),null===(i=V())&&(i=J());null!==r&&null!==(i=d())?e=[e,t,r,i]:(e=null,Un=a)}else e=null,Un=a;else e=null,Un=a;return null!==e&&(e=function(e){return n.substring(Un-1,e+1)}(s)),null===e&&(Un=s),e}function V(){var e;return null===(e=y())&&(33===n.charCodeAt(Un)?(e="!",Un++):(e=null,0===Mn&&i('"!"')),null===e&&(/^[#-[]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[#-[]")),null===e&&(/^[\]-~]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[\\]-~]")),null===e&&(e=b())))),e}function J(){var e,t,r;return r=Un,92===n.charCodeAt(Un)?(e="\\",Un++):(e=null,0===Mn&&i('"\\\\"')),null!==e?(/^[\0-\t]/.test(n.charAt(Un))?(t=n.charAt(Un),Un++):(t=null,0===Mn&&i("[\\0-\\t]")),null===t&&(/^[\x0B-\f]/.test(n.charAt(Un))?(t=n.charAt(Un),Un++):(t=null,0===Mn&&i("[\\x0B-\\f]")),null===t&&(/^[\x0E-]/.test(n.charAt(Un))?(t=n.charAt(Un),Un++):(t=null,0===Mn&&i("[\\x0E-]")))),null!==t?e=[e,t]:(e=null,Un=r)):(e=null,Un=r),e}function K(){var e,t,r,s,a,o;return a=Un,o=Un,null!==(e=Y())?(58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(r=null!==(r=Q())?r:"")&&null!==(s=ne())?e=[e,t,r,s]:(e=null,Un=o)):(e=null,Un=o),null!==e&&(e=function(e){try{jn.uri=new Hn(jn.scheme,jn.user,jn.host,jn.port),delete jn.scheme,delete jn.user,delete jn.host,delete jn.host_type,delete jn.port}catch(e){jn=-1}}()),null===e&&(Un=a),e}function z(){var e,t,s,a,o,l,u,c;return u=Un,c=Un,null!==(e=Y())?(58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(s=null!==(s=Q())?s:"")&&null!==(a=ne())&&null!==(o=pe())&&null!==(l=null!==(l=we())?l:"")?e=[e,t,s,a,o,l]:(e=null,Un=c)):(e=null,Un=c),null!==e&&(e=function(e){try{jn.uri=new Hn(jn.scheme,jn.user,jn.host,jn.port,jn.uri_params,jn.uri_headers),delete jn.scheme,delete jn.user,delete jn.host,delete jn.host_type,delete jn.port,delete jn.uri_params,"SIP_URI"===r&&(jn=jn.uri)}catch(e){jn=-1}}()),null===e&&(Un=u),e}function Y(){var e;return null===(e=$())&&(e=X()),e}function $(){var e,t;return t=Un,"sips"===n.substr(Un,4).toLowerCase()?(e=n.substr(Un,4),Un+=4):(e=null,0===Mn&&i('"sips"')),null!==e&&(e=function(e,t){jn.scheme=t.toLowerCase()}(0,e)),null===e&&(Un=t),e}function X(){var e,t;return t=Un,"sip"===n.substr(Un,3).toLowerCase()?(e=n.substr(Un,3),Un+=3):(e=null,0===Mn&&i('"sip"')),null!==e&&(e=function(e,t){jn.scheme=t.toLowerCase()}(0,e)),null===e&&(Un=t),e}function Q(){var e,t,r,s,a,o;return s=Un,a=Un,null!==(e=Z())?(o=Un,58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(r=te())?t=[t,r]:(t=null,Un=o),null!==(t=null!==t?t:"")?(64===n.charCodeAt(Un)?(r="@",Un++):(r=null,0===Mn&&i('"@"')),null!==r?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=function(e){jn.user=decodeURIComponent(n.substring(Un-1,e))}(s)),null===e&&(Un=s),e}function Z(){var e,t;if(null===(t=m())&&null===(t=g())&&(t=ee()),null!==t)for(e=[];null!==t;)e.push(t),null===(t=m())&&null===(t=g())&&(t=ee());else e=null;return e}function ee(){var e;return 38===n.charCodeAt(Un)?(e="&",Un++):(e=null,0===Mn&&i('"&"')),null===e&&(61===n.charCodeAt(Un)?(e="=",Un++):(e=null,0===Mn&&i('"="')),null===e&&(43===n.charCodeAt(Un)?(e="+",Un++):(e=null,0===Mn&&i('"+"')),null===e&&(36===n.charCodeAt(Un)?(e="$",Un++):(e=null,0===Mn&&i('"$"')),null===e&&(44===n.charCodeAt(Un)?(e=",",Un++):(e=null,0===Mn&&i('","')),null===e&&(59===n.charCodeAt(Un)?(e=";",Un++):(e=null,0===Mn&&i('";"')),null===e&&(63===n.charCodeAt(Un)?(e="?",Un++):(e=null,0===Mn&&i('"?"')),null===e&&(47===n.charCodeAt(Un)?(e="/",Un++):(e=null,0===Mn&&i('"/"'))))))))),e}function te(){var e,t,r;for(r=Un,e=[],null===(t=m())&&null===(t=g())&&(38===n.charCodeAt(Un)?(t="&",Un++):(t=null,0===Mn&&i('"&"')),null===t&&(61===n.charCodeAt(Un)?(t="=",Un++):(t=null,0===Mn&&i('"="')),null===t&&(43===n.charCodeAt(Un)?(t="+",Un++):(t=null,0===Mn&&i('"+"')),null===t&&(36===n.charCodeAt(Un)?(t="$",Un++):(t=null,0===Mn&&i('"$"')),null===t&&(44===n.charCodeAt(Un)?(t=",",Un++):(t=null,0===Mn&&i('","')))))));null!==t;)e.push(t),null===(t=m())&&null===(t=g())&&(38===n.charCodeAt(Un)?(t="&",Un++):(t=null,0===Mn&&i('"&"')),null===t&&(61===n.charCodeAt(Un)?(t="=",Un++):(t=null,0===Mn&&i('"="')),null===t&&(43===n.charCodeAt(Un)?(t="+",Un++):(t=null,0===Mn&&i('"+"')),null===t&&(36===n.charCodeAt(Un)?(t="$",Un++):(t=null,0===Mn&&i('"$"')),null===t&&(44===n.charCodeAt(Un)?(t=",",Un++):(t=null,0===Mn&&i('","')))))));return null!==e&&(e=function(e){jn.password=n.substring(Un,e)}(r)),null===e&&(Un=r),e}function ne(){var e,t,r,s,a;return s=Un,null!==(e=re())?(a=Un,58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(r=fe())?t=[t,r]:(t=null,Un=a),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,Un=s)):(e=null,Un=s),e}function re(){var e,t;return t=Un,null===(e=ie())&&null===(e=de())&&(e=oe()),null!==e&&(e=function(e){return jn.host=n.substring(Un,e).toLowerCase(),jn.host}(t)),null===e&&(Un=t),e}function ie(){var e,t,r,s,a,o;for(s=Un,a=Un,e=[],o=Un,null!==(t=se())?(46===n.charCodeAt(Un)?(r=".",Un++):(r=null,0===Mn&&i('"."')),null!==r?t=[t,r]:(t=null,Un=o)):(t=null,Un=o);null!==t;)e.push(t),o=Un,null!==(t=se())?(46===n.charCodeAt(Un)?(r=".",Un++):(r=null,0===Mn&&i('"."')),null!==r?t=[t,r]:(t=null,Un=o)):(t=null,Un=o);return null!==e&&null!==(t=ae())?(46===n.charCodeAt(Un)?(r=".",Un++):(r=null,0===Mn&&i('"."')),null!==(r=null!==r?r:"")?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=function(e){return jn.host_type="domain",n.substring(Un,e)}(s)),null===e&&(Un=s),e}function se(){var e,t,r,s;if(s=Un,null!==(e=p())){for(t=[],null===(r=p())&&(45===n.charCodeAt(Un)?(r="-",Un++):(r=null,0===Mn&&i('"-"')),null===r&&(95===n.charCodeAt(Un)?(r="_",Un++):(r=null,0===Mn&&i('"_"'))));null!==r;)t.push(r),null===(r=p())&&(45===n.charCodeAt(Un)?(r="-",Un++):(r=null,0===Mn&&i('"-"')),null===r&&(95===n.charCodeAt(Un)?(r="_",Un++):(r=null,0===Mn&&i('"_"'))));null!==t?e=[e,t]:(e=null,Un=s)}else e=null,Un=s;return e}function ae(){var e,t,r,s;if(s=Un,null!==(e=o())){for(t=[],null===(r=p())&&(45===n.charCodeAt(Un)?(r="-",Un++):(r=null,0===Mn&&i('"-"')),null===r&&(95===n.charCodeAt(Un)?(r="_",Un++):(r=null,0===Mn&&i('"_"'))));null!==r;)t.push(r),null===(r=p())&&(45===n.charCodeAt(Un)?(r="-",Un++):(r=null,0===Mn&&i('"-"')),null===r&&(95===n.charCodeAt(Un)?(r="_",Un++):(r=null,0===Mn&&i('"_"'))));null!==t?e=[e,t]:(e=null,Un=s)}else e=null,Un=s;return e}function oe(){var e,t,r,s,a;return s=Un,a=Un,91===n.charCodeAt(Un)?(e="[",Un++):(e=null,0===Mn&&i('"["')),null!==e&&null!==(t=le())?(93===n.charCodeAt(Un)?(r="]",Un++):(r=null,0===Mn&&i('"]"')),null!==r?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=function(e){return jn.host_type="IPv6",n.substring(Un,e)}(s)),null===e&&(Un=s),e}function le(){var e,t,r,s,a,o,l,u,c,d,h,f,p,_,m,v;return _=Un,m=Un,null!==(e=ue())?(58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(r=ue())?(58===n.charCodeAt(Un)?(s=":",Un++):(s=null,0===Mn&&i('":"')),null!==s&&null!==(a=ue())?(58===n.charCodeAt(Un)?(o=":",Un++):(o=null,0===Mn&&i('":"')),null!==o&&null!==(l=ue())?(58===n.charCodeAt(Un)?(u=":",Un++):(u=null,0===Mn&&i('":"')),null!==u&&null!==(c=ue())?(58===n.charCodeAt(Un)?(d=":",Un++):(d=null,0===Mn&&i('":"')),null!==d&&null!==(h=ue())?(58===n.charCodeAt(Un)?(f=":",Un++):(f=null,0===Mn&&i('":"')),null!==f&&null!==(p=ce())?e=[e,t,r,s,a,o,l,u,c,d,h,f,p]:(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m),null===e&&(m=Un,"::"===n.substr(Un,2)?(e="::",Un+=2):(e=null,0===Mn&&i('"::"')),null!==e&&null!==(t=ue())?(58===n.charCodeAt(Un)?(r=":",Un++):(r=null,0===Mn&&i('":"')),null!==r&&null!==(s=ue())?(58===n.charCodeAt(Un)?(a=":",Un++):(a=null,0===Mn&&i('":"')),null!==a&&null!==(o=ue())?(58===n.charCodeAt(Un)?(l=":",Un++):(l=null,0===Mn&&i('":"')),null!==l&&null!==(u=ue())?(58===n.charCodeAt(Un)?(c=":",Un++):(c=null,0===Mn&&i('":"')),null!==c&&null!==(d=ue())?(58===n.charCodeAt(Un)?(h=":",Un++):(h=null,0===Mn&&i('":"')),null!==h&&null!==(f=ce())?e=[e,t,r,s,a,o,l,u,c,d,h,f]:(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m),null===e&&(m=Un,"::"===n.substr(Un,2)?(e="::",Un+=2):(e=null,0===Mn&&i('"::"')),null!==e&&null!==(t=ue())?(58===n.charCodeAt(Un)?(r=":",Un++):(r=null,0===Mn&&i('":"')),null!==r&&null!==(s=ue())?(58===n.charCodeAt(Un)?(a=":",Un++):(a=null,0===Mn&&i('":"')),null!==a&&null!==(o=ue())?(58===n.charCodeAt(Un)?(l=":",Un++):(l=null,0===Mn&&i('":"')),null!==l&&null!==(u=ue())?(58===n.charCodeAt(Un)?(c=":",Un++):(c=null,0===Mn&&i('":"')),null!==c&&null!==(d=ce())?e=[e,t,r,s,a,o,l,u,c,d]:(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m),null===e&&(m=Un,"::"===n.substr(Un,2)?(e="::",Un+=2):(e=null,0===Mn&&i('"::"')),null!==e&&null!==(t=ue())?(58===n.charCodeAt(Un)?(r=":",Un++):(r=null,0===Mn&&i('":"')),null!==r&&null!==(s=ue())?(58===n.charCodeAt(Un)?(a=":",Un++):(a=null,0===Mn&&i('":"')),null!==a&&null!==(o=ue())?(58===n.charCodeAt(Un)?(l=":",Un++):(l=null,0===Mn&&i('":"')),null!==l&&null!==(u=ce())?e=[e,t,r,s,a,o,l,u]:(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m),null===e&&(m=Un,"::"===n.substr(Un,2)?(e="::",Un+=2):(e=null,0===Mn&&i('"::"')),null!==e&&null!==(t=ue())?(58===n.charCodeAt(Un)?(r=":",Un++):(r=null,0===Mn&&i('":"')),null!==r&&null!==(s=ue())?(58===n.charCodeAt(Un)?(a=":",Un++):(a=null,0===Mn&&i('":"')),null!==a&&null!==(o=ce())?e=[e,t,r,s,a,o]:(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m),null===e&&(m=Un,"::"===n.substr(Un,2)?(e="::",Un+=2):(e=null,0===Mn&&i('"::"')),null!==e&&null!==(t=ue())?(58===n.charCodeAt(Un)?(r=":",Un++):(r=null,0===Mn&&i('":"')),null!==r&&null!==(s=ce())?e=[e,t,r,s]:(e=null,Un=m)):(e=null,Un=m),null===e&&(m=Un,"::"===n.substr(Un,2)?(e="::",Un+=2):(e=null,0===Mn&&i('"::"')),null!==e&&null!==(t=ce())?e=[e,t]:(e=null,Un=m),null===e&&(m=Un,"::"===n.substr(Un,2)?(e="::",Un+=2):(e=null,0===Mn&&i('"::"')),null!==e&&null!==(t=ue())?e=[e,t]:(e=null,Un=m),null===e&&(m=Un,null!==(e=ue())?("::"===n.substr(Un,2)?(t="::",Un+=2):(t=null,0===Mn&&i('"::"')),null!==t&&null!==(r=ue())?(58===n.charCodeAt(Un)?(s=":",Un++):(s=null,0===Mn&&i('":"')),null!==s&&null!==(a=ue())?(58===n.charCodeAt(Un)?(o=":",Un++):(o=null,0===Mn&&i('":"')),null!==o&&null!==(l=ue())?(58===n.charCodeAt(Un)?(u=":",Un++):(u=null,0===Mn&&i('":"')),null!==u&&null!==(c=ue())?(58===n.charCodeAt(Un)?(d=":",Un++):(d=null,0===Mn&&i('":"')),null!==d&&null!==(h=ce())?e=[e,t,r,s,a,o,l,u,c,d,h]:(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m),null===e&&(m=Un,null!==(e=ue())?(v=Un,58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(r=ue())?t=[t,r]:(t=null,Un=v),null!==(t=null!==t?t:"")?("::"===n.substr(Un,2)?(r="::",Un+=2):(r=null,0===Mn&&i('"::"')),null!==r&&null!==(s=ue())?(58===n.charCodeAt(Un)?(a=":",Un++):(a=null,0===Mn&&i('":"')),null!==a&&null!==(o=ue())?(58===n.charCodeAt(Un)?(l=":",Un++):(l=null,0===Mn&&i('":"')),null!==l&&null!==(u=ue())?(58===n.charCodeAt(Un)?(c=":",Un++):(c=null,0===Mn&&i('":"')),null!==c&&null!==(d=ce())?e=[e,t,r,s,a,o,l,u,c,d]:(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m),null===e&&(m=Un,null!==(e=ue())?(v=Un,58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(r=ue())?t=[t,r]:(t=null,Un=v),null!==(t=null!==t?t:"")?(v=Un,58===n.charCodeAt(Un)?(r=":",Un++):(r=null,0===Mn&&i('":"')),null!==r&&null!==(s=ue())?r=[r,s]:(r=null,Un=v),null!==(r=null!==r?r:"")?("::"===n.substr(Un,2)?(s="::",Un+=2):(s=null,0===Mn&&i('"::"')),null!==s&&null!==(a=ue())?(58===n.charCodeAt(Un)?(o=":",Un++):(o=null,0===Mn&&i('":"')),null!==o&&null!==(l=ue())?(58===n.charCodeAt(Un)?(u=":",Un++):(u=null,0===Mn&&i('":"')),null!==u&&null!==(c=ce())?e=[e,t,r,s,a,o,l,u,c]:(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m),null===e&&(m=Un,null!==(e=ue())?(v=Un,58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(r=ue())?t=[t,r]:(t=null,Un=v),null!==(t=null!==t?t:"")?(v=Un,58===n.charCodeAt(Un)?(r=":",Un++):(r=null,0===Mn&&i('":"')),null!==r&&null!==(s=ue())?r=[r,s]:(r=null,Un=v),null!==(r=null!==r?r:"")?(v=Un,58===n.charCodeAt(Un)?(s=":",Un++):(s=null,0===Mn&&i('":"')),null!==s&&null!==(a=ue())?s=[s,a]:(s=null,Un=v),null!==(s=null!==s?s:"")?("::"===n.substr(Un,2)?(a="::",Un+=2):(a=null,0===Mn&&i('"::"')),null!==a&&null!==(o=ue())?(58===n.charCodeAt(Un)?(l=":",Un++):(l=null,0===Mn&&i('":"')),null!==l&&null!==(u=ce())?e=[e,t,r,s,a,o,l,u]:(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m),null===e&&(m=Un,null!==(e=ue())?(v=Un,58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(r=ue())?t=[t,r]:(t=null,Un=v),null!==(t=null!==t?t:"")?(v=Un,58===n.charCodeAt(Un)?(r=":",Un++):(r=null,0===Mn&&i('":"')),null!==r&&null!==(s=ue())?r=[r,s]:(r=null,Un=v),null!==(r=null!==r?r:"")?(v=Un,58===n.charCodeAt(Un)?(s=":",Un++):(s=null,0===Mn&&i('":"')),null!==s&&null!==(a=ue())?s=[s,a]:(s=null,Un=v),null!==(s=null!==s?s:"")?(v=Un,58===n.charCodeAt(Un)?(a=":",Un++):(a=null,0===Mn&&i('":"')),null!==a&&null!==(o=ue())?a=[a,o]:(a=null,Un=v),null!==(a=null!==a?a:"")?("::"===n.substr(Un,2)?(o="::",Un+=2):(o=null,0===Mn&&i('"::"')),null!==o&&null!==(l=ce())?e=[e,t,r,s,a,o,l]:(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m),null===e&&(m=Un,null!==(e=ue())?(v=Un,58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(r=ue())?t=[t,r]:(t=null,Un=v),null!==(t=null!==t?t:"")?(v=Un,58===n.charCodeAt(Un)?(r=":",Un++):(r=null,0===Mn&&i('":"')),null!==r&&null!==(s=ue())?r=[r,s]:(r=null,Un=v),null!==(r=null!==r?r:"")?(v=Un,58===n.charCodeAt(Un)?(s=":",Un++):(s=null,0===Mn&&i('":"')),null!==s&&null!==(a=ue())?s=[s,a]:(s=null,Un=v),null!==(s=null!==s?s:"")?(v=Un,58===n.charCodeAt(Un)?(a=":",Un++):(a=null,0===Mn&&i('":"')),null!==a&&null!==(o=ue())?a=[a,o]:(a=null,Un=v),null!==(a=null!==a?a:"")?(v=Un,58===n.charCodeAt(Un)?(o=":",Un++):(o=null,0===Mn&&i('":"')),null!==o&&null!==(l=ue())?o=[o,l]:(o=null,Un=v),null!==(o=null!==o?o:"")?("::"===n.substr(Un,2)?(l="::",Un+=2):(l=null,0===Mn&&i('"::"')),null!==l&&null!==(u=ue())?e=[e,t,r,s,a,o,l,u]:(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m),null===e&&(m=Un,null!==(e=ue())?(v=Un,58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(r=ue())?t=[t,r]:(t=null,Un=v),null!==(t=null!==t?t:"")?(v=Un,58===n.charCodeAt(Un)?(r=":",Un++):(r=null,0===Mn&&i('":"')),null!==r&&null!==(s=ue())?r=[r,s]:(r=null,Un=v),null!==(r=null!==r?r:"")?(v=Un,58===n.charCodeAt(Un)?(s=":",Un++):(s=null,0===Mn&&i('":"')),null!==s&&null!==(a=ue())?s=[s,a]:(s=null,Un=v),null!==(s=null!==s?s:"")?(v=Un,58===n.charCodeAt(Un)?(a=":",Un++):(a=null,0===Mn&&i('":"')),null!==a&&null!==(o=ue())?a=[a,o]:(a=null,Un=v),null!==(a=null!==a?a:"")?(v=Un,58===n.charCodeAt(Un)?(o=":",Un++):(o=null,0===Mn&&i('":"')),null!==o&&null!==(l=ue())?o=[o,l]:(o=null,Un=v),null!==(o=null!==o?o:"")?(v=Un,58===n.charCodeAt(Un)?(l=":",Un++):(l=null,0===Mn&&i('":"')),null!==l&&null!==(u=ue())?l=[l,u]:(l=null,Un=v),null!==(l=null!==l?l:"")?("::"===n.substr(Un,2)?(u="::",Un+=2):(u=null,0===Mn&&i('"::"')),null!==u?e=[e,t,r,s,a,o,l,u]:(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m)):(e=null,Un=m))))))))))))))),null!==e&&(e=function(e){return jn.host_type="IPv6",n.substring(Un,e)}(_)),null===e&&(Un=_),e}function ue(){var e,t,n,r,i;return i=Un,null!==(e=l())&&null!==(t=null!==(t=l())?t:"")&&null!==(n=null!==(n=l())?n:"")&&null!==(r=null!==(r=l())?r:"")?e=[e,t,n,r]:(e=null,Un=i),e}function ce(){var e,t,r,s;return s=Un,null!==(e=ue())?(58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t&&null!==(r=ue())?e=[e,t,r]:(e=null,Un=s)):(e=null,Un=s),null===e&&(e=de()),e}function de(){var e,t,r,s,a,o,l,u,c;return u=Un,c=Un,null!==(e=he())?(46===n.charCodeAt(Un)?(t=".",Un++):(t=null,0===Mn&&i('"."')),null!==t&&null!==(r=he())?(46===n.charCodeAt(Un)?(s=".",Un++):(s=null,0===Mn&&i('"."')),null!==s&&null!==(a=he())?(46===n.charCodeAt(Un)?(o=".",Un++):(o=null,0===Mn&&i('"."')),null!==o&&null!==(l=he())?e=[e,t,r,s,a,o,l]:(e=null,Un=c)):(e=null,Un=c)):(e=null,Un=c)):(e=null,Un=c),null!==e&&(e=function(e){return jn.host_type="IPv4",n.substring(Un,e)}(u)),null===e&&(Un=u),e}function he(){var e,t,r,s;return s=Un,"25"===n.substr(Un,2)?(e="25",Un+=2):(e=null,0===Mn&&i('"25"')),null!==e?(/^[0-5]/.test(n.charAt(Un))?(t=n.charAt(Un),Un++):(t=null,0===Mn&&i("[0-5]")),null!==t?e=[e,t]:(e=null,Un=s)):(e=null,Un=s),null===e&&(s=Un,50===n.charCodeAt(Un)?(e="2",Un++):(e=null,0===Mn&&i('"2"')),null!==e?(/^[0-4]/.test(n.charAt(Un))?(t=n.charAt(Un),Un++):(t=null,0===Mn&&i("[0-4]")),null!==t&&null!==(r=a())?e=[e,t,r]:(e=null,Un=s)):(e=null,Un=s),null===e&&(s=Un,49===n.charCodeAt(Un)?(e="1",Un++):(e=null,0===Mn&&i('"1"')),null!==e&&null!==(t=a())&&null!==(r=a())?e=[e,t,r]:(e=null,Un=s),null===e&&(s=Un,/^[1-9]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[1-9]")),null!==e&&null!==(t=a())?e=[e,t]:(e=null,Un=s),null===e&&(e=a())))),e}function fe(){var e,t,n,r,i,s,o;return s=Un,o=Un,e=a(),null!==(e=null!==e?e:"")&&null!==(t=null!==(t=a())?t:"")&&null!==(n=null!==(n=a())?n:"")&&null!==(r=null!==(r=a())?r:"")&&null!==(i=null!==(i=a())?i:"")?e=[e,t,n,r,i]:(e=null,Un=o),null!==e&&(e=function(e,t){return t=parseInt(t.join("")),jn.port=t,t}(0,e)),null===e&&(Un=s),e}function pe(){var e,t,r,s;for(e=[],s=Un,59===n.charCodeAt(Un)?(t=";",Un++):(t=null,0===Mn&&i('";"')),null!==t&&null!==(r=_e())?t=[t,r]:(t=null,Un=s);null!==t;)e.push(t),s=Un,59===n.charCodeAt(Un)?(t=";",Un++):(t=null,0===Mn&&i('";"')),null!==t&&null!==(r=_e())?t=[t,r]:(t=null,Un=s);return e}function _e(){var e;return null===(e=me())&&null===(e=ve())&&null===(e=ge())&&null===(e=ye())&&null===(e=Te())&&null===(e=Ce())&&(e=Se()),e}function me(){var e,t,r,s;return r=Un,s=Un,"transport="===n.substr(Un,10).toLowerCase()?(e=n.substr(Un,10),Un+=10):(e=null,0===Mn&&i('"transport="')),null!==e?("udp"===n.substr(Un,3).toLowerCase()?(t=n.substr(Un,3),Un+=3):(t=null,0===Mn&&i('"udp"')),null===t&&("tcp"===n.substr(Un,3).toLowerCase()?(t=n.substr(Un,3),Un+=3):(t=null,0===Mn&&i('"tcp"')),null===t&&("sctp"===n.substr(Un,4).toLowerCase()?(t=n.substr(Un,4),Un+=4):(t=null,0===Mn&&i('"sctp"')),null===t&&("tls"===n.substr(Un,3).toLowerCase()?(t=n.substr(Un,3),Un+=3):(t=null,0===Mn&&i('"tls"')),null===t&&(t=A())))),null!==t?e=[e,t]:(e=null,Un=s)):(e=null,Un=s),null!==e&&(e=function(e,t){jn.uri_params||(jn.uri_params={}),jn.uri_params.transport=t.toLowerCase()}(0,e[1])),null===e&&(Un=r),e}function ve(){var e,t,r,s;return r=Un,s=Un,"user="===n.substr(Un,5).toLowerCase()?(e=n.substr(Un,5),Un+=5):(e=null,0===Mn&&i('"user="')),null!==e?("phone"===n.substr(Un,5).toLowerCase()?(t=n.substr(Un,5),Un+=5):(t=null,0===Mn&&i('"phone"')),null===t&&("ip"===n.substr(Un,2).toLowerCase()?(t=n.substr(Un,2),Un+=2):(t=null,0===Mn&&i('"ip"')),null===t&&(t=A())),null!==t?e=[e,t]:(e=null,Un=s)):(e=null,Un=s),null!==e&&(e=function(e,t){jn.uri_params||(jn.uri_params={}),jn.uri_params.user=t.toLowerCase()}(0,e[1])),null===e&&(Un=r),e}function ge(){var e,t,r,s;return r=Un,s=Un,"method="===n.substr(Un,7).toLowerCase()?(e=n.substr(Un,7),Un+=7):(e=null,0===Mn&&i('"method="')),null!==e&&null!==(t=at())?e=[e,t]:(e=null,Un=s),null!==e&&(e=function(e,t){jn.uri_params||(jn.uri_params={}),jn.uri_params.method=t}(0,e[1])),null===e&&(Un=r),e}function ye(){var e,t,r,s;return r=Un,s=Un,"ttl="===n.substr(Un,4).toLowerCase()?(e=n.substr(Un,4),Un+=4):(e=null,0===Mn&&i('"ttl="')),null!==e&&null!==(t=Tn())?e=[e,t]:(e=null,Un=s),null!==e&&(e=function(e,t){jn.params||(jn.params={}),jn.params.ttl=t}(0,e[1])),null===e&&(Un=r),e}function Te(){var e,t,r,s;return r=Un,s=Un,"maddr="===n.substr(Un,6).toLowerCase()?(e=n.substr(Un,6),Un+=6):(e=null,0===Mn&&i('"maddr="')),null!==e&&null!==(t=re())?e=[e,t]:(e=null,Un=s),null!==e&&(e=function(e,t){jn.uri_params||(jn.uri_params={}),jn.uri_params.maddr=t}(0,e[1])),null===e&&(Un=r),e}function Ce(){var e,t,r,s,a,o;return s=Un,a=Un,"lr"===n.substr(Un,2).toLowerCase()?(e=n.substr(Un,2),Un+=2):(e=null,0===Mn&&i('"lr"')),null!==e?(o=Un,61===n.charCodeAt(Un)?(t="=",Un++):(t=null,0===Mn&&i('"="')),null!==t&&null!==(r=A())?t=[t,r]:(t=null,Un=o),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(jn.uri_params||(jn.uri_params={}),e=void(jn.uri_params.lr=void 0)),null===e&&(Un=s),e}function Se(){var e,t,r,s,a,o;return s=Un,a=Un,null!==(e=Ee())?(o=Un,61===n.charCodeAt(Un)?(t="=",Un++):(t=null,0===Mn&&i('"="')),null!==t&&null!==(r=be())?t=[t,r]:(t=null,Un=o),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=function(e,t,n){jn.uri_params||(jn.uri_params={}),n=void 0===n?void 0:n[1],jn.uri_params[t.toLowerCase()]=n}(0,e[0],e[1])),null===e&&(Un=s),e}function Ee(){var e,t,n;if(n=Un,null!==(t=Re()))for(e=[];null!==t;)e.push(t),t=Re();else e=null;return null!==e&&(e=e.join("")),null===e&&(Un=n),e}function be(){var e,t,n;if(n=Un,null!==(t=Re()))for(e=[];null!==t;)e.push(t),t=Re();else e=null;return null!==e&&(e=e.join("")),null===e&&(Un=n),e}function Re(){var e;return null===(e=Ae())&&null===(e=m())&&(e=g()),e}function Ae(){var e;return 91===n.charCodeAt(Un)?(e="[",Un++):(e=null,0===Mn&&i('"["')),null===e&&(93===n.charCodeAt(Un)?(e="]",Un++):(e=null,0===Mn&&i('"]"')),null===e&&(47===n.charCodeAt(Un)?(e="/",Un++):(e=null,0===Mn&&i('"/"')),null===e&&(58===n.charCodeAt(Un)?(e=":",Un++):(e=null,0===Mn&&i('":"')),null===e&&(38===n.charCodeAt(Un)?(e="&",Un++):(e=null,0===Mn&&i('"&"')),null===e&&(43===n.charCodeAt(Un)?(e="+",Un++):(e=null,0===Mn&&i('"+"')),null===e&&(36===n.charCodeAt(Un)?(e="$",Un++):(e=null,0===Mn&&i('"$"')))))))),e}function we(){var e,t,r,s,a,o,l;if(o=Un,63===n.charCodeAt(Un)?(e="?",Un++):(e=null,0===Mn&&i('"?"')),null!==e)if(null!==(t=Ie())){for(r=[],l=Un,38===n.charCodeAt(Un)?(s="&",Un++):(s=null,0===Mn&&i('"&"')),null!==s&&null!==(a=Ie())?s=[s,a]:(s=null,Un=l);null!==s;)r.push(s),l=Un,38===n.charCodeAt(Un)?(s="&",Un++):(s=null,0===Mn&&i('"&"')),null!==s&&null!==(a=Ie())?s=[s,a]:(s=null,Un=l);null!==r?e=[e,t,r]:(e=null,Un=o)}else e=null,Un=o;else e=null,Un=o;return e}function Ie(){var e,t,r,s,a;return s=Un,a=Un,null!==(e=ke())?(61===n.charCodeAt(Un)?(t="=",Un++):(t=null,0===Mn&&i('"="')),null!==t&&null!==(r=Oe())?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=function(e,t,n){t=t.join("").toLowerCase(),n=n.join(""),jn.uri_headers||(jn.uri_headers={}),jn.uri_headers[t]?jn.uri_headers[t].push(n):jn.uri_headers[t]=[n]}(0,e[0],e[2])),null===e&&(Un=s),e}function ke(){var e,t;if(null===(t=Pe())&&null===(t=m())&&(t=g()),null!==t)for(e=[];null!==t;)e.push(t),null===(t=Pe())&&null===(t=m())&&(t=g());else e=null;return e}function Oe(){var e,t;for(e=[],null===(t=Pe())&&null===(t=m())&&(t=g());null!==t;)e.push(t),null===(t=Pe())&&null===(t=m())&&(t=g());return e}function Pe(){var e;return 91===n.charCodeAt(Un)?(e="[",Un++):(e=null,0===Mn&&i('"["')),null===e&&(93===n.charCodeAt(Un)?(e="]",Un++):(e=null,0===Mn&&i('"]"')),null===e&&(47===n.charCodeAt(Un)?(e="/",Un++):(e=null,0===Mn&&i('"/"')),null===e&&(63===n.charCodeAt(Un)?(e="?",Un++):(e=null,0===Mn&&i('"?"')),null===e&&(58===n.charCodeAt(Un)?(e=":",Un++):(e=null,0===Mn&&i('":"')),null===e&&(43===n.charCodeAt(Un)?(e="+",Un++):(e=null,0===Mn&&i('"+"')),null===e&&(36===n.charCodeAt(Un)?(e="$",Un++):(e=null,0===Mn&&i('"$"')))))))),e}function xe(){var e,t,n,r,i,s;return s=Un,null!==(e=at())&&null!==(t=h())&&null!==(n=Ne())&&null!==(r=h())&&null!==(i=$e())?e=[e,t,n,r,i]:(e=null,Un=s),e}function Ne(){var e;return null===(e=z())&&(e=De()),e}function De(){var e,t,r,s;return s=Un,null!==(e=Ve())?(58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null!==t?(null===(r=Ue())&&(r=qe()),null!==r?e=[e,t,r]:(e=null,Un=s)):(e=null,Un=s)):(e=null,Un=s),e}function Ue(){var e,t,r,s,a;return s=Un,null===(e=Me())&&(e=Le()),null!==e?(a=Un,63===n.charCodeAt(Un)?(t="?",Un++):(t=null,0===Mn&&i('"?"')),null!==t&&null!==(r=Ye())?t=[t,r]:(t=null,Un=a),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,Un=s)):(e=null,Un=s),e}function Me(){var e,t,r,s;return s=Un,"//"===n.substr(Un,2)?(e="//",Un+=2):(e=null,0===Mn&&i('"//"')),null!==e&&null!==(t=Je())&&null!==(r=null!==(r=Le())?r:"")?e=[e,t,r]:(e=null,Un=s),e}function Le(){var e,t,r;return r=Un,47===n.charCodeAt(Un)?(e="/",Un++):(e=null,0===Mn&&i('"/"')),null!==e&&null!==(t=je())?e=[e,t]:(e=null,Un=r),e}function qe(){var e,t,n,r;if(r=Un,null!==(e=Fe())){for(t=[],n=He();null!==n;)t.push(n),n=He();null!==t?e=[e,t]:(e=null,Un=r)}else e=null,Un=r;return e}function He(){var e;return null===(e=_())&&null===(e=m())&&(e=g()),e}function Fe(){var e;return null===(e=m())&&null===(e=g())&&(59===n.charCodeAt(Un)?(e=";",Un++):(e=null,0===Mn&&i('";"')),null===e&&(63===n.charCodeAt(Un)?(e="?",Un++):(e=null,0===Mn&&i('"?"')),null===e&&(58===n.charCodeAt(Un)?(e=":",Un++):(e=null,0===Mn&&i('":"')),null===e&&(64===n.charCodeAt(Un)?(e="@",Un++):(e=null,0===Mn&&i('"@"')),null===e&&(38===n.charCodeAt(Un)?(e="&",Un++):(e=null,0===Mn&&i('"&"')),null===e&&(61===n.charCodeAt(Un)?(e="=",Un++):(e=null,0===Mn&&i('"="')),null===e&&(43===n.charCodeAt(Un)?(e="+",Un++):(e=null,0===Mn&&i('"+"')),null===e&&(36===n.charCodeAt(Un)?(e="$",Un++):(e=null,0===Mn&&i('"$"')),null===e&&(44===n.charCodeAt(Un)?(e=",",Un++):(e=null,0===Mn&&i('","'))))))))))),e}function je(){var e,t,r,s,a,o;if(a=Un,null!==(e=Ge())){for(t=[],o=Un,47===n.charCodeAt(Un)?(r="/",Un++):(r=null,0===Mn&&i('"/"')),null!==r&&null!==(s=Ge())?r=[r,s]:(r=null,Un=o);null!==r;)t.push(r),o=Un,47===n.charCodeAt(Un)?(r="/",Un++):(r=null,0===Mn&&i('"/"')),null!==r&&null!==(s=Ge())?r=[r,s]:(r=null,Un=o);null!==t?e=[e,t]:(e=null,Un=a)}else e=null,Un=a;return e}function Ge(){var e,t,r,s,a,o;for(a=Un,e=[],t=We();null!==t;)e.push(t),t=We();if(null!==e){for(t=[],o=Un,59===n.charCodeAt(Un)?(r=";",Un++):(r=null,0===Mn&&i('";"')),null!==r&&null!==(s=Be())?r=[r,s]:(r=null,Un=o);null!==r;)t.push(r),o=Un,59===n.charCodeAt(Un)?(r=";",Un++):(r=null,0===Mn&&i('";"')),null!==r&&null!==(s=Be())?r=[r,s]:(r=null,Un=o);null!==t?e=[e,t]:(e=null,Un=a)}else e=null,Un=a;return e}function Be(){var e,t;for(e=[],t=We();null!==t;)e.push(t),t=We();return e}function We(){var e;return null===(e=m())&&null===(e=g())&&(58===n.charCodeAt(Un)?(e=":",Un++):(e=null,0===Mn&&i('":"')),null===e&&(64===n.charCodeAt(Un)?(e="@",Un++):(e=null,0===Mn&&i('"@"')),null===e&&(38===n.charCodeAt(Un)?(e="&",Un++):(e=null,0===Mn&&i('"&"')),null===e&&(61===n.charCodeAt(Un)?(e="=",Un++):(e=null,0===Mn&&i('"="')),null===e&&(43===n.charCodeAt(Un)?(e="+",Un++):(e=null,0===Mn&&i('"+"')),null===e&&(36===n.charCodeAt(Un)?(e="$",Un++):(e=null,0===Mn&&i('"$"')),null===e&&(44===n.charCodeAt(Un)?(e=",",Un++):(e=null,0===Mn&&i('","'))))))))),e}function Ve(){var e,t,r,s,l;if(s=Un,l=Un,null!==(e=o())){for(t=[],null===(r=o())&&null===(r=a())&&(43===n.charCodeAt(Un)?(r="+",Un++):(r=null,0===Mn&&i('"+"')),null===r&&(45===n.charCodeAt(Un)?(r="-",Un++):(r=null,0===Mn&&i('"-"')),null===r&&(46===n.charCodeAt(Un)?(r=".",Un++):(r=null,0===Mn&&i('"."')))));null!==r;)t.push(r),null===(r=o())&&null===(r=a())&&(43===n.charCodeAt(Un)?(r="+",Un++):(r=null,0===Mn&&i('"+"')),null===r&&(45===n.charCodeAt(Un)?(r="-",Un++):(r=null,0===Mn&&i('"-"')),null===r&&(46===n.charCodeAt(Un)?(r=".",Un++):(r=null,0===Mn&&i('"."')))));null!==t?e=[e,t]:(e=null,Un=l)}else e=null,Un=l;return null!==e&&(e=function(e){jn.scheme=n.substring(Un,e)}(s)),null===e&&(Un=s),e}function Je(){var e;return null===(e=Ke())&&(e=ze()),e}function Ke(){var e,t,r,s;return r=Un,s=Un,null!==(e=Q())?(64===n.charCodeAt(Un)?(t="@",Un++):(t=null,0===Mn&&i('"@"')),null!==t?e=[e,t]:(e=null,Un=s)):(e=null,Un=s),null!==(e=null!==e?e:"")&&null!==(t=ne())?e=[e,t]:(e=null,Un=r),e=null!==e?e:""}function ze(){var e,t;if(null===(t=m())&&null===(t=g())&&(36===n.charCodeAt(Un)?(t="$",Un++):(t=null,0===Mn&&i('"$"')),null===t&&(44===n.charCodeAt(Un)?(t=",",Un++):(t=null,0===Mn&&i('","')),null===t&&(59===n.charCodeAt(Un)?(t=";",Un++):(t=null,0===Mn&&i('";"')),null===t&&(58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null===t&&(64===n.charCodeAt(Un)?(t="@",Un++):(t=null,0===Mn&&i('"@"')),null===t&&(38===n.charCodeAt(Un)?(t="&",Un++):(t=null,0===Mn&&i('"&"')),null===t&&(61===n.charCodeAt(Un)?(t="=",Un++):(t=null,0===Mn&&i('"="')),null===t&&(43===n.charCodeAt(Un)?(t="+",Un++):(t=null,0===Mn&&i('"+"')))))))))),null!==t)for(e=[];null!==t;)e.push(t),null===(t=m())&&null===(t=g())&&(36===n.charCodeAt(Un)?(t="$",Un++):(t=null,0===Mn&&i('"$"')),null===t&&(44===n.charCodeAt(Un)?(t=",",Un++):(t=null,0===Mn&&i('","')),null===t&&(59===n.charCodeAt(Un)?(t=";",Un++):(t=null,0===Mn&&i('";"')),null===t&&(58===n.charCodeAt(Un)?(t=":",Un++):(t=null,0===Mn&&i('":"')),null===t&&(64===n.charCodeAt(Un)?(t="@",Un++):(t=null,0===Mn&&i('"@"')),null===t&&(38===n.charCodeAt(Un)?(t="&",Un++):(t=null,0===Mn&&i('"&"')),null===t&&(61===n.charCodeAt(Un)?(t="=",Un++):(t=null,0===Mn&&i('"="')),null===t&&(43===n.charCodeAt(Un)?(t="+",Un++):(t=null,0===Mn&&i('"+"'))))))))));else e=null;return e}function Ye(){var e,t;for(e=[],t=He();null!==t;)e.push(t),t=He();return e}function $e(){var e,t,r,s,o,l,u,c;if(u=Un,c=Un,"sip"===n.substr(Un,3).toLowerCase()?(e=n.substr(Un,3),Un+=3):(e=null,0===Mn&&i('"SIP"')),null!==e)if(47===n.charCodeAt(Un)?(t="/",Un++):(t=null,0===Mn&&i('"/"')),null!==t){if(null!==(s=a()))for(r=[];null!==s;)r.push(s),s=a();else r=null;if(null!==r)if(46===n.charCodeAt(Un)?(s=".",Un++):(s=null,0===Mn&&i('"."')),null!==s){if(null!==(l=a()))for(o=[];null!==l;)o.push(l),l=a();else o=null;null!==o?e=[e,t,r,s,o]:(e=null,Un=c)}else e=null,Un=c;else e=null,Un=c}else e=null,Un=c;else e=null,Un=c;return null!==e&&(e=function(e){jn.sip_version=n.substring(Un,e)}(u)),null===e&&(Un=u),e}function Xe(){var e;return"INVITE"===n.substr(Un,6)?(e="INVITE",Un+=6):(e=null,0===Mn&&i('"INVITE"')),e}function Qe(){var e;return"ACK"===n.substr(Un,3)?(e="ACK",Un+=3):(e=null,0===Mn&&i('"ACK"')),e}function Ze(){var e;return"OPTIONS"===n.substr(Un,7)?(e="OPTIONS",Un+=7):(e=null,0===Mn&&i('"OPTIONS"')),e}function et(){var e;return"BYE"===n.substr(Un,3)?(e="BYE",Un+=3):(e=null,0===Mn&&i('"BYE"')),e}function tt(){var e;return"CANCEL"===n.substr(Un,6)?(e="CANCEL",Un+=6):(e=null,0===Mn&&i('"CANCEL"')),e}function nt(){var e;return"REGISTER"===n.substr(Un,8)?(e="REGISTER",Un+=8):(e=null,0===Mn&&i('"REGISTER"')),e}function rt(){var e;return"SUBSCRIBE"===n.substr(Un,9)?(e="SUBSCRIBE",Un+=9):(e=null,0===Mn&&i('"SUBSCRIBE"')),e}function it(){var e;return"NOTIFY"===n.substr(Un,6)?(e="NOTIFY",Un+=6):(e=null,0===Mn&&i('"NOTIFY"')),e}function st(){var e;return"REFER"===n.substr(Un,5)?(e="REFER",Un+=5):(e=null,0===Mn&&i('"REFER"')),e}function at(){var e,t;return t=Un,null===(e=Xe())&&null===(e=Qe())&&null===(e=Ze())&&null===(e=et())&&null===(e=tt())&&null===(e=nt())&&null===(e=rt())&&null===(e=it())&&null===(e=st())&&(e=A()),null!==e&&(e=function(e){return jn.method=n.substring(Un,e),jn.method}(t)),null===e&&(Un=t),e}function ot(){var e,t,n,r,i,s;return s=Un,null!==(e=$e())&&null!==(t=h())&&null!==(n=lt())&&null!==(r=h())&&null!==(i=ct())?e=[e,t,n,r,i]:(e=null,Un=s),e}function lt(){var e,t;return t=Un,null!==(e=ut())&&(e=function(e,t){jn.status_code=parseInt(t.join(""))}(0,e)),null===e&&(Un=t),e}function ut(){var e,t,n,r;return r=Un,null!==(e=a())&&null!==(t=a())&&null!==(n=a())?e=[e,t,n]:(e=null,Un=r),e}function ct(){var e,t,r;for(r=Un,e=[],null===(t=_())&&null===(t=m())&&null===(t=g())&&null===(t=b())&&null===(t=R())&&null===(t=h())&&(t=f());null!==t;)e.push(t),null===(t=_())&&null===(t=m())&&null===(t=g())&&null===(t=b())&&null===(t=R())&&null===(t=h())&&(t=f());return null!==e&&(e=function(e){jn.reason_phrase=n.substring(Un,e)}(r)),null===e&&(Un=r),e}function dt(){var e,t,n,r,i,s,a;if(i=Un,s=Un,null===(e=K())&&(e=ht()),null!==e){for(t=[],a=Un,null!==(n=L())&&null!==(r=pt())?n=[n,r]:(n=null,Un=a);null!==n;)t.push(n),a=Un,null!==(n=L())&&null!==(r=pt())?n=[n,r]:(n=null,Un=a);null!==t?e=[e,t]:(e=null,Un=s)}else e=null,Un=s;return null!==e&&(e=function(e){var t;jn.multi_header||(jn.multi_header=[]);try{t=new Fn(jn.uri,jn.display_name,jn.params),delete jn.uri,delete jn.display_name,delete jn.params}catch(e){t=null}jn.multi_header.push({possition:Un,offset:e,parsed:t})}(i)),null===e&&(Un=i),e}function ht(){var e,t,n,r,i;return i=Un,e=ft(),null!==(e=null!==e?e:"")&&null!==(t=U())&&null!==(n=z())&&null!==(r=D())?e=[e,t,n,r]:(e=null,Un=i),e}function ft(){var e,t,r,i,s,a,o;if(s=Un,a=Un,null!==(e=A())){for(t=[],o=Un,null!==(r=y())&&null!==(i=A())?r=[r,i]:(r=null,Un=o);null!==r;)t.push(r),o=Un,null!==(r=y())&&null!==(i=A())?r=[r,i]:(r=null,Un=o);null!==t?e=[e,t]:(e=null,Un=a)}else e=null,Un=a;return null===e&&(e=B()),null!==e&&(e=function(e,t){'"'===(t=n.substring(Un,e).trim())[0]&&(t=t.substring(1,t.length-1)),jn.display_name=t}(s,e)),null===e&&(Un=s),e}function pt(){var e;return null===(e=_t())&&null===(e=mt())&&(e=yt()),e}function _t(){var e,t,r,s,a;return s=Un,a=Un,"q"===n.substr(Un,1).toLowerCase()?(e=n.substr(Un,1),Un++):(e=null,0===Mn&&i('"q"')),null!==e&&null!==(t=P())&&null!==(r=gt())?e=[e,t,r]:(e=null,Un=a),null!==e&&(e=function(e,t){jn.params||(jn.params={}),jn.params.q=t}(0,e[2])),null===e&&(Un=s),e}function mt(){var e,t,r,s,a;return s=Un,a=Un,"expires"===n.substr(Un,7).toLowerCase()?(e=n.substr(Un,7),Un+=7):(e=null,0===Mn&&i('"expires"')),null!==e&&null!==(t=P())&&null!==(r=vt())?e=[e,t,r]:(e=null,Un=a),null!==e&&(e=function(e,t){jn.params||(jn.params={}),jn.params.expires=t}(0,e[2])),null===e&&(Un=s),e}function vt(){var e,t,n;if(n=Un,null!==(t=a()))for(e=[];null!==t;)e.push(t),t=a();else e=null;return null!==e&&(e=function(e,t){return parseInt(t.join(""))}(0,e)),null===e&&(Un=n),e}function gt(){var e,t,r,s,o,l,u,c;return l=Un,u=Un,48===n.charCodeAt(Un)?(e="0",Un++):(e=null,0===Mn&&i('"0"')),null!==e?(c=Un,46===n.charCodeAt(Un)?(t=".",Un++):(t=null,0===Mn&&i('"."')),null!==t&&null!==(r=null!==(r=a())?r:"")&&null!==(s=null!==(s=a())?s:"")&&null!==(o=null!==(o=a())?o:"")?t=[t,r,s,o]:(t=null,Un=c),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,Un=u)):(e=null,Un=u),null!==e&&(e=function(e){return parseFloat(n.substring(Un,e))}(l)),null===e&&(Un=l),e}function yt(){var e,t,n,r,i,s;return r=Un,i=Un,null!==(e=A())?(s=Un,null!==(t=P())&&null!==(n=Tt())?t=[t,n]:(t=null,Un=s),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,Un=i)):(e=null,Un=i),null!==e&&(e=function(e,t,n){jn.params||(jn.params={}),n=void 0===n?void 0:n[1],jn.params[t.toLowerCase()]=n}(0,e[0],e[1])),null===e&&(Un=r),e}function Tt(){var e;return null===(e=A())&&null===(e=re())&&(e=B()),e}function Ct(){var e;return"render"===n.substr(Un,6).toLowerCase()?(e=n.substr(Un,6),Un+=6):(e=null,0===Mn&&i('"render"')),null===e&&("session"===n.substr(Un,7).toLowerCase()?(e=n.substr(Un,7),Un+=7):(e=null,0===Mn&&i('"session"')),null===e&&("icon"===n.substr(Un,4).toLowerCase()?(e=n.substr(Un,4),Un+=4):(e=null,0===Mn&&i('"icon"')),null===e&&("alert"===n.substr(Un,5).toLowerCase()?(e=n.substr(Un,5),Un+=5):(e=null,0===Mn&&i('"alert"')),null===e&&(e=A())))),e}function St(){var e;return null===(e=Et())&&(e=yt()),e}function Et(){var e,t,r,s;return s=Un,"handling"===n.substr(Un,8).toLowerCase()?(e=n.substr(Un,8),Un+=8):(e=null,0===Mn&&i('"handling"')),null!==e&&null!==(t=P())?("optional"===n.substr(Un,8).toLowerCase()?(r=n.substr(Un,8),Un+=8):(r=null,0===Mn&&i('"optional"')),null===r&&("required"===n.substr(Un,8).toLowerCase()?(r=n.substr(Un,8),Un+=8):(r=null,0===Mn&&i('"required"')),null===r&&(r=A())),null!==r?e=[e,t,r]:(e=null,Un=s)):(e=null,Un=s),e}function bt(){var e,t,n,r,i,s,a,o;if(a=Un,null!==(e=Rt()))if(null!==(t=O()))if(null!==(n=Ot())){for(r=[],o=Un,null!==(i=L())&&null!==(s=Pt())?i=[i,s]:(i=null,Un=o);null!==i;)r.push(i),o=Un,null!==(i=L())&&null!==(s=Pt())?i=[i,s]:(i=null,Un=o);null!==r?e=[e,t,n,r]:(e=null,Un=a)}else e=null,Un=a;else e=null,Un=a;else e=null,Un=a;return e}function Rt(){var e;return null===(e=At())&&(e=wt()),e}function At(){var e;return"text"===n.substr(Un,4).toLowerCase()?(e=n.substr(Un,4),Un+=4):(e=null,0===Mn&&i('"text"')),null===e&&("image"===n.substr(Un,5).toLowerCase()?(e=n.substr(Un,5),Un+=5):(e=null,0===Mn&&i('"image"')),null===e&&("audio"===n.substr(Un,5).toLowerCase()?(e=n.substr(Un,5),Un+=5):(e=null,0===Mn&&i('"audio"')),null===e&&("video"===n.substr(Un,5).toLowerCase()?(e=n.substr(Un,5),Un+=5):(e=null,0===Mn&&i('"video"')),null===e&&("application"===n.substr(Un,11).toLowerCase()?(e=n.substr(Un,11),Un+=11):(e=null,0===Mn&&i('"application"')),null===e&&(e=It()))))),e}function wt(){var e;return"message"===n.substr(Un,7).toLowerCase()?(e=n.substr(Un,7),Un+=7):(e=null,0===Mn&&i('"message"')),null===e&&("multipart"===n.substr(Un,9).toLowerCase()?(e=n.substr(Un,9),Un+=9):(e=null,0===Mn&&i('"multipart"')),null===e&&(e=It())),e}function It(){var e;return null===(e=A())&&(e=kt()),e}function kt(){var e,t,r;return r=Un,"x-"===n.substr(Un,2).toLowerCase()?(e=n.substr(Un,2),Un+=2):(e=null,0===Mn&&i('"x-"')),null!==e&&null!==(t=A())?e=[e,t]:(e=null,Un=r),e}function Ot(){var e;return null===(e=It())&&(e=A()),e}function Pt(){var e,t,n,r;return r=Un,null!==(e=A())&&null!==(t=P())&&null!==(n=xt())?e=[e,t,n]:(e=null,Un=r),e}function xt(){var e;return null===(e=A())&&(e=B()),e}function Nt(){var e,t,n;if(n=Un,null!==(t=a()))for(e=[];null!==t;)e.push(t),t=a();else e=null;return null!==e&&(e=function(e,t){jn.value=parseInt(t.join(""))}(0,e)),null===e&&(Un=n),e}function Dt(){var e,t,r,s,a,o;if(a=Un,null!==(e=w())){for(t=[],o=Un,46===n.charCodeAt(Un)?(r=".",Un++):(r=null,0===Mn&&i('"."')),null!==r&&null!==(s=w())?r=[r,s]:(r=null,Un=o);null!==r;)t.push(r),o=Un,46===n.charCodeAt(Un)?(r=".",Un++):(r=null,0===Mn&&i('"."')),null!==r&&null!==(s=w())?r=[r,s]:(r=null,Un=o);null!==t?e=[e,t]:(e=null,Un=a)}else e=null,Un=a;return e}function Ut(){var e;return null===(e=Mt())&&(e=yt()),e}function Mt(){var e,t,r,s,a;return s=Un,a=Un,"tag"===n.substr(Un,3).toLowerCase()?(e=n.substr(Un,3),Un+=3):(e=null,0===Mn&&i('"tag"')),null!==e&&null!==(t=P())&&null!==(r=A())?e=[e,t,r]:(e=null,Un=a),null!==e&&(e=function(e,t){jn.tag=t}(0,e[2])),null===e&&(Un=s),e}function Lt(){var e,t,r,s,a,o,l,u;if(l=Un,"digest"===n.substr(Un,6).toLowerCase()?(e=n.substr(Un,6),Un+=6):(e=null,0===Mn&&i('"Digest"')),null!==e)if(null!==(t=y()))if(null!==(r=Ft())){for(s=[],u=Un,null!==(a=M())&&null!==(o=Ft())?a=[a,o]:(a=null,Un=u);null!==a;)s.push(a),u=Un,null!==(a=M())&&null!==(o=Ft())?a=[a,o]:(a=null,Un=u);null!==s?e=[e,t,r,s]:(e=null,Un=l)}else e=null,Un=l;else e=null,Un=l;else e=null,Un=l;return null===e&&(e=qt()),e}function qt(){var e,t,n,r,i,s,a,o;if(a=Un,null!==(e=A()))if(null!==(t=y()))if(null!==(n=Ht())){for(r=[],o=Un,null!==(i=M())&&null!==(s=Ht())?i=[i,s]:(i=null,Un=o);null!==i;)r.push(i),o=Un,null!==(i=M())&&null!==(s=Ht())?i=[i,s]:(i=null,Un=o);null!==r?e=[e,t,n,r]:(e=null,Un=a)}else e=null,Un=a;else e=null,Un=a;else e=null,Un=a;return e}function Ht(){var e,t,n,r;return r=Un,null!==(e=A())&&null!==(t=P())?(null===(n=A())&&(n=B()),null!==n?e=[e,t,n]:(e=null,Un=r)):(e=null,Un=r),e}function Ft(){var e;return null===(e=jt())&&null===(e=Bt())&&null===(e=Vt())&&null===(e=Kt())&&null===(e=zt())&&null===(e=Yt())&&null===(e=$t())&&(e=Ht()),e}function jt(){var e,t,r,s;return s=Un,"realm"===n.substr(Un,5).toLowerCase()?(e=n.substr(Un,5),Un+=5):(e=null,0===Mn&&i('"realm"')),null!==e&&null!==(t=P())&&null!==(r=Gt())?e=[e,t,r]:(e=null,Un=s),e}function Gt(){var e,t;return t=Un,null!==(e=W())&&(e=function(e,t){jn.realm=t}(0,e)),null===e&&(Un=t),e}function Bt(){var e,t,r,s,a,o,l,u,c;if(u=Un,"domain"===n.substr(Un,6).toLowerCase()?(e=n.substr(Un,6),Un+=6):(e=null,0===Mn&&i('"domain"')),null!==e)if(null!==(t=P()))if(null!==(r=H()))if(null!==(s=Wt())){if(a=[],c=Un,null!==(l=h()))for(o=[];null!==l;)o.push(l),l=h();else o=null;for(null!==o&&null!==(l=Wt())?o=[o,l]:(o=null,Un=c);null!==o;){if(a.push(o),c=Un,null!==(l=h()))for(o=[];null!==l;)o.push(l),l=h();else o=null;null!==o&&null!==(l=Wt())?o=[o,l]:(o=null,Un=c)}null!==a&&null!==(o=F())?e=[e,t,r,s,a,o]:(e=null,Un=u)}else e=null,Un=u;else e=null,Un=u;else e=null,Un=u;else e=null,Un=u;return e}function Wt(){var e;return null===(e=De())&&(e=Le()),e}function Vt(){var e,t,r,s;return s=Un,"nonce"===n.substr(Un,5).toLowerCase()?(e=n.substr(Un,5),Un+=5):(e=null,0===Mn&&i('"nonce"')),null!==e&&null!==(t=P())&&null!==(r=Jt())?e=[e,t,r]:(e=null,Un=s),e}function Jt(){var e,t;return t=Un,null!==(e=W())&&(e=function(e,t){jn.nonce=t}(0,e)),null===e&&(Un=t),e}function Kt(){var e,t,r,s,a;return s=Un,a=Un,"opaque"===n.substr(Un,6).toLowerCase()?(e=n.substr(Un,6),Un+=6):(e=null,0===Mn&&i('"opaque"')),null!==e&&null!==(t=P())&&null!==(r=W())?e=[e,t,r]:(e=null,Un=a),null!==e&&(e=function(e,t){jn.opaque=t}(0,e[2])),null===e&&(Un=s),e}function zt(){var e,t,r,s,a;return s=Un,"stale"===n.substr(Un,5).toLowerCase()?(e=n.substr(Un,5),Un+=5):(e=null,0===Mn&&i('"stale"')),null!==e&&null!==(t=P())?(a=Un,"true"===n.substr(Un,4).toLowerCase()?(r=n.substr(Un,4),Un+=4):(r=null,0===Mn&&i('"true"')),null!==r&&(r=void(jn.stale=!0)),null===r&&(Un=a),null===r&&(a=Un,"false"===n.substr(Un,5).toLowerCase()?(r=n.substr(Un,5),Un+=5):(r=null,0===Mn&&i('"false"')),null!==r&&(r=void(jn.stale=!1)),null===r&&(Un=a)),null!==r?e=[e,t,r]:(e=null,Un=s)):(e=null,Un=s),e}function Yt(){var e,t,r,s,a;return s=Un,a=Un,"algorithm"===n.substr(Un,9).toLowerCase()?(e=n.substr(Un,9),Un+=9):(e=null,0===Mn&&i('"algorithm"')),null!==e&&null!==(t=P())?("md5"===n.substr(Un,3).toLowerCase()?(r=n.substr(Un,3),Un+=3):(r=null,0===Mn&&i('"MD5"')),null===r&&("md5-sess"===n.substr(Un,8).toLowerCase()?(r=n.substr(Un,8),Un+=8):(r=null,0===Mn&&i('"MD5-sess"')),null===r&&(r=A())),null!==r?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=function(e,t){jn.algorithm=t.toUpperCase()}(0,e[2])),null===e&&(Un=s),e}function $t(){var e,t,r,s,a,o,l,u,c,d;if(u=Un,"qop"===n.substr(Un,3).toLowerCase()?(e=n.substr(Un,3),Un+=3):(e=null,0===Mn&&i('"qop"')),null!==e)if(null!==(t=P()))if(null!==(r=H())){if(c=Un,null!==(s=Xt())){for(a=[],d=Un,44===n.charCodeAt(Un)?(o=",",Un++):(o=null,0===Mn&&i('","')),null!==o&&null!==(l=Xt())?o=[o,l]:(o=null,Un=d);null!==o;)a.push(o),d=Un,44===n.charCodeAt(Un)?(o=",",Un++):(o=null,0===Mn&&i('","')),null!==o&&null!==(l=Xt())?o=[o,l]:(o=null,Un=d);null!==a?s=[s,a]:(s=null,Un=c)}else s=null,Un=c;null!==s&&null!==(a=F())?e=[e,t,r,s,a]:(e=null,Un=u)}else e=null,Un=u;else e=null,Un=u;else e=null,Un=u;return e}function Xt(){var e,t;return t=Un,"auth-int"===n.substr(Un,8).toLowerCase()?(e=n.substr(Un,8),Un+=8):(e=null,0===Mn&&i('"auth-int"')),null===e&&("auth"===n.substr(Un,4).toLowerCase()?(e=n.substr(Un,4),Un+=4):(e=null,0===Mn&&i('"auth"')),null===e&&(e=A())),null!==e&&(e=function(e,t){jn.qop||(jn.qop=[]),jn.qop.push(t.toLowerCase())}(0,e)),null===e&&(Un=t),e}function Qt(){var e,t,n,r,i,s,a;if(i=Un,s=Un,null!==(e=ht())){for(t=[],a=Un,null!==(n=L())&&null!==(r=yt())?n=[n,r]:(n=null,Un=a);null!==n;)t.push(n),a=Un,null!==(n=L())&&null!==(r=yt())?n=[n,r]:(n=null,Un=a);null!==t?e=[e,t]:(e=null,Un=s)}else e=null,Un=s;return null!==e&&(e=function(e){var t;jn.multi_header||(jn.multi_header=[]);try{t=new Fn(jn.uri,jn.display_name,jn.params),delete jn.uri,delete jn.display_name,delete jn.params}catch(e){t=null}jn.multi_header.push({possition:Un,offset:e,parsed:t})}(i)),null===e&&(Un=i),e}function Zt(){var e;return null===(e=en())&&(e=yt()),e}function en(){var e,t,r,s,o,l;if(o=Un,l=Un,"cause"===n.substr(Un,5).toLowerCase()?(e=n.substr(Un,5),Un+=5):(e=null,0===Mn&&i('"cause"')),null!==e)if(null!==(t=P())){if(null!==(s=a()))for(r=[];null!==s;)r.push(s),s=a();else r=null;null!==r?e=[e,t,r]:(e=null,Un=l)}else e=null,Un=l;else e=null,Un=l;return null!==e&&(e=function(e,t){jn.cause=parseInt(t.join(""))}(0,e[2])),null===e&&(Un=o),e}function tn(){var e,t,n,r,i,s;if(i=Un,null!==(e=ht())){for(t=[],s=Un,null!==(n=L())&&null!==(r=yt())?n=[n,r]:(n=null,Un=s);null!==n;)t.push(n),s=Un,null!==(n=L())&&null!==(r=yt())?n=[n,r]:(n=null,Un=s);null!==t?e=[e,t]:(e=null,Un=i)}else e=null,Un=i;return e}function nn(){var e,t;return t=Un,"active"===n.substr(Un,6).toLowerCase()?(e=n.substr(Un,6),Un+=6):(e=null,0===Mn&&i('"active"')),null===e&&("pending"===n.substr(Un,7).toLowerCase()?(e=n.substr(Un,7),Un+=7):(e=null,0===Mn&&i('"pending"')),null===e&&("terminated"===n.substr(Un,10).toLowerCase()?(e=n.substr(Un,10),Un+=10):(e=null,0===Mn&&i('"terminated"')),null===e&&(e=A()))),null!==e&&(e=function(e){jn.state=n.substring(Un,e)}(t)),null===e&&(Un=t),e}function rn(){var e,t,r,s,a;return s=Un,a=Un,"reason"===n.substr(Un,6).toLowerCase()?(e=n.substr(Un,6),Un+=6):(e=null,0===Mn&&i('"reason"')),null!==e&&null!==(t=P())&&null!==(r=sn())?e=[e,t,r]:(e=null,Un=a),null!==e&&(e=function(e,t){void 0!==t&&(jn.reason=t)}(0,e[2])),null===e&&(Un=s),null===e&&(s=Un,a=Un,"expires"===n.substr(Un,7).toLowerCase()?(e=n.substr(Un,7),Un+=7):(e=null,0===Mn&&i('"expires"')),null!==e&&null!==(t=P())&&null!==(r=vt())?e=[e,t,r]:(e=null,Un=a),null!==e&&(e=function(e,t){void 0!==t&&(jn.expires=t)}(0,e[2])),null===e&&(Un=s),null===e&&(s=Un,a=Un,"retry_after"===n.substr(Un,11).toLowerCase()?(e=n.substr(Un,11),Un+=11):(e=null,0===Mn&&i('"retry_after"')),null!==e&&null!==(t=P())&&null!==(r=vt())?e=[e,t,r]:(e=null,Un=a),null!==e&&(e=function(e,t){void 0!==t&&(jn.retry_after=t)}(0,e[2])),null===e&&(Un=s),null===e&&(e=yt()))),e}function sn(){var e;return"deactivated"===n.substr(Un,11).toLowerCase()?(e=n.substr(Un,11),Un+=11):(e=null,0===Mn&&i('"deactivated"')),null===e&&("probation"===n.substr(Un,9).toLowerCase()?(e=n.substr(Un,9),Un+=9):(e=null,0===Mn&&i('"probation"')),null===e&&("rejected"===n.substr(Un,8).toLowerCase()?(e=n.substr(Un,8),Un+=8):(e=null,0===Mn&&i('"rejected"')),null===e&&("timeout"===n.substr(Un,7).toLowerCase()?(e=n.substr(Un,7),Un+=7):(e=null,0===Mn&&i('"timeout"')),null===e&&("giveup"===n.substr(Un,6).toLowerCase()?(e=n.substr(Un,6),Un+=6):(e=null,0===Mn&&i('"giveup"')),null===e&&("noresource"===n.substr(Un,10).toLowerCase()?(e=n.substr(Un,10),Un+=10):(e=null,0===Mn&&i('"noresource"')),null===e&&("invariant"===n.substr(Un,9).toLowerCase()?(e=n.substr(Un,9),Un+=9):(e=null,0===Mn&&i('"invariant"')),null===e&&(e=A()))))))),e}function an(){var e;return null===(e=Mt())&&(e=yt()),e}function on(){var e,t,n,r,i,s,a,o;if(a=Un,null!==(e=pn()))if(null!==(t=y()))if(null!==(n=vn())){for(r=[],o=Un,null!==(i=L())&&null!==(s=ln())?i=[i,s]:(i=null,Un=o);null!==i;)r.push(i),o=Un,null!==(i=L())&&null!==(s=ln())?i=[i,s]:(i=null,Un=o);null!==r?e=[e,t,n,r]:(e=null,Un=a)}else e=null,Un=a;else e=null,Un=a;else e=null,Un=a;return e}function ln(){var e;return null===(e=un())&&null===(e=cn())&&null===(e=dn())&&null===(e=hn())&&null===(e=fn())&&(e=yt()),e}function un(){var e,t,r,s,a;return s=Un,a=Un,"ttl"===n.substr(Un,3).toLowerCase()?(e=n.substr(Un,3),Un+=3):(e=null,0===Mn&&i('"ttl"')),null!==e&&null!==(t=P())&&null!==(r=Tn())?e=[e,t,r]:(e=null,Un=a),null!==e&&(e=function(e,t){jn.ttl=t}(0,e[2])),null===e&&(Un=s),e}function cn(){var e,t,r,s,a;return s=Un,a=Un,"maddr"===n.substr(Un,5).toLowerCase()?(e=n.substr(Un,5),Un+=5):(e=null,0===Mn&&i('"maddr"')),null!==e&&null!==(t=P())&&null!==(r=re())?e=[e,t,r]:(e=null,Un=a),null!==e&&(e=function(e,t){jn.maddr=t}(0,e[2])),null===e&&(Un=s),e}function dn(){var e,t,r,s,a;return s=Un,a=Un,"received"===n.substr(Un,8).toLowerCase()?(e=n.substr(Un,8),Un+=8):(e=null,0===Mn&&i('"received"')),null!==e&&null!==(t=P())?(null===(r=de())&&(r=le()),null!==r?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=function(e,t){jn.received=t}(0,e[2])),null===e&&(Un=s),e}function hn(){var e,t,r,s,a;return s=Un,a=Un,"branch"===n.substr(Un,6).toLowerCase()?(e=n.substr(Un,6),Un+=6):(e=null,0===Mn&&i('"branch"')),null!==e&&null!==(t=P())&&null!==(r=A())?e=[e,t,r]:(e=null,Un=a),null!==e&&(e=function(e,t){jn.branch=t}(0,e[2])),null===e&&(Un=s),e}function fn(){var e,t,r,s,o,l,u;if(o=Un,l=Un,"rport"===n.substr(Un,5).toLowerCase()?(e=n.substr(Un,5),Un+=5):(e=null,0===Mn&&i('"rport"')),null!==e){if(u=Un,null!==(t=P())){for(r=[],s=a();null!==s;)r.push(s),s=a();null!==r?t=[t,r]:(t=null,Un=u)}else t=null,Un=u;null!==(t=null!==t?t:"")?e=[e,t]:(e=null,Un=l)}else e=null,Un=l;return null!==e&&(e=void("undefined"!=typeof response_port&&(jn.rport=response_port.join("")))),null===e&&(Un=o),e}function pn(){var e,t,n,r,i,s;return s=Un,null!==(e=_n())&&null!==(t=O())&&null!==(n=A())&&null!==(r=O())&&null!==(i=mn())?e=[e,t,n,r,i]:(e=null,Un=s),e}function _n(){var e,t;return t=Un,"sip"===n.substr(Un,3).toLowerCase()?(e=n.substr(Un,3),Un+=3):(e=null,0===Mn&&i('"SIP"')),null===e&&(e=A()),null!==e&&(e=function(e,t){jn.protocol=t}(0,e)),null===e&&(Un=t),e}function mn(){var e,t;return t=Un,"udp"===n.substr(Un,3).toLowerCase()?(e=n.substr(Un,3),Un+=3):(e=null,0===Mn&&i('"UDP"')),null===e&&("tcp"===n.substr(Un,3).toLowerCase()?(e=n.substr(Un,3),Un+=3):(e=null,0===Mn&&i('"TCP"')),null===e&&("tls"===n.substr(Un,3).toLowerCase()?(e=n.substr(Un,3),Un+=3):(e=null,0===Mn&&i('"TLS"')),null===e&&("sctp"===n.substr(Un,4).toLowerCase()?(e=n.substr(Un,4),Un+=4):(e=null,0===Mn&&i('"SCTP"')),null===e&&(e=A())))),null!==e&&(e=function(e,t){jn.transport=t}(0,e)),null===e&&(Un=t),e}function vn(){var e,t,n,r,i;return r=Un,null!==(e=gn())?(i=Un,null!==(t=q())&&null!==(n=yn())?t=[t,n]:(t=null,Un=i),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,Un=r)):(e=null,Un=r),e}function gn(){var e,t;return t=Un,null===(e=de())&&null===(e=oe())&&(e=ie()),null!==e&&(e=function(e){jn.host=n.substring(Un,e)}(t)),null===e&&(Un=t),e}function yn(){var e,t,n,r,i,s,o;return s=Un,o=Un,e=a(),null!==(e=null!==e?e:"")&&null!==(t=null!==(t=a())?t:"")&&null!==(n=null!==(n=a())?n:"")&&null!==(r=null!==(r=a())?r:"")&&null!==(i=null!==(i=a())?i:"")?e=[e,t,n,r,i]:(e=null,Un=o),null!==e&&(e=function(e,t){jn.port=parseInt(t.join(""))}(0,e)),null===e&&(Un=s),e}function Tn(){var e,t,n,r,i;return r=Un,i=Un,null!==(e=a())&&null!==(t=null!==(t=a())?t:"")&&null!==(n=null!==(n=a())?n:"")?e=[e,t,n]:(e=null,Un=i),null!==e&&(e=function(e,t){return parseInt(t.join(""))}(0,e)),null===e&&(Un=r),e}function Cn(){var e,t;return t=Un,null!==(e=vt())&&(e=function(e,t){jn.expires=t}(0,e)),null===e&&(Un=t),e}function Sn(){var e;return null===(e=En())&&(e=yt()),e}function En(){var e,t,r,s,a;return s=Un,a=Un,"refresher"===n.substr(Un,9).toLowerCase()?(e=n.substr(Un,9),Un+=9):(e=null,0===Mn&&i('"refresher"')),null!==e&&null!==(t=P())?("uac"===n.substr(Un,3).toLowerCase()?(r=n.substr(Un,3),Un+=3):(r=null,0===Mn&&i('"uac"')),null===r&&("uas"===n.substr(Un,3).toLowerCase()?(r=n.substr(Un,3),Un+=3):(r=null,0===Mn&&i('"uas"'))),null!==r?e=[e,t,r]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=function(e,t){jn.refresher=t.toLowerCase()}(0,e[2])),null===e&&(Un=s),e}function bn(){var e,t;for(e=[],null===(t=E())&&null===(t=R())&&(t=y());null!==t;)e.push(t),null===(t=E())&&null===(t=R())&&(t=y());return e}function Rn(){var e,t,r,s,a,o,l,u,c,d,h;return d=Un,h=Un,null!==(e=wn())?(45===n.charCodeAt(Un)?(t="-",Un++):(t=null,0===Mn&&i('"-"')),null!==t&&null!==(r=An())?(45===n.charCodeAt(Un)?(s="-",Un++):(s=null,0===Mn&&i('"-"')),null!==s&&null!==(a=An())?(45===n.charCodeAt(Un)?(o="-",Un++):(o=null,0===Mn&&i('"-"')),null!==o&&null!==(l=An())?(45===n.charCodeAt(Un)?(u="-",Un++):(u=null,0===Mn&&i('"-"')),null!==u&&null!==(c=In())?e=[e,t,r,s,a,o,l,u,c]:(e=null,Un=h)):(e=null,Un=h)):(e=null,Un=h)):(e=null,Un=h)):(e=null,Un=h),null!==e&&(e=function(e,t){jn=n.substring(Un+5,e)}(d,e[0])),null===e&&(Un=d),e}function An(){var e,t,n,r,i;return i=Un,null!==(e=l())&&null!==(t=l())&&null!==(n=l())&&null!==(r=l())?e=[e,t,n,r]:(e=null,Un=i),e}function wn(){var e,t,n;return n=Un,null!==(e=An())&&null!==(t=An())?e=[e,t]:(e=null,Un=n),e}function In(){var e,t,n,r;return r=Un,null!==(e=An())&&null!==(t=An())&&null!==(n=An())?e=[e,t,n]:(e=null,Un=r),e}function kn(){var e,t,r,s,a,o;return s=Un,a=Un,null!==(e=I())?(o=Un,64===n.charCodeAt(Un)?(t="@",Un++):(t=null,0===Mn&&i('"@"')),null!==t&&null!==(r=I())?t=[t,r]:(t=null,Un=o),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=function(e){jn.call_id=n.substring(Un,e)}(s)),null===e&&(Un=s),e}function On(){var e;return null===(e=Pn())&&null===(e=xn())&&null===(e=Nn())&&(e=yt()),e}function Pn(){var e,t,r,s,a;return s=Un,a=Un,"to-tag"===n.substr(Un,6)?(e="to-tag",Un+=6):(e=null,0===Mn&&i('"to-tag"')),null!==e&&null!==(t=P())&&null!==(r=A())?e=[e,t,r]:(e=null,Un=a),null!==e&&(e=function(e,t){jn.to_tag=t}(0,e[2])),null===e&&(Un=s),e}function xn(){var e,t,r,s,a;return s=Un,a=Un,"from-tag"===n.substr(Un,8)?(e="from-tag",Un+=8):(e=null,0===Mn&&i('"from-tag"')),null!==e&&null!==(t=P())&&null!==(r=A())?e=[e,t,r]:(e=null,Un=a),null!==e&&(e=function(e,t){jn.from_tag=t}(0,e[2])),null===e&&(Un=s),e}function Nn(){var e,t;return t=Un,"early-only"===n.substr(Un,10)?(e="early-only",Un+=10):(e=null,0===Mn&&i('"early-only"')),null!==e&&(e=void(jn.early_only=!0)),null===e&&(Un=t),e}var Dn={CRLF:s,DIGIT:a,ALPHA:o,HEXDIG:l,WSP:u,OCTET:c,DQUOTE:d,SP:h,HTAB:f,alphanum:p,reserved:_,unreserved:m,mark:v,escaped:g,LWS:y,SWS:T,HCOLON:C,TEXT_UTF8_TRIM:S,TEXT_UTF8char:E,UTF8_NONASCII:b,UTF8_CONT:R,LHEX:function(){var e;return null===(e=a())&&(/^[a-f]/.test(n.charAt(Un))?(e=n.charAt(Un),Un++):(e=null,0===Mn&&i("[a-f]"))),e},token:A,token_nodot:w,separators:function(){var e;return 40===n.charCodeAt(Un)?(e="(",Un++):(e=null,0===Mn&&i('"("')),null===e&&(41===n.charCodeAt(Un)?(e=")",Un++):(e=null,0===Mn&&i('")"')),null===e&&(60===n.charCodeAt(Un)?(e="<",Un++):(e=null,0===Mn&&i('"<"')),null===e&&(62===n.charCodeAt(Un)?(e=">",Un++):(e=null,0===Mn&&i('">"')),null===e&&(64===n.charCodeAt(Un)?(e="@",Un++):(e=null,0===Mn&&i('"@"')),null===e&&(44===n.charCodeAt(Un)?(e=",",Un++):(e=null,0===Mn&&i('","')),null===e&&(59===n.charCodeAt(Un)?(e=";",Un++):(e=null,0===Mn&&i('";"')),null===e&&(58===n.charCodeAt(Un)?(e=":",Un++):(e=null,0===Mn&&i('":"')),null===e&&(92===n.charCodeAt(Un)?(e="\\",Un++):(e=null,0===Mn&&i('"\\\\"')),null===e&&null===(e=d())&&(47===n.charCodeAt(Un)?(e="/",Un++):(e=null,0===Mn&&i('"/"')),null===e&&(91===n.charCodeAt(Un)?(e="[",Un++):(e=null,0===Mn&&i('"["')),null===e&&(93===n.charCodeAt(Un)?(e="]",Un++):(e=null,0===Mn&&i('"]"')),null===e&&(63===n.charCodeAt(Un)?(e="?",Un++):(e=null,0===Mn&&i('"?"')),null===e&&(61===n.charCodeAt(Un)?(e="=",Un++):(e=null,0===Mn&&i('"="')),null===e&&(123===n.charCodeAt(Un)?(e="{",Un++):(e=null,0===Mn&&i('"{"')),null===e&&(125===n.charCodeAt(Un)?(e="}",Un++):(e=null,0===Mn&&i('"}"')),null===e&&null===(e=h())&&(e=f())))))))))))))))),e},word:I,STAR:k,SLASH:O,EQUAL:P,LPAREN:x,RPAREN:N,RAQUOT:D,LAQUOT:U,COMMA:M,SEMI:L,COLON:q,LDQUOT:H,RDQUOT:F,comment:j,ctext:G,quoted_string:B,quoted_string_clean:W,qdtext:V,quoted_pair:J,SIP_URI_noparams:K,SIP_URI:z,uri_scheme:Y,uri_scheme_sips:$,uri_scheme_sip:X,userinfo:Q,user:Z,user_unreserved:ee,password:te,hostport:ne,host:re,hostname:ie,domainlabel:se,toplabel:ae,IPv6reference:oe,IPv6address:le,h16:ue,ls32:ce,IPv4address:de,dec_octet:he,port:fe,uri_parameters:pe,uri_parameter:_e,transport_param:me,user_param:ve,method_param:ge,ttl_param:ye,maddr_param:Te,lr_param:Ce,other_param:Se,pname:Ee,pvalue:be,paramchar:Re,param_unreserved:Ae,headers:we,header:Ie,hname:ke,hvalue:Oe,hnv_unreserved:Pe,Request_Response:function(){var e;return null===(e=ot())&&(e=xe()),e},Request_Line:xe,Request_URI:Ne,absoluteURI:De,hier_part:Ue,net_path:Me,abs_path:Le,opaque_part:qe,uric:He,uric_no_slash:Fe,path_segments:je,segment:Ge,param:Be,pchar:We,scheme:Ve,authority:Je,srvr:Ke,reg_name:ze,query:Ye,SIP_Version:$e,INVITEm:Xe,ACKm:Qe,OPTIONSm:Ze,BYEm:et,CANCELm:tt,REGISTERm:nt,SUBSCRIBEm:rt,NOTIFYm:it,REFERm:st,Method:at,Status_Line:ot,Status_Code:lt,extension_code:ut,Reason_Phrase:ct,Allow_Events:function(){var e,t,n,r,i,s;if(i=Un,null!==(e=Dt())){for(t=[],s=Un,null!==(n=M())&&null!==(r=Dt())?n=[n,r]:(n=null,Un=s);null!==n;)t.push(n),s=Un,null!==(n=M())&&null!==(r=Dt())?n=[n,r]:(n=null,Un=s);null!==t?e=[e,t]:(e=null,Un=i)}else e=null,Un=i;return e},Call_ID:function(){var e,t,r,s,a,o;return s=Un,a=Un,null!==(e=I())?(o=Un,64===n.charCodeAt(Un)?(t="@",Un++):(t=null,0===Mn&&i('"@"')),null!==t&&null!==(r=I())?t=[t,r]:(t=null,Un=o),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,Un=a)):(e=null,Un=a),null!==e&&(e=function(e){jn=n.substring(Un,e)}(s)),null===e&&(Un=s),e},Contact:function(){var e,t,n,r,i,s,a;if(i=Un,null===(e=k()))if(s=Un,null!==(e=dt())){for(t=[],a=Un,null!==(n=M())&&null!==(r=dt())?n=[n,r]:(n=null,Un=a);null!==n;)t.push(n),a=Un,null!==(n=M())&&null!==(r=dt())?n=[n,r]:(n=null,Un=a);null!==t?e=[e,t]:(e=null,Un=s)}else e=null,Un=s;return null!==e&&(e=function(e){var t,n;for(n=jn.multi_header.length,t=0;t2&&void 0!==arguments[2]?arguments[2]:{},i=e;if(void 0===e||void 0===t)throw new TypeError("Not enough arguments");if(!(e=this._ua.normalizeTarget(e)))throw new TypeError("Invalid target: "+i);var s=c.cloneArray(r.extraHeaders),a=r.eventHandlers||{},o=r.contentType||"text/plain";for(var h in a)Object.prototype.hasOwnProperty.call(a,h)&&this.on(h,a[h]);s.push("Content-Type: "+o),this._request=new u.OutgoingRequest(l.MESSAGE,e,this._ua,null,s),t&&(this._request.body=t);var f=new d(this._ua,this._request,{onRequestTimeout:function(){n._onRequestTimeout()},onTransportError:function(){n._onTransportError()},onReceiveResponse:function(e){n._receiveResponse(e)}});this._newMessage("local",this._request),f.send()}},{key:"init_incoming",value:function(e){this._request=e,this._newMessage("remote",e),this._is_replied||(this._is_replied=!0,e.reply(200)),this._close()}},{key:"accept",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=c.cloneArray(e.extraHeaders),n=e.body;if("incoming"!==this._direction)throw new h.NotSupportedError('"accept" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");this._is_replied=!0,this._request.reply(200,null,t,n)}},{key:"reject",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.status_code||480,n=e.reason_phrase,r=c.cloneArray(e.extraHeaders),i=e.body;if("incoming"!==this._direction)throw new h.NotSupportedError('"reject" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");if(t<300||t>=700)throw new TypeError("Invalid status_code: "+t);this._is_replied=!0,this._request.reply(t,n,r,i)}},{key:"_receiveResponse",value:function(e){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(e.status_code):break;case/^2[0-9]{2}$/.test(e.status_code):this._succeeded("remote",e);break;default:var t=c.sipErrorCause(e.status_code);this._failed("remote",e,t)}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,l.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,l.causes.CONNECTION_ERROR)}},{key:"_close",value:function(){this._closed=!0,this._ua.destroyMessage(this)}},{key:"_newMessage",value:function(e,t){"remote"===e?(this._direction="incoming",this._local_identity=t.to,this._remote_identity=t.from):"local"===e&&(this._direction="outgoing",this._local_identity=t.from,this._remote_identity=t.to),this._ua.newMessage(this,{originator:e,message:this,request:t})}},{key:"_failed",value:function(e,t,n){f("MESSAGE failed"),this._close(),f('emit "failed"'),this.emit("failed",{originator:e,response:t||null,cause:n})}},{key:"_succeeded",value:function(e,t){f("MESSAGE succeeded"),this._close(),f('emit "succeeded"'),this.emit("succeeded",{originator:e,response:t})}},{key:"direction",get:function(){return this._direction}},{key:"local_identity",get:function(){return this._local_identity}},{key:"remote_identity",get:function(){return this._remote_identity}}]),t}()},{"./Constants":2,"./Exceptions":6,"./RequestSender":18,"./SIPMessage":19,"./Utils":26,debug:29,events:31}],10:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n";for(var t in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,t)&&(e+=";"+t,null!==this._parameters[t]&&(e+="="+this._parameters[t]));return e}},{key:"uri",get:function(){return this._uri}},{key:"display_name",get:function(){return this._display_name},set:function(e){this._display_name=0===e?"0":e}}]),e}()},{"./Grammar":7,"./URI":25}],11:[function(e,t,n){"use strict";function r(e,t){var n=t,r=0,i=0;if(e.substring(n,n+2).match(/(^\r\n)/))return-2;for(;0===r;){if(-1===(i=e.indexOf("\r\n",n)))return i;!e.substring(i+2,i+4).match(/(^\r\n)/)&&e.charAt(i+2).match(/(^\s+)/)?n=i+2:r=i}return r}function i(e,t,n,r){var i=void 0,o=t.indexOf(":",n),l=t.substring(n,o).trim(),u=t.substring(o+1,r).trim();switch(l.toLowerCase()){case"via":case"v":e.addHeader("via",u),1===e.getHeaders("via").length?(i=e.parseHeader("Via"))&&(e.via=i,e.via_branch=i.branch):i=0;break;case"from":case"f":e.setHeader("from",u),(i=e.parseHeader("from"))&&(e.from=i,e.from_tag=i.getParam("tag"));break;case"to":case"t":e.setHeader("to",u),(i=e.parseHeader("to"))&&(e.to=i,e.to_tag=i.getParam("tag"));break;case"record-route":if(-1===(i=s.parse(u,"Record_Route")))i=void 0;else{var c=!0,d=!1,h=void 0;try{for(var f,p=i[Symbol.iterator]();!(c=(f=p.next()).done);c=!0){var _=f.value;e.addHeader("record-route",u.substring(_.possition,_.offset)),e.headers["Record-Route"][e.getHeaders("record-route").length-1].parsed=_.parsed}}catch(e){d=!0,h=e}finally{try{!c&&p.return&&p.return()}finally{if(d)throw h}}}break;case"call-id":case"i":e.setHeader("call-id",u),(i=e.parseHeader("call-id"))&&(e.call_id=u);break;case"contact":case"m":if(-1===(i=s.parse(u,"Contact")))i=void 0;else{var m=!0,v=!1,g=void 0;try{for(var y,T=i[Symbol.iterator]();!(m=(y=T.next()).done);m=!0){var C=y.value;e.addHeader("contact",u.substring(C.possition,C.offset)),e.headers.Contact[e.getHeaders("contact").length-1].parsed=C.parsed}}catch(e){v=!0,g=e}finally{try{!m&&T.return&&T.return()}finally{if(v)throw g}}}break;case"content-length":case"l":e.setHeader("content-length",u),i=e.parseHeader("content-length");break;case"content-type":case"c":e.setHeader("content-type",u),i=e.parseHeader("content-type");break;case"cseq":e.setHeader("cseq",u),(i=e.parseHeader("cseq"))&&(e.cseq=i.value),e instanceof a.IncomingResponse&&(e.method=i.method);break;case"max-forwards":e.setHeader("max-forwards",u),i=e.parseHeader("max-forwards");break;case"www-authenticate":e.setHeader("www-authenticate",u),i=e.parseHeader("www-authenticate");break;case"proxy-authenticate":e.setHeader("proxy-authenticate",u),i=e.parseHeader("proxy-authenticate");break;case"session-expires":case"x":e.setHeader("session-expires",u),(i=e.parseHeader("session-expires"))&&(e.session_expires=i.expires,e.session_expires_refresher=i.refresher);break;case"refer-to":case"r":e.setHeader("refer-to",u),(i=e.parseHeader("refer-to"))&&(e.refer_to=i);break;case"replaces":e.setHeader("replaces",u),(i=e.parseHeader("replaces"))&&(e.replaces=i);break;case"event":case"o":e.setHeader("event",u),(i=e.parseHeader("event"))&&(e.event=i);break;default:e.setHeader(l,u),i=0}return void 0!==i||{error:'error parsing header "'+l+'"'}}var s=e("./Grammar"),a=e("./SIPMessage"),o=e("debug")("JsSIP:ERROR:Parser");o.log=console.warn.bind(console),n.parseMessage=function(e,t){var n=void 0,l=void 0,u=e.indexOf("\r\n");if(-1!==u){var c=e.substring(0,u),d=s.parse(c,"Request_Response");if(-1!==d){d.status_code?((n=new a.IncomingResponse).status_code=d.status_code,n.reason_phrase=d.reason_phrase):((n=new a.IncomingRequest(t)).method=d.method,n.ruri=d.uri),n.data=e;for(var h=u+2;;){if(-2===(u=r(e,h))){l=h+2;break}if(-1===u)return void o("parseMessage() | malformed message");if(!0!==(d=i(n,e,h,u)))return void o("parseMessage() |",d.error);h=u+2}if(n.hasHeader("content-length")){var f=n.getHeader("content-length");n.body=e.substr(l,f)}else n.body=e.substring(l);return n}o('parseMessage() | error parsing first line of SIP message: "'+c+'"')}else o("parseMessage() | no CRLF found, not a SIP message")}},{"./Grammar":7,"./SIPMessage":19,debug:29}],12:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a="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},o=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{},n=arguments[2];S("connect()");var r=e,i=t.eventHandlers||{},s=f.cloneArray(t.extraHeaders),a=t.mediaConstraints||{audio:!0,video:!0},o=t.mediaStream||null,l=t.pcConfig||{iceServers:[]},u=t.rtcConstraints||null,h=t.rtcOfferConstraints||null;if(this._rtcOfferConstraints=h,this._rtcAnswerConstraints=t.rtcAnswerConstraints||null,this._data=t.data||this._data,void 0===e)throw new TypeError("Not enough arguments");if(this._status!==b.STATUS_NULL)throw new d.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new d.NotSupportedError("WebRTC not supported");if(!(e=this._ua.normalizeTarget(e)))throw new TypeError("Invalid target: "+r);this._sessionTimers.enabled&&f.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=c.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=c.SESSION_EXPIRES);for(var p in i)Object.prototype.hasOwnProperty.call(i,p)&&this.on(p,i[p]);this._from_tag=f.newTag();var m=t.anonymous||!1,v={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:m,outbound:!0}),m&&(v.from_display_name="Anonymous",v.from_uri="sip:anonymous@anonymous.invalid",s.push("P-Preferred-Identity: "+this._ua.configuration.uri.toString()),s.push("Privacy: id")),s.push("Contact: "+this._contact),s.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&s.push("Session-Expires: "+this._sessionTimers.defaultExpires),this._request=new _.InitialOutgoingInviteRequest(e,this._ua,v,s),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(l,u),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,n&&n(this),this._newRTCSession("local",this._request),this._sendInitialRequest(a,h,o)}},{key:"init_incoming",value:function(e,t){var n=this;S("init_incoming()");var r=void 0,i=e.getHeader("Content-Type");e.body&&"application/sdp"!==i?e.reply(415):(this._status=b.STATUS_INVITE_RECEIVED,this._from_tag=e.from_tag,this._id=e.call_id+this._from_tag,this._request=e,this._contact=this._ua.contact.toString(),e.hasHeader("expires")&&(r=1e3*e.getHeader("expires")),e.to_tag=f.newTag(),this._createDialog(e,"UAS",!0)?(e.body?this._late_sdp=!1:this._late_sdp=!0,this._status=b.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(function(){e.reply(408),n._failed("local",null,c.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),r&&(this._timers.expiresTimer=setTimeout(function(){n._status===b.STATUS_WAITING_FOR_ANSWER&&(e.reply(487),n._failed("system",null,c.causes.EXPIRES))},r)),this._direction="incoming",this._local_identity=e.to,this._remote_identity=e.from,t&&t(this),this._newRTCSession("remote",e),this._status!==b.STATUS_TERMINATED&&(e.reply(180,null,["Contact: "+this._contact]),this._progress("local",null))):e.reply(500,"Missing Contact header field"))}},{key:"answer",value:function(){function e(e){var t=this;if(this._status!==b.STATUS_TERMINATED)if(this._localMediaStream=e,e&&this._connection.addStream(e),this._late_sdp)n.call(this);else{var r={originator:"remote",type:"offer",sdp:o.body};S('emit "sdp"'),this.emit("sdp",r);var i=new RTCSessionDescription({type:"offer",sdp:r.sdp});this._connection.setRemoteDescription(i).then(n.bind(this)).catch(function(e){o.reply(488),t._failed("system",null,c.causes.WEBRTC_ERROR),E('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)})}}function t(){this._status!==b.STATUS_TERMINATED&&(o.reply(480),this._failed("local",null,c.causes.USER_DENIED_MEDIA_ACCESS))}function n(){this._connecting(o),this._late_sdp?this._createLocalDescription("offer",r.bind(this),i.bind(this),this._rtcOfferConstraints):this._createLocalDescription("answer",r.bind(this),i.bind(this),m)}function r(e){this._status!==b.STATUS_TERMINATED&&(this._handleSessionTimersInIncomingRequest(o,l),o.reply(200,null,l,e,function(){this._status=b.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(o,e),this._setACKTimer(),this._accepted("local")}.bind(this),function(){this._failed("system",null,c.causes.CONNECTION_ERROR)}.bind(this)))}function i(){this._status!==b.STATUS_TERMINATED&&(o.reply(500),this._failed("system",null,c.causes.WEBRTC_ERROR))}var s=this,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};S("answer()");var o=this._request,l=f.cloneArray(a.extraHeaders),u=a.mediaConstraints||{},h=a.mediaStream||null,p=a.pcConfig||{iceServers:[]},_=a.rtcConstraints||null,m=a.rtcAnswerConstraints||null,v=void 0,g=!1,y=!1,T=!1,C=!1;if(this._rtcAnswerConstraints=m,this._rtcOfferConstraints=a.rtcOfferConstraints||null,this._data=a.data||this._data,"incoming"!==this._direction)throw new d.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==b.STATUS_WAITING_FOR_ANSWER)throw new d.InvalidStateError(this._status);if(this._sessionTimers.enabled&&f.isDecimal(a.sessionTimersExpires)&&(a.sessionTimersExpires>=c.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=a.sessionTimersExpires:this._sessionTimers.defaultExpires=c.SESSION_EXPIRES),this._status=b.STATUS_ANSWERED,this._createDialog(o,"UAS")){clearTimeout(this._timers.userNoAnswerTimer),l.unshift("Contact: "+this._contact);var R=o.parseSDP();Array.isArray(R.media)||(R.media=[R.media]);var A=!0,w=!1,I=void 0;try{for(var k,O=R.media[Symbol.iterator]();!(A=(k=O.next()).done);A=!0){var P=k.value;"audio"===P.type&&(g=!0,P.direction&&"sendrecv"!==P.direction||(T=!0)),"video"===P.type&&(y=!0,P.direction&&"sendrecv"!==P.direction||(C=!0))}}catch(e){w=!0,I=e}finally{try{!A&&O.return&&O.return()}finally{if(w)throw I}}if(h&&!1===u.audio){v=h.getAudioTracks();var x=!0,N=!1,D=void 0;try{for(var U,M=v[Symbol.iterator]();!(x=(U=M.next()).done);x=!0){var L=U.value;h.removeTrack(L)}}catch(e){N=!0,D=e}finally{try{!x&&M.return&&M.return()}finally{if(N)throw D}}}if(h&&!1===u.video){v=h.getVideoTracks();var q=!0,H=!1,F=void 0;try{for(var j,G=v[Symbol.iterator]();!(q=(j=G.next()).done);q=!0){var B=j.value;h.removeTrack(B)}}catch(e){H=!0,F=e}finally{try{!q&&G.return&&G.return()}finally{if(H)throw F}}}h||void 0!==u.audio||(u.audio=T),h||void 0!==u.video||(u.video=C),h||g||(u.audio=!1),h||y||(u.video=!1),this._createRTCConnection(p,_),h?e(h):u.audio||u.video?(this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(u).then(e.bind(this)).catch(function(e){t.call(s,e),E('emit "getusermediafailed" [error:%o]',e),s.emit("getusermediafailed",e)})):e.call(this,null)}else o.reply(500,"Error creating dialog")}},{key:"terminate",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};S("terminate()");var n=t.cause||c.causes.BYE,r=f.cloneArray(t.extraHeaders),i=t.body,s=void 0,a=t.status_code,o=t.reason_phrase;if(this._status===b.STATUS_TERMINATED)throw new d.InvalidStateError(this._status);switch(this._status){case b.STATUS_NULL:case b.STATUS_INVITE_SENT:case b.STATUS_1XX_RECEIVED:if(S("canceling session"),a&&(a<200||a>=700))throw new TypeError("Invalid status_code: "+a);a&&(s="SIP ;cause="+a+' ;text="'+(o=o||c.REASON_PHRASE[a]||"")+'"'),this._status===b.STATUS_NULL||this._status===b.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=s):this._status===b.STATUS_1XX_RECEIVED&&this._request.cancel(s),this._status=b.STATUS_CANCELED,this._failed("local",null,c.causes.CANCELED);break;case b.STATUS_WAITING_FOR_ANSWER:case b.STATUS_ANSWERED:if(S("rejecting session"),(a=a||480)<300||a>=700)throw new TypeError("Invalid status_code: "+a);this._request.reply(a,o,r,i),this._failed("local",null,c.causes.REJECTED);break;case b.STATUS_WAITING_FOR_ACK:case b.STATUS_CONFIRMED:if(S("terminating session"),o=t.reason_phrase||c.REASON_PHRASE[a]||"",a&&(a<200||a>=700))throw new TypeError("Invalid status_code: "+a);if(a&&r.push("Reason: SIP ;cause="+a+'; text="'+o+'"'),this._status===b.STATUS_WAITING_FOR_ACK&&"incoming"===this._direction&&this._request.server_transaction.state!==h.C.STATUS_TERMINATED){var l=this._dialog;this.receiveRequest=function(t){t.method===c.ACK&&(e.sendRequest(c.BYE,{extraHeaders:r,body:i}),l.terminate())},this._request.server_transaction.on("stateChanged",function(){e._request.server_transaction.state===h.C.STATUS_TERMINATED&&(e.sendRequest(c.BYE,{extraHeaders:r,body:i}),l.terminate())}),this._ended("local",null,n),this._dialog=l,this._ua.newDialog(l)}else this.sendRequest(c.BYE,{extraHeaders:r,body:i}),this._ended("local",null,n)}}},{key:"sendDTMF",value:function(e){function t(){var e=this,a=void 0;if(this._status===b.STATUS_TERMINATED||!this._tones||r>=this._tones.length)this._tones=null;else{var o=this._tones[r];if(r+=1,","===o)a=2e3;else{var l=new g(this);n.eventHandlers={onFailed:function(){e._tones=null}},l.send(o,n),a=i+s}setTimeout(t.bind(this),a)}}var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};S("sendDTMF() | tones: %s",e);var r=0,i=n.duration||null,s=n.interToneGap||null;if(void 0===e)throw new TypeError("Not enough arguments");if(this._status!==b.STATUS_CONFIRMED&&this._status!==b.STATUS_WAITING_FOR_ACK)throw new d.InvalidStateError(this._status);if("number"==typeof e&&(e=e.toString()),!e||"string"!=typeof e||!e.match(/^[0-9A-DR#*,]+$/i))throw new TypeError("Invalid tones: "+e);if(i&&!f.isDecimal(i))throw new TypeError("Invalid tone duration: "+i);if(i?ig.C.MAX_DURATION?(S('"duration" value is greater than the maximum allowed, setting it to '+g.C.MAX_DURATION+" milliseconds"),i=g.C.MAX_DURATION):i=Math.abs(i):i=g.C.DEFAULT_DURATION,n.duration=i,s&&!f.isDecimal(s))throw new TypeError("Invalid interToneGap: "+s);s?s2&&void 0!==arguments[2]?arguments[2]:{};if(S("sendInfo()"),this._status!==b.STATUS_CONFIRMED&&this._status!==b.STATUS_WAITING_FOR_ACK)throw new d.InvalidStateError(this._status);new y(this).send(e,t,n)}},{key:"mute",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{audio:!0,video:!1};S("mute()");var t=!1,n=!1;!1===this._audioMuted&&e.audio&&(t=!0,this._audioMuted=!0,this._toogleMuteAudio(!0)),!1===this._videoMuted&&e.video&&(n=!0,this._videoMuted=!0,this._toogleMuteVideo(!0)),!0!==t&&!0!==n||this._onmute({audio:t,video:n})}},{key:"unmute",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{audio:!0,video:!0};S("unmute()");var t=!1,n=!1;!0===this._audioMuted&&e.audio&&(t=!0,this._audioMuted=!1,!1===this._localHold&&this._toogleMuteAudio(!1)),!0===this._videoMuted&&e.video&&(n=!0,this._videoMuted=!1,!1===this._localHold&&this._toogleMuteVideo(!1)),!0!==t&&!0!==n||this._onunmute({audio:t,video:n})}},{key:"hold",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];if(S("hold()"),this._status!==b.STATUS_WAITING_FOR_ACK&&this._status!==b.STATUS_CONFIRMED)return!1;if(!0===this._localHold)return!1;if(!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");var r={succeeded:function(){n&&n()},failed:function(){e.terminate({cause:c.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:r,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:r,extraHeaders:t.extraHeaders}),!0}},{key:"unhold",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];if(S("unhold()"),this._status!==b.STATUS_WAITING_FOR_ACK&&this._status!==b.STATUS_CONFIRMED)return!1;if(!1===this._localHold)return!1;if(!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");var r={succeeded:function(){n&&n()},failed:function(){e.terminate({cause:c.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:r,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:r,extraHeaders:t.extraHeaders}),!0}},{key:"renegotiate",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];S("renegotiate()");var r=t.rtcOfferConstraints||null;if(this._status!==b.STATUS_WAITING_FOR_ACK&&this._status!==b.STATUS_CONFIRMED)return!1;if(!this._isReadyToReOffer())return!1;var i={succeeded:function(){n&&n()},failed:function(){e.terminate({cause:c.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:i,rtcOfferConstraints:r,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:i,rtcOfferConstraints:r,extraHeaders:t.extraHeaders}),!0}},{key:"refer",value:function(e,t){var n=this;S("refer()");var r=e;if(this._status!==b.STATUS_WAITING_FOR_ACK&&this._status!==b.STATUS_CONFIRMED)return!1;if(!(e=this._ua.normalizeTarget(e)))throw new TypeError("Invalid target: "+r);var i=new C(this);i.sendRefer(e,t);var s=i.id;return this._referSubscribers[s]=i,i.on("requestFailed",function(){delete n._referSubscribers[s]}),i.on("accepted",function(){delete n._referSubscribers[s]}),i.on("failed",function(){delete n._referSubscribers[s]}),i}},{key:"sendRequest",value:function(e,t){return S("sendRequest()"),this._dialog.sendRequest(e,t)}},{key:"receiveRequest",value:function(e){var t=this;if(S("receiveRequest()"),e.method===c.CANCEL)this._status!==b.STATUS_WAITING_FOR_ANSWER&&this._status!==b.STATUS_ANSWERED||(this._status=b.STATUS_CANCELED,this._request.reply(487),this._failed("remote",e,c.causes.CANCELED));else switch(e.method){case c.ACK:if(this._status!==b.STATUS_WAITING_FOR_ACK)return;if(this._status=b.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!e.body){this.terminate({cause:c.causes.MISSING_SDP,status_code:400});break}var n={originator:"remote",type:"answer",sdp:e.body},r=new RTCSessionDescription({type:"answer",sdp:n.sdp});this.emit("sdp",n),this._connection.setRemoteDescription(r).then(function(){t._is_confirmed||t._confirmed("remote",e)}).catch(function(e){t.terminate({cause:c.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),t.emit("peerconnection:setremotedescriptionfailed",e)})}else this._is_confirmed||this._confirmed("remote",e);break;case c.BYE:this._status===b.STATUS_CONFIRMED?(e.reply(200),this._ended("remote",e,c.causes.BYE)):this._status===b.STATUS_INVITE_RECEIVED?(e.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",e,c.causes.BYE)):e.reply(403,"Wrong Status");break;case c.INVITE:this._status===b.STATUS_CONFIRMED?e.hasHeader("replaces")?this._receiveReplaces(e):this._receiveReinvite(e):e.reply(403,"Wrong Status");break;case c.INFO:if(this._status===b.STATUS_1XX_RECEIVED||this._status===b.STATUS_WAITING_FOR_ANSWER||this._status===b.STATUS_ANSWERED||this._status===b.STATUS_WAITING_FOR_ACK||this._status===b.STATUS_CONFIRMED){var i=e.getHeader("content-type");i&&i.match(/^application\/dtmf-relay/i)?new g(this).init_incoming(e):void 0!==i?new y(this).init_incoming(e):e.reply(415)}else e.reply(403,"Wrong Status");break;case c.UPDATE:this._status===b.STATUS_CONFIRMED?this._receiveUpdate(e):e.reply(403,"Wrong Status");break;case c.REFER:this._status===b.STATUS_CONFIRMED?this._receiveRefer(e):e.reply(403,"Wrong Status");break;case c.NOTIFY:this._status===b.STATUS_CONFIRMED?this._receiveNotify(e):e.reply(403,"Wrong Status");break;default:e.reply(501)}}},{key:"onTransportError",value:function(){E("onTransportError()"),this._status!==b.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:c.causes.CONNECTION_ERROR,cause:c.causes.CONNECTION_ERROR})}},{key:"onRequestTimeout",value:function(){E("onRequestTimeout()"),this._status!==b.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:c.causes.REQUEST_TIMEOUT,cause:c.causes.REQUEST_TIMEOUT})}},{key:"onDialogError",value:function(){E("onDialogError()"),this._status!==b.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:c.causes.DIALOG_ERROR,cause:c.causes.DIALOG_ERROR})}},{key:"newDTMF",value:function(e){S("newDTMF()"),this.emit("newDTMF",e)}},{key:"newInfo",value:function(e){S("newInfo()"),this.emit("newInfo",e)}},{key:"_isReadyToReOffer",value:function(){return this._rtcReady?this._dialog?!0!==this._dialog.uac_pending_reply&&!0!==this._dialog.uas_pending_reply||(S("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):(S("_isReadyToReOffer() | session not established yet"),!1):(S("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}},{key:"_close",value:function(){if(S("close()"),this._status!==b.STATUS_TERMINATED){if(this._status=b.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(e){E("close() | error closing the RTCPeerConnection: %o",e)}this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(S("close() | closing local MediaStream"),f.closeMediaStream(this._localMediaStream));for(var e in this._timers)Object.prototype.hasOwnProperty.call(this._timers,e)&&clearTimeout(this._timers[e]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(var t in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,t)&&(this._earlyDialogs[t].terminate(),delete this._earlyDialogs[t]);for(var n in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,n)&&delete this._referSubscribers[n];this._ua.destroyRTCSession(this)}}},{key:"_setInvite2xxTimer",value:function(e,t){function n(){this._status===b.STATUS_WAITING_FOR_ACK&&(e.reply(200,null,["Contact: "+this._contact],t),rp.T2&&(r=p.T2),this._timers.invite2xxTimer=setTimeout(n.bind(this),r))}var r=p.T1;this._timers.invite2xxTimer=setTimeout(n.bind(this),r)}},{key:"_setACKTimer",value:function(){var e=this;this._timers.ackTimer=setTimeout(function(){e._status===b.STATUS_WAITING_FOR_ACK&&(S("no ACK received, terminating the session"),clearTimeout(e._timers.invite2xxTimer),e.sendRequest(c.BYE),e._ended("remote",null,c.causes.NO_ACK))},p.TIMER_H)}},{key:"_createRTCConnection",value:function(e,t){var n=this;this._connection=new RTCPeerConnection(e,t),this._connection.addEventListener("iceconnectionstatechange",function(){"failed"===n._connection.iceConnectionState&&n.terminate({cause:c.causes.RTP_TIMEOUT,status_code:408,reason_phrase:c.causes.RTP_TIMEOUT})}),S('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}},{key:"_createLocalDescription",value:function(e,t,n,r){function i(r){var i=this,s=void 0;a.addEventListener("icecandidate",s=function(n){if(!n.candidate){if(a.removeEventListener("icecandidate",s),i._rtcReady=!0,t){var r={originator:"local",type:e,sdp:a.localDescription.sdp};S('emit "sdp"'),i.emit("sdp",r),t(r.sdp)}t=null}}),a.setLocalDescription(r).then(function(){if("complete"===a.iceGatheringState&&(i._rtcReady=!0,t)){var n={originator:"local",type:e,sdp:a.localDescription.sdp};S('emit "sdp"'),i.emit("sdp",n),t(n.sdp),t=null}}).catch(function(e){i._rtcReady=!0,n&&n(e),E('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',e),i.emit("peerconnection:setlocaldescriptionfailed",e)})}var s=this;S("createLocalDescription()");var a=this._connection;if(this._rtcReady=!1,"offer"===e)a.createOffer(r).then(i.bind(this)).catch(function(e){s._rtcReady=!0,n&&n(e),E('emit "peerconnection:createofferfailed" [error:%o]',e),s.emit("peerconnection:createofferfailed",e)});else{if("answer"!==e)throw new Error('createLocalDescription() | type must be "offer" or "answer", but "'+e+'" was given');a.createAnswer(r).then(i.bind(this)).catch(function(e){s._rtcReady=!0,n&&n(e),E('emit "peerconnection:createanswerfailed" [error:%o]',e),s.emit("peerconnection:createanswerfailed",e)})}}},{key:"_createDialog",value:function(e,t,n){var r="UAS"===t?e.to_tag:e.from_tag,i="UAS"===t?e.from_tag:e.to_tag,s=e.call_id+r+i,a=this._earlyDialogs[s];if(n)return!!a||((a=new m(this,e,t,m.C.STATUS_EARLY)).error?(S(a.error),this._failed("remote",e,c.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[s]=a,!0));if(this._from_tag=e.from_tag,this._to_tag=e.to_tag,a)return a.update(e,t),this._dialog=a,delete this._earlyDialogs[s],!0;var o=new m(this,e,t);return o.error?(S(o.error),this._failed("remote",e,c.causes.INTERNAL_ERROR),!1):(this._dialog=o,!0)}},{key:"_receiveReinvite",value:function(e){function t(){var t=this;n.call(this,function(n){var r=["Contact: "+t._contact];t._handleSessionTimersInIncomingRequest(e,r),t._late_sdp&&(n=t._mangleOffer(n)),e.reply(200,null,r,n,function(){t._status=b.STATUS_WAITING_FOR_ACK,t._setInvite2xxTimer(e,n),t._setACKTimer()}),"function"==typeof s.callback&&s.callback()},function(){e.reply(500)})}function n(e,t){this._late_sdp?this._createLocalDescription("offer",e,t,this._rtcOfferConstraints):(!0===this._remoteHold&&!1===a?(this._remoteHold=!1,this._onunhold("remote")):!1===this._remoteHold&&!0===a&&(this._remoteHold=!0,this._onhold("remote")),this._createLocalDescription("answer",e,t,this._rtcAnswerConstraints))}var r=this;S("receiveReinvite()");var i=e.getHeader("Content-Type"),s={request:e,callback:void 0,reject:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o=!0;var n=t.status_code||403,r=t.reason_phrase||"",i=f.cloneArray(t.extraHeaders);if(this._status!==b.STATUS_CONFIRMED)return!1;if(n<300||n>=700)throw new TypeError("Invalid status_code: "+n);e.reply(n,r,i)}.bind(this)},a=!1,o=!1;if(this.emit("reinvite",s),!o)if(e.body){if(this._late_sdp=!1,"application/sdp"!==i)return S("invalid Content-Type"),void e.reply(415);var l=e.parseSDP(),u=!0,c=!1,d=void 0;try{for(var h,p=l.media[Symbol.iterator]();!(u=(h=p.next()).done);u=!0){var _=h.value;if(-1!==R.indexOf(_.type)){var m=_.direction||l.direction||"sendrecv";if("sendonly"!==m&&"inactive"!==m){a=!1;break}a=!0}}}catch(e){c=!0,d=e}finally{try{!u&&p.return&&p.return()}finally{if(c)throw d}}var v={originator:"remote",type:"offer",sdp:e.body},g=new RTCSessionDescription({type:"offer",sdp:v.sdp});this.emit("sdp",v),this._connection.setRemoteDescription(g).then(t.bind(this)).catch(function(t){e.reply(488),E('emit "peerconnection:setremotedescriptionfailed" [error:%o]',t),r.emit("peerconnection:setremotedescriptionfailed",t)})}else this._late_sdp=!0,t.call(this)}},{key:"_receiveUpdate",value:function(e){var t=this;S("receiveUpdate()");var n=e.getHeader("Content-Type"),r={request:e,callback:void 0,reject:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i=!0;var n=t.status_code||403,r=t.reason_phrase||"",s=f.cloneArray(t.extraHeaders);if(this._status!==b.STATUS_CONFIRMED)return!1;if(n<300||n>=700)throw new TypeError("Invalid status_code: "+n);e.reply(n,r,s)}.bind(this)},i=!1,s=!1;if(this.emit("update",r),!i){if(!e.body){var a=[];return this._handleSessionTimersInIncomingRequest(e,a),void e.reply(200,null,a)}if("application/sdp"!==n)return S("invalid Content-Type"),void e.reply(415);var o=e.parseSDP(),l=!0,u=!1,c=void 0;try{for(var d,h=o.media[Symbol.iterator]();!(l=(d=h.next()).done);l=!0){var p=d.value;if(-1!==R.indexOf(p.type)){var _=p.direction||o.direction||"sendrecv";if("sendonly"!==_&&"inactive"!==_){s=!1;break}s=!0}}}catch(e){u=!0,c=e}finally{try{!l&&h.return&&h.return()}finally{if(u)throw c}}var m={originator:"remote",type:"offer",sdp:e.body};S('emit "sdp"'),this.emit("sdp",m);var v=new RTCSessionDescription({type:"offer",sdp:m.sdp});this._connection.setRemoteDescription(v).then(function(){!0===t._remoteHold&&!1===s?(t._remoteHold=!1,t._onunhold("remote")):!1===t._remoteHold&&!0===s&&(t._remoteHold=!0,t._onhold("remote")),t._createLocalDescription("answer",function(n){var i=["Contact: "+t._contact];t._handleSessionTimersInIncomingRequest(e,i),e.reply(200,null,i,n),"function"==typeof r.callback&&r.callback()},function(){e.reply(500)})}).catch(function(n){e.reply(488),E('emit "peerconnection:setremotedescriptionfailed" [error:%o]',n),t.emit("peerconnection:setremotedescriptionfailed",n)})}}},{key:"_receiveRefer",value:function(e){function n(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(n="function"==typeof n?n:null,this._status!==b.STATUS_WAITING_FOR_ACK&&this._status!==b.STATUS_CONFIRMED)return!1;var i=new t(this._ua);if(i.on("progress",function(e){var t=e.response;s.notify(t.status_code,t.reason_phrase)}),i.on("accepted",function(e){var t=e.response;s.notify(t.status_code,t.reason_phrase)}),i.on("failed",function(e){var t=e.message,n=e.cause;t?s.notify(t.status_code,t.reason_phrase):s.notify(487,n)}),e.refer_to.uri.hasHeader("replaces")){var a=decodeURIComponent(e.refer_to.uri.getHeader("replaces"));r.extraHeaders=f.cloneArray(r.extraHeaders),r.extraHeaders.push("Replaces: "+a)}i.connect(e.refer_to.uri.toAor(),r,n)}function r(){s.notify(603)}var i=this;if(S("receiveRefer()"),void 0===a(e.refer_to))return S("no Refer-To header field present in REFER"),void e.reply(400);if(e.refer_to.uri.scheme!==c.SIP)return S("Refer-To header field points to a non-SIP URI scheme"),void e.reply(416);e.reply(202);var s=new T(this,e.cseq);S('emit "refer"'),this.emit("refer",{request:e,accept:function(e,t){n.call(i,e,t)},reject:function(){r.call(i)}})}},{key:"_receiveNotify",value:function(e){switch(S("receiveNotify()"),void 0===a(e.event)&&e.reply(400),e.event.event){case"refer":var t=void 0,n=void 0;if(e.event.params&&e.event.params.id)t=e.event.params.id,n=this._referSubscribers[t];else{if(1!==Object.keys(this._referSubscribers).length)return void e.reply(400,"Missing event id parameter");n=this._referSubscribers[Object.keys(this._referSubscribers)[0]]}if(!n)return void e.reply(481,"Subscription does not exist");n.receiveNotify(e),e.reply(200);break;default:e.reply(489)}}},{key:"_receiveReplaces",value:function(e){function n(n){var r=this;if(this._status!==b.STATUS_WAITING_FOR_ACK&&this._status!==b.STATUS_CONFIRMED)return!1;var i=new t(this._ua);i.on("confirmed",function(){r.terminate()}),i.init_incoming(e,n)}function r(){S("Replaced INVITE rejected by the user"),e.reply(486)}var i=this;S("receiveReplaces()"),this.emit("replaces",{request:e,accept:function(e){n.call(i,e)},reject:function(){r.call(i)}})}},{key:"_sendInitialRequest",value:function(e,t,n){function r(e){this._status!==b.STATUS_TERMINATED&&(this._localMediaStream=e,e&&this._connection.addStream(e),this._connecting(this._request),this._createLocalDescription("offer",s.bind(this),a.bind(this),t))}function i(){this._status!==b.STATUS_TERMINATED&&this._failed("local",null,c.causes.USER_DENIED_MEDIA_ACCESS)}function s(e){this._is_canceled||this._status===b.STATUS_TERMINATED||(this._request.body=e,this._status=b.STATUS_INVITE_SENT,S('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),l.send())}function a(){this._status!==b.STATUS_TERMINATED&&this._failed("system",null,c.causes.WEBRTC_ERROR)}var o=this,l=new v(this._ua,this._request,{onRequestTimeout:function(){o.onRequestTimeout()},onTransportError:function(){o.onTransportError()},onAuthenticated:function(e){o._request=e},onReceiveResponse:function(e){o._receiveInviteResponse(e)}});n?setTimeout(function(){r(n)}):e.audio||e.video?(this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(e).then(r.bind(this)).catch(function(e){i.call(o,e),E('emit "getusermediafailed" [error:%o]',e),o.emit("getusermediafailed",e)})):r.call(this,null)}},{key:"_receiveInviteResponse",value:function(e){var t=this;if(S("receiveInviteResponse()"),this._dialog&&e.status_code>=200&&e.status_code<=299){if(this._dialog.id.call_id===e.call_id&&this._dialog.id.local_tag===e.from_tag&&this._dialog.id.remote_tag===e.to_tag)return void this.sendRequest(c.ACK);var n=new m(this,e,"UAC");return void 0!==n.error?void S(n.error):(this.sendRequest(c.ACK),void this.sendRequest(c.BYE))}if(this._is_canceled)e.status_code>=100&&e.status_code<200?this._request.cancel(this._cancel_reason):e.status_code>=200&&e.status_code<299&&this._acceptAndTerminate(e);else if(this._status===b.STATUS_INVITE_SENT||this._status===b.STATUS_1XX_RECEIVED)switch(!0){case/^100$/.test(e.status_code):this._status=b.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(e.status_code):if(!e.to_tag){S("1xx response received without to tag");break}if(e.hasHeader("contact")&&!this._createDialog(e,"UAC",!0))break;if(this._status=b.STATUS_1XX_RECEIVED,this._progress("remote",e),!e.body)break;var r={originator:"remote",type:"answer",sdp:e.body};S('emit "sdp"'),this.emit("sdp",r);var i=new RTCSessionDescription({type:"answer",sdp:r.sdp});this._connection.setRemoteDescription(i).catch(function(e){E('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)});break;case/^2[0-9]{2}$/.test(e.status_code):if(this._status=b.STATUS_CONFIRMED,!e.body){this._acceptAndTerminate(e,400,c.causes.MISSING_SDP),this._failed("remote",e,c.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(e,"UAC"))break;var s={originator:"remote",type:"answer",sdp:e.body};S('emit "sdp"'),this.emit("sdp",s);var a=new RTCSessionDescription({type:"answer",sdp:s.sdp});Promise.resolve().then(function(){if("stable"===t._connection.signalingState)return t._connection.createOffer().then(function(e){return t._connection.setLocalDescription(e)}).catch(function(n){t._acceptAndTerminate(e,500,n.toString()),t._failed("local",e,c.causes.WEBRTC_ERROR),E('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',n),t.emit("peerconnection:setlocaldescriptionfailed",n)})}).then(function(){t._connection.setRemoteDescription(a).then(function(){t._handleSessionTimersInIncomingResponse(e),t._accepted("remote",e),t.sendRequest(c.ACK),t._confirmed("local",null)}).catch(function(n){t._acceptAndTerminate(e,488,"Not Acceptable Here"),t._failed("remote",e,c.causes.BAD_MEDIA_DESCRIPTION),E('emit "peerconnection:setremotedescriptionfailed" [error:%o]',n),t.emit("peerconnection:setremotedescriptionfailed",n)})});break;default:var o=f.sipErrorCause(e.status_code);this._failed("remote",e,o)}}},{key:"_sendReinvite",value:function(){function e(e){var n=this;if(this._status!==b.STATUS_TERMINATED&&(this.sendRequest(c.ACK),!o))if(this._handleSessionTimersInIncomingResponse(e),e.body)if("application/sdp"===e.getHeader("Content-Type")){var r={originator:"remote",type:"answer",sdp:e.body};S('emit "sdp"'),this.emit("sdp",r);var i=new RTCSessionDescription({type:"answer",sdp:r.sdp});this._connection.setRemoteDescription(i).then(function(){s.succeeded&&s.succeeded(e)}).catch(function(e){t.call(n),E('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),n.emit("peerconnection:setremotedescriptionfailed",e)})}else t.call(this);else t.call(this)}function t(e){s.failed&&s.failed(e)}var n=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};S("sendReinvite()");var i=f.cloneArray(r.extraHeaders),s=r.eventHandlers||{},a=r.rtcOfferConstraints||this._rtcOfferConstraints||null,o=!1;i.push("Contact: "+this._contact),i.push("Content-Type: application/sdp"),this._sessionTimers.running&&i.push("Session-Expires: "+this._sessionTimers.currentExpires+";refresher="+(this._sessionTimers.refresher?"uac":"uas")),this._createLocalDescription("offer",function(r){r=n._mangleOffer(r),n.sendRequest(c.INVITE,{extraHeaders:i,body:r,eventHandlers:{onSuccessResponse:function(t){e.call(n,t),o=!0},onErrorResponse:function(e){t.call(n,e)},onTransportError:function(){n.onTransportError()},onRequestTimeout:function(){n.onRequestTimeout()},onDialogError:function(){n.onDialogError()}}})},function(){t()},a)}},{key:"_sendUpdate",value:function(){function e(e){var n=this;if(this._status!==b.STATUS_TERMINATED&&!l)if(this._handleSessionTimersInIncomingResponse(e),o){if(!e.body)return void t.call(this);if("application/sdp"!==e.getHeader("Content-Type"))return void t.call(this);var r={originator:"remote",type:"answer",sdp:e.body};S('emit "sdp"'),this.emit("sdp",r);var i=new RTCSessionDescription({type:"answer",sdp:r.sdp});this._connection.setRemoteDescription(i).then(function(){s.succeeded&&s.succeeded(e)}).catch(function(e){t.call(n),E('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),n.emit("peerconnection:setremotedescriptionfailed",e)})}else s.succeeded&&s.succeeded(e)}function t(e){s.failed&&s.failed(e)}var n=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};S("sendUpdate()");var i=f.cloneArray(r.extraHeaders),s=r.eventHandlers||{},a=r.rtcOfferConstraints||this._rtcOfferConstraints||null,o=r.sdpOffer||!1,l=!1;i.push("Contact: "+this._contact),this._sessionTimers.running&&i.push("Session-Expires: "+this._sessionTimers.currentExpires+";refresher="+(this._sessionTimers.refresher?"uac":"uas")),o?(i.push("Content-Type: application/sdp"),this._createLocalDescription("offer",function(r){r=n._mangleOffer(r),n.sendRequest(c.UPDATE,{extraHeaders:i,body:r,eventHandlers:{onSuccessResponse:function(t){e.call(n,t),l=!0},onErrorResponse:function(e){t.call(n,e)},onTransportError:function(){n.onTransportError()},onRequestTimeout:function(){n.onRequestTimeout()},onDialogError:function(){n.onDialogError()}}})},function(){t.call(n)},a)):this.sendRequest(c.UPDATE,{extraHeaders:i,eventHandlers:{onSuccessResponse:function(t){e.call(n,t)},onErrorResponse:function(e){t.call(n,e)},onTransportError:function(){n.onTransportError()},onRequestTimeout:function(){n.onRequestTimeout()},onDialogError:function(){n.onDialogError()}}})}},{key:"_acceptAndTerminate",value:function(e,t,n){S("acceptAndTerminate()");var r=[];t&&(n=n||c.REASON_PHRASE[t]||"",r.push("Reason: SIP ;cause="+t+'; text="'+n+'"')),(this._dialog||this._createDialog(e,"UAC"))&&(this.sendRequest(c.ACK),this.sendRequest(c.BYE,{extraHeaders:r})),this._status=b.STATUS_TERMINATED}},{key:"_mangleOffer",value:function(e){if(!this._localHold&&!this._remoteHold)return e;if(e=u.parse(e),this._localHold&&!this._remoteHold){S("mangleOffer() | me on hold, mangling offer");var t=!0,n=!1,r=void 0;try{for(var i,s=e.media[Symbol.iterator]();!(t=(i=s.next()).done);t=!0){var a=i.value;-1!==R.indexOf(a.type)&&(a.direction?"sendrecv"===a.direction?a.direction="sendonly":"recvonly"===a.direction&&(a.direction="inactive"):a.direction="sendonly")}}catch(e){n=!0,r=e}finally{try{!t&&s.return&&s.return()}finally{if(n)throw r}}}else if(this._localHold&&this._remoteHold){S("mangleOffer() | both on hold, mangling offer");var o=!0,l=!1,c=void 0;try{for(var d,h=e.media[Symbol.iterator]();!(o=(d=h.next()).done);o=!0){var f=d.value;-1!==R.indexOf(f.type)&&(f.direction="inactive")}}catch(e){l=!0,c=e}finally{try{!o&&h.return&&h.return()}finally{if(l)throw c}}}else if(this._remoteHold){S("mangleOffer() | remote on hold, mangling offer");var p=!0,_=!1,m=void 0;try{for(var v,g=e.media[Symbol.iterator]();!(p=(v=g.next()).done);p=!0){var y=v.value;-1!==R.indexOf(y.type)&&(y.direction?"sendrecv"===y.direction?y.direction="recvonly":"recvonly"===y.direction&&(y.direction="inactive"):y.direction="recvonly")}}catch(e){_=!0,m=e}finally{try{!p&&g.return&&g.return()}finally{if(_)throw m}}}return u.write(e)}},{key:"_setLocalMediaStatus",value:function(){var e=!0,t=!0;(this._localHold||this._remoteHold)&&(e=!1,t=!1),this._audioMuted&&(e=!1),this._videoMuted&&(t=!1),this._toogleMuteAudio(!e),this._toogleMuteVideo(!t)}},{key:"_handleSessionTimersInIncomingRequest",value:function(e,t){if(this._sessionTimers.enabled){var n=void 0;e.session_expires&&e.session_expires>=c.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=e.session_expires,n=e.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,n="uas"),t.push("Session-Expires: "+this._sessionTimers.currentExpires+";refresher="+n),this._sessionTimers.refresher="uas"===n,this._runSessionTimer()}}},{key:"_handleSessionTimersInIncomingResponse",value:function(e){if(this._sessionTimers.enabled){var t=void 0;e.session_expires&&e.session_expires>=c.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=e.session_expires,t=e.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,t="uac"),this._sessionTimers.refresher="uac"===t,this._runSessionTimer()}}},{key:"_runSessionTimer",value:function(){var e=this,t=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(function(){e._status!==b.STATUS_TERMINATED&&(S("runSessionTimer() | sending session refresh request"),e._sendUpdate({eventHandlers:{succeeded:function(t){e._handleSessionTimersInIncomingResponse(t)}}}))},500*t):this._sessionTimers.timer=setTimeout(function(){e._status!==b.STATUS_TERMINATED&&(E("runSessionTimer() | timer expired, terminating the session"),e.terminate({cause:c.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},1100*t)}},{key:"_toogleMuteAudio",value:function(e){var t=this._connection.getLocalStreams(),n=!0,r=!1,i=void 0;try{for(var s,a=t[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var o=s.value.getAudioTracks(),l=!0,u=!1,c=void 0;try{for(var d,h=o[Symbol.iterator]();!(l=(d=h.next()).done);l=!0)d.value.enabled=!e}catch(e){u=!0,c=e}finally{try{!l&&h.return&&h.return()}finally{if(u)throw c}}}}catch(e){r=!0,i=e}finally{try{!n&&a.return&&a.return()}finally{if(r)throw i}}}},{key:"_toogleMuteVideo",value:function(e){var t=this._connection.getLocalStreams(),n=!0,r=!1,i=void 0;try{for(var s,a=t[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var o=s.value.getVideoTracks(),l=!0,u=!1,c=void 0;try{for(var d,h=o[Symbol.iterator]();!(l=(d=h.next()).done);l=!0)d.value.enabled=!e}catch(e){u=!0,c=e}finally{try{!l&&h.return&&h.return()}finally{if(u)throw c}}}}catch(e){r=!0,i=e}finally{try{!n&&a.return&&a.return()}finally{if(r)throw i}}}},{key:"_newRTCSession",value:function(e,t){S("newRTCSession()"),this._ua.newRTCSession(this,{originator:e,session:this,request:t})}},{key:"_connecting",value:function(e){S("session connecting"),S('emit "connecting"'),this.emit("connecting",{request:e})}},{key:"_progress",value:function(e,t){S("session progress"),S('emit "progress"'),this.emit("progress",{originator:e,response:t||null})}},{key:"_accepted",value:function(e,t){S("session accepted"),this._start_time=new Date,S('emit "accepted"'),this.emit("accepted",{originator:e,response:t||null})}},{key:"_confirmed",value:function(e,t){S("session confirmed"),this._is_confirmed=!0,S('emit "confirmed"'),this.emit("confirmed",{originator:e,ack:t||null})}},{key:"_ended",value:function(e,t,n){S("session ended"),this._end_time=new Date,this._close(),S('emit "ended"'),this.emit("ended",{originator:e,message:t||null,cause:n})}},{key:"_failed",value:function(e,t,n){S("session failed"),this._close(),S('emit "failed"'),this.emit("failed",{originator:e,message:t||null,cause:n})}},{key:"_onhold",value:function(e){S("session onhold"),this._setLocalMediaStatus(),S('emit "hold"'),this.emit("hold",{originator:e})}},{key:"_onunhold",value:function(e){S("session onunhold"),this._setLocalMediaStatus(),S('emit "unhold"'),this.emit("unhold",{originator:e})}},{key:"_onmute",value:function(e){var t=e.audio,n=e.video;S("session onmute"),this._setLocalMediaStatus(),S('emit "muted"'),this.emit("muted",{audio:t,video:n})}},{key:"_onunmute",value:function(e){var t=e.audio,n=e.video;S("session onunmute"),this._setLocalMediaStatus(),S('emit "unmuted"'),this.emit("unmuted",{audio:t,video:n})}},{key:"C",get:function(){return b}},{key:"causes",get:function(){return c.causes}},{key:"id",get:function(){return this._id}},{key:"connection",get:function(){return this._connection}},{key:"direcion",get:function(){return this._direcion}},{key:"local_identity",get:function(){return this._local_identity}},{key:"remote_identity",get:function(){return this._remote_identity}},{key:"start_time",get:function(){return this._start_time}},{key:"end_time",get:function(){return this._end_time}},{key:"data",get:function(){return this._data},set:function(e){this._data=e}},{key:"status",get:function(){return this._status}}]),t}()},{"./Constants":2,"./Dialog":3,"./Exceptions":6,"./RTCSession/DTMF":13,"./RTCSession/Info":14,"./RTCSession/ReferNotifier":15,"./RTCSession/ReferSubscriber":16,"./RequestSender":18,"./SIPMessage":19,"./Timers":21,"./Transactions":22,"./Utils":26,debug:29,events:31,"sdp-transform":36}],13:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};if(void 0===e)throw new TypeError("Not enough arguments");if(this._direction="outgoing",this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK)throw new u.InvalidStateError(this._session.status);var r=c.cloneArray(n.extraHeaders);if(this.eventHandlers=n.eventHandlers||{},"string"==typeof e)e=e.toUpperCase();else{if("number"!=typeof e)throw new TypeError("Invalid tone: "+e);e=e.toString()}if(!e.match(/^[0-9A-DR#*]$/))throw new TypeError("Invalid tone: "+e);this._tone=e,this._duration=n.duration,r.push("Content-Type: application/dtmf-relay");var i="Signal="+this._tone+"\r\n";i+="Duration="+this._duration,this._session.newDTMF({originator:"local",dtmf:this,request:this._request}),this._session.sendRequest(l.INFO,{extraHeaders:r,eventHandlers:{onSuccessResponse:function(e){t.emit("succeeded",{originator:"remote",response:e})},onErrorResponse:function(e){t.eventHandlers.onFailed&&t.eventHandlers.onFailed(),t.emit("failed",{originator:"remote",response:e})},onRequestTimeout:function(){t._session.onRequestTimeout()},onTransportError:function(){t._session.onTransportError()},onDialogError:function(){t._session.onDialogError()}},body:i})}},{key:"init_incoming",value:function(e){var t=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,n=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;if(this._direction="incoming",this._request=e,e.reply(200),e.body){var r=e.body.split("\n");r.length>=1&&t.test(r[0])&&(this._tone=r[0].replace(t,"$2")),r.length>=2&&n.test(r[1])&&(this._duration=parseInt(r[1].replace(n,"$2"),10))}this._duration||(this._duration=h.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:e}):d("invalid INFO DTMF received, discarded")}},{key:"tone",get:function(){return this._tone}},{key:"duration",get:function(){return this._duration}}]),t}(),t.exports.C=h},{"../Constants":2,"../Exceptions":6,"../Utils":26,debug:29,events:31}],14:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=function(){function e(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:{};if(this._direction="outgoing",void 0===e)throw new TypeError("Not enough arguments");if(this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK)throw new u.InvalidStateError(this._session.status);this._contentType=e,this._body=t;var i=c.cloneArray(r.extraHeaders);i.push("Content-Type: "+e),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(this,l.INFO,{extraHeaders:i,eventHandlers:{onSuccessResponse:function(e){n.emit("succeeded",{originator:"remote",response:e})},onErrorResponse:function(e){n.emit("failed",{originator:"remote",response:e})},onTransportError:function(){n._session.onTransportError()},onRequestTimeout:function(){n._session.onRequestTimeout()},onDialogError:function(){n._session.onDialogError()}},body:t})}},{key:"init_incoming",value:function(e){this._direction="incoming",this.request=e,e.reply(200),this._contentType=e.getHeader("content-type"),this._body=e.body,this._session.newInfo({originator:"remote",info:this,request:e})}},{key:"contentType",get:function(){return this._contentType}},{key:"body",get:function(){return this._body}}]),t}()},{"../Constants":2,"../Exceptions":6,"../Utils":26,debug:29,events:31}],15:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n=200?"terminated;reason=noresource":"active;expires="+this._expires,this._session.sendRequest(s.NOTIFY,{extraHeaders:["Event: "+o.event_type+";id="+this._id,"Subscription-State: "+n,"Content-Type: "+o.body_type],body:"SIP/2.0 "+e+" "+t,eventHandlers:{onErrorResponse:function(){this._active=!1}}})}}}]),e}()},{"../Constants":2,debug:29}],16:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};d("sendRefer()");var r=c.cloneArray(n.extraHeaders),i=n.eventHandlers||{};for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&this.on(s,i[s]);var a=null;n.replaces&&(a=n.replaces.request.call_id,a+=";to-tag="+n.replaces.to_tag,a+=";from-tag="+n.replaces.from_tag,a=encodeURIComponent(a));var o="Refer-To: <"+e+(a?"?Replaces="+a:"")+">";r.push(o);var u=this._session.sendRequest(l.REFER,{extraHeaders:r,eventHandlers:{onSuccessResponse:function(e){t._requestSucceeded(e)},onErrorResponse:function(e){t._requestFailed(e,l.causes.REJECTED)},onTransportError:function(){t._requestFailed(null,l.causes.CONNECTION_ERROR)},onRequestTimeout:function(){t._requestFailed(null,l.causes.REQUEST_TIMEOUT)},onDialogError:function(){t._requestFailed(null,l.causes.DIALOG_ERROR)}}});this._id=u.cseq}},{key:"receiveNotify",value:function(e){if(d("receiveNotify()"),e.body){var t=u.parse(e.body,"Status_Line");if(-1!==t)switch(!0){case/^100$/.test(t.status_code):this.emit("trying",{request:e,status_line:t});break;case/^1[0-9]{2}$/.test(t.status_code):this.emit("progress",{request:e,status_line:t});break;case/^2[0-9]{2}$/.test(t.status_code):this.emit("accepted",{request:e,status_line:t});break;default:this.emit("failed",{request:e,status_line:t})}else d('receiveNotify() | error parsing NOTIFY body: "'+e.body+'"')}}},{key:"_requestSucceeded",value:function(e){d("REFER succeeded"),d('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:e})}},{key:"_requestFailed",value:function(e,t){d("REFER failed"),d('emit "requestFailed"'),this.emit("requestFailed",{response:e||null,cause:t})}},{key:"id",get:function(){return this._id}}]),t}()},{"../Constants":2,"../Grammar":7,"../Utils":26,debug:29,events:31}],17:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n"'}return i(e,[{key:"setExtraHeaders",value:function(e){Array.isArray(e)||(e=[]),this._extraHeaders=e.slice()}},{key:"setExtraContactParams",value:function(e){e instanceof Object||(e={}),this._extraContactParams="";for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var n=e[t];this._extraContactParams+=";"+t,n&&(this._extraContactParams+="="+n)}}},{key:"register",value:function(){var e=this;if(this._registering)u("Register request in progress...");else{var t=this._extraHeaders.slice();t.push("Contact: "+this._contact+";expires="+this._expires+this._extraContactParams),t.push("Expires: "+this._expires);var n=new o.OutgoingRequest(a.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},t),r=new l(this._ua,n,{onRequestTimeout:function(){e._registrationFailure(null,a.causes.REQUEST_TIMEOUT)},onTransportError:function(){e._registrationFailure(null,a.causes.CONNECTION_ERROR)},onAuthenticated:function(){e._cseq+=1},onReceiveResponse:function(t){var n=void 0,r=void 0,i=t.getHeaders("contact").length;if(t.cseq===e._cseq)switch(null!==e._registrationTimer&&(clearTimeout(e._registrationTimer),e._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(t.status_code):break;case/^2[0-9]{2}$/.test(t.status_code):if(e._registering=!1,t.hasHeader("expires")&&(r=t.getHeader("expires")),!i){u("no Contact header in response to REGISTER, response ignored");break}for(;i--;){if((n=t.parseHeader("contact",i)).uri.user===e._ua.contact.uri.user){r=n.getParam("expires");break}n=null}if(!n){u("no Contact header pointing to us, response ignored");break}r||(r=e._expires),e._registrationTimer=setTimeout(function(){e._registrationTimer=null,0===e._ua.listeners("registrationExpiring").length?e.register():e._ua.emit("registrationExpiring")},1e3*r-5e3),n.hasParam("temp-gruu")&&(e._ua.contact.temp_gruu=n.getParam("temp-gruu").replace(/"/g,"")),n.hasParam("pub-gruu")&&(e._ua.contact.pub_gruu=n.getParam("pub-gruu").replace(/"/g,"")),e._registered||(e._registered=!0,e._ua.registered({response:t}));break;case/^423$/.test(t.status_code):t.hasHeader("min-expires")?(e._expires=t.getHeader("min-expires"),e.register()):(u("423 response received for REGISTER without Min-Expires"),e._registrationFailure(t,a.causes.SIP_FAILURE_CODE));break;default:var o=s.sipErrorCause(t.status_code);e._registrationFailure(t,o)}}});this._registering=!0,r.send()}}},{key:"unregister",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this._registered){this._registered=!1,null!==this._registrationTimer&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);var n=this._extraHeaders.slice();t.all?n.push("Contact: *"+this._extraContactParams):n.push("Contact: "+this._contact+";expires=0"+this._extraContactParams),n.push("Expires: 0");var r=new o.OutgoingRequest(a.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},n);new l(this._ua,r,{onRequestTimeout:function(){e._unregistered(null,a.causes.REQUEST_TIMEOUT)},onTransportError:function(){e._unregistered(null,a.causes.CONNECTION_ERROR)},onAuthenticated:function(){e._cseq+=1},onReceiveResponse:function(t){switch(!0){case/^1[0-9]{2}$/.test(t.status_code):break;case/^2[0-9]{2}$/.test(t.status_code):e._unregistered(t);break;default:var n=s.sipErrorCause(t.status_code);e._unregistered(t,n)}}}).send()}else u("already unregistered")}},{key:"close",value:function(){this._registered&&this.unregister()}},{key:"onTransportClosed",value:function(){this._registering=!1,null!==this._registrationTimer&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),this._registered&&(this._registered=!1,this._ua.unregistered({}))}},{key:"_registrationFailure",value:function(e,t){this._registering=!1,this._ua.registrationFailed({response:e||null,cause:t}),this._registered&&(this._registered=!1,this._ua.unregistered({response:e||null,cause:t}))}},{key:"_unregistered",value:function(e,t){this._registering=!1,this._registered=!1,this._ua.unregistered({response:e||null,cause:t||null})}}]),e}()},{"./Constants":2,"./RequestSender":18,"./SIPMessage":19,"./Utils":26,debug:29}],18:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n"),this.setHeader("via",""),this.setHeader("max-forwards",l.MAX_FORWARDS);var d=i.to_display_name||0===i.to_display_name?'"'+i.to_display_name+'" ':"";d+="<"+(i.to_uri||n)+">",d+=i.to_tag?";tag="+i.to_tag:"",this.to=c.parse(d),this.setHeader("to",d);var h=void 0;h=i.from_display_name||0===i.from_display_name?'"'+i.from_display_name+'" ':r.configuration.display_name?'"'+r.configuration.display_name+'" ':"",h+="<"+(i.from_uri||r.configuration.uri)+">;tag=",h+=i.from_tag||u.newTag(),this.from=c.parse(h),this.setHeader("from",h);var f=i.call_id||r.configuration.jssip_id+u.createRandomToken(15);this.call_id=f,this.setHeader("call-id",f);var p=i.cseq||Math.floor(1e4*Math.random());this.cseq=p,this.setHeader("cseq",p+" "+t)}return a(e,[{key:"setHeader",value:function(e,t){for(var n=new RegExp("^\\s*"+e+"\\s*:","i"),r=0;r1&&void 0!==arguments[1]?arguments[1]:0;if(e=u.headerize(e),this.headers[e]){if(!(t>=this.headers[e].length)){var n=this.headers[e][t],r=n.raw;if(n.parsed)return n.parsed;var i=d.parse(r,e.replace(/-/g,"_"));return-1===i?(this.headers[e].splice(t,1),void h('error parsing "'+e+'" header field with value "'+r+'"')):(n.parsed=i,i)}h('not so many "'+e+'" headers present')}else h('header "'+e+'" not present')}},{key:"s",value:function(e,t){return this.parseHeader(e,t)}},{key:"setHeader",value:function(e,t){var n={raw:t};this.headers[u.headerize(e)]=[n]}},{key:"parseSDP",value:function(e){return!e&&this.sdp?this.sdp:(this.sdp=o.parse(this.body||""),this.sdp)}},{key:"toString",value:function(){return this.data}}]),e}(),m=function(e){function t(e){s(this,t);var n=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.ua=e,n.headers={},n.ruri=null,n.transport=null,n.server_transaction=null,n}return i(t,_),a(t,[{key:"reply",value:function(e,t,n,r,i,s){var a=[],o=this.getHeader("To");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);t=t||l.REASON_PHRASE[e]||"",n=u.cloneArray(n);var c="SIP/2.0 "+e+" "+t+"\r\n";if(this.method===l.INVITE&&e>100&&e<=200){var d=this.getHeaders("record-route"),h=!0,f=!1,p=void 0;try{for(var _,m=d[Symbol.iterator]();!(h=(_=m.next()).done);h=!0)c+="Record-Route: "+_.value+"\r\n"}catch(e){f=!0,p=e}finally{try{!h&&m.return&&m.return()}finally{if(f)throw p}}}var v=this.getHeaders("via"),g=!0,y=!1,T=void 0;try{for(var C,S=v[Symbol.iterator]();!(g=(C=S.next()).done);g=!0)c+="Via: "+C.value+"\r\n"}catch(e){y=!0,T=e}finally{try{!g&&S.return&&S.return()}finally{if(y)throw T}}!this.to_tag&&e>100?o+=";tag="+u.newTag():this.to_tag&&!this.s("to").hasParam("tag")&&(o+=";tag="+this.to_tag),c+="To: "+o+"\r\n",c+="From: "+this.getHeader("From")+"\r\n",c+="Call-ID: "+this.call_id+"\r\n",c+="CSeq: "+this.cseq+" "+this.method+"\r\n";var E=!0,b=!1,R=void 0;try{for(var A,w=n[Symbol.iterator]();!(E=(A=w.next()).done);E=!0)c+=A.value.trim()+"\r\n"}catch(e){b=!0,R=e}finally{try{!E&&w.return&&w.return()}finally{if(b)throw R}}switch(this.method){case l.INVITE:this.ua.configuration.session_timers&&a.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&a.push("gruu"),a.push("ice","replaces");break;case l.UPDATE:this.ua.configuration.session_timers&&a.push("timer"),r&&a.push("ice"),a.push("replaces")}a.push("outbound"),this.method===l.OPTIONS?(c+="Allow: "+l.ALLOWED_METHODS+"\r\n",c+="Accept: "+l.ACCEPTED_BODY_TYPES+"\r\n"):405===e?c+="Allow: "+l.ALLOWED_METHODS+"\r\n":415===e&&(c+="Accept: "+l.ACCEPTED_BODY_TYPES+"\r\n"),c+="Supported: "+a+"\r\n",r?(c+="Content-Type: application/sdp\r\n",c+="Content-Length: "+u.str_utf8_length(r)+"\r\n\r\n",c+=r):c+="Content-Length: 0\r\n\r\n",this.server_transaction.receiveResponse(e,c,i,s)}},{key:"reply_sl",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this.getHeaders("via");if(!e||e<100||e>699)throw new TypeError("Invalid status_code: "+e);if(t&&"string"!=typeof t&&!(t instanceof String))throw new TypeError("Invalid reason_phrase: "+t);var r="SIP/2.0 "+e+" "+(t=t||l.REASON_PHRASE[e]||"")+"\r\n",i=!0,s=!1,a=void 0;try{for(var o,c=n[Symbol.iterator]();!(i=(o=c.next()).done);i=!0)r+="Via: "+o.value+"\r\n"}catch(e){s=!0,a=e}finally{try{!i&&c.return&&c.return()}finally{if(s)throw a}}var d=this.getHeader("To");!this.to_tag&&e>100?d+=";tag="+u.newTag():this.to_tag&&!this.s("to").hasParam("tag")&&(d+=";tag="+this.to_tag),r+="To: "+d+"\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+="Content-Length: 0\r\n\r\n",this.transport.send(r)}}]),t}(),v=function(e){function t(){s(this,t);var e=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.headers={},e.status_code=null,e.reason_phrase=null,e}return i(t,_),t}();t.exports={OutgoingRequest:f,InitialOutgoingInviteRequest:p,IncomingRequest:m,IncomingResponse:v}},{"./Constants":2,"./Grammar":7,"./NameAddrHeader":10,"./Utils":26,debug:29,"sdp-transform":36}],20:[function(e,t,n){"use strict";var r=e("./Utils"),i=e("./Grammar"),s=e("debug")("JsSIP:ERROR:Socket");s.log=console.warn.bind(console),n.isSocket=function(e){if(Array.isArray(e))return!1;if(void 0===e)return s("undefined JsSIP.Socket instance"),!1;try{if(!r.isString(e.url))throw s("missing or invalid JsSIP.Socket url property"),new Error;if(!r.isString(e.via_transport))throw s("missing or invalid JsSIP.Socket via_transport property"),new Error;if(-1===i.parse(e.sip_uri,"SIP_URI"))throw s("missing or invalid JsSIP.Socket sip_uri property"),new Error}catch(e){return!1}try{["connect","disconnect","send"].forEach(function(t){if(!r.isFunction(e[t]))throw s("missing or invalid JsSIP.Socket method: "+t),new Error})}catch(e){return!1}return!0}},{"./Grammar":7,"./Utils":26,debug:29}],21:[function(e,t,n){"use strict";var r=500;t.exports={T1:r,T2:4e3,T4:5e3,TIMER_B:32e3,TIMER_D:0,TIMER_F:32e3,TIMER_H:32e3,TIMER_I:0,TIMER_J:0,TIMER_K:0,TIMER_L:32e3,TIMER_M:32e3,PROVISIONAL_RESPONSE_INTERVAL:6e4}},{}],22:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=function(){function e(e,t){for(var n=0;n=100&&n<=199)switch(this.state){case m.STATUS_CALLING:this.stateChanged(m.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(e);break;case m.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(e)}else if(n>=200&&n<=299)switch(this.state){case m.STATUS_CALLING:case m.STATUS_PROCEEDING:this.stateChanged(m.STATUS_ACCEPTED),this.M=setTimeout(function(){t.timer_M()},c.TIMER_M),this.eventHandlers.onReceiveResponse(e);break;case m.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(e)}else if(n>=300&&n<=699)switch(this.state){case m.STATUS_CALLING:case m.STATUS_PROCEEDING:this.stateChanged(m.STATUS_COMPLETED),this.sendACK(e),this.eventHandlers.onReceiveResponse(e);break;case m.STATUS_COMPLETED:this.sendACK(e)}}},{key:"C",get:function(){return m}}]),t}(),y=function(e){function t(e,n,s,a){r(this,t);var o=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));o.id="z9hG4bK"+Math.floor(1e7*Math.random()),o.transport=n,o.request=s,o.eventHandlers=a;var l="SIP/2.0/"+n.via_transport;return l+=" "+e.configuration.via_host+";branch="+o.id,o.request.setHeader("via",l),o}return s(t,o),a(t,[{key:"send",value:function(){this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){f("transport error occurred for transaction "+this.id),this.eventHandlers.onTransportError()}},{key:"C",get:function(){return m}}]),t}(),T=function(e){function t(e,n,s){r(this,t);var a=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return a.type=m.NON_INVITE_SERVER,a.id=s.via_branch,a.ua=e,a.transport=n,a.request=s,a.last_response="",s.server_transaction=a,a.state=m.STATUS_TRYING,e.newTransaction(a),a}return s(t,o),a(t,[{key:"stateChanged",value:function(e){this.state=e,this.emit("stateChanged")}},{key:"timer_J",value:function(){p("Timer J expired for transaction "+this.id),this.stateChanged(m.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,p("transport error occurred, deleting transaction "+this.id),clearTimeout(this.J),this.stateChanged(m.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"receiveResponse",value:function(e,t,n,r){var i=this;if(100===e)switch(this.state){case m.STATUS_TRYING:this.stateChanged(m.STATUS_PROCEEDING),this.transport.send(t)||this.onTransportError();break;case m.STATUS_PROCEEDING:this.last_response=t,this.transport.send(t)?n&&n():(this.onTransportError(),r&&r())}else if(e>=200&&e<=699)switch(this.state){case m.STATUS_TRYING:case m.STATUS_PROCEEDING:this.stateChanged(m.STATUS_COMPLETED),this.last_response=t,this.J=setTimeout(function(){i.timer_J()},c.TIMER_J),this.transport.send(t)?n&&n():(this.onTransportError(),r&&r());break;case m.STATUS_COMPLETED:}}},{key:"C",get:function(){return m}}]),t}(),C=function(e){function t(e,n,s){r(this,t);var a=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return a.type=m.INVITE_SERVER,a.id=s.via_branch,a.ua=e,a.transport=n,a.request=s,a.last_response="",s.server_transaction=a,a.state=m.STATUS_PROCEEDING,e.newTransaction(a),a.resendProvisionalTimer=null,s.reply(100),a}return s(t,o),a(t,[{key:"stateChanged",value:function(e){this.state=e,this.emit("stateChanged")}},{key:"timer_H",value:function(){_("Timer H expired for transaction "+this.id),this.state===m.STATUS_COMPLETED&&_("ACK not received, dialog will be terminated"),this.stateChanged(m.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_I",value:function(){this.stateChanged(m.STATUS_TERMINATED)}},{key:"timer_L",value:function(){_("Timer L expired for transaction "+this.id),this.state===m.STATUS_ACCEPTED&&(this.stateChanged(m.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,_("transport error occurred, deleting transaction "+this.id),null!==this.resendProvisionalTimer&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),clearTimeout(this.L),clearTimeout(this.H),clearTimeout(this.I),this.stateChanged(m.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"resend_provisional",value:function(){this.transport.send(this.last_response)||this.onTransportError()}},{key:"receiveResponse",value:function(e,t,n,r){var i=this;if(e>=100&&e<=199)switch(this.state){case m.STATUS_PROCEEDING:this.transport.send(t)||this.onTransportError(),this.last_response=t}if(e>100&&e<=199&&this.state===m.STATUS_PROCEEDING)null===this.resendProvisionalTimer&&(this.resendProvisionalTimer=setInterval(function(){i.resend_provisional()},c.PROVISIONAL_RESPONSE_INTERVAL));else if(e>=200&&e<=299)switch(this.state){case m.STATUS_PROCEEDING:this.stateChanged(m.STATUS_ACCEPTED),this.last_response=t,this.L=setTimeout(function(){i.timer_L()},c.TIMER_L),null!==this.resendProvisionalTimer&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case m.STATUS_ACCEPTED:this.transport.send(t)?n&&n():(this.onTransportError(),r&&r())}else if(e>=300&&e<=699)switch(this.state){case m.STATUS_PROCEEDING:null!==this.resendProvisionalTimer&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(t)?(this.stateChanged(m.STATUS_COMPLETED),this.H=setTimeout(function(){i.timer_H()},c.TIMER_H),n&&n()):(this.onTransportError(),r&&r())}}},{key:"C",get:function(){return m}}]),t}();t.exports={C:m,NonInviteClientTransaction:v,InviteClientTransaction:g,AckClientTransaction:y,NonInviteServerTransaction:T,InviteServerTransaction:C,checkTransaction:function(e,t){var n=e._transactions,r=void 0;switch(t.method){case l.INVITE:if(r=n.ist[t.via_branch]){switch(r.state){case m.STATUS_PROCEEDING:r.transport.send(r.last_response);break;case m.STATUS_ACCEPTED:}return!0}break;case l.ACK:if(!(r=n.ist[t.via_branch]))return!1;if(r.state===m.STATUS_ACCEPTED)return!1;if(r.state===m.STATUS_COMPLETED)return r.state=m.STATUS_CONFIRMED,r.I=setTimeout(function(){r.timer_I()},c.TIMER_I),!0;break;case l.CANCEL:return(r=n.ist[t.via_branch])?(t.reply_sl(200),r.state!==m.STATUS_PROCEEDING):(t.reply_sl(481),!0);default:if(r=n.nist[t.via_branch]){switch(r.state){case m.STATUS_TRYING:break;case m.STATUS_PROCEEDING:case m.STATUS_COMPLETED:r.transport.send(r.last_response)}return!0}}}}},{"./Constants":2,"./SIPMessage":19,"./Timers":21,debug:29,events:31}],23:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:l.recovery_options;if(r(this,e),a("new()"),this.status=l.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=n,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1,void 0===t)throw new TypeError("Invalid argument. undefined 'sockets' argument");t instanceof Array||(t=[t]),t.forEach(function(e){if(!s.isSocket(e.socket))throw new TypeError("Invalid argument. invalid 'JsSIP.Socket' instance");if(e.weight&&!Number(e.weight))throw new TypeError("Invalid argument. 'weight' attribute is not a number");this.sockets.push({socket:e.socket,weight:e.weight||0,status:l.SOCKET_STATUS_READY})},this),this._getSocket()}return i(e,[{key:"connect",value:function(){a("connect()"),this.isConnected()?a("Transport is already connected"):this.isConnecting()?a("Transport is connecting"):(this.close_requested=!1,this.status=l.STATUS_CONNECTING,this.onconnecting({socket:this.socket,attempts:this.recover_attempts}),this.close_requested||(this.socket.onconnect=this._onConnect.bind(this),this.socket.ondisconnect=this._onDisconnect.bind(this),this.socket.ondata=this._onData.bind(this),this.socket.connect()))}},{key:"disconnect",value:function(){a("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=l.STATUS_DISCONNECTED,null!==this.recovery_timer&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.socket.onconnect=function(){},this.socket.ondisconnect=function(){},this.socket.ondata=function(){},this.socket.disconnect(),this.ondisconnect()}},{key:"send",value:function(e){if(a("send()"),!this.isConnected())return o("unable to send message, transport is not connected"),!1;var t=e.toString();return a("sending message:\n\n"+t+"\n"),this.socket.send(t)}},{key:"isConnected",value:function(){return this.status===l.STATUS_CONNECTED}},{key:"isConnecting",value:function(){return this.status===l.STATUS_CONNECTING}},{key:"_reconnect",value:function(){var e=this;this.recover_attempts+=1;var t=Math.floor(Math.random()*Math.pow(2,this.recover_attempts)+1);tthis.recovery_options.max_interval&&(t=this.recovery_options.max_interval),a("reconnection attempt: "+this.recover_attempts+". next connection attempt in "+t+" seconds"),this.recovery_timer=setTimeout(function(){e.close_requested||e.isConnected()||e.isConnecting()||(e._getSocket(),e.connect())},1e3*t)}},{key:"_getSocket",value:function(){var e=[];if(this.sockets.forEach(function(t){t.status!==l.SOCKET_STATUS_ERROR&&(0===e.length?e.push(t):t.weight>e[0].weight?e=[t]:t.weight===e[0].weight&&e.push(t))}),0===e.length)return this.sockets.forEach(function(e){e.status=l.SOCKET_STATUS_READY}),void this._getSocket();var t=Math.floor(Math.random()*e.length);this.socket=e[t].socket}},{key:"_onConnect",value:function(){this.recover_attempts=0,this.status=l.STATUS_CONNECTED,null!==this.recovery_timer&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}},{key:"_onDisconnect",value:function(e,t,n){this.status=l.STATUS_DISCONNECTED,this.ondisconnect({socket:this.socket,error:e,code:t,reason:n}),this.close_requested||(this.sockets.forEach(function(e){this.socket===e.socket&&(e.status=l.SOCKET_STATUS_ERROR)},this),this._reconnect(e))}},{key:"_onData",value:function(e){if("\r\n"!==e){if("string"!=typeof e){try{e=String.fromCharCode.apply(null,new Uint8Array(e))}catch(e){return void a("received binary message failed to be converted into string, message discarded")}a("received binary message:\n\n"+e+"\n")}else a("received text message:\n\n"+e+"\n");this.ondata({transport:this,message:e})}else a("received message with CRLF Keep Alive response")}},{key:"via_transport",get:function(){return this.socket.via_transport}},{key:"url",get:function(){return this.socket.url}},{key:"sip_uri",get:function(){return this.socket.sip_uri}}]),e}()},{"./Socket":20,debug:29}],24:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e){this.emit("connecting",e)}function o(e){this._status!==I.STATUS_USER_CLOSED&&(this._status=I.STATUS_READY,this._error=null,this.emit("connected",e),this._dynConfiguration.register&&this._registrator.register())}function l(e){var t=["nict","ict","nist","ist"],n=!0,r=!1,i=void 0;try{for(var s,a=t[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var o=s.value;for(var l in this._transactions[o])Object.prototype.hasOwnProperty.call(this._transactions[o],l)&&this._transactions[o][l].onTransportError()}}catch(e){r=!0,i=e}finally{try{!n&&a.return&&a.return()}finally{if(r)throw i}}this.emit("disconnected",e),this._registrator.onTransportClosed(),this._status!==I.STATUS_USER_CLOSED&&(this._status=I.STATUS_NOT_READY,this._error=I.NETWORK_ERROR)}function u(e){var t=e.transport,n=e.message;if((n=S.parseMessage(n,this))&&!(this._status===I.STATUS_USER_CLOSED&&n instanceof E.IncomingRequest)&&b(n,this,t))if(n instanceof E.IncomingRequest)n.transport=t,this.receiveRequest(n);else if(n instanceof E.IncomingResponse){var r=void 0;switch(n.method){case h.INVITE:(r=this._transactions.ict[n.via_branch])&&r.receiveResponse(n);break;case h.ACK:break;default:(r=this._transactions.nict[n.via_branch])&&r.receiveResponse(n)}}}var c=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=e.anonymous||null,n=e.outbound||null,r="<";return r+=t?this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":this.pub_gruu||this.uri.toString(),!n||(t?this.temp_gruu:this.pub_gruu)||(r+=";ob"),r+=">"}};var r=["password","realm","ha1","display_name","register"];for(var i in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,i)&&(-1!==r.indexOf(i)?Object.defineProperty(this._configuration,i,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,i,{writable:!1,configurable:!1}));A("configuration parameters after validation:");for(var s in this._configuration)if(Object.prototype.hasOwnProperty.call(R.settings,s))switch(s){case"uri":case"registrar_server":A("- "+s+": "+this._configuration[s]);break;case"password":case"ha1":A("- "+s+": NOT SHOWN");break;default:A("- "+s+": "+JSON.stringify(this._configuration[s]))}}},{key:"C",get:function(){return I}},{key:"status",get:function(){return this._status}},{key:"contact",get:function(){return this._contact}},{key:"configuration",get:function(){return this._configuration}},{key:"transport",get:function(){return this._transport}}]),t}()},{"./Config":1,"./Constants":2,"./Exceptions":6,"./Grammar":7,"./Message":9,"./Parser":11,"./RTCSession":12,"./Registrator":17,"./SIPMessage":19,"./Transactions":22,"./Transport":23,"./URI":25,"./Utils":26,"./sanityCheck":28,debug:29,events:31}],25:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n4&&void 0!==arguments[4]?arguments[4]:{},l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};if(r(this,e),!i)throw new TypeError('missing or invalid "host" parameter');this._parameters={},this._headers={},this._scheme=t||s.SIP,this._user=n,this._host=i,this._port=a;for(var u in o)Object.prototype.hasOwnProperty.call(o,u)&&this.setParam(u,o[u]);for(var c in l)Object.prototype.hasOwnProperty.call(l,c)&&this.setHeader(c,l[c])}return i(e,null,[{key:"parse",value:function(e){return-1!==(e=o.parse(e,"SIP_URI"))?e:void 0}}]),i(e,[{key:"setParam",value:function(e,t){e&&(this._parameters[e.toLowerCase()]=void 0===t||null===t?null:t.toString())}},{key:"getParam",value:function(e){if(e)return this._parameters[e.toLowerCase()]}},{key:"hasParam",value:function(e){if(e)return this._parameters.hasOwnProperty(e.toLowerCase())&&!0||!1}},{key:"deleteParam",value:function(e){if(e=e.toLowerCase(),this._parameters.hasOwnProperty(e)){var t=this._parameters[e];return delete this._parameters[e],t}}},{key:"clearParams",value:function(){this._parameters={}}},{key:"setHeader",value:function(e,t){this._headers[a.headerize(e)]=Array.isArray(t)?t:[t]}},{key:"getHeader",value:function(e){if(e)return this._headers[a.headerize(e)]}},{key:"hasHeader",value:function(e){if(e)return this._headers.hasOwnProperty(a.headerize(e))&&!0||!1}},{key:"deleteHeader",value:function(e){if(e=a.headerize(e),this._headers.hasOwnProperty(e)){var t=this._headers[e];return delete this._headers[e],t}}},{key:"clearHeaders",value:function(){this._headers={}}},{key:"clone",value:function(){return new e(this._scheme,this._user,this._host,this._port,JSON.parse(JSON.stringify(this._parameters)),JSON.parse(JSON.stringify(this._headers)))}},{key:"toString",value:function(){var e=[],t=this._scheme+":";this._user&&(t+=a.escapeUser(this._user)+"@"),t+=this._host,(this._port||0===this._port)&&(t+=":"+this._port);for(var n in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,n)&&(t+=";"+n,null!==this._parameters[n]&&(t+="="+this._parameters[n]));for(var r in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,r)){var i=!0,s=!1,o=void 0;try{for(var l,u=this._headers[r][Symbol.iterator]();!(i=(l=u.next()).done);i=!0){var c=l.value;e.push(r+"="+c)}}catch(e){s=!0,o=e}finally{try{!i&&u.return&&u.return()}finally{if(s)throw o}}}return e.length>0&&(t+="?"+e.join("&")),t}},{key:"toAor",value:function(e){var t=this._scheme+":";return this._user&&(t+=a.escapeUser(this._user)+"@"),t+=this._host,e&&(this._port||0===this._port)&&(t+=":"+this._port),t}},{key:"scheme",get:function(){return this._scheme},set:function(e){this._scheme=e.toLowerCase()}},{key:"user",get:function(){return this._user},set:function(e){this._user=e}},{key:"host",get:function(){return this._host},set:function(e){this._host=e.toLowerCase()}},{key:"port",get:function(){return this._port},set:function(e){this._port=0===e?e:parseInt(e,10)||null}}]),e}()},{"./Constants":2,"./Grammar":7,"./Utils":26}],26:[function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=e("./Constants"),s=e("./URI"),a=e("./Grammar");n.str_utf8_length=function(e){return unescape(encodeURIComponent(e)).length};var o=n.isFunction=function(e){return void 0!==e&&"[object Function]"===Object.prototype.toString.call(e)};n.isString=function(e){return void 0!==e&&"[object String]"===Object.prototype.toString.call(e)},n.isDecimal=function(e){return!isNaN(e)&&parseFloat(e)===parseInt(e,10)},n.isEmpty=function(e){return null===e||""===e||void 0===e||Array.isArray(e)&&0===e.length||"number"==typeof e&&isNaN(e)},n.hasMethods=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r1&&void 0!==arguments[1]?arguments[1]:32,n=void 0,r="";for(n=0;n>>32-t}function n(e,t){var n=2147483648&e,r=2147483648&t,i=1073741824&e,s=1073741824&t,a=(1073741823&e)+(1073741823&t);return i&s?2147483648^a^n^r:i|s?1073741824&a?3221225472^a^n^r:1073741824^a^n^r:a^n^r}function r(e,t,n){return e&t|~e&n}function i(e,t,n){return e&n|t&~n}function s(e,t,n){return e^t^n}function a(e,t,n){return t^(e|~n)}function o(e,i,s,a,o,l,u){return e=n(e,n(n(r(i,s,a),o),u)),n(t(e,l),i)}function l(e,r,s,a,o,l,u){return e=n(e,n(n(i(r,s,a),o),u)),n(t(e,l),r)}function u(e,r,i,a,o,l,u){return e=n(e,n(n(s(r,i,a),o),u)),n(t(e,l),r)}function c(e,r,i,s,o,l,u){return e=n(e,n(n(a(r,i,s),o),u)),n(t(e,l),r)}function d(e){var t="",n="",r=void 0;for(r=0;r<=3;r++)t+=(n="0"+(e>>>8*r&255).toString(16)).substr(n.length-2,2);return t}var h=[],f=void 0,p=void 0,_=void 0,m=void 0,v=void 0,g=void 0,y=void 0,T=void 0,C=void 0;for(h=function(e){for(var t=void 0,n=e.length,r=n+8,i=16*((r-r%64)/64+1),s=new Array(i-1),a=0,o=0;o>>29,s}(e=function(e){e=e.replace(/\r\n/g,"\n");for(var t="",n=0;n127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(63&r|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(63&r|128))}return t}(e)),g=1732584193,y=4023233417,T=2562383102,C=271733878,f=0;f1)return o("more than one Via header field present in the response, dropping the response"),!1},function(){if(a.str_utf8_length(d.body)=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},n.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),n.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],n.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},n.enable(i())}).call(this,e("_process"))},{"./debug":30,_process:33}],30:[function(e,t,n){function r(e){var t,r=0;for(t in e)r=(r<<5)-r+e.charCodeAt(t),r|=0;return n.colors[Math.abs(r)%n.colors.length]}function i(e){function t(){if(t.enabled){var e=t,r=+new Date,s=r-(i||r);e.diff=s,e.prev=i,e.curr=r,i=r;for(var a=new Array(arguments.length),o=0;o0&&this._events[e].length>n&&(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},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}if(!i(t))throw TypeError("listener must be a function");var r=!1;return n.listener=t,this.on(e,n),this},r.prototype.removeListener=function(e,t){var n,r,s,o;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],s=n.length,r=-1,n===t||i(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(a(n)){for(o=s;o-- >0;)if(n[o]===t||n[o].listener&&n[o].listener===t){r=o;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,n;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(n=this._events[e],i(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},{}],32:[function(e,t,n){function r(e){if(!((e=String(e)).length>100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*d;case"days":case"day":case"d":return n*c;case"hours":case"hour":case"hrs":case"hr":case"h":return n*u;case"minutes":case"minute":case"mins":case"min":case"m":return n*l;case"seconds":case"second":case"secs":case"sec":case"s":return n*o;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function i(e){return e>=c?Math.round(e/c)+"d":e>=u?Math.round(e/u)+"h":e>=l?Math.round(e/l)+"m":e>=o?Math.round(e/o)+"s":e+"ms"}function s(e){return a(e,c,"day")||a(e,u,"hour")||a(e,l,"minute")||a(e,o,"second")||e+" ms"}function a(e,t,n){if(!(e0)return r(e);if("number"===n&&!1===isNaN(e))return t.long?s(e):i(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],33:[function(e,t,n){function r(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function s(e){if(d===setTimeout)return setTimeout(e,0);if((d===r||!d)&&setTimeout)return d=setTimeout,setTimeout(e,0);try{return d(e,0)}catch(t){try{return d.call(null,e,0)}catch(t){return d.call(this,e,0)}}}function a(e){if(h===clearTimeout)return clearTimeout(e);if((h===i||!h)&&clearTimeout)return h=clearTimeout,clearTimeout(e);try{return h(e)}catch(t){try{return h.call(null,e)}catch(t){return h.call(this,e)}}}function o(){m&&p&&(m=!1,p.length?_=p.concat(_):v=-1,_.length&&l())}function l(){if(!m){var e=s(o);m=!0;for(var t=_.length;t;){for(p=_,_=[];++v1)for(var n=1;n=14393&&-1===e.indexOf("?transport=udp")}),delete e.url,e.urls=i?r[0]:r,!!r.length}return!1})}function s(e,t){var n={codecs:[],headerExtensions:[],fecMechanisms:[]},r=function(e,t){e=parseInt(e,10);for(var n=0;n0;o--)this._iceGatherers=new e.RTCIceGatherer({iceServers:n.iceServers,gatherPolicy:n.iceTransportPolicy});else n.iceCandidatePoolSize=0;this._config=n,this.transceivers=[],this._sdpSessionId=l.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0};return n.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this.dispatchEvent(e),"function"==typeof this.onicegatheringstatechange&&this.onicegatheringstatechange(e)},n.prototype.getConfiguration=function(){return this._config},n.prototype.getLocalStreams=function(){return this.localStreams},n.prototype.getRemoteStreams=function(){return this.remoteStreams},n.prototype._createTransceiver=function(e){var t=this.transceivers.length>0,n={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:e,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,wantReceive:!0};if(this.usingBundle&&t)n.iceTransport=this.transceivers[0].iceTransport,n.dtlsTransport=this.transceivers[0].dtlsTransport;else{var r=this._createIceAndDtlsTransports();n.iceTransport=r.iceTransport,n.dtlsTransport=r.dtlsTransport}return this.transceivers.push(n),n},n.prototype.addTrack=function(t,n){for(var r,i=0;i=15025)e.getTracks().forEach(function(t){n.addTrack(t,e)});else{var r=e.clone();e.getTracks().forEach(function(e,t){var n=r.getTracks()[t];e.addEventListener("enabled",function(e){n.enabled=e.enabled})}),r.getTracks().forEach(function(e){n.addTrack(e,r)})}},n.prototype.removeStream=function(e){var t=this.localStreams.indexOf(e);t>-1&&(this.localStreams.splice(t,1),this._maybeFireNegotiationNeeded())},n.prototype.getSenders=function(){return this.transceivers.filter(function(e){return!!e.rtpSender}).map(function(e){return e.rtpSender})},n.prototype.getReceivers=function(){return this.transceivers.filter(function(e){return!!e.rtpReceiver}).map(function(e){return e.rtpReceiver})},n.prototype._createIceGatherer=function(t,n){var r=this;if(n&&t>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var i=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(i,"state",{value:"new",writable:!0}),this.transceivers[t].candidates=[],this.transceivers[t].bufferCandidates=function(e){var n=!e.candidate||0===Object.keys(e.candidate).length;i.state=n?"completed":"gathering",null!==r.transceivers[t].candidates&&r.transceivers[t].candidates.push(e.candidate)},i.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),i},n.prototype._gather=function(t,n){var r=this,i=this.transceivers[n].iceGatherer;if(!i.onlocalcandidate){var s=this.transceivers[n].candidates;this.transceivers[n].candidates=null,i.removeEventListener("localcandidate",this.transceivers[n].bufferCandidates),i.onlocalcandidate=function(e){if(!(r.usingBundle&&n>0)){var s=new Event("icecandidate");s.candidate={sdpMid:t,sdpMLineIndex:n};var a=e.candidate,o=!a||0===Object.keys(a).length;o?"new"!==i.state&&"gathering"!==i.state||(i.state="completed"):("new"===i.state&&(i.state="gathering"),a.component=1,s.candidate.candidate=l.writeCandidate(a));var u=l.splitSections(r.localDescription.sdp);u[s.candidate.sdpMLineIndex+1]+=o?"a=end-of-candidates\r\n":"a="+s.candidate.candidate+"\r\n",r.localDescription.sdp=u.join("");var c=r.transceivers.every(function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state});"gathering"!==r.iceGatheringState&&(r.iceGatheringState="gathering",r._emitGatheringStateChange()),o||(r.dispatchEvent(s),"function"==typeof r.onicecandidate&&r.onicecandidate(s)),c&&(r.dispatchEvent(new Event("icecandidate")),"function"==typeof r.onicecandidate&&r.onicecandidate(new Event("icecandidate")),r.iceGatheringState="complete",r._emitGatheringStateChange())}},e.setTimeout(function(){s.forEach(function(e){var t=new Event("RTCIceGatherEvent");t.candidate=e,i.onlocalcandidate(t)})},0)}},n.prototype._createIceAndDtlsTransports=function(){var t=this,n=new e.RTCIceTransport(null);n.onicestatechange=function(){t._updateConnectionState()};var r=new e.RTCDtlsTransport(n);return r.ondtlsstatechange=function(){t._updateConnectionState()},r.onerror=function(){Object.defineProperty(r,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:n,dtlsTransport:r}},n.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var n=this.transceivers[e].iceTransport;n&&(delete n.onicestatechange,delete this.transceivers[e].iceTransport);var r=this.transceivers[e].dtlsTransport;r&&(delete r.ondtlsstatechange,delete r.onerror,delete this.transceivers[e].dtlsTransport)},n.prototype._transceive=function(e,n,r){var i=s(e.localCapabilities,e.remoteCapabilities);n&&e.rtpSender&&(i.encodings=e.sendEncodingParameters,i.rtcp={cname:l.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(i.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(i)),r&&e.rtpReceiver&&i.codecs.length>0&&("video"===e.kind&&e.recvEncodingParameters&&t<15019&&e.recvEncodingParameters.forEach(function(e){delete e.rtx}),i.encodings=e.recvEncodingParameters,i.rtcp={cname:e.rtcpParameters.cname,compound:e.rtcpParameters.compound},e.sendEncodingParameters.length&&(i.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(i))},n.prototype.setLocalDescription=function(e){var t=this,n=arguments;if(!a("setLocalDescription",e.type,this.signalingState))return new Promise(function(r,i){var s=new Error("Can not set local "+e.type+" in state "+t.signalingState);s.name="InvalidStateError",n.length>2&&"function"==typeof n[2]&&n[2].apply(null,[s]),i(s)});var r,i;if("offer"===e.type)r=l.splitSections(e.sdp),i=r.shift(),r.forEach(function(e,n){var r=l.parseRtpParameters(e);t.transceivers[n].localCapabilities=r}),this.transceivers.forEach(function(e,n){t._gather(e.mid,n)});else if("answer"===e.type){r=l.splitSections(t.remoteDescription.sdp),i=r.shift();var o=l.matchPrefix(i,"a=ice-lite").length>0;r.forEach(function(e,n){var r=t.transceivers[n],a=r.iceGatherer,u=r.iceTransport,c=r.dtlsTransport,d=r.localCapabilities,h=r.remoteCapabilities;if(!(l.isRejected(e)&&1===!l.matchPrefix(e,"a=bundle-only").length)&&!r.isDatachannel){var f=l.getIceParameters(e,i),p=l.getDtlsParameters(e,i);o&&(p.role="server"),t.usingBundle&&0!==n||(t._gather(r.mid,n),"new"===u.state&&u.start(a,f,o?"controlling":"controlled"),"new"===c.state&&c.start(p));var _=s(d,h);t._transceive(r,_.codecs.length>0,!1)}})}switch(this.localDescription={type:e.type,sdp:e.sdp},e.type){case"offer":this._updateSignalingState("have-local-offer");break;case"answer":this._updateSignalingState("stable");break;default:throw new TypeError('unsupported type "'+e.type+'"')}var u=arguments.length>1&&"function"==typeof arguments[1]&&arguments[1];return new Promise(function(e){u&&u.apply(null),e()})},n.prototype.setRemoteDescription=function(n){var r=this,i=arguments;if(!a("setRemoteDescription",n.type,this.signalingState))return new Promise(function(e,t){var s=new Error("Can not set remote "+n.type+" in state "+r.signalingState);s.name="InvalidStateError",i.length>2&&"function"==typeof i[2]&&i[2].apply(null,[s]),t(s)});var s={};this.remoteStreams.forEach(function(e){s[e.id]=e});var u=[],c=l.splitSections(n.sdp),d=c.shift(),h=l.matchPrefix(d,"a=ice-lite").length>0,f=l.matchPrefix(d,"a=group:BUNDLE ").length>0;this.usingBundle=f;var p=l.matchPrefix(d,"a=ice-options:")[0];switch(this.canTrickleIceCandidates=!!p&&p.substr(14).split(" ").indexOf("trickle")>=0,c.forEach(function(i,a){var c=l.splitLines(i),p=l.getKind(i),_=l.isRejected(i)&&1===!l.matchPrefix(i,"a=bundle-only").length,m=c[0].substr(2).split(" ")[2],v=l.getDirection(i,d),g=l.parseMsid(i),y=l.getMid(i)||l.generateIdentifier();if("application"!==p||"DTLS/SCTP"!==m){var T,C,S,E,b,R,A,w,I,k,O,P=l.parseRtpParameters(i);_||(k=l.getIceParameters(i,d),(O=l.getDtlsParameters(i,d)).role="client"),A=l.parseRtpEncodingParameters(i);var x=l.parseRtcpParameters(i),N=l.matchPrefix(i,"a=end-of-candidates",d).length>0,D=l.matchPrefix(i,"a=candidate:").map(function(e){return l.parseCandidate(e)}).filter(function(e){return 1===e.component});if(("offer"===n.type||"answer"===n.type)&&!_&&f&&a>0&&r.transceivers[a]&&(r._disposeIceAndDtlsTransports(a),r.transceivers[a].iceGatherer=r.transceivers[0].iceGatherer,r.transceivers[a].iceTransport=r.transceivers[0].iceTransport,r.transceivers[a].dtlsTransport=r.transceivers[0].dtlsTransport,r.transceivers[a].rtpSender&&r.transceivers[a].rtpSender.setTransport(r.transceivers[0].dtlsTransport),r.transceivers[a].rtpReceiver&&r.transceivers[a].rtpReceiver.setTransport(r.transceivers[0].dtlsTransport)),"offer"!==n.type||_)"answer"!==n.type||_||(C=(T=r.transceivers[a]).iceGatherer,S=T.iceTransport,E=T.dtlsTransport,b=T.rtpReceiver,R=T.sendEncodingParameters,w=T.localCapabilities,r.transceivers[a].recvEncodingParameters=A,r.transceivers[a].remoteCapabilities=P,r.transceivers[a].rtcpParameters=x,D.length&&"new"===S.state&&(!h&&!N||f&&0!==a?D.forEach(function(e){o(T.iceTransport,e)}):S.setRemoteCandidates(D)),f&&0!==a||("new"===S.state&&S.start(C,k,"controlling"),"new"===E.state&&E.start(O)),r._transceive(T,"sendrecv"===v||"recvonly"===v,"sendrecv"===v||"sendonly"===v),!b||"sendrecv"!==v&&"sendonly"!==v?delete T.rtpReceiver:(I=b.track,g?(s[g.stream]||(s[g.stream]=new e.MediaStream),s[g.stream].addTrack(I),u.push([I,b,s[g.stream]])):(s.default||(s.default=new e.MediaStream),s.default.addTrack(I),u.push([I,b,s.default]))));else{(T=r.transceivers[a]||r._createTransceiver(p)).mid=y,T.iceGatherer||(T.iceGatherer=r._createIceGatherer(a,f)),D.length&&"new"===T.iceTransport.state&&(!N||f&&0!==a?D.forEach(function(e){o(T.iceTransport,e)}):T.iceTransport.setRemoteCandidates(D)),w=e.RTCRtpReceiver.getCapabilities(p),t<15019&&(w.codecs=w.codecs.filter(function(e){return"rtx"!==e.name})),R=T.sendEncodingParameters||[{ssrc:1001*(2*a+2)}];var U=!1;if(("sendrecv"===v||"sendonly"===v)&&(U=!T.rtpReceiver,b=T.rtpReceiver||new e.RTCRtpReceiver(T.dtlsTransport,p),U)){var M;I=b.track,g?(s[g.stream]||(s[g.stream]=new e.MediaStream,Object.defineProperty(s[g.stream],"id",{get:function(){return g.stream}})),Object.defineProperty(I,"id",{get:function(){return g.track}}),M=s[g.stream]):(s.default||(s.default=new e.MediaStream),M=s.default),M.addTrack(I),u.push([I,b,M])}T.localCapabilities=w,T.remoteCapabilities=P,T.rtpReceiver=b,T.rtcpParameters=x,T.sendEncodingParameters=R,T.recvEncodingParameters=A,r._transceive(r.transceivers[a],!1,U)}}else r.transceivers[a]={mid:y,isDatachannel:!0}}),void 0===this._dtlsRole&&(this._dtlsRole="offer"===n.type?"active":"passive"),this.remoteDescription={type:n.type,sdp:n.sdp},n.type){case"offer":this._updateSignalingState("have-remote-offer");break;case"answer":this._updateSignalingState("stable");break;default:throw new TypeError('unsupported type "'+n.type+'"')}return Object.keys(s).forEach(function(t){var n=s[t];if(n.getTracks().length){if(-1===r.remoteStreams.indexOf(n)){r.remoteStreams.push(n);var i=new Event("addstream");i.stream=n,e.setTimeout(function(){r.dispatchEvent(i),"function"==typeof r.onaddstream&&r.onaddstream(i)})}u.forEach(function(t){var i=t[0],s=t[1];if(n.id===t[2].id){var a=new Event("track");a.track=i,a.receiver=s,a.transceiver={receiver:s},a.streams=[n],e.setTimeout(function(){r.dispatchEvent(a),"function"==typeof r.ontrack&&r.ontrack(a)})}})}}),e.setTimeout(function(){r&&r.transceivers&&r.transceivers.forEach(function(e){e.iceTransport&&"new"===e.iceTransport.state&&e.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),e.iceTransport.addRemoteCandidate({}))})},4e3),new Promise(function(e){i.length>1&&"function"==typeof i[1]&&i[1].apply(null),e()})},n.prototype.close=function(){this.transceivers.forEach(function(e){e.iceTransport&&e.iceTransport.stop(),e.dtlsTransport&&e.dtlsTransport.stop(),e.rtpSender&&e.rtpSender.stop(),e.rtpReceiver&&e.rtpReceiver.stop()}),this._updateSignalingState("closed")},n.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this.dispatchEvent(t),"function"==typeof this.onsignalingstatechange&&this.onsignalingstatechange(t)},n.prototype._maybeFireNegotiationNeeded=function(){var t=this;"stable"===this.signalingState&&!0!==this.needNegotiation&&(this.needNegotiation=!0,e.setTimeout(function(){if(!1!==t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t.dispatchEvent(e),"function"==typeof t.onnegotiationneeded&&t.onnegotiationneeded(e)}},0))},n.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(e){t[e.iceTransport.state]++,t[e.dtlsTransport.state]++}),t.connected+=t.completed,e="new",t.failed>0?e="failed":t.connecting>0||t.checking>0?e="connecting":t.disconnected>0?e="disconnected":t.new>0?e="new":(t.connected>0||t.completed>0)&&(e="connected"),e!==this.iceConnectionState){this.iceConnectionState=e;var n=new Event("iceconnectionstatechange");this.dispatchEvent(n),"function"==typeof this.oniceconnectionstatechange&&this.oniceconnectionstatechange(n)}},n.prototype.createOffer=function(){var n,i=this,s=arguments;1===arguments.length&&"function"!=typeof arguments[0]?n=arguments[0]:3===arguments.length&&(n=arguments[2]);var a=this.transceivers.filter(function(e){return"audio"===e.kind}).length,o=this.transceivers.filter(function(e){return"video"===e.kind}).length;if(n){if(n.mandatory||n.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==n.offerToReceiveAudio&&(a=!0===n.offerToReceiveAudio?1:!1===n.offerToReceiveAudio?0:n.offerToReceiveAudio),void 0!==n.offerToReceiveVideo&&(o=!0===n.offerToReceiveVideo?1:!1===n.offerToReceiveVideo?0:n.offerToReceiveVideo)}for(this.transceivers.forEach(function(e){"audio"===e.kind?--a<0&&(e.wantReceive=!1):"video"===e.kind&&--o<0&&(e.wantReceive=!1)});a>0||o>0;)a>0&&(this._createTransceiver("audio"),a--),o>0&&(this._createTransceiver("video"),o--);var u=l.writeSessionBoilerplate(this._sdpSessionId,this._sdpSessionVersion++);this.transceivers.forEach(function(n,r){var s=n.track,a=n.kind,o=l.generateIdentifier();n.mid=o,n.iceGatherer||(n.iceGatherer=i._createIceGatherer(r,i.usingBundle));var u=e.RTCRtpSender.getCapabilities(a);t<15019&&(u.codecs=u.codecs.filter(function(e){return"rtx"!==e.name})),u.codecs.forEach(function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1")});var c=n.sendEncodingParameters||[{ssrc:1001*(2*r+1)}];s&&t>=15019&&"video"===a&&!c[0].rtx&&(c[0].rtx={ssrc:c[0].ssrc+1}),n.wantReceive&&(n.rtpReceiver=new e.RTCRtpReceiver(n.dtlsTransport,a)),n.localCapabilities=u,n.sendEncodingParameters=c}),"max-compat"!==this._config.bundlePolicy&&(u+="a=group:BUNDLE "+this.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"),u+="a=ice-options:trickle\r\n",this.transceivers.forEach(function(e,t){u+=r(e,e.localCapabilities,"offer",e.stream,i._dtlsRole),u+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===i.iceGatheringState||0!==t&&i.usingBundle||(e.iceGatherer.getLocalCandidates().forEach(function(e){e.component=1,u+="a="+l.writeCandidate(e)+"\r\n"}),"completed"===e.iceGatherer.state&&(u+="a=end-of-candidates\r\n"))});var c=new e.RTCSessionDescription({type:"offer",sdp:u});return new Promise(function(e){if(s.length>0&&"function"==typeof s[0])return s[0].apply(null,[c]),void e();e(c)})},n.prototype.createAnswer=function(){var n=this,i=arguments,a=l.writeSessionBoilerplate(this._sdpSessionId,this._sdpSessionVersion++);this.usingBundle&&(a+="a=group:BUNDLE "+this.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n");var o=l.splitSections(this.remoteDescription.sdp).length-1;this.transceivers.forEach(function(e,i){if(!(i+1>o))if(e.isDatachannel)a+="m=application 0 DTLS/SCTP 5000\r\nc=IN IP4 0.0.0.0\r\na=mid:"+e.mid+"\r\n";else{if(e.stream){var l;"audio"===e.kind?l=e.stream.getAudioTracks()[0]:"video"===e.kind&&(l=e.stream.getVideoTracks()[0]),l&&t>=15019&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1})}var u=s(e.localCapabilities,e.remoteCapabilities);!u.codecs.filter(function(e){return"rtx"===e.name.toLowerCase()}).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,a+=r(e,u,"answer",e.stream,n._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(a+="a=rtcp-rsize\r\n")}});var u=new e.RTCSessionDescription({type:"answer",sdp:a});return new Promise(function(e){if(i.length>0&&"function"==typeof i[0])return i[0].apply(null,[u]),void e();e(u)})},n.prototype.addIceCandidate=function(e){var t,n;if(e&&""!==e.candidate){if(void 0===e.sdpMLineIndex&&!e.sdpMid)throw new TypeError("sdpMLineIndex or sdpMid required");if(this.remoteDescription){var r=e.sdpMLineIndex;if(e.sdpMid)for(var i=0;i0?l.parseCandidate(e.candidate):{};if("tcp"===a.protocol&&(0===a.port||9===a.port))return Promise.resolve();if(a.component&&1!==a.component)return Promise.resolve();if((0===r||r>0&&s.iceTransport!==this.transceivers[0].iceTransport)&&(o(s.iceTransport,a)||((t=new Error("Can not add ICE candidate")).name="OperationError")),!t){var u=e.candidate.trim();0===u.indexOf("a=")&&(u=u.substr(2)),(n=l.splitSections(this.remoteDescription.sdp))[r+1]+="a="+(a.type?u:"end-of-candidates")+"\r\n",this.remoteDescription.sdp=n.join("")}}else(t=new Error("Can not add ICE candidate")).name="OperationError"}else(t=new Error("Can not add ICE candidate without a remote description")).name="InvalidStateError"}else for(var c=0;c2&&"function"==typeof d[2]&&d[2].apply(null,[t]),n(t)):(d.length>1&&"function"==typeof d[1]&&d[1].apply(null),e())})},n.prototype.getStats=function(){var e=[];this.transceivers.forEach(function(t){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(n){t[n]&&e.push(t[n].getStats())})});var t=arguments.length>1&&"function"==typeof arguments[1]&&arguments[1],n=function(e){return{inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};return new Promise(function(r){var i=new Map;Promise.all(e).then(function(e){e.forEach(function(e){Object.keys(e).forEach(function(t){e[t].type=n(e[t]),i.set(t,e[t])})}),t&&t.apply(null,i),r(i)})})},n}},{sdp:39}],35:[function(e,t,n){var r=t.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w\/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-\.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%d trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))? (\S*)(?: (\S*))?/,names:["value","direction","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+" %s"+(e.config?" %s":"")}},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_\/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{push:"invalid",names:["value"]}]};Object.keys(r).forEach(function(e){r[e].forEach(function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")})})},{}],36:[function(e,t,n){var r=e("./parser"),i=e("./writer");n.write=i,n.parse=r.parse,n.parseFmtpConfig=r.parseFmtpConfig,n.parseParams=r.parseParams,n.parsePayloads=r.parsePayloads,n.parseRemoteCandidates=r.parseRemoteCandidates,n.parseImageAttributes=r.parseImageAttributes,n.parseSimulcastStreamList=r.parseSimulcastStreamList},{"./parser":37,"./writer":38}],37:[function(e,t,n){var r=function(e){return String(Number(e))===e?Number(e):e},i=function(e,t,n,i){if(i&&!n)t[i]=r(e[1]);else for(var s=0;s=r)return e;var i=n[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}})},a=function(e,t,n){var r=[e+"="+(t.format instanceof Function?t.format(t.push?n:n[t.name]):t.format)];if(t.names)for(var i=0;i0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},r.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},r.parseFmtp=function(e){for(var t,n={},r=e.substr(e.indexOf(" ")+1).split(";"),i=0;i-1?(n.attribute=e.substr(t+1,r-t-1),n.value=e.substr(r+1)):n.attribute=e.substr(t+1),n},r.getMid=function(e){var t=r.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},r.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},r.getDtlsParameters=function(e,t){return{role:"auto",fingerprints:r.matchPrefix(e+t,"a=fingerprint:").map(r.parseFingerprint)}},r.writeDtlsParameters=function(e,t){var n="a=setup:"+t+"\r\n";return e.fingerprints.forEach(function(e){n+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"}),n},r.getIceParameters=function(e,t){var n=r.splitLines(e);return{usernameFragment:(n=n.concat(r.splitLines(t))).filter(function(e){return 0===e.indexOf("a=ice-ufrag:")})[0].substr(12),password:n.filter(function(e){return 0===e.indexOf("a=ice-pwd:")})[0].substr(10)}},r.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},r.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},n=r.splitLines(e)[0].split(" "),i=3;i0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=t.codecs.map(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType}).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach(function(e){n+=r.writeRtpMap(e),n+=r.writeFmtp(e),n+=r.writeRtcpFb(e)});var i=0;return t.codecs.forEach(function(e){e.maxptime>i&&(i=e.maxptime)}),i>0&&(n+="a=maxptime:"+i+"\r\n"),n+="a=rtcp-mux\r\n",t.headerExtensions.forEach(function(e){n+=r.writeExtmap(e)}),n},r.parseRtpEncodingParameters=function(e){var t,n=[],i=r.parseRtpParameters(e),s=-1!==i.fecMechanisms.indexOf("RED"),a=-1!==i.fecMechanisms.indexOf("ULPFEC"),o=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute}),l=o.length>0&&o[0].ssrc,u=r.matchPrefix(e,"a=ssrc-group:FID").map(function(e){var t=e.split(" ");return t.shift(),t.map(function(e){return parseInt(e,10)})});u.length>0&&u[0].length>1&&u[0][0]===l&&(t=u[0][1]),i.codecs.forEach(function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var r={ssrc:l,codecPayloadType:parseInt(e.parameters.apt,10),rtx:{ssrc:t}};n.push(r),s&&((r=JSON.parse(JSON.stringify(r))).fec={ssrc:t,mechanism:a?"red+ulpfec":"red"},n.push(r))}}),0===n.length&&l&&n.push({ssrc:l});var c=r.matchPrefix(e,"b=");return c.length&&(c=0===c[0].indexOf("b=TIAS:")?parseInt(c[0].substr(7),10):0===c[0].indexOf("b=AS:")?1e3*parseInt(c[0].substr(5),10)*.95-16e3:void 0,n.forEach(function(e){e.maxBitrate=c})),n},r.parseRtcpParameters=function(e){var t={},n=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute})[0];n&&(t.cname=n.value,t.ssrc=n.ssrc);var i=r.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=i.length>0,t.compound=0===i.length;var s=r.matchPrefix(e,"a=rtcp-mux");return t.mux=s.length>0,t},r.parseMsid=function(e){var t,n=r.matchPrefix(e,"a=msid:");if(1===n.length)return t=n[0].substr(7).split(" "),{stream:t[0],track:t[1]};var i=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"msid"===e.attribute});return i.length>0?(t=i[0].value.split(" "),{stream:t[0],track:t[1]}):void 0},r.generateSessionId=function(){return Math.random().toString().substr(2,21)},r.writeSessionBoilerplate=function(e,t){var n=void 0!==t?t:2;return"v=0\r\no=thisisadapterortc "+(e||r.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},r.writeMediaSection=function(e,t,n,i){var s=r.writeRtpDescription(e.kind,t);if(s+=r.writeIceParameters(e.iceGatherer.getLocalParameters()),s+=r.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===n?"actpass":"active"),s+="a=mid:"+e.mid+"\r\n",e.direction?s+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?s+="a=sendrecv\r\n":e.rtpSender?s+="a=sendonly\r\n":e.rtpReceiver?s+="a=recvonly\r\n":s+="a=inactive\r\n",e.rtpSender){var a="msid:"+i.id+" "+e.rtpSender.track.id+"\r\n";s+="a="+a,s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+a,e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+a,s+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+r.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+r.localCName+"\r\n"),s},r.getDirection=function(e,t){for(var n=r.splitLines(e),i=0;i=63)){var s=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=s.apply(this);return e._reverseStreams=e._reverseStreams||{},t.map(function(t){return e._reverseStreams[t.id]})};var a=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var n=this;if(n._streams=n._streams||{},n._reverseStreams=n._reverseStreams||{},t.getTracks().forEach(function(e){if(n.getSenders().find(function(t){return t.track===e}))throw new DOMException("Track already exists.","InvalidAccessError")}),!n._reverseStreams[t.id]){var r=new e.MediaStream(t.getTracks());n._streams[t.id]=r,n._reverseStreams[r.id]=t,t=r}a.apply(n,[t])};var o=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;t._streams=t._streams||{},t._reverseStreams=t._reverseStreams||{},o.apply(t,[t._streams[e.id]||e]),delete t._reverseStreams[t._streams[e.id]?t._streams[e.id].id:e.id],delete t._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,n){var r=this;if("closed"===r.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var i=[].slice.call(arguments,1);if(1!==i.length||!i[0].getTracks().find(function(e){return e===t}))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(r.getSenders().find(function(e){return e.track===t}))throw new DOMException("Track already exists.","InvalidAccessError");r._streams=r._streams||{},r._reverseStreams=r._reverseStreams||{};var s=r._streams[n.id];if(s)s.addTrack(t),Promise.resolve().then(function(){r.dispatchEvent(new Event("negotiationneeded"))});else{var a=new e.MediaStream([t]);r._streams[n.id]=a,r._reverseStreams[a.id]=n,r.addStream(a)}return r.getSenders().find(function(e){return e.track===t})},["createOffer","createAnswer"].forEach(function(n){var r=e.RTCPeerConnection.prototype[n];e.RTCPeerConnection.prototype[n]=function(){var e=this,n=arguments;return arguments.length&&"function"==typeof arguments[0]?r.apply(e,[function(r){var i=t(e,r);n[0].apply(null,[i])},function(e){n[1]&&n[1].apply(null,e)},arguments[2]]):r.apply(e,arguments).then(function(n){return t(e,n)})}});var l=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){var e=this;return arguments.length&&arguments[0].type?(arguments[0]=n(e,arguments[0]),l.apply(e,arguments)):l.apply(e,arguments)};var u=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=this,n=u.get.apply(this);return""===n.type?n:t(e,n)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;if("closed"===t.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(e._pc===t))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");t._streams=t._streams||{};var n;Object.keys(t._streams).forEach(function(r){t._streams[r].getTracks().find(function(t){return e.track===t})&&(n=t._streams[r])}),n&&(1===n.getTracks().length?t.removeStream(t._reverseStreams[n.id]):n.removeTrack(e.track),t.dispatchEvent(new Event("negotiationneeded")))}}},shimPeerConnection:function(e){var t=r.detectBrowser(e);if(e.RTCPeerConnection){var n=e.RTCPeerConnection;e.RTCPeerConnection=function(e,t){if(e&&e.iceServers){for(var i=[],s=0;s0&&"function"==typeof e)return s.apply(this,arguments);if(0===s.length&&(0===arguments.length||"function"!=typeof arguments[0]))return s.apply(this,[]);var a=function(e){var t={};return e.result().forEach(function(e){var n={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach(function(t){n[t]=e.stat(t)}),t[n.id]=n}),t},o=function(e){return new Map(Object.keys(e).map(function(t){return[t,e[t]]}))};if(arguments.length>=2){return s.apply(this,[function(e){i[1](o(a(e)))},arguments[0]])}return new Promise(function(e,t){s.apply(r,[function(t){e(o(a(t)))},t])}).then(t,n)},t.version<51&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){var e=arguments,t=this,r=new Promise(function(r,i){n.apply(t,[e[0],r,i])});return e.length<2?r:r.then(function(){e[1].apply(null,[])},function(t){e.length>=3&&e[2].apply(null,[t])})}}),t.version<52&&["createOffer","createAnswer"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){var e=this;if(arguments.length<1||1===arguments.length&&"object"==typeof arguments[0]){var t=1===arguments.length?arguments[0]:void 0;return new Promise(function(r,i){n.apply(e,[r,i,t])})}return n.apply(this,arguments)}}),["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}});var a=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?a.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}}};t.exports={shimMediaStream:s.shimMediaStream,shimOnTrack:s.shimOnTrack,shimAddTrackRemoveTrack:s.shimAddTrackRemoveTrack,shimGetSendersWithDtmf:s.shimGetSendersWithDtmf,shimSourceObject:s.shimSourceObject,shimPeerConnection:s.shimPeerConnection,shimGetUserMedia:e("./getusermedia")}},{"../utils.js":50,"./getusermedia":43}],43:[function(e,t,n){"use strict";var r=e("../utils.js"),i=r.log;t.exports=function(e){var t=r.detectBrowser(e),n=e&&e.navigator,s=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;var t={};return Object.keys(e).forEach(function(n){if("require"!==n&&"advanced"!==n&&"mediaSource"!==n){var r="object"==typeof e[n]?e[n]:{ideal:e[n]};void 0!==r.exact&&"number"==typeof r.exact&&(r.min=r.max=r.exact);var i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==r.ideal){t.optional=t.optional||[];var s={};"number"==typeof r.ideal?(s[i("min",n)]=r.ideal,t.optional.push(s),(s={})[i("max",n)]=r.ideal,t.optional.push(s)):(s[i("",n)]=r.ideal,t.optional.push(s))}void 0!==r.exact&&"number"!=typeof r.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",n)]=r.exact):["min","max"].forEach(function(e){void 0!==r[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,n)]=r[e])})}}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},a=function(e,r){if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){var a=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])};a((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),a(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=s(e.audio)}if(e&&"object"==typeof e.video){var o=e.video.facingMode;o=o&&("object"==typeof o?o:{ideal:o});var l=t.version<66;if(o&&("user"===o.exact||"environment"===o.exact||"user"===o.ideal||"environment"===o.ideal)&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||l)){delete e.video.facingMode;var u;if("environment"===o.exact||"environment"===o.ideal?u=["back","rear"]:"user"!==o.exact&&"user"!==o.ideal||(u=["front"]),u)return n.mediaDevices.enumerateDevices().then(function(t){var n=(t=t.filter(function(e){return"videoinput"===e.kind})).find(function(e){return u.some(function(t){return-1!==e.label.toLowerCase().indexOf(t)})});return!n&&t.length&&-1!==u.indexOf("back")&&(n=t[t.length-1]),n&&(e.video.deviceId=o.exact?{exact:n.deviceId}:{ideal:n.deviceId}),e.video=s(e.video),i("chrome: "+JSON.stringify(e)),r(e)})}e.video=s(e.video)}return i("chrome: "+JSON.stringify(e)),r(e)},o=function(e){return{name:{PermissionDeniedError:"NotAllowedError",InvalidStateError:"NotReadableError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotReadableError",MediaDeviceKillSwitchOn:"NotReadableError"}[e.name]||e.name,message:e.message,constraint:e.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}};n.getUserMedia=function(e,t,r){a(e,function(e){n.webkitGetUserMedia(e,t,function(e){r&&r(o(e))})})};var l=function(e){return new Promise(function(t,r){n.getUserMedia(e,t,r)})};if(n.mediaDevices||(n.mediaDevices={getUserMedia:l,enumerateDevices:function(){return new Promise(function(t){var n={audio:"audioinput",video:"videoinput"};return e.MediaStreamTrack.getSources(function(e){t(e.map(function(e){return{label:e.label,kind:n[e.kind],deviceId:e.id,groupId:""}}))})})},getSupportedConstraints:function(){return{deviceId:!0,echoCancellation:!0,facingMode:!0,frameRate:!0,height:!0,width:!0}}}),n.mediaDevices.getUserMedia){var u=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(e){return a(e,function(e){return u(e).then(function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach(function(e){e.stop()}),new DOMException("","NotFoundError");return t},function(e){return Promise.reject(o(e))})})}}else n.mediaDevices.getUserMedia=function(e){return l(e)};void 0===n.mediaDevices.addEventListener&&(n.mediaDevices.addEventListener=function(){i("Dummy mediaDevices.addEventListener called.")}),void 0===n.mediaDevices.removeEventListener&&(n.mediaDevices.removeEventListener=function(){i("Dummy mediaDevices.removeEventListener called.")})}},{"../utils.js":50}],44:[function(e,t,n){"use strict";function r(e,t,n){if(e.RTCPeerConnection){var r=e.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(e,r){if(e!==t)return i.apply(this,arguments);var s=function(e){r(n(e))};return this._eventMap=this._eventMap||{},this._eventMap[r]=s,i.apply(this,[e,s])};var s=r.removeEventListener;r.removeEventListener=function(e,n){if(e!==t||!this._eventMap||!this._eventMap[n])return s.apply(this,arguments);var r=this._eventMap[n];return delete this._eventMap[n],s.apply(this,[e,r])},Object.defineProperty(r,"on"+t,{get:function(){return this["_on"+t]},set:function(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)}})}}var i=e("sdp"),s=e("./utils");t.exports={shimRTCIceCandidate:function(e){if(!(e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){"object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2));var n=new t(e),r=i.parseCandidate(e.candidate),s=Object.assign(n,r);return s.toJSON=function(){return{candidate:s.candidate,sdpMid:s.sdpMid,sdpMLineIndex:s.sdpMLineIndex,usernameFragment:s.usernameFragment}},s},r(e,"icecandidate",function(t){return t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t})}},shimCreateObjectURL:function(e){var t=e&&e.URL;if("object"==typeof e&&e.HTMLMediaElement&&"srcObject"in e.HTMLMediaElement.prototype&&t.createObjectURL&&t.revokeObjectURL){var n=t.createObjectURL.bind(t),r=t.revokeObjectURL.bind(t),i=new Map,a=0;t.createObjectURL=function(e){if("getTracks"in e){var t="polyblob:"+ ++a;return i.set(t,e),s.deprecated("URL.createObjectURL(stream)","elem.srcObject = stream"),t}return n(e)},t.revokeObjectURL=function(e){r(e),i.delete(e)};var o=Object.getOwnPropertyDescriptor(e.HTMLMediaElement.prototype,"src");Object.defineProperty(e.HTMLMediaElement.prototype,"src",{get:function(){return o.get.apply(this)},set:function(e){return this.srcObject=i.get(e)||null,o.set.apply(this,[e])}});var l=e.HTMLMediaElement.prototype.setAttribute;e.HTMLMediaElement.prototype.setAttribute=function(){return 2===arguments.length&&"src"===(""+arguments[0]).toLowerCase()&&(this.srcObject=i.get(arguments[1])||null),l.apply(this,arguments)}}}}},{"./utils":50,sdp:39}],45:[function(e,t,n){"use strict";var r=e("../utils"),i=e("rtcpeerconnection-shim");t.exports={shimGetUserMedia:e("./getusermedia"),shimPeerConnection:function(e){var t=r.detectBrowser(e);if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(e){return e}),e.RTCSessionDescription||(e.RTCSessionDescription=function(e){return e}),t.version<15025)){var n=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set:function(e){n.set.call(this,e);var t=new Event("enabled");t.enabled=e,this.dispatchEvent(t)}})}!e.RTCRtpSender||"dtmf"in e.RTCRtpSender.prototype||Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=new e.RTCDtmfSender(this):"video"===this.track.kind&&(this._dtmf=null)),this._dtmf}}),e.RTCPeerConnection=i(e,t.version)},shimReplaceTrack:function(e){!e.RTCRtpSender||"replaceTrack"in e.RTCRtpSender.prototype||(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}}},{"../utils":50,"./getusermedia":46,"rtcpeerconnection-shim":34}],46:[function(e,t,n){"use strict";t.exports=function(e){var t=e&&e.navigator,n=function(e){return{name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString:function(){return this.name}}},r=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return r(e).catch(function(e){return Promise.reject(n(e))})}}},{}],47:[function(e,t,n){"use strict";var r=e("../utils"),i={shimOnTrack:function(e){"object"!=typeof e||!e.RTCPeerConnection||"ontrack"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&(this.removeEventListener("track",this._ontrack),this.removeEventListener("addstream",this._ontrackpoly)),this.addEventListener("track",this._ontrack=e),this.addEventListener("addstream",this._ontrackpoly=function(e){e.stream.getTracks().forEach(function(t){var n=new Event("track");n.track=t,n.receiver={track:t},n.transceiver={receiver:n.receiver},n.streams=[e.stream],this.dispatchEvent(n)}.bind(this))}.bind(this))}}),"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})},shimSourceObject:function(e){"object"==typeof e&&(!e.HTMLMediaElement||"srcObject"in e.HTMLMediaElement.prototype||Object.defineProperty(e.HTMLMediaElement.prototype,"srcObject",{get:function(){return this.mozSrcObject},set:function(e){this.mozSrcObject=e}}))},shimPeerConnection:function(e){var t=r.detectBrowser(e);if("object"==typeof e&&(e.RTCPeerConnection||e.mozRTCPeerConnection)){e.RTCPeerConnection||(e.RTCPeerConnection=function(n,r){if(t.version<38&&n&&n.iceServers){for(var i=[],s=0;s55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){var c=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])},d=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(e){return"object"==typeof e&&"object"==typeof e.audio&&(e=JSON.parse(JSON.stringify(e)),c(e.audio,"autoGainControl","mozAutoGainControl"),c(e.audio,"noiseSuppression","mozNoiseSuppression")),d(e)},s&&s.prototype.getSettings){var h=s.prototype.getSettings;s.prototype.getSettings=function(){var e=h.apply(this,arguments);return c(e,"mozAutoGainControl","autoGainControl"),c(e,"mozNoiseSuppression","noiseSuppression"),e}}if(s&&s.prototype.applyConstraints){var f=s.prototype.applyConstraints;s.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"==typeof e&&(e=JSON.parse(JSON.stringify(e)),c(e,"autoGainControl","mozAutoGainControl"),c(e,"noiseSuppression","mozNoiseSuppression")),f.apply(this,[e])}}}n.getUserMedia=function(e,i,s){if(t.version<44)return o(e,i,s);r.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(e).then(i,s)}}},{"../utils":50}],49:[function(e,t,n){"use strict";var r=e("../utils"),i={shimLocalStreamsAPI:function(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),"getStreamById"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getStreamById=function(e){var t=null;return this._localStreams&&this._localStreams.forEach(function(n){n.id===e&&(t=n)}),this._remoteStreams&&this._remoteStreams.forEach(function(n){n.id===e&&(t=n)}),t}),!("addStream"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),-1===this._localStreams.indexOf(e)&&this._localStreams.push(e);var n=this;e.getTracks().forEach(function(r){t.call(n,r,e)})},e.RTCPeerConnection.prototype.addTrack=function(e,n){n&&(this._localStreams?-1===this._localStreams.indexOf(n)&&this._localStreams.push(n):this._localStreams=[n]),t.call(this,e,n)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);var t=this._localStreams.indexOf(e);if(-1!==t){this._localStreams.splice(t,1);var n=this,r=e.getTracks();this.getSenders().forEach(function(e){-1!==r.indexOf(e.track)&&n.removeTrack(e)})}})}},shimRemoteStreamsAPI:function(e){"object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),"onaddstream"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=function(e){var t=e.streams[0];if(this._remoteStreams||(this._remoteStreams=[]),!(this._remoteStreams.indexOf(t)>=0)){this._remoteStreams.push(t);var n=new Event("addstream");n.stream=e.streams[0],this.dispatchEvent(n)}}.bind(this))}}))},shimCallbacksAPI:function(e){if("object"==typeof e&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype,n=t.createOffer,r=t.createAnswer,i=t.setLocalDescription,s=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){var r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){var n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i};var o=function(e,t,n){var r=i.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r};t.setLocalDescription=o,o=function(e,t,n){var r=s.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.setRemoteDescription=o,o=function(e,t,n){var r=a.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.addIceCandidate=o}},shimGetUserMedia:function(e){var t=e&&e.navigator;t.getUserMedia||(t.webkitGetUserMedia?t.getUserMedia=t.webkitGetUserMedia.bind(t):t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,n,r){t.mediaDevices.getUserMedia(e).then(n,r)}.bind(t)))},shimRTCIceServerUrls:function(e){var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,n){if(e&&e.iceServers){for(var i=[],s=0;s=n&&parseInt(r[n],10)},detectBrowser:function(e){var t=e&&e.navigator,n={};if(n.browser=null,n.version=null,void 0===e||!e.navigator)return n.browser="Not a browser.",n;if(t.mozGetUserMedia)n.browser="firefox",n.version=this.extractVersion(t.userAgent,/Firefox\/(\d+)\./,1);else if(t.webkitGetUserMedia)if(e.webkitRTCPeerConnection)n.browser="chrome",n.version=this.extractVersion(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!t.userAgent.match(/Version\/(\d+).(\d+)/))return n.browser="Unsupported webkit-based browser with GUM support but no WebRTC support.",n;n.browser="safari",n.version=this.extractVersion(t.userAgent,/AppleWebKit\/(\d+)\./,1)}else if(t.mediaDevices&&t.userAgent.match(/Edge\/(\d+).(\d+)$/))n.browser="edge",n.version=this.extractVersion(t.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!t.mediaDevices||!t.userAgent.match(/AppleWebKit\/(\d+)\./))return n.browser="Not a supported browser.",n;n.browser="safari",n.version=this.extractVersion(t.userAgent,/AppleWebKit\/(\d+)\./,1)}return n}};t.exports={log:s.log,deprecated:s.deprecated,disableLog:s.disableLog,disableWarnings:s.disableWarnings,extractVersion:s.extractVersion,shimCreateObjectURL:s.shimCreateObjectURL,detectBrowser:s.detectBrowser.bind(s)}},{}],51:[function(e,t,n){t.exports={name:"jssip",title:"JsSIP",description:"the Javascript SIP library",version:"3.0.23",homepage:"http://jssip.net",author:"José Luis Millán (https://github.com/jmillan)",contributors:["Iñaki Baz Castillo (https://github.com/ibc)","Saúl Ibarra Corretgé (https://github.com/saghul)"],main:"lib/JsSIP.js",keywords:["sip","websocket","webrtc","node","browser","library"],license:"MIT",repository:{type:"git",url:"https://github.com/versatica/JsSIP.git"},bugs:{url:"https://github.com/versatica/JsSIP/issues"},dependencies:{debug:"^3.0.1","sdp-transform":"^2.3.0","webrtc-adapter":"^5.0.0"},browserify:{transform:[["babelify",{presets:["es2015"]}]]},devDependencies:{"babel-preset-es2015":"^6.24.1",babelify:"7.3.0",browserify:"^14.3.0",gulp:"git+https://github.com/gulpjs/gulp.git#4.0","gulp-eslint":"^4.0.0","gulp-expect-file":"0.0.7","gulp-header":"1.8.9","gulp-nodeunit-runner":"^0.2.2","gulp-plumber":"^1.1.0","gulp-rename":"^1.2.2","gulp-uglify":"^3.0.0","gulp-util":"^3.0.8",eslint:"^4.4.1",pegjs:"0.7.0","vinyl-buffer":"^1.0.0","vinyl-source-stream":"^1.1.0"},scripts:{test:"gulp test"}}},{}]},{},[8])(8)}); \ No newline at end of file diff --git a/package.json b/package.json index 7da180660..5cedd3aac 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "jssip", "title": "JsSIP", "description": "the Javascript SIP library", - "version": "3.0.23", + "version": "3.0.24", "homepage": "http://jssip.net", "author": "José Luis Millán (https://github.com/jmillan)", "contributors": [