text: /*
   * JsSIP.js 0.6.3
   * the Javascript SIP library
   * Copyright 2012-2015 José Luis Millán <jmillan@aliax.net> (https://github.com/jmillan)
   * Homepage: http://jssip.net
   * License MIT
   */
  
  !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.JsSIP=e()}}(function(){var e;return function t(e,n,r){function s(i,o){if(!n[i]){if(!e[i]){var u="function"==typeof require&&require;if(!o&&u)return u(i,!0);if(l)return l(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var c=n[i]={exports:{}};e[i][0].call(c.exports,function(t){var n=e[i][1][t];return s(n?n:t)},c,c.exports,t,e,n,r)}return n[i].exports}for(var l="function"==typeof require&&require,i=0;i<r.length;i++)s(r[i]);return s}({1:[function(e,t){var n=e("../package.json"),r={USER_AGENT:n.title+" "+n.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",DIALOG_ERROR:"Dialog Error",BYE:"Terminated",WEBRTC_NOT_SUPPORTED:"WebRTC Not Supported",WEBRTC_ERROR:"WebRTC Error",CANCELED:"Canceled",NO_ANSWER:"No Answer",EXPIRES:"Expires",NO_ACK:"No ACK",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],INCOMPATIBLE_SDP:[488,606],AUTHENTICATION_ERROR:[401,407]},ACK:"ACK",BYE:"BYE",CANCEL:"CANCEL",INFO:"INFO",INVITE:"INVITE",MESSAGE:"MESSAGE",NOTIFY:"NOTIFY",OPTIONS:"OPTIONS",REGISTER:"REGISTER",UPDATE:"UPDATE",SUBSCRIBE:"SUBSCRIBE",REASON_PHRASE:{100:"Trying",180:"Ringing",181:"Call Is Being Forwarded",182:"Queued",183:"Session Progress",199:"Early Dialog Terminated",200:"OK",202:"Accepted",204:"No Notification",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",305:"Use Proxy",380:"Alternative Service",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",410:"Gone",412:"Conditional Request Failed",413:"Request Entity Too Large",414:"Request-URI Too Long",415:"Unsupported Media Type",416:"Unsupported URI Scheme",417:"Unknown Resource-Priority",420:"Bad Extension",421:"Extension Required",422:"Session Interval Too Small",423:"Interval Too Brief",428:"Use Identity Header",429:"Provide Referrer Identity",430:"Flow Failed",433:"Anonymity Disallowed",436:"Bad Identity-Info",437:"Unsupported Certificate",438:"Invalid Identity Header",439:"First Hop Lacks Outbound Support",440:"Max-Breadth Exceeded",469:"Bad Info Package",470:"Consent Needed",478:"Unresolvable Destination",480:"Temporarily Unavailable",481:"Call/Transaction Does Not Exist",482:"Loop Detected",483:"Too Many Hops",484:"Address Incomplete",485:"Ambiguous",486:"Busy Here",487:"Request Terminated",488:"Not Acceptable Here",489:"Bad Event",491:"Request Pending",493:"Undecipherable",494:"Security Agreement Required",500:"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",ACCEPTED_BODY_TYPES:"application/sdp, application/dtmf-relay",MAX_FORWARDS:69,SESSION_EXPIRES:90,MIN_SESSION_EXPIRES:60};t.exports=r},{"../package.json":46}],2:[function(e,t){function n(e,t,n,i){var o;return this.uac_pending_reply=!1,this.uas_pending_reply=!1,t.hasHeader("contact")?(i=t instanceof l.IncomingResponse?t.status_code<200?r.STATUS_EARLY:r.STATUS_CONFIRMED:i||r.STATUS_CONFIRMED,o=t.parseHeader("contact"),"UAS"===n?(this.id={call_id:t.call_id,local_tag:t.to_tag,remote_tag:t.from_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this.state=i,this.remote_seqnum=t.cseq,this.local_uri=t.parseHeader("to").uri,this.remote_uri=t.parseHeader("from").uri,this.remote_target=o.uri,this.route_set=t.getHeaders("record-route")):"UAC"===n&&(this.id={call_id:t.call_id,local_tag:t.from_tag,remote_tag:t.to_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this.state=i,this.local_seqnum=t.cseq,this.local_uri=t.parseHeader("from").uri,this.remote_uri=t.parseHeader("to").uri,this.remote_target=o.uri,this.route_set=t.getHeaders("record-route").reverse()),this.owner=e,e.ua.dialogs[this.id.toString()]=this,void s("new "+n+" dialog created with status "+(this.state===r.STATUS_EARLY?"EARLY":"CONFIRMED"))):{error:"unable to create a Dialog without Contact header field"}}t.exports=n;var r={STATUS_EARLY:1,STATUS_CONFIRMED:2};n.C=r;var s=e("debug")("JsSIP:Dialog"),l=e("./SIPMessage"),i=e("./Constants"),o=e("./Transactions"),u=e("./Dialog/RequestSender");n.prototype={update:function(e,t){this.state=r.STATUS_CONFIRMED,s("dialog "+this.id.toString()+"  changed to CONFIRMED state"),"UAC"===t&&(this.route_set=e.getHeaders("record-route").reverse())},terminate:function(){s("dialog "+this.id.toString()+" deleted"),delete this.owner.ua.dialogs[this.id.toString()]},createRequest:function(e,t,n){var r,s;return t=t&&t.slice()||[],this.local_seqnum||(this.local_seqnum=Math.floor(1e4*Math.random())),r=e===i.CANCEL||e===i.ACK?this.local_seqnum:this.local_seqnum+=1,s=new l.OutgoingRequest(e,this.remote_target,this.owner.ua,{cseq:r,call_id:this.id.call_id,from_uri:this.local_uri,from_tag:this.id.local_tag,to_uri:this.remote_uri,to_tag:this.id.remote_tag,route_set:this.route_set},t,n),s.dialog=this,s},checkInDialogRequest:function(e){var t=this;if(this.remote_seqnum){if(e.cseq<this.remote_seqnum)return e.method!==i.ACK&&e.reply(500),!1;e.cseq>this.remote_seqnum&&(this.remote_seqnum=e.cseq)}else this.remote_seqnum=e.cseq;if(e.method===i.INVITE||e.method===i.UPDATE&&e.body){if(this.uac_pending_reply===!0)e.reply(491);else{if(this.uas_pending_reply===!0){var n=(10*Math.random()|0)+1;return e.reply(500,null,["Retry-After:"+n]),!1}this.uas_pending_reply=!0,e.server_transaction.on("stateChanged",function r(){(this.state===o.C.STATUS_ACCEPTED||this.state===o.C.STATUS_COMPLETED||this.state===o.C.STATUS_TERMINATED)&&(e.server_transaction.removeListener("stateChanged",r),t.uas_pending_reply=!1,t.uac_pending_reply===!1&&t.owner.onReadyToReinvite())})}e.hasHeader("contact")&&e.server_transaction.on("stateChanged",function(){this.state===o.C.STATUS_ACCEPTED&&(t.remote_target=e.parseHeader("contact").uri)})}else e.method===i.NOTIFY&&e.hasHeader("contact")&&e.server_transaction.on("stateChanged",function(){this.state===o.C.STATUS_COMPLETED&&(t.remote_target=e.parseHeader("contact").uri)});return!0},sendRequest:function(e,t,n){n=n||{};var r=n.extraHeaders&&n.extraHeaders.slice()||[],s=n.body||null,l=this.createRequest(t,r,s),i=new u(this,e,l);i.send()},receiveRequest:function(e){this.checkInDialogRequest(e)&&this.owner.receiveRequest(e)}}},{"./Constants":1,"./Dialog/RequestSender":3,"./SIPMessage":16,"./Transactions":18,debug:29}],3:[function(e,t){function n(e,t,n){this.dialog=e,this.applicant=t,this.request=n,this.reattempt=!1,this.reattemptTimer=null}t.exports=n;var r=e("../Constants"),s=e("../Transactions"),l=e("../RTCSession"),i=e("../RequestSender");n.prototype={send:function(){var e=this,t=new i(this,this.dialog.owner.ua);t.send(),this.request.method===r.INVITE&&t.clientTransaction.state!==s.C.STATUS_TERMINATED&&(this.dialog.uac_pending_reply=!0,t.clientTransaction.on("stateChanged",function n(){(this.state===s.C.STATUS_ACCEPTED||this.state===s.C.STATUS_COMPLETED||this.state===s.C.STATUS_TERMINATED)&&(t.clientTransaction.removeListener("stateChanged",n),e.dialog.uac_pending_reply=!1,e.dialog.uas_pending_reply===!1&&e.dialog.owner.onReadyToReinvite())}))},onRequestTimeout:function(){this.applicant.onRequestTimeout()},onTransportError:function(){this.applicant.onTransportError()},receiveResponse:function(e){var t=this;408===e.status_code||481===e.status_code?this.applicant.onDialogError(e):e.method===r.INVITE&&491===e.status_code?this.reattempt?this.applicant.receiveResponse(e):(this.request.cseq.value=this.dialog.local_seqnum+=1,this.reattemptTimer=setTimeout(function(){t.applicant.owner.status!==l.C.STATUS_TERMINATED&&(t.reattempt=!0,t.request_sender.send())},1e3)):this.applicant.receiveResponse(e)}}},{"../Constants":1,"../RTCSession":11,"../RequestSender":15,"../Transactions":18}],4:[function(e,t){function n(e){this.username=e.configuration.authorization_user,this.password=e.configuration.password,this.cnonce=null,this.nc=0,this.ncHex="00000000",this.response=null}t.exports=n;var r=e("debug")("JsSIP:DigestAuthentication"),s=e("./Utils");n.prototype.authenticate=function(e,t){if(this.algorithm=t.algorithm,this.realm=t.realm,this.nonce=t.nonce,this.opaque=t.opaque,this.stale=t.stale,this.algorithm){if("MD5"!==this.algorithm)return r('challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this.algorithm="MD5";if(!this.realm)return r("challenge without Digest realm, authentication aborted"),!1;if(!this.nonce)return r("challenge without Digest nonce, authentication aborted"),!1;if(t.qop)if(t.qop.indexOf("auth")>-1)this.qop="auth";else{if(!(t.qop.indexOf("auth-int")>-1))return r('challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;this.qop="auth-int"}else this.qop=null;return this.method=e.method,this.uri=e.ruri,this.cnonce=s.createRandomToken(12),this.nc+=1,this.updateNcHex(),4294967296===this.nc&&(this.nc=1,this.ncHex="00000001"),this.calculateResponse(),!0},n.prototype.calculateResponse=function(){var e,t;e=s.calculateMD5(this.username+":"+this.realm+":"+this.password),"auth"===this.qop?(t=s.calculateMD5(this.method+":"+this.uri),this.response=s.calculateMD5(e+":"+this.nonce+":"+this.ncHex+":"+this.cnonce+":auth:"+t)):"auth-int"===this.qop?(t=s.calculateMD5(this.method+":"+this.uri+":"+s.calculateMD5(this.body?this.body:"")),this.response=s.calculateMD5(e+":"+this.nonce+":"+this.ncHex+":"+this.cnonce+":auth-int:"+t)):null===this.qop&&(t=s.calculateMD5(this.method+":"+this.uri),this.response=s.calculateMD5(e+":"+this.nonce+":"+t))},n.prototype.toString=function(){var e=[];if(!this.response)throw new Error("response field does not exist, cannot generate Authorization header");return e.push("algorithm="+this.algorithm),e.push('username="'+this.username+'"'),e.push('realm="'+this.realm+'"'),e.push('nonce="'+this.nonce+'"'),e.push('uri="'+this.uri+'"'),e.push('response="'+this.response+'"'),this.opaque&&e.push('opaque="'+this.opaque+'"'),this.qop&&(e.push("qop="+this.qop),e.push('cnonce="'+this.cnonce+'"'),e.push("nc="+this.ncHex)),"Digest "+e.join(", ")},n.prototype.updateNcHex=function(){var e=Number(this.nc).toString(16);this.ncHex="00000000".substr(0,8-e.length)+e}},{"./Utils":22,debug:29}],5:[function(e,t){var n={ConfigurationError:function(){var e=function(e,t){this.code=1,this.name="CONFIGURATION_ERROR",this.parameter=e,this.value=t,this.message=this.value?"Invalid value "+JSON.stringify(this.value)+' for parameter "'+this.parameter+'"':"Missing parameter: "+this.parameter};return e.prototype=new Error,e}(),InvalidStateError:function(){var e=function(e){this.code=2,this.name="INVALID_STATE_ERROR",this.status=e,this.message="Invalid status: "+e};return e.prototype=new Error,e}(),NotSupportedError:function(){var e=function(e){this.code=3,this.name="NOT_SUPPORTED_ERROR",this.message=e};return e.prototype=new Error,e}(),NotReadyError:function(){var e=function(e){this.code=4,this.name="NOT_READY_ERROR",this.message=e};return e.prototype=new Error,e}()};t.exports=n},{}],6:[function(e,t){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 s(e){os>ls||(ls>os&&(os=ls,us=[]),us.push(e))}function l(){var e;return"\r\n"===n.substr(ls,2)?(e="\r\n",ls+=2):(e=null,0===is&&s('"\\r\\n"')),e}function i(){var e;return/^[0-9]/.test(n.charAt(ls))?(e=n.charAt(ls),ls++):(e=null,0===is&&s("[0-9]")),e}function o(){var e;return/^[a-zA-Z]/.test(n.charAt(ls))?(e=n.charAt(ls),ls++):(e=null,0===is&&s("[a-zA-Z]")),e}function u(){var e;return/^[0-9a-fA-F]/.test(n.charAt(ls))?(e=n.charAt(ls),ls++):(e=null,0===is&&s("[0-9a-fA-F]")),e}function a(){var e;return e=d(),null===e&&(e=p()),e}function c(){var e;return/^[\0-\xFF]/.test(n.charAt(ls))?(e=n.charAt(ls),ls++):(e=null,0===is&&s("[\\0-\\xFF]")),e}function h(){var e;return/^["]/.test(n.charAt(ls))?(e=n.charAt(ls),ls++):(e=null,0===is&&s('["]')),e}function d(){var e;return 32===n.charCodeAt(ls)?(e=" ",ls++):(e=null,0===is&&s('" "')),e}function p(){var e;return 9===n.charCodeAt(ls)?(e="	",ls++):(e=null,0===is&&s('"\\t"')),e}function f(){var e;return/^[a-zA-Z0-9]/.test(n.charAt(ls))?(e=n.charAt(ls),ls++):(e=null,0===is&&s("[a-zA-Z0-9]")),e}function m(){var e;return 59===n.charCodeAt(ls)?(e=";",ls++):(e=null,0===is&&s('";"')),null===e&&(47===n.charCodeAt(ls)?(e="/",ls++):(e=null,0===is&&s('"/"')),null===e&&(63===n.charCodeAt(ls)?(e="?",ls++):(e=null,0===is&&s('"?"')),null===e&&(58===n.charCodeAt(ls)?(e=":",ls++):(e=null,0===is&&s('":"')),null===e&&(64===n.charCodeAt(ls)?(e="@",ls++):(e=null,0===is&&s('"@"')),null===e&&(38===n.charCodeAt(ls)?(e="&",ls++):(e=null,0===is&&s('"&"')),null===e&&(61===n.charCodeAt(ls)?(e="=",ls++):(e=null,0===is&&s('"="')),null===e&&(43===n.charCodeAt(ls)?(e="+",ls++):(e=null,0===is&&s('"+"')),null===e&&(36===n.charCodeAt(ls)?(e="$",ls++):(e=null,0===is&&s('"$"')),null===e&&(44===n.charCodeAt(ls)?(e=",",ls++):(e=null,0===is&&s('","'))))))))))),e}function g(){var e;return e=f(),null===e&&(e=T()),e}function T(){var e;return 45===n.charCodeAt(ls)?(e="-",ls++):(e=null,0===is&&s('"-"')),null===e&&(95===n.charCodeAt(ls)?(e="_",ls++):(e=null,0===is&&s('"_"')),null===e&&(46===n.charCodeAt(ls)?(e=".",ls++):(e=null,0===is&&s('"."')),null===e&&(33===n.charCodeAt(ls)?(e="!",ls++):(e=null,0===is&&s('"!"')),null===e&&(126===n.charCodeAt(ls)?(e="~",ls++):(e=null,0===is&&s('"~"')),null===e&&(42===n.charCodeAt(ls)?(e="*",ls++):(e=null,0===is&&s('"*"')),null===e&&(39===n.charCodeAt(ls)?(e="'",ls++):(e=null,0===is&&s('"\'"')),null===e&&(40===n.charCodeAt(ls)?(e="(",ls++):(e=null,0===is&&s('"("')),null===e&&(41===n.charCodeAt(ls)?(e=")",ls++):(e=null,0===is&&s('")"')))))))))),e}function _(){var e,t,r,l,i;return l=ls,i=ls,37===n.charCodeAt(ls)?(e="%",ls++):(e=null,0===is&&s('"%"')),null!==e?(t=u(),null!==t?(r=u(),null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(e,t){return t.join("")}(l,e)),null===e&&(ls=l),e}function v(){var e,t,n,r,s,i;for(r=ls,s=ls,i=ls,e=[],t=a();null!==t;)e.push(t),t=a();if(null!==e?(t=l(),null!==t?e=[e,t]:(e=null,ls=i)):(e=null,ls=i),e=null!==e?e:"",null!==e){if(n=a(),null!==n)for(t=[];null!==n;)t.push(n),n=a();else t=null;null!==t?e=[e,t]:(e=null,ls=s)}else e=null,ls=s;return null!==e&&(e=function(){return" "}(r)),null===e&&(ls=r),e}function C(){var e;return e=v(),e=null!==e?e:""}function S(){var e,t,r,l,i;for(l=ls,i=ls,e=[],t=d(),null===t&&(t=p());null!==t;)e.push(t),t=d(),null===t&&(t=p());return null!==e?(58===n.charCodeAt(ls)?(t=":",ls++):(t=null,0===is&&s('":"')),null!==t?(r=C(),null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(){return":"}(l)),null===e&&(ls=l),e}function E(){var e,t,r,s,l,i,o;if(l=ls,i=ls,t=A(),null!==t)for(e=[];null!==t;)e.push(t),t=A();else e=null;if(null!==e){for(t=[],o=ls,r=[],s=v();null!==s;)r.push(s),s=v();for(null!==r?(s=A(),null!==s?r=[r,s]:(r=null,ls=o)):(r=null,ls=o);null!==r;){for(t.push(r),o=ls,r=[],s=v();null!==s;)r.push(s),s=v();null!==r?(s=A(),null!==s?r=[r,s]:(r=null,ls=o)):(r=null,ls=o)}null!==t?e=[e,t]:(e=null,ls=i)}else e=null,ls=i;return null!==e&&(e=function(e){return n.substring(ls,e)}(l)),null===e&&(ls=l),e}function A(){var e;return/^[!-~]/.test(n.charAt(ls))?(e=n.charAt(ls),ls++):(e=null,0===is&&s("[!-~]")),null===e&&(e=R()),e}function R(){var e;return/^[\x80-\uFFFF]/.test(n.charAt(ls))?(e=n.charAt(ls),ls++):(e=null,0===is&&s("[\\x80-\\uFFFF]")),e}function y(){var e;return/^[\x80-\xBF]/.test(n.charAt(ls))?(e=n.charAt(ls),ls++):(e=null,0===is&&s("[\\x80-\\xBF]")),e}function b(){var e;return e=i(),null===e&&(/^[a-f]/.test(n.charAt(ls))?(e=n.charAt(ls),ls++):(e=null,0===is&&s("[a-f]"))),e}function I(){var e,t,r;if(r=ls,t=f(),null===t&&(45===n.charCodeAt(ls)?(t="-",ls++):(t=null,0===is&&s('"-"')),null===t&&(46===n.charCodeAt(ls)?(t=".",ls++):(t=null,0===is&&s('"."')),null===t&&(33===n.charCodeAt(ls)?(t="!",ls++):(t=null,0===is&&s('"!"')),null===t&&(37===n.charCodeAt(ls)?(t="%",ls++):(t=null,0===is&&s('"%"')),null===t&&(42===n.charCodeAt(ls)?(t="*",ls++):(t=null,0===is&&s('"*"')),null===t&&(95===n.charCodeAt(ls)?(t="_",ls++):(t=null,0===is&&s('"_"')),null===t&&(43===n.charCodeAt(ls)?(t="+",ls++):(t=null,0===is&&s('"+"')),null===t&&(96===n.charCodeAt(ls)?(t="`",ls++):(t=null,0===is&&s('"`"')),null===t&&(39===n.charCodeAt(ls)?(t="'",ls++):(t=null,0===is&&s('"\'"')),null===t&&(126===n.charCodeAt(ls)?(t="~",ls++):(t=null,0===is&&s('"~"')))))))))))),null!==t)for(e=[];null!==t;)e.push(t),t=f(),null===t&&(45===n.charCodeAt(ls)?(t="-",ls++):(t=null,0===is&&s('"-"')),null===t&&(46===n.charCodeAt(ls)?(t=".",ls++):(t=null,0===is&&s('"."')),null===t&&(33===n.charCodeAt(ls)?(t="!",ls++):(t=null,0===is&&s('"!"')),null===t&&(37===n.charCodeAt(ls)?(t="%",ls++):(t=null,0===is&&s('"%"')),null===t&&(42===n.charCodeAt(ls)?(t="*",ls++):(t=null,0===is&&s('"*"')),null===t&&(95===n.charCodeAt(ls)?(t="_",ls++):(t=null,0===is&&s('"_"')),null===t&&(43===n.charCodeAt(ls)?(t="+",ls++):(t=null,0===is&&s('"+"')),null===t&&(96===n.charCodeAt(ls)?(t="`",ls++):(t=null,0===is&&s('"`"')),null===t&&(39===n.charCodeAt(ls)?(t="'",ls++):(t=null,0===is&&s('"\'"')),null===t&&(126===n.charCodeAt(ls)?(t="~",ls++):(t=null,0===is&&s('"~"'))))))))))));else e=null;return null!==e&&(e=function(e){return n.substring(ls,e)}(r)),null===e&&(ls=r),e}function w(){var e,t,r;if(r=ls,t=f(),null===t&&(45===n.charCodeAt(ls)?(t="-",ls++):(t=null,0===is&&s('"-"')),null===t&&(33===n.charCodeAt(ls)?(t="!",ls++):(t=null,0===is&&s('"!"')),null===t&&(37===n.charCodeAt(ls)?(t="%",ls++):(t=null,0===is&&s('"%"')),null===t&&(42===n.charCodeAt(ls)?(t="*",ls++):(t=null,0===is&&s('"*"')),null===t&&(95===n.charCodeAt(ls)?(t="_",ls++):(t=null,0===is&&s('"_"')),null===t&&(43===n.charCodeAt(ls)?(t="+",ls++):(t=null,0===is&&s('"+"')),null===t&&(96===n.charCodeAt(ls)?(t="`",ls++):(t=null,0===is&&s('"`"')),null===t&&(39===n.charCodeAt(ls)?(t="'",ls++):(t=null,0===is&&s('"\'"')),null===t&&(126===n.charCodeAt(ls)?(t="~",ls++):(t=null,0===is&&s('"~"'))))))))))),null!==t)for(e=[];null!==t;)e.push(t),t=f(),null===t&&(45===n.charCodeAt(ls)?(t="-",ls++):(t=null,0===is&&s('"-"')),null===t&&(33===n.charCodeAt(ls)?(t="!",ls++):(t=null,0===is&&s('"!"')),null===t&&(37===n.charCodeAt(ls)?(t="%",ls++):(t=null,0===is&&s('"%"')),null===t&&(42===n.charCodeAt(ls)?(t="*",ls++):(t=null,0===is&&s('"*"')),null===t&&(95===n.charCodeAt(ls)?(t="_",ls++):(t=null,0===is&&s('"_"')),null===t&&(43===n.charCodeAt(ls)?(t="+",ls++):(t=null,0===is&&s('"+"')),null===t&&(96===n.charCodeAt(ls)?(t="`",ls++):(t=null,0===is&&s('"`"')),null===t&&(39===n.charCodeAt(ls)?(t="'",ls++):(t=null,0===is&&s('"\'"')),null===t&&(126===n.charCodeAt(ls)?(t="~",ls++):(t=null,0===is&&s('"~"')))))))))));else e=null;return null!==e&&(e=function(e){return n.substring(ls,e)}(r)),null===e&&(ls=r),e}function N(){var e;return 40===n.charCodeAt(ls)?(e="(",ls++):(e=null,0===is&&s('"("')),null===e&&(41===n.charCodeAt(ls)?(e=")",ls++):(e=null,0===is&&s('")"')),null===e&&(60===n.charCodeAt(ls)?(e="<",ls++):(e=null,0===is&&s('"<"')),null===e&&(62===n.charCodeAt(ls)?(e=">",ls++):(e=null,0===is&&s('">"')),null===e&&(64===n.charCodeAt(ls)?(e="@",ls++):(e=null,0===is&&s('"@"')),null===e&&(44===n.charCodeAt(ls)?(e=",",ls++):(e=null,0===is&&s('","')),null===e&&(59===n.charCodeAt(ls)?(e=";",ls++):(e=null,0===is&&s('";"')),null===e&&(58===n.charCodeAt(ls)?(e=":",ls++):(e=null,0===is&&s('":"')),null===e&&(92===n.charCodeAt(ls)?(e="\\",ls++):(e=null,0===is&&s('"\\\\"')),null===e&&(e=h(),null===e&&(47===n.charCodeAt(ls)?(e="/",ls++):(e=null,0===is&&s('"/"')),null===e&&(91===n.charCodeAt(ls)?(e="[",ls++):(e=null,0===is&&s('"["')),null===e&&(93===n.charCodeAt(ls)?(e="]",ls++):(e=null,0===is&&s('"]"')),null===e&&(63===n.charCodeAt(ls)?(e="?",ls++):(e=null,0===is&&s('"?"')),null===e&&(61===n.charCodeAt(ls)?(e="=",ls++):(e=null,0===is&&s('"="')),null===e&&(123===n.charCodeAt(ls)?(e="{",ls++):(e=null,0===is&&s('"{"')),null===e&&(125===n.charCodeAt(ls)?(e="}",ls++):(e=null,0===is&&s('"}"')),null===e&&(e=d(),null===e&&(e=p())))))))))))))))))),e}function D(){var e,t,r;if(r=ls,t=f(),null===t&&(45===n.charCodeAt(ls)?(t="-",ls++):(t=null,0===is&&s('"-"')),null===t&&(46===n.charCodeAt(ls)?(t=".",ls++):(t=null,0===is&&s('"."')),null===t&&(33===n.charCodeAt(ls)?(t="!",ls++):(t=null,0===is&&s('"!"')),null===t&&(37===n.charCodeAt(ls)?(t="%",ls++):(t=null,0===is&&s('"%"')),null===t&&(42===n.charCodeAt(ls)?(t="*",ls++):(t=null,0===is&&s('"*"')),null===t&&(95===n.charCodeAt(ls)?(t="_",ls++):(t=null,0===is&&s('"_"')),null===t&&(43===n.charCodeAt(ls)?(t="+",ls++):(t=null,0===is&&s('"+"')),null===t&&(96===n.charCodeAt(ls)?(t="`",ls++):(t=null,0===is&&s('"`"')),null===t&&(39===n.charCodeAt(ls)?(t="'",ls++):(t=null,0===is&&s('"\'"')),null===t&&(126===n.charCodeAt(ls)?(t="~",ls++):(t=null,0===is&&s('"~"')),null===t&&(40===n.charCodeAt(ls)?(t="(",ls++):(t=null,0===is&&s('"("')),null===t&&(41===n.charCodeAt(ls)?(t=")",ls++):(t=null,0===is&&s('")"')),null===t&&(60===n.charCodeAt(ls)?(t="<",ls++):(t=null,0===is&&s('"<"')),null===t&&(62===n.charCodeAt(ls)?(t=">",ls++):(t=null,0===is&&s('">"')),null===t&&(58===n.charCodeAt(ls)?(t=":",ls++):(t=null,0===is&&s('":"')),null===t&&(92===n.charCodeAt(ls)?(t="\\",ls++):(t=null,0===is&&s('"\\\\"')),null===t&&(t=h(),null===t&&(47===n.charCodeAt(ls)?(t="/",ls++):(t=null,0===is&&s('"/"')),null===t&&(91===n.charCodeAt(ls)?(t="[",ls++):(t=null,0===is&&s('"["')),null===t&&(93===n.charCodeAt(ls)?(t="]",ls++):(t=null,0===is&&s('"]"')),null===t&&(63===n.charCodeAt(ls)?(t="?",ls++):(t=null,0===is&&s('"?"')),null===t&&(123===n.charCodeAt(ls)?(t="{",ls++):(t=null,0===is&&s('"{"')),null===t&&(125===n.charCodeAt(ls)?(t="}",ls++):(t=null,0===is&&s('"}"'))))))))))))))))))))))))),null!==t)for(e=[];null!==t;)e.push(t),t=f(),null===t&&(45===n.charCodeAt(ls)?(t="-",ls++):(t=null,0===is&&s('"-"')),null===t&&(46===n.charCodeAt(ls)?(t=".",ls++):(t=null,0===is&&s('"."')),null===t&&(33===n.charCodeAt(ls)?(t="!",ls++):(t=null,0===is&&s('"!"')),null===t&&(37===n.charCodeAt(ls)?(t="%",ls++):(t=null,0===is&&s('"%"')),null===t&&(42===n.charCodeAt(ls)?(t="*",ls++):(t=null,0===is&&s('"*"')),null===t&&(95===n.charCodeAt(ls)?(t="_",ls++):(t=null,0===is&&s('"_"')),null===t&&(43===n.charCodeAt(ls)?(t="+",ls++):(t=null,0===is&&s('"+"')),null===t&&(96===n.charCodeAt(ls)?(t="`",ls++):(t=null,0===is&&s('"`"')),null===t&&(39===n.charCodeAt(ls)?(t="'",ls++):(t=null,0===is&&s('"\'"')),null===t&&(126===n.charCodeAt(ls)?(t="~",ls++):(t=null,0===is&&s('"~"')),null===t&&(40===n.charCodeAt(ls)?(t="(",ls++):(t=null,0===is&&s('"("')),null===t&&(41===n.charCodeAt(ls)?(t=")",ls++):(t=null,0===is&&s('")"')),null===t&&(60===n.charCodeAt(ls)?(t="<",ls++):(t=null,0===is&&s('"<"')),null===t&&(62===n.charCodeAt(ls)?(t=">",ls++):(t=null,0===is&&s('">"')),null===t&&(58===n.charCodeAt(ls)?(t=":",ls++):(t=null,0===is&&s('":"')),null===t&&(92===n.charCodeAt(ls)?(t="\\",ls++):(t=null,0===is&&s('"\\\\"')),null===t&&(t=h(),null===t&&(47===n.charCodeAt(ls)?(t="/",ls++):(t=null,0===is&&s('"/"')),null===t&&(91===n.charCodeAt(ls)?(t="[",ls++):(t=null,0===is&&s('"["')),null===t&&(93===n.charCodeAt(ls)?(t="]",ls++):(t=null,0===is&&s('"]"')),null===t&&(63===n.charCodeAt(ls)?(t="?",ls++):(t=null,0===is&&s('"?"')),null===t&&(123===n.charCodeAt(ls)?(t="{",ls++):(t=null,0===is&&s('"{"')),null===t&&(125===n.charCodeAt(ls)?(t="}",ls++):(t=null,0===is&&s('"}"')))))))))))))))))))))))));else e=null;return null!==e&&(e=function(e){return n.substring(ls,e)}(r)),null===e&&(ls=r),e}function U(){var e,t,r,l,i;return l=ls,i=ls,e=C(),null!==e?(42===n.charCodeAt(ls)?(t="*",ls++):(t=null,0===is&&s('"*"')),null!==t?(r=C(),null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(){return"*"}(l)),null===e&&(ls=l),e}function O(){var e,t,r,l,i;return l=ls,i=ls,e=C(),null!==e?(47===n.charCodeAt(ls)?(t="/",ls++):(t=null,0===is&&s('"/"')),null!==t?(r=C(),null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(){return"/"}(l)),null===e&&(ls=l),e}function x(){var e,t,r,l,i;return l=ls,i=ls,e=C(),null!==e?(61===n.charCodeAt(ls)?(t="=",ls++):(t=null,0===is&&s('"="')),null!==t?(r=C(),null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(){return"="}(l)),null===e&&(ls=l),e}function P(){var e,t,r,l,i;return l=ls,i=ls,e=C(),null!==e?(40===n.charCodeAt(ls)?(t="(",ls++):(t=null,0===is&&s('"("')),null!==t?(r=C(),null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(){return"("}(l)),null===e&&(ls=l),e}function M(){var e,t,r,l,i;return l=ls,i=ls,e=C(),null!==e?(41===n.charCodeAt(ls)?(t=")",ls++):(t=null,0===is&&s('")"')),null!==t?(r=C(),null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(){return")"}(l)),null===e&&(ls=l),e}function L(){var e,t,r,l;return r=ls,l=ls,62===n.charCodeAt(ls)?(e=">",ls++):(e=null,0===is&&s('">"')),null!==e?(t=C(),null!==t?e=[e,t]:(e=null,ls=l)):(e=null,ls=l),null!==e&&(e=function(){return">"}(r)),null===e&&(ls=r),e}function q(){var e,t,r,l;return r=ls,l=ls,e=C(),null!==e?(60===n.charCodeAt(ls)?(t="<",ls++):(t=null,0===is&&s('"<"')),null!==t?e=[e,t]:(e=null,ls=l)):(e=null,ls=l),null!==e&&(e=function(){return"<"}(r)),null===e&&(ls=r),e}function k(){var e,t,r,l,i;return l=ls,i=ls,e=C(),null!==e?(44===n.charCodeAt(ls)?(t=",",ls++):(t=null,0===is&&s('","')),null!==t?(r=C(),null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(){return","}(l)),null===e&&(ls=l),e}function H(){var e,t,r,l,i;return l=ls,i=ls,e=C(),null!==e?(59===n.charCodeAt(ls)?(t=";",ls++):(t=null,0===is&&s('";"')),null!==t?(r=C(),null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(){return";"}(l)),null===e&&(ls=l),e}function F(){var e,t,r,l,i;return l=ls,i=ls,e=C(),null!==e?(58===n.charCodeAt(ls)?(t=":",ls++):(t=null,0===is&&s('":"')),null!==t?(r=C(),null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(){return":"}(l)),null===e&&(ls=l),e}function G(){var e,t,n,r;return n=ls,r=ls,e=C(),null!==e?(t=h(),null!==t?e=[e,t]:(e=null,ls=r)):(e=null,ls=r),null!==e&&(e=function(){return'"'}(n)),null===e&&(ls=n),e}function j(){var e,t,n,r;return n=ls,r=ls,e=h(),null!==e?(t=C(),null!==t?e=[e,t]:(e=null,ls=r)):(e=null,ls=r),null!==e&&(e=function(){return'"'}(n)),null===e&&(ls=n),e}function W(){var e,t,n,r;if(r=ls,e=P(),null!==e){for(t=[],n=B(),null===n&&(n=K(),null===n&&(n=W()));null!==n;)t.push(n),n=B(),null===n&&(n=K(),null===n&&(n=W()));null!==t?(n=M(),null!==n?e=[e,t,n]:(e=null,ls=r)):(e=null,ls=r)}else e=null,ls=r;return e}function B(){var e;return/^[!-']/.test(n.charAt(ls))?(e=n.charAt(ls),ls++):(e=null,0===is&&s("[!-']")),null===e&&(/^[*-[]/.test(n.charAt(ls))?(e=n.charAt(ls),ls++):(e=null,0===is&&s("[*-[]")),null===e&&(/^[\]-~]/.test(n.charAt(ls))?(e=n.charAt(ls),ls++):(e=null,0===is&&s("[\\]-~]")),null===e&&(e=R(),null===e&&(e=v())))),e}function z(){var e,t,r,s,l,i;if(l=ls,i=ls,e=C(),null!==e)if(t=h(),null!==t){for(r=[],s=Y(),null===s&&(s=K());null!==s;)r.push(s),s=Y(),null===s&&(s=K());null!==r?(s=h(),null!==s?e=[e,t,r,s]:(e=null,ls=i)):(e=null,ls=i)}else e=null,ls=i;else e=null,ls=i;return null!==e&&(e=function(e){return n.substring(ls,e)}(l)),null===e&&(ls=l),e}function V(){var e,t,r,s,l,i;if(l=ls,i=ls,e=C(),null!==e)if(t=h(),null!==t){for(r=[],s=Y(),null===s&&(s=K());null!==s;)r.push(s),s=Y(),null===s&&(s=K());null!==r?(s=h(),null!==s?e=[e,t,r,s]:(e=null,ls=i)):(e=null,ls=i)}else e=null,ls=i;else e=null,ls=i;return null!==e&&(e=function(e){return n.substring(ls-1,e+1)}(l)),null===e&&(ls=l),e}function Y(){var e;return e=v(),null===e&&(33===n.charCodeAt(ls)?(e="!",ls++):(e=null,0===is&&s('"!"')),null===e&&(/^[#-[]/.test(n.charAt(ls))?(e=n.charAt(ls),ls++):(e=null,0===is&&s("[#-[]")),null===e&&(/^[\]-~]/.test(n.charAt(ls))?(e=n.charAt(ls),ls++):(e=null,0===is&&s("[\\]-~]")),null===e&&(e=R())))),e}function K(){var e,t,r;return r=ls,92===n.charCodeAt(ls)?(e="\\",ls++):(e=null,0===is&&s('"\\\\"')),null!==e?(/^[\0-\t]/.test(n.charAt(ls))?(t=n.charAt(ls),ls++):(t=null,0===is&&s("[\\0-\\t]")),null===t&&(/^[\x0B-\f]/.test(n.charAt(ls))?(t=n.charAt(ls),ls++):(t=null,0===is&&s("[\\x0B-\\f]")),null===t&&(/^[\x0E-]/.test(n.charAt(ls))?(t=n.charAt(ls),ls++):(t=null,0===is&&s("[\\x0E-]")))),null!==t?e=[e,t]:(e=null,ls=r)):(e=null,ls=r),e}function J(){var e,t,r,l,i,o;return i=ls,o=ls,e=$(),null!==e?(58===n.charCodeAt(ls)?(t=":",ls++):(t=null,0===is&&s('":"')),null!==t?(r=Z(),r=null!==r?r:"",null!==r?(l=nt(),null!==l?e=[e,t,r,l]:(e=null,ls=o)):(e=null,ls=o)):(e=null,ls=o)):(e=null,ls=o),null!==e&&(e=function(){try{hs.uri=new as(hs.scheme,hs.user,hs.host,hs.port),delete hs.scheme,delete hs.user,delete hs.host,delete hs.host_type,delete hs.port}catch(e){hs=-1}}(i)),null===e&&(ls=i),e}function X(){var e,t,l,i,o,u,a,c;return a=ls,c=ls,e=$(),null!==e?(58===n.charCodeAt(ls)?(t=":",ls++):(t=null,0===is&&s('":"')),null!==t?(l=Z(),l=null!==l?l:"",null!==l?(i=nt(),null!==i?(o=ft(),null!==o?(u=It(),u=null!==u?u:"",null!==u?e=[e,t,l,i,o,u]:(e=null,ls=c)):(e=null,ls=c)):(e=null,ls=c)):(e=null,ls=c)):(e=null,ls=c)):(e=null,ls=c),null!==e&&(e=function(){try{hs.uri=new as(hs.scheme,hs.user,hs.host,hs.port,hs.uri_params,hs.uri_headers),delete hs.scheme,delete hs.user,delete hs.host,delete hs.host_type,delete hs.port,delete hs.uri_params,"SIP_URI"===r&&(hs=hs.uri)}catch(e){hs=-1}}(a)),null===e&&(ls=a),e}function $(){var e,t;return"sip"===n.substr(ls,3).toLowerCase()?(e=n.substr(ls,3),ls+=3):(e=null,0===is&&s('"sip"')),null===e&&(t=ls,"sips"===n.substr(ls,4).toLowerCase()?(e=n.substr(ls,4),ls+=4):(e=null,0===is&&s('"sips"')),null!==e&&(e=function(){hs.scheme=uri_scheme.toLowerCase()}(t)),null===e&&(ls=t)),e}function Z(){var e,t,r,l,i,o;return l=ls,i=ls,e=Q(),null!==e?(o=ls,58===n.charCodeAt(ls)?(t=":",ls++):(t=null,0===is&&s('":"')),null!==t?(r=tt(),null!==r?t=[t,r]:(t=null,ls=o)):(t=null,ls=o),t=null!==t?t:"",null!==t?(64===n.charCodeAt(ls)?(r="@",ls++):(r=null,0===is&&s('"@"')),null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(e){hs.user=decodeURIComponent(n.substring(ls-1,e))}(l)),null===e&&(ls=l),e}function Q(){var e,t;if(t=g(),null===t&&(t=_(),null===t&&(t=et())),null!==t)for(e=[];null!==t;)e.push(t),t=g(),null===t&&(t=_(),null===t&&(t=et()));else e=null;return e}function et(){var e;return 38===n.charCodeAt(ls)?(e="&",ls++):(e=null,0===is&&s('"&"')),null===e&&(61===n.charCodeAt(ls)?(e="=",ls++):(e=null,0===is&&s('"="')),null===e&&(43===n.charCodeAt(ls)?(e="+",ls++):(e=null,0===is&&s('"+"')),null===e&&(36===n.charCodeAt(ls)?(e="$",ls++):(e=null,0===is&&s('"$"')),null===e&&(44===n.charCodeAt(ls)?(e=",",ls++):(e=null,0===is&&s('","')),null===e&&(59===n.charCodeAt(ls)?(e=";",ls++):(e=null,0===is&&s('";"')),null===e&&(63===n.charCodeAt(ls)?(e="?",ls++):(e=null,0===is&&s('"?"')),null===e&&(47===n.charCodeAt(ls)?(e="/",ls++):(e=null,0===is&&s('"/"'))))))))),e
  }function tt(){var e,t,r;for(r=ls,e=[],t=g(),null===t&&(t=_(),null===t&&(38===n.charCodeAt(ls)?(t="&",ls++):(t=null,0===is&&s('"&"')),null===t&&(61===n.charCodeAt(ls)?(t="=",ls++):(t=null,0===is&&s('"="')),null===t&&(43===n.charCodeAt(ls)?(t="+",ls++):(t=null,0===is&&s('"+"')),null===t&&(36===n.charCodeAt(ls)?(t="$",ls++):(t=null,0===is&&s('"$"')),null===t&&(44===n.charCodeAt(ls)?(t=",",ls++):(t=null,0===is&&s('","'))))))));null!==t;)e.push(t),t=g(),null===t&&(t=_(),null===t&&(38===n.charCodeAt(ls)?(t="&",ls++):(t=null,0===is&&s('"&"')),null===t&&(61===n.charCodeAt(ls)?(t="=",ls++):(t=null,0===is&&s('"="')),null===t&&(43===n.charCodeAt(ls)?(t="+",ls++):(t=null,0===is&&s('"+"')),null===t&&(36===n.charCodeAt(ls)?(t="$",ls++):(t=null,0===is&&s('"$"')),null===t&&(44===n.charCodeAt(ls)?(t=",",ls++):(t=null,0===is&&s('","'))))))));return null!==e&&(e=function(e){hs.password=n.substring(ls,e)}(r)),null===e&&(ls=r),e}function nt(){var e,t,r,l,i;return l=ls,e=rt(),null!==e?(i=ls,58===n.charCodeAt(ls)?(t=":",ls++):(t=null,0===is&&s('":"')),null!==t?(r=pt(),null!==r?t=[t,r]:(t=null,ls=i)):(t=null,ls=i),t=null!==t?t:"",null!==t?e=[e,t]:(e=null,ls=l)):(e=null,ls=l),e}function rt(){var e,t;return t=ls,e=ht(),null===e&&(e=ot(),null===e&&(e=st())),null!==e&&(e=function(e){return hs.host=n.substring(ls,e).toLowerCase(),hs.host}(t)),null===e&&(ls=t),e}function st(){var e,t,r,l,i,o;for(l=ls,i=ls,e=[],o=ls,t=lt(),null!==t?(46===n.charCodeAt(ls)?(r=".",ls++):(r=null,0===is&&s('"."')),null!==r?t=[t,r]:(t=null,ls=o)):(t=null,ls=o);null!==t;)e.push(t),o=ls,t=lt(),null!==t?(46===n.charCodeAt(ls)?(r=".",ls++):(r=null,0===is&&s('"."')),null!==r?t=[t,r]:(t=null,ls=o)):(t=null,ls=o);return null!==e?(t=it(),null!==t?(46===n.charCodeAt(ls)?(r=".",ls++):(r=null,0===is&&s('"."')),r=null!==r?r:"",null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(e){return hs.host_type="domain",n.substring(ls,e)}(l)),null===e&&(ls=l),e}function lt(){var e,t;if(/^[a-zA-Z0-9_\-]/.test(n.charAt(ls))?(t=n.charAt(ls),ls++):(t=null,0===is&&s("[a-zA-Z0-9_\\-]")),null!==t)for(e=[];null!==t;)e.push(t),/^[a-zA-Z0-9_\-]/.test(n.charAt(ls))?(t=n.charAt(ls),ls++):(t=null,0===is&&s("[a-zA-Z0-9_\\-]"));else e=null;return e}function it(){var e,t;if(/^[a-zA-Z0-9_\-]/.test(n.charAt(ls))?(t=n.charAt(ls),ls++):(t=null,0===is&&s("[a-zA-Z0-9_\\-]")),null!==t)for(e=[];null!==t;)e.push(t),/^[a-zA-Z0-9_\-]/.test(n.charAt(ls))?(t=n.charAt(ls),ls++):(t=null,0===is&&s("[a-zA-Z0-9_\\-]"));else e=null;return e}function ot(){var e,t,r,l,i;return l=ls,i=ls,91===n.charCodeAt(ls)?(e="[",ls++):(e=null,0===is&&s('"["')),null!==e?(t=ut(),null!==t?(93===n.charCodeAt(ls)?(r="]",ls++):(r=null,0===is&&s('"]"')),null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(e){return hs.host_type="IPv6",n.substring(ls,e)}(l)),null===e&&(ls=l),e}function ut(){var e,t,r,l,i,o,u,a,c,h,d,p,f,m,g,T;return m=ls,g=ls,e=at(),null!==e?(58===n.charCodeAt(ls)?(t=":",ls++):(t=null,0===is&&s('":"')),null!==t?(r=at(),null!==r?(58===n.charCodeAt(ls)?(l=":",ls++):(l=null,0===is&&s('":"')),null!==l?(i=at(),null!==i?(58===n.charCodeAt(ls)?(o=":",ls++):(o=null,0===is&&s('":"')),null!==o?(u=at(),null!==u?(58===n.charCodeAt(ls)?(a=":",ls++):(a=null,0===is&&s('":"')),null!==a?(c=at(),null!==c?(58===n.charCodeAt(ls)?(h=":",ls++):(h=null,0===is&&s('":"')),null!==h?(d=at(),null!==d?(58===n.charCodeAt(ls)?(p=":",ls++):(p=null,0===is&&s('":"')),null!==p?(f=ct(),null!==f?e=[e,t,r,l,i,o,u,a,c,h,d,p,f]:(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g),null===e&&(g=ls,"::"===n.substr(ls,2)?(e="::",ls+=2):(e=null,0===is&&s('"::"')),null!==e?(t=at(),null!==t?(58===n.charCodeAt(ls)?(r=":",ls++):(r=null,0===is&&s('":"')),null!==r?(l=at(),null!==l?(58===n.charCodeAt(ls)?(i=":",ls++):(i=null,0===is&&s('":"')),null!==i?(o=at(),null!==o?(58===n.charCodeAt(ls)?(u=":",ls++):(u=null,0===is&&s('":"')),null!==u?(a=at(),null!==a?(58===n.charCodeAt(ls)?(c=":",ls++):(c=null,0===is&&s('":"')),null!==c?(h=at(),null!==h?(58===n.charCodeAt(ls)?(d=":",ls++):(d=null,0===is&&s('":"')),null!==d?(p=ct(),null!==p?e=[e,t,r,l,i,o,u,a,c,h,d,p]:(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g),null===e&&(g=ls,"::"===n.substr(ls,2)?(e="::",ls+=2):(e=null,0===is&&s('"::"')),null!==e?(t=at(),null!==t?(58===n.charCodeAt(ls)?(r=":",ls++):(r=null,0===is&&s('":"')),null!==r?(l=at(),null!==l?(58===n.charCodeAt(ls)?(i=":",ls++):(i=null,0===is&&s('":"')),null!==i?(o=at(),null!==o?(58===n.charCodeAt(ls)?(u=":",ls++):(u=null,0===is&&s('":"')),null!==u?(a=at(),null!==a?(58===n.charCodeAt(ls)?(c=":",ls++):(c=null,0===is&&s('":"')),null!==c?(h=ct(),null!==h?e=[e,t,r,l,i,o,u,a,c,h]:(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g),null===e&&(g=ls,"::"===n.substr(ls,2)?(e="::",ls+=2):(e=null,0===is&&s('"::"')),null!==e?(t=at(),null!==t?(58===n.charCodeAt(ls)?(r=":",ls++):(r=null,0===is&&s('":"')),null!==r?(l=at(),null!==l?(58===n.charCodeAt(ls)?(i=":",ls++):(i=null,0===is&&s('":"')),null!==i?(o=at(),null!==o?(58===n.charCodeAt(ls)?(u=":",ls++):(u=null,0===is&&s('":"')),null!==u?(a=ct(),null!==a?e=[e,t,r,l,i,o,u,a]:(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g),null===e&&(g=ls,"::"===n.substr(ls,2)?(e="::",ls+=2):(e=null,0===is&&s('"::"')),null!==e?(t=at(),null!==t?(58===n.charCodeAt(ls)?(r=":",ls++):(r=null,0===is&&s('":"')),null!==r?(l=at(),null!==l?(58===n.charCodeAt(ls)?(i=":",ls++):(i=null,0===is&&s('":"')),null!==i?(o=ct(),null!==o?e=[e,t,r,l,i,o]:(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g),null===e&&(g=ls,"::"===n.substr(ls,2)?(e="::",ls+=2):(e=null,0===is&&s('"::"')),null!==e?(t=at(),null!==t?(58===n.charCodeAt(ls)?(r=":",ls++):(r=null,0===is&&s('":"')),null!==r?(l=ct(),null!==l?e=[e,t,r,l]:(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g),null===e&&(g=ls,"::"===n.substr(ls,2)?(e="::",ls+=2):(e=null,0===is&&s('"::"')),null!==e?(t=ct(),null!==t?e=[e,t]:(e=null,ls=g)):(e=null,ls=g),null===e&&(g=ls,"::"===n.substr(ls,2)?(e="::",ls+=2):(e=null,0===is&&s('"::"')),null!==e?(t=at(),null!==t?e=[e,t]:(e=null,ls=g)):(e=null,ls=g),null===e&&(g=ls,e=at(),null!==e?("::"===n.substr(ls,2)?(t="::",ls+=2):(t=null,0===is&&s('"::"')),null!==t?(r=at(),null!==r?(58===n.charCodeAt(ls)?(l=":",ls++):(l=null,0===is&&s('":"')),null!==l?(i=at(),null!==i?(58===n.charCodeAt(ls)?(o=":",ls++):(o=null,0===is&&s('":"')),null!==o?(u=at(),null!==u?(58===n.charCodeAt(ls)?(a=":",ls++):(a=null,0===is&&s('":"')),null!==a?(c=at(),null!==c?(58===n.charCodeAt(ls)?(h=":",ls++):(h=null,0===is&&s('":"')),null!==h?(d=ct(),null!==d?e=[e,t,r,l,i,o,u,a,c,h,d]:(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g),null===e&&(g=ls,e=at(),null!==e?(T=ls,58===n.charCodeAt(ls)?(t=":",ls++):(t=null,0===is&&s('":"')),null!==t?(r=at(),null!==r?t=[t,r]:(t=null,ls=T)):(t=null,ls=T),t=null!==t?t:"",null!==t?("::"===n.substr(ls,2)?(r="::",ls+=2):(r=null,0===is&&s('"::"')),null!==r?(l=at(),null!==l?(58===n.charCodeAt(ls)?(i=":",ls++):(i=null,0===is&&s('":"')),null!==i?(o=at(),null!==o?(58===n.charCodeAt(ls)?(u=":",ls++):(u=null,0===is&&s('":"')),null!==u?(a=at(),null!==a?(58===n.charCodeAt(ls)?(c=":",ls++):(c=null,0===is&&s('":"')),null!==c?(h=ct(),null!==h?e=[e,t,r,l,i,o,u,a,c,h]:(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g),null===e&&(g=ls,e=at(),null!==e?(T=ls,58===n.charCodeAt(ls)?(t=":",ls++):(t=null,0===is&&s('":"')),null!==t?(r=at(),null!==r?t=[t,r]:(t=null,ls=T)):(t=null,ls=T),t=null!==t?t:"",null!==t?(T=ls,58===n.charCodeAt(ls)?(r=":",ls++):(r=null,0===is&&s('":"')),null!==r?(l=at(),null!==l?r=[r,l]:(r=null,ls=T)):(r=null,ls=T),r=null!==r?r:"",null!==r?("::"===n.substr(ls,2)?(l="::",ls+=2):(l=null,0===is&&s('"::"')),null!==l?(i=at(),null!==i?(58===n.charCodeAt(ls)?(o=":",ls++):(o=null,0===is&&s('":"')),null!==o?(u=at(),null!==u?(58===n.charCodeAt(ls)?(a=":",ls++):(a=null,0===is&&s('":"')),null!==a?(c=ct(),null!==c?e=[e,t,r,l,i,o,u,a,c]:(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g),null===e&&(g=ls,e=at(),null!==e?(T=ls,58===n.charCodeAt(ls)?(t=":",ls++):(t=null,0===is&&s('":"')),null!==t?(r=at(),null!==r?t=[t,r]:(t=null,ls=T)):(t=null,ls=T),t=null!==t?t:"",null!==t?(T=ls,58===n.charCodeAt(ls)?(r=":",ls++):(r=null,0===is&&s('":"')),null!==r?(l=at(),null!==l?r=[r,l]:(r=null,ls=T)):(r=null,ls=T),r=null!==r?r:"",null!==r?(T=ls,58===n.charCodeAt(ls)?(l=":",ls++):(l=null,0===is&&s('":"')),null!==l?(i=at(),null!==i?l=[l,i]:(l=null,ls=T)):(l=null,ls=T),l=null!==l?l:"",null!==l?("::"===n.substr(ls,2)?(i="::",ls+=2):(i=null,0===is&&s('"::"')),null!==i?(o=at(),null!==o?(58===n.charCodeAt(ls)?(u=":",ls++):(u=null,0===is&&s('":"')),null!==u?(a=ct(),null!==a?e=[e,t,r,l,i,o,u,a]:(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g),null===e&&(g=ls,e=at(),null!==e?(T=ls,58===n.charCodeAt(ls)?(t=":",ls++):(t=null,0===is&&s('":"')),null!==t?(r=at(),null!==r?t=[t,r]:(t=null,ls=T)):(t=null,ls=T),t=null!==t?t:"",null!==t?(T=ls,58===n.charCodeAt(ls)?(r=":",ls++):(r=null,0===is&&s('":"')),null!==r?(l=at(),null!==l?r=[r,l]:(r=null,ls=T)):(r=null,ls=T),r=null!==r?r:"",null!==r?(T=ls,58===n.charCodeAt(ls)?(l=":",ls++):(l=null,0===is&&s('":"')),null!==l?(i=at(),null!==i?l=[l,i]:(l=null,ls=T)):(l=null,ls=T),l=null!==l?l:"",null!==l?(T=ls,58===n.charCodeAt(ls)?(i=":",ls++):(i=null,0===is&&s('":"')),null!==i?(o=at(),null!==o?i=[i,o]:(i=null,ls=T)):(i=null,ls=T),i=null!==i?i:"",null!==i?("::"===n.substr(ls,2)?(o="::",ls+=2):(o=null,0===is&&s('"::"')),null!==o?(u=ct(),null!==u?e=[e,t,r,l,i,o,u]:(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g),null===e&&(g=ls,e=at(),null!==e?(T=ls,58===n.charCodeAt(ls)?(t=":",ls++):(t=null,0===is&&s('":"')),null!==t?(r=at(),null!==r?t=[t,r]:(t=null,ls=T)):(t=null,ls=T),t=null!==t?t:"",null!==t?(T=ls,58===n.charCodeAt(ls)?(r=":",ls++):(r=null,0===is&&s('":"')),null!==r?(l=at(),null!==l?r=[r,l]:(r=null,ls=T)):(r=null,ls=T),r=null!==r?r:"",null!==r?(T=ls,58===n.charCodeAt(ls)?(l=":",ls++):(l=null,0===is&&s('":"')),null!==l?(i=at(),null!==i?l=[l,i]:(l=null,ls=T)):(l=null,ls=T),l=null!==l?l:"",null!==l?(T=ls,58===n.charCodeAt(ls)?(i=":",ls++):(i=null,0===is&&s('":"')),null!==i?(o=at(),null!==o?i=[i,o]:(i=null,ls=T)):(i=null,ls=T),i=null!==i?i:"",null!==i?(T=ls,58===n.charCodeAt(ls)?(o=":",ls++):(o=null,0===is&&s('":"')),null!==o?(u=at(),null!==u?o=[o,u]:(o=null,ls=T)):(o=null,ls=T),o=null!==o?o:"",null!==o?("::"===n.substr(ls,2)?(u="::",ls+=2):(u=null,0===is&&s('"::"')),null!==u?(a=at(),null!==a?e=[e,t,r,l,i,o,u,a]:(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g),null===e&&(g=ls,e=at(),null!==e?(T=ls,58===n.charCodeAt(ls)?(t=":",ls++):(t=null,0===is&&s('":"')),null!==t?(r=at(),null!==r?t=[t,r]:(t=null,ls=T)):(t=null,ls=T),t=null!==t?t:"",null!==t?(T=ls,58===n.charCodeAt(ls)?(r=":",ls++):(r=null,0===is&&s('":"')),null!==r?(l=at(),null!==l?r=[r,l]:(r=null,ls=T)):(r=null,ls=T),r=null!==r?r:"",null!==r?(T=ls,58===n.charCodeAt(ls)?(l=":",ls++):(l=null,0===is&&s('":"')),null!==l?(i=at(),null!==i?l=[l,i]:(l=null,ls=T)):(l=null,ls=T),l=null!==l?l:"",null!==l?(T=ls,58===n.charCodeAt(ls)?(i=":",ls++):(i=null,0===is&&s('":"')),null!==i?(o=at(),null!==o?i=[i,o]:(i=null,ls=T)):(i=null,ls=T),i=null!==i?i:"",null!==i?(T=ls,58===n.charCodeAt(ls)?(o=":",ls++):(o=null,0===is&&s('":"')),null!==o?(u=at(),null!==u?o=[o,u]:(o=null,ls=T)):(o=null,ls=T),o=null!==o?o:"",null!==o?(T=ls,58===n.charCodeAt(ls)?(u=":",ls++):(u=null,0===is&&s('":"')),null!==u?(a=at(),null!==a?u=[u,a]:(u=null,ls=T)):(u=null,ls=T),u=null!==u?u:"",null!==u?("::"===n.substr(ls,2)?(a="::",ls+=2):(a=null,0===is&&s('"::"')),null!==a?e=[e,t,r,l,i,o,u,a]:(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g)):(e=null,ls=g))))))))))))))),null!==e&&(e=function(e){return hs.host_type="IPv6",n.substring(ls,e)}(m)),null===e&&(ls=m),e}function at(){var e,t,n,r,s;return s=ls,e=u(),null!==e?(t=u(),t=null!==t?t:"",null!==t?(n=u(),n=null!==n?n:"",null!==n?(r=u(),r=null!==r?r:"",null!==r?e=[e,t,n,r]:(e=null,ls=s)):(e=null,ls=s)):(e=null,ls=s)):(e=null,ls=s),e}function ct(){var e,t,r,l;return l=ls,e=at(),null!==e?(58===n.charCodeAt(ls)?(t=":",ls++):(t=null,0===is&&s('":"')),null!==t?(r=at(),null!==r?e=[e,t,r]:(e=null,ls=l)):(e=null,ls=l)):(e=null,ls=l),null===e&&(e=ht()),e}function ht(){var e,t,r,l,i,o,u,a,c;return a=ls,c=ls,e=dt(),null!==e?(46===n.charCodeAt(ls)?(t=".",ls++):(t=null,0===is&&s('"."')),null!==t?(r=dt(),null!==r?(46===n.charCodeAt(ls)?(l=".",ls++):(l=null,0===is&&s('"."')),null!==l?(i=dt(),null!==i?(46===n.charCodeAt(ls)?(o=".",ls++):(o=null,0===is&&s('"."')),null!==o?(u=dt(),null!==u?e=[e,t,r,l,i,o,u]:(e=null,ls=c)):(e=null,ls=c)):(e=null,ls=c)):(e=null,ls=c)):(e=null,ls=c)):(e=null,ls=c)):(e=null,ls=c),null!==e&&(e=function(e){return hs.host_type="IPv4",n.substring(ls,e)}(a)),null===e&&(ls=a),e}function dt(){var e,t,r,l;return l=ls,"25"===n.substr(ls,2)?(e="25",ls+=2):(e=null,0===is&&s('"25"')),null!==e?(/^[0-5]/.test(n.charAt(ls))?(t=n.charAt(ls),ls++):(t=null,0===is&&s("[0-5]")),null!==t?e=[e,t]:(e=null,ls=l)):(e=null,ls=l),null===e&&(l=ls,50===n.charCodeAt(ls)?(e="2",ls++):(e=null,0===is&&s('"2"')),null!==e?(/^[0-4]/.test(n.charAt(ls))?(t=n.charAt(ls),ls++):(t=null,0===is&&s("[0-4]")),null!==t?(r=i(),null!==r?e=[e,t,r]:(e=null,ls=l)):(e=null,ls=l)):(e=null,ls=l),null===e&&(l=ls,49===n.charCodeAt(ls)?(e="1",ls++):(e=null,0===is&&s('"1"')),null!==e?(t=i(),null!==t?(r=i(),null!==r?e=[e,t,r]:(e=null,ls=l)):(e=null,ls=l)):(e=null,ls=l),null===e&&(l=ls,/^[1-9]/.test(n.charAt(ls))?(e=n.charAt(ls),ls++):(e=null,0===is&&s("[1-9]")),null!==e?(t=i(),null!==t?e=[e,t]:(e=null,ls=l)):(e=null,ls=l),null===e&&(e=i())))),e}function pt(){var e,t,n,r,s,l,o;return l=ls,o=ls,e=i(),e=null!==e?e:"",null!==e?(t=i(),t=null!==t?t:"",null!==t?(n=i(),n=null!==n?n:"",null!==n?(r=i(),r=null!==r?r:"",null!==r?(s=i(),s=null!==s?s:"",null!==s?e=[e,t,n,r,s]:(e=null,ls=o)):(e=null,ls=o)):(e=null,ls=o)):(e=null,ls=o)):(e=null,ls=o),null!==e&&(e=function(e,t){return t=parseInt(t.join("")),hs.port=t,t}(l,e)),null===e&&(ls=l),e}function ft(){var e,t,r,l;for(e=[],l=ls,59===n.charCodeAt(ls)?(t=";",ls++):(t=null,0===is&&s('";"')),null!==t?(r=mt(),null!==r?t=[t,r]:(t=null,ls=l)):(t=null,ls=l);null!==t;)e.push(t),l=ls,59===n.charCodeAt(ls)?(t=";",ls++):(t=null,0===is&&s('";"')),null!==t?(r=mt(),null!==r?t=[t,r]:(t=null,ls=l)):(t=null,ls=l);return e}function mt(){var e;return e=gt(),null===e&&(e=Tt(),null===e&&(e=_t(),null===e&&(e=vt(),null===e&&(e=Ct(),null===e&&(e=St(),null===e&&(e=Et())))))),e}function gt(){var e,t,r,l;return r=ls,l=ls,"transport="===n.substr(ls,10).toLowerCase()?(e=n.substr(ls,10),ls+=10):(e=null,0===is&&s('"transport="')),null!==e?("udp"===n.substr(ls,3).toLowerCase()?(t=n.substr(ls,3),ls+=3):(t=null,0===is&&s('"udp"')),null===t&&("tcp"===n.substr(ls,3).toLowerCase()?(t=n.substr(ls,3),ls+=3):(t=null,0===is&&s('"tcp"')),null===t&&("sctp"===n.substr(ls,4).toLowerCase()?(t=n.substr(ls,4),ls+=4):(t=null,0===is&&s('"sctp"')),null===t&&("tls"===n.substr(ls,3).toLowerCase()?(t=n.substr(ls,3),ls+=3):(t=null,0===is&&s('"tls"')),null===t&&(t=I())))),null!==t?e=[e,t]:(e=null,ls=l)):(e=null,ls=l),null!==e&&(e=function(e,t){hs.uri_params||(hs.uri_params={}),hs.uri_params.transport=t.toLowerCase()}(r,e[1])),null===e&&(ls=r),e}function Tt(){var e,t,r,l;return r=ls,l=ls,"user="===n.substr(ls,5).toLowerCase()?(e=n.substr(ls,5),ls+=5):(e=null,0===is&&s('"user="')),null!==e?("phone"===n.substr(ls,5).toLowerCase()?(t=n.substr(ls,5),ls+=5):(t=null,0===is&&s('"phone"')),null===t&&("ip"===n.substr(ls,2).toLowerCase()?(t=n.substr(ls,2),ls+=2):(t=null,0===is&&s('"ip"')),null===t&&(t=I())),null!==t?e=[e,t]:(e=null,ls=l)):(e=null,ls=l),null!==e&&(e=function(e,t){hs.uri_params||(hs.uri_params={}),hs.uri_params.user=t.toLowerCase()}(r,e[1])),null===e&&(ls=r),e}function _t(){var e,t,r,l;return r=ls,l=ls,"method="===n.substr(ls,7).toLowerCase()?(e=n.substr(ls,7),ls+=7):(e=null,0===is&&s('"method="')),null!==e?(t=on(),null!==t?e=[e,t]:(e=null,ls=l)):(e=null,ls=l),null!==e&&(e=function(e,t){hs.uri_params||(hs.uri_params={}),hs.uri_params.method=t}(r,e[1])),null===e&&(ls=r),e}function vt(){var e,t,r,l;return r=ls,l=ls,"ttl="===n.substr(ls,4).toLowerCase()?(e=n.substr(ls,4),ls+=4):(e=null,0===is&&s('"ttl="')),null!==e?(t=jr(),null!==t?e=[e,t]:(e=null,ls=l)):(e=null,ls=l),null!==e&&(e=function(e,t){hs.params||(hs.params={}),hs.params.ttl=t}(r,e[1])),null===e&&(ls=r),e}function Ct(){var e,t,r,l;return r=ls,l=ls,"maddr="===n.substr(ls,6).toLowerCase()?(e=n.substr(ls,6),ls+=6):(e=null,0===is&&s('"maddr="')),null!==e?(t=rt(),null!==t?e=[e,t]:(e=null,ls=l)):(e=null,ls=l),null!==e&&(e=function(e,t){hs.uri_params||(hs.uri_params={}),hs.uri_params.maddr=t}(r,e[1])),null===e&&(ls=r),e}function St(){var e,t,r,l,i,o;return l=ls,i=ls,"lr"===n.substr(ls,2).toLowerCase()?(e=n.substr(ls,2),ls+=2):(e=null,0===is&&s('"lr"')),null!==e?(o=ls,61===n.charCodeAt(ls)?(t="=",ls++):(t=null,0===is&&s('"="')),null!==t?(r=I(),null!==r?t=[t,r]:(t=null,ls=o)):(t=null,ls=o),t=null!==t?t:"",null!==t?e=[e,t]:(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(){hs.uri_params||(hs.uri_params={}),hs.uri_params.lr=void 0}(l)),null===e&&(ls=l),e}function Et(){var e,t,r,l,i,o;return l=ls,i=ls,e=At(),null!==e?(o=ls,61===n.charCodeAt(ls)?(t="=",ls++):(t=null,0===is&&s('"="')),null!==t?(r=Rt(),null!==r?t=[t,r]:(t=null,ls=o)):(t=null,ls=o),t=null!==t?t:"",null!==t?e=[e,t]:(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(e,t,n){hs.uri_params||(hs.uri_params={}),n="undefined"==typeof n?void 0:n[1],hs.uri_params[t.toLowerCase()]=n&&n.toLowerCase()}(l,e[0],e[1])),null===e&&(ls=l),e}function At(){var e,t,n;if(n=ls,t=yt(),null!==t)for(e=[];null!==t;)e.push(t),t=yt();else e=null;return null!==e&&(e=function(e,t){return t.join("")}(n,e)),null===e&&(ls=n),e}function Rt(){var e,t,n;if(n=ls,t=yt(),null!==t)for(e=[];null!==t;)e.push(t),t=yt();else e=null;return null!==e&&(e=function(e,t){return t.join("")}(n,e)),null===e&&(ls=n),e}function yt(){var e;return e=bt(),null===e&&(e=g(),null===e&&(e=_())),e}function bt(){var e;return 91===n.charCodeAt(ls)?(e="[",ls++):(e=null,0===is&&s('"["')),null===e&&(93===n.charCodeAt(ls)?(e="]",ls++):(e=null,0===is&&s('"]"')),null===e&&(47===n.charCodeAt(ls)?(e="/",ls++):(e=null,0===is&&s('"/"')),null===e&&(58===n.charCodeAt(ls)?(e=":",ls++):(e=null,0===is&&s('":"')),null===e&&(38===n.charCodeAt(ls)?(e="&",ls++):(e=null,0===is&&s('"&"')),null===e&&(43===n.charCodeAt(ls)?(e="+",ls++):(e=null,0===is&&s('"+"')),null===e&&(36===n.charCodeAt(ls)?(e="$",ls++):(e=null,0===is&&s('"$"')))))))),e}function It(){var e,t,r,l,i,o,u;if(o=ls,63===n.charCodeAt(ls)?(e="?",ls++):(e=null,0===is&&s('"?"')),null!==e)if(t=wt(),null!==t){for(r=[],u=ls,38===n.charCodeAt(ls)?(l="&",ls++):(l=null,0===is&&s('"&"')),null!==l?(i=wt(),null!==i?l=[l,i]:(l=null,ls=u)):(l=null,ls=u);null!==l;)r.push(l),u=ls,38===n.charCodeAt(ls)?(l="&",ls++):(l=null,0===is&&s('"&"')),null!==l?(i=wt(),null!==i?l=[l,i]:(l=null,ls=u)):(l=null,ls=u);null!==r?e=[e,t,r]:(e=null,ls=o)}else e=null,ls=o;else e=null,ls=o;return e}function wt(){var e,t,r,l,i;return l=ls,i=ls,e=Nt(),null!==e?(61===n.charCodeAt(ls)?(t="=",ls++):(t=null,0===is&&s('"="')),null!==t?(r=Dt(),null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(e,t,n){t=t.join("").toLowerCase(),n=n.join(""),hs.uri_headers||(hs.uri_headers={}),hs.uri_headers[t]?hs.uri_headers[t].push(n):hs.uri_headers[t]=[n]}(l,e[0],e[2])),null===e&&(ls=l),e}function Nt(){var e,t;if(t=Ut(),null===t&&(t=g(),null===t&&(t=_())),null!==t)for(e=[];null!==t;)e.push(t),t=Ut(),null===t&&(t=g(),null===t&&(t=_()));else e=null;return e}function Dt(){var e,t;for(e=[],t=Ut(),null===t&&(t=g(),null===t&&(t=_()));null!==t;)e.push(t),t=Ut(),null===t&&(t=g(),null===t&&(t=_()));return e}function Ut(){var e;return 91===n.charCodeAt(ls)?(e="[",ls++):(e=null,0===is&&s('"["')),null===e&&(93===n.charCodeAt(ls)?(e="]",ls++):(e=null,0===is&&s('"]"')),null===e&&(47===n.charCodeAt(ls)?(e="/",ls++):(e=null,0===is&&s('"/"')),null===e&&(63===n.charCodeAt(ls)?(e="?",ls++):(e=null,0===is&&s('"?"')),null===e&&(58===n.charCodeAt(ls)?(e=":",ls++):(e=null,0===is&&s('":"')),null===e&&(43===n.charCodeAt(ls)?(e="+",ls++):(e=null,0===is&&s('"+"')),null===e&&(36===n.charCodeAt(ls)?(e="$",ls++):(e=null,0===is&&s('"$"')))))))),e}function Ot(){var e;return e=un(),null===e&&(e=xt()),e}function xt(){var e,t,n,r,s,l;return l=ls,e=on(),null!==e?(t=d(),null!==t?(n=Pt(),null!==n?(r=d(),null!==r?(s=$t(),null!==s?e=[e,t,n,r,s]:(e=null,ls=l)):(e=null,ls=l)):(e=null,ls=l)):(e=null,ls=l)):(e=null,ls=l),e}function Pt(){var e;return e=X(),null===e&&(e=Mt()),e}function Mt(){var e,t,r,l;return l=ls,e=Vt(),null!==e?(58===n.charCodeAt(ls)?(t=":",ls++):(t=null,0===is&&s('":"')),null!==t?(r=Lt(),null===r&&(r=Ht()),null!==r?e=[e,t,r]:(e=null,ls=l)):(e=null,ls=l)):(e=null,ls=l),e}function Lt(){var e,t,r,l,i;return l=ls,e=qt(),null===e&&(e=kt()),null!==e?(i=ls,63===n.charCodeAt(ls)?(t="?",ls++):(t=null,0===is&&s('"?"')),null!==t?(r=Xt(),null!==r?t=[t,r]:(t=null,ls=i)):(t=null,ls=i),t=null!==t?t:"",null!==t?e=[e,t]:(e=null,ls=l)):(e=null,ls=l),e}function qt(){var e,t,r,l;return l=ls,"//"===n.substr(ls,2)?(e="//",ls+=2):(e=null,0===is&&s('"//"')),null!==e?(t=Yt(),null!==t?(r=kt(),r=null!==r?r:"",null!==r?e=[e,t,r]:(e=null,ls=l)):(e=null,ls=l)):(e=null,ls=l),e}function kt(){var e,t,r;return r=ls,47===n.charCodeAt(ls)?(e="/",ls++):(e=null,0===is&&s('"/"')),null!==e?(t=jt(),null!==t?e=[e,t]:(e=null,ls=r)):(e=null,ls=r),e}function Ht(){var e,t,n,r;if(r=ls,e=Gt(),null!==e){for(t=[],n=Ft();null!==n;)t.push(n),n=Ft();null!==t?e=[e,t]:(e=null,ls=r)}else e=null,ls=r;return e}function Ft(){var e;return e=m(),null===e&&(e=g(),null===e&&(e=_())),e}function Gt(){var e;return e=g(),null===e&&(e=_(),null===e&&(59===n.charCodeAt(ls)?(e=";",ls++):(e=null,0===is&&s('";"')),null===e&&(63===n.charCodeAt(ls)?(e="?",ls++):(e=null,0===is&&s('"?"')),null===e&&(58===n.charCodeAt(ls)?(e=":",ls++):(e=null,0===is&&s('":"')),null===e&&(64===n.charCodeAt(ls)?(e="@",ls++):(e=null,0===is&&s('"@"')),null===e&&(38===n.charCodeAt(ls)?(e="&",ls++):(e=null,0===is&&s('"&"')),null===e&&(61===n.charCodeAt(ls)?(e="=",ls++):(e=null,0===is&&s('"="')),null===e&&(43===n.charCodeAt(ls)?(e="+",ls++):(e=null,0===is&&s('"+"')),null===e&&(36===n.charCodeAt(ls)?(e="$",ls++):(e=null,0===is&&s('"$"')),null===e&&(44===n.charCodeAt(ls)?(e=",",ls++):(e=null,0===is&&s('","')))))))))))),e}function jt(){var e,t,r,l,i,o;if(i=ls,e=Wt(),null!==e){for(t=[],o=ls,47===n.charCodeAt(ls)?(r="/",ls++):(r=null,0===is&&s('"/"')),null!==r?(l=Wt(),null!==l?r=[r,l]:(r=null,ls=o)):(r=null,ls=o);null!==r;)t.push(r),o=ls,47===n.charCodeAt(ls)?(r="/",ls++):(r=null,0===is&&s('"/"')),null!==r?(l=Wt(),null!==l?r=[r,l]:(r=null,ls=o)):(r=null,ls=o);null!==t?e=[e,t]:(e=null,ls=i)}else e=null,ls=i;return e}function Wt(){var e,t,r,l,i,o;for(i=ls,e=[],t=zt();null!==t;)e.push(t),t=zt();if(null!==e){for(t=[],o=ls,59===n.charCodeAt(ls)?(r=";",ls++):(r=null,0===is&&s('";"')),null!==r?(l=Bt(),null!==l?r=[r,l]:(r=null,ls=o)):(r=null,ls=o);null!==r;)t.push(r),o=ls,59===n.charCodeAt(ls)?(r=";",ls++):(r=null,0===is&&s('";"')),null!==r?(l=Bt(),null!==l?r=[r,l]:(r=null,ls=o)):(r=null,ls=o);null!==t?e=[e,t]:(e=null,ls=i)}else e=null,ls=i;return e}function Bt(){var e,t;for(e=[],t=zt();null!==t;)e.push(t),t=zt();return e}function zt(){var e;return e=g(),null===e&&(e=_(),null===e&&(58===n.charCodeAt(ls)?(e=":",ls++):(e=null,0===is&&s('":"')),null===e&&(64===n.charCodeAt(ls)?(e="@",ls++):(e=null,0===is&&s('"@"')),null===e&&(38===n.charCodeAt(ls)?(e="&",ls++):(e=null,0===is&&s('"&"')),null===e&&(61===n.charCodeAt(ls)?(e="=",ls++):(e=null,0===is&&s('"="')),null===e&&(43===n.charCodeAt(ls)?(e="+",ls++):(e=null,0===is&&s('"+"')),null===e&&(36===n.charCodeAt(ls)?(e="$",ls++):(e=null,0===is&&s('"$"')),null===e&&(44===n.charCodeAt(ls)?(e=",",ls++):(e=null,0===is&&s('","')))))))))),e}function Vt(){var e,t,r,l,u;if(l=ls,u=ls,e=o(),null!==e){for(t=[],r=o(),null===r&&(r=i(),null===r&&(43===n.charCodeAt(ls)?(r="+",ls++):(r=null,0===is&&s('"+"')),null===r&&(45===n.charCodeAt(ls)?(r="-",ls++):(r=null,0===is&&s('"-"')),null===r&&(46===n.charCodeAt(ls)?(r=".",ls++):(r=null,0===is&&s('"."'))))));null!==r;)t.push(r),r=o(),null===r&&(r=i(),null===r&&(43===n.charCodeAt(ls)?(r="+",ls++):(r=null,0===is&&s('"+"')),null===r&&(45===n.charCodeAt(ls)?(r="-",ls++):(r=null,0===is&&s('"-"')),null===r&&(46===n.charCodeAt(ls)?(r=".",ls++):(r=null,0===is&&s('"."'))))));null!==t?e=[e,t]:(e=null,ls=u)}else e=null,ls=u;return null!==e&&(e=function(e){hs.scheme=n.substring(ls,e)}(l)),null===e&&(ls=l),e}function Yt(){var e;return e=Kt(),null===e&&(e=Jt()),e}function Kt(){var e,t,r,l;return r=ls,l=ls,e=Z(),null!==e?(64===n.charCodeAt(ls)?(t="@",ls++):(t=null,0===is&&s('"@"')),null!==t?e=[e,t]:(e=null,ls=l)):(e=null,ls=l),e=null!==e?e:"",null!==e?(t=nt(),null!==t?e=[e,t]:(e=null,ls=r)):(e=null,ls=r),e=null!==e?e:""}function Jt(){var e,t;if(t=g(),null===t&&(t=_(),null===t&&(36===n.charCodeAt(ls)?(t="$",ls++):(t=null,0===is&&s('"$"')),null===t&&(44===n.charCodeAt(ls)?(t=",",ls++):(t=null,0===is&&s('","')),null===t&&(59===n.charCodeAt(ls)?(t=";",ls++):(t=null,0===is&&s('";"')),null===t&&(58===n.charCodeAt(ls)?(t=":",ls++):(t=null,0===is&&s('":"')),null===t&&(64===n.charCodeAt(ls)?(t="@",ls++):(t=null,0===is&&s('"@"')),null===t&&(38===n.charCodeAt(ls)?(t="&",ls++):(t=null,0===is&&s('"&"')),null===t&&(61===n.charCodeAt(ls)?(t="=",ls++):(t=null,0===is&&s('"="')),null===t&&(43===n.charCodeAt(ls)?(t="+",ls++):(t=null,0===is&&s('"+"'))))))))))),null!==t)for(e=[];null!==t;)e.push(t),t=g(),null===t&&(t=_(),null===t&&(36===n.charCodeAt(ls)?(t="$",ls++):(t=null,0===is&&s('"$"')),null===t&&(44===n.charCodeAt(ls)?(t=",",ls++):(t=null,0===is&&s('","')),null===t&&(59===n.charCodeAt(ls)?(t=";",ls++):(t=null,0===is&&s('";"')),null===t&&(58===n.charCodeAt(ls)?(t=":",ls++):(t=null,0===is&&s('":"')),null===t&&(64===n.charCodeAt(ls)?(t="@",ls++):(t=null,0===is&&s('"@"')),null===t&&(38===n.charCodeAt(ls)?(t="&",ls++):(t=null,0===is&&s('"&"')),null===t&&(61===n.charCodeAt(ls)?(t="=",ls++):(t=null,0===is&&s('"="')),null===t&&(43===n.charCodeAt(ls)?(t="+",ls++):(t=null,0===is&&s('"+"')))))))))));else e=null;return e}function Xt(){var e,t;for(e=[],t=Ft();null!==t;)e.push(t),t=Ft();return e}function $t(){var e,t,r,l,o,u,a,c;if(a=ls,c=ls,"sip"===n.substr(ls,3).toLowerCase()?(e=n.substr(ls,3),ls+=3):(e=null,0===is&&s('"SIP"')),null!==e)if(47===n.charCodeAt(ls)?(t="/",ls++):(t=null,0===is&&s('"/"')),null!==t){if(l=i(),null!==l)for(r=[];null!==l;)r.push(l),l=i();else r=null;if(null!==r)if(46===n.charCodeAt(ls)?(l=".",ls++):(l=null,0===is&&s('"."')),null!==l){if(u=i(),null!==u)for(o=[];null!==u;)o.push(u),u=i();else o=null;null!==o?e=[e,t,r,l,o]:(e=null,ls=c)}else e=null,ls=c;else e=null,ls=c}else e=null,ls=c;else e=null,ls=c;return null!==e&&(e=function(e){hs.sip_version=n.substring(ls,e)}(a)),null===e&&(ls=a),e}function Zt(){var e;return"INVITE"===n.substr(ls,6)?(e="INVITE",ls+=6):(e=null,0===is&&s('"INVITE"')),e}function Qt(){var e;return"ACK"===n.substr(ls,3)?(e="ACK",ls+=3):(e=null,0===is&&s('"ACK"')),e}function en(){var e;return"OPTIONS"===n.substr(ls,7)?(e="OPTIONS",ls+=7):(e=null,0===is&&s('"OPTIONS"')),e}function tn(){var e;return"BYE"===n.substr(ls,3)?(e="BYE",ls+=3):(e=null,0===is&&s('"BYE"')),e}function nn(){var e;return"CANCEL"===n.substr(ls,6)?(e="CANCEL",ls+=6):(e=null,0===is&&s('"CANCEL"')),e}function rn(){var e;return"REGISTER"===n.substr(ls,8)?(e="REGISTER",ls+=8):(e=null,0===is&&s('"REGISTER"')),e}function sn(){var e;return"SUBSCRIBE"===n.substr(ls,9)?(e="SUBSCRIBE",ls+=9):(e=null,0===is&&s('"SUBSCRIBE"')),e}function ln(){var e;return"NOTIFY"===n.substr(ls,6)?(e="NOTIFY",ls+=6):(e=null,0===is&&s('"NOTIFY"')),e}function on(){var e,t;return t=ls,e=Zt(),null===e&&(e=Qt(),null===e&&(e=en(),null===e&&(e=tn(),null===e&&(e=nn(),null===e&&(e=rn(),null===e&&(e=sn(),null===e&&(e=ln(),null===e&&(e=I())))))))),null!==e&&(e=function(e){return hs.method=n.substring(ls,e),hs.method}(t)),null===e&&(ls=t),e}function un(){var e,t,n,r,s,l;return l=ls,e=$t(),null!==e?(t=d(),null!==t?(n=an(),null!==n?(r=d(),null!==r?(s=hn(),null!==s?e=[e,t,n,r,s]:(e=null,ls=l)):(e=null,ls=l)):(e=null,ls=l)):(e=null,ls=l)):(e=null,ls=l),e}function an(){var e,t;return t=ls,e=cn(),null!==e&&(e=function(e,t){hs.status_code=parseInt(t.join(""))}(t,e)),null===e&&(ls=t),e}function cn(){var e,t,n,r;return r=ls,e=i(),null!==e?(t=i(),null!==t?(n=i(),null!==n?e=[e,t,n]:(e=null,ls=r)):(e=null,ls=r)):(e=null,ls=r),e}function hn(){var e,t,r;for(r=ls,e=[],t=m(),null===t&&(t=g(),null===t&&(t=_(),null===t&&(t=R(),null===t&&(t=y(),null===t&&(t=d(),null===t&&(t=p()))))));null!==t;)e.push(t),t=m(),null===t&&(t=g(),null===t&&(t=_(),null===t&&(t=R(),null===t&&(t=y(),null===t&&(t=d(),null===t&&(t=p()))))));return null!==e&&(e=function(e){hs.reason_phrase=n.substring(ls,e)}(r)),null===e&&(ls=r),e}function dn(){var e,t,n,r,s,l;if(s=ls,e=zn(),null!==e){for(t=[],l=ls,n=k(),null!==n?(r=zn(),null!==r?n=[n,r]:(n=null,ls=l)):(n=null,ls=l);null!==n;)t.push(n),l=ls,n=k(),null!==n?(r=zn(),null!==r?n=[n,r]:(n=null,ls=l)):(n=null,ls=l);null!==t?e=[e,t]:(e=null,ls=s)}else e=null,ls=s;return e}function pn(){var e,t,r,l,i,o;return l=ls,i=ls,e=D(),null!==e?(o=ls,64===n.charCodeAt(ls)?(t="@",ls++):(t=null,0===is&&s('"@"')),null!==t?(r=D(),null!==r?t=[t,r]:(t=null,ls=o)):(t=null,ls=o),t=null!==t?t:"",null!==t?e=[e,t]:(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(e){hs=n.substring(ls,e)}(l)),null===e&&(ls=l),e}function fn(){var e,t,n,r,s,l,i;if(s=ls,e=U(),null===e)if(l=ls,e=mn(),null!==e){for(t=[],i=ls,n=k(),null!==n?(r=mn(),null!==r?n=[n,r]:(n=null,ls=i)):(n=null,ls=i);null!==n;)t.push(n),i=ls,n=k(),null!==n?(r=mn(),null!==r?n=[n,r]:(n=null,ls=i)):(n=null,ls=i);null!==t?e=[e,t]:(e=null,ls=l)}else e=null,ls=l;return null!==e&&(e=function(){var e,t;for(t=hs.multi_header.length,e=0;t>e;e++)if(null===hs.multi_header[e].parsed){hs=null;break}hs=null!==hs?hs.multi_header:-1}(s)),null===e&&(ls=s),e}function mn(){var e,t,n,r,s,l,i;if(s=ls,l=ls,e=J(),null===e&&(e=gn()),null!==e){for(t=[],i=ls,n=H(),null!==n?(r=_n(),null!==r?n=[n,r]:(n=null,ls=i)):(n=null,ls=i);null!==n;)t.push(n),i=ls,n=H(),null!==n?(r=_n(),null!==r?n=[n,r]:(n=null,ls=i)):(n=null,ls=i);null!==t?e=[e,t]:(e=null,ls=l)}else e=null,ls=l;return null!==e&&(e=function(e){var t;hs.multi_header||(hs.multi_header=[]);try{t=new cs(hs.uri,hs.display_name,hs.params),delete hs.uri,delete hs.display_name,delete hs.params}catch(n){t=null}hs.multi_header.push({possition:ls,offset:e,parsed:t})}(s)),null===e&&(ls=s),e}function gn(){var e,t,n,r,s;return s=ls,e=Tn(),e=null!==e?e:"",null!==e?(t=q(),null!==t?(n=X(),null!==n?(r=L(),null!==r?e=[e,t,n,r]:(e=null,ls=s)):(e=null,ls=s)):(e=null,ls=s)):(e=null,ls=s),e}function Tn(){var e,t,r,s,l,i,o;if(l=ls,i=ls,e=I(),null!==e){for(t=[],o=ls,r=v(),null!==r?(s=I(),null!==s?r=[r,s]:(r=null,ls=o)):(r=null,ls=o);null!==r;)t.push(r),o=ls,r=v(),null!==r?(s=I(),null!==s?r=[r,s]:(r=null,ls=o)):(r=null,ls=o);null!==t?e=[e,t]:(e=null,ls=i)}else e=null,ls=i;return null===e&&(e=z()),null!==e&&(e=function(e,t){t=n.substring(ls,e).trim(),'"'===t[0]&&(t=t.substring(1,t.length-1)),hs.display_name=t
  }(l,e)),null===e&&(ls=l),e}function _n(){var e;return e=vn(),null===e&&(e=Cn(),null===e&&(e=An())),e}function vn(){var e,t,r,l,i;return l=ls,i=ls,"q"===n.substr(ls,1).toLowerCase()?(e=n.substr(ls,1),ls++):(e=null,0===is&&s('"q"')),null!==e?(t=x(),null!==t?(r=En(),null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(e,t){hs.params||(hs.params={}),hs.params.q=t}(l,e[2])),null===e&&(ls=l),e}function Cn(){var e,t,r,l,i;return l=ls,i=ls,"expires"===n.substr(ls,7).toLowerCase()?(e=n.substr(ls,7),ls+=7):(e=null,0===is&&s('"expires"')),null!==e?(t=x(),null!==t?(r=Sn(),null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(e,t){hs.params||(hs.params={}),hs.params.expires=t}(l,e[2])),null===e&&(ls=l),e}function Sn(){var e,t,n;if(n=ls,t=i(),null!==t)for(e=[];null!==t;)e.push(t),t=i();else e=null;return null!==e&&(e=function(e,t){return parseInt(t.join(""))}(n,e)),null===e&&(ls=n),e}function En(){var e,t,r,l,o,u,a,c;return u=ls,a=ls,48===n.charCodeAt(ls)?(e="0",ls++):(e=null,0===is&&s('"0"')),null!==e?(c=ls,46===n.charCodeAt(ls)?(t=".",ls++):(t=null,0===is&&s('"."')),null!==t?(r=i(),r=null!==r?r:"",null!==r?(l=i(),l=null!==l?l:"",null!==l?(o=i(),o=null!==o?o:"",null!==o?t=[t,r,l,o]:(t=null,ls=c)):(t=null,ls=c)):(t=null,ls=c)):(t=null,ls=c),t=null!==t?t:"",null!==t?e=[e,t]:(e=null,ls=a)):(e=null,ls=a),null!==e&&(e=function(e){return parseFloat(n.substring(ls,e))}(u)),null===e&&(ls=u),e}function An(){var e,t,n,r,s,l;return r=ls,s=ls,e=I(),null!==e?(l=ls,t=x(),null!==t?(n=Rn(),null!==n?t=[t,n]:(t=null,ls=l)):(t=null,ls=l),t=null!==t?t:"",null!==t?e=[e,t]:(e=null,ls=s)):(e=null,ls=s),null!==e&&(e=function(e,t,n){hs.params||(hs.params={}),n="undefined"==typeof n?void 0:n[1],hs.params[t.toLowerCase()]=n}(r,e[0],e[1])),null===e&&(ls=r),e}function Rn(){var e;return e=I(),null===e&&(e=rt(),null===e&&(e=z())),e}function yn(){var e,t,n,r,s,l;if(s=ls,e=bn(),null!==e){for(t=[],l=ls,n=H(),null!==n?(r=In(),null!==r?n=[n,r]:(n=null,ls=l)):(n=null,ls=l);null!==n;)t.push(n),l=ls,n=H(),null!==n?(r=In(),null!==r?n=[n,r]:(n=null,ls=l)):(n=null,ls=l);null!==t?e=[e,t]:(e=null,ls=s)}else e=null,ls=s;return e}function bn(){var e;return"render"===n.substr(ls,6).toLowerCase()?(e=n.substr(ls,6),ls+=6):(e=null,0===is&&s('"render"')),null===e&&("session"===n.substr(ls,7).toLowerCase()?(e=n.substr(ls,7),ls+=7):(e=null,0===is&&s('"session"')),null===e&&("icon"===n.substr(ls,4).toLowerCase()?(e=n.substr(ls,4),ls+=4):(e=null,0===is&&s('"icon"')),null===e&&("alert"===n.substr(ls,5).toLowerCase()?(e=n.substr(ls,5),ls+=5):(e=null,0===is&&s('"alert"')),null===e&&(e=I())))),e}function In(){var e;return e=wn(),null===e&&(e=An()),e}function wn(){var e,t,r,l;return l=ls,"handling"===n.substr(ls,8).toLowerCase()?(e=n.substr(ls,8),ls+=8):(e=null,0===is&&s('"handling"')),null!==e?(t=x(),null!==t?("optional"===n.substr(ls,8).toLowerCase()?(r=n.substr(ls,8),ls+=8):(r=null,0===is&&s('"optional"')),null===r&&("required"===n.substr(ls,8).toLowerCase()?(r=n.substr(ls,8),ls+=8):(r=null,0===is&&s('"required"')),null===r&&(r=I())),null!==r?e=[e,t,r]:(e=null,ls=l)):(e=null,ls=l)):(e=null,ls=l),e}function Nn(){var e,t,n,r,s,l;if(s=ls,e=I(),null!==e){for(t=[],l=ls,n=k(),null!==n?(r=I(),null!==r?n=[n,r]:(n=null,ls=l)):(n=null,ls=l);null!==n;)t.push(n),l=ls,n=k(),null!==n?(r=I(),null!==r?n=[n,r]:(n=null,ls=l)):(n=null,ls=l);null!==t?e=[e,t]:(e=null,ls=s)}else e=null,ls=s;return e}function Dn(){var e,t,n;if(n=ls,t=i(),null!==t)for(e=[];null!==t;)e.push(t),t=i();else e=null;return null!==e&&(e=function(e,t){hs=parseInt(t.join(""))}(n,e)),null===e&&(ls=n),e}function Un(){var e,t;return t=ls,e=On(),null!==e&&(e=function(e){hs=n.substring(ls,e)}(t)),null===e&&(ls=t),e}function On(){var e,t,n,r,s,l,i,o;if(i=ls,e=xn(),null!==e)if(t=O(),null!==t)if(n=kn(),null!==n){for(r=[],o=ls,s=H(),null!==s?(l=Hn(),null!==l?s=[s,l]:(s=null,ls=o)):(s=null,ls=o);null!==s;)r.push(s),o=ls,s=H(),null!==s?(l=Hn(),null!==l?s=[s,l]:(s=null,ls=o)):(s=null,ls=o);null!==r?e=[e,t,n,r]:(e=null,ls=i)}else e=null,ls=i;else e=null,ls=i;else e=null,ls=i;return e}function xn(){var e;return e=Pn(),null===e&&(e=Mn()),e}function Pn(){var e;return"text"===n.substr(ls,4).toLowerCase()?(e=n.substr(ls,4),ls+=4):(e=null,0===is&&s('"text"')),null===e&&("image"===n.substr(ls,5).toLowerCase()?(e=n.substr(ls,5),ls+=5):(e=null,0===is&&s('"image"')),null===e&&("audio"===n.substr(ls,5).toLowerCase()?(e=n.substr(ls,5),ls+=5):(e=null,0===is&&s('"audio"')),null===e&&("video"===n.substr(ls,5).toLowerCase()?(e=n.substr(ls,5),ls+=5):(e=null,0===is&&s('"video"')),null===e&&("application"===n.substr(ls,11).toLowerCase()?(e=n.substr(ls,11),ls+=11):(e=null,0===is&&s('"application"')),null===e&&(e=Ln()))))),e}function Mn(){var e;return"message"===n.substr(ls,7).toLowerCase()?(e=n.substr(ls,7),ls+=7):(e=null,0===is&&s('"message"')),null===e&&("multipart"===n.substr(ls,9).toLowerCase()?(e=n.substr(ls,9),ls+=9):(e=null,0===is&&s('"multipart"')),null===e&&(e=Ln())),e}function Ln(){var e;return e=I(),null===e&&(e=qn()),e}function qn(){var e,t,r;return r=ls,"x-"===n.substr(ls,2).toLowerCase()?(e=n.substr(ls,2),ls+=2):(e=null,0===is&&s('"x-"')),null!==e?(t=I(),null!==t?e=[e,t]:(e=null,ls=r)):(e=null,ls=r),e}function kn(){var e;return e=Ln(),null===e&&(e=I()),e}function Hn(){var e,t,n,r;return r=ls,e=I(),null!==e?(t=x(),null!==t?(n=Fn(),null!==n?e=[e,t,n]:(e=null,ls=r)):(e=null,ls=r)):(e=null,ls=r),e}function Fn(){var e;return e=I(),null===e&&(e=z()),e}function Gn(){var e,t,n,r;return r=ls,e=jn(),null!==e?(t=v(),null!==t?(n=on(),null!==n?e=[e,t,n]:(e=null,ls=r)):(e=null,ls=r)):(e=null,ls=r),e}function jn(){var e,t,n;if(n=ls,t=i(),null!==t)for(e=[];null!==t;)e.push(t),t=i();else e=null;return null!==e&&(e=function(e,t){hs.value=parseInt(t.join(""))}(n,e)),null===e&&(ls=n),e}function Wn(){var e,t;return t=ls,e=Sn(),null!==e&&(e=function(e,t){hs=t}(t,e)),null===e&&(ls=t),e}function Bn(){var e,t,n,r,s,l,i;if(s=ls,l=ls,e=zn(),null!==e){for(t=[],i=ls,n=H(),null!==n?(r=An(),null!==r?n=[n,r]:(n=null,ls=i)):(n=null,ls=i);null!==n;)t.push(n),i=ls,n=H(),null!==n?(r=An(),null!==r?n=[n,r]:(n=null,ls=i)):(n=null,ls=i);null!==t?e=[e,t]:(e=null,ls=l)}else e=null,ls=l;return null!==e&&(e=function(e,t){hs.event=t.join("").toLowerCase()}(s,e[0])),null===e&&(ls=s),e}function zn(){var e,t,r,l,i,o;if(i=ls,e=w(),null!==e){for(t=[],o=ls,46===n.charCodeAt(ls)?(r=".",ls++):(r=null,0===is&&s('"."')),null!==r?(l=w(),null!==l?r=[r,l]:(r=null,ls=o)):(r=null,ls=o);null!==r;)t.push(r),o=ls,46===n.charCodeAt(ls)?(r=".",ls++):(r=null,0===is&&s('"."')),null!==r?(l=w(),null!==l?r=[r,l]:(r=null,ls=o)):(r=null,ls=o);null!==t?e=[e,t]:(e=null,ls=i)}else e=null,ls=i;return e}function Vn(){var e,t,n,r,s,l,i;if(s=ls,l=ls,e=J(),null===e&&(e=gn()),null!==e){for(t=[],i=ls,n=H(),null!==n?(r=Yn(),null!==r?n=[n,r]:(n=null,ls=i)):(n=null,ls=i);null!==n;)t.push(n),i=ls,n=H(),null!==n?(r=Yn(),null!==r?n=[n,r]:(n=null,ls=i)):(n=null,ls=i);null!==t?e=[e,t]:(e=null,ls=l)}else e=null,ls=l;return null!==e&&(e=function(){var e=hs.tag;try{hs=new cs(hs.uri,hs.display_name,hs.params),e&&hs.setParam("tag",e)}catch(t){hs=-1}}(s)),null===e&&(ls=s),e}function Yn(){var e;return e=Kn(),null===e&&(e=An()),e}function Kn(){var e,t,r,l,i;return l=ls,i=ls,"tag"===n.substr(ls,3).toLowerCase()?(e=n.substr(ls,3),ls+=3):(e=null,0===is&&s('"tag"')),null!==e?(t=x(),null!==t?(r=I(),null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(e,t){hs.tag=t}(l,e[2])),null===e&&(ls=l),e}function Jn(){var e,t,n;if(n=ls,t=i(),null!==t)for(e=[];null!==t;)e.push(t),t=i();else e=null;return null!==e&&(e=function(e,t){hs=parseInt(t.join(""))}(n,e)),null===e&&(ls=n),e}function Xn(){var e,t;return t=ls,e=Sn(),null!==e&&(e=function(e,t){hs=t}(t,e)),null===e&&(ls=t),e}function $n(){var e,t,n,r,s,l,i,o,u,a;for(o=ls,u=ls,e=[],t=Tn();null!==t;)e.push(t),t=Tn();if(null!==e)if(t=q(),null!==t)if(n=X(),null!==n)if(r=L(),null!==r){for(s=[],a=ls,l=H(),null!==l?(i=An(),null!==i?l=[l,i]:(l=null,ls=a)):(l=null,ls=a);null!==l;)s.push(l),a=ls,l=H(),null!==l?(i=An(),null!==i?l=[l,i]:(l=null,ls=a)):(l=null,ls=a);null!==s?e=[e,t,n,r,s]:(e=null,ls=u)}else e=null,ls=u;else e=null,ls=u;else e=null,ls=u;else e=null,ls=u;return null!==e&&(e=function(){try{hs=new cs(hs.uri,hs.display_name,hs.params)}catch(e){hs=-1}}(o)),null===e&&(ls=o),e}function Zn(){var e;return e=Qn()}function Qn(){var e,t,r,l,i,o,u,a;if(u=ls,"digest"===n.substr(ls,6).toLowerCase()?(e=n.substr(ls,6),ls+=6):(e=null,0===is&&s('"Digest"')),null!==e)if(t=v(),null!==t)if(r=nr(),null!==r){for(l=[],a=ls,i=k(),null!==i?(o=nr(),null!==o?i=[i,o]:(i=null,ls=a)):(i=null,ls=a);null!==i;)l.push(i),a=ls,i=k(),null!==i?(o=nr(),null!==o?i=[i,o]:(i=null,ls=a)):(i=null,ls=a);null!==l?e=[e,t,r,l]:(e=null,ls=u)}else e=null,ls=u;else e=null,ls=u;else e=null,ls=u;return null===e&&(e=er()),e}function er(){var e,t,n,r,s,l,i,o;if(i=ls,e=I(),null!==e)if(t=v(),null!==t)if(n=tr(),null!==n){for(r=[],o=ls,s=k(),null!==s?(l=tr(),null!==l?s=[s,l]:(s=null,ls=o)):(s=null,ls=o);null!==s;)r.push(s),o=ls,s=k(),null!==s?(l=tr(),null!==l?s=[s,l]:(s=null,ls=o)):(s=null,ls=o);null!==r?e=[e,t,n,r]:(e=null,ls=i)}else e=null,ls=i;else e=null,ls=i;else e=null,ls=i;return e}function tr(){var e,t,n,r;return r=ls,e=I(),null!==e?(t=x(),null!==t?(n=I(),null===n&&(n=z()),null!==n?e=[e,t,n]:(e=null,ls=r)):(e=null,ls=r)):(e=null,ls=r),e}function nr(){var e;return e=rr(),null===e&&(e=lr(),null===e&&(e=or(),null===e&&(e=ar(),null===e&&(e=cr(),null===e&&(e=hr(),null===e&&(e=dr(),null===e&&(e=tr()))))))),e}function rr(){var e,t,r,l;return l=ls,"realm"===n.substr(ls,5).toLowerCase()?(e=n.substr(ls,5),ls+=5):(e=null,0===is&&s('"realm"')),null!==e?(t=x(),null!==t?(r=sr(),null!==r?e=[e,t,r]:(e=null,ls=l)):(e=null,ls=l)):(e=null,ls=l),e}function sr(){var e,t;return t=ls,e=V(),null!==e&&(e=function(e,t){hs.realm=t}(t,e)),null===e&&(ls=t),e}function lr(){var e,t,r,l,i,o,u,a,c;if(a=ls,"domain"===n.substr(ls,6).toLowerCase()?(e=n.substr(ls,6),ls+=6):(e=null,0===is&&s('"domain"')),null!==e)if(t=x(),null!==t)if(r=G(),null!==r)if(l=ir(),null!==l){if(i=[],c=ls,u=d(),null!==u)for(o=[];null!==u;)o.push(u),u=d();else o=null;for(null!==o?(u=ir(),null!==u?o=[o,u]:(o=null,ls=c)):(o=null,ls=c);null!==o;){if(i.push(o),c=ls,u=d(),null!==u)for(o=[];null!==u;)o.push(u),u=d();else o=null;null!==o?(u=ir(),null!==u?o=[o,u]:(o=null,ls=c)):(o=null,ls=c)}null!==i?(o=j(),null!==o?e=[e,t,r,l,i,o]:(e=null,ls=a)):(e=null,ls=a)}else e=null,ls=a;else e=null,ls=a;else e=null,ls=a;else e=null,ls=a;return e}function ir(){var e;return e=Mt(),null===e&&(e=kt()),e}function or(){var e,t,r,l;return l=ls,"nonce"===n.substr(ls,5).toLowerCase()?(e=n.substr(ls,5),ls+=5):(e=null,0===is&&s('"nonce"')),null!==e?(t=x(),null!==t?(r=ur(),null!==r?e=[e,t,r]:(e=null,ls=l)):(e=null,ls=l)):(e=null,ls=l),e}function ur(){var e,t;return t=ls,e=V(),null!==e&&(e=function(e,t){hs.nonce=t}(t,e)),null===e&&(ls=t),e}function ar(){var e,t,r,l,i;return l=ls,i=ls,"opaque"===n.substr(ls,6).toLowerCase()?(e=n.substr(ls,6),ls+=6):(e=null,0===is&&s('"opaque"')),null!==e?(t=x(),null!==t?(r=V(),null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(e,t){hs.opaque=t}(l,e[2])),null===e&&(ls=l),e}function cr(){var e,t,r,l,i;return l=ls,"stale"===n.substr(ls,5).toLowerCase()?(e=n.substr(ls,5),ls+=5):(e=null,0===is&&s('"stale"')),null!==e?(t=x(),null!==t?(i=ls,"true"===n.substr(ls,4).toLowerCase()?(r=n.substr(ls,4),ls+=4):(r=null,0===is&&s('"true"')),null!==r&&(r=function(){hs.stale=!0}(i)),null===r&&(ls=i),null===r&&(i=ls,"false"===n.substr(ls,5).toLowerCase()?(r=n.substr(ls,5),ls+=5):(r=null,0===is&&s('"false"')),null!==r&&(r=function(){hs.stale=!1}(i)),null===r&&(ls=i)),null!==r?e=[e,t,r]:(e=null,ls=l)):(e=null,ls=l)):(e=null,ls=l),e}function hr(){var e,t,r,l,i;return l=ls,i=ls,"algorithm"===n.substr(ls,9).toLowerCase()?(e=n.substr(ls,9),ls+=9):(e=null,0===is&&s('"algorithm"')),null!==e?(t=x(),null!==t?("md5"===n.substr(ls,3).toLowerCase()?(r=n.substr(ls,3),ls+=3):(r=null,0===is&&s('"MD5"')),null===r&&("md5-sess"===n.substr(ls,8).toLowerCase()?(r=n.substr(ls,8),ls+=8):(r=null,0===is&&s('"MD5-sess"')),null===r&&(r=I())),null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(e,t){hs.algorithm=t.toUpperCase()}(l,e[2])),null===e&&(ls=l),e}function dr(){var e,t,r,l,i,o,u,a,c,h;if(a=ls,"qop"===n.substr(ls,3).toLowerCase()?(e=n.substr(ls,3),ls+=3):(e=null,0===is&&s('"qop"')),null!==e)if(t=x(),null!==t)if(r=G(),null!==r){if(c=ls,l=pr(),null!==l){for(i=[],h=ls,44===n.charCodeAt(ls)?(o=",",ls++):(o=null,0===is&&s('","')),null!==o?(u=pr(),null!==u?o=[o,u]:(o=null,ls=h)):(o=null,ls=h);null!==o;)i.push(o),h=ls,44===n.charCodeAt(ls)?(o=",",ls++):(o=null,0===is&&s('","')),null!==o?(u=pr(),null!==u?o=[o,u]:(o=null,ls=h)):(o=null,ls=h);null!==i?l=[l,i]:(l=null,ls=c)}else l=null,ls=c;null!==l?(i=j(),null!==i?e=[e,t,r,l,i]:(e=null,ls=a)):(e=null,ls=a)}else e=null,ls=a;else e=null,ls=a;else e=null,ls=a;return e}function pr(){var e,t;return t=ls,"auth-int"===n.substr(ls,8).toLowerCase()?(e=n.substr(ls,8),ls+=8):(e=null,0===is&&s('"auth-int"')),null===e&&("auth"===n.substr(ls,4).toLowerCase()?(e=n.substr(ls,4),ls+=4):(e=null,0===is&&s('"auth"')),null===e&&(e=I())),null!==e&&(e=function(e,t){hs.qop||(hs.qop=[]),hs.qop.push(t.toLowerCase())}(t,e)),null===e&&(ls=t),e}function fr(){var e,t,n,r,s,l;if(s=ls,e=I(),null!==e){for(t=[],l=ls,n=k(),null!==n?(r=I(),null!==r?n=[n,r]:(n=null,ls=l)):(n=null,ls=l);null!==n;)t.push(n),l=ls,n=k(),null!==n?(r=I(),null!==r?n=[n,r]:(n=null,ls=l)):(n=null,ls=l);null!==t?e=[e,t]:(e=null,ls=s)}else e=null,ls=s;return e}function mr(){var e,t,n,r,s,l,i;if(s=ls,l=ls,e=gr(),null!==e){for(t=[],i=ls,n=k(),null!==n?(r=gr(),null!==r?n=[n,r]:(n=null,ls=i)):(n=null,ls=i);null!==n;)t.push(n),i=ls,n=k(),null!==n?(r=gr(),null!==r?n=[n,r]:(n=null,ls=i)):(n=null,ls=i);null!==t?e=[e,t]:(e=null,ls=l)}else e=null,ls=l;return null!==e&&(e=function(){var e,t;for(t=hs.multi_header.length,e=0;t>e;e++)if(null===hs.multi_header[e].parsed){hs=null;break}hs=null!==hs?hs.multi_header:-1}(s)),null===e&&(ls=s),e}function gr(){var e,t,n,r,s,l,i;if(s=ls,l=ls,e=gn(),null!==e){for(t=[],i=ls,n=H(),null!==n?(r=An(),null!==r?n=[n,r]:(n=null,ls=i)):(n=null,ls=i);null!==n;)t.push(n),i=ls,n=H(),null!==n?(r=An(),null!==r?n=[n,r]:(n=null,ls=i)):(n=null,ls=i);null!==t?e=[e,t]:(e=null,ls=l)}else e=null,ls=l;return null!==e&&(e=function(e){var t;hs.multi_header||(hs.multi_header=[]);try{t=new cs(hs.uri,hs.display_name,hs.params),delete hs.uri,delete hs.display_name,delete hs.params}catch(n){t=null}hs.multi_header.push({possition:ls,offset:e,parsed:t})}(s)),null===e&&(ls=s),e}function Tr(){var e,t,n,r,s,l;if(s=ls,e=I(),null!==e){for(t=[],l=ls,n=k(),null!==n?(r=I(),null!==r?n=[n,r]:(n=null,ls=l)):(n=null,ls=l);null!==n;)t.push(n),l=ls,n=k(),null!==n?(r=I(),null!==r?n=[n,r]:(n=null,ls=l)):(n=null,ls=l);null!==t?e=[e,t]:(e=null,ls=s)}else e=null,ls=s;return e}function _r(){var e,t,n,r,s,l;if(s=ls,e=vr(),null!==e){for(t=[],l=ls,n=k(),null!==n?(r=vr(),null!==r?n=[n,r]:(n=null,ls=l)):(n=null,ls=l);null!==n;)t.push(n),l=ls,n=k(),null!==n?(r=vr(),null!==r?n=[n,r]:(n=null,ls=l)):(n=null,ls=l);null!==t?e=[e,t]:(e=null,ls=s)}else e=null,ls=s;return e}function vr(){var e,t,n,r,s,l;if(s=ls,e=gn(),null!==e){for(t=[],l=ls,n=H(),null!==n?(r=An(),null!==r?n=[n,r]:(n=null,ls=l)):(n=null,ls=l);null!==n;)t.push(n),l=ls,n=H(),null!==n?(r=An(),null!==r?n=[n,r]:(n=null,ls=l)):(n=null,ls=l);null!==t?e=[e,t]:(e=null,ls=s)}else e=null,ls=s;return e}function Cr(){var e,t,n,r,s,l;if(s=ls,e=Sr(),null!==e){for(t=[],l=ls,n=H(),null!==n?(r=Er(),null!==r?n=[n,r]:(n=null,ls=l)):(n=null,ls=l);null!==n;)t.push(n),l=ls,n=H(),null!==n?(r=Er(),null!==r?n=[n,r]:(n=null,ls=l)):(n=null,ls=l);null!==t?e=[e,t]:(e=null,ls=s)}else e=null,ls=s;return e}function Sr(){var e,t;return t=ls,"active"===n.substr(ls,6).toLowerCase()?(e=n.substr(ls,6),ls+=6):(e=null,0===is&&s('"active"')),null===e&&("pending"===n.substr(ls,7).toLowerCase()?(e=n.substr(ls,7),ls+=7):(e=null,0===is&&s('"pending"')),null===e&&("terminated"===n.substr(ls,10).toLowerCase()?(e=n.substr(ls,10),ls+=10):(e=null,0===is&&s('"terminated"')),null===e&&(e=I()))),null!==e&&(e=function(e){hs.state=n.substring(ls,e)}(t)),null===e&&(ls=t),e}function Er(){var e,t,r,l,i;return l=ls,i=ls,"reason"===n.substr(ls,6).toLowerCase()?(e=n.substr(ls,6),ls+=6):(e=null,0===is&&s('"reason"')),null!==e?(t=x(),null!==t?(r=Ar(),null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(e,t){"undefined"!=typeof t&&(hs.reason=t)}(l,e[2])),null===e&&(ls=l),null===e&&(l=ls,i=ls,"expires"===n.substr(ls,7).toLowerCase()?(e=n.substr(ls,7),ls+=7):(e=null,0===is&&s('"expires"')),null!==e?(t=x(),null!==t?(r=Sn(),null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(e,t){"undefined"!=typeof t&&(hs.expires=t)}(l,e[2])),null===e&&(ls=l),null===e&&(l=ls,i=ls,"retry_after"===n.substr(ls,11).toLowerCase()?(e=n.substr(ls,11),ls+=11):(e=null,0===is&&s('"retry_after"')),null!==e?(t=x(),null!==t?(r=Sn(),null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(e,t){"undefined"!=typeof t&&(hs.retry_after=t)}(l,e[2])),null===e&&(ls=l),null===e&&(e=An()))),e}function Ar(){var e;return"deactivated"===n.substr(ls,11).toLowerCase()?(e=n.substr(ls,11),ls+=11):(e=null,0===is&&s('"deactivated"')),null===e&&("probation"===n.substr(ls,9).toLowerCase()?(e=n.substr(ls,9),ls+=9):(e=null,0===is&&s('"probation"')),null===e&&("rejected"===n.substr(ls,8).toLowerCase()?(e=n.substr(ls,8),ls+=8):(e=null,0===is&&s('"rejected"')),null===e&&("timeout"===n.substr(ls,7).toLowerCase()?(e=n.substr(ls,7),ls+=7):(e=null,0===is&&s('"timeout"')),null===e&&("giveup"===n.substr(ls,6).toLowerCase()?(e=n.substr(ls,6),ls+=6):(e=null,0===is&&s('"giveup"')),null===e&&("noresource"===n.substr(ls,10).toLowerCase()?(e=n.substr(ls,10),ls+=10):(e=null,0===is&&s('"noresource"')),null===e&&("invariant"===n.substr(ls,9).toLowerCase()?(e=n.substr(ls,9),ls+=9):(e=null,0===is&&s('"invariant"')),null===e&&(e=I()))))))),e}function Rr(){var e;return e=E(),e=null!==e?e:""}function yr(){var e,t,n,r,s,l;if(s=ls,e=I(),null!==e){for(t=[],l=ls,n=k(),null!==n?(r=I(),null!==r?n=[n,r]:(n=null,ls=l)):(n=null,ls=l);null!==n;)t.push(n),l=ls,n=k(),null!==n?(r=I(),null!==r?n=[n,r]:(n=null,ls=l)):(n=null,ls=l);null!==t?e=[e,t]:(e=null,ls=s)}else e=null,ls=s;return e=null!==e?e:""}function br(){var e,t,n,r,s,l,i;if(s=ls,l=ls,e=J(),null===e&&(e=gn()),null!==e){for(t=[],i=ls,n=H(),null!==n?(r=Ir(),null!==r?n=[n,r]:(n=null,ls=i)):(n=null,ls=i);null!==n;)t.push(n),i=ls,n=H(),null!==n?(r=Ir(),null!==r?n=[n,r]:(n=null,ls=i)):(n=null,ls=i);null!==t?e=[e,t]:(e=null,ls=l)}else e=null,ls=l;return null!==e&&(e=function(){var e=hs.tag;try{hs=new cs(hs.uri,hs.display_name,hs.params),e&&hs.setParam("tag",e)}catch(t){hs=-1}}(s)),null===e&&(ls=s),e}function Ir(){var e;return e=Kn(),null===e&&(e=An()),e}function wr(){var e,t,n,r,s,l;if(s=ls,e=Nr(),null!==e){for(t=[],l=ls,n=k(),null!==n?(r=Nr(),null!==r?n=[n,r]:(n=null,ls=l)):(n=null,ls=l);null!==n;)t.push(n),l=ls,n=k(),null!==n?(r=Nr(),null!==r?n=[n,r]:(n=null,ls=l)):(n=null,ls=l);null!==t?e=[e,t]:(e=null,ls=s)}else e=null,ls=s;return e}function Nr(){var e,t,n,r,s,l,i,o;if(i=ls,e=Lr(),null!==e)if(t=v(),null!==t)if(n=Hr(),null!==n){for(r=[],o=ls,s=H(),null!==s?(l=Dr(),null!==l?s=[s,l]:(s=null,ls=o)):(s=null,ls=o);null!==s;)r.push(s),o=ls,s=H(),null!==s?(l=Dr(),null!==l?s=[s,l]:(s=null,ls=o)):(s=null,ls=o);null!==r?e=[e,t,n,r]:(e=null,ls=i)}else e=null,ls=i;else e=null,ls=i;else e=null,ls=i;return e}function Dr(){var e;return e=Ur(),null===e&&(e=Or(),null===e&&(e=xr(),null===e&&(e=Pr(),null===e&&(e=Mr(),null===e&&(e=An()))))),e}function Ur(){var e,t,r,l,i;return l=ls,i=ls,"ttl"===n.substr(ls,3).toLowerCase()?(e=n.substr(ls,3),ls+=3):(e=null,0===is&&s('"ttl"')),null!==e?(t=x(),null!==t?(r=jr(),null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(e,t){hs.ttl=t}(l,e[2])),null===e&&(ls=l),e}function Or(){var e,t,r,l,i;return l=ls,i=ls,"maddr"===n.substr(ls,5).toLowerCase()?(e=n.substr(ls,5),ls+=5):(e=null,0===is&&s('"maddr"')),null!==e?(t=x(),null!==t?(r=rt(),null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(e,t){hs.maddr=t}(l,e[2])),null===e&&(ls=l),e}function xr(){var e,t,r,l,i;return l=ls,i=ls,"received"===n.substr(ls,8).toLowerCase()?(e=n.substr(ls,8),ls+=8):(e=null,0===is&&s('"received"')),null!==e?(t=x(),null!==t?(r=ht(),null===r&&(r=ut()),null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(e,t){hs.received=t}(l,e[2])),null===e&&(ls=l),e}function Pr(){var e,t,r,l,i;return l=ls,i=ls,"branch"===n.substr(ls,6).toLowerCase()?(e=n.substr(ls,6),ls+=6):(e=null,0===is&&s('"branch"')),null!==e?(t=x(),null!==t?(r=I(),null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(e,t){hs.branch=t}(l,e[2])),null===e&&(ls=l),e}function Mr(){var e,t,r,l,o,u,a;if(o=ls,u=ls,"rport"===n.substr(ls,5).toLowerCase()?(e=n.substr(ls,5),ls+=5):(e=null,0===is&&s('"rport"')),null!==e){if(a=ls,t=x(),null!==t){for(r=[],l=i();null!==l;)r.push(l),l=i();null!==r?t=[t,r]:(t=null,ls=a)}else t=null,ls=a;t=null!==t?t:"",null!==t?e=[e,t]:(e=null,ls=u)}else e=null,ls=u;return null!==e&&(e=function(){"undefined"!=typeof response_port&&(hs.rport=response_port.join(""))}(o)),null===e&&(ls=o),e}function Lr(){var e,t,n,r,s,l;return l=ls,e=qr(),null!==e?(t=O(),null!==t?(n=I(),null!==n?(r=O(),null!==r?(s=kr(),null!==s?e=[e,t,n,r,s]:(e=null,ls=l)):(e=null,ls=l)):(e=null,ls=l)):(e=null,ls=l)):(e=null,ls=l),e}function qr(){var e,t;return t=ls,"sip"===n.substr(ls,3).toLowerCase()?(e=n.substr(ls,3),ls+=3):(e=null,0===is&&s('"SIP"')),null===e&&(e=I()),null!==e&&(e=function(e,t){hs.protocol=t}(t,e)),null===e&&(ls=t),e}function kr(){var e,t;return t=ls,"udp"===n.substr(ls,3).toLowerCase()?(e=n.substr(ls,3),ls+=3):(e=null,0===is&&s('"UDP"')),null===e&&("tcp"===n.substr(ls,3).toLowerCase()?(e=n.substr(ls,3),ls+=3):(e=null,0===is&&s('"TCP"')),null===e&&("tls"===n.substr(ls,3).toLowerCase()?(e=n.substr(ls,3),ls+=3):(e=null,0===is&&s('"TLS"')),null===e&&("sctp"===n.substr(ls,4).toLowerCase()?(e=n.substr(ls,4),ls+=4):(e=null,0===is&&s('"SCTP"')),null===e&&(e=I())))),null!==e&&(e=function(e,t){hs.transport=t}(t,e)),null===e&&(ls=t),e}function Hr(){var e,t,n,r,s;return r=ls,e=Fr(),null!==e?(s=ls,t=F(),null!==t?(n=Gr(),null!==n?t=[t,n]:(t=null,ls=s)):(t=null,ls=s),t=null!==t?t:"",null!==t?e=[e,t]:(e=null,ls=r)):(e=null,ls=r),e}function Fr(){var e,t;return t=ls,e=ht(),null===e&&(e=ot(),null===e&&(e=st())),null!==e&&(e=function(e){hs.host=n.substring(ls,e)}(t)),null===e&&(ls=t),e}function Gr(){var e,t,n,r,s,l,o;return l=ls,o=ls,e=i(),e=null!==e?e:"",null!==e?(t=i(),t=null!==t?t:"",null!==t?(n=i(),n=null!==n?n:"",null!==n?(r=i(),r=null!==r?r:"",null!==r?(s=i(),s=null!==s?s:"",null!==s?e=[e,t,n,r,s]:(e=null,ls=o)):(e=null,ls=o)):(e=null,ls=o)):(e=null,ls=o)):(e=null,ls=o),null!==e&&(e=function(e,t){hs.port=parseInt(t.join(""))}(l,e)),null===e&&(ls=l),e}function jr(){var e,t,n,r,s;return r=ls,s=ls,e=i(),null!==e?(t=i(),t=null!==t?t:"",null!==t?(n=i(),n=null!==n?n:"",null!==n?e=[e,t,n]:(e=null,ls=s)):(e=null,ls=s)):(e=null,ls=s),null!==e&&(e=function(e,t){return parseInt(t.join(""))}(r,e)),null===e&&(ls=r),e}function Wr(){var e;return e=Qn()}function Br(){var e,t,n,r,s,l;if(s=ls,e=zr(),null!==e){for(t=[],l=ls,n=H(),null!==n?(r=Vr(),null!==r?n=[n,r]:(n=null,ls=l)):(n=null,ls=l);null!==n;)t.push(n),l=ls,n=H(),null!==n?(r=Vr(),null!==r?n=[n,r]:(n=null,ls=l)):(n=null,ls=l);null!==t?e=[e,t]:(e=null,ls=s)}else e=null,ls=s;return e}function zr(){var e,t;return t=ls,e=Sn(),null!==e&&(e=function(e,t){hs.expires=t}(t,e)),null===e&&(ls=t),e}function Vr(){var e;return e=Yr(),null===e&&(e=An()),e}function Yr(){var e,t,r,l,i;return l=ls,i=ls,"refresher"===n.substr(ls,9).toLowerCase()?(e=n.substr(ls,9),ls+=9):(e=null,0===is&&s('"refresher"')),null!==e?(t=x(),null!==t?("uac"===n.substr(ls,3).toLowerCase()?(r=n.substr(ls,3),ls+=3):(r=null,0===is&&s('"uac"')),null===r&&("uas"===n.substr(ls,3).toLowerCase()?(r=n.substr(ls,3),ls+=3):(r=null,0===is&&s('"uas"'))),null!==r?e=[e,t,r]:(e=null,ls=i)):(e=null,ls=i)):(e=null,ls=i),null!==e&&(e=function(e,t){hs.refresher=t.toLowerCase()}(l,e[2])),null===e&&(ls=l),e}function Kr(){var e,t,n,r;return r=ls,e=I(),null!==e?(t=S(),null!==t?(n=Jr(),null!==n?e=[e,t,n]:(e=null,ls=r)):(e=null,ls=r)):(e=null,ls=r),e}function Jr(){var e,t;for(e=[],t=A(),null===t&&(t=y(),null===t&&(t=v()));null!==t;)e.push(t),t=A(),null===t&&(t=y(),null===t&&(t=v()));return e}function Xr(){var e,t;for(e=[],t=c();null!==t;)e.push(t),t=c();return e}function $r(){var e,t,r;return r=ls,"uuid:"===n.substr(ls,5)?(e="uuid:",ls+=5):(e=null,0===is&&s('"uuid:"')),null!==e?(t=Zr(),null!==t?e=[e,t]:(e=null,ls=r)):(e=null,ls=r),e}function Zr(){var e,t,r,l,i,o,u,a,c,h,d;return h=ls,d=ls,e=es(),null!==e?(45===n.charCodeAt(ls)?(t="-",ls++):(t=null,0===is&&s('"-"')),null!==t?(r=Qr(),null!==r?(45===n.charCodeAt(ls)?(l="-",ls++):(l=null,0===is&&s('"-"')),null!==l?(i=Qr(),null!==i?(45===n.charCodeAt(ls)?(o="-",ls++):(o=null,0===is&&s('"-"')),null!==o?(u=Qr(),null!==u?(45===n.charCodeAt(ls)?(a="-",ls++):(a=null,0===is&&s('"-"')),null!==a?(c=ts(),null!==c?e=[e,t,r,l,i,o,u,a,c]:(e=null,ls=d)):(e=null,ls=d)):(e=null,ls=d)):(e=null,ls=d)):(e=null,ls=d)):(e=null,ls=d)):(e=null,ls=d)):(e=null,ls=d)):(e=null,ls=d),null!==e&&(e=function(e){hs=n.substring(ls+5,e)}(h,e[0])),null===e&&(ls=h),e}function Qr(){var e,t,n,r,s;return s=ls,e=u(),null!==e?(t=u(),null!==t?(n=u(),null!==n?(r=u(),null!==r?e=[e,t,n,r]:(e=null,ls=s)):(e=null,ls=s)):(e=null,ls=s)):(e=null,ls=s),e}function es(){var e,t,n;return n=ls,e=Qr(),null!==e?(t=Qr(),null!==t?e=[e,t]:(e=null,ls=n)):(e=null,ls=n),e}function ts(){var e,t,n,r;return r=ls,e=Qr(),null!==e?(t=Qr(),null!==t?(n=Qr(),null!==n?e=[e,t,n]:(e=null,ls=r)):(e=null,ls=r)):(e=null,ls=r),e}function ns(e){e.sort();for(var t=null,n=[],r=0;r<e.length;r++)e[r]!==t&&(n.push(e[r]),t=e[r]);return n}function rs(){for(var e=1,t=1,r=!1,s=0;s<Math.max(ls,os);s++){var l=n.charAt(s);"\n"===l?(r||e++,t=1,r=!1):"\r"===l||"\u2028"===l||"\u2029"===l?(e++,t=1,r=!0):(t++,r=!1)}return{line:e,column:t}}var ss={CRLF:l,DIGIT:i,ALPHA:o,HEXDIG:u,WSP:a,OCTET:c,DQUOTE:h,SP:d,HTAB:p,alphanum:f,reserved:m,unreserved:g,mark:T,escaped:_,LWS:v,SWS:C,HCOLON:S,TEXT_UTF8_TRIM:E,TEXT_UTF8char:A,UTF8_NONASCII:R,UTF8_CONT:y,LHEX:b,token:I,token_nodot:w,separators:N,word:D,STAR:U,SLASH:O,EQUAL:x,LPAREN:P,RPAREN:M,RAQUOT:L,LAQUOT:q,COMMA:k,SEMI:H,COLON:F,LDQUOT:G,RDQUOT:j,comment:W,ctext:B,quoted_string:z,quoted_string_clean:V,qdtext:Y,quoted_pair:K,SIP_URI_noparams:J,SIP_URI:X,uri_scheme:$,userinfo:Z,user:Q,user_unreserved:et,password:tt,hostport:nt,host:rt,hostname:st,domainlabel:lt,toplabel:it,IPv6reference:ot,IPv6address:ut,h16:at,ls32:ct,IPv4address:ht,dec_octet:dt,port:pt,uri_parameters:ft,uri_parameter:mt,transport_param:gt,user_param:Tt,method_param:_t,ttl_param:vt,maddr_param:Ct,lr_param:St,other_param:Et,pname:At,pvalue:Rt,paramchar:yt,param_unreserved:bt,headers:It,header:wt,hname:Nt,hvalue:Dt,hnv_unreserved:Ut,Request_Response:Ot,Request_Line:xt,Request_URI:Pt,absoluteURI:Mt,hier_part:Lt,net_path:qt,abs_path:kt,opaque_part:Ht,uric:Ft,uric_no_slash:Gt,path_segments:jt,segment:Wt,param:Bt,pchar:zt,scheme:Vt,authority:Yt,srvr:Kt,reg_name:Jt,query:Xt,SIP_Version:$t,INVITEm:Zt,ACKm:Qt,OPTIONSm:en,BYEm:tn,CANCELm:nn,REGISTERm:rn,SUBSCRIBEm:sn,NOTIFYm:ln,Method:on,Status_Line:un,Status_Code:an,extension_code:cn,Reason_Phrase:hn,Allow_Events:dn,Call_ID:pn,Contact:fn,contact_param:mn,name_addr:gn,display_name:Tn,contact_params:_n,c_p_q:vn,c_p_expires:Cn,delta_seconds:Sn,qvalue:En,generic_param:An,gen_value:Rn,Content_Disposition:yn,disp_type:bn,disp_param:In,handling_param:wn,Content_Encoding:Nn,Content_Length:Dn,Content_Type:Un,media_type:On,m_type:xn,discrete_type:Pn,composite_type:Mn,extension_token:Ln,x_token:qn,m_subtype:kn,m_parameter:Hn,m_value:Fn,CSeq:Gn,CSeq_value:jn,Expires:Wn,Event:Bn,event_type:zn,From:Vn,from_param:Yn,tag_param:Kn,Max_Forwards:Jn,Min_Expires:Xn,Name_Addr_Header:$n,Proxy_Authenticate:Zn,challenge:Qn,other_challenge:er,auth_param:tr,digest_cln:nr,realm:rr,realm_value:sr,domain:lr,URI:ir,nonce:or,nonce_value:ur,opaque:ar,stale:cr,algorithm:hr,qop_options:dr,qop_value:pr,Proxy_Require:fr,Record_Route:mr,rec_route:gr,Require:Tr,Route:_r,route_param:vr,Subscription_State:Cr,substate_value:Sr,subexp_params:Er,event_reason_value:Ar,Subject:Rr,Supported:yr,To:br,to_param:Ir,Via:wr,via_param:Nr,via_params:Dr,via_ttl:Ur,via_maddr:Or,via_received:xr,via_branch:Pr,response_port:Mr,sent_protocol:Lr,protocol_name:qr,transport:kr,sent_by:Hr,via_host:Fr,via_port:Gr,ttl:jr,WWW_Authenticate:Wr,Session_Expires:Br,s_e_expires:zr,s_e_params:Vr,s_e_refresher:Yr,extension_header:Kr,header_value:Jr,message_body:Xr,uuid_URI:$r,uuid:Zr,hex4:Qr,hex8:es,hex12:ts};if(void 0!==r){if(void 0===ss[r])throw new Error("Invalid rule name: "+t(r)+".")}else r="CRLF";var ls=0,is=0,os=0,us=[],as=e("./URI"),cs=e("./NameAddrHeader"),hs={},ds=ss[r]();if(null===ds||ls!==n.length){var ps=Math.max(ls,os),fs=ps<n.length?n.charAt(ps):null,ms=rs();return new this.SyntaxError(ns(us),fs,ps,ms.line,ms.column),-1}return hs},toSource:function(){return this._source}};return n.SyntaxError=function(e,n,r,s,l){function i(e,n){var r,s;switch(e.length){case 0:r="end of input";break;case 1:r=e[0];break;default:r=e.slice(0,e.length-1).join(", ")+" or "+e[e.length-1]}return s=n?t(n):"end of input","Expected "+r+" but "+s+" found."}this.name="SyntaxError",this.expected=e,this.found=n,this.message=i(e,n),this.offset=r,this.line=s,this.column=l},n.SyntaxError.prototype=Error.prototype,n}()},{"./NameAddrHeader":9,"./URI":21}],7:[function(e,t){var n=e("debug")("JsSIP"),r=e("../package.json");n("version %s",r.version);var s=e("rtcninja"),l=e("./Constants"),i=e("./Exceptions"),o=e("./Utils"),u=e("./UA"),a=e("./URI"),c=e("./NameAddrHeader"),h=e("./Grammar"),d=t.exports={C:l,Exceptions:i,Utils:o,UA:u,URI:a,NameAddrHeader:c,Grammar:h,debug:e("debug"),rtcninja:s};Object.defineProperties(d,{name:{get:function(){return r.title}},version:{get:function(){return r.version}}}),d.rtcninja.called||d.rtcninja()},{"../package.json":46,"./Constants":1,"./Exceptions":5,"./Grammar":6,"./NameAddrHeader":9,"./UA":20,"./URI":21,"./Utils":22,debug:29,rtcninja:34}],8:[function(e,t){function n(e){this.ua=e,this.data={},s.EventEmitter.call(this)}t.exports=n;var r=e("util"),s=e("events"),l=e("./Constants"),i=e("./SIPMessage"),o=e("./Utils"),u=e("./RequestSender"),a=e("./Transactions"),c=e("./Exceptions");r.inherits(n,s.EventEmitter),n.prototype.send=function(e,t,n){var r,s,o,a,c,h=e;if(void 0===e||void 0===t)throw new TypeError("Not enough arguments");if(e=this.ua.normalizeTarget(e),!e)throw new TypeError("Invalid target: "+h);n=n||{},c=n.extraHeaders&&n.extraHeaders.slice()||[],a=n.eventHandlers||{},o=n.contentType||"text/plain",this.content_type=o;for(s in a)this.on(s,a[s]);this.closed=!1,this.ua.applicants[this]=this,c.push("Content-Type: "+o),this.request=new i.OutgoingRequest(l.MESSAGE,e,this.ua,null,c),t?(this.request.body=t,this.content=t):this.content=null,r=new u(this,this.ua),this.newMessage("local",this.request),r.send()},n.prototype.receiveResponse=function(e){var t;if(!this.closed)switch(!0){case/^1[0-9]{2}$/.test(e.status_code):break;case/^2[0-9]{2}$/.test(e.status_code):delete this.ua.applicants[this],this.emit("succeeded",{originator:"remote",response:e});break;default:delete this.ua.applicants[this],t=o.sipErrorCause(e.status_code),this.emit("failed",{originator:"remote",response:e,cause:t})}},n.prototype.onRequestTimeout=function(){this.closed||this.emit("failed",{originator:"system",cause:l.causes.REQUEST_TIMEOUT})},n.prototype.onTransportError=function(){this.closed||this.emit("failed",{originator:"system",cause:l.causes.CONNECTION_ERROR})},n.prototype.close=function(){this.closed=!0,delete this.ua.applicants[this]
  },n.prototype.init_incoming=function(e){var t;this.request=e,this.content_type=e.getHeader("Content-Type"),this.content=e.body?e.body:null,this.newMessage("remote",e),t=this.ua.transactions.nist[e.via_branch],!t||t.state!==a.C.STATUS_TRYING&&t.state!==a.C.STATUS_PROCEEDING||e.reply(200)},n.prototype.accept=function(e){e=e||{};var t=e.extraHeaders&&e.extraHeaders.slice()||[],n=e.body;if("incoming"!==this.direction)throw new c.NotSupportedError('"accept" not supported for outgoing Message');this.request.reply(200,null,t,n)},n.prototype.reject=function(e){e=e||{};var t=e.status_code||480,n=e.reason_phrase,r=e.extraHeaders&&e.extraHeaders.slice()||[],s=e.body;if("incoming"!==this.direction)throw new c.NotSupportedError('"reject" not supported for outgoing Message');if(300>t||t>=700)throw new TypeError("Invalid status_code: "+t);this.request.reply(t,n,r,s)},n.prototype.newMessage=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({originator:e,message:this,request:t})}},{"./Constants":1,"./Exceptions":5,"./RequestSender":15,"./SIPMessage":16,"./Transactions":18,"./Utils":22,events:24,util:28}],9:[function(e,t){function n(e,t,n){var s;if(!(e&&e instanceof r))throw new TypeError('missing or invalid "uri" parameter');this.uri=e,this.parameters={};for(s in n)this.setParam(s,n[s]);Object.defineProperties(this,{display_name:{get:function(){return t},set:function(e){t=0===e?"0":e}}})}t.exports=n;var r=e("./URI"),s=e("./Grammar");n.prototype={setParam:function(e,t){e&&(this.parameters[e.toLowerCase()]="undefined"==typeof t||null===t?null:t.toString())},getParam:function(e){return e?this.parameters[e.toLowerCase()]:void 0},hasParam:function(e){return e?this.parameters.hasOwnProperty(e.toLowerCase())&&!0||!1:void 0},deleteParam:function(e){var t;return e=e.toLowerCase(),this.parameters.hasOwnProperty(e)?(t=this.parameters[e],delete this.parameters[e],t):void 0},clearParams:function(){this.parameters={}},clone:function(){return new n(this.uri.clone(),this.display_name,JSON.parse(JSON.stringify(this.parameters)))},toString:function(){var e,t;e=this.display_name||0===this.display_name?'"'+this.display_name+'" ':"",e+="<"+this.uri.toString()+">";for(t in this.parameters)e+=";"+t,null!==this.parameters[t]&&(e+="="+this.parameters[t]);return e}},n.parse=function(e){return e=s.parse(e,"Name_Addr_Header"),-1!==e?e:void 0}},{"./Grammar":6,"./URI":21}],10:[function(e,t){function n(e,t){var n=t,r=0,s=0;if(e.substring(n,n+2).match(/(^\r\n)/))return-2;for(;0===r;){if(s=e.indexOf("\r\n",n),-1===s)return s;!e.substring(s+2,s+4).match(/(^\r\n)/)&&e.charAt(s+2).match(/(^\s+)/)?n=s+2:r=s}return r}function r(e,t,n,r){var s,l,i,a,c=t.indexOf(":",n),h=t.substring(n,c).trim(),d=t.substring(c+1,r).trim();switch(h.toLowerCase()){case"via":case"v":e.addHeader("via",d),1===e.getHeaders("via").length?(a=e.parseHeader("Via"),a&&(e.via=a,e.via_branch=a.branch)):a=0;break;case"from":case"f":e.setHeader("from",d),a=e.parseHeader("from"),a&&(e.from=a,e.from_tag=a.getParam("tag"));break;case"to":case"t":e.setHeader("to",d),a=e.parseHeader("to"),a&&(e.to=a,e.to_tag=a.getParam("tag"));break;case"record-route":for(a=o.parse(d,"Record_Route"),-1===a&&(a=void 0),i=a.length,l=0;i>l;l++)s=a[l],e.addHeader("record-route",d.substring(s.possition,s.offset)),e.headers["Record-Route"][e.getHeaders("record-route").length-1].parsed=s.parsed;break;case"call-id":case"i":e.setHeader("call-id",d),a=e.parseHeader("call-id"),a&&(e.call_id=d);break;case"contact":case"m":for(a=o.parse(d,"Contact"),-1===a&&(a=void 0),i=a.length,l=0;i>l;l++)s=a[l],e.addHeader("contact",d.substring(s.possition,s.offset)),e.headers.Contact[e.getHeaders("contact").length-1].parsed=s.parsed;break;case"content-length":case"l":e.setHeader("content-length",d),a=e.parseHeader("content-length");break;case"content-type":case"c":e.setHeader("content-type",d),a=e.parseHeader("content-type");break;case"cseq":e.setHeader("cseq",d),a=e.parseHeader("cseq"),a&&(e.cseq=a.value),e instanceof u.IncomingResponse&&(e.method=a.method);break;case"max-forwards":e.setHeader("max-forwards",d),a=e.parseHeader("max-forwards");break;case"www-authenticate":e.setHeader("www-authenticate",d),a=e.parseHeader("www-authenticate");break;case"proxy-authenticate":e.setHeader("proxy-authenticate",d),a=e.parseHeader("proxy-authenticate");break;case"session-expires":case"x":e.setHeader("session-expires",d),a=e.parseHeader("session-expires"),a&&(e.session_expires=a.expires,e.session_expires_refresher=a.refresher);break;default:e.setHeader(h,d),a=0}return void 0===a?{error:'error parsing header "'+h+'"'}:!0}var s={};t.exports=s;var l=e("debug")("JsSIP:ERROR:Parser");l.log=console.warn.bind(console);var i=e("sdp-transform"),o=e("./Grammar"),u=e("./SIPMessage");s.parseMessage=function(e,t){var s,i,a,c,h,d=0,p=e.indexOf("\r\n");if(-1===p)return void l("parseMessage() | no CRLF found, not a SIP message");if(i=e.substring(0,p),h=o.parse(i,"Request_Response"),-1===h)return void l('parseMessage() | error parsing first line of SIP message: "'+i+'"');for(h.status_code?(s=new u.IncomingResponse,s.status_code=h.status_code,s.reason_phrase=h.reason_phrase):(s=new u.IncomingRequest(t),s.method=h.method,s.ruri=h.uri),s.data=e,d=p+2;;){if(p=n(e,d),-2===p){c=d+2;break}if(-1===p)return void h.error("parseMessage() | malformed message");if(h=r(s,e,d,p),h!==!0)return void l("parseMessage() |",h.error);d=p+2}return s.hasHeader("content-length")?(a=s.getHeader("content-length"),s.body=e.substr(c,a)):s.body=e.substring(c),s},s.parseSDP=i.parse,s.writeSDP=i.write,s.parseFmtpConfig=i.parseFmtpConfig,s.parsePayloads=i.parsePayloads,s.parseRemoteCandidates=i.parseRemoteCandidates},{"./Grammar":6,"./SIPMessage":16,debug:29,"sdp-transform":40}],11:[function(e,t){function n(e){L("new"),this.ua=e,this.status=x.STATUS_NULL,this.dialog=null,this.earlyDialogs={},this.connection=null,this.is_confirmed=!1,this.late_sdp=!1,this.rtcOfferConstraints=null,this.renegotiateOptions={},this.localMediaStream=null,this.localMediaStreamLocallyGenerated=!1,this.rtcReady=!0,this.timers={ackTimer:null,expiresTimer:null,invite2xxTimer:null,userNoAnswerTimer:null},this.direction=null,this.local_identity=null,this.remote_identity=null,this.start_time=null,this.end_time=null,this.tones=null,this.audioMuted=!1,this.videoMuted=!1,this.local_hold=!1,this.remote_hold=!1,this.sessionTimers={enabled:this.ua.configuration.session_timers,defaultExpires:H.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this.pending_actions={actions:[],length:function(){return this.actions.length},isPending:function(e){var t=0,n=this.actions.length;for(t;n>t;t++)if(this.actions[t].name===e)return!0;return!1},shift:function(){return this.actions.shift()},push:function(e){this.actions.push({name:e})},pop:function(e){var t=0,n=this.actions.length;for(t;n>t;t++)this.actions[t].name===e&&this.actions.splice(t,1)}},this.data={},M.EventEmitter.call(this)}function r(e,t){var n=this,r=B.T1;this.timers.invite2xxTimer=setTimeout(function s(){n.status===x.STATUS_WAITING_FOR_ACK&&(e.reply(200,null,["Contact: "+n.contact],t),r<B.T2&&(r=2*r,r>B.T2&&(r=B.T2)),n.timers.invite2xxTimer=setTimeout(s,r))},r)}function s(){var e=this;this.timers.ackTimer=setTimeout(function(){e.status===x.STATUS_WAITING_FOR_ACK&&(L("no ACK received, terminating the session"),clearTimeout(e.timers.invite2xxTimer),g.call(e,H.BYE),I.call(e,"remote",null,H.causes.NO_ACK))},B.TIMER_H)}function l(e,t){var n=this;this.connection=new k.Connection(e,t),this.connection.onaddstream=function(e,t){n.emit("addstream",{stream:t})},this.connection.onremovestream=function(e,t){n.emit("removestream",{stream:t})},this.connection.oniceconnectionstatechange=function(e,t){"failed"===t&&n.terminate({cause:H.causes.RTP_TIMEOUT,status_code:200,reason_phrase:H.causes.RTP_TIMEOUT})}}function i(e,t,n,r){function s(e){i.onicecandidate=function(e,n){n||(i.onicecandidate=null,l.rtcReady=!0,t(i.localDescription.sdp),t=null)},i.setLocalDescription(e,function(){"complete"===i.iceGatheringState&&(l.rtcReady=!0,t&&(t(i.localDescription.sdp),t=null))},function(e){l.rtcReady=!0,n&&n(e)})}L("createLocalDescription()");var l=this,i=this.connection;if(this.rtcReady=!1,"offer"===e)i.createOffer(s,function(e){l.rtcReady=!0,n(e)},r);else{if("answer"!==e)throw new Error('createLocalDescription() | type must be "offer" or "answer", but "'+e+'" was given');i.createAnswer(s,function(e){l.rtcReady=!0,n(e)},r)}}function o(){return this.rtcReady?this.dialog.uac_pending_reply===!0||this.dialog.uas_pending_reply===!0?(L("isReadyToReinvite() | no, there is another INVITE transaction in progress"),!1):!0:(L("isReadyToReinvite() | no, rtcReady is false"),!1)}function u(e,t,n){var r,s,l="UAS"===t?e.to_tag:e.from_tag,i="UAS"===t?e.from_tag:e.to_tag,o=e.call_id+l+i;return s=this.earlyDialogs[o],n?s?!0:(s=new V(this,e,t,V.C.STATUS_EARLY),s.error?(L(r.error),w.call(this,"remote",e,H.causes.INTERNAL_ERROR),!1):(this.earlyDialogs[o]=s,!0)):s?(s.update(e,t),this.dialog=s,delete this.earlyDialogs[o],!0):(r=new V(this,e,t),r.error?(L(r.error),w.call(this,"remote",e,H.causes.INTERNAL_ERROR),!1):(this.dialog=r,!0))}function a(e){function t(){n(function(t){var n=["Contact: "+a.contact];T.call(a,e,n),e.reply(200,null,n,t,function(){a.status=x.STATUS_WAITING_FOR_ACK,r.call(a,e,t),s.call(a),a.remote_hold===!0&&h===!1?D.call(a,"remote"):a.remote_hold===!1&&h===!0&&N.call(a,"remote")})},function(){e.reply(500)})}function n(e,t){a.late_sdp?i.call(a,"offer",e,t,a.rtcOfferConstraints):i.call(a,"answer",e,t)}L("receiveReinvite()");var l,o,u,a=this,c=e.getHeader("Content-Type"),h=!1;if(e.body){if(this.late_sdp=!1,"application/sdp"!==c)return L("invalid Content-Type"),void e.reply(415);for(l=j.parseSDP(e.body),o=0;o<l.media.length;o++){if(u=l.media[o].direction||l.direction||"sendrecv","sendonly"!==u&&"inactive"!==u){h=!1;break}h=!0}this.connection.setRemoteDescription(new k.RTCSessionDescription({type:"offer",sdp:e.body}),t,function(){e.reply(488)})}else this.late_sdp=!0,t()}function c(e){L("receiveUpdate()");var t,n,r,s=this,l=e.getHeader("Content-Type"),o=!1;if(!e.body){var u=[];return T.call(this,e,u),void e.reply(200,null,u)}if("application/sdp"!==l)return L("invalid Content-Type"),void e.reply(415);for(t=j.parseSDP(e.body),n=0;n<t.media.length;n++){if(r=t.media[n].direction||t.direction||"sendrecv","sendonly"!==r&&"inactive"!==r){o=!1;break}o=!0}this.connection.setRemoteDescription(new k.RTCSessionDescription({type:"offer",sdp:e.body}),function(){i.call(s,"answer",function(t){var n=["Contact: "+s.contact];T.call(s,e,n),e.reply(200,null,n,t,function(){s.remote_hold===!0&&o===!1?D.call(s,"remote"):s.remote_hold===!1&&o===!0&&N.call(s,"remote")})},function(){e.reply(500)})},function(){e.reply(488)})}function h(e,t,n){function r(e){u.status!==x.STATUS_TERMINATED&&(u.localMediaStream=e,u.connection.addStream(e),A.call(u,u.request),i.call(u,"offer",l,o,t))}function s(){u.status!==x.STATUS_TERMINATED&&w.call(u,"local",null,H.causes.USER_DENIED_MEDIA_ACCESS)}function l(e){u.isCanceled||u.status===x.STATUS_TERMINATED||(u.request.body=e,u.status=x.STATUS_INVITE_SENT,a.send())}function o(){u.status!==x.STATUS_TERMINATED&&w.call(u,"system",null,H.causes.WEBRTC_ERROR)}var u=this,a=new Y(u,this.ua);this.receiveResponse=function(e){d.call(u,e)},n?r(n):(this.localMediaStreamLocallyGenerated=!0,k.getUserMedia(e,r,s))}function d(e){L("receiveInviteResponse()");var t,n,r=this;if(this.dialog&&e.status_code>=200&&e.status_code<=299)return this.dialog.id.call_id===e.call_id&&this.dialog.id.local_tag===e.from_tag&&this.dialog.id.remote_tag===e.to_tag?void g.call(this,H.ACK):(n=new V(this,e,"UAC"),void 0!==n.error?void L(n.error):(n.sendRequest({owner:{status:x.STATUS_TERMINATED},onRequestTimeout:function(){},onTransportError:function(){},onDialogError:function(){},receiveResponse:function(){}},H.ACK),void n.sendRequest({owner:{status:x.STATUS_TERMINATED},onRequestTimeout:function(){},onTransportError:function(){},onDialogError:function(){},receiveResponse:function(){}},H.BYE)));if(this.isCanceled)return this.isCanceled=!1,void(e.status_code>=100&&e.status_code<200?this.request.cancel(this.cancelReason):e.status_code>=200&&e.status_code<299&&m.call(this,e));if(this.status===x.STATUS_INVITE_SENT||this.status===x.STATUS_1XX_RECEIVED)switch(!0){case/^100$/.test(e.status_code):this.status=x.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(e.status_code):if(!e.to_tag){L("1xx response received without to tag");break}if(e.hasHeader("contact")&&!u.call(this,e,"UAC",!0))break;if(this.status=x.STATUS_1XX_RECEIVED,R.call(this,"remote",e),!e.body)break;this.connection.setRemoteDescription(new k.RTCSessionDescription({type:"pranswer",sdp:e.body}),null,function(){r.earlyDialogs[e.call_id+e.from_tag+e.to_tag].terminate()});break;case/^2[0-9]{2}$/.test(e.status_code):if(this.status=x.STATUS_CONFIRMED,!e.body){m.call(this,e,400,H.causes.MISSING_SDP),w.call(this,"remote",e,H.causes.BAD_MEDIA_DESCRIPTION);break}if(!u.call(this,e,"UAC"))break;this.connection.setRemoteDescription(new k.RTCSessionDescription({type:"answer",sdp:e.body}),function(){y.call(r,"remote",e),g.call(r,H.ACK),b.call(r,"local",null),_.call(r,e)},function(){m.call(r,e,488,"Not Acceptable Here"),w.call(r,"remote",e,H.causes.BAD_MEDIA_DESCRIPTION)});break;default:t=W.sipErrorCause(e.status_code),w.call(this,"remote",e,t)}}function p(e){function t(e){return r.status!==x.STATUS_TERMINATED?(g.call(r,H.ACK),_.call(r,e),e.body?"application/sdp"!==e.getHeader("Content-Type")?void n():void r.connection.setRemoteDescription(new k.RTCSessionDescription({type:"answer",sdp:e.body}),function(){l.succeeded&&l.succeeded(e)},function(){n()}):void n()):void 0}function n(e){l.failed&&l.failed(e)}L("sendReinvite()"),e=e||{};var r=this,s=e.extraHeaders||[],l=e.eventHandlers||{},u=e.mangle||null;s.push("Contact: "+this.contact),s.push("Content-Type: application/sdp"),this.sessionTimers.running&&s.push("Session-Expires: "+this.sessionTimers.currentExpires+";refresher="+(this.sessionTimers.refresher?"uac":"uas")),i.call(this,"offer",function(e){u&&(e=u(e));var l=new K(r,H.INVITE);l.send({extraHeaders:s,body:e,eventHandlers:{onSuccessResponse:function(e){t(e)},onErrorResponse:function(e){n(e)},onTransportError:function(){r.onTransportError()},onRequestTimeout:function(){r.onRequestTimeout()},onDialogError:function(){r.onDialogError()}}})},function(){o.call(r)&&r.onReadyToReinvite(),n()},this.rtcOfferConstraints)}function f(e){function t(e){if(r.status!==x.STATUS_TERMINATED)if(_.call(r,e),u){if(!e.body)return void n();if("application/sdp"!==e.getHeader("Content-Type"))return void n();r.connection.setRemoteDescription(new k.RTCSessionDescription({type:"answer",sdp:e.body}),function(){l.succeeded&&l.succeeded(e)},function(){n()})}else l.succeeded&&l.succeeded(e)}function n(e){l.failed&&l.failed(e)}L("sendUpdate()"),e=e||{};var r=this,s=e.extraHeaders||[],l=e.eventHandlers||{},u=e.sdpOffer||!1,a=e.mangle||null;if(s.push("Contact: "+this.contact),this.sessionTimers.running&&s.push("Session-Expires: "+this.sessionTimers.currentExpires+";refresher="+(this.sessionTimers.refresher?"uac":"uas")),u)s.push("Content-Type: application/sdp"),i.call(this,"offer",function(e){a&&(e=a(e));var l=new K(r,H.UPDATE);l.send({extraHeaders:s,body:e,eventHandlers:{onSuccessResponse:function(e){t(e)},onErrorResponse:function(e){n(e)},onTransportError:function(){r.onTransportError()},onRequestTimeout:function(){r.onRequestTimeout()},onDialogError:function(){r.onDialogError()}}})},function(){o.call(r)&&r.onReadyToReinvite(),n()},this.rtcOfferConstraints);else{var c=new K(r,H.UPDATE);c.send({extraHeaders:s,eventHandlers:{onSuccessResponse:function(e){t(e)},onErrorResponse:function(e){n(e)},onTransportError:function(){r.onTransportError()},onRequestTimeout:function(){r.onRequestTimeout()},onDialogError:function(){r.onDialogError()}}})}}function m(e,t,n){L("acceptAndTerminate()");var r=[];t&&(n=n||H.REASON_PHRASE[t]||"",r.push("Reason: SIP ;cause="+t+'; text="'+n+'"')),(this.dialog||u.call(this,e,"UAC"))&&(g.call(this,H.ACK),g.call(this,H.BYE,{extraHeaders:r})),this.status=x.STATUS_TERMINATED}function g(e,t){L("sendRequest()");var n=new K(this,e);n.send(t)}function T(e,t){if(this.sessionTimers.enabled){var n;e.session_expires&&e.session_expires>=H.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,v.call(this)}}function _(e){if(this.sessionTimers.enabled){var t;e.session_expires&&e.session_expires>=H.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,v.call(this)}}function v(){var e=this,t=this.sessionTimers.currentExpires;this.sessionTimers.running=!0,clearTimeout(this.sessionTimers.timer),this.sessionTimers.timer=this.sessionTimers.refresher?setTimeout(function(){e.status!==x.STATUS_TERMINATED&&(L("runSessionTimer() | sending session refresh request"),f.call(e,{eventHandlers:{succeeded:function(t){_.call(e,t)}}}))},500*t):setTimeout(function(){e.status!==x.STATUS_TERMINATED&&(q("runSessionTimer() | timer expired, terminating the session"),e.terminate({cause:H.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},1100*t)}function C(e){var t,n,r,s=this.connection.getLocalStreams();for(t in s){r=s[t].getAudioTracks();for(n in r)r[n].enabled=!e}}function S(e){var t,n,r,s=this.connection.getLocalStreams();for(t in s){r=s[t].getVideoTracks();for(n in r)r[n].enabled=!e}}function E(e,t){L("newRTCSession"),"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.newRTCSession({originator:e,session:this,request:t})}function A(e){L("session connecting"),this.emit("connecting",{request:e})}function R(e,t){L("session progress"),this.emit("progress",{originator:e,response:t||null})}function y(e,t){L("session accepted"),this.start_time=new Date,this.emit("accepted",{originator:e,response:t||null})}function b(e,t){L("session confirmed"),this.is_confirmed=!0,this.emit("confirmed",{originator:e,ack:t||null})}function I(e,t,n){L("session ended"),this.end_time=new Date,this.close(),this.emit("ended",{originator:e,message:t||null,cause:n})}function w(e,t,n){L("session failed"),this.close(),this.emit("failed",{originator:e,message:t||null,cause:n})}function N(e){L("session onhold"),"local"===e?this.local_hold=!0:this.remote_hold=!0,this.emit("hold",{originator:e})}function D(e){L("session onunhold"),"local"===e?this.local_hold=!1:this.remote_hold=!1,this.emit("unhold",{originator:e})}function U(e){L("session onmute"),this.emit("muted",{audio:e.audio,video:e.video})}function O(e){L("session onunmute"),this.emit("unmuted",{audio:e.audio,video:e.video})}t.exports=n;var x={STATUS_NULL:0,STATUS_INVITE_SENT:1,STATUS_1XX_RECEIVED:2,STATUS_INVITE_RECEIVED:3,STATUS_WAITING_FOR_ANSWER:4,STATUS_ANSWERED:5,STATUS_WAITING_FOR_ACK:6,STATUS_CANCELED:7,STATUS_TERMINATED:8,STATUS_CONFIRMED:9};n.C=x;var P=e("util"),M=e("events"),L=e("debug")("JsSIP:RTCSession"),q=e("debug")("JsSIP:ERROR:RTCSession");q.log=console.warn.bind(console);var k=e("rtcninja"),H=e("./Constants"),F=e("./Exceptions"),G=e("./Transactions"),j=e("./Parser"),W=e("./Utils"),B=e("./Timers"),z=e("./SIPMessage"),V=e("./Dialog"),Y=e("./RequestSender"),K=e("./RTCSession/Request"),J=e("./RTCSession/DTMF");P.inherits(n,M.EventEmitter),n.prototype.isInProgress=function(){switch(this.status){case x.STATUS_NULL:case x.STATUS_INVITE_SENT:case x.STATUS_1XX_RECEIVED:case x.STATUS_INVITE_RECEIVED:case x.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}},n.prototype.isEstablished=function(){switch(this.status){case x.STATUS_ANSWERED:case x.STATUS_WAITING_FOR_ACK:case x.STATUS_CONFIRMED:return!0;default:return!1}},n.prototype.isEnded=function(){switch(this.status){case x.STATUS_CANCELED:case x.STATUS_TERMINATED:return!0;default:return!1}},n.prototype.isMuted=function(){return{audio:this.audioMuted,video:this.videoMuted}},n.prototype.isOnHold=function(){return{local:this.local_hold,remote:this.remote_hold}},n.prototype.connect=function(e,t){L("connect()"),t=t||{};var n,r,s=e,i=t.eventHandlers||{},o=t.extraHeaders&&t.extraHeaders.slice()||[],u=t.mediaConstraints||{audio:!0,video:!0},a=t.mediaStream||null,c=t.pcConfig||{iceServers:[]},d=t.rtcConstraints||null,p=t.rtcOfferConstraints||null;if(this.sessionTimers.enabled&&W.isDecimal(t.sessionTimersExpires)&&(this.sessionTimers.defaultExpires=t.sessionTimersExpires>=H.MIN_SESSION_EXPIRES?t.sessionTimersExpires:H.MIN_SESSION_EXPIRES),this.rtcOfferConstraints=p,this.data=t.data||{},void 0===e)throw new TypeError("Not enough arguments");if(!k.hasWebRTC())throw new F.NotSupportedError("WebRTC not supported");if(e=this.ua.normalizeTarget(e),!e)throw new TypeError("Invalid target: "+s);if(this.status!==x.STATUS_NULL)throw new F.InvalidStateError(this.status);for(n in i)this.on(n,i[n]);this.from_tag=W.newTag(),this.anonymous=t.anonymous||!1,this.isCanceled=!1,r={from_tag:this.from_tag},this.contact=this.ua.contact.toString({anonymous:this.anonymous,outbound:!0}),this.anonymous&&(r.from_display_name="Anonymous",r.from_uri="sip:anonymous@anonymous.invalid",o.push("P-Preferred-Identity: "+this.ua.configuration.uri.toString()),o.push("Privacy: id")),o.push("Contact: "+this.contact),o.push("Content-Type: application/sdp"),this.sessionTimers.enabled&&o.push("Session-Expires: "+this.sessionTimers.defaultExpires),this.request=new z.OutgoingRequest(H.INVITE,e,this.ua,r,o),this.id=this.request.call_id+this.from_tag,l.call(this,c,d),this.ua.sessions[this.id]=this,E.call(this,"local",this.request),h.call(this,u,p,a)},n.prototype.init_incoming=function(e){L("init_incoming()");var t,n=this,r=e.getHeader("Content-Type");return e.body&&"application/sdp"!==r?void e.reply(415):(this.status=x.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(),this.ua.sessions[this.id]=this,e.hasHeader("expires")&&(t=1e3*e.getHeader("expires")),e.to_tag=W.newTag(),u.call(this,e,"UAS",!0)?(this.late_sdp=e.body?!1:!0,n.status=x.STATUS_WAITING_FOR_ANSWER,n.timers.userNoAnswerTimer=setTimeout(function(){e.reply(408),w.call(n,"local",null,H.causes.NO_ANSWER)},n.ua.configuration.no_answer_timeout),t&&(n.timers.expiresTimer=setTimeout(function(){n.status===x.STATUS_WAITING_FOR_ANSWER&&(e.reply(487),w.call(n,"system",null,H.causes.EXPIRES))},t)),E.call(n,"remote",e),e.reply(180,null,["Contact: "+n.contact]),void R.call(n,"local",null)):void e.reply(500,"Missing Contact header field"))},n.prototype.answer=function(e){function t(e){_.status!==x.STATUS_TERMINATED&&(_.localMediaStream=e,_.connection.addStream(e),_.late_sdp?o():_.connection.setRemoteDescription(new k.RTCSessionDescription({type:"offer",sdp:v.body}),o,function(){v.reply(488),w.call(_,"system",null,H.causes.WEBRTC_ERROR)}))}function n(){_.status!==x.STATUS_TERMINATED&&(v.reply(480),w.call(_,"local",null,H.causes.USER_DENIED_MEDIA_ACCESS))}function o(){A.call(_,v),_.late_sdp?i.call(_,"offer",a,c,I):i.call(_,"answer",a,c,I)}function a(e){function t(){_.status=x.STATUS_WAITING_FOR_ACK,r.call(_,v,e),s.call(_),y.call(_,"local")}function n(){w.call(_,"system",null,H.causes.CONNECTION_ERROR)}_.status!==x.STATUS_TERMINATED&&(T.call(_,v,C),v.reply(200,null,C,e,t,n))}function c(){_.status!==x.STATUS_TERMINATED&&(v.reply(500),w.call(_,"system",null,H.causes.WEBRTC_ERROR))}L("answer()"),e=e||{};var h,d,p,f,m=!1,g=!1,_=this,v=this.request,C=e.extraHeaders&&e.extraHeaders.slice()||[],S=e.mediaConstraints||{},E=e.mediaStream||null,R=e.pcConfig||{iceServers:[]},b=e.rtcConstraints||null,I=e.rtcAnswerConstraints||null;if(this.sessionTimers.enabled&&W.isDecimal(e.sessionTimersExpires)&&(this.sessionTimers.defaultExpires=e.sessionTimersExpires>=H.MIN_SESSION_EXPIRES?e.sessionTimersExpires:H.MIN_SESSION_EXPIRES),this.data=e.data||{},"incoming"!==this.direction)throw new F.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this.status!==x.STATUS_WAITING_FOR_ANSWER)throw new F.InvalidStateError(this.status);if(this.status=x.STATUS_ANSWERED,!u.call(this,v,"UAS"))return void v.reply(500,"Error creating dialog");for(clearTimeout(this.timers.userNoAnswerTimer),C.unshift("Contact: "+_.contact),p=j.parseSDP(v.body||""),Array.isArray(p.media)||(p.media=[p.media]),h=p.media.length;h--;){var N=p.media[h];"audio"!==N.type||N.direction&&"sendrecv"!==N.direction||(m=!0),"video"!==N.type||N.direction&&"sendrecv"!==N.direction||(g=!0)}if(E&&S.audio===!1)for(f=E.getAudioTracks(),d=f.length,h=0;d>h;h++)E.removeTrack(f[h]);if(E&&S.video===!1)for(f=E.getVideoTracks(),d=f.length,h=0;d>h;h++)E.removeTrack(f[h]);void 0===S.audio&&(S.audio=m),void 0===S.video&&(S.video=g),l.call(this,R,b),E?t(E):(_.localMediaStreamLocallyGenerated=!0,k.getUserMedia(S,t,n))},n.prototype.terminate=function(e){L("terminate()"),e=e||{};var t,n,r=e.cause||H.causes.BYE,s=e.status_code,l=e.reason_phrase,i=e.extraHeaders&&e.extraHeaders.slice()||[],o=e.body,u=this;if(this.status===x.STATUS_TERMINATED)throw new F.InvalidStateError(this.status);switch(this.status){case x.STATUS_NULL:case x.STATUS_INVITE_SENT:case x.STATUS_1XX_RECEIVED:if(L("canceling sesssion"),s&&(200>s||s>=700))throw new TypeError("Invalid status_code: "+s);s&&(l=l||H.REASON_PHRASE[s]||"",t="SIP ;cause="+s+' ;text="'+l+'"'),this.status===x.STATUS_NULL?(this.isCanceled=!0,this.cancelReason=t):this.status===x.STATUS_INVITE_SENT?(this.isCanceled=!0,this.cancelReason=t):this.status===x.STATUS_1XX_RECEIVED&&this.request.cancel(t),this.status=x.STATUS_CANCELED,w.call(this,"local",null,H.causes.CANCELED);break;case x.STATUS_WAITING_FOR_ANSWER:case x.STATUS_ANSWERED:if(L("rejecting session"),s=s||480,300>s||s>=700)throw new TypeError("Invalid status_code: "+s);this.request.reply(s,l,i,o),w.call(this,"local",null,H.causes.REJECTED);break;case x.STATUS_WAITING_FOR_ACK:case x.STATUS_CONFIRMED:if(L("terminating session"),l=e.reason_phrase||H.REASON_PHRASE[s]||"",s&&(200>s||s>=700))throw new TypeError("Invalid status_code: "+s);s&&i.push("Reason: SIP ;cause="+s+'; text="'+l+'"'),this.status===x.STATUS_WAITING_FOR_ACK&&"incoming"===this.direction&&this.request.server_transaction.state!==G.C.STATUS_TERMINATED?(n=this.dialog,this.receiveRequest=function(e){e.method===H.ACK&&(g.call(this,H.BYE,{extraHeaders:i,body:o}),n.terminate())},this.request.server_transaction.on("stateChanged",function(){this.state===G.C.STATUS_TERMINATED&&(g.call(u,H.BYE,{extraHeaders:i,body:o}),n.terminate())}),I.call(this,"local",null,r),this.dialog=n,this.ua.dialogs[n.id.toString()]=n):(g.call(this,H.BYE,{extraHeaders:i,body:o}),I.call(this,"local",null,r))}},n.prototype.close=function(){L("close()");var e;if(this.status!==x.STATUS_TERMINATED){this.connection&&this.connection.close(),this.localMediaStream&&this.localMediaStreamLocallyGenerated&&(L("close() | closing local MediaStream"),k.closeMediaStream(this.localMediaStream));for(e in this.timers)clearTimeout(this.timers[e]);clearTimeout(this.sessionTimers.timer),this.dialog&&(this.dialog.terminate(),delete this.dialog);for(e in this.earlyDialogs)this.earlyDialogs[e].terminate(),delete this.earlyDialogs[e];this.status=x.STATUS_TERMINATED,delete this.ua.sessions[this.id]}},n.prototype.sendDTMF=function(e,t){function n(){var e,o;if(i.status===x.STATUS_TERMINATED||!i.tones||l>=i.tones.length)return void(i.tones=null);if(e=i.tones[l],l+=1,","===e)o=2e3;else{var u=new J(i);t.eventHandlers={failed:function(){i.tones=null}},u.send(e,t),o=r+s}setTimeout(n,o)}L("sendDTMF() | tones: %s",e);var r,s,l=0,i=this;if(t=t||{},r=t.duration||null,s=t.interToneGap||null,void 0===e)throw new TypeError("Not enough arguments");if(this.status!==x.STATUS_CONFIRMED&&this.status!==x.STATUS_WAITING_FOR_ACK)throw new F.InvalidStateError(this.status);if("number"==typeof e&&(e=e.toString()),!e||"string"!=typeof e||!e.match(/^[0-9A-D#*,]+$/i))throw new TypeError("Invalid tones: "+e);if(r&&!W.isDecimal(r))throw new TypeError("Invalid tone duration: "+r);if(r?r<J.C.MIN_DURATION?(L('"duration" value is lower than the minimum allowed, setting it to '+J.C.MIN_DURATION+" milliseconds"),r=J.C.MIN_DURATION):r>J.C.MAX_DURATION?(L('"duration" value is greater than the maximum allowed, setting it to '+J.C.MAX_DURATION+" milliseconds"),r=J.C.MAX_DURATION):r=Math.abs(r):r=J.C.DEFAULT_DURATION,t.duration=r,s&&!W.isDecimal(s))throw new TypeError("Invalid interToneGap: "+s);return s?s<J.C.MIN_INTER_TONE_GAP?(L('"interToneGap" value is lower than the minimum allowed, setting it to '+J.C.MIN_INTER_TONE_GAP+" milliseconds"),s=J.C.MIN_INTER_TONE_GAP):s=Math.abs(s):s=J.C.DEFAULT_INTER_TONE_GAP,this.tones?void(this.tones+=e):(this.tones=e,void n())},n.prototype.mute=function(e){L("mute()"),e=e||{audio:!0,video:!1};var t=!1,n=!1;this.audioMuted===!1&&e.audio&&(t=!0,this.audioMuted=!0,C.call(this,!0)),this.videoMuted===!1&&e.video&&(n=!0,this.videoMuted=!0,S.call(this,!0)),(t===!0||n===!0)&&U.call(this,{audio:t,video:n})},n.prototype.unmute=function(e){L("unmute()"),e=e||{audio:!0,video:!0};var t=!1,n=!1;this.audioMuted===!0&&e.audio&&(t=!0,this.audioMuted=!1,this.local_hold===!1&&C.call(this,!1)),this.videoMuted===!0&&e.video&&(n=!0,this.videoMuted=!1,this.local_hold===!1&&S.call(this,!1)),(t===!0||n===!0)&&O.call(this,{audio:t,video:n})},n.prototype.hold=function(){L("hold()");var e=this;if(this.status!==x.STATUS_WAITING_FOR_ACK&&this.status!==x.STATUS_CONFIRMED)throw new F.InvalidStateError(this.status);return C.call(this,!0),S.call(this,!0),o.call(this)?void(this.local_hold!==!0&&(N.call(this,"local"),p.call(this,{mangle:function(e){var t,n;for(e=j.parseSDP(e),n=e.media.length,t=0;n>t;t++){var r=e.media[t];r.direction?"sendrecv"===r.direction?r.direction="sendonly":"recvonly"===r.direction&&(r.direction="inactive"):r.direction="sendonly"}return j.writeSDP(e)},eventHandlers:{failed:function(){e.terminate({cause:H.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}}}))):this.pending_actions.isPending("unhold")?void 0:this.pending_actions.isPending("renegotiate")?void 0:this.pending_actions.isPending("hold")?void 0:void this.pending_actions.push("hold")},n.prototype.unhold=function(){L("unhold()");var e=this;if(this.status!==x.STATUS_WAITING_FOR_ACK&&this.status!==x.STATUS_CONFIRMED)throw new F.InvalidStateError(this.status);return this.audioMuted||C.call(this,!1),this.videoMuted||S.call(this,!1),o.call(this)?void(this.local_hold!==!1&&(D.call(this,"local"),p.call(this,{eventHandlers:{failed:function(){e.terminate({cause:H.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}}}))):this.pending_actions.isPending("hold")?void 0:this.pending_actions.isPending("renegotiate")?void 0:this.pending_actions.isPending("unhold")?void 0:void this.pending_actions.push("unhold")},n.prototype.renegotiate=function(e){L("renegotiate()");var t,n=this;if(this.status!==x.STATUS_WAITING_FOR_ACK&&this.status!==x.STATUS_CONFIRMED)throw new F.InvalidStateError(this.status);return this.renegotiateOptions=e||{},o.call(this)?(this.local_hold===!0&&D.call(this,"local"),t={failed:function(){n.terminate({cause:H.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}},void(this.renegotiateOptions.useUpdate?f.call(this,{sdpOffer:!0,eventHandlers:t}):p.call(this,{eventHandlers:t}))):this.pending_actions.isPending("hold")?void 0:this.pending_actions.isPending("unhold")?void 0:this.pending_actions.isPending("renegotiate")?void 0:void this.pending_actions.push("renegotiate")},n.prototype.receiveRequest=function(e){L("receiveRequest()");
  var t,n=this;if(e.method===H.CANCEL)(this.status===x.STATUS_WAITING_FOR_ANSWER||this.status===x.STATUS_ANSWERED)&&(this.status=x.STATUS_CANCELED,this.request.reply(487),w.call(this,"remote",e,H.causes.CANCELED));else switch(e.method){case H.ACK:if(this.status===x.STATUS_WAITING_FOR_ACK){if(clearTimeout(this.timers.ackTimer),clearTimeout(this.timers.invite2xxTimer),this.late_sdp){if(!e.body){I.call(this,"remote",e,H.causes.MISSING_SDP);break}this.connection.setRemoteDescription(new k.RTCSessionDescription({type:"answer",sdp:e.body}),function(){n.status=x.STATUS_CONFIRMED},function(){I.call(n,"remote",e,H.causes.BAD_MEDIA_DESCRIPTION)})}else this.status=x.STATUS_CONFIRMED;this.status!==x.STATUS_CONFIRMED||this.is_confirmed||b.call(this,"remote",e)}break;case H.BYE:this.status===x.STATUS_CONFIRMED?(e.reply(200),I.call(this,"remote",e,H.causes.BYE)):this.status===x.STATUS_INVITE_RECEIVED?(e.reply(200),this.request.reply(487,"BYE Received"),I.call(this,"remote",e,H.causes.BYE)):e.reply(403,"Wrong Status");break;case H.INVITE:this.status===x.STATUS_CONFIRMED?a.call(this,e):e.reply(403,"Wrong Status");break;case H.INFO:this.status===x.STATUS_CONFIRMED||this.status===x.STATUS_WAITING_FOR_ACK||this.status===x.STATUS_INVITE_RECEIVED?(t=e.getHeader("content-type"),t&&t.match(/^application\/dtmf-relay/i)?new J(this).init_incoming(e):e.reply(415)):e.reply(403,"Wrong Status");break;case H.UPDATE:this.status===x.STATUS_CONFIRMED?c.call(this,e):e.reply(403,"Wrong Status");break;default:e.reply(501)}},n.prototype.onTransportError=function(){q("onTransportError()"),this.status!==x.STATUS_TERMINATED&&(this.status===x.STATUS_CONFIRMED?I.call(this,"system",null,H.causes.CONNECTION_ERROR):w.call(this,"system",null,H.causes.CONNECTION_ERROR))},n.prototype.onRequestTimeout=function(){L("onRequestTimeout"),this.status!==x.STATUS_TERMINATED&&(this.status===x.STATUS_CONFIRMED?I.call(this,"system",null,H.causes.REQUEST_TIMEOUT):w.call(this,"system",null,H.causes.REQUEST_TIMEOUT))},n.prototype.onDialogError=function(e){q("onDialogError()"),this.status!==x.STATUS_TERMINATED&&(this.status===x.STATUS_CONFIRMED?I.call(this,"remote",e,H.causes.DIALOG_ERROR):w.call(this,"remote",e,H.causes.DIALOG_ERROR))},n.prototype.newDTMF=function(e){L("newDTMF()"),this.emit("newDTMF",e)},n.prototype.onReadyToReinvite=function(){var e=this.pending_actions.length()>0?this.pending_actions.shift():null;e&&("hold"===e.name?this.hold():"unhold"===e.name?this.unhold():"renegotiate"===e.name&&this.renegotiate(this.renegotiateOptions))}},{"./Constants":1,"./Dialog":2,"./Exceptions":5,"./Parser":10,"./RTCSession/DTMF":12,"./RTCSession/Request":13,"./RequestSender":15,"./SIPMessage":16,"./Timers":17,"./Transactions":18,"./Utils":22,debug:29,events:24,rtcninja:34,util:28}],12:[function(e,t){function n(e){this.owner=e,this.direction=null,this.tone=null,this.duration=null}t.exports=n;var r={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};n.C=r;var s=e("debug")("JsSIP:RTCSession:DTMF"),l=e("debug")("JsSIP:ERROR:RTCSession:DTMF");l.log=console.warn.bind(console);var i=e("../Constants"),o=e("../Exceptions"),u=e("../RTCSession");n.prototype.send=function(e,t){var n,r;if(void 0===e)throw new TypeError("Not enough arguments");if(this.direction="outgoing",this.owner.status!==u.C.STATUS_CONFIRMED&&this.owner.status!==u.C.STATUS_WAITING_FOR_ACK)throw new o.InvalidStateError(this.owner.status);if(t=t||{},n=t.extraHeaders?t.extraHeaders.slice():[],this.eventHandlers=t.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-D#*]$/))throw new TypeError("Invalid tone: "+e);this.tone=e,this.duration=t.duration,n.push("Content-Type: application/dtmf-relay"),r="Signal="+this.tone+"\r\n",r+="Duration="+this.duration,this.owner.newDTMF({originator:"local",dtmf:this,request:this.request}),this.owner.dialog.sendRequest(this,i.INFO,{extraHeaders:n,body:r})},n.prototype.receiveResponse=function(e){switch(!0){case/^1[0-9]{2}$/.test(e.status_code):break;case/^2[0-9]{2}$/.test(e.status_code):s("onSuccessResponse"),this.eventHandlers.onSuccessResponse&&this.eventHandlers.onSuccessResponse(e);break;default:this.eventHandlers.onErrorResponse&&this.eventHandlers.onErrorResponse(e)}},n.prototype.onRequestTimeout=function(){l("onRequestTimeout"),this.eventHandlers.onRequestTimeout&&this.eventHandlers.onRequestTimeout()},n.prototype.onTransportError=function(){l("onTransportError"),this.eventHandlers.onTransportError&&this.eventHandlers.onTransportError()},n.prototype.onDialogError=function(){l("onDialogError"),this.eventHandlers.onDialogError&&this.eventHandlers.onDialogError()},n.prototype.init_incoming=function(e){var t,n=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,r=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;this.direction="incoming",this.request=e,e.reply(200),e.body&&(t=e.body.split("\r\n"),2===t.length&&(n.test(t[0])&&(this.tone=t[0].replace(n,"$2")),r.test(t[1])&&(this.duration=parseInt(t[1].replace(r,"$2"),10)))),this.tone&&this.duration?this.owner.newDTMF({originator:"remote",dtmf:this,request:e}):s("invalid INFO DTMF received, discarded")}},{"../Constants":1,"../Exceptions":5,"../RTCSession":11,debug:29}],13:[function(e,t){function n(e,t){if(r("new | %s",t),this.session=e,this.method=t,this.session.status!==o.C.STATUS_1XX_RECEIVED&&this.session.status!==o.C.STATUS_WAITING_FOR_ANSWER&&this.session.status!==o.C.STATUS_WAITING_FOR_ACK&&this.session.status!==o.C.STATUS_CONFIRMED&&this.session.status!==o.C.STATUS_TERMINATED)throw new i.InvalidStateError(this.session.status);if(this.session.status===o.C.STATUS_TERMINATED&&t!==l.BYE)throw new i.InvalidStateError(this.session.status)}t.exports=n;var r=e("debug")("JsSIP:RTCSession:Request"),s=e("debug")("JsSIP:ERROR:RTCSession:Request");s.log=console.warn.bind(console);var l=e("../Constants"),i=e("../Exceptions"),o=e("../RTCSession");n.prototype.send=function(e){e=e||{};var t=e.extraHeaders&&e.extraHeaders.slice()||[],n=e.body||null;this.eventHandlers=e.eventHandlers||{},this.session.dialog.sendRequest(this,this.method,{extraHeaders:t,body:n})},n.prototype.receiveResponse=function(e){switch(!0){case/^1[0-9]{2}$/.test(e.status_code):r("onProgressResponse"),this.eventHandlers.onProgressResponse&&this.eventHandlers.onProgressResponse(e);break;case/^2[0-9]{2}$/.test(e.status_code):r("onSuccessResponse"),this.eventHandlers.onSuccessResponse&&this.eventHandlers.onSuccessResponse(e);break;default:r("onErrorResponse"),this.eventHandlers.onErrorResponse&&this.eventHandlers.onErrorResponse(e)}},n.prototype.onRequestTimeout=function(){s("onRequestTimeout"),this.eventHandlers.onRequestTimeout&&this.eventHandlers.onRequestTimeout()},n.prototype.onTransportError=function(){s("onTransportError"),this.eventHandlers.onTransportError&&this.eventHandlers.onTransportError()},n.prototype.onDialogError=function(){s("onDialogError"),this.eventHandlers.onDialogError&&this.eventHandlers.onDialogError()}},{"../Constants":1,"../Exceptions":5,"../RTCSession":11,debug:29}],14:[function(e,t){function n(e,t){var n=1;this.ua=e,this.transport=t,this.registrar=e.configuration.registrar_server,this.expires=e.configuration.register_expires,this.call_id=s.createRandomToken(22),this.cseq=0,this.to_uri=e.configuration.uri,this.registrationTimer=null,this.registered=!1,this.contact=this.ua.contact.toString(),this.contact+=";+sip.ice",this.extraHeaders=[],this.extraContactParams="",n&&(this.contact+=";reg-id="+n,this.contact+=';+sip.instance="<urn:uuid:'+this.ua.configuration.instance_id+'>"')}t.exports=n;var r=e("debug")("JsSIP:Registrator"),s=e("./Utils"),l=e("./Constants"),i=e("./SIPMessage"),o=e("./RequestSender");n.prototype={setExtraHeaders:function(e){Array.isArray(e)||(e=[]),this.extraHeaders=e.slice()},setExtraContactParams:function(e){e instanceof Object||(e={}),this.extraContactParams="";for(var t in e){var n=e[t];this.extraContactParams+=";"+t,n&&(this.extraContactParams+="="+n)}},register:function(){var e,t,n,u=this;n=this.extraHeaders.slice(),n.push("Contact: "+this.contact+";expires="+this.expires+this.extraContactParams),n.push("Expires: "+this.expires),this.request=new i.OutgoingRequest(l.REGISTER,this.registrar,this.ua,{to_uri:this.to_uri,call_id:this.call_id,cseq:this.cseq+=1},n),e=new o(this,this.ua),this.receiveResponse=function(e){var n,i,o=e.getHeaders("contact").length;if(e.cseq===this.cseq)switch(null!==this.registrationTimer&&(clearTimeout(this.registrationTimer),this.registrationTimer=null),!0){case/^1[0-9]{2}$/.test(e.status_code):break;case/^2[0-9]{2}$/.test(e.status_code):if(e.hasHeader("expires")&&(i=e.getHeader("expires")),!o){r("no Contact header in response to REGISTER, response ignored");break}for(;o--;){if(n=e.parseHeader("contact",o),n.uri.user===this.ua.contact.uri.user){i=n.getParam("expires");break}n=null}if(!n){r("no Contact header pointing to us, response ignored");break}i||(i=this.expires),this.registrationTimer=setTimeout(function(){u.registrationTimer=null,u.register()},1e3*i-3e3),n.hasParam("temp-gruu")&&(this.ua.contact.temp_gruu=n.getParam("temp-gruu").replace(/"/g,"")),n.hasParam("pub-gruu")&&(this.ua.contact.pub_gruu=n.getParam("pub-gruu").replace(/"/g,"")),this.registered||(this.registered=!0,this.ua.registered({response:e}));break;case/^423$/.test(e.status_code):e.hasHeader("min-expires")?(this.expires=e.getHeader("min-expires"),this.register()):(r("423 response received for REGISTER without Min-Expires"),this.registrationFailure(e,l.causes.SIP_FAILURE_CODE));break;default:t=s.sipErrorCause(e.status_code),this.registrationFailure(e,t)}},this.onRequestTimeout=function(){this.registrationFailure(null,l.causes.REQUEST_TIMEOUT)},this.onTransportError=function(){this.registrationFailure(null,l.causes.CONNECTION_ERROR)},e.send()},unregister:function(e){var t;if(!this.registered)return void r("already unregistered");e=e||{},this.registered=!1,null!==this.registrationTimer&&(clearTimeout(this.registrationTimer),this.registrationTimer=null),t=this.extraHeaders.slice(),e.all?(t.push("Contact: *"+this.extraContactParams),t.push("Expires: 0"),this.request=new i.OutgoingRequest(l.REGISTER,this.registrar,this.ua,{to_uri:this.to_uri,call_id:this.call_id,cseq:this.cseq+=1},t)):(t.push("Contact: "+this.contact+";expires=0"+this.extraContactParams),t.push("Expires: 0"),this.request=new i.OutgoingRequest(l.REGISTER,this.registrar,this.ua,{to_uri:this.to_uri,call_id:this.call_id,cseq:this.cseq+=1},t));var n=new o(this,this.ua);this.receiveResponse=function(e){var t;switch(!0){case/^1[0-9]{2}$/.test(e.status_code):break;case/^2[0-9]{2}$/.test(e.status_code):this.unregistered(e);break;default:t=s.sipErrorCause(e.status_code),this.unregistered(e,t)}},this.onRequestTimeout=function(){this.unregistered(null,l.causes.REQUEST_TIMEOUT)},this.onTransportError=function(){this.unregistered(null,l.causes.CONNECTION_ERROR)},n.send()},registrationFailure:function(e,t){this.ua.registrationFailed({response:e||null,cause:t}),this.registered&&(this.registered=!1,this.ua.unregistered({response:e||null,cause:t}))},unregistered:function(e,t){this.registered=!1,this.ua.unregistered({response:e||null,cause:t||null})},onTransportClosed:function(){null!==this.registrationTimer&&(clearTimeout(this.registrationTimer),this.registrationTimer=null),this.registered&&(this.registered=!1,this.ua.unregistered({}))},close:function(){this.registered&&this.unregister()}}},{"./Constants":1,"./RequestSender":15,"./SIPMessage":16,"./Utils":22,debug:29}],15:[function(e,t){function n(e,t){this.ua=t,this.applicant=e,this.method=e.request.method,this.request=e.request,this.credentials=null,this.challenged=!1,this.staled=!1,t.status!==l.C.STATUS_USER_CLOSED||this.method===s.BYE&&this.method===s.ACK||this.onTransportError()}t.exports=n;var r=e("debug")("JsSIP:RequestSender"),s=e("./Constants"),l=e("./UA"),i=e("./DigestAuthentication"),o=e("./Transactions");n.prototype={send:function(){switch(this.method){case"INVITE":this.clientTransaction=new o.InviteClientTransaction(this,this.request,this.ua.transport);break;case"ACK":this.clientTransaction=new o.AckClientTransaction(this,this.request,this.ua.transport);break;default:this.clientTransaction=new o.NonInviteClientTransaction(this,this.request,this.ua.transport)}this.clientTransaction.send()},onRequestTimeout:function(){this.applicant.onRequestTimeout()},onTransportError:function(){this.applicant.onTransportError()},receiveResponse:function(e){var t,n,l,o=e.status_code;if(401!==o&&407!==o||null===this.ua.configuration.password)this.applicant.receiveResponse(e);else{if(401===e.status_code?(n=e.parseHeader("www-authenticate"),l="authorization"):(n=e.parseHeader("proxy-authenticate"),l="proxy-authorization"),!n)return r(e.status_code+" with wrong or missing challenge, cannot authenticate"),void this.applicant.receiveResponse(e);if(!this.challenged||!this.staled&&n.stale===!0){if(this.credentials||(this.credentials=new i(this.ua)),!this.credentials.authenticate(this.request,n))return void this.applicant.receiveResponse(e);this.challenged=!0,n.stale&&(this.staled=!0),e.method===s.REGISTER?t=this.applicant.cseq+=1:this.request.dialog?t=this.request.dialog.local_seqnum+=1:(t=this.request.cseq+1,this.request.cseq=t),this.request.setHeader("cseq",t+" "+this.method),this.request.setHeader(l,this.credentials.toString()),this.send()}else this.applicant.receiveResponse(e)}}}},{"./Constants":1,"./DigestAuthentication":4,"./Transactions":18,"./UA":20,debug:29}],16:[function(e,t){function n(e,t,n,r,s,l){var i,c,h,d;return r=r||{},e&&t&&n?(this.ua=n,this.headers={},this.method=e,this.ruri=t,this.body=l,this.extraHeaders=s&&s.slice()||[],r.route_set?this.setHeader("route",r.route_set):n.configuration.use_preloaded_route&&this.setHeader("route",n.transport.server.sip_uri),this.setHeader("via",""),this.setHeader("max-forwards",o.MAX_FORWARDS),i=r.to_display_name||0===r.to_display_name?'"'+r.to_display_name+'" ':"",i+="<"+(r.to_uri||t)+">",i+=r.to_tag?";tag="+r.to_tag:"",this.to=new a.parse(i),this.setHeader("to",i),c=r.from_display_name||0===r.from_display_name?'"'+r.from_display_name+'" ':n.configuration.display_name?'"'+n.configuration.display_name+'" ':"",c+="<"+(r.from_uri||n.configuration.uri)+">;tag=",c+=r.from_tag||u.newTag(),this.from=new a.parse(c),this.setHeader("from",c),h=r.call_id||n.configuration.jssip_id+u.createRandomToken(15),this.call_id=h,this.setHeader("call-id",h),d=r.cseq||Math.floor(1e4*Math.random()),this.cseq=d,void this.setHeader("cseq",d+" "+e)):null}function r(){this.data=null,this.headers=null,this.method=null,this.via=null,this.via_branch=null,this.call_id=null,this.cseq=null,this.from=null,this.from_tag=null,this.to=null,this.to_tag=null,this.body=null}function s(e){this.ua=e,this.headers={},this.ruri=null,this.transport=null,this.server_transaction=null}function l(){this.headers={},this.status_code=null,this.reason_phrase=null}t.exports={OutgoingRequest:n,IncomingRequest:s,IncomingResponse:l};var i=e("debug")("JsSIP:SIPMessage"),o=e("./Constants"),u=e("./Utils"),a=e("./NameAddrHeader"),c=e("./Grammar");n.prototype={setHeader:function(e,t){this.headers[u.headerize(e)]=Array.isArray(t)?t:[t]},getHeader:function(e){var t,n,r=this.extraHeaders.length,s=this.headers[u.headerize(e)];if(s){if(s[0])return s[0]}else for(t=new RegExp("^\\s*"+e+"\\s*:","i"),n=0;r>n;n++)if(s=this.extraHeaders[n],t.test(s))return s.substring(s.indexOf(":")+1).trim()},getHeaders:function(e){var t,n,r,s=this.headers[u.headerize(e)],l=[];if(s){for(n=s.length,t=0;n>t;t++)l.push(s[t]);return l}for(n=this.extraHeaders.length,r=new RegExp("^\\s*"+e+"\\s*:","i"),t=0;n>t;t++)s=this.extraHeaders[t],r.test(s)&&l.push(s.substring(s.indexOf(":")+1).trim());return l},hasHeader:function(e){var t,n,r=this.extraHeaders.length;if(this.headers[u.headerize(e)])return!0;for(t=new RegExp("^\\s*"+e+"\\s*:","i"),n=0;r>n;n++)if(t.test(this.extraHeaders[n]))return!0;return!1},toString:function(){var e,t,n,r="",s=[];r+=this.method+" "+this.ruri+" SIP/2.0\r\n";for(e in this.headers)for(t=this.headers[e].length,n=0;t>n;n++)r+=e+": "+this.headers[e][n]+"\r\n";for(t=this.extraHeaders.length,n=0;t>n;n++)r+=this.extraHeaders[n].trim()+"\r\n";switch(this.method){case o.REGISTER:s.push("path","gruu");break;case o.INVITE:this.ua.configuration.session_timers&&s.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&s.push("gruu"),s.push("ice");break;case o.UPDATE:this.ua.configuration.session_timers&&s.push("timer"),s.push("ice")}return s.push("outbound"),r+="Allow: "+o.ALLOWED_METHODS+"\r\n",r+="Supported: "+s+"\r\n",r+="User-Agent: "+o.USER_AGENT+"\r\n",this.body?(t=u.str_utf8_length(this.body),r+="Content-Length: "+t+"\r\n\r\n",r+=this.body):r+="Content-Length: 0\r\n\r\n",r}},r.prototype={addHeader:function(e,t){var n={raw:t};e=u.headerize(e),this.headers[e]?this.headers[e].push(n):this.headers[e]=[n]},getHeader:function(e){var t=this.headers[u.headerize(e)];if(t)return t[0]?t[0].raw:void 0},getHeaders:function(e){var t,n,r=this.headers[u.headerize(e)],s=[];if(!r)return[];for(n=r.length,t=0;n>t;t++)s.push(r[t].raw);return s},hasHeader:function(e){return this.headers[u.headerize(e)]?!0:!1},parseHeader:function(e,t){var n,r,s;return e=u.headerize(e),t=t||0,this.headers[e]?t>=this.headers[e].length?void i('not so many "'+e+'" headers present'):(n=this.headers[e][t],r=n.raw,n.parsed?n.parsed:(s=c.parse(r,e.replace(/-/g,"_")),-1===s?(this.headers[e].splice(t,1),void i('error parsing "'+e+'" header field with value "'+r+'"')):(n.parsed=s,s))):void i('header "'+e+'" not present')},s:function(e,t){return this.parseHeader(e,t)},setHeader:function(e,t){var n={raw:t};this.headers[u.headerize(e)]=[n]},toString:function(){return this.data}},s.prototype=new r,s.prototype.reply=function(e,t,n,r,s,l){var i,a,c,h,d,p=[],f=this.getHeader("To"),m=0,g=0;if(e=e||null,t=t||null,!e||100>e||e>699)throw new TypeError("Invalid status_code: "+e);if(t&&"string"!=typeof t&&!(t instanceof String))throw new TypeError("Invalid reason_phrase: "+t);if(t=t||o.REASON_PHRASE[e]||"",n=n&&n.slice()||[],d="SIP/2.0 "+e+" "+t+"\r\n",this.method===o.INVITE&&e>100&&200>=e)for(i=this.getHeaders("record-route"),c=i.length,m;c>m;m++)d+="Record-Route: "+i[m]+"\r\n";for(a=this.getHeaders("via"),c=a.length,g;c>g;g++)d+="Via: "+a[g]+"\r\n";for(!this.to_tag&&e>100?f+=";tag="+u.newTag():this.to_tag&&!this.s("to").hasParam("tag")&&(f+=";tag="+this.to_tag),d+="To: "+f+"\r\n",d+="From: "+this.getHeader("From")+"\r\n",d+="Call-ID: "+this.call_id+"\r\n",d+="CSeq: "+this.cseq+" "+this.method+"\r\n",c=n.length,h=0;c>h;h++)d+=n[h].trim()+"\r\n";switch(this.method){case o.INVITE:this.ua.configuration.session_timers&&p.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&p.push("gruu"),p.push("ice");break;case o.UPDATE:this.ua.configuration.session_timers&&p.push("timer"),r&&p.push("ice")}p.push("outbound"),this.method===o.OPTIONS?(d+="Allow: "+o.ALLOWED_METHODS+"\r\n",d+="Accept: "+o.ACCEPTED_BODY_TYPES+"\r\n"):405===e?d+="Allow: "+o.ALLOWED_METHODS+"\r\n":415===e&&(d+="Accept: "+o.ACCEPTED_BODY_TYPES+"\r\n"),d+="Supported: "+p+"\r\n",r?(c=u.str_utf8_length(r),d+="Content-Type: application/sdp\r\n",d+="Content-Length: "+c+"\r\n\r\n",d+=r):d+="Content-Length: 0\r\n\r\n",this.server_transaction.receiveResponse(e,d,s,l)},s.prototype.reply_sl=function(e,t){var n,r,s=0,l=this.getHeaders("via"),i=l.length;if(e=e||null,t=t||null,!e||100>e||e>699)throw new TypeError("Invalid status_code: "+e);if(t&&"string"!=typeof t&&!(t instanceof String))throw new TypeError("Invalid reason_phrase: "+t);for(t=t||o.REASON_PHRASE[e]||"",r="SIP/2.0 "+e+" "+t+"\r\n",s;i>s;s++)r+="Via: "+l[s]+"\r\n";n=this.getHeader("To"),!this.to_tag&&e>100?n+=";tag="+u.newTag():this.to_tag&&!this.s("to").hasParam("tag")&&(n+=";tag="+this.to_tag),r+="To: "+n+"\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)},l.prototype=new r},{"./Constants":1,"./Grammar":6,"./NameAddrHeader":9,"./Utils":22,debug:29}],17:[function(e,t){var n=500,r=4e3,s=5e3,l={T1:n,T2:r,T4:s,TIMER_B:64*n,TIMER_D:0*n,TIMER_F:64*n,TIMER_H:64*n,TIMER_I:0*n,TIMER_J:0*n,TIMER_K:0*s,TIMER_L:64*n,TIMER_M:64*n,PROVISIONAL_RESPONSE_INTERVAL:6e4};t.exports=l},{}],18:[function(e,t){function n(e,t,n){var r,s;this.type=u.NON_INVITE_CLIENT,this.transport=n,this.id="z9hG4bK"+Math.floor(1e7*Math.random()),this.request_sender=e,this.request=t,s=e.ua.configuration.hack_via_tcp?"TCP":e.ua.configuration.hack_via_ws?"WS":n.server.scheme,r="SIP/2.0/"+s,r+=" "+e.ua.configuration.via_host+";branch="+this.id,this.request.setHeader("via",r),this.request_sender.ua.newTransaction(this),c.EventEmitter.call(this)}function r(e,t,n){var r,s,l=this;this.type=u.INVITE_CLIENT,this.transport=n,this.id="z9hG4bK"+Math.floor(1e7*Math.random()),this.request_sender=e,this.request=t,s=e.ua.configuration.hack_via_tcp?"TCP":e.ua.configuration.hack_via_ws?"WS":n.server.scheme,r="SIP/2.0/"+s,r+=" "+e.ua.configuration.via_host+";branch="+this.id,this.request.setHeader("via",r),this.request_sender.ua.newTransaction(this),this.request.cancel=function(e){l.cancel_request(l,e)},c.EventEmitter.call(this)}function s(e,t,n){var r,s;this.transport=n,this.id="z9hG4bK"+Math.floor(1e7*Math.random()),this.request_sender=e,this.request=t,s=e.ua.configuration.hack_via_tcp?"TCP":e.ua.configuration.hack_via_ws?"WS":n.server.scheme,r="SIP/2.0/"+s,r+=" "+e.ua.configuration.via_host+";branch="+this.id,this.request.setHeader("via",r),c.EventEmitter.call(this)}function l(e,t){this.type=u.NON_INVITE_SERVER,this.id=e.via_branch,this.request=e,this.transport=e.transport,this.ua=t,this.last_response="",e.server_transaction=this,this.state=u.STATUS_TRYING,t.newTransaction(this),c.EventEmitter.call(this)}function i(e,t){this.type=u.INVITE_SERVER,this.id=e.via_branch,this.request=e,this.transport=e.transport,this.ua=t,this.last_response="",e.server_transaction=this,this.state=u.STATUS_PROCEEDING,t.newTransaction(this),this.resendProvisionalTimer=null,e.reply(100),c.EventEmitter.call(this)}function o(e,t){var n;switch(t.method){case g.INVITE:if(n=e.transactions.ist[t.via_branch]){switch(n.state){case u.STATUS_PROCEEDING:n.transport.send(n.last_response);break;case u.STATUS_ACCEPTED:}return!0}break;case g.ACK:if(n=e.transactions.ist[t.via_branch],!n)return!1;if(n.state===u.STATUS_ACCEPTED)return!1;if(n.state===u.STATUS_COMPLETED)return n.state=u.STATUS_CONFIRMED,n.I=setTimeout(function(){n.timer_I()},T.TIMER_I),!0;break;case g.CANCEL:return n=e.transactions.ist[t.via_branch],n?(t.reply_sl(200),n.state===u.STATUS_PROCEEDING?!1:!0):(t.reply_sl(481),!0);default:if(n=e.transactions.nist[t.via_branch]){switch(n.state){case u.STATUS_TRYING:break;case u.STATUS_PROCEEDING:case u.STATUS_COMPLETED:n.transport.send(n.last_response)}return!0}}}t.exports={C:null,NonInviteClientTransaction:n,InviteClientTransaction:r,AckClientTransaction:s,NonInviteServerTransaction:l,InviteServerTransaction:i,checkTransaction:o};var u={STATUS_TRYING:1,STATUS_PROCEEDING:2,STATUS_CALLING:3,STATUS_ACCEPTED:4,STATUS_COMPLETED:5,STATUS_TERMINATED:6,STATUS_CONFIRMED:7,NON_INVITE_CLIENT:"nict",NON_INVITE_SERVER:"nist",INVITE_CLIENT:"ict",INVITE_SERVER:"ist"};t.exports.C=u;var a=e("util"),c=e("events"),h=e("debug")("JsSIP:NonInviteClientTransaction"),d=e("debug")("JsSIP:InviteClientTransaction"),p=e("debug")("JsSIP:AckClientTransaction"),f=e("debug")("JsSIP:NonInviteServerTransaction"),m=e("debug")("JsSIP:InviteServerTransaction"),g=e("./Constants"),T=e("./Timers");a.inherits(n,c.EventEmitter),n.prototype.stateChanged=function(e){this.state=e,this.emit("stateChanged")},n.prototype.send=function(){var e=this;this.stateChanged(u.STATUS_TRYING),this.F=setTimeout(function(){e.timer_F()},T.TIMER_F),this.transport.send(this.request)||this.onTransportError()},n.prototype.onTransportError=function(){h("transport error occurred, deleting transaction "+this.id),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(u.STATUS_TERMINATED),this.request_sender.ua.destroyTransaction(this),this.request_sender.onTransportError()},n.prototype.timer_F=function(){h("Timer F expired for transaction "+this.id),this.stateChanged(u.STATUS_TERMINATED),this.request_sender.ua.destroyTransaction(this),this.request_sender.onRequestTimeout()},n.prototype.timer_K=function(){this.stateChanged(u.STATUS_TERMINATED),this.request_sender.ua.destroyTransaction(this)},n.prototype.receiveResponse=function(e){var t=this,n=e.status_code;if(200>n)switch(this.state){case u.STATUS_TRYING:case u.STATUS_PROCEEDING:this.stateChanged(u.STATUS_PROCEEDING),this.request_sender.receiveResponse(e)}else switch(this.state){case u.STATUS_TRYING:case u.STATUS_PROCEEDING:this.stateChanged(u.STATUS_COMPLETED),clearTimeout(this.F),408===n?this.request_sender.onRequestTimeout():this.request_sender.receiveResponse(e),this.K=setTimeout(function(){t.timer_K()},T.TIMER_K);break;case u.STATUS_COMPLETED:}},a.inherits(r,c.EventEmitter),r.prototype.stateChanged=function(e){this.state=e,this.emit("stateChanged")},r.prototype.send=function(){var e=this;this.stateChanged(u.STATUS_CALLING),this.B=setTimeout(function(){e.timer_B()},T.TIMER_B),this.transport.send(this.request)||this.onTransportError()},r.prototype.onTransportError=function(){d("transport error occurred, deleting transaction "+this.id),clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==u.STATUS_ACCEPTED&&this.request_sender.onTransportError(),this.stateChanged(u.STATUS_TERMINATED),this.request_sender.ua.destroyTransaction(this)},r.prototype.timer_M=function(){d("Timer M expired for transaction "+this.id),this.state===u.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(u.STATUS_TERMINATED),this.request_sender.ua.destroyTransaction(this))},r.prototype.timer_B=function(){d("Timer B expired for transaction "+this.id),this.state===u.STATUS_CALLING&&(this.stateChanged(u.STATUS_TERMINATED),this.request_sender.ua.destroyTransaction(this),this.request_sender.onRequestTimeout())},r.prototype.timer_D=function(){d("Timer D expired for transaction "+this.id),clearTimeout(this.B),this.stateChanged(u.STATUS_TERMINATED),this.request_sender.ua.destroyTransaction(this)},r.prototype.sendACK=function(e){var t=this;this.ack="ACK "+this.request.ruri+" SIP/2.0\r\n",this.ack+="Via: "+this.request.headers.Via.toString()+"\r\n",this.request.headers.Route&&(this.ack+="Route: "+this.request.headers.Route.toString()+"\r\n"),this.ack+="To: "+e.getHeader("to")+"\r\n",this.ack+="From: "+this.request.headers.From.toString()+"\r\n",this.ack+="Call-ID: "+this.request.headers["Call-ID"].toString()+"\r\n",this.ack+="CSeq: "+this.request.headers.CSeq.toString().split(" ")[0],this.ack+=" ACK\r\n",this.ack+="Content-Length: 0\r\n\r\n",this.D=setTimeout(function(){t.timer_D()},T.TIMER_D),this.transport.send(this.ack)},r.prototype.cancel_request=function(e,t){var n=e.request;this.cancel=g.CANCEL+" "+n.ruri+" SIP/2.0\r\n",this.cancel+="Via: "+n.headers.Via.toString()+"\r\n",this.request.headers.Route&&(this.cancel+="Route: "+n.headers.Route.toString()+"\r\n"),this.cancel+="To: "+n.headers.To.toString()+"\r\n",this.cancel+="From: "+n.headers.From.toString()+"\r\n",this.cancel+="Call-ID: "+n.headers["Call-ID"].toString()+"\r\n",this.cancel+="CSeq: "+n.headers.CSeq.toString().split(" ")[0]+" CANCEL\r\n",t&&(this.cancel+="Reason: "+t+"\r\n"),this.cancel+="Content-Length: 0\r\n\r\n",this.state===u.STATUS_PROCEEDING&&this.transport.send(this.cancel)},r.prototype.receiveResponse=function(e){var t=this,n=e.status_code;if(n>=100&&199>=n)switch(this.state){case u.STATUS_CALLING:this.stateChanged(u.STATUS_PROCEEDING),this.request_sender.receiveResponse(e);break;case u.STATUS_PROCEEDING:this.request_sender.receiveResponse(e)}else if(n>=200&&299>=n)switch(this.state){case u.STATUS_CALLING:case u.STATUS_PROCEEDING:this.stateChanged(u.STATUS_ACCEPTED),this.M=setTimeout(function(){t.timer_M()},T.TIMER_M),this.request_sender.receiveResponse(e);break;case u.STATUS_ACCEPTED:this.request_sender.receiveResponse(e)}else if(n>=300&&699>=n)switch(this.state){case u.STATUS_CALLING:case u.STATUS_PROCEEDING:this.stateChanged(u.STATUS_COMPLETED),this.sendACK(e),this.request_sender.receiveResponse(e);break;case u.STATUS_COMPLETED:this.sendACK(e)}},a.inherits(s,c.EventEmitter),s.prototype.send=function(){this.transport.send(this.request)||this.onTransportError()},s.prototype.onTransportError=function(){p("transport error occurred for transaction "+this.id),this.request_sender.onTransportError()},a.inherits(l,c.EventEmitter),l.prototype.stateChanged=function(e){this.state=e,this.emit("stateChanged")},l.prototype.timer_J=function(){f("Timer J expired for transaction "+this.id),this.stateChanged(u.STATUS_TERMINATED),this.ua.destroyTransaction(this)},l.prototype.onTransportError=function(){this.transportError||(this.transportError=!0,f("transport error occurred, deleting transaction "+this.id),clearTimeout(this.J),this.stateChanged(u.STATUS_TERMINATED),this.ua.destroyTransaction(this))},l.prototype.receiveResponse=function(e,t,n,r){var s=this;if(100===e)switch(this.state){case u.STATUS_TRYING:this.stateChanged(u.STATUS_PROCEEDING),this.transport.send(t)||this.onTransportError();break;case u.STATUS_PROCEEDING:this.last_response=t,this.transport.send(t)?n&&n():(this.onTransportError(),r&&r())}else if(e>=200&&699>=e)switch(this.state){case u.STATUS_TRYING:case u.STATUS_PROCEEDING:this.stateChanged(u.STATUS_COMPLETED),this.last_response=t,this.J=setTimeout(function(){s.timer_J()},T.TIMER_J),this.transport.send(t)?n&&n():(this.onTransportError(),r&&r());break;case u.STATUS_COMPLETED:}},a.inherits(i,c.EventEmitter),i.prototype.stateChanged=function(e){this.state=e,this.emit("stateChanged")},i.prototype.timer_H=function(){m("Timer H expired for transaction "+this.id),this.state===u.STATUS_COMPLETED&&m("ACK not received, dialog will be terminated"),this.stateChanged(u.STATUS_TERMINATED),this.ua.destroyTransaction(this)},i.prototype.timer_I=function(){this.stateChanged(u.STATUS_TERMINATED),this.ua.destroyTransaction(this)},i.prototype.timer_L=function(){m("Timer L expired for transaction "+this.id),this.state===u.STATUS_ACCEPTED&&(this.stateChanged(u.STATUS_TERMINATED),this.ua.destroyTransaction(this))},i.prototype.onTransportError=function(){this.transportError||(this.transportError=!0,m("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(u.STATUS_TERMINATED),this.ua.destroyTransaction(this))},i.prototype.resend_provisional=function(){this.transport.send(this.last_response)||this.onTransportError()},i.prototype.receiveResponse=function(e,t,n,r){var s=this;if(e>=100&&199>=e)switch(this.state){case u.STATUS_PROCEEDING:this.transport.send(t)||this.onTransportError(),this.last_response=t}if(e>100&&199>=e&&this.state===u.STATUS_PROCEEDING)null===this.resendProvisionalTimer&&(this.resendProvisionalTimer=setInterval(function(){s.resend_provisional()},T.PROVISIONAL_RESPONSE_INTERVAL));else if(e>=200&&299>=e)switch(this.state){case u.STATUS_PROCEEDING:this.stateChanged(u.STATUS_ACCEPTED),this.last_response=t,this.L=setTimeout(function(){s.timer_L()},T.TIMER_L),null!==this.resendProvisionalTimer&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case u.STATUS_ACCEPTED:this.transport.send(t)?n&&n():(this.onTransportError(),r&&r())}else if(e>=300&&699>=e)switch(this.state){case u.STATUS_PROCEEDING:null!==this.resendProvisionalTimer&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(t)?(this.stateChanged(u.STATUS_COMPLETED),this.H=setTimeout(function(){s.timer_H()},T.TIMER_H),n&&n()):(this.onTransportError(),r&&r())}}},{"./Constants":1,"./Timers":17,debug:29,events:24,util:28}],19:[function(e,t){function n(e,t){this.ua=e,this.ws=null,this.server=t,this.reconnection_attempts=0,this.closed=!1,this.connected=!1,this.reconnectTimer=null,this.lastTransportError={},this.node_websocket_options=this.ua.configuration.node_websocket_options||{},this.node_websocket_options.headers=this.node_websocket_options.headers||{},this.node_websocket_options.headers["User-Agent"]=l.USER_AGENT
  }t.exports=n;var r={STATUS_READY:0,STATUS_DISCONNECTED:1,STATUS_ERROR:2};n.C=r;var s=e("debug")("JsSIP:Transport"),l=e("./Constants"),i=e("./Parser"),o=e("./UA"),u=e("./SIPMessage"),a=e("./sanityCheck"),c=e("websocket").w3cwebsocket;n.prototype={connect:function(){var e=this;if(this.ws&&(this.ws.readyState===this.ws.OPEN||this.ws.readyState===this.ws.CONNECTING))return s("WebSocket "+this.server.ws_uri+" is already connected"),!1;this.ws&&this.ws.close(),s("connecting to WebSocket "+this.server.ws_uri),this.ua.onTransportConnecting(this,0===this.reconnection_attempts?1:this.reconnection_attempts);try{this.ws=new c(this.server.ws_uri,"sip",this.node_websocket_options.origin,this.node_websocket_options.headers,this.node_websocket_options.requestOptions,this.node_websocket_options.clientConfig),this.ws.binaryType="arraybuffer",this.ws.onopen=function(){e.onOpen()},this.ws.onclose=function(t){e.onClose(t)},this.ws.onmessage=function(t){e.onMessage(t)},this.ws.onerror=function(t){e.onError(t)}}catch(t){s("error connecting to WebSocket "+this.server.ws_uri+": "+t),this.lastTransportError.code=null,this.lastTransportError.reason=t.message,this.ua.onTransportError(this)}},disconnect:function(){this.ws&&(clearTimeout(this.reconnectTimer),this.closed=!0,s("closing WebSocket "+this.server.ws_uri),this.ws.close()),null!==this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.ua.onTransportDisconnected({transport:this,code:this.lastTransportError.code,reason:this.lastTransportError.reason}))},send:function(e){var t=e.toString();return this.ws&&this.ws.readyState===this.ws.OPEN?(s("sending WebSocket message:\n\n"+t+"\n"),this.ws.send(t),!0):(s("unable to send message, WebSocket is not open"),!1)},onOpen:function(){this.connected=!0,s("WebSocket "+this.server.ws_uri+" connected"),null!==this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.reconnection_attempts=0,this.closed=!1,this.ua.onTransportConnected(this)},onClose:function(e){var t=this.connected;this.connected=!1,this.lastTransportError.code=e.code,this.lastTransportError.reason=e.reason,s("WebSocket disconnected (code: "+e.code+(e.reason?"| reason: "+e.reason:"")+")"),e.wasClean===!1&&s("WebSocket abrupt disconnection"),t===!0?(this.ua.onTransportClosed(this),this.closed?this.ua.emit("disconnected",this.ua,{transport:this,code:this.lastTransportError.code,reason:this.lastTransportError.reason}):this.reConnect()):this.ua.onTransportError(this)},onMessage:function(e){var t,n,r=e.data;if("\r\n"===r)return void s("received WebSocket message with CRLF Keep Alive response");if("string"!=typeof r){try{r=String.fromCharCode.apply(null,new Uint8Array(r))}catch(c){return void s("received WebSocket binary message failed to be converted into string, message discarded")}s("received WebSocket binary message:\n\n"+r+"\n")}else s("received WebSocket text message:\n\n"+r+"\n");if(t=i.parseMessage(r,this.ua),t&&!(this.ua.status===o.C.STATUS_USER_CLOSED&&t instanceof u.IncomingRequest)&&a(t,this.ua,this))if(t instanceof u.IncomingRequest)t.transport=this,this.ua.receiveRequest(t);else if(t instanceof u.IncomingResponse)switch(t.method){case l.INVITE:n=this.ua.transactions.ict[t.via_branch],n&&n.receiveResponse(t);break;case l.ACK:break;default:n=this.ua.transactions.nict[t.via_branch],n&&n.receiveResponse(t)}},onError:function(e){s("WebSocket connection error: "+e)},reConnect:function(){var e=this;this.reconnection_attempts+=1,this.reconnection_attempts>this.ua.configuration.ws_server_max_reconnection?(s("maximum reconnection attempts for WebSocket "+this.server.ws_uri),this.ua.onTransportError(this)):(s("trying to reconnect to WebSocket "+this.server.ws_uri+" (reconnection attempt "+this.reconnection_attempts+")"),this.reconnectTimer=setTimeout(function(){e.connect(),e.reconnectTimer=null},1e3*this.ua.configuration.ws_server_reconnection_timeout))}}},{"./Constants":1,"./Parser":10,"./SIPMessage":16,"./UA":20,"./sanityCheck":23,debug:29,websocket:43}],20:[function(e,t){function n(e){if(this.cache={credentials:{}},this.configuration={},this.dynConfiguration={},this.dialogs={},this.applicants={},this.sessions={},this.transport=null,this.contact=null,this.status=r.STATUS_INIT,this.error=null,this.transactions={nist:{},nict:{},ist:{},ict:{}},this.data={},this.transportRecoverAttempts=0,this.transportRecoveryTimer=null,Object.defineProperties(this,{transactionsCount:{get:function(){var e,t=["nist","nict","ist","ict"],n=0;for(e in t)n+=Object.keys(this.transactions[t[e]]).length;return n}},nictTransactionsCount:{get:function(){return Object.keys(this.transactions.nict).length}},nistTransactionsCount:{get:function(){return Object.keys(this.transactions.nist).length}},ictTransactionsCount:{get:function(){return Object.keys(this.transactions.ict).length}},istTransactionsCount:{get:function(){return Object.keys(this.transactions.ist).length}}}),void 0===e)throw new TypeError("Not enough arguments");try{this.loadConfig(e)}catch(t){throw this.status=r.STATUS_NOT_READY,this.error=r.CONFIGURATION_ERROR,t}this._registrator=new a(this),l.EventEmitter.call(this)}t.exports=n;var r={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2};n.C=r;var s=e("util"),l=e("events"),i=e("debug")("JsSIP:UA"),o=e("rtcninja"),u=e("./Constants"),a=e("./Registrator"),c=e("./RTCSession"),h=e("./Message"),d=e("./Transport"),p=e("./Transactions"),p=e("./Transactions"),f=e("./Utils"),m=e("./Exceptions"),g=e("./URI"),T=e("./Grammar");s.inherits(n,l.EventEmitter),n.prototype.start=function(){var e;i("user requested startup"),this.status===r.STATUS_INIT?(e=this.getNextWsServer(),this.transport=new d(this,e),this.transport.connect()):this.status===r.STATUS_USER_CLOSED?(i("restarting UA"),this.status=r.STATUS_READY,this.transport.connect()):i(this.status===r.STATUS_READY?"UA is in READY status, not restarted":"ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this.dynConfiguration.register=this.configuration.register},n.prototype.register=function(){this.dynConfiguration.register=!0,this._registrator.register()},n.prototype.unregister=function(e){this.dynConfiguration.register=!1,this._registrator.unregister(e)},n.prototype.registrator=function(){return this._registrator},n.prototype.isRegistered=function(){return this._registrator.registered?!0:!1},n.prototype.isConnected=function(){return this.transport?this.transport.connected:!1},n.prototype.call=function(e,t){var n;n=new c(this),n.connect(e,t)},n.prototype.sendMessage=function(e,t,n){var r;r=new h(this),r.send(e,t,n)},n.prototype.terminateSessions=function(e){for(var t in this.sessions)this.sessions[t].isEnded()||this.sessions[t].terminate(e)},n.prototype.stop=function(){var e,t,n,s=this;if(i("user requested closure"),this.dynConfiguration={},this.status===r.STATUS_USER_CLOSED)return void i("UA already closed");clearTimeout(this.transportRecoveryTimer),this._registrator.close(),n=Object.keys(this.sessions).length;for(e in this.sessions)i("closing session "+e),this.sessions[e].terminate();for(t in this.applicants)this.applicants[t].close();this.status=r.STATUS_USER_CLOSED,0===this.nistTransactionsCount&&0===this.nictTransactionsCount&&0===n?s.transport.disconnect():setTimeout(function(){s.transport.disconnect()},2e3)},n.prototype.normalizeTarget=function(e){return f.normalizeTarget(e,this.configuration.hostport_params)},n.prototype.saveCredentials=function(e){this.cache.credentials[e.realm]=this.cache.credentials[e.realm]||{},this.cache.credentials[e.realm][e.uri]=e},n.prototype.getCredentials=function(e){var t,n;return t=e.ruri.host,this.cache.credentials[t]&&this.cache.credentials[t][e.ruri]&&(n=this.cache.credentials[t][e.ruri],n.method=e.method),n},n.prototype.onTransportClosed=function(e){var t,n,r,s=["nict","ict","nist","ist"];for(e.server.status=d.C.STATUS_DISCONNECTED,i("connection state set to "+d.C.STATUS_DISCONNECTED),r=s.length,t=0;r>t;t++)for(n in this.transactions[s[t]])this.transactions[s[t]][n].onTransportError();this.emit("disconnected")},n.prototype.onTransportError=function(e){var t;i("transport "+e.server.ws_uri+" failed | connection state set to "+d.C.STATUS_ERROR),e.server.status=d.C.STATUS_ERROR,this.emit("disconnected",{transport:e,code:e.lastTransportError.code,reason:e.lastTransportError.reason}),this.status!==r.STATUS_USER_CLOSED&&(t=this.getNextWsServer(),t?(this.transport=new d(this,t),this.transport.connect()):(this.closeSessionsOnTransportError(),this.error&&this.error===r.NETWORK_ERROR||(this.status=r.STATUS_NOT_READY,this.error=r.NETWORK_ERROR),this.recoverTransport()))},n.prototype.onTransportConnected=function(e){this.transport=e,this.transportRecoverAttempts=0,e.server.status=d.C.STATUS_READY,i("connection state set to "+d.C.STATUS_READY),this.status!==r.STATUS_USER_CLOSED&&(this.status=r.STATUS_READY,this.error=null,this.emit("connected",{transport:e}),this.dynConfiguration.register&&this._registrator.register())},n.prototype.onTransportConnecting=function(e,t){this.emit("connecting",{transport:e,attempts:t})},n.prototype.onTransportDisconnected=function(e){this.emit("disconnected",e)},n.prototype.newTransaction=function(e){this.transactions[e.type][e.id]=e,this.emit("newTransaction",{transaction:e})},n.prototype.destroyTransaction=function(e){delete this.transactions[e.type][e.id],this.emit("transactionDestroyed",{transaction:e})},n.prototype.newMessage=function(e){this.emit("newMessage",e)},n.prototype.newRTCSession=function(e){this.emit("newRTCSession",e)},n.prototype.registered=function(e){this.emit("registered",e)},n.prototype.unregistered=function(e){this.emit("unregistered",e)},n.prototype.registrationFailed=function(e){this.emit("registrationFailed",e)},n.prototype.receiveRequest=function(e){var t,n,r,s=e.method;if(e.ruri.user!==this.configuration.uri.user&&e.ruri.user!==this.contact.uri.user)return i("Request-URI does not point to us"),void(e.method!==u.ACK&&e.reply_sl(404));if(e.ruri.scheme===u.SIPS)return void e.reply_sl(416);if(!p.checkTransaction(this,e)){if(s===u.INVITE?new p.InviteServerTransaction(e,this):s!==u.ACK&&s!==u.CANCEL&&new p.NonInviteServerTransaction(e,this),s===u.OPTIONS)e.reply(200);else if(s===u.MESSAGE){if(0===this.listeners("newMessage").length)return void e.reply(405);r=new h(this),r.init_incoming(e)}else if(s===u.INVITE&&0===this.listeners("newRTCSession").length)return void e.reply(405);if(e.to_tag)t=this.findDialog(e),t?t.receiveRequest(e):s===u.NOTIFY?(n=this.findSession(e),n?n.receiveRequest(e):(i("received NOTIFY request for a non existent subscription"),e.reply(481,"Subscription does not exist"))):s!==u.ACK&&e.reply(481);else switch(s){case u.INVITE:o.hasWebRTC()?(n=new c(this),n.init_incoming(e)):(i("INVITE received but WebRTC is not supported"),e.reply(488));break;case u.BYE:e.reply(481);break;case u.CANCEL:n=this.findSession(e),n?n.receiveRequest(e):i("received CANCEL request for a non existent session");break;case u.ACK:break;default:e.reply(405)}}},n.prototype.findSession=function(e){var t=e.call_id+e.from_tag,n=this.sessions[t],r=e.call_id+e.to_tag,s=this.sessions[r];return n?n:s?s:null},n.prototype.findDialog=function(e){var t=e.call_id+e.from_tag+e.to_tag,n=this.dialogs[t];return n?n:(t=e.call_id+e.to_tag+e.from_tag,n=this.dialogs[t],n?n:null)},n.prototype.getNextWsServer=function(){var e,t,n,r=[];for(t=this.configuration.ws_servers.length,e=0;t>e;e++)n=this.configuration.ws_servers[e],n.status!==d.C.STATUS_ERROR&&(0===r.length?r.push(n):n.weight>r[0].weight?r=[n]:n.weight===r[0].weight&&r.push(n));return e=Math.floor(Math.random()*r.length),r[e]},n.prototype.closeSessionsOnTransportError=function(){var e;for(e in this.sessions)this.sessions[e].onTransportError();this._registrator.onTransportClosed()},n.prototype.recoverTransport=function(e){var t,n,r,s,l,o;for(e=e||this,l=e.transportRecoverAttempts,n=e.configuration.ws_servers.length,t=0;n>t;t++)e.configuration.ws_servers[t].status=0;o=e.getNextWsServer(),r=Math.floor(Math.random()*Math.pow(2,l)+1),s=r*e.configuration.connection_recovery_min_interval,s>e.configuration.connection_recovery_max_interval&&(i("time for next connection attempt exceeds connection_recovery_max_interval, resetting counter"),s=e.configuration.connection_recovery_min_interval,l=0),i("next connection attempt in "+s+" seconds"),this.transportRecoveryTimer=setTimeout(function(){e.transportRecoverAttempts=l+1,e.transport=new d(e,o),e.transport.connect()},1e3*s)},n.prototype.loadConfig=function(e){var t,r,s,l,o,u={via_host:f.createRandomToken(12)+".invalid",password:null,register_expires:600,register:!0,registrar_server:null,ws_server_max_reconnection:3,ws_server_reconnection_timeout:4,connection_recovery_min_interval:2,connection_recovery_max_interval:30,use_preloaded_route:!1,no_answer_timeout:60,session_timers:!0,hack_via_tcp:!1,hack_via_ws:!1,hack_ip_in_contact:!1,node_websocket_options:{}};for(t in n.configuration_check.mandatory){if(!e.hasOwnProperty(t))throw new m.ConfigurationError(t);if(r=e[t],s=n.configuration_check.mandatory[t].call(this,r),void 0===s)throw new m.ConfigurationError(t,r);u[t]=s}for(t in n.configuration_check.optional)if(e.hasOwnProperty(t)){if(r=e[t],f.isEmpty(r))continue;if(s=n.configuration_check.optional[t].call(this,r),void 0===s)throw new m.ConfigurationError(t,r);u[t]=s}if(u.connection_recovery_max_interval<u.connection_recovery_min_interval)throw new m.ConfigurationError("connection_recovery_max_interval",u.connection_recovery_max_interval);0===u.display_name&&(u.display_name="0"),u.instance_id||(u.instance_id=f.newUUID()),u.jssip_id=f.createRandomToken(5),l=u.uri.clone(),l.user=null,u.hostport_params=l.toString().replace(/^sip:/i,""),u.authorization_user||(u.authorization_user=u.uri.user),u.registrar_server||(o=u.uri.clone(),o.user=null,u.registrar_server=o),u.no_answer_timeout=1e3*u.no_answer_timeout,u.hack_ip_in_contact&&(u.via_host=f.getRandomTestNetIP()),this.contact={pub_gruu:null,temp_gruu:null,uri:new g("sip",f.createRandomToken(8),u.via_host,null,{transport:"ws"}),toString:function(e){e=e||{};var 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+=">"}};for(t in u)n.configuration_skeleton[t].value=u[t];Object.defineProperties(this.configuration,n.configuration_skeleton);for(t in u)n.configuration_skeleton[t].value="";i("configuration parameters after validation:");for(t in u)switch(t){case"uri":case"registrar_server":i("- "+t+": "+u[t]);break;case"password":i("- "+t+": NOT SHOWN");break;default:i("- "+t+": "+JSON.stringify(u[t]))}},n.configuration_skeleton=function(){var e,t,n={},r=["jssip_id","ws_server_max_reconnection","ws_server_reconnection_timeout","hostport_params","uri","ws_servers","authorization_user","connection_recovery_max_interval","connection_recovery_min_interval","display_name","hack_via_tcp","hack_via_ws","hack_ip_in_contact","instance_id","no_answer_timeout","session_timers","node_websocket_options","password","register_expires","registrar_server","use_preloaded_route","via_core_value","via_host"];for(e in r)t=r[e],n[t]={value:"",writable:!1,configurable:!1};return n.register={value:"",writable:!0,configurable:!1},n}(),n.configuration_check={mandatory:{uri:function(e){var t;return/^sip:/i.test(e)||(e=u.SIP+":"+e),t=g.parse(e),t&&t.user?t:void 0},ws_servers:function(e){var t,n,r;if("string"==typeof e)e=[{ws_uri:e}];else{if(!Array.isArray(e))return;for(n=e.length,t=0;n>t;t++)"string"==typeof e[t]&&(e[t]={ws_uri:e[t]})}if(0===e.length)return!1;for(n=e.length,t=0;n>t;t++){if(!e[t].ws_uri)return void i('ERROR: missing "ws_uri" attribute in ws_servers parameter');if(e[t].weight&&!Number(e[t].weight))return void i('ERROR: "weight" attribute in ws_servers parameter must be a Number');if(r=T.parse(e[t].ws_uri,"absoluteURI"),-1===r)return void i('ERROR: invalid "ws_uri" attribute in ws_servers parameter: '+e[t].ws_uri);if("wss"!==r.scheme&&"ws"!==r.scheme)return void i("ERROR: invalid URI scheme in ws_servers parameter: "+r.scheme);e[t].sip_uri="<sip:"+r.host+(r.port?":"+r.port:"")+";transport=ws;lr>",e[t].weight||(e[t].weight=0),e[t].status=0,e[t].scheme=r.scheme.toUpperCase()}return e}},optional:{authorization_user:function(e){return-1===T.parse('"'+e+'"',"quoted_string")?void 0:e},connection_recovery_max_interval:function(e){var t;return f.isDecimal(e)&&(t=Number(e),t>0)?t:void 0},connection_recovery_min_interval:function(e){var t;return f.isDecimal(e)&&(t=Number(e),t>0)?t:void 0},display_name:function(e){return-1===T.parse('"'+e+'"',"display_name")?void 0:e},hack_via_tcp:function(e){return"boolean"==typeof e?e:void 0},hack_via_ws:function(e){return"boolean"==typeof e?e:void 0},hack_ip_in_contact:function(e){return"boolean"==typeof e?e:void 0},instance_id:function(e){return/^uuid:/i.test(e)&&(e=e.substr(5)),-1===T.parse(e,"uuid")?void 0:e},no_answer_timeout:function(e){var t;return f.isDecimal(e)&&(t=Number(e),t>0)?t:void 0},session_timers:function(e){return"boolean"==typeof e?e:void 0},node_websocket_options:function(e){return"object"==typeof e?e:{}},password:function(e){return String(e)},register:function(e){return"boolean"==typeof e?e:void 0},register_expires:function(e){var t;return f.isDecimal(e)&&(t=Number(e),t>0)?t:void 0},registrar_server:function(e){var t;return/^sip:/i.test(e)||(e=u.SIP+":"+e),t=g.parse(e),t?t.user?void 0:t:void 0},use_preloaded_route:function(e){return"boolean"==typeof e?e:void 0}}}},{"./Constants":1,"./Exceptions":5,"./Grammar":6,"./Message":8,"./RTCSession":11,"./Registrator":14,"./Transactions":18,"./Transport":19,"./URI":21,"./Utils":22,debug:29,events:24,rtcninja:34,util:28}],21:[function(e,t){function n(e,t,n,s,l,i){var o,u;if(!n)throw new TypeError('missing or invalid "host" parameter');e=e||r.SIP,this.parameters={},this.headers={};for(o in l)this.setParam(o,l[o]);for(u in i)this.setHeader(u,i[u]);Object.defineProperties(this,{scheme:{get:function(){return e},set:function(t){e=t.toLowerCase()}},user:{get:function(){return t},set:function(e){t=e}},host:{get:function(){return n},set:function(e){n=e.toLowerCase()}},port:{get:function(){return s},set:function(e){s=0===e?e:parseInt(e,10)||null}}})}t.exports=n;var r=e("./Constants"),s=e("./Utils"),l=e("./Grammar");n.prototype={setParam:function(e,t){e&&(this.parameters[e.toLowerCase()]="undefined"==typeof t||null===t?null:t.toString().toLowerCase())},getParam:function(e){return e?this.parameters[e.toLowerCase()]:void 0},hasParam:function(e){return e?this.parameters.hasOwnProperty(e.toLowerCase())&&!0||!1:void 0},deleteParam:function(e){var t;return e=e.toLowerCase(),this.parameters.hasOwnProperty(e)?(t=this.parameters[e],delete this.parameters[e],t):void 0},clearParams:function(){this.parameters={}},setHeader:function(e,t){this.headers[s.headerize(e)]=Array.isArray(t)?t:[t]},getHeader:function(e){return e?this.headers[s.headerize(e)]:void 0},hasHeader:function(e){return e?this.headers.hasOwnProperty(s.headerize(e))&&!0||!1:void 0},deleteHeader:function(e){var t;return e=s.headerize(e),this.headers.hasOwnProperty(e)?(t=this.headers[e],delete this.headers[e],t):void 0},clearHeaders:function(){this.headers={}},clone:function(){return new n(this.scheme,this.user,this.host,this.port,JSON.parse(JSON.stringify(this.parameters)),JSON.parse(JSON.stringify(this.headers)))},toString:function(){var e,t,n,r,l=[];r=this.scheme+":",this.user&&(r+=s.escapeUser(this.user)+"@"),r+=this.host,(this.port||0===this.port)&&(r+=":"+this.port);for(t in this.parameters)r+=";"+t,null!==this.parameters[t]&&(r+="="+this.parameters[t]);for(e in this.headers)for(n in this.headers[e])l.push(e+"="+this.headers[e][n]);return l.length>0&&(r+="?"+l.join("&")),r},toAor:function(e){var t;return t=this.scheme+":",this.user&&(t+=s.escapeUser(this.user)+"@"),t+=this.host,e&&(this.port||0===this.port)&&(t+=":"+this.port),t}},n.parse=function(e){return e=l.parse(e,"SIP_URI"),-1!==e?e:void 0}},{"./Constants":1,"./Grammar":6,"./Utils":22}],22:[function(e,t){var n={};t.exports=n;var r=e("./Constants"),s=e("./URI"),l=e("./Grammar");n.str_utf8_length=function(e){return unescape(encodeURIComponent(e)).length},n.isFunction=function(e){return void 0!==e&&"[object Function]"===Object.prototype.toString.call(e)?!0:!1},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)?!0:void 0},n.createRandomToken=function(e,t){var n,r,s="";for(t=t||32,n=0;e>n;n++)r=Math.random()*t|0,s+=r.toString(t);return s},n.newTag=function(){return n.createRandomToken(10)},n.newUUID=function(){var e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0,n="x"===e?t:3&t|8;return n.toString(16)});return e},n.hostType=function(e){return e?(e=l.parse(e,"host"),-1!==e?e.host_type:void 0):void 0},n.normalizeTarget=function(e,t){var l,i,o,u;if(e){if(e instanceof s)return e;if("string"==typeof e){switch(i=e.split("@"),i.length){case 1:if(!t)return;o=e,u=t;break;case 2:o=i[0],u=i[1];break;default:o=i.slice(0,i.length-1).join("@"),u=i[i.length-1]}return o=o.replace(/^(sips?|tel):/i,""),/^[\-\.\(\)]*\+?[0-9\-\.\(\)]+$/.test(o)&&(o=o.replace(/[\-\.\(\)]/g,"")),e=r.SIP+":"+n.escapeUser(o)+"@"+u,(l=s.parse(e))?l:void 0}}else;},n.escapeUser=function(e){return encodeURIComponent(decodeURIComponent(e)).replace(/%3A/gi,":").replace(/%2B/gi,"+").replace(/%3F/gi,"?").replace(/%2F/gi,"/")},n.headerize=function(e){var t,n={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},r=e.toLowerCase().replace(/_/g,"-").split("-"),s="",l=r.length;for(t=0;l>t;t++)0!==t&&(s+="-"),s+=r[t].charAt(0).toUpperCase()+r[t].substring(1);return n[s]&&(s=n[s]),s},n.sipErrorCause=function(e){var t;for(t in r.SIP_ERROR_CAUSES)if(-1!==r.SIP_ERROR_CAUSES[t].indexOf(e))return r.causes[t];return r.causes.SIP_FAILURE_CODE},n.getRandomTestNetIP=function(){function e(e,t){return Math.floor(Math.random()*(t-e+1)+e)}return"192.0.2."+e(1,254)},n.calculateMD5=function(e){function t(e,t){return e<<t|e>>>32-t}function n(e,t){var n,r,s,l,i;return s=2147483648&e,l=2147483648&t,n=1073741824&e,r=1073741824&t,i=(1073741823&e)+(1073741823&t),n&r?2147483648^i^s^l:n|r?1073741824&i?3221225472^i^s^l:1073741824^i^s^l:i^s^l}function r(e,t,n){return e&t|~e&n}function s(e,t,n){return e&n|t&~n}function l(e,t,n){return e^t^n}function i(e,t,n){return t^(e|~n)}function o(e,s,l,i,o,u,a){return e=n(e,n(n(r(s,l,i),o),a)),n(t(e,u),s)}function u(e,r,l,i,o,u,a){return e=n(e,n(n(s(r,l,i),o),a)),n(t(e,u),r)}function a(e,r,s,i,o,u,a){return e=n(e,n(n(l(r,s,i),o),a)),n(t(e,u),r)}function c(e,r,s,l,o,u,a){return e=n(e,n(n(i(r,s,l),o),a)),n(t(e,u),r)}function h(e){for(var t,n=e.length,r=n+8,s=(r-r%64)/64,l=16*(s+1),i=new Array(l-1),o=0,u=0;n>u;)t=(u-u%4)/4,o=u%4*8,i[t]=i[t]|e.charCodeAt(u)<<o,u++;return t=(u-u%4)/4,o=u%4*8,i[t]=i[t]|128<<o,i[l-2]=n<<3,i[l-1]=n>>>29,i}function d(e){var t,n,r="",s="";for(n=0;3>=n;n++)t=e>>>8*n&255,s="0"+t.toString(16),r+=s.substr(s.length-2,2);return r}function p(e){e=e.replace(/\r\n/g,"\n");for(var t="",n=0;n<e.length;n++){var r=e.charCodeAt(n);128>r?t+=String.fromCharCode(r):r>127&&2048>r?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(63&r|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(63&r|128))}return t}var f,m,g,T,_,v,C,S,E,A=[],R=7,y=12,b=17,I=22,w=5,N=9,D=14,U=20,O=4,x=11,P=16,M=23,L=6,q=10,k=15,H=21;for(e=p(e),A=h(e),v=1732584193,C=4023233417,S=2562383102,E=271733878,f=0;f<A.length;f+=16)m=v,g=C,T=S,_=E,v=o(v,C,S,E,A[f+0],R,3614090360),E=o(E,v,C,S,A[f+1],y,3905402710),S=o(S,E,v,C,A[f+2],b,606105819),C=o(C,S,E,v,A[f+3],I,3250441966),v=o(v,C,S,E,A[f+4],R,4118548399),E=o(E,v,C,S,A[f+5],y,1200080426),S=o(S,E,v,C,A[f+6],b,2821735955),C=o(C,S,E,v,A[f+7],I,4249261313),v=o(v,C,S,E,A[f+8],R,1770035416),E=o(E,v,C,S,A[f+9],y,2336552879),S=o(S,E,v,C,A[f+10],b,4294925233),C=o(C,S,E,v,A[f+11],I,2304563134),v=o(v,C,S,E,A[f+12],R,1804603682),E=o(E,v,C,S,A[f+13],y,4254626195),S=o(S,E,v,C,A[f+14],b,2792965006),C=o(C,S,E,v,A[f+15],I,1236535329),v=u(v,C,S,E,A[f+1],w,4129170786),E=u(E,v,C,S,A[f+6],N,3225465664),S=u(S,E,v,C,A[f+11],D,643717713),C=u(C,S,E,v,A[f+0],U,3921069994),v=u(v,C,S,E,A[f+5],w,3593408605),E=u(E,v,C,S,A[f+10],N,38016083),S=u(S,E,v,C,A[f+15],D,3634488961),C=u(C,S,E,v,A[f+4],U,3889429448),v=u(v,C,S,E,A[f+9],w,568446438),E=u(E,v,C,S,A[f+14],N,3275163606),S=u(S,E,v,C,A[f+3],D,4107603335),C=u(C,S,E,v,A[f+8],U,1163531501),v=u(v,C,S,E,A[f+13],w,2850285829),E=u(E,v,C,S,A[f+2],N,4243563512),S=u(S,E,v,C,A[f+7],D,1735328473),C=u(C,S,E,v,A[f+12],U,2368359562),v=a(v,C,S,E,A[f+5],O,4294588738),E=a(E,v,C,S,A[f+8],x,2272392833),S=a(S,E,v,C,A[f+11],P,1839030562),C=a(C,S,E,v,A[f+14],M,4259657740),v=a(v,C,S,E,A[f+1],O,2763975236),E=a(E,v,C,S,A[f+4],x,1272893353),S=a(S,E,v,C,A[f+7],P,4139469664),C=a(C,S,E,v,A[f+10],M,3200236656),v=a(v,C,S,E,A[f+13],O,681279174),E=a(E,v,C,S,A[f+0],x,3936430074),S=a(S,E,v,C,A[f+3],P,3572445317),C=a(C,S,E,v,A[f+6],M,76029189),v=a(v,C,S,E,A[f+9],O,3654602809),E=a(E,v,C,S,A[f+12],x,3873151461),S=a(S,E,v,C,A[f+15],P,530742520),C=a(C,S,E,v,A[f+2],M,3299628645),v=c(v,C,S,E,A[f+0],L,4096336452),E=c(E,v,C,S,A[f+7],q,1126891415),S=c(S,E,v,C,A[f+14],k,2878612391),C=c(C,S,E,v,A[f+5],H,4237533241),v=c(v,C,S,E,A[f+12],L,1700485571),E=c(E,v,C,S,A[f+3],q,2399980690),S=c(S,E,v,C,A[f+10],k,4293915773),C=c(C,S,E,v,A[f+1],H,2240044497),v=c(v,C,S,E,A[f+8],L,1873313359),E=c(E,v,C,S,A[f+15],q,4264355552),S=c(S,E,v,C,A[f+6],k,2734768916),C=c(C,S,E,v,A[f+13],H,1309151649),v=c(v,C,S,E,A[f+4],L,4149444226),E=c(E,v,C,S,A[f+11],q,3174756917),S=c(S,E,v,C,A[f+2],k,718787259),C=c(C,S,E,v,A[f+9],H,3951481745),v=n(v,m),C=n(C,g),S=n(S,T),E=n(E,_);var F=d(v)+d(C)+d(S)+d(E);return F.toLowerCase()}},{"./Constants":1,"./Grammar":6,"./URI":21}],23:[function(e,t){function n(e,t,n){var r,s;for(h=e,d=t,p=n,r=C.length;r--;)if(s=C[r](h),s===!1)return!1;if(h instanceof g.IncomingRequest){for(r=_.length;r--;)if(s=_[r](h),s===!1)return!1}else if(h instanceof g.IncomingResponse)for(r=v.length;r--;)if(s=v[r](h),s===!1)return!1;return!0}function r(){return"sip"!==h.s("to").uri.scheme?(c(416),!1):void 0}function s(){return h.to_tag||h.call_id.substr(0,5)!==d.configuration.jssip_id?void 0:(c(482),!1)}function l(){var e=T.str_utf8_length(h.body),t=h.getHeader("content-length");return t>e?(c(400),!1):void 0}function i(){var e,t,n=h.from_tag,r=h.call_id,s=h.cseq;if(!h.to_tag)if(h.method===m.INVITE){if(d.transactions.ist[h.via_branch])return!1;for(t in d.transactions.ist)if(e=d.transactions.ist[t],e.request.from_tag===n&&e.request.call_id===r&&e.request.cseq===s)return c(482),!1}else{if(d.transactions.nist[h.via_branch])return!1;for(t in d.transactions.nist)if(e=d.transactions.nist[t],e.request.from_tag===n&&e.request.call_id===r&&e.request.cseq===s)return c(482),!1}}function o(){return h.getHeaders("via").length>1?(f("more than one Via header field present in the response, dropping the response"),!1):void 0}function u(){var e=T.str_utf8_length(h.body),t=h.getHeader("content-length");return t>e?(f("message body length is lower than the value in Content-Length header field, dropping the response"),!1):void 0}function a(){for(var e=["from","to","call_id","cseq","via"],t=e.length;t--;)if(!h.hasHeader(e[t]))return f("missing mandatory header field : "+e[t]+", dropping the response"),!1}function c(e){var t,n="SIP/2.0 "+e+" "+m.REASON_PHRASE[e]+"\r\n",r=h.getHeaders("via"),s=r.length,l=0;for(l;s>l;l++)n+="Via: "+r[l]+"\r\n";t=h.getHeader("To"),h.to_tag||(t+=";tag="+T.newTag()),n+="To: "+t+"\r\n",n+="From: "+h.getHeader("From")+"\r\n",n+="Call-ID: "+h.call_id+"\r\n",n+="CSeq: "+h.cseq+" "+h.method+"\r\n",n+="\r\n",p.send(n)}t.exports=n;var h,d,p,f=e("debug")("JsSIP:sanityCheck"),m=e("./Constants"),g=e("./SIPMessage"),T=e("./Utils"),_=[],v=[],C=[];_.push(r),_.push(s),_.push(l),_.push(i),v.push(o),v.push(u),C.push(a)},{"./Constants":1,"./SIPMessage":16,"./Utils":22,debug:29}],24:[function(e,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(e){return"function"==typeof e}function s(e){return"number"==typeof e}function l(e){return"object"==typeof e&&null!==e}function i(e){return void 0===e}t.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!s(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,n,s,o,u,a;if(this._events||(this._events={}),"error"===e&&(!this._events.error||l(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(n=this._events[e],i(n))return!1;if(r(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:for(s=arguments.length,o=new Array(s-1),u=1;s>u;u++)o[u-1]=arguments[u];n.apply(this,o)}else if(l(n)){for(s=arguments.length,o=new Array(s-1),u=1;s>u;u++)o[u-1]=arguments[u];for(a=n.slice(),s=a.length,u=0;s>u;u++)a[u].apply(this,o)}return!0},n.prototype.addListener=function(e,t){var s;if(!r(t))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,r(t.listener)?t.listener:t),this._events[e]?l(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,l(this._events[e])&&!this._events[e].warned){var s;s=i(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,s&&s>0&&this._events[e].length>s&&(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())}return this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function n(){this.removeListener(e,n),s||(s=!0,t.apply(this,arguments))}if(!r(t))throw TypeError("listener must be a function");var s=!1;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var n,s,i,o;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],i=n.length,s=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(l(n)){for(o=i;o-->0;)if(n[o]===t||n[o].listener&&n[o].listener===t){s=o;break}if(0>s)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(s,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.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],r(n))this.removeListener(e,n);else for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.listenerCount=function(e,t){var n;return n=e._events&&e._events[t]?r(e._events[t])?1:e._events[t].length:0}},{}],25:[function(e,t){t.exports="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],26:[function(e,t){function n(){if(!i){i=!0;for(var e,t=l.length;t;){e=l,l=[];for(var n=-1;++n<t;)e[n]();
  t=l.length}i=!1}}function r(){}var s=t.exports={},l=[],i=!1;s.nextTick=function(e){l.push(e),i||setTimeout(n,0)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.on=r,s.addListener=r,s.once=r,s.off=r,s.removeListener=r,s.removeAllListeners=r,s.emit=r,s.binding=function(){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(){throw new Error("process.chdir is not supported")},s.umask=function(){return 0}},{}],27:[function(e,t){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],28:[function(e,t,n){(function(t,r){function s(e,t){var r={seen:[],stylize:i};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),m(t)?r.showHidden=t:t&&n._extend(r,t),S(r.showHidden)&&(r.showHidden=!1),S(r.depth)&&(r.depth=2),S(r.colors)&&(r.colors=!1),S(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=l),u(r,e,r.depth)}function l(e,t){var n=s.styles[t];return n?"["+s.colors[n][0]+"m"+e+"["+s.colors[n][1]+"m":e}function i(e){return e}function o(e){var t={};return e.forEach(function(e){t[e]=!0}),t}function u(e,t,r){if(e.customInspect&&t&&b(t.inspect)&&t.inspect!==n.inspect&&(!t.constructor||t.constructor.prototype!==t)){var s=t.inspect(r,e);return v(s)||(s=u(e,s,r)),s}var l=a(e,t);if(l)return l;var i=Object.keys(t),m=o(i);if(e.showHidden&&(i=Object.getOwnPropertyNames(t)),y(t)&&(i.indexOf("message")>=0||i.indexOf("description")>=0))return c(t);if(0===i.length){if(b(t)){var g=t.name?": "+t.name:"";return e.stylize("[Function"+g+"]","special")}if(E(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(R(t))return e.stylize(Date.prototype.toString.call(t),"date");if(y(t))return c(t)}var T="",_=!1,C=["{","}"];if(f(t)&&(_=!0,C=["[","]"]),b(t)){var S=t.name?": "+t.name:"";T=" [Function"+S+"]"}if(E(t)&&(T=" "+RegExp.prototype.toString.call(t)),R(t)&&(T=" "+Date.prototype.toUTCString.call(t)),y(t)&&(T=" "+c(t)),0===i.length&&(!_||0==t.length))return C[0]+T+C[1];if(0>r)return E(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var A;return A=_?h(e,t,r,m,i):i.map(function(n){return d(e,t,r,m,n,_)}),e.seen.pop(),p(A,T,C)}function a(e,t){if(S(t))return e.stylize("undefined","undefined");if(v(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return _(t)?e.stylize(""+t,"number"):m(t)?e.stylize(""+t,"boolean"):g(t)?e.stylize("null","null"):void 0}function c(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,n,r,s){for(var l=[],i=0,o=t.length;o>i;++i)l.push(U(t,String(i))?d(e,t,n,r,String(i),!0):"");return s.forEach(function(s){s.match(/^\d+$/)||l.push(d(e,t,n,r,s,!0))}),l}function d(e,t,n,r,s,l){var i,o,a;if(a=Object.getOwnPropertyDescriptor(t,s)||{value:t[s]},a.get?o=a.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):a.set&&(o=e.stylize("[Setter]","special")),U(r,s)||(i="["+s+"]"),o||(e.seen.indexOf(a.value)<0?(o=g(n)?u(e,a.value,null):u(e,a.value,n-1),o.indexOf("\n")>-1&&(o=l?o.split("\n").map(function(e){return"  "+e}).join("\n").substr(2):"\n"+o.split("\n").map(function(e){return"   "+e}).join("\n"))):o=e.stylize("[Circular]","special")),S(i)){if(l&&s.match(/^\d+$/))return o;i=JSON.stringify(""+s),i.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(i=i.substr(1,i.length-2),i=e.stylize(i,"name")):(i=i.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),i=e.stylize(i,"string"))}return i+": "+o}function p(e,t,n){var r=0,s=e.reduce(function(e,t){return r++,t.indexOf("\n")>=0&&r++,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0);return s>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n  ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}function f(e){return Array.isArray(e)}function m(e){return"boolean"==typeof e}function g(e){return null===e}function T(e){return null==e}function _(e){return"number"==typeof e}function v(e){return"string"==typeof e}function C(e){return"symbol"==typeof e}function S(e){return void 0===e}function E(e){return A(e)&&"[object RegExp]"===w(e)}function A(e){return"object"==typeof e&&null!==e}function R(e){return A(e)&&"[object Date]"===w(e)}function y(e){return A(e)&&("[object Error]"===w(e)||e instanceof Error)}function b(e){return"function"==typeof e}function I(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function w(e){return Object.prototype.toString.call(e)}function N(e){return 10>e?"0"+e.toString(10):e.toString(10)}function D(){var e=new Date,t=[N(e.getHours()),N(e.getMinutes()),N(e.getSeconds())].join(":");return[e.getDate(),M[e.getMonth()],t].join(" ")}function U(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var O=/%[sdj%]/g;n.format=function(e){if(!v(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(s(arguments[n]));return t.join(" ")}for(var n=1,r=arguments,l=r.length,i=String(e).replace(O,function(e){if("%%"===e)return"%";if(n>=l)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return e}}),o=r[n];l>n;o=r[++n])i+=g(o)||!A(o)?" "+o:" "+s(o);return i},n.deprecate=function(e,s){function l(){if(!i){if(t.throwDeprecation)throw new Error(s);t.traceDeprecation?console.trace(s):console.error(s),i=!0}return e.apply(this,arguments)}if(S(r.process))return function(){return n.deprecate(e,s).apply(this,arguments)};if(t.noDeprecation===!0)return e;var i=!1;return l};var x,P={};n.debuglog=function(e){if(S(x)&&(x=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!P[e])if(new RegExp("\\b"+e+"\\b","i").test(x)){var r=t.pid;P[e]=function(){var t=n.format.apply(n,arguments);console.error("%s %d: %s",e,r,t)}}else P[e]=function(){};return P[e]},n.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},n.isArray=f,n.isBoolean=m,n.isNull=g,n.isNullOrUndefined=T,n.isNumber=_,n.isString=v,n.isSymbol=C,n.isUndefined=S,n.isRegExp=E,n.isObject=A,n.isDate=R,n.isError=y,n.isFunction=b,n.isPrimitive=I,n.isBuffer=e("./support/isBuffer");var M=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];n.log=function(){console.log("%s - %s",D(),n.format.apply(n,arguments))},n.inherits=e("inherits"),n._extend=function(e,t){if(!t||!A(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":27,_process:26,inherits:25}],29:[function(e,t,n){function r(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}function s(){var e=arguments,t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+n.humanize(this.diff),!t)return e;var r="color: "+this.color;e=[e[0],r,"color: inherit"].concat(Array.prototype.slice.call(e,1));var s=0,l=0;return e[0].replace(/%[a-z%]/g,function(e){"%%"!==e&&(s++,"%c"===e&&(l=s))}),e.splice(l,0,r),e}function l(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function i(e){try{null==e?u.removeItem("debug"):u.debug=e}catch(t){}}function o(){var e;try{e=u.debug}catch(t){}return e}n=t.exports=e("./debug"),n.log=l,n.formatArgs=s,n.save=i,n.load=o,n.useColors=r;var u;u="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:window.localStorage,n.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],n.formatters.j=function(e){return JSON.stringify(e)},n.enable(o())},{"./debug":30}],30:[function(e,t,n){function r(){return n.colors[c++%n.colors.length]}function s(e){function t(){}function s(){var e=s,t=+new Date,l=t-(a||t);e.diff=l,e.prev=a,e.curr=t,a=t,null==e.useColors&&(e.useColors=n.useColors()),null==e.color&&e.useColors&&(e.color=r());var i=Array.prototype.slice.call(arguments);i[0]=n.coerce(i[0]),"string"!=typeof i[0]&&(i=["%o"].concat(i));var o=0;i[0]=i[0].replace(/%([a-z%])/g,function(t,r){if("%%"===t)return t;o++;var s=n.formatters[r];if("function"==typeof s){var l=i[o];t=s.call(e,l),i.splice(o,1),o--}return t}),"function"==typeof n.formatArgs&&(i=n.formatArgs.apply(e,i));var u=s.log||n.log||console.log.bind(console);u.apply(e,i)}t.enabled=!1,s.enabled=!0;var l=n.enabled(e)?s:t;return l.namespace=e,l}function l(e){n.save(e);for(var t=(e||"").split(/[\s,]+/),r=t.length,s=0;r>s;s++)t[s]&&(e=t[s].replace(/\*/g,".*?"),"-"===e[0]?n.skips.push(new RegExp("^"+e.substr(1)+"$")):n.names.push(new RegExp("^"+e+"$")))}function i(){n.enable("")}function o(e){var t,r;for(t=0,r=n.skips.length;r>t;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;r>t;t++)if(n.names[t].test(e))return!0;return!1}function u(e){return e instanceof Error?e.stack||e.message:e}n=t.exports=s,n.coerce=u,n.disable=i,n.enable=l,n.enabled=o,n.humanize=e("ms"),n.names=[],n.skips=[],n.formatters={};var a,c=0},{ms:31}],31:[function(e,t){function n(e){var t=/^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"y":return n*c;case"days":case"day":case"d":return n*a;case"hours":case"hour":case"h":return n*u;case"minutes":case"minute":case"m":return n*o;case"seconds":case"second":case"s":return n*i;case"ms":return n}}}function r(e){return e>=a?Math.round(e/a)+"d":e>=u?Math.round(e/u)+"h":e>=o?Math.round(e/o)+"m":e>=i?Math.round(e/i)+"s":e+"ms"}function s(e){return l(e,a,"day")||l(e,u,"hour")||l(e,o,"minute")||l(e,i,"second")||e+" ms"}function l(e,t,n){return t>e?void 0:1.5*t>e?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}var i=1e3,o=60*i,u=60*o,a=24*u,c=365.25*a;t.exports=function(e,t){return t=t||{},"string"==typeof e?n(e):t["long"]?s(e):r(e)}},{}],32:[function(e,t){(function(n){function r(e){function t(e){return function(){throw new Error("rtcninja: WebRTC not supported, missing "+e+" [browser: "+s.name+" "+s.version+"]")}}if(f&&s.chrome&&p>=32||s.android&&s.chrome&&p>=39||f&&s.opera&&p>=27||s.android&&s.opera&&p>=24||s.android&&s.webkit&&!s.chrome&&p>=37||g.webkitGetUserMedia&&n.webkitRTCPeerConnection)m=!0,o=g.webkitGetUserMedia.bind(g),u=n.webkitRTCPeerConnection,a=n.RTCSessionDescription,c=n.RTCIceCandidate,h=n.MediaStreamTrack,d=function(e,t){return e.src=URL.createObjectURL(t),e};else if(f&&s.firefox&&p>=22||s.android&&s.firefox&&p>=33||g.mozGetUserMedia&&n.mozRTCPeerConnection)m=!0,o=g.mozGetUserMedia.bind(g),u=n.mozRTCPeerConnection,a=n.mozRTCSessionDescription,c=n.mozRTCIceCandidate,h=n.MediaStreamTrack,d=function(e,t){return e.src=URL.createObjectURL(t),e};else if(e.plugin&&"function"==typeof e.plugin.isRequired&&e.plugin.isRequired()&&"function"==typeof e.plugin.isInstalled&&e.plugin.isInstalled()){var T=e.plugin["interface"];m=!0,o=T.getUserMedia,u=T.RTCPeerConnection,a=T.RTCSessionDescription,c=T.RTCIceCandidate,h=T.MediaStreamTrack,d=T.attachMediaStream}else g.getUserMedia&&n.RTCPeerConnection&&(m=!0,o=g.getUserMedia.bind(g),u=n.RTCPeerConnection,a=n.RTCSessionDescription,c=n.RTCIceCandidate,h=n.MediaStreamTrack,d=n.attachMediaStream||function(e,t){return e.src=URL.createObjectURL(t),e});return r.hasWebRTC=function(){return m},r.getUserMedia=o?function(e,t,n){l("getUserMedia() | constraints:",e);try{o(e,function(e){l("getUserMedia() | success"),t&&t(e)},function(e){l("getUserMedia() | error:",e),n&&n(e)})}catch(r){i("getUserMedia() | error:",r),n&&n(r)}}:function(e,n,r){i("getUserMedia() | WebRTC not supported"),r?r(new Error("rtcninja: WebRTC not supported, missing getUserMedia [browser: "+s.name+" "+s.version+"]")):t("getUserMedia")},r.RTCPeerConnection=u||t("RTCPeerConnection"),r.RTCSessionDescription=a||t("RTCSessionDescription"),r.RTCIceCandidate=c||t("RTCIceCandidate"),r.MediaStreamTrack=h||t("MediaStreamTrack"),r.attachMediaStream=d||t("attachMediaStream"),r.closeMediaStream=function(e){if(e){var t=n.MediaStreamTrack;if(t&&t.prototype&&t.prototype.stop){l("closeMediaStream() | calling stop() on all the MediaStreamTrack");var r,s,i;if(t.prototype.getTracks)for(r=e.getTracks(),s=0,i=r.length;i>s;s++)r[s].stop();else{for(r=e.getAudioTracks(),s=0,i=r.length;i>s;s++)r[s].stop();for(r=e.getVideoTracks(),s=0,i=r.length;i>s;s++)r[s].stop()}}else"function"==typeof e.stop&&(l("closeMediaStream() | calling stop() on the MediaStream"),e.stop())}},r.fixPeerConnectionConfig=function(e){Array.isArray(e.iceServers)||(e.iceServers=[]);for(var t=0,n=e.iceServers.length;n>t;t++){var r=e.iceServers[t],s=r.hasOwnProperty("urls"),l=r.hasOwnProperty("url");"object"==typeof r&&(s&&!l?r.url=Array.isArray(r.urls)?r.urls[0]:r.urls:!s&&l&&(r.urls=Array.isArray(r.url)?r.url.slice():r.url),l&&Array.isArray(r.url)&&(r.url=r.url[0]))}},r}t.exports=r;var s=e("bowser").browser,l=e("debug")("rtcninja:Adapter"),i=e("debug")("rtcninja:ERROR:Adapter");i.log=console.warn.bind(console);var o=null,u=null,a=null,c=null,h=null,d=null,p=Number(s.version)||0,f=!(s.mobile&&s.tablet),m=!1,g=n.navigator||{}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{bowser:36,debug:29}],33:[function(e,t){function n(e,t){a("new | original pcConfig:",e),s.call(this,e),a("new | processed pcConfig:",this.pcConfig),this.pc=new h.RTCPeerConnection(this.pcConfig,t),this._localDescription=null,this._signalingState=null,this._iceConnectionState=null,this._iceGatheringState=null,this.timerGatheringTimeout=null,this.timerGatheringTimeoutAfterRelay=null,this.ignoreIceGathering=!1,this.closed=!1,l.call(this),i.call(this)}function r(){return this.closed||this.pc&&"closed"===this.pc.iceConnectionState}function s(e){this.pcConfig=u(!0,e),h.fixPeerConnectionConfig(this.pcConfig),this.options={iceTransportsRelay:"relay"===this.pcConfig.iceTransports,iceTransportsNone:"none"===this.pcConfig.iceTransports,gatheringTimeout:this.pcConfig.gatheringTimeout,gatheringTimeoutAfterRelay:this.pcConfig.gatheringTimeoutAfterRelay},delete this.pcConfig.gatheringTimeout,delete this.pcConfig.gatheringTimeoutAfterRelay}function l(){var e=this,t=this.pc;Object.defineProperties(this,{peerConnection:{get:function(){return t}},signalingState:{get:function(){return t.signalingState}},iceConnectionState:{get:function(){return t.iceConnectionState}},iceGatheringState:{get:function(){return t.iceGatheringState}},localDescription:{get:function(){return o.call(e)}},remoteDescription:{get:function(){return t.remoteDescription}},peerIdentity:{get:function(){return t.peerIdentity}}})}function i(){var e=this,t=this.pc;t.onnegotiationneeded=function(t){r.call(e)||(a("onnegotiationneeded()"),e.onnegotiationneeded&&e.onnegotiationneeded(t))},t.onicecandidate=function(t){if(!r.call(e)&&!e.ignoreIceGathering&&!e.options.iceTransportsNone){var n=t.candidate;if(n){var s=d.REGEXP_RELAY_CANDIDATE.test(n.candidate);if(e.options.iceTransportsRelay&&!s)return;s&&!e.timerGatheringTimeoutAfterRelay&&"number"==typeof e.options.gatheringTimeoutAfterRelay&&(a("onicecandidate() | first relay candidate found, ending gathering in %d ms",e.options.gatheringTimeoutAfterRelay),e.timerGatheringTimeoutAfterRelay=setTimeout(function(){r.call(e)||(a("forced end of candidates after timeout"),delete e.timerGatheringTimeoutAfterRelay,clearTimeout(e.timerGatheringTimeout),delete e.timerGatheringTimeout,e.ignoreIceGathering=!0,e.onicecandidate&&e.onicecandidate({candidate:null},null))},e.options.gatheringTimeoutAfterRelay));var l=new h.RTCIceCandidate({sdpMid:n.sdpMid,sdpMLineIndex:n.sdpMLineIndex,candidate:n.candidate});null===p.normalizeCandidate&&(d.REGEXP_NORMALIZED_CANDIDATE.test(n.candidate)?p.normalizeCandidate=!1:(a('onicecandidate() | normalizing ICE candidates syntax (remove "a=" and "\\r\\n")'),p.normalizeCandidate=!0)),p.normalizeCandidate&&(l.candidate=n.candidate.replace(d.REGEXP_FIX_CANDIDATE,"")),a("onicecandidate() | m%d(%s) %s",l.sdpMLineIndex,l.sdpMid||"no mid",l.candidate),e.onicecandidate&&e.onicecandidate(t,l)}else a("onicecandidate() | end of candidates"),clearTimeout(e.timerGatheringTimeout),delete e.timerGatheringTimeout,clearTimeout(e.timerGatheringTimeoutAfterRelay),delete e.timerGatheringTimeoutAfterRelay,e.onicecandidate&&e.onicecandidate(t,null)}},t.onaddstream=function(t){r.call(e)||(a("onaddstream() | stream:",t.stream),e.onaddstream&&e.onaddstream(t,t.stream))},t.onremovestream=function(t){r.call(e)||(a("onremovestream() | stream:",t.stream),e.onremovestream&&e.onremovestream(t,t.stream))},t.ondatachannel=function(t){r.call(e)||(a("ondatachannel()"),e.ondatachannel&&e.ondatachannel(t,t.channel))},t.onsignalingstatechange=function(n){t.signalingState!==e._signalingState&&(a("onsignalingstatechange() | signalingState: %s",t.signalingState),e._signalingState=t.signalingState,e.onsignalingstatechange&&e.onsignalingstatechange(n,t.signalingState))},t.oniceconnectionstatechange=function(n){t.iceConnectionState!==e._iceConnectionState&&(a("oniceconnectionstatechange() | iceConnectionState: %s",t.iceConnectionState),e._iceConnectionState=t.iceConnectionState,e.oniceconnectionstatechange&&e.oniceconnectionstatechange(n,t.iceConnectionState))},t.onicegatheringstatechange=function(n){r.call(e)||t.iceGatheringState!==e._iceGatheringState&&(a("onicegatheringstatechange() | iceGatheringState: %s",t.iceGatheringState),e._iceGatheringState=t.iceGatheringState,e.onicegatheringstatechange&&e.onicegatheringstatechange(n,t.iceGatheringState))},t.onidentityresult=function(t){r.call(e)||(a("onidentityresult()"),e.onidentityresult&&e.onidentityresult(t))},t.onpeeridentity=function(t){r.call(e)||(a("onpeeridentity()"),e.onpeeridentity&&e.onpeeridentity(t))},t.onidpassertionerror=function(t){r.call(e)||(a("onidpassertionerror()"),e.onidpassertionerror&&e.onidpassertionerror(t))},t.onidpvalidationerror=function(t){r.call(e)||(a("onidpvalidationerror()"),e.onidpvalidationerror&&e.onidpvalidationerror(t))}}function o(){var e=this.pc,t=this.options,n=null;return e.localDescription?(t.iceTransportsRelay?n=e.localDescription.sdp.replace(d.REGEXP_SDP_NON_RELAY_CANDIDATES,""):t.iceTransportsNone&&(n=e.localDescription.sdp.replace(d.REGEXP_SDP_CANDIDATES,"")),this._localDescription=new h.RTCSessionDescription({type:e.localDescription.type,sdp:n||e.localDescription.sdp}),this._localDescription):(this._localDescription=null,null)}t.exports=n;var u=e("merge"),a=e("debug")("rtcninja:Connection"),c=e("debug")("rtcninja:ERROR:Connection");c.log=console.warn.bind(console);var h=e("./Adapter"),d={REGEXP_NORMALIZED_CANDIDATE:new RegExp(/^candidate:/i),REGEXP_FIX_CANDIDATE:new RegExp(/(^a=|\r|\n)/gi),REGEXP_RELAY_CANDIDATE:new RegExp(/ relay /i),REGEXP_SDP_CANDIDATES:new RegExp(/^a=candidate:.*\r\n/gim),REGEXP_SDP_NON_RELAY_CANDIDATES:new RegExp(/^a=candidate:(.(?! relay ))*\r\n/gim)},p={normalizeCandidate:null};n.prototype.createOffer=function(e,t,n){a("createOffer()");var s=this;this.pc.createOffer(function(t){r.call(s)||(a("createOffer() | success"),e&&e(t))},function(e){r.call(s)||(c("createOffer() | error:",e),t&&t(e))},n)},n.prototype.createAnswer=function(e,t,n){a("createAnswer()");var s=this;this.pc.createAnswer(function(t){r.call(s)||(a("createAnswer() | success"),e&&e(t))},function(e){r.call(s)||(c("createAnswer() | error:",e),t&&t(e))},n)},n.prototype.setLocalDescription=function(e,t,n){function s(){"number"==typeof l.options.gatheringTimeout&&"complete"!==l.pc.iceGatheringState&&(a("setLocalDescription() | ending gathering in %d ms (gatheringTimeout option)",l.options.gatheringTimeout),l.timerGatheringTimeout=setTimeout(function(){r.call(l)||(a("forced end of candidates after gatheringTimeout timeout"),delete l.timerGatheringTimeout,clearTimeout(l.timerGatheringTimeoutAfterRelay),delete l.timerGatheringTimeoutAfterRelay,l.ignoreIceGathering=!0,l.onicecandidate&&l.onicecandidate({candidate:null},null))},l.options.gatheringTimeout))}a("setLocalDescription()");var l=this;this.pc.setLocalDescription(e,function(){r.call(l)||(a("setLocalDescription() | success"),clearTimeout(l.timerGatheringTimeout),delete l.timerGatheringTimeout,clearTimeout(l.timerGatheringTimeoutAfterRelay),delete l.timerGatheringTimeoutAfterRelay,s(),t&&t())},function(e){r.call(l)||(c("setLocalDescription() | error:",e),n&&n(e))}),this.ignoreIceGathering=!1},n.prototype.setRemoteDescription=function(e,t,n){a("setRemoteDescription()");var s=this;this.pc.setRemoteDescription(e,function(){r.call(s)||(a("setRemoteDescription() | success"),t&&t())},function(e){r.call(s)||(c("setRemoteDescription() | error:",e),n&&n(e))})},n.prototype.updateIce=function(e){a("updateIce() | pcConfig:",e),s.call(this,e),this.pc.updateIce(this.pcConfig),this.ignoreIceGathering=!1},n.prototype.addIceCandidate=function(e,t,n){a("addIceCandidate() | candidate:",e);var s=this;this.pc.addIceCandidate(e,function(){r.call(s)||(a("addIceCandidate() | success"),t&&t())},function(e){r.call(s)||(c("addIceCandidate() | error:",e),n&&n(e))})},n.prototype.getConfiguration=function(){return a("getConfiguration()"),this.pc.getConfiguration()},n.prototype.getLocalStreams=function(){return a("getLocalStreams()"),this.pc.getLocalStreams()},n.prototype.getRemoteStreams=function(){return a("getRemoteStreams()"),this.pc.getRemoteStreams()},n.getStreamById=function(e){a("getStreamById() | streamId:",e),this.pc.getStreamById(e)},n.prototype.addStream=function(e){a("addStream() | stream:",e),this.pc.addStream(e)},n.prototype.removeStream=function(e){a("removeStream() | stream:",e),this.pc.removeStream(e)},n.prototype.close=function(){a("close()"),this.closed=!0,clearTimeout(this.timerGatheringTimeout),delete this.timerGatheringTimeout,clearTimeout(this.timerGatheringTimeoutAfterRelay),delete this.timerGatheringTimeoutAfterRelay,this.pc.close()},n.prototype.createDataChannel=function(){return a("createDataChannel()"),this.pc.createDataChannel.apply(this.pc,arguments)},n.prototype.createDTMFSender=function(e){return a("createDTMFSender()"),this.pc.createDTMFSender(e)},n.prototype.getStats=function(){return a("getStats()"),this.pc.getStats.apply(this.pc,arguments)},n.prototype.setIdentityProvider=function(){return a("setIdentityProvider()"),this.pc.setIdentityProvider.apply(this.pc,arguments)},n.prototype.getIdentityAssertion=function(){return a("getIdentityAssertion()"),this.pc.getIdentityAssertion()}},{"./Adapter":32,debug:29,merge:37}],34:[function(e,t){function n(e){var t=o(e||{});return a=!0,n.Connection=u,n.getUserMedia=t.getUserMedia,n.RTCSessionDescription=t.RTCSessionDescription,n.RTCIceCandidate=t.RTCIceCandidate,n.MediaStreamTrack=t.MediaStreamTrack,n.attachMediaStream=t.attachMediaStream,n.closeMediaStream=t.closeMediaStream,t.hasWebRTC()?(s("WebRTC supported"),!0):(l("WebRTC not supported"),!1)}t.exports=n;var r=e("bowser").browser,s=e("debug")("rtcninja"),l=e("debug")("rtcninja:ERROR");l.log=console.warn.bind(console);var i=e("./version"),o=e("./Adapter"),u=e("./Connection"),a=!1;s("version %s",i),s("detected browser: %s %s [mobile:%s, tablet:%s, android:%s, ios:%s]",r.name,r.version,!!r.mobile,!!r.tablet,!!r.android,!!r.ios),n.hasWebRTC=function(){return a||n(),o.hasWebRTC()},Object.defineProperty(n,"version",{get:function(){return i}}),Object.defineProperty(n,"called",{get:function(){return a}}),n.debug=e("debug")},{"./Adapter":32,"./Connection":33,"./version":35,bowser:36,debug:29}],35:[function(e,t){t.exports=e("../package.json").version},{"../package.json":38}],36:[function(t,n){!function(t,r){"undefined"!=typeof n&&n.exports?n.exports.browser=r():"function"==typeof e&&e.amd?e(r):this[t]=r()}("bowser",function(){function e(e){function n(t){var n=e.match(t);return n&&n.length>1&&n[1]||""}var r,s=n(/(ipod|iphone|ipad)/i).toLowerCase(),l=/like android/i.test(e),i=!l&&/android/i.test(e),o=n(/version\/(\d+(\.\d+)?)/i),u=/tablet/i.test(e),a=!u&&/[^-]mobi/i.test(e);/opera|opr/i.test(e)?r={name:"Opera",opera:t,version:o||n(/(?:opera|opr)[\s\/](\d+(\.\d+)?)/i)}:/windows phone/i.test(e)?r={name:"Windows Phone",windowsphone:t,msie:t,version:n(/iemobile\/(\d+(\.\d+)?)/i)}:/msie|trident/i.test(e)?r={name:"Internet Explorer",msie:t,version:n(/(?:msie |rv:)(\d+(\.\d+)?)/i)}:/chrome|crios|crmo/i.test(e)?r={name:"Chrome",chrome:t,version:n(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:s?(r={name:"iphone"==s?"iPhone":"ipad"==s?"iPad":"iPod"},o&&(r.version=o)):/sailfish/i.test(e)?r={name:"Sailfish",sailfish:t,version:n(/sailfish\s?browser\/(\d+(\.\d+)?)/i)}:/seamonkey\//i.test(e)?r={name:"SeaMonkey",seamonkey:t,version:n(/seamonkey\/(\d+(\.\d+)?)/i)}:/firefox|iceweasel/i.test(e)?(r={name:"Firefox",firefox:t,version:n(/(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i)},/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(e)&&(r.firefoxos=t)):/silk/i.test(e)?r={name:"Amazon Silk",silk:t,version:n(/silk\/(\d+(\.\d+)?)/i)}:i?r={name:"Android",version:o}:/phantom/i.test(e)?r={name:"PhantomJS",phantom:t,version:n(/phantomjs\/(\d+(\.\d+)?)/i)}:/blackberry|\bbb\d+/i.test(e)||/rim\stablet/i.test(e)?r={name:"BlackBerry",blackberry:t,version:o||n(/blackberry[\d]+\/(\d+(\.\d+)?)/i)}:/(web|hpw)os/i.test(e)?(r={name:"WebOS",webos:t,version:o||n(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)},/touchpad\//i.test(e)&&(r.touchpad=t)):r=/bada/i.test(e)?{name:"Bada",bada:t,version:n(/dolfin\/(\d+(\.\d+)?)/i)}:/tizen/i.test(e)?{name:"Tizen",tizen:t,version:n(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i)||o}:/safari/i.test(e)?{name:"Safari",safari:t,version:o}:{},/(apple)?webkit/i.test(e)?(r.name=r.name||"Webkit",r.webkit=t,!r.version&&o&&(r.version=o)):!r.opera&&/gecko\//i.test(e)&&(r.name=r.name||"Gecko",r.gecko=t,r.version=r.version||n(/gecko\/(\d+(\.\d+)?)/i)),i||r.silk?r.android=t:s&&(r[s]=t,r.ios=t);var c="";s?(c=n(/os (\d+([_\s]\d+)*) like mac os x/i),c=c.replace(/[_\s]/g,".")):i?c=n(/android[ \/-](\d+(\.\d+)*)/i):r.windowsphone?c=n(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i):r.webos?c=n(/(?:web|hpw)os\/(\d+(\.\d+)*)/i):r.blackberry?c=n(/rim\stablet\sos\s(\d+(\.\d+)*)/i):r.bada?c=n(/bada\/(\d+(\.\d+)*)/i):r.tizen&&(c=n(/tizen[\/\s](\d+(\.\d+)*)/i)),c&&(r.osversion=c);var h=c.split(".")[0];return u||"ipad"==s||i&&(3==h||4==h&&!a)||r.silk?r.tablet=t:(a||"iphone"==s||"ipod"==s||i||r.blackberry||r.webos||r.bada)&&(r.mobile=t),r.msie&&r.version>=10||r.chrome&&r.version>=20||r.firefox&&r.version>=20||r.safari&&r.version>=6||r.opera&&r.version>=10||r.ios&&r.osversion&&r.osversion.split(".")[0]>=6||r.blackberry&&r.version>=10.1?r.a=t:r.msie&&r.version<10||r.chrome&&r.version<20||r.firefox&&r.version<20||r.safari&&r.version<6||r.opera&&r.version<10||r.ios&&r.osversion&&r.osversion.split(".")[0]<6?r.c=t:r.x=t,r}var t=!0,n=e("undefined"!=typeof navigator?navigator.userAgent:"");return n._detect=e,n})},{}],37:[function(e,t){!function(e){function n(e,t){if("object"!==s(e))return t;for(var r in t)e[r]="object"===s(e[r])&&"object"===s(t[r])?n(e[r],t[r]):t[r];return e}function r(e,t,r){var i=r[0],o=r.length;(e||"object"!==s(i))&&(i={});for(var u=0;o>u;++u){var a=r[u],c=s(a);if("object"===c)for(var h in a){var d=e?l.clone(a[h]):a[h];i[h]=t?n(i[h],d):d}}return i}function s(e){return{}.toString.call(e).slice(8,-1).toLowerCase()}var l=function(e){return r(e===!0,!1,arguments)},i="merge";l.recursive=function(e){return r(e===!0,!0,arguments)},l.clone=function(e){var t,n,r=e,i=s(e);if("array"===i)for(r=[],n=e.length,t=0;n>t;++t)r[t]=l.clone(e[t]);else if("object"===i){r={};for(t in e)r[t]=l.clone(e[t])}return r},e?t.exports=l:window[i]=l}("object"==typeof t&&t&&"object"==typeof t.exports&&t.exports)},{}],38:[function(e,t){t.exports={name:"rtcninja",version:"0.2.9",description:"WebRTC API wrapper to deal with different browsers",author:{name:"Iñaki Baz Castillo",email:"ibc@aliax.net"},license:"ISC",main:"lib/rtcninja.js",homepage:"https://github.com/ibc/rtcninja.js",repository:{type:"git",url:"https://github.com/ibc/rtcninja.js.git"},keywords:["webrtc"],engines:{node:">=0.10.32"},dependencies:{bowser:"^0.7.2",debug:"^2.1.1",merge:"^1.2.0"},devDependencies:{browserify:"^8.1.1",gulp:"git+https://github.com/gulpjs/gulp.git#4.0","gulp-expect-file":"0.0.7","gulp-filelog":"^0.4.1","gulp-header":"^1.2.2","gulp-jshint":"^1.9.0","gulp-rename":"^1.2.0","gulp-uglify":"^1.0.2","jshint-stylish":"^1.0.0","vinyl-transform":"^1.0.0"},readme:"# rtcninja.js\n\nWebRTC API wrapper to deal with different browsers.\n\n\n## Installation\n\n* With **npm**:\n\n```bash\n$ npm install rtcninja\n```\n\n* With **bower**:\n\n```bash\n$ bower install rtcninja\n```\n\n## Usage in Node\n\n```javascript\nvar rtcninja = require('rtcninja');\n```\n\n\n## Browserified library\n\nTake a browserified version of the library from the `dist/` folder:\n\n* `dist/rtcninja-X.Y.Z.js`: The uncompressed version.\n* `dist/rtcninja-X.Y.Z.min.js`: The compressed production-ready version.\n* `dist/rtcninja.js`: A copy of the uncompressed version.\n* `dist/rtcninja.min.js`: A copy of the compressed version.\n\nThey expose the global `window.rtcninja` module.\n\n```html\n<script src='rtcninja-X.Y.Z.js'></script>\n```\n\n\n## Usage Example\n\n```javascript\n// Must first call it.\nrtcninja();\n\n// Then check.\nif (rtcninja.hasWebRTC()) {\n    // Do something.\n}\nelse {\n    // Do something.\n}\n```\n\n\n## Documentation\n\nYou can read the full [API documentation](docs/index.md) in the docs folder.\n\n\n## Debugging\n\nThe library includes the Node [debug](https://github.com/visionmedia/debug) module. In order to enable debugging:\n\nIn Node set the `DEBUG=rtcninja*` environment variable before running the application, or set it at the top of the script:\n\n```javascript\nprocess.env.DEBUG = 'rtcninja*';\n```\n\nIn the browser run `rtcninja.debug.enable('rtcninja*');` and reload the page. Note that the debugging settings are stored into the browser LocalStorage. To disable it run `rtcninja.debug.disable('rtcninja*');`.\n\n\n## Author\n\nIñaki Baz Castillo at [eFace2Face](http://eface2face.com).\n\n\n## License\n\nISC.\n",readmeFilename:"README.md",gitHead:"1ffa5f09184e3575ad5313784fe615c8f293da3b",bugs:{url:"https://github.com/ibc/rtcninja.js/issues"},_id:"rtcninja@0.2.9",scripts:{},_shasum:"9c71e12e12c9ac8f5ba87a6f23d5688b1ac2f328",_from:"rtcninja@>=0.2.9 <0.3.0"}},{}],39:[function(e,t){var n=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\-]*)\/(\d*)(?:\s*\/(\S*))?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":"rtpmap:%d %s/%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:([\w_\/]*) (\S*)(?: (\S*))?/,names:["value","uri","config"],format:function(e){return null!=e.config?"extmap:%s %s %s":"extmap:%s %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:(\w*)/,format:"mid:%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*))?(?: generation (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","generation"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",null!=e.generation&&(t+=" generation %d"),t}},{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:"ssrc:%d %s:%s"},{name:"msidSemantic",reg:/^msid-semantic: (\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)/},{push:"invalid",names:["value"]}]};Object.keys(n).forEach(function(e){var t=n[e];t.forEach(function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")})})},{}],40:[function(e,t,n){var r=e("./parser"),s=e("./writer");n.write=s,n.parse=r.parse,n.parseFmtpConfig=r.parseFmtpConfig,n.parsePayloads=r.parsePayloads,n.parseRemoteCandidates=r.parseRemoteCandidates},{"./parser":41,"./writer":42}],41:[function(e,t,n){var r=function(e){return String(Number(e))===e?Number(e):e},s=function(e,t,n,s){if(s&&!n)t[s]=r(e[1]);else for(var l=0;l<n.length;l+=1)null!=e[l+1]&&(t[n[l]]=r(e[l+1]))},l=function(e,t,n){var r=e.name&&e.names;e.push&&!t[e.push]?t[e.push]=[]:r&&!t[e.name]&&(t[e.name]={});var l=e.push?{}:r?t[e.name]:t;s(n.match(e.reg),l,e.names,e.name),e.push&&t[e.push].push(l)},i=e("./grammar"),o=RegExp.prototype.test.bind(/^([a-z])=(.*)/);n.parse=function(e){var t={},n=[],r=t;return e.split(/(\r\n|\r|\n)/).filter(o).forEach(function(e){var t=e[0],s=e.slice(2);"m"===t&&(n.push({rtp:[],fmtp:[]}),r=n[n.length-1]);for(var o=0;o<(i[t]||[]).length;o+=1){var u=i[t][o];if(u.reg.test(s))return l(u,r,s)}}),t.media=n,t};var u=function(e,t){var n=t.split("=");return 2===n.length&&(e[n[0]]=r(n[1])),e};n.parseFmtpConfig=function(e){return e.split(";").reduce(u,{})},n.parsePayloads=function(e){return e.split(" ").map(Number)},n.parseRemoteCandidates=function(e){for(var t=[],n=e.split(" ").map(r),s=0;s<n.length;s+=3)t.push({component:n[s],ip:n[s+1],port:n[s+2]});return t}},{"./grammar":39}],42:[function(e,t){var n=e("./grammar"),r=/%[sdv%]/g,s=function(e){var t=1,n=arguments,s=n.length;return e.replace(r,function(e){if(t>=s)return e;var r=n[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(r);case"%d":return Number(r);case"%v":return""}})},l=function(e,t,n){var r=t.format instanceof Function?t.format(t.push?n:n[t.name]):t.format,l=[e+"="+r];if(t.names)for(var i=0;i<t.names.length;i+=1){var o=t.names[i];l.push(t.name?n[t.name][o]:n[t.names[i]])}else l.push(n[t.name]);return s.apply(null,l)},i=["v","o","s","i","u","e","p","c","b","t","r","z","a"],o=["i","c","b","a"];t.exports=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach(function(e){null==e.payloads&&(e.payloads="")});var r=t.outerOrder||i,s=t.innerOrder||o,u=[];return r.forEach(function(t){n[t].forEach(function(n){n.name in e?u.push(l(t,n,e)):n.push in e&&e[n.push].forEach(function(e){u.push(l(t,n,e))})})}),e.media.forEach(function(e){u.push(l("m",n.m[0],e)),s.forEach(function(t){n[t].forEach(function(n){n.name in e?u.push(l(t,n,e)):n.push in e&&e[n.push].forEach(function(e){u.push(l(t,n,e))})})})}),u.join("\r\n")+"\r\n"}},{"./grammar":39}],43:[function(e,t){function n(e,t){var n;return n=t?new s(e,t):new s(e)}var r=function(){return this}(),s=r.WebSocket||r.MozWebSocket;t.exports={w3cwebsocket:s?n:null,version:e("./version")}},{"./version":44}],44:[function(e,t){t.exports=e("../package.json").version},{"../package.json":45}],45:[function(e,t){t.exports={name:"websocket",description:"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.",keywords:["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],author:{name:"Brian McKelvey",email:"brian@worlize.com",url:"https://www.worlize.com/"},version:"1.0.17",repository:{type:"git",url:"https://github.com/theturtle32/WebSocket-Node.git"},homepage:"https://github.com/theturtle32/WebSocket-Node",engines:{node:">=0.8.0"},dependencies:{debug:"~2.1.0",nan:"~1.0.0","typedarray-to-buffer":"~3.0.0"},devDependencies:{"buffer-equal":"0.0.1",faucet:"0.0.1",gulp:"git+https://github.com/gulpjs/gulp.git#4.0","gulp-jshint":"^1.9.0","jshint-stylish":"^1.0.0",tape:"^3.0.0"},config:{verbose:!1},scripts:{install:"(node-gyp rebuild 2> builderror.log) || (exit 0)",test:"faucet test/unit",gulp:"gulp"},main:"index",directories:{lib:"./lib"},browser:"lib/browser.js",gitHead:"cda940b883aa884906ac13158fe514229a67f426",bugs:{url:"https://github.com/theturtle32/WebSocket-Node/issues"},_id:"websocket@1.0.17",_shasum:"8a572afc6ec120eb41473ca517d07d932f7b6a1c",_from:"websocket@>=1.0.17 <2.0.0",_npmVersion:"1.4.28",_npmUser:{name:"theturtle32",email:"brian@worlize.com"},maintainers:[{name:"theturtle32",email:"brian@worlize.com"}],dist:{shasum:"8a572afc6ec120eb41473ca517d07d932f7b6a1c",tarball:"http://registry.npmjs.org/websocket/-/websocket-1.0.17.tgz"},_resolved:"https://registry.npmjs.org/websocket/-/websocket-1.0.17.tgz",readme:"ERROR: No README data found!"}},{}],46:[function(e,t){t.exports={name:"jssip",title:"JsSIP",description:"the Javascript SIP library",version:"0.6.3",homepage:"http://jssip.net",author:"José Luis Millán <jmillan@aliax.net> (https://github.com/jmillan)",contributors:["Iñaki Baz Castillo <ibc@aliax.net> (https://github.com/ibc)","Saúl Ibarra Corretgé <saghul@gmail.com> (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:"^2.1.1",rtcninja:"^0.2.9","sdp-transform":"~1.1.0",websocket:"^1.0.17"},devDependencies:{browserify:"^8.1.1",gulp:"git+https://github.com/gulpjs/gulp.git#4.0","gulp-expect-file":"0.0.7","gulp-filelog":"^0.4.1","gulp-header":"^1.2.2","gulp-jshint":"^1.9.0","gulp-nodeunit-runner":"^0.2.2","gulp-rename":"^1.2.0","gulp-uglify":"^1.0.2","gulp-util":"^3.0.2","jshint-stylish":"^1.0.0",pegjs:"0.7.0","vinyl-transform":"^1.0.0"},scripts:{test:"gulp test"}}},{}]},{},[7])(7)});