check

/* * SIP version 0.5.0 * Copyright (c) 2014-2014 Junction Networks, Inc * Homepage: http://sipjs.com * License: http://sipjs.com/license/ * * * ~~~SIP.js contains substantial portions of JsSIP under the following license~~~ * Homepage: http://jssip.net * Copyright (c) 2012-2013 José Luis Millán - Versatica * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * ~~~ end JsSIP license ~~~ */ !function(a){var b=function(){"use strict";var a={};return Object.defineProperties(a,{version:{get:function(){return"0.5.0"}},name:{get:function(){return"SIP.js"}}}),a}();!function(b){var c=function(){var a=function(a,b,c){this.logger=a,this.category=b,this.label=c};return a.prototype.debug=function(a){this.logger.debug(this.category,this.label,a)},a.prototype.log=function(a){this.logger.log(this.category,this.label,a)},a.prototype.warn=function(a){this.logger.warn(this.category,this.label,a)},a.prototype.error=function(a){this.logger.error(this.category,this.label,a)},a}(),d=function(){var b,c={error:0,warn:1,log:2,debug:3},d=2,e=!0,f=null;this.loggers={},b=this.getLogger("sip.loggerfactory"),Object.defineProperties(this,{builtinEnabled:{get:function(){return e},set:function(c){"boolean"==typeof c?e=c:b.error('invalid "builtinEnabled" parameter value: '+a.JSON.stringify(c))}},level:{get:function(){return d},set:function(e){e>=0&&3>=e?d=e:e>3?d=3:c.hasOwnProperty(e)?d=c[e]:b.error('invalid "level" parameter value: '+a.JSON.stringify(e))}},connector:{get:function(){return f},set:function(c){null===c||""===c||void 0===c?f=null:"function"==typeof c?f=c:b.error('invalid "connector" parameter value: '+a.JSON.stringify(c))}}})};d.prototype.print=function(a,b,c,d){var e=[];e.push(new Date),e.push(b),c&&e.push(c),e.push(""),"string"==typeof d?a.call(console,e.join(" | ")+d):a.call(console,d)},d.prototype.debug=function(a,b,c){3===this.level&&(this.builtinEnabled&&this.print(console.debug,a,b,c),this.connector&&this.connector("debug",a,b,c))},d.prototype.log=function(a,b,c){this.level>=2&&(this.builtinEnabled&&this.print(console.log,a,b,c),this.connector&&this.connector("log",a,b,c))},d.prototype.warn=function(a,b,c){this.level>=1&&(this.builtinEnabled&&this.print(console.warn,a,b,c),this.connector&&this.connector("warn",a,b,c))},d.prototype.error=function(a,b,c){this.builtinEnabled&&this.print(console.error,a,b,c),this.connector&&this.connector("error",a,b,c)},d.prototype.getLogger=function(a,b){var d;return b&&3===this.level?new c(this,a,b):this.loggers[a]?this.loggers[a]:(d=new c(this,a),this.loggers[a]=d,d)},b.LoggerFactory=d}(b),function(a){var b,c,d=(new a.LoggerFactory).getLogger("sip.eventemitter"),e={MAX_LISTENERS:10};b=function(){},b.prototype={initEvents:function(a){return this.events={},this.oneTimeListeners={},this.initMoreEvents(a)},initMoreEvents:function(a){var b;for(this.logger||(this.logger=d),this.maxListeners=e.MAX_LISTENERS,b=0;b0},on:function(a,b,c){if(void 0===b)return this;if("function"!=typeof b)return this.logger.error("listener must be a function"),this;if(!this.checkEvent(a))throw this.logger.error("unable to add a listener to a nonexistent event "+a),new TypeError("Invalid or uninitialized event: "+a);var d={listener:b};return c&&(d.bindTarget=c),this.events[a].length>=this.maxListeners?(this.logger.warn("max listeners exceeded for event "+a),this):(this.events[a].push(d),this.logger.log("new listener added to event "+a),this)},once:function(a,b,c){var d=this.events&&this.events[a]&&this.events[a].length;this.on(a,b,c);var e=this.events&&this.events[a]&&this.events[a].length;return e===d+1&&this.oneTimeListeners[a].push({listener:b,bindTarget:c}),this},off:function(a,b,c){var d,e,f=0;if(b&&"function"!=typeof b)return this.logger.error("listener must be a function"),this;if(!a){for(f in this.events)this.events[f]=[],this.oneTimeListeners[f]=[];return this}if(!this.checkEvent(a))throw this.logger.error("unable to remove a listener from a nonexistent event "+a),new TypeError("Invalid or uninitialized event: "+a);for(d=this.events[a],e=d.length;e>f;)!d[f]||b&&d[f].listener!==b||c&&d[f].bindTarget!==c?f++:d.splice(f,1);return this},setMaxListeners:function(a){return"number"!=typeof a||0>a?(this.logger.error("listeners must be a positive number"),this):(this.maxListeners=a,this)},emit:function(a){var b,c,d;if(!this.checkEvent(a))throw this.logger.error("unable to emit a nonexistent event "+a),new TypeError("Invalid or uninitialized event: "+a);this.logger.log("emitting event "+a),b=this.events[a];for(c in b)try{b[c].listener.apply(b[c].bindTarget||this,Array.prototype.slice.apply(arguments,[1]))}catch(e){this.logger.error(e.stack)}for(c in this.oneTimeListeners[a])d=this.oneTimeListeners[a][c],this.off(a,d.listener,d.bindTarget);return this.oneTimeListeners[a]=[],this}},c=function(a,b,c){this.type=a,this.sender=b,this.data=c},b.C=e,a.EventEmitter=b,a.Event=c}(b),b.C={USER_AGENT:b.name+"/"+b.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",AUTHENTICATION_ERROR:"Authentication Error",DIALOG_ERROR:"Dialog Error",WEBRTC_NOT_SUPPORTED:"WebRTC Not Supported",WEBRTC_ERROR:"WebRTC Error",CANCELED:"Canceled",NO_ANSWER:"No Answer",EXPIRES:"Expires",NO_ACK:"No ACK",NO_PRACK:"No PRACK",USER_DENIED_MEDIA_ACCESS:"User Denied Media Access",BAD_MEDIA_DESCRIPTION:"Bad Media Description",RTP_TIMEOUT:"RTP Timeout"},supported:{UNSUPPORTED:0,SUPPORTED:1,REQUIRED:2},SIP_ERROR_CAUSES:{REDIRECTED:[300,301,302,305,380],BUSY:[486,600],REJECTED:[403,603],NOT_FOUND:[404,604],UNAVAILABLE:[480,410,408,430],ADDRESS_INCOMPLETE:[484],INCOMPATIBLE_SDP:[488,606],AUTHENTICATION_ERROR:[401,407]},ACK:"ACK",BYE:"BYE",CANCEL:"CANCEL",INFO:"INFO",INVITE:"INVITE",MESSAGE:"MESSAGE",NOTIFY:"NOTIFY",OPTIONS:"OPTIONS",REGISTER:"REGISTER",UPDATE:"UPDATE",SUBSCRIBE:"SUBSCRIBE",REFER:"REFER",PRACK:"PRACK",REASON_PHRASE:{100:"Trying",180:"Ringing",181:"Call Is Being Forwarded",182:"Queued",183:"Session Progress",199:"Early Dialog Terminated",200:"OK",202:"Accepted",204:"No Notification",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",305:"Use Proxy",380:"Alternative Service",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",410:"Gone",412:"Conditional Request Failed",413:"Request Entity Too Large",414:"Request-URI Too Long",415:"Unsupported Media Type",416:"Unsupported URI Scheme",417:"Unknown Resource-Priority",420:"Bad Extension",421:"Extension Required",422:"Session Interval Too Small",423:"Interval Too Brief",428:"Use Identity Header",429:"Provide Referrer Identity",430:"Flow Failed",433:"Anonymity Disallowed",436:"Bad Identity-Info",437:"Unsupported Certificate",438:"Invalid Identity Header",439:"First Hop Lacks Outbound Support",440:"Max-Breadth Exceeded",469:"Bad Info Package",470:"Consent Needed",478:"Unresolvable Destination",480:"Temporarily Unavailable",481:"Call/Transaction Does Not Exist",482:"Loop Detected",483:"Too Many Hops",484:"Address Incomplete",485:"Ambiguous",486:"Busy Here",487:"Request Terminated",488:"Not Acceptable Here",489:"Bad Event",491:"Request Pending",493:"Undecipherable",494:"Security Agreement Required",500:"Server 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"}},function(b){var c;c={ConfigurationError:function(){var b=function(b,c){this.code=1,this.name="CONFIGURATION_ERROR",this.parameter=b,this.value=c,this.message=this.value?"Invalid value "+a.JSON.stringify(this.value)+' for parameter "'+this.parameter+'"':"Missing parameter: "+this.parameter};return b.prototype=new Error,b}(),InvalidStateError:function(){var a=function(a){this.code=2,this.name="INVALID_STATE_ERROR",this.status=a,this.message="Invalid status: "+a};return a.prototype=new Error,a}(),NotSupportedError:function(){var a=function(a){this.code=3,this.name="NOT_SUPPORTED_ERROR",this.message=a};return a.prototype=new Error,a}(),NotReadyError:function(){var a=function(a){this.code=4,this.name="NOT_READY_ERROR",this.message=a};return a.prototype=new Error,a}()},b.Exceptions=c}(b),function(a){var b,c=500,d=4e3,e=5e3;b={T1:c,T2:d,T4:e,TIMER_B:64*c,TIMER_D:0*c,TIMER_F:64*c,TIMER_H:64*c,TIMER_I:0*c,TIMER_J:0*c,TIMER_K:0*e,TIMER_L:64*c,TIMER_M:64*c,TIMER_N:64*c,PROVISIONAL_RESPONSE_INTERVAL:6e4},a.Timers=b}(b),function(b){var c,d={STATUS_READY:0,STATUS_DISCONNECTED:1,STATUS_ERROR:2};c=function(a,b){this.logger=a.getLogger("sip.transport"),this.ua=a,this.ws=null,this.server=b,this.reconnection_attempts=0,this.closed=!1,this.connected=!1,this.reconnectTimer=null,this.lastTransportError={},this.ua.transport=this,this.connect()},c.prototype={send:function(a){var b=a.toString();return this.ws&&this.ws.readyState===WebSocket.OPEN?(this.ua.configuration.traceSip===!0&&this.logger.log("sending WebSocket message:\n\n"+b+"\n"),this.ws.send(b),!0):(this.logger.warn("unable to send message, WebSocket is not open"),!1)},disconnect:function(){this.ws&&(a.clearTimeout(this.reconnectTimer),this.closed=!0,this.logger.log("closing WebSocket "+this.server.ws_uri),this.ws.close()),null!==this.reconnectTimer&&(a.clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.ua.emit("disconnected",{transport:this,code:this.lastTransportError.code,reason:this.lastTransportError.reason}))},connect:function(){var a=this;if(this.ws&&(this.ws.readyState===WebSocket.OPEN||this.ws.readyState===WebSocket.CONNECTING))return this.logger.log("WebSocket "+this.server.ws_uri+" is already connected"),!1;this.ws&&this.ws.close(),this.logger.log("connecting to WebSocket "+this.server.ws_uri),this.ua.onTransportConnecting(this,0===this.reconnection_attempts?1:this.reconnection_attempts);try{this.ws=new WebSocket(this.server.ws_uri,"sip")}catch(b){this.logger.warn("error connecting to WebSocket "+this.server.ws_uri+": "+b)}this.ws.binaryType="arraybuffer",this.ws.onopen=function(){a.onOpen()},this.ws.onclose=function(b){a.onClose(b)},this.ws.onmessage=function(b){a.onMessage(b)},this.ws.onerror=function(b){a.onError(b)}},onOpen:function(){this.connected=!0,this.logger.log("WebSocket "+this.server.ws_uri+" connected"),null!==this.reconnectTimer&&(a.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.reconnection_attempts=0,this.closed=!1,this.ua.onTransportConnected(this)},onClose:function(a){var b=this.connected;this.connected=!1,this.lastTransportError.code=a.code,this.lastTransportError.reason=a.reason,this.logger.log("WebSocket disconnected (code: "+a.code+(a.reason?"| reason: "+a.reason:"")+")"),a.wasClean===!1&&this.logger.warn("WebSocket abrupt disconnection"),b===!0?(this.ua.onTransportClosed(this),this.closed?this.ua.emit("disconnected",{transport:this,code:this.lastTransportError.code,reason:this.lastTransportError.reason}):this.reConnect()):this.ua.onTransportError(this)},onMessage:function(a){var c,d,e=a.data;if("\r\n"===e)return void(this.ua.configuration.traceSip===!0&&this.logger.log("received WebSocket message with CRLF Keep Alive response"));if("string"!=typeof e){try{e=String.fromCharCode.apply(null,new Uint8Array(e))}catch(f){return void this.logger.warn("received WebSocket binary message failed to be converted into string, message discarded")}this.ua.configuration.traceSip===!0&&this.logger.log("received WebSocket binary message:\n\n"+e+"\n")}else this.ua.configuration.traceSip===!0&&this.logger.log("received WebSocket text message:\n\n"+e+"\n");if(c=b.Parser.parseMessage(e,this.ua),c&&!(this.ua.status===b.UA.C.STATUS_USER_CLOSED&&c instanceof b.IncomingRequest)&&b.sanityCheck(c,this.ua,this))if(c instanceof b.IncomingRequest)c.transport=this,this.ua.receiveRequest(c);else if(c instanceof b.IncomingResponse)switch(c.method){case b.C.INVITE:d=this.ua.transactions.ict[c.via_branch],d&&d.receiveResponse(c);break;case b.C.ACK:break;default:d=this.ua.transactions.nict[c.via_branch],d&&d.receiveResponse(c)}},onError:function(a){this.logger.warn("WebSocket connection error: "+a)},reConnect:function(){var b=this;this.reconnection_attempts+=1,this.reconnection_attempts>this.ua.configuration.wsServerMaxReconnection?(this.logger.warn("maximum reconnection attempts for WebSocket "+this.server.ws_uri),this.ua.onTransportError(this)):(this.logger.log("trying to reconnect to WebSocket "+this.server.ws_uri+" (reconnection attempt "+this.reconnection_attempts+")"),this.reconnectTimer=a.setTimeout(function(){b.connect(),b.reconnectTimer=null},1e3*this.ua.configuration.wsServerReconnectionTimeout))}},c.C=d,b.Transport=c}(b),function(a){function b(a,b){var c=b,d=0,e=0;if(a.substring(c,c+2).match(/(^\r\n)/))return-2;for(;0===d;){if(e=a.indexOf("\r\n",c),-1===e)return e;!a.substring(e+2,e+4).match(/(^\r\n)/)&&a.charAt(e+2).match(/(^\s+)/)?c=e+2:d=e}return d}function c(b,c,d,e){var f,g,h,i,j=c.indexOf(":",d),k=c.substring(d,j).trim(),l=c.substring(j+1,e).trim();switch(k.toLowerCase()){case"via":case"v":b.addHeader("via",l),1===b.getHeaders("via").length?(i=b.parseHeader("Via"),i&&(b.via=i,b.via_branch=i.branch)):i=0;break;case"from":case"f":b.setHeader("from",l),i=b.parseHeader("from"),i&&(b.from=i,b.from_tag=i.getParam("tag"));break;case"to":case"t":b.setHeader("to",l),i=b.parseHeader("to"),i&&(b.to=i,b.to_tag=i.getParam("tag"));break;case"record-route":for(i=a.Grammar.parse(l,"Record_Route"),-1===i&&(i=void 0),h=i.length,g=0;h>g;g++)f=i[g],b.addHeader("record-route",l.substring(f.possition,f.offset)),b.headers["Record-Route"][b.getHeaders("record-route").length-1].parsed=f.parsed;break;case"call-id":case"i":b.setHeader("call-id",l),i=b.parseHeader("call-id"),i&&(b.call_id=l);break;case"contact":case"m":for(i=a.Grammar.parse(l,"Contact"),-1===i&&(i=void 0),h=i.length,g=0;h>g;g++)f=i[g],b.addHeader("contact",l.substring(f.possition,f.offset)),b.headers.Contact[b.getHeaders("contact").length-1].parsed=f.parsed;break;case"content-length":case"l":b.setHeader("content-length",l),i=b.parseHeader("content-length");break;case"content-type":case"c":b.setHeader("content-type",l),i=b.parseHeader("content-type");break;case"cseq":b.setHeader("cseq",l),i=b.parseHeader("cseq"),i&&(b.cseq=i.value),b instanceof a.IncomingResponse&&(b.method=i.method);break;case"max-forwards":b.setHeader("max-forwards",l),i=b.parseHeader("max-forwards");break;case"www-authenticate":b.setHeader("www-authenticate",l),i=b.parseHeader("www-authenticate");break;case"proxy-authenticate":b.setHeader("proxy-authenticate",l),i=b.parseHeader("proxy-authenticate");break;case"refer-to":case"r":b.setHeader("refer-to",l),i=b.parseHeader("refer-to"),i&&(b.refer_to=i);break;default:b.setHeader(k,l),i=0}return void 0===i?{error:'error parsing header "'+k+'"'}:!0}var d;d={},d.parseMessage=function(d,e){var f,g,h,i,j,k=0,l=d.indexOf("\r\n"),m=e.getLogger("sip.parser");if(-1===l)return void m.warn("no CRLF found, not a SIP message, discarded");if(g=d.substring(0,l),j=a.Grammar.parse(g,"Request_Response"),-1===j)return void m.warn('error parsing first line of SIP message: "'+g+'"');for(j.status_code?(f=new a.IncomingResponse(e),f.status_code=j.status_code,f.reason_phrase=j.reason_phrase):(f=new a.IncomingRequest(e),f.method=j.method,f.ruri=j.uri),f.data=d,k=l+2;;){if(l=b(d,k),-2===l){i=k+2;break}if(-1===l)return void m.error("malformed message");if(j=c(f,d,k,l),j!==!0)return void m.error(j.error);k=l+2}return f.hasHeader("content-length")?(h=f.getHeader("content-length"),f.body=d.substr(i,h)):f.body=d.substring(i),f},a.Parser=d}(b),function(a){var b,c,d,e;b=function(b,c,d,e,f,g){var h,i,j,k;return e=e||{},b&&c&&d?(this.logger=d.getLogger("sip.sipmessage"),this.ua=d,this.headers={},this.method=b,this.ruri=c,this.body=g,this.extraHeaders=f||[],this.statusCode=e.status_code,this.reasonPhrase=e.reason_phrase,e.route_set?this.setHeader("route",e.route_set):d.configuration.usePreloadedRoute&&this.setHeader("route",d.transport.server.sip_uri),this.setHeader("via",""),this.setHeader("max-forwards",a.UA.C.MAX_FORWARDS),h=e.to_displayName||0===e.to_displayName?'"'+e.to_displayName+'" ':"",h+="<"+(e.to_uri||c)+">",h+=e.to_tag?";tag="+e.to_tag:"",this.to=new a.NameAddrHeader.parse(h),this.setHeader("to",h),i=e.from_displayName||0===e.from_displayName?'"'+e.from_displayName+'" ':d.configuration.displayName?'"'+d.configuration.displayName+'" ':"",i+="<"+(e.from_uri||d.configuration.uri)+">;tag=",i+=e.from_tag||a.Utils.newTag(),this.from=new a.NameAddrHeader.parse(i),this.setHeader("from",i),j=e.call_id||d.configuration.jssipId+a.Utils.createRandomToken(15),this.call_id=j,this.setHeader("call-id",j),k=e.cseq||Math.floor(1e4*Math.random()),this.cseq=k,void this.setHeader("cseq",k+" "+b)):null},b.prototype={setHeader:function(b,c){this.headers[a.Utils.headerize(b)]=c instanceof Array?c:[c]},getHeader:function(b){var c,d,e=this.extraHeaders.length,f=this.headers[a.Utils.headerize(b)];if(f){if(f[0])return f[0]}else for(c=new RegExp("^\\s*"+b+"\\s*:","i"),d=0;e>d;d++)if(f=this.extraHeaders[d],c.test(f))return f.substring(f.indexOf(":")+1).trim()},getHeaders:function(b){var c,d,e,f=this.headers[a.Utils.headerize(b)],g=[];if(f){for(d=f.length,c=0;d>c;c++)g.push(f[c]);return g}for(d=this.extraHeaders.length,e=new RegExp("^\\s*"+b+"\\s*:","i"),c=0;d>c;c++)f=this.extraHeaders[c],e.test(f)&&g.push(f.substring(f.indexOf(":")+1).trim());return g},hasHeader:function(b){var c,d,e=this.extraHeaders.length;if(this.headers[a.Utils.headerize(b)])return!0;for(c=new RegExp("^\\s*"+b+"\\s*:","i"),d=0;e>d;d++)if(c.test(this.extraHeaders[d]))return!0;return!1},toString:function(){var b,c,d,e="",f=[];e+=this.method+" "+this.ruri+" SIP/2.0\r\n";for(b in this.headers)for(c=this.headers[b].length,d=0;c>d;d++)e+=b+": "+this.headers[b][d]+"\r\n";for(c=this.extraHeaders.length,d=0;c>d;d++)e+=this.extraHeaders[d].trim()+"\r\n";return this.method===a.C.REGISTER?f.push("path","gruu"):this.method===a.C.INVITE&&(this.ua.contact.pub_guu||this.ua.contact.temp_gruu)&&f.push("gruu"),"supported"===this.ua.configuration.reliable&&f.push("100rel"),f.push("outbound"),e+="Supported: "+f+"\r\n",e+="User-Agent: "+this.ua.configuration.userAgentString+"\r\n",this.body?(c=a.Utils.str_utf8_length(this.body),e+="Content-Length: "+c+"\r\n\r\n",e+=this.body):e+="Content-Length: 0\r\n\r\n",e}},c=function(){this.data=null,this.headers=null,this.method=null,this.via=null,this.via_branch=null,this.call_id=null,this.cseq=null,this.from=null,this.from_tag=null,this.to=null,this.to_tag=null,this.body=null},c.prototype={addHeader:function(b,c){var d={raw:c};b=a.Utils.headerize(b),this.headers[b]?this.headers[b].push(d):this.headers[b]=[d]},getHeader:function(b){var c=this.headers[a.Utils.headerize(b)];if(c)return c[0]?c[0].raw:void 0},getHeaders:function(b){var c,d,e=this.headers[a.Utils.headerize(b)],f=[];if(!e)return[];for(d=e.length,c=0;d>c;c++)f.push(e[c].raw);return f},hasHeader:function(b){return this.headers[a.Utils.headerize(b)]?!0:!1},parseHeader:function(b,c){var d,e,f;return b=a.Utils.headerize(b),c=c||0,this.headers[b]?c>=this.headers[b].length?void this.logger.log('not so many "'+b+'" headers present'):(d=this.headers[b][c],e=d.raw,d.parsed?d.parsed:(f=a.Grammar.parse(e,b.replace(/-/g,"_")),-1===f?(this.headers[b].splice(c,1),void this.logger.warn('error parsing "'+b+'" header field with value "'+e+'"')):(d.parsed=f,f))):void this.logger.log('header "'+b+'" not present')},s:function(a,b){return this.parseHeader(a,b)},setHeader:function(b,c){var d={raw:c};this.headers[a.Utils.headerize(b)]=[d]},toString:function(){return this.data}},d=function(a){this.logger=a.getLogger("sip.sipmessage"),this.ua=a,this.headers={},this.ruri=null,this.transport=null,this.server_transaction=null},d.prototype=new c,d.prototype.reply=function(b,c,d,e,f,g){var h,i,j,k,l,m=[],n=this.getHeader("To"),o=0,p=0;if(b=b||null,c=c||null,!b||100>b||b>699)throw new TypeError("Invalid status_code: "+b);if(c&&"string"!=typeof c&&!(c instanceof String))throw new TypeError("Invalid reason_phrase: "+c);if(c=c||a.C.REASON_PHRASE[b]||"",d=d||[],l="SIP/2.0 "+b+" "+c+"\r\n",this.method===a.C.INVITE&&b>100&&200>=b)for(h=this.getHeaders("record-route"),j=h.length,o;j>o;o++)l+="Record-Route: "+h[o]+"\r\n";for(i=this.getHeaders("via"),j=i.length,p;j>p;p++)l+="Via: "+i[p]+"\r\n";for(!this.to_tag&&b>100?n+=";tag="+a.Utils.newTag():this.to_tag&&!this.s("to").hasParam("tag")&&(n+=";tag="+this.to_tag),l+="To: "+n+"\r\n",l+="From: "+this.getHeader("From")+"\r\n",l+="Call-ID: "+this.call_id+"\r\n",l+="CSeq: "+this.cseq+" "+this.method+"\r\n",j=d.length,k=0;j>k;k++)l+=d[k].trim()+"\r\n";return this.method===a.C.INVITE&&(this.ua.contact.pub_guu||this.ua.contact.temp_gruu)&&m.push("gruu"),"supported"===this.ua.configuration.reliable&&m.push("100rel"),m.push("outbound"),l+="Supported: "+m+"\r\n",e?(j=a.Utils.str_utf8_length(e),l+="Content-Type: application/sdp\r\n",l+="Content-Length: "+j+"\r\n\r\n",l+=e):l+="Content-Length: 0\r\n\r\n",this.server_transaction.receiveResponse(b,l,f,g),l},d.prototype.reply_sl=function(b,c){var d,e,f=0,g=this.getHeaders("via"),h=g.length;if(b=b||null,c=c||null,!b||100>b||b>699)throw new TypeError("Invalid status_code: "+b);if(c&&"string"!=typeof c&&!(c instanceof String))throw new TypeError("Invalid reason_phrase: "+c);for(c=c||a.C.REASON_PHRASE[b]||"",e="SIP/2.0 "+b+" "+c+"\r\n",f;h>f;f++)e+="Via: "+g[f]+"\r\n";d=this.getHeader("To"),!this.to_tag&&b>100?d+=";tag="+a.Utils.newTag():this.to_tag&&!this.s("to").hasParam("tag")&&(d+=";tag="+this.to_tag),e+="To: "+d+"\r\n",e+="From: "+this.getHeader("From")+"\r\n",e+="Call-ID: "+this.call_id+"\r\n",e+="CSeq: "+this.cseq+" "+this.method+"\r\n",e+="Content-Length: 0\r\n\r\n",this.transport.send(e)},e=function(a){this.logger=a.getLogger("sip.sipmessage"),this.headers={},this.status_code=null,this.reason_phrase=null},e.prototype=new c,a.OutgoingRequest=b,a.IncomingRequest=d,a.IncomingResponse=e}(b),function(b){var c;c=function(a,c,d,e,f,g){var h,i;if(!d)throw new TypeError('missing or invalid "host" parameter');a=a||b.C.SIP,this.parameters={},this.headers={};for(h in f)this.setParam(h,f[h]);for(i in g)this.setHeader(i,g[i]);Object.defineProperties(this,{scheme:{get:function(){return a},set:function(b){a=b.toLowerCase()}},user:{get:function(){return c},set:function(a){c=a}},host:{get:function(){return d},set:function(a){d=a.toLowerCase()}},port:{get:function(){return e},set:function(a){e=0===a?a:parseInt(a,10)||null}}})},c.prototype={setParam:function(a,b){a&&(this.parameters[a.toLowerCase()]="undefined"==typeof b||null===b?null:b.toString().toLowerCase())},getParam:function(a){return a?this.parameters[a.toLowerCase()]:void 0},hasParam:function(a){return a?this.parameters.hasOwnProperty(a.toLowerCase())&&!0||!1:void 0},deleteParam:function(a){var b;return a=a.toLowerCase(),this.parameters.hasOwnProperty(a)?(b=this.parameters[a],delete this.parameters[a],b):void 0},clearParams:function(){this.parameters={}},setHeader:function(a,c){this.headers[b.Utils.headerize(a)]=c instanceof Array?c:[c]},getHeader:function(a){return a?this.headers[b.Utils.headerize(a)]:void 0},hasHeader:function(a){return a?this.headers.hasOwnProperty(b.Utils.headerize(a))&&!0||!1:void 0},deleteHeader:function(a){var c;return a=b.Utils.headerize(a),this.headers.hasOwnProperty(a)?(c=this.headers[a],delete this.headers[a],c):void 0},clearHeaders:function(){this.headers={}},clone:function(){return new c(this.scheme,this.user,this.host,this.port,a.JSON.parse(a.JSON.stringify(this.parameters)),a.JSON.parse(a.JSON.stringify(this.headers)))},toString:function(){var a,c,d,e,f=[];e=this.scheme+":",this.user&&(e+=b.Utils.escapeUser(this.user)+"@"),e+=this.host,(this.port||0===this.port)&&(e+=":"+this.port);for(c in this.parameters)e+=";"+c,null!==this.parameters[c]&&(e+="="+this.parameters[c]);for(a in this.headers)for(d in this.headers[a])f.push(a+"="+this.headers[a][d]);return f.length>0&&(e+="?"+f.join("&")),e}},c.parse=function(a){return a=b.Grammar.parse(a,"SIP_URI"),-1!==a?a:void 0},b.URI=c}(b),function(b){var c;c=function(a,c,d){var e;if(!(a&&a instanceof b.URI))throw new TypeError('missing or invalid "uri" parameter');this.uri=a,this.parameters={};for(e in d)this.setParam(e,d[e]);Object.defineProperties(this,{displayName:{get:function(){return c},set:function(a){c=0===a?"0":a}}})},c.prototype={setParam:function(a,b){a&&(this.parameters[a.toLowerCase()]="undefined"==typeof b||null===b?null:b.toString())},getParam:b.URI.prototype.getParam,hasParam:b.URI.prototype.hasParam,deleteParam:b.URI.prototype.deleteParam,clearParams:b.URI.prototype.clearParams,clone:function(){return new c(this.uri.clone(),this.displayName,a.JSON.parse(a.JSON.stringify(this.parameters)))},toString:function(){var a,b;a=this.displayName||0===this.displayName?'"'+this.displayName+'" ':"",a+="<"+this.uri.toString()+">";for(b in this.parameters)a+=";"+b,null!==this.parameters[b]&&(a+="="+this.parameters[b]);return a}},c.parse=function(a){return a=b.Grammar.parse(a,"Name_Addr_Header"),-1!==a?a:void 0},b.NameAddrHeader=c}(b),function(b){var c={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"},d=function(a,b,d){var e,f=["stateChanged"];this.type=c.NON_INVITE_CLIENT,this.transport=d,this.id="z9hG4bK"+Math.floor(1e7*Math.random()),this.request_sender=a,this.request=b,this.logger=a.ua.getLogger("sip.transaction.nict",this.id),e="SIP/2.0/"+(a.ua.configuration.hackViaTcp?"TCP":d.server.scheme),e+=" "+a.ua.configuration.viaHost+";branch="+this.id,this.request.setHeader("via",e),this.request_sender.ua.newTransaction(this),this.initEvents(f)};d.prototype=new b.EventEmitter,d.prototype.stateChanged=function(a){this.state=a,this.emit("stateChanged")},d.prototype.send=function(){var d=this;this.stateChanged(c.STATUS_TRYING),this.F=a.setTimeout(function(){d.timer_F()},b.Timers.TIMER_F),this.transport.send(this.request)||this.onTransportError()},d.prototype.onTransportError=function(){this.logger.log("transport error occurred, deleting non-INVITE client transaction "+this.id),a.clearTimeout(this.F),a.clearTimeout(this.K),this.stateChanged(c.STATUS_TERMINATED),this.request_sender.ua.destroyTransaction(this),this.request_sender.onTransportError()},d.prototype.timer_F=function(){this.logger.log("Timer F expired for non-INVITE client transaction "+this.id),this.stateChanged(c.STATUS_TERMINATED),this.request_sender.ua.destroyTransaction(this),this.request_sender.onRequestTimeout()},d.prototype.timer_K=function(){this.stateChanged(c.STATUS_TERMINATED),this.request_sender.ua.destroyTransaction(this)},d.prototype.receiveResponse=function(d){var e=this,f=d.status_code;if(200>f)switch(this.state){case c.STATUS_TRYING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_PROCEEDING),this.request_sender.receiveResponse(d)}else switch(this.state){case c.STATUS_TRYING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_COMPLETED),a.clearTimeout(this.F),408===f?this.request_sender.onRequestTimeout():this.request_sender.receiveResponse(d),this.K=a.setTimeout(function(){e.timer_K()},b.Timers.TIMER_K);break;case c.STATUS_COMPLETED:}};var e=function(a,b,d){var e,f=this,g=["stateChanged"];this.type=c.INVITE_CLIENT,this.transport=d,this.id="z9hG4bK"+Math.floor(1e7*Math.random()),this.request_sender=a,this.request=b,this.logger=a.ua.getLogger("sip.transaction.ict",this.id),e="SIP/2.0/"+(a.ua.configuration.hackViaTcp?"TCP":d.server.scheme),e+=" "+a.ua.configuration.viaHost+";branch="+this.id,this.request.setHeader("via",e),this.request_sender.ua.newTransaction(this),this.request.cancel=function(a){f.cancel_request(f,a)},this.initEvents(g)};e.prototype=new b.EventEmitter,e.prototype.stateChanged=function(a){this.state=a,this.emit("stateChanged")},e.prototype.send=function(){var d=this;this.stateChanged(c.STATUS_CALLING),this.B=a.setTimeout(function(){d.timer_B()},b.Timers.TIMER_B),this.transport.send(this.request)||this.onTransportError()},e.prototype.onTransportError=function(){this.logger.log("transport error occurred, deleting INVITE client transaction "+this.id),a.clearTimeout(this.B),a.clearTimeout(this.D),a.clearTimeout(this.M),this.stateChanged(c.STATUS_TERMINATED),this.request_sender.ua.destroyTransaction(this),this.state!==c.STATUS_ACCEPTED&&this.request_sender.onTransportError()},e.prototype.timer_M=function(){this.logger.log("Timer M expired for INVITE client transaction "+this.id),this.state===c.STATUS_ACCEPTED&&(a.clearTimeout(this.B),this.stateChanged(c.STATUS_TERMINATED),this.request_sender.ua.destroyTransaction(this))},e.prototype.timer_B=function(){this.logger.log("Timer B expired for INVITE client transaction "+this.id),this.state===c.STATUS_CALLING&&(this.stateChanged(c.STATUS_TERMINATED),this.request_sender.ua.destroyTransaction(this),this.request_sender.onRequestTimeout())},e.prototype.timer_D=function(){this.logger.log("Timer D expired for INVITE client transaction "+this.id),a.clearTimeout(this.B),this.stateChanged(c.STATUS_TERMINATED),this.request_sender.ua.destroyTransaction(this)},e.prototype.sendACK=function(c){var d=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: "+c.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\r\n",this.D=a.setTimeout(function(){d.timer_D()},b.Timers.TIMER_D),this.transport.send(this.ack)},e.prototype.cancel_request=function(a,d){var e=a.request;this.cancel=b.C.CANCEL+" "+e.ruri+" SIP/2.0\r\n",this.cancel+="Via: "+e.headers.Via.toString()+"\r\n",this.request.headers.Route&&(this.cancel+="Route: "+e.headers.Route.toString()+"\r\n"),this.cancel+="To: "+e.headers.To.toString()+"\r\n",this.cancel+="From: "+e.headers.From.toString()+"\r\n",this.cancel+="Call-ID: "+e.headers["Call-ID"].toString()+"\r\n",this.cancel+="CSeq: "+e.headers.CSeq.toString().split(" ")[0]+" CANCEL\r\n",d&&(this.cancel+="Reason: "+d+"\r\n"),this.cancel+="Content-Length: 0\r\n\r\n",this.state===c.STATUS_PROCEEDING&&this.transport.send(this.cancel)},e.prototype.receiveResponse=function(d){var e=this,f=d.status_code;if(f>=100&&199>=f)switch(this.state){case c.STATUS_CALLING:this.stateChanged(c.STATUS_PROCEEDING),this.request_sender.receiveResponse(d),this.cancel&&this.transport.send(this.cancel);break;case c.STATUS_PROCEEDING:this.request_sender.receiveResponse(d)}else if(f>=200&&299>=f)switch(this.state){case c.STATUS_CALLING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_ACCEPTED),this.M=a.setTimeout(function(){e.timer_M()},b.Timers.TIMER_M),this.request_sender.receiveResponse(d);break;case c.STATUS_ACCEPTED:this.request_sender.receiveResponse(d)}else if(f>=300&&699>=f)switch(this.state){case c.STATUS_CALLING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_COMPLETED),this.sendACK(d),this.request_sender.receiveResponse(d);break;case c.STATUS_COMPLETED:this.sendACK(d)}};var f=function(a,b,c){var d;this.transport=c,this.id="z9hG4bK"+Math.floor(1e7*Math.random()),this.request_sender=a,this.request=b,this.logger=a.ua.getLogger("sip.transaction.nict",this.id),d="SIP/2.0/"+(a.ua.configuration.hackViaTcp?"TCP":c.server.scheme),d+=" "+a.ua.configuration.viaHost+";branch="+this.id,this.request.setHeader("via",d)};f.prototype=new b.EventEmitter,f.prototype.send=function(){this.transport.send(this.request)||this.onTransportError()},f.prototype.onTransportError=function(){this.logger.log("transport error occurred, for an ACK client transaction "+this.id),this.request_sender.onTransportError() };var g=function(a,b){var d=["stateChanged"];this.type=c.NON_INVITE_SERVER,this.id=a.via_branch,this.request=a,this.transport=a.transport,this.ua=b,this.last_response="",a.server_transaction=this,this.logger=b.getLogger("sip.transaction.nist",this.id),this.state=c.STATUS_TRYING,b.newTransaction(this),this.initEvents(d)};g.prototype=new b.EventEmitter,g.prototype.stateChanged=function(a){this.state=a,this.emit("stateChanged")},g.prototype.timer_J=function(){this.logger.log("Timer J expired for non-INVITE server transaction "+this.id),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this)},g.prototype.onTransportError=function(){this.transportError||(this.transportError=!0,this.logger.log("transport error occurred, deleting non-INVITE server transaction "+this.id),a.clearTimeout(this.J),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this))},g.prototype.receiveResponse=function(d,e,f,g){var h=this;if(100===d)switch(this.state){case c.STATUS_TRYING:this.stateChanged(c.STATUS_PROCEEDING),this.transport.send(e)||this.onTransportError();break;case c.STATUS_PROCEEDING:this.last_response=e,this.transport.send(e)?f&&f():(this.onTransportError(),g&&g())}else if(d>=200&&699>=d)switch(this.state){case c.STATUS_TRYING:case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_COMPLETED),this.last_response=e,this.J=a.setTimeout(function(){h.timer_J()},b.Timers.TIMER_J),this.transport.send(e)?f&&f():(this.onTransportError(),g&&g());break;case c.STATUS_COMPLETED:}};var h=function(a,b){var d=["stateChanged"];this.type=c.INVITE_SERVER,this.id=a.via_branch,this.request=a,this.transport=a.transport,this.ua=b,this.last_response="",a.server_transaction=this,this.logger=b.getLogger("sip.transaction.ist",this.id),this.state=c.STATUS_PROCEEDING,b.newTransaction(this),this.resendProvisionalTimer=null,a.reply(100),this.initEvents(d)};h.prototype=new b.EventEmitter,h.prototype.stateChanged=function(a){this.state=a,this.emit("stateChanged")},h.prototype.timer_H=function(){this.logger.log("Timer H expired for INVITE server transaction "+this.id),this.state===c.STATUS_COMPLETED&&this.logger.warn("transactions","ACK for INVITE server transaction was never received, call will be terminated"),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this)},h.prototype.timer_I=function(){this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this)},h.prototype.timer_L=function(){this.logger.log("Timer L expired for INVITE server transaction "+this.id),this.state===c.STATUS_ACCEPTED&&(this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this))},h.prototype.onTransportError=function(){this.transportError||(this.transportError=!0,this.logger.log("transport error occurred, deleting INVITE server transaction "+this.id),null!==this.resendProvisionalTimer&&(a.clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),a.clearTimeout(this.L),a.clearTimeout(this.H),a.clearTimeout(this.I),this.stateChanged(c.STATUS_TERMINATED),this.ua.destroyTransaction(this))},h.prototype.resend_provisional=function(){this.transport.send(this.last_response)||this.onTransportError()},h.prototype.receiveResponse=function(d,e,f,g){var h=this;if(d>=100&&199>=d)switch(this.state){case c.STATUS_PROCEEDING:this.transport.send(e)||this.onTransportError(),this.last_response=e}if(d>100&&199>=d&&this.state===c.STATUS_PROCEEDING)null===this.resendProvisionalTimer&&(this.resendProvisionalTimer=a.setInterval(function(){h.resend_provisional()},b.Timers.PROVISIONAL_RESPONSE_INTERVAL));else if(d>=200&&299>=d)switch(this.state){case c.STATUS_PROCEEDING:this.stateChanged(c.STATUS_ACCEPTED),this.last_response=e,this.L=a.setTimeout(function(){h.timer_L()},b.Timers.TIMER_L),null!==this.resendProvisionalTimer&&(a.clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case c.STATUS_ACCEPTED:this.transport.send(e)?f&&f():(this.onTransportError(),g&&g())}else if(d>=300&&699>=d)switch(this.state){case c.STATUS_PROCEEDING:null!==this.resendProvisionalTimer&&(a.clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(e)?(this.stateChanged(c.STATUS_COMPLETED),this.H=a.setTimeout(function(){h.timer_H()},b.Timers.TIMER_H),f&&f()):(this.onTransportError(),g&&g())}};var i=function(d,e){var f;switch(e.method){case b.C.INVITE:if(f=d.transactions.ist[e.via_branch]){switch(f.state){case c.STATUS_PROCEEDING:f.transport.send(f.last_response);break;case c.STATUS_ACCEPTED:}return!0}break;case b.C.ACK:if(f=d.transactions.ist[e.via_branch],!f)return!1;if(f.state===c.STATUS_ACCEPTED)return!1;if(f.state===c.STATUS_COMPLETED)return f.state=c.STATUS_CONFIRMED,f.I=a.setTimeout(function(){f.timer_I()},b.Timers.TIMER_I),!0;break;case b.C.CANCEL:return f=d.transactions.ist[e.via_branch],f?(e.reply_sl(200),f.state===c.STATUS_PROCEEDING?!1:!0):(e.reply_sl(481),!0);default:if(f=d.transactions.nist[e.via_branch]){switch(f.state){case c.STATUS_TRYING:break;case c.STATUS_PROCEEDING:case c.STATUS_COMPLETED:f.transport.send(f.last_response)}return!0}}};b.Transactions={C:c,checkTransaction:i,NonInviteClientTransaction:d,InviteClientTransaction:e,AckClientTransaction:f,NonInviteServerTransaction:g,InviteServerTransaction:h}}(b),function(b){var c,d=function(b){var c;return c=function(a,b,c){this.dialog=a,this.applicant=b,this.request=c,this.reattempt=!1,this.reattemptTimer=null},c.prototype={send:function(){var a=this,c=new b.RequestSender(this,this.dialog.owner.ua);c.send(),this.request.method===b.C.INVITE&&c.clientTransaction.state!==b.Transactions.C.STATUS_TERMINATED&&(this.dialog.uac_pending_reply=!0,c.clientTransaction.on("stateChanged",function d(){(this.state===b.Transactions.C.STATUS_ACCEPTED||this.state===b.Transactions.C.STATUS_COMPLETED||this.state===b.Transactions.C.STATUS_TERMINATED)&&(this.off("stateChanged",d),a.dialog.uac_pending_reply=!1,a.dialog.uas_pending_reply===!1&&a.dialog.owner.onReadyToReinvite())}))},onRequestTimeout:function(){this.applicant.onRequestTimeout()},onTransportError:function(){this.applicant.onTransportError()},receiveResponse:function(c){var d=this;408===c.status_code||481===c.status_code?this.applicant.onDialogError(c):c.method===b.C.INVITE&&491===c.status_code?this.reattempt?this.applicant.receiveResponse(c):(this.request.cseq.value=this.dialog.local_seqnum+=1,this.reattemptTimer=a.setTimeout(function(){d.applicant.owner.status!==b.Session.C.STATUS_TERMINATED&&(d.reattempt=!0,d.request_sender.send())},this.getReattemptTimeout())):this.applicant.receiveResponse(c)}},c}(b),e={STATUS_EARLY:1,STATUS_CONFIRMED:2};c=function(a,c,d,f){var g;return this.uac_pending_reply=!1,this.uas_pending_reply=!1,c.hasHeader("contact")?(f=c instanceof b.IncomingResponse?c.status_code<200?e.STATUS_EARLY:e.STATUS_CONFIRMED:f||e.STATUS_CONFIRMED,g=c.parseHeader("contact"),"UAS"===d?(this.id={call_id:c.call_id,local_tag:c.to_tag,remote_tag:c.from_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this.state=f,this.remote_seqnum=c.cseq,this.local_uri=c.parseHeader("to").uri,this.remote_uri=c.parseHeader("from").uri,this.remote_target=g.uri,this.route_set=c.getHeaders("record-route"),this.invite_seqnum=c.cseq,this.local_seqnum=c.cseq):"UAC"===d&&(this.id={call_id:c.call_id,local_tag:c.from_tag,remote_tag:c.to_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this.state=f,this.invite_seqnum=c.cseq,this.local_seqnum=c.cseq,this.local_uri=c.parseHeader("from").uri,this.pracked=[],this.remote_uri=c.parseHeader("to").uri,this.remote_target=g.uri,this.route_set=c.getHeaders("record-route").reverse(),this.state!==e.STATUS_EARLY||a.hasOffer||(this.mediaHandler=a.mediaHandlerFactory(a))),this.logger=a.ua.getLogger("sip.dialog",this.id.toString()),this.owner=a,a.ua.dialogs[this.id.toString()]=this,void this.logger.log("new "+d+" dialog created with status "+(this.state===e.STATUS_EARLY?"EARLY":"CONFIRMED"))):{error:"unable to create a Dialog without Contact header field"}},c.prototype={update:function(a,b){this.state=e.STATUS_CONFIRMED,this.logger.log("dialog "+this.id.toString()+" changed to CONFIRMED state"),"UAC"===b&&(this.route_set=a.getHeaders("record-route").reverse())},terminate:function(){this.logger.log("dialog "+this.id.toString()+" deleted"),this.mediaHandler&&this.state!==e.STATUS_CONFIRMED&&this.mediaHandler.peerConnection.close(),delete this.owner.ua.dialogs[this.id.toString()]},createRequest:function(a,c,d){var e,f;return c=c||[],this.local_seqnum||(this.local_seqnum=Math.floor(1e4*Math.random())),e=a===b.C.CANCEL||a===b.C.ACK?this.invite_seqnum:this.local_seqnum+=1,f=new b.OutgoingRequest(a,this.remote_target,this.owner.ua,{cseq:e,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},c,d),f.dialog=this,f},checkInDialogRequest:function(a){var c=this;if(this.remote_seqnum){if(a.cseqthis.remote_seqnum&&(this.remote_seqnum=a.cseq)}else this.remote_seqnum=a.cseq;switch(a.method){case b.C.INVITE:if(this.uac_pending_reply===!0)a.reply(491);else{if(this.uas_pending_reply===!0){var d=(10*Math.random()|0)+1;return a.reply(500,null,["Retry-After:"+d]),!1}this.uas_pending_reply=!0,a.server_transaction.on("stateChanged",function e(){(this.state===b.Transactions.C.STATUS_ACCEPTED||this.state===b.Transactions.C.STATUS_COMPLETED||this.state===b.Transactions.C.STATUS_TERMINATED)&&(this.off("stateChanged",e),c.uas_pending_reply=!1,c.uac_pending_reply===!1&&c.owner.onReadyToReinvite())})}a.hasHeader("contact")&&a.server_transaction.on("stateChanged",function(){this.state===b.Transactions.C.STATUS_ACCEPTED&&(c.remote_target=a.parseHeader("contact").uri)});break;case b.C.NOTIFY:a.hasHeader("contact")&&a.server_transaction.on("stateChanged",function(){this.state===b.Transactions.C.STATUS_COMPLETED&&(c.remote_target=a.parseHeader("contact").uri)})}return!0},sendRequest:function(a,b,c){c=c||{};var e=c.extraHeaders||[],f=c.body||null,g=this.createRequest(b,e,f),h=new d(this,a,g);h.send()},receiveRequest:function(a){this.checkInDialogRequest(a)&&this.owner.receiveRequest(a)}},c.C=e,b.Dialog=c}(b),function(a){var b;b=function(b,c){this.logger=c.getLogger("sip.requestsender"),this.ua=c,this.applicant=b,this.method=b.request.method,this.request=b.request,this.credentials=null,this.challenged=!1,this.staled=!1,c.status!==a.UA.C.STATUS_USER_CLOSED||this.method===a.C.BYE&&this.method===a.C.ACK||this.onTransportError()},b.prototype={send:function(){switch(this.method){case"INVITE":this.clientTransaction=new a.Transactions.InviteClientTransaction(this,this.request,this.ua.transport);break;case"ACK":this.clientTransaction=new a.Transactions.AckClientTransaction(this,this.request,this.ua.transport);break;default:this.clientTransaction=new a.Transactions.NonInviteClientTransaction(this,this.request,this.ua.transport)}return this.clientTransaction.send(),this.clientTransaction},onRequestTimeout:function(){this.applicant.onRequestTimeout()},onTransportError:function(){this.applicant.onTransportError()},receiveResponse:function(b){var c,d,e,f=b.status_code;if(401!==f&&407!==f||null===this.ua.configuration.password)this.applicant.receiveResponse(b);else{if(401===b.status_code?(d=b.parseHeader("www-authenticate"),e="authorization"):(d=b.parseHeader("proxy-authenticate"),e="proxy-authorization"),!d)return this.logger.warn(b.status_code+" with wrong or missing challenge, cannot authenticate"),void this.applicant.receiveResponse(b);if(!this.challenged||!this.staled&&d.stale===!0){if(this.credentials||(this.credentials=new a.DigestAuthentication(this.ua)),!this.credentials.authenticate(this.request,d))return void this.applicant.receiveResponse(b);this.challenged=!0,d.stale&&(this.staled=!0),b.method===a.C.REGISTER?c=this.applicant.cseq+=1:this.request.dialog?c=this.request.dialog.local_seqnum+=1:(c=this.request.cseq+1,this.request.cseq=c),this.request.setHeader("cseq",c+" "+this.method),this.request.setHeader(e,this.credentials.toString()),this.send()}else this.applicant.receiveResponse(b)}}},a.RequestSender=b}(b),function(b){var c;c=function(a){var c={},d=1,e=["registered","unregistered"];this.registrar=a.configuration.registrarServer,this.expires=a.configuration.registerExpires,this.contact=a.contact.toString(),d&&(this.contact+=";reg-id="+d,this.contact+=';+sip.instance=""'),this.call_id=b.Utils.createRandomToken(22),this.cseq=80,this.to_uri=a.configuration.uri,c.to_uri=this.to_uri,c.call_id=this.call_id,c.cseq=this.cseq,b.Utils.augment(this,b.ClientContext,[a,"REGISTER",this.registrar,{params:c}]),this.registrationTimer=null,this.registrationExpiredTimer=null,this.registered=!1,this.logger=a.getLogger("sip.registercontext"),this.initMoreEvents(e)},c.prototype={register:function(c){var d,e=this;c=c||{},d=c.extraHeaders||[],d.push("Contact: "+this.contact+";expires="+this.expires),d.push("Allow: "+b.Utils.getAllowedMethods(this.ua)),this.receiveResponse=function(d){var f,g,h,i=d.getHeaders("contact").length;if(d.cseq===this.cseq)switch(null!==this.registrationTimer&&(a.clearTimeout(this.registrationTimer),this.registrationTimer=null),!0){case/^1[0-9]{2}$/.test(d.status_code):this.emit("progress",d);break;case/^2[0-9]{2}$/.test(d.status_code):if(this.emit("accepted",d),d.hasHeader("expires")&&(g=d.getHeader("expires")),null!==this.registrationExpiredTimer&&(a.clearTimeout(this.registrationExpiredTimer),this.registrationExpiredTimer=null),!i){this.logger.warn("no Contact header in response to REGISTER, response ignored");break}for(;i--;){if(f=d.parseHeader("contact",i),f.uri.user===this.ua.contact.uri.user){g=f.getParam("expires");break}f=null}if(!f){this.logger.warn("no Contact header pointing to us, response ignored");break}g||(g=this.expires),this.registrationTimer=a.setTimeout(function(){e.registrationTimer=null,e.register(c)},1e3*g-3e3),this.registrationExpiredTimer=a.setTimeout(function(){console.warn("registration expired"),e.registered&&e.unregistered(null,b.C.causes.EXPIRES)},1e3*g),f.hasParam("temp-gruu")&&(this.ua.contact.temp_gruu=f.getParam("temp-gruu").replace(/"/g,"")),f.hasParam("pub-gruu")&&(this.ua.contact.pub_gruu=f.getParam("pub-gruu").replace(/"/g,"")),this.registered=!0,this.emit("registered",d||null);break;case/^423$/.test(d.status_code):d.hasHeader("min-expires")?(this.expires=d.getHeader("min-expires"),this.register(c)):(this.logger.warn("423 response received for REGISTER without Min-Expires"),this.registrationFailure(d,b.C.causes.SIP_FAILURE_CODE));break;default:h=b.Utils.sipErrorCause(d.status_code),this.registrationFailure(d,h)}},this.onRequestTimeout=function(){this.registrationFailure(null,b.C.causes.REQUEST_TIMEOUT)},this.onTransportError=function(){this.registrationFailure(null,b.C.causes.CONNECTION_ERROR)},this.cseq++,this.request.cseq=this.cseq,this.request.setHeader("cseq",this.cseq+" REGISTER"),this.request.extraHeaders=d,this.send()},registrationFailure:function(a,b){this.emit("failed",a||null,b||null)},onTransportClosed:function(){this.registered_before=this.registered,null!==this.registrationTimer&&(a.clearTimeout(this.registrationTimer),this.registrationTimer=null),null!==this.registrationExpiredTimer&&(a.clearTimeout(this.registrationExpiredTimer),this.registrationExpiredTimer=null),this.registered&&this.unregistered(null,b.C.causes.CONNECTION_ERROR)},onTransportConnected:function(){this.register()},close:function(){this.registered_before=this.registered,this.unregister()},unregister:function(c){var d;return this.registered?(c=c||{},d=c.extraHeaders||[],this.registered=!1,null!==this.registrationTimer&&(a.clearTimeout(this.registrationTimer),this.registrationTimer=null),c.all?(d.push("Contact: *"),d.push("Expires: 0")):d.push("Contact: "+this.contact+";expires=0"),this.receiveResponse=function(c){var d;switch(!0){case/^1[0-9]{2}$/.test(c.status_code):this.emit("progress",c);break;case/^2[0-9]{2}$/.test(c.status_code):this.emit("accepted",c),null!==this.registrationExpiredTimer&&(a.clearTimeout(this.registrationExpiredTimer),this.registrationExpiredTimer=null),this.unregistered(c);break;default:d=b.Utils.sipErrorCause(c.status_code),this.unregistered(c,d)}},this.onRequestTimeout=function(){},this.onTransportError=function(){},this.cseq++,this.request.cseq=this.cseq,this.request.setHeader("cseq",this.cseq+" REGISTER"),this.request.extraHeaders=d,void this.send()):void this.logger.warn("already unregistered")},unregistered:function(a,b){this.registered=!1,this.emit("unregistered",a||null,b||null)}},b.RegisterContext=c}(b),function(a){var b=function(a,b){a=a,b=b};b.prototype={isReady:function(){},close:function(){},getDescription:function(a,b,c){a=a,b=b,c=c},setDescription:function(a,b,c){a=a,b=b,c=c}},a.MediaHandler=b}(b),function(a){var b;b=function(b,c,d,e){var f,g,h=d,i=["progress","accepted","rejected","failed","cancel"];if(void 0===d)throw new TypeError("Not enough arguments");if(d=b.normalizeTarget(d),!d)throw new TypeError("Invalid target: "+h);this.ua=b,this.logger=b.getLogger("sip.clientcontext"),this.method=c,f=e&&e.params,g=e&&e.extraHeaders||[],e&&e.body&&(this.body=e.body),e&&e.contentType&&(this.contentType=e.contentType,g.push("Content-Type: "+this.contentType)),this.request=new a.OutgoingRequest(this.method,d,this.ua,f,g),this.localIdentity=this.request.from,this.remoteIdentity=this.request.to,this.body&&(this.request.body=this.body),this.data={},this.initEvents(i)},b.prototype=new a.EventEmitter,b.prototype.send=function(){return new a.RequestSender(this,this.ua).send(),this},b.prototype.cancel=function(b){b=b||{};var c,d=b.status_code,e=b.reason_phrase;if(d&&200>d||d>699)throw new TypeError("Invalid status_code: "+d);d&&(e=e||a.C.REASON_PHRASE[d]||"",c="SIP ;cause="+d+' ;text="'+e+'"'),this.request.cancel(c),this.emit("cancel")},b.prototype.receiveResponse=function(b){var c=a.C.REASON_PHRASE[b.status_code]||"";switch(!0){case/^1[0-9]{2}$/.test(b.status_code):this.emit("progress",b,c);break;case/^2[0-9]{2}$/.test(b.status_code):this.ua.applicants[this]&&delete this.ua.applicants[this],this.emit("accepted",b,c);break;default:this.ua.applicants[this]&&delete this.ua.applicants[this],this.emit("rejected",b,c),this.emit("failed",b,c)}},b.prototype.onRequestTimeout=function(){this.emit("failed",null,a.C.causes.REQUEST_TIMEOUT)},b.prototype.onTransportError=function(){this.emit("failed",null,a.C.causes.CONNECTION_ERROR)},a.ClientContext=b}(b),function(a){var b;b=function(b,c){var d=["progress","accepted","rejected","failed"];this.ua=b,this.logger=b.getLogger("sip.servercontext"),this.request=c,this.transaction=c.method===a.C.INVITE?new a.Transactions.InviteServerTransaction(c,b):new a.Transactions.NonInviteServerTransaction(c,b),c.body&&(this.body=c.body),c.hasHeader("Content-Type")&&(this.contentType=c.getHeader("Content-Type")),this.method=c.method,this.data={},this.localIdentity=c.to,this.remoteIdentity=c.from,this.initEvents(d)},b.prototype=new a.EventEmitter,b.prototype.progress=function(b){b=b||{};var c,d=b.statusCode||180,e=b.reasonPhrase||a.C.REASON_PHRASE[d],f=b.extraHeaders||[],g=b.body;if(100>d||d>199)throw new TypeError("Invalid statusCode: "+d);return c=this.request.reply(d,e,f,g),this.emit("progress",c,e),this},b.prototype.accept=function(b){b=b||{};var c,d=b.statusCode||200,e=b.reasonPhrase||a.C.REASON_PHRASE[d],f=b.extraHeaders||[],g=b.body;if(200>d||d>299)throw new TypeError("Invalid statusCode: "+d);return c=this.request.reply(d,e,f,g),this.emit("accepted",c,e),this},b.prototype.reject=function(b){b=b||{};var c,d=b.statusCode||480,e=b.reasonPhrase||a.C.REASON_PHRASE[d],f=b.extraHeaders||[],g=b.body;if(300>d||d>699)throw new TypeError("Invalid statusCode: "+d);return c=this.request.reply(d,e,f,g),this.emit("rejected",c,e),this.emit("failed",c,e),this},b.prototype.reply=function(a){a=a||{};var b=a.statusCode,c=a.reasonPhrase,d=a.extraHeaders||[],e=a.body;return this.request.reply(b,c,d,e),this},b.prototype.onRequestTimeout=function(){this.emit("failed",null,a.C.causes.REQUEST_TIMEOUT)},b.prototype.onTransportError=function(){this.emit("failed",null,a.C.causes.CONNECTION_ERROR)},a.ServerContext=b}(b),function(b){var c,d,e,f=function(a){var b,c={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};return b=function(a){var b=["succeeded","failed"];this.logger=a.ua.getLogger("sip.invitecontext.dtmf",a.id),this.owner=a,this.direction=null,this.tone=null,this.duration=null,this.initEvents(b)},b.prototype=new a.EventEmitter,b.prototype.send=function(b,c){var d,e,f,g;if(void 0===b)throw new TypeError("Not enough arguments");if(this.direction="outgoing",this.owner.status!==a.Session.C.STATUS_CONFIRMED&&this.owner.status!==a.Session.C.STATUS_WAITING_FOR_ACK)throw new a.Exceptions.InvalidStateError(this.owner.status);if(c=c||{},f=c.extraHeaders?c.extraHeaders.slice():[],e=c.eventHandlers||{},"string"==typeof b)b=b.toUpperCase();else{if("number"!=typeof b)throw new TypeError("Invalid tone: "+b);b=b.toString()}if(!b.match(/^[0-9A-D#*]$/))throw new TypeError("Invalid tone: "+b);this.tone=b,this.duration=c.duration;for(d in e)this.on(d,e[d]);f.push("Content-Type: application/dtmf-relay"),g="Signal= "+this.tone+"\r\n",g+="Duration= "+this.duration,this.owner.emit("dtmf",{originator:"local",dtmf:this,request:this.request}),this.owner.dialog.sendRequest(this,a.C.INFO,{extraHeaders:f,body:g})},b.prototype.receiveResponse=function(b){var c;switch(!0){case/^1[0-9]{2}$/.test(b.status_code):break;case/^2[0-9]{2}$/.test(b.status_code):this.emit("succeeded",{originator:"remote",response:b});break;default:c=a.Utils.sipErrorCause(b.status_code),this.emit("failed",b,c)}},b.prototype.onRequestTimeout=function(){this.emit("failed",null,a.C.causes.REQUEST_TIMEOUT),this.owner.onRequestTimeout()},b.prototype.onTransportError=function(){this.emit("failed",null,a.C.causes.CONNECTION_ERROR),this.owner.onTransportError()},b.prototype.onDialogError=function(b){this.emit("failed",b,a.C.causes.DIALOG_ERROR),this.owner.onDialogError(b)},b.prototype.init_incoming=function(a){var b,c=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,d=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;this.direction="incoming",this.request=a,a.reply(200),a.body&&(b=a.body.split("\r\n"),2===b.length&&(c.test(b[0])&&(this.tone=b[0].replace(c,"$2")),d.test(b[1])&&(this.duration=parseInt(b[1].replace(d,"$2"),10)))),this.tone&&this.duration?this.owner.emit("dtmf",{originator:"remote",dtmf:this,request:a}):this.logger.warn("invalid INFO DTMF received, discarded")},b.C=c,b}(b),g={STATUS_NULL:0,STATUS_INVITE_SENT:1,STATUS_1XX_RECEIVED:2,STATUS_INVITE_RECEIVED:3,STATUS_WAITING_FOR_ANSWER:4,STATUS_ANSWERED:5,STATUS_WAITING_FOR_PRACK:6,STATUS_WAITING_FOR_ACK:7,STATUS_CANCELED:8,STATUS_TERMINATED:9,STATUS_ANSWERED_WAITING_FOR_PRACK:10,STATUS_EARLY_MEDIA:11,STATUS_CONFIRMED:12};c=function(a){var c=["connecting","terminated","dtmf","invite","cancel","referred","refer","bye","hold","unhold","muted","unmuted"];this.status=g.STATUS_NULL,this.dialog=null,this.earlyDialogs={},this.mediaHandlerFactory=a||b.WebRTC.MediaHandler.defaultFactory,this.hasOffer=!1,this.hasAnswer=!1,this.timers={ackTimer:null,expiresTimer:null,invite2xxTimer:null,userNoAnswerTimer:null,rel1xxTimer:null,prackTimer:null},this.startTime=null,this.endTime=null,this.tones=null,this.local_hold=!1,this.remote_hold=!1,this.pending_actions={actions:[],length:function(){return this.actions.length},isPending:function(a){var b=0,c=this.actions.length;for(b;c>b;b++)if(this.actions[b].name===a)return!0;return!1},shift:function(){return this.actions.shift()},push:function(a){this.actions.push({name:a})},pop:function(a){var b=0,c=this.actions.length;for(b;c>b;b++)this.actions[b].name===a&&(this.actions.splice(b,1),c--,b--)}},this.early_sdp=null,this.rel100=b.C.supported.UNSUPPORTED,this.initMoreEvents(c)},c.prototype={dtmf:function(c,d){var e,h,i=0,j=this;if(d=d||{},e=d.duration||null,h=d.interToneGap||null,void 0===c)throw new TypeError("Not enough arguments");if(this.status!==g.STATUS_CONFIRMED&&this.status!==g.STATUS_WAITING_FOR_ACK)throw new b.Exceptions.InvalidStateError(this.status);if(!c||"string"!=typeof c&&"number"!=typeof c||!c.toString().match(/^[0-9A-D#*,]+$/i))throw new TypeError("Invalid tones: "+c);if(c=c.toString(),e&&!b.Utils.isDecimal(e))throw new TypeError("Invalid tone duration: "+e);if(e?ef.C.MAX_DURATION?(this.logger.warn('"duration" value is greater than the maximum allowed, setting it to '+f.C.MAX_DURATION+" milliseconds"),e=f.C.MAX_DURATION):e=Math.abs(e):e=f.C.DEFAULT_DURATION,d.duration=e,h&&!b.Utils.isDecimal(h))throw new TypeError("Invalid interToneGap: "+h);if(h?h=l.length)return j.tones=null,this;if(b=l[i],i+=1,","===b)c=2e3;else{var m=new f(j);m.on("failed",function(){j.tones=null}),m.send(b,d),c=e+h}a.setTimeout(k,c)};return k(),this},bye:function(a){a=a||{};var c=a.statusCode;if(this.status===g.STATUS_TERMINATED)return this.logger.error("Error: Attempted to send BYE in a terminated session."),this;if(this.logger.log("terminating Session"),c&&(200>c||c>=700))throw new TypeError("Invalid statusCode: "+c);return a.receiveResponse=function(){},this.sendRequest(b.C.BYE,a).terminated()},refer:function(a,c){c=c||{};var d,e=c.extraHeaders||[];if(void 0===a)throw new TypeError("Not enough arguments");if(a instanceof b.InviteServerContext||a instanceof b.InviteClientContext)e.push("Contact: "+this.contact),e.push("Allow: "+b.Utils.getAllowedMethods(this.ua)),e.push("Refer-To: <"+a.dialog.remote_target.toString()+"?Replaces="+a.dialog.id.call_id+"%3Bto-tag%3D"+a.dialog.id.remote_tag+"%3Bfrom-tag%3D"+a.dialog.id.local_tag+">");else{if(this.status!==g.STATUS_CONFIRMED)throw new b.Exceptions.InvalidStateError(this.status);if(a=this.ua.normalizeTarget(a),!a)throw new TypeError("Invalid target: "+d);e.push("Contact: "+this.contact),e.push("Allow: "+b.Utils.getAllowedMethods(this.ua)),e.push("Refer-To: "+a)}return this.sendRequest(b.C.REFER,{extraHeaders:e,body:c.body,receiveResponse:function(){}}).terminate()},sendRequest:function(a,c){c=c||{};var d=this,e=new b.OutgoingRequest(a,this.dialog.remote_target,this.ua,{cseq:c.cseq||(this.dialog.local_seqnum+=1),call_id:this.dialog.id.call_id,from_uri:this.dialog.local_uri,from_tag:this.dialog.id.local_tag,to_uri:this.dialog.remote_uri,to_tag:this.dialog.id.remote_tag,route_set:this.dialog.route_set,statusCode:c.statusCode,reasonPhrase:c.reasonPhrase},c.extraHeaders||[],c.body);return new b.RequestSender({request:e,onRequestTimeout:function(){d.onRequestTimeout()},onTransportError:function(){d.onTransportError()},receiveResponse:c.receiveResponse||function(a){d.receiveNonInviteResponse(a)}},this.ua).send(),this.checkEvent(a.toLowerCase())&&this.emit(a.toLowerCase(),e),this},close:function(){var b;if(this.status===g.STATUS_TERMINATED)return this;this.logger.log("closing INVITE session "+this.id),this.mediaHandler&&this.mediaHandler.close();for(b in this.timers)a.clearTimeout(this.timers[b]);this.dialog&&(this.dialog.terminate(),delete this.dialog);for(b in this.earlyDialogs)this.earlyDialogs[b].terminate(),delete this.earlyDialogs[b];return this.status=g.STATUS_TERMINATED,delete this.ua.sessions[this.id],this},createDialog:function(a,c,d){var e,f,g=a["UAS"===c?"to_tag":"from_tag"],h=a["UAS"===c?"from_tag":"to_tag"],i=a.call_id+g+h;if(f=this.earlyDialogs[i],d)return f?!0:(f=new b.Dialog(this,a,c,b.Dialog.C.STATUS_EARLY),f.error?(this.logger.error(f.error),this.failed(a,b.C.causes.INTERNAL_ERROR),!1):(this.earlyDialogs[i]=f,!0));if(f){f.update(a,c),this.dialog=f,delete this.earlyDialogs[i];for(var j in this.earlyDialogs)this.earlyDialogs[j].terminate(),delete this.earlyDialogs[j];return!0}return e=new b.Dialog(this,a,c),e.error?(this.logger.error(e.error),this.failed(a,b.C.causes.INTERNAL_ERROR),!1):(this.to_tag=a.to_tag,this.dialog=e,!0)},isReadyToReinvite:function(){return this.mediaHandler.isReady()&&!this.dialog.uac_pending_reply&&!this.dialog.uas_pending_reply},mute:function(a){var b=this.mediaHandler.mute(a);b&&this.onmute(b)},unmute:function(a){a=a||{},a.local_hold=this.local_hold;var b=this.mediaHandler.unmute(a);b&&this.onunmute(b)},hold:function(){if(this.status!==g.STATUS_WAITING_FOR_ACK&&this.status!==g.STATUS_CONFIRMED)throw new b.Exceptions.InvalidStateError(this.status);return this.mediaHandler.hold(),this.isReadyToReinvite()?void(this.local_hold!==!0&&(this.onhold("local"),this.sendReinvite({mangle:function(a){return/a=(sendrecv|sendonly|recvonly|inactive)/.test(a)?(a=a.replace(/a=sendrecv\r\n/g,"a=sendonly"),a=a.replace(/a=recvonly\r\n/g,"a=inactive")):a=a.replace(/(m=[^\r]*\r\n)/g,"$1a=sendonly\r\n"),a}}))):void(this.pending_actions.isPending("unhold")?this.pending_actions.pop("unhold"):this.pending_actions.isPending("hold")||this.pending_actions.push("hold"))},unhold:function(){if(this.status!==g.STATUS_WAITING_FOR_ACK&&this.status!==g.STATUS_CONFIRMED)throw new b.Exceptions.InvalidStateError(this.status);return this.mediaHandler.unhold(),this.isReadyToReinvite()?void(this.local_hold!==!1&&(this.onunhold("local"),this.sendReinvite())):void(this.pending_actions.isPending("hold")?this.pending_actions.pop("hold"):this.pending_actions.isPending("unhold")||this.pending_actions.push("unhold"))},isOnHold:function(){return{local:this.local_hold,remote:this.remote_hold}},receiveReinvite:function(a){var b=this,c=a.getHeader("Content-Type"),d=!0;if(a.body){if("application/sdp"!==c)return this.logger.warn("invalid Content-Type"),void a.reply(415);d=/a=(sendonly|inactive)/.test(a.body),this.mediaHandler.setDescription(a.body,function(){b.mediaHandler.getDescription(function(c){a.reply(200,null,["Contact: "+b.contact],c,function(){b.status=g.STATUS_WAITING_FOR_ACK,b.setInvite2xxTimer(a,c),b.setACKTimer(),b.remote_hold&&!d?b.onunhold("remote"):!b.remote_hold&&d&&b.onhold("remote")})},function(){a.reply(500)},b.mediaHint)},function(c){b.logger.error(c),a.reply(488)})}},sendReinvite:function(c){c=c||{};var d=this,e=c.extraHeaders||[],f=c.eventHandlers||{},h=c.mangle||null;this.reinviteSucceeded=f.succeeded?f.succeeded:function(){a.clearTimeout(d.timers.ackTimer),a.clearTimeout(d.timers.invite2xxTimer),d.status=g.STATUS_CONFIRMED},this.reinviteFailed=f.failed?f.failed:function(){},e.push("Contact: "+this.contact),e.push("Allow: "+b.Utils.getAllowedMethods(this.ua)),e.push("Content-Type: application/sdp"),this.receiveResponse=this.receiveReinviteResponse,this.mediaHandler.getDescription(function(a){h&&(a=h(a)),d.dialog.sendRequest(d,b.C.INVITE,{extraHeaders:e,body:a})},function(){d.isReadyToReinvite()&&d.onReadyToReinvite(),d.reinviteFailed()},d.mediaHint)},receiveRequest:function(a){switch(a.method){case b.C.BYE:a.reply(200),this.status===g.STATUS_CONFIRMED&&(this.emit("bye",a),this.terminated(a,b.C.causes.BYE));break;case b.C.INVITE:this.status===g.STATUS_CONFIRMED&&(this.logger.log("re-INVITE received"),this.receiveReinvite(a));break;case b.C.INFO:if(this.status===g.STATUS_CONFIRMED||this.status===g.STATUS_WAITING_FOR_ACK){var c=a.getHeader("content-type");c&&c.match(/^application\/dtmf-relay/i)&&new f(this).init_incoming(a)}break;case b.C.REFER:if(this.status===g.STATUS_CONFIRMED){this.logger.log("REFER received"),a.reply(202,"Accepted");var d=this.checkListener("refer"),e=this.checkListener("referred"),h=d||e?"SIP/2.0 100 Trying":"SIP/2.0 603 Declined";if(this.sendRequest(b.C.NOTIFY,{extraHeaders:["Event: refer","Subscription-State: terminated","Content-Type: message/sipfrag"],body:h,receiveResponse:function(){}}),d)this.emit("refer",a.parseHeader("refer-to").uri,a); else if(e){b.Hacks.Chrome.getsConfusedAboutGUM(this);var i=this.ua.invite(a.parseHeader("refer-to").uri,{media:this.mediaHint});this.referred(a,i),this.terminate()}}}},receiveReinviteResponse:function(a){var c=this,d=a.getHeader("Content-Type");if(this.status!==g.STATUS_TERMINATED)switch(!0){case/^1[0-9]{2}$/.test(a.status_code):break;case/^2[0-9]{2}$/.test(a.status_code):if(this.status=g.STATUS_CONFIRMED,this.sendRequest(b.C.ACK,{cseq:a.cseq}),!a.body){this.reinviteFailed();break}if("application/sdp"!==d){this.reinviteFailed();break}this.mediaHandler.setDescription(a.body,function(){c.reinviteSucceeded()},function(){c.reinviteFailed()});break;default:this.reinviteFailed()}},acceptAndTerminate:function(a,c,d){var e=[];return c&&(d=d||b.C.REASON_PHRASE[c]||"",e.push("Reason: SIP ;cause="+c+'; text="'+d+'"')),(this.dialog||this.createDialog(a,"UAC"))&&(this.sendRequest(b.C.ACK,{cseq:a.cseq}),this.sendRequest(b.C.BYE,{extraHeaders:e})),this},setInvite2xxTimer:function(c,d){var e=this,f=b.Timers.T1;this.timers.invite2xxTimer=a.setTimeout(function h(){e.status===g.STATUS_WAITING_FOR_ACK&&(c.reply(200,null,["Contact: "+e.contact],d),f=Math.min(2*f,b.Timers.T2),e.timers.invite2xxTimer=a.setTimeout(h,f))},f)},setACKTimer:function(){var c=this;this.timers.ackTimer=a.setTimeout(function(){c.status===g.STATUS_WAITING_FOR_ACK&&(c.logger.log("no ACK received, terminating the call"),a.clearTimeout(c.timers.invite2xxTimer),c.sendRequest(b.C.BYE),c.terminated(null,b.C.causes.NO_ACK))},b.Timers.TIMER_H)},onReadyToReinvite:function(){var a=this.pending_actions.shift();a&&this[a.name]&&this[a.name]()},onTransportError:function(){this.status===g.STATUS_CONFIRMED?this.terminated(null,b.C.causes.CONNECTION_ERROR):this.status!==g.STATUS_TERMINATED&&this.failed(null,b.C.causes.CONNECTION_ERROR)},onRequestTimeout:function(){this.status===g.STATUS_CONFIRMED?this.terminated(null,b.C.causes.REQUEST_TIMEOUT):this.status!==g.STATUS_TERMINATED&&this.failed(null,b.C.causes.REQUEST_TIMEOUT)},onDialogError:function(a){this.status===g.STATUS_CONFIRMED?this.terminated(a,b.C.causes.DIALOG_ERROR):this.status!==g.STATUS_TERMINATED&&this.failed(a,b.C.causes.DIALOG_ERROR)},onhold:function(a){this["local"===a?"local_hold":"remote_hold"]=!0,this.emit("hold",{originator:a})},onunhold:function(a){this["local"===a?"local_hold":"remote_hold"]=!1,this.emit("unhold",{originator:a})},onmute:function(a){this.emit("muted",{audio:a.audio,video:a.video})},onunmute:function(a){this.emit("unmuted",{audio:a.audio,video:a.video})},failed:function(a,b){return this.close(),this.emit("failed",a,b)},rejected:function(a,b){return this.close(),this.emit("rejected",a||null,b)},referred:function(a,b){return this.emit("referred",a||null,b||null)},canceled:function(){return this.close(),this.emit("cancel")},accepted:function(a){var b=a?a.status_code:null;return this.startTime=new Date,this.emit("accepted",{code:b,response:a||null})},terminated:function(a,b){return this.endTime=new Date,this.close(),this.emit("terminated",{message:a||null,cause:b||null})},connecting:function(a){return this.emit("connecting",{request:a})}},c.C=g,b.Session=c,d=function(c,d){function e(a,b){d.hasHeader(a)&&d.getHeader(a).toLowerCase().indexOf("100rel")>=0&&(i.rel100=b)}function f(){var c={extraHeaders:["Contact: "+i.contact]};i.rel100!==b.C.supported.REQUIRED&&i.progress(c),i.status=g.STATUS_WAITING_FOR_ANSWER,i.timers.userNoAnswerTimer=a.setTimeout(function(){d.reply(408),i.failed(d,b.C.causes.NO_ANSWER)},i.ua.configuration.noAnswerTimeout),h&&(i.timers.expiresTimer=a.setTimeout(function(){i.status===g.STATUS_WAITING_FOR_ANSWER&&(d.reply(487),i.failed(d,b.C.causes.EXPIRES))},h)),i.emit("invite",d)}var h,i=this,j=d.getHeader("Content-Type"),k=d.getHeader("Content-Disposition");if(!k&&"application/sdp"!==j||k&&k.indexOf("render")>=0)this.renderbody=d.body,this.rendertype=j;else if("application/sdp"!==j&&k&&"session"===k)return void d.reply(415);return b.Hacks.Firefox.cannotHandleRelayCandidates(d),b.Hacks.Firefox.cannotHandleExtraWhitespace(d),b.Utils.augment(this,b.ServerContext,[c,d]),b.Utils.augment(this,b.Session,[c.configuration.mediaHandlerFactory]),this.status=g.STATUS_INVITE_RECEIVED,this.from_tag=d.from_tag,this.id=d.call_id+this.from_tag,this.request=d,this.contact=this.ua.contact.toString(),this.logger=c.getLogger("sip.inviteservercontext",this.id),this.ua.sessions[this.id]=this,d.hasHeader("expires")&&(h=1e3*d.getHeader("expires")),e("require",b.C.supported.REQUIRED),e("supported",b.C.supported.SUPPORTED),d.to_tag=b.Utils.newTag(),this.createDialog(d,"UAS",!0)?(this.mediaHandler=this.mediaHandlerFactory(this,{RTCConstraints:{optional:[{DtlsSrtpKeyAgreement:"true"}]}}),this.mediaHandler&&this.mediaHandler.getRemoteStreams&&(this.getRemoteStreams=this.mediaHandler.getRemoteStreams.bind(this.mediaHandler),this.getLocalStreams=this.mediaHandler.getLocalStreams.bind(this.mediaHandler)),void(!d.body||this.renderbody?setTimeout(f,0):(this.hasOffer=!0,this.mediaHandler.setDescription(d.body,f,function(a){i.logger.warn("invalid SDP"),i.logger.warn(a),d.reply(488)})))):void d.reply(500,"Missing Contact header field")},d.prototype={reject:function(a){if(this.status===g.STATUS_TERMINATED)throw new b.Exceptions.InvalidStateError(this.status);return this.logger.log("rejecting RTCSession"),b.ServerContext.prototype.reject.apply(this,[a]),this.terminated()},terminate:function(a){a=a||{};var c,d=a.extraHeaders||[],e=a.body,f=this;return this.status===g.STATUS_WAITING_FOR_ACK&&this.request.server_transaction.state!==b.Transactions.C.STATUS_TERMINATED?(c=this.dialog,this.receiveRequest=function(a){a.method===b.C.ACK&&(this.request(b.C.BYE,{extraHeaders:d,body:e}),c.terminate())},this.request.server_transaction.on("stateChanged",function(){this.state===b.Transactions.C.STATUS_TERMINATED&&(this.request=new b.OutgoingRequest(b.C.BYE,this.dialog.remote_target,this.ua,{cseq:this.dialog.local_seqnum+=1,call_id:this.dialog.id.call_id,from_uri:this.dialog.local_uri,from_tag:this.dialog.id.local_tag,to_uri:this.dialog.remote_uri,to_tag:this.dialog.id.remote_tag,route_set:this.dialog.route_set},d,e),new b.RequestSender({request:this.request,onRequestTimeout:function(){f.onRequestTimeout()},onTransportError:function(){f.onTransportError()},receiveResponse:function(){}},this.ua).send(),c.terminate())}),this.emit("bye",this.request),this.terminated(),this.dialog=c,this.ua.dialogs[c.id.toString()]=c):this.status===g.STATUS_CONFIRMED?this.bye(a):this.reject(a),this},progress:function(c){function d(){h=c.statusCode||183,this.status=g.STATUS_WAITING_FOR_PRACK,j.push("Contact: "+this.contact),j.push("Require: 100rel"),j.push("RSeq: "+Math.floor(1e4*Math.random())),this.mediaHint=c.media,this.mediaHandler.getDescription(function(c){if(!this.isCanceled&&this.status!==g.STATUS_TERMINATED){this.early_sdp=c,this[this.hasOffer?"hasAnswer":"hasOffer"]=!0;var d=b.Timers.T1;this.timers.rel1xxTimer=a.setTimeout(function e(){this.request.reply(h,null,j,c),d*=2,this.timers.rel1xxTimer=a.setTimeout(e.bind(this),d)}.bind(this),d),this.timers.prackTimer=a.setTimeout(function(){this.status===g.STATUS_WAITING_FOR_PRACK&&(this.logger.log("no PRACK received, rejecting the call"),a.clearTimeout(this.timers.rel1xxTimer),this.request.reply(504),this.terminated(null,b.C.causes.NO_PRACK))}.bind(this),64*b.Timers.T1),f=this.request.reply(h,i,j,c),this.emit("progress",f)}}.bind(this),function(){this.failed(null,b.C.causes.WEBRTC_ERROR)}.bind(this),c.media)}function e(){f=this.request.reply(h,i,j,k),this.emit("progress",f)}c=c||{};var f,h=c.statusCode||180,i=c.reasonPhrase,j=c.extraHeaders||[],k=c.body;if(100>h||h>199)throw new TypeError("Invalid statusCode: "+h);return this.isCanceled||this.status===g.STATUS_TERMINATED?this:(100!==c.statusCode&&(this.rel100===b.C.supported.REQUIRED||this.rel100===b.C.supported.SUPPORTED&&c.rel100)?d.apply(this):e.apply(this),this)},accept:function(c){c=c||{},b.Utils.optionsOverride(c,"media","mediaConstraints",!0,this.logger,this.ua.configuration.media),this.mediaHint=c.media;var d=this,e=this.request,f=c.extraHeaders||[],h=function(a){var c=function(){d.status=g.STATUS_WAITING_FOR_ACK,d.setInvite2xxTimer(e,a),d.setACKTimer(),d.hasAnswer&&d.accepted()},h=function(){d.failed(null,b.C.causes.CONNECTION_ERROR)};f.push("Contact: "+d.contact),d.hasOffer?d.hasAnswer=!0:d.hasOffer=!0,e.reply(200,null,f,a,c,h)},i=function(){d.status!==g.STATUS_TERMINATED&&d.failed(null,b.C.causes.WEBRTC_ERROR)};if(this.status===g.STATUS_WAITING_FOR_PRACK)return this.status=g.STATUS_ANSWERED_WAITING_FOR_PRACK,this;if(this.status===g.STATUS_WAITING_FOR_ANSWER)this.status=g.STATUS_ANSWERED;else if(this.status!==g.STATUS_EARLY_MEDIA)throw new b.Exceptions.InvalidStateError(this.status);return this.createDialog(e,"UAS")?(a.clearTimeout(this.timers.userNoAnswerTimer),this.status===g.STATUS_EARLY_MEDIA?h():this.mediaHandler.getDescription(h,i,d.mediaHint),this):(e.reply(500,"Missing Contact header field"),this)},receiveRequest:function(d){function e(){var b;a.clearTimeout(this.timers.ackTimer),a.clearTimeout(this.timers.invite2xxTimer),this.status=g.STATUS_CONFIRMED,this.unmute(),b=d.getHeader("Content-Type"),"application/sdp"!==b&&(this.renderbody=d.body,this.rendertype=b),this.accepted()}switch(d.method){case b.C.CANCEL:(this.status===g.STATUS_WAITING_FOR_ANSWER||this.status===g.STATUS_WAITING_FOR_PRACK||this.status===g.STATUS_ANSWERED_WAITING_FOR_PRACK||this.status===g.STATUS_EARLY_MEDIA||this.status===g.STATUS_ANSWERED)&&(this.status=g.STATUS_CANCELED,this.request.reply(487),this.canceled(d),this.rejected(d,b.C.causes.CANCELED),this.failed(d,b.C.causes.CANCELED));break;case b.C.ACK:this.status===g.STATUS_WAITING_FOR_ACK&&(this.hasAnswer?e.apply(this):d.body&&"application/sdp"===d.getHeader("content-type")?(b.Hacks.Firefox.cannotHandleRelayCandidates(d),b.Hacks.Firefox.cannotHandleExtraWhitespace(d),this.hasAnswer=!0,this.mediaHandler.setDescription(d.body,e.bind(this),function(a){this.logger.warn(a),this.terminate({statusCode:"488",reasonPhrase:"Bad Media Description"}),this.failed(d,b.C.causes.BAD_MEDIA_DESCRIPTION)}.bind(this))):this.early_sdp?e.apply(this):this.failed(d,b.C.causes.BAD_MEDIA_DESCRIPTION));break;case b.C.PRACK:this.status===g.STATUS_WAITING_FOR_PRACK||this.status===g.STATUS_ANSWERED_WAITING_FOR_PRACK?this.hasAnswer?(a.clearTimeout(this.timers.rel1xxTimer),a.clearTimeout(this.timers.prackTimer),d.reply(200),this.status===g.STATUS_ANSWERED_WAITING_FOR_PRACK&&(this.status=g.STATUS_EARLY_MEDIA,this.accept()),this.status=g.STATUS_EARLY_MEDIA,this.mute()):d.body&&"application/sdp"===d.getHeader("content-type")?(this.hasAnswer=!0,this.mediaHandler.setDescription(d.body,function(){a.clearTimeout(this.timers.rel1xxTimer),a.clearTimeout(this.timers.prackTimer),d.reply(200),this.status===g.STATUS_ANSWERED_WAITING_FOR_PRACK&&(this.status=g.STATUS_EARLY_MEDIA,this.accept()),this.status=g.STATUS_EARLY_MEDIA,this.mute()}.bind(this),function(a){this.logger.warn(a),this.terminate({statusCode:"488",reasonPhrase:"Bad Media Description"}),this.failed(d,b.C.causes.BAD_MEDIA_DESCRIPTION)}.bind(this))):(this.terminate({statusCode:"488",reasonPhrase:"Bad Media Description"}),this.failed(d,b.C.causes.BAD_MEDIA_DESCRIPTION)):this.status===g.STATUS_EARLY_MEDIA&&d.reply(200);break;default:c.prototype.receiveRequest.apply(this,[d])}}},b.InviteServerContext=d,e=function(a,c,d){d=d||{};var e,f,h=d.extraHeaders||[],i=d.stunServers||null,j=d.turnServers||null;if(!b.WebRTC.isSupported)throw new b.Exceptions.NotSupportedError("WebRTC not supported");if(this.RTCConstraints=d.RTCConstraints||{},this.inviteWithoutSdp=d.inviteWithoutSdp||!1,this.anonymous=d.anonymous||!1,this.renderbody=d.renderbody||null,this.rendertype=d.rendertype||"text/plain",e={from_tag:this.from_tag},this.contact=a.contact.toString({anonymous:this.anonymous,outbound:this.anonymous?!a.contact.temp_gruu:!a.contact.pub_gruu}),this.anonymous&&(e.from_displayName="Anonymous",e.from_uri="sip:anonymous@anonymous.invalid",h.push("P-Preferred-Identity: "+a.configuration.uri.toString()),h.push("Privacy: id")),h.push("Contact: "+this.contact),h.push("Allow: "+b.Utils.getAllowedMethods(a)),this.inviteWithoutSdp?this.renderbody&&(h.push("Content-Type: "+this.rendertype),h.push("Content-Disposition: render;handling=optional")):h.push("Content-Type: application/sdp"),"required"===a.configuration.reliable&&h.push("Require: 100rel"),d.extraHeaders=h,d.params=e,b.Utils.augment(this,b.ClientContext,[a,b.C.INVITE,c,d]),b.Utils.augment(this,b.Session,[a.configuration.mediaHandlerFactory]),this.status!==g.STATUS_NULL)throw new b.Exceptions.InvalidStateError(this.status);if(this.from_tag=b.Utils.newTag(),this.isCanceled=!1,this.received_100=!1,this.method=b.C.INVITE,this.receiveNonInviteResponse=this.receiveResponse,this.receiveResponse=this.receiveInviteResponse,this.logger=a.getLogger("sip.inviteclientcontext"),i){if(f=b.UA.configuration_check.optional.stunServers(i),!f)throw new TypeError("Invalid stunServers: "+i);this.stunServers=f}if(j){if(f=b.UA.configuration_check.optional.turnServers(j),!f)throw new TypeError("Invalid turnServers: "+j);this.turnServers=f}a.applicants[this]=this,this.id=this.request.call_id+this.from_tag,this.mediaHandler=this.mediaHandlerFactory(this,{RTCConstraints:this.RTCConstraints,stunServers:this.stunServers,turnServers:this.turnServers}),this.mediaHandler&&this.mediaHandler.getRemoteStreams&&(this.getRemoteStreams=this.mediaHandler.getRemoteStreams.bind(this.mediaHandler),this.getLocalStreams=this.mediaHandler.getLocalStreams.bind(this.mediaHandler))},e.prototype={invite:function(a){var c=this;return a=a||{},b.Utils.optionsOverride(a,"media","mediaConstraints",!0,this.logger,this.ua.configuration.media),this.mediaHint=a.media,this.ua.sessions[this.id]=this,this.inviteWithoutSdp?(this.request.body=c.renderbody,this.status=g.STATUS_INVITE_SENT,this.send()):this.mediaHandler.getDescription(function(a){c.isCanceled||c.status===g.STATUS_TERMINATED||(c.hasOffer=!0,c.request.body=a,c.status=g.STATUS_INVITE_SENT,c.send())},function(){c.status!==g.STATUS_TERMINATED&&c.failed(null,b.C.causes.WEBRTC_ERROR)},c.mediaHint),this},receiveInviteResponse:function(a){var c,d=this,e=a.call_id+a.from_tag+a.to_tag,f=[],h={};if(this.status!==g.STATUS_TERMINATED&&a.method===b.C.INVITE){if(this.dialog&&a.status_code>=200&&a.status_code<=299){if(e!==this.dialog.id.toString()){if(!this.createDialog(a,"UAC",!0))return;return this.earlyDialogs[e].sendRequest(this,b.C.ACK,{body:b.Utils.generateFakeSDP(a.body)}),this.earlyDialogs[e].sendRequest(this,b.C.BYE),void(this.status!==g.STATUS_CONFIRMED&&this.failed(a,b.C.causes.WEBRTC_ERROR))}if(this.status===g.STATUS_CONFIRMED)return void this.sendRequest(b.C.ACK,{cseq:a.cseq});if(!this.hasAnswer)return}if(this.dialog&&a.status_code<200){if(!this.earlyDialogs[e]&&!this.createDialog(a,"UAC",!0))return;return f.push("RAck: "+a.getHeader("rseq")+" "+a.getHeader("cseq")),this.earlyDialogs[e].pracked.push(a.getHeader("rseq")),void this.earlyDialogs[e].sendRequest(this,b.C.PRACK,{extraHeaders:f,body:b.Utils.generateFakeSDP(a.body)})}if(this.isCanceled)return void(a.status_code>=100&&a.status_code<200?(this.request.cancel(this.cancelReason),this.canceled(null)):a.status_code>=200&&a.status_code<299&&(this.acceptAndTerminate(a),this.emit("bye",this.request)));switch(!0){case/^100$/.test(a.status_code):this.received_100=!0;break;case/^1[0-9]{2}$/.test(a.status_code):if(!a.to_tag){this.logger.warn("1xx response received without to tag");break}if(a.hasHeader("contact")&&!this.createDialog(a,"UAC",!0))break;if(this.status=g.STATUS_1XX_RECEIVED,a.hasHeader("require")&&-1!==a.getHeader("require").indexOf("100rel")){if(this.dialog||!this.earlyDialogs[e])break;if(-1!==this.earlyDialogs[e].pracked.indexOf(a.getHeader("rseq"))||this.earlyDialogs[e].pracked[this.earlyDialogs[e].pracked.length-1]>=a.getHeader("rseq")&&this.earlyDialogs[e].pracked.length>0)return;if(b.Hacks.Firefox.cannotHandleRelayCandidates(a),b.Hacks.Firefox.cannotHandleExtraWhitespace(a),a.body)if(this.hasOffer){if(!this.createDialog(a,"UAC"))break;this.hasAnswer=!0,this.mediaHandler.setDescription(a.body,function(){f.push("RAck: "+a.getHeader("rseq")+" "+a.getHeader("cseq")),d.dialog.pracked.push(a.getHeader("rseq")),d.sendRequest(b.C.PRACK,{extraHeaders:f,receiveResponse:function(){}}),d.status=g.STATUS_EARLY_MEDIA,d.mute(),d.emit("progress",a)},function(c){d.logger.warn(c),d.acceptAndTerminate(a,488,"Not Acceptable Here"),d.failed(a,b.C.causes.BAD_MEDIA_DESCRIPTION)})}else this.earlyDialogs[e].pracked.push(a.getHeader("rseq")),this.earlyDialogs[e].mediaHandler.setDescription(a.body,function(){d.earlyDialogs[e].mediaHandler.getDescription(function(c){f.push("Content-Type: application/sdp"),f.push("RAck: "+a.getHeader("rseq")+" "+a.getHeader("cseq")),d.earlyDialogs[e].sendRequest(d,b.C.PRACK,{extraHeaders:f,body:c}),d.status=g.STATUS_EARLY_MEDIA,d.emit("progress",a)},function(){d.earlyDialogs[e].pracked.push(a.getHeader("rseq")),d.status!==g.STATUS_TERMINATED&&d.failed(null,b.C.causes.WEBRTC_ERROR)},d.mediaHint)},function(b){d.earlyDialogs[e].pracked.splice(d.earlyDialogs[e].pracked.indexOf(a.getHeader("rseq")),1),d.logger.warn("invalid SDP"),d.logger.warn(b)});else f.push("RAck: "+a.getHeader("rseq")+" "+a.getHeader("cseq")),this.earlyDialogs[e].pracked.push(a.getHeader("rseq")),this.earlyDialogs[e].sendRequest(this,b.C.PRACK,{extraHeaders:f}),this.emit("progress",a)}else this.emit("progress",a);break;case/^2[0-9]{2}$/.test(a.status_code):var i=this.request.cseq+" "+this.request.method;if(i!==a.getHeader("cseq"))break;if(this.status===g.STATUS_EARLY_MEDIA&&this.dialog){this.status=g.STATUS_CONFIRMED,this.unmute(),h={},this.renderbody&&(f.push("Content-Type: "+this.rendertype),h.extraHeaders=f,h.body=this.renderbody),h.cseq=a.cseq,this.sendRequest(b.C.ACK,h),this.accepted(a);break}if(this.dialog)break;if(b.Hacks.Firefox.cannotHandleRelayCandidates(a),b.Hacks.Firefox.cannotHandleExtraWhitespace(a),this.hasOffer)if(this.hasAnswer)this.renderbody&&(f.push("Content-Type: "+d.rendertype),h.extraHeaders=f,h.body=this.renderbody),this.sendRequest(b.C.ACK,h);else{if(!a.body){this.acceptAndTerminate(a,400,"Missing session description"),this.failed(a,b.C.causes.BAD_MEDIA_DESCRIPTION);break}if(!this.createDialog(a,"UAC"))break;this.hasAnswer=!0,this.mediaHandler.setDescription(a.body,function(){var c={};d.status=g.STATUS_CONFIRMED,d.unmute(),d.renderbody&&(f.push("Content-Type: "+d.rendertype),c.extraHeaders=f,c.body=d.renderbody),c.cseq=a.cseq,d.sendRequest(b.C.ACK,c),d.accepted(a)},function(c){d.logger.warn(c),d.acceptAndTerminate(a,488,"Not Acceptable Here"),d.failed(a,b.C.causes.BAD_MEDIA_DESCRIPTION)})}else if(this.earlyDialogs[e]&&this.earlyDialogs[e].mediaHandler.localMedia){if(this.hasOffer=!0,this.hasAnswer=!0,this.mediaHandler=this.earlyDialogs[e].mediaHandler,!this.createDialog(a,"UAC"))break;this.status=g.STATUS_CONFIRMED,this.sendRequest(b.C.ACK,{cseq:a.cseq}),this.unmute(),this.accepted(a)}else{if(!a.body){this.acceptAndTerminate(a,400,"Missing session description"),this.failed(a,b.C.causes.BAD_MEDIA_DESCRIPTION);break}if(!this.createDialog(a,"UAC"))break;this.hasOffer=!0,this.mediaHandler.setDescription(a.body,function(){d.mediaHandler.getDescription(function(c){d.isCanceled||d.status===g.STATUS_TERMINATED||(c=b.Hacks.Firefox.hasMissingCLineInSDP(c),d.status=g.STATUS_CONFIRMED,d.hasAnswer=!0,d.unmute(),d.sendRequest(b.C.ACK,{body:c,extraHeaders:["Content-Type: application/sdp"],cseq:a.cseq}),d.accepted(a))},function(){console.log("there was a problem")},d.mediaHint)},function(b){d.logger.warn("invalid SDP"),d.logger.warn(b),a.reply(488)})}break;default:c=b.Utils.sipErrorCause(a.status_code),this.failed(a,c),this.rejected(a,c)}}},cancel:function(a){a=a||{};var c,d=a.status_code,e=a.reasonPhrase;if(this.status===g.STATUS_TERMINATED)throw new b.Exceptions.InvalidStateError(this.status);if(this.logger.log("canceling RTCSession"),d&&(200>d||d>=700))throw new TypeError("Invalid status_code: "+d);return d&&(e=e||b.C.REASON_PHRASE[d]||"",c="SIP ;cause="+d+' ;text="'+e+'"'),this.status===g.STATUS_NULL||this.status===g.STATUS_INVITE_SENT&&!this.received_100?(this.isCanceled=!0,this.cancelReason=c):(this.status===g.STATUS_INVITE_SENT||this.status===g.STATUS_1XX_RECEIVED||this.status===g.STATUS_EARLY_MEDIA)&&this.request.cancel(c),this.canceled()},terminate:function(a){return this.status===g.STATUS_TERMINATED?this:(this.status===g.STATUS_WAITING_FOR_ACK||this.status===g.STATUS_CONFIRMED?this.bye(a):this.cancel(a),this.terminated())},receiveRequest:function(a){return a.method===b.C.CANCEL,c.prototype.receiveRequest.apply(this,[a])}},b.InviteClientContext=e}(b),b.Subscription=function(a,c,d,e){var f;if(e=e||{},e.extraHeaders=e.extraHeaders||[],f=["notify"],this.id=null,this.state="init",!d)throw new TypeError("Event necessary to create a subscription.");this.event=d,!e.expires||e.expires<3600?this.expires=3600:"number"!=typeof e.expires?(a.logger.warn("expires must be a number. Using default of 3600."),this.expires=3600):this.expires=e.expires,e.extraHeaders.push("Event: "+this.event),e.extraHeaders.push("Expires: "+this.expires),e.body&&(this.body=e.body),this.contact=a.contact.toString(),e.extraHeaders.push("Contact: "+this.contact),e.extraHeaders.push("Allow: "+b.Utils.getAllowedMethods(a)),b.Utils.augment(this,b.ClientContext,[a,b.C.SUBSCRIBE,c,e]),this.logger=a.getLogger("sip.subscription"),this.dialog=null,this.timers={N:null,sub_duration:null},this.errorCodes=[404,405,410,416,480,481,482,483,484,485,489,501,604],this.initMoreEvents(f)},b.Subscription.prototype={subscribe:function(){var c=this;return a.clearTimeout(this.timers.sub_duration),a.clearTimeout(this.timers.N),this.timers.N=a.setTimeout(function(){c.timer_fire()},b.Timers.TIMER_N),this.send(),this.state="notify_wait",this},receiveResponse:function(c){var d,e=this;-1!==this.errorCodes.indexOf(c.status_code)?this.failed(c,null):/^2[0-9]{2}$/.test(c.status_code)&&(d=c.getHeader("Expires"),a.clearTimeout(this.timers.N),this.createConfirmedDialog(c,"UAC")&&(this.id=this.dialog.id.toString(),this.ua.subscriptions[this.id]=this),d&&d<=this.expires?this.timers.sub_duration=a.setTimeout(function(){e.subscribe()},1e3*d):d?(this.logger.warn("Expires header in a 200-class response to SUBSCRIBE with a higher value than the one in the request"),this.failed(c,b.C.INVALID_EXPIRES_HEADER)):(this.logger.warn("Expires header missing in a 200-class response to SUBSCRIBE"),this.failed(c,b.C.EXPIRES_HEADER_MISSING)))},unsubscribe:function(){var c=[],d=this;this.state="terminated",c.push("Event: "+this.event),c.push("Expires: 0"),c.push("Contact: "+this.contact),c.push("Allow: "+b.Utils.getAllowedMethods(this.ua)),this.request=new b.OutgoingRequest(this.method,this.request.to.uri.toString(),this.ua,null,c),this.receiveResponse=function(){},a.clearTimeout(this.timers.sub_duration),a.clearTimeout(this.timers.N),this.timers.N=a.setTimeout(function(){d.timer_fire()},b.Timers.TIMER_N),this.send()},timer_fire:function(){"terminated"===this.state?this.close():"pending"===this.state||"notify_wait"===this.state?(this.state="terminated",this.close()):this.subscribe()},close:function(){"terminated"!==this.state&&this.unsubscribe(),this.terminateDialog(),a.clearTimeout(this.timers.N),a.clearTimeout(this.timers.sub_duration),delete this.ua.subscriptions[this.id]},createConfirmedDialog:function(a,c){var d;return d=new b.Dialog(this,a,c),d.error?!1:(this.dialog=d,!0)},terminateDialog:function(){this.dialog&&(this.dialog.terminate(),delete this.dialog)},receiveRequest:function(c){function d(){e.expires&&(e.expires=Math.min(f.expires,Math.max(e.expires,3600)),f.timers.sub_duration=a.setTimeout(f.subscribe.bind(f),1e3*e.expires))}var e,f=this;if(!this.matchEvent(c))return void c.reply(489);switch(e=c.parseHeader("Subscription-State"),c.reply(200,b.C.REASON_200),a.clearTimeout(this.timers.N),a.clearTimeout(this.timers.sub_duration),this.emit("notify",{request:c}),e.state){case"active":this.state="active",d();break;case"pending":"notify_wait"===this.state&&d(),this.state="pending";break;case"terminated":if(e.reason)switch(this.logger.log("terminating subscription with reason "+e.reason),e.reason){case"deactivated":case"timeout":return void this.subscribe();case"probation":case"giveup":return void(e.params&&e.params["retry-after"]?this.timers.sub_duration=a.setTimeout(function(){f.subscribe()},e.params["retry-after"]):this.subscribe());case"rejected":case"noresource":case"invariant":}this.close()}},failed:function(a,b){return this.close(),this.emit("failed",a,b)},matchEvent:function(a){var b;return a.hasHeader("Event")?a.hasHeader("Subscription-State")?(b=a.parseHeader("event").event,this.event!==b?(this.logger.warn("event match failed"),a.reply(481,"Event Match Failed"),!1):!0):(this.logger.warn("missing Subscription-State header"),!1):(this.logger.warn("missing Event header"),!1)}},function(b){var c;c={},c.MediaHandler=function(a){var b=function(b,c){c=c||{},this.logger=b.ua.getLogger("sip.invitecontext.mediahandler",b.id),this.session=b,this.localMedia=null,this.ready=!0,this.mediaStreamManager=a.WebRTC.MediaStreamManager.cast(c.mediaStreamManager),this.audioMuted=!1,this.videoMuted=!1;var d,e,f,g=this,h=[],i=c.stunServers||null,j=c.turnServers||null,k=this.session.ua.configuration;for(this.RTCConstraints=c.RTCConstraints||{},i||(i=k.stunServers),j||(j=k.turnServers),h.push({url:i}),e=j.length,d=0;e>d;d++)f=j[d],h.push({url:f.urls,username:f.username,credential:f.password});this.peerConnection=new a.WebRTC.RTCPeerConnection({iceServers:h},this.RTCConstraints),this.peerConnection.onaddstream=function(a){g.logger.log("stream added: "+a.stream.id)},this.peerConnection.onremovestream=function(a){g.logger.log("stream removed: "+a.stream.id)},this.peerConnection.onicecandidate=function(a){a.candidate?g.logger.log("ICE candidate received: "+a.candidate.candidate):void 0!==g.onIceCompleted&&g.onIceCompleted()},this.peerConnection.oniceconnectionstatechange=function(){g.logger.log('ICE connection state changed to "'+this.iceConnectionState+'"')},this.peerConnection.onstatechange=function(){g.logger.log('PeerConnection state changed to "'+this.readyState+'"')}};return b.defaultFactory=function(a,c){return new b(a,c)},b.prototype={isReady:function(){return this.ready},close:function(){this.logger.log("closing PeerConnection"),this.peerConnection&&"closed"!==this.peerConnection.signalingState&&(this.peerConnection.close(),this.localMedia&&this.mediaStreamManager.release(this.localMedia))},getDescription:function(b,c,d){function e(){g.createOfferOrAnswer(b,c,g.RTCConstraints)}function f(a){g.logger.log("acquired local media stream"),g.localMedia=a,g.session.connecting(),g.addStream(a,e,c,g.RTCConstraints)}var g=this;return g.localMedia?(g.logger.log("already have local media"),void e()):(d instanceof a.WebRTC.MediaStream&&(g.logger.log("mediaHint provided to getDescription is a MediaStream, casting to MediaStreamManager:",d),g.mediaStreamManager=a.WebRTC.MediaStreamManager.cast(d)),g.logger.log("acquiring local media"),void g.mediaStreamManager.acquire(f,function(a){g.logger.error("unable to acquire stream"),g.logger.error(a),g.session.connecting(),c(a)},d))},setDescription:function(b,c,d){var e=this.hasOffer("local")?"answer":"offer",f=new a.WebRTC.RTCSessionDescription({type:e,sdp:b});this.peerConnection.setRemoteDescription(f,c,d)},isMuted:function(){return{audio:this.audioMuted,video:this.videoMuted}},mute:function(a){if(0!==this.getLocalStreams().length){a=a||{audio:this.getLocalStreams()[0].getAudioTracks().length>0,video:this.getLocalStreams()[0].getVideoTracks().length>0};var b=!1,c=!1;return a.audio&&!this.audioMuted&&(b=!0,this.audioMuted=!0,this.toggleMuteAudio(!0)),a.video&&!this.videoMuted&&(c=!0,this.videoMuted=!0,this.toggleMuteVideo(!0)),b||c?{audio:b,video:c}:void 0}},unmute:function(a){if(0!==this.getLocalStreams().length){a=a||{audio:this.getLocalStreams()[0].getAudioTracks().length>0,video:this.getLocalStreams()[0].getVideoTracks().length>0};var b=!1,c=!1;return a.audio&&this.audioMuted&&(b=!0,this.audioMuted=!1,a.local_hold||this.toggleMuteAudio(!1)),a.video&&this.videoMuted&&(c=!0,this.videoMuted=!1,a.local_hold||this.toggleMuteVideo(!1)),b||c?{audio:b,video:c}:void 0}},hold:function(){this.toggleMuteAudio(!0),this.toggleMuteVideo(!0)},unhold:function(){this.audioMuted||this.toggleMuteAudio(!1),this.videoMuted||this.toggleMuteVideo(!1)},getLocalStreams:function(){var a=this.peerConnection;return a&&"closed"===a.signalingState?(this.logger.warn("peerConnection is closed, getLocalStreams returning []"),[]):a.getLocalStreams&&a.getLocalStreams()||a.localStreams||[]},getRemoteStreams:function(){var a=this.peerConnection;return a&&"closed"===a.signalingState?(this.logger.warn("peerConnection is closed, getRemoteStreams returning []"),[]):a.getRemoteStreams&&a.getRemoteStreams()||a.remoteStreams||[]},hasOffer:function(a){var b="have-"+a+"-offer";return this.peerConnection.signalingState===b},createOfferOrAnswer:function(b,c,d){function e(){var c=h.peerConnection.localDescription.sdp;c=a.Hacks.Chrome.needsExplicitlyInactiveSDP(c),h.ready=!0,b(c)}function f(){"complete"===h.peerConnection.iceGatheringState&&"connected"===h.peerConnection.iceConnectionState?e():h.onIceCompleted=function(){h.onIceCompleted=void 0,e()}}function g(a,b){h.logger.error("peerConnection."+a+" failed"),h.logger.error(b),h.ready=!0,c(b)}var h=this;h.ready=!1;var i=h.hasOffer("remote")?"createAnswer":"createOffer";h.peerConnection[i](function(a){h.peerConnection.setLocalDescription(a,f,g.bind(null,"setLocalDescription"))},g.bind(null,i),d)},addStream:function(a,b,c,d){try{this.peerConnection.addStream(a,d)}catch(e){return this.logger.error("error adding stream"),this.logger.error(e),void c(e)}b()},toggleMuteAudio:function(a){var b,c,d,e,f,g=this.getLocalStreams();for(b=0,e=g.length;e>b;b++)for(d=g[b].getAudioTracks(),c=0,f=d.length;f>c;c++)d[c].enabled=!a},toggleMuteVideo:function(a){var b,c,d,e,f,g=this.getLocalStreams();for(b=0,e=g.length;e>b;b++)for(d=g[b].getVideoTracks(),c=0,f=d.length;f>c;c++)d[c].enabled=!a}},b}(b),c.MediaStreamManager=function(a){var b=function(a){this.setConstraints(a)};return b.prototype={acquire:function(b,c,d){d=d||this.constraints,a.WebRTC.getUserMedia(d,b,c)},release:function(a){a.stop()},setConstraints:function(a){this.constraints=a||{audio:!0,video:!0}}},b.ofStream=function(a){this.stream=a},b.ofStream.prototype=Object.create(b.prototype,{acquire:{value:function(a){a(this.stream)}},release:{value:function(){}}}),b.cast=function(c){return c?c instanceof b?c:a.WebRTC.MediaStream&&c instanceof a.WebRTC.MediaStream?new b.ofStream(c):new b(c):new b},b}(b),c.MediaStream=a.MediaStream||a.webkitMediaStream,a.navigator.getUserMedia?c.getUserMedia=a.navigator.getUserMedia.bind(navigator):a.navigator.webkitGetUserMedia?c.getUserMedia=a.navigator.webkitGetUserMedia.bind(navigator):a.navigator.mozGetUserMedia&&(c.getUserMedia=a.navigator.mozGetUserMedia.bind(navigator)),a.RTCPeerConnection?c.RTCPeerConnection=a.RTCPeerConnection:a.webkitRTCPeerConnection?c.RTCPeerConnection=a.webkitRTCPeerConnection:a.mozRTCPeerConnection&&(c.RTCPeerConnection=a.mozRTCPeerConnection),a.RTCSessionDescription?c.RTCSessionDescription=a.RTCSessionDescription:a.webkitRTCSessionDescription?c.RTCSessionDescription=a.webkitRTCSessionDescription:a.mozRTCSessionDescription&&(c.RTCSessionDescription=a.mozRTCSessionDescription),c.isSupported=c.getUserMedia&&c.RTCPeerConnection&&c.RTCSessionDescription?!0:!1,b.WebRTC=c}(b),function(b){var c,d={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2,EVENT_METHODS:{invite:"INVITE",message:"MESSAGE"},ALLOWED_METHODS:["ACK","CANCEL","BYE","OPTIONS"],ACCEPTED_BODY_TYPES:["application/sdp","application/dtmf-relay"],MAX_FORWARDS:70,TAG_LENGTH:10};c=function(a){function c(a){return function(b){g.emit(a,b)}}var e,f,g=this,h=["connecting","connected","disconnected","newTransaction","transactionDestroyed","registered","unregistered","registrationFailed","invite","newSession","message"]; for(e=0,f=d.ALLOWED_METHODS.length;f>e;e++)h.push(d.ALLOWED_METHODS[e].toLowerCase());d.ACCEPTED_BODY_TYPES=d.ACCEPTED_BODY_TYPES.toString(),this.log=new b.LoggerFactory,this.logger=this.getLogger("sip.ua"),this.cache={credentials:{}},this.configuration={},this.dialogs={},this.applicants={},this.data={},this.sessions={},this.subscriptions={},this.transport=null,this.contact=null,this.status=d.STATUS_INIT,this.error=null,this.transactions={nist:{},nict:{},ist:{},ict:{}},this.transportRecoverAttempts=0,this.transportRecoveryTimer=null,Object.defineProperties(this,{transactionsCount:{get:function(){var a,b=["nist","nict","ist","ict"],c=0;for(a in b)c+=Object.keys(this.transactions[b[a]]).length;return c}},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===a?a={}:("string"==typeof a||a instanceof String)&&(a={uri:a}),a.log&&(a.log.hasOwnProperty("builtinEnabled")&&(this.log.builtinEnabled=a.log.builtinEnabled),a.log.hasOwnProperty("level")&&(this.log.level=a.log.level),a.log.hasOwnProperty("connector")&&(this.log.connector=a.log.connector));try{this.loadConfig(a),this.initEvents(h)}catch(i){throw this.status=d.STATUS_NOT_READY,this.error=d.CONFIGURATION_ERROR,i}this.registerContext=new b.RegisterContext(this),this.registerContext.on("failed",c("registrationFailed")),this.registerContext.on("registered",c("registered")),this.registerContext.on("unregistered",c("unregistered")),this.configuration.autostart&&this.start()},c.prototype=new b.EventEmitter,c.prototype.register=function(a){return this.configuration.register=!0,this.registerContext.register(a),this},c.prototype.unregister=function(a){return this.configuration.register=!1,this.registerContext.unregister(a),this},c.prototype.isRegistered=function(){return this.registerContext.registered},c.prototype.isConnected=function(){return this.transport?this.transport.connected:!1},c.prototype.invite=function(a,c){c=c||{},b.Utils.optionsOverride(c,"media","mediaConstraints",!0,this.logger);var d=new b.InviteClientContext(this,a,c);return this.isConnected()?d.invite({media:c.media}):this.once("connected",function(){d.invite({media:c.media})}),d},c.prototype.subscribe=function(a,c,d){var e=new b.Subscription(this,a,c,d);return this.isConnected()?e.subscribe():this.once("connected",function(){e.subscribe()}),e},c.prototype.message=function(a,c,d){if(void 0===c)throw new TypeError("Not enough arguments");d=d||{},d.contentType=d.contentType||"text/plain",d.body=c;var e=new b.ClientContext(this,b.C.MESSAGE,a,d);return this.isConnected()?e.send():this.once("connected",function(){e.send()}),e},c.prototype.request=function(a,c,d){var e=new b.ClientContext(this,a,c,d);return this.isConnected()?e.send():this.once("connected",function(){e.send()}),e},c.prototype.stop=function(){function b(){0===g.nistTransactionsCount&&0===g.nictTransactionsCount&&(g.off("transactionDestroyed",b),g.transport.disconnect())}var c,e,f,g=this;if(this.logger.log("user requested closure..."),this.status===d.STATUS_USER_CLOSED)return this.logger.warn("UA already closed"),this;a.clearTimeout(this.transportRecoveryTimer),this.logger.log("closing registerContext"),this.registerContext.close();for(c in this.sessions)this.logger.log("closing session "+c),this.sessions[c].terminate();for(e in this.subscriptions)this.logger.log("unsubscribing from subscription "+e),this.subscriptions[e].close();for(f in this.applicants)this.applicants[f].close();return this.status=d.STATUS_USER_CLOSED,0===this.nistTransactionsCount&&0===this.nictTransactionsCount?this.transport.disconnect():this.on("transactionDestroyed",b),this},c.prototype.start=function(){var a;return this.logger.log("user requested startup..."),this.status===d.STATUS_INIT?(a=this.getNextWsServer(),new b.Transport(this,a)):this.status===d.STATUS_USER_CLOSED?(this.logger.log("resuming"),this.status=d.STATUS_READY,this.transport.connect()):this.status===d.STATUS_READY?this.logger.log("UA is in READY status, not resuming"):this.logger.error("Connection is down. Auto-Recovery system is trying to connect"),this},c.prototype.normalizeTarget=function(a){return b.Utils.normalizeTarget(a,this.configuration.hostportParams)},c.prototype.saveCredentials=function(a){return this.cache.credentials[a.realm]=this.cache.credentials[a.realm]||{},this.cache.credentials[a.realm][a.uri]=a,this},c.prototype.getCredentials=function(a){var b,c;return b=a.ruri.host,this.cache.credentials[b]&&this.cache.credentials[b][a.ruri]&&(c=this.cache.credentials[b][a.ruri],c.method=a.method),c},c.prototype.getLogger=function(a,b){return this.log.getLogger(a,b)},c.prototype.onTransportClosed=function(a){var c,d,e,f=["nict","ict","nist","ist"];for(a.server.status=b.Transport.C.STATUS_DISCONNECTED,this.logger.log("connection state set to "+b.Transport.C.STATUS_DISCONNECTED),e=f.length,c=0;e>c;c++)for(d in this.transactions[f[c]])this.transactions[f[c]][d].onTransportError();this.contact.pub_gruu||this.closeSessionsOnTransportError()},c.prototype.onTransportError=function(a){var c;this.logger.log("transport "+a.server.ws_uri+" failed | connection state set to "+b.Transport.C.STATUS_ERROR),a.server.status=b.Transport.C.STATUS_ERROR,this.emit("disconnected",{transport:a}),c=this.getNextWsServer(),c?new b.Transport(this,c):(this.closeSessionsOnTransportError(),this.error&&this.error===d.NETWORK_ERROR||(this.status=d.STATUS_NOT_READY,this.error=d.NETWORK_ERROR),this.recoverTransport())},c.prototype.onTransportConnected=function(a){this.transport=a,this.transportRecoverAttempts=0,a.server.status=b.Transport.C.STATUS_READY,this.logger.log("connection state set to "+b.Transport.C.STATUS_READY),this.status!==d.STATUS_USER_CLOSED&&(this.status=d.STATUS_READY,this.error=null,this.configuration.register&&this.registerContext.onTransportConnected(),this.emit("connected",{transport:a}))},c.prototype.onTransportConnecting=function(a,b){this.emit("connecting",{transport:a,attempts:b})},c.prototype.newTransaction=function(a){this.transactions[a.type][a.id]=a,this.emit("newTransaction",{transaction:a})},c.prototype.destroyTransaction=function(a){delete this.transactions[a.type][a.id],this.emit("transactionDestroyed",{transaction:a})},c.prototype.receiveRequest=function(a){var c,e,f,g,h=a.method,i=a.method.toLowerCase(),j=this;if(a.ruri.user!==this.configuration.uri.user&&a.ruri.user!==this.contact.uri.user)return this.logger.warn("Request-URI does not point to us"),void(a.method!==b.C.ACK&&a.reply_sl(404));if(a.ruri.scheme===b.C.SIPS)return void a.reply_sl(416);if(!b.Transactions.checkTransaction(this,a)){if(h===b.C.OPTIONS)new b.Transactions.NonInviteServerTransaction(a,this),a.reply(200,null,["Allow: "+b.Utils.getAllowedMethods(this),"Accept: "+d.ACCEPTED_BODY_TYPES]);else if(h===b.C.MESSAGE){if(!this.checkListener(i))return new b.Transactions.NonInviteServerTransaction(a,this),void a.reply(405,null,["Allow: "+b.Utils.getAllowedMethods(this)]);f=new b.ServerContext(this,a),f.body=a.body,f.content_type=a.getHeader("Content-Type")||"text/plain",a.reply(200,null),this.emit("message",f)}else h!==b.C.INVITE&&h!==b.C.ACK&&(g=new b.ServerContext(this,a));if(a.to_tag)c=this.findDialog(a),c?(h===b.C.INVITE&&new b.Transactions.InviteServerTransaction(a,this),c.receiveRequest(a)):h===b.C.NOTIFY?(e=this.findSession(a),e?e.receiveRequest(a):(this.logger.warn("received NOTIFY request for a non existent session"),a.reply(481,"Subscription does not exist"))):h!==b.C.ACK&&a.reply(481);else switch(h){case b.C.INVITE:b.WebRTC.isSupported?e=new b.InviteServerContext(this,a).on("invite",function(){j.emit("invite",this)}):(this.logger.warn("INVITE received but WebRTC is not supported"),a.reply(488));break;case b.C.BYE:a.reply(481);break;case b.C.CANCEL:e=this.findSession(a),e?e.receiveRequest(a):this.logger.warn("received CANCEL request for a non existent session");break;case b.C.ACK:break;default:a.reply(405)}}},c.prototype.findSession=function(a){return this.sessions[a.call_id+a.from_tag]||this.sessions[a.call_id+a.to_tag]||null},c.prototype.findDialog=function(a){return this.dialogs[a.call_id+a.from_tag+a.to_tag]||this.dialogs[a.call_id+a.to_tag+a.from_tag]||null},c.prototype.getNextWsServer=function(){var a,c,d,e=[];for(c=this.configuration.wsServers.length,a=0;c>a;a++)d=this.configuration.wsServers[a],d.status!==b.Transport.C.STATUS_ERROR&&(0===e.length?e.push(d):d.weight>e[0].weight?e=[d]:d.weight===e[0].weight&&e.push(d));return a=Math.floor(Math.random()*e.length),e[a]},c.prototype.closeSessionsOnTransportError=function(){var a;for(a in this.sessions)this.sessions[a].onTransportError();this.registerContext.onTransportClosed()},c.prototype.recoverTransport=function(c){var d,e,f,g,h,i;for(c=c||this,h=c.transportRecoverAttempts,e=c.configuration.wsServers.length,d=0;e>d;d++)c.configuration.wsServers[d].status=0;i=c.getNextWsServer(),f=Math.floor(Math.random()*Math.pow(2,h)+1),g=f*c.configuration.connectionRecoveryMinInterval,g>c.configuration.connectionRecoveryMaxInterval&&(this.logger.log("time for next connection attempt exceeds connectionRecoveryMaxInterval, resetting counter"),g=c.configuration.connectionRecoveryMinInterval,h=0),this.logger.log("next connection attempt in "+g+" seconds"),this.transportRecoveryTimer=a.setTimeout(function(){c.transportRecoverAttempts=h+1,new b.Transport(c,i)},1e3*g)},c.prototype.loadConfig=function(d){function e(a,b){var c=a.replace(/([a-z][A-Z])/g,function(a){return a[0]+"_"+a[1].toLowerCase()});if(a!==c){var e=d.hasOwnProperty(a);d.hasOwnProperty(c)&&(b.warn(c+" is deprecated, please use "+a),e&&b.warn(a+" overriding "+c)),d[a]=e?d[a]:d[c]}}var f,g,h,i,j,k={viaHost:b.Utils.createRandomToken(12)+".invalid",uri:new b.URI("sip","anonymous."+b.Utils.createRandomToken(6),"anonymous.invalid",null,null),wsServers:[{scheme:"WSS",sip_uri:"",status:0,weight:0,ws_uri:"wss://edge.sip.onsip.com"}],password:null,registerExpires:600,registerMinExpires:120,register:!0,registrarServer:null,wsServerMaxReconnection:3,wsServerReconnectionTimeout:4,connectionRecoveryMinInterval:2,connectionRecoveryMaxInterval:30,usePreloadedRoute:!1,userAgentString:b.C.USER_AGENT,noAnswerTimeout:60,stunServers:["stun:stun.l.google.com:19302"],turnServers:[],traceSip:!1,hackViaTcp:!1,hackIpInContact:!1,autostart:!0,reliable:"none",mediaHandlerFactory:b.WebRTC.MediaHandler.defaultFactory};for(f in c.configuration_check.mandatory){if(e(f,this.logger),!d.hasOwnProperty(f))throw new b.Exceptions.ConfigurationError(f);if(g=d[f],h=c.configuration_check.mandatory[f](g),void 0===h)throw new b.Exceptions.ConfigurationError(f,g);k[f]=h}for(f in c.configuration_check.optional)if(e(f,this.logger),d.hasOwnProperty(f)){if(g=d[f],null===g||""===g||void 0===g||g instanceof Array&&0===g.length)continue;if("number"==typeof g&&a.isNaN(g))continue;if(h=c.configuration_check.optional[f](g),void 0===h)throw new b.Exceptions.ConfigurationError(f,g);k[f]=h}if(k.connectionRecoveryMaxInterval"}},b.Utils.optionsOverride(k,"media","mediaConstraints",!0,this.logger);for(f in k)c.configuration_skeleton[f].value=k[f];Object.defineProperties(this.configuration,c.configuration_skeleton);for(f in k)c.configuration_skeleton[f].value="";this.logger.log("configuration parameters after validation:");for(f in k)switch(f){case"uri":case"registrarServer":case"mediaHandlerFactory":this.logger.log("· "+f+": "+k[f]);break;case"password":this.logger.log("· "+f+": NOT SHOWN");break;default:this.logger.log("· "+f+": "+a.JSON.stringify(k[f]))}},c.configuration_skeleton=function(){var a,b,c={},d=["jssipId","registerMinExpires","wsServerMaxReconnection","wsServerReconnectionTimeout","hostportParams","uri","wsServers","authorizationUser","connectionRecoveryMaxInterval","connectionRecoveryMinInterval","displayName","hackViaTcp","hackIpInContact","instanceId","noAnswerTimeout","password","registerExpires","registrarServer","reliable","userAgentString","autostart","stunServers","traceSip","turnServers","usePreloadedRoute","mediaHandlerFactory","media","mediaConstraints","via_core_value","viaHost"];for(a in d)b=d[a],c[b]={value:"",writable:!1,configurable:!1};return c.register={value:"",writable:!0,configurable:!1},c}(),c.configuration_check={mandatory:{},optional:{uri:function(a){var c;return/^sip:/i.test(a)||(a=b.C.SIP+":"+a),c=b.URI.parse(a),c?c.user?c:void 0:void 0},wsServers:function(a){var c,d,e;if("string"==typeof a)a=[{ws_uri:a}];else{if(!(a instanceof Array))return;for(d=a.length,c=0;d>c;c++)"string"==typeof a[c]&&(a[c]={ws_uri:a[c]})}if(0===a.length)return!1;for(d=a.length,c=0;d>c;c++){if(!a[c].ws_uri)return;if(a[c].weight&&!Number(a[c].weight))return;if(e=b.Grammar.parse(a[c].ws_uri,"absoluteURI"),-1===e)return;if("wss"!==e.scheme&&"ws"!==e.scheme)return;a[c].sip_uri="",a[c].weight||(a[c].weight=0),a[c].status=0,a[c].scheme=e.scheme.toUpperCase()}return a},authorizationUser:function(a){return-1===b.Grammar.parse('"'+a+'"',"quoted_string")?void 0:a},connectionRecoveryMaxInterval:function(c){var d;return b.Utils.isDecimal(c)&&(d=a.Number(c),d>0)?d:void 0},connectionRecoveryMinInterval:function(c){var d;return b.Utils.isDecimal(c)&&(d=a.Number(c),d>0)?d:void 0},displayName:function(a){return-1===b.Grammar.parse('"'+a+'"',"displayName")?void 0:a},hackViaTcp:function(a){return"boolean"==typeof a?a:void 0},hackIpInContact:function(a){return"boolean"==typeof a?a:void 0},instanceId:function(a){return"string"==typeof a?(/^uuid:/i.test(a)&&(a=a.substr(5)),-1===b.Grammar.parse(a,"uuid")?void 0:a):void 0},noAnswerTimeout:function(c){var d;return b.Utils.isDecimal(c)&&(d=a.Number(c),d>0)?d:void 0},password:function(a){return String(a)},reliable:function(a){return"required"===a?a:"supported"===a?(b.UA.C.SUPPORTED=b.UA.C.SUPPORTED+", 100rel",a):"none"},register:function(a){return"boolean"==typeof a?a:void 0},registerExpires:function(c){var d;return b.Utils.isDecimal(c)&&(d=a.Number(c),d>0)?d:void 0},registrarServer:function(a){var c;if("string"==typeof a)return/^sip:/i.test(a)||(a=b.C.SIP+":"+a),c=b.URI.parse(a),c?c.user?void 0:c:void 0},stunServers:function(a){var c,d,e;if("string"==typeof a)a=[a];else if(!(a instanceof Array))return;for(d=a.length,c=0;d>c;c++){if(e=a[c],/^stuns?:/.test(e)||(e="stun:"+e),-1===b.Grammar.parse(e,"stun_URI"))return;a[c]=e}return a},traceSip:function(a){return"boolean"==typeof a?a:void 0},turnServers:function(a){var c,d,e,f;for(a instanceof Array||(a=[a]),d=a.length,c=0;d>c;c++){if(e=a[c],e.server&&(e.urls=[e.server]),!e.urls||!e.username||!e.password)return;for(!e.urls instanceof Array&&(e.urls=[e.urls]),d=e.urls.length,c=0;d>c;c++)if(f=e.urls[c],/^turns?:/.test(f)||(f="turn:"+f),-1===b.Grammar.parse(f,"turn_URI"))return}return a},userAgentString:function(a){return"string"==typeof a?a:void 0},usePreloadedRoute:function(a){return"boolean"==typeof a?a:void 0},autostart:function(a){return"boolean"==typeof a?a:void 0},mediaHandlerFactory:function(a){return a instanceof Function?a:void 0}}},c.C=d,b.UA=c}(b),function(b){var c;c={augment:function(a,b,c,d){var e,f;f=b.prototype;for(e in f)(d||void 0===a[e])&&(a[e]=f[e]);b.apply(a,c)},optionsOverride:function(a,b,c,d,e,f){d&&a[c]&&e.warn(c+" is deprecated, please use "+b+" instead"),a[b]&&a[c]&&e.warn(b+" overriding "+c),a[b]=a[b]||a[c]||f},str_utf8_length:function(b){return a.unescape(encodeURIComponent(b)).length},generateFakeSDP:function(a){if(a){var b=a.indexOf("o="),c=a.indexOf("\r\n",b);return"v=0\r\n"+a.slice(b,c)+"\r\ns=-\r\nt=0 0\r\nc=IN IP4 0.0.0.0"}},isFunction:function(a){return void 0!==a?"[object Function]"===Object.prototype.toString.call(a)?!0:!1:!1},isDecimal:function(a){return!isNaN(a)&&parseFloat(a)===parseInt(a,10)},createRandomToken:function(a,b){var c,d,e="";for(b=b||32,c=0;a>c;c++)d=Math.random()*b|0,e+=d.toString(b);return e},newTag:function(){return b.Utils.createRandomToken(b.UA.C.TAG_LENGTH)},newUUID:function(){var a="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"===a?b:3&b|8;return c.toString(16)});return a},hostType:function(a){return a?(a=b.Grammar.parse(a,"host"),-1!==a?a.host_type:void 0):void 0},normalizeTarget:function(a,c){var d,e,f,g;if(a){if(a instanceof b.URI)return a;if("string"==typeof a){switch(e=a.split("@"),e.length){case 1:if(!c)return;f=a,g=c;break;case 2:f=e[0],g=e[1];break;default:f=e.slice(0,e.length-1).join("@"),g=e[e.length-1]}return f=f.replace(/^(sips?|tel):/i,""),/^[\-\.\(\)]*\+?[0-9\-\.\(\)]+$/.test(f)&&(f=f.replace(/[\-\.\(\)]/g,"")),a=b.C.SIP+":"+b.Utils.escapeUser(f)+"@"+g,(d=b.URI.parse(a))?d:void 0}}else;},escapeUser:function(b){return a.encodeURIComponent(a.decodeURIComponent(b)).replace(/%3A/gi,":").replace(/%2B/gi,"+").replace(/%3F/gi,"?").replace(/%2F/gi,"/")},headerize:function(a){var b,c={"Call-Id":"Call-ID",Cseq:"CSeq",Rack:"RAck",Rseq:"RSeq","Www-Authenticate":"WWW-Authenticate"},d=a.toLowerCase().replace(/_/g,"-").split("-"),e="",f=d.length;for(b=0;f>b;b++)0!==b&&(e+="-"),e+=d[b].charAt(0).toUpperCase()+d[b].substring(1);return c[e]&&(e=c[e]),e},sipErrorCause:function(a){var c;for(c in b.C.SIP_ERROR_CAUSES)if(-1!==b.C.SIP_ERROR_CAUSES[c].indexOf(a))return b.C.causes[c];return b.C.causes.SIP_FAILURE_CODE},getRandomTestNetIP:function(){function b(b,c){return a.Math.floor(a.Math.random()*(c-b+1)+b)}return"192.0.2."+b(1,254)},getAllowedMethods:function(a){var c,d=b.UA.C.ALLOWED_METHODS.toString();for(c in b.UA.C.EVENT_METHODS)a.checkListener(c)&&(d+=","+b.UA.C.EVENT_METHODS[c]);return d},calculateMD5:function(a){function b(a,b){return a<>>32-b}function c(a,b){var c,d,e,f,g;return e=2147483648&a,f=2147483648&b,c=1073741824&a,d=1073741824&b,g=(1073741823&a)+(1073741823&b),c&d?2147483648^g^e^f:c|d?1073741824&g?3221225472^g^e^f:1073741824^g^e^f:g^e^f}function d(a,b,c){return a&b|~a&c}function e(a,b,c){return a&c|b&~c}function f(a,b,c){return a^b^c}function g(a,b,c){return b^(a|~c)}function h(a,e,f,g,h,i,j){return a=c(a,c(c(d(e,f,g),h),j)),c(b(a,i),e)}function i(a,d,f,g,h,i,j){return a=c(a,c(c(e(d,f,g),h),j)),c(b(a,i),d)}function j(a,d,e,g,h,i,j){return a=c(a,c(c(f(d,e,g),h),j)),c(b(a,i),d)}function k(a,d,e,f,h,i,j){return a=c(a,c(c(g(d,e,f),h),j)),c(b(a,i),d)}function l(a){for(var b,c=a.length,d=c+8,e=(d-d%64)/64,f=16*(e+1),g=Array(f-1),h=0,i=0;c>i;)b=(i-i%4)/4,h=i%4*8,g[b]=g[b]|a.charCodeAt(i)<>>29,g}function m(a){var b,c,d="",e="";for(c=0;3>=c;c++)b=a>>>8*c&255,e="0"+b.toString(16),d+=e.substr(e.length-2,2);return d}function n(a){a=a.replace(/\r\n/g,"\n");for(var b="",c=0;cd?b+=String.fromCharCode(d):d>127&&2048>d?(b+=String.fromCharCode(d>>6|192),b+=String.fromCharCode(63&d|128)):(b+=String.fromCharCode(d>>12|224),b+=String.fromCharCode(d>>6&63|128),b+=String.fromCharCode(63&d|128))}return b}var o,p,q,r,s,t,u,v,w,x=[],y=7,z=12,A=17,B=22,C=5,D=9,E=14,F=20,G=4,H=11,I=16,J=23,K=6,L=10,M=15,N=21;for(a=n(a),x=l(a),t=1732584193,u=4023233417,v=2562383102,w=271733878,o=0;ob?(j(400),!1):void 0}function e(){var b,c,d=m.from_tag,e=m.call_id,f=m.cseq;if(!m.to_tag)if(m.method===a.C.INVITE){if(b=n.transactions.ist[m.via_branch])return;for(c in n.transactions.ist)if(b=n.transactions.ist[c],b.request.from_tag===d&&b.request.call_id===e&&b.request.cseq===f)return j(482),!1}else{if(b=n.transactions.nist[m.via_branch])return;for(c in n.transactions.nist)if(b=n.transactions.nist[c],b.request.from_tag===d&&b.request.call_id===e&&b.request.cseq===f)return j(482),!1}}function f(){return m.getHeaders("via").length>1?(l.warn("More than one Via header field present in the response. Dropping the response"),!1):void 0}function g(){var a=n.configuration.viaHost;return m.via.host!==a||void 0!==m.via.port?(l.warn("Via sent-by in the response does not match UA Via host value. Dropping the response"),!1):void 0}function h(){var b=a.Utils.str_utf8_length(m.body),c=m.getHeader("content-length");return c>b?(l.warn("Message body length is lower than the value in Content-Length header field. Dropping the response"),!1):void 0}function i(){for(var a=["from","to","call_id","cseq","via"],b=a.length;b--;)if(!m.hasHeader(a[b]))return l.warn("Missing mandatory header field : "+a[b]+". Dropping the response"),!1}function j(b){var c,d="SIP/2.0 "+b+" "+a.C.REASON_PHRASE[b]+"\r\n",e=m.getHeaders("via"),f=e.length,g=0;for(g;f>g;g++)d+="Via: "+e[g]+"\r\n";c=m.getHeader("To"),m.to_tag||(c+=";tag="+a.Utils.newTag()),d+="To: "+c+"\r\n",d+="From: "+m.getHeader("From")+"\r\n",d+="Call-ID: "+m.call_id+"\r\n",d+="CSeq: "+m.cseq+" "+m.method+"\r\n",d+="\r\n",o.send(d)}var k,l,m,n,o,p=[],q=[],r=[];p.push(b),p.push(c),p.push(d),p.push(e),q.push(f),q.push(g),q.push(h),r.push(i),k=function(b,c,d){var e,f;for(m=b,n=c,o=d,l=n.getLogger("sip.sanitycheck"),e=r.length;e--;)if(f=r[e](m),f===!1)return!1;if(m instanceof a.IncomingRequest){for(e=p.length;e--;)if(f=p[e](m),f===!1)return!1}else if(m instanceof a.IncomingResponse)for(e=q.length;e--;)if(f=q[e](m),f===!1)return!1;return!0},a.sanityCheck=k}(b),function(a){var b;b=function(a){this.logger=a.getLogger("jssip.digestauthentication"),this.username=a.configuration.authorizationUser,this.password=a.configuration.password,this.cnonce=null,this.nc=0,this.ncHex="00000000",this.response=null},b.prototype.authenticate=function(b,c){if(this.algorithm=c.algorithm,this.realm=c.realm,this.nonce=c.nonce,this.opaque=c.opaque,this.stale=c.stale,this.algorithm){if("MD5"!==this.algorithm)return this.logger.warn('challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this.algorithm="MD5";if(!this.realm)return this.logger.warn("challenge without Digest realm, authentication aborted"),!1;if(!this.nonce)return this.logger.warn("challenge without Digest nonce, authentication aborted"),!1;if(c.qop)if(c.qop.indexOf("auth")>-1)this.qop="auth";else{if(!(c.qop.indexOf("auth-int")>-1))return this.logger.warn('challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;this.qop="auth-int"}else this.qop=null;return this.method=b.method,this.uri=b.ruri,this.cnonce=a.Utils.createRandomToken(12),this.nc+=1,this.updateNcHex(),4294967296===this.nc&&(this.nc=1,this.ncHex="00000001"),this.calculateResponse(),!0},b.prototype.calculateResponse=function(){var b,c;b=a.Utils.calculateMD5(this.username+":"+this.realm+":"+this.password),"auth"===this.qop?(c=a.Utils.calculateMD5(this.method+":"+this.uri),this.response=a.Utils.calculateMD5(b+":"+this.nonce+":"+this.ncHex+":"+this.cnonce+":auth:"+c)):"auth-int"===this.qop?(c=a.Utils.calculateMD5(this.method+":"+this.uri+":"+a.Utils.calculateMD5(this.body?this.body:"")),this.response=a.Utils.calculateMD5(b+":"+this.nonce+":"+this.ncHex+":"+this.cnonce+":auth-int:"+c)):null===this.qop&&(c=a.Utils.calculateMD5(this.method+":"+this.uri),this.response=a.Utils.calculateMD5(b+":"+this.nonce+":"+c))},b.prototype.toString=function(){var a=[];if(!this.response)throw new Error("response field does not exist, cannot generate Authorization header");return a.push("algorithm="+this.algorithm),a.push('username="'+this.username+'"'),a.push('realm="'+this.realm+'"'),a.push('nonce="'+this.nonce+'"'),a.push('uri="'+this.uri+'"'),a.push('response="'+this.response+'"'),this.opaque&&a.push('opaque="'+this.opaque+'"'),this.qop&&(a.push("qop="+this.qop),a.push('cnonce="'+this.cnonce+'"'),a.push("nc="+this.ncHex)),"Digest "+a.join(", ")},b.prototype.updateNcHex=function(){var a=Number(this.nc).toString(16);this.ncHex="00000000".substr(0,8-a.length)+a},a.DigestAuthentication=b}(b),"object"==typeof module&&module&&"object"==typeof module.exports?module.exports=b:(a.SIP=b,"function"==typeof define&&define.amd&&define("sip",[],function(){return b}))}(window),SIP.Grammar=function(){function a(a){return'"'+a.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 b={parse:function(b,c){function d(a){qe>oe||(oe>qe&&(qe=oe,re=[]),re.push(a))}function e(){var a;return"\r\n"===b.substr(oe,2)?(a="\r\n",oe+=2):(a=null,0===pe&&d('"\\r\\n"')),a}function f(){var a;return/^[0-9]/.test(b.charAt(oe))?(a=b.charAt(oe),oe++):(a=null,0===pe&&d("[0-9]")),a}function g(){var a;return/^[a-zA-Z]/.test(b.charAt(oe))?(a=b.charAt(oe),oe++):(a=null,0===pe&&d("[a-zA-Z]")),a}function h(){var a;return/^[0-9a-fA-F]/.test(b.charAt(oe))?(a=b.charAt(oe),oe++):(a=null,0===pe&&d("[0-9a-fA-F]")),a}function i(){var a;return a=l(),null===a&&(a=m()),a}function j(){var a;return/^[\0-\xFF]/.test(b.charAt(oe))?(a=b.charAt(oe),oe++):(a=null,0===pe&&d("[\\0-\\xFF]")),a}function k(){var a;return/^["]/.test(b.charAt(oe))?(a=b.charAt(oe),oe++):(a=null,0===pe&&d('["]')),a}function l(){var a;return 32===b.charCodeAt(oe)?(a=" ",oe++):(a=null,0===pe&&d('" "')),a}function m(){var a;return 9===b.charCodeAt(oe)?(a=" ",oe++):(a=null,0===pe&&d('"\\t"')),a}function n(){var a;return/^[a-zA-Z0-9]/.test(b.charAt(oe))?(a=b.charAt(oe),oe++):(a=null,0===pe&&d("[a-zA-Z0-9]")),a}function o(){var a;return 59===b.charCodeAt(oe)?(a=";",oe++):(a=null,0===pe&&d('";"')),null===a&&(47===b.charCodeAt(oe)?(a="/",oe++):(a=null,0===pe&&d('"/"')),null===a&&(63===b.charCodeAt(oe)?(a="?",oe++):(a=null,0===pe&&d('"?"')),null===a&&(58===b.charCodeAt(oe)?(a=":",oe++):(a=null,0===pe&&d('":"')),null===a&&(64===b.charCodeAt(oe)?(a="@",oe++):(a=null,0===pe&&d('"@"')),null===a&&(38===b.charCodeAt(oe)?(a="&",oe++):(a=null,0===pe&&d('"&"')),null===a&&(61===b.charCodeAt(oe)?(a="=",oe++):(a=null,0===pe&&d('"="')),null===a&&(43===b.charCodeAt(oe)?(a="+",oe++):(a=null,0===pe&&d('"+"')),null===a&&(36===b.charCodeAt(oe)?(a="$",oe++):(a=null,0===pe&&d('"$"')),null===a&&(44===b.charCodeAt(oe)?(a=",",oe++):(a=null,0===pe&&d('","'))))))))))),a}function p(){var a;return a=n(),null===a&&(a=q()),a}function q(){var a;return 45===b.charCodeAt(oe)?(a="-",oe++):(a=null,0===pe&&d('"-"')),null===a&&(95===b.charCodeAt(oe)?(a="_",oe++):(a=null,0===pe&&d('"_"')),null===a&&(46===b.charCodeAt(oe)?(a=".",oe++):(a=null,0===pe&&d('"."')),null===a&&(33===b.charCodeAt(oe)?(a="!",oe++):(a=null,0===pe&&d('"!"')),null===a&&(126===b.charCodeAt(oe)?(a="~",oe++):(a=null,0===pe&&d('"~"')),null===a&&(42===b.charCodeAt(oe)?(a="*",oe++):(a=null,0===pe&&d('"*"')),null===a&&(39===b.charCodeAt(oe)?(a="'",oe++):(a=null,0===pe&&d('"\'"')),null===a&&(40===b.charCodeAt(oe)?(a="(",oe++):(a=null,0===pe&&d('"("')),null===a&&(41===b.charCodeAt(oe)?(a=")",oe++):(a=null,0===pe&&d('")"')))))))))),a}function r(){var a,c,e,f,g;return f=oe,g=oe,37===b.charCodeAt(oe)?(a="%",oe++):(a=null,0===pe&&d('"%"')),null!==a?(c=h(),null!==c?(e=h(),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(a,b){return b.join("")}(f,a)),null===a&&(oe=f),a}function s(){var a,b,c,d,f,g;for(d=oe,f=oe,g=oe,a=[],b=i();null!==b;)a.push(b),b=i();if(null!==a?(b=e(),null!==b?a=[a,b]:(a=null,oe=g)):(a=null,oe=g),a=null!==a?a:"",null!==a){if(c=i(),null!==c)for(b=[];null!==c;)b.push(c),c=i();else b=null;null!==b?a=[a,b]:(a=null,oe=f)}else a=null,oe=f;return null!==a&&(a=function(){return" "}(d)),null===a&&(oe=d),a}function t(){var a;return a=s(),a=null!==a?a:""}function u(){var a,c,e,f,g; for(f=oe,g=oe,a=[],c=l(),null===c&&(c=m());null!==c;)a.push(c),c=l(),null===c&&(c=m());return null!==a?(58===b.charCodeAt(oe)?(c=":",oe++):(c=null,0===pe&&d('":"')),null!==c?(e=t(),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(){return":"}(f)),null===a&&(oe=f),a}function v(){var a,c,d,e,f,g,h;if(f=oe,g=oe,c=w(),null!==c)for(a=[];null!==c;)a.push(c),c=w();else a=null;if(null!==a){for(c=[],h=oe,d=[],e=s();null!==e;)d.push(e),e=s();for(null!==d?(e=w(),null!==e?d=[d,e]:(d=null,oe=h)):(d=null,oe=h);null!==d;){for(c.push(d),h=oe,d=[],e=s();null!==e;)d.push(e),e=s();null!==d?(e=w(),null!==e?d=[d,e]:(d=null,oe=h)):(d=null,oe=h)}null!==c?a=[a,c]:(a=null,oe=g)}else a=null,oe=g;return null!==a&&(a=function(a){return b.substring(oe,a)}(f)),null===a&&(oe=f),a}function w(){var a;return/^[!-~]/.test(b.charAt(oe))?(a=b.charAt(oe),oe++):(a=null,0===pe&&d("[!-~]")),null===a&&(a=x()),a}function x(){var a;return/^[\x80-\uFFFF]/.test(b.charAt(oe))?(a=b.charAt(oe),oe++):(a=null,0===pe&&d("[\\x80-\\uFFFF]")),a}function y(){var a;return/^[\x80-\xBF]/.test(b.charAt(oe))?(a=b.charAt(oe),oe++):(a=null,0===pe&&d("[\\x80-\\xBF]")),a}function z(){var a;return a=f(),null===a&&(/^[a-f]/.test(b.charAt(oe))?(a=b.charAt(oe),oe++):(a=null,0===pe&&d("[a-f]"))),a}function A(){var a,c,e;if(e=oe,c=n(),null===c&&(45===b.charCodeAt(oe)?(c="-",oe++):(c=null,0===pe&&d('"-"')),null===c&&(46===b.charCodeAt(oe)?(c=".",oe++):(c=null,0===pe&&d('"."')),null===c&&(33===b.charCodeAt(oe)?(c="!",oe++):(c=null,0===pe&&d('"!"')),null===c&&(37===b.charCodeAt(oe)?(c="%",oe++):(c=null,0===pe&&d('"%"')),null===c&&(42===b.charCodeAt(oe)?(c="*",oe++):(c=null,0===pe&&d('"*"')),null===c&&(95===b.charCodeAt(oe)?(c="_",oe++):(c=null,0===pe&&d('"_"')),null===c&&(43===b.charCodeAt(oe)?(c="+",oe++):(c=null,0===pe&&d('"+"')),null===c&&(96===b.charCodeAt(oe)?(c="`",oe++):(c=null,0===pe&&d('"`"')),null===c&&(39===b.charCodeAt(oe)?(c="'",oe++):(c=null,0===pe&&d('"\'"')),null===c&&(126===b.charCodeAt(oe)?(c="~",oe++):(c=null,0===pe&&d('"~"')))))))))))),null!==c)for(a=[];null!==c;)a.push(c),c=n(),null===c&&(45===b.charCodeAt(oe)?(c="-",oe++):(c=null,0===pe&&d('"-"')),null===c&&(46===b.charCodeAt(oe)?(c=".",oe++):(c=null,0===pe&&d('"."')),null===c&&(33===b.charCodeAt(oe)?(c="!",oe++):(c=null,0===pe&&d('"!"')),null===c&&(37===b.charCodeAt(oe)?(c="%",oe++):(c=null,0===pe&&d('"%"')),null===c&&(42===b.charCodeAt(oe)?(c="*",oe++):(c=null,0===pe&&d('"*"')),null===c&&(95===b.charCodeAt(oe)?(c="_",oe++):(c=null,0===pe&&d('"_"')),null===c&&(43===b.charCodeAt(oe)?(c="+",oe++):(c=null,0===pe&&d('"+"')),null===c&&(96===b.charCodeAt(oe)?(c="`",oe++):(c=null,0===pe&&d('"`"')),null===c&&(39===b.charCodeAt(oe)?(c="'",oe++):(c=null,0===pe&&d('"\'"')),null===c&&(126===b.charCodeAt(oe)?(c="~",oe++):(c=null,0===pe&&d('"~"'))))))))))));else a=null;return null!==a&&(a=function(a){return b.substring(oe,a)}(e)),null===a&&(oe=e),a}function B(){var a,c,e;if(e=oe,c=n(),null===c&&(45===b.charCodeAt(oe)?(c="-",oe++):(c=null,0===pe&&d('"-"')),null===c&&(33===b.charCodeAt(oe)?(c="!",oe++):(c=null,0===pe&&d('"!"')),null===c&&(37===b.charCodeAt(oe)?(c="%",oe++):(c=null,0===pe&&d('"%"')),null===c&&(42===b.charCodeAt(oe)?(c="*",oe++):(c=null,0===pe&&d('"*"')),null===c&&(95===b.charCodeAt(oe)?(c="_",oe++):(c=null,0===pe&&d('"_"')),null===c&&(43===b.charCodeAt(oe)?(c="+",oe++):(c=null,0===pe&&d('"+"')),null===c&&(96===b.charCodeAt(oe)?(c="`",oe++):(c=null,0===pe&&d('"`"')),null===c&&(39===b.charCodeAt(oe)?(c="'",oe++):(c=null,0===pe&&d('"\'"')),null===c&&(126===b.charCodeAt(oe)?(c="~",oe++):(c=null,0===pe&&d('"~"'))))))))))),null!==c)for(a=[];null!==c;)a.push(c),c=n(),null===c&&(45===b.charCodeAt(oe)?(c="-",oe++):(c=null,0===pe&&d('"-"')),null===c&&(33===b.charCodeAt(oe)?(c="!",oe++):(c=null,0===pe&&d('"!"')),null===c&&(37===b.charCodeAt(oe)?(c="%",oe++):(c=null,0===pe&&d('"%"')),null===c&&(42===b.charCodeAt(oe)?(c="*",oe++):(c=null,0===pe&&d('"*"')),null===c&&(95===b.charCodeAt(oe)?(c="_",oe++):(c=null,0===pe&&d('"_"')),null===c&&(43===b.charCodeAt(oe)?(c="+",oe++):(c=null,0===pe&&d('"+"')),null===c&&(96===b.charCodeAt(oe)?(c="`",oe++):(c=null,0===pe&&d('"`"')),null===c&&(39===b.charCodeAt(oe)?(c="'",oe++):(c=null,0===pe&&d('"\'"')),null===c&&(126===b.charCodeAt(oe)?(c="~",oe++):(c=null,0===pe&&d('"~"')))))))))));else a=null;return null!==a&&(a=function(a){return b.substring(oe,a)}(e)),null===a&&(oe=e),a}function C(){var a;return 40===b.charCodeAt(oe)?(a="(",oe++):(a=null,0===pe&&d('"("')),null===a&&(41===b.charCodeAt(oe)?(a=")",oe++):(a=null,0===pe&&d('")"')),null===a&&(60===b.charCodeAt(oe)?(a="<",oe++):(a=null,0===pe&&d('"<"')),null===a&&(62===b.charCodeAt(oe)?(a=">",oe++):(a=null,0===pe&&d('">"')),null===a&&(64===b.charCodeAt(oe)?(a="@",oe++):(a=null,0===pe&&d('"@"')),null===a&&(44===b.charCodeAt(oe)?(a=",",oe++):(a=null,0===pe&&d('","')),null===a&&(59===b.charCodeAt(oe)?(a=";",oe++):(a=null,0===pe&&d('";"')),null===a&&(58===b.charCodeAt(oe)?(a=":",oe++):(a=null,0===pe&&d('":"')),null===a&&(92===b.charCodeAt(oe)?(a="\\",oe++):(a=null,0===pe&&d('"\\\\"')),null===a&&(a=k(),null===a&&(47===b.charCodeAt(oe)?(a="/",oe++):(a=null,0===pe&&d('"/"')),null===a&&(91===b.charCodeAt(oe)?(a="[",oe++):(a=null,0===pe&&d('"["')),null===a&&(93===b.charCodeAt(oe)?(a="]",oe++):(a=null,0===pe&&d('"]"')),null===a&&(63===b.charCodeAt(oe)?(a="?",oe++):(a=null,0===pe&&d('"?"')),null===a&&(61===b.charCodeAt(oe)?(a="=",oe++):(a=null,0===pe&&d('"="')),null===a&&(123===b.charCodeAt(oe)?(a="{",oe++):(a=null,0===pe&&d('"{"')),null===a&&(125===b.charCodeAt(oe)?(a="}",oe++):(a=null,0===pe&&d('"}"')),null===a&&(a=l(),null===a&&(a=m())))))))))))))))))),a}function D(){var a,c,e;if(e=oe,c=n(),null===c&&(45===b.charCodeAt(oe)?(c="-",oe++):(c=null,0===pe&&d('"-"')),null===c&&(46===b.charCodeAt(oe)?(c=".",oe++):(c=null,0===pe&&d('"."')),null===c&&(33===b.charCodeAt(oe)?(c="!",oe++):(c=null,0===pe&&d('"!"')),null===c&&(37===b.charCodeAt(oe)?(c="%",oe++):(c=null,0===pe&&d('"%"')),null===c&&(42===b.charCodeAt(oe)?(c="*",oe++):(c=null,0===pe&&d('"*"')),null===c&&(95===b.charCodeAt(oe)?(c="_",oe++):(c=null,0===pe&&d('"_"')),null===c&&(43===b.charCodeAt(oe)?(c="+",oe++):(c=null,0===pe&&d('"+"')),null===c&&(96===b.charCodeAt(oe)?(c="`",oe++):(c=null,0===pe&&d('"`"')),null===c&&(39===b.charCodeAt(oe)?(c="'",oe++):(c=null,0===pe&&d('"\'"')),null===c&&(126===b.charCodeAt(oe)?(c="~",oe++):(c=null,0===pe&&d('"~"')),null===c&&(40===b.charCodeAt(oe)?(c="(",oe++):(c=null,0===pe&&d('"("')),null===c&&(41===b.charCodeAt(oe)?(c=")",oe++):(c=null,0===pe&&d('")"')),null===c&&(60===b.charCodeAt(oe)?(c="<",oe++):(c=null,0===pe&&d('"<"')),null===c&&(62===b.charCodeAt(oe)?(c=">",oe++):(c=null,0===pe&&d('">"')),null===c&&(58===b.charCodeAt(oe)?(c=":",oe++):(c=null,0===pe&&d('":"')),null===c&&(92===b.charCodeAt(oe)?(c="\\",oe++):(c=null,0===pe&&d('"\\\\"')),null===c&&(c=k(),null===c&&(47===b.charCodeAt(oe)?(c="/",oe++):(c=null,0===pe&&d('"/"')),null===c&&(91===b.charCodeAt(oe)?(c="[",oe++):(c=null,0===pe&&d('"["')),null===c&&(93===b.charCodeAt(oe)?(c="]",oe++):(c=null,0===pe&&d('"]"')),null===c&&(63===b.charCodeAt(oe)?(c="?",oe++):(c=null,0===pe&&d('"?"')),null===c&&(123===b.charCodeAt(oe)?(c="{",oe++):(c=null,0===pe&&d('"{"')),null===c&&(125===b.charCodeAt(oe)?(c="}",oe++):(c=null,0===pe&&d('"}"'))))))))))))))))))))))))),null!==c)for(a=[];null!==c;)a.push(c),c=n(),null===c&&(45===b.charCodeAt(oe)?(c="-",oe++):(c=null,0===pe&&d('"-"')),null===c&&(46===b.charCodeAt(oe)?(c=".",oe++):(c=null,0===pe&&d('"."')),null===c&&(33===b.charCodeAt(oe)?(c="!",oe++):(c=null,0===pe&&d('"!"')),null===c&&(37===b.charCodeAt(oe)?(c="%",oe++):(c=null,0===pe&&d('"%"')),null===c&&(42===b.charCodeAt(oe)?(c="*",oe++):(c=null,0===pe&&d('"*"')),null===c&&(95===b.charCodeAt(oe)?(c="_",oe++):(c=null,0===pe&&d('"_"')),null===c&&(43===b.charCodeAt(oe)?(c="+",oe++):(c=null,0===pe&&d('"+"')),null===c&&(96===b.charCodeAt(oe)?(c="`",oe++):(c=null,0===pe&&d('"`"')),null===c&&(39===b.charCodeAt(oe)?(c="'",oe++):(c=null,0===pe&&d('"\'"')),null===c&&(126===b.charCodeAt(oe)?(c="~",oe++):(c=null,0===pe&&d('"~"')),null===c&&(40===b.charCodeAt(oe)?(c="(",oe++):(c=null,0===pe&&d('"("')),null===c&&(41===b.charCodeAt(oe)?(c=")",oe++):(c=null,0===pe&&d('")"')),null===c&&(60===b.charCodeAt(oe)?(c="<",oe++):(c=null,0===pe&&d('"<"')),null===c&&(62===b.charCodeAt(oe)?(c=">",oe++):(c=null,0===pe&&d('">"')),null===c&&(58===b.charCodeAt(oe)?(c=":",oe++):(c=null,0===pe&&d('":"')),null===c&&(92===b.charCodeAt(oe)?(c="\\",oe++):(c=null,0===pe&&d('"\\\\"')),null===c&&(c=k(),null===c&&(47===b.charCodeAt(oe)?(c="/",oe++):(c=null,0===pe&&d('"/"')),null===c&&(91===b.charCodeAt(oe)?(c="[",oe++):(c=null,0===pe&&d('"["')),null===c&&(93===b.charCodeAt(oe)?(c="]",oe++):(c=null,0===pe&&d('"]"')),null===c&&(63===b.charCodeAt(oe)?(c="?",oe++):(c=null,0===pe&&d('"?"')),null===c&&(123===b.charCodeAt(oe)?(c="{",oe++):(c=null,0===pe&&d('"{"')),null===c&&(125===b.charCodeAt(oe)?(c="}",oe++):(c=null,0===pe&&d('"}"')))))))))))))))))))))))));else a=null;return null!==a&&(a=function(a){return b.substring(oe,a)}(e)),null===a&&(oe=e),a}function E(){var a,c,e,f,g;return f=oe,g=oe,a=t(),null!==a?(42===b.charCodeAt(oe)?(c="*",oe++):(c=null,0===pe&&d('"*"')),null!==c?(e=t(),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(){return"*"}(f)),null===a&&(oe=f),a}function F(){var a,c,e,f,g;return f=oe,g=oe,a=t(),null!==a?(47===b.charCodeAt(oe)?(c="/",oe++):(c=null,0===pe&&d('"/"')),null!==c?(e=t(),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(){return"/"}(f)),null===a&&(oe=f),a}function G(){var a,c,e,f,g;return f=oe,g=oe,a=t(),null!==a?(61===b.charCodeAt(oe)?(c="=",oe++):(c=null,0===pe&&d('"="')),null!==c?(e=t(),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(){return"="}(f)),null===a&&(oe=f),a}function H(){var a,c,e,f,g;return f=oe,g=oe,a=t(),null!==a?(40===b.charCodeAt(oe)?(c="(",oe++):(c=null,0===pe&&d('"("')),null!==c?(e=t(),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(){return"("}(f)),null===a&&(oe=f),a}function I(){var a,c,e,f,g;return f=oe,g=oe,a=t(),null!==a?(41===b.charCodeAt(oe)?(c=")",oe++):(c=null,0===pe&&d('")"')),null!==c?(e=t(),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(){return")"}(f)),null===a&&(oe=f),a}function J(){var a,c,e,f;return e=oe,f=oe,62===b.charCodeAt(oe)?(a=">",oe++):(a=null,0===pe&&d('">"')),null!==a?(c=t(),null!==c?a=[a,c]:(a=null,oe=f)):(a=null,oe=f),null!==a&&(a=function(){return">"}(e)),null===a&&(oe=e),a}function K(){var a,c,e,f;return e=oe,f=oe,a=t(),null!==a?(60===b.charCodeAt(oe)?(c="<",oe++):(c=null,0===pe&&d('"<"')),null!==c?a=[a,c]:(a=null,oe=f)):(a=null,oe=f),null!==a&&(a=function(){return"<"}(e)),null===a&&(oe=e),a}function L(){var a,c,e,f,g;return f=oe,g=oe,a=t(),null!==a?(44===b.charCodeAt(oe)?(c=",",oe++):(c=null,0===pe&&d('","')),null!==c?(e=t(),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(){return","}(f)),null===a&&(oe=f),a}function M(){var a,c,e,f,g;return f=oe,g=oe,a=t(),null!==a?(59===b.charCodeAt(oe)?(c=";",oe++):(c=null,0===pe&&d('";"')),null!==c?(e=t(),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(){return";"}(f)),null===a&&(oe=f),a}function N(){var a,c,e,f,g;return f=oe,g=oe,a=t(),null!==a?(58===b.charCodeAt(oe)?(c=":",oe++):(c=null,0===pe&&d('":"')),null!==c?(e=t(),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(){return":"}(f)),null===a&&(oe=f),a}function O(){var a,b,c,d;return c=oe,d=oe,a=t(),null!==a?(b=k(),null!==b?a=[a,b]:(a=null,oe=d)):(a=null,oe=d),null!==a&&(a=function(){return'"'}(c)),null===a&&(oe=c),a}function P(){var a,b,c,d;return c=oe,d=oe,a=k(),null!==a?(b=t(),null!==b?a=[a,b]:(a=null,oe=d)):(a=null,oe=d),null!==a&&(a=function(){return'"'}(c)),null===a&&(oe=c),a}function Q(){var a,b,c,d;if(d=oe,a=H(),null!==a){for(b=[],c=R(),null===c&&(c=V(),null===c&&(c=Q()));null!==c;)b.push(c),c=R(),null===c&&(c=V(),null===c&&(c=Q()));null!==b?(c=I(),null!==c?a=[a,b,c]:(a=null,oe=d)):(a=null,oe=d)}else a=null,oe=d;return a}function R(){var a;return/^[!-']/.test(b.charAt(oe))?(a=b.charAt(oe),oe++):(a=null,0===pe&&d("[!-']")),null===a&&(/^[*-[]/.test(b.charAt(oe))?(a=b.charAt(oe),oe++):(a=null,0===pe&&d("[*-[]")),null===a&&(/^[\]-~]/.test(b.charAt(oe))?(a=b.charAt(oe),oe++):(a=null,0===pe&&d("[\\]-~]")),null===a&&(a=x(),null===a&&(a=s())))),a}function S(){var a,c,d,e,f,g;if(f=oe,g=oe,a=t(),null!==a)if(c=k(),null!==c){for(d=[],e=U(),null===e&&(e=V());null!==e;)d.push(e),e=U(),null===e&&(e=V());null!==d?(e=k(),null!==e?a=[a,c,d,e]:(a=null,oe=g)):(a=null,oe=g)}else a=null,oe=g;else a=null,oe=g;return null!==a&&(a=function(a){return b.substring(oe,a)}(f)),null===a&&(oe=f),a}function T(){var a,c,d,e,f,g;if(f=oe,g=oe,a=t(),null!==a)if(c=k(),null!==c){for(d=[],e=U(),null===e&&(e=V());null!==e;)d.push(e),e=U(),null===e&&(e=V());null!==d?(e=k(),null!==e?a=[a,c,d,e]:(a=null,oe=g)):(a=null,oe=g)}else a=null,oe=g;else a=null,oe=g;return null!==a&&(a=function(a){return b.substring(oe-1,a+1)}(f)),null===a&&(oe=f),a}function U(){var a;return a=s(),null===a&&(33===b.charCodeAt(oe)?(a="!",oe++):(a=null,0===pe&&d('"!"')),null===a&&(/^[#-[]/.test(b.charAt(oe))?(a=b.charAt(oe),oe++):(a=null,0===pe&&d("[#-[]")),null===a&&(/^[\]-~]/.test(b.charAt(oe))?(a=b.charAt(oe),oe++):(a=null,0===pe&&d("[\\]-~]")),null===a&&(a=x())))),a}function V(){var a,c,e;return e=oe,92===b.charCodeAt(oe)?(a="\\",oe++):(a=null,0===pe&&d('"\\\\"')),null!==a?(/^[\0-\t]/.test(b.charAt(oe))?(c=b.charAt(oe),oe++):(c=null,0===pe&&d("[\\0-\\t]")),null===c&&(/^[\x0B-\f]/.test(b.charAt(oe))?(c=b.charAt(oe),oe++):(c=null,0===pe&&d("[\\x0B-\\f]")),null===c&&(/^[\x0E-]/.test(b.charAt(oe))?(c=b.charAt(oe),oe++):(c=null,0===pe&&d("[\\x0E-]")))),null!==c?a=[a,c]:(a=null,oe=e)):(a=null,oe=e),a}function W(){var a,c,e,f,g,h;return g=oe,h=oe,a=Y(),null!==a?(58===b.charCodeAt(oe)?(c=":",oe++):(c=null,0===pe&&d('":"')),null!==c?(e=Z(),e=null!==e?e:"",null!==e?(f=bb(),null!==f?a=[a,c,e,f]:(a=null,oe=h)):(a=null,oe=h)):(a=null,oe=h)):(a=null,oe=h),null!==a&&(a=function(){try{se.uri=new SIP.URI(se.scheme,se.user,se.host,se.port),delete se.scheme,delete se.user,delete se.host,delete se.host_type,delete se.port}catch(a){se=-1}}(g)),null===a&&(oe=g),a}function X(){var a,e,f,g,h,i,j,k;return j=oe,k=oe,a=Y(),null!==a?(58===b.charCodeAt(oe)?(e=":",oe++):(e=null,0===pe&&d('":"')),null!==e?(f=Z(),f=null!==f?f:"",null!==f?(g=bb(),null!==g?(h=nb(),null!==h?(i=Ab(),i=null!==i?i:"",null!==i?a=[a,e,f,g,h,i]:(a=null,oe=k)):(a=null,oe=k)):(a=null,oe=k)):(a=null,oe=k)):(a=null,oe=k)):(a=null,oe=k),null!==a&&(a=function(){try{se.uri=new SIP.URI(se.scheme,se.user,se.host,se.port,se.uri_params,se.uri_headers),delete se.scheme,delete se.user,delete se.host,delete se.host_type,delete se.port,delete se.uri_params,"SIP_URI"===c&&(se=se.uri)}catch(a){se=-1}}(j)),null===a&&(oe=j),a}function Y(){var a,c;return c=oe,"sips"===b.substr(oe,4).toLowerCase()?(a=b.substr(oe,4),oe+=4):(a=null,0===pe&&d('"sips"')),null===a&&("sip"===b.substr(oe,3).toLowerCase()?(a=b.substr(oe,3),oe+=3):(a=null,0===pe&&d('"sip"'))),null!==a&&(a=function(a,b){se.scheme=b.toLowerCase()}(c,a)),null===a&&(oe=c),a}function Z(){var a,c,e,f,g,h;return f=oe,g=oe,a=$(),null!==a?(h=oe,58===b.charCodeAt(oe)?(c=":",oe++):(c=null,0===pe&&d('":"')),null!==c?(e=ab(),null!==e?c=[c,e]:(c=null,oe=h)):(c=null,oe=h),c=null!==c?c:"",null!==c?(64===b.charCodeAt(oe)?(e="@",oe++):(e=null,0===pe&&d('"@"')),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(a){se.user=window.decodeURIComponent(b.substring(oe-1,a))}(f)),null===a&&(oe=f),a}function $(){var a,b;if(b=p(),null===b&&(b=r(),null===b&&(b=_())),null!==b)for(a=[];null!==b;)a.push(b),b=p(),null===b&&(b=r(),null===b&&(b=_()));else a=null;return a}function _(){var a;return 38===b.charCodeAt(oe)?(a="&",oe++):(a=null,0===pe&&d('"&"')),null===a&&(61===b.charCodeAt(oe)?(a="=",oe++):(a=null,0===pe&&d('"="')),null===a&&(43===b.charCodeAt(oe)?(a="+",oe++):(a=null,0===pe&&d('"+"')),null===a&&(36===b.charCodeAt(oe)?(a="$",oe++):(a=null,0===pe&&d('"$"')),null===a&&(44===b.charCodeAt(oe)?(a=",",oe++):(a=null,0===pe&&d('","')),null===a&&(59===b.charCodeAt(oe)?(a=";",oe++):(a=null,0===pe&&d('";"')),null===a&&(63===b.charCodeAt(oe)?(a="?",oe++):(a=null,0===pe&&d('"?"')),null===a&&(47===b.charCodeAt(oe)?(a="/",oe++):(a=null,0===pe&&d('"/"'))))))))),a}function ab(){var a,c,e;for(e=oe,a=[],c=p(),null===c&&(c=r(),null===c&&(38===b.charCodeAt(oe)?(c="&",oe++):(c=null,0===pe&&d('"&"')),null===c&&(61===b.charCodeAt(oe)?(c="=",oe++):(c=null,0===pe&&d('"="')),null===c&&(43===b.charCodeAt(oe)?(c="+",oe++):(c=null,0===pe&&d('"+"')),null===c&&(36===b.charCodeAt(oe)?(c="$",oe++):(c=null,0===pe&&d('"$"')),null===c&&(44===b.charCodeAt(oe)?(c=",",oe++):(c=null,0===pe&&d('","'))))))));null!==c;)a.push(c),c=p(),null===c&&(c=r(),null===c&&(38===b.charCodeAt(oe)?(c="&",oe++):(c=null,0===pe&&d('"&"')),null===c&&(61===b.charCodeAt(oe)?(c="=",oe++):(c=null,0===pe&&d('"="')),null===c&&(43===b.charCodeAt(oe)?(c="+",oe++):(c=null,0===pe&&d('"+"')),null===c&&(36===b.charCodeAt(oe)?(c="$",oe++):(c=null,0===pe&&d('"$"')),null===c&&(44===b.charCodeAt(oe)?(c=",",oe++):(c=null,0===pe&&d('","'))))))));return null!==a&&(a=function(a){se.password=b.substring(oe,a)}(e)),null===a&&(oe=e),a}function bb(){var a,c,e,f,g;return f=oe,a=cb(),null!==a?(g=oe,58===b.charCodeAt(oe)?(c=":",oe++):(c=null,0===pe&&d('":"')),null!==c?(e=mb(),null!==e?c=[c,e]:(c=null,oe=g)):(c=null,oe=g),c=null!==c?c:"",null!==c?a=[a,c]:(a=null,oe=f)):(a=null,oe=f),a}function cb(){var a,c;return c=oe,a=db(),null===a&&(a=kb(),null===a&&(a=gb())),null!==a&&(a=function(a){return se.host=b.substring(oe,a).toLowerCase(),se.host}(c)),null===a&&(oe=c),a}function db(){var a,c,e,f,g,h;for(f=oe,g=oe,a=[],h=oe,c=eb(),null!==c?(46===b.charCodeAt(oe)?(e=".",oe++):(e=null,0===pe&&d('"."')),null!==e?c=[c,e]:(c=null,oe=h)):(c=null,oe=h);null!==c;)a.push(c),h=oe,c=eb(),null!==c?(46===b.charCodeAt(oe)?(e=".",oe++):(e=null,0===pe&&d('"."')),null!==e?c=[c,e]:(c=null,oe=h)):(c=null,oe=h);return null!==a?(c=fb(),null!==c?(46===b.charCodeAt(oe)?(e=".",oe++):(e=null,0===pe&&d('"."')),e=null!==e?e:"",null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(a){return se.host_type="domain",b.substring(oe,a)}(f)),null===a&&(oe=f),a}function eb(){var a,c;if(/^[a-zA-Z0-9_\-]/.test(b.charAt(oe))?(c=b.charAt(oe),oe++):(c=null,0===pe&&d("[a-zA-Z0-9_\\-]")),null!==c)for(a=[];null!==c;)a.push(c),/^[a-zA-Z0-9_\-]/.test(b.charAt(oe))?(c=b.charAt(oe),oe++):(c=null,0===pe&&d("[a-zA-Z0-9_\\-]"));else a=null;return a}function fb(){var a,c;if(/^[a-zA-Z_\-]/.test(b.charAt(oe))?(c=b.charAt(oe),oe++):(c=null,0===pe&&d("[a-zA-Z_\\-]")),null!==c)for(a=[];null!==c;)a.push(c),/^[a-zA-Z_\-]/.test(b.charAt(oe))?(c=b.charAt(oe),oe++):(c=null,0===pe&&d("[a-zA-Z_\\-]"));else a=null;return a}function gb(){var a,c,e,f,g;return f=oe,g=oe,91===b.charCodeAt(oe)?(a="[",oe++):(a=null,0===pe&&d('"["')),null!==a?(c=hb(),null!==c?(93===b.charCodeAt(oe)?(e="]",oe++):(e=null,0===pe&&d('"]"')),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(a){return se.host_type="IPv6",b.substring(oe,a)}(f)),null===a&&(oe=f),a}function hb(){var a,c,e,f,g,h,i,j,k,l,m,n,o,p,q,r;return p=oe,q=oe,a=ib(),null!==a?(58===b.charCodeAt(oe)?(c=":",oe++):(c=null,0===pe&&d('":"')),null!==c?(e=ib(),null!==e?(58===b.charCodeAt(oe)?(f=":",oe++):(f=null,0===pe&&d('":"')),null!==f?(g=ib(),null!==g?(58===b.charCodeAt(oe)?(h=":",oe++):(h=null,0===pe&&d('":"')),null!==h?(i=ib(),null!==i?(58===b.charCodeAt(oe)?(j=":",oe++):(j=null,0===pe&&d('":"')),null!==j?(k=ib(),null!==k?(58===b.charCodeAt(oe)?(l=":",oe++):(l=null,0===pe&&d('":"')),null!==l?(m=ib(),null!==m?(58===b.charCodeAt(oe)?(n=":",oe++):(n=null,0===pe&&d('":"')),null!==n?(o=jb(),null!==o?a=[a,c,e,f,g,h,i,j,k,l,m,n,o]:(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q),null===a&&(q=oe,"::"===b.substr(oe,2)?(a="::",oe+=2):(a=null,0===pe&&d('"::"')),null!==a?(c=ib(),null!==c?(58===b.charCodeAt(oe)?(e=":",oe++):(e=null,0===pe&&d('":"')),null!==e?(f=ib(),null!==f?(58===b.charCodeAt(oe)?(g=":",oe++):(g=null,0===pe&&d('":"')),null!==g?(h=ib(),null!==h?(58===b.charCodeAt(oe)?(i=":",oe++):(i=null,0===pe&&d('":"')),null!==i?(j=ib(),null!==j?(58===b.charCodeAt(oe)?(k=":",oe++):(k=null,0===pe&&d('":"')),null!==k?(l=ib(),null!==l?(58===b.charCodeAt(oe)?(m=":",oe++):(m=null,0===pe&&d('":"')),null!==m?(n=jb(),null!==n?a=[a,c,e,f,g,h,i,j,k,l,m,n]:(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q),null===a&&(q=oe,"::"===b.substr(oe,2)?(a="::",oe+=2):(a=null,0===pe&&d('"::"')),null!==a?(c=ib(),null!==c?(58===b.charCodeAt(oe)?(e=":",oe++):(e=null,0===pe&&d('":"')),null!==e?(f=ib(),null!==f?(58===b.charCodeAt(oe)?(g=":",oe++):(g=null,0===pe&&d('":"')),null!==g?(h=ib(),null!==h?(58===b.charCodeAt(oe)?(i=":",oe++):(i=null,0===pe&&d('":"')),null!==i?(j=ib(),null!==j?(58===b.charCodeAt(oe)?(k=":",oe++):(k=null,0===pe&&d('":"')),null!==k?(l=jb(),null!==l?a=[a,c,e,f,g,h,i,j,k,l]:(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q),null===a&&(q=oe,"::"===b.substr(oe,2)?(a="::",oe+=2):(a=null,0===pe&&d('"::"')),null!==a?(c=ib(),null!==c?(58===b.charCodeAt(oe)?(e=":",oe++):(e=null,0===pe&&d('":"')),null!==e?(f=ib(),null!==f?(58===b.charCodeAt(oe)?(g=":",oe++):(g=null,0===pe&&d('":"')),null!==g?(h=ib(),null!==h?(58===b.charCodeAt(oe)?(i=":",oe++):(i=null,0===pe&&d('":"')),null!==i?(j=jb(),null!==j?a=[a,c,e,f,g,h,i,j]:(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q),null===a&&(q=oe,"::"===b.substr(oe,2)?(a="::",oe+=2):(a=null,0===pe&&d('"::"')),null!==a?(c=ib(),null!==c?(58===b.charCodeAt(oe)?(e=":",oe++):(e=null,0===pe&&d('":"')),null!==e?(f=ib(),null!==f?(58===b.charCodeAt(oe)?(g=":",oe++):(g=null,0===pe&&d('":"')),null!==g?(h=jb(),null!==h?a=[a,c,e,f,g,h]:(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q),null===a&&(q=oe,"::"===b.substr(oe,2)?(a="::",oe+=2):(a=null,0===pe&&d('"::"')),null!==a?(c=ib(),null!==c?(58===b.charCodeAt(oe)?(e=":",oe++):(e=null,0===pe&&d('":"')),null!==e?(f=jb(),null!==f?a=[a,c,e,f]:(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q),null===a&&(q=oe,"::"===b.substr(oe,2)?(a="::",oe+=2):(a=null,0===pe&&d('"::"')),null!==a?(c=jb(),null!==c?a=[a,c]:(a=null,oe=q)):(a=null,oe=q),null===a&&(q=oe,"::"===b.substr(oe,2)?(a="::",oe+=2):(a=null,0===pe&&d('"::"')),null!==a?(c=ib(),null!==c?a=[a,c]:(a=null,oe=q)):(a=null,oe=q),null===a&&(q=oe,a=ib(),null!==a?("::"===b.substr(oe,2)?(c="::",oe+=2):(c=null,0===pe&&d('"::"')),null!==c?(e=ib(),null!==e?(58===b.charCodeAt(oe)?(f=":",oe++):(f=null,0===pe&&d('":"')),null!==f?(g=ib(),null!==g?(58===b.charCodeAt(oe)?(h=":",oe++):(h=null,0===pe&&d('":"')),null!==h?(i=ib(),null!==i?(58===b.charCodeAt(oe)?(j=":",oe++):(j=null,0===pe&&d('":"')),null!==j?(k=ib(),null!==k?(58===b.charCodeAt(oe)?(l=":",oe++):(l=null,0===pe&&d('":"')),null!==l?(m=jb(),null!==m?a=[a,c,e,f,g,h,i,j,k,l,m]:(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q),null===a&&(q=oe,a=ib(),null!==a?(r=oe,58===b.charCodeAt(oe)?(c=":",oe++):(c=null,0===pe&&d('":"')),null!==c?(e=ib(),null!==e?c=[c,e]:(c=null,oe=r)):(c=null,oe=r),c=null!==c?c:"",null!==c?("::"===b.substr(oe,2)?(e="::",oe+=2):(e=null,0===pe&&d('"::"')),null!==e?(f=ib(),null!==f?(58===b.charCodeAt(oe)?(g=":",oe++):(g=null,0===pe&&d('":"')),null!==g?(h=ib(),null!==h?(58===b.charCodeAt(oe)?(i=":",oe++):(i=null,0===pe&&d('":"')),null!==i?(j=ib(),null!==j?(58===b.charCodeAt(oe)?(k=":",oe++):(k=null,0===pe&&d('":"')),null!==k?(l=jb(),null!==l?a=[a,c,e,f,g,h,i,j,k,l]:(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q),null===a&&(q=oe,a=ib(),null!==a?(r=oe,58===b.charCodeAt(oe)?(c=":",oe++):(c=null,0===pe&&d('":"')),null!==c?(e=ib(),null!==e?c=[c,e]:(c=null,oe=r)):(c=null,oe=r),c=null!==c?c:"",null!==c?(r=oe,58===b.charCodeAt(oe)?(e=":",oe++):(e=null,0===pe&&d('":"')),null!==e?(f=ib(),null!==f?e=[e,f]:(e=null,oe=r)):(e=null,oe=r),e=null!==e?e:"",null!==e?("::"===b.substr(oe,2)?(f="::",oe+=2):(f=null,0===pe&&d('"::"')),null!==f?(g=ib(),null!==g?(58===b.charCodeAt(oe)?(h=":",oe++):(h=null,0===pe&&d('":"')),null!==h?(i=ib(),null!==i?(58===b.charCodeAt(oe)?(j=":",oe++):(j=null,0===pe&&d('":"')),null!==j?(k=jb(),null!==k?a=[a,c,e,f,g,h,i,j,k]:(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q),null===a&&(q=oe,a=ib(),null!==a?(r=oe,58===b.charCodeAt(oe)?(c=":",oe++):(c=null,0===pe&&d('":"')),null!==c?(e=ib(),null!==e?c=[c,e]:(c=null,oe=r)):(c=null,oe=r),c=null!==c?c:"",null!==c?(r=oe,58===b.charCodeAt(oe)?(e=":",oe++):(e=null,0===pe&&d('":"')),null!==e?(f=ib(),null!==f?e=[e,f]:(e=null,oe=r)):(e=null,oe=r),e=null!==e?e:"",null!==e?(r=oe,58===b.charCodeAt(oe)?(f=":",oe++):(f=null,0===pe&&d('":"')),null!==f?(g=ib(),null!==g?f=[f,g]:(f=null,oe=r)):(f=null,oe=r),f=null!==f?f:"",null!==f?("::"===b.substr(oe,2)?(g="::",oe+=2):(g=null,0===pe&&d('"::"')),null!==g?(h=ib(),null!==h?(58===b.charCodeAt(oe)?(i=":",oe++):(i=null,0===pe&&d('":"')),null!==i?(j=jb(),null!==j?a=[a,c,e,f,g,h,i,j]:(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q),null===a&&(q=oe,a=ib(),null!==a?(r=oe,58===b.charCodeAt(oe)?(c=":",oe++):(c=null,0===pe&&d('":"')),null!==c?(e=ib(),null!==e?c=[c,e]:(c=null,oe=r)):(c=null,oe=r),c=null!==c?c:"",null!==c?(r=oe,58===b.charCodeAt(oe)?(e=":",oe++):(e=null,0===pe&&d('":"')),null!==e?(f=ib(),null!==f?e=[e,f]:(e=null,oe=r)):(e=null,oe=r),e=null!==e?e:"",null!==e?(r=oe,58===b.charCodeAt(oe)?(f=":",oe++):(f=null,0===pe&&d('":"')),null!==f?(g=ib(),null!==g?f=[f,g]:(f=null,oe=r)):(f=null,oe=r),f=null!==f?f:"",null!==f?(r=oe,58===b.charCodeAt(oe)?(g=":",oe++):(g=null,0===pe&&d('":"')),null!==g?(h=ib(),null!==h?g=[g,h]:(g=null,oe=r)):(g=null,oe=r),g=null!==g?g:"",null!==g?("::"===b.substr(oe,2)?(h="::",oe+=2):(h=null,0===pe&&d('"::"')),null!==h?(i=jb(),null!==i?a=[a,c,e,f,g,h,i]:(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q),null===a&&(q=oe,a=ib(),null!==a?(r=oe,58===b.charCodeAt(oe)?(c=":",oe++):(c=null,0===pe&&d('":"')),null!==c?(e=ib(),null!==e?c=[c,e]:(c=null,oe=r)):(c=null,oe=r),c=null!==c?c:"",null!==c?(r=oe,58===b.charCodeAt(oe)?(e=":",oe++):(e=null,0===pe&&d('":"')),null!==e?(f=ib(),null!==f?e=[e,f]:(e=null,oe=r)):(e=null,oe=r),e=null!==e?e:"",null!==e?(r=oe,58===b.charCodeAt(oe)?(f=":",oe++):(f=null,0===pe&&d('":"')),null!==f?(g=ib(),null!==g?f=[f,g]:(f=null,oe=r)):(f=null,oe=r),f=null!==f?f:"",null!==f?(r=oe,58===b.charCodeAt(oe)?(g=":",oe++):(g=null,0===pe&&d('":"')),null!==g?(h=ib(),null!==h?g=[g,h]:(g=null,oe=r)):(g=null,oe=r),g=null!==g?g:"",null!==g?(r=oe,58===b.charCodeAt(oe)?(h=":",oe++):(h=null,0===pe&&d('":"')),null!==h?(i=ib(),null!==i?h=[h,i]:(h=null,oe=r)):(h=null,oe=r),h=null!==h?h:"",null!==h?("::"===b.substr(oe,2)?(i="::",oe+=2):(i=null,0===pe&&d('"::"')),null!==i?(j=ib(),null!==j?a=[a,c,e,f,g,h,i,j]:(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q),null===a&&(q=oe,a=ib(),null!==a?(r=oe,58===b.charCodeAt(oe)?(c=":",oe++):(c=null,0===pe&&d('":"')),null!==c?(e=ib(),null!==e?c=[c,e]:(c=null,oe=r)):(c=null,oe=r),c=null!==c?c:"",null!==c?(r=oe,58===b.charCodeAt(oe)?(e=":",oe++):(e=null,0===pe&&d('":"')),null!==e?(f=ib(),null!==f?e=[e,f]:(e=null,oe=r)):(e=null,oe=r),e=null!==e?e:"",null!==e?(r=oe,58===b.charCodeAt(oe)?(f=":",oe++):(f=null,0===pe&&d('":"')),null!==f?(g=ib(),null!==g?f=[f,g]:(f=null,oe=r)):(f=null,oe=r),f=null!==f?f:"",null!==f?(r=oe,58===b.charCodeAt(oe)?(g=":",oe++):(g=null,0===pe&&d('":"')),null!==g?(h=ib(),null!==h?g=[g,h]:(g=null,oe=r)):(g=null,oe=r),g=null!==g?g:"",null!==g?(r=oe,58===b.charCodeAt(oe)?(h=":",oe++):(h=null,0===pe&&d('":"')),null!==h?(i=ib(),null!==i?h=[h,i]:(h=null,oe=r)):(h=null,oe=r),h=null!==h?h:"",null!==h?(r=oe,58===b.charCodeAt(oe)?(i=":",oe++):(i=null,0===pe&&d('":"')),null!==i?(j=ib(),null!==j?i=[i,j]:(i=null,oe=r)):(i=null,oe=r),i=null!==i?i:"",null!==i?("::"===b.substr(oe,2)?(j="::",oe+=2):(j=null,0===pe&&d('"::"')),null!==j?a=[a,c,e,f,g,h,i,j]:(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q)):(a=null,oe=q))))))))))))))),null!==a&&(a=function(a){return se.host_type="IPv6",b.substring(oe,a)}(p)),null===a&&(oe=p),a}function ib(){var a,b,c,d,e;return e=oe,a=h(),null!==a?(b=h(),b=null!==b?b:"",null!==b?(c=h(),c=null!==c?c:"",null!==c?(d=h(),d=null!==d?d:"",null!==d?a=[a,b,c,d]:(a=null,oe=e)):(a=null,oe=e)):(a=null,oe=e)):(a=null,oe=e),a}function jb(){var a,c,e,f;return f=oe,a=ib(),null!==a?(58===b.charCodeAt(oe)?(c=":",oe++):(c=null,0===pe&&d('":"')),null!==c?(e=ib(),null!==e?a=[a,c,e]:(a=null,oe=f)):(a=null,oe=f)):(a=null,oe=f),null===a&&(a=kb()),a}function kb(){var a,c,e,f,g,h,i,j,k;return j=oe,k=oe,a=lb(),null!==a?(46===b.charCodeAt(oe)?(c=".",oe++):(c=null,0===pe&&d('"."')),null!==c?(e=lb(),null!==e?(46===b.charCodeAt(oe)?(f=".",oe++):(f=null,0===pe&&d('"."')),null!==f?(g=lb(),null!==g?(46===b.charCodeAt(oe)?(h=".",oe++):(h=null,0===pe&&d('"."')),null!==h?(i=lb(),null!==i?a=[a,c,e,f,g,h,i]:(a=null,oe=k)):(a=null,oe=k)):(a=null,oe=k)):(a=null,oe=k)):(a=null,oe=k)):(a=null,oe=k)):(a=null,oe=k),null!==a&&(a=function(a){return se.host_type="IPv4",b.substring(oe,a)}(j)),null===a&&(oe=j),a}function lb(){var a,c,e,g;return g=oe,"25"===b.substr(oe,2)?(a="25",oe+=2):(a=null,0===pe&&d('"25"')),null!==a?(/^[0-5]/.test(b.charAt(oe))?(c=b.charAt(oe),oe++):(c=null,0===pe&&d("[0-5]")),null!==c?a=[a,c]:(a=null,oe=g)):(a=null,oe=g),null===a&&(g=oe,50===b.charCodeAt(oe)?(a="2",oe++):(a=null,0===pe&&d('"2"')),null!==a?(/^[0-4]/.test(b.charAt(oe))?(c=b.charAt(oe),oe++):(c=null,0===pe&&d("[0-4]")),null!==c?(e=f(),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null===a&&(g=oe,49===b.charCodeAt(oe)?(a="1",oe++):(a=null,0===pe&&d('"1"')),null!==a?(c=f(),null!==c?(e=f(),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null===a&&(g=oe,/^[1-9]/.test(b.charAt(oe))?(a=b.charAt(oe),oe++):(a=null,0===pe&&d("[1-9]")),null!==a?(c=f(),null!==c?a=[a,c]:(a=null,oe=g)):(a=null,oe=g),null===a&&(a=f())))),a}function mb(){var a,b,c,d,e,g,h;return g=oe,h=oe,a=f(),a=null!==a?a:"",null!==a?(b=f(),b=null!==b?b:"",null!==b?(c=f(),c=null!==c?c:"",null!==c?(d=f(),d=null!==d?d:"",null!==d?(e=f(),e=null!==e?e:"",null!==e?a=[a,b,c,d,e]:(a=null,oe=h)):(a=null,oe=h)):(a=null,oe=h)):(a=null,oe=h)):(a=null,oe=h),null!==a&&(a=function(a,b){return b=parseInt(b.join("")),se.port=b,b}(g,a)),null===a&&(oe=g),a}function nb(){var a,c,e,f;for(a=[],f=oe,59===b.charCodeAt(oe)?(c=";",oe++):(c=null,0===pe&&d('";"')),null!==c?(e=ob(),null!==e?c=[c,e]:(c=null,oe=f)):(c=null,oe=f);null!==c;)a.push(c),f=oe,59===b.charCodeAt(oe)?(c=";",oe++):(c=null,0===pe&&d('";"')),null!==c?(e=ob(),null!==e?c=[c,e]:(c=null,oe=f)):(c=null,oe=f);return a}function ob(){var a;return a=pb(),null===a&&(a=qb(),null===a&&(a=rb(),null===a&&(a=sb(),null===a&&(a=tb(),null===a&&(a=ub(),null===a&&(a=vb())))))),a}function pb(){var a,c,e,f;return e=oe,f=oe,"transport="===b.substr(oe,10).toLowerCase()?(a=b.substr(oe,10),oe+=10):(a=null,0===pe&&d('"transport="')),null!==a?("udp"===b.substr(oe,3).toLowerCase()?(c=b.substr(oe,3),oe+=3):(c=null,0===pe&&d('"udp"')),null===c&&("tcp"===b.substr(oe,3).toLowerCase()?(c=b.substr(oe,3),oe+=3):(c=null,0===pe&&d('"tcp"')),null===c&&("sctp"===b.substr(oe,4).toLowerCase()?(c=b.substr(oe,4),oe+=4):(c=null,0===pe&&d('"sctp"')),null===c&&("tls"===b.substr(oe,3).toLowerCase()?(c=b.substr(oe,3),oe+=3):(c=null,0===pe&&d('"tls"')),null===c&&(c=A())))),null!==c?a=[a,c]:(a=null,oe=f)):(a=null,oe=f),null!==a&&(a=function(a,b){se.uri_params||(se.uri_params={}),se.uri_params.transport=b.toLowerCase() }(e,a[1])),null===a&&(oe=e),a}function qb(){var a,c,e,f;return e=oe,f=oe,"user="===b.substr(oe,5).toLowerCase()?(a=b.substr(oe,5),oe+=5):(a=null,0===pe&&d('"user="')),null!==a?("phone"===b.substr(oe,5).toLowerCase()?(c=b.substr(oe,5),oe+=5):(c=null,0===pe&&d('"phone"')),null===c&&("ip"===b.substr(oe,2).toLowerCase()?(c=b.substr(oe,2),oe+=2):(c=null,0===pe&&d('"ip"')),null===c&&(c=A())),null!==c?a=[a,c]:(a=null,oe=f)):(a=null,oe=f),null!==a&&(a=function(a,b){se.uri_params||(se.uri_params={}),se.uri_params.user=b.toLowerCase()}(e,a[1])),null===a&&(oe=e),a}function rb(){var a,c,e,f;return e=oe,f=oe,"method="===b.substr(oe,7).toLowerCase()?(a=b.substr(oe,7),oe+=7):(a=null,0===pe&&d('"method="')),null!==a?(c=hc(),null!==c?a=[a,c]:(a=null,oe=f)):(a=null,oe=f),null!==a&&(a=function(a,b){se.uri_params||(se.uri_params={}),se.uri_params.method=b}(e,a[1])),null===a&&(oe=e),a}function sb(){var a,c,e,f;return e=oe,f=oe,"ttl="===b.substr(oe,4).toLowerCase()?(a=b.substr(oe,4),oe+=4):(a=null,0===pe&&d('"ttl="')),null!==a?(c=Ud(),null!==c?a=[a,c]:(a=null,oe=f)):(a=null,oe=f),null!==a&&(a=function(a,b){se.params||(se.params={}),se.params.ttl=b}(e,a[1])),null===a&&(oe=e),a}function tb(){var a,c,e,f;return e=oe,f=oe,"maddr="===b.substr(oe,6).toLowerCase()?(a=b.substr(oe,6),oe+=6):(a=null,0===pe&&d('"maddr="')),null!==a?(c=cb(),null!==c?a=[a,c]:(a=null,oe=f)):(a=null,oe=f),null!==a&&(a=function(a,b){se.uri_params||(se.uri_params={}),se.uri_params.maddr=b}(e,a[1])),null===a&&(oe=e),a}function ub(){var a,c,e,f,g,h;return f=oe,g=oe,"lr"===b.substr(oe,2).toLowerCase()?(a=b.substr(oe,2),oe+=2):(a=null,0===pe&&d('"lr"')),null!==a?(h=oe,61===b.charCodeAt(oe)?(c="=",oe++):(c=null,0===pe&&d('"="')),null!==c?(e=A(),null!==e?c=[c,e]:(c=null,oe=h)):(c=null,oe=h),c=null!==c?c:"",null!==c?a=[a,c]:(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(){se.uri_params||(se.uri_params={}),se.uri_params.lr=void 0}(f)),null===a&&(oe=f),a}function vb(){var a,c,e,f,g,h;return f=oe,g=oe,a=wb(),null!==a?(h=oe,61===b.charCodeAt(oe)?(c="=",oe++):(c=null,0===pe&&d('"="')),null!==c?(e=xb(),null!==e?c=[c,e]:(c=null,oe=h)):(c=null,oe=h),c=null!==c?c:"",null!==c?a=[a,c]:(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(a,b,c){se.uri_params||(se.uri_params={}),c="undefined"==typeof c?void 0:c[1],se.uri_params[b.toLowerCase()]=c&&c.toLowerCase()}(f,a[0],a[1])),null===a&&(oe=f),a}function wb(){var a,b,c;if(c=oe,b=yb(),null!==b)for(a=[];null!==b;)a.push(b),b=yb();else a=null;return null!==a&&(a=function(a,b){return b.join("")}(c,a)),null===a&&(oe=c),a}function xb(){var a,b,c;if(c=oe,b=yb(),null!==b)for(a=[];null!==b;)a.push(b),b=yb();else a=null;return null!==a&&(a=function(a,b){return b.join("")}(c,a)),null===a&&(oe=c),a}function yb(){var a;return a=zb(),null===a&&(a=p(),null===a&&(a=r())),a}function zb(){var a;return 91===b.charCodeAt(oe)?(a="[",oe++):(a=null,0===pe&&d('"["')),null===a&&(93===b.charCodeAt(oe)?(a="]",oe++):(a=null,0===pe&&d('"]"')),null===a&&(47===b.charCodeAt(oe)?(a="/",oe++):(a=null,0===pe&&d('"/"')),null===a&&(58===b.charCodeAt(oe)?(a=":",oe++):(a=null,0===pe&&d('":"')),null===a&&(38===b.charCodeAt(oe)?(a="&",oe++):(a=null,0===pe&&d('"&"')),null===a&&(43===b.charCodeAt(oe)?(a="+",oe++):(a=null,0===pe&&d('"+"')),null===a&&(36===b.charCodeAt(oe)?(a="$",oe++):(a=null,0===pe&&d('"$"')))))))),a}function Ab(){var a,c,e,f,g,h,i;if(h=oe,63===b.charCodeAt(oe)?(a="?",oe++):(a=null,0===pe&&d('"?"')),null!==a)if(c=Bb(),null!==c){for(e=[],i=oe,38===b.charCodeAt(oe)?(f="&",oe++):(f=null,0===pe&&d('"&"')),null!==f?(g=Bb(),null!==g?f=[f,g]:(f=null,oe=i)):(f=null,oe=i);null!==f;)e.push(f),i=oe,38===b.charCodeAt(oe)?(f="&",oe++):(f=null,0===pe&&d('"&"')),null!==f?(g=Bb(),null!==g?f=[f,g]:(f=null,oe=i)):(f=null,oe=i);null!==e?a=[a,c,e]:(a=null,oe=h)}else a=null,oe=h;else a=null,oe=h;return a}function Bb(){var a,c,e,f,g;return f=oe,g=oe,a=Cb(),null!==a?(61===b.charCodeAt(oe)?(c="=",oe++):(c=null,0===pe&&d('"="')),null!==c?(e=Db(),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(a,b,c){b=b.join("").toLowerCase(),c=c.join(""),se.uri_headers||(se.uri_headers={}),se.uri_headers[b]?se.uri_headers[b].push(c):se.uri_headers[b]=[c]}(f,a[0],a[2])),null===a&&(oe=f),a}function Cb(){var a,b;if(b=Eb(),null===b&&(b=p(),null===b&&(b=r())),null!==b)for(a=[];null!==b;)a.push(b),b=Eb(),null===b&&(b=p(),null===b&&(b=r()));else a=null;return a}function Db(){var a,b;for(a=[],b=Eb(),null===b&&(b=p(),null===b&&(b=r()));null!==b;)a.push(b),b=Eb(),null===b&&(b=p(),null===b&&(b=r()));return a}function Eb(){var a;return 91===b.charCodeAt(oe)?(a="[",oe++):(a=null,0===pe&&d('"["')),null===a&&(93===b.charCodeAt(oe)?(a="]",oe++):(a=null,0===pe&&d('"]"')),null===a&&(47===b.charCodeAt(oe)?(a="/",oe++):(a=null,0===pe&&d('"/"')),null===a&&(63===b.charCodeAt(oe)?(a="?",oe++):(a=null,0===pe&&d('"?"')),null===a&&(58===b.charCodeAt(oe)?(a=":",oe++):(a=null,0===pe&&d('":"')),null===a&&(43===b.charCodeAt(oe)?(a="+",oe++):(a=null,0===pe&&d('"+"')),null===a&&(36===b.charCodeAt(oe)?(a="$",oe++):(a=null,0===pe&&d('"$"')))))))),a}function Fb(){var a;return a=ic(),null===a&&(a=Gb()),a}function Gb(){var a,b,c,d,e,f;return f=oe,a=hc(),null!==a?(b=l(),null!==b?(c=Hb(),null!==c?(d=l(),null!==d?(e=Yb(),null!==e?a=[a,b,c,d,e]:(a=null,oe=f)):(a=null,oe=f)):(a=null,oe=f)):(a=null,oe=f)):(a=null,oe=f),a}function Hb(){var a;return a=X(),null===a&&(a=Ib()),a}function Ib(){var a,c,e,f;return f=oe,a=Tb(),null!==a?(58===b.charCodeAt(oe)?(c=":",oe++):(c=null,0===pe&&d('":"')),null!==c?(e=Jb(),null===e&&(e=Mb()),null!==e?a=[a,c,e]:(a=null,oe=f)):(a=null,oe=f)):(a=null,oe=f),a}function Jb(){var a,c,e,f,g;return f=oe,a=Kb(),null===a&&(a=Lb()),null!==a?(g=oe,63===b.charCodeAt(oe)?(c="?",oe++):(c=null,0===pe&&d('"?"')),null!==c?(e=Xb(),null!==e?c=[c,e]:(c=null,oe=g)):(c=null,oe=g),c=null!==c?c:"",null!==c?a=[a,c]:(a=null,oe=f)):(a=null,oe=f),a}function Kb(){var a,c,e,f;return f=oe,"//"===b.substr(oe,2)?(a="//",oe+=2):(a=null,0===pe&&d('"//"')),null!==a?(c=Ub(),null!==c?(e=Lb(),e=null!==e?e:"",null!==e?a=[a,c,e]:(a=null,oe=f)):(a=null,oe=f)):(a=null,oe=f),a}function Lb(){var a,c,e;return e=oe,47===b.charCodeAt(oe)?(a="/",oe++):(a=null,0===pe&&d('"/"')),null!==a?(c=Pb(),null!==c?a=[a,c]:(a=null,oe=e)):(a=null,oe=e),a}function Mb(){var a,b,c,d;if(d=oe,a=Ob(),null!==a){for(b=[],c=Nb();null!==c;)b.push(c),c=Nb();null!==b?a=[a,b]:(a=null,oe=d)}else a=null,oe=d;return a}function Nb(){var a;return a=o(),null===a&&(a=p(),null===a&&(a=r())),a}function Ob(){var a;return a=p(),null===a&&(a=r(),null===a&&(59===b.charCodeAt(oe)?(a=";",oe++):(a=null,0===pe&&d('";"')),null===a&&(63===b.charCodeAt(oe)?(a="?",oe++):(a=null,0===pe&&d('"?"')),null===a&&(58===b.charCodeAt(oe)?(a=":",oe++):(a=null,0===pe&&d('":"')),null===a&&(64===b.charCodeAt(oe)?(a="@",oe++):(a=null,0===pe&&d('"@"')),null===a&&(38===b.charCodeAt(oe)?(a="&",oe++):(a=null,0===pe&&d('"&"')),null===a&&(61===b.charCodeAt(oe)?(a="=",oe++):(a=null,0===pe&&d('"="')),null===a&&(43===b.charCodeAt(oe)?(a="+",oe++):(a=null,0===pe&&d('"+"')),null===a&&(36===b.charCodeAt(oe)?(a="$",oe++):(a=null,0===pe&&d('"$"')),null===a&&(44===b.charCodeAt(oe)?(a=",",oe++):(a=null,0===pe&&d('","')))))))))))),a}function Pb(){var a,c,e,f,g,h;if(g=oe,a=Qb(),null!==a){for(c=[],h=oe,47===b.charCodeAt(oe)?(e="/",oe++):(e=null,0===pe&&d('"/"')),null!==e?(f=Qb(),null!==f?e=[e,f]:(e=null,oe=h)):(e=null,oe=h);null!==e;)c.push(e),h=oe,47===b.charCodeAt(oe)?(e="/",oe++):(e=null,0===pe&&d('"/"')),null!==e?(f=Qb(),null!==f?e=[e,f]:(e=null,oe=h)):(e=null,oe=h);null!==c?a=[a,c]:(a=null,oe=g)}else a=null,oe=g;return a}function Qb(){var a,c,e,f,g,h;for(g=oe,a=[],c=Sb();null!==c;)a.push(c),c=Sb();if(null!==a){for(c=[],h=oe,59===b.charCodeAt(oe)?(e=";",oe++):(e=null,0===pe&&d('";"')),null!==e?(f=Rb(),null!==f?e=[e,f]:(e=null,oe=h)):(e=null,oe=h);null!==e;)c.push(e),h=oe,59===b.charCodeAt(oe)?(e=";",oe++):(e=null,0===pe&&d('";"')),null!==e?(f=Rb(),null!==f?e=[e,f]:(e=null,oe=h)):(e=null,oe=h);null!==c?a=[a,c]:(a=null,oe=g)}else a=null,oe=g;return a}function Rb(){var a,b;for(a=[],b=Sb();null!==b;)a.push(b),b=Sb();return a}function Sb(){var a;return a=p(),null===a&&(a=r(),null===a&&(58===b.charCodeAt(oe)?(a=":",oe++):(a=null,0===pe&&d('":"')),null===a&&(64===b.charCodeAt(oe)?(a="@",oe++):(a=null,0===pe&&d('"@"')),null===a&&(38===b.charCodeAt(oe)?(a="&",oe++):(a=null,0===pe&&d('"&"')),null===a&&(61===b.charCodeAt(oe)?(a="=",oe++):(a=null,0===pe&&d('"="')),null===a&&(43===b.charCodeAt(oe)?(a="+",oe++):(a=null,0===pe&&d('"+"')),null===a&&(36===b.charCodeAt(oe)?(a="$",oe++):(a=null,0===pe&&d('"$"')),null===a&&(44===b.charCodeAt(oe)?(a=",",oe++):(a=null,0===pe&&d('","')))))))))),a}function Tb(){var a,c,e,h,i;if(h=oe,i=oe,a=g(),null!==a){for(c=[],e=g(),null===e&&(e=f(),null===e&&(43===b.charCodeAt(oe)?(e="+",oe++):(e=null,0===pe&&d('"+"')),null===e&&(45===b.charCodeAt(oe)?(e="-",oe++):(e=null,0===pe&&d('"-"')),null===e&&(46===b.charCodeAt(oe)?(e=".",oe++):(e=null,0===pe&&d('"."'))))));null!==e;)c.push(e),e=g(),null===e&&(e=f(),null===e&&(43===b.charCodeAt(oe)?(e="+",oe++):(e=null,0===pe&&d('"+"')),null===e&&(45===b.charCodeAt(oe)?(e="-",oe++):(e=null,0===pe&&d('"-"')),null===e&&(46===b.charCodeAt(oe)?(e=".",oe++):(e=null,0===pe&&d('"."'))))));null!==c?a=[a,c]:(a=null,oe=i)}else a=null,oe=i;return null!==a&&(a=function(a){se.scheme=b.substring(oe,a)}(h)),null===a&&(oe=h),a}function Ub(){var a;return a=Vb(),null===a&&(a=Wb()),a}function Vb(){var a,c,e,f;return e=oe,f=oe,a=Z(),null!==a?(64===b.charCodeAt(oe)?(c="@",oe++):(c=null,0===pe&&d('"@"')),null!==c?a=[a,c]:(a=null,oe=f)):(a=null,oe=f),a=null!==a?a:"",null!==a?(c=bb(),null!==c?a=[a,c]:(a=null,oe=e)):(a=null,oe=e),a=null!==a?a:""}function Wb(){var a,c;if(c=p(),null===c&&(c=r(),null===c&&(36===b.charCodeAt(oe)?(c="$",oe++):(c=null,0===pe&&d('"$"')),null===c&&(44===b.charCodeAt(oe)?(c=",",oe++):(c=null,0===pe&&d('","')),null===c&&(59===b.charCodeAt(oe)?(c=";",oe++):(c=null,0===pe&&d('";"')),null===c&&(58===b.charCodeAt(oe)?(c=":",oe++):(c=null,0===pe&&d('":"')),null===c&&(64===b.charCodeAt(oe)?(c="@",oe++):(c=null,0===pe&&d('"@"')),null===c&&(38===b.charCodeAt(oe)?(c="&",oe++):(c=null,0===pe&&d('"&"')),null===c&&(61===b.charCodeAt(oe)?(c="=",oe++):(c=null,0===pe&&d('"="')),null===c&&(43===b.charCodeAt(oe)?(c="+",oe++):(c=null,0===pe&&d('"+"'))))))))))),null!==c)for(a=[];null!==c;)a.push(c),c=p(),null===c&&(c=r(),null===c&&(36===b.charCodeAt(oe)?(c="$",oe++):(c=null,0===pe&&d('"$"')),null===c&&(44===b.charCodeAt(oe)?(c=",",oe++):(c=null,0===pe&&d('","')),null===c&&(59===b.charCodeAt(oe)?(c=";",oe++):(c=null,0===pe&&d('";"')),null===c&&(58===b.charCodeAt(oe)?(c=":",oe++):(c=null,0===pe&&d('":"')),null===c&&(64===b.charCodeAt(oe)?(c="@",oe++):(c=null,0===pe&&d('"@"')),null===c&&(38===b.charCodeAt(oe)?(c="&",oe++):(c=null,0===pe&&d('"&"')),null===c&&(61===b.charCodeAt(oe)?(c="=",oe++):(c=null,0===pe&&d('"="')),null===c&&(43===b.charCodeAt(oe)?(c="+",oe++):(c=null,0===pe&&d('"+"')))))))))));else a=null;return a}function Xb(){var a,b;for(a=[],b=Nb();null!==b;)a.push(b),b=Nb();return a}function Yb(){var a,c,e,g,h,i,j,k;if(j=oe,k=oe,"sip"===b.substr(oe,3).toLowerCase()?(a=b.substr(oe,3),oe+=3):(a=null,0===pe&&d('"SIP"')),null!==a)if(47===b.charCodeAt(oe)?(c="/",oe++):(c=null,0===pe&&d('"/"')),null!==c){if(g=f(),null!==g)for(e=[];null!==g;)e.push(g),g=f();else e=null;if(null!==e)if(46===b.charCodeAt(oe)?(g=".",oe++):(g=null,0===pe&&d('"."')),null!==g){if(i=f(),null!==i)for(h=[];null!==i;)h.push(i),i=f();else h=null;null!==h?a=[a,c,e,g,h]:(a=null,oe=k)}else a=null,oe=k;else a=null,oe=k}else a=null,oe=k;else a=null,oe=k;return null!==a&&(a=function(a){se.sip_version=b.substring(oe,a)}(j)),null===a&&(oe=j),a}function Zb(){var a;return"INVITE"===b.substr(oe,6)?(a="INVITE",oe+=6):(a=null,0===pe&&d('"INVITE"')),a}function $b(){var a;return"ACK"===b.substr(oe,3)?(a="ACK",oe+=3):(a=null,0===pe&&d('"ACK"')),a}function _b(){var a;return"VXACH"===b.substr(oe,5)?(a="VXACH",oe+=5):(a=null,0===pe&&d('"VXACH"')),a}function ac(){var a;return"OPTIONS"===b.substr(oe,7)?(a="OPTIONS",oe+=7):(a=null,0===pe&&d('"OPTIONS"')),a}function bc(){var a;return"BYE"===b.substr(oe,3)?(a="BYE",oe+=3):(a=null,0===pe&&d('"BYE"')),a}function cc(){var a;return"CANCEL"===b.substr(oe,6)?(a="CANCEL",oe+=6):(a=null,0===pe&&d('"CANCEL"')),a}function dc(){var a;return"REGISTER"===b.substr(oe,8)?(a="REGISTER",oe+=8):(a=null,0===pe&&d('"REGISTER"')),a}function ec(){var a;return"SUBSCRIBE"===b.substr(oe,9)?(a="SUBSCRIBE",oe+=9):(a=null,0===pe&&d('"SUBSCRIBE"')),a}function fc(){var a;return"NOTIFY"===b.substr(oe,6)?(a="NOTIFY",oe+=6):(a=null,0===pe&&d('"NOTIFY"')),a}function gc(){var a;return"REFER"===b.substr(oe,5)?(a="REFER",oe+=5):(a=null,0===pe&&d('"REFER"')),a}function hc(){var a,c;return c=oe,a=Zb(),null===a&&(a=$b(),null===a&&(a=ac(),null===a&&(a=bc(),null===a&&(a=cc(),null===a&&(a=dc(),null===a&&(a=ec(),null===a&&(a=fc(),null===a&&(a=gc(),null===a&&(a=A()))))))))),null!==a&&(a=function(a){return se.method=b.substring(oe,a),se.method}(c)),null===a&&(oe=c),a}function ic(){var a,b,c,d,e,f;return f=oe,a=Yb(),null!==a?(b=l(),null!==b?(c=jc(),null!==c?(d=l(),null!==d?(e=lc(),null!==e?a=[a,b,c,d,e]:(a=null,oe=f)):(a=null,oe=f)):(a=null,oe=f)):(a=null,oe=f)):(a=null,oe=f),a}function jc(){var a,b;return b=oe,a=kc(),null!==a&&(a=function(a,b){se.status_code=parseInt(b.join(""))}(b,a)),null===a&&(oe=b),a}function kc(){var a,b,c,d;return d=oe,a=f(),null!==a?(b=f(),null!==b?(c=f(),null!==c?a=[a,b,c]:(a=null,oe=d)):(a=null,oe=d)):(a=null,oe=d),a}function lc(){var a,c,d;for(d=oe,a=[],c=o(),null===c&&(c=p(),null===c&&(c=r(),null===c&&(c=x(),null===c&&(c=y(),null===c&&(c=l(),null===c&&(c=m()))))));null!==c;)a.push(c),c=o(),null===c&&(c=p(),null===c&&(c=r(),null===c&&(c=x(),null===c&&(c=y(),null===c&&(c=l(),null===c&&(c=m()))))));return null!==a&&(a=function(a){se.reason_phrase=b.substring(oe,a)}(d)),null===a&&(oe=d),a}function mc(){var a,b,c,d,e,f;if(e=oe,a=Tc(),null!==a){for(b=[],f=oe,c=L(),null!==c?(d=Tc(),null!==d?c=[c,d]:(c=null,oe=f)):(c=null,oe=f);null!==c;)b.push(c),f=oe,c=L(),null!==c?(d=Tc(),null!==d?c=[c,d]:(c=null,oe=f)):(c=null,oe=f);null!==b?a=[a,b]:(a=null,oe=e)}else a=null,oe=e;return a}function nc(){var a,c,e,f,g,h;return f=oe,g=oe,a=D(),null!==a?(h=oe,64===b.charCodeAt(oe)?(c="@",oe++):(c=null,0===pe&&d('"@"')),null!==c?(e=D(),null!==e?c=[c,e]:(c=null,oe=h)):(c=null,oe=h),c=null!==c?c:"",null!==c?a=[a,c]:(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(a){se=b.substring(oe,a)}(f)),null===a&&(oe=f),a}function oc(){var a,b,c,d,e,f,g;if(e=oe,a=E(),null===a)if(f=oe,a=pc(),null!==a){for(b=[],g=oe,c=L(),null!==c?(d=pc(),null!==d?c=[c,d]:(c=null,oe=g)):(c=null,oe=g);null!==c;)b.push(c),g=oe,c=L(),null!==c?(d=pc(),null!==d?c=[c,d]:(c=null,oe=g)):(c=null,oe=g);null!==b?a=[a,b]:(a=null,oe=f)}else a=null,oe=f;return null!==a&&(a=function(){var a,b;for(b=se.multi_header.length,a=0;b>a;a++)if(null===se.multi_header[a].parsed){se=null;break}se=null!==se?se.multi_header:-1}(e)),null===a&&(oe=e),a}function pc(){var a,b,c,d,e,f,g;if(e=oe,f=oe,a=W(),null===a&&(a=qc()),null!==a){for(b=[],g=oe,c=M(),null!==c?(d=sc(),null!==d?c=[c,d]:(c=null,oe=g)):(c=null,oe=g);null!==c;)b.push(c),g=oe,c=M(),null!==c?(d=sc(),null!==d?c=[c,d]:(c=null,oe=g)):(c=null,oe=g);null!==b?a=[a,b]:(a=null,oe=f)}else a=null,oe=f;return null!==a&&(a=function(a){var b;se.multi_header||(se.multi_header=[]);try{b=new SIP.NameAddrHeader(se.uri,se.displayName,se.params),delete se.uri,delete se.displayName,delete se.params}catch(c){b=null}se.multi_header.push({possition:oe,offset:a,parsed:b})}(e)),null===a&&(oe=e),a}function qc(){var a,b,c,d,e;return e=oe,a=rc(),a=null!==a?a:"",null!==a?(b=K(),null!==b?(c=X(),null!==c?(d=J(),null!==d?a=[a,b,c,d]:(a=null,oe=e)):(a=null,oe=e)):(a=null,oe=e)):(a=null,oe=e),a}function rc(){var a,c,d,e,f,g,h;if(f=oe,g=oe,a=A(),null!==a){for(c=[],h=oe,d=s(),null!==d?(e=A(),null!==e?d=[d,e]:(d=null,oe=h)):(d=null,oe=h);null!==d;)c.push(d),h=oe,d=s(),null!==d?(e=A(),null!==e?d=[d,e]:(d=null,oe=h)):(d=null,oe=h);null!==c?a=[a,c]:(a=null,oe=g)}else a=null,oe=g;return null===a&&(a=S()),null!==a&&(a=function(a,c){c=b.substring(oe,a).trim(),'"'===c[0]&&(c=c.substring(1,c.length-1)),se.displayName=c}(f,a)),null===a&&(oe=f),a}function sc(){var a;return a=tc(),null===a&&(a=uc(),null===a&&(a=xc())),a}function tc(){var a,c,e,f,g;return f=oe,g=oe,"q"===b.substr(oe,1).toLowerCase()?(a=b.substr(oe,1),oe++):(a=null,0===pe&&d('"q"')),null!==a?(c=G(),null!==c?(e=wc(),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(a,b){se.params||(se.params={}),se.params.q=b}(f,a[2])),null===a&&(oe=f),a}function uc(){var a,c,e,f,g;return f=oe,g=oe,"expires"===b.substr(oe,7).toLowerCase()?(a=b.substr(oe,7),oe+=7):(a=null,0===pe&&d('"expires"')),null!==a?(c=G(),null!==c?(e=vc(),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(a,b){se.params||(se.params={}),se.params.expires=b}(f,a[2])),null===a&&(oe=f),a}function vc(){var a,b,c;if(c=oe,b=f(),null!==b)for(a=[];null!==b;)a.push(b),b=f();else a=null;return null!==a&&(a=function(a,b){return parseInt(b.join(""))}(c,a)),null===a&&(oe=c),a}function wc(){var a,c,e,g,h,i,j,k;return i=oe,j=oe,48===b.charCodeAt(oe)?(a="0",oe++):(a=null,0===pe&&d('"0"')),null!==a?(k=oe,46===b.charCodeAt(oe)?(c=".",oe++):(c=null,0===pe&&d('"."')),null!==c?(e=f(),e=null!==e?e:"",null!==e?(g=f(),g=null!==g?g:"",null!==g?(h=f(),h=null!==h?h:"",null!==h?c=[c,e,g,h]:(c=null,oe=k)):(c=null,oe=k)):(c=null,oe=k)):(c=null,oe=k),c=null!==c?c:"",null!==c?a=[a,c]:(a=null,oe=j)):(a=null,oe=j),null!==a&&(a=function(a){return parseFloat(b.substring(oe,a))}(i)),null===a&&(oe=i),a}function xc(){var a,b,c,d,e,f;return d=oe,e=oe,a=A(),null!==a?(f=oe,b=G(),null!==b?(c=yc(),null!==c?b=[b,c]:(b=null,oe=f)):(b=null,oe=f),b=null!==b?b:"",null!==b?a=[a,b]:(a=null,oe=e)):(a=null,oe=e),null!==a&&(a=function(a,b,c){se.params||(se.params={}),c="undefined"==typeof c?void 0:c[1],se.params[b.toLowerCase()]=c}(d,a[0],a[1])),null===a&&(oe=d),a}function yc(){var a;return a=A(),null===a&&(a=cb(),null===a&&(a=S())),a}function zc(){var a,b,c,d,e,f;if(e=oe,a=Ac(),null!==a){for(b=[],f=oe,c=M(),null!==c?(d=Bc(),null!==d?c=[c,d]:(c=null,oe=f)):(c=null,oe=f);null!==c;)b.push(c),f=oe,c=M(),null!==c?(d=Bc(),null!==d?c=[c,d]:(c=null,oe=f)):(c=null,oe=f);null!==b?a=[a,b]:(a=null,oe=e)}else a=null,oe=e;return a}function Ac(){var a;return"render"===b.substr(oe,6).toLowerCase()?(a=b.substr(oe,6),oe+=6):(a=null,0===pe&&d('"render"')),null===a&&("session"===b.substr(oe,7).toLowerCase()?(a=b.substr(oe,7),oe+=7):(a=null,0===pe&&d('"session"')),null===a&&("icon"===b.substr(oe,4).toLowerCase()?(a=b.substr(oe,4),oe+=4):(a=null,0===pe&&d('"icon"')),null===a&&("alert"===b.substr(oe,5).toLowerCase()?(a=b.substr(oe,5),oe+=5):(a=null,0===pe&&d('"alert"')),null===a&&(a=A())))),a}function Bc(){var a;return a=Cc(),null===a&&(a=xc()),a}function Cc(){var a,c,e,f;return f=oe,"handling"===b.substr(oe,8).toLowerCase()?(a=b.substr(oe,8),oe+=8):(a=null,0===pe&&d('"handling"')),null!==a?(c=G(),null!==c?("optional"===b.substr(oe,8).toLowerCase()?(e=b.substr(oe,8),oe+=8):(e=null,0===pe&&d('"optional"')),null===e&&("required"===b.substr(oe,8).toLowerCase()?(e=b.substr(oe,8),oe+=8):(e=null,0===pe&&d('"required"')),null===e&&(e=A())),null!==e?a=[a,c,e]:(a=null,oe=f)):(a=null,oe=f)):(a=null,oe=f),a}function Dc(){var a,b,c,d,e,f;if(e=oe,a=A(),null!==a){for(b=[],f=oe,c=L(),null!==c?(d=A(),null!==d?c=[c,d]:(c=null,oe=f)):(c=null,oe=f);null!==c;)b.push(c),f=oe,c=L(),null!==c?(d=A(),null!==d?c=[c,d]:(c=null,oe=f)):(c=null,oe=f);null!==b?a=[a,b]:(a=null,oe=e)}else a=null,oe=e;return a}function Ec(){var a,b,c;if(c=oe,b=f(),null!==b)for(a=[];null!==b;)a.push(b),b=f();else a=null;return null!==a&&(a=function(a,b){se=parseInt(b.join(""))}(c,a)),null===a&&(oe=c),a}function Fc(){var a,c;return c=oe,a=Gc(),null!==a&&(a=function(a){se=b.substring(oe,a)}(c)),null===a&&(oe=c),a}function Gc(){var a,b,c,d,e,f,g,h;if(g=oe,a=Hc(),null!==a)if(b=F(),null!==b)if(c=Mc(),null!==c){for(d=[],h=oe,e=M(),null!==e?(f=Nc(),null!==f?e=[e,f]:(e=null,oe=h)):(e=null,oe=h);null!==e;)d.push(e),h=oe,e=M(),null!==e?(f=Nc(),null!==f?e=[e,f]:(e=null,oe=h)):(e=null,oe=h);null!==d?a=[a,b,c,d]:(a=null,oe=g)}else a=null,oe=g;else a=null,oe=g;else a=null,oe=g;return a}function Hc(){var a;return a=Ic(),null===a&&(a=Jc()),a}function Ic(){var a;return"text"===b.substr(oe,4).toLowerCase()?(a=b.substr(oe,4),oe+=4):(a=null,0===pe&&d('"text"')),null===a&&("image"===b.substr(oe,5).toLowerCase()?(a=b.substr(oe,5),oe+=5):(a=null,0===pe&&d('"image"')),null===a&&("audio"===b.substr(oe,5).toLowerCase()?(a=b.substr(oe,5),oe+=5):(a=null,0===pe&&d('"audio"')),null===a&&("video"===b.substr(oe,5).toLowerCase()?(a=b.substr(oe,5),oe+=5):(a=null,0===pe&&d('"video"')),null===a&&("application"===b.substr(oe,11).toLowerCase()?(a=b.substr(oe,11),oe+=11):(a=null,0===pe&&d('"application"')),null===a&&(a=Kc()))))),a}function Jc(){var a;return"message"===b.substr(oe,7).toLowerCase()?(a=b.substr(oe,7),oe+=7):(a=null,0===pe&&d('"message"')),null===a&&("multipart"===b.substr(oe,9).toLowerCase()?(a=b.substr(oe,9),oe+=9):(a=null,0===pe&&d('"multipart"')),null===a&&(a=Kc())),a}function Kc(){var a;return a=A(),null===a&&(a=Lc()),a}function Lc(){var a,c,e;return e=oe,"x-"===b.substr(oe,2).toLowerCase()?(a=b.substr(oe,2),oe+=2):(a=null,0===pe&&d('"x-"')),null!==a?(c=A(),null!==c?a=[a,c]:(a=null,oe=e)):(a=null,oe=e),a}function Mc(){var a;return a=Kc(),null===a&&(a=A()),a}function Nc(){var a,b,c,d;return d=oe,a=A(),null!==a?(b=G(),null!==b?(c=Oc(),null!==c?a=[a,b,c]:(a=null,oe=d)):(a=null,oe=d)):(a=null,oe=d),a}function Oc(){var a;return a=A(),null===a&&(a=S()),a}function Pc(){var a,b,c,d;return d=oe,a=Qc(),null!==a?(b=s(),null!==b?(c=hc(),null!==c?a=[a,b,c]:(a=null,oe=d)):(a=null,oe=d)):(a=null,oe=d),a}function Qc(){var a,b,c;if(c=oe,b=f(),null!==b)for(a=[];null!==b;)a.push(b),b=f();else a=null;return null!==a&&(a=function(a,b){se.value=parseInt(b.join(""))}(c,a)),null===a&&(oe=c),a}function Rc(){var a,b;return b=oe,a=vc(),null!==a&&(a=function(a,b){se=b}(b,a)),null===a&&(oe=b),a}function Sc(){var a,b,c,d,e,f,g;if(e=oe,f=oe,a=Tc(),null!==a){for(b=[],g=oe,c=M(),null!==c?(d=xc(),null!==d?c=[c,d]:(c=null,oe=g)):(c=null,oe=g);null!==c;)b.push(c),g=oe,c=M(),null!==c?(d=xc(),null!==d?c=[c,d]:(c=null,oe=g)):(c=null,oe=g);null!==b?a=[a,b]:(a=null,oe=f)}else a=null,oe=f;return null!==a&&(a=function(a,b){se.event=b.join("").toLowerCase()}(e,a[0])),null===a&&(oe=e),a}function Tc(){var a,c,e,f,g,h;if(g=oe,a=B(),null!==a){for(c=[],h=oe,46===b.charCodeAt(oe)?(e=".",oe++):(e=null,0===pe&&d('"."')),null!==e?(f=B(),null!==f?e=[e,f]:(e=null,oe=h)):(e=null,oe=h);null!==e;)c.push(e),h=oe,46===b.charCodeAt(oe)?(e=".",oe++):(e=null,0===pe&&d('"."')),null!==e?(f=B(),null!==f?e=[e,f]:(e=null,oe=h)):(e=null,oe=h);null!==c?a=[a,c]:(a=null,oe=g)}else a=null,oe=g;return a}function Uc(){var a,b,c,d,e,f,g;if(e=oe,f=oe,a=W(),null===a&&(a=qc()),null!==a){for(b=[],g=oe,c=M(),null!==c?(d=Vc(),null!==d?c=[c,d]:(c=null,oe=g)):(c=null,oe=g);null!==c;)b.push(c),g=oe,c=M(),null!==c?(d=Vc(),null!==d?c=[c,d]:(c=null,oe=g)):(c=null,oe=g);null!==b?a=[a,b]:(a=null,oe=f)}else a=null,oe=f;return null!==a&&(a=function(){var a=se.tag;try{se=new SIP.NameAddrHeader(se.uri,se.displayName,se.params),a&&se.setParam("tag",a)}catch(b){se=-1}}(e)),null===a&&(oe=e),a}function Vc(){var a;return a=Wc(),null===a&&(a=xc()),a}function Wc(){var a,c,e,f,g;return f=oe,g=oe,"tag"===b.substr(oe,3).toLowerCase()?(a=b.substr(oe,3),oe+=3):(a=null,0===pe&&d('"tag"')),null!==a?(c=G(),null!==c?(e=A(),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(a,b){se.tag=b}(f,a[2])),null===a&&(oe=f),a}function Xc(){var a,b,c;if(c=oe,b=f(),null!==b)for(a=[];null!==b;)a.push(b),b=f();else a=null;return null!==a&&(a=function(a,b){se=parseInt(b.join(""))}(c,a)),null===a&&(oe=c),a}function Yc(){var a,b;return b=oe,a=vc(),null!==a&&(a=function(a,b){se=b}(b,a)),null===a&&(oe=b),a}function Zc(){var a,b,c,d,e,f,g,h,i,j;for(h=oe,i=oe,a=[],b=rc();null!==b;)a.push(b),b=rc();if(null!==a)if(b=K(),null!==b)if(c=X(),null!==c)if(d=J(),null!==d){for(e=[],j=oe,f=M(),null!==f?(g=xc(),null!==g?f=[f,g]:(f=null,oe=j)):(f=null,oe=j);null!==f;)e.push(f),j=oe,f=M(),null!==f?(g=xc(),null!==g?f=[f,g]:(f=null,oe=j)):(f=null,oe=j);null!==e?a=[a,b,c,d,e]:(a=null,oe=i)}else a=null,oe=i;else a=null,oe=i;else a=null,oe=i;else a=null,oe=i;return null!==a&&(a=function(){try{se=new SIP.NameAddrHeader(se.uri,se.displayName,se.params)}catch(a){se=-1}}(h)),null===a&&(oe=h),a}function $c(){var a;return a=_c()}function _c(){var a,c,e,f,g,h,i,j;if(i=oe,"digest"===b.substr(oe,6).toLowerCase()?(a=b.substr(oe,6),oe+=6):(a=null,0===pe&&d('"Digest"')),null!==a)if(c=s(),null!==c)if(e=cd(),null!==e){for(f=[],j=oe,g=L(),null!==g?(h=cd(),null!==h?g=[g,h]:(g=null,oe=j)):(g=null,oe=j);null!==g;)f.push(g),j=oe,g=L(),null!==g?(h=cd(),null!==h?g=[g,h]:(g=null,oe=j)):(g=null,oe=j);null!==f?a=[a,c,e,f]:(a=null,oe=i)}else a=null,oe=i;else a=null,oe=i;else a=null,oe=i;return null===a&&(a=ad()),a}function ad(){var a,b,c,d,e,f,g,h;if(g=oe,a=A(),null!==a)if(b=s(),null!==b)if(c=bd(),null!==c){for(d=[],h=oe,e=L(),null!==e?(f=bd(),null!==f?e=[e,f]:(e=null,oe=h)):(e=null,oe=h);null!==e;)d.push(e),h=oe,e=L(),null!==e?(f=bd(),null!==f?e=[e,f]:(e=null,oe=h)):(e=null,oe=h);null!==d?a=[a,b,c,d]:(a=null,oe=g)}else a=null,oe=g;else a=null,oe=g;else a=null,oe=g;return a}function bd(){var a,b,c,d;return d=oe,a=A(),null!==a?(b=G(),null!==b?(c=A(),null===c&&(c=S()),null!==c?a=[a,b,c]:(a=null,oe=d)):(a=null,oe=d)):(a=null,oe=d),a}function cd(){var a;return a=dd(),null===a&&(a=fd(),null===a&&(a=hd(),null===a&&(a=jd(),null===a&&(a=kd(),null===a&&(a=ld(),null===a&&(a=md(),null===a&&(a=bd()))))))),a}function dd(){var a,c,e,f;return f=oe,"realm"===b.substr(oe,5).toLowerCase()?(a=b.substr(oe,5),oe+=5):(a=null,0===pe&&d('"realm"')),null!==a?(c=G(),null!==c?(e=ed(),null!==e?a=[a,c,e]:(a=null,oe=f)):(a=null,oe=f)):(a=null,oe=f),a}function ed(){var a,b;return b=oe,a=T(),null!==a&&(a=function(a,b){se.realm=b}(b,a)),null===a&&(oe=b),a}function fd(){var a,c,e,f,g,h,i,j,k;if(j=oe,"domain"===b.substr(oe,6).toLowerCase()?(a=b.substr(oe,6),oe+=6):(a=null,0===pe&&d('"domain"')),null!==a)if(c=G(),null!==c)if(e=O(),null!==e)if(f=gd(),null!==f){if(g=[],k=oe,i=l(),null!==i)for(h=[];null!==i;)h.push(i),i=l();else h=null;for(null!==h?(i=gd(),null!==i?h=[h,i]:(h=null,oe=k)):(h=null,oe=k);null!==h;){if(g.push(h),k=oe,i=l(),null!==i)for(h=[];null!==i;)h.push(i),i=l();else h=null;null!==h?(i=gd(),null!==i?h=[h,i]:(h=null,oe=k)):(h=null,oe=k)}null!==g?(h=P(),null!==h?a=[a,c,e,f,g,h]:(a=null,oe=j)):(a=null,oe=j)}else a=null,oe=j;else a=null,oe=j;else a=null,oe=j;else a=null,oe=j;return a}function gd(){var a;return a=Ib(),null===a&&(a=Lb()),a}function hd(){var a,c,e,f;return f=oe,"nonce"===b.substr(oe,5).toLowerCase()?(a=b.substr(oe,5),oe+=5):(a=null,0===pe&&d('"nonce"')),null!==a?(c=G(),null!==c?(e=id(),null!==e?a=[a,c,e]:(a=null,oe=f)):(a=null,oe=f)):(a=null,oe=f),a}function id(){var a,b;return b=oe,a=T(),null!==a&&(a=function(a,b){se.nonce=b}(b,a)),null===a&&(oe=b),a}function jd(){var a,c,e,f,g;return f=oe,g=oe,"opaque"===b.substr(oe,6).toLowerCase()?(a=b.substr(oe,6),oe+=6):(a=null,0===pe&&d('"opaque"')),null!==a?(c=G(),null!==c?(e=T(),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(a,b){se.opaque=b}(f,a[2])),null===a&&(oe=f),a}function kd(){var a,c,e,f,g;return f=oe,"stale"===b.substr(oe,5).toLowerCase()?(a=b.substr(oe,5),oe+=5):(a=null,0===pe&&d('"stale"')),null!==a?(c=G(),null!==c?(g=oe,"true"===b.substr(oe,4).toLowerCase()?(e=b.substr(oe,4),oe+=4):(e=null,0===pe&&d('"true"')),null!==e&&(e=function(){se.stale=!0}(g)),null===e&&(oe=g),null===e&&(g=oe,"false"===b.substr(oe,5).toLowerCase()?(e=b.substr(oe,5),oe+=5):(e=null,0===pe&&d('"false"')),null!==e&&(e=function(){se.stale=!1}(g)),null===e&&(oe=g)),null!==e?a=[a,c,e]:(a=null,oe=f)):(a=null,oe=f)):(a=null,oe=f),a}function ld(){var a,c,e,f,g;return f=oe,g=oe,"algorithm"===b.substr(oe,9).toLowerCase()?(a=b.substr(oe,9),oe+=9):(a=null,0===pe&&d('"algorithm"')),null!==a?(c=G(),null!==c?("md5"===b.substr(oe,3).toLowerCase()?(e=b.substr(oe,3),oe+=3):(e=null,0===pe&&d('"MD5"')),null===e&&("md5-sess"===b.substr(oe,8).toLowerCase()?(e=b.substr(oe,8),oe+=8):(e=null,0===pe&&d('"MD5-sess"')),null===e&&(e=A())),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(a,b){se.algorithm=b.toUpperCase()}(f,a[2])),null===a&&(oe=f),a}function md(){var a,c,e,f,g,h,i,j,k,l;if(j=oe,"qop"===b.substr(oe,3).toLowerCase()?(a=b.substr(oe,3),oe+=3):(a=null,0===pe&&d('"qop"')),null!==a)if(c=G(),null!==c)if(e=O(),null!==e){if(k=oe,f=nd(),null!==f){for(g=[],l=oe,44===b.charCodeAt(oe)?(h=",",oe++):(h=null,0===pe&&d('","')),null!==h?(i=nd(),null!==i?h=[h,i]:(h=null,oe=l)):(h=null,oe=l);null!==h;)g.push(h),l=oe,44===b.charCodeAt(oe)?(h=",",oe++):(h=null,0===pe&&d('","')),null!==h?(i=nd(),null!==i?h=[h,i]:(h=null,oe=l)):(h=null,oe=l);null!==g?f=[f,g]:(f=null,oe=k)}else f=null,oe=k;null!==f?(g=P(),null!==g?a=[a,c,e,f,g]:(a=null,oe=j)):(a=null,oe=j)}else a=null,oe=j;else a=null,oe=j;else a=null,oe=j;return a}function nd(){var a,c;return c=oe,"auth-int"===b.substr(oe,8).toLowerCase()?(a=b.substr(oe,8),oe+=8):(a=null,0===pe&&d('"auth-int"')),null===a&&("auth"===b.substr(oe,4).toLowerCase()?(a=b.substr(oe,4),oe+=4):(a=null,0===pe&&d('"auth"')),null===a&&(a=A())),null!==a&&(a=function(a,b){se.qop||(se.qop=[]),se.qop.push(b.toLowerCase())}(c,a)),null===a&&(oe=c),a}function od(){var a,b,c,d,e,f;if(e=oe,a=A(),null!==a){for(b=[],f=oe,c=L(),null!==c?(d=A(),null!==d?c=[c,d]:(c=null,oe=f)):(c=null,oe=f);null!==c;)b.push(c),f=oe,c=L(),null!==c?(d=A(),null!==d?c=[c,d]:(c=null,oe=f)):(c=null,oe=f);null!==b?a=[a,b]:(a=null,oe=e)}else a=null,oe=e;return a}function pd(){var a,b,c,d,e,f;return f=oe,a=qd(),null!==a?(b=s(),null!==b?(c=qd(),null!==c?(d=s(),null!==d?(e=hc(),null!==e?a=[a,b,c,d,e]:(a=null,oe=f)):(a=null,oe=f)):(a=null,oe=f)):(a=null,oe=f)):(a=null,oe=f),a}function qd(){var a,b,c;if(c=oe,b=f(),null!==b)for(a=[];null!==b;)a.push(b),b=f();else a=null;return null!==a&&(a=function(a,b){se.value=parseInt(b.join(""))}(c,a)),null===a&&(oe=c),a}function rd(){var a,b,c,d,e,f,g;if(e=oe,f=oe,a=sd(),null!==a){for(b=[],g=oe,c=L(),null!==c?(d=sd(),null!==d?c=[c,d]:(c=null,oe=g)):(c=null,oe=g);null!==c;)b.push(c),g=oe,c=L(),null!==c?(d=sd(),null!==d?c=[c,d]:(c=null,oe=g)):(c=null,oe=g);null!==b?a=[a,b]:(a=null,oe=f)}else a=null,oe=f;return null!==a&&(a=function(){var a,b;for(b=se.multi_header.length,a=0;b>a;a++)if(null===se.multi_header[a].parsed){se=null;break}se=null!==se?se.multi_header:-1}(e)),null===a&&(oe=e),a}function sd(){var a,b,c,d,e,f,g;if(e=oe,f=oe,a=qc(),null!==a){for(b=[],g=oe,c=M(),null!==c?(d=xc(),null!==d?c=[c,d]:(c=null,oe=g)):(c=null,oe=g);null!==c;)b.push(c),g=oe,c=M(),null!==c?(d=xc(),null!==d?c=[c,d]:(c=null,oe=g)):(c=null,oe=g);null!==b?a=[a,b]:(a=null,oe=f)}else a=null,oe=f;return null!==a&&(a=function(a){var b;se.multi_header||(se.multi_header=[]);try{b=new SIP.NameAddrHeader(se.uri,se.displayName,se.params),delete se.uri,delete se.displayName,delete se.params}catch(c){b=null}se.multi_header.push({possition:oe,offset:a,parsed:b})}(e)),null===a&&(oe=e),a}function td(){var a,b,c,d,e,f,g;if(e=oe,f=oe,a=W(),null===a&&(a=qc()),null!==a){for(b=[],g=oe,c=M(),null!==c?(d=xc(),null!==d?c=[c,d]:(c=null,oe=g)):(c=null,oe=g);null!==c;)b.push(c),g=oe,c=M(),null!==c?(d=xc(),null!==d?c=[c,d]:(c=null,oe=g)):(c=null,oe=g);null!==b?a=[a,b]:(a=null,oe=f)}else a=null,oe=f;return null!==a&&(a=function(){try{se=new SIP.NameAddrHeader(se.uri,se.displayName,se.params)}catch(a){se=-1}}(e)),null===a&&(oe=e),a}function ud(){var a,b,c,d,e,f;if(e=oe,a=A(),null!==a){for(b=[],f=oe,c=L(),null!==c?(d=A(),null!==d?c=[c,d]:(c=null,oe=f)):(c=null,oe=f);null!==c;)b.push(c),f=oe,c=L(),null!==c?(d=A(),null!==d?c=[c,d]:(c=null,oe=f)):(c=null,oe=f);null!==b?a=[a,b]:(a=null,oe=e)}else a=null,oe=e;return a}function vd(){var a,b,c,d,e,f; if(e=oe,a=wd(),null!==a){for(b=[],f=oe,c=L(),null!==c?(d=wd(),null!==d?c=[c,d]:(c=null,oe=f)):(c=null,oe=f);null!==c;)b.push(c),f=oe,c=L(),null!==c?(d=wd(),null!==d?c=[c,d]:(c=null,oe=f)):(c=null,oe=f);null!==b?a=[a,b]:(a=null,oe=e)}else a=null,oe=e;return a}function wd(){var a,b,c,d,e,f;if(e=oe,a=qc(),null!==a){for(b=[],f=oe,c=M(),null!==c?(d=xc(),null!==d?c=[c,d]:(c=null,oe=f)):(c=null,oe=f);null!==c;)b.push(c),f=oe,c=M(),null!==c?(d=xc(),null!==d?c=[c,d]:(c=null,oe=f)):(c=null,oe=f);null!==b?a=[a,b]:(a=null,oe=e)}else a=null,oe=e;return a}function xd(){var a,b,c;if(c=oe,b=f(),null!==b)for(a=[];null!==b;)a.push(b),b=f();else a=null;return null!==a&&(a=function(a,b){se.value=parseInt(b.join(""))}(c,a)),null===a&&(oe=c),a}function yd(){var a,b,c,d,e,f;if(e=oe,a=zd(),null!==a){for(b=[],f=oe,c=M(),null!==c?(d=Ad(),null!==d?c=[c,d]:(c=null,oe=f)):(c=null,oe=f);null!==c;)b.push(c),f=oe,c=M(),null!==c?(d=Ad(),null!==d?c=[c,d]:(c=null,oe=f)):(c=null,oe=f);null!==b?a=[a,b]:(a=null,oe=e)}else a=null,oe=e;return a}function zd(){var a,c;return c=oe,"active"===b.substr(oe,6).toLowerCase()?(a=b.substr(oe,6),oe+=6):(a=null,0===pe&&d('"active"')),null===a&&("pending"===b.substr(oe,7).toLowerCase()?(a=b.substr(oe,7),oe+=7):(a=null,0===pe&&d('"pending"')),null===a&&("terminated"===b.substr(oe,10).toLowerCase()?(a=b.substr(oe,10),oe+=10):(a=null,0===pe&&d('"terminated"')),null===a&&(a=A()))),null!==a&&(a=function(a){se.state=b.substring(oe,a)}(c)),null===a&&(oe=c),a}function Ad(){var a,c,e,f,g;return f=oe,g=oe,"reason"===b.substr(oe,6).toLowerCase()?(a=b.substr(oe,6),oe+=6):(a=null,0===pe&&d('"reason"')),null!==a?(c=G(),null!==c?(e=Bd(),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(a,b){"undefined"!=typeof b&&(se.reason=b)}(f,a[2])),null===a&&(oe=f),null===a&&(f=oe,g=oe,"expires"===b.substr(oe,7).toLowerCase()?(a=b.substr(oe,7),oe+=7):(a=null,0===pe&&d('"expires"')),null!==a?(c=G(),null!==c?(e=vc(),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(a,b){"undefined"!=typeof b&&(se.expires=b)}(f,a[2])),null===a&&(oe=f),null===a&&(f=oe,g=oe,"retry_after"===b.substr(oe,11).toLowerCase()?(a=b.substr(oe,11),oe+=11):(a=null,0===pe&&d('"retry_after"')),null!==a?(c=G(),null!==c?(e=vc(),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(a,b){"undefined"!=typeof b&&(se.retry_after=b)}(f,a[2])),null===a&&(oe=f),null===a&&(a=xc()))),a}function Bd(){var a;return"deactivated"===b.substr(oe,11).toLowerCase()?(a=b.substr(oe,11),oe+=11):(a=null,0===pe&&d('"deactivated"')),null===a&&("probation"===b.substr(oe,9).toLowerCase()?(a=b.substr(oe,9),oe+=9):(a=null,0===pe&&d('"probation"')),null===a&&("rejected"===b.substr(oe,8).toLowerCase()?(a=b.substr(oe,8),oe+=8):(a=null,0===pe&&d('"rejected"')),null===a&&("timeout"===b.substr(oe,7).toLowerCase()?(a=b.substr(oe,7),oe+=7):(a=null,0===pe&&d('"timeout"')),null===a&&("giveup"===b.substr(oe,6).toLowerCase()?(a=b.substr(oe,6),oe+=6):(a=null,0===pe&&d('"giveup"')),null===a&&("noresource"===b.substr(oe,10).toLowerCase()?(a=b.substr(oe,10),oe+=10):(a=null,0===pe&&d('"noresource"')),null===a&&("invariant"===b.substr(oe,9).toLowerCase()?(a=b.substr(oe,9),oe+=9):(a=null,0===pe&&d('"invariant"')),null===a&&(a=A()))))))),a}function Cd(){var a;return a=v(),a=null!==a?a:""}function Dd(){var a,b,c,d,e,f;if(e=oe,a=A(),null!==a){for(b=[],f=oe,c=L(),null!==c?(d=A(),null!==d?c=[c,d]:(c=null,oe=f)):(c=null,oe=f);null!==c;)b.push(c),f=oe,c=L(),null!==c?(d=A(),null!==d?c=[c,d]:(c=null,oe=f)):(c=null,oe=f);null!==b?a=[a,b]:(a=null,oe=e)}else a=null,oe=e;return a=null!==a?a:""}function Ed(){var a,b,c,d,e,f,g;if(e=oe,f=oe,a=W(),null===a&&(a=qc()),null!==a){for(b=[],g=oe,c=M(),null!==c?(d=Fd(),null!==d?c=[c,d]:(c=null,oe=g)):(c=null,oe=g);null!==c;)b.push(c),g=oe,c=M(),null!==c?(d=Fd(),null!==d?c=[c,d]:(c=null,oe=g)):(c=null,oe=g);null!==b?a=[a,b]:(a=null,oe=f)}else a=null,oe=f;return null!==a&&(a=function(){var a=se.tag;try{se=new SIP.NameAddrHeader(se.uri,se.displayName,se.params),a&&se.setParam("tag",a)}catch(b){se=-1}}(e)),null===a&&(oe=e),a}function Fd(){var a;return a=Wc(),null===a&&(a=xc()),a}function Gd(){var a,b,c,d,e,f;if(e=oe,a=Hd(),null!==a){for(b=[],f=oe,c=L(),null!==c?(d=Hd(),null!==d?c=[c,d]:(c=null,oe=f)):(c=null,oe=f);null!==c;)b.push(c),f=oe,c=L(),null!==c?(d=Hd(),null!==d?c=[c,d]:(c=null,oe=f)):(c=null,oe=f);null!==b?a=[a,b]:(a=null,oe=e)}else a=null,oe=e;return a}function Hd(){var a,b,c,d,e,f,g,h;if(g=oe,a=Od(),null!==a)if(b=s(),null!==b)if(c=Rd(),null!==c){for(d=[],h=oe,e=M(),null!==e?(f=Id(),null!==f?e=[e,f]:(e=null,oe=h)):(e=null,oe=h);null!==e;)d.push(e),h=oe,e=M(),null!==e?(f=Id(),null!==f?e=[e,f]:(e=null,oe=h)):(e=null,oe=h);null!==d?a=[a,b,c,d]:(a=null,oe=g)}else a=null,oe=g;else a=null,oe=g;else a=null,oe=g;return a}function Id(){var a;return a=Jd(),null===a&&(a=Kd(),null===a&&(a=Ld(),null===a&&(a=Md(),null===a&&(a=Nd(),null===a&&(a=xc()))))),a}function Jd(){var a,c,e,f,g;return f=oe,g=oe,"ttl"===b.substr(oe,3).toLowerCase()?(a=b.substr(oe,3),oe+=3):(a=null,0===pe&&d('"ttl"')),null!==a?(c=G(),null!==c?(e=Ud(),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(a,b){se.ttl=b}(f,a[2])),null===a&&(oe=f),a}function Kd(){var a,c,e,f,g;return f=oe,g=oe,"maddr"===b.substr(oe,5).toLowerCase()?(a=b.substr(oe,5),oe+=5):(a=null,0===pe&&d('"maddr"')),null!==a?(c=G(),null!==c?(e=cb(),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(a,b){se.maddr=b}(f,a[2])),null===a&&(oe=f),a}function Ld(){var a,c,e,f,g;return f=oe,g=oe,"received"===b.substr(oe,8).toLowerCase()?(a=b.substr(oe,8),oe+=8):(a=null,0===pe&&d('"received"')),null!==a?(c=G(),null!==c?(e=kb(),null===e&&(e=hb()),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(a,b){se.received=b}(f,a[2])),null===a&&(oe=f),a}function Md(){var a,c,e,f,g;return f=oe,g=oe,"branch"===b.substr(oe,6).toLowerCase()?(a=b.substr(oe,6),oe+=6):(a=null,0===pe&&d('"branch"')),null!==a?(c=G(),null!==c?(e=A(),null!==e?a=[a,c,e]:(a=null,oe=g)):(a=null,oe=g)):(a=null,oe=g),null!==a&&(a=function(a,b){se.branch=b}(f,a[2])),null===a&&(oe=f),a}function Nd(){var a,c,e,g,h,i,j;if(h=oe,i=oe,"rport"===b.substr(oe,5).toLowerCase()?(a=b.substr(oe,5),oe+=5):(a=null,0===pe&&d('"rport"')),null!==a){if(j=oe,c=G(),null!==c){for(e=[],g=f();null!==g;)e.push(g),g=f();null!==e?c=[c,e]:(c=null,oe=j)}else c=null,oe=j;c=null!==c?c:"",null!==c?a=[a,c]:(a=null,oe=i)}else a=null,oe=i;return null!==a&&(a=function(){"undefined"!=typeof response_port&&(se.rport=response_port.join(""))}(h)),null===a&&(oe=h),a}function Od(){var a,b,c,d,e,f;return f=oe,a=Pd(),null!==a?(b=F(),null!==b?(c=A(),null!==c?(d=F(),null!==d?(e=Qd(),null!==e?a=[a,b,c,d,e]:(a=null,oe=f)):(a=null,oe=f)):(a=null,oe=f)):(a=null,oe=f)):(a=null,oe=f),a}function Pd(){var a,c;return c=oe,"sip"===b.substr(oe,3).toLowerCase()?(a=b.substr(oe,3),oe+=3):(a=null,0===pe&&d('"SIP"')),null===a&&(a=A()),null!==a&&(a=function(a,b){se.protocol=b}(c,a)),null===a&&(oe=c),a}function Qd(){var a,c;return c=oe,"udp"===b.substr(oe,3).toLowerCase()?(a=b.substr(oe,3),oe+=3):(a=null,0===pe&&d('"UDP"')),null===a&&("tcp"===b.substr(oe,3).toLowerCase()?(a=b.substr(oe,3),oe+=3):(a=null,0===pe&&d('"TCP"')),null===a&&("tls"===b.substr(oe,3).toLowerCase()?(a=b.substr(oe,3),oe+=3):(a=null,0===pe&&d('"TLS"')),null===a&&("sctp"===b.substr(oe,4).toLowerCase()?(a=b.substr(oe,4),oe+=4):(a=null,0===pe&&d('"SCTP"')),null===a&&(a=A())))),null!==a&&(a=function(a,b){se.transport=b}(c,a)),null===a&&(oe=c),a}function Rd(){var a,b,c,d,e;return d=oe,a=Sd(),null!==a?(e=oe,b=N(),null!==b?(c=Td(),null!==c?b=[b,c]:(b=null,oe=e)):(b=null,oe=e),b=null!==b?b:"",null!==b?a=[a,b]:(a=null,oe=d)):(a=null,oe=d),a}function Sd(){var a,c;return c=oe,a=db(),null===a&&(a=kb(),null===a&&(a=gb())),null!==a&&(a=function(a){se.host=b.substring(oe,a)}(c)),null===a&&(oe=c),a}function Td(){var a,b,c,d,e,g,h;return g=oe,h=oe,a=f(),a=null!==a?a:"",null!==a?(b=f(),b=null!==b?b:"",null!==b?(c=f(),c=null!==c?c:"",null!==c?(d=f(),d=null!==d?d:"",null!==d?(e=f(),e=null!==e?e:"",null!==e?a=[a,b,c,d,e]:(a=null,oe=h)):(a=null,oe=h)):(a=null,oe=h)):(a=null,oe=h)):(a=null,oe=h),null!==a&&(a=function(a,b){se.port=parseInt(b.join(""))}(g,a)),null===a&&(oe=g),a}function Ud(){var a,b,c,d,e;return d=oe,e=oe,a=f(),null!==a?(b=f(),b=null!==b?b:"",null!==b?(c=f(),c=null!==c?c:"",null!==c?a=[a,b,c]:(a=null,oe=e)):(a=null,oe=e)):(a=null,oe=e),null!==a&&(a=function(a,b){return parseInt(b.join(""))}(d,a)),null===a&&(oe=d),a}function Vd(){var a;return a=_c()}function Wd(){var a,b,c,d;return d=oe,a=A(),null!==a?(b=u(),null!==b?(c=Xd(),null!==c?a=[a,b,c]:(a=null,oe=d)):(a=null,oe=d)):(a=null,oe=d),a}function Xd(){var a,b;for(a=[],b=w(),null===b&&(b=y(),null===b&&(b=s()));null!==b;)a.push(b),b=w(),null===b&&(b=y(),null===b&&(b=s()));return a}function Yd(){var a,b;for(a=[],b=j();null!==b;)a.push(b),b=j();return a}function Zd(){var a,c,e,f;return f=oe,a=$d(),null!==a?(58===b.charCodeAt(oe)?(c=":",oe++):(c=null,0===pe&&d('":"')),null!==c?(e=_d(),null!==e?a=[a,c,e]:(a=null,oe=f)):(a=null,oe=f)):(a=null,oe=f),a}function $d(){var a,c;return c=oe,"stuns"===b.substr(oe,5).toLowerCase()?(a=b.substr(oe,5),oe+=5):(a=null,0===pe&&d('"stuns"')),null===a&&("stun"===b.substr(oe,4).toLowerCase()?(a=b.substr(oe,4),oe+=4):(a=null,0===pe&&d('"stun"'))),null!==a&&(a=function(a,b){se.scheme=b}(c,a)),null===a&&(oe=c),a}function _d(){var a,c,e,f,g;return f=oe,a=ae(),null!==a?(g=oe,58===b.charCodeAt(oe)?(c=":",oe++):(c=null,0===pe&&d('":"')),null!==c?(e=mb(),null!==e?c=[c,e]:(c=null,oe=g)):(c=null,oe=g),c=null!==c?c:"",null!==c?a=[a,c]:(a=null,oe=f)):(a=null,oe=f),a}function ae(){var a,b;return b=oe,a=kb(),null===a&&(a=gb(),null===a&&(a=Wb())),null!==a&&(a=function(a,b){se.host=b}(b,a)),null===a&&(oe=b),a}function Wb(){var a,c,d;for(d=oe,a=[],c=be(),null===c&&(c=r(),null===c&&(c=ce()));null!==c;)a.push(c),c=be(),null===c&&(c=r(),null===c&&(c=ce()));return null!==a&&(a=function(a){return b.substring(oe,a)}(d)),null===a&&(oe=d),a}function be(){var a;return a=g(),null===a&&(a=f(),null===a&&(45===b.charCodeAt(oe)?(a="-",oe++):(a=null,0===pe&&d('"-"')),null===a&&(46===b.charCodeAt(oe)?(a=".",oe++):(a=null,0===pe&&d('"."')),null===a&&(95===b.charCodeAt(oe)?(a="_",oe++):(a=null,0===pe&&d('"_"')),null===a&&(126===b.charCodeAt(oe)?(a="~",oe++):(a=null,0===pe&&d('"~"'))))))),a}function ce(){var a;return 33===b.charCodeAt(oe)?(a="!",oe++):(a=null,0===pe&&d('"!"')),null===a&&(36===b.charCodeAt(oe)?(a="$",oe++):(a=null,0===pe&&d('"$"')),null===a&&(38===b.charCodeAt(oe)?(a="&",oe++):(a=null,0===pe&&d('"&"')),null===a&&(39===b.charCodeAt(oe)?(a="'",oe++):(a=null,0===pe&&d('"\'"')),null===a&&(40===b.charCodeAt(oe)?(a="(",oe++):(a=null,0===pe&&d('"("')),null===a&&(41===b.charCodeAt(oe)?(a=")",oe++):(a=null,0===pe&&d('")"')),null===a&&(42===b.charCodeAt(oe)?(a="*",oe++):(a=null,0===pe&&d('"*"')),null===a&&(43===b.charCodeAt(oe)?(a="+",oe++):(a=null,0===pe&&d('"+"')),null===a&&(44===b.charCodeAt(oe)?(a=",",oe++):(a=null,0===pe&&d('","')),null===a&&(59===b.charCodeAt(oe)?(a=";",oe++):(a=null,0===pe&&d('";"')),null===a&&(61===b.charCodeAt(oe)?(a="=",oe++):(a=null,0===pe&&d('"="')))))))))))),a}function de(){var a,c,e,f,g,h,i;return h=oe,a=ee(),null!==a?(58===b.charCodeAt(oe)?(c=":",oe++):(c=null,0===pe&&d('":"')),null!==c?(e=_d(),null!==e?(i=oe,"?transport="===b.substr(oe,11)?(f="?transport=",oe+=11):(f=null,0===pe&&d('"?transport="')),null!==f?(g=Qd(),null!==g?f=[f,g]:(f=null,oe=i)):(f=null,oe=i),f=null!==f?f:"",null!==f?a=[a,c,e,f]:(a=null,oe=h)):(a=null,oe=h)):(a=null,oe=h)):(a=null,oe=h),a}function ee(){var a,c;return c=oe,"turns"===b.substr(oe,5).toLowerCase()?(a=b.substr(oe,5),oe+=5):(a=null,0===pe&&d('"turns"')),null===a&&("turn"===b.substr(oe,4).toLowerCase()?(a=b.substr(oe,4),oe+=4):(a=null,0===pe&&d('"turn"'))),null!==a&&(a=function(a,b){se.scheme=b}(c,a)),null===a&&(oe=c),a}function fe(){var a,c,e,f,g;if(f=oe,g=oe,a=Qd(),null!==a){if("udp"===b.substr(oe,3).toLowerCase()?(c=b.substr(oe,3),oe+=3):(c=null,0===pe&&d('"udp"')),null===c&&("tcp"===b.substr(oe,3).toLowerCase()?(c=b.substr(oe,3),oe+=3):(c=null,0===pe&&d('"tcp"')),null===c))for(c=[],e=p();null!==e;)c.push(e),e=p();null!==c?a=[a,c]:(a=null,oe=g)}else a=null,oe=g;return null!==a&&(a=function(){se.transport=transport}(f)),null===a&&(oe=f),a}function ge(){var a,c,e;return e=oe,"uuid:"===b.substr(oe,5)?(a="uuid:",oe+=5):(a=null,0===pe&&d('"uuid:"')),null!==a?(c=he(),null!==c?a=[a,c]:(a=null,oe=e)):(a=null,oe=e),a}function he(){var a,c,e,f,g,h,i,j,k,l,m;return l=oe,m=oe,a=je(),null!==a?(45===b.charCodeAt(oe)?(c="-",oe++):(c=null,0===pe&&d('"-"')),null!==c?(e=ie(),null!==e?(45===b.charCodeAt(oe)?(f="-",oe++):(f=null,0===pe&&d('"-"')),null!==f?(g=ie(),null!==g?(45===b.charCodeAt(oe)?(h="-",oe++):(h=null,0===pe&&d('"-"')),null!==h?(i=ie(),null!==i?(45===b.charCodeAt(oe)?(j="-",oe++):(j=null,0===pe&&d('"-"')),null!==j?(k=ke(),null!==k?a=[a,c,e,f,g,h,i,j,k]:(a=null,oe=m)):(a=null,oe=m)):(a=null,oe=m)):(a=null,oe=m)):(a=null,oe=m)):(a=null,oe=m)):(a=null,oe=m)):(a=null,oe=m)):(a=null,oe=m),null!==a&&(a=function(a){se=b.substring(oe+5,a)}(l,a[0])),null===a&&(oe=l),a}function ie(){var a,b,c,d,e;return e=oe,a=h(),null!==a?(b=h(),null!==b?(c=h(),null!==c?(d=h(),null!==d?a=[a,b,c,d]:(a=null,oe=e)):(a=null,oe=e)):(a=null,oe=e)):(a=null,oe=e),a}function je(){var a,b,c;return c=oe,a=ie(),null!==a?(b=ie(),null!==b?a=[a,b]:(a=null,oe=c)):(a=null,oe=c),a}function ke(){var a,b,c,d;return d=oe,a=ie(),null!==a?(b=ie(),null!==b?(c=ie(),null!==c?a=[a,b,c]:(a=null,oe=d)):(a=null,oe=d)):(a=null,oe=d),a}function le(a){a.sort();for(var b=null,c=[],d=0;d
Comments