@zhaokun/cti 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,34 @@
1
+ /*! version: 1.3.2 */
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.zhaokunCTI=t():e.zhaokunCTI=t()}(self,(()=>(()=>{var e={7:e=>{"use strict";var t,n="object"==typeof Reflect?Reflect:null,r=n&&"function"==typeof n.apply?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};t=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=Number.isNaN||function(e){return e!=e};function i(){i.init.call(this)}e.exports=i,e.exports.once=function(e,t){return new Promise((function(n,r){function o(n){e.removeListener(t,i),r(n)}function i(){"function"==typeof e.removeListener&&e.removeListener("error",o),n([].slice.call(arguments))}_(e,t,i,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&_(e,"error",t,n)}(e,o,{once:!0})}))},i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var s=10;function u(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function a(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function l(e,t,n,r){var o,i,s,l;if(u(n),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),i=e._events),s=i[t]),void 0===s)s=i[t]=n,++e._eventsCount;else if("function"==typeof s?s=i[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),(o=a(e))>0&&s.length>o&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,l=c,console&&console.warn&&console.warn(l)}return e}function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function f(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=c.bind(r);return o.listener=n,r.wrapFn=o,o}function h(e,t,n){var r=e._events;if(void 0===r)return[];var o=r[t];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(o):p(o,o.length)}function d(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function p(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function _(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function o(i){r.once&&e.removeEventListener(t,o),n(i)}))}}Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),i.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},i.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},i.prototype.getMaxListeners=function(){return a(this)},i.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var o="error"===e,i=this._events;if(void 0!==i)o=o&&void 0===i.error;else if(!o)return!1;if(o){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var u=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw u.context=s,u}var a=i[e];if(void 0===a)return!1;if("function"==typeof a)r(a,this,t);else{var l=a.length,c=p(a,l);for(n=0;n<l;++n)r(c[n],this,t)}return!0},i.prototype.addListener=function(e,t){return l(this,e,t,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(e,t){return l(this,e,t,!0)},i.prototype.once=function(e,t){return u(t),this.on(e,f(this,e,t)),this},i.prototype.prependOnceListener=function(e,t){return u(t),this.prependListener(e,f(this,e,t)),this},i.prototype.removeListener=function(e,t){var n,r,o,i,s;if(u(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(o=-1,i=n.length-1;i>=0;i--)if(n[i]===t||n[i].listener===t){s=n[i].listener,o=i;break}if(o<0)return this;0===o?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,o),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,s||t)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var o,i=Object.keys(n);for(r=0;r<i.length;++r)"removeListener"!==(o=i[r])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},i.prototype.listeners=function(e){return h(this,e,!0)},i.prototype.rawListeners=function(e){return h(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):d.call(e,t)},i.prototype.listenerCount=d,i.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},700:(e,t,n)=>{"use strict";function r(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,u=!0,a=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return u=e.done,e},e:function(e){a=!0,s=e},f:function(){try{u||null==n.return||n.return()}finally{if(a)throw s}}}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var i=n(137),s=n(349),u=n(561),a=n(670),l=n(627),c=n(956);t.settings={authorization_user:null,password:null,realm:null,ha1:null,authorization_jwt:null,display_name:null,uri:null,contact_uri:null,instance_id:null,use_preloaded_route:!1,session_timers:!0,session_timers_refresh_method:s.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:s.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:s.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:"".concat(i.createRandomToken(12),".invalid")};var f={mandatory:{sockets:function(e){var t=[];if(l.isSocket(e))t.push({socket:e});else{if(!Array.isArray(e)||!e.length)return;var n,o=r(e);try{for(o.s();!(n=o.n()).done;){var i=n.value;Object.prototype.hasOwnProperty.call(i,"socket")&&l.isSocket(i.socket)?t.push(i):l.isSocket(i)&&t.push({socket:i})}}catch(e){o.e(e)}finally{o.f()}}return t},uri:function(e){/^sip:/i.test(e)||(e="".concat(s.SIP,":").concat(e));var t=a.parse(e);return t&&t.user?t:void 0}},optional:{authorization_user:function(e){return-1===u.parse('"'.concat(e,'"'),"quoted_string")?void 0:e},authorization_jwt:function(e){if("string"==typeof e)return e},user_agent:function(e){if("string"==typeof e)return e},connection_recovery_max_interval:function(e){if(i.isDecimal(e)){var t=Number(e);if(t>0)return t}},connection_recovery_min_interval:function(e){if(i.isDecimal(e)){var t=Number(e);if(t>0)return t}},contact_uri:function(e){if("string"==typeof e){var t=u.parse(e,"SIP_URI");if(-1!==t)return t}},display_name:function(e){return e},instance_id:function(e){return/^uuid:/i.test(e)&&(e=e.substr(5)),-1===u.parse(e,"uuid")?void 0:e},no_answer_timeout:function(e){if(i.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())===s.INVITE||e===s.UPDATE))return e},session_timers_force_refresher:function(e){if("boolean"==typeof e)return e},password:function(e){return String(e)},realm:function(e){return String(e)},ha1:function(e){return String(e)},register:function(e){if("boolean"==typeof e)return e},register_expires:function(e){if(i.isDecimal(e)){var t=Number(e);if(t>0)return t}},registrar_server:function(e){/^sip:/i.test(e)||(e="".concat(s.SIP,":").concat(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},extra_headers:function(e){var t=[];if(Array.isArray(e)&&e.length){var n,o=r(e);try{for(o.s();!(n=o.n()).done;){var i=n.value;"string"==typeof i&&t.push(i)}}catch(e){o.e(e)}finally{o.f()}return t}}}};t.load=function(e,t){for(var n in f.mandatory){if(!t.hasOwnProperty(n))throw new c.ConfigurationError(n);var r=t[n],o=f.mandatory[n](r);if(void 0===o)throw new c.ConfigurationError(n,r);e[n]=o}for(var s in f.optional)if(t.hasOwnProperty(s)){var u=t[s];if(i.isEmpty(u))continue;var a=f.optional[s](u);if(void 0===a)throw new c.ConfigurationError(s,u);e[s]=a}}},349:(e,t,n)=>{"use strict";var r=n(633);e.exports={USER_AGENT:"".concat(r.title," ").concat(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",DTMF_TRANSPORT:{INFO:"INFO",RFC2833:"RFC2833"},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,NOTIFY",ACCEPTED_BODY_TYPES:"application/sdp, application/dtmf-relay",MAX_FORWARDS:69,SESSION_EXPIRES:90,MIN_SESSION_EXPIRES:60,CONNECTION_RECOVERY_MAX_INTERVAL:30,CONNECTION_RECOVERY_MIN_INTERVAL:2}},978:(e,t,n)=>{"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}var i=n(510),s=n(213),u=n(349),a=n(143),l=n(453),c=n(137),f=new i("Dialog"),h={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};e.exports=function(){function e(t,n,r){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:h.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 s.IncomingResponse&&(o=n.status_code<200?h.STATUS_EARLY:h.STATUS_CONFIRMED);var i=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=o,this._remote_seqnum=n.cseq,this._local_uri=n.parseHeader("to").uri,this._remote_uri=n.parseHeader("from").uri,this._remote_target=i.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=o,this._local_seqnum=n.cseq,this._local_uri=n.parseHeader("from").uri,this._remote_uri=n.parseHeader("to").uri,this._remote_target=i.uri,this._route_set=n.getHeaders("record-route").reverse(),this._ack_seqnum=null),this._ua.newDialog(this),f.debug("new ".concat(r," dialog created with status ").concat(this._state===h.STATUS_EARLY?"EARLY":"CONFIRMED"))}return o(e,null,[{key:"C",get:function(){return h}}]),o(e,[{key:"isTerminated",value:function(){return this._status===h.STATUS_TERMINATED}},{key:"update",value:function(e,t){this._state=h.STATUS_CONFIRMED,f.debug("dialog ".concat(this._id.toString()," changed to CONFIRMED state")),"UAC"===t&&(this._route_set=e.getHeaders("record-route").reverse())}},{key:"terminate",value:function(){f.debug("dialog ".concat(this._id.toString()," deleted")),this._ua.destroyDialog(this),this._state=h.STATUS_TERMINATED}},{key:"sendRequest",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=c.cloneArray(n.extraHeaders),o=c.cloneObject(n.eventHandlers),i=n.body||null,s=this._createRequest(e,r,i);return o.onAuthenticated=function(){t._local_seqnum+=1},new l(this,s,o).send(),s}},{key:"receiveRequest",value:function(e){this._checkInDialogRequest(e)&&(e.method===u.ACK&&null!==this._ack_seqnum?this._ack_seqnum=null:e.method===u.INVITE&&(this._ack_seqnum=e.cseq),this._owner.receiveRequest(e))}},{key:"_createRequest",value:function(e,t,n){t=c.cloneArray(t),this._local_seqnum||(this._local_seqnum=Math.floor(1e4*Math.random()));var r=e===u.CANCEL||e===u.ACK?this._local_seqnum:this._local_seqnum+=1;return new s.OutgoingRequest(e,this._remote_target,this._ua,{cseq:r,call_id:this._id.call_id,from_uri:this._local_uri,from_tag:this._id.local_tag,to_uri:this._remote_uri,to_tag:this._id.remote_tag,route_set:this._route_set},t,n)}},{key:"_checkInDialogRequest",value:function(e){var t=this;if(this._remote_seqnum)if(e.cseq<this._remote_seqnum){if(e.method!==u.ACK)return e.reply(500),!1;if(null===this._ack_seqnum||e.cseq!==this._ack_seqnum)return!1}else e.cseq>this._remote_seqnum&&(this._remote_seqnum=e.cseq);else this._remote_seqnum=e.cseq;if(e.method===u.INVITE||e.method===u.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:".concat(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===u.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}()},453:(e,t,n)=>{"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var o=n(349),i=n(143),s=n(396),u={onRequestTimeout:function(){},onTransportError:function(){},onSuccessResponse:function(){},onErrorResponse:function(){},onAuthenticated:function(){},onDialogError:function(){}};e.exports=function(){function e(t,n,r){for(var o in function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._dialog=t,this._ua=t._ua,this._request=n,this._eventHandlers=r,this._reattempt=!1,this._reattemptTimer=null,u)Object.prototype.hasOwnProperty.call(u,o)&&(this._eventHandlers[o]||(this._eventHandlers[o]=u[o]))}var t,n,a;return t=e,(n=[{key:"send",value:function(){var e=this,t=new s(this._ua,this._request,{onRequestTimeout:function(){e._eventHandlers.onRequestTimeout()},onTransportError:function(){e._eventHandlers.onTransportError()},onAuthenticated:function(t){e._eventHandlers.onAuthenticated(t)},onReceiveResponse:function(t){e._receiveResponse(t)}});t.send(),(this._request.method===o.INVITE||this._request.method===o.UPDATE&&this._request.body)&&t.clientTransaction.state!==i.C.STATUS_TERMINATED&&(this._dialog.uac_pending_reply=!0,t.clientTransaction.on("stateChanged",(function n(){t.clientTransaction.state!==i.C.STATUS_ACCEPTED&&t.clientTransaction.state!==i.C.STATUS_COMPLETED&&t.clientTransaction.state!==i.C.STATUS_TERMINATED||(t.clientTransaction.removeListener("stateChanged",n),e._dialog.uac_pending_reply=!1)})))}},{key:"_receiveResponse",value:function(e){var t=this;408===e.status_code||481===e.status_code?this._eventHandlers.onDialogError(e):e.method===o.INVITE&&491===e.status_code?this._reattempt?e.status_code>=200&&e.status_code<300?this._eventHandlers.onSuccessResponse(e):e.status_code>=300&&this._eventHandlers.onErrorResponse(e):(this._request.cseq=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout((function(){t._dialog.isTerminated()||(t._reattempt=!0,t.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}}])&&r(t.prototype,n),a&&r(t,a),e}()},554:(e,t,n)=>{"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var o=n(510),i=n(137),s=new o("DigestAuthentication");e.exports=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._credentials=t,this._cnonce=null,this._nc=0,this._ncHex="00000000",this._algorithm=null,this._realm=null,this._nonce=null,this._opaque=null,this._stale=null,this._qop=null,this._method=null,this._uri=null,this._ha1=null,this._response=null}var t,n,o;return t=e,n=[{key:"get",value:function(e){switch(e){case"realm":return this._realm;case"ha1":return this._ha1;default:return void s.warn('get() | cannot get "%s" parameter',e)}}},{key:"authenticate",value:function(e,t){var n=e.method,r=e.ruri,o=e.body,u=arguments.length>2&&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 s.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return s.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return s.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return s.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return s.warn('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 s.warn('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=u||i.createRandomToken(12),this._nc+=1;var a,l,c=Number(this._nc).toString(16);return this._ncHex="00000000".substr(0,8-c.length)+c,4294967296===this._nc&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=i.calculateMD5("".concat(this._credentials.username,":").concat(this._realm,":").concat(this._credentials.password)):this._ha1=this._credentials.ha1,"auth"===this._qop?(a="".concat(this._method,":").concat(this._uri),l=i.calculateMD5(a),s.debug('authenticate() | using qop=auth [a2:"%s"]',a),this._response=i.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(this._ncHex,":").concat(this._cnonce,":auth:").concat(l))):"auth-int"===this._qop?(a="".concat(this._method,":").concat(this._uri,":").concat(i.calculateMD5(o||"")),l=i.calculateMD5(a),s.debug('authenticate() | using qop=auth-int [a2:"%s"]',a),this._response=i.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(this._ncHex,":").concat(this._cnonce,":auth-int:").concat(l))):null===this._qop&&(a="".concat(this._method,":").concat(this._uri),l=i.calculateMD5(a),s.debug('authenticate() | using qop=null [a2:"%s"]',a),this._response=i.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(l))),s.debug("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=".concat(this._algorithm)),e.push('username="'.concat(this._credentials.username,'"')),e.push('realm="'.concat(this._realm,'"')),e.push('nonce="'.concat(this._nonce,'"')),e.push('uri="'.concat(this._uri,'"')),e.push('response="'.concat(this._response,'"')),this._opaque&&e.push('opaque="'.concat(this._opaque,'"')),this._qop&&(e.push("qop=".concat(this._qop)),e.push('cnonce="'.concat(this._cnonce,'"')),e.push("nc=".concat(this._ncHex))),"Digest ".concat(e.join(", "))}}],n&&r(t.prototype,n),o&&r(t,o),e}()},956:e=>{"use strict";function t(e){return t="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},t(e)}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}function o(e){var n=u();return function(){var r,o=l(e);if(n){var i=l(this).constructor;r=Reflect.construct(o,arguments,i)}else r=o.apply(this,arguments);return function(e,n){if(n&&("object"===t(n)||"function"==typeof n))return n;return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,r)}}function i(e){var t="function"==typeof Map?new Map:void 0;return i=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return s(e,arguments,l(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),a(r,e)},i(e)}function s(e,t,n){return s=u()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&a(o,n.prototype),o},s.apply(null,arguments)}function u(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function a(e,t){return a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},a(e,t)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}var c=function(e){r(i,e);var t=o(i);function i(e,r){var o;return n(this,i),(o=t.call(this)).code=1,o.name="CONFIGURATION_ERROR",o.parameter=e,o.value=r,o.message=o.value?"Invalid value ".concat(JSON.stringify(o.value),' for parameter "').concat(o.parameter,'"'):"Missing parameter: ".concat(o.parameter),o}return i}(i(Error)),f=function(e){r(i,e);var t=o(i);function i(e){var r;return n(this,i),(r=t.call(this)).code=2,r.name="INVALID_STATE_ERROR",r.status=e,r.message="Invalid status: ".concat(e),r}return i}(i(Error)),h=function(e){r(i,e);var t=o(i);function i(e){var r;return n(this,i),(r=t.call(this)).code=3,r.name="NOT_SUPPORTED_ERROR",r.message=e,r}return i}(i(Error)),d=function(e){r(i,e);var t=o(i);function i(e){var r;return n(this,i),(r=t.call(this)).code=4,r.name="NOT_READY_ERROR",r.message=e,r}return i}(i(Error));e.exports={ConfigurationError:c,InvalidStateError:f,NotSupportedError:h,NotReadyError:d}},561:(e,t,n)=>{"use strict";e.exports=function(){function e(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 t={parse:function(t,r){var o={CRLF:c,DIGIT:f,ALPHA:h,HEXDIG:d,WSP:p,OCTET:_,DQUOTE:v,SP:m,HTAB:y,alphanum:g,reserved:b,unreserved:T,mark:S,escaped:E,LWS:C,SWS:w,HCOLON:A,TEXT_UTF8_TRIM:R,TEXT_UTF8char:I,UTF8_NONASCII:O,UTF8_CONT:k,LHEX:function(){var e;null===(e=f())&&(/^[a-f]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[a-f]")));return e},token:N,token_nodot:x,separators:function(){var e;40===t.charCodeAt(i)?(e="(",i++):(e=null,0===s&&l('"("'));null===e&&(41===t.charCodeAt(i)?(e=")",i++):(e=null,0===s&&l('")"')),null===e&&(60===t.charCodeAt(i)?(e="<",i++):(e=null,0===s&&l('"<"')),null===e&&(62===t.charCodeAt(i)?(e=">",i++):(e=null,0===s&&l('">"')),null===e&&(64===t.charCodeAt(i)?(e="@",i++):(e=null,0===s&&l('"@"')),null===e&&(44===t.charCodeAt(i)?(e=",",i++):(e=null,0===s&&l('","')),null===e&&(59===t.charCodeAt(i)?(e=";",i++):(e=null,0===s&&l('";"')),null===e&&(58===t.charCodeAt(i)?(e=":",i++):(e=null,0===s&&l('":"')),null===e&&(92===t.charCodeAt(i)?(e="\\",i++):(e=null,0===s&&l('"\\\\"')),null===e&&null===(e=v())&&(47===t.charCodeAt(i)?(e="/",i++):(e=null,0===s&&l('"/"')),null===e&&(91===t.charCodeAt(i)?(e="[",i++):(e=null,0===s&&l('"["')),null===e&&(93===t.charCodeAt(i)?(e="]",i++):(e=null,0===s&&l('"]"')),null===e&&(63===t.charCodeAt(i)?(e="?",i++):(e=null,0===s&&l('"?"')),null===e&&(61===t.charCodeAt(i)?(e="=",i++):(e=null,0===s&&l('"="')),null===e&&(123===t.charCodeAt(i)?(e="{",i++):(e=null,0===s&&l('"{"')),null===e&&(125===t.charCodeAt(i)?(e="}",i++):(e=null,0===s&&l('"}"')),null===e&&null===(e=m())&&(e=y()))))))))))))))));return e},word:P,STAR:D,SLASH:U,EQUAL:M,LPAREN:L,RPAREN:q,RAQUOT:j,LAQUOT:H,COMMA:F,SEMI:B,COLON:G,LDQUOT:W,RDQUOT:V,comment:function e(){var t,n,r,o;if(o=i,null!==(t=L())){for(n=[],null===(r=K())&&null===(r=J())&&(r=e());null!==r;)n.push(r),null===(r=K())&&null===(r=J())&&(r=e());null!==n&&null!==(r=q())?t=[t,n,r]:(t=null,i=o)}else t=null,i=o;return t},ctext:K,quoted_string:Y,quoted_string_clean:z,qdtext:$,quoted_pair:J,SIP_URI_noparams:X,SIP_URI:Q,uri_scheme:Z,uri_scheme_sips:ee,uri_scheme_sip:te,userinfo:ne,user:re,user_unreserved:oe,password:ie,hostport:se,host:ue,hostname:ae,domainlabel:le,toplabel:ce,IPv6reference:fe,IPv6address:he,h16:de,ls32:pe,IPv4address:_e,dec_octet:ve,port:me,uri_parameters:ye,uri_parameter:ge,transport_param:be,user_param:Te,method_param:Se,ttl_param:Ee,maddr_param:Ce,lr_param:we,other_param:Ae,pname:Re,pvalue:Ie,paramchar:Oe,param_unreserved:ke,headers:Ne,header:xe,hname:Pe,hvalue:De,hnv_unreserved:Ue,Request_Response:function(){var e;null===(e=ft())&&(e=Me());return e},Request_Line:Me,Request_URI:Le,absoluteURI:qe,hier_part:je,net_path:He,abs_path:Fe,opaque_part:Be,uric:Ge,uric_no_slash:We,path_segments:Ve,segment:Ke,param:Ye,pchar:ze,scheme:$e,authority:Je,srvr:Xe,reg_name:Qe,query:Ze,SIP_Version:et,INVITEm:tt,ACKm:nt,OPTIONSm:rt,BYEm:ot,CANCELm:it,REGISTERm:st,SUBSCRIBEm:ut,NOTIFYm:at,REFERm:lt,Method:ct,Status_Line:ft,Status_Code:ht,extension_code:dt,Reason_Phrase:pt,Allow_Events:function(){var e,t,n,r,o,s;if(o=i,null!==(e=qt())){for(t=[],s=i,null!==(n=F())&&null!==(r=qt())?n=[n,r]:(n=null,i=s);null!==n;)t.push(n),s=i,null!==(n=F())&&null!==(r=qt())?n=[n,r]:(n=null,i=s);null!==t?e=[e,t]:(e=null,i=o)}else e=null,i=o;return e},Call_ID:function(){var e,n,r,o,u,a;o=i,u=i,null!==(e=P())?(a=i,64===t.charCodeAt(i)?(n="@",i++):(n=null,0===s&&l('"@"')),null!==n&&null!==(r=P())?n=[n,r]:(n=null,i=a),null!==(n=null!==n?n:"")?e=[e,n]:(e=null,i=u)):(e=null,i=u);null!==e&&(e=function(e){Fn=t.substring(i,e)}(o));null===e&&(i=o);return e},Contact:function(){var e,t,n,r,o,s,u;if(o=i,null===(e=D()))if(s=i,null!==(e=_t())){for(t=[],u=i,null!==(n=F())&&null!==(r=_t())?n=[n,r]:(n=null,i=u);null!==n;)t.push(n),u=i,null!==(n=F())&&null!==(r=_t())?n=[n,r]:(n=null,i=u);null!==t?e=[e,t]:(e=null,i=s)}else e=null,i=s;null!==e&&(e=function(){var e,t;for(t=Fn.multi_header.length,e=0;e<t;e++)if(null===Fn.multi_header[e].parsed){Fn=null;break}Fn=null!==Fn?Fn.multi_header:-1}());null===e&&(i=o);return e},contact_param:_t,name_addr:vt,display_name:mt,contact_params:yt,c_p_q:gt,c_p_expires:bt,delta_seconds:Tt,qvalue:St,generic_param:Et,gen_value:Ct,Content_Disposition:function(){var e,t,n,r,o,s;if(o=i,null!==(e=wt())){for(t=[],s=i,null!==(n=B())&&null!==(r=At())?n=[n,r]:(n=null,i=s);null!==n;)t.push(n),s=i,null!==(n=B())&&null!==(r=At())?n=[n,r]:(n=null,i=s);null!==t?e=[e,t]:(e=null,i=o)}else e=null,i=o;return e},disp_type:wt,disp_param:At,handling_param:Rt,Content_Encoding:function(){var e,t,n,r,o,s;if(o=i,null!==(e=N())){for(t=[],s=i,null!==(n=F())&&null!==(r=N())?n=[n,r]:(n=null,i=s);null!==n;)t.push(n),s=i,null!==(n=F())&&null!==(r=N())?n=[n,r]:(n=null,i=s);null!==t?e=[e,t]:(e=null,i=o)}else e=null,i=o;return e},Content_Length:function(){var e,t,n;if(n=i,null!==(t=f()))for(e=[];null!==t;)e.push(t),t=f();else e=null;null!==e&&(e=void(Fn=parseInt(e.join(""))));null===e&&(i=n);return e},Content_Type:function(){var e,n;n=i,null!==(e=It())&&(e=function(e){Fn=t.substring(i,e)}(n));null===e&&(i=n);return e},media_type:It,m_type:Ot,discrete_type:kt,composite_type:Nt,extension_token:xt,x_token:Pt,m_subtype:Dt,m_parameter:Ut,m_value:Mt,CSeq:function(){var e,t,n,r;r=i,null!==(e=Lt())&&null!==(t=C())&&null!==(n=ct())?e=[e,t,n]:(e=null,i=r);return e},CSeq_value:Lt,Expires:function(){var e,t;t=i,null!==(e=Tt())&&(e=void(Fn=e));null===e&&(i=t);return e},Event:function(){var e,t,n,r,o,s,u;if(o=i,s=i,null!==(e=qt())){for(t=[],u=i,null!==(n=B())&&null!==(r=Et())?n=[n,r]:(n=null,i=u);null!==n;)t.push(n),u=i,null!==(n=B())&&null!==(r=Et())?n=[n,r]:(n=null,i=u);null!==t?e=[e,t]:(e=null,i=s)}else e=null,i=s;null!==e&&(a=e[0],e=void(Fn.event=a.join("").toLowerCase()));var a;null===e&&(i=o);return e},event_type:qt,From:function(){var e,t,n,r,o,s,u;o=i,s=i,null===(e=X())&&(e=vt());if(null!==e){for(t=[],u=i,null!==(n=B())&&null!==(r=jt())?n=[n,r]:(n=null,i=u);null!==n;)t.push(n),u=i,null!==(n=B())&&null!==(r=jt())?n=[n,r]:(n=null,i=u);null!==t?e=[e,t]:(e=null,i=s)}else e=null,i=s;null!==e&&(e=function(){var e=Fn.tag;try{Fn=new Hn(Fn.uri,Fn.display_name,Fn.params),e&&Fn.setParam("tag",e)}catch(e){Fn=-1}}());null===e&&(i=o);return e},from_param:jt,tag_param:Ht,Max_Forwards:function(){var e,t,n;if(n=i,null!==(t=f()))for(e=[];null!==t;)e.push(t),t=f();else e=null;null!==e&&(e=void(Fn=parseInt(e.join(""))));null===e&&(i=n);return e},Min_Expires:function(){var e,t;t=i,null!==(e=Tt())&&(e=void(Fn=e));null===e&&(i=t);return e},Name_Addr_Header:function(){var e,t,n,r,o,s,u,a,l,c;a=i,l=i,e=[],t=mt();for(;null!==t;)e.push(t),t=mt();if(null!==e)if(null!==(t=H()))if(null!==(n=Q()))if(null!==(r=j())){for(o=[],c=i,null!==(s=B())&&null!==(u=Et())?s=[s,u]:(s=null,i=c);null!==s;)o.push(s),c=i,null!==(s=B())&&null!==(u=Et())?s=[s,u]:(s=null,i=c);null!==o?e=[e,t,n,r,o]:(e=null,i=l)}else e=null,i=l;else e=null,i=l;else e=null,i=l;else e=null,i=l;null!==e&&(e=function(){try{Fn=new Hn(Fn.uri,Fn.display_name,Fn.params)}catch(e){Fn=-1}}());null===e&&(i=a);return e},Proxy_Authenticate:function(){return Ft()},challenge:Ft,other_challenge:Bt,auth_param:Gt,digest_cln:Wt,realm:Vt,realm_value:Kt,domain:Yt,URI:zt,nonce:$t,nonce_value:Jt,opaque:Xt,stale:Qt,algorithm:Zt,qop_options:en,qop_value:tn,Proxy_Require:function(){var e,t,n,r,o,s;if(o=i,null!==(e=N())){for(t=[],s=i,null!==(n=F())&&null!==(r=N())?n=[n,r]:(n=null,i=s);null!==n;)t.push(n),s=i,null!==(n=F())&&null!==(r=N())?n=[n,r]:(n=null,i=s);null!==t?e=[e,t]:(e=null,i=o)}else e=null,i=o;return e},Record_Route:function(){var e,t,n,r,o,s,u;if(o=i,s=i,null!==(e=nn())){for(t=[],u=i,null!==(n=F())&&null!==(r=nn())?n=[n,r]:(n=null,i=u);null!==n;)t.push(n),u=i,null!==(n=F())&&null!==(r=nn())?n=[n,r]:(n=null,i=u);null!==t?e=[e,t]:(e=null,i=s)}else e=null,i=s;null!==e&&(e=function(){var e,t;for(t=Fn.multi_header.length,e=0;e<t;e++)if(null===Fn.multi_header[e].parsed){Fn=null;break}Fn=null!==Fn?Fn.multi_header:-1}());null===e&&(i=o);return e},rec_route:nn,Reason:function(){var e,n,r,o,u,a,c;u=i,a=i,"sip"===t.substr(i,3).toLowerCase()?(e=t.substr(i,3),i+=3):(e=null,0===s&&l('"SIP"'));null===e&&(e=N());if(null!==e){for(n=[],c=i,null!==(r=B())&&null!==(o=rn())?r=[r,o]:(r=null,i=c);null!==r;)n.push(r),c=i,null!==(r=B())&&null!==(o=rn())?r=[r,o]:(r=null,i=c);null!==n?e=[e,n]:(e=null,i=a)}else e=null,i=a;null!==e&&(e=function(e,t){if(Fn.protocol=t.toLowerCase(),Fn.params||(Fn.params={}),Fn.params.text&&'"'===Fn.params.text[0]){var n=Fn.params.text;Fn.text=n.substring(1,n.length-1),delete Fn.params.text}}(0,e[0]));null===e&&(i=u);return e},reason_param:rn,reason_cause:on,Require:function(){var e,t,n,r,o,s;if(o=i,null!==(e=N())){for(t=[],s=i,null!==(n=F())&&null!==(r=N())?n=[n,r]:(n=null,i=s);null!==n;)t.push(n),s=i,null!==(n=F())&&null!==(r=N())?n=[n,r]:(n=null,i=s);null!==t?e=[e,t]:(e=null,i=o)}else e=null,i=o;return e},Route:function(){var e,t,n,r,o,s;if(o=i,null!==(e=sn())){for(t=[],s=i,null!==(n=F())&&null!==(r=sn())?n=[n,r]:(n=null,i=s);null!==n;)t.push(n),s=i,null!==(n=F())&&null!==(r=sn())?n=[n,r]:(n=null,i=s);null!==t?e=[e,t]:(e=null,i=o)}else e=null,i=o;return e},route_param:sn,Subscription_State:function(){var e,t,n,r,o,s;if(o=i,null!==(e=un())){for(t=[],s=i,null!==(n=B())&&null!==(r=an())?n=[n,r]:(n=null,i=s);null!==n;)t.push(n),s=i,null!==(n=B())&&null!==(r=an())?n=[n,r]:(n=null,i=s);null!==t?e=[e,t]:(e=null,i=o)}else e=null,i=o;return e},substate_value:un,subexp_params:an,event_reason_value:ln,Subject:function(){var e;return e=null!==(e=R())?e:""},Supported:function(){var e,t,n,r,o,s;if(o=i,null!==(e=N())){for(t=[],s=i,null!==(n=F())&&null!==(r=N())?n=[n,r]:(n=null,i=s);null!==n;)t.push(n),s=i,null!==(n=F())&&null!==(r=N())?n=[n,r]:(n=null,i=s);null!==t?e=[e,t]:(e=null,i=o)}else e=null,i=o;return e=null!==e?e:""},To:function(){var e,t,n,r,o,s,u;o=i,s=i,null===(e=X())&&(e=vt());if(null!==e){for(t=[],u=i,null!==(n=B())&&null!==(r=cn())?n=[n,r]:(n=null,i=u);null!==n;)t.push(n),u=i,null!==(n=B())&&null!==(r=cn())?n=[n,r]:(n=null,i=u);null!==t?e=[e,t]:(e=null,i=s)}else e=null,i=s;null!==e&&(e=function(){var e=Fn.tag;try{Fn=new Hn(Fn.uri,Fn.display_name,Fn.params),e&&Fn.setParam("tag",e)}catch(e){Fn=-1}}());null===e&&(i=o);return e},to_param:cn,Via:function(){var e,t,n,r,o,s;if(o=i,null!==(e=fn())){for(t=[],s=i,null!==(n=F())&&null!==(r=fn())?n=[n,r]:(n=null,i=s);null!==n;)t.push(n),s=i,null!==(n=F())&&null!==(r=fn())?n=[n,r]:(n=null,i=s);null!==t?e=[e,t]:(e=null,i=o)}else e=null,i=o;return e},via_param:fn,via_params:hn,via_ttl:dn,via_maddr:pn,via_received:_n,via_branch:vn,response_port:mn,rport:yn,sent_protocol:gn,protocol_name:bn,transport:Tn,sent_by:Sn,via_host:En,via_port:Cn,ttl:wn,WWW_Authenticate:function(){return Ft()},Session_Expires:function(){var e,t,n,r,o,s;if(o=i,null!==(e=An())){for(t=[],s=i,null!==(n=B())&&null!==(r=Rn())?n=[n,r]:(n=null,i=s);null!==n;)t.push(n),s=i,null!==(n=B())&&null!==(r=Rn())?n=[n,r]:(n=null,i=s);null!==t?e=[e,t]:(e=null,i=o)}else e=null,i=o;return e},s_e_expires:An,s_e_params:Rn,s_e_refresher:In,extension_header:function(){var e,t,n,r;r=i,null!==(e=N())&&null!==(t=A())&&null!==(n=On())?e=[e,t,n]:(e=null,i=r);return e},header_value:On,message_body:function(){var e,t;e=[],t=_();for(;null!==t;)e.push(t),t=_();return e},uuid_URI:function(){var e,n,r;r=i,"uuid:"===t.substr(i,5)?(e="uuid:",i+=5):(e=null,0===s&&l('"uuid:"'));null!==e&&null!==(n=kn())?e=[e,n]:(e=null,i=r);return e},uuid:kn,hex4:Nn,hex8:xn,hex12:Pn,Refer_To:function(){var e,t,n,r,o,s,u;o=i,s=i,null===(e=X())&&(e=vt());if(null!==e){for(t=[],u=i,null!==(n=B())&&null!==(r=Et())?n=[n,r]:(n=null,i=u);null!==n;)t.push(n),u=i,null!==(n=B())&&null!==(r=Et())?n=[n,r]:(n=null,i=u);null!==t?e=[e,t]:(e=null,i=s)}else e=null,i=s;null!==e&&(e=function(){try{Fn=new Hn(Fn.uri,Fn.display_name,Fn.params)}catch(e){Fn=-1}}());null===e&&(i=o);return e},Replaces:function(){var e,t,n,r,o,s;if(o=i,null!==(e=Dn())){for(t=[],s=i,null!==(n=B())&&null!==(r=Un())?n=[n,r]:(n=null,i=s);null!==n;)t.push(n),s=i,null!==(n=B())&&null!==(r=Un())?n=[n,r]:(n=null,i=s);null!==t?e=[e,t]:(e=null,i=o)}else e=null,i=o;return e},call_id:Dn,replaces_param:Un,to_tag:Mn,from_tag:Ln,early_flag:qn};if(void 0!==r){if(void 0===o[r])throw new Error("Invalid rule name: "+e(r)+".")}else r="CRLF";var i=0,s=0,u=0,a=[];function l(e){i<u||(i>u&&(u=i,a=[]),a.push(e))}function c(){var e;return"\r\n"===t.substr(i,2)?(e="\r\n",i+=2):(e=null,0===s&&l('"\\r\\n"')),e}function f(){var e;return/^[0-9]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[0-9]")),e}function h(){var e;return/^[a-zA-Z]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[a-zA-Z]")),e}function d(){var e;return/^[0-9a-fA-F]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[0-9a-fA-F]")),e}function p(){var e;return null===(e=m())&&(e=y()),e}function _(){var e;return/^[\0-\xFF]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[\\0-\\xFF]")),e}function v(){var e;return/^["]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l('["]')),e}function m(){var e;return 32===t.charCodeAt(i)?(e=" ",i++):(e=null,0===s&&l('" "')),e}function y(){var e;return 9===t.charCodeAt(i)?(e="\t",i++):(e=null,0===s&&l('"\\t"')),e}function g(){var e;return/^[a-zA-Z0-9]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[a-zA-Z0-9]")),e}function b(){var e;return 59===t.charCodeAt(i)?(e=";",i++):(e=null,0===s&&l('";"')),null===e&&(47===t.charCodeAt(i)?(e="/",i++):(e=null,0===s&&l('"/"')),null===e&&(63===t.charCodeAt(i)?(e="?",i++):(e=null,0===s&&l('"?"')),null===e&&(58===t.charCodeAt(i)?(e=":",i++):(e=null,0===s&&l('":"')),null===e&&(64===t.charCodeAt(i)?(e="@",i++):(e=null,0===s&&l('"@"')),null===e&&(38===t.charCodeAt(i)?(e="&",i++):(e=null,0===s&&l('"&"')),null===e&&(61===t.charCodeAt(i)?(e="=",i++):(e=null,0===s&&l('"="')),null===e&&(43===t.charCodeAt(i)?(e="+",i++):(e=null,0===s&&l('"+"')),null===e&&(36===t.charCodeAt(i)?(e="$",i++):(e=null,0===s&&l('"$"')),null===e&&(44===t.charCodeAt(i)?(e=",",i++):(e=null,0===s&&l('","'))))))))))),e}function T(){var e;return null===(e=g())&&(e=S()),e}function S(){var e;return 45===t.charCodeAt(i)?(e="-",i++):(e=null,0===s&&l('"-"')),null===e&&(95===t.charCodeAt(i)?(e="_",i++):(e=null,0===s&&l('"_"')),null===e&&(46===t.charCodeAt(i)?(e=".",i++):(e=null,0===s&&l('"."')),null===e&&(33===t.charCodeAt(i)?(e="!",i++):(e=null,0===s&&l('"!"')),null===e&&(126===t.charCodeAt(i)?(e="~",i++):(e=null,0===s&&l('"~"')),null===e&&(42===t.charCodeAt(i)?(e="*",i++):(e=null,0===s&&l('"*"')),null===e&&(39===t.charCodeAt(i)?(e="'",i++):(e=null,0===s&&l('"\'"')),null===e&&(40===t.charCodeAt(i)?(e="(",i++):(e=null,0===s&&l('"("')),null===e&&(41===t.charCodeAt(i)?(e=")",i++):(e=null,0===s&&l('")"')))))))))),e}function E(){var e,n,r,o,u;return o=i,u=i,37===t.charCodeAt(i)?(e="%",i++):(e=null,0===s&&l('"%"')),null!==e&&null!==(n=d())&&null!==(r=d())?e=[e,n,r]:(e=null,i=u),null!==e&&(e=e.join("")),null===e&&(i=o),e}function C(){var e,t,n,r,o,s;for(r=i,o=i,s=i,e=[],t=p();null!==t;)e.push(t),t=p();if(null!==e&&null!==(t=c())?e=[e,t]:(e=null,i=s),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,i=o)}else e=null,i=o;return null!==e&&(e=" "),null===e&&(i=r),e}function w(){var e;return e=null!==(e=C())?e:""}function A(){var e,n,r,o,u;for(o=i,u=i,e=[],null===(n=m())&&(n=y());null!==n;)e.push(n),null===(n=m())&&(n=y());return null!==e?(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(r=w())?e=[e,n,r]:(e=null,i=u)):(e=null,i=u),null!==e&&(e=":"),null===e&&(i=o),e}function R(){var e,n,r,o,s,u,a;if(s=i,u=i,null!==(n=I()))for(e=[];null!==n;)e.push(n),n=I();else e=null;if(null!==e){for(n=[],a=i,r=[],o=C();null!==o;)r.push(o),o=C();for(null!==r&&null!==(o=I())?r=[r,o]:(r=null,i=a);null!==r;){for(n.push(r),a=i,r=[],o=C();null!==o;)r.push(o),o=C();null!==r&&null!==(o=I())?r=[r,o]:(r=null,i=a)}null!==n?e=[e,n]:(e=null,i=u)}else e=null,i=u;return null!==e&&(e=function(e){return t.substring(i,e)}(s)),null===e&&(i=s),e}function I(){var e;return/^[!-~]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[!-~]")),null===e&&(e=O()),e}function O(){var e;return/^[\x80-\uFFFF]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[\\x80-\\uFFFF]")),e}function k(){var e;return/^[\x80-\xBF]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[\\x80-\\xBF]")),e}function N(){var e,n,r;if(r=i,null===(n=g())&&(45===t.charCodeAt(i)?(n="-",i++):(n=null,0===s&&l('"-"')),null===n&&(46===t.charCodeAt(i)?(n=".",i++):(n=null,0===s&&l('"."')),null===n&&(33===t.charCodeAt(i)?(n="!",i++):(n=null,0===s&&l('"!"')),null===n&&(37===t.charCodeAt(i)?(n="%",i++):(n=null,0===s&&l('"%"')),null===n&&(42===t.charCodeAt(i)?(n="*",i++):(n=null,0===s&&l('"*"')),null===n&&(95===t.charCodeAt(i)?(n="_",i++):(n=null,0===s&&l('"_"')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&l('"+"')),null===n&&(96===t.charCodeAt(i)?(n="`",i++):(n=null,0===s&&l('"`"')),null===n&&(39===t.charCodeAt(i)?(n="'",i++):(n=null,0===s&&l('"\'"')),null===n&&(126===t.charCodeAt(i)?(n="~",i++):(n=null,0===s&&l('"~"')))))))))))),null!==n)for(e=[];null!==n;)e.push(n),null===(n=g())&&(45===t.charCodeAt(i)?(n="-",i++):(n=null,0===s&&l('"-"')),null===n&&(46===t.charCodeAt(i)?(n=".",i++):(n=null,0===s&&l('"."')),null===n&&(33===t.charCodeAt(i)?(n="!",i++):(n=null,0===s&&l('"!"')),null===n&&(37===t.charCodeAt(i)?(n="%",i++):(n=null,0===s&&l('"%"')),null===n&&(42===t.charCodeAt(i)?(n="*",i++):(n=null,0===s&&l('"*"')),null===n&&(95===t.charCodeAt(i)?(n="_",i++):(n=null,0===s&&l('"_"')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&l('"+"')),null===n&&(96===t.charCodeAt(i)?(n="`",i++):(n=null,0===s&&l('"`"')),null===n&&(39===t.charCodeAt(i)?(n="'",i++):(n=null,0===s&&l('"\'"')),null===n&&(126===t.charCodeAt(i)?(n="~",i++):(n=null,0===s&&l('"~"'))))))))))));else e=null;return null!==e&&(e=function(e){return t.substring(i,e)}(r)),null===e&&(i=r),e}function x(){var e,n,r;if(r=i,null===(n=g())&&(45===t.charCodeAt(i)?(n="-",i++):(n=null,0===s&&l('"-"')),null===n&&(33===t.charCodeAt(i)?(n="!",i++):(n=null,0===s&&l('"!"')),null===n&&(37===t.charCodeAt(i)?(n="%",i++):(n=null,0===s&&l('"%"')),null===n&&(42===t.charCodeAt(i)?(n="*",i++):(n=null,0===s&&l('"*"')),null===n&&(95===t.charCodeAt(i)?(n="_",i++):(n=null,0===s&&l('"_"')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&l('"+"')),null===n&&(96===t.charCodeAt(i)?(n="`",i++):(n=null,0===s&&l('"`"')),null===n&&(39===t.charCodeAt(i)?(n="'",i++):(n=null,0===s&&l('"\'"')),null===n&&(126===t.charCodeAt(i)?(n="~",i++):(n=null,0===s&&l('"~"'))))))))))),null!==n)for(e=[];null!==n;)e.push(n),null===(n=g())&&(45===t.charCodeAt(i)?(n="-",i++):(n=null,0===s&&l('"-"')),null===n&&(33===t.charCodeAt(i)?(n="!",i++):(n=null,0===s&&l('"!"')),null===n&&(37===t.charCodeAt(i)?(n="%",i++):(n=null,0===s&&l('"%"')),null===n&&(42===t.charCodeAt(i)?(n="*",i++):(n=null,0===s&&l('"*"')),null===n&&(95===t.charCodeAt(i)?(n="_",i++):(n=null,0===s&&l('"_"')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&l('"+"')),null===n&&(96===t.charCodeAt(i)?(n="`",i++):(n=null,0===s&&l('"`"')),null===n&&(39===t.charCodeAt(i)?(n="'",i++):(n=null,0===s&&l('"\'"')),null===n&&(126===t.charCodeAt(i)?(n="~",i++):(n=null,0===s&&l('"~"')))))))))));else e=null;return null!==e&&(e=function(e){return t.substring(i,e)}(r)),null===e&&(i=r),e}function P(){var e,n,r;if(r=i,null===(n=g())&&(45===t.charCodeAt(i)?(n="-",i++):(n=null,0===s&&l('"-"')),null===n&&(46===t.charCodeAt(i)?(n=".",i++):(n=null,0===s&&l('"."')),null===n&&(33===t.charCodeAt(i)?(n="!",i++):(n=null,0===s&&l('"!"')),null===n&&(37===t.charCodeAt(i)?(n="%",i++):(n=null,0===s&&l('"%"')),null===n&&(42===t.charCodeAt(i)?(n="*",i++):(n=null,0===s&&l('"*"')),null===n&&(95===t.charCodeAt(i)?(n="_",i++):(n=null,0===s&&l('"_"')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&l('"+"')),null===n&&(96===t.charCodeAt(i)?(n="`",i++):(n=null,0===s&&l('"`"')),null===n&&(39===t.charCodeAt(i)?(n="'",i++):(n=null,0===s&&l('"\'"')),null===n&&(126===t.charCodeAt(i)?(n="~",i++):(n=null,0===s&&l('"~"')),null===n&&(40===t.charCodeAt(i)?(n="(",i++):(n=null,0===s&&l('"("')),null===n&&(41===t.charCodeAt(i)?(n=")",i++):(n=null,0===s&&l('")"')),null===n&&(60===t.charCodeAt(i)?(n="<",i++):(n=null,0===s&&l('"<"')),null===n&&(62===t.charCodeAt(i)?(n=">",i++):(n=null,0===s&&l('">"')),null===n&&(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null===n&&(92===t.charCodeAt(i)?(n="\\",i++):(n=null,0===s&&l('"\\\\"')),null===n&&null===(n=v())&&(47===t.charCodeAt(i)?(n="/",i++):(n=null,0===s&&l('"/"')),null===n&&(91===t.charCodeAt(i)?(n="[",i++):(n=null,0===s&&l('"["')),null===n&&(93===t.charCodeAt(i)?(n="]",i++):(n=null,0===s&&l('"]"')),null===n&&(63===t.charCodeAt(i)?(n="?",i++):(n=null,0===s&&l('"?"')),null===n&&(123===t.charCodeAt(i)?(n="{",i++):(n=null,0===s&&l('"{"')),null===n&&(125===t.charCodeAt(i)?(n="}",i++):(n=null,0===s&&l('"}"')))))))))))))))))))))))),null!==n)for(e=[];null!==n;)e.push(n),null===(n=g())&&(45===t.charCodeAt(i)?(n="-",i++):(n=null,0===s&&l('"-"')),null===n&&(46===t.charCodeAt(i)?(n=".",i++):(n=null,0===s&&l('"."')),null===n&&(33===t.charCodeAt(i)?(n="!",i++):(n=null,0===s&&l('"!"')),null===n&&(37===t.charCodeAt(i)?(n="%",i++):(n=null,0===s&&l('"%"')),null===n&&(42===t.charCodeAt(i)?(n="*",i++):(n=null,0===s&&l('"*"')),null===n&&(95===t.charCodeAt(i)?(n="_",i++):(n=null,0===s&&l('"_"')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&l('"+"')),null===n&&(96===t.charCodeAt(i)?(n="`",i++):(n=null,0===s&&l('"`"')),null===n&&(39===t.charCodeAt(i)?(n="'",i++):(n=null,0===s&&l('"\'"')),null===n&&(126===t.charCodeAt(i)?(n="~",i++):(n=null,0===s&&l('"~"')),null===n&&(40===t.charCodeAt(i)?(n="(",i++):(n=null,0===s&&l('"("')),null===n&&(41===t.charCodeAt(i)?(n=")",i++):(n=null,0===s&&l('")"')),null===n&&(60===t.charCodeAt(i)?(n="<",i++):(n=null,0===s&&l('"<"')),null===n&&(62===t.charCodeAt(i)?(n=">",i++):(n=null,0===s&&l('">"')),null===n&&(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null===n&&(92===t.charCodeAt(i)?(n="\\",i++):(n=null,0===s&&l('"\\\\"')),null===n&&null===(n=v())&&(47===t.charCodeAt(i)?(n="/",i++):(n=null,0===s&&l('"/"')),null===n&&(91===t.charCodeAt(i)?(n="[",i++):(n=null,0===s&&l('"["')),null===n&&(93===t.charCodeAt(i)?(n="]",i++):(n=null,0===s&&l('"]"')),null===n&&(63===t.charCodeAt(i)?(n="?",i++):(n=null,0===s&&l('"?"')),null===n&&(123===t.charCodeAt(i)?(n="{",i++):(n=null,0===s&&l('"{"')),null===n&&(125===t.charCodeAt(i)?(n="}",i++):(n=null,0===s&&l('"}"'))))))))))))))))))))))));else e=null;return null!==e&&(e=function(e){return t.substring(i,e)}(r)),null===e&&(i=r),e}function D(){var e,n,r,o,u;return o=i,u=i,null!==(e=w())?(42===t.charCodeAt(i)?(n="*",i++):(n=null,0===s&&l('"*"')),null!==n&&null!==(r=w())?e=[e,n,r]:(e=null,i=u)):(e=null,i=u),null!==e&&(e="*"),null===e&&(i=o),e}function U(){var e,n,r,o,u;return o=i,u=i,null!==(e=w())?(47===t.charCodeAt(i)?(n="/",i++):(n=null,0===s&&l('"/"')),null!==n&&null!==(r=w())?e=[e,n,r]:(e=null,i=u)):(e=null,i=u),null!==e&&(e="/"),null===e&&(i=o),e}function M(){var e,n,r,o,u;return o=i,u=i,null!==(e=w())?(61===t.charCodeAt(i)?(n="=",i++):(n=null,0===s&&l('"="')),null!==n&&null!==(r=w())?e=[e,n,r]:(e=null,i=u)):(e=null,i=u),null!==e&&(e="="),null===e&&(i=o),e}function L(){var e,n,r,o,u;return o=i,u=i,null!==(e=w())?(40===t.charCodeAt(i)?(n="(",i++):(n=null,0===s&&l('"("')),null!==n&&null!==(r=w())?e=[e,n,r]:(e=null,i=u)):(e=null,i=u),null!==e&&(e="("),null===e&&(i=o),e}function q(){var e,n,r,o,u;return o=i,u=i,null!==(e=w())?(41===t.charCodeAt(i)?(n=")",i++):(n=null,0===s&&l('")"')),null!==n&&null!==(r=w())?e=[e,n,r]:(e=null,i=u)):(e=null,i=u),null!==e&&(e=")"),null===e&&(i=o),e}function j(){var e,n,r,o;return r=i,o=i,62===t.charCodeAt(i)?(e=">",i++):(e=null,0===s&&l('">"')),null!==e&&null!==(n=w())?e=[e,n]:(e=null,i=o),null!==e&&(e=">"),null===e&&(i=r),e}function H(){var e,n,r,o;return r=i,o=i,null!==(e=w())?(60===t.charCodeAt(i)?(n="<",i++):(n=null,0===s&&l('"<"')),null!==n?e=[e,n]:(e=null,i=o)):(e=null,i=o),null!==e&&(e="<"),null===e&&(i=r),e}function F(){var e,n,r,o,u;return o=i,u=i,null!==(e=w())?(44===t.charCodeAt(i)?(n=",",i++):(n=null,0===s&&l('","')),null!==n&&null!==(r=w())?e=[e,n,r]:(e=null,i=u)):(e=null,i=u),null!==e&&(e=","),null===e&&(i=o),e}function B(){var e,n,r,o,u;return o=i,u=i,null!==(e=w())?(59===t.charCodeAt(i)?(n=";",i++):(n=null,0===s&&l('";"')),null!==n&&null!==(r=w())?e=[e,n,r]:(e=null,i=u)):(e=null,i=u),null!==e&&(e=";"),null===e&&(i=o),e}function G(){var e,n,r,o,u;return o=i,u=i,null!==(e=w())?(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(r=w())?e=[e,n,r]:(e=null,i=u)):(e=null,i=u),null!==e&&(e=":"),null===e&&(i=o),e}function W(){var e,t,n,r;return n=i,r=i,null!==(e=w())&&null!==(t=v())?e=[e,t]:(e=null,i=r),null!==e&&(e='"'),null===e&&(i=n),e}function V(){var e,t,n,r;return n=i,r=i,null!==(e=v())&&null!==(t=w())?e=[e,t]:(e=null,i=r),null!==e&&(e='"'),null===e&&(i=n),e}function K(){var e;return/^[!-']/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[!-']")),null===e&&(/^[*-[]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[*-[]")),null===e&&(/^[\]-~]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[\\]-~]")),null===e&&null===(e=O())&&(e=C()))),e}function Y(){var e,n,r,o,s,u;if(s=i,u=i,null!==(e=w()))if(null!==(n=v())){for(r=[],null===(o=$())&&(o=J());null!==o;)r.push(o),null===(o=$())&&(o=J());null!==r&&null!==(o=v())?e=[e,n,r,o]:(e=null,i=u)}else e=null,i=u;else e=null,i=u;return null!==e&&(e=function(e){return t.substring(i,e)}(s)),null===e&&(i=s),e}function z(){var e,n,r,o,s,u;if(s=i,u=i,null!==(e=w()))if(null!==(n=v())){for(r=[],null===(o=$())&&(o=J());null!==o;)r.push(o),null===(o=$())&&(o=J());null!==r&&null!==(o=v())?e=[e,n,r,o]:(e=null,i=u)}else e=null,i=u;else e=null,i=u;return null!==e&&(e=function(e){var n=t.substring(i,e).trim();return n.substring(1,n.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(s)),null===e&&(i=s),e}function $(){var e;return null===(e=C())&&(33===t.charCodeAt(i)?(e="!",i++):(e=null,0===s&&l('"!"')),null===e&&(/^[#-[]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[#-[]")),null===e&&(/^[\]-~]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[\\]-~]")),null===e&&(e=O())))),e}function J(){var e,n,r;return r=i,92===t.charCodeAt(i)?(e="\\",i++):(e=null,0===s&&l('"\\\\"')),null!==e?(/^[\0-\t]/.test(t.charAt(i))?(n=t.charAt(i),i++):(n=null,0===s&&l("[\\0-\\t]")),null===n&&(/^[\x0B-\f]/.test(t.charAt(i))?(n=t.charAt(i),i++):(n=null,0===s&&l("[\\x0B-\\f]")),null===n&&(/^[\x0E-]/.test(t.charAt(i))?(n=t.charAt(i),i++):(n=null,0===s&&l("[\\x0E-]")))),null!==n?e=[e,n]:(e=null,i=r)):(e=null,i=r),e}function X(){var e,n,r,o,u,a;return u=i,a=i,null!==(e=Z())?(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(r=null!==(r=ne())?r:"")&&null!==(o=se())?e=[e,n,r,o]:(e=null,i=a)):(e=null,i=a),null!==e&&(e=function(){try{Fn.uri=new jn(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&&(i=u),e}function Q(){var e,n,o,u,a,c,f,h;return f=i,h=i,null!==(e=Z())?(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(o=null!==(o=ne())?o:"")&&null!==(u=se())&&null!==(a=ye())&&null!==(c=null!==(c=Ne())?c:"")?e=[e,n,o,u,a,c]:(e=null,i=h)):(e=null,i=h),null!==e&&(e=function(){try{Fn.uri=new jn(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&&(i=f),e}function Z(){var e;return null===(e=ee())&&(e=te()),e}function ee(){var e,n,r;return n=i,"sips"===t.substr(i,4).toLowerCase()?(e=t.substr(i,4),i+=4):(e=null,0===s&&l('"sips"')),null!==e&&(r=e,e=void(Fn.scheme=r.toLowerCase())),null===e&&(i=n),e}function te(){var e,n,r;return n=i,"sip"===t.substr(i,3).toLowerCase()?(e=t.substr(i,3),i+=3):(e=null,0===s&&l('"sip"')),null!==e&&(r=e,e=void(Fn.scheme=r.toLowerCase())),null===e&&(i=n),e}function ne(){var e,n,r,o,u,a;return o=i,u=i,null!==(e=re())?(a=i,58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(r=ie())?n=[n,r]:(n=null,i=a),null!==(n=null!==n?n:"")?(64===t.charCodeAt(i)?(r="@",i++):(r=null,0===s&&l('"@"')),null!==r?e=[e,n,r]:(e=null,i=u)):(e=null,i=u)):(e=null,i=u),null!==e&&(e=function(e){Fn.user=decodeURIComponent(t.substring(i-1,e))}(o)),null===e&&(i=o),e}function re(){var e,t;if(null===(t=T())&&null===(t=E())&&(t=oe()),null!==t)for(e=[];null!==t;)e.push(t),null===(t=T())&&null===(t=E())&&(t=oe());else e=null;return e}function oe(){var e;return 38===t.charCodeAt(i)?(e="&",i++):(e=null,0===s&&l('"&"')),null===e&&(61===t.charCodeAt(i)?(e="=",i++):(e=null,0===s&&l('"="')),null===e&&(43===t.charCodeAt(i)?(e="+",i++):(e=null,0===s&&l('"+"')),null===e&&(36===t.charCodeAt(i)?(e="$",i++):(e=null,0===s&&l('"$"')),null===e&&(44===t.charCodeAt(i)?(e=",",i++):(e=null,0===s&&l('","')),null===e&&(59===t.charCodeAt(i)?(e=";",i++):(e=null,0===s&&l('";"')),null===e&&(63===t.charCodeAt(i)?(e="?",i++):(e=null,0===s&&l('"?"')),null===e&&(47===t.charCodeAt(i)?(e="/",i++):(e=null,0===s&&l('"/"'))))))))),e}function ie(){var e,n,r;for(r=i,e=[],null===(n=T())&&null===(n=E())&&(38===t.charCodeAt(i)?(n="&",i++):(n=null,0===s&&l('"&"')),null===n&&(61===t.charCodeAt(i)?(n="=",i++):(n=null,0===s&&l('"="')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&l('"+"')),null===n&&(36===t.charCodeAt(i)?(n="$",i++):(n=null,0===s&&l('"$"')),null===n&&(44===t.charCodeAt(i)?(n=",",i++):(n=null,0===s&&l('","')))))));null!==n;)e.push(n),null===(n=T())&&null===(n=E())&&(38===t.charCodeAt(i)?(n="&",i++):(n=null,0===s&&l('"&"')),null===n&&(61===t.charCodeAt(i)?(n="=",i++):(n=null,0===s&&l('"="')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&l('"+"')),null===n&&(36===t.charCodeAt(i)?(n="$",i++):(n=null,0===s&&l('"$"')),null===n&&(44===t.charCodeAt(i)?(n=",",i++):(n=null,0===s&&l('","')))))));return null!==e&&(e=function(e){Fn.password=t.substring(i,e)}(r)),null===e&&(i=r),e}function se(){var e,n,r,o,u;return o=i,null!==(e=ue())?(u=i,58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(r=me())?n=[n,r]:(n=null,i=u),null!==(n=null!==n?n:"")?e=[e,n]:(e=null,i=o)):(e=null,i=o),e}function ue(){var e,n;return n=i,null===(e=ae())&&null===(e=_e())&&(e=fe()),null!==e&&(e=function(e){return Fn.host=t.substring(i,e).toLowerCase(),Fn.host}(n)),null===e&&(i=n),e}function ae(){var e,n,r,o,u,a;for(o=i,u=i,e=[],a=i,null!==(n=le())?(46===t.charCodeAt(i)?(r=".",i++):(r=null,0===s&&l('"."')),null!==r?n=[n,r]:(n=null,i=a)):(n=null,i=a);null!==n;)e.push(n),a=i,null!==(n=le())?(46===t.charCodeAt(i)?(r=".",i++):(r=null,0===s&&l('"."')),null!==r?n=[n,r]:(n=null,i=a)):(n=null,i=a);return null!==e&&null!==(n=ce())?(46===t.charCodeAt(i)?(r=".",i++):(r=null,0===s&&l('"."')),null!==(r=null!==r?r:"")?e=[e,n,r]:(e=null,i=u)):(e=null,i=u),null!==e&&(e=function(e){return Fn.host_type="domain",t.substring(i,e)}(o)),null===e&&(i=o),e}function le(){var e,n,r,o;if(o=i,null!==(e=g())){for(n=[],null===(r=g())&&(45===t.charCodeAt(i)?(r="-",i++):(r=null,0===s&&l('"-"')),null===r&&(95===t.charCodeAt(i)?(r="_",i++):(r=null,0===s&&l('"_"'))));null!==r;)n.push(r),null===(r=g())&&(45===t.charCodeAt(i)?(r="-",i++):(r=null,0===s&&l('"-"')),null===r&&(95===t.charCodeAt(i)?(r="_",i++):(r=null,0===s&&l('"_"'))));null!==n?e=[e,n]:(e=null,i=o)}else e=null,i=o;return e}function ce(){var e,n,r,o;if(o=i,null!==(e=h())){for(n=[],null===(r=g())&&(45===t.charCodeAt(i)?(r="-",i++):(r=null,0===s&&l('"-"')),null===r&&(95===t.charCodeAt(i)?(r="_",i++):(r=null,0===s&&l('"_"'))));null!==r;)n.push(r),null===(r=g())&&(45===t.charCodeAt(i)?(r="-",i++):(r=null,0===s&&l('"-"')),null===r&&(95===t.charCodeAt(i)?(r="_",i++):(r=null,0===s&&l('"_"'))));null!==n?e=[e,n]:(e=null,i=o)}else e=null,i=o;return e}function fe(){var e,n,r,o,u;return o=i,u=i,91===t.charCodeAt(i)?(e="[",i++):(e=null,0===s&&l('"["')),null!==e&&null!==(n=he())?(93===t.charCodeAt(i)?(r="]",i++):(r=null,0===s&&l('"]"')),null!==r?e=[e,n,r]:(e=null,i=u)):(e=null,i=u),null!==e&&(e=function(e){return Fn.host_type="IPv6",t.substring(i,e)}(o)),null===e&&(i=o),e}function he(){var e,n,r,o,u,a,c,f,h,d,p,_,v,m,y,g;return m=i,y=i,null!==(e=de())?(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(r=de())?(58===t.charCodeAt(i)?(o=":",i++):(o=null,0===s&&l('":"')),null!==o&&null!==(u=de())?(58===t.charCodeAt(i)?(a=":",i++):(a=null,0===s&&l('":"')),null!==a&&null!==(c=de())?(58===t.charCodeAt(i)?(f=":",i++):(f=null,0===s&&l('":"')),null!==f&&null!==(h=de())?(58===t.charCodeAt(i)?(d=":",i++):(d=null,0===s&&l('":"')),null!==d&&null!==(p=de())?(58===t.charCodeAt(i)?(_=":",i++):(_=null,0===s&&l('":"')),null!==_&&null!==(v=pe())?e=[e,n,r,o,u,a,c,f,h,d,p,_,v]:(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y),null===e&&(y=i,"::"===t.substr(i,2)?(e="::",i+=2):(e=null,0===s&&l('"::"')),null!==e&&null!==(n=de())?(58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&l('":"')),null!==r&&null!==(o=de())?(58===t.charCodeAt(i)?(u=":",i++):(u=null,0===s&&l('":"')),null!==u&&null!==(a=de())?(58===t.charCodeAt(i)?(c=":",i++):(c=null,0===s&&l('":"')),null!==c&&null!==(f=de())?(58===t.charCodeAt(i)?(h=":",i++):(h=null,0===s&&l('":"')),null!==h&&null!==(d=de())?(58===t.charCodeAt(i)?(p=":",i++):(p=null,0===s&&l('":"')),null!==p&&null!==(_=pe())?e=[e,n,r,o,u,a,c,f,h,d,p,_]:(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y),null===e&&(y=i,"::"===t.substr(i,2)?(e="::",i+=2):(e=null,0===s&&l('"::"')),null!==e&&null!==(n=de())?(58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&l('":"')),null!==r&&null!==(o=de())?(58===t.charCodeAt(i)?(u=":",i++):(u=null,0===s&&l('":"')),null!==u&&null!==(a=de())?(58===t.charCodeAt(i)?(c=":",i++):(c=null,0===s&&l('":"')),null!==c&&null!==(f=de())?(58===t.charCodeAt(i)?(h=":",i++):(h=null,0===s&&l('":"')),null!==h&&null!==(d=pe())?e=[e,n,r,o,u,a,c,f,h,d]:(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y),null===e&&(y=i,"::"===t.substr(i,2)?(e="::",i+=2):(e=null,0===s&&l('"::"')),null!==e&&null!==(n=de())?(58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&l('":"')),null!==r&&null!==(o=de())?(58===t.charCodeAt(i)?(u=":",i++):(u=null,0===s&&l('":"')),null!==u&&null!==(a=de())?(58===t.charCodeAt(i)?(c=":",i++):(c=null,0===s&&l('":"')),null!==c&&null!==(f=pe())?e=[e,n,r,o,u,a,c,f]:(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y),null===e&&(y=i,"::"===t.substr(i,2)?(e="::",i+=2):(e=null,0===s&&l('"::"')),null!==e&&null!==(n=de())?(58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&l('":"')),null!==r&&null!==(o=de())?(58===t.charCodeAt(i)?(u=":",i++):(u=null,0===s&&l('":"')),null!==u&&null!==(a=pe())?e=[e,n,r,o,u,a]:(e=null,i=y)):(e=null,i=y)):(e=null,i=y),null===e&&(y=i,"::"===t.substr(i,2)?(e="::",i+=2):(e=null,0===s&&l('"::"')),null!==e&&null!==(n=de())?(58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&l('":"')),null!==r&&null!==(o=pe())?e=[e,n,r,o]:(e=null,i=y)):(e=null,i=y),null===e&&(y=i,"::"===t.substr(i,2)?(e="::",i+=2):(e=null,0===s&&l('"::"')),null!==e&&null!==(n=pe())?e=[e,n]:(e=null,i=y),null===e&&(y=i,"::"===t.substr(i,2)?(e="::",i+=2):(e=null,0===s&&l('"::"')),null!==e&&null!==(n=de())?e=[e,n]:(e=null,i=y),null===e&&(y=i,null!==(e=de())?("::"===t.substr(i,2)?(n="::",i+=2):(n=null,0===s&&l('"::"')),null!==n&&null!==(r=de())?(58===t.charCodeAt(i)?(o=":",i++):(o=null,0===s&&l('":"')),null!==o&&null!==(u=de())?(58===t.charCodeAt(i)?(a=":",i++):(a=null,0===s&&l('":"')),null!==a&&null!==(c=de())?(58===t.charCodeAt(i)?(f=":",i++):(f=null,0===s&&l('":"')),null!==f&&null!==(h=de())?(58===t.charCodeAt(i)?(d=":",i++):(d=null,0===s&&l('":"')),null!==d&&null!==(p=pe())?e=[e,n,r,o,u,a,c,f,h,d,p]:(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y),null===e&&(y=i,null!==(e=de())?(g=i,58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(r=de())?n=[n,r]:(n=null,i=g),null!==(n=null!==n?n:"")?("::"===t.substr(i,2)?(r="::",i+=2):(r=null,0===s&&l('"::"')),null!==r&&null!==(o=de())?(58===t.charCodeAt(i)?(u=":",i++):(u=null,0===s&&l('":"')),null!==u&&null!==(a=de())?(58===t.charCodeAt(i)?(c=":",i++):(c=null,0===s&&l('":"')),null!==c&&null!==(f=de())?(58===t.charCodeAt(i)?(h=":",i++):(h=null,0===s&&l('":"')),null!==h&&null!==(d=pe())?e=[e,n,r,o,u,a,c,f,h,d]:(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y),null===e&&(y=i,null!==(e=de())?(g=i,58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(r=de())?n=[n,r]:(n=null,i=g),null!==(n=null!==n?n:"")?(g=i,58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&l('":"')),null!==r&&null!==(o=de())?r=[r,o]:(r=null,i=g),null!==(r=null!==r?r:"")?("::"===t.substr(i,2)?(o="::",i+=2):(o=null,0===s&&l('"::"')),null!==o&&null!==(u=de())?(58===t.charCodeAt(i)?(a=":",i++):(a=null,0===s&&l('":"')),null!==a&&null!==(c=de())?(58===t.charCodeAt(i)?(f=":",i++):(f=null,0===s&&l('":"')),null!==f&&null!==(h=pe())?e=[e,n,r,o,u,a,c,f,h]:(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y),null===e&&(y=i,null!==(e=de())?(g=i,58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(r=de())?n=[n,r]:(n=null,i=g),null!==(n=null!==n?n:"")?(g=i,58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&l('":"')),null!==r&&null!==(o=de())?r=[r,o]:(r=null,i=g),null!==(r=null!==r?r:"")?(g=i,58===t.charCodeAt(i)?(o=":",i++):(o=null,0===s&&l('":"')),null!==o&&null!==(u=de())?o=[o,u]:(o=null,i=g),null!==(o=null!==o?o:"")?("::"===t.substr(i,2)?(u="::",i+=2):(u=null,0===s&&l('"::"')),null!==u&&null!==(a=de())?(58===t.charCodeAt(i)?(c=":",i++):(c=null,0===s&&l('":"')),null!==c&&null!==(f=pe())?e=[e,n,r,o,u,a,c,f]:(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y),null===e&&(y=i,null!==(e=de())?(g=i,58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(r=de())?n=[n,r]:(n=null,i=g),null!==(n=null!==n?n:"")?(g=i,58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&l('":"')),null!==r&&null!==(o=de())?r=[r,o]:(r=null,i=g),null!==(r=null!==r?r:"")?(g=i,58===t.charCodeAt(i)?(o=":",i++):(o=null,0===s&&l('":"')),null!==o&&null!==(u=de())?o=[o,u]:(o=null,i=g),null!==(o=null!==o?o:"")?(g=i,58===t.charCodeAt(i)?(u=":",i++):(u=null,0===s&&l('":"')),null!==u&&null!==(a=de())?u=[u,a]:(u=null,i=g),null!==(u=null!==u?u:"")?("::"===t.substr(i,2)?(a="::",i+=2):(a=null,0===s&&l('"::"')),null!==a&&null!==(c=pe())?e=[e,n,r,o,u,a,c]:(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y),null===e&&(y=i,null!==(e=de())?(g=i,58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(r=de())?n=[n,r]:(n=null,i=g),null!==(n=null!==n?n:"")?(g=i,58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&l('":"')),null!==r&&null!==(o=de())?r=[r,o]:(r=null,i=g),null!==(r=null!==r?r:"")?(g=i,58===t.charCodeAt(i)?(o=":",i++):(o=null,0===s&&l('":"')),null!==o&&null!==(u=de())?o=[o,u]:(o=null,i=g),null!==(o=null!==o?o:"")?(g=i,58===t.charCodeAt(i)?(u=":",i++):(u=null,0===s&&l('":"')),null!==u&&null!==(a=de())?u=[u,a]:(u=null,i=g),null!==(u=null!==u?u:"")?(g=i,58===t.charCodeAt(i)?(a=":",i++):(a=null,0===s&&l('":"')),null!==a&&null!==(c=de())?a=[a,c]:(a=null,i=g),null!==(a=null!==a?a:"")?("::"===t.substr(i,2)?(c="::",i+=2):(c=null,0===s&&l('"::"')),null!==c&&null!==(f=de())?e=[e,n,r,o,u,a,c,f]:(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y),null===e&&(y=i,null!==(e=de())?(g=i,58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(r=de())?n=[n,r]:(n=null,i=g),null!==(n=null!==n?n:"")?(g=i,58===t.charCodeAt(i)?(r=":",i++):(r=null,0===s&&l('":"')),null!==r&&null!==(o=de())?r=[r,o]:(r=null,i=g),null!==(r=null!==r?r:"")?(g=i,58===t.charCodeAt(i)?(o=":",i++):(o=null,0===s&&l('":"')),null!==o&&null!==(u=de())?o=[o,u]:(o=null,i=g),null!==(o=null!==o?o:"")?(g=i,58===t.charCodeAt(i)?(u=":",i++):(u=null,0===s&&l('":"')),null!==u&&null!==(a=de())?u=[u,a]:(u=null,i=g),null!==(u=null!==u?u:"")?(g=i,58===t.charCodeAt(i)?(a=":",i++):(a=null,0===s&&l('":"')),null!==a&&null!==(c=de())?a=[a,c]:(a=null,i=g),null!==(a=null!==a?a:"")?(g=i,58===t.charCodeAt(i)?(c=":",i++):(c=null,0===s&&l('":"')),null!==c&&null!==(f=de())?c=[c,f]:(c=null,i=g),null!==(c=null!==c?c:"")?("::"===t.substr(i,2)?(f="::",i+=2):(f=null,0===s&&l('"::"')),null!==f?e=[e,n,r,o,u,a,c,f]:(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y)):(e=null,i=y))))))))))))))),null!==e&&(e=function(e){return Fn.host_type="IPv6",t.substring(i,e)}(m)),null===e&&(i=m),e}function de(){var e,t,n,r,o;return o=i,null!==(e=d())&&null!==(t=null!==(t=d())?t:"")&&null!==(n=null!==(n=d())?n:"")&&null!==(r=null!==(r=d())?r:"")?e=[e,t,n,r]:(e=null,i=o),e}function pe(){var e,n,r,o;return o=i,null!==(e=de())?(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n&&null!==(r=de())?e=[e,n,r]:(e=null,i=o)):(e=null,i=o),null===e&&(e=_e()),e}function _e(){var e,n,r,o,u,a,c,f,h;return f=i,h=i,null!==(e=ve())?(46===t.charCodeAt(i)?(n=".",i++):(n=null,0===s&&l('"."')),null!==n&&null!==(r=ve())?(46===t.charCodeAt(i)?(o=".",i++):(o=null,0===s&&l('"."')),null!==o&&null!==(u=ve())?(46===t.charCodeAt(i)?(a=".",i++):(a=null,0===s&&l('"."')),null!==a&&null!==(c=ve())?e=[e,n,r,o,u,a,c]:(e=null,i=h)):(e=null,i=h)):(e=null,i=h)):(e=null,i=h),null!==e&&(e=function(e){return Fn.host_type="IPv4",t.substring(i,e)}(f)),null===e&&(i=f),e}function ve(){var e,n,r,o;return o=i,"25"===t.substr(i,2)?(e="25",i+=2):(e=null,0===s&&l('"25"')),null!==e?(/^[0-5]/.test(t.charAt(i))?(n=t.charAt(i),i++):(n=null,0===s&&l("[0-5]")),null!==n?e=[e,n]:(e=null,i=o)):(e=null,i=o),null===e&&(o=i,50===t.charCodeAt(i)?(e="2",i++):(e=null,0===s&&l('"2"')),null!==e?(/^[0-4]/.test(t.charAt(i))?(n=t.charAt(i),i++):(n=null,0===s&&l("[0-4]")),null!==n&&null!==(r=f())?e=[e,n,r]:(e=null,i=o)):(e=null,i=o),null===e&&(o=i,49===t.charCodeAt(i)?(e="1",i++):(e=null,0===s&&l('"1"')),null!==e&&null!==(n=f())&&null!==(r=f())?e=[e,n,r]:(e=null,i=o),null===e&&(o=i,/^[1-9]/.test(t.charAt(i))?(e=t.charAt(i),i++):(e=null,0===s&&l("[1-9]")),null!==e&&null!==(n=f())?e=[e,n]:(e=null,i=o),null===e&&(e=f())))),e}function me(){var e,t,n,r,o,s,u,a;return s=i,u=i,null!==(e=null!==(e=f())?e:"")&&null!==(t=null!==(t=f())?t:"")&&null!==(n=null!==(n=f())?n:"")&&null!==(r=null!==(r=f())?r:"")&&null!==(o=null!==(o=f())?o:"")?e=[e,t,n,r,o]:(e=null,i=u),null!==e&&(a=e,a=parseInt(a.join("")),Fn.port=a,e=a),null===e&&(i=s),e}function ye(){var e,n,r,o;for(e=[],o=i,59===t.charCodeAt(i)?(n=";",i++):(n=null,0===s&&l('";"')),null!==n&&null!==(r=ge())?n=[n,r]:(n=null,i=o);null!==n;)e.push(n),o=i,59===t.charCodeAt(i)?(n=";",i++):(n=null,0===s&&l('";"')),null!==n&&null!==(r=ge())?n=[n,r]:(n=null,i=o);return e}function ge(){var e;return null===(e=be())&&null===(e=Te())&&null===(e=Se())&&null===(e=Ee())&&null===(e=Ce())&&null===(e=we())&&(e=Ae()),e}function be(){var e,n,r,o,u;return r=i,o=i,"transport="===t.substr(i,10).toLowerCase()?(e=t.substr(i,10),i+=10):(e=null,0===s&&l('"transport="')),null!==e?("udp"===t.substr(i,3).toLowerCase()?(n=t.substr(i,3),i+=3):(n=null,0===s&&l('"udp"')),null===n&&("tcp"===t.substr(i,3).toLowerCase()?(n=t.substr(i,3),i+=3):(n=null,0===s&&l('"tcp"')),null===n&&("sctp"===t.substr(i,4).toLowerCase()?(n=t.substr(i,4),i+=4):(n=null,0===s&&l('"sctp"')),null===n&&("tls"===t.substr(i,3).toLowerCase()?(n=t.substr(i,3),i+=3):(n=null,0===s&&l('"tls"')),null===n&&(n=N())))),null!==n?e=[e,n]:(e=null,i=o)):(e=null,i=o),null!==e&&(u=e[1],Fn.uri_params||(Fn.uri_params={}),e=void(Fn.uri_params.transport=u.toLowerCase())),null===e&&(i=r),e}function Te(){var e,n,r,o,u;return r=i,o=i,"user="===t.substr(i,5).toLowerCase()?(e=t.substr(i,5),i+=5):(e=null,0===s&&l('"user="')),null!==e?("phone"===t.substr(i,5).toLowerCase()?(n=t.substr(i,5),i+=5):(n=null,0===s&&l('"phone"')),null===n&&("ip"===t.substr(i,2).toLowerCase()?(n=t.substr(i,2),i+=2):(n=null,0===s&&l('"ip"')),null===n&&(n=N())),null!==n?e=[e,n]:(e=null,i=o)):(e=null,i=o),null!==e&&(u=e[1],Fn.uri_params||(Fn.uri_params={}),e=void(Fn.uri_params.user=u.toLowerCase())),null===e&&(i=r),e}function Se(){var e,n,r,o,u;return r=i,o=i,"method="===t.substr(i,7).toLowerCase()?(e=t.substr(i,7),i+=7):(e=null,0===s&&l('"method="')),null!==e&&null!==(n=ct())?e=[e,n]:(e=null,i=o),null!==e&&(u=e[1],Fn.uri_params||(Fn.uri_params={}),e=void(Fn.uri_params.method=u)),null===e&&(i=r),e}function Ee(){var e,n,r,o,u;return r=i,o=i,"ttl="===t.substr(i,4).toLowerCase()?(e=t.substr(i,4),i+=4):(e=null,0===s&&l('"ttl="')),null!==e&&null!==(n=wn())?e=[e,n]:(e=null,i=o),null!==e&&(u=e[1],Fn.params||(Fn.params={}),e=void(Fn.params.ttl=u)),null===e&&(i=r),e}function Ce(){var e,n,r,o,u;return r=i,o=i,"maddr="===t.substr(i,6).toLowerCase()?(e=t.substr(i,6),i+=6):(e=null,0===s&&l('"maddr="')),null!==e&&null!==(n=ue())?e=[e,n]:(e=null,i=o),null!==e&&(u=e[1],Fn.uri_params||(Fn.uri_params={}),e=void(Fn.uri_params.maddr=u)),null===e&&(i=r),e}function we(){var e,n,r,o,u,a;return o=i,u=i,"lr"===t.substr(i,2).toLowerCase()?(e=t.substr(i,2),i+=2):(e=null,0===s&&l('"lr"')),null!==e?(a=i,61===t.charCodeAt(i)?(n="=",i++):(n=null,0===s&&l('"="')),null!==n&&null!==(r=N())?n=[n,r]:(n=null,i=a),null!==(n=null!==n?n:"")?e=[e,n]:(e=null,i=u)):(e=null,i=u),null!==e&&(Fn.uri_params||(Fn.uri_params={}),e=void(Fn.uri_params.lr=void 0)),null===e&&(i=o),e}function Ae(){var e,n,r,o,u,a,c,f;return o=i,u=i,null!==(e=Re())?(a=i,61===t.charCodeAt(i)?(n="=",i++):(n=null,0===s&&l('"="')),null!==n&&null!==(r=Ie())?n=[n,r]:(n=null,i=a),null!==(n=null!==n?n:"")?e=[e,n]:(e=null,i=u)):(e=null,i=u),null!==e&&(c=e[0],f=e[1],Fn.uri_params||(Fn.uri_params={}),f=void 0===f?void 0:f[1],e=void(Fn.uri_params[c.toLowerCase()]=f)),null===e&&(i=o),e}function Re(){var e,t,n;if(n=i,null!==(t=Oe()))for(e=[];null!==t;)e.push(t),t=Oe();else e=null;return null!==e&&(e=e.join("")),null===e&&(i=n),e}function Ie(){var e,t,n;if(n=i,null!==(t=Oe()))for(e=[];null!==t;)e.push(t),t=Oe();else e=null;return null!==e&&(e=e.join("")),null===e&&(i=n),e}function Oe(){var e;return null===(e=ke())&&null===(e=T())&&(e=E()),e}function ke(){var e;return 91===t.charCodeAt(i)?(e="[",i++):(e=null,0===s&&l('"["')),null===e&&(93===t.charCodeAt(i)?(e="]",i++):(e=null,0===s&&l('"]"')),null===e&&(47===t.charCodeAt(i)?(e="/",i++):(e=null,0===s&&l('"/"')),null===e&&(58===t.charCodeAt(i)?(e=":",i++):(e=null,0===s&&l('":"')),null===e&&(38===t.charCodeAt(i)?(e="&",i++):(e=null,0===s&&l('"&"')),null===e&&(43===t.charCodeAt(i)?(e="+",i++):(e=null,0===s&&l('"+"')),null===e&&(36===t.charCodeAt(i)?(e="$",i++):(e=null,0===s&&l('"$"')))))))),e}function Ne(){var e,n,r,o,u,a,c;if(a=i,63===t.charCodeAt(i)?(e="?",i++):(e=null,0===s&&l('"?"')),null!==e)if(null!==(n=xe())){for(r=[],c=i,38===t.charCodeAt(i)?(o="&",i++):(o=null,0===s&&l('"&"')),null!==o&&null!==(u=xe())?o=[o,u]:(o=null,i=c);null!==o;)r.push(o),c=i,38===t.charCodeAt(i)?(o="&",i++):(o=null,0===s&&l('"&"')),null!==o&&null!==(u=xe())?o=[o,u]:(o=null,i=c);null!==r?e=[e,n,r]:(e=null,i=a)}else e=null,i=a;else e=null,i=a;return e}function xe(){var e,n,r,o,u,a,c;return o=i,u=i,null!==(e=Pe())?(61===t.charCodeAt(i)?(n="=",i++):(n=null,0===s&&l('"="')),null!==n&&null!==(r=De())?e=[e,n,r]:(e=null,i=u)):(e=null,i=u),null!==e&&(a=e[0],c=e[2],a=a.join("").toLowerCase(),c=c.join(""),Fn.uri_headers||(Fn.uri_headers={}),e=void(Fn.uri_headers[a]?Fn.uri_headers[a].push(c):Fn.uri_headers[a]=[c])),null===e&&(i=o),e}function Pe(){var e,t;if(null===(t=Ue())&&null===(t=T())&&(t=E()),null!==t)for(e=[];null!==t;)e.push(t),null===(t=Ue())&&null===(t=T())&&(t=E());else e=null;return e}function De(){var e,t;for(e=[],null===(t=Ue())&&null===(t=T())&&(t=E());null!==t;)e.push(t),null===(t=Ue())&&null===(t=T())&&(t=E());return e}function Ue(){var e;return 91===t.charCodeAt(i)?(e="[",i++):(e=null,0===s&&l('"["')),null===e&&(93===t.charCodeAt(i)?(e="]",i++):(e=null,0===s&&l('"]"')),null===e&&(47===t.charCodeAt(i)?(e="/",i++):(e=null,0===s&&l('"/"')),null===e&&(63===t.charCodeAt(i)?(e="?",i++):(e=null,0===s&&l('"?"')),null===e&&(58===t.charCodeAt(i)?(e=":",i++):(e=null,0===s&&l('":"')),null===e&&(43===t.charCodeAt(i)?(e="+",i++):(e=null,0===s&&l('"+"')),null===e&&(36===t.charCodeAt(i)?(e="$",i++):(e=null,0===s&&l('"$"')))))))),e}function Me(){var e,t,n,r,o,s;return s=i,null!==(e=ct())&&null!==(t=m())&&null!==(n=Le())&&null!==(r=m())&&null!==(o=et())?e=[e,t,n,r,o]:(e=null,i=s),e}function Le(){var e;return null===(e=Q())&&(e=qe()),e}function qe(){var e,n,r,o;return o=i,null!==(e=$e())?(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null!==n?(null===(r=je())&&(r=Be()),null!==r?e=[e,n,r]:(e=null,i=o)):(e=null,i=o)):(e=null,i=o),e}function je(){var e,n,r,o,u;return o=i,null===(e=He())&&(e=Fe()),null!==e?(u=i,63===t.charCodeAt(i)?(n="?",i++):(n=null,0===s&&l('"?"')),null!==n&&null!==(r=Ze())?n=[n,r]:(n=null,i=u),null!==(n=null!==n?n:"")?e=[e,n]:(e=null,i=o)):(e=null,i=o),e}function He(){var e,n,r,o;return o=i,"//"===t.substr(i,2)?(e="//",i+=2):(e=null,0===s&&l('"//"')),null!==e&&null!==(n=Je())&&null!==(r=null!==(r=Fe())?r:"")?e=[e,n,r]:(e=null,i=o),e}function Fe(){var e,n,r;return r=i,47===t.charCodeAt(i)?(e="/",i++):(e=null,0===s&&l('"/"')),null!==e&&null!==(n=Ve())?e=[e,n]:(e=null,i=r),e}function Be(){var e,t,n,r;if(r=i,null!==(e=We())){for(t=[],n=Ge();null!==n;)t.push(n),n=Ge();null!==t?e=[e,t]:(e=null,i=r)}else e=null,i=r;return e}function Ge(){var e;return null===(e=b())&&null===(e=T())&&(e=E()),e}function We(){var e;return null===(e=T())&&null===(e=E())&&(59===t.charCodeAt(i)?(e=";",i++):(e=null,0===s&&l('";"')),null===e&&(63===t.charCodeAt(i)?(e="?",i++):(e=null,0===s&&l('"?"')),null===e&&(58===t.charCodeAt(i)?(e=":",i++):(e=null,0===s&&l('":"')),null===e&&(64===t.charCodeAt(i)?(e="@",i++):(e=null,0===s&&l('"@"')),null===e&&(38===t.charCodeAt(i)?(e="&",i++):(e=null,0===s&&l('"&"')),null===e&&(61===t.charCodeAt(i)?(e="=",i++):(e=null,0===s&&l('"="')),null===e&&(43===t.charCodeAt(i)?(e="+",i++):(e=null,0===s&&l('"+"')),null===e&&(36===t.charCodeAt(i)?(e="$",i++):(e=null,0===s&&l('"$"')),null===e&&(44===t.charCodeAt(i)?(e=",",i++):(e=null,0===s&&l('","'))))))))))),e}function Ve(){var e,n,r,o,u,a;if(u=i,null!==(e=Ke())){for(n=[],a=i,47===t.charCodeAt(i)?(r="/",i++):(r=null,0===s&&l('"/"')),null!==r&&null!==(o=Ke())?r=[r,o]:(r=null,i=a);null!==r;)n.push(r),a=i,47===t.charCodeAt(i)?(r="/",i++):(r=null,0===s&&l('"/"')),null!==r&&null!==(o=Ke())?r=[r,o]:(r=null,i=a);null!==n?e=[e,n]:(e=null,i=u)}else e=null,i=u;return e}function Ke(){var e,n,r,o,u,a;for(u=i,e=[],n=ze();null!==n;)e.push(n),n=ze();if(null!==e){for(n=[],a=i,59===t.charCodeAt(i)?(r=";",i++):(r=null,0===s&&l('";"')),null!==r&&null!==(o=Ye())?r=[r,o]:(r=null,i=a);null!==r;)n.push(r),a=i,59===t.charCodeAt(i)?(r=";",i++):(r=null,0===s&&l('";"')),null!==r&&null!==(o=Ye())?r=[r,o]:(r=null,i=a);null!==n?e=[e,n]:(e=null,i=u)}else e=null,i=u;return e}function Ye(){var e,t;for(e=[],t=ze();null!==t;)e.push(t),t=ze();return e}function ze(){var e;return null===(e=T())&&null===(e=E())&&(58===t.charCodeAt(i)?(e=":",i++):(e=null,0===s&&l('":"')),null===e&&(64===t.charCodeAt(i)?(e="@",i++):(e=null,0===s&&l('"@"')),null===e&&(38===t.charCodeAt(i)?(e="&",i++):(e=null,0===s&&l('"&"')),null===e&&(61===t.charCodeAt(i)?(e="=",i++):(e=null,0===s&&l('"="')),null===e&&(43===t.charCodeAt(i)?(e="+",i++):(e=null,0===s&&l('"+"')),null===e&&(36===t.charCodeAt(i)?(e="$",i++):(e=null,0===s&&l('"$"')),null===e&&(44===t.charCodeAt(i)?(e=",",i++):(e=null,0===s&&l('","'))))))))),e}function $e(){var e,n,r,o,u;if(o=i,u=i,null!==(e=h())){for(n=[],null===(r=h())&&null===(r=f())&&(43===t.charCodeAt(i)?(r="+",i++):(r=null,0===s&&l('"+"')),null===r&&(45===t.charCodeAt(i)?(r="-",i++):(r=null,0===s&&l('"-"')),null===r&&(46===t.charCodeAt(i)?(r=".",i++):(r=null,0===s&&l('"."')))));null!==r;)n.push(r),null===(r=h())&&null===(r=f())&&(43===t.charCodeAt(i)?(r="+",i++):(r=null,0===s&&l('"+"')),null===r&&(45===t.charCodeAt(i)?(r="-",i++):(r=null,0===s&&l('"-"')),null===r&&(46===t.charCodeAt(i)?(r=".",i++):(r=null,0===s&&l('"."')))));null!==n?e=[e,n]:(e=null,i=u)}else e=null,i=u;return null!==e&&(e=function(e){Fn.scheme=t.substring(i,e)}(o)),null===e&&(i=o),e}function Je(){var e;return null===(e=Xe())&&(e=Qe()),e}function Xe(){var e,n,r,o;return r=i,o=i,null!==(e=ne())?(64===t.charCodeAt(i)?(n="@",i++):(n=null,0===s&&l('"@"')),null!==n?e=[e,n]:(e=null,i=o)):(e=null,i=o),null!==(e=null!==e?e:"")&&null!==(n=se())?e=[e,n]:(e=null,i=r),e=null!==e?e:""}function Qe(){var e,n;if(null===(n=T())&&null===(n=E())&&(36===t.charCodeAt(i)?(n="$",i++):(n=null,0===s&&l('"$"')),null===n&&(44===t.charCodeAt(i)?(n=",",i++):(n=null,0===s&&l('","')),null===n&&(59===t.charCodeAt(i)?(n=";",i++):(n=null,0===s&&l('";"')),null===n&&(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null===n&&(64===t.charCodeAt(i)?(n="@",i++):(n=null,0===s&&l('"@"')),null===n&&(38===t.charCodeAt(i)?(n="&",i++):(n=null,0===s&&l('"&"')),null===n&&(61===t.charCodeAt(i)?(n="=",i++):(n=null,0===s&&l('"="')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&l('"+"')))))))))),null!==n)for(e=[];null!==n;)e.push(n),null===(n=T())&&null===(n=E())&&(36===t.charCodeAt(i)?(n="$",i++):(n=null,0===s&&l('"$"')),null===n&&(44===t.charCodeAt(i)?(n=",",i++):(n=null,0===s&&l('","')),null===n&&(59===t.charCodeAt(i)?(n=";",i++):(n=null,0===s&&l('";"')),null===n&&(58===t.charCodeAt(i)?(n=":",i++):(n=null,0===s&&l('":"')),null===n&&(64===t.charCodeAt(i)?(n="@",i++):(n=null,0===s&&l('"@"')),null===n&&(38===t.charCodeAt(i)?(n="&",i++):(n=null,0===s&&l('"&"')),null===n&&(61===t.charCodeAt(i)?(n="=",i++):(n=null,0===s&&l('"="')),null===n&&(43===t.charCodeAt(i)?(n="+",i++):(n=null,0===s&&l('"+"'))))))))));else e=null;return e}function Ze(){var e,t;for(e=[],t=Ge();null!==t;)e.push(t),t=Ge();return e}function et(){var e,n,r,o,u,a,c,h;if(c=i,h=i,"sip"===t.substr(i,3).toLowerCase()?(e=t.substr(i,3),i+=3):(e=null,0===s&&l('"SIP"')),null!==e)if(47===t.charCodeAt(i)?(n="/",i++):(n=null,0===s&&l('"/"')),null!==n){if(null!==(o=f()))for(r=[];null!==o;)r.push(o),o=f();else r=null;if(null!==r)if(46===t.charCodeAt(i)?(o=".",i++):(o=null,0===s&&l('"."')),null!==o){if(null!==(a=f()))for(u=[];null!==a;)u.push(a),a=f();else u=null;null!==u?e=[e,n,r,o,u]:(e=null,i=h)}else e=null,i=h;else e=null,i=h}else e=null,i=h;else e=null,i=h;return null!==e&&(e=function(e){Fn.sip_version=t.substring(i,e)}(c)),null===e&&(i=c),e}function tt(){var e;return"INVITE"===t.substr(i,6)?(e="INVITE",i+=6):(e=null,0===s&&l('"INVITE"')),e}function nt(){var e;return"ACK"===t.substr(i,3)?(e="ACK",i+=3):(e=null,0===s&&l('"ACK"')),e}function rt(){var e;return"OPTIONS"===t.substr(i,7)?(e="OPTIONS",i+=7):(e=null,0===s&&l('"OPTIONS"')),e}function ot(){var e;return"BYE"===t.substr(i,3)?(e="BYE",i+=3):(e=null,0===s&&l('"BYE"')),e}function it(){var e;return"CANCEL"===t.substr(i,6)?(e="CANCEL",i+=6):(e=null,0===s&&l('"CANCEL"')),e}function st(){var e;return"REGISTER"===t.substr(i,8)?(e="REGISTER",i+=8):(e=null,0===s&&l('"REGISTER"')),e}function ut(){var e;return"SUBSCRIBE"===t.substr(i,9)?(e="SUBSCRIBE",i+=9):(e=null,0===s&&l('"SUBSCRIBE"')),e}function at(){var e;return"NOTIFY"===t.substr(i,6)?(e="NOTIFY",i+=6):(e=null,0===s&&l('"NOTIFY"')),e}function lt(){var e;return"REFER"===t.substr(i,5)?(e="REFER",i+=5):(e=null,0===s&&l('"REFER"')),e}function ct(){var e,n;return n=i,null===(e=tt())&&null===(e=nt())&&null===(e=rt())&&null===(e=ot())&&null===(e=it())&&null===(e=st())&&null===(e=ut())&&null===(e=at())&&null===(e=lt())&&(e=N()),null!==e&&(e=function(e){return Fn.method=t.substring(i,e),Fn.method}(n)),null===e&&(i=n),e}function ft(){var e,t,n,r,o,s;return s=i,null!==(e=et())&&null!==(t=m())&&null!==(n=ht())&&null!==(r=m())&&null!==(o=pt())?e=[e,t,n,r,o]:(e=null,i=s),e}function ht(){var e,t,n;return t=i,null!==(e=dt())&&(n=e,e=void(Fn.status_code=parseInt(n.join("")))),null===e&&(i=t),e}function dt(){var e,t,n,r;return r=i,null!==(e=f())&&null!==(t=f())&&null!==(n=f())?e=[e,t,n]:(e=null,i=r),e}function pt(){var e,n,r;for(r=i,e=[],null===(n=b())&&null===(n=T())&&null===(n=E())&&null===(n=O())&&null===(n=k())&&null===(n=m())&&(n=y());null!==n;)e.push(n),null===(n=b())&&null===(n=T())&&null===(n=E())&&null===(n=O())&&null===(n=k())&&null===(n=m())&&(n=y());return null!==e&&(e=function(e){Fn.reason_phrase=t.substring(i,e)}(r)),null===e&&(i=r),e}function _t(){var e,t,n,r,o,s,u;if(o=i,s=i,null===(e=X())&&(e=vt()),null!==e){for(t=[],u=i,null!==(n=B())&&null!==(r=yt())?n=[n,r]:(n=null,i=u);null!==n;)t.push(n),u=i,null!==(n=B())&&null!==(r=yt())?n=[n,r]:(n=null,i=u);null!==t?e=[e,t]:(e=null,i=s)}else e=null,i=s;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:i,offset:e,parsed:t})}(o)),null===e&&(i=o),e}function vt(){var e,t,n,r,o;return o=i,null!==(e=null!==(e=mt())?e:"")&&null!==(t=H())&&null!==(n=Q())&&null!==(r=j())?e=[e,t,n,r]:(e=null,i=o),e}function mt(){var e,t,n,r,o,s,u,a;if(o=i,s=i,null!==(e=N())){for(t=[],u=i,null!==(n=C())&&null!==(r=N())?n=[n,r]:(n=null,i=u);null!==n;)t.push(n),u=i,null!==(n=C())&&null!==(r=N())?n=[n,r]:(n=null,i=u);null!==t?e=[e,t]:(e=null,i=s)}else e=null,i=s;return null===e&&(e=z()),null!==e&&(a=e,e=void(Fn.display_name="string"==typeof a?a:a[1].reduce((function(e,t){return e+t[0]+t[1]}),a[0]))),null===e&&(i=o),e}function yt(){var e;return null===(e=gt())&&null===(e=bt())&&(e=Et()),e}function gt(){var e,n,r,o,u,a;return o=i,u=i,"q"===t.substr(i,1).toLowerCase()?(e=t.substr(i,1),i++):(e=null,0===s&&l('"q"')),null!==e&&null!==(n=M())&&null!==(r=St())?e=[e,n,r]:(e=null,i=u),null!==e&&(a=e[2],Fn.params||(Fn.params={}),e=void(Fn.params.q=a)),null===e&&(i=o),e}function bt(){var e,n,r,o,u,a;return o=i,u=i,"expires"===t.substr(i,7).toLowerCase()?(e=t.substr(i,7),i+=7):(e=null,0===s&&l('"expires"')),null!==e&&null!==(n=M())&&null!==(r=Tt())?e=[e,n,r]:(e=null,i=u),null!==e&&(a=e[2],Fn.params||(Fn.params={}),e=void(Fn.params.expires=a)),null===e&&(i=o),e}function Tt(){var e,t,n;if(n=i,null!==(t=f()))for(e=[];null!==t;)e.push(t),t=f();else e=null;return null!==e&&(e=parseInt(e.join(""))),null===e&&(i=n),e}function St(){var e,n,r,o,u,a,c,h;return a=i,c=i,48===t.charCodeAt(i)?(e="0",i++):(e=null,0===s&&l('"0"')),null!==e?(h=i,46===t.charCodeAt(i)?(n=".",i++):(n=null,0===s&&l('"."')),null!==n&&null!==(r=null!==(r=f())?r:"")&&null!==(o=null!==(o=f())?o:"")&&null!==(u=null!==(u=f())?u:"")?n=[n,r,o,u]:(n=null,i=h),null!==(n=null!==n?n:"")?e=[e,n]:(e=null,i=c)):(e=null,i=c),null!==e&&(e=function(e){return parseFloat(t.substring(i,e))}(a)),null===e&&(i=a),e}function Et(){var e,t,n,r,o,s,u,a;return r=i,o=i,null!==(e=N())?(s=i,null!==(t=M())&&null!==(n=Ct())?t=[t,n]:(t=null,i=s),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,i=o)):(e=null,i=o),null!==e&&(u=e[0],a=e[1],Fn.params||(Fn.params={}),a=void 0===a?void 0:a[1],e=void(Fn.params[u.toLowerCase()]=a)),null===e&&(i=r),e}function Ct(){var e;return null===(e=N())&&null===(e=ue())&&(e=Y()),e}function wt(){var e;return"render"===t.substr(i,6).toLowerCase()?(e=t.substr(i,6),i+=6):(e=null,0===s&&l('"render"')),null===e&&("session"===t.substr(i,7).toLowerCase()?(e=t.substr(i,7),i+=7):(e=null,0===s&&l('"session"')),null===e&&("icon"===t.substr(i,4).toLowerCase()?(e=t.substr(i,4),i+=4):(e=null,0===s&&l('"icon"')),null===e&&("alert"===t.substr(i,5).toLowerCase()?(e=t.substr(i,5),i+=5):(e=null,0===s&&l('"alert"')),null===e&&(e=N())))),e}function At(){var e;return null===(e=Rt())&&(e=Et()),e}function Rt(){var e,n,r,o;return o=i,"handling"===t.substr(i,8).toLowerCase()?(e=t.substr(i,8),i+=8):(e=null,0===s&&l('"handling"')),null!==e&&null!==(n=M())?("optional"===t.substr(i,8).toLowerCase()?(r=t.substr(i,8),i+=8):(r=null,0===s&&l('"optional"')),null===r&&("required"===t.substr(i,8).toLowerCase()?(r=t.substr(i,8),i+=8):(r=null,0===s&&l('"required"')),null===r&&(r=N())),null!==r?e=[e,n,r]:(e=null,i=o)):(e=null,i=o),e}function It(){var e,t,n,r,o,s,u,a;if(u=i,null!==(e=Ot()))if(null!==(t=U()))if(null!==(n=Dt())){for(r=[],a=i,null!==(o=B())&&null!==(s=Ut())?o=[o,s]:(o=null,i=a);null!==o;)r.push(o),a=i,null!==(o=B())&&null!==(s=Ut())?o=[o,s]:(o=null,i=a);null!==r?e=[e,t,n,r]:(e=null,i=u)}else e=null,i=u;else e=null,i=u;else e=null,i=u;return e}function Ot(){var e;return null===(e=kt())&&(e=Nt()),e}function kt(){var e;return"text"===t.substr(i,4).toLowerCase()?(e=t.substr(i,4),i+=4):(e=null,0===s&&l('"text"')),null===e&&("image"===t.substr(i,5).toLowerCase()?(e=t.substr(i,5),i+=5):(e=null,0===s&&l('"image"')),null===e&&("audio"===t.substr(i,5).toLowerCase()?(e=t.substr(i,5),i+=5):(e=null,0===s&&l('"audio"')),null===e&&("video"===t.substr(i,5).toLowerCase()?(e=t.substr(i,5),i+=5):(e=null,0===s&&l('"video"')),null===e&&("application"===t.substr(i,11).toLowerCase()?(e=t.substr(i,11),i+=11):(e=null,0===s&&l('"application"')),null===e&&(e=xt()))))),e}function Nt(){var e;return"message"===t.substr(i,7).toLowerCase()?(e=t.substr(i,7),i+=7):(e=null,0===s&&l('"message"')),null===e&&("multipart"===t.substr(i,9).toLowerCase()?(e=t.substr(i,9),i+=9):(e=null,0===s&&l('"multipart"')),null===e&&(e=xt())),e}function xt(){var e;return null===(e=N())&&(e=Pt()),e}function Pt(){var e,n,r;return r=i,"x-"===t.substr(i,2).toLowerCase()?(e=t.substr(i,2),i+=2):(e=null,0===s&&l('"x-"')),null!==e&&null!==(n=N())?e=[e,n]:(e=null,i=r),e}function Dt(){var e;return null===(e=xt())&&(e=N()),e}function Ut(){var e,t,n,r;return r=i,null!==(e=N())&&null!==(t=M())&&null!==(n=Mt())?e=[e,t,n]:(e=null,i=r),e}function Mt(){var e;return null===(e=N())&&(e=Y()),e}function Lt(){var e,t,n,r;if(n=i,null!==(t=f()))for(e=[];null!==t;)e.push(t),t=f();else e=null;return null!==e&&(r=e,e=void(Fn.value=parseInt(r.join("")))),null===e&&(i=n),e}function qt(){var e,n,r,o,u,a;if(u=i,null!==(e=x())){for(n=[],a=i,46===t.charCodeAt(i)?(r=".",i++):(r=null,0===s&&l('"."')),null!==r&&null!==(o=x())?r=[r,o]:(r=null,i=a);null!==r;)n.push(r),a=i,46===t.charCodeAt(i)?(r=".",i++):(r=null,0===s&&l('"."')),null!==r&&null!==(o=x())?r=[r,o]:(r=null,i=a);null!==n?e=[e,n]:(e=null,i=u)}else e=null,i=u;return e}function jt(){var e;return null===(e=Ht())&&(e=Et()),e}function Ht(){var e,n,r,o,u,a;return o=i,u=i,"tag"===t.substr(i,3).toLowerCase()?(e=t.substr(i,3),i+=3):(e=null,0===s&&l('"tag"')),null!==e&&null!==(n=M())&&null!==(r=N())?e=[e,n,r]:(e=null,i=u),null!==e&&(a=e[2],e=void(Fn.tag=a)),null===e&&(i=o),e}function Ft(){var e,n,r,o,u,a,c,f;if(c=i,"digest"===t.substr(i,6).toLowerCase()?(e=t.substr(i,6),i+=6):(e=null,0===s&&l('"Digest"')),null!==e)if(null!==(n=C()))if(null!==(r=Wt())){for(o=[],f=i,null!==(u=F())&&null!==(a=Wt())?u=[u,a]:(u=null,i=f);null!==u;)o.push(u),f=i,null!==(u=F())&&null!==(a=Wt())?u=[u,a]:(u=null,i=f);null!==o?e=[e,n,r,o]:(e=null,i=c)}else e=null,i=c;else e=null,i=c;else e=null,i=c;return null===e&&(e=Bt()),e}function Bt(){var e,t,n,r,o,s,u,a;if(u=i,null!==(e=N()))if(null!==(t=C()))if(null!==(n=Gt())){for(r=[],a=i,null!==(o=F())&&null!==(s=Gt())?o=[o,s]:(o=null,i=a);null!==o;)r.push(o),a=i,null!==(o=F())&&null!==(s=Gt())?o=[o,s]:(o=null,i=a);null!==r?e=[e,t,n,r]:(e=null,i=u)}else e=null,i=u;else e=null,i=u;else e=null,i=u;return e}function Gt(){var e,t,n,r;return r=i,null!==(e=N())&&null!==(t=M())?(null===(n=N())&&(n=Y()),null!==n?e=[e,t,n]:(e=null,i=r)):(e=null,i=r),e}function Wt(){var e;return null===(e=Vt())&&null===(e=Yt())&&null===(e=$t())&&null===(e=Xt())&&null===(e=Qt())&&null===(e=Zt())&&null===(e=en())&&(e=Gt()),e}function Vt(){var e,n,r,o;return o=i,"realm"===t.substr(i,5).toLowerCase()?(e=t.substr(i,5),i+=5):(e=null,0===s&&l('"realm"')),null!==e&&null!==(n=M())&&null!==(r=Kt())?e=[e,n,r]:(e=null,i=o),e}function Kt(){var e,t,n;return t=i,null!==(e=z())&&(n=e,e=void(Fn.realm=n)),null===e&&(i=t),e}function Yt(){var e,n,r,o,u,a,c,f,h;if(f=i,"domain"===t.substr(i,6).toLowerCase()?(e=t.substr(i,6),i+=6):(e=null,0===s&&l('"domain"')),null!==e)if(null!==(n=M()))if(null!==(r=W()))if(null!==(o=zt())){if(u=[],h=i,null!==(c=m()))for(a=[];null!==c;)a.push(c),c=m();else a=null;for(null!==a&&null!==(c=zt())?a=[a,c]:(a=null,i=h);null!==a;){if(u.push(a),h=i,null!==(c=m()))for(a=[];null!==c;)a.push(c),c=m();else a=null;null!==a&&null!==(c=zt())?a=[a,c]:(a=null,i=h)}null!==u&&null!==(a=V())?e=[e,n,r,o,u,a]:(e=null,i=f)}else e=null,i=f;else e=null,i=f;else e=null,i=f;else e=null,i=f;return e}function zt(){var e;return null===(e=qe())&&(e=Fe()),e}function $t(){var e,n,r,o;return o=i,"nonce"===t.substr(i,5).toLowerCase()?(e=t.substr(i,5),i+=5):(e=null,0===s&&l('"nonce"')),null!==e&&null!==(n=M())&&null!==(r=Jt())?e=[e,n,r]:(e=null,i=o),e}function Jt(){var e,t,n;return t=i,null!==(e=z())&&(n=e,e=void(Fn.nonce=n)),null===e&&(i=t),e}function Xt(){var e,n,r,o,u,a;return o=i,u=i,"opaque"===t.substr(i,6).toLowerCase()?(e=t.substr(i,6),i+=6):(e=null,0===s&&l('"opaque"')),null!==e&&null!==(n=M())&&null!==(r=z())?e=[e,n,r]:(e=null,i=u),null!==e&&(a=e[2],e=void(Fn.opaque=a)),null===e&&(i=o),e}function Qt(){var e,n,r,o,u;return o=i,"stale"===t.substr(i,5).toLowerCase()?(e=t.substr(i,5),i+=5):(e=null,0===s&&l('"stale"')),null!==e&&null!==(n=M())?(u=i,"true"===t.substr(i,4).toLowerCase()?(r=t.substr(i,4),i+=4):(r=null,0===s&&l('"true"')),null!==r&&(r=void(Fn.stale=!0)),null===r&&(i=u),null===r&&(u=i,"false"===t.substr(i,5).toLowerCase()?(r=t.substr(i,5),i+=5):(r=null,0===s&&l('"false"')),null!==r&&(r=void(Fn.stale=!1)),null===r&&(i=u)),null!==r?e=[e,n,r]:(e=null,i=o)):(e=null,i=o),e}function Zt(){var e,n,r,o,u,a;return o=i,u=i,"algorithm"===t.substr(i,9).toLowerCase()?(e=t.substr(i,9),i+=9):(e=null,0===s&&l('"algorithm"')),null!==e&&null!==(n=M())?("md5"===t.substr(i,3).toLowerCase()?(r=t.substr(i,3),i+=3):(r=null,0===s&&l('"MD5"')),null===r&&("md5-sess"===t.substr(i,8).toLowerCase()?(r=t.substr(i,8),i+=8):(r=null,0===s&&l('"MD5-sess"')),null===r&&(r=N())),null!==r?e=[e,n,r]:(e=null,i=u)):(e=null,i=u),null!==e&&(a=e[2],e=void(Fn.algorithm=a.toUpperCase())),null===e&&(i=o),e}function en(){var e,n,r,o,u,a,c,f,h,d;if(f=i,"qop"===t.substr(i,3).toLowerCase()?(e=t.substr(i,3),i+=3):(e=null,0===s&&l('"qop"')),null!==e)if(null!==(n=M()))if(null!==(r=W())){if(h=i,null!==(o=tn())){for(u=[],d=i,44===t.charCodeAt(i)?(a=",",i++):(a=null,0===s&&l('","')),null!==a&&null!==(c=tn())?a=[a,c]:(a=null,i=d);null!==a;)u.push(a),d=i,44===t.charCodeAt(i)?(a=",",i++):(a=null,0===s&&l('","')),null!==a&&null!==(c=tn())?a=[a,c]:(a=null,i=d);null!==u?o=[o,u]:(o=null,i=h)}else o=null,i=h;null!==o&&null!==(u=V())?e=[e,n,r,o,u]:(e=null,i=f)}else e=null,i=f;else e=null,i=f;else e=null,i=f;return e}function tn(){var e,n,r;return n=i,"auth-int"===t.substr(i,8).toLowerCase()?(e=t.substr(i,8),i+=8):(e=null,0===s&&l('"auth-int"')),null===e&&("auth"===t.substr(i,4).toLowerCase()?(e=t.substr(i,4),i+=4):(e=null,0===s&&l('"auth"')),null===e&&(e=N())),null!==e&&(r=e,Fn.qop||(Fn.qop=[]),e=void Fn.qop.push(r.toLowerCase())),null===e&&(i=n),e}function nn(){var e,t,n,r,o,s,u;if(o=i,s=i,null!==(e=vt())){for(t=[],u=i,null!==(n=B())&&null!==(r=Et())?n=[n,r]:(n=null,i=u);null!==n;)t.push(n),u=i,null!==(n=B())&&null!==(r=Et())?n=[n,r]:(n=null,i=u);null!==t?e=[e,t]:(e=null,i=s)}else e=null,i=s;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:i,offset:e,parsed:t})}(o)),null===e&&(i=o),e}function rn(){var e;return null===(e=on())&&(e=Et()),e}function on(){var e,n,r,o,u,a,c;if(u=i,a=i,"cause"===t.substr(i,5).toLowerCase()?(e=t.substr(i,5),i+=5):(e=null,0===s&&l('"cause"')),null!==e)if(null!==(n=M())){if(null!==(o=f()))for(r=[];null!==o;)r.push(o),o=f();else r=null;null!==r?e=[e,n,r]:(e=null,i=a)}else e=null,i=a;else e=null,i=a;return null!==e&&(c=e[2],e=void(Fn.cause=parseInt(c.join("")))),null===e&&(i=u),e}function sn(){var e,t,n,r,o,s;if(o=i,null!==(e=vt())){for(t=[],s=i,null!==(n=B())&&null!==(r=Et())?n=[n,r]:(n=null,i=s);null!==n;)t.push(n),s=i,null!==(n=B())&&null!==(r=Et())?n=[n,r]:(n=null,i=s);null!==t?e=[e,t]:(e=null,i=o)}else e=null,i=o;return e}function un(){var e,n;return n=i,"active"===t.substr(i,6).toLowerCase()?(e=t.substr(i,6),i+=6):(e=null,0===s&&l('"active"')),null===e&&("pending"===t.substr(i,7).toLowerCase()?(e=t.substr(i,7),i+=7):(e=null,0===s&&l('"pending"')),null===e&&("terminated"===t.substr(i,10).toLowerCase()?(e=t.substr(i,10),i+=10):(e=null,0===s&&l('"terminated"')),null===e&&(e=N()))),null!==e&&(e=function(e){Fn.state=t.substring(i,e)}(n)),null===e&&(i=n),e}function an(){var e,n,r,o,u,a,c,f;return o=i,u=i,"reason"===t.substr(i,6).toLowerCase()?(e=t.substr(i,6),i+=6):(e=null,0===s&&l('"reason"')),null!==e&&null!==(n=M())&&null!==(r=ln())?e=[e,n,r]:(e=null,i=u),null!==e&&(e=void(void 0!==(a=e[2])&&(Fn.reason=a))),null===e&&(i=o),null===e&&(o=i,u=i,"expires"===t.substr(i,7).toLowerCase()?(e=t.substr(i,7),i+=7):(e=null,0===s&&l('"expires"')),null!==e&&null!==(n=M())&&null!==(r=Tt())?e=[e,n,r]:(e=null,i=u),null!==e&&(e=void(void 0!==(f=e[2])&&(Fn.expires=f))),null===e&&(i=o),null===e&&(o=i,u=i,"retry_after"===t.substr(i,11).toLowerCase()?(e=t.substr(i,11),i+=11):(e=null,0===s&&l('"retry_after"')),null!==e&&null!==(n=M())&&null!==(r=Tt())?e=[e,n,r]:(e=null,i=u),null!==e&&(e=void(void 0!==(c=e[2])&&(Fn.retry_after=c))),null===e&&(i=o),null===e&&(e=Et()))),e}function ln(){var e;return"deactivated"===t.substr(i,11).toLowerCase()?(e=t.substr(i,11),i+=11):(e=null,0===s&&l('"deactivated"')),null===e&&("probation"===t.substr(i,9).toLowerCase()?(e=t.substr(i,9),i+=9):(e=null,0===s&&l('"probation"')),null===e&&("rejected"===t.substr(i,8).toLowerCase()?(e=t.substr(i,8),i+=8):(e=null,0===s&&l('"rejected"')),null===e&&("timeout"===t.substr(i,7).toLowerCase()?(e=t.substr(i,7),i+=7):(e=null,0===s&&l('"timeout"')),null===e&&("giveup"===t.substr(i,6).toLowerCase()?(e=t.substr(i,6),i+=6):(e=null,0===s&&l('"giveup"')),null===e&&("noresource"===t.substr(i,10).toLowerCase()?(e=t.substr(i,10),i+=10):(e=null,0===s&&l('"noresource"')),null===e&&("invariant"===t.substr(i,9).toLowerCase()?(e=t.substr(i,9),i+=9):(e=null,0===s&&l('"invariant"')),null===e&&(e=N()))))))),e}function cn(){var e;return null===(e=Ht())&&(e=Et()),e}function fn(){var e,t,n,r,o,s,u,a;if(u=i,null!==(e=gn()))if(null!==(t=C()))if(null!==(n=Sn())){for(r=[],a=i,null!==(o=B())&&null!==(s=hn())?o=[o,s]:(o=null,i=a);null!==o;)r.push(o),a=i,null!==(o=B())&&null!==(s=hn())?o=[o,s]:(o=null,i=a);null!==r?e=[e,t,n,r]:(e=null,i=u)}else e=null,i=u;else e=null,i=u;else e=null,i=u;return e}function hn(){var e;return null===(e=dn())&&null===(e=pn())&&null===(e=_n())&&null===(e=vn())&&null===(e=mn())&&(e=Et()),e}function dn(){var e,n,r,o,u,a;return o=i,u=i,"ttl"===t.substr(i,3).toLowerCase()?(e=t.substr(i,3),i+=3):(e=null,0===s&&l('"ttl"')),null!==e&&null!==(n=M())&&null!==(r=wn())?e=[e,n,r]:(e=null,i=u),null!==e&&(a=e[2],e=void(Fn.ttl=a)),null===e&&(i=o),e}function pn(){var e,n,r,o,u,a;return o=i,u=i,"maddr"===t.substr(i,5).toLowerCase()?(e=t.substr(i,5),i+=5):(e=null,0===s&&l('"maddr"')),null!==e&&null!==(n=M())&&null!==(r=ue())?e=[e,n,r]:(e=null,i=u),null!==e&&(a=e[2],e=void(Fn.maddr=a)),null===e&&(i=o),e}function _n(){var e,n,r,o,u,a;return o=i,u=i,"received"===t.substr(i,8).toLowerCase()?(e=t.substr(i,8),i+=8):(e=null,0===s&&l('"received"')),null!==e&&null!==(n=M())?(null===(r=_e())&&(r=he()),null!==r?e=[e,n,r]:(e=null,i=u)):(e=null,i=u),null!==e&&(a=e[2],e=void(Fn.received=a)),null===e&&(i=o),e}function vn(){var e,n,r,o,u,a;return o=i,u=i,"branch"===t.substr(i,6).toLowerCase()?(e=t.substr(i,6),i+=6):(e=null,0===s&&l('"branch"')),null!==e&&null!==(n=M())&&null!==(r=N())?e=[e,n,r]:(e=null,i=u),null!==e&&(a=e[2],e=void(Fn.branch=a)),null===e&&(i=o),e}function mn(){var e,n,r,o,u;return o=i,"rport"===t.substr(i,5).toLowerCase()?(e=t.substr(i,5),i+=5):(e=null,0===s&&l('"rport"')),null!==e?(u=i,null!==(n=M())&&null!==(r=yn())?n=[n,r]:(n=null,i=u),null!==(n=null!==n?n:"")?e=[e,n]:(e=null,i=o)):(e=null,i=o),e}function yn(){var e,t,n,r,o,s,u,a;return s=i,u=i,null!==(e=null!==(e=f())?e:"")&&null!==(t=null!==(t=f())?t:"")&&null!==(n=null!==(n=f())?n:"")&&null!==(r=null!==(r=f())?r:"")&&null!==(o=null!==(o=f())?o:"")?e=[e,t,n,r,o]:(e=null,i=u),null!==e&&(a=e,e=void(Fn.rport=parseInt(a.join("")))),null===e&&(i=s),e}function gn(){var e,t,n,r,o,s;return s=i,null!==(e=bn())&&null!==(t=U())&&null!==(n=N())&&null!==(r=U())&&null!==(o=Tn())?e=[e,t,n,r,o]:(e=null,i=s),e}function bn(){var e,n,r;return n=i,"sip"===t.substr(i,3).toLowerCase()?(e=t.substr(i,3),i+=3):(e=null,0===s&&l('"SIP"')),null===e&&(e=N()),null!==e&&(r=e,e=void(Fn.protocol=r)),null===e&&(i=n),e}function Tn(){var e,n,r;return n=i,"udp"===t.substr(i,3).toLowerCase()?(e=t.substr(i,3),i+=3):(e=null,0===s&&l('"UDP"')),null===e&&("tcp"===t.substr(i,3).toLowerCase()?(e=t.substr(i,3),i+=3):(e=null,0===s&&l('"TCP"')),null===e&&("tls"===t.substr(i,3).toLowerCase()?(e=t.substr(i,3),i+=3):(e=null,0===s&&l('"TLS"')),null===e&&("sctp"===t.substr(i,4).toLowerCase()?(e=t.substr(i,4),i+=4):(e=null,0===s&&l('"SCTP"')),null===e&&(e=N())))),null!==e&&(r=e,e=void(Fn.transport=r)),null===e&&(i=n),e}function Sn(){var e,t,n,r,o;return r=i,null!==(e=En())?(o=i,null!==(t=G())&&null!==(n=Cn())?t=[t,n]:(t=null,i=o),null!==(t=null!==t?t:"")?e=[e,t]:(e=null,i=r)):(e=null,i=r),e}function En(){var e,n;return n=i,null===(e=_e())&&null===(e=fe())&&(e=ae()),null!==e&&(e=function(e){Fn.host=t.substring(i,e)}(n)),null===e&&(i=n),e}function Cn(){var e,t,n,r,o,s,u,a;return s=i,u=i,null!==(e=null!==(e=f())?e:"")&&null!==(t=null!==(t=f())?t:"")&&null!==(n=null!==(n=f())?n:"")&&null!==(r=null!==(r=f())?r:"")&&null!==(o=null!==(o=f())?o:"")?e=[e,t,n,r,o]:(e=null,i=u),null!==e&&(a=e,e=void(Fn.port=parseInt(a.join("")))),null===e&&(i=s),e}function wn(){var e,t,n,r,o;return r=i,o=i,null!==(e=f())&&null!==(t=null!==(t=f())?t:"")&&null!==(n=null!==(n=f())?n:"")?e=[e,t,n]:(e=null,i=o),null!==e&&(e=parseInt(e.join(""))),null===e&&(i=r),e}function An(){var e,t,n;return t=i,null!==(e=Tt())&&(n=e,e=void(Fn.expires=n)),null===e&&(i=t),e}function Rn(){var e;return null===(e=In())&&(e=Et()),e}function In(){var e,n,r,o,u,a;return o=i,u=i,"refresher"===t.substr(i,9).toLowerCase()?(e=t.substr(i,9),i+=9):(e=null,0===s&&l('"refresher"')),null!==e&&null!==(n=M())?("uac"===t.substr(i,3).toLowerCase()?(r=t.substr(i,3),i+=3):(r=null,0===s&&l('"uac"')),null===r&&("uas"===t.substr(i,3).toLowerCase()?(r=t.substr(i,3),i+=3):(r=null,0===s&&l('"uas"'))),null!==r?e=[e,n,r]:(e=null,i=u)):(e=null,i=u),null!==e&&(a=e[2],e=void(Fn.refresher=a.toLowerCase())),null===e&&(i=o),e}function On(){var e,t;for(e=[],null===(t=I())&&null===(t=k())&&(t=C());null!==t;)e.push(t),null===(t=I())&&null===(t=k())&&(t=C());return e}function kn(){var e,n,r,o,u,a,c,f,h,d,p;return d=i,p=i,null!==(e=xn())?(45===t.charCodeAt(i)?(n="-",i++):(n=null,0===s&&l('"-"')),null!==n&&null!==(r=Nn())?(45===t.charCodeAt(i)?(o="-",i++):(o=null,0===s&&l('"-"')),null!==o&&null!==(u=Nn())?(45===t.charCodeAt(i)?(a="-",i++):(a=null,0===s&&l('"-"')),null!==a&&null!==(c=Nn())?(45===t.charCodeAt(i)?(f="-",i++):(f=null,0===s&&l('"-"')),null!==f&&null!==(h=Pn())?e=[e,n,r,o,u,a,c,f,h]:(e=null,i=p)):(e=null,i=p)):(e=null,i=p)):(e=null,i=p)):(e=null,i=p),null!==e&&(e=function(e){Fn=t.substring(i+5,e)}(d,e[0])),null===e&&(i=d),e}function Nn(){var e,t,n,r,o;return o=i,null!==(e=d())&&null!==(t=d())&&null!==(n=d())&&null!==(r=d())?e=[e,t,n,r]:(e=null,i=o),e}function xn(){var e,t,n;return n=i,null!==(e=Nn())&&null!==(t=Nn())?e=[e,t]:(e=null,i=n),e}function Pn(){var e,t,n,r;return r=i,null!==(e=Nn())&&null!==(t=Nn())&&null!==(n=Nn())?e=[e,t,n]:(e=null,i=r),e}function Dn(){var e,n,r,o,u,a;return o=i,u=i,null!==(e=P())?(a=i,64===t.charCodeAt(i)?(n="@",i++):(n=null,0===s&&l('"@"')),null!==n&&null!==(r=P())?n=[n,r]:(n=null,i=a),null!==(n=null!==n?n:"")?e=[e,n]:(e=null,i=u)):(e=null,i=u),null!==e&&(e=function(e){Fn.call_id=t.substring(i,e)}(o)),null===e&&(i=o),e}function Un(){var e;return null===(e=Mn())&&null===(e=Ln())&&null===(e=qn())&&(e=Et()),e}function Mn(){var e,n,r,o,u,a;return o=i,u=i,"to-tag"===t.substr(i,6)?(e="to-tag",i+=6):(e=null,0===s&&l('"to-tag"')),null!==e&&null!==(n=M())&&null!==(r=N())?e=[e,n,r]:(e=null,i=u),null!==e&&(a=e[2],e=void(Fn.to_tag=a)),null===e&&(i=o),e}function Ln(){var e,n,r,o,u,a;return o=i,u=i,"from-tag"===t.substr(i,8)?(e="from-tag",i+=8):(e=null,0===s&&l('"from-tag"')),null!==e&&null!==(n=M())&&null!==(r=N())?e=[e,n,r]:(e=null,i=u),null!==e&&(a=e[2],e=void(Fn.from_tag=a)),null===e&&(i=o),e}function qn(){var e,n;return n=i,"early-only"===t.substr(i,10)?(e="early-only",i+=10):(e=null,0===s&&l('"early-only"')),null!==e&&(e=void(Fn.early_only=!0)),null===e&&(i=n),e}var jn=n(670),Hn=n(47),Fn={};if(null===o[r]()||i!==t.length){var Bn=Math.max(i,u),Gn=Bn<t.length?t.charAt(Bn):null,Wn=function(){for(var e=1,n=1,r=!1,o=0;o<Math.max(i,u);o++){var s=t.charAt(o);"\n"===s?(r||e++,n=1,r=!1):"\r"===s||"\u2028"===s||"\u2029"===s?(e++,n=1,r=!0):(n++,r=!1)}return{line:e,column:n}}();return new this.SyntaxError(function(e){e.sort();for(var t=null,n=[],r=0;r<e.length;r++)e[r]!==t&&(n.push(e[r]),t=e[r]);return n}(a),Gn,Bn,Wn.line,Wn.column),-1}return Fn},toSource:function(){return this._source},SyntaxError:function(t,n,r,o,i){this.name="SyntaxError",this.expected=t,this.found=n,this.message=function(t,n){var r;switch(t.length){case 0:r="end of input";break;case 1:r=t[0];break;default:r=t.slice(0,t.length-1).join(", ")+" or "+t[t.length-1]}return"Expected "+r+" but "+(n?e(n):"end of input")+" found."}(t,n),this.offset=r,this.line=o,this.column=i}};return t.SyntaxError.prototype=Error.prototype,t}()},53:(e,t,n)=>{"use strict";var r=n(633),o=n(349),i=n(956),s=n(137),u=n(544),a=n(670),l=n(47),c=n(561),f=n(32);n(720)("JsSIP")("version %s",r.version),e.exports={C:o,Exceptions:i,Utils:s,UA:u,URI:a,NameAddrHeader:l,WebSocketInterface:f,Grammar:c,debug:n(720),get name(){return r.title},get version(){return r.version}}},510:(e,t,n)=>{"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var o=n(720),i="JsSIP";e.exports=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),t?(this._debug=o.default("".concat(i,":").concat(t)),this._warn=o.default("".concat(i,":WARN:").concat(t)),this._error=o.default("".concat(i,":ERROR:").concat(t))):(this._debug=o.default(i),this._warn=o.default("".concat(i,":WARN")),this._error=o.default("".concat(i,":ERROR"))),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}var t,n,s;return t=e,(n=[{key:"debug",get:function(){return this._debug}},{key:"warn",get:function(){return this._warn}},{key:"error",get:function(){return this._error}}])&&r(t.prototype,n),s&&r(t,s),e}()},603:(e,t,n)=>{"use strict";function r(e){return 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},r(e)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t){return i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},i(e,t)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=u(e);if(t){var i=u(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return function(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,n)}}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}var a=n(7).EventEmitter,l=n(510),c=n(349),f=n(213),h=n(137),d=n(396),p=n(956),_=n(670),v=new l("Message");e.exports=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(a,e);var t,n,r,u=s(a);function a(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(t=u.call(this))._ua=e,t._request=null,t._closed=!1,t._direction=null,t._local_identity=null,t._remote_identity=null,t._is_replied=!1,t._data={},t}return t=a,n=[{key:"send",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=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: ".concat(o));var i=h.cloneArray(r.extraHeaders),s=h.cloneObject(r.eventHandlers),u=r.contentType||"text/plain",a={};for(var l in r.fromUserName&&(a.from_uri=new _("sip",r.fromUserName,this._ua.configuration.uri.host),i.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString()))),r.fromDisplayName&&(a.from_display_name=r.fromDisplayName),s)Object.prototype.hasOwnProperty.call(s,l)&&this.on(l,s[l]);i.push("Content-Type: ".concat(u)),this._request=new f.OutgoingRequest(c.MESSAGE,e,this._ua,a,i),t&&(this._request.body=t);var p=new d(this._ua,this._request,{onRequestTimeout:function(){n._onRequestTimeout()},onTransportError:function(){n._onTransportError()},onReceiveResponse:function(e){n._receiveResponse(e)}});this._newMessage("local",this._request),p.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=h.cloneArray(e.extraHeaders),n=e.body;if("incoming"!==this._direction)throw new p.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=h.cloneArray(e.extraHeaders),o=e.body;if("incoming"!==this._direction)throw new p.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: ".concat(t));this._is_replied=!0,this._request.reply(t,n,r,o)}},{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=h.sipErrorCause(e.status_code);this._failed("remote",e,t)}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,c.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,c.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){v.debug("MESSAGE failed"),this._close(),v.debug('emit "failed"'),this.emit("failed",{originator:e,response:t||null,cause:n})}},{key:"_succeeded",value:function(e,t){v.debug("MESSAGE succeeded"),this._close(),v.debug('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}}],n&&o(t.prototype,n),r&&o(t,r),a}(a)},47:(e,t,n)=>{"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}var i=n(670),s=n(561);e.exports=function(){function e(t,n,r){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!(t&&t instanceof i))throw new TypeError('missing or invalid "uri" parameter');for(var o in this._uri=t,this._parameters={},this.display_name=n,r)Object.prototype.hasOwnProperty.call(r,o)&&this.setParam(o,r[o])}return o(e,null,[{key:"parse",value:function(e){return-1!==(e=s.parse(e,"Name_Addr_Header"))?e:void 0}}]),o(e,[{key:"setParam",value:function(e,t){e&&(this._parameters[e.toLowerCase()]=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:"clone",value:function(){return new e(this._uri.clone(),this._display_name,JSON.parse(JSON.stringify(this._parameters)))}},{key:"_quote",value:function(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}},{key:"toString",value:function(){var e=this._display_name?'"'.concat(this._quote(this._display_name),'" '):"";for(var t in e+="<".concat(this._uri.toString(),">"),this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,t)&&(e+=";".concat(t),null!==this._parameters[t]&&(e+="=".concat(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}()},6:(e,t,n)=>{"use strict";function r(e){return 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},r(e)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t){return i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},i(e,t)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=u(e);if(t){var i=u(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return function(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,n)}}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}var a=n(7).EventEmitter,l=n(510),c=n(349),f=n(213),h=n(137),d=n(396),p=n(956),_=new l("Options");e.exports=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(a,e);var t,n,r,u=s(a);function a(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(t=u.call(this))._ua=e,t._request=null,t._closed=!1,t._direction=null,t._local_identity=null,t._remote_identity=null,t._is_replied=!1,t._data={},t}return t=a,n=[{key:"send",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=e;if(void 0===e)throw new TypeError("A target is required for OPTIONS");if(!(e=this._ua.normalizeTarget(e)))throw new TypeError("Invalid target: ".concat(o));var i=h.cloneArray(r.extraHeaders),s=h.cloneObject(r.eventHandlers),u=r.contentType||"application/sdp";for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&this.on(a,s[a]);i.push("Content-Type: ".concat(u)),this._request=new f.OutgoingRequest(c.OPTIONS,e,this._ua,null,i),t&&(this._request.body=t);var l=new d(this._ua,this._request,{onRequestTimeout:function(){n._onRequestTimeout()},onTransportError:function(){n._onTransportError()},onReceiveResponse:function(e){n._receiveResponse(e)}});this._newOptions("local",this._request),l.send()}},{key:"init_incoming",value:function(e){this._request=e,this._newOptions("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=h.cloneArray(e.extraHeaders),n=e.body;if("incoming"!==this._direction)throw new p.NotSupportedError('"accept" not supported for outgoing Options');if(this._is_replied)throw new Error("incoming Options 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=h.cloneArray(e.extraHeaders),o=e.body;if("incoming"!==this._direction)throw new p.NotSupportedError('"reject" not supported for outgoing Options');if(this._is_replied)throw new Error("incoming Options already replied");if(t<300||t>=700)throw new TypeError("Invalid status_code: ".concat(t));this._is_replied=!0,this._request.reply(t,n,r,o)}},{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=h.sipErrorCause(e.status_code);this._failed("remote",e,t)}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,c.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,c.causes.CONNECTION_ERROR)}},{key:"_close",value:function(){this._closed=!0,this._ua.destroyMessage(this)}},{key:"_newOptions",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.newOptions(this,{originator:e,message:this,request:t})}},{key:"_failed",value:function(e,t,n){_.debug("OPTIONS failed"),this._close(),_.debug('emit "failed"'),this.emit("failed",{originator:e,response:t||null,cause:n})}},{key:"_succeeded",value:function(e,t){_.debug("OPTIONS succeeded"),this._close(),_.debug('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}}],n&&o(t.prototype,n),r&&o(t,r),a}(a)},725:(e,t,n)=>{"use strict";function r(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,u=!0,a=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return u=e.done,e},e:function(e){a=!0,s=e},f:function(){try{u||null==n.return||n.return()}finally{if(a)throw s}}}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var i=n(510),s=n(561),u=n(213),a=new i("Parser");function l(e,t){var n=t,r=0,o=0;if(e.substring(n,n+2).match(/(^\r\n)/))return-2;for(;0===r;){if(-1===(o=e.indexOf("\r\n",n)))return o;!e.substring(o+2,o+4).match(/(^\r\n)/)&&e.charAt(o+2).match(/(^\s+)/)?n=o+2:r=o}return r}function c(e,t,n,o){var i,a=t.indexOf(":",n),l=t.substring(n,a).trim(),c=t.substring(a+1,o).trim();switch(l.toLowerCase()){case"via":case"v":e.addHeader("via",c),1===e.getHeaders("via").length?(i=e.parseHeader("Via"))&&(e.via=i,e.via_branch=i.branch):i=0;break;case"from":case"f":e.setHeader("from",c),(i=e.parseHeader("from"))&&(e.from=i,e.from_tag=i.getParam("tag"));break;case"to":case"t":e.setHeader("to",c),(i=e.parseHeader("to"))&&(e.to=i,e.to_tag=i.getParam("tag"));break;case"record-route":if(-1===(i=s.parse(c,"Record_Route")))i=void 0;else{var f,h=r(i);try{for(h.s();!(f=h.n()).done;){var d=f.value;e.addHeader("record-route",c.substring(d.possition,d.offset)),e.headers["Record-Route"][e.getHeaders("record-route").length-1].parsed=d.parsed}}catch(e){h.e(e)}finally{h.f()}}break;case"call-id":case"i":e.setHeader("call-id",c),(i=e.parseHeader("call-id"))&&(e.call_id=c);break;case"contact":case"m":if(-1===(i=s.parse(c,"Contact")))i=void 0;else{var p,_=r(i);try{for(_.s();!(p=_.n()).done;){var v=p.value;e.addHeader("contact",c.substring(v.possition,v.offset)),e.headers.Contact[e.getHeaders("contact").length-1].parsed=v.parsed}}catch(e){_.e(e)}finally{_.f()}}break;case"content-length":case"l":e.setHeader("content-length",c),i=e.parseHeader("content-length");break;case"content-type":case"c":e.setHeader("content-type",c),i=e.parseHeader("content-type");break;case"cseq":e.setHeader("cseq",c),(i=e.parseHeader("cseq"))&&(e.cseq=i.value),e instanceof u.IncomingResponse&&(e.method=i.method);break;case"max-forwards":e.setHeader("max-forwards",c),i=e.parseHeader("max-forwards");break;case"www-authenticate":e.setHeader("www-authenticate",c),i=e.parseHeader("www-authenticate");break;case"proxy-authenticate":e.setHeader("proxy-authenticate",c),i=e.parseHeader("proxy-authenticate");break;case"session-expires":case"x":e.setHeader("session-expires",c),(i=e.parseHeader("session-expires"))&&(e.session_expires=i.expires,e.session_expires_refresher=i.refresher);break;case"refer-to":case"r":e.setHeader("refer-to",c),(i=e.parseHeader("refer-to"))&&(e.refer_to=i);break;case"replaces":e.setHeader("replaces",c),(i=e.parseHeader("replaces"))&&(e.replaces=i);break;case"event":case"o":e.setHeader("event",c),(i=e.parseHeader("event"))&&(e.event=i);break;default:e.addHeader(l,c),i=0}return void 0!==i||{error:'error parsing header "'.concat(l,'"')}}t.parseMessage=function(e,t){var n,r,o=e.indexOf("\r\n");if(-1!==o){var i=e.substring(0,o),f=s.parse(i,"Request_Response");if(-1!==f){f.status_code?((n=new u.IncomingResponse).status_code=f.status_code,n.reason_phrase=f.reason_phrase):((n=new u.IncomingRequest(t)).method=f.method,n.ruri=f.uri),n.data=e;for(var h=o+2;;){if(-2===(o=l(e,h))){r=h+2;break}if(-1===o)return void a.warn("parseMessage() | malformed message");if(!0!==(f=c(n,e,h,o)))return void a.warn("parseMessage() |",f.error);h=o+2}if(n.hasHeader("content-length")){var d=n.getHeader("content-length");n.body=e.substr(r,d)}else n.body=e.substring(r);return n}a.warn('parseMessage() | error parsing first line of SIP message: "'.concat(i,'"'))}else a.warn("parseMessage() | no CRLF found, not a SIP message")}},395:(e,t,n)=>{"use strict";function r(e){return 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},r(e)}function o(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,u=!0,a=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return u=e.done,e},e:function(e){a=!0,s=e},f:function(){try{u||null==n.return||n.return()}finally{if(a)throw s}}}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function u(e,t,n){return t&&s(e.prototype,t),n&&s(e,n),e}function a(e,t){return a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},a(e,t)}function l(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=c(e);if(t){var i=c(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return function(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,n)}}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}var f=n(7).EventEmitter,h=n(363),d=n(510),p=n(349),_=n(956),v=n(143),m=n(137),y=n(672),g=n(213),b=n(978),T=n(396),S=n(697),E=n(850),C=n(276),w=n(716),A=n(670),R=new d("RTCSession"),I={STATUS_NULL:0,STATUS_INVITE_SENT:1,STATUS_1XX_RECEIVED:2,STATUS_INVITE_RECEIVED:3,STATUS_WAITING_FOR_ANSWER:4,STATUS_ANSWERED:5,STATUS_WAITING_FOR_ACK:6,STATUS_CANCELED:7,STATUS_TERMINATED:8,STATUS_CONFIRMED:9},O=["audio","video"];e.exports=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}(n,e);var t=l(n);function n(e){var r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),R.debug("new"),(r=t.call(this))._id=null,r._ua=e,r._status=I.STATUS_NULL,r._dialog=null,r._earlyDialogs={},r._contact=null,r._from_tag=null,r._to_tag=null,r._connection=null,r._connectionPromiseQueue=Promise.resolve(),r._request=null,r._is_canceled=!1,r._cancel_reason="",r._is_confirmed=!1,r._late_sdp=!1,r._rtcOfferConstraints=null,r._rtcAnswerConstraints=null,r._localMediaStream=null,r._localMediaStreamLocallyGenerated=!1,r._rtcReady=!0,r._iceReady=!1,r._timers={ackTimer:null,expiresTimer:null,invite2xxTimer:null,userNoAnswerTimer:null},r._direction=null,r._local_identity=null,r._remote_identity=null,r._start_time=null,r._end_time=null,r._tones=null,r._audioMuted=!1,r._videoMuted=!1,r._localHold=!1,r._remoteHold=!1,r._sessionTimers={enabled:r._ua.configuration.session_timers,refreshMethod:r._ua.configuration.session_timers_refresh_method,defaultExpires:p.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},r._referSubscribers={},r._data={},r}return u(n,null,[{key:"C",get:function(){return I}}]),u(n,[{key:"isInProgress",value:function(){switch(this._status){case I.STATUS_NULL:case I.STATUS_INVITE_SENT:case I.STATUS_1XX_RECEIVED:case I.STATUS_INVITE_RECEIVED:case I.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}},{key:"isEstablished",value:function(){switch(this._status){case I.STATUS_ANSWERED:case I.STATUS_WAITING_FOR_ACK:case I.STATUS_CONFIRMED:return!0;default:return!1}}},{key:"isEnded",value:function(){switch(this._status){case I.STATUS_CANCELED:case I.STATUS_TERMINATED:return!0;default:return!1}}},{key:"isMuted",value:function(){return{audio:this._audioMuted,video:this._videoMuted}}},{key:"isOnHold",value:function(){return{local:this._localHold,remote:this._remoteHold}}},{key:"connect",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;R.debug("connect()");var r=e,o=m.cloneObject(t.eventHandlers),i=m.cloneArray(t.extraHeaders),s=m.cloneObject(t.mediaConstraints,{audio:!0,video:!0}),u=t.mediaStream||null,a=m.cloneObject(t.pcConfig,{iceServers:[]}),l=t.rtcConstraints||null,c=t.rtcOfferConstraints||null;if(this._rtcOfferConstraints=c,this._rtcAnswerConstraints=t.rtcAnswerConstraints||null,this._data=t.data||this._data,void 0===e)throw new TypeError("Not enough arguments");if(this._status!==I.STATUS_NULL)throw new _.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new _.NotSupportedError("WebRTC not supported");if(!(e=this._ua.normalizeTarget(e)))throw new TypeError("Invalid target: ".concat(r));for(var f in this._sessionTimers.enabled&&m.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=p.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=p.SESSION_EXPIRES),o)Object.prototype.hasOwnProperty.call(o,f)&&this.on(f,o[f]);this._from_tag=m.newTag();var h=t.anonymous||!1,d={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:h,outbound:!0}),h?(d.from_display_name="Anonymous",d.from_uri=new A("sip","anonymous","anonymous.invalid"),i.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString())),i.push("Privacy: id")):t.fromUserName&&(d.from_uri=new A("sip",t.fromUserName,this._ua.configuration.uri.host),i.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString()))),t.fromDisplayName&&(d.from_display_name=t.fromDisplayName),i.push("Contact: ".concat(this._contact)),i.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&i.push("Session-Expires: ".concat(this._sessionTimers.defaultExpires).concat(this._ua.configuration.session_timers_force_refresher?";refresher=uac":"")),this._request=new g.InitialOutgoingInviteRequest(e,this._ua,d,i),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(a,l),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(s,c,u)}},{key:"init_incoming",value:function(e,t){var n,r=this;R.debug("init_incoming()");var o=e.hasHeader("Content-Type")?e.getHeader("Content-Type").toLowerCase():void 0;e.body&&"application/sdp"!==o?e.reply(415):(this._status=I.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")&&(n=1e3*e.getHeader("expires")),e.to_tag=m.newTag(),this._createDialog(e,"UAS",!0)?(e.body?this._late_sdp=!1:this._late_sdp=!0,this._status=I.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout((function(){e.reply(408),r._failed("local",null,p.causes.NO_ANSWER)}),this._ua.configuration.no_answer_timeout),n&&(this._timers.expiresTimer=setTimeout((function(){r._status===I.STATUS_WAITING_FOR_ANSWER&&(e.reply(487),r._failed("system",null,p.causes.EXPIRES))}),n)),this._direction="incoming",this._local_identity=e.to,this._remote_identity=e.from,t&&t(this),this._newRTCSession("remote",e),this._status!==I.STATUS_TERMINATED&&(e.reply(180,null,["Contact: ".concat(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]:{};R.debug("answer()");var n=this._request,r=m.cloneArray(t.extraHeaders),i=m.cloneObject(t.mediaConstraints),s=t.mediaStream||null,u=m.cloneObject(t.pcConfig,{iceServers:[]}),a=t.rtcConstraints||null,l=t.rtcAnswerConstraints||null,c=m.cloneObject(t.rtcOfferConstraints),f=!1,h=!1,d=!1,v=!1;if(this._rtcAnswerConstraints=l,this._rtcOfferConstraints=t.rtcOfferConstraints||null,this._data=t.data||this._data,"incoming"!==this._direction)throw new _.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==I.STATUS_WAITING_FOR_ANSWER)throw new _.InvalidStateError(this._status);if(this._sessionTimers.enabled&&m.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=p.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=p.SESSION_EXPIRES),this._status=I.STATUS_ANSWERED,this._createDialog(n,"UAS")){clearTimeout(this._timers.userNoAnswerTimer),r.unshift("Contact: ".concat(this._contact));var y=n.parseSDP();Array.isArray(y.media)||(y.media=[y.media]);var g,b=o(y.media);try{for(b.s();!(g=b.n()).done;){var T=g.value;"audio"===T.type&&(f=!0,T.direction&&"sendrecv"!==T.direction||(d=!0)),"video"===T.type&&(h=!0,T.direction&&"sendrecv"!==T.direction||(v=!0))}}catch(e){b.e(e)}finally{b.f()}if(s&&!1===i.audio){var S,E=o(s.getAudioTracks());try{for(E.s();!(S=E.n()).done;){var C=S.value;s.removeTrack(C)}}catch(e){E.e(e)}finally{E.f()}}if(s&&!1===i.video){var w,A=o(s.getVideoTracks());try{for(A.s();!(w=A.n()).done;){var O=w.value;s.removeTrack(O)}}catch(e){A.e(e)}finally{A.f()}}s||void 0!==i.audio||(i.audio=d),s||void 0!==i.video||(i.video=v),s||f||c.offerToReceiveAudio||(i.audio=!1),s||h||c.offerToReceiveVideo||(i.video=!1),this._createRTCConnection(u,a),Promise.resolve().then((function(){return s||(i.audio||i.video?(e._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(i).catch((function(t){if(e._status===I.STATUS_TERMINATED)throw new Error("terminated");throw n.reply(480),e._failed("local",null,p.causes.USER_DENIED_MEDIA_ACCESS),R.warn('emit "getusermediafailed" [error:%o]',t),e.emit("getusermediafailed",t),new Error("getUserMedia() failed")}))):void 0)})).then((function(t){if(e._status===I.STATUS_TERMINATED)throw new Error("terminated");e._localMediaStream=t,t&&t.getTracks().forEach((function(n){e._connection.addTrack(n,t)}))})).then((function(){if(!e._late_sdp){var t={originator:"remote",type:"offer",sdp:n.body};R.debug('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,p.causes.WEBRTC_ERROR),R.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',t),e.emit("peerconnection:setremotedescriptionfailed",t),new Error("peerconnection.setRemoteDescription() failed")})),e._connectionPromiseQueue}})).then((function(){if(e._status===I.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",l).catch((function(){throw n.reply(500),new Error("_createLocalDescription() failed")}))})).then((function(t){if(e._status===I.STATUS_TERMINATED)throw new Error("terminated");e._handleSessionTimersInIncomingRequest(n,r),n.reply(200,null,r,t,(function(){e._status=I.STATUS_WAITING_FOR_ACK,e._setInvite2xxTimer(n,t),e._setACKTimer(),e._accepted("local")}),(function(){e._failed("system",null,p.causes.CONNECTION_ERROR)}))})).catch((function(t){e._status!==I.STATUS_TERMINATED&&R.warn(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]:{};R.debug("terminate()");var n,r=t.cause||p.causes.BYE,o=m.cloneArray(t.extraHeaders),i=t.body,s=t.status_code,u=t.reason_phrase;if(this._status===I.STATUS_TERMINATED)throw new _.InvalidStateError(this._status);switch(this._status){case I.STATUS_NULL:case I.STATUS_INVITE_SENT:case I.STATUS_1XX_RECEIVED:if(R.debug("canceling session"),s&&(s<200||s>=700))throw new TypeError("Invalid status_code: ".concat(s));s&&(u=u||p.REASON_PHRASE[s]||"",n="SIP ;cause=".concat(s,' ;text="').concat(u,'"')),this._status===I.STATUS_NULL||this._status===I.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=n):this._status===I.STATUS_1XX_RECEIVED&&this._request.cancel(n),this._status=I.STATUS_CANCELED,this._failed("local",null,p.causes.CANCELED);break;case I.STATUS_WAITING_FOR_ANSWER:case I.STATUS_ANSWERED:if(R.debug("rejecting session"),(s=s||480)<300||s>=700)throw new TypeError("Invalid status_code: ".concat(s));this._request.reply(s,u,o,i),this._failed("local",null,p.causes.REJECTED);break;case I.STATUS_WAITING_FOR_ACK:case I.STATUS_CONFIRMED:if(R.debug("terminating session"),u=t.reason_phrase||p.REASON_PHRASE[s]||"",s&&(s<200||s>=700))throw new TypeError("Invalid status_code: ".concat(s));if(s&&o.push("Reason: SIP ;cause=".concat(s,'; text="').concat(u,'"')),this._status===I.STATUS_WAITING_FOR_ACK&&"incoming"===this._direction&&this._request.server_transaction.state!==v.C.STATUS_TERMINATED){var a=this._dialog;this.receiveRequest=function(t){t.method===p.ACK&&(e.sendRequest(p.BYE,{extraHeaders:o,body:i}),a.terminate())},this._request.server_transaction.on("stateChanged",(function(){e._request.server_transaction.state===v.C.STATUS_TERMINATED&&(e.sendRequest(p.BYE,{extraHeaders:o,body:i}),a.terminate())})),this._ended("local",null,r),this._dialog=a,this._ua.newDialog(a)}else this.sendRequest(p.BYE,{extraHeaders:o,body:i}),this._ended("local",null,r)}}},{key:"sendDTMF",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};R.debug("sendDTMF() | tones: %s",e);var n=0,r=t.duration||null,o=t.interToneGap||null,i=t.transportType||p.DTMF_TRANSPORT.INFO;if(void 0===e)throw new TypeError("Not enough arguments");if(this._status!==I.STATUS_CONFIRMED&&this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_1XX_RECEIVED)throw new _.InvalidStateError(this._status);if(i!==p.DTMF_TRANSPORT.INFO&&i!==p.DTMF_TRANSPORT.RFC2833)throw new TypeError("invalid transportType: ".concat(i));if("number"==typeof e&&(e=e.toString()),!e||"string"!=typeof e||!e.match(/^[0-9A-DR#*,]+$/i))throw new TypeError("Invalid tones: ".concat(e));if(r&&!m.isDecimal(r))throw new TypeError("Invalid tone duration: ".concat(r));if(r?r<S.C.MIN_DURATION?(R.debug('"duration" value is lower than the minimum allowed, setting it to '.concat(S.C.MIN_DURATION," milliseconds")),r=S.C.MIN_DURATION):r>S.C.MAX_DURATION?(R.debug('"duration" value is greater than the maximum allowed, setting it to '.concat(S.C.MAX_DURATION," milliseconds")),r=S.C.MAX_DURATION):r=Math.abs(r):r=S.C.DEFAULT_DURATION,t.duration=r,o&&!m.isDecimal(o))throw new TypeError("Invalid interToneGap: ".concat(o));if(o?o<S.C.MIN_INTER_TONE_GAP?(R.debug('"interToneGap" value is lower than the minimum allowed, setting it to '.concat(S.C.MIN_INTER_TONE_GAP," milliseconds")),o=S.C.MIN_INTER_TONE_GAP):o=Math.abs(o):o=S.C.DEFAULT_INTER_TONE_GAP,i!==p.DTMF_TRANSPORT.RFC2833)this._tones?this._tones+=e:(this._tones=e,function e(){var i,s=this;if(this._status===I.STATUS_TERMINATED||!this._tones||n>=this._tones.length)return void(this._tones=null);var u=this._tones[n];if(n+=1,","===u)i=2e3;else{var a=new S(this);t.eventHandlers={onFailed:function(){s._tones=null}},a.send(u,t),i=r+o}setTimeout(e.bind(this),i)}.call(this));else{var s=this._getDTMFRTPSender();s&&(e=s.toneBuffer+e,s.insertDTMF(e,r,o))}}},{key:"sendInfo",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(R.debug("sendInfo()"),this._status!==I.STATUS_CONFIRMED&&this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_1XX_RECEIVED)throw new _.InvalidStateError(this._status);new E(this).send(e,t,n)}},{key:"mute",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{audio:!0,video:!1};R.debug("mute()");var t=!1,n=!1;!1===this._audioMuted&&e.audio&&(t=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),!1===this._videoMuted&&e.video&&(n=!0,this._videoMuted=!0,this._toggleMuteVideo(!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};R.debug("unmute()");var t=!1,n=!1;!0===this._audioMuted&&e.audio&&(t=!0,this._audioMuted=!1,!1===this._localHold&&this._toggleMuteAudio(!1)),!0===this._videoMuted&&e.video&&(n=!0,this._videoMuted=!1,!1===this._localHold&&this._toggleMuteVideo(!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.length>1?arguments[1]:void 0;if(R.debug("hold()"),this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.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:p.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.length>1?arguments[1]:void 0;if(R.debug("unhold()"),this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.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:p.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.length>1?arguments[1]:void 0;R.debug("renegotiate()");var r=t.rtcOfferConstraints||null;if(this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_CONFIRMED)return!1;if(!this._isReadyToReOffer())return!1;var o={succeeded:function(){n&&n()},failed:function(){e.terminate({cause:p.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,rtcOfferConstraints:r,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:o,rtcOfferConstraints:r,extraHeaders:t.extraHeaders}),!0}},{key:"refer",value:function(e,t){var n=this;R.debug("refer()");var r=e;if(this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_CONFIRMED)return!1;if(!(e=this._ua.normalizeTarget(e)))throw new TypeError("Invalid target: ".concat(r));var o=new w(this);o.sendRefer(e,t);var i=o.id;return this._referSubscribers[i]=o,o.on("requestFailed",(function(){delete n._referSubscribers[i]})),o.on("accepted",(function(){delete n._referSubscribers[i]})),o.on("failed",(function(){delete n._referSubscribers[i]})),o}},{key:"sendRequest",value:function(e,t){return R.debug("sendRequest()"),this._dialog.sendRequest(e,t)}},{key:"receiveRequest",value:function(e){var t=this;if(R.debug("receiveRequest()"),e.method===p.CANCEL)this._status!==I.STATUS_WAITING_FOR_ANSWER&&this._status!==I.STATUS_ANSWERED||(this._status=I.STATUS_CANCELED,this._request.reply(487),this._failed("remote",e,p.causes.CANCELED));else switch(e.method){case p.ACK:if(this._status!==I.STATUS_WAITING_FOR_ACK)return;if(this._status=I.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!e.body){this.terminate({cause:p.causes.MISSING_SDP,status_code:400});break}var n={originator:"remote",type:"answer",sdp:e.body};R.debug('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:p.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),R.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)}))}else this._is_confirmed||this._confirmed("remote",e);break;case p.BYE:this._status===I.STATUS_CONFIRMED||this._status===I.STATUS_WAITING_FOR_ACK?(e.reply(200),this._ended("remote",e,p.causes.BYE)):this._status===I.STATUS_INVITE_RECEIVED||this._status===I.STATUS_WAITING_FOR_ANSWER?(e.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",e,p.causes.BYE)):e.reply(403,"Wrong Status");break;case p.INVITE:this._status===I.STATUS_CONFIRMED?e.hasHeader("replaces")?this._receiveReplaces(e):this._receiveReinvite(e):e.reply(403,"Wrong Status");break;case p.INFO:if(this._status===I.STATUS_1XX_RECEIVED||this._status===I.STATUS_WAITING_FOR_ANSWER||this._status===I.STATUS_ANSWERED||this._status===I.STATUS_WAITING_FOR_ACK||this._status===I.STATUS_CONFIRMED){var o=e.hasHeader("Content-Type")?e.getHeader("Content-Type").toLowerCase():void 0;o&&o.match(/^application\/dtmf-relay/i)?new S(this).init_incoming(e):void 0!==o?new E(this).init_incoming(e):e.reply(415)}else e.reply(403,"Wrong Status");break;case p.UPDATE:this._status===I.STATUS_CONFIRMED?this._receiveUpdate(e):e.reply(403,"Wrong Status");break;case p.REFER:this._status===I.STATUS_CONFIRMED?this._receiveRefer(e):e.reply(403,"Wrong Status");break;case p.NOTIFY:this._status===I.STATUS_CONFIRMED?this._receiveNotify(e):e.reply(403,"Wrong Status");break;default:e.reply(501)}}},{key:"onTransportError",value:function(){R.warn("onTransportError()"),this._status!==I.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:p.causes.CONNECTION_ERROR,cause:p.causes.CONNECTION_ERROR})}},{key:"onRequestTimeout",value:function(){R.warn("onRequestTimeout()"),this._status!==I.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:p.causes.REQUEST_TIMEOUT,cause:p.causes.REQUEST_TIMEOUT})}},{key:"onDialogError",value:function(){R.warn("onDialogError()"),this._status!==I.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:p.causes.DIALOG_ERROR,cause:p.causes.DIALOG_ERROR})}},{key:"newDTMF",value:function(e){R.debug("newDTMF()"),this.emit("newDTMF",e)}},{key:"newInfo",value:function(e){R.debug("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||(R.debug("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):(R.debug("_isReadyToReOffer() | session not established yet"),!1):(R.debug("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}},{key:"_close",value:function(){if(R.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(R.debug("close() | closing local MediaStream"),m.closeMediaStream(this._localMediaStream)),this._status!==I.STATUS_TERMINATED){if(this._status=I.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(e){R.warn("close() | error closing the RTCPeerConnection: %o",e)}for(var e in this._timers)Object.prototype.hasOwnProperty.call(this._timers,e)&&clearTimeout(this._timers[e]);for(var t in clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog),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=y.T1;this._timers.invite2xxTimer=setTimeout(function r(){this._status===I.STATUS_WAITING_FOR_ACK&&(e.reply(200,null,["Contact: ".concat(this._contact)],t),n<y.T2&&(n*=2)>y.T2&&(n=y.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===I.STATUS_WAITING_FOR_ACK&&(R.debug("no ACK received, terminating the session"),clearTimeout(e._timers.invite2xxTimer),e.sendRequest(p.BYE),e._ended("remote",null,p.causes.NO_ACK))}),y.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:p.causes.RTP_TIMEOUT,status_code:408,reason_phrase:p.causes.RTP_TIMEOUT})})),R.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}},{key:"_createLocalDescription",value:function(e,t){var n=this;if(R.debug("createLocalDescription()"),"offer"!==e&&"answer"!==e)throw new Error('createLocalDescription() | invalid type "'.concat(e,'"'));var r=this._connection;return this._rtcReady=!1,Promise.resolve().then((function(){return"offer"===e?r.createOffer(t).catch((function(e){return R.warn('emit "peerconnection:createofferfailed" [error:%o]',e),n.emit("peerconnection:createofferfailed",e),Promise.reject(e)})):r.createAnswer(t).catch((function(e){return R.warn('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,R.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',e),n.emit("peerconnection:setlocaldescriptionfailed",e),Promise.reject(e)}))})).then((function(){var o=t&&t.iceRestart;if("complete"===r.iceGatheringState&&!o||"gathering"===r.iceGatheringState&&n._iceReady){n._rtcReady=!0;var i={originator:"local",type:e,sdp:r.localDescription.sdp};return R.debug('emit "sdp"'),n.emit("sdp",i),Promise.resolve(i.sdp)}return new Promise((function(t){var o,i,s=!1;n._iceReady=!1;var u=function(){if(!s){r.removeEventListener("icecandidate",o),r.removeEventListener("icegatheringstatechange",i),s=!0,n._rtcReady=!0,n._iceReady=!0;var u={originator:"local",type:e,sdp:r.localDescription.sdp};R.debug('emit "sdp"'),n.emit("sdp",u),t(u.sdp)}};r.addEventListener("icecandidate",o=function(e){var t=e.candidate;t?n.emit("icecandidate",{candidate:t,ready:u}):u()}),r.addEventListener("icegatheringstatechange",i=function(){"complete"===r.iceGatheringState&&u()})}))}))}},{key:"_createDialog",value:function(e,t,n){var r="UAS"===t?e.to_tag:e.from_tag,o="UAS"===t?e.from_tag:e.to_tag,i=e.call_id+r+o,s=this._earlyDialogs[i];if(n)return!!s||((s=new b(this,e,t,b.C.STATUS_EARLY)).error?(R.debug(s.error),this._failed("remote",e,p.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[i]=s,!0));if(this._from_tag=e.from_tag,this._to_tag=e.to_tag,s)return s.update(e,t),this._dialog=s,delete this._earlyDialogs[i],!0;var u=new b(this,e,t);return u.error?(R.debug(u.error),this._failed("remote",e,p.causes.INTERNAL_ERROR),!1):(this._dialog=u,!0)}},{key:"_receiveReinvite",value:function(e){var t=this;R.debug("receiveReinvite()");var n=e.hasHeader("Content-Type")?e.getHeader("Content-Type").toLowerCase():void 0,r={request:e,callback:void 0,reject:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o=!0;var n=t.status_code||403,r=t.reason_phrase||"",i=m.cloneArray(t.extraHeaders);if(this._status!==I.STATUS_CONFIRMED)return!1;if(n<300||n>=700)throw new TypeError("Invalid status_code: ".concat(n));e.reply(n,r,i)}.bind(this)},o=!1;if(this.emit("reinvite",r),!o){if(this._late_sdp=!1,!e.body)return this._late_sdp=!0,this._remoteHold&&(this._remoteHold=!1,this._onunhold("remote")),void(this._connectionPromiseQueue=this._connectionPromiseQueue.then((function(){return t._createLocalDescription("offer",t._rtcOfferConstraints)})).then((function(e){i.call(t,e)})).catch((function(){e.reply(500)})));if("application/sdp"!==n)return R.debug("invalid Content-Type"),void e.reply(415);this._processInDialogSdpOffer(e).then((function(e){t._status!==I.STATUS_TERMINATED&&i.call(t,e)})).catch((function(e){R.warn(e)}))}function i(t){var n=this,o=["Contact: ".concat(this._contact)];this._handleSessionTimersInIncomingRequest(e,o),this._late_sdp&&(t=this._mangleOffer(t)),e.reply(200,null,o,t,(function(){n._status=I.STATUS_WAITING_FOR_ACK,n._setInvite2xxTimer(e,t),n._setACKTimer()})),"function"==typeof r.callback&&r.callback()}}},{key:"_receiveUpdate",value:function(e){var t=this;R.debug("receiveUpdate()");var n=e.hasHeader("Content-Type")?e.getHeader("Content-Type").toLowerCase():void 0,r={request:e,callback:void 0,reject:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o=!0;var n=t.status_code||403,r=t.reason_phrase||"",i=m.cloneArray(t.extraHeaders);if(this._status!==I.STATUS_CONFIRMED)return!1;if(n<300||n>=700)throw new TypeError("Invalid status_code: ".concat(n));e.reply(n,r,i)}.bind(this)},o=!1;if(this.emit("update",r),!o)if(e.body){if("application/sdp"!==n)return R.debug("invalid Content-Type"),void e.reply(415);this._processInDialogSdpOffer(e).then((function(e){t._status!==I.STATUS_TERMINATED&&i.call(t,e)})).catch((function(e){R.warn(e)}))}else i.call(this,null);function i(t){var n=["Contact: ".concat(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;R.debug("_processInDialogSdpOffer()");var n,r=e.parseSDP(),i=!1,s=o(r.media);try{for(s.s();!(n=s.n()).done;){var u=n.value;if(-1!==O.indexOf(u.type)){var a=u.direction||r.direction||"sendrecv";if("sendonly"!==a&&"inactive"!==a){i=!1;break}i=!0}}}catch(e){s.e(e)}finally{s.f()}var l={originator:"remote",type:"offer",sdp:e.body};R.debug('emit "sdp"'),this.emit("sdp",l);var c=new RTCSessionDescription({type:"offer",sdp:l.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then((function(){if(t._status===I.STATUS_TERMINATED)throw new Error("terminated");return t._connection.setRemoteDescription(c).catch((function(n){throw e.reply(488),R.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',n),t.emit("peerconnection:setremotedescriptionfailed",n),n}))})).then((function(){if(t._status===I.STATUS_TERMINATED)throw new Error("terminated");!0===t._remoteHold&&!1===i?(t._remoteHold=!1,t._onunhold("remote")):!1===t._remoteHold&&!0===i&&(t._remoteHold=!0,t._onhold("remote"))})).then((function(){if(t._status===I.STATUS_TERMINATED)throw new Error("terminated");return t._createLocalDescription("answer",t._rtcAnswerConstraints).catch((function(t){throw e.reply(500),R.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',t),t}))})).catch((function(e){R.warn("_processInDialogSdpOffer() failed [error: %o]",e)})),this._connectionPromiseQueue}},{key:"_receiveRefer",value:function(e){var t=this;if(R.debug("receiveRefer()"),!e.refer_to)return R.debug("no Refer-To header field present in REFER"),void e.reply(400);if(e.refer_to.uri.scheme!==p.SIP)return R.debug("Refer-To header field points to a non-SIP URI scheme"),void e.reply(416);e.reply(202);var r=new C(this,e.cseq);function o(t){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(t="function"==typeof t?t:null,this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_CONFIRMED)return!1;var i=new n(this._ua);if(i.on("progress",(function(e){var t=e.response;r.notify(t.status_code,t.reason_phrase)})),i.on("accepted",(function(e){var t=e.response;r.notify(t.status_code,t.reason_phrase)})),i.on("_failed",(function(e){var t=e.message,n=e.cause;t?r.notify(t.status_code,t.reason_phrase):r.notify(487,n)})),e.refer_to.uri.hasHeader("replaces")){var s=decodeURIComponent(e.refer_to.uri.getHeader("replaces"));o.extraHeaders=m.cloneArray(o.extraHeaders),o.extraHeaders.push("Replaces: ".concat(s))}i.connect(e.refer_to.uri.toAor(),o,t)}function i(){r.notify(603)}R.debug('emit "refer"'),this.emit("refer",{request:e,accept:function(e,n){o.call(t,e,n)},reject:function(){i.call(t)}})}},{key:"_receiveNotify",value:function(e){if(R.debug("receiveNotify()"),e.event||e.reply(400),"refer"===e.event.event){var t,n;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)}else e.reply(489)}},{key:"_receiveReplaces",value:function(e){var t=this;function r(t){var r=this;if(this._status!==I.STATUS_WAITING_FOR_ACK&&this._status!==I.STATUS_CONFIRMED)return!1;var o=new n(this._ua);o.on("confirmed",(function(){r.terminate()})),o.init_incoming(e,t)}function o(){R.debug("Replaced INVITE rejected by the user"),e.reply(486)}R.debug("receiveReplaces()"),this.emit("replaces",{request:e,accept:function(e){r.call(t,e)},reject:function(){o.call(t)}})}},{key:"_sendInitialRequest",value:function(e,t,n){var r=this,o=new T(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===I.STATUS_TERMINATED)throw new Error("terminated");throw r._failed("local",null,p.causes.USER_DENIED_MEDIA_ACCESS),R.warn('emit "getusermediafailed" [error:%o]',e),r.emit("getusermediafailed",e),e}))):void 0)})).then((function(e){if(r._status===I.STATUS_TERMINATED)throw new Error("terminated");return r._localMediaStream=e,e&&e.getTracks().forEach((function(t){r._connection.addTrack(t,e)})),r._connecting(r._request),r._createLocalDescription("offer",t).catch((function(e){throw r._failed("local",null,p.causes.WEBRTC_ERROR),e}))})).then((function(e){if(r._is_canceled||r._status===I.STATUS_TERMINATED)throw new Error("terminated");r._request.body=e,r._status=I.STATUS_INVITE_SENT,R.debug('emit "sending" [request:%o]',r._request),r.emit("sending",{request:r._request}),o.send()})).catch((function(e){r._status!==I.STATUS_TERMINATED&&R.warn(e)}))}},{key:"_getDTMFRTPSender",value:function(){var e=this._connection.getSenders().find((function(e){return e.track&&"audio"===e.track.kind}));if(e&&e.dtmf)return e.dtmf;R.warn("sendDTMF() | no local audio track to send DTMF with")}},{key:"_receiveInviteResponse",value:function(e){var t=this;if(R.debug("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(p.ACK);var n=new b(this,e,"UAC");return void 0!==n.error?void R.debug(n.error):(this.sendRequest(p.ACK),void this.sendRequest(p.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===I.STATUS_INVITE_SENT||this._status===I.STATUS_1XX_RECEIVED)switch(!0){case/^100$/.test(e.status_code):this._status=I.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(e.status_code):if(!e.to_tag){R.debug("1xx response received without to tag");break}if(e.hasHeader("contact")&&!this._createDialog(e,"UAC",!0))break;if(this._status=I.STATUS_1XX_RECEIVED,!e.body){this._progress("remote",e);break}var r={originator:"remote",type:"answer",sdp:e.body};R.debug('emit "sdp"'),this.emit("sdp",r);var o=new RTCSessionDescription({type:"answer",sdp:r.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then((function(){return t._connection.setRemoteDescription(o)})).then((function(){return t._progress("remote",e)})).catch((function(e){R.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)}));break;case/^2[0-9]{2}$/.test(e.status_code):if(this._status=I.STATUS_CONFIRMED,!e.body){this._acceptAndTerminate(e,400,p.causes.MISSING_SDP),this._failed("remote",e,p.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(e,"UAC"))break;var i={originator:"remote",type:"answer",sdp:e.body};R.debug('emit "sdp"'),this.emit("sdp",i);var s=new RTCSessionDescription({type:"answer",sdp:i.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then((function(){if("stable"===t._connection.signalingState)return t._connection.createOffer(t._rtcOfferConstraints).then((function(e){return t._connection.setLocalDescription(e)})).catch((function(n){t._acceptAndTerminate(e,500,n.toString()),t._failed("local",e,p.causes.WEBRTC_ERROR)}))})).then((function(){t._connection.setRemoteDescription(s).then((function(){t._handleSessionTimersInIncomingResponse(e),t._accepted("remote",e),t.sendRequest(p.ACK),t._confirmed("local",null)})).catch((function(n){t._acceptAndTerminate(e,488,"Not Acceptable Here"),t._failed("remote",e,p.causes.BAD_MEDIA_DESCRIPTION),R.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',n),t.emit("peerconnection:setremotedescriptionfailed",n)}))}));break;default:var u=m.sipErrorCause(e.status_code);this._failed("remote",e,u)}}},{key:"_sendReinvite",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};R.debug("sendReinvite()");var n=m.cloneArray(t.extraHeaders),r=m.cloneObject(t.eventHandlers),o=t.rtcOfferConstraints||this._rtcOfferConstraints||null,i=!1;function s(e){var t=this;if(this._status!==I.STATUS_TERMINATED&&(this.sendRequest(p.ACK),!i))if(this._handleSessionTimersInIncomingResponse(e),e.body)if(e.hasHeader("Content-Type")&&"application/sdp"===e.getHeader("Content-Type").toLowerCase()){var n={originator:"remote",type:"answer",sdp:e.body};R.debug('emit "sdp"'),this.emit("sdp",n);var o=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then((function(){return t._connection.setRemoteDescription(o)})).then((function(){r.succeeded&&r.succeeded(e)})).catch((function(e){u.call(t),R.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)}))}else u.call(this);else u.call(this)}function u(e){r.failed&&r.failed(e)}n.push("Contact: ".concat(this._contact)),n.push("Content-Type: application/sdp"),this._sessionTimers.running&&n.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(this._sessionTimers.refresher?"uac":"uas")),this._connectionPromiseQueue=this._connectionPromiseQueue.then((function(){return e._createLocalDescription("offer",o)})).then((function(t){var r={originator:"local",type:"offer",sdp:t=e._mangleOffer(t)};R.debug('emit "sdp"'),e.emit("sdp",r),e.sendRequest(p.INVITE,{extraHeaders:n,body:t,eventHandlers:{onSuccessResponse:function(t){s.call(e,t),i=!0},onErrorResponse:function(t){u.call(e,t)},onTransportError:function(){e.onTransportError()},onRequestTimeout:function(){e.onRequestTimeout()},onDialogError:function(){e.onDialogError()}}})})).catch((function(){u()}))}},{key:"_sendUpdate",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};R.debug("sendUpdate()");var n=m.cloneArray(t.extraHeaders),r=m.cloneObject(t.eventHandlers),o=t.rtcOfferConstraints||this._rtcOfferConstraints||null,i=t.sdpOffer||!1,s=!1;function u(e){var t=this;if(this._status!==I.STATUS_TERMINATED&&!s)if(this._handleSessionTimersInIncomingResponse(e),i){if(!e.body)return void a.call(this);if(!e.hasHeader("Content-Type")||"application/sdp"!==e.getHeader("Content-Type").toLowerCase())return void a.call(this);var n={originator:"remote",type:"answer",sdp:e.body};R.debug('emit "sdp"'),this.emit("sdp",n);var o=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then((function(){return t._connection.setRemoteDescription(o)})).then((function(){r.succeeded&&r.succeeded(e)})).catch((function(e){a.call(t),R.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',e),t.emit("peerconnection:setremotedescriptionfailed",e)}))}else r.succeeded&&r.succeeded(e)}function a(e){r.failed&&r.failed(e)}n.push("Contact: ".concat(this._contact)),this._sessionTimers.running&&n.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(this._sessionTimers.refresher?"uac":"uas")),i?(n.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then((function(){return e._createLocalDescription("offer",o)})).then((function(t){var r={originator:"local",type:"offer",sdp:t=e._mangleOffer(t)};R.debug('emit "sdp"'),e.emit("sdp",r),e.sendRequest(p.UPDATE,{extraHeaders:n,body:t,eventHandlers:{onSuccessResponse:function(t){u.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.call(e)}))):this.sendRequest(p.UPDATE,{extraHeaders:n,eventHandlers:{onSuccessResponse:function(t){u.call(e,t)},onErrorResponse:function(t){a.call(e,t)},onTransportError:function(){e.onTransportError()},onRequestTimeout:function(){e.onRequestTimeout()},onDialogError:function(){e.onDialogError()}}})}},{key:"_acceptAndTerminate",value:function(e,t,n){R.debug("acceptAndTerminate()");var r=[];t&&(n=n||p.REASON_PHRASE[t]||"",r.push("Reason: SIP ;cause=".concat(t,'; text="').concat(n,'"'))),(this._dialog||this._createDialog(e,"UAC"))&&(this.sendRequest(p.ACK),this.sendRequest(p.BYE,{extraHeaders:r})),this._status=I.STATUS_TERMINATED}},{key:"_mangleOffer",value:function(e){if(!this._localHold&&!this._remoteHold)return e;if(e=h.parse(e),this._localHold&&!this._remoteHold){R.debug("mangleOffer() | me on hold, mangling offer");var t,n=o(e.media);try{for(n.s();!(t=n.n()).done;){var r=t.value;-1!==O.indexOf(r.type)&&(r.direction?"sendrecv"===r.direction?r.direction="sendonly":"recvonly"===r.direction&&(r.direction="inactive"):r.direction="sendonly")}}catch(e){n.e(e)}finally{n.f()}}else if(this._localHold&&this._remoteHold){R.debug("mangleOffer() | both on hold, mangling offer");var i,s=o(e.media);try{for(s.s();!(i=s.n()).done;){var u=i.value;-1!==O.indexOf(u.type)&&(u.direction="inactive")}}catch(e){s.e(e)}finally{s.f()}}else if(this._remoteHold){R.debug("mangleOffer() | remote on hold, mangling offer");var a,l=o(e.media);try{for(l.s();!(a=l.n()).done;){var c=a.value;-1!==O.indexOf(c.type)&&(c.direction?"sendrecv"===c.direction?c.direction="recvonly":"recvonly"===c.direction&&(c.direction="inactive"):c.direction="recvonly")}}catch(e){l.e(e)}finally{l.f()}}return h.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._toggleMuteAudio(!e),this._toggleMuteVideo(!t)}},{key:"_handleSessionTimersInIncomingRequest",value:function(e,t){var n;this._sessionTimers.enabled&&(e.session_expires&&e.session_expires>=p.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: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(n)),this._sessionTimers.refresher="uas"===n,this._runSessionTimer())}},{key:"_handleSessionTimersInIncomingResponse",value:function(e){var t;this._sessionTimers.enabled&&(e.session_expires&&e.session_expires>=p.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!==I.STATUS_TERMINATED&&e._isReadyToReOffer()&&(R.debug("runSessionTimer() | sending session refresh request"),e._sessionTimers.refreshMethod===p.UPDATE?e._sendUpdate():e._sendReinvite())}),500*t):this._sessionTimers.timer=setTimeout((function(){e._status!==I.STATUS_TERMINATED&&(R.warn("runSessionTimer() | timer expired, terminating the session"),e.terminate({cause:p.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))}),1100*t)}},{key:"_toggleMuteAudio",value:function(e){var t,n=this._connection.getSenders().filter((function(e){return e.track&&"audio"===e.track.kind})),r=o(n);try{for(r.s();!(t=r.n()).done;){t.value.track.enabled=!e}}catch(e){r.e(e)}finally{r.f()}}},{key:"_toggleMuteVideo",value:function(e){var t,n=this._connection.getSenders().filter((function(e){return e.track&&"video"===e.track.kind})),r=o(n);try{for(r.s();!(t=r.n()).done;){t.value.track.enabled=!e}}catch(e){r.e(e)}finally{r.f()}}},{key:"_newRTCSession",value:function(e,t){R.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:e,session:this,request:t})}},{key:"_connecting",value:function(e){R.debug("session connecting"),R.debug('emit "connecting"'),this.emit("connecting",{request:e})}},{key:"_progress",value:function(e,t){R.debug("session progress"),R.debug('emit "progress"'),this.emit("progress",{originator:e,response:t||null})}},{key:"_accepted",value:function(e,t){R.debug("session accepted"),this._start_time=new Date,R.debug('emit "accepted"'),this.emit("accepted",{originator:e,response:t||null})}},{key:"_confirmed",value:function(e,t){R.debug("session confirmed"),this._is_confirmed=!0,R.debug('emit "confirmed"'),this.emit("confirmed",{originator:e,ack:t||null})}},{key:"_ended",value:function(e,t,n){R.debug("session ended"),this._end_time=new Date,this._close(),R.debug('emit "ended"'),this.emit("ended",{originator:e,message:t||null,cause:n})}},{key:"_failed",value:function(e,t,n){R.debug("session failed"),R.debug('emit "_failed"'),this.emit("_failed",{originator:e,message:t||null,cause:n}),this._close(),R.debug('emit "failed"'),this.emit("failed",{originator:e,message:t||null,cause:n})}},{key:"_onhold",value:function(e){R.debug("session onhold"),this._setLocalMediaStatus(),R.debug('emit "hold"'),this.emit("hold",{originator:e})}},{key:"_onunhold",value:function(e){R.debug("session onunhold"),this._setLocalMediaStatus(),R.debug('emit "unhold"'),this.emit("unhold",{originator:e})}},{key:"_onmute",value:function(e){var t=e.audio,n=e.video;R.debug("session onmute"),this._setLocalMediaStatus(),R.debug('emit "muted"'),this.emit("muted",{audio:t,video:n})}},{key:"_onunmute",value:function(e){var t=e.audio,n=e.video;R.debug("session onunmute"),this._setLocalMediaStatus(),R.debug('emit "unmuted"'),this.emit("unmuted",{audio:t,video:n})}},{key:"C",get:function(){return I}},{key:"causes",get:function(){return p.causes}},{key:"id",get:function(){return this._id}},{key:"connection",get:function(){return this._connection}},{key:"contact",get:function(){return this._contact}},{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}}]),n}(f)},697:(e,t,n)=>{"use strict";function r(e){return 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},r(e)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t){return i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},i(e,t)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=u(e);if(t){var i=u(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return function(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,n)}}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}var a=n(7).EventEmitter,l=n(510),c=n(349),f=n(956),h=n(137),d=new l("RTCSession:DTMF"),p={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};e.exports=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(a,e);var t,n,r,u=s(a);function a(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(t=u.call(this))._session=e,t._direction=null,t._tone=null,t._duration=null,t._request=null,t}return t=a,n=[{key:"send",value:function(e){var t=this,n=arguments.length>1&&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 f.InvalidStateError(this._session.status);var r=h.cloneArray(n.extraHeaders);if(this.eventHandlers=h.cloneObject(n.eventHandlers),"string"==typeof e)e=e.toUpperCase();else{if("number"!=typeof e)throw new TypeError("Invalid tone: ".concat(e));e=e.toString()}if(!e.match(/^[0-9A-DR#*]$/))throw new TypeError("Invalid tone: ".concat(e));this._tone=e,this._duration=n.duration,r.push("Content-Type: application/dtmf-relay");var o="Signal=".concat(this._tone,"\r\n");o+="Duration=".concat(this._duration),this._session.newDTMF({originator:"local",dtmf:this,request:this._request}),this._session.sendRequest(c.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:o})}},{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=p.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:e}):d.debug("invalid INFO DTMF received, discarded")}},{key:"tone",get:function(){return this._tone}},{key:"duration",get:function(){return this._duration}}],n&&o(t.prototype,n),r&&o(t,r),a}(a),e.exports.C=p},850:(e,t,n)=>{"use strict";function r(e){return 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},r(e)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t){return i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},i(e,t)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=u(e);if(t){var i=u(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return function(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,n)}}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}var a=n(7).EventEmitter,l=n(349),c=n(956),f=n(137);e.exports=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(a,e);var t,n,r,u=s(a);function a(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(t=u.call(this))._session=e,t._direction=null,t._contentType=null,t._body=null,t}return t=a,n=[{key:"send",value:function(e,t){var n=this,r=arguments.length>2&&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 c.InvalidStateError(this._session.status);this._contentType=e,this._body=t;var o=f.cloneArray(r.extraHeaders);o.push("Content-Type: ".concat(e)),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(l.INFO,{extraHeaders:o,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.hasHeader("Content-Type")?e.getHeader("Content-Type").toLowerCase():void 0,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}}],n&&o(t.prototype,n),r&&o(t,r),a}(a)},276:(e,t,n)=>{"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var o=n(510),i=n(349),s=new o("RTCSession:ReferNotifier"),u="refer",a="message/sipfrag;version=2.0",l=300;e.exports=function(){function e(t,n,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._session=t,this._id=n,this._expires=r||l,this._active=!0,this.notify(100)}var t,n,o;return t=e,(n=[{key:"notify",value:function(e,t){var n;s.debug("notify()"),!1!==this._active&&(t=t||i.REASON_PHRASE[e]||"",n=e>=200?"terminated;reason=noresource":"active;expires=".concat(this._expires),this._session.sendRequest(i.NOTIFY,{extraHeaders:["Event: ".concat(u,";id=").concat(this._id),"Subscription-State: ".concat(n),"Content-Type: ".concat(a)],body:"SIP/2.0 ".concat(e," ").concat(t),eventHandlers:{onErrorResponse:function(){this._active=!1}}}))}}])&&r(t.prototype,n),o&&r(t,o),e}()},716:(e,t,n)=>{"use strict";function r(e){return 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},r(e)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t){return i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},i(e,t)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=u(e);if(t){var i=u(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return function(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,n)}}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}var a=n(7).EventEmitter,l=n(510),c=n(349),f=n(561),h=n(137),d=new l("RTCSession:ReferSubscriber");e.exports=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(a,e);var t,n,r,u=s(a);function a(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(t=u.call(this))._id=null,t._session=e,t}return t=a,n=[{key:"sendRefer",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};d.debug("sendRefer()");var r=h.cloneArray(n.extraHeaders),o=h.cloneObject(n.eventHandlers);for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&this.on(i,o[i]);var s=null;n.replaces&&(s=n.replaces._request.call_id,s+=";to-tag=".concat(n.replaces._to_tag),s+=";from-tag=".concat(n.replaces._from_tag),s=encodeURIComponent(s));var u="Refer-To: <".concat(e).concat(s?"?Replaces=".concat(s):"",">");if(r.push(u),!r.some((function(e){return e.toLowerCase().startsWith("referred-by:")}))){var a="Referred-By: <".concat(this._session._ua._configuration.uri._scheme,":").concat(this._session._ua._configuration.uri._user,"@").concat(this._session._ua._configuration.uri._host,">");r.push(a)}r.push("Contact: ".concat(this._session.contact));var l=this._session.sendRequest(c.REFER,{extraHeaders:r,eventHandlers:{onSuccessResponse:function(e){t._requestSucceeded(e)},onErrorResponse:function(e){t._requestFailed(e,c.causes.REJECTED)},onTransportError:function(){t._requestFailed(null,c.causes.CONNECTION_ERROR)},onRequestTimeout:function(){t._requestFailed(null,c.causes.REQUEST_TIMEOUT)},onDialogError:function(){t._requestFailed(null,c.causes.DIALOG_ERROR)}}});this._id=l.cseq}},{key:"receiveNotify",value:function(e){if(d.debug("receiveNotify()"),e.body){var t=f.parse(e.body.trim().split("\r\n",1)[0],"Status_Line");if(-1!==t)switch(!0){case/^100$/.test(t.status_code):this.emit("trying",{request:e,status_line:t});break;case/^1[0-9]{2}$/.test(t.status_code):this.emit("progress",{request:e,status_line:t});break;case/^2[0-9]{2}$/.test(t.status_code):this.emit("accepted",{request:e,status_line:t});break;default:this.emit("failed",{request:e,status_line:t})}else d.debug('receiveNotify() | error parsing NOTIFY body: "'.concat(e.body,'"'))}}},{key:"_requestSucceeded",value:function(e){d.debug("REFER succeeded"),d.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:e})}},{key:"_requestFailed",value:function(e,t){d.debug("REFER failed"),d.debug('emit "requestFailed"'),this.emit("requestFailed",{response:e||null,cause:t})}},{key:"id",get:function(){return this._id}}],n&&o(t.prototype,n),r&&o(t,r),a}(a)},680:(e,t,n)=>{"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var o=n(510),i=n(137),s=n(349),u=n(213),a=n(396),l=new o("Registrator");e.exports=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._reg_id=1,this._ua=t,this._transport=n,this._registrar=t.configuration.registrar_server,this._expires=t.configuration.register_expires,this._call_id=i.createRandomToken(22),this._cseq=0,this._to_uri=t.configuration.uri,this._registrationTimer=null,this._registering=!1,this._registered=!1,this._contact=this._ua.contact.toString(),this._contact+=";+sip.ice",this._extraHeaders=[],this._extraContactParams="",this._sipInstance='"<urn:uuid:'.concat(this._ua.configuration.instance_id,'>"'),this._contact+=";reg-id=".concat(this._reg_id),this._contact+=";+sip.instance=".concat(this._sipInstance)}var t,n,o;return t=e,n=[{key:"setExtraHeaders",value:function(e){Array.isArray(e)||(e=[]),this._extraHeaders=e.slice()}},{key:"setExtraContactParams",value:function(e){for(var t in e instanceof Object||(e={}),this._extraContactParams="",e)if(Object.prototype.hasOwnProperty.call(e,t)){var n=e[t];this._extraContactParams+=";".concat(t),n&&(this._extraContactParams+="=".concat(n))}}},{key:"register",value:function(){var e=this;if(this._registering)l.debug("Register request in progress...");else{var t=this._extraHeaders.slice();t.push("Contact: ".concat(this._contact,";expires=").concat(this._expires).concat(this._extraContactParams)),t.push("Expires: ".concat(this._expires));var n=new u.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){if(t.cseq===e._cseq)switch(null!==e._registrationTimer&&(clearTimeout(e._registrationTimer),e._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(t.status_code):break;case/^2[0-9]{2}$/.test(t.status_code):if(e._registering=!1,!t.hasHeader("Contact")){l.debug("no Contact header in response to REGISTER, response ignored");break}var n=t.headers.Contact.reduce((function(e,t){return e.concat(t.parsed)}),[]),r=n.find((function(t){return e._sipInstance===t.getParam("+sip.instance")&&e._reg_id===parseInt(t.getParam("reg-id"))}));if(r||(r=n.find((function(t){return t.uri.user===e._ua.contact.uri.user}))),!r){l.debug("no Contact header pointing to us, response ignored");break}var o=r.getParam("expires");!o&&t.hasHeader("expires")&&(o=t.getHeader("expires")),o||(o=e._expires),(o=Number(o))<10&&(o=10);var u=o>64?1e3*o/2+Math.floor(1e3*(o/2-32)*Math.random()):1e3*o-5e3;e._registrationTimer=setTimeout((function(){e._registrationTimer=null,0===e._ua.listeners("registrationExpiring").length?e.register():e._ua.emit("registrationExpiring")}),u),r.hasParam("temp-gruu")&&(e._ua.contact.temp_gruu=r.getParam("temp-gruu").replace(/"/g,"")),r.hasParam("pub-gruu")&&(e._ua.contact.pub_gruu=r.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.debug("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: *".concat(this._extraContactParams)):n.push("Contact: ".concat(this._contact,";expires=0").concat(this._extraContactParams)),n.push("Expires: 0");var r=new u.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.debug("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}}],n&&r(t.prototype,n),o&&r(t,o),e}()},396:(e,t,n)=>{"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var o=n(510),i=n(349),s=n(554),u=n(143),a=new o("RequestSender"),l={onRequestTimeout:function(){},onTransportError:function(){},onReceiveResponse:function(){},onAuthenticated:function(){}};e.exports=function(){function e(t,n,r){for(var o in function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._ua=t,this._eventHandlers=r,this._method=n.method,this._request=n,this._auth=null,this._challenged=!1,this._staled=!1,l)Object.prototype.hasOwnProperty.call(l,o)&&(this._eventHandlers[o]||(this._eventHandlers[o]=l[o]));t.status!==t.C.STATUS_USER_CLOSED||this._method===i.BYE&&this._method===i.ACK||this._eventHandlers.onTransportError()}var t,n,o;return t=e,(n=[{key:"send",value:function(){var e=this,t={onRequestTimeout:function(){e._eventHandlers.onRequestTimeout()},onTransportError:function(){e._eventHandlers.onTransportError()},onReceiveResponse:function(t){e._receiveResponse(t)}};switch(this._method){case"INVITE":this.clientTransaction=new u.InviteClientTransaction(this._ua,this._ua.transport,this._request,t);break;case"ACK":this.clientTransaction=new u.AckClientTransaction(this._ua,this._ua.transport,this._request,t);break;default:this.clientTransaction=new u.NonInviteClientTransaction(this._ua,this._ua.transport,this._request,t)}this._ua._configuration.authorization_jwt&&this._request.setHeader("Authorization",this._ua._configuration.authorization_jwt),this.clientTransaction.send()}},{key:"_receiveResponse",value:function(e){var t,n,r=e.status_code;if(401!==r&&407!==r||null===this._ua.configuration.password&&null===this._ua.configuration.ha1)this._eventHandlers.onReceiveResponse(e);else{if(401===e.status_code?(t=e.parseHeader("www-authenticate"),n="authorization"):(t=e.parseHeader("proxy-authenticate"),n="proxy-authorization"),!t)return a.debug("".concat(e.status_code," with wrong or missing challenge, cannot authenticate")),void this._eventHandlers.onReceiveResponse(e);if(!this._challenged||!this._staled&&!0===t.stale){if(this._auth||(this._auth=new s({username:this._ua.configuration.authorization_user,password:this._ua.configuration.password,realm:this._ua.configuration.realm,ha1:this._ua.configuration.ha1})),!this._auth.authenticate(this._request,t))return void this._eventHandlers.onReceiveResponse(e);this._challenged=!0,this._ua.set("realm",this._auth.get("realm")),this._ua.set("ha1",this._auth.get("ha1")),t.stale&&(this._staled=!0),this._request=this._request.clone(),this._request.cseq+=1,this._request.setHeader("cseq","".concat(this._request.cseq," ").concat(this._method)),this._request.setHeader(n,this._auth.toString()),this._eventHandlers.onAuthenticated(this._request),this.send()}else this._eventHandlers.onReceiveResponse(e)}}}])&&r(t.prototype,n),o&&r(t,o),e}()},213:(e,t,n)=>{"use strict";function r(e){return 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},r(e)}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}function i(e,t){return i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},i(e,t)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=u(e);if(t){var i=u(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return function(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,n)}}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function a(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return l(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return l(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,u=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return s=e.done,e},e:function(e){u=!0,i=e},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw i}}}}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function h(e,t,n){return t&&f(e.prototype,t),n&&f(e,n),e}var d=n(363),p=n(510),_=n(349),v=n(137),m=n(47),y=n(561),g=new p("SIPMessage"),b=function(){function e(t,n,r,o,i,s){if(c(this,e),!t||!n||!r)return null;o=o||{},this.ua=r,this.headers={},this.method=t,this.ruri=n,this.body=s,this.extraHeaders=v.cloneArray(i),this.ua.configuration.extra_headers&&(this.extraHeaders=this.extraHeaders.concat(this.ua.configuration.extra_headers)),o.route_set?this.setHeader("route",o.route_set):r.configuration.use_preloaded_route&&this.setHeader("route","<".concat(r.transport.sip_uri,";lr>")),this.setHeader("via",""),this.setHeader("max-forwards",_.MAX_FORWARDS);var u=o.to_uri||n,a=o.to_tag?{tag:o.to_tag}:null,l=void 0!==o.to_display_name?o.to_display_name:null;this.to=new m(u,l,a),this.setHeader("to",this.to.toString());var f,h=o.from_uri||r.configuration.uri,d={tag:o.from_tag||v.newTag()};f=void 0!==o.from_display_name?o.from_display_name:r.configuration.display_name?r.configuration.display_name:null,this.from=new m(h,f,d),this.setHeader("from",this.from.toString());var p=o.call_id||r.configuration.jssip_id+v.createRandomToken(15);this.call_id=p,this.setHeader("call-id",p);var y=o.cseq||Math.floor(1e4*Math.random());this.cseq=y,this.setHeader("cseq","".concat(y," ").concat(t))}return h(e,[{key:"setHeader",value:function(e,t){for(var n=new RegExp("^\\s*".concat(e,"\\s*:"),"i"),r=0;r<this.extraHeaders.length;r++)n.test(this.extraHeaders[r])&&this.extraHeaders.splice(r,1);this.headers[v.headerize(e)]=Array.isArray(t)?t:[t]}},{key:"getHeader",value:function(e){var t=this.headers[v.headerize(e)];if(t){if(t[0])return t[0]}else{var n,r=new RegExp("^\\s*".concat(e,"\\s*:"),"i"),o=a(this.extraHeaders);try{for(o.s();!(n=o.n()).done;){var i=n.value;if(r.test(i))return i.substring(i.indexOf(":")+1).trim()}}catch(e){o.e(e)}finally{o.f()}}}},{key:"getHeaders",value:function(e){var t=this.headers[v.headerize(e)],n=[];if(t){var r,o=a(t);try{for(o.s();!(r=o.n()).done;){var i=r.value;n.push(i)}}catch(e){o.e(e)}finally{o.f()}return n}var s,u=new RegExp("^\\s*".concat(e,"\\s*:"),"i"),l=a(this.extraHeaders);try{for(l.s();!(s=l.n()).done;){var c=s.value;u.test(c)&&n.push(c.substring(c.indexOf(":")+1).trim())}}catch(e){l.e(e)}finally{l.f()}return n}},{key:"hasHeader",value:function(e){if(this.headers[v.headerize(e)])return!0;var t,n=new RegExp("^\\s*".concat(e,"\\s*:"),"i"),r=a(this.extraHeaders);try{for(r.s();!(t=r.n()).done;){var o=t.value;if(n.test(o))return!0}}catch(e){r.e(e)}finally{r.f()}return!1}},{key:"parseSDP",value:function(e){return!e&&this.sdp||(this.sdp=d.parse(this.body||"")),this.sdp}},{key:"toString",value:function(){var e="".concat(this.method," ").concat(this.ruri," SIP/2.0\r\n");for(var t in this.headers)if(Object.prototype.hasOwnProperty.call(this.headers,t)){var n,r=a(this.headers[t]);try{for(r.s();!(n=r.n()).done;){var o=n.value;e+="".concat(t,": ").concat(o,"\r\n")}}catch(e){r.e(e)}finally{r.f()}}var i,s=a(this.extraHeaders);try{for(s.s();!(i=s.n()).done;){var u=i.value;e+="".concat(u.trim(),"\r\n")}}catch(e){s.e(e)}finally{s.f()}var l=[];switch(this.method){case _.REGISTER:l.push("path","gruu");break;case _.INVITE:this.ua.configuration.session_timers&&l.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&l.push("gruu"),l.push("ice","replaces");break;case _.UPDATE:this.ua.configuration.session_timers&&l.push("timer"),l.push("ice")}l.push("outbound");var c=this.ua.configuration.user_agent||_.USER_AGENT;if(e+="Allow: ".concat(_.ALLOWED_METHODS,"\r\n"),e+="Supported: ".concat(l,"\r\n"),e+="User-Agent: ".concat(c,"\r\n"),this.body){var f=v.str_utf8_length(this.body);e+="Content-Length: ".concat(f,"\r\n\r\n"),e+=this.body}else e+="Content-Length: 0\r\n\r\n";return e}},{key:"clone",value:function(){var t=new e(this.method,this.ruri,this.ua);return Object.keys(this.headers).forEach((function(e){t.headers[e]=this.headers[e].slice()}),this),t.body=this.body,t.extraHeaders=v.cloneArray(this.extraHeaders),t.to=this.to,t.from=this.from,t.call_id=this.call_id,t.cseq=this.cseq,t}}]),e}(),T=function(e){o(n,e);var t=s(n);function n(e,r,o,i,s){var u;return c(this,n),(u=t.call(this,_.INVITE,e,r,o,i,s)).transaction=null,u}return h(n,[{key:"cancel",value:function(e){this.transaction.cancel(e)}},{key:"clone",value:function(){var e=new n(this.ruri,this.ua);return Object.keys(this.headers).forEach((function(t){e.headers[t]=this.headers[t].slice()}),this),e.body=this.body,e.extraHeaders=v.cloneArray(this.extraHeaders),e.to=this.to,e.from=this.from,e.call_id=this.call_id,e.cseq=this.cseq,e.transaction=this.transaction,e}}]),n}(b),S=function(){function e(){c(this,e),this.data=null,this.headers=null,this.method=null,this.via=null,this.via_branch=null,this.call_id=null,this.cseq=null,this.from=null,this.from_tag=null,this.to=null,this.to_tag=null,this.body=null,this.sdp=null}return h(e,[{key:"addHeader",value:function(e,t){var n={raw:t};e=v.headerize(e),this.headers[e]?this.headers[e].push(n):this.headers[e]=[n]}},{key:"getHeader",value:function(e){var t=this.headers[v.headerize(e)];if(t)return t[0]?t[0].raw:void 0}},{key:"getHeaders",value:function(e){var t=this.headers[v.headerize(e)],n=[];if(!t)return[];var r,o=a(t);try{for(o.s();!(r=o.n()).done;){var i=r.value;n.push(i.raw)}}catch(e){o.e(e)}finally{o.f()}return n}},{key:"hasHeader",value:function(e){return!!this.headers[v.headerize(e)]}},{key:"parseHeader",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(e=v.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 o=y.parse(r,e.replace(/-/g,"_"));return-1===o?(this.headers[e].splice(t,1),void g.debug('error parsing "'.concat(e,'" header field with value "').concat(r,'"'))):(n.parsed=o,o)}g.debug('not so many "'.concat(e,'" headers present'))}else g.debug('header "'.concat(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[v.headerize(e)]=[n]}},{key:"parseSDP",value:function(e){return!e&&this.sdp||(this.sdp=d.parse(this.body||"")),this.sdp}},{key:"toString",value:function(){return this.data}}]),e}(),E=function(e){o(n,e);var t=s(n);function n(e){var r;return c(this,n),(r=t.call(this)).ua=e,r.headers={},r.ruri=null,r.transport=null,r.server_transaction=null,r}return h(n,[{key:"reply",value:function(e,t,n,r,o,i){var s=[],u=this.getHeader("To");if(t=t||null,!(e=e||null)||e<100||e>699)throw new TypeError("Invalid status_code: ".concat(e));if(t&&"string"!=typeof t&&!(t instanceof String))throw new TypeError("Invalid reason_phrase: ".concat(t));t=t||_.REASON_PHRASE[e]||"",n=v.cloneArray(n),this.ua.configuration.extra_headers&&(n=n.concat(this.ua.configuration.extra_headers));var l="SIP/2.0 ".concat(e," ").concat(t,"\r\n");if(this.method===_.INVITE&&e>100&&e<=200){var c,f=a(this.getHeaders("record-route"));try{for(f.s();!(c=f.n()).done;){var h=c.value;l+="Record-Route: ".concat(h,"\r\n")}}catch(e){f.e(e)}finally{f.f()}}var d,p=a(this.getHeaders("via"));try{for(p.s();!(d=p.n()).done;){var m=d.value;l+="Via: ".concat(m,"\r\n")}}catch(e){p.e(e)}finally{p.f()}!this.to_tag&&e>100?u+=";tag=".concat(v.newTag()):this.to_tag&&!this.s("to").hasParam("tag")&&(u+=";tag=".concat(this.to_tag)),l+="To: ".concat(u,"\r\n"),l+="From: ".concat(this.getHeader("From"),"\r\n"),l+="Call-ID: ".concat(this.call_id,"\r\n"),l+="CSeq: ".concat(this.cseq," ").concat(this.method,"\r\n");var y,g=a(n);try{for(g.s();!(y=g.n()).done;){var b=y.value;l+="".concat(b.trim(),"\r\n")}}catch(e){g.e(e)}finally{g.f()}switch(this.method){case _.INVITE:this.ua.configuration.session_timers&&s.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&s.push("gruu"),s.push("ice","replaces");break;case _.UPDATE:this.ua.configuration.session_timers&&s.push("timer"),r&&s.push("ice"),s.push("replaces")}if(s.push("outbound"),this.method===_.OPTIONS?(l+="Allow: ".concat(_.ALLOWED_METHODS,"\r\n"),l+="Accept: ".concat(_.ACCEPTED_BODY_TYPES,"\r\n")):405===e?l+="Allow: ".concat(_.ALLOWED_METHODS,"\r\n"):415===e&&(l+="Accept: ".concat(_.ACCEPTED_BODY_TYPES,"\r\n")),l+="Supported: ".concat(s,"\r\n"),r){var T=v.str_utf8_length(r);l+="Content-Type: application/sdp\r\n",l+="Content-Length: ".concat(T,"\r\n\r\n"),l+=r}else l+="Content-Length: ".concat(0,"\r\n\r\n");this.server_transaction.receiveResponse(e,l,o,i)}},{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: ".concat(e));if(t&&"string"!=typeof t&&!(t instanceof String))throw new TypeError("Invalid reason_phrase: ".concat(t));t=t||_.REASON_PHRASE[e]||"";var r,o="SIP/2.0 ".concat(e," ").concat(t,"\r\n"),i=a(n);try{for(i.s();!(r=i.n()).done;){var s=r.value;o+="Via: ".concat(s,"\r\n")}}catch(e){i.e(e)}finally{i.f()}var u=this.getHeader("To");if(!this.to_tag&&e>100?u+=";tag=".concat(v.newTag()):this.to_tag&&!this.s("to").hasParam("tag")&&(u+=";tag=".concat(this.to_tag)),o+="To: ".concat(u,"\r\n"),o+="From: ".concat(this.getHeader("From"),"\r\n"),o+="Call-ID: ".concat(this.call_id,"\r\n"),o+="CSeq: ".concat(this.cseq," ").concat(this.method,"\r\n"),this.ua.configuration.extra_headers){var l,c=a(this.ua.configuration.extra_headers);try{for(c.s();!(l=c.n()).done;){var f=l.value;o+="".concat(f.trim(),"\r\n")}}catch(e){c.e(e)}finally{c.f()}}o+="Content-Length: ".concat(0,"\r\n\r\n"),this.transport.send(o)}}]),n}(S),C=function(e){o(n,e);var t=s(n);function n(){var e;return c(this,n),(e=t.call(this)).headers={},e.status_code=null,e.reason_phrase=null,e}return n}(S);e.exports={OutgoingRequest:b,InitialOutgoingInviteRequest:T,IncomingRequest:E,IncomingResponse:C}},627:(e,t,n)=>{"use strict";var r=n(510),o=n(137),i=n(561),s=new r("Socket");
3
+ /**
4
+ * Interface documentation: https://jssip.net/documentation/$last_version/api/socket/
5
+ *
6
+ * interface Socket {
7
+ * attribute String via_transport
8
+ * attribute String url
9
+ * attribute String sip_uri
10
+ *
11
+ * method connect();
12
+ * method disconnect();
13
+ * method send(data);
14
+ *
15
+ * attribute EventHandler onconnect
16
+ * attribute EventHandler ondisconnect
17
+ * attribute EventHandler ondata
18
+ * }
19
+ *
20
+ */
21
+ t.isSocket=function(e){if(Array.isArray(e))return!1;if(void 0===e)return s.warn("undefined JsSIP.Socket instance"),!1;try{if(!o.isString(e.url))throw s.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!o.isString(e.via_transport))throw s.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(-1===i.parse(e.sip_uri,"SIP_URI"))throw s.warn("missing or invalid JsSIP.Socket sip_uri property"),new Error("missing or invalid JsSIP.Socket sip_uri property")}catch(e){return!1}try{["connect","disconnect","send"].forEach((function(t){if(!o.isFunction(e[t]))throw s.warn("missing or invalid JsSIP.Socket method: ".concat(t)),new Error("Missing or invalid JsSIP.Socket method: ".concat(t))}))}catch(e){return!1}return!0}},672:e=>{"use strict";var t=500;e.exports={T1:t,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}},143:(e,t,n)=>{"use strict";function r(e){return 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},r(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}function a(e,t){return a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},a(e,t)}function l(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=f(e);if(t){var i=f(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return function(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;return c(e)}(this,n)}}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function f(e){return f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},f(e)}var h=n(7).EventEmitter,d=n(510),p=n(349),_=n(213),v=n(672),m=new d("NonInviteClientTransaction"),y=new d("InviteClientTransaction"),g=new d("AckClientTransaction"),b=new d("NonInviteServerTransaction"),T=new d("InviteServerTransaction"),S={STATUS_TRYING:1,STATUS_PROCEEDING:2,STATUS_CALLING:3,STATUS_ACCEPTED:4,STATUS_COMPLETED:5,STATUS_TERMINATED:6,STATUS_CONFIRMED:7,NON_INVITE_CLIENT:"nict",NON_INVITE_SERVER:"nist",INVITE_CLIENT:"ict",INVITE_SERVER:"ist"},E=function(e){u(n,e);var t=l(n);function n(e,r,i,s){var u;o(this,n),(u=t.call(this)).type=S.NON_INVITE_CLIENT,u.id="z9hG4bK".concat(Math.floor(1e7*Math.random())),u.ua=e,u.transport=r,u.request=i,u.eventHandlers=s;var a="SIP/2.0/".concat(r.via_transport);return a+=" ".concat(e.configuration.via_host,";branch=").concat(u.id),u.request.setHeader("via",a),u.ua.newTransaction(c(u)),u}return s(n,[{key:"stateChanged",value:function(e){this.state=e,this.emit("stateChanged")}},{key:"send",value:function(){var e=this;this.stateChanged(S.STATUS_TRYING),this.F=setTimeout((function(){e.timer_F()}),v.TIMER_F),this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){m.debug("transport error occurred, deleting transaction ".concat(this.id)),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(S.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}},{key:"timer_F",value:function(){m.debug("Timer F expired for transaction ".concat(this.id)),this.stateChanged(S.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}},{key:"timer_K",value:function(){this.stateChanged(S.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"receiveResponse",value:function(e){var t=this,n=e.status_code;if(n<200)switch(this.state){case S.STATUS_TRYING:case S.STATUS_PROCEEDING:this.stateChanged(S.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(e)}else switch(this.state){case S.STATUS_TRYING:case S.STATUS_PROCEEDING:this.stateChanged(S.STATUS_COMPLETED),clearTimeout(this.F),408===n?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(e),this.K=setTimeout((function(){t.timer_K()}),v.TIMER_K)}}},{key:"C",get:function(){return S}}]),n}(h),C=function(e){u(n,e);var t=l(n);function n(e,r,i,s){var u;o(this,n),(u=t.call(this)).type=S.INVITE_CLIENT,u.id="z9hG4bK".concat(Math.floor(1e7*Math.random())),u.ua=e,u.transport=r,u.request=i,u.eventHandlers=s,i.transaction=c(u);var a="SIP/2.0/".concat(r.via_transport);return a+=" ".concat(e.configuration.via_host,";branch=").concat(u.id),u.request.setHeader("via",a),u.ua.newTransaction(c(u)),u}return s(n,[{key:"stateChanged",value:function(e){this.state=e,this.emit("stateChanged")}},{key:"send",value:function(){var e=this;this.stateChanged(S.STATUS_CALLING),this.B=setTimeout((function(){e.timer_B()}),v.TIMER_B),this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==S.STATUS_ACCEPTED&&(y.debug("transport error occurred, deleting transaction ".concat(this.id)),this.eventHandlers.onTransportError()),this.stateChanged(S.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_M",value:function(){y.debug("Timer M expired for transaction ".concat(this.id)),this.state===S.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(S.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"timer_B",value:function(){y.debug("Timer B expired for transaction ".concat(this.id)),this.state===S.STATUS_CALLING&&(this.stateChanged(S.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}},{key:"timer_D",value:function(){y.debug("Timer D expired for transaction ".concat(this.id)),clearTimeout(this.B),this.stateChanged(S.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"sendACK",value:function(e){var t=this,n=new _.OutgoingRequest(p.ACK,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});n.setHeader("from",this.request.getHeader("from")),n.setHeader("via",this.request.getHeader("via")),n.setHeader("to",e.getHeader("to")),this.D=setTimeout((function(){t.timer_D()}),v.TIMER_D),this.transport.send(n)}},{key:"cancel",value:function(e){if(this.state===S.STATUS_PROCEEDING){var t=new _.OutgoingRequest(p.CANCEL,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});t.setHeader("from",this.request.getHeader("from")),t.setHeader("via",this.request.getHeader("via")),t.setHeader("to",this.request.getHeader("to")),e&&t.setHeader("reason",e),this.transport.send(t)}}},{key:"receiveResponse",value:function(e){var t=this,n=e.status_code;if(n>=100&&n<=199)switch(this.state){case S.STATUS_CALLING:this.stateChanged(S.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(e);break;case S.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(e)}else if(n>=200&&n<=299)switch(this.state){case S.STATUS_CALLING:case S.STATUS_PROCEEDING:this.stateChanged(S.STATUS_ACCEPTED),this.M=setTimeout((function(){t.timer_M()}),v.TIMER_M),this.eventHandlers.onReceiveResponse(e);break;case S.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(e)}else if(n>=300&&n<=699)switch(this.state){case S.STATUS_CALLING:case S.STATUS_PROCEEDING:this.stateChanged(S.STATUS_COMPLETED),this.sendACK(e),this.eventHandlers.onReceiveResponse(e);break;case S.STATUS_COMPLETED:this.sendACK(e)}}},{key:"C",get:function(){return S}}]),n}(h),w=function(e){u(n,e);var t=l(n);function n(e,r,i,s){var u;o(this,n),(u=t.call(this)).id="z9hG4bK".concat(Math.floor(1e7*Math.random())),u.transport=r,u.request=i,u.eventHandlers=s;var a="SIP/2.0/".concat(r.via_transport);return a+=" ".concat(e.configuration.via_host,";branch=").concat(u.id),u.request.setHeader("via",a),u}return s(n,[{key:"send",value:function(){this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){g.debug("transport error occurred for transaction ".concat(this.id)),this.eventHandlers.onTransportError()}},{key:"C",get:function(){return S}}]),n}(h),A=function(e){u(n,e);var t=l(n);function n(e,r,i){var s;return o(this,n),(s=t.call(this)).type=S.NON_INVITE_SERVER,s.id=i.via_branch,s.ua=e,s.transport=r,s.request=i,s.last_response="",i.server_transaction=c(s),s.state=S.STATUS_TRYING,e.newTransaction(c(s)),s}return s(n,[{key:"stateChanged",value:function(e){this.state=e,this.emit("stateChanged")}},{key:"timer_J",value:function(){b.debug("Timer J expired for transaction ".concat(this.id)),this.stateChanged(S.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,b.debug("transport error occurred, deleting transaction ".concat(this.id)),clearTimeout(this.J),this.stateChanged(S.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"receiveResponse",value:function(e,t,n,r){var o=this;if(100===e)switch(this.state){case S.STATUS_TRYING:this.stateChanged(S.STATUS_PROCEEDING),this.transport.send(t)||this.onTransportError();break;case S.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 S.STATUS_TRYING:case S.STATUS_PROCEEDING:this.stateChanged(S.STATUS_COMPLETED),this.last_response=t,this.J=setTimeout((function(){o.timer_J()}),v.TIMER_J),this.transport.send(t)?n&&n():(this.onTransportError(),r&&r())}}},{key:"C",get:function(){return S}}]),n}(h),R=function(e){u(n,e);var t=l(n);function n(e,r,i){var s;return o(this,n),(s=t.call(this)).type=S.INVITE_SERVER,s.id=i.via_branch,s.ua=e,s.transport=r,s.request=i,s.last_response="",i.server_transaction=c(s),s.state=S.STATUS_PROCEEDING,e.newTransaction(c(s)),s.resendProvisionalTimer=null,i.reply(100),s}return s(n,[{key:"stateChanged",value:function(e){this.state=e,this.emit("stateChanged")}},{key:"timer_H",value:function(){T.debug("Timer H expired for transaction ".concat(this.id)),this.state===S.STATUS_COMPLETED&&T.debug("ACK not received, dialog will be terminated"),this.stateChanged(S.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_I",value:function(){this.stateChanged(S.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_L",value:function(){T.debug("Timer L expired for transaction ".concat(this.id)),this.state===S.STATUS_ACCEPTED&&(this.stateChanged(S.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,T.debug("transport error occurred, deleting transaction ".concat(this.id)),null!==this.resendProvisionalTimer&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),clearTimeout(this.L),clearTimeout(this.H),clearTimeout(this.I),this.stateChanged(S.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 o=this;if(e>=100&&e<=199&&this.state===S.STATUS_PROCEEDING)this.transport.send(t)||this.onTransportError(),this.last_response=t;if(e>100&&e<=199&&this.state===S.STATUS_PROCEEDING)null===this.resendProvisionalTimer&&(this.resendProvisionalTimer=setInterval((function(){o.resend_provisional()}),v.PROVISIONAL_RESPONSE_INTERVAL));else if(e>=200&&e<=299)switch(this.state){case S.STATUS_PROCEEDING:this.stateChanged(S.STATUS_ACCEPTED),this.last_response=t,this.L=setTimeout((function(){o.timer_L()}),v.TIMER_L),null!==this.resendProvisionalTimer&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case S.STATUS_ACCEPTED:this.transport.send(t)?n&&n():(this.onTransportError(),r&&r())}else if(e>=300&&e<=699&&this.state===S.STATUS_PROCEEDING)null!==this.resendProvisionalTimer&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(t)?(this.stateChanged(S.STATUS_COMPLETED),this.H=setTimeout((function(){o.timer_H()}),v.TIMER_H),n&&n()):(this.onTransportError(),r&&r())}},{key:"C",get:function(){return S}}]),n}(h);e.exports={C:S,NonInviteClientTransaction:E,InviteClientTransaction:C,AckClientTransaction:w,NonInviteServerTransaction:A,InviteServerTransaction:R,checkTransaction:function(e,t){var n,r=e._transactions;switch(t.method){case p.INVITE:if(n=r.ist[t.via_branch]){if(n.state===S.STATUS_PROCEEDING)n.transport.send(n.last_response);return!0}break;case p.ACK:if(!(n=r.ist[t.via_branch]))return!1;if(n.state===S.STATUS_ACCEPTED)return!1;if(n.state===S.STATUS_COMPLETED)return n.state=S.STATUS_CONFIRMED,n.I=setTimeout((function(){n.timer_I()}),v.TIMER_I),!0;break;case p.CANCEL:return(n=r.ist[t.via_branch])?(t.reply_sl(200),n.state!==S.STATUS_PROCEEDING):(t.reply_sl(481),!0);default:if(n=r.nist[t.via_branch]){switch(n.state){case S.STATUS_TRYING:break;case S.STATUS_PROCEEDING:case S.STATUS_COMPLETED:n.transport.send(n.last_response)}return!0}}}}},13:(e,t,n)=>{"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var o=n(510),i=n(627),s=n(349),u=new o("Transport"),a={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:s.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:s.CONNECTION_RECOVERY_MAX_INTERVAL}};e.exports=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a.recovery_options;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),u.debug("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;// It seems that TextDecoder is not available in some versions of React-Native.
22
+ try{this.textDecoder=new TextDecoder("utf8")}catch(e){u.warn("cannot use TextDecoder: ".concat(e))}if(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()}var t,n,o;return t=e,(n=[{key:"connect",value:function(){u.debug("connect()"),this.isConnected()?u.debug("Transport is already connected"):this.isConnecting()?u.debug("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(){u.debug("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({socket:this.socket,error:!1})}},{key:"send",value:function(e){if(u.debug("send()"),!this.isConnected())return u.warn("unable to send message, transport is not connected"),!1;var t=e.toString();return u.debug("sending message:\n\n".concat(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);t<this.recovery_options.min_interval?t=this.recovery_options.min_interval:t>this.recovery_options.max_interval&&(t=this.recovery_options.max_interval),u.debug("reconnection attempt: ".concat(this.recover_attempts,". next connection attempt in ").concat(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\r\n"!==e)if("\r\n"!==e){if("string"!=typeof e){try{e=this.textDecoder?this.textDecoder.decode(e):String.fromCharCode.apply(null,new Uint8Array(e))}catch(e){return void u.debug("received binary message failed to be converted into string, message discarded")}u.debug("received binary message:\n\n".concat(e,"\n"))}else u.debug("received text message:\n\n".concat(e,"\n"));this.ondata({transport:this,message:e})}else u.debug("received message with CRLF Keep Alive response");else{u.debug("received message with double-CRLF Keep Alive request");try{this.socket.send("\r\n")}catch(e){u.warn("error sending Keep Alive response: ".concat(e))}}}},{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}}])&&r(t.prototype,n),o&&r(t,o),e}()},544:(e,t,n)=>{"use strict";function r(e){return 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},r(e)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}function s(e,t){return s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},s(e,t)}function u(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=l(e);if(t){var i=l(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return function(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;return a(e)}(this,n)}}function a(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}var c=n(7).EventEmitter,f=n(510),h=n(349),d=n(680),p=n(395),_=n(603),v=n(6),m=n(143),y=n(13),g=n(137),b=n(956),T=n(670),S=n(725),E=n(213),C=n(46),w=n(700),A=new f("UA"),R={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2};function I(e){this.emit("connecting",e)}function O(e){this._status!==R.STATUS_USER_CLOSED&&(this._status=R.STATUS_READY,this._error=null,this.emit("connected",e),this._dynConfiguration.register&&this._registrator.register())}function k(e){for(var t=0,n=["nict","ict","nist","ist"];t<n.length;t++){var r=n[t];for(var o in this._transactions[r])Object.prototype.hasOwnProperty.call(this._transactions[r],o)&&this._transactions[r][o].onTransportError()}this.emit("disconnected",e),this._registrator.onTransportClosed(),this._status!==R.STATUS_USER_CLOSED&&(this._status=R.STATUS_NOT_READY,this._error=R.NETWORK_ERROR)}function N(e){var t=e.transport,n=e.message;if((n=S.parseMessage(n,this))&&!(this._status===R.STATUS_USER_CLOSED&&n instanceof E.IncomingRequest)&&C(n,this,t))if(n instanceof E.IncomingRequest)n.transport=t,this.receiveRequest(n);else if(n instanceof E.IncomingResponse){var r;switch(n.method){case h.INVITE:(r=this._transactions.ict[n.via_branch])&&r.receiveResponse(n);break;case h.ACK:break;default:(r=this._transactions.nict[n.via_branch])&&r.receiveResponse(n)}}}e.exports=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(n,e);var t=u(n);function n(e){var r;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),A.debug("new() [configuration:%o]",e),(r=t.call(this))._cache={credentials:{}},r._configuration=Object.assign({},w.settings),r._dynConfiguration={},r._dialogs={},r._applicants={},r._sessions={},r._transport=null,r._contact=null,r._status=R.STATUS_INIT,r._error=null,r._transactions={nist:{},nict:{},ist:{},ict:{}},r._data={},r._closeTimer=null,void 0===e)throw new TypeError("Not enough arguments");try{r._loadConfig(e)}catch(e){throw r._status=R.STATUS_NOT_READY,r._error=R.CONFIGURATION_ERROR,e}return r._registrator=new d(a(r)),r}return i(n,null,[{key:"C",get:function(){return R}}]),i(n,[{key:"start",value:function(){A.debug("start()"),this._status===R.STATUS_INIT?this._transport.connect():this._status===R.STATUS_USER_CLOSED?(A.debug("restarting UA"),null!==this._closeTimer&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=R.STATUS_INIT,this._transport.connect()):this._status===R.STATUS_READY?A.debug("UA is in READY status, not restarted"):A.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this._dynConfiguration.register=this._configuration.register}},{key:"register",value:function(){A.debug("register()"),this._dynConfiguration.register=!0,this._registrator.register()}},{key:"unregister",value:function(e){A.debug("unregister()"),this._dynConfiguration.register=!1,this._registrator.unregister(e)}},{key:"registrator",value:function(){return this._registrator}},{key:"isRegistered",value:function(){return this._registrator.registered}},{key:"isConnected",value:function(){return this._transport.isConnected()}},{key:"call",value:function(e,t){A.debug("call()");var n=new p(this);return n.connect(e,t),n}},{key:"sendMessage",value:function(e,t,n){A.debug("sendMessage()");var r=new _(this);return r.send(e,t,n),r}},{key:"sendOptions",value:function(e,t,n){A.debug("sendOptions()");var r=new v(this);return r.send(e,t,n),r}},{key:"terminateSessions",value:function(e){for(var t in A.debug("terminateSessions()"),this._sessions)this._sessions[t].isEnded()||this._sessions[t].terminate(e)}},{key:"stop",value:function(){var e=this;if(A.debug("stop()"),this._dynConfiguration={},this._status!==R.STATUS_USER_CLOSED){this._registrator.close();var t=Object.keys(this._sessions).length;for(var n in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,n)){A.debug("closing session ".concat(n));try{this._sessions[n].terminate()}catch(e){}}for(var r in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,r))try{this._applicants[r].close()}catch(e){}this._status=R.STATUS_USER_CLOSED,0===Object.keys(this._transactions.nict).length+Object.keys(this._transactions.nist).length+Object.keys(this._transactions.ict).length+Object.keys(this._transactions.ist).length&&0===t?this._transport.disconnect():this._closeTimer=setTimeout((function(){e._closeTimer=null,e._transport.disconnect()}),2e3)}else A.debug("UA already closed")}},{key:"normalizeTarget",value:function(e){return g.normalizeTarget(e,this._configuration.hostport_params)}},{key:"get",value:function(e){switch(e){case"authorization_user":return this._configuration.authorization_user;case"realm":return this._configuration.realm;case"ha1":return this._configuration.ha1;case"authorization_jwt":return this._configuration.authorization_jwt;default:return void A.warn('get() | cannot get "%s" parameter in runtime',e)}}},{key:"set",value:function(e,t){switch(e){case"authorization_user":this._configuration.authorization_user=String(t);break;case"password":this._configuration.password=String(t);break;case"realm":this._configuration.realm=String(t);break;case"ha1":this._configuration.ha1=String(t),this._configuration.password=null;break;case"authorization_jwt":this._configuration.authorization_jwt=String(t);break;case"display_name":this._configuration.display_name=t;break;case"extra_headers":this._configuration.extra_headers=t;break;default:return A.warn('set() | cannot set "%s" parameter in runtime',e),!1}return!0}},{key:"newTransaction",value:function(e){this._transactions[e.type][e.id]=e,this.emit("newTransaction",{transaction:e})}},{key:"destroyTransaction",value:function(e){delete this._transactions[e.type][e.id],this.emit("transactionDestroyed",{transaction:e})}},{key:"newDialog",value:function(e){this._dialogs[e.id]=e}},{key:"destroyDialog",value:function(e){delete this._dialogs[e.id]}},{key:"newMessage",value:function(e,t){this._applicants[e]=e,this.emit("newMessage",t)}},{key:"newOptions",value:function(e,t){this._applicants[e]=e,this.emit("newOptions",t)}},{key:"destroyMessage",value:function(e){delete this._applicants[e]}},{key:"newRTCSession",value:function(e,t){this._sessions[e.id]=e,this.emit("newRTCSession",t)}},{key:"destroyRTCSession",value:function(e){delete this._sessions[e.id]}},{key:"registered",value:function(e){this.emit("registered",e)}},{key:"unregistered",value:function(e){this.emit("unregistered",e)}},{key:"registrationFailed",value:function(e){this.emit("registrationFailed",e)}},{key:"receiveRequest",value:function(e){var t=e.method;if(e.ruri.user!==this._configuration.uri.user&&e.ruri.user!==this._contact.uri.user)return A.debug("Request-URI does not point to us"),void(e.method!==h.ACK&&e.reply_sl(404));if(e.ruri.scheme!==h.SIPS){if(!m.checkTransaction(this,e)){if(t===h.INVITE?new m.InviteServerTransaction(this,this._transport,e):t!==h.ACK&&t!==h.CANCEL&&new m.NonInviteServerTransaction(this,this._transport,e),t===h.OPTIONS){if(0===this.listeners("newOptions").length)return void e.reply(200);new v(this).init_incoming(e)}else if(t===h.MESSAGE){if(0===this.listeners("newMessage").length)return void e.reply(405);new _(this).init_incoming(e)}else if(t===h.INVITE&&!e.to_tag&&0===this.listeners("newRTCSession").length)return void e.reply(405);var n,r;if(e.to_tag)(n=this._findDialog(e.call_id,e.from_tag,e.to_tag))?n.receiveRequest(e):t===h.NOTIFY?(r=this._findSession(e))?r.receiveRequest(e):(A.debug("received NOTIFY request for a non existent subscription"),e.reply(481,"Subscription does not exist")):t!==h.ACK&&e.reply(481);else switch(t){case h.INVITE:if(window.RTCPeerConnection)if(e.hasHeader("replaces")){var o=e.replaces;(n=this._findDialog(o.call_id,o.from_tag,o.to_tag))?(r=n.owner).isEnded()?e.reply(603):r.receiveRequest(e):e.reply(481)}else(r=new p(this)).init_incoming(e);else A.warn("INVITE received but WebRTC is not supported"),e.reply(488);break;case h.BYE:e.reply(481);break;case h.CANCEL:(r=this._findSession(e))?r.receiveRequest(e):A.debug("received CANCEL request for a non existent session");break;case h.ACK:break;case h.NOTIFY:this.emit("sipEvent",{event:e.event,request:e}),e.reply(200);break;default:e.reply(405)}}}else e.reply_sl(416)}},{key:"_findSession",value:function(e){var t=e.call_id,n=e.from_tag,r=e.to_tag,o=t+n,i=this._sessions[o],s=t+r,u=this._sessions[s];return i||(u||null)}},{key:"_findDialog",value:function(e,t,n){var r=e+t+n,o=this._dialogs[r];return o||(r=e+n+t,(o=this._dialogs[r])||null)}},{key:"_loadConfig",value:function(e){try{w.load(this._configuration,e)}catch(e){throw e}0===this._configuration.display_name&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=g.newUUID()),this._configuration.jssip_id=g.createRandomToken(5);var t=this._configuration.uri.clone();t.user=null,this._configuration.hostport_params=t.toString().replace(/^sip:/i,"");try{this._transport=new y(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=I.bind(this),this._transport.onconnect=O.bind(this),this._transport.ondisconnect=k.bind(this),this._transport.ondata=N.bind(this)}catch(e){throw A.warn(e),new b.ConfigurationError("sockets",this._configuration.sockets)}if(delete this._configuration.sockets,this._configuration.authorization_user||(this._configuration.authorization_user=this._configuration.uri.user),!this._configuration.registrar_server){var n=this._configuration.uri.clone();n.user=null,n.clearParams(),n.clearHeaders(),this._configuration.registrar_server=n}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new T("sip",g.createRandomToken(8),this._configuration.via_host,null,{transport:"ws"}),this._contact={pub_gruu:null,temp_gruu:null,uri:this._configuration.contact_uri,toString:function(){var e=arguments.length>0&&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=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register","extra_headers"];for(var o in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,o)&&(-1!==r.indexOf(o)?Object.defineProperty(this._configuration,o,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,o,{writable:!1,configurable:!1}));for(var i in A.debug("configuration parameters after validation:"),this._configuration)if(Object.prototype.hasOwnProperty.call(w.settings,i))switch(i){case"uri":case"registrar_server":A.debug("- ".concat(i,": ").concat(this._configuration[i]));break;case"password":case"ha1":case"authorization_jwt":A.debug("- ".concat(i,": NOT SHOWN"));break;default:A.debug("- ".concat(i,": ").concat(JSON.stringify(this._configuration[i])))}}},{key:"C",get:function(){return R}},{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}}]),n}(c)},670:(e,t,n)=>{"use strict";function r(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,u=!0,a=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return u=e.done,e},e:function(e){a=!0,s=e},f:function(){try{u||null==n.return||n.return()}finally{if(a)throw s}}}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}var u=n(349),a=n(137),l=n(561);e.exports=function(){function e(t,n,r,o){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},s=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');for(var a in this._parameters={},this._headers={},this._scheme=t||u.SIP,this._user=n,this._host=r,this._port=o,i)Object.prototype.hasOwnProperty.call(i,a)&&this.setParam(a,i[a]);for(var l in s)Object.prototype.hasOwnProperty.call(s,l)&&this.setHeader(l,s[l])}return s(e,null,[{key:"parse",value:function(e){return-1!==(e=l.parse(e,"SIP_URI"))?e:void 0}}]),s(e,[{key:"setParam",value:function(e,t){e&&(this._parameters[e.toLowerCase()]=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[a.headerize(e)]=Array.isArray(t)?t:[t]}},{key:"getHeader",value:function(e){if(e)return this._headers[a.headerize(e)]}},{key:"hasHeader",value:function(e){if(e)return!!this._headers.hasOwnProperty(a.headerize(e))}},{key:"deleteHeader",value:function(e){if(e=a.headerize(e),this._headers.hasOwnProperty(e)){var t=this._headers[e];return delete this._headers[e],t}}},{key:"clearHeaders",value:function(){this._headers={}}},{key:"clone",value:function(){return new e(this._scheme,this._user,this._host,this._port,JSON.parse(JSON.stringify(this._parameters)),JSON.parse(JSON.stringify(this._headers)))}},{key:"toString",value:function(){var e=[],t="".concat(this._scheme,":");for(var n in this._user&&(t+="".concat(a.escapeUser(this._user),"@")),t+=this._host,(this._port||0===this._port)&&(t+=":".concat(this._port)),this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,n)&&(t+=";".concat(n),null!==this._parameters[n]&&(t+="=".concat(this._parameters[n])));for(var o in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,o)){var i,s=r(this._headers[o]);try{for(s.s();!(i=s.n()).done;){var u=i.value;e.push("".concat(o,"=").concat(u))}}catch(e){s.e(e)}finally{s.f()}}return e.length>0&&(t+="?".concat(e.join("&"))),t}},{key:"toAor",value:function(e){var t="".concat(this._scheme,":");return this._user&&(t+="".concat(a.escapeUser(this._user),"@")),t+=this._host,e&&(this._port||0===this._port)&&(t+=":".concat(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}()},137:(e,t,n)=>{"use strict";function r(e){return 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},r(e)}function o(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,u=!0,a=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return u=e.done,e},e:function(e){a=!0,s=e},f:function(){try{u||null==n.return||n.return()}finally{if(a)throw s}}}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var s=n(349),u=n(670),a=n(561);t.str_utf8_length=function(e){return unescape(encodeURIComponent(e)).length};var l=t.isFunction=function(e){return void 0!==e&&"[object Function]"===Object.prototype.toString.call(e)};t.isString=function(e){return void 0!==e&&"[object String]"===Object.prototype.toString.call(e)},t.isDecimal=function(e){return!isNaN(e)&&parseFloat(e)===parseInt(e,10)},t.isEmpty=function(e){return null===e||""===e||void 0===e||Array.isArray(e)&&0===e.length||"number"==typeof e&&isNaN(e)},t.hasMethods=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];for(var o=0,i=n;o<i.length;o++){var s=i[o];if(l(e[s]))return!1}return!0};var c=t.createRandomToken=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:32,r="";for(t=0;t<e;t++)r+=(Math.random()*n|0).toString(n);return r};t.newTag=function(){return c(10)},t.newUUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},t.hostType=function(e){if(e)return-1!==(e=a.parse(e,"host"))?e.host_type:void 0};var f=t.escapeUser=function(e){return encodeURIComponent(decodeURIComponent(e)).replace(/%3A/gi,":").replace(/%2B/gi,"+").replace(/%3F/gi,"?").replace(/%2F/gi,"/")};t.normalizeTarget=function(e,t){if(e){if(e instanceof u)return e;if("string"==typeof e){var n,r,o,i=e.split("@");switch(i.length){case 1:if(!t)return;n=e,r=t;break;case 2:n=i[0],r=i[1];break;default:n=i.slice(0,i.length-1).join("@"),r=i[i.length-1]}return n=n.replace(/^(sips?|tel):/i,""),/^[-.()]*\+?[0-9\-.()]+$/.test(n)&&(n=n.replace(/[-.()]/g,"")),e="".concat(s.SIP,":").concat(f(n),"@").concat(r),(o=u.parse(e))?o:void 0}}else;},t.headerize=function(e){var t,n={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},r=e.toLowerCase().replace(/_/g,"-").split("-"),o="",i=r.length;for(t=0;t<i;t++)0!==t&&(o+="-"),o+=r[t].charAt(0).toUpperCase()+r[t].substring(1);return n[o]&&(o=n[o]),o},t.sipErrorCause=function(e){for(var t in s.SIP_ERROR_CAUSES)if(-1!==s.SIP_ERROR_CAUSES[t].indexOf(e))return s.causes[t];return s.causes.SIP_FAILURE_CODE},t.getRandomTestNetIP=function(){return"192.0.2.".concat((e=1,t=254,Math.floor(Math.random()*(t-e+1)+e)));var e,t},t.calculateMD5=function(e){function t(e,t){return e<<t|e>>>32-t}function n(e,t){var n=2147483648&e,r=2147483648&t,o=1073741824&e,i=1073741824&t,s=(1073741823&e)+(1073741823&t);return o&i?2147483648^s^n^r:o|i?1073741824&s?3221225472^s^n^r:1073741824^s^n^r:s^n^r}function r(e,r,o,i,s,u,a){return e=n(e,n(n(function(e,t,n){return e&t|~e&n}(r,o,i),s),a)),n(t(e,u),r)}function o(e,r,o,i,s,u,a){return e=n(e,n(n(function(e,t,n){return e&n|t&~n}(r,o,i),s),a)),n(t(e,u),r)}function i(e,r,o,i,s,u,a){return e=n(e,n(n(function(e,t,n){return e^t^n}(r,o,i),s),a)),n(t(e,u),r)}function s(e,r,o,i,s,u,a){return e=n(e,n(n(function(e,t,n){return t^(e|~n)}(r,o,i),s),a)),n(t(e,u),r)}function u(e){var t,n="",r="";for(t=0;t<=3;t++)n+=(r="0".concat((e>>>8*t&255).toString(16))).substr(r.length-2,2);return n}var a,l,c,f,h,d,p,_,v,m;for(a=function(e){for(var t,n=e.length,r=n+8,o=16*((r-r%64)/64+1),i=new Array(o-1),s=0,u=0;u<n;)s=u%4*8,i[t=(u-u%4)/4]=i[t]|e.charCodeAt(u)<<s,u++;return s=u%4*8,i[t=(u-u%4)/4]=i[t]|128<<s,i[o-2]=n<<3,i[o-1]=n>>>29,i}(e=function(e){for(var t="",n=0;n<e.length;n++){var r=e.charCodeAt(n);r<128?t+=String.fromCharCode(r):r>127&&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,l=0;l<a.length;l+=16)c=p,f=_,h=v,d=m,p=r(p,_,v,m,a[l+0],7,3614090360),m=r(m,p,_,v,a[l+1],12,3905402710),v=r(v,m,p,_,a[l+2],17,606105819),_=r(_,v,m,p,a[l+3],22,3250441966),p=r(p,_,v,m,a[l+4],7,4118548399),m=r(m,p,_,v,a[l+5],12,1200080426),v=r(v,m,p,_,a[l+6],17,2821735955),_=r(_,v,m,p,a[l+7],22,4249261313),p=r(p,_,v,m,a[l+8],7,1770035416),m=r(m,p,_,v,a[l+9],12,2336552879),v=r(v,m,p,_,a[l+10],17,4294925233),_=r(_,v,m,p,a[l+11],22,2304563134),p=r(p,_,v,m,a[l+12],7,1804603682),m=r(m,p,_,v,a[l+13],12,4254626195),v=r(v,m,p,_,a[l+14],17,2792965006),p=o(p,_=r(_,v,m,p,a[l+15],22,1236535329),v,m,a[l+1],5,4129170786),m=o(m,p,_,v,a[l+6],9,3225465664),v=o(v,m,p,_,a[l+11],14,643717713),_=o(_,v,m,p,a[l+0],20,3921069994),p=o(p,_,v,m,a[l+5],5,3593408605),m=o(m,p,_,v,a[l+10],9,38016083),v=o(v,m,p,_,a[l+15],14,3634488961),_=o(_,v,m,p,a[l+4],20,3889429448),p=o(p,_,v,m,a[l+9],5,568446438),m=o(m,p,_,v,a[l+14],9,3275163606),v=o(v,m,p,_,a[l+3],14,4107603335),_=o(_,v,m,p,a[l+8],20,1163531501),p=o(p,_,v,m,a[l+13],5,2850285829),m=o(m,p,_,v,a[l+2],9,4243563512),v=o(v,m,p,_,a[l+7],14,1735328473),p=i(p,_=o(_,v,m,p,a[l+12],20,2368359562),v,m,a[l+5],4,4294588738),m=i(m,p,_,v,a[l+8],11,2272392833),v=i(v,m,p,_,a[l+11],16,1839030562),_=i(_,v,m,p,a[l+14],23,4259657740),p=i(p,_,v,m,a[l+1],4,2763975236),m=i(m,p,_,v,a[l+4],11,1272893353),v=i(v,m,p,_,a[l+7],16,4139469664),_=i(_,v,m,p,a[l+10],23,3200236656),p=i(p,_,v,m,a[l+13],4,681279174),m=i(m,p,_,v,a[l+0],11,3936430074),v=i(v,m,p,_,a[l+3],16,3572445317),_=i(_,v,m,p,a[l+6],23,76029189),p=i(p,_,v,m,a[l+9],4,3654602809),m=i(m,p,_,v,a[l+12],11,3873151461),v=i(v,m,p,_,a[l+15],16,530742520),p=s(p,_=i(_,v,m,p,a[l+2],23,3299628645),v,m,a[l+0],6,4096336452),m=s(m,p,_,v,a[l+7],10,1126891415),v=s(v,m,p,_,a[l+14],15,2878612391),_=s(_,v,m,p,a[l+5],21,4237533241),p=s(p,_,v,m,a[l+12],6,1700485571),m=s(m,p,_,v,a[l+3],10,2399980690),v=s(v,m,p,_,a[l+10],15,4293915773),_=s(_,v,m,p,a[l+1],21,2240044497),p=s(p,_,v,m,a[l+8],6,1873313359),m=s(m,p,_,v,a[l+15],10,4264355552),v=s(v,m,p,_,a[l+6],15,2734768916),_=s(_,v,m,p,a[l+13],21,1309151649),p=s(p,_,v,m,a[l+4],6,4149444226),m=s(m,p,_,v,a[l+11],10,3174756917),v=s(v,m,p,_,a[l+2],15,718787259),_=s(_,v,m,p,a[l+9],21,3951481745),p=n(p,c),_=n(_,f),v=n(v,h),m=n(m,d);return(u(p)+u(_)+u(v)+u(m)).toLowerCase()},t.closeMediaStream=function(e){if(e)try{if(e.getTracks){var t,n=o(e.getTracks());try{for(n.s();!(t=n.n()).done;){t.value.stop()}}catch(e){n.e(e)}finally{n.f()}}else{var i,s=o(e.getAudioTracks());try{for(s.s();!(i=s.n()).done;){i.value.stop()}}catch(e){s.e(e)}finally{s.f()}var u,a=o(e.getVideoTracks());try{for(a.s();!(u=a.n()).done;){u.value.stop()}}catch(e){a.e(e)}finally{a.f()}}}catch(t){"function"!=typeof e.stop&&"object"!==r(e.stop)||e.stop()}},t.cloneArray=function(e){return e&&e.slice()||[]},t.cloneObject=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e&&Object.assign({},e)||t}},32:(e,t,n)=>{"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var o=n(510),i=n(561),s=new o("WebSocketInterface");e.exports=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),s.debug('new() [url:"%s"]',t),this._url=t,this._sip_uri=null,this._via_transport=null,this._ws=null;var n=i.parse(t,"absoluteURI");if(-1===n)throw s.warn("invalid WebSocket URI: ".concat(t)),new TypeError("Invalid argument: ".concat(t));if("wss"!==n.scheme&&"ws"!==n.scheme)throw s.warn("invalid WebSocket URI scheme: ".concat(n.scheme)),new TypeError("Invalid argument: ".concat(t));this._sip_uri="sip:".concat(n.host).concat(n.port?":".concat(n.port):"",";transport=ws"),this._via_transport=n.scheme.toUpperCase()}var t,n,o;return t=e,(n=[{key:"connect",value:function(){if(s.debug("connect()"),this.isConnected())s.debug("WebSocket ".concat(this._url," is already connected"));else if(this.isConnecting())s.debug("WebSocket ".concat(this._url," is connecting"));else{this._ws&&this.disconnect(),s.debug("connecting to WebSocket ".concat(this._url));try{this._ws=new WebSocket(this._url,"sip"),this._ws.binaryType="arraybuffer",this._ws.onopen=this._onOpen.bind(this),this._ws.onclose=this._onClose.bind(this),this._ws.onmessage=this._onMessage.bind(this),this._ws.onerror=this._onError.bind(this)}catch(e){this._onError(e)}}}},{key:"disconnect",value:function(){s.debug("disconnect()"),this._ws&&(this._ws.onopen=function(){},this._ws.onclose=function(){},this._ws.onmessage=function(){},this._ws.onerror=function(){},this._ws.close(),this._ws=null)}},{key:"send",value:function(e){return s.debug("send()"),this.isConnected()?(this._ws.send(e),!0):(s.warn("unable to send message, WebSocket is not open"),!1)}},{key:"isConnected",value:function(){return this._ws&&this._ws.readyState===this._ws.OPEN}},{key:"isConnecting",value:function(){return this._ws&&this._ws.readyState===this._ws.CONNECTING}},{key:"_onOpen",value:function(){s.debug("WebSocket ".concat(this._url," connected")),this.onconnect()}},{key:"_onClose",value:function(e){var t=e.wasClean,n=e.code,r=e.reason;s.debug("WebSocket ".concat(this._url," closed")),!1===t&&s.debug("WebSocket abrupt disconnection"),this.ondisconnect(!t,n,r)}},{key:"_onMessage",value:function(e){var t=e.data;s.debug("received WebSocket message"),this.ondata(t)}},{key:"_onError",value:function(e){s.warn("WebSocket ".concat(this._url," error: "),e)}},{key:"via_transport",get:function(){return this._via_transport},set:function(e){this._via_transport=e.toUpperCase()}},{key:"sip_uri",get:function(){return this._sip_uri}},{key:"url",get:function(){return this._url}}])&&r(t.prototype,n),o&&r(t,o),e}()},46:(e,t,n)=>{"use strict";function r(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,u=!0,a=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return u=e.done,e},e:function(e){a=!0,s=e},f:function(){try{u||null==n.return||n.return()}finally{if(a)throw s}}}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var i,s,u,a=n(510),l=n(349),c=n(213),f=n(137),h=new a("sanityCheck"),d=[function(){for(var e=0,t=["from","to","call_id","cseq","via"];e<t.length;e++){var n=t[e];if(!i.hasHeader(n))return h.debug("missing mandatory header field : ".concat(n,", dropping the response")),!1}}],p=[function(){if("sip"!==i.s("to").uri.scheme)return v(416),!1},function(){if(!i.to_tag&&i.call_id.substr(0,5)===s.configuration.jssip_id)return v(482),!1},function(){var e=f.str_utf8_length(i.body),t=i.getHeader("content-length");if(e<t)return v(400),!1},function(){var e,t=i.from_tag,n=i.call_id,r=i.cseq;if(i.to_tag)return;if(i.method===l.INVITE){if(s._transactions.ist[i.via_branch])return!1;for(var o in s._transactions.ist)if(Object.prototype.hasOwnProperty.call(s._transactions.ist,o)&&(e=s._transactions.ist[o]).request.from_tag===t&&e.request.call_id===n&&e.request.cseq===r)return v(482),!1}else{if(s._transactions.nist[i.via_branch])return!1;for(var u in s._transactions.nist)if(Object.prototype.hasOwnProperty.call(s._transactions.nist,u)&&(e=s._transactions.nist[u]).request.from_tag===t&&e.request.call_id===n&&e.request.cseq===r)return v(482),!1}}],_=[function(){if(i.getHeaders("via").length>1)return h.debug("more than one Via header field present in the response, dropping the response"),!1},function(){var e=f.str_utf8_length(i.body),t=i.getHeader("content-length");if(e<t)return h.debug("message body length is lower than the value in Content-Length header field, dropping the response"),!1}];function v(e){var t,n,o=i.getHeaders("via"),s="SIP/2.0 ".concat(e," ").concat(l.REASON_PHRASE[e],"\r\n"),a=r(o);try{for(a.s();!(n=a.n()).done;){var c=n.value;s+="Via: ".concat(c,"\r\n")}}catch(e){a.e(e)}finally{a.f()}t=i.getHeader("To"),i.to_tag||(t+=";tag=".concat(f.newTag())),s+="To: ".concat(t,"\r\n"),s+="From: ".concat(i.getHeader("From"),"\r\n"),s+="Call-ID: ".concat(i.call_id,"\r\n"),s+="CSeq: ".concat(i.cseq," ").concat(i.method,"\r\n"),s+="\r\n",u.send(s)}e.exports=function(e,t,n){i=e,s=t,u=n;var o,a=r(d);try{for(a.s();!(o=a.n()).done;){if(!1===(0,o.value)())return!1}}catch(e){a.e(e)}finally{a.f()}if(i instanceof c.IncomingRequest){var l,f=r(p);try{for(f.s();!(l=f.n()).done;){if(!1===(0,l.value)())return!1}}catch(e){f.e(e)}finally{f.f()}}else if(i instanceof c.IncomingResponse){var h,v=r(_);try{for(v.s();!(h=v.n()).done;){if(!1===(0,h.value)())return!1}}catch(e){v.e(e)}finally{v.f()}}return!0}},720:(e,t,n)=>{t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(o=r))})),t.splice(o,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=
23
+ /**
24
+ * Currently only WebKit-based Web Inspectors, Firefox >= v31,
25
+ * and the Firebug extension (any Firefox version) are known
26
+ * to support "%c" CSS customizations.
27
+ *
28
+ * TODO: add a `localStorage` variable to explicitly enable/disable colors
29
+ */
30
+ function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.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"],t.log=console.debug||console.log||(()=>{}),e.exports=n(791)(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},791:(e,t,n)=>{e.exports=function(e){function t(e){let n,o,i,s=null;function u(...e){if(!u.enabled)return;const r=u,o=Number(new Date),i=o-(n||o);r.diff=i,r.prev=n,r.curr=o,n=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,o)=>{if("%%"===n)return"%";s++;const i=t.formatters[o];if("function"==typeof i){const t=e[s];n=i.call(r,t),e.splice(s,1),s--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return u.namespace=e,u.useColors=t.useColors(),u.color=t.selectColor(e),u.extend=r,u.destroy=t.destroy,Object.defineProperty(u,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{s=e}}),"function"==typeof t.init&&t.init(u),u}function r(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function o(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(o),...t.skips.map(o).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=n(774),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}},774:e=>{var t=1e3,n=60*t,r=60*n,o=24*r,i=7*o,s=365.25*o;function u(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}e.exports=function(e,a){a=a||{};var l=typeof e;if("string"===l&&e.length>0)return function(e){if((e=String(e)).length>100)return;var u=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!u)return;var a=parseFloat(u[1]);switch((u[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return a*s;case"weeks":case"week":case"w":return a*i;case"days":case"day":case"d":return a*o;case"hours":case"hour":case"hrs":case"hr":case"h":return a*r;case"minutes":case"minute":case"mins":case"min":case"m":return a*n;case"seconds":case"second":case"secs":case"sec":case"s":return a*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}(e);if("number"===l&&isFinite(e))return a.long?function(e){var i=Math.abs(e);if(i>=o)return u(e,i,o,"day");if(i>=r)return u(e,i,r,"hour");if(i>=n)return u(e,i,n,"minute");if(i>=t)return u(e,i,t,"second");return e+" ms"}(e):function(e){var i=Math.abs(e);if(i>=o)return Math.round(e/o)+"d";if(i>=r)return Math.round(e/r)+"h";if(i>=n)return Math.round(e/n)+"m";if(i>=t)return Math.round(e/t)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},602:e=>{var t=e.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{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"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{
31
+ // RFC version 26 for SCTP over DTLS
32
+ name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{
33
+ // RFC version 26 for SCTP over DTLS
34
+ name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(t).forEach((function(e){t[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}))},363:(e,t,n)=>{var r=n(20),o=n(804);t.write=o,t.parse=r.parse,t.parseParams=r.parseParams,t.parseFmtpConfig=r.parseFmtpConfig,t.parsePayloads=r.parsePayloads,t.parseRemoteCandidates=r.parseRemoteCandidates,t.parseImageAttributes=r.parseImageAttributes,t.parseSimulcastStreamList=r.parseSimulcastStreamList},20:(e,t,n)=>{var r=function(e){return String(Number(e))===e?Number(e):e},o=function(e,t,n){var o=e.name&&e.names;e.push&&!t[e.push]?t[e.push]=[]:o&&!t[e.name]&&(t[e.name]={});var i=e.push?{}:o?t[e.name]:t;!function(e,t,n,o){if(o&&!n)t[o]=r(e[1]);else for(var i=0;i<n.length;i+=1)null!=e[i+1]&&(t[n[i]]=r(e[i+1]))}(n.match(e.reg),i,e.names,e.name),e.push&&t[e.push].push(i)},i=n(602),s=RegExp.prototype.test.bind(/^([a-z])=(.*)/);t.parse=function(e){var t={},n=[],r=t;return e.split(/(\r\n|\r|\n)/).filter(s).forEach((function(e){var t=e[0],s=e.slice(2);"m"===t&&(n.push({rtp:[],fmtp:[]}),r=n[n.length-1]);for(var u=0;u<(i[t]||[]).length;u+=1){var a=i[t][u];if(a.reg.test(s))return o(a,r,s)}})),t.media=n,t};var u=function(e,t){var n=t.split(/=(.+)/,2);return 2===n.length?e[n[0]]=r(n[1]):1===n.length&&t.length>1&&(e[n[0]]=void 0),e};t.parseParams=function(e){return e.split(/;\s?/).reduce(u,{})},t.parseFmtpConfig=t.parseParams,t.parsePayloads=function(e){return e.toString().split(" ").map(Number)},t.parseRemoteCandidates=function(e){for(var t=[],n=e.split(" ").map(r),o=0;o<n.length;o+=3)t.push({component:n[o],ip:n[o+1],port:n[o+2]});return t},t.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(u,{})}))},t.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var t,n=!1;return"~"!==e[0]?t=r(e):(t=r(e.substring(1,e.length)),n=!0),{scid:t,paused:n}}))}))}},804:(e,t,n)=>{var r=n(602),o=/%[sdv%]/g,i=function(e){var t=1,n=arguments,r=n.length;return e.replace(o,(function(e){if(t>=r)return e;var o=n[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(o);case"%d":return Number(o);case"%v":return""}}))},s=function(e,t,n){var r=[e+"="+(t.format instanceof Function?t.format(t.push?n:n[t.name]):t.format)];if(t.names)for(var o=0;o<t.names.length;o+=1){var s=t.names[o];t.name?r.push(n[t.name][s]):r.push(n[t.names[o]])}else r.push(n[t.name]);return i.apply(null,r)},u=["v","o","s","i","u","e","p","c","b","t","r","z","a"],a=["i","c","b","a"];e.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||u,o=t.innerOrder||a,i=[];return n.forEach((function(t){r[t].forEach((function(n){n.name in e&&null!=e[n.name]?i.push(s(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach((function(e){i.push(s(t,n,e))}))}))})),e.media.forEach((function(e){i.push(s("m",r.m[0],e)),o.forEach((function(t){r[t].forEach((function(n){n.name in e&&null!=e[n.name]?i.push(s(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach((function(e){i.push(s(t,n,e))}))}))}))})),i.join("\r\n")+"\r\n"}},633:e=>{"use strict";e.exports=JSON.parse('{"name":"jssip","title":"JsSIP","description":"the Javascript SIP library","version":"3.10.1","homepage":"https://jssip.net","contributors":["José Luis Millán <jmillan@aliax.net> (https://github.com/jmillan)","Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)"],"types":"lib/JsSIP.d.ts","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":{"@types/events":"^3.0.0","@types/debug":"^4.1.7","debug":"^4.3.1","events":"^3.3.0","sdp-transform":"^2.14.1"},"devDependencies":{"@babel/core":"^7.19.6","@babel/preset-env":"^7.19.4","ansi-colors":"^3.2.4","browserify":"^16.5.1","eslint":"^5.16.0","fancy-log":"^1.3.3","gulp":"^4.0.2","gulp-babel":"^8.0.0","gulp-eslint":"^5.0.0","gulp-expect-file":"^1.0.2","gulp-header":"^2.0.9","gulp-nodeunit-runner":"^0.2.2","gulp-plumber":"^1.2.1","gulp-rename":"^1.4.0","gulp-uglify-es":"^1.0.4","pegjs":"^0.7.0","vinyl-buffer":"^1.0.1","vinyl-source-stream":"^2.0.0"},"scripts":{"lint":"node npm-scripts.js lint","test":"node npm-scripts.js test","prepublish":"node npm-scripts.js prepublish","release":"node npm-scripts.js release"}}')}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var r={};return(()=>{"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,o(r.key),r)}}function o(t){var n=function(t,n){if("object"!=e(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,n||"default");if("object"!=e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}(t,"string");return"symbol"==e(n)?n:n+""}n.d(r,{default:()=>pe});var i,s,u,a=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.allowedEvents=t,this.events={}}return n=e,(r=[{key:"on",value:function(t,n){if("function"!=typeof n)throw new Error("回调必须是函数");if(!t||"string"!=typeof t)throw new Error("事件名必须是非空字符串");this.events[t]||(this.events[t]=[]),e.KEEP_EVENTS.includes(t)?0===this.events[t].length&&this.events[t].push(n):this.events[t].push(n)}},{key:"emit",value:function(e,t){var n=this.events[e];n&&n.forEach((function(n){try{n(t)}catch(t){console.error("事件 ".concat(e," 回调执行错误:"),t)}}))}},{key:"off",value:function(e,t){var n=this.events[e];n&&(this.events[e]=n.filter((function(e){return e!==t})))}},{key:"destroy",value:function(){this.events={}}},{key:"destroyEvents",value:function(){var t=this;Object.keys(this.events).forEach((function(n){e.KEEP_EVENTS.includes(n)||delete t.events[n]}))}}])&&t(n.prototype,r),o&&t(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}();function l(e){return l="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},l(e)}function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?c(Object(n),!0).forEach((function(t){d(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function h(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,p(r.key),r)}}function d(e,t,n){return(t=p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e){var t=function(e,t){if("object"!=l(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=l(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==l(t)?t:t+""}i=a,u=[],(s=o(s="KEEP_EVENTS"))in i?Object.defineProperty(i,s,{value:u,enumerable:!0,configurable:!0,writable:!0}):i[s]=u;var _=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return function(e,t,n){return t&&h(e.prototype,t),n&&h(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(e,[{key:"on",value:function(e,t){this.eventBus.on(e,t)}}],[{key:"getEventBus",value:function(){return e.eventBus}},{key:"getBase",value:function(){return e.base}},{key:"setBase",value:function(t){e.base=f(f({},e.base),t)}}])}();d(_,"base",{webrtc:!1,checkin:!1,token:"",agent:"",account:"",socket:"",sip:{socket:"",account:"",password:"",domain:""},env:""}),d(_,"eventBus",new a);var v=n(53);function m(e){return m="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},m(e)}function y(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,g(r.key),r)}}function g(e){var t=function(e,t){if("object"!=m(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=m(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==m(t)?t:t+""}var b=function(){return function(e,t,n){return t&&y(e.prototype,t),n&&y(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.allowedEvents=t,this.events={}}),[{key:"on",value:function(e,t){var n;void 0===(null===(n=this.events[e])||void 0===n?void 0:n.length)&&(this.events[e]||(this.events[e]=[]),this.events[e].push(t))}},{key:"emit",value:function(e,t){var n=this.events[e];n&&n.forEach((function(e){e(t)}))}},{key:"off",value:function(e,t){var n=this.events[e];n&&(this.events[e]=n.filter((function(e){return e!==t})))}},{key:"destroy",value:function(){this.events={}}}])}();function T(e){return T="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},T(e)}function S(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,I(r.key),r)}}function E(e,t,n){return t=w(t),function(e,t){if(t&&("object"==T(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,C()?Reflect.construct(t,n||[],w(e).constructor):t.apply(e,n))}function C(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(C=function(){return!!e})()}function w(e){return w=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},w(e)}function A(e,t){return A=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},A(e,t)}function R(e,t,n){return(t=I(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function I(e){var t=function(e,t){if("object"!=T(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=T(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==T(t)?t:t+""}var O=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),E(this,t)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&A(e,t)}(t,e),function(e,t,n){return t&&S(e.prototype,t),n&&S(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(t,[{key:"on",value:function(e,n){t.eventBus.on(e,n)}},{key:"init",value:function(){var e=this;if(t.content&&t.content.isConnected())t.content.start();else if(!t.content||!t.content.isRegistered())if(t.content)t.content.start();else{var n=_.getBase(),r={sockets:[new v.WebSocketInterface(n.sip.socket)],uri:"sip:"+n.sip.account+"@"+n.sip.domain,password:n.sip.password,mediaConstraints:{audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0},video:!1}};t.content=new v.UA(r),t.content.on("newRTCSession",(function(n){t.eventBus.emit("newRTCSession",n);var r=n.session;"remote"===n.originator&&(t.answerSession=n.session),r.on("peerconnection",(function(e){t.eventBus.emit("peerconnection",n),e.peerconnection.onaddstream=function(e){t.audio.srcObject=e.stream,t.audio.play()}})),r.on("progress",(function(r){t.eventBus.emit("progress",r);var o=n.request.headers["Call-Info"];void 0!==o&&(o[0].raw.includes("answer-after")&&e.answer())})),r.on("failed",(function(e){t.answerSession=null,t.eventBus.emit("failed",e)})),r.on("ended",(function(e){t.eventBus.emit("ended",e),t.answerSession=null}))})),t.content.on("registrationFailed",(function(e){t.eventBus.emit("registrationFailed",e)})),t.content.on("disconnected",(function(e){t.eventBus.emit("disconnected",e)})),t.content.on("registered",(function(e){t.eventBus.emit("registered",e)})),e.start()}}},{key:"answer",value:function(){t.answerSession?t.answerSession.answer({mediaConstraints:{audio:!0,video:!1},mediaStream:null,pcConfig:{iceServers:[]},sessionTimersExpires:180}):t.eventBus.emit("answerSession",{code:401,message:"接听对象不存在",data:""})}},{key:"start",value:function(){t.content&&(t.content.isRegistered()||t.content.start())}},{key:"stop",value:function(){t.content&&t.content.stop()}},{key:"switchMicrophone",value:function(e){t.answerSession&&navigator.mediaDevices.getUserMedia({audio:{deviceId:{exact:e}},video:!1}).then((function(e){var n=t.answerSession.connection.getSenders().find((function(e){var t;return"audio"===(null===(t=e.track)||void 0===t?void 0:t.kind)}));n&&n.replaceTrack(e.getAudioTracks()[0])})).catch((function(e){console.error("切换麦克风失败:",e)}))}},{key:"switchSpeaker",value:function(e){t.audio.setSinkId?t.audio.setSinkId(e).then((function(){return console.log("已切换到扬声器: ".concat(e))})).catch((function(e){return console.error("切换扬声器失败:",e)})):console.warn("当前浏览器不支持切换扬声器")}}],[{key:"getEventBus",value:function(){return t.eventBus}},{key:"getContent",value:function(){return t.content}},{key:"destroy",value:function(){t.eventBus.destroy()}}])}(_);function k(e){return k="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},k(e)}function N(e,t){var n=e.toString();return n.length>=t?n:n.padStart(t,"0")}function x(e){return x="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},x(e)}function P(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,D(r.key),r)}}function D(e){var t=function(e,t){if("object"!=x(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=x(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==x(t)?t:t+""}R(O,"content",null),R(O,"answerSession",null),R(O,"audio",new Audio),R(O,"eventBus",new b);var U=function(){return function(e,t,n){return t&&P(e.prototype,t),n&&P(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}((function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.defaultColor="#909399"}),[{key:"log",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.defaultColor,r=_.getBase();if(r.env&&"debug"===r.env){for(var o,i=function(e,t){if(0===arguments.length)return null;var n,r=t||"{y}-{m}-{d} {h}:{i}:{s}";"object"===k(e)?n=e:("string"==typeof e&&/^[0-9]+$/.test(e)&&(e=parseInt(e)),"number"==typeof e&&10===e.toString().length&&(e*=1e3),n=new Date(e));var o={y:n.getFullYear(),m:n.getMonth()+1,d:n.getDate(),h:n.getHours(),i:n.getMinutes(),s:n.getSeconds(),a:n.getDay()};return r.replace(/{([ymdhisa])+}/g,(function(e,t){var n=o[t];return"a"===t?["日","一","二","三","四","五","六"][n]:n.toString().padStart(2,"0")}))}(new Date),s=arguments.length,u=new Array(s>3?s-3:0),a=3;a<s;a++)u[a-3]=arguments[a];(o=console).log.apply(o,["%c ".concat(e," %c ").concat(t," %c"),"background:#35495E; padding: 2px 1px; border-radius: 3px 0 0 3px; color: #fff;","background:".concat(n,"; padding: 2px 1px; border-radius: 0 3px 3px 0; color: #fff;"),"background:transparent"].concat(u,["".concat(i)]))}}},{key:"info",value:function(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];this.log.apply(this,[e,t,"#909399"].concat(r))}},{key:"success",value:function(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];this.log.apply(this,[e,t,"#67C23A"].concat(r))}},{key:"error",value:function(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];this.log.apply(this,[e,t,"#F56C6C"].concat(r))}},{key:"warning",value:function(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];this.log.apply(this,[e,t,"#E6A23C"].concat(r))}},{key:"custom",value:function(e,t,n){for(var r=arguments.length,o=new Array(r>3?r-3:0),i=3;i<r;i++)o[i-3]=arguments[i];this.log.apply(this,[e,t,n].concat(o))}}])}();const M=new U;function L(e){return L="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},L(e)}function q(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,j(r.key),r)}}function j(e){var t=function(e,t){if("object"!=L(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=L(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==L(t)?t:t+""}var H=function(){return function(e,t,n){return t&&q(e.prototype,t),n&&q(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e3;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.updateInterval=t,this.worker=null,this.isRunning=!1,this.elapsedSeconds=0,this.onUpdate=null}),[{key:"start",value:function(){var e=this;if(!this.isRunning){this.isRunning=!0,this.elapsedSeconds=0;var t=new Blob(['\nlet elapsedSeconds = 0\nlet intervalId = null\n\nonmessage = function (e) {\n if (e.data.command === "start") {\n const interval = e.data.interval || 1000\n intervalId = setInterval(() => {\n elapsedSeconds++\n postMessage({ command: "tick", elapsedSeconds: elapsedSeconds })\n }, interval)\n } else if (e.data.command === "stop") {\n clearInterval(intervalId)\n intervalId = null\n elapsedSeconds = 0\n }\n}\n'],{type:"application/javascript"}),n=URL.createObjectURL(t);this.worker=new Worker(n),this.worker.postMessage({command:"start",interval:this.updateInterval}),this.worker.onmessage=function(t){"tick"===t.data.command&&(e.elapsedSeconds=t.data.elapsedSeconds,e.onUpdate&&e.onUpdate(e.elapsedSeconds))}}}},{key:"stop",value:function(){this.worker&&(this.worker.postMessage({command:"stop"}),this.worker.terminate(),this.worker=null),this.isRunning=!1}},{key:"setOnUpdate",value:function(e){this.onUpdate=e}}])}();function F(e){return F="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},F(e)}function B(){B=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",a=i.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function c(e,t,n,r){var i=t&&t.prototype instanceof m?t:m,s=Object.create(i.prototype),u=new k(r||[]);return o(s,"_invoke",{value:A(e,n,u)}),s}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=c;var h="suspendedStart",d="suspendedYield",p="executing",_="completed",v={};function m(){}function y(){}function g(){}var b={};l(b,s,(function(){return this}));var T=Object.getPrototypeOf,S=T&&T(T(N([])));S&&S!==n&&r.call(S,s)&&(b=S);var E=g.prototype=m.prototype=Object.create(b);function C(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function n(o,i,s,u){var a=f(e[o],e,i);if("throw"!==a.type){var l=a.arg,c=l.value;return c&&"object"==F(c)&&r.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,s,u)}),(function(e){n("throw",e,s,u)})):t.resolve(c).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,u)}))}u(a.arg)}var i;o(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,o){n(e,r,t,o)}))}return i=i?i.then(o,o):o()}})}function A(t,n,r){var o=h;return function(i,s){if(o===p)throw Error("Generator is already running");if(o===_){if("throw"===i)throw s;return{value:e,done:!0}}for(r.method=i,r.arg=s;;){var u=r.delegate;if(u){var a=R(u,r);if(a){if(a===v)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===h)throw o=_,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=p;var l=f(t,n,r);if("normal"===l.type){if(o=r.done?_:d,l.arg===v)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(o=_,r.method="throw",r.arg=l.arg)}}}function R(t,n){var r=n.method,o=t.iterator[r];if(o===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,R(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var i=f(o,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,v;var s=i.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,v):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function I(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(I,this),this.reset(!0)}function N(t){if(t||""===t){var n=t[s];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function n(){for(;++o<t.length;)if(r.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return i.next=i}}throw new TypeError(F(t)+" is not iterable")}return y.prototype=g,o(E,"constructor",{value:g,configurable:!0}),o(g,"constructor",{value:y,configurable:!0}),y.displayName=l(g,a,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,l(e,a,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},C(w.prototype),l(w.prototype,u,(function(){return this})),t.AsyncIterator=w,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var s=new w(c(e,n,r,o),i);return t.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},C(E),l(E,a,"Generator"),l(E,s,(function(){return this})),l(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=N,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function o(r,o){return u.type="throw",u.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],u=s.completion;if("root"===s.tryLoc)return o("end");if(s.tryLoc<=this.prev){var a=r.call(s,"catchLoc"),l=r.call(s,"finallyLoc");if(a&&l){if(this.prev<s.catchLoc)return o(s.catchLoc,!0);if(this.prev<s.finallyLoc)return o(s.finallyLoc)}else if(a){if(this.prev<s.catchLoc)return o(s.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return o(s.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=e,s.arg=t,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),O(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;O(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:N(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}function G(e,t,n,r,o,i,s){try{var u=e[i](s),a=u.value}catch(e){return void n(e)}u.done?t(a):Promise.resolve(a).then(r,o)}function W(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function s(e){G(i,r,o,s,u,"next",e)}function u(e){G(i,r,o,s,u,"throw",e)}s(void 0)}))}}function V(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,J(r.key),r)}}function K(e,t,n){return t=z(t),function(e,t){if(t&&("object"==F(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,Y()?Reflect.construct(t,n||[],z(e).constructor):t.apply(e,n))}function Y(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Y=function(){return!!e})()}function z(e){return z=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},z(e)}function $(e,t){return $=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},$(e,t)}function J(e){var t=function(e,t){if("object"!=F(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=F(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==F(t)?t:t+""}var X=function(e){function t(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(e=K(this,t)).baseInfo=_.getBase(),e.initEvent(),e.initJssip(),e.telephone={type:"",reconnect:!1,clientTime:Math.floor(Date.now()/1e3),serverTime:Math.floor(Date.now()/1e3),statusTime:0,diff:0,statusCode:""},e.timer=null,e.watchTimer=null,e.permissionTimer=null,e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&$(e,t)}(t,e),function(e,t,n){return t&&V(e.prototype,t),n&&V(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(t,[{key:"startWatchTimer",value:function(){var e=this;this.watchTimer=new H,this.watchTimer.setOnUpdate((function(){if(e.telephone.clientTime=Math.floor(Date.now()/1e3),0!==e.telephone.statusTime){var t=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"hms",n=Math.floor(e/864e5),r=e%864e5,o=Math.floor(r/36e5),i=r%36e5,s=Math.floor(i/6e4),u=i%6e4,a=Math.round(u/1e3);return"dhms"===t?{day:N(n),hours:N(o,2),minutes:N(s,2),seconds:N(a,2)}:"hms"===t?{hours:N(n>0?24*n+o:o,2),minutes:N(s,2),seconds:N(a,2)}:void 0}(1e3*(e.telephone.clientTime-e.telephone.statusTime+e.telephone.diff),"hms");e.eventBus.emit("onlinetime",t.hours+":"+t.minutes+":"+t.seconds)}})),this.watchTimer.start()}},{key:"stopWatchTimer",value:function(){this.watchTimer&&(this.watchTimer.stop(),this.watchTimer=null)}},{key:"stopPermissionTime",value:function(){this.permissionTimer&&(this.permissionTimer.stop(),this.permissionTimer=null)}},{key:"startTimer",value:function(){var e=this;this.timer=new H(3e4),this.timer.setOnUpdate((function(){e.sendMessage({type:"Time",data:{}})})),this.timer.start()}},{key:"stopTimer",value:function(){this.timer&&(this.timer.stop(),this.timer=null)}},{key:"stop",value:function(){this.eventBus.emit("onlinetime","00:00:00"),this.stopTimer(),this.stopWatchTimer(),this.stopPermissionTime(),this.baseInfo.webrtc&&this.sip&&this.sip.stop(),t.content&&(t.content.close(),t.content=null)}},{key:"sipEvent",value:function(){var e=this;this.sipEventBus.on("newRTCSession",(function(e){M.custom("telephone","newRTCSession","#E13164",e)})),this.sipEventBus.on("peerconnection",(function(e){M.custom("telephone","peerconnection","#E13164",e)})),this.sipEventBus.on("progress",(function(e){M.custom("telephone","progress","#E13164",e)})),this.sipEventBus.on("failed",(function(e){M.custom("telephone","failed","#E13164",e)})),this.sipEventBus.on("ended",(function(e){M.custom("telephone","ended","#E13164",e)})),this.sipEventBus.on("registrationFailed",(function(e){M.custom("telephone","registrationFailed","#E13164",e)})),this.sipEventBus.on("disconnected",(function(t){M.custom("telephone","disconnected","#E13164",t),e.onclose()})),this.sipEventBus.on("answerSession",(function(t){M.error("telephone","error",t),e.eventBus.emit("error",t)})),this.sipEventBus.on("registered",(function(t){M.custom("telephone","registered","#E13164",t),e.checkin("jssip"),e.onopen("jssip")}))}},{key:"onopen",value:function(e){var n,r=O.getContent();M.info("telephone","onopen",{source:e,webrtc:this.baseInfo.webrtc,readyState:null==t||null===(n=t.content)||void 0===n?void 0:n.readyState,jssip:r,isRegistered:null==r?void 0:r.isRegistered(),isConnected:null==r?void 0:r.isConnected()});var o=200,i="连接成功";"Logout"===this.telephone.type?o=200:"Login"===this.telephone.type&&(o=201),this.baseInfo.webrtc?t.content.readyState===WebSocket.OPEN&&r&&r.isRegistered()&&r.isConnected()&&this.eventBus.emit("onopen",{code:o,message:i}):this.eventBus.emit("onopen",{code:o,message:i})}},{key:"onclose",value:function(){var e=this;if("Logout"===e.telephone.type)if(this.baseInfo.webrtc){var n=O.getContent();if(n){n.isConnected();t.content||n.isConnected()||r({code:200,message:"连接关闭"})}}else r({code:200,message:"连接关闭"});else r({code:201,message:"连接关闭"});function r(t){e.eventBus.emit("onclose",t),e.eventBus.destroyEvents()}}},{key:"initEvent",value:function(){this.eventBus=_.getEventBus()}},{key:"initJssip",value:function(){this.sip=new O,this.sipEventBus=O.getEventBus(),this.sipEvent()}},{key:"init",value:function(){if(t.content&&t.content.readyState===WebSocket.OPEN)this.checkin("socket");else{for(var e=this,n=0,r=["webrtc","token","agent","account","socket"];n<r.length;n++){var o=r[n];if(void 0===e.baseInfo[o])return void console.error("".concat(o," is required"))}t.content=new WebSocket(e.baseInfo.socket+"/v1/cc/socket?access_token="+e.baseInfo.token),t.content.onopen=function(){M.success("telephone","WebSocket连接成功"),e.telephone.clientTime=Math.floor(Date.now()/1e3),e.onopen("socket"),e.eventBus.emit("onlinetime","00:00:00"),e.startTimer(),e.startWatchTimer(),e.baseInfo.webrtc&&e.startPermissionTime(),e.baseInfo.webrtc?e.webrtcInfo():e.checkin("socket"),e.sendMessage({type:"Time",data:{}})},t.content.onclose=function(t){M.warning("telephone","onclose",t),e.onclose(),e.stopTimer(),e.stopWatchTimer(),e.reconnect(),e.eventBus.emit("onlinetime","00:00:00"),e.telephone.type="Logout"},t.content.onerror=function(t){M.error("telephone","onerror",t),e.stopTimer(),e.stopWatchTimer(),e.eventBus.emit("onerror",t)},t.content.onmessage=function(t){if(t.data){var n=JSON.parse(t.data),r=n.type,o=n.code,i=n.data;switch(M.custom("telephone","收到数据","#409EFF",n),e.eventBus.emit("onmessage",n),r){case"WebrtcInfo":_.setBase({sip:{socket:i.url,account:i.account,password:i.password,domain:i.domain}}),e.checkin("socket");break;case"Login":e.telephone.type="Login",e.telephone.reconnect=!0,e.relayList();break;case"Logout":e.telephone.type="Logout",e.telephone.reconnect=!1,e.stop();break;case"Status":e.telephone.statusCode=i.status,e.telephone.statusTime=i.time;break;case"Time":e.telephone.serverTime=i,e.telephone.diff=e.telephone.serverTime-e.telephone.clientTime;break;case"Error":11e3===o&&(e.telephone.reconnect=!1,e.stop())}}}}}},{key:"reconnect",value:function(){var e=this;e.telephone.reconnect&&setTimeout((function(){try{e.init()}catch(t){e.reconnect()}}),5e3)}},{key:"checkin",value:function(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=O.getContent();M.info("telephone","checkin",{source:n,webrtc:this.baseInfo.webrtc,readyState:null==t||null===(e=t.content)||void 0===e?void 0:e.readyState,jssip:r,isRegistered:null==r?void 0:r.isRegistered(),isConnected:null==r?void 0:r.isConnected()});var o=!1;this.baseInfo.webrtc?r&&r.isRegistered&&r.isRegistered()&&t.content.readyState===WebSocket.OPEN?o=!0:this.sip.init():o=!0,o&&"Login"!==this.telephone.type&&this.login()}},{key:"login",value:function(){this.sendMessage({type:"Login",data:{agent:this.baseInfo.agent,account:this.baseInfo.account}})}},{key:"logout",value:function(){this.sendMessage({type:"Logout",data:{}})}},{key:"hangup",value:function(){this.sendMessage({type:"Hangup",data:{}})}},{key:"relayList",value:function(){this.sendMessage({type:"RelayList",data:{}})}},{key:"call",value:(u=W(B().mark((function e(t){var n,r;return B().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n={customer:t.customer,relayNumber:t.relayNumber,custom:t.custom,subscriber:t.subscriber},!this.baseInfo.webrtc){e.next=8;break}return e.next=4,this.checkMicrophoneStatus();case 4:200===(r=e.sent).code?this.sendMessage({type:"Call",data:n}):(M.error("telephone","error",r),this.eventBus.emit("error",r)),e.next=9;break;case 8:this.sendMessage({type:"Call",data:n});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"keyup",value:function(e){this.sendMessage({type:"Keyup",data:{key:e}})}},{key:"status",value:function(e){this.sendMessage({type:"Status",data:{status:e}})}},{key:"regionInfo",value:function(e){this.sendMessage({type:"RegionInfo",data:{mobile:e}})}},{key:"mobileAnswer",value:function(e){this.sendMessage({type:"MobileAnswer",data:{status:e.status,relayNumber:e.relayNumber}})}},{key:"transferQueue",value:function(e){this.sendMessage({type:"Blind",data:{type:1,queueId:e}})}},{key:"transfer",value:function(e){this.sendMessage({type:"Blind",data:{type:0,customer:e.customer,relayNumber:e.relayNumber}})}},{key:"threeWayStart",value:function(e){this.sendMessage({type:"ThreeWayStart",data:{customer:e.customer,relayNumber:e.relayNumber}})}},{key:"threeWayCancel",value:function(){this.sendMessage({type:"ThreeWayCancel",data:{}})}},{key:"consultStart",value:function(e){this.sendMessage({type:"ConsultStart",data:{customer:e.customer,relayNumber:e.relayNumber}})}},{key:"consultCancel",value:function(){this.sendMessage({type:"ConsultCancel",data:{}})}},{key:"consultTransfer",value:function(){this.sendMessage({type:"ConsultTransfer",data:{}})}},{key:"hold",value:function(){this.sendMessage({type:"Hold",data:{status:1}})}},{key:"unhold",value:function(){this.sendMessage({type:"Hold",data:{status:0}})}},{key:"grade",value:function(){this.sendMessage({type:"Grade",data:{}})}},{key:"answer",value:function(){this.baseInfo.webrtc?this.sip.answer():this.sendMessage({type:"Answer",data:{}})}},{key:"webrtcInfo",value:function(){this.sendMessage({type:"WebrtcInfo",data:{agent:this.baseInfo.agent,account:this.baseInfo.account}})}},{key:"queueList",value:function(){this.sendMessage({type:"QueueList",data:{}})}},{key:"flowList",value:function(){this.sendMessage({type:"FlowList",data:{}})}},{key:"flow",value:function(e){this.sendMessage({type:"Flow",data:{flowId:e}})}},{key:"customHandle",value:function(e){this.sendMessage(e)}},{key:"sendMessage",value:function(e){t.content&&t.content.readyState===WebSocket.OPEN?(M.info("telephone","发送数据",e),t.content.send(JSON.stringify(e))):(M.error("telephone","error",{code:456,message:"Websocket未连接",data:""}),this.eventBus.emit("error",{code:456,message:"Websocket未连接",data:""}))}},{key:"getDefaultMedia",value:(s=W(B().mark((function e(){var t,n,r,o,i;return B().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getMedia();case 2:if(t=e.sent,n=t.code,r=t.data,200!==n){e.next=14;break}if(o=r.audioinput.find((function(e){return"default"===e.deviceId})),i=r.audiooutput.find((function(e){return"default"===e.deviceId})),!o){e.next=11;break}return e.abrupt("return",{type:"DefaultMedia",code:200,data:{input:o,output:i}});case 11:return e.abrupt("return",{type:"DefaultMedia",code:101,data:{input:{deviceId:(null==o?void 0:o.deviceId)||"",label:(null==o?void 0:o.label)||"获取失败,麦克风未开启或未授权",groupId:(null==o?void 0:o.groupId)||"",kind:(null==o?void 0:o.kind)||""},output:{deviceId:(null==i?void 0:i.deviceId)||"",label:(null==i?void 0:i.label)||"获取失败,麦克风未开启或未授权",groupId:(null==i?void 0:i.groupId)||"",kind:(null==i?void 0:i.kind)||""}}});case 12:e.next=15;break;case 14:return e.abrupt("return",t);case 15:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"getMedia",value:(i=W(B().mark((function e(){var t,n,r;return B().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.mediaDevices.enumerateDevices();case 3:return t=e.sent,n=t.filter((function(e){return"audioinput"===e.kind})),r=t.filter((function(e){return"audiooutput"===e.kind})),e.abrupt("return",{type:"Media",code:200,data:{audioinput:n,audiooutput:r}});case 9:return e.prev=9,e.t0=e.catch(0),e.abrupt("return",{type:"Media",code:105,message:"获取麦克风权限失败",data:{input:{deviceId:"",label:"获取失败,麦克风未开启或未授权",groupId:"",kind:""},output:{deviceId:"",label:"获取失败,麦克风未开启或未授权",groupId:"",kind:""}}});case 12:case"end":return e.stop()}}),e,null,[[0,9]])}))),function(){return i.apply(this,arguments)})},{key:"checkMicrophoneStatus",value:(o=W(B().mark((function e(){var t,n;return B().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.mediaDevices.enumerateDevices();case 3:if(t=e.sent,0!==(n=t.filter((function(e){return"audioinput"===e.kind}))).length){e.next=7;break}return e.abrupt("return",{type:"CheckMicrophoneStatus",code:101,message:"没有找到麦克风设备"});case 7:if(!n.some((function(e){return""!==e.label}))){e.next=12;break}return e.abrupt("return",{type:"CheckMicrophoneStatus",code:200,message:"麦克风已开启"});case 12:return e.abrupt("return",{type:"CheckMicrophoneStatus",code:101,message:"麦克风未开启或未授权"});case 13:e.next=18;break;case 15:return e.prev=15,e.t0=e.catch(0),e.abrupt("return",{type:"CheckMicrophoneStatus",code:101,message:"获取设备信息时出错"});case 18:case"end":return e.stop()}}),e,null,[[0,15]])}))),function(){return o.apply(this,arguments)})},{key:"getPhoneInfo",value:(r=W(B().mark((function e(){return B().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",{type:this.telephone.type,webrtc:this.baseInfo.webrtc,account:this.baseInfo.account,agent:this.baseInfo.agent,socket:this.baseInfo.socket,token:this.baseInfo.token});case 1:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getSystemInfo",value:(n=W(B().mark((function e(){var t,n,r,o,i,s,u;return B().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={name:"",version:""},(n=navigator.userAgent).indexOf("Chrome")>-1?(t.name="Chrome",r=n.match(/Chrome\/(\d+\.\d+)/),t.version=r?r[1]:""):n.indexOf("Firefox")>-1?(t.name="Firefox",o=n.match(/Firefox\/(\d+\.\d+)/),t.version=o?o[1]:""):n.indexOf("Safari")>-1?(t.name="Safari",i=n.match(/Version\/(\d+\.\d+)/),t.version=i?i[1]:""):n.indexOf("Edge")>-1?(t.name="Edge",s=n.match(/Edge\/(\d+\.\d+)/),t.version=s?s[1]:""):n.indexOf("Edg")>-1&&(t.name="Edge",u=n.match(/Edg\/(\d+\.\d+)/),t.version=u?u[1]:""),e.abrupt("return",{type:"SystemInfo",code:200,data:{browser:t,support:{webrtc:!!(window.RTCPeerConnection||window.webkitRTCPeerConnection||window.mozRTCPeerConnection),websocket:"WebSocket"in window}}});case 4:case"end":return e.stop()}}),e)}))),function(){return n.apply(this,arguments)})},{key:"startPermissionTime",value:function(){var e=this;this.permissionTimer=new H,this.permissionTimer.setOnUpdate(W(B().mark((function t(){return B().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.checkMicrophoneStatus();case 2:200===t.sent.code?e.eventBus.emit("onpermission",{microphone:!0}):e.eventBus.emit("onpermission",{microphone:!1});case 4:case"end":return t.stop()}}),t)})))),this.permissionTimer.start()}}]);var n,r,o,i,s,u}(_);function Q(e){return Q="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},Q(e)}function Z(e,t,n){return(t=re(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ee(){ee=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",a=i.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function c(e,t,n,r){var i=t&&t.prototype instanceof m?t:m,s=Object.create(i.prototype),u=new k(r||[]);return o(s,"_invoke",{value:A(e,n,u)}),s}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=c;var h="suspendedStart",d="suspendedYield",p="executing",_="completed",v={};function m(){}function y(){}function g(){}var b={};l(b,s,(function(){return this}));var T=Object.getPrototypeOf,S=T&&T(T(N([])));S&&S!==n&&r.call(S,s)&&(b=S);var E=g.prototype=m.prototype=Object.create(b);function C(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function n(o,i,s,u){var a=f(e[o],e,i);if("throw"!==a.type){var l=a.arg,c=l.value;return c&&"object"==Q(c)&&r.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,s,u)}),(function(e){n("throw",e,s,u)})):t.resolve(c).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,u)}))}u(a.arg)}var i;o(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,o){n(e,r,t,o)}))}return i=i?i.then(o,o):o()}})}function A(t,n,r){var o=h;return function(i,s){if(o===p)throw Error("Generator is already running");if(o===_){if("throw"===i)throw s;return{value:e,done:!0}}for(r.method=i,r.arg=s;;){var u=r.delegate;if(u){var a=R(u,r);if(a){if(a===v)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===h)throw o=_,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=p;var l=f(t,n,r);if("normal"===l.type){if(o=r.done?_:d,l.arg===v)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(o=_,r.method="throw",r.arg=l.arg)}}}function R(t,n){var r=n.method,o=t.iterator[r];if(o===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,R(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var i=f(o,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,v;var s=i.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,v):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function I(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(I,this),this.reset(!0)}function N(t){if(t||""===t){var n=t[s];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function n(){for(;++o<t.length;)if(r.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return i.next=i}}throw new TypeError(Q(t)+" is not iterable")}return y.prototype=g,o(E,"constructor",{value:g,configurable:!0}),o(g,"constructor",{value:y,configurable:!0}),y.displayName=l(g,a,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,l(e,a,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},C(w.prototype),l(w.prototype,u,(function(){return this})),t.AsyncIterator=w,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var s=new w(c(e,n,r,o),i);return t.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},C(E),l(E,a,"Generator"),l(E,s,(function(){return this})),l(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=N,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function o(r,o){return u.type="throw",u.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],u=s.completion;if("root"===s.tryLoc)return o("end");if(s.tryLoc<=this.prev){var a=r.call(s,"catchLoc"),l=r.call(s,"finallyLoc");if(a&&l){if(this.prev<s.catchLoc)return o(s.catchLoc,!0);if(this.prev<s.finallyLoc)return o(s.finallyLoc)}else if(a){if(this.prev<s.catchLoc)return o(s.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return o(s.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=e,s.arg=t,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),O(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;O(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:N(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}function te(e,t,n,r,o,i,s){try{var u=e[i](s),a=u.value}catch(e){return void n(e)}u.done?t(a):Promise.resolve(a).then(r,o)}function ne(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,re(r.key),r)}}function re(e){var t=function(e,t){if("object"!=Q(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=Q(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Q(t)?t:t+""}function oe(e,t){if(t&&("object"==Q(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function ie(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(ie=function(){return!!e})()}function se(e){return se=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},se(e)}function ue(e,t){return ue=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ue(e,t)}function ae(e,t,n){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,n)}function le(e,t,n){return e.set(fe(e,t),n),n}function ce(e,t){return e.get(fe(e,t))}function fe(e,t,n){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:n;throw new TypeError("Private element is not present on this object")}!function(e,t,n){(t=J(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(X,"content",null);var he=new WeakMap,de=new WeakMap,pe=function(e){function t(e){var n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),n=function(e,t,n){return t=se(t),oe(e,ie()?Reflect.construct(t,n||[],se(e).constructor):t.apply(e,n))}(this,t),ae(n,he,void 0),ae(n,de,void 0),navigator.permissions.query({name:"microphone"}).then(function(){var e,t=(e=ee().mark((function e(t){return ee().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("prompt"!==t.state){e.next=5;break}return e.next=3,navigator.mediaDevices.getUserMedia({audio:!0});case 3:e.sent.getTracks().forEach((function(e){return e.stop()}));case 5:case"end":return e.stop()}}),e)})),function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function s(e){te(i,r,o,s,u,"next",e)}function u(e){te(i,r,o,s,u,"throw",e)}s(void 0)}))});return function(e){return t.apply(this,arguments)}}()),le(he,n,_.getEventBus()),_.setBase(e),le(de,n,new X),n.agent=Z(Z(Z(Z({start:function(){ce(de,n).init()},logout:function(){ce(de,n).logout()},hangup:function(){ce(de,n).hangup()},relayList:function(){ce(de,n).relayList()},answer:function(){ce(de,n).answer()},call:function(e){ce(de,n).call(e)},keyup:function(e){ce(de,n).keyup(e)},status:function(e){ce(de,n).status(e)},regionInfo:function(e){ce(de,n).regionInfo(e)},mobileAnswer:function(e){ce(de,n).mobileAnswer(e)},transferQueue:function(e){ce(de,n).transferQueue(e)},transfer:function(e){ce(de,n).transfer(e)},threeWayStart:function(e){ce(de,n).threeWayStart(e)},threeWayCancel:function(){ce(de,n).threeWayCancel()},consultStart:function(e){ce(de,n).consultStart(e)},consultCancel:function(){ce(de,n).consultCancel()},consultTransfer:function(){ce(de,n).consultTransfer()},hold:function(){ce(de,n).hold()},unhold:function(){ce(de,n).unhold()},grade:function(){ce(de,n).grade()},queueList:function(){ce(de,n).queueList()}},"status",(function(e){ce(de,n).status(e)})),"getPhoneInfo",(function(){return ce(de,n).getPhoneInfo()})),"flowList",(function(){ce(de,n).flowList()})),"flow",(function(e){ce(de,n).flow(e)})),n.tool={getMedia:function(){return ce(de,n).getMedia()},getDefaultMedia:function(){return ce(de,n).getDefaultMedia()},checkMicrophoneStatus:function(){return ce(de,n).checkMicrophoneStatus()},getSystemInfo:function(){return ce(de,n).getSystemInfo()}},n.custom={handle:function(e){ce(de,n).customHandle(e)}};for(var r=0,o=["webrtc","token","agent","account","socket"];r<o.length;r++){var i=o[r];if(void 0===e[i])return console.error("".concat(i," is required")),oe(n)}return n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&ue(e,t)}(t,e),function(e,t,n){return t&&ne(e.prototype,t),n&&ne(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(t,[{key:"on",value:function(e,t){ce(he,this).on(e,t)}},{key:"onopen",value:function(e){ce(he,this).on("onopen",e)}},{key:"onmessage",value:function(e){ce(he,this).on("onmessage",e)}},{key:"onclose",value:function(e){ce(he,this).on("onclose",e)}},{key:"onerror",value:function(e){ce(he,this).on("onerror",e)}},{key:"onlinetime",value:function(e){ce(he,this).on("onlinetime",e)}},{key:"onpermission",value:function(e){ce(he,this).on("onpermission",e)}},{key:"error",value:function(e){ce(he,this).on("error",e)}}])}(_)})(),r=r.default})()));