From 98d9736ad8ca42bf0ed2133e9542e6e4825b372c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Thu, 5 Apr 2018 09:01:37 +0200 Subject: [PATCH] 3.2.8 --- CHANGELOG.md | 10 + dist/jssip.js | 1250 +++++++++++++-------------------------------- dist/jssip.min.js | 4 +- package.json | 2 +- 4 files changed, 362 insertions(+), 904 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4388f4f6..7c1971129 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,16 @@ CHANGELOG ========= +Version 3.2.8 (released in 2018-04-05) +-------------------------------------- +* Fix #511. Add missing payload on 'UA:disconnected' event. + + +Version 3.2.7 (released in 2018-03-23) +-------------------------------------- +* Fix regression (#509): ua.call() not working if stream is given. + + Version 3.2.6 (released in 2018-03-22) -------------------------------------- * RTCSession: custom local description trigger support diff --git a/dist/jssip.js b/dist/jssip.js index 725ead31e..f01d31e78 100644 --- a/dist/jssip.js +++ b/dist/jssip.js @@ -1,12 +1,12 @@ /* - * JsSIP v3.2.7 + * JsSIP v3.2.8 * the Javascript SIP library * Copyright: 2012-2018 José Luis Millán (https://github.com/jmillan) * Homepage: http://jssip.net * License: MIT */ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.JsSIP = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 1) + if (type === 'error') { + if (!this._events.error || + (isObject(this._events.error) && !this._events.error.length)) { er = arguments[1]; - if (er instanceof Error) { - throw er; // Unhandled 'error' event - } else { - // At least give some kind of context to the user - var err = new Error('Unhandled "error" event. (' + er + ')'); - err.context = er; - throw err; + if (er instanceof Error) { + throw er; // Unhandled 'error' event + } else { + // At least give some kind of context to the user + var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); + err.context = er; + throw err; + } } - return false; } - handler = events[type]; + handler = this._events[type]; - if (!handler) + if (isUndefined(handler)) return false; - var isFn = typeof handler === 'function'; - len = arguments.length; - switch (len) { + if (isFunction(handler)) { + switch (arguments.length) { // fast cases - case 1: - emitNone(handler, isFn, this); - break; - case 2: - emitOne(handler, isFn, this, arguments[1]); - break; - case 3: - emitTwo(handler, isFn, this, arguments[1], arguments[2]); - break; - case 4: - emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]); - break; + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; // slower - default: - args = new Array(len - 1); - for (i = 1; i < len; i++) - args[i - 1] = arguments[i]; - emitMany(handler, isFn, this, args); + default: + args = Array.prototype.slice.call(arguments, 1); + handler.apply(this, args); + } + } else if (isObject(handler)) { + args = Array.prototype.slice.call(arguments, 1); + listeners = handler.slice(); + len = listeners.length; + for (i = 0; i < len; i++) + listeners[i].apply(this, args); } return true; }; -function _addListener(target, type, listener, prepend) { +EventEmitter.prototype.addListener = function(type, listener) { var m; - var events; - var existing; - if (typeof listener !== 'function') - throw new TypeError('"listener" argument must be a function'); + if (!isFunction(listener)) + throw TypeError('listener must be a function'); - events = target._events; - if (!events) { - events = target._events = objectCreate(null); - target._eventsCount = 0; - } else { - // To avoid recursion in the case that type === "newListener"! Before - // adding it to the listeners, first emit "newListener". - if (events.newListener) { - target.emit('newListener', type, - listener.listener ? listener.listener : listener); + if (!this._events) + this._events = {}; - // Re-assign `events` because a newListener handler could have caused the - // this._events to be assigned to a new object - events = target._events; - } - existing = events[type]; - } + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (this._events.newListener) + this.emit('newListener', type, + isFunction(listener.listener) ? + listener.listener : listener); - if (!existing) { + if (!this._events[type]) // Optimize the case of one listener. Don't need the extra array object. - existing = events[type] = listener; - ++target._eventsCount; - } else { - if (typeof existing === 'function') { - // Adding the second element, need to change to array. - existing = events[type] = - prepend ? [listener, existing] : [existing, listener]; + this._events[type] = listener; + else if (isObject(this._events[type])) + // If we've already got an array, just append. + this._events[type].push(listener); + else + // Adding the second element, need to change to array. + this._events[type] = [this._events[type], listener]; + + // Check for listener leak + if (isObject(this._events[type]) && !this._events[type].warned) { + if (!isUndefined(this._maxListeners)) { + m = this._maxListeners; } else { - // If we've already got an array, just append. - if (prepend) { - existing.unshift(listener); - } else { - existing.push(listener); - } + m = EventEmitter.defaultMaxListeners; } - // Check for listener leak - if (!existing.warned) { - m = $getMaxListeners(target); - if (m && m > 0 && existing.length > m) { - existing.warned = true; - var w = new Error('Possible EventEmitter memory leak detected. ' + - existing.length + ' "' + String(type) + '" listeners ' + - 'added. Use emitter.setMaxListeners() to ' + - 'increase limit.'); - w.name = 'MaxListenersExceededWarning'; - w.emitter = target; - w.type = type; - w.count = existing.length; - if (typeof console === 'object' && console.warn) { - console.warn('%s: %s', w.name, w.message); - } + if (m && m > 0 && this._events[type].length > m) { + this._events[type].warned = true; + console.error('(node) warning: possible EventEmitter memory ' + + 'leak detected. %d listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit.', + this._events[type].length); + if (typeof console.trace === 'function') { + // not supported in IE 10 + console.trace(); } } } - return target; -} - -EventEmitter.prototype.addListener = function addListener(type, listener) { - return _addListener(this, type, listener, false); + return this; }; EventEmitter.prototype.on = EventEmitter.prototype.addListener; -EventEmitter.prototype.prependListener = - function prependListener(type, listener) { - return _addListener(this, type, listener, true); - }; +EventEmitter.prototype.once = function(type, listener) { + if (!isFunction(listener)) + throw TypeError('listener must be a function'); -function onceWrapper() { - if (!this.fired) { - this.target.removeListener(this.type, this.wrapFn); - this.fired = true; - switch (arguments.length) { - case 0: - return this.listener.call(this.target); - case 1: - return this.listener.call(this.target, arguments[0]); - case 2: - return this.listener.call(this.target, arguments[0], arguments[1]); - case 3: - return this.listener.call(this.target, arguments[0], arguments[1], - arguments[2]); - default: - var args = new Array(arguments.length); - for (var i = 0; i < args.length; ++i) - args[i] = arguments[i]; - this.listener.apply(this.target, args); + var fired = false; + + function g() { + this.removeListener(type, g); + + if (!fired) { + fired = true; + listener.apply(this, arguments); } } -} -function _onceWrap(target, type, listener) { - var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener }; - var wrapped = bind.call(onceWrapper, state); - wrapped.listener = listener; - state.wrapFn = wrapped; - return wrapped; -} + g.listener = listener; + this.on(type, g); -EventEmitter.prototype.once = function once(type, listener) { - if (typeof listener !== 'function') - throw new TypeError('"listener" argument must be a function'); - this.on(type, _onceWrap(this, type, listener)); return this; }; -EventEmitter.prototype.prependOnceListener = - function prependOnceListener(type, listener) { - if (typeof listener !== 'function') - throw new TypeError('"listener" argument must be a function'); - this.prependListener(type, _onceWrap(this, type, listener)); - return this; - }; - -// Emits a 'removeListener' event if and only if the listener was removed. -EventEmitter.prototype.removeListener = - function removeListener(type, listener) { - var list, events, position, i, originalListener; +// emits a 'removeListener' event iff the listener was removed +EventEmitter.prototype.removeListener = function(type, listener) { + var list, position, length, i; - if (typeof listener !== 'function') - throw new TypeError('"listener" argument must be a function'); + if (!isFunction(listener)) + throw TypeError('listener must be a function'); - events = this._events; - if (!events) - return this; + if (!this._events || !this._events[type]) + return this; - list = events[type]; - if (!list) - return this; + list = this._events[type]; + length = list.length; + position = -1; - if (list === listener || list.listener === listener) { - if (--this._eventsCount === 0) - this._events = objectCreate(null); - else { - delete events[type]; - if (events.removeListener) - this.emit('removeListener', type, list.listener || listener); - } - } else if (typeof list !== 'function') { - position = -1; + if (list === listener || + (isFunction(list.listener) && list.listener === listener)) { + delete this._events[type]; + if (this._events.removeListener) + this.emit('removeListener', type, listener); - for (i = list.length - 1; i >= 0; i--) { - if (list[i] === listener || list[i].listener === listener) { - originalListener = list[i].listener; - position = i; - break; - } - } - - if (position < 0) - return this; - - if (position === 0) - list.shift(); - else - spliceOne(list, position); - - if (list.length === 1) - events[type] = list[0]; - - if (events.removeListener) - this.emit('removeListener', type, originalListener || listener); + } else if (isObject(list)) { + for (i = length; i-- > 0;) { + if (list[i] === listener || + (list[i].listener && list[i].listener === listener)) { + position = i; + break; } + } + if (position < 0) return this; - }; -EventEmitter.prototype.removeAllListeners = - function removeAllListeners(type) { - var listeners, events, i; + if (list.length === 1) { + list.length = 0; + delete this._events[type]; + } else { + list.splice(position, 1); + } - events = this._events; - if (!events) - return this; + if (this._events.removeListener) + this.emit('removeListener', type, listener); + } - // not listening for removeListener, no need to emit - if (!events.removeListener) { - if (arguments.length === 0) { - this._events = objectCreate(null); - this._eventsCount = 0; - } else if (events[type]) { - if (--this._eventsCount === 0) - this._events = objectCreate(null); - else - delete events[type]; - } - return this; - } + return this; +}; - // emit removeListener for all listeners on all events - if (arguments.length === 0) { - var keys = objectKeys(events); - var key; - for (i = 0; i < keys.length; ++i) { - key = keys[i]; - if (key === 'removeListener') continue; - this.removeAllListeners(key); - } - this.removeAllListeners('removeListener'); - this._events = objectCreate(null); - this._eventsCount = 0; - return this; - } +EventEmitter.prototype.removeAllListeners = function(type) { + var key, listeners; - listeners = events[type]; + if (!this._events) + return this; - if (typeof listeners === 'function') { - this.removeListener(type, listeners); - } else if (listeners) { - // LIFO order - for (i = listeners.length - 1; i >= 0; i--) { - this.removeListener(type, listeners[i]); - } - } + // not listening for removeListener, no need to emit + if (!this._events.removeListener) { + if (arguments.length === 0) + this._events = {}; + else if (this._events[type]) + delete this._events[type]; + return this; + } - return this; - }; + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + for (key in this._events) { + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = {}; + return this; + } -EventEmitter.prototype.listeners = function listeners(type) { - var evlistener; - var ret; - var events = this._events; + listeners = this._events[type]; - if (!events) - ret = []; - else { - evlistener = events[type]; - if (!evlistener) - ret = []; - else if (typeof evlistener === 'function') - ret = [evlistener.listener || evlistener]; - else - ret = unwrapListeners(evlistener); + if (isFunction(listeners)) { + this.removeListener(type, listeners); + } else if (listeners) { + // LIFO order + while (listeners.length) + this.removeListener(type, listeners[listeners.length - 1]); } + delete this._events[type]; - return ret; + return this; }; -EventEmitter.listenerCount = function(emitter, type) { - if (typeof emitter.listenerCount === 'function') { - return emitter.listenerCount(type); - } else { - return listenerCount.call(emitter, type); - } +EventEmitter.prototype.listeners = function(type) { + var ret; + if (!this._events || !this._events[type]) + ret = []; + else if (isFunction(this._events[type])) + ret = [this._events[type]]; + else + ret = this._events[type].slice(); + return ret; }; -EventEmitter.prototype.listenerCount = listenerCount; -function listenerCount(type) { - var events = this._events; +EventEmitter.prototype.listenerCount = function(type) { + if (this._events) { + var evlistener = this._events[type]; - if (events) { - var evlistener = events[type]; - - if (typeof evlistener === 'function') { + if (isFunction(evlistener)) return 1; - } else if (evlistener) { + else if (evlistener) return evlistener.length; - } } - return 0; -} +}; -EventEmitter.prototype.eventNames = function eventNames() { - return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : []; +EventEmitter.listenerCount = function(emitter, type) { + return emitter.listenerCount(type); }; -// About 1.5x faster than the two-arg version of Array#splice(). -function spliceOne(list, index) { - for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) - list[i] = list[k]; - list.pop(); +function isFunction(arg) { + return typeof arg === 'function'; } -function arrayClone(arr, n) { - var copy = new Array(n); - for (var i = 0; i < n; ++i) - copy[i] = arr[i]; - return copy; +function isNumber(arg) { + return typeof arg === 'number'; } -function unwrapListeners(arr) { - var ret = new Array(arr.length); - for (var i = 0; i < ret.length; ++i) { - ret[i] = arr[i].listener || arr[i]; - } - return ret; +function isObject(arg) { + return typeof arg === 'object' && arg !== null; } -function objectCreatePolyfill(proto) { - var F = function() {}; - F.prototype = proto; - return new F; -} -function objectKeysPolyfill(obj) { - var keys = []; - for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k)) { - keys.push(k); - } - return k; -} -function functionBindPolyfill(context) { - var fn = this; - return function () { - return fn.apply(context, arguments); - }; +function isUndefined(arg) { + return arg === void 0; } },{}],32:[function(require,module,exports){ @@ -24668,18 +24454,14 @@ function writeMediaSection(transceiver, caps, type, stream, dtlsRole) { } if (transceiver.rtpSender) { - var trackId = transceiver.rtpSender._initialTrackId || - transceiver.rtpSender.track.id; - transceiver.rtpSender._initialTrackId = trackId; // spec. var msid = 'msid:' + (stream ? stream.id : '-') + ' ' + - trackId + '\r\n'; + transceiver.rtpSender.track.id + '\r\n'; sdp += 'a=' + msid; - // for Chrome. Legacy should no longer be required. + + // for Chrome. sdp += 'a=ssrc:' + transceiver.sendEncodingParameters[0].ssrc + ' ' + msid; - - // RTX if (transceiver.sendEncodingParameters[0].rtx) { sdp += 'a=ssrc:' + transceiver.sendEncodingParameters[0].rtx.ssrc + ' ' + msid; @@ -24852,14 +24634,6 @@ function maybeAddCandidate(iceTransport, candidate) { function makeError(name, description) { var e = new Error(description); e.name = name; - // legacy error codes from https://heycam.github.io/webidl/#idl-DOMException-error-names - e.code = { - NotSupportedError: 9, - InvalidStateError: 11, - InvalidAccessError: 15, - TypeError: undefined, - OperationError: undefined - }[name]; return e; } @@ -24911,7 +24685,6 @@ module.exports = function(window, edgeVersion) { this.signalingState = 'stable'; this.iceConnectionState = 'new'; - this.connectionState = 'new'; this.iceGatheringState = 'new'; config = JSON.parse(JSON.stringify(config || {})); @@ -24978,7 +24751,6 @@ module.exports = function(window, edgeVersion) { RTCPeerConnection.prototype.onremovestream = null; RTCPeerConnection.prototype.onsignalingstatechange = null; RTCPeerConnection.prototype.oniceconnectionstatechange = null; - RTCPeerConnection.prototype.onconnectionstatechange = null; RTCPeerConnection.prototype.onicegatheringstatechange = null; RTCPeerConnection.prototype.onnegotiationneeded = null; RTCPeerConnection.prototype.ondatachannel = null; @@ -25011,8 +24783,8 @@ module.exports = function(window, edgeVersion) { }; // internal helper to create a transceiver object. - // (which is not yet the same as the WebRTC 1.0 transceiver) - RTCPeerConnection.prototype._createTransceiver = function(kind, doNotAdd) { + // (whih is not yet the same as the WebRTC 1.0 transceiver) + RTCPeerConnection.prototype._createTransceiver = function(kind) { var hasBundleTransport = this.transceivers.length > 0; var transceiver = { track: null, @@ -25039,9 +24811,7 @@ module.exports = function(window, edgeVersion) { transceiver.iceTransport = transports.iceTransport; transceiver.dtlsTransport = transports.dtlsTransport; } - if (!doNotAdd) { - this.transceivers.push(transceiver); - } + this.transceivers.push(transceiver); return transceiver; }; @@ -25243,36 +25013,22 @@ module.exports = function(window, edgeVersion) { } // RTCIceCandidate doesn't have a component, needs to be added cand.component = 1; - // also the usernameFragment. TODO: update SDP to take both variants. - cand.ufrag = iceGatherer.getLocalParameters().usernameFragment; - var serializedCandidate = SDPUtils.writeCandidate(cand); event.candidate = Object.assign(event.candidate, SDPUtils.parseCandidate(serializedCandidate)); - event.candidate.candidate = serializedCandidate; - event.candidate.toJSON = function() { - return { - candidate: event.candidate.candidate, - sdpMid: event.candidate.sdpMid, - sdpMLineIndex: event.candidate.sdpMLineIndex, - usernameFragment: event.candidate.usernameFragment - }; - }; } // update local description. - var sections = SDPUtils.getMediaSections(pc.localDescription.sdp); + var sections = SDPUtils.splitSections(pc.localDescription.sdp); if (!end) { - sections[event.candidate.sdpMLineIndex] += + sections[event.candidate.sdpMLineIndex + 1] += 'a=' + event.candidate.candidate + '\r\n'; } else { - sections[event.candidate.sdpMLineIndex] += + sections[event.candidate.sdpMLineIndex + 1] += 'a=end-of-candidates\r\n'; } - pc.localDescription.sdp = - SDPUtils.getDescription(pc.localDescription.sdp) + - sections.join(''); + pc.localDescription.sdp = sections.join(''); var complete = pc.transceivers.every(function(transceiver) { return transceiver.iceGatherer && transceiver.iceGatherer.state === 'completed'; @@ -25308,7 +25064,6 @@ module.exports = function(window, edgeVersion) { var pc = this; var iceTransport = new window.RTCIceTransport(null); iceTransport.onicestatechange = function() { - pc._updateIceConnectionState(); pc._updateConnectionState(); }; @@ -25378,8 +25133,6 @@ module.exports = function(window, edgeVersion) { } if (transceiver.recvEncodingParameters.length) { params.encodings = transceiver.recvEncodingParameters; - } else { - params.encodings = [{}]; } params.rtcp = { compound: transceiver.rtcpParameters.compound @@ -25442,7 +25195,7 @@ module.exports = function(window, edgeVersion) { var rejected = SDPUtils.isRejected(mediaSection) && SDPUtils.matchPrefix(mediaSection, 'a=bundle-only').length === 0; - if (!rejected && !transceiver.rejected) { + if (!rejected && !transceiver.isDatachannel) { var remoteIceParameters = SDPUtils.getIceParameters( mediaSection, sessionpart); var remoteDtlsParameters = SDPUtils.getDtlsParameters( @@ -25539,23 +25292,14 @@ module.exports = function(window, edgeVersion) { var mid = SDPUtils.getMid(mediaSection) || SDPUtils.generateIdentifier(); // Reject datachannels which are not implemented yet. - if ((kind === 'application' && protocol === 'DTLS/SCTP') || rejected) { - // TODO: this is dangerous in the case where a non-rejected m-line - // becomes rejected. + if (kind === 'application' && protocol === 'DTLS/SCTP') { pc.transceivers[sdpMLineIndex] = { mid: mid, - kind: kind, - rejected: true + isDatachannel: true }; return; } - if (!rejected && pc.transceivers[sdpMLineIndex] && - pc.transceivers[sdpMLineIndex].rejected) { - // recycle a rejected transceiver. - pc.transceivers[sdpMLineIndex] = pc._createTransceiver(kind, true); - } - var transceiver; var iceGatherer; var iceTransport; @@ -25885,44 +25629,6 @@ module.exports = function(window, edgeVersion) { }, 0); }; - // Update the ice connection state. - RTCPeerConnection.prototype._updateIceConnectionState = function() { - var newState; - var states = { - 'new': 0, - closed: 0, - checking: 0, - connected: 0, - completed: 0, - disconnected: 0, - failed: 0 - }; - this.transceivers.forEach(function(transceiver) { - states[transceiver.iceTransport.state]++; - }); - - newState = 'new'; - if (states.failed > 0) { - newState = 'failed'; - } else if (states.checking > 0) { - newState = 'checking'; - } else if (states.disconnected > 0) { - newState = 'disconnected'; - } else if (states.new > 0) { - newState = 'new'; - } else if (states.connected > 0) { - newState = 'connected'; - } else if (states.completed > 0) { - newState = 'completed'; - } - - if (newState !== this.iceConnectionState) { - this.iceConnectionState = newState; - var event = new Event('iceconnectionstatechange'); - this._dispatchEvent('iceconnectionstatechange', event); - } - }; - // Update the connection state. RTCPeerConnection.prototype._updateConnectionState = function() { var newState; @@ -25930,6 +25636,7 @@ module.exports = function(window, edgeVersion) { 'new': 0, closed: 0, connecting: 0, + checking: 0, connected: 0, completed: 0, disconnected: 0, @@ -25945,20 +25652,20 @@ module.exports = function(window, edgeVersion) { newState = 'new'; if (states.failed > 0) { newState = 'failed'; - } else if (states.connecting > 0) { + } else if (states.connecting > 0 || states.checking > 0) { newState = 'connecting'; } else if (states.disconnected > 0) { newState = 'disconnected'; } else if (states.new > 0) { newState = 'new'; - } else if (states.connected > 0) { + } else if (states.connected > 0 || states.completed > 0) { newState = 'connected'; } - if (newState !== this.connectionState) { - this.connectionState = newState; - var event = new Event('connectionstatechange'); - this._dispatchEvent('connectionstatechange', event); + if (newState !== this.iceConnectionState) { + this.iceConnectionState = newState; + var event = new Event('iceconnectionstatechange'); + this._dispatchEvent('iceconnectionstatechange', event); } }; @@ -26062,27 +25769,6 @@ module.exports = function(window, edgeVersion) { codec.parameters['level-asymmetry-allowed'] === undefined) { codec.parameters['level-asymmetry-allowed'] = '1'; } - - // for subsequent offers, we might have to re-use the payload - // type of the last offer. - if (transceiver.remoteCapabilities && - transceiver.remoteCapabilities.codecs) { - transceiver.remoteCapabilities.codecs.forEach(function(remoteCodec) { - if (codec.name.toLowerCase() === remoteCodec.name.toLowerCase() && - codec.clockRate === remoteCodec.clockRate) { - codec.preferredPayloadType = remoteCodec.payloadType; - } - }); - } - }); - localCapabilities.headerExtensions.forEach(function(hdrExt) { - var remoteExtensions = transceiver.remoteCapabilities && - transceiver.remoteCapabilities.headerExtensions || []; - remoteExtensions.forEach(function(rHdrExt) { - if (hdrExt.uri === rHdrExt.uri) { - hdrExt.id = rHdrExt.id; - } - }); }); // generate an ssrc now, to be used later in rtpSender.send @@ -26149,12 +25835,6 @@ module.exports = function(window, edgeVersion) { 'Can not call createAnswer after close')); } - if (!(pc.signalingState === 'have-remote-offer' || - pc.signalingState === 'have-local-pranswer')) { - return Promise.reject(makeError('InvalidStateError', - 'Can not call createAnswer in signalingState ' + pc.signalingState)); - } - var sdp = SDPUtils.writeSessionBoilerplate(pc._sdpSessionId, pc._sdpSessionVersion++); if (pc.usingBundle) { @@ -26162,24 +25842,15 @@ module.exports = function(window, edgeVersion) { return t.mid; }).join(' ') + '\r\n'; } - var mediaSectionsInOffer = SDPUtils.getMediaSections( - pc.remoteDescription.sdp).length; + var mediaSectionsInOffer = SDPUtils.splitSections( + pc.remoteDescription.sdp).length - 1; pc.transceivers.forEach(function(transceiver, sdpMLineIndex) { if (sdpMLineIndex + 1 > mediaSectionsInOffer) { return; } - if (transceiver.rejected) { - if (transceiver.kind === 'application') { - sdp += 'm=application 0 DTLS/SCTP 5000\r\n'; - } else if (transceiver.kind === 'audio') { - sdp += 'm=audio 0 UDP/TLS/RTP/SAVPF 0\r\n' + - 'a=rtpmap:0 PCMU/8000\r\n'; - } else if (transceiver.kind === 'video') { - sdp += 'm=video 0 UDP/TLS/RTP/SAVPF 120\r\n' + - 'a=rtpmap:120 VP8/90000\r\n'; - } - sdp += 'c=IN IP4 0.0.0.0\r\n' + - 'a=inactive\r\n' + + if (transceiver.isDatachannel) { + sdp += 'm=application 0 DTLS/SCTP 5000\r\n' + + 'c=IN IP4 0.0.0.0\r\n' + 'a=mid:' + transceiver.mid + '\r\n'; return; } @@ -26245,15 +25916,13 @@ module.exports = function(window, edgeVersion) { 'Can not add ICE candidate without a remote description')); } else if (!candidate || candidate.candidate === '') { for (var j = 0; j < pc.transceivers.length; j++) { - if (pc.transceivers[j].rejected) { + if (pc.transceivers[j].isDatachannel) { continue; } pc.transceivers[j].iceTransport.addRemoteCandidate({}); - sections = SDPUtils.getMediaSections(pc.remoteDescription.sdp); - sections[j] += 'a=end-of-candidates\r\n'; - pc.remoteDescription.sdp = - SDPUtils.getDescription(pc.remoteDescription.sdp) + - sections.join(''); + sections = SDPUtils.splitSections(pc.remoteDescription.sdp); + sections[j + 1] += 'a=end-of-candidates\r\n'; + pc.remoteDescription.sdp = sections.join(''); if (pc.usingBundle) { break; } @@ -26270,7 +25939,7 @@ module.exports = function(window, edgeVersion) { } var transceiver = pc.transceivers[sdpMLineIndex]; if (transceiver) { - if (transceiver.rejected) { + if (transceiver.isDatachannel) { return resolve(); } var cand = Object.keys(candidate.candidate).length > 0 ? @@ -26298,13 +25967,11 @@ module.exports = function(window, edgeVersion) { if (candidateString.indexOf('a=') === 0) { candidateString = candidateString.substr(2); } - sections = SDPUtils.getMediaSections(pc.remoteDescription.sdp); - sections[sdpMLineIndex] += 'a=' + + sections = SDPUtils.splitSections(pc.remoteDescription.sdp); + sections[sdpMLineIndex + 1] += 'a=' + (cand.type ? candidateString : 'end-of-candidates') + '\r\n'; - pc.remoteDescription.sdp = - SDPUtils.getDescription(pc.remoteDescription.sdp) + - sections.join(''); + pc.remoteDescription.sdp = sections.join(''); } else { return reject(makeError('OperationError', 'Can not add ICE candidate')); @@ -26736,13 +26403,6 @@ var grammar = module.exports = { reg: /^framerate:(\d+(?:$|\.\d+))/, format: 'framerate:%s' }, - { // RFC4570 - //a=source-filter: incl IN IP4 239.5.2.31 10.1.15.5 - name: 'sourceFilter', - reg: /^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/, - names: ['filterMode', 'netType', 'addressTypes', 'destAddress', 'srcList'], - format: 'source-filter: %s %s %s %s %s' - }, { // any a= that we don't understand is kepts verbatim on media.invalid push: 'invalid', names: ['value'] @@ -27046,19 +26706,6 @@ SDPUtils.splitSections = function(blob) { }); }; -// returns the session description. -SDPUtils.getDescription = function(blob) { - var sections = SDPUtils.splitSections(blob); - return sections && sections[0]; -}; - -// returns the individual media sections. -SDPUtils.getMediaSections = function(blob) { - var sections = SDPUtils.splitSections(blob); - sections.shift(); - return sections; -}; - // Returns lines that start with a certain prefix. SDPUtils.matchPrefix = function(blob, prefix) { return SDPUtils.splitLines(blob).filter(function(line) { @@ -27136,9 +26783,9 @@ SDPUtils.writeCandidate = function(candidate) { sdp.push('tcptype'); sdp.push(candidate.tcpType); } - if (candidate.usernameFragment || candidate.ufrag) { + if (candidate.ufrag) { sdp.push('ufrag'); - sdp.push(candidate.usernameFragment || candidate.ufrag); + sdp.push(candidate.ufrag); } return 'candidate:' + sdp.join(' '); }; @@ -27667,28 +27314,15 @@ SDPUtils.isRejected = function(mediaSection) { SDPUtils.parseMLine = function(mediaSection) { var lines = SDPUtils.splitLines(mediaSection); - var parts = lines[0].substr(2).split(' '); + var mline = lines[0].split(' '); return { - kind: parts[0], - port: parseInt(parts[1], 10), - protocol: parts[2], - fmt: parts.slice(3).join(' ') + kind: mline[0].substr(2), + port: parseInt(mline[1], 10), + protocol: mline[2], + fmt: mline.slice(3).join(' ') }; }; -SDPUtils.parseOLine = function(mediaSection) { - var line = SDPUtils.matchPrefix(mediaSection, 'o=')[0]; - var parts = line.substr(2).split(' '); - return { - username: parts[0], - sessionId: parts[1], - sessionVersion: parseInt(parts[2], 10), - netType: parts[3], - addressType: parts[4], - address: parts[5], - }; -} - // Expose public methods. if (typeof module === 'object') { module.exports = SDPUtils; @@ -27745,6 +27379,14 @@ module.exports = function(dependencies, opts) { var logging = utils.log; var browserDetails = utils.detectBrowser(window); + // Export to the adapter global object visible in the browser. + var adapter = { + browserDetails: browserDetails, + extractVersion: utils.extractVersion, + disableLog: utils.disableLog, + disableWarnings: utils.disableWarnings + }; + // Uncomment the line below if you want logging to occur, including logging // for the switch statement below. Can also be turned on in the browser via // adapter.disableLog(false), but then logging from the switch statement below @@ -27758,15 +27400,6 @@ module.exports = function(dependencies, opts) { var safariShim = require('./safari/safari_shim') || null; var commonShim = require('./common_shim') || null; - // Export to the adapter global object visible in the browser. - var adapter = { - browserDetails: browserDetails, - commonShim: commonShim, - extractVersion: utils.extractVersion, - disableLog: utils.disableLog, - disableWarnings: utils.disableWarnings - }; - // Shim browser if found. switch (browserDetails.browser) { case 'chrome': @@ -27789,8 +27422,6 @@ module.exports = function(dependencies, opts) { chromeShim.shimGetSendersWithDtmf(window); commonShim.shimRTCIceCandidate(window); - commonShim.shimMaxMessageSize(window); - commonShim.shimSendThrowTypeError(window); break; case 'firefox': if (!firefoxShim || !firefoxShim.shimPeerConnection || @@ -27810,8 +27441,6 @@ module.exports = function(dependencies, opts) { firefoxShim.shimRemoveStream(window); commonShim.shimRTCIceCandidate(window); - commonShim.shimMaxMessageSize(window); - commonShim.shimSendThrowTypeError(window); break; case 'edge': if (!edgeShim || !edgeShim.shimPeerConnection || !options.shimEdge) { @@ -27828,9 +27457,6 @@ module.exports = function(dependencies, opts) { edgeShim.shimReplaceTrack(window); // the edge shim implements the full RTCIceCandidate object. - - commonShim.shimMaxMessageSize(window); - commonShim.shimSendThrowTypeError(window); break; case 'safari': if (!safariShim || !options.shimSafari) { @@ -27851,8 +27477,6 @@ module.exports = function(dependencies, opts) { safariShim.shimCreateOfferLegacy(window); commonShim.shimRTCIceCandidate(window); - commonShim.shimMaxMessageSize(window); - commonShim.shimSendThrowTypeError(window); break; default: logging('Unsupported browser!'); @@ -27942,13 +27566,6 @@ module.exports = { } return origSetRemoteDescription.apply(pc, arguments); }; - } else if (!('RTCRtpTransceiver' in window)) { - utils.wrapPeerConnectionEvent(window, 'track', function(e) { - if (!e.transceiver) { - e.transceiver = {receiver: e.receiver}; - } - return e; - }); } }, @@ -28419,7 +28036,7 @@ module.exports = { var browserDetails = utils.detectBrowser(window); // The RTCPeerConnection object. - if (!window.RTCPeerConnection && window.webkitRTCPeerConnection) { + if (!window.RTCPeerConnection) { window.RTCPeerConnection = function(pcConfig, pcConstraints) { // Translate iceTransportPolicy to iceTransports, // see https://code.google.com/p/webrtc/issues/detail?id=4869 @@ -28748,16 +28365,12 @@ module.exports = function(window) { return { name: { PermissionDeniedError: 'NotAllowedError', - PermissionDismissedError: 'NotAllowedError', - InvalidStateError: 'NotAllowedError', + InvalidStateError: 'NotReadableError', DevicesNotFoundError: 'NotFoundError', ConstraintNotSatisfiedError: 'OverconstrainedError', TrackStartError: 'NotReadableError', - MediaDeviceFailedDueToShutdown: 'NotAllowedError', - MediaDeviceKillSwitchOn: 'NotAllowedError', - TabCaptureError: 'AbortError', - ScreenCaptureError: 'AbortError', - DeviceCaptureError: 'AbortError' + MediaDeviceFailedDueToShutdown: 'NotReadableError', + MediaDeviceKillSwitchOn: 'NotReadableError' }[e.name] || e.name, message: e.message, constraint: e.constraintName, @@ -28869,12 +28482,63 @@ module.exports = function(window) { var SDPUtils = require('sdp'); var utils = require('./utils'); +// Wraps the peerconnection event eventNameToWrap in a function +// which returns the modified event object. +function wrapPeerConnectionEvent(window, eventNameToWrap, wrapper) { + if (!window.RTCPeerConnection) { + return; + } + var proto = window.RTCPeerConnection.prototype; + var nativeAddEventListener = proto.addEventListener; + proto.addEventListener = function(nativeEventName, cb) { + if (nativeEventName !== eventNameToWrap) { + return nativeAddEventListener.apply(this, arguments); + } + var wrappedCallback = function(e) { + cb(wrapper(e)); + }; + this._eventMap = this._eventMap || {}; + this._eventMap[cb] = wrappedCallback; + return nativeAddEventListener.apply(this, [nativeEventName, + wrappedCallback]); + }; + + var nativeRemoveEventListener = proto.removeEventListener; + proto.removeEventListener = function(nativeEventName, cb) { + if (nativeEventName !== eventNameToWrap || !this._eventMap + || !this._eventMap[cb]) { + return nativeRemoveEventListener.apply(this, arguments); + } + var unwrappedCb = this._eventMap[cb]; + delete this._eventMap[cb]; + return nativeRemoveEventListener.apply(this, [nativeEventName, + unwrappedCb]); + }; + + Object.defineProperty(proto, 'on' + eventNameToWrap, { + get: function() { + return this['_on' + eventNameToWrap]; + }, + set: function(cb) { + if (this['_on' + eventNameToWrap]) { + this.removeEventListener(eventNameToWrap, + this['_on' + eventNameToWrap]); + delete this['_on' + eventNameToWrap]; + } + if (cb) { + this.addEventListener(eventNameToWrap, + this['_on' + eventNameToWrap] = cb); + } + } + }); +} + module.exports = { shimRTCIceCandidate: function(window) { // foundation is arbitrarily chosen as an indicator for full support for // https://w3c.github.io/webrtc-pc/#rtcicecandidate-interface - if (!window.RTCIceCandidate || (window.RTCIceCandidate && 'foundation' in - window.RTCIceCandidate.prototype)) { + if (window.RTCIceCandidate && 'foundation' in + window.RTCIceCandidate.prototype) { return; } @@ -28887,31 +28551,27 @@ module.exports = { args.candidate = args.candidate.substr(2); } - if (args.candidate && args.candidate.length) { - // Augment the native candidate with the parsed fields. - var nativeCandidate = new NativeRTCIceCandidate(args); - var parsedCandidate = SDPUtils.parseCandidate(args.candidate); - var augmentedCandidate = Object.assign(nativeCandidate, - parsedCandidate); - - // Add a serializer that does not serialize the extra attributes. - augmentedCandidate.toJSON = function() { - return { - candidate: augmentedCandidate.candidate, - sdpMid: augmentedCandidate.sdpMid, - sdpMLineIndex: augmentedCandidate.sdpMLineIndex, - usernameFragment: augmentedCandidate.usernameFragment, - }; + // Augment the native candidate with the parsed fields. + var nativeCandidate = new NativeRTCIceCandidate(args); + var parsedCandidate = SDPUtils.parseCandidate(args.candidate); + var augmentedCandidate = Object.assign(nativeCandidate, + parsedCandidate); + + // Add a serializer that does not serialize the extra attributes. + augmentedCandidate.toJSON = function() { + return { + candidate: augmentedCandidate.candidate, + sdpMid: augmentedCandidate.sdpMid, + sdpMLineIndex: augmentedCandidate.sdpMLineIndex, + usernameFragment: augmentedCandidate.usernameFragment, }; - return augmentedCandidate; - } - return new NativeRTCIceCandidate(args); + }; + return augmentedCandidate; }; - window.RTCIceCandidate.prototype = NativeRTCIceCandidate.prototype; // Hook up the augmented candidate in onicecandidate and // addEventListener('icecandidate', ...) - utils.wrapPeerConnectionEvent(window, 'icecandidate', function(e) { + wrapPeerConnectionEvent(window, 'icecandidate', function(e) { if (e.candidate) { Object.defineProperty(e, 'candidate', { value: new window.RTCIceCandidate(e.candidate), @@ -28973,169 +28633,6 @@ module.exports = { } return nativeSetAttribute.apply(this, arguments); }; - }, - - shimMaxMessageSize: function(window) { - if (window.RTCSctpTransport || !window.RTCPeerConnection) { - return; - } - var browserDetails = utils.detectBrowser(window); - - if (!('sctp' in window.RTCPeerConnection.prototype)) { - Object.defineProperty(window.RTCPeerConnection.prototype, 'sctp', { - get: function() { - return typeof this._sctp === 'undefined' ? null : this._sctp; - } - }); - } - - var sctpInDescription = function(description) { - var sections = SDPUtils.splitSections(description.sdp); - sections.shift(); - return sections.some(function(mediaSection) { - var mLine = SDPUtils.parseMLine(mediaSection); - return mLine && mLine.kind === 'application' - && mLine.protocol.indexOf('SCTP') !== -1; - }); - }; - - var getRemoteFirefoxVersion = function(description) { - // TODO: Is there a better solution for detecting Firefox? - var match = description.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/); - if (match === null || match.length < 2) { - return -1; - } - var version = parseInt(match[1], 10); - // Test for NaN (yes, this is ugly) - return version !== version ? -1 : version; - }; - - var getCanSendMaxMessageSize = function(remoteIsFirefox) { - // Every implementation we know can send at least 64 KiB. - // Note: Although Chrome is technically able to send up to 256 KiB, the - // data does not reach the other peer reliably. - // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=8419 - var canSendMaxMessageSize = 65536; - if (browserDetails.browser === 'firefox') { - if (browserDetails.version < 57) { - if (remoteIsFirefox === -1) { - // FF < 57 will send in 16 KiB chunks using the deprecated PPID - // fragmentation. - canSendMaxMessageSize = 16384; - } else { - // However, other FF (and RAWRTC) can reassemble PPID-fragmented - // messages. Thus, supporting ~2 GiB when sending. - canSendMaxMessageSize = 2147483637; - } - } else { - // Currently, all FF >= 57 will reset the remote maximum message size - // to the default value when a data channel is created at a later - // stage. :( - // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1426831 - canSendMaxMessageSize = - browserDetails.version === 57 ? 65535 : 65536; - } - } - return canSendMaxMessageSize; - }; - - var getMaxMessageSize = function(description, remoteIsFirefox) { - // Note: 65536 bytes is the default value from the SDP spec. Also, - // every implementation we know supports receiving 65536 bytes. - var maxMessageSize = 65536; - - // FF 57 has a slightly incorrect default remote max message size, so - // we need to adjust it here to avoid a failure when sending. - // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1425697 - if (browserDetails.browser === 'firefox' - && browserDetails.version === 57) { - maxMessageSize = 65535; - } - - var match = SDPUtils.matchPrefix(description.sdp, 'a=max-message-size:'); - if (match.length > 0) { - maxMessageSize = parseInt(match[0].substr(19), 10); - } else if (browserDetails.browser === 'firefox' && - remoteIsFirefox !== -1) { - // If the maximum message size is not present in the remote SDP and - // both local and remote are Firefox, the remote peer can receive - // ~2 GiB. - maxMessageSize = 2147483637; - } - return maxMessageSize; - }; - - var origSetRemoteDescription = - window.RTCPeerConnection.prototype.setRemoteDescription; - window.RTCPeerConnection.prototype.setRemoteDescription = function() { - var pc = this; - pc._sctp = null; - - if (sctpInDescription(arguments[0])) { - // Check if the remote is FF. - var isFirefox = getRemoteFirefoxVersion(arguments[0]); - - // Get the maximum message size the local peer is capable of sending - var canSendMMS = getCanSendMaxMessageSize(isFirefox); - - // Get the maximum message size of the remote peer. - var remoteMMS = getMaxMessageSize(arguments[0], isFirefox); - - // Determine final maximum message size - var maxMessageSize; - if (canSendMMS === 0 && remoteMMS === 0) { - maxMessageSize = Number.POSITIVE_INFINITY; - } else if (canSendMMS === 0 || remoteMMS === 0) { - maxMessageSize = Math.max(canSendMMS, remoteMMS); - } else { - maxMessageSize = Math.min(canSendMMS, remoteMMS); - } - - // Create a dummy RTCSctpTransport object and the 'maxMessageSize' - // attribute. - var sctp = {}; - Object.defineProperty(sctp, 'maxMessageSize', { - get: function() { - return maxMessageSize; - } - }); - pc._sctp = sctp; - } - - return origSetRemoteDescription.apply(pc, arguments); - }; - }, - - shimSendThrowTypeError: function(window) { - if (!window.RTCPeerConnection) { - return; - } - - // Note: Although Firefox >= 57 has a native implementation, the maximum - // message size can be reset for all data channels at a later stage. - // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1426831 - - var origCreateDataChannel = - window.RTCPeerConnection.prototype.createDataChannel; - window.RTCPeerConnection.prototype.createDataChannel = function() { - var pc = this; - var dataChannel = origCreateDataChannel.apply(pc, arguments); - var origDataChannelSend = dataChannel.send; - - // Patch 'send' method - dataChannel.send = function() { - var dc = this; - var data = arguments[0]; - var length = data.length || data.size || data.byteLength; - if (length > pc.sctp.maxMessageSize) { - throw new DOMException('Message too large (can send a maximum of ' + - pc.sctp.maxMessageSize + ' bytes)', 'TypeError'); - } - return origDataChannelSend.apply(dc, arguments); - }; - - return dataChannel; - }; } }; @@ -29159,11 +28656,16 @@ module.exports = { var browserDetails = utils.detectBrowser(window); if (window.RTCIceGatherer) { + // ORTC defines an RTCIceCandidate object but no constructor. + // Not implemented in Edge. if (!window.RTCIceCandidate) { window.RTCIceCandidate = function(args) { return args; }; } + // ORTC does not have a session description object but + // other browsers (i.e. Chrome) that will support both PC and ORTC + // in the future might have this defined already. if (!window.RTCSessionDescription) { window.RTCSessionDescription = function(args) { return args; @@ -29202,11 +28704,6 @@ module.exports = { } }); } - // Edge currently only implements the RTCDtmfSender, not the - // RTCDTMFSender alias. See http://draft.ortc.org/#rtcdtmfsender2* - if (window.RTCDtmfSender && !window.RTCDTMFSender) { - window.RTCDTMFSender = window.RTCDtmfSender; - } window.RTCPeerConnection = shimRTCPeerConnection(window, browserDetails.version); @@ -29792,26 +29289,24 @@ module.exports = { return this._onaddstream; }, set: function(f) { - var pc = this; if (this._onaddstream) { this.removeEventListener('addstream', this._onaddstream); this.removeEventListener('track', this._onaddstreampoly); } this.addEventListener('addstream', this._onaddstream = f); this.addEventListener('track', this._onaddstreampoly = function(e) { - e.streams.forEach(function(stream) { - if (!pc._remoteStreams) { - pc._remoteStreams = []; - } - if (pc._remoteStreams.indexOf(stream) >= 0) { - return; - } - pc._remoteStreams.push(stream); - var event = new Event('addstream'); - event.stream = stream; - pc.dispatchEvent(event); - }); - }); + var stream = e.streams[0]; + if (!this._remoteStreams) { + this._remoteStreams = []; + } + if (this._remoteStreams.indexOf(stream) >= 0) { + return; + } + this._remoteStreams.push(stream); + var event = new Event('addstream'); + event.stream = e.streams[0]; + this.dispatchEvent(event); + }.bind(this)); } }); } @@ -29951,17 +29446,9 @@ module.exports = { }); if (offerOptions.offerToReceiveAudio === false && audioTransceiver) { if (audioTransceiver.direction === 'sendrecv') { - if (audioTransceiver.setDirection) { - audioTransceiver.setDirection('sendonly'); - } else { - audioTransceiver.direction = 'sendonly'; - } + audioTransceiver.setDirection('sendonly'); } else if (audioTransceiver.direction === 'recvonly') { - if (audioTransceiver.setDirection) { - audioTransceiver.setDirection('inactive'); - } else { - audioTransceiver.direction = 'inactive'; - } + audioTransceiver.setDirection('inactive'); } } else if (offerOptions.offerToReceiveAudio === true && !audioTransceiver) { @@ -30015,61 +29502,9 @@ function extractVersion(uastring, expr, pos) { return match && match.length >= pos && parseInt(match[pos], 10); } -// Wraps the peerconnection event eventNameToWrap in a function -// which returns the modified event object. -function wrapPeerConnectionEvent(window, eventNameToWrap, wrapper) { - if (!window.RTCPeerConnection) { - return; - } - var proto = window.RTCPeerConnection.prototype; - var nativeAddEventListener = proto.addEventListener; - proto.addEventListener = function(nativeEventName, cb) { - if (nativeEventName !== eventNameToWrap) { - return nativeAddEventListener.apply(this, arguments); - } - var wrappedCallback = function(e) { - cb(wrapper(e)); - }; - this._eventMap = this._eventMap || {}; - this._eventMap[cb] = wrappedCallback; - return nativeAddEventListener.apply(this, [nativeEventName, - wrappedCallback]); - }; - - var nativeRemoveEventListener = proto.removeEventListener; - proto.removeEventListener = function(nativeEventName, cb) { - if (nativeEventName !== eventNameToWrap || !this._eventMap - || !this._eventMap[cb]) { - return nativeRemoveEventListener.apply(this, arguments); - } - var unwrappedCb = this._eventMap[cb]; - delete this._eventMap[cb]; - return nativeRemoveEventListener.apply(this, [nativeEventName, - unwrappedCb]); - }; - - Object.defineProperty(proto, 'on' + eventNameToWrap, { - get: function() { - return this['_on' + eventNameToWrap]; - }, - set: function(cb) { - if (this['_on' + eventNameToWrap]) { - this.removeEventListener(eventNameToWrap, - this['_on' + eventNameToWrap]); - delete this['_on' + eventNameToWrap]; - } - if (cb) { - this.addEventListener(eventNameToWrap, - this['_on' + eventNameToWrap] = cb); - } - } - }); -} - // Utility methods. module.exports = { extractVersion: extractVersion, - wrapPeerConnectionEvent: wrapPeerConnectionEvent, disableLog: function(bool) { if (typeof bool !== 'boolean') { return new Error('Argument type: ' + typeof bool + @@ -30135,23 +29570,36 @@ module.exports = { return result; } - if (navigator.mozGetUserMedia) { // Firefox. + // Firefox. + if (navigator.mozGetUserMedia) { result.browser = 'firefox'; result.version = extractVersion(navigator.userAgent, /Firefox\/(\d+)\./, 1); } else if (navigator.webkitGetUserMedia) { - // Chrome, Chromium, Webview, Opera. - // Version matches Chrome/WebRTC version. - result.browser = 'chrome'; - result.version = extractVersion(navigator.userAgent, + // Chrome, Chromium, Webview, Opera, all use the chrome shim for now + if (window.webkitRTCPeerConnection) { + result.browser = 'chrome'; + result.version = extractVersion(navigator.userAgent, /Chrom(e|ium)\/(\d+)\./, 2); + } else { // Safari (in an unpublished version) or unknown webkit-based. + if (navigator.userAgent.match(/Version\/(\d+).(\d+)/)) { + result.browser = 'safari'; + result.version = extractVersion(navigator.userAgent, + /AppleWebKit\/(\d+)\./, 1); + } else { // unknown webkit-based browser. + result.browser = 'Unsupported webkit-based browser ' + + 'with GUM support but no WebRTC support.'; + return result; + } + } } else if (navigator.mediaDevices && navigator.userAgent.match(/Edge\/(\d+).(\d+)$/)) { // Edge. result.browser = 'edge'; result.version = extractVersion(navigator.userAgent, /Edge\/(\d+).(\d+)$/, 2); - } else if (window.RTCPeerConnection && - navigator.userAgent.match(/AppleWebKit\/(\d+)\./)) { // Safari. + } else if (navigator.mediaDevices && + navigator.userAgent.match(/AppleWebKit\/(\d+)\./)) { + // Safari, with webkitGetUserMedia removed. result.browser = 'safari'; result.version = extractVersion(navigator.userAgent, /AppleWebKit\/(\d+)\./, 1); @@ -30169,7 +29617,7 @@ module.exports={ "name": "jssip", "title": "JsSIP", "description": "the Javascript SIP library", - "version": "3.2.7", + "version": "3.2.8", "homepage": "http://jssip.net", "author": "José Luis Millán (https://github.com/jmillan)", "contributors": [ @@ -30225,4 +29673,4 @@ module.exports={ } },{}]},{},[8])(8) -}); +}); \ No newline at end of file diff --git a/dist/jssip.min.js b/dist/jssip.min.js index 867944e04..bdc2ce4e8 100644 --- a/dist/jssip.min.js +++ b/dist/jssip.min.js @@ -1,9 +1,9 @@ /* - * JsSIP v3.2.7 + * JsSIP v3.2.8 * the Javascript SIP library * Copyright: 2012-2018 José Luis Millán (https://github.com/jmillan) * Homepage: http://jssip.net * License: MIT */ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).JsSIP=e()}}(function(){return function(){return function e(t,n,r){function i(o,a){if(!n[o]){if(!t[o]){var l="function"==typeof require&&require;if(!a&&l)return l(o,!0);if(s)return s(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var c=n[o]={exports:{}};t[o][0].call(c.exports,function(e){var n=t[o][1][e];return i(n||e)},c,c.exports,e,t,n,r)}return n[o].exports}for(var s="function"==typeof require&&require,o=0;o0)return t}},connection_recovery_min_interval:function(e){if(r.isDecimal(e)){var t=Number(e);if(t>0)return t}},contact_uri:function(e){if("string"==typeof e){var t=s.parse(e,"SIP_URI");if(-1!==t)return t}},display_name:function(e){return-1===s.parse('"'+e+'"',"display_name")?void 0:e},instance_id:function(e){return/^uuid:/i.test(e)&&(e=e.substr(5)),-1===s.parse(e,"uuid")?void 0:e},no_answer_timeout:function(e){if(r.isDecimal(e)){var t=Number(e);if(t>0)return t}},session_timers:function(e){if("boolean"==typeof e)return e},session_timers_refresh_method:function(e){if("string"==typeof e&&((e=e.toUpperCase())===i.INVITE||e===i.UPDATE))return e},password:function(e){return String(e)},realm:function(e){return String(e)},ha1:function(e){return String(e)},register:function(e){if("boolean"==typeof e)return e},register_expires:function(e){if(r.isDecimal(e)){var t=Number(e);if(t>0)return t}},registrar_server:function(e){/^sip:/i.test(e)||(e=i.SIP+":"+e);var t=o.parse(e);return t?t.user?void 0:t:void 0},use_preloaded_route:function(e){if("boolean"==typeof e)return e}}};n.load=function(e,t){for(var n in u.mandatory){if(!t.hasOwnProperty(n))throw new l.ConfigurationError(n);var i=t[n],s=u.mandatory[n](i);if(void 0===s)throw new l.ConfigurationError(n,i);e[n]=s}for(var o in u.optional)if(t.hasOwnProperty(o)){var a=t[o];if(r.isEmpty(a))continue;var c=u.optional[o](a);if(void 0===c)throw new l.ConfigurationError(o,a);e[o]=c}}},{"./Constants":2,"./Exceptions":6,"./Grammar":7,"./Socket":20,"./URI":25,"./Utils":26}],2:[function(e,t,n){"use strict";var r=e("../package.json");t.exports={USER_AGENT:r.title+" "+r.version,SIP:"sip",SIPS:"sips",causes:{CONNECTION_ERROR:"Connection Error",REQUEST_TIMEOUT:"Request Timeout",SIP_FAILURE_CODE:"SIP Failure Code",INTERNAL_ERROR:"Internal Error",BUSY:"Busy",REJECTED:"Rejected",REDIRECTED:"Redirected",UNAVAILABLE:"Unavailable",NOT_FOUND:"Not Found",ADDRESS_INCOMPLETE:"Address Incomplete",INCOMPATIBLE_SDP:"Incompatible SDP",MISSING_SDP:"Missing SDP",AUTHENTICATION_ERROR:"Authentication Error",BYE:"Terminated",WEBRTC_ERROR:"WebRTC Error",CANCELED:"Canceled",NO_ANSWER:"No Answer",EXPIRES:"Expires",NO_ACK:"No ACK",DIALOG_ERROR:"Dialog Error",USER_DENIED_MEDIA_ACCESS:"User Denied Media Access",BAD_MEDIA_DESCRIPTION:"Bad Media Description",RTP_TIMEOUT:"RTP Timeout"},SIP_ERROR_CAUSES:{REDIRECTED:[300,301,302,305,380],BUSY:[486,600],REJECTED:[403,603],NOT_FOUND:[404,604],UNAVAILABLE:[480,410,408,430],ADDRESS_INCOMPLETE:[484,424],INCOMPATIBLE_SDP:[488,606],AUTHENTICATION_ERROR:[401,407]},ACK:"ACK",BYE:"BYE",CANCEL:"CANCEL",INFO:"INFO",INVITE:"INVITE",MESSAGE:"MESSAGE",NOTIFY:"NOTIFY",OPTIONS:"OPTIONS",REGISTER:"REGISTER",REFER:"REFER",UPDATE:"UPDATE",SUBSCRIBE:"SUBSCRIBE",REASON_PHRASE:{100:"Trying",180:"Ringing",181:"Call Is Being Forwarded",182:"Queued",183:"Session Progress",199:"Early Dialog Terminated",200:"OK",202:"Accepted",204:"No Notification",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",305:"Use Proxy",380:"Alternative Service",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",410:"Gone",412:"Conditional Request Failed",413:"Request Entity Too Large",414:"Request-URI Too Long",415:"Unsupported Media Type",416:"Unsupported URI Scheme",417:"Unknown Resource-Priority",420:"Bad Extension",421:"Extension Required",422:"Session Interval Too Small",423:"Interval Too Brief",424:"Bad Location Information",428:"Use Identity Header",429:"Provide Referrer Identity",430:"Flow Failed",433:"Anonymity Disallowed",436:"Bad Identity-Info",437:"Unsupported Certificate",438:"Invalid Identity Header",439:"First Hop Lacks Outbound Support",440:"Max-Breadth Exceeded",469:"Bad Info Package",470:"Consent Needed",478:"Unresolvable Destination",480:"Temporarily Unavailable",481:"Call/Transaction Does Not Exist",482:"Loop Detected",483:"Too Many Hops",484:"Address Incomplete",485:"Ambiguous",486:"Busy Here",487:"Request Terminated",488:"Not Acceptable Here",489:"Bad Event",491:"Request Pending",493:"Undecipherable",494:"Security Agreement Required",500:"JsSIP Internal Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Server Time-out",505:"Version Not Supported",513:"Message Too Large",580:"Precondition Failure",600:"Busy Everywhere",603:"Decline",604:"Does Not Exist Anywhere",606:"Not Acceptable"},ALLOWED_METHODS:"INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO",ACCEPTED_BODY_TYPES:"application/sdp, application/dtmf-relay",MAX_FORWARDS:69,SESSION_EXPIRES:90,MIN_SESSION_EXPIRES:60}},{"../package.json":51}],3:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n3&&void 0!==arguments[3]?arguments[3]:c.STATUS_CONFIRMED;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._owner=t,this._ua=t._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,!n.hasHeader("contact"))return{error:"unable to create a Dialog without Contact header field"};n instanceof i.IncomingResponse&&(s=n.status_code<200?c.STATUS_EARLY:c.STATUS_CONFIRMED);var o=n.parseHeader("contact");"UAS"===r?(this._id={call_id:n.call_id,local_tag:n.to_tag,remote_tag:n.from_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=s,this._remote_seqnum=n.cseq,this._local_uri=n.parseHeader("to").uri,this._remote_uri=n.parseHeader("from").uri,this._remote_target=o.uri,this._route_set=n.getHeaders("record-route"),this._ack_seqnum=this._remote_seqnum):"UAC"===r&&(this._id={call_id:n.call_id,local_tag:n.from_tag,remote_tag:n.to_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=s,this._local_seqnum=n.cseq,this._local_uri=n.parseHeader("from").uri,this._remote_uri=n.parseHeader("to").uri,this._remote_target=o.uri,this._route_set=n.getHeaders("record-route").reverse(),this._ack_seqnum=null),this._ua.newDialog(this),u("new "+r+" dialog created with status "+(this._state===c.STATUS_EARLY?"EARLY":"CONFIRMED"))}return r(e,[{key:"update",value:function(e,t){this._state=c.STATUS_CONFIRMED,u("dialog "+this._id.toString()+" changed to CONFIRMED state"),"UAC"===t&&(this._route_set=e.getHeaders("record-route").reverse())}},{key:"terminate",value:function(){u("dialog "+this._id.toString()+" deleted"),this._ua.destroyDialog(this)}},{key:"sendRequest",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=l.cloneArray(n.extraHeaders),i=n.eventHandlers||{},s=n.body||null,o=this._createRequest(e,r,s);i.onAuthenticated=function(){t._local_seqnum+=1};return new a(this,o,i).send(),o}},{key:"receiveRequest",value:function(e){this._checkInDialogRequest(e)&&(e.method===s.ACK&&null!==this._ack_seqnum?this._ack_seqnum=null:e.method===s.INVITE&&(this._ack_seqnum=e.cseq),this._owner.receiveRequest(e))}},{key:"_createRequest",value:function(e,t,n){t=l.cloneArray(t),this._local_seqnum||(this._local_seqnum=Math.floor(1e4*Math.random()));var r=e===s.CANCEL||e===s.ACK?this._local_seqnum:this._local_seqnum+=1;return new i.OutgoingRequest(e,this._remote_target,this._ua,{cseq:r,call_id:this._id.call_id,from_uri:this._local_uri,from_tag:this._id.local_tag,to_uri:this._remote_uri,to_tag:this._id.remote_tag,route_set:this._route_set},t,n)}},{key:"_checkInDialogRequest",value:function(e){var t=this;if(this._remote_seqnum)if(e.cseqthis._remote_seqnum&&(this._remote_seqnum=e.cseq);else this._remote_seqnum=e.cseq;if(e.method===s.INVITE||e.method===s.UPDATE&&e.body){if(!0===this._uac_pending_reply)e.reply(491);else{if(!0===this._uas_pending_reply){var n=1+(10*Math.random()|0);return e.reply(500,null,["Retry-After:"+n]),!1}this._uas_pending_reply=!0;e.server_transaction.on("stateChanged",function n(){e.server_transaction.state!==o.C.STATUS_ACCEPTED&&e.server_transaction.state!==o.C.STATUS_COMPLETED&&e.server_transaction.state!==o.C.STATUS_TERMINATED||(e.server_transaction.removeListener("stateChanged",n),t._uas_pending_reply=!1)})}e.hasHeader("contact")&&e.server_transaction.on("stateChanged",function(){e.server_transaction.state===o.C.STATUS_ACCEPTED&&(t._remote_target=e.parseHeader("contact").uri)})}else e.method===s.NOTIFY&&e.hasHeader("contact")&&e.server_transaction.on("stateChanged",function(){e.server_transaction.state===o.C.STATUS_COMPLETED&&(t._remote_target=e.parseHeader("contact").uri)});return!0}},{key:"id",get:function(){return this._id}},{key:"local_seqnum",get:function(){return this._local_seqnum},set:function(e){this._local_seqnum=e}},{key:"owner",get:function(){return this._owner}},{key:"uac_pending_reply",get:function(){return this._uac_pending_reply},set:function(e){this._uac_pending_reply=e}},{key:"uas_pending_reply",get:function(){return this._uas_pending_reply}}]),e}()},{"./Constants":2,"./Dialog/RequestSender":4,"./SIPMessage":19,"./Transactions":22,"./Utils":26,debug:29}],4:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n=200&&e.status_code<300?this._eventHandlers.onSuccessResponse(e):e.status_code>=300&&this._eventHandlers.onErrorResponse(e):(this._request.cseq.value=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout(function(){t._dialog.owner.status!==o.C.STATUS_TERMINATED&&(t._reattempt=!0,t._request_sender.send())},1e3)):e.status_code>=200&&e.status_code<300?this._eventHandlers.onSuccessResponse(e):e.status_code>=300&&this._eventHandlers.onErrorResponse(e)}},{key:"request",get:function(){return this._request}}]),e}()},{"../Constants":2,"../RTCSession":12,"../RequestSender":18,"../Transactions":22}],5:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:null;if(this._algorithm=t.algorithm,this._realm=t.realm,this._nonce=t.nonce,this._opaque=t.opaque,this._stale=t.stale,this._algorithm){if("MD5"!==this._algorithm)return o('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return o("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return o("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return o("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return o('authenticate() | no plain SIP password, and stored `realm` does not match the given `realm`, cannot authenticate [stored:"%s", given:"%s"]',this._credentials.realm,this._realm),!1}if(t.qop)if(t.qop.indexOf("auth-int")>-1)this._qop="auth-int";else{if(!(t.qop.indexOf("auth")>-1))return o('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;this._qop="auth"}else this._qop=null;this._method=n,this._uri=r,this._cnonce=l||i.createRandomToken(12),this._nc+=1;var u=Number(this._nc).toString(16);this._ncHex="00000000".substr(0,8-u.length)+u,4294967296===this._nc&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=i.calculateMD5(this._credentials.username+":"+this._realm+":"+this._credentials.password):this._ha1=this._credentials.ha1;var c=void 0;return"auth"===this._qop?(c=i.calculateMD5(this._method+":"+this._uri),this._response=i.calculateMD5(this._ha1+":"+this._nonce+":"+this._ncHex+":"+this._cnonce+":auth:"+c)):"auth-int"===this._qop?(c=i.calculateMD5(this._method+":"+this._uri+":"+i.calculateMD5(a||"")),this._response=i.calculateMD5(this._ha1+":"+this._nonce+":"+this._ncHex+":"+this._cnonce+":auth-int:"+c)):null===this._qop&&(c=i.calculateMD5(this._method+":"+this._uri),this._response=i.calculateMD5(this._ha1+":"+this._nonce+":"+c)),s("authenticate() | response generated"),!0}},{key:"toString",value:function(){var e=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return e.push("algorithm="+this._algorithm),e.push('username="'+this._credentials.username+'"'),e.push('realm="'+this._realm+'"'),e.push('nonce="'+this._nonce+'"'),e.push('uri="'+this._uri+'"'),e.push('response="'+this._response+'"'),this._opaque&&e.push('opaque="'+this._opaque+'"'),this._qop&&(e.push("qop="+this._qop),e.push('cnonce="'+this._cnonce+'"'),e.push("nc="+this._ncHex)),"Digest "+e.join(", ")}}]),e}()},{"./Utils":26,debug:29}],6:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var o=function(e){s(t,Error);function t(e,n){r(this,t);var s=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return s.code=1,s.name="CONFIGURATION_ERROR",s.parameter=e,s.value=n,s.message=s.value?"Invalid value "+JSON.stringify(s.value)+' for parameter "'+s.parameter+'"':"Missing parameter: "+s.parameter,s}return t}(),a=function(e){s(t,Error);function t(e){r(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.code=2,n.name="INVALID_STATE_ERROR",n.status=e,n.message="Invalid status: "+e,n}return t}(),l=function(e){s(t,Error);function t(e){r(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.code=3,n.name="NOT_SUPPORTED_ERROR",n.message=e,n}return t}(),u=function(e){s(t,Error);function t(e){r(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.code=4,n.name="NOT_READY_ERROR",n.message=e,n}return t}();t.exports={ConfigurationError:o,InvalidStateError:a,NotSupportedError:l,NotReadyError:u}},{}],7:[function(e,t,n){"use strict";t.exports=function(){function t(e){return'"'+e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var n={parse:function(n,r){var i={CRLF:c,DIGIT:d,ALPHA:h,HEXDIG:f,WSP:p,OCTET:_,DQUOTE:m,SP:v,HTAB:g,alphanum:y,reserved:T,unreserved:C,mark:S,escaped:E,LWS:b,SWS:R,HCOLON:A,TEXT_UTF8_TRIM:w,TEXT_UTF8char:I,UTF8_NONASCII:P,UTF8_CONT:k,LHEX:function(){var e;null===(e=d())&&(/^[a-f]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===o&&u("[a-f]")));return e},token:O,token_nodot:x,separators:function(){var e;40===n.charCodeAt(s)?(e="(",s++):(e=null,0===o&&u('"("'));null===e&&(41===n.charCodeAt(s)?(e=")",s++):(e=null,0===o&&u('")"')),null===e&&(60===n.charCodeAt(s)?(e="<",s++):(e=null,0===o&&u('"<"')),null===e&&(62===n.charCodeAt(s)?(e=">",s++):(e=null,0===o&&u('">"')),null===e&&(64===n.charCodeAt(s)?(e="@",s++):(e=null,0===o&&u('"@"')),null===e&&(44===n.charCodeAt(s)?(e=",",s++):(e=null,0===o&&u('","')),null===e&&(59===n.charCodeAt(s)?(e=";",s++):(e=null,0===o&&u('";"')),null===e&&(58===n.charCodeAt(s)?(e=":",s++):(e=null,0===o&&u('":"')),null===e&&(92===n.charCodeAt(s)?(e="\\",s++):(e=null,0===o&&u('"\\\\"')),null===e&&null===(e=m())&&(47===n.charCodeAt(s)?(e="/",s++):(e=null,0===o&&u('"/"')),null===e&&(91===n.charCodeAt(s)?(e="[",s++):(e=null,0===o&&u('"["')),null===e&&(93===n.charCodeAt(s)?(e="]",s++):(e=null,0===o&&u('"]"')),null===e&&(63===n.charCodeAt(s)?(e="?",s++):(e=null,0===o&&u('"?"')),null===e&&(61===n.charCodeAt(s)?(e="=",s++):(e=null,0===o&&u('"="')),null===e&&(123===n.charCodeAt(s)?(e="{",s++):(e=null,0===o&&u('"{"')),null===e&&(125===n.charCodeAt(s)?(e="}",s++):(e=null,0===o&&u('"}"')),null===e&&null===(e=v())&&(e=g()))))))))))))))));return e},word:D,STAR:N,SLASH:U,EQUAL:M,LPAREN:L,RPAREN:q,RAQUOT:F,LAQUOT:H,COMMA:j,SEMI:G,COLON:B,LDQUOT:V,RDQUOT:W,comment:function e(){var t,n,r;var i;i=s;t=L();if(null!==t){for(n=[],null===(r=J())&&null===(r=$())&&(r=e());null!==r;)n.push(r),null===(r=J())&&null===(r=$())&&(r=e());null!==n&&null!==(r=q())?t=[t,n,r]:(t=null,s=i)}else t=null,s=i;return t},ctext:J,quoted_string:z,quoted_string_clean:K,qdtext:Y,quoted_pair:$,SIP_URI_noparams:Q,SIP_URI:X,uri_scheme:Z,uri_scheme_sips:ee,uri_scheme_sip:te,userinfo:ne,user:re,user_unreserved:ie,password:se,hostport:oe,host:ae,hostname:le,domainlabel:ue,toplabel:ce,IPv6reference:de,IPv6address:he,h16:fe,ls32:pe,IPv4address:_e,dec_octet:me,port:ve,uri_parameters:ge,uri_parameter:ye,transport_param:Te,user_param:Ce,method_param:Se,ttl_param:Ee,maddr_param:be,lr_param:Re,other_param:Ae,pname:we,pvalue:Ie,paramchar:Pe,param_unreserved:ke,headers:Oe,header:xe,hname:De,hvalue:Ne,hnv_unreserved:Ue,Request_Response:function(){var e;null===(e=dt())&&(e=Me());return e},Request_Line:Me,Request_URI:Le,absoluteURI:qe,hier_part:Fe,net_path:He,abs_path:je,opaque_part:Ge,uric:Be,uric_no_slash:Ve,path_segments:We,segment:Je,param:ze,pchar:Ke,scheme:Ye,authority:$e,srvr:Qe,reg_name:Xe,query:Ze,SIP_Version:et,INVITEm:tt,ACKm:nt,OPTIONSm:rt,BYEm:it,CANCELm:st,REGISTERm:ot,SUBSCRIBEm:at,NOTIFYm:lt,REFERm:ut,Method:ct,Status_Line:dt,Status_Code:ht,extension_code:ft,Reason_Phrase:pt,Allow_Events:function(){var e,t,n,r,i,o;if(i=s,null!==(e=qt())){for(t=[],o=s,null!==(n=j())&&null!==(r=qt())?n=[n,r]:(n=null,s=o);null!==n;)t.push(n),o=s,null!==(n=j())&&null!==(r=qt())?n=[n,r]:(n=null,s=o);null!==t?e=[e,t]:(e=null,s=i)}else e=null,s=i;return e},Call_ID:function(){var e,t,r,i,a,l;i=s,a=s,null!==(e=D())?(l=s,64===n.charCodeAt(s)?(t="@",s++):(t=null,0===o&&u('"@"')),null!==t&&null!==(r=D())?t=[t,r]:(t=null,s=l),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=a)):(e=null,s=a);null!==e&&(c=i,e=void(Hn=n.substring(s,c)));var c;null===e&&(s=i);return e},Contact:function(){var e,t,n,r,i,o,a;if(i=s,null===(e=N()))if(o=s,null!==(e=_t())){for(t=[],a=s,null!==(n=j())&&null!==(r=_t())?n=[n,r]:(n=null,s=a);null!==n;)t.push(n),a=s,null!==(n=j())&&null!==(r=_t())?n=[n,r]:(n=null,s=a);null!==t?e=[e,t]:(e=null,s=o)}else e=null,s=o;null!==e&&(e=function(e){var t,n;for(n=Hn.multi_header.length,t=0;ta&&(a=s,l=[]),l.push(e))}function c(){var e;return"\r\n"===n.substr(s,2)?(e="\r\n",s+=2):(e=null,0===o&&u('"\\r\\n"')),e}function d(){var e;return/^[0-9]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===o&&u("[0-9]")),e}function h(){var e;return/^[a-zA-Z]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===o&&u("[a-zA-Z]")),e}function f(){var e;return/^[0-9a-fA-F]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===o&&u("[0-9a-fA-F]")),e}function p(){var e;return null===(e=v())&&(e=g()),e}function _(){var e;return/^[\0-\xFF]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===o&&u("[\\0-\\xFF]")),e}function m(){var e;return/^["]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===o&&u('["]')),e}function v(){var e;return 32===n.charCodeAt(s)?(e=" ",s++):(e=null,0===o&&u('" "')),e}function g(){var e;return 9===n.charCodeAt(s)?(e="\t",s++):(e=null,0===o&&u('"\\t"')),e}function y(){var e;return/^[a-zA-Z0-9]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===o&&u("[a-zA-Z0-9]")),e}function T(){var e;return 59===n.charCodeAt(s)?(e=";",s++):(e=null,0===o&&u('";"')),null===e&&(47===n.charCodeAt(s)?(e="/",s++):(e=null,0===o&&u('"/"')),null===e&&(63===n.charCodeAt(s)?(e="?",s++):(e=null,0===o&&u('"?"')),null===e&&(58===n.charCodeAt(s)?(e=":",s++):(e=null,0===o&&u('":"')),null===e&&(64===n.charCodeAt(s)?(e="@",s++):(e=null,0===o&&u('"@"')),null===e&&(38===n.charCodeAt(s)?(e="&",s++):(e=null,0===o&&u('"&"')),null===e&&(61===n.charCodeAt(s)?(e="=",s++):(e=null,0===o&&u('"="')),null===e&&(43===n.charCodeAt(s)?(e="+",s++):(e=null,0===o&&u('"+"')),null===e&&(36===n.charCodeAt(s)?(e="$",s++):(e=null,0===o&&u('"$"')),null===e&&(44===n.charCodeAt(s)?(e=",",s++):(e=null,0===o&&u('","'))))))))))),e}function C(){var e;return null===(e=y())&&(e=S()),e}function S(){var e;return 45===n.charCodeAt(s)?(e="-",s++):(e=null,0===o&&u('"-"')),null===e&&(95===n.charCodeAt(s)?(e="_",s++):(e=null,0===o&&u('"_"')),null===e&&(46===n.charCodeAt(s)?(e=".",s++):(e=null,0===o&&u('"."')),null===e&&(33===n.charCodeAt(s)?(e="!",s++):(e=null,0===o&&u('"!"')),null===e&&(126===n.charCodeAt(s)?(e="~",s++):(e=null,0===o&&u('"~"')),null===e&&(42===n.charCodeAt(s)?(e="*",s++):(e=null,0===o&&u('"*"')),null===e&&(39===n.charCodeAt(s)?(e="'",s++):(e=null,0===o&&u('"\'"')),null===e&&(40===n.charCodeAt(s)?(e="(",s++):(e=null,0===o&&u('"("')),null===e&&(41===n.charCodeAt(s)?(e=")",s++):(e=null,0===o&&u('")"')))))))))),e}function E(){var e,t,r,i,a;return i=s,a=s,37===n.charCodeAt(s)?(e="%",s++):(e=null,0===o&&u('"%"')),null!==e&&null!==(t=f())&&null!==(r=f())?e=[e,t,r]:(e=null,s=a),null!==e&&(e=e.join("")),null===e&&(s=i),e}function b(){var e,t,n,r,i,o;for(r=s,i=s,o=s,e=[],t=p();null!==t;)e.push(t),t=p();if(null!==e&&null!==(t=c())?e=[e,t]:(e=null,s=o),null!==(e=null!==e?e:"")){if(null!==(n=p()))for(t=[];null!==n;)t.push(n),n=p();else t=null;null!==t?e=[e,t]:(e=null,s=i)}else e=null,s=i;return null!==e&&(e=" "),null===e&&(s=r),e}function R(){var e;return e=null!==(e=b())?e:""}function A(){var e,t,r,i,a;for(i=s,a=s,e=[],null===(t=v())&&(t=g());null!==t;)e.push(t),null===(t=v())&&(t=g());return null!==e?(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===o&&u('":"')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=a)):(e=null,s=a),null!==e&&(e=":"),null===e&&(s=i),e}function w(){var e,t,r,i,o,a,l;if(o=s,a=s,null!==(t=I()))for(e=[];null!==t;)e.push(t),t=I();else e=null;if(null!==e){for(t=[],l=s,r=[],i=b();null!==i;)r.push(i),i=b();for(null!==r&&null!==(i=I())?r=[r,i]:(r=null,s=l);null!==r;){for(t.push(r),l=s,r=[],i=b();null!==i;)r.push(i),i=b();null!==r&&null!==(i=I())?r=[r,i]:(r=null,s=l)}null!==t?e=[e,t]:(e=null,s=a)}else e=null,s=a;null!==e&&(u=o,e=n.substring(s,u));var u;return null===e&&(s=o),e}function I(){var e;return/^[!-~]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===o&&u("[!-~]")),null===e&&(e=P()),e}function P(){var e;return/^[\x80-\uFFFF]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===o&&u("[\\x80-\\uFFFF]")),e}function k(){var e;return/^[\x80-\xBF]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===o&&u("[\\x80-\\xBF]")),e}function O(){var e,t,r;if(r=s,null===(t=y())&&(45===n.charCodeAt(s)?(t="-",s++):(t=null,0===o&&u('"-"')),null===t&&(46===n.charCodeAt(s)?(t=".",s++):(t=null,0===o&&u('"."')),null===t&&(33===n.charCodeAt(s)?(t="!",s++):(t=null,0===o&&u('"!"')),null===t&&(37===n.charCodeAt(s)?(t="%",s++):(t=null,0===o&&u('"%"')),null===t&&(42===n.charCodeAt(s)?(t="*",s++):(t=null,0===o&&u('"*"')),null===t&&(95===n.charCodeAt(s)?(t="_",s++):(t=null,0===o&&u('"_"')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===o&&u('"+"')),null===t&&(96===n.charCodeAt(s)?(t="`",s++):(t=null,0===o&&u('"`"')),null===t&&(39===n.charCodeAt(s)?(t="'",s++):(t=null,0===o&&u('"\'"')),null===t&&(126===n.charCodeAt(s)?(t="~",s++):(t=null,0===o&&u('"~"')))))))))))),null!==t)for(e=[];null!==t;)e.push(t),null===(t=y())&&(45===n.charCodeAt(s)?(t="-",s++):(t=null,0===o&&u('"-"')),null===t&&(46===n.charCodeAt(s)?(t=".",s++):(t=null,0===o&&u('"."')),null===t&&(33===n.charCodeAt(s)?(t="!",s++):(t=null,0===o&&u('"!"')),null===t&&(37===n.charCodeAt(s)?(t="%",s++):(t=null,0===o&&u('"%"')),null===t&&(42===n.charCodeAt(s)?(t="*",s++):(t=null,0===o&&u('"*"')),null===t&&(95===n.charCodeAt(s)?(t="_",s++):(t=null,0===o&&u('"_"')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===o&&u('"+"')),null===t&&(96===n.charCodeAt(s)?(t="`",s++):(t=null,0===o&&u('"`"')),null===t&&(39===n.charCodeAt(s)?(t="'",s++):(t=null,0===o&&u('"\'"')),null===t&&(126===n.charCodeAt(s)?(t="~",s++):(t=null,0===o&&u('"~"'))))))))))));else e=null;null!==e&&(i=r,e=n.substring(s,i));var i;return null===e&&(s=r),e}function x(){var e,t,r;if(r=s,null===(t=y())&&(45===n.charCodeAt(s)?(t="-",s++):(t=null,0===o&&u('"-"')),null===t&&(33===n.charCodeAt(s)?(t="!",s++):(t=null,0===o&&u('"!"')),null===t&&(37===n.charCodeAt(s)?(t="%",s++):(t=null,0===o&&u('"%"')),null===t&&(42===n.charCodeAt(s)?(t="*",s++):(t=null,0===o&&u('"*"')),null===t&&(95===n.charCodeAt(s)?(t="_",s++):(t=null,0===o&&u('"_"')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===o&&u('"+"')),null===t&&(96===n.charCodeAt(s)?(t="`",s++):(t=null,0===o&&u('"`"')),null===t&&(39===n.charCodeAt(s)?(t="'",s++):(t=null,0===o&&u('"\'"')),null===t&&(126===n.charCodeAt(s)?(t="~",s++):(t=null,0===o&&u('"~"'))))))))))),null!==t)for(e=[];null!==t;)e.push(t),null===(t=y())&&(45===n.charCodeAt(s)?(t="-",s++):(t=null,0===o&&u('"-"')),null===t&&(33===n.charCodeAt(s)?(t="!",s++):(t=null,0===o&&u('"!"')),null===t&&(37===n.charCodeAt(s)?(t="%",s++):(t=null,0===o&&u('"%"')),null===t&&(42===n.charCodeAt(s)?(t="*",s++):(t=null,0===o&&u('"*"')),null===t&&(95===n.charCodeAt(s)?(t="_",s++):(t=null,0===o&&u('"_"')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===o&&u('"+"')),null===t&&(96===n.charCodeAt(s)?(t="`",s++):(t=null,0===o&&u('"`"')),null===t&&(39===n.charCodeAt(s)?(t="'",s++):(t=null,0===o&&u('"\'"')),null===t&&(126===n.charCodeAt(s)?(t="~",s++):(t=null,0===o&&u('"~"')))))))))));else e=null;null!==e&&(i=r,e=n.substring(s,i));var i;return null===e&&(s=r),e}function D(){var e,t,r;if(r=s,null===(t=y())&&(45===n.charCodeAt(s)?(t="-",s++):(t=null,0===o&&u('"-"')),null===t&&(46===n.charCodeAt(s)?(t=".",s++):(t=null,0===o&&u('"."')),null===t&&(33===n.charCodeAt(s)?(t="!",s++):(t=null,0===o&&u('"!"')),null===t&&(37===n.charCodeAt(s)?(t="%",s++):(t=null,0===o&&u('"%"')),null===t&&(42===n.charCodeAt(s)?(t="*",s++):(t=null,0===o&&u('"*"')),null===t&&(95===n.charCodeAt(s)?(t="_",s++):(t=null,0===o&&u('"_"')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===o&&u('"+"')),null===t&&(96===n.charCodeAt(s)?(t="`",s++):(t=null,0===o&&u('"`"')),null===t&&(39===n.charCodeAt(s)?(t="'",s++):(t=null,0===o&&u('"\'"')),null===t&&(126===n.charCodeAt(s)?(t="~",s++):(t=null,0===o&&u('"~"')),null===t&&(40===n.charCodeAt(s)?(t="(",s++):(t=null,0===o&&u('"("')),null===t&&(41===n.charCodeAt(s)?(t=")",s++):(t=null,0===o&&u('")"')),null===t&&(60===n.charCodeAt(s)?(t="<",s++):(t=null,0===o&&u('"<"')),null===t&&(62===n.charCodeAt(s)?(t=">",s++):(t=null,0===o&&u('">"')),null===t&&(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===o&&u('":"')),null===t&&(92===n.charCodeAt(s)?(t="\\",s++):(t=null,0===o&&u('"\\\\"')),null===t&&null===(t=m())&&(47===n.charCodeAt(s)?(t="/",s++):(t=null,0===o&&u('"/"')),null===t&&(91===n.charCodeAt(s)?(t="[",s++):(t=null,0===o&&u('"["')),null===t&&(93===n.charCodeAt(s)?(t="]",s++):(t=null,0===o&&u('"]"')),null===t&&(63===n.charCodeAt(s)?(t="?",s++):(t=null,0===o&&u('"?"')),null===t&&(123===n.charCodeAt(s)?(t="{",s++):(t=null,0===o&&u('"{"')),null===t&&(125===n.charCodeAt(s)?(t="}",s++):(t=null,0===o&&u('"}"')))))))))))))))))))))))),null!==t)for(e=[];null!==t;)e.push(t),null===(t=y())&&(45===n.charCodeAt(s)?(t="-",s++):(t=null,0===o&&u('"-"')),null===t&&(46===n.charCodeAt(s)?(t=".",s++):(t=null,0===o&&u('"."')),null===t&&(33===n.charCodeAt(s)?(t="!",s++):(t=null,0===o&&u('"!"')),null===t&&(37===n.charCodeAt(s)?(t="%",s++):(t=null,0===o&&u('"%"')),null===t&&(42===n.charCodeAt(s)?(t="*",s++):(t=null,0===o&&u('"*"')),null===t&&(95===n.charCodeAt(s)?(t="_",s++):(t=null,0===o&&u('"_"')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===o&&u('"+"')),null===t&&(96===n.charCodeAt(s)?(t="`",s++):(t=null,0===o&&u('"`"')),null===t&&(39===n.charCodeAt(s)?(t="'",s++):(t=null,0===o&&u('"\'"')),null===t&&(126===n.charCodeAt(s)?(t="~",s++):(t=null,0===o&&u('"~"')),null===t&&(40===n.charCodeAt(s)?(t="(",s++):(t=null,0===o&&u('"("')),null===t&&(41===n.charCodeAt(s)?(t=")",s++):(t=null,0===o&&u('")"')),null===t&&(60===n.charCodeAt(s)?(t="<",s++):(t=null,0===o&&u('"<"')),null===t&&(62===n.charCodeAt(s)?(t=">",s++):(t=null,0===o&&u('">"')),null===t&&(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===o&&u('":"')),null===t&&(92===n.charCodeAt(s)?(t="\\",s++):(t=null,0===o&&u('"\\\\"')),null===t&&null===(t=m())&&(47===n.charCodeAt(s)?(t="/",s++):(t=null,0===o&&u('"/"')),null===t&&(91===n.charCodeAt(s)?(t="[",s++):(t=null,0===o&&u('"["')),null===t&&(93===n.charCodeAt(s)?(t="]",s++):(t=null,0===o&&u('"]"')),null===t&&(63===n.charCodeAt(s)?(t="?",s++):(t=null,0===o&&u('"?"')),null===t&&(123===n.charCodeAt(s)?(t="{",s++):(t=null,0===o&&u('"{"')),null===t&&(125===n.charCodeAt(s)?(t="}",s++):(t=null,0===o&&u('"}"'))))))))))))))))))))))));else e=null;null!==e&&(i=r,e=n.substring(s,i));var i;return null===e&&(s=r),e}function N(){var e,t,r,i,a;return i=s,a=s,null!==(e=R())?(42===n.charCodeAt(s)?(t="*",s++):(t=null,0===o&&u('"*"')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=a)):(e=null,s=a),null!==e&&(e="*"),null===e&&(s=i),e}function U(){var e,t,r,i,a;return i=s,a=s,null!==(e=R())?(47===n.charCodeAt(s)?(t="/",s++):(t=null,0===o&&u('"/"')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=a)):(e=null,s=a),null!==e&&(e="/"),null===e&&(s=i),e}function M(){var e,t,r,i,a;return i=s,a=s,null!==(e=R())?(61===n.charCodeAt(s)?(t="=",s++):(t=null,0===o&&u('"="')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=a)):(e=null,s=a),null!==e&&(e="="),null===e&&(s=i),e}function L(){var e,t,r,i,a;return i=s,a=s,null!==(e=R())?(40===n.charCodeAt(s)?(t="(",s++):(t=null,0===o&&u('"("')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=a)):(e=null,s=a),null!==e&&(e="("),null===e&&(s=i),e}function q(){var e,t,r,i,a;return i=s,a=s,null!==(e=R())?(41===n.charCodeAt(s)?(t=")",s++):(t=null,0===o&&u('")"')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=a)):(e=null,s=a),null!==e&&(e=")"),null===e&&(s=i),e}function F(){var e,t,r,i;return r=s,i=s,62===n.charCodeAt(s)?(e=">",s++):(e=null,0===o&&u('">"')),null!==e&&null!==(t=R())?e=[e,t]:(e=null,s=i),null!==e&&(e=">"),null===e&&(s=r),e}function H(){var e,t,r,i;return r=s,i=s,null!==(e=R())?(60===n.charCodeAt(s)?(t="<",s++):(t=null,0===o&&u('"<"')),null!==t?e=[e,t]:(e=null,s=i)):(e=null,s=i),null!==e&&(e="<"),null===e&&(s=r),e}function j(){var e,t,r,i,a;return i=s,a=s,null!==(e=R())?(44===n.charCodeAt(s)?(t=",",s++):(t=null,0===o&&u('","')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=a)):(e=null,s=a),null!==e&&(e=","),null===e&&(s=i),e}function G(){var e,t,r,i,a;return i=s,a=s,null!==(e=R())?(59===n.charCodeAt(s)?(t=";",s++):(t=null,0===o&&u('";"')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=a)):(e=null,s=a),null!==e&&(e=";"),null===e&&(s=i),e}function B(){var e,t,r,i,a;return i=s,a=s,null!==(e=R())?(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===o&&u('":"')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=a)):(e=null,s=a),null!==e&&(e=":"),null===e&&(s=i),e}function V(){var e,t,n,r;return n=s,r=s,null!==(e=R())&&null!==(t=m())?e=[e,t]:(e=null,s=r),null!==e&&(e='"'),null===e&&(s=n),e}function W(){var e,t,n,r;return n=s,r=s,null!==(e=m())&&null!==(t=R())?e=[e,t]:(e=null,s=r),null!==e&&(e='"'),null===e&&(s=n),e}function J(){var e;return/^[!-']/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===o&&u("[!-']")),null===e&&(/^[*-[]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===o&&u("[*-[]")),null===e&&(/^[\]-~]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===o&&u("[\\]-~]")),null===e&&null===(e=P())&&(e=b()))),e}function z(){var e,t,r,i,o,a;if(o=s,a=s,null!==(e=R()))if(null!==(t=m())){for(r=[],null===(i=Y())&&(i=$());null!==i;)r.push(i),null===(i=Y())&&(i=$());null!==r&&null!==(i=m())?e=[e,t,r,i]:(e=null,s=a)}else e=null,s=a;else e=null,s=a;null!==e&&(l=o,e=n.substring(s,l));var l;return null===e&&(s=o),e}function K(){var e,t,r,i,o,a;if(o=s,a=s,null!==(e=R()))if(null!==(t=m())){for(r=[],null===(i=Y())&&(i=$());null!==i;)r.push(i),null===(i=Y())&&(i=$());null!==r&&null!==(i=m())?e=[e,t,r,i]:(e=null,s=a)}else e=null,s=a;else e=null,s=a;null!==e&&(l=o,e=n.substring(s-1,l+1));var l;return null===e&&(s=o),e}function Y(){var e;return null===(e=b())&&(33===n.charCodeAt(s)?(e="!",s++):(e=null,0===o&&u('"!"')),null===e&&(/^[#-[]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===o&&u("[#-[]")),null===e&&(/^[\]-~]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===o&&u("[\\]-~]")),null===e&&(e=P())))),e}function $(){var e,t,r;return r=s,92===n.charCodeAt(s)?(e="\\",s++):(e=null,0===o&&u('"\\\\"')),null!==e?(/^[\0-\t]/.test(n.charAt(s))?(t=n.charAt(s),s++):(t=null,0===o&&u("[\\0-\\t]")),null===t&&(/^[\x0B-\f]/.test(n.charAt(s))?(t=n.charAt(s),s++):(t=null,0===o&&u("[\\x0B-\\f]")),null===t&&(/^[\x0E-]/.test(n.charAt(s))?(t=n.charAt(s),s++):(t=null,0===o&&u("[\\x0E-]")))),null!==t?e=[e,t]:(e=null,s=r)):(e=null,s=r),e}function Q(){var e,t,r,i,a,l;return a=s,l=s,null!==(e=Z())?(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===o&&u('":"')),null!==t&&null!==(r=null!==(r=ne())?r:"")&&null!==(i=oe())?e=[e,t,r,i]:(e=null,s=l)):(e=null,s=l),null!==e&&(e=function(e){try{Hn.uri=new qn(Hn.scheme,Hn.user,Hn.host,Hn.port),delete Hn.scheme,delete Hn.user,delete Hn.host,delete Hn.host_type,delete Hn.port}catch(e){Hn=-1}}()),null===e&&(s=a),e}function X(){var e,t,i,a,l,c,d,h;return d=s,h=s,null!==(e=Z())?(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===o&&u('":"')),null!==t&&null!==(i=null!==(i=ne())?i:"")&&null!==(a=oe())&&null!==(l=ge())&&null!==(c=null!==(c=Oe())?c:"")?e=[e,t,i,a,l,c]:(e=null,s=h)):(e=null,s=h),null!==e&&(e=function(e){try{Hn.uri=new qn(Hn.scheme,Hn.user,Hn.host,Hn.port,Hn.uri_params,Hn.uri_headers),delete Hn.scheme,delete Hn.user,delete Hn.host,delete Hn.host_type,delete Hn.port,delete Hn.uri_params,"SIP_URI"===r&&(Hn=Hn.uri)}catch(e){Hn=-1}}()),null===e&&(s=d),e}function Z(){var e;return null===(e=ee())&&(e=te()),e}function ee(){var e,t;t=s,"sips"===n.substr(s,4).toLowerCase()?(e=n.substr(s,4),s+=4):(e=null,0===o&&u('"sips"')),null!==e&&(r=e,e=void(Hn.scheme=r.toLowerCase()));var r;return null===e&&(s=t),e}function te(){var e,t;t=s,"sip"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===o&&u('"sip"')),null!==e&&(r=e,e=void(Hn.scheme=r.toLowerCase()));var r;return null===e&&(s=t),e}function ne(){var e,t,r,i,a,l;i=s,a=s,null!==(e=re())?(l=s,58===n.charCodeAt(s)?(t=":",s++):(t=null,0===o&&u('":"')),null!==t&&null!==(r=se())?t=[t,r]:(t=null,s=l),null!==(t=null!==t?t:"")?(64===n.charCodeAt(s)?(r="@",s++):(r=null,0===o&&u('"@"')),null!==r?e=[e,t,r]:(e=null,s=a)):(e=null,s=a)):(e=null,s=a),null!==e&&(c=i,e=void(Hn.user=decodeURIComponent(n.substring(s-1,c))));var c;return null===e&&(s=i),e}function re(){var e,t;if(null===(t=C())&&null===(t=E())&&(t=ie()),null!==t)for(e=[];null!==t;)e.push(t),null===(t=C())&&null===(t=E())&&(t=ie());else e=null;return e}function ie(){var e;return 38===n.charCodeAt(s)?(e="&",s++):(e=null,0===o&&u('"&"')),null===e&&(61===n.charCodeAt(s)?(e="=",s++):(e=null,0===o&&u('"="')),null===e&&(43===n.charCodeAt(s)?(e="+",s++):(e=null,0===o&&u('"+"')),null===e&&(36===n.charCodeAt(s)?(e="$",s++):(e=null,0===o&&u('"$"')),null===e&&(44===n.charCodeAt(s)?(e=",",s++):(e=null,0===o&&u('","')),null===e&&(59===n.charCodeAt(s)?(e=";",s++):(e=null,0===o&&u('";"')),null===e&&(63===n.charCodeAt(s)?(e="?",s++):(e=null,0===o&&u('"?"')),null===e&&(47===n.charCodeAt(s)?(e="/",s++):(e=null,0===o&&u('"/"'))))))))),e}function se(){var e,t,r;for(r=s,e=[],null===(t=C())&&null===(t=E())&&(38===n.charCodeAt(s)?(t="&",s++):(t=null,0===o&&u('"&"')),null===t&&(61===n.charCodeAt(s)?(t="=",s++):(t=null,0===o&&u('"="')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===o&&u('"+"')),null===t&&(36===n.charCodeAt(s)?(t="$",s++):(t=null,0===o&&u('"$"')),null===t&&(44===n.charCodeAt(s)?(t=",",s++):(t=null,0===o&&u('","')))))));null!==t;)e.push(t),null===(t=C())&&null===(t=E())&&(38===n.charCodeAt(s)?(t="&",s++):(t=null,0===o&&u('"&"')),null===t&&(61===n.charCodeAt(s)?(t="=",s++):(t=null,0===o&&u('"="')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===o&&u('"+"')),null===t&&(36===n.charCodeAt(s)?(t="$",s++):(t=null,0===o&&u('"$"')),null===t&&(44===n.charCodeAt(s)?(t=",",s++):(t=null,0===o&&u('","')))))));null!==e&&(i=r,e=void(Hn.password=n.substring(s,i)));var i;return null===e&&(s=r),e}function oe(){var e,t,r,i,a;return i=s,null!==(e=ae())?(a=s,58===n.charCodeAt(s)?(t=":",s++):(t=null,0===o&&u('":"')),null!==t&&null!==(r=ve())?t=[t,r]:(t=null,s=a),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=i)):(e=null,s=i),e}function ae(){var e,t;t=s,null===(e=le())&&null===(e=_e())&&(e=de()),null!==e&&(r=t,Hn.host=n.substring(s,r).toLowerCase(),e=Hn.host);var r;return null===e&&(s=t),e}function le(){var e,t,r,i,a,l;for(i=s,a=s,e=[],l=s,null!==(t=ue())?(46===n.charCodeAt(s)?(r=".",s++):(r=null,0===o&&u('"."')),null!==r?t=[t,r]:(t=null,s=l)):(t=null,s=l);null!==t;)e.push(t),l=s,null!==(t=ue())?(46===n.charCodeAt(s)?(r=".",s++):(r=null,0===o&&u('"."')),null!==r?t=[t,r]:(t=null,s=l)):(t=null,s=l);null!==e&&null!==(t=ce())?(46===n.charCodeAt(s)?(r=".",s++):(r=null,0===o&&u('"."')),null!==(r=null!==r?r:"")?e=[e,t,r]:(e=null,s=a)):(e=null,s=a),null!==e&&(c=i,Hn.host_type="domain",e=n.substring(s,c));var c;return null===e&&(s=i),e}function ue(){var e,t,r,i;if(i=s,null!==(e=y())){for(t=[],null===(r=y())&&(45===n.charCodeAt(s)?(r="-",s++):(r=null,0===o&&u('"-"')),null===r&&(95===n.charCodeAt(s)?(r="_",s++):(r=null,0===o&&u('"_"'))));null!==r;)t.push(r),null===(r=y())&&(45===n.charCodeAt(s)?(r="-",s++):(r=null,0===o&&u('"-"')),null===r&&(95===n.charCodeAt(s)?(r="_",s++):(r=null,0===o&&u('"_"'))));null!==t?e=[e,t]:(e=null,s=i)}else e=null,s=i;return e}function ce(){var e,t,r,i;if(i=s,null!==(e=h())){for(t=[],null===(r=y())&&(45===n.charCodeAt(s)?(r="-",s++):(r=null,0===o&&u('"-"')),null===r&&(95===n.charCodeAt(s)?(r="_",s++):(r=null,0===o&&u('"_"'))));null!==r;)t.push(r),null===(r=y())&&(45===n.charCodeAt(s)?(r="-",s++):(r=null,0===o&&u('"-"')),null===r&&(95===n.charCodeAt(s)?(r="_",s++):(r=null,0===o&&u('"_"'))));null!==t?e=[e,t]:(e=null,s=i)}else e=null,s=i;return e}function de(){var e,t,r,i,a;i=s,a=s,91===n.charCodeAt(s)?(e="[",s++):(e=null,0===o&&u('"["')),null!==e&&null!==(t=he())?(93===n.charCodeAt(s)?(r="]",s++):(r=null,0===o&&u('"]"')),null!==r?e=[e,t,r]:(e=null,s=a)):(e=null,s=a),null!==e&&(l=i,Hn.host_type="IPv6",e=n.substring(s,l));var l;return null===e&&(s=i),e}function he(){var e,t,r,i,a,l,c,d,h,f,p,_,m,v,g,y;v=s,g=s,null!==(e=fe())?(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===o&&u('":"')),null!==t&&null!==(r=fe())?(58===n.charCodeAt(s)?(i=":",s++):(i=null,0===o&&u('":"')),null!==i&&null!==(a=fe())?(58===n.charCodeAt(s)?(l=":",s++):(l=null,0===o&&u('":"')),null!==l&&null!==(c=fe())?(58===n.charCodeAt(s)?(d=":",s++):(d=null,0===o&&u('":"')),null!==d&&null!==(h=fe())?(58===n.charCodeAt(s)?(f=":",s++):(f=null,0===o&&u('":"')),null!==f&&null!==(p=fe())?(58===n.charCodeAt(s)?(_=":",s++):(_=null,0===o&&u('":"')),null!==_&&null!==(m=pe())?e=[e,t,r,i,a,l,c,d,h,f,p,_,m]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,"::"===n.substr(s,2)?(e="::",s+=2):(e=null,0===o&&u('"::"')),null!==e&&null!==(t=fe())?(58===n.charCodeAt(s)?(r=":",s++):(r=null,0===o&&u('":"')),null!==r&&null!==(i=fe())?(58===n.charCodeAt(s)?(a=":",s++):(a=null,0===o&&u('":"')),null!==a&&null!==(l=fe())?(58===n.charCodeAt(s)?(c=":",s++):(c=null,0===o&&u('":"')),null!==c&&null!==(d=fe())?(58===n.charCodeAt(s)?(h=":",s++):(h=null,0===o&&u('":"')),null!==h&&null!==(f=fe())?(58===n.charCodeAt(s)?(p=":",s++):(p=null,0===o&&u('":"')),null!==p&&null!==(_=pe())?e=[e,t,r,i,a,l,c,d,h,f,p,_]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,"::"===n.substr(s,2)?(e="::",s+=2):(e=null,0===o&&u('"::"')),null!==e&&null!==(t=fe())?(58===n.charCodeAt(s)?(r=":",s++):(r=null,0===o&&u('":"')),null!==r&&null!==(i=fe())?(58===n.charCodeAt(s)?(a=":",s++):(a=null,0===o&&u('":"')),null!==a&&null!==(l=fe())?(58===n.charCodeAt(s)?(c=":",s++):(c=null,0===o&&u('":"')),null!==c&&null!==(d=fe())?(58===n.charCodeAt(s)?(h=":",s++):(h=null,0===o&&u('":"')),null!==h&&null!==(f=pe())?e=[e,t,r,i,a,l,c,d,h,f]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,"::"===n.substr(s,2)?(e="::",s+=2):(e=null,0===o&&u('"::"')),null!==e&&null!==(t=fe())?(58===n.charCodeAt(s)?(r=":",s++):(r=null,0===o&&u('":"')),null!==r&&null!==(i=fe())?(58===n.charCodeAt(s)?(a=":",s++):(a=null,0===o&&u('":"')),null!==a&&null!==(l=fe())?(58===n.charCodeAt(s)?(c=":",s++):(c=null,0===o&&u('":"')),null!==c&&null!==(d=pe())?e=[e,t,r,i,a,l,c,d]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,"::"===n.substr(s,2)?(e="::",s+=2):(e=null,0===o&&u('"::"')),null!==e&&null!==(t=fe())?(58===n.charCodeAt(s)?(r=":",s++):(r=null,0===o&&u('":"')),null!==r&&null!==(i=fe())?(58===n.charCodeAt(s)?(a=":",s++):(a=null,0===o&&u('":"')),null!==a&&null!==(l=pe())?e=[e,t,r,i,a,l]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,"::"===n.substr(s,2)?(e="::",s+=2):(e=null,0===o&&u('"::"')),null!==e&&null!==(t=fe())?(58===n.charCodeAt(s)?(r=":",s++):(r=null,0===o&&u('":"')),null!==r&&null!==(i=pe())?e=[e,t,r,i]:(e=null,s=g)):(e=null,s=g),null===e&&(g=s,"::"===n.substr(s,2)?(e="::",s+=2):(e=null,0===o&&u('"::"')),null!==e&&null!==(t=pe())?e=[e,t]:(e=null,s=g),null===e&&(g=s,"::"===n.substr(s,2)?(e="::",s+=2):(e=null,0===o&&u('"::"')),null!==e&&null!==(t=fe())?e=[e,t]:(e=null,s=g),null===e&&(g=s,null!==(e=fe())?("::"===n.substr(s,2)?(t="::",s+=2):(t=null,0===o&&u('"::"')),null!==t&&null!==(r=fe())?(58===n.charCodeAt(s)?(i=":",s++):(i=null,0===o&&u('":"')),null!==i&&null!==(a=fe())?(58===n.charCodeAt(s)?(l=":",s++):(l=null,0===o&&u('":"')),null!==l&&null!==(c=fe())?(58===n.charCodeAt(s)?(d=":",s++):(d=null,0===o&&u('":"')),null!==d&&null!==(h=fe())?(58===n.charCodeAt(s)?(f=":",s++):(f=null,0===o&&u('":"')),null!==f&&null!==(p=pe())?e=[e,t,r,i,a,l,c,d,h,f,p]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,null!==(e=fe())?(y=s,58===n.charCodeAt(s)?(t=":",s++):(t=null,0===o&&u('":"')),null!==t&&null!==(r=fe())?t=[t,r]:(t=null,s=y),null!==(t=null!==t?t:"")?("::"===n.substr(s,2)?(r="::",s+=2):(r=null,0===o&&u('"::"')),null!==r&&null!==(i=fe())?(58===n.charCodeAt(s)?(a=":",s++):(a=null,0===o&&u('":"')),null!==a&&null!==(l=fe())?(58===n.charCodeAt(s)?(c=":",s++):(c=null,0===o&&u('":"')),null!==c&&null!==(d=fe())?(58===n.charCodeAt(s)?(h=":",s++):(h=null,0===o&&u('":"')),null!==h&&null!==(f=pe())?e=[e,t,r,i,a,l,c,d,h,f]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,null!==(e=fe())?(y=s,58===n.charCodeAt(s)?(t=":",s++):(t=null,0===o&&u('":"')),null!==t&&null!==(r=fe())?t=[t,r]:(t=null,s=y),null!==(t=null!==t?t:"")?(y=s,58===n.charCodeAt(s)?(r=":",s++):(r=null,0===o&&u('":"')),null!==r&&null!==(i=fe())?r=[r,i]:(r=null,s=y),null!==(r=null!==r?r:"")?("::"===n.substr(s,2)?(i="::",s+=2):(i=null,0===o&&u('"::"')),null!==i&&null!==(a=fe())?(58===n.charCodeAt(s)?(l=":",s++):(l=null,0===o&&u('":"')),null!==l&&null!==(c=fe())?(58===n.charCodeAt(s)?(d=":",s++):(d=null,0===o&&u('":"')),null!==d&&null!==(h=pe())?e=[e,t,r,i,a,l,c,d,h]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,null!==(e=fe())?(y=s,58===n.charCodeAt(s)?(t=":",s++):(t=null,0===o&&u('":"')),null!==t&&null!==(r=fe())?t=[t,r]:(t=null,s=y),null!==(t=null!==t?t:"")?(y=s,58===n.charCodeAt(s)?(r=":",s++):(r=null,0===o&&u('":"')),null!==r&&null!==(i=fe())?r=[r,i]:(r=null,s=y),null!==(r=null!==r?r:"")?(y=s,58===n.charCodeAt(s)?(i=":",s++):(i=null,0===o&&u('":"')),null!==i&&null!==(a=fe())?i=[i,a]:(i=null,s=y),null!==(i=null!==i?i:"")?("::"===n.substr(s,2)?(a="::",s+=2):(a=null,0===o&&u('"::"')),null!==a&&null!==(l=fe())?(58===n.charCodeAt(s)?(c=":",s++):(c=null,0===o&&u('":"')),null!==c&&null!==(d=pe())?e=[e,t,r,i,a,l,c,d]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,null!==(e=fe())?(y=s,58===n.charCodeAt(s)?(t=":",s++):(t=null,0===o&&u('":"')),null!==t&&null!==(r=fe())?t=[t,r]:(t=null,s=y),null!==(t=null!==t?t:"")?(y=s,58===n.charCodeAt(s)?(r=":",s++):(r=null,0===o&&u('":"')),null!==r&&null!==(i=fe())?r=[r,i]:(r=null,s=y),null!==(r=null!==r?r:"")?(y=s,58===n.charCodeAt(s)?(i=":",s++):(i=null,0===o&&u('":"')),null!==i&&null!==(a=fe())?i=[i,a]:(i=null,s=y),null!==(i=null!==i?i:"")?(y=s,58===n.charCodeAt(s)?(a=":",s++):(a=null,0===o&&u('":"')),null!==a&&null!==(l=fe())?a=[a,l]:(a=null,s=y),null!==(a=null!==a?a:"")?("::"===n.substr(s,2)?(l="::",s+=2):(l=null,0===o&&u('"::"')),null!==l&&null!==(c=pe())?e=[e,t,r,i,a,l,c]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,null!==(e=fe())?(y=s,58===n.charCodeAt(s)?(t=":",s++):(t=null,0===o&&u('":"')),null!==t&&null!==(r=fe())?t=[t,r]:(t=null,s=y),null!==(t=null!==t?t:"")?(y=s,58===n.charCodeAt(s)?(r=":",s++):(r=null,0===o&&u('":"')),null!==r&&null!==(i=fe())?r=[r,i]:(r=null,s=y),null!==(r=null!==r?r:"")?(y=s,58===n.charCodeAt(s)?(i=":",s++):(i=null,0===o&&u('":"')),null!==i&&null!==(a=fe())?i=[i,a]:(i=null,s=y),null!==(i=null!==i?i:"")?(y=s,58===n.charCodeAt(s)?(a=":",s++):(a=null,0===o&&u('":"')),null!==a&&null!==(l=fe())?a=[a,l]:(a=null,s=y),null!==(a=null!==a?a:"")?(y=s,58===n.charCodeAt(s)?(l=":",s++):(l=null,0===o&&u('":"')),null!==l&&null!==(c=fe())?l=[l,c]:(l=null,s=y),null!==(l=null!==l?l:"")?("::"===n.substr(s,2)?(c="::",s+=2):(c=null,0===o&&u('"::"')),null!==c&&null!==(d=fe())?e=[e,t,r,i,a,l,c,d]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,null!==(e=fe())?(y=s,58===n.charCodeAt(s)?(t=":",s++):(t=null,0===o&&u('":"')),null!==t&&null!==(r=fe())?t=[t,r]:(t=null,s=y),null!==(t=null!==t?t:"")?(y=s,58===n.charCodeAt(s)?(r=":",s++):(r=null,0===o&&u('":"')),null!==r&&null!==(i=fe())?r=[r,i]:(r=null,s=y),null!==(r=null!==r?r:"")?(y=s,58===n.charCodeAt(s)?(i=":",s++):(i=null,0===o&&u('":"')),null!==i&&null!==(a=fe())?i=[i,a]:(i=null,s=y),null!==(i=null!==i?i:"")?(y=s,58===n.charCodeAt(s)?(a=":",s++):(a=null,0===o&&u('":"')),null!==a&&null!==(l=fe())?a=[a,l]:(a=null,s=y),null!==(a=null!==a?a:"")?(y=s,58===n.charCodeAt(s)?(l=":",s++):(l=null,0===o&&u('":"')),null!==l&&null!==(c=fe())?l=[l,c]:(l=null,s=y),null!==(l=null!==l?l:"")?(y=s,58===n.charCodeAt(s)?(c=":",s++):(c=null,0===o&&u('":"')),null!==c&&null!==(d=fe())?c=[c,d]:(c=null,s=y),null!==(c=null!==c?c:"")?("::"===n.substr(s,2)?(d="::",s+=2):(d=null,0===o&&u('"::"')),null!==d?e=[e,t,r,i,a,l,c,d]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g))))))))))))))),null!==e&&(T=v,Hn.host_type="IPv6",e=n.substring(s,T));var T;return null===e&&(s=v),e}function fe(){var e,t,n,r,i;return i=s,null!==(e=f())&&null!==(t=null!==(t=f())?t:"")&&null!==(n=null!==(n=f())?n:"")&&null!==(r=null!==(r=f())?r:"")?e=[e,t,n,r]:(e=null,s=i),e}function pe(){var e,t,r,i;return i=s,null!==(e=fe())?(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===o&&u('":"')),null!==t&&null!==(r=fe())?e=[e,t,r]:(e=null,s=i)):(e=null,s=i),null===e&&(e=_e()),e}function _e(){var e,t,r,i,a,l,c,d,h;d=s,h=s,null!==(e=me())?(46===n.charCodeAt(s)?(t=".",s++):(t=null,0===o&&u('"."')),null!==t&&null!==(r=me())?(46===n.charCodeAt(s)?(i=".",s++):(i=null,0===o&&u('"."')),null!==i&&null!==(a=me())?(46===n.charCodeAt(s)?(l=".",s++):(l=null,0===o&&u('"."')),null!==l&&null!==(c=me())?e=[e,t,r,i,a,l,c]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h)):(e=null,s=h),null!==e&&(f=d,Hn.host_type="IPv4",e=n.substring(s,f));var f;return null===e&&(s=d),e}function me(){var e,t,r,i;return i=s,"25"===n.substr(s,2)?(e="25",s+=2):(e=null,0===o&&u('"25"')),null!==e?(/^[0-5]/.test(n.charAt(s))?(t=n.charAt(s),s++):(t=null,0===o&&u("[0-5]")),null!==t?e=[e,t]:(e=null,s=i)):(e=null,s=i),null===e&&(i=s,50===n.charCodeAt(s)?(e="2",s++):(e=null,0===o&&u('"2"')),null!==e?(/^[0-4]/.test(n.charAt(s))?(t=n.charAt(s),s++):(t=null,0===o&&u("[0-4]")),null!==t&&null!==(r=d())?e=[e,t,r]:(e=null,s=i)):(e=null,s=i),null===e&&(i=s,49===n.charCodeAt(s)?(e="1",s++):(e=null,0===o&&u('"1"')),null!==e&&null!==(t=d())&&null!==(r=d())?e=[e,t,r]:(e=null,s=i),null===e&&(i=s,/^[1-9]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===o&&u("[1-9]")),null!==e&&null!==(t=d())?e=[e,t]:(e=null,s=i),null===e&&(e=d())))),e}function ve(){var e,t,n,r,i,o,a;o=s,a=s,null!==(e=null!==(e=d())?e:"")&&null!==(t=null!==(t=d())?t:"")&&null!==(n=null!==(n=d())?n:"")&&null!==(r=null!==(r=d())?r:"")&&null!==(i=null!==(i=d())?i:"")?e=[e,t,n,r,i]:(e=null,s=a),null!==e&&(l=e,l=parseInt(l.join("")),Hn.port=l,e=l);var l;return null===e&&(s=o),e}function ge(){var e,t,r,i;for(e=[],i=s,59===n.charCodeAt(s)?(t=";",s++):(t=null,0===o&&u('";"')),null!==t&&null!==(r=ye())?t=[t,r]:(t=null,s=i);null!==t;)e.push(t),i=s,59===n.charCodeAt(s)?(t=";",s++):(t=null,0===o&&u('";"')),null!==t&&null!==(r=ye())?t=[t,r]:(t=null,s=i);return e}function ye(){var e;return null===(e=Te())&&null===(e=Ce())&&null===(e=Se())&&null===(e=Ee())&&null===(e=be())&&null===(e=Re())&&(e=Ae()),e}function Te(){var e,t,r,i;r=s,i=s,"transport="===n.substr(s,10).toLowerCase()?(e=n.substr(s,10),s+=10):(e=null,0===o&&u('"transport="')),null!==e?("udp"===n.substr(s,3).toLowerCase()?(t=n.substr(s,3),s+=3):(t=null,0===o&&u('"udp"')),null===t&&("tcp"===n.substr(s,3).toLowerCase()?(t=n.substr(s,3),s+=3):(t=null,0===o&&u('"tcp"')),null===t&&("sctp"===n.substr(s,4).toLowerCase()?(t=n.substr(s,4),s+=4):(t=null,0===o&&u('"sctp"')),null===t&&("tls"===n.substr(s,3).toLowerCase()?(t=n.substr(s,3),s+=3):(t=null,0===o&&u('"tls"')),null===t&&(t=O())))),null!==t?e=[e,t]:(e=null,s=i)):(e=null,s=i),null!==e&&(a=e[1],Hn.uri_params||(Hn.uri_params={}),e=void(Hn.uri_params.transport=a.toLowerCase()));var a;return null===e&&(s=r),e}function Ce(){var e,t,r,i;r=s,i=s,"user="===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===o&&u('"user="')),null!==e?("phone"===n.substr(s,5).toLowerCase()?(t=n.substr(s,5),s+=5):(t=null,0===o&&u('"phone"')),null===t&&("ip"===n.substr(s,2).toLowerCase()?(t=n.substr(s,2),s+=2):(t=null,0===o&&u('"ip"')),null===t&&(t=O())),null!==t?e=[e,t]:(e=null,s=i)):(e=null,s=i),null!==e&&(a=e[1],Hn.uri_params||(Hn.uri_params={}),e=void(Hn.uri_params.user=a.toLowerCase()));var a;return null===e&&(s=r),e}function Se(){var e,t,r,i;r=s,i=s,"method="===n.substr(s,7).toLowerCase()?(e=n.substr(s,7),s+=7):(e=null,0===o&&u('"method="')),null!==e&&null!==(t=ct())?e=[e,t]:(e=null,s=i),null!==e&&(a=e[1],Hn.uri_params||(Hn.uri_params={}),e=void(Hn.uri_params.method=a));var a;return null===e&&(s=r),e}function Ee(){var e,t,r,i;r=s,i=s,"ttl="===n.substr(s,4).toLowerCase()?(e=n.substr(s,4),s+=4):(e=null,0===o&&u('"ttl="')),null!==e&&null!==(t=bn())?e=[e,t]:(e=null,s=i),null!==e&&(a=e[1],Hn.params||(Hn.params={}),e=void(Hn.params.ttl=a));var a;return null===e&&(s=r),e}function be(){var e,t,r,i;r=s,i=s,"maddr="===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===o&&u('"maddr="')),null!==e&&null!==(t=ae())?e=[e,t]:(e=null,s=i),null!==e&&(a=e[1],Hn.uri_params||(Hn.uri_params={}),e=void(Hn.uri_params.maddr=a));var a;return null===e&&(s=r),e}function Re(){var e,t,r,i,a,l;return i=s,a=s,"lr"===n.substr(s,2).toLowerCase()?(e=n.substr(s,2),s+=2):(e=null,0===o&&u('"lr"')),null!==e?(l=s,61===n.charCodeAt(s)?(t="=",s++):(t=null,0===o&&u('"="')),null!==t&&null!==(r=O())?t=[t,r]:(t=null,s=l),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=a)):(e=null,s=a),null!==e&&(Hn.uri_params||(Hn.uri_params={}),e=void(Hn.uri_params.lr=void 0)),null===e&&(s=i),e}function Ae(){var e,t,r,i,a,l;i=s,a=s,null!==(e=we())?(l=s,61===n.charCodeAt(s)?(t="=",s++):(t=null,0===o&&u('"="')),null!==t&&null!==(r=Ie())?t=[t,r]:(t=null,s=l),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=a)):(e=null,s=a),null!==e&&(c=e[0],d=e[1],Hn.uri_params||(Hn.uri_params={}),d=void 0===d?void 0:d[1],e=void(Hn.uri_params[c.toLowerCase()]=d));var c,d;return null===e&&(s=i),e}function we(){var e,t,n;if(n=s,null!==(t=Pe()))for(e=[];null!==t;)e.push(t),t=Pe();else e=null;return null!==e&&(e=e.join("")),null===e&&(s=n),e}function Ie(){var e,t,n;if(n=s,null!==(t=Pe()))for(e=[];null!==t;)e.push(t),t=Pe();else e=null;return null!==e&&(e=e.join("")),null===e&&(s=n),e}function Pe(){var e;return null===(e=ke())&&null===(e=C())&&(e=E()),e}function ke(){var e;return 91===n.charCodeAt(s)?(e="[",s++):(e=null,0===o&&u('"["')),null===e&&(93===n.charCodeAt(s)?(e="]",s++):(e=null,0===o&&u('"]"')),null===e&&(47===n.charCodeAt(s)?(e="/",s++):(e=null,0===o&&u('"/"')),null===e&&(58===n.charCodeAt(s)?(e=":",s++):(e=null,0===o&&u('":"')),null===e&&(38===n.charCodeAt(s)?(e="&",s++):(e=null,0===o&&u('"&"')),null===e&&(43===n.charCodeAt(s)?(e="+",s++):(e=null,0===o&&u('"+"')),null===e&&(36===n.charCodeAt(s)?(e="$",s++):(e=null,0===o&&u('"$"')))))))),e}function Oe(){var e,t,r,i,a,l,c;if(l=s,63===n.charCodeAt(s)?(e="?",s++):(e=null,0===o&&u('"?"')),null!==e)if(null!==(t=xe())){for(r=[],c=s,38===n.charCodeAt(s)?(i="&",s++):(i=null,0===o&&u('"&"')),null!==i&&null!==(a=xe())?i=[i,a]:(i=null,s=c);null!==i;)r.push(i),c=s,38===n.charCodeAt(s)?(i="&",s++):(i=null,0===o&&u('"&"')),null!==i&&null!==(a=xe())?i=[i,a]:(i=null,s=c);null!==r?e=[e,t,r]:(e=null,s=l)}else e=null,s=l;else e=null,s=l;return e}function xe(){var e,t,r,i,a;i=s,a=s,null!==(e=De())?(61===n.charCodeAt(s)?(t="=",s++):(t=null,0===o&&u('"="')),null!==t&&null!==(r=Ne())?e=[e,t,r]:(e=null,s=a)):(e=null,s=a),null!==e&&(l=e[0],c=e[2],l=l.join("").toLowerCase(),c=c.join(""),Hn.uri_headers||(Hn.uri_headers={}),e=void(Hn.uri_headers[l]?Hn.uri_headers[l].push(c):Hn.uri_headers[l]=[c]));var l,c;return null===e&&(s=i),e}function De(){var e,t;if(null===(t=Ue())&&null===(t=C())&&(t=E()),null!==t)for(e=[];null!==t;)e.push(t),null===(t=Ue())&&null===(t=C())&&(t=E());else e=null;return e}function Ne(){var e,t;for(e=[],null===(t=Ue())&&null===(t=C())&&(t=E());null!==t;)e.push(t),null===(t=Ue())&&null===(t=C())&&(t=E());return e}function Ue(){var e;return 91===n.charCodeAt(s)?(e="[",s++):(e=null,0===o&&u('"["')),null===e&&(93===n.charCodeAt(s)?(e="]",s++):(e=null,0===o&&u('"]"')),null===e&&(47===n.charCodeAt(s)?(e="/",s++):(e=null,0===o&&u('"/"')),null===e&&(63===n.charCodeAt(s)?(e="?",s++):(e=null,0===o&&u('"?"')),null===e&&(58===n.charCodeAt(s)?(e=":",s++):(e=null,0===o&&u('":"')),null===e&&(43===n.charCodeAt(s)?(e="+",s++):(e=null,0===o&&u('"+"')),null===e&&(36===n.charCodeAt(s)?(e="$",s++):(e=null,0===o&&u('"$"')))))))),e}function Me(){var e,t,n,r,i,o;return o=s,null!==(e=ct())&&null!==(t=v())&&null!==(n=Le())&&null!==(r=v())&&null!==(i=et())?e=[e,t,n,r,i]:(e=null,s=o),e}function Le(){var e;return null===(e=X())&&(e=qe()),e}function qe(){var e,t,r,i;return i=s,null!==(e=Ye())?(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===o&&u('":"')),null!==t?(null===(r=Fe())&&(r=Ge()),null!==r?e=[e,t,r]:(e=null,s=i)):(e=null,s=i)):(e=null,s=i),e}function Fe(){var e,t,r,i,a;return i=s,null===(e=He())&&(e=je()),null!==e?(a=s,63===n.charCodeAt(s)?(t="?",s++):(t=null,0===o&&u('"?"')),null!==t&&null!==(r=Ze())?t=[t,r]:(t=null,s=a),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=i)):(e=null,s=i),e}function He(){var e,t,r,i;return i=s,"//"===n.substr(s,2)?(e="//",s+=2):(e=null,0===o&&u('"//"')),null!==e&&null!==(t=$e())&&null!==(r=null!==(r=je())?r:"")?e=[e,t,r]:(e=null,s=i),e}function je(){var e,t,r;return r=s,47===n.charCodeAt(s)?(e="/",s++):(e=null,0===o&&u('"/"')),null!==e&&null!==(t=We())?e=[e,t]:(e=null,s=r),e}function Ge(){var e,t,n,r;if(r=s,null!==(e=Ve())){for(t=[],n=Be();null!==n;)t.push(n),n=Be();null!==t?e=[e,t]:(e=null,s=r)}else e=null,s=r;return e}function Be(){var e;return null===(e=T())&&null===(e=C())&&(e=E()),e}function Ve(){var e;return null===(e=C())&&null===(e=E())&&(59===n.charCodeAt(s)?(e=";",s++):(e=null,0===o&&u('";"')),null===e&&(63===n.charCodeAt(s)?(e="?",s++):(e=null,0===o&&u('"?"')),null===e&&(58===n.charCodeAt(s)?(e=":",s++):(e=null,0===o&&u('":"')),null===e&&(64===n.charCodeAt(s)?(e="@",s++):(e=null,0===o&&u('"@"')),null===e&&(38===n.charCodeAt(s)?(e="&",s++):(e=null,0===o&&u('"&"')),null===e&&(61===n.charCodeAt(s)?(e="=",s++):(e=null,0===o&&u('"="')),null===e&&(43===n.charCodeAt(s)?(e="+",s++):(e=null,0===o&&u('"+"')),null===e&&(36===n.charCodeAt(s)?(e="$",s++):(e=null,0===o&&u('"$"')),null===e&&(44===n.charCodeAt(s)?(e=",",s++):(e=null,0===o&&u('","'))))))))))),e}function We(){var e,t,r,i,a,l;if(a=s,null!==(e=Je())){for(t=[],l=s,47===n.charCodeAt(s)?(r="/",s++):(r=null,0===o&&u('"/"')),null!==r&&null!==(i=Je())?r=[r,i]:(r=null,s=l);null!==r;)t.push(r),l=s,47===n.charCodeAt(s)?(r="/",s++):(r=null,0===o&&u('"/"')),null!==r&&null!==(i=Je())?r=[r,i]:(r=null,s=l);null!==t?e=[e,t]:(e=null,s=a)}else e=null,s=a;return e}function Je(){var e,t,r,i,a,l;for(a=s,e=[],t=Ke();null!==t;)e.push(t),t=Ke();if(null!==e){for(t=[],l=s,59===n.charCodeAt(s)?(r=";",s++):(r=null,0===o&&u('";"')),null!==r&&null!==(i=ze())?r=[r,i]:(r=null,s=l);null!==r;)t.push(r),l=s,59===n.charCodeAt(s)?(r=";",s++):(r=null,0===o&&u('";"')),null!==r&&null!==(i=ze())?r=[r,i]:(r=null,s=l);null!==t?e=[e,t]:(e=null,s=a)}else e=null,s=a;return e}function ze(){var e,t;for(e=[],t=Ke();null!==t;)e.push(t),t=Ke();return e}function Ke(){var e;return null===(e=C())&&null===(e=E())&&(58===n.charCodeAt(s)?(e=":",s++):(e=null,0===o&&u('":"')),null===e&&(64===n.charCodeAt(s)?(e="@",s++):(e=null,0===o&&u('"@"')),null===e&&(38===n.charCodeAt(s)?(e="&",s++):(e=null,0===o&&u('"&"')),null===e&&(61===n.charCodeAt(s)?(e="=",s++):(e=null,0===o&&u('"="')),null===e&&(43===n.charCodeAt(s)?(e="+",s++):(e=null,0===o&&u('"+"')),null===e&&(36===n.charCodeAt(s)?(e="$",s++):(e=null,0===o&&u('"$"')),null===e&&(44===n.charCodeAt(s)?(e=",",s++):(e=null,0===o&&u('","'))))))))),e}function Ye(){var e,t,r,i,a;if(i=s,a=s,null!==(e=h())){for(t=[],null===(r=h())&&null===(r=d())&&(43===n.charCodeAt(s)?(r="+",s++):(r=null,0===o&&u('"+"')),null===r&&(45===n.charCodeAt(s)?(r="-",s++):(r=null,0===o&&u('"-"')),null===r&&(46===n.charCodeAt(s)?(r=".",s++):(r=null,0===o&&u('"."')))));null!==r;)t.push(r),null===(r=h())&&null===(r=d())&&(43===n.charCodeAt(s)?(r="+",s++):(r=null,0===o&&u('"+"')),null===r&&(45===n.charCodeAt(s)?(r="-",s++):(r=null,0===o&&u('"-"')),null===r&&(46===n.charCodeAt(s)?(r=".",s++):(r=null,0===o&&u('"."')))));null!==t?e=[e,t]:(e=null,s=a)}else e=null,s=a;null!==e&&(l=i,e=void(Hn.scheme=n.substring(s,l)));var l;return null===e&&(s=i),e}function $e(){var e;return null===(e=Qe())&&(e=Xe()),e}function Qe(){var e,t,r,i;return r=s,i=s,null!==(e=ne())?(64===n.charCodeAt(s)?(t="@",s++):(t=null,0===o&&u('"@"')),null!==t?e=[e,t]:(e=null,s=i)):(e=null,s=i),null!==(e=null!==e?e:"")&&null!==(t=oe())?e=[e,t]:(e=null,s=r),e=null!==e?e:""}function Xe(){var e,t;if(null===(t=C())&&null===(t=E())&&(36===n.charCodeAt(s)?(t="$",s++):(t=null,0===o&&u('"$"')),null===t&&(44===n.charCodeAt(s)?(t=",",s++):(t=null,0===o&&u('","')),null===t&&(59===n.charCodeAt(s)?(t=";",s++):(t=null,0===o&&u('";"')),null===t&&(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===o&&u('":"')),null===t&&(64===n.charCodeAt(s)?(t="@",s++):(t=null,0===o&&u('"@"')),null===t&&(38===n.charCodeAt(s)?(t="&",s++):(t=null,0===o&&u('"&"')),null===t&&(61===n.charCodeAt(s)?(t="=",s++):(t=null,0===o&&u('"="')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===o&&u('"+"')))))))))),null!==t)for(e=[];null!==t;)e.push(t),null===(t=C())&&null===(t=E())&&(36===n.charCodeAt(s)?(t="$",s++):(t=null,0===o&&u('"$"')),null===t&&(44===n.charCodeAt(s)?(t=",",s++):(t=null,0===o&&u('","')),null===t&&(59===n.charCodeAt(s)?(t=";",s++):(t=null,0===o&&u('";"')),null===t&&(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===o&&u('":"')),null===t&&(64===n.charCodeAt(s)?(t="@",s++):(t=null,0===o&&u('"@"')),null===t&&(38===n.charCodeAt(s)?(t="&",s++):(t=null,0===o&&u('"&"')),null===t&&(61===n.charCodeAt(s)?(t="=",s++):(t=null,0===o&&u('"="')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===o&&u('"+"'))))))))));else e=null;return e}function Ze(){var e,t;for(e=[],t=Be();null!==t;)e.push(t),t=Be();return e}function et(){var e,t,r,i,a,l,c,h;if(c=s,h=s,"sip"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===o&&u('"SIP"')),null!==e)if(47===n.charCodeAt(s)?(t="/",s++):(t=null,0===o&&u('"/"')),null!==t){if(null!==(i=d()))for(r=[];null!==i;)r.push(i),i=d();else r=null;if(null!==r)if(46===n.charCodeAt(s)?(i=".",s++):(i=null,0===o&&u('"."')),null!==i){if(null!==(l=d()))for(a=[];null!==l;)a.push(l),l=d();else a=null;null!==a?e=[e,t,r,i,a]:(e=null,s=h)}else e=null,s=h;else e=null,s=h}else e=null,s=h;else e=null,s=h;null!==e&&(f=c,e=void(Hn.sip_version=n.substring(s,f)));var f;return null===e&&(s=c),e}function tt(){var e;return"INVITE"===n.substr(s,6)?(e="INVITE",s+=6):(e=null,0===o&&u('"INVITE"')),e}function nt(){var e;return"ACK"===n.substr(s,3)?(e="ACK",s+=3):(e=null,0===o&&u('"ACK"')),e}function rt(){var e;return"OPTIONS"===n.substr(s,7)?(e="OPTIONS",s+=7):(e=null,0===o&&u('"OPTIONS"')),e}function it(){var e;return"BYE"===n.substr(s,3)?(e="BYE",s+=3):(e=null,0===o&&u('"BYE"')),e}function st(){var e;return"CANCEL"===n.substr(s,6)?(e="CANCEL",s+=6):(e=null,0===o&&u('"CANCEL"')),e}function ot(){var e;return"REGISTER"===n.substr(s,8)?(e="REGISTER",s+=8):(e=null,0===o&&u('"REGISTER"')),e}function at(){var e;return"SUBSCRIBE"===n.substr(s,9)?(e="SUBSCRIBE",s+=9):(e=null,0===o&&u('"SUBSCRIBE"')),e}function lt(){var e;return"NOTIFY"===n.substr(s,6)?(e="NOTIFY",s+=6):(e=null,0===o&&u('"NOTIFY"')),e}function ut(){var e;return"REFER"===n.substr(s,5)?(e="REFER",s+=5):(e=null,0===o&&u('"REFER"')),e}function ct(){var e,t;t=s,null===(e=tt())&&null===(e=nt())&&null===(e=rt())&&null===(e=it())&&null===(e=st())&&null===(e=ot())&&null===(e=at())&&null===(e=lt())&&null===(e=ut())&&(e=O()),null!==e&&(r=t,Hn.method=n.substring(s,r),e=Hn.method);var r;return null===e&&(s=t),e}function dt(){var e,t,n,r,i,o;return o=s,null!==(e=et())&&null!==(t=v())&&null!==(n=ht())&&null!==(r=v())&&null!==(i=pt())?e=[e,t,n,r,i]:(e=null,s=o),e}function ht(){var e,t;t=s,null!==(e=ft())&&(n=e,e=void(Hn.status_code=parseInt(n.join(""))));var n;return null===e&&(s=t),e}function ft(){var e,t,n,r;return r=s,null!==(e=d())&&null!==(t=d())&&null!==(n=d())?e=[e,t,n]:(e=null,s=r),e}function pt(){var e,t,r;for(r=s,e=[],null===(t=T())&&null===(t=C())&&null===(t=E())&&null===(t=P())&&null===(t=k())&&null===(t=v())&&(t=g());null!==t;)e.push(t),null===(t=T())&&null===(t=C())&&null===(t=E())&&null===(t=P())&&null===(t=k())&&null===(t=v())&&(t=g());null!==e&&(i=r,e=void(Hn.reason_phrase=n.substring(s,i)));var i;return null===e&&(s=r),e}function _t(){var e,t,n,r,i,o,a;if(i=s,o=s,null===(e=Q())&&(e=mt()),null!==e){for(t=[],a=s,null!==(n=G())&&null!==(r=gt())?n=[n,r]:(n=null,s=a);null!==n;)t.push(n),a=s,null!==(n=G())&&null!==(r=gt())?n=[n,r]:(n=null,s=a);null!==t?e=[e,t]:(e=null,s=o)}else e=null,s=o;return null!==e&&(e=function(e){var t;Hn.multi_header||(Hn.multi_header=[]);try{t=new Fn(Hn.uri,Hn.display_name,Hn.params),delete Hn.uri,delete Hn.display_name,delete Hn.params}catch(e){t=null}Hn.multi_header.push({possition:s,offset:e,parsed:t})}(i)),null===e&&(s=i),e}function mt(){var e,t,n,r,i;return i=s,null!==(e=null!==(e=vt())?e:"")&&null!==(t=H())&&null!==(n=X())&&null!==(r=F())?e=[e,t,n,r]:(e=null,s=i),e}function vt(){var e,t,r,i,o,a,l;if(o=s,a=s,null!==(e=O())){for(t=[],l=s,null!==(r=b())&&null!==(i=O())?r=[r,i]:(r=null,s=l);null!==r;)t.push(r),l=s,null!==(r=b())&&null!==(i=O())?r=[r,i]:(r=null,s=l);null!==t?e=[e,t]:(e=null,s=a)}else e=null,s=a;null===e&&(e=z()),null!==e&&(u=o,c=e,'"'===(c=n.substring(s,u).trim())[0]&&(c=c.substring(1,c.length-1)),e=void(Hn.display_name=c));var u,c;return null===e&&(s=o),e}function gt(){var e;return null===(e=yt())&&null===(e=Tt())&&(e=Et()),e}function yt(){var e,t,r,i,a;i=s,a=s,"q"===n.substr(s,1).toLowerCase()?(e=n.substr(s,1),s++):(e=null,0===o&&u('"q"')),null!==e&&null!==(t=M())&&null!==(r=St())?e=[e,t,r]:(e=null,s=a),null!==e&&(l=e[2],Hn.params||(Hn.params={}),e=void(Hn.params.q=l));var l;return null===e&&(s=i),e}function Tt(){var e,t,r,i,a;i=s,a=s,"expires"===n.substr(s,7).toLowerCase()?(e=n.substr(s,7),s+=7):(e=null,0===o&&u('"expires"')),null!==e&&null!==(t=M())&&null!==(r=Ct())?e=[e,t,r]:(e=null,s=a),null!==e&&(l=e[2],Hn.params||(Hn.params={}),e=void(Hn.params.expires=l));var l;return null===e&&(s=i),e}function Ct(){var e,t,n;if(n=s,null!==(t=d()))for(e=[];null!==t;)e.push(t),t=d();else e=null;return null!==e&&(e=parseInt(e.join(""))),null===e&&(s=n),e}function St(){var e,t,r,i,a,l,c,h;l=s,c=s,48===n.charCodeAt(s)?(e="0",s++):(e=null,0===o&&u('"0"')),null!==e?(h=s,46===n.charCodeAt(s)?(t=".",s++):(t=null,0===o&&u('"."')),null!==t&&null!==(r=null!==(r=d())?r:"")&&null!==(i=null!==(i=d())?i:"")&&null!==(a=null!==(a=d())?a:"")?t=[t,r,i,a]:(t=null,s=h),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=c)):(e=null,s=c),null!==e&&(f=l,e=parseFloat(n.substring(s,f)));var f;return null===e&&(s=l),e}function Et(){var e,t,n,r,i,o;r=s,i=s,null!==(e=O())?(o=s,null!==(t=M())&&null!==(n=bt())?t=[t,n]:(t=null,s=o),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=i)):(e=null,s=i),null!==e&&(a=e[0],l=e[1],Hn.params||(Hn.params={}),l=void 0===l?void 0:l[1],e=void(Hn.params[a.toLowerCase()]=l));var a,l;return null===e&&(s=r),e}function bt(){var e;return null===(e=O())&&null===(e=ae())&&(e=z()),e}function Rt(){var e;return"render"===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===o&&u('"render"')),null===e&&("session"===n.substr(s,7).toLowerCase()?(e=n.substr(s,7),s+=7):(e=null,0===o&&u('"session"')),null===e&&("icon"===n.substr(s,4).toLowerCase()?(e=n.substr(s,4),s+=4):(e=null,0===o&&u('"icon"')),null===e&&("alert"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===o&&u('"alert"')),null===e&&(e=O())))),e}function At(){var e;return null===(e=wt())&&(e=Et()),e}function wt(){var e,t,r,i;return i=s,"handling"===n.substr(s,8).toLowerCase()?(e=n.substr(s,8),s+=8):(e=null,0===o&&u('"handling"')),null!==e&&null!==(t=M())?("optional"===n.substr(s,8).toLowerCase()?(r=n.substr(s,8),s+=8):(r=null,0===o&&u('"optional"')),null===r&&("required"===n.substr(s,8).toLowerCase()?(r=n.substr(s,8),s+=8):(r=null,0===o&&u('"required"')),null===r&&(r=O())),null!==r?e=[e,t,r]:(e=null,s=i)):(e=null,s=i),e}function It(){var e,t,n,r,i,o,a,l;if(a=s,null!==(e=Pt()))if(null!==(t=U()))if(null!==(n=Nt())){for(r=[],l=s,null!==(i=G())&&null!==(o=Ut())?i=[i,o]:(i=null,s=l);null!==i;)r.push(i),l=s,null!==(i=G())&&null!==(o=Ut())?i=[i,o]:(i=null,s=l);null!==r?e=[e,t,n,r]:(e=null,s=a)}else e=null,s=a;else e=null,s=a;else e=null,s=a;return e}function Pt(){var e;return null===(e=kt())&&(e=Ot()),e}function kt(){var e;return"text"===n.substr(s,4).toLowerCase()?(e=n.substr(s,4),s+=4):(e=null,0===o&&u('"text"')),null===e&&("image"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===o&&u('"image"')),null===e&&("audio"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===o&&u('"audio"')),null===e&&("video"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===o&&u('"video"')),null===e&&("application"===n.substr(s,11).toLowerCase()?(e=n.substr(s,11),s+=11):(e=null,0===o&&u('"application"')),null===e&&(e=xt()))))),e}function Ot(){var e;return"message"===n.substr(s,7).toLowerCase()?(e=n.substr(s,7),s+=7):(e=null,0===o&&u('"message"')),null===e&&("multipart"===n.substr(s,9).toLowerCase()?(e=n.substr(s,9),s+=9):(e=null,0===o&&u('"multipart"')),null===e&&(e=xt())),e}function xt(){var e;return null===(e=O())&&(e=Dt()),e}function Dt(){var e,t,r;return r=s,"x-"===n.substr(s,2).toLowerCase()?(e=n.substr(s,2),s+=2):(e=null,0===o&&u('"x-"')),null!==e&&null!==(t=O())?e=[e,t]:(e=null,s=r),e}function Nt(){var e;return null===(e=xt())&&(e=O()),e}function Ut(){var e,t,n,r;return r=s,null!==(e=O())&&null!==(t=M())&&null!==(n=Mt())?e=[e,t,n]:(e=null,s=r),e}function Mt(){var e;return null===(e=O())&&(e=z()),e}function Lt(){var e,t,n;if(n=s,null!==(t=d()))for(e=[];null!==t;)e.push(t),t=d();else e=null;null!==e&&(r=e,e=void(Hn.value=parseInt(r.join(""))));var r;return null===e&&(s=n),e}function qt(){var e,t,r,i,a,l;if(a=s,null!==(e=x())){for(t=[],l=s,46===n.charCodeAt(s)?(r=".",s++):(r=null,0===o&&u('"."')),null!==r&&null!==(i=x())?r=[r,i]:(r=null,s=l);null!==r;)t.push(r),l=s,46===n.charCodeAt(s)?(r=".",s++):(r=null,0===o&&u('"."')),null!==r&&null!==(i=x())?r=[r,i]:(r=null,s=l);null!==t?e=[e,t]:(e=null,s=a)}else e=null,s=a;return e}function Ft(){var e;return null===(e=Ht())&&(e=Et()),e}function Ht(){var e,t,r,i,a;i=s,a=s,"tag"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===o&&u('"tag"')),null!==e&&null!==(t=M())&&null!==(r=O())?e=[e,t,r]:(e=null,s=a),null!==e&&(l=e[2],e=void(Hn.tag=l));var l;return null===e&&(s=i),e}function jt(){var e,t,r,i,a,l,c,d;if(c=s,"digest"===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===o&&u('"Digest"')),null!==e)if(null!==(t=b()))if(null!==(r=Vt())){for(i=[],d=s,null!==(a=j())&&null!==(l=Vt())?a=[a,l]:(a=null,s=d);null!==a;)i.push(a),d=s,null!==(a=j())&&null!==(l=Vt())?a=[a,l]:(a=null,s=d);null!==i?e=[e,t,r,i]:(e=null,s=c)}else e=null,s=c;else e=null,s=c;else e=null,s=c;return null===e&&(e=Gt()),e}function Gt(){var e,t,n,r,i,o,a,l;if(a=s,null!==(e=O()))if(null!==(t=b()))if(null!==(n=Bt())){for(r=[],l=s,null!==(i=j())&&null!==(o=Bt())?i=[i,o]:(i=null,s=l);null!==i;)r.push(i),l=s,null!==(i=j())&&null!==(o=Bt())?i=[i,o]:(i=null,s=l);null!==r?e=[e,t,n,r]:(e=null,s=a)}else e=null,s=a;else e=null,s=a;else e=null,s=a;return e}function Bt(){var e,t,n,r;return r=s,null!==(e=O())&&null!==(t=M())?(null===(n=O())&&(n=z()),null!==n?e=[e,t,n]:(e=null,s=r)):(e=null,s=r),e}function Vt(){var e;return null===(e=Wt())&&null===(e=zt())&&null===(e=Yt())&&null===(e=Qt())&&null===(e=Xt())&&null===(e=Zt())&&null===(e=en())&&(e=Bt()),e}function Wt(){var e,t,r,i;return i=s,"realm"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===o&&u('"realm"')),null!==e&&null!==(t=M())&&null!==(r=Jt())?e=[e,t,r]:(e=null,s=i),e}function Jt(){var e,t;t=s,null!==(e=K())&&(n=e,e=void(Hn.realm=n));var n;return null===e&&(s=t),e}function zt(){var e,t,r,i,a,l,c,d,h;if(d=s,"domain"===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===o&&u('"domain"')),null!==e)if(null!==(t=M()))if(null!==(r=V()))if(null!==(i=Kt())){if(a=[],h=s,null!==(c=v()))for(l=[];null!==c;)l.push(c),c=v();else l=null;for(null!==l&&null!==(c=Kt())?l=[l,c]:(l=null,s=h);null!==l;){if(a.push(l),h=s,null!==(c=v()))for(l=[];null!==c;)l.push(c),c=v();else l=null;null!==l&&null!==(c=Kt())?l=[l,c]:(l=null,s=h)}null!==a&&null!==(l=W())?e=[e,t,r,i,a,l]:(e=null,s=d)}else e=null,s=d;else e=null,s=d;else e=null,s=d;else e=null,s=d;return e}function Kt(){var e;return null===(e=qe())&&(e=je()),e}function Yt(){var e,t,r,i;return i=s,"nonce"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===o&&u('"nonce"')),null!==e&&null!==(t=M())&&null!==(r=$t())?e=[e,t,r]:(e=null,s=i),e}function $t(){var e,t;t=s,null!==(e=K())&&(n=e,e=void(Hn.nonce=n));var n;return null===e&&(s=t),e}function Qt(){var e,t,r,i,a;i=s,a=s,"opaque"===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===o&&u('"opaque"')),null!==e&&null!==(t=M())&&null!==(r=K())?e=[e,t,r]:(e=null,s=a),null!==e&&(l=e[2],e=void(Hn.opaque=l));var l;return null===e&&(s=i),e}function Xt(){var e,t,r,i,a;return i=s,"stale"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===o&&u('"stale"')),null!==e&&null!==(t=M())?(a=s,"true"===n.substr(s,4).toLowerCase()?(r=n.substr(s,4),s+=4):(r=null,0===o&&u('"true"')),null!==r&&(r=void(Hn.stale=!0)),null===r&&(s=a),null===r&&(a=s,"false"===n.substr(s,5).toLowerCase()?(r=n.substr(s,5),s+=5):(r=null,0===o&&u('"false"')),null!==r&&(r=void(Hn.stale=!1)),null===r&&(s=a)),null!==r?e=[e,t,r]:(e=null,s=i)):(e=null,s=i),e}function Zt(){var e,t,r,i,a;i=s,a=s,"algorithm"===n.substr(s,9).toLowerCase()?(e=n.substr(s,9),s+=9):(e=null,0===o&&u('"algorithm"')),null!==e&&null!==(t=M())?("md5"===n.substr(s,3).toLowerCase()?(r=n.substr(s,3),s+=3):(r=null,0===o&&u('"MD5"')),null===r&&("md5-sess"===n.substr(s,8).toLowerCase()?(r=n.substr(s,8),s+=8):(r=null,0===o&&u('"MD5-sess"')),null===r&&(r=O())),null!==r?e=[e,t,r]:(e=null,s=a)):(e=null,s=a),null!==e&&(l=e[2],e=void(Hn.algorithm=l.toUpperCase()));var l;return null===e&&(s=i),e}function en(){var e,t,r,i,a,l,c,d,h,f;if(d=s,"qop"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===o&&u('"qop"')),null!==e)if(null!==(t=M()))if(null!==(r=V())){if(h=s,null!==(i=tn())){for(a=[],f=s,44===n.charCodeAt(s)?(l=",",s++):(l=null,0===o&&u('","')),null!==l&&null!==(c=tn())?l=[l,c]:(l=null,s=f);null!==l;)a.push(l),f=s,44===n.charCodeAt(s)?(l=",",s++):(l=null,0===o&&u('","')),null!==l&&null!==(c=tn())?l=[l,c]:(l=null,s=f);null!==a?i=[i,a]:(i=null,s=h)}else i=null,s=h;null!==i&&null!==(a=W())?e=[e,t,r,i,a]:(e=null,s=d)}else e=null,s=d;else e=null,s=d;else e=null,s=d;return e}function tn(){var e,t;t=s,"auth-int"===n.substr(s,8).toLowerCase()?(e=n.substr(s,8),s+=8):(e=null,0===o&&u('"auth-int"')),null===e&&("auth"===n.substr(s,4).toLowerCase()?(e=n.substr(s,4),s+=4):(e=null,0===o&&u('"auth"')),null===e&&(e=O())),null!==e&&(r=e,Hn.qop||(Hn.qop=[]),e=void Hn.qop.push(r.toLowerCase()));var r;return null===e&&(s=t),e}function nn(){var e,t,n,r,i,o,a;if(i=s,o=s,null!==(e=mt())){for(t=[],a=s,null!==(n=G())&&null!==(r=Et())?n=[n,r]:(n=null,s=a);null!==n;)t.push(n),a=s,null!==(n=G())&&null!==(r=Et())?n=[n,r]:(n=null,s=a);null!==t?e=[e,t]:(e=null,s=o)}else e=null,s=o;return null!==e&&(e=function(e){var t;Hn.multi_header||(Hn.multi_header=[]);try{t=new Fn(Hn.uri,Hn.display_name,Hn.params),delete Hn.uri,delete Hn.display_name,delete Hn.params}catch(e){t=null}Hn.multi_header.push({possition:s,offset:e,parsed:t})}(i)),null===e&&(s=i),e}function rn(){var e;return null===(e=sn())&&(e=Et()),e}function sn(){var e,t,r,i,a,l;if(a=s,l=s,"cause"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===o&&u('"cause"')),null!==e)if(null!==(t=M())){if(null!==(i=d()))for(r=[];null!==i;)r.push(i),i=d();else r=null;null!==r?e=[e,t,r]:(e=null,s=l)}else e=null,s=l;else e=null,s=l;null!==e&&(c=e[2],e=void(Hn.cause=parseInt(c.join(""))));var c;return null===e&&(s=a),e}function on(){var e,t,n,r,i,o;if(i=s,null!==(e=mt())){for(t=[],o=s,null!==(n=G())&&null!==(r=Et())?n=[n,r]:(n=null,s=o);null!==n;)t.push(n),o=s,null!==(n=G())&&null!==(r=Et())?n=[n,r]:(n=null,s=o);null!==t?e=[e,t]:(e=null,s=i)}else e=null,s=i;return e}function an(){var e,t;t=s,"active"===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===o&&u('"active"')),null===e&&("pending"===n.substr(s,7).toLowerCase()?(e=n.substr(s,7),s+=7):(e=null,0===o&&u('"pending"')),null===e&&("terminated"===n.substr(s,10).toLowerCase()?(e=n.substr(s,10),s+=10):(e=null,0===o&&u('"terminated"')),null===e&&(e=O()))),null!==e&&(r=t,e=void(Hn.state=n.substring(s,r)));var r;return null===e&&(s=t),e}function ln(){var e,t,r,i,a;i=s,a=s,"reason"===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===o&&u('"reason"')),null!==e&&null!==(t=M())&&null!==(r=un())?e=[e,t,r]:(e=null,s=a),null!==e&&(e=void(void 0!==(l=e[2])&&(Hn.reason=l)));var l;null===e&&(s=i),null===e&&(i=s,a=s,"expires"===n.substr(s,7).toLowerCase()?(e=n.substr(s,7),s+=7):(e=null,0===o&&u('"expires"')),null!==e&&null!==(t=M())&&null!==(r=Ct())?e=[e,t,r]:(e=null,s=a),null!==e&&(e=void(void 0!==(d=e[2])&&(Hn.expires=d))),null===e&&(s=i),null===e&&(i=s,a=s,"retry_after"===n.substr(s,11).toLowerCase()?(e=n.substr(s,11),s+=11):(e=null,0===o&&u('"retry_after"')),null!==e&&null!==(t=M())&&null!==(r=Ct())?e=[e,t,r]:(e=null,s=a),null!==e&&(e=void(void 0!==(c=e[2])&&(Hn.retry_after=c))),null===e&&(s=i),null===e&&(e=Et())));var c,d;return e}function un(){var e;return"deactivated"===n.substr(s,11).toLowerCase()?(e=n.substr(s,11),s+=11):(e=null,0===o&&u('"deactivated"')),null===e&&("probation"===n.substr(s,9).toLowerCase()?(e=n.substr(s,9),s+=9):(e=null,0===o&&u('"probation"')),null===e&&("rejected"===n.substr(s,8).toLowerCase()?(e=n.substr(s,8),s+=8):(e=null,0===o&&u('"rejected"')),null===e&&("timeout"===n.substr(s,7).toLowerCase()?(e=n.substr(s,7),s+=7):(e=null,0===o&&u('"timeout"')),null===e&&("giveup"===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===o&&u('"giveup"')),null===e&&("noresource"===n.substr(s,10).toLowerCase()?(e=n.substr(s,10),s+=10):(e=null,0===o&&u('"noresource"')),null===e&&("invariant"===n.substr(s,9).toLowerCase()?(e=n.substr(s,9),s+=9):(e=null,0===o&&u('"invariant"')),null===e&&(e=O()))))))),e}function cn(){var e;return null===(e=Ht())&&(e=Et()),e}function dn(){var e,t,n,r,i,o,a,l;if(a=s,null!==(e=gn()))if(null!==(t=b()))if(null!==(n=Cn())){for(r=[],l=s,null!==(i=G())&&null!==(o=hn())?i=[i,o]:(i=null,s=l);null!==i;)r.push(i),l=s,null!==(i=G())&&null!==(o=hn())?i=[i,o]:(i=null,s=l);null!==r?e=[e,t,n,r]:(e=null,s=a)}else e=null,s=a;else e=null,s=a;else e=null,s=a;return e}function hn(){var e;return null===(e=fn())&&null===(e=pn())&&null===(e=_n())&&null===(e=mn())&&null===(e=vn())&&(e=Et()),e}function fn(){var e,t,r,i,a;i=s,a=s,"ttl"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===o&&u('"ttl"')),null!==e&&null!==(t=M())&&null!==(r=bn())?e=[e,t,r]:(e=null,s=a),null!==e&&(l=e[2],e=void(Hn.ttl=l));var l;return null===e&&(s=i),e}function pn(){var e,t,r,i,a;i=s,a=s,"maddr"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===o&&u('"maddr"')),null!==e&&null!==(t=M())&&null!==(r=ae())?e=[e,t,r]:(e=null,s=a),null!==e&&(l=e[2],e=void(Hn.maddr=l));var l;return null===e&&(s=i),e}function _n(){var e,t,r,i,a;i=s,a=s,"received"===n.substr(s,8).toLowerCase()?(e=n.substr(s,8),s+=8):(e=null,0===o&&u('"received"')),null!==e&&null!==(t=M())?(null===(r=_e())&&(r=he()),null!==r?e=[e,t,r]:(e=null,s=a)):(e=null,s=a),null!==e&&(l=e[2],e=void(Hn.received=l));var l;return null===e&&(s=i),e}function mn(){var e,t,r,i,a;i=s,a=s,"branch"===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===o&&u('"branch"')),null!==e&&null!==(t=M())&&null!==(r=O())?e=[e,t,r]:(e=null,s=a),null!==e&&(l=e[2],e=void(Hn.branch=l));var l;return null===e&&(s=i),e}function vn(){var e,t,r,i,a,l,c;if(a=s,l=s,"rport"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===o&&u('"rport"')),null!==e){if(c=s,null!==(t=M())){for(r=[],i=d();null!==i;)r.push(i),i=d();null!==r?t=[t,r]:(t=null,s=c)}else t=null,s=c;null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=l)}else e=null,s=l;return null!==e&&(e=void("undefined"!=typeof response_port&&(Hn.rport=response_port.join("")))),null===e&&(s=a),e}function gn(){var e,t,n,r,i,o;return o=s,null!==(e=yn())&&null!==(t=U())&&null!==(n=O())&&null!==(r=U())&&null!==(i=Tn())?e=[e,t,n,r,i]:(e=null,s=o),e}function yn(){var e,t;t=s,"sip"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===o&&u('"SIP"')),null===e&&(e=O()),null!==e&&(r=e,e=void(Hn.protocol=r));var r;return null===e&&(s=t),e}function Tn(){var e,t;t=s,"udp"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===o&&u('"UDP"')),null===e&&("tcp"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===o&&u('"TCP"')),null===e&&("tls"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===o&&u('"TLS"')),null===e&&("sctp"===n.substr(s,4).toLowerCase()?(e=n.substr(s,4),s+=4):(e=null,0===o&&u('"SCTP"')),null===e&&(e=O())))),null!==e&&(r=e,e=void(Hn.transport=r));var r;return null===e&&(s=t),e}function Cn(){var e,t,n,r,i;return r=s,null!==(e=Sn())?(i=s,null!==(t=B())&&null!==(n=En())?t=[t,n]:(t=null,s=i),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=r)):(e=null,s=r),e}function Sn(){var e,t;t=s,null===(e=_e())&&null===(e=de())&&(e=le()),null!==e&&(r=t,e=void(Hn.host=n.substring(s,r)));var r;return null===e&&(s=t),e}function En(){var e,t,n,r,i,o,a;o=s,a=s,null!==(e=null!==(e=d())?e:"")&&null!==(t=null!==(t=d())?t:"")&&null!==(n=null!==(n=d())?n:"")&&null!==(r=null!==(r=d())?r:"")&&null!==(i=null!==(i=d())?i:"")?e=[e,t,n,r,i]:(e=null,s=a),null!==e&&(l=e,e=void(Hn.port=parseInt(l.join(""))));var l;return null===e&&(s=o),e}function bn(){var e,t,n,r,i;return r=s,i=s,null!==(e=d())&&null!==(t=null!==(t=d())?t:"")&&null!==(n=null!==(n=d())?n:"")?e=[e,t,n]:(e=null,s=i),null!==e&&(e=parseInt(e.join(""))),null===e&&(s=r),e}function Rn(){var e,t;t=s,null!==(e=Ct())&&(n=e,e=void(Hn.expires=n));var n;return null===e&&(s=t),e}function An(){var e;return null===(e=wn())&&(e=Et()),e}function wn(){var e,t,r,i,a;i=s,a=s,"refresher"===n.substr(s,9).toLowerCase()?(e=n.substr(s,9),s+=9):(e=null,0===o&&u('"refresher"')),null!==e&&null!==(t=M())?("uac"===n.substr(s,3).toLowerCase()?(r=n.substr(s,3),s+=3):(r=null,0===o&&u('"uac"')),null===r&&("uas"===n.substr(s,3).toLowerCase()?(r=n.substr(s,3),s+=3):(r=null,0===o&&u('"uas"'))),null!==r?e=[e,t,r]:(e=null,s=a)):(e=null,s=a),null!==e&&(l=e[2],e=void(Hn.refresher=l.toLowerCase()));var l;return null===e&&(s=i),e}function In(){var e,t;for(e=[],null===(t=I())&&null===(t=k())&&(t=b());null!==t;)e.push(t),null===(t=I())&&null===(t=k())&&(t=b());return e}function Pn(){var e,t,r,i,a,l,c,d,h,f,p;f=s,p=s,null!==(e=On())?(45===n.charCodeAt(s)?(t="-",s++):(t=null,0===o&&u('"-"')),null!==t&&null!==(r=kn())?(45===n.charCodeAt(s)?(i="-",s++):(i=null,0===o&&u('"-"')),null!==i&&null!==(a=kn())?(45===n.charCodeAt(s)?(l="-",s++):(l=null,0===o&&u('"-"')),null!==l&&null!==(c=kn())?(45===n.charCodeAt(s)?(d="-",s++):(d=null,0===o&&u('"-"')),null!==d&&null!==(h=xn())?e=[e,t,r,i,a,l,c,d,h]:(e=null,s=p)):(e=null,s=p)):(e=null,s=p)):(e=null,s=p)):(e=null,s=p),null!==e&&(_=f,e[0],e=void(Hn=n.substring(s+5,_)));var _;return null===e&&(s=f),e}function kn(){var e,t,n,r,i;return i=s,null!==(e=f())&&null!==(t=f())&&null!==(n=f())&&null!==(r=f())?e=[e,t,n,r]:(e=null,s=i),e}function On(){var e,t,n;return n=s,null!==(e=kn())&&null!==(t=kn())?e=[e,t]:(e=null,s=n),e}function xn(){var e,t,n,r;return r=s,null!==(e=kn())&&null!==(t=kn())&&null!==(n=kn())?e=[e,t,n]:(e=null,s=r),e}function Dn(){var e,t,r,i,a,l;i=s,a=s,null!==(e=D())?(l=s,64===n.charCodeAt(s)?(t="@",s++):(t=null,0===o&&u('"@"')),null!==t&&null!==(r=D())?t=[t,r]:(t=null,s=l),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=a)):(e=null,s=a),null!==e&&(c=i,e=void(Hn.call_id=n.substring(s,c)));var c;return null===e&&(s=i),e}function Nn(){var e;return null===(e=Un())&&null===(e=Mn())&&null===(e=Ln())&&(e=Et()),e}function Un(){var e,t,r,i,a;i=s,a=s,"to-tag"===n.substr(s,6)?(e="to-tag",s+=6):(e=null,0===o&&u('"to-tag"')),null!==e&&null!==(t=M())&&null!==(r=O())?e=[e,t,r]:(e=null,s=a),null!==e&&(l=e[2],e=void(Hn.to_tag=l));var l;return null===e&&(s=i),e}function Mn(){var e,t,r,i,a;i=s,a=s,"from-tag"===n.substr(s,8)?(e="from-tag",s+=8):(e=null,0===o&&u('"from-tag"')),null!==e&&null!==(t=M())&&null!==(r=O())?e=[e,t,r]:(e=null,s=a),null!==e&&(l=e[2],e=void(Hn.from_tag=l));var l;return null===e&&(s=i),e}function Ln(){var e,t;return t=s,"early-only"===n.substr(s,10)?(e="early-only",s+=10):(e=null,0===o&&u('"early-only"')),null!==e&&(e=void(Hn.early_only=!0)),null===e&&(s=t),e}var qn=e("./URI"),Fn=e("./NameAddrHeader"),Hn={};if(null===i[r]()||s!==n.length){var jn=Math.max(s,a),Gn=jn2&&void 0!==arguments[2]?arguments[2]:{},i=e;if(void 0===e||void 0===t)throw new TypeError("Not enough arguments");if(!(e=this._ua.normalizeTarget(e)))throw new TypeError("Invalid target: "+i);var u=a.cloneArray(r.extraHeaders),c=r.eventHandlers||{},d=r.contentType||"text/plain";for(var h in c)Object.prototype.hasOwnProperty.call(c,h)&&this.on(h,c[h]);u.push("Content-Type: "+d),this._request=new o.OutgoingRequest(s.MESSAGE,e,this._ua,null,u),t&&(this._request.body=t);var f=new l(this._ua,this._request,{onRequestTimeout:function(){n._onRequestTimeout()},onTransportError:function(){n._onTransportError()},onReceiveResponse:function(e){n._receiveResponse(e)}});this._newMessage("local",this._request),f.send()}},{key:"init_incoming",value:function(e){this._request=e,this._newMessage("remote",e),this._is_replied||(this._is_replied=!0,e.reply(200)),this._close()}},{key:"accept",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=a.cloneArray(e.extraHeaders),n=e.body;if("incoming"!==this._direction)throw new u.NotSupportedError('"accept" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");this._is_replied=!0,this._request.reply(200,null,t,n)}},{key:"reject",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.status_code||480,n=e.reason_phrase,r=a.cloneArray(e.extraHeaders),i=e.body;if("incoming"!==this._direction)throw new u.NotSupportedError('"reject" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");if(t<300||t>=700)throw new TypeError("Invalid status_code: "+t);this._is_replied=!0,this._request.reply(t,n,r,i)}},{key:"_receiveResponse",value:function(e){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(e.status_code):break;case/^2[0-9]{2}$/.test(e.status_code):this._succeeded("remote",e);break;default:var t=a.sipErrorCause(e.status_code);this._failed("remote",e,t)}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,s.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,s.causes.CONNECTION_ERROR)}},{key:"_close",value:function(){this._closed=!0,this._ua.destroyMessage(this)}},{key:"_newMessage",value:function(e,t){"remote"===e?(this._direction="incoming",this._local_identity=t.to,this._remote_identity=t.from):"local"===e&&(this._direction="outgoing",this._local_identity=t.from,this._remote_identity=t.to),this._ua.newMessage(this,{originator:e,message:this,request:t})}},{key:"_failed",value:function(e,t,n){c("MESSAGE failed"),this._close(),c('emit "failed"'),this.emit("failed",{originator:e,response:t||null,cause:n})}},{key:"_succeeded",value:function(e,t){c("MESSAGE succeeded"),this._close(),c('emit "succeeded"'),this.emit("succeeded",{originator:e,response:t})}},{key:"direction",get:function(){return this._direction}},{key:"local_identity",get:function(){return this._local_identity}},{key:"remote_identity",get:function(){return this._remote_identity}}]),t}()},{"./Constants":2,"./Exceptions":6,"./RequestSender":18,"./SIPMessage":19,"./Utils":26,debug:29,events:31}],10:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n";for(var t in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,t)&&(e+=";"+t,null!==this._parameters[t]&&(e+="="+this._parameters[t]));return e}},{key:"uri",get:function(){return this._uri}},{key:"display_name",get:function(){return this._display_name},set:function(e){this._display_name=0===e?"0":e}}]),e}()},{"./Grammar":7,"./URI":25}],11:[function(e,t,n){"use strict";var r=e("./Grammar"),i=e("./SIPMessage"),s=e("debug")("JsSIP:ERROR:Parser");s.log=console.warn.bind(console),n.parseMessage=function(e,t){var n=void 0,l=void 0,u=e.indexOf("\r\n");if(-1!==u){var c=e.substring(0,u),d=r.parse(c,"Request_Response");if(-1!==d){d.status_code?((n=new i.IncomingResponse).status_code=d.status_code,n.reason_phrase=d.reason_phrase):((n=new i.IncomingRequest(t)).method=d.method,n.ruri=d.uri),n.data=e;for(var h=u+2;;){if(-2===(u=o(e,h))){l=h+2;break}if(-1===u)return void s("parseMessage() | malformed message");if(!0!==(d=a(n,e,h,u)))return void s("parseMessage() |",d.error);h=u+2}if(n.hasHeader("content-length")){var f=n.getHeader("content-length");n.body=e.substr(l,f)}else n.body=e.substring(l);return n}s('parseMessage() | error parsing first line of SIP message: "'+c+'"')}else s("parseMessage() | no CRLF found, not a SIP message")};function o(e,t){var n=t,r=0,i=0;if(e.substring(n,n+2).match(/(^\r\n)/))return-2;for(;0===r;){if(-1===(i=e.indexOf("\r\n",n)))return i;!e.substring(i+2,i+4).match(/(^\r\n)/)&&e.charAt(i+2).match(/(^\s+)/)?n=i+2:r=i}return r}function a(e,t,n,s){var o=void 0,a=t.indexOf(":",n),l=t.substring(n,a).trim(),u=t.substring(a+1,s).trim();switch(l.toLowerCase()){case"via":case"v":e.addHeader("via",u),1===e.getHeaders("via").length?(o=e.parseHeader("Via"))&&(e.via=o,e.via_branch=o.branch):o=0;break;case"from":case"f":e.setHeader("from",u),(o=e.parseHeader("from"))&&(e.from=o,e.from_tag=o.getParam("tag"));break;case"to":case"t":e.setHeader("to",u),(o=e.parseHeader("to"))&&(e.to=o,e.to_tag=o.getParam("tag"));break;case"record-route":if(-1===(o=r.parse(u,"Record_Route")))o=void 0;else{var c=!0,d=!1,h=void 0;try{for(var f,p=o[Symbol.iterator]();!(c=(f=p.next()).done);c=!0){var _=f.value;e.addHeader("record-route",u.substring(_.possition,_.offset)),e.headers["Record-Route"][e.getHeaders("record-route").length-1].parsed=_.parsed}}catch(e){d=!0,h=e}finally{try{!c&&p.return&&p.return()}finally{if(d)throw h}}}break;case"call-id":case"i":e.setHeader("call-id",u),(o=e.parseHeader("call-id"))&&(e.call_id=u);break;case"contact":case"m":if(-1===(o=r.parse(u,"Contact")))o=void 0;else{var m=!0,v=!1,g=void 0;try{for(var y,T=o[Symbol.iterator]();!(m=(y=T.next()).done);m=!0){var C=y.value;e.addHeader("contact",u.substring(C.possition,C.offset)),e.headers.Contact[e.getHeaders("contact").length-1].parsed=C.parsed}}catch(e){v=!0,g=e}finally{try{!m&&T.return&&T.return()}finally{if(v)throw g}}}break;case"content-length":case"l":e.setHeader("content-length",u),o=e.parseHeader("content-length");break;case"content-type":case"c":e.setHeader("content-type",u),o=e.parseHeader("content-type");break;case"cseq":e.setHeader("cseq",u),(o=e.parseHeader("cseq"))&&(e.cseq=o.value),e instanceof i.IncomingResponse&&(e.method=o.method);break;case"max-forwards":e.setHeader("max-forwards",u),o=e.parseHeader("max-forwards");break;case"www-authenticate":e.setHeader("www-authenticate",u),o=e.parseHeader("www-authenticate");break;case"proxy-authenticate":e.setHeader("proxy-authenticate",u),o=e.parseHeader("proxy-authenticate");break;case"session-expires":case"x":e.setHeader("session-expires",u),(o=e.parseHeader("session-expires"))&&(e.session_expires=o.expires,e.session_expires_refresher=o.refresher);break;case"refer-to":case"r":e.setHeader("refer-to",u),(o=e.parseHeader("refer-to"))&&(e.refer_to=o);break;case"replaces":e.setHeader("replaces",u),(o=e.parseHeader("replaces"))&&(e.replaces=o);break;case"event":case"o":e.setHeader("event",u),(o=e.parseHeader("event"))&&(e.event=o);break;default:e.setHeader(l,u),o=0}return void 0!==o||{error:'error parsing header "'+l+'"'}}},{"./Grammar":7,"./SIPMessage":19,debug:29}],12:[function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{},n=arguments[2];y("connect()");var r=e,i=t.eventHandlers||{},s=c.cloneArray(t.extraHeaders),o=t.mediaConstraints||{audio:!0,video:!0},u=t.mediaStream||null,d=t.pcConfig||{iceServers:[]},f=t.rtcConstraints||null,p=t.rtcOfferConstraints||null;if(this._rtcOfferConstraints=p,this._rtcAnswerConstraints=t.rtcAnswerConstraints||null,this._data=t.data||this._data,void 0===e)throw new TypeError("Not enough arguments");if(this._status!==C.STATUS_NULL)throw new l.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new l.NotSupportedError("WebRTC not supported");if(!(e=this._ua.normalizeTarget(e)))throw new TypeError("Invalid target: "+r);this._sessionTimers.enabled&&c.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=a.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=a.SESSION_EXPIRES);for(var _ in i)Object.prototype.hasOwnProperty.call(i,_)&&this.on(_,i[_]);this._from_tag=c.newTag();var m=t.anonymous||!1,v={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:m,outbound:!0}),m&&(v.from_display_name="Anonymous",v.from_uri="sip:anonymous@anonymous.invalid",s.push("P-Preferred-Identity: "+this._ua.configuration.uri.toString()),s.push("Privacy: id")),s.push("Contact: "+this._contact),s.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&s.push("Session-Expires: "+this._sessionTimers.defaultExpires),this._request=new h.InitialOutgoingInviteRequest(e,this._ua,v,s),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(d,f),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,n&&n(this),this._newRTCSession("local",this._request),this._sendInitialRequest(o,p,u)}},{key:"init_incoming",value:function(e,t){var n=this;y("init_incoming()");var r=void 0,i=e.getHeader("Content-Type");e.body&&"application/sdp"!==i?e.reply(415):(this._status=C.STATUS_INVITE_RECEIVED,this._from_tag=e.from_tag,this._id=e.call_id+this._from_tag,this._request=e,this._contact=this._ua.contact.toString(),e.hasHeader("expires")&&(r=1e3*e.getHeader("expires")),e.to_tag=c.newTag(),this._createDialog(e,"UAS",!0)?(e.body?this._late_sdp=!1:this._late_sdp=!0,this._status=C.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(function(){e.reply(408),n._failed("local",null,a.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),r&&(this._timers.expiresTimer=setTimeout(function(){n._status===C.STATUS_WAITING_FOR_ANSWER&&(e.reply(487),n._failed("system",null,a.causes.EXPIRES))},r)),this._direction="incoming",this._local_identity=e.to,this._remote_identity=e.from,t&&t(this),this._newRTCSession("remote",e),this._status!==C.STATUS_TERMINATED&&(e.reply(180,null,["Contact: "+this._contact]),this._progress("local",null))):e.reply(500,"Missing Contact header field"))}},{key:"answer",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};y("answer()");var n=this._request,r=c.cloneArray(t.extraHeaders),i=t.mediaConstraints||{},s=t.mediaStream||null,o=t.pcConfig||{iceServers:[]},u=t.rtcConstraints||null,d=t.rtcAnswerConstraints||null,h=void 0,f=!1,p=!1,_=!1,m=!1;if(this._rtcAnswerConstraints=d,this._rtcOfferConstraints=t.rtcOfferConstraints||null,this._data=t.data||this._data,"incoming"!==this._direction)throw new l.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==C.STATUS_WAITING_FOR_ANSWER)throw new l.InvalidStateError(this._status);if(this._sessionTimers.enabled&&c.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=a.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=a.SESSION_EXPIRES),this._status=C.STATUS_ANSWERED,this._createDialog(n,"UAS")){clearTimeout(this._timers.userNoAnswerTimer),r.unshift("Contact: "+this._contact);var v=n.parseSDP();Array.isArray(v.media)||(v.media=[v.media]);var g=!0,S=!1,E=void 0;try{for(var b,R=v.media[Symbol.iterator]();!(g=(b=R.next()).done);g=!0){var A=b.value;"audio"===A.type&&(f=!0,A.direction&&"sendrecv"!==A.direction||(_=!0)),"video"===A.type&&(p=!0,A.direction&&"sendrecv"!==A.direction||(m=!0))}}catch(e){S=!0,E=e}finally{try{!g&&R.return&&R.return()}finally{if(S)throw E}}if(s&&!1===i.audio){h=s.getAudioTracks();var w=!0,I=!1,P=void 0;try{for(var k,O=h[Symbol.iterator]();!(w=(k=O.next()).done);w=!0){var x=k.value;s.removeTrack(x)}}catch(e){I=!0,P=e}finally{try{!w&&O.return&&O.return()}finally{if(I)throw P}}}if(s&&!1===i.video){h=s.getVideoTracks();var D=!0,N=!1,U=void 0;try{for(var M,L=h[Symbol.iterator]();!(D=(M=L.next()).done);D=!0){var q=M.value;s.removeTrack(q)}}catch(e){N=!0,U=e}finally{try{!D&&L.return&&L.return()}finally{if(N)throw U}}}s||void 0!==i.audio||(i.audio=_),s||void 0!==i.video||(i.video=m),s||f||(i.audio=!1),s||p||(i.video=!1),this._createRTCConnection(o,u),Promise.resolve().then(function(){return s||(i.audio||i.video?(e._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(i).catch(function(t){if(e._status===C.STATUS_TERMINATED)throw new Error("terminated");throw n.reply(480),e._failed("local",null,a.causes.USER_DENIED_MEDIA_ACCESS),T('emit "getusermediafailed" [error:%o]',t),e.emit("getusermediafailed",t),new Error("getUserMedia() failed")})):void 0)}).then(function(t){if(e._status===C.STATUS_TERMINATED)throw new Error("terminated");e._localMediaStream=t,t&&e._connection.addStream(t)}).then(function(){if(!e._late_sdp){var t={originator:"remote",type:"offer",sdp:n.body};y('emit "sdp"'),e.emit("sdp",t);var r=new RTCSessionDescription({type:"offer",sdp:t.sdp});return e._connectionPromiseQueue=e._connectionPromiseQueue.then(function(){return e._connection.setRemoteDescription(r)}).catch(function(t){throw n.reply(488),e._failed("system",null,a.causes.WEBRTC_ERROR),T('emit "peerconnection:setremotedescriptionfailed" [error:%o]',t),e.emit("peerconnection:setremotedescriptionfailed",t),new Error("peerconnection.setRemoteDescription() failed")}),e._connectionPromiseQueue}}).then(function(){if(e._status===C.STATUS_TERMINATED)throw new Error("terminated");return e._connecting(n),e._late_sdp?e._createLocalDescription("offer",e._rtcOfferConstraints).catch(function(){throw n.reply(500),new Error("_createLocalDescription() failed")}):e._createLocalDescription("answer",d).catch(function(){throw n.reply(500),new Error("_createLocalDescription() failed")})}).then(function(t){if(e._status===C.STATUS_TERMINATED)throw new Error("terminated");e._handleSessionTimersInIncomingRequest(n,r),n.reply(200,null,r,t,function(){e._status=C.STATUS_WAITING_FOR_ACK,e._setInvite2xxTimer(n,t),e._setACKTimer(),e._accepted("local")},function(){e._failed("system",null,a.causes.CONNECTION_ERROR)})}).catch(function(t){e._status!==C.STATUS_TERMINATED&&T(t)})}else n.reply(500,"Error creating dialog")}},{key:"terminate",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};y("terminate()");var n=t.cause||a.causes.BYE,r=c.cloneArray(t.extraHeaders),i=t.body,s=void 0,o=t.status_code,d=t.reason_phrase;if(this._status===C.STATUS_TERMINATED)throw new l.InvalidStateError(this._status);switch(this._status){case C.STATUS_NULL:case C.STATUS_INVITE_SENT:case C.STATUS_1XX_RECEIVED:if(y("canceling session"),o&&(o<200||o>=700))throw new TypeError("Invalid status_code: "+o);o&&(s="SIP ;cause="+o+' ;text="'+(d=d||a.REASON_PHRASE[o]||"")+'"'),this._status===C.STATUS_NULL||this._status===C.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=s):this._status===C.STATUS_1XX_RECEIVED&&this._request.cancel(s),this._status=C.STATUS_CANCELED,this._failed("local",null,a.causes.CANCELED);break;case C.STATUS_WAITING_FOR_ANSWER:case C.STATUS_ANSWERED:if(y("rejecting session"),(o=o||480)<300||o>=700)throw new TypeError("Invalid status_code: "+o);this._request.reply(o,d,r,i),this._failed("local",null,a.causes.REJECTED);break;case C.STATUS_WAITING_FOR_ACK:case C.STATUS_CONFIRMED:if(y("terminating session"),d=t.reason_phrase||a.REASON_PHRASE[o]||"",o&&(o<200||o>=700))throw new TypeError("Invalid status_code: "+o);if(o&&r.push("Reason: SIP ;cause="+o+'; text="'+d+'"'),this._status===C.STATUS_WAITING_FOR_ACK&&"incoming"===this._direction&&this._request.server_transaction.state!==u.C.STATUS_TERMINATED){var h=this._dialog;this.receiveRequest=function(t){t.method===a.ACK&&(e.sendRequest(a.BYE,{extraHeaders:r,body:i}),h.terminate())},this._request.server_transaction.on("stateChanged",function(){e._request.server_transaction.state===u.C.STATUS_TERMINATED&&(e.sendRequest(a.BYE,{extraHeaders:r,body:i}),h.terminate())}),this._ended("local",null,n),this._dialog=h,this._ua.newDialog(h)}else this.sendRequest(a.BYE,{extraHeaders:r,body:i}),this._ended("local",null,n)}}},{key:"sendDTMF",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};y("sendDTMF() | tones: %s",e);var n=0,r=t.duration||null,i=t.interToneGap||null;if(void 0===e)throw new TypeError("Not enough arguments");if(this._status!==C.STATUS_CONFIRMED&&this._status!==C.STATUS_WAITING_FOR_ACK)throw new l.InvalidStateError(this._status);if("number"==typeof e&&(e=e.toString()),!e||"string"!=typeof e||!e.match(/^[0-9A-DR#*,]+$/i))throw new TypeError("Invalid tones: "+e);if(r&&!c.isDecimal(r))throw new TypeError("Invalid tone duration: "+r);if(r?r<_.C.MIN_DURATION?(y('"duration" value is lower than the minimum allowed, setting it to '+_.C.MIN_DURATION+" milliseconds"),r=_.C.MIN_DURATION):r>_.C.MAX_DURATION?(y('"duration" value is greater than the maximum allowed, setting it to '+_.C.MAX_DURATION+" milliseconds"),r=_.C.MAX_DURATION):r=Math.abs(r):r=_.C.DEFAULT_DURATION,t.duration=r,i&&!c.isDecimal(i))throw new TypeError("Invalid interToneGap: "+i);i?i<_.C.MIN_INTER_TONE_GAP?(y('"interToneGap" value is lower than the minimum allowed, setting it to '+_.C.MIN_INTER_TONE_GAP+" milliseconds"),i=_.C.MIN_INTER_TONE_GAP):i=Math.abs(i):i=_.C.DEFAULT_INTER_TONE_GAP,this._tones?this._tones+=e:(this._tones=e,function e(){var s=this;var o=void 0;if(this._status===C.STATUS_TERMINATED||!this._tones||n>=this._tones.length)return void(this._tones=null);var a=this._tones[n];n+=1;if(","===a)o=2e3;else{var l=new _(this);t.eventHandlers={onFailed:function(){s._tones=null}},l.send(a,t),o=r+i}setTimeout(e.bind(this),o)}.call(this))}},{key:"sendInfo",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(y("sendInfo()"),this._status!==C.STATUS_CONFIRMED&&this._status!==C.STATUS_WAITING_FOR_ACK)throw new l.InvalidStateError(this._status);new m(this).send(e,t,n)}},{key:"mute",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{audio:!0,video:!1};y("mute()");var t=!1,n=!1;!1===this._audioMuted&&e.audio&&(t=!0,this._audioMuted=!0,this._toogleMuteAudio(!0)),!1===this._videoMuted&&e.video&&(n=!0,this._videoMuted=!0,this._toogleMuteVideo(!0)),!0!==t&&!0!==n||this._onmute({audio:t,video:n})}},{key:"unmute",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{audio:!0,video:!0};y("unmute()");var t=!1,n=!1;!0===this._audioMuted&&e.audio&&(t=!0,this._audioMuted=!1,!1===this._localHold&&this._toogleMuteAudio(!1)),!0===this._videoMuted&&e.video&&(n=!0,this._videoMuted=!1,!1===this._localHold&&this._toogleMuteVideo(!1)),!0!==t&&!0!==n||this._onunmute({audio:t,video:n})}},{key:"hold",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];if(y("hold()"),this._status!==C.STATUS_WAITING_FOR_ACK&&this._status!==C.STATUS_CONFIRMED)return!1;if(!0===this._localHold)return!1;if(!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");var r={succeeded:function(){n&&n()},failed:function(){e.terminate({cause:a.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:r,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:r,extraHeaders:t.extraHeaders}),!0}},{key:"unhold",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];if(y("unhold()"),this._status!==C.STATUS_WAITING_FOR_ACK&&this._status!==C.STATUS_CONFIRMED)return!1;if(!1===this._localHold)return!1;if(!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");var r={succeeded:function(){n&&n()},failed:function(){e.terminate({cause:a.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:r,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:r,extraHeaders:t.extraHeaders}),!0}},{key:"renegotiate",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];y("renegotiate()");var r=t.rtcOfferConstraints||null;if(this._status!==C.STATUS_WAITING_FOR_ACK&&this._status!==C.STATUS_CONFIRMED)return!1;if(!this._isReadyToReOffer())return!1;var i={succeeded:function(){n&&n()},failed:function(){e.terminate({cause:a.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:i,rtcOfferConstraints:r,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:i,rtcOfferConstraints:r,extraHeaders:t.extraHeaders}),!0}},{key:"refer",value:function(e,t){var n=this;y("refer()");var r=e;if(this._status!==C.STATUS_WAITING_FOR_ACK&&this._status!==C.STATUS_CONFIRMED)return!1;if(!(e=this._ua.normalizeTarget(e)))throw new TypeError("Invalid target: "+r);var i=new g(this);i.sendRefer(e,t);var s=i.id;return this._referSubscribers[s]=i,i.on("requestFailed",function(){delete n._referSubscribers[s]}),i.on("accepted",function(){delete n._referSubscribers[s]}),i.on("failed",function(){delete n._referSubscribers[s]}),i}},{key:"sendRequest",value:function(e,t){return y("sendRequest()"),this._dialog.sendRequest(e,t)}},{key:"receiveRequest",value:function(e){var t=this;if(y("receiveRequest()"),e.method===a.CANCEL)this._status!==C.STATUS_WAITING_FOR_ANSWER&&this._status!==C.STATUS_ANSWERED||(this._status=C.STATUS_CANCELED,this._request.reply(487),this._failed("remote",e,a.causes.CANCELED));else switch(e.method){case a.ACK:if(this._status!==C.STATUS_WAITING_FOR_ACK)return;if(this._status=C.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!e.body){this.terminate({cause:a.causes.MISSING_SDP,status_code:400});break}var n={originator:"remote",type:"answer",sdp:e.body};y('emit "sdp"'),this.emit("sdp",n);var r=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._connection.setRemoteDescription(r)}).then(function(){t._is_confirmed||t._confirmed("remote",e)}).catch(function(e){t.terminate({cause:a.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),T('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)})}else this._is_confirmed||this._confirmed("remote",e);break;case a.BYE:this._status===C.STATUS_CONFIRMED?(e.reply(200),this._ended("remote",e,a.causes.BYE)):this._status===C.STATUS_INVITE_RECEIVED?(e.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",e,a.causes.BYE)):e.reply(403,"Wrong Status");break;case a.INVITE:this._status===C.STATUS_CONFIRMED?e.hasHeader("replaces")?this._receiveReplaces(e):this._receiveReinvite(e):e.reply(403,"Wrong Status");break;case a.INFO:if(this._status===C.STATUS_1XX_RECEIVED||this._status===C.STATUS_WAITING_FOR_ANSWER||this._status===C.STATUS_ANSWERED||this._status===C.STATUS_WAITING_FOR_ACK||this._status===C.STATUS_CONFIRMED){var i=e.getHeader("content-type");i&&i.match(/^application\/dtmf-relay/i)?new _(this).init_incoming(e):void 0!==i?new m(this).init_incoming(e):e.reply(415)}else e.reply(403,"Wrong Status");break;case a.UPDATE:this._status===C.STATUS_CONFIRMED?this._receiveUpdate(e):e.reply(403,"Wrong Status");break;case a.REFER:this._status===C.STATUS_CONFIRMED?this._receiveRefer(e):e.reply(403,"Wrong Status");break;case a.NOTIFY:this._status===C.STATUS_CONFIRMED?this._receiveNotify(e):e.reply(403,"Wrong Status");break;default:e.reply(501)}}},{key:"onTransportError",value:function(){T("onTransportError()"),this._status!==C.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:a.causes.CONNECTION_ERROR,cause:a.causes.CONNECTION_ERROR})}},{key:"onRequestTimeout",value:function(){T("onRequestTimeout()"),this._status!==C.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:a.causes.REQUEST_TIMEOUT,cause:a.causes.REQUEST_TIMEOUT})}},{key:"onDialogError",value:function(){T("onDialogError()"),this._status!==C.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:a.causes.DIALOG_ERROR,cause:a.causes.DIALOG_ERROR})}},{key:"newDTMF",value:function(e){y("newDTMF()"),this.emit("newDTMF",e)}},{key:"newInfo",value:function(e){y("newInfo()"),this.emit("newInfo",e)}},{key:"_isReadyToReOffer",value:function(){return this._rtcReady?this._dialog?!0!==this._dialog.uac_pending_reply&&!0!==this._dialog.uas_pending_reply||(y("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):(y("_isReadyToReOffer() | session not established yet"),!1):(y("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}},{key:"_close",value:function(){if(y("close()"),this._status!==C.STATUS_TERMINATED){if(this._status=C.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(e){T("close() | error closing the RTCPeerConnection: %o",e)}this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(y("close() | closing local MediaStream"),c.closeMediaStream(this._localMediaStream));for(var e in this._timers)Object.prototype.hasOwnProperty.call(this._timers,e)&&clearTimeout(this._timers[e]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(var t in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,t)&&(this._earlyDialogs[t].terminate(),delete this._earlyDialogs[t]);for(var n in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,n)&&delete this._referSubscribers[n];this._ua.destroyRTCSession(this)}}},{key:"_setInvite2xxTimer",value:function(e,t){var n=d.T1;this._timers.invite2xxTimer=setTimeout(function r(){this._status===C.STATUS_WAITING_FOR_ACK&&(e.reply(200,null,["Contact: "+this._contact],t),nd.T2&&(n=d.T2),this._timers.invite2xxTimer=setTimeout(r.bind(this),n))}.bind(this),n)}},{key:"_setACKTimer",value:function(){var e=this;this._timers.ackTimer=setTimeout(function(){e._status===C.STATUS_WAITING_FOR_ACK&&(y("no ACK received, terminating the session"),clearTimeout(e._timers.invite2xxTimer),e.sendRequest(a.BYE),e._ended("remote",null,a.causes.NO_ACK))},d.TIMER_H)}},{key:"_createRTCConnection",value:function(e,t){var n=this;this._connection=new RTCPeerConnection(e,t),this._connection.addEventListener("iceconnectionstatechange",function(){"failed"===n._connection.iceConnectionState&&n.terminate({cause:a.causes.RTP_TIMEOUT,status_code:408,reason_phrase:a.causes.RTP_TIMEOUT})}),y('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}},{key:"_createLocalDescription",value:function(e,t){var n=this;if(y("createLocalDescription()"),"offer"!==e&&"answer"!==e)throw new Error('createLocalDescription() | invalid type "'+e+'"');var r=this._connection;return this._rtcReady=!1,Promise.resolve().then(function(){return"offer"===e?r.createOffer(t).catch(function(e){return T('emit "peerconnection:createofferfailed" [error:%o]',e),n.emit("peerconnection:createofferfailed",e),Promise.reject(e)}):r.createAnswer(t).catch(function(e){return T('emit "peerconnection:createanswerfailed" [error:%o]',e),n.emit("peerconnection:createanswerfailed",e),Promise.reject(e)})}).then(function(e){return r.setLocalDescription(e).catch(function(e){return n._rtcReady=!0,T('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',e),n.emit("peerconnection:setlocaldescriptionfailed",e),Promise.reject(e)})}).then(function(){if("complete"===r.iceGatheringState){n._rtcReady=!0;var t={originator:"local",type:e,sdp:r.localDescription.sdp};return y('emit "sdp"'),n.emit("sdp",t),Promise.resolve(t.sdp)}return new Promise(function(t){var i=!1,s=void 0,o=function(){r.removeEventListener("icecandidate",s),i=!0,n._rtcReady=!0;var o={originator:"local",type:e,sdp:r.localDescription.sdp};y('emit "sdp"'),n.emit("sdp",o),t(o.sdp)};r.addEventListener("icecandidate",s=function(e){var t=e.candidate;t?n.emit("icecandidate",{candidate:t,ready:o}):i||o()})})})}},{key:"_createDialog",value:function(e,t,n){var r="UAS"===t?e.to_tag:e.from_tag,i="UAS"===t?e.from_tag:e.to_tag,s=e.call_id+r+i,o=this._earlyDialogs[s];if(n)return!!o||((o=new f(this,e,t,f.C.STATUS_EARLY)).error?(y(o.error),this._failed("remote",e,a.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[s]=o,!0));if(this._from_tag=e.from_tag,this._to_tag=e.to_tag,o)return o.update(e,t),this._dialog=o,delete this._earlyDialogs[s],!0;var l=new f(this,e,t);return l.error?(y(l.error),this._failed("remote",e,a.causes.INTERNAL_ERROR),!1):(this._dialog=l,!0)}},{key:"_receiveReinvite",value:function(e){var t=this;y("receiveReinvite()");var n=e.getHeader("Content-Type"),r={request:e,callback:void 0,reject:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i=!0;var n=t.status_code||403,r=t.reason_phrase||"",s=c.cloneArray(t.extraHeaders);if(this._status!==C.STATUS_CONFIRMED)return!1;if(n<300||n>=700)throw new TypeError("Invalid status_code: "+n);e.reply(n,r,s)}.bind(this)},i=!1;if(this.emit("reinvite",r),!i){if(this._late_sdp=!1,!e.body)return this._late_sdp=!0,void(this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._createLocalDescription("offer",t._rtcOfferConstraints)}).then(function(e){s.call(t,e)}).catch(function(){e.reply(500)}));if("application/sdp"!==n)return y("invalid Content-Type"),void e.reply(415);this._processInDialogSdpOffer(e).then(function(e){t._status!==C.STATUS_TERMINATED&&s.call(t,e)}).catch(function(e){T(e)})}function s(t){var n=this,i=["Contact: "+this._contact];this._handleSessionTimersInIncomingRequest(e,i),this._late_sdp&&(t=this._mangleOffer(t)),e.reply(200,null,i,t,function(){n._status=C.STATUS_WAITING_FOR_ACK,n._setInvite2xxTimer(e,t),n._setACKTimer()}),"function"==typeof r.callback&&r.callback()}}},{key:"_receiveUpdate",value:function(e){var t=this;y("receiveUpdate()");var n=e.getHeader("Content-Type"),r={request:e,callback:void 0,reject:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i=!0;var n=t.status_code||403,r=t.reason_phrase||"",s=c.cloneArray(t.extraHeaders);if(this._status!==C.STATUS_CONFIRMED)return!1;if(n<300||n>=700)throw new TypeError("Invalid status_code: "+n);e.reply(n,r,s)}.bind(this)},i=!1;if(this.emit("update",r),!i)if(e.body){if("application/sdp"!==n)return y("invalid Content-Type"),void e.reply(415);this._processInDialogSdpOffer(e).then(function(e){t._status!==C.STATUS_TERMINATED&&s.call(t,e)}).catch(function(e){T(e)})}else s.call(this,null);function s(t){var n=["Contact: "+this._contact];this._handleSessionTimersInIncomingRequest(e,n),e.reply(200,null,n,t),"function"==typeof r.callback&&r.callback()}}},{key:"_processInDialogSdpOffer",value:function(e){var t=this;y("_processInDialogSdpOffer()");var n=e.parseSDP(),r=!1,i=!0,s=!1,o=void 0;try{for(var a,l=n.media[Symbol.iterator]();!(i=(a=l.next()).done);i=!0){var u=a.value;if(-1!==S.indexOf(u.type)){var c=u.direction||n.direction||"sendrecv";if("sendonly"!==c&&"inactive"!==c){r=!1;break}r=!0}}}catch(e){s=!0,o=e}finally{try{!i&&l.return&&l.return()}finally{if(s)throw o}}var d={originator:"remote",type:"offer",sdp:e.body};y('emit "sdp"'),this.emit("sdp",d);var h=new RTCSessionDescription({type:"offer",sdp:d.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){if(t._status===C.STATUS_TERMINATED)throw new Error("terminated");return t._connection.setRemoteDescription(h).catch(function(n){throw e.reply(488),T('emit "peerconnection:setremotedescriptionfailed" [error:%o]',n),t.emit("peerconnection:setremotedescriptionfailed",n),new Error("peerconnection.setRemoteDescription() failed")})}).then(function(){if(t._status===C.STATUS_TERMINATED)throw new Error("terminated");!0===t._remoteHold&&!1===r?(t._remoteHold=!1,t._onunhold("remote")):!1===t._remoteHold&&!0===r&&(t._remoteHold=!0,t._onhold("remote"))}).then(function(){if(t._status===C.STATUS_TERMINATED)throw new Error("terminated");return t._createLocalDescription("answer",t._rtcAnswerConstraints).catch(function(){throw e.reply(500),new Error("_createLocalDescription() failed")})}),this._connectionPromiseQueue}},{key:"_receiveRefer",value:function(e){var n=this;if(y("receiveRefer()"),void 0===r(e.refer_to))return y("no Refer-To header field present in REFER"),void e.reply(400);if(e.refer_to.uri.scheme!==a.SIP)return y("Refer-To header field points to a non-SIP URI scheme"),void e.reply(416);e.reply(202);var i=new v(this,e.cseq);y('emit "refer"'),this.emit("refer",{request:e,accept:function(r,s){(function(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(n="function"==typeof n?n:null,this._status!==C.STATUS_WAITING_FOR_ACK&&this._status!==C.STATUS_CONFIRMED)return!1;var s=new t(this._ua);if(s.on("progress",function(e){var t=e.response;i.notify(t.status_code,t.reason_phrase)}),s.on("accepted",function(e){var t=e.response;i.notify(t.status_code,t.reason_phrase)}),s.on("failed",function(e){var t=e.message,n=e.cause;t?i.notify(t.status_code,t.reason_phrase):i.notify(487,n)}),e.refer_to.uri.hasHeader("replaces")){var o=decodeURIComponent(e.refer_to.uri.getHeader("replaces"));r.extraHeaders=c.cloneArray(r.extraHeaders),r.extraHeaders.push("Replaces: "+o)}s.connect(e.refer_to.uri.toAor(),r,n)}).call(n,r,s)},reject:function(){(function(){i.notify(603)}).call(n)}})}},{key:"_receiveNotify",value:function(e){switch(y("receiveNotify()"),void 0===r(e.event)&&e.reply(400),e.event.event){case"refer":var t=void 0,n=void 0;if(e.event.params&&e.event.params.id)t=e.event.params.id,n=this._referSubscribers[t];else{if(1!==Object.keys(this._referSubscribers).length)return void e.reply(400,"Missing event id parameter");n=this._referSubscribers[Object.keys(this._referSubscribers)[0]]}if(!n)return void e.reply(481,"Subscription does not exist");n.receiveNotify(e),e.reply(200);break;default:e.reply(489)}}},{key:"_receiveReplaces",value:function(e){var n=this;y("receiveReplaces()");this.emit("replaces",{request:e,accept:function(r){(function(n){var r=this;if(this._status!==C.STATUS_WAITING_FOR_ACK&&this._status!==C.STATUS_CONFIRMED)return!1;var i=new t(this._ua);i.on("confirmed",function(){r.terminate()}),i.init_incoming(e,n)}).call(n,r)},reject:function(){(function(){y("Replaced INVITE rejected by the user"),e.reply(486)}).call(n)}})}},{key:"_sendInitialRequest",value:function(e,t,n){var r=this,i=new p(this._ua,this._request,{onRequestTimeout:function(){r.onRequestTimeout()},onTransportError:function(){r.onTransportError()},onAuthenticated:function(e){r._request=e},onReceiveResponse:function(e){r._receiveInviteResponse(e)}});Promise.resolve().then(function(){return n||(e.audio||e.video?(r._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(e).catch(function(e){if(r._status===C.STATUS_TERMINATED)throw new Error("terminated");throw r._failed("local",null,a.causes.USER_DENIED_MEDIA_ACCESS),T('emit "getusermediafailed" [error:%o]',e),r.emit("getusermediafailed"),e})):void 0)}).then(function(e){if(r._status===C.STATUS_TERMINATED)throw new Error("terminated");return r._localMediaStream=e,e&&r._connection.addStream(e),r._connecting(r._request),r._createLocalDescription("offer",t).catch(function(e){throw r._failed("local",null,a.causes.WEBRTC_ERROR),e})}).then(function(e){if(r._is_canceled||r._status===C.STATUS_TERMINATED)throw new Error("terminated");r._request.body=e,r._status=C.STATUS_INVITE_SENT,y('emit "sending" [request:%o]',r._request),r.emit("sending",{request:r._request}),i.send()}).catch(function(e){r._status!==C.STATUS_TERMINATED&&T(e)})}},{key:"_receiveInviteResponse",value:function(e){var t=this;if(y("receiveInviteResponse()"),this._dialog&&e.status_code>=200&&e.status_code<=299){if(this._dialog.id.call_id===e.call_id&&this._dialog.id.local_tag===e.from_tag&&this._dialog.id.remote_tag===e.to_tag)return void this.sendRequest(a.ACK);var n=new f(this,e,"UAC");return void 0!==n.error?void y(n.error):(this.sendRequest(a.ACK),void this.sendRequest(a.BYE))}if(this._is_canceled)e.status_code>=100&&e.status_code<200?this._request.cancel(this._cancel_reason):e.status_code>=200&&e.status_code<299&&this._acceptAndTerminate(e);else if(this._status===C.STATUS_INVITE_SENT||this._status===C.STATUS_1XX_RECEIVED)switch(!0){case/^100$/.test(e.status_code):this._status=C.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(e.status_code):if(!e.to_tag){y("1xx response received without to tag");break}if(e.hasHeader("contact")&&!this._createDialog(e,"UAC",!0))break;if(this._status=C.STATUS_1XX_RECEIVED,this._progress("remote",e),!e.body)break;var r={originator:"remote",type:"answer",sdp:e.body};y('emit "sdp"'),this.emit("sdp",r);var i=new RTCSessionDescription({type:"answer",sdp:r.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._connection.setRemoteDescription(i)}).catch(function(e){T('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)});break;case/^2[0-9]{2}$/.test(e.status_code):if(this._status=C.STATUS_CONFIRMED,!e.body){this._acceptAndTerminate(e,400,a.causes.MISSING_SDP),this._failed("remote",e,a.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(e,"UAC"))break;var s={originator:"remote",type:"answer",sdp:e.body};y('emit "sdp"'),this.emit("sdp",s);var o=new RTCSessionDescription({type:"answer",sdp:s.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){if("stable"===t._connection.signalingState)return t._connection.createOffer().then(function(e){return t._connection.setLocalDescription(e)}).catch(function(n){t._acceptAndTerminate(e,500,n.toString()),t._failed("local",e,a.causes.WEBRTC_ERROR)})}).then(function(){t._connection.setRemoteDescription(o).then(function(){t._handleSessionTimersInIncomingResponse(e),t._accepted("remote",e),t.sendRequest(a.ACK),t._confirmed("local",null)}).catch(function(n){t._acceptAndTerminate(e,488,"Not Acceptable Here"),t._failed("remote",e,a.causes.BAD_MEDIA_DESCRIPTION),T('emit "peerconnection:setremotedescriptionfailed" [error:%o]',n),t.emit("peerconnection:setremotedescriptionfailed",n)})});break;default:var l=c.sipErrorCause(e.status_code);this._failed("remote",e,l)}}},{key:"_sendReinvite",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};y("sendReinvite()");var n=c.cloneArray(t.extraHeaders),r=t.eventHandlers||{},i=t.rtcOfferConstraints||this._rtcOfferConstraints||null,s=!1;n.push("Contact: "+this._contact),n.push("Content-Type: application/sdp"),this._sessionTimers.running&&n.push("Session-Expires: "+this._sessionTimers.currentExpires+";refresher="+(this._sessionTimers.refresher?"uac":"uas")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return e._createLocalDescription("offer",i)}).then(function(t){t=e._mangleOffer(t),e.sendRequest(a.INVITE,{extraHeaders:n,body:t,eventHandlers:{onSuccessResponse:function(t){(function(e){var t=this;if(this._status===C.STATUS_TERMINATED)return;if(this.sendRequest(a.ACK),s)return;{if(this._handleSessionTimersInIncomingResponse(e),!e.body)return void o.call(this);if("application/sdp"!==e.getHeader("Content-Type"))return void o.call(this)}var n={originator:"remote",type:"answer",sdp:e.body};y('emit "sdp"'),this.emit("sdp",n);var i=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._connection.setRemoteDescription(i)}).then(function(){r.succeeded&&r.succeeded(e)}).catch(function(e){o.call(t),T('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)})}).call(e,t),s=!0},onErrorResponse:function(t){o.call(e,t)},onTransportError:function(){e.onTransportError()},onRequestTimeout:function(){e.onRequestTimeout()},onDialogError:function(){e.onDialogError()}}})}).catch(function(){o()});function o(e){r.failed&&r.failed(e)}}},{key:"_sendUpdate",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};y("sendUpdate()");var n=c.cloneArray(t.extraHeaders),r=t.eventHandlers||{},i=t.rtcOfferConstraints||this._rtcOfferConstraints||null,s=t.sdpOffer||!1,o=!1;n.push("Contact: "+this._contact),this._sessionTimers.running&&n.push("Session-Expires: "+this._sessionTimers.currentExpires+";refresher="+(this._sessionTimers.refresher?"uac":"uas")),s?(n.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return e._createLocalDescription("offer",i)}).then(function(t){t=e._mangleOffer(t),e.sendRequest(a.UPDATE,{extraHeaders:n,body:t,eventHandlers:{onSuccessResponse:function(t){l.call(e,t),o=!0},onErrorResponse:function(t){u.call(e,t)},onTransportError:function(){e.onTransportError()},onRequestTimeout:function(){e.onRequestTimeout()},onDialogError:function(){e.onDialogError()}}})}).catch(function(){u.call(e)})):this.sendRequest(a.UPDATE,{extraHeaders:n,eventHandlers:{onSuccessResponse:function(t){l.call(e,t)},onErrorResponse:function(t){u.call(e,t)},onTransportError:function(){e.onTransportError()},onRequestTimeout:function(){e.onRequestTimeout()},onDialogError:function(){e.onDialogError()}}});function l(e){var t=this;if(this._status!==C.STATUS_TERMINATED&&!o)if(this._handleSessionTimersInIncomingResponse(e),s){if(!e.body)return void u.call(this);if("application/sdp"!==e.getHeader("Content-Type"))return void u.call(this);var n={originator:"remote",type:"answer",sdp:e.body};y('emit "sdp"'),this.emit("sdp",n);var i=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._connection.setRemoteDescription(i)}).then(function(){r.succeeded&&r.succeeded(e)}).catch(function(e){u.call(t),T('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)})}else r.succeeded&&r.succeeded(e)}function u(e){r.failed&&r.failed(e)}}},{key:"_acceptAndTerminate",value:function(e,t,n){y("acceptAndTerminate()");var r=[];t&&(n=n||a.REASON_PHRASE[t]||"",r.push("Reason: SIP ;cause="+t+'; text="'+n+'"')),(this._dialog||this._createDialog(e,"UAC"))&&(this.sendRequest(a.ACK),this.sendRequest(a.BYE,{extraHeaders:r})),this._status=C.STATUS_TERMINATED}},{key:"_mangleOffer",value:function(e){if(!this._localHold&&!this._remoteHold)return e;if(e=o.parse(e),this._localHold&&!this._remoteHold){y("mangleOffer() | me on hold, mangling offer");var t=!0,n=!1,r=void 0;try{for(var i,s=e.media[Symbol.iterator]();!(t=(i=s.next()).done);t=!0){var a=i.value;-1!==S.indexOf(a.type)&&(a.direction?"sendrecv"===a.direction?a.direction="sendonly":"recvonly"===a.direction&&(a.direction="inactive"):a.direction="sendonly")}}catch(e){n=!0,r=e}finally{try{!t&&s.return&&s.return()}finally{if(n)throw r}}}else if(this._localHold&&this._remoteHold){y("mangleOffer() | both on hold, mangling offer");var l=!0,u=!1,c=void 0;try{for(var d,h=e.media[Symbol.iterator]();!(l=(d=h.next()).done);l=!0){var f=d.value;-1!==S.indexOf(f.type)&&(f.direction="inactive")}}catch(e){u=!0,c=e}finally{try{!l&&h.return&&h.return()}finally{if(u)throw c}}}else if(this._remoteHold){y("mangleOffer() | remote on hold, mangling offer");var p=!0,_=!1,m=void 0;try{for(var v,g=e.media[Symbol.iterator]();!(p=(v=g.next()).done);p=!0){var T=v.value;-1!==S.indexOf(T.type)&&(T.direction?"sendrecv"===T.direction?T.direction="recvonly":"recvonly"===T.direction&&(T.direction="inactive"):T.direction="recvonly")}}catch(e){_=!0,m=e}finally{try{!p&&g.return&&g.return()}finally{if(_)throw m}}}return o.write(e)}},{key:"_setLocalMediaStatus",value:function(){var e=!0,t=!0;(this._localHold||this._remoteHold)&&(e=!1,t=!1),this._audioMuted&&(e=!1),this._videoMuted&&(t=!1),this._toogleMuteAudio(!e),this._toogleMuteVideo(!t)}},{key:"_handleSessionTimersInIncomingRequest",value:function(e,t){if(this._sessionTimers.enabled){var n=void 0;e.session_expires&&e.session_expires>=a.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=e.session_expires,n=e.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,n="uas"),t.push("Session-Expires: "+this._sessionTimers.currentExpires+";refresher="+n),this._sessionTimers.refresher="uas"===n,this._runSessionTimer()}}},{key:"_handleSessionTimersInIncomingResponse",value:function(e){if(this._sessionTimers.enabled){var t=void 0;e.session_expires&&e.session_expires>=a.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=e.session_expires,t=e.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,t="uac"),this._sessionTimers.refresher="uac"===t,this._runSessionTimer()}}},{key:"_runSessionTimer",value:function(){var e=this,t=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(function(){e._status!==C.STATUS_TERMINATED&&(y("runSessionTimer() | sending session refresh request"),e._sessionTimers.refreshMethod===a.UPDATE?e._sendUpdate():e._sendReinvite())},500*t):this._sessionTimers.timer=setTimeout(function(){e._status!==C.STATUS_TERMINATED&&(T("runSessionTimer() | timer expired, terminating the session"),e.terminate({cause:a.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},1100*t)}},{key:"_toogleMuteAudio",value:function(e){var t=this._connection.getLocalStreams(),n=!0,r=!1,i=void 0;try{for(var s,o=t[Symbol.iterator]();!(n=(s=o.next()).done);n=!0){var a=s.value.getAudioTracks(),l=!0,u=!1,c=void 0;try{for(var d,h=a[Symbol.iterator]();!(l=(d=h.next()).done);l=!0){d.value.enabled=!e}}catch(e){u=!0,c=e}finally{try{!l&&h.return&&h.return()}finally{if(u)throw c}}}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}}},{key:"_toogleMuteVideo",value:function(e){var t=this._connection.getLocalStreams(),n=!0,r=!1,i=void 0;try{for(var s,o=t[Symbol.iterator]();!(n=(s=o.next()).done);n=!0){var a=s.value.getVideoTracks(),l=!0,u=!1,c=void 0;try{for(var d,h=a[Symbol.iterator]();!(l=(d=h.next()).done);l=!0){d.value.enabled=!e}}catch(e){u=!0,c=e}finally{try{!l&&h.return&&h.return()}finally{if(u)throw c}}}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}}},{key:"_newRTCSession",value:function(e,t){y("newRTCSession()"),this._ua.newRTCSession(this,{originator:e,session:this,request:t})}},{key:"_connecting",value:function(e){y("session connecting"),y('emit "connecting"'),this.emit("connecting",{request:e})}},{key:"_progress",value:function(e,t){y("session progress"),y('emit "progress"'),this.emit("progress",{originator:e,response:t||null})}},{key:"_accepted",value:function(e,t){y("session accepted"),this._start_time=new Date,y('emit "accepted"'),this.emit("accepted",{originator:e,response:t||null})}},{key:"_confirmed",value:function(e,t){y("session confirmed"),this._is_confirmed=!0,y('emit "confirmed"'),this.emit("confirmed",{originator:e,ack:t||null})}},{key:"_ended",value:function(e,t,n){y("session ended"),this._end_time=new Date,this._close(),y('emit "ended"'),this.emit("ended",{originator:e,message:t||null,cause:n})}},{key:"_failed",value:function(e,t,n){y("session failed"),this._close(),y('emit "failed"'),this.emit("failed",{originator:e,message:t||null,cause:n})}},{key:"_onhold",value:function(e){y("session onhold"),this._setLocalMediaStatus(),y('emit "hold"'),this.emit("hold",{originator:e})}},{key:"_onunhold",value:function(e){y("session onunhold"),this._setLocalMediaStatus(),y('emit "unhold"'),this.emit("unhold",{originator:e})}},{key:"_onmute",value:function(e){var t=e.audio,n=e.video;y("session onmute"),this._setLocalMediaStatus(),y('emit "muted"'),this.emit("muted",{audio:t,video:n})}},{key:"_onunmute",value:function(e){var t=e.audio,n=e.video;y("session onunmute"),this._setLocalMediaStatus(),y('emit "unmuted"'),this.emit("unmuted",{audio:t,video:n})}},{key:"C",get:function(){return C}},{key:"causes",get:function(){return a.causes}},{key:"id",get:function(){return this._id}},{key:"connection",get:function(){return this._connection}},{key:"direction",get:function(){return this._direction}},{key:"local_identity",get:function(){return this._local_identity}},{key:"remote_identity",get:function(){return this._remote_identity}},{key:"start_time",get:function(){return this._start_time}},{key:"end_time",get:function(){return this._end_time}},{key:"data",get:function(){return this._data},set:function(e){this._data=e}},{key:"status",get:function(){return this._status}}]),t}()},{"./Constants":2,"./Dialog":3,"./Exceptions":6,"./RTCSession/DTMF":13,"./RTCSession/Info":14,"./RTCSession/ReferNotifier":15,"./RTCSession/ReferSubscriber":16,"./RequestSender":18,"./SIPMessage":19,"./Timers":21,"./Transactions":22,"./Utils":26,debug:29,events:31,"sdp-transform":36}],13:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};if(void 0===e)throw new TypeError("Not enough arguments");if(this._direction="outgoing",this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK)throw new o.InvalidStateError(this._session.status);var r=a.cloneArray(n.extraHeaders);if(this.eventHandlers=n.eventHandlers||{},"string"==typeof e)e=e.toUpperCase();else{if("number"!=typeof e)throw new TypeError("Invalid tone: "+e);e=e.toString()}if(!e.match(/^[0-9A-DR#*]$/))throw new TypeError("Invalid tone: "+e);this._tone=e,this._duration=n.duration,r.push("Content-Type: application/dtmf-relay");var i="Signal="+this._tone+"\r\n";i+="Duration="+this._duration,this._session.newDTMF({originator:"local",dtmf:this,request:this._request}),this._session.sendRequest(s.INFO,{extraHeaders:r,eventHandlers:{onSuccessResponse:function(e){t.emit("succeeded",{originator:"remote",response:e})},onErrorResponse:function(e){t.eventHandlers.onFailed&&t.eventHandlers.onFailed(),t.emit("failed",{originator:"remote",response:e})},onRequestTimeout:function(){t._session.onRequestTimeout()},onTransportError:function(){t._session.onTransportError()},onDialogError:function(){t._session.onDialogError()}},body:i})}},{key:"init_incoming",value:function(e){var t=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,n=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;if(this._direction="incoming",this._request=e,e.reply(200),e.body){var r=e.body.split("\n");r.length>=1&&t.test(r[0])&&(this._tone=r[0].replace(t,"$2")),r.length>=2&&n.test(r[1])&&(this._duration=parseInt(r[1].replace(n,"$2"),10))}this._duration||(this._duration=u.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:e}):l("invalid INFO DTMF received, discarded")}},{key:"tone",get:function(){return this._tone}},{key:"duration",get:function(){return this._duration}}]),t}(),t.exports.C=u},{"../Constants":2,"../Exceptions":6,"../Utils":26,debug:29,events:31}],14:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:{};if(this._direction="outgoing",void 0===e)throw new TypeError("Not enough arguments");if(this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK)throw new o.InvalidStateError(this._session.status);this._contentType=e,this._body=t;var i=a.cloneArray(r.extraHeaders);i.push("Content-Type: "+e),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(s.INFO,{extraHeaders:i,eventHandlers:{onSuccessResponse:function(e){n.emit("succeeded",{originator:"remote",response:e})},onErrorResponse:function(e){n.emit("failed",{originator:"remote",response:e})},onTransportError:function(){n._session.onTransportError()},onRequestTimeout:function(){n._session.onRequestTimeout()},onDialogError:function(){n._session.onDialogError()}},body:t})}},{key:"init_incoming",value:function(e){this._direction="incoming",this.request=e,e.reply(200),this._contentType=e.getHeader("content-type"),this._body=e.body,this._session.newInfo({originator:"remote",info:this,request:e})}},{key:"contentType",get:function(){return this._contentType}},{key:"body",get:function(){return this._body}}]),t}()},{"../Constants":2,"../Exceptions":6,"../Utils":26,debug:29,events:31}],15:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n=200?"terminated;reason=noresource":"active;expires="+this._expires,this._session.sendRequest(i.NOTIFY,{extraHeaders:["Event: "+o.event_type+";id="+this._id,"Subscription-State: "+n,"Content-Type: "+o.body_type],body:"SIP/2.0 "+e+" "+t,eventHandlers:{onErrorResponse:function(){this._active=!1}}})}}}]),e}()},{"../Constants":2,debug:29}],16:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};l("sendRefer()");var r=a.cloneArray(n.extraHeaders),i=n.eventHandlers||{};for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&this.on(o,i[o]);var u=null;n.replaces&&(u=n.replaces._request.call_id,u+=";to-tag="+n.replaces._to_tag,u+=";from-tag="+n.replaces._from_tag,u=encodeURIComponent(u));var c="Refer-To: <"+e+(u?"?Replaces="+u:"")+">";r.push(c);var d=this._session.sendRequest(s.REFER,{extraHeaders:r,eventHandlers:{onSuccessResponse:function(e){t._requestSucceeded(e)},onErrorResponse:function(e){t._requestFailed(e,s.causes.REJECTED)},onTransportError:function(){t._requestFailed(null,s.causes.CONNECTION_ERROR)},onRequestTimeout:function(){t._requestFailed(null,s.causes.REQUEST_TIMEOUT)},onDialogError:function(){t._requestFailed(null,s.causes.DIALOG_ERROR)}}});this._id=d.cseq}},{key:"receiveNotify",value:function(e){if(l("receiveNotify()"),e.body){var t=o.parse(e.body.trim(),"Status_Line");if(-1!==t)switch(!0){case/^100$/.test(t.status_code):this.emit("trying",{request:e,status_line:t});break;case/^1[0-9]{2}$/.test(t.status_code):this.emit("progress",{request:e,status_line:t});break;case/^2[0-9]{2}$/.test(t.status_code):this.emit("accepted",{request:e,status_line:t});break;default:this.emit("failed",{request:e,status_line:t})}else l('receiveNotify() | error parsing NOTIFY body: "'+e.body+'"')}}},{key:"_requestSucceeded",value:function(e){l("REFER succeeded"),l('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:e})}},{key:"_requestFailed",value:function(e,t){l("REFER failed"),l('emit "requestFailed"'),this.emit("requestFailed",{response:e||null,cause:t})}},{key:"id",get:function(){return this._id}}]),t}()},{"../Constants":2,"../Grammar":7,"../Utils":26,debug:29,events:31}],17:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n"'}return r(e,[{key:"setExtraHeaders",value:function(e){Array.isArray(e)||(e=[]),this._extraHeaders=e.slice()}},{key:"setExtraContactParams",value:function(e){e instanceof Object||(e={}),this._extraContactParams="";for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var n=e[t];this._extraContactParams+=";"+t,n&&(this._extraContactParams+="="+n)}}},{key:"register",value:function(){var e=this;if(this._registering)l("Register request in progress...");else{var t=this._extraHeaders.slice();t.push("Contact: "+this._contact+";expires="+this._expires+this._extraContactParams),t.push("Expires: "+this._expires);var n=new o.OutgoingRequest(s.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},t),r=new a(this._ua,n,{onRequestTimeout:function(){e._registrationFailure(null,s.causes.REQUEST_TIMEOUT)},onTransportError:function(){e._registrationFailure(null,s.causes.CONNECTION_ERROR)},onAuthenticated:function(){e._cseq+=1},onReceiveResponse:function(t){var n=void 0,r=void 0,o=t.getHeaders("contact").length;if(t.cseq===e._cseq)switch(null!==e._registrationTimer&&(clearTimeout(e._registrationTimer),e._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(t.status_code):break;case/^2[0-9]{2}$/.test(t.status_code):if(e._registering=!1,!o){l("no Contact header in response to REGISTER, response ignored");break}for(;o--;){if((n=t.parseHeader("contact",o)).uri.user===e._ua.contact.uri.user){r=n.getParam("expires");break}n=null}if(!n){l("no Contact header pointing to us, response ignored");break}!r&&t.hasHeader("expires")&&(r=t.getHeader("expires")),r||(r=e._expires),(r=Number(r))<10&&(r=10),e._registrationTimer=setTimeout(function(){e._registrationTimer=null,0===e._ua.listeners("registrationExpiring").length?e.register():e._ua.emit("registrationExpiring")},1e3*r-5e3),n.hasParam("temp-gruu")&&(e._ua.contact.temp_gruu=n.getParam("temp-gruu").replace(/"/g,"")),n.hasParam("pub-gruu")&&(e._ua.contact.pub_gruu=n.getParam("pub-gruu").replace(/"/g,"")),e._registered||(e._registered=!0,e._ua.registered({response:t}));break;case/^423$/.test(t.status_code):t.hasHeader("min-expires")?(e._expires=Number(t.getHeader("min-expires")),e._expires<10&&(e._expires=10),e.register()):(l("423 response received for REGISTER without Min-Expires"),e._registrationFailure(t,s.causes.SIP_FAILURE_CODE));break;default:var a=i.sipErrorCause(t.status_code);e._registrationFailure(t,a)}}});this._registering=!0,r.send()}}},{key:"unregister",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this._registered){this._registered=!1,null!==this._registrationTimer&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);var n=this._extraHeaders.slice();t.all?n.push("Contact: *"+this._extraContactParams):n.push("Contact: "+this._contact+";expires=0"+this._extraContactParams),n.push("Expires: 0");var r=new o.OutgoingRequest(s.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},n);new a(this._ua,r,{onRequestTimeout:function(){e._unregistered(null,s.causes.REQUEST_TIMEOUT)},onTransportError:function(){e._unregistered(null,s.causes.CONNECTION_ERROR)},onAuthenticated:function(){e._cseq+=1},onReceiveResponse:function(t){switch(!0){case/^1[0-9]{2}$/.test(t.status_code):break;case/^2[0-9]{2}$/.test(t.status_code):e._unregistered(t);break;default:var n=i.sipErrorCause(t.status_code);e._unregistered(t,n)}}}).send()}else l("already unregistered")}},{key:"close",value:function(){this._registered&&this.unregister()}},{key:"onTransportClosed",value:function(){this._registering=!1,null!==this._registrationTimer&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),this._registered&&(this._registered=!1,this._ua.unregistered({}))}},{key:"_registrationFailure",value:function(e,t){this._registering=!1,this._ua.registrationFailed({response:e||null,cause:t}),this._registered&&(this._registered=!1,this._ua.unregistered({response:e||null,cause:t}))}},{key:"_unregistered",value:function(e,t){this._registering=!1,this._registered=!1,this._ua.unregistered({response:e||null,cause:t||null})}},{key:"registered",get:function(){return this._registered}}]),e}()},{"./Constants":2,"./RequestSender":18,"./SIPMessage":19,"./Utils":26,debug:29}],18:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n"),this.setHeader("via",""),this.setHeader("max-forwards",l.MAX_FORWARDS);var d=i.to_display_name||0===i.to_display_name?'"'+i.to_display_name+'" ':"";d+="<"+(i.to_uri||n)+">",d+=i.to_tag?";tag="+i.to_tag:"",this.to=c.parse(d),this.setHeader("to",d);var h=void 0;h=i.from_display_name||0===i.from_display_name?'"'+i.from_display_name+'" ':r.configuration.display_name?'"'+r.configuration.display_name+'" ':"",h+="<"+(i.from_uri||r.configuration.uri)+">;tag=",h+=i.from_tag||u.newTag(),this.from=c.parse(h),this.setHeader("from",h);var f=i.call_id||r.configuration.jssip_id+u.createRandomToken(15);this.call_id=f,this.setHeader("call-id",f);var p=i.cseq||Math.floor(1e4*Math.random());this.cseq=p,this.setHeader("cseq",p+" "+t)}return r(e,[{key:"setHeader",value:function(e,t){for(var n=new RegExp("^\\s*"+e+"\\s*:","i"),r=0;r1&&void 0!==arguments[1]?arguments[1]:0;if(e=u.headerize(e),this.headers[e]){if(!(t>=this.headers[e].length)){var n=this.headers[e][t],r=n.raw;if(n.parsed)return n.parsed;var i=d.parse(r,e.replace(/-/g,"_"));return-1===i?(this.headers[e].splice(t,1),void h('error parsing "'+e+'" header field with value "'+r+'"')):(n.parsed=i,i)}h('not so many "'+e+'" headers present')}else h('header "'+e+'" not present')}},{key:"s",value:function(e,t){return this.parseHeader(e,t)}},{key:"setHeader",value:function(e,t){var n={raw:t};this.headers[u.headerize(e)]=[n]}},{key:"parseSDP",value:function(e){return!e&&this.sdp?this.sdp:(this.sdp=a.parse(this.body||""),this.sdp)}},{key:"toString",value:function(){return this.data}}]),e}(),m=function(e){s(t,_);function t(e){o(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.ua=e,n.headers={},n.ruri=null,n.transport=null,n.server_transaction=null,n}return r(t,[{key:"reply",value:function(e,t,n,r,i,s){var o=[],a=this.getHeader("To");if(e=e||null,t=t||null,!e||e<100||e>699)throw new TypeError("Invalid status_code: "+e);if(t&&"string"!=typeof t&&!(t instanceof String))throw new TypeError("Invalid reason_phrase: "+t);t=t||l.REASON_PHRASE[e]||"",n=u.cloneArray(n);var c="SIP/2.0 "+e+" "+t+"\r\n";if(this.method===l.INVITE&&e>100&&e<=200){var d=this.getHeaders("record-route"),h=!0,f=!1,p=void 0;try{for(var _,m=d[Symbol.iterator]();!(h=(_=m.next()).done);h=!0){c+="Record-Route: "+_.value+"\r\n"}}catch(e){f=!0,p=e}finally{try{!h&&m.return&&m.return()}finally{if(f)throw p}}}var v=this.getHeaders("via"),g=!0,y=!1,T=void 0;try{for(var C,S=v[Symbol.iterator]();!(g=(C=S.next()).done);g=!0){c+="Via: "+C.value+"\r\n"}}catch(e){y=!0,T=e}finally{try{!g&&S.return&&S.return()}finally{if(y)throw T}}!this.to_tag&&e>100?a+=";tag="+u.newTag():this.to_tag&&!this.s("to").hasParam("tag")&&(a+=";tag="+this.to_tag),c+="To: "+a+"\r\n",c+="From: "+this.getHeader("From")+"\r\n",c+="Call-ID: "+this.call_id+"\r\n",c+="CSeq: "+this.cseq+" "+this.method+"\r\n";var E=!0,b=!1,R=void 0;try{for(var A,w=n[Symbol.iterator]();!(E=(A=w.next()).done);E=!0){c+=A.value.trim()+"\r\n"}}catch(e){b=!0,R=e}finally{try{!E&&w.return&&w.return()}finally{if(b)throw R}}switch(this.method){case l.INVITE:this.ua.configuration.session_timers&&o.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&o.push("gruu"),o.push("ice","replaces");break;case l.UPDATE:this.ua.configuration.session_timers&&o.push("timer"),r&&o.push("ice"),o.push("replaces")}if(o.push("outbound"),this.method===l.OPTIONS?(c+="Allow: "+l.ALLOWED_METHODS+"\r\n",c+="Accept: "+l.ACCEPTED_BODY_TYPES+"\r\n"):405===e?c+="Allow: "+l.ALLOWED_METHODS+"\r\n":415===e&&(c+="Accept: "+l.ACCEPTED_BODY_TYPES+"\r\n"),c+="Supported: "+o+"\r\n",r){c+="Content-Type: application/sdp\r\n",c+="Content-Length: "+u.str_utf8_length(r)+"\r\n\r\n",c+=r}else c+="Content-Length: 0\r\n\r\n";this.server_transaction.receiveResponse(e,c,i,s)}},{key:"reply_sl",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this.getHeaders("via");if(!e||e<100||e>699)throw new TypeError("Invalid status_code: "+e);if(t&&"string"!=typeof t&&!(t instanceof String))throw new TypeError("Invalid reason_phrase: "+t);var r="SIP/2.0 "+e+" "+(t=t||l.REASON_PHRASE[e]||"")+"\r\n",i=!0,s=!1,o=void 0;try{for(var a,c=n[Symbol.iterator]();!(i=(a=c.next()).done);i=!0){r+="Via: "+a.value+"\r\n"}}catch(e){s=!0,o=e}finally{try{!i&&c.return&&c.return()}finally{if(s)throw o}}var d=this.getHeader("To");!this.to_tag&&e>100?d+=";tag="+u.newTag():this.to_tag&&!this.s("to").hasParam("tag")&&(d+=";tag="+this.to_tag),r+="To: "+d+"\r\n",r+="From: "+this.getHeader("From")+"\r\n",r+="Call-ID: "+this.call_id+"\r\n",r+="CSeq: "+this.cseq+" "+this.method+"\r\n",r+="Content-Length: 0\r\n\r\n",this.transport.send(r)}}]),t}(),v=function(e){s(t,_);function t(){o(this,t);var e=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.headers={},e.status_code=null,e.reason_phrase=null,e}return t}();t.exports={OutgoingRequest:f,InitialOutgoingInviteRequest:p,IncomingRequest:m,IncomingResponse:v}},{"./Constants":2,"./Grammar":7,"./NameAddrHeader":10,"./Utils":26,debug:29,"sdp-transform":36}],20:[function(e,t,n){"use strict";var r=e("./Utils"),i=e("./Grammar"),s=e("debug")("JsSIP:ERROR:Socket");s.log=console.warn.bind(console),n.isSocket=function(e){if(Array.isArray(e))return!1;if(void 0===e)return s("undefined JsSIP.Socket instance"),!1;try{if(!r.isString(e.url))throw s("missing or invalid JsSIP.Socket url property"),new Error;if(!r.isString(e.via_transport))throw s("missing or invalid JsSIP.Socket via_transport property"),new Error;if(-1===i.parse(e.sip_uri,"SIP_URI"))throw s("missing or invalid JsSIP.Socket sip_uri property"),new Error}catch(e){return!1}try{["connect","disconnect","send"].forEach(function(t){if(!r.isFunction(e[t]))throw s("missing or invalid JsSIP.Socket method: "+t),new Error})}catch(e){return!1}return!0}},{"./Grammar":7,"./Utils":26,debug:29}],21:[function(e,t,n){"use strict";t.exports={T1:500,T2:4e3,T4:5e3,TIMER_B:32e3,TIMER_D:0,TIMER_F:32e3,TIMER_H:32e3,TIMER_I:0,TIMER_J:0,TIMER_K:0,TIMER_L:32e3,TIMER_M:32e3,PROVISIONAL_RESPONSE_INTERVAL:6e4}},{}],22:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n=100&&n<=199)switch(this.state){case m.STATUS_CALLING:this.stateChanged(m.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(e);break;case m.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(e)}else if(n>=200&&n<=299)switch(this.state){case m.STATUS_CALLING:case m.STATUS_PROCEEDING:this.stateChanged(m.STATUS_ACCEPTED),this.M=setTimeout(function(){t.timer_M()},c.TIMER_M),this.eventHandlers.onReceiveResponse(e);break;case m.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(e)}else if(n>=300&&n<=699)switch(this.state){case m.STATUS_CALLING:case m.STATUS_PROCEEDING:this.stateChanged(m.STATUS_COMPLETED),this.sendACK(e),this.eventHandlers.onReceiveResponse(e);break;case m.STATUS_COMPLETED:this.sendACK(e)}}},{key:"C",get:function(){return m}}]),t}(),y=function(e){o(t,a);function t(e,n,r,o){i(this,t);var a=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));a.id="z9hG4bK"+Math.floor(1e7*Math.random()),a.transport=n,a.request=r,a.eventHandlers=o;var l="SIP/2.0/"+n.via_transport;return l+=" "+e.configuration.via_host+";branch="+a.id,a.request.setHeader("via",l),a}return r(t,[{key:"send",value:function(){this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){f("transport error occurred for transaction "+this.id),this.eventHandlers.onTransportError()}},{key:"C",get:function(){return m}}]),t}(),T=function(e){o(t,a);function t(e,n,r){i(this,t);var o=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return o.type=m.NON_INVITE_SERVER,o.id=r.via_branch,o.ua=e,o.transport=n,o.request=r,o.last_response="",r.server_transaction=o,o.state=m.STATUS_TRYING,e.newTransaction(o),o}return r(t,[{key:"stateChanged",value:function(e){this.state=e,this.emit("stateChanged")}},{key:"timer_J",value:function(){p("Timer J expired for transaction "+this.id),this.stateChanged(m.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,p("transport error occurred, deleting transaction "+this.id),clearTimeout(this.J),this.stateChanged(m.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"receiveResponse",value:function(e,t,n,r){var i=this;if(100===e)switch(this.state){case m.STATUS_TRYING:this.stateChanged(m.STATUS_PROCEEDING),this.transport.send(t)||this.onTransportError();break;case m.STATUS_PROCEEDING:this.last_response=t,this.transport.send(t)?n&&n():(this.onTransportError(),r&&r())}else if(e>=200&&e<=699)switch(this.state){case m.STATUS_TRYING:case m.STATUS_PROCEEDING:this.stateChanged(m.STATUS_COMPLETED),this.last_response=t,this.J=setTimeout(function(){i.timer_J()},c.TIMER_J),this.transport.send(t)?n&&n():(this.onTransportError(),r&&r());break;case m.STATUS_COMPLETED:}}},{key:"C",get:function(){return m}}]),t}(),C=function(e){o(t,a);function t(e,n,r){i(this,t);var o=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return o.type=m.INVITE_SERVER,o.id=r.via_branch,o.ua=e,o.transport=n,o.request=r,o.last_response="",r.server_transaction=o,o.state=m.STATUS_PROCEEDING,e.newTransaction(o),o.resendProvisionalTimer=null,r.reply(100),o}return r(t,[{key:"stateChanged",value:function(e){this.state=e,this.emit("stateChanged")}},{key:"timer_H",value:function(){_("Timer H expired for transaction "+this.id),this.state===m.STATUS_COMPLETED&&_("ACK not received, dialog will be terminated"),this.stateChanged(m.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_I",value:function(){this.stateChanged(m.STATUS_TERMINATED)}},{key:"timer_L",value:function(){_("Timer L expired for transaction "+this.id),this.state===m.STATUS_ACCEPTED&&(this.stateChanged(m.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,_("transport error occurred, deleting transaction "+this.id),null!==this.resendProvisionalTimer&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),clearTimeout(this.L),clearTimeout(this.H),clearTimeout(this.I),this.stateChanged(m.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"resend_provisional",value:function(){this.transport.send(this.last_response)||this.onTransportError()}},{key:"receiveResponse",value:function(e,t,n,r){var i=this;if(e>=100&&e<=199)switch(this.state){case m.STATUS_PROCEEDING:this.transport.send(t)||this.onTransportError(),this.last_response=t}if(e>100&&e<=199&&this.state===m.STATUS_PROCEEDING)null===this.resendProvisionalTimer&&(this.resendProvisionalTimer=setInterval(function(){i.resend_provisional()},c.PROVISIONAL_RESPONSE_INTERVAL));else if(e>=200&&e<=299)switch(this.state){case m.STATUS_PROCEEDING:this.stateChanged(m.STATUS_ACCEPTED),this.last_response=t,this.L=setTimeout(function(){i.timer_L()},c.TIMER_L),null!==this.resendProvisionalTimer&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case m.STATUS_ACCEPTED:this.transport.send(t)?n&&n():(this.onTransportError(),r&&r())}else if(e>=300&&e<=699)switch(this.state){case m.STATUS_PROCEEDING:null!==this.resendProvisionalTimer&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(t)?(this.stateChanged(m.STATUS_COMPLETED),this.H=setTimeout(function(){i.timer_H()},c.TIMER_H),n&&n()):(this.onTransportError(),r&&r())}}},{key:"C",get:function(){return m}}]),t}();t.exports={C:m,NonInviteClientTransaction:v,InviteClientTransaction:g,AckClientTransaction:y,NonInviteServerTransaction:T,InviteServerTransaction:C,checkTransaction:function(e,t){var n=e._transactions,r=void 0;switch(t.method){case l.INVITE:if(r=n.ist[t.via_branch]){switch(r.state){case m.STATUS_PROCEEDING:r.transport.send(r.last_response);break;case m.STATUS_ACCEPTED:}return!0}break;case l.ACK:if(!(r=n.ist[t.via_branch]))return!1;if(r.state===m.STATUS_ACCEPTED)return!1;if(r.state===m.STATUS_COMPLETED)return r.state=m.STATUS_CONFIRMED,r.I=setTimeout(function(){r.timer_I()},c.TIMER_I),!0;break;case l.CANCEL:return(r=n.ist[t.via_branch])?(t.reply_sl(200),r.state!==m.STATUS_PROCEEDING):(t.reply_sl(481),!0);default:if(r=n.nist[t.via_branch]){switch(r.state){case m.STATUS_TRYING:break;case m.STATUS_PROCEEDING:case m.STATUS_COMPLETED:r.transport.send(r.last_response)}return!0}}}}},{"./Constants":2,"./SIPMessage":19,"./Timers":21,debug:29,events:31}],23:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:a.recovery_options;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),s("new()"),this.status=a.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=n,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1,void 0===t)throw new TypeError("Invalid argument. undefined 'sockets' argument");t instanceof Array||(t=[t]),t.forEach(function(e){if(!i.isSocket(e.socket))throw new TypeError("Invalid argument. invalid 'JsSIP.Socket' instance");if(e.weight&&!Number(e.weight))throw new TypeError("Invalid argument. 'weight' attribute is not a number");this.sockets.push({socket:e.socket,weight:e.weight||0,status:a.SOCKET_STATUS_READY})},this),this._getSocket()}return r(e,[{key:"connect",value:function(){s("connect()"),this.isConnected()?s("Transport is already connected"):this.isConnecting()?s("Transport is connecting"):(this.close_requested=!1,this.status=a.STATUS_CONNECTING,this.onconnecting({socket:this.socket,attempts:this.recover_attempts}),this.close_requested||(this.socket.onconnect=this._onConnect.bind(this),this.socket.ondisconnect=this._onDisconnect.bind(this),this.socket.ondata=this._onData.bind(this),this.socket.connect()))}},{key:"disconnect",value:function(){s("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=a.STATUS_DISCONNECTED,null!==this.recovery_timer&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.socket.onconnect=function(){},this.socket.ondisconnect=function(){},this.socket.ondata=function(){},this.socket.disconnect(),this.ondisconnect()}},{key:"send",value:function(e){if(s("send()"),!this.isConnected())return o("unable to send message, transport is not connected"),!1;var t=e.toString();return s("sending message:\n\n"+t+"\n"),this.socket.send(t)}},{key:"isConnected",value:function(){return this.status===a.STATUS_CONNECTED}},{key:"isConnecting",value:function(){return this.status===a.STATUS_CONNECTING}},{key:"_reconnect",value:function(){var e=this;this.recover_attempts+=1;var t=Math.floor(Math.random()*Math.pow(2,this.recover_attempts)+1);tthis.recovery_options.max_interval&&(t=this.recovery_options.max_interval),s("reconnection attempt: "+this.recover_attempts+". next connection attempt in "+t+" seconds"),this.recovery_timer=setTimeout(function(){e.close_requested||e.isConnected()||e.isConnecting()||(e._getSocket(),e.connect())},1e3*t)}},{key:"_getSocket",value:function(){var e=[];if(this.sockets.forEach(function(t){t.status!==a.SOCKET_STATUS_ERROR&&(0===e.length?e.push(t):t.weight>e[0].weight?e=[t]:t.weight===e[0].weight&&e.push(t))}),0===e.length)return this.sockets.forEach(function(e){e.status=a.SOCKET_STATUS_READY}),void this._getSocket();var t=Math.floor(Math.random()*e.length);this.socket=e[t].socket}},{key:"_onConnect",value:function(){this.recover_attempts=0,this.status=a.STATUS_CONNECTED,null!==this.recovery_timer&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}},{key:"_onDisconnect",value:function(e,t,n){this.status=a.STATUS_DISCONNECTED,this.ondisconnect({socket:this.socket,error:e,code:t,reason:n}),this.close_requested||(this.sockets.forEach(function(e){this.socket===e.socket&&(e.status=a.SOCKET_STATUS_ERROR)},this),this._reconnect(e))}},{key:"_onData",value:function(e){if("\r\n"!==e){if("string"!=typeof e){try{e=String.fromCharCode.apply(null,new Uint8Array(e))}catch(e){return void s("received binary message failed to be converted into string, message discarded")}s("received binary message:\n\n"+e+"\n")}else s("received text message:\n\n"+e+"\n");this.ondata({transport:this,message:e})}else s("received message with CRLF Keep Alive response")}},{key:"via_transport",get:function(){return this.socket.via_transport}},{key:"url",get:function(){return this.socket.url}},{key:"sip_uri",get:function(){return this.socket.sip_uri}}]),e}()},{"./Socket":20,debug:29}],24:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=e.anonymous||null,n=e.outbound||null,r="<";return r+=t?this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":this.pub_gruu||this.uri.toString(),!n||(t?this.temp_gruu:this.pub_gruu)||(r+=";ob"),r+=">"}};var r=["password","realm","ha1","display_name","register"];for(var i in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,i)&&(-1!==r.indexOf(i)?Object.defineProperty(this._configuration,i,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,i,{writable:!1,configurable:!1}));y("configuration parameters after validation:");for(var o in this._configuration)if(Object.prototype.hasOwnProperty.call(g.settings,o))switch(o){case"uri":case"registrar_server":y("- "+o+": "+this._configuration[o]);break;case"password":case"ha1":y("- "+o+": NOT SHOWN");break;default:y("- "+o+": "+JSON.stringify(this._configuration[o]))}}},{key:"C",get:function(){return C}},{key:"status",get:function(){return this._status}},{key:"contact",get:function(){return this._contact}},{key:"configuration",get:function(){return this._configuration}},{key:"transport",get:function(){return this._transport}}]),t}()},{"./Config":1,"./Constants":2,"./Exceptions":6,"./Grammar":7,"./Message":9,"./Parser":11,"./RTCSession":12,"./Registrator":17,"./SIPMessage":19,"./Transactions":22,"./Transport":23,"./URI":25,"./Utils":26,"./sanityCheck":28,debug:29,events:31}],25:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n4&&void 0!==arguments[4]?arguments[4]:{},a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!r)throw new TypeError('missing or invalid "host" parameter');this._parameters={},this._headers={},this._scheme=t||i.SIP,this._user=n,this._host=r,this._port=s;for(var l in o)Object.prototype.hasOwnProperty.call(o,l)&&this.setParam(l,o[l]);for(var u in a)Object.prototype.hasOwnProperty.call(a,u)&&this.setHeader(u,a[u])}return r(e,[{key:"setParam",value:function(e,t){e&&(this._parameters[e.toLowerCase()]=void 0===t||null===t?null:t.toString())}},{key:"getParam",value:function(e){if(e)return this._parameters[e.toLowerCase()]}},{key:"hasParam",value:function(e){if(e)return!!this._parameters.hasOwnProperty(e.toLowerCase())}},{key:"deleteParam",value:function(e){if(e=e.toLowerCase(),this._parameters.hasOwnProperty(e)){var t=this._parameters[e];return delete this._parameters[e],t}}},{key:"clearParams",value:function(){this._parameters={}}},{key:"setHeader",value:function(e,t){this._headers[s.headerize(e)]=Array.isArray(t)?t:[t]}},{key:"getHeader",value:function(e){if(e)return this._headers[s.headerize(e)]}},{key:"hasHeader",value:function(e){if(e)return!!this._headers.hasOwnProperty(s.headerize(e))}},{key:"deleteHeader",value:function(e){if(e=s.headerize(e),this._headers.hasOwnProperty(e)){var t=this._headers[e];return delete this._headers[e],t}}},{key:"clearHeaders",value:function(){this._headers={}}},{key:"clone",value:function(){return new e(this._scheme,this._user,this._host,this._port,JSON.parse(JSON.stringify(this._parameters)),JSON.parse(JSON.stringify(this._headers)))}},{key:"toString",value:function(){var e=[],t=this._scheme+":";this._user&&(t+=s.escapeUser(this._user)+"@"),t+=this._host,(this._port||0===this._port)&&(t+=":"+this._port);for(var n in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,n)&&(t+=";"+n,null!==this._parameters[n]&&(t+="="+this._parameters[n]));for(var r in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,r)){var i=!0,o=!1,a=void 0;try{for(var l,u=this._headers[r][Symbol.iterator]();!(i=(l=u.next()).done);i=!0){var c=l.value;e.push(r+"="+c)}}catch(e){o=!0,a=e}finally{try{!i&&u.return&&u.return()}finally{if(o)throw a}}}return e.length>0&&(t+="?"+e.join("&")),t}},{key:"toAor",value:function(e){var t=this._scheme+":";return this._user&&(t+=s.escapeUser(this._user)+"@"),t+=this._host,e&&(this._port||0===this._port)&&(t+=":"+this._port),t}},{key:"scheme",get:function(){return this._scheme},set:function(e){this._scheme=e.toLowerCase()}},{key:"user",get:function(){return this._user},set:function(e){this._user=e}},{key:"host",get:function(){return this._host},set:function(e){this._host=e.toLowerCase()}},{key:"port",get:function(){return this._port},set:function(e){this._port=0===e?e:parseInt(e,10)||null}}]),e}()},{"./Constants":2,"./Grammar":7,"./Utils":26}],26:[function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=e("./Constants"),s=e("./URI"),o=e("./Grammar");n.str_utf8_length=function(e){return unescape(encodeURIComponent(e)).length};var a=n.isFunction=function(e){return void 0!==e&&"[object Function]"===Object.prototype.toString.call(e)};n.isString=function(e){return void 0!==e&&"[object String]"===Object.prototype.toString.call(e)},n.isDecimal=function(e){return!isNaN(e)&&parseFloat(e)===parseInt(e,10)},n.isEmpty=function(e){return null===e||""===e||void 0===e||Array.isArray(e)&&0===e.length||"number"==typeof e&&isNaN(e)},n.hasMethods=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r1&&void 0!==arguments[1]?arguments[1]:32,n=void 0,r="";for(n=0;n>>32-t}function n(e,t){var n=2147483648&e,r=2147483648&t,i=1073741824&e,s=1073741824&t,o=(1073741823&e)+(1073741823&t);return i&s?2147483648^o^n^r:i|s?1073741824&o?3221225472^o^n^r:1073741824^o^n^r:o^n^r}function r(e,r,i,s,o,a,l){var u,c,d;return n(t(e=n(e,n(n((u=r,c=i,d=s,u&c|~u&d),o),l)),a),r)}function i(e,r,i,s,o,a,l){var u,c,d;return n(t(e=n(e,n(n((u=r,c=i,d=s,u&d|c&~d),o),l)),a),r)}function s(e,r,i,s,o,a,l){var u,c,d;return n(t(e=n(e,n(n((u=r,c=i,d=s,u^c^d),o),l)),a),r)}function o(e,r,i,s,o,a,l){var u,c,d;return n(t(e=n(e,n(n((u=r,c=i,d=s,c^(u|~d)),o),l)),a),r)}function a(e){var t="",n="",r=void 0;for(r=0;r<=3;r++)t+=(n="0"+(e>>>8*r&255).toString(16)).substr(n.length-2,2);return t}var l=[],u=void 0,c=void 0,d=void 0,h=void 0,f=void 0,p=void 0,_=void 0,m=void 0,v=void 0;for(l=function(e){for(var t=void 0,n=e.length,r=n+8,i=16*((r-r%64)/64+1),s=new Array(i-1),o=0,a=0;a>>29,s}(e=function(e){e=e.replace(/\r\n/g,"\n");for(var t="",n=0;n127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(63&r|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(63&r|128))}return t}(e)),p=1732584193,_=4023233417,m=2562383102,v=271733878,u=0;u1)return o("more than one Via header field present in the response, dropping the response"),!1},function(){var e=s.str_utf8_length(c.body),t=c.getHeader("content-length");if(e=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},n.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),n.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];n.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}};function i(){var e;try{e=n.storage.debug}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}n.enable(i())}).call(this,e("_process"))},{"./debug":30,_process:33}],30:[function(e,t,n){(n=t.exports=r.debug=r.default=r).coerce=function(e){return e instanceof Error?e.stack||e.message:e},n.disable=function(){n.enable("")},n.enable=function(e){n.save(e),n.names=[],n.skips=[];var t,r=("string"==typeof e?e:"").split(/[\s,]+/),i=r.length;for(t=0;t1&&(t=arguments[1]),t instanceof Error)throw t;var l=new Error('Unhandled "error" event. ('+t+")");throw l.context=t,l}if(!(n=o[e]))return!1;var u="function"==typeof n;switch(r=arguments.length){case 1:!function(e,t,n){if(t)e.call(n);else for(var r=e.length,i=_(e,r),s=0;s0&&a.length>s){a.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",l.name,l.message)}}else a=o[t]=n,++e._eventsCount;return e}o.prototype.addListener=function(e,t){return d(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return d(this,e,t,!0)};function h(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t=0;o--)if(n[o]===t||n[o].listener===t){a=n[o].listener,s=o;break}if(s<0)return this;0===s?n.shift():function(e,t){for(var n=t,r=n+1,i=e.length;r=0;s--)this.removeListener(e,t[s]);return this},o.prototype.listeners=function(e){var t,n=this._events;return n&&(t=n[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),n=0;n0?Reflect.ownKeys(this._events):[]};function _(e,t){for(var n=new Array(t),r=0;r0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*a;case"days":case"day":case"d":return n*o;case"hours":case"hour":case"hrs":case"hr":case"h":return n*s;case"minutes":case"minute":case"mins":case"min":case"m":return n*i;case"seconds":case"second":case"secs":case"sec":case"s":return n*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===n&&!1===isNaN(e))return t.long?l(u=e,o,"day")||l(u,s,"hour")||l(u,i,"minute")||l(u,r,"second")||u+" ms":function(e){if(e>=o)return Math.round(e/o)+"d";if(e>=s)return Math.round(e/s)+"h";if(e>=i)return Math.round(e/i)+"m";if(e>=r)return Math.round(e/r)+"s";return e+"ms"}(e);var u;throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function l(e,t,n){if(!(e1)for(var n=1;n=14393&&-1===e.indexOf("?transport=udp"):(n=!0,!0)}),delete e.url,e.urls=i?r[0]:r,!!r.length}})}(n.iceServers||[],t),this._iceGatherers=[],n.iceCandidatePoolSize)for(var o=n.iceCandidatePoolSize;o>0;o--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:n.iceServers,gatherPolicy:n.iceTransportPolicy}));else n.iceCandidatePoolSize=0;this._config=n,this.transceivers=[],this._sdpSessionId=r.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};c.prototype.onicecandidate=null,c.prototype.onaddstream=null,c.prototype.ontrack=null,c.prototype.onremovestream=null,c.prototype.onsignalingstatechange=null,c.prototype.oniceconnectionstatechange=null,c.prototype.onconnectionstatechange=null,c.prototype.onicegatheringstatechange=null,c.prototype.onnegotiationneeded=null,c.prototype.ondatachannel=null,c.prototype._dispatchEvent=function(e,t){this._isClosed||(this.dispatchEvent(t),"function"==typeof this["on"+e]&&this["on"+e](t))},c.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)},c.prototype.getConfiguration=function(){return this._config},c.prototype.getLocalStreams=function(){return this.localStreams},c.prototype.getRemoteStreams=function(){return this.remoteStreams},c.prototype._createTransceiver=function(e,t){var n=this.transceivers.length>0,r={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:e,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&n)r.iceTransport=this.transceivers[0].iceTransport,r.dtlsTransport=this.transceivers[0].dtlsTransport;else{var i=this._createIceAndDtlsTransports();r.iceTransport=i.iceTransport,r.dtlsTransport=i.dtlsTransport}return t||this.transceivers.push(r),r},c.prototype.addTrack=function(t,n){if(this._isClosed)throw l("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");if(this.transceivers.find(function(e){return e.track===t}))throw l("InvalidAccessError","Track already exists.");for(var r,i=0;i=15025)e.getTracks().forEach(function(t){n.addTrack(t,e)});else{var r=e.clone();e.getTracks().forEach(function(e,t){var n=r.getTracks()[t];e.addEventListener("enabled",function(e){n.enabled=e.enabled})}),r.getTracks().forEach(function(e){n.addTrack(e,r)})}},c.prototype.removeTrack=function(t){if(this._isClosed)throw l("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(t instanceof e.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var n=this.transceivers.find(function(e){return e.rtpSender===t});if(!n)throw l("InvalidAccessError","Sender was not created by this connection.");var r=n.stream;n.rtpSender.stop(),n.rtpSender=null,n.track=null,n.stream=null;-1===this.transceivers.map(function(e){return e.stream}).indexOf(r)&&this.localStreams.indexOf(r)>-1&&this.localStreams.splice(this.localStreams.indexOf(r),1),this._maybeFireNegotiationNeeded()},c.prototype.removeStream=function(e){var t=this;e.getTracks().forEach(function(e){var n=t.getSenders().find(function(t){return t.track===e});n&&t.removeTrack(n)})},c.prototype.getSenders=function(){return this.transceivers.filter(function(e){return!!e.rtpSender}).map(function(e){return e.rtpSender})},c.prototype.getReceivers=function(){return this.transceivers.filter(function(e){return!!e.rtpReceiver}).map(function(e){return e.rtpReceiver})},c.prototype._createIceGatherer=function(t,n){var r=this;if(n&&t>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var i=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(i,"state",{value:"new",writable:!0}),this.transceivers[t].bufferedCandidateEvents=[],this.transceivers[t].bufferCandidates=function(e){var n=!e.candidate||0===Object.keys(e.candidate).length;i.state=n?"completed":"gathering",null!==r.transceivers[t].bufferedCandidateEvents&&r.transceivers[t].bufferedCandidateEvents.push(e)},i.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),i},c.prototype._gather=function(t,n){var i=this,s=this.transceivers[n].iceGatherer;if(!s.onlocalcandidate){var o=this.transceivers[n].bufferedCandidateEvents;this.transceivers[n].bufferedCandidateEvents=null,s.removeEventListener("localcandidate",this.transceivers[n].bufferCandidates),s.onlocalcandidate=function(e){if(!(i.usingBundle&&n>0)){var o=new Event("icecandidate");o.candidate={sdpMid:t,sdpMLineIndex:n};var a=e.candidate,l=!a||0===Object.keys(a).length;if(l)"new"!==s.state&&"gathering"!==s.state||(s.state="completed");else{"new"===s.state&&(s.state="gathering"),a.component=1,a.ufrag=s.getLocalParameters().usernameFragment;var u=r.writeCandidate(a);o.candidate=Object.assign(o.candidate,r.parseCandidate(u)),o.candidate.candidate=u,o.candidate.toJSON=function(){return{candidate:o.candidate.candidate,sdpMid:o.candidate.sdpMid,sdpMLineIndex:o.candidate.sdpMLineIndex,usernameFragment:o.candidate.usernameFragment}}}var c=r.getMediaSections(i.localDescription.sdp);c[o.candidate.sdpMLineIndex]+=l?"a=end-of-candidates\r\n":"a="+o.candidate.candidate+"\r\n",i.localDescription.sdp=r.getDescription(i.localDescription.sdp)+c.join("");var d=i.transceivers.every(function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state});"gathering"!==i.iceGatheringState&&(i.iceGatheringState="gathering",i._emitGatheringStateChange()),l||i._dispatchEvent("icecandidate",o),d&&(i._dispatchEvent("icecandidate",new Event("icecandidate")),i.iceGatheringState="complete",i._emitGatheringStateChange())}},e.setTimeout(function(){o.forEach(function(e){s.onlocalcandidate(e)})},0)}},c.prototype._createIceAndDtlsTransports=function(){var t=this,n=new e.RTCIceTransport(null);n.onicestatechange=function(){t._updateIceConnectionState(),t._updateConnectionState()};var r=new e.RTCDtlsTransport(n);return r.ondtlsstatechange=function(){t._updateConnectionState()},r.onerror=function(){Object.defineProperty(r,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:n,dtlsTransport:r}},c.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var n=this.transceivers[e].iceTransport;n&&(delete n.onicestatechange,delete this.transceivers[e].iceTransport);var r=this.transceivers[e].dtlsTransport;r&&(delete r.ondtlsstatechange,delete r.onerror,delete this.transceivers[e].dtlsTransport)},c.prototype._transceive=function(e,n,i){var o=s(e.localCapabilities,e.remoteCapabilities);n&&e.rtpSender&&(o.encodings=e.sendEncodingParameters,o.rtcp={cname:r.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(o.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(o)),i&&e.rtpReceiver&&o.codecs.length>0&&("video"===e.kind&&e.recvEncodingParameters&&t<15019&&e.recvEncodingParameters.forEach(function(e){delete e.rtx}),e.recvEncodingParameters.length?o.encodings=e.recvEncodingParameters:o.encodings=[{}],o.rtcp={compound:e.rtcpParameters.compound},e.rtcpParameters.cname&&(o.rtcp.cname=e.rtcpParameters.cname),e.sendEncodingParameters.length&&(o.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(o))},c.prototype.setLocalDescription=function(e){var t=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(l("TypeError",'Unsupported type "'+e.type+'"'));if(!o("setLocalDescription",e.type,t.signalingState)||t._isClosed)return Promise.reject(l("InvalidStateError","Can not set local "+e.type+" in state "+t.signalingState));var n,i;if("offer"===e.type)n=r.splitSections(e.sdp),i=n.shift(),n.forEach(function(e,n){var i=r.parseRtpParameters(e);t.transceivers[n].localCapabilities=i}),t.transceivers.forEach(function(e,n){t._gather(e.mid,n)});else if("answer"===e.type){n=r.splitSections(t.remoteDescription.sdp),i=n.shift();var a=r.matchPrefix(i,"a=ice-lite").length>0;n.forEach(function(e,n){var o=t.transceivers[n],l=o.iceGatherer,u=o.iceTransport,c=o.dtlsTransport,d=o.localCapabilities,h=o.remoteCapabilities;if(!(r.isRejected(e)&&0===r.matchPrefix(e,"a=bundle-only").length)&&!o.rejected){var f=r.getIceParameters(e,i),p=r.getDtlsParameters(e,i);a&&(p.role="server"),t.usingBundle&&0!==n||(t._gather(o.mid,n),"new"===u.state&&u.start(l,f,a?"controlling":"controlled"),"new"===c.state&&c.start(p));var _=s(d,h);t._transceive(o,_.codecs.length>0,!1)}})}return t.localDescription={type:e.type,sdp:e.sdp},"offer"===e.type?t._updateSignalingState("have-local-offer"):t._updateSignalingState("stable"),Promise.resolve()},c.prototype.setRemoteDescription=function(i){var s=this;if(-1===["offer","answer"].indexOf(i.type))return Promise.reject(l("TypeError",'Unsupported type "'+i.type+'"'));if(!o("setRemoteDescription",i.type,s.signalingState)||s._isClosed)return Promise.reject(l("InvalidStateError","Can not set remote "+i.type+" in state "+s.signalingState));var c={};s.remoteStreams.forEach(function(e){c[e.id]=e});var d=[],h=r.splitSections(i.sdp),f=h.shift(),p=r.matchPrefix(f,"a=ice-lite").length>0,_=r.matchPrefix(f,"a=group:BUNDLE ").length>0;s.usingBundle=_;var m=r.matchPrefix(f,"a=ice-options:")[0];return s.canTrickleIceCandidates=!!m&&m.substr(14).split(" ").indexOf("trickle")>=0,h.forEach(function(o,l){var u=r.splitLines(o),h=r.getKind(o),m=r.isRejected(o)&&0===r.matchPrefix(o,"a=bundle-only").length,v=u[0].substr(2).split(" ")[2],g=r.getDirection(o,f),y=r.parseMsid(o),T=r.getMid(o)||r.generateIdentifier();if("application"===h&&"DTLS/SCTP"===v||m)s.transceivers[l]={mid:T,kind:h,rejected:!0};else{!m&&s.transceivers[l]&&s.transceivers[l].rejected&&(s.transceivers[l]=s._createTransceiver(h,!0));var C,S,E,b,R,A,w,I,P,k,O,x=r.parseRtpParameters(o);m||(k=r.getIceParameters(o,f),(O=r.getDtlsParameters(o,f)).role="client"),w=r.parseRtpEncodingParameters(o);var D=r.parseRtcpParameters(o),N=r.matchPrefix(o,"a=end-of-candidates",f).length>0,U=r.matchPrefix(o,"a=candidate:").map(function(e){return r.parseCandidate(e)}).filter(function(e){return 1===e.component});if(("offer"===i.type||"answer"===i.type)&&!m&&_&&l>0&&s.transceivers[l]&&(s._disposeIceAndDtlsTransports(l),s.transceivers[l].iceGatherer=s.transceivers[0].iceGatherer,s.transceivers[l].iceTransport=s.transceivers[0].iceTransport,s.transceivers[l].dtlsTransport=s.transceivers[0].dtlsTransport,s.transceivers[l].rtpSender&&s.transceivers[l].rtpSender.setTransport(s.transceivers[0].dtlsTransport),s.transceivers[l].rtpReceiver&&s.transceivers[l].rtpReceiver.setTransport(s.transceivers[0].dtlsTransport)),"offer"!==i.type||m)"answer"!==i.type||m||(S=(C=s.transceivers[l]).iceGatherer,E=C.iceTransport,b=C.dtlsTransport,R=C.rtpReceiver,A=C.sendEncodingParameters,I=C.localCapabilities,s.transceivers[l].recvEncodingParameters=w,s.transceivers[l].remoteCapabilities=x,s.transceivers[l].rtcpParameters=D,U.length&&"new"===E.state&&(!p&&!N||_&&0!==l?U.forEach(function(e){a(C.iceTransport,e)}):E.setRemoteCandidates(U)),_&&0!==l||("new"===E.state&&E.start(S,k,"controlling"),"new"===b.state&&b.start(O)),s._transceive(C,"sendrecv"===g||"recvonly"===g,"sendrecv"===g||"sendonly"===g),!R||"sendrecv"!==g&&"sendonly"!==g?delete C.rtpReceiver:(P=R.track,y?(c[y.stream]||(c[y.stream]=new e.MediaStream),n(P,c[y.stream]),d.push([P,R,c[y.stream]])):(c.default||(c.default=new e.MediaStream),n(P,c.default),d.push([P,R,c.default]))));else{(C=s.transceivers[l]||s._createTransceiver(h)).mid=T,C.iceGatherer||(C.iceGatherer=s._createIceGatherer(l,_)),U.length&&"new"===C.iceTransport.state&&(!N||_&&0!==l?U.forEach(function(e){a(C.iceTransport,e)}):C.iceTransport.setRemoteCandidates(U)),I=e.RTCRtpReceiver.getCapabilities(h),t<15019&&(I.codecs=I.codecs.filter(function(e){return"rtx"!==e.name})),A=C.sendEncodingParameters||[{ssrc:1001*(2*l+2)}];var M=!1;if("sendrecv"===g||"sendonly"===g){if(M=!C.rtpReceiver,R=C.rtpReceiver||new e.RTCRtpReceiver(C.dtlsTransport,h),M){var L;P=R.track,y&&"-"===y.stream||(y?(c[y.stream]||(c[y.stream]=new e.MediaStream,Object.defineProperty(c[y.stream],"id",{get:function(){return y.stream}})),Object.defineProperty(P,"id",{get:function(){return y.track}}),L=c[y.stream]):(c.default||(c.default=new e.MediaStream),L=c.default)),L&&(n(P,L),C.associatedRemoteMediaStreams.push(L)),d.push([P,R,L])}}else C.rtpReceiver&&C.rtpReceiver.track&&(C.associatedRemoteMediaStreams.forEach(function(t){var n=t.getTracks().find(function(e){return e.id===C.rtpReceiver.track.id});n&&(r=n,(i=t).removeTrack(r),i.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:r})));var r,i}),C.associatedRemoteMediaStreams=[]);C.localCapabilities=I,C.remoteCapabilities=x,C.rtpReceiver=R,C.rtcpParameters=D,C.sendEncodingParameters=A,C.recvEncodingParameters=w,s._transceive(s.transceivers[l],!1,M)}}}),void 0===s._dtlsRole&&(s._dtlsRole="offer"===i.type?"active":"passive"),s.remoteDescription={type:i.type,sdp:i.sdp},"offer"===i.type?s._updateSignalingState("have-remote-offer"):s._updateSignalingState("stable"),Object.keys(c).forEach(function(t){var n=c[t];if(n.getTracks().length){if(-1===s.remoteStreams.indexOf(n)){s.remoteStreams.push(n);var r=new Event("addstream");r.stream=n,e.setTimeout(function(){s._dispatchEvent("addstream",r)})}d.forEach(function(e){var t=e[0],r=e[1];n.id===e[2].id&&u(s,t,r,[n])})}}),d.forEach(function(e){e[2]||u(s,e[0],e[1],[])}),e.setTimeout(function(){s&&s.transceivers&&s.transceivers.forEach(function(e){e.iceTransport&&"new"===e.iceTransport.state&&e.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),e.iceTransport.addRemoteCandidate({}))})},4e3),Promise.resolve()},c.prototype.close=function(){this.transceivers.forEach(function(e){e.iceTransport&&e.iceTransport.stop(),e.dtlsTransport&&e.dtlsTransport.stop(),e.rtpSender&&e.rtpSender.stop(),e.rtpReceiver&&e.rtpReceiver.stop()}),this._isClosed=!0,this._updateSignalingState("closed")},c.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t)},c.prototype._maybeFireNegotiationNeeded=function(){var t=this;"stable"===this.signalingState&&!0!==this.needNegotiation&&(this.needNegotiation=!0,e.setTimeout(function(){if(t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t._dispatchEvent("negotiationneeded",e)}},0))},c.prototype._updateIceConnectionState=function(){var e,t={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(e){t[e.iceTransport.state]++}),e="new",t.failed>0?e="failed":t.checking>0?e="checking":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0?e="connected":t.completed>0&&(e="completed"),e!==this.iceConnectionState){this.iceConnectionState=e;var n=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",n)}},c.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(e){t[e.iceTransport.state]++,t[e.dtlsTransport.state]++}),t.connected+=t.completed,e="new",t.failed>0?e="failed":t.connecting>0?e="connecting":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0&&(e="connected"),e!==this.connectionState){this.connectionState=e;var n=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",n)}},c.prototype.createOffer=function(){var n=this;if(n._isClosed)return Promise.reject(l("InvalidStateError","Can not call createOffer after close"));var s=n.transceivers.filter(function(e){return"audio"===e.kind}).length,o=n.transceivers.filter(function(e){return"video"===e.kind}).length,a=arguments[0];if(a){if(a.mandatory||a.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==a.offerToReceiveAudio&&(s=!0===a.offerToReceiveAudio?1:!1===a.offerToReceiveAudio?0:a.offerToReceiveAudio),void 0!==a.offerToReceiveVideo&&(o=!0===a.offerToReceiveVideo?1:!1===a.offerToReceiveVideo?0:a.offerToReceiveVideo)}for(n.transceivers.forEach(function(e){"audio"===e.kind?--s<0&&(e.wantReceive=!1):"video"===e.kind&&--o<0&&(e.wantReceive=!1)});s>0||o>0;)s>0&&(n._createTransceiver("audio"),s--),o>0&&(n._createTransceiver("video"),o--);var u=r.writeSessionBoilerplate(n._sdpSessionId,n._sdpSessionVersion++);n.transceivers.forEach(function(i,s){var o=i.track,a=i.kind,l=i.mid||r.generateIdentifier();i.mid=l,i.iceGatherer||(i.iceGatherer=n._createIceGatherer(s,n.usingBundle));var u=e.RTCRtpSender.getCapabilities(a);t<15019&&(u.codecs=u.codecs.filter(function(e){return"rtx"!==e.name})),u.codecs.forEach(function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1"),i.remoteCapabilities&&i.remoteCapabilities.codecs&&i.remoteCapabilities.codecs.forEach(function(t){e.name.toLowerCase()===t.name.toLowerCase()&&e.clockRate===t.clockRate&&(e.preferredPayloadType=t.payloadType)})}),u.headerExtensions.forEach(function(e){(i.remoteCapabilities&&i.remoteCapabilities.headerExtensions||[]).forEach(function(t){e.uri===t.uri&&(e.id=t.id)})});var c=i.sendEncodingParameters||[{ssrc:1001*(2*s+1)}];o&&t>=15019&&"video"===a&&!c[0].rtx&&(c[0].rtx={ssrc:c[0].ssrc+1}),i.wantReceive&&(i.rtpReceiver=new e.RTCRtpReceiver(i.dtlsTransport,a)),i.localCapabilities=u,i.sendEncodingParameters=c}),"max-compat"!==n._config.bundlePolicy&&(u+="a=group:BUNDLE "+n.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"),u+="a=ice-options:trickle\r\n",n.transceivers.forEach(function(e,t){u+=i(e,e.localCapabilities,"offer",e.stream,n._dtlsRole),u+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===n.iceGatheringState||0!==t&&n.usingBundle||(e.iceGatherer.getLocalCandidates().forEach(function(e){e.component=1,u+="a="+r.writeCandidate(e)+"\r\n"}),"completed"===e.iceGatherer.state&&(u+="a=end-of-candidates\r\n"))});var c=new e.RTCSessionDescription({type:"offer",sdp:u});return Promise.resolve(c)},c.prototype.createAnswer=function(){var n=this;if(n._isClosed)return Promise.reject(l("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==n.signalingState&&"have-local-pranswer"!==n.signalingState)return Promise.reject(l("InvalidStateError","Can not call createAnswer in signalingState "+n.signalingState));var o=r.writeSessionBoilerplate(n._sdpSessionId,n._sdpSessionVersion++);n.usingBundle&&(o+="a=group:BUNDLE "+n.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n");var a=r.getMediaSections(n.remoteDescription.sdp).length;n.transceivers.forEach(function(e,r){if(!(r+1>a)){if(e.rejected)return"application"===e.kind?o+="m=application 0 DTLS/SCTP 5000\r\n":"audio"===e.kind?o+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n":"video"===e.kind&&(o+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"),void(o+="c=IN IP4 0.0.0.0\r\na=inactive\r\na=mid:"+e.mid+"\r\n");if(e.stream){var l;"audio"===e.kind?l=e.stream.getAudioTracks()[0]:"video"===e.kind&&(l=e.stream.getVideoTracks()[0]),l&&t>=15019&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1})}var u=s(e.localCapabilities,e.remoteCapabilities);!u.codecs.filter(function(e){return"rtx"===e.name.toLowerCase()}).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,o+=i(e,u,"answer",e.stream,n._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(o+="a=rtcp-rsize\r\n")}});var u=new e.RTCSessionDescription({type:"answer",sdp:o});return Promise.resolve(u)},c.prototype.addIceCandidate=function(e){var t,n=this;return e&&void 0===e.sdpMLineIndex&&!e.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(i,s){if(!n.remoteDescription)return s(l("InvalidStateError","Can not add ICE candidate without a remote description"));if(e&&""!==e.candidate){var o=e.sdpMLineIndex;if(e.sdpMid)for(var u=0;u0?r.parseCandidate(e.candidate):{};if("tcp"===d.protocol&&(0===d.port||9===d.port))return i();if(d.component&&1!==d.component)return i();if((0===o||o>0&&c.iceTransport!==n.transceivers[0].iceTransport)&&!a(c.iceTransport,d))return s(l("OperationError","Can not add ICE candidate"));var h=e.candidate.trim();0===h.indexOf("a=")&&(h=h.substr(2)),(t=r.getMediaSections(n.remoteDescription.sdp))[o]+="a="+(d.type?h:"end-of-candidates")+"\r\n",n.remoteDescription.sdp=r.getDescription(n.remoteDescription.sdp)+t.join("")}else for(var f=0;f=r)return e;var i=n[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}})}.apply(null,r)},o=["v","o","s","i","u","e","p","c","b","t","r","z","a"],a=["i","c","b","a"];t.exports=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach(function(e){null==e.payloads&&(e.payloads="")});var n=t.outerOrder||o,i=t.innerOrder||a,l=[];return n.forEach(function(t){r[t].forEach(function(n){n.name in e&&null!=e[n.name]?l.push(s(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach(function(e){l.push(s(t,n,e))})})}),e.media.forEach(function(e){l.push(s("m",r.m[0],e)),i.forEach(function(t){r[t].forEach(function(n){n.name in e&&null!=e[n.name]?l.push(s(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach(function(e){l.push(s(t,n,e))})})})}),l.join("\r\n")+"\r\n"}},{"./grammar":35}],39:[function(e,t,n){"use strict";var r={};r.generateIdentifier=function(){return Math.random().toString(36).substr(2,10)},r.localCName=r.generateIdentifier(),r.splitLines=function(e){return e.trim().split("\n").map(function(e){return e.trim()})},r.splitSections=function(e){return e.split("\nm=").map(function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"})},r.getDescription=function(e){var t=r.splitSections(e);return t&&t[0]},r.getMediaSections=function(e){var t=r.splitSections(e);return t.shift(),t},r.matchPrefix=function(e,t){return r.splitLines(e).filter(function(e){return 0===e.indexOf(t)})},r.parseCandidate=function(e){for(var t,n={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],port:parseInt(t[5],10),type:t[7]},r=8;r0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},r.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},r.parseFmtp=function(e){for(var t,n={},r=e.substr(e.indexOf(" ")+1).split(";"),i=0;i-1?(n.attribute=e.substr(t+1,r-t-1),n.value=e.substr(r+1)):n.attribute=e.substr(t+1),n},r.getMid=function(e){var t=r.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},r.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},r.getDtlsParameters=function(e,t){return{role:"auto",fingerprints:r.matchPrefix(e+t,"a=fingerprint:").map(r.parseFingerprint)}},r.writeDtlsParameters=function(e,t){var n="a=setup:"+t+"\r\n";return e.fingerprints.forEach(function(e){n+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"}),n},r.getIceParameters=function(e,t){var n=r.splitLines(e);return{usernameFragment:(n=n.concat(r.splitLines(t))).filter(function(e){return 0===e.indexOf("a=ice-ufrag:")})[0].substr(12),password:n.filter(function(e){return 0===e.indexOf("a=ice-pwd:")})[0].substr(10)}},r.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},r.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},n=r.splitLines(e)[0].split(" "),i=3;i0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=t.codecs.map(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType}).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach(function(e){n+=r.writeRtpMap(e),n+=r.writeFmtp(e),n+=r.writeRtcpFb(e)});var i=0;return t.codecs.forEach(function(e){e.maxptime>i&&(i=e.maxptime)}),i>0&&(n+="a=maxptime:"+i+"\r\n"),n+="a=rtcp-mux\r\n",t.headerExtensions.forEach(function(e){n+=r.writeExtmap(e)}),n},r.parseRtpEncodingParameters=function(e){var t,n=[],i=r.parseRtpParameters(e),s=-1!==i.fecMechanisms.indexOf("RED"),o=-1!==i.fecMechanisms.indexOf("ULPFEC"),a=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute}),l=a.length>0&&a[0].ssrc,u=r.matchPrefix(e,"a=ssrc-group:FID").map(function(e){var t=e.split(" ");return t.shift(),t.map(function(e){return parseInt(e,10)})});u.length>0&&u[0].length>1&&u[0][0]===l&&(t=u[0][1]),i.codecs.forEach(function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var r={ssrc:l,codecPayloadType:parseInt(e.parameters.apt,10),rtx:{ssrc:t}};n.push(r),s&&((r=JSON.parse(JSON.stringify(r))).fec={ssrc:t,mechanism:o?"red+ulpfec":"red"},n.push(r))}}),0===n.length&&l&&n.push({ssrc:l});var c=r.matchPrefix(e,"b=");return c.length&&(c=0===c[0].indexOf("b=TIAS:")?parseInt(c[0].substr(7),10):0===c[0].indexOf("b=AS:")?1e3*parseInt(c[0].substr(5),10)*.95-16e3:void 0,n.forEach(function(e){e.maxBitrate=c})),n},r.parseRtcpParameters=function(e){var t={},n=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute})[0];n&&(t.cname=n.value,t.ssrc=n.ssrc);var i=r.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=i.length>0,t.compound=0===i.length;var s=r.matchPrefix(e,"a=rtcp-mux");return t.mux=s.length>0,t},r.parseMsid=function(e){var t,n=r.matchPrefix(e,"a=msid:");if(1===n.length)return{stream:(t=n[0].substr(7).split(" "))[0],track:t[1]};var i=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"msid"===e.attribute});return i.length>0?{stream:(t=i[0].value.split(" "))[0],track:t[1]}:void 0},r.generateSessionId=function(){return Math.random().toString().substr(2,21)},r.writeSessionBoilerplate=function(e,t){var n=void 0!==t?t:2;return"v=0\r\no=thisisadapterortc "+(e||r.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},r.writeMediaSection=function(e,t,n,i){var s=r.writeRtpDescription(e.kind,t);if(s+=r.writeIceParameters(e.iceGatherer.getLocalParameters()),s+=r.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===n?"actpass":"active"),s+="a=mid:"+e.mid+"\r\n",e.direction?s+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?s+="a=sendrecv\r\n":e.rtpSender?s+="a=sendonly\r\n":e.rtpReceiver?s+="a=recvonly\r\n":s+="a=inactive\r\n",e.rtpSender){var o="msid:"+i.id+" "+e.rtpSender.track.id+"\r\n";s+="a="+o,s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+o,e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+o,s+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+r.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+r.localCName+"\r\n"),s},r.getDirection=function(e,t){for(var n=r.splitLines(e),i=0;i=65)return this.shimAddTrackRemoveTrackWithNative(e);var n=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=n.apply(this);return e._reverseStreams=e._reverseStreams||{},t.map(function(t){return e._reverseStreams[t.id]})};var i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var n=this;if(n._streams=n._streams||{},n._reverseStreams=n._reverseStreams||{},t.getTracks().forEach(function(e){if(n.getSenders().find(function(t){return t.track===e}))throw new DOMException("Track already exists.","InvalidAccessError")}),!n._reverseStreams[t.id]){var r=new e.MediaStream(t.getTracks());n._streams[t.id]=r,n._reverseStreams[r.id]=t,t=r}i.apply(n,[t])};var s=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},s.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,n){var r=this;if("closed"===r.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var i=[].slice.call(arguments,1);if(1!==i.length||!i[0].getTracks().find(function(e){return e===t}))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(r.getSenders().find(function(e){return e.track===t}))throw new DOMException("Track already exists.","InvalidAccessError");r._streams=r._streams||{},r._reverseStreams=r._reverseStreams||{};var s=r._streams[n.id];if(s)s.addTrack(t),Promise.resolve().then(function(){r.dispatchEvent(new Event("negotiationneeded"))});else{var o=new e.MediaStream([t]);r._streams[n.id]=o,r._reverseStreams[o.id]=n,r.addStream(o)}return r.getSenders().find(function(e){return e.track===t})};function o(e,t){var n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(function(t){var r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(i.id,"g"),r.id)}),new RTCSessionDescription({type:t.type,sdp:n})}["createOffer","createAnswer"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){var e=this,t=arguments;return arguments.length&&"function"==typeof arguments[0]?n.apply(e,[function(n){var r=o(e,n);t[0].apply(null,[r])},function(e){t[1]&&t[1].apply(null,e)},arguments[2]]):n.apply(e,arguments).then(function(t){return o(e,t)})}});var a=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=function(e,t){var n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(function(t){var r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(r.id,"g"),i.id)}),new RTCSessionDescription({type:t.type,sdp:n})}(this,arguments[0]),a.apply(this,arguments)):a.apply(this,arguments)};var l=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=l.get.apply(this);return""===e.type?e:o(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;if("closed"===t.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(e._pc===t))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");t._streams=t._streams||{};var n;Object.keys(t._streams).forEach(function(r){t._streams[r].getTracks().find(function(t){return e.track===t})&&(n=t._streams[r])}),n&&(1===n.getTracks().length?t.removeStream(t._reverseStreams[n.id]):n.removeTrack(e.track),t.dispatchEvent(new Event("negotiationneeded")))}},shimPeerConnection:function(e){var t=r.detectBrowser(e);if(!e.RTCPeerConnection&&e.webkitRTCPeerConnection)e.RTCPeerConnection=function(t,n){return i("PeerConnection"),t&&t.iceTransportPolicy&&(t.iceTransports=t.iceTransportPolicy),new e.webkitRTCPeerConnection(t,n)},e.RTCPeerConnection.prototype=e.webkitRTCPeerConnection.prototype,e.webkitRTCPeerConnection.generateCertificate&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function(){return e.webkitRTCPeerConnection.generateCertificate}});else{var n=e.RTCPeerConnection;e.RTCPeerConnection=function(e,t){if(e&&e.iceServers){for(var i=[],s=0;s0&&"function"==typeof e)return s.apply(this,arguments);if(0===s.length&&(0===arguments.length||"function"!=typeof arguments[0]))return s.apply(this,[]);var o=function(e){var t={};return e.result().forEach(function(e){var n={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach(function(t){n[t]=e.stat(t)}),t[n.id]=n}),t},a=function(e){return new Map(Object.keys(e).map(function(t){return[t,e[t]]}))};if(arguments.length>=2){return s.apply(this,[function(e){i[1](a(o(e)))},arguments[0]])}return new Promise(function(e,t){s.apply(r,[function(t){e(a(o(t)))},t])}).then(t,n)},t.version<51&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){var e=arguments,t=this,r=new Promise(function(r,i){n.apply(t,[e[0],r,i])});return e.length<2?r:r.then(function(){e[1].apply(null,[])},function(t){e.length>=3&&e[2].apply(null,[t])})}}),t.version<52&&["createOffer","createAnswer"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){var e=this;if(arguments.length<1||1===arguments.length&&"object"==typeof arguments[0]){var t=1===arguments.length?arguments[0]:void 0;return new Promise(function(r,i){n.apply(e,[r,i,t])})}return n.apply(this,arguments)}}),["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}});var o=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?o.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}}}},{"../utils.js":50,"./getusermedia":43}],43:[function(e,t,n){"use strict";var r=e("../utils.js"),i=r.log;t.exports=function(e){var t=r.detectBrowser(e),n=e&&e.navigator,s=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;var t={};return Object.keys(e).forEach(function(n){if("require"!==n&&"advanced"!==n&&"mediaSource"!==n){var r="object"==typeof e[n]?e[n]:{ideal:e[n]};void 0!==r.exact&&"number"==typeof r.exact&&(r.min=r.max=r.exact);var i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==r.ideal){t.optional=t.optional||[];var s={};"number"==typeof r.ideal?(s[i("min",n)]=r.ideal,t.optional.push(s),(s={})[i("max",n)]=r.ideal,t.optional.push(s)):(s[i("",n)]=r.ideal,t.optional.push(s))}void 0!==r.exact&&"number"!=typeof r.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",n)]=r.exact):["min","max"].forEach(function(e){void 0!==r[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,n)]=r[e])})}}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},o=function(e,r){if(t.version>=61)return r(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){var o=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])};o((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),o(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=s(e.audio)}if(e&&"object"==typeof e.video){var a=e.video.facingMode;a=a&&("object"==typeof a?a:{ideal:a});var l=t.version<66;if(a&&("user"===a.exact||"environment"===a.exact||"user"===a.ideal||"environment"===a.ideal)&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||l)){delete e.video.facingMode;var u;if("environment"===a.exact||"environment"===a.ideal?u=["back","rear"]:"user"!==a.exact&&"user"!==a.ideal||(u=["front"]),u)return n.mediaDevices.enumerateDevices().then(function(t){var n=(t=t.filter(function(e){return"videoinput"===e.kind})).find(function(e){return u.some(function(t){return-1!==e.label.toLowerCase().indexOf(t)})});return!n&&t.length&&-1!==u.indexOf("back")&&(n=t[t.length-1]),n&&(e.video.deviceId=a.exact?{exact:n.deviceId}:{ideal:n.deviceId}),e.video=s(e.video),i("chrome: "+JSON.stringify(e)),r(e)})}e.video=s(e.video)}return i("chrome: "+JSON.stringify(e)),r(e)},a=function(e){return{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}};n.getUserMedia=function(e,t,r){o(e,function(e){n.webkitGetUserMedia(e,t,function(e){r&&r(a(e))})})};var l=function(e){return new Promise(function(t,r){n.getUserMedia(e,t,r)})};if(n.mediaDevices||(n.mediaDevices={getUserMedia:l,enumerateDevices:function(){return new Promise(function(t){var n={audio:"audioinput",video:"videoinput"};return e.MediaStreamTrack.getSources(function(e){t(e.map(function(e){return{label:e.label,kind:n[e.kind],deviceId:e.id,groupId:""}}))})})},getSupportedConstraints:function(){return{deviceId:!0,echoCancellation:!0,facingMode:!0,frameRate:!0,height:!0,width:!0}}}),n.mediaDevices.getUserMedia){var u=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(e){return o(e,function(e){return u(e).then(function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach(function(e){e.stop()}),new DOMException("","NotFoundError");return t},function(e){return Promise.reject(a(e))})})}}else n.mediaDevices.getUserMedia=function(e){return l(e)};void 0===n.mediaDevices.addEventListener&&(n.mediaDevices.addEventListener=function(){i("Dummy mediaDevices.addEventListener called.")}),void 0===n.mediaDevices.removeEventListener&&(n.mediaDevices.removeEventListener=function(){i("Dummy mediaDevices.removeEventListener called.")})}},{"../utils.js":50}],44:[function(e,t,n){"use strict";var r=e("sdp"),i=e("./utils");t.exports={shimRTCIceCandidate:function(e){if(e.RTCIceCandidate&&!(e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var n=new t(e),i=r.parseCandidate(e.candidate),s=Object.assign(n,i);return s.toJSON=function(){return{candidate:s.candidate,sdpMid:s.sdpMid,sdpMLineIndex:s.sdpMLineIndex,usernameFragment:s.usernameFragment}},s}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,i.wrapPeerConnectionEvent(e,"icecandidate",function(t){return t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t})}},shimCreateObjectURL:function(e){var t=e&&e.URL;if("object"==typeof e&&e.HTMLMediaElement&&"srcObject"in e.HTMLMediaElement.prototype&&t.createObjectURL&&t.revokeObjectURL){var n=t.createObjectURL.bind(t),r=t.revokeObjectURL.bind(t),s=new Map,o=0;t.createObjectURL=function(e){if("getTracks"in e){var t="polyblob:"+ ++o;return s.set(t,e),i.deprecated("URL.createObjectURL(stream)","elem.srcObject = stream"),t}return n(e)},t.revokeObjectURL=function(e){r(e),s.delete(e)};var a=Object.getOwnPropertyDescriptor(e.HTMLMediaElement.prototype,"src");Object.defineProperty(e.HTMLMediaElement.prototype,"src",{get:function(){return a.get.apply(this)},set:function(e){return this.srcObject=s.get(e)||null,a.set.apply(this,[e])}});var l=e.HTMLMediaElement.prototype.setAttribute;e.HTMLMediaElement.prototype.setAttribute=function(){return 2===arguments.length&&"src"===(""+arguments[0]).toLowerCase()&&(this.srcObject=s.get(arguments[1])||null),l.apply(this,arguments)}}},shimMaxMessageSize:function(e){if(!e.RTCSctpTransport&&e.RTCPeerConnection){var t=i.detectBrowser(e);"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp}});var n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,function(e){var t=r.splitSections(e.sdp);return t.shift(),t.some(function(e){var t=r.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")})}(arguments[0])){var e,i=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;var n=parseInt(t[1],10);return n!=n?-1:n}(arguments[0]),s=function(e){var n=65536;return"firefox"===t.browser&&(n=t.version<57?-1===e?16384:2147483637:57===t.version?65535:65536),n}(i),o=function(e,n){var i=65536;"firefox"===t.browser&&57===t.version&&(i=65535);var s=r.matchPrefix(e.sdp,"a=max-message-size:");return s.length>0?i=parseInt(s[0].substr(19),10):"firefox"===t.browser&&-1!==n&&(i=2147483637),i}(arguments[0],i);e=0===s&&0===o?Number.POSITIVE_INFINITY:0===s||0===o?Math.max(s,o):Math.min(s,o);var a={};Object.defineProperty(a,"maxMessageSize",{get:function(){return e}}),this._sctp=a}return n.apply(this,arguments)}}},shimSendThrowTypeError:function(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var e=this,n=t.apply(e,arguments),r=n.send;return n.send=function(){var t=arguments[0];if((t.length||t.size||t.byteLength)>e.sctp.maxMessageSize)throw new DOMException("Message too large (can send a maximum of "+e.sctp.maxMessageSize+" bytes)","TypeError");return r.apply(this,arguments)},n}}}}},{"./utils":50,sdp:39}],45:[function(e,t,n){"use strict";var r=e("../utils"),i=e("rtcpeerconnection-shim");t.exports={shimGetUserMedia:e("./getusermedia"),shimPeerConnection:function(e){var t=r.detectBrowser(e);if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(e){return e}),e.RTCSessionDescription||(e.RTCSessionDescription=function(e){return e}),t.version<15025)){var n=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set:function(e){n.set.call(this,e);var t=new Event("enabled");t.enabled=e,this.dispatchEvent(t)}})}!e.RTCRtpSender||"dtmf"in e.RTCRtpSender.prototype||Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=new e.RTCDtmfSender(this):"video"===this.track.kind&&(this._dtmf=null)),this._dtmf}}),e.RTCDtmfSender&&!e.RTCDTMFSender&&(e.RTCDTMFSender=e.RTCDtmfSender),e.RTCPeerConnection=i(e,t.version)},shimReplaceTrack:function(e){!e.RTCRtpSender||"replaceTrack"in e.RTCRtpSender.prototype||(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}}},{"../utils":50,"./getusermedia":46,"rtcpeerconnection-shim":34}],46:[function(e,t,n){"use strict";t.exports=function(e){var t=e&&e.navigator,n=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return n(e).catch(function(e){return Promise.reject({name:{PermissionDeniedError:"NotAllowedError"}[(t=e).name]||t.name,message:t.message,constraint:t.constraint,toString:function(){return this.name}});var t})}}},{}],47:[function(e,t,n){"use strict";var r=e("../utils");t.exports={shimGetUserMedia:e("./getusermedia"),shimOnTrack:function(e){"object"!=typeof e||!e.RTCPeerConnection||"ontrack"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&(this.removeEventListener("track",this._ontrack),this.removeEventListener("addstream",this._ontrackpoly)),this.addEventListener("track",this._ontrack=e),this.addEventListener("addstream",this._ontrackpoly=function(e){e.stream.getTracks().forEach(function(t){var n=new Event("track");n.track=t,n.receiver={track:t},n.transceiver={receiver:n.receiver},n.streams=[e.stream],this.dispatchEvent(n)}.bind(this))}.bind(this))}}),"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})},shimSourceObject:function(e){"object"==typeof e&&(!e.HTMLMediaElement||"srcObject"in e.HTMLMediaElement.prototype||Object.defineProperty(e.HTMLMediaElement.prototype,"srcObject",{get:function(){return this.mozSrcObject},set:function(e){this.mozSrcObject=e}}))},shimPeerConnection:function(e){var t=r.detectBrowser(e);if("object"==typeof e&&(e.RTCPeerConnection||e.mozRTCPeerConnection)){e.RTCPeerConnection||(e.RTCPeerConnection=function(n,r){if(t.version<38&&n&&n.iceServers){for(var i=[],s=0;s55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){var c=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])},d=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(e){return"object"==typeof e&&"object"==typeof e.audio&&(e=JSON.parse(JSON.stringify(e)),c(e.audio,"autoGainControl","mozAutoGainControl"),c(e.audio,"noiseSuppression","mozNoiseSuppression")),d(e)},s&&s.prototype.getSettings){var h=s.prototype.getSettings;s.prototype.getSettings=function(){var e=h.apply(this,arguments);return c(e,"mozAutoGainControl","autoGainControl"),c(e,"mozNoiseSuppression","noiseSuppression"),e}}if(s&&s.prototype.applyConstraints){var f=s.prototype.applyConstraints;s.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"==typeof e&&(e=JSON.parse(JSON.stringify(e)),c(e,"autoGainControl","mozAutoGainControl"),c(e,"noiseSuppression","mozNoiseSuppression")),f.apply(this,[e])}}}n.getUserMedia=function(e,i,s){if(t.version<44)return a(e,i,s);r.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(e).then(i,s)}}},{"../utils":50}],49:[function(e,t,n){"use strict";var r=e("../utils");t.exports={shimLocalStreamsAPI:function(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),"getStreamById"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getStreamById=function(e){var t=null;return this._localStreams&&this._localStreams.forEach(function(n){n.id===e&&(t=n)}),this._remoteStreams&&this._remoteStreams.forEach(function(n){n.id===e&&(t=n)}),t}),!("addStream"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),-1===this._localStreams.indexOf(e)&&this._localStreams.push(e);var n=this;e.getTracks().forEach(function(r){t.call(n,r,e)})},e.RTCPeerConnection.prototype.addTrack=function(e,n){return n&&(this._localStreams?-1===this._localStreams.indexOf(n)&&this._localStreams.push(n):this._localStreams=[n]),t.call(this,e,n)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);var t=this._localStreams.indexOf(e);if(-1!==t){this._localStreams.splice(t,1);var n=this,r=e.getTracks();this.getSenders().forEach(function(e){-1!==r.indexOf(e.track)&&n.removeTrack(e)})}})}},shimRemoteStreamsAPI:function(e){"object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),"onaddstream"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(e){var t=this;this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=function(e){e.streams.forEach(function(e){if(t._remoteStreams||(t._remoteStreams=[]),!(t._remoteStreams.indexOf(e)>=0)){t._remoteStreams.push(e);var n=new Event("addstream");n.stream=e,t.dispatchEvent(n)}})})}}))},shimCallbacksAPI:function(e){if("object"==typeof e&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype,n=t.createOffer,r=t.createAnswer,i=t.setLocalDescription,s=t.setRemoteDescription,o=t.addIceCandidate;t.createOffer=function(e,t){var r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){var n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i};var a=function(e,t,n){var r=i.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r};t.setLocalDescription=a,a=function(e,t,n){var r=s.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.setRemoteDescription=a,a=function(e,t,n){var r=o.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.addIceCandidate=a}},shimGetUserMedia:function(e){var t=e&&e.navigator;t.getUserMedia||(t.webkitGetUserMedia?t.getUserMedia=t.webkitGetUserMedia.bind(t):t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,n,r){t.mediaDevices.getUserMedia(e).then(n,r)}.bind(t)))},shimRTCIceServerUrls:function(e){var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,n){if(e&&e.iceServers){for(var i=[],s=0;s=n&&parseInt(r[n],10)}t.exports={extractVersion:s,wrapPeerConnectionEvent:function(e,t,n){if(e.RTCPeerConnection){var r=e.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(e,r){if(e!==t)return i.apply(this,arguments);var s=function(e){r(n(e))};return this._eventMap=this._eventMap||{},this._eventMap[r]=s,i.apply(this,[e,s])};var s=r.removeEventListener;r.removeEventListener=function(e,n){if(e!==t||!this._eventMap||!this._eventMap[n])return s.apply(this,arguments);var r=this._eventMap[n];return delete this._eventMap[n],s.apply(this,[e,r])},Object.defineProperty(r,"on"+t,{get:function(){return this["_on"+t]},set:function(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)}})}},disableLog:function(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(r=e,e?"adapter.js logging disabled":"adapter.js logging enabled")},disableWarnings:function(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(i=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))},log:function(){if("object"==typeof window){if(r)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}},deprecated:function(e,t){i&&console.warn(e+" is deprecated, please use "+t+" instead.")},detectBrowser:function(e){var t=e&&e.navigator,n={};if(n.browser=null,n.version=null,void 0===e||!e.navigator)return n.browser="Not a browser.",n;if(t.mozGetUserMedia)n.browser="firefox",n.version=s(t.userAgent,/Firefox\/(\d+)\./,1);else if(t.webkitGetUserMedia)n.browser="chrome",n.version=s(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(t.mediaDevices&&t.userAgent.match(/Edge\/(\d+).(\d+)$/))n.browser="edge",n.version=s(t.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!e.RTCPeerConnection||!t.userAgent.match(/AppleWebKit\/(\d+)\./))return n.browser="Not a supported browser.",n;n.browser="safari",n.version=s(t.userAgent,/AppleWebKit\/(\d+)\./,1)}return n}}},{}],51:[function(e,t,n){t.exports={name:"jssip",title:"JsSIP",description:"the Javascript SIP library",version:"3.2.7",homepage:"http://jssip.net",author:"José Luis Millán (https://github.com/jmillan)",contributors:["Iñaki Baz Castillo (https://github.com/ibc)","Saúl Ibarra Corretgé (https://github.com/saghul)"],main:"lib-es5/JsSIP.js",keywords:["sip","websocket","webrtc","node","browser","library"],license:"MIT",repository:{type:"git",url:"https://github.com/versatica/JsSIP.git"},bugs:{url:"https://github.com/versatica/JsSIP/issues"},dependencies:{debug:"^3.1.0","sdp-transform":"^2.4.0","webrtc-adapter":"^6.1.4"},devDependencies:{"ansi-colors":"^1.1.0","babel-core":"^6.26.0","babel-preset-env":"^1.6.1",browserify:"^16.1.1",eslint:"^4.19.1","fancy-log":"^1.3.2",gulp:"^4.0.0","gulp-babel":"^7.0.1","gulp-eslint":"^4.0.2","gulp-expect-file":"0.0.7","gulp-header":"^2.0.5","gulp-nodeunit-runner":"^0.2.2","gulp-plumber":"^1.2.0","gulp-rename":"^1.2.2","gulp-uglify":"^3.0.0",pegjs:"^0.7.0","vinyl-buffer":"^1.0.1","vinyl-source-stream":"^2.0.0"},scripts:{test:"gulp test",prepublishOnly:"gulp babel"}}},{}]},{},[8])(8)}); \ No newline at end of file +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).JsSIP=e()}}(function(){return function e(t,n,r){function i(a,o){if(!n[a]){if(!t[a]){var l="function"==typeof require&&require;if(!o&&l)return l(a,!0);if(s)return s(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var c=n[a]={exports:{}};t[a][0].call(c.exports,function(e){var n=t[a][1][e];return i(n||e)},c,c.exports,e,t,n,r)}return n[a].exports}for(var s="function"==typeof require&&require,a=0;a0)return t}},connection_recovery_min_interval:function(e){if(r.isDecimal(e)){var t=Number(e);if(t>0)return t}},contact_uri:function(e){if("string"==typeof e){var t=s.parse(e,"SIP_URI");if(-1!==t)return t}},display_name:function(e){return-1===s.parse('"'+e+'"',"display_name")?void 0:e},instance_id:function(e){return/^uuid:/i.test(e)&&(e=e.substr(5)),-1===s.parse(e,"uuid")?void 0:e},no_answer_timeout:function(e){if(r.isDecimal(e)){var t=Number(e);if(t>0)return t}},session_timers:function(e){if("boolean"==typeof e)return e},session_timers_refresh_method:function(e){if("string"==typeof e&&((e=e.toUpperCase())===i.INVITE||e===i.UPDATE))return e},password:function(e){return String(e)},realm:function(e){return String(e)},ha1:function(e){return String(e)},register:function(e){if("boolean"==typeof e)return e},register_expires:function(e){if(r.isDecimal(e)){var t=Number(e);if(t>0)return t}},registrar_server:function(e){/^sip:/i.test(e)||(e=i.SIP+":"+e);var t=a.parse(e);return t?t.user?void 0:t:void 0},use_preloaded_route:function(e){if("boolean"==typeof e)return e}}};n.load=function(e,t){for(var n in u.mandatory){if(!t.hasOwnProperty(n))throw new l.ConfigurationError(n);var i=t[n],s=u.mandatory[n](i);if(void 0===s)throw new l.ConfigurationError(n,i);e[n]=s}for(var a in u.optional)if(t.hasOwnProperty(a)){var o=t[a];if(r.isEmpty(o))continue;var c=u.optional[a](o);if(void 0===c)throw new l.ConfigurationError(a,o);e[a]=c}}},{"./Constants":2,"./Exceptions":6,"./Grammar":7,"./Socket":20,"./URI":25,"./Utils":26}],2:[function(e,t,n){"use strict";var r=e("../package.json");t.exports={USER_AGENT:r.title+" "+r.version,SIP:"sip",SIPS:"sips",causes:{CONNECTION_ERROR:"Connection Error",REQUEST_TIMEOUT:"Request Timeout",SIP_FAILURE_CODE:"SIP Failure Code",INTERNAL_ERROR:"Internal Error",BUSY:"Busy",REJECTED:"Rejected",REDIRECTED:"Redirected",UNAVAILABLE:"Unavailable",NOT_FOUND:"Not Found",ADDRESS_INCOMPLETE:"Address Incomplete",INCOMPATIBLE_SDP:"Incompatible SDP",MISSING_SDP:"Missing SDP",AUTHENTICATION_ERROR:"Authentication Error",BYE:"Terminated",WEBRTC_ERROR:"WebRTC Error",CANCELED:"Canceled",NO_ANSWER:"No Answer",EXPIRES:"Expires",NO_ACK:"No ACK",DIALOG_ERROR:"Dialog Error",USER_DENIED_MEDIA_ACCESS:"User Denied Media Access",BAD_MEDIA_DESCRIPTION:"Bad Media Description",RTP_TIMEOUT:"RTP Timeout"},SIP_ERROR_CAUSES:{REDIRECTED:[300,301,302,305,380],BUSY:[486,600],REJECTED:[403,603],NOT_FOUND:[404,604],UNAVAILABLE:[480,410,408,430],ADDRESS_INCOMPLETE:[484,424],INCOMPATIBLE_SDP:[488,606],AUTHENTICATION_ERROR:[401,407]},ACK:"ACK",BYE:"BYE",CANCEL:"CANCEL",INFO:"INFO",INVITE:"INVITE",MESSAGE:"MESSAGE",NOTIFY:"NOTIFY",OPTIONS:"OPTIONS",REGISTER:"REGISTER",REFER:"REFER",UPDATE:"UPDATE",SUBSCRIBE:"SUBSCRIBE",REASON_PHRASE:{100:"Trying",180:"Ringing",181:"Call Is Being Forwarded",182:"Queued",183:"Session Progress",199:"Early Dialog Terminated",200:"OK",202:"Accepted",204:"No Notification",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",305:"Use Proxy",380:"Alternative Service",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",410:"Gone",412:"Conditional Request Failed",413:"Request Entity Too Large",414:"Request-URI Too Long",415:"Unsupported Media Type",416:"Unsupported URI Scheme",417:"Unknown Resource-Priority",420:"Bad Extension",421:"Extension Required",422:"Session Interval Too Small",423:"Interval Too Brief",424:"Bad Location Information",428:"Use Identity Header",429:"Provide Referrer Identity",430:"Flow Failed",433:"Anonymity Disallowed",436:"Bad Identity-Info",437:"Unsupported Certificate",438:"Invalid Identity Header",439:"First Hop Lacks Outbound Support",440:"Max-Breadth Exceeded",469:"Bad Info Package",470:"Consent Needed",478:"Unresolvable Destination",480:"Temporarily Unavailable",481:"Call/Transaction Does Not Exist",482:"Loop Detected",483:"Too Many Hops",484:"Address Incomplete",485:"Ambiguous",486:"Busy Here",487:"Request Terminated",488:"Not Acceptable Here",489:"Bad Event",491:"Request Pending",493:"Undecipherable",494:"Security Agreement Required",500:"JsSIP Internal Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Server Time-out",505:"Version Not Supported",513:"Message Too Large",580:"Precondition Failure",600:"Busy Everywhere",603:"Decline",604:"Does Not Exist Anywhere",606:"Not Acceptable"},ALLOWED_METHODS:"INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO",ACCEPTED_BODY_TYPES:"application/sdp, application/dtmf-relay",MAX_FORWARDS:69,SESSION_EXPIRES:90,MIN_SESSION_EXPIRES:60}},{"../package.json":51}],3:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n3&&void 0!==arguments[3]?arguments[3]:c.STATUS_CONFIRMED;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._owner=t,this._ua=t._ua,this._uac_pending_reply=!1,this._uas_pending_reply=!1,!n.hasHeader("contact"))return{error:"unable to create a Dialog without Contact header field"};n instanceof i.IncomingResponse&&(s=n.status_code<200?c.STATUS_EARLY:c.STATUS_CONFIRMED);var a=n.parseHeader("contact");"UAS"===r?(this._id={call_id:n.call_id,local_tag:n.to_tag,remote_tag:n.from_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=s,this._remote_seqnum=n.cseq,this._local_uri=n.parseHeader("to").uri,this._remote_uri=n.parseHeader("from").uri,this._remote_target=a.uri,this._route_set=n.getHeaders("record-route"),this._ack_seqnum=this._remote_seqnum):"UAC"===r&&(this._id={call_id:n.call_id,local_tag:n.from_tag,remote_tag:n.to_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=s,this._local_seqnum=n.cseq,this._local_uri=n.parseHeader("from").uri,this._remote_uri=n.parseHeader("to").uri,this._remote_target=a.uri,this._route_set=n.getHeaders("record-route").reverse(),this._ack_seqnum=null),this._ua.newDialog(this),u("new "+r+" dialog created with status "+(this._state===c.STATUS_EARLY?"EARLY":"CONFIRMED"))}return r(e,[{key:"update",value:function(e,t){this._state=c.STATUS_CONFIRMED,u("dialog "+this._id.toString()+" changed to CONFIRMED state"),"UAC"===t&&(this._route_set=e.getHeaders("record-route").reverse())}},{key:"terminate",value:function(){u("dialog "+this._id.toString()+" deleted"),this._ua.destroyDialog(this)}},{key:"sendRequest",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=l.cloneArray(n.extraHeaders),i=n.eventHandlers||{},s=n.body||null,a=this._createRequest(e,r,s);i.onAuthenticated=function(){t._local_seqnum+=1};return new o(this,a,i).send(),a}},{key:"receiveRequest",value:function(e){this._checkInDialogRequest(e)&&(e.method===s.ACK&&null!==this._ack_seqnum?this._ack_seqnum=null:e.method===s.INVITE&&(this._ack_seqnum=e.cseq),this._owner.receiveRequest(e))}},{key:"_createRequest",value:function(e,t,n){t=l.cloneArray(t),this._local_seqnum||(this._local_seqnum=Math.floor(1e4*Math.random()));var r=e===s.CANCEL||e===s.ACK?this._local_seqnum:this._local_seqnum+=1;return new i.OutgoingRequest(e,this._remote_target,this._ua,{cseq:r,call_id:this._id.call_id,from_uri:this._local_uri,from_tag:this._id.local_tag,to_uri:this._remote_uri,to_tag:this._id.remote_tag,route_set:this._route_set},t,n)}},{key:"_checkInDialogRequest",value:function(e){var t=this;if(this._remote_seqnum)if(e.cseqthis._remote_seqnum&&(this._remote_seqnum=e.cseq);else this._remote_seqnum=e.cseq;if(e.method===s.INVITE||e.method===s.UPDATE&&e.body){if(!0===this._uac_pending_reply)e.reply(491);else{if(!0===this._uas_pending_reply){var n=1+(10*Math.random()|0);return e.reply(500,null,["Retry-After:"+n]),!1}this._uas_pending_reply=!0;e.server_transaction.on("stateChanged",function n(){e.server_transaction.state!==a.C.STATUS_ACCEPTED&&e.server_transaction.state!==a.C.STATUS_COMPLETED&&e.server_transaction.state!==a.C.STATUS_TERMINATED||(e.server_transaction.removeListener("stateChanged",n),t._uas_pending_reply=!1)})}e.hasHeader("contact")&&e.server_transaction.on("stateChanged",function(){e.server_transaction.state===a.C.STATUS_ACCEPTED&&(t._remote_target=e.parseHeader("contact").uri)})}else e.method===s.NOTIFY&&e.hasHeader("contact")&&e.server_transaction.on("stateChanged",function(){e.server_transaction.state===a.C.STATUS_COMPLETED&&(t._remote_target=e.parseHeader("contact").uri)});return!0}},{key:"id",get:function(){return this._id}},{key:"local_seqnum",get:function(){return this._local_seqnum},set:function(e){this._local_seqnum=e}},{key:"owner",get:function(){return this._owner}},{key:"uac_pending_reply",get:function(){return this._uac_pending_reply},set:function(e){this._uac_pending_reply=e}},{key:"uas_pending_reply",get:function(){return this._uas_pending_reply}}]),e}()},{"./Constants":2,"./Dialog/RequestSender":4,"./SIPMessage":19,"./Transactions":22,"./Utils":26,debug:29}],4:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n=200&&e.status_code<300?this._eventHandlers.onSuccessResponse(e):e.status_code>=300&&this._eventHandlers.onErrorResponse(e):(this._request.cseq.value=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout(function(){t._dialog.owner.status!==a.C.STATUS_TERMINATED&&(t._reattempt=!0,t._request_sender.send())},1e3)):e.status_code>=200&&e.status_code<300?this._eventHandlers.onSuccessResponse(e):e.status_code>=300&&this._eventHandlers.onErrorResponse(e)}},{key:"request",get:function(){return this._request}}]),e}()},{"../Constants":2,"../RTCSession":12,"../RequestSender":18,"../Transactions":22}],5:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:null;if(this._algorithm=t.algorithm,this._realm=t.realm,this._nonce=t.nonce,this._opaque=t.opaque,this._stale=t.stale,this._algorithm){if("MD5"!==this._algorithm)return a('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return a("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return a("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return a("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return a('authenticate() | no plain SIP password, and stored `realm` does not match the given `realm`, cannot authenticate [stored:"%s", given:"%s"]',this._credentials.realm,this._realm),!1}if(t.qop)if(t.qop.indexOf("auth-int")>-1)this._qop="auth-int";else{if(!(t.qop.indexOf("auth")>-1))return a('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;this._qop="auth"}else this._qop=null;this._method=n,this._uri=r,this._cnonce=l||i.createRandomToken(12),this._nc+=1;var u=Number(this._nc).toString(16);this._ncHex="00000000".substr(0,8-u.length)+u,4294967296===this._nc&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=i.calculateMD5(this._credentials.username+":"+this._realm+":"+this._credentials.password):this._ha1=this._credentials.ha1;var c=void 0;return"auth"===this._qop?(c=i.calculateMD5(this._method+":"+this._uri),this._response=i.calculateMD5(this._ha1+":"+this._nonce+":"+this._ncHex+":"+this._cnonce+":auth:"+c)):"auth-int"===this._qop?(c=i.calculateMD5(this._method+":"+this._uri+":"+i.calculateMD5(o||"")),this._response=i.calculateMD5(this._ha1+":"+this._nonce+":"+this._ncHex+":"+this._cnonce+":auth-int:"+c)):null===this._qop&&(c=i.calculateMD5(this._method+":"+this._uri),this._response=i.calculateMD5(this._ha1+":"+this._nonce+":"+c)),s("authenticate() | response generated"),!0}},{key:"toString",value:function(){var e=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return e.push("algorithm="+this._algorithm),e.push('username="'+this._credentials.username+'"'),e.push('realm="'+this._realm+'"'),e.push('nonce="'+this._nonce+'"'),e.push('uri="'+this._uri+'"'),e.push('response="'+this._response+'"'),this._opaque&&e.push('opaque="'+this._opaque+'"'),this._qop&&(e.push("qop="+this._qop),e.push('cnonce="'+this._cnonce+'"'),e.push("nc="+this._ncHex)),"Digest "+e.join(", ")}}]),e}()},{"./Utils":26,debug:29}],6:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=function(e){s(t,Error);function t(e,n){r(this,t);var s=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return s.code=1,s.name="CONFIGURATION_ERROR",s.parameter=e,s.value=n,s.message=s.value?"Invalid value "+JSON.stringify(s.value)+' for parameter "'+s.parameter+'"':"Missing parameter: "+s.parameter,s}return t}(),o=function(e){s(t,Error);function t(e){r(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.code=2,n.name="INVALID_STATE_ERROR",n.status=e,n.message="Invalid status: "+e,n}return t}(),l=function(e){s(t,Error);function t(e){r(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.code=3,n.name="NOT_SUPPORTED_ERROR",n.message=e,n}return t}(),u=function(e){s(t,Error);function t(e){r(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.code=4,n.name="NOT_READY_ERROR",n.message=e,n}return t}();t.exports={ConfigurationError:a,InvalidStateError:o,NotSupportedError:l,NotReadyError:u}},{}],7:[function(e,t,n){"use strict";t.exports=function(){function t(e){return'"'+e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var n={parse:function(n,r){var i={CRLF:c,DIGIT:d,ALPHA:h,HEXDIG:f,WSP:p,OCTET:_,DQUOTE:v,SP:m,HTAB:g,alphanum:y,reserved:T,unreserved:C,mark:S,escaped:E,LWS:b,SWS:R,HCOLON:A,TEXT_UTF8_TRIM:w,TEXT_UTF8char:I,UTF8_NONASCII:k,UTF8_CONT:P,LHEX:function(){var e;null===(e=d())&&(/^[a-f]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[a-f]")));return e},token:O,token_nodot:x,separators:function(){var e;40===n.charCodeAt(s)?(e="(",s++):(e=null,0===a&&u('"("'));null===e&&(41===n.charCodeAt(s)?(e=")",s++):(e=null,0===a&&u('")"')),null===e&&(60===n.charCodeAt(s)?(e="<",s++):(e=null,0===a&&u('"<"')),null===e&&(62===n.charCodeAt(s)?(e=">",s++):(e=null,0===a&&u('">"')),null===e&&(64===n.charCodeAt(s)?(e="@",s++):(e=null,0===a&&u('"@"')),null===e&&(44===n.charCodeAt(s)?(e=",",s++):(e=null,0===a&&u('","')),null===e&&(59===n.charCodeAt(s)?(e=";",s++):(e=null,0===a&&u('";"')),null===e&&(58===n.charCodeAt(s)?(e=":",s++):(e=null,0===a&&u('":"')),null===e&&(92===n.charCodeAt(s)?(e="\\",s++):(e=null,0===a&&u('"\\\\"')),null===e&&null===(e=v())&&(47===n.charCodeAt(s)?(e="/",s++):(e=null,0===a&&u('"/"')),null===e&&(91===n.charCodeAt(s)?(e="[",s++):(e=null,0===a&&u('"["')),null===e&&(93===n.charCodeAt(s)?(e="]",s++):(e=null,0===a&&u('"]"')),null===e&&(63===n.charCodeAt(s)?(e="?",s++):(e=null,0===a&&u('"?"')),null===e&&(61===n.charCodeAt(s)?(e="=",s++):(e=null,0===a&&u('"="')),null===e&&(123===n.charCodeAt(s)?(e="{",s++):(e=null,0===a&&u('"{"')),null===e&&(125===n.charCodeAt(s)?(e="}",s++):(e=null,0===a&&u('"}"')),null===e&&null===(e=m())&&(e=g()))))))))))))))));return e},word:D,STAR:N,SLASH:U,EQUAL:M,LPAREN:L,RPAREN:q,RAQUOT:H,LAQUOT:F,COMMA:j,SEMI:G,COLON:B,LDQUOT:W,RDQUOT:V,comment:function e(){var t,n,r;var i;i=s;t=L();if(null!==t){for(n=[],null===(r=J())&&null===(r=$())&&(r=e());null!==r;)n.push(r),null===(r=J())&&null===(r=$())&&(r=e());null!==n&&null!==(r=q())?t=[t,n,r]:(t=null,s=i)}else t=null,s=i;return t},ctext:J,quoted_string:K,quoted_string_clean:z,qdtext:Y,quoted_pair:$,SIP_URI_noparams:Q,SIP_URI:X,uri_scheme:Z,uri_scheme_sips:ee,uri_scheme_sip:te,userinfo:ne,user:re,user_unreserved:ie,password:se,hostport:ae,host:oe,hostname:le,domainlabel:ue,toplabel:ce,IPv6reference:de,IPv6address:he,h16:fe,ls32:pe,IPv4address:_e,dec_octet:ve,port:me,uri_parameters:ge,uri_parameter:ye,transport_param:Te,user_param:Ce,method_param:Se,ttl_param:Ee,maddr_param:be,lr_param:Re,other_param:Ae,pname:we,pvalue:Ie,paramchar:ke,param_unreserved:Pe,headers:Oe,header:xe,hname:De,hvalue:Ne,hnv_unreserved:Ue,Request_Response:function(){var e;null===(e=dt())&&(e=Me());return e},Request_Line:Me,Request_URI:Le,absoluteURI:qe,hier_part:He,net_path:Fe,abs_path:je,opaque_part:Ge,uric:Be,uric_no_slash:We,path_segments:Ve,segment:Je,param:Ke,pchar:ze,scheme:Ye,authority:$e,srvr:Qe,reg_name:Xe,query:Ze,SIP_Version:et,INVITEm:tt,ACKm:nt,OPTIONSm:rt,BYEm:it,CANCELm:st,REGISTERm:at,SUBSCRIBEm:ot,NOTIFYm:lt,REFERm:ut,Method:ct,Status_Line:dt,Status_Code:ht,extension_code:ft,Reason_Phrase:pt,Allow_Events:function(){var e,t,n,r,i,a;if(i=s,null!==(e=qt())){for(t=[],a=s,null!==(n=j())&&null!==(r=qt())?n=[n,r]:(n=null,s=a);null!==n;)t.push(n),a=s,null!==(n=j())&&null!==(r=qt())?n=[n,r]:(n=null,s=a);null!==t?e=[e,t]:(e=null,s=i)}else e=null,s=i;return e},Call_ID:function(){var e,t,r,i,o,l;i=s,o=s,null!==(e=D())?(l=s,64===n.charCodeAt(s)?(t="@",s++):(t=null,0===a&&u('"@"')),null!==t&&null!==(r=D())?t=[t,r]:(t=null,s=l),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=o)):(e=null,s=o);null!==e&&(c=i,e=void(Fn=n.substring(s,c)));var c;null===e&&(s=i);return e},Contact:function(){var e,t,n,r,i,a,o;if(i=s,null===(e=N()))if(a=s,null!==(e=_t())){for(t=[],o=s,null!==(n=j())&&null!==(r=_t())?n=[n,r]:(n=null,s=o);null!==n;)t.push(n),o=s,null!==(n=j())&&null!==(r=_t())?n=[n,r]:(n=null,s=o);null!==t?e=[e,t]:(e=null,s=a)}else e=null,s=a;null!==e&&(e=function(e){var t,n;for(n=Fn.multi_header.length,t=0;to&&(o=s,l=[]),l.push(e))}function c(){var e;return"\r\n"===n.substr(s,2)?(e="\r\n",s+=2):(e=null,0===a&&u('"\\r\\n"')),e}function d(){var e;return/^[0-9]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[0-9]")),e}function h(){var e;return/^[a-zA-Z]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[a-zA-Z]")),e}function f(){var e;return/^[0-9a-fA-F]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[0-9a-fA-F]")),e}function p(){var e;return null===(e=m())&&(e=g()),e}function _(){var e;return/^[\0-\xFF]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[\\0-\\xFF]")),e}function v(){var e;return/^["]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u('["]')),e}function m(){var e;return 32===n.charCodeAt(s)?(e=" ",s++):(e=null,0===a&&u('" "')),e}function g(){var e;return 9===n.charCodeAt(s)?(e="\t",s++):(e=null,0===a&&u('"\\t"')),e}function y(){var e;return/^[a-zA-Z0-9]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[a-zA-Z0-9]")),e}function T(){var e;return 59===n.charCodeAt(s)?(e=";",s++):(e=null,0===a&&u('";"')),null===e&&(47===n.charCodeAt(s)?(e="/",s++):(e=null,0===a&&u('"/"')),null===e&&(63===n.charCodeAt(s)?(e="?",s++):(e=null,0===a&&u('"?"')),null===e&&(58===n.charCodeAt(s)?(e=":",s++):(e=null,0===a&&u('":"')),null===e&&(64===n.charCodeAt(s)?(e="@",s++):(e=null,0===a&&u('"@"')),null===e&&(38===n.charCodeAt(s)?(e="&",s++):(e=null,0===a&&u('"&"')),null===e&&(61===n.charCodeAt(s)?(e="=",s++):(e=null,0===a&&u('"="')),null===e&&(43===n.charCodeAt(s)?(e="+",s++):(e=null,0===a&&u('"+"')),null===e&&(36===n.charCodeAt(s)?(e="$",s++):(e=null,0===a&&u('"$"')),null===e&&(44===n.charCodeAt(s)?(e=",",s++):(e=null,0===a&&u('","'))))))))))),e}function C(){var e;return null===(e=y())&&(e=S()),e}function S(){var e;return 45===n.charCodeAt(s)?(e="-",s++):(e=null,0===a&&u('"-"')),null===e&&(95===n.charCodeAt(s)?(e="_",s++):(e=null,0===a&&u('"_"')),null===e&&(46===n.charCodeAt(s)?(e=".",s++):(e=null,0===a&&u('"."')),null===e&&(33===n.charCodeAt(s)?(e="!",s++):(e=null,0===a&&u('"!"')),null===e&&(126===n.charCodeAt(s)?(e="~",s++):(e=null,0===a&&u('"~"')),null===e&&(42===n.charCodeAt(s)?(e="*",s++):(e=null,0===a&&u('"*"')),null===e&&(39===n.charCodeAt(s)?(e="'",s++):(e=null,0===a&&u('"\'"')),null===e&&(40===n.charCodeAt(s)?(e="(",s++):(e=null,0===a&&u('"("')),null===e&&(41===n.charCodeAt(s)?(e=")",s++):(e=null,0===a&&u('")"')))))))))),e}function E(){var e,t,r,i,o;return i=s,o=s,37===n.charCodeAt(s)?(e="%",s++):(e=null,0===a&&u('"%"')),null!==e&&null!==(t=f())&&null!==(r=f())?e=[e,t,r]:(e=null,s=o),null!==e&&(e=e.join("")),null===e&&(s=i),e}function b(){var e,t,n,r,i,a;for(r=s,i=s,a=s,e=[],t=p();null!==t;)e.push(t),t=p();if(null!==e&&null!==(t=c())?e=[e,t]:(e=null,s=a),null!==(e=null!==e?e:"")){if(null!==(n=p()))for(t=[];null!==n;)t.push(n),n=p();else t=null;null!==t?e=[e,t]:(e=null,s=i)}else e=null,s=i;return null!==e&&(e=" "),null===e&&(s=r),e}function R(){var e;return e=null!==(e=b())?e:""}function A(){var e,t,r,i,o;for(i=s,o=s,e=[],null===(t=m())&&(t=g());null!==t;)e.push(t),null===(t=m())&&(t=g());return null!==e?(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(e=":"),null===e&&(s=i),e}function w(){var e,t,r,i,a,o,l;if(a=s,o=s,null!==(t=I()))for(e=[];null!==t;)e.push(t),t=I();else e=null;if(null!==e){for(t=[],l=s,r=[],i=b();null!==i;)r.push(i),i=b();for(null!==r&&null!==(i=I())?r=[r,i]:(r=null,s=l);null!==r;){for(t.push(r),l=s,r=[],i=b();null!==i;)r.push(i),i=b();null!==r&&null!==(i=I())?r=[r,i]:(r=null,s=l)}null!==t?e=[e,t]:(e=null,s=o)}else e=null,s=o;null!==e&&(u=a,e=n.substring(s,u));var u;return null===e&&(s=a),e}function I(){var e;return/^[!-~]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[!-~]")),null===e&&(e=k()),e}function k(){var e;return/^[\x80-\uFFFF]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[\\x80-\\uFFFF]")),e}function P(){var e;return/^[\x80-\xBF]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[\\x80-\\xBF]")),e}function O(){var e,t,r;if(r=s,null===(t=y())&&(45===n.charCodeAt(s)?(t="-",s++):(t=null,0===a&&u('"-"')),null===t&&(46===n.charCodeAt(s)?(t=".",s++):(t=null,0===a&&u('"."')),null===t&&(33===n.charCodeAt(s)?(t="!",s++):(t=null,0===a&&u('"!"')),null===t&&(37===n.charCodeAt(s)?(t="%",s++):(t=null,0===a&&u('"%"')),null===t&&(42===n.charCodeAt(s)?(t="*",s++):(t=null,0===a&&u('"*"')),null===t&&(95===n.charCodeAt(s)?(t="_",s++):(t=null,0===a&&u('"_"')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===a&&u('"+"')),null===t&&(96===n.charCodeAt(s)?(t="`",s++):(t=null,0===a&&u('"`"')),null===t&&(39===n.charCodeAt(s)?(t="'",s++):(t=null,0===a&&u('"\'"')),null===t&&(126===n.charCodeAt(s)?(t="~",s++):(t=null,0===a&&u('"~"')))))))))))),null!==t)for(e=[];null!==t;)e.push(t),null===(t=y())&&(45===n.charCodeAt(s)?(t="-",s++):(t=null,0===a&&u('"-"')),null===t&&(46===n.charCodeAt(s)?(t=".",s++):(t=null,0===a&&u('"."')),null===t&&(33===n.charCodeAt(s)?(t="!",s++):(t=null,0===a&&u('"!"')),null===t&&(37===n.charCodeAt(s)?(t="%",s++):(t=null,0===a&&u('"%"')),null===t&&(42===n.charCodeAt(s)?(t="*",s++):(t=null,0===a&&u('"*"')),null===t&&(95===n.charCodeAt(s)?(t="_",s++):(t=null,0===a&&u('"_"')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===a&&u('"+"')),null===t&&(96===n.charCodeAt(s)?(t="`",s++):(t=null,0===a&&u('"`"')),null===t&&(39===n.charCodeAt(s)?(t="'",s++):(t=null,0===a&&u('"\'"')),null===t&&(126===n.charCodeAt(s)?(t="~",s++):(t=null,0===a&&u('"~"'))))))))))));else e=null;null!==e&&(i=r,e=n.substring(s,i));var i;return null===e&&(s=r),e}function x(){var e,t,r;if(r=s,null===(t=y())&&(45===n.charCodeAt(s)?(t="-",s++):(t=null,0===a&&u('"-"')),null===t&&(33===n.charCodeAt(s)?(t="!",s++):(t=null,0===a&&u('"!"')),null===t&&(37===n.charCodeAt(s)?(t="%",s++):(t=null,0===a&&u('"%"')),null===t&&(42===n.charCodeAt(s)?(t="*",s++):(t=null,0===a&&u('"*"')),null===t&&(95===n.charCodeAt(s)?(t="_",s++):(t=null,0===a&&u('"_"')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===a&&u('"+"')),null===t&&(96===n.charCodeAt(s)?(t="`",s++):(t=null,0===a&&u('"`"')),null===t&&(39===n.charCodeAt(s)?(t="'",s++):(t=null,0===a&&u('"\'"')),null===t&&(126===n.charCodeAt(s)?(t="~",s++):(t=null,0===a&&u('"~"'))))))))))),null!==t)for(e=[];null!==t;)e.push(t),null===(t=y())&&(45===n.charCodeAt(s)?(t="-",s++):(t=null,0===a&&u('"-"')),null===t&&(33===n.charCodeAt(s)?(t="!",s++):(t=null,0===a&&u('"!"')),null===t&&(37===n.charCodeAt(s)?(t="%",s++):(t=null,0===a&&u('"%"')),null===t&&(42===n.charCodeAt(s)?(t="*",s++):(t=null,0===a&&u('"*"')),null===t&&(95===n.charCodeAt(s)?(t="_",s++):(t=null,0===a&&u('"_"')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===a&&u('"+"')),null===t&&(96===n.charCodeAt(s)?(t="`",s++):(t=null,0===a&&u('"`"')),null===t&&(39===n.charCodeAt(s)?(t="'",s++):(t=null,0===a&&u('"\'"')),null===t&&(126===n.charCodeAt(s)?(t="~",s++):(t=null,0===a&&u('"~"')))))))))));else e=null;null!==e&&(i=r,e=n.substring(s,i));var i;return null===e&&(s=r),e}function D(){var e,t,r;if(r=s,null===(t=y())&&(45===n.charCodeAt(s)?(t="-",s++):(t=null,0===a&&u('"-"')),null===t&&(46===n.charCodeAt(s)?(t=".",s++):(t=null,0===a&&u('"."')),null===t&&(33===n.charCodeAt(s)?(t="!",s++):(t=null,0===a&&u('"!"')),null===t&&(37===n.charCodeAt(s)?(t="%",s++):(t=null,0===a&&u('"%"')),null===t&&(42===n.charCodeAt(s)?(t="*",s++):(t=null,0===a&&u('"*"')),null===t&&(95===n.charCodeAt(s)?(t="_",s++):(t=null,0===a&&u('"_"')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===a&&u('"+"')),null===t&&(96===n.charCodeAt(s)?(t="`",s++):(t=null,0===a&&u('"`"')),null===t&&(39===n.charCodeAt(s)?(t="'",s++):(t=null,0===a&&u('"\'"')),null===t&&(126===n.charCodeAt(s)?(t="~",s++):(t=null,0===a&&u('"~"')),null===t&&(40===n.charCodeAt(s)?(t="(",s++):(t=null,0===a&&u('"("')),null===t&&(41===n.charCodeAt(s)?(t=")",s++):(t=null,0===a&&u('")"')),null===t&&(60===n.charCodeAt(s)?(t="<",s++):(t=null,0===a&&u('"<"')),null===t&&(62===n.charCodeAt(s)?(t=">",s++):(t=null,0===a&&u('">"')),null===t&&(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null===t&&(92===n.charCodeAt(s)?(t="\\",s++):(t=null,0===a&&u('"\\\\"')),null===t&&null===(t=v())&&(47===n.charCodeAt(s)?(t="/",s++):(t=null,0===a&&u('"/"')),null===t&&(91===n.charCodeAt(s)?(t="[",s++):(t=null,0===a&&u('"["')),null===t&&(93===n.charCodeAt(s)?(t="]",s++):(t=null,0===a&&u('"]"')),null===t&&(63===n.charCodeAt(s)?(t="?",s++):(t=null,0===a&&u('"?"')),null===t&&(123===n.charCodeAt(s)?(t="{",s++):(t=null,0===a&&u('"{"')),null===t&&(125===n.charCodeAt(s)?(t="}",s++):(t=null,0===a&&u('"}"')))))))))))))))))))))))),null!==t)for(e=[];null!==t;)e.push(t),null===(t=y())&&(45===n.charCodeAt(s)?(t="-",s++):(t=null,0===a&&u('"-"')),null===t&&(46===n.charCodeAt(s)?(t=".",s++):(t=null,0===a&&u('"."')),null===t&&(33===n.charCodeAt(s)?(t="!",s++):(t=null,0===a&&u('"!"')),null===t&&(37===n.charCodeAt(s)?(t="%",s++):(t=null,0===a&&u('"%"')),null===t&&(42===n.charCodeAt(s)?(t="*",s++):(t=null,0===a&&u('"*"')),null===t&&(95===n.charCodeAt(s)?(t="_",s++):(t=null,0===a&&u('"_"')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===a&&u('"+"')),null===t&&(96===n.charCodeAt(s)?(t="`",s++):(t=null,0===a&&u('"`"')),null===t&&(39===n.charCodeAt(s)?(t="'",s++):(t=null,0===a&&u('"\'"')),null===t&&(126===n.charCodeAt(s)?(t="~",s++):(t=null,0===a&&u('"~"')),null===t&&(40===n.charCodeAt(s)?(t="(",s++):(t=null,0===a&&u('"("')),null===t&&(41===n.charCodeAt(s)?(t=")",s++):(t=null,0===a&&u('")"')),null===t&&(60===n.charCodeAt(s)?(t="<",s++):(t=null,0===a&&u('"<"')),null===t&&(62===n.charCodeAt(s)?(t=">",s++):(t=null,0===a&&u('">"')),null===t&&(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null===t&&(92===n.charCodeAt(s)?(t="\\",s++):(t=null,0===a&&u('"\\\\"')),null===t&&null===(t=v())&&(47===n.charCodeAt(s)?(t="/",s++):(t=null,0===a&&u('"/"')),null===t&&(91===n.charCodeAt(s)?(t="[",s++):(t=null,0===a&&u('"["')),null===t&&(93===n.charCodeAt(s)?(t="]",s++):(t=null,0===a&&u('"]"')),null===t&&(63===n.charCodeAt(s)?(t="?",s++):(t=null,0===a&&u('"?"')),null===t&&(123===n.charCodeAt(s)?(t="{",s++):(t=null,0===a&&u('"{"')),null===t&&(125===n.charCodeAt(s)?(t="}",s++):(t=null,0===a&&u('"}"'))))))))))))))))))))))));else e=null;null!==e&&(i=r,e=n.substring(s,i));var i;return null===e&&(s=r),e}function N(){var e,t,r,i,o;return i=s,o=s,null!==(e=R())?(42===n.charCodeAt(s)?(t="*",s++):(t=null,0===a&&u('"*"')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(e="*"),null===e&&(s=i),e}function U(){var e,t,r,i,o;return i=s,o=s,null!==(e=R())?(47===n.charCodeAt(s)?(t="/",s++):(t=null,0===a&&u('"/"')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(e="/"),null===e&&(s=i),e}function M(){var e,t,r,i,o;return i=s,o=s,null!==(e=R())?(61===n.charCodeAt(s)?(t="=",s++):(t=null,0===a&&u('"="')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(e="="),null===e&&(s=i),e}function L(){var e,t,r,i,o;return i=s,o=s,null!==(e=R())?(40===n.charCodeAt(s)?(t="(",s++):(t=null,0===a&&u('"("')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(e="("),null===e&&(s=i),e}function q(){var e,t,r,i,o;return i=s,o=s,null!==(e=R())?(41===n.charCodeAt(s)?(t=")",s++):(t=null,0===a&&u('")"')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(e=")"),null===e&&(s=i),e}function H(){var e,t,r,i;return r=s,i=s,62===n.charCodeAt(s)?(e=">",s++):(e=null,0===a&&u('">"')),null!==e&&null!==(t=R())?e=[e,t]:(e=null,s=i),null!==e&&(e=">"),null===e&&(s=r),e}function F(){var e,t,r,i;return r=s,i=s,null!==(e=R())?(60===n.charCodeAt(s)?(t="<",s++):(t=null,0===a&&u('"<"')),null!==t?e=[e,t]:(e=null,s=i)):(e=null,s=i),null!==e&&(e="<"),null===e&&(s=r),e}function j(){var e,t,r,i,o;return i=s,o=s,null!==(e=R())?(44===n.charCodeAt(s)?(t=",",s++):(t=null,0===a&&u('","')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(e=","),null===e&&(s=i),e}function G(){var e,t,r,i,o;return i=s,o=s,null!==(e=R())?(59===n.charCodeAt(s)?(t=";",s++):(t=null,0===a&&u('";"')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(e=";"),null===e&&(s=i),e}function B(){var e,t,r,i,o;return i=s,o=s,null!==(e=R())?(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(r=R())?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(e=":"),null===e&&(s=i),e}function W(){var e,t,n,r;return n=s,r=s,null!==(e=R())&&null!==(t=v())?e=[e,t]:(e=null,s=r),null!==e&&(e='"'),null===e&&(s=n),e}function V(){var e,t,n,r;return n=s,r=s,null!==(e=v())&&null!==(t=R())?e=[e,t]:(e=null,s=r),null!==e&&(e='"'),null===e&&(s=n),e}function J(){var e;return/^[!-']/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[!-']")),null===e&&(/^[*-[]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[*-[]")),null===e&&(/^[\]-~]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[\\]-~]")),null===e&&null===(e=k())&&(e=b()))),e}function K(){var e,t,r,i,a,o;if(a=s,o=s,null!==(e=R()))if(null!==(t=v())){for(r=[],null===(i=Y())&&(i=$());null!==i;)r.push(i),null===(i=Y())&&(i=$());null!==r&&null!==(i=v())?e=[e,t,r,i]:(e=null,s=o)}else e=null,s=o;else e=null,s=o;null!==e&&(l=a,e=n.substring(s,l));var l;return null===e&&(s=a),e}function z(){var e,t,r,i,a,o;if(a=s,o=s,null!==(e=R()))if(null!==(t=v())){for(r=[],null===(i=Y())&&(i=$());null!==i;)r.push(i),null===(i=Y())&&(i=$());null!==r&&null!==(i=v())?e=[e,t,r,i]:(e=null,s=o)}else e=null,s=o;else e=null,s=o;null!==e&&(l=a,e=n.substring(s-1,l+1));var l;return null===e&&(s=a),e}function Y(){var e;return null===(e=b())&&(33===n.charCodeAt(s)?(e="!",s++):(e=null,0===a&&u('"!"')),null===e&&(/^[#-[]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[#-[]")),null===e&&(/^[\]-~]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[\\]-~]")),null===e&&(e=k())))),e}function $(){var e,t,r;return r=s,92===n.charCodeAt(s)?(e="\\",s++):(e=null,0===a&&u('"\\\\"')),null!==e?(/^[\0-\t]/.test(n.charAt(s))?(t=n.charAt(s),s++):(t=null,0===a&&u("[\\0-\\t]")),null===t&&(/^[\x0B-\f]/.test(n.charAt(s))?(t=n.charAt(s),s++):(t=null,0===a&&u("[\\x0B-\\f]")),null===t&&(/^[\x0E-]/.test(n.charAt(s))?(t=n.charAt(s),s++):(t=null,0===a&&u("[\\x0E-]")))),null!==t?e=[e,t]:(e=null,s=r)):(e=null,s=r),e}function Q(){var e,t,r,i,o,l;return o=s,l=s,null!==(e=Z())?(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(r=null!==(r=ne())?r:"")&&null!==(i=ae())?e=[e,t,r,i]:(e=null,s=l)):(e=null,s=l),null!==e&&(e=function(e){try{Fn.uri=new qn(Fn.scheme,Fn.user,Fn.host,Fn.port),delete Fn.scheme,delete Fn.user,delete Fn.host,delete Fn.host_type,delete Fn.port}catch(e){Fn=-1}}()),null===e&&(s=o),e}function X(){var e,t,i,o,l,c,d,h;return d=s,h=s,null!==(e=Z())?(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(i=null!==(i=ne())?i:"")&&null!==(o=ae())&&null!==(l=ge())&&null!==(c=null!==(c=Oe())?c:"")?e=[e,t,i,o,l,c]:(e=null,s=h)):(e=null,s=h),null!==e&&(e=function(e){try{Fn.uri=new qn(Fn.scheme,Fn.user,Fn.host,Fn.port,Fn.uri_params,Fn.uri_headers),delete Fn.scheme,delete Fn.user,delete Fn.host,delete Fn.host_type,delete Fn.port,delete Fn.uri_params,"SIP_URI"===r&&(Fn=Fn.uri)}catch(e){Fn=-1}}()),null===e&&(s=d),e}function Z(){var e;return null===(e=ee())&&(e=te()),e}function ee(){var e,t;t=s,"sips"===n.substr(s,4).toLowerCase()?(e=n.substr(s,4),s+=4):(e=null,0===a&&u('"sips"')),null!==e&&(r=e,e=void(Fn.scheme=r.toLowerCase()));var r;return null===e&&(s=t),e}function te(){var e,t;t=s,"sip"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===a&&u('"sip"')),null!==e&&(r=e,e=void(Fn.scheme=r.toLowerCase()));var r;return null===e&&(s=t),e}function ne(){var e,t,r,i,o,l;i=s,o=s,null!==(e=re())?(l=s,58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(r=se())?t=[t,r]:(t=null,s=l),null!==(t=null!==t?t:"")?(64===n.charCodeAt(s)?(r="@",s++):(r=null,0===a&&u('"@"')),null!==r?e=[e,t,r]:(e=null,s=o)):(e=null,s=o)):(e=null,s=o),null!==e&&(c=i,e=void(Fn.user=decodeURIComponent(n.substring(s-1,c))));var c;return null===e&&(s=i),e}function re(){var e,t;if(null===(t=C())&&null===(t=E())&&(t=ie()),null!==t)for(e=[];null!==t;)e.push(t),null===(t=C())&&null===(t=E())&&(t=ie());else e=null;return e}function ie(){var e;return 38===n.charCodeAt(s)?(e="&",s++):(e=null,0===a&&u('"&"')),null===e&&(61===n.charCodeAt(s)?(e="=",s++):(e=null,0===a&&u('"="')),null===e&&(43===n.charCodeAt(s)?(e="+",s++):(e=null,0===a&&u('"+"')),null===e&&(36===n.charCodeAt(s)?(e="$",s++):(e=null,0===a&&u('"$"')),null===e&&(44===n.charCodeAt(s)?(e=",",s++):(e=null,0===a&&u('","')),null===e&&(59===n.charCodeAt(s)?(e=";",s++):(e=null,0===a&&u('";"')),null===e&&(63===n.charCodeAt(s)?(e="?",s++):(e=null,0===a&&u('"?"')),null===e&&(47===n.charCodeAt(s)?(e="/",s++):(e=null,0===a&&u('"/"'))))))))),e}function se(){var e,t,r;for(r=s,e=[],null===(t=C())&&null===(t=E())&&(38===n.charCodeAt(s)?(t="&",s++):(t=null,0===a&&u('"&"')),null===t&&(61===n.charCodeAt(s)?(t="=",s++):(t=null,0===a&&u('"="')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===a&&u('"+"')),null===t&&(36===n.charCodeAt(s)?(t="$",s++):(t=null,0===a&&u('"$"')),null===t&&(44===n.charCodeAt(s)?(t=",",s++):(t=null,0===a&&u('","')))))));null!==t;)e.push(t),null===(t=C())&&null===(t=E())&&(38===n.charCodeAt(s)?(t="&",s++):(t=null,0===a&&u('"&"')),null===t&&(61===n.charCodeAt(s)?(t="=",s++):(t=null,0===a&&u('"="')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===a&&u('"+"')),null===t&&(36===n.charCodeAt(s)?(t="$",s++):(t=null,0===a&&u('"$"')),null===t&&(44===n.charCodeAt(s)?(t=",",s++):(t=null,0===a&&u('","')))))));null!==e&&(i=r,e=void(Fn.password=n.substring(s,i)));var i;return null===e&&(s=r),e}function ae(){var e,t,r,i,o;return i=s,null!==(e=oe())?(o=s,58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(r=me())?t=[t,r]:(t=null,s=o),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=i)):(e=null,s=i),e}function oe(){var e,t;t=s,null===(e=le())&&null===(e=_e())&&(e=de()),null!==e&&(r=t,Fn.host=n.substring(s,r).toLowerCase(),e=Fn.host);var r;return null===e&&(s=t),e}function le(){var e,t,r,i,o,l;for(i=s,o=s,e=[],l=s,null!==(t=ue())?(46===n.charCodeAt(s)?(r=".",s++):(r=null,0===a&&u('"."')),null!==r?t=[t,r]:(t=null,s=l)):(t=null,s=l);null!==t;)e.push(t),l=s,null!==(t=ue())?(46===n.charCodeAt(s)?(r=".",s++):(r=null,0===a&&u('"."')),null!==r?t=[t,r]:(t=null,s=l)):(t=null,s=l);null!==e&&null!==(t=ce())?(46===n.charCodeAt(s)?(r=".",s++):(r=null,0===a&&u('"."')),null!==(r=null!==r?r:"")?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(c=i,Fn.host_type="domain",e=n.substring(s,c));var c;return null===e&&(s=i),e}function ue(){var e,t,r,i;if(i=s,null!==(e=y())){for(t=[],null===(r=y())&&(45===n.charCodeAt(s)?(r="-",s++):(r=null,0===a&&u('"-"')),null===r&&(95===n.charCodeAt(s)?(r="_",s++):(r=null,0===a&&u('"_"'))));null!==r;)t.push(r),null===(r=y())&&(45===n.charCodeAt(s)?(r="-",s++):(r=null,0===a&&u('"-"')),null===r&&(95===n.charCodeAt(s)?(r="_",s++):(r=null,0===a&&u('"_"'))));null!==t?e=[e,t]:(e=null,s=i)}else e=null,s=i;return e}function ce(){var e,t,r,i;if(i=s,null!==(e=h())){for(t=[],null===(r=y())&&(45===n.charCodeAt(s)?(r="-",s++):(r=null,0===a&&u('"-"')),null===r&&(95===n.charCodeAt(s)?(r="_",s++):(r=null,0===a&&u('"_"'))));null!==r;)t.push(r),null===(r=y())&&(45===n.charCodeAt(s)?(r="-",s++):(r=null,0===a&&u('"-"')),null===r&&(95===n.charCodeAt(s)?(r="_",s++):(r=null,0===a&&u('"_"'))));null!==t?e=[e,t]:(e=null,s=i)}else e=null,s=i;return e}function de(){var e,t,r,i,o;i=s,o=s,91===n.charCodeAt(s)?(e="[",s++):(e=null,0===a&&u('"["')),null!==e&&null!==(t=he())?(93===n.charCodeAt(s)?(r="]",s++):(r=null,0===a&&u('"]"')),null!==r?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(l=i,Fn.host_type="IPv6",e=n.substring(s,l));var l;return null===e&&(s=i),e}function he(){var e,t,r,i,o,l,c,d,h,f,p,_,v,m,g,y;m=s,g=s,null!==(e=fe())?(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(r=fe())?(58===n.charCodeAt(s)?(i=":",s++):(i=null,0===a&&u('":"')),null!==i&&null!==(o=fe())?(58===n.charCodeAt(s)?(l=":",s++):(l=null,0===a&&u('":"')),null!==l&&null!==(c=fe())?(58===n.charCodeAt(s)?(d=":",s++):(d=null,0===a&&u('":"')),null!==d&&null!==(h=fe())?(58===n.charCodeAt(s)?(f=":",s++):(f=null,0===a&&u('":"')),null!==f&&null!==(p=fe())?(58===n.charCodeAt(s)?(_=":",s++):(_=null,0===a&&u('":"')),null!==_&&null!==(v=pe())?e=[e,t,r,i,o,l,c,d,h,f,p,_,v]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,"::"===n.substr(s,2)?(e="::",s+=2):(e=null,0===a&&u('"::"')),null!==e&&null!==(t=fe())?(58===n.charCodeAt(s)?(r=":",s++):(r=null,0===a&&u('":"')),null!==r&&null!==(i=fe())?(58===n.charCodeAt(s)?(o=":",s++):(o=null,0===a&&u('":"')),null!==o&&null!==(l=fe())?(58===n.charCodeAt(s)?(c=":",s++):(c=null,0===a&&u('":"')),null!==c&&null!==(d=fe())?(58===n.charCodeAt(s)?(h=":",s++):(h=null,0===a&&u('":"')),null!==h&&null!==(f=fe())?(58===n.charCodeAt(s)?(p=":",s++):(p=null,0===a&&u('":"')),null!==p&&null!==(_=pe())?e=[e,t,r,i,o,l,c,d,h,f,p,_]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,"::"===n.substr(s,2)?(e="::",s+=2):(e=null,0===a&&u('"::"')),null!==e&&null!==(t=fe())?(58===n.charCodeAt(s)?(r=":",s++):(r=null,0===a&&u('":"')),null!==r&&null!==(i=fe())?(58===n.charCodeAt(s)?(o=":",s++):(o=null,0===a&&u('":"')),null!==o&&null!==(l=fe())?(58===n.charCodeAt(s)?(c=":",s++):(c=null,0===a&&u('":"')),null!==c&&null!==(d=fe())?(58===n.charCodeAt(s)?(h=":",s++):(h=null,0===a&&u('":"')),null!==h&&null!==(f=pe())?e=[e,t,r,i,o,l,c,d,h,f]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,"::"===n.substr(s,2)?(e="::",s+=2):(e=null,0===a&&u('"::"')),null!==e&&null!==(t=fe())?(58===n.charCodeAt(s)?(r=":",s++):(r=null,0===a&&u('":"')),null!==r&&null!==(i=fe())?(58===n.charCodeAt(s)?(o=":",s++):(o=null,0===a&&u('":"')),null!==o&&null!==(l=fe())?(58===n.charCodeAt(s)?(c=":",s++):(c=null,0===a&&u('":"')),null!==c&&null!==(d=pe())?e=[e,t,r,i,o,l,c,d]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,"::"===n.substr(s,2)?(e="::",s+=2):(e=null,0===a&&u('"::"')),null!==e&&null!==(t=fe())?(58===n.charCodeAt(s)?(r=":",s++):(r=null,0===a&&u('":"')),null!==r&&null!==(i=fe())?(58===n.charCodeAt(s)?(o=":",s++):(o=null,0===a&&u('":"')),null!==o&&null!==(l=pe())?e=[e,t,r,i,o,l]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,"::"===n.substr(s,2)?(e="::",s+=2):(e=null,0===a&&u('"::"')),null!==e&&null!==(t=fe())?(58===n.charCodeAt(s)?(r=":",s++):(r=null,0===a&&u('":"')),null!==r&&null!==(i=pe())?e=[e,t,r,i]:(e=null,s=g)):(e=null,s=g),null===e&&(g=s,"::"===n.substr(s,2)?(e="::",s+=2):(e=null,0===a&&u('"::"')),null!==e&&null!==(t=pe())?e=[e,t]:(e=null,s=g),null===e&&(g=s,"::"===n.substr(s,2)?(e="::",s+=2):(e=null,0===a&&u('"::"')),null!==e&&null!==(t=fe())?e=[e,t]:(e=null,s=g),null===e&&(g=s,null!==(e=fe())?("::"===n.substr(s,2)?(t="::",s+=2):(t=null,0===a&&u('"::"')),null!==t&&null!==(r=fe())?(58===n.charCodeAt(s)?(i=":",s++):(i=null,0===a&&u('":"')),null!==i&&null!==(o=fe())?(58===n.charCodeAt(s)?(l=":",s++):(l=null,0===a&&u('":"')),null!==l&&null!==(c=fe())?(58===n.charCodeAt(s)?(d=":",s++):(d=null,0===a&&u('":"')),null!==d&&null!==(h=fe())?(58===n.charCodeAt(s)?(f=":",s++):(f=null,0===a&&u('":"')),null!==f&&null!==(p=pe())?e=[e,t,r,i,o,l,c,d,h,f,p]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,null!==(e=fe())?(y=s,58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(r=fe())?t=[t,r]:(t=null,s=y),null!==(t=null!==t?t:"")?("::"===n.substr(s,2)?(r="::",s+=2):(r=null,0===a&&u('"::"')),null!==r&&null!==(i=fe())?(58===n.charCodeAt(s)?(o=":",s++):(o=null,0===a&&u('":"')),null!==o&&null!==(l=fe())?(58===n.charCodeAt(s)?(c=":",s++):(c=null,0===a&&u('":"')),null!==c&&null!==(d=fe())?(58===n.charCodeAt(s)?(h=":",s++):(h=null,0===a&&u('":"')),null!==h&&null!==(f=pe())?e=[e,t,r,i,o,l,c,d,h,f]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,null!==(e=fe())?(y=s,58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(r=fe())?t=[t,r]:(t=null,s=y),null!==(t=null!==t?t:"")?(y=s,58===n.charCodeAt(s)?(r=":",s++):(r=null,0===a&&u('":"')),null!==r&&null!==(i=fe())?r=[r,i]:(r=null,s=y),null!==(r=null!==r?r:"")?("::"===n.substr(s,2)?(i="::",s+=2):(i=null,0===a&&u('"::"')),null!==i&&null!==(o=fe())?(58===n.charCodeAt(s)?(l=":",s++):(l=null,0===a&&u('":"')),null!==l&&null!==(c=fe())?(58===n.charCodeAt(s)?(d=":",s++):(d=null,0===a&&u('":"')),null!==d&&null!==(h=pe())?e=[e,t,r,i,o,l,c,d,h]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,null!==(e=fe())?(y=s,58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(r=fe())?t=[t,r]:(t=null,s=y),null!==(t=null!==t?t:"")?(y=s,58===n.charCodeAt(s)?(r=":",s++):(r=null,0===a&&u('":"')),null!==r&&null!==(i=fe())?r=[r,i]:(r=null,s=y),null!==(r=null!==r?r:"")?(y=s,58===n.charCodeAt(s)?(i=":",s++):(i=null,0===a&&u('":"')),null!==i&&null!==(o=fe())?i=[i,o]:(i=null,s=y),null!==(i=null!==i?i:"")?("::"===n.substr(s,2)?(o="::",s+=2):(o=null,0===a&&u('"::"')),null!==o&&null!==(l=fe())?(58===n.charCodeAt(s)?(c=":",s++):(c=null,0===a&&u('":"')),null!==c&&null!==(d=pe())?e=[e,t,r,i,o,l,c,d]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,null!==(e=fe())?(y=s,58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(r=fe())?t=[t,r]:(t=null,s=y),null!==(t=null!==t?t:"")?(y=s,58===n.charCodeAt(s)?(r=":",s++):(r=null,0===a&&u('":"')),null!==r&&null!==(i=fe())?r=[r,i]:(r=null,s=y),null!==(r=null!==r?r:"")?(y=s,58===n.charCodeAt(s)?(i=":",s++):(i=null,0===a&&u('":"')),null!==i&&null!==(o=fe())?i=[i,o]:(i=null,s=y),null!==(i=null!==i?i:"")?(y=s,58===n.charCodeAt(s)?(o=":",s++):(o=null,0===a&&u('":"')),null!==o&&null!==(l=fe())?o=[o,l]:(o=null,s=y),null!==(o=null!==o?o:"")?("::"===n.substr(s,2)?(l="::",s+=2):(l=null,0===a&&u('"::"')),null!==l&&null!==(c=pe())?e=[e,t,r,i,o,l,c]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,null!==(e=fe())?(y=s,58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(r=fe())?t=[t,r]:(t=null,s=y),null!==(t=null!==t?t:"")?(y=s,58===n.charCodeAt(s)?(r=":",s++):(r=null,0===a&&u('":"')),null!==r&&null!==(i=fe())?r=[r,i]:(r=null,s=y),null!==(r=null!==r?r:"")?(y=s,58===n.charCodeAt(s)?(i=":",s++):(i=null,0===a&&u('":"')),null!==i&&null!==(o=fe())?i=[i,o]:(i=null,s=y),null!==(i=null!==i?i:"")?(y=s,58===n.charCodeAt(s)?(o=":",s++):(o=null,0===a&&u('":"')),null!==o&&null!==(l=fe())?o=[o,l]:(o=null,s=y),null!==(o=null!==o?o:"")?(y=s,58===n.charCodeAt(s)?(l=":",s++):(l=null,0===a&&u('":"')),null!==l&&null!==(c=fe())?l=[l,c]:(l=null,s=y),null!==(l=null!==l?l:"")?("::"===n.substr(s,2)?(c="::",s+=2):(c=null,0===a&&u('"::"')),null!==c&&null!==(d=fe())?e=[e,t,r,i,o,l,c,d]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g),null===e&&(g=s,null!==(e=fe())?(y=s,58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(r=fe())?t=[t,r]:(t=null,s=y),null!==(t=null!==t?t:"")?(y=s,58===n.charCodeAt(s)?(r=":",s++):(r=null,0===a&&u('":"')),null!==r&&null!==(i=fe())?r=[r,i]:(r=null,s=y),null!==(r=null!==r?r:"")?(y=s,58===n.charCodeAt(s)?(i=":",s++):(i=null,0===a&&u('":"')),null!==i&&null!==(o=fe())?i=[i,o]:(i=null,s=y),null!==(i=null!==i?i:"")?(y=s,58===n.charCodeAt(s)?(o=":",s++):(o=null,0===a&&u('":"')),null!==o&&null!==(l=fe())?o=[o,l]:(o=null,s=y),null!==(o=null!==o?o:"")?(y=s,58===n.charCodeAt(s)?(l=":",s++):(l=null,0===a&&u('":"')),null!==l&&null!==(c=fe())?l=[l,c]:(l=null,s=y),null!==(l=null!==l?l:"")?(y=s,58===n.charCodeAt(s)?(c=":",s++):(c=null,0===a&&u('":"')),null!==c&&null!==(d=fe())?c=[c,d]:(c=null,s=y),null!==(c=null!==c?c:"")?("::"===n.substr(s,2)?(d="::",s+=2):(d=null,0===a&&u('"::"')),null!==d?e=[e,t,r,i,o,l,c,d]:(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g)):(e=null,s=g))))))))))))))),null!==e&&(T=m,Fn.host_type="IPv6",e=n.substring(s,T));var T;return null===e&&(s=m),e}function fe(){var e,t,n,r,i;return i=s,null!==(e=f())&&null!==(t=null!==(t=f())?t:"")&&null!==(n=null!==(n=f())?n:"")&&null!==(r=null!==(r=f())?r:"")?e=[e,t,n,r]:(e=null,s=i),e}function pe(){var e,t,r,i;return i=s,null!==(e=fe())?(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t&&null!==(r=fe())?e=[e,t,r]:(e=null,s=i)):(e=null,s=i),null===e&&(e=_e()),e}function _e(){var e,t,r,i,o,l,c,d,h;d=s,h=s,null!==(e=ve())?(46===n.charCodeAt(s)?(t=".",s++):(t=null,0===a&&u('"."')),null!==t&&null!==(r=ve())?(46===n.charCodeAt(s)?(i=".",s++):(i=null,0===a&&u('"."')),null!==i&&null!==(o=ve())?(46===n.charCodeAt(s)?(l=".",s++):(l=null,0===a&&u('"."')),null!==l&&null!==(c=ve())?e=[e,t,r,i,o,l,c]:(e=null,s=h)):(e=null,s=h)):(e=null,s=h)):(e=null,s=h),null!==e&&(f=d,Fn.host_type="IPv4",e=n.substring(s,f));var f;return null===e&&(s=d),e}function ve(){var e,t,r,i;return i=s,"25"===n.substr(s,2)?(e="25",s+=2):(e=null,0===a&&u('"25"')),null!==e?(/^[0-5]/.test(n.charAt(s))?(t=n.charAt(s),s++):(t=null,0===a&&u("[0-5]")),null!==t?e=[e,t]:(e=null,s=i)):(e=null,s=i),null===e&&(i=s,50===n.charCodeAt(s)?(e="2",s++):(e=null,0===a&&u('"2"')),null!==e?(/^[0-4]/.test(n.charAt(s))?(t=n.charAt(s),s++):(t=null,0===a&&u("[0-4]")),null!==t&&null!==(r=d())?e=[e,t,r]:(e=null,s=i)):(e=null,s=i),null===e&&(i=s,49===n.charCodeAt(s)?(e="1",s++):(e=null,0===a&&u('"1"')),null!==e&&null!==(t=d())&&null!==(r=d())?e=[e,t,r]:(e=null,s=i),null===e&&(i=s,/^[1-9]/.test(n.charAt(s))?(e=n.charAt(s),s++):(e=null,0===a&&u("[1-9]")),null!==e&&null!==(t=d())?e=[e,t]:(e=null,s=i),null===e&&(e=d())))),e}function me(){var e,t,n,r,i,a,o;a=s,o=s,null!==(e=null!==(e=d())?e:"")&&null!==(t=null!==(t=d())?t:"")&&null!==(n=null!==(n=d())?n:"")&&null!==(r=null!==(r=d())?r:"")&&null!==(i=null!==(i=d())?i:"")?e=[e,t,n,r,i]:(e=null,s=o),null!==e&&(l=e,l=parseInt(l.join("")),Fn.port=l,e=l);var l;return null===e&&(s=a),e}function ge(){var e,t,r,i;for(e=[],i=s,59===n.charCodeAt(s)?(t=";",s++):(t=null,0===a&&u('";"')),null!==t&&null!==(r=ye())?t=[t,r]:(t=null,s=i);null!==t;)e.push(t),i=s,59===n.charCodeAt(s)?(t=";",s++):(t=null,0===a&&u('";"')),null!==t&&null!==(r=ye())?t=[t,r]:(t=null,s=i);return e}function ye(){var e;return null===(e=Te())&&null===(e=Ce())&&null===(e=Se())&&null===(e=Ee())&&null===(e=be())&&null===(e=Re())&&(e=Ae()),e}function Te(){var e,t,r,i;r=s,i=s,"transport="===n.substr(s,10).toLowerCase()?(e=n.substr(s,10),s+=10):(e=null,0===a&&u('"transport="')),null!==e?("udp"===n.substr(s,3).toLowerCase()?(t=n.substr(s,3),s+=3):(t=null,0===a&&u('"udp"')),null===t&&("tcp"===n.substr(s,3).toLowerCase()?(t=n.substr(s,3),s+=3):(t=null,0===a&&u('"tcp"')),null===t&&("sctp"===n.substr(s,4).toLowerCase()?(t=n.substr(s,4),s+=4):(t=null,0===a&&u('"sctp"')),null===t&&("tls"===n.substr(s,3).toLowerCase()?(t=n.substr(s,3),s+=3):(t=null,0===a&&u('"tls"')),null===t&&(t=O())))),null!==t?e=[e,t]:(e=null,s=i)):(e=null,s=i),null!==e&&(o=e[1],Fn.uri_params||(Fn.uri_params={}),e=void(Fn.uri_params.transport=o.toLowerCase()));var o;return null===e&&(s=r),e}function Ce(){var e,t,r,i;r=s,i=s,"user="===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===a&&u('"user="')),null!==e?("phone"===n.substr(s,5).toLowerCase()?(t=n.substr(s,5),s+=5):(t=null,0===a&&u('"phone"')),null===t&&("ip"===n.substr(s,2).toLowerCase()?(t=n.substr(s,2),s+=2):(t=null,0===a&&u('"ip"')),null===t&&(t=O())),null!==t?e=[e,t]:(e=null,s=i)):(e=null,s=i),null!==e&&(o=e[1],Fn.uri_params||(Fn.uri_params={}),e=void(Fn.uri_params.user=o.toLowerCase()));var o;return null===e&&(s=r),e}function Se(){var e,t,r,i;r=s,i=s,"method="===n.substr(s,7).toLowerCase()?(e=n.substr(s,7),s+=7):(e=null,0===a&&u('"method="')),null!==e&&null!==(t=ct())?e=[e,t]:(e=null,s=i),null!==e&&(o=e[1],Fn.uri_params||(Fn.uri_params={}),e=void(Fn.uri_params.method=o));var o;return null===e&&(s=r),e}function Ee(){var e,t,r,i;r=s,i=s,"ttl="===n.substr(s,4).toLowerCase()?(e=n.substr(s,4),s+=4):(e=null,0===a&&u('"ttl="')),null!==e&&null!==(t=bn())?e=[e,t]:(e=null,s=i),null!==e&&(o=e[1],Fn.params||(Fn.params={}),e=void(Fn.params.ttl=o));var o;return null===e&&(s=r),e}function be(){var e,t,r,i;r=s,i=s,"maddr="===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===a&&u('"maddr="')),null!==e&&null!==(t=oe())?e=[e,t]:(e=null,s=i),null!==e&&(o=e[1],Fn.uri_params||(Fn.uri_params={}),e=void(Fn.uri_params.maddr=o));var o;return null===e&&(s=r),e}function Re(){var e,t,r,i,o,l;return i=s,o=s,"lr"===n.substr(s,2).toLowerCase()?(e=n.substr(s,2),s+=2):(e=null,0===a&&u('"lr"')),null!==e?(l=s,61===n.charCodeAt(s)?(t="=",s++):(t=null,0===a&&u('"="')),null!==t&&null!==(r=O())?t=[t,r]:(t=null,s=l),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=o)):(e=null,s=o),null!==e&&(Fn.uri_params||(Fn.uri_params={}),e=void(Fn.uri_params.lr=void 0)),null===e&&(s=i),e}function Ae(){var e,t,r,i,o,l;i=s,o=s,null!==(e=we())?(l=s,61===n.charCodeAt(s)?(t="=",s++):(t=null,0===a&&u('"="')),null!==t&&null!==(r=Ie())?t=[t,r]:(t=null,s=l),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=o)):(e=null,s=o),null!==e&&(c=e[0],d=e[1],Fn.uri_params||(Fn.uri_params={}),d=void 0===d?void 0:d[1],e=void(Fn.uri_params[c.toLowerCase()]=d));var c,d;return null===e&&(s=i),e}function we(){var e,t,n;if(n=s,null!==(t=ke()))for(e=[];null!==t;)e.push(t),t=ke();else e=null;return null!==e&&(e=e.join("")),null===e&&(s=n),e}function Ie(){var e,t,n;if(n=s,null!==(t=ke()))for(e=[];null!==t;)e.push(t),t=ke();else e=null;return null!==e&&(e=e.join("")),null===e&&(s=n),e}function ke(){var e;return null===(e=Pe())&&null===(e=C())&&(e=E()),e}function Pe(){var e;return 91===n.charCodeAt(s)?(e="[",s++):(e=null,0===a&&u('"["')),null===e&&(93===n.charCodeAt(s)?(e="]",s++):(e=null,0===a&&u('"]"')),null===e&&(47===n.charCodeAt(s)?(e="/",s++):(e=null,0===a&&u('"/"')),null===e&&(58===n.charCodeAt(s)?(e=":",s++):(e=null,0===a&&u('":"')),null===e&&(38===n.charCodeAt(s)?(e="&",s++):(e=null,0===a&&u('"&"')),null===e&&(43===n.charCodeAt(s)?(e="+",s++):(e=null,0===a&&u('"+"')),null===e&&(36===n.charCodeAt(s)?(e="$",s++):(e=null,0===a&&u('"$"')))))))),e}function Oe(){var e,t,r,i,o,l,c;if(l=s,63===n.charCodeAt(s)?(e="?",s++):(e=null,0===a&&u('"?"')),null!==e)if(null!==(t=xe())){for(r=[],c=s,38===n.charCodeAt(s)?(i="&",s++):(i=null,0===a&&u('"&"')),null!==i&&null!==(o=xe())?i=[i,o]:(i=null,s=c);null!==i;)r.push(i),c=s,38===n.charCodeAt(s)?(i="&",s++):(i=null,0===a&&u('"&"')),null!==i&&null!==(o=xe())?i=[i,o]:(i=null,s=c);null!==r?e=[e,t,r]:(e=null,s=l)}else e=null,s=l;else e=null,s=l;return e}function xe(){var e,t,r,i,o;i=s,o=s,null!==(e=De())?(61===n.charCodeAt(s)?(t="=",s++):(t=null,0===a&&u('"="')),null!==t&&null!==(r=Ne())?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(l=e[0],c=e[2],l=l.join("").toLowerCase(),c=c.join(""),Fn.uri_headers||(Fn.uri_headers={}),e=void(Fn.uri_headers[l]?Fn.uri_headers[l].push(c):Fn.uri_headers[l]=[c]));var l,c;return null===e&&(s=i),e}function De(){var e,t;if(null===(t=Ue())&&null===(t=C())&&(t=E()),null!==t)for(e=[];null!==t;)e.push(t),null===(t=Ue())&&null===(t=C())&&(t=E());else e=null;return e}function Ne(){var e,t;for(e=[],null===(t=Ue())&&null===(t=C())&&(t=E());null!==t;)e.push(t),null===(t=Ue())&&null===(t=C())&&(t=E());return e}function Ue(){var e;return 91===n.charCodeAt(s)?(e="[",s++):(e=null,0===a&&u('"["')),null===e&&(93===n.charCodeAt(s)?(e="]",s++):(e=null,0===a&&u('"]"')),null===e&&(47===n.charCodeAt(s)?(e="/",s++):(e=null,0===a&&u('"/"')),null===e&&(63===n.charCodeAt(s)?(e="?",s++):(e=null,0===a&&u('"?"')),null===e&&(58===n.charCodeAt(s)?(e=":",s++):(e=null,0===a&&u('":"')),null===e&&(43===n.charCodeAt(s)?(e="+",s++):(e=null,0===a&&u('"+"')),null===e&&(36===n.charCodeAt(s)?(e="$",s++):(e=null,0===a&&u('"$"')))))))),e}function Me(){var e,t,n,r,i,a;return a=s,null!==(e=ct())&&null!==(t=m())&&null!==(n=Le())&&null!==(r=m())&&null!==(i=et())?e=[e,t,n,r,i]:(e=null,s=a),e}function Le(){var e;return null===(e=X())&&(e=qe()),e}function qe(){var e,t,r,i;return i=s,null!==(e=Ye())?(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null!==t?(null===(r=He())&&(r=Ge()),null!==r?e=[e,t,r]:(e=null,s=i)):(e=null,s=i)):(e=null,s=i),e}function He(){var e,t,r,i,o;return i=s,null===(e=Fe())&&(e=je()),null!==e?(o=s,63===n.charCodeAt(s)?(t="?",s++):(t=null,0===a&&u('"?"')),null!==t&&null!==(r=Ze())?t=[t,r]:(t=null,s=o),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=i)):(e=null,s=i),e}function Fe(){var e,t,r,i;return i=s,"//"===n.substr(s,2)?(e="//",s+=2):(e=null,0===a&&u('"//"')),null!==e&&null!==(t=$e())&&null!==(r=null!==(r=je())?r:"")?e=[e,t,r]:(e=null,s=i),e}function je(){var e,t,r;return r=s,47===n.charCodeAt(s)?(e="/",s++):(e=null,0===a&&u('"/"')),null!==e&&null!==(t=Ve())?e=[e,t]:(e=null,s=r),e}function Ge(){var e,t,n,r;if(r=s,null!==(e=We())){for(t=[],n=Be();null!==n;)t.push(n),n=Be();null!==t?e=[e,t]:(e=null,s=r)}else e=null,s=r;return e}function Be(){var e;return null===(e=T())&&null===(e=C())&&(e=E()),e}function We(){var e;return null===(e=C())&&null===(e=E())&&(59===n.charCodeAt(s)?(e=";",s++):(e=null,0===a&&u('";"')),null===e&&(63===n.charCodeAt(s)?(e="?",s++):(e=null,0===a&&u('"?"')),null===e&&(58===n.charCodeAt(s)?(e=":",s++):(e=null,0===a&&u('":"')),null===e&&(64===n.charCodeAt(s)?(e="@",s++):(e=null,0===a&&u('"@"')),null===e&&(38===n.charCodeAt(s)?(e="&",s++):(e=null,0===a&&u('"&"')),null===e&&(61===n.charCodeAt(s)?(e="=",s++):(e=null,0===a&&u('"="')),null===e&&(43===n.charCodeAt(s)?(e="+",s++):(e=null,0===a&&u('"+"')),null===e&&(36===n.charCodeAt(s)?(e="$",s++):(e=null,0===a&&u('"$"')),null===e&&(44===n.charCodeAt(s)?(e=",",s++):(e=null,0===a&&u('","'))))))))))),e}function Ve(){var e,t,r,i,o,l;if(o=s,null!==(e=Je())){for(t=[],l=s,47===n.charCodeAt(s)?(r="/",s++):(r=null,0===a&&u('"/"')),null!==r&&null!==(i=Je())?r=[r,i]:(r=null,s=l);null!==r;)t.push(r),l=s,47===n.charCodeAt(s)?(r="/",s++):(r=null,0===a&&u('"/"')),null!==r&&null!==(i=Je())?r=[r,i]:(r=null,s=l);null!==t?e=[e,t]:(e=null,s=o)}else e=null,s=o;return e}function Je(){var e,t,r,i,o,l;for(o=s,e=[],t=ze();null!==t;)e.push(t),t=ze();if(null!==e){for(t=[],l=s,59===n.charCodeAt(s)?(r=";",s++):(r=null,0===a&&u('";"')),null!==r&&null!==(i=Ke())?r=[r,i]:(r=null,s=l);null!==r;)t.push(r),l=s,59===n.charCodeAt(s)?(r=";",s++):(r=null,0===a&&u('";"')),null!==r&&null!==(i=Ke())?r=[r,i]:(r=null,s=l);null!==t?e=[e,t]:(e=null,s=o)}else e=null,s=o;return e}function Ke(){var e,t;for(e=[],t=ze();null!==t;)e.push(t),t=ze();return e}function ze(){var e;return null===(e=C())&&null===(e=E())&&(58===n.charCodeAt(s)?(e=":",s++):(e=null,0===a&&u('":"')),null===e&&(64===n.charCodeAt(s)?(e="@",s++):(e=null,0===a&&u('"@"')),null===e&&(38===n.charCodeAt(s)?(e="&",s++):(e=null,0===a&&u('"&"')),null===e&&(61===n.charCodeAt(s)?(e="=",s++):(e=null,0===a&&u('"="')),null===e&&(43===n.charCodeAt(s)?(e="+",s++):(e=null,0===a&&u('"+"')),null===e&&(36===n.charCodeAt(s)?(e="$",s++):(e=null,0===a&&u('"$"')),null===e&&(44===n.charCodeAt(s)?(e=",",s++):(e=null,0===a&&u('","'))))))))),e}function Ye(){var e,t,r,i,o;if(i=s,o=s,null!==(e=h())){for(t=[],null===(r=h())&&null===(r=d())&&(43===n.charCodeAt(s)?(r="+",s++):(r=null,0===a&&u('"+"')),null===r&&(45===n.charCodeAt(s)?(r="-",s++):(r=null,0===a&&u('"-"')),null===r&&(46===n.charCodeAt(s)?(r=".",s++):(r=null,0===a&&u('"."')))));null!==r;)t.push(r),null===(r=h())&&null===(r=d())&&(43===n.charCodeAt(s)?(r="+",s++):(r=null,0===a&&u('"+"')),null===r&&(45===n.charCodeAt(s)?(r="-",s++):(r=null,0===a&&u('"-"')),null===r&&(46===n.charCodeAt(s)?(r=".",s++):(r=null,0===a&&u('"."')))));null!==t?e=[e,t]:(e=null,s=o)}else e=null,s=o;null!==e&&(l=i,e=void(Fn.scheme=n.substring(s,l)));var l;return null===e&&(s=i),e}function $e(){var e;return null===(e=Qe())&&(e=Xe()),e}function Qe(){var e,t,r,i;return r=s,i=s,null!==(e=ne())?(64===n.charCodeAt(s)?(t="@",s++):(t=null,0===a&&u('"@"')),null!==t?e=[e,t]:(e=null,s=i)):(e=null,s=i),null!==(e=null!==e?e:"")&&null!==(t=ae())?e=[e,t]:(e=null,s=r),e=null!==e?e:""}function Xe(){var e,t;if(null===(t=C())&&null===(t=E())&&(36===n.charCodeAt(s)?(t="$",s++):(t=null,0===a&&u('"$"')),null===t&&(44===n.charCodeAt(s)?(t=",",s++):(t=null,0===a&&u('","')),null===t&&(59===n.charCodeAt(s)?(t=";",s++):(t=null,0===a&&u('";"')),null===t&&(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null===t&&(64===n.charCodeAt(s)?(t="@",s++):(t=null,0===a&&u('"@"')),null===t&&(38===n.charCodeAt(s)?(t="&",s++):(t=null,0===a&&u('"&"')),null===t&&(61===n.charCodeAt(s)?(t="=",s++):(t=null,0===a&&u('"="')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===a&&u('"+"')))))))))),null!==t)for(e=[];null!==t;)e.push(t),null===(t=C())&&null===(t=E())&&(36===n.charCodeAt(s)?(t="$",s++):(t=null,0===a&&u('"$"')),null===t&&(44===n.charCodeAt(s)?(t=",",s++):(t=null,0===a&&u('","')),null===t&&(59===n.charCodeAt(s)?(t=";",s++):(t=null,0===a&&u('";"')),null===t&&(58===n.charCodeAt(s)?(t=":",s++):(t=null,0===a&&u('":"')),null===t&&(64===n.charCodeAt(s)?(t="@",s++):(t=null,0===a&&u('"@"')),null===t&&(38===n.charCodeAt(s)?(t="&",s++):(t=null,0===a&&u('"&"')),null===t&&(61===n.charCodeAt(s)?(t="=",s++):(t=null,0===a&&u('"="')),null===t&&(43===n.charCodeAt(s)?(t="+",s++):(t=null,0===a&&u('"+"'))))))))));else e=null;return e}function Ze(){var e,t;for(e=[],t=Be();null!==t;)e.push(t),t=Be();return e}function et(){var e,t,r,i,o,l,c,h;if(c=s,h=s,"sip"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===a&&u('"SIP"')),null!==e)if(47===n.charCodeAt(s)?(t="/",s++):(t=null,0===a&&u('"/"')),null!==t){if(null!==(i=d()))for(r=[];null!==i;)r.push(i),i=d();else r=null;if(null!==r)if(46===n.charCodeAt(s)?(i=".",s++):(i=null,0===a&&u('"."')),null!==i){if(null!==(l=d()))for(o=[];null!==l;)o.push(l),l=d();else o=null;null!==o?e=[e,t,r,i,o]:(e=null,s=h)}else e=null,s=h;else e=null,s=h}else e=null,s=h;else e=null,s=h;null!==e&&(f=c,e=void(Fn.sip_version=n.substring(s,f)));var f;return null===e&&(s=c),e}function tt(){var e;return"INVITE"===n.substr(s,6)?(e="INVITE",s+=6):(e=null,0===a&&u('"INVITE"')),e}function nt(){var e;return"ACK"===n.substr(s,3)?(e="ACK",s+=3):(e=null,0===a&&u('"ACK"')),e}function rt(){var e;return"OPTIONS"===n.substr(s,7)?(e="OPTIONS",s+=7):(e=null,0===a&&u('"OPTIONS"')),e}function it(){var e;return"BYE"===n.substr(s,3)?(e="BYE",s+=3):(e=null,0===a&&u('"BYE"')),e}function st(){var e;return"CANCEL"===n.substr(s,6)?(e="CANCEL",s+=6):(e=null,0===a&&u('"CANCEL"')),e}function at(){var e;return"REGISTER"===n.substr(s,8)?(e="REGISTER",s+=8):(e=null,0===a&&u('"REGISTER"')),e}function ot(){var e;return"SUBSCRIBE"===n.substr(s,9)?(e="SUBSCRIBE",s+=9):(e=null,0===a&&u('"SUBSCRIBE"')),e}function lt(){var e;return"NOTIFY"===n.substr(s,6)?(e="NOTIFY",s+=6):(e=null,0===a&&u('"NOTIFY"')),e}function ut(){var e;return"REFER"===n.substr(s,5)?(e="REFER",s+=5):(e=null,0===a&&u('"REFER"')),e}function ct(){var e,t;t=s,null===(e=tt())&&null===(e=nt())&&null===(e=rt())&&null===(e=it())&&null===(e=st())&&null===(e=at())&&null===(e=ot())&&null===(e=lt())&&null===(e=ut())&&(e=O()),null!==e&&(r=t,Fn.method=n.substring(s,r),e=Fn.method);var r;return null===e&&(s=t),e}function dt(){var e,t,n,r,i,a;return a=s,null!==(e=et())&&null!==(t=m())&&null!==(n=ht())&&null!==(r=m())&&null!==(i=pt())?e=[e,t,n,r,i]:(e=null,s=a),e}function ht(){var e,t;t=s,null!==(e=ft())&&(n=e,e=void(Fn.status_code=parseInt(n.join(""))));var n;return null===e&&(s=t),e}function ft(){var e,t,n,r;return r=s,null!==(e=d())&&null!==(t=d())&&null!==(n=d())?e=[e,t,n]:(e=null,s=r),e}function pt(){var e,t,r;for(r=s,e=[],null===(t=T())&&null===(t=C())&&null===(t=E())&&null===(t=k())&&null===(t=P())&&null===(t=m())&&(t=g());null!==t;)e.push(t),null===(t=T())&&null===(t=C())&&null===(t=E())&&null===(t=k())&&null===(t=P())&&null===(t=m())&&(t=g());null!==e&&(i=r,e=void(Fn.reason_phrase=n.substring(s,i)));var i;return null===e&&(s=r),e}function _t(){var e,t,n,r,i,a,o;if(i=s,a=s,null===(e=Q())&&(e=vt()),null!==e){for(t=[],o=s,null!==(n=G())&&null!==(r=gt())?n=[n,r]:(n=null,s=o);null!==n;)t.push(n),o=s,null!==(n=G())&&null!==(r=gt())?n=[n,r]:(n=null,s=o);null!==t?e=[e,t]:(e=null,s=a)}else e=null,s=a;return null!==e&&(e=function(e){var t;Fn.multi_header||(Fn.multi_header=[]);try{t=new Hn(Fn.uri,Fn.display_name,Fn.params),delete Fn.uri,delete Fn.display_name,delete Fn.params}catch(e){t=null}Fn.multi_header.push({possition:s,offset:e,parsed:t})}(i)),null===e&&(s=i),e}function vt(){var e,t,n,r,i;return i=s,null!==(e=null!==(e=mt())?e:"")&&null!==(t=F())&&null!==(n=X())&&null!==(r=H())?e=[e,t,n,r]:(e=null,s=i),e}function mt(){var e,t,r,i,a,o,l;if(a=s,o=s,null!==(e=O())){for(t=[],l=s,null!==(r=b())&&null!==(i=O())?r=[r,i]:(r=null,s=l);null!==r;)t.push(r),l=s,null!==(r=b())&&null!==(i=O())?r=[r,i]:(r=null,s=l);null!==t?e=[e,t]:(e=null,s=o)}else e=null,s=o;null===e&&(e=K()),null!==e&&(u=a,c=e,'"'===(c=n.substring(s,u).trim())[0]&&(c=c.substring(1,c.length-1)),e=void(Fn.display_name=c));var u,c;return null===e&&(s=a),e}function gt(){var e;return null===(e=yt())&&null===(e=Tt())&&(e=Et()),e}function yt(){var e,t,r,i,o;i=s,o=s,"q"===n.substr(s,1).toLowerCase()?(e=n.substr(s,1),s++):(e=null,0===a&&u('"q"')),null!==e&&null!==(t=M())&&null!==(r=St())?e=[e,t,r]:(e=null,s=o),null!==e&&(l=e[2],Fn.params||(Fn.params={}),e=void(Fn.params.q=l));var l;return null===e&&(s=i),e}function Tt(){var e,t,r,i,o;i=s,o=s,"expires"===n.substr(s,7).toLowerCase()?(e=n.substr(s,7),s+=7):(e=null,0===a&&u('"expires"')),null!==e&&null!==(t=M())&&null!==(r=Ct())?e=[e,t,r]:(e=null,s=o),null!==e&&(l=e[2],Fn.params||(Fn.params={}),e=void(Fn.params.expires=l));var l;return null===e&&(s=i),e}function Ct(){var e,t,n;if(n=s,null!==(t=d()))for(e=[];null!==t;)e.push(t),t=d();else e=null;return null!==e&&(e=parseInt(e.join(""))),null===e&&(s=n),e}function St(){var e,t,r,i,o,l,c,h;l=s,c=s,48===n.charCodeAt(s)?(e="0",s++):(e=null,0===a&&u('"0"')),null!==e?(h=s,46===n.charCodeAt(s)?(t=".",s++):(t=null,0===a&&u('"."')),null!==t&&null!==(r=null!==(r=d())?r:"")&&null!==(i=null!==(i=d())?i:"")&&null!==(o=null!==(o=d())?o:"")?t=[t,r,i,o]:(t=null,s=h),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=c)):(e=null,s=c),null!==e&&(f=l,e=parseFloat(n.substring(s,f)));var f;return null===e&&(s=l),e}function Et(){var e,t,n,r,i,a;r=s,i=s,null!==(e=O())?(a=s,null!==(t=M())&&null!==(n=bt())?t=[t,n]:(t=null,s=a),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=i)):(e=null,s=i),null!==e&&(o=e[0],l=e[1],Fn.params||(Fn.params={}),l=void 0===l?void 0:l[1],e=void(Fn.params[o.toLowerCase()]=l));var o,l;return null===e&&(s=r),e}function bt(){var e;return null===(e=O())&&null===(e=oe())&&(e=K()),e}function Rt(){var e;return"render"===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===a&&u('"render"')),null===e&&("session"===n.substr(s,7).toLowerCase()?(e=n.substr(s,7),s+=7):(e=null,0===a&&u('"session"')),null===e&&("icon"===n.substr(s,4).toLowerCase()?(e=n.substr(s,4),s+=4):(e=null,0===a&&u('"icon"')),null===e&&("alert"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===a&&u('"alert"')),null===e&&(e=O())))),e}function At(){var e;return null===(e=wt())&&(e=Et()),e}function wt(){var e,t,r,i;return i=s,"handling"===n.substr(s,8).toLowerCase()?(e=n.substr(s,8),s+=8):(e=null,0===a&&u('"handling"')),null!==e&&null!==(t=M())?("optional"===n.substr(s,8).toLowerCase()?(r=n.substr(s,8),s+=8):(r=null,0===a&&u('"optional"')),null===r&&("required"===n.substr(s,8).toLowerCase()?(r=n.substr(s,8),s+=8):(r=null,0===a&&u('"required"')),null===r&&(r=O())),null!==r?e=[e,t,r]:(e=null,s=i)):(e=null,s=i),e}function It(){var e,t,n,r,i,a,o,l;if(o=s,null!==(e=kt()))if(null!==(t=U()))if(null!==(n=Nt())){for(r=[],l=s,null!==(i=G())&&null!==(a=Ut())?i=[i,a]:(i=null,s=l);null!==i;)r.push(i),l=s,null!==(i=G())&&null!==(a=Ut())?i=[i,a]:(i=null,s=l);null!==r?e=[e,t,n,r]:(e=null,s=o)}else e=null,s=o;else e=null,s=o;else e=null,s=o;return e}function kt(){var e;return null===(e=Pt())&&(e=Ot()),e}function Pt(){var e;return"text"===n.substr(s,4).toLowerCase()?(e=n.substr(s,4),s+=4):(e=null,0===a&&u('"text"')),null===e&&("image"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===a&&u('"image"')),null===e&&("audio"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===a&&u('"audio"')),null===e&&("video"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===a&&u('"video"')),null===e&&("application"===n.substr(s,11).toLowerCase()?(e=n.substr(s,11),s+=11):(e=null,0===a&&u('"application"')),null===e&&(e=xt()))))),e}function Ot(){var e;return"message"===n.substr(s,7).toLowerCase()?(e=n.substr(s,7),s+=7):(e=null,0===a&&u('"message"')),null===e&&("multipart"===n.substr(s,9).toLowerCase()?(e=n.substr(s,9),s+=9):(e=null,0===a&&u('"multipart"')),null===e&&(e=xt())),e}function xt(){var e;return null===(e=O())&&(e=Dt()),e}function Dt(){var e,t,r;return r=s,"x-"===n.substr(s,2).toLowerCase()?(e=n.substr(s,2),s+=2):(e=null,0===a&&u('"x-"')),null!==e&&null!==(t=O())?e=[e,t]:(e=null,s=r),e}function Nt(){var e;return null===(e=xt())&&(e=O()),e}function Ut(){var e,t,n,r;return r=s,null!==(e=O())&&null!==(t=M())&&null!==(n=Mt())?e=[e,t,n]:(e=null,s=r),e}function Mt(){var e;return null===(e=O())&&(e=K()),e}function Lt(){var e,t,n;if(n=s,null!==(t=d()))for(e=[];null!==t;)e.push(t),t=d();else e=null;null!==e&&(r=e,e=void(Fn.value=parseInt(r.join(""))));var r;return null===e&&(s=n),e}function qt(){var e,t,r,i,o,l;if(o=s,null!==(e=x())){for(t=[],l=s,46===n.charCodeAt(s)?(r=".",s++):(r=null,0===a&&u('"."')),null!==r&&null!==(i=x())?r=[r,i]:(r=null,s=l);null!==r;)t.push(r),l=s,46===n.charCodeAt(s)?(r=".",s++):(r=null,0===a&&u('"."')),null!==r&&null!==(i=x())?r=[r,i]:(r=null,s=l);null!==t?e=[e,t]:(e=null,s=o)}else e=null,s=o;return e}function Ht(){var e;return null===(e=Ft())&&(e=Et()),e}function Ft(){var e,t,r,i,o;i=s,o=s,"tag"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===a&&u('"tag"')),null!==e&&null!==(t=M())&&null!==(r=O())?e=[e,t,r]:(e=null,s=o),null!==e&&(l=e[2],e=void(Fn.tag=l));var l;return null===e&&(s=i),e}function jt(){var e,t,r,i,o,l,c,d;if(c=s,"digest"===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===a&&u('"Digest"')),null!==e)if(null!==(t=b()))if(null!==(r=Wt())){for(i=[],d=s,null!==(o=j())&&null!==(l=Wt())?o=[o,l]:(o=null,s=d);null!==o;)i.push(o),d=s,null!==(o=j())&&null!==(l=Wt())?o=[o,l]:(o=null,s=d);null!==i?e=[e,t,r,i]:(e=null,s=c)}else e=null,s=c;else e=null,s=c;else e=null,s=c;return null===e&&(e=Gt()),e}function Gt(){var e,t,n,r,i,a,o,l;if(o=s,null!==(e=O()))if(null!==(t=b()))if(null!==(n=Bt())){for(r=[],l=s,null!==(i=j())&&null!==(a=Bt())?i=[i,a]:(i=null,s=l);null!==i;)r.push(i),l=s,null!==(i=j())&&null!==(a=Bt())?i=[i,a]:(i=null,s=l);null!==r?e=[e,t,n,r]:(e=null,s=o)}else e=null,s=o;else e=null,s=o;else e=null,s=o;return e}function Bt(){var e,t,n,r;return r=s,null!==(e=O())&&null!==(t=M())?(null===(n=O())&&(n=K()),null!==n?e=[e,t,n]:(e=null,s=r)):(e=null,s=r),e}function Wt(){var e;return null===(e=Vt())&&null===(e=Kt())&&null===(e=Yt())&&null===(e=Qt())&&null===(e=Xt())&&null===(e=Zt())&&null===(e=en())&&(e=Bt()),e}function Vt(){var e,t,r,i;return i=s,"realm"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===a&&u('"realm"')),null!==e&&null!==(t=M())&&null!==(r=Jt())?e=[e,t,r]:(e=null,s=i),e}function Jt(){var e,t;t=s,null!==(e=z())&&(n=e,e=void(Fn.realm=n));var n;return null===e&&(s=t),e}function Kt(){var e,t,r,i,o,l,c,d,h;if(d=s,"domain"===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===a&&u('"domain"')),null!==e)if(null!==(t=M()))if(null!==(r=W()))if(null!==(i=zt())){if(o=[],h=s,null!==(c=m()))for(l=[];null!==c;)l.push(c),c=m();else l=null;for(null!==l&&null!==(c=zt())?l=[l,c]:(l=null,s=h);null!==l;){if(o.push(l),h=s,null!==(c=m()))for(l=[];null!==c;)l.push(c),c=m();else l=null;null!==l&&null!==(c=zt())?l=[l,c]:(l=null,s=h)}null!==o&&null!==(l=V())?e=[e,t,r,i,o,l]:(e=null,s=d)}else e=null,s=d;else e=null,s=d;else e=null,s=d;else e=null,s=d;return e}function zt(){var e;return null===(e=qe())&&(e=je()),e}function Yt(){var e,t,r,i;return i=s,"nonce"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===a&&u('"nonce"')),null!==e&&null!==(t=M())&&null!==(r=$t())?e=[e,t,r]:(e=null,s=i),e}function $t(){var e,t;t=s,null!==(e=z())&&(n=e,e=void(Fn.nonce=n));var n;return null===e&&(s=t),e}function Qt(){var e,t,r,i,o;i=s,o=s,"opaque"===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===a&&u('"opaque"')),null!==e&&null!==(t=M())&&null!==(r=z())?e=[e,t,r]:(e=null,s=o),null!==e&&(l=e[2],e=void(Fn.opaque=l));var l;return null===e&&(s=i),e}function Xt(){var e,t,r,i,o;return i=s,"stale"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===a&&u('"stale"')),null!==e&&null!==(t=M())?(o=s,"true"===n.substr(s,4).toLowerCase()?(r=n.substr(s,4),s+=4):(r=null,0===a&&u('"true"')),null!==r&&(r=void(Fn.stale=!0)),null===r&&(s=o),null===r&&(o=s,"false"===n.substr(s,5).toLowerCase()?(r=n.substr(s,5),s+=5):(r=null,0===a&&u('"false"')),null!==r&&(r=void(Fn.stale=!1)),null===r&&(s=o)),null!==r?e=[e,t,r]:(e=null,s=i)):(e=null,s=i),e}function Zt(){var e,t,r,i,o;i=s,o=s,"algorithm"===n.substr(s,9).toLowerCase()?(e=n.substr(s,9),s+=9):(e=null,0===a&&u('"algorithm"')),null!==e&&null!==(t=M())?("md5"===n.substr(s,3).toLowerCase()?(r=n.substr(s,3),s+=3):(r=null,0===a&&u('"MD5"')),null===r&&("md5-sess"===n.substr(s,8).toLowerCase()?(r=n.substr(s,8),s+=8):(r=null,0===a&&u('"MD5-sess"')),null===r&&(r=O())),null!==r?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(l=e[2],e=void(Fn.algorithm=l.toUpperCase()));var l;return null===e&&(s=i),e}function en(){var e,t,r,i,o,l,c,d,h,f;if(d=s,"qop"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===a&&u('"qop"')),null!==e)if(null!==(t=M()))if(null!==(r=W())){if(h=s,null!==(i=tn())){for(o=[],f=s,44===n.charCodeAt(s)?(l=",",s++):(l=null,0===a&&u('","')),null!==l&&null!==(c=tn())?l=[l,c]:(l=null,s=f);null!==l;)o.push(l),f=s,44===n.charCodeAt(s)?(l=",",s++):(l=null,0===a&&u('","')),null!==l&&null!==(c=tn())?l=[l,c]:(l=null,s=f);null!==o?i=[i,o]:(i=null,s=h)}else i=null,s=h;null!==i&&null!==(o=V())?e=[e,t,r,i,o]:(e=null,s=d)}else e=null,s=d;else e=null,s=d;else e=null,s=d;return e}function tn(){var e,t;t=s,"auth-int"===n.substr(s,8).toLowerCase()?(e=n.substr(s,8),s+=8):(e=null,0===a&&u('"auth-int"')),null===e&&("auth"===n.substr(s,4).toLowerCase()?(e=n.substr(s,4),s+=4):(e=null,0===a&&u('"auth"')),null===e&&(e=O())),null!==e&&(r=e,Fn.qop||(Fn.qop=[]),e=void Fn.qop.push(r.toLowerCase()));var r;return null===e&&(s=t),e}function nn(){var e,t,n,r,i,a,o;if(i=s,a=s,null!==(e=vt())){for(t=[],o=s,null!==(n=G())&&null!==(r=Et())?n=[n,r]:(n=null,s=o);null!==n;)t.push(n),o=s,null!==(n=G())&&null!==(r=Et())?n=[n,r]:(n=null,s=o);null!==t?e=[e,t]:(e=null,s=a)}else e=null,s=a;return null!==e&&(e=function(e){var t;Fn.multi_header||(Fn.multi_header=[]);try{t=new Hn(Fn.uri,Fn.display_name,Fn.params),delete Fn.uri,delete Fn.display_name,delete Fn.params}catch(e){t=null}Fn.multi_header.push({possition:s,offset:e,parsed:t})}(i)),null===e&&(s=i),e}function rn(){var e;return null===(e=sn())&&(e=Et()),e}function sn(){var e,t,r,i,o,l;if(o=s,l=s,"cause"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===a&&u('"cause"')),null!==e)if(null!==(t=M())){if(null!==(i=d()))for(r=[];null!==i;)r.push(i),i=d();else r=null;null!==r?e=[e,t,r]:(e=null,s=l)}else e=null,s=l;else e=null,s=l;null!==e&&(c=e[2],e=void(Fn.cause=parseInt(c.join(""))));var c;return null===e&&(s=o),e}function an(){var e,t,n,r,i,a;if(i=s,null!==(e=vt())){for(t=[],a=s,null!==(n=G())&&null!==(r=Et())?n=[n,r]:(n=null,s=a);null!==n;)t.push(n),a=s,null!==(n=G())&&null!==(r=Et())?n=[n,r]:(n=null,s=a);null!==t?e=[e,t]:(e=null,s=i)}else e=null,s=i;return e}function on(){var e,t;t=s,"active"===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===a&&u('"active"')),null===e&&("pending"===n.substr(s,7).toLowerCase()?(e=n.substr(s,7),s+=7):(e=null,0===a&&u('"pending"')),null===e&&("terminated"===n.substr(s,10).toLowerCase()?(e=n.substr(s,10),s+=10):(e=null,0===a&&u('"terminated"')),null===e&&(e=O()))),null!==e&&(r=t,e=void(Fn.state=n.substring(s,r)));var r;return null===e&&(s=t),e}function ln(){var e,t,r,i,o;i=s,o=s,"reason"===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===a&&u('"reason"')),null!==e&&null!==(t=M())&&null!==(r=un())?e=[e,t,r]:(e=null,s=o),null!==e&&(e=void(void 0!==(l=e[2])&&(Fn.reason=l)));var l;null===e&&(s=i),null===e&&(i=s,o=s,"expires"===n.substr(s,7).toLowerCase()?(e=n.substr(s,7),s+=7):(e=null,0===a&&u('"expires"')),null!==e&&null!==(t=M())&&null!==(r=Ct())?e=[e,t,r]:(e=null,s=o),null!==e&&(e=void(void 0!==(d=e[2])&&(Fn.expires=d))),null===e&&(s=i),null===e&&(i=s,o=s,"retry_after"===n.substr(s,11).toLowerCase()?(e=n.substr(s,11),s+=11):(e=null,0===a&&u('"retry_after"')),null!==e&&null!==(t=M())&&null!==(r=Ct())?e=[e,t,r]:(e=null,s=o),null!==e&&(e=void(void 0!==(c=e[2])&&(Fn.retry_after=c))),null===e&&(s=i),null===e&&(e=Et())));var c,d;return e}function un(){var e;return"deactivated"===n.substr(s,11).toLowerCase()?(e=n.substr(s,11),s+=11):(e=null,0===a&&u('"deactivated"')),null===e&&("probation"===n.substr(s,9).toLowerCase()?(e=n.substr(s,9),s+=9):(e=null,0===a&&u('"probation"')),null===e&&("rejected"===n.substr(s,8).toLowerCase()?(e=n.substr(s,8),s+=8):(e=null,0===a&&u('"rejected"')),null===e&&("timeout"===n.substr(s,7).toLowerCase()?(e=n.substr(s,7),s+=7):(e=null,0===a&&u('"timeout"')),null===e&&("giveup"===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===a&&u('"giveup"')),null===e&&("noresource"===n.substr(s,10).toLowerCase()?(e=n.substr(s,10),s+=10):(e=null,0===a&&u('"noresource"')),null===e&&("invariant"===n.substr(s,9).toLowerCase()?(e=n.substr(s,9),s+=9):(e=null,0===a&&u('"invariant"')),null===e&&(e=O()))))))),e}function cn(){var e;return null===(e=Ft())&&(e=Et()),e}function dn(){var e,t,n,r,i,a,o,l;if(o=s,null!==(e=gn()))if(null!==(t=b()))if(null!==(n=Cn())){for(r=[],l=s,null!==(i=G())&&null!==(a=hn())?i=[i,a]:(i=null,s=l);null!==i;)r.push(i),l=s,null!==(i=G())&&null!==(a=hn())?i=[i,a]:(i=null,s=l);null!==r?e=[e,t,n,r]:(e=null,s=o)}else e=null,s=o;else e=null,s=o;else e=null,s=o;return e}function hn(){var e;return null===(e=fn())&&null===(e=pn())&&null===(e=_n())&&null===(e=vn())&&null===(e=mn())&&(e=Et()),e}function fn(){var e,t,r,i,o;i=s,o=s,"ttl"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===a&&u('"ttl"')),null!==e&&null!==(t=M())&&null!==(r=bn())?e=[e,t,r]:(e=null,s=o),null!==e&&(l=e[2],e=void(Fn.ttl=l));var l;return null===e&&(s=i),e}function pn(){var e,t,r,i,o;i=s,o=s,"maddr"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===a&&u('"maddr"')),null!==e&&null!==(t=M())&&null!==(r=oe())?e=[e,t,r]:(e=null,s=o),null!==e&&(l=e[2],e=void(Fn.maddr=l));var l;return null===e&&(s=i),e}function _n(){var e,t,r,i,o;i=s,o=s,"received"===n.substr(s,8).toLowerCase()?(e=n.substr(s,8),s+=8):(e=null,0===a&&u('"received"')),null!==e&&null!==(t=M())?(null===(r=_e())&&(r=he()),null!==r?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(l=e[2],e=void(Fn.received=l));var l;return null===e&&(s=i),e}function vn(){var e,t,r,i,o;i=s,o=s,"branch"===n.substr(s,6).toLowerCase()?(e=n.substr(s,6),s+=6):(e=null,0===a&&u('"branch"')),null!==e&&null!==(t=M())&&null!==(r=O())?e=[e,t,r]:(e=null,s=o),null!==e&&(l=e[2],e=void(Fn.branch=l));var l;return null===e&&(s=i),e}function mn(){var e,t,r,i,o,l,c;if(o=s,l=s,"rport"===n.substr(s,5).toLowerCase()?(e=n.substr(s,5),s+=5):(e=null,0===a&&u('"rport"')),null!==e){if(c=s,null!==(t=M())){for(r=[],i=d();null!==i;)r.push(i),i=d();null!==r?t=[t,r]:(t=null,s=c)}else t=null,s=c;null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=l)}else e=null,s=l;return null!==e&&(e=void("undefined"!=typeof response_port&&(Fn.rport=response_port.join("")))),null===e&&(s=o),e}function gn(){var e,t,n,r,i,a;return a=s,null!==(e=yn())&&null!==(t=U())&&null!==(n=O())&&null!==(r=U())&&null!==(i=Tn())?e=[e,t,n,r,i]:(e=null,s=a),e}function yn(){var e,t;t=s,"sip"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===a&&u('"SIP"')),null===e&&(e=O()),null!==e&&(r=e,e=void(Fn.protocol=r));var r;return null===e&&(s=t),e}function Tn(){var e,t;t=s,"udp"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===a&&u('"UDP"')),null===e&&("tcp"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===a&&u('"TCP"')),null===e&&("tls"===n.substr(s,3).toLowerCase()?(e=n.substr(s,3),s+=3):(e=null,0===a&&u('"TLS"')),null===e&&("sctp"===n.substr(s,4).toLowerCase()?(e=n.substr(s,4),s+=4):(e=null,0===a&&u('"SCTP"')),null===e&&(e=O())))),null!==e&&(r=e,e=void(Fn.transport=r));var r;return null===e&&(s=t),e}function Cn(){var e,t,n,r,i;return r=s,null!==(e=Sn())?(i=s,null!==(t=B())&&null!==(n=En())?t=[t,n]:(t=null,s=i),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=r)):(e=null,s=r),e}function Sn(){var e,t;t=s,null===(e=_e())&&null===(e=de())&&(e=le()),null!==e&&(r=t,e=void(Fn.host=n.substring(s,r)));var r;return null===e&&(s=t),e}function En(){var e,t,n,r,i,a,o;a=s,o=s,null!==(e=null!==(e=d())?e:"")&&null!==(t=null!==(t=d())?t:"")&&null!==(n=null!==(n=d())?n:"")&&null!==(r=null!==(r=d())?r:"")&&null!==(i=null!==(i=d())?i:"")?e=[e,t,n,r,i]:(e=null,s=o),null!==e&&(l=e,e=void(Fn.port=parseInt(l.join(""))));var l;return null===e&&(s=a),e}function bn(){var e,t,n,r,i;return r=s,i=s,null!==(e=d())&&null!==(t=null!==(t=d())?t:"")&&null!==(n=null!==(n=d())?n:"")?e=[e,t,n]:(e=null,s=i),null!==e&&(e=parseInt(e.join(""))),null===e&&(s=r),e}function Rn(){var e,t;t=s,null!==(e=Ct())&&(n=e,e=void(Fn.expires=n));var n;return null===e&&(s=t),e}function An(){var e;return null===(e=wn())&&(e=Et()),e}function wn(){var e,t,r,i,o;i=s,o=s,"refresher"===n.substr(s,9).toLowerCase()?(e=n.substr(s,9),s+=9):(e=null,0===a&&u('"refresher"')),null!==e&&null!==(t=M())?("uac"===n.substr(s,3).toLowerCase()?(r=n.substr(s,3),s+=3):(r=null,0===a&&u('"uac"')),null===r&&("uas"===n.substr(s,3).toLowerCase()?(r=n.substr(s,3),s+=3):(r=null,0===a&&u('"uas"'))),null!==r?e=[e,t,r]:(e=null,s=o)):(e=null,s=o),null!==e&&(l=e[2],e=void(Fn.refresher=l.toLowerCase()));var l;return null===e&&(s=i),e}function In(){var e,t;for(e=[],null===(t=I())&&null===(t=P())&&(t=b());null!==t;)e.push(t),null===(t=I())&&null===(t=P())&&(t=b());return e}function kn(){var e,t,r,i,o,l,c,d,h,f,p;f=s,p=s,null!==(e=On())?(45===n.charCodeAt(s)?(t="-",s++):(t=null,0===a&&u('"-"')),null!==t&&null!==(r=Pn())?(45===n.charCodeAt(s)?(i="-",s++):(i=null,0===a&&u('"-"')),null!==i&&null!==(o=Pn())?(45===n.charCodeAt(s)?(l="-",s++):(l=null,0===a&&u('"-"')),null!==l&&null!==(c=Pn())?(45===n.charCodeAt(s)?(d="-",s++):(d=null,0===a&&u('"-"')),null!==d&&null!==(h=xn())?e=[e,t,r,i,o,l,c,d,h]:(e=null,s=p)):(e=null,s=p)):(e=null,s=p)):(e=null,s=p)):(e=null,s=p),null!==e&&(_=f,e[0],e=void(Fn=n.substring(s+5,_)));var _;return null===e&&(s=f),e}function Pn(){var e,t,n,r,i;return i=s,null!==(e=f())&&null!==(t=f())&&null!==(n=f())&&null!==(r=f())?e=[e,t,n,r]:(e=null,s=i),e}function On(){var e,t,n;return n=s,null!==(e=Pn())&&null!==(t=Pn())?e=[e,t]:(e=null,s=n),e}function xn(){var e,t,n,r;return r=s,null!==(e=Pn())&&null!==(t=Pn())&&null!==(n=Pn())?e=[e,t,n]:(e=null,s=r),e}function Dn(){var e,t,r,i,o,l;i=s,o=s,null!==(e=D())?(l=s,64===n.charCodeAt(s)?(t="@",s++):(t=null,0===a&&u('"@"')),null!==t&&null!==(r=D())?t=[t,r]:(t=null,s=l),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,s=o)):(e=null,s=o),null!==e&&(c=i,e=void(Fn.call_id=n.substring(s,c)));var c;return null===e&&(s=i),e}function Nn(){var e;return null===(e=Un())&&null===(e=Mn())&&null===(e=Ln())&&(e=Et()),e}function Un(){var e,t,r,i,o;i=s,o=s,"to-tag"===n.substr(s,6)?(e="to-tag",s+=6):(e=null,0===a&&u('"to-tag"')),null!==e&&null!==(t=M())&&null!==(r=O())?e=[e,t,r]:(e=null,s=o),null!==e&&(l=e[2],e=void(Fn.to_tag=l));var l;return null===e&&(s=i),e}function Mn(){var e,t,r,i,o;i=s,o=s,"from-tag"===n.substr(s,8)?(e="from-tag",s+=8):(e=null,0===a&&u('"from-tag"')),null!==e&&null!==(t=M())&&null!==(r=O())?e=[e,t,r]:(e=null,s=o),null!==e&&(l=e[2],e=void(Fn.from_tag=l));var l;return null===e&&(s=i),e}function Ln(){var e,t;return t=s,"early-only"===n.substr(s,10)?(e="early-only",s+=10):(e=null,0===a&&u('"early-only"')),null!==e&&(e=void(Fn.early_only=!0)),null===e&&(s=t),e}var qn=e("./URI"),Hn=e("./NameAddrHeader"),Fn={};if(null===i[r]()||s!==n.length){var jn=Math.max(s,o),Gn=jn2&&void 0!==arguments[2]?arguments[2]:{},i=e;if(void 0===e||void 0===t)throw new TypeError("Not enough arguments");if(!(e=this._ua.normalizeTarget(e)))throw new TypeError("Invalid target: "+i);var u=o.cloneArray(r.extraHeaders),c=r.eventHandlers||{},d=r.contentType||"text/plain";for(var h in c)Object.prototype.hasOwnProperty.call(c,h)&&this.on(h,c[h]);u.push("Content-Type: "+d),this._request=new a.OutgoingRequest(s.MESSAGE,e,this._ua,null,u),t&&(this._request.body=t);var f=new l(this._ua,this._request,{onRequestTimeout:function(){n._onRequestTimeout()},onTransportError:function(){n._onTransportError()},onReceiveResponse:function(e){n._receiveResponse(e)}});this._newMessage("local",this._request),f.send()}},{key:"init_incoming",value:function(e){this._request=e,this._newMessage("remote",e),this._is_replied||(this._is_replied=!0,e.reply(200)),this._close()}},{key:"accept",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=o.cloneArray(e.extraHeaders),n=e.body;if("incoming"!==this._direction)throw new u.NotSupportedError('"accept" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");this._is_replied=!0,this._request.reply(200,null,t,n)}},{key:"reject",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.status_code||480,n=e.reason_phrase,r=o.cloneArray(e.extraHeaders),i=e.body;if("incoming"!==this._direction)throw new u.NotSupportedError('"reject" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");if(t<300||t>=700)throw new TypeError("Invalid status_code: "+t);this._is_replied=!0,this._request.reply(t,n,r,i)}},{key:"_receiveResponse",value:function(e){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(e.status_code):break;case/^2[0-9]{2}$/.test(e.status_code):this._succeeded("remote",e);break;default:var t=o.sipErrorCause(e.status_code);this._failed("remote",e,t)}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,s.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,s.causes.CONNECTION_ERROR)}},{key:"_close",value:function(){this._closed=!0,this._ua.destroyMessage(this)}},{key:"_newMessage",value:function(e,t){"remote"===e?(this._direction="incoming",this._local_identity=t.to,this._remote_identity=t.from):"local"===e&&(this._direction="outgoing",this._local_identity=t.from,this._remote_identity=t.to),this._ua.newMessage(this,{originator:e,message:this,request:t})}},{key:"_failed",value:function(e,t,n){c("MESSAGE failed"),this._close(),c('emit "failed"'),this.emit("failed",{originator:e,response:t||null,cause:n})}},{key:"_succeeded",value:function(e,t){c("MESSAGE succeeded"),this._close(),c('emit "succeeded"'),this.emit("succeeded",{originator:e,response:t})}},{key:"direction",get:function(){return this._direction}},{key:"local_identity",get:function(){return this._local_identity}},{key:"remote_identity",get:function(){return this._remote_identity}}]),t}()},{"./Constants":2,"./Exceptions":6,"./RequestSender":18,"./SIPMessage":19,"./Utils":26,debug:29,events:31}],10:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n";for(var t in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,t)&&(e+=";"+t,null!==this._parameters[t]&&(e+="="+this._parameters[t]));return e}},{key:"uri",get:function(){return this._uri}},{key:"display_name",get:function(){return this._display_name},set:function(e){this._display_name=0===e?"0":e}}]),e}()},{"./Grammar":7,"./URI":25}],11:[function(e,t,n){"use strict";var r=e("./Grammar"),i=e("./SIPMessage"),s=e("debug")("JsSIP:ERROR:Parser");s.log=console.warn.bind(console),n.parseMessage=function(e,t){var n=void 0,l=void 0,u=e.indexOf("\r\n");if(-1!==u){var c=e.substring(0,u),d=r.parse(c,"Request_Response");if(-1!==d){d.status_code?((n=new i.IncomingResponse).status_code=d.status_code,n.reason_phrase=d.reason_phrase):((n=new i.IncomingRequest(t)).method=d.method,n.ruri=d.uri),n.data=e;for(var h=u+2;;){if(-2===(u=a(e,h))){l=h+2;break}if(-1===u)return void s("parseMessage() | malformed message");if(!0!==(d=o(n,e,h,u)))return void s("parseMessage() |",d.error);h=u+2}if(n.hasHeader("content-length")){var f=n.getHeader("content-length");n.body=e.substr(l,f)}else n.body=e.substring(l);return n}s('parseMessage() | error parsing first line of SIP message: "'+c+'"')}else s("parseMessage() | no CRLF found, not a SIP message")};function a(e,t){var n=t,r=0,i=0;if(e.substring(n,n+2).match(/(^\r\n)/))return-2;for(;0===r;){if(-1===(i=e.indexOf("\r\n",n)))return i;!e.substring(i+2,i+4).match(/(^\r\n)/)&&e.charAt(i+2).match(/(^\s+)/)?n=i+2:r=i}return r}function o(e,t,n,s){var a=void 0,o=t.indexOf(":",n),l=t.substring(n,o).trim(),u=t.substring(o+1,s).trim();switch(l.toLowerCase()){case"via":case"v":e.addHeader("via",u),1===e.getHeaders("via").length?(a=e.parseHeader("Via"))&&(e.via=a,e.via_branch=a.branch):a=0;break;case"from":case"f":e.setHeader("from",u),(a=e.parseHeader("from"))&&(e.from=a,e.from_tag=a.getParam("tag"));break;case"to":case"t":e.setHeader("to",u),(a=e.parseHeader("to"))&&(e.to=a,e.to_tag=a.getParam("tag"));break;case"record-route":if(-1===(a=r.parse(u,"Record_Route")))a=void 0;else{var c=!0,d=!1,h=void 0;try{for(var f,p=a[Symbol.iterator]();!(c=(f=p.next()).done);c=!0){var _=f.value;e.addHeader("record-route",u.substring(_.possition,_.offset)),e.headers["Record-Route"][e.getHeaders("record-route").length-1].parsed=_.parsed}}catch(e){d=!0,h=e}finally{try{!c&&p.return&&p.return()}finally{if(d)throw h}}}break;case"call-id":case"i":e.setHeader("call-id",u),(a=e.parseHeader("call-id"))&&(e.call_id=u);break;case"contact":case"m":if(-1===(a=r.parse(u,"Contact")))a=void 0;else{var v=!0,m=!1,g=void 0;try{for(var y,T=a[Symbol.iterator]();!(v=(y=T.next()).done);v=!0){var C=y.value;e.addHeader("contact",u.substring(C.possition,C.offset)),e.headers.Contact[e.getHeaders("contact").length-1].parsed=C.parsed}}catch(e){m=!0,g=e}finally{try{!v&&T.return&&T.return()}finally{if(m)throw g}}}break;case"content-length":case"l":e.setHeader("content-length",u),a=e.parseHeader("content-length");break;case"content-type":case"c":e.setHeader("content-type",u),a=e.parseHeader("content-type");break;case"cseq":e.setHeader("cseq",u),(a=e.parseHeader("cseq"))&&(e.cseq=a.value),e instanceof i.IncomingResponse&&(e.method=a.method);break;case"max-forwards":e.setHeader("max-forwards",u),a=e.parseHeader("max-forwards");break;case"www-authenticate":e.setHeader("www-authenticate",u),a=e.parseHeader("www-authenticate");break;case"proxy-authenticate":e.setHeader("proxy-authenticate",u),a=e.parseHeader("proxy-authenticate");break;case"session-expires":case"x":e.setHeader("session-expires",u),(a=e.parseHeader("session-expires"))&&(e.session_expires=a.expires,e.session_expires_refresher=a.refresher);break;case"refer-to":case"r":e.setHeader("refer-to",u),(a=e.parseHeader("refer-to"))&&(e.refer_to=a);break;case"replaces":e.setHeader("replaces",u),(a=e.parseHeader("replaces"))&&(e.replaces=a);break;case"event":case"o":e.setHeader("event",u),(a=e.parseHeader("event"))&&(e.event=a);break;default:e.setHeader(l,u),a=0}return void 0!==a||{error:'error parsing header "'+l+'"'}}},{"./Grammar":7,"./SIPMessage":19,debug:29}],12:[function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{},n=arguments[2];y("connect()");var r=e,i=t.eventHandlers||{},s=c.cloneArray(t.extraHeaders),a=t.mediaConstraints||{audio:!0,video:!0},u=t.mediaStream||null,d=t.pcConfig||{iceServers:[]},f=t.rtcConstraints||null,p=t.rtcOfferConstraints||null;if(this._rtcOfferConstraints=p,this._rtcAnswerConstraints=t.rtcAnswerConstraints||null,this._data=t.data||this._data,void 0===e)throw new TypeError("Not enough arguments");if(this._status!==C.STATUS_NULL)throw new l.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new l.NotSupportedError("WebRTC not supported");if(!(e=this._ua.normalizeTarget(e)))throw new TypeError("Invalid target: "+r);this._sessionTimers.enabled&&c.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=o.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=o.SESSION_EXPIRES);for(var _ in i)Object.prototype.hasOwnProperty.call(i,_)&&this.on(_,i[_]);this._from_tag=c.newTag();var v=t.anonymous||!1,m={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:v,outbound:!0}),v&&(m.from_display_name="Anonymous",m.from_uri="sip:anonymous@anonymous.invalid",s.push("P-Preferred-Identity: "+this._ua.configuration.uri.toString()),s.push("Privacy: id")),s.push("Contact: "+this._contact),s.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&s.push("Session-Expires: "+this._sessionTimers.defaultExpires),this._request=new h.InitialOutgoingInviteRequest(e,this._ua,m,s),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(d,f),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,n&&n(this),this._newRTCSession("local",this._request),this._sendInitialRequest(a,p,u)}},{key:"init_incoming",value:function(e,t){var n=this;y("init_incoming()");var r=void 0,i=e.getHeader("Content-Type");e.body&&"application/sdp"!==i?e.reply(415):(this._status=C.STATUS_INVITE_RECEIVED,this._from_tag=e.from_tag,this._id=e.call_id+this._from_tag,this._request=e,this._contact=this._ua.contact.toString(),e.hasHeader("expires")&&(r=1e3*e.getHeader("expires")),e.to_tag=c.newTag(),this._createDialog(e,"UAS",!0)?(e.body?this._late_sdp=!1:this._late_sdp=!0,this._status=C.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(function(){e.reply(408),n._failed("local",null,o.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),r&&(this._timers.expiresTimer=setTimeout(function(){n._status===C.STATUS_WAITING_FOR_ANSWER&&(e.reply(487),n._failed("system",null,o.causes.EXPIRES))},r)),this._direction="incoming",this._local_identity=e.to,this._remote_identity=e.from,t&&t(this),this._newRTCSession("remote",e),this._status!==C.STATUS_TERMINATED&&(e.reply(180,null,["Contact: "+this._contact]),this._progress("local",null))):e.reply(500,"Missing Contact header field"))}},{key:"answer",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};y("answer()");var n=this._request,r=c.cloneArray(t.extraHeaders),i=t.mediaConstraints||{},s=t.mediaStream||null,a=t.pcConfig||{iceServers:[]},u=t.rtcConstraints||null,d=t.rtcAnswerConstraints||null,h=void 0,f=!1,p=!1,_=!1,v=!1;if(this._rtcAnswerConstraints=d,this._rtcOfferConstraints=t.rtcOfferConstraints||null,this._data=t.data||this._data,"incoming"!==this._direction)throw new l.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==C.STATUS_WAITING_FOR_ANSWER)throw new l.InvalidStateError(this._status);if(this._sessionTimers.enabled&&c.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=o.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=o.SESSION_EXPIRES),this._status=C.STATUS_ANSWERED,this._createDialog(n,"UAS")){clearTimeout(this._timers.userNoAnswerTimer),r.unshift("Contact: "+this._contact);var m=n.parseSDP();Array.isArray(m.media)||(m.media=[m.media]);var g=!0,S=!1,E=void 0;try{for(var b,R=m.media[Symbol.iterator]();!(g=(b=R.next()).done);g=!0){var A=b.value;"audio"===A.type&&(f=!0,A.direction&&"sendrecv"!==A.direction||(_=!0)),"video"===A.type&&(p=!0,A.direction&&"sendrecv"!==A.direction||(v=!0))}}catch(e){S=!0,E=e}finally{try{!g&&R.return&&R.return()}finally{if(S)throw E}}if(s&&!1===i.audio){h=s.getAudioTracks();var w=!0,I=!1,k=void 0;try{for(var P,O=h[Symbol.iterator]();!(w=(P=O.next()).done);w=!0){var x=P.value;s.removeTrack(x)}}catch(e){I=!0,k=e}finally{try{!w&&O.return&&O.return()}finally{if(I)throw k}}}if(s&&!1===i.video){h=s.getVideoTracks();var D=!0,N=!1,U=void 0;try{for(var M,L=h[Symbol.iterator]();!(D=(M=L.next()).done);D=!0){var q=M.value;s.removeTrack(q)}}catch(e){N=!0,U=e}finally{try{!D&&L.return&&L.return()}finally{if(N)throw U}}}s||void 0!==i.audio||(i.audio=_),s||void 0!==i.video||(i.video=v),s||f||(i.audio=!1),s||p||(i.video=!1),this._createRTCConnection(a,u),Promise.resolve().then(function(){return s||(i.audio||i.video?(e._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(i).catch(function(t){if(e._status===C.STATUS_TERMINATED)throw new Error("terminated");throw n.reply(480),e._failed("local",null,o.causes.USER_DENIED_MEDIA_ACCESS),T('emit "getusermediafailed" [error:%o]',t),e.emit("getusermediafailed",t),new Error("getUserMedia() failed")})):void 0)}).then(function(t){if(e._status===C.STATUS_TERMINATED)throw new Error("terminated");e._localMediaStream=t,t&&e._connection.addStream(t)}).then(function(){if(!e._late_sdp){var t={originator:"remote",type:"offer",sdp:n.body};y('emit "sdp"'),e.emit("sdp",t);var r=new RTCSessionDescription({type:"offer",sdp:t.sdp});return e._connectionPromiseQueue=e._connectionPromiseQueue.then(function(){return e._connection.setRemoteDescription(r)}).catch(function(t){throw n.reply(488),e._failed("system",null,o.causes.WEBRTC_ERROR),T('emit "peerconnection:setremotedescriptionfailed" [error:%o]',t),e.emit("peerconnection:setremotedescriptionfailed",t),new Error("peerconnection.setRemoteDescription() failed")}),e._connectionPromiseQueue}}).then(function(){if(e._status===C.STATUS_TERMINATED)throw new Error("terminated");return e._connecting(n),e._late_sdp?e._createLocalDescription("offer",e._rtcOfferConstraints).catch(function(){throw n.reply(500),new Error("_createLocalDescription() failed")}):e._createLocalDescription("answer",d).catch(function(){throw n.reply(500),new Error("_createLocalDescription() failed")})}).then(function(t){if(e._status===C.STATUS_TERMINATED)throw new Error("terminated");e._handleSessionTimersInIncomingRequest(n,r),n.reply(200,null,r,t,function(){e._status=C.STATUS_WAITING_FOR_ACK,e._setInvite2xxTimer(n,t),e._setACKTimer(),e._accepted("local")},function(){e._failed("system",null,o.causes.CONNECTION_ERROR)})}).catch(function(t){e._status!==C.STATUS_TERMINATED&&T(t)})}else n.reply(500,"Error creating dialog")}},{key:"terminate",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};y("terminate()");var n=t.cause||o.causes.BYE,r=c.cloneArray(t.extraHeaders),i=t.body,s=void 0,a=t.status_code,d=t.reason_phrase;if(this._status===C.STATUS_TERMINATED)throw new l.InvalidStateError(this._status);switch(this._status){case C.STATUS_NULL:case C.STATUS_INVITE_SENT:case C.STATUS_1XX_RECEIVED:if(y("canceling session"),a&&(a<200||a>=700))throw new TypeError("Invalid status_code: "+a);a&&(s="SIP ;cause="+a+' ;text="'+(d=d||o.REASON_PHRASE[a]||"")+'"'),this._status===C.STATUS_NULL||this._status===C.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=s):this._status===C.STATUS_1XX_RECEIVED&&this._request.cancel(s),this._status=C.STATUS_CANCELED,this._failed("local",null,o.causes.CANCELED);break;case C.STATUS_WAITING_FOR_ANSWER:case C.STATUS_ANSWERED:if(y("rejecting session"),(a=a||480)<300||a>=700)throw new TypeError("Invalid status_code: "+a);this._request.reply(a,d,r,i),this._failed("local",null,o.causes.REJECTED);break;case C.STATUS_WAITING_FOR_ACK:case C.STATUS_CONFIRMED:if(y("terminating session"),d=t.reason_phrase||o.REASON_PHRASE[a]||"",a&&(a<200||a>=700))throw new TypeError("Invalid status_code: "+a);if(a&&r.push("Reason: SIP ;cause="+a+'; text="'+d+'"'),this._status===C.STATUS_WAITING_FOR_ACK&&"incoming"===this._direction&&this._request.server_transaction.state!==u.C.STATUS_TERMINATED){var h=this._dialog;this.receiveRequest=function(t){t.method===o.ACK&&(e.sendRequest(o.BYE,{extraHeaders:r,body:i}),h.terminate())},this._request.server_transaction.on("stateChanged",function(){e._request.server_transaction.state===u.C.STATUS_TERMINATED&&(e.sendRequest(o.BYE,{extraHeaders:r,body:i}),h.terminate())}),this._ended("local",null,n),this._dialog=h,this._ua.newDialog(h)}else this.sendRequest(o.BYE,{extraHeaders:r,body:i}),this._ended("local",null,n)}}},{key:"sendDTMF",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};y("sendDTMF() | tones: %s",e);var n=0,r=t.duration||null,i=t.interToneGap||null;if(void 0===e)throw new TypeError("Not enough arguments");if(this._status!==C.STATUS_CONFIRMED&&this._status!==C.STATUS_WAITING_FOR_ACK)throw new l.InvalidStateError(this._status);if("number"==typeof e&&(e=e.toString()),!e||"string"!=typeof e||!e.match(/^[0-9A-DR#*,]+$/i))throw new TypeError("Invalid tones: "+e);if(r&&!c.isDecimal(r))throw new TypeError("Invalid tone duration: "+r);if(r?r<_.C.MIN_DURATION?(y('"duration" value is lower than the minimum allowed, setting it to '+_.C.MIN_DURATION+" milliseconds"),r=_.C.MIN_DURATION):r>_.C.MAX_DURATION?(y('"duration" value is greater than the maximum allowed, setting it to '+_.C.MAX_DURATION+" milliseconds"),r=_.C.MAX_DURATION):r=Math.abs(r):r=_.C.DEFAULT_DURATION,t.duration=r,i&&!c.isDecimal(i))throw new TypeError("Invalid interToneGap: "+i);i?i<_.C.MIN_INTER_TONE_GAP?(y('"interToneGap" value is lower than the minimum allowed, setting it to '+_.C.MIN_INTER_TONE_GAP+" milliseconds"),i=_.C.MIN_INTER_TONE_GAP):i=Math.abs(i):i=_.C.DEFAULT_INTER_TONE_GAP,this._tones?this._tones+=e:(this._tones=e,function e(){var s=this;var a=void 0;if(this._status===C.STATUS_TERMINATED||!this._tones||n>=this._tones.length)return void(this._tones=null);var o=this._tones[n];n+=1;if(","===o)a=2e3;else{var l=new _(this);t.eventHandlers={onFailed:function(){s._tones=null}},l.send(o,t),a=r+i}setTimeout(e.bind(this),a)}.call(this))}},{key:"sendInfo",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(y("sendInfo()"),this._status!==C.STATUS_CONFIRMED&&this._status!==C.STATUS_WAITING_FOR_ACK)throw new l.InvalidStateError(this._status);new v(this).send(e,t,n)}},{key:"mute",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{audio:!0,video:!1};y("mute()");var t=!1,n=!1;!1===this._audioMuted&&e.audio&&(t=!0,this._audioMuted=!0,this._toogleMuteAudio(!0)),!1===this._videoMuted&&e.video&&(n=!0,this._videoMuted=!0,this._toogleMuteVideo(!0)),!0!==t&&!0!==n||this._onmute({audio:t,video:n})}},{key:"unmute",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{audio:!0,video:!0};y("unmute()");var t=!1,n=!1;!0===this._audioMuted&&e.audio&&(t=!0,this._audioMuted=!1,!1===this._localHold&&this._toogleMuteAudio(!1)),!0===this._videoMuted&&e.video&&(n=!0,this._videoMuted=!1,!1===this._localHold&&this._toogleMuteVideo(!1)),!0!==t&&!0!==n||this._onunmute({audio:t,video:n})}},{key:"hold",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];if(y("hold()"),this._status!==C.STATUS_WAITING_FOR_ACK&&this._status!==C.STATUS_CONFIRMED)return!1;if(!0===this._localHold)return!1;if(!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");var r={succeeded:function(){n&&n()},failed:function(){e.terminate({cause:o.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:r,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:r,extraHeaders:t.extraHeaders}),!0}},{key:"unhold",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];if(y("unhold()"),this._status!==C.STATUS_WAITING_FOR_ACK&&this._status!==C.STATUS_CONFIRMED)return!1;if(!1===this._localHold)return!1;if(!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");var r={succeeded:function(){n&&n()},failed:function(){e.terminate({cause:o.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:r,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:r,extraHeaders:t.extraHeaders}),!0}},{key:"renegotiate",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1];y("renegotiate()");var r=t.rtcOfferConstraints||null;if(this._status!==C.STATUS_WAITING_FOR_ACK&&this._status!==C.STATUS_CONFIRMED)return!1;if(!this._isReadyToReOffer())return!1;var i={succeeded:function(){n&&n()},failed:function(){e.terminate({cause:o.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:i,rtcOfferConstraints:r,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:i,rtcOfferConstraints:r,extraHeaders:t.extraHeaders}),!0}},{key:"refer",value:function(e,t){var n=this;y("refer()");var r=e;if(this._status!==C.STATUS_WAITING_FOR_ACK&&this._status!==C.STATUS_CONFIRMED)return!1;if(!(e=this._ua.normalizeTarget(e)))throw new TypeError("Invalid target: "+r);var i=new g(this);i.sendRefer(e,t);var s=i.id;return this._referSubscribers[s]=i,i.on("requestFailed",function(){delete n._referSubscribers[s]}),i.on("accepted",function(){delete n._referSubscribers[s]}),i.on("failed",function(){delete n._referSubscribers[s]}),i}},{key:"sendRequest",value:function(e,t){return y("sendRequest()"),this._dialog.sendRequest(e,t)}},{key:"receiveRequest",value:function(e){var t=this;if(y("receiveRequest()"),e.method===o.CANCEL)this._status!==C.STATUS_WAITING_FOR_ANSWER&&this._status!==C.STATUS_ANSWERED||(this._status=C.STATUS_CANCELED,this._request.reply(487),this._failed("remote",e,o.causes.CANCELED));else switch(e.method){case o.ACK:if(this._status!==C.STATUS_WAITING_FOR_ACK)return;if(this._status=C.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!e.body){this.terminate({cause:o.causes.MISSING_SDP,status_code:400});break}var n={originator:"remote",type:"answer",sdp:e.body};y('emit "sdp"'),this.emit("sdp",n);var r=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._connection.setRemoteDescription(r)}).then(function(){t._is_confirmed||t._confirmed("remote",e)}).catch(function(e){t.terminate({cause:o.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),T('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)})}else this._is_confirmed||this._confirmed("remote",e);break;case o.BYE:this._status===C.STATUS_CONFIRMED?(e.reply(200),this._ended("remote",e,o.causes.BYE)):this._status===C.STATUS_INVITE_RECEIVED?(e.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",e,o.causes.BYE)):e.reply(403,"Wrong Status");break;case o.INVITE:this._status===C.STATUS_CONFIRMED?e.hasHeader("replaces")?this._receiveReplaces(e):this._receiveReinvite(e):e.reply(403,"Wrong Status");break;case o.INFO:if(this._status===C.STATUS_1XX_RECEIVED||this._status===C.STATUS_WAITING_FOR_ANSWER||this._status===C.STATUS_ANSWERED||this._status===C.STATUS_WAITING_FOR_ACK||this._status===C.STATUS_CONFIRMED){var i=e.getHeader("content-type");i&&i.match(/^application\/dtmf-relay/i)?new _(this).init_incoming(e):void 0!==i?new v(this).init_incoming(e):e.reply(415)}else e.reply(403,"Wrong Status");break;case o.UPDATE:this._status===C.STATUS_CONFIRMED?this._receiveUpdate(e):e.reply(403,"Wrong Status");break;case o.REFER:this._status===C.STATUS_CONFIRMED?this._receiveRefer(e):e.reply(403,"Wrong Status");break;case o.NOTIFY:this._status===C.STATUS_CONFIRMED?this._receiveNotify(e):e.reply(403,"Wrong Status");break;default:e.reply(501)}}},{key:"onTransportError",value:function(){T("onTransportError()"),this._status!==C.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:o.causes.CONNECTION_ERROR,cause:o.causes.CONNECTION_ERROR})}},{key:"onRequestTimeout",value:function(){T("onRequestTimeout()"),this._status!==C.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:o.causes.REQUEST_TIMEOUT,cause:o.causes.REQUEST_TIMEOUT})}},{key:"onDialogError",value:function(){T("onDialogError()"),this._status!==C.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:o.causes.DIALOG_ERROR,cause:o.causes.DIALOG_ERROR})}},{key:"newDTMF",value:function(e){y("newDTMF()"),this.emit("newDTMF",e)}},{key:"newInfo",value:function(e){y("newInfo()"),this.emit("newInfo",e)}},{key:"_isReadyToReOffer",value:function(){return this._rtcReady?this._dialog?!0!==this._dialog.uac_pending_reply&&!0!==this._dialog.uas_pending_reply||(y("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):(y("_isReadyToReOffer() | session not established yet"),!1):(y("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}},{key:"_close",value:function(){if(y("close()"),this._status!==C.STATUS_TERMINATED){if(this._status=C.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(e){T("close() | error closing the RTCPeerConnection: %o",e)}this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(y("close() | closing local MediaStream"),c.closeMediaStream(this._localMediaStream));for(var e in this._timers)Object.prototype.hasOwnProperty.call(this._timers,e)&&clearTimeout(this._timers[e]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(var t in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,t)&&(this._earlyDialogs[t].terminate(),delete this._earlyDialogs[t]);for(var n in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,n)&&delete this._referSubscribers[n];this._ua.destroyRTCSession(this)}}},{key:"_setInvite2xxTimer",value:function(e,t){var n=d.T1;this._timers.invite2xxTimer=setTimeout(function r(){this._status===C.STATUS_WAITING_FOR_ACK&&(e.reply(200,null,["Contact: "+this._contact],t),nd.T2&&(n=d.T2),this._timers.invite2xxTimer=setTimeout(r.bind(this),n))}.bind(this),n)}},{key:"_setACKTimer",value:function(){var e=this;this._timers.ackTimer=setTimeout(function(){e._status===C.STATUS_WAITING_FOR_ACK&&(y("no ACK received, terminating the session"),clearTimeout(e._timers.invite2xxTimer),e.sendRequest(o.BYE),e._ended("remote",null,o.causes.NO_ACK))},d.TIMER_H)}},{key:"_createRTCConnection",value:function(e,t){var n=this;this._connection=new RTCPeerConnection(e,t),this._connection.addEventListener("iceconnectionstatechange",function(){"failed"===n._connection.iceConnectionState&&n.terminate({cause:o.causes.RTP_TIMEOUT,status_code:408,reason_phrase:o.causes.RTP_TIMEOUT})}),y('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}},{key:"_createLocalDescription",value:function(e,t){var n=this;if(y("createLocalDescription()"),"offer"!==e&&"answer"!==e)throw new Error('createLocalDescription() | invalid type "'+e+'"');var r=this._connection;return this._rtcReady=!1,Promise.resolve().then(function(){return"offer"===e?r.createOffer(t).catch(function(e){return T('emit "peerconnection:createofferfailed" [error:%o]',e),n.emit("peerconnection:createofferfailed",e),Promise.reject(e)}):r.createAnswer(t).catch(function(e){return T('emit "peerconnection:createanswerfailed" [error:%o]',e),n.emit("peerconnection:createanswerfailed",e),Promise.reject(e)})}).then(function(e){return r.setLocalDescription(e).catch(function(e){return n._rtcReady=!0,T('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',e),n.emit("peerconnection:setlocaldescriptionfailed",e),Promise.reject(e)})}).then(function(){if("complete"===r.iceGatheringState){n._rtcReady=!0;var t={originator:"local",type:e,sdp:r.localDescription.sdp};return y('emit "sdp"'),n.emit("sdp",t),Promise.resolve(t.sdp)}return new Promise(function(t){var i=!1,s=void 0,a=function(){r.removeEventListener("icecandidate",s),i=!0,n._rtcReady=!0;var a={originator:"local",type:e,sdp:r.localDescription.sdp};y('emit "sdp"'),n.emit("sdp",a),t(a.sdp)};r.addEventListener("icecandidate",s=function(e){var t=e.candidate;t?n.emit("icecandidate",{candidate:t,ready:a}):i||a()})})})}},{key:"_createDialog",value:function(e,t,n){var r="UAS"===t?e.to_tag:e.from_tag,i="UAS"===t?e.from_tag:e.to_tag,s=e.call_id+r+i,a=this._earlyDialogs[s];if(n)return!!a||((a=new f(this,e,t,f.C.STATUS_EARLY)).error?(y(a.error),this._failed("remote",e,o.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[s]=a,!0));if(this._from_tag=e.from_tag,this._to_tag=e.to_tag,a)return a.update(e,t),this._dialog=a,delete this._earlyDialogs[s],!0;var l=new f(this,e,t);return l.error?(y(l.error),this._failed("remote",e,o.causes.INTERNAL_ERROR),!1):(this._dialog=l,!0)}},{key:"_receiveReinvite",value:function(e){var t=this;y("receiveReinvite()");var n=e.getHeader("Content-Type"),r={request:e,callback:void 0,reject:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i=!0;var n=t.status_code||403,r=t.reason_phrase||"",s=c.cloneArray(t.extraHeaders);if(this._status!==C.STATUS_CONFIRMED)return!1;if(n<300||n>=700)throw new TypeError("Invalid status_code: "+n);e.reply(n,r,s)}.bind(this)},i=!1;if(this.emit("reinvite",r),!i){if(this._late_sdp=!1,!e.body)return this._late_sdp=!0,void(this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._createLocalDescription("offer",t._rtcOfferConstraints)}).then(function(e){s.call(t,e)}).catch(function(){e.reply(500)}));if("application/sdp"!==n)return y("invalid Content-Type"),void e.reply(415);this._processInDialogSdpOffer(e).then(function(e){t._status!==C.STATUS_TERMINATED&&s.call(t,e)}).catch(function(e){T(e)})}function s(t){var n=this,i=["Contact: "+this._contact];this._handleSessionTimersInIncomingRequest(e,i),this._late_sdp&&(t=this._mangleOffer(t)),e.reply(200,null,i,t,function(){n._status=C.STATUS_WAITING_FOR_ACK,n._setInvite2xxTimer(e,t),n._setACKTimer()}),"function"==typeof r.callback&&r.callback()}}},{key:"_receiveUpdate",value:function(e){var t=this;y("receiveUpdate()");var n=e.getHeader("Content-Type"),r={request:e,callback:void 0,reject:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i=!0;var n=t.status_code||403,r=t.reason_phrase||"",s=c.cloneArray(t.extraHeaders);if(this._status!==C.STATUS_CONFIRMED)return!1;if(n<300||n>=700)throw new TypeError("Invalid status_code: "+n);e.reply(n,r,s)}.bind(this)},i=!1;if(this.emit("update",r),!i)if(e.body){if("application/sdp"!==n)return y("invalid Content-Type"),void e.reply(415);this._processInDialogSdpOffer(e).then(function(e){t._status!==C.STATUS_TERMINATED&&s.call(t,e)}).catch(function(e){T(e)})}else s.call(this,null);function s(t){var n=["Contact: "+this._contact];this._handleSessionTimersInIncomingRequest(e,n),e.reply(200,null,n,t),"function"==typeof r.callback&&r.callback()}}},{key:"_processInDialogSdpOffer",value:function(e){var t=this;y("_processInDialogSdpOffer()");var n=e.parseSDP(),r=!1,i=!0,s=!1,a=void 0;try{for(var o,l=n.media[Symbol.iterator]();!(i=(o=l.next()).done);i=!0){var u=o.value;if(-1!==S.indexOf(u.type)){var c=u.direction||n.direction||"sendrecv";if("sendonly"!==c&&"inactive"!==c){r=!1;break}r=!0}}}catch(e){s=!0,a=e}finally{try{!i&&l.return&&l.return()}finally{if(s)throw a}}var d={originator:"remote",type:"offer",sdp:e.body};y('emit "sdp"'),this.emit("sdp",d);var h=new RTCSessionDescription({type:"offer",sdp:d.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){if(t._status===C.STATUS_TERMINATED)throw new Error("terminated");return t._connection.setRemoteDescription(h).catch(function(n){throw e.reply(488),T('emit "peerconnection:setremotedescriptionfailed" [error:%o]',n),t.emit("peerconnection:setremotedescriptionfailed",n),new Error("peerconnection.setRemoteDescription() failed")})}).then(function(){if(t._status===C.STATUS_TERMINATED)throw new Error("terminated");!0===t._remoteHold&&!1===r?(t._remoteHold=!1,t._onunhold("remote")):!1===t._remoteHold&&!0===r&&(t._remoteHold=!0,t._onhold("remote"))}).then(function(){if(t._status===C.STATUS_TERMINATED)throw new Error("terminated");return t._createLocalDescription("answer",t._rtcAnswerConstraints).catch(function(){throw e.reply(500),new Error("_createLocalDescription() failed")})}),this._connectionPromiseQueue}},{key:"_receiveRefer",value:function(e){var n=this;if(y("receiveRefer()"),void 0===r(e.refer_to))return y("no Refer-To header field present in REFER"),void e.reply(400);if(e.refer_to.uri.scheme!==o.SIP)return y("Refer-To header field points to a non-SIP URI scheme"),void e.reply(416);e.reply(202);var i=new m(this,e.cseq);y('emit "refer"'),this.emit("refer",{request:e,accept:function(r,s){(function(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(n="function"==typeof n?n:null,this._status!==C.STATUS_WAITING_FOR_ACK&&this._status!==C.STATUS_CONFIRMED)return!1;var s=new t(this._ua);if(s.on("progress",function(e){var t=e.response;i.notify(t.status_code,t.reason_phrase)}),s.on("accepted",function(e){var t=e.response;i.notify(t.status_code,t.reason_phrase)}),s.on("failed",function(e){var t=e.message,n=e.cause;t?i.notify(t.status_code,t.reason_phrase):i.notify(487,n)}),e.refer_to.uri.hasHeader("replaces")){var a=decodeURIComponent(e.refer_to.uri.getHeader("replaces"));r.extraHeaders=c.cloneArray(r.extraHeaders),r.extraHeaders.push("Replaces: "+a)}s.connect(e.refer_to.uri.toAor(),r,n)}).call(n,r,s)},reject:function(){(function(){i.notify(603)}).call(n)}})}},{key:"_receiveNotify",value:function(e){switch(y("receiveNotify()"),void 0===r(e.event)&&e.reply(400),e.event.event){case"refer":var t=void 0,n=void 0;if(e.event.params&&e.event.params.id)t=e.event.params.id,n=this._referSubscribers[t];else{if(1!==Object.keys(this._referSubscribers).length)return void e.reply(400,"Missing event id parameter");n=this._referSubscribers[Object.keys(this._referSubscribers)[0]]}if(!n)return void e.reply(481,"Subscription does not exist");n.receiveNotify(e),e.reply(200);break;default:e.reply(489)}}},{key:"_receiveReplaces",value:function(e){var n=this;y("receiveReplaces()");this.emit("replaces",{request:e,accept:function(r){(function(n){var r=this;if(this._status!==C.STATUS_WAITING_FOR_ACK&&this._status!==C.STATUS_CONFIRMED)return!1;var i=new t(this._ua);i.on("confirmed",function(){r.terminate()}),i.init_incoming(e,n)}).call(n,r)},reject:function(){(function(){y("Replaced INVITE rejected by the user"),e.reply(486)}).call(n)}})}},{key:"_sendInitialRequest",value:function(e,t,n){var r=this,i=new p(this._ua,this._request,{onRequestTimeout:function(){r.onRequestTimeout()},onTransportError:function(){r.onTransportError()},onAuthenticated:function(e){r._request=e},onReceiveResponse:function(e){r._receiveInviteResponse(e)}});Promise.resolve().then(function(){return n||(e.audio||e.video?(r._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(e).catch(function(e){if(r._status===C.STATUS_TERMINATED)throw new Error("terminated");throw r._failed("local",null,o.causes.USER_DENIED_MEDIA_ACCESS),T('emit "getusermediafailed" [error:%o]',e),r.emit("getusermediafailed"),e})):void 0)}).then(function(e){if(r._status===C.STATUS_TERMINATED)throw new Error("terminated");return r._localMediaStream=e,e&&r._connection.addStream(e),r._connecting(r._request),r._createLocalDescription("offer",t).catch(function(e){throw r._failed("local",null,o.causes.WEBRTC_ERROR),e})}).then(function(e){if(r._is_canceled||r._status===C.STATUS_TERMINATED)throw new Error("terminated");r._request.body=e,r._status=C.STATUS_INVITE_SENT,y('emit "sending" [request:%o]',r._request),r.emit("sending",{request:r._request}),i.send()}).catch(function(e){r._status!==C.STATUS_TERMINATED&&T(e)})}},{key:"_receiveInviteResponse",value:function(e){var t=this;if(y("receiveInviteResponse()"),this._dialog&&e.status_code>=200&&e.status_code<=299){if(this._dialog.id.call_id===e.call_id&&this._dialog.id.local_tag===e.from_tag&&this._dialog.id.remote_tag===e.to_tag)return void this.sendRequest(o.ACK);var n=new f(this,e,"UAC");return void 0!==n.error?void y(n.error):(this.sendRequest(o.ACK),void this.sendRequest(o.BYE))}if(this._is_canceled)e.status_code>=100&&e.status_code<200?this._request.cancel(this._cancel_reason):e.status_code>=200&&e.status_code<299&&this._acceptAndTerminate(e);else if(this._status===C.STATUS_INVITE_SENT||this._status===C.STATUS_1XX_RECEIVED)switch(!0){case/^100$/.test(e.status_code):this._status=C.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(e.status_code):if(!e.to_tag){y("1xx response received without to tag");break}if(e.hasHeader("contact")&&!this._createDialog(e,"UAC",!0))break;if(this._status=C.STATUS_1XX_RECEIVED,this._progress("remote",e),!e.body)break;var r={originator:"remote",type:"answer",sdp:e.body};y('emit "sdp"'),this.emit("sdp",r);var i=new RTCSessionDescription({type:"answer",sdp:r.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._connection.setRemoteDescription(i)}).catch(function(e){T('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)});break;case/^2[0-9]{2}$/.test(e.status_code):if(this._status=C.STATUS_CONFIRMED,!e.body){this._acceptAndTerminate(e,400,o.causes.MISSING_SDP),this._failed("remote",e,o.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(e,"UAC"))break;var s={originator:"remote",type:"answer",sdp:e.body};y('emit "sdp"'),this.emit("sdp",s);var a=new RTCSessionDescription({type:"answer",sdp:s.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){if("stable"===t._connection.signalingState)return t._connection.createOffer().then(function(e){return t._connection.setLocalDescription(e)}).catch(function(n){t._acceptAndTerminate(e,500,n.toString()),t._failed("local",e,o.causes.WEBRTC_ERROR)})}).then(function(){t._connection.setRemoteDescription(a).then(function(){t._handleSessionTimersInIncomingResponse(e),t._accepted("remote",e),t.sendRequest(o.ACK),t._confirmed("local",null)}).catch(function(n){t._acceptAndTerminate(e,488,"Not Acceptable Here"),t._failed("remote",e,o.causes.BAD_MEDIA_DESCRIPTION),T('emit "peerconnection:setremotedescriptionfailed" [error:%o]',n),t.emit("peerconnection:setremotedescriptionfailed",n)})});break;default:var l=c.sipErrorCause(e.status_code);this._failed("remote",e,l)}}},{key:"_sendReinvite",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};y("sendReinvite()");var n=c.cloneArray(t.extraHeaders),r=t.eventHandlers||{},i=t.rtcOfferConstraints||this._rtcOfferConstraints||null,s=!1;n.push("Contact: "+this._contact),n.push("Content-Type: application/sdp"),this._sessionTimers.running&&n.push("Session-Expires: "+this._sessionTimers.currentExpires+";refresher="+(this._sessionTimers.refresher?"uac":"uas")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return e._createLocalDescription("offer",i)}).then(function(t){t=e._mangleOffer(t),e.sendRequest(o.INVITE,{extraHeaders:n,body:t,eventHandlers:{onSuccessResponse:function(t){(function(e){var t=this;if(this._status===C.STATUS_TERMINATED)return;if(this.sendRequest(o.ACK),s)return;{if(this._handleSessionTimersInIncomingResponse(e),!e.body)return void a.call(this);if("application/sdp"!==e.getHeader("Content-Type"))return void a.call(this)}var n={originator:"remote",type:"answer",sdp:e.body};y('emit "sdp"'),this.emit("sdp",n);var i=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._connection.setRemoteDescription(i)}).then(function(){r.succeeded&&r.succeeded(e)}).catch(function(e){a.call(t),T('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)})}).call(e,t),s=!0},onErrorResponse:function(t){a.call(e,t)},onTransportError:function(){e.onTransportError()},onRequestTimeout:function(){e.onRequestTimeout()},onDialogError:function(){e.onDialogError()}}})}).catch(function(){a()});function a(e){r.failed&&r.failed(e)}}},{key:"_sendUpdate",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};y("sendUpdate()");var n=c.cloneArray(t.extraHeaders),r=t.eventHandlers||{},i=t.rtcOfferConstraints||this._rtcOfferConstraints||null,s=t.sdpOffer||!1,a=!1;n.push("Contact: "+this._contact),this._sessionTimers.running&&n.push("Session-Expires: "+this._sessionTimers.currentExpires+";refresher="+(this._sessionTimers.refresher?"uac":"uas")),s?(n.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return e._createLocalDescription("offer",i)}).then(function(t){t=e._mangleOffer(t),e.sendRequest(o.UPDATE,{extraHeaders:n,body:t,eventHandlers:{onSuccessResponse:function(t){l.call(e,t),a=!0},onErrorResponse:function(t){u.call(e,t)},onTransportError:function(){e.onTransportError()},onRequestTimeout:function(){e.onRequestTimeout()},onDialogError:function(){e.onDialogError()}}})}).catch(function(){u.call(e)})):this.sendRequest(o.UPDATE,{extraHeaders:n,eventHandlers:{onSuccessResponse:function(t){l.call(e,t)},onErrorResponse:function(t){u.call(e,t)},onTransportError:function(){e.onTransportError()},onRequestTimeout:function(){e.onRequestTimeout()},onDialogError:function(){e.onDialogError()}}});function l(e){var t=this;if(this._status!==C.STATUS_TERMINATED&&!a)if(this._handleSessionTimersInIncomingResponse(e),s){if(!e.body)return void u.call(this);if("application/sdp"!==e.getHeader("Content-Type"))return void u.call(this);var n={originator:"remote",type:"answer",sdp:e.body};y('emit "sdp"'),this.emit("sdp",n);var i=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._connection.setRemoteDescription(i)}).then(function(){r.succeeded&&r.succeeded(e)}).catch(function(e){u.call(t),T('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)})}else r.succeeded&&r.succeeded(e)}function u(e){r.failed&&r.failed(e)}}},{key:"_acceptAndTerminate",value:function(e,t,n){y("acceptAndTerminate()");var r=[];t&&(n=n||o.REASON_PHRASE[t]||"",r.push("Reason: SIP ;cause="+t+'; text="'+n+'"')),(this._dialog||this._createDialog(e,"UAC"))&&(this.sendRequest(o.ACK),this.sendRequest(o.BYE,{extraHeaders:r})),this._status=C.STATUS_TERMINATED}},{key:"_mangleOffer",value:function(e){if(!this._localHold&&!this._remoteHold)return e;if(e=a.parse(e),this._localHold&&!this._remoteHold){y("mangleOffer() | me on hold, mangling offer");var t=!0,n=!1,r=void 0;try{for(var i,s=e.media[Symbol.iterator]();!(t=(i=s.next()).done);t=!0){var o=i.value;-1!==S.indexOf(o.type)&&(o.direction?"sendrecv"===o.direction?o.direction="sendonly":"recvonly"===o.direction&&(o.direction="inactive"):o.direction="sendonly")}}catch(e){n=!0,r=e}finally{try{!t&&s.return&&s.return()}finally{if(n)throw r}}}else if(this._localHold&&this._remoteHold){y("mangleOffer() | both on hold, mangling offer");var l=!0,u=!1,c=void 0;try{for(var d,h=e.media[Symbol.iterator]();!(l=(d=h.next()).done);l=!0){var f=d.value;-1!==S.indexOf(f.type)&&(f.direction="inactive")}}catch(e){u=!0,c=e}finally{try{!l&&h.return&&h.return()}finally{if(u)throw c}}}else if(this._remoteHold){y("mangleOffer() | remote on hold, mangling offer");var p=!0,_=!1,v=void 0;try{for(var m,g=e.media[Symbol.iterator]();!(p=(m=g.next()).done);p=!0){var T=m.value;-1!==S.indexOf(T.type)&&(T.direction?"sendrecv"===T.direction?T.direction="recvonly":"recvonly"===T.direction&&(T.direction="inactive"):T.direction="recvonly")}}catch(e){_=!0,v=e}finally{try{!p&&g.return&&g.return()}finally{if(_)throw v}}}return a.write(e)}},{key:"_setLocalMediaStatus",value:function(){var e=!0,t=!0;(this._localHold||this._remoteHold)&&(e=!1,t=!1),this._audioMuted&&(e=!1),this._videoMuted&&(t=!1),this._toogleMuteAudio(!e),this._toogleMuteVideo(!t)}},{key:"_handleSessionTimersInIncomingRequest",value:function(e,t){if(this._sessionTimers.enabled){var n=void 0;e.session_expires&&e.session_expires>=o.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=e.session_expires,n=e.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,n="uas"),t.push("Session-Expires: "+this._sessionTimers.currentExpires+";refresher="+n),this._sessionTimers.refresher="uas"===n,this._runSessionTimer()}}},{key:"_handleSessionTimersInIncomingResponse",value:function(e){if(this._sessionTimers.enabled){var t=void 0;e.session_expires&&e.session_expires>=o.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=e.session_expires,t=e.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,t="uac"),this._sessionTimers.refresher="uac"===t,this._runSessionTimer()}}},{key:"_runSessionTimer",value:function(){var e=this,t=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(function(){e._status!==C.STATUS_TERMINATED&&(y("runSessionTimer() | sending session refresh request"),e._sessionTimers.refreshMethod===o.UPDATE?e._sendUpdate():e._sendReinvite())},500*t):this._sessionTimers.timer=setTimeout(function(){e._status!==C.STATUS_TERMINATED&&(T("runSessionTimer() | timer expired, terminating the session"),e.terminate({cause:o.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},1100*t)}},{key:"_toogleMuteAudio",value:function(e){var t=this._connection.getLocalStreams(),n=!0,r=!1,i=void 0;try{for(var s,a=t[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var o=s.value.getAudioTracks(),l=!0,u=!1,c=void 0;try{for(var d,h=o[Symbol.iterator]();!(l=(d=h.next()).done);l=!0){d.value.enabled=!e}}catch(e){u=!0,c=e}finally{try{!l&&h.return&&h.return()}finally{if(u)throw c}}}}catch(e){r=!0,i=e}finally{try{!n&&a.return&&a.return()}finally{if(r)throw i}}}},{key:"_toogleMuteVideo",value:function(e){var t=this._connection.getLocalStreams(),n=!0,r=!1,i=void 0;try{for(var s,a=t[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var o=s.value.getVideoTracks(),l=!0,u=!1,c=void 0;try{for(var d,h=o[Symbol.iterator]();!(l=(d=h.next()).done);l=!0){d.value.enabled=!e}}catch(e){u=!0,c=e}finally{try{!l&&h.return&&h.return()}finally{if(u)throw c}}}}catch(e){r=!0,i=e}finally{try{!n&&a.return&&a.return()}finally{if(r)throw i}}}},{key:"_newRTCSession",value:function(e,t){y("newRTCSession()"),this._ua.newRTCSession(this,{originator:e,session:this,request:t})}},{key:"_connecting",value:function(e){y("session connecting"),y('emit "connecting"'),this.emit("connecting",{request:e})}},{key:"_progress",value:function(e,t){y("session progress"),y('emit "progress"'),this.emit("progress",{originator:e,response:t||null})}},{key:"_accepted",value:function(e,t){y("session accepted"),this._start_time=new Date,y('emit "accepted"'),this.emit("accepted",{originator:e,response:t||null})}},{key:"_confirmed",value:function(e,t){y("session confirmed"),this._is_confirmed=!0,y('emit "confirmed"'),this.emit("confirmed",{originator:e,ack:t||null})}},{key:"_ended",value:function(e,t,n){y("session ended"),this._end_time=new Date,this._close(),y('emit "ended"'),this.emit("ended",{originator:e,message:t||null,cause:n})}},{key:"_failed",value:function(e,t,n){y("session failed"),this._close(),y('emit "failed"'),this.emit("failed",{originator:e,message:t||null,cause:n})}},{key:"_onhold",value:function(e){y("session onhold"),this._setLocalMediaStatus(),y('emit "hold"'),this.emit("hold",{originator:e})}},{key:"_onunhold",value:function(e){y("session onunhold"),this._setLocalMediaStatus(),y('emit "unhold"'),this.emit("unhold",{originator:e})}},{key:"_onmute",value:function(e){var t=e.audio,n=e.video;y("session onmute"),this._setLocalMediaStatus(),y('emit "muted"'),this.emit("muted",{audio:t,video:n})}},{key:"_onunmute",value:function(e){var t=e.audio,n=e.video;y("session onunmute"),this._setLocalMediaStatus(),y('emit "unmuted"'),this.emit("unmuted",{audio:t,video:n})}},{key:"C",get:function(){return C}},{key:"causes",get:function(){return o.causes}},{key:"id",get:function(){return this._id}},{key:"connection",get:function(){return this._connection}},{key:"direction",get:function(){return this._direction}},{key:"local_identity",get:function(){return this._local_identity}},{key:"remote_identity",get:function(){return this._remote_identity}},{key:"start_time",get:function(){return this._start_time}},{key:"end_time",get:function(){return this._end_time}},{key:"data",get:function(){return this._data},set:function(e){this._data=e}},{key:"status",get:function(){return this._status}}]),t}()},{"./Constants":2,"./Dialog":3,"./Exceptions":6,"./RTCSession/DTMF":13,"./RTCSession/Info":14,"./RTCSession/ReferNotifier":15,"./RTCSession/ReferSubscriber":16,"./RequestSender":18,"./SIPMessage":19,"./Timers":21,"./Transactions":22,"./Utils":26,debug:29,events:31,"sdp-transform":36}],13:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};if(void 0===e)throw new TypeError("Not enough arguments");if(this._direction="outgoing",this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK)throw new a.InvalidStateError(this._session.status);var r=o.cloneArray(n.extraHeaders);if(this.eventHandlers=n.eventHandlers||{},"string"==typeof e)e=e.toUpperCase();else{if("number"!=typeof e)throw new TypeError("Invalid tone: "+e);e=e.toString()}if(!e.match(/^[0-9A-DR#*]$/))throw new TypeError("Invalid tone: "+e);this._tone=e,this._duration=n.duration,r.push("Content-Type: application/dtmf-relay");var i="Signal="+this._tone+"\r\n";i+="Duration="+this._duration,this._session.newDTMF({originator:"local",dtmf:this,request:this._request}),this._session.sendRequest(s.INFO,{extraHeaders:r,eventHandlers:{onSuccessResponse:function(e){t.emit("succeeded",{originator:"remote",response:e})},onErrorResponse:function(e){t.eventHandlers.onFailed&&t.eventHandlers.onFailed(),t.emit("failed",{originator:"remote",response:e})},onRequestTimeout:function(){t._session.onRequestTimeout()},onTransportError:function(){t._session.onTransportError()},onDialogError:function(){t._session.onDialogError()}},body:i})}},{key:"init_incoming",value:function(e){var t=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,n=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;if(this._direction="incoming",this._request=e,e.reply(200),e.body){var r=e.body.split("\n");r.length>=1&&t.test(r[0])&&(this._tone=r[0].replace(t,"$2")),r.length>=2&&n.test(r[1])&&(this._duration=parseInt(r[1].replace(n,"$2"),10))}this._duration||(this._duration=u.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:e}):l("invalid INFO DTMF received, discarded")}},{key:"tone",get:function(){return this._tone}},{key:"duration",get:function(){return this._duration}}]),t}(),t.exports.C=u},{"../Constants":2,"../Exceptions":6,"../Utils":26,debug:29,events:31}],14:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:{};if(this._direction="outgoing",void 0===e)throw new TypeError("Not enough arguments");if(this._session.status!==this._session.C.STATUS_CONFIRMED&&this._session.status!==this._session.C.STATUS_WAITING_FOR_ACK)throw new a.InvalidStateError(this._session.status);this._contentType=e,this._body=t;var i=o.cloneArray(r.extraHeaders);i.push("Content-Type: "+e),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(s.INFO,{extraHeaders:i,eventHandlers:{onSuccessResponse:function(e){n.emit("succeeded",{originator:"remote",response:e})},onErrorResponse:function(e){n.emit("failed",{originator:"remote",response:e})},onTransportError:function(){n._session.onTransportError()},onRequestTimeout:function(){n._session.onRequestTimeout()},onDialogError:function(){n._session.onDialogError()}},body:t})}},{key:"init_incoming",value:function(e){this._direction="incoming",this.request=e,e.reply(200),this._contentType=e.getHeader("content-type"),this._body=e.body,this._session.newInfo({originator:"remote",info:this,request:e})}},{key:"contentType",get:function(){return this._contentType}},{key:"body",get:function(){return this._body}}]),t}()},{"../Constants":2,"../Exceptions":6,"../Utils":26,debug:29,events:31}],15:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n=200?"terminated;reason=noresource":"active;expires="+this._expires,this._session.sendRequest(i.NOTIFY,{extraHeaders:["Event: "+a.event_type+";id="+this._id,"Subscription-State: "+n,"Content-Type: "+a.body_type],body:"SIP/2.0 "+e+" "+t,eventHandlers:{onErrorResponse:function(){this._active=!1}}})}}}]),e}()},{"../Constants":2,debug:29}],16:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};l("sendRefer()");var r=o.cloneArray(n.extraHeaders),i=n.eventHandlers||{};for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&this.on(a,i[a]);var u=null;n.replaces&&(u=n.replaces._request.call_id,u+=";to-tag="+n.replaces._to_tag,u+=";from-tag="+n.replaces._from_tag,u=encodeURIComponent(u));var c="Refer-To: <"+e+(u?"?Replaces="+u:"")+">";r.push(c);var d=this._session.sendRequest(s.REFER,{extraHeaders:r,eventHandlers:{onSuccessResponse:function(e){t._requestSucceeded(e)},onErrorResponse:function(e){t._requestFailed(e,s.causes.REJECTED)},onTransportError:function(){t._requestFailed(null,s.causes.CONNECTION_ERROR)},onRequestTimeout:function(){t._requestFailed(null,s.causes.REQUEST_TIMEOUT)},onDialogError:function(){t._requestFailed(null,s.causes.DIALOG_ERROR)}}});this._id=d.cseq}},{key:"receiveNotify",value:function(e){if(l("receiveNotify()"),e.body){var t=a.parse(e.body.trim(),"Status_Line");if(-1!==t)switch(!0){case/^100$/.test(t.status_code):this.emit("trying",{request:e,status_line:t});break;case/^1[0-9]{2}$/.test(t.status_code):this.emit("progress",{request:e,status_line:t});break;case/^2[0-9]{2}$/.test(t.status_code):this.emit("accepted",{request:e,status_line:t});break;default:this.emit("failed",{request:e,status_line:t})}else l('receiveNotify() | error parsing NOTIFY body: "'+e.body+'"')}}},{key:"_requestSucceeded",value:function(e){l("REFER succeeded"),l('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:e})}},{key:"_requestFailed",value:function(e,t){l("REFER failed"),l('emit "requestFailed"'),this.emit("requestFailed",{response:e||null,cause:t})}},{key:"id",get:function(){return this._id}}]),t}()},{"../Constants":2,"../Grammar":7,"../Utils":26,debug:29,events:31}],17:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n"'}return r(e,[{key:"setExtraHeaders",value:function(e){Array.isArray(e)||(e=[]),this._extraHeaders=e.slice()}},{key:"setExtraContactParams",value:function(e){e instanceof Object||(e={}),this._extraContactParams="";for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var n=e[t];this._extraContactParams+=";"+t,n&&(this._extraContactParams+="="+n)}}},{key:"register",value:function(){var e=this;if(this._registering)l("Register request in progress...");else{var t=this._extraHeaders.slice();t.push("Contact: "+this._contact+";expires="+this._expires+this._extraContactParams),t.push("Expires: "+this._expires);var n=new a.OutgoingRequest(s.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},t),r=new o(this._ua,n,{onRequestTimeout:function(){e._registrationFailure(null,s.causes.REQUEST_TIMEOUT)},onTransportError:function(){e._registrationFailure(null,s.causes.CONNECTION_ERROR)},onAuthenticated:function(){e._cseq+=1},onReceiveResponse:function(t){var n=void 0,r=void 0,a=t.getHeaders("contact").length;if(t.cseq===e._cseq)switch(null!==e._registrationTimer&&(clearTimeout(e._registrationTimer),e._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(t.status_code):break;case/^2[0-9]{2}$/.test(t.status_code):if(e._registering=!1,!a){l("no Contact header in response to REGISTER, response ignored");break}for(;a--;){if((n=t.parseHeader("contact",a)).uri.user===e._ua.contact.uri.user){r=n.getParam("expires");break}n=null}if(!n){l("no Contact header pointing to us, response ignored");break}!r&&t.hasHeader("expires")&&(r=t.getHeader("expires")),r||(r=e._expires),(r=Number(r))<10&&(r=10),e._registrationTimer=setTimeout(function(){e._registrationTimer=null,0===e._ua.listeners("registrationExpiring").length?e.register():e._ua.emit("registrationExpiring")},1e3*r-5e3),n.hasParam("temp-gruu")&&(e._ua.contact.temp_gruu=n.getParam("temp-gruu").replace(/"/g,"")),n.hasParam("pub-gruu")&&(e._ua.contact.pub_gruu=n.getParam("pub-gruu").replace(/"/g,"")),e._registered||(e._registered=!0,e._ua.registered({response:t}));break;case/^423$/.test(t.status_code):t.hasHeader("min-expires")?(e._expires=Number(t.getHeader("min-expires")),e._expires<10&&(e._expires=10),e.register()):(l("423 response received for REGISTER without Min-Expires"),e._registrationFailure(t,s.causes.SIP_FAILURE_CODE));break;default:var o=i.sipErrorCause(t.status_code);e._registrationFailure(t,o)}}});this._registering=!0,r.send()}}},{key:"unregister",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this._registered){this._registered=!1,null!==this._registrationTimer&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);var n=this._extraHeaders.slice();t.all?n.push("Contact: *"+this._extraContactParams):n.push("Contact: "+this._contact+";expires=0"+this._extraContactParams),n.push("Expires: 0");var r=new a.OutgoingRequest(s.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},n);new o(this._ua,r,{onRequestTimeout:function(){e._unregistered(null,s.causes.REQUEST_TIMEOUT)},onTransportError:function(){e._unregistered(null,s.causes.CONNECTION_ERROR)},onAuthenticated:function(){e._cseq+=1},onReceiveResponse:function(t){switch(!0){case/^1[0-9]{2}$/.test(t.status_code):break;case/^2[0-9]{2}$/.test(t.status_code):e._unregistered(t);break;default:var n=i.sipErrorCause(t.status_code);e._unregistered(t,n)}}}).send()}else l("already unregistered")}},{key:"close",value:function(){this._registered&&this.unregister()}},{key:"onTransportClosed",value:function(){this._registering=!1,null!==this._registrationTimer&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),this._registered&&(this._registered=!1,this._ua.unregistered({}))}},{key:"_registrationFailure",value:function(e,t){this._registering=!1,this._ua.registrationFailed({response:e||null,cause:t}),this._registered&&(this._registered=!1,this._ua.unregistered({response:e||null,cause:t}))}},{key:"_unregistered",value:function(e,t){this._registering=!1,this._registered=!1,this._ua.unregistered({response:e||null,cause:t||null})}},{key:"registered",get:function(){return this._registered}}]),e}()},{"./Constants":2,"./RequestSender":18,"./SIPMessage":19,"./Utils":26,debug:29}],18:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n"),this.setHeader("via",""),this.setHeader("max-forwards",l.MAX_FORWARDS);var d=i.to_display_name||0===i.to_display_name?'"'+i.to_display_name+'" ':"";d+="<"+(i.to_uri||n)+">",d+=i.to_tag?";tag="+i.to_tag:"",this.to=c.parse(d),this.setHeader("to",d);var h=void 0;h=i.from_display_name||0===i.from_display_name?'"'+i.from_display_name+'" ':r.configuration.display_name?'"'+r.configuration.display_name+'" ':"",h+="<"+(i.from_uri||r.configuration.uri)+">;tag=",h+=i.from_tag||u.newTag(),this.from=c.parse(h),this.setHeader("from",h);var f=i.call_id||r.configuration.jssip_id+u.createRandomToken(15);this.call_id=f,this.setHeader("call-id",f);var p=i.cseq||Math.floor(1e4*Math.random());this.cseq=p,this.setHeader("cseq",p+" "+t)}return r(e,[{key:"setHeader",value:function(e,t){for(var n=new RegExp("^\\s*"+e+"\\s*:","i"),r=0;r1&&void 0!==arguments[1]?arguments[1]:0;if(e=u.headerize(e),this.headers[e]){if(!(t>=this.headers[e].length)){var n=this.headers[e][t],r=n.raw;if(n.parsed)return n.parsed;var i=d.parse(r,e.replace(/-/g,"_"));return-1===i?(this.headers[e].splice(t,1),void h('error parsing "'+e+'" header field with value "'+r+'"')):(n.parsed=i,i)}h('not so many "'+e+'" headers present')}else h('header "'+e+'" not present')}},{key:"s",value:function(e,t){return this.parseHeader(e,t)}},{key:"setHeader",value:function(e,t){var n={raw:t};this.headers[u.headerize(e)]=[n]}},{key:"parseSDP",value:function(e){return!e&&this.sdp?this.sdp:(this.sdp=o.parse(this.body||""),this.sdp)}},{key:"toString",value:function(){return this.data}}]),e}(),v=function(e){s(t,_);function t(e){a(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.ua=e,n.headers={},n.ruri=null,n.transport=null,n.server_transaction=null,n}return r(t,[{key:"reply",value:function(e,t,n,r,i,s){var a=[],o=this.getHeader("To");if(e=e||null,t=t||null,!e||e<100||e>699)throw new TypeError("Invalid status_code: "+e);if(t&&"string"!=typeof t&&!(t instanceof String))throw new TypeError("Invalid reason_phrase: "+t);t=t||l.REASON_PHRASE[e]||"",n=u.cloneArray(n);var c="SIP/2.0 "+e+" "+t+"\r\n";if(this.method===l.INVITE&&e>100&&e<=200){var d=this.getHeaders("record-route"),h=!0,f=!1,p=void 0;try{for(var _,v=d[Symbol.iterator]();!(h=(_=v.next()).done);h=!0){c+="Record-Route: "+_.value+"\r\n"}}catch(e){f=!0,p=e}finally{try{!h&&v.return&&v.return()}finally{if(f)throw p}}}var m=this.getHeaders("via"),g=!0,y=!1,T=void 0;try{for(var C,S=m[Symbol.iterator]();!(g=(C=S.next()).done);g=!0){c+="Via: "+C.value+"\r\n"}}catch(e){y=!0,T=e}finally{try{!g&&S.return&&S.return()}finally{if(y)throw T}}!this.to_tag&&e>100?o+=";tag="+u.newTag():this.to_tag&&!this.s("to").hasParam("tag")&&(o+=";tag="+this.to_tag),c+="To: "+o+"\r\n",c+="From: "+this.getHeader("From")+"\r\n",c+="Call-ID: "+this.call_id+"\r\n",c+="CSeq: "+this.cseq+" "+this.method+"\r\n";var E=!0,b=!1,R=void 0;try{for(var A,w=n[Symbol.iterator]();!(E=(A=w.next()).done);E=!0){c+=A.value.trim()+"\r\n"}}catch(e){b=!0,R=e}finally{try{!E&&w.return&&w.return()}finally{if(b)throw R}}switch(this.method){case l.INVITE:this.ua.configuration.session_timers&&a.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&a.push("gruu"),a.push("ice","replaces");break;case l.UPDATE:this.ua.configuration.session_timers&&a.push("timer"),r&&a.push("ice"),a.push("replaces")}if(a.push("outbound"),this.method===l.OPTIONS?(c+="Allow: "+l.ALLOWED_METHODS+"\r\n",c+="Accept: "+l.ACCEPTED_BODY_TYPES+"\r\n"):405===e?c+="Allow: "+l.ALLOWED_METHODS+"\r\n":415===e&&(c+="Accept: "+l.ACCEPTED_BODY_TYPES+"\r\n"),c+="Supported: "+a+"\r\n",r){c+="Content-Type: application/sdp\r\n",c+="Content-Length: "+u.str_utf8_length(r)+"\r\n\r\n",c+=r}else c+="Content-Length: 0\r\n\r\n";this.server_transaction.receiveResponse(e,c,i,s)}},{key:"reply_sl",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this.getHeaders("via");if(!e||e<100||e>699)throw new TypeError("Invalid status_code: "+e);if(t&&"string"!=typeof t&&!(t instanceof String))throw new TypeError("Invalid reason_phrase: "+t);var r="SIP/2.0 "+e+" "+(t=t||l.REASON_PHRASE[e]||"")+"\r\n",i=!0,s=!1,a=void 0;try{for(var o,c=n[Symbol.iterator]();!(i=(o=c.next()).done);i=!0){r+="Via: "+o.value+"\r\n"}}catch(e){s=!0,a=e}finally{try{!i&&c.return&&c.return()}finally{if(s)throw a}}var d=this.getHeader("To");!this.to_tag&&e>100?d+=";tag="+u.newTag():this.to_tag&&!this.s("to").hasParam("tag")&&(d+=";tag="+this.to_tag),r+="To: "+d+"\r\n",r+="From: "+this.getHeader("From")+"\r\n",r+="Call-ID: "+this.call_id+"\r\n",r+="CSeq: "+this.cseq+" "+this.method+"\r\n",r+="Content-Length: 0\r\n\r\n",this.transport.send(r)}}]),t}(),m=function(e){s(t,_);function t(){a(this,t);var e=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.headers={},e.status_code=null,e.reason_phrase=null,e}return t}();t.exports={OutgoingRequest:f,InitialOutgoingInviteRequest:p,IncomingRequest:v,IncomingResponse:m}},{"./Constants":2,"./Grammar":7,"./NameAddrHeader":10,"./Utils":26,debug:29,"sdp-transform":36}],20:[function(e,t,n){"use strict";var r=e("./Utils"),i=e("./Grammar"),s=e("debug")("JsSIP:ERROR:Socket");s.log=console.warn.bind(console),n.isSocket=function(e){if(Array.isArray(e))return!1;if(void 0===e)return s("undefined JsSIP.Socket instance"),!1;try{if(!r.isString(e.url))throw s("missing or invalid JsSIP.Socket url property"),new Error;if(!r.isString(e.via_transport))throw s("missing or invalid JsSIP.Socket via_transport property"),new Error;if(-1===i.parse(e.sip_uri,"SIP_URI"))throw s("missing or invalid JsSIP.Socket sip_uri property"),new Error}catch(e){return!1}try{["connect","disconnect","send"].forEach(function(t){if(!r.isFunction(e[t]))throw s("missing or invalid JsSIP.Socket method: "+t),new Error})}catch(e){return!1}return!0}},{"./Grammar":7,"./Utils":26,debug:29}],21:[function(e,t,n){"use strict";t.exports={T1:500,T2:4e3,T4:5e3,TIMER_B:32e3,TIMER_D:0,TIMER_F:32e3,TIMER_H:32e3,TIMER_I:0,TIMER_J:0,TIMER_K:0,TIMER_L:32e3,TIMER_M:32e3,PROVISIONAL_RESPONSE_INTERVAL:6e4}},{}],22:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n=100&&n<=199)switch(this.state){case v.STATUS_CALLING:this.stateChanged(v.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(e);break;case v.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(e)}else if(n>=200&&n<=299)switch(this.state){case v.STATUS_CALLING:case v.STATUS_PROCEEDING:this.stateChanged(v.STATUS_ACCEPTED),this.M=setTimeout(function(){t.timer_M()},c.TIMER_M),this.eventHandlers.onReceiveResponse(e);break;case v.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(e)}else if(n>=300&&n<=699)switch(this.state){case v.STATUS_CALLING:case v.STATUS_PROCEEDING:this.stateChanged(v.STATUS_COMPLETED),this.sendACK(e),this.eventHandlers.onReceiveResponse(e);break;case v.STATUS_COMPLETED:this.sendACK(e)}}},{key:"C",get:function(){return v}}]),t}(),y=function(e){a(t,o);function t(e,n,r,a){i(this,t);var o=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));o.id="z9hG4bK"+Math.floor(1e7*Math.random()),o.transport=n,o.request=r,o.eventHandlers=a;var l="SIP/2.0/"+n.via_transport;return l+=" "+e.configuration.via_host+";branch="+o.id,o.request.setHeader("via",l),o}return r(t,[{key:"send",value:function(){this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){f("transport error occurred for transaction "+this.id),this.eventHandlers.onTransportError()}},{key:"C",get:function(){return v}}]),t}(),T=function(e){a(t,o);function t(e,n,r){i(this,t);var a=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return a.type=v.NON_INVITE_SERVER,a.id=r.via_branch,a.ua=e,a.transport=n,a.request=r,a.last_response="",r.server_transaction=a,a.state=v.STATUS_TRYING,e.newTransaction(a),a}return r(t,[{key:"stateChanged",value:function(e){this.state=e,this.emit("stateChanged")}},{key:"timer_J",value:function(){p("Timer J expired for transaction "+this.id),this.stateChanged(v.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,p("transport error occurred, deleting transaction "+this.id),clearTimeout(this.J),this.stateChanged(v.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"receiveResponse",value:function(e,t,n,r){var i=this;if(100===e)switch(this.state){case v.STATUS_TRYING:this.stateChanged(v.STATUS_PROCEEDING),this.transport.send(t)||this.onTransportError();break;case v.STATUS_PROCEEDING:this.last_response=t,this.transport.send(t)?n&&n():(this.onTransportError(),r&&r())}else if(e>=200&&e<=699)switch(this.state){case v.STATUS_TRYING:case v.STATUS_PROCEEDING:this.stateChanged(v.STATUS_COMPLETED),this.last_response=t,this.J=setTimeout(function(){i.timer_J()},c.TIMER_J),this.transport.send(t)?n&&n():(this.onTransportError(),r&&r());break;case v.STATUS_COMPLETED:}}},{key:"C",get:function(){return v}}]),t}(),C=function(e){a(t,o);function t(e,n,r){i(this,t);var a=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return a.type=v.INVITE_SERVER,a.id=r.via_branch,a.ua=e,a.transport=n,a.request=r,a.last_response="",r.server_transaction=a,a.state=v.STATUS_PROCEEDING,e.newTransaction(a),a.resendProvisionalTimer=null,r.reply(100),a}return r(t,[{key:"stateChanged",value:function(e){this.state=e,this.emit("stateChanged")}},{key:"timer_H",value:function(){_("Timer H expired for transaction "+this.id),this.state===v.STATUS_COMPLETED&&_("ACK not received, dialog will be terminated"),this.stateChanged(v.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_I",value:function(){this.stateChanged(v.STATUS_TERMINATED)}},{key:"timer_L",value:function(){_("Timer L expired for transaction "+this.id),this.state===v.STATUS_ACCEPTED&&(this.stateChanged(v.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,_("transport error occurred, deleting transaction "+this.id),null!==this.resendProvisionalTimer&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),clearTimeout(this.L),clearTimeout(this.H),clearTimeout(this.I),this.stateChanged(v.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"resend_provisional",value:function(){this.transport.send(this.last_response)||this.onTransportError()}},{key:"receiveResponse",value:function(e,t,n,r){var i=this;if(e>=100&&e<=199)switch(this.state){case v.STATUS_PROCEEDING:this.transport.send(t)||this.onTransportError(),this.last_response=t}if(e>100&&e<=199&&this.state===v.STATUS_PROCEEDING)null===this.resendProvisionalTimer&&(this.resendProvisionalTimer=setInterval(function(){i.resend_provisional()},c.PROVISIONAL_RESPONSE_INTERVAL));else if(e>=200&&e<=299)switch(this.state){case v.STATUS_PROCEEDING:this.stateChanged(v.STATUS_ACCEPTED),this.last_response=t,this.L=setTimeout(function(){i.timer_L()},c.TIMER_L),null!==this.resendProvisionalTimer&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case v.STATUS_ACCEPTED:this.transport.send(t)?n&&n():(this.onTransportError(),r&&r())}else if(e>=300&&e<=699)switch(this.state){case v.STATUS_PROCEEDING:null!==this.resendProvisionalTimer&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(t)?(this.stateChanged(v.STATUS_COMPLETED),this.H=setTimeout(function(){i.timer_H()},c.TIMER_H),n&&n()):(this.onTransportError(),r&&r())}}},{key:"C",get:function(){return v}}]),t}();t.exports={C:v,NonInviteClientTransaction:m,InviteClientTransaction:g,AckClientTransaction:y,NonInviteServerTransaction:T,InviteServerTransaction:C,checkTransaction:function(e,t){var n=e._transactions,r=void 0;switch(t.method){case l.INVITE:if(r=n.ist[t.via_branch]){switch(r.state){case v.STATUS_PROCEEDING:r.transport.send(r.last_response);break;case v.STATUS_ACCEPTED:}return!0}break;case l.ACK:if(!(r=n.ist[t.via_branch]))return!1;if(r.state===v.STATUS_ACCEPTED)return!1;if(r.state===v.STATUS_COMPLETED)return r.state=v.STATUS_CONFIRMED,r.I=setTimeout(function(){r.timer_I()},c.TIMER_I),!0;break;case l.CANCEL:return(r=n.ist[t.via_branch])?(t.reply_sl(200),r.state!==v.STATUS_PROCEEDING):(t.reply_sl(481),!0);default:if(r=n.nist[t.via_branch]){switch(r.state){case v.STATUS_TRYING:break;case v.STATUS_PROCEEDING:case v.STATUS_COMPLETED:r.transport.send(r.last_response)}return!0}}}}},{"./Constants":2,"./SIPMessage":19,"./Timers":21,debug:29,events:31}],23:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:o.recovery_options;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),s("new()"),this.status=o.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=n,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1,void 0===t)throw new TypeError("Invalid argument. undefined 'sockets' argument");t instanceof Array||(t=[t]),t.forEach(function(e){if(!i.isSocket(e.socket))throw new TypeError("Invalid argument. invalid 'JsSIP.Socket' instance");if(e.weight&&!Number(e.weight))throw new TypeError("Invalid argument. 'weight' attribute is not a number");this.sockets.push({socket:e.socket,weight:e.weight||0,status:o.SOCKET_STATUS_READY})},this),this._getSocket()}return r(e,[{key:"connect",value:function(){s("connect()"),this.isConnected()?s("Transport is already connected"):this.isConnecting()?s("Transport is connecting"):(this.close_requested=!1,this.status=o.STATUS_CONNECTING,this.onconnecting({socket:this.socket,attempts:this.recover_attempts}),this.close_requested||(this.socket.onconnect=this._onConnect.bind(this),this.socket.ondisconnect=this._onDisconnect.bind(this),this.socket.ondata=this._onData.bind(this),this.socket.connect()))}},{key:"disconnect",value:function(){s("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=o.STATUS_DISCONNECTED,null!==this.recovery_timer&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.socket.onconnect=function(){},this.socket.ondisconnect=function(){},this.socket.ondata=function(){},this.socket.disconnect(),this.ondisconnect({socket:this.socket,error:!1})}},{key:"send",value:function(e){if(s("send()"),!this.isConnected())return a("unable to send message, transport is not connected"),!1;var t=e.toString();return s("sending message:\n\n"+t+"\n"),this.socket.send(t)}},{key:"isConnected",value:function(){return this.status===o.STATUS_CONNECTED}},{key:"isConnecting",value:function(){return this.status===o.STATUS_CONNECTING}},{key:"_reconnect",value:function(){var e=this;this.recover_attempts+=1;var t=Math.floor(Math.random()*Math.pow(2,this.recover_attempts)+1);tthis.recovery_options.max_interval&&(t=this.recovery_options.max_interval),s("reconnection attempt: "+this.recover_attempts+". next connection attempt in "+t+" seconds"),this.recovery_timer=setTimeout(function(){e.close_requested||e.isConnected()||e.isConnecting()||(e._getSocket(),e.connect())},1e3*t)}},{key:"_getSocket",value:function(){var e=[];if(this.sockets.forEach(function(t){t.status!==o.SOCKET_STATUS_ERROR&&(0===e.length?e.push(t):t.weight>e[0].weight?e=[t]:t.weight===e[0].weight&&e.push(t))}),0===e.length)return this.sockets.forEach(function(e){e.status=o.SOCKET_STATUS_READY}),void this._getSocket();var t=Math.floor(Math.random()*e.length);this.socket=e[t].socket}},{key:"_onConnect",value:function(){this.recover_attempts=0,this.status=o.STATUS_CONNECTED,null!==this.recovery_timer&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}},{key:"_onDisconnect",value:function(e,t,n){this.status=o.STATUS_DISCONNECTED,this.ondisconnect({socket:this.socket,error:e,code:t,reason:n}),this.close_requested||(this.sockets.forEach(function(e){this.socket===e.socket&&(e.status=o.SOCKET_STATUS_ERROR)},this),this._reconnect(e))}},{key:"_onData",value:function(e){if("\r\n"!==e){if("string"!=typeof e){try{e=String.fromCharCode.apply(null,new Uint8Array(e))}catch(e){return void s("received binary message failed to be converted into string, message discarded")}s("received binary message:\n\n"+e+"\n")}else s("received text message:\n\n"+e+"\n");this.ondata({transport:this,message:e})}else s("received message with CRLF Keep Alive response")}},{key:"via_transport",get:function(){return this.socket.via_transport}},{key:"url",get:function(){return this.socket.url}},{key:"sip_uri",get:function(){return this.socket.sip_uri}}]),e}()},{"./Socket":20,debug:29}],24:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=e.anonymous||null,n=e.outbound||null,r="<";return r+=t?this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":this.pub_gruu||this.uri.toString(),!n||(t?this.temp_gruu:this.pub_gruu)||(r+=";ob"),r+=">"}};var r=["password","realm","ha1","display_name","register"];for(var i in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,i)&&(-1!==r.indexOf(i)?Object.defineProperty(this._configuration,i,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,i,{writable:!1,configurable:!1}));y("configuration parameters after validation:");for(var a in this._configuration)if(Object.prototype.hasOwnProperty.call(g.settings,a))switch(a){case"uri":case"registrar_server":y("- "+a+": "+this._configuration[a]);break;case"password":case"ha1":y("- "+a+": NOT SHOWN");break;default:y("- "+a+": "+JSON.stringify(this._configuration[a]))}}},{key:"C",get:function(){return C}},{key:"status",get:function(){return this._status}},{key:"contact",get:function(){return this._contact}},{key:"configuration",get:function(){return this._configuration}},{key:"transport",get:function(){return this._transport}}]),t}()},{"./Config":1,"./Constants":2,"./Exceptions":6,"./Grammar":7,"./Message":9,"./Parser":11,"./RTCSession":12,"./Registrator":17,"./SIPMessage":19,"./Transactions":22,"./Transport":23,"./URI":25,"./Utils":26,"./sanityCheck":28,debug:29,events:31}],25:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n4&&void 0!==arguments[4]?arguments[4]:{},o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!r)throw new TypeError('missing or invalid "host" parameter');this._parameters={},this._headers={},this._scheme=t||i.SIP,this._user=n,this._host=r,this._port=s;for(var l in a)Object.prototype.hasOwnProperty.call(a,l)&&this.setParam(l,a[l]);for(var u in o)Object.prototype.hasOwnProperty.call(o,u)&&this.setHeader(u,o[u])}return r(e,[{key:"setParam",value:function(e,t){e&&(this._parameters[e.toLowerCase()]=void 0===t||null===t?null:t.toString())}},{key:"getParam",value:function(e){if(e)return this._parameters[e.toLowerCase()]}},{key:"hasParam",value:function(e){if(e)return!!this._parameters.hasOwnProperty(e.toLowerCase())}},{key:"deleteParam",value:function(e){if(e=e.toLowerCase(),this._parameters.hasOwnProperty(e)){var t=this._parameters[e];return delete this._parameters[e],t}}},{key:"clearParams",value:function(){this._parameters={}}},{key:"setHeader",value:function(e,t){this._headers[s.headerize(e)]=Array.isArray(t)?t:[t]}},{key:"getHeader",value:function(e){if(e)return this._headers[s.headerize(e)]}},{key:"hasHeader",value:function(e){if(e)return!!this._headers.hasOwnProperty(s.headerize(e))}},{key:"deleteHeader",value:function(e){if(e=s.headerize(e),this._headers.hasOwnProperty(e)){var t=this._headers[e];return delete this._headers[e],t}}},{key:"clearHeaders",value:function(){this._headers={}}},{key:"clone",value:function(){return new e(this._scheme,this._user,this._host,this._port,JSON.parse(JSON.stringify(this._parameters)),JSON.parse(JSON.stringify(this._headers)))}},{key:"toString",value:function(){var e=[],t=this._scheme+":";this._user&&(t+=s.escapeUser(this._user)+"@"),t+=this._host,(this._port||0===this._port)&&(t+=":"+this._port);for(var n in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,n)&&(t+=";"+n,null!==this._parameters[n]&&(t+="="+this._parameters[n]));for(var r in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,r)){var i=!0,a=!1,o=void 0;try{for(var l,u=this._headers[r][Symbol.iterator]();!(i=(l=u.next()).done);i=!0){var c=l.value;e.push(r+"="+c)}}catch(e){a=!0,o=e}finally{try{!i&&u.return&&u.return()}finally{if(a)throw o}}}return e.length>0&&(t+="?"+e.join("&")),t}},{key:"toAor",value:function(e){var t=this._scheme+":";return this._user&&(t+=s.escapeUser(this._user)+"@"),t+=this._host,e&&(this._port||0===this._port)&&(t+=":"+this._port),t}},{key:"scheme",get:function(){return this._scheme},set:function(e){this._scheme=e.toLowerCase()}},{key:"user",get:function(){return this._user},set:function(e){this._user=e}},{key:"host",get:function(){return this._host},set:function(e){this._host=e.toLowerCase()}},{key:"port",get:function(){return this._port},set:function(e){this._port=0===e?e:parseInt(e,10)||null}}]),e}()},{"./Constants":2,"./Grammar":7,"./Utils":26}],26:[function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=e("./Constants"),s=e("./URI"),a=e("./Grammar");n.str_utf8_length=function(e){return unescape(encodeURIComponent(e)).length};var o=n.isFunction=function(e){return void 0!==e&&"[object Function]"===Object.prototype.toString.call(e)};n.isString=function(e){return void 0!==e&&"[object String]"===Object.prototype.toString.call(e)},n.isDecimal=function(e){return!isNaN(e)&&parseFloat(e)===parseInt(e,10)},n.isEmpty=function(e){return null===e||""===e||void 0===e||Array.isArray(e)&&0===e.length||"number"==typeof e&&isNaN(e)},n.hasMethods=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r1&&void 0!==arguments[1]?arguments[1]:32,n=void 0,r="";for(n=0;n>>32-t}function n(e,t){var n=2147483648&e,r=2147483648&t,i=1073741824&e,s=1073741824&t,a=(1073741823&e)+(1073741823&t);return i&s?2147483648^a^n^r:i|s?1073741824&a?3221225472^a^n^r:1073741824^a^n^r:a^n^r}function r(e,r,i,s,a,o,l){var u,c,d;return n(t(e=n(e,n(n((u=r,c=i,d=s,u&c|~u&d),a),l)),o),r)}function i(e,r,i,s,a,o,l){var u,c,d;return n(t(e=n(e,n(n((u=r,c=i,d=s,u&d|c&~d),a),l)),o),r)}function s(e,r,i,s,a,o,l){var u,c,d;return n(t(e=n(e,n(n((u=r,c=i,d=s,u^c^d),a),l)),o),r)}function a(e,r,i,s,a,o,l){var u,c,d;return n(t(e=n(e,n(n((u=r,c=i,d=s,c^(u|~d)),a),l)),o),r)}function o(e){var t="",n="",r=void 0;for(r=0;r<=3;r++)t+=(n="0"+(e>>>8*r&255).toString(16)).substr(n.length-2,2);return t}var l=[],u=void 0,c=void 0,d=void 0,h=void 0,f=void 0,p=void 0,_=void 0,v=void 0,m=void 0;for(l=function(e){for(var t=void 0,n=e.length,r=n+8,i=16*((r-r%64)/64+1),s=new Array(i-1),a=0,o=0;o>>29,s}(e=function(e){e=e.replace(/\r\n/g,"\n");for(var t="",n=0;n127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(63&r|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(63&r|128))}return t}(e)),p=1732584193,_=4023233417,v=2562383102,m=271733878,u=0;u1)return a("more than one Via header field present in the response, dropping the response"),!1},function(){var e=s.str_utf8_length(c.body),t=c.getHeader("content-length");if(e=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},n.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),n.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];n.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}};function i(){var e;try{e=n.storage.debug}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}n.enable(i())}).call(this,e("_process"))},{"./debug":30,_process:33}],30:[function(e,t,n){(n=t.exports=r.debug=r.default=r).coerce=function(e){return e instanceof Error?e.stack||e.message:e},n.disable=function(){n.enable("")},n.enable=function(e){n.save(e),n.names=[],n.skips=[];var t,r=("string"==typeof e?e:"").split(/[\s,]+/),i=r.length;for(t=0;t0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var n=!1;function r(){this.removeListener(e,r),n||(n=!0,t.apply(this,arguments))}return r.listener=t,this.on(e,r),this},r.prototype.removeListener=function(e,t){var n,r,a,o;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(a=(n=this._events[e]).length,r=-1,n===t||i(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(n)){for(o=a;o-- >0;)if(n[o]===t||n[o].listener&&n[o].listener===t){r=o;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i(n=this._events[e]))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)};function i(e){return"function"==typeof e}function s(e){return"object"==typeof e&&null!==e}function a(e){return void 0===e}},{}],32:[function(e,t,n){var r=1e3,i=60*r,s=60*i,a=24*s,o=365.25*a;t.exports=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*o;case"days":case"day":case"d":return n*a;case"hours":case"hour":case"hrs":case"hr":case"h":return n*s;case"minutes":case"minute":case"mins":case"min":case"m":return n*i;case"seconds":case"second":case"secs":case"sec":case"s":return n*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===n&&!1===isNaN(e))return t.long?l(u=e,a,"day")||l(u,s,"hour")||l(u,i,"minute")||l(u,r,"second")||u+" ms":function(e){if(e>=a)return Math.round(e/a)+"d";if(e>=s)return Math.round(e/s)+"h";if(e>=i)return Math.round(e/i)+"m";if(e>=r)return Math.round(e/r)+"s";return e+"ms"}(e);var u;throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function l(e,t,n){if(!(e1)for(var n=1;n=14393&&-1===e.indexOf("?transport=udp"):(n=!0,!0)}),delete e.url,e.urls=i?r[0]:r,!!r.length}})}(n.iceServers||[],t),this._iceGatherers=[],n.iceCandidatePoolSize)for(var a=n.iceCandidatePoolSize;a>0;a--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:n.iceServers,gatherPolicy:n.iceTransportPolicy}));else n.iceCandidatePoolSize=0;this._config=n,this.transceivers=[],this._sdpSessionId=r.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};c.prototype.onicecandidate=null,c.prototype.onaddstream=null,c.prototype.ontrack=null,c.prototype.onremovestream=null,c.prototype.onsignalingstatechange=null,c.prototype.oniceconnectionstatechange=null,c.prototype.onicegatheringstatechange=null,c.prototype.onnegotiationneeded=null,c.prototype.ondatachannel=null,c.prototype._dispatchEvent=function(e,t){this._isClosed||(this.dispatchEvent(t),"function"==typeof this["on"+e]&&this["on"+e](t))},c.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)},c.prototype.getConfiguration=function(){return this._config},c.prototype.getLocalStreams=function(){return this.localStreams},c.prototype.getRemoteStreams=function(){return this.remoteStreams},c.prototype._createTransceiver=function(e){var t=this.transceivers.length>0,n={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:e,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&t)n.iceTransport=this.transceivers[0].iceTransport,n.dtlsTransport=this.transceivers[0].dtlsTransport;else{var r=this._createIceAndDtlsTransports();n.iceTransport=r.iceTransport,n.dtlsTransport=r.dtlsTransport}return this.transceivers.push(n),n},c.prototype.addTrack=function(t,n){if(this._isClosed)throw l("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");if(this.transceivers.find(function(e){return e.track===t}))throw l("InvalidAccessError","Track already exists.");for(var r,i=0;i=15025)e.getTracks().forEach(function(t){n.addTrack(t,e)});else{var r=e.clone();e.getTracks().forEach(function(e,t){var n=r.getTracks()[t];e.addEventListener("enabled",function(e){n.enabled=e.enabled})}),r.getTracks().forEach(function(e){n.addTrack(e,r)})}},c.prototype.removeTrack=function(t){if(this._isClosed)throw l("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(t instanceof e.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var n=this.transceivers.find(function(e){return e.rtpSender===t});if(!n)throw l("InvalidAccessError","Sender was not created by this connection.");var r=n.stream;n.rtpSender.stop(),n.rtpSender=null,n.track=null,n.stream=null;-1===this.transceivers.map(function(e){return e.stream}).indexOf(r)&&this.localStreams.indexOf(r)>-1&&this.localStreams.splice(this.localStreams.indexOf(r),1),this._maybeFireNegotiationNeeded()},c.prototype.removeStream=function(e){var t=this;e.getTracks().forEach(function(e){var n=t.getSenders().find(function(t){return t.track===e});n&&t.removeTrack(n)})},c.prototype.getSenders=function(){return this.transceivers.filter(function(e){return!!e.rtpSender}).map(function(e){return e.rtpSender})},c.prototype.getReceivers=function(){return this.transceivers.filter(function(e){return!!e.rtpReceiver}).map(function(e){return e.rtpReceiver})},c.prototype._createIceGatherer=function(t,n){var r=this;if(n&&t>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var i=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(i,"state",{value:"new",writable:!0}),this.transceivers[t].bufferedCandidateEvents=[],this.transceivers[t].bufferCandidates=function(e){var n=!e.candidate||0===Object.keys(e.candidate).length;i.state=n?"completed":"gathering",null!==r.transceivers[t].bufferedCandidateEvents&&r.transceivers[t].bufferedCandidateEvents.push(e)},i.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),i},c.prototype._gather=function(t,n){var i=this,s=this.transceivers[n].iceGatherer;if(!s.onlocalcandidate){var a=this.transceivers[n].bufferedCandidateEvents;this.transceivers[n].bufferedCandidateEvents=null,s.removeEventListener("localcandidate",this.transceivers[n].bufferCandidates),s.onlocalcandidate=function(e){if(!(i.usingBundle&&n>0)){var a=new Event("icecandidate");a.candidate={sdpMid:t,sdpMLineIndex:n};var o=e.candidate,l=!o||0===Object.keys(o).length;if(l)"new"!==s.state&&"gathering"!==s.state||(s.state="completed");else{"new"===s.state&&(s.state="gathering"),o.component=1;var u=r.writeCandidate(o);a.candidate=Object.assign(a.candidate,r.parseCandidate(u)),a.candidate.candidate=u}var c=r.splitSections(i.localDescription.sdp);c[a.candidate.sdpMLineIndex+1]+=l?"a=end-of-candidates\r\n":"a="+a.candidate.candidate+"\r\n",i.localDescription.sdp=c.join("");var d=i.transceivers.every(function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state});"gathering"!==i.iceGatheringState&&(i.iceGatheringState="gathering",i._emitGatheringStateChange()),l||i._dispatchEvent("icecandidate",a),d&&(i._dispatchEvent("icecandidate",new Event("icecandidate")),i.iceGatheringState="complete",i._emitGatheringStateChange())}},e.setTimeout(function(){a.forEach(function(e){s.onlocalcandidate(e)})},0)}},c.prototype._createIceAndDtlsTransports=function(){var t=this,n=new e.RTCIceTransport(null);n.onicestatechange=function(){t._updateConnectionState()};var r=new e.RTCDtlsTransport(n);return r.ondtlsstatechange=function(){t._updateConnectionState()},r.onerror=function(){Object.defineProperty(r,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:n,dtlsTransport:r}},c.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var n=this.transceivers[e].iceTransport;n&&(delete n.onicestatechange,delete this.transceivers[e].iceTransport);var r=this.transceivers[e].dtlsTransport;r&&(delete r.ondtlsstatechange,delete r.onerror,delete this.transceivers[e].dtlsTransport)},c.prototype._transceive=function(e,n,i){var a=s(e.localCapabilities,e.remoteCapabilities);n&&e.rtpSender&&(a.encodings=e.sendEncodingParameters,a.rtcp={cname:r.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(a.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(a)),i&&e.rtpReceiver&&a.codecs.length>0&&("video"===e.kind&&e.recvEncodingParameters&&t<15019&&e.recvEncodingParameters.forEach(function(e){delete e.rtx}),e.recvEncodingParameters.length&&(a.encodings=e.recvEncodingParameters),a.rtcp={compound:e.rtcpParameters.compound},e.rtcpParameters.cname&&(a.rtcp.cname=e.rtcpParameters.cname),e.sendEncodingParameters.length&&(a.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(a))},c.prototype.setLocalDescription=function(e){var t=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(l("TypeError",'Unsupported type "'+e.type+'"'));if(!a("setLocalDescription",e.type,t.signalingState)||t._isClosed)return Promise.reject(l("InvalidStateError","Can not set local "+e.type+" in state "+t.signalingState));var n,i;if("offer"===e.type)n=r.splitSections(e.sdp),i=n.shift(),n.forEach(function(e,n){var i=r.parseRtpParameters(e);t.transceivers[n].localCapabilities=i}),t.transceivers.forEach(function(e,n){t._gather(e.mid,n)});else if("answer"===e.type){n=r.splitSections(t.remoteDescription.sdp),i=n.shift();var o=r.matchPrefix(i,"a=ice-lite").length>0;n.forEach(function(e,n){var a=t.transceivers[n],l=a.iceGatherer,u=a.iceTransport,c=a.dtlsTransport,d=a.localCapabilities,h=a.remoteCapabilities;if(!(r.isRejected(e)&&0===r.matchPrefix(e,"a=bundle-only").length)&&!a.isDatachannel){var f=r.getIceParameters(e,i),p=r.getDtlsParameters(e,i);o&&(p.role="server"),t.usingBundle&&0!==n||(t._gather(a.mid,n),"new"===u.state&&u.start(l,f,o?"controlling":"controlled"),"new"===c.state&&c.start(p));var _=s(d,h);t._transceive(a,_.codecs.length>0,!1)}})}return t.localDescription={type:e.type,sdp:e.sdp},"offer"===e.type?t._updateSignalingState("have-local-offer"):t._updateSignalingState("stable"),Promise.resolve()},c.prototype.setRemoteDescription=function(i){var s=this;if(-1===["offer","answer"].indexOf(i.type))return Promise.reject(l("TypeError",'Unsupported type "'+i.type+'"'));if(!a("setRemoteDescription",i.type,s.signalingState)||s._isClosed)return Promise.reject(l("InvalidStateError","Can not set remote "+i.type+" in state "+s.signalingState));var c={};s.remoteStreams.forEach(function(e){c[e.id]=e});var d=[],h=r.splitSections(i.sdp),f=h.shift(),p=r.matchPrefix(f,"a=ice-lite").length>0,_=r.matchPrefix(f,"a=group:BUNDLE ").length>0;s.usingBundle=_;var v=r.matchPrefix(f,"a=ice-options:")[0];return s.canTrickleIceCandidates=!!v&&v.substr(14).split(" ").indexOf("trickle")>=0,h.forEach(function(a,l){var u=r.splitLines(a),h=r.getKind(a),v=r.isRejected(a)&&0===r.matchPrefix(a,"a=bundle-only").length,m=u[0].substr(2).split(" ")[2],g=r.getDirection(a,f),y=r.parseMsid(a),T=r.getMid(a)||r.generateIdentifier();if("application"!==h||"DTLS/SCTP"!==m){var C,S,E,b,R,A,w,I,k,P,O,x=r.parseRtpParameters(a);v||(P=r.getIceParameters(a,f),(O=r.getDtlsParameters(a,f)).role="client"),w=r.parseRtpEncodingParameters(a);var D=r.parseRtcpParameters(a),N=r.matchPrefix(a,"a=end-of-candidates",f).length>0,U=r.matchPrefix(a,"a=candidate:").map(function(e){return r.parseCandidate(e)}).filter(function(e){return 1===e.component});if(("offer"===i.type||"answer"===i.type)&&!v&&_&&l>0&&s.transceivers[l]&&(s._disposeIceAndDtlsTransports(l),s.transceivers[l].iceGatherer=s.transceivers[0].iceGatherer,s.transceivers[l].iceTransport=s.transceivers[0].iceTransport,s.transceivers[l].dtlsTransport=s.transceivers[0].dtlsTransport,s.transceivers[l].rtpSender&&s.transceivers[l].rtpSender.setTransport(s.transceivers[0].dtlsTransport),s.transceivers[l].rtpReceiver&&s.transceivers[l].rtpReceiver.setTransport(s.transceivers[0].dtlsTransport)),"offer"!==i.type||v)"answer"!==i.type||v||(S=(C=s.transceivers[l]).iceGatherer,E=C.iceTransport,b=C.dtlsTransport,R=C.rtpReceiver,A=C.sendEncodingParameters,I=C.localCapabilities,s.transceivers[l].recvEncodingParameters=w,s.transceivers[l].remoteCapabilities=x,s.transceivers[l].rtcpParameters=D,U.length&&"new"===E.state&&(!p&&!N||_&&0!==l?U.forEach(function(e){o(C.iceTransport,e)}):E.setRemoteCandidates(U)),_&&0!==l||("new"===E.state&&E.start(S,P,"controlling"),"new"===b.state&&b.start(O)),s._transceive(C,"sendrecv"===g||"recvonly"===g,"sendrecv"===g||"sendonly"===g),!R||"sendrecv"!==g&&"sendonly"!==g?delete C.rtpReceiver:(k=R.track,y?(c[y.stream]||(c[y.stream]=new e.MediaStream),n(k,c[y.stream]),d.push([k,R,c[y.stream]])):(c.default||(c.default=new e.MediaStream),n(k,c.default),d.push([k,R,c.default]))));else{(C=s.transceivers[l]||s._createTransceiver(h)).mid=T,C.iceGatherer||(C.iceGatherer=s._createIceGatherer(l,_)),U.length&&"new"===C.iceTransport.state&&(!N||_&&0!==l?U.forEach(function(e){o(C.iceTransport,e)}):C.iceTransport.setRemoteCandidates(U)),I=e.RTCRtpReceiver.getCapabilities(h),t<15019&&(I.codecs=I.codecs.filter(function(e){return"rtx"!==e.name})),A=C.sendEncodingParameters||[{ssrc:1001*(2*l+2)}];var M=!1;if("sendrecv"===g||"sendonly"===g){if(M=!C.rtpReceiver,R=C.rtpReceiver||new e.RTCRtpReceiver(C.dtlsTransport,h),M){var L;k=R.track,y&&"-"===y.stream||(y?(c[y.stream]||(c[y.stream]=new e.MediaStream,Object.defineProperty(c[y.stream],"id",{get:function(){return y.stream}})),Object.defineProperty(k,"id",{get:function(){return y.track}}),L=c[y.stream]):(c.default||(c.default=new e.MediaStream),L=c.default)),L&&(n(k,L),C.associatedRemoteMediaStreams.push(L)),d.push([k,R,L])}}else C.rtpReceiver&&C.rtpReceiver.track&&(C.associatedRemoteMediaStreams.forEach(function(t){var n=t.getTracks().find(function(e){return e.id===C.rtpReceiver.track.id});n&&(r=n,(i=t).removeTrack(r),i.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:r})));var r,i}),C.associatedRemoteMediaStreams=[]);C.localCapabilities=I,C.remoteCapabilities=x,C.rtpReceiver=R,C.rtcpParameters=D,C.sendEncodingParameters=A,C.recvEncodingParameters=w,s._transceive(s.transceivers[l],!1,M)}}else s.transceivers[l]={mid:T,isDatachannel:!0}}),void 0===s._dtlsRole&&(s._dtlsRole="offer"===i.type?"active":"passive"),s.remoteDescription={type:i.type,sdp:i.sdp},"offer"===i.type?s._updateSignalingState("have-remote-offer"):s._updateSignalingState("stable"),Object.keys(c).forEach(function(t){var n=c[t];if(n.getTracks().length){if(-1===s.remoteStreams.indexOf(n)){s.remoteStreams.push(n);var r=new Event("addstream");r.stream=n,e.setTimeout(function(){s._dispatchEvent("addstream",r)})}d.forEach(function(e){var t=e[0],r=e[1];n.id===e[2].id&&u(s,t,r,[n])})}}),d.forEach(function(e){e[2]||u(s,e[0],e[1],[])}),e.setTimeout(function(){s&&s.transceivers&&s.transceivers.forEach(function(e){e.iceTransport&&"new"===e.iceTransport.state&&e.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),e.iceTransport.addRemoteCandidate({}))})},4e3),Promise.resolve()},c.prototype.close=function(){this.transceivers.forEach(function(e){e.iceTransport&&e.iceTransport.stop(),e.dtlsTransport&&e.dtlsTransport.stop(),e.rtpSender&&e.rtpSender.stop(),e.rtpReceiver&&e.rtpReceiver.stop()}),this._isClosed=!0,this._updateSignalingState("closed")},c.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t)},c.prototype._maybeFireNegotiationNeeded=function(){var t=this;"stable"===this.signalingState&&!0!==this.needNegotiation&&(this.needNegotiation=!0,e.setTimeout(function(){if(t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t._dispatchEvent("negotiationneeded",e)}},0))},c.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(e){t[e.iceTransport.state]++,t[e.dtlsTransport.state]++}),t.connected+=t.completed,e="new",t.failed>0?e="failed":t.connecting>0||t.checking>0?e="connecting":t.disconnected>0?e="disconnected":t.new>0?e="new":(t.connected>0||t.completed>0)&&(e="connected"),e!==this.iceConnectionState){this.iceConnectionState=e;var n=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",n)}},c.prototype.createOffer=function(){var n=this;if(n._isClosed)return Promise.reject(l("InvalidStateError","Can not call createOffer after close"));var s=n.transceivers.filter(function(e){return"audio"===e.kind}).length,a=n.transceivers.filter(function(e){return"video"===e.kind}).length,o=arguments[0];if(o){if(o.mandatory||o.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==o.offerToReceiveAudio&&(s=!0===o.offerToReceiveAudio?1:!1===o.offerToReceiveAudio?0:o.offerToReceiveAudio),void 0!==o.offerToReceiveVideo&&(a=!0===o.offerToReceiveVideo?1:!1===o.offerToReceiveVideo?0:o.offerToReceiveVideo)}for(n.transceivers.forEach(function(e){"audio"===e.kind?--s<0&&(e.wantReceive=!1):"video"===e.kind&&--a<0&&(e.wantReceive=!1)});s>0||a>0;)s>0&&(n._createTransceiver("audio"),s--),a>0&&(n._createTransceiver("video"),a--);var u=r.writeSessionBoilerplate(n._sdpSessionId,n._sdpSessionVersion++);n.transceivers.forEach(function(i,s){var a=i.track,o=i.kind,l=i.mid||r.generateIdentifier();i.mid=l,i.iceGatherer||(i.iceGatherer=n._createIceGatherer(s,n.usingBundle));var u=e.RTCRtpSender.getCapabilities(o);t<15019&&(u.codecs=u.codecs.filter(function(e){return"rtx"!==e.name})),u.codecs.forEach(function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1")});var c=i.sendEncodingParameters||[{ssrc:1001*(2*s+1)}];a&&t>=15019&&"video"===o&&!c[0].rtx&&(c[0].rtx={ssrc:c[0].ssrc+1}),i.wantReceive&&(i.rtpReceiver=new e.RTCRtpReceiver(i.dtlsTransport,o)),i.localCapabilities=u,i.sendEncodingParameters=c}),"max-compat"!==n._config.bundlePolicy&&(u+="a=group:BUNDLE "+n.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"),u+="a=ice-options:trickle\r\n",n.transceivers.forEach(function(e,t){u+=i(e,e.localCapabilities,"offer",e.stream,n._dtlsRole),u+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===n.iceGatheringState||0!==t&&n.usingBundle||(e.iceGatherer.getLocalCandidates().forEach(function(e){e.component=1,u+="a="+r.writeCandidate(e)+"\r\n"}),"completed"===e.iceGatherer.state&&(u+="a=end-of-candidates\r\n"))});var c=new e.RTCSessionDescription({type:"offer",sdp:u});return Promise.resolve(c)},c.prototype.createAnswer=function(){var n=this;if(n._isClosed)return Promise.reject(l("InvalidStateError","Can not call createAnswer after close"));var a=r.writeSessionBoilerplate(n._sdpSessionId,n._sdpSessionVersion++);n.usingBundle&&(a+="a=group:BUNDLE "+n.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n");var o=r.splitSections(n.remoteDescription.sdp).length-1;n.transceivers.forEach(function(e,r){if(!(r+1>o))if(e.isDatachannel)a+="m=application 0 DTLS/SCTP 5000\r\nc=IN IP4 0.0.0.0\r\na=mid:"+e.mid+"\r\n";else{if(e.stream){var l;"audio"===e.kind?l=e.stream.getAudioTracks()[0]:"video"===e.kind&&(l=e.stream.getVideoTracks()[0]),l&&t>=15019&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1})}var u=s(e.localCapabilities,e.remoteCapabilities);!u.codecs.filter(function(e){return"rtx"===e.name.toLowerCase()}).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,a+=i(e,u,"answer",e.stream,n._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(a+="a=rtcp-rsize\r\n")}});var u=new e.RTCSessionDescription({type:"answer",sdp:a});return Promise.resolve(u)},c.prototype.addIceCandidate=function(e){var t,n=this;return e&&void 0===e.sdpMLineIndex&&!e.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(i,s){if(!n.remoteDescription)return s(l("InvalidStateError","Can not add ICE candidate without a remote description"));if(e&&""!==e.candidate){var a=e.sdpMLineIndex;if(e.sdpMid)for(var u=0;u0?r.parseCandidate(e.candidate):{};if("tcp"===d.protocol&&(0===d.port||9===d.port))return i();if(d.component&&1!==d.component)return i();if((0===a||a>0&&c.iceTransport!==n.transceivers[0].iceTransport)&&!o(c.iceTransport,d))return s(l("OperationError","Can not add ICE candidate"));var h=e.candidate.trim();0===h.indexOf("a=")&&(h=h.substr(2)),(t=r.splitSections(n.remoteDescription.sdp))[a+1]+="a="+(d.type?h:"end-of-candidates")+"\r\n",n.remoteDescription.sdp=t.join("")}else for(var f=0;f=r)return e;var i=n[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}})}.apply(null,r)},a=["v","o","s","i","u","e","p","c","b","t","r","z","a"],o=["i","c","b","a"];t.exports=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach(function(e){null==e.payloads&&(e.payloads="")});var n=t.outerOrder||a,i=t.innerOrder||o,l=[];return n.forEach(function(t){r[t].forEach(function(n){n.name in e&&null!=e[n.name]?l.push(s(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach(function(e){l.push(s(t,n,e))})})}),e.media.forEach(function(e){l.push(s("m",r.m[0],e)),i.forEach(function(t){r[t].forEach(function(n){n.name in e&&null!=e[n.name]?l.push(s(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach(function(e){l.push(s(t,n,e))})})})}),l.join("\r\n")+"\r\n"}},{"./grammar":35}],39:[function(e,t,n){"use strict";var r={};r.generateIdentifier=function(){return Math.random().toString(36).substr(2,10)},r.localCName=r.generateIdentifier(),r.splitLines=function(e){return e.trim().split("\n").map(function(e){return e.trim()})},r.splitSections=function(e){return e.split("\nm=").map(function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"})},r.matchPrefix=function(e,t){return r.splitLines(e).filter(function(e){return 0===e.indexOf(t)})},r.parseCandidate=function(e){for(var t,n={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],port:parseInt(t[5],10),type:t[7]},r=8;r0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},r.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},r.parseFmtp=function(e){for(var t,n={},r=e.substr(e.indexOf(" ")+1).split(";"),i=0;i-1?(n.attribute=e.substr(t+1,r-t-1),n.value=e.substr(r+1)):n.attribute=e.substr(t+1),n},r.getMid=function(e){var t=r.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},r.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},r.getDtlsParameters=function(e,t){return{role:"auto",fingerprints:r.matchPrefix(e+t,"a=fingerprint:").map(r.parseFingerprint)}},r.writeDtlsParameters=function(e,t){var n="a=setup:"+t+"\r\n";return e.fingerprints.forEach(function(e){n+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"}),n},r.getIceParameters=function(e,t){var n=r.splitLines(e);return{usernameFragment:(n=n.concat(r.splitLines(t))).filter(function(e){return 0===e.indexOf("a=ice-ufrag:")})[0].substr(12),password:n.filter(function(e){return 0===e.indexOf("a=ice-pwd:")})[0].substr(10)}},r.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},r.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},n=r.splitLines(e)[0].split(" "),i=3;i0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=t.codecs.map(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType}).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach(function(e){n+=r.writeRtpMap(e),n+=r.writeFmtp(e),n+=r.writeRtcpFb(e)});var i=0;return t.codecs.forEach(function(e){e.maxptime>i&&(i=e.maxptime)}),i>0&&(n+="a=maxptime:"+i+"\r\n"),n+="a=rtcp-mux\r\n",t.headerExtensions.forEach(function(e){n+=r.writeExtmap(e)}),n},r.parseRtpEncodingParameters=function(e){var t,n=[],i=r.parseRtpParameters(e),s=-1!==i.fecMechanisms.indexOf("RED"),a=-1!==i.fecMechanisms.indexOf("ULPFEC"),o=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute}),l=o.length>0&&o[0].ssrc,u=r.matchPrefix(e,"a=ssrc-group:FID").map(function(e){var t=e.split(" ");return t.shift(),t.map(function(e){return parseInt(e,10)})});u.length>0&&u[0].length>1&&u[0][0]===l&&(t=u[0][1]),i.codecs.forEach(function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var r={ssrc:l,codecPayloadType:parseInt(e.parameters.apt,10),rtx:{ssrc:t}};n.push(r),s&&((r=JSON.parse(JSON.stringify(r))).fec={ssrc:t,mechanism:a?"red+ulpfec":"red"},n.push(r))}}),0===n.length&&l&&n.push({ssrc:l});var c=r.matchPrefix(e,"b=");return c.length&&(c=0===c[0].indexOf("b=TIAS:")?parseInt(c[0].substr(7),10):0===c[0].indexOf("b=AS:")?1e3*parseInt(c[0].substr(5),10)*.95-16e3:void 0,n.forEach(function(e){e.maxBitrate=c})),n},r.parseRtcpParameters=function(e){var t={},n=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute})[0];n&&(t.cname=n.value,t.ssrc=n.ssrc);var i=r.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=i.length>0,t.compound=0===i.length;var s=r.matchPrefix(e,"a=rtcp-mux");return t.mux=s.length>0,t},r.parseMsid=function(e){var t,n=r.matchPrefix(e,"a=msid:");if(1===n.length)return{stream:(t=n[0].substr(7).split(" "))[0],track:t[1]};var i=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"msid"===e.attribute});return i.length>0?{stream:(t=i[0].value.split(" "))[0],track:t[1]}:void 0},r.generateSessionId=function(){return Math.random().toString().substr(2,21)},r.writeSessionBoilerplate=function(e,t){var n=void 0!==t?t:2;return"v=0\r\no=thisisadapterortc "+(e||r.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},r.writeMediaSection=function(e,t,n,i){var s=r.writeRtpDescription(e.kind,t);if(s+=r.writeIceParameters(e.iceGatherer.getLocalParameters()),s+=r.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===n?"actpass":"active"),s+="a=mid:"+e.mid+"\r\n",e.direction?s+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?s+="a=sendrecv\r\n":e.rtpSender?s+="a=sendonly\r\n":e.rtpReceiver?s+="a=recvonly\r\n":s+="a=inactive\r\n",e.rtpSender){var a="msid:"+i.id+" "+e.rtpSender.track.id+"\r\n";s+="a="+a,s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+a,e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+a,s+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+r.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+r.localCName+"\r\n"),s},r.getDirection=function(e,t){for(var n=r.splitLines(e),i=0;i=65)return this.shimAddTrackRemoveTrackWithNative(e);var n=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=n.apply(this);return e._reverseStreams=e._reverseStreams||{},t.map(function(t){return e._reverseStreams[t.id]})};var i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var n=this;if(n._streams=n._streams||{},n._reverseStreams=n._reverseStreams||{},t.getTracks().forEach(function(e){if(n.getSenders().find(function(t){return t.track===e}))throw new DOMException("Track already exists.","InvalidAccessError")}),!n._reverseStreams[t.id]){var r=new e.MediaStream(t.getTracks());n._streams[t.id]=r,n._reverseStreams[r.id]=t,t=r}i.apply(n,[t])};var s=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},s.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,n){var r=this;if("closed"===r.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var i=[].slice.call(arguments,1);if(1!==i.length||!i[0].getTracks().find(function(e){return e===t}))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(r.getSenders().find(function(e){return e.track===t}))throw new DOMException("Track already exists.","InvalidAccessError");r._streams=r._streams||{},r._reverseStreams=r._reverseStreams||{};var s=r._streams[n.id];if(s)s.addTrack(t),Promise.resolve().then(function(){r.dispatchEvent(new Event("negotiationneeded"))});else{var a=new e.MediaStream([t]);r._streams[n.id]=a,r._reverseStreams[a.id]=n,r.addStream(a)}return r.getSenders().find(function(e){return e.track===t})};function a(e,t){var n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(function(t){var r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(i.id,"g"),r.id)}),new RTCSessionDescription({type:t.type,sdp:n})}["createOffer","createAnswer"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){var e=this,t=arguments;return arguments.length&&"function"==typeof arguments[0]?n.apply(e,[function(n){var r=a(e,n);t[0].apply(null,[r])},function(e){t[1]&&t[1].apply(null,e)},arguments[2]]):n.apply(e,arguments).then(function(t){return a(e,t)})}});var o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=function(e,t){var n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(function(t){var r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(r.id,"g"),i.id)}),new RTCSessionDescription({type:t.type,sdp:n})}(this,arguments[0]),o.apply(this,arguments)):o.apply(this,arguments)};var l=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=l.get.apply(this);return""===e.type?e:a(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;if("closed"===t.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(e._pc===t))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");t._streams=t._streams||{};var n;Object.keys(t._streams).forEach(function(r){t._streams[r].getTracks().find(function(t){return e.track===t})&&(n=t._streams[r])}),n&&(1===n.getTracks().length?t.removeStream(t._reverseStreams[n.id]):n.removeTrack(e.track),t.dispatchEvent(new Event("negotiationneeded")))}},shimPeerConnection:function(e){var t=r.detectBrowser(e);if(e.RTCPeerConnection){var n=e.RTCPeerConnection;e.RTCPeerConnection=function(e,t){if(e&&e.iceServers){for(var i=[],s=0;s0&&"function"==typeof e)return s.apply(this,arguments);if(0===s.length&&(0===arguments.length||"function"!=typeof arguments[0]))return s.apply(this,[]);var a=function(e){var t={};return e.result().forEach(function(e){var n={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach(function(t){n[t]=e.stat(t)}),t[n.id]=n}),t},o=function(e){return new Map(Object.keys(e).map(function(t){return[t,e[t]]}))};if(arguments.length>=2){return s.apply(this,[function(e){i[1](o(a(e)))},arguments[0]])}return new Promise(function(e,t){s.apply(r,[function(t){e(o(a(t)))},t])}).then(t,n)},t.version<51&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){var e=arguments,t=this,r=new Promise(function(r,i){n.apply(t,[e[0],r,i])});return e.length<2?r:r.then(function(){e[1].apply(null,[])},function(t){e.length>=3&&e[2].apply(null,[t])})}}),t.version<52&&["createOffer","createAnswer"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){var e=this;if(arguments.length<1||1===arguments.length&&"object"==typeof arguments[0]){var t=1===arguments.length?arguments[0]:void 0;return new Promise(function(r,i){n.apply(e,[r,i,t])})}return n.apply(this,arguments)}}),["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t];e.RTCPeerConnection.prototype[t]=function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}});var a=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?a.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}}}},{"../utils.js":50,"./getusermedia":43}],43:[function(e,t,n){"use strict";var r=e("../utils.js"),i=r.log;t.exports=function(e){var t=r.detectBrowser(e),n=e&&e.navigator,s=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;var t={};return Object.keys(e).forEach(function(n){if("require"!==n&&"advanced"!==n&&"mediaSource"!==n){var r="object"==typeof e[n]?e[n]:{ideal:e[n]};void 0!==r.exact&&"number"==typeof r.exact&&(r.min=r.max=r.exact);var i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==r.ideal){t.optional=t.optional||[];var s={};"number"==typeof r.ideal?(s[i("min",n)]=r.ideal,t.optional.push(s),(s={})[i("max",n)]=r.ideal,t.optional.push(s)):(s[i("",n)]=r.ideal,t.optional.push(s))}void 0!==r.exact&&"number"!=typeof r.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",n)]=r.exact):["min","max"].forEach(function(e){void 0!==r[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,n)]=r[e])})}}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},a=function(e,r){if(t.version>=61)return r(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){var a=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])};a((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),a(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=s(e.audio)}if(e&&"object"==typeof e.video){var o=e.video.facingMode;o=o&&("object"==typeof o?o:{ideal:o});var l=t.version<66;if(o&&("user"===o.exact||"environment"===o.exact||"user"===o.ideal||"environment"===o.ideal)&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||l)){delete e.video.facingMode;var u;if("environment"===o.exact||"environment"===o.ideal?u=["back","rear"]:"user"!==o.exact&&"user"!==o.ideal||(u=["front"]),u)return n.mediaDevices.enumerateDevices().then(function(t){var n=(t=t.filter(function(e){return"videoinput"===e.kind})).find(function(e){return u.some(function(t){return-1!==e.label.toLowerCase().indexOf(t)})});return!n&&t.length&&-1!==u.indexOf("back")&&(n=t[t.length-1]),n&&(e.video.deviceId=o.exact?{exact:n.deviceId}:{ideal:n.deviceId}),e.video=s(e.video),i("chrome: "+JSON.stringify(e)),r(e)})}e.video=s(e.video)}return i("chrome: "+JSON.stringify(e)),r(e)},o=function(e){return{name:{PermissionDeniedError:"NotAllowedError",InvalidStateError:"NotReadableError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotReadableError",MediaDeviceKillSwitchOn:"NotReadableError"}[e.name]||e.name,message:e.message,constraint:e.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}};n.getUserMedia=function(e,t,r){a(e,function(e){n.webkitGetUserMedia(e,t,function(e){r&&r(o(e))})})};var l=function(e){return new Promise(function(t,r){n.getUserMedia(e,t,r)})};if(n.mediaDevices||(n.mediaDevices={getUserMedia:l,enumerateDevices:function(){return new Promise(function(t){var n={audio:"audioinput",video:"videoinput"};return e.MediaStreamTrack.getSources(function(e){t(e.map(function(e){return{label:e.label,kind:n[e.kind],deviceId:e.id,groupId:""}}))})})},getSupportedConstraints:function(){return{deviceId:!0,echoCancellation:!0,facingMode:!0,frameRate:!0,height:!0,width:!0}}}),n.mediaDevices.getUserMedia){var u=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(e){return a(e,function(e){return u(e).then(function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach(function(e){e.stop()}),new DOMException("","NotFoundError");return t},function(e){return Promise.reject(o(e))})})}}else n.mediaDevices.getUserMedia=function(e){return l(e)};void 0===n.mediaDevices.addEventListener&&(n.mediaDevices.addEventListener=function(){i("Dummy mediaDevices.addEventListener called.")}),void 0===n.mediaDevices.removeEventListener&&(n.mediaDevices.removeEventListener=function(){i("Dummy mediaDevices.removeEventListener called.")})}},{"../utils.js":50}],44:[function(e,t,n){"use strict";var r=e("sdp"),i=e("./utils");t.exports={shimRTCIceCandidate:function(e){if(!(e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){"object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2));var n=new t(e),i=r.parseCandidate(e.candidate),s=Object.assign(n,i);return s.toJSON=function(){return{candidate:s.candidate,sdpMid:s.sdpMid,sdpMLineIndex:s.sdpMLineIndex,usernameFragment:s.usernameFragment}},s},function(e,t,n){if(e.RTCPeerConnection){var r=e.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(e,r){if(e!==t)return i.apply(this,arguments);var s=function(e){r(n(e))};return this._eventMap=this._eventMap||{},this._eventMap[r]=s,i.apply(this,[e,s])};var s=r.removeEventListener;r.removeEventListener=function(e,n){if(e!==t||!this._eventMap||!this._eventMap[n])return s.apply(this,arguments);var r=this._eventMap[n];return delete this._eventMap[n],s.apply(this,[e,r])},Object.defineProperty(r,"on"+t,{get:function(){return this["_on"+t]},set:function(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)}})}}(e,"icecandidate",function(t){return t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t})}},shimCreateObjectURL:function(e){var t=e&&e.URL;if("object"==typeof e&&e.HTMLMediaElement&&"srcObject"in e.HTMLMediaElement.prototype&&t.createObjectURL&&t.revokeObjectURL){var n=t.createObjectURL.bind(t),r=t.revokeObjectURL.bind(t),s=new Map,a=0;t.createObjectURL=function(e){if("getTracks"in e){var t="polyblob:"+ ++a;return s.set(t,e),i.deprecated("URL.createObjectURL(stream)","elem.srcObject = stream"),t}return n(e)},t.revokeObjectURL=function(e){r(e),s.delete(e)};var o=Object.getOwnPropertyDescriptor(e.HTMLMediaElement.prototype,"src");Object.defineProperty(e.HTMLMediaElement.prototype,"src",{get:function(){return o.get.apply(this)},set:function(e){return this.srcObject=s.get(e)||null,o.set.apply(this,[e])}});var l=e.HTMLMediaElement.prototype.setAttribute;e.HTMLMediaElement.prototype.setAttribute=function(){return 2===arguments.length&&"src"===(""+arguments[0]).toLowerCase()&&(this.srcObject=s.get(arguments[1])||null),l.apply(this,arguments)}}}}},{"./utils":50,sdp:39}],45:[function(e,t,n){"use strict";var r=e("../utils"),i=e("rtcpeerconnection-shim");t.exports={shimGetUserMedia:e("./getusermedia"),shimPeerConnection:function(e){var t=r.detectBrowser(e);if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(e){return e}),e.RTCSessionDescription||(e.RTCSessionDescription=function(e){return e}),t.version<15025)){var n=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set:function(e){n.set.call(this,e);var t=new Event("enabled");t.enabled=e,this.dispatchEvent(t)}})}!e.RTCRtpSender||"dtmf"in e.RTCRtpSender.prototype||Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=new e.RTCDtmfSender(this):"video"===this.track.kind&&(this._dtmf=null)),this._dtmf}}),e.RTCPeerConnection=i(e,t.version)},shimReplaceTrack:function(e){!e.RTCRtpSender||"replaceTrack"in e.RTCRtpSender.prototype||(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}}},{"../utils":50,"./getusermedia":46,"rtcpeerconnection-shim":34}],46:[function(e,t,n){"use strict";t.exports=function(e){var t=e&&e.navigator,n=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return n(e).catch(function(e){return Promise.reject({name:{PermissionDeniedError:"NotAllowedError"}[(t=e).name]||t.name,message:t.message,constraint:t.constraint,toString:function(){return this.name}});var t})}}},{}],47:[function(e,t,n){"use strict";var r=e("../utils");t.exports={shimGetUserMedia:e("./getusermedia"),shimOnTrack:function(e){"object"!=typeof e||!e.RTCPeerConnection||"ontrack"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&(this.removeEventListener("track",this._ontrack),this.removeEventListener("addstream",this._ontrackpoly)),this.addEventListener("track",this._ontrack=e),this.addEventListener("addstream",this._ontrackpoly=function(e){e.stream.getTracks().forEach(function(t){var n=new Event("track");n.track=t,n.receiver={track:t},n.transceiver={receiver:n.receiver},n.streams=[e.stream],this.dispatchEvent(n)}.bind(this))}.bind(this))}}),"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})},shimSourceObject:function(e){"object"==typeof e&&(!e.HTMLMediaElement||"srcObject"in e.HTMLMediaElement.prototype||Object.defineProperty(e.HTMLMediaElement.prototype,"srcObject",{get:function(){return this.mozSrcObject},set:function(e){this.mozSrcObject=e}}))},shimPeerConnection:function(e){var t=r.detectBrowser(e);if("object"==typeof e&&(e.RTCPeerConnection||e.mozRTCPeerConnection)){e.RTCPeerConnection||(e.RTCPeerConnection=function(n,r){if(t.version<38&&n&&n.iceServers){for(var i=[],s=0;s55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){var c=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])},d=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(e){return"object"==typeof e&&"object"==typeof e.audio&&(e=JSON.parse(JSON.stringify(e)),c(e.audio,"autoGainControl","mozAutoGainControl"),c(e.audio,"noiseSuppression","mozNoiseSuppression")),d(e)},s&&s.prototype.getSettings){var h=s.prototype.getSettings;s.prototype.getSettings=function(){var e=h.apply(this,arguments);return c(e,"mozAutoGainControl","autoGainControl"),c(e,"mozNoiseSuppression","noiseSuppression"),e}}if(s&&s.prototype.applyConstraints){var f=s.prototype.applyConstraints;s.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"==typeof e&&(e=JSON.parse(JSON.stringify(e)),c(e,"autoGainControl","mozAutoGainControl"),c(e,"noiseSuppression","mozNoiseSuppression")),f.apply(this,[e])}}}n.getUserMedia=function(e,i,s){if(t.version<44)return o(e,i,s);r.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(e).then(i,s)}}},{"../utils":50}],49:[function(e,t,n){"use strict";var r=e("../utils");t.exports={shimLocalStreamsAPI:function(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),"getStreamById"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getStreamById=function(e){var t=null;return this._localStreams&&this._localStreams.forEach(function(n){n.id===e&&(t=n)}),this._remoteStreams&&this._remoteStreams.forEach(function(n){n.id===e&&(t=n)}),t}),!("addStream"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),-1===this._localStreams.indexOf(e)&&this._localStreams.push(e);var n=this;e.getTracks().forEach(function(r){t.call(n,r,e)})},e.RTCPeerConnection.prototype.addTrack=function(e,n){return n&&(this._localStreams?-1===this._localStreams.indexOf(n)&&this._localStreams.push(n):this._localStreams=[n]),t.call(this,e,n)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);var t=this._localStreams.indexOf(e);if(-1!==t){this._localStreams.splice(t,1);var n=this,r=e.getTracks();this.getSenders().forEach(function(e){-1!==r.indexOf(e.track)&&n.removeTrack(e)})}})}},shimRemoteStreamsAPI:function(e){"object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),"onaddstream"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=function(e){var t=e.streams[0];if(this._remoteStreams||(this._remoteStreams=[]),!(this._remoteStreams.indexOf(t)>=0)){this._remoteStreams.push(t);var n=new Event("addstream");n.stream=e.streams[0],this.dispatchEvent(n)}}.bind(this))}}))},shimCallbacksAPI:function(e){if("object"==typeof e&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype,n=t.createOffer,r=t.createAnswer,i=t.setLocalDescription,s=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){var r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){var n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i};var o=function(e,t,n){var r=i.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r};t.setLocalDescription=o,o=function(e,t,n){var r=s.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.setRemoteDescription=o,o=function(e,t,n){var r=a.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.addIceCandidate=o}},shimGetUserMedia:function(e){var t=e&&e.navigator;t.getUserMedia||(t.webkitGetUserMedia?t.getUserMedia=t.webkitGetUserMedia.bind(t):t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,n,r){t.mediaDevices.getUserMedia(e).then(n,r)}.bind(t)))},shimRTCIceServerUrls:function(e){var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,n){if(e&&e.iceServers){for(var i=[],s=0;s=n&&parseInt(r[n],10)}t.exports={extractVersion:s,disableLog:function(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(r=e,e?"adapter.js logging disabled":"adapter.js logging enabled")},disableWarnings:function(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(i=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))},log:function(){if("object"==typeof window){if(r)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}},deprecated:function(e,t){i&&console.warn(e+" is deprecated, please use "+t+" instead.")},detectBrowser:function(e){var t=e&&e.navigator,n={};if(n.browser=null,n.version=null,void 0===e||!e.navigator)return n.browser="Not a browser.",n;if(t.mozGetUserMedia)n.browser="firefox",n.version=s(t.userAgent,/Firefox\/(\d+)\./,1);else if(t.webkitGetUserMedia)if(e.webkitRTCPeerConnection)n.browser="chrome",n.version=s(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!t.userAgent.match(/Version\/(\d+).(\d+)/))return n.browser="Unsupported webkit-based browser with GUM support but no WebRTC support.",n;n.browser="safari",n.version=s(t.userAgent,/AppleWebKit\/(\d+)\./,1)}else if(t.mediaDevices&&t.userAgent.match(/Edge\/(\d+).(\d+)$/))n.browser="edge",n.version=s(t.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!t.mediaDevices||!t.userAgent.match(/AppleWebKit\/(\d+)\./))return n.browser="Not a supported browser.",n;n.browser="safari",n.version=s(t.userAgent,/AppleWebKit\/(\d+)\./,1)}return n}}},{}],51:[function(e,t,n){t.exports={name:"jssip",title:"JsSIP",description:"the Javascript SIP library",version:"3.2.8",homepage:"http://jssip.net",author:"José Luis Millán (https://github.com/jmillan)",contributors:["Iñaki Baz Castillo (https://github.com/ibc)","Saúl Ibarra Corretgé (https://github.com/saghul)"],main:"lib-es5/JsSIP.js",keywords:["sip","websocket","webrtc","node","browser","library"],license:"MIT",repository:{type:"git",url:"https://github.com/versatica/JsSIP.git"},bugs:{url:"https://github.com/versatica/JsSIP/issues"},dependencies:{debug:"^3.1.0","sdp-transform":"^2.4.0","webrtc-adapter":"^6.1.4"},devDependencies:{"ansi-colors":"^1.1.0","babel-core":"^6.26.0","babel-preset-env":"^1.6.1",browserify:"^16.1.1",eslint:"^4.19.1","fancy-log":"^1.3.2",gulp:"^4.0.0","gulp-babel":"^7.0.1","gulp-eslint":"^4.0.2","gulp-expect-file":"0.0.7","gulp-header":"^2.0.5","gulp-nodeunit-runner":"^0.2.2","gulp-plumber":"^1.2.0","gulp-rename":"^1.2.2","gulp-uglify":"^3.0.0",pegjs:"^0.7.0","vinyl-buffer":"^1.0.1","vinyl-source-stream":"^2.0.0"},scripts:{test:"gulp test",prepublishOnly:"gulp babel"}}},{}]},{},[8])(8)}); \ No newline at end of file diff --git a/package.json b/package.json index c5a3c0659..96ccd30f4 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "jssip", "title": "JsSIP", "description": "the Javascript SIP library", - "version": "3.2.7", + "version": "3.2.8", "homepage": "http://jssip.net", "author": "José Luis Millán (https://github.com/jmillan)", "contributors": [