@voicenter-team/opensips-js 1.0.75 → 1.0.76
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +26 -3
- package/dist/opensips-js.cjs.js +25 -25
- package/dist/opensips-js.es.js +531 -531
- package/dist/opensips-js.iife.js +21 -21
- package/dist/opensips-js.umd.js +21 -21
- package/package.json +1 -1
package/dist/opensips-js.umd.js
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
(function(or,vt){typeof exports=="object"&&typeof module<"u"?module.exports=vt():typeof define=="function"&&define.amd?define(vt):(or=typeof globalThis<"u"?globalThis:or||self,or.OpensipsJS=vt())})(this,function(){"use strict";var or=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function vt(c){return c&&c.__esModule&&Object.prototype.hasOwnProperty.call(c,"default")?c.default:c}const sl={name:"jssip",title:"JsSIP",description:"the Javascript SIP library",version:"3.10.0",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"}};var vu=sl,Xe={USER_AGENT:"".concat(vu.title," ").concat(vu.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};function nl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?nl=function(n){return typeof n}:nl=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},nl(c)}function rl(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function il(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&ar(c,r)}function ll(c){var r=Tu();return function(){var o=ur(c),a;if(r){var t=ur(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return nh(this,a)}}function nh(c,r){return r&&(nl(r)==="object"||typeof r=="function")?r:rh(c)}function rh(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function mn(c){var r=typeof Map=="function"?new Map:void 0;return mn=function(o){if(o===null||!ih(o))return o;if(typeof o!="function")throw new TypeError("Super expression must either be null or a function");if(typeof r<"u"){if(r.has(o))return r.get(o);r.set(o,a)}function a(){return ol(o,arguments,ur(this).constructor)}return a.prototype=Object.create(o.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),ar(a,o)},mn(c)}function ol(c,r,n){return Tu()?ol=Reflect.construct:ol=function(a,t,s){var p=[null];p.push.apply(p,t);var h=Function.bind.apply(a,p),d=new h;return s&&ar(d,s.prototype),d},ol.apply(null,arguments)}function Tu(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function ih(c){return Function.toString.call(c).indexOf("[native code]")!==-1}function ar(c,r){return ar=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},ar(c,r)}function ur(c){return ur=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},ur(c)}var lh=function(c){il(n,c);var r=ll(n);function n(o,a){var t;return rl(this,n),t=r.call(this),t.code=1,t.name="CONFIGURATION_ERROR",t.parameter=o,t.value=a,t.message=t.value?"Invalid value ".concat(JSON.stringify(t.value),' for parameter "').concat(t.parameter,'"'):"Missing parameter: ".concat(t.parameter),t}return n}(mn(Error)),oh=function(c){il(n,c);var r=ll(n);function n(o){var a;return rl(this,n),a=r.call(this),a.code=2,a.name="INVALID_STATE_ERROR",a.status=o,a.message="Invalid status: ".concat(o),a}return n}(mn(Error)),ah=function(c){il(n,c);var r=ll(n);function n(o){var a;return rl(this,n),a=r.call(this),a.code=3,a.name="NOT_SUPPORTED_ERROR",a.message=o,a}return n}(mn(Error)),uh=function(c){il(n,c);var r=ll(n);function n(o){var a;return rl(this,n),a=r.call(this),a.code=4,a.name="NOT_READY_ERROR",a.message=o,a}return n}(mn(Error)),ps={ConfigurationError:lh,InvalidStateError:oh,NotSupportedError:ah,NotReadyError:uh},Ye={},bo,Eu;function wo(){if(Eu)return bo;Eu=1;function c(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function r(t,s){for(var p=0;p<s.length;p++){var h=s[p];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(t,h.key,h)}}function n(t,s,p){return s&&r(t.prototype,s),p&&r(t,p),t}var o=ms(),a=Vt();return bo=function(){n(t,null,[{key:"parse",value:function(p){if(p=a.parse(p,"Name_Addr_Header"),p!==-1)return p}}]);function t(s,p,h){if(c(this,t),!s||!(s instanceof o))throw new TypeError('missing or invalid "uri" parameter');this._uri=s,this._parameters={},this.display_name=p;for(var d in h)Object.prototype.hasOwnProperty.call(h,d)&&this.setParam(d,h[d])}return n(t,[{key:"setParam",value:function(p,h){p&&(this._parameters[p.toLowerCase()]=typeof h>"u"||h===null?null:h.toString())}},{key:"getParam",value:function(p){if(p)return this._parameters[p.toLowerCase()]}},{key:"hasParam",value:function(p){if(p)return this._parameters.hasOwnProperty(p.toLowerCase())&&!0||!1}},{key:"deleteParam",value:function(p){if(p=p.toLowerCase(),this._parameters.hasOwnProperty(p)){var h=this._parameters[p];return delete this._parameters[p],h}}},{key:"clearParams",value:function(){this._parameters={}}},{key:"clone",value:function(){return new t(this._uri.clone(),this._display_name,JSON.parse(JSON.stringify(this._parameters)))}},{key:"_quote",value:function(p){return p.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}},{key:"toString",value:function(){var p=this._display_name?'"'.concat(this._quote(this._display_name),'" '):"";p+="<".concat(this._uri.toString(),">");for(var h in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,h)&&(p+=";".concat(h),this._parameters[h]!==null&&(p+="=".concat(this._parameters[h])));return p}},{key:"uri",get:function(){return this._uri}},{key:"display_name",get:function(){return this._display_name},set:function(p){this._display_name=p===0?"0":p}}]),t}(),bo}var Oo,yu;function Vt(){return yu||(yu=1,Oo=function(){function c(n){return'"'+n.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 r={parse:function(o,a){var t={CRLF:g,DIGIT:v,ALPHA:E,HEXDIG:S,WSP:C,OCTET:I,DQUOTE:w,SP:F,HTAB:L,alphanum:ie,reserved:N,unreserved:H,mark:ve,escaped:me,LWS:M,SWS:D,HCOLON:j,TEXT_UTF8_TRIM:V,TEXT_UTF8char:Y,UTF8_NONASCII:$,UTF8_CONT:X,LHEX:U,token:P,token_nodot:Z,separators:et,word:Q,STAR:W,SLASH:B,EQUAL:te,LPAREN:de,RPAREN:Ae,RAQUOT:Ue,LAQUOT:Se,COMMA:ne,SEMI:Te,COLON:tt,LDQUOT:st,RDQUOT:ge,comment:Ee,ctext:Ce,quoted_string:be,quoted_string_clean:he,qdtext:ce,quoted_pair:fe,SIP_URI_noparams:Re,SIP_URI:Oe,uri_scheme:Je,uri_scheme_sips:Me,uri_scheme_sip:Pt,userinfo:gt,user:On,user_unreserved:Dn,password:zs,hostport:Xt,host:hs,hostname:Js,domainlabel:Nn,toplabel:Un,IPv6reference:Xs,IPv6address:_e,h16:re,ls32:nt,IPv4address:qt,dec_octet:Rs,port:Kr,uri_parameters:Pn,uri_parameter:kn,transport_param:Wr,user_param:Yr,method_param:zr,ttl_param:Jr,maddr_param:Xr,lr_param:Qr,other_param:Zr,pname:ei,pvalue:Is,paramchar:bs,param_unreserved:ti,headers:Qs,header:Zs,hname:si,hvalue:ws,hnv_unreserved:en,Request_Response:ro,Request_Line:ni,Request_URI:Mn,absoluteURI:xn,hier_part:ri,net_path:tn,abs_path:sn,opaque_part:Os,uric:Ds,uric_no_slash:ii,path_segments:nn,segment:Ns,param:_s,pchar:Us,scheme:li,authority:oi,srvr:ai,reg_name:ui,query:Ln,SIP_Version:$n,INVITEm:ci,ACKm:fi,OPTIONSm:hi,BYEm:_i,CANCELm:di,REGISTERm:pi,SUBSCRIBEm:mi,NOTIFYm:gi,REFERm:rn,Method:ln,Status_Line:vi,Status_Code:Ti,extension_code:Ei,Reason_Phrase:io,Allow_Events:tu,Call_ID:su,Contact:Hn,contact_param:kt,name_addr:Mt,display_name:Ps,contact_params:Fn,c_p_q:yi,c_p_expires:Qt,delta_seconds:Zt,qvalue:Ge,generic_param:Ke,gen_value:lo,Content_Disposition:oo,disp_type:qn,disp_param:Vn,handling_param:ao,Content_Encoding:nu,Content_Length:ru,Content_Type:uo,media_type:Si,m_type:Ci,discrete_type:Ai,composite_type:on,extension_token:an,x_token:Ri,m_subtype:jn,m_parameter:Bn,m_value:co,CSeq:fo,CSeq_value:ho,Expires:iu,Event:un,event_type:cn,From:Ii,from_param:fn,tag_param:bi,Max_Forwards:lu,Min_Expires:ou,Name_Addr_Header:au,Proxy_Authenticate:wi,challenge:Gn,other_challenge:ks,auth_param:es,digest_cln:hn,realm:Oi,realm_value:Di,domain:_n,URI:dn,nonce:Ni,nonce_value:Ui,opaque:Pi,stale:ki,algorithm:Mi,qop_options:pn,qop_value:Kn,Proxy_Require:uu,Record_Route:Wn,rec_route:Yn,Reason:xi,reason_param:zn,reason_cause:_o,Require:cu,Route:Jn,route_param:Xn,Subscription_State:po,substate_value:Qn,subexp_params:Zn,event_reason_value:mo,Subject:fu,Supported:hu,To:Li,to_param:$i,Via:er,via_param:Ms,via_params:tr,via_ttl:Hi,via_maddr:Fi,via_received:qi,via_branch:Vi,response_port:ji,rport:Bi,sent_protocol:Gi,protocol_name:Ki,transport:Wi,sent_by:Yi,via_host:zi,via_port:sr,ttl:Ji,WWW_Authenticate:_u,Session_Expires:go,s_e_expires:nr,s_e_params:rr,s_e_refresher:vo,extension_header:To,header_value:Eo,message_body:du,uuid_URI:yo,uuid:xt,hex4:Lt,hex8:Xi,hex12:So,Refer_To:pu,Replaces:Co,call_id:ir,replaces_param:lr,to_tag:Qi,from_tag:Zi,early_flag:Ao};if(a!==void 0){if(t[a]===void 0)throw new Error("Invalid rule name: "+c(a)+".")}else a="CRLF";var s=0,p=0,h=[];function d(e){s<p||(s>p&&(p=s,h=[]),h.push(e))}function g(){var e;return o.substr(s,2)===`\r
|
1
|
+
(function(or,vt){typeof exports=="object"&&typeof module<"u"?module.exports=vt():typeof define=="function"&&define.amd?define(vt):(or=typeof globalThis<"u"?globalThis:or||self,or.OpensipsJS=vt())})(this,function(){"use strict";var or=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function vt(c){return c&&c.__esModule&&Object.prototype.hasOwnProperty.call(c,"default")?c.default:c}const sl={name:"jssip",title:"JsSIP",description:"the Javascript SIP library",version:"3.10.0",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"}};var vu=sl,Xe={USER_AGENT:"".concat(vu.title," ").concat(vu.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};function nl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?nl=function(n){return typeof n}:nl=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},nl(c)}function rl(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function il(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&ar(c,r)}function ll(c){var r=Tu();return function(){var o=ur(c),a;if(r){var t=ur(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return nh(this,a)}}function nh(c,r){return r&&(nl(r)==="object"||typeof r=="function")?r:rh(c)}function rh(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function mn(c){var r=typeof Map=="function"?new Map:void 0;return mn=function(o){if(o===null||!ih(o))return o;if(typeof o!="function")throw new TypeError("Super expression must either be null or a function");if(typeof r<"u"){if(r.has(o))return r.get(o);r.set(o,a)}function a(){return ol(o,arguments,ur(this).constructor)}return a.prototype=Object.create(o.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),ar(a,o)},mn(c)}function ol(c,r,n){return Tu()?ol=Reflect.construct:ol=function(a,t,s){var p=[null];p.push.apply(p,t);var h=Function.bind.apply(a,p),d=new h;return s&&ar(d,s.prototype),d},ol.apply(null,arguments)}function Tu(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function ih(c){return Function.toString.call(c).indexOf("[native code]")!==-1}function ar(c,r){return ar=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},ar(c,r)}function ur(c){return ur=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},ur(c)}var lh=function(c){il(n,c);var r=ll(n);function n(o,a){var t;return rl(this,n),t=r.call(this),t.code=1,t.name="CONFIGURATION_ERROR",t.parameter=o,t.value=a,t.message=t.value?"Invalid value ".concat(JSON.stringify(t.value),' for parameter "').concat(t.parameter,'"'):"Missing parameter: ".concat(t.parameter),t}return n}(mn(Error)),oh=function(c){il(n,c);var r=ll(n);function n(o){var a;return rl(this,n),a=r.call(this),a.code=2,a.name="INVALID_STATE_ERROR",a.status=o,a.message="Invalid status: ".concat(o),a}return n}(mn(Error)),ah=function(c){il(n,c);var r=ll(n);function n(o){var a;return rl(this,n),a=r.call(this),a.code=3,a.name="NOT_SUPPORTED_ERROR",a.message=o,a}return n}(mn(Error)),uh=function(c){il(n,c);var r=ll(n);function n(o){var a;return rl(this,n),a=r.call(this),a.code=4,a.name="NOT_READY_ERROR",a.message=o,a}return n}(mn(Error)),ms={ConfigurationError:lh,InvalidStateError:oh,NotSupportedError:ah,NotReadyError:uh},Ye={},bo,Eu;function wo(){if(Eu)return bo;Eu=1;function c(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function r(t,s){for(var p=0;p<s.length;p++){var h=s[p];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(t,h.key,h)}}function n(t,s,p){return s&&r(t.prototype,s),p&&r(t,p),t}var o=gs(),a=Vt();return bo=function(){n(t,null,[{key:"parse",value:function(p){if(p=a.parse(p,"Name_Addr_Header"),p!==-1)return p}}]);function t(s,p,h){if(c(this,t),!s||!(s instanceof o))throw new TypeError('missing or invalid "uri" parameter');this._uri=s,this._parameters={},this.display_name=p;for(var d in h)Object.prototype.hasOwnProperty.call(h,d)&&this.setParam(d,h[d])}return n(t,[{key:"setParam",value:function(p,h){p&&(this._parameters[p.toLowerCase()]=typeof h>"u"||h===null?null:h.toString())}},{key:"getParam",value:function(p){if(p)return this._parameters[p.toLowerCase()]}},{key:"hasParam",value:function(p){if(p)return this._parameters.hasOwnProperty(p.toLowerCase())&&!0||!1}},{key:"deleteParam",value:function(p){if(p=p.toLowerCase(),this._parameters.hasOwnProperty(p)){var h=this._parameters[p];return delete this._parameters[p],h}}},{key:"clearParams",value:function(){this._parameters={}}},{key:"clone",value:function(){return new t(this._uri.clone(),this._display_name,JSON.parse(JSON.stringify(this._parameters)))}},{key:"_quote",value:function(p){return p.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}},{key:"toString",value:function(){var p=this._display_name?'"'.concat(this._quote(this._display_name),'" '):"";p+="<".concat(this._uri.toString(),">");for(var h in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,h)&&(p+=";".concat(h),this._parameters[h]!==null&&(p+="=".concat(this._parameters[h])));return p}},{key:"uri",get:function(){return this._uri}},{key:"display_name",get:function(){return this._display_name},set:function(p){this._display_name=p===0?"0":p}}]),t}(),bo}var Oo,yu;function Vt(){return yu||(yu=1,Oo=function(){function c(n){return'"'+n.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 r={parse:function(o,a){var t={CRLF:g,DIGIT:v,ALPHA:E,HEXDIG:S,WSP:C,OCTET:I,DQUOTE:w,SP:F,HTAB:L,alphanum:ie,reserved:N,unreserved:H,mark:ve,escaped:me,LWS:M,SWS:D,HCOLON:j,TEXT_UTF8_TRIM:V,TEXT_UTF8char:Y,UTF8_NONASCII:$,UTF8_CONT:X,LHEX:U,token:P,token_nodot:Z,separators:et,word:Q,STAR:W,SLASH:B,EQUAL:te,LPAREN:de,RPAREN:Ae,RAQUOT:Ue,LAQUOT:Se,COMMA:ne,SEMI:Te,COLON:tt,LDQUOT:st,RDQUOT:ge,comment:Ee,ctext:Ce,quoted_string:be,quoted_string_clean:he,qdtext:ce,quoted_pair:fe,SIP_URI_noparams:Re,SIP_URI:Oe,uri_scheme:Je,uri_scheme_sips:Me,uri_scheme_sip:Pt,userinfo:gt,user:On,user_unreserved:Dn,password:zs,hostport:Qt,host:_s,hostname:Js,domainlabel:Nn,toplabel:Un,IPv6reference:Xs,IPv6address:_e,h16:re,ls32:nt,IPv4address:qt,dec_octet:Is,port:Kr,uri_parameters:Pn,uri_parameter:kn,transport_param:Wr,user_param:Yr,method_param:zr,ttl_param:Jr,maddr_param:Xr,lr_param:Qr,other_param:Zr,pname:ei,pvalue:bs,paramchar:ws,param_unreserved:ti,headers:Qs,header:Zs,hname:si,hvalue:Os,hnv_unreserved:en,Request_Response:ro,Request_Line:ni,Request_URI:Mn,absoluteURI:xn,hier_part:ri,net_path:tn,abs_path:sn,opaque_part:Ds,uric:Ns,uric_no_slash:ii,path_segments:nn,segment:Us,param:ds,pchar:Ps,scheme:li,authority:oi,srvr:ai,reg_name:ui,query:Ln,SIP_Version:$n,INVITEm:ci,ACKm:fi,OPTIONSm:hi,BYEm:_i,CANCELm:di,REGISTERm:pi,SUBSCRIBEm:mi,NOTIFYm:gi,REFERm:rn,Method:ln,Status_Line:vi,Status_Code:Ti,extension_code:Ei,Reason_Phrase:io,Allow_Events:tu,Call_ID:su,Contact:Hn,contact_param:kt,name_addr:Mt,display_name:ks,contact_params:Fn,c_p_q:yi,c_p_expires:Zt,delta_seconds:es,qvalue:Ge,generic_param:Ke,gen_value:lo,Content_Disposition:oo,disp_type:qn,disp_param:Vn,handling_param:ao,Content_Encoding:nu,Content_Length:ru,Content_Type:uo,media_type:Si,m_type:Ci,discrete_type:Ai,composite_type:on,extension_token:an,x_token:Ri,m_subtype:jn,m_parameter:Bn,m_value:co,CSeq:fo,CSeq_value:ho,Expires:iu,Event:un,event_type:cn,From:Ii,from_param:fn,tag_param:bi,Max_Forwards:lu,Min_Expires:ou,Name_Addr_Header:au,Proxy_Authenticate:wi,challenge:Gn,other_challenge:Ms,auth_param:ts,digest_cln:hn,realm:Oi,realm_value:Di,domain:_n,URI:dn,nonce:Ni,nonce_value:Ui,opaque:Pi,stale:ki,algorithm:Mi,qop_options:pn,qop_value:Kn,Proxy_Require:uu,Record_Route:Wn,rec_route:Yn,Reason:xi,reason_param:zn,reason_cause:_o,Require:cu,Route:Jn,route_param:Xn,Subscription_State:po,substate_value:Qn,subexp_params:Zn,event_reason_value:mo,Subject:fu,Supported:hu,To:Li,to_param:$i,Via:er,via_param:xs,via_params:tr,via_ttl:Hi,via_maddr:Fi,via_received:qi,via_branch:Vi,response_port:ji,rport:Bi,sent_protocol:Gi,protocol_name:Ki,transport:Wi,sent_by:Yi,via_host:zi,via_port:sr,ttl:Ji,WWW_Authenticate:_u,Session_Expires:go,s_e_expires:nr,s_e_params:rr,s_e_refresher:vo,extension_header:To,header_value:Eo,message_body:du,uuid_URI:yo,uuid:xt,hex4:Lt,hex8:Xi,hex12:So,Refer_To:pu,Replaces:Co,call_id:ir,replaces_param:lr,to_tag:Qi,from_tag:Zi,early_flag:Ao};if(a!==void 0){if(t[a]===void 0)throw new Error("Invalid rule name: "+c(a)+".")}else a="CRLF";var s=0,p=0,h=[];function d(e){s<p||(s>p&&(p=s,h=[]),h.push(e))}function g(){var e;return o.substr(s,2)===`\r
|
2
2
|
`?(e=`\r
|
3
|
-
`,s+=2):(e=null,d('"\\r\\n"')),e}function v(){var e;return/^[0-9]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[0-9]")),e}function E(){var e;return/^[a-zA-Z]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[a-zA-Z]")),e}function S(){var e;return/^[0-9a-fA-F]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[0-9a-fA-F]")),e}function C(){var e;return e=F(),e===null&&(e=L()),e}function I(){var e;return/^[\0-\xFF]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[\\0-\\xFF]")),e}function w(){var e;return/^["]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d('["]')),e}function F(){var e;return o.charCodeAt(s)===32?(e=" ",s++):(e=null,d('" "')),e}function L(){var e;return o.charCodeAt(s)===9?(e=" ",s++):(e=null,d('"\\t"')),e}function ie(){var e;return/^[a-zA-Z0-9]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[a-zA-Z0-9]")),e}function N(){var e;return o.charCodeAt(s)===59?(e=";",s++):(e=null,d('";"')),e===null&&(o.charCodeAt(s)===47?(e="/",s++):(e=null,d('"/"')),e===null&&(o.charCodeAt(s)===63?(e="?",s++):(e=null,d('"?"')),e===null&&(o.charCodeAt(s)===58?(e=":",s++):(e=null,d('":"')),e===null&&(o.charCodeAt(s)===64?(e="@",s++):(e=null,d('"@"')),e===null&&(o.charCodeAt(s)===38?(e="&",s++):(e=null,d('"&"')),e===null&&(o.charCodeAt(s)===61?(e="=",s++):(e=null,d('"="')),e===null&&(o.charCodeAt(s)===43?(e="+",s++):(e=null,d('"+"')),e===null&&(o.charCodeAt(s)===36?(e="$",s++):(e=null,d('"$"')),e===null&&(o.charCodeAt(s)===44?(e=",",s++):(e=null,d('","'))))))))))),e}function H(){var e;return e=ie(),e===null&&(e=ve()),e}function ve(){var e;return o.charCodeAt(s)===45?(e="-",s++):(e=null,d('"-"')),e===null&&(o.charCodeAt(s)===95?(e="_",s++):(e=null,d('"_"')),e===null&&(o.charCodeAt(s)===46?(e=".",s++):(e=null,d('"."')),e===null&&(o.charCodeAt(s)===33?(e="!",s++):(e=null,d('"!"')),e===null&&(o.charCodeAt(s)===126?(e="~",s++):(e=null,d('"~"')),e===null&&(o.charCodeAt(s)===42?(e="*",s++):(e=null,d('"*"')),e===null&&(o.charCodeAt(s)===39?(e="'",s++):(e=null,d(`"'"`)),e===null&&(o.charCodeAt(s)===40?(e="(",s++):(e=null,d('"("')),e===null&&(o.charCodeAt(s)===41?(e=")",s++):(e=null,d('")"')))))))))),e}function me(){var e,l,u,f,_;return f=s,_=s,o.charCodeAt(s)===37?(e="%",s++):(e=null,d('"%"')),e!==null?(l=S(),l!==null?(u=S(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){return T.join("")}(f,e)),e===null&&(s=f),e}function M(){var e,l,u,f,_,m;for(f=s,_=s,m=s,e=[],l=C();l!==null;)e.push(l),l=C();if(e!==null?(l=g(),l!==null?e=[e,l]:(e=null,s=m)):(e=null,s=m),e=e!==null?e:"",e!==null){if(u=C(),u!==null)for(l=[];u!==null;)l.push(u),u=C();else l=null;l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e!==null&&(e=function(T){return" "}()),e===null&&(s=f),e}function D(){var e;return e=M(),e=e!==null?e:"",e}function j(){var e,l,u,f,_;for(f=s,_=s,e=[],l=F(),l===null&&(l=L());l!==null;)e.push(l),l=F(),l===null&&(l=L());return e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m){return":"}()),e===null&&(s=f),e}function V(){var e,l,u,f,_,m,T;if(_=s,m=s,l=Y(),l!==null)for(e=[];l!==null;)e.push(l),l=Y();else e=null;if(e!==null){for(l=[],T=s,u=[],f=M();f!==null;)u.push(f),f=M();for(u!==null?(f=Y(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;){for(l.push(u),T=s,u=[],f=M();f!==null;)u.push(f),f=M();u!==null?(f=Y(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T)}l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y){return o.substring(s,y)}(_)),e===null&&(s=_),e}function Y(){var e;return/^[!-~]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[!-~]")),e===null&&(e=$()),e}function $(){var e;return/^[\x80-\uFFFF]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[\\x80-\\uFFFF]")),e}function X(){var e;return/^[\x80-\xBF]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[\\x80-\\xBF]")),e}function U(){var e;return e=v(),e===null&&(/^[a-f]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[a-f]"))),e}function P(){var e,l,u;if(u=s,l=ie(),l===null&&(o.charCodeAt(s)===45?(l="-",s++):(l=null,d('"-"')),l===null&&(o.charCodeAt(s)===46?(l=".",s++):(l=null,d('"."')),l===null&&(o.charCodeAt(s)===33?(l="!",s++):(l=null,d('"!"')),l===null&&(o.charCodeAt(s)===37?(l="%",s++):(l=null,d('"%"')),l===null&&(o.charCodeAt(s)===42?(l="*",s++):(l=null,d('"*"')),l===null&&(o.charCodeAt(s)===95?(l="_",s++):(l=null,d('"_"')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')),l===null&&(o.charCodeAt(s)===96?(l="`",s++):(l=null,d('"`"')),l===null&&(o.charCodeAt(s)===39?(l="'",s++):(l=null,d(`"'"`)),l===null&&(o.charCodeAt(s)===126?(l="~",s++):(l=null,d('"~"')))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=ie(),l===null&&(o.charCodeAt(s)===45?(l="-",s++):(l=null,d('"-"')),l===null&&(o.charCodeAt(s)===46?(l=".",s++):(l=null,d('"."')),l===null&&(o.charCodeAt(s)===33?(l="!",s++):(l=null,d('"!"')),l===null&&(o.charCodeAt(s)===37?(l="%",s++):(l=null,d('"%"')),l===null&&(o.charCodeAt(s)===42?(l="*",s++):(l=null,d('"*"')),l===null&&(o.charCodeAt(s)===95?(l="_",s++):(l=null,d('"_"')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')),l===null&&(o.charCodeAt(s)===96?(l="`",s++):(l=null,d('"`"')),l===null&&(o.charCodeAt(s)===39?(l="'",s++):(l=null,d(`"'"`)),l===null&&(o.charCodeAt(s)===126?(l="~",s++):(l=null,d('"~"'))))))))))));else e=null;return e!==null&&(e=function(f){return o.substring(s,f)}(u)),e===null&&(s=u),e}function Z(){var e,l,u;if(u=s,l=ie(),l===null&&(o.charCodeAt(s)===45?(l="-",s++):(l=null,d('"-"')),l===null&&(o.charCodeAt(s)===33?(l="!",s++):(l=null,d('"!"')),l===null&&(o.charCodeAt(s)===37?(l="%",s++):(l=null,d('"%"')),l===null&&(o.charCodeAt(s)===42?(l="*",s++):(l=null,d('"*"')),l===null&&(o.charCodeAt(s)===95?(l="_",s++):(l=null,d('"_"')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')),l===null&&(o.charCodeAt(s)===96?(l="`",s++):(l=null,d('"`"')),l===null&&(o.charCodeAt(s)===39?(l="'",s++):(l=null,d(`"'"`)),l===null&&(o.charCodeAt(s)===126?(l="~",s++):(l=null,d('"~"'))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=ie(),l===null&&(o.charCodeAt(s)===45?(l="-",s++):(l=null,d('"-"')),l===null&&(o.charCodeAt(s)===33?(l="!",s++):(l=null,d('"!"')),l===null&&(o.charCodeAt(s)===37?(l="%",s++):(l=null,d('"%"')),l===null&&(o.charCodeAt(s)===42?(l="*",s++):(l=null,d('"*"')),l===null&&(o.charCodeAt(s)===95?(l="_",s++):(l=null,d('"_"')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')),l===null&&(o.charCodeAt(s)===96?(l="`",s++):(l=null,d('"`"')),l===null&&(o.charCodeAt(s)===39?(l="'",s++):(l=null,d(`"'"`)),l===null&&(o.charCodeAt(s)===126?(l="~",s++):(l=null,d('"~"')))))))))));else e=null;return e!==null&&(e=function(f){return o.substring(s,f)}(u)),e===null&&(s=u),e}function et(){var e;return o.charCodeAt(s)===40?(e="(",s++):(e=null,d('"("')),e===null&&(o.charCodeAt(s)===41?(e=")",s++):(e=null,d('")"')),e===null&&(o.charCodeAt(s)===60?(e="<",s++):(e=null,d('"<"')),e===null&&(o.charCodeAt(s)===62?(e=">",s++):(e=null,d('">"')),e===null&&(o.charCodeAt(s)===64?(e="@",s++):(e=null,d('"@"')),e===null&&(o.charCodeAt(s)===44?(e=",",s++):(e=null,d('","')),e===null&&(o.charCodeAt(s)===59?(e=";",s++):(e=null,d('";"')),e===null&&(o.charCodeAt(s)===58?(e=":",s++):(e=null,d('":"')),e===null&&(o.charCodeAt(s)===92?(e="\\",s++):(e=null,d('"\\\\"')),e===null&&(e=w(),e===null&&(o.charCodeAt(s)===47?(e="/",s++):(e=null,d('"/"')),e===null&&(o.charCodeAt(s)===91?(e="[",s++):(e=null,d('"["')),e===null&&(o.charCodeAt(s)===93?(e="]",s++):(e=null,d('"]"')),e===null&&(o.charCodeAt(s)===63?(e="?",s++):(e=null,d('"?"')),e===null&&(o.charCodeAt(s)===61?(e="=",s++):(e=null,d('"="')),e===null&&(o.charCodeAt(s)===123?(e="{",s++):(e=null,d('"{"')),e===null&&(o.charCodeAt(s)===125?(e="}",s++):(e=null,d('"}"')),e===null&&(e=F(),e===null&&(e=L())))))))))))))))))),e}function Q(){var e,l,u;if(u=s,l=ie(),l===null&&(o.charCodeAt(s)===45?(l="-",s++):(l=null,d('"-"')),l===null&&(o.charCodeAt(s)===46?(l=".",s++):(l=null,d('"."')),l===null&&(o.charCodeAt(s)===33?(l="!",s++):(l=null,d('"!"')),l===null&&(o.charCodeAt(s)===37?(l="%",s++):(l=null,d('"%"')),l===null&&(o.charCodeAt(s)===42?(l="*",s++):(l=null,d('"*"')),l===null&&(o.charCodeAt(s)===95?(l="_",s++):(l=null,d('"_"')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')),l===null&&(o.charCodeAt(s)===96?(l="`",s++):(l=null,d('"`"')),l===null&&(o.charCodeAt(s)===39?(l="'",s++):(l=null,d(`"'"`)),l===null&&(o.charCodeAt(s)===126?(l="~",s++):(l=null,d('"~"')),l===null&&(o.charCodeAt(s)===40?(l="(",s++):(l=null,d('"("')),l===null&&(o.charCodeAt(s)===41?(l=")",s++):(l=null,d('")"')),l===null&&(o.charCodeAt(s)===60?(l="<",s++):(l=null,d('"<"')),l===null&&(o.charCodeAt(s)===62?(l=">",s++):(l=null,d('">"')),l===null&&(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l===null&&(o.charCodeAt(s)===92?(l="\\",s++):(l=null,d('"\\\\"')),l===null&&(l=w(),l===null&&(o.charCodeAt(s)===47?(l="/",s++):(l=null,d('"/"')),l===null&&(o.charCodeAt(s)===91?(l="[",s++):(l=null,d('"["')),l===null&&(o.charCodeAt(s)===93?(l="]",s++):(l=null,d('"]"')),l===null&&(o.charCodeAt(s)===63?(l="?",s++):(l=null,d('"?"')),l===null&&(o.charCodeAt(s)===123?(l="{",s++):(l=null,d('"{"')),l===null&&(o.charCodeAt(s)===125?(l="}",s++):(l=null,d('"}"'))))))))))))))))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=ie(),l===null&&(o.charCodeAt(s)===45?(l="-",s++):(l=null,d('"-"')),l===null&&(o.charCodeAt(s)===46?(l=".",s++):(l=null,d('"."')),l===null&&(o.charCodeAt(s)===33?(l="!",s++):(l=null,d('"!"')),l===null&&(o.charCodeAt(s)===37?(l="%",s++):(l=null,d('"%"')),l===null&&(o.charCodeAt(s)===42?(l="*",s++):(l=null,d('"*"')),l===null&&(o.charCodeAt(s)===95?(l="_",s++):(l=null,d('"_"')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')),l===null&&(o.charCodeAt(s)===96?(l="`",s++):(l=null,d('"`"')),l===null&&(o.charCodeAt(s)===39?(l="'",s++):(l=null,d(`"'"`)),l===null&&(o.charCodeAt(s)===126?(l="~",s++):(l=null,d('"~"')),l===null&&(o.charCodeAt(s)===40?(l="(",s++):(l=null,d('"("')),l===null&&(o.charCodeAt(s)===41?(l=")",s++):(l=null,d('")"')),l===null&&(o.charCodeAt(s)===60?(l="<",s++):(l=null,d('"<"')),l===null&&(o.charCodeAt(s)===62?(l=">",s++):(l=null,d('">"')),l===null&&(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l===null&&(o.charCodeAt(s)===92?(l="\\",s++):(l=null,d('"\\\\"')),l===null&&(l=w(),l===null&&(o.charCodeAt(s)===47?(l="/",s++):(l=null,d('"/"')),l===null&&(o.charCodeAt(s)===91?(l="[",s++):(l=null,d('"["')),l===null&&(o.charCodeAt(s)===93?(l="]",s++):(l=null,d('"]"')),l===null&&(o.charCodeAt(s)===63?(l="?",s++):(l=null,d('"?"')),l===null&&(o.charCodeAt(s)===123?(l="{",s++):(l=null,d('"{"')),l===null&&(o.charCodeAt(s)===125?(l="}",s++):(l=null,d('"}"')))))))))))))))))))))))));else e=null;return e!==null&&(e=function(f){return o.substring(s,f)}(u)),e===null&&(s=u),e}function W(){var e,l,u,f,_;return f=s,_=s,e=D(),e!==null?(o.charCodeAt(s)===42?(l="*",s++):(l=null,d('"*"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m){return"*"}()),e===null&&(s=f),e}function B(){var e,l,u,f,_;return f=s,_=s,e=D(),e!==null?(o.charCodeAt(s)===47?(l="/",s++):(l=null,d('"/"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m){return"/"}()),e===null&&(s=f),e}function te(){var e,l,u,f,_;return f=s,_=s,e=D(),e!==null?(o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m){return"="}()),e===null&&(s=f),e}function de(){var e,l,u,f,_;return f=s,_=s,e=D(),e!==null?(o.charCodeAt(s)===40?(l="(",s++):(l=null,d('"("')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m){return"("}()),e===null&&(s=f),e}function Ae(){var e,l,u,f,_;return f=s,_=s,e=D(),e!==null?(o.charCodeAt(s)===41?(l=")",s++):(l=null,d('")"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m){return")"}()),e===null&&(s=f),e}function Ue(){var e,l,u,f;return u=s,f=s,o.charCodeAt(s)===62?(e=">",s++):(e=null,d('">"')),e!==null?(l=D(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(_){return">"}()),e===null&&(s=u),e}function Se(){var e,l,u,f;return u=s,f=s,e=D(),e!==null?(o.charCodeAt(s)===60?(l="<",s++):(l=null,d('"<"')),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(_){return"<"}()),e===null&&(s=u),e}function ne(){var e,l,u,f,_;return f=s,_=s,e=D(),e!==null?(o.charCodeAt(s)===44?(l=",",s++):(l=null,d('","')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m){return","}()),e===null&&(s=f),e}function Te(){var e,l,u,f,_;return f=s,_=s,e=D(),e!==null?(o.charCodeAt(s)===59?(l=";",s++):(l=null,d('";"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m){return";"}()),e===null&&(s=f),e}function tt(){var e,l,u,f,_;return f=s,_=s,e=D(),e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m){return":"}()),e===null&&(s=f),e}function st(){var e,l,u,f;return u=s,f=s,e=D(),e!==null?(l=w(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(_){return'"'}()),e===null&&(s=u),e}function ge(){var e,l,u,f;return u=s,f=s,e=w(),e!==null?(l=D(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(_){return'"'}()),e===null&&(s=u),e}function Ee(){var e,l,u,f;if(f=s,e=de(),e!==null){for(l=[],u=Ce(),u===null&&(u=fe(),u===null&&(u=Ee()));u!==null;)l.push(u),u=Ce(),u===null&&(u=fe(),u===null&&(u=Ee()));l!==null?(u=Ae(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)}else e=null,s=f;return e}function Ce(){var e;return/^[!-']/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[!-']")),e===null&&(/^[*-[]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[*-[]")),e===null&&(/^[\]-~]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[\\]-~]")),e===null&&(e=$(),e===null&&(e=M())))),e}function be(){var e,l,u,f,_,m;if(_=s,m=s,e=D(),e!==null)if(l=w(),l!==null){for(u=[],f=ce(),f===null&&(f=fe());f!==null;)u.push(f),f=ce(),f===null&&(f=fe());u!==null?(f=w(),f!==null?e=[e,l,u,f]:(e=null,s=m)):(e=null,s=m)}else e=null,s=m;else e=null,s=m;return e!==null&&(e=function(T){return o.substring(s,T)}(_)),e===null&&(s=_),e}function he(){var e,l,u,f,_,m;if(_=s,m=s,e=D(),e!==null)if(l=w(),l!==null){for(u=[],f=ce(),f===null&&(f=fe());f!==null;)u.push(f),f=ce(),f===null&&(f=fe());u!==null?(f=w(),f!==null?e=[e,l,u,f]:(e=null,s=m)):(e=null,s=m)}else e=null,s=m;else e=null,s=m;return e!==null&&(e=function(T){var y=o.substring(s,T).trim();return y.substring(1,y.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(_)),e===null&&(s=_),e}function ce(){var e;return e=M(),e===null&&(o.charCodeAt(s)===33?(e="!",s++):(e=null,d('"!"')),e===null&&(/^[#-[]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[#-[]")),e===null&&(/^[\]-~]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[\\]-~]")),e===null&&(e=$())))),e}function fe(){var e,l,u;return u=s,o.charCodeAt(s)===92?(e="\\",s++):(e=null,d('"\\\\"')),e!==null?(/^[\0-\t]/.test(o.charAt(s))?(l=o.charAt(s),s++):(l=null,d("[\\0-\\t]")),l===null&&(/^[\x0B-\f]/.test(o.charAt(s))?(l=o.charAt(s),s++):(l=null,d("[\\x0B-\\f]")),l===null&&(/^[\x0E-]/.test(o.charAt(s))?(l=o.charAt(s),s++):(l=null,d("[\\x0E-]")))),l!==null?e=[e,l]:(e=null,s=u)):(e=null,s=u),e}function Re(){var e,l,u,f,_,m;return _=s,m=s,e=Je(),e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=gt(),u=u!==null?u:"",u!==null?(f=Xt(),f!==null?e=[e,l,u,f]:(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m),e!==null&&(e=function(T){try{b.uri=new ds(b.scheme,b.user,b.host,b.port),delete b.scheme,delete b.user,delete b.host,delete b.host_type,delete b.port}catch{b=-1}}()),e===null&&(s=_),e}function Oe(){var e,l,u,f,_,m,T,y;return T=s,y=s,e=Je(),e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=gt(),u=u!==null?u:"",u!==null?(f=Xt(),f!==null?(_=Pn(),_!==null?(m=Qs(),m=m!==null?m:"",m!==null?e=[e,l,u,f,_,m]:(e=null,s=y)):(e=null,s=y)):(e=null,s=y)):(e=null,s=y)):(e=null,s=y)):(e=null,s=y),e!==null&&(e=function(O){try{b.uri=new ds(b.scheme,b.user,b.host,b.port,b.uri_params,b.uri_headers),delete b.scheme,delete b.user,delete b.host,delete b.host_type,delete b.port,delete b.uri_params,a==="SIP_URI"&&(b=b.uri)}catch{b=-1}}()),e===null&&(s=T),e}function Je(){var e;return e=Me(),e===null&&(e=Pt()),e}function Me(){var e,l;return l=s,o.substr(s,4).toLowerCase()==="sips"?(e=o.substr(s,4),s+=4):(e=null,d('"sips"')),e!==null&&(e=function(u,f){b.scheme=f.toLowerCase()}(l,e)),e===null&&(s=l),e}function Pt(){var e,l;return l=s,o.substr(s,3).toLowerCase()==="sip"?(e=o.substr(s,3),s+=3):(e=null,d('"sip"')),e!==null&&(e=function(u,f){b.scheme=f.toLowerCase()}(l,e)),e===null&&(s=l),e}function gt(){var e,l,u,f,_,m;return f=s,_=s,e=On(),e!==null?(m=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=zs(),u!==null?l=[l,u]:(l=null,s=m)):(l=null,s=m),l=l!==null?l:"",l!==null?(o.charCodeAt(s)===64?(u="@",s++):(u=null,d('"@"')),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(T){b.user=decodeURIComponent(o.substring(s-1,T))}(f)),e===null&&(s=f),e}function On(){var e,l;if(l=H(),l===null&&(l=me(),l===null&&(l=Dn())),l!==null)for(e=[];l!==null;)e.push(l),l=H(),l===null&&(l=me(),l===null&&(l=Dn()));else e=null;return e}function Dn(){var e;return o.charCodeAt(s)===38?(e="&",s++):(e=null,d('"&"')),e===null&&(o.charCodeAt(s)===61?(e="=",s++):(e=null,d('"="')),e===null&&(o.charCodeAt(s)===43?(e="+",s++):(e=null,d('"+"')),e===null&&(o.charCodeAt(s)===36?(e="$",s++):(e=null,d('"$"')),e===null&&(o.charCodeAt(s)===44?(e=",",s++):(e=null,d('","')),e===null&&(o.charCodeAt(s)===59?(e=";",s++):(e=null,d('";"')),e===null&&(o.charCodeAt(s)===63?(e="?",s++):(e=null,d('"?"')),e===null&&(o.charCodeAt(s)===47?(e="/",s++):(e=null,d('"/"'))))))))),e}function zs(){var e,l,u;for(u=s,e=[],l=H(),l===null&&(l=me(),l===null&&(o.charCodeAt(s)===38?(l="&",s++):(l=null,d('"&"')),l===null&&(o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')),l===null&&(o.charCodeAt(s)===36?(l="$",s++):(l=null,d('"$"')),l===null&&(o.charCodeAt(s)===44?(l=",",s++):(l=null,d('","'))))))));l!==null;)e.push(l),l=H(),l===null&&(l=me(),l===null&&(o.charCodeAt(s)===38?(l="&",s++):(l=null,d('"&"')),l===null&&(o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')),l===null&&(o.charCodeAt(s)===36?(l="$",s++):(l=null,d('"$"')),l===null&&(o.charCodeAt(s)===44?(l=",",s++):(l=null,d('","'))))))));return e!==null&&(e=function(f){b.password=o.substring(s,f)}(u)),e===null&&(s=u),e}function Xt(){var e,l,u,f,_;return f=s,e=hs(),e!==null?(_=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=Kr(),u!==null?l=[l,u]:(l=null,s=_)):(l=null,s=_),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e}function hs(){var e,l;return l=s,e=Js(),e===null&&(e=qt(),e===null&&(e=Xs())),e!==null&&(e=function(u){return b.host=o.substring(s,u).toLowerCase(),b.host}(l)),e===null&&(s=l),e}function Js(){var e,l,u,f,_,m;for(f=s,_=s,e=[],m=s,l=Nn(),l!==null?(o.charCodeAt(s)===46?(u=".",s++):(u=null,d('"."')),u!==null?l=[l,u]:(l=null,s=m)):(l=null,s=m);l!==null;)e.push(l),m=s,l=Nn(),l!==null?(o.charCodeAt(s)===46?(u=".",s++):(u=null,d('"."')),u!==null?l=[l,u]:(l=null,s=m)):(l=null,s=m);return e!==null?(l=Un(),l!==null?(o.charCodeAt(s)===46?(u=".",s++):(u=null,d('"."')),u=u!==null?u:"",u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(T){return b.host_type="domain",o.substring(s,T)}(f)),e===null&&(s=f),e}function Nn(){var e,l,u,f;if(f=s,e=ie(),e!==null){for(l=[],u=ie(),u===null&&(o.charCodeAt(s)===45?(u="-",s++):(u=null,d('"-"')),u===null&&(o.charCodeAt(s)===95?(u="_",s++):(u=null,d('"_"'))));u!==null;)l.push(u),u=ie(),u===null&&(o.charCodeAt(s)===45?(u="-",s++):(u=null,d('"-"')),u===null&&(o.charCodeAt(s)===95?(u="_",s++):(u=null,d('"_"'))));l!==null?e=[e,l]:(e=null,s=f)}else e=null,s=f;return e}function Un(){var e,l,u,f;if(f=s,e=E(),e!==null){for(l=[],u=ie(),u===null&&(o.charCodeAt(s)===45?(u="-",s++):(u=null,d('"-"')),u===null&&(o.charCodeAt(s)===95?(u="_",s++):(u=null,d('"_"'))));u!==null;)l.push(u),u=ie(),u===null&&(o.charCodeAt(s)===45?(u="-",s++):(u=null,d('"-"')),u===null&&(o.charCodeAt(s)===95?(u="_",s++):(u=null,d('"_"'))));l!==null?e=[e,l]:(e=null,s=f)}else e=null,s=f;return e}function Xs(){var e,l,u,f,_;return f=s,_=s,o.charCodeAt(s)===91?(e="[",s++):(e=null,d('"["')),e!==null?(l=_e(),l!==null?(o.charCodeAt(s)===93?(u="]",s++):(u=null,d('"]"')),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m){return b.host_type="IPv6",o.substring(s,m)}(f)),e===null&&(s=f),e}function _e(){var e,l,u,f,_,m,T,y,O,se,De,At,xs,x,A,pe;return x=s,A=s,e=re(),e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=re(),u!==null?(o.charCodeAt(s)===58?(f=":",s++):(f=null,d('":"')),f!==null?(_=re(),_!==null?(o.charCodeAt(s)===58?(m=":",s++):(m=null,d('":"')),m!==null?(T=re(),T!==null?(o.charCodeAt(s)===58?(y=":",s++):(y=null,d('":"')),y!==null?(O=re(),O!==null?(o.charCodeAt(s)===58?(se=":",s++):(se=null,d('":"')),se!==null?(De=re(),De!==null?(o.charCodeAt(s)===58?(At=":",s++):(At=null,d('":"')),At!==null?(xs=nt(),xs!==null?e=[e,l,u,f,_,m,T,y,O,se,De,At,xs]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=re(),l!==null?(o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?(o.charCodeAt(s)===58?(_=":",s++):(_=null,d('":"')),_!==null?(m=re(),m!==null?(o.charCodeAt(s)===58?(T=":",s++):(T=null,d('":"')),T!==null?(y=re(),y!==null?(o.charCodeAt(s)===58?(O=":",s++):(O=null,d('":"')),O!==null?(se=re(),se!==null?(o.charCodeAt(s)===58?(De=":",s++):(De=null,d('":"')),De!==null?(At=nt(),At!==null?e=[e,l,u,f,_,m,T,y,O,se,De,At]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=re(),l!==null?(o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?(o.charCodeAt(s)===58?(_=":",s++):(_=null,d('":"')),_!==null?(m=re(),m!==null?(o.charCodeAt(s)===58?(T=":",s++):(T=null,d('":"')),T!==null?(y=re(),y!==null?(o.charCodeAt(s)===58?(O=":",s++):(O=null,d('":"')),O!==null?(se=nt(),se!==null?e=[e,l,u,f,_,m,T,y,O,se]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=re(),l!==null?(o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?(o.charCodeAt(s)===58?(_=":",s++):(_=null,d('":"')),_!==null?(m=re(),m!==null?(o.charCodeAt(s)===58?(T=":",s++):(T=null,d('":"')),T!==null?(y=nt(),y!==null?e=[e,l,u,f,_,m,T,y]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=re(),l!==null?(o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?(o.charCodeAt(s)===58?(_=":",s++):(_=null,d('":"')),_!==null?(m=nt(),m!==null?e=[e,l,u,f,_,m]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=re(),l!==null?(o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=nt(),f!==null?e=[e,l,u,f]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=nt(),l!==null?e=[e,l]:(e=null,s=A)):(e=null,s=A),e===null&&(A=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=re(),l!==null?e=[e,l]:(e=null,s=A)):(e=null,s=A),e===null&&(A=s,e=re(),e!==null?(o.substr(s,2)==="::"?(l="::",s+=2):(l=null,d('"::"')),l!==null?(u=re(),u!==null?(o.charCodeAt(s)===58?(f=":",s++):(f=null,d('":"')),f!==null?(_=re(),_!==null?(o.charCodeAt(s)===58?(m=":",s++):(m=null,d('":"')),m!==null?(T=re(),T!==null?(o.charCodeAt(s)===58?(y=":",s++):(y=null,d('":"')),y!==null?(O=re(),O!==null?(o.charCodeAt(s)===58?(se=":",s++):(se=null,d('":"')),se!==null?(De=nt(),De!==null?e=[e,l,u,f,_,m,T,y,O,se,De]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,e=re(),e!==null?(pe=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=re(),u!==null?l=[l,u]:(l=null,s=pe)):(l=null,s=pe),l=l!==null?l:"",l!==null?(o.substr(s,2)==="::"?(u="::",s+=2):(u=null,d('"::"')),u!==null?(f=re(),f!==null?(o.charCodeAt(s)===58?(_=":",s++):(_=null,d('":"')),_!==null?(m=re(),m!==null?(o.charCodeAt(s)===58?(T=":",s++):(T=null,d('":"')),T!==null?(y=re(),y!==null?(o.charCodeAt(s)===58?(O=":",s++):(O=null,d('":"')),O!==null?(se=nt(),se!==null?e=[e,l,u,f,_,m,T,y,O,se]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,e=re(),e!==null?(pe=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=re(),u!==null?l=[l,u]:(l=null,s=pe)):(l=null,s=pe),l=l!==null?l:"",l!==null?(pe=s,o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?u=[u,f]:(u=null,s=pe)):(u=null,s=pe),u=u!==null?u:"",u!==null?(o.substr(s,2)==="::"?(f="::",s+=2):(f=null,d('"::"')),f!==null?(_=re(),_!==null?(o.charCodeAt(s)===58?(m=":",s++):(m=null,d('":"')),m!==null?(T=re(),T!==null?(o.charCodeAt(s)===58?(y=":",s++):(y=null,d('":"')),y!==null?(O=nt(),O!==null?e=[e,l,u,f,_,m,T,y,O]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,e=re(),e!==null?(pe=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=re(),u!==null?l=[l,u]:(l=null,s=pe)):(l=null,s=pe),l=l!==null?l:"",l!==null?(pe=s,o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?u=[u,f]:(u=null,s=pe)):(u=null,s=pe),u=u!==null?u:"",u!==null?(pe=s,o.charCodeAt(s)===58?(f=":",s++):(f=null,d('":"')),f!==null?(_=re(),_!==null?f=[f,_]:(f=null,s=pe)):(f=null,s=pe),f=f!==null?f:"",f!==null?(o.substr(s,2)==="::"?(_="::",s+=2):(_=null,d('"::"')),_!==null?(m=re(),m!==null?(o.charCodeAt(s)===58?(T=":",s++):(T=null,d('":"')),T!==null?(y=nt(),y!==null?e=[e,l,u,f,_,m,T,y]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,e=re(),e!==null?(pe=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=re(),u!==null?l=[l,u]:(l=null,s=pe)):(l=null,s=pe),l=l!==null?l:"",l!==null?(pe=s,o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?u=[u,f]:(u=null,s=pe)):(u=null,s=pe),u=u!==null?u:"",u!==null?(pe=s,o.charCodeAt(s)===58?(f=":",s++):(f=null,d('":"')),f!==null?(_=re(),_!==null?f=[f,_]:(f=null,s=pe)):(f=null,s=pe),f=f!==null?f:"",f!==null?(pe=s,o.charCodeAt(s)===58?(_=":",s++):(_=null,d('":"')),_!==null?(m=re(),m!==null?_=[_,m]:(_=null,s=pe)):(_=null,s=pe),_=_!==null?_:"",_!==null?(o.substr(s,2)==="::"?(m="::",s+=2):(m=null,d('"::"')),m!==null?(T=nt(),T!==null?e=[e,l,u,f,_,m,T]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,e=re(),e!==null?(pe=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=re(),u!==null?l=[l,u]:(l=null,s=pe)):(l=null,s=pe),l=l!==null?l:"",l!==null?(pe=s,o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?u=[u,f]:(u=null,s=pe)):(u=null,s=pe),u=u!==null?u:"",u!==null?(pe=s,o.charCodeAt(s)===58?(f=":",s++):(f=null,d('":"')),f!==null?(_=re(),_!==null?f=[f,_]:(f=null,s=pe)):(f=null,s=pe),f=f!==null?f:"",f!==null?(pe=s,o.charCodeAt(s)===58?(_=":",s++):(_=null,d('":"')),_!==null?(m=re(),m!==null?_=[_,m]:(_=null,s=pe)):(_=null,s=pe),_=_!==null?_:"",_!==null?(pe=s,o.charCodeAt(s)===58?(m=":",s++):(m=null,d('":"')),m!==null?(T=re(),T!==null?m=[m,T]:(m=null,s=pe)):(m=null,s=pe),m=m!==null?m:"",m!==null?(o.substr(s,2)==="::"?(T="::",s+=2):(T=null,d('"::"')),T!==null?(y=re(),y!==null?e=[e,l,u,f,_,m,T,y]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,e=re(),e!==null?(pe=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=re(),u!==null?l=[l,u]:(l=null,s=pe)):(l=null,s=pe),l=l!==null?l:"",l!==null?(pe=s,o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?u=[u,f]:(u=null,s=pe)):(u=null,s=pe),u=u!==null?u:"",u!==null?(pe=s,o.charCodeAt(s)===58?(f=":",s++):(f=null,d('":"')),f!==null?(_=re(),_!==null?f=[f,_]:(f=null,s=pe)):(f=null,s=pe),f=f!==null?f:"",f!==null?(pe=s,o.charCodeAt(s)===58?(_=":",s++):(_=null,d('":"')),_!==null?(m=re(),m!==null?_=[_,m]:(_=null,s=pe)):(_=null,s=pe),_=_!==null?_:"",_!==null?(pe=s,o.charCodeAt(s)===58?(m=":",s++):(m=null,d('":"')),m!==null?(T=re(),T!==null?m=[m,T]:(m=null,s=pe)):(m=null,s=pe),m=m!==null?m:"",m!==null?(pe=s,o.charCodeAt(s)===58?(T=":",s++):(T=null,d('":"')),T!==null?(y=re(),y!==null?T=[T,y]:(T=null,s=pe)):(T=null,s=pe),T=T!==null?T:"",T!==null?(o.substr(s,2)==="::"?(y="::",s+=2):(y=null,d('"::"')),y!==null?e=[e,l,u,f,_,m,T,y]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A))))))))))))))),e!==null&&(e=function(Yv){return b.host_type="IPv6",o.substring(s,Yv)}(x)),e===null&&(s=x),e}function re(){var e,l,u,f,_;return _=s,e=S(),e!==null?(l=S(),l=l!==null?l:"",l!==null?(u=S(),u=u!==null?u:"",u!==null?(f=S(),f=f!==null?f:"",f!==null?e=[e,l,u,f]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e}function nt(){var e,l,u,f;return f=s,e=re(),e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=re(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e===null&&(e=qt()),e}function qt(){var e,l,u,f,_,m,T,y,O;return y=s,O=s,e=Rs(),e!==null?(o.charCodeAt(s)===46?(l=".",s++):(l=null,d('"."')),l!==null?(u=Rs(),u!==null?(o.charCodeAt(s)===46?(f=".",s++):(f=null,d('"."')),f!==null?(_=Rs(),_!==null?(o.charCodeAt(s)===46?(m=".",s++):(m=null,d('"."')),m!==null?(T=Rs(),T!==null?e=[e,l,u,f,_,m,T]:(e=null,s=O)):(e=null,s=O)):(e=null,s=O)):(e=null,s=O)):(e=null,s=O)):(e=null,s=O)):(e=null,s=O),e!==null&&(e=function(se){return b.host_type="IPv4",o.substring(s,se)}(y)),e===null&&(s=y),e}function Rs(){var e,l,u,f;return f=s,o.substr(s,2)==="25"?(e="25",s+=2):(e=null,d('"25"')),e!==null?(/^[0-5]/.test(o.charAt(s))?(l=o.charAt(s),s++):(l=null,d("[0-5]")),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e===null&&(f=s,o.charCodeAt(s)===50?(e="2",s++):(e=null,d('"2"')),e!==null?(/^[0-4]/.test(o.charAt(s))?(l=o.charAt(s),s++):(l=null,d("[0-4]")),l!==null?(u=v(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e===null&&(f=s,o.charCodeAt(s)===49?(e="1",s++):(e=null,d('"1"')),e!==null?(l=v(),l!==null?(u=v(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e===null&&(f=s,/^[1-9]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[1-9]")),e!==null?(l=v(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e===null&&(e=v())))),e}function Kr(){var e,l,u,f,_,m,T;return m=s,T=s,e=v(),e=e!==null?e:"",e!==null?(l=v(),l=l!==null?l:"",l!==null?(u=v(),u=u!==null?u:"",u!==null?(f=v(),f=f!==null?f:"",f!==null?(_=v(),_=_!==null?_:"",_!==null?e=[e,l,u,f,_]:(e=null,s=T)):(e=null,s=T)):(e=null,s=T)):(e=null,s=T)):(e=null,s=T),e!==null&&(e=function(y,O){return O=parseInt(O.join("")),b.port=O,O}(m,e)),e===null&&(s=m),e}function Pn(){var e,l,u,f;for(e=[],f=s,o.charCodeAt(s)===59?(l=";",s++):(l=null,d('";"')),l!==null?(u=kn(),u!==null?l=[l,u]:(l=null,s=f)):(l=null,s=f);l!==null;)e.push(l),f=s,o.charCodeAt(s)===59?(l=";",s++):(l=null,d('";"')),l!==null?(u=kn(),u!==null?l=[l,u]:(l=null,s=f)):(l=null,s=f);return e}function kn(){var e;return e=Wr(),e===null&&(e=Yr(),e===null&&(e=zr(),e===null&&(e=Jr(),e===null&&(e=Xr(),e===null&&(e=Qr(),e===null&&(e=Zr())))))),e}function Wr(){var e,l,u,f;return u=s,f=s,o.substr(s,10).toLowerCase()==="transport="?(e=o.substr(s,10),s+=10):(e=null,d('"transport="')),e!==null?(o.substr(s,3).toLowerCase()==="udp"?(l=o.substr(s,3),s+=3):(l=null,d('"udp"')),l===null&&(o.substr(s,3).toLowerCase()==="tcp"?(l=o.substr(s,3),s+=3):(l=null,d('"tcp"')),l===null&&(o.substr(s,4).toLowerCase()==="sctp"?(l=o.substr(s,4),s+=4):(l=null,d('"sctp"')),l===null&&(o.substr(s,3).toLowerCase()==="tls"?(l=o.substr(s,3),s+=3):(l=null,d('"tls"')),l===null&&(l=P())))),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(_,m){b.uri_params||(b.uri_params={}),b.uri_params.transport=m.toLowerCase()}(u,e[1])),e===null&&(s=u),e}function Yr(){var e,l,u,f;return u=s,f=s,o.substr(s,5).toLowerCase()==="user="?(e=o.substr(s,5),s+=5):(e=null,d('"user="')),e!==null?(o.substr(s,5).toLowerCase()==="phone"?(l=o.substr(s,5),s+=5):(l=null,d('"phone"')),l===null&&(o.substr(s,2).toLowerCase()==="ip"?(l=o.substr(s,2),s+=2):(l=null,d('"ip"')),l===null&&(l=P())),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(_,m){b.uri_params||(b.uri_params={}),b.uri_params.user=m.toLowerCase()}(u,e[1])),e===null&&(s=u),e}function zr(){var e,l,u,f;return u=s,f=s,o.substr(s,7).toLowerCase()==="method="?(e=o.substr(s,7),s+=7):(e=null,d('"method="')),e!==null?(l=ln(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(_,m){b.uri_params||(b.uri_params={}),b.uri_params.method=m}(u,e[1])),e===null&&(s=u),e}function Jr(){var e,l,u,f;return u=s,f=s,o.substr(s,4).toLowerCase()==="ttl="?(e=o.substr(s,4),s+=4):(e=null,d('"ttl="')),e!==null?(l=Ji(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(_,m){b.params||(b.params={}),b.params.ttl=m}(u,e[1])),e===null&&(s=u),e}function Xr(){var e,l,u,f;return u=s,f=s,o.substr(s,6).toLowerCase()==="maddr="?(e=o.substr(s,6),s+=6):(e=null,d('"maddr="')),e!==null?(l=hs(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(_,m){b.uri_params||(b.uri_params={}),b.uri_params.maddr=m}(u,e[1])),e===null&&(s=u),e}function Qr(){var e,l,u,f,_,m;return f=s,_=s,o.substr(s,2).toLowerCase()==="lr"?(e=o.substr(s,2),s+=2):(e=null,d('"lr"')),e!==null?(m=s,o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l!==null?(u=P(),u!==null?l=[l,u]:(l=null,s=m)):(l=null,s=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(T){b.uri_params||(b.uri_params={}),b.uri_params.lr=void 0}()),e===null&&(s=f),e}function Zr(){var e,l,u,f,_,m;return f=s,_=s,e=ei(),e!==null?(m=s,o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l!==null?(u=Is(),u!==null?l=[l,u]:(l=null,s=m)):(l=null,s=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(T,y,O){b.uri_params||(b.uri_params={}),typeof O>"u"?O=void 0:O=O[1],b.uri_params[y.toLowerCase()]=O}(f,e[0],e[1])),e===null&&(s=f),e}function ei(){var e,l,u;if(u=s,l=bs(),l!==null)for(e=[];l!==null;)e.push(l),l=bs();else e=null;return e!==null&&(e=function(f,_){return _.join("")}(u,e)),e===null&&(s=u),e}function Is(){var e,l,u;if(u=s,l=bs(),l!==null)for(e=[];l!==null;)e.push(l),l=bs();else e=null;return e!==null&&(e=function(f,_){return _.join("")}(u,e)),e===null&&(s=u),e}function bs(){var e;return e=ti(),e===null&&(e=H(),e===null&&(e=me())),e}function ti(){var e;return o.charCodeAt(s)===91?(e="[",s++):(e=null,d('"["')),e===null&&(o.charCodeAt(s)===93?(e="]",s++):(e=null,d('"]"')),e===null&&(o.charCodeAt(s)===47?(e="/",s++):(e=null,d('"/"')),e===null&&(o.charCodeAt(s)===58?(e=":",s++):(e=null,d('":"')),e===null&&(o.charCodeAt(s)===38?(e="&",s++):(e=null,d('"&"')),e===null&&(o.charCodeAt(s)===43?(e="+",s++):(e=null,d('"+"')),e===null&&(o.charCodeAt(s)===36?(e="$",s++):(e=null,d('"$"')))))))),e}function Qs(){var e,l,u,f,_,m,T;if(m=s,o.charCodeAt(s)===63?(e="?",s++):(e=null,d('"?"')),e!==null)if(l=Zs(),l!==null){for(u=[],T=s,o.charCodeAt(s)===38?(f="&",s++):(f=null,d('"&"')),f!==null?(_=Zs(),_!==null?f=[f,_]:(f=null,s=T)):(f=null,s=T);f!==null;)u.push(f),T=s,o.charCodeAt(s)===38?(f="&",s++):(f=null,d('"&"')),f!==null?(_=Zs(),_!==null?f=[f,_]:(f=null,s=T)):(f=null,s=T);u!==null?e=[e,l,u]:(e=null,s=m)}else e=null,s=m;else e=null,s=m;return e}function Zs(){var e,l,u,f,_;return f=s,_=s,e=si(),e!==null?(o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l!==null?(u=ws(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T,y){T=T.join("").toLowerCase(),y=y.join(""),b.uri_headers||(b.uri_headers={}),b.uri_headers[T]?b.uri_headers[T].push(y):b.uri_headers[T]=[y]}(f,e[0],e[2])),e===null&&(s=f),e}function si(){var e,l;if(l=en(),l===null&&(l=H(),l===null&&(l=me())),l!==null)for(e=[];l!==null;)e.push(l),l=en(),l===null&&(l=H(),l===null&&(l=me()));else e=null;return e}function ws(){var e,l;for(e=[],l=en(),l===null&&(l=H(),l===null&&(l=me()));l!==null;)e.push(l),l=en(),l===null&&(l=H(),l===null&&(l=me()));return e}function en(){var e;return o.charCodeAt(s)===91?(e="[",s++):(e=null,d('"["')),e===null&&(o.charCodeAt(s)===93?(e="]",s++):(e=null,d('"]"')),e===null&&(o.charCodeAt(s)===47?(e="/",s++):(e=null,d('"/"')),e===null&&(o.charCodeAt(s)===63?(e="?",s++):(e=null,d('"?"')),e===null&&(o.charCodeAt(s)===58?(e=":",s++):(e=null,d('":"')),e===null&&(o.charCodeAt(s)===43?(e="+",s++):(e=null,d('"+"')),e===null&&(o.charCodeAt(s)===36?(e="$",s++):(e=null,d('"$"')))))))),e}function ro(){var e;return e=vi(),e===null&&(e=ni()),e}function ni(){var e,l,u,f,_,m;return m=s,e=ln(),e!==null?(l=F(),l!==null?(u=Mn(),u!==null?(f=F(),f!==null?(_=$n(),_!==null?e=[e,l,u,f,_]:(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m),e}function Mn(){var e;return e=Oe(),e===null&&(e=xn()),e}function xn(){var e,l,u,f;return f=s,e=li(),e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=ri(),u===null&&(u=Os()),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function ri(){var e,l,u,f,_;return f=s,e=tn(),e===null&&(e=sn()),e!==null?(_=s,o.charCodeAt(s)===63?(l="?",s++):(l=null,d('"?"')),l!==null?(u=Ln(),u!==null?l=[l,u]:(l=null,s=_)):(l=null,s=_),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e}function tn(){var e,l,u,f;return f=s,o.substr(s,2)==="//"?(e="//",s+=2):(e=null,d('"//"')),e!==null?(l=oi(),l!==null?(u=sn(),u=u!==null?u:"",u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function sn(){var e,l,u;return u=s,o.charCodeAt(s)===47?(e="/",s++):(e=null,d('"/"')),e!==null?(l=nn(),l!==null?e=[e,l]:(e=null,s=u)):(e=null,s=u),e}function Os(){var e,l,u,f;if(f=s,e=ii(),e!==null){for(l=[],u=Ds();u!==null;)l.push(u),u=Ds();l!==null?e=[e,l]:(e=null,s=f)}else e=null,s=f;return e}function Ds(){var e;return e=N(),e===null&&(e=H(),e===null&&(e=me())),e}function ii(){var e;return e=H(),e===null&&(e=me(),e===null&&(o.charCodeAt(s)===59?(e=";",s++):(e=null,d('";"')),e===null&&(o.charCodeAt(s)===63?(e="?",s++):(e=null,d('"?"')),e===null&&(o.charCodeAt(s)===58?(e=":",s++):(e=null,d('":"')),e===null&&(o.charCodeAt(s)===64?(e="@",s++):(e=null,d('"@"')),e===null&&(o.charCodeAt(s)===38?(e="&",s++):(e=null,d('"&"')),e===null&&(o.charCodeAt(s)===61?(e="=",s++):(e=null,d('"="')),e===null&&(o.charCodeAt(s)===43?(e="+",s++):(e=null,d('"+"')),e===null&&(o.charCodeAt(s)===36?(e="$",s++):(e=null,d('"$"')),e===null&&(o.charCodeAt(s)===44?(e=",",s++):(e=null,d('","')))))))))))),e}function nn(){var e,l,u,f,_,m;if(_=s,e=Ns(),e!==null){for(l=[],m=s,o.charCodeAt(s)===47?(u="/",s++):(u=null,d('"/"')),u!==null?(f=Ns(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,o.charCodeAt(s)===47?(u="/",s++):(u=null,d('"/"')),u!==null?(f=Ns(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function Ns(){var e,l,u,f,_,m;for(_=s,e=[],l=Us();l!==null;)e.push(l),l=Us();if(e!==null){for(l=[],m=s,o.charCodeAt(s)===59?(u=";",s++):(u=null,d('";"')),u!==null?(f=_s(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,o.charCodeAt(s)===59?(u=";",s++):(u=null,d('";"')),u!==null?(f=_s(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function _s(){var e,l;for(e=[],l=Us();l!==null;)e.push(l),l=Us();return e}function Us(){var e;return e=H(),e===null&&(e=me(),e===null&&(o.charCodeAt(s)===58?(e=":",s++):(e=null,d('":"')),e===null&&(o.charCodeAt(s)===64?(e="@",s++):(e=null,d('"@"')),e===null&&(o.charCodeAt(s)===38?(e="&",s++):(e=null,d('"&"')),e===null&&(o.charCodeAt(s)===61?(e="=",s++):(e=null,d('"="')),e===null&&(o.charCodeAt(s)===43?(e="+",s++):(e=null,d('"+"')),e===null&&(o.charCodeAt(s)===36?(e="$",s++):(e=null,d('"$"')),e===null&&(o.charCodeAt(s)===44?(e=",",s++):(e=null,d('","')))))))))),e}function li(){var e,l,u,f,_;if(f=s,_=s,e=E(),e!==null){for(l=[],u=E(),u===null&&(u=v(),u===null&&(o.charCodeAt(s)===43?(u="+",s++):(u=null,d('"+"')),u===null&&(o.charCodeAt(s)===45?(u="-",s++):(u=null,d('"-"')),u===null&&(o.charCodeAt(s)===46?(u=".",s++):(u=null,d('"."'))))));u!==null;)l.push(u),u=E(),u===null&&(u=v(),u===null&&(o.charCodeAt(s)===43?(u="+",s++):(u=null,d('"+"')),u===null&&(o.charCodeAt(s)===45?(u="-",s++):(u=null,d('"-"')),u===null&&(o.charCodeAt(s)===46?(u=".",s++):(u=null,d('"."'))))));l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e!==null&&(e=function(m){b.scheme=o.substring(s,m)}(f)),e===null&&(s=f),e}function oi(){var e;return e=ai(),e===null&&(e=ui()),e}function ai(){var e,l,u,f;return u=s,f=s,e=gt(),e!==null?(o.charCodeAt(s)===64?(l="@",s++):(l=null,d('"@"')),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e=e!==null?e:"",e!==null?(l=Xt(),l!==null?e=[e,l]:(e=null,s=u)):(e=null,s=u),e=e!==null?e:"",e}function ui(){var e,l;if(l=H(),l===null&&(l=me(),l===null&&(o.charCodeAt(s)===36?(l="$",s++):(l=null,d('"$"')),l===null&&(o.charCodeAt(s)===44?(l=",",s++):(l=null,d('","')),l===null&&(o.charCodeAt(s)===59?(l=";",s++):(l=null,d('";"')),l===null&&(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l===null&&(o.charCodeAt(s)===64?(l="@",s++):(l=null,d('"@"')),l===null&&(o.charCodeAt(s)===38?(l="&",s++):(l=null,d('"&"')),l===null&&(o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"'))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=H(),l===null&&(l=me(),l===null&&(o.charCodeAt(s)===36?(l="$",s++):(l=null,d('"$"')),l===null&&(o.charCodeAt(s)===44?(l=",",s++):(l=null,d('","')),l===null&&(o.charCodeAt(s)===59?(l=";",s++):(l=null,d('";"')),l===null&&(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l===null&&(o.charCodeAt(s)===64?(l="@",s++):(l=null,d('"@"')),l===null&&(o.charCodeAt(s)===38?(l="&",s++):(l=null,d('"&"')),l===null&&(o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')))))))))));else e=null;return e}function Ln(){var e,l;for(e=[],l=Ds();l!==null;)e.push(l),l=Ds();return e}function $n(){var e,l,u,f,_,m,T,y;if(T=s,y=s,o.substr(s,3).toLowerCase()==="sip"?(e=o.substr(s,3),s+=3):(e=null,d('"SIP"')),e!==null)if(o.charCodeAt(s)===47?(l="/",s++):(l=null,d('"/"')),l!==null){if(f=v(),f!==null)for(u=[];f!==null;)u.push(f),f=v();else u=null;if(u!==null)if(o.charCodeAt(s)===46?(f=".",s++):(f=null,d('"."')),f!==null){if(m=v(),m!==null)for(_=[];m!==null;)_.push(m),m=v();else _=null;_!==null?e=[e,l,u,f,_]:(e=null,s=y)}else e=null,s=y;else e=null,s=y}else e=null,s=y;else e=null,s=y;return e!==null&&(e=function(O){b.sip_version=o.substring(s,O)}(T)),e===null&&(s=T),e}function ci(){var e;return o.substr(s,6)==="INVITE"?(e="INVITE",s+=6):(e=null,d('"INVITE"')),e}function fi(){var e;return o.substr(s,3)==="ACK"?(e="ACK",s+=3):(e=null,d('"ACK"')),e}function hi(){var e;return o.substr(s,7)==="OPTIONS"?(e="OPTIONS",s+=7):(e=null,d('"OPTIONS"')),e}function _i(){var e;return o.substr(s,3)==="BYE"?(e="BYE",s+=3):(e=null,d('"BYE"')),e}function di(){var e;return o.substr(s,6)==="CANCEL"?(e="CANCEL",s+=6):(e=null,d('"CANCEL"')),e}function pi(){var e;return o.substr(s,8)==="REGISTER"?(e="REGISTER",s+=8):(e=null,d('"REGISTER"')),e}function mi(){var e;return o.substr(s,9)==="SUBSCRIBE"?(e="SUBSCRIBE",s+=9):(e=null,d('"SUBSCRIBE"')),e}function gi(){var e;return o.substr(s,6)==="NOTIFY"?(e="NOTIFY",s+=6):(e=null,d('"NOTIFY"')),e}function rn(){var e;return o.substr(s,5)==="REFER"?(e="REFER",s+=5):(e=null,d('"REFER"')),e}function ln(){var e,l;return l=s,e=ci(),e===null&&(e=fi(),e===null&&(e=hi(),e===null&&(e=_i(),e===null&&(e=di(),e===null&&(e=pi(),e===null&&(e=mi(),e===null&&(e=gi(),e===null&&(e=rn(),e===null&&(e=P()))))))))),e!==null&&(e=function(u){return b.method=o.substring(s,u),b.method}(l)),e===null&&(s=l),e}function vi(){var e,l,u,f,_,m;return m=s,e=$n(),e!==null?(l=F(),l!==null?(u=Ti(),u!==null?(f=F(),f!==null?(_=io(),_!==null?e=[e,l,u,f,_]:(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m),e}function Ti(){var e,l;return l=s,e=Ei(),e!==null&&(e=function(u,f){b.status_code=parseInt(f.join(""))}(l,e)),e===null&&(s=l),e}function Ei(){var e,l,u,f;return f=s,e=v(),e!==null?(l=v(),l!==null?(u=v(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function io(){var e,l,u;for(u=s,e=[],l=N(),l===null&&(l=H(),l===null&&(l=me(),l===null&&(l=$(),l===null&&(l=X(),l===null&&(l=F(),l===null&&(l=L()))))));l!==null;)e.push(l),l=N(),l===null&&(l=H(),l===null&&(l=me(),l===null&&(l=$(),l===null&&(l=X(),l===null&&(l=F(),l===null&&(l=L()))))));return e!==null&&(e=function(f){b.reason_phrase=o.substring(s,f)}(u)),e===null&&(s=u),e}function tu(){var e,l,u,f,_,m;if(_=s,e=cn(),e!==null){for(l=[],m=s,u=ne(),u!==null?(f=cn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=ne(),u!==null?(f=cn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function su(){var e,l,u,f,_,m;return f=s,_=s,e=Q(),e!==null?(m=s,o.charCodeAt(s)===64?(l="@",s++):(l=null,d('"@"')),l!==null?(u=Q(),u!==null?l=[l,u]:(l=null,s=m)):(l=null,s=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(T){b=o.substring(s,T)}(f)),e===null&&(s=f),e}function Hn(){var e,l,u,f,_,m,T;if(_=s,e=W(),e===null)if(m=s,e=kt(),e!==null){for(l=[],T=s,u=ne(),u!==null?(f=kt(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=ne(),u!==null?(f=kt(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y){var O,se;for(se=b.multi_header.length,O=0;O<se;O++)if(b.multi_header[O].parsed===null){b=null;break}b!==null?b=b.multi_header:b=-1}()),e===null&&(s=_),e}function kt(){var e,l,u,f,_,m,T;if(_=s,m=s,e=Re(),e===null&&(e=Mt()),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=Fn(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=Te(),u!==null?(f=Fn(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y){var O;b.multi_header||(b.multi_header=[]);try{O=new R(b.uri,b.display_name,b.params),delete b.uri,delete b.display_name,delete b.params}catch{O=null}b.multi_header.push({possition:s,offset:y,parsed:O})}(_)),e===null&&(s=_),e}function Mt(){var e,l,u,f,_;return _=s,e=Ps(),e=e!==null?e:"",e!==null?(l=Se(),l!==null?(u=Oe(),u!==null?(f=Ue(),f!==null?e=[e,l,u,f]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e}function Ps(){var e,l,u,f,_,m,T;if(_=s,m=s,e=P(),e!==null){for(l=[],T=s,u=M(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=M(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e===null&&(e=he()),e!==null&&(e=function(y,O){typeof O=="string"?b.display_name=O:b.display_name=O[1].reduce(function(se,De){return se+De[0]+De[1]},O[0])}(_,e)),e===null&&(s=_),e}function Fn(){var e;return e=yi(),e===null&&(e=Qt(),e===null&&(e=Ke())),e}function yi(){var e,l,u,f,_;return f=s,_=s,o.substr(s,1).toLowerCase()==="q"?(e=o.substr(s,1),s++):(e=null,d('"q"')),e!==null?(l=te(),l!==null?(u=Ge(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){b.params||(b.params={}),b.params.q=T}(f,e[2])),e===null&&(s=f),e}function Qt(){var e,l,u,f,_;return f=s,_=s,o.substr(s,7).toLowerCase()==="expires"?(e=o.substr(s,7),s+=7):(e=null,d('"expires"')),e!==null?(l=te(),l!==null?(u=Zt(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){b.params||(b.params={}),b.params.expires=T}(f,e[2])),e===null&&(s=f),e}function Zt(){var e,l,u;if(u=s,l=v(),l!==null)for(e=[];l!==null;)e.push(l),l=v();else e=null;return e!==null&&(e=function(f,_){return parseInt(_.join(""))}(u,e)),e===null&&(s=u),e}function Ge(){var e,l,u,f,_,m,T,y;return m=s,T=s,o.charCodeAt(s)===48?(e="0",s++):(e=null,d('"0"')),e!==null?(y=s,o.charCodeAt(s)===46?(l=".",s++):(l=null,d('"."')),l!==null?(u=v(),u=u!==null?u:"",u!==null?(f=v(),f=f!==null?f:"",f!==null?(_=v(),_=_!==null?_:"",_!==null?l=[l,u,f,_]:(l=null,s=y)):(l=null,s=y)):(l=null,s=y)):(l=null,s=y),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=T)):(e=null,s=T),e!==null&&(e=function(O){return parseFloat(o.substring(s,O))}(m)),e===null&&(s=m),e}function Ke(){var e,l,u,f,_,m;return f=s,_=s,e=P(),e!==null?(m=s,l=te(),l!==null?(u=lo(),u!==null?l=[l,u]:(l=null,s=m)):(l=null,s=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(T,y,O){b.params||(b.params={}),typeof O>"u"?O=void 0:O=O[1],b.params[y.toLowerCase()]=O}(f,e[0],e[1])),e===null&&(s=f),e}function lo(){var e;return e=P(),e===null&&(e=hs(),e===null&&(e=be())),e}function oo(){var e,l,u,f,_,m;if(_=s,e=qn(),e!==null){for(l=[],m=s,u=Te(),u!==null?(f=Vn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=Te(),u!==null?(f=Vn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function qn(){var e;return o.substr(s,6).toLowerCase()==="render"?(e=o.substr(s,6),s+=6):(e=null,d('"render"')),e===null&&(o.substr(s,7).toLowerCase()==="session"?(e=o.substr(s,7),s+=7):(e=null,d('"session"')),e===null&&(o.substr(s,4).toLowerCase()==="icon"?(e=o.substr(s,4),s+=4):(e=null,d('"icon"')),e===null&&(o.substr(s,5).toLowerCase()==="alert"?(e=o.substr(s,5),s+=5):(e=null,d('"alert"')),e===null&&(e=P())))),e}function Vn(){var e;return e=ao(),e===null&&(e=Ke()),e}function ao(){var e,l,u,f;return f=s,o.substr(s,8).toLowerCase()==="handling"?(e=o.substr(s,8),s+=8):(e=null,d('"handling"')),e!==null?(l=te(),l!==null?(o.substr(s,8).toLowerCase()==="optional"?(u=o.substr(s,8),s+=8):(u=null,d('"optional"')),u===null&&(o.substr(s,8).toLowerCase()==="required"?(u=o.substr(s,8),s+=8):(u=null,d('"required"')),u===null&&(u=P())),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function nu(){var e,l,u,f,_,m;if(_=s,e=P(),e!==null){for(l=[],m=s,u=ne(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=ne(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function ru(){var e,l,u;if(u=s,l=v(),l!==null)for(e=[];l!==null;)e.push(l),l=v();else e=null;return e!==null&&(e=function(f,_){b=parseInt(_.join(""))}(u,e)),e===null&&(s=u),e}function uo(){var e,l;return l=s,e=Si(),e!==null&&(e=function(u){b=o.substring(s,u)}(l)),e===null&&(s=l),e}function Si(){var e,l,u,f,_,m,T,y;if(T=s,e=Ci(),e!==null)if(l=B(),l!==null)if(u=jn(),u!==null){for(f=[],y=s,_=Te(),_!==null?(m=Bn(),m!==null?_=[_,m]:(_=null,s=y)):(_=null,s=y);_!==null;)f.push(_),y=s,_=Te(),_!==null?(m=Bn(),m!==null?_=[_,m]:(_=null,s=y)):(_=null,s=y);f!==null?e=[e,l,u,f]:(e=null,s=T)}else e=null,s=T;else e=null,s=T;else e=null,s=T;return e}function Ci(){var e;return e=Ai(),e===null&&(e=on()),e}function Ai(){var e;return o.substr(s,4).toLowerCase()==="text"?(e=o.substr(s,4),s+=4):(e=null,d('"text"')),e===null&&(o.substr(s,5).toLowerCase()==="image"?(e=o.substr(s,5),s+=5):(e=null,d('"image"')),e===null&&(o.substr(s,5).toLowerCase()==="audio"?(e=o.substr(s,5),s+=5):(e=null,d('"audio"')),e===null&&(o.substr(s,5).toLowerCase()==="video"?(e=o.substr(s,5),s+=5):(e=null,d('"video"')),e===null&&(o.substr(s,11).toLowerCase()==="application"?(e=o.substr(s,11),s+=11):(e=null,d('"application"')),e===null&&(e=an()))))),e}function on(){var e;return o.substr(s,7).toLowerCase()==="message"?(e=o.substr(s,7),s+=7):(e=null,d('"message"')),e===null&&(o.substr(s,9).toLowerCase()==="multipart"?(e=o.substr(s,9),s+=9):(e=null,d('"multipart"')),e===null&&(e=an())),e}function an(){var e;return e=P(),e===null&&(e=Ri()),e}function Ri(){var e,l,u;return u=s,o.substr(s,2).toLowerCase()==="x-"?(e=o.substr(s,2),s+=2):(e=null,d('"x-"')),e!==null?(l=P(),l!==null?e=[e,l]:(e=null,s=u)):(e=null,s=u),e}function jn(){var e;return e=an(),e===null&&(e=P()),e}function Bn(){var e,l,u,f;return f=s,e=P(),e!==null?(l=te(),l!==null?(u=co(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function co(){var e;return e=P(),e===null&&(e=be()),e}function fo(){var e,l,u,f;return f=s,e=ho(),e!==null?(l=M(),l!==null?(u=ln(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function ho(){var e,l,u;if(u=s,l=v(),l!==null)for(e=[];l!==null;)e.push(l),l=v();else e=null;return e!==null&&(e=function(f,_){b.value=parseInt(_.join(""))}(u,e)),e===null&&(s=u),e}function iu(){var e,l;return l=s,e=Zt(),e!==null&&(e=function(u,f){b=f}(l,e)),e===null&&(s=l),e}function un(){var e,l,u,f,_,m,T;if(_=s,m=s,e=cn(),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=Ke(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=Te(),u!==null?(f=Ke(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y,O){b.event=O.join("").toLowerCase()}(_,e[0])),e===null&&(s=_),e}function cn(){var e,l,u,f,_,m;if(_=s,e=Z(),e!==null){for(l=[],m=s,o.charCodeAt(s)===46?(u=".",s++):(u=null,d('"."')),u!==null?(f=Z(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,o.charCodeAt(s)===46?(u=".",s++):(u=null,d('"."')),u!==null?(f=Z(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function Ii(){var e,l,u,f,_,m,T;if(_=s,m=s,e=Re(),e===null&&(e=Mt()),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=fn(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=Te(),u!==null?(f=fn(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y){var O=b.tag;try{b=new R(b.uri,b.display_name,b.params),O&&b.setParam("tag",O)}catch{b=-1}}()),e===null&&(s=_),e}function fn(){var e;return e=bi(),e===null&&(e=Ke()),e}function bi(){var e,l,u,f,_;return f=s,_=s,o.substr(s,3).toLowerCase()==="tag"?(e=o.substr(s,3),s+=3):(e=null,d('"tag"')),e!==null?(l=te(),l!==null?(u=P(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){b.tag=T}(f,e[2])),e===null&&(s=f),e}function lu(){var e,l,u;if(u=s,l=v(),l!==null)for(e=[];l!==null;)e.push(l),l=v();else e=null;return e!==null&&(e=function(f,_){b=parseInt(_.join(""))}(u,e)),e===null&&(s=u),e}function ou(){var e,l;return l=s,e=Zt(),e!==null&&(e=function(u,f){b=f}(l,e)),e===null&&(s=l),e}function au(){var e,l,u,f,_,m,T,y,O,se;for(y=s,O=s,e=[],l=Ps();l!==null;)e.push(l),l=Ps();if(e!==null)if(l=Se(),l!==null)if(u=Oe(),u!==null)if(f=Ue(),f!==null){for(_=[],se=s,m=Te(),m!==null?(T=Ke(),T!==null?m=[m,T]:(m=null,s=se)):(m=null,s=se);m!==null;)_.push(m),se=s,m=Te(),m!==null?(T=Ke(),T!==null?m=[m,T]:(m=null,s=se)):(m=null,s=se);_!==null?e=[e,l,u,f,_]:(e=null,s=O)}else e=null,s=O;else e=null,s=O;else e=null,s=O;else e=null,s=O;return e!==null&&(e=function(De){try{b=new R(b.uri,b.display_name,b.params)}catch{b=-1}}()),e===null&&(s=y),e}function wi(){var e;return e=Gn(),e}function Gn(){var e,l,u,f,_,m,T,y;if(T=s,o.substr(s,6).toLowerCase()==="digest"?(e=o.substr(s,6),s+=6):(e=null,d('"Digest"')),e!==null)if(l=M(),l!==null)if(u=hn(),u!==null){for(f=[],y=s,_=ne(),_!==null?(m=hn(),m!==null?_=[_,m]:(_=null,s=y)):(_=null,s=y);_!==null;)f.push(_),y=s,_=ne(),_!==null?(m=hn(),m!==null?_=[_,m]:(_=null,s=y)):(_=null,s=y);f!==null?e=[e,l,u,f]:(e=null,s=T)}else e=null,s=T;else e=null,s=T;else e=null,s=T;return e===null&&(e=ks()),e}function ks(){var e,l,u,f,_,m,T,y;if(T=s,e=P(),e!==null)if(l=M(),l!==null)if(u=es(),u!==null){for(f=[],y=s,_=ne(),_!==null?(m=es(),m!==null?_=[_,m]:(_=null,s=y)):(_=null,s=y);_!==null;)f.push(_),y=s,_=ne(),_!==null?(m=es(),m!==null?_=[_,m]:(_=null,s=y)):(_=null,s=y);f!==null?e=[e,l,u,f]:(e=null,s=T)}else e=null,s=T;else e=null,s=T;else e=null,s=T;return e}function es(){var e,l,u,f;return f=s,e=P(),e!==null?(l=te(),l!==null?(u=P(),u===null&&(u=be()),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function hn(){var e;return e=Oi(),e===null&&(e=_n(),e===null&&(e=Ni(),e===null&&(e=Pi(),e===null&&(e=ki(),e===null&&(e=Mi(),e===null&&(e=pn(),e===null&&(e=es()))))))),e}function Oi(){var e,l,u,f;return f=s,o.substr(s,5).toLowerCase()==="realm"?(e=o.substr(s,5),s+=5):(e=null,d('"realm"')),e!==null?(l=te(),l!==null?(u=Di(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function Di(){var e,l;return l=s,e=he(),e!==null&&(e=function(u,f){b.realm=f}(l,e)),e===null&&(s=l),e}function _n(){var e,l,u,f,_,m,T,y,O;if(y=s,o.substr(s,6).toLowerCase()==="domain"?(e=o.substr(s,6),s+=6):(e=null,d('"domain"')),e!==null)if(l=te(),l!==null)if(u=st(),u!==null)if(f=dn(),f!==null){if(_=[],O=s,T=F(),T!==null)for(m=[];T!==null;)m.push(T),T=F();else m=null;for(m!==null?(T=dn(),T!==null?m=[m,T]:(m=null,s=O)):(m=null,s=O);m!==null;){if(_.push(m),O=s,T=F(),T!==null)for(m=[];T!==null;)m.push(T),T=F();else m=null;m!==null?(T=dn(),T!==null?m=[m,T]:(m=null,s=O)):(m=null,s=O)}_!==null?(m=ge(),m!==null?e=[e,l,u,f,_,m]:(e=null,s=y)):(e=null,s=y)}else e=null,s=y;else e=null,s=y;else e=null,s=y;else e=null,s=y;return e}function dn(){var e;return e=xn(),e===null&&(e=sn()),e}function Ni(){var e,l,u,f;return f=s,o.substr(s,5).toLowerCase()==="nonce"?(e=o.substr(s,5),s+=5):(e=null,d('"nonce"')),e!==null?(l=te(),l!==null?(u=Ui(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function Ui(){var e,l;return l=s,e=he(),e!==null&&(e=function(u,f){b.nonce=f}(l,e)),e===null&&(s=l),e}function Pi(){var e,l,u,f,_;return f=s,_=s,o.substr(s,6).toLowerCase()==="opaque"?(e=o.substr(s,6),s+=6):(e=null,d('"opaque"')),e!==null?(l=te(),l!==null?(u=he(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){b.opaque=T}(f,e[2])),e===null&&(s=f),e}function ki(){var e,l,u,f,_;return f=s,o.substr(s,5).toLowerCase()==="stale"?(e=o.substr(s,5),s+=5):(e=null,d('"stale"')),e!==null?(l=te(),l!==null?(_=s,o.substr(s,4).toLowerCase()==="true"?(u=o.substr(s,4),s+=4):(u=null,d('"true"')),u!==null&&(u=function(m){b.stale=!0}()),u===null&&(s=_),u===null&&(_=s,o.substr(s,5).toLowerCase()==="false"?(u=o.substr(s,5),s+=5):(u=null,d('"false"')),u!==null&&(u=function(m){b.stale=!1}()),u===null&&(s=_)),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function Mi(){var e,l,u,f,_;return f=s,_=s,o.substr(s,9).toLowerCase()==="algorithm"?(e=o.substr(s,9),s+=9):(e=null,d('"algorithm"')),e!==null?(l=te(),l!==null?(o.substr(s,3).toLowerCase()==="md5"?(u=o.substr(s,3),s+=3):(u=null,d('"MD5"')),u===null&&(o.substr(s,8).toLowerCase()==="md5-sess"?(u=o.substr(s,8),s+=8):(u=null,d('"MD5-sess"')),u===null&&(u=P())),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){b.algorithm=T.toUpperCase()}(f,e[2])),e===null&&(s=f),e}function pn(){var e,l,u,f,_,m,T,y,O,se;if(y=s,o.substr(s,3).toLowerCase()==="qop"?(e=o.substr(s,3),s+=3):(e=null,d('"qop"')),e!==null)if(l=te(),l!==null)if(u=st(),u!==null){if(O=s,f=Kn(),f!==null){for(_=[],se=s,o.charCodeAt(s)===44?(m=",",s++):(m=null,d('","')),m!==null?(T=Kn(),T!==null?m=[m,T]:(m=null,s=se)):(m=null,s=se);m!==null;)_.push(m),se=s,o.charCodeAt(s)===44?(m=",",s++):(m=null,d('","')),m!==null?(T=Kn(),T!==null?m=[m,T]:(m=null,s=se)):(m=null,s=se);_!==null?f=[f,_]:(f=null,s=O)}else f=null,s=O;f!==null?(_=ge(),_!==null?e=[e,l,u,f,_]:(e=null,s=y)):(e=null,s=y)}else e=null,s=y;else e=null,s=y;else e=null,s=y;return e}function Kn(){var e,l;return l=s,o.substr(s,8).toLowerCase()==="auth-int"?(e=o.substr(s,8),s+=8):(e=null,d('"auth-int"')),e===null&&(o.substr(s,4).toLowerCase()==="auth"?(e=o.substr(s,4),s+=4):(e=null,d('"auth"')),e===null&&(e=P())),e!==null&&(e=function(u,f){b.qop||(b.qop=[]),b.qop.push(f.toLowerCase())}(l,e)),e===null&&(s=l),e}function uu(){var e,l,u,f,_,m;if(_=s,e=P(),e!==null){for(l=[],m=s,u=ne(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=ne(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function Wn(){var e,l,u,f,_,m,T;if(_=s,m=s,e=Yn(),e!==null){for(l=[],T=s,u=ne(),u!==null?(f=Yn(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=ne(),u!==null?(f=Yn(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y){var O,se;for(se=b.multi_header.length,O=0;O<se;O++)if(b.multi_header[O].parsed===null){b=null;break}b!==null?b=b.multi_header:b=-1}()),e===null&&(s=_),e}function Yn(){var e,l,u,f,_,m,T;if(_=s,m=s,e=Mt(),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=Ke(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=Te(),u!==null?(f=Ke(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y){var O;b.multi_header||(b.multi_header=[]);try{O=new R(b.uri,b.display_name,b.params),delete b.uri,delete b.display_name,delete b.params}catch{O=null}b.multi_header.push({possition:s,offset:y,parsed:O})}(_)),e===null&&(s=_),e}function xi(){var e,l,u,f,_,m,T;if(_=s,m=s,o.substr(s,3).toLowerCase()==="sip"?(e=o.substr(s,3),s+=3):(e=null,d('"SIP"')),e===null&&(e=P()),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=zn(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=Te(),u!==null?(f=zn(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y,O){if(b.protocol=O.toLowerCase(),b.params||(b.params={}),b.params.text&&b.params.text[0]==='"'){var se=b.params.text;b.text=se.substring(1,se.length-1),delete b.params.text}}(_,e[0])),e===null&&(s=_),e}function zn(){var e;return e=_o(),e===null&&(e=Ke()),e}function _o(){var e,l,u,f,_,m;if(_=s,m=s,o.substr(s,5).toLowerCase()==="cause"?(e=o.substr(s,5),s+=5):(e=null,d('"cause"')),e!==null)if(l=te(),l!==null){if(f=v(),f!==null)for(u=[];f!==null;)u.push(f),f=v();else u=null;u!==null?e=[e,l,u]:(e=null,s=m)}else e=null,s=m;else e=null,s=m;return e!==null&&(e=function(T,y){b.cause=parseInt(y.join(""))}(_,e[2])),e===null&&(s=_),e}function cu(){var e,l,u,f,_,m;if(_=s,e=P(),e!==null){for(l=[],m=s,u=ne(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=ne(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function Jn(){var e,l,u,f,_,m;if(_=s,e=Xn(),e!==null){for(l=[],m=s,u=ne(),u!==null?(f=Xn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=ne(),u!==null?(f=Xn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function Xn(){var e,l,u,f,_,m;if(_=s,e=Mt(),e!==null){for(l=[],m=s,u=Te(),u!==null?(f=Ke(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=Te(),u!==null?(f=Ke(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function po(){var e,l,u,f,_,m;if(_=s,e=Qn(),e!==null){for(l=[],m=s,u=Te(),u!==null?(f=Zn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=Te(),u!==null?(f=Zn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function Qn(){var e,l;return l=s,o.substr(s,6).toLowerCase()==="active"?(e=o.substr(s,6),s+=6):(e=null,d('"active"')),e===null&&(o.substr(s,7).toLowerCase()==="pending"?(e=o.substr(s,7),s+=7):(e=null,d('"pending"')),e===null&&(o.substr(s,10).toLowerCase()==="terminated"?(e=o.substr(s,10),s+=10):(e=null,d('"terminated"')),e===null&&(e=P()))),e!==null&&(e=function(u){b.state=o.substring(s,u)}(l)),e===null&&(s=l),e}function Zn(){var e,l,u,f,_;return f=s,_=s,o.substr(s,6).toLowerCase()==="reason"?(e=o.substr(s,6),s+=6):(e=null,d('"reason"')),e!==null?(l=te(),l!==null?(u=mo(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){typeof T<"u"&&(b.reason=T)}(f,e[2])),e===null&&(s=f),e===null&&(f=s,_=s,o.substr(s,7).toLowerCase()==="expires"?(e=o.substr(s,7),s+=7):(e=null,d('"expires"')),e!==null?(l=te(),l!==null?(u=Zt(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){typeof T<"u"&&(b.expires=T)}(f,e[2])),e===null&&(s=f),e===null&&(f=s,_=s,o.substr(s,11).toLowerCase()==="retry_after"?(e=o.substr(s,11),s+=11):(e=null,d('"retry_after"')),e!==null?(l=te(),l!==null?(u=Zt(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){typeof T<"u"&&(b.retry_after=T)}(f,e[2])),e===null&&(s=f),e===null&&(e=Ke()))),e}function mo(){var e;return o.substr(s,11).toLowerCase()==="deactivated"?(e=o.substr(s,11),s+=11):(e=null,d('"deactivated"')),e===null&&(o.substr(s,9).toLowerCase()==="probation"?(e=o.substr(s,9),s+=9):(e=null,d('"probation"')),e===null&&(o.substr(s,8).toLowerCase()==="rejected"?(e=o.substr(s,8),s+=8):(e=null,d('"rejected"')),e===null&&(o.substr(s,7).toLowerCase()==="timeout"?(e=o.substr(s,7),s+=7):(e=null,d('"timeout"')),e===null&&(o.substr(s,6).toLowerCase()==="giveup"?(e=o.substr(s,6),s+=6):(e=null,d('"giveup"')),e===null&&(o.substr(s,10).toLowerCase()==="noresource"?(e=o.substr(s,10),s+=10):(e=null,d('"noresource"')),e===null&&(o.substr(s,9).toLowerCase()==="invariant"?(e=o.substr(s,9),s+=9):(e=null,d('"invariant"')),e===null&&(e=P()))))))),e}function fu(){var e;return e=V(),e=e!==null?e:"",e}function hu(){var e,l,u,f,_,m;if(_=s,e=P(),e!==null){for(l=[],m=s,u=ne(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=ne(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e=e!==null?e:"",e}function Li(){var e,l,u,f,_,m,T;if(_=s,m=s,e=Re(),e===null&&(e=Mt()),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=$i(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=Te(),u!==null?(f=$i(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y){var O=b.tag;try{b=new R(b.uri,b.display_name,b.params),O&&b.setParam("tag",O)}catch{b=-1}}()),e===null&&(s=_),e}function $i(){var e;return e=bi(),e===null&&(e=Ke()),e}function er(){var e,l,u,f,_,m;if(_=s,e=Ms(),e!==null){for(l=[],m=s,u=ne(),u!==null?(f=Ms(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=ne(),u!==null?(f=Ms(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function Ms(){var e,l,u,f,_,m,T,y;if(T=s,e=Gi(),e!==null)if(l=M(),l!==null)if(u=Yi(),u!==null){for(f=[],y=s,_=Te(),_!==null?(m=tr(),m!==null?_=[_,m]:(_=null,s=y)):(_=null,s=y);_!==null;)f.push(_),y=s,_=Te(),_!==null?(m=tr(),m!==null?_=[_,m]:(_=null,s=y)):(_=null,s=y);f!==null?e=[e,l,u,f]:(e=null,s=T)}else e=null,s=T;else e=null,s=T;else e=null,s=T;return e}function tr(){var e;return e=Hi(),e===null&&(e=Fi(),e===null&&(e=qi(),e===null&&(e=Vi(),e===null&&(e=ji(),e===null&&(e=Ke()))))),e}function Hi(){var e,l,u,f,_;return f=s,_=s,o.substr(s,3).toLowerCase()==="ttl"?(e=o.substr(s,3),s+=3):(e=null,d('"ttl"')),e!==null?(l=te(),l!==null?(u=Ji(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){b.ttl=T}(f,e[2])),e===null&&(s=f),e}function Fi(){var e,l,u,f,_;return f=s,_=s,o.substr(s,5).toLowerCase()==="maddr"?(e=o.substr(s,5),s+=5):(e=null,d('"maddr"')),e!==null?(l=te(),l!==null?(u=hs(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){b.maddr=T}(f,e[2])),e===null&&(s=f),e}function qi(){var e,l,u,f,_;return f=s,_=s,o.substr(s,8).toLowerCase()==="received"?(e=o.substr(s,8),s+=8):(e=null,d('"received"')),e!==null?(l=te(),l!==null?(u=qt(),u===null&&(u=_e()),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){b.received=T}(f,e[2])),e===null&&(s=f),e}function Vi(){var e,l,u,f,_;return f=s,_=s,o.substr(s,6).toLowerCase()==="branch"?(e=o.substr(s,6),s+=6):(e=null,d('"branch"')),e!==null?(l=te(),l!==null?(u=P(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){b.branch=T}(f,e[2])),e===null&&(s=f),e}function ji(){var e,l,u,f,_;return f=s,o.substr(s,5).toLowerCase()==="rport"?(e=o.substr(s,5),s+=5):(e=null,d('"rport"')),e!==null?(_=s,l=te(),l!==null?(u=Bi(),u!==null?l=[l,u]:(l=null,s=_)):(l=null,s=_),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e}function Bi(){var e,l,u,f,_,m,T;return m=s,T=s,e=v(),e=e!==null?e:"",e!==null?(l=v(),l=l!==null?l:"",l!==null?(u=v(),u=u!==null?u:"",u!==null?(f=v(),f=f!==null?f:"",f!==null?(_=v(),_=_!==null?_:"",_!==null?e=[e,l,u,f,_]:(e=null,s=T)):(e=null,s=T)):(e=null,s=T)):(e=null,s=T)):(e=null,s=T),e!==null&&(e=function(y,O){b.rport=parseInt(O.join(""))}(m,e)),e===null&&(s=m),e}function Gi(){var e,l,u,f,_,m;return m=s,e=Ki(),e!==null?(l=B(),l!==null?(u=P(),u!==null?(f=B(),f!==null?(_=Wi(),_!==null?e=[e,l,u,f,_]:(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m),e}function Ki(){var e,l;return l=s,o.substr(s,3).toLowerCase()==="sip"?(e=o.substr(s,3),s+=3):(e=null,d('"SIP"')),e===null&&(e=P()),e!==null&&(e=function(u,f){b.protocol=f}(l,e)),e===null&&(s=l),e}function Wi(){var e,l;return l=s,o.substr(s,3).toLowerCase()==="udp"?(e=o.substr(s,3),s+=3):(e=null,d('"UDP"')),e===null&&(o.substr(s,3).toLowerCase()==="tcp"?(e=o.substr(s,3),s+=3):(e=null,d('"TCP"')),e===null&&(o.substr(s,3).toLowerCase()==="tls"?(e=o.substr(s,3),s+=3):(e=null,d('"TLS"')),e===null&&(o.substr(s,4).toLowerCase()==="sctp"?(e=o.substr(s,4),s+=4):(e=null,d('"SCTP"')),e===null&&(e=P())))),e!==null&&(e=function(u,f){b.transport=f}(l,e)),e===null&&(s=l),e}function Yi(){var e,l,u,f,_;return f=s,e=zi(),e!==null?(_=s,l=tt(),l!==null?(u=sr(),u!==null?l=[l,u]:(l=null,s=_)):(l=null,s=_),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e}function zi(){var e,l;return l=s,e=qt(),e===null&&(e=Xs(),e===null&&(e=Js())),e!==null&&(e=function(u){b.host=o.substring(s,u)}(l)),e===null&&(s=l),e}function sr(){var e,l,u,f,_,m,T;return m=s,T=s,e=v(),e=e!==null?e:"",e!==null?(l=v(),l=l!==null?l:"",l!==null?(u=v(),u=u!==null?u:"",u!==null?(f=v(),f=f!==null?f:"",f!==null?(_=v(),_=_!==null?_:"",_!==null?e=[e,l,u,f,_]:(e=null,s=T)):(e=null,s=T)):(e=null,s=T)):(e=null,s=T)):(e=null,s=T),e!==null&&(e=function(y,O){b.port=parseInt(O.join(""))}(m,e)),e===null&&(s=m),e}function Ji(){var e,l,u,f,_;return f=s,_=s,e=v(),e!==null?(l=v(),l=l!==null?l:"",l!==null?(u=v(),u=u!==null?u:"",u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){return parseInt(T.join(""))}(f,e)),e===null&&(s=f),e}function _u(){var e;return e=Gn(),e}function go(){var e,l,u,f,_,m;if(_=s,e=nr(),e!==null){for(l=[],m=s,u=Te(),u!==null?(f=rr(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=Te(),u!==null?(f=rr(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function nr(){var e,l;return l=s,e=Zt(),e!==null&&(e=function(u,f){b.expires=f}(l,e)),e===null&&(s=l),e}function rr(){var e;return e=vo(),e===null&&(e=Ke()),e}function vo(){var e,l,u,f,_;return f=s,_=s,o.substr(s,9).toLowerCase()==="refresher"?(e=o.substr(s,9),s+=9):(e=null,d('"refresher"')),e!==null?(l=te(),l!==null?(o.substr(s,3).toLowerCase()==="uac"?(u=o.substr(s,3),s+=3):(u=null,d('"uac"')),u===null&&(o.substr(s,3).toLowerCase()==="uas"?(u=o.substr(s,3),s+=3):(u=null,d('"uas"'))),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){b.refresher=T.toLowerCase()}(f,e[2])),e===null&&(s=f),e}function To(){var e,l,u,f;return f=s,e=P(),e!==null?(l=j(),l!==null?(u=Eo(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function Eo(){var e,l;for(e=[],l=Y(),l===null&&(l=X(),l===null&&(l=M()));l!==null;)e.push(l),l=Y(),l===null&&(l=X(),l===null&&(l=M()));return e}function du(){var e,l;for(e=[],l=I();l!==null;)e.push(l),l=I();return e}function yo(){var e,l,u;return u=s,o.substr(s,5)==="uuid:"?(e="uuid:",s+=5):(e=null,d('"uuid:"')),e!==null?(l=xt(),l!==null?e=[e,l]:(e=null,s=u)):(e=null,s=u),e}function xt(){var e,l,u,f,_,m,T,y,O,se,De;return se=s,De=s,e=Xi(),e!==null?(o.charCodeAt(s)===45?(l="-",s++):(l=null,d('"-"')),l!==null?(u=Lt(),u!==null?(o.charCodeAt(s)===45?(f="-",s++):(f=null,d('"-"')),f!==null?(_=Lt(),_!==null?(o.charCodeAt(s)===45?(m="-",s++):(m=null,d('"-"')),m!==null?(T=Lt(),T!==null?(o.charCodeAt(s)===45?(y="-",s++):(y=null,d('"-"')),y!==null?(O=So(),O!==null?e=[e,l,u,f,_,m,T,y,O]:(e=null,s=De)):(e=null,s=De)):(e=null,s=De)):(e=null,s=De)):(e=null,s=De)):(e=null,s=De)):(e=null,s=De)):(e=null,s=De)):(e=null,s=De),e!==null&&(e=function(At,xs){b=o.substring(s+5,At)}(se,e[0])),e===null&&(s=se),e}function Lt(){var e,l,u,f,_;return _=s,e=S(),e!==null?(l=S(),l!==null?(u=S(),u!==null?(f=S(),f!==null?e=[e,l,u,f]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e}function Xi(){var e,l,u;return u=s,e=Lt(),e!==null?(l=Lt(),l!==null?e=[e,l]:(e=null,s=u)):(e=null,s=u),e}function So(){var e,l,u,f;return f=s,e=Lt(),e!==null?(l=Lt(),l!==null?(u=Lt(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function pu(){var e,l,u,f,_,m,T;if(_=s,m=s,e=Re(),e===null&&(e=Mt()),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=Ke(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=Te(),u!==null?(f=Ke(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y){try{b=new R(b.uri,b.display_name,b.params)}catch{b=-1}}()),e===null&&(s=_),e}function Co(){var e,l,u,f,_,m;if(_=s,e=ir(),e!==null){for(l=[],m=s,u=Te(),u!==null?(f=lr(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=Te(),u!==null?(f=lr(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function ir(){var e,l,u,f,_,m;return f=s,_=s,e=Q(),e!==null?(m=s,o.charCodeAt(s)===64?(l="@",s++):(l=null,d('"@"')),l!==null?(u=Q(),u!==null?l=[l,u]:(l=null,s=m)):(l=null,s=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(T){b.call_id=o.substring(s,T)}(f)),e===null&&(s=f),e}function lr(){var e;return e=Qi(),e===null&&(e=Zi(),e===null&&(e=Ao(),e===null&&(e=Ke()))),e}function Qi(){var e,l,u,f,_;return f=s,_=s,o.substr(s,6)==="to-tag"?(e="to-tag",s+=6):(e=null,d('"to-tag"')),e!==null?(l=te(),l!==null?(u=P(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){b.to_tag=T}(f,e[2])),e===null&&(s=f),e}function Zi(){var e,l,u,f,_;return f=s,_=s,o.substr(s,8)==="from-tag"?(e="from-tag",s+=8):(e=null,d('"from-tag"')),e!==null?(l=te(),l!==null?(u=P(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){b.from_tag=T}(f,e[2])),e===null&&(s=f),e}function Ao(){var e,l;return l=s,o.substr(s,10)==="early-only"?(e="early-only",s+=10):(e=null,d('"early-only"')),e!==null&&(e=function(u){b.early_only=!0}()),e===null&&(s=l),e}function mu(e){e.sort();for(var l=null,u=[],f=0;f<e.length;f++)e[f]!==l&&(u.push(e[f]),l=e[f]);return u}function Ro(){for(var e=1,l=1,u=!1,f=0;f<Math.max(s,p);f++){var _=o.charAt(f);_===`
|
4
|
-
`?(u||e++,l=1,u=!1):_==="\r"||_==="\u2028"||_==="\u2029"?(e++,l=1,u=!0):(l++,u=!1)}return{line:e,column:l}}var
|
3
|
+
`,s+=2):(e=null,d('"\\r\\n"')),e}function v(){var e;return/^[0-9]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[0-9]")),e}function E(){var e;return/^[a-zA-Z]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[a-zA-Z]")),e}function S(){var e;return/^[0-9a-fA-F]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[0-9a-fA-F]")),e}function C(){var e;return e=F(),e===null&&(e=L()),e}function I(){var e;return/^[\0-\xFF]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[\\0-\\xFF]")),e}function w(){var e;return/^["]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d('["]')),e}function F(){var e;return o.charCodeAt(s)===32?(e=" ",s++):(e=null,d('" "')),e}function L(){var e;return o.charCodeAt(s)===9?(e=" ",s++):(e=null,d('"\\t"')),e}function ie(){var e;return/^[a-zA-Z0-9]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[a-zA-Z0-9]")),e}function N(){var e;return o.charCodeAt(s)===59?(e=";",s++):(e=null,d('";"')),e===null&&(o.charCodeAt(s)===47?(e="/",s++):(e=null,d('"/"')),e===null&&(o.charCodeAt(s)===63?(e="?",s++):(e=null,d('"?"')),e===null&&(o.charCodeAt(s)===58?(e=":",s++):(e=null,d('":"')),e===null&&(o.charCodeAt(s)===64?(e="@",s++):(e=null,d('"@"')),e===null&&(o.charCodeAt(s)===38?(e="&",s++):(e=null,d('"&"')),e===null&&(o.charCodeAt(s)===61?(e="=",s++):(e=null,d('"="')),e===null&&(o.charCodeAt(s)===43?(e="+",s++):(e=null,d('"+"')),e===null&&(o.charCodeAt(s)===36?(e="$",s++):(e=null,d('"$"')),e===null&&(o.charCodeAt(s)===44?(e=",",s++):(e=null,d('","'))))))))))),e}function H(){var e;return e=ie(),e===null&&(e=ve()),e}function ve(){var e;return o.charCodeAt(s)===45?(e="-",s++):(e=null,d('"-"')),e===null&&(o.charCodeAt(s)===95?(e="_",s++):(e=null,d('"_"')),e===null&&(o.charCodeAt(s)===46?(e=".",s++):(e=null,d('"."')),e===null&&(o.charCodeAt(s)===33?(e="!",s++):(e=null,d('"!"')),e===null&&(o.charCodeAt(s)===126?(e="~",s++):(e=null,d('"~"')),e===null&&(o.charCodeAt(s)===42?(e="*",s++):(e=null,d('"*"')),e===null&&(o.charCodeAt(s)===39?(e="'",s++):(e=null,d(`"'"`)),e===null&&(o.charCodeAt(s)===40?(e="(",s++):(e=null,d('"("')),e===null&&(o.charCodeAt(s)===41?(e=")",s++):(e=null,d('")"')))))))))),e}function me(){var e,l,u,f,_;return f=s,_=s,o.charCodeAt(s)===37?(e="%",s++):(e=null,d('"%"')),e!==null?(l=S(),l!==null?(u=S(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){return T.join("")}(f,e)),e===null&&(s=f),e}function M(){var e,l,u,f,_,m;for(f=s,_=s,m=s,e=[],l=C();l!==null;)e.push(l),l=C();if(e!==null?(l=g(),l!==null?e=[e,l]:(e=null,s=m)):(e=null,s=m),e=e!==null?e:"",e!==null){if(u=C(),u!==null)for(l=[];u!==null;)l.push(u),u=C();else l=null;l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e!==null&&(e=function(T){return" "}()),e===null&&(s=f),e}function D(){var e;return e=M(),e=e!==null?e:"",e}function j(){var e,l,u,f,_;for(f=s,_=s,e=[],l=F(),l===null&&(l=L());l!==null;)e.push(l),l=F(),l===null&&(l=L());return e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m){return":"}()),e===null&&(s=f),e}function V(){var e,l,u,f,_,m,T;if(_=s,m=s,l=Y(),l!==null)for(e=[];l!==null;)e.push(l),l=Y();else e=null;if(e!==null){for(l=[],T=s,u=[],f=M();f!==null;)u.push(f),f=M();for(u!==null?(f=Y(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;){for(l.push(u),T=s,u=[],f=M();f!==null;)u.push(f),f=M();u!==null?(f=Y(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T)}l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y){return o.substring(s,y)}(_)),e===null&&(s=_),e}function Y(){var e;return/^[!-~]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[!-~]")),e===null&&(e=$()),e}function $(){var e;return/^[\x80-\uFFFF]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[\\x80-\\uFFFF]")),e}function X(){var e;return/^[\x80-\xBF]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[\\x80-\\xBF]")),e}function U(){var e;return e=v(),e===null&&(/^[a-f]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[a-f]"))),e}function P(){var e,l,u;if(u=s,l=ie(),l===null&&(o.charCodeAt(s)===45?(l="-",s++):(l=null,d('"-"')),l===null&&(o.charCodeAt(s)===46?(l=".",s++):(l=null,d('"."')),l===null&&(o.charCodeAt(s)===33?(l="!",s++):(l=null,d('"!"')),l===null&&(o.charCodeAt(s)===37?(l="%",s++):(l=null,d('"%"')),l===null&&(o.charCodeAt(s)===42?(l="*",s++):(l=null,d('"*"')),l===null&&(o.charCodeAt(s)===95?(l="_",s++):(l=null,d('"_"')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')),l===null&&(o.charCodeAt(s)===96?(l="`",s++):(l=null,d('"`"')),l===null&&(o.charCodeAt(s)===39?(l="'",s++):(l=null,d(`"'"`)),l===null&&(o.charCodeAt(s)===126?(l="~",s++):(l=null,d('"~"')))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=ie(),l===null&&(o.charCodeAt(s)===45?(l="-",s++):(l=null,d('"-"')),l===null&&(o.charCodeAt(s)===46?(l=".",s++):(l=null,d('"."')),l===null&&(o.charCodeAt(s)===33?(l="!",s++):(l=null,d('"!"')),l===null&&(o.charCodeAt(s)===37?(l="%",s++):(l=null,d('"%"')),l===null&&(o.charCodeAt(s)===42?(l="*",s++):(l=null,d('"*"')),l===null&&(o.charCodeAt(s)===95?(l="_",s++):(l=null,d('"_"')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')),l===null&&(o.charCodeAt(s)===96?(l="`",s++):(l=null,d('"`"')),l===null&&(o.charCodeAt(s)===39?(l="'",s++):(l=null,d(`"'"`)),l===null&&(o.charCodeAt(s)===126?(l="~",s++):(l=null,d('"~"'))))))))))));else e=null;return e!==null&&(e=function(f){return o.substring(s,f)}(u)),e===null&&(s=u),e}function Z(){var e,l,u;if(u=s,l=ie(),l===null&&(o.charCodeAt(s)===45?(l="-",s++):(l=null,d('"-"')),l===null&&(o.charCodeAt(s)===33?(l="!",s++):(l=null,d('"!"')),l===null&&(o.charCodeAt(s)===37?(l="%",s++):(l=null,d('"%"')),l===null&&(o.charCodeAt(s)===42?(l="*",s++):(l=null,d('"*"')),l===null&&(o.charCodeAt(s)===95?(l="_",s++):(l=null,d('"_"')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')),l===null&&(o.charCodeAt(s)===96?(l="`",s++):(l=null,d('"`"')),l===null&&(o.charCodeAt(s)===39?(l="'",s++):(l=null,d(`"'"`)),l===null&&(o.charCodeAt(s)===126?(l="~",s++):(l=null,d('"~"'))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=ie(),l===null&&(o.charCodeAt(s)===45?(l="-",s++):(l=null,d('"-"')),l===null&&(o.charCodeAt(s)===33?(l="!",s++):(l=null,d('"!"')),l===null&&(o.charCodeAt(s)===37?(l="%",s++):(l=null,d('"%"')),l===null&&(o.charCodeAt(s)===42?(l="*",s++):(l=null,d('"*"')),l===null&&(o.charCodeAt(s)===95?(l="_",s++):(l=null,d('"_"')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')),l===null&&(o.charCodeAt(s)===96?(l="`",s++):(l=null,d('"`"')),l===null&&(o.charCodeAt(s)===39?(l="'",s++):(l=null,d(`"'"`)),l===null&&(o.charCodeAt(s)===126?(l="~",s++):(l=null,d('"~"')))))))))));else e=null;return e!==null&&(e=function(f){return o.substring(s,f)}(u)),e===null&&(s=u),e}function et(){var e;return o.charCodeAt(s)===40?(e="(",s++):(e=null,d('"("')),e===null&&(o.charCodeAt(s)===41?(e=")",s++):(e=null,d('")"')),e===null&&(o.charCodeAt(s)===60?(e="<",s++):(e=null,d('"<"')),e===null&&(o.charCodeAt(s)===62?(e=">",s++):(e=null,d('">"')),e===null&&(o.charCodeAt(s)===64?(e="@",s++):(e=null,d('"@"')),e===null&&(o.charCodeAt(s)===44?(e=",",s++):(e=null,d('","')),e===null&&(o.charCodeAt(s)===59?(e=";",s++):(e=null,d('";"')),e===null&&(o.charCodeAt(s)===58?(e=":",s++):(e=null,d('":"')),e===null&&(o.charCodeAt(s)===92?(e="\\",s++):(e=null,d('"\\\\"')),e===null&&(e=w(),e===null&&(o.charCodeAt(s)===47?(e="/",s++):(e=null,d('"/"')),e===null&&(o.charCodeAt(s)===91?(e="[",s++):(e=null,d('"["')),e===null&&(o.charCodeAt(s)===93?(e="]",s++):(e=null,d('"]"')),e===null&&(o.charCodeAt(s)===63?(e="?",s++):(e=null,d('"?"')),e===null&&(o.charCodeAt(s)===61?(e="=",s++):(e=null,d('"="')),e===null&&(o.charCodeAt(s)===123?(e="{",s++):(e=null,d('"{"')),e===null&&(o.charCodeAt(s)===125?(e="}",s++):(e=null,d('"}"')),e===null&&(e=F(),e===null&&(e=L())))))))))))))))))),e}function Q(){var e,l,u;if(u=s,l=ie(),l===null&&(o.charCodeAt(s)===45?(l="-",s++):(l=null,d('"-"')),l===null&&(o.charCodeAt(s)===46?(l=".",s++):(l=null,d('"."')),l===null&&(o.charCodeAt(s)===33?(l="!",s++):(l=null,d('"!"')),l===null&&(o.charCodeAt(s)===37?(l="%",s++):(l=null,d('"%"')),l===null&&(o.charCodeAt(s)===42?(l="*",s++):(l=null,d('"*"')),l===null&&(o.charCodeAt(s)===95?(l="_",s++):(l=null,d('"_"')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')),l===null&&(o.charCodeAt(s)===96?(l="`",s++):(l=null,d('"`"')),l===null&&(o.charCodeAt(s)===39?(l="'",s++):(l=null,d(`"'"`)),l===null&&(o.charCodeAt(s)===126?(l="~",s++):(l=null,d('"~"')),l===null&&(o.charCodeAt(s)===40?(l="(",s++):(l=null,d('"("')),l===null&&(o.charCodeAt(s)===41?(l=")",s++):(l=null,d('")"')),l===null&&(o.charCodeAt(s)===60?(l="<",s++):(l=null,d('"<"')),l===null&&(o.charCodeAt(s)===62?(l=">",s++):(l=null,d('">"')),l===null&&(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l===null&&(o.charCodeAt(s)===92?(l="\\",s++):(l=null,d('"\\\\"')),l===null&&(l=w(),l===null&&(o.charCodeAt(s)===47?(l="/",s++):(l=null,d('"/"')),l===null&&(o.charCodeAt(s)===91?(l="[",s++):(l=null,d('"["')),l===null&&(o.charCodeAt(s)===93?(l="]",s++):(l=null,d('"]"')),l===null&&(o.charCodeAt(s)===63?(l="?",s++):(l=null,d('"?"')),l===null&&(o.charCodeAt(s)===123?(l="{",s++):(l=null,d('"{"')),l===null&&(o.charCodeAt(s)===125?(l="}",s++):(l=null,d('"}"'))))))))))))))))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=ie(),l===null&&(o.charCodeAt(s)===45?(l="-",s++):(l=null,d('"-"')),l===null&&(o.charCodeAt(s)===46?(l=".",s++):(l=null,d('"."')),l===null&&(o.charCodeAt(s)===33?(l="!",s++):(l=null,d('"!"')),l===null&&(o.charCodeAt(s)===37?(l="%",s++):(l=null,d('"%"')),l===null&&(o.charCodeAt(s)===42?(l="*",s++):(l=null,d('"*"')),l===null&&(o.charCodeAt(s)===95?(l="_",s++):(l=null,d('"_"')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')),l===null&&(o.charCodeAt(s)===96?(l="`",s++):(l=null,d('"`"')),l===null&&(o.charCodeAt(s)===39?(l="'",s++):(l=null,d(`"'"`)),l===null&&(o.charCodeAt(s)===126?(l="~",s++):(l=null,d('"~"')),l===null&&(o.charCodeAt(s)===40?(l="(",s++):(l=null,d('"("')),l===null&&(o.charCodeAt(s)===41?(l=")",s++):(l=null,d('")"')),l===null&&(o.charCodeAt(s)===60?(l="<",s++):(l=null,d('"<"')),l===null&&(o.charCodeAt(s)===62?(l=">",s++):(l=null,d('">"')),l===null&&(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l===null&&(o.charCodeAt(s)===92?(l="\\",s++):(l=null,d('"\\\\"')),l===null&&(l=w(),l===null&&(o.charCodeAt(s)===47?(l="/",s++):(l=null,d('"/"')),l===null&&(o.charCodeAt(s)===91?(l="[",s++):(l=null,d('"["')),l===null&&(o.charCodeAt(s)===93?(l="]",s++):(l=null,d('"]"')),l===null&&(o.charCodeAt(s)===63?(l="?",s++):(l=null,d('"?"')),l===null&&(o.charCodeAt(s)===123?(l="{",s++):(l=null,d('"{"')),l===null&&(o.charCodeAt(s)===125?(l="}",s++):(l=null,d('"}"')))))))))))))))))))))))));else e=null;return e!==null&&(e=function(f){return o.substring(s,f)}(u)),e===null&&(s=u),e}function W(){var e,l,u,f,_;return f=s,_=s,e=D(),e!==null?(o.charCodeAt(s)===42?(l="*",s++):(l=null,d('"*"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m){return"*"}()),e===null&&(s=f),e}function B(){var e,l,u,f,_;return f=s,_=s,e=D(),e!==null?(o.charCodeAt(s)===47?(l="/",s++):(l=null,d('"/"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m){return"/"}()),e===null&&(s=f),e}function te(){var e,l,u,f,_;return f=s,_=s,e=D(),e!==null?(o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m){return"="}()),e===null&&(s=f),e}function de(){var e,l,u,f,_;return f=s,_=s,e=D(),e!==null?(o.charCodeAt(s)===40?(l="(",s++):(l=null,d('"("')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m){return"("}()),e===null&&(s=f),e}function Ae(){var e,l,u,f,_;return f=s,_=s,e=D(),e!==null?(o.charCodeAt(s)===41?(l=")",s++):(l=null,d('")"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m){return")"}()),e===null&&(s=f),e}function Ue(){var e,l,u,f;return u=s,f=s,o.charCodeAt(s)===62?(e=">",s++):(e=null,d('">"')),e!==null?(l=D(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(_){return">"}()),e===null&&(s=u),e}function Se(){var e,l,u,f;return u=s,f=s,e=D(),e!==null?(o.charCodeAt(s)===60?(l="<",s++):(l=null,d('"<"')),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(_){return"<"}()),e===null&&(s=u),e}function ne(){var e,l,u,f,_;return f=s,_=s,e=D(),e!==null?(o.charCodeAt(s)===44?(l=",",s++):(l=null,d('","')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m){return","}()),e===null&&(s=f),e}function Te(){var e,l,u,f,_;return f=s,_=s,e=D(),e!==null?(o.charCodeAt(s)===59?(l=";",s++):(l=null,d('";"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m){return";"}()),e===null&&(s=f),e}function tt(){var e,l,u,f,_;return f=s,_=s,e=D(),e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=D(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m){return":"}()),e===null&&(s=f),e}function st(){var e,l,u,f;return u=s,f=s,e=D(),e!==null?(l=w(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(_){return'"'}()),e===null&&(s=u),e}function ge(){var e,l,u,f;return u=s,f=s,e=w(),e!==null?(l=D(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(_){return'"'}()),e===null&&(s=u),e}function Ee(){var e,l,u,f;if(f=s,e=de(),e!==null){for(l=[],u=Ce(),u===null&&(u=fe(),u===null&&(u=Ee()));u!==null;)l.push(u),u=Ce(),u===null&&(u=fe(),u===null&&(u=Ee()));l!==null?(u=Ae(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)}else e=null,s=f;return e}function Ce(){var e;return/^[!-']/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[!-']")),e===null&&(/^[*-[]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[*-[]")),e===null&&(/^[\]-~]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[\\]-~]")),e===null&&(e=$(),e===null&&(e=M())))),e}function be(){var e,l,u,f,_,m;if(_=s,m=s,e=D(),e!==null)if(l=w(),l!==null){for(u=[],f=ce(),f===null&&(f=fe());f!==null;)u.push(f),f=ce(),f===null&&(f=fe());u!==null?(f=w(),f!==null?e=[e,l,u,f]:(e=null,s=m)):(e=null,s=m)}else e=null,s=m;else e=null,s=m;return e!==null&&(e=function(T){return o.substring(s,T)}(_)),e===null&&(s=_),e}function he(){var e,l,u,f,_,m;if(_=s,m=s,e=D(),e!==null)if(l=w(),l!==null){for(u=[],f=ce(),f===null&&(f=fe());f!==null;)u.push(f),f=ce(),f===null&&(f=fe());u!==null?(f=w(),f!==null?e=[e,l,u,f]:(e=null,s=m)):(e=null,s=m)}else e=null,s=m;else e=null,s=m;return e!==null&&(e=function(T){var y=o.substring(s,T).trim();return y.substring(1,y.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(_)),e===null&&(s=_),e}function ce(){var e;return e=M(),e===null&&(o.charCodeAt(s)===33?(e="!",s++):(e=null,d('"!"')),e===null&&(/^[#-[]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[#-[]")),e===null&&(/^[\]-~]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[\\]-~]")),e===null&&(e=$())))),e}function fe(){var e,l,u;return u=s,o.charCodeAt(s)===92?(e="\\",s++):(e=null,d('"\\\\"')),e!==null?(/^[\0-\t]/.test(o.charAt(s))?(l=o.charAt(s),s++):(l=null,d("[\\0-\\t]")),l===null&&(/^[\x0B-\f]/.test(o.charAt(s))?(l=o.charAt(s),s++):(l=null,d("[\\x0B-\\f]")),l===null&&(/^[\x0E-]/.test(o.charAt(s))?(l=o.charAt(s),s++):(l=null,d("[\\x0E-]")))),l!==null?e=[e,l]:(e=null,s=u)):(e=null,s=u),e}function Re(){var e,l,u,f,_,m;return _=s,m=s,e=Je(),e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=gt(),u=u!==null?u:"",u!==null?(f=Qt(),f!==null?e=[e,l,u,f]:(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m),e!==null&&(e=function(T){try{b.uri=new ps(b.scheme,b.user,b.host,b.port),delete b.scheme,delete b.user,delete b.host,delete b.host_type,delete b.port}catch{b=-1}}()),e===null&&(s=_),e}function Oe(){var e,l,u,f,_,m,T,y;return T=s,y=s,e=Je(),e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=gt(),u=u!==null?u:"",u!==null?(f=Qt(),f!==null?(_=Pn(),_!==null?(m=Qs(),m=m!==null?m:"",m!==null?e=[e,l,u,f,_,m]:(e=null,s=y)):(e=null,s=y)):(e=null,s=y)):(e=null,s=y)):(e=null,s=y)):(e=null,s=y),e!==null&&(e=function(O){try{b.uri=new ps(b.scheme,b.user,b.host,b.port,b.uri_params,b.uri_headers),delete b.scheme,delete b.user,delete b.host,delete b.host_type,delete b.port,delete b.uri_params,a==="SIP_URI"&&(b=b.uri)}catch{b=-1}}()),e===null&&(s=T),e}function Je(){var e;return e=Me(),e===null&&(e=Pt()),e}function Me(){var e,l;return l=s,o.substr(s,4).toLowerCase()==="sips"?(e=o.substr(s,4),s+=4):(e=null,d('"sips"')),e!==null&&(e=function(u,f){b.scheme=f.toLowerCase()}(l,e)),e===null&&(s=l),e}function Pt(){var e,l;return l=s,o.substr(s,3).toLowerCase()==="sip"?(e=o.substr(s,3),s+=3):(e=null,d('"sip"')),e!==null&&(e=function(u,f){b.scheme=f.toLowerCase()}(l,e)),e===null&&(s=l),e}function gt(){var e,l,u,f,_,m;return f=s,_=s,e=On(),e!==null?(m=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=zs(),u!==null?l=[l,u]:(l=null,s=m)):(l=null,s=m),l=l!==null?l:"",l!==null?(o.charCodeAt(s)===64?(u="@",s++):(u=null,d('"@"')),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(T){b.user=decodeURIComponent(o.substring(s-1,T))}(f)),e===null&&(s=f),e}function On(){var e,l;if(l=H(),l===null&&(l=me(),l===null&&(l=Dn())),l!==null)for(e=[];l!==null;)e.push(l),l=H(),l===null&&(l=me(),l===null&&(l=Dn()));else e=null;return e}function Dn(){var e;return o.charCodeAt(s)===38?(e="&",s++):(e=null,d('"&"')),e===null&&(o.charCodeAt(s)===61?(e="=",s++):(e=null,d('"="')),e===null&&(o.charCodeAt(s)===43?(e="+",s++):(e=null,d('"+"')),e===null&&(o.charCodeAt(s)===36?(e="$",s++):(e=null,d('"$"')),e===null&&(o.charCodeAt(s)===44?(e=",",s++):(e=null,d('","')),e===null&&(o.charCodeAt(s)===59?(e=";",s++):(e=null,d('";"')),e===null&&(o.charCodeAt(s)===63?(e="?",s++):(e=null,d('"?"')),e===null&&(o.charCodeAt(s)===47?(e="/",s++):(e=null,d('"/"'))))))))),e}function zs(){var e,l,u;for(u=s,e=[],l=H(),l===null&&(l=me(),l===null&&(o.charCodeAt(s)===38?(l="&",s++):(l=null,d('"&"')),l===null&&(o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')),l===null&&(o.charCodeAt(s)===36?(l="$",s++):(l=null,d('"$"')),l===null&&(o.charCodeAt(s)===44?(l=",",s++):(l=null,d('","'))))))));l!==null;)e.push(l),l=H(),l===null&&(l=me(),l===null&&(o.charCodeAt(s)===38?(l="&",s++):(l=null,d('"&"')),l===null&&(o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')),l===null&&(o.charCodeAt(s)===36?(l="$",s++):(l=null,d('"$"')),l===null&&(o.charCodeAt(s)===44?(l=",",s++):(l=null,d('","'))))))));return e!==null&&(e=function(f){b.password=o.substring(s,f)}(u)),e===null&&(s=u),e}function Qt(){var e,l,u,f,_;return f=s,e=_s(),e!==null?(_=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=Kr(),u!==null?l=[l,u]:(l=null,s=_)):(l=null,s=_),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e}function _s(){var e,l;return l=s,e=Js(),e===null&&(e=qt(),e===null&&(e=Xs())),e!==null&&(e=function(u){return b.host=o.substring(s,u).toLowerCase(),b.host}(l)),e===null&&(s=l),e}function Js(){var e,l,u,f,_,m;for(f=s,_=s,e=[],m=s,l=Nn(),l!==null?(o.charCodeAt(s)===46?(u=".",s++):(u=null,d('"."')),u!==null?l=[l,u]:(l=null,s=m)):(l=null,s=m);l!==null;)e.push(l),m=s,l=Nn(),l!==null?(o.charCodeAt(s)===46?(u=".",s++):(u=null,d('"."')),u!==null?l=[l,u]:(l=null,s=m)):(l=null,s=m);return e!==null?(l=Un(),l!==null?(o.charCodeAt(s)===46?(u=".",s++):(u=null,d('"."')),u=u!==null?u:"",u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(T){return b.host_type="domain",o.substring(s,T)}(f)),e===null&&(s=f),e}function Nn(){var e,l,u,f;if(f=s,e=ie(),e!==null){for(l=[],u=ie(),u===null&&(o.charCodeAt(s)===45?(u="-",s++):(u=null,d('"-"')),u===null&&(o.charCodeAt(s)===95?(u="_",s++):(u=null,d('"_"'))));u!==null;)l.push(u),u=ie(),u===null&&(o.charCodeAt(s)===45?(u="-",s++):(u=null,d('"-"')),u===null&&(o.charCodeAt(s)===95?(u="_",s++):(u=null,d('"_"'))));l!==null?e=[e,l]:(e=null,s=f)}else e=null,s=f;return e}function Un(){var e,l,u,f;if(f=s,e=E(),e!==null){for(l=[],u=ie(),u===null&&(o.charCodeAt(s)===45?(u="-",s++):(u=null,d('"-"')),u===null&&(o.charCodeAt(s)===95?(u="_",s++):(u=null,d('"_"'))));u!==null;)l.push(u),u=ie(),u===null&&(o.charCodeAt(s)===45?(u="-",s++):(u=null,d('"-"')),u===null&&(o.charCodeAt(s)===95?(u="_",s++):(u=null,d('"_"'))));l!==null?e=[e,l]:(e=null,s=f)}else e=null,s=f;return e}function Xs(){var e,l,u,f,_;return f=s,_=s,o.charCodeAt(s)===91?(e="[",s++):(e=null,d('"["')),e!==null?(l=_e(),l!==null?(o.charCodeAt(s)===93?(u="]",s++):(u=null,d('"]"')),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m){return b.host_type="IPv6",o.substring(s,m)}(f)),e===null&&(s=f),e}function _e(){var e,l,u,f,_,m,T,y,O,se,De,At,Ls,x,A,pe;return x=s,A=s,e=re(),e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=re(),u!==null?(o.charCodeAt(s)===58?(f=":",s++):(f=null,d('":"')),f!==null?(_=re(),_!==null?(o.charCodeAt(s)===58?(m=":",s++):(m=null,d('":"')),m!==null?(T=re(),T!==null?(o.charCodeAt(s)===58?(y=":",s++):(y=null,d('":"')),y!==null?(O=re(),O!==null?(o.charCodeAt(s)===58?(se=":",s++):(se=null,d('":"')),se!==null?(De=re(),De!==null?(o.charCodeAt(s)===58?(At=":",s++):(At=null,d('":"')),At!==null?(Ls=nt(),Ls!==null?e=[e,l,u,f,_,m,T,y,O,se,De,At,Ls]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=re(),l!==null?(o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?(o.charCodeAt(s)===58?(_=":",s++):(_=null,d('":"')),_!==null?(m=re(),m!==null?(o.charCodeAt(s)===58?(T=":",s++):(T=null,d('":"')),T!==null?(y=re(),y!==null?(o.charCodeAt(s)===58?(O=":",s++):(O=null,d('":"')),O!==null?(se=re(),se!==null?(o.charCodeAt(s)===58?(De=":",s++):(De=null,d('":"')),De!==null?(At=nt(),At!==null?e=[e,l,u,f,_,m,T,y,O,se,De,At]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=re(),l!==null?(o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?(o.charCodeAt(s)===58?(_=":",s++):(_=null,d('":"')),_!==null?(m=re(),m!==null?(o.charCodeAt(s)===58?(T=":",s++):(T=null,d('":"')),T!==null?(y=re(),y!==null?(o.charCodeAt(s)===58?(O=":",s++):(O=null,d('":"')),O!==null?(se=nt(),se!==null?e=[e,l,u,f,_,m,T,y,O,se]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=re(),l!==null?(o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?(o.charCodeAt(s)===58?(_=":",s++):(_=null,d('":"')),_!==null?(m=re(),m!==null?(o.charCodeAt(s)===58?(T=":",s++):(T=null,d('":"')),T!==null?(y=nt(),y!==null?e=[e,l,u,f,_,m,T,y]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=re(),l!==null?(o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?(o.charCodeAt(s)===58?(_=":",s++):(_=null,d('":"')),_!==null?(m=nt(),m!==null?e=[e,l,u,f,_,m]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=re(),l!==null?(o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=nt(),f!==null?e=[e,l,u,f]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=nt(),l!==null?e=[e,l]:(e=null,s=A)):(e=null,s=A),e===null&&(A=s,o.substr(s,2)==="::"?(e="::",s+=2):(e=null,d('"::"')),e!==null?(l=re(),l!==null?e=[e,l]:(e=null,s=A)):(e=null,s=A),e===null&&(A=s,e=re(),e!==null?(o.substr(s,2)==="::"?(l="::",s+=2):(l=null,d('"::"')),l!==null?(u=re(),u!==null?(o.charCodeAt(s)===58?(f=":",s++):(f=null,d('":"')),f!==null?(_=re(),_!==null?(o.charCodeAt(s)===58?(m=":",s++):(m=null,d('":"')),m!==null?(T=re(),T!==null?(o.charCodeAt(s)===58?(y=":",s++):(y=null,d('":"')),y!==null?(O=re(),O!==null?(o.charCodeAt(s)===58?(se=":",s++):(se=null,d('":"')),se!==null?(De=nt(),De!==null?e=[e,l,u,f,_,m,T,y,O,se,De]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,e=re(),e!==null?(pe=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=re(),u!==null?l=[l,u]:(l=null,s=pe)):(l=null,s=pe),l=l!==null?l:"",l!==null?(o.substr(s,2)==="::"?(u="::",s+=2):(u=null,d('"::"')),u!==null?(f=re(),f!==null?(o.charCodeAt(s)===58?(_=":",s++):(_=null,d('":"')),_!==null?(m=re(),m!==null?(o.charCodeAt(s)===58?(T=":",s++):(T=null,d('":"')),T!==null?(y=re(),y!==null?(o.charCodeAt(s)===58?(O=":",s++):(O=null,d('":"')),O!==null?(se=nt(),se!==null?e=[e,l,u,f,_,m,T,y,O,se]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,e=re(),e!==null?(pe=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=re(),u!==null?l=[l,u]:(l=null,s=pe)):(l=null,s=pe),l=l!==null?l:"",l!==null?(pe=s,o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?u=[u,f]:(u=null,s=pe)):(u=null,s=pe),u=u!==null?u:"",u!==null?(o.substr(s,2)==="::"?(f="::",s+=2):(f=null,d('"::"')),f!==null?(_=re(),_!==null?(o.charCodeAt(s)===58?(m=":",s++):(m=null,d('":"')),m!==null?(T=re(),T!==null?(o.charCodeAt(s)===58?(y=":",s++):(y=null,d('":"')),y!==null?(O=nt(),O!==null?e=[e,l,u,f,_,m,T,y,O]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,e=re(),e!==null?(pe=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=re(),u!==null?l=[l,u]:(l=null,s=pe)):(l=null,s=pe),l=l!==null?l:"",l!==null?(pe=s,o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?u=[u,f]:(u=null,s=pe)):(u=null,s=pe),u=u!==null?u:"",u!==null?(pe=s,o.charCodeAt(s)===58?(f=":",s++):(f=null,d('":"')),f!==null?(_=re(),_!==null?f=[f,_]:(f=null,s=pe)):(f=null,s=pe),f=f!==null?f:"",f!==null?(o.substr(s,2)==="::"?(_="::",s+=2):(_=null,d('"::"')),_!==null?(m=re(),m!==null?(o.charCodeAt(s)===58?(T=":",s++):(T=null,d('":"')),T!==null?(y=nt(),y!==null?e=[e,l,u,f,_,m,T,y]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,e=re(),e!==null?(pe=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=re(),u!==null?l=[l,u]:(l=null,s=pe)):(l=null,s=pe),l=l!==null?l:"",l!==null?(pe=s,o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?u=[u,f]:(u=null,s=pe)):(u=null,s=pe),u=u!==null?u:"",u!==null?(pe=s,o.charCodeAt(s)===58?(f=":",s++):(f=null,d('":"')),f!==null?(_=re(),_!==null?f=[f,_]:(f=null,s=pe)):(f=null,s=pe),f=f!==null?f:"",f!==null?(pe=s,o.charCodeAt(s)===58?(_=":",s++):(_=null,d('":"')),_!==null?(m=re(),m!==null?_=[_,m]:(_=null,s=pe)):(_=null,s=pe),_=_!==null?_:"",_!==null?(o.substr(s,2)==="::"?(m="::",s+=2):(m=null,d('"::"')),m!==null?(T=nt(),T!==null?e=[e,l,u,f,_,m,T]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,e=re(),e!==null?(pe=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=re(),u!==null?l=[l,u]:(l=null,s=pe)):(l=null,s=pe),l=l!==null?l:"",l!==null?(pe=s,o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?u=[u,f]:(u=null,s=pe)):(u=null,s=pe),u=u!==null?u:"",u!==null?(pe=s,o.charCodeAt(s)===58?(f=":",s++):(f=null,d('":"')),f!==null?(_=re(),_!==null?f=[f,_]:(f=null,s=pe)):(f=null,s=pe),f=f!==null?f:"",f!==null?(pe=s,o.charCodeAt(s)===58?(_=":",s++):(_=null,d('":"')),_!==null?(m=re(),m!==null?_=[_,m]:(_=null,s=pe)):(_=null,s=pe),_=_!==null?_:"",_!==null?(pe=s,o.charCodeAt(s)===58?(m=":",s++):(m=null,d('":"')),m!==null?(T=re(),T!==null?m=[m,T]:(m=null,s=pe)):(m=null,s=pe),m=m!==null?m:"",m!==null?(o.substr(s,2)==="::"?(T="::",s+=2):(T=null,d('"::"')),T!==null?(y=re(),y!==null?e=[e,l,u,f,_,m,T,y]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A),e===null&&(A=s,e=re(),e!==null?(pe=s,o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=re(),u!==null?l=[l,u]:(l=null,s=pe)):(l=null,s=pe),l=l!==null?l:"",l!==null?(pe=s,o.charCodeAt(s)===58?(u=":",s++):(u=null,d('":"')),u!==null?(f=re(),f!==null?u=[u,f]:(u=null,s=pe)):(u=null,s=pe),u=u!==null?u:"",u!==null?(pe=s,o.charCodeAt(s)===58?(f=":",s++):(f=null,d('":"')),f!==null?(_=re(),_!==null?f=[f,_]:(f=null,s=pe)):(f=null,s=pe),f=f!==null?f:"",f!==null?(pe=s,o.charCodeAt(s)===58?(_=":",s++):(_=null,d('":"')),_!==null?(m=re(),m!==null?_=[_,m]:(_=null,s=pe)):(_=null,s=pe),_=_!==null?_:"",_!==null?(pe=s,o.charCodeAt(s)===58?(m=":",s++):(m=null,d('":"')),m!==null?(T=re(),T!==null?m=[m,T]:(m=null,s=pe)):(m=null,s=pe),m=m!==null?m:"",m!==null?(pe=s,o.charCodeAt(s)===58?(T=":",s++):(T=null,d('":"')),T!==null?(y=re(),y!==null?T=[T,y]:(T=null,s=pe)):(T=null,s=pe),T=T!==null?T:"",T!==null?(o.substr(s,2)==="::"?(y="::",s+=2):(y=null,d('"::"')),y!==null?e=[e,l,u,f,_,m,T,y]:(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A)):(e=null,s=A))))))))))))))),e!==null&&(e=function(Yv){return b.host_type="IPv6",o.substring(s,Yv)}(x)),e===null&&(s=x),e}function re(){var e,l,u,f,_;return _=s,e=S(),e!==null?(l=S(),l=l!==null?l:"",l!==null?(u=S(),u=u!==null?u:"",u!==null?(f=S(),f=f!==null?f:"",f!==null?e=[e,l,u,f]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e}function nt(){var e,l,u,f;return f=s,e=re(),e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=re(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e===null&&(e=qt()),e}function qt(){var e,l,u,f,_,m,T,y,O;return y=s,O=s,e=Is(),e!==null?(o.charCodeAt(s)===46?(l=".",s++):(l=null,d('"."')),l!==null?(u=Is(),u!==null?(o.charCodeAt(s)===46?(f=".",s++):(f=null,d('"."')),f!==null?(_=Is(),_!==null?(o.charCodeAt(s)===46?(m=".",s++):(m=null,d('"."')),m!==null?(T=Is(),T!==null?e=[e,l,u,f,_,m,T]:(e=null,s=O)):(e=null,s=O)):(e=null,s=O)):(e=null,s=O)):(e=null,s=O)):(e=null,s=O)):(e=null,s=O),e!==null&&(e=function(se){return b.host_type="IPv4",o.substring(s,se)}(y)),e===null&&(s=y),e}function Is(){var e,l,u,f;return f=s,o.substr(s,2)==="25"?(e="25",s+=2):(e=null,d('"25"')),e!==null?(/^[0-5]/.test(o.charAt(s))?(l=o.charAt(s),s++):(l=null,d("[0-5]")),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e===null&&(f=s,o.charCodeAt(s)===50?(e="2",s++):(e=null,d('"2"')),e!==null?(/^[0-4]/.test(o.charAt(s))?(l=o.charAt(s),s++):(l=null,d("[0-4]")),l!==null?(u=v(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e===null&&(f=s,o.charCodeAt(s)===49?(e="1",s++):(e=null,d('"1"')),e!==null?(l=v(),l!==null?(u=v(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e===null&&(f=s,/^[1-9]/.test(o.charAt(s))?(e=o.charAt(s),s++):(e=null,d("[1-9]")),e!==null?(l=v(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e===null&&(e=v())))),e}function Kr(){var e,l,u,f,_,m,T;return m=s,T=s,e=v(),e=e!==null?e:"",e!==null?(l=v(),l=l!==null?l:"",l!==null?(u=v(),u=u!==null?u:"",u!==null?(f=v(),f=f!==null?f:"",f!==null?(_=v(),_=_!==null?_:"",_!==null?e=[e,l,u,f,_]:(e=null,s=T)):(e=null,s=T)):(e=null,s=T)):(e=null,s=T)):(e=null,s=T),e!==null&&(e=function(y,O){return O=parseInt(O.join("")),b.port=O,O}(m,e)),e===null&&(s=m),e}function Pn(){var e,l,u,f;for(e=[],f=s,o.charCodeAt(s)===59?(l=";",s++):(l=null,d('";"')),l!==null?(u=kn(),u!==null?l=[l,u]:(l=null,s=f)):(l=null,s=f);l!==null;)e.push(l),f=s,o.charCodeAt(s)===59?(l=";",s++):(l=null,d('";"')),l!==null?(u=kn(),u!==null?l=[l,u]:(l=null,s=f)):(l=null,s=f);return e}function kn(){var e;return e=Wr(),e===null&&(e=Yr(),e===null&&(e=zr(),e===null&&(e=Jr(),e===null&&(e=Xr(),e===null&&(e=Qr(),e===null&&(e=Zr())))))),e}function Wr(){var e,l,u,f;return u=s,f=s,o.substr(s,10).toLowerCase()==="transport="?(e=o.substr(s,10),s+=10):(e=null,d('"transport="')),e!==null?(o.substr(s,3).toLowerCase()==="udp"?(l=o.substr(s,3),s+=3):(l=null,d('"udp"')),l===null&&(o.substr(s,3).toLowerCase()==="tcp"?(l=o.substr(s,3),s+=3):(l=null,d('"tcp"')),l===null&&(o.substr(s,4).toLowerCase()==="sctp"?(l=o.substr(s,4),s+=4):(l=null,d('"sctp"')),l===null&&(o.substr(s,3).toLowerCase()==="tls"?(l=o.substr(s,3),s+=3):(l=null,d('"tls"')),l===null&&(l=P())))),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(_,m){b.uri_params||(b.uri_params={}),b.uri_params.transport=m.toLowerCase()}(u,e[1])),e===null&&(s=u),e}function Yr(){var e,l,u,f;return u=s,f=s,o.substr(s,5).toLowerCase()==="user="?(e=o.substr(s,5),s+=5):(e=null,d('"user="')),e!==null?(o.substr(s,5).toLowerCase()==="phone"?(l=o.substr(s,5),s+=5):(l=null,d('"phone"')),l===null&&(o.substr(s,2).toLowerCase()==="ip"?(l=o.substr(s,2),s+=2):(l=null,d('"ip"')),l===null&&(l=P())),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(_,m){b.uri_params||(b.uri_params={}),b.uri_params.user=m.toLowerCase()}(u,e[1])),e===null&&(s=u),e}function zr(){var e,l,u,f;return u=s,f=s,o.substr(s,7).toLowerCase()==="method="?(e=o.substr(s,7),s+=7):(e=null,d('"method="')),e!==null?(l=ln(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(_,m){b.uri_params||(b.uri_params={}),b.uri_params.method=m}(u,e[1])),e===null&&(s=u),e}function Jr(){var e,l,u,f;return u=s,f=s,o.substr(s,4).toLowerCase()==="ttl="?(e=o.substr(s,4),s+=4):(e=null,d('"ttl="')),e!==null?(l=Ji(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(_,m){b.params||(b.params={}),b.params.ttl=m}(u,e[1])),e===null&&(s=u),e}function Xr(){var e,l,u,f;return u=s,f=s,o.substr(s,6).toLowerCase()==="maddr="?(e=o.substr(s,6),s+=6):(e=null,d('"maddr="')),e!==null?(l=_s(),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e!==null&&(e=function(_,m){b.uri_params||(b.uri_params={}),b.uri_params.maddr=m}(u,e[1])),e===null&&(s=u),e}function Qr(){var e,l,u,f,_,m;return f=s,_=s,o.substr(s,2).toLowerCase()==="lr"?(e=o.substr(s,2),s+=2):(e=null,d('"lr"')),e!==null?(m=s,o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l!==null?(u=P(),u!==null?l=[l,u]:(l=null,s=m)):(l=null,s=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(T){b.uri_params||(b.uri_params={}),b.uri_params.lr=void 0}()),e===null&&(s=f),e}function Zr(){var e,l,u,f,_,m;return f=s,_=s,e=ei(),e!==null?(m=s,o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l!==null?(u=bs(),u!==null?l=[l,u]:(l=null,s=m)):(l=null,s=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(T,y,O){b.uri_params||(b.uri_params={}),typeof O>"u"?O=void 0:O=O[1],b.uri_params[y.toLowerCase()]=O}(f,e[0],e[1])),e===null&&(s=f),e}function ei(){var e,l,u;if(u=s,l=ws(),l!==null)for(e=[];l!==null;)e.push(l),l=ws();else e=null;return e!==null&&(e=function(f,_){return _.join("")}(u,e)),e===null&&(s=u),e}function bs(){var e,l,u;if(u=s,l=ws(),l!==null)for(e=[];l!==null;)e.push(l),l=ws();else e=null;return e!==null&&(e=function(f,_){return _.join("")}(u,e)),e===null&&(s=u),e}function ws(){var e;return e=ti(),e===null&&(e=H(),e===null&&(e=me())),e}function ti(){var e;return o.charCodeAt(s)===91?(e="[",s++):(e=null,d('"["')),e===null&&(o.charCodeAt(s)===93?(e="]",s++):(e=null,d('"]"')),e===null&&(o.charCodeAt(s)===47?(e="/",s++):(e=null,d('"/"')),e===null&&(o.charCodeAt(s)===58?(e=":",s++):(e=null,d('":"')),e===null&&(o.charCodeAt(s)===38?(e="&",s++):(e=null,d('"&"')),e===null&&(o.charCodeAt(s)===43?(e="+",s++):(e=null,d('"+"')),e===null&&(o.charCodeAt(s)===36?(e="$",s++):(e=null,d('"$"')))))))),e}function Qs(){var e,l,u,f,_,m,T;if(m=s,o.charCodeAt(s)===63?(e="?",s++):(e=null,d('"?"')),e!==null)if(l=Zs(),l!==null){for(u=[],T=s,o.charCodeAt(s)===38?(f="&",s++):(f=null,d('"&"')),f!==null?(_=Zs(),_!==null?f=[f,_]:(f=null,s=T)):(f=null,s=T);f!==null;)u.push(f),T=s,o.charCodeAt(s)===38?(f="&",s++):(f=null,d('"&"')),f!==null?(_=Zs(),_!==null?f=[f,_]:(f=null,s=T)):(f=null,s=T);u!==null?e=[e,l,u]:(e=null,s=m)}else e=null,s=m;else e=null,s=m;return e}function Zs(){var e,l,u,f,_;return f=s,_=s,e=si(),e!==null?(o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l!==null?(u=Os(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T,y){T=T.join("").toLowerCase(),y=y.join(""),b.uri_headers||(b.uri_headers={}),b.uri_headers[T]?b.uri_headers[T].push(y):b.uri_headers[T]=[y]}(f,e[0],e[2])),e===null&&(s=f),e}function si(){var e,l;if(l=en(),l===null&&(l=H(),l===null&&(l=me())),l!==null)for(e=[];l!==null;)e.push(l),l=en(),l===null&&(l=H(),l===null&&(l=me()));else e=null;return e}function Os(){var e,l;for(e=[],l=en(),l===null&&(l=H(),l===null&&(l=me()));l!==null;)e.push(l),l=en(),l===null&&(l=H(),l===null&&(l=me()));return e}function en(){var e;return o.charCodeAt(s)===91?(e="[",s++):(e=null,d('"["')),e===null&&(o.charCodeAt(s)===93?(e="]",s++):(e=null,d('"]"')),e===null&&(o.charCodeAt(s)===47?(e="/",s++):(e=null,d('"/"')),e===null&&(o.charCodeAt(s)===63?(e="?",s++):(e=null,d('"?"')),e===null&&(o.charCodeAt(s)===58?(e=":",s++):(e=null,d('":"')),e===null&&(o.charCodeAt(s)===43?(e="+",s++):(e=null,d('"+"')),e===null&&(o.charCodeAt(s)===36?(e="$",s++):(e=null,d('"$"')))))))),e}function ro(){var e;return e=vi(),e===null&&(e=ni()),e}function ni(){var e,l,u,f,_,m;return m=s,e=ln(),e!==null?(l=F(),l!==null?(u=Mn(),u!==null?(f=F(),f!==null?(_=$n(),_!==null?e=[e,l,u,f,_]:(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m),e}function Mn(){var e;return e=Oe(),e===null&&(e=xn()),e}function xn(){var e,l,u,f;return f=s,e=li(),e!==null?(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l!==null?(u=ri(),u===null&&(u=Ds()),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function ri(){var e,l,u,f,_;return f=s,e=tn(),e===null&&(e=sn()),e!==null?(_=s,o.charCodeAt(s)===63?(l="?",s++):(l=null,d('"?"')),l!==null?(u=Ln(),u!==null?l=[l,u]:(l=null,s=_)):(l=null,s=_),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e}function tn(){var e,l,u,f;return f=s,o.substr(s,2)==="//"?(e="//",s+=2):(e=null,d('"//"')),e!==null?(l=oi(),l!==null?(u=sn(),u=u!==null?u:"",u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function sn(){var e,l,u;return u=s,o.charCodeAt(s)===47?(e="/",s++):(e=null,d('"/"')),e!==null?(l=nn(),l!==null?e=[e,l]:(e=null,s=u)):(e=null,s=u),e}function Ds(){var e,l,u,f;if(f=s,e=ii(),e!==null){for(l=[],u=Ns();u!==null;)l.push(u),u=Ns();l!==null?e=[e,l]:(e=null,s=f)}else e=null,s=f;return e}function Ns(){var e;return e=N(),e===null&&(e=H(),e===null&&(e=me())),e}function ii(){var e;return e=H(),e===null&&(e=me(),e===null&&(o.charCodeAt(s)===59?(e=";",s++):(e=null,d('";"')),e===null&&(o.charCodeAt(s)===63?(e="?",s++):(e=null,d('"?"')),e===null&&(o.charCodeAt(s)===58?(e=":",s++):(e=null,d('":"')),e===null&&(o.charCodeAt(s)===64?(e="@",s++):(e=null,d('"@"')),e===null&&(o.charCodeAt(s)===38?(e="&",s++):(e=null,d('"&"')),e===null&&(o.charCodeAt(s)===61?(e="=",s++):(e=null,d('"="')),e===null&&(o.charCodeAt(s)===43?(e="+",s++):(e=null,d('"+"')),e===null&&(o.charCodeAt(s)===36?(e="$",s++):(e=null,d('"$"')),e===null&&(o.charCodeAt(s)===44?(e=",",s++):(e=null,d('","')))))))))))),e}function nn(){var e,l,u,f,_,m;if(_=s,e=Us(),e!==null){for(l=[],m=s,o.charCodeAt(s)===47?(u="/",s++):(u=null,d('"/"')),u!==null?(f=Us(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,o.charCodeAt(s)===47?(u="/",s++):(u=null,d('"/"')),u!==null?(f=Us(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function Us(){var e,l,u,f,_,m;for(_=s,e=[],l=Ps();l!==null;)e.push(l),l=Ps();if(e!==null){for(l=[],m=s,o.charCodeAt(s)===59?(u=";",s++):(u=null,d('";"')),u!==null?(f=ds(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,o.charCodeAt(s)===59?(u=";",s++):(u=null,d('";"')),u!==null?(f=ds(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function ds(){var e,l;for(e=[],l=Ps();l!==null;)e.push(l),l=Ps();return e}function Ps(){var e;return e=H(),e===null&&(e=me(),e===null&&(o.charCodeAt(s)===58?(e=":",s++):(e=null,d('":"')),e===null&&(o.charCodeAt(s)===64?(e="@",s++):(e=null,d('"@"')),e===null&&(o.charCodeAt(s)===38?(e="&",s++):(e=null,d('"&"')),e===null&&(o.charCodeAt(s)===61?(e="=",s++):(e=null,d('"="')),e===null&&(o.charCodeAt(s)===43?(e="+",s++):(e=null,d('"+"')),e===null&&(o.charCodeAt(s)===36?(e="$",s++):(e=null,d('"$"')),e===null&&(o.charCodeAt(s)===44?(e=",",s++):(e=null,d('","')))))))))),e}function li(){var e,l,u,f,_;if(f=s,_=s,e=E(),e!==null){for(l=[],u=E(),u===null&&(u=v(),u===null&&(o.charCodeAt(s)===43?(u="+",s++):(u=null,d('"+"')),u===null&&(o.charCodeAt(s)===45?(u="-",s++):(u=null,d('"-"')),u===null&&(o.charCodeAt(s)===46?(u=".",s++):(u=null,d('"."'))))));u!==null;)l.push(u),u=E(),u===null&&(u=v(),u===null&&(o.charCodeAt(s)===43?(u="+",s++):(u=null,d('"+"')),u===null&&(o.charCodeAt(s)===45?(u="-",s++):(u=null,d('"-"')),u===null&&(o.charCodeAt(s)===46?(u=".",s++):(u=null,d('"."'))))));l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e!==null&&(e=function(m){b.scheme=o.substring(s,m)}(f)),e===null&&(s=f),e}function oi(){var e;return e=ai(),e===null&&(e=ui()),e}function ai(){var e,l,u,f;return u=s,f=s,e=gt(),e!==null?(o.charCodeAt(s)===64?(l="@",s++):(l=null,d('"@"')),l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e=e!==null?e:"",e!==null?(l=Qt(),l!==null?e=[e,l]:(e=null,s=u)):(e=null,s=u),e=e!==null?e:"",e}function ui(){var e,l;if(l=H(),l===null&&(l=me(),l===null&&(o.charCodeAt(s)===36?(l="$",s++):(l=null,d('"$"')),l===null&&(o.charCodeAt(s)===44?(l=",",s++):(l=null,d('","')),l===null&&(o.charCodeAt(s)===59?(l=";",s++):(l=null,d('";"')),l===null&&(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l===null&&(o.charCodeAt(s)===64?(l="@",s++):(l=null,d('"@"')),l===null&&(o.charCodeAt(s)===38?(l="&",s++):(l=null,d('"&"')),l===null&&(o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"'))))))))))),l!==null)for(e=[];l!==null;)e.push(l),l=H(),l===null&&(l=me(),l===null&&(o.charCodeAt(s)===36?(l="$",s++):(l=null,d('"$"')),l===null&&(o.charCodeAt(s)===44?(l=",",s++):(l=null,d('","')),l===null&&(o.charCodeAt(s)===59?(l=";",s++):(l=null,d('";"')),l===null&&(o.charCodeAt(s)===58?(l=":",s++):(l=null,d('":"')),l===null&&(o.charCodeAt(s)===64?(l="@",s++):(l=null,d('"@"')),l===null&&(o.charCodeAt(s)===38?(l="&",s++):(l=null,d('"&"')),l===null&&(o.charCodeAt(s)===61?(l="=",s++):(l=null,d('"="')),l===null&&(o.charCodeAt(s)===43?(l="+",s++):(l=null,d('"+"')))))))))));else e=null;return e}function Ln(){var e,l;for(e=[],l=Ns();l!==null;)e.push(l),l=Ns();return e}function $n(){var e,l,u,f,_,m,T,y;if(T=s,y=s,o.substr(s,3).toLowerCase()==="sip"?(e=o.substr(s,3),s+=3):(e=null,d('"SIP"')),e!==null)if(o.charCodeAt(s)===47?(l="/",s++):(l=null,d('"/"')),l!==null){if(f=v(),f!==null)for(u=[];f!==null;)u.push(f),f=v();else u=null;if(u!==null)if(o.charCodeAt(s)===46?(f=".",s++):(f=null,d('"."')),f!==null){if(m=v(),m!==null)for(_=[];m!==null;)_.push(m),m=v();else _=null;_!==null?e=[e,l,u,f,_]:(e=null,s=y)}else e=null,s=y;else e=null,s=y}else e=null,s=y;else e=null,s=y;return e!==null&&(e=function(O){b.sip_version=o.substring(s,O)}(T)),e===null&&(s=T),e}function ci(){var e;return o.substr(s,6)==="INVITE"?(e="INVITE",s+=6):(e=null,d('"INVITE"')),e}function fi(){var e;return o.substr(s,3)==="ACK"?(e="ACK",s+=3):(e=null,d('"ACK"')),e}function hi(){var e;return o.substr(s,7)==="OPTIONS"?(e="OPTIONS",s+=7):(e=null,d('"OPTIONS"')),e}function _i(){var e;return o.substr(s,3)==="BYE"?(e="BYE",s+=3):(e=null,d('"BYE"')),e}function di(){var e;return o.substr(s,6)==="CANCEL"?(e="CANCEL",s+=6):(e=null,d('"CANCEL"')),e}function pi(){var e;return o.substr(s,8)==="REGISTER"?(e="REGISTER",s+=8):(e=null,d('"REGISTER"')),e}function mi(){var e;return o.substr(s,9)==="SUBSCRIBE"?(e="SUBSCRIBE",s+=9):(e=null,d('"SUBSCRIBE"')),e}function gi(){var e;return o.substr(s,6)==="NOTIFY"?(e="NOTIFY",s+=6):(e=null,d('"NOTIFY"')),e}function rn(){var e;return o.substr(s,5)==="REFER"?(e="REFER",s+=5):(e=null,d('"REFER"')),e}function ln(){var e,l;return l=s,e=ci(),e===null&&(e=fi(),e===null&&(e=hi(),e===null&&(e=_i(),e===null&&(e=di(),e===null&&(e=pi(),e===null&&(e=mi(),e===null&&(e=gi(),e===null&&(e=rn(),e===null&&(e=P()))))))))),e!==null&&(e=function(u){return b.method=o.substring(s,u),b.method}(l)),e===null&&(s=l),e}function vi(){var e,l,u,f,_,m;return m=s,e=$n(),e!==null?(l=F(),l!==null?(u=Ti(),u!==null?(f=F(),f!==null?(_=io(),_!==null?e=[e,l,u,f,_]:(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m),e}function Ti(){var e,l;return l=s,e=Ei(),e!==null&&(e=function(u,f){b.status_code=parseInt(f.join(""))}(l,e)),e===null&&(s=l),e}function Ei(){var e,l,u,f;return f=s,e=v(),e!==null?(l=v(),l!==null?(u=v(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function io(){var e,l,u;for(u=s,e=[],l=N(),l===null&&(l=H(),l===null&&(l=me(),l===null&&(l=$(),l===null&&(l=X(),l===null&&(l=F(),l===null&&(l=L()))))));l!==null;)e.push(l),l=N(),l===null&&(l=H(),l===null&&(l=me(),l===null&&(l=$(),l===null&&(l=X(),l===null&&(l=F(),l===null&&(l=L()))))));return e!==null&&(e=function(f){b.reason_phrase=o.substring(s,f)}(u)),e===null&&(s=u),e}function tu(){var e,l,u,f,_,m;if(_=s,e=cn(),e!==null){for(l=[],m=s,u=ne(),u!==null?(f=cn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=ne(),u!==null?(f=cn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function su(){var e,l,u,f,_,m;return f=s,_=s,e=Q(),e!==null?(m=s,o.charCodeAt(s)===64?(l="@",s++):(l=null,d('"@"')),l!==null?(u=Q(),u!==null?l=[l,u]:(l=null,s=m)):(l=null,s=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(T){b=o.substring(s,T)}(f)),e===null&&(s=f),e}function Hn(){var e,l,u,f,_,m,T;if(_=s,e=W(),e===null)if(m=s,e=kt(),e!==null){for(l=[],T=s,u=ne(),u!==null?(f=kt(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=ne(),u!==null?(f=kt(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y){var O,se;for(se=b.multi_header.length,O=0;O<se;O++)if(b.multi_header[O].parsed===null){b=null;break}b!==null?b=b.multi_header:b=-1}()),e===null&&(s=_),e}function kt(){var e,l,u,f,_,m,T;if(_=s,m=s,e=Re(),e===null&&(e=Mt()),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=Fn(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=Te(),u!==null?(f=Fn(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y){var O;b.multi_header||(b.multi_header=[]);try{O=new R(b.uri,b.display_name,b.params),delete b.uri,delete b.display_name,delete b.params}catch{O=null}b.multi_header.push({possition:s,offset:y,parsed:O})}(_)),e===null&&(s=_),e}function Mt(){var e,l,u,f,_;return _=s,e=ks(),e=e!==null?e:"",e!==null?(l=Se(),l!==null?(u=Oe(),u!==null?(f=Ue(),f!==null?e=[e,l,u,f]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e}function ks(){var e,l,u,f,_,m,T;if(_=s,m=s,e=P(),e!==null){for(l=[],T=s,u=M(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=M(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e===null&&(e=he()),e!==null&&(e=function(y,O){typeof O=="string"?b.display_name=O:b.display_name=O[1].reduce(function(se,De){return se+De[0]+De[1]},O[0])}(_,e)),e===null&&(s=_),e}function Fn(){var e;return e=yi(),e===null&&(e=Zt(),e===null&&(e=Ke())),e}function yi(){var e,l,u,f,_;return f=s,_=s,o.substr(s,1).toLowerCase()==="q"?(e=o.substr(s,1),s++):(e=null,d('"q"')),e!==null?(l=te(),l!==null?(u=Ge(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){b.params||(b.params={}),b.params.q=T}(f,e[2])),e===null&&(s=f),e}function Zt(){var e,l,u,f,_;return f=s,_=s,o.substr(s,7).toLowerCase()==="expires"?(e=o.substr(s,7),s+=7):(e=null,d('"expires"')),e!==null?(l=te(),l!==null?(u=es(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){b.params||(b.params={}),b.params.expires=T}(f,e[2])),e===null&&(s=f),e}function es(){var e,l,u;if(u=s,l=v(),l!==null)for(e=[];l!==null;)e.push(l),l=v();else e=null;return e!==null&&(e=function(f,_){return parseInt(_.join(""))}(u,e)),e===null&&(s=u),e}function Ge(){var e,l,u,f,_,m,T,y;return m=s,T=s,o.charCodeAt(s)===48?(e="0",s++):(e=null,d('"0"')),e!==null?(y=s,o.charCodeAt(s)===46?(l=".",s++):(l=null,d('"."')),l!==null?(u=v(),u=u!==null?u:"",u!==null?(f=v(),f=f!==null?f:"",f!==null?(_=v(),_=_!==null?_:"",_!==null?l=[l,u,f,_]:(l=null,s=y)):(l=null,s=y)):(l=null,s=y)):(l=null,s=y),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=T)):(e=null,s=T),e!==null&&(e=function(O){return parseFloat(o.substring(s,O))}(m)),e===null&&(s=m),e}function Ke(){var e,l,u,f,_,m;return f=s,_=s,e=P(),e!==null?(m=s,l=te(),l!==null?(u=lo(),u!==null?l=[l,u]:(l=null,s=m)):(l=null,s=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(T,y,O){b.params||(b.params={}),typeof O>"u"?O=void 0:O=O[1],b.params[y.toLowerCase()]=O}(f,e[0],e[1])),e===null&&(s=f),e}function lo(){var e;return e=P(),e===null&&(e=_s(),e===null&&(e=be())),e}function oo(){var e,l,u,f,_,m;if(_=s,e=qn(),e!==null){for(l=[],m=s,u=Te(),u!==null?(f=Vn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=Te(),u!==null?(f=Vn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function qn(){var e;return o.substr(s,6).toLowerCase()==="render"?(e=o.substr(s,6),s+=6):(e=null,d('"render"')),e===null&&(o.substr(s,7).toLowerCase()==="session"?(e=o.substr(s,7),s+=7):(e=null,d('"session"')),e===null&&(o.substr(s,4).toLowerCase()==="icon"?(e=o.substr(s,4),s+=4):(e=null,d('"icon"')),e===null&&(o.substr(s,5).toLowerCase()==="alert"?(e=o.substr(s,5),s+=5):(e=null,d('"alert"')),e===null&&(e=P())))),e}function Vn(){var e;return e=ao(),e===null&&(e=Ke()),e}function ao(){var e,l,u,f;return f=s,o.substr(s,8).toLowerCase()==="handling"?(e=o.substr(s,8),s+=8):(e=null,d('"handling"')),e!==null?(l=te(),l!==null?(o.substr(s,8).toLowerCase()==="optional"?(u=o.substr(s,8),s+=8):(u=null,d('"optional"')),u===null&&(o.substr(s,8).toLowerCase()==="required"?(u=o.substr(s,8),s+=8):(u=null,d('"required"')),u===null&&(u=P())),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function nu(){var e,l,u,f,_,m;if(_=s,e=P(),e!==null){for(l=[],m=s,u=ne(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=ne(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function ru(){var e,l,u;if(u=s,l=v(),l!==null)for(e=[];l!==null;)e.push(l),l=v();else e=null;return e!==null&&(e=function(f,_){b=parseInt(_.join(""))}(u,e)),e===null&&(s=u),e}function uo(){var e,l;return l=s,e=Si(),e!==null&&(e=function(u){b=o.substring(s,u)}(l)),e===null&&(s=l),e}function Si(){var e,l,u,f,_,m,T,y;if(T=s,e=Ci(),e!==null)if(l=B(),l!==null)if(u=jn(),u!==null){for(f=[],y=s,_=Te(),_!==null?(m=Bn(),m!==null?_=[_,m]:(_=null,s=y)):(_=null,s=y);_!==null;)f.push(_),y=s,_=Te(),_!==null?(m=Bn(),m!==null?_=[_,m]:(_=null,s=y)):(_=null,s=y);f!==null?e=[e,l,u,f]:(e=null,s=T)}else e=null,s=T;else e=null,s=T;else e=null,s=T;return e}function Ci(){var e;return e=Ai(),e===null&&(e=on()),e}function Ai(){var e;return o.substr(s,4).toLowerCase()==="text"?(e=o.substr(s,4),s+=4):(e=null,d('"text"')),e===null&&(o.substr(s,5).toLowerCase()==="image"?(e=o.substr(s,5),s+=5):(e=null,d('"image"')),e===null&&(o.substr(s,5).toLowerCase()==="audio"?(e=o.substr(s,5),s+=5):(e=null,d('"audio"')),e===null&&(o.substr(s,5).toLowerCase()==="video"?(e=o.substr(s,5),s+=5):(e=null,d('"video"')),e===null&&(o.substr(s,11).toLowerCase()==="application"?(e=o.substr(s,11),s+=11):(e=null,d('"application"')),e===null&&(e=an()))))),e}function on(){var e;return o.substr(s,7).toLowerCase()==="message"?(e=o.substr(s,7),s+=7):(e=null,d('"message"')),e===null&&(o.substr(s,9).toLowerCase()==="multipart"?(e=o.substr(s,9),s+=9):(e=null,d('"multipart"')),e===null&&(e=an())),e}function an(){var e;return e=P(),e===null&&(e=Ri()),e}function Ri(){var e,l,u;return u=s,o.substr(s,2).toLowerCase()==="x-"?(e=o.substr(s,2),s+=2):(e=null,d('"x-"')),e!==null?(l=P(),l!==null?e=[e,l]:(e=null,s=u)):(e=null,s=u),e}function jn(){var e;return e=an(),e===null&&(e=P()),e}function Bn(){var e,l,u,f;return f=s,e=P(),e!==null?(l=te(),l!==null?(u=co(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function co(){var e;return e=P(),e===null&&(e=be()),e}function fo(){var e,l,u,f;return f=s,e=ho(),e!==null?(l=M(),l!==null?(u=ln(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function ho(){var e,l,u;if(u=s,l=v(),l!==null)for(e=[];l!==null;)e.push(l),l=v();else e=null;return e!==null&&(e=function(f,_){b.value=parseInt(_.join(""))}(u,e)),e===null&&(s=u),e}function iu(){var e,l;return l=s,e=es(),e!==null&&(e=function(u,f){b=f}(l,e)),e===null&&(s=l),e}function un(){var e,l,u,f,_,m,T;if(_=s,m=s,e=cn(),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=Ke(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=Te(),u!==null?(f=Ke(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y,O){b.event=O.join("").toLowerCase()}(_,e[0])),e===null&&(s=_),e}function cn(){var e,l,u,f,_,m;if(_=s,e=Z(),e!==null){for(l=[],m=s,o.charCodeAt(s)===46?(u=".",s++):(u=null,d('"."')),u!==null?(f=Z(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,o.charCodeAt(s)===46?(u=".",s++):(u=null,d('"."')),u!==null?(f=Z(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function Ii(){var e,l,u,f,_,m,T;if(_=s,m=s,e=Re(),e===null&&(e=Mt()),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=fn(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=Te(),u!==null?(f=fn(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y){var O=b.tag;try{b=new R(b.uri,b.display_name,b.params),O&&b.setParam("tag",O)}catch{b=-1}}()),e===null&&(s=_),e}function fn(){var e;return e=bi(),e===null&&(e=Ke()),e}function bi(){var e,l,u,f,_;return f=s,_=s,o.substr(s,3).toLowerCase()==="tag"?(e=o.substr(s,3),s+=3):(e=null,d('"tag"')),e!==null?(l=te(),l!==null?(u=P(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){b.tag=T}(f,e[2])),e===null&&(s=f),e}function lu(){var e,l,u;if(u=s,l=v(),l!==null)for(e=[];l!==null;)e.push(l),l=v();else e=null;return e!==null&&(e=function(f,_){b=parseInt(_.join(""))}(u,e)),e===null&&(s=u),e}function ou(){var e,l;return l=s,e=es(),e!==null&&(e=function(u,f){b=f}(l,e)),e===null&&(s=l),e}function au(){var e,l,u,f,_,m,T,y,O,se;for(y=s,O=s,e=[],l=ks();l!==null;)e.push(l),l=ks();if(e!==null)if(l=Se(),l!==null)if(u=Oe(),u!==null)if(f=Ue(),f!==null){for(_=[],se=s,m=Te(),m!==null?(T=Ke(),T!==null?m=[m,T]:(m=null,s=se)):(m=null,s=se);m!==null;)_.push(m),se=s,m=Te(),m!==null?(T=Ke(),T!==null?m=[m,T]:(m=null,s=se)):(m=null,s=se);_!==null?e=[e,l,u,f,_]:(e=null,s=O)}else e=null,s=O;else e=null,s=O;else e=null,s=O;else e=null,s=O;return e!==null&&(e=function(De){try{b=new R(b.uri,b.display_name,b.params)}catch{b=-1}}()),e===null&&(s=y),e}function wi(){var e;return e=Gn(),e}function Gn(){var e,l,u,f,_,m,T,y;if(T=s,o.substr(s,6).toLowerCase()==="digest"?(e=o.substr(s,6),s+=6):(e=null,d('"Digest"')),e!==null)if(l=M(),l!==null)if(u=hn(),u!==null){for(f=[],y=s,_=ne(),_!==null?(m=hn(),m!==null?_=[_,m]:(_=null,s=y)):(_=null,s=y);_!==null;)f.push(_),y=s,_=ne(),_!==null?(m=hn(),m!==null?_=[_,m]:(_=null,s=y)):(_=null,s=y);f!==null?e=[e,l,u,f]:(e=null,s=T)}else e=null,s=T;else e=null,s=T;else e=null,s=T;return e===null&&(e=Ms()),e}function Ms(){var e,l,u,f,_,m,T,y;if(T=s,e=P(),e!==null)if(l=M(),l!==null)if(u=ts(),u!==null){for(f=[],y=s,_=ne(),_!==null?(m=ts(),m!==null?_=[_,m]:(_=null,s=y)):(_=null,s=y);_!==null;)f.push(_),y=s,_=ne(),_!==null?(m=ts(),m!==null?_=[_,m]:(_=null,s=y)):(_=null,s=y);f!==null?e=[e,l,u,f]:(e=null,s=T)}else e=null,s=T;else e=null,s=T;else e=null,s=T;return e}function ts(){var e,l,u,f;return f=s,e=P(),e!==null?(l=te(),l!==null?(u=P(),u===null&&(u=be()),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function hn(){var e;return e=Oi(),e===null&&(e=_n(),e===null&&(e=Ni(),e===null&&(e=Pi(),e===null&&(e=ki(),e===null&&(e=Mi(),e===null&&(e=pn(),e===null&&(e=ts()))))))),e}function Oi(){var e,l,u,f;return f=s,o.substr(s,5).toLowerCase()==="realm"?(e=o.substr(s,5),s+=5):(e=null,d('"realm"')),e!==null?(l=te(),l!==null?(u=Di(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function Di(){var e,l;return l=s,e=he(),e!==null&&(e=function(u,f){b.realm=f}(l,e)),e===null&&(s=l),e}function _n(){var e,l,u,f,_,m,T,y,O;if(y=s,o.substr(s,6).toLowerCase()==="domain"?(e=o.substr(s,6),s+=6):(e=null,d('"domain"')),e!==null)if(l=te(),l!==null)if(u=st(),u!==null)if(f=dn(),f!==null){if(_=[],O=s,T=F(),T!==null)for(m=[];T!==null;)m.push(T),T=F();else m=null;for(m!==null?(T=dn(),T!==null?m=[m,T]:(m=null,s=O)):(m=null,s=O);m!==null;){if(_.push(m),O=s,T=F(),T!==null)for(m=[];T!==null;)m.push(T),T=F();else m=null;m!==null?(T=dn(),T!==null?m=[m,T]:(m=null,s=O)):(m=null,s=O)}_!==null?(m=ge(),m!==null?e=[e,l,u,f,_,m]:(e=null,s=y)):(e=null,s=y)}else e=null,s=y;else e=null,s=y;else e=null,s=y;else e=null,s=y;return e}function dn(){var e;return e=xn(),e===null&&(e=sn()),e}function Ni(){var e,l,u,f;return f=s,o.substr(s,5).toLowerCase()==="nonce"?(e=o.substr(s,5),s+=5):(e=null,d('"nonce"')),e!==null?(l=te(),l!==null?(u=Ui(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function Ui(){var e,l;return l=s,e=he(),e!==null&&(e=function(u,f){b.nonce=f}(l,e)),e===null&&(s=l),e}function Pi(){var e,l,u,f,_;return f=s,_=s,o.substr(s,6).toLowerCase()==="opaque"?(e=o.substr(s,6),s+=6):(e=null,d('"opaque"')),e!==null?(l=te(),l!==null?(u=he(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){b.opaque=T}(f,e[2])),e===null&&(s=f),e}function ki(){var e,l,u,f,_;return f=s,o.substr(s,5).toLowerCase()==="stale"?(e=o.substr(s,5),s+=5):(e=null,d('"stale"')),e!==null?(l=te(),l!==null?(_=s,o.substr(s,4).toLowerCase()==="true"?(u=o.substr(s,4),s+=4):(u=null,d('"true"')),u!==null&&(u=function(m){b.stale=!0}()),u===null&&(s=_),u===null&&(_=s,o.substr(s,5).toLowerCase()==="false"?(u=o.substr(s,5),s+=5):(u=null,d('"false"')),u!==null&&(u=function(m){b.stale=!1}()),u===null&&(s=_)),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function Mi(){var e,l,u,f,_;return f=s,_=s,o.substr(s,9).toLowerCase()==="algorithm"?(e=o.substr(s,9),s+=9):(e=null,d('"algorithm"')),e!==null?(l=te(),l!==null?(o.substr(s,3).toLowerCase()==="md5"?(u=o.substr(s,3),s+=3):(u=null,d('"MD5"')),u===null&&(o.substr(s,8).toLowerCase()==="md5-sess"?(u=o.substr(s,8),s+=8):(u=null,d('"MD5-sess"')),u===null&&(u=P())),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){b.algorithm=T.toUpperCase()}(f,e[2])),e===null&&(s=f),e}function pn(){var e,l,u,f,_,m,T,y,O,se;if(y=s,o.substr(s,3).toLowerCase()==="qop"?(e=o.substr(s,3),s+=3):(e=null,d('"qop"')),e!==null)if(l=te(),l!==null)if(u=st(),u!==null){if(O=s,f=Kn(),f!==null){for(_=[],se=s,o.charCodeAt(s)===44?(m=",",s++):(m=null,d('","')),m!==null?(T=Kn(),T!==null?m=[m,T]:(m=null,s=se)):(m=null,s=se);m!==null;)_.push(m),se=s,o.charCodeAt(s)===44?(m=",",s++):(m=null,d('","')),m!==null?(T=Kn(),T!==null?m=[m,T]:(m=null,s=se)):(m=null,s=se);_!==null?f=[f,_]:(f=null,s=O)}else f=null,s=O;f!==null?(_=ge(),_!==null?e=[e,l,u,f,_]:(e=null,s=y)):(e=null,s=y)}else e=null,s=y;else e=null,s=y;else e=null,s=y;return e}function Kn(){var e,l;return l=s,o.substr(s,8).toLowerCase()==="auth-int"?(e=o.substr(s,8),s+=8):(e=null,d('"auth-int"')),e===null&&(o.substr(s,4).toLowerCase()==="auth"?(e=o.substr(s,4),s+=4):(e=null,d('"auth"')),e===null&&(e=P())),e!==null&&(e=function(u,f){b.qop||(b.qop=[]),b.qop.push(f.toLowerCase())}(l,e)),e===null&&(s=l),e}function uu(){var e,l,u,f,_,m;if(_=s,e=P(),e!==null){for(l=[],m=s,u=ne(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=ne(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function Wn(){var e,l,u,f,_,m,T;if(_=s,m=s,e=Yn(),e!==null){for(l=[],T=s,u=ne(),u!==null?(f=Yn(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=ne(),u!==null?(f=Yn(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y){var O,se;for(se=b.multi_header.length,O=0;O<se;O++)if(b.multi_header[O].parsed===null){b=null;break}b!==null?b=b.multi_header:b=-1}()),e===null&&(s=_),e}function Yn(){var e,l,u,f,_,m,T;if(_=s,m=s,e=Mt(),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=Ke(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=Te(),u!==null?(f=Ke(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y){var O;b.multi_header||(b.multi_header=[]);try{O=new R(b.uri,b.display_name,b.params),delete b.uri,delete b.display_name,delete b.params}catch{O=null}b.multi_header.push({possition:s,offset:y,parsed:O})}(_)),e===null&&(s=_),e}function xi(){var e,l,u,f,_,m,T;if(_=s,m=s,o.substr(s,3).toLowerCase()==="sip"?(e=o.substr(s,3),s+=3):(e=null,d('"SIP"')),e===null&&(e=P()),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=zn(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=Te(),u!==null?(f=zn(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y,O){if(b.protocol=O.toLowerCase(),b.params||(b.params={}),b.params.text&&b.params.text[0]==='"'){var se=b.params.text;b.text=se.substring(1,se.length-1),delete b.params.text}}(_,e[0])),e===null&&(s=_),e}function zn(){var e;return e=_o(),e===null&&(e=Ke()),e}function _o(){var e,l,u,f,_,m;if(_=s,m=s,o.substr(s,5).toLowerCase()==="cause"?(e=o.substr(s,5),s+=5):(e=null,d('"cause"')),e!==null)if(l=te(),l!==null){if(f=v(),f!==null)for(u=[];f!==null;)u.push(f),f=v();else u=null;u!==null?e=[e,l,u]:(e=null,s=m)}else e=null,s=m;else e=null,s=m;return e!==null&&(e=function(T,y){b.cause=parseInt(y.join(""))}(_,e[2])),e===null&&(s=_),e}function cu(){var e,l,u,f,_,m;if(_=s,e=P(),e!==null){for(l=[],m=s,u=ne(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=ne(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function Jn(){var e,l,u,f,_,m;if(_=s,e=Xn(),e!==null){for(l=[],m=s,u=ne(),u!==null?(f=Xn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=ne(),u!==null?(f=Xn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function Xn(){var e,l,u,f,_,m;if(_=s,e=Mt(),e!==null){for(l=[],m=s,u=Te(),u!==null?(f=Ke(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=Te(),u!==null?(f=Ke(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function po(){var e,l,u,f,_,m;if(_=s,e=Qn(),e!==null){for(l=[],m=s,u=Te(),u!==null?(f=Zn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=Te(),u!==null?(f=Zn(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function Qn(){var e,l;return l=s,o.substr(s,6).toLowerCase()==="active"?(e=o.substr(s,6),s+=6):(e=null,d('"active"')),e===null&&(o.substr(s,7).toLowerCase()==="pending"?(e=o.substr(s,7),s+=7):(e=null,d('"pending"')),e===null&&(o.substr(s,10).toLowerCase()==="terminated"?(e=o.substr(s,10),s+=10):(e=null,d('"terminated"')),e===null&&(e=P()))),e!==null&&(e=function(u){b.state=o.substring(s,u)}(l)),e===null&&(s=l),e}function Zn(){var e,l,u,f,_;return f=s,_=s,o.substr(s,6).toLowerCase()==="reason"?(e=o.substr(s,6),s+=6):(e=null,d('"reason"')),e!==null?(l=te(),l!==null?(u=mo(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){typeof T<"u"&&(b.reason=T)}(f,e[2])),e===null&&(s=f),e===null&&(f=s,_=s,o.substr(s,7).toLowerCase()==="expires"?(e=o.substr(s,7),s+=7):(e=null,d('"expires"')),e!==null?(l=te(),l!==null?(u=es(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){typeof T<"u"&&(b.expires=T)}(f,e[2])),e===null&&(s=f),e===null&&(f=s,_=s,o.substr(s,11).toLowerCase()==="retry_after"?(e=o.substr(s,11),s+=11):(e=null,d('"retry_after"')),e!==null?(l=te(),l!==null?(u=es(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){typeof T<"u"&&(b.retry_after=T)}(f,e[2])),e===null&&(s=f),e===null&&(e=Ke()))),e}function mo(){var e;return o.substr(s,11).toLowerCase()==="deactivated"?(e=o.substr(s,11),s+=11):(e=null,d('"deactivated"')),e===null&&(o.substr(s,9).toLowerCase()==="probation"?(e=o.substr(s,9),s+=9):(e=null,d('"probation"')),e===null&&(o.substr(s,8).toLowerCase()==="rejected"?(e=o.substr(s,8),s+=8):(e=null,d('"rejected"')),e===null&&(o.substr(s,7).toLowerCase()==="timeout"?(e=o.substr(s,7),s+=7):(e=null,d('"timeout"')),e===null&&(o.substr(s,6).toLowerCase()==="giveup"?(e=o.substr(s,6),s+=6):(e=null,d('"giveup"')),e===null&&(o.substr(s,10).toLowerCase()==="noresource"?(e=o.substr(s,10),s+=10):(e=null,d('"noresource"')),e===null&&(o.substr(s,9).toLowerCase()==="invariant"?(e=o.substr(s,9),s+=9):(e=null,d('"invariant"')),e===null&&(e=P()))))))),e}function fu(){var e;return e=V(),e=e!==null?e:"",e}function hu(){var e,l,u,f,_,m;if(_=s,e=P(),e!==null){for(l=[],m=s,u=ne(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=ne(),u!==null?(f=P(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e=e!==null?e:"",e}function Li(){var e,l,u,f,_,m,T;if(_=s,m=s,e=Re(),e===null&&(e=Mt()),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=$i(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=Te(),u!==null?(f=$i(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y){var O=b.tag;try{b=new R(b.uri,b.display_name,b.params),O&&b.setParam("tag",O)}catch{b=-1}}()),e===null&&(s=_),e}function $i(){var e;return e=bi(),e===null&&(e=Ke()),e}function er(){var e,l,u,f,_,m;if(_=s,e=xs(),e!==null){for(l=[],m=s,u=ne(),u!==null?(f=xs(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=ne(),u!==null?(f=xs(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function xs(){var e,l,u,f,_,m,T,y;if(T=s,e=Gi(),e!==null)if(l=M(),l!==null)if(u=Yi(),u!==null){for(f=[],y=s,_=Te(),_!==null?(m=tr(),m!==null?_=[_,m]:(_=null,s=y)):(_=null,s=y);_!==null;)f.push(_),y=s,_=Te(),_!==null?(m=tr(),m!==null?_=[_,m]:(_=null,s=y)):(_=null,s=y);f!==null?e=[e,l,u,f]:(e=null,s=T)}else e=null,s=T;else e=null,s=T;else e=null,s=T;return e}function tr(){var e;return e=Hi(),e===null&&(e=Fi(),e===null&&(e=qi(),e===null&&(e=Vi(),e===null&&(e=ji(),e===null&&(e=Ke()))))),e}function Hi(){var e,l,u,f,_;return f=s,_=s,o.substr(s,3).toLowerCase()==="ttl"?(e=o.substr(s,3),s+=3):(e=null,d('"ttl"')),e!==null?(l=te(),l!==null?(u=Ji(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){b.ttl=T}(f,e[2])),e===null&&(s=f),e}function Fi(){var e,l,u,f,_;return f=s,_=s,o.substr(s,5).toLowerCase()==="maddr"?(e=o.substr(s,5),s+=5):(e=null,d('"maddr"')),e!==null?(l=te(),l!==null?(u=_s(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){b.maddr=T}(f,e[2])),e===null&&(s=f),e}function qi(){var e,l,u,f,_;return f=s,_=s,o.substr(s,8).toLowerCase()==="received"?(e=o.substr(s,8),s+=8):(e=null,d('"received"')),e!==null?(l=te(),l!==null?(u=qt(),u===null&&(u=_e()),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){b.received=T}(f,e[2])),e===null&&(s=f),e}function Vi(){var e,l,u,f,_;return f=s,_=s,o.substr(s,6).toLowerCase()==="branch"?(e=o.substr(s,6),s+=6):(e=null,d('"branch"')),e!==null?(l=te(),l!==null?(u=P(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){b.branch=T}(f,e[2])),e===null&&(s=f),e}function ji(){var e,l,u,f,_;return f=s,o.substr(s,5).toLowerCase()==="rport"?(e=o.substr(s,5),s+=5):(e=null,d('"rport"')),e!==null?(_=s,l=te(),l!==null?(u=Bi(),u!==null?l=[l,u]:(l=null,s=_)):(l=null,s=_),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e}function Bi(){var e,l,u,f,_,m,T;return m=s,T=s,e=v(),e=e!==null?e:"",e!==null?(l=v(),l=l!==null?l:"",l!==null?(u=v(),u=u!==null?u:"",u!==null?(f=v(),f=f!==null?f:"",f!==null?(_=v(),_=_!==null?_:"",_!==null?e=[e,l,u,f,_]:(e=null,s=T)):(e=null,s=T)):(e=null,s=T)):(e=null,s=T)):(e=null,s=T),e!==null&&(e=function(y,O){b.rport=parseInt(O.join(""))}(m,e)),e===null&&(s=m),e}function Gi(){var e,l,u,f,_,m;return m=s,e=Ki(),e!==null?(l=B(),l!==null?(u=P(),u!==null?(f=B(),f!==null?(_=Wi(),_!==null?e=[e,l,u,f,_]:(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m)):(e=null,s=m),e}function Ki(){var e,l;return l=s,o.substr(s,3).toLowerCase()==="sip"?(e=o.substr(s,3),s+=3):(e=null,d('"SIP"')),e===null&&(e=P()),e!==null&&(e=function(u,f){b.protocol=f}(l,e)),e===null&&(s=l),e}function Wi(){var e,l;return l=s,o.substr(s,3).toLowerCase()==="udp"?(e=o.substr(s,3),s+=3):(e=null,d('"UDP"')),e===null&&(o.substr(s,3).toLowerCase()==="tcp"?(e=o.substr(s,3),s+=3):(e=null,d('"TCP"')),e===null&&(o.substr(s,3).toLowerCase()==="tls"?(e=o.substr(s,3),s+=3):(e=null,d('"TLS"')),e===null&&(o.substr(s,4).toLowerCase()==="sctp"?(e=o.substr(s,4),s+=4):(e=null,d('"SCTP"')),e===null&&(e=P())))),e!==null&&(e=function(u,f){b.transport=f}(l,e)),e===null&&(s=l),e}function Yi(){var e,l,u,f,_;return f=s,e=zi(),e!==null?(_=s,l=tt(),l!==null?(u=sr(),u!==null?l=[l,u]:(l=null,s=_)):(l=null,s=_),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=f)):(e=null,s=f),e}function zi(){var e,l;return l=s,e=qt(),e===null&&(e=Xs(),e===null&&(e=Js())),e!==null&&(e=function(u){b.host=o.substring(s,u)}(l)),e===null&&(s=l),e}function sr(){var e,l,u,f,_,m,T;return m=s,T=s,e=v(),e=e!==null?e:"",e!==null?(l=v(),l=l!==null?l:"",l!==null?(u=v(),u=u!==null?u:"",u!==null?(f=v(),f=f!==null?f:"",f!==null?(_=v(),_=_!==null?_:"",_!==null?e=[e,l,u,f,_]:(e=null,s=T)):(e=null,s=T)):(e=null,s=T)):(e=null,s=T)):(e=null,s=T),e!==null&&(e=function(y,O){b.port=parseInt(O.join(""))}(m,e)),e===null&&(s=m),e}function Ji(){var e,l,u,f,_;return f=s,_=s,e=v(),e!==null?(l=v(),l=l!==null?l:"",l!==null?(u=v(),u=u!==null?u:"",u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){return parseInt(T.join(""))}(f,e)),e===null&&(s=f),e}function _u(){var e;return e=Gn(),e}function go(){var e,l,u,f,_,m;if(_=s,e=nr(),e!==null){for(l=[],m=s,u=Te(),u!==null?(f=rr(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=Te(),u!==null?(f=rr(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function nr(){var e,l;return l=s,e=es(),e!==null&&(e=function(u,f){b.expires=f}(l,e)),e===null&&(s=l),e}function rr(){var e;return e=vo(),e===null&&(e=Ke()),e}function vo(){var e,l,u,f,_;return f=s,_=s,o.substr(s,9).toLowerCase()==="refresher"?(e=o.substr(s,9),s+=9):(e=null,d('"refresher"')),e!==null?(l=te(),l!==null?(o.substr(s,3).toLowerCase()==="uac"?(u=o.substr(s,3),s+=3):(u=null,d('"uac"')),u===null&&(o.substr(s,3).toLowerCase()==="uas"?(u=o.substr(s,3),s+=3):(u=null,d('"uas"'))),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){b.refresher=T.toLowerCase()}(f,e[2])),e===null&&(s=f),e}function To(){var e,l,u,f;return f=s,e=P(),e!==null?(l=j(),l!==null?(u=Eo(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function Eo(){var e,l;for(e=[],l=Y(),l===null&&(l=X(),l===null&&(l=M()));l!==null;)e.push(l),l=Y(),l===null&&(l=X(),l===null&&(l=M()));return e}function du(){var e,l;for(e=[],l=I();l!==null;)e.push(l),l=I();return e}function yo(){var e,l,u;return u=s,o.substr(s,5)==="uuid:"?(e="uuid:",s+=5):(e=null,d('"uuid:"')),e!==null?(l=xt(),l!==null?e=[e,l]:(e=null,s=u)):(e=null,s=u),e}function xt(){var e,l,u,f,_,m,T,y,O,se,De;return se=s,De=s,e=Xi(),e!==null?(o.charCodeAt(s)===45?(l="-",s++):(l=null,d('"-"')),l!==null?(u=Lt(),u!==null?(o.charCodeAt(s)===45?(f="-",s++):(f=null,d('"-"')),f!==null?(_=Lt(),_!==null?(o.charCodeAt(s)===45?(m="-",s++):(m=null,d('"-"')),m!==null?(T=Lt(),T!==null?(o.charCodeAt(s)===45?(y="-",s++):(y=null,d('"-"')),y!==null?(O=So(),O!==null?e=[e,l,u,f,_,m,T,y,O]:(e=null,s=De)):(e=null,s=De)):(e=null,s=De)):(e=null,s=De)):(e=null,s=De)):(e=null,s=De)):(e=null,s=De)):(e=null,s=De)):(e=null,s=De),e!==null&&(e=function(At,Ls){b=o.substring(s+5,At)}(se,e[0])),e===null&&(s=se),e}function Lt(){var e,l,u,f,_;return _=s,e=S(),e!==null?(l=S(),l!==null?(u=S(),u!==null?(f=S(),f!==null?e=[e,l,u,f]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e}function Xi(){var e,l,u;return u=s,e=Lt(),e!==null?(l=Lt(),l!==null?e=[e,l]:(e=null,s=u)):(e=null,s=u),e}function So(){var e,l,u,f;return f=s,e=Lt(),e!==null?(l=Lt(),l!==null?(u=Lt(),u!==null?e=[e,l,u]:(e=null,s=f)):(e=null,s=f)):(e=null,s=f),e}function pu(){var e,l,u,f,_,m,T;if(_=s,m=s,e=Re(),e===null&&(e=Mt()),e!==null){for(l=[],T=s,u=Te(),u!==null?(f=Ke(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);u!==null;)l.push(u),T=s,u=Te(),u!==null?(f=Ke(),f!==null?u=[u,f]:(u=null,s=T)):(u=null,s=T);l!==null?e=[e,l]:(e=null,s=m)}else e=null,s=m;return e!==null&&(e=function(y){try{b=new R(b.uri,b.display_name,b.params)}catch{b=-1}}()),e===null&&(s=_),e}function Co(){var e,l,u,f,_,m;if(_=s,e=ir(),e!==null){for(l=[],m=s,u=Te(),u!==null?(f=lr(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);u!==null;)l.push(u),m=s,u=Te(),u!==null?(f=lr(),f!==null?u=[u,f]:(u=null,s=m)):(u=null,s=m);l!==null?e=[e,l]:(e=null,s=_)}else e=null,s=_;return e}function ir(){var e,l,u,f,_,m;return f=s,_=s,e=Q(),e!==null?(m=s,o.charCodeAt(s)===64?(l="@",s++):(l=null,d('"@"')),l!==null?(u=Q(),u!==null?l=[l,u]:(l=null,s=m)):(l=null,s=m),l=l!==null?l:"",l!==null?e=[e,l]:(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(T){b.call_id=o.substring(s,T)}(f)),e===null&&(s=f),e}function lr(){var e;return e=Qi(),e===null&&(e=Zi(),e===null&&(e=Ao(),e===null&&(e=Ke()))),e}function Qi(){var e,l,u,f,_;return f=s,_=s,o.substr(s,6)==="to-tag"?(e="to-tag",s+=6):(e=null,d('"to-tag"')),e!==null?(l=te(),l!==null?(u=P(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){b.to_tag=T}(f,e[2])),e===null&&(s=f),e}function Zi(){var e,l,u,f,_;return f=s,_=s,o.substr(s,8)==="from-tag"?(e="from-tag",s+=8):(e=null,d('"from-tag"')),e!==null?(l=te(),l!==null?(u=P(),u!==null?e=[e,l,u]:(e=null,s=_)):(e=null,s=_)):(e=null,s=_),e!==null&&(e=function(m,T){b.from_tag=T}(f,e[2])),e===null&&(s=f),e}function Ao(){var e,l;return l=s,o.substr(s,10)==="early-only"?(e="early-only",s+=10):(e=null,d('"early-only"')),e!==null&&(e=function(u){b.early_only=!0}()),e===null&&(s=l),e}function mu(e){e.sort();for(var l=null,u=[],f=0;f<e.length;f++)e[f]!==l&&(u.push(e[f]),l=e[f]);return u}function Ro(){for(var e=1,l=1,u=!1,f=0;f<Math.max(s,p);f++){var _=o.charAt(f);_===`
|
4
|
+
`?(u||e++,l=1,u=!1):_==="\r"||_==="\u2028"||_==="\u2029"?(e++,l=1,u=!0):(l++,u=!1)}return{line:e,column:l}}var ps=gs(),R=wo(),b={},el=t[a]();if(el===null||s!==o.length){var tl=Math.max(s,p),Io=tl<o.length?o.charAt(tl):null,i=Ro();return new this.SyntaxError(mu(h),Io,tl,i.line,i.column),-1}return b},toSource:function(){return this._source}};return r.SyntaxError=function(n,o,a,t,s){function p(h,d){var g,v;switch(h.length){case 0:g="end of input";break;case 1:g=h[0];break;default:g=h.slice(0,h.length-1).join(", ")+" or "+h[h.length-1]}return v=d?c(d):"end of input","Expected "+g+" but "+v+" found."}this.name="SyntaxError",this.expected=n,this.found=o,this.message=p(n,o),this.offset=a,this.line=t,this.column=s},r.SyntaxError.prototype=Error.prototype,r}()),Oo}var Do,Su;function gs(){if(Su)return Do;Su=1;function c(d,g){var v;if(typeof Symbol>"u"||d[Symbol.iterator]==null){if(Array.isArray(d)||(v=r(d))||g&&d&&typeof d.length=="number"){v&&(d=v);var E=0,S=function(){};return{s:S,n:function(){return E>=d.length?{done:!0}:{done:!1,value:d[E++]}},e:function(L){throw L},f:S}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
5
5
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var C=!0,I=!1,w;return{s:function(){v=d[Symbol.iterator]()},n:function(){var L=v.next();return C=L.done,L},e:function(L){I=!0,w=L},f:function(){try{!C&&v.return!=null&&v.return()}finally{if(I)throw w}}}}function r(d,g){if(d){if(typeof d=="string")return n(d,g);var v=Object.prototype.toString.call(d).slice(8,-1);if(v==="Object"&&d.constructor&&(v=d.constructor.name),v==="Map"||v==="Set")return Array.from(d);if(v==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(v))return n(d,g)}}function n(d,g){(g==null||g>d.length)&&(g=d.length);for(var v=0,E=new Array(g);v<g;v++)E[v]=d[v];return E}function o(d,g){if(!(d instanceof g))throw new TypeError("Cannot call a class as a function")}function a(d,g){for(var v=0;v<g.length;v++){var E=g[v];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(d,E.key,E)}}function t(d,g,v){return g&&a(d.prototype,g),v&&a(d,v),d}var s=Xe,p=Tt(),h=Vt();return Do=function(){t(d,null,[{key:"parse",value:function(v){if(v=h.parse(v,"SIP_URI"),v!==-1)return v}}]);function d(g,v,E,S){var C=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{},I=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{};if(o(this,d),!E)throw new TypeError('missing or invalid "host" parameter');this._parameters={},this._headers={},this._scheme=g||s.SIP,this._user=v,this._host=E,this._port=S;for(var w in C)Object.prototype.hasOwnProperty.call(C,w)&&this.setParam(w,C[w]);for(var F in I)Object.prototype.hasOwnProperty.call(I,F)&&this.setHeader(F,I[F])}return t(d,[{key:"setParam",value:function(v,E){v&&(this._parameters[v.toLowerCase()]=typeof E>"u"||E===null?null:E.toString())}},{key:"getParam",value:function(v){if(v)return this._parameters[v.toLowerCase()]}},{key:"hasParam",value:function(v){if(v)return this._parameters.hasOwnProperty(v.toLowerCase())&&!0||!1}},{key:"deleteParam",value:function(v){if(v=v.toLowerCase(),this._parameters.hasOwnProperty(v)){var E=this._parameters[v];return delete this._parameters[v],E}}},{key:"clearParams",value:function(){this._parameters={}}},{key:"setHeader",value:function(v,E){this._headers[p.headerize(v)]=Array.isArray(E)?E:[E]}},{key:"getHeader",value:function(v){if(v)return this._headers[p.headerize(v)]}},{key:"hasHeader",value:function(v){if(v)return this._headers.hasOwnProperty(p.headerize(v))&&!0||!1}},{key:"deleteHeader",value:function(v){if(v=p.headerize(v),this._headers.hasOwnProperty(v)){var E=this._headers[v];return delete this._headers[v],E}}},{key:"clearHeaders",value:function(){this._headers={}}},{key:"clone",value:function(){return new d(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 v=[],E="".concat(this._scheme,":");this._user&&(E+="".concat(p.escapeUser(this._user),"@")),E+=this._host,(this._port||this._port===0)&&(E+=":".concat(this._port));for(var S in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,S)&&(E+=";".concat(S),this._parameters[S]!==null&&(E+="=".concat(this._parameters[S])));for(var C in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,C)){var I=c(this._headers[C]),w;try{for(I.s();!(w=I.n()).done;){var F=w.value;v.push("".concat(C,"=").concat(F))}}catch(L){I.e(L)}finally{I.f()}}return v.length>0&&(E+="?".concat(v.join("&"))),E}},{key:"toAor",value:function(v){var E="".concat(this._scheme,":");return this._user&&(E+="".concat(p.escapeUser(this._user),"@")),E+=this._host,v&&(this._port||this._port===0)&&(E+=":".concat(this._port)),E}},{key:"scheme",get:function(){return this._scheme},set:function(v){this._scheme=v.toLowerCase()}},{key:"user",get:function(){return this._user},set:function(v){this._user=v}},{key:"host",get:function(){return this._host},set:function(v){this._host=v.toLowerCase()}},{key:"port",get:function(){return this._port},set:function(v){this._port=v===0?v:parseInt(v,10)||null}}]),d}(),Do}var Cu;function Tt(){if(Cu)return Ye;Cu=1;function c(g){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?c=function(E){return typeof E}:c=function(E){return E&&typeof Symbol=="function"&&E.constructor===Symbol&&E!==Symbol.prototype?"symbol":typeof E},c(g)}function r(g,v){var E;if(typeof Symbol>"u"||g[Symbol.iterator]==null){if(Array.isArray(g)||(E=n(g))||v&&g&&typeof g.length=="number"){E&&(g=E);var S=0,C=function(){};return{s:C,n:function(){return S>=g.length?{done:!0}:{done:!1,value:g[S++]}},e:function(ie){throw ie},f:C}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
6
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var I=!0,w=!1,F;return{s:function(){E=g[Symbol.iterator]()},n:function(){var ie=E.next();return I=ie.done,ie},e:function(ie){w=!0,F=ie},f:function(){try{!I&&E.return!=null&&E.return()}finally{if(w)throw F}}}}function n(g,v){if(g){if(typeof g=="string")return o(g,v);var E=Object.prototype.toString.call(g).slice(8,-1);if(E==="Object"&&g.constructor&&(E=g.constructor.name),E==="Map"||E==="Set")return Array.from(g);if(E==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(E))return o(g,v)}}function o(g,v){(v==null||v>g.length)&&(v=g.length);for(var E=0,S=new Array(v);E<v;E++)S[E]=g[E];return S}var a=Xe,t=ms(),s=Vt();Ye.str_utf8_length=function(g){return unescape(encodeURIComponent(g)).length};var p=Ye.isFunction=function(g){return g!==void 0?Object.prototype.toString.call(g)==="[object Function]":!1};Ye.isString=function(g){return g!==void 0?Object.prototype.toString.call(g)==="[object String]":!1},Ye.isDecimal=function(g){return!isNaN(g)&&parseFloat(g)===parseInt(g,10)},Ye.isEmpty=function(g){return g===null||g===""||g===void 0||Array.isArray(g)&&g.length===0||typeof g=="number"&&isNaN(g)},Ye.hasMethods=function(g){for(var v=arguments.length,E=new Array(v>1?v-1:0),S=1;S<v;S++)E[S-1]=arguments[S];for(var C=0,I=E;C<I.length;C++){var w=I[C];if(p(g[w]))return!1}return!0};var h=Ye.createRandomToken=function(g){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:32,E,S,C="";for(E=0;E<g;E++)S=Math.random()*v|0,C+=S.toString(v);return C};Ye.newTag=function(){return h(10)},Ye.newUUID=function(){var g="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(v){var E=Math.random()*16|0,S=v==="x"?E:E&3|8;return S.toString(16)});return g},Ye.hostType=function(g){if(g){if(g=s.parse(g,"host"),g!==-1)return g.host_type}else return};var d=Ye.escapeUser=function(g){return encodeURIComponent(decodeURIComponent(g)).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/")};return Ye.normalizeTarget=function(g,v){if(g){if(g instanceof t)return g;if(typeof g=="string"){var E=g.split("@"),S,C;switch(E.length){case 1:if(!v)return;S=g,C=v;break;case 2:S=E[0],C=E[1];break;default:S=E.slice(0,E.length-1).join("@"),C=E[E.length-1]}S=S.replace(/^(sips?|tel):/i,""),/^[-.()]*\+?[0-9\-.()]+$/.test(S)&&(S=S.replace(/[-.()]/g,"")),g="".concat(a.SIP,":").concat(d(S),"@").concat(C);var I;return(I=t.parse(g))?I:void 0}else return}else return},Ye.headerize=function(g){var v={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},E=g.toLowerCase().replace(/_/g,"-").split("-"),S="",C=E.length,I;for(I=0;I<C;I++)I!==0&&(S+="-"),S+=E[I].charAt(0).toUpperCase()+E[I].substring(1);return v[S]&&(S=v[S]),S},Ye.sipErrorCause=function(g){for(var v in a.SIP_ERROR_CAUSES)if(a.SIP_ERROR_CAUSES[v].indexOf(g)!==-1)return a.causes[v];return a.causes.SIP_FAILURE_CODE},Ye.getRandomTestNetIP=function(){function g(v,E){return Math.floor(Math.random()*(E-v+1)+v)}return"192.0.2.".concat(g(1,254))},Ye.calculateMD5=function(g){function v(he,ce){return he<<ce|he>>>32-ce}function E(he,ce){var fe=he&2147483648,Re=ce&2147483648,Oe=he&1073741824,Je=ce&1073741824,Me=(he&1073741823)+(ce&1073741823);return Oe&Je?Me^2147483648^fe^Re:Oe|Je?Me&1073741824?Me^3221225472^fe^Re:Me^1073741824^fe^Re:Me^fe^Re}function S(he,ce,fe){return he&ce|~he&fe}function C(he,ce,fe){return he&fe|ce&~fe}function I(he,ce,fe){return he^ce^fe}function w(he,ce,fe){return ce^(he|~fe)}function F(he,ce,fe,Re,Oe,Je,Me){return he=E(he,E(E(S(ce,fe,Re),Oe),Me)),E(v(he,Je),ce)}function L(he,ce,fe,Re,Oe,Je,Me){return he=E(he,E(E(C(ce,fe,Re),Oe),Me)),E(v(he,Je),ce)}function ie(he,ce,fe,Re,Oe,Je,Me){return he=E(he,E(E(I(ce,fe,Re),Oe),Me)),E(v(he,Je),ce)}function N(he,ce,fe,Re,Oe,Je,Me){return he=E(he,E(E(w(ce,fe,Re),Oe),Me)),E(v(he,Je),ce)}function H(he){for(var ce,fe=he.length,Re=fe+8,Oe=(Re-Re%64)/64,Je=(Oe+1)*16,Me=new Array(Je-1),Pt=0,gt=0;gt<fe;)ce=(gt-gt%4)/4,Pt=gt%4*8,Me[ce]=Me[ce]|he.charCodeAt(gt)<<Pt,gt++;return ce=(gt-gt%4)/4,Pt=gt%4*8,Me[ce]=Me[ce]|128<<Pt,Me[Je-2]=fe<<3,Me[Je-1]=fe>>>29,Me}function ve(he){var ce="",fe="",Re,Oe;for(Oe=0;Oe<=3;Oe++)Re=he>>>Oe*8&255,fe="0".concat(Re.toString(16)),ce=ce+fe.substr(fe.length-2,2);return ce}function me(he){for(var ce="",fe=0;fe<he.length;fe++){var Re=he.charCodeAt(fe);Re<128?ce+=String.fromCharCode(Re):Re>127&&Re<2048?(ce+=String.fromCharCode(Re>>6|192),ce+=String.fromCharCode(Re&63|128)):(ce+=String.fromCharCode(Re>>12|224),ce+=String.fromCharCode(Re>>6&63|128),ce+=String.fromCharCode(Re&63|128))}return ce}var M=[],D,j,V,Y,$,X,U,P,Z,et=7,Q=12,W=17,B=22,te=5,de=9,Ae=14,Ue=20,Se=4,ne=11,Te=16,tt=23,st=6,ge=10,Ee=15,Ce=21;for(g=me(g),M=H(g),X=1732584193,U=4023233417,P=2562383102,Z=271733878,D=0;D<M.length;D+=16)j=X,V=U,Y=P,$=Z,X=F(X,U,P,Z,M[D+0],et,3614090360),Z=F(Z,X,U,P,M[D+1],Q,3905402710),P=F(P,Z,X,U,M[D+2],W,606105819),U=F(U,P,Z,X,M[D+3],B,3250441966),X=F(X,U,P,Z,M[D+4],et,4118548399),Z=F(Z,X,U,P,M[D+5],Q,1200080426),P=F(P,Z,X,U,M[D+6],W,2821735955),U=F(U,P,Z,X,M[D+7],B,4249261313),X=F(X,U,P,Z,M[D+8],et,1770035416),Z=F(Z,X,U,P,M[D+9],Q,2336552879),P=F(P,Z,X,U,M[D+10],W,4294925233),U=F(U,P,Z,X,M[D+11],B,2304563134),X=F(X,U,P,Z,M[D+12],et,1804603682),Z=F(Z,X,U,P,M[D+13],Q,4254626195),P=F(P,Z,X,U,M[D+14],W,2792965006),U=F(U,P,Z,X,M[D+15],B,1236535329),X=L(X,U,P,Z,M[D+1],te,4129170786),Z=L(Z,X,U,P,M[D+6],de,3225465664),P=L(P,Z,X,U,M[D+11],Ae,643717713),U=L(U,P,Z,X,M[D+0],Ue,3921069994),X=L(X,U,P,Z,M[D+5],te,3593408605),Z=L(Z,X,U,P,M[D+10],de,38016083),P=L(P,Z,X,U,M[D+15],Ae,3634488961),U=L(U,P,Z,X,M[D+4],Ue,3889429448),X=L(X,U,P,Z,M[D+9],te,568446438),Z=L(Z,X,U,P,M[D+14],de,3275163606),P=L(P,Z,X,U,M[D+3],Ae,4107603335),U=L(U,P,Z,X,M[D+8],Ue,1163531501),X=L(X,U,P,Z,M[D+13],te,2850285829),Z=L(Z,X,U,P,M[D+2],de,4243563512),P=L(P,Z,X,U,M[D+7],Ae,1735328473),U=L(U,P,Z,X,M[D+12],Ue,2368359562),X=ie(X,U,P,Z,M[D+5],Se,4294588738),Z=ie(Z,X,U,P,M[D+8],ne,2272392833),P=ie(P,Z,X,U,M[D+11],Te,1839030562),U=ie(U,P,Z,X,M[D+14],tt,4259657740),X=ie(X,U,P,Z,M[D+1],Se,2763975236),Z=ie(Z,X,U,P,M[D+4],ne,1272893353),P=ie(P,Z,X,U,M[D+7],Te,4139469664),U=ie(U,P,Z,X,M[D+10],tt,3200236656),X=ie(X,U,P,Z,M[D+13],Se,681279174),Z=ie(Z,X,U,P,M[D+0],ne,3936430074),P=ie(P,Z,X,U,M[D+3],Te,3572445317),U=ie(U,P,Z,X,M[D+6],tt,76029189),X=ie(X,U,P,Z,M[D+9],Se,3654602809),Z=ie(Z,X,U,P,M[D+12],ne,3873151461),P=ie(P,Z,X,U,M[D+15],Te,530742520),U=ie(U,P,Z,X,M[D+2],tt,3299628645),X=N(X,U,P,Z,M[D+0],st,4096336452),Z=N(Z,X,U,P,M[D+7],ge,1126891415),P=N(P,Z,X,U,M[D+14],Ee,2878612391),U=N(U,P,Z,X,M[D+5],Ce,4237533241),X=N(X,U,P,Z,M[D+12],st,1700485571),Z=N(Z,X,U,P,M[D+3],ge,2399980690),P=N(P,Z,X,U,M[D+10],Ee,4293915773),U=N(U,P,Z,X,M[D+1],Ce,2240044497),X=N(X,U,P,Z,M[D+8],st,1873313359),Z=N(Z,X,U,P,M[D+15],ge,4264355552),P=N(P,Z,X,U,M[D+6],Ee,2734768916),U=N(U,P,Z,X,M[D+13],Ce,1309151649),X=N(X,U,P,Z,M[D+4],st,4149444226),Z=N(Z,X,U,P,M[D+11],ge,3174756917),P=N(P,Z,X,U,M[D+2],Ee,718787259),U=N(U,P,Z,X,M[D+9],Ce,3951481745),X=E(X,j),U=E(U,V),P=E(P,Y),Z=E(Z,$);var be=ve(X)+ve(U)+ve(P)+ve(Z);return be.toLowerCase()},Ye.closeMediaStream=function(g){if(g)try{var v;if(g.getTracks){v=g.getTracks();var E=r(v),S;try{for(E.s();!(S=E.n()).done;){var C=S.value;C.stop()}}catch(H){E.e(H)}finally{E.f()}}else{v=g.getAudioTracks();var I=r(v),w;try{for(I.s();!(w=I.n()).done;){var F=w.value;F.stop()}}catch(H){I.e(H)}finally{I.f()}v=g.getVideoTracks();var L=r(v),ie;try{for(L.s();!(ie=L.n()).done;){var N=ie.value;N.stop()}}catch(H){L.e(H)}finally{L.f()}}}catch{(typeof g.stop=="function"||c(g.stop)==="object")&&g.stop()}},Ye.cloneArray=function(g){return g&&g.slice()||[]},Ye.cloneObject=function(g){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return g&&Object.assign({},g)||v},Ye}var No={exports:{}},gn=typeof Reflect=="object"?Reflect:null,Au=gn&&typeof gn.apply=="function"?gn.apply:function(r,n,o){return Function.prototype.apply.call(r,n,o)},al;gn&&typeof gn.ownKeys=="function"?al=gn.ownKeys:Object.getOwnPropertySymbols?al=function(r){return Object.getOwnPropertyNames(r).concat(Object.getOwnPropertySymbols(r))}:al=function(r){return Object.getOwnPropertyNames(r)};function ch(c){console&&console.warn&&console.warn(c)}var Ru=Number.isNaN||function(r){return r!==r};function Pe(){Pe.init.call(this)}No.exports=Pe,No.exports.once=dh,Pe.EventEmitter=Pe,Pe.prototype._events=void 0,Pe.prototype._eventsCount=0,Pe.prototype._maxListeners=void 0;var Iu=10;function ul(c){if(typeof c!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof c)}Object.defineProperty(Pe,"defaultMaxListeners",{enumerable:!0,get:function(){return Iu},set:function(c){if(typeof c!="number"||c<0||Ru(c))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+c+".");Iu=c}}),Pe.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Pe.prototype.setMaxListeners=function(r){if(typeof r!="number"||r<0||Ru(r))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+r+".");return this._maxListeners=r,this};function bu(c){return c._maxListeners===void 0?Pe.defaultMaxListeners:c._maxListeners}Pe.prototype.getMaxListeners=function(){return bu(this)},Pe.prototype.emit=function(r){for(var n=[],o=1;o<arguments.length;o++)n.push(arguments[o]);var a=r==="error",t=this._events;if(t!==void 0)a=a&&t.error===void 0;else if(!a)return!1;if(a){var s;if(n.length>0&&(s=n[0]),s instanceof Error)throw s;var p=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw p.context=s,p}var h=t[r];if(h===void 0)return!1;if(typeof h=="function")Au(h,this,n);else for(var d=h.length,g=Uu(h,d),o=0;o<d;++o)Au(g[o],this,n);return!0};function wu(c,r,n,o){var a,t,s;if(ul(n),t=c._events,t===void 0?(t=c._events=Object.create(null),c._eventsCount=0):(t.newListener!==void 0&&(c.emit("newListener",r,n.listener?n.listener:n),t=c._events),s=t[r]),s===void 0)s=t[r]=n,++c._eventsCount;else if(typeof s=="function"?s=t[r]=o?[n,s]:[s,n]:o?s.unshift(n):s.push(n),a=bu(c),a>0&&s.length>a&&!s.warned){s.warned=!0;var p=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(r)+" listeners added. Use emitter.setMaxListeners() to increase limit");p.name="MaxListenersExceededWarning",p.emitter=c,p.type=r,p.count=s.length,ch(p)}return c}Pe.prototype.addListener=function(r,n){return wu(this,r,n,!1)},Pe.prototype.on=Pe.prototype.addListener,Pe.prototype.prependListener=function(r,n){return wu(this,r,n,!0)};function fh(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Ou(c,r,n){var o={fired:!1,wrapFn:void 0,target:c,type:r,listener:n},a=fh.bind(o);return a.listener=n,o.wrapFn=a,a}Pe.prototype.once=function(r,n){return ul(n),this.on(r,Ou(this,r,n)),this},Pe.prototype.prependOnceListener=function(r,n){return ul(n),this.prependListener(r,Ou(this,r,n)),this},Pe.prototype.removeListener=function(r,n){var o,a,t,s,p;if(ul(n),a=this._events,a===void 0)return this;if(o=a[r],o===void 0)return this;if(o===n||o.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete a[r],a.removeListener&&this.emit("removeListener",r,o.listener||n));else if(typeof o!="function"){for(t=-1,s=o.length-1;s>=0;s--)if(o[s]===n||o[s].listener===n){p=o[s].listener,t=s;break}if(t<0)return this;t===0?o.shift():hh(o,t),o.length===1&&(a[r]=o[0]),a.removeListener!==void 0&&this.emit("removeListener",r,p||n)}return this},Pe.prototype.off=Pe.prototype.removeListener,Pe.prototype.removeAllListeners=function(r){var n,o,a;if(o=this._events,o===void 0)return this;if(o.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):o[r]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete o[r]),this;if(arguments.length===0){var t=Object.keys(o),s;for(a=0;a<t.length;++a)s=t[a],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(n=o[r],typeof n=="function")this.removeListener(r,n);else if(n!==void 0)for(a=n.length-1;a>=0;a--)this.removeListener(r,n[a]);return this};function Du(c,r,n){var o=c._events;if(o===void 0)return[];var a=o[r];return a===void 0?[]:typeof a=="function"?n?[a.listener||a]:[a]:n?_h(a):Uu(a,a.length)}Pe.prototype.listeners=function(r){return Du(this,r,!0)},Pe.prototype.rawListeners=function(r){return Du(this,r,!1)},Pe.listenerCount=function(c,r){return typeof c.listenerCount=="function"?c.listenerCount(r):Nu.call(c,r)},Pe.prototype.listenerCount=Nu;function Nu(c){var r=this._events;if(r!==void 0){var n=r[c];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}Pe.prototype.eventNames=function(){return this._eventsCount>0?al(this._events):[]};function Uu(c,r){for(var n=new Array(r),o=0;o<r;++o)n[o]=c[o];return n}function hh(c,r){for(;r+1<c.length;r++)c[r]=c[r+1];c.pop()}function _h(c){for(var r=new Array(c.length),n=0;n<r.length;++n)r[n]=c[n].listener||c[n];return r}function dh(c,r){return new Promise(function(n,o){function a(s){c.removeListener(r,t),o(s)}function t(){typeof c.removeListener=="function"&&c.removeListener("error",a),n([].slice.call(arguments))}Pu(c,r,t,{once:!0}),r!=="error"&&ph(c,a,{once:!0})})}function ph(c,r,n){typeof c.on=="function"&&Pu(c,"error",r,n)}function Pu(c,r,n,o){if(typeof c.on=="function")o.once?c.once(r,n):c.on(r,n);else if(typeof c.addEventListener=="function")c.addEventListener(r,function a(t){o.once&&c.removeEventListener(r,a),n(t)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof c)}var ot=No.exports,Uo={exports:{}},Po,ku;function mh(){if(ku)return Po;ku=1;var c=1e3,r=c*60,n=r*60,o=n*24,a=o*7,t=o*365.25;Po=function(g,v){v=v||{};var E=typeof g;if(E==="string"&&g.length>0)return s(g);if(E==="number"&&isFinite(g))return v.long?h(g):p(g);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(g))};function s(g){if(g=String(g),!(g.length>100)){var v=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(g);if(v){var E=parseFloat(v[1]),S=(v[2]||"ms").toLowerCase();switch(S){case"years":case"year":case"yrs":case"yr":case"y":return E*t;case"weeks":case"week":case"w":return E*a;case"days":case"day":case"d":return E*o;case"hours":case"hour":case"hrs":case"hr":case"h":return E*n;case"minutes":case"minute":case"mins":case"min":case"m":return E*r;case"seconds":case"second":case"secs":case"sec":case"s":return E*c;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return E;default:return}}}}function p(g){var v=Math.abs(g);return v>=o?Math.round(g/o)+"d":v>=n?Math.round(g/n)+"h":v>=r?Math.round(g/r)+"m":v>=c?Math.round(g/c)+"s":g+"ms"}function h(g){var v=Math.abs(g);return v>=o?d(g,v,o,"day"):v>=n?d(g,v,n,"hour"):v>=r?d(g,v,r,"minute"):v>=c?d(g,v,c,"second"):g+" ms"}function d(g,v,E,S){var C=v>=E*1.5;return Math.round(g/E)+" "+S+(C?"s":"")}return Po}function gh(c){n.debug=n,n.default=n,n.coerce=h,n.disable=t,n.enable=a,n.enabled=s,n.humanize=mh(),n.destroy=d,Object.keys(c).forEach(g=>{n[g]=c[g]}),n.names=[],n.skips=[],n.formatters={};function r(g){let v=0;for(let E=0;E<g.length;E++)v=(v<<5)-v+g.charCodeAt(E),v|=0;return n.colors[Math.abs(v)%n.colors.length]}n.selectColor=r;function n(g){let v,E=null,S,C;function I(...w){if(!I.enabled)return;const F=I,L=Number(new Date),ie=L-(v||L);F.diff=ie,F.prev=v,F.curr=L,v=L,w[0]=n.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let N=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(ve,me)=>{if(ve==="%%")return"%";N++;const M=n.formatters[me];if(typeof M=="function"){const D=w[N];ve=M.call(F,D),w.splice(N,1),N--}return ve}),n.formatArgs.call(F,w),(F.log||n.log).apply(F,w)}return I.namespace=g,I.useColors=n.useColors(),I.color=n.selectColor(g),I.extend=o,I.destroy=n.destroy,Object.defineProperty(I,"enabled",{enumerable:!0,configurable:!1,get:()=>E!==null?E:(S!==n.namespaces&&(S=n.namespaces,C=n.enabled(g)),C),set:w=>{E=w}}),typeof n.init=="function"&&n.init(I),I}function o(g,v){const E=n(this.namespace+(typeof v>"u"?":":v)+g);return E.log=this.log,E}function a(g){n.save(g),n.namespaces=g,n.names=[],n.skips=[];let v;const E=(typeof g=="string"?g:"").split(/[\s,]+/),S=E.length;for(v=0;v<S;v++)E[v]&&(g=E[v].replace(/\*/g,".*?"),g[0]==="-"?n.skips.push(new RegExp("^"+g.slice(1)+"$")):n.names.push(new RegExp("^"+g+"$")))}function t(){const g=[...n.names.map(p),...n.skips.map(p).map(v=>"-"+v)].join(",");return n.enable(""),g}function s(g){if(g[g.length-1]==="*")return!0;let v,E;for(v=0,E=n.skips.length;v<E;v++)if(n.skips[v].test(g))return!1;for(v=0,E=n.names.length;v<E;v++)if(n.names[v].test(g))return!0;return!1}function p(g){return g.toString().substring(2,g.toString().length-2).replace(/\.\*\?$/,"*")}function h(g){return g instanceof Error?g.stack||g.message:g}function d(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}var vh=gh;(function(c,r){r.formatArgs=o,r.save=a,r.load=t,r.useColors=n,r.storage=s(),r.destroy=(()=>{let h=!1;return()=>{h||(h=!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`."))}})(),r.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"];function n(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function o(h){if(h[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+h[0]+(this.useColors?"%c ":" ")+"+"+c.exports.humanize(this.diff),!this.useColors)return;const d="color: "+this.color;h.splice(1,0,d,"color: inherit");let g=0,v=0;h[0].replace(/%[a-zA-Z%]/g,E=>{E!=="%%"&&(g++,E==="%c"&&(v=g))}),h.splice(v,0,d)}r.log=console.debug||console.log||(()=>{});function a(h){try{h?r.storage.setItem("debug",h):r.storage.removeItem("debug")}catch{}}function t(){let h;try{h=r.storage.getItem("debug")}catch{}return!h&&typeof process<"u"&&"env"in process&&(h=process.env.DEBUG),h}function s(){try{return localStorage}catch{}}c.exports=vh(r);const{formatters:p}=c.exports;p.j=function(h){try{return JSON.stringify(h)}catch(d){return"[UnexpectedJSONParseError]: "+d.message}}})(Uo,Uo.exports);var vn=Uo.exports;function Th(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Mu(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Eh(c,r,n){return r&&Mu(c.prototype,r),n&&Mu(c,n),c}var Tn=vn,En="JsSIP",rt=function(){function c(r){Th(this,c),r?(this._debug=Tn.default("".concat(En,":").concat(r)),this._warn=Tn.default("".concat(En,":WARN:").concat(r)),this._error=Tn.default("".concat(En,":ERROR:").concat(r))):(this._debug=Tn.default(En),this._warn=Tn.default("".concat(En,":WARN")),this._error=Tn.default("".concat(En,":ERROR"))),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}return Eh(c,[{key:"debug",get:function(){return this._debug}},{key:"warn",get:function(){return this._warn}},{key:"error",get:function(){return this._error}}]),c}(),Ot={},xu={},Lu={exports:{}},$u=Lu.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(c){return c.encoding?"rtpmap:%d %s/%s/%s":c.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(c){return c.address!=null?"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(c){return c.subtype!=null?"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(c){return"extmap:%d"+(c.direction?"/%s":"%v")+(c["encrypt-uri"]?" %s":"%v")+" %s"+(c.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(c){return c.sessionConfig!=null?"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(c){var r="candidate:%s %d %s %d %s %d typ %s";return r+=c.raddr!=null?" raddr %s rport %d":"%v%v",r+=c.tcptype!=null?" tcptype %s":"%v",c.generation!=null&&(r+=" generation %d"),r+=c["network-id"]!=null?" network-id %d":"%v",r+=c["network-cost"]!=null?" network-cost %d":"%v",r}},{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(c){var r="ssrc:%d";return c.attribute!=null&&(r+=" %s",c.value!=null&&(r+=":%s")),r}},{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(c){return c.maxMessageSize!=null?"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(c){return c.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(c){return"imageattr:%s %s %s"+(c.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(c){return"simulcast:%s %s"+(c.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"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(c){return"ts-refclk:%s"+(c.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(c){var r="mediaclk:";return r+=c.id!=null?"id=%s %s":"%v%s",r+=c.mediaClockValue!=null?"=%s":"",r+=c.rateNumerator!=null?" rate=%s":"",r+=c.rateDenominator!=null?"/%s":"",r}},{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($u).forEach(function(c){var r=$u[c];r.forEach(function(n){n.reg||(n.reg=/(.*)/),n.format||(n.format="%s")})});var Hu=Lu.exports;(function(c){var r=function(p){return String(Number(p))===p?Number(p):p},n=function(p,h,d,g){if(g&&!d)h[g]=r(p[1]);else for(var v=0;v<d.length;v+=1)p[v+1]!=null&&(h[d[v]]=r(p[v+1]))},o=function(p,h,d){var g=p.name&&p.names;p.push&&!h[p.push]?h[p.push]=[]:g&&!h[p.name]&&(h[p.name]={});var v=p.push?{}:g?h[p.name]:h;n(d.match(p.reg),v,p.names,p.name),p.push&&h[p.push].push(v)},a=Hu,t=RegExp.prototype.test.bind(/^([a-z])=(.*)/);c.parse=function(p){var h={},d=[],g=h;return p.split(/(\r\n|\r|\n)/).filter(t).forEach(function(v){var E=v[0],S=v.slice(2);E==="m"&&(d.push({rtp:[],fmtp:[]}),g=d[d.length-1]);for(var C=0;C<(a[E]||[]).length;C+=1){var I=a[E][C];if(I.reg.test(S))return o(I,g,S)}}),h.media=d,h};var s=function(p,h){var d=h.split(/=(.+)/,2);return d.length===2?p[d[0]]=r(d[1]):d.length===1&&h.length>1&&(p[d[0]]=void 0),p};c.parseParams=function(p){return p.split(/;\s?/).reduce(s,{})},c.parseFmtpConfig=c.parseParams,c.parsePayloads=function(p){return p.toString().split(" ").map(Number)},c.parseRemoteCandidates=function(p){for(var h=[],d=p.split(" ").map(r),g=0;g<d.length;g+=3)h.push({component:d[g],ip:d[g+1],port:d[g+2]});return h},c.parseImageAttributes=function(p){return p.split(" ").map(function(h){return h.substring(1,h.length-1).split(",").reduce(s,{})})},c.parseSimulcastStreamList=function(p){return p.split(";").map(function(h){return h.split(",").map(function(d){var g,v=!1;return d[0]!=="~"?g=r(d):(g=r(d.substring(1,d.length)),v=!0),{scid:g,paused:v}})})}})(xu);var ko=Hu,yh=/%[sdv%]/g,Sh=function(c){var r=1,n=arguments,o=n.length;return c.replace(yh,function(a){if(r>=o)return a;var t=n[r];switch(r+=1,a){case"%%":return"%";case"%s":return String(t);case"%d":return Number(t);case"%v":return""}})},cr=function(c,r,n){var o=r.format instanceof Function?r.format(r.push?n:n[r.name]):r.format,a=[c+"="+o];if(r.names)for(var t=0;t<r.names.length;t+=1){var s=r.names[t];r.name?a.push(n[r.name][s]):a.push(n[r.names[t]])}else a.push(n[r.name]);return Sh.apply(null,a)},Ch=["v","o","s","i","u","e","p","c","b","t","r","z","a"],Ah=["i","c","b","a"],Rh=function(c,r){r=r||{},c.version==null&&(c.version=0),c.name==null&&(c.name=" "),c.media.forEach(function(t){t.payloads==null&&(t.payloads="")});var n=r.outerOrder||Ch,o=r.innerOrder||Ah,a=[];return n.forEach(function(t){ko[t].forEach(function(s){s.name in c&&c[s.name]!=null?a.push(cr(t,s,c)):s.push in c&&c[s.push]!=null&&c[s.push].forEach(function(p){a.push(cr(t,s,p))})})}),c.media.forEach(function(t){a.push(cr("m",ko.m[0],t)),o.forEach(function(s){ko[s].forEach(function(p){p.name in t&&t[p.name]!=null?a.push(cr(s,p,t)):p.push in t&&t[p.push]!=null&&t[p.push].forEach(function(h){a.push(cr(s,p,h))})})})}),a.join(`\r
|
6
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var I=!0,w=!1,F;return{s:function(){E=g[Symbol.iterator]()},n:function(){var ie=E.next();return I=ie.done,ie},e:function(ie){w=!0,F=ie},f:function(){try{!I&&E.return!=null&&E.return()}finally{if(w)throw F}}}}function n(g,v){if(g){if(typeof g=="string")return o(g,v);var E=Object.prototype.toString.call(g).slice(8,-1);if(E==="Object"&&g.constructor&&(E=g.constructor.name),E==="Map"||E==="Set")return Array.from(g);if(E==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(E))return o(g,v)}}function o(g,v){(v==null||v>g.length)&&(v=g.length);for(var E=0,S=new Array(v);E<v;E++)S[E]=g[E];return S}var a=Xe,t=gs(),s=Vt();Ye.str_utf8_length=function(g){return unescape(encodeURIComponent(g)).length};var p=Ye.isFunction=function(g){return g!==void 0?Object.prototype.toString.call(g)==="[object Function]":!1};Ye.isString=function(g){return g!==void 0?Object.prototype.toString.call(g)==="[object String]":!1},Ye.isDecimal=function(g){return!isNaN(g)&&parseFloat(g)===parseInt(g,10)},Ye.isEmpty=function(g){return g===null||g===""||g===void 0||Array.isArray(g)&&g.length===0||typeof g=="number"&&isNaN(g)},Ye.hasMethods=function(g){for(var v=arguments.length,E=new Array(v>1?v-1:0),S=1;S<v;S++)E[S-1]=arguments[S];for(var C=0,I=E;C<I.length;C++){var w=I[C];if(p(g[w]))return!1}return!0};var h=Ye.createRandomToken=function(g){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:32,E,S,C="";for(E=0;E<g;E++)S=Math.random()*v|0,C+=S.toString(v);return C};Ye.newTag=function(){return h(10)},Ye.newUUID=function(){var g="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(v){var E=Math.random()*16|0,S=v==="x"?E:E&3|8;return S.toString(16)});return g},Ye.hostType=function(g){if(g){if(g=s.parse(g,"host"),g!==-1)return g.host_type}else return};var d=Ye.escapeUser=function(g){return encodeURIComponent(decodeURIComponent(g)).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/")};return Ye.normalizeTarget=function(g,v){if(g){if(g instanceof t)return g;if(typeof g=="string"){var E=g.split("@"),S,C;switch(E.length){case 1:if(!v)return;S=g,C=v;break;case 2:S=E[0],C=E[1];break;default:S=E.slice(0,E.length-1).join("@"),C=E[E.length-1]}S=S.replace(/^(sips?|tel):/i,""),/^[-.()]*\+?[0-9\-.()]+$/.test(S)&&(S=S.replace(/[-.()]/g,"")),g="".concat(a.SIP,":").concat(d(S),"@").concat(C);var I;return(I=t.parse(g))?I:void 0}else return}else return},Ye.headerize=function(g){var v={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},E=g.toLowerCase().replace(/_/g,"-").split("-"),S="",C=E.length,I;for(I=0;I<C;I++)I!==0&&(S+="-"),S+=E[I].charAt(0).toUpperCase()+E[I].substring(1);return v[S]&&(S=v[S]),S},Ye.sipErrorCause=function(g){for(var v in a.SIP_ERROR_CAUSES)if(a.SIP_ERROR_CAUSES[v].indexOf(g)!==-1)return a.causes[v];return a.causes.SIP_FAILURE_CODE},Ye.getRandomTestNetIP=function(){function g(v,E){return Math.floor(Math.random()*(E-v+1)+v)}return"192.0.2.".concat(g(1,254))},Ye.calculateMD5=function(g){function v(he,ce){return he<<ce|he>>>32-ce}function E(he,ce){var fe=he&2147483648,Re=ce&2147483648,Oe=he&1073741824,Je=ce&1073741824,Me=(he&1073741823)+(ce&1073741823);return Oe&Je?Me^2147483648^fe^Re:Oe|Je?Me&1073741824?Me^3221225472^fe^Re:Me^1073741824^fe^Re:Me^fe^Re}function S(he,ce,fe){return he&ce|~he&fe}function C(he,ce,fe){return he&fe|ce&~fe}function I(he,ce,fe){return he^ce^fe}function w(he,ce,fe){return ce^(he|~fe)}function F(he,ce,fe,Re,Oe,Je,Me){return he=E(he,E(E(S(ce,fe,Re),Oe),Me)),E(v(he,Je),ce)}function L(he,ce,fe,Re,Oe,Je,Me){return he=E(he,E(E(C(ce,fe,Re),Oe),Me)),E(v(he,Je),ce)}function ie(he,ce,fe,Re,Oe,Je,Me){return he=E(he,E(E(I(ce,fe,Re),Oe),Me)),E(v(he,Je),ce)}function N(he,ce,fe,Re,Oe,Je,Me){return he=E(he,E(E(w(ce,fe,Re),Oe),Me)),E(v(he,Je),ce)}function H(he){for(var ce,fe=he.length,Re=fe+8,Oe=(Re-Re%64)/64,Je=(Oe+1)*16,Me=new Array(Je-1),Pt=0,gt=0;gt<fe;)ce=(gt-gt%4)/4,Pt=gt%4*8,Me[ce]=Me[ce]|he.charCodeAt(gt)<<Pt,gt++;return ce=(gt-gt%4)/4,Pt=gt%4*8,Me[ce]=Me[ce]|128<<Pt,Me[Je-2]=fe<<3,Me[Je-1]=fe>>>29,Me}function ve(he){var ce="",fe="",Re,Oe;for(Oe=0;Oe<=3;Oe++)Re=he>>>Oe*8&255,fe="0".concat(Re.toString(16)),ce=ce+fe.substr(fe.length-2,2);return ce}function me(he){for(var ce="",fe=0;fe<he.length;fe++){var Re=he.charCodeAt(fe);Re<128?ce+=String.fromCharCode(Re):Re>127&&Re<2048?(ce+=String.fromCharCode(Re>>6|192),ce+=String.fromCharCode(Re&63|128)):(ce+=String.fromCharCode(Re>>12|224),ce+=String.fromCharCode(Re>>6&63|128),ce+=String.fromCharCode(Re&63|128))}return ce}var M=[],D,j,V,Y,$,X,U,P,Z,et=7,Q=12,W=17,B=22,te=5,de=9,Ae=14,Ue=20,Se=4,ne=11,Te=16,tt=23,st=6,ge=10,Ee=15,Ce=21;for(g=me(g),M=H(g),X=1732584193,U=4023233417,P=2562383102,Z=271733878,D=0;D<M.length;D+=16)j=X,V=U,Y=P,$=Z,X=F(X,U,P,Z,M[D+0],et,3614090360),Z=F(Z,X,U,P,M[D+1],Q,3905402710),P=F(P,Z,X,U,M[D+2],W,606105819),U=F(U,P,Z,X,M[D+3],B,3250441966),X=F(X,U,P,Z,M[D+4],et,4118548399),Z=F(Z,X,U,P,M[D+5],Q,1200080426),P=F(P,Z,X,U,M[D+6],W,2821735955),U=F(U,P,Z,X,M[D+7],B,4249261313),X=F(X,U,P,Z,M[D+8],et,1770035416),Z=F(Z,X,U,P,M[D+9],Q,2336552879),P=F(P,Z,X,U,M[D+10],W,4294925233),U=F(U,P,Z,X,M[D+11],B,2304563134),X=F(X,U,P,Z,M[D+12],et,1804603682),Z=F(Z,X,U,P,M[D+13],Q,4254626195),P=F(P,Z,X,U,M[D+14],W,2792965006),U=F(U,P,Z,X,M[D+15],B,1236535329),X=L(X,U,P,Z,M[D+1],te,4129170786),Z=L(Z,X,U,P,M[D+6],de,3225465664),P=L(P,Z,X,U,M[D+11],Ae,643717713),U=L(U,P,Z,X,M[D+0],Ue,3921069994),X=L(X,U,P,Z,M[D+5],te,3593408605),Z=L(Z,X,U,P,M[D+10],de,38016083),P=L(P,Z,X,U,M[D+15],Ae,3634488961),U=L(U,P,Z,X,M[D+4],Ue,3889429448),X=L(X,U,P,Z,M[D+9],te,568446438),Z=L(Z,X,U,P,M[D+14],de,3275163606),P=L(P,Z,X,U,M[D+3],Ae,4107603335),U=L(U,P,Z,X,M[D+8],Ue,1163531501),X=L(X,U,P,Z,M[D+13],te,2850285829),Z=L(Z,X,U,P,M[D+2],de,4243563512),P=L(P,Z,X,U,M[D+7],Ae,1735328473),U=L(U,P,Z,X,M[D+12],Ue,2368359562),X=ie(X,U,P,Z,M[D+5],Se,4294588738),Z=ie(Z,X,U,P,M[D+8],ne,2272392833),P=ie(P,Z,X,U,M[D+11],Te,1839030562),U=ie(U,P,Z,X,M[D+14],tt,4259657740),X=ie(X,U,P,Z,M[D+1],Se,2763975236),Z=ie(Z,X,U,P,M[D+4],ne,1272893353),P=ie(P,Z,X,U,M[D+7],Te,4139469664),U=ie(U,P,Z,X,M[D+10],tt,3200236656),X=ie(X,U,P,Z,M[D+13],Se,681279174),Z=ie(Z,X,U,P,M[D+0],ne,3936430074),P=ie(P,Z,X,U,M[D+3],Te,3572445317),U=ie(U,P,Z,X,M[D+6],tt,76029189),X=ie(X,U,P,Z,M[D+9],Se,3654602809),Z=ie(Z,X,U,P,M[D+12],ne,3873151461),P=ie(P,Z,X,U,M[D+15],Te,530742520),U=ie(U,P,Z,X,M[D+2],tt,3299628645),X=N(X,U,P,Z,M[D+0],st,4096336452),Z=N(Z,X,U,P,M[D+7],ge,1126891415),P=N(P,Z,X,U,M[D+14],Ee,2878612391),U=N(U,P,Z,X,M[D+5],Ce,4237533241),X=N(X,U,P,Z,M[D+12],st,1700485571),Z=N(Z,X,U,P,M[D+3],ge,2399980690),P=N(P,Z,X,U,M[D+10],Ee,4293915773),U=N(U,P,Z,X,M[D+1],Ce,2240044497),X=N(X,U,P,Z,M[D+8],st,1873313359),Z=N(Z,X,U,P,M[D+15],ge,4264355552),P=N(P,Z,X,U,M[D+6],Ee,2734768916),U=N(U,P,Z,X,M[D+13],Ce,1309151649),X=N(X,U,P,Z,M[D+4],st,4149444226),Z=N(Z,X,U,P,M[D+11],ge,3174756917),P=N(P,Z,X,U,M[D+2],Ee,718787259),U=N(U,P,Z,X,M[D+9],Ce,3951481745),X=E(X,j),U=E(U,V),P=E(P,Y),Z=E(Z,$);var be=ve(X)+ve(U)+ve(P)+ve(Z);return be.toLowerCase()},Ye.closeMediaStream=function(g){if(g)try{var v;if(g.getTracks){v=g.getTracks();var E=r(v),S;try{for(E.s();!(S=E.n()).done;){var C=S.value;C.stop()}}catch(H){E.e(H)}finally{E.f()}}else{v=g.getAudioTracks();var I=r(v),w;try{for(I.s();!(w=I.n()).done;){var F=w.value;F.stop()}}catch(H){I.e(H)}finally{I.f()}v=g.getVideoTracks();var L=r(v),ie;try{for(L.s();!(ie=L.n()).done;){var N=ie.value;N.stop()}}catch(H){L.e(H)}finally{L.f()}}}catch{(typeof g.stop=="function"||c(g.stop)==="object")&&g.stop()}},Ye.cloneArray=function(g){return g&&g.slice()||[]},Ye.cloneObject=function(g){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return g&&Object.assign({},g)||v},Ye}var No={exports:{}},gn=typeof Reflect=="object"?Reflect:null,Au=gn&&typeof gn.apply=="function"?gn.apply:function(r,n,o){return Function.prototype.apply.call(r,n,o)},al;gn&&typeof gn.ownKeys=="function"?al=gn.ownKeys:Object.getOwnPropertySymbols?al=function(r){return Object.getOwnPropertyNames(r).concat(Object.getOwnPropertySymbols(r))}:al=function(r){return Object.getOwnPropertyNames(r)};function ch(c){console&&console.warn&&console.warn(c)}var Ru=Number.isNaN||function(r){return r!==r};function Pe(){Pe.init.call(this)}No.exports=Pe,No.exports.once=dh,Pe.EventEmitter=Pe,Pe.prototype._events=void 0,Pe.prototype._eventsCount=0,Pe.prototype._maxListeners=void 0;var Iu=10;function ul(c){if(typeof c!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof c)}Object.defineProperty(Pe,"defaultMaxListeners",{enumerable:!0,get:function(){return Iu},set:function(c){if(typeof c!="number"||c<0||Ru(c))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+c+".");Iu=c}}),Pe.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Pe.prototype.setMaxListeners=function(r){if(typeof r!="number"||r<0||Ru(r))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+r+".");return this._maxListeners=r,this};function bu(c){return c._maxListeners===void 0?Pe.defaultMaxListeners:c._maxListeners}Pe.prototype.getMaxListeners=function(){return bu(this)},Pe.prototype.emit=function(r){for(var n=[],o=1;o<arguments.length;o++)n.push(arguments[o]);var a=r==="error",t=this._events;if(t!==void 0)a=a&&t.error===void 0;else if(!a)return!1;if(a){var s;if(n.length>0&&(s=n[0]),s instanceof Error)throw s;var p=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw p.context=s,p}var h=t[r];if(h===void 0)return!1;if(typeof h=="function")Au(h,this,n);else for(var d=h.length,g=Uu(h,d),o=0;o<d;++o)Au(g[o],this,n);return!0};function wu(c,r,n,o){var a,t,s;if(ul(n),t=c._events,t===void 0?(t=c._events=Object.create(null),c._eventsCount=0):(t.newListener!==void 0&&(c.emit("newListener",r,n.listener?n.listener:n),t=c._events),s=t[r]),s===void 0)s=t[r]=n,++c._eventsCount;else if(typeof s=="function"?s=t[r]=o?[n,s]:[s,n]:o?s.unshift(n):s.push(n),a=bu(c),a>0&&s.length>a&&!s.warned){s.warned=!0;var p=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(r)+" listeners added. Use emitter.setMaxListeners() to increase limit");p.name="MaxListenersExceededWarning",p.emitter=c,p.type=r,p.count=s.length,ch(p)}return c}Pe.prototype.addListener=function(r,n){return wu(this,r,n,!1)},Pe.prototype.on=Pe.prototype.addListener,Pe.prototype.prependListener=function(r,n){return wu(this,r,n,!0)};function fh(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Ou(c,r,n){var o={fired:!1,wrapFn:void 0,target:c,type:r,listener:n},a=fh.bind(o);return a.listener=n,o.wrapFn=a,a}Pe.prototype.once=function(r,n){return ul(n),this.on(r,Ou(this,r,n)),this},Pe.prototype.prependOnceListener=function(r,n){return ul(n),this.prependListener(r,Ou(this,r,n)),this},Pe.prototype.removeListener=function(r,n){var o,a,t,s,p;if(ul(n),a=this._events,a===void 0)return this;if(o=a[r],o===void 0)return this;if(o===n||o.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete a[r],a.removeListener&&this.emit("removeListener",r,o.listener||n));else if(typeof o!="function"){for(t=-1,s=o.length-1;s>=0;s--)if(o[s]===n||o[s].listener===n){p=o[s].listener,t=s;break}if(t<0)return this;t===0?o.shift():hh(o,t),o.length===1&&(a[r]=o[0]),a.removeListener!==void 0&&this.emit("removeListener",r,p||n)}return this},Pe.prototype.off=Pe.prototype.removeListener,Pe.prototype.removeAllListeners=function(r){var n,o,a;if(o=this._events,o===void 0)return this;if(o.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):o[r]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete o[r]),this;if(arguments.length===0){var t=Object.keys(o),s;for(a=0;a<t.length;++a)s=t[a],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(n=o[r],typeof n=="function")this.removeListener(r,n);else if(n!==void 0)for(a=n.length-1;a>=0;a--)this.removeListener(r,n[a]);return this};function Du(c,r,n){var o=c._events;if(o===void 0)return[];var a=o[r];return a===void 0?[]:typeof a=="function"?n?[a.listener||a]:[a]:n?_h(a):Uu(a,a.length)}Pe.prototype.listeners=function(r){return Du(this,r,!0)},Pe.prototype.rawListeners=function(r){return Du(this,r,!1)},Pe.listenerCount=function(c,r){return typeof c.listenerCount=="function"?c.listenerCount(r):Nu.call(c,r)},Pe.prototype.listenerCount=Nu;function Nu(c){var r=this._events;if(r!==void 0){var n=r[c];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}Pe.prototype.eventNames=function(){return this._eventsCount>0?al(this._events):[]};function Uu(c,r){for(var n=new Array(r),o=0;o<r;++o)n[o]=c[o];return n}function hh(c,r){for(;r+1<c.length;r++)c[r]=c[r+1];c.pop()}function _h(c){for(var r=new Array(c.length),n=0;n<r.length;++n)r[n]=c[n].listener||c[n];return r}function dh(c,r){return new Promise(function(n,o){function a(s){c.removeListener(r,t),o(s)}function t(){typeof c.removeListener=="function"&&c.removeListener("error",a),n([].slice.call(arguments))}Pu(c,r,t,{once:!0}),r!=="error"&&ph(c,a,{once:!0})})}function ph(c,r,n){typeof c.on=="function"&&Pu(c,"error",r,n)}function Pu(c,r,n,o){if(typeof c.on=="function")o.once?c.once(r,n):c.on(r,n);else if(typeof c.addEventListener=="function")c.addEventListener(r,function a(t){o.once&&c.removeEventListener(r,a),n(t)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof c)}var ot=No.exports,Uo={exports:{}},Po,ku;function mh(){if(ku)return Po;ku=1;var c=1e3,r=c*60,n=r*60,o=n*24,a=o*7,t=o*365.25;Po=function(g,v){v=v||{};var E=typeof g;if(E==="string"&&g.length>0)return s(g);if(E==="number"&&isFinite(g))return v.long?h(g):p(g);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(g))};function s(g){if(g=String(g),!(g.length>100)){var v=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(g);if(v){var E=parseFloat(v[1]),S=(v[2]||"ms").toLowerCase();switch(S){case"years":case"year":case"yrs":case"yr":case"y":return E*t;case"weeks":case"week":case"w":return E*a;case"days":case"day":case"d":return E*o;case"hours":case"hour":case"hrs":case"hr":case"h":return E*n;case"minutes":case"minute":case"mins":case"min":case"m":return E*r;case"seconds":case"second":case"secs":case"sec":case"s":return E*c;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return E;default:return}}}}function p(g){var v=Math.abs(g);return v>=o?Math.round(g/o)+"d":v>=n?Math.round(g/n)+"h":v>=r?Math.round(g/r)+"m":v>=c?Math.round(g/c)+"s":g+"ms"}function h(g){var v=Math.abs(g);return v>=o?d(g,v,o,"day"):v>=n?d(g,v,n,"hour"):v>=r?d(g,v,r,"minute"):v>=c?d(g,v,c,"second"):g+" ms"}function d(g,v,E,S){var C=v>=E*1.5;return Math.round(g/E)+" "+S+(C?"s":"")}return Po}function gh(c){n.debug=n,n.default=n,n.coerce=h,n.disable=t,n.enable=a,n.enabled=s,n.humanize=mh(),n.destroy=d,Object.keys(c).forEach(g=>{n[g]=c[g]}),n.names=[],n.skips=[],n.formatters={};function r(g){let v=0;for(let E=0;E<g.length;E++)v=(v<<5)-v+g.charCodeAt(E),v|=0;return n.colors[Math.abs(v)%n.colors.length]}n.selectColor=r;function n(g){let v,E=null,S,C;function I(...w){if(!I.enabled)return;const F=I,L=Number(new Date),ie=L-(v||L);F.diff=ie,F.prev=v,F.curr=L,v=L,w[0]=n.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let N=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(ve,me)=>{if(ve==="%%")return"%";N++;const M=n.formatters[me];if(typeof M=="function"){const D=w[N];ve=M.call(F,D),w.splice(N,1),N--}return ve}),n.formatArgs.call(F,w),(F.log||n.log).apply(F,w)}return I.namespace=g,I.useColors=n.useColors(),I.color=n.selectColor(g),I.extend=o,I.destroy=n.destroy,Object.defineProperty(I,"enabled",{enumerable:!0,configurable:!1,get:()=>E!==null?E:(S!==n.namespaces&&(S=n.namespaces,C=n.enabled(g)),C),set:w=>{E=w}}),typeof n.init=="function"&&n.init(I),I}function o(g,v){const E=n(this.namespace+(typeof v>"u"?":":v)+g);return E.log=this.log,E}function a(g){n.save(g),n.namespaces=g,n.names=[],n.skips=[];let v;const E=(typeof g=="string"?g:"").split(/[\s,]+/),S=E.length;for(v=0;v<S;v++)E[v]&&(g=E[v].replace(/\*/g,".*?"),g[0]==="-"?n.skips.push(new RegExp("^"+g.slice(1)+"$")):n.names.push(new RegExp("^"+g+"$")))}function t(){const g=[...n.names.map(p),...n.skips.map(p).map(v=>"-"+v)].join(",");return n.enable(""),g}function s(g){if(g[g.length-1]==="*")return!0;let v,E;for(v=0,E=n.skips.length;v<E;v++)if(n.skips[v].test(g))return!1;for(v=0,E=n.names.length;v<E;v++)if(n.names[v].test(g))return!0;return!1}function p(g){return g.toString().substring(2,g.toString().length-2).replace(/\.\*\?$/,"*")}function h(g){return g instanceof Error?g.stack||g.message:g}function d(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}var vh=gh;(function(c,r){r.formatArgs=o,r.save=a,r.load=t,r.useColors=n,r.storage=s(),r.destroy=(()=>{let h=!1;return()=>{h||(h=!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`."))}})(),r.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"];function n(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function o(h){if(h[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+h[0]+(this.useColors?"%c ":" ")+"+"+c.exports.humanize(this.diff),!this.useColors)return;const d="color: "+this.color;h.splice(1,0,d,"color: inherit");let g=0,v=0;h[0].replace(/%[a-zA-Z%]/g,E=>{E!=="%%"&&(g++,E==="%c"&&(v=g))}),h.splice(v,0,d)}r.log=console.debug||console.log||(()=>{});function a(h){try{h?r.storage.setItem("debug",h):r.storage.removeItem("debug")}catch{}}function t(){let h;try{h=r.storage.getItem("debug")}catch{}return!h&&typeof process<"u"&&"env"in process&&(h=process.env.DEBUG),h}function s(){try{return localStorage}catch{}}c.exports=vh(r);const{formatters:p}=c.exports;p.j=function(h){try{return JSON.stringify(h)}catch(d){return"[UnexpectedJSONParseError]: "+d.message}}})(Uo,Uo.exports);var vn=Uo.exports;function Th(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Mu(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Eh(c,r,n){return r&&Mu(c.prototype,r),n&&Mu(c,n),c}var Tn=vn,En="JsSIP",rt=function(){function c(r){Th(this,c),r?(this._debug=Tn.default("".concat(En,":").concat(r)),this._warn=Tn.default("".concat(En,":WARN:").concat(r)),this._error=Tn.default("".concat(En,":ERROR:").concat(r))):(this._debug=Tn.default(En),this._warn=Tn.default("".concat(En,":WARN")),this._error=Tn.default("".concat(En,":ERROR"))),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}return Eh(c,[{key:"debug",get:function(){return this._debug}},{key:"warn",get:function(){return this._warn}},{key:"error",get:function(){return this._error}}]),c}(),Ot={},xu={},Lu={exports:{}},$u=Lu.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(c){return c.encoding?"rtpmap:%d %s/%s/%s":c.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(c){return c.address!=null?"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(c){return c.subtype!=null?"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(c){return"extmap:%d"+(c.direction?"/%s":"%v")+(c["encrypt-uri"]?" %s":"%v")+" %s"+(c.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(c){return c.sessionConfig!=null?"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(c){var r="candidate:%s %d %s %d %s %d typ %s";return r+=c.raddr!=null?" raddr %s rport %d":"%v%v",r+=c.tcptype!=null?" tcptype %s":"%v",c.generation!=null&&(r+=" generation %d"),r+=c["network-id"]!=null?" network-id %d":"%v",r+=c["network-cost"]!=null?" network-cost %d":"%v",r}},{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(c){var r="ssrc:%d";return c.attribute!=null&&(r+=" %s",c.value!=null&&(r+=":%s")),r}},{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(c){return c.maxMessageSize!=null?"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(c){return c.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(c){return"imageattr:%s %s %s"+(c.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(c){return"simulcast:%s %s"+(c.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"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(c){return"ts-refclk:%s"+(c.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(c){var r="mediaclk:";return r+=c.id!=null?"id=%s %s":"%v%s",r+=c.mediaClockValue!=null?"=%s":"",r+=c.rateNumerator!=null?" rate=%s":"",r+=c.rateDenominator!=null?"/%s":"",r}},{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($u).forEach(function(c){var r=$u[c];r.forEach(function(n){n.reg||(n.reg=/(.*)/),n.format||(n.format="%s")})});var Hu=Lu.exports;(function(c){var r=function(p){return String(Number(p))===p?Number(p):p},n=function(p,h,d,g){if(g&&!d)h[g]=r(p[1]);else for(var v=0;v<d.length;v+=1)p[v+1]!=null&&(h[d[v]]=r(p[v+1]))},o=function(p,h,d){var g=p.name&&p.names;p.push&&!h[p.push]?h[p.push]=[]:g&&!h[p.name]&&(h[p.name]={});var v=p.push?{}:g?h[p.name]:h;n(d.match(p.reg),v,p.names,p.name),p.push&&h[p.push].push(v)},a=Hu,t=RegExp.prototype.test.bind(/^([a-z])=(.*)/);c.parse=function(p){var h={},d=[],g=h;return p.split(/(\r\n|\r|\n)/).filter(t).forEach(function(v){var E=v[0],S=v.slice(2);E==="m"&&(d.push({rtp:[],fmtp:[]}),g=d[d.length-1]);for(var C=0;C<(a[E]||[]).length;C+=1){var I=a[E][C];if(I.reg.test(S))return o(I,g,S)}}),h.media=d,h};var s=function(p,h){var d=h.split(/=(.+)/,2);return d.length===2?p[d[0]]=r(d[1]):d.length===1&&h.length>1&&(p[d[0]]=void 0),p};c.parseParams=function(p){return p.split(/;\s?/).reduce(s,{})},c.parseFmtpConfig=c.parseParams,c.parsePayloads=function(p){return p.toString().split(" ").map(Number)},c.parseRemoteCandidates=function(p){for(var h=[],d=p.split(" ").map(r),g=0;g<d.length;g+=3)h.push({component:d[g],ip:d[g+1],port:d[g+2]});return h},c.parseImageAttributes=function(p){return p.split(" ").map(function(h){return h.substring(1,h.length-1).split(",").reduce(s,{})})},c.parseSimulcastStreamList=function(p){return p.split(";").map(function(h){return h.split(",").map(function(d){var g,v=!1;return d[0]!=="~"?g=r(d):(g=r(d.substring(1,d.length)),v=!0),{scid:g,paused:v}})})}})(xu);var ko=Hu,yh=/%[sdv%]/g,Sh=function(c){var r=1,n=arguments,o=n.length;return c.replace(yh,function(a){if(r>=o)return a;var t=n[r];switch(r+=1,a){case"%%":return"%";case"%s":return String(t);case"%d":return Number(t);case"%v":return""}})},cr=function(c,r,n){var o=r.format instanceof Function?r.format(r.push?n:n[r.name]):r.format,a=[c+"="+o];if(r.names)for(var t=0;t<r.names.length;t+=1){var s=r.names[t];r.name?a.push(n[r.name][s]):a.push(n[r.names[t]])}else a.push(n[r.name]);return Sh.apply(null,a)},Ch=["v","o","s","i","u","e","p","c","b","t","r","z","a"],Ah=["i","c","b","a"],Rh=function(c,r){r=r||{},c.version==null&&(c.version=0),c.name==null&&(c.name=" "),c.media.forEach(function(t){t.payloads==null&&(t.payloads="")});var n=r.outerOrder||Ch,o=r.innerOrder||Ah,a=[];return n.forEach(function(t){ko[t].forEach(function(s){s.name in c&&c[s.name]!=null?a.push(cr(t,s,c)):s.push in c&&c[s.push]!=null&&c[s.push].forEach(function(p){a.push(cr(t,s,p))})})}),c.media.forEach(function(t){a.push(cr("m",ko.m[0],t)),o.forEach(function(s){ko[s].forEach(function(p){p.name in t&&t[p.name]!=null?a.push(cr(s,p,t)):p.push in t&&t[p.push]!=null&&t[p.push].forEach(function(h){a.push(cr(s,p,h))})})})}),a.join(`\r
|
7
7
|
`)+`\r
|
8
|
-
`}
|
8
|
+
`},$s=xu,Ih=Rh;Ot.write=Ih,Ot.parse=$s.parse,Ot.parseParams=$s.parseParams,Ot.parseFmtpConfig=$s.parseFmtpConfig,Ot.parsePayloads=$s.parsePayloads,Ot.parseRemoteCandidates=$s.parseRemoteCandidates,Ot.parseImageAttributes=$s.parseImageAttributes,Ot.parseSimulcastStreamList=$s.parseSimulcastStreamList;function cl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?cl=function(n){return typeof n}:cl=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},cl(c)}function Mo(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&xo(c,r)}function xo(c,r){return xo=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},xo(c,r)}function Lo(c){var r=Oh();return function(){var o=fl(c),a;if(r){var t=fl(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return bh(this,a)}}function bh(c,r){return r&&(cl(r)==="object"||typeof r=="function")?r:wh(c)}function wh(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Oh(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function fl(c){return fl=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},fl(c)}function Dt(c,r){var n;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(n=Dh(c))||r&&c&&typeof c.length=="number"){n&&(c=n);var o=0,a=function(){};return{s:a,n:function(){return o>=c.length?{done:!0}:{done:!1,value:c[o++]}},e:function(d){throw d},f:a}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
9
9
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var t=!0,s=!1,p;return{s:function(){n=c[Symbol.iterator]()},n:function(){var d=n.next();return t=d.done,d},e:function(d){s=!0,p=d},f:function(){try{!t&&n.return!=null&&n.return()}finally{if(s)throw p}}}}function Dh(c,r){if(c){if(typeof c=="string")return Fu(c,r);var n=Object.prototype.toString.call(c).slice(8,-1);if(n==="Object"&&c.constructor&&(n=c.constructor.name),n==="Map"||n==="Set")return Array.from(c);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Fu(c,r)}}function Fu(c,r){(r==null||r>c.length)&&(r=c.length);for(var n=0,o=new Array(r);n<r;n++)o[n]=c[n];return o}function fr(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function qu(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function hl(c,r,n){return r&&qu(c.prototype,r),n&&qu(c,n),c}var Vu=Ot,Nh=rt,at=Xe,Qe=Tt(),ju=wo(),Uh=Vt(),$o=new Nh("SIPMessage"),Bu=function(){function c(r,n,o,a,t,s){if(fr(this,c),!r||!n||!o)return null;a=a||{},this.ua=o,this.headers={},this.method=r,this.ruri=n,this.body=s,this.extraHeaders=Qe.cloneArray(t),this.ua.configuration.extra_headers&&(this.extraHeaders=this.extraHeaders.concat(this.ua.configuration.extra_headers)),a.route_set?this.setHeader("route",a.route_set):o.configuration.use_preloaded_route&&this.setHeader("route","<".concat(o.transport.sip_uri,";lr>")),this.setHeader("via",""),this.setHeader("max-forwards",at.MAX_FORWARDS);var p=a.to_uri||n,h=a.to_tag?{tag:a.to_tag}:null,d=typeof a.to_display_name<"u"?a.to_display_name:null;this.to=new ju(p,d,h),this.setHeader("to",this.to.toString());var g=a.from_uri||o.configuration.uri,v={tag:a.from_tag||Qe.newTag()},E;typeof a.from_display_name<"u"?E=a.from_display_name:o.configuration.display_name?E=o.configuration.display_name:E=null,this.from=new ju(g,E,v),this.setHeader("from",this.from.toString());var S=a.call_id||o.configuration.jssip_id+Qe.createRandomToken(15);this.call_id=S,this.setHeader("call-id",S);var C=a.cseq||Math.floor(Math.random()*1e4);this.cseq=C,this.setHeader("cseq","".concat(C," ").concat(r))}return hl(c,[{key:"setHeader",value:function(n,o){for(var a=new RegExp("^\\s*".concat(n,"\\s*:"),"i"),t=0;t<this.extraHeaders.length;t++)a.test(this.extraHeaders[t])&&this.extraHeaders.splice(t,1);this.headers[Qe.headerize(n)]=Array.isArray(o)?o:[o]}},{key:"getHeader",value:function(n){var o=this.headers[Qe.headerize(n)];if(o){if(o[0])return o[0]}else{var a=new RegExp("^\\s*".concat(n,"\\s*:"),"i"),t=Dt(this.extraHeaders),s;try{for(t.s();!(s=t.n()).done;){var p=s.value;if(a.test(p))return p.substring(p.indexOf(":")+1).trim()}}catch(h){t.e(h)}finally{t.f()}}}},{key:"getHeaders",value:function(n){var o=this.headers[Qe.headerize(n)],a=[];if(o){var t=Dt(o),s;try{for(t.s();!(s=t.n()).done;){var p=s.value;a.push(p)}}catch(E){t.e(E)}finally{t.f()}return a}else{var h=new RegExp("^\\s*".concat(n,"\\s*:"),"i"),d=Dt(this.extraHeaders),g;try{for(d.s();!(g=d.n()).done;){var v=g.value;h.test(v)&&a.push(v.substring(v.indexOf(":")+1).trim())}}catch(E){d.e(E)}finally{d.f()}return a}}},{key:"hasHeader",value:function(n){if(this.headers[Qe.headerize(n)])return!0;var o=new RegExp("^\\s*".concat(n,"\\s*:"),"i"),a=Dt(this.extraHeaders),t;try{for(a.s();!(t=a.n()).done;){var s=t.value;if(o.test(s))return!0}}catch(p){a.e(p)}finally{a.f()}return!1}},{key:"parseSDP",value:function(n){return!n&&this.sdp?this.sdp:(this.sdp=Vu.parse(this.body||""),this.sdp)}},{key:"toString",value:function(){var n="".concat(this.method," ").concat(this.ruri,` SIP/2.0\r
|
10
10
|
`);for(var o in this.headers)if(Object.prototype.hasOwnProperty.call(this.headers,o)){var a=Dt(this.headers[o]),t;try{for(a.s();!(t=a.n()).done;){var s=t.value;n+="".concat(o,": ").concat(s,`\r
|
11
11
|
`)}}catch(S){a.e(S)}finally{a.f()}}var p=Dt(this.extraHeaders),h;try{for(p.s();!(h=p.n()).done;){var d=h.value;n+="".concat(d.trim(),`\r
|
@@ -43,11 +43,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
43
43
|
`),this.ua.configuration.extra_headers){var E=Dt(this.ua.configuration.extra_headers),S;try{for(E.s();!(S=E.n()).done;){var C=S.value;p+="".concat(C.trim(),`\r
|
44
44
|
`)}}catch(I){E.e(I)}finally{E.f()}}p+="Content-Length: ".concat(0,`\r
|
45
45
|
\r
|
46
|
-
`),this.transport.send(p)}}]),n}(Gu),Mh=function(c){Mo(n,c);var r=Lo(n);function n(){var o;return fr(this,n),o=r.call(this),o.headers={},o.status_code=null,o.reason_phrase=null,o}return n}(Gu),ts={OutgoingRequest:Bu,InitialOutgoingInviteRequest:Ph,IncomingRequest:kh,IncomingResponse:Mh};function xh(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Ku(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Lh(c,r,n){return r&&Ku(c.prototype,r),n&&Ku(c,n),c}var $h=rt,ss=Tt(),$t=new $h("DigestAuthentication"),Hh=function(){function c(r){xh(this,c),this._credentials=r,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}return Lh(c,[{key:"get",value:function(n){switch(n){case"realm":return this._realm;case"ha1":return this._ha1;default:$t.warn('get() | cannot get "%s" parameter',n);return}}},{key:"authenticate",value:function(n,o){var a=n.method,t=n.ruri,s=n.body,p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;if(this._algorithm=o.algorithm,this._realm=o.realm,this._nonce=o.nonce,this._opaque=o.opaque,this._stale=o.stale,this._algorithm){if(this._algorithm!=="MD5")return $t.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return $t.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return $t.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return $t.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return $t.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(o.qop)if(o.qop.indexOf("auth-int")>-1)this._qop="auth-int";else if(o.qop.indexOf("auth")>-1)this._qop="auth";else return $t.warn('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;else this._qop=null;this._method=a,this._uri=t,this._cnonce=p||ss.createRandomToken(12),this._nc+=1;var h=Number(this._nc).toString(16);this._ncHex="00000000".substr(0,8-h.length)+h,this._nc===4294967296&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=ss.calculateMD5("".concat(this._credentials.username,":").concat(this._realm,":").concat(this._credentials.password)):this._ha1=this._credentials.ha1;var d,g;return this._qop==="auth"?(d="".concat(this._method,":").concat(this._uri),g=ss.calculateMD5(d),$t.debug('authenticate() | using qop=auth [a2:"%s"]',d),this._response=ss.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(this._ncHex,":").concat(this._cnonce,":auth:").concat(g))):this._qop==="auth-int"?(d="".concat(this._method,":").concat(this._uri,":").concat(ss.calculateMD5(s||"")),g=ss.calculateMD5(d),$t.debug('authenticate() | using qop=auth-int [a2:"%s"]',d),this._response=ss.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(this._ncHex,":").concat(this._cnonce,":auth-int:").concat(g))):this._qop===null&&(d="".concat(this._method,":").concat(this._uri),g=ss.calculateMD5(d),$t.debug('authenticate() | using qop=null [a2:"%s"]',d),this._response=ss.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(g))),$t.debug("authenticate() | response generated"),!0}},{key:"toString",value:function(){var n=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return n.push("algorithm=".concat(this._algorithm)),n.push('username="'.concat(this._credentials.username,'"')),n.push('realm="'.concat(this._realm,'"')),n.push('nonce="'.concat(this._nonce,'"')),n.push('uri="'.concat(this._uri,'"')),n.push('response="'.concat(this._response,'"')),this._opaque&&n.push('opaque="'.concat(this._opaque,'"')),this._qop&&(n.push("qop=".concat(this._qop)),n.push('cnonce="'.concat(this._cnonce,'"')),n.push("nc=".concat(this._ncHex))),"Digest ".concat(n.join(", "))}}]),c}(),ns=500,Fh=4e3,Wu=5e3,Yu={T1:ns,T2:Fh,T4:Wu,TIMER_B:64*ns,TIMER_D:0*ns,TIMER_F:64*ns,TIMER_H:64*ns,TIMER_I:0*ns,TIMER_J:0*ns,TIMER_K:0*Wu,TIMER_L:64*ns,TIMER_M:64*ns,PROVISIONAL_RESPONSE_INTERVAL:6e4};function _l(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?_l=function(n){return typeof n}:_l=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},_l(c)}function hr(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function zu(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function _r(c,r,n){return r&&zu(c.prototype,r),n&&zu(c,n),c}function dr(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&Ho(c,r)}function Ho(c,r){return Ho=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Ho(c,r)}function pr(c){var r=Vh();return function(){var o=dl(c),a;if(r){var t=dl(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return qh(this,a)}}function qh(c,r){return r&&(_l(r)==="object"||typeof r=="function")?r:gs(c)}function gs(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Vh(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function dl(c){return dl=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},dl(c)}var mr=ot.EventEmitter,gr=rt,vr=Xe,Ju=ts,jt=Yu,Xu=new gr("NonInviteClientTransaction"),pl=new gr("InviteClientTransaction"),jh=new gr("AckClientTransaction"),Qu=new gr("NonInviteServerTransaction"),ml=new gr("InviteServerTransaction"),le={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"},Bh=function(c){dr(n,c);var r=pr(n);function n(o,a,t,s){var p;hr(this,n),p=r.call(this),p.type=le.NON_INVITE_CLIENT,p.id="z9hG4bK".concat(Math.floor(Math.random()*1e7)),p.ua=o,p.transport=a,p.request=t,p.eventHandlers=s;var h="SIP/2.0/".concat(a.via_transport);return h+=" ".concat(o.configuration.via_host,";branch=").concat(p.id),p.request.setHeader("via",h),p.ua.newTransaction(gs(p)),p}return _r(n,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"send",value:function(){var a=this;this.stateChanged(le.STATUS_TRYING),this.F=setTimeout(function(){a.timer_F()},jt.TIMER_F),this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){Xu.debug("transport error occurred, deleting transaction ".concat(this.id)),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}},{key:"timer_F",value:function(){Xu.debug("Timer F expired for transaction ".concat(this.id)),this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}},{key:"timer_K",value:function(){this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"receiveResponse",value:function(a){var t=this,s=a.status_code;if(s<200)switch(this.state){case le.STATUS_TRYING:case le.STATUS_PROCEEDING:this.stateChanged(le.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(a);break}else switch(this.state){case le.STATUS_TRYING:case le.STATUS_PROCEEDING:this.stateChanged(le.STATUS_COMPLETED),clearTimeout(this.F),s===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(a),this.K=setTimeout(function(){t.timer_K()},jt.TIMER_K);break;case le.STATUS_COMPLETED:break}}},{key:"C",get:function(){return le}}]),n}(mr),Gh=function(c){dr(n,c);var r=pr(n);function n(o,a,t,s){var p;hr(this,n),p=r.call(this),p.type=le.INVITE_CLIENT,p.id="z9hG4bK".concat(Math.floor(Math.random()*1e7)),p.ua=o,p.transport=a,p.request=t,p.eventHandlers=s,t.transaction=gs(p);var h="SIP/2.0/".concat(a.via_transport);return h+=" ".concat(o.configuration.via_host,";branch=").concat(p.id),p.request.setHeader("via",h),p.ua.newTransaction(gs(p)),p}return _r(n,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"send",value:function(){var a=this;this.stateChanged(le.STATUS_CALLING),this.B=setTimeout(function(){a.timer_B()},jt.TIMER_B),this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==le.STATUS_ACCEPTED&&(pl.debug("transport error occurred, deleting transaction ".concat(this.id)),this.eventHandlers.onTransportError()),this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_M",value:function(){pl.debug("Timer M expired for transaction ".concat(this.id)),this.state===le.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"timer_B",value:function(){pl.debug("Timer B expired for transaction ".concat(this.id)),this.state===le.STATUS_CALLING&&(this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}},{key:"timer_D",value:function(){pl.debug("Timer D expired for transaction ".concat(this.id)),clearTimeout(this.B),this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"sendACK",value:function(a){var t=this,s=new Ju.OutgoingRequest(vr.ACK,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});s.setHeader("from",this.request.getHeader("from")),s.setHeader("via",this.request.getHeader("via")),s.setHeader("to",a.getHeader("to")),this.D=setTimeout(function(){t.timer_D()},jt.TIMER_D),this.transport.send(s)}},{key:"cancel",value:function(a){if(this.state===le.STATUS_PROCEEDING){var t=new Ju.OutgoingRequest(vr.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")),a&&t.setHeader("reason",a),this.transport.send(t)}}},{key:"receiveResponse",value:function(a){var t=this,s=a.status_code;if(s>=100&&s<=199)switch(this.state){case le.STATUS_CALLING:this.stateChanged(le.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(a);break;case le.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(a);break}else if(s>=200&&s<=299)switch(this.state){case le.STATUS_CALLING:case le.STATUS_PROCEEDING:this.stateChanged(le.STATUS_ACCEPTED),this.M=setTimeout(function(){t.timer_M()},jt.TIMER_M),this.eventHandlers.onReceiveResponse(a);break;case le.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(a);break}else if(s>=300&&s<=699)switch(this.state){case le.STATUS_CALLING:case le.STATUS_PROCEEDING:this.stateChanged(le.STATUS_COMPLETED),this.sendACK(a),this.eventHandlers.onReceiveResponse(a);break;case le.STATUS_COMPLETED:this.sendACK(a);break}}},{key:"C",get:function(){return le}}]),n}(mr),Kh=function(c){dr(n,c);var r=pr(n);function n(o,a,t,s){var p;hr(this,n),p=r.call(this),p.id="z9hG4bK".concat(Math.floor(Math.random()*1e7)),p.transport=a,p.request=t,p.eventHandlers=s;var h="SIP/2.0/".concat(a.via_transport);return h+=" ".concat(o.configuration.via_host,";branch=").concat(p.id),p.request.setHeader("via",h),p}return _r(n,[{key:"send",value:function(){this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){jh.debug("transport error occurred for transaction ".concat(this.id)),this.eventHandlers.onTransportError()}},{key:"C",get:function(){return le}}]),n}(mr),Wh=function(c){dr(n,c);var r=pr(n);function n(o,a,t){var s;return hr(this,n),s=r.call(this),s.type=le.NON_INVITE_SERVER,s.id=t.via_branch,s.ua=o,s.transport=a,s.request=t,s.last_response="",t.server_transaction=gs(s),s.state=le.STATUS_TRYING,o.newTransaction(gs(s)),s}return _r(n,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"timer_J",value:function(){Qu.debug("Timer J expired for transaction ".concat(this.id)),this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,Qu.debug("transport error occurred, deleting transaction ".concat(this.id)),clearTimeout(this.J),this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"receiveResponse",value:function(a,t,s,p){var h=this;if(a===100)switch(this.state){case le.STATUS_TRYING:this.stateChanged(le.STATUS_PROCEEDING),this.transport.send(t)||this.onTransportError();break;case le.STATUS_PROCEEDING:this.last_response=t,this.transport.send(t)?s&&s():(this.onTransportError(),p&&p());break}else if(a>=200&&a<=699)switch(this.state){case le.STATUS_TRYING:case le.STATUS_PROCEEDING:this.stateChanged(le.STATUS_COMPLETED),this.last_response=t,this.J=setTimeout(function(){h.timer_J()},jt.TIMER_J),this.transport.send(t)?s&&s():(this.onTransportError(),p&&p());break;case le.STATUS_COMPLETED:break}}},{key:"C",get:function(){return le}}]),n}(mr),Yh=function(c){dr(n,c);var r=pr(n);function n(o,a,t){var s;return hr(this,n),s=r.call(this),s.type=le.INVITE_SERVER,s.id=t.via_branch,s.ua=o,s.transport=a,s.request=t,s.last_response="",t.server_transaction=gs(s),s.state=le.STATUS_PROCEEDING,o.newTransaction(gs(s)),s.resendProvisionalTimer=null,t.reply(100),s}return _r(n,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"timer_H",value:function(){ml.debug("Timer H expired for transaction ".concat(this.id)),this.state===le.STATUS_COMPLETED&&ml.debug("ACK not received, dialog will be terminated"),this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_I",value:function(){this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_L",value:function(){ml.debug("Timer L expired for transaction ".concat(this.id)),this.state===le.STATUS_ACCEPTED&&(this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,ml.debug("transport error occurred, deleting transaction ".concat(this.id)),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),clearTimeout(this.L),clearTimeout(this.H),clearTimeout(this.I),this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"resend_provisional",value:function(){this.transport.send(this.last_response)||this.onTransportError()}},{key:"receiveResponse",value:function(a,t,s,p){var h=this;if(a>=100&&a<=199)switch(this.state){case le.STATUS_PROCEEDING:this.transport.send(t)||this.onTransportError(),this.last_response=t;break}if(a>100&&a<=199&&this.state===le.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(function(){h.resend_provisional()},jt.PROVISIONAL_RESPONSE_INTERVAL));else if(a>=200&&a<=299)switch(this.state){case le.STATUS_PROCEEDING:this.stateChanged(le.STATUS_ACCEPTED),this.last_response=t,this.L=setTimeout(function(){h.timer_L()},jt.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case le.STATUS_ACCEPTED:this.transport.send(t)?s&&s():(this.onTransportError(),p&&p());break}else if(a>=300&&a<=699)switch(this.state){case le.STATUS_PROCEEDING:this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(t)?(this.stateChanged(le.STATUS_COMPLETED),this.H=setTimeout(function(){h.timer_H()},jt.TIMER_H),s&&s()):(this.onTransportError(),p&&p());break}}},{key:"C",get:function(){return le}}]),n}(mr);function zh(c,r){var n=c._transactions,o;switch(r.method){case vr.INVITE:if(o=n.ist[r.via_branch],o){switch(o.state){case le.STATUS_PROCEEDING:o.transport.send(o.last_response);break;case le.STATUS_ACCEPTED:break}return!0}break;case vr.ACK:if(o=n.ist[r.via_branch],o){if(o.state===le.STATUS_ACCEPTED)return!1;if(o.state===le.STATUS_COMPLETED)return o.state=le.STATUS_CONFIRMED,o.I=setTimeout(function(){o.timer_I()},jt.TIMER_I),!0}else return!1;break;case vr.CANCEL:return o=n.ist[r.via_branch],o?(r.reply_sl(200),o.state!==le.STATUS_PROCEEDING):(r.reply_sl(481),!0);default:if(o=n.nist[r.via_branch],o){switch(o.state){case le.STATUS_TRYING:break;case le.STATUS_PROCEEDING:case le.STATUS_COMPLETED:o.transport.send(o.last_response);break}return!0}break}}var Tr={C:le,NonInviteClientTransaction:Bh,InviteClientTransaction:Gh,AckClientTransaction:Kh,NonInviteServerTransaction:Wh,InviteServerTransaction:Yh,checkTransaction:zh};function Jh(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Zu(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Xh(c,r,n){return r&&Zu(c.prototype,r),n&&Zu(c,n),c}var Qh=rt,ec=Xe,Zh=Hh,Fo=Tr,e_=new Qh("RequestSender"),qo={onRequestTimeout:function(){},onTransportError:function(){},onReceiveResponse:function(){},onAuthenticated:function(){}},Er=function(){function c(r,n,o){Jh(this,c),this._ua=r,this._eventHandlers=o,this._method=n.method,this._request=n,this._auth=null,this._challenged=!1,this._staled=!1;for(var a in qo)Object.prototype.hasOwnProperty.call(qo,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=qo[a]));r.status===r.C.STATUS_USER_CLOSED&&(this._method!==ec.BYE||this._method!==ec.ACK)&&this._eventHandlers.onTransportError()}return Xh(c,[{key:"send",value:function(){var n=this,o={onRequestTimeout:function(){n._eventHandlers.onRequestTimeout()},onTransportError:function(){n._eventHandlers.onTransportError()},onReceiveResponse:function(t){n._receiveResponse(t)}};switch(this._method){case"INVITE":this.clientTransaction=new Fo.InviteClientTransaction(this._ua,this._ua.transport,this._request,o);break;case"ACK":this.clientTransaction=new Fo.AckClientTransaction(this._ua,this._ua.transport,this._request,o);break;default:this.clientTransaction=new Fo.NonInviteClientTransaction(this._ua,this._ua.transport,this._request,o)}this._ua._configuration.authorization_jwt&&this._request.setHeader("Authorization",this._ua._configuration.authorization_jwt),this.clientTransaction.send()}},{key:"_receiveResponse",value:function(n){var o,a,t=n.status_code;if((t===401||t===407)&&(this._ua.configuration.password!==null||this._ua.configuration.ha1!==null)){if(n.status_code===401?(o=n.parseHeader("www-authenticate"),a="authorization"):(o=n.parseHeader("proxy-authenticate"),a="proxy-authorization"),!o){e_.debug("".concat(n.status_code," with wrong or missing challenge, cannot authenticate")),this._eventHandlers.onReceiveResponse(n);return}if(!this._challenged||!this._staled&&o.stale===!0){if(this._auth||(this._auth=new Zh({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,o)){this._eventHandlers.onReceiveResponse(n);return}this._challenged=!0,this._ua.set("realm",this._auth.get("realm")),this._ua.set("ha1",this._auth.get("ha1")),o.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(a,this._auth.toString()),this._eventHandlers.onAuthenticated(this._request),this.send()}else this._eventHandlers.onReceiveResponse(n)}else this._eventHandlers.onReceiveResponse(n)}}]),c}();function t_(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function tc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function s_(c,r,n){return r&&tc(c.prototype,r),n&&tc(c,n),c}var n_=rt,Vo=Tt(),$s=Xe,sc=ts,nc=Er,yr=new n_("Registrator"),gl=10,r_=function(){function c(r,n){t_(this,c),this._reg_id=1,this._ua=r,this._transport=n,this._registrar=r.configuration.registrar_server,this._expires=r.configuration.register_expires,this._call_id=Vo.createRandomToken(22),this._cseq=0,this._to_uri=r.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)}return s_(c,[{key:"setExtraHeaders",value:function(n){Array.isArray(n)||(n=[]),this._extraHeaders=n.slice()}},{key:"setExtraContactParams",value:function(n){n instanceof Object||(n={}),this._extraContactParams="";for(var o in n)if(Object.prototype.hasOwnProperty.call(n,o)){var a=n[o];this._extraContactParams+=";".concat(o),a&&(this._extraContactParams+="=".concat(a))}}},{key:"register",value:function(){var n=this;if(this._registering){yr.debug("Register request in progress...");return}var o=this._extraHeaders.slice();o.push("Contact: ".concat(this._contact,";expires=").concat(this._expires).concat(this._extraContactParams)),o.push("Expires: ".concat(this._expires));var a=new sc.OutgoingRequest($s.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},o),t=new nc(this._ua,a,{onRequestTimeout:function(){n._registrationFailure(null,$s.causes.REQUEST_TIMEOUT)},onTransportError:function(){n._registrationFailure(null,$s.causes.CONNECTION_ERROR)},onAuthenticated:function(){n._cseq+=1},onReceiveResponse:function(p){if(p.cseq===n._cseq)switch(n._registrationTimer!==null&&(clearTimeout(n._registrationTimer),n._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(p.status_code):break;case/^2[0-9]{2}$/.test(p.status_code):{if(n._registering=!1,!p.hasHeader("Contact")){yr.debug("no Contact header in response to REGISTER, response ignored");break}var h=p.headers.Contact.reduce(function(S,C){return S.concat(C.parsed)},[]),d=h.find(function(S){return n._sipInstance===S.getParam("+sip.instance")&&n._reg_id===parseInt(S.getParam("reg-id"))});if(d||(d=h.find(function(S){return S.uri.user===n._ua.contact.uri.user})),!d){yr.debug("no Contact header pointing to us, response ignored");break}var g=d.getParam("expires");!g&&p.hasHeader("expires")&&(g=p.getHeader("expires")),g||(g=n._expires),g=Number(g),g<gl&&(g=gl);var v=g>64?g*1e3/2+Math.floor((g/2-32)*1e3*Math.random()):g*1e3-5e3;n._registrationTimer=setTimeout(function(){n._registrationTimer=null,n._ua.listeners("registrationExpiring").length===0?n.register():n._ua.emit("registrationExpiring")},v),d.hasParam("temp-gruu")&&(n._ua.contact.temp_gruu=d.getParam("temp-gruu").replace(/"/g,"")),d.hasParam("pub-gruu")&&(n._ua.contact.pub_gruu=d.getParam("pub-gruu").replace(/"/g,"")),n._registered||(n._registered=!0,n._ua.registered({response:p}));break}case/^423$/.test(p.status_code):{p.hasHeader("min-expires")?(n._expires=Number(p.getHeader("min-expires")),n._expires<gl&&(n._expires=gl),n.register()):(yr.debug("423 response received for REGISTER without Min-Expires"),n._registrationFailure(p,$s.causes.SIP_FAILURE_CODE));break}default:{var E=Vo.sipErrorCause(p.status_code);n._registrationFailure(p,E)}}}});this._registering=!0,t.send()}},{key:"unregister",value:function(){var n=this,o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!this._registered){yr.debug("already unregistered");return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);var a=this._extraHeaders.slice();o.all?a.push("Contact: *".concat(this._extraContactParams)):a.push("Contact: ".concat(this._contact,";expires=0").concat(this._extraContactParams)),a.push("Expires: 0");var t=new sc.OutgoingRequest($s.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},a),s=new nc(this._ua,t,{onRequestTimeout:function(){n._unregistered(null,$s.causes.REQUEST_TIMEOUT)},onTransportError:function(){n._unregistered(null,$s.causes.CONNECTION_ERROR)},onAuthenticated:function(){n._cseq+=1},onReceiveResponse:function(h){switch(!0){case/^1[0-9]{2}$/.test(h.status_code):break;case/^2[0-9]{2}$/.test(h.status_code):n._unregistered(h);break;default:{var d=Vo.sipErrorCause(h.status_code);n._unregistered(h,d)}}}});s.send()}},{key:"close",value:function(){this._registered&&this.unregister()}},{key:"onTransportClosed",value:function(){this._registering=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),this._registered&&(this._registered=!1,this._ua.unregistered({}))}},{key:"_registrationFailure",value:function(n,o){this._registering=!1,this._ua.registrationFailed({response:n||null,cause:o}),this._registered&&(this._registered=!1,this._ua.unregistered({response:n||null,cause:o}))}},{key:"_unregistered",value:function(n,o){this._registering=!1,this._registered=!1,this._ua.unregistered({response:n||null,cause:o||null})}},{key:"registered",get:function(){return this._registered}}]),c}();function i_(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function rc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function l_(c,r,n){return r&&rc(c.prototype,r),n&&rc(c,n),c}var jo=Xe,vl=Tr,o_=Er,Bo={onRequestTimeout:function(){},onTransportError:function(){},onSuccessResponse:function(){},onErrorResponse:function(){},onAuthenticated:function(){},onDialogError:function(){}},a_=function(){function c(r,n,o){i_(this,c),this._dialog=r,this._ua=r._ua,this._request=n,this._eventHandlers=o,this._reattempt=!1,this._reattemptTimer=null;for(var a in Bo)Object.prototype.hasOwnProperty.call(Bo,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=Bo[a]))}return l_(c,[{key:"send",value:function(){var n=this,o=new o_(this._ua,this._request,{onRequestTimeout:function(){n._eventHandlers.onRequestTimeout()},onTransportError:function(){n._eventHandlers.onTransportError()},onAuthenticated:function(s){n._eventHandlers.onAuthenticated(s)},onReceiveResponse:function(s){n._receiveResponse(s)}});if(o.send(),(this._request.method===jo.INVITE||this._request.method===jo.UPDATE&&this._request.body)&&o.clientTransaction.state!==vl.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;var a=function t(){(o.clientTransaction.state===vl.C.STATUS_ACCEPTED||o.clientTransaction.state===vl.C.STATUS_COMPLETED||o.clientTransaction.state===vl.C.STATUS_TERMINATED)&&(o.clientTransaction.removeListener("stateChanged",t),n._dialog.uac_pending_reply=!1)};o.clientTransaction.on("stateChanged",a)}}},{key:"_receiveResponse",value:function(n){var o=this;n.status_code===408||n.status_code===481?this._eventHandlers.onDialogError(n):n.method===jo.INVITE&&n.status_code===491?this._reattempt?n.status_code>=200&&n.status_code<300?this._eventHandlers.onSuccessResponse(n):n.status_code>=300&&this._eventHandlers.onErrorResponse(n):(this._request.cseq=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout(function(){o._dialog.isTerminated()||(o._reattempt=!0,o.send())},1e3)):n.status_code>=200&&n.status_code<300?this._eventHandlers.onSuccessResponse(n):n.status_code>=300&&this._eventHandlers.onErrorResponse(n)}},{key:"request",get:function(){return this._request}}]),c}();function u_(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function ic(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function lc(c,r,n){return r&&ic(c.prototype,r),n&&ic(c,n),c}var c_=rt,oc=ts,vs=Xe,Sr=Tr,f_=a_,Go=Tt(),Ko=new c_("Dialog"),Ts={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3},h_=function(){lc(c,null,[{key:"C",get:function(){return Ts}}]);function c(r,n,o){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:Ts.STATUS_CONFIRMED;if(u_(this,c),this._owner=r,this._ua=r._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 oc.IncomingResponse&&(a=n.status_code<200?Ts.STATUS_EARLY:Ts.STATUS_CONFIRMED);var t=n.parseHeader("contact");o==="UAS"?(this._id={call_id:n.call_id,local_tag:n.to_tag,remote_tag:n.from_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._remote_seqnum=n.cseq,this._local_uri=n.parseHeader("to").uri,this._remote_uri=n.parseHeader("from").uri,this._remote_target=t.uri,this._route_set=n.getHeaders("record-route"),this._ack_seqnum=this._remote_seqnum):o==="UAC"&&(this._id={call_id:n.call_id,local_tag:n.from_tag,remote_tag:n.to_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._local_seqnum=n.cseq,this._local_uri=n.parseHeader("from").uri,this._remote_uri=n.parseHeader("to").uri,this._remote_target=t.uri,this._route_set=n.getHeaders("record-route").reverse(),this._ack_seqnum=null),this._ua.newDialog(this),Ko.debug("new ".concat(o," dialog created with status ").concat(this._state===Ts.STATUS_EARLY?"EARLY":"CONFIRMED"))}return lc(c,[{key:"isTerminated",value:function(){return this._status===Ts.STATUS_TERMINATED}},{key:"update",value:function(n,o){this._state=Ts.STATUS_CONFIRMED,Ko.debug("dialog ".concat(this._id.toString()," changed to CONFIRMED state")),o==="UAC"&&(this._route_set=n.getHeaders("record-route").reverse())}},{key:"terminate",value:function(){Ko.debug("dialog ".concat(this._id.toString()," deleted")),this._ua.destroyDialog(this),this._state=Ts.STATUS_TERMINATED}},{key:"sendRequest",value:function(n){var o=this,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=Go.cloneArray(a.extraHeaders),s=Go.cloneObject(a.eventHandlers),p=a.body||null,h=this._createRequest(n,t,p);s.onAuthenticated=function(){o._local_seqnum+=1};var d=new f_(this,h,s);return d.send(),h}},{key:"receiveRequest",value:function(n){this._checkInDialogRequest(n)&&(n.method===vs.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:n.method===vs.INVITE&&(this._ack_seqnum=n.cseq),this._owner.receiveRequest(n))}},{key:"_createRequest",value:function(n,o,a){o=Go.cloneArray(o),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));var t=n===vs.CANCEL||n===vs.ACK?this._local_seqnum:this._local_seqnum+=1,s=new oc.OutgoingRequest(n,this._remote_target,this._ua,{cseq:t,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},o,a);return s}},{key:"_checkInDialogRequest",value:function(n){var o=this;if(!this._remote_seqnum)this._remote_seqnum=n.cseq;else if(n.cseq<this._remote_seqnum)if(n.method===vs.ACK){if(this._ack_seqnum===null||n.cseq!==this._ack_seqnum)return!1}else return n.reply(500),!1;else n.cseq>this._remote_seqnum&&(this._remote_seqnum=n.cseq);if(n.method===vs.INVITE||n.method===vs.UPDATE&&n.body){if(this._uac_pending_reply===!0)n.reply(491);else if(this._uas_pending_reply===!0){var a=(Math.random()*10|0)+1;return n.reply(500,null,["Retry-After:".concat(a)]),!1}else{this._uas_pending_reply=!0;var t=function s(){(n.server_transaction.state===Sr.C.STATUS_ACCEPTED||n.server_transaction.state===Sr.C.STATUS_COMPLETED||n.server_transaction.state===Sr.C.STATUS_TERMINATED)&&(n.server_transaction.removeListener("stateChanged",s),o._uas_pending_reply=!1)};n.server_transaction.on("stateChanged",t)}n.hasHeader("contact")&&n.server_transaction.on("stateChanged",function(){n.server_transaction.state===Sr.C.STATUS_ACCEPTED&&(o._remote_target=n.parseHeader("contact").uri)})}else n.method===vs.NOTIFY&&n.hasHeader("contact")&&n.server_transaction.on("stateChanged",function(){n.server_transaction.state===Sr.C.STATUS_COMPLETED&&(o._remote_target=n.parseHeader("contact").uri)});return!0}},{key:"id",get:function(){return this._id}},{key:"local_seqnum",get:function(){return this._local_seqnum},set:function(n){this._local_seqnum=n}},{key:"owner",get:function(){return this._owner}},{key:"uac_pending_reply",get:function(){return this._uac_pending_reply},set:function(n){this._uac_pending_reply=n}},{key:"uas_pending_reply",get:function(){return this._uas_pending_reply}}]),c}(),Wo={exports:{}};function Tl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Tl=function(n){return typeof n}:Tl=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Tl(c)}function __(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function ac(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function d_(c,r,n){return r&&ac(c.prototype,r),n&&ac(c,n),c}function p_(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&Yo(c,r)}function Yo(c,r){return Yo=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Yo(c,r)}function m_(c){var r=T_();return function(){var o=El(c),a;if(r){var t=El(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return g_(this,a)}}function g_(c,r){return r&&(Tl(r)==="object"||typeof r=="function")?r:v_(c)}function v_(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function T_(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function El(c){return El=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},El(c)}var E_=ot.EventEmitter,y_=rt,S_=Xe,C_=ps,uc=Tt(),A_=new y_("RTCSession:DTMF"),cc={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};Wo.exports=function(c){p_(n,c);var r=m_(n);function n(o){var a;return __(this,n),a=r.call(this),a._session=o,a._direction=null,a._tone=null,a._duration=null,a._request=null,a}return d_(n,[{key:"send",value:function(a){var t=this,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(a===void 0)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 C_.InvalidStateError(this._session.status);var p=uc.cloneArray(s.extraHeaders);if(this.eventHandlers=uc.cloneObject(s.eventHandlers),typeof a=="string")a=a.toUpperCase();else if(typeof a=="number")a=a.toString();else throw new TypeError("Invalid tone: ".concat(a));if(a.match(/^[0-9A-DR#*]$/))this._tone=a;else throw new TypeError("Invalid tone: ".concat(a));this._duration=s.duration,p.push("Content-Type: application/dtmf-relay");var h="Signal=".concat(this._tone,`\r
|
46
|
+
`),this.transport.send(p)}}]),n}(Gu),Mh=function(c){Mo(n,c);var r=Lo(n);function n(){var o;return fr(this,n),o=r.call(this),o.headers={},o.status_code=null,o.reason_phrase=null,o}return n}(Gu),ss={OutgoingRequest:Bu,InitialOutgoingInviteRequest:Ph,IncomingRequest:kh,IncomingResponse:Mh};function xh(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Ku(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Lh(c,r,n){return r&&Ku(c.prototype,r),n&&Ku(c,n),c}var $h=rt,ns=Tt(),$t=new $h("DigestAuthentication"),Hh=function(){function c(r){xh(this,c),this._credentials=r,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}return Lh(c,[{key:"get",value:function(n){switch(n){case"realm":return this._realm;case"ha1":return this._ha1;default:$t.warn('get() | cannot get "%s" parameter',n);return}}},{key:"authenticate",value:function(n,o){var a=n.method,t=n.ruri,s=n.body,p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;if(this._algorithm=o.algorithm,this._realm=o.realm,this._nonce=o.nonce,this._opaque=o.opaque,this._stale=o.stale,this._algorithm){if(this._algorithm!=="MD5")return $t.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return $t.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return $t.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return $t.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return $t.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(o.qop)if(o.qop.indexOf("auth-int")>-1)this._qop="auth-int";else if(o.qop.indexOf("auth")>-1)this._qop="auth";else return $t.warn('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;else this._qop=null;this._method=a,this._uri=t,this._cnonce=p||ns.createRandomToken(12),this._nc+=1;var h=Number(this._nc).toString(16);this._ncHex="00000000".substr(0,8-h.length)+h,this._nc===4294967296&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=ns.calculateMD5("".concat(this._credentials.username,":").concat(this._realm,":").concat(this._credentials.password)):this._ha1=this._credentials.ha1;var d,g;return this._qop==="auth"?(d="".concat(this._method,":").concat(this._uri),g=ns.calculateMD5(d),$t.debug('authenticate() | using qop=auth [a2:"%s"]',d),this._response=ns.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(this._ncHex,":").concat(this._cnonce,":auth:").concat(g))):this._qop==="auth-int"?(d="".concat(this._method,":").concat(this._uri,":").concat(ns.calculateMD5(s||"")),g=ns.calculateMD5(d),$t.debug('authenticate() | using qop=auth-int [a2:"%s"]',d),this._response=ns.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(this._ncHex,":").concat(this._cnonce,":auth-int:").concat(g))):this._qop===null&&(d="".concat(this._method,":").concat(this._uri),g=ns.calculateMD5(d),$t.debug('authenticate() | using qop=null [a2:"%s"]',d),this._response=ns.calculateMD5("".concat(this._ha1,":").concat(this._nonce,":").concat(g))),$t.debug("authenticate() | response generated"),!0}},{key:"toString",value:function(){var n=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return n.push("algorithm=".concat(this._algorithm)),n.push('username="'.concat(this._credentials.username,'"')),n.push('realm="'.concat(this._realm,'"')),n.push('nonce="'.concat(this._nonce,'"')),n.push('uri="'.concat(this._uri,'"')),n.push('response="'.concat(this._response,'"')),this._opaque&&n.push('opaque="'.concat(this._opaque,'"')),this._qop&&(n.push("qop=".concat(this._qop)),n.push('cnonce="'.concat(this._cnonce,'"')),n.push("nc=".concat(this._ncHex))),"Digest ".concat(n.join(", "))}}]),c}(),rs=500,Fh=4e3,Wu=5e3,Yu={T1:rs,T2:Fh,T4:Wu,TIMER_B:64*rs,TIMER_D:0*rs,TIMER_F:64*rs,TIMER_H:64*rs,TIMER_I:0*rs,TIMER_J:0*rs,TIMER_K:0*Wu,TIMER_L:64*rs,TIMER_M:64*rs,PROVISIONAL_RESPONSE_INTERVAL:6e4};function _l(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?_l=function(n){return typeof n}:_l=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},_l(c)}function hr(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function zu(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function _r(c,r,n){return r&&zu(c.prototype,r),n&&zu(c,n),c}function dr(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&Ho(c,r)}function Ho(c,r){return Ho=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Ho(c,r)}function pr(c){var r=Vh();return function(){var o=dl(c),a;if(r){var t=dl(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return qh(this,a)}}function qh(c,r){return r&&(_l(r)==="object"||typeof r=="function")?r:vs(c)}function vs(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Vh(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function dl(c){return dl=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},dl(c)}var mr=ot.EventEmitter,gr=rt,vr=Xe,Ju=ss,jt=Yu,Xu=new gr("NonInviteClientTransaction"),pl=new gr("InviteClientTransaction"),jh=new gr("AckClientTransaction"),Qu=new gr("NonInviteServerTransaction"),ml=new gr("InviteServerTransaction"),le={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"},Bh=function(c){dr(n,c);var r=pr(n);function n(o,a,t,s){var p;hr(this,n),p=r.call(this),p.type=le.NON_INVITE_CLIENT,p.id="z9hG4bK".concat(Math.floor(Math.random()*1e7)),p.ua=o,p.transport=a,p.request=t,p.eventHandlers=s;var h="SIP/2.0/".concat(a.via_transport);return h+=" ".concat(o.configuration.via_host,";branch=").concat(p.id),p.request.setHeader("via",h),p.ua.newTransaction(vs(p)),p}return _r(n,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"send",value:function(){var a=this;this.stateChanged(le.STATUS_TRYING),this.F=setTimeout(function(){a.timer_F()},jt.TIMER_F),this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){Xu.debug("transport error occurred, deleting transaction ".concat(this.id)),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}},{key:"timer_F",value:function(){Xu.debug("Timer F expired for transaction ".concat(this.id)),this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}},{key:"timer_K",value:function(){this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"receiveResponse",value:function(a){var t=this,s=a.status_code;if(s<200)switch(this.state){case le.STATUS_TRYING:case le.STATUS_PROCEEDING:this.stateChanged(le.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(a);break}else switch(this.state){case le.STATUS_TRYING:case le.STATUS_PROCEEDING:this.stateChanged(le.STATUS_COMPLETED),clearTimeout(this.F),s===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(a),this.K=setTimeout(function(){t.timer_K()},jt.TIMER_K);break;case le.STATUS_COMPLETED:break}}},{key:"C",get:function(){return le}}]),n}(mr),Gh=function(c){dr(n,c);var r=pr(n);function n(o,a,t,s){var p;hr(this,n),p=r.call(this),p.type=le.INVITE_CLIENT,p.id="z9hG4bK".concat(Math.floor(Math.random()*1e7)),p.ua=o,p.transport=a,p.request=t,p.eventHandlers=s,t.transaction=vs(p);var h="SIP/2.0/".concat(a.via_transport);return h+=" ".concat(o.configuration.via_host,";branch=").concat(p.id),p.request.setHeader("via",h),p.ua.newTransaction(vs(p)),p}return _r(n,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"send",value:function(){var a=this;this.stateChanged(le.STATUS_CALLING),this.B=setTimeout(function(){a.timer_B()},jt.TIMER_B),this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==le.STATUS_ACCEPTED&&(pl.debug("transport error occurred, deleting transaction ".concat(this.id)),this.eventHandlers.onTransportError()),this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_M",value:function(){pl.debug("Timer M expired for transaction ".concat(this.id)),this.state===le.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"timer_B",value:function(){pl.debug("Timer B expired for transaction ".concat(this.id)),this.state===le.STATUS_CALLING&&(this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}},{key:"timer_D",value:function(){pl.debug("Timer D expired for transaction ".concat(this.id)),clearTimeout(this.B),this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"sendACK",value:function(a){var t=this,s=new Ju.OutgoingRequest(vr.ACK,this.request.ruri,this.ua,{route_set:this.request.getHeaders("route"),call_id:this.request.getHeader("call-id"),cseq:this.request.cseq});s.setHeader("from",this.request.getHeader("from")),s.setHeader("via",this.request.getHeader("via")),s.setHeader("to",a.getHeader("to")),this.D=setTimeout(function(){t.timer_D()},jt.TIMER_D),this.transport.send(s)}},{key:"cancel",value:function(a){if(this.state===le.STATUS_PROCEEDING){var t=new Ju.OutgoingRequest(vr.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")),a&&t.setHeader("reason",a),this.transport.send(t)}}},{key:"receiveResponse",value:function(a){var t=this,s=a.status_code;if(s>=100&&s<=199)switch(this.state){case le.STATUS_CALLING:this.stateChanged(le.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(a);break;case le.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(a);break}else if(s>=200&&s<=299)switch(this.state){case le.STATUS_CALLING:case le.STATUS_PROCEEDING:this.stateChanged(le.STATUS_ACCEPTED),this.M=setTimeout(function(){t.timer_M()},jt.TIMER_M),this.eventHandlers.onReceiveResponse(a);break;case le.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(a);break}else if(s>=300&&s<=699)switch(this.state){case le.STATUS_CALLING:case le.STATUS_PROCEEDING:this.stateChanged(le.STATUS_COMPLETED),this.sendACK(a),this.eventHandlers.onReceiveResponse(a);break;case le.STATUS_COMPLETED:this.sendACK(a);break}}},{key:"C",get:function(){return le}}]),n}(mr),Kh=function(c){dr(n,c);var r=pr(n);function n(o,a,t,s){var p;hr(this,n),p=r.call(this),p.id="z9hG4bK".concat(Math.floor(Math.random()*1e7)),p.transport=a,p.request=t,p.eventHandlers=s;var h="SIP/2.0/".concat(a.via_transport);return h+=" ".concat(o.configuration.via_host,";branch=").concat(p.id),p.request.setHeader("via",h),p}return _r(n,[{key:"send",value:function(){this.transport.send(this.request)||this.onTransportError()}},{key:"onTransportError",value:function(){jh.debug("transport error occurred for transaction ".concat(this.id)),this.eventHandlers.onTransportError()}},{key:"C",get:function(){return le}}]),n}(mr),Wh=function(c){dr(n,c);var r=pr(n);function n(o,a,t){var s;return hr(this,n),s=r.call(this),s.type=le.NON_INVITE_SERVER,s.id=t.via_branch,s.ua=o,s.transport=a,s.request=t,s.last_response="",t.server_transaction=vs(s),s.state=le.STATUS_TRYING,o.newTransaction(vs(s)),s}return _r(n,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"timer_J",value:function(){Qu.debug("Timer J expired for transaction ".concat(this.id)),this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,Qu.debug("transport error occurred, deleting transaction ".concat(this.id)),clearTimeout(this.J),this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"receiveResponse",value:function(a,t,s,p){var h=this;if(a===100)switch(this.state){case le.STATUS_TRYING:this.stateChanged(le.STATUS_PROCEEDING),this.transport.send(t)||this.onTransportError();break;case le.STATUS_PROCEEDING:this.last_response=t,this.transport.send(t)?s&&s():(this.onTransportError(),p&&p());break}else if(a>=200&&a<=699)switch(this.state){case le.STATUS_TRYING:case le.STATUS_PROCEEDING:this.stateChanged(le.STATUS_COMPLETED),this.last_response=t,this.J=setTimeout(function(){h.timer_J()},jt.TIMER_J),this.transport.send(t)?s&&s():(this.onTransportError(),p&&p());break;case le.STATUS_COMPLETED:break}}},{key:"C",get:function(){return le}}]),n}(mr),Yh=function(c){dr(n,c);var r=pr(n);function n(o,a,t){var s;return hr(this,n),s=r.call(this),s.type=le.INVITE_SERVER,s.id=t.via_branch,s.ua=o,s.transport=a,s.request=t,s.last_response="",t.server_transaction=vs(s),s.state=le.STATUS_PROCEEDING,o.newTransaction(vs(s)),s.resendProvisionalTimer=null,t.reply(100),s}return _r(n,[{key:"stateChanged",value:function(a){this.state=a,this.emit("stateChanged")}},{key:"timer_H",value:function(){ml.debug("Timer H expired for transaction ".concat(this.id)),this.state===le.STATUS_COMPLETED&&ml.debug("ACK not received, dialog will be terminated"),this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_I",value:function(){this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this)}},{key:"timer_L",value:function(){ml.debug("Timer L expired for transaction ".concat(this.id)),this.state===le.STATUS_ACCEPTED&&(this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"onTransportError",value:function(){this.transportError||(this.transportError=!0,ml.debug("transport error occurred, deleting transaction ".concat(this.id)),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),clearTimeout(this.L),clearTimeout(this.H),clearTimeout(this.I),this.stateChanged(le.STATUS_TERMINATED),this.ua.destroyTransaction(this))}},{key:"resend_provisional",value:function(){this.transport.send(this.last_response)||this.onTransportError()}},{key:"receiveResponse",value:function(a,t,s,p){var h=this;if(a>=100&&a<=199)switch(this.state){case le.STATUS_PROCEEDING:this.transport.send(t)||this.onTransportError(),this.last_response=t;break}if(a>100&&a<=199&&this.state===le.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(function(){h.resend_provisional()},jt.PROVISIONAL_RESPONSE_INTERVAL));else if(a>=200&&a<=299)switch(this.state){case le.STATUS_PROCEEDING:this.stateChanged(le.STATUS_ACCEPTED),this.last_response=t,this.L=setTimeout(function(){h.timer_L()},jt.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case le.STATUS_ACCEPTED:this.transport.send(t)?s&&s():(this.onTransportError(),p&&p());break}else if(a>=300&&a<=699)switch(this.state){case le.STATUS_PROCEEDING:this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(t)?(this.stateChanged(le.STATUS_COMPLETED),this.H=setTimeout(function(){h.timer_H()},jt.TIMER_H),s&&s()):(this.onTransportError(),p&&p());break}}},{key:"C",get:function(){return le}}]),n}(mr);function zh(c,r){var n=c._transactions,o;switch(r.method){case vr.INVITE:if(o=n.ist[r.via_branch],o){switch(o.state){case le.STATUS_PROCEEDING:o.transport.send(o.last_response);break;case le.STATUS_ACCEPTED:break}return!0}break;case vr.ACK:if(o=n.ist[r.via_branch],o){if(o.state===le.STATUS_ACCEPTED)return!1;if(o.state===le.STATUS_COMPLETED)return o.state=le.STATUS_CONFIRMED,o.I=setTimeout(function(){o.timer_I()},jt.TIMER_I),!0}else return!1;break;case vr.CANCEL:return o=n.ist[r.via_branch],o?(r.reply_sl(200),o.state!==le.STATUS_PROCEEDING):(r.reply_sl(481),!0);default:if(o=n.nist[r.via_branch],o){switch(o.state){case le.STATUS_TRYING:break;case le.STATUS_PROCEEDING:case le.STATUS_COMPLETED:o.transport.send(o.last_response);break}return!0}break}}var Tr={C:le,NonInviteClientTransaction:Bh,InviteClientTransaction:Gh,AckClientTransaction:Kh,NonInviteServerTransaction:Wh,InviteServerTransaction:Yh,checkTransaction:zh};function Jh(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Zu(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Xh(c,r,n){return r&&Zu(c.prototype,r),n&&Zu(c,n),c}var Qh=rt,ec=Xe,Zh=Hh,Fo=Tr,e_=new Qh("RequestSender"),qo={onRequestTimeout:function(){},onTransportError:function(){},onReceiveResponse:function(){},onAuthenticated:function(){}},Er=function(){function c(r,n,o){Jh(this,c),this._ua=r,this._eventHandlers=o,this._method=n.method,this._request=n,this._auth=null,this._challenged=!1,this._staled=!1;for(var a in qo)Object.prototype.hasOwnProperty.call(qo,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=qo[a]));r.status===r.C.STATUS_USER_CLOSED&&(this._method!==ec.BYE||this._method!==ec.ACK)&&this._eventHandlers.onTransportError()}return Xh(c,[{key:"send",value:function(){var n=this,o={onRequestTimeout:function(){n._eventHandlers.onRequestTimeout()},onTransportError:function(){n._eventHandlers.onTransportError()},onReceiveResponse:function(t){n._receiveResponse(t)}};switch(this._method){case"INVITE":this.clientTransaction=new Fo.InviteClientTransaction(this._ua,this._ua.transport,this._request,o);break;case"ACK":this.clientTransaction=new Fo.AckClientTransaction(this._ua,this._ua.transport,this._request,o);break;default:this.clientTransaction=new Fo.NonInviteClientTransaction(this._ua,this._ua.transport,this._request,o)}this._ua._configuration.authorization_jwt&&this._request.setHeader("Authorization",this._ua._configuration.authorization_jwt),this.clientTransaction.send()}},{key:"_receiveResponse",value:function(n){var o,a,t=n.status_code;if((t===401||t===407)&&(this._ua.configuration.password!==null||this._ua.configuration.ha1!==null)){if(n.status_code===401?(o=n.parseHeader("www-authenticate"),a="authorization"):(o=n.parseHeader("proxy-authenticate"),a="proxy-authorization"),!o){e_.debug("".concat(n.status_code," with wrong or missing challenge, cannot authenticate")),this._eventHandlers.onReceiveResponse(n);return}if(!this._challenged||!this._staled&&o.stale===!0){if(this._auth||(this._auth=new Zh({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,o)){this._eventHandlers.onReceiveResponse(n);return}this._challenged=!0,this._ua.set("realm",this._auth.get("realm")),this._ua.set("ha1",this._auth.get("ha1")),o.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(a,this._auth.toString()),this._eventHandlers.onAuthenticated(this._request),this.send()}else this._eventHandlers.onReceiveResponse(n)}else this._eventHandlers.onReceiveResponse(n)}}]),c}();function t_(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function tc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function s_(c,r,n){return r&&tc(c.prototype,r),n&&tc(c,n),c}var n_=rt,Vo=Tt(),Hs=Xe,sc=ss,nc=Er,yr=new n_("Registrator"),gl=10,r_=function(){function c(r,n){t_(this,c),this._reg_id=1,this._ua=r,this._transport=n,this._registrar=r.configuration.registrar_server,this._expires=r.configuration.register_expires,this._call_id=Vo.createRandomToken(22),this._cseq=0,this._to_uri=r.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)}return s_(c,[{key:"setExtraHeaders",value:function(n){Array.isArray(n)||(n=[]),this._extraHeaders=n.slice()}},{key:"setExtraContactParams",value:function(n){n instanceof Object||(n={}),this._extraContactParams="";for(var o in n)if(Object.prototype.hasOwnProperty.call(n,o)){var a=n[o];this._extraContactParams+=";".concat(o),a&&(this._extraContactParams+="=".concat(a))}}},{key:"register",value:function(){var n=this;if(this._registering){yr.debug("Register request in progress...");return}var o=this._extraHeaders.slice();o.push("Contact: ".concat(this._contact,";expires=").concat(this._expires).concat(this._extraContactParams)),o.push("Expires: ".concat(this._expires));var a=new sc.OutgoingRequest(Hs.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},o),t=new nc(this._ua,a,{onRequestTimeout:function(){n._registrationFailure(null,Hs.causes.REQUEST_TIMEOUT)},onTransportError:function(){n._registrationFailure(null,Hs.causes.CONNECTION_ERROR)},onAuthenticated:function(){n._cseq+=1},onReceiveResponse:function(p){if(p.cseq===n._cseq)switch(n._registrationTimer!==null&&(clearTimeout(n._registrationTimer),n._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(p.status_code):break;case/^2[0-9]{2}$/.test(p.status_code):{if(n._registering=!1,!p.hasHeader("Contact")){yr.debug("no Contact header in response to REGISTER, response ignored");break}var h=p.headers.Contact.reduce(function(S,C){return S.concat(C.parsed)},[]),d=h.find(function(S){return n._sipInstance===S.getParam("+sip.instance")&&n._reg_id===parseInt(S.getParam("reg-id"))});if(d||(d=h.find(function(S){return S.uri.user===n._ua.contact.uri.user})),!d){yr.debug("no Contact header pointing to us, response ignored");break}var g=d.getParam("expires");!g&&p.hasHeader("expires")&&(g=p.getHeader("expires")),g||(g=n._expires),g=Number(g),g<gl&&(g=gl);var v=g>64?g*1e3/2+Math.floor((g/2-32)*1e3*Math.random()):g*1e3-5e3;n._registrationTimer=setTimeout(function(){n._registrationTimer=null,n._ua.listeners("registrationExpiring").length===0?n.register():n._ua.emit("registrationExpiring")},v),d.hasParam("temp-gruu")&&(n._ua.contact.temp_gruu=d.getParam("temp-gruu").replace(/"/g,"")),d.hasParam("pub-gruu")&&(n._ua.contact.pub_gruu=d.getParam("pub-gruu").replace(/"/g,"")),n._registered||(n._registered=!0,n._ua.registered({response:p}));break}case/^423$/.test(p.status_code):{p.hasHeader("min-expires")?(n._expires=Number(p.getHeader("min-expires")),n._expires<gl&&(n._expires=gl),n.register()):(yr.debug("423 response received for REGISTER without Min-Expires"),n._registrationFailure(p,Hs.causes.SIP_FAILURE_CODE));break}default:{var E=Vo.sipErrorCause(p.status_code);n._registrationFailure(p,E)}}}});this._registering=!0,t.send()}},{key:"unregister",value:function(){var n=this,o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!this._registered){yr.debug("already unregistered");return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);var a=this._extraHeaders.slice();o.all?a.push("Contact: *".concat(this._extraContactParams)):a.push("Contact: ".concat(this._contact,";expires=0").concat(this._extraContactParams)),a.push("Expires: 0");var t=new sc.OutgoingRequest(Hs.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},a),s=new nc(this._ua,t,{onRequestTimeout:function(){n._unregistered(null,Hs.causes.REQUEST_TIMEOUT)},onTransportError:function(){n._unregistered(null,Hs.causes.CONNECTION_ERROR)},onAuthenticated:function(){n._cseq+=1},onReceiveResponse:function(h){switch(!0){case/^1[0-9]{2}$/.test(h.status_code):break;case/^2[0-9]{2}$/.test(h.status_code):n._unregistered(h);break;default:{var d=Vo.sipErrorCause(h.status_code);n._unregistered(h,d)}}}});s.send()}},{key:"close",value:function(){this._registered&&this.unregister()}},{key:"onTransportClosed",value:function(){this._registering=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),this._registered&&(this._registered=!1,this._ua.unregistered({}))}},{key:"_registrationFailure",value:function(n,o){this._registering=!1,this._ua.registrationFailed({response:n||null,cause:o}),this._registered&&(this._registered=!1,this._ua.unregistered({response:n||null,cause:o}))}},{key:"_unregistered",value:function(n,o){this._registering=!1,this._registered=!1,this._ua.unregistered({response:n||null,cause:o||null})}},{key:"registered",get:function(){return this._registered}}]),c}();function i_(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function rc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function l_(c,r,n){return r&&rc(c.prototype,r),n&&rc(c,n),c}var jo=Xe,vl=Tr,o_=Er,Bo={onRequestTimeout:function(){},onTransportError:function(){},onSuccessResponse:function(){},onErrorResponse:function(){},onAuthenticated:function(){},onDialogError:function(){}},a_=function(){function c(r,n,o){i_(this,c),this._dialog=r,this._ua=r._ua,this._request=n,this._eventHandlers=o,this._reattempt=!1,this._reattemptTimer=null;for(var a in Bo)Object.prototype.hasOwnProperty.call(Bo,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=Bo[a]))}return l_(c,[{key:"send",value:function(){var n=this,o=new o_(this._ua,this._request,{onRequestTimeout:function(){n._eventHandlers.onRequestTimeout()},onTransportError:function(){n._eventHandlers.onTransportError()},onAuthenticated:function(s){n._eventHandlers.onAuthenticated(s)},onReceiveResponse:function(s){n._receiveResponse(s)}});if(o.send(),(this._request.method===jo.INVITE||this._request.method===jo.UPDATE&&this._request.body)&&o.clientTransaction.state!==vl.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;var a=function t(){(o.clientTransaction.state===vl.C.STATUS_ACCEPTED||o.clientTransaction.state===vl.C.STATUS_COMPLETED||o.clientTransaction.state===vl.C.STATUS_TERMINATED)&&(o.clientTransaction.removeListener("stateChanged",t),n._dialog.uac_pending_reply=!1)};o.clientTransaction.on("stateChanged",a)}}},{key:"_receiveResponse",value:function(n){var o=this;n.status_code===408||n.status_code===481?this._eventHandlers.onDialogError(n):n.method===jo.INVITE&&n.status_code===491?this._reattempt?n.status_code>=200&&n.status_code<300?this._eventHandlers.onSuccessResponse(n):n.status_code>=300&&this._eventHandlers.onErrorResponse(n):(this._request.cseq=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout(function(){o._dialog.isTerminated()||(o._reattempt=!0,o.send())},1e3)):n.status_code>=200&&n.status_code<300?this._eventHandlers.onSuccessResponse(n):n.status_code>=300&&this._eventHandlers.onErrorResponse(n)}},{key:"request",get:function(){return this._request}}]),c}();function u_(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function ic(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function lc(c,r,n){return r&&ic(c.prototype,r),n&&ic(c,n),c}var c_=rt,oc=ss,Ts=Xe,Sr=Tr,f_=a_,Go=Tt(),Ko=new c_("Dialog"),Es={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3},h_=function(){lc(c,null,[{key:"C",get:function(){return Es}}]);function c(r,n,o){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:Es.STATUS_CONFIRMED;if(u_(this,c),this._owner=r,this._ua=r._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 oc.IncomingResponse&&(a=n.status_code<200?Es.STATUS_EARLY:Es.STATUS_CONFIRMED);var t=n.parseHeader("contact");o==="UAS"?(this._id={call_id:n.call_id,local_tag:n.to_tag,remote_tag:n.from_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._remote_seqnum=n.cseq,this._local_uri=n.parseHeader("to").uri,this._remote_uri=n.parseHeader("from").uri,this._remote_target=t.uri,this._route_set=n.getHeaders("record-route"),this._ack_seqnum=this._remote_seqnum):o==="UAC"&&(this._id={call_id:n.call_id,local_tag:n.from_tag,remote_tag:n.to_tag,toString:function(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._local_seqnum=n.cseq,this._local_uri=n.parseHeader("from").uri,this._remote_uri=n.parseHeader("to").uri,this._remote_target=t.uri,this._route_set=n.getHeaders("record-route").reverse(),this._ack_seqnum=null),this._ua.newDialog(this),Ko.debug("new ".concat(o," dialog created with status ").concat(this._state===Es.STATUS_EARLY?"EARLY":"CONFIRMED"))}return lc(c,[{key:"isTerminated",value:function(){return this._status===Es.STATUS_TERMINATED}},{key:"update",value:function(n,o){this._state=Es.STATUS_CONFIRMED,Ko.debug("dialog ".concat(this._id.toString()," changed to CONFIRMED state")),o==="UAC"&&(this._route_set=n.getHeaders("record-route").reverse())}},{key:"terminate",value:function(){Ko.debug("dialog ".concat(this._id.toString()," deleted")),this._ua.destroyDialog(this),this._state=Es.STATUS_TERMINATED}},{key:"sendRequest",value:function(n){var o=this,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=Go.cloneArray(a.extraHeaders),s=Go.cloneObject(a.eventHandlers),p=a.body||null,h=this._createRequest(n,t,p);s.onAuthenticated=function(){o._local_seqnum+=1};var d=new f_(this,h,s);return d.send(),h}},{key:"receiveRequest",value:function(n){this._checkInDialogRequest(n)&&(n.method===Ts.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:n.method===Ts.INVITE&&(this._ack_seqnum=n.cseq),this._owner.receiveRequest(n))}},{key:"_createRequest",value:function(n,o,a){o=Go.cloneArray(o),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));var t=n===Ts.CANCEL||n===Ts.ACK?this._local_seqnum:this._local_seqnum+=1,s=new oc.OutgoingRequest(n,this._remote_target,this._ua,{cseq:t,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},o,a);return s}},{key:"_checkInDialogRequest",value:function(n){var o=this;if(!this._remote_seqnum)this._remote_seqnum=n.cseq;else if(n.cseq<this._remote_seqnum)if(n.method===Ts.ACK){if(this._ack_seqnum===null||n.cseq!==this._ack_seqnum)return!1}else return n.reply(500),!1;else n.cseq>this._remote_seqnum&&(this._remote_seqnum=n.cseq);if(n.method===Ts.INVITE||n.method===Ts.UPDATE&&n.body){if(this._uac_pending_reply===!0)n.reply(491);else if(this._uas_pending_reply===!0){var a=(Math.random()*10|0)+1;return n.reply(500,null,["Retry-After:".concat(a)]),!1}else{this._uas_pending_reply=!0;var t=function s(){(n.server_transaction.state===Sr.C.STATUS_ACCEPTED||n.server_transaction.state===Sr.C.STATUS_COMPLETED||n.server_transaction.state===Sr.C.STATUS_TERMINATED)&&(n.server_transaction.removeListener("stateChanged",s),o._uas_pending_reply=!1)};n.server_transaction.on("stateChanged",t)}n.hasHeader("contact")&&n.server_transaction.on("stateChanged",function(){n.server_transaction.state===Sr.C.STATUS_ACCEPTED&&(o._remote_target=n.parseHeader("contact").uri)})}else n.method===Ts.NOTIFY&&n.hasHeader("contact")&&n.server_transaction.on("stateChanged",function(){n.server_transaction.state===Sr.C.STATUS_COMPLETED&&(o._remote_target=n.parseHeader("contact").uri)});return!0}},{key:"id",get:function(){return this._id}},{key:"local_seqnum",get:function(){return this._local_seqnum},set:function(n){this._local_seqnum=n}},{key:"owner",get:function(){return this._owner}},{key:"uac_pending_reply",get:function(){return this._uac_pending_reply},set:function(n){this._uac_pending_reply=n}},{key:"uas_pending_reply",get:function(){return this._uas_pending_reply}}]),c}(),Wo={exports:{}};function Tl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Tl=function(n){return typeof n}:Tl=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Tl(c)}function __(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function ac(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function d_(c,r,n){return r&&ac(c.prototype,r),n&&ac(c,n),c}function p_(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&Yo(c,r)}function Yo(c,r){return Yo=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Yo(c,r)}function m_(c){var r=T_();return function(){var o=El(c),a;if(r){var t=El(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return g_(this,a)}}function g_(c,r){return r&&(Tl(r)==="object"||typeof r=="function")?r:v_(c)}function v_(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function T_(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function El(c){return El=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},El(c)}var E_=ot.EventEmitter,y_=rt,S_=Xe,C_=ms,uc=Tt(),A_=new y_("RTCSession:DTMF"),cc={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};Wo.exports=function(c){p_(n,c);var r=m_(n);function n(o){var a;return __(this,n),a=r.call(this),a._session=o,a._direction=null,a._tone=null,a._duration=null,a._request=null,a}return d_(n,[{key:"send",value:function(a){var t=this,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(a===void 0)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 C_.InvalidStateError(this._session.status);var p=uc.cloneArray(s.extraHeaders);if(this.eventHandlers=uc.cloneObject(s.eventHandlers),typeof a=="string")a=a.toUpperCase();else if(typeof a=="number")a=a.toString();else throw new TypeError("Invalid tone: ".concat(a));if(a.match(/^[0-9A-DR#*]$/))this._tone=a;else throw new TypeError("Invalid tone: ".concat(a));this._duration=s.duration,p.push("Content-Type: application/dtmf-relay");var h="Signal=".concat(this._tone,`\r
|
47
47
|
`);h+="Duration=".concat(this._duration),this._session.newDTMF({originator:"local",dtmf:this,request:this._request}),this._session.sendRequest(S_.INFO,{extraHeaders:p,eventHandlers:{onSuccessResponse:function(g){t.emit("succeeded",{originator:"remote",response:g})},onErrorResponse:function(g){t.eventHandlers.onFailed&&t.eventHandlers.onFailed(),t.emit("failed",{originator:"remote",response:g})},onRequestTimeout:function(){t._session.onRequestTimeout()},onTransportError:function(){t._session.onTransportError()},onDialogError:function(){t._session.onDialogError()}},body:h})}},{key:"init_incoming",value:function(a){var t=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,s=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;if(this._direction="incoming",this._request=a,a.reply(200),a.body){var p=a.body.split(`
|
48
|
-
`);p.length>=1&&t.test(p[0])&&(this._tone=p[0].replace(t,"$2")),p.length>=2&&s.test(p[1])&&(this._duration=parseInt(p[1].replace(s,"$2"),10))}this._duration||(this._duration=cc.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:a}):A_.debug("invalid INFO DTMF received, discarded")}},{key:"tone",get:function(){return this._tone}},{key:"duration",get:function(){return this._duration}}]),n}(E_),Wo.exports.C=cc;var R_=Wo.exports;function yl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?yl=function(n){return typeof n}:yl=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},yl(c)}function I_(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function fc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function b_(c,r,n){return r&&fc(c.prototype,r),n&&fc(c,n),c}function w_(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&zo(c,r)}function zo(c,r){return zo=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},zo(c,r)}function O_(c){var r=U_();return function(){var o=Sl(c),a;if(r){var t=Sl(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return D_(this,a)}}function D_(c,r){return r&&(yl(r)==="object"||typeof r=="function")?r:N_(c)}function N_(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function U_(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Sl(c){return Sl=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},Sl(c)}var P_=ot.EventEmitter,k_=Xe,M_=
|
49
|
-
`,1)[0],"Status_Line");if(t===-1){
|
50
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var t=!0,s=!1,p;return{s:function(){n=c[Symbol.iterator]()},n:function(){var d=n.next();return t=d.done,d},e:function(d){s=!0,p=d},f:function(){try{!t&&n.return!=null&&n.return()}finally{if(s)throw p}}}}function ed(c,r){if(c){if(typeof c=="string")return mc(c,r);var n=Object.prototype.toString.call(c).slice(8,-1);if(n==="Object"&&c.constructor&&(n=c.constructor.name),n==="Map"||n==="Set")return Array.from(c);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return mc(c,r)}}function mc(c,r){(r==null||r>c.length)&&(r=c.length);for(var n=0,o=new Array(r);n<r;n++)o[n]=c[n];return o}function td(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function gc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function vc(c,r,n){return r&&gc(c.prototype,r),n&&gc(c,n),c}function sd(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&Qo(c,r)}function Qo(c,r){return Qo=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Qo(c,r)}function nd(c){var r=ld();return function(){var o=Il(c),a;if(r){var t=Il(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return rd(this,a)}}function rd(c,r){return r&&(Rl(r)==="object"||typeof r=="function")?r:id(c)}function id(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function ld(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Il(c){return Il=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},Il(c)}var od=ot.EventEmitter,Tc=Ot,ad=rt,oe=Xe,Fs=ps,Ec=Tr,Fe=Tt(),Ar=Yu,ud=ts,bl=h_,cd=Er,bt=R_,yc=L_,fd=V_,hd=Z_,Sc=ms(),G=new ad("RTCSession"),z={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},wl=["audio","video"],_d=function(c){sd(n,c);var r=nd(n);vc(n,null,[{key:"C",get:function(){return z}}]);function n(o){var a;return td(this,n),G.debug("new"),a=r.call(this),a._id=null,a._ua=o,a._status=z.STATUS_NULL,a._dialog=null,a._earlyDialogs={},a._contact=null,a._from_tag=null,a._to_tag=null,a._connection=null,a._connectionPromiseQueue=Promise.resolve(),a._request=null,a._is_canceled=!1,a._cancel_reason="",a._is_confirmed=!1,a._late_sdp=!1,a._rtcOfferConstraints=null,a._rtcAnswerConstraints=null,a._localMediaStream=null,a._localMediaStreamLocallyGenerated=!1,a._rtcReady=!0,a._iceReady=!1,a._timers={ackTimer:null,expiresTimer:null,invite2xxTimer:null,userNoAnswerTimer:null},a._direction=null,a._local_identity=null,a._remote_identity=null,a._start_time=null,a._end_time=null,a._tones=null,a._audioMuted=!1,a._videoMuted=!1,a._localHold=!1,a._remoteHold=!1,a._sessionTimers={enabled:a._ua.configuration.session_timers,refreshMethod:a._ua.configuration.session_timers_refresh_method,defaultExpires:oe.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},a._referSubscribers={},a._data={},a}return vc(n,[{key:"isInProgress",value:function(){switch(this._status){case z.STATUS_NULL:case z.STATUS_INVITE_SENT:case z.STATUS_1XX_RECEIVED:case z.STATUS_INVITE_RECEIVED:case z.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}},{key:"isEstablished",value:function(){switch(this._status){case z.STATUS_ANSWERED:case z.STATUS_WAITING_FOR_ACK:case z.STATUS_CONFIRMED:return!0;default:return!1}}},{key:"isEnded",value:function(){switch(this._status){case z.STATUS_CANCELED:case z.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(a){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;G.debug("connect()");var p=a,h=Fe.cloneObject(t.eventHandlers),d=Fe.cloneArray(t.extraHeaders),g=Fe.cloneObject(t.mediaConstraints,{audio:!0,video:!0}),v=t.mediaStream||null,E=Fe.cloneObject(t.pcConfig,{iceServers:[]}),S=t.rtcConstraints||null,C=t.rtcOfferConstraints||null;if(this._rtcOfferConstraints=C,this._rtcAnswerConstraints=t.rtcAnswerConstraints||null,this._data=t.data||this._data,a===void 0)throw new TypeError("Not enough arguments");if(this._status!==z.STATUS_NULL)throw new Fs.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new Fs.NotSupportedError("WebRTC not supported");if(a=this._ua.normalizeTarget(a),!a)throw new TypeError("Invalid target: ".concat(p));this._sessionTimers.enabled&&Fe.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=oe.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=oe.SESSION_EXPIRES);for(var I in h)Object.prototype.hasOwnProperty.call(h,I)&&this.on(I,h[I]);this._from_tag=Fe.newTag();var w=t.anonymous||!1,F={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:w,outbound:!0}),w?(F.from_display_name="Anonymous",F.from_uri=new Sc("sip","anonymous","anonymous.invalid"),d.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString())),d.push("Privacy: id")):t.fromUserName&&(F.from_uri=new Sc("sip",t.fromUserName,this._ua.configuration.uri.host),d.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString()))),t.fromDisplayName&&(F.from_display_name=t.fromDisplayName),d.push("Contact: ".concat(this._contact)),d.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&d.push("Session-Expires: ".concat(this._sessionTimers.defaultExpires).concat(this._ua.configuration.session_timers_force_refresher?";refresher=uac":"")),this._request=new ud.InitialOutgoingInviteRequest(a,this._ua,F,d),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(E,S),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,s&&s(this),this._newRTCSession("local",this._request),this._sendInitialRequest(g,C,v)}},{key:"init_incoming",value:function(a,t){var s=this;G.debug("init_incoming()");var p,h=a.hasHeader("Content-Type")?a.getHeader("Content-Type").toLowerCase():void 0;if(a.body&&h!=="application/sdp"){a.reply(415);return}if(this._status=z.STATUS_INVITE_RECEIVED,this._from_tag=a.from_tag,this._id=a.call_id+this._from_tag,this._request=a,this._contact=this._ua.contact.toString(),a.hasHeader("expires")&&(p=a.getHeader("expires")*1e3),a.to_tag=Fe.newTag(),!this._createDialog(a,"UAS",!0)){a.reply(500,"Missing Contact header field");return}a.body?this._late_sdp=!1:this._late_sdp=!0,this._status=z.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(function(){a.reply(408),s._failed("local",null,oe.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),p&&(this._timers.expiresTimer=setTimeout(function(){s._status===z.STATUS_WAITING_FOR_ANSWER&&(a.reply(487),s._failed("system",null,oe.causes.EXPIRES))},p)),this._direction="incoming",this._local_identity=a.to,this._remote_identity=a.from,t&&t(this),this._newRTCSession("remote",a),this._status!==z.STATUS_TERMINATED&&(a.reply(180,null,["Contact: ".concat(this._contact)]),this._progress("local",null))}},{key:"answer",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};G.debug("answer()");var s=this._request,p=Fe.cloneArray(t.extraHeaders),h=Fe.cloneObject(t.mediaConstraints),d=t.mediaStream||null,g=Fe.cloneObject(t.pcConfig,{iceServers:[]}),v=t.rtcConstraints||null,E=t.rtcAnswerConstraints||null,S=Fe.cloneObject(t.rtcOfferConstraints),C,I=!1,w=!1,F=!1,L=!1;if(this._rtcAnswerConstraints=E,this._rtcOfferConstraints=t.rtcOfferConstraints||null,this._data=t.data||this._data,this._direction!=="incoming")throw new Fs.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==z.STATUS_WAITING_FOR_ANSWER)throw new Fs.InvalidStateError(this._status);if(this._sessionTimers.enabled&&Fe.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=oe.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=oe.SESSION_EXPIRES),this._status=z.STATUS_ANSWERED,!this._createDialog(s,"UAS")){s.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),p.unshift("Contact: ".concat(this._contact));var ie=s.parseSDP();Array.isArray(ie.media)||(ie.media=[ie.media]);var N=rs(ie.media),H;try{for(N.s();!(H=N.n()).done;){var ve=H.value;ve.type==="audio"&&(I=!0,(!ve.direction||ve.direction==="sendrecv")&&(F=!0)),ve.type==="video"&&(w=!0,(!ve.direction||ve.direction==="sendrecv")&&(L=!0))}}catch($){N.e($)}finally{N.f()}if(d&&h.audio===!1){C=d.getAudioTracks();var me=rs(C),M;try{for(me.s();!(M=me.n()).done;){var D=M.value;d.removeTrack(D)}}catch($){me.e($)}finally{me.f()}}if(d&&h.video===!1){C=d.getVideoTracks();var j=rs(C),V;try{for(j.s();!(V=j.n()).done;){var Y=V.value;d.removeTrack(Y)}}catch($){j.e($)}finally{j.f()}}!d&&h.audio===void 0&&(h.audio=F),!d&&h.video===void 0&&(h.video=L),!d&&!I&&!S.offerToReceiveAudio&&(h.audio=!1),!d&&!w&&!S.offerToReceiveVideo&&(h.video=!1),this._createRTCConnection(g,v),Promise.resolve().then(function(){if(d)return d;if(h.audio||h.video)return a._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(h).catch(function($){throw a._status===z.STATUS_TERMINATED?new Error("terminated"):(s.reply(480),a._failed("local",null,oe.causes.USER_DENIED_MEDIA_ACCESS),G.warn('emit "getusermediafailed" [error:%o]',$),a.emit("getusermediafailed",$),new Error("getUserMedia() failed"))})}).then(function($){if(a._status===z.STATUS_TERMINATED)throw new Error("terminated");a._localMediaStream=$,$&&$.getTracks().forEach(function(X){a._connection.addTrack(X,$)})}).then(function(){if(!a._late_sdp){var $={originator:"remote",type:"offer",sdp:s.body};G.debug('emit "sdp"'),a.emit("sdp",$);var X=new RTCSessionDescription({type:"offer",sdp:$.sdp});return a._connectionPromiseQueue=a._connectionPromiseQueue.then(function(){return a._connection.setRemoteDescription(X)}).catch(function(U){throw s.reply(488),a._failed("system",null,oe.causes.WEBRTC_ERROR),G.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',U),a.emit("peerconnection:setremotedescriptionfailed",U),new Error("peerconnection.setRemoteDescription() failed")}),a._connectionPromiseQueue}}).then(function(){if(a._status===z.STATUS_TERMINATED)throw new Error("terminated");return a._connecting(s),a._late_sdp?a._createLocalDescription("offer",a._rtcOfferConstraints).catch(function(){throw s.reply(500),new Error("_createLocalDescription() failed")}):a._createLocalDescription("answer",E).catch(function(){throw s.reply(500),new Error("_createLocalDescription() failed")})}).then(function($){if(a._status===z.STATUS_TERMINATED)throw new Error("terminated");a._handleSessionTimersInIncomingRequest(s,p),s.reply(200,null,p,$,function(){a._status=z.STATUS_WAITING_FOR_ACK,a._setInvite2xxTimer(s,$),a._setACKTimer(),a._accepted("local")},function(){a._failed("system",null,oe.causes.CONNECTION_ERROR)})}).catch(function($){a._status!==z.STATUS_TERMINATED&&G.warn($)})}},{key:"terminate",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};G.debug("terminate()");var s=t.cause||oe.causes.BYE,p=Fe.cloneArray(t.extraHeaders),h=t.body,d,g=t.status_code,v=t.reason_phrase;if(this._status===z.STATUS_TERMINATED)throw new Fs.InvalidStateError(this._status);switch(this._status){case z.STATUS_NULL:case z.STATUS_INVITE_SENT:case z.STATUS_1XX_RECEIVED:if(G.debug("canceling session"),g&&(g<200||g>=700))throw new TypeError("Invalid status_code: ".concat(g));g&&(v=v||oe.REASON_PHRASE[g]||"",d="SIP ;cause=".concat(g,' ;text="').concat(v,'"')),this._status===z.STATUS_NULL||this._status===z.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=d):this._status===z.STATUS_1XX_RECEIVED&&this._request.cancel(d),this._status=z.STATUS_CANCELED,this._failed("local",null,oe.causes.CANCELED);break;case z.STATUS_WAITING_FOR_ANSWER:case z.STATUS_ANSWERED:if(G.debug("rejecting session"),g=g||480,g<300||g>=700)throw new TypeError("Invalid status_code: ".concat(g));this._request.reply(g,v,p,h),this._failed("local",null,oe.causes.REJECTED);break;case z.STATUS_WAITING_FOR_ACK:case z.STATUS_CONFIRMED:if(G.debug("terminating session"),v=t.reason_phrase||oe.REASON_PHRASE[g]||"",g&&(g<200||g>=700))throw new TypeError("Invalid status_code: ".concat(g));if(g&&p.push("Reason: SIP ;cause=".concat(g,'; text="').concat(v,'"')),this._status===z.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==Ec.C.STATUS_TERMINATED){var E=this._dialog;this.receiveRequest=function(S){var C=S.method;C===oe.ACK&&(a.sendRequest(oe.BYE,{extraHeaders:p,body:h}),E.terminate())},this._request.server_transaction.on("stateChanged",function(){a._request.server_transaction.state===Ec.C.STATUS_TERMINATED&&(a.sendRequest(oe.BYE,{extraHeaders:p,body:h}),E.terminate())}),this._ended("local",null,s),this._dialog=E,this._ua.newDialog(E)}else this.sendRequest(oe.BYE,{extraHeaders:p,body:h}),this._ended("local",null,s)}}},{key:"sendDTMF",value:function(a){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};G.debug("sendDTMF() | tones: %s",a);var s=0,p=t.duration||null,h=t.interToneGap||null,d=t.transportType||oe.DTMF_TRANSPORT.INFO;if(a===void 0)throw new TypeError("Not enough arguments");if(this._status!==z.STATUS_CONFIRMED&&this._status!==z.STATUS_WAITING_FOR_ACK&&this._status!==z.STATUS_1XX_RECEIVED)throw new Fs.InvalidStateError(this._status);if(d!==oe.DTMF_TRANSPORT.INFO&&d!==oe.DTMF_TRANSPORT.RFC2833)throw new TypeError("invalid transportType: ".concat(d));if(typeof a=="number"&&(a=a.toString()),!a||typeof a!="string"||!a.match(/^[0-9A-DR#*,]+$/i))throw new TypeError("Invalid tones: ".concat(a));if(p&&!Fe.isDecimal(p))throw new TypeError("Invalid tone duration: ".concat(p));if(p?p<bt.C.MIN_DURATION?(G.debug('"duration" value is lower than the minimum allowed, setting it to '.concat(bt.C.MIN_DURATION," milliseconds")),p=bt.C.MIN_DURATION):p>bt.C.MAX_DURATION?(G.debug('"duration" value is greater than the maximum allowed, setting it to '.concat(bt.C.MAX_DURATION," milliseconds")),p=bt.C.MAX_DURATION):p=Math.abs(p):p=bt.C.DEFAULT_DURATION,t.duration=p,h&&!Fe.isDecimal(h))throw new TypeError("Invalid interToneGap: ".concat(h));if(h?h<bt.C.MIN_INTER_TONE_GAP?(G.debug('"interToneGap" value is lower than the minimum allowed, setting it to '.concat(bt.C.MIN_INTER_TONE_GAP," milliseconds")),h=bt.C.MIN_INTER_TONE_GAP):h=Math.abs(h):h=bt.C.DEFAULT_INTER_TONE_GAP,d===oe.DTMF_TRANSPORT.RFC2833){var g=this._getDTMFRTPSender();g&&(a=g.toneBuffer+a,g.insertDTMF(a,p,h));return}if(this._tones){this._tones+=a;return}this._tones=a,v.call(this);function v(){var E=this,S;if(this._status===z.STATUS_TERMINATED||!this._tones||s>=this._tones.length){this._tones=null;return}var C=this._tones[s];if(s+=1,C===",")S=2e3;else{var I=new bt(this);t.eventHandlers={onFailed:function(){E._tones=null}},I.send(C,t),S=p+h}setTimeout(v.bind(this),S)}}},{key:"sendInfo",value:function(a,t){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(G.debug("sendInfo()"),this._status!==z.STATUS_CONFIRMED&&this._status!==z.STATUS_WAITING_FOR_ACK&&this._status!==z.STATUS_1XX_RECEIVED)throw new Fs.InvalidStateError(this._status);var p=new yc(this);p.send(a,t,s)}},{key:"mute",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{audio:!0,video:!1};G.debug("mute()");var t=!1,s=!1;this._audioMuted===!1&&a.audio&&(t=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&a.video&&(s=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(t===!0||s===!0)&&this._onmute({audio:t,video:s})}},{key:"unmute",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{audio:!0,video:!0};G.debug("unmute()");var t=!1,s=!1;this._audioMuted===!0&&a.audio&&(t=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&a.video&&(s=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(t===!0||s===!0)&&this._onunmute({audio:t,video:s})}},{key:"hold",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;if(G.debug("hold()"),this._status!==z.STATUS_WAITING_FOR_ACK&&this._status!==z.STATUS_CONFIRMED||this._localHold===!0||!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");var p={succeeded:function(){s&&s()},failed:function(){a.terminate({cause:oe.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:p,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:p,extraHeaders:t.extraHeaders}),!0}},{key:"unhold",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;if(G.debug("unhold()"),this._status!==z.STATUS_WAITING_FOR_ACK&&this._status!==z.STATUS_CONFIRMED||this._localHold===!1||!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");var p={succeeded:function(){s&&s()},failed:function(){a.terminate({cause:oe.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:p,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:p,extraHeaders:t.extraHeaders}),!0}},{key:"renegotiate",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;G.debug("renegotiate()");var p=t.rtcOfferConstraints||null;if(this._status!==z.STATUS_WAITING_FOR_ACK&&this._status!==z.STATUS_CONFIRMED||!this._isReadyToReOffer())return!1;var h={succeeded:function(){s&&s()},failed:function(){a.terminate({cause:oe.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:h,rtcOfferConstraints:p,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:h,rtcOfferConstraints:p,extraHeaders:t.extraHeaders}),!0}},{key:"refer",value:function(a,t){var s=this;G.debug("refer()");var p=a;if(this._status!==z.STATUS_WAITING_FOR_ACK&&this._status!==z.STATUS_CONFIRMED)return!1;if(a=this._ua.normalizeTarget(a),!a)throw new TypeError("Invalid target: ".concat(p));var h=new hd(this);h.sendRefer(a,t);var d=h.id;return this._referSubscribers[d]=h,h.on("requestFailed",function(){delete s._referSubscribers[d]}),h.on("accepted",function(){delete s._referSubscribers[d]}),h.on("failed",function(){delete s._referSubscribers[d]}),h}},{key:"sendRequest",value:function(a,t){return G.debug("sendRequest()"),this._dialog.sendRequest(a,t)}},{key:"receiveRequest",value:function(a){var t=this;if(G.debug("receiveRequest()"),a.method===oe.CANCEL)(this._status===z.STATUS_WAITING_FOR_ANSWER||this._status===z.STATUS_ANSWERED)&&(this._status=z.STATUS_CANCELED,this._request.reply(487),this._failed("remote",a,oe.causes.CANCELED));else switch(a.method){case oe.ACK:if(this._status!==z.STATUS_WAITING_FOR_ACK)return;if(this._status=z.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!a.body){this.terminate({cause:oe.causes.MISSING_SDP,status_code:400});break}var s={originator:"remote",type:"answer",sdp:a.body};G.debug('emit "sdp"'),this.emit("sdp",s);var p=new RTCSessionDescription({type:"answer",sdp:s.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._connection.setRemoteDescription(p)}).then(function(){t._is_confirmed||t._confirmed("remote",a)}).catch(function(d){t.terminate({cause:oe.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),G.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',d),t.emit("peerconnection:setremotedescriptionfailed",d)})}else this._is_confirmed||this._confirmed("remote",a);break;case oe.BYE:this._status===z.STATUS_CONFIRMED||this._status===z.STATUS_WAITING_FOR_ACK?(a.reply(200),this._ended("remote",a,oe.causes.BYE)):this._status===z.STATUS_INVITE_RECEIVED||this._status===z.STATUS_WAITING_FOR_ANSWER?(a.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",a,oe.causes.BYE)):a.reply(403,"Wrong Status");break;case oe.INVITE:this._status===z.STATUS_CONFIRMED?a.hasHeader("replaces")?this._receiveReplaces(a):this._receiveReinvite(a):a.reply(403,"Wrong Status");break;case oe.INFO:if(this._status===z.STATUS_1XX_RECEIVED||this._status===z.STATUS_WAITING_FOR_ANSWER||this._status===z.STATUS_ANSWERED||this._status===z.STATUS_WAITING_FOR_ACK||this._status===z.STATUS_CONFIRMED){var h=a.hasHeader("Content-Type")?a.getHeader("Content-Type").toLowerCase():void 0;h&&h.match(/^application\/dtmf-relay/i)?new bt(this).init_incoming(a):h!==void 0?new yc(this).init_incoming(a):a.reply(415)}else a.reply(403,"Wrong Status");break;case oe.UPDATE:this._status===z.STATUS_CONFIRMED?this._receiveUpdate(a):a.reply(403,"Wrong Status");break;case oe.REFER:this._status===z.STATUS_CONFIRMED?this._receiveRefer(a):a.reply(403,"Wrong Status");break;case oe.NOTIFY:this._status===z.STATUS_CONFIRMED?this._receiveNotify(a):a.reply(403,"Wrong Status");break;default:a.reply(501)}}},{key:"onTransportError",value:function(){G.warn("onTransportError()"),this._status!==z.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:oe.causes.CONNECTION_ERROR,cause:oe.causes.CONNECTION_ERROR})}},{key:"onRequestTimeout",value:function(){G.warn("onRequestTimeout()"),this._status!==z.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:oe.causes.REQUEST_TIMEOUT,cause:oe.causes.REQUEST_TIMEOUT})}},{key:"onDialogError",value:function(){G.warn("onDialogError()"),this._status!==z.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:oe.causes.DIALOG_ERROR,cause:oe.causes.DIALOG_ERROR})}},{key:"newDTMF",value:function(a){G.debug("newDTMF()"),this.emit("newDTMF",a)}},{key:"newInfo",value:function(a){G.debug("newInfo()"),this.emit("newInfo",a)}},{key:"_isReadyToReOffer",value:function(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(G.debug("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(G.debug("_isReadyToReOffer() | session not established yet"),!1):(G.debug("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}},{key:"_close",value:function(){if(G.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(G.debug("close() | closing local MediaStream"),Fe.closeMediaStream(this._localMediaStream)),this._status!==z.STATUS_TERMINATED){if(this._status=z.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(p){G.warn("close() | error closing the RTCPeerConnection: %o",p)}for(var a in this._timers)Object.prototype.hasOwnProperty.call(this._timers,a)&&clearTimeout(this._timers[a]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(var t in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,t)&&(this._earlyDialogs[t].terminate(),delete this._earlyDialogs[t]);for(var s in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,s)&&delete this._referSubscribers[s];this._ua.destroyRTCSession(this)}}},{key:"_setInvite2xxTimer",value:function(a,t){var s=Ar.T1;function p(){this._status===z.STATUS_WAITING_FOR_ACK&&(a.reply(200,null,["Contact: ".concat(this._contact)],t),s<Ar.T2&&(s=s*2,s>Ar.T2&&(s=Ar.T2)),this._timers.invite2xxTimer=setTimeout(p.bind(this),s))}this._timers.invite2xxTimer=setTimeout(p.bind(this),s)}},{key:"_setACKTimer",value:function(){var a=this;this._timers.ackTimer=setTimeout(function(){a._status===z.STATUS_WAITING_FOR_ACK&&(G.debug("no ACK received, terminating the session"),clearTimeout(a._timers.invite2xxTimer),a.sendRequest(oe.BYE),a._ended("remote",null,oe.causes.NO_ACK))},Ar.TIMER_H)}},{key:"_createRTCConnection",value:function(a,t){var s=this;this._connection=new RTCPeerConnection(a,t),this._connection.addEventListener("iceconnectionstatechange",function(){var p=s._connection.iceConnectionState;p==="failed"&&s.terminate({cause:oe.causes.RTP_TIMEOUT,status_code:408,reason_phrase:oe.causes.RTP_TIMEOUT})}),G.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}},{key:"_createLocalDescription",value:function(a,t){var s=this;if(G.debug("createLocalDescription()"),a!=="offer"&&a!=="answer")throw new Error('createLocalDescription() | invalid type "'.concat(a,'"'));var p=this._connection;return this._rtcReady=!1,Promise.resolve().then(function(){return a==="offer"?p.createOffer(t).catch(function(h){return G.warn('emit "peerconnection:createofferfailed" [error:%o]',h),s.emit("peerconnection:createofferfailed",h),Promise.reject(h)}):p.createAnswer(t).catch(function(h){return G.warn('emit "peerconnection:createanswerfailed" [error:%o]',h),s.emit("peerconnection:createanswerfailed",h),Promise.reject(h)})}).then(function(h){return p.setLocalDescription(h).catch(function(d){return s._rtcReady=!0,G.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',d),s.emit("peerconnection:setlocaldescriptionfailed",d),Promise.reject(d)})}).then(function(){var h=t&&t.iceRestart;if(p.iceGatheringState==="complete"&&!h||p.iceGatheringState==="gathering"&&s._iceReady){s._rtcReady=!0;var d={originator:"local",type:a,sdp:p.localDescription.sdp};return G.debug('emit "sdp"'),s.emit("sdp",d),Promise.resolve(d.sdp)}return new Promise(function(g){var v=!1,E,S;s._iceReady=!1;var C=function(){p.removeEventListener("icecandidate",E),p.removeEventListener("icegatheringstatechange",S),v=!0,s._rtcReady=!0,s._iceReady=!0;var w={originator:"local",type:a,sdp:p.localDescription.sdp};G.debug('emit "sdp"'),s.emit("sdp",w),g(w.sdp)};p.addEventListener("icecandidate",E=function(w){var F=w.candidate;F?s.emit("icecandidate",{candidate:F,ready:C}):v||C()}),p.addEventListener("icegatheringstatechange",S=function(){p.iceGatheringState==="complete"&&!v&&C()})})})}},{key:"_createDialog",value:function(a,t,s){var p=t==="UAS"?a.to_tag:a.from_tag,h=t==="UAS"?a.from_tag:a.to_tag,d=a.call_id+p+h,g=this._earlyDialogs[d];if(s)return g?!0:(g=new bl(this,a,t,bl.C.STATUS_EARLY),g.error?(G.debug(g.error),this._failed("remote",a,oe.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[d]=g,!0));if(this._from_tag=a.from_tag,this._to_tag=a.to_tag,g)return g.update(a,t),this._dialog=g,delete this._earlyDialogs[d],!0;var v=new bl(this,a,t);return v.error?(G.debug(v.error),this._failed("remote",a,oe.causes.INTERNAL_ERROR),!1):(this._dialog=v,!0)}},{key:"_receiveReinvite",value:function(a){var t=this;G.debug("receiveReinvite()");var s=a.hasHeader("Content-Type")?a.getHeader("Content-Type").toLowerCase():void 0,p={request:a,callback:void 0,reject:d.bind(this)},h=!1;function d(){var v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};h=!0;var E=v.status_code||403,S=v.reason_phrase||"",C=Fe.cloneArray(v.extraHeaders);if(this._status!==z.STATUS_CONFIRMED)return!1;if(E<300||E>=700)throw new TypeError("Invalid status_code: ".concat(E));a.reply(E,S,C)}if(this.emit("reinvite",p),h)return;if(this._late_sdp=!1,!a.body){this._late_sdp=!0,this._remoteHold&&(this._remoteHold=!1,this._onunhold("remote")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._createLocalDescription("offer",t._rtcOfferConstraints)}).then(function(v){g.call(t,v)}).catch(function(){a.reply(500)});return}if(s!=="application/sdp"){G.debug("invalid Content-Type"),a.reply(415);return}this._processInDialogSdpOffer(a).then(function(v){t._status!==z.STATUS_TERMINATED&&g.call(t,v)}).catch(function(v){G.warn(v)});function g(v){var E=this,S=["Contact: ".concat(this._contact)];this._handleSessionTimersInIncomingRequest(a,S),this._late_sdp&&(v=this._mangleOffer(v)),a.reply(200,null,S,v,function(){E._status=z.STATUS_WAITING_FOR_ACK,E._setInvite2xxTimer(a,v),E._setACKTimer()}),typeof p.callback=="function"&&p.callback()}}},{key:"_receiveUpdate",value:function(a){var t=this;G.debug("receiveUpdate()");var s=a.hasHeader("Content-Type")?a.getHeader("Content-Type").toLowerCase():void 0,p={request:a,callback:void 0,reject:d.bind(this)},h=!1;function d(){var v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};h=!0;var E=v.status_code||403,S=v.reason_phrase||"",C=Fe.cloneArray(v.extraHeaders);if(this._status!==z.STATUS_CONFIRMED)return!1;if(E<300||E>=700)throw new TypeError("Invalid status_code: ".concat(E));a.reply(E,S,C)}if(this.emit("update",p),h)return;if(!a.body){g.call(this,null);return}if(s!=="application/sdp"){G.debug("invalid Content-Type"),a.reply(415);return}this._processInDialogSdpOffer(a).then(function(v){t._status!==z.STATUS_TERMINATED&&g.call(t,v)}).catch(function(v){G.warn(v)});function g(v){var E=["Contact: ".concat(this._contact)];this._handleSessionTimersInIncomingRequest(a,E),a.reply(200,null,E,v),typeof p.callback=="function"&&p.callback()}}},{key:"_processInDialogSdpOffer",value:function(a){var t=this;G.debug("_processInDialogSdpOffer()");var s=a.parseSDP(),p=!1,h=rs(s.media),d;try{for(h.s();!(d=h.n()).done;){var g=d.value;if(wl.indexOf(g.type)!==-1){var v=g.direction||s.direction||"sendrecv";if(v==="sendonly"||v==="inactive")p=!0;else{p=!1;break}}}}catch(C){h.e(C)}finally{h.f()}var E={originator:"remote",type:"offer",sdp:a.body};G.debug('emit "sdp"'),this.emit("sdp",E);var S=new RTCSessionDescription({type:"offer",sdp:E.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){if(t._status===z.STATUS_TERMINATED)throw new Error("terminated");return t._connection.setRemoteDescription(S).catch(function(C){throw a.reply(488),G.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',C),t.emit("peerconnection:setremotedescriptionfailed",C),C})}).then(function(){if(t._status===z.STATUS_TERMINATED)throw new Error("terminated");t._remoteHold===!0&&p===!1?(t._remoteHold=!1,t._onunhold("remote")):t._remoteHold===!1&&p===!0&&(t._remoteHold=!0,t._onhold("remote"))}).then(function(){if(t._status===z.STATUS_TERMINATED)throw new Error("terminated");return t._createLocalDescription("answer",t._rtcAnswerConstraints).catch(function(C){throw a.reply(500),G.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',C),C})}).catch(function(C){G.warn("_processInDialogSdpOffer() failed [error: %o]",C)}),this._connectionPromiseQueue}},{key:"_receiveRefer",value:function(a){var t=this;if(G.debug("receiveRefer()"),!a.refer_to){G.debug("no Refer-To header field present in REFER"),a.reply(400);return}if(a.refer_to.uri.scheme!==oe.SIP){G.debug("Refer-To header field points to a non-SIP URI scheme"),a.reply(416);return}a.reply(202);var s=new fd(this,a.cseq);G.debug('emit "refer"'),this.emit("refer",{request:a,accept:function(g,v){p.call(t,g,v)},reject:function(){h.call(t)}});function p(d){var g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(d=typeof d=="function"?d:null,this._status!==z.STATUS_WAITING_FOR_ACK&&this._status!==z.STATUS_CONFIRMED)return!1;var v=new n(this._ua);if(v.on("progress",function(S){var C=S.response;s.notify(C.status_code,C.reason_phrase)}),v.on("accepted",function(S){var C=S.response;s.notify(C.status_code,C.reason_phrase)}),v.on("_failed",function(S){var C=S.message,I=S.cause;C?s.notify(C.status_code,C.reason_phrase):s.notify(487,I)}),a.refer_to.uri.hasHeader("replaces")){var E=decodeURIComponent(a.refer_to.uri.getHeader("replaces"));g.extraHeaders=Fe.cloneArray(g.extraHeaders),g.extraHeaders.push("Replaces: ".concat(E))}v.connect(a.refer_to.uri.toAor(),g,d)}function h(){s.notify(603)}}},{key:"_receiveNotify",value:function(a){switch(G.debug("receiveNotify()"),a.event||a.reply(400),a.event.event){case"refer":{var t,s;if(a.event.params&&a.event.params.id)t=a.event.params.id,s=this._referSubscribers[t];else if(Object.keys(this._referSubscribers).length===1)s=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{a.reply(400,"Missing event id parameter");return}if(!s){a.reply(481,"Subscription does not exist");return}s.receiveNotify(a),a.reply(200);break}default:a.reply(489)}}},{key:"_receiveReplaces",value:function(a){var t=this;G.debug("receiveReplaces()");function s(h){var d=this;if(this._status!==z.STATUS_WAITING_FOR_ACK&&this._status!==z.STATUS_CONFIRMED)return!1;var g=new n(this._ua);g.on("confirmed",function(){d.terminate()}),g.init_incoming(a,h)}function p(){G.debug("Replaced INVITE rejected by the user"),a.reply(486)}this.emit("replaces",{request:a,accept:function(d){s.call(t,d)},reject:function(){p.call(t)}})}},{key:"_sendInitialRequest",value:function(a,t,s){var p=this,h=new cd(this._ua,this._request,{onRequestTimeout:function(){p.onRequestTimeout()},onTransportError:function(){p.onTransportError()},onAuthenticated:function(g){p._request=g},onReceiveResponse:function(g){p._receiveInviteResponse(g)}});Promise.resolve().then(function(){if(s)return s;if(a.audio||a.video)return p._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(a).catch(function(d){throw p._status===z.STATUS_TERMINATED?new Error("terminated"):(p._failed("local",null,oe.causes.USER_DENIED_MEDIA_ACCESS),G.warn('emit "getusermediafailed" [error:%o]',d),p.emit("getusermediafailed",d),d)})}).then(function(d){if(p._status===z.STATUS_TERMINATED)throw new Error("terminated");return p._localMediaStream=d,d&&d.getTracks().forEach(function(g){p._connection.addTrack(g,d)}),p._connecting(p._request),p._createLocalDescription("offer",t).catch(function(g){throw p._failed("local",null,oe.causes.WEBRTC_ERROR),g})}).then(function(d){if(p._is_canceled||p._status===z.STATUS_TERMINATED)throw new Error("terminated");p._request.body=d,p._status=z.STATUS_INVITE_SENT,G.debug('emit "sending" [request:%o]',p._request),p.emit("sending",{request:p._request}),h.send()}).catch(function(d){p._status!==z.STATUS_TERMINATED&&G.warn(d)})}},{key:"_getDTMFRTPSender",value:function(){var a=this._connection.getSenders().find(function(t){return t.track&&t.track.kind==="audio"});if(!(a&&a.dtmf)){G.warn("sendDTMF() | no local audio track to send DTMF with");return}return a.dtmf}},{key:"_receiveInviteResponse",value:function(a){var t=this;if(G.debug("receiveInviteResponse()"),this._dialog&&a.status_code>=200&&a.status_code<=299)if(this._dialog.id.call_id===a.call_id&&this._dialog.id.local_tag===a.from_tag&&this._dialog.id.remote_tag===a.to_tag){this.sendRequest(oe.ACK);return}else{var s=new bl(this,a,"UAC");if(s.error!==void 0){G.debug(s.error);return}this.sendRequest(oe.ACK),this.sendRequest(oe.BYE);return}if(this._is_canceled){a.status_code>=100&&a.status_code<200?this._request.cancel(this._cancel_reason):a.status_code>=200&&a.status_code<299&&this._acceptAndTerminate(a);return}if(!(this._status!==z.STATUS_INVITE_SENT&&this._status!==z.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(a.status_code):this._status=z.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(a.status_code):{if(!a.to_tag){G.debug("1xx response received without to tag");break}if(a.hasHeader("contact")&&!this._createDialog(a,"UAC",!0))break;if(this._status=z.STATUS_1XX_RECEIVED,!a.body){this._progress("remote",a);break}var p={originator:"remote",type:"answer",sdp:a.body};G.debug('emit "sdp"'),this.emit("sdp",p);var h=new RTCSessionDescription({type:"answer",sdp:p.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._connection.setRemoteDescription(h)}).then(function(){return t._progress("remote",a)}).catch(function(E){G.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',E),t.emit("peerconnection:setremotedescriptionfailed",E)});break}case/^2[0-9]{2}$/.test(a.status_code):{if(this._status=z.STATUS_CONFIRMED,!a.body){this._acceptAndTerminate(a,400,oe.causes.MISSING_SDP),this._failed("remote",a,oe.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(a,"UAC"))break;var d={originator:"remote",type:"answer",sdp:a.body};G.debug('emit "sdp"'),this.emit("sdp",d);var g=new RTCSessionDescription({type:"answer",sdp:d.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){if(t._connection.signalingState==="stable")return t._connection.createOffer(t._rtcOfferConstraints).then(function(E){return t._connection.setLocalDescription(E)}).catch(function(E){t._acceptAndTerminate(a,500,E.toString()),t._failed("local",a,oe.causes.WEBRTC_ERROR)})}).then(function(){t._connection.setRemoteDescription(g).then(function(){t._handleSessionTimersInIncomingResponse(a),t._accepted("remote",a),t.sendRequest(oe.ACK),t._confirmed("local",null)}).catch(function(E){t._acceptAndTerminate(a,488,"Not Acceptable Here"),t._failed("remote",a,oe.causes.BAD_MEDIA_DESCRIPTION),G.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',E),t.emit("peerconnection:setremotedescriptionfailed",E)})});break}default:{var v=Fe.sipErrorCause(a.status_code);this._failed("remote",a,v)}}}},{key:"_sendReinvite",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};G.debug("sendReinvite()");var s=Fe.cloneArray(t.extraHeaders),p=Fe.cloneObject(t.eventHandlers),h=t.rtcOfferConstraints||this._rtcOfferConstraints||null,d=!1;s.push("Contact: ".concat(this._contact)),s.push("Content-Type: application/sdp"),this._sessionTimers.running&&s.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(this._sessionTimers.refresher?"uac":"uas")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return a._createLocalDescription("offer",h)}).then(function(E){E=a._mangleOffer(E);var S={originator:"local",type:"offer",sdp:E};G.debug('emit "sdp"'),a.emit("sdp",S),a.sendRequest(oe.INVITE,{extraHeaders:s,body:E,eventHandlers:{onSuccessResponse:function(I){g.call(a,I),d=!0},onErrorResponse:function(I){v.call(a,I)},onTransportError:function(){a.onTransportError()},onRequestTimeout:function(){a.onRequestTimeout()},onDialogError:function(){a.onDialogError()}}})}).catch(function(){v()});function g(E){var S=this;if(this._status!==z.STATUS_TERMINATED&&(this.sendRequest(oe.ACK),!d)){if(this._handleSessionTimersInIncomingResponse(E),E.body){if(!E.hasHeader("Content-Type")||E.getHeader("Content-Type").toLowerCase()!=="application/sdp"){v.call(this);return}}else{v.call(this);return}var C={originator:"remote",type:"answer",sdp:E.body};G.debug('emit "sdp"'),this.emit("sdp",C);var I=new RTCSessionDescription({type:"answer",sdp:C.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return S._connection.setRemoteDescription(I)}).then(function(){p.succeeded&&p.succeeded(E)}).catch(function(w){v.call(S),G.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',w),S.emit("peerconnection:setremotedescriptionfailed",w)})}}function v(E){p.failed&&p.failed(E)}}},{key:"_sendUpdate",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};G.debug("sendUpdate()");var s=Fe.cloneArray(t.extraHeaders),p=Fe.cloneObject(t.eventHandlers),h=t.rtcOfferConstraints||this._rtcOfferConstraints||null,d=t.sdpOffer||!1,g=!1;s.push("Contact: ".concat(this._contact)),this._sessionTimers.running&&s.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(this._sessionTimers.refresher?"uac":"uas")),d?(s.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return a._createLocalDescription("offer",h)}).then(function(S){S=a._mangleOffer(S);var C={originator:"local",type:"offer",sdp:S};G.debug('emit "sdp"'),a.emit("sdp",C),a.sendRequest(oe.UPDATE,{extraHeaders:s,body:S,eventHandlers:{onSuccessResponse:function(w){v.call(a,w),g=!0},onErrorResponse:function(w){E.call(a,w)},onTransportError:function(){a.onTransportError()},onRequestTimeout:function(){a.onRequestTimeout()},onDialogError:function(){a.onDialogError()}}})}).catch(function(){E.call(a)})):this.sendRequest(oe.UPDATE,{extraHeaders:s,eventHandlers:{onSuccessResponse:function(C){v.call(a,C)},onErrorResponse:function(C){E.call(a,C)},onTransportError:function(){a.onTransportError()},onRequestTimeout:function(){a.onRequestTimeout()},onDialogError:function(){a.onDialogError()}}});function v(S){var C=this;if(this._status!==z.STATUS_TERMINATED&&!g)if(this._handleSessionTimersInIncomingResponse(S),d){if(S.body){if(!S.hasHeader("Content-Type")||S.getHeader("Content-Type").toLowerCase()!=="application/sdp"){E.call(this);return}}else{E.call(this);return}var I={originator:"remote",type:"answer",sdp:S.body};G.debug('emit "sdp"'),this.emit("sdp",I);var w=new RTCSessionDescription({type:"answer",sdp:I.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return C._connection.setRemoteDescription(w)}).then(function(){p.succeeded&&p.succeeded(S)}).catch(function(F){E.call(C),G.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',F),C.emit("peerconnection:setremotedescriptionfailed",F)})}else p.succeeded&&p.succeeded(S)}function E(S){p.failed&&p.failed(S)}}},{key:"_acceptAndTerminate",value:function(a,t,s){G.debug("acceptAndTerminate()");var p=[];t&&(s=s||oe.REASON_PHRASE[t]||"",p.push("Reason: SIP ;cause=".concat(t,'; text="').concat(s,'"'))),(this._dialog||this._createDialog(a,"UAC"))&&(this.sendRequest(oe.ACK),this.sendRequest(oe.BYE,{extraHeaders:p})),this._status=z.STATUS_TERMINATED}},{key:"_mangleOffer",value:function(a){if(!this._localHold&&!this._remoteHold)return a;if(a=Tc.parse(a),this._localHold&&!this._remoteHold){G.debug("mangleOffer() | me on hold, mangling offer");var t=rs(a.media),s;try{for(t.s();!(s=t.n()).done;){var p=s.value;wl.indexOf(p.type)!==-1&&(p.direction?p.direction==="sendrecv"?p.direction="sendonly":p.direction==="recvonly"&&(p.direction="inactive"):p.direction="sendonly")}}catch(C){t.e(C)}finally{t.f()}}else if(this._localHold&&this._remoteHold){G.debug("mangleOffer() | both on hold, mangling offer");var h=rs(a.media),d;try{for(h.s();!(d=h.n()).done;){var g=d.value;wl.indexOf(g.type)!==-1&&(g.direction="inactive")}}catch(C){h.e(C)}finally{h.f()}}else if(this._remoteHold){G.debug("mangleOffer() | remote on hold, mangling offer");var v=rs(a.media),E;try{for(v.s();!(E=v.n()).done;){var S=E.value;wl.indexOf(S.type)!==-1&&(S.direction?S.direction==="sendrecv"?S.direction="recvonly":S.direction==="recvonly"&&(S.direction="inactive"):S.direction="recvonly")}}catch(C){v.e(C)}finally{v.f()}}return Tc.write(a)}},{key:"_setLocalMediaStatus",value:function(){var a=!0,t=!0;(this._localHold||this._remoteHold)&&(a=!1,t=!1),this._audioMuted&&(a=!1),this._videoMuted&&(t=!1),this._toggleMuteAudio(!a),this._toggleMuteVideo(!t)}},{key:"_handleSessionTimersInIncomingRequest",value:function(a,t){if(this._sessionTimers.enabled){var s;a.session_expires&&a.session_expires>=oe.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=a.session_expires,s=a.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,s="uas"),t.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(s)),this._sessionTimers.refresher=s==="uas",this._runSessionTimer()}}},{key:"_handleSessionTimersInIncomingResponse",value:function(a){if(this._sessionTimers.enabled){var t;a.session_expires&&a.session_expires>=oe.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=a.session_expires,t=a.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,t="uac"),this._sessionTimers.refresher=t==="uac",this._runSessionTimer()}}},{key:"_runSessionTimer",value:function(){var a=this,t=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(function(){a._status!==z.STATUS_TERMINATED&&a._isReadyToReOffer()&&(G.debug("runSessionTimer() | sending session refresh request"),a._sessionTimers.refreshMethod===oe.UPDATE?a._sendUpdate():a._sendReinvite())},t*500):this._sessionTimers.timer=setTimeout(function(){a._status!==z.STATUS_TERMINATED&&(G.warn("runSessionTimer() | timer expired, terminating the session"),a.terminate({cause:oe.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},t*1100)}},{key:"_toggleMuteAudio",value:function(a){var t=this._connection.getSenders().filter(function(d){return d.track&&d.track.kind==="audio"}),s=rs(t),p;try{for(s.s();!(p=s.n()).done;){var h=p.value;h.track.enabled=!a}}catch(d){s.e(d)}finally{s.f()}}},{key:"_toggleMuteVideo",value:function(a){var t=this._connection.getSenders().filter(function(d){return d.track&&d.track.kind==="video"}),s=rs(t),p;try{for(s.s();!(p=s.n()).done;){var h=p.value;h.track.enabled=!a}}catch(d){s.e(d)}finally{s.f()}}},{key:"_newRTCSession",value:function(a,t){G.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:a,session:this,request:t})}},{key:"_connecting",value:function(a){G.debug("session connecting"),G.debug('emit "connecting"'),this.emit("connecting",{request:a})}},{key:"_progress",value:function(a,t){G.debug("session progress"),G.debug('emit "progress"'),this.emit("progress",{originator:a,response:t||null})}},{key:"_accepted",value:function(a,t){G.debug("session accepted"),this._start_time=new Date,G.debug('emit "accepted"'),this.emit("accepted",{originator:a,response:t||null})}},{key:"_confirmed",value:function(a,t){G.debug("session confirmed"),this._is_confirmed=!0,G.debug('emit "confirmed"'),this.emit("confirmed",{originator:a,ack:t||null})}},{key:"_ended",value:function(a,t,s){G.debug("session ended"),this._end_time=new Date,this._close(),G.debug('emit "ended"'),this.emit("ended",{originator:a,message:t||null,cause:s})}},{key:"_failed",value:function(a,t,s){G.debug("session failed"),G.debug('emit "_failed"'),this.emit("_failed",{originator:a,message:t||null,cause:s}),this._close(),G.debug('emit "failed"'),this.emit("failed",{originator:a,message:t||null,cause:s})}},{key:"_onhold",value:function(a){G.debug("session onhold"),this._setLocalMediaStatus(),G.debug('emit "hold"'),this.emit("hold",{originator:a})}},{key:"_onunhold",value:function(a){G.debug("session onunhold"),this._setLocalMediaStatus(),G.debug('emit "unhold"'),this.emit("unhold",{originator:a})}},{key:"_onmute",value:function(a){var t=a.audio,s=a.video;G.debug("session onmute"),this._setLocalMediaStatus(),G.debug('emit "muted"'),this.emit("muted",{audio:t,video:s})}},{key:"_onunmute",value:function(a){var t=a.audio,s=a.video;G.debug("session onunmute"),this._setLocalMediaStatus(),G.debug('emit "unmuted"'),this.emit("unmuted",{audio:t,video:s})}},{key:"C",get:function(){return z}},{key:"causes",get:function(){return oe.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(a){this._data=a}},{key:"status",get:function(){return this._status}}]),n}(od);function Ol(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Ol=function(n){return typeof n}:Ol=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Ol(c)}function dd(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Cc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function pd(c,r,n){return r&&Cc(c.prototype,r),n&&Cc(c,n),c}function md(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&Zo(c,r)}function Zo(c,r){return Zo=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Zo(c,r)}function gd(c){var r=Ed();return function(){var o=Dl(c),a;if(r){var t=Dl(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return vd(this,a)}}function vd(c,r){return r&&(Ol(r)==="object"||typeof r=="function")?r:Td(c)}function Td(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Ed(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Dl(c){return Dl=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},Dl(c)}var yd=ot.EventEmitter,Sd=rt,ea=Xe,Cd=ts,Rr=Tt(),Ad=Er,Ac=ps,Rd=ms(),Nl=new Sd("Message"),Id=function(c){md(n,c);var r=gd(n);function n(o){var a;return dd(this,n),a=r.call(this),a._ua=o,a._request=null,a._closed=!1,a._direction=null,a._local_identity=null,a._remote_identity=null,a._is_replied=!1,a._data={},a}return pd(n,[{key:"send",value:function(a,t){var s=this,p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},h=a;if(a===void 0||t===void 0)throw new TypeError("Not enough arguments");if(a=this._ua.normalizeTarget(a),!a)throw new TypeError("Invalid target: ".concat(h));var d=Rr.cloneArray(p.extraHeaders),g=Rr.cloneObject(p.eventHandlers),v=p.contentType||"text/plain",E={};p.fromUserName&&(E.from_uri=new Rd("sip",p.fromUserName,this._ua.configuration.uri.host),d.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString()))),p.fromDisplayName&&(E.from_display_name=p.fromDisplayName);for(var S in g)Object.prototype.hasOwnProperty.call(g,S)&&this.on(S,g[S]);d.push("Content-Type: ".concat(v)),this._request=new Cd.OutgoingRequest(ea.MESSAGE,a,this._ua,E,d),t&&(this._request.body=t);var C=new Ad(this._ua,this._request,{onRequestTimeout:function(){s._onRequestTimeout()},onTransportError:function(){s._onTransportError()},onReceiveResponse:function(w){s._receiveResponse(w)}});this._newMessage("local",this._request),C.send()}},{key:"init_incoming",value:function(a){this._request=a,this._newMessage("remote",a),this._is_replied||(this._is_replied=!0,a.reply(200)),this._close()}},{key:"accept",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=Rr.cloneArray(a.extraHeaders),s=a.body;if(this._direction!=="incoming")throw new Ac.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,s)}},{key:"reject",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=a.status_code||480,s=a.reason_phrase,p=Rr.cloneArray(a.extraHeaders),h=a.body;if(this._direction!=="incoming")throw new Ac.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,s,p,h)}},{key:"_receiveResponse",value:function(a){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(a.status_code):break;case/^2[0-9]{2}$/.test(a.status_code):this._succeeded("remote",a);break;default:{var t=Rr.sipErrorCause(a.status_code);this._failed("remote",a,t);break}}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,ea.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,ea.causes.CONNECTION_ERROR)}},{key:"_close",value:function(){this._closed=!0,this._ua.destroyMessage(this)}},{key:"_newMessage",value:function(a,t){a==="remote"?(this._direction="incoming",this._local_identity=t.to,this._remote_identity=t.from):a==="local"&&(this._direction="outgoing",this._local_identity=t.from,this._remote_identity=t.to),this._ua.newMessage(this,{originator:a,message:this,request:t})}},{key:"_failed",value:function(a,t,s){Nl.debug("MESSAGE failed"),this._close(),Nl.debug('emit "failed"'),this.emit("failed",{originator:a,response:t||null,cause:s})}},{key:"_succeeded",value:function(a,t){Nl.debug("MESSAGE succeeded"),this._close(),Nl.debug('emit "succeeded"'),this.emit("succeeded",{originator:a,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}(yd);function Ul(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Ul=function(n){return typeof n}:Ul=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Ul(c)}function bd(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Rc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function wd(c,r,n){return r&&Rc(c.prototype,r),n&&Rc(c,n),c}function Od(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&ta(c,r)}function ta(c,r){return ta=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},ta(c,r)}function Dd(c){var r=Pd();return function(){var o=Pl(c),a;if(r){var t=Pl(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return Nd(this,a)}}function Nd(c,r){return r&&(Ul(r)==="object"||typeof r=="function")?r:Ud(c)}function Ud(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Pd(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Pl(c){return Pl=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},Pl(c)}var kd=ot.EventEmitter,Md=rt,sa=Xe,xd=ts,Ir=Tt(),Ld=Er,Ic=ps,kl=new Md("Options"),$d=function(c){Od(n,c);var r=Dd(n);function n(o){var a;return bd(this,n),a=r.call(this),a._ua=o,a._request=null,a._closed=!1,a._direction=null,a._local_identity=null,a._remote_identity=null,a._is_replied=!1,a._data={},a}return wd(n,[{key:"send",value:function(a,t){var s=this,p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},h=a;if(a===void 0)throw new TypeError("A target is required for OPTIONS");if(a=this._ua.normalizeTarget(a),!a)throw new TypeError("Invalid target: ".concat(h));var d=Ir.cloneArray(p.extraHeaders),g=Ir.cloneObject(p.eventHandlers),v=p.contentType||"application/sdp";for(var E in g)Object.prototype.hasOwnProperty.call(g,E)&&this.on(E,g[E]);d.push("Content-Type: ".concat(v)),this._request=new xd.OutgoingRequest(sa.OPTIONS,a,this._ua,null,d),t&&(this._request.body=t);var S=new Ld(this._ua,this._request,{onRequestTimeout:function(){s._onRequestTimeout()},onTransportError:function(){s._onTransportError()},onReceiveResponse:function(I){s._receiveResponse(I)}});this._newOptions("local",this._request),S.send()}},{key:"init_incoming",value:function(a){this._request=a,this._newOptions("remote",a),this._is_replied||(this._is_replied=!0,a.reply(200)),this._close()}},{key:"accept",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=Ir.cloneArray(a.extraHeaders),s=a.body;if(this._direction!=="incoming")throw new Ic.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,s)}},{key:"reject",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=a.status_code||480,s=a.reason_phrase,p=Ir.cloneArray(a.extraHeaders),h=a.body;if(this._direction!=="incoming")throw new Ic.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,s,p,h)}},{key:"_receiveResponse",value:function(a){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(a.status_code):break;case/^2[0-9]{2}$/.test(a.status_code):this._succeeded("remote",a);break;default:{var t=Ir.sipErrorCause(a.status_code);this._failed("remote",a,t);break}}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,sa.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,sa.causes.CONNECTION_ERROR)}},{key:"_close",value:function(){this._closed=!0,this._ua.destroyMessage(this)}},{key:"_newOptions",value:function(a,t){a==="remote"?(this._direction="incoming",this._local_identity=t.to,this._remote_identity=t.from):a==="local"&&(this._direction="outgoing",this._local_identity=t.from,this._remote_identity=t.to),this._ua.newOptions(this,{originator:a,message:this,request:t})}},{key:"_failed",value:function(a,t,s){kl.debug("OPTIONS failed"),this._close(),kl.debug('emit "failed"'),this.emit("failed",{originator:a,response:t||null,cause:s})}},{key:"_succeeded",value:function(a,t){kl.debug("OPTIONS succeeded"),this._close(),kl.debug('emit "succeeded"'),this.emit("succeeded",{originator:a,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}(kd),na={},Hd=rt,ra=Tt(),Fd=Vt(),br=new Hd("Socket");na.isSocket=function(c){if(Array.isArray(c))return!1;if(typeof c>"u")return br.warn("undefined JsSIP.Socket instance"),!1;try{if(!ra.isString(c.url))throw br.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!ra.isString(c.via_transport))throw br.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(Fd.parse(c.sip_uri,"SIP_URI")===-1)throw br.warn("missing or invalid JsSIP.Socket sip_uri property"),new Error("missing or invalid JsSIP.Socket sip_uri property")}catch{return!1}try{["connect","disconnect","send"].forEach(function(r){if(!ra.isFunction(c[r]))throw br.warn("missing or invalid JsSIP.Socket method: ".concat(r)),new Error("Missing or invalid JsSIP.Socket method: ".concat(r))})}catch{return!1}return!0};function qd(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function bc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Vd(c,r,n){return r&&bc(c.prototype,r),n&&bc(c,n),c}var jd=rt,Bd=na,wc=Xe,Rt=new jd("Transport"),Nt={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:wc.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:wc.CONNECTION_RECOVERY_MAX_INTERVAL}},Gd=function(){function c(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Nt.recovery_options;qd(this,c),Rt.debug("new()"),this.status=Nt.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=n,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1;try{this.textDecoder=new TextDecoder("utf8")}catch(o){Rt.warn("cannot use TextDecoder: ".concat(o))}if(typeof r>"u")throw new TypeError("Invalid argument. undefined 'sockets' argument");r instanceof Array||(r=[r]),r.forEach(function(o){if(!Bd.isSocket(o.socket))throw new TypeError("Invalid argument. invalid 'JsSIP.Socket' instance");if(o.weight&&!Number(o.weight))throw new TypeError("Invalid argument. 'weight' attribute is not a number");this.sockets.push({socket:o.socket,weight:o.weight||0,status:Nt.SOCKET_STATUS_READY})},this),this._getSocket()}return Vd(c,[{key:"connect",value:function(){if(Rt.debug("connect()"),this.isConnected()){Rt.debug("Transport is already connected");return}else if(this.isConnecting()){Rt.debug("Transport is connecting");return}this.close_requested=!1,this.status=Nt.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(){Rt.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=Nt.STATUS_DISCONNECTED,this.recovery_timer!==null&&(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(n){if(Rt.debug("send()"),!this.isConnected())return Rt.warn("unable to send message, transport is not connected"),!1;var o=n.toString();return Rt.debug(`sending message:
|
48
|
+
`);p.length>=1&&t.test(p[0])&&(this._tone=p[0].replace(t,"$2")),p.length>=2&&s.test(p[1])&&(this._duration=parseInt(p[1].replace(s,"$2"),10))}this._duration||(this._duration=cc.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:a}):A_.debug("invalid INFO DTMF received, discarded")}},{key:"tone",get:function(){return this._tone}},{key:"duration",get:function(){return this._duration}}]),n}(E_),Wo.exports.C=cc;var R_=Wo.exports;function yl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?yl=function(n){return typeof n}:yl=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},yl(c)}function I_(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function fc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function b_(c,r,n){return r&&fc(c.prototype,r),n&&fc(c,n),c}function w_(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&zo(c,r)}function zo(c,r){return zo=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},zo(c,r)}function O_(c){var r=U_();return function(){var o=Sl(c),a;if(r){var t=Sl(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return D_(this,a)}}function D_(c,r){return r&&(yl(r)==="object"||typeof r=="function")?r:N_(c)}function N_(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function U_(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Sl(c){return Sl=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},Sl(c)}var P_=ot.EventEmitter,k_=Xe,M_=ms,x_=Tt(),L_=function(c){w_(n,c);var r=O_(n);function n(o){var a;return I_(this,n),a=r.call(this),a._session=o,a._direction=null,a._contentType=null,a._body=null,a}return b_(n,[{key:"send",value:function(a,t){var s=this,p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this._direction="outgoing",a===void 0)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 M_.InvalidStateError(this._session.status);this._contentType=a,this._body=t;var h=x_.cloneArray(p.extraHeaders);h.push("Content-Type: ".concat(a)),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(k_.INFO,{extraHeaders:h,eventHandlers:{onSuccessResponse:function(g){s.emit("succeeded",{originator:"remote",response:g})},onErrorResponse:function(g){s.emit("failed",{originator:"remote",response:g})},onTransportError:function(){s._session.onTransportError()},onRequestTimeout:function(){s._session.onRequestTimeout()},onDialogError:function(){s._session.onDialogError()}},body:t})}},{key:"init_incoming",value:function(a){this._direction="incoming",this.request=a,a.reply(200),this._contentType=a.hasHeader("Content-Type")?a.getHeader("Content-Type").toLowerCase():void 0,this._body=a.body,this._session.newInfo({originator:"remote",info:this,request:a})}},{key:"contentType",get:function(){return this._contentType}},{key:"body",get:function(){return this._body}}]),n}(P_);function $_(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function hc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function H_(c,r,n){return r&&hc(c.prototype,r),n&&hc(c,n),c}var F_=rt,_c=Xe,q_=new F_("RTCSession:ReferNotifier"),Jo={event_type:"refer",body_type:"message/sipfrag;version=2.0",expires:300},V_=function(){function c(r,n,o){$_(this,c),this._session=r,this._id=n,this._expires=o||Jo.expires,this._active=!0,this.notify(100)}return H_(c,[{key:"notify",value:function(n,o){if(q_.debug("notify()"),this._active!==!1){o=o||_c.REASON_PHRASE[n]||"";var a;n>=200?a="terminated;reason=noresource":a="active;expires=".concat(this._expires),this._session.sendRequest(_c.NOTIFY,{extraHeaders:["Event: ".concat(Jo.event_type,";id=").concat(this._id),"Subscription-State: ".concat(a),"Content-Type: ".concat(Jo.body_type)],body:"SIP/2.0 ".concat(n," ").concat(o),eventHandlers:{onErrorResponse:function(){this._active=!1}}})}}}]),c}();function Cl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Cl=function(n){return typeof n}:Cl=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Cl(c)}function j_(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function dc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function B_(c,r,n){return r&&dc(c.prototype,r),n&&dc(c,n),c}function G_(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&Xo(c,r)}function Xo(c,r){return Xo=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Xo(c,r)}function K_(c){var r=z_();return function(){var o=Al(c),a;if(r){var t=Al(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return W_(this,a)}}function W_(c,r){return r&&(Cl(r)==="object"||typeof r=="function")?r:Y_(c)}function Y_(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function z_(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Al(c){return Al=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},Al(c)}var J_=ot.EventEmitter,X_=rt,Cr=Xe,Q_=Vt(),pc=Tt(),Fs=new X_("RTCSession:ReferSubscriber"),Z_=function(c){G_(n,c);var r=K_(n);function n(o){var a;return j_(this,n),a=r.call(this),a._id=null,a._session=o,a}return B_(n,[{key:"sendRefer",value:function(a){var t=this,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Fs.debug("sendRefer()");var p=pc.cloneArray(s.extraHeaders),h=pc.cloneObject(s.eventHandlers);for(var d in h)Object.prototype.hasOwnProperty.call(h,d)&&this.on(d,h[d]);var g=null;s.replaces&&(g=s.replaces._request.call_id,g+=";to-tag=".concat(s.replaces._to_tag),g+=";from-tag=".concat(s.replaces._from_tag),g=encodeURIComponent(g));var v="Refer-To: <".concat(a).concat(g?"?Replaces=".concat(g):"",">");if(p.push(v),!p.some(function(C){return C.toLowerCase().startsWith("referred-by:")})){var E="Referred-By: <".concat(this._session._ua._configuration.uri._scheme,":").concat(this._session._ua._configuration.uri._user,"@").concat(this._session._ua._configuration.uri._host,">");p.push(E)}p.push("Contact: ".concat(this._session.contact));var S=this._session.sendRequest(Cr.REFER,{extraHeaders:p,eventHandlers:{onSuccessResponse:function(I){t._requestSucceeded(I)},onErrorResponse:function(I){t._requestFailed(I,Cr.causes.REJECTED)},onTransportError:function(){t._requestFailed(null,Cr.causes.CONNECTION_ERROR)},onRequestTimeout:function(){t._requestFailed(null,Cr.causes.REQUEST_TIMEOUT)},onDialogError:function(){t._requestFailed(null,Cr.causes.DIALOG_ERROR)}}});this._id=S.cseq}},{key:"receiveNotify",value:function(a){if(Fs.debug("receiveNotify()"),!!a.body){var t=Q_.parse(a.body.trim().split(`\r
|
49
|
+
`,1)[0],"Status_Line");if(t===-1){Fs.debug('receiveNotify() | error parsing NOTIFY body: "'.concat(a.body,'"'));return}switch(!0){case/^100$/.test(t.status_code):this.emit("trying",{request:a,status_line:t});break;case/^1[0-9]{2}$/.test(t.status_code):this.emit("progress",{request:a,status_line:t});break;case/^2[0-9]{2}$/.test(t.status_code):this.emit("accepted",{request:a,status_line:t});break;default:this.emit("failed",{request:a,status_line:t});break}}}},{key:"_requestSucceeded",value:function(a){Fs.debug("REFER succeeded"),Fs.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:a})}},{key:"_requestFailed",value:function(a,t){Fs.debug("REFER failed"),Fs.debug('emit "requestFailed"'),this.emit("requestFailed",{response:a||null,cause:t})}},{key:"id",get:function(){return this._id}}]),n}(J_);function Rl(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Rl=function(n){return typeof n}:Rl=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Rl(c)}function is(c,r){var n;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(n=ed(c))||r&&c&&typeof c.length=="number"){n&&(c=n);var o=0,a=function(){};return{s:a,n:function(){return o>=c.length?{done:!0}:{done:!1,value:c[o++]}},e:function(d){throw d},f:a}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
50
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var t=!0,s=!1,p;return{s:function(){n=c[Symbol.iterator]()},n:function(){var d=n.next();return t=d.done,d},e:function(d){s=!0,p=d},f:function(){try{!t&&n.return!=null&&n.return()}finally{if(s)throw p}}}}function ed(c,r){if(c){if(typeof c=="string")return mc(c,r);var n=Object.prototype.toString.call(c).slice(8,-1);if(n==="Object"&&c.constructor&&(n=c.constructor.name),n==="Map"||n==="Set")return Array.from(c);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return mc(c,r)}}function mc(c,r){(r==null||r>c.length)&&(r=c.length);for(var n=0,o=new Array(r);n<r;n++)o[n]=c[n];return o}function td(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function gc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function vc(c,r,n){return r&&gc(c.prototype,r),n&&gc(c,n),c}function sd(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&Qo(c,r)}function Qo(c,r){return Qo=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Qo(c,r)}function nd(c){var r=ld();return function(){var o=Il(c),a;if(r){var t=Il(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return rd(this,a)}}function rd(c,r){return r&&(Rl(r)==="object"||typeof r=="function")?r:id(c)}function id(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function ld(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Il(c){return Il=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},Il(c)}var od=ot.EventEmitter,Tc=Ot,ad=rt,oe=Xe,qs=ms,Ec=Tr,Fe=Tt(),Ar=Yu,ud=ss,bl=h_,cd=Er,bt=R_,yc=L_,fd=V_,hd=Z_,Sc=gs(),G=new ad("RTCSession"),z={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},wl=["audio","video"],_d=function(c){sd(n,c);var r=nd(n);vc(n,null,[{key:"C",get:function(){return z}}]);function n(o){var a;return td(this,n),G.debug("new"),a=r.call(this),a._id=null,a._ua=o,a._status=z.STATUS_NULL,a._dialog=null,a._earlyDialogs={},a._contact=null,a._from_tag=null,a._to_tag=null,a._connection=null,a._connectionPromiseQueue=Promise.resolve(),a._request=null,a._is_canceled=!1,a._cancel_reason="",a._is_confirmed=!1,a._late_sdp=!1,a._rtcOfferConstraints=null,a._rtcAnswerConstraints=null,a._localMediaStream=null,a._localMediaStreamLocallyGenerated=!1,a._rtcReady=!0,a._iceReady=!1,a._timers={ackTimer:null,expiresTimer:null,invite2xxTimer:null,userNoAnswerTimer:null},a._direction=null,a._local_identity=null,a._remote_identity=null,a._start_time=null,a._end_time=null,a._tones=null,a._audioMuted=!1,a._videoMuted=!1,a._localHold=!1,a._remoteHold=!1,a._sessionTimers={enabled:a._ua.configuration.session_timers,refreshMethod:a._ua.configuration.session_timers_refresh_method,defaultExpires:oe.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},a._referSubscribers={},a._data={},a}return vc(n,[{key:"isInProgress",value:function(){switch(this._status){case z.STATUS_NULL:case z.STATUS_INVITE_SENT:case z.STATUS_1XX_RECEIVED:case z.STATUS_INVITE_RECEIVED:case z.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}},{key:"isEstablished",value:function(){switch(this._status){case z.STATUS_ANSWERED:case z.STATUS_WAITING_FOR_ACK:case z.STATUS_CONFIRMED:return!0;default:return!1}}},{key:"isEnded",value:function(){switch(this._status){case z.STATUS_CANCELED:case z.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(a){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;G.debug("connect()");var p=a,h=Fe.cloneObject(t.eventHandlers),d=Fe.cloneArray(t.extraHeaders),g=Fe.cloneObject(t.mediaConstraints,{audio:!0,video:!0}),v=t.mediaStream||null,E=Fe.cloneObject(t.pcConfig,{iceServers:[]}),S=t.rtcConstraints||null,C=t.rtcOfferConstraints||null;if(this._rtcOfferConstraints=C,this._rtcAnswerConstraints=t.rtcAnswerConstraints||null,this._data=t.data||this._data,a===void 0)throw new TypeError("Not enough arguments");if(this._status!==z.STATUS_NULL)throw new qs.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new qs.NotSupportedError("WebRTC not supported");if(a=this._ua.normalizeTarget(a),!a)throw new TypeError("Invalid target: ".concat(p));this._sessionTimers.enabled&&Fe.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=oe.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=oe.SESSION_EXPIRES);for(var I in h)Object.prototype.hasOwnProperty.call(h,I)&&this.on(I,h[I]);this._from_tag=Fe.newTag();var w=t.anonymous||!1,F={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:w,outbound:!0}),w?(F.from_display_name="Anonymous",F.from_uri=new Sc("sip","anonymous","anonymous.invalid"),d.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString())),d.push("Privacy: id")):t.fromUserName&&(F.from_uri=new Sc("sip",t.fromUserName,this._ua.configuration.uri.host),d.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString()))),t.fromDisplayName&&(F.from_display_name=t.fromDisplayName),d.push("Contact: ".concat(this._contact)),d.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&d.push("Session-Expires: ".concat(this._sessionTimers.defaultExpires).concat(this._ua.configuration.session_timers_force_refresher?";refresher=uac":"")),this._request=new ud.InitialOutgoingInviteRequest(a,this._ua,F,d),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(E,S),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,s&&s(this),this._newRTCSession("local",this._request),this._sendInitialRequest(g,C,v)}},{key:"init_incoming",value:function(a,t){var s=this;G.debug("init_incoming()");var p,h=a.hasHeader("Content-Type")?a.getHeader("Content-Type").toLowerCase():void 0;if(a.body&&h!=="application/sdp"){a.reply(415);return}if(this._status=z.STATUS_INVITE_RECEIVED,this._from_tag=a.from_tag,this._id=a.call_id+this._from_tag,this._request=a,this._contact=this._ua.contact.toString(),a.hasHeader("expires")&&(p=a.getHeader("expires")*1e3),a.to_tag=Fe.newTag(),!this._createDialog(a,"UAS",!0)){a.reply(500,"Missing Contact header field");return}a.body?this._late_sdp=!1:this._late_sdp=!0,this._status=z.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(function(){a.reply(408),s._failed("local",null,oe.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),p&&(this._timers.expiresTimer=setTimeout(function(){s._status===z.STATUS_WAITING_FOR_ANSWER&&(a.reply(487),s._failed("system",null,oe.causes.EXPIRES))},p)),this._direction="incoming",this._local_identity=a.to,this._remote_identity=a.from,t&&t(this),this._newRTCSession("remote",a),this._status!==z.STATUS_TERMINATED&&(a.reply(180,null,["Contact: ".concat(this._contact)]),this._progress("local",null))}},{key:"answer",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};G.debug("answer()");var s=this._request,p=Fe.cloneArray(t.extraHeaders),h=Fe.cloneObject(t.mediaConstraints),d=t.mediaStream||null,g=Fe.cloneObject(t.pcConfig,{iceServers:[]}),v=t.rtcConstraints||null,E=t.rtcAnswerConstraints||null,S=Fe.cloneObject(t.rtcOfferConstraints),C,I=!1,w=!1,F=!1,L=!1;if(this._rtcAnswerConstraints=E,this._rtcOfferConstraints=t.rtcOfferConstraints||null,this._data=t.data||this._data,this._direction!=="incoming")throw new qs.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==z.STATUS_WAITING_FOR_ANSWER)throw new qs.InvalidStateError(this._status);if(this._sessionTimers.enabled&&Fe.isDecimal(t.sessionTimersExpires)&&(t.sessionTimersExpires>=oe.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=t.sessionTimersExpires:this._sessionTimers.defaultExpires=oe.SESSION_EXPIRES),this._status=z.STATUS_ANSWERED,!this._createDialog(s,"UAS")){s.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),p.unshift("Contact: ".concat(this._contact));var ie=s.parseSDP();Array.isArray(ie.media)||(ie.media=[ie.media]);var N=is(ie.media),H;try{for(N.s();!(H=N.n()).done;){var ve=H.value;ve.type==="audio"&&(I=!0,(!ve.direction||ve.direction==="sendrecv")&&(F=!0)),ve.type==="video"&&(w=!0,(!ve.direction||ve.direction==="sendrecv")&&(L=!0))}}catch($){N.e($)}finally{N.f()}if(d&&h.audio===!1){C=d.getAudioTracks();var me=is(C),M;try{for(me.s();!(M=me.n()).done;){var D=M.value;d.removeTrack(D)}}catch($){me.e($)}finally{me.f()}}if(d&&h.video===!1){C=d.getVideoTracks();var j=is(C),V;try{for(j.s();!(V=j.n()).done;){var Y=V.value;d.removeTrack(Y)}}catch($){j.e($)}finally{j.f()}}!d&&h.audio===void 0&&(h.audio=F),!d&&h.video===void 0&&(h.video=L),!d&&!I&&!S.offerToReceiveAudio&&(h.audio=!1),!d&&!w&&!S.offerToReceiveVideo&&(h.video=!1),this._createRTCConnection(g,v),Promise.resolve().then(function(){if(d)return d;if(h.audio||h.video)return a._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(h).catch(function($){throw a._status===z.STATUS_TERMINATED?new Error("terminated"):(s.reply(480),a._failed("local",null,oe.causes.USER_DENIED_MEDIA_ACCESS),G.warn('emit "getusermediafailed" [error:%o]',$),a.emit("getusermediafailed",$),new Error("getUserMedia() failed"))})}).then(function($){if(a._status===z.STATUS_TERMINATED)throw new Error("terminated");a._localMediaStream=$,$&&$.getTracks().forEach(function(X){a._connection.addTrack(X,$)})}).then(function(){if(!a._late_sdp){var $={originator:"remote",type:"offer",sdp:s.body};G.debug('emit "sdp"'),a.emit("sdp",$);var X=new RTCSessionDescription({type:"offer",sdp:$.sdp});return a._connectionPromiseQueue=a._connectionPromiseQueue.then(function(){return a._connection.setRemoteDescription(X)}).catch(function(U){throw s.reply(488),a._failed("system",null,oe.causes.WEBRTC_ERROR),G.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',U),a.emit("peerconnection:setremotedescriptionfailed",U),new Error("peerconnection.setRemoteDescription() failed")}),a._connectionPromiseQueue}}).then(function(){if(a._status===z.STATUS_TERMINATED)throw new Error("terminated");return a._connecting(s),a._late_sdp?a._createLocalDescription("offer",a._rtcOfferConstraints).catch(function(){throw s.reply(500),new Error("_createLocalDescription() failed")}):a._createLocalDescription("answer",E).catch(function(){throw s.reply(500),new Error("_createLocalDescription() failed")})}).then(function($){if(a._status===z.STATUS_TERMINATED)throw new Error("terminated");a._handleSessionTimersInIncomingRequest(s,p),s.reply(200,null,p,$,function(){a._status=z.STATUS_WAITING_FOR_ACK,a._setInvite2xxTimer(s,$),a._setACKTimer(),a._accepted("local")},function(){a._failed("system",null,oe.causes.CONNECTION_ERROR)})}).catch(function($){a._status!==z.STATUS_TERMINATED&&G.warn($)})}},{key:"terminate",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};G.debug("terminate()");var s=t.cause||oe.causes.BYE,p=Fe.cloneArray(t.extraHeaders),h=t.body,d,g=t.status_code,v=t.reason_phrase;if(this._status===z.STATUS_TERMINATED)throw new qs.InvalidStateError(this._status);switch(this._status){case z.STATUS_NULL:case z.STATUS_INVITE_SENT:case z.STATUS_1XX_RECEIVED:if(G.debug("canceling session"),g&&(g<200||g>=700))throw new TypeError("Invalid status_code: ".concat(g));g&&(v=v||oe.REASON_PHRASE[g]||"",d="SIP ;cause=".concat(g,' ;text="').concat(v,'"')),this._status===z.STATUS_NULL||this._status===z.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=d):this._status===z.STATUS_1XX_RECEIVED&&this._request.cancel(d),this._status=z.STATUS_CANCELED,this._failed("local",null,oe.causes.CANCELED);break;case z.STATUS_WAITING_FOR_ANSWER:case z.STATUS_ANSWERED:if(G.debug("rejecting session"),g=g||480,g<300||g>=700)throw new TypeError("Invalid status_code: ".concat(g));this._request.reply(g,v,p,h),this._failed("local",null,oe.causes.REJECTED);break;case z.STATUS_WAITING_FOR_ACK:case z.STATUS_CONFIRMED:if(G.debug("terminating session"),v=t.reason_phrase||oe.REASON_PHRASE[g]||"",g&&(g<200||g>=700))throw new TypeError("Invalid status_code: ".concat(g));if(g&&p.push("Reason: SIP ;cause=".concat(g,'; text="').concat(v,'"')),this._status===z.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==Ec.C.STATUS_TERMINATED){var E=this._dialog;this.receiveRequest=function(S){var C=S.method;C===oe.ACK&&(a.sendRequest(oe.BYE,{extraHeaders:p,body:h}),E.terminate())},this._request.server_transaction.on("stateChanged",function(){a._request.server_transaction.state===Ec.C.STATUS_TERMINATED&&(a.sendRequest(oe.BYE,{extraHeaders:p,body:h}),E.terminate())}),this._ended("local",null,s),this._dialog=E,this._ua.newDialog(E)}else this.sendRequest(oe.BYE,{extraHeaders:p,body:h}),this._ended("local",null,s)}}},{key:"sendDTMF",value:function(a){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};G.debug("sendDTMF() | tones: %s",a);var s=0,p=t.duration||null,h=t.interToneGap||null,d=t.transportType||oe.DTMF_TRANSPORT.INFO;if(a===void 0)throw new TypeError("Not enough arguments");if(this._status!==z.STATUS_CONFIRMED&&this._status!==z.STATUS_WAITING_FOR_ACK&&this._status!==z.STATUS_1XX_RECEIVED)throw new qs.InvalidStateError(this._status);if(d!==oe.DTMF_TRANSPORT.INFO&&d!==oe.DTMF_TRANSPORT.RFC2833)throw new TypeError("invalid transportType: ".concat(d));if(typeof a=="number"&&(a=a.toString()),!a||typeof a!="string"||!a.match(/^[0-9A-DR#*,]+$/i))throw new TypeError("Invalid tones: ".concat(a));if(p&&!Fe.isDecimal(p))throw new TypeError("Invalid tone duration: ".concat(p));if(p?p<bt.C.MIN_DURATION?(G.debug('"duration" value is lower than the minimum allowed, setting it to '.concat(bt.C.MIN_DURATION," milliseconds")),p=bt.C.MIN_DURATION):p>bt.C.MAX_DURATION?(G.debug('"duration" value is greater than the maximum allowed, setting it to '.concat(bt.C.MAX_DURATION," milliseconds")),p=bt.C.MAX_DURATION):p=Math.abs(p):p=bt.C.DEFAULT_DURATION,t.duration=p,h&&!Fe.isDecimal(h))throw new TypeError("Invalid interToneGap: ".concat(h));if(h?h<bt.C.MIN_INTER_TONE_GAP?(G.debug('"interToneGap" value is lower than the minimum allowed, setting it to '.concat(bt.C.MIN_INTER_TONE_GAP," milliseconds")),h=bt.C.MIN_INTER_TONE_GAP):h=Math.abs(h):h=bt.C.DEFAULT_INTER_TONE_GAP,d===oe.DTMF_TRANSPORT.RFC2833){var g=this._getDTMFRTPSender();g&&(a=g.toneBuffer+a,g.insertDTMF(a,p,h));return}if(this._tones){this._tones+=a;return}this._tones=a,v.call(this);function v(){var E=this,S;if(this._status===z.STATUS_TERMINATED||!this._tones||s>=this._tones.length){this._tones=null;return}var C=this._tones[s];if(s+=1,C===",")S=2e3;else{var I=new bt(this);t.eventHandlers={onFailed:function(){E._tones=null}},I.send(C,t),S=p+h}setTimeout(v.bind(this),S)}}},{key:"sendInfo",value:function(a,t){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(G.debug("sendInfo()"),this._status!==z.STATUS_CONFIRMED&&this._status!==z.STATUS_WAITING_FOR_ACK&&this._status!==z.STATUS_1XX_RECEIVED)throw new qs.InvalidStateError(this._status);var p=new yc(this);p.send(a,t,s)}},{key:"mute",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{audio:!0,video:!1};G.debug("mute()");var t=!1,s=!1;this._audioMuted===!1&&a.audio&&(t=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&a.video&&(s=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(t===!0||s===!0)&&this._onmute({audio:t,video:s})}},{key:"unmute",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{audio:!0,video:!0};G.debug("unmute()");var t=!1,s=!1;this._audioMuted===!0&&a.audio&&(t=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&a.video&&(s=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(t===!0||s===!0)&&this._onunmute({audio:t,video:s})}},{key:"hold",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;if(G.debug("hold()"),this._status!==z.STATUS_WAITING_FOR_ACK&&this._status!==z.STATUS_CONFIRMED||this._localHold===!0||!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");var p={succeeded:function(){s&&s()},failed:function(){a.terminate({cause:oe.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:p,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:p,extraHeaders:t.extraHeaders}),!0}},{key:"unhold",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;if(G.debug("unhold()"),this._status!==z.STATUS_WAITING_FOR_ACK&&this._status!==z.STATUS_CONFIRMED||this._localHold===!1||!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");var p={succeeded:function(){s&&s()},failed:function(){a.terminate({cause:oe.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:p,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:p,extraHeaders:t.extraHeaders}),!0}},{key:"renegotiate",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;G.debug("renegotiate()");var p=t.rtcOfferConstraints||null;if(this._status!==z.STATUS_WAITING_FOR_ACK&&this._status!==z.STATUS_CONFIRMED||!this._isReadyToReOffer())return!1;var h={succeeded:function(){s&&s()},failed:function(){a.terminate({cause:oe.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),t.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:h,rtcOfferConstraints:p,extraHeaders:t.extraHeaders}):this._sendReinvite({eventHandlers:h,rtcOfferConstraints:p,extraHeaders:t.extraHeaders}),!0}},{key:"refer",value:function(a,t){var s=this;G.debug("refer()");var p=a;if(this._status!==z.STATUS_WAITING_FOR_ACK&&this._status!==z.STATUS_CONFIRMED)return!1;if(a=this._ua.normalizeTarget(a),!a)throw new TypeError("Invalid target: ".concat(p));var h=new hd(this);h.sendRefer(a,t);var d=h.id;return this._referSubscribers[d]=h,h.on("requestFailed",function(){delete s._referSubscribers[d]}),h.on("accepted",function(){delete s._referSubscribers[d]}),h.on("failed",function(){delete s._referSubscribers[d]}),h}},{key:"sendRequest",value:function(a,t){return G.debug("sendRequest()"),this._dialog.sendRequest(a,t)}},{key:"receiveRequest",value:function(a){var t=this;if(G.debug("receiveRequest()"),a.method===oe.CANCEL)(this._status===z.STATUS_WAITING_FOR_ANSWER||this._status===z.STATUS_ANSWERED)&&(this._status=z.STATUS_CANCELED,this._request.reply(487),this._failed("remote",a,oe.causes.CANCELED));else switch(a.method){case oe.ACK:if(this._status!==z.STATUS_WAITING_FOR_ACK)return;if(this._status=z.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!a.body){this.terminate({cause:oe.causes.MISSING_SDP,status_code:400});break}var s={originator:"remote",type:"answer",sdp:a.body};G.debug('emit "sdp"'),this.emit("sdp",s);var p=new RTCSessionDescription({type:"answer",sdp:s.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._connection.setRemoteDescription(p)}).then(function(){t._is_confirmed||t._confirmed("remote",a)}).catch(function(d){t.terminate({cause:oe.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),G.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',d),t.emit("peerconnection:setremotedescriptionfailed",d)})}else this._is_confirmed||this._confirmed("remote",a);break;case oe.BYE:this._status===z.STATUS_CONFIRMED||this._status===z.STATUS_WAITING_FOR_ACK?(a.reply(200),this._ended("remote",a,oe.causes.BYE)):this._status===z.STATUS_INVITE_RECEIVED||this._status===z.STATUS_WAITING_FOR_ANSWER?(a.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",a,oe.causes.BYE)):a.reply(403,"Wrong Status");break;case oe.INVITE:this._status===z.STATUS_CONFIRMED?a.hasHeader("replaces")?this._receiveReplaces(a):this._receiveReinvite(a):a.reply(403,"Wrong Status");break;case oe.INFO:if(this._status===z.STATUS_1XX_RECEIVED||this._status===z.STATUS_WAITING_FOR_ANSWER||this._status===z.STATUS_ANSWERED||this._status===z.STATUS_WAITING_FOR_ACK||this._status===z.STATUS_CONFIRMED){var h=a.hasHeader("Content-Type")?a.getHeader("Content-Type").toLowerCase():void 0;h&&h.match(/^application\/dtmf-relay/i)?new bt(this).init_incoming(a):h!==void 0?new yc(this).init_incoming(a):a.reply(415)}else a.reply(403,"Wrong Status");break;case oe.UPDATE:this._status===z.STATUS_CONFIRMED?this._receiveUpdate(a):a.reply(403,"Wrong Status");break;case oe.REFER:this._status===z.STATUS_CONFIRMED?this._receiveRefer(a):a.reply(403,"Wrong Status");break;case oe.NOTIFY:this._status===z.STATUS_CONFIRMED?this._receiveNotify(a):a.reply(403,"Wrong Status");break;default:a.reply(501)}}},{key:"onTransportError",value:function(){G.warn("onTransportError()"),this._status!==z.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:oe.causes.CONNECTION_ERROR,cause:oe.causes.CONNECTION_ERROR})}},{key:"onRequestTimeout",value:function(){G.warn("onRequestTimeout()"),this._status!==z.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:oe.causes.REQUEST_TIMEOUT,cause:oe.causes.REQUEST_TIMEOUT})}},{key:"onDialogError",value:function(){G.warn("onDialogError()"),this._status!==z.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:oe.causes.DIALOG_ERROR,cause:oe.causes.DIALOG_ERROR})}},{key:"newDTMF",value:function(a){G.debug("newDTMF()"),this.emit("newDTMF",a)}},{key:"newInfo",value:function(a){G.debug("newInfo()"),this.emit("newInfo",a)}},{key:"_isReadyToReOffer",value:function(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(G.debug("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(G.debug("_isReadyToReOffer() | session not established yet"),!1):(G.debug("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}},{key:"_close",value:function(){if(G.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(G.debug("close() | closing local MediaStream"),Fe.closeMediaStream(this._localMediaStream)),this._status!==z.STATUS_TERMINATED){if(this._status=z.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(p){G.warn("close() | error closing the RTCPeerConnection: %o",p)}for(var a in this._timers)Object.prototype.hasOwnProperty.call(this._timers,a)&&clearTimeout(this._timers[a]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(var t in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,t)&&(this._earlyDialogs[t].terminate(),delete this._earlyDialogs[t]);for(var s in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,s)&&delete this._referSubscribers[s];this._ua.destroyRTCSession(this)}}},{key:"_setInvite2xxTimer",value:function(a,t){var s=Ar.T1;function p(){this._status===z.STATUS_WAITING_FOR_ACK&&(a.reply(200,null,["Contact: ".concat(this._contact)],t),s<Ar.T2&&(s=s*2,s>Ar.T2&&(s=Ar.T2)),this._timers.invite2xxTimer=setTimeout(p.bind(this),s))}this._timers.invite2xxTimer=setTimeout(p.bind(this),s)}},{key:"_setACKTimer",value:function(){var a=this;this._timers.ackTimer=setTimeout(function(){a._status===z.STATUS_WAITING_FOR_ACK&&(G.debug("no ACK received, terminating the session"),clearTimeout(a._timers.invite2xxTimer),a.sendRequest(oe.BYE),a._ended("remote",null,oe.causes.NO_ACK))},Ar.TIMER_H)}},{key:"_createRTCConnection",value:function(a,t){var s=this;this._connection=new RTCPeerConnection(a,t),this._connection.addEventListener("iceconnectionstatechange",function(){var p=s._connection.iceConnectionState;p==="failed"&&s.terminate({cause:oe.causes.RTP_TIMEOUT,status_code:408,reason_phrase:oe.causes.RTP_TIMEOUT})}),G.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}},{key:"_createLocalDescription",value:function(a,t){var s=this;if(G.debug("createLocalDescription()"),a!=="offer"&&a!=="answer")throw new Error('createLocalDescription() | invalid type "'.concat(a,'"'));var p=this._connection;return this._rtcReady=!1,Promise.resolve().then(function(){return a==="offer"?p.createOffer(t).catch(function(h){return G.warn('emit "peerconnection:createofferfailed" [error:%o]',h),s.emit("peerconnection:createofferfailed",h),Promise.reject(h)}):p.createAnswer(t).catch(function(h){return G.warn('emit "peerconnection:createanswerfailed" [error:%o]',h),s.emit("peerconnection:createanswerfailed",h),Promise.reject(h)})}).then(function(h){return p.setLocalDescription(h).catch(function(d){return s._rtcReady=!0,G.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',d),s.emit("peerconnection:setlocaldescriptionfailed",d),Promise.reject(d)})}).then(function(){var h=t&&t.iceRestart;if(p.iceGatheringState==="complete"&&!h||p.iceGatheringState==="gathering"&&s._iceReady){s._rtcReady=!0;var d={originator:"local",type:a,sdp:p.localDescription.sdp};return G.debug('emit "sdp"'),s.emit("sdp",d),Promise.resolve(d.sdp)}return new Promise(function(g){var v=!1,E,S;s._iceReady=!1;var C=function(){p.removeEventListener("icecandidate",E),p.removeEventListener("icegatheringstatechange",S),v=!0,s._rtcReady=!0,s._iceReady=!0;var w={originator:"local",type:a,sdp:p.localDescription.sdp};G.debug('emit "sdp"'),s.emit("sdp",w),g(w.sdp)};p.addEventListener("icecandidate",E=function(w){var F=w.candidate;F?s.emit("icecandidate",{candidate:F,ready:C}):v||C()}),p.addEventListener("icegatheringstatechange",S=function(){p.iceGatheringState==="complete"&&!v&&C()})})})}},{key:"_createDialog",value:function(a,t,s){var p=t==="UAS"?a.to_tag:a.from_tag,h=t==="UAS"?a.from_tag:a.to_tag,d=a.call_id+p+h,g=this._earlyDialogs[d];if(s)return g?!0:(g=new bl(this,a,t,bl.C.STATUS_EARLY),g.error?(G.debug(g.error),this._failed("remote",a,oe.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[d]=g,!0));if(this._from_tag=a.from_tag,this._to_tag=a.to_tag,g)return g.update(a,t),this._dialog=g,delete this._earlyDialogs[d],!0;var v=new bl(this,a,t);return v.error?(G.debug(v.error),this._failed("remote",a,oe.causes.INTERNAL_ERROR),!1):(this._dialog=v,!0)}},{key:"_receiveReinvite",value:function(a){var t=this;G.debug("receiveReinvite()");var s=a.hasHeader("Content-Type")?a.getHeader("Content-Type").toLowerCase():void 0,p={request:a,callback:void 0,reject:d.bind(this)},h=!1;function d(){var v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};h=!0;var E=v.status_code||403,S=v.reason_phrase||"",C=Fe.cloneArray(v.extraHeaders);if(this._status!==z.STATUS_CONFIRMED)return!1;if(E<300||E>=700)throw new TypeError("Invalid status_code: ".concat(E));a.reply(E,S,C)}if(this.emit("reinvite",p),h)return;if(this._late_sdp=!1,!a.body){this._late_sdp=!0,this._remoteHold&&(this._remoteHold=!1,this._onunhold("remote")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._createLocalDescription("offer",t._rtcOfferConstraints)}).then(function(v){g.call(t,v)}).catch(function(){a.reply(500)});return}if(s!=="application/sdp"){G.debug("invalid Content-Type"),a.reply(415);return}this._processInDialogSdpOffer(a).then(function(v){t._status!==z.STATUS_TERMINATED&&g.call(t,v)}).catch(function(v){G.warn(v)});function g(v){var E=this,S=["Contact: ".concat(this._contact)];this._handleSessionTimersInIncomingRequest(a,S),this._late_sdp&&(v=this._mangleOffer(v)),a.reply(200,null,S,v,function(){E._status=z.STATUS_WAITING_FOR_ACK,E._setInvite2xxTimer(a,v),E._setACKTimer()}),typeof p.callback=="function"&&p.callback()}}},{key:"_receiveUpdate",value:function(a){var t=this;G.debug("receiveUpdate()");var s=a.hasHeader("Content-Type")?a.getHeader("Content-Type").toLowerCase():void 0,p={request:a,callback:void 0,reject:d.bind(this)},h=!1;function d(){var v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};h=!0;var E=v.status_code||403,S=v.reason_phrase||"",C=Fe.cloneArray(v.extraHeaders);if(this._status!==z.STATUS_CONFIRMED)return!1;if(E<300||E>=700)throw new TypeError("Invalid status_code: ".concat(E));a.reply(E,S,C)}if(this.emit("update",p),h)return;if(!a.body){g.call(this,null);return}if(s!=="application/sdp"){G.debug("invalid Content-Type"),a.reply(415);return}this._processInDialogSdpOffer(a).then(function(v){t._status!==z.STATUS_TERMINATED&&g.call(t,v)}).catch(function(v){G.warn(v)});function g(v){var E=["Contact: ".concat(this._contact)];this._handleSessionTimersInIncomingRequest(a,E),a.reply(200,null,E,v),typeof p.callback=="function"&&p.callback()}}},{key:"_processInDialogSdpOffer",value:function(a){var t=this;G.debug("_processInDialogSdpOffer()");var s=a.parseSDP(),p=!1,h=is(s.media),d;try{for(h.s();!(d=h.n()).done;){var g=d.value;if(wl.indexOf(g.type)!==-1){var v=g.direction||s.direction||"sendrecv";if(v==="sendonly"||v==="inactive")p=!0;else{p=!1;break}}}}catch(C){h.e(C)}finally{h.f()}var E={originator:"remote",type:"offer",sdp:a.body};G.debug('emit "sdp"'),this.emit("sdp",E);var S=new RTCSessionDescription({type:"offer",sdp:E.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){if(t._status===z.STATUS_TERMINATED)throw new Error("terminated");return t._connection.setRemoteDescription(S).catch(function(C){throw a.reply(488),G.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',C),t.emit("peerconnection:setremotedescriptionfailed",C),C})}).then(function(){if(t._status===z.STATUS_TERMINATED)throw new Error("terminated");t._remoteHold===!0&&p===!1?(t._remoteHold=!1,t._onunhold("remote")):t._remoteHold===!1&&p===!0&&(t._remoteHold=!0,t._onhold("remote"))}).then(function(){if(t._status===z.STATUS_TERMINATED)throw new Error("terminated");return t._createLocalDescription("answer",t._rtcAnswerConstraints).catch(function(C){throw a.reply(500),G.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',C),C})}).catch(function(C){G.warn("_processInDialogSdpOffer() failed [error: %o]",C)}),this._connectionPromiseQueue}},{key:"_receiveRefer",value:function(a){var t=this;if(G.debug("receiveRefer()"),!a.refer_to){G.debug("no Refer-To header field present in REFER"),a.reply(400);return}if(a.refer_to.uri.scheme!==oe.SIP){G.debug("Refer-To header field points to a non-SIP URI scheme"),a.reply(416);return}a.reply(202);var s=new fd(this,a.cseq);G.debug('emit "refer"'),this.emit("refer",{request:a,accept:function(g,v){p.call(t,g,v)},reject:function(){h.call(t)}});function p(d){var g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(d=typeof d=="function"?d:null,this._status!==z.STATUS_WAITING_FOR_ACK&&this._status!==z.STATUS_CONFIRMED)return!1;var v=new n(this._ua);if(v.on("progress",function(S){var C=S.response;s.notify(C.status_code,C.reason_phrase)}),v.on("accepted",function(S){var C=S.response;s.notify(C.status_code,C.reason_phrase)}),v.on("_failed",function(S){var C=S.message,I=S.cause;C?s.notify(C.status_code,C.reason_phrase):s.notify(487,I)}),a.refer_to.uri.hasHeader("replaces")){var E=decodeURIComponent(a.refer_to.uri.getHeader("replaces"));g.extraHeaders=Fe.cloneArray(g.extraHeaders),g.extraHeaders.push("Replaces: ".concat(E))}v.connect(a.refer_to.uri.toAor(),g,d)}function h(){s.notify(603)}}},{key:"_receiveNotify",value:function(a){switch(G.debug("receiveNotify()"),a.event||a.reply(400),a.event.event){case"refer":{var t,s;if(a.event.params&&a.event.params.id)t=a.event.params.id,s=this._referSubscribers[t];else if(Object.keys(this._referSubscribers).length===1)s=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{a.reply(400,"Missing event id parameter");return}if(!s){a.reply(481,"Subscription does not exist");return}s.receiveNotify(a),a.reply(200);break}default:a.reply(489)}}},{key:"_receiveReplaces",value:function(a){var t=this;G.debug("receiveReplaces()");function s(h){var d=this;if(this._status!==z.STATUS_WAITING_FOR_ACK&&this._status!==z.STATUS_CONFIRMED)return!1;var g=new n(this._ua);g.on("confirmed",function(){d.terminate()}),g.init_incoming(a,h)}function p(){G.debug("Replaced INVITE rejected by the user"),a.reply(486)}this.emit("replaces",{request:a,accept:function(d){s.call(t,d)},reject:function(){p.call(t)}})}},{key:"_sendInitialRequest",value:function(a,t,s){var p=this,h=new cd(this._ua,this._request,{onRequestTimeout:function(){p.onRequestTimeout()},onTransportError:function(){p.onTransportError()},onAuthenticated:function(g){p._request=g},onReceiveResponse:function(g){p._receiveInviteResponse(g)}});Promise.resolve().then(function(){if(s)return s;if(a.audio||a.video)return p._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(a).catch(function(d){throw p._status===z.STATUS_TERMINATED?new Error("terminated"):(p._failed("local",null,oe.causes.USER_DENIED_MEDIA_ACCESS),G.warn('emit "getusermediafailed" [error:%o]',d),p.emit("getusermediafailed",d),d)})}).then(function(d){if(p._status===z.STATUS_TERMINATED)throw new Error("terminated");return p._localMediaStream=d,d&&d.getTracks().forEach(function(g){p._connection.addTrack(g,d)}),p._connecting(p._request),p._createLocalDescription("offer",t).catch(function(g){throw p._failed("local",null,oe.causes.WEBRTC_ERROR),g})}).then(function(d){if(p._is_canceled||p._status===z.STATUS_TERMINATED)throw new Error("terminated");p._request.body=d,p._status=z.STATUS_INVITE_SENT,G.debug('emit "sending" [request:%o]',p._request),p.emit("sending",{request:p._request}),h.send()}).catch(function(d){p._status!==z.STATUS_TERMINATED&&G.warn(d)})}},{key:"_getDTMFRTPSender",value:function(){var a=this._connection.getSenders().find(function(t){return t.track&&t.track.kind==="audio"});if(!(a&&a.dtmf)){G.warn("sendDTMF() | no local audio track to send DTMF with");return}return a.dtmf}},{key:"_receiveInviteResponse",value:function(a){var t=this;if(G.debug("receiveInviteResponse()"),this._dialog&&a.status_code>=200&&a.status_code<=299)if(this._dialog.id.call_id===a.call_id&&this._dialog.id.local_tag===a.from_tag&&this._dialog.id.remote_tag===a.to_tag){this.sendRequest(oe.ACK);return}else{var s=new bl(this,a,"UAC");if(s.error!==void 0){G.debug(s.error);return}this.sendRequest(oe.ACK),this.sendRequest(oe.BYE);return}if(this._is_canceled){a.status_code>=100&&a.status_code<200?this._request.cancel(this._cancel_reason):a.status_code>=200&&a.status_code<299&&this._acceptAndTerminate(a);return}if(!(this._status!==z.STATUS_INVITE_SENT&&this._status!==z.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(a.status_code):this._status=z.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(a.status_code):{if(!a.to_tag){G.debug("1xx response received without to tag");break}if(a.hasHeader("contact")&&!this._createDialog(a,"UAC",!0))break;if(this._status=z.STATUS_1XX_RECEIVED,!a.body){this._progress("remote",a);break}var p={originator:"remote",type:"answer",sdp:a.body};G.debug('emit "sdp"'),this.emit("sdp",p);var h=new RTCSessionDescription({type:"answer",sdp:p.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return t._connection.setRemoteDescription(h)}).then(function(){return t._progress("remote",a)}).catch(function(E){G.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',E),t.emit("peerconnection:setremotedescriptionfailed",E)});break}case/^2[0-9]{2}$/.test(a.status_code):{if(this._status=z.STATUS_CONFIRMED,!a.body){this._acceptAndTerminate(a,400,oe.causes.MISSING_SDP),this._failed("remote",a,oe.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(a,"UAC"))break;var d={originator:"remote",type:"answer",sdp:a.body};G.debug('emit "sdp"'),this.emit("sdp",d);var g=new RTCSessionDescription({type:"answer",sdp:d.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){if(t._connection.signalingState==="stable")return t._connection.createOffer(t._rtcOfferConstraints).then(function(E){return t._connection.setLocalDescription(E)}).catch(function(E){t._acceptAndTerminate(a,500,E.toString()),t._failed("local",a,oe.causes.WEBRTC_ERROR)})}).then(function(){t._connection.setRemoteDescription(g).then(function(){t._handleSessionTimersInIncomingResponse(a),t._accepted("remote",a),t.sendRequest(oe.ACK),t._confirmed("local",null)}).catch(function(E){t._acceptAndTerminate(a,488,"Not Acceptable Here"),t._failed("remote",a,oe.causes.BAD_MEDIA_DESCRIPTION),G.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',E),t.emit("peerconnection:setremotedescriptionfailed",E)})});break}default:{var v=Fe.sipErrorCause(a.status_code);this._failed("remote",a,v)}}}},{key:"_sendReinvite",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};G.debug("sendReinvite()");var s=Fe.cloneArray(t.extraHeaders),p=Fe.cloneObject(t.eventHandlers),h=t.rtcOfferConstraints||this._rtcOfferConstraints||null,d=!1;s.push("Contact: ".concat(this._contact)),s.push("Content-Type: application/sdp"),this._sessionTimers.running&&s.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(this._sessionTimers.refresher?"uac":"uas")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return a._createLocalDescription("offer",h)}).then(function(E){E=a._mangleOffer(E);var S={originator:"local",type:"offer",sdp:E};G.debug('emit "sdp"'),a.emit("sdp",S),a.sendRequest(oe.INVITE,{extraHeaders:s,body:E,eventHandlers:{onSuccessResponse:function(I){g.call(a,I),d=!0},onErrorResponse:function(I){v.call(a,I)},onTransportError:function(){a.onTransportError()},onRequestTimeout:function(){a.onRequestTimeout()},onDialogError:function(){a.onDialogError()}}})}).catch(function(){v()});function g(E){var S=this;if(this._status!==z.STATUS_TERMINATED&&(this.sendRequest(oe.ACK),!d)){if(this._handleSessionTimersInIncomingResponse(E),E.body){if(!E.hasHeader("Content-Type")||E.getHeader("Content-Type").toLowerCase()!=="application/sdp"){v.call(this);return}}else{v.call(this);return}var C={originator:"remote",type:"answer",sdp:E.body};G.debug('emit "sdp"'),this.emit("sdp",C);var I=new RTCSessionDescription({type:"answer",sdp:C.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return S._connection.setRemoteDescription(I)}).then(function(){p.succeeded&&p.succeeded(E)}).catch(function(w){v.call(S),G.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',w),S.emit("peerconnection:setremotedescriptionfailed",w)})}}function v(E){p.failed&&p.failed(E)}}},{key:"_sendUpdate",value:function(){var a=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};G.debug("sendUpdate()");var s=Fe.cloneArray(t.extraHeaders),p=Fe.cloneObject(t.eventHandlers),h=t.rtcOfferConstraints||this._rtcOfferConstraints||null,d=t.sdpOffer||!1,g=!1;s.push("Contact: ".concat(this._contact)),this._sessionTimers.running&&s.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(this._sessionTimers.refresher?"uac":"uas")),d?(s.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return a._createLocalDescription("offer",h)}).then(function(S){S=a._mangleOffer(S);var C={originator:"local",type:"offer",sdp:S};G.debug('emit "sdp"'),a.emit("sdp",C),a.sendRequest(oe.UPDATE,{extraHeaders:s,body:S,eventHandlers:{onSuccessResponse:function(w){v.call(a,w),g=!0},onErrorResponse:function(w){E.call(a,w)},onTransportError:function(){a.onTransportError()},onRequestTimeout:function(){a.onRequestTimeout()},onDialogError:function(){a.onDialogError()}}})}).catch(function(){E.call(a)})):this.sendRequest(oe.UPDATE,{extraHeaders:s,eventHandlers:{onSuccessResponse:function(C){v.call(a,C)},onErrorResponse:function(C){E.call(a,C)},onTransportError:function(){a.onTransportError()},onRequestTimeout:function(){a.onRequestTimeout()},onDialogError:function(){a.onDialogError()}}});function v(S){var C=this;if(this._status!==z.STATUS_TERMINATED&&!g)if(this._handleSessionTimersInIncomingResponse(S),d){if(S.body){if(!S.hasHeader("Content-Type")||S.getHeader("Content-Type").toLowerCase()!=="application/sdp"){E.call(this);return}}else{E.call(this);return}var I={originator:"remote",type:"answer",sdp:S.body};G.debug('emit "sdp"'),this.emit("sdp",I);var w=new RTCSessionDescription({type:"answer",sdp:I.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(function(){return C._connection.setRemoteDescription(w)}).then(function(){p.succeeded&&p.succeeded(S)}).catch(function(F){E.call(C),G.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',F),C.emit("peerconnection:setremotedescriptionfailed",F)})}else p.succeeded&&p.succeeded(S)}function E(S){p.failed&&p.failed(S)}}},{key:"_acceptAndTerminate",value:function(a,t,s){G.debug("acceptAndTerminate()");var p=[];t&&(s=s||oe.REASON_PHRASE[t]||"",p.push("Reason: SIP ;cause=".concat(t,'; text="').concat(s,'"'))),(this._dialog||this._createDialog(a,"UAC"))&&(this.sendRequest(oe.ACK),this.sendRequest(oe.BYE,{extraHeaders:p})),this._status=z.STATUS_TERMINATED}},{key:"_mangleOffer",value:function(a){if(!this._localHold&&!this._remoteHold)return a;if(a=Tc.parse(a),this._localHold&&!this._remoteHold){G.debug("mangleOffer() | me on hold, mangling offer");var t=is(a.media),s;try{for(t.s();!(s=t.n()).done;){var p=s.value;wl.indexOf(p.type)!==-1&&(p.direction?p.direction==="sendrecv"?p.direction="sendonly":p.direction==="recvonly"&&(p.direction="inactive"):p.direction="sendonly")}}catch(C){t.e(C)}finally{t.f()}}else if(this._localHold&&this._remoteHold){G.debug("mangleOffer() | both on hold, mangling offer");var h=is(a.media),d;try{for(h.s();!(d=h.n()).done;){var g=d.value;wl.indexOf(g.type)!==-1&&(g.direction="inactive")}}catch(C){h.e(C)}finally{h.f()}}else if(this._remoteHold){G.debug("mangleOffer() | remote on hold, mangling offer");var v=is(a.media),E;try{for(v.s();!(E=v.n()).done;){var S=E.value;wl.indexOf(S.type)!==-1&&(S.direction?S.direction==="sendrecv"?S.direction="recvonly":S.direction==="recvonly"&&(S.direction="inactive"):S.direction="recvonly")}}catch(C){v.e(C)}finally{v.f()}}return Tc.write(a)}},{key:"_setLocalMediaStatus",value:function(){var a=!0,t=!0;(this._localHold||this._remoteHold)&&(a=!1,t=!1),this._audioMuted&&(a=!1),this._videoMuted&&(t=!1),this._toggleMuteAudio(!a),this._toggleMuteVideo(!t)}},{key:"_handleSessionTimersInIncomingRequest",value:function(a,t){if(this._sessionTimers.enabled){var s;a.session_expires&&a.session_expires>=oe.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=a.session_expires,s=a.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,s="uas"),t.push("Session-Expires: ".concat(this._sessionTimers.currentExpires,";refresher=").concat(s)),this._sessionTimers.refresher=s==="uas",this._runSessionTimer()}}},{key:"_handleSessionTimersInIncomingResponse",value:function(a){if(this._sessionTimers.enabled){var t;a.session_expires&&a.session_expires>=oe.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=a.session_expires,t=a.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,t="uac"),this._sessionTimers.refresher=t==="uac",this._runSessionTimer()}}},{key:"_runSessionTimer",value:function(){var a=this,t=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(function(){a._status!==z.STATUS_TERMINATED&&a._isReadyToReOffer()&&(G.debug("runSessionTimer() | sending session refresh request"),a._sessionTimers.refreshMethod===oe.UPDATE?a._sendUpdate():a._sendReinvite())},t*500):this._sessionTimers.timer=setTimeout(function(){a._status!==z.STATUS_TERMINATED&&(G.warn("runSessionTimer() | timer expired, terminating the session"),a.terminate({cause:oe.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},t*1100)}},{key:"_toggleMuteAudio",value:function(a){var t=this._connection.getSenders().filter(function(d){return d.track&&d.track.kind==="audio"}),s=is(t),p;try{for(s.s();!(p=s.n()).done;){var h=p.value;h.track.enabled=!a}}catch(d){s.e(d)}finally{s.f()}}},{key:"_toggleMuteVideo",value:function(a){var t=this._connection.getSenders().filter(function(d){return d.track&&d.track.kind==="video"}),s=is(t),p;try{for(s.s();!(p=s.n()).done;){var h=p.value;h.track.enabled=!a}}catch(d){s.e(d)}finally{s.f()}}},{key:"_newRTCSession",value:function(a,t){G.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:a,session:this,request:t})}},{key:"_connecting",value:function(a){G.debug("session connecting"),G.debug('emit "connecting"'),this.emit("connecting",{request:a})}},{key:"_progress",value:function(a,t){G.debug("session progress"),G.debug('emit "progress"'),this.emit("progress",{originator:a,response:t||null})}},{key:"_accepted",value:function(a,t){G.debug("session accepted"),this._start_time=new Date,G.debug('emit "accepted"'),this.emit("accepted",{originator:a,response:t||null})}},{key:"_confirmed",value:function(a,t){G.debug("session confirmed"),this._is_confirmed=!0,G.debug('emit "confirmed"'),this.emit("confirmed",{originator:a,ack:t||null})}},{key:"_ended",value:function(a,t,s){G.debug("session ended"),this._end_time=new Date,this._close(),G.debug('emit "ended"'),this.emit("ended",{originator:a,message:t||null,cause:s})}},{key:"_failed",value:function(a,t,s){G.debug("session failed"),G.debug('emit "_failed"'),this.emit("_failed",{originator:a,message:t||null,cause:s}),this._close(),G.debug('emit "failed"'),this.emit("failed",{originator:a,message:t||null,cause:s})}},{key:"_onhold",value:function(a){G.debug("session onhold"),this._setLocalMediaStatus(),G.debug('emit "hold"'),this.emit("hold",{originator:a})}},{key:"_onunhold",value:function(a){G.debug("session onunhold"),this._setLocalMediaStatus(),G.debug('emit "unhold"'),this.emit("unhold",{originator:a})}},{key:"_onmute",value:function(a){var t=a.audio,s=a.video;G.debug("session onmute"),this._setLocalMediaStatus(),G.debug('emit "muted"'),this.emit("muted",{audio:t,video:s})}},{key:"_onunmute",value:function(a){var t=a.audio,s=a.video;G.debug("session onunmute"),this._setLocalMediaStatus(),G.debug('emit "unmuted"'),this.emit("unmuted",{audio:t,video:s})}},{key:"C",get:function(){return z}},{key:"causes",get:function(){return oe.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(a){this._data=a}},{key:"status",get:function(){return this._status}}]),n}(od);function Ol(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Ol=function(n){return typeof n}:Ol=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Ol(c)}function dd(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Cc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function pd(c,r,n){return r&&Cc(c.prototype,r),n&&Cc(c,n),c}function md(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&Zo(c,r)}function Zo(c,r){return Zo=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},Zo(c,r)}function gd(c){var r=Ed();return function(){var o=Dl(c),a;if(r){var t=Dl(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return vd(this,a)}}function vd(c,r){return r&&(Ol(r)==="object"||typeof r=="function")?r:Td(c)}function Td(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Ed(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Dl(c){return Dl=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},Dl(c)}var yd=ot.EventEmitter,Sd=rt,ea=Xe,Cd=ss,Rr=Tt(),Ad=Er,Ac=ms,Rd=gs(),Nl=new Sd("Message"),Id=function(c){md(n,c);var r=gd(n);function n(o){var a;return dd(this,n),a=r.call(this),a._ua=o,a._request=null,a._closed=!1,a._direction=null,a._local_identity=null,a._remote_identity=null,a._is_replied=!1,a._data={},a}return pd(n,[{key:"send",value:function(a,t){var s=this,p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},h=a;if(a===void 0||t===void 0)throw new TypeError("Not enough arguments");if(a=this._ua.normalizeTarget(a),!a)throw new TypeError("Invalid target: ".concat(h));var d=Rr.cloneArray(p.extraHeaders),g=Rr.cloneObject(p.eventHandlers),v=p.contentType||"text/plain",E={};p.fromUserName&&(E.from_uri=new Rd("sip",p.fromUserName,this._ua.configuration.uri.host),d.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString()))),p.fromDisplayName&&(E.from_display_name=p.fromDisplayName);for(var S in g)Object.prototype.hasOwnProperty.call(g,S)&&this.on(S,g[S]);d.push("Content-Type: ".concat(v)),this._request=new Cd.OutgoingRequest(ea.MESSAGE,a,this._ua,E,d),t&&(this._request.body=t);var C=new Ad(this._ua,this._request,{onRequestTimeout:function(){s._onRequestTimeout()},onTransportError:function(){s._onTransportError()},onReceiveResponse:function(w){s._receiveResponse(w)}});this._newMessage("local",this._request),C.send()}},{key:"init_incoming",value:function(a){this._request=a,this._newMessage("remote",a),this._is_replied||(this._is_replied=!0,a.reply(200)),this._close()}},{key:"accept",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=Rr.cloneArray(a.extraHeaders),s=a.body;if(this._direction!=="incoming")throw new Ac.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,s)}},{key:"reject",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=a.status_code||480,s=a.reason_phrase,p=Rr.cloneArray(a.extraHeaders),h=a.body;if(this._direction!=="incoming")throw new Ac.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,s,p,h)}},{key:"_receiveResponse",value:function(a){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(a.status_code):break;case/^2[0-9]{2}$/.test(a.status_code):this._succeeded("remote",a);break;default:{var t=Rr.sipErrorCause(a.status_code);this._failed("remote",a,t);break}}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,ea.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,ea.causes.CONNECTION_ERROR)}},{key:"_close",value:function(){this._closed=!0,this._ua.destroyMessage(this)}},{key:"_newMessage",value:function(a,t){a==="remote"?(this._direction="incoming",this._local_identity=t.to,this._remote_identity=t.from):a==="local"&&(this._direction="outgoing",this._local_identity=t.from,this._remote_identity=t.to),this._ua.newMessage(this,{originator:a,message:this,request:t})}},{key:"_failed",value:function(a,t,s){Nl.debug("MESSAGE failed"),this._close(),Nl.debug('emit "failed"'),this.emit("failed",{originator:a,response:t||null,cause:s})}},{key:"_succeeded",value:function(a,t){Nl.debug("MESSAGE succeeded"),this._close(),Nl.debug('emit "succeeded"'),this.emit("succeeded",{originator:a,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}(yd);function Ul(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Ul=function(n){return typeof n}:Ul=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Ul(c)}function bd(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Rc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function wd(c,r,n){return r&&Rc(c.prototype,r),n&&Rc(c,n),c}function Od(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&ta(c,r)}function ta(c,r){return ta=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},ta(c,r)}function Dd(c){var r=Pd();return function(){var o=Pl(c),a;if(r){var t=Pl(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return Nd(this,a)}}function Nd(c,r){return r&&(Ul(r)==="object"||typeof r=="function")?r:Ud(c)}function Ud(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Pd(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Pl(c){return Pl=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},Pl(c)}var kd=ot.EventEmitter,Md=rt,sa=Xe,xd=ss,Ir=Tt(),Ld=Er,Ic=ms,kl=new Md("Options"),$d=function(c){Od(n,c);var r=Dd(n);function n(o){var a;return bd(this,n),a=r.call(this),a._ua=o,a._request=null,a._closed=!1,a._direction=null,a._local_identity=null,a._remote_identity=null,a._is_replied=!1,a._data={},a}return wd(n,[{key:"send",value:function(a,t){var s=this,p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},h=a;if(a===void 0)throw new TypeError("A target is required for OPTIONS");if(a=this._ua.normalizeTarget(a),!a)throw new TypeError("Invalid target: ".concat(h));var d=Ir.cloneArray(p.extraHeaders),g=Ir.cloneObject(p.eventHandlers),v=p.contentType||"application/sdp";for(var E in g)Object.prototype.hasOwnProperty.call(g,E)&&this.on(E,g[E]);d.push("Content-Type: ".concat(v)),this._request=new xd.OutgoingRequest(sa.OPTIONS,a,this._ua,null,d),t&&(this._request.body=t);var S=new Ld(this._ua,this._request,{onRequestTimeout:function(){s._onRequestTimeout()},onTransportError:function(){s._onTransportError()},onReceiveResponse:function(I){s._receiveResponse(I)}});this._newOptions("local",this._request),S.send()}},{key:"init_incoming",value:function(a){this._request=a,this._newOptions("remote",a),this._is_replied||(this._is_replied=!0,a.reply(200)),this._close()}},{key:"accept",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=Ir.cloneArray(a.extraHeaders),s=a.body;if(this._direction!=="incoming")throw new Ic.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,s)}},{key:"reject",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=a.status_code||480,s=a.reason_phrase,p=Ir.cloneArray(a.extraHeaders),h=a.body;if(this._direction!=="incoming")throw new Ic.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,s,p,h)}},{key:"_receiveResponse",value:function(a){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(a.status_code):break;case/^2[0-9]{2}$/.test(a.status_code):this._succeeded("remote",a);break;default:{var t=Ir.sipErrorCause(a.status_code);this._failed("remote",a,t);break}}}},{key:"_onRequestTimeout",value:function(){this._closed||this._failed("system",null,sa.causes.REQUEST_TIMEOUT)}},{key:"_onTransportError",value:function(){this._closed||this._failed("system",null,sa.causes.CONNECTION_ERROR)}},{key:"_close",value:function(){this._closed=!0,this._ua.destroyMessage(this)}},{key:"_newOptions",value:function(a,t){a==="remote"?(this._direction="incoming",this._local_identity=t.to,this._remote_identity=t.from):a==="local"&&(this._direction="outgoing",this._local_identity=t.from,this._remote_identity=t.to),this._ua.newOptions(this,{originator:a,message:this,request:t})}},{key:"_failed",value:function(a,t,s){kl.debug("OPTIONS failed"),this._close(),kl.debug('emit "failed"'),this.emit("failed",{originator:a,response:t||null,cause:s})}},{key:"_succeeded",value:function(a,t){kl.debug("OPTIONS succeeded"),this._close(),kl.debug('emit "succeeded"'),this.emit("succeeded",{originator:a,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}(kd),na={},Hd=rt,ra=Tt(),Fd=Vt(),br=new Hd("Socket");na.isSocket=function(c){if(Array.isArray(c))return!1;if(typeof c>"u")return br.warn("undefined JsSIP.Socket instance"),!1;try{if(!ra.isString(c.url))throw br.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!ra.isString(c.via_transport))throw br.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(Fd.parse(c.sip_uri,"SIP_URI")===-1)throw br.warn("missing or invalid JsSIP.Socket sip_uri property"),new Error("missing or invalid JsSIP.Socket sip_uri property")}catch{return!1}try{["connect","disconnect","send"].forEach(function(r){if(!ra.isFunction(c[r]))throw br.warn("missing or invalid JsSIP.Socket method: ".concat(r)),new Error("Missing or invalid JsSIP.Socket method: ".concat(r))})}catch{return!1}return!0};function qd(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function bc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Vd(c,r,n){return r&&bc(c.prototype,r),n&&bc(c,n),c}var jd=rt,Bd=na,wc=Xe,Rt=new jd("Transport"),Nt={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:wc.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:wc.CONNECTION_RECOVERY_MAX_INTERVAL}},Gd=function(){function c(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Nt.recovery_options;qd(this,c),Rt.debug("new()"),this.status=Nt.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=n,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1;try{this.textDecoder=new TextDecoder("utf8")}catch(o){Rt.warn("cannot use TextDecoder: ".concat(o))}if(typeof r>"u")throw new TypeError("Invalid argument. undefined 'sockets' argument");r instanceof Array||(r=[r]),r.forEach(function(o){if(!Bd.isSocket(o.socket))throw new TypeError("Invalid argument. invalid 'JsSIP.Socket' instance");if(o.weight&&!Number(o.weight))throw new TypeError("Invalid argument. 'weight' attribute is not a number");this.sockets.push({socket:o.socket,weight:o.weight||0,status:Nt.SOCKET_STATUS_READY})},this),this._getSocket()}return Vd(c,[{key:"connect",value:function(){if(Rt.debug("connect()"),this.isConnected()){Rt.debug("Transport is already connected");return}else if(this.isConnecting()){Rt.debug("Transport is connecting");return}this.close_requested=!1,this.status=Nt.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(){Rt.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=Nt.STATUS_DISCONNECTED,this.recovery_timer!==null&&(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(n){if(Rt.debug("send()"),!this.isConnected())return Rt.warn("unable to send message, transport is not connected"),!1;var o=n.toString();return Rt.debug(`sending message:
|
51
51
|
|
52
52
|
`.concat(o,`
|
53
53
|
`)),this.socket.send(o)}},{key:"isConnected",value:function(){return this.status===Nt.STATUS_CONNECTED}},{key:"isConnecting",value:function(){return this.status===Nt.STATUS_CONNECTING}},{key:"_reconnect",value:function(){var n=this;this.recover_attempts+=1;var o=Math.floor(Math.random()*Math.pow(2,this.recover_attempts)+1);o<this.recovery_options.min_interval?o=this.recovery_options.min_interval:o>this.recovery_options.max_interval&&(o=this.recovery_options.max_interval),Rt.debug("reconnection attempt: ".concat(this.recover_attempts,". next connection attempt in ").concat(o," seconds")),this.recovery_timer=setTimeout(function(){!n.close_requested&&!(n.isConnected()||n.isConnecting())&&(n._getSocket(),n.connect())},o*1e3)}},{key:"_getSocket",value:function(){var n=[];if(this.sockets.forEach(function(a){a.status!==Nt.SOCKET_STATUS_ERROR&&(n.length===0?n.push(a):a.weight>n[0].weight?n=[a]:a.weight===n[0].weight&&n.push(a))}),n.length===0){this.sockets.forEach(function(a){a.status=Nt.SOCKET_STATUS_READY}),this._getSocket();return}var o=Math.floor(Math.random()*n.length);this.socket=n[o].socket}},{key:"_onConnect",value:function(){this.recover_attempts=0,this.status=Nt.STATUS_CONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}},{key:"_onDisconnect",value:function(n,o,a){this.status=Nt.STATUS_DISCONNECTED,this.ondisconnect({socket:this.socket,error:n,code:o,reason:a}),!this.close_requested&&(this.sockets.forEach(function(t){this.socket===t.socket&&(t.status=Nt.SOCKET_STATUS_ERROR)},this),this._reconnect(n))}},{key:"_onData",value:function(n){if(n===`\r
|
@@ -58,10 +58,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
58
58
|
|
59
59
|
`.concat(n,`
|
60
60
|
`));this.ondata({transport:this,message:n})}},{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}}]),c}(),Oc={};function Dc(c,r){var n;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(n=Kd(c))||r&&c&&typeof c.length=="number"){n&&(c=n);var o=0,a=function(){};return{s:a,n:function(){return o>=c.length?{done:!0}:{done:!1,value:c[o++]}},e:function(d){throw d},f:a}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
61
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var t=!0,s=!1,p;return{s:function(){n=c[Symbol.iterator]()},n:function(){var d=n.next();return t=d.done,d},e:function(d){s=!0,p=d},f:function(){try{!t&&n.return!=null&&n.return()}finally{if(s)throw p}}}}function Kd(c,r){if(c){if(typeof c=="string")return Nc(c,r);var n=Object.prototype.toString.call(c).slice(8,-1);if(n==="Object"&&c.constructor&&(n=c.constructor.name),n==="Map"||n==="Set")return Array.from(c);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Nc(c,r)}}function Nc(c,r){(r==null||r>c.length)&&(r=c.length);for(var n=0,o=new Array(r);n<r;n++)o[n]=c[n];return o}var Wd=rt,ia=Vt(),la=
|
61
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var t=!0,s=!1,p;return{s:function(){n=c[Symbol.iterator]()},n:function(){var d=n.next();return t=d.done,d},e:function(d){s=!0,p=d},f:function(){try{!t&&n.return!=null&&n.return()}finally{if(s)throw p}}}}function Kd(c,r){if(c){if(typeof c=="string")return Nc(c,r);var n=Object.prototype.toString.call(c).slice(8,-1);if(n==="Object"&&c.constructor&&(n=c.constructor.name),n==="Map"||n==="Set")return Array.from(c);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Nc(c,r)}}function Nc(c,r){(r==null||r>c.length)&&(r=c.length);for(var n=0,o=new Array(r);n<r;n++)o[n]=c[n];return o}var Wd=rt,ia=Vt(),la=ss,Ml=new Wd("Parser");Oc.parseMessage=function(c,r){var n,o,a=c.indexOf(`\r
|
62
62
|
`);if(a===-1){Ml.warn("parseMessage() | no CRLF found, not a SIP message");return}var t=c.substring(0,a),s=ia.parse(t,"Request_Response");if(s===-1){Ml.warn('parseMessage() | error parsing first line of SIP message: "'.concat(t,'"'));return}else s.status_code?(n=new la.IncomingResponse,n.status_code=s.status_code,n.reason_phrase=s.reason_phrase):(n=new la.IncomingRequest(r),n.method=s.method,n.ruri=s.uri);n.data=c;for(var p=a+2;;){if(a=Yd(c,p),a===-2){o=p+2;break}else if(a===-1){Ml.warn("parseMessage() | malformed message");return}if(s=zd(n,c,p,a),s!==!0){Ml.warn("parseMessage() |",s.error);return}p=a+2}if(n.hasHeader("content-length")){var h=n.getHeader("content-length");n.body=c.substr(o,h)}else n.body=c.substring(o);return n};function Yd(c,r){var n=r,o=0,a=0;if(c.substring(n,n+2).match(/(^\r\n)/))return-2;for(;o===0;){if(a=c.indexOf(`\r
|
63
63
|
`,n),a===-1)return a;!c.substring(a+2,a+4).match(/(^\r\n)/)&&c.charAt(a+2).match(/(^\s+)/)?n=a+2:o=a}return o}function zd(c,r,n,o){var a,t=r.indexOf(":",n),s=r.substring(n,t).trim(),p=r.substring(t+1,o).trim();switch(s.toLowerCase()){case"via":case"v":c.addHeader("via",p),c.getHeaders("via").length===1?(a=c.parseHeader("Via"),a&&(c.via=a,c.via_branch=a.branch)):a=0;break;case"from":case"f":c.setHeader("from",p),a=c.parseHeader("from"),a&&(c.from=a,c.from_tag=a.getParam("tag"));break;case"to":case"t":c.setHeader("to",p),a=c.parseHeader("to"),a&&(c.to=a,c.to_tag=a.getParam("tag"));break;case"record-route":if(a=ia.parse(p,"Record_Route"),a===-1)a=void 0;else{var h=Dc(a),d;try{for(h.s();!(d=h.n()).done;){var g=d.value;c.addHeader("record-route",p.substring(g.possition,g.offset)),c.headers["Record-Route"][c.getHeaders("record-route").length-1].parsed=g.parsed}}catch(C){h.e(C)}finally{h.f()}}break;case"call-id":case"i":c.setHeader("call-id",p),a=c.parseHeader("call-id"),a&&(c.call_id=p);break;case"contact":case"m":if(a=ia.parse(p,"Contact"),a===-1)a=void 0;else{var v=Dc(a),E;try{for(v.s();!(E=v.n()).done;){var S=E.value;c.addHeader("contact",p.substring(S.possition,S.offset)),c.headers.Contact[c.getHeaders("contact").length-1].parsed=S.parsed}}catch(C){v.e(C)}finally{v.f()}}break;case"content-length":case"l":c.setHeader("content-length",p),a=c.parseHeader("content-length");break;case"content-type":case"c":c.setHeader("content-type",p),a=c.parseHeader("content-type");break;case"cseq":c.setHeader("cseq",p),a=c.parseHeader("cseq"),a&&(c.cseq=a.value),c instanceof la.IncomingResponse&&(c.method=a.method);break;case"max-forwards":c.setHeader("max-forwards",p),a=c.parseHeader("max-forwards");break;case"www-authenticate":c.setHeader("www-authenticate",p),a=c.parseHeader("www-authenticate");break;case"proxy-authenticate":c.setHeader("proxy-authenticate",p),a=c.parseHeader("proxy-authenticate");break;case"session-expires":case"x":c.setHeader("session-expires",p),a=c.parseHeader("session-expires"),a&&(c.session_expires=a.expires,c.session_expires_refresher=a.refresher);break;case"refer-to":case"r":c.setHeader("refer-to",p),a=c.parseHeader("refer-to"),a&&(c.refer_to=a);break;case"replaces":c.setHeader("replaces",p),a=c.parseHeader("replaces"),a&&(c.replaces=a);break;case"event":case"o":c.setHeader("event",p),a=c.parseHeader("event"),a&&(c.event=a);break;default:c.addHeader(s,p),a=0}return a===void 0?{error:'error parsing header "'.concat(s,'"')}:!0}function xl(c,r){var n;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(n=Jd(c))||r&&c&&typeof c.length=="number"){n&&(c=n);var o=0,a=function(){};return{s:a,n:function(){return o>=c.length?{done:!0}:{done:!1,value:c[o++]}},e:function(d){throw d},f:a}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
64
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var t=!0,s=!1,p;return{s:function(){n=c[Symbol.iterator]()},n:function(){var d=n.next();return t=d.done,d},e:function(d){s=!0,p=d},f:function(){try{!t&&n.return!=null&&n.return()}finally{if(s)throw p}}}}function Jd(c,r){if(c){if(typeof c=="string")return Uc(c,r);var n=Object.prototype.toString.call(c).slice(8,-1);if(n==="Object"&&c.constructor&&(n=c.constructor.name),n==="Map"||n==="Set")return Array.from(c);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Uc(c,r)}}function Uc(c,r){(r==null||r>c.length)&&(r=c.length);for(var n=0,o=new Array(r);n<r;n++)o[n]=c[n];return o}var Xd=rt,Pc=Xe,kc=
|
64
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var t=!0,s=!1,p;return{s:function(){n=c[Symbol.iterator]()},n:function(){var d=n.next();return t=d.done,d},e:function(d){s=!0,p=d},f:function(){try{!t&&n.return!=null&&n.return()}finally{if(s)throw p}}}}function Jd(c,r){if(c){if(typeof c=="string")return Uc(c,r);var n=Object.prototype.toString.call(c).slice(8,-1);if(n==="Object"&&c.constructor&&(n=c.constructor.name),n==="Map"||n==="Set")return Array.from(c);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Uc(c,r)}}function Uc(c,r){(r==null||r>c.length)&&(r=c.length);for(var n=0,o=new Array(r);n<r;n++)o[n]=c[n];return o}var Xd=rt,Pc=Xe,kc=ss,oa=Tt(),aa=new Xd("sanityCheck"),Qd=[ap],Zd=[sp,np,rp,ip],ep=[lp,op],xe,Bt,Mc,tp=function(c,r,n){xe=c,Bt=r,Mc=n;var o=xl(Qd),a;try{for(o.s();!(a=o.n()).done;){var t=a.value;if(t()===!1)return!1}}catch(E){o.e(E)}finally{o.f()}if(xe instanceof kc.IncomingRequest){var s=xl(Zd),p;try{for(s.s();!(p=s.n()).done;){var h=p.value;if(h()===!1)return!1}}catch(E){s.e(E)}finally{s.f()}}else if(xe instanceof kc.IncomingResponse){var d=xl(ep),g;try{for(d.s();!(g=d.n()).done;){var v=g.value;if(v()===!1)return!1}}catch(E){d.e(E)}finally{d.f()}}return!0};function sp(){if(xe.s("to").uri.scheme!=="sip")return wr(416),!1}function np(){if(!xe.to_tag&&xe.call_id.substr(0,5)===Bt.configuration.jssip_id)return wr(482),!1}function rp(){var c=oa.str_utf8_length(xe.body),r=xe.getHeader("content-length");if(c<r)return wr(400),!1}function ip(){var c=xe.from_tag,r=xe.call_id,n=xe.cseq,o;if(!xe.to_tag)if(xe.method===Pc.INVITE){if(Bt._transactions.ist[xe.via_branch])return!1;for(var a in Bt._transactions.ist)if(Object.prototype.hasOwnProperty.call(Bt._transactions.ist,a)&&(o=Bt._transactions.ist[a],o.request.from_tag===c&&o.request.call_id===r&&o.request.cseq===n))return wr(482),!1}else{if(Bt._transactions.nist[xe.via_branch])return!1;for(var t in Bt._transactions.nist)if(Object.prototype.hasOwnProperty.call(Bt._transactions.nist,t)&&(o=Bt._transactions.nist[t],o.request.from_tag===c&&o.request.call_id===r&&o.request.cseq===n))return wr(482),!1}}function lp(){if(xe.getHeaders("via").length>1)return aa.debug("more than one Via header field present in the response, dropping the response"),!1}function op(){var c=oa.str_utf8_length(xe.body),r=xe.getHeader("content-length");if(c<r)return aa.debug("message body length is lower than the value in Content-Length header field, dropping the response"),!1}function ap(){for(var c=["from","to","call_id","cseq","via"],r=0,n=c;r<n.length;r++){var o=n[r];if(!xe.hasHeader(o))return aa.debug("missing mandatory header field : ".concat(o,", dropping the response")),!1}}function wr(c){var r=xe.getHeaders("via"),n,o="SIP/2.0 ".concat(c," ").concat(Pc.REASON_PHRASE[c],`\r
|
65
65
|
`),a=xl(r),t;try{for(a.s();!(t=a.n()).done;){var s=t.value;o+="Via: ".concat(s,`\r
|
66
66
|
`)}}catch(p){a.e(p)}finally{a.f()}n=xe.getHeader("To"),xe.to_tag||(n+=";tag=".concat(oa.newTag())),o+="To: ".concat(n,`\r
|
67
67
|
`),o+="From: ".concat(xe.getHeader("From"),`\r
|
@@ -69,10 +69,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
69
69
|
`),o+="CSeq: ".concat(xe.cseq," ").concat(xe.method,`\r
|
70
70
|
`),o+=`\r
|
71
71
|
`,Mc.send(o)}var ua={};function xc(c,r){var n;if(typeof Symbol>"u"||c[Symbol.iterator]==null){if(Array.isArray(c)||(n=up(c))||r&&c&&typeof c.length=="number"){n&&(c=n);var o=0,a=function(){};return{s:a,n:function(){return o>=c.length?{done:!0}:{done:!1,value:c[o++]}},e:function(d){throw d},f:a}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
72
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var t=!0,s=!1,p;return{s:function(){n=c[Symbol.iterator]()},n:function(){var d=n.next();return t=d.done,d},e:function(d){s=!0,p=d},f:function(){try{!t&&n.return!=null&&n.return()}finally{if(s)throw p}}}}function up(c,r){if(c){if(typeof c=="string")return Lc(c,r);var n=Object.prototype.toString.call(c).slice(8,-1);if(n==="Object"&&c.constructor&&(n=c.constructor.name),n==="Map"||n==="Set")return Array.from(c);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Lc(c,r)}}function Lc(c,r){(r==null||r>c.length)&&(r=c.length);for(var n=0,o=new Array(r);n<r;n++)o[n]=c[n];return o}var yn=Tt(),qs=Xe,ca=Vt(),$c=ms(),fa=na,ha=ps;ua.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:qs.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:qs.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:qs.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:"".concat(yn.createRandomToken(12),".invalid")};var Ll={mandatory:{sockets:function(r){var n=[];if(fa.isSocket(r))n.push({socket:r});else if(Array.isArray(r)&&r.length){var o=xc(r),a;try{for(o.s();!(a=o.n()).done;){var t=a.value;Object.prototype.hasOwnProperty.call(t,"socket")&&fa.isSocket(t.socket)?n.push(t):fa.isSocket(t)&&n.push({socket:t})}}catch(s){o.e(s)}finally{o.f()}}else return;return n},uri:function(r){/^sip:/i.test(r)||(r="".concat(qs.SIP,":").concat(r));var n=$c.parse(r);if(n)return n.user?n:void 0}},optional:{authorization_user:function(r){if(ca.parse('"'.concat(r,'"'),"quoted_string")!==-1)return r},authorization_jwt:function(r){if(typeof r=="string")return r},user_agent:function(r){if(typeof r=="string")return r},connection_recovery_max_interval:function(r){if(yn.isDecimal(r)){var n=Number(r);if(n>0)return n}},connection_recovery_min_interval:function(r){if(yn.isDecimal(r)){var n=Number(r);if(n>0)return n}},contact_uri:function(r){if(typeof r=="string"){var n=ca.parse(r,"SIP_URI");if(n!==-1)return n}},display_name:function(r){return r},instance_id:function(r){if(/^uuid:/i.test(r)&&(r=r.substr(5)),ca.parse(r,"uuid")!==-1)return r},no_answer_timeout:function(r){if(yn.isDecimal(r)){var n=Number(r);if(n>0)return n}},session_timers:function(r){if(typeof r=="boolean")return r},session_timers_refresh_method:function(r){if(typeof r=="string"&&(r=r.toUpperCase(),r===qs.INVITE||r===qs.UPDATE))return r},session_timers_force_refresher:function(r){if(typeof r=="boolean")return r},password:function(r){return String(r)},realm:function(r){return String(r)},ha1:function(r){return String(r)},register:function(r){if(typeof r=="boolean")return r},register_expires:function(r){if(yn.isDecimal(r)){var n=Number(r);if(n>0)return n}},registrar_server:function(r){/^sip:/i.test(r)||(r="".concat(qs.SIP,":").concat(r));var n=$c.parse(r);if(n)return n.user?void 0:n},use_preloaded_route:function(r){if(typeof r=="boolean")return r},extra_headers:function(r){var n=[];if(Array.isArray(r)&&r.length){var o=xc(r),a;try{for(o.s();!(a=o.n()).done;){var t=a.value;typeof t=="string"&&n.push(t)}}catch(s){o.e(s)}finally{o.f()}}else return;return n}}};ua.load=function(c,r){for(var n in Ll.mandatory)if(r.hasOwnProperty(n)){var o=r[n],a=Ll.mandatory[n](o);if(a!==void 0)c[n]=a;else throw new ha.ConfigurationError(n,o)}else throw new ha.ConfigurationError(n);for(var t in Ll.optional)if(r.hasOwnProperty(t)){var s=r[t];if(yn.isEmpty(s))continue;var p=Ll.optional[t](s);if(p!==void 0)c[t]=p;else throw new ha.ConfigurationError(t,s)}};function $l(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?$l=function(n){return typeof n}:$l=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},$l(c)}function cp(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Hc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Fc(c,r,n){return r&&Hc(c.prototype,r),n&&Hc(c,n),c}function fp(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&_a(c,r)}function _a(c,r){return _a=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},_a(c,r)}function hp(c){var r=dp();return function(){var o=Hl(c),a;if(r){var t=Hl(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return _p(this,a)}}function _p(c,r){return r&&($l(r)==="object"||typeof r=="function")?r:qc(c)}function qc(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function dp(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Hl(c){return Hl=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},Hl(c)}var pp=ot.EventEmitter,mp=rt,ut=Xe,gp=r_,Vc=_d,jc=Id,Bc=$d,da=Tr,vp=Gd,Fl=Tt(),Tp=ps,Ep=ms(),yp=Oc,pa=ts,Sp=tp,ma=ua,$e=new mp("UA"),ct={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2},Cp=function(c){fp(n,c);var r=hp(n);Fc(n,null,[{key:"C",get:function(){return ct}}]);function n(o){var a;if(cp(this,n),$e.debug("new() [configuration:%o]",o),a=r.call(this),a._cache={credentials:{}},a._configuration=Object.assign({},ma.settings),a._dynConfiguration={},a._dialogs={},a._applicants={},a._sessions={},a._transport=null,a._contact=null,a._status=ct.STATUS_INIT,a._error=null,a._transactions={nist:{},nict:{},ist:{},ict:{}},a._data={},a._closeTimer=null,o===void 0)throw new TypeError("Not enough arguments");try{a._loadConfig(o)}catch(t){throw a._status=ct.STATUS_NOT_READY,a._error=ct.CONFIGURATION_ERROR,t}return a._registrator=new gp(qc(a)),a}return Fc(n,[{key:"start",value:function(){$e.debug("start()"),this._status===ct.STATUS_INIT?this._transport.connect():this._status===ct.STATUS_USER_CLOSED?($e.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=ct.STATUS_INIT,this._transport.connect()):this._status===ct.STATUS_READY?$e.debug("UA is in READY status, not restarted"):$e.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this._dynConfiguration.register=this._configuration.register}},{key:"register",value:function(){$e.debug("register()"),this._dynConfiguration.register=!0,this._registrator.register()}},{key:"unregister",value:function(a){$e.debug("unregister()"),this._dynConfiguration.register=!1,this._registrator.unregister(a)}},{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(a,t){$e.debug("call()");var s=new Vc(this);return s.connect(a,t),s}},{key:"sendMessage",value:function(a,t,s){$e.debug("sendMessage()");var p=new jc(this);return p.send(a,t,s),p}},{key:"sendOptions",value:function(a,t,s){$e.debug("sendOptions()");var p=new Bc(this);return p.send(a,t,s),p}},{key:"terminateSessions",value:function(a){$e.debug("terminateSessions()");for(var t in this._sessions)this._sessions[t].isEnded()||this._sessions[t].terminate(a)}},{key:"stop",value:function(){var a=this;if($e.debug("stop()"),this._dynConfiguration={},this._status===ct.STATUS_USER_CLOSED){$e.debug("UA already closed");return}this._registrator.close();var t=Object.keys(this._sessions).length;for(var s in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,s)){$e.debug("closing session ".concat(s));try{this._sessions[s].terminate()}catch{}}for(var p in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,p))try{this._applicants[p].close()}catch{}this._status=ct.STATUS_USER_CLOSED;var h=Object.keys(this._transactions.nict).length+Object.keys(this._transactions.nist).length+Object.keys(this._transactions.ict).length+Object.keys(this._transactions.ist).length;h===0&&t===0?this._transport.disconnect():this._closeTimer=setTimeout(function(){a._closeTimer=null,a._transport.disconnect()},2e3)}},{key:"normalizeTarget",value:function(a){return Fl.normalizeTarget(a,this._configuration.hostport_params)}},{key:"get",value:function(a){switch(a){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:$e.warn('get() | cannot get "%s" parameter in runtime',a);return}}},{key:"set",value:function(a,t){switch(a){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}default:return $e.warn('set() | cannot set "%s" parameter in runtime',a),!1}return!0}},{key:"newTransaction",value:function(a){this._transactions[a.type][a.id]=a,this.emit("newTransaction",{transaction:a})}},{key:"destroyTransaction",value:function(a){delete this._transactions[a.type][a.id],this.emit("transactionDestroyed",{transaction:a})}},{key:"newDialog",value:function(a){this._dialogs[a.id]=a}},{key:"destroyDialog",value:function(a){delete this._dialogs[a.id]}},{key:"newMessage",value:function(a,t){this._applicants[a]=a,this.emit("newMessage",t)}},{key:"newOptions",value:function(a,t){this._applicants[a]=a,this.emit("newOptions",t)}},{key:"destroyMessage",value:function(a){delete this._applicants[a]}},{key:"newRTCSession",value:function(a,t){this._sessions[a.id]=a,this.emit("newRTCSession",t)}},{key:"destroyRTCSession",value:function(a){delete this._sessions[a.id]}},{key:"registered",value:function(a){this.emit("registered",a)}},{key:"unregistered",value:function(a){this.emit("unregistered",a)}},{key:"registrationFailed",value:function(a){this.emit("registrationFailed",a)}},{key:"receiveRequest",value:function(a){var t=a.method;if(a.ruri.user!==this._configuration.uri.user&&a.ruri.user!==this._contact.uri.user){$e.debug("Request-URI does not point to us"),a.method!==ut.ACK&&a.reply_sl(404);return}if(a.ruri.scheme===ut.SIPS){a.reply_sl(416);return}if(!da.checkTransaction(this,a)){if(t===ut.INVITE?new da.InviteServerTransaction(this,this._transport,a):t!==ut.ACK&&t!==ut.CANCEL&&new da.NonInviteServerTransaction(this,this._transport,a),t===ut.OPTIONS){if(this.listeners("newOptions").length===0){a.reply(200);return}var s=new Bc(this);s.init_incoming(a)}else if(t===ut.MESSAGE){if(this.listeners("newMessage").length===0){a.reply(405);return}var p=new jc(this);p.init_incoming(a)}else if(t===ut.INVITE&&!a.to_tag&&this.listeners("newRTCSession").length===0){a.reply(405);return}var h,d;if(a.to_tag)h=this._findDialog(a.call_id,a.from_tag,a.to_tag),h?h.receiveRequest(a):t===ut.NOTIFY?(d=this._findSession(a),d?d.receiveRequest(a):($e.debug("received NOTIFY request for a non existent subscription"),a.reply(481,"Subscription does not exist"))):t!==ut.ACK&&a.reply(481);else switch(t){case ut.INVITE:if(window.RTCPeerConnection)if(a.hasHeader("replaces")){var g=a.replaces;h=this._findDialog(g.call_id,g.from_tag,g.to_tag),h?(d=h.owner,d.isEnded()?a.reply(603):d.receiveRequest(a)):a.reply(481)}else d=new Vc(this),d.init_incoming(a);else $e.warn("INVITE received but WebRTC is not supported"),a.reply(488);break;case ut.BYE:a.reply(481);break;case ut.CANCEL:d=this._findSession(a),d?d.receiveRequest(a):$e.debug("received CANCEL request for a non existent session");break;case ut.ACK:break;case ut.NOTIFY:this.emit("sipEvent",{event:a.event,request:a}),a.reply(200);break;default:a.reply(405);break}}}},{key:"_findSession",value:function(a){var t=a.call_id,s=a.from_tag,p=a.to_tag,h=t+s,d=this._sessions[h],g=t+p,v=this._sessions[g];return d||v||null}},{key:"_findDialog",value:function(a,t,s){var p=a+t+s,h=this._dialogs[p];return h||(p=a+s+t,h=this._dialogs[p],h||null)}},{key:"_loadConfig",value:function(a){try{ma.load(this._configuration,a)}catch(g){throw g}this._configuration.display_name===0&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=Fl.newUUID()),this._configuration.jssip_id=Fl.createRandomToken(5);var t=this._configuration.uri.clone();t.user=null,this._configuration.hostport_params=t.toString().replace(/^sip:/i,"");try{this._transport=new vp(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=Ap.bind(this),this._transport.onconnect=Rp.bind(this),this._transport.ondisconnect=Ip.bind(this),this._transport.ondata=bp.bind(this)}catch(g){throw $e.warn(g),new Tp.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 s=this._configuration.uri.clone();s.user=null,s.clearParams(),s.clearHeaders(),this._configuration.registrar_server=s}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new Ep("sip",Fl.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 v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},E=v.anonymous||null,S=v.outbound||null,C="<";return E?C+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":C+=this.pub_gruu||this.uri.toString(),S&&(E?!this.temp_gruu:!this.pub_gruu)&&(C+=";ob"),C+=">",C}};var p=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register"];for(var h in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,h)&&(p.indexOf(h)!==-1?Object.defineProperty(this._configuration,h,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,h,{writable:!1,configurable:!1}));$e.debug("configuration parameters after validation:");for(var d in this._configuration)if(Object.prototype.hasOwnProperty.call(ma.settings,d))switch(d){case"uri":case"registrar_server":$e.debug("- ".concat(d,": ").concat(this._configuration[d]));break;case"password":case"ha1":case"authorization_jwt":$e.debug("- ".concat(d,": NOT SHOWN"));break;default:$e.debug("- ".concat(d,": ").concat(JSON.stringify(this._configuration[d])))}}},{key:"C",get:function(){return ct}},{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}(pp);function Ap(c){this.emit("connecting",c)}function Rp(c){this._status!==ct.STATUS_USER_CLOSED&&(this._status=ct.STATUS_READY,this._error=null,this.emit("connected",c),this._dynConfiguration.register&&this._registrator.register())}function Ip(c){for(var r=["nict","ict","nist","ist"],n=0,o=r;n<o.length;n++){var a=o[n];for(var t in this._transactions[a])Object.prototype.hasOwnProperty.call(this._transactions[a],t)&&this._transactions[a][t].onTransportError()}this.emit("disconnected",c),this._registrator.onTransportClosed(),this._status!==ct.STATUS_USER_CLOSED&&(this._status=ct.STATUS_NOT_READY,this._error=ct.NETWORK_ERROR)}function bp(c){var r=c.transport,n=c.message;if(n=yp.parseMessage(n,this),!!n&&!(this._status===ct.STATUS_USER_CLOSED&&n instanceof pa.IncomingRequest)&&Sp(n,this,r)){if(n instanceof pa.IncomingRequest)n.transport=r,this.receiveRequest(n);else if(n instanceof pa.IncomingResponse){var o;switch(n.method){case ut.INVITE:o=this._transactions.ict[n.via_branch],o&&o.receiveResponse(n);break;case ut.ACK:break;default:o=this._transactions.nict[n.via_branch],o&&o.receiveResponse(n);break}}}}function wp(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Gc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Op(c,r,n){return r&&Gc(c.prototype,r),n&&Gc(c,n),c}var Dp=rt,Np=Vt(),St=new Dp("WebSocketInterface"),Up=function(){function c(r){wp(this,c),St.debug('new() [url:"%s"]',r),this._url=r,this._sip_uri=null,this._via_transport=null,this._ws=null;var n=Np.parse(r,"absoluteURI");if(n===-1)throw St.warn("invalid WebSocket URI: ".concat(r)),new TypeError("Invalid argument: ".concat(r));if(n.scheme!=="wss"&&n.scheme!=="ws")throw St.warn("invalid WebSocket URI scheme: ".concat(n.scheme)),new TypeError("Invalid argument: ".concat(r));this._sip_uri="sip:".concat(n.host).concat(n.port?":".concat(n.port):"",";transport=ws"),this._via_transport=n.scheme.toUpperCase()}return Op(c,[{key:"connect",value:function(){if(St.debug("connect()"),this.isConnected()){St.debug("WebSocket ".concat(this._url," is already connected"));return}else if(this.isConnecting()){St.debug("WebSocket ".concat(this._url," is connecting"));return}this._ws&&this.disconnect(),St.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(n){this._onError(n)}}},{key:"disconnect",value:function(){St.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(n){return St.debug("send()"),this.isConnected()?(this._ws.send(n),!0):(St.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(){St.debug("WebSocket ".concat(this._url," connected")),this.onconnect()}},{key:"_onClose",value:function(n){var o=n.wasClean,a=n.code,t=n.reason;St.debug("WebSocket ".concat(this._url," closed")),o===!1&&St.debug("WebSocket abrupt disconnection"),this.ondisconnect(!o,a,t)}},{key:"_onMessage",value:function(n){var o=n.data;St.debug("received WebSocket message"),this.ondata(o)}},{key:"_onError",value:function(n){St.warn("WebSocket ".concat(this._url," error: "),n)}},{key:"via_transport",get:function(){return this._via_transport},set:function(n){this._via_transport=n.toUpperCase()}},{key:"sip_uri",get:function(){return this._sip_uri}},{key:"url",get:function(){return this._url}}]),c}(),ga=sl,Pp=Xe,kp=ps,Mp=Tt(),xp=Cp,Lp=ms(),$p=wo(),Hp=Vt(),Fp=Up,qp=vn("JsSIP");qp("version %s",ga.version);var Kc={C:Pp,Exceptions:kp,Utils:Mp,UA:xp,URI:Lp,NameAddrHeader:$p,WebSocketInterface:Fp,Grammar:Hp,debug:vn,get name(){return ga.title},get version(){return ga.version}};const Sn=vn,Cn="JsSIP";var it=class{constructor(r){r?(this._debug=Sn.default(`${Cn}:${r}`),this._warn=Sn.default(`${Cn}:WARN:${r}`),this._error=Sn.default(`${Cn}:ERROR:${r}`)):(this._debug=Sn.default(Cn),this._warn=Sn.default(`${Cn}:WARN`),this._error=Sn.default(`${Cn}:ERROR`)),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}get debug(){return this._debug}get warn(){return this._warn}get error(){return this._error}};const Wc=sl;var we={USER_AGENT:`${Wc.title} ${Wc.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};const Ie=vt(we);var ze={},va,Yc;function Ta(){if(Yc)return va;Yc=1;const c=is(),r=Gt();return va=class th{static parse(o){if(o=r.parse(o,"Name_Addr_Header"),o!==-1)return o}constructor(o,a,t){if(!o||!(o instanceof c))throw new TypeError('missing or invalid "uri" parameter');this._uri=o,this._parameters={},this.display_name=a;for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&this.setParam(s,t[s])}get uri(){return this._uri}get display_name(){return this._display_name}set display_name(o){this._display_name=o===0?"0":o}setParam(o,a){o&&(this._parameters[o.toLowerCase()]=typeof a>"u"||a===null?null:a.toString())}getParam(o){if(o)return this._parameters[o.toLowerCase()]}hasParam(o){if(o)return this._parameters.hasOwnProperty(o.toLowerCase())&&!0||!1}deleteParam(o){if(o=o.toLowerCase(),this._parameters.hasOwnProperty(o)){const a=this._parameters[o];return delete this._parameters[o],a}}clearParams(){this._parameters={}}clone(){return new th(this._uri.clone(),this._display_name,JSON.parse(JSON.stringify(this._parameters)))}_quote(o){return o.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}toString(){let o=this._display_name?`"${this._quote(this._display_name)}" `:"";o+=`<${this._uri.toString()}>`;for(const a in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,a)&&(o+=`;${a}`,this._parameters[a]!==null&&(o+=`=${this._parameters[a]}`));return o}},va}var Ea,zc;function Gt(){return zc||(zc=1,Ea=function(){function c(n){return'"'+n.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 r={parse:function(n,o){var a={CRLF:d,DIGIT:g,ALPHA:v,HEXDIG:E,WSP:S,OCTET:C,DQUOTE:I,SP:w,HTAB:F,alphanum:L,reserved:ie,unreserved:N,mark:H,escaped:ve,LWS:me,SWS:M,HCOLON:D,TEXT_UTF8_TRIM:j,TEXT_UTF8char:V,UTF8_NONASCII:Y,UTF8_CONT:$,LHEX:X,token:U,token_nodot:P,separators:Z,word:et,STAR:Q,SLASH:W,EQUAL:B,LPAREN:te,RPAREN:de,RAQUOT:Ae,LAQUOT:Ue,COMMA:Se,SEMI:ne,COLON:Te,LDQUOT:tt,RDQUOT:st,comment:ge,ctext:Ee,quoted_string:Ce,quoted_string_clean:be,qdtext:he,quoted_pair:ce,SIP_URI_noparams:fe,SIP_URI:Re,uri_scheme:Oe,uri_scheme_sips:Je,uri_scheme_sip:Me,userinfo:Pt,user:gt,user_unreserved:On,password:Dn,hostport:zs,host:Xt,hostname:hs,domainlabel:Js,toplabel:Nn,IPv6reference:Un,IPv6address:Xs,h16:_e,ls32:re,IPv4address:nt,dec_octet:qt,port:Rs,uri_parameters:Kr,uri_parameter:Pn,transport_param:kn,user_param:Wr,method_param:Yr,ttl_param:zr,maddr_param:Jr,lr_param:Xr,other_param:Qr,pname:Zr,pvalue:ei,paramchar:Is,param_unreserved:bs,headers:ti,header:Qs,hname:Zs,hvalue:si,hnv_unreserved:ws,Request_Response:en,Request_Line:ro,Request_URI:ni,absoluteURI:Mn,hier_part:xn,net_path:ri,abs_path:tn,opaque_part:sn,uric:Os,uric_no_slash:Ds,path_segments:ii,segment:nn,param:Ns,pchar:_s,scheme:Us,authority:li,srvr:oi,reg_name:ai,query:ui,SIP_Version:Ln,INVITEm:$n,ACKm:ci,OPTIONSm:fi,BYEm:hi,CANCELm:_i,REGISTERm:di,SUBSCRIBEm:pi,NOTIFYm:mi,REFERm:gi,Method:rn,Status_Line:ln,Status_Code:vi,extension_code:Ti,Reason_Phrase:Ei,Allow_Events:io,Call_ID:tu,Contact:su,contact_param:Hn,name_addr:kt,display_name:Mt,contact_params:Ps,c_p_q:Fn,c_p_expires:yi,delta_seconds:Qt,qvalue:Zt,generic_param:Ge,gen_value:Ke,Content_Disposition:lo,disp_type:oo,disp_param:qn,handling_param:Vn,Content_Encoding:ao,Content_Length:nu,Content_Type:ru,media_type:uo,m_type:Si,discrete_type:Ci,composite_type:Ai,extension_token:on,x_token:an,m_subtype:Ri,m_parameter:jn,m_value:Bn,CSeq:co,CSeq_value:fo,Expires:ho,Event:iu,event_type:un,From:cn,from_param:Ii,tag_param:fn,Max_Forwards:bi,Min_Expires:lu,Name_Addr_Header:ou,Proxy_Authenticate:au,challenge:wi,other_challenge:Gn,auth_param:ks,digest_cln:es,realm:hn,realm_value:Oi,domain:Di,URI:_n,nonce:dn,nonce_value:Ni,opaque:Ui,stale:Pi,algorithm:ki,qop_options:Mi,qop_value:pn,Proxy_Require:Kn,Record_Route:uu,rec_route:Wn,Reason:Yn,reason_param:xi,reason_cause:zn,Require:_o,Route:cu,route_param:Jn,Subscription_State:Xn,substate_value:po,subexp_params:Qn,event_reason_value:Zn,Subject:mo,Supported:fu,To:hu,to_param:Li,Via:$i,via_param:er,via_params:Ms,via_ttl:tr,via_maddr:Hi,via_received:Fi,via_branch:qi,response_port:Vi,rport:ji,sent_protocol:Bi,protocol_name:Gi,transport:Ki,sent_by:Wi,via_host:Yi,via_port:zi,ttl:sr,WWW_Authenticate:Ji,Session_Expires:_u,s_e_expires:go,s_e_params:nr,s_e_refresher:rr,extension_header:vo,header_value:To,message_body:Eo,uuid_URI:du,uuid:yo,hex4:xt,hex8:Lt,hex12:Xi,Refer_To:So,Replaces:pu,call_id:Co,replaces_param:ir,to_tag:lr,from_tag:Qi,early_flag:Zi};if(o!==void 0){if(a[o]===void 0)throw new Error("Invalid rule name: "+c(o)+".")}else o="CRLF";var t=0,s=0,p=[];function h(i){t<s||(t>s&&(s=t,p=[]),p.push(i))}function d(){var i;return n.substr(t,2)===`\r
|
72
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var t=!0,s=!1,p;return{s:function(){n=c[Symbol.iterator]()},n:function(){var d=n.next();return t=d.done,d},e:function(d){s=!0,p=d},f:function(){try{!t&&n.return!=null&&n.return()}finally{if(s)throw p}}}}function up(c,r){if(c){if(typeof c=="string")return Lc(c,r);var n=Object.prototype.toString.call(c).slice(8,-1);if(n==="Object"&&c.constructor&&(n=c.constructor.name),n==="Map"||n==="Set")return Array.from(c);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Lc(c,r)}}function Lc(c,r){(r==null||r>c.length)&&(r=c.length);for(var n=0,o=new Array(r);n<r;n++)o[n]=c[n];return o}var yn=Tt(),Vs=Xe,ca=Vt(),$c=gs(),fa=na,ha=ms;ua.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:Vs.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:Vs.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:Vs.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:"".concat(yn.createRandomToken(12),".invalid")};var Ll={mandatory:{sockets:function(r){var n=[];if(fa.isSocket(r))n.push({socket:r});else if(Array.isArray(r)&&r.length){var o=xc(r),a;try{for(o.s();!(a=o.n()).done;){var t=a.value;Object.prototype.hasOwnProperty.call(t,"socket")&&fa.isSocket(t.socket)?n.push(t):fa.isSocket(t)&&n.push({socket:t})}}catch(s){o.e(s)}finally{o.f()}}else return;return n},uri:function(r){/^sip:/i.test(r)||(r="".concat(Vs.SIP,":").concat(r));var n=$c.parse(r);if(n)return n.user?n:void 0}},optional:{authorization_user:function(r){if(ca.parse('"'.concat(r,'"'),"quoted_string")!==-1)return r},authorization_jwt:function(r){if(typeof r=="string")return r},user_agent:function(r){if(typeof r=="string")return r},connection_recovery_max_interval:function(r){if(yn.isDecimal(r)){var n=Number(r);if(n>0)return n}},connection_recovery_min_interval:function(r){if(yn.isDecimal(r)){var n=Number(r);if(n>0)return n}},contact_uri:function(r){if(typeof r=="string"){var n=ca.parse(r,"SIP_URI");if(n!==-1)return n}},display_name:function(r){return r},instance_id:function(r){if(/^uuid:/i.test(r)&&(r=r.substr(5)),ca.parse(r,"uuid")!==-1)return r},no_answer_timeout:function(r){if(yn.isDecimal(r)){var n=Number(r);if(n>0)return n}},session_timers:function(r){if(typeof r=="boolean")return r},session_timers_refresh_method:function(r){if(typeof r=="string"&&(r=r.toUpperCase(),r===Vs.INVITE||r===Vs.UPDATE))return r},session_timers_force_refresher:function(r){if(typeof r=="boolean")return r},password:function(r){return String(r)},realm:function(r){return String(r)},ha1:function(r){return String(r)},register:function(r){if(typeof r=="boolean")return r},register_expires:function(r){if(yn.isDecimal(r)){var n=Number(r);if(n>0)return n}},registrar_server:function(r){/^sip:/i.test(r)||(r="".concat(Vs.SIP,":").concat(r));var n=$c.parse(r);if(n)return n.user?void 0:n},use_preloaded_route:function(r){if(typeof r=="boolean")return r},extra_headers:function(r){var n=[];if(Array.isArray(r)&&r.length){var o=xc(r),a;try{for(o.s();!(a=o.n()).done;){var t=a.value;typeof t=="string"&&n.push(t)}}catch(s){o.e(s)}finally{o.f()}}else return;return n}}};ua.load=function(c,r){for(var n in Ll.mandatory)if(r.hasOwnProperty(n)){var o=r[n],a=Ll.mandatory[n](o);if(a!==void 0)c[n]=a;else throw new ha.ConfigurationError(n,o)}else throw new ha.ConfigurationError(n);for(var t in Ll.optional)if(r.hasOwnProperty(t)){var s=r[t];if(yn.isEmpty(s))continue;var p=Ll.optional[t](s);if(p!==void 0)c[t]=p;else throw new ha.ConfigurationError(t,s)}};function $l(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?$l=function(n){return typeof n}:$l=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},$l(c)}function cp(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Hc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Fc(c,r,n){return r&&Hc(c.prototype,r),n&&Hc(c,n),c}function fp(c,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&_a(c,r)}function _a(c,r){return _a=Object.setPrototypeOf||function(o,a){return o.__proto__=a,o},_a(c,r)}function hp(c){var r=dp();return function(){var o=Hl(c),a;if(r){var t=Hl(this).constructor;a=Reflect.construct(o,arguments,t)}else a=o.apply(this,arguments);return _p(this,a)}}function _p(c,r){return r&&($l(r)==="object"||typeof r=="function")?r:qc(c)}function qc(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function dp(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Hl(c){return Hl=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},Hl(c)}var pp=ot.EventEmitter,mp=rt,ut=Xe,gp=r_,Vc=_d,jc=Id,Bc=$d,da=Tr,vp=Gd,Fl=Tt(),Tp=ms,Ep=gs(),yp=Oc,pa=ss,Sp=tp,ma=ua,$e=new mp("UA"),ct={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2},Cp=function(c){fp(n,c);var r=hp(n);Fc(n,null,[{key:"C",get:function(){return ct}}]);function n(o){var a;if(cp(this,n),$e.debug("new() [configuration:%o]",o),a=r.call(this),a._cache={credentials:{}},a._configuration=Object.assign({},ma.settings),a._dynConfiguration={},a._dialogs={},a._applicants={},a._sessions={},a._transport=null,a._contact=null,a._status=ct.STATUS_INIT,a._error=null,a._transactions={nist:{},nict:{},ist:{},ict:{}},a._data={},a._closeTimer=null,o===void 0)throw new TypeError("Not enough arguments");try{a._loadConfig(o)}catch(t){throw a._status=ct.STATUS_NOT_READY,a._error=ct.CONFIGURATION_ERROR,t}return a._registrator=new gp(qc(a)),a}return Fc(n,[{key:"start",value:function(){$e.debug("start()"),this._status===ct.STATUS_INIT?this._transport.connect():this._status===ct.STATUS_USER_CLOSED?($e.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=ct.STATUS_INIT,this._transport.connect()):this._status===ct.STATUS_READY?$e.debug("UA is in READY status, not restarted"):$e.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this._dynConfiguration.register=this._configuration.register}},{key:"register",value:function(){$e.debug("register()"),this._dynConfiguration.register=!0,this._registrator.register()}},{key:"unregister",value:function(a){$e.debug("unregister()"),this._dynConfiguration.register=!1,this._registrator.unregister(a)}},{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(a,t){$e.debug("call()");var s=new Vc(this);return s.connect(a,t),s}},{key:"sendMessage",value:function(a,t,s){$e.debug("sendMessage()");var p=new jc(this);return p.send(a,t,s),p}},{key:"sendOptions",value:function(a,t,s){$e.debug("sendOptions()");var p=new Bc(this);return p.send(a,t,s),p}},{key:"terminateSessions",value:function(a){$e.debug("terminateSessions()");for(var t in this._sessions)this._sessions[t].isEnded()||this._sessions[t].terminate(a)}},{key:"stop",value:function(){var a=this;if($e.debug("stop()"),this._dynConfiguration={},this._status===ct.STATUS_USER_CLOSED){$e.debug("UA already closed");return}this._registrator.close();var t=Object.keys(this._sessions).length;for(var s in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,s)){$e.debug("closing session ".concat(s));try{this._sessions[s].terminate()}catch{}}for(var p in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,p))try{this._applicants[p].close()}catch{}this._status=ct.STATUS_USER_CLOSED;var h=Object.keys(this._transactions.nict).length+Object.keys(this._transactions.nist).length+Object.keys(this._transactions.ict).length+Object.keys(this._transactions.ist).length;h===0&&t===0?this._transport.disconnect():this._closeTimer=setTimeout(function(){a._closeTimer=null,a._transport.disconnect()},2e3)}},{key:"normalizeTarget",value:function(a){return Fl.normalizeTarget(a,this._configuration.hostport_params)}},{key:"get",value:function(a){switch(a){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:$e.warn('get() | cannot get "%s" parameter in runtime',a);return}}},{key:"set",value:function(a,t){switch(a){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}default:return $e.warn('set() | cannot set "%s" parameter in runtime',a),!1}return!0}},{key:"newTransaction",value:function(a){this._transactions[a.type][a.id]=a,this.emit("newTransaction",{transaction:a})}},{key:"destroyTransaction",value:function(a){delete this._transactions[a.type][a.id],this.emit("transactionDestroyed",{transaction:a})}},{key:"newDialog",value:function(a){this._dialogs[a.id]=a}},{key:"destroyDialog",value:function(a){delete this._dialogs[a.id]}},{key:"newMessage",value:function(a,t){this._applicants[a]=a,this.emit("newMessage",t)}},{key:"newOptions",value:function(a,t){this._applicants[a]=a,this.emit("newOptions",t)}},{key:"destroyMessage",value:function(a){delete this._applicants[a]}},{key:"newRTCSession",value:function(a,t){this._sessions[a.id]=a,this.emit("newRTCSession",t)}},{key:"destroyRTCSession",value:function(a){delete this._sessions[a.id]}},{key:"registered",value:function(a){this.emit("registered",a)}},{key:"unregistered",value:function(a){this.emit("unregistered",a)}},{key:"registrationFailed",value:function(a){this.emit("registrationFailed",a)}},{key:"receiveRequest",value:function(a){var t=a.method;if(a.ruri.user!==this._configuration.uri.user&&a.ruri.user!==this._contact.uri.user){$e.debug("Request-URI does not point to us"),a.method!==ut.ACK&&a.reply_sl(404);return}if(a.ruri.scheme===ut.SIPS){a.reply_sl(416);return}if(!da.checkTransaction(this,a)){if(t===ut.INVITE?new da.InviteServerTransaction(this,this._transport,a):t!==ut.ACK&&t!==ut.CANCEL&&new da.NonInviteServerTransaction(this,this._transport,a),t===ut.OPTIONS){if(this.listeners("newOptions").length===0){a.reply(200);return}var s=new Bc(this);s.init_incoming(a)}else if(t===ut.MESSAGE){if(this.listeners("newMessage").length===0){a.reply(405);return}var p=new jc(this);p.init_incoming(a)}else if(t===ut.INVITE&&!a.to_tag&&this.listeners("newRTCSession").length===0){a.reply(405);return}var h,d;if(a.to_tag)h=this._findDialog(a.call_id,a.from_tag,a.to_tag),h?h.receiveRequest(a):t===ut.NOTIFY?(d=this._findSession(a),d?d.receiveRequest(a):($e.debug("received NOTIFY request for a non existent subscription"),a.reply(481,"Subscription does not exist"))):t!==ut.ACK&&a.reply(481);else switch(t){case ut.INVITE:if(window.RTCPeerConnection)if(a.hasHeader("replaces")){var g=a.replaces;h=this._findDialog(g.call_id,g.from_tag,g.to_tag),h?(d=h.owner,d.isEnded()?a.reply(603):d.receiveRequest(a)):a.reply(481)}else d=new Vc(this),d.init_incoming(a);else $e.warn("INVITE received but WebRTC is not supported"),a.reply(488);break;case ut.BYE:a.reply(481);break;case ut.CANCEL:d=this._findSession(a),d?d.receiveRequest(a):$e.debug("received CANCEL request for a non existent session");break;case ut.ACK:break;case ut.NOTIFY:this.emit("sipEvent",{event:a.event,request:a}),a.reply(200);break;default:a.reply(405);break}}}},{key:"_findSession",value:function(a){var t=a.call_id,s=a.from_tag,p=a.to_tag,h=t+s,d=this._sessions[h],g=t+p,v=this._sessions[g];return d||v||null}},{key:"_findDialog",value:function(a,t,s){var p=a+t+s,h=this._dialogs[p];return h||(p=a+s+t,h=this._dialogs[p],h||null)}},{key:"_loadConfig",value:function(a){try{ma.load(this._configuration,a)}catch(g){throw g}this._configuration.display_name===0&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=Fl.newUUID()),this._configuration.jssip_id=Fl.createRandomToken(5);var t=this._configuration.uri.clone();t.user=null,this._configuration.hostport_params=t.toString().replace(/^sip:/i,"");try{this._transport=new vp(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=Ap.bind(this),this._transport.onconnect=Rp.bind(this),this._transport.ondisconnect=Ip.bind(this),this._transport.ondata=bp.bind(this)}catch(g){throw $e.warn(g),new Tp.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 s=this._configuration.uri.clone();s.user=null,s.clearParams(),s.clearHeaders(),this._configuration.registrar_server=s}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new Ep("sip",Fl.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 v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},E=v.anonymous||null,S=v.outbound||null,C="<";return E?C+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":C+=this.pub_gruu||this.uri.toString(),S&&(E?!this.temp_gruu:!this.pub_gruu)&&(C+=";ob"),C+=">",C}};var p=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register"];for(var h in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,h)&&(p.indexOf(h)!==-1?Object.defineProperty(this._configuration,h,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,h,{writable:!1,configurable:!1}));$e.debug("configuration parameters after validation:");for(var d in this._configuration)if(Object.prototype.hasOwnProperty.call(ma.settings,d))switch(d){case"uri":case"registrar_server":$e.debug("- ".concat(d,": ").concat(this._configuration[d]));break;case"password":case"ha1":case"authorization_jwt":$e.debug("- ".concat(d,": NOT SHOWN"));break;default:$e.debug("- ".concat(d,": ").concat(JSON.stringify(this._configuration[d])))}}},{key:"C",get:function(){return ct}},{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}(pp);function Ap(c){this.emit("connecting",c)}function Rp(c){this._status!==ct.STATUS_USER_CLOSED&&(this._status=ct.STATUS_READY,this._error=null,this.emit("connected",c),this._dynConfiguration.register&&this._registrator.register())}function Ip(c){for(var r=["nict","ict","nist","ist"],n=0,o=r;n<o.length;n++){var a=o[n];for(var t in this._transactions[a])Object.prototype.hasOwnProperty.call(this._transactions[a],t)&&this._transactions[a][t].onTransportError()}this.emit("disconnected",c),this._registrator.onTransportClosed(),this._status!==ct.STATUS_USER_CLOSED&&(this._status=ct.STATUS_NOT_READY,this._error=ct.NETWORK_ERROR)}function bp(c){var r=c.transport,n=c.message;if(n=yp.parseMessage(n,this),!!n&&!(this._status===ct.STATUS_USER_CLOSED&&n instanceof pa.IncomingRequest)&&Sp(n,this,r)){if(n instanceof pa.IncomingRequest)n.transport=r,this.receiveRequest(n);else if(n instanceof pa.IncomingResponse){var o;switch(n.method){case ut.INVITE:o=this._transactions.ict[n.via_branch],o&&o.receiveResponse(n);break;case ut.ACK:break;default:o=this._transactions.nict[n.via_branch],o&&o.receiveResponse(n);break}}}}function wp(c,r){if(!(c instanceof r))throw new TypeError("Cannot call a class as a function")}function Gc(c,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(c,o.key,o)}}function Op(c,r,n){return r&&Gc(c.prototype,r),n&&Gc(c,n),c}var Dp=rt,Np=Vt(),St=new Dp("WebSocketInterface"),Up=function(){function c(r){wp(this,c),St.debug('new() [url:"%s"]',r),this._url=r,this._sip_uri=null,this._via_transport=null,this._ws=null;var n=Np.parse(r,"absoluteURI");if(n===-1)throw St.warn("invalid WebSocket URI: ".concat(r)),new TypeError("Invalid argument: ".concat(r));if(n.scheme!=="wss"&&n.scheme!=="ws")throw St.warn("invalid WebSocket URI scheme: ".concat(n.scheme)),new TypeError("Invalid argument: ".concat(r));this._sip_uri="sip:".concat(n.host).concat(n.port?":".concat(n.port):"",";transport=ws"),this._via_transport=n.scheme.toUpperCase()}return Op(c,[{key:"connect",value:function(){if(St.debug("connect()"),this.isConnected()){St.debug("WebSocket ".concat(this._url," is already connected"));return}else if(this.isConnecting()){St.debug("WebSocket ".concat(this._url," is connecting"));return}this._ws&&this.disconnect(),St.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(n){this._onError(n)}}},{key:"disconnect",value:function(){St.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(n){return St.debug("send()"),this.isConnected()?(this._ws.send(n),!0):(St.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(){St.debug("WebSocket ".concat(this._url," connected")),this.onconnect()}},{key:"_onClose",value:function(n){var o=n.wasClean,a=n.code,t=n.reason;St.debug("WebSocket ".concat(this._url," closed")),o===!1&&St.debug("WebSocket abrupt disconnection"),this.ondisconnect(!o,a,t)}},{key:"_onMessage",value:function(n){var o=n.data;St.debug("received WebSocket message"),this.ondata(o)}},{key:"_onError",value:function(n){St.warn("WebSocket ".concat(this._url," error: "),n)}},{key:"via_transport",get:function(){return this._via_transport},set:function(n){this._via_transport=n.toUpperCase()}},{key:"sip_uri",get:function(){return this._sip_uri}},{key:"url",get:function(){return this._url}}]),c}(),ga=sl,Pp=Xe,kp=ms,Mp=Tt(),xp=Cp,Lp=gs(),$p=wo(),Hp=Vt(),Fp=Up,qp=vn("JsSIP");qp("version %s",ga.version);var Kc={C:Pp,Exceptions:kp,Utils:Mp,UA:xp,URI:Lp,NameAddrHeader:$p,WebSocketInterface:Fp,Grammar:Hp,debug:vn,get name(){return ga.title},get version(){return ga.version}};const Sn=vn,Cn="JsSIP";var it=class{constructor(r){r?(this._debug=Sn.default(`${Cn}:${r}`),this._warn=Sn.default(`${Cn}:WARN:${r}`),this._error=Sn.default(`${Cn}:ERROR:${r}`)):(this._debug=Sn.default(Cn),this._warn=Sn.default(`${Cn}:WARN`),this._error=Sn.default(`${Cn}:ERROR`)),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}get debug(){return this._debug}get warn(){return this._warn}get error(){return this._error}};const Wc=sl;var we={USER_AGENT:`${Wc.title} ${Wc.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};const Ie=vt(we);var ze={},va,Yc;function Ta(){if(Yc)return va;Yc=1;const c=ls(),r=Gt();return va=class th{static parse(o){if(o=r.parse(o,"Name_Addr_Header"),o!==-1)return o}constructor(o,a,t){if(!o||!(o instanceof c))throw new TypeError('missing or invalid "uri" parameter');this._uri=o,this._parameters={},this.display_name=a;for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&this.setParam(s,t[s])}get uri(){return this._uri}get display_name(){return this._display_name}set display_name(o){this._display_name=o===0?"0":o}setParam(o,a){o&&(this._parameters[o.toLowerCase()]=typeof a>"u"||a===null?null:a.toString())}getParam(o){if(o)return this._parameters[o.toLowerCase()]}hasParam(o){if(o)return this._parameters.hasOwnProperty(o.toLowerCase())&&!0||!1}deleteParam(o){if(o=o.toLowerCase(),this._parameters.hasOwnProperty(o)){const a=this._parameters[o];return delete this._parameters[o],a}}clearParams(){this._parameters={}}clone(){return new th(this._uri.clone(),this._display_name,JSON.parse(JSON.stringify(this._parameters)))}_quote(o){return o.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}toString(){let o=this._display_name?`"${this._quote(this._display_name)}" `:"";o+=`<${this._uri.toString()}>`;for(const a in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,a)&&(o+=`;${a}`,this._parameters[a]!==null&&(o+=`=${this._parameters[a]}`));return o}},va}var Ea,zc;function Gt(){return zc||(zc=1,Ea=function(){function c(n){return'"'+n.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 r={parse:function(n,o){var a={CRLF:d,DIGIT:g,ALPHA:v,HEXDIG:E,WSP:S,OCTET:C,DQUOTE:I,SP:w,HTAB:F,alphanum:L,reserved:ie,unreserved:N,mark:H,escaped:ve,LWS:me,SWS:M,HCOLON:D,TEXT_UTF8_TRIM:j,TEXT_UTF8char:V,UTF8_NONASCII:Y,UTF8_CONT:$,LHEX:X,token:U,token_nodot:P,separators:Z,word:et,STAR:Q,SLASH:W,EQUAL:B,LPAREN:te,RPAREN:de,RAQUOT:Ae,LAQUOT:Ue,COMMA:Se,SEMI:ne,COLON:Te,LDQUOT:tt,RDQUOT:st,comment:ge,ctext:Ee,quoted_string:Ce,quoted_string_clean:be,qdtext:he,quoted_pair:ce,SIP_URI_noparams:fe,SIP_URI:Re,uri_scheme:Oe,uri_scheme_sips:Je,uri_scheme_sip:Me,userinfo:Pt,user:gt,user_unreserved:On,password:Dn,hostport:zs,host:Qt,hostname:_s,domainlabel:Js,toplabel:Nn,IPv6reference:Un,IPv6address:Xs,h16:_e,ls32:re,IPv4address:nt,dec_octet:qt,port:Is,uri_parameters:Kr,uri_parameter:Pn,transport_param:kn,user_param:Wr,method_param:Yr,ttl_param:zr,maddr_param:Jr,lr_param:Xr,other_param:Qr,pname:Zr,pvalue:ei,paramchar:bs,param_unreserved:ws,headers:ti,header:Qs,hname:Zs,hvalue:si,hnv_unreserved:Os,Request_Response:en,Request_Line:ro,Request_URI:ni,absoluteURI:Mn,hier_part:xn,net_path:ri,abs_path:tn,opaque_part:sn,uric:Ds,uric_no_slash:Ns,path_segments:ii,segment:nn,param:Us,pchar:ds,scheme:Ps,authority:li,srvr:oi,reg_name:ai,query:ui,SIP_Version:Ln,INVITEm:$n,ACKm:ci,OPTIONSm:fi,BYEm:hi,CANCELm:_i,REGISTERm:di,SUBSCRIBEm:pi,NOTIFYm:mi,REFERm:gi,Method:rn,Status_Line:ln,Status_Code:vi,extension_code:Ti,Reason_Phrase:Ei,Allow_Events:io,Call_ID:tu,Contact:su,contact_param:Hn,name_addr:kt,display_name:Mt,contact_params:ks,c_p_q:Fn,c_p_expires:yi,delta_seconds:Zt,qvalue:es,generic_param:Ge,gen_value:Ke,Content_Disposition:lo,disp_type:oo,disp_param:qn,handling_param:Vn,Content_Encoding:ao,Content_Length:nu,Content_Type:ru,media_type:uo,m_type:Si,discrete_type:Ci,composite_type:Ai,extension_token:on,x_token:an,m_subtype:Ri,m_parameter:jn,m_value:Bn,CSeq:co,CSeq_value:fo,Expires:ho,Event:iu,event_type:un,From:cn,from_param:Ii,tag_param:fn,Max_Forwards:bi,Min_Expires:lu,Name_Addr_Header:ou,Proxy_Authenticate:au,challenge:wi,other_challenge:Gn,auth_param:Ms,digest_cln:ts,realm:hn,realm_value:Oi,domain:Di,URI:_n,nonce:dn,nonce_value:Ni,opaque:Ui,stale:Pi,algorithm:ki,qop_options:Mi,qop_value:pn,Proxy_Require:Kn,Record_Route:uu,rec_route:Wn,Reason:Yn,reason_param:xi,reason_cause:zn,Require:_o,Route:cu,route_param:Jn,Subscription_State:Xn,substate_value:po,subexp_params:Qn,event_reason_value:Zn,Subject:mo,Supported:fu,To:hu,to_param:Li,Via:$i,via_param:er,via_params:xs,via_ttl:tr,via_maddr:Hi,via_received:Fi,via_branch:qi,response_port:Vi,rport:ji,sent_protocol:Bi,protocol_name:Gi,transport:Ki,sent_by:Wi,via_host:Yi,via_port:zi,ttl:sr,WWW_Authenticate:Ji,Session_Expires:_u,s_e_expires:go,s_e_params:nr,s_e_refresher:rr,extension_header:vo,header_value:To,message_body:Eo,uuid_URI:du,uuid:yo,hex4:xt,hex8:Lt,hex12:Xi,Refer_To:So,Replaces:pu,call_id:Co,replaces_param:ir,to_tag:lr,from_tag:Qi,early_flag:Zi};if(o!==void 0){if(a[o]===void 0)throw new Error("Invalid rule name: "+c(o)+".")}else o="CRLF";var t=0,s=0,p=[];function h(i){t<s||(t>s&&(s=t,p=[]),p.push(i))}function d(){var i;return n.substr(t,2)===`\r
|
73
73
|
`?(i=`\r
|
74
|
-
`,t+=2):(i=null,h('"\\r\\n"')),i}function g(){var i;return/^[0-9]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[0-9]")),i}function v(){var i;return/^[a-zA-Z]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[a-zA-Z]")),i}function E(){var i;return/^[0-9a-fA-F]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[0-9a-fA-F]")),i}function S(){var i;return i=w(),i===null&&(i=F()),i}function C(){var i;return/^[\0-\xFF]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[\\0-\\xFF]")),i}function I(){var i;return/^["]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h('["]')),i}function w(){var i;return n.charCodeAt(t)===32?(i=" ",t++):(i=null,h('" "')),i}function F(){var i;return n.charCodeAt(t)===9?(i=" ",t++):(i=null,h('"\\t"')),i}function L(){var i;return/^[a-zA-Z0-9]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[a-zA-Z0-9]")),i}function ie(){var i;return n.charCodeAt(t)===59?(i=";",t++):(i=null,h('";"')),i===null&&(n.charCodeAt(t)===47?(i="/",t++):(i=null,h('"/"')),i===null&&(n.charCodeAt(t)===63?(i="?",t++):(i=null,h('"?"')),i===null&&(n.charCodeAt(t)===58?(i=":",t++):(i=null,h('":"')),i===null&&(n.charCodeAt(t)===64?(i="@",t++):(i=null,h('"@"')),i===null&&(n.charCodeAt(t)===38?(i="&",t++):(i=null,h('"&"')),i===null&&(n.charCodeAt(t)===61?(i="=",t++):(i=null,h('"="')),i===null&&(n.charCodeAt(t)===43?(i="+",t++):(i=null,h('"+"')),i===null&&(n.charCodeAt(t)===36?(i="$",t++):(i=null,h('"$"')),i===null&&(n.charCodeAt(t)===44?(i=",",t++):(i=null,h('","'))))))))))),i}function N(){var i;return i=L(),i===null&&(i=H()),i}function H(){var i;return n.charCodeAt(t)===45?(i="-",t++):(i=null,h('"-"')),i===null&&(n.charCodeAt(t)===95?(i="_",t++):(i=null,h('"_"')),i===null&&(n.charCodeAt(t)===46?(i=".",t++):(i=null,h('"."')),i===null&&(n.charCodeAt(t)===33?(i="!",t++):(i=null,h('"!"')),i===null&&(n.charCodeAt(t)===126?(i="~",t++):(i=null,h('"~"')),i===null&&(n.charCodeAt(t)===42?(i="*",t++):(i=null,h('"*"')),i===null&&(n.charCodeAt(t)===39?(i="'",t++):(i=null,h(`"'"`)),i===null&&(n.charCodeAt(t)===40?(i="(",t++):(i=null,h('"("')),i===null&&(n.charCodeAt(t)===41?(i=")",t++):(i=null,h('")"')))))))))),i}function ve(){var i,e,l,u,f;return u=t,f=t,n.charCodeAt(t)===37?(i="%",t++):(i=null,h('"%"')),i!==null?(e=E(),e!==null?(l=E(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){return m.join("")}(u,i)),i===null&&(t=u),i}function me(){var i,e,l,u,f,_;for(u=t,f=t,_=t,i=[],e=S();e!==null;)i.push(e),e=S();if(i!==null?(e=d(),e!==null?i=[i,e]:(i=null,t=_)):(i=null,t=_),i=i!==null?i:"",i!==null){if(l=S(),l!==null)for(e=[];l!==null;)e.push(l),l=S();else e=null;e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i!==null&&(i=function(m){return" "}()),i===null&&(t=u),i}function M(){var i;return i=me(),i=i!==null?i:"",i}function D(){var i,e,l,u,f;for(u=t,f=t,i=[],e=w(),e===null&&(e=F());e!==null;)i.push(e),e=w(),e===null&&(e=F());return i!==null?(n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_){return":"}()),i===null&&(t=u),i}function j(){var i,e,l,u,f,_,m;if(f=t,_=t,e=V(),e!==null)for(i=[];e!==null;)i.push(e),e=V();else i=null;if(i!==null){for(e=[],m=t,l=[],u=me();u!==null;)l.push(u),u=me();for(l!==null?(u=V(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;){for(e.push(l),m=t,l=[],u=me();u!==null;)l.push(u),u=me();l!==null?(u=V(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m)}e!==null?i=[i,e]:(i=null,t=_)}else i=null,t=_;return i!==null&&(i=function(T){return n.substring(t,T)}(f)),i===null&&(t=f),i}function V(){var i;return/^[!-~]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[!-~]")),i===null&&(i=Y()),i}function Y(){var i;return/^[\x80-\uFFFF]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[\\x80-\\uFFFF]")),i}function $(){var i;return/^[\x80-\xBF]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[\\x80-\\xBF]")),i}function X(){var i;return i=g(),i===null&&(/^[a-f]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[a-f]"))),i}function U(){var i,e,l;if(l=t,e=L(),e===null&&(n.charCodeAt(t)===45?(e="-",t++):(e=null,h('"-"')),e===null&&(n.charCodeAt(t)===46?(e=".",t++):(e=null,h('"."')),e===null&&(n.charCodeAt(t)===33?(e="!",t++):(e=null,h('"!"')),e===null&&(n.charCodeAt(t)===37?(e="%",t++):(e=null,h('"%"')),e===null&&(n.charCodeAt(t)===42?(e="*",t++):(e=null,h('"*"')),e===null&&(n.charCodeAt(t)===95?(e="_",t++):(e=null,h('"_"')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,h('"+"')),e===null&&(n.charCodeAt(t)===96?(e="`",t++):(e=null,h('"`"')),e===null&&(n.charCodeAt(t)===39?(e="'",t++):(e=null,h(`"'"`)),e===null&&(n.charCodeAt(t)===126?(e="~",t++):(e=null,h('"~"')))))))))))),e!==null)for(i=[];e!==null;)i.push(e),e=L(),e===null&&(n.charCodeAt(t)===45?(e="-",t++):(e=null,h('"-"')),e===null&&(n.charCodeAt(t)===46?(e=".",t++):(e=null,h('"."')),e===null&&(n.charCodeAt(t)===33?(e="!",t++):(e=null,h('"!"')),e===null&&(n.charCodeAt(t)===37?(e="%",t++):(e=null,h('"%"')),e===null&&(n.charCodeAt(t)===42?(e="*",t++):(e=null,h('"*"')),e===null&&(n.charCodeAt(t)===95?(e="_",t++):(e=null,h('"_"')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,h('"+"')),e===null&&(n.charCodeAt(t)===96?(e="`",t++):(e=null,h('"`"')),e===null&&(n.charCodeAt(t)===39?(e="'",t++):(e=null,h(`"'"`)),e===null&&(n.charCodeAt(t)===126?(e="~",t++):(e=null,h('"~"'))))))))))));else i=null;return i!==null&&(i=function(u){return n.substring(t,u)}(l)),i===null&&(t=l),i}function P(){var i,e,l;if(l=t,e=L(),e===null&&(n.charCodeAt(t)===45?(e="-",t++):(e=null,h('"-"')),e===null&&(n.charCodeAt(t)===33?(e="!",t++):(e=null,h('"!"')),e===null&&(n.charCodeAt(t)===37?(e="%",t++):(e=null,h('"%"')),e===null&&(n.charCodeAt(t)===42?(e="*",t++):(e=null,h('"*"')),e===null&&(n.charCodeAt(t)===95?(e="_",t++):(e=null,h('"_"')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,h('"+"')),e===null&&(n.charCodeAt(t)===96?(e="`",t++):(e=null,h('"`"')),e===null&&(n.charCodeAt(t)===39?(e="'",t++):(e=null,h(`"'"`)),e===null&&(n.charCodeAt(t)===126?(e="~",t++):(e=null,h('"~"'))))))))))),e!==null)for(i=[];e!==null;)i.push(e),e=L(),e===null&&(n.charCodeAt(t)===45?(e="-",t++):(e=null,h('"-"')),e===null&&(n.charCodeAt(t)===33?(e="!",t++):(e=null,h('"!"')),e===null&&(n.charCodeAt(t)===37?(e="%",t++):(e=null,h('"%"')),e===null&&(n.charCodeAt(t)===42?(e="*",t++):(e=null,h('"*"')),e===null&&(n.charCodeAt(t)===95?(e="_",t++):(e=null,h('"_"')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,h('"+"')),e===null&&(n.charCodeAt(t)===96?(e="`",t++):(e=null,h('"`"')),e===null&&(n.charCodeAt(t)===39?(e="'",t++):(e=null,h(`"'"`)),e===null&&(n.charCodeAt(t)===126?(e="~",t++):(e=null,h('"~"')))))))))));else i=null;return i!==null&&(i=function(u){return n.substring(t,u)}(l)),i===null&&(t=l),i}function Z(){var i;return n.charCodeAt(t)===40?(i="(",t++):(i=null,h('"("')),i===null&&(n.charCodeAt(t)===41?(i=")",t++):(i=null,h('")"')),i===null&&(n.charCodeAt(t)===60?(i="<",t++):(i=null,h('"<"')),i===null&&(n.charCodeAt(t)===62?(i=">",t++):(i=null,h('">"')),i===null&&(n.charCodeAt(t)===64?(i="@",t++):(i=null,h('"@"')),i===null&&(n.charCodeAt(t)===44?(i=",",t++):(i=null,h('","')),i===null&&(n.charCodeAt(t)===59?(i=";",t++):(i=null,h('";"')),i===null&&(n.charCodeAt(t)===58?(i=":",t++):(i=null,h('":"')),i===null&&(n.charCodeAt(t)===92?(i="\\",t++):(i=null,h('"\\\\"')),i===null&&(i=I(),i===null&&(n.charCodeAt(t)===47?(i="/",t++):(i=null,h('"/"')),i===null&&(n.charCodeAt(t)===91?(i="[",t++):(i=null,h('"["')),i===null&&(n.charCodeAt(t)===93?(i="]",t++):(i=null,h('"]"')),i===null&&(n.charCodeAt(t)===63?(i="?",t++):(i=null,h('"?"')),i===null&&(n.charCodeAt(t)===61?(i="=",t++):(i=null,h('"="')),i===null&&(n.charCodeAt(t)===123?(i="{",t++):(i=null,h('"{"')),i===null&&(n.charCodeAt(t)===125?(i="}",t++):(i=null,h('"}"')),i===null&&(i=w(),i===null&&(i=F())))))))))))))))))),i}function et(){var i,e,l;if(l=t,e=L(),e===null&&(n.charCodeAt(t)===45?(e="-",t++):(e=null,h('"-"')),e===null&&(n.charCodeAt(t)===46?(e=".",t++):(e=null,h('"."')),e===null&&(n.charCodeAt(t)===33?(e="!",t++):(e=null,h('"!"')),e===null&&(n.charCodeAt(t)===37?(e="%",t++):(e=null,h('"%"')),e===null&&(n.charCodeAt(t)===42?(e="*",t++):(e=null,h('"*"')),e===null&&(n.charCodeAt(t)===95?(e="_",t++):(e=null,h('"_"')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,h('"+"')),e===null&&(n.charCodeAt(t)===96?(e="`",t++):(e=null,h('"`"')),e===null&&(n.charCodeAt(t)===39?(e="'",t++):(e=null,h(`"'"`)),e===null&&(n.charCodeAt(t)===126?(e="~",t++):(e=null,h('"~"')),e===null&&(n.charCodeAt(t)===40?(e="(",t++):(e=null,h('"("')),e===null&&(n.charCodeAt(t)===41?(e=")",t++):(e=null,h('")"')),e===null&&(n.charCodeAt(t)===60?(e="<",t++):(e=null,h('"<"')),e===null&&(n.charCodeAt(t)===62?(e=">",t++):(e=null,h('">"')),e===null&&(n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e===null&&(n.charCodeAt(t)===92?(e="\\",t++):(e=null,h('"\\\\"')),e===null&&(e=I(),e===null&&(n.charCodeAt(t)===47?(e="/",t++):(e=null,h('"/"')),e===null&&(n.charCodeAt(t)===91?(e="[",t++):(e=null,h('"["')),e===null&&(n.charCodeAt(t)===93?(e="]",t++):(e=null,h('"]"')),e===null&&(n.charCodeAt(t)===63?(e="?",t++):(e=null,h('"?"')),e===null&&(n.charCodeAt(t)===123?(e="{",t++):(e=null,h('"{"')),e===null&&(n.charCodeAt(t)===125?(e="}",t++):(e=null,h('"}"'))))))))))))))))))))))))),e!==null)for(i=[];e!==null;)i.push(e),e=L(),e===null&&(n.charCodeAt(t)===45?(e="-",t++):(e=null,h('"-"')),e===null&&(n.charCodeAt(t)===46?(e=".",t++):(e=null,h('"."')),e===null&&(n.charCodeAt(t)===33?(e="!",t++):(e=null,h('"!"')),e===null&&(n.charCodeAt(t)===37?(e="%",t++):(e=null,h('"%"')),e===null&&(n.charCodeAt(t)===42?(e="*",t++):(e=null,h('"*"')),e===null&&(n.charCodeAt(t)===95?(e="_",t++):(e=null,h('"_"')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,h('"+"')),e===null&&(n.charCodeAt(t)===96?(e="`",t++):(e=null,h('"`"')),e===null&&(n.charCodeAt(t)===39?(e="'",t++):(e=null,h(`"'"`)),e===null&&(n.charCodeAt(t)===126?(e="~",t++):(e=null,h('"~"')),e===null&&(n.charCodeAt(t)===40?(e="(",t++):(e=null,h('"("')),e===null&&(n.charCodeAt(t)===41?(e=")",t++):(e=null,h('")"')),e===null&&(n.charCodeAt(t)===60?(e="<",t++):(e=null,h('"<"')),e===null&&(n.charCodeAt(t)===62?(e=">",t++):(e=null,h('">"')),e===null&&(n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e===null&&(n.charCodeAt(t)===92?(e="\\",t++):(e=null,h('"\\\\"')),e===null&&(e=I(),e===null&&(n.charCodeAt(t)===47?(e="/",t++):(e=null,h('"/"')),e===null&&(n.charCodeAt(t)===91?(e="[",t++):(e=null,h('"["')),e===null&&(n.charCodeAt(t)===93?(e="]",t++):(e=null,h('"]"')),e===null&&(n.charCodeAt(t)===63?(e="?",t++):(e=null,h('"?"')),e===null&&(n.charCodeAt(t)===123?(e="{",t++):(e=null,h('"{"')),e===null&&(n.charCodeAt(t)===125?(e="}",t++):(e=null,h('"}"')))))))))))))))))))))))));else i=null;return i!==null&&(i=function(u){return n.substring(t,u)}(l)),i===null&&(t=l),i}function Q(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(n.charCodeAt(t)===42?(e="*",t++):(e=null,h('"*"')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_){return"*"}()),i===null&&(t=u),i}function W(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(n.charCodeAt(t)===47?(e="/",t++):(e=null,h('"/"')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_){return"/"}()),i===null&&(t=u),i}function B(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(n.charCodeAt(t)===61?(e="=",t++):(e=null,h('"="')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_){return"="}()),i===null&&(t=u),i}function te(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(n.charCodeAt(t)===40?(e="(",t++):(e=null,h('"("')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_){return"("}()),i===null&&(t=u),i}function de(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(n.charCodeAt(t)===41?(e=")",t++):(e=null,h('")"')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_){return")"}()),i===null&&(t=u),i}function Ae(){var i,e,l,u;return l=t,u=t,n.charCodeAt(t)===62?(i=">",t++):(i=null,h('">"')),i!==null?(e=M(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f){return">"}()),i===null&&(t=l),i}function Ue(){var i,e,l,u;return l=t,u=t,i=M(),i!==null?(n.charCodeAt(t)===60?(e="<",t++):(e=null,h('"<"')),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f){return"<"}()),i===null&&(t=l),i}function Se(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(n.charCodeAt(t)===44?(e=",",t++):(e=null,h('","')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_){return","}()),i===null&&(t=u),i}function ne(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(n.charCodeAt(t)===59?(e=";",t++):(e=null,h('";"')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_){return";"}()),i===null&&(t=u),i}function Te(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_){return":"}()),i===null&&(t=u),i}function tt(){var i,e,l,u;return l=t,u=t,i=M(),i!==null?(e=I(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f){return'"'}()),i===null&&(t=l),i}function st(){var i,e,l,u;return l=t,u=t,i=I(),i!==null?(e=M(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f){return'"'}()),i===null&&(t=l),i}function ge(){var i,e,l,u;if(u=t,i=te(),i!==null){for(e=[],l=Ee(),l===null&&(l=ce(),l===null&&(l=ge()));l!==null;)e.push(l),l=Ee(),l===null&&(l=ce(),l===null&&(l=ge()));e!==null?(l=de(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)}else i=null,t=u;return i}function Ee(){var i;return/^[!-']/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[!-']")),i===null&&(/^[*-[]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[*-[]")),i===null&&(/^[\]-~]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[\\]-~]")),i===null&&(i=Y(),i===null&&(i=me())))),i}function Ce(){var i,e,l,u,f,_;if(f=t,_=t,i=M(),i!==null)if(e=I(),e!==null){for(l=[],u=he(),u===null&&(u=ce());u!==null;)l.push(u),u=he(),u===null&&(u=ce());l!==null?(u=I(),u!==null?i=[i,e,l,u]:(i=null,t=_)):(i=null,t=_)}else i=null,t=_;else i=null,t=_;return i!==null&&(i=function(m){return n.substring(t,m)}(f)),i===null&&(t=f),i}function be(){var i,e,l,u,f,_;if(f=t,_=t,i=M(),i!==null)if(e=I(),e!==null){for(l=[],u=he(),u===null&&(u=ce());u!==null;)l.push(u),u=he(),u===null&&(u=ce());l!==null?(u=I(),u!==null?i=[i,e,l,u]:(i=null,t=_)):(i=null,t=_)}else i=null,t=_;else i=null,t=_;return i!==null&&(i=function(m){var T=n.substring(t,m).trim();return T.substring(1,T.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(f)),i===null&&(t=f),i}function he(){var i;return i=me(),i===null&&(n.charCodeAt(t)===33?(i="!",t++):(i=null,h('"!"')),i===null&&(/^[#-[]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[#-[]")),i===null&&(/^[\]-~]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[\\]-~]")),i===null&&(i=Y())))),i}function ce(){var i,e,l;return l=t,n.charCodeAt(t)===92?(i="\\",t++):(i=null,h('"\\\\"')),i!==null?(/^[\0-\t]/.test(n.charAt(t))?(e=n.charAt(t),t++):(e=null,h("[\\0-\\t]")),e===null&&(/^[\x0B-\f]/.test(n.charAt(t))?(e=n.charAt(t),t++):(e=null,h("[\\x0B-\\f]")),e===null&&(/^[\x0E-]/.test(n.charAt(t))?(e=n.charAt(t),t++):(e=null,h("[\\x0E-]")))),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function fe(){var i,e,l,u,f,_;return f=t,_=t,i=Oe(),i!==null?(n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=Pt(),l=l!==null?l:"",l!==null?(u=zs(),u!==null?i=[i,e,l,u]:(i=null,t=_)):(i=null,t=_)):(i=null,t=_)):(i=null,t=_),i!==null&&(i=function(m){try{R.uri=new Ro(R.scheme,R.user,R.host,R.port),delete R.scheme,delete R.user,delete R.host,delete R.host_type,delete R.port}catch{R=-1}}()),i===null&&(t=f),i}function Re(){var i,e,l,u,f,_,m,T;return m=t,T=t,i=Oe(),i!==null?(n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=Pt(),l=l!==null?l:"",l!==null?(u=zs(),u!==null?(f=Kr(),f!==null?(_=ti(),_=_!==null?_:"",_!==null?i=[i,e,l,u,f,_]:(i=null,t=T)):(i=null,t=T)):(i=null,t=T)):(i=null,t=T)):(i=null,t=T)):(i=null,t=T),i!==null&&(i=function(y){try{R.uri=new Ro(R.scheme,R.user,R.host,R.port,R.uri_params,R.uri_headers),delete R.scheme,delete R.user,delete R.host,delete R.host_type,delete R.port,delete R.uri_params,o==="SIP_URI"&&(R=R.uri)}catch{R=-1}}()),i===null&&(t=m),i}function Oe(){var i;return i=Je(),i===null&&(i=Me()),i}function Je(){var i,e;return e=t,n.substr(t,4).toLowerCase()==="sips"?(i=n.substr(t,4),t+=4):(i=null,h('"sips"')),i!==null&&(i=function(l,u){R.scheme=u.toLowerCase()}(e,i)),i===null&&(t=e),i}function Me(){var i,e;return e=t,n.substr(t,3).toLowerCase()==="sip"?(i=n.substr(t,3),t+=3):(i=null,h('"sip"')),i!==null&&(i=function(l,u){R.scheme=u.toLowerCase()}(e,i)),i===null&&(t=e),i}function Pt(){var i,e,l,u,f,_;return u=t,f=t,i=gt(),i!==null?(_=t,n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=Dn(),l!==null?e=[e,l]:(e=null,t=_)):(e=null,t=_),e=e!==null?e:"",e!==null?(n.charCodeAt(t)===64?(l="@",t++):(l=null,h('"@"')),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m){R.user=decodeURIComponent(n.substring(t-1,m))}(u)),i===null&&(t=u),i}function gt(){var i,e;if(e=N(),e===null&&(e=ve(),e===null&&(e=On())),e!==null)for(i=[];e!==null;)i.push(e),e=N(),e===null&&(e=ve(),e===null&&(e=On()));else i=null;return i}function On(){var i;return n.charCodeAt(t)===38?(i="&",t++):(i=null,h('"&"')),i===null&&(n.charCodeAt(t)===61?(i="=",t++):(i=null,h('"="')),i===null&&(n.charCodeAt(t)===43?(i="+",t++):(i=null,h('"+"')),i===null&&(n.charCodeAt(t)===36?(i="$",t++):(i=null,h('"$"')),i===null&&(n.charCodeAt(t)===44?(i=",",t++):(i=null,h('","')),i===null&&(n.charCodeAt(t)===59?(i=";",t++):(i=null,h('";"')),i===null&&(n.charCodeAt(t)===63?(i="?",t++):(i=null,h('"?"')),i===null&&(n.charCodeAt(t)===47?(i="/",t++):(i=null,h('"/"'))))))))),i}function Dn(){var i,e,l;for(l=t,i=[],e=N(),e===null&&(e=ve(),e===null&&(n.charCodeAt(t)===38?(e="&",t++):(e=null,h('"&"')),e===null&&(n.charCodeAt(t)===61?(e="=",t++):(e=null,h('"="')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,h('"+"')),e===null&&(n.charCodeAt(t)===36?(e="$",t++):(e=null,h('"$"')),e===null&&(n.charCodeAt(t)===44?(e=",",t++):(e=null,h('","'))))))));e!==null;)i.push(e),e=N(),e===null&&(e=ve(),e===null&&(n.charCodeAt(t)===38?(e="&",t++):(e=null,h('"&"')),e===null&&(n.charCodeAt(t)===61?(e="=",t++):(e=null,h('"="')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,h('"+"')),e===null&&(n.charCodeAt(t)===36?(e="$",t++):(e=null,h('"$"')),e===null&&(n.charCodeAt(t)===44?(e=",",t++):(e=null,h('","'))))))));return i!==null&&(i=function(u){R.password=n.substring(t,u)}(l)),i===null&&(t=l),i}function zs(){var i,e,l,u,f;return u=t,i=Xt(),i!==null?(f=t,n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=Rs(),l!==null?e=[e,l]:(e=null,t=f)):(e=null,t=f),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i}function Xt(){var i,e;return e=t,i=hs(),i===null&&(i=nt(),i===null&&(i=Un())),i!==null&&(i=function(l){return R.host=n.substring(t,l).toLowerCase(),R.host}(e)),i===null&&(t=e),i}function hs(){var i,e,l,u,f,_;for(u=t,f=t,i=[],_=t,e=Js(),e!==null?(n.charCodeAt(t)===46?(l=".",t++):(l=null,h('"."')),l!==null?e=[e,l]:(e=null,t=_)):(e=null,t=_);e!==null;)i.push(e),_=t,e=Js(),e!==null?(n.charCodeAt(t)===46?(l=".",t++):(l=null,h('"."')),l!==null?e=[e,l]:(e=null,t=_)):(e=null,t=_);return i!==null?(e=Nn(),e!==null?(n.charCodeAt(t)===46?(l=".",t++):(l=null,h('"."')),l=l!==null?l:"",l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m){return R.host_type="domain",n.substring(t,m)}(u)),i===null&&(t=u),i}function Js(){var i,e,l,u;if(u=t,i=L(),i!==null){for(e=[],l=L(),l===null&&(n.charCodeAt(t)===45?(l="-",t++):(l=null,h('"-"')),l===null&&(n.charCodeAt(t)===95?(l="_",t++):(l=null,h('"_"'))));l!==null;)e.push(l),l=L(),l===null&&(n.charCodeAt(t)===45?(l="-",t++):(l=null,h('"-"')),l===null&&(n.charCodeAt(t)===95?(l="_",t++):(l=null,h('"_"'))));e!==null?i=[i,e]:(i=null,t=u)}else i=null,t=u;return i}function Nn(){var i,e,l,u;if(u=t,i=v(),i!==null){for(e=[],l=L(),l===null&&(n.charCodeAt(t)===45?(l="-",t++):(l=null,h('"-"')),l===null&&(n.charCodeAt(t)===95?(l="_",t++):(l=null,h('"_"'))));l!==null;)e.push(l),l=L(),l===null&&(n.charCodeAt(t)===45?(l="-",t++):(l=null,h('"-"')),l===null&&(n.charCodeAt(t)===95?(l="_",t++):(l=null,h('"_"'))));e!==null?i=[i,e]:(i=null,t=u)}else i=null,t=u;return i}function Un(){var i,e,l,u,f;return u=t,f=t,n.charCodeAt(t)===91?(i="[",t++):(i=null,h('"["')),i!==null?(e=Xs(),e!==null?(n.charCodeAt(t)===93?(l="]",t++):(l=null,h('"]"')),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_){return R.host_type="IPv6",n.substring(t,_)}(u)),i===null&&(t=u),i}function Xs(){var i,e,l,u,f,_,m,T,y,O,se,De,At,xs,x,A;return xs=t,x=t,i=_e(),i!==null?(n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=_e(),l!==null?(n.charCodeAt(t)===58?(u=":",t++):(u=null,h('":"')),u!==null?(f=_e(),f!==null?(n.charCodeAt(t)===58?(_=":",t++):(_=null,h('":"')),_!==null?(m=_e(),m!==null?(n.charCodeAt(t)===58?(T=":",t++):(T=null,h('":"')),T!==null?(y=_e(),y!==null?(n.charCodeAt(t)===58?(O=":",t++):(O=null,h('":"')),O!==null?(se=_e(),se!==null?(n.charCodeAt(t)===58?(De=":",t++):(De=null,h('":"')),De!==null?(At=re(),At!==null?i=[i,e,l,u,f,_,m,T,y,O,se,De,At]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,n.substr(t,2)==="::"?(i="::",t+=2):(i=null,h('"::"')),i!==null?(e=_e(),e!==null?(n.charCodeAt(t)===58?(l=":",t++):(l=null,h('":"')),l!==null?(u=_e(),u!==null?(n.charCodeAt(t)===58?(f=":",t++):(f=null,h('":"')),f!==null?(_=_e(),_!==null?(n.charCodeAt(t)===58?(m=":",t++):(m=null,h('":"')),m!==null?(T=_e(),T!==null?(n.charCodeAt(t)===58?(y=":",t++):(y=null,h('":"')),y!==null?(O=_e(),O!==null?(n.charCodeAt(t)===58?(se=":",t++):(se=null,h('":"')),se!==null?(De=re(),De!==null?i=[i,e,l,u,f,_,m,T,y,O,se,De]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,n.substr(t,2)==="::"?(i="::",t+=2):(i=null,h('"::"')),i!==null?(e=_e(),e!==null?(n.charCodeAt(t)===58?(l=":",t++):(l=null,h('":"')),l!==null?(u=_e(),u!==null?(n.charCodeAt(t)===58?(f=":",t++):(f=null,h('":"')),f!==null?(_=_e(),_!==null?(n.charCodeAt(t)===58?(m=":",t++):(m=null,h('":"')),m!==null?(T=_e(),T!==null?(n.charCodeAt(t)===58?(y=":",t++):(y=null,h('":"')),y!==null?(O=re(),O!==null?i=[i,e,l,u,f,_,m,T,y,O]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,n.substr(t,2)==="::"?(i="::",t+=2):(i=null,h('"::"')),i!==null?(e=_e(),e!==null?(n.charCodeAt(t)===58?(l=":",t++):(l=null,h('":"')),l!==null?(u=_e(),u!==null?(n.charCodeAt(t)===58?(f=":",t++):(f=null,h('":"')),f!==null?(_=_e(),_!==null?(n.charCodeAt(t)===58?(m=":",t++):(m=null,h('":"')),m!==null?(T=re(),T!==null?i=[i,e,l,u,f,_,m,T]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,n.substr(t,2)==="::"?(i="::",t+=2):(i=null,h('"::"')),i!==null?(e=_e(),e!==null?(n.charCodeAt(t)===58?(l=":",t++):(l=null,h('":"')),l!==null?(u=_e(),u!==null?(n.charCodeAt(t)===58?(f=":",t++):(f=null,h('":"')),f!==null?(_=re(),_!==null?i=[i,e,l,u,f,_]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,n.substr(t,2)==="::"?(i="::",t+=2):(i=null,h('"::"')),i!==null?(e=_e(),e!==null?(n.charCodeAt(t)===58?(l=":",t++):(l=null,h('":"')),l!==null?(u=re(),u!==null?i=[i,e,l,u]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,n.substr(t,2)==="::"?(i="::",t+=2):(i=null,h('"::"')),i!==null?(e=re(),e!==null?i=[i,e]:(i=null,t=x)):(i=null,t=x),i===null&&(x=t,n.substr(t,2)==="::"?(i="::",t+=2):(i=null,h('"::"')),i!==null?(e=_e(),e!==null?i=[i,e]:(i=null,t=x)):(i=null,t=x),i===null&&(x=t,i=_e(),i!==null?(n.substr(t,2)==="::"?(e="::",t+=2):(e=null,h('"::"')),e!==null?(l=_e(),l!==null?(n.charCodeAt(t)===58?(u=":",t++):(u=null,h('":"')),u!==null?(f=_e(),f!==null?(n.charCodeAt(t)===58?(_=":",t++):(_=null,h('":"')),_!==null?(m=_e(),m!==null?(n.charCodeAt(t)===58?(T=":",t++):(T=null,h('":"')),T!==null?(y=_e(),y!==null?(n.charCodeAt(t)===58?(O=":",t++):(O=null,h('":"')),O!==null?(se=re(),se!==null?i=[i,e,l,u,f,_,m,T,y,O,se]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,i=_e(),i!==null?(A=t,n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=_e(),l!==null?e=[e,l]:(e=null,t=A)):(e=null,t=A),e=e!==null?e:"",e!==null?(n.substr(t,2)==="::"?(l="::",t+=2):(l=null,h('"::"')),l!==null?(u=_e(),u!==null?(n.charCodeAt(t)===58?(f=":",t++):(f=null,h('":"')),f!==null?(_=_e(),_!==null?(n.charCodeAt(t)===58?(m=":",t++):(m=null,h('":"')),m!==null?(T=_e(),T!==null?(n.charCodeAt(t)===58?(y=":",t++):(y=null,h('":"')),y!==null?(O=re(),O!==null?i=[i,e,l,u,f,_,m,T,y,O]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,i=_e(),i!==null?(A=t,n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=_e(),l!==null?e=[e,l]:(e=null,t=A)):(e=null,t=A),e=e!==null?e:"",e!==null?(A=t,n.charCodeAt(t)===58?(l=":",t++):(l=null,h('":"')),l!==null?(u=_e(),u!==null?l=[l,u]:(l=null,t=A)):(l=null,t=A),l=l!==null?l:"",l!==null?(n.substr(t,2)==="::"?(u="::",t+=2):(u=null,h('"::"')),u!==null?(f=_e(),f!==null?(n.charCodeAt(t)===58?(_=":",t++):(_=null,h('":"')),_!==null?(m=_e(),m!==null?(n.charCodeAt(t)===58?(T=":",t++):(T=null,h('":"')),T!==null?(y=re(),y!==null?i=[i,e,l,u,f,_,m,T,y]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,i=_e(),i!==null?(A=t,n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=_e(),l!==null?e=[e,l]:(e=null,t=A)):(e=null,t=A),e=e!==null?e:"",e!==null?(A=t,n.charCodeAt(t)===58?(l=":",t++):(l=null,h('":"')),l!==null?(u=_e(),u!==null?l=[l,u]:(l=null,t=A)):(l=null,t=A),l=l!==null?l:"",l!==null?(A=t,n.charCodeAt(t)===58?(u=":",t++):(u=null,h('":"')),u!==null?(f=_e(),f!==null?u=[u,f]:(u=null,t=A)):(u=null,t=A),u=u!==null?u:"",u!==null?(n.substr(t,2)==="::"?(f="::",t+=2):(f=null,h('"::"')),f!==null?(_=_e(),_!==null?(n.charCodeAt(t)===58?(m=":",t++):(m=null,h('":"')),m!==null?(T=re(),T!==null?i=[i,e,l,u,f,_,m,T]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,i=_e(),i!==null?(A=t,n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=_e(),l!==null?e=[e,l]:(e=null,t=A)):(e=null,t=A),e=e!==null?e:"",e!==null?(A=t,n.charCodeAt(t)===58?(l=":",t++):(l=null,h('":"')),l!==null?(u=_e(),u!==null?l=[l,u]:(l=null,t=A)):(l=null,t=A),l=l!==null?l:"",l!==null?(A=t,n.charCodeAt(t)===58?(u=":",t++):(u=null,h('":"')),u!==null?(f=_e(),f!==null?u=[u,f]:(u=null,t=A)):(u=null,t=A),u=u!==null?u:"",u!==null?(A=t,n.charCodeAt(t)===58?(f=":",t++):(f=null,h('":"')),f!==null?(_=_e(),_!==null?f=[f,_]:(f=null,t=A)):(f=null,t=A),f=f!==null?f:"",f!==null?(n.substr(t,2)==="::"?(_="::",t+=2):(_=null,h('"::"')),_!==null?(m=re(),m!==null?i=[i,e,l,u,f,_,m]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,i=_e(),i!==null?(A=t,n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=_e(),l!==null?e=[e,l]:(e=null,t=A)):(e=null,t=A),e=e!==null?e:"",e!==null?(A=t,n.charCodeAt(t)===58?(l=":",t++):(l=null,h('":"')),l!==null?(u=_e(),u!==null?l=[l,u]:(l=null,t=A)):(l=null,t=A),l=l!==null?l:"",l!==null?(A=t,n.charCodeAt(t)===58?(u=":",t++):(u=null,h('":"')),u!==null?(f=_e(),f!==null?u=[u,f]:(u=null,t=A)):(u=null,t=A),u=u!==null?u:"",u!==null?(A=t,n.charCodeAt(t)===58?(f=":",t++):(f=null,h('":"')),f!==null?(_=_e(),_!==null?f=[f,_]:(f=null,t=A)):(f=null,t=A),f=f!==null?f:"",f!==null?(A=t,n.charCodeAt(t)===58?(_=":",t++):(_=null,h('":"')),_!==null?(m=_e(),m!==null?_=[_,m]:(_=null,t=A)):(_=null,t=A),_=_!==null?_:"",_!==null?(n.substr(t,2)==="::"?(m="::",t+=2):(m=null,h('"::"')),m!==null?(T=_e(),T!==null?i=[i,e,l,u,f,_,m,T]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,i=_e(),i!==null?(A=t,n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=_e(),l!==null?e=[e,l]:(e=null,t=A)):(e=null,t=A),e=e!==null?e:"",e!==null?(A=t,n.charCodeAt(t)===58?(l=":",t++):(l=null,h('":"')),l!==null?(u=_e(),u!==null?l=[l,u]:(l=null,t=A)):(l=null,t=A),l=l!==null?l:"",l!==null?(A=t,n.charCodeAt(t)===58?(u=":",t++):(u=null,h('":"')),u!==null?(f=_e(),f!==null?u=[u,f]:(u=null,t=A)):(u=null,t=A),u=u!==null?u:"",u!==null?(A=t,n.charCodeAt(t)===58?(f=":",t++):(f=null,h('":"')),f!==null?(_=_e(),_!==null?f=[f,_]:(f=null,t=A)):(f=null,t=A),f=f!==null?f:"",f!==null?(A=t,n.charCodeAt(t)===58?(_=":",t++):(_=null,h('":"')),_!==null?(m=_e(),m!==null?_=[_,m]:(_=null,t=A)):(_=null,t=A),_=_!==null?_:"",_!==null?(A=t,n.charCodeAt(t)===58?(m=":",t++):(m=null,h('":"')),m!==null?(T=_e(),T!==null?m=[m,T]:(m=null,t=A)):(m=null,t=A),m=m!==null?m:"",m!==null?(n.substr(t,2)==="::"?(T="::",t+=2):(T=null,h('"::"')),T!==null?i=[i,e,l,u,f,_,m,T]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x))))))))))))))),i!==null&&(i=function(pe){return R.host_type="IPv6",n.substring(t,pe)}(xs)),i===null&&(t=xs),i}function _e(){var i,e,l,u,f;return f=t,i=E(),i!==null?(e=E(),e=e!==null?e:"",e!==null?(l=E(),l=l!==null?l:"",l!==null?(u=E(),u=u!==null?u:"",u!==null?i=[i,e,l,u]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i}function re(){var i,e,l,u;return u=t,i=_e(),i!==null?(n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=_e(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i===null&&(i=nt()),i}function nt(){var i,e,l,u,f,_,m,T,y;return T=t,y=t,i=qt(),i!==null?(n.charCodeAt(t)===46?(e=".",t++):(e=null,h('"."')),e!==null?(l=qt(),l!==null?(n.charCodeAt(t)===46?(u=".",t++):(u=null,h('"."')),u!==null?(f=qt(),f!==null?(n.charCodeAt(t)===46?(_=".",t++):(_=null,h('"."')),_!==null?(m=qt(),m!==null?i=[i,e,l,u,f,_,m]:(i=null,t=y)):(i=null,t=y)):(i=null,t=y)):(i=null,t=y)):(i=null,t=y)):(i=null,t=y)):(i=null,t=y),i!==null&&(i=function(O){return R.host_type="IPv4",n.substring(t,O)}(T)),i===null&&(t=T),i}function qt(){var i,e,l,u;return u=t,n.substr(t,2)==="25"?(i="25",t+=2):(i=null,h('"25"')),i!==null?(/^[0-5]/.test(n.charAt(t))?(e=n.charAt(t),t++):(e=null,h("[0-5]")),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i===null&&(u=t,n.charCodeAt(t)===50?(i="2",t++):(i=null,h('"2"')),i!==null?(/^[0-4]/.test(n.charAt(t))?(e=n.charAt(t),t++):(e=null,h("[0-4]")),e!==null?(l=g(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i===null&&(u=t,n.charCodeAt(t)===49?(i="1",t++):(i=null,h('"1"')),i!==null?(e=g(),e!==null?(l=g(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i===null&&(u=t,/^[1-9]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[1-9]")),i!==null?(e=g(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i===null&&(i=g())))),i}function Rs(){var i,e,l,u,f,_,m;return _=t,m=t,i=g(),i=i!==null?i:"",i!==null?(e=g(),e=e!==null?e:"",e!==null?(l=g(),l=l!==null?l:"",l!==null?(u=g(),u=u!==null?u:"",u!==null?(f=g(),f=f!==null?f:"",f!==null?i=[i,e,l,u,f]:(i=null,t=m)):(i=null,t=m)):(i=null,t=m)):(i=null,t=m)):(i=null,t=m),i!==null&&(i=function(T,y){return y=parseInt(y.join("")),R.port=y,y}(_,i)),i===null&&(t=_),i}function Kr(){var i,e,l,u;for(i=[],u=t,n.charCodeAt(t)===59?(e=";",t++):(e=null,h('";"')),e!==null?(l=Pn(),l!==null?e=[e,l]:(e=null,t=u)):(e=null,t=u);e!==null;)i.push(e),u=t,n.charCodeAt(t)===59?(e=";",t++):(e=null,h('";"')),e!==null?(l=Pn(),l!==null?e=[e,l]:(e=null,t=u)):(e=null,t=u);return i}function Pn(){var i;return i=kn(),i===null&&(i=Wr(),i===null&&(i=Yr(),i===null&&(i=zr(),i===null&&(i=Jr(),i===null&&(i=Xr(),i===null&&(i=Qr())))))),i}function kn(){var i,e,l,u;return l=t,u=t,n.substr(t,10).toLowerCase()==="transport="?(i=n.substr(t,10),t+=10):(i=null,h('"transport="')),i!==null?(n.substr(t,3).toLowerCase()==="udp"?(e=n.substr(t,3),t+=3):(e=null,h('"udp"')),e===null&&(n.substr(t,3).toLowerCase()==="tcp"?(e=n.substr(t,3),t+=3):(e=null,h('"tcp"')),e===null&&(n.substr(t,4).toLowerCase()==="sctp"?(e=n.substr(t,4),t+=4):(e=null,h('"sctp"')),e===null&&(n.substr(t,3).toLowerCase()==="tls"?(e=n.substr(t,3),t+=3):(e=null,h('"tls"')),e===null&&(e=U())))),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f,_){R.uri_params||(R.uri_params={}),R.uri_params.transport=_.toLowerCase()}(l,i[1])),i===null&&(t=l),i}function Wr(){var i,e,l,u;return l=t,u=t,n.substr(t,5).toLowerCase()==="user="?(i=n.substr(t,5),t+=5):(i=null,h('"user="')),i!==null?(n.substr(t,5).toLowerCase()==="phone"?(e=n.substr(t,5),t+=5):(e=null,h('"phone"')),e===null&&(n.substr(t,2).toLowerCase()==="ip"?(e=n.substr(t,2),t+=2):(e=null,h('"ip"')),e===null&&(e=U())),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f,_){R.uri_params||(R.uri_params={}),R.uri_params.user=_.toLowerCase()}(l,i[1])),i===null&&(t=l),i}function Yr(){var i,e,l,u;return l=t,u=t,n.substr(t,7).toLowerCase()==="method="?(i=n.substr(t,7),t+=7):(i=null,h('"method="')),i!==null?(e=rn(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f,_){R.uri_params||(R.uri_params={}),R.uri_params.method=_}(l,i[1])),i===null&&(t=l),i}function zr(){var i,e,l,u;return l=t,u=t,n.substr(t,4).toLowerCase()==="ttl="?(i=n.substr(t,4),t+=4):(i=null,h('"ttl="')),i!==null?(e=sr(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f,_){R.params||(R.params={}),R.params.ttl=_}(l,i[1])),i===null&&(t=l),i}function Jr(){var i,e,l,u;return l=t,u=t,n.substr(t,6).toLowerCase()==="maddr="?(i=n.substr(t,6),t+=6):(i=null,h('"maddr="')),i!==null?(e=Xt(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f,_){R.uri_params||(R.uri_params={}),R.uri_params.maddr=_}(l,i[1])),i===null&&(t=l),i}function Xr(){var i,e,l,u,f,_;return u=t,f=t,n.substr(t,2).toLowerCase()==="lr"?(i=n.substr(t,2),t+=2):(i=null,h('"lr"')),i!==null?(_=t,n.charCodeAt(t)===61?(e="=",t++):(e=null,h('"="')),e!==null?(l=U(),l!==null?e=[e,l]:(e=null,t=_)):(e=null,t=_),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m){R.uri_params||(R.uri_params={}),R.uri_params.lr=void 0}()),i===null&&(t=u),i}function Qr(){var i,e,l,u,f,_;return u=t,f=t,i=Zr(),i!==null?(_=t,n.charCodeAt(t)===61?(e="=",t++):(e=null,h('"="')),e!==null?(l=ei(),l!==null?e=[e,l]:(e=null,t=_)):(e=null,t=_),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m,T,y){R.uri_params||(R.uri_params={}),typeof y>"u"?y=void 0:y=y[1],R.uri_params[T.toLowerCase()]=y}(u,i[0],i[1])),i===null&&(t=u),i}function Zr(){var i,e,l;if(l=t,e=Is(),e!==null)for(i=[];e!==null;)i.push(e),e=Is();else i=null;return i!==null&&(i=function(u,f){return f.join("")}(l,i)),i===null&&(t=l),i}function ei(){var i,e,l;if(l=t,e=Is(),e!==null)for(i=[];e!==null;)i.push(e),e=Is();else i=null;return i!==null&&(i=function(u,f){return f.join("")}(l,i)),i===null&&(t=l),i}function Is(){var i;return i=bs(),i===null&&(i=N(),i===null&&(i=ve())),i}function bs(){var i;return n.charCodeAt(t)===91?(i="[",t++):(i=null,h('"["')),i===null&&(n.charCodeAt(t)===93?(i="]",t++):(i=null,h('"]"')),i===null&&(n.charCodeAt(t)===47?(i="/",t++):(i=null,h('"/"')),i===null&&(n.charCodeAt(t)===58?(i=":",t++):(i=null,h('":"')),i===null&&(n.charCodeAt(t)===38?(i="&",t++):(i=null,h('"&"')),i===null&&(n.charCodeAt(t)===43?(i="+",t++):(i=null,h('"+"')),i===null&&(n.charCodeAt(t)===36?(i="$",t++):(i=null,h('"$"')))))))),i}function ti(){var i,e,l,u,f,_,m;if(_=t,n.charCodeAt(t)===63?(i="?",t++):(i=null,h('"?"')),i!==null)if(e=Qs(),e!==null){for(l=[],m=t,n.charCodeAt(t)===38?(u="&",t++):(u=null,h('"&"')),u!==null?(f=Qs(),f!==null?u=[u,f]:(u=null,t=m)):(u=null,t=m);u!==null;)l.push(u),m=t,n.charCodeAt(t)===38?(u="&",t++):(u=null,h('"&"')),u!==null?(f=Qs(),f!==null?u=[u,f]:(u=null,t=m)):(u=null,t=m);l!==null?i=[i,e,l]:(i=null,t=_)}else i=null,t=_;else i=null,t=_;return i}function Qs(){var i,e,l,u,f;return u=t,f=t,i=Zs(),i!==null?(n.charCodeAt(t)===61?(e="=",t++):(e=null,h('"="')),e!==null?(l=si(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m,T){m=m.join("").toLowerCase(),T=T.join(""),R.uri_headers||(R.uri_headers={}),R.uri_headers[m]?R.uri_headers[m].push(T):R.uri_headers[m]=[T]}(u,i[0],i[2])),i===null&&(t=u),i}function Zs(){var i,e;if(e=ws(),e===null&&(e=N(),e===null&&(e=ve())),e!==null)for(i=[];e!==null;)i.push(e),e=ws(),e===null&&(e=N(),e===null&&(e=ve()));else i=null;return i}function si(){var i,e;for(i=[],e=ws(),e===null&&(e=N(),e===null&&(e=ve()));e!==null;)i.push(e),e=ws(),e===null&&(e=N(),e===null&&(e=ve()));return i}function ws(){var i;return n.charCodeAt(t)===91?(i="[",t++):(i=null,h('"["')),i===null&&(n.charCodeAt(t)===93?(i="]",t++):(i=null,h('"]"')),i===null&&(n.charCodeAt(t)===47?(i="/",t++):(i=null,h('"/"')),i===null&&(n.charCodeAt(t)===63?(i="?",t++):(i=null,h('"?"')),i===null&&(n.charCodeAt(t)===58?(i=":",t++):(i=null,h('":"')),i===null&&(n.charCodeAt(t)===43?(i="+",t++):(i=null,h('"+"')),i===null&&(n.charCodeAt(t)===36?(i="$",t++):(i=null,h('"$"')))))))),i}function en(){var i;return i=ln(),i===null&&(i=ro()),i}function ro(){var i,e,l,u,f,_;return _=t,i=rn(),i!==null?(e=w(),e!==null?(l=ni(),l!==null?(u=w(),u!==null?(f=Ln(),f!==null?i=[i,e,l,u,f]:(i=null,t=_)):(i=null,t=_)):(i=null,t=_)):(i=null,t=_)):(i=null,t=_),i}function ni(){var i;return i=Re(),i===null&&(i=Mn()),i}function Mn(){var i,e,l,u;return u=t,i=Us(),i!==null?(n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=xn(),l===null&&(l=sn()),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function xn(){var i,e,l,u,f;return u=t,i=ri(),i===null&&(i=tn()),i!==null?(f=t,n.charCodeAt(t)===63?(e="?",t++):(e=null,h('"?"')),e!==null?(l=ui(),l!==null?e=[e,l]:(e=null,t=f)):(e=null,t=f),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i}function ri(){var i,e,l,u;return u=t,n.substr(t,2)==="//"?(i="//",t+=2):(i=null,h('"//"')),i!==null?(e=li(),e!==null?(l=tn(),l=l!==null?l:"",l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function tn(){var i,e,l;return l=t,n.charCodeAt(t)===47?(i="/",t++):(i=null,h('"/"')),i!==null?(e=ii(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function sn(){var i,e,l,u;if(u=t,i=Ds(),i!==null){for(e=[],l=Os();l!==null;)e.push(l),l=Os();e!==null?i=[i,e]:(i=null,t=u)}else i=null,t=u;return i}function Os(){var i;return i=ie(),i===null&&(i=N(),i===null&&(i=ve())),i}function Ds(){var i;return i=N(),i===null&&(i=ve(),i===null&&(n.charCodeAt(t)===59?(i=";",t++):(i=null,h('";"')),i===null&&(n.charCodeAt(t)===63?(i="?",t++):(i=null,h('"?"')),i===null&&(n.charCodeAt(t)===58?(i=":",t++):(i=null,h('":"')),i===null&&(n.charCodeAt(t)===64?(i="@",t++):(i=null,h('"@"')),i===null&&(n.charCodeAt(t)===38?(i="&",t++):(i=null,h('"&"')),i===null&&(n.charCodeAt(t)===61?(i="=",t++):(i=null,h('"="')),i===null&&(n.charCodeAt(t)===43?(i="+",t++):(i=null,h('"+"')),i===null&&(n.charCodeAt(t)===36?(i="$",t++):(i=null,h('"$"')),i===null&&(n.charCodeAt(t)===44?(i=",",t++):(i=null,h('","')))))))))))),i}function ii(){var i,e,l,u,f,_;if(f=t,i=nn(),i!==null){for(e=[],_=t,n.charCodeAt(t)===47?(l="/",t++):(l=null,h('"/"')),l!==null?(u=nn(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,n.charCodeAt(t)===47?(l="/",t++):(l=null,h('"/"')),l!==null?(u=nn(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function nn(){var i,e,l,u,f,_;for(f=t,i=[],e=_s();e!==null;)i.push(e),e=_s();if(i!==null){for(e=[],_=t,n.charCodeAt(t)===59?(l=";",t++):(l=null,h('";"')),l!==null?(u=Ns(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,n.charCodeAt(t)===59?(l=";",t++):(l=null,h('";"')),l!==null?(u=Ns(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Ns(){var i,e;for(i=[],e=_s();e!==null;)i.push(e),e=_s();return i}function _s(){var i;return i=N(),i===null&&(i=ve(),i===null&&(n.charCodeAt(t)===58?(i=":",t++):(i=null,h('":"')),i===null&&(n.charCodeAt(t)===64?(i="@",t++):(i=null,h('"@"')),i===null&&(n.charCodeAt(t)===38?(i="&",t++):(i=null,h('"&"')),i===null&&(n.charCodeAt(t)===61?(i="=",t++):(i=null,h('"="')),i===null&&(n.charCodeAt(t)===43?(i="+",t++):(i=null,h('"+"')),i===null&&(n.charCodeAt(t)===36?(i="$",t++):(i=null,h('"$"')),i===null&&(n.charCodeAt(t)===44?(i=",",t++):(i=null,h('","')))))))))),i}function Us(){var i,e,l,u,f;if(u=t,f=t,i=v(),i!==null){for(e=[],l=v(),l===null&&(l=g(),l===null&&(n.charCodeAt(t)===43?(l="+",t++):(l=null,h('"+"')),l===null&&(n.charCodeAt(t)===45?(l="-",t++):(l=null,h('"-"')),l===null&&(n.charCodeAt(t)===46?(l=".",t++):(l=null,h('"."'))))));l!==null;)e.push(l),l=v(),l===null&&(l=g(),l===null&&(n.charCodeAt(t)===43?(l="+",t++):(l=null,h('"+"')),l===null&&(n.charCodeAt(t)===45?(l="-",t++):(l=null,h('"-"')),l===null&&(n.charCodeAt(t)===46?(l=".",t++):(l=null,h('"."'))))));e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i!==null&&(i=function(_){R.scheme=n.substring(t,_)}(u)),i===null&&(t=u),i}function li(){var i;return i=oi(),i===null&&(i=ai()),i}function oi(){var i,e,l,u;return l=t,u=t,i=Pt(),i!==null?(n.charCodeAt(t)===64?(e="@",t++):(e=null,h('"@"')),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i=i!==null?i:"",i!==null?(e=zs(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i=i!==null?i:"",i}function ai(){var i,e;if(e=N(),e===null&&(e=ve(),e===null&&(n.charCodeAt(t)===36?(e="$",t++):(e=null,h('"$"')),e===null&&(n.charCodeAt(t)===44?(e=",",t++):(e=null,h('","')),e===null&&(n.charCodeAt(t)===59?(e=";",t++):(e=null,h('";"')),e===null&&(n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e===null&&(n.charCodeAt(t)===64?(e="@",t++):(e=null,h('"@"')),e===null&&(n.charCodeAt(t)===38?(e="&",t++):(e=null,h('"&"')),e===null&&(n.charCodeAt(t)===61?(e="=",t++):(e=null,h('"="')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,h('"+"'))))))))))),e!==null)for(i=[];e!==null;)i.push(e),e=N(),e===null&&(e=ve(),e===null&&(n.charCodeAt(t)===36?(e="$",t++):(e=null,h('"$"')),e===null&&(n.charCodeAt(t)===44?(e=",",t++):(e=null,h('","')),e===null&&(n.charCodeAt(t)===59?(e=";",t++):(e=null,h('";"')),e===null&&(n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e===null&&(n.charCodeAt(t)===64?(e="@",t++):(e=null,h('"@"')),e===null&&(n.charCodeAt(t)===38?(e="&",t++):(e=null,h('"&"')),e===null&&(n.charCodeAt(t)===61?(e="=",t++):(e=null,h('"="')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,h('"+"')))))))))));else i=null;return i}function ui(){var i,e;for(i=[],e=Os();e!==null;)i.push(e),e=Os();return i}function Ln(){var i,e,l,u,f,_,m,T;if(m=t,T=t,n.substr(t,3).toLowerCase()==="sip"?(i=n.substr(t,3),t+=3):(i=null,h('"SIP"')),i!==null)if(n.charCodeAt(t)===47?(e="/",t++):(e=null,h('"/"')),e!==null){if(u=g(),u!==null)for(l=[];u!==null;)l.push(u),u=g();else l=null;if(l!==null)if(n.charCodeAt(t)===46?(u=".",t++):(u=null,h('"."')),u!==null){if(_=g(),_!==null)for(f=[];_!==null;)f.push(_),_=g();else f=null;f!==null?i=[i,e,l,u,f]:(i=null,t=T)}else i=null,t=T;else i=null,t=T}else i=null,t=T;else i=null,t=T;return i!==null&&(i=function(y){R.sip_version=n.substring(t,y)}(m)),i===null&&(t=m),i}function $n(){var i;return n.substr(t,6)==="INVITE"?(i="INVITE",t+=6):(i=null,h('"INVITE"')),i}function ci(){var i;return n.substr(t,3)==="ACK"?(i="ACK",t+=3):(i=null,h('"ACK"')),i}function fi(){var i;return n.substr(t,7)==="OPTIONS"?(i="OPTIONS",t+=7):(i=null,h('"OPTIONS"')),i}function hi(){var i;return n.substr(t,3)==="BYE"?(i="BYE",t+=3):(i=null,h('"BYE"')),i}function _i(){var i;return n.substr(t,6)==="CANCEL"?(i="CANCEL",t+=6):(i=null,h('"CANCEL"')),i}function di(){var i;return n.substr(t,8)==="REGISTER"?(i="REGISTER",t+=8):(i=null,h('"REGISTER"')),i}function pi(){var i;return n.substr(t,9)==="SUBSCRIBE"?(i="SUBSCRIBE",t+=9):(i=null,h('"SUBSCRIBE"')),i}function mi(){var i;return n.substr(t,6)==="NOTIFY"?(i="NOTIFY",t+=6):(i=null,h('"NOTIFY"')),i}function gi(){var i;return n.substr(t,5)==="REFER"?(i="REFER",t+=5):(i=null,h('"REFER"')),i}function rn(){var i,e;return e=t,i=$n(),i===null&&(i=ci(),i===null&&(i=fi(),i===null&&(i=hi(),i===null&&(i=_i(),i===null&&(i=di(),i===null&&(i=pi(),i===null&&(i=mi(),i===null&&(i=gi(),i===null&&(i=U()))))))))),i!==null&&(i=function(l){return R.method=n.substring(t,l),R.method}(e)),i===null&&(t=e),i}function ln(){var i,e,l,u,f,_;return _=t,i=Ln(),i!==null?(e=w(),e!==null?(l=vi(),l!==null?(u=w(),u!==null?(f=Ei(),f!==null?i=[i,e,l,u,f]:(i=null,t=_)):(i=null,t=_)):(i=null,t=_)):(i=null,t=_)):(i=null,t=_),i}function vi(){var i,e;return e=t,i=Ti(),i!==null&&(i=function(l,u){R.status_code=parseInt(u.join(""))}(e,i)),i===null&&(t=e),i}function Ti(){var i,e,l,u;return u=t,i=g(),i!==null?(e=g(),e!==null?(l=g(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Ei(){var i,e,l;for(l=t,i=[],e=ie(),e===null&&(e=N(),e===null&&(e=ve(),e===null&&(e=Y(),e===null&&(e=$(),e===null&&(e=w(),e===null&&(e=F()))))));e!==null;)i.push(e),e=ie(),e===null&&(e=N(),e===null&&(e=ve(),e===null&&(e=Y(),e===null&&(e=$(),e===null&&(e=w(),e===null&&(e=F()))))));return i!==null&&(i=function(u){R.reason_phrase=n.substring(t,u)}(l)),i===null&&(t=l),i}function io(){var i,e,l,u,f,_;if(f=t,i=un(),i!==null){for(e=[],_=t,l=Se(),l!==null?(u=un(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=Se(),l!==null?(u=un(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function tu(){var i,e,l,u,f,_;return u=t,f=t,i=et(),i!==null?(_=t,n.charCodeAt(t)===64?(e="@",t++):(e=null,h('"@"')),e!==null?(l=et(),l!==null?e=[e,l]:(e=null,t=_)):(e=null,t=_),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m){R=n.substring(t,m)}(u)),i===null&&(t=u),i}function su(){var i,e,l,u,f,_,m;if(f=t,i=Q(),i===null)if(_=t,i=Hn(),i!==null){for(e=[],m=t,l=Se(),l!==null?(u=Hn(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=Se(),l!==null?(u=Hn(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=_)}else i=null,t=_;return i!==null&&(i=function(T){var y,O;for(O=R.multi_header.length,y=0;y<O;y++)if(R.multi_header[y].parsed===null){R=null;break}R!==null?R=R.multi_header:R=-1}()),i===null&&(t=f),i}function Hn(){var i,e,l,u,f,_,m;if(f=t,_=t,i=fe(),i===null&&(i=kt()),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=Ps(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=ne(),l!==null?(u=Ps(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=_)}else i=null,t=_;return i!==null&&(i=function(T){var y;R.multi_header||(R.multi_header=[]);try{y=new ds(R.uri,R.display_name,R.params),delete R.uri,delete R.display_name,delete R.params}catch{y=null}R.multi_header.push({possition:t,offset:T,parsed:y})}(f)),i===null&&(t=f),i}function kt(){var i,e,l,u,f;return f=t,i=Mt(),i=i!==null?i:"",i!==null?(e=Ue(),e!==null?(l=Re(),l!==null?(u=Ae(),u!==null?i=[i,e,l,u]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i}function Mt(){var i,e,l,u,f,_,m;if(f=t,_=t,i=U(),i!==null){for(e=[],m=t,l=me(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=me(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=_)}else i=null,t=_;return i===null&&(i=be()),i!==null&&(i=function(T,y){typeof y=="string"?R.display_name=y:R.display_name=y[1].reduce(function(O,se){return O+se[0]+se[1]},y[0])}(f,i)),i===null&&(t=f),i}function Ps(){var i;return i=Fn(),i===null&&(i=yi(),i===null&&(i=Ge())),i}function Fn(){var i,e,l,u,f;return u=t,f=t,n.substr(t,1).toLowerCase()==="q"?(i=n.substr(t,1),t++):(i=null,h('"q"')),i!==null?(e=B(),e!==null?(l=Zt(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){R.params||(R.params={}),R.params.q=m}(u,i[2])),i===null&&(t=u),i}function yi(){var i,e,l,u,f;return u=t,f=t,n.substr(t,7).toLowerCase()==="expires"?(i=n.substr(t,7),t+=7):(i=null,h('"expires"')),i!==null?(e=B(),e!==null?(l=Qt(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){R.params||(R.params={}),R.params.expires=m}(u,i[2])),i===null&&(t=u),i}function Qt(){var i,e,l;if(l=t,e=g(),e!==null)for(i=[];e!==null;)i.push(e),e=g();else i=null;return i!==null&&(i=function(u,f){return parseInt(f.join(""))}(l,i)),i===null&&(t=l),i}function Zt(){var i,e,l,u,f,_,m,T;return _=t,m=t,n.charCodeAt(t)===48?(i="0",t++):(i=null,h('"0"')),i!==null?(T=t,n.charCodeAt(t)===46?(e=".",t++):(e=null,h('"."')),e!==null?(l=g(),l=l!==null?l:"",l!==null?(u=g(),u=u!==null?u:"",u!==null?(f=g(),f=f!==null?f:"",f!==null?e=[e,l,u,f]:(e=null,t=T)):(e=null,t=T)):(e=null,t=T)):(e=null,t=T),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=m)):(i=null,t=m),i!==null&&(i=function(y){return parseFloat(n.substring(t,y))}(_)),i===null&&(t=_),i}function Ge(){var i,e,l,u,f,_;return u=t,f=t,i=U(),i!==null?(_=t,e=B(),e!==null?(l=Ke(),l!==null?e=[e,l]:(e=null,t=_)):(e=null,t=_),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m,T,y){R.params||(R.params={}),typeof y>"u"?y=void 0:y=y[1],R.params[T.toLowerCase()]=y}(u,i[0],i[1])),i===null&&(t=u),i}function Ke(){var i;return i=U(),i===null&&(i=Xt(),i===null&&(i=Ce())),i}function lo(){var i,e,l,u,f,_;if(f=t,i=oo(),i!==null){for(e=[],_=t,l=ne(),l!==null?(u=qn(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=ne(),l!==null?(u=qn(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function oo(){var i;return n.substr(t,6).toLowerCase()==="render"?(i=n.substr(t,6),t+=6):(i=null,h('"render"')),i===null&&(n.substr(t,7).toLowerCase()==="session"?(i=n.substr(t,7),t+=7):(i=null,h('"session"')),i===null&&(n.substr(t,4).toLowerCase()==="icon"?(i=n.substr(t,4),t+=4):(i=null,h('"icon"')),i===null&&(n.substr(t,5).toLowerCase()==="alert"?(i=n.substr(t,5),t+=5):(i=null,h('"alert"')),i===null&&(i=U())))),i}function qn(){var i;return i=Vn(),i===null&&(i=Ge()),i}function Vn(){var i,e,l,u;return u=t,n.substr(t,8).toLowerCase()==="handling"?(i=n.substr(t,8),t+=8):(i=null,h('"handling"')),i!==null?(e=B(),e!==null?(n.substr(t,8).toLowerCase()==="optional"?(l=n.substr(t,8),t+=8):(l=null,h('"optional"')),l===null&&(n.substr(t,8).toLowerCase()==="required"?(l=n.substr(t,8),t+=8):(l=null,h('"required"')),l===null&&(l=U())),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function ao(){var i,e,l,u,f,_;if(f=t,i=U(),i!==null){for(e=[],_=t,l=Se(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=Se(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function nu(){var i,e,l;if(l=t,e=g(),e!==null)for(i=[];e!==null;)i.push(e),e=g();else i=null;return i!==null&&(i=function(u,f){R=parseInt(f.join(""))}(l,i)),i===null&&(t=l),i}function ru(){var i,e;return e=t,i=uo(),i!==null&&(i=function(l){R=n.substring(t,l)}(e)),i===null&&(t=e),i}function uo(){var i,e,l,u,f,_,m,T;if(m=t,i=Si(),i!==null)if(e=W(),e!==null)if(l=Ri(),l!==null){for(u=[],T=t,f=ne(),f!==null?(_=jn(),_!==null?f=[f,_]:(f=null,t=T)):(f=null,t=T);f!==null;)u.push(f),T=t,f=ne(),f!==null?(_=jn(),_!==null?f=[f,_]:(f=null,t=T)):(f=null,t=T);u!==null?i=[i,e,l,u]:(i=null,t=m)}else i=null,t=m;else i=null,t=m;else i=null,t=m;return i}function Si(){var i;return i=Ci(),i===null&&(i=Ai()),i}function Ci(){var i;return n.substr(t,4).toLowerCase()==="text"?(i=n.substr(t,4),t+=4):(i=null,h('"text"')),i===null&&(n.substr(t,5).toLowerCase()==="image"?(i=n.substr(t,5),t+=5):(i=null,h('"image"')),i===null&&(n.substr(t,5).toLowerCase()==="audio"?(i=n.substr(t,5),t+=5):(i=null,h('"audio"')),i===null&&(n.substr(t,5).toLowerCase()==="video"?(i=n.substr(t,5),t+=5):(i=null,h('"video"')),i===null&&(n.substr(t,11).toLowerCase()==="application"?(i=n.substr(t,11),t+=11):(i=null,h('"application"')),i===null&&(i=on()))))),i}function Ai(){var i;return n.substr(t,7).toLowerCase()==="message"?(i=n.substr(t,7),t+=7):(i=null,h('"message"')),i===null&&(n.substr(t,9).toLowerCase()==="multipart"?(i=n.substr(t,9),t+=9):(i=null,h('"multipart"')),i===null&&(i=on())),i}function on(){var i;return i=U(),i===null&&(i=an()),i}function an(){var i,e,l;return l=t,n.substr(t,2).toLowerCase()==="x-"?(i=n.substr(t,2),t+=2):(i=null,h('"x-"')),i!==null?(e=U(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function Ri(){var i;return i=on(),i===null&&(i=U()),i}function jn(){var i,e,l,u;return u=t,i=U(),i!==null?(e=B(),e!==null?(l=Bn(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Bn(){var i;return i=U(),i===null&&(i=Ce()),i}function co(){var i,e,l,u;return u=t,i=fo(),i!==null?(e=me(),e!==null?(l=rn(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function fo(){var i,e,l;if(l=t,e=g(),e!==null)for(i=[];e!==null;)i.push(e),e=g();else i=null;return i!==null&&(i=function(u,f){R.value=parseInt(f.join(""))}(l,i)),i===null&&(t=l),i}function ho(){var i,e;return e=t,i=Qt(),i!==null&&(i=function(l,u){R=u}(e,i)),i===null&&(t=e),i}function iu(){var i,e,l,u,f,_,m;if(f=t,_=t,i=un(),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=ne(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=_)}else i=null,t=_;return i!==null&&(i=function(T,y){R.event=y.join("").toLowerCase()}(f,i[0])),i===null&&(t=f),i}function un(){var i,e,l,u,f,_;if(f=t,i=P(),i!==null){for(e=[],_=t,n.charCodeAt(t)===46?(l=".",t++):(l=null,h('"."')),l!==null?(u=P(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,n.charCodeAt(t)===46?(l=".",t++):(l=null,h('"."')),l!==null?(u=P(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function cn(){var i,e,l,u,f,_,m;if(f=t,_=t,i=fe(),i===null&&(i=kt()),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=Ii(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=ne(),l!==null?(u=Ii(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=_)}else i=null,t=_;return i!==null&&(i=function(T){var y=R.tag;try{R=new ds(R.uri,R.display_name,R.params),y&&R.setParam("tag",y)}catch{R=-1}}()),i===null&&(t=f),i}function Ii(){var i;return i=fn(),i===null&&(i=Ge()),i}function fn(){var i,e,l,u,f;return u=t,f=t,n.substr(t,3).toLowerCase()==="tag"?(i=n.substr(t,3),t+=3):(i=null,h('"tag"')),i!==null?(e=B(),e!==null?(l=U(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){R.tag=m}(u,i[2])),i===null&&(t=u),i}function bi(){var i,e,l;if(l=t,e=g(),e!==null)for(i=[];e!==null;)i.push(e),e=g();else i=null;return i!==null&&(i=function(u,f){R=parseInt(f.join(""))}(l,i)),i===null&&(t=l),i}function lu(){var i,e;return e=t,i=Qt(),i!==null&&(i=function(l,u){R=u}(e,i)),i===null&&(t=e),i}function ou(){var i,e,l,u,f,_,m,T,y,O;for(T=t,y=t,i=[],e=Mt();e!==null;)i.push(e),e=Mt();if(i!==null)if(e=Ue(),e!==null)if(l=Re(),l!==null)if(u=Ae(),u!==null){for(f=[],O=t,_=ne(),_!==null?(m=Ge(),m!==null?_=[_,m]:(_=null,t=O)):(_=null,t=O);_!==null;)f.push(_),O=t,_=ne(),_!==null?(m=Ge(),m!==null?_=[_,m]:(_=null,t=O)):(_=null,t=O);f!==null?i=[i,e,l,u,f]:(i=null,t=y)}else i=null,t=y;else i=null,t=y;else i=null,t=y;else i=null,t=y;return i!==null&&(i=function(se){try{R=new ds(R.uri,R.display_name,R.params)}catch{R=-1}}()),i===null&&(t=T),i}function au(){var i;return i=wi(),i}function wi(){var i,e,l,u,f,_,m,T;if(m=t,n.substr(t,6).toLowerCase()==="digest"?(i=n.substr(t,6),t+=6):(i=null,h('"Digest"')),i!==null)if(e=me(),e!==null)if(l=es(),l!==null){for(u=[],T=t,f=Se(),f!==null?(_=es(),_!==null?f=[f,_]:(f=null,t=T)):(f=null,t=T);f!==null;)u.push(f),T=t,f=Se(),f!==null?(_=es(),_!==null?f=[f,_]:(f=null,t=T)):(f=null,t=T);u!==null?i=[i,e,l,u]:(i=null,t=m)}else i=null,t=m;else i=null,t=m;else i=null,t=m;return i===null&&(i=Gn()),i}function Gn(){var i,e,l,u,f,_,m,T;if(m=t,i=U(),i!==null)if(e=me(),e!==null)if(l=ks(),l!==null){for(u=[],T=t,f=Se(),f!==null?(_=ks(),_!==null?f=[f,_]:(f=null,t=T)):(f=null,t=T);f!==null;)u.push(f),T=t,f=Se(),f!==null?(_=ks(),_!==null?f=[f,_]:(f=null,t=T)):(f=null,t=T);u!==null?i=[i,e,l,u]:(i=null,t=m)}else i=null,t=m;else i=null,t=m;else i=null,t=m;return i}function ks(){var i,e,l,u;return u=t,i=U(),i!==null?(e=B(),e!==null?(l=U(),l===null&&(l=Ce()),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function es(){var i;return i=hn(),i===null&&(i=Di(),i===null&&(i=dn(),i===null&&(i=Ui(),i===null&&(i=Pi(),i===null&&(i=ki(),i===null&&(i=Mi(),i===null&&(i=ks()))))))),i}function hn(){var i,e,l,u;return u=t,n.substr(t,5).toLowerCase()==="realm"?(i=n.substr(t,5),t+=5):(i=null,h('"realm"')),i!==null?(e=B(),e!==null?(l=Oi(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Oi(){var i,e;return e=t,i=be(),i!==null&&(i=function(l,u){R.realm=u}(e,i)),i===null&&(t=e),i}function Di(){var i,e,l,u,f,_,m,T,y;if(T=t,n.substr(t,6).toLowerCase()==="domain"?(i=n.substr(t,6),t+=6):(i=null,h('"domain"')),i!==null)if(e=B(),e!==null)if(l=tt(),l!==null)if(u=_n(),u!==null){if(f=[],y=t,m=w(),m!==null)for(_=[];m!==null;)_.push(m),m=w();else _=null;for(_!==null?(m=_n(),m!==null?_=[_,m]:(_=null,t=y)):(_=null,t=y);_!==null;){if(f.push(_),y=t,m=w(),m!==null)for(_=[];m!==null;)_.push(m),m=w();else _=null;_!==null?(m=_n(),m!==null?_=[_,m]:(_=null,t=y)):(_=null,t=y)}f!==null?(_=st(),_!==null?i=[i,e,l,u,f,_]:(i=null,t=T)):(i=null,t=T)}else i=null,t=T;else i=null,t=T;else i=null,t=T;else i=null,t=T;return i}function _n(){var i;return i=Mn(),i===null&&(i=tn()),i}function dn(){var i,e,l,u;return u=t,n.substr(t,5).toLowerCase()==="nonce"?(i=n.substr(t,5),t+=5):(i=null,h('"nonce"')),i!==null?(e=B(),e!==null?(l=Ni(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Ni(){var i,e;return e=t,i=be(),i!==null&&(i=function(l,u){R.nonce=u}(e,i)),i===null&&(t=e),i}function Ui(){var i,e,l,u,f;return u=t,f=t,n.substr(t,6).toLowerCase()==="opaque"?(i=n.substr(t,6),t+=6):(i=null,h('"opaque"')),i!==null?(e=B(),e!==null?(l=be(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){R.opaque=m}(u,i[2])),i===null&&(t=u),i}function Pi(){var i,e,l,u,f;return u=t,n.substr(t,5).toLowerCase()==="stale"?(i=n.substr(t,5),t+=5):(i=null,h('"stale"')),i!==null?(e=B(),e!==null?(f=t,n.substr(t,4).toLowerCase()==="true"?(l=n.substr(t,4),t+=4):(l=null,h('"true"')),l!==null&&(l=function(_){R.stale=!0}()),l===null&&(t=f),l===null&&(f=t,n.substr(t,5).toLowerCase()==="false"?(l=n.substr(t,5),t+=5):(l=null,h('"false"')),l!==null&&(l=function(_){R.stale=!1}()),l===null&&(t=f)),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function ki(){var i,e,l,u,f;return u=t,f=t,n.substr(t,9).toLowerCase()==="algorithm"?(i=n.substr(t,9),t+=9):(i=null,h('"algorithm"')),i!==null?(e=B(),e!==null?(n.substr(t,3).toLowerCase()==="md5"?(l=n.substr(t,3),t+=3):(l=null,h('"MD5"')),l===null&&(n.substr(t,8).toLowerCase()==="md5-sess"?(l=n.substr(t,8),t+=8):(l=null,h('"MD5-sess"')),l===null&&(l=U())),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){R.algorithm=m.toUpperCase()}(u,i[2])),i===null&&(t=u),i}function Mi(){var i,e,l,u,f,_,m,T,y,O;if(T=t,n.substr(t,3).toLowerCase()==="qop"?(i=n.substr(t,3),t+=3):(i=null,h('"qop"')),i!==null)if(e=B(),e!==null)if(l=tt(),l!==null){if(y=t,u=pn(),u!==null){for(f=[],O=t,n.charCodeAt(t)===44?(_=",",t++):(_=null,h('","')),_!==null?(m=pn(),m!==null?_=[_,m]:(_=null,t=O)):(_=null,t=O);_!==null;)f.push(_),O=t,n.charCodeAt(t)===44?(_=",",t++):(_=null,h('","')),_!==null?(m=pn(),m!==null?_=[_,m]:(_=null,t=O)):(_=null,t=O);f!==null?u=[u,f]:(u=null,t=y)}else u=null,t=y;u!==null?(f=st(),f!==null?i=[i,e,l,u,f]:(i=null,t=T)):(i=null,t=T)}else i=null,t=T;else i=null,t=T;else i=null,t=T;return i}function pn(){var i,e;return e=t,n.substr(t,8).toLowerCase()==="auth-int"?(i=n.substr(t,8),t+=8):(i=null,h('"auth-int"')),i===null&&(n.substr(t,4).toLowerCase()==="auth"?(i=n.substr(t,4),t+=4):(i=null,h('"auth"')),i===null&&(i=U())),i!==null&&(i=function(l,u){R.qop||(R.qop=[]),R.qop.push(u.toLowerCase())}(e,i)),i===null&&(t=e),i}function Kn(){var i,e,l,u,f,_;if(f=t,i=U(),i!==null){for(e=[],_=t,l=Se(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=Se(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function uu(){var i,e,l,u,f,_,m;if(f=t,_=t,i=Wn(),i!==null){for(e=[],m=t,l=Se(),l!==null?(u=Wn(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=Se(),l!==null?(u=Wn(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=_)}else i=null,t=_;return i!==null&&(i=function(T){var y,O;for(O=R.multi_header.length,y=0;y<O;y++)if(R.multi_header[y].parsed===null){R=null;break}R!==null?R=R.multi_header:R=-1}()),i===null&&(t=f),i}function Wn(){var i,e,l,u,f,_,m;if(f=t,_=t,i=kt(),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=ne(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=_)}else i=null,t=_;return i!==null&&(i=function(T){var y;R.multi_header||(R.multi_header=[]);try{y=new ds(R.uri,R.display_name,R.params),delete R.uri,delete R.display_name,delete R.params}catch{y=null}R.multi_header.push({possition:t,offset:T,parsed:y})}(f)),i===null&&(t=f),i}function Yn(){var i,e,l,u,f,_,m;if(f=t,_=t,n.substr(t,3).toLowerCase()==="sip"?(i=n.substr(t,3),t+=3):(i=null,h('"SIP"')),i===null&&(i=U()),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=xi(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=ne(),l!==null?(u=xi(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=_)}else i=null,t=_;return i!==null&&(i=function(T,y){if(R.protocol=y.toLowerCase(),R.params||(R.params={}),R.params.text&&R.params.text[0]==='"'){var O=R.params.text;R.text=O.substring(1,O.length-1),delete R.params.text}}(f,i[0])),i===null&&(t=f),i}function xi(){var i;return i=zn(),i===null&&(i=Ge()),i}function zn(){var i,e,l,u,f,_;if(f=t,_=t,n.substr(t,5).toLowerCase()==="cause"?(i=n.substr(t,5),t+=5):(i=null,h('"cause"')),i!==null)if(e=B(),e!==null){if(u=g(),u!==null)for(l=[];u!==null;)l.push(u),u=g();else l=null;l!==null?i=[i,e,l]:(i=null,t=_)}else i=null,t=_;else i=null,t=_;return i!==null&&(i=function(m,T){R.cause=parseInt(T.join(""))}(f,i[2])),i===null&&(t=f),i}function _o(){var i,e,l,u,f,_;if(f=t,i=U(),i!==null){for(e=[],_=t,l=Se(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=Se(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function cu(){var i,e,l,u,f,_;if(f=t,i=Jn(),i!==null){for(e=[],_=t,l=Se(),l!==null?(u=Jn(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=Se(),l!==null?(u=Jn(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Jn(){var i,e,l,u,f,_;if(f=t,i=kt(),i!==null){for(e=[],_=t,l=ne(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=ne(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Xn(){var i,e,l,u,f,_;if(f=t,i=po(),i!==null){for(e=[],_=t,l=ne(),l!==null?(u=Qn(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=ne(),l!==null?(u=Qn(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function po(){var i,e;return e=t,n.substr(t,6).toLowerCase()==="active"?(i=n.substr(t,6),t+=6):(i=null,h('"active"')),i===null&&(n.substr(t,7).toLowerCase()==="pending"?(i=n.substr(t,7),t+=7):(i=null,h('"pending"')),i===null&&(n.substr(t,10).toLowerCase()==="terminated"?(i=n.substr(t,10),t+=10):(i=null,h('"terminated"')),i===null&&(i=U()))),i!==null&&(i=function(l){R.state=n.substring(t,l)}(e)),i===null&&(t=e),i}function Qn(){var i,e,l,u,f;return u=t,f=t,n.substr(t,6).toLowerCase()==="reason"?(i=n.substr(t,6),t+=6):(i=null,h('"reason"')),i!==null?(e=B(),e!==null?(l=Zn(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){typeof m<"u"&&(R.reason=m)}(u,i[2])),i===null&&(t=u),i===null&&(u=t,f=t,n.substr(t,7).toLowerCase()==="expires"?(i=n.substr(t,7),t+=7):(i=null,h('"expires"')),i!==null?(e=B(),e!==null?(l=Qt(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){typeof m<"u"&&(R.expires=m)}(u,i[2])),i===null&&(t=u),i===null&&(u=t,f=t,n.substr(t,11).toLowerCase()==="retry_after"?(i=n.substr(t,11),t+=11):(i=null,h('"retry_after"')),i!==null?(e=B(),e!==null?(l=Qt(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){typeof m<"u"&&(R.retry_after=m)}(u,i[2])),i===null&&(t=u),i===null&&(i=Ge()))),i}function Zn(){var i;return n.substr(t,11).toLowerCase()==="deactivated"?(i=n.substr(t,11),t+=11):(i=null,h('"deactivated"')),i===null&&(n.substr(t,9).toLowerCase()==="probation"?(i=n.substr(t,9),t+=9):(i=null,h('"probation"')),i===null&&(n.substr(t,8).toLowerCase()==="rejected"?(i=n.substr(t,8),t+=8):(i=null,h('"rejected"')),i===null&&(n.substr(t,7).toLowerCase()==="timeout"?(i=n.substr(t,7),t+=7):(i=null,h('"timeout"')),i===null&&(n.substr(t,6).toLowerCase()==="giveup"?(i=n.substr(t,6),t+=6):(i=null,h('"giveup"')),i===null&&(n.substr(t,10).toLowerCase()==="noresource"?(i=n.substr(t,10),t+=10):(i=null,h('"noresource"')),i===null&&(n.substr(t,9).toLowerCase()==="invariant"?(i=n.substr(t,9),t+=9):(i=null,h('"invariant"')),i===null&&(i=U()))))))),i}function mo(){var i;return i=j(),i=i!==null?i:"",i}function fu(){var i,e,l,u,f,_;if(f=t,i=U(),i!==null){for(e=[],_=t,l=Se(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=Se(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i=i!==null?i:"",i}function hu(){var i,e,l,u,f,_,m;if(f=t,_=t,i=fe(),i===null&&(i=kt()),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=Li(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=ne(),l!==null?(u=Li(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=_)}else i=null,t=_;return i!==null&&(i=function(T){var y=R.tag;try{R=new ds(R.uri,R.display_name,R.params),y&&R.setParam("tag",y)}catch{R=-1}}()),i===null&&(t=f),i}function Li(){var i;return i=fn(),i===null&&(i=Ge()),i}function $i(){var i,e,l,u,f,_;if(f=t,i=er(),i!==null){for(e=[],_=t,l=Se(),l!==null?(u=er(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=Se(),l!==null?(u=er(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function er(){var i,e,l,u,f,_,m,T;if(m=t,i=Bi(),i!==null)if(e=me(),e!==null)if(l=Wi(),l!==null){for(u=[],T=t,f=ne(),f!==null?(_=Ms(),_!==null?f=[f,_]:(f=null,t=T)):(f=null,t=T);f!==null;)u.push(f),T=t,f=ne(),f!==null?(_=Ms(),_!==null?f=[f,_]:(f=null,t=T)):(f=null,t=T);u!==null?i=[i,e,l,u]:(i=null,t=m)}else i=null,t=m;else i=null,t=m;else i=null,t=m;return i}function Ms(){var i;return i=tr(),i===null&&(i=Hi(),i===null&&(i=Fi(),i===null&&(i=qi(),i===null&&(i=Vi(),i===null&&(i=Ge()))))),i}function tr(){var i,e,l,u,f;return u=t,f=t,n.substr(t,3).toLowerCase()==="ttl"?(i=n.substr(t,3),t+=3):(i=null,h('"ttl"')),i!==null?(e=B(),e!==null?(l=sr(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){R.ttl=m}(u,i[2])),i===null&&(t=u),i}function Hi(){var i,e,l,u,f;return u=t,f=t,n.substr(t,5).toLowerCase()==="maddr"?(i=n.substr(t,5),t+=5):(i=null,h('"maddr"')),i!==null?(e=B(),e!==null?(l=Xt(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){R.maddr=m}(u,i[2])),i===null&&(t=u),i}function Fi(){var i,e,l,u,f;return u=t,f=t,n.substr(t,8).toLowerCase()==="received"?(i=n.substr(t,8),t+=8):(i=null,h('"received"')),i!==null?(e=B(),e!==null?(l=nt(),l===null&&(l=Xs()),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){R.received=m}(u,i[2])),i===null&&(t=u),i}function qi(){var i,e,l,u,f;return u=t,f=t,n.substr(t,6).toLowerCase()==="branch"?(i=n.substr(t,6),t+=6):(i=null,h('"branch"')),i!==null?(e=B(),e!==null?(l=U(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){R.branch=m}(u,i[2])),i===null&&(t=u),i}function Vi(){var i,e,l,u,f;return u=t,n.substr(t,5).toLowerCase()==="rport"?(i=n.substr(t,5),t+=5):(i=null,h('"rport"')),i!==null?(f=t,e=B(),e!==null?(l=ji(),l!==null?e=[e,l]:(e=null,t=f)):(e=null,t=f),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i}function ji(){var i,e,l,u,f,_,m;return _=t,m=t,i=g(),i=i!==null?i:"",i!==null?(e=g(),e=e!==null?e:"",e!==null?(l=g(),l=l!==null?l:"",l!==null?(u=g(),u=u!==null?u:"",u!==null?(f=g(),f=f!==null?f:"",f!==null?i=[i,e,l,u,f]:(i=null,t=m)):(i=null,t=m)):(i=null,t=m)):(i=null,t=m)):(i=null,t=m),i!==null&&(i=function(T,y){R.rport=parseInt(y.join(""))}(_,i)),i===null&&(t=_),i}function Bi(){var i,e,l,u,f,_;return _=t,i=Gi(),i!==null?(e=W(),e!==null?(l=U(),l!==null?(u=W(),u!==null?(f=Ki(),f!==null?i=[i,e,l,u,f]:(i=null,t=_)):(i=null,t=_)):(i=null,t=_)):(i=null,t=_)):(i=null,t=_),i}function Gi(){var i,e;return e=t,n.substr(t,3).toLowerCase()==="sip"?(i=n.substr(t,3),t+=3):(i=null,h('"SIP"')),i===null&&(i=U()),i!==null&&(i=function(l,u){R.protocol=u}(e,i)),i===null&&(t=e),i}function Ki(){var i,e;return e=t,n.substr(t,3).toLowerCase()==="udp"?(i=n.substr(t,3),t+=3):(i=null,h('"UDP"')),i===null&&(n.substr(t,3).toLowerCase()==="tcp"?(i=n.substr(t,3),t+=3):(i=null,h('"TCP"')),i===null&&(n.substr(t,3).toLowerCase()==="tls"?(i=n.substr(t,3),t+=3):(i=null,h('"TLS"')),i===null&&(n.substr(t,4).toLowerCase()==="sctp"?(i=n.substr(t,4),t+=4):(i=null,h('"SCTP"')),i===null&&(i=U())))),i!==null&&(i=function(l,u){R.transport=u}(e,i)),i===null&&(t=e),i}function Wi(){var i,e,l,u,f;return u=t,i=Yi(),i!==null?(f=t,e=Te(),e!==null?(l=zi(),l!==null?e=[e,l]:(e=null,t=f)):(e=null,t=f),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i}function Yi(){var i,e;return e=t,i=nt(),i===null&&(i=Un(),i===null&&(i=hs())),i!==null&&(i=function(l){R.host=n.substring(t,l)}(e)),i===null&&(t=e),i}function zi(){var i,e,l,u,f,_,m;return _=t,m=t,i=g(),i=i!==null?i:"",i!==null?(e=g(),e=e!==null?e:"",e!==null?(l=g(),l=l!==null?l:"",l!==null?(u=g(),u=u!==null?u:"",u!==null?(f=g(),f=f!==null?f:"",f!==null?i=[i,e,l,u,f]:(i=null,t=m)):(i=null,t=m)):(i=null,t=m)):(i=null,t=m)):(i=null,t=m),i!==null&&(i=function(T,y){R.port=parseInt(y.join(""))}(_,i)),i===null&&(t=_),i}function sr(){var i,e,l,u,f;return u=t,f=t,i=g(),i!==null?(e=g(),e=e!==null?e:"",e!==null?(l=g(),l=l!==null?l:"",l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){return parseInt(m.join(""))}(u,i)),i===null&&(t=u),i}function Ji(){var i;return i=wi(),i}function _u(){var i,e,l,u,f,_;if(f=t,i=go(),i!==null){for(e=[],_=t,l=ne(),l!==null?(u=nr(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=ne(),l!==null?(u=nr(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function go(){var i,e;return e=t,i=Qt(),i!==null&&(i=function(l,u){R.expires=u}(e,i)),i===null&&(t=e),i}function nr(){var i;return i=rr(),i===null&&(i=Ge()),i}function rr(){var i,e,l,u,f;return u=t,f=t,n.substr(t,9).toLowerCase()==="refresher"?(i=n.substr(t,9),t+=9):(i=null,h('"refresher"')),i!==null?(e=B(),e!==null?(n.substr(t,3).toLowerCase()==="uac"?(l=n.substr(t,3),t+=3):(l=null,h('"uac"')),l===null&&(n.substr(t,3).toLowerCase()==="uas"?(l=n.substr(t,3),t+=3):(l=null,h('"uas"'))),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){R.refresher=m.toLowerCase()}(u,i[2])),i===null&&(t=u),i}function vo(){var i,e,l,u;return u=t,i=U(),i!==null?(e=D(),e!==null?(l=To(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function To(){var i,e;for(i=[],e=V(),e===null&&(e=$(),e===null&&(e=me()));e!==null;)i.push(e),e=V(),e===null&&(e=$(),e===null&&(e=me()));return i}function Eo(){var i,e;for(i=[],e=C();e!==null;)i.push(e),e=C();return i}function du(){var i,e,l;return l=t,n.substr(t,5)==="uuid:"?(i="uuid:",t+=5):(i=null,h('"uuid:"')),i!==null?(e=yo(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function yo(){var i,e,l,u,f,_,m,T,y,O,se;return O=t,se=t,i=Lt(),i!==null?(n.charCodeAt(t)===45?(e="-",t++):(e=null,h('"-"')),e!==null?(l=xt(),l!==null?(n.charCodeAt(t)===45?(u="-",t++):(u=null,h('"-"')),u!==null?(f=xt(),f!==null?(n.charCodeAt(t)===45?(_="-",t++):(_=null,h('"-"')),_!==null?(m=xt(),m!==null?(n.charCodeAt(t)===45?(T="-",t++):(T=null,h('"-"')),T!==null?(y=Xi(),y!==null?i=[i,e,l,u,f,_,m,T,y]:(i=null,t=se)):(i=null,t=se)):(i=null,t=se)):(i=null,t=se)):(i=null,t=se)):(i=null,t=se)):(i=null,t=se)):(i=null,t=se)):(i=null,t=se),i!==null&&(i=function(De,At){R=n.substring(t+5,De)}(O,i[0])),i===null&&(t=O),i}function xt(){var i,e,l,u,f;return f=t,i=E(),i!==null?(e=E(),e!==null?(l=E(),l!==null?(u=E(),u!==null?i=[i,e,l,u]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i}function Lt(){var i,e,l;return l=t,i=xt(),i!==null?(e=xt(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function Xi(){var i,e,l,u;return u=t,i=xt(),i!==null?(e=xt(),e!==null?(l=xt(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function So(){var i,e,l,u,f,_,m;if(f=t,_=t,i=fe(),i===null&&(i=kt()),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=ne(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=_)}else i=null,t=_;return i!==null&&(i=function(T){try{R=new ds(R.uri,R.display_name,R.params)}catch{R=-1}}()),i===null&&(t=f),i}function pu(){var i,e,l,u,f,_;if(f=t,i=Co(),i!==null){for(e=[],_=t,l=ne(),l!==null?(u=ir(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=ne(),l!==null?(u=ir(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Co(){var i,e,l,u,f,_;return u=t,f=t,i=et(),i!==null?(_=t,n.charCodeAt(t)===64?(e="@",t++):(e=null,h('"@"')),e!==null?(l=et(),l!==null?e=[e,l]:(e=null,t=_)):(e=null,t=_),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m){R.call_id=n.substring(t,m)}(u)),i===null&&(t=u),i}function ir(){var i;return i=lr(),i===null&&(i=Qi(),i===null&&(i=Zi(),i===null&&(i=Ge()))),i}function lr(){var i,e,l,u,f;return u=t,f=t,n.substr(t,6)==="to-tag"?(i="to-tag",t+=6):(i=null,h('"to-tag"')),i!==null?(e=B(),e!==null?(l=U(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){R.to_tag=m}(u,i[2])),i===null&&(t=u),i}function Qi(){var i,e,l,u,f;return u=t,f=t,n.substr(t,8)==="from-tag"?(i="from-tag",t+=8):(i=null,h('"from-tag"')),i!==null?(e=B(),e!==null?(l=U(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){R.from_tag=m}(u,i[2])),i===null&&(t=u),i}function Zi(){var i,e;return e=t,n.substr(t,10)==="early-only"?(i="early-only",t+=10):(i=null,h('"early-only"')),i!==null&&(i=function(l){R.early_only=!0}()),i===null&&(t=e),i}function Ao(i){i.sort();for(var e=null,l=[],u=0;u<i.length;u++)i[u]!==e&&(l.push(i[u]),e=i[u]);return l}function mu(){for(var i=1,e=1,l=!1,u=0;u<Math.max(t,s);u++){var f=n.charAt(u);f===`
|
75
|
-
`?(l||i++,e=1,l=!1):f==="\r"||f==="\u2028"||f==="\u2029"?(i++,e=1,l=!0):(e++,l=!1)}return{line:i,column:e}}var Ro=is(),ds=Ta(),R={},b=a[o]();if(b===null||t!==n.length){var el=Math.max(t,s),tl=el<n.length?n.charAt(el):null,Io=mu();return new this.SyntaxError(Ao(p),tl,el,Io.line,Io.column),-1}return R},toSource:function(){return this._source}};return r.SyntaxError=function(n,o,a,t,s){function p(h,d){var g,v;switch(h.length){case 0:g="end of input";break;case 1:g=h[0];break;default:g=h.slice(0,h.length-1).join(", ")+" or "+h[h.length-1]}return v=d?c(d):"end of input","Expected "+g+" but "+v+" found."}this.name="SyntaxError",this.expected=n,this.found=o,this.message=p(n,o),this.offset=a,this.line=t,this.column=s},r.SyntaxError.prototype=Error.prototype,r}()),Ea}var ya,Jc;function is(){if(Jc)return ya;Jc=1;const c=we,r=ft(),n=Gt();return ya=class sh{static parse(a){if(a=n.parse(a,"SIP_URI"),a!==-1)return a}constructor(a,t,s,p,h={},d={}){if(!s)throw new TypeError('missing or invalid "host" parameter');this._parameters={},this._headers={},this._scheme=a||c.SIP,this._user=t,this._host=s,this._port=p;for(const g in h)Object.prototype.hasOwnProperty.call(h,g)&&this.setParam(g,h[g]);for(const g in d)Object.prototype.hasOwnProperty.call(d,g)&&this.setHeader(g,d[g])}get scheme(){return this._scheme}set scheme(a){this._scheme=a.toLowerCase()}get user(){return this._user}set user(a){this._user=a}get host(){return this._host}set host(a){this._host=a.toLowerCase()}get port(){return this._port}set port(a){this._port=a===0?a:parseInt(a,10)||null}setParam(a,t){a&&(this._parameters[a.toLowerCase()]=typeof t>"u"||t===null?null:t.toString())}getParam(a){if(a)return this._parameters[a.toLowerCase()]}hasParam(a){if(a)return this._parameters.hasOwnProperty(a.toLowerCase())&&!0||!1}deleteParam(a){if(a=a.toLowerCase(),this._parameters.hasOwnProperty(a)){const t=this._parameters[a];return delete this._parameters[a],t}}clearParams(){this._parameters={}}setHeader(a,t){this._headers[r.headerize(a)]=Array.isArray(t)?t:[t]}getHeader(a){if(a)return this._headers[r.headerize(a)]}hasHeader(a){if(a)return this._headers.hasOwnProperty(r.headerize(a))&&!0||!1}deleteHeader(a){if(a=r.headerize(a),this._headers.hasOwnProperty(a)){const t=this._headers[a];return delete this._headers[a],t}}clearHeaders(){this._headers={}}clone(){return new sh(this._scheme,this._user,this._host,this._port,JSON.parse(JSON.stringify(this._parameters)),JSON.parse(JSON.stringify(this._headers)))}toString(){const a=[];let t=`${this._scheme}:`;this._user&&(t+=`${r.escapeUser(this._user)}@`),t+=this._host,(this._port||this._port===0)&&(t+=`:${this._port}`);for(const s in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,s)&&(t+=`;${s}`,this._parameters[s]!==null&&(t+=`=${this._parameters[s]}`));for(const s in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,s))for(const p of this._headers[s])a.push(`${s}=${p}`);return a.length>0&&(t+=`?${a.join("&")}`),t}toAor(a){let t=`${this._scheme}:`;return this._user&&(t+=`${r.escapeUser(this._user)}@`),t+=this._host,a&&(this._port||this._port===0)&&(t+=`:${this._port}`),t}},ya}var Xc;function ft(){if(Xc)return ze;Xc=1;const c=we,r=is(),n=Gt();ze.str_utf8_length=s=>unescape(encodeURIComponent(s)).length;const o=ze.isFunction=s=>s!==void 0?Object.prototype.toString.call(s)==="[object Function]":!1;ze.isString=s=>s!==void 0?Object.prototype.toString.call(s)==="[object String]":!1,ze.isDecimal=s=>!isNaN(s)&&parseFloat(s)===parseInt(s,10),ze.isEmpty=s=>s===null||s===""||s===void 0||Array.isArray(s)&&s.length===0||typeof s=="number"&&isNaN(s),ze.hasMethods=function(s,...p){for(const h of p)if(o(s[h]))return!1;return!0};const a=ze.createRandomToken=(s,p=32)=>{let h,d,g="";for(h=0;h<s;h++)d=Math.random()*p|0,g+=d.toString(p);return g};ze.newTag=()=>a(10),ze.newUUID=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,p=>{const h=Math.random()*16|0;return(p==="x"?h:h&3|8).toString(16)}),ze.hostType=s=>{if(s){if(s=n.parse(s,"host"),s!==-1)return s.host_type}else return};const t=ze.escapeUser=s=>encodeURIComponent(decodeURIComponent(s)).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/");return ze.normalizeTarget=(s,p)=>{if(s){if(s instanceof r)return s;if(typeof s=="string"){const h=s.split("@");let d,g;switch(h.length){case 1:if(!p)return;d=s,g=p;break;case 2:d=h[0],g=h[1];break;default:d=h.slice(0,h.length-1).join("@"),g=h[h.length-1]}d=d.replace(/^(sips?|tel):/i,""),/^[-.()]*\+?[0-9\-.()]+$/.test(d)&&(d=d.replace(/[-.()]/g,"")),s=`${c.SIP}:${t(d)}@${g}`;let v;return(v=r.parse(s))?v:void 0}else return}else return},ze.headerize=s=>{const p={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},h=s.toLowerCase().replace(/_/g,"-").split("-");let d="";const g=h.length;let v;for(v=0;v<g;v++)v!==0&&(d+="-"),d+=h[v].charAt(0).toUpperCase()+h[v].substring(1);return p[d]&&(d=p[d]),d},ze.sipErrorCause=s=>{for(const p in c.SIP_ERROR_CAUSES)if(c.SIP_ERROR_CAUSES[p].indexOf(s)!==-1)return c.causes[p];return c.causes.SIP_FAILURE_CODE},ze.getRandomTestNetIP=()=>{function s(p,h){return Math.floor(Math.random()*(h-p+1)+p)}return`192.0.2.${s(1,254)}`},ze.calculateMD5=s=>{function p(ge,Ee){return ge<<Ee|ge>>>32-Ee}function h(ge,Ee){const Ce=ge&2147483648,be=Ee&2147483648,he=ge&1073741824,ce=Ee&1073741824,fe=(ge&1073741823)+(Ee&1073741823);return he&ce?fe^2147483648^Ce^be:he|ce?fe&1073741824?fe^3221225472^Ce^be:fe^1073741824^Ce^be:fe^Ce^be}function d(ge,Ee,Ce){return ge&Ee|~ge&Ce}function g(ge,Ee,Ce){return ge&Ce|Ee&~Ce}function v(ge,Ee,Ce){return ge^Ee^Ce}function E(ge,Ee,Ce){return Ee^(ge|~Ce)}function S(ge,Ee,Ce,be,he,ce,fe){return ge=h(ge,h(h(d(Ee,Ce,be),he),fe)),h(p(ge,ce),Ee)}function C(ge,Ee,Ce,be,he,ce,fe){return ge=h(ge,h(h(g(Ee,Ce,be),he),fe)),h(p(ge,ce),Ee)}function I(ge,Ee,Ce,be,he,ce,fe){return ge=h(ge,h(h(v(Ee,Ce,be),he),fe)),h(p(ge,ce),Ee)}function w(ge,Ee,Ce,be,he,ce,fe){return ge=h(ge,h(h(E(Ee,Ce,be),he),fe)),h(p(ge,ce),Ee)}function F(ge){let Ee;const Ce=ge.length,be=Ce+8,ce=((be-be%64)/64+1)*16,fe=new Array(ce-1);let Re=0,Oe=0;for(;Oe<Ce;)Ee=(Oe-Oe%4)/4,Re=Oe%4*8,fe[Ee]=fe[Ee]|ge.charCodeAt(Oe)<<Re,Oe++;return Ee=(Oe-Oe%4)/4,Re=Oe%4*8,fe[Ee]=fe[Ee]|128<<Re,fe[ce-2]=Ce<<3,fe[ce-1]=Ce>>>29,fe}function L(ge){let Ee="",Ce="",be,he;for(he=0;he<=3;he++)be=ge>>>he*8&255,Ce=`0${be.toString(16)}`,Ee=Ee+Ce.substr(Ce.length-2,2);return Ee}function ie(ge){let Ee="";for(let Ce=0;Ce<ge.length;Ce++){const be=ge.charCodeAt(Ce);be<128?Ee+=String.fromCharCode(be):be>127&&be<2048?(Ee+=String.fromCharCode(be>>6|192),Ee+=String.fromCharCode(be&63|128)):(Ee+=String.fromCharCode(be>>12|224),Ee+=String.fromCharCode(be>>6&63|128),Ee+=String.fromCharCode(be&63|128))}return Ee}let N=[],H,ve,me,M,D,j,V,Y,$;const X=7,U=12,P=17,Z=22,et=5,Q=9,W=14,B=20,te=4,de=11,Ae=16,Ue=23,Se=6,ne=10,Te=15,tt=21;for(s=ie(s),N=F(s),j=1732584193,V=4023233417,Y=2562383102,$=271733878,H=0;H<N.length;H+=16)ve=j,me=V,M=Y,D=$,j=S(j,V,Y,$,N[H+0],X,3614090360),$=S($,j,V,Y,N[H+1],U,3905402710),Y=S(Y,$,j,V,N[H+2],P,606105819),V=S(V,Y,$,j,N[H+3],Z,3250441966),j=S(j,V,Y,$,N[H+4],X,4118548399),$=S($,j,V,Y,N[H+5],U,1200080426),Y=S(Y,$,j,V,N[H+6],P,2821735955),V=S(V,Y,$,j,N[H+7],Z,4249261313),j=S(j,V,Y,$,N[H+8],X,1770035416),$=S($,j,V,Y,N[H+9],U,2336552879),Y=S(Y,$,j,V,N[H+10],P,4294925233),V=S(V,Y,$,j,N[H+11],Z,2304563134),j=S(j,V,Y,$,N[H+12],X,1804603682),$=S($,j,V,Y,N[H+13],U,4254626195),Y=S(Y,$,j,V,N[H+14],P,2792965006),V=S(V,Y,$,j,N[H+15],Z,1236535329),j=C(j,V,Y,$,N[H+1],et,4129170786),$=C($,j,V,Y,N[H+6],Q,3225465664),Y=C(Y,$,j,V,N[H+11],W,643717713),V=C(V,Y,$,j,N[H+0],B,3921069994),j=C(j,V,Y,$,N[H+5],et,3593408605),$=C($,j,V,Y,N[H+10],Q,38016083),Y=C(Y,$,j,V,N[H+15],W,3634488961),V=C(V,Y,$,j,N[H+4],B,3889429448),j=C(j,V,Y,$,N[H+9],et,568446438),$=C($,j,V,Y,N[H+14],Q,3275163606),Y=C(Y,$,j,V,N[H+3],W,4107603335),V=C(V,Y,$,j,N[H+8],B,1163531501),j=C(j,V,Y,$,N[H+13],et,2850285829),$=C($,j,V,Y,N[H+2],Q,4243563512),Y=C(Y,$,j,V,N[H+7],W,1735328473),V=C(V,Y,$,j,N[H+12],B,2368359562),j=I(j,V,Y,$,N[H+5],te,4294588738),$=I($,j,V,Y,N[H+8],de,2272392833),Y=I(Y,$,j,V,N[H+11],Ae,1839030562),V=I(V,Y,$,j,N[H+14],Ue,4259657740),j=I(j,V,Y,$,N[H+1],te,2763975236),$=I($,j,V,Y,N[H+4],de,1272893353),Y=I(Y,$,j,V,N[H+7],Ae,4139469664),V=I(V,Y,$,j,N[H+10],Ue,3200236656),j=I(j,V,Y,$,N[H+13],te,681279174),$=I($,j,V,Y,N[H+0],de,3936430074),Y=I(Y,$,j,V,N[H+3],Ae,3572445317),V=I(V,Y,$,j,N[H+6],Ue,76029189),j=I(j,V,Y,$,N[H+9],te,3654602809),$=I($,j,V,Y,N[H+12],de,3873151461),Y=I(Y,$,j,V,N[H+15],Ae,530742520),V=I(V,Y,$,j,N[H+2],Ue,3299628645),j=w(j,V,Y,$,N[H+0],Se,4096336452),$=w($,j,V,Y,N[H+7],ne,1126891415),Y=w(Y,$,j,V,N[H+14],Te,2878612391),V=w(V,Y,$,j,N[H+5],tt,4237533241),j=w(j,V,Y,$,N[H+12],Se,1700485571),$=w($,j,V,Y,N[H+3],ne,2399980690),Y=w(Y,$,j,V,N[H+10],Te,4293915773),V=w(V,Y,$,j,N[H+1],tt,2240044497),j=w(j,V,Y,$,N[H+8],Se,1873313359),$=w($,j,V,Y,N[H+15],ne,4264355552),Y=w(Y,$,j,V,N[H+6],Te,2734768916),V=w(V,Y,$,j,N[H+13],tt,1309151649),j=w(j,V,Y,$,N[H+4],Se,4149444226),$=w($,j,V,Y,N[H+11],ne,3174756917),Y=w(Y,$,j,V,N[H+2],Te,718787259),V=w(V,Y,$,j,N[H+9],tt,3951481745),j=h(j,ve),V=h(V,me),Y=h(Y,M),$=h($,D);return(L(j)+L(V)+L(Y)+L($)).toLowerCase()},ze.closeMediaStream=s=>{if(s)try{let p;if(s.getTracks){p=s.getTracks();for(const h of p)h.stop()}else{p=s.getAudioTracks();for(const h of p)h.stop();p=s.getVideoTracks();for(const h of p)h.stop()}}catch{(typeof s.stop=="function"||typeof s.stop=="object")&&s.stop()}},ze.cloneArray=s=>s&&s.slice()||[],ze.cloneObject=(s,p={})=>s&&Object.assign({},s)||p,ze}const Qc=Ot,Vp=it,ht=we,Ze=ft(),Zc=Ta(),jp=Gt(),Sa=new Vp("SIPMessage");class ql{constructor(r,n,o,a,t,s){if(!r||!n||!o)return null;a=a||{},this.ua=o,this.headers={},this.method=r,this.ruri=n,this.body=s,this.extraHeaders=Ze.cloneArray(t),this.ua.configuration.extra_headers&&(this.extraHeaders=this.extraHeaders.concat(this.ua.configuration.extra_headers)),a.route_set?this.setHeader("route",a.route_set):o.configuration.use_preloaded_route&&this.setHeader("route",`<${o.transport.sip_uri};lr>`),this.setHeader("via",""),this.setHeader("max-forwards",ht.MAX_FORWARDS);const p=a.to_uri||n,h=a.to_tag?{tag:a.to_tag}:null,d=typeof a.to_display_name<"u"?a.to_display_name:null;this.to=new Zc(p,d,h),this.setHeader("to",this.to.toString());const g=a.from_uri||o.configuration.uri,v={tag:a.from_tag||Ze.newTag()};let E;typeof a.from_display_name<"u"?E=a.from_display_name:o.configuration.display_name?E=o.configuration.display_name:E=null,this.from=new Zc(g,E,v),this.setHeader("from",this.from.toString());const S=a.call_id||o.configuration.jssip_id+Ze.createRandomToken(15);this.call_id=S,this.setHeader("call-id",S);const C=a.cseq||Math.floor(Math.random()*1e4);this.cseq=C,this.setHeader("cseq",`${C} ${r}`)}setHeader(r,n){const o=new RegExp(`^\\s*${r}\\s*:`,"i");for(let a=0;a<this.extraHeaders.length;a++)o.test(this.extraHeaders[a])&&this.extraHeaders.splice(a,1);this.headers[Ze.headerize(r)]=Array.isArray(n)?n:[n]}getHeader(r){const n=this.headers[Ze.headerize(r)];if(n){if(n[0])return n[0]}else{const o=new RegExp(`^\\s*${r}\\s*:`,"i");for(const a of this.extraHeaders)if(o.test(a))return a.substring(a.indexOf(":")+1).trim()}}getHeaders(r){const n=this.headers[Ze.headerize(r)],o=[];if(n){for(const a of n)o.push(a);return o}else{const a=new RegExp(`^\\s*${r}\\s*:`,"i");for(const t of this.extraHeaders)a.test(t)&&o.push(t.substring(t.indexOf(":")+1).trim());return o}}hasHeader(r){if(this.headers[Ze.headerize(r)])return!0;{const n=new RegExp(`^\\s*${r}\\s*:`,"i");for(const o of this.extraHeaders)if(n.test(o))return!0}return!1}parseSDP(r){return!r&&this.sdp?this.sdp:(this.sdp=Qc.parse(this.body||""),this.sdp)}toString(){let r=`${this.method} ${this.ruri} SIP/2.0\r
|
74
|
+
`,t+=2):(i=null,h('"\\r\\n"')),i}function g(){var i;return/^[0-9]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[0-9]")),i}function v(){var i;return/^[a-zA-Z]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[a-zA-Z]")),i}function E(){var i;return/^[0-9a-fA-F]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[0-9a-fA-F]")),i}function S(){var i;return i=w(),i===null&&(i=F()),i}function C(){var i;return/^[\0-\xFF]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[\\0-\\xFF]")),i}function I(){var i;return/^["]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h('["]')),i}function w(){var i;return n.charCodeAt(t)===32?(i=" ",t++):(i=null,h('" "')),i}function F(){var i;return n.charCodeAt(t)===9?(i=" ",t++):(i=null,h('"\\t"')),i}function L(){var i;return/^[a-zA-Z0-9]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[a-zA-Z0-9]")),i}function ie(){var i;return n.charCodeAt(t)===59?(i=";",t++):(i=null,h('";"')),i===null&&(n.charCodeAt(t)===47?(i="/",t++):(i=null,h('"/"')),i===null&&(n.charCodeAt(t)===63?(i="?",t++):(i=null,h('"?"')),i===null&&(n.charCodeAt(t)===58?(i=":",t++):(i=null,h('":"')),i===null&&(n.charCodeAt(t)===64?(i="@",t++):(i=null,h('"@"')),i===null&&(n.charCodeAt(t)===38?(i="&",t++):(i=null,h('"&"')),i===null&&(n.charCodeAt(t)===61?(i="=",t++):(i=null,h('"="')),i===null&&(n.charCodeAt(t)===43?(i="+",t++):(i=null,h('"+"')),i===null&&(n.charCodeAt(t)===36?(i="$",t++):(i=null,h('"$"')),i===null&&(n.charCodeAt(t)===44?(i=",",t++):(i=null,h('","'))))))))))),i}function N(){var i;return i=L(),i===null&&(i=H()),i}function H(){var i;return n.charCodeAt(t)===45?(i="-",t++):(i=null,h('"-"')),i===null&&(n.charCodeAt(t)===95?(i="_",t++):(i=null,h('"_"')),i===null&&(n.charCodeAt(t)===46?(i=".",t++):(i=null,h('"."')),i===null&&(n.charCodeAt(t)===33?(i="!",t++):(i=null,h('"!"')),i===null&&(n.charCodeAt(t)===126?(i="~",t++):(i=null,h('"~"')),i===null&&(n.charCodeAt(t)===42?(i="*",t++):(i=null,h('"*"')),i===null&&(n.charCodeAt(t)===39?(i="'",t++):(i=null,h(`"'"`)),i===null&&(n.charCodeAt(t)===40?(i="(",t++):(i=null,h('"("')),i===null&&(n.charCodeAt(t)===41?(i=")",t++):(i=null,h('")"')))))))))),i}function ve(){var i,e,l,u,f;return u=t,f=t,n.charCodeAt(t)===37?(i="%",t++):(i=null,h('"%"')),i!==null?(e=E(),e!==null?(l=E(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){return m.join("")}(u,i)),i===null&&(t=u),i}function me(){var i,e,l,u,f,_;for(u=t,f=t,_=t,i=[],e=S();e!==null;)i.push(e),e=S();if(i!==null?(e=d(),e!==null?i=[i,e]:(i=null,t=_)):(i=null,t=_),i=i!==null?i:"",i!==null){if(l=S(),l!==null)for(e=[];l!==null;)e.push(l),l=S();else e=null;e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i!==null&&(i=function(m){return" "}()),i===null&&(t=u),i}function M(){var i;return i=me(),i=i!==null?i:"",i}function D(){var i,e,l,u,f;for(u=t,f=t,i=[],e=w(),e===null&&(e=F());e!==null;)i.push(e),e=w(),e===null&&(e=F());return i!==null?(n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_){return":"}()),i===null&&(t=u),i}function j(){var i,e,l,u,f,_,m;if(f=t,_=t,e=V(),e!==null)for(i=[];e!==null;)i.push(e),e=V();else i=null;if(i!==null){for(e=[],m=t,l=[],u=me();u!==null;)l.push(u),u=me();for(l!==null?(u=V(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;){for(e.push(l),m=t,l=[],u=me();u!==null;)l.push(u),u=me();l!==null?(u=V(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m)}e!==null?i=[i,e]:(i=null,t=_)}else i=null,t=_;return i!==null&&(i=function(T){return n.substring(t,T)}(f)),i===null&&(t=f),i}function V(){var i;return/^[!-~]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[!-~]")),i===null&&(i=Y()),i}function Y(){var i;return/^[\x80-\uFFFF]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[\\x80-\\uFFFF]")),i}function $(){var i;return/^[\x80-\xBF]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[\\x80-\\xBF]")),i}function X(){var i;return i=g(),i===null&&(/^[a-f]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[a-f]"))),i}function U(){var i,e,l;if(l=t,e=L(),e===null&&(n.charCodeAt(t)===45?(e="-",t++):(e=null,h('"-"')),e===null&&(n.charCodeAt(t)===46?(e=".",t++):(e=null,h('"."')),e===null&&(n.charCodeAt(t)===33?(e="!",t++):(e=null,h('"!"')),e===null&&(n.charCodeAt(t)===37?(e="%",t++):(e=null,h('"%"')),e===null&&(n.charCodeAt(t)===42?(e="*",t++):(e=null,h('"*"')),e===null&&(n.charCodeAt(t)===95?(e="_",t++):(e=null,h('"_"')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,h('"+"')),e===null&&(n.charCodeAt(t)===96?(e="`",t++):(e=null,h('"`"')),e===null&&(n.charCodeAt(t)===39?(e="'",t++):(e=null,h(`"'"`)),e===null&&(n.charCodeAt(t)===126?(e="~",t++):(e=null,h('"~"')))))))))))),e!==null)for(i=[];e!==null;)i.push(e),e=L(),e===null&&(n.charCodeAt(t)===45?(e="-",t++):(e=null,h('"-"')),e===null&&(n.charCodeAt(t)===46?(e=".",t++):(e=null,h('"."')),e===null&&(n.charCodeAt(t)===33?(e="!",t++):(e=null,h('"!"')),e===null&&(n.charCodeAt(t)===37?(e="%",t++):(e=null,h('"%"')),e===null&&(n.charCodeAt(t)===42?(e="*",t++):(e=null,h('"*"')),e===null&&(n.charCodeAt(t)===95?(e="_",t++):(e=null,h('"_"')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,h('"+"')),e===null&&(n.charCodeAt(t)===96?(e="`",t++):(e=null,h('"`"')),e===null&&(n.charCodeAt(t)===39?(e="'",t++):(e=null,h(`"'"`)),e===null&&(n.charCodeAt(t)===126?(e="~",t++):(e=null,h('"~"'))))))))))));else i=null;return i!==null&&(i=function(u){return n.substring(t,u)}(l)),i===null&&(t=l),i}function P(){var i,e,l;if(l=t,e=L(),e===null&&(n.charCodeAt(t)===45?(e="-",t++):(e=null,h('"-"')),e===null&&(n.charCodeAt(t)===33?(e="!",t++):(e=null,h('"!"')),e===null&&(n.charCodeAt(t)===37?(e="%",t++):(e=null,h('"%"')),e===null&&(n.charCodeAt(t)===42?(e="*",t++):(e=null,h('"*"')),e===null&&(n.charCodeAt(t)===95?(e="_",t++):(e=null,h('"_"')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,h('"+"')),e===null&&(n.charCodeAt(t)===96?(e="`",t++):(e=null,h('"`"')),e===null&&(n.charCodeAt(t)===39?(e="'",t++):(e=null,h(`"'"`)),e===null&&(n.charCodeAt(t)===126?(e="~",t++):(e=null,h('"~"'))))))))))),e!==null)for(i=[];e!==null;)i.push(e),e=L(),e===null&&(n.charCodeAt(t)===45?(e="-",t++):(e=null,h('"-"')),e===null&&(n.charCodeAt(t)===33?(e="!",t++):(e=null,h('"!"')),e===null&&(n.charCodeAt(t)===37?(e="%",t++):(e=null,h('"%"')),e===null&&(n.charCodeAt(t)===42?(e="*",t++):(e=null,h('"*"')),e===null&&(n.charCodeAt(t)===95?(e="_",t++):(e=null,h('"_"')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,h('"+"')),e===null&&(n.charCodeAt(t)===96?(e="`",t++):(e=null,h('"`"')),e===null&&(n.charCodeAt(t)===39?(e="'",t++):(e=null,h(`"'"`)),e===null&&(n.charCodeAt(t)===126?(e="~",t++):(e=null,h('"~"')))))))))));else i=null;return i!==null&&(i=function(u){return n.substring(t,u)}(l)),i===null&&(t=l),i}function Z(){var i;return n.charCodeAt(t)===40?(i="(",t++):(i=null,h('"("')),i===null&&(n.charCodeAt(t)===41?(i=")",t++):(i=null,h('")"')),i===null&&(n.charCodeAt(t)===60?(i="<",t++):(i=null,h('"<"')),i===null&&(n.charCodeAt(t)===62?(i=">",t++):(i=null,h('">"')),i===null&&(n.charCodeAt(t)===64?(i="@",t++):(i=null,h('"@"')),i===null&&(n.charCodeAt(t)===44?(i=",",t++):(i=null,h('","')),i===null&&(n.charCodeAt(t)===59?(i=";",t++):(i=null,h('";"')),i===null&&(n.charCodeAt(t)===58?(i=":",t++):(i=null,h('":"')),i===null&&(n.charCodeAt(t)===92?(i="\\",t++):(i=null,h('"\\\\"')),i===null&&(i=I(),i===null&&(n.charCodeAt(t)===47?(i="/",t++):(i=null,h('"/"')),i===null&&(n.charCodeAt(t)===91?(i="[",t++):(i=null,h('"["')),i===null&&(n.charCodeAt(t)===93?(i="]",t++):(i=null,h('"]"')),i===null&&(n.charCodeAt(t)===63?(i="?",t++):(i=null,h('"?"')),i===null&&(n.charCodeAt(t)===61?(i="=",t++):(i=null,h('"="')),i===null&&(n.charCodeAt(t)===123?(i="{",t++):(i=null,h('"{"')),i===null&&(n.charCodeAt(t)===125?(i="}",t++):(i=null,h('"}"')),i===null&&(i=w(),i===null&&(i=F())))))))))))))))))),i}function et(){var i,e,l;if(l=t,e=L(),e===null&&(n.charCodeAt(t)===45?(e="-",t++):(e=null,h('"-"')),e===null&&(n.charCodeAt(t)===46?(e=".",t++):(e=null,h('"."')),e===null&&(n.charCodeAt(t)===33?(e="!",t++):(e=null,h('"!"')),e===null&&(n.charCodeAt(t)===37?(e="%",t++):(e=null,h('"%"')),e===null&&(n.charCodeAt(t)===42?(e="*",t++):(e=null,h('"*"')),e===null&&(n.charCodeAt(t)===95?(e="_",t++):(e=null,h('"_"')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,h('"+"')),e===null&&(n.charCodeAt(t)===96?(e="`",t++):(e=null,h('"`"')),e===null&&(n.charCodeAt(t)===39?(e="'",t++):(e=null,h(`"'"`)),e===null&&(n.charCodeAt(t)===126?(e="~",t++):(e=null,h('"~"')),e===null&&(n.charCodeAt(t)===40?(e="(",t++):(e=null,h('"("')),e===null&&(n.charCodeAt(t)===41?(e=")",t++):(e=null,h('")"')),e===null&&(n.charCodeAt(t)===60?(e="<",t++):(e=null,h('"<"')),e===null&&(n.charCodeAt(t)===62?(e=">",t++):(e=null,h('">"')),e===null&&(n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e===null&&(n.charCodeAt(t)===92?(e="\\",t++):(e=null,h('"\\\\"')),e===null&&(e=I(),e===null&&(n.charCodeAt(t)===47?(e="/",t++):(e=null,h('"/"')),e===null&&(n.charCodeAt(t)===91?(e="[",t++):(e=null,h('"["')),e===null&&(n.charCodeAt(t)===93?(e="]",t++):(e=null,h('"]"')),e===null&&(n.charCodeAt(t)===63?(e="?",t++):(e=null,h('"?"')),e===null&&(n.charCodeAt(t)===123?(e="{",t++):(e=null,h('"{"')),e===null&&(n.charCodeAt(t)===125?(e="}",t++):(e=null,h('"}"'))))))))))))))))))))))))),e!==null)for(i=[];e!==null;)i.push(e),e=L(),e===null&&(n.charCodeAt(t)===45?(e="-",t++):(e=null,h('"-"')),e===null&&(n.charCodeAt(t)===46?(e=".",t++):(e=null,h('"."')),e===null&&(n.charCodeAt(t)===33?(e="!",t++):(e=null,h('"!"')),e===null&&(n.charCodeAt(t)===37?(e="%",t++):(e=null,h('"%"')),e===null&&(n.charCodeAt(t)===42?(e="*",t++):(e=null,h('"*"')),e===null&&(n.charCodeAt(t)===95?(e="_",t++):(e=null,h('"_"')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,h('"+"')),e===null&&(n.charCodeAt(t)===96?(e="`",t++):(e=null,h('"`"')),e===null&&(n.charCodeAt(t)===39?(e="'",t++):(e=null,h(`"'"`)),e===null&&(n.charCodeAt(t)===126?(e="~",t++):(e=null,h('"~"')),e===null&&(n.charCodeAt(t)===40?(e="(",t++):(e=null,h('"("')),e===null&&(n.charCodeAt(t)===41?(e=")",t++):(e=null,h('")"')),e===null&&(n.charCodeAt(t)===60?(e="<",t++):(e=null,h('"<"')),e===null&&(n.charCodeAt(t)===62?(e=">",t++):(e=null,h('">"')),e===null&&(n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e===null&&(n.charCodeAt(t)===92?(e="\\",t++):(e=null,h('"\\\\"')),e===null&&(e=I(),e===null&&(n.charCodeAt(t)===47?(e="/",t++):(e=null,h('"/"')),e===null&&(n.charCodeAt(t)===91?(e="[",t++):(e=null,h('"["')),e===null&&(n.charCodeAt(t)===93?(e="]",t++):(e=null,h('"]"')),e===null&&(n.charCodeAt(t)===63?(e="?",t++):(e=null,h('"?"')),e===null&&(n.charCodeAt(t)===123?(e="{",t++):(e=null,h('"{"')),e===null&&(n.charCodeAt(t)===125?(e="}",t++):(e=null,h('"}"')))))))))))))))))))))))));else i=null;return i!==null&&(i=function(u){return n.substring(t,u)}(l)),i===null&&(t=l),i}function Q(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(n.charCodeAt(t)===42?(e="*",t++):(e=null,h('"*"')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_){return"*"}()),i===null&&(t=u),i}function W(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(n.charCodeAt(t)===47?(e="/",t++):(e=null,h('"/"')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_){return"/"}()),i===null&&(t=u),i}function B(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(n.charCodeAt(t)===61?(e="=",t++):(e=null,h('"="')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_){return"="}()),i===null&&(t=u),i}function te(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(n.charCodeAt(t)===40?(e="(",t++):(e=null,h('"("')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_){return"("}()),i===null&&(t=u),i}function de(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(n.charCodeAt(t)===41?(e=")",t++):(e=null,h('")"')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_){return")"}()),i===null&&(t=u),i}function Ae(){var i,e,l,u;return l=t,u=t,n.charCodeAt(t)===62?(i=">",t++):(i=null,h('">"')),i!==null?(e=M(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f){return">"}()),i===null&&(t=l),i}function Ue(){var i,e,l,u;return l=t,u=t,i=M(),i!==null?(n.charCodeAt(t)===60?(e="<",t++):(e=null,h('"<"')),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f){return"<"}()),i===null&&(t=l),i}function Se(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(n.charCodeAt(t)===44?(e=",",t++):(e=null,h('","')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_){return","}()),i===null&&(t=u),i}function ne(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(n.charCodeAt(t)===59?(e=";",t++):(e=null,h('";"')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_){return";"}()),i===null&&(t=u),i}function Te(){var i,e,l,u,f;return u=t,f=t,i=M(),i!==null?(n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=M(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_){return":"}()),i===null&&(t=u),i}function tt(){var i,e,l,u;return l=t,u=t,i=M(),i!==null?(e=I(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f){return'"'}()),i===null&&(t=l),i}function st(){var i,e,l,u;return l=t,u=t,i=I(),i!==null?(e=M(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f){return'"'}()),i===null&&(t=l),i}function ge(){var i,e,l,u;if(u=t,i=te(),i!==null){for(e=[],l=Ee(),l===null&&(l=ce(),l===null&&(l=ge()));l!==null;)e.push(l),l=Ee(),l===null&&(l=ce(),l===null&&(l=ge()));e!==null?(l=de(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)}else i=null,t=u;return i}function Ee(){var i;return/^[!-']/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[!-']")),i===null&&(/^[*-[]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[*-[]")),i===null&&(/^[\]-~]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[\\]-~]")),i===null&&(i=Y(),i===null&&(i=me())))),i}function Ce(){var i,e,l,u,f,_;if(f=t,_=t,i=M(),i!==null)if(e=I(),e!==null){for(l=[],u=he(),u===null&&(u=ce());u!==null;)l.push(u),u=he(),u===null&&(u=ce());l!==null?(u=I(),u!==null?i=[i,e,l,u]:(i=null,t=_)):(i=null,t=_)}else i=null,t=_;else i=null,t=_;return i!==null&&(i=function(m){return n.substring(t,m)}(f)),i===null&&(t=f),i}function be(){var i,e,l,u,f,_;if(f=t,_=t,i=M(),i!==null)if(e=I(),e!==null){for(l=[],u=he(),u===null&&(u=ce());u!==null;)l.push(u),u=he(),u===null&&(u=ce());l!==null?(u=I(),u!==null?i=[i,e,l,u]:(i=null,t=_)):(i=null,t=_)}else i=null,t=_;else i=null,t=_;return i!==null&&(i=function(m){var T=n.substring(t,m).trim();return T.substring(1,T.length-1).replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g,"$1")}(f)),i===null&&(t=f),i}function he(){var i;return i=me(),i===null&&(n.charCodeAt(t)===33?(i="!",t++):(i=null,h('"!"')),i===null&&(/^[#-[]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[#-[]")),i===null&&(/^[\]-~]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[\\]-~]")),i===null&&(i=Y())))),i}function ce(){var i,e,l;return l=t,n.charCodeAt(t)===92?(i="\\",t++):(i=null,h('"\\\\"')),i!==null?(/^[\0-\t]/.test(n.charAt(t))?(e=n.charAt(t),t++):(e=null,h("[\\0-\\t]")),e===null&&(/^[\x0B-\f]/.test(n.charAt(t))?(e=n.charAt(t),t++):(e=null,h("[\\x0B-\\f]")),e===null&&(/^[\x0E-]/.test(n.charAt(t))?(e=n.charAt(t),t++):(e=null,h("[\\x0E-]")))),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function fe(){var i,e,l,u,f,_;return f=t,_=t,i=Oe(),i!==null?(n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=Pt(),l=l!==null?l:"",l!==null?(u=zs(),u!==null?i=[i,e,l,u]:(i=null,t=_)):(i=null,t=_)):(i=null,t=_)):(i=null,t=_),i!==null&&(i=function(m){try{R.uri=new Ro(R.scheme,R.user,R.host,R.port),delete R.scheme,delete R.user,delete R.host,delete R.host_type,delete R.port}catch{R=-1}}()),i===null&&(t=f),i}function Re(){var i,e,l,u,f,_,m,T;return m=t,T=t,i=Oe(),i!==null?(n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=Pt(),l=l!==null?l:"",l!==null?(u=zs(),u!==null?(f=Kr(),f!==null?(_=ti(),_=_!==null?_:"",_!==null?i=[i,e,l,u,f,_]:(i=null,t=T)):(i=null,t=T)):(i=null,t=T)):(i=null,t=T)):(i=null,t=T)):(i=null,t=T),i!==null&&(i=function(y){try{R.uri=new Ro(R.scheme,R.user,R.host,R.port,R.uri_params,R.uri_headers),delete R.scheme,delete R.user,delete R.host,delete R.host_type,delete R.port,delete R.uri_params,o==="SIP_URI"&&(R=R.uri)}catch{R=-1}}()),i===null&&(t=m),i}function Oe(){var i;return i=Je(),i===null&&(i=Me()),i}function Je(){var i,e;return e=t,n.substr(t,4).toLowerCase()==="sips"?(i=n.substr(t,4),t+=4):(i=null,h('"sips"')),i!==null&&(i=function(l,u){R.scheme=u.toLowerCase()}(e,i)),i===null&&(t=e),i}function Me(){var i,e;return e=t,n.substr(t,3).toLowerCase()==="sip"?(i=n.substr(t,3),t+=3):(i=null,h('"sip"')),i!==null&&(i=function(l,u){R.scheme=u.toLowerCase()}(e,i)),i===null&&(t=e),i}function Pt(){var i,e,l,u,f,_;return u=t,f=t,i=gt(),i!==null?(_=t,n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=Dn(),l!==null?e=[e,l]:(e=null,t=_)):(e=null,t=_),e=e!==null?e:"",e!==null?(n.charCodeAt(t)===64?(l="@",t++):(l=null,h('"@"')),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m){R.user=decodeURIComponent(n.substring(t-1,m))}(u)),i===null&&(t=u),i}function gt(){var i,e;if(e=N(),e===null&&(e=ve(),e===null&&(e=On())),e!==null)for(i=[];e!==null;)i.push(e),e=N(),e===null&&(e=ve(),e===null&&(e=On()));else i=null;return i}function On(){var i;return n.charCodeAt(t)===38?(i="&",t++):(i=null,h('"&"')),i===null&&(n.charCodeAt(t)===61?(i="=",t++):(i=null,h('"="')),i===null&&(n.charCodeAt(t)===43?(i="+",t++):(i=null,h('"+"')),i===null&&(n.charCodeAt(t)===36?(i="$",t++):(i=null,h('"$"')),i===null&&(n.charCodeAt(t)===44?(i=",",t++):(i=null,h('","')),i===null&&(n.charCodeAt(t)===59?(i=";",t++):(i=null,h('";"')),i===null&&(n.charCodeAt(t)===63?(i="?",t++):(i=null,h('"?"')),i===null&&(n.charCodeAt(t)===47?(i="/",t++):(i=null,h('"/"'))))))))),i}function Dn(){var i,e,l;for(l=t,i=[],e=N(),e===null&&(e=ve(),e===null&&(n.charCodeAt(t)===38?(e="&",t++):(e=null,h('"&"')),e===null&&(n.charCodeAt(t)===61?(e="=",t++):(e=null,h('"="')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,h('"+"')),e===null&&(n.charCodeAt(t)===36?(e="$",t++):(e=null,h('"$"')),e===null&&(n.charCodeAt(t)===44?(e=",",t++):(e=null,h('","'))))))));e!==null;)i.push(e),e=N(),e===null&&(e=ve(),e===null&&(n.charCodeAt(t)===38?(e="&",t++):(e=null,h('"&"')),e===null&&(n.charCodeAt(t)===61?(e="=",t++):(e=null,h('"="')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,h('"+"')),e===null&&(n.charCodeAt(t)===36?(e="$",t++):(e=null,h('"$"')),e===null&&(n.charCodeAt(t)===44?(e=",",t++):(e=null,h('","'))))))));return i!==null&&(i=function(u){R.password=n.substring(t,u)}(l)),i===null&&(t=l),i}function zs(){var i,e,l,u,f;return u=t,i=Qt(),i!==null?(f=t,n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=Is(),l!==null?e=[e,l]:(e=null,t=f)):(e=null,t=f),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i}function Qt(){var i,e;return e=t,i=_s(),i===null&&(i=nt(),i===null&&(i=Un())),i!==null&&(i=function(l){return R.host=n.substring(t,l).toLowerCase(),R.host}(e)),i===null&&(t=e),i}function _s(){var i,e,l,u,f,_;for(u=t,f=t,i=[],_=t,e=Js(),e!==null?(n.charCodeAt(t)===46?(l=".",t++):(l=null,h('"."')),l!==null?e=[e,l]:(e=null,t=_)):(e=null,t=_);e!==null;)i.push(e),_=t,e=Js(),e!==null?(n.charCodeAt(t)===46?(l=".",t++):(l=null,h('"."')),l!==null?e=[e,l]:(e=null,t=_)):(e=null,t=_);return i!==null?(e=Nn(),e!==null?(n.charCodeAt(t)===46?(l=".",t++):(l=null,h('"."')),l=l!==null?l:"",l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m){return R.host_type="domain",n.substring(t,m)}(u)),i===null&&(t=u),i}function Js(){var i,e,l,u;if(u=t,i=L(),i!==null){for(e=[],l=L(),l===null&&(n.charCodeAt(t)===45?(l="-",t++):(l=null,h('"-"')),l===null&&(n.charCodeAt(t)===95?(l="_",t++):(l=null,h('"_"'))));l!==null;)e.push(l),l=L(),l===null&&(n.charCodeAt(t)===45?(l="-",t++):(l=null,h('"-"')),l===null&&(n.charCodeAt(t)===95?(l="_",t++):(l=null,h('"_"'))));e!==null?i=[i,e]:(i=null,t=u)}else i=null,t=u;return i}function Nn(){var i,e,l,u;if(u=t,i=v(),i!==null){for(e=[],l=L(),l===null&&(n.charCodeAt(t)===45?(l="-",t++):(l=null,h('"-"')),l===null&&(n.charCodeAt(t)===95?(l="_",t++):(l=null,h('"_"'))));l!==null;)e.push(l),l=L(),l===null&&(n.charCodeAt(t)===45?(l="-",t++):(l=null,h('"-"')),l===null&&(n.charCodeAt(t)===95?(l="_",t++):(l=null,h('"_"'))));e!==null?i=[i,e]:(i=null,t=u)}else i=null,t=u;return i}function Un(){var i,e,l,u,f;return u=t,f=t,n.charCodeAt(t)===91?(i="[",t++):(i=null,h('"["')),i!==null?(e=Xs(),e!==null?(n.charCodeAt(t)===93?(l="]",t++):(l=null,h('"]"')),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_){return R.host_type="IPv6",n.substring(t,_)}(u)),i===null&&(t=u),i}function Xs(){var i,e,l,u,f,_,m,T,y,O,se,De,At,Ls,x,A;return Ls=t,x=t,i=_e(),i!==null?(n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=_e(),l!==null?(n.charCodeAt(t)===58?(u=":",t++):(u=null,h('":"')),u!==null?(f=_e(),f!==null?(n.charCodeAt(t)===58?(_=":",t++):(_=null,h('":"')),_!==null?(m=_e(),m!==null?(n.charCodeAt(t)===58?(T=":",t++):(T=null,h('":"')),T!==null?(y=_e(),y!==null?(n.charCodeAt(t)===58?(O=":",t++):(O=null,h('":"')),O!==null?(se=_e(),se!==null?(n.charCodeAt(t)===58?(De=":",t++):(De=null,h('":"')),De!==null?(At=re(),At!==null?i=[i,e,l,u,f,_,m,T,y,O,se,De,At]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,n.substr(t,2)==="::"?(i="::",t+=2):(i=null,h('"::"')),i!==null?(e=_e(),e!==null?(n.charCodeAt(t)===58?(l=":",t++):(l=null,h('":"')),l!==null?(u=_e(),u!==null?(n.charCodeAt(t)===58?(f=":",t++):(f=null,h('":"')),f!==null?(_=_e(),_!==null?(n.charCodeAt(t)===58?(m=":",t++):(m=null,h('":"')),m!==null?(T=_e(),T!==null?(n.charCodeAt(t)===58?(y=":",t++):(y=null,h('":"')),y!==null?(O=_e(),O!==null?(n.charCodeAt(t)===58?(se=":",t++):(se=null,h('":"')),se!==null?(De=re(),De!==null?i=[i,e,l,u,f,_,m,T,y,O,se,De]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,n.substr(t,2)==="::"?(i="::",t+=2):(i=null,h('"::"')),i!==null?(e=_e(),e!==null?(n.charCodeAt(t)===58?(l=":",t++):(l=null,h('":"')),l!==null?(u=_e(),u!==null?(n.charCodeAt(t)===58?(f=":",t++):(f=null,h('":"')),f!==null?(_=_e(),_!==null?(n.charCodeAt(t)===58?(m=":",t++):(m=null,h('":"')),m!==null?(T=_e(),T!==null?(n.charCodeAt(t)===58?(y=":",t++):(y=null,h('":"')),y!==null?(O=re(),O!==null?i=[i,e,l,u,f,_,m,T,y,O]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,n.substr(t,2)==="::"?(i="::",t+=2):(i=null,h('"::"')),i!==null?(e=_e(),e!==null?(n.charCodeAt(t)===58?(l=":",t++):(l=null,h('":"')),l!==null?(u=_e(),u!==null?(n.charCodeAt(t)===58?(f=":",t++):(f=null,h('":"')),f!==null?(_=_e(),_!==null?(n.charCodeAt(t)===58?(m=":",t++):(m=null,h('":"')),m!==null?(T=re(),T!==null?i=[i,e,l,u,f,_,m,T]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,n.substr(t,2)==="::"?(i="::",t+=2):(i=null,h('"::"')),i!==null?(e=_e(),e!==null?(n.charCodeAt(t)===58?(l=":",t++):(l=null,h('":"')),l!==null?(u=_e(),u!==null?(n.charCodeAt(t)===58?(f=":",t++):(f=null,h('":"')),f!==null?(_=re(),_!==null?i=[i,e,l,u,f,_]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,n.substr(t,2)==="::"?(i="::",t+=2):(i=null,h('"::"')),i!==null?(e=_e(),e!==null?(n.charCodeAt(t)===58?(l=":",t++):(l=null,h('":"')),l!==null?(u=re(),u!==null?i=[i,e,l,u]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,n.substr(t,2)==="::"?(i="::",t+=2):(i=null,h('"::"')),i!==null?(e=re(),e!==null?i=[i,e]:(i=null,t=x)):(i=null,t=x),i===null&&(x=t,n.substr(t,2)==="::"?(i="::",t+=2):(i=null,h('"::"')),i!==null?(e=_e(),e!==null?i=[i,e]:(i=null,t=x)):(i=null,t=x),i===null&&(x=t,i=_e(),i!==null?(n.substr(t,2)==="::"?(e="::",t+=2):(e=null,h('"::"')),e!==null?(l=_e(),l!==null?(n.charCodeAt(t)===58?(u=":",t++):(u=null,h('":"')),u!==null?(f=_e(),f!==null?(n.charCodeAt(t)===58?(_=":",t++):(_=null,h('":"')),_!==null?(m=_e(),m!==null?(n.charCodeAt(t)===58?(T=":",t++):(T=null,h('":"')),T!==null?(y=_e(),y!==null?(n.charCodeAt(t)===58?(O=":",t++):(O=null,h('":"')),O!==null?(se=re(),se!==null?i=[i,e,l,u,f,_,m,T,y,O,se]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,i=_e(),i!==null?(A=t,n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=_e(),l!==null?e=[e,l]:(e=null,t=A)):(e=null,t=A),e=e!==null?e:"",e!==null?(n.substr(t,2)==="::"?(l="::",t+=2):(l=null,h('"::"')),l!==null?(u=_e(),u!==null?(n.charCodeAt(t)===58?(f=":",t++):(f=null,h('":"')),f!==null?(_=_e(),_!==null?(n.charCodeAt(t)===58?(m=":",t++):(m=null,h('":"')),m!==null?(T=_e(),T!==null?(n.charCodeAt(t)===58?(y=":",t++):(y=null,h('":"')),y!==null?(O=re(),O!==null?i=[i,e,l,u,f,_,m,T,y,O]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,i=_e(),i!==null?(A=t,n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=_e(),l!==null?e=[e,l]:(e=null,t=A)):(e=null,t=A),e=e!==null?e:"",e!==null?(A=t,n.charCodeAt(t)===58?(l=":",t++):(l=null,h('":"')),l!==null?(u=_e(),u!==null?l=[l,u]:(l=null,t=A)):(l=null,t=A),l=l!==null?l:"",l!==null?(n.substr(t,2)==="::"?(u="::",t+=2):(u=null,h('"::"')),u!==null?(f=_e(),f!==null?(n.charCodeAt(t)===58?(_=":",t++):(_=null,h('":"')),_!==null?(m=_e(),m!==null?(n.charCodeAt(t)===58?(T=":",t++):(T=null,h('":"')),T!==null?(y=re(),y!==null?i=[i,e,l,u,f,_,m,T,y]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,i=_e(),i!==null?(A=t,n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=_e(),l!==null?e=[e,l]:(e=null,t=A)):(e=null,t=A),e=e!==null?e:"",e!==null?(A=t,n.charCodeAt(t)===58?(l=":",t++):(l=null,h('":"')),l!==null?(u=_e(),u!==null?l=[l,u]:(l=null,t=A)):(l=null,t=A),l=l!==null?l:"",l!==null?(A=t,n.charCodeAt(t)===58?(u=":",t++):(u=null,h('":"')),u!==null?(f=_e(),f!==null?u=[u,f]:(u=null,t=A)):(u=null,t=A),u=u!==null?u:"",u!==null?(n.substr(t,2)==="::"?(f="::",t+=2):(f=null,h('"::"')),f!==null?(_=_e(),_!==null?(n.charCodeAt(t)===58?(m=":",t++):(m=null,h('":"')),m!==null?(T=re(),T!==null?i=[i,e,l,u,f,_,m,T]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,i=_e(),i!==null?(A=t,n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=_e(),l!==null?e=[e,l]:(e=null,t=A)):(e=null,t=A),e=e!==null?e:"",e!==null?(A=t,n.charCodeAt(t)===58?(l=":",t++):(l=null,h('":"')),l!==null?(u=_e(),u!==null?l=[l,u]:(l=null,t=A)):(l=null,t=A),l=l!==null?l:"",l!==null?(A=t,n.charCodeAt(t)===58?(u=":",t++):(u=null,h('":"')),u!==null?(f=_e(),f!==null?u=[u,f]:(u=null,t=A)):(u=null,t=A),u=u!==null?u:"",u!==null?(A=t,n.charCodeAt(t)===58?(f=":",t++):(f=null,h('":"')),f!==null?(_=_e(),_!==null?f=[f,_]:(f=null,t=A)):(f=null,t=A),f=f!==null?f:"",f!==null?(n.substr(t,2)==="::"?(_="::",t+=2):(_=null,h('"::"')),_!==null?(m=re(),m!==null?i=[i,e,l,u,f,_,m]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,i=_e(),i!==null?(A=t,n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=_e(),l!==null?e=[e,l]:(e=null,t=A)):(e=null,t=A),e=e!==null?e:"",e!==null?(A=t,n.charCodeAt(t)===58?(l=":",t++):(l=null,h('":"')),l!==null?(u=_e(),u!==null?l=[l,u]:(l=null,t=A)):(l=null,t=A),l=l!==null?l:"",l!==null?(A=t,n.charCodeAt(t)===58?(u=":",t++):(u=null,h('":"')),u!==null?(f=_e(),f!==null?u=[u,f]:(u=null,t=A)):(u=null,t=A),u=u!==null?u:"",u!==null?(A=t,n.charCodeAt(t)===58?(f=":",t++):(f=null,h('":"')),f!==null?(_=_e(),_!==null?f=[f,_]:(f=null,t=A)):(f=null,t=A),f=f!==null?f:"",f!==null?(A=t,n.charCodeAt(t)===58?(_=":",t++):(_=null,h('":"')),_!==null?(m=_e(),m!==null?_=[_,m]:(_=null,t=A)):(_=null,t=A),_=_!==null?_:"",_!==null?(n.substr(t,2)==="::"?(m="::",t+=2):(m=null,h('"::"')),m!==null?(T=_e(),T!==null?i=[i,e,l,u,f,_,m,T]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x),i===null&&(x=t,i=_e(),i!==null?(A=t,n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=_e(),l!==null?e=[e,l]:(e=null,t=A)):(e=null,t=A),e=e!==null?e:"",e!==null?(A=t,n.charCodeAt(t)===58?(l=":",t++):(l=null,h('":"')),l!==null?(u=_e(),u!==null?l=[l,u]:(l=null,t=A)):(l=null,t=A),l=l!==null?l:"",l!==null?(A=t,n.charCodeAt(t)===58?(u=":",t++):(u=null,h('":"')),u!==null?(f=_e(),f!==null?u=[u,f]:(u=null,t=A)):(u=null,t=A),u=u!==null?u:"",u!==null?(A=t,n.charCodeAt(t)===58?(f=":",t++):(f=null,h('":"')),f!==null?(_=_e(),_!==null?f=[f,_]:(f=null,t=A)):(f=null,t=A),f=f!==null?f:"",f!==null?(A=t,n.charCodeAt(t)===58?(_=":",t++):(_=null,h('":"')),_!==null?(m=_e(),m!==null?_=[_,m]:(_=null,t=A)):(_=null,t=A),_=_!==null?_:"",_!==null?(A=t,n.charCodeAt(t)===58?(m=":",t++):(m=null,h('":"')),m!==null?(T=_e(),T!==null?m=[m,T]:(m=null,t=A)):(m=null,t=A),m=m!==null?m:"",m!==null?(n.substr(t,2)==="::"?(T="::",t+=2):(T=null,h('"::"')),T!==null?i=[i,e,l,u,f,_,m,T]:(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x)):(i=null,t=x))))))))))))))),i!==null&&(i=function(pe){return R.host_type="IPv6",n.substring(t,pe)}(Ls)),i===null&&(t=Ls),i}function _e(){var i,e,l,u,f;return f=t,i=E(),i!==null?(e=E(),e=e!==null?e:"",e!==null?(l=E(),l=l!==null?l:"",l!==null?(u=E(),u=u!==null?u:"",u!==null?i=[i,e,l,u]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i}function re(){var i,e,l,u;return u=t,i=_e(),i!==null?(n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=_e(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i===null&&(i=nt()),i}function nt(){var i,e,l,u,f,_,m,T,y;return T=t,y=t,i=qt(),i!==null?(n.charCodeAt(t)===46?(e=".",t++):(e=null,h('"."')),e!==null?(l=qt(),l!==null?(n.charCodeAt(t)===46?(u=".",t++):(u=null,h('"."')),u!==null?(f=qt(),f!==null?(n.charCodeAt(t)===46?(_=".",t++):(_=null,h('"."')),_!==null?(m=qt(),m!==null?i=[i,e,l,u,f,_,m]:(i=null,t=y)):(i=null,t=y)):(i=null,t=y)):(i=null,t=y)):(i=null,t=y)):(i=null,t=y)):(i=null,t=y),i!==null&&(i=function(O){return R.host_type="IPv4",n.substring(t,O)}(T)),i===null&&(t=T),i}function qt(){var i,e,l,u;return u=t,n.substr(t,2)==="25"?(i="25",t+=2):(i=null,h('"25"')),i!==null?(/^[0-5]/.test(n.charAt(t))?(e=n.charAt(t),t++):(e=null,h("[0-5]")),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i===null&&(u=t,n.charCodeAt(t)===50?(i="2",t++):(i=null,h('"2"')),i!==null?(/^[0-4]/.test(n.charAt(t))?(e=n.charAt(t),t++):(e=null,h("[0-4]")),e!==null?(l=g(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i===null&&(u=t,n.charCodeAt(t)===49?(i="1",t++):(i=null,h('"1"')),i!==null?(e=g(),e!==null?(l=g(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i===null&&(u=t,/^[1-9]/.test(n.charAt(t))?(i=n.charAt(t),t++):(i=null,h("[1-9]")),i!==null?(e=g(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i===null&&(i=g())))),i}function Is(){var i,e,l,u,f,_,m;return _=t,m=t,i=g(),i=i!==null?i:"",i!==null?(e=g(),e=e!==null?e:"",e!==null?(l=g(),l=l!==null?l:"",l!==null?(u=g(),u=u!==null?u:"",u!==null?(f=g(),f=f!==null?f:"",f!==null?i=[i,e,l,u,f]:(i=null,t=m)):(i=null,t=m)):(i=null,t=m)):(i=null,t=m)):(i=null,t=m),i!==null&&(i=function(T,y){return y=parseInt(y.join("")),R.port=y,y}(_,i)),i===null&&(t=_),i}function Kr(){var i,e,l,u;for(i=[],u=t,n.charCodeAt(t)===59?(e=";",t++):(e=null,h('";"')),e!==null?(l=Pn(),l!==null?e=[e,l]:(e=null,t=u)):(e=null,t=u);e!==null;)i.push(e),u=t,n.charCodeAt(t)===59?(e=";",t++):(e=null,h('";"')),e!==null?(l=Pn(),l!==null?e=[e,l]:(e=null,t=u)):(e=null,t=u);return i}function Pn(){var i;return i=kn(),i===null&&(i=Wr(),i===null&&(i=Yr(),i===null&&(i=zr(),i===null&&(i=Jr(),i===null&&(i=Xr(),i===null&&(i=Qr())))))),i}function kn(){var i,e,l,u;return l=t,u=t,n.substr(t,10).toLowerCase()==="transport="?(i=n.substr(t,10),t+=10):(i=null,h('"transport="')),i!==null?(n.substr(t,3).toLowerCase()==="udp"?(e=n.substr(t,3),t+=3):(e=null,h('"udp"')),e===null&&(n.substr(t,3).toLowerCase()==="tcp"?(e=n.substr(t,3),t+=3):(e=null,h('"tcp"')),e===null&&(n.substr(t,4).toLowerCase()==="sctp"?(e=n.substr(t,4),t+=4):(e=null,h('"sctp"')),e===null&&(n.substr(t,3).toLowerCase()==="tls"?(e=n.substr(t,3),t+=3):(e=null,h('"tls"')),e===null&&(e=U())))),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f,_){R.uri_params||(R.uri_params={}),R.uri_params.transport=_.toLowerCase()}(l,i[1])),i===null&&(t=l),i}function Wr(){var i,e,l,u;return l=t,u=t,n.substr(t,5).toLowerCase()==="user="?(i=n.substr(t,5),t+=5):(i=null,h('"user="')),i!==null?(n.substr(t,5).toLowerCase()==="phone"?(e=n.substr(t,5),t+=5):(e=null,h('"phone"')),e===null&&(n.substr(t,2).toLowerCase()==="ip"?(e=n.substr(t,2),t+=2):(e=null,h('"ip"')),e===null&&(e=U())),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f,_){R.uri_params||(R.uri_params={}),R.uri_params.user=_.toLowerCase()}(l,i[1])),i===null&&(t=l),i}function Yr(){var i,e,l,u;return l=t,u=t,n.substr(t,7).toLowerCase()==="method="?(i=n.substr(t,7),t+=7):(i=null,h('"method="')),i!==null?(e=rn(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f,_){R.uri_params||(R.uri_params={}),R.uri_params.method=_}(l,i[1])),i===null&&(t=l),i}function zr(){var i,e,l,u;return l=t,u=t,n.substr(t,4).toLowerCase()==="ttl="?(i=n.substr(t,4),t+=4):(i=null,h('"ttl="')),i!==null?(e=sr(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f,_){R.params||(R.params={}),R.params.ttl=_}(l,i[1])),i===null&&(t=l),i}function Jr(){var i,e,l,u;return l=t,u=t,n.substr(t,6).toLowerCase()==="maddr="?(i=n.substr(t,6),t+=6):(i=null,h('"maddr="')),i!==null?(e=Qt(),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i!==null&&(i=function(f,_){R.uri_params||(R.uri_params={}),R.uri_params.maddr=_}(l,i[1])),i===null&&(t=l),i}function Xr(){var i,e,l,u,f,_;return u=t,f=t,n.substr(t,2).toLowerCase()==="lr"?(i=n.substr(t,2),t+=2):(i=null,h('"lr"')),i!==null?(_=t,n.charCodeAt(t)===61?(e="=",t++):(e=null,h('"="')),e!==null?(l=U(),l!==null?e=[e,l]:(e=null,t=_)):(e=null,t=_),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m){R.uri_params||(R.uri_params={}),R.uri_params.lr=void 0}()),i===null&&(t=u),i}function Qr(){var i,e,l,u,f,_;return u=t,f=t,i=Zr(),i!==null?(_=t,n.charCodeAt(t)===61?(e="=",t++):(e=null,h('"="')),e!==null?(l=ei(),l!==null?e=[e,l]:(e=null,t=_)):(e=null,t=_),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m,T,y){R.uri_params||(R.uri_params={}),typeof y>"u"?y=void 0:y=y[1],R.uri_params[T.toLowerCase()]=y}(u,i[0],i[1])),i===null&&(t=u),i}function Zr(){var i,e,l;if(l=t,e=bs(),e!==null)for(i=[];e!==null;)i.push(e),e=bs();else i=null;return i!==null&&(i=function(u,f){return f.join("")}(l,i)),i===null&&(t=l),i}function ei(){var i,e,l;if(l=t,e=bs(),e!==null)for(i=[];e!==null;)i.push(e),e=bs();else i=null;return i!==null&&(i=function(u,f){return f.join("")}(l,i)),i===null&&(t=l),i}function bs(){var i;return i=ws(),i===null&&(i=N(),i===null&&(i=ve())),i}function ws(){var i;return n.charCodeAt(t)===91?(i="[",t++):(i=null,h('"["')),i===null&&(n.charCodeAt(t)===93?(i="]",t++):(i=null,h('"]"')),i===null&&(n.charCodeAt(t)===47?(i="/",t++):(i=null,h('"/"')),i===null&&(n.charCodeAt(t)===58?(i=":",t++):(i=null,h('":"')),i===null&&(n.charCodeAt(t)===38?(i="&",t++):(i=null,h('"&"')),i===null&&(n.charCodeAt(t)===43?(i="+",t++):(i=null,h('"+"')),i===null&&(n.charCodeAt(t)===36?(i="$",t++):(i=null,h('"$"')))))))),i}function ti(){var i,e,l,u,f,_,m;if(_=t,n.charCodeAt(t)===63?(i="?",t++):(i=null,h('"?"')),i!==null)if(e=Qs(),e!==null){for(l=[],m=t,n.charCodeAt(t)===38?(u="&",t++):(u=null,h('"&"')),u!==null?(f=Qs(),f!==null?u=[u,f]:(u=null,t=m)):(u=null,t=m);u!==null;)l.push(u),m=t,n.charCodeAt(t)===38?(u="&",t++):(u=null,h('"&"')),u!==null?(f=Qs(),f!==null?u=[u,f]:(u=null,t=m)):(u=null,t=m);l!==null?i=[i,e,l]:(i=null,t=_)}else i=null,t=_;else i=null,t=_;return i}function Qs(){var i,e,l,u,f;return u=t,f=t,i=Zs(),i!==null?(n.charCodeAt(t)===61?(e="=",t++):(e=null,h('"="')),e!==null?(l=si(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m,T){m=m.join("").toLowerCase(),T=T.join(""),R.uri_headers||(R.uri_headers={}),R.uri_headers[m]?R.uri_headers[m].push(T):R.uri_headers[m]=[T]}(u,i[0],i[2])),i===null&&(t=u),i}function Zs(){var i,e;if(e=Os(),e===null&&(e=N(),e===null&&(e=ve())),e!==null)for(i=[];e!==null;)i.push(e),e=Os(),e===null&&(e=N(),e===null&&(e=ve()));else i=null;return i}function si(){var i,e;for(i=[],e=Os(),e===null&&(e=N(),e===null&&(e=ve()));e!==null;)i.push(e),e=Os(),e===null&&(e=N(),e===null&&(e=ve()));return i}function Os(){var i;return n.charCodeAt(t)===91?(i="[",t++):(i=null,h('"["')),i===null&&(n.charCodeAt(t)===93?(i="]",t++):(i=null,h('"]"')),i===null&&(n.charCodeAt(t)===47?(i="/",t++):(i=null,h('"/"')),i===null&&(n.charCodeAt(t)===63?(i="?",t++):(i=null,h('"?"')),i===null&&(n.charCodeAt(t)===58?(i=":",t++):(i=null,h('":"')),i===null&&(n.charCodeAt(t)===43?(i="+",t++):(i=null,h('"+"')),i===null&&(n.charCodeAt(t)===36?(i="$",t++):(i=null,h('"$"')))))))),i}function en(){var i;return i=ln(),i===null&&(i=ro()),i}function ro(){var i,e,l,u,f,_;return _=t,i=rn(),i!==null?(e=w(),e!==null?(l=ni(),l!==null?(u=w(),u!==null?(f=Ln(),f!==null?i=[i,e,l,u,f]:(i=null,t=_)):(i=null,t=_)):(i=null,t=_)):(i=null,t=_)):(i=null,t=_),i}function ni(){var i;return i=Re(),i===null&&(i=Mn()),i}function Mn(){var i,e,l,u;return u=t,i=Ps(),i!==null?(n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e!==null?(l=xn(),l===null&&(l=sn()),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function xn(){var i,e,l,u,f;return u=t,i=ri(),i===null&&(i=tn()),i!==null?(f=t,n.charCodeAt(t)===63?(e="?",t++):(e=null,h('"?"')),e!==null?(l=ui(),l!==null?e=[e,l]:(e=null,t=f)):(e=null,t=f),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i}function ri(){var i,e,l,u;return u=t,n.substr(t,2)==="//"?(i="//",t+=2):(i=null,h('"//"')),i!==null?(e=li(),e!==null?(l=tn(),l=l!==null?l:"",l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function tn(){var i,e,l;return l=t,n.charCodeAt(t)===47?(i="/",t++):(i=null,h('"/"')),i!==null?(e=ii(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function sn(){var i,e,l,u;if(u=t,i=Ns(),i!==null){for(e=[],l=Ds();l!==null;)e.push(l),l=Ds();e!==null?i=[i,e]:(i=null,t=u)}else i=null,t=u;return i}function Ds(){var i;return i=ie(),i===null&&(i=N(),i===null&&(i=ve())),i}function Ns(){var i;return i=N(),i===null&&(i=ve(),i===null&&(n.charCodeAt(t)===59?(i=";",t++):(i=null,h('";"')),i===null&&(n.charCodeAt(t)===63?(i="?",t++):(i=null,h('"?"')),i===null&&(n.charCodeAt(t)===58?(i=":",t++):(i=null,h('":"')),i===null&&(n.charCodeAt(t)===64?(i="@",t++):(i=null,h('"@"')),i===null&&(n.charCodeAt(t)===38?(i="&",t++):(i=null,h('"&"')),i===null&&(n.charCodeAt(t)===61?(i="=",t++):(i=null,h('"="')),i===null&&(n.charCodeAt(t)===43?(i="+",t++):(i=null,h('"+"')),i===null&&(n.charCodeAt(t)===36?(i="$",t++):(i=null,h('"$"')),i===null&&(n.charCodeAt(t)===44?(i=",",t++):(i=null,h('","')))))))))))),i}function ii(){var i,e,l,u,f,_;if(f=t,i=nn(),i!==null){for(e=[],_=t,n.charCodeAt(t)===47?(l="/",t++):(l=null,h('"/"')),l!==null?(u=nn(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,n.charCodeAt(t)===47?(l="/",t++):(l=null,h('"/"')),l!==null?(u=nn(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function nn(){var i,e,l,u,f,_;for(f=t,i=[],e=ds();e!==null;)i.push(e),e=ds();if(i!==null){for(e=[],_=t,n.charCodeAt(t)===59?(l=";",t++):(l=null,h('";"')),l!==null?(u=Us(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,n.charCodeAt(t)===59?(l=";",t++):(l=null,h('";"')),l!==null?(u=Us(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Us(){var i,e;for(i=[],e=ds();e!==null;)i.push(e),e=ds();return i}function ds(){var i;return i=N(),i===null&&(i=ve(),i===null&&(n.charCodeAt(t)===58?(i=":",t++):(i=null,h('":"')),i===null&&(n.charCodeAt(t)===64?(i="@",t++):(i=null,h('"@"')),i===null&&(n.charCodeAt(t)===38?(i="&",t++):(i=null,h('"&"')),i===null&&(n.charCodeAt(t)===61?(i="=",t++):(i=null,h('"="')),i===null&&(n.charCodeAt(t)===43?(i="+",t++):(i=null,h('"+"')),i===null&&(n.charCodeAt(t)===36?(i="$",t++):(i=null,h('"$"')),i===null&&(n.charCodeAt(t)===44?(i=",",t++):(i=null,h('","')))))))))),i}function Ps(){var i,e,l,u,f;if(u=t,f=t,i=v(),i!==null){for(e=[],l=v(),l===null&&(l=g(),l===null&&(n.charCodeAt(t)===43?(l="+",t++):(l=null,h('"+"')),l===null&&(n.charCodeAt(t)===45?(l="-",t++):(l=null,h('"-"')),l===null&&(n.charCodeAt(t)===46?(l=".",t++):(l=null,h('"."'))))));l!==null;)e.push(l),l=v(),l===null&&(l=g(),l===null&&(n.charCodeAt(t)===43?(l="+",t++):(l=null,h('"+"')),l===null&&(n.charCodeAt(t)===45?(l="-",t++):(l=null,h('"-"')),l===null&&(n.charCodeAt(t)===46?(l=".",t++):(l=null,h('"."'))))));e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i!==null&&(i=function(_){R.scheme=n.substring(t,_)}(u)),i===null&&(t=u),i}function li(){var i;return i=oi(),i===null&&(i=ai()),i}function oi(){var i,e,l,u;return l=t,u=t,i=Pt(),i!==null?(n.charCodeAt(t)===64?(e="@",t++):(e=null,h('"@"')),e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i=i!==null?i:"",i!==null?(e=zs(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i=i!==null?i:"",i}function ai(){var i,e;if(e=N(),e===null&&(e=ve(),e===null&&(n.charCodeAt(t)===36?(e="$",t++):(e=null,h('"$"')),e===null&&(n.charCodeAt(t)===44?(e=",",t++):(e=null,h('","')),e===null&&(n.charCodeAt(t)===59?(e=";",t++):(e=null,h('";"')),e===null&&(n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e===null&&(n.charCodeAt(t)===64?(e="@",t++):(e=null,h('"@"')),e===null&&(n.charCodeAt(t)===38?(e="&",t++):(e=null,h('"&"')),e===null&&(n.charCodeAt(t)===61?(e="=",t++):(e=null,h('"="')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,h('"+"'))))))))))),e!==null)for(i=[];e!==null;)i.push(e),e=N(),e===null&&(e=ve(),e===null&&(n.charCodeAt(t)===36?(e="$",t++):(e=null,h('"$"')),e===null&&(n.charCodeAt(t)===44?(e=",",t++):(e=null,h('","')),e===null&&(n.charCodeAt(t)===59?(e=";",t++):(e=null,h('";"')),e===null&&(n.charCodeAt(t)===58?(e=":",t++):(e=null,h('":"')),e===null&&(n.charCodeAt(t)===64?(e="@",t++):(e=null,h('"@"')),e===null&&(n.charCodeAt(t)===38?(e="&",t++):(e=null,h('"&"')),e===null&&(n.charCodeAt(t)===61?(e="=",t++):(e=null,h('"="')),e===null&&(n.charCodeAt(t)===43?(e="+",t++):(e=null,h('"+"')))))))))));else i=null;return i}function ui(){var i,e;for(i=[],e=Ds();e!==null;)i.push(e),e=Ds();return i}function Ln(){var i,e,l,u,f,_,m,T;if(m=t,T=t,n.substr(t,3).toLowerCase()==="sip"?(i=n.substr(t,3),t+=3):(i=null,h('"SIP"')),i!==null)if(n.charCodeAt(t)===47?(e="/",t++):(e=null,h('"/"')),e!==null){if(u=g(),u!==null)for(l=[];u!==null;)l.push(u),u=g();else l=null;if(l!==null)if(n.charCodeAt(t)===46?(u=".",t++):(u=null,h('"."')),u!==null){if(_=g(),_!==null)for(f=[];_!==null;)f.push(_),_=g();else f=null;f!==null?i=[i,e,l,u,f]:(i=null,t=T)}else i=null,t=T;else i=null,t=T}else i=null,t=T;else i=null,t=T;return i!==null&&(i=function(y){R.sip_version=n.substring(t,y)}(m)),i===null&&(t=m),i}function $n(){var i;return n.substr(t,6)==="INVITE"?(i="INVITE",t+=6):(i=null,h('"INVITE"')),i}function ci(){var i;return n.substr(t,3)==="ACK"?(i="ACK",t+=3):(i=null,h('"ACK"')),i}function fi(){var i;return n.substr(t,7)==="OPTIONS"?(i="OPTIONS",t+=7):(i=null,h('"OPTIONS"')),i}function hi(){var i;return n.substr(t,3)==="BYE"?(i="BYE",t+=3):(i=null,h('"BYE"')),i}function _i(){var i;return n.substr(t,6)==="CANCEL"?(i="CANCEL",t+=6):(i=null,h('"CANCEL"')),i}function di(){var i;return n.substr(t,8)==="REGISTER"?(i="REGISTER",t+=8):(i=null,h('"REGISTER"')),i}function pi(){var i;return n.substr(t,9)==="SUBSCRIBE"?(i="SUBSCRIBE",t+=9):(i=null,h('"SUBSCRIBE"')),i}function mi(){var i;return n.substr(t,6)==="NOTIFY"?(i="NOTIFY",t+=6):(i=null,h('"NOTIFY"')),i}function gi(){var i;return n.substr(t,5)==="REFER"?(i="REFER",t+=5):(i=null,h('"REFER"')),i}function rn(){var i,e;return e=t,i=$n(),i===null&&(i=ci(),i===null&&(i=fi(),i===null&&(i=hi(),i===null&&(i=_i(),i===null&&(i=di(),i===null&&(i=pi(),i===null&&(i=mi(),i===null&&(i=gi(),i===null&&(i=U()))))))))),i!==null&&(i=function(l){return R.method=n.substring(t,l),R.method}(e)),i===null&&(t=e),i}function ln(){var i,e,l,u,f,_;return _=t,i=Ln(),i!==null?(e=w(),e!==null?(l=vi(),l!==null?(u=w(),u!==null?(f=Ei(),f!==null?i=[i,e,l,u,f]:(i=null,t=_)):(i=null,t=_)):(i=null,t=_)):(i=null,t=_)):(i=null,t=_),i}function vi(){var i,e;return e=t,i=Ti(),i!==null&&(i=function(l,u){R.status_code=parseInt(u.join(""))}(e,i)),i===null&&(t=e),i}function Ti(){var i,e,l,u;return u=t,i=g(),i!==null?(e=g(),e!==null?(l=g(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Ei(){var i,e,l;for(l=t,i=[],e=ie(),e===null&&(e=N(),e===null&&(e=ve(),e===null&&(e=Y(),e===null&&(e=$(),e===null&&(e=w(),e===null&&(e=F()))))));e!==null;)i.push(e),e=ie(),e===null&&(e=N(),e===null&&(e=ve(),e===null&&(e=Y(),e===null&&(e=$(),e===null&&(e=w(),e===null&&(e=F()))))));return i!==null&&(i=function(u){R.reason_phrase=n.substring(t,u)}(l)),i===null&&(t=l),i}function io(){var i,e,l,u,f,_;if(f=t,i=un(),i!==null){for(e=[],_=t,l=Se(),l!==null?(u=un(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=Se(),l!==null?(u=un(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function tu(){var i,e,l,u,f,_;return u=t,f=t,i=et(),i!==null?(_=t,n.charCodeAt(t)===64?(e="@",t++):(e=null,h('"@"')),e!==null?(l=et(),l!==null?e=[e,l]:(e=null,t=_)):(e=null,t=_),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m){R=n.substring(t,m)}(u)),i===null&&(t=u),i}function su(){var i,e,l,u,f,_,m;if(f=t,i=Q(),i===null)if(_=t,i=Hn(),i!==null){for(e=[],m=t,l=Se(),l!==null?(u=Hn(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=Se(),l!==null?(u=Hn(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=_)}else i=null,t=_;return i!==null&&(i=function(T){var y,O;for(O=R.multi_header.length,y=0;y<O;y++)if(R.multi_header[y].parsed===null){R=null;break}R!==null?R=R.multi_header:R=-1}()),i===null&&(t=f),i}function Hn(){var i,e,l,u,f,_,m;if(f=t,_=t,i=fe(),i===null&&(i=kt()),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=ks(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=ne(),l!==null?(u=ks(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=_)}else i=null,t=_;return i!==null&&(i=function(T){var y;R.multi_header||(R.multi_header=[]);try{y=new ps(R.uri,R.display_name,R.params),delete R.uri,delete R.display_name,delete R.params}catch{y=null}R.multi_header.push({possition:t,offset:T,parsed:y})}(f)),i===null&&(t=f),i}function kt(){var i,e,l,u,f;return f=t,i=Mt(),i=i!==null?i:"",i!==null?(e=Ue(),e!==null?(l=Re(),l!==null?(u=Ae(),u!==null?i=[i,e,l,u]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i}function Mt(){var i,e,l,u,f,_,m;if(f=t,_=t,i=U(),i!==null){for(e=[],m=t,l=me(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=me(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=_)}else i=null,t=_;return i===null&&(i=be()),i!==null&&(i=function(T,y){typeof y=="string"?R.display_name=y:R.display_name=y[1].reduce(function(O,se){return O+se[0]+se[1]},y[0])}(f,i)),i===null&&(t=f),i}function ks(){var i;return i=Fn(),i===null&&(i=yi(),i===null&&(i=Ge())),i}function Fn(){var i,e,l,u,f;return u=t,f=t,n.substr(t,1).toLowerCase()==="q"?(i=n.substr(t,1),t++):(i=null,h('"q"')),i!==null?(e=B(),e!==null?(l=es(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){R.params||(R.params={}),R.params.q=m}(u,i[2])),i===null&&(t=u),i}function yi(){var i,e,l,u,f;return u=t,f=t,n.substr(t,7).toLowerCase()==="expires"?(i=n.substr(t,7),t+=7):(i=null,h('"expires"')),i!==null?(e=B(),e!==null?(l=Zt(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){R.params||(R.params={}),R.params.expires=m}(u,i[2])),i===null&&(t=u),i}function Zt(){var i,e,l;if(l=t,e=g(),e!==null)for(i=[];e!==null;)i.push(e),e=g();else i=null;return i!==null&&(i=function(u,f){return parseInt(f.join(""))}(l,i)),i===null&&(t=l),i}function es(){var i,e,l,u,f,_,m,T;return _=t,m=t,n.charCodeAt(t)===48?(i="0",t++):(i=null,h('"0"')),i!==null?(T=t,n.charCodeAt(t)===46?(e=".",t++):(e=null,h('"."')),e!==null?(l=g(),l=l!==null?l:"",l!==null?(u=g(),u=u!==null?u:"",u!==null?(f=g(),f=f!==null?f:"",f!==null?e=[e,l,u,f]:(e=null,t=T)):(e=null,t=T)):(e=null,t=T)):(e=null,t=T),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=m)):(i=null,t=m),i!==null&&(i=function(y){return parseFloat(n.substring(t,y))}(_)),i===null&&(t=_),i}function Ge(){var i,e,l,u,f,_;return u=t,f=t,i=U(),i!==null?(_=t,e=B(),e!==null?(l=Ke(),l!==null?e=[e,l]:(e=null,t=_)):(e=null,t=_),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m,T,y){R.params||(R.params={}),typeof y>"u"?y=void 0:y=y[1],R.params[T.toLowerCase()]=y}(u,i[0],i[1])),i===null&&(t=u),i}function Ke(){var i;return i=U(),i===null&&(i=Qt(),i===null&&(i=Ce())),i}function lo(){var i,e,l,u,f,_;if(f=t,i=oo(),i!==null){for(e=[],_=t,l=ne(),l!==null?(u=qn(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=ne(),l!==null?(u=qn(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function oo(){var i;return n.substr(t,6).toLowerCase()==="render"?(i=n.substr(t,6),t+=6):(i=null,h('"render"')),i===null&&(n.substr(t,7).toLowerCase()==="session"?(i=n.substr(t,7),t+=7):(i=null,h('"session"')),i===null&&(n.substr(t,4).toLowerCase()==="icon"?(i=n.substr(t,4),t+=4):(i=null,h('"icon"')),i===null&&(n.substr(t,5).toLowerCase()==="alert"?(i=n.substr(t,5),t+=5):(i=null,h('"alert"')),i===null&&(i=U())))),i}function qn(){var i;return i=Vn(),i===null&&(i=Ge()),i}function Vn(){var i,e,l,u;return u=t,n.substr(t,8).toLowerCase()==="handling"?(i=n.substr(t,8),t+=8):(i=null,h('"handling"')),i!==null?(e=B(),e!==null?(n.substr(t,8).toLowerCase()==="optional"?(l=n.substr(t,8),t+=8):(l=null,h('"optional"')),l===null&&(n.substr(t,8).toLowerCase()==="required"?(l=n.substr(t,8),t+=8):(l=null,h('"required"')),l===null&&(l=U())),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function ao(){var i,e,l,u,f,_;if(f=t,i=U(),i!==null){for(e=[],_=t,l=Se(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=Se(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function nu(){var i,e,l;if(l=t,e=g(),e!==null)for(i=[];e!==null;)i.push(e),e=g();else i=null;return i!==null&&(i=function(u,f){R=parseInt(f.join(""))}(l,i)),i===null&&(t=l),i}function ru(){var i,e;return e=t,i=uo(),i!==null&&(i=function(l){R=n.substring(t,l)}(e)),i===null&&(t=e),i}function uo(){var i,e,l,u,f,_,m,T;if(m=t,i=Si(),i!==null)if(e=W(),e!==null)if(l=Ri(),l!==null){for(u=[],T=t,f=ne(),f!==null?(_=jn(),_!==null?f=[f,_]:(f=null,t=T)):(f=null,t=T);f!==null;)u.push(f),T=t,f=ne(),f!==null?(_=jn(),_!==null?f=[f,_]:(f=null,t=T)):(f=null,t=T);u!==null?i=[i,e,l,u]:(i=null,t=m)}else i=null,t=m;else i=null,t=m;else i=null,t=m;return i}function Si(){var i;return i=Ci(),i===null&&(i=Ai()),i}function Ci(){var i;return n.substr(t,4).toLowerCase()==="text"?(i=n.substr(t,4),t+=4):(i=null,h('"text"')),i===null&&(n.substr(t,5).toLowerCase()==="image"?(i=n.substr(t,5),t+=5):(i=null,h('"image"')),i===null&&(n.substr(t,5).toLowerCase()==="audio"?(i=n.substr(t,5),t+=5):(i=null,h('"audio"')),i===null&&(n.substr(t,5).toLowerCase()==="video"?(i=n.substr(t,5),t+=5):(i=null,h('"video"')),i===null&&(n.substr(t,11).toLowerCase()==="application"?(i=n.substr(t,11),t+=11):(i=null,h('"application"')),i===null&&(i=on()))))),i}function Ai(){var i;return n.substr(t,7).toLowerCase()==="message"?(i=n.substr(t,7),t+=7):(i=null,h('"message"')),i===null&&(n.substr(t,9).toLowerCase()==="multipart"?(i=n.substr(t,9),t+=9):(i=null,h('"multipart"')),i===null&&(i=on())),i}function on(){var i;return i=U(),i===null&&(i=an()),i}function an(){var i,e,l;return l=t,n.substr(t,2).toLowerCase()==="x-"?(i=n.substr(t,2),t+=2):(i=null,h('"x-"')),i!==null?(e=U(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function Ri(){var i;return i=on(),i===null&&(i=U()),i}function jn(){var i,e,l,u;return u=t,i=U(),i!==null?(e=B(),e!==null?(l=Bn(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Bn(){var i;return i=U(),i===null&&(i=Ce()),i}function co(){var i,e,l,u;return u=t,i=fo(),i!==null?(e=me(),e!==null?(l=rn(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function fo(){var i,e,l;if(l=t,e=g(),e!==null)for(i=[];e!==null;)i.push(e),e=g();else i=null;return i!==null&&(i=function(u,f){R.value=parseInt(f.join(""))}(l,i)),i===null&&(t=l),i}function ho(){var i,e;return e=t,i=Zt(),i!==null&&(i=function(l,u){R=u}(e,i)),i===null&&(t=e),i}function iu(){var i,e,l,u,f,_,m;if(f=t,_=t,i=un(),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=ne(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=_)}else i=null,t=_;return i!==null&&(i=function(T,y){R.event=y.join("").toLowerCase()}(f,i[0])),i===null&&(t=f),i}function un(){var i,e,l,u,f,_;if(f=t,i=P(),i!==null){for(e=[],_=t,n.charCodeAt(t)===46?(l=".",t++):(l=null,h('"."')),l!==null?(u=P(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,n.charCodeAt(t)===46?(l=".",t++):(l=null,h('"."')),l!==null?(u=P(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function cn(){var i,e,l,u,f,_,m;if(f=t,_=t,i=fe(),i===null&&(i=kt()),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=Ii(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=ne(),l!==null?(u=Ii(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=_)}else i=null,t=_;return i!==null&&(i=function(T){var y=R.tag;try{R=new ps(R.uri,R.display_name,R.params),y&&R.setParam("tag",y)}catch{R=-1}}()),i===null&&(t=f),i}function Ii(){var i;return i=fn(),i===null&&(i=Ge()),i}function fn(){var i,e,l,u,f;return u=t,f=t,n.substr(t,3).toLowerCase()==="tag"?(i=n.substr(t,3),t+=3):(i=null,h('"tag"')),i!==null?(e=B(),e!==null?(l=U(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){R.tag=m}(u,i[2])),i===null&&(t=u),i}function bi(){var i,e,l;if(l=t,e=g(),e!==null)for(i=[];e!==null;)i.push(e),e=g();else i=null;return i!==null&&(i=function(u,f){R=parseInt(f.join(""))}(l,i)),i===null&&(t=l),i}function lu(){var i,e;return e=t,i=Zt(),i!==null&&(i=function(l,u){R=u}(e,i)),i===null&&(t=e),i}function ou(){var i,e,l,u,f,_,m,T,y,O;for(T=t,y=t,i=[],e=Mt();e!==null;)i.push(e),e=Mt();if(i!==null)if(e=Ue(),e!==null)if(l=Re(),l!==null)if(u=Ae(),u!==null){for(f=[],O=t,_=ne(),_!==null?(m=Ge(),m!==null?_=[_,m]:(_=null,t=O)):(_=null,t=O);_!==null;)f.push(_),O=t,_=ne(),_!==null?(m=Ge(),m!==null?_=[_,m]:(_=null,t=O)):(_=null,t=O);f!==null?i=[i,e,l,u,f]:(i=null,t=y)}else i=null,t=y;else i=null,t=y;else i=null,t=y;else i=null,t=y;return i!==null&&(i=function(se){try{R=new ps(R.uri,R.display_name,R.params)}catch{R=-1}}()),i===null&&(t=T),i}function au(){var i;return i=wi(),i}function wi(){var i,e,l,u,f,_,m,T;if(m=t,n.substr(t,6).toLowerCase()==="digest"?(i=n.substr(t,6),t+=6):(i=null,h('"Digest"')),i!==null)if(e=me(),e!==null)if(l=ts(),l!==null){for(u=[],T=t,f=Se(),f!==null?(_=ts(),_!==null?f=[f,_]:(f=null,t=T)):(f=null,t=T);f!==null;)u.push(f),T=t,f=Se(),f!==null?(_=ts(),_!==null?f=[f,_]:(f=null,t=T)):(f=null,t=T);u!==null?i=[i,e,l,u]:(i=null,t=m)}else i=null,t=m;else i=null,t=m;else i=null,t=m;return i===null&&(i=Gn()),i}function Gn(){var i,e,l,u,f,_,m,T;if(m=t,i=U(),i!==null)if(e=me(),e!==null)if(l=Ms(),l!==null){for(u=[],T=t,f=Se(),f!==null?(_=Ms(),_!==null?f=[f,_]:(f=null,t=T)):(f=null,t=T);f!==null;)u.push(f),T=t,f=Se(),f!==null?(_=Ms(),_!==null?f=[f,_]:(f=null,t=T)):(f=null,t=T);u!==null?i=[i,e,l,u]:(i=null,t=m)}else i=null,t=m;else i=null,t=m;else i=null,t=m;return i}function Ms(){var i,e,l,u;return u=t,i=U(),i!==null?(e=B(),e!==null?(l=U(),l===null&&(l=Ce()),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function ts(){var i;return i=hn(),i===null&&(i=Di(),i===null&&(i=dn(),i===null&&(i=Ui(),i===null&&(i=Pi(),i===null&&(i=ki(),i===null&&(i=Mi(),i===null&&(i=Ms()))))))),i}function hn(){var i,e,l,u;return u=t,n.substr(t,5).toLowerCase()==="realm"?(i=n.substr(t,5),t+=5):(i=null,h('"realm"')),i!==null?(e=B(),e!==null?(l=Oi(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Oi(){var i,e;return e=t,i=be(),i!==null&&(i=function(l,u){R.realm=u}(e,i)),i===null&&(t=e),i}function Di(){var i,e,l,u,f,_,m,T,y;if(T=t,n.substr(t,6).toLowerCase()==="domain"?(i=n.substr(t,6),t+=6):(i=null,h('"domain"')),i!==null)if(e=B(),e!==null)if(l=tt(),l!==null)if(u=_n(),u!==null){if(f=[],y=t,m=w(),m!==null)for(_=[];m!==null;)_.push(m),m=w();else _=null;for(_!==null?(m=_n(),m!==null?_=[_,m]:(_=null,t=y)):(_=null,t=y);_!==null;){if(f.push(_),y=t,m=w(),m!==null)for(_=[];m!==null;)_.push(m),m=w();else _=null;_!==null?(m=_n(),m!==null?_=[_,m]:(_=null,t=y)):(_=null,t=y)}f!==null?(_=st(),_!==null?i=[i,e,l,u,f,_]:(i=null,t=T)):(i=null,t=T)}else i=null,t=T;else i=null,t=T;else i=null,t=T;else i=null,t=T;return i}function _n(){var i;return i=Mn(),i===null&&(i=tn()),i}function dn(){var i,e,l,u;return u=t,n.substr(t,5).toLowerCase()==="nonce"?(i=n.substr(t,5),t+=5):(i=null,h('"nonce"')),i!==null?(e=B(),e!==null?(l=Ni(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function Ni(){var i,e;return e=t,i=be(),i!==null&&(i=function(l,u){R.nonce=u}(e,i)),i===null&&(t=e),i}function Ui(){var i,e,l,u,f;return u=t,f=t,n.substr(t,6).toLowerCase()==="opaque"?(i=n.substr(t,6),t+=6):(i=null,h('"opaque"')),i!==null?(e=B(),e!==null?(l=be(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){R.opaque=m}(u,i[2])),i===null&&(t=u),i}function Pi(){var i,e,l,u,f;return u=t,n.substr(t,5).toLowerCase()==="stale"?(i=n.substr(t,5),t+=5):(i=null,h('"stale"')),i!==null?(e=B(),e!==null?(f=t,n.substr(t,4).toLowerCase()==="true"?(l=n.substr(t,4),t+=4):(l=null,h('"true"')),l!==null&&(l=function(_){R.stale=!0}()),l===null&&(t=f),l===null&&(f=t,n.substr(t,5).toLowerCase()==="false"?(l=n.substr(t,5),t+=5):(l=null,h('"false"')),l!==null&&(l=function(_){R.stale=!1}()),l===null&&(t=f)),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function ki(){var i,e,l,u,f;return u=t,f=t,n.substr(t,9).toLowerCase()==="algorithm"?(i=n.substr(t,9),t+=9):(i=null,h('"algorithm"')),i!==null?(e=B(),e!==null?(n.substr(t,3).toLowerCase()==="md5"?(l=n.substr(t,3),t+=3):(l=null,h('"MD5"')),l===null&&(n.substr(t,8).toLowerCase()==="md5-sess"?(l=n.substr(t,8),t+=8):(l=null,h('"MD5-sess"')),l===null&&(l=U())),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){R.algorithm=m.toUpperCase()}(u,i[2])),i===null&&(t=u),i}function Mi(){var i,e,l,u,f,_,m,T,y,O;if(T=t,n.substr(t,3).toLowerCase()==="qop"?(i=n.substr(t,3),t+=3):(i=null,h('"qop"')),i!==null)if(e=B(),e!==null)if(l=tt(),l!==null){if(y=t,u=pn(),u!==null){for(f=[],O=t,n.charCodeAt(t)===44?(_=",",t++):(_=null,h('","')),_!==null?(m=pn(),m!==null?_=[_,m]:(_=null,t=O)):(_=null,t=O);_!==null;)f.push(_),O=t,n.charCodeAt(t)===44?(_=",",t++):(_=null,h('","')),_!==null?(m=pn(),m!==null?_=[_,m]:(_=null,t=O)):(_=null,t=O);f!==null?u=[u,f]:(u=null,t=y)}else u=null,t=y;u!==null?(f=st(),f!==null?i=[i,e,l,u,f]:(i=null,t=T)):(i=null,t=T)}else i=null,t=T;else i=null,t=T;else i=null,t=T;return i}function pn(){var i,e;return e=t,n.substr(t,8).toLowerCase()==="auth-int"?(i=n.substr(t,8),t+=8):(i=null,h('"auth-int"')),i===null&&(n.substr(t,4).toLowerCase()==="auth"?(i=n.substr(t,4),t+=4):(i=null,h('"auth"')),i===null&&(i=U())),i!==null&&(i=function(l,u){R.qop||(R.qop=[]),R.qop.push(u.toLowerCase())}(e,i)),i===null&&(t=e),i}function Kn(){var i,e,l,u,f,_;if(f=t,i=U(),i!==null){for(e=[],_=t,l=Se(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=Se(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function uu(){var i,e,l,u,f,_,m;if(f=t,_=t,i=Wn(),i!==null){for(e=[],m=t,l=Se(),l!==null?(u=Wn(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=Se(),l!==null?(u=Wn(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=_)}else i=null,t=_;return i!==null&&(i=function(T){var y,O;for(O=R.multi_header.length,y=0;y<O;y++)if(R.multi_header[y].parsed===null){R=null;break}R!==null?R=R.multi_header:R=-1}()),i===null&&(t=f),i}function Wn(){var i,e,l,u,f,_,m;if(f=t,_=t,i=kt(),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=ne(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=_)}else i=null,t=_;return i!==null&&(i=function(T){var y;R.multi_header||(R.multi_header=[]);try{y=new ps(R.uri,R.display_name,R.params),delete R.uri,delete R.display_name,delete R.params}catch{y=null}R.multi_header.push({possition:t,offset:T,parsed:y})}(f)),i===null&&(t=f),i}function Yn(){var i,e,l,u,f,_,m;if(f=t,_=t,n.substr(t,3).toLowerCase()==="sip"?(i=n.substr(t,3),t+=3):(i=null,h('"SIP"')),i===null&&(i=U()),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=xi(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=ne(),l!==null?(u=xi(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=_)}else i=null,t=_;return i!==null&&(i=function(T,y){if(R.protocol=y.toLowerCase(),R.params||(R.params={}),R.params.text&&R.params.text[0]==='"'){var O=R.params.text;R.text=O.substring(1,O.length-1),delete R.params.text}}(f,i[0])),i===null&&(t=f),i}function xi(){var i;return i=zn(),i===null&&(i=Ge()),i}function zn(){var i,e,l,u,f,_;if(f=t,_=t,n.substr(t,5).toLowerCase()==="cause"?(i=n.substr(t,5),t+=5):(i=null,h('"cause"')),i!==null)if(e=B(),e!==null){if(u=g(),u!==null)for(l=[];u!==null;)l.push(u),u=g();else l=null;l!==null?i=[i,e,l]:(i=null,t=_)}else i=null,t=_;else i=null,t=_;return i!==null&&(i=function(m,T){R.cause=parseInt(T.join(""))}(f,i[2])),i===null&&(t=f),i}function _o(){var i,e,l,u,f,_;if(f=t,i=U(),i!==null){for(e=[],_=t,l=Se(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=Se(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function cu(){var i,e,l,u,f,_;if(f=t,i=Jn(),i!==null){for(e=[],_=t,l=Se(),l!==null?(u=Jn(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=Se(),l!==null?(u=Jn(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Jn(){var i,e,l,u,f,_;if(f=t,i=kt(),i!==null){for(e=[],_=t,l=ne(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=ne(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Xn(){var i,e,l,u,f,_;if(f=t,i=po(),i!==null){for(e=[],_=t,l=ne(),l!==null?(u=Qn(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=ne(),l!==null?(u=Qn(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function po(){var i,e;return e=t,n.substr(t,6).toLowerCase()==="active"?(i=n.substr(t,6),t+=6):(i=null,h('"active"')),i===null&&(n.substr(t,7).toLowerCase()==="pending"?(i=n.substr(t,7),t+=7):(i=null,h('"pending"')),i===null&&(n.substr(t,10).toLowerCase()==="terminated"?(i=n.substr(t,10),t+=10):(i=null,h('"terminated"')),i===null&&(i=U()))),i!==null&&(i=function(l){R.state=n.substring(t,l)}(e)),i===null&&(t=e),i}function Qn(){var i,e,l,u,f;return u=t,f=t,n.substr(t,6).toLowerCase()==="reason"?(i=n.substr(t,6),t+=6):(i=null,h('"reason"')),i!==null?(e=B(),e!==null?(l=Zn(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){typeof m<"u"&&(R.reason=m)}(u,i[2])),i===null&&(t=u),i===null&&(u=t,f=t,n.substr(t,7).toLowerCase()==="expires"?(i=n.substr(t,7),t+=7):(i=null,h('"expires"')),i!==null?(e=B(),e!==null?(l=Zt(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){typeof m<"u"&&(R.expires=m)}(u,i[2])),i===null&&(t=u),i===null&&(u=t,f=t,n.substr(t,11).toLowerCase()==="retry_after"?(i=n.substr(t,11),t+=11):(i=null,h('"retry_after"')),i!==null?(e=B(),e!==null?(l=Zt(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){typeof m<"u"&&(R.retry_after=m)}(u,i[2])),i===null&&(t=u),i===null&&(i=Ge()))),i}function Zn(){var i;return n.substr(t,11).toLowerCase()==="deactivated"?(i=n.substr(t,11),t+=11):(i=null,h('"deactivated"')),i===null&&(n.substr(t,9).toLowerCase()==="probation"?(i=n.substr(t,9),t+=9):(i=null,h('"probation"')),i===null&&(n.substr(t,8).toLowerCase()==="rejected"?(i=n.substr(t,8),t+=8):(i=null,h('"rejected"')),i===null&&(n.substr(t,7).toLowerCase()==="timeout"?(i=n.substr(t,7),t+=7):(i=null,h('"timeout"')),i===null&&(n.substr(t,6).toLowerCase()==="giveup"?(i=n.substr(t,6),t+=6):(i=null,h('"giveup"')),i===null&&(n.substr(t,10).toLowerCase()==="noresource"?(i=n.substr(t,10),t+=10):(i=null,h('"noresource"')),i===null&&(n.substr(t,9).toLowerCase()==="invariant"?(i=n.substr(t,9),t+=9):(i=null,h('"invariant"')),i===null&&(i=U()))))))),i}function mo(){var i;return i=j(),i=i!==null?i:"",i}function fu(){var i,e,l,u,f,_;if(f=t,i=U(),i!==null){for(e=[],_=t,l=Se(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=Se(),l!==null?(u=U(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i=i!==null?i:"",i}function hu(){var i,e,l,u,f,_,m;if(f=t,_=t,i=fe(),i===null&&(i=kt()),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=Li(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=ne(),l!==null?(u=Li(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=_)}else i=null,t=_;return i!==null&&(i=function(T){var y=R.tag;try{R=new ps(R.uri,R.display_name,R.params),y&&R.setParam("tag",y)}catch{R=-1}}()),i===null&&(t=f),i}function Li(){var i;return i=fn(),i===null&&(i=Ge()),i}function $i(){var i,e,l,u,f,_;if(f=t,i=er(),i!==null){for(e=[],_=t,l=Se(),l!==null?(u=er(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=Se(),l!==null?(u=er(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function er(){var i,e,l,u,f,_,m,T;if(m=t,i=Bi(),i!==null)if(e=me(),e!==null)if(l=Wi(),l!==null){for(u=[],T=t,f=ne(),f!==null?(_=xs(),_!==null?f=[f,_]:(f=null,t=T)):(f=null,t=T);f!==null;)u.push(f),T=t,f=ne(),f!==null?(_=xs(),_!==null?f=[f,_]:(f=null,t=T)):(f=null,t=T);u!==null?i=[i,e,l,u]:(i=null,t=m)}else i=null,t=m;else i=null,t=m;else i=null,t=m;return i}function xs(){var i;return i=tr(),i===null&&(i=Hi(),i===null&&(i=Fi(),i===null&&(i=qi(),i===null&&(i=Vi(),i===null&&(i=Ge()))))),i}function tr(){var i,e,l,u,f;return u=t,f=t,n.substr(t,3).toLowerCase()==="ttl"?(i=n.substr(t,3),t+=3):(i=null,h('"ttl"')),i!==null?(e=B(),e!==null?(l=sr(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){R.ttl=m}(u,i[2])),i===null&&(t=u),i}function Hi(){var i,e,l,u,f;return u=t,f=t,n.substr(t,5).toLowerCase()==="maddr"?(i=n.substr(t,5),t+=5):(i=null,h('"maddr"')),i!==null?(e=B(),e!==null?(l=Qt(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){R.maddr=m}(u,i[2])),i===null&&(t=u),i}function Fi(){var i,e,l,u,f;return u=t,f=t,n.substr(t,8).toLowerCase()==="received"?(i=n.substr(t,8),t+=8):(i=null,h('"received"')),i!==null?(e=B(),e!==null?(l=nt(),l===null&&(l=Xs()),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){R.received=m}(u,i[2])),i===null&&(t=u),i}function qi(){var i,e,l,u,f;return u=t,f=t,n.substr(t,6).toLowerCase()==="branch"?(i=n.substr(t,6),t+=6):(i=null,h('"branch"')),i!==null?(e=B(),e!==null?(l=U(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){R.branch=m}(u,i[2])),i===null&&(t=u),i}function Vi(){var i,e,l,u,f;return u=t,n.substr(t,5).toLowerCase()==="rport"?(i=n.substr(t,5),t+=5):(i=null,h('"rport"')),i!==null?(f=t,e=B(),e!==null?(l=ji(),l!==null?e=[e,l]:(e=null,t=f)):(e=null,t=f),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i}function ji(){var i,e,l,u,f,_,m;return _=t,m=t,i=g(),i=i!==null?i:"",i!==null?(e=g(),e=e!==null?e:"",e!==null?(l=g(),l=l!==null?l:"",l!==null?(u=g(),u=u!==null?u:"",u!==null?(f=g(),f=f!==null?f:"",f!==null?i=[i,e,l,u,f]:(i=null,t=m)):(i=null,t=m)):(i=null,t=m)):(i=null,t=m)):(i=null,t=m),i!==null&&(i=function(T,y){R.rport=parseInt(y.join(""))}(_,i)),i===null&&(t=_),i}function Bi(){var i,e,l,u,f,_;return _=t,i=Gi(),i!==null?(e=W(),e!==null?(l=U(),l!==null?(u=W(),u!==null?(f=Ki(),f!==null?i=[i,e,l,u,f]:(i=null,t=_)):(i=null,t=_)):(i=null,t=_)):(i=null,t=_)):(i=null,t=_),i}function Gi(){var i,e;return e=t,n.substr(t,3).toLowerCase()==="sip"?(i=n.substr(t,3),t+=3):(i=null,h('"SIP"')),i===null&&(i=U()),i!==null&&(i=function(l,u){R.protocol=u}(e,i)),i===null&&(t=e),i}function Ki(){var i,e;return e=t,n.substr(t,3).toLowerCase()==="udp"?(i=n.substr(t,3),t+=3):(i=null,h('"UDP"')),i===null&&(n.substr(t,3).toLowerCase()==="tcp"?(i=n.substr(t,3),t+=3):(i=null,h('"TCP"')),i===null&&(n.substr(t,3).toLowerCase()==="tls"?(i=n.substr(t,3),t+=3):(i=null,h('"TLS"')),i===null&&(n.substr(t,4).toLowerCase()==="sctp"?(i=n.substr(t,4),t+=4):(i=null,h('"SCTP"')),i===null&&(i=U())))),i!==null&&(i=function(l,u){R.transport=u}(e,i)),i===null&&(t=e),i}function Wi(){var i,e,l,u,f;return u=t,i=Yi(),i!==null?(f=t,e=Te(),e!==null?(l=zi(),l!==null?e=[e,l]:(e=null,t=f)):(e=null,t=f),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=u)):(i=null,t=u),i}function Yi(){var i,e;return e=t,i=nt(),i===null&&(i=Un(),i===null&&(i=_s())),i!==null&&(i=function(l){R.host=n.substring(t,l)}(e)),i===null&&(t=e),i}function zi(){var i,e,l,u,f,_,m;return _=t,m=t,i=g(),i=i!==null?i:"",i!==null?(e=g(),e=e!==null?e:"",e!==null?(l=g(),l=l!==null?l:"",l!==null?(u=g(),u=u!==null?u:"",u!==null?(f=g(),f=f!==null?f:"",f!==null?i=[i,e,l,u,f]:(i=null,t=m)):(i=null,t=m)):(i=null,t=m)):(i=null,t=m)):(i=null,t=m),i!==null&&(i=function(T,y){R.port=parseInt(y.join(""))}(_,i)),i===null&&(t=_),i}function sr(){var i,e,l,u,f;return u=t,f=t,i=g(),i!==null?(e=g(),e=e!==null?e:"",e!==null?(l=g(),l=l!==null?l:"",l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){return parseInt(m.join(""))}(u,i)),i===null&&(t=u),i}function Ji(){var i;return i=wi(),i}function _u(){var i,e,l,u,f,_;if(f=t,i=go(),i!==null){for(e=[],_=t,l=ne(),l!==null?(u=nr(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=ne(),l!==null?(u=nr(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function go(){var i,e;return e=t,i=Zt(),i!==null&&(i=function(l,u){R.expires=u}(e,i)),i===null&&(t=e),i}function nr(){var i;return i=rr(),i===null&&(i=Ge()),i}function rr(){var i,e,l,u,f;return u=t,f=t,n.substr(t,9).toLowerCase()==="refresher"?(i=n.substr(t,9),t+=9):(i=null,h('"refresher"')),i!==null?(e=B(),e!==null?(n.substr(t,3).toLowerCase()==="uac"?(l=n.substr(t,3),t+=3):(l=null,h('"uac"')),l===null&&(n.substr(t,3).toLowerCase()==="uas"?(l=n.substr(t,3),t+=3):(l=null,h('"uas"'))),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){R.refresher=m.toLowerCase()}(u,i[2])),i===null&&(t=u),i}function vo(){var i,e,l,u;return u=t,i=U(),i!==null?(e=D(),e!==null?(l=To(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function To(){var i,e;for(i=[],e=V(),e===null&&(e=$(),e===null&&(e=me()));e!==null;)i.push(e),e=V(),e===null&&(e=$(),e===null&&(e=me()));return i}function Eo(){var i,e;for(i=[],e=C();e!==null;)i.push(e),e=C();return i}function du(){var i,e,l;return l=t,n.substr(t,5)==="uuid:"?(i="uuid:",t+=5):(i=null,h('"uuid:"')),i!==null?(e=yo(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function yo(){var i,e,l,u,f,_,m,T,y,O,se;return O=t,se=t,i=Lt(),i!==null?(n.charCodeAt(t)===45?(e="-",t++):(e=null,h('"-"')),e!==null?(l=xt(),l!==null?(n.charCodeAt(t)===45?(u="-",t++):(u=null,h('"-"')),u!==null?(f=xt(),f!==null?(n.charCodeAt(t)===45?(_="-",t++):(_=null,h('"-"')),_!==null?(m=xt(),m!==null?(n.charCodeAt(t)===45?(T="-",t++):(T=null,h('"-"')),T!==null?(y=Xi(),y!==null?i=[i,e,l,u,f,_,m,T,y]:(i=null,t=se)):(i=null,t=se)):(i=null,t=se)):(i=null,t=se)):(i=null,t=se)):(i=null,t=se)):(i=null,t=se)):(i=null,t=se)):(i=null,t=se),i!==null&&(i=function(De,At){R=n.substring(t+5,De)}(O,i[0])),i===null&&(t=O),i}function xt(){var i,e,l,u,f;return f=t,i=E(),i!==null?(e=E(),e!==null?(l=E(),l!==null?(u=E(),u!==null?i=[i,e,l,u]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i}function Lt(){var i,e,l;return l=t,i=xt(),i!==null?(e=xt(),e!==null?i=[i,e]:(i=null,t=l)):(i=null,t=l),i}function Xi(){var i,e,l,u;return u=t,i=xt(),i!==null?(e=xt(),e!==null?(l=xt(),l!==null?i=[i,e,l]:(i=null,t=u)):(i=null,t=u)):(i=null,t=u),i}function So(){var i,e,l,u,f,_,m;if(f=t,_=t,i=fe(),i===null&&(i=kt()),i!==null){for(e=[],m=t,l=ne(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);l!==null;)e.push(l),m=t,l=ne(),l!==null?(u=Ge(),u!==null?l=[l,u]:(l=null,t=m)):(l=null,t=m);e!==null?i=[i,e]:(i=null,t=_)}else i=null,t=_;return i!==null&&(i=function(T){try{R=new ps(R.uri,R.display_name,R.params)}catch{R=-1}}()),i===null&&(t=f),i}function pu(){var i,e,l,u,f,_;if(f=t,i=Co(),i!==null){for(e=[],_=t,l=ne(),l!==null?(u=ir(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);l!==null;)e.push(l),_=t,l=ne(),l!==null?(u=ir(),u!==null?l=[l,u]:(l=null,t=_)):(l=null,t=_);e!==null?i=[i,e]:(i=null,t=f)}else i=null,t=f;return i}function Co(){var i,e,l,u,f,_;return u=t,f=t,i=et(),i!==null?(_=t,n.charCodeAt(t)===64?(e="@",t++):(e=null,h('"@"')),e!==null?(l=et(),l!==null?e=[e,l]:(e=null,t=_)):(e=null,t=_),e=e!==null?e:"",e!==null?i=[i,e]:(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(m){R.call_id=n.substring(t,m)}(u)),i===null&&(t=u),i}function ir(){var i;return i=lr(),i===null&&(i=Qi(),i===null&&(i=Zi(),i===null&&(i=Ge()))),i}function lr(){var i,e,l,u,f;return u=t,f=t,n.substr(t,6)==="to-tag"?(i="to-tag",t+=6):(i=null,h('"to-tag"')),i!==null?(e=B(),e!==null?(l=U(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){R.to_tag=m}(u,i[2])),i===null&&(t=u),i}function Qi(){var i,e,l,u,f;return u=t,f=t,n.substr(t,8)==="from-tag"?(i="from-tag",t+=8):(i=null,h('"from-tag"')),i!==null?(e=B(),e!==null?(l=U(),l!==null?i=[i,e,l]:(i=null,t=f)):(i=null,t=f)):(i=null,t=f),i!==null&&(i=function(_,m){R.from_tag=m}(u,i[2])),i===null&&(t=u),i}function Zi(){var i,e;return e=t,n.substr(t,10)==="early-only"?(i="early-only",t+=10):(i=null,h('"early-only"')),i!==null&&(i=function(l){R.early_only=!0}()),i===null&&(t=e),i}function Ao(i){i.sort();for(var e=null,l=[],u=0;u<i.length;u++)i[u]!==e&&(l.push(i[u]),e=i[u]);return l}function mu(){for(var i=1,e=1,l=!1,u=0;u<Math.max(t,s);u++){var f=n.charAt(u);f===`
|
75
|
+
`?(l||i++,e=1,l=!1):f==="\r"||f==="\u2028"||f==="\u2029"?(i++,e=1,l=!0):(e++,l=!1)}return{line:i,column:e}}var Ro=ls(),ps=Ta(),R={},b=a[o]();if(b===null||t!==n.length){var el=Math.max(t,s),tl=el<n.length?n.charAt(el):null,Io=mu();return new this.SyntaxError(Ao(p),tl,el,Io.line,Io.column),-1}return R},toSource:function(){return this._source}};return r.SyntaxError=function(n,o,a,t,s){function p(h,d){var g,v;switch(h.length){case 0:g="end of input";break;case 1:g=h[0];break;default:g=h.slice(0,h.length-1).join(", ")+" or "+h[h.length-1]}return v=d?c(d):"end of input","Expected "+g+" but "+v+" found."}this.name="SyntaxError",this.expected=n,this.found=o,this.message=p(n,o),this.offset=a,this.line=t,this.column=s},r.SyntaxError.prototype=Error.prototype,r}()),Ea}var ya,Jc;function ls(){if(Jc)return ya;Jc=1;const c=we,r=ft(),n=Gt();return ya=class sh{static parse(a){if(a=n.parse(a,"SIP_URI"),a!==-1)return a}constructor(a,t,s,p,h={},d={}){if(!s)throw new TypeError('missing or invalid "host" parameter');this._parameters={},this._headers={},this._scheme=a||c.SIP,this._user=t,this._host=s,this._port=p;for(const g in h)Object.prototype.hasOwnProperty.call(h,g)&&this.setParam(g,h[g]);for(const g in d)Object.prototype.hasOwnProperty.call(d,g)&&this.setHeader(g,d[g])}get scheme(){return this._scheme}set scheme(a){this._scheme=a.toLowerCase()}get user(){return this._user}set user(a){this._user=a}get host(){return this._host}set host(a){this._host=a.toLowerCase()}get port(){return this._port}set port(a){this._port=a===0?a:parseInt(a,10)||null}setParam(a,t){a&&(this._parameters[a.toLowerCase()]=typeof t>"u"||t===null?null:t.toString())}getParam(a){if(a)return this._parameters[a.toLowerCase()]}hasParam(a){if(a)return this._parameters.hasOwnProperty(a.toLowerCase())&&!0||!1}deleteParam(a){if(a=a.toLowerCase(),this._parameters.hasOwnProperty(a)){const t=this._parameters[a];return delete this._parameters[a],t}}clearParams(){this._parameters={}}setHeader(a,t){this._headers[r.headerize(a)]=Array.isArray(t)?t:[t]}getHeader(a){if(a)return this._headers[r.headerize(a)]}hasHeader(a){if(a)return this._headers.hasOwnProperty(r.headerize(a))&&!0||!1}deleteHeader(a){if(a=r.headerize(a),this._headers.hasOwnProperty(a)){const t=this._headers[a];return delete this._headers[a],t}}clearHeaders(){this._headers={}}clone(){return new sh(this._scheme,this._user,this._host,this._port,JSON.parse(JSON.stringify(this._parameters)),JSON.parse(JSON.stringify(this._headers)))}toString(){const a=[];let t=`${this._scheme}:`;this._user&&(t+=`${r.escapeUser(this._user)}@`),t+=this._host,(this._port||this._port===0)&&(t+=`:${this._port}`);for(const s in this._parameters)Object.prototype.hasOwnProperty.call(this._parameters,s)&&(t+=`;${s}`,this._parameters[s]!==null&&(t+=`=${this._parameters[s]}`));for(const s in this._headers)if(Object.prototype.hasOwnProperty.call(this._headers,s))for(const p of this._headers[s])a.push(`${s}=${p}`);return a.length>0&&(t+=`?${a.join("&")}`),t}toAor(a){let t=`${this._scheme}:`;return this._user&&(t+=`${r.escapeUser(this._user)}@`),t+=this._host,a&&(this._port||this._port===0)&&(t+=`:${this._port}`),t}},ya}var Xc;function ft(){if(Xc)return ze;Xc=1;const c=we,r=ls(),n=Gt();ze.str_utf8_length=s=>unescape(encodeURIComponent(s)).length;const o=ze.isFunction=s=>s!==void 0?Object.prototype.toString.call(s)==="[object Function]":!1;ze.isString=s=>s!==void 0?Object.prototype.toString.call(s)==="[object String]":!1,ze.isDecimal=s=>!isNaN(s)&&parseFloat(s)===parseInt(s,10),ze.isEmpty=s=>s===null||s===""||s===void 0||Array.isArray(s)&&s.length===0||typeof s=="number"&&isNaN(s),ze.hasMethods=function(s,...p){for(const h of p)if(o(s[h]))return!1;return!0};const a=ze.createRandomToken=(s,p=32)=>{let h,d,g="";for(h=0;h<s;h++)d=Math.random()*p|0,g+=d.toString(p);return g};ze.newTag=()=>a(10),ze.newUUID=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,p=>{const h=Math.random()*16|0;return(p==="x"?h:h&3|8).toString(16)}),ze.hostType=s=>{if(s){if(s=n.parse(s,"host"),s!==-1)return s.host_type}else return};const t=ze.escapeUser=s=>encodeURIComponent(decodeURIComponent(s)).replace(/%3A/ig,":").replace(/%2B/ig,"+").replace(/%3F/ig,"?").replace(/%2F/ig,"/");return ze.normalizeTarget=(s,p)=>{if(s){if(s instanceof r)return s;if(typeof s=="string"){const h=s.split("@");let d,g;switch(h.length){case 1:if(!p)return;d=s,g=p;break;case 2:d=h[0],g=h[1];break;default:d=h.slice(0,h.length-1).join("@"),g=h[h.length-1]}d=d.replace(/^(sips?|tel):/i,""),/^[-.()]*\+?[0-9\-.()]+$/.test(d)&&(d=d.replace(/[-.()]/g,"")),s=`${c.SIP}:${t(d)}@${g}`;let v;return(v=r.parse(s))?v:void 0}else return}else return},ze.headerize=s=>{const p={"Call-Id":"Call-ID",Cseq:"CSeq","Www-Authenticate":"WWW-Authenticate"},h=s.toLowerCase().replace(/_/g,"-").split("-");let d="";const g=h.length;let v;for(v=0;v<g;v++)v!==0&&(d+="-"),d+=h[v].charAt(0).toUpperCase()+h[v].substring(1);return p[d]&&(d=p[d]),d},ze.sipErrorCause=s=>{for(const p in c.SIP_ERROR_CAUSES)if(c.SIP_ERROR_CAUSES[p].indexOf(s)!==-1)return c.causes[p];return c.causes.SIP_FAILURE_CODE},ze.getRandomTestNetIP=()=>{function s(p,h){return Math.floor(Math.random()*(h-p+1)+p)}return`192.0.2.${s(1,254)}`},ze.calculateMD5=s=>{function p(ge,Ee){return ge<<Ee|ge>>>32-Ee}function h(ge,Ee){const Ce=ge&2147483648,be=Ee&2147483648,he=ge&1073741824,ce=Ee&1073741824,fe=(ge&1073741823)+(Ee&1073741823);return he&ce?fe^2147483648^Ce^be:he|ce?fe&1073741824?fe^3221225472^Ce^be:fe^1073741824^Ce^be:fe^Ce^be}function d(ge,Ee,Ce){return ge&Ee|~ge&Ce}function g(ge,Ee,Ce){return ge&Ce|Ee&~Ce}function v(ge,Ee,Ce){return ge^Ee^Ce}function E(ge,Ee,Ce){return Ee^(ge|~Ce)}function S(ge,Ee,Ce,be,he,ce,fe){return ge=h(ge,h(h(d(Ee,Ce,be),he),fe)),h(p(ge,ce),Ee)}function C(ge,Ee,Ce,be,he,ce,fe){return ge=h(ge,h(h(g(Ee,Ce,be),he),fe)),h(p(ge,ce),Ee)}function I(ge,Ee,Ce,be,he,ce,fe){return ge=h(ge,h(h(v(Ee,Ce,be),he),fe)),h(p(ge,ce),Ee)}function w(ge,Ee,Ce,be,he,ce,fe){return ge=h(ge,h(h(E(Ee,Ce,be),he),fe)),h(p(ge,ce),Ee)}function F(ge){let Ee;const Ce=ge.length,be=Ce+8,ce=((be-be%64)/64+1)*16,fe=new Array(ce-1);let Re=0,Oe=0;for(;Oe<Ce;)Ee=(Oe-Oe%4)/4,Re=Oe%4*8,fe[Ee]=fe[Ee]|ge.charCodeAt(Oe)<<Re,Oe++;return Ee=(Oe-Oe%4)/4,Re=Oe%4*8,fe[Ee]=fe[Ee]|128<<Re,fe[ce-2]=Ce<<3,fe[ce-1]=Ce>>>29,fe}function L(ge){let Ee="",Ce="",be,he;for(he=0;he<=3;he++)be=ge>>>he*8&255,Ce=`0${be.toString(16)}`,Ee=Ee+Ce.substr(Ce.length-2,2);return Ee}function ie(ge){let Ee="";for(let Ce=0;Ce<ge.length;Ce++){const be=ge.charCodeAt(Ce);be<128?Ee+=String.fromCharCode(be):be>127&&be<2048?(Ee+=String.fromCharCode(be>>6|192),Ee+=String.fromCharCode(be&63|128)):(Ee+=String.fromCharCode(be>>12|224),Ee+=String.fromCharCode(be>>6&63|128),Ee+=String.fromCharCode(be&63|128))}return Ee}let N=[],H,ve,me,M,D,j,V,Y,$;const X=7,U=12,P=17,Z=22,et=5,Q=9,W=14,B=20,te=4,de=11,Ae=16,Ue=23,Se=6,ne=10,Te=15,tt=21;for(s=ie(s),N=F(s),j=1732584193,V=4023233417,Y=2562383102,$=271733878,H=0;H<N.length;H+=16)ve=j,me=V,M=Y,D=$,j=S(j,V,Y,$,N[H+0],X,3614090360),$=S($,j,V,Y,N[H+1],U,3905402710),Y=S(Y,$,j,V,N[H+2],P,606105819),V=S(V,Y,$,j,N[H+3],Z,3250441966),j=S(j,V,Y,$,N[H+4],X,4118548399),$=S($,j,V,Y,N[H+5],U,1200080426),Y=S(Y,$,j,V,N[H+6],P,2821735955),V=S(V,Y,$,j,N[H+7],Z,4249261313),j=S(j,V,Y,$,N[H+8],X,1770035416),$=S($,j,V,Y,N[H+9],U,2336552879),Y=S(Y,$,j,V,N[H+10],P,4294925233),V=S(V,Y,$,j,N[H+11],Z,2304563134),j=S(j,V,Y,$,N[H+12],X,1804603682),$=S($,j,V,Y,N[H+13],U,4254626195),Y=S(Y,$,j,V,N[H+14],P,2792965006),V=S(V,Y,$,j,N[H+15],Z,1236535329),j=C(j,V,Y,$,N[H+1],et,4129170786),$=C($,j,V,Y,N[H+6],Q,3225465664),Y=C(Y,$,j,V,N[H+11],W,643717713),V=C(V,Y,$,j,N[H+0],B,3921069994),j=C(j,V,Y,$,N[H+5],et,3593408605),$=C($,j,V,Y,N[H+10],Q,38016083),Y=C(Y,$,j,V,N[H+15],W,3634488961),V=C(V,Y,$,j,N[H+4],B,3889429448),j=C(j,V,Y,$,N[H+9],et,568446438),$=C($,j,V,Y,N[H+14],Q,3275163606),Y=C(Y,$,j,V,N[H+3],W,4107603335),V=C(V,Y,$,j,N[H+8],B,1163531501),j=C(j,V,Y,$,N[H+13],et,2850285829),$=C($,j,V,Y,N[H+2],Q,4243563512),Y=C(Y,$,j,V,N[H+7],W,1735328473),V=C(V,Y,$,j,N[H+12],B,2368359562),j=I(j,V,Y,$,N[H+5],te,4294588738),$=I($,j,V,Y,N[H+8],de,2272392833),Y=I(Y,$,j,V,N[H+11],Ae,1839030562),V=I(V,Y,$,j,N[H+14],Ue,4259657740),j=I(j,V,Y,$,N[H+1],te,2763975236),$=I($,j,V,Y,N[H+4],de,1272893353),Y=I(Y,$,j,V,N[H+7],Ae,4139469664),V=I(V,Y,$,j,N[H+10],Ue,3200236656),j=I(j,V,Y,$,N[H+13],te,681279174),$=I($,j,V,Y,N[H+0],de,3936430074),Y=I(Y,$,j,V,N[H+3],Ae,3572445317),V=I(V,Y,$,j,N[H+6],Ue,76029189),j=I(j,V,Y,$,N[H+9],te,3654602809),$=I($,j,V,Y,N[H+12],de,3873151461),Y=I(Y,$,j,V,N[H+15],Ae,530742520),V=I(V,Y,$,j,N[H+2],Ue,3299628645),j=w(j,V,Y,$,N[H+0],Se,4096336452),$=w($,j,V,Y,N[H+7],ne,1126891415),Y=w(Y,$,j,V,N[H+14],Te,2878612391),V=w(V,Y,$,j,N[H+5],tt,4237533241),j=w(j,V,Y,$,N[H+12],Se,1700485571),$=w($,j,V,Y,N[H+3],ne,2399980690),Y=w(Y,$,j,V,N[H+10],Te,4293915773),V=w(V,Y,$,j,N[H+1],tt,2240044497),j=w(j,V,Y,$,N[H+8],Se,1873313359),$=w($,j,V,Y,N[H+15],ne,4264355552),Y=w(Y,$,j,V,N[H+6],Te,2734768916),V=w(V,Y,$,j,N[H+13],tt,1309151649),j=w(j,V,Y,$,N[H+4],Se,4149444226),$=w($,j,V,Y,N[H+11],ne,3174756917),Y=w(Y,$,j,V,N[H+2],Te,718787259),V=w(V,Y,$,j,N[H+9],tt,3951481745),j=h(j,ve),V=h(V,me),Y=h(Y,M),$=h($,D);return(L(j)+L(V)+L(Y)+L($)).toLowerCase()},ze.closeMediaStream=s=>{if(s)try{let p;if(s.getTracks){p=s.getTracks();for(const h of p)h.stop()}else{p=s.getAudioTracks();for(const h of p)h.stop();p=s.getVideoTracks();for(const h of p)h.stop()}}catch{(typeof s.stop=="function"||typeof s.stop=="object")&&s.stop()}},ze.cloneArray=s=>s&&s.slice()||[],ze.cloneObject=(s,p={})=>s&&Object.assign({},s)||p,ze}const Qc=Ot,Vp=it,ht=we,Ze=ft(),Zc=Ta(),jp=Gt(),Sa=new Vp("SIPMessage");class ql{constructor(r,n,o,a,t,s){if(!r||!n||!o)return null;a=a||{},this.ua=o,this.headers={},this.method=r,this.ruri=n,this.body=s,this.extraHeaders=Ze.cloneArray(t),this.ua.configuration.extra_headers&&(this.extraHeaders=this.extraHeaders.concat(this.ua.configuration.extra_headers)),a.route_set?this.setHeader("route",a.route_set):o.configuration.use_preloaded_route&&this.setHeader("route",`<${o.transport.sip_uri};lr>`),this.setHeader("via",""),this.setHeader("max-forwards",ht.MAX_FORWARDS);const p=a.to_uri||n,h=a.to_tag?{tag:a.to_tag}:null,d=typeof a.to_display_name<"u"?a.to_display_name:null;this.to=new Zc(p,d,h),this.setHeader("to",this.to.toString());const g=a.from_uri||o.configuration.uri,v={tag:a.from_tag||Ze.newTag()};let E;typeof a.from_display_name<"u"?E=a.from_display_name:o.configuration.display_name?E=o.configuration.display_name:E=null,this.from=new Zc(g,E,v),this.setHeader("from",this.from.toString());const S=a.call_id||o.configuration.jssip_id+Ze.createRandomToken(15);this.call_id=S,this.setHeader("call-id",S);const C=a.cseq||Math.floor(Math.random()*1e4);this.cseq=C,this.setHeader("cseq",`${C} ${r}`)}setHeader(r,n){const o=new RegExp(`^\\s*${r}\\s*:`,"i");for(let a=0;a<this.extraHeaders.length;a++)o.test(this.extraHeaders[a])&&this.extraHeaders.splice(a,1);this.headers[Ze.headerize(r)]=Array.isArray(n)?n:[n]}getHeader(r){const n=this.headers[Ze.headerize(r)];if(n){if(n[0])return n[0]}else{const o=new RegExp(`^\\s*${r}\\s*:`,"i");for(const a of this.extraHeaders)if(o.test(a))return a.substring(a.indexOf(":")+1).trim()}}getHeaders(r){const n=this.headers[Ze.headerize(r)],o=[];if(n){for(const a of n)o.push(a);return o}else{const a=new RegExp(`^\\s*${r}\\s*:`,"i");for(const t of this.extraHeaders)a.test(t)&&o.push(t.substring(t.indexOf(":")+1).trim());return o}}hasHeader(r){if(this.headers[Ze.headerize(r)])return!0;{const n=new RegExp(`^\\s*${r}\\s*:`,"i");for(const o of this.extraHeaders)if(n.test(o))return!0}return!1}parseSDP(r){return!r&&this.sdp?this.sdp:(this.sdp=Qc.parse(this.body||""),this.sdp)}toString(){let r=`${this.method} ${this.ruri} SIP/2.0\r
|
76
76
|
`;for(const a in this.headers)if(Object.prototype.hasOwnProperty.call(this.headers,a))for(const t of this.headers[a])r+=`${a}: ${t}\r
|
77
77
|
`;for(const a of this.extraHeaders)r+=`${a.trim()}\r
|
78
78
|
`;const n=[];switch(this.method){case ht.REGISTER:n.push("path","gruu");break;case ht.INVITE:this.ua.configuration.session_timers&&n.push("timer"),(this.ua.contact.pub_gruu||this.ua.contact.temp_gruu)&&n.push("gruu"),n.push("ice","replaces");break;case ht.UPDATE:this.ua.configuration.session_timers&&n.push("timer"),n.push("ice");break}n.push("outbound");const o=this.ua.configuration.user_agent||ht.USER_AGENT;if(r+=`Allow: ${ht.ALLOWED_METHODS}\r
|
@@ -109,10 +109,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
109
109
|
`,this.ua.configuration.extra_headers)for(const s of this.ua.configuration.extra_headers)a+=`${s.trim()}\r
|
110
110
|
`;a+=`Content-Length: 0\r
|
111
111
|
\r
|
112
|
-
`,this.transport.send(a)}}class Gp extends ef{constructor(){super(),this.headers={},this.status_code=null,this.reason_phrase=null}}var Kt={OutgoingRequest:ql,InitialOutgoingInviteRequest:Ca,IncomingRequest:Bp,IncomingResponse:Gp};const Kp=it,ls=ft(),Ht=new Kp("DigestAuthentication");var tf=class{constructor(r){this._credentials=r,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}get(r){switch(r){case"realm":return this._realm;case"ha1":return this._ha1;default:Ht.warn('get() | cannot get "%s" parameter',r);return}}authenticate({method:r,ruri:n,body:o},a,t=null){if(this._algorithm=a.algorithm,this._realm=a.realm,this._nonce=a.nonce,this._opaque=a.opaque,this._stale=a.stale,this._algorithm){if(this._algorithm!=="MD5")return Ht.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return Ht.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return Ht.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return Ht.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return Ht.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(a.qop)if(a.qop.indexOf("auth-int")>-1)this._qop="auth-int";else if(a.qop.indexOf("auth")>-1)this._qop="auth";else return Ht.warn('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;else this._qop=null;this._method=r,this._uri=n,this._cnonce=t||ls.createRandomToken(12),this._nc+=1;const s=Number(this._nc).toString(16);this._ncHex="00000000".substr(0,8-s.length)+s,this._nc===4294967296&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=ls.calculateMD5(`${this._credentials.username}:${this._realm}:${this._credentials.password}`):this._ha1=this._credentials.ha1;let p,h;return this._qop==="auth"?(p=`${this._method}:${this._uri}`,h=ls.calculateMD5(p),Ht.debug('authenticate() | using qop=auth [a2:"%s"]',p),this._response=ls.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth:${h}`)):this._qop==="auth-int"?(p=`${this._method}:${this._uri}:${ls.calculateMD5(o||"")}`,h=ls.calculateMD5(p),Ht.debug('authenticate() | using qop=auth-int [a2:"%s"]',p),this._response=ls.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth-int:${h}`)):this._qop===null&&(p=`${this._method}:${this._uri}`,h=ls.calculateMD5(p),Ht.debug('authenticate() | using qop=null [a2:"%s"]',p),this._response=ls.calculateMD5(`${this._ha1}:${this._nonce}:${h}`)),Ht.debug("authenticate() | response generated"),!0}toString(){const r=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return r.push(`algorithm=${this._algorithm}`),r.push(`username="${this._credentials.username}"`),r.push(`realm="${this._realm}"`),r.push(`nonce="${this._nonce}"`),r.push(`uri="${this._uri}"`),r.push(`response="${this._response}"`),this._opaque&&r.push(`opaque="${this._opaque}"`),this._qop&&(r.push(`qop=${this._qop}`),r.push(`cnonce="${this._cnonce}"`),r.push(`nc=${this._ncHex}`)),`Digest ${r.join(", ")}`}};const Wp=vt(tf),os=500,Yp=4e3,sf=5e3;var nf={T1:os,T2:Yp,T4:sf,TIMER_B:64*os,TIMER_D:0*os,TIMER_F:64*os,TIMER_H:64*os,TIMER_I:0*os,TIMER_J:0*os,TIMER_K:0*sf,TIMER_L:64*os,TIMER_M:64*os,PROVISIONAL_RESPONSE_INTERVAL:6e4};const Or=ot.EventEmitter,Dr=it,Nr=we,rf=Kt,Wt=nf,lf=new Dr("NonInviteClientTransaction"),Vl=new Dr("InviteClientTransaction"),zp=new Dr("AckClientTransaction"),of=new Dr("NonInviteServerTransaction"),jl=new Dr("InviteServerTransaction"),ae={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"};class Jp extends Or{constructor(r,n,o,a){super(),this.type=ae.NON_INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=r,this.transport=n,this.request=o,this.eventHandlers=a;let t=`SIP/2.0/${n.via_transport}`;t+=` ${r.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t),this.ua.newTransaction(this)}get C(){return ae}stateChanged(r){this.state=r,this.emit("stateChanged")}send(){this.stateChanged(ae.STATUS_TRYING),this.F=setTimeout(()=>{this.timer_F()},Wt.TIMER_F),this.transport.send(this.request)||this.onTransportError()}onTransportError(){lf.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}timer_F(){lf.debug(`Timer F expired for transaction ${this.id}`),this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}timer_K(){this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this)}receiveResponse(r){const n=r.status_code;if(n<200)switch(this.state){case ae.STATUS_TRYING:case ae.STATUS_PROCEEDING:this.stateChanged(ae.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(r);break}else switch(this.state){case ae.STATUS_TRYING:case ae.STATUS_PROCEEDING:this.stateChanged(ae.STATUS_COMPLETED),clearTimeout(this.F),n===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(r),this.K=setTimeout(()=>{this.timer_K()},Wt.TIMER_K);break;case ae.STATUS_COMPLETED:break}}}class Xp extends Or{constructor(r,n,o,a){super(),this.type=ae.INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=r,this.transport=n,this.request=o,this.eventHandlers=a,o.transaction=this;let t=`SIP/2.0/${n.via_transport}`;t+=` ${r.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t),this.ua.newTransaction(this)}get C(){return ae}stateChanged(r){this.state=r,this.emit("stateChanged")}send(){this.stateChanged(ae.STATUS_CALLING),this.B=setTimeout(()=>{this.timer_B()},Wt.TIMER_B),this.transport.send(this.request)||this.onTransportError()}onTransportError(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==ae.STATUS_ACCEPTED&&(Vl.debug(`transport error occurred, deleting transaction ${this.id}`),this.eventHandlers.onTransportError()),this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_M(){Vl.debug(`Timer M expired for transaction ${this.id}`),this.state===ae.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this))}timer_B(){Vl.debug(`Timer B expired for transaction ${this.id}`),this.state===ae.STATUS_CALLING&&(this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}timer_D(){Vl.debug(`Timer D expired for transaction ${this.id}`),clearTimeout(this.B),this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this)}sendACK(r){const n=new rf.OutgoingRequest(Nr.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",r.getHeader("to")),this.D=setTimeout(()=>{this.timer_D()},Wt.TIMER_D),this.transport.send(n)}cancel(r){if(this.state!==ae.STATUS_PROCEEDING)return;const n=new rf.OutgoingRequest(Nr.CANCEL,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",this.request.getHeader("to")),r&&n.setHeader("reason",r),this.transport.send(n)}receiveResponse(r){const n=r.status_code;if(n>=100&&n<=199)switch(this.state){case ae.STATUS_CALLING:this.stateChanged(ae.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(r);break;case ae.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(r);break}else if(n>=200&&n<=299)switch(this.state){case ae.STATUS_CALLING:case ae.STATUS_PROCEEDING:this.stateChanged(ae.STATUS_ACCEPTED),this.M=setTimeout(()=>{this.timer_M()},Wt.TIMER_M),this.eventHandlers.onReceiveResponse(r);break;case ae.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(r);break}else if(n>=300&&n<=699)switch(this.state){case ae.STATUS_CALLING:case ae.STATUS_PROCEEDING:this.stateChanged(ae.STATUS_COMPLETED),this.sendACK(r),this.eventHandlers.onReceiveResponse(r);break;case ae.STATUS_COMPLETED:this.sendACK(r);break}}}class Qp extends Or{constructor(r,n,o,a){super(),this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.transport=n,this.request=o,this.eventHandlers=a;let t=`SIP/2.0/${n.via_transport}`;t+=` ${r.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t)}get C(){return ae}send(){this.transport.send(this.request)||this.onTransportError()}onTransportError(){zp.debug(`transport error occurred for transaction ${this.id}`),this.eventHandlers.onTransportError()}}class Zp extends Or{constructor(r,n,o){super(),this.type=ae.NON_INVITE_SERVER,this.id=o.via_branch,this.ua=r,this.transport=n,this.request=o,this.last_response="",o.server_transaction=this,this.state=ae.STATUS_TRYING,r.newTransaction(this)}get C(){return ae}stateChanged(r){this.state=r,this.emit("stateChanged")}timer_J(){of.debug(`Timer J expired for transaction ${this.id}`),this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this)}onTransportError(){this.transportError||(this.transportError=!0,of.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.J),this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this))}receiveResponse(r,n,o,a){if(r===100)switch(this.state){case ae.STATUS_TRYING:this.stateChanged(ae.STATUS_PROCEEDING),this.transport.send(n)||this.onTransportError();break;case ae.STATUS_PROCEEDING:this.last_response=n,this.transport.send(n)?o&&o():(this.onTransportError(),a&&a());break}else if(r>=200&&r<=699)switch(this.state){case ae.STATUS_TRYING:case ae.STATUS_PROCEEDING:this.stateChanged(ae.STATUS_COMPLETED),this.last_response=n,this.J=setTimeout(()=>{this.timer_J()},Wt.TIMER_J),this.transport.send(n)?o&&o():(this.onTransportError(),a&&a());break;case ae.STATUS_COMPLETED:break}}}class em extends Or{constructor(r,n,o){super(),this.type=ae.INVITE_SERVER,this.id=o.via_branch,this.ua=r,this.transport=n,this.request=o,this.last_response="",o.server_transaction=this,this.state=ae.STATUS_PROCEEDING,r.newTransaction(this),this.resendProvisionalTimer=null,o.reply(100)}get C(){return ae}stateChanged(r){this.state=r,this.emit("stateChanged")}timer_H(){jl.debug(`Timer H expired for transaction ${this.id}`),this.state===ae.STATUS_COMPLETED&&jl.debug("ACK not received, dialog will be terminated"),this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_I(){this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_L(){jl.debug(`Timer L expired for transaction ${this.id}`),this.state===ae.STATUS_ACCEPTED&&(this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this))}onTransportError(){this.transportError||(this.transportError=!0,jl.debug(`transport error occurred, deleting transaction ${this.id}`),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),clearTimeout(this.L),clearTimeout(this.H),clearTimeout(this.I),this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this))}resend_provisional(){this.transport.send(this.last_response)||this.onTransportError()}receiveResponse(r,n,o,a){if(r>=100&&r<=199)switch(this.state){case ae.STATUS_PROCEEDING:this.transport.send(n)||this.onTransportError(),this.last_response=n;break}if(r>100&&r<=199&&this.state===ae.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(()=>{this.resend_provisional()},Wt.PROVISIONAL_RESPONSE_INTERVAL));else if(r>=200&&r<=299)switch(this.state){case ae.STATUS_PROCEEDING:this.stateChanged(ae.STATUS_ACCEPTED),this.last_response=n,this.L=setTimeout(()=>{this.timer_L()},Wt.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case ae.STATUS_ACCEPTED:this.transport.send(n)?o&&o():(this.onTransportError(),a&&a());break}else if(r>=300&&r<=699)switch(this.state){case ae.STATUS_PROCEEDING:this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(n)?(this.stateChanged(ae.STATUS_COMPLETED),this.H=setTimeout(()=>{this.timer_H()},Wt.TIMER_H),o&&o()):(this.onTransportError(),a&&a());break}}}function tm({_transactions:c},r){let n;switch(r.method){case Nr.INVITE:if(n=c.ist[r.via_branch],n){switch(n.state){case ae.STATUS_PROCEEDING:n.transport.send(n.last_response);break;case ae.STATUS_ACCEPTED:break}return!0}break;case Nr.ACK:if(n=c.ist[r.via_branch],n){if(n.state===ae.STATUS_ACCEPTED)return!1;if(n.state===ae.STATUS_COMPLETED)return n.state=ae.STATUS_CONFIRMED,n.I=setTimeout(()=>{n.timer_I()},Wt.TIMER_I),!0}else return!1;break;case Nr.CANCEL:return n=c.ist[r.via_branch],n?(r.reply_sl(200),n.state!==ae.STATUS_PROCEEDING):(r.reply_sl(481),!0);default:if(n=c.nist[r.via_branch],n){switch(n.state){case ae.STATUS_TRYING:break;case ae.STATUS_PROCEEDING:case ae.STATUS_COMPLETED:n.transport.send(n.last_response);break}return!0}break}}var An={C:ae,NonInviteClientTransaction:Jp,InviteClientTransaction:Xp,AckClientTransaction:Qp,NonInviteServerTransaction:Zp,InviteServerTransaction:em,checkTransaction:tm};const Ur=vt(An),sm=it,af=we,nm=tf,Aa=An,rm=new sm("RequestSender"),Ra={onRequestTimeout:()=>{},onTransportError:()=>{},onReceiveResponse:()=>{},onAuthenticated:()=>{}};var Rn=class{constructor(r,n,o){this._ua=r,this._eventHandlers=o,this._method=n.method,this._request=n,this._auth=null,this._challenged=!1,this._staled=!1;for(const a in Ra)Object.prototype.hasOwnProperty.call(Ra,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=Ra[a]));r.status===r.C.STATUS_USER_CLOSED&&(this._method!==af.BYE||this._method!==af.ACK)&&this._eventHandlers.onTransportError()}send(){const r={onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onReceiveResponse:n=>{this._receiveResponse(n)}};switch(this._method){case"INVITE":this.clientTransaction=new Aa.InviteClientTransaction(this._ua,this._ua.transport,this._request,r);break;case"ACK":this.clientTransaction=new Aa.AckClientTransaction(this._ua,this._ua.transport,this._request,r);break;default:this.clientTransaction=new Aa.NonInviteClientTransaction(this._ua,this._ua.transport,this._request,r)}this._ua._configuration.authorization_jwt&&this._request.setHeader("Authorization",this._ua._configuration.authorization_jwt),this.clientTransaction.send()}_receiveResponse(r){let n,o;const a=r.status_code;if((a===401||a===407)&&(this._ua.configuration.password!==null||this._ua.configuration.ha1!==null)){if(r.status_code===401?(n=r.parseHeader("www-authenticate"),o="authorization"):(n=r.parseHeader("proxy-authenticate"),o="proxy-authorization"),!n){rm.debug(`${r.status_code} with wrong or missing challenge, cannot authenticate`),this._eventHandlers.onReceiveResponse(r);return}if(!this._challenged||!this._staled&&n.stale===!0){if(this._auth||(this._auth=new nm({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,n)){this._eventHandlers.onReceiveResponse(r);return}this._challenged=!0,this._ua.set("realm",this._auth.get("realm")),this._ua.set("ha1",this._auth.get("ha1")),n.stale&&(this._staled=!0),this._request=this._request.clone(),this._request.cseq+=1,this._request.setHeader("cseq",`${this._request.cseq} ${this._method}`),this._request.setHeader(o,this._auth.toString()),this._eventHandlers.onAuthenticated(this._request),this.send()}else this._eventHandlers.onReceiveResponse(r)}else this._eventHandlers.onReceiveResponse(r)}};const im=vt(Rn),lm=it,Ia=ft(),Vs=we,uf=Kt,cf=Rn,Pr=new lm("Registrator"),Bl=10;var om=class{constructor(r,n){this._reg_id=1,this._ua=r,this._transport=n,this._registrar=r.configuration.registrar_server,this._expires=r.configuration.register_expires,this._call_id=Ia.createRandomToken(22),this._cseq=0,this._to_uri=r.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:${this._ua.configuration.instance_id}>"`,this._contact+=`;reg-id=${this._reg_id}`,this._contact+=`;+sip.instance=${this._sipInstance}`}get registered(){return this._registered}setExtraHeaders(r){Array.isArray(r)||(r=[]),this._extraHeaders=r.slice()}setExtraContactParams(r){r instanceof Object||(r={}),this._extraContactParams="";for(const n in r)if(Object.prototype.hasOwnProperty.call(r,n)){const o=r[n];this._extraContactParams+=`;${n}`,o&&(this._extraContactParams+=`=${o}`)}}register(){if(this._registering){Pr.debug("Register request in progress...");return}const r=this._extraHeaders.slice();r.push(`Contact: ${this._contact};expires=${this._expires}${this._extraContactParams}`),r.push(`Expires: ${this._expires}`);const n=new uf.OutgoingRequest(Vs.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},r),o=new cf(this._ua,n,{onRequestTimeout:()=>{this._registrationFailure(null,Vs.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._registrationFailure(null,Vs.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:a=>{if(a.cseq===this._cseq)switch(this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(a.status_code):break;case/^2[0-9]{2}$/.test(a.status_code):{if(this._registering=!1,!a.hasHeader("Contact")){Pr.debug("no Contact header in response to REGISTER, response ignored");break}const t=a.headers.Contact.reduce((d,g)=>d.concat(g.parsed),[]);let s=t.find(d=>this._sipInstance===d.getParam("+sip.instance")&&this._reg_id===parseInt(d.getParam("reg-id")));if(s||(s=t.find(d=>d.uri.user===this._ua.contact.uri.user)),!s){Pr.debug("no Contact header pointing to us, response ignored");break}let p=s.getParam("expires");!p&&a.hasHeader("expires")&&(p=a.getHeader("expires")),p||(p=this._expires),p=Number(p),p<Bl&&(p=Bl);const h=p>64?p*1e3/2+Math.floor((p/2-32)*1e3*Math.random()):p*1e3-5e3;this._registrationTimer=setTimeout(()=>{this._registrationTimer=null,this._ua.listeners("registrationExpiring").length===0?this.register():this._ua.emit("registrationExpiring")},h),s.hasParam("temp-gruu")&&(this._ua.contact.temp_gruu=s.getParam("temp-gruu").replace(/"/g,"")),s.hasParam("pub-gruu")&&(this._ua.contact.pub_gruu=s.getParam("pub-gruu").replace(/"/g,"")),this._registered||(this._registered=!0,this._ua.registered({response:a}));break}case/^423$/.test(a.status_code):{a.hasHeader("min-expires")?(this._expires=Number(a.getHeader("min-expires")),this._expires<Bl&&(this._expires=Bl),this.register()):(Pr.debug("423 response received for REGISTER without Min-Expires"),this._registrationFailure(a,Vs.causes.SIP_FAILURE_CODE));break}default:{const t=Ia.sipErrorCause(a.status_code);this._registrationFailure(a,t)}}}});this._registering=!0,o.send()}unregister(r={}){if(!this._registered){Pr.debug("already unregistered");return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);const n=this._extraHeaders.slice();r.all?n.push(`Contact: *${this._extraContactParams}`):n.push(`Contact: ${this._contact};expires=0${this._extraContactParams}`),n.push("Expires: 0");const o=new uf.OutgoingRequest(Vs.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},n);new cf(this._ua,o,{onRequestTimeout:()=>{this._unregistered(null,Vs.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._unregistered(null,Vs.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:t=>{switch(!0){case/^1[0-9]{2}$/.test(t.status_code):break;case/^2[0-9]{2}$/.test(t.status_code):this._unregistered(t);break;default:{const s=Ia.sipErrorCause(t.status_code);this._unregistered(t,s)}}}}).send()}close(){this._registered&&this.unregister()}onTransportClosed(){this._registering=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),this._registered&&(this._registered=!1,this._ua.unregistered({}))}_registrationFailure(r,n){this._registering=!1,this._ua.registrationFailed({response:r||null,cause:n}),this._registered&&(this._registered=!1,this._ua.unregistered({response:r||null,cause:n}))}_unregistered(r,n){this._registering=!1,this._registered=!1,this._ua.unregistered({response:r||null,cause:n||null})}};class am extends Error{constructor(r,n){super(),this.code=1,this.name="CONFIGURATION_ERROR",this.parameter=r,this.value=n,this.message=this.value?`Invalid value ${JSON.stringify(this.value)} for parameter "${this.parameter}"`:`Missing parameter: ${this.parameter}`}}class um extends Error{constructor(r){super(),this.code=2,this.name="INVALID_STATE_ERROR",this.status=r,this.message=`Invalid status: ${r}`}}class cm extends Error{constructor(r){super(),this.code=3,this.name="NOT_SUPPORTED_ERROR",this.message=r}}class fm extends Error{constructor(r){super(),this.code=4,this.name="NOT_READY_ERROR",this.message=r}}var as={ConfigurationError:am,InvalidStateError:um,NotSupportedError:cm,NotReadyError:fm};const hm=vt(as),ba=we,Gl=An,_m=Rn,wa={onRequestTimeout:()=>{},onTransportError:()=>{},onSuccessResponse:()=>{},onErrorResponse:()=>{},onAuthenticated:()=>{},onDialogError:()=>{}};var dm=class{constructor(r,n,o){this._dialog=r,this._ua=r._ua,this._request=n,this._eventHandlers=o,this._reattempt=!1,this._reattemptTimer=null;for(const a in wa)Object.prototype.hasOwnProperty.call(wa,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=wa[a]))}get request(){return this._request}send(){const r=new _m(this._ua,this._request,{onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onAuthenticated:n=>{this._eventHandlers.onAuthenticated(n)},onReceiveResponse:n=>{this._receiveResponse(n)}});if(r.send(),(this._request.method===ba.INVITE||this._request.method===ba.UPDATE&&this._request.body)&&r.clientTransaction.state!==Gl.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;const n=()=>{(r.clientTransaction.state===Gl.C.STATUS_ACCEPTED||r.clientTransaction.state===Gl.C.STATUS_COMPLETED||r.clientTransaction.state===Gl.C.STATUS_TERMINATED)&&(r.clientTransaction.removeListener("stateChanged",n),this._dialog.uac_pending_reply=!1)};r.clientTransaction.on("stateChanged",n)}}_receiveResponse(r){r.status_code===408||r.status_code===481?this._eventHandlers.onDialogError(r):r.method===ba.INVITE&&r.status_code===491?this._reattempt?r.status_code>=200&&r.status_code<300?this._eventHandlers.onSuccessResponse(r):r.status_code>=300&&this._eventHandlers.onErrorResponse(r):(this._request.cseq=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout(()=>{this._dialog.isTerminated()||(this._reattempt=!0,this.send())},1e3)):r.status_code>=200&&r.status_code<300?this._eventHandlers.onSuccessResponse(r):r.status_code>=300&&this._eventHandlers.onErrorResponse(r)}};const pm=it,ff=Kt,Es=we,kr=An,mm=dm,Oa=ft(),Da=new pm("Dialog"),ys={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};var hf=class{static get C(){return ys}constructor(r,n,o,a=ys.STATUS_CONFIRMED){if(this._owner=r,this._ua=r._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 ff.IncomingResponse&&(a=n.status_code<200?ys.STATUS_EARLY:ys.STATUS_CONFIRMED);const t=n.parseHeader("contact");o==="UAS"?(this._id={call_id:n.call_id,local_tag:n.to_tag,remote_tag:n.from_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._remote_seqnum=n.cseq,this._local_uri=n.parseHeader("to").uri,this._remote_uri=n.parseHeader("from").uri,this._remote_target=t.uri,this._route_set=n.getHeaders("record-route"),this._ack_seqnum=this._remote_seqnum):o==="UAC"&&(this._id={call_id:n.call_id,local_tag:n.from_tag,remote_tag:n.to_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._local_seqnum=n.cseq,this._local_uri=n.parseHeader("from").uri,this._remote_uri=n.parseHeader("to").uri,this._remote_target=t.uri,this._route_set=n.getHeaders("record-route").reverse(),this._ack_seqnum=null),this._ua.newDialog(this),Da.debug(`new ${o} dialog created with status ${this._state===ys.STATUS_EARLY?"EARLY":"CONFIRMED"}`)}get id(){return this._id}get local_seqnum(){return this._local_seqnum}set local_seqnum(r){this._local_seqnum=r}get owner(){return this._owner}get uac_pending_reply(){return this._uac_pending_reply}set uac_pending_reply(r){this._uac_pending_reply=r}get uas_pending_reply(){return this._uas_pending_reply}isTerminated(){return this._status===ys.STATUS_TERMINATED}update(r,n){this._state=ys.STATUS_CONFIRMED,Da.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),n==="UAC"&&(this._route_set=r.getHeaders("record-route").reverse())}terminate(){Da.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=ys.STATUS_TERMINATED}sendRequest(r,n={}){const o=Oa.cloneArray(n.extraHeaders),a=Oa.cloneObject(n.eventHandlers),t=n.body||null,s=this._createRequest(r,o,t);return a.onAuthenticated=()=>{this._local_seqnum+=1},new mm(this,s,a).send(),s}receiveRequest(r){this._checkInDialogRequest(r)&&(r.method===Es.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:r.method===Es.INVITE&&(this._ack_seqnum=r.cseq),this._owner.receiveRequest(r))}_createRequest(r,n,o){n=Oa.cloneArray(n),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));const a=r===Es.CANCEL||r===Es.ACK?this._local_seqnum:this._local_seqnum+=1;return new ff.OutgoingRequest(r,this._remote_target,this._ua,{cseq:a,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},n,o)}_checkInDialogRequest(r){if(!this._remote_seqnum)this._remote_seqnum=r.cseq;else if(r.cseq<this._remote_seqnum)if(r.method===Es.ACK){if(this._ack_seqnum===null||r.cseq!==this._ack_seqnum)return!1}else return r.reply(500),!1;else r.cseq>this._remote_seqnum&&(this._remote_seqnum=r.cseq);if(r.method===Es.INVITE||r.method===Es.UPDATE&&r.body){if(this._uac_pending_reply===!0)r.reply(491);else if(this._uas_pending_reply===!0){const n=(Math.random()*10|0)+1;return r.reply(500,null,[`Retry-After:${n}`]),!1}else{this._uas_pending_reply=!0;const n=()=>{(r.server_transaction.state===kr.C.STATUS_ACCEPTED||r.server_transaction.state===kr.C.STATUS_COMPLETED||r.server_transaction.state===kr.C.STATUS_TERMINATED)&&(r.server_transaction.removeListener("stateChanged",n),this._uas_pending_reply=!1)};r.server_transaction.on("stateChanged",n)}r.hasHeader("contact")&&r.server_transaction.on("stateChanged",()=>{r.server_transaction.state===kr.C.STATUS_ACCEPTED&&(this._remote_target=r.parseHeader("contact").uri)})}else r.method===Es.NOTIFY&&r.hasHeader("contact")&&r.server_transaction.on("stateChanged",()=>{r.server_transaction.state===kr.C.STATUS_COMPLETED&&(this._remote_target=r.parseHeader("contact").uri)});return!0}};const Kl=vt(hf);var Na={exports:{}};const gm=ot.EventEmitter,vm=it,Tm=we,Em=as,_f=ft(),ym=new vm("RTCSession:DTMF"),df={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};Na.exports=class extends gm{constructor(r){super(),this._session=r,this._direction=null,this._tone=null,this._duration=null,this._request=null}get tone(){return this._tone}get duration(){return this._duration}send(r,n={}){if(r===void 0)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 Em.InvalidStateError(this._session.status);const o=_f.cloneArray(n.extraHeaders);if(this.eventHandlers=_f.cloneObject(n.eventHandlers),typeof r=="string")r=r.toUpperCase();else if(typeof r=="number")r=r.toString();else throw new TypeError(`Invalid tone: ${r}`);if(r.match(/^[0-9A-DR#*]$/))this._tone=r;else throw new TypeError(`Invalid tone: ${r}`);this._duration=n.duration,o.push("Content-Type: application/dtmf-relay");let a=`Signal=${this._tone}\r
|
112
|
+
`,this.transport.send(a)}}class Gp extends ef{constructor(){super(),this.headers={},this.status_code=null,this.reason_phrase=null}}var Kt={OutgoingRequest:ql,InitialOutgoingInviteRequest:Ca,IncomingRequest:Bp,IncomingResponse:Gp};const Kp=it,os=ft(),Ht=new Kp("DigestAuthentication");var tf=class{constructor(r){this._credentials=r,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}get(r){switch(r){case"realm":return this._realm;case"ha1":return this._ha1;default:Ht.warn('get() | cannot get "%s" parameter',r);return}}authenticate({method:r,ruri:n,body:o},a,t=null){if(this._algorithm=a.algorithm,this._realm=a.realm,this._nonce=a.nonce,this._opaque=a.opaque,this._stale=a.stale,this._algorithm){if(this._algorithm!=="MD5")return Ht.warn('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted'),!1}else this._algorithm="MD5";if(!this._nonce)return Ht.warn("authenticate() | challenge without Digest nonce, authentication aborted"),!1;if(!this._realm)return Ht.warn("authenticate() | challenge without Digest realm, authentication aborted"),!1;if(!this._credentials.password){if(!this._credentials.ha1)return Ht.warn("authenticate() | no plain SIP password nor ha1 provided, authentication aborted"),!1;if(this._credentials.realm!==this._realm)return Ht.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(a.qop)if(a.qop.indexOf("auth-int")>-1)this._qop="auth-int";else if(a.qop.indexOf("auth")>-1)this._qop="auth";else return Ht.warn('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted'),!1;else this._qop=null;this._method=r,this._uri=n,this._cnonce=t||os.createRandomToken(12),this._nc+=1;const s=Number(this._nc).toString(16);this._ncHex="00000000".substr(0,8-s.length)+s,this._nc===4294967296&&(this._nc=1,this._ncHex="00000001"),this._credentials.password?this._ha1=os.calculateMD5(`${this._credentials.username}:${this._realm}:${this._credentials.password}`):this._ha1=this._credentials.ha1;let p,h;return this._qop==="auth"?(p=`${this._method}:${this._uri}`,h=os.calculateMD5(p),Ht.debug('authenticate() | using qop=auth [a2:"%s"]',p),this._response=os.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth:${h}`)):this._qop==="auth-int"?(p=`${this._method}:${this._uri}:${os.calculateMD5(o||"")}`,h=os.calculateMD5(p),Ht.debug('authenticate() | using qop=auth-int [a2:"%s"]',p),this._response=os.calculateMD5(`${this._ha1}:${this._nonce}:${this._ncHex}:${this._cnonce}:auth-int:${h}`)):this._qop===null&&(p=`${this._method}:${this._uri}`,h=os.calculateMD5(p),Ht.debug('authenticate() | using qop=null [a2:"%s"]',p),this._response=os.calculateMD5(`${this._ha1}:${this._nonce}:${h}`)),Ht.debug("authenticate() | response generated"),!0}toString(){const r=[];if(!this._response)throw new Error("response field does not exist, cannot generate Authorization header");return r.push(`algorithm=${this._algorithm}`),r.push(`username="${this._credentials.username}"`),r.push(`realm="${this._realm}"`),r.push(`nonce="${this._nonce}"`),r.push(`uri="${this._uri}"`),r.push(`response="${this._response}"`),this._opaque&&r.push(`opaque="${this._opaque}"`),this._qop&&(r.push(`qop=${this._qop}`),r.push(`cnonce="${this._cnonce}"`),r.push(`nc=${this._ncHex}`)),`Digest ${r.join(", ")}`}};const Wp=vt(tf),as=500,Yp=4e3,sf=5e3;var nf={T1:as,T2:Yp,T4:sf,TIMER_B:64*as,TIMER_D:0*as,TIMER_F:64*as,TIMER_H:64*as,TIMER_I:0*as,TIMER_J:0*as,TIMER_K:0*sf,TIMER_L:64*as,TIMER_M:64*as,PROVISIONAL_RESPONSE_INTERVAL:6e4};const Or=ot.EventEmitter,Dr=it,Nr=we,rf=Kt,Wt=nf,lf=new Dr("NonInviteClientTransaction"),Vl=new Dr("InviteClientTransaction"),zp=new Dr("AckClientTransaction"),of=new Dr("NonInviteServerTransaction"),jl=new Dr("InviteServerTransaction"),ae={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"};class Jp extends Or{constructor(r,n,o,a){super(),this.type=ae.NON_INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=r,this.transport=n,this.request=o,this.eventHandlers=a;let t=`SIP/2.0/${n.via_transport}`;t+=` ${r.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t),this.ua.newTransaction(this)}get C(){return ae}stateChanged(r){this.state=r,this.emit("stateChanged")}send(){this.stateChanged(ae.STATUS_TRYING),this.F=setTimeout(()=>{this.timer_F()},Wt.TIMER_F),this.transport.send(this.request)||this.onTransportError()}onTransportError(){lf.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.F),clearTimeout(this.K),this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onTransportError()}timer_F(){lf.debug(`Timer F expired for transaction ${this.id}`),this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout()}timer_K(){this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this)}receiveResponse(r){const n=r.status_code;if(n<200)switch(this.state){case ae.STATUS_TRYING:case ae.STATUS_PROCEEDING:this.stateChanged(ae.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(r);break}else switch(this.state){case ae.STATUS_TRYING:case ae.STATUS_PROCEEDING:this.stateChanged(ae.STATUS_COMPLETED),clearTimeout(this.F),n===408?this.eventHandlers.onRequestTimeout():this.eventHandlers.onReceiveResponse(r),this.K=setTimeout(()=>{this.timer_K()},Wt.TIMER_K);break;case ae.STATUS_COMPLETED:break}}}class Xp extends Or{constructor(r,n,o,a){super(),this.type=ae.INVITE_CLIENT,this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.ua=r,this.transport=n,this.request=o,this.eventHandlers=a,o.transaction=this;let t=`SIP/2.0/${n.via_transport}`;t+=` ${r.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t),this.ua.newTransaction(this)}get C(){return ae}stateChanged(r){this.state=r,this.emit("stateChanged")}send(){this.stateChanged(ae.STATUS_CALLING),this.B=setTimeout(()=>{this.timer_B()},Wt.TIMER_B),this.transport.send(this.request)||this.onTransportError()}onTransportError(){clearTimeout(this.B),clearTimeout(this.D),clearTimeout(this.M),this.state!==ae.STATUS_ACCEPTED&&(Vl.debug(`transport error occurred, deleting transaction ${this.id}`),this.eventHandlers.onTransportError()),this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_M(){Vl.debug(`Timer M expired for transaction ${this.id}`),this.state===ae.STATUS_ACCEPTED&&(clearTimeout(this.B),this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this))}timer_B(){Vl.debug(`Timer B expired for transaction ${this.id}`),this.state===ae.STATUS_CALLING&&(this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this),this.eventHandlers.onRequestTimeout())}timer_D(){Vl.debug(`Timer D expired for transaction ${this.id}`),clearTimeout(this.B),this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this)}sendACK(r){const n=new rf.OutgoingRequest(Nr.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",r.getHeader("to")),this.D=setTimeout(()=>{this.timer_D()},Wt.TIMER_D),this.transport.send(n)}cancel(r){if(this.state!==ae.STATUS_PROCEEDING)return;const n=new rf.OutgoingRequest(Nr.CANCEL,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",this.request.getHeader("to")),r&&n.setHeader("reason",r),this.transport.send(n)}receiveResponse(r){const n=r.status_code;if(n>=100&&n<=199)switch(this.state){case ae.STATUS_CALLING:this.stateChanged(ae.STATUS_PROCEEDING),this.eventHandlers.onReceiveResponse(r);break;case ae.STATUS_PROCEEDING:this.eventHandlers.onReceiveResponse(r);break}else if(n>=200&&n<=299)switch(this.state){case ae.STATUS_CALLING:case ae.STATUS_PROCEEDING:this.stateChanged(ae.STATUS_ACCEPTED),this.M=setTimeout(()=>{this.timer_M()},Wt.TIMER_M),this.eventHandlers.onReceiveResponse(r);break;case ae.STATUS_ACCEPTED:this.eventHandlers.onReceiveResponse(r);break}else if(n>=300&&n<=699)switch(this.state){case ae.STATUS_CALLING:case ae.STATUS_PROCEEDING:this.stateChanged(ae.STATUS_COMPLETED),this.sendACK(r),this.eventHandlers.onReceiveResponse(r);break;case ae.STATUS_COMPLETED:this.sendACK(r);break}}}class Qp extends Or{constructor(r,n,o,a){super(),this.id=`z9hG4bK${Math.floor(Math.random()*1e7)}`,this.transport=n,this.request=o,this.eventHandlers=a;let t=`SIP/2.0/${n.via_transport}`;t+=` ${r.configuration.via_host};branch=${this.id}`,this.request.setHeader("via",t)}get C(){return ae}send(){this.transport.send(this.request)||this.onTransportError()}onTransportError(){zp.debug(`transport error occurred for transaction ${this.id}`),this.eventHandlers.onTransportError()}}class Zp extends Or{constructor(r,n,o){super(),this.type=ae.NON_INVITE_SERVER,this.id=o.via_branch,this.ua=r,this.transport=n,this.request=o,this.last_response="",o.server_transaction=this,this.state=ae.STATUS_TRYING,r.newTransaction(this)}get C(){return ae}stateChanged(r){this.state=r,this.emit("stateChanged")}timer_J(){of.debug(`Timer J expired for transaction ${this.id}`),this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this)}onTransportError(){this.transportError||(this.transportError=!0,of.debug(`transport error occurred, deleting transaction ${this.id}`),clearTimeout(this.J),this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this))}receiveResponse(r,n,o,a){if(r===100)switch(this.state){case ae.STATUS_TRYING:this.stateChanged(ae.STATUS_PROCEEDING),this.transport.send(n)||this.onTransportError();break;case ae.STATUS_PROCEEDING:this.last_response=n,this.transport.send(n)?o&&o():(this.onTransportError(),a&&a());break}else if(r>=200&&r<=699)switch(this.state){case ae.STATUS_TRYING:case ae.STATUS_PROCEEDING:this.stateChanged(ae.STATUS_COMPLETED),this.last_response=n,this.J=setTimeout(()=>{this.timer_J()},Wt.TIMER_J),this.transport.send(n)?o&&o():(this.onTransportError(),a&&a());break;case ae.STATUS_COMPLETED:break}}}class em extends Or{constructor(r,n,o){super(),this.type=ae.INVITE_SERVER,this.id=o.via_branch,this.ua=r,this.transport=n,this.request=o,this.last_response="",o.server_transaction=this,this.state=ae.STATUS_PROCEEDING,r.newTransaction(this),this.resendProvisionalTimer=null,o.reply(100)}get C(){return ae}stateChanged(r){this.state=r,this.emit("stateChanged")}timer_H(){jl.debug(`Timer H expired for transaction ${this.id}`),this.state===ae.STATUS_COMPLETED&&jl.debug("ACK not received, dialog will be terminated"),this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_I(){this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this)}timer_L(){jl.debug(`Timer L expired for transaction ${this.id}`),this.state===ae.STATUS_ACCEPTED&&(this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this))}onTransportError(){this.transportError||(this.transportError=!0,jl.debug(`transport error occurred, deleting transaction ${this.id}`),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),clearTimeout(this.L),clearTimeout(this.H),clearTimeout(this.I),this.stateChanged(ae.STATUS_TERMINATED),this.ua.destroyTransaction(this))}resend_provisional(){this.transport.send(this.last_response)||this.onTransportError()}receiveResponse(r,n,o,a){if(r>=100&&r<=199)switch(this.state){case ae.STATUS_PROCEEDING:this.transport.send(n)||this.onTransportError(),this.last_response=n;break}if(r>100&&r<=199&&this.state===ae.STATUS_PROCEEDING)this.resendProvisionalTimer===null&&(this.resendProvisionalTimer=setInterval(()=>{this.resend_provisional()},Wt.PROVISIONAL_RESPONSE_INTERVAL));else if(r>=200&&r<=299)switch(this.state){case ae.STATUS_PROCEEDING:this.stateChanged(ae.STATUS_ACCEPTED),this.last_response=n,this.L=setTimeout(()=>{this.timer_L()},Wt.TIMER_L),this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null);case ae.STATUS_ACCEPTED:this.transport.send(n)?o&&o():(this.onTransportError(),a&&a());break}else if(r>=300&&r<=699)switch(this.state){case ae.STATUS_PROCEEDING:this.resendProvisionalTimer!==null&&(clearInterval(this.resendProvisionalTimer),this.resendProvisionalTimer=null),this.transport.send(n)?(this.stateChanged(ae.STATUS_COMPLETED),this.H=setTimeout(()=>{this.timer_H()},Wt.TIMER_H),o&&o()):(this.onTransportError(),a&&a());break}}}function tm({_transactions:c},r){let n;switch(r.method){case Nr.INVITE:if(n=c.ist[r.via_branch],n){switch(n.state){case ae.STATUS_PROCEEDING:n.transport.send(n.last_response);break;case ae.STATUS_ACCEPTED:break}return!0}break;case Nr.ACK:if(n=c.ist[r.via_branch],n){if(n.state===ae.STATUS_ACCEPTED)return!1;if(n.state===ae.STATUS_COMPLETED)return n.state=ae.STATUS_CONFIRMED,n.I=setTimeout(()=>{n.timer_I()},Wt.TIMER_I),!0}else return!1;break;case Nr.CANCEL:return n=c.ist[r.via_branch],n?(r.reply_sl(200),n.state!==ae.STATUS_PROCEEDING):(r.reply_sl(481),!0);default:if(n=c.nist[r.via_branch],n){switch(n.state){case ae.STATUS_TRYING:break;case ae.STATUS_PROCEEDING:case ae.STATUS_COMPLETED:n.transport.send(n.last_response);break}return!0}break}}var An={C:ae,NonInviteClientTransaction:Jp,InviteClientTransaction:Xp,AckClientTransaction:Qp,NonInviteServerTransaction:Zp,InviteServerTransaction:em,checkTransaction:tm};const Ur=vt(An),sm=it,af=we,nm=tf,Aa=An,rm=new sm("RequestSender"),Ra={onRequestTimeout:()=>{},onTransportError:()=>{},onReceiveResponse:()=>{},onAuthenticated:()=>{}};var Rn=class{constructor(r,n,o){this._ua=r,this._eventHandlers=o,this._method=n.method,this._request=n,this._auth=null,this._challenged=!1,this._staled=!1;for(const a in Ra)Object.prototype.hasOwnProperty.call(Ra,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=Ra[a]));r.status===r.C.STATUS_USER_CLOSED&&(this._method!==af.BYE||this._method!==af.ACK)&&this._eventHandlers.onTransportError()}send(){const r={onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onReceiveResponse:n=>{this._receiveResponse(n)}};switch(this._method){case"INVITE":this.clientTransaction=new Aa.InviteClientTransaction(this._ua,this._ua.transport,this._request,r);break;case"ACK":this.clientTransaction=new Aa.AckClientTransaction(this._ua,this._ua.transport,this._request,r);break;default:this.clientTransaction=new Aa.NonInviteClientTransaction(this._ua,this._ua.transport,this._request,r)}this._ua._configuration.authorization_jwt&&this._request.setHeader("Authorization",this._ua._configuration.authorization_jwt),this.clientTransaction.send()}_receiveResponse(r){let n,o;const a=r.status_code;if((a===401||a===407)&&(this._ua.configuration.password!==null||this._ua.configuration.ha1!==null)){if(r.status_code===401?(n=r.parseHeader("www-authenticate"),o="authorization"):(n=r.parseHeader("proxy-authenticate"),o="proxy-authorization"),!n){rm.debug(`${r.status_code} with wrong or missing challenge, cannot authenticate`),this._eventHandlers.onReceiveResponse(r);return}if(!this._challenged||!this._staled&&n.stale===!0){if(this._auth||(this._auth=new nm({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,n)){this._eventHandlers.onReceiveResponse(r);return}this._challenged=!0,this._ua.set("realm",this._auth.get("realm")),this._ua.set("ha1",this._auth.get("ha1")),n.stale&&(this._staled=!0),this._request=this._request.clone(),this._request.cseq+=1,this._request.setHeader("cseq",`${this._request.cseq} ${this._method}`),this._request.setHeader(o,this._auth.toString()),this._eventHandlers.onAuthenticated(this._request),this.send()}else this._eventHandlers.onReceiveResponse(r)}else this._eventHandlers.onReceiveResponse(r)}};const im=vt(Rn),lm=it,Ia=ft(),js=we,uf=Kt,cf=Rn,Pr=new lm("Registrator"),Bl=10;var om=class{constructor(r,n){this._reg_id=1,this._ua=r,this._transport=n,this._registrar=r.configuration.registrar_server,this._expires=r.configuration.register_expires,this._call_id=Ia.createRandomToken(22),this._cseq=0,this._to_uri=r.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:${this._ua.configuration.instance_id}>"`,this._contact+=`;reg-id=${this._reg_id}`,this._contact+=`;+sip.instance=${this._sipInstance}`}get registered(){return this._registered}setExtraHeaders(r){Array.isArray(r)||(r=[]),this._extraHeaders=r.slice()}setExtraContactParams(r){r instanceof Object||(r={}),this._extraContactParams="";for(const n in r)if(Object.prototype.hasOwnProperty.call(r,n)){const o=r[n];this._extraContactParams+=`;${n}`,o&&(this._extraContactParams+=`=${o}`)}}register(){if(this._registering){Pr.debug("Register request in progress...");return}const r=this._extraHeaders.slice();r.push(`Contact: ${this._contact};expires=${this._expires}${this._extraContactParams}`),r.push(`Expires: ${this._expires}`);const n=new uf.OutgoingRequest(js.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},r),o=new cf(this._ua,n,{onRequestTimeout:()=>{this._registrationFailure(null,js.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._registrationFailure(null,js.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:a=>{if(a.cseq===this._cseq)switch(this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),!0){case/^1[0-9]{2}$/.test(a.status_code):break;case/^2[0-9]{2}$/.test(a.status_code):{if(this._registering=!1,!a.hasHeader("Contact")){Pr.debug("no Contact header in response to REGISTER, response ignored");break}const t=a.headers.Contact.reduce((d,g)=>d.concat(g.parsed),[]);let s=t.find(d=>this._sipInstance===d.getParam("+sip.instance")&&this._reg_id===parseInt(d.getParam("reg-id")));if(s||(s=t.find(d=>d.uri.user===this._ua.contact.uri.user)),!s){Pr.debug("no Contact header pointing to us, response ignored");break}let p=s.getParam("expires");!p&&a.hasHeader("expires")&&(p=a.getHeader("expires")),p||(p=this._expires),p=Number(p),p<Bl&&(p=Bl);const h=p>64?p*1e3/2+Math.floor((p/2-32)*1e3*Math.random()):p*1e3-5e3;this._registrationTimer=setTimeout(()=>{this._registrationTimer=null,this._ua.listeners("registrationExpiring").length===0?this.register():this._ua.emit("registrationExpiring")},h),s.hasParam("temp-gruu")&&(this._ua.contact.temp_gruu=s.getParam("temp-gruu").replace(/"/g,"")),s.hasParam("pub-gruu")&&(this._ua.contact.pub_gruu=s.getParam("pub-gruu").replace(/"/g,"")),this._registered||(this._registered=!0,this._ua.registered({response:a}));break}case/^423$/.test(a.status_code):{a.hasHeader("min-expires")?(this._expires=Number(a.getHeader("min-expires")),this._expires<Bl&&(this._expires=Bl),this.register()):(Pr.debug("423 response received for REGISTER without Min-Expires"),this._registrationFailure(a,js.causes.SIP_FAILURE_CODE));break}default:{const t=Ia.sipErrorCause(a.status_code);this._registrationFailure(a,t)}}}});this._registering=!0,o.send()}unregister(r={}){if(!this._registered){Pr.debug("already unregistered");return}this._registered=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null);const n=this._extraHeaders.slice();r.all?n.push(`Contact: *${this._extraContactParams}`):n.push(`Contact: ${this._contact};expires=0${this._extraContactParams}`),n.push("Expires: 0");const o=new uf.OutgoingRequest(js.REGISTER,this._registrar,this._ua,{to_uri:this._to_uri,call_id:this._call_id,cseq:this._cseq+=1},n);new cf(this._ua,o,{onRequestTimeout:()=>{this._unregistered(null,js.causes.REQUEST_TIMEOUT)},onTransportError:()=>{this._unregistered(null,js.causes.CONNECTION_ERROR)},onAuthenticated:()=>{this._cseq+=1},onReceiveResponse:t=>{switch(!0){case/^1[0-9]{2}$/.test(t.status_code):break;case/^2[0-9]{2}$/.test(t.status_code):this._unregistered(t);break;default:{const s=Ia.sipErrorCause(t.status_code);this._unregistered(t,s)}}}}).send()}close(){this._registered&&this.unregister()}onTransportClosed(){this._registering=!1,this._registrationTimer!==null&&(clearTimeout(this._registrationTimer),this._registrationTimer=null),this._registered&&(this._registered=!1,this._ua.unregistered({}))}_registrationFailure(r,n){this._registering=!1,this._ua.registrationFailed({response:r||null,cause:n}),this._registered&&(this._registered=!1,this._ua.unregistered({response:r||null,cause:n}))}_unregistered(r,n){this._registering=!1,this._registered=!1,this._ua.unregistered({response:r||null,cause:n||null})}};class am extends Error{constructor(r,n){super(),this.code=1,this.name="CONFIGURATION_ERROR",this.parameter=r,this.value=n,this.message=this.value?`Invalid value ${JSON.stringify(this.value)} for parameter "${this.parameter}"`:`Missing parameter: ${this.parameter}`}}class um extends Error{constructor(r){super(),this.code=2,this.name="INVALID_STATE_ERROR",this.status=r,this.message=`Invalid status: ${r}`}}class cm extends Error{constructor(r){super(),this.code=3,this.name="NOT_SUPPORTED_ERROR",this.message=r}}class fm extends Error{constructor(r){super(),this.code=4,this.name="NOT_READY_ERROR",this.message=r}}var us={ConfigurationError:am,InvalidStateError:um,NotSupportedError:cm,NotReadyError:fm};const hm=vt(us),ba=we,Gl=An,_m=Rn,wa={onRequestTimeout:()=>{},onTransportError:()=>{},onSuccessResponse:()=>{},onErrorResponse:()=>{},onAuthenticated:()=>{},onDialogError:()=>{}};var dm=class{constructor(r,n,o){this._dialog=r,this._ua=r._ua,this._request=n,this._eventHandlers=o,this._reattempt=!1,this._reattemptTimer=null;for(const a in wa)Object.prototype.hasOwnProperty.call(wa,a)&&(this._eventHandlers[a]||(this._eventHandlers[a]=wa[a]))}get request(){return this._request}send(){const r=new _m(this._ua,this._request,{onRequestTimeout:()=>{this._eventHandlers.onRequestTimeout()},onTransportError:()=>{this._eventHandlers.onTransportError()},onAuthenticated:n=>{this._eventHandlers.onAuthenticated(n)},onReceiveResponse:n=>{this._receiveResponse(n)}});if(r.send(),(this._request.method===ba.INVITE||this._request.method===ba.UPDATE&&this._request.body)&&r.clientTransaction.state!==Gl.C.STATUS_TERMINATED){this._dialog.uac_pending_reply=!0;const n=()=>{(r.clientTransaction.state===Gl.C.STATUS_ACCEPTED||r.clientTransaction.state===Gl.C.STATUS_COMPLETED||r.clientTransaction.state===Gl.C.STATUS_TERMINATED)&&(r.clientTransaction.removeListener("stateChanged",n),this._dialog.uac_pending_reply=!1)};r.clientTransaction.on("stateChanged",n)}}_receiveResponse(r){r.status_code===408||r.status_code===481?this._eventHandlers.onDialogError(r):r.method===ba.INVITE&&r.status_code===491?this._reattempt?r.status_code>=200&&r.status_code<300?this._eventHandlers.onSuccessResponse(r):r.status_code>=300&&this._eventHandlers.onErrorResponse(r):(this._request.cseq=this._dialog.local_seqnum+=1,this._reattemptTimer=setTimeout(()=>{this._dialog.isTerminated()||(this._reattempt=!0,this.send())},1e3)):r.status_code>=200&&r.status_code<300?this._eventHandlers.onSuccessResponse(r):r.status_code>=300&&this._eventHandlers.onErrorResponse(r)}};const pm=it,ff=Kt,ys=we,kr=An,mm=dm,Oa=ft(),Da=new pm("Dialog"),Ss={STATUS_EARLY:1,STATUS_CONFIRMED:2,STATUS_TERMINATED:3};var hf=class{static get C(){return Ss}constructor(r,n,o,a=Ss.STATUS_CONFIRMED){if(this._owner=r,this._ua=r._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 ff.IncomingResponse&&(a=n.status_code<200?Ss.STATUS_EARLY:Ss.STATUS_CONFIRMED);const t=n.parseHeader("contact");o==="UAS"?(this._id={call_id:n.call_id,local_tag:n.to_tag,remote_tag:n.from_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._remote_seqnum=n.cseq,this._local_uri=n.parseHeader("to").uri,this._remote_uri=n.parseHeader("from").uri,this._remote_target=t.uri,this._route_set=n.getHeaders("record-route"),this._ack_seqnum=this._remote_seqnum):o==="UAC"&&(this._id={call_id:n.call_id,local_tag:n.from_tag,remote_tag:n.to_tag,toString(){return this.call_id+this.local_tag+this.remote_tag}},this._state=a,this._local_seqnum=n.cseq,this._local_uri=n.parseHeader("from").uri,this._remote_uri=n.parseHeader("to").uri,this._remote_target=t.uri,this._route_set=n.getHeaders("record-route").reverse(),this._ack_seqnum=null),this._ua.newDialog(this),Da.debug(`new ${o} dialog created with status ${this._state===Ss.STATUS_EARLY?"EARLY":"CONFIRMED"}`)}get id(){return this._id}get local_seqnum(){return this._local_seqnum}set local_seqnum(r){this._local_seqnum=r}get owner(){return this._owner}get uac_pending_reply(){return this._uac_pending_reply}set uac_pending_reply(r){this._uac_pending_reply=r}get uas_pending_reply(){return this._uas_pending_reply}isTerminated(){return this._status===Ss.STATUS_TERMINATED}update(r,n){this._state=Ss.STATUS_CONFIRMED,Da.debug(`dialog ${this._id.toString()} changed to CONFIRMED state`),n==="UAC"&&(this._route_set=r.getHeaders("record-route").reverse())}terminate(){Da.debug(`dialog ${this._id.toString()} deleted`),this._ua.destroyDialog(this),this._state=Ss.STATUS_TERMINATED}sendRequest(r,n={}){const o=Oa.cloneArray(n.extraHeaders),a=Oa.cloneObject(n.eventHandlers),t=n.body||null,s=this._createRequest(r,o,t);return a.onAuthenticated=()=>{this._local_seqnum+=1},new mm(this,s,a).send(),s}receiveRequest(r){this._checkInDialogRequest(r)&&(r.method===ys.ACK&&this._ack_seqnum!==null?this._ack_seqnum=null:r.method===ys.INVITE&&(this._ack_seqnum=r.cseq),this._owner.receiveRequest(r))}_createRequest(r,n,o){n=Oa.cloneArray(n),this._local_seqnum||(this._local_seqnum=Math.floor(Math.random()*1e4));const a=r===ys.CANCEL||r===ys.ACK?this._local_seqnum:this._local_seqnum+=1;return new ff.OutgoingRequest(r,this._remote_target,this._ua,{cseq:a,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},n,o)}_checkInDialogRequest(r){if(!this._remote_seqnum)this._remote_seqnum=r.cseq;else if(r.cseq<this._remote_seqnum)if(r.method===ys.ACK){if(this._ack_seqnum===null||r.cseq!==this._ack_seqnum)return!1}else return r.reply(500),!1;else r.cseq>this._remote_seqnum&&(this._remote_seqnum=r.cseq);if(r.method===ys.INVITE||r.method===ys.UPDATE&&r.body){if(this._uac_pending_reply===!0)r.reply(491);else if(this._uas_pending_reply===!0){const n=(Math.random()*10|0)+1;return r.reply(500,null,[`Retry-After:${n}`]),!1}else{this._uas_pending_reply=!0;const n=()=>{(r.server_transaction.state===kr.C.STATUS_ACCEPTED||r.server_transaction.state===kr.C.STATUS_COMPLETED||r.server_transaction.state===kr.C.STATUS_TERMINATED)&&(r.server_transaction.removeListener("stateChanged",n),this._uas_pending_reply=!1)};r.server_transaction.on("stateChanged",n)}r.hasHeader("contact")&&r.server_transaction.on("stateChanged",()=>{r.server_transaction.state===kr.C.STATUS_ACCEPTED&&(this._remote_target=r.parseHeader("contact").uri)})}else r.method===ys.NOTIFY&&r.hasHeader("contact")&&r.server_transaction.on("stateChanged",()=>{r.server_transaction.state===kr.C.STATUS_COMPLETED&&(this._remote_target=r.parseHeader("contact").uri)});return!0}};const Kl=vt(hf);var Na={exports:{}};const gm=ot.EventEmitter,vm=it,Tm=we,Em=us,_f=ft(),ym=new vm("RTCSession:DTMF"),df={MIN_DURATION:70,MAX_DURATION:6e3,DEFAULT_DURATION:100,MIN_INTER_TONE_GAP:50,DEFAULT_INTER_TONE_GAP:500};Na.exports=class extends gm{constructor(r){super(),this._session=r,this._direction=null,this._tone=null,this._duration=null,this._request=null}get tone(){return this._tone}get duration(){return this._duration}send(r,n={}){if(r===void 0)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 Em.InvalidStateError(this._session.status);const o=_f.cloneArray(n.extraHeaders);if(this.eventHandlers=_f.cloneObject(n.eventHandlers),typeof r=="string")r=r.toUpperCase();else if(typeof r=="number")r=r.toString();else throw new TypeError(`Invalid tone: ${r}`);if(r.match(/^[0-9A-DR#*]$/))this._tone=r;else throw new TypeError(`Invalid tone: ${r}`);this._duration=n.duration,o.push("Content-Type: application/dtmf-relay");let a=`Signal=${this._tone}\r
|
113
113
|
`;a+=`Duration=${this._duration}`,this._session.newDTMF({originator:"local",dtmf:this,request:this._request}),this._session.sendRequest(Tm.INFO,{extraHeaders:o,eventHandlers:{onSuccessResponse:t=>{this.emit("succeeded",{originator:"remote",response:t})},onErrorResponse:t=>{this.eventHandlers.onFailed&&this.eventHandlers.onFailed(),this.emit("failed",{originator:"remote",response:t})},onRequestTimeout:()=>{this._session.onRequestTimeout()},onTransportError:()=>{this._session.onTransportError()},onDialogError:()=>{this._session.onDialogError()}},body:a})}init_incoming(r){const n=/^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/,o=/^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;if(this._direction="incoming",this._request=r,r.reply(200),r.body){const a=r.body.split(`
|
114
|
-
`);a.length>=1&&n.test(a[0])&&(this._tone=a[0].replace(n,"$2")),a.length>=2&&o.test(a[1])&&(this._duration=parseInt(a[1].replace(o,"$2"),10))}this._duration||(this._duration=df.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:r}):ym.debug("invalid INFO DTMF received, discarded")}},Na.exports.C=df;var Sm=Na.exports;const Cm=ot.EventEmitter,Am=we,Rm=
|
115
|
-
`,1)[0],"Status_Line");if(n===-1){js.debug(`receiveNotify() | error parsing NOTIFY body: "${r.body}"`);return}switch(!0){case/^100$/.test(n.status_code):this.emit("trying",{request:r,status_line:n});break;case/^1[0-9]{2}$/.test(n.status_code):this.emit("progress",{request:r,status_line:n});break;case/^2[0-9]{2}$/.test(n.status_code):this.emit("accepted",{request:r,status_line:n});break;default:this.emit("failed",{request:r,status_line:n});break}}_requestSucceeded(r){js.debug("REFER succeeded"),js.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:r})}_requestFailed(r,n){js.debug("REFER failed"),js.debug('emit "requestFailed"'),this.emit("requestFailed",{response:r||null,cause:n})}};const Mm=ot.EventEmitter,vf=Ot,xm=it,ue=we,Bs=as,Tf=An,qe=ft(),xr=nf,Lm=Kt,Wl=hf,$m=Rn,wt=Sm,Ef=pf,Hm=Dm,Fm=km,yf=is(),K=new xm("RTCSession"),J={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},Yl=["audio","video"];var Sf=class gu extends Mm{static get C(){return J}constructor(r){K.debug("new"),super(),this._id=null,this._ua=r,this._status=J.STATUS_NULL,this._dialog=null,this._earlyDialogs={},this._contact=null,this._from_tag=null,this._to_tag=null,this._connection=null,this._connectionPromiseQueue=Promise.resolve(),this._request=null,this._is_canceled=!1,this._cancel_reason="",this._is_confirmed=!1,this._late_sdp=!1,this._rtcOfferConstraints=null,this._rtcAnswerConstraints=null,this._localMediaStream=null,this._localMediaStreamLocallyGenerated=!1,this._rtcReady=!0,this._iceReady=!1,this._timers={ackTimer:null,expiresTimer:null,invite2xxTimer:null,userNoAnswerTimer:null},this._direction=null,this._local_identity=null,this._remote_identity=null,this._start_time=null,this._end_time=null,this._tones=null,this._audioMuted=!1,this._videoMuted=!1,this._localHold=!1,this._remoteHold=!1,this._sessionTimers={enabled:this._ua.configuration.session_timers,refreshMethod:this._ua.configuration.session_timers_refresh_method,defaultExpires:ue.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._referSubscribers={},this._data={}}get C(){return J}get causes(){return ue.causes}get id(){return this._id}get connection(){return this._connection}get contact(){return this._contact}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}get start_time(){return this._start_time}get end_time(){return this._end_time}get data(){return this._data}set data(r){this._data=r}get status(){return this._status}isInProgress(){switch(this._status){case J.STATUS_NULL:case J.STATUS_INVITE_SENT:case J.STATUS_1XX_RECEIVED:case J.STATUS_INVITE_RECEIVED:case J.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}isEstablished(){switch(this._status){case J.STATUS_ANSWERED:case J.STATUS_WAITING_FOR_ACK:case J.STATUS_CONFIRMED:return!0;default:return!1}}isEnded(){switch(this._status){case J.STATUS_CANCELED:case J.STATUS_TERMINATED:return!0;default:return!1}}isMuted(){return{audio:this._audioMuted,video:this._videoMuted}}isOnHold(){return{local:this._localHold,remote:this._remoteHold}}connect(r,n={},o){K.debug("connect()");const a=r,t=qe.cloneObject(n.eventHandlers),s=qe.cloneArray(n.extraHeaders),p=qe.cloneObject(n.mediaConstraints,{audio:!0,video:!0}),h=n.mediaStream||null,d=qe.cloneObject(n.pcConfig,{iceServers:[]}),g=n.rtcConstraints||null,v=n.rtcOfferConstraints||null;if(this._rtcOfferConstraints=v,this._rtcAnswerConstraints=n.rtcAnswerConstraints||null,this._data=n.data||this._data,r===void 0)throw new TypeError("Not enough arguments");if(this._status!==J.STATUS_NULL)throw new Bs.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new Bs.NotSupportedError("WebRTC not supported");if(r=this._ua.normalizeTarget(r),!r)throw new TypeError(`Invalid target: ${a}`);this._sessionTimers.enabled&&qe.isDecimal(n.sessionTimersExpires)&&(n.sessionTimersExpires>=ue.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=n.sessionTimersExpires:this._sessionTimers.defaultExpires=ue.SESSION_EXPIRES);for(const C in t)Object.prototype.hasOwnProperty.call(t,C)&&this.on(C,t[C]);this._from_tag=qe.newTag();const E=n.anonymous||!1,S={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:E,outbound:!0}),E?(S.from_display_name="Anonymous",S.from_uri=new yf("sip","anonymous","anonymous.invalid"),s.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),s.push("Privacy: id")):n.fromUserName&&(S.from_uri=new yf("sip",n.fromUserName,this._ua.configuration.uri.host),s.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),n.fromDisplayName&&(S.from_display_name=n.fromDisplayName),s.push(`Contact: ${this._contact}`),s.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&s.push(`Session-Expires: ${this._sessionTimers.defaultExpires}${this._ua.configuration.session_timers_force_refresher?";refresher=uac":""}`),this._request=new Lm.InitialOutgoingInviteRequest(r,this._ua,S,s),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(d,g),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,o&&o(this),this._newRTCSession("local",this._request),this._sendInitialRequest(p,v,h)}init_incoming(r,n){K.debug("init_incoming()");let o;const a=r.hasHeader("Content-Type")?r.getHeader("Content-Type").toLowerCase():void 0;if(r.body&&a!=="application/sdp"){r.reply(415);return}if(this._status=J.STATUS_INVITE_RECEIVED,this._from_tag=r.from_tag,this._id=r.call_id+this._from_tag,this._request=r,this._contact=this._ua.contact.toString(),r.hasHeader("expires")&&(o=r.getHeader("expires")*1e3),r.to_tag=qe.newTag(),!this._createDialog(r,"UAS",!0)){r.reply(500,"Missing Contact header field");return}r.body?this._late_sdp=!1:this._late_sdp=!0,this._status=J.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{r.reply(408),this._failed("local",null,ue.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),o&&(this._timers.expiresTimer=setTimeout(()=>{this._status===J.STATUS_WAITING_FOR_ANSWER&&(r.reply(487),this._failed("system",null,ue.causes.EXPIRES))},o)),this._direction="incoming",this._local_identity=r.to,this._remote_identity=r.from,n&&n(this),this._newRTCSession("remote",r),this._status!==J.STATUS_TERMINATED&&(r.reply(180,null,[`Contact: ${this._contact}`]),this._progress("local",null))}answer(r={}){K.debug("answer()");const n=this._request,o=qe.cloneArray(r.extraHeaders),a=qe.cloneObject(r.mediaConstraints),t=r.mediaStream||null,s=qe.cloneObject(r.pcConfig,{iceServers:[]}),p=r.rtcConstraints||null,h=r.rtcAnswerConstraints||null,d=qe.cloneObject(r.rtcOfferConstraints);let g,v=!1,E=!1,S=!1,C=!1;if(this._rtcAnswerConstraints=h,this._rtcOfferConstraints=r.rtcOfferConstraints||null,this._data=r.data||this._data,this._direction!=="incoming")throw new Bs.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==J.STATUS_WAITING_FOR_ANSWER)throw new Bs.InvalidStateError(this._status);if(this._sessionTimers.enabled&&qe.isDecimal(r.sessionTimersExpires)&&(r.sessionTimersExpires>=ue.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=r.sessionTimersExpires:this._sessionTimers.defaultExpires=ue.SESSION_EXPIRES),this._status=J.STATUS_ANSWERED,!this._createDialog(n,"UAS")){n.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),o.unshift(`Contact: ${this._contact}`);const I=n.parseSDP();Array.isArray(I.media)||(I.media=[I.media]);for(const w of I.media)w.type==="audio"&&(v=!0,(!w.direction||w.direction==="sendrecv")&&(S=!0)),w.type==="video"&&(E=!0,(!w.direction||w.direction==="sendrecv")&&(C=!0));if(t&&a.audio===!1){g=t.getAudioTracks();for(const w of g)t.removeTrack(w)}if(t&&a.video===!1){g=t.getVideoTracks();for(const w of g)t.removeTrack(w)}!t&&a.audio===void 0&&(a.audio=S),!t&&a.video===void 0&&(a.video=C),!t&&!v&&!d.offerToReceiveAudio&&(a.audio=!1),!t&&!E&&!d.offerToReceiveVideo&&(a.video=!1),this._createRTCConnection(s,p),Promise.resolve().then(()=>{if(t)return t;if(a.audio||a.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(a).catch(w=>{throw this._status===J.STATUS_TERMINATED?new Error("terminated"):(n.reply(480),this._failed("local",null,ue.causes.USER_DENIED_MEDIA_ACCESS),K.warn('emit "getusermediafailed" [error:%o]',w),this.emit("getusermediafailed",w),new Error("getUserMedia() failed"))})}).then(w=>{if(this._status===J.STATUS_TERMINATED)throw new Error("terminated");this._localMediaStream=w,w&&w.getTracks().forEach(F=>{this._connection.addTrack(F,w)})}).then(()=>{if(this._late_sdp)return;const w={originator:"remote",type:"offer",sdp:n.body};K.debug('emit "sdp"'),this.emit("sdp",w);const F=new RTCSessionDescription({type:"offer",sdp:w.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(F)).catch(L=>{throw n.reply(488),this._failed("system",null,ue.causes.WEBRTC_ERROR),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',L),this.emit("peerconnection:setremotedescriptionfailed",L),new Error("peerconnection.setRemoteDescription() failed")}),this._connectionPromiseQueue}).then(()=>{if(this._status===J.STATUS_TERMINATED)throw new Error("terminated");return this._connecting(n),this._late_sdp?this._createLocalDescription("offer",this._rtcOfferConstraints).catch(()=>{throw n.reply(500),new Error("_createLocalDescription() failed")}):this._createLocalDescription("answer",h).catch(()=>{throw n.reply(500),new Error("_createLocalDescription() failed")})}).then(w=>{if(this._status===J.STATUS_TERMINATED)throw new Error("terminated");this._handleSessionTimersInIncomingRequest(n,o),n.reply(200,null,o,w,()=>{this._status=J.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(n,w),this._setACKTimer(),this._accepted("local")},()=>{this._failed("system",null,ue.causes.CONNECTION_ERROR)})}).catch(w=>{this._status!==J.STATUS_TERMINATED&&K.warn(w)})}terminate(r={}){K.debug("terminate()");const n=r.cause||ue.causes.BYE,o=qe.cloneArray(r.extraHeaders),a=r.body;let t,s=r.status_code,p=r.reason_phrase;if(this._status===J.STATUS_TERMINATED)throw new Bs.InvalidStateError(this._status);switch(this._status){case J.STATUS_NULL:case J.STATUS_INVITE_SENT:case J.STATUS_1XX_RECEIVED:if(K.debug("canceling session"),s&&(s<200||s>=700))throw new TypeError(`Invalid status_code: ${s}`);s&&(p=p||ue.REASON_PHRASE[s]||"",t=`SIP ;cause=${s} ;text="${p}"`),this._status===J.STATUS_NULL||this._status===J.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=t):this._status===J.STATUS_1XX_RECEIVED&&this._request.cancel(t),this._status=J.STATUS_CANCELED,this._failed("local",null,ue.causes.CANCELED);break;case J.STATUS_WAITING_FOR_ANSWER:case J.STATUS_ANSWERED:if(K.debug("rejecting session"),s=s||480,s<300||s>=700)throw new TypeError(`Invalid status_code: ${s}`);this._request.reply(s,p,o,a),this._failed("local",null,ue.causes.REJECTED);break;case J.STATUS_WAITING_FOR_ACK:case J.STATUS_CONFIRMED:if(K.debug("terminating session"),p=r.reason_phrase||ue.REASON_PHRASE[s]||"",s&&(s<200||s>=700))throw new TypeError(`Invalid status_code: ${s}`);if(s&&o.push(`Reason: SIP ;cause=${s}; text="${p}"`),this._status===J.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==Tf.C.STATUS_TERMINATED){const h=this._dialog;this.receiveRequest=({method:d})=>{d===ue.ACK&&(this.sendRequest(ue.BYE,{extraHeaders:o,body:a}),h.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===Tf.C.STATUS_TERMINATED&&(this.sendRequest(ue.BYE,{extraHeaders:o,body:a}),h.terminate())}),this._ended("local",null,n),this._dialog=h,this._ua.newDialog(h)}else this.sendRequest(ue.BYE,{extraHeaders:o,body:a}),this._ended("local",null,n)}}sendDTMF(r,n={}){K.debug("sendDTMF() | tones: %s",r);let o=0,a=n.duration||null,t=n.interToneGap||null;const s=n.transportType||ue.DTMF_TRANSPORT.INFO;if(r===void 0)throw new TypeError("Not enough arguments");if(this._status!==J.STATUS_CONFIRMED&&this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_1XX_RECEIVED)throw new Bs.InvalidStateError(this._status);if(s!==ue.DTMF_TRANSPORT.INFO&&s!==ue.DTMF_TRANSPORT.RFC2833)throw new TypeError(`invalid transportType: ${s}`);if(typeof r=="number"&&(r=r.toString()),!r||typeof r!="string"||!r.match(/^[0-9A-DR#*,]+$/i))throw new TypeError(`Invalid tones: ${r}`);if(a&&!qe.isDecimal(a))throw new TypeError(`Invalid tone duration: ${a}`);if(a?a<wt.C.MIN_DURATION?(K.debug(`"duration" value is lower than the minimum allowed, setting it to ${wt.C.MIN_DURATION} milliseconds`),a=wt.C.MIN_DURATION):a>wt.C.MAX_DURATION?(K.debug(`"duration" value is greater than the maximum allowed, setting it to ${wt.C.MAX_DURATION} milliseconds`),a=wt.C.MAX_DURATION):a=Math.abs(a):a=wt.C.DEFAULT_DURATION,n.duration=a,t&&!qe.isDecimal(t))throw new TypeError(`Invalid interToneGap: ${t}`);if(t?t<wt.C.MIN_INTER_TONE_GAP?(K.debug(`"interToneGap" value is lower than the minimum allowed, setting it to ${wt.C.MIN_INTER_TONE_GAP} milliseconds`),t=wt.C.MIN_INTER_TONE_GAP):t=Math.abs(t):t=wt.C.DEFAULT_INTER_TONE_GAP,s===ue.DTMF_TRANSPORT.RFC2833){const h=this._getDTMFRTPSender();h&&(r=h.toneBuffer+r,h.insertDTMF(r,a,t));return}if(this._tones){this._tones+=r;return}this._tones=r,p.call(this);function p(){let h;if(this._status===J.STATUS_TERMINATED||!this._tones||o>=this._tones.length){this._tones=null;return}const d=this._tones[o];if(o+=1,d===",")h=2e3;else{const g=new wt(this);n.eventHandlers={onFailed:()=>{this._tones=null}},g.send(d,n),h=a+t}setTimeout(p.bind(this),h)}}sendInfo(r,n,o={}){if(K.debug("sendInfo()"),this._status!==J.STATUS_CONFIRMED&&this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_1XX_RECEIVED)throw new Bs.InvalidStateError(this._status);new Ef(this).send(r,n,o)}mute(r={audio:!0,video:!1}){K.debug("mute()");let n=!1,o=!1;this._audioMuted===!1&&r.audio&&(n=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&r.video&&(o=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(n===!0||o===!0)&&this._onmute({audio:n,video:o})}unmute(r={audio:!0,video:!0}){K.debug("unmute()");let n=!1,o=!1;this._audioMuted===!0&&r.audio&&(n=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&r.video&&(o=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(n===!0||o===!0)&&this._onunmute({audio:n,video:o})}hold(r={},n){if(K.debug("hold()"),this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_CONFIRMED||this._localHold===!0||!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");const o={succeeded:()=>{n&&n()},failed:()=>{this.terminate({cause:ue.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return r.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,extraHeaders:r.extraHeaders}):this._sendReinvite({eventHandlers:o,extraHeaders:r.extraHeaders}),!0}unhold(r={},n){if(K.debug("unhold()"),this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_CONFIRMED||this._localHold===!1||!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");const o={succeeded:()=>{n&&n()},failed:()=>{this.terminate({cause:ue.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return r.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,extraHeaders:r.extraHeaders}):this._sendReinvite({eventHandlers:o,extraHeaders:r.extraHeaders}),!0}renegotiate(r={},n){K.debug("renegotiate()");const o=r.rtcOfferConstraints||null;if(this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_CONFIRMED||!this._isReadyToReOffer())return!1;const a={succeeded:()=>{n&&n()},failed:()=>{this.terminate({cause:ue.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),r.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:a,rtcOfferConstraints:o,extraHeaders:r.extraHeaders}):this._sendReinvite({eventHandlers:a,rtcOfferConstraints:o,extraHeaders:r.extraHeaders}),!0}refer(r,n){K.debug("refer()");const o=r;if(this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_CONFIRMED)return!1;if(r=this._ua.normalizeTarget(r),!r)throw new TypeError(`Invalid target: ${o}`);const a=new Fm(this);a.sendRefer(r,n);const t=a.id;return this._referSubscribers[t]=a,a.on("requestFailed",()=>{delete this._referSubscribers[t]}),a.on("accepted",()=>{delete this._referSubscribers[t]}),a.on("failed",()=>{delete this._referSubscribers[t]}),a}sendRequest(r,n){return K.debug("sendRequest()"),this._dialog.sendRequest(r,n)}receiveRequest(r){if(K.debug("receiveRequest()"),r.method===ue.CANCEL)(this._status===J.STATUS_WAITING_FOR_ANSWER||this._status===J.STATUS_ANSWERED)&&(this._status=J.STATUS_CANCELED,this._request.reply(487),this._failed("remote",r,ue.causes.CANCELED));else switch(r.method){case ue.ACK:if(this._status!==J.STATUS_WAITING_FOR_ACK)return;if(this._status=J.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!r.body){this.terminate({cause:ue.causes.MISSING_SDP,status_code:400});break}const n={originator:"remote",type:"answer",sdp:r.body};K.debug('emit "sdp"'),this.emit("sdp",n);const o=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(o)).then(()=>{this._is_confirmed||this._confirmed("remote",r)}).catch(a=>{this.terminate({cause:ue.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)})}else this._is_confirmed||this._confirmed("remote",r);break;case ue.BYE:this._status===J.STATUS_CONFIRMED||this._status===J.STATUS_WAITING_FOR_ACK?(r.reply(200),this._ended("remote",r,ue.causes.BYE)):this._status===J.STATUS_INVITE_RECEIVED||this._status===J.STATUS_WAITING_FOR_ANSWER?(r.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",r,ue.causes.BYE)):r.reply(403,"Wrong Status");break;case ue.INVITE:this._status===J.STATUS_CONFIRMED?r.hasHeader("replaces")?this._receiveReplaces(r):this._receiveReinvite(r):r.reply(403,"Wrong Status");break;case ue.INFO:if(this._status===J.STATUS_1XX_RECEIVED||this._status===J.STATUS_WAITING_FOR_ANSWER||this._status===J.STATUS_ANSWERED||this._status===J.STATUS_WAITING_FOR_ACK||this._status===J.STATUS_CONFIRMED){const n=r.hasHeader("Content-Type")?r.getHeader("Content-Type").toLowerCase():void 0;n&&n.match(/^application\/dtmf-relay/i)?new wt(this).init_incoming(r):n!==void 0?new Ef(this).init_incoming(r):r.reply(415)}else r.reply(403,"Wrong Status");break;case ue.UPDATE:this._status===J.STATUS_CONFIRMED?this._receiveUpdate(r):r.reply(403,"Wrong Status");break;case ue.REFER:this._status===J.STATUS_CONFIRMED?this._receiveRefer(r):r.reply(403,"Wrong Status");break;case ue.NOTIFY:this._status===J.STATUS_CONFIRMED?this._receiveNotify(r):r.reply(403,"Wrong Status");break;default:r.reply(501)}}onTransportError(){K.warn("onTransportError()"),this._status!==J.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:ue.causes.CONNECTION_ERROR,cause:ue.causes.CONNECTION_ERROR})}onRequestTimeout(){K.warn("onRequestTimeout()"),this._status!==J.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:ue.causes.REQUEST_TIMEOUT,cause:ue.causes.REQUEST_TIMEOUT})}onDialogError(){K.warn("onDialogError()"),this._status!==J.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:ue.causes.DIALOG_ERROR,cause:ue.causes.DIALOG_ERROR})}newDTMF(r){K.debug("newDTMF()"),this.emit("newDTMF",r)}newInfo(r){K.debug("newInfo()"),this.emit("newInfo",r)}_isReadyToReOffer(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(K.debug("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(K.debug("_isReadyToReOffer() | session not established yet"),!1):(K.debug("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}_close(){if(K.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(K.debug("close() | closing local MediaStream"),qe.closeMediaStream(this._localMediaStream)),this._status!==J.STATUS_TERMINATED){if(this._status=J.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(r){K.warn("close() | error closing the RTCPeerConnection: %o",r)}for(const r in this._timers)Object.prototype.hasOwnProperty.call(this._timers,r)&&clearTimeout(this._timers[r]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const r in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,r)&&(this._earlyDialogs[r].terminate(),delete this._earlyDialogs[r]);for(const r in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,r)&&delete this._referSubscribers[r];this._ua.destroyRTCSession(this)}}_setInvite2xxTimer(r,n){let o=xr.T1;function a(){this._status===J.STATUS_WAITING_FOR_ACK&&(r.reply(200,null,[`Contact: ${this._contact}`],n),o<xr.T2&&(o=o*2,o>xr.T2&&(o=xr.T2)),this._timers.invite2xxTimer=setTimeout(a.bind(this),o))}this._timers.invite2xxTimer=setTimeout(a.bind(this),o)}_setACKTimer(){this._timers.ackTimer=setTimeout(()=>{this._status===J.STATUS_WAITING_FOR_ACK&&(K.debug("no ACK received, terminating the session"),clearTimeout(this._timers.invite2xxTimer),this.sendRequest(ue.BYE),this._ended("remote",null,ue.causes.NO_ACK))},xr.TIMER_H)}_createRTCConnection(r,n){this._connection=new RTCPeerConnection(r,n),this._connection.addEventListener("iceconnectionstatechange",()=>{this._connection.iceConnectionState==="failed"&&this.terminate({cause:ue.causes.RTP_TIMEOUT,status_code:408,reason_phrase:ue.causes.RTP_TIMEOUT})}),K.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}_createLocalDescription(r,n){if(K.debug("createLocalDescription()"),r!=="offer"&&r!=="answer")throw new Error(`createLocalDescription() | invalid type "${r}"`);const o=this._connection;return this._rtcReady=!1,Promise.resolve().then(()=>r==="offer"?o.createOffer(n).catch(a=>(K.warn('emit "peerconnection:createofferfailed" [error:%o]',a),this.emit("peerconnection:createofferfailed",a),Promise.reject(a))):o.createAnswer(n).catch(a=>(K.warn('emit "peerconnection:createanswerfailed" [error:%o]',a),this.emit("peerconnection:createanswerfailed",a),Promise.reject(a)))).then(a=>o.setLocalDescription(a).catch(t=>(this._rtcReady=!0,K.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',t),this.emit("peerconnection:setlocaldescriptionfailed",t),Promise.reject(t)))).then(()=>{const a=n&&n.iceRestart;if(o.iceGatheringState==="complete"&&!a||o.iceGatheringState==="gathering"&&this._iceReady){this._rtcReady=!0;const t={originator:"local",type:r,sdp:o.localDescription.sdp};return K.debug('emit "sdp"'),this.emit("sdp",t),Promise.resolve(t.sdp)}return new Promise(t=>{let s=!1,p,h;this._iceReady=!1;const d=()=>{o.removeEventListener("icecandidate",p),o.removeEventListener("icegatheringstatechange",h),s=!0,this._rtcReady=!0,this._iceReady=!0;const g={originator:"local",type:r,sdp:o.localDescription.sdp};K.debug('emit "sdp"'),this.emit("sdp",g),t(g.sdp)};o.addEventListener("icecandidate",p=g=>{const v=g.candidate;v?this.emit("icecandidate",{candidate:v,ready:d}):s||d()}),o.addEventListener("icegatheringstatechange",h=()=>{o.iceGatheringState==="complete"&&!s&&d()})})})}_createDialog(r,n,o){const a=n==="UAS"?r.to_tag:r.from_tag,t=n==="UAS"?r.from_tag:r.to_tag,s=r.call_id+a+t;let p=this._earlyDialogs[s];if(o)return p?!0:(p=new Wl(this,r,n,Wl.C.STATUS_EARLY),p.error?(K.debug(p.error),this._failed("remote",r,ue.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[s]=p,!0));{if(this._from_tag=r.from_tag,this._to_tag=r.to_tag,p)return p.update(r,n),this._dialog=p,delete this._earlyDialogs[s],!0;const h=new Wl(this,r,n);return h.error?(K.debug(h.error),this._failed("remote",r,ue.causes.INTERNAL_ERROR),!1):(this._dialog=h,!0)}}_receiveReinvite(r){K.debug("receiveReinvite()");const n=r.hasHeader("Content-Type")?r.getHeader("Content-Type").toLowerCase():void 0,o={request:r,callback:void 0,reject:t.bind(this)};let a=!1;function t(p={}){a=!0;const h=p.status_code||403,d=p.reason_phrase||"",g=qe.cloneArray(p.extraHeaders);if(this._status!==J.STATUS_CONFIRMED)return!1;if(h<300||h>=700)throw new TypeError(`Invalid status_code: ${h}`);r.reply(h,d,g)}if(this.emit("reinvite",o),a)return;if(this._late_sdp=!1,!r.body){this._late_sdp=!0,this._remoteHold&&(this._remoteHold=!1,this._onunhold("remote")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",this._rtcOfferConstraints)).then(p=>{s.call(this,p)}).catch(()=>{r.reply(500)});return}if(n!=="application/sdp"){K.debug("invalid Content-Type"),r.reply(415);return}this._processInDialogSdpOffer(r).then(p=>{this._status!==J.STATUS_TERMINATED&&s.call(this,p)}).catch(p=>{K.warn(p)});function s(p){const h=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(r,h),this._late_sdp&&(p=this._mangleOffer(p)),r.reply(200,null,h,p,()=>{this._status=J.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(r,p),this._setACKTimer()}),typeof o.callback=="function"&&o.callback()}}_receiveUpdate(r){K.debug("receiveUpdate()");const n=r.hasHeader("Content-Type")?r.getHeader("Content-Type").toLowerCase():void 0,o={request:r,callback:void 0,reject:t.bind(this)};let a=!1;function t(p={}){a=!0;const h=p.status_code||403,d=p.reason_phrase||"",g=qe.cloneArray(p.extraHeaders);if(this._status!==J.STATUS_CONFIRMED)return!1;if(h<300||h>=700)throw new TypeError(`Invalid status_code: ${h}`);r.reply(h,d,g)}if(this.emit("update",o),a)return;if(!r.body){s.call(this,null);return}if(n!=="application/sdp"){K.debug("invalid Content-Type"),r.reply(415);return}this._processInDialogSdpOffer(r).then(p=>{this._status!==J.STATUS_TERMINATED&&s.call(this,p)}).catch(p=>{K.warn(p)});function s(p){const h=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(r,h),r.reply(200,null,h,p),typeof o.callback=="function"&&o.callback()}}_processInDialogSdpOffer(r){K.debug("_processInDialogSdpOffer()");const n=r.parseSDP();let o=!1;for(const s of n.media){if(Yl.indexOf(s.type)===-1)continue;const p=s.direction||n.direction||"sendrecv";if(p==="sendonly"||p==="inactive")o=!0;else{o=!1;break}}const a={originator:"remote",type:"offer",sdp:r.body};K.debug('emit "sdp"'),this.emit("sdp",a);const t=new RTCSessionDescription({type:"offer",sdp:a.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._status===J.STATUS_TERMINATED)throw new Error("terminated");return this._connection.setRemoteDescription(t).catch(s=>{throw r.reply(488),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',s),this.emit("peerconnection:setremotedescriptionfailed",s),s})}).then(()=>{if(this._status===J.STATUS_TERMINATED)throw new Error("terminated");this._remoteHold===!0&&o===!1?(this._remoteHold=!1,this._onunhold("remote")):this._remoteHold===!1&&o===!0&&(this._remoteHold=!0,this._onhold("remote"))}).then(()=>{if(this._status===J.STATUS_TERMINATED)throw new Error("terminated");return this._createLocalDescription("answer",this._rtcAnswerConstraints).catch(s=>{throw r.reply(500),K.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',s),s})}).catch(s=>{K.warn("_processInDialogSdpOffer() failed [error: %o]",s)}),this._connectionPromiseQueue}_receiveRefer(r){if(K.debug("receiveRefer()"),!r.refer_to){K.debug("no Refer-To header field present in REFER"),r.reply(400);return}if(r.refer_to.uri.scheme!==ue.SIP){K.debug("Refer-To header field points to a non-SIP URI scheme"),r.reply(416);return}r.reply(202);const n=new Hm(this,r.cseq);K.debug('emit "refer"'),this.emit("refer",{request:r,accept:(t,s)=>{o.call(this,t,s)},reject:()=>{a.call(this)}});function o(t,s={}){if(t=typeof t=="function"?t:null,this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_CONFIRMED)return!1;const p=new gu(this._ua);if(p.on("progress",({response:h})=>{n.notify(h.status_code,h.reason_phrase)}),p.on("accepted",({response:h})=>{n.notify(h.status_code,h.reason_phrase)}),p.on("_failed",({message:h,cause:d})=>{h?n.notify(h.status_code,h.reason_phrase):n.notify(487,d)}),r.refer_to.uri.hasHeader("replaces")){const h=decodeURIComponent(r.refer_to.uri.getHeader("replaces"));s.extraHeaders=qe.cloneArray(s.extraHeaders),s.extraHeaders.push(`Replaces: ${h}`)}p.connect(r.refer_to.uri.toAor(),s,t)}function a(){n.notify(603)}}_receiveNotify(r){switch(K.debug("receiveNotify()"),r.event||r.reply(400),r.event.event){case"refer":{let n,o;if(r.event.params&&r.event.params.id)n=r.event.params.id,o=this._referSubscribers[n];else if(Object.keys(this._referSubscribers).length===1)o=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{r.reply(400,"Missing event id parameter");return}if(!o){r.reply(481,"Subscription does not exist");return}o.receiveNotify(r),r.reply(200);break}default:r.reply(489)}}_receiveReplaces(r){K.debug("receiveReplaces()");function n(a){if(this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_CONFIRMED)return!1;const t=new gu(this._ua);t.on("confirmed",()=>{this.terminate()}),t.init_incoming(r,a)}function o(){K.debug("Replaced INVITE rejected by the user"),r.reply(486)}this.emit("replaces",{request:r,accept:a=>{n.call(this,a)},reject:()=>{o.call(this)}})}_sendInitialRequest(r,n,o){const a=new $m(this._ua,this._request,{onRequestTimeout:()=>{this.onRequestTimeout()},onTransportError:()=>{this.onTransportError()},onAuthenticated:t=>{this._request=t},onReceiveResponse:t=>{this._receiveInviteResponse(t)}});Promise.resolve().then(()=>{if(o)return o;if(r.audio||r.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(r).catch(t=>{throw this._status===J.STATUS_TERMINATED?new Error("terminated"):(this._failed("local",null,ue.causes.USER_DENIED_MEDIA_ACCESS),K.warn('emit "getusermediafailed" [error:%o]',t),this.emit("getusermediafailed",t),t)})}).then(t=>{if(this._status===J.STATUS_TERMINATED)throw new Error("terminated");return this._localMediaStream=t,t&&t.getTracks().forEach(s=>{this._connection.addTrack(s,t)}),this._connecting(this._request),this._createLocalDescription("offer",n).catch(s=>{throw this._failed("local",null,ue.causes.WEBRTC_ERROR),s})}).then(t=>{if(this._is_canceled||this._status===J.STATUS_TERMINATED)throw new Error("terminated");this._request.body=t,this._status=J.STATUS_INVITE_SENT,K.debug('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),a.send()}).catch(t=>{this._status!==J.STATUS_TERMINATED&&K.warn(t)})}_getDTMFRTPSender(){const r=this._connection.getSenders().find(n=>n.track&&n.track.kind==="audio");if(!(r&&r.dtmf)){K.warn("sendDTMF() | no local audio track to send DTMF with");return}return r.dtmf}_receiveInviteResponse(r){if(K.debug("receiveInviteResponse()"),this._dialog&&r.status_code>=200&&r.status_code<=299)if(this._dialog.id.call_id===r.call_id&&this._dialog.id.local_tag===r.from_tag&&this._dialog.id.remote_tag===r.to_tag){this.sendRequest(ue.ACK);return}else{const n=new Wl(this,r,"UAC");if(n.error!==void 0){K.debug(n.error);return}this.sendRequest(ue.ACK),this.sendRequest(ue.BYE);return}if(this._is_canceled){r.status_code>=100&&r.status_code<200?this._request.cancel(this._cancel_reason):r.status_code>=200&&r.status_code<299&&this._acceptAndTerminate(r);return}if(!(this._status!==J.STATUS_INVITE_SENT&&this._status!==J.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(r.status_code):this._status=J.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(r.status_code):{if(!r.to_tag){K.debug("1xx response received without to tag");break}if(r.hasHeader("contact")&&!this._createDialog(r,"UAC",!0))break;if(this._status=J.STATUS_1XX_RECEIVED,!r.body){this._progress("remote",r);break}const n={originator:"remote",type:"answer",sdp:r.body};K.debug('emit "sdp"'),this.emit("sdp",n);const o=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(o)).then(()=>this._progress("remote",r)).catch(a=>{K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)});break}case/^2[0-9]{2}$/.test(r.status_code):{if(this._status=J.STATUS_CONFIRMED,!r.body){this._acceptAndTerminate(r,400,ue.causes.MISSING_SDP),this._failed("remote",r,ue.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(r,"UAC"))break;const n={originator:"remote",type:"answer",sdp:r.body};K.debug('emit "sdp"'),this.emit("sdp",n);const o=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._connection.signalingState==="stable")return this._connection.createOffer(this._rtcOfferConstraints).then(a=>this._connection.setLocalDescription(a)).catch(a=>{this._acceptAndTerminate(r,500,a.toString()),this._failed("local",r,ue.causes.WEBRTC_ERROR)})}).then(()=>{this._connection.setRemoteDescription(o).then(()=>{this._handleSessionTimersInIncomingResponse(r),this._accepted("remote",r),this.sendRequest(ue.ACK),this._confirmed("local",null)}).catch(a=>{this._acceptAndTerminate(r,488,"Not Acceptable Here"),this._failed("remote",r,ue.causes.BAD_MEDIA_DESCRIPTION),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)})});break}default:{const n=qe.sipErrorCause(r.status_code);this._failed("remote",r,n)}}}_sendReinvite(r={}){K.debug("sendReinvite()");const n=qe.cloneArray(r.extraHeaders),o=qe.cloneObject(r.eventHandlers),a=r.rtcOfferConstraints||this._rtcOfferConstraints||null;let t=!1;n.push(`Contact: ${this._contact}`),n.push("Content-Type: application/sdp"),this._sessionTimers.running&&n.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",a)).then(h=>{h=this._mangleOffer(h);const d={originator:"local",type:"offer",sdp:h};K.debug('emit "sdp"'),this.emit("sdp",d),this.sendRequest(ue.INVITE,{extraHeaders:n,body:h,eventHandlers:{onSuccessResponse:g=>{s.call(this,g),t=!0},onErrorResponse:g=>{p.call(this,g)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{p()});function s(h){if(this._status===J.STATUS_TERMINATED||(this.sendRequest(ue.ACK),t))return;if(this._handleSessionTimersInIncomingResponse(h),h.body){if(!h.hasHeader("Content-Type")||h.getHeader("Content-Type").toLowerCase()!=="application/sdp"){p.call(this);return}}else{p.call(this);return}const d={originator:"remote",type:"answer",sdp:h.body};K.debug('emit "sdp"'),this.emit("sdp",d);const g=new RTCSessionDescription({type:"answer",sdp:d.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(g)).then(()=>{o.succeeded&&o.succeeded(h)}).catch(v=>{p.call(this),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',v),this.emit("peerconnection:setremotedescriptionfailed",v)})}function p(h){o.failed&&o.failed(h)}}_sendUpdate(r={}){K.debug("sendUpdate()");const n=qe.cloneArray(r.extraHeaders),o=qe.cloneObject(r.eventHandlers),a=r.rtcOfferConstraints||this._rtcOfferConstraints||null,t=r.sdpOffer||!1;let s=!1;n.push(`Contact: ${this._contact}`),this._sessionTimers.running&&n.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),t?(n.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",a)).then(d=>{d=this._mangleOffer(d);const g={originator:"local",type:"offer",sdp:d};K.debug('emit "sdp"'),this.emit("sdp",g),this.sendRequest(ue.UPDATE,{extraHeaders:n,body:d,eventHandlers:{onSuccessResponse:v=>{p.call(this,v),s=!0},onErrorResponse:v=>{h.call(this,v)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{h.call(this)})):this.sendRequest(ue.UPDATE,{extraHeaders:n,eventHandlers:{onSuccessResponse:d=>{p.call(this,d)},onErrorResponse:d=>{h.call(this,d)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}});function p(d){if(this._status!==J.STATUS_TERMINATED&&!s)if(this._handleSessionTimersInIncomingResponse(d),t){if(d.body){if(!d.hasHeader("Content-Type")||d.getHeader("Content-Type").toLowerCase()!=="application/sdp"){h.call(this);return}}else{h.call(this);return}const g={originator:"remote",type:"answer",sdp:d.body};K.debug('emit "sdp"'),this.emit("sdp",g);const v=new RTCSessionDescription({type:"answer",sdp:g.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(v)).then(()=>{o.succeeded&&o.succeeded(d)}).catch(E=>{h.call(this),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',E),this.emit("peerconnection:setremotedescriptionfailed",E)})}else o.succeeded&&o.succeeded(d)}function h(d){o.failed&&o.failed(d)}}_acceptAndTerminate(r,n,o){K.debug("acceptAndTerminate()");const a=[];n&&(o=o||ue.REASON_PHRASE[n]||"",a.push(`Reason: SIP ;cause=${n}; text="${o}"`)),(this._dialog||this._createDialog(r,"UAC"))&&(this.sendRequest(ue.ACK),this.sendRequest(ue.BYE,{extraHeaders:a})),this._status=J.STATUS_TERMINATED}_mangleOffer(r){if(!this._localHold&&!this._remoteHold)return r;if(r=vf.parse(r),this._localHold&&!this._remoteHold){K.debug("mangleOffer() | me on hold, mangling offer");for(const n of r.media)Yl.indexOf(n.type)!==-1&&(n.direction?n.direction==="sendrecv"?n.direction="sendonly":n.direction==="recvonly"&&(n.direction="inactive"):n.direction="sendonly")}else if(this._localHold&&this._remoteHold){K.debug("mangleOffer() | both on hold, mangling offer");for(const n of r.media)Yl.indexOf(n.type)!==-1&&(n.direction="inactive")}else if(this._remoteHold){K.debug("mangleOffer() | remote on hold, mangling offer");for(const n of r.media)Yl.indexOf(n.type)!==-1&&(n.direction?n.direction==="sendrecv"?n.direction="recvonly":n.direction==="recvonly"&&(n.direction="inactive"):n.direction="recvonly")}return vf.write(r)}_setLocalMediaStatus(){let r=!0,n=!0;(this._localHold||this._remoteHold)&&(r=!1,n=!1),this._audioMuted&&(r=!1),this._videoMuted&&(n=!1),this._toggleMuteAudio(!r),this._toggleMuteVideo(!n)}_handleSessionTimersInIncomingRequest(r,n){if(!this._sessionTimers.enabled)return;let o;r.session_expires&&r.session_expires>=ue.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=r.session_expires,o=r.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,o="uas"),n.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${o}`),this._sessionTimers.refresher=o==="uas",this._runSessionTimer()}_handleSessionTimersInIncomingResponse(r){if(!this._sessionTimers.enabled)return;let n;r.session_expires&&r.session_expires>=ue.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=r.session_expires,n=r.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,n="uac"),this._sessionTimers.refresher=n==="uac",this._runSessionTimer()}_runSessionTimer(){const r=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(()=>{this._status!==J.STATUS_TERMINATED&&this._isReadyToReOffer()&&(K.debug("runSessionTimer() | sending session refresh request"),this._sessionTimers.refreshMethod===ue.UPDATE?this._sendUpdate():this._sendReinvite())},r*500):this._sessionTimers.timer=setTimeout(()=>{this._status!==J.STATUS_TERMINATED&&(K.warn("runSessionTimer() | timer expired, terminating the session"),this.terminate({cause:ue.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},r*1100)}_toggleMuteAudio(r){const n=this._connection.getSenders().filter(o=>o.track&&o.track.kind==="audio");for(const o of n)o.track.enabled=!r}_toggleMuteVideo(r){const n=this._connection.getSenders().filter(o=>o.track&&o.track.kind==="video");for(const o of n)o.track.enabled=!r}_newRTCSession(r,n){K.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:r,session:this,request:n})}_connecting(r){K.debug("session connecting"),K.debug('emit "connecting"'),this.emit("connecting",{request:r})}_progress(r,n){K.debug("session progress"),K.debug('emit "progress"'),this.emit("progress",{originator:r,response:n||null})}_accepted(r,n){K.debug("session accepted"),this._start_time=new Date,K.debug('emit "accepted"'),this.emit("accepted",{originator:r,response:n||null})}_confirmed(r,n){K.debug("session confirmed"),this._is_confirmed=!0,K.debug('emit "confirmed"'),this.emit("confirmed",{originator:r,ack:n||null})}_ended(r,n,o){K.debug("session ended"),this._end_time=new Date,this._close(),K.debug('emit "ended"'),this.emit("ended",{originator:r,message:n||null,cause:o})}_failed(r,n,o){K.debug("session failed"),K.debug('emit "_failed"'),this.emit("_failed",{originator:r,message:n||null,cause:o}),this._close(),K.debug('emit "failed"'),this.emit("failed",{originator:r,message:n||null,cause:o})}_onhold(r){K.debug("session onhold"),this._setLocalMediaStatus(),K.debug('emit "hold"'),this.emit("hold",{originator:r})}_onunhold(r){K.debug("session onunhold"),this._setLocalMediaStatus(),K.debug('emit "unhold"'),this.emit("unhold",{originator:r})}_onmute({audio:r,video:n}){K.debug("session onmute"),this._setLocalMediaStatus(),K.debug('emit "muted"'),this.emit("muted",{audio:r,video:n})}_onunmute({audio:r,video:n}){K.debug("session onunmute"),this._setLocalMediaStatus(),K.debug('emit "unmuted"'),this.emit("unmuted",{audio:r,video:n})}};const qm=vt(Sf),Vm=ot.EventEmitter,jm=it,Pa=we,Bm=Kt,Lr=ft(),Gm=Rn,Cf=as,Km=is(),zl=new jm("Message");var Wm=class extends Vm{constructor(r){super(),this._ua=r,this._request=null,this._closed=!1,this._direction=null,this._local_identity=null,this._remote_identity=null,this._is_replied=!1,this._data={}}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}send(r,n,o={}){const a=r;if(r===void 0||n===void 0)throw new TypeError("Not enough arguments");if(r=this._ua.normalizeTarget(r),!r)throw new TypeError(`Invalid target: ${a}`);const t=Lr.cloneArray(o.extraHeaders),s=Lr.cloneObject(o.eventHandlers),p=o.contentType||"text/plain",h={};o.fromUserName&&(h.from_uri=new Km("sip",o.fromUserName,this._ua.configuration.uri.host),t.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),o.fromDisplayName&&(h.from_display_name=o.fromDisplayName);for(const g in s)Object.prototype.hasOwnProperty.call(s,g)&&this.on(g,s[g]);t.push(`Content-Type: ${p}`),this._request=new Bm.OutgoingRequest(Pa.MESSAGE,r,this._ua,h,t),n&&(this._request.body=n);const d=new Gm(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:g=>{this._receiveResponse(g)}});this._newMessage("local",this._request),d.send()}init_incoming(r){this._request=r,this._newMessage("remote",r),this._is_replied||(this._is_replied=!0,r.reply(200)),this._close()}accept(r={}){const n=Lr.cloneArray(r.extraHeaders),o=r.body;if(this._direction!=="incoming")throw new Cf.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,n,o)}reject(r={}){const n=r.status_code||480,o=r.reason_phrase,a=Lr.cloneArray(r.extraHeaders),t=r.body;if(this._direction!=="incoming")throw new Cf.NotSupportedError('"reject" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");if(n<300||n>=700)throw new TypeError(`Invalid status_code: ${n}`);this._is_replied=!0,this._request.reply(n,o,a,t)}_receiveResponse(r){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(r.status_code):break;case/^2[0-9]{2}$/.test(r.status_code):this._succeeded("remote",r);break;default:{const n=Lr.sipErrorCause(r.status_code);this._failed("remote",r,n);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,Pa.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,Pa.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newMessage(r,n){r==="remote"?(this._direction="incoming",this._local_identity=n.to,this._remote_identity=n.from):r==="local"&&(this._direction="outgoing",this._local_identity=n.from,this._remote_identity=n.to),this._ua.newMessage(this,{originator:r,message:this,request:n})}_failed(r,n,o){zl.debug("MESSAGE failed"),this._close(),zl.debug('emit "failed"'),this.emit("failed",{originator:r,response:n||null,cause:o})}_succeeded(r,n){zl.debug("MESSAGE succeeded"),this._close(),zl.debug('emit "succeeded"'),this.emit("succeeded",{originator:r,response:n})}};const Ym=ot.EventEmitter,zm=it,ka=we,Jm=Kt,$r=ft(),Xm=Rn,Af=as,Jl=new zm("Options");var Qm=class extends Ym{constructor(r){super(),this._ua=r,this._request=null,this._closed=!1,this._direction=null,this._local_identity=null,this._remote_identity=null,this._is_replied=!1,this._data={}}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}send(r,n,o={}){const a=r;if(r===void 0)throw new TypeError("A target is required for OPTIONS");if(r=this._ua.normalizeTarget(r),!r)throw new TypeError(`Invalid target: ${a}`);const t=$r.cloneArray(o.extraHeaders),s=$r.cloneObject(o.eventHandlers),p=o.contentType||"application/sdp";for(const d in s)Object.prototype.hasOwnProperty.call(s,d)&&this.on(d,s[d]);t.push(`Content-Type: ${p}`),this._request=new Jm.OutgoingRequest(ka.OPTIONS,r,this._ua,null,t),n&&(this._request.body=n);const h=new Xm(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:d=>{this._receiveResponse(d)}});this._newOptions("local",this._request),h.send()}init_incoming(r){this._request=r,this._newOptions("remote",r),this._is_replied||(this._is_replied=!0,r.reply(200)),this._close()}accept(r={}){const n=$r.cloneArray(r.extraHeaders),o=r.body;if(this._direction!=="incoming")throw new Af.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,n,o)}reject(r={}){const n=r.status_code||480,o=r.reason_phrase,a=$r.cloneArray(r.extraHeaders),t=r.body;if(this._direction!=="incoming")throw new Af.NotSupportedError('"reject" not supported for outgoing Options');if(this._is_replied)throw new Error("incoming Options already replied");if(n<300||n>=700)throw new TypeError(`Invalid status_code: ${n}`);this._is_replied=!0,this._request.reply(n,o,a,t)}_receiveResponse(r){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(r.status_code):break;case/^2[0-9]{2}$/.test(r.status_code):this._succeeded("remote",r);break;default:{const n=$r.sipErrorCause(r.status_code);this._failed("remote",r,n);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,ka.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,ka.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newOptions(r,n){r==="remote"?(this._direction="incoming",this._local_identity=n.to,this._remote_identity=n.from):r==="local"&&(this._direction="outgoing",this._local_identity=n.from,this._remote_identity=n.to),this._ua.newOptions(this,{originator:r,message:this,request:n})}_failed(r,n,o){Jl.debug("OPTIONS failed"),this._close(),Jl.debug('emit "failed"'),this.emit("failed",{originator:r,response:n||null,cause:o})}_succeeded(r,n){Jl.debug("OPTIONS succeeded"),this._close(),Jl.debug('emit "succeeded"'),this.emit("succeeded",{originator:r,response:n})}},Ma={};const Zm=it,xa=ft(),eg=Gt(),Hr=new Zm("Socket");Ma.isSocket=c=>{if(Array.isArray(c))return!1;if(typeof c>"u")return Hr.warn("undefined JsSIP.Socket instance"),!1;try{if(!xa.isString(c.url))throw Hr.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!xa.isString(c.via_transport))throw Hr.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(eg.parse(c.sip_uri,"SIP_URI")===-1)throw Hr.warn("missing or invalid JsSIP.Socket sip_uri property"),new Error("missing or invalid JsSIP.Socket sip_uri property")}catch{return!1}try{["connect","disconnect","send"].forEach(r=>{if(!xa.isFunction(c[r]))throw Hr.warn(`missing or invalid JsSIP.Socket method: ${r}`),new Error(`Missing or invalid JsSIP.Socket method: ${r}`)})}catch{return!1}return!0};const tg=it,sg=Ma,Rf=we,It=new tg("Transport"),Ut={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:Rf.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:Rf.CONNECTION_RECOVERY_MAX_INTERVAL}};var ng=class{constructor(r,n=Ut.recovery_options){It.debug("new()"),this.status=Ut.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=n,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1;try{this.textDecoder=new TextDecoder("utf8")}catch(o){It.warn(`cannot use TextDecoder: ${o}`)}if(typeof r>"u")throw new TypeError("Invalid argument. undefined 'sockets' argument");r instanceof Array||(r=[r]),r.forEach(function(o){if(!sg.isSocket(o.socket))throw new TypeError("Invalid argument. invalid 'JsSIP.Socket' instance");if(o.weight&&!Number(o.weight))throw new TypeError("Invalid argument. 'weight' attribute is not a number");this.sockets.push({socket:o.socket,weight:o.weight||0,status:Ut.SOCKET_STATUS_READY})},this),this._getSocket()}get via_transport(){return this.socket.via_transport}get url(){return this.socket.url}get sip_uri(){return this.socket.sip_uri}connect(){if(It.debug("connect()"),this.isConnected()){It.debug("Transport is already connected");return}else if(this.isConnecting()){It.debug("Transport is connecting");return}this.close_requested=!1,this.status=Ut.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())}disconnect(){It.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=Ut.STATUS_DISCONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.socket.onconnect=()=>{},this.socket.ondisconnect=()=>{},this.socket.ondata=()=>{},this.socket.disconnect(),this.ondisconnect({socket:this.socket,error:!1})}send(r){if(It.debug("send()"),!this.isConnected())return It.warn("unable to send message, transport is not connected"),!1;const n=r.toString();return It.debug(`sending message:
|
114
|
+
`);a.length>=1&&n.test(a[0])&&(this._tone=a[0].replace(n,"$2")),a.length>=2&&o.test(a[1])&&(this._duration=parseInt(a[1].replace(o,"$2"),10))}this._duration||(this._duration=df.DEFAULT_DURATION),this._tone?this._session.newDTMF({originator:"remote",dtmf:this,request:r}):ym.debug("invalid INFO DTMF received, discarded")}},Na.exports.C=df;var Sm=Na.exports;const Cm=ot.EventEmitter,Am=we,Rm=us,Im=ft();var pf=class extends Cm{constructor(r){super(),this._session=r,this._direction=null,this._contentType=null,this._body=null}get contentType(){return this._contentType}get body(){return this._body}send(r,n,o={}){if(this._direction="outgoing",r===void 0)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 Rm.InvalidStateError(this._session.status);this._contentType=r,this._body=n;const a=Im.cloneArray(o.extraHeaders);a.push(`Content-Type: ${r}`),this._session.newInfo({originator:"local",info:this,request:this.request}),this._session.sendRequest(Am.INFO,{extraHeaders:a,eventHandlers:{onSuccessResponse:t=>{this.emit("succeeded",{originator:"remote",response:t})},onErrorResponse:t=>{this.emit("failed",{originator:"remote",response:t})},onTransportError:()=>{this._session.onTransportError()},onRequestTimeout:()=>{this._session.onRequestTimeout()},onDialogError:()=>{this._session.onDialogError()}},body:n})}init_incoming(r){this._direction="incoming",this.request=r,r.reply(200),this._contentType=r.hasHeader("Content-Type")?r.getHeader("Content-Type").toLowerCase():void 0,this._body=r.body,this._session.newInfo({originator:"remote",info:this,request:r})}};const bm=vt(pf),wm=it,mf=we,Om=new wm("RTCSession:ReferNotifier"),Ua={event_type:"refer",body_type:"message/sipfrag;version=2.0",expires:300};var Dm=class{constructor(r,n,o){this._session=r,this._id=n,this._expires=o||Ua.expires,this._active=!0,this.notify(100)}notify(r,n){if(Om.debug("notify()"),this._active===!1)return;n=n||mf.REASON_PHRASE[r]||"";let o;r>=200?o="terminated;reason=noresource":o=`active;expires=${this._expires}`,this._session.sendRequest(mf.NOTIFY,{extraHeaders:[`Event: ${Ua.event_type};id=${this._id}`,`Subscription-State: ${o}`,`Content-Type: ${Ua.body_type}`],body:`SIP/2.0 ${r} ${n}`,eventHandlers:{onErrorResponse(){this._active=!1}}})}};const Nm=ot.EventEmitter,Um=it,Mr=we,Pm=Gt(),gf=ft(),Bs=new Um("RTCSession:ReferSubscriber");var km=class extends Nm{constructor(r){super(),this._id=null,this._session=r}get id(){return this._id}sendRefer(r,n={}){Bs.debug("sendRefer()");const o=gf.cloneArray(n.extraHeaders),a=gf.cloneObject(n.eventHandlers);for(const h in a)Object.prototype.hasOwnProperty.call(a,h)&&this.on(h,a[h]);let t=null;n.replaces&&(t=n.replaces._request.call_id,t+=`;to-tag=${n.replaces._to_tag}`,t+=`;from-tag=${n.replaces._from_tag}`,t=encodeURIComponent(t));const s=`Refer-To: <${r}${t?`?Replaces=${t}`:""}>`;if(o.push(s),!o.some(h=>h.toLowerCase().startsWith("referred-by:"))){const h=`Referred-By: <${this._session._ua._configuration.uri._scheme}:${this._session._ua._configuration.uri._user}@${this._session._ua._configuration.uri._host}>`;o.push(h)}o.push(`Contact: ${this._session.contact}`);const p=this._session.sendRequest(Mr.REFER,{extraHeaders:o,eventHandlers:{onSuccessResponse:h=>{this._requestSucceeded(h)},onErrorResponse:h=>{this._requestFailed(h,Mr.causes.REJECTED)},onTransportError:()=>{this._requestFailed(null,Mr.causes.CONNECTION_ERROR)},onRequestTimeout:()=>{this._requestFailed(null,Mr.causes.REQUEST_TIMEOUT)},onDialogError:()=>{this._requestFailed(null,Mr.causes.DIALOG_ERROR)}}});this._id=p.cseq}receiveNotify(r){if(Bs.debug("receiveNotify()"),!r.body)return;const n=Pm.parse(r.body.trim().split(`\r
|
115
|
+
`,1)[0],"Status_Line");if(n===-1){Bs.debug(`receiveNotify() | error parsing NOTIFY body: "${r.body}"`);return}switch(!0){case/^100$/.test(n.status_code):this.emit("trying",{request:r,status_line:n});break;case/^1[0-9]{2}$/.test(n.status_code):this.emit("progress",{request:r,status_line:n});break;case/^2[0-9]{2}$/.test(n.status_code):this.emit("accepted",{request:r,status_line:n});break;default:this.emit("failed",{request:r,status_line:n});break}}_requestSucceeded(r){Bs.debug("REFER succeeded"),Bs.debug('emit "requestSucceeded"'),this.emit("requestSucceeded",{response:r})}_requestFailed(r,n){Bs.debug("REFER failed"),Bs.debug('emit "requestFailed"'),this.emit("requestFailed",{response:r||null,cause:n})}};const Mm=ot.EventEmitter,vf=Ot,xm=it,ue=we,Gs=us,Tf=An,qe=ft(),xr=nf,Lm=Kt,Wl=hf,$m=Rn,wt=Sm,Ef=pf,Hm=Dm,Fm=km,yf=ls(),K=new xm("RTCSession"),J={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},Yl=["audio","video"];var Sf=class gu extends Mm{static get C(){return J}constructor(r){K.debug("new"),super(),this._id=null,this._ua=r,this._status=J.STATUS_NULL,this._dialog=null,this._earlyDialogs={},this._contact=null,this._from_tag=null,this._to_tag=null,this._connection=null,this._connectionPromiseQueue=Promise.resolve(),this._request=null,this._is_canceled=!1,this._cancel_reason="",this._is_confirmed=!1,this._late_sdp=!1,this._rtcOfferConstraints=null,this._rtcAnswerConstraints=null,this._localMediaStream=null,this._localMediaStreamLocallyGenerated=!1,this._rtcReady=!0,this._iceReady=!1,this._timers={ackTimer:null,expiresTimer:null,invite2xxTimer:null,userNoAnswerTimer:null},this._direction=null,this._local_identity=null,this._remote_identity=null,this._start_time=null,this._end_time=null,this._tones=null,this._audioMuted=!1,this._videoMuted=!1,this._localHold=!1,this._remoteHold=!1,this._sessionTimers={enabled:this._ua.configuration.session_timers,refreshMethod:this._ua.configuration.session_timers_refresh_method,defaultExpires:ue.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._referSubscribers={},this._data={}}get C(){return J}get causes(){return ue.causes}get id(){return this._id}get connection(){return this._connection}get contact(){return this._contact}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}get start_time(){return this._start_time}get end_time(){return this._end_time}get data(){return this._data}set data(r){this._data=r}get status(){return this._status}isInProgress(){switch(this._status){case J.STATUS_NULL:case J.STATUS_INVITE_SENT:case J.STATUS_1XX_RECEIVED:case J.STATUS_INVITE_RECEIVED:case J.STATUS_WAITING_FOR_ANSWER:return!0;default:return!1}}isEstablished(){switch(this._status){case J.STATUS_ANSWERED:case J.STATUS_WAITING_FOR_ACK:case J.STATUS_CONFIRMED:return!0;default:return!1}}isEnded(){switch(this._status){case J.STATUS_CANCELED:case J.STATUS_TERMINATED:return!0;default:return!1}}isMuted(){return{audio:this._audioMuted,video:this._videoMuted}}isOnHold(){return{local:this._localHold,remote:this._remoteHold}}connect(r,n={},o){K.debug("connect()");const a=r,t=qe.cloneObject(n.eventHandlers),s=qe.cloneArray(n.extraHeaders),p=qe.cloneObject(n.mediaConstraints,{audio:!0,video:!0}),h=n.mediaStream||null,d=qe.cloneObject(n.pcConfig,{iceServers:[]}),g=n.rtcConstraints||null,v=n.rtcOfferConstraints||null;if(this._rtcOfferConstraints=v,this._rtcAnswerConstraints=n.rtcAnswerConstraints||null,this._data=n.data||this._data,r===void 0)throw new TypeError("Not enough arguments");if(this._status!==J.STATUS_NULL)throw new Gs.InvalidStateError(this._status);if(!window.RTCPeerConnection)throw new Gs.NotSupportedError("WebRTC not supported");if(r=this._ua.normalizeTarget(r),!r)throw new TypeError(`Invalid target: ${a}`);this._sessionTimers.enabled&&qe.isDecimal(n.sessionTimersExpires)&&(n.sessionTimersExpires>=ue.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=n.sessionTimersExpires:this._sessionTimers.defaultExpires=ue.SESSION_EXPIRES);for(const C in t)Object.prototype.hasOwnProperty.call(t,C)&&this.on(C,t[C]);this._from_tag=qe.newTag();const E=n.anonymous||!1,S={from_tag:this._from_tag};this._contact=this._ua.contact.toString({anonymous:E,outbound:!0}),E?(S.from_display_name="Anonymous",S.from_uri=new yf("sip","anonymous","anonymous.invalid"),s.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`),s.push("Privacy: id")):n.fromUserName&&(S.from_uri=new yf("sip",n.fromUserName,this._ua.configuration.uri.host),s.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),n.fromDisplayName&&(S.from_display_name=n.fromDisplayName),s.push(`Contact: ${this._contact}`),s.push("Content-Type: application/sdp"),this._sessionTimers.enabled&&s.push(`Session-Expires: ${this._sessionTimers.defaultExpires}${this._ua.configuration.session_timers_force_refresher?";refresher=uac":""}`),this._request=new Lm.InitialOutgoingInviteRequest(r,this._ua,S,s),this._id=this._request.call_id+this._from_tag,this._createRTCConnection(d,g),this._direction="outgoing",this._local_identity=this._request.from,this._remote_identity=this._request.to,o&&o(this),this._newRTCSession("local",this._request),this._sendInitialRequest(p,v,h)}init_incoming(r,n){K.debug("init_incoming()");let o;const a=r.hasHeader("Content-Type")?r.getHeader("Content-Type").toLowerCase():void 0;if(r.body&&a!=="application/sdp"){r.reply(415);return}if(this._status=J.STATUS_INVITE_RECEIVED,this._from_tag=r.from_tag,this._id=r.call_id+this._from_tag,this._request=r,this._contact=this._ua.contact.toString(),r.hasHeader("expires")&&(o=r.getHeader("expires")*1e3),r.to_tag=qe.newTag(),!this._createDialog(r,"UAS",!0)){r.reply(500,"Missing Contact header field");return}r.body?this._late_sdp=!1:this._late_sdp=!0,this._status=J.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{r.reply(408),this._failed("local",null,ue.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),o&&(this._timers.expiresTimer=setTimeout(()=>{this._status===J.STATUS_WAITING_FOR_ANSWER&&(r.reply(487),this._failed("system",null,ue.causes.EXPIRES))},o)),this._direction="incoming",this._local_identity=r.to,this._remote_identity=r.from,n&&n(this),this._newRTCSession("remote",r),this._status!==J.STATUS_TERMINATED&&(r.reply(180,null,[`Contact: ${this._contact}`]),this._progress("local",null))}answer(r={}){K.debug("answer()");const n=this._request,o=qe.cloneArray(r.extraHeaders),a=qe.cloneObject(r.mediaConstraints),t=r.mediaStream||null,s=qe.cloneObject(r.pcConfig,{iceServers:[]}),p=r.rtcConstraints||null,h=r.rtcAnswerConstraints||null,d=qe.cloneObject(r.rtcOfferConstraints);let g,v=!1,E=!1,S=!1,C=!1;if(this._rtcAnswerConstraints=h,this._rtcOfferConstraints=r.rtcOfferConstraints||null,this._data=r.data||this._data,this._direction!=="incoming")throw new Gs.NotSupportedError('"answer" not supported for outgoing RTCSession');if(this._status!==J.STATUS_WAITING_FOR_ANSWER)throw new Gs.InvalidStateError(this._status);if(this._sessionTimers.enabled&&qe.isDecimal(r.sessionTimersExpires)&&(r.sessionTimersExpires>=ue.MIN_SESSION_EXPIRES?this._sessionTimers.defaultExpires=r.sessionTimersExpires:this._sessionTimers.defaultExpires=ue.SESSION_EXPIRES),this._status=J.STATUS_ANSWERED,!this._createDialog(n,"UAS")){n.reply(500,"Error creating dialog");return}clearTimeout(this._timers.userNoAnswerTimer),o.unshift(`Contact: ${this._contact}`);const I=n.parseSDP();Array.isArray(I.media)||(I.media=[I.media]);for(const w of I.media)w.type==="audio"&&(v=!0,(!w.direction||w.direction==="sendrecv")&&(S=!0)),w.type==="video"&&(E=!0,(!w.direction||w.direction==="sendrecv")&&(C=!0));if(t&&a.audio===!1){g=t.getAudioTracks();for(const w of g)t.removeTrack(w)}if(t&&a.video===!1){g=t.getVideoTracks();for(const w of g)t.removeTrack(w)}!t&&a.audio===void 0&&(a.audio=S),!t&&a.video===void 0&&(a.video=C),!t&&!v&&!d.offerToReceiveAudio&&(a.audio=!1),!t&&!E&&!d.offerToReceiveVideo&&(a.video=!1),this._createRTCConnection(s,p),Promise.resolve().then(()=>{if(t)return t;if(a.audio||a.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(a).catch(w=>{throw this._status===J.STATUS_TERMINATED?new Error("terminated"):(n.reply(480),this._failed("local",null,ue.causes.USER_DENIED_MEDIA_ACCESS),K.warn('emit "getusermediafailed" [error:%o]',w),this.emit("getusermediafailed",w),new Error("getUserMedia() failed"))})}).then(w=>{if(this._status===J.STATUS_TERMINATED)throw new Error("terminated");this._localMediaStream=w,w&&w.getTracks().forEach(F=>{this._connection.addTrack(F,w)})}).then(()=>{if(this._late_sdp)return;const w={originator:"remote",type:"offer",sdp:n.body};K.debug('emit "sdp"'),this.emit("sdp",w);const F=new RTCSessionDescription({type:"offer",sdp:w.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(F)).catch(L=>{throw n.reply(488),this._failed("system",null,ue.causes.WEBRTC_ERROR),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',L),this.emit("peerconnection:setremotedescriptionfailed",L),new Error("peerconnection.setRemoteDescription() failed")}),this._connectionPromiseQueue}).then(()=>{if(this._status===J.STATUS_TERMINATED)throw new Error("terminated");return this._connecting(n),this._late_sdp?this._createLocalDescription("offer",this._rtcOfferConstraints).catch(()=>{throw n.reply(500),new Error("_createLocalDescription() failed")}):this._createLocalDescription("answer",h).catch(()=>{throw n.reply(500),new Error("_createLocalDescription() failed")})}).then(w=>{if(this._status===J.STATUS_TERMINATED)throw new Error("terminated");this._handleSessionTimersInIncomingRequest(n,o),n.reply(200,null,o,w,()=>{this._status=J.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(n,w),this._setACKTimer(),this._accepted("local")},()=>{this._failed("system",null,ue.causes.CONNECTION_ERROR)})}).catch(w=>{this._status!==J.STATUS_TERMINATED&&K.warn(w)})}terminate(r={}){K.debug("terminate()");const n=r.cause||ue.causes.BYE,o=qe.cloneArray(r.extraHeaders),a=r.body;let t,s=r.status_code,p=r.reason_phrase;if(this._status===J.STATUS_TERMINATED)throw new Gs.InvalidStateError(this._status);switch(this._status){case J.STATUS_NULL:case J.STATUS_INVITE_SENT:case J.STATUS_1XX_RECEIVED:if(K.debug("canceling session"),s&&(s<200||s>=700))throw new TypeError(`Invalid status_code: ${s}`);s&&(p=p||ue.REASON_PHRASE[s]||"",t=`SIP ;cause=${s} ;text="${p}"`),this._status===J.STATUS_NULL||this._status===J.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=t):this._status===J.STATUS_1XX_RECEIVED&&this._request.cancel(t),this._status=J.STATUS_CANCELED,this._failed("local",null,ue.causes.CANCELED);break;case J.STATUS_WAITING_FOR_ANSWER:case J.STATUS_ANSWERED:if(K.debug("rejecting session"),s=s||480,s<300||s>=700)throw new TypeError(`Invalid status_code: ${s}`);this._request.reply(s,p,o,a),this._failed("local",null,ue.causes.REJECTED);break;case J.STATUS_WAITING_FOR_ACK:case J.STATUS_CONFIRMED:if(K.debug("terminating session"),p=r.reason_phrase||ue.REASON_PHRASE[s]||"",s&&(s<200||s>=700))throw new TypeError(`Invalid status_code: ${s}`);if(s&&o.push(`Reason: SIP ;cause=${s}; text="${p}"`),this._status===J.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==Tf.C.STATUS_TERMINATED){const h=this._dialog;this.receiveRequest=({method:d})=>{d===ue.ACK&&(this.sendRequest(ue.BYE,{extraHeaders:o,body:a}),h.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===Tf.C.STATUS_TERMINATED&&(this.sendRequest(ue.BYE,{extraHeaders:o,body:a}),h.terminate())}),this._ended("local",null,n),this._dialog=h,this._ua.newDialog(h)}else this.sendRequest(ue.BYE,{extraHeaders:o,body:a}),this._ended("local",null,n)}}sendDTMF(r,n={}){K.debug("sendDTMF() | tones: %s",r);let o=0,a=n.duration||null,t=n.interToneGap||null;const s=n.transportType||ue.DTMF_TRANSPORT.INFO;if(r===void 0)throw new TypeError("Not enough arguments");if(this._status!==J.STATUS_CONFIRMED&&this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_1XX_RECEIVED)throw new Gs.InvalidStateError(this._status);if(s!==ue.DTMF_TRANSPORT.INFO&&s!==ue.DTMF_TRANSPORT.RFC2833)throw new TypeError(`invalid transportType: ${s}`);if(typeof r=="number"&&(r=r.toString()),!r||typeof r!="string"||!r.match(/^[0-9A-DR#*,]+$/i))throw new TypeError(`Invalid tones: ${r}`);if(a&&!qe.isDecimal(a))throw new TypeError(`Invalid tone duration: ${a}`);if(a?a<wt.C.MIN_DURATION?(K.debug(`"duration" value is lower than the minimum allowed, setting it to ${wt.C.MIN_DURATION} milliseconds`),a=wt.C.MIN_DURATION):a>wt.C.MAX_DURATION?(K.debug(`"duration" value is greater than the maximum allowed, setting it to ${wt.C.MAX_DURATION} milliseconds`),a=wt.C.MAX_DURATION):a=Math.abs(a):a=wt.C.DEFAULT_DURATION,n.duration=a,t&&!qe.isDecimal(t))throw new TypeError(`Invalid interToneGap: ${t}`);if(t?t<wt.C.MIN_INTER_TONE_GAP?(K.debug(`"interToneGap" value is lower than the minimum allowed, setting it to ${wt.C.MIN_INTER_TONE_GAP} milliseconds`),t=wt.C.MIN_INTER_TONE_GAP):t=Math.abs(t):t=wt.C.DEFAULT_INTER_TONE_GAP,s===ue.DTMF_TRANSPORT.RFC2833){const h=this._getDTMFRTPSender();h&&(r=h.toneBuffer+r,h.insertDTMF(r,a,t));return}if(this._tones){this._tones+=r;return}this._tones=r,p.call(this);function p(){let h;if(this._status===J.STATUS_TERMINATED||!this._tones||o>=this._tones.length){this._tones=null;return}const d=this._tones[o];if(o+=1,d===",")h=2e3;else{const g=new wt(this);n.eventHandlers={onFailed:()=>{this._tones=null}},g.send(d,n),h=a+t}setTimeout(p.bind(this),h)}}sendInfo(r,n,o={}){if(K.debug("sendInfo()"),this._status!==J.STATUS_CONFIRMED&&this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_1XX_RECEIVED)throw new Gs.InvalidStateError(this._status);new Ef(this).send(r,n,o)}mute(r={audio:!0,video:!1}){K.debug("mute()");let n=!1,o=!1;this._audioMuted===!1&&r.audio&&(n=!0,this._audioMuted=!0,this._toggleMuteAudio(!0)),this._videoMuted===!1&&r.video&&(o=!0,this._videoMuted=!0,this._toggleMuteVideo(!0)),(n===!0||o===!0)&&this._onmute({audio:n,video:o})}unmute(r={audio:!0,video:!0}){K.debug("unmute()");let n=!1,o=!1;this._audioMuted===!0&&r.audio&&(n=!0,this._audioMuted=!1,this._localHold===!1&&this._toggleMuteAudio(!1)),this._videoMuted===!0&&r.video&&(o=!0,this._videoMuted=!1,this._localHold===!1&&this._toggleMuteVideo(!1)),(n===!0||o===!0)&&this._onunmute({audio:n,video:o})}hold(r={},n){if(K.debug("hold()"),this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_CONFIRMED||this._localHold===!0||!this._isReadyToReOffer())return!1;this._localHold=!0,this._onhold("local");const o={succeeded:()=>{n&&n()},failed:()=>{this.terminate({cause:ue.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Hold Failed"})}};return r.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,extraHeaders:r.extraHeaders}):this._sendReinvite({eventHandlers:o,extraHeaders:r.extraHeaders}),!0}unhold(r={},n){if(K.debug("unhold()"),this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_CONFIRMED||this._localHold===!1||!this._isReadyToReOffer())return!1;this._localHold=!1,this._onunhold("local");const o={succeeded:()=>{n&&n()},failed:()=>{this.terminate({cause:ue.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Unhold Failed"})}};return r.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:o,extraHeaders:r.extraHeaders}):this._sendReinvite({eventHandlers:o,extraHeaders:r.extraHeaders}),!0}renegotiate(r={},n){K.debug("renegotiate()");const o=r.rtcOfferConstraints||null;if(this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_CONFIRMED||!this._isReadyToReOffer())return!1;const a={succeeded:()=>{n&&n()},failed:()=>{this.terminate({cause:ue.causes.WEBRTC_ERROR,status_code:500,reason_phrase:"Media Renegotiation Failed"})}};return this._setLocalMediaStatus(),r.useUpdate?this._sendUpdate({sdpOffer:!0,eventHandlers:a,rtcOfferConstraints:o,extraHeaders:r.extraHeaders}):this._sendReinvite({eventHandlers:a,rtcOfferConstraints:o,extraHeaders:r.extraHeaders}),!0}refer(r,n){K.debug("refer()");const o=r;if(this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_CONFIRMED)return!1;if(r=this._ua.normalizeTarget(r),!r)throw new TypeError(`Invalid target: ${o}`);const a=new Fm(this);a.sendRefer(r,n);const t=a.id;return this._referSubscribers[t]=a,a.on("requestFailed",()=>{delete this._referSubscribers[t]}),a.on("accepted",()=>{delete this._referSubscribers[t]}),a.on("failed",()=>{delete this._referSubscribers[t]}),a}sendRequest(r,n){return K.debug("sendRequest()"),this._dialog.sendRequest(r,n)}receiveRequest(r){if(K.debug("receiveRequest()"),r.method===ue.CANCEL)(this._status===J.STATUS_WAITING_FOR_ANSWER||this._status===J.STATUS_ANSWERED)&&(this._status=J.STATUS_CANCELED,this._request.reply(487),this._failed("remote",r,ue.causes.CANCELED));else switch(r.method){case ue.ACK:if(this._status!==J.STATUS_WAITING_FOR_ACK)return;if(this._status=J.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!r.body){this.terminate({cause:ue.causes.MISSING_SDP,status_code:400});break}const n={originator:"remote",type:"answer",sdp:r.body};K.debug('emit "sdp"'),this.emit("sdp",n);const o=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(o)).then(()=>{this._is_confirmed||this._confirmed("remote",r)}).catch(a=>{this.terminate({cause:ue.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)})}else this._is_confirmed||this._confirmed("remote",r);break;case ue.BYE:this._status===J.STATUS_CONFIRMED||this._status===J.STATUS_WAITING_FOR_ACK?(r.reply(200),this._ended("remote",r,ue.causes.BYE)):this._status===J.STATUS_INVITE_RECEIVED||this._status===J.STATUS_WAITING_FOR_ANSWER?(r.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",r,ue.causes.BYE)):r.reply(403,"Wrong Status");break;case ue.INVITE:this._status===J.STATUS_CONFIRMED?r.hasHeader("replaces")?this._receiveReplaces(r):this._receiveReinvite(r):r.reply(403,"Wrong Status");break;case ue.INFO:if(this._status===J.STATUS_1XX_RECEIVED||this._status===J.STATUS_WAITING_FOR_ANSWER||this._status===J.STATUS_ANSWERED||this._status===J.STATUS_WAITING_FOR_ACK||this._status===J.STATUS_CONFIRMED){const n=r.hasHeader("Content-Type")?r.getHeader("Content-Type").toLowerCase():void 0;n&&n.match(/^application\/dtmf-relay/i)?new wt(this).init_incoming(r):n!==void 0?new Ef(this).init_incoming(r):r.reply(415)}else r.reply(403,"Wrong Status");break;case ue.UPDATE:this._status===J.STATUS_CONFIRMED?this._receiveUpdate(r):r.reply(403,"Wrong Status");break;case ue.REFER:this._status===J.STATUS_CONFIRMED?this._receiveRefer(r):r.reply(403,"Wrong Status");break;case ue.NOTIFY:this._status===J.STATUS_CONFIRMED?this._receiveNotify(r):r.reply(403,"Wrong Status");break;default:r.reply(501)}}onTransportError(){K.warn("onTransportError()"),this._status!==J.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:ue.causes.CONNECTION_ERROR,cause:ue.causes.CONNECTION_ERROR})}onRequestTimeout(){K.warn("onRequestTimeout()"),this._status!==J.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:ue.causes.REQUEST_TIMEOUT,cause:ue.causes.REQUEST_TIMEOUT})}onDialogError(){K.warn("onDialogError()"),this._status!==J.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:ue.causes.DIALOG_ERROR,cause:ue.causes.DIALOG_ERROR})}newDTMF(r){K.debug("newDTMF()"),this.emit("newDTMF",r)}newInfo(r){K.debug("newInfo()"),this.emit("newInfo",r)}_isReadyToReOffer(){return this._rtcReady?this._dialog?this._dialog.uac_pending_reply===!0||this._dialog.uas_pending_reply===!0?(K.debug("_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress"),!1):!0:(K.debug("_isReadyToReOffer() | session not established yet"),!1):(K.debug("_isReadyToReOffer() | internal WebRTC status not ready"),!1)}_close(){if(K.debug("close()"),this._localMediaStream&&this._localMediaStreamLocallyGenerated&&(K.debug("close() | closing local MediaStream"),qe.closeMediaStream(this._localMediaStream)),this._status!==J.STATUS_TERMINATED){if(this._status=J.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(r){K.warn("close() | error closing the RTCPeerConnection: %o",r)}for(const r in this._timers)Object.prototype.hasOwnProperty.call(this._timers,r)&&clearTimeout(this._timers[r]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const r in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,r)&&(this._earlyDialogs[r].terminate(),delete this._earlyDialogs[r]);for(const r in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,r)&&delete this._referSubscribers[r];this._ua.destroyRTCSession(this)}}_setInvite2xxTimer(r,n){let o=xr.T1;function a(){this._status===J.STATUS_WAITING_FOR_ACK&&(r.reply(200,null,[`Contact: ${this._contact}`],n),o<xr.T2&&(o=o*2,o>xr.T2&&(o=xr.T2)),this._timers.invite2xxTimer=setTimeout(a.bind(this),o))}this._timers.invite2xxTimer=setTimeout(a.bind(this),o)}_setACKTimer(){this._timers.ackTimer=setTimeout(()=>{this._status===J.STATUS_WAITING_FOR_ACK&&(K.debug("no ACK received, terminating the session"),clearTimeout(this._timers.invite2xxTimer),this.sendRequest(ue.BYE),this._ended("remote",null,ue.causes.NO_ACK))},xr.TIMER_H)}_createRTCConnection(r,n){this._connection=new RTCPeerConnection(r,n),this._connection.addEventListener("iceconnectionstatechange",()=>{this._connection.iceConnectionState==="failed"&&this.terminate({cause:ue.causes.RTP_TIMEOUT,status_code:408,reason_phrase:ue.causes.RTP_TIMEOUT})}),K.debug('emit "peerconnection"'),this.emit("peerconnection",{peerconnection:this._connection})}_createLocalDescription(r,n){if(K.debug("createLocalDescription()"),r!=="offer"&&r!=="answer")throw new Error(`createLocalDescription() | invalid type "${r}"`);const o=this._connection;return this._rtcReady=!1,Promise.resolve().then(()=>r==="offer"?o.createOffer(n).catch(a=>(K.warn('emit "peerconnection:createofferfailed" [error:%o]',a),this.emit("peerconnection:createofferfailed",a),Promise.reject(a))):o.createAnswer(n).catch(a=>(K.warn('emit "peerconnection:createanswerfailed" [error:%o]',a),this.emit("peerconnection:createanswerfailed",a),Promise.reject(a)))).then(a=>o.setLocalDescription(a).catch(t=>(this._rtcReady=!0,K.warn('emit "peerconnection:setlocaldescriptionfailed" [error:%o]',t),this.emit("peerconnection:setlocaldescriptionfailed",t),Promise.reject(t)))).then(()=>{const a=n&&n.iceRestart;if(o.iceGatheringState==="complete"&&!a||o.iceGatheringState==="gathering"&&this._iceReady){this._rtcReady=!0;const t={originator:"local",type:r,sdp:o.localDescription.sdp};return K.debug('emit "sdp"'),this.emit("sdp",t),Promise.resolve(t.sdp)}return new Promise(t=>{let s=!1,p,h;this._iceReady=!1;const d=()=>{o.removeEventListener("icecandidate",p),o.removeEventListener("icegatheringstatechange",h),s=!0,this._rtcReady=!0,this._iceReady=!0;const g={originator:"local",type:r,sdp:o.localDescription.sdp};K.debug('emit "sdp"'),this.emit("sdp",g),t(g.sdp)};o.addEventListener("icecandidate",p=g=>{const v=g.candidate;v?this.emit("icecandidate",{candidate:v,ready:d}):s||d()}),o.addEventListener("icegatheringstatechange",h=()=>{o.iceGatheringState==="complete"&&!s&&d()})})})}_createDialog(r,n,o){const a=n==="UAS"?r.to_tag:r.from_tag,t=n==="UAS"?r.from_tag:r.to_tag,s=r.call_id+a+t;let p=this._earlyDialogs[s];if(o)return p?!0:(p=new Wl(this,r,n,Wl.C.STATUS_EARLY),p.error?(K.debug(p.error),this._failed("remote",r,ue.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[s]=p,!0));{if(this._from_tag=r.from_tag,this._to_tag=r.to_tag,p)return p.update(r,n),this._dialog=p,delete this._earlyDialogs[s],!0;const h=new Wl(this,r,n);return h.error?(K.debug(h.error),this._failed("remote",r,ue.causes.INTERNAL_ERROR),!1):(this._dialog=h,!0)}}_receiveReinvite(r){K.debug("receiveReinvite()");const n=r.hasHeader("Content-Type")?r.getHeader("Content-Type").toLowerCase():void 0,o={request:r,callback:void 0,reject:t.bind(this)};let a=!1;function t(p={}){a=!0;const h=p.status_code||403,d=p.reason_phrase||"",g=qe.cloneArray(p.extraHeaders);if(this._status!==J.STATUS_CONFIRMED)return!1;if(h<300||h>=700)throw new TypeError(`Invalid status_code: ${h}`);r.reply(h,d,g)}if(this.emit("reinvite",o),a)return;if(this._late_sdp=!1,!r.body){this._late_sdp=!0,this._remoteHold&&(this._remoteHold=!1,this._onunhold("remote")),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",this._rtcOfferConstraints)).then(p=>{s.call(this,p)}).catch(()=>{r.reply(500)});return}if(n!=="application/sdp"){K.debug("invalid Content-Type"),r.reply(415);return}this._processInDialogSdpOffer(r).then(p=>{this._status!==J.STATUS_TERMINATED&&s.call(this,p)}).catch(p=>{K.warn(p)});function s(p){const h=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(r,h),this._late_sdp&&(p=this._mangleOffer(p)),r.reply(200,null,h,p,()=>{this._status=J.STATUS_WAITING_FOR_ACK,this._setInvite2xxTimer(r,p),this._setACKTimer()}),typeof o.callback=="function"&&o.callback()}}_receiveUpdate(r){K.debug("receiveUpdate()");const n=r.hasHeader("Content-Type")?r.getHeader("Content-Type").toLowerCase():void 0,o={request:r,callback:void 0,reject:t.bind(this)};let a=!1;function t(p={}){a=!0;const h=p.status_code||403,d=p.reason_phrase||"",g=qe.cloneArray(p.extraHeaders);if(this._status!==J.STATUS_CONFIRMED)return!1;if(h<300||h>=700)throw new TypeError(`Invalid status_code: ${h}`);r.reply(h,d,g)}if(this.emit("update",o),a)return;if(!r.body){s.call(this,null);return}if(n!=="application/sdp"){K.debug("invalid Content-Type"),r.reply(415);return}this._processInDialogSdpOffer(r).then(p=>{this._status!==J.STATUS_TERMINATED&&s.call(this,p)}).catch(p=>{K.warn(p)});function s(p){const h=[`Contact: ${this._contact}`];this._handleSessionTimersInIncomingRequest(r,h),r.reply(200,null,h,p),typeof o.callback=="function"&&o.callback()}}_processInDialogSdpOffer(r){K.debug("_processInDialogSdpOffer()");const n=r.parseSDP();let o=!1;for(const s of n.media){if(Yl.indexOf(s.type)===-1)continue;const p=s.direction||n.direction||"sendrecv";if(p==="sendonly"||p==="inactive")o=!0;else{o=!1;break}}const a={originator:"remote",type:"offer",sdp:r.body};K.debug('emit "sdp"'),this.emit("sdp",a);const t=new RTCSessionDescription({type:"offer",sdp:a.sdp});return this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._status===J.STATUS_TERMINATED)throw new Error("terminated");return this._connection.setRemoteDescription(t).catch(s=>{throw r.reply(488),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',s),this.emit("peerconnection:setremotedescriptionfailed",s),s})}).then(()=>{if(this._status===J.STATUS_TERMINATED)throw new Error("terminated");this._remoteHold===!0&&o===!1?(this._remoteHold=!1,this._onunhold("remote")):this._remoteHold===!1&&o===!0&&(this._remoteHold=!0,this._onhold("remote"))}).then(()=>{if(this._status===J.STATUS_TERMINATED)throw new Error("terminated");return this._createLocalDescription("answer",this._rtcAnswerConstraints).catch(s=>{throw r.reply(500),K.warn('emit "peerconnection:createtelocaldescriptionfailed" [error:%o]',s),s})}).catch(s=>{K.warn("_processInDialogSdpOffer() failed [error: %o]",s)}),this._connectionPromiseQueue}_receiveRefer(r){if(K.debug("receiveRefer()"),!r.refer_to){K.debug("no Refer-To header field present in REFER"),r.reply(400);return}if(r.refer_to.uri.scheme!==ue.SIP){K.debug("Refer-To header field points to a non-SIP URI scheme"),r.reply(416);return}r.reply(202);const n=new Hm(this,r.cseq);K.debug('emit "refer"'),this.emit("refer",{request:r,accept:(t,s)=>{o.call(this,t,s)},reject:()=>{a.call(this)}});function o(t,s={}){if(t=typeof t=="function"?t:null,this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_CONFIRMED)return!1;const p=new gu(this._ua);if(p.on("progress",({response:h})=>{n.notify(h.status_code,h.reason_phrase)}),p.on("accepted",({response:h})=>{n.notify(h.status_code,h.reason_phrase)}),p.on("_failed",({message:h,cause:d})=>{h?n.notify(h.status_code,h.reason_phrase):n.notify(487,d)}),r.refer_to.uri.hasHeader("replaces")){const h=decodeURIComponent(r.refer_to.uri.getHeader("replaces"));s.extraHeaders=qe.cloneArray(s.extraHeaders),s.extraHeaders.push(`Replaces: ${h}`)}p.connect(r.refer_to.uri.toAor(),s,t)}function a(){n.notify(603)}}_receiveNotify(r){switch(K.debug("receiveNotify()"),r.event||r.reply(400),r.event.event){case"refer":{let n,o;if(r.event.params&&r.event.params.id)n=r.event.params.id,o=this._referSubscribers[n];else if(Object.keys(this._referSubscribers).length===1)o=this._referSubscribers[Object.keys(this._referSubscribers)[0]];else{r.reply(400,"Missing event id parameter");return}if(!o){r.reply(481,"Subscription does not exist");return}o.receiveNotify(r),r.reply(200);break}default:r.reply(489)}}_receiveReplaces(r){K.debug("receiveReplaces()");function n(a){if(this._status!==J.STATUS_WAITING_FOR_ACK&&this._status!==J.STATUS_CONFIRMED)return!1;const t=new gu(this._ua);t.on("confirmed",()=>{this.terminate()}),t.init_incoming(r,a)}function o(){K.debug("Replaced INVITE rejected by the user"),r.reply(486)}this.emit("replaces",{request:r,accept:a=>{n.call(this,a)},reject:()=>{o.call(this)}})}_sendInitialRequest(r,n,o){const a=new $m(this._ua,this._request,{onRequestTimeout:()=>{this.onRequestTimeout()},onTransportError:()=>{this.onTransportError()},onAuthenticated:t=>{this._request=t},onReceiveResponse:t=>{this._receiveInviteResponse(t)}});Promise.resolve().then(()=>{if(o)return o;if(r.audio||r.video)return this._localMediaStreamLocallyGenerated=!0,navigator.mediaDevices.getUserMedia(r).catch(t=>{throw this._status===J.STATUS_TERMINATED?new Error("terminated"):(this._failed("local",null,ue.causes.USER_DENIED_MEDIA_ACCESS),K.warn('emit "getusermediafailed" [error:%o]',t),this.emit("getusermediafailed",t),t)})}).then(t=>{if(this._status===J.STATUS_TERMINATED)throw new Error("terminated");return this._localMediaStream=t,t&&t.getTracks().forEach(s=>{this._connection.addTrack(s,t)}),this._connecting(this._request),this._createLocalDescription("offer",n).catch(s=>{throw this._failed("local",null,ue.causes.WEBRTC_ERROR),s})}).then(t=>{if(this._is_canceled||this._status===J.STATUS_TERMINATED)throw new Error("terminated");this._request.body=t,this._status=J.STATUS_INVITE_SENT,K.debug('emit "sending" [request:%o]',this._request),this.emit("sending",{request:this._request}),a.send()}).catch(t=>{this._status!==J.STATUS_TERMINATED&&K.warn(t)})}_getDTMFRTPSender(){const r=this._connection.getSenders().find(n=>n.track&&n.track.kind==="audio");if(!(r&&r.dtmf)){K.warn("sendDTMF() | no local audio track to send DTMF with");return}return r.dtmf}_receiveInviteResponse(r){if(K.debug("receiveInviteResponse()"),this._dialog&&r.status_code>=200&&r.status_code<=299)if(this._dialog.id.call_id===r.call_id&&this._dialog.id.local_tag===r.from_tag&&this._dialog.id.remote_tag===r.to_tag){this.sendRequest(ue.ACK);return}else{const n=new Wl(this,r,"UAC");if(n.error!==void 0){K.debug(n.error);return}this.sendRequest(ue.ACK),this.sendRequest(ue.BYE);return}if(this._is_canceled){r.status_code>=100&&r.status_code<200?this._request.cancel(this._cancel_reason):r.status_code>=200&&r.status_code<299&&this._acceptAndTerminate(r);return}if(!(this._status!==J.STATUS_INVITE_SENT&&this._status!==J.STATUS_1XX_RECEIVED))switch(!0){case/^100$/.test(r.status_code):this._status=J.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(r.status_code):{if(!r.to_tag){K.debug("1xx response received without to tag");break}if(r.hasHeader("contact")&&!this._createDialog(r,"UAC",!0))break;if(this._status=J.STATUS_1XX_RECEIVED,!r.body){this._progress("remote",r);break}const n={originator:"remote",type:"answer",sdp:r.body};K.debug('emit "sdp"'),this.emit("sdp",n);const o=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(o)).then(()=>this._progress("remote",r)).catch(a=>{K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)});break}case/^2[0-9]{2}$/.test(r.status_code):{if(this._status=J.STATUS_CONFIRMED,!r.body){this._acceptAndTerminate(r,400,ue.causes.MISSING_SDP),this._failed("remote",r,ue.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(r,"UAC"))break;const n={originator:"remote",type:"answer",sdp:r.body};K.debug('emit "sdp"'),this.emit("sdp",n);const o=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._connection.signalingState==="stable")return this._connection.createOffer(this._rtcOfferConstraints).then(a=>this._connection.setLocalDescription(a)).catch(a=>{this._acceptAndTerminate(r,500,a.toString()),this._failed("local",r,ue.causes.WEBRTC_ERROR)})}).then(()=>{this._connection.setRemoteDescription(o).then(()=>{this._handleSessionTimersInIncomingResponse(r),this._accepted("remote",r),this.sendRequest(ue.ACK),this._confirmed("local",null)}).catch(a=>{this._acceptAndTerminate(r,488,"Not Acceptable Here"),this._failed("remote",r,ue.causes.BAD_MEDIA_DESCRIPTION),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)})});break}default:{const n=qe.sipErrorCause(r.status_code);this._failed("remote",r,n)}}}_sendReinvite(r={}){K.debug("sendReinvite()");const n=qe.cloneArray(r.extraHeaders),o=qe.cloneObject(r.eventHandlers),a=r.rtcOfferConstraints||this._rtcOfferConstraints||null;let t=!1;n.push(`Contact: ${this._contact}`),n.push("Content-Type: application/sdp"),this._sessionTimers.running&&n.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",a)).then(h=>{h=this._mangleOffer(h);const d={originator:"local",type:"offer",sdp:h};K.debug('emit "sdp"'),this.emit("sdp",d),this.sendRequest(ue.INVITE,{extraHeaders:n,body:h,eventHandlers:{onSuccessResponse:g=>{s.call(this,g),t=!0},onErrorResponse:g=>{p.call(this,g)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{p()});function s(h){if(this._status===J.STATUS_TERMINATED||(this.sendRequest(ue.ACK),t))return;if(this._handleSessionTimersInIncomingResponse(h),h.body){if(!h.hasHeader("Content-Type")||h.getHeader("Content-Type").toLowerCase()!=="application/sdp"){p.call(this);return}}else{p.call(this);return}const d={originator:"remote",type:"answer",sdp:h.body};K.debug('emit "sdp"'),this.emit("sdp",d);const g=new RTCSessionDescription({type:"answer",sdp:d.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(g)).then(()=>{o.succeeded&&o.succeeded(h)}).catch(v=>{p.call(this),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',v),this.emit("peerconnection:setremotedescriptionfailed",v)})}function p(h){o.failed&&o.failed(h)}}_sendUpdate(r={}){K.debug("sendUpdate()");const n=qe.cloneArray(r.extraHeaders),o=qe.cloneObject(r.eventHandlers),a=r.rtcOfferConstraints||this._rtcOfferConstraints||null,t=r.sdpOffer||!1;let s=!1;n.push(`Contact: ${this._contact}`),this._sessionTimers.running&&n.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${this._sessionTimers.refresher?"uac":"uas"}`),t?(n.push("Content-Type: application/sdp"),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._createLocalDescription("offer",a)).then(d=>{d=this._mangleOffer(d);const g={originator:"local",type:"offer",sdp:d};K.debug('emit "sdp"'),this.emit("sdp",g),this.sendRequest(ue.UPDATE,{extraHeaders:n,body:d,eventHandlers:{onSuccessResponse:v=>{p.call(this,v),s=!0},onErrorResponse:v=>{h.call(this,v)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}})}).catch(()=>{h.call(this)})):this.sendRequest(ue.UPDATE,{extraHeaders:n,eventHandlers:{onSuccessResponse:d=>{p.call(this,d)},onErrorResponse:d=>{h.call(this,d)},onTransportError:()=>{this.onTransportError()},onRequestTimeout:()=>{this.onRequestTimeout()},onDialogError:()=>{this.onDialogError()}}});function p(d){if(this._status!==J.STATUS_TERMINATED&&!s)if(this._handleSessionTimersInIncomingResponse(d),t){if(d.body){if(!d.hasHeader("Content-Type")||d.getHeader("Content-Type").toLowerCase()!=="application/sdp"){h.call(this);return}}else{h.call(this);return}const g={originator:"remote",type:"answer",sdp:d.body};K.debug('emit "sdp"'),this.emit("sdp",g);const v=new RTCSessionDescription({type:"answer",sdp:g.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(v)).then(()=>{o.succeeded&&o.succeeded(d)}).catch(E=>{h.call(this),K.warn('emit "peerconnection:setremotedescriptionfailed" [error:%o]',E),this.emit("peerconnection:setremotedescriptionfailed",E)})}else o.succeeded&&o.succeeded(d)}function h(d){o.failed&&o.failed(d)}}_acceptAndTerminate(r,n,o){K.debug("acceptAndTerminate()");const a=[];n&&(o=o||ue.REASON_PHRASE[n]||"",a.push(`Reason: SIP ;cause=${n}; text="${o}"`)),(this._dialog||this._createDialog(r,"UAC"))&&(this.sendRequest(ue.ACK),this.sendRequest(ue.BYE,{extraHeaders:a})),this._status=J.STATUS_TERMINATED}_mangleOffer(r){if(!this._localHold&&!this._remoteHold)return r;if(r=vf.parse(r),this._localHold&&!this._remoteHold){K.debug("mangleOffer() | me on hold, mangling offer");for(const n of r.media)Yl.indexOf(n.type)!==-1&&(n.direction?n.direction==="sendrecv"?n.direction="sendonly":n.direction==="recvonly"&&(n.direction="inactive"):n.direction="sendonly")}else if(this._localHold&&this._remoteHold){K.debug("mangleOffer() | both on hold, mangling offer");for(const n of r.media)Yl.indexOf(n.type)!==-1&&(n.direction="inactive")}else if(this._remoteHold){K.debug("mangleOffer() | remote on hold, mangling offer");for(const n of r.media)Yl.indexOf(n.type)!==-1&&(n.direction?n.direction==="sendrecv"?n.direction="recvonly":n.direction==="recvonly"&&(n.direction="inactive"):n.direction="recvonly")}return vf.write(r)}_setLocalMediaStatus(){let r=!0,n=!0;(this._localHold||this._remoteHold)&&(r=!1,n=!1),this._audioMuted&&(r=!1),this._videoMuted&&(n=!1),this._toggleMuteAudio(!r),this._toggleMuteVideo(!n)}_handleSessionTimersInIncomingRequest(r,n){if(!this._sessionTimers.enabled)return;let o;r.session_expires&&r.session_expires>=ue.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=r.session_expires,o=r.session_expires_refresher||"uas"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,o="uas"),n.push(`Session-Expires: ${this._sessionTimers.currentExpires};refresher=${o}`),this._sessionTimers.refresher=o==="uas",this._runSessionTimer()}_handleSessionTimersInIncomingResponse(r){if(!this._sessionTimers.enabled)return;let n;r.session_expires&&r.session_expires>=ue.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=r.session_expires,n=r.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,n="uac"),this._sessionTimers.refresher=n==="uac",this._runSessionTimer()}_runSessionTimer(){const r=this._sessionTimers.currentExpires;this._sessionTimers.running=!0,clearTimeout(this._sessionTimers.timer),this._sessionTimers.refresher?this._sessionTimers.timer=setTimeout(()=>{this._status!==J.STATUS_TERMINATED&&this._isReadyToReOffer()&&(K.debug("runSessionTimer() | sending session refresh request"),this._sessionTimers.refreshMethod===ue.UPDATE?this._sendUpdate():this._sendReinvite())},r*500):this._sessionTimers.timer=setTimeout(()=>{this._status!==J.STATUS_TERMINATED&&(K.warn("runSessionTimer() | timer expired, terminating the session"),this.terminate({cause:ue.causes.REQUEST_TIMEOUT,status_code:408,reason_phrase:"Session Timer Expired"}))},r*1100)}_toggleMuteAudio(r){const n=this._connection.getSenders().filter(o=>o.track&&o.track.kind==="audio");for(const o of n)o.track.enabled=!r}_toggleMuteVideo(r){const n=this._connection.getSenders().filter(o=>o.track&&o.track.kind==="video");for(const o of n)o.track.enabled=!r}_newRTCSession(r,n){K.debug("newRTCSession()"),this._ua.newRTCSession(this,{originator:r,session:this,request:n})}_connecting(r){K.debug("session connecting"),K.debug('emit "connecting"'),this.emit("connecting",{request:r})}_progress(r,n){K.debug("session progress"),K.debug('emit "progress"'),this.emit("progress",{originator:r,response:n||null})}_accepted(r,n){K.debug("session accepted"),this._start_time=new Date,K.debug('emit "accepted"'),this.emit("accepted",{originator:r,response:n||null})}_confirmed(r,n){K.debug("session confirmed"),this._is_confirmed=!0,K.debug('emit "confirmed"'),this.emit("confirmed",{originator:r,ack:n||null})}_ended(r,n,o){K.debug("session ended"),this._end_time=new Date,this._close(),K.debug('emit "ended"'),this.emit("ended",{originator:r,message:n||null,cause:o})}_failed(r,n,o){K.debug("session failed"),K.debug('emit "_failed"'),this.emit("_failed",{originator:r,message:n||null,cause:o}),this._close(),K.debug('emit "failed"'),this.emit("failed",{originator:r,message:n||null,cause:o})}_onhold(r){K.debug("session onhold"),this._setLocalMediaStatus(),K.debug('emit "hold"'),this.emit("hold",{originator:r})}_onunhold(r){K.debug("session onunhold"),this._setLocalMediaStatus(),K.debug('emit "unhold"'),this.emit("unhold",{originator:r})}_onmute({audio:r,video:n}){K.debug("session onmute"),this._setLocalMediaStatus(),K.debug('emit "muted"'),this.emit("muted",{audio:r,video:n})}_onunmute({audio:r,video:n}){K.debug("session onunmute"),this._setLocalMediaStatus(),K.debug('emit "unmuted"'),this.emit("unmuted",{audio:r,video:n})}};const qm=vt(Sf),Vm=ot.EventEmitter,jm=it,Pa=we,Bm=Kt,Lr=ft(),Gm=Rn,Cf=us,Km=ls(),zl=new jm("Message");var Wm=class extends Vm{constructor(r){super(),this._ua=r,this._request=null,this._closed=!1,this._direction=null,this._local_identity=null,this._remote_identity=null,this._is_replied=!1,this._data={}}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}send(r,n,o={}){const a=r;if(r===void 0||n===void 0)throw new TypeError("Not enough arguments");if(r=this._ua.normalizeTarget(r),!r)throw new TypeError(`Invalid target: ${a}`);const t=Lr.cloneArray(o.extraHeaders),s=Lr.cloneObject(o.eventHandlers),p=o.contentType||"text/plain",h={};o.fromUserName&&(h.from_uri=new Km("sip",o.fromUserName,this._ua.configuration.uri.host),t.push(`P-Preferred-Identity: ${this._ua.configuration.uri.toString()}`)),o.fromDisplayName&&(h.from_display_name=o.fromDisplayName);for(const g in s)Object.prototype.hasOwnProperty.call(s,g)&&this.on(g,s[g]);t.push(`Content-Type: ${p}`),this._request=new Bm.OutgoingRequest(Pa.MESSAGE,r,this._ua,h,t),n&&(this._request.body=n);const d=new Gm(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:g=>{this._receiveResponse(g)}});this._newMessage("local",this._request),d.send()}init_incoming(r){this._request=r,this._newMessage("remote",r),this._is_replied||(this._is_replied=!0,r.reply(200)),this._close()}accept(r={}){const n=Lr.cloneArray(r.extraHeaders),o=r.body;if(this._direction!=="incoming")throw new Cf.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,n,o)}reject(r={}){const n=r.status_code||480,o=r.reason_phrase,a=Lr.cloneArray(r.extraHeaders),t=r.body;if(this._direction!=="incoming")throw new Cf.NotSupportedError('"reject" not supported for outgoing Message');if(this._is_replied)throw new Error("incoming Message already replied");if(n<300||n>=700)throw new TypeError(`Invalid status_code: ${n}`);this._is_replied=!0,this._request.reply(n,o,a,t)}_receiveResponse(r){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(r.status_code):break;case/^2[0-9]{2}$/.test(r.status_code):this._succeeded("remote",r);break;default:{const n=Lr.sipErrorCause(r.status_code);this._failed("remote",r,n);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,Pa.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,Pa.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newMessage(r,n){r==="remote"?(this._direction="incoming",this._local_identity=n.to,this._remote_identity=n.from):r==="local"&&(this._direction="outgoing",this._local_identity=n.from,this._remote_identity=n.to),this._ua.newMessage(this,{originator:r,message:this,request:n})}_failed(r,n,o){zl.debug("MESSAGE failed"),this._close(),zl.debug('emit "failed"'),this.emit("failed",{originator:r,response:n||null,cause:o})}_succeeded(r,n){zl.debug("MESSAGE succeeded"),this._close(),zl.debug('emit "succeeded"'),this.emit("succeeded",{originator:r,response:n})}};const Ym=ot.EventEmitter,zm=it,ka=we,Jm=Kt,$r=ft(),Xm=Rn,Af=us,Jl=new zm("Options");var Qm=class extends Ym{constructor(r){super(),this._ua=r,this._request=null,this._closed=!1,this._direction=null,this._local_identity=null,this._remote_identity=null,this._is_replied=!1,this._data={}}get direction(){return this._direction}get local_identity(){return this._local_identity}get remote_identity(){return this._remote_identity}send(r,n,o={}){const a=r;if(r===void 0)throw new TypeError("A target is required for OPTIONS");if(r=this._ua.normalizeTarget(r),!r)throw new TypeError(`Invalid target: ${a}`);const t=$r.cloneArray(o.extraHeaders),s=$r.cloneObject(o.eventHandlers),p=o.contentType||"application/sdp";for(const d in s)Object.prototype.hasOwnProperty.call(s,d)&&this.on(d,s[d]);t.push(`Content-Type: ${p}`),this._request=new Jm.OutgoingRequest(ka.OPTIONS,r,this._ua,null,t),n&&(this._request.body=n);const h=new Xm(this._ua,this._request,{onRequestTimeout:()=>{this._onRequestTimeout()},onTransportError:()=>{this._onTransportError()},onReceiveResponse:d=>{this._receiveResponse(d)}});this._newOptions("local",this._request),h.send()}init_incoming(r){this._request=r,this._newOptions("remote",r),this._is_replied||(this._is_replied=!0,r.reply(200)),this._close()}accept(r={}){const n=$r.cloneArray(r.extraHeaders),o=r.body;if(this._direction!=="incoming")throw new Af.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,n,o)}reject(r={}){const n=r.status_code||480,o=r.reason_phrase,a=$r.cloneArray(r.extraHeaders),t=r.body;if(this._direction!=="incoming")throw new Af.NotSupportedError('"reject" not supported for outgoing Options');if(this._is_replied)throw new Error("incoming Options already replied");if(n<300||n>=700)throw new TypeError(`Invalid status_code: ${n}`);this._is_replied=!0,this._request.reply(n,o,a,t)}_receiveResponse(r){if(!this._closed)switch(!0){case/^1[0-9]{2}$/.test(r.status_code):break;case/^2[0-9]{2}$/.test(r.status_code):this._succeeded("remote",r);break;default:{const n=$r.sipErrorCause(r.status_code);this._failed("remote",r,n);break}}}_onRequestTimeout(){this._closed||this._failed("system",null,ka.causes.REQUEST_TIMEOUT)}_onTransportError(){this._closed||this._failed("system",null,ka.causes.CONNECTION_ERROR)}_close(){this._closed=!0,this._ua.destroyMessage(this)}_newOptions(r,n){r==="remote"?(this._direction="incoming",this._local_identity=n.to,this._remote_identity=n.from):r==="local"&&(this._direction="outgoing",this._local_identity=n.from,this._remote_identity=n.to),this._ua.newOptions(this,{originator:r,message:this,request:n})}_failed(r,n,o){Jl.debug("OPTIONS failed"),this._close(),Jl.debug('emit "failed"'),this.emit("failed",{originator:r,response:n||null,cause:o})}_succeeded(r,n){Jl.debug("OPTIONS succeeded"),this._close(),Jl.debug('emit "succeeded"'),this.emit("succeeded",{originator:r,response:n})}},Ma={};const Zm=it,xa=ft(),eg=Gt(),Hr=new Zm("Socket");Ma.isSocket=c=>{if(Array.isArray(c))return!1;if(typeof c>"u")return Hr.warn("undefined JsSIP.Socket instance"),!1;try{if(!xa.isString(c.url))throw Hr.warn("missing or invalid JsSIP.Socket url property"),new Error("Missing or invalid JsSIP.Socket url property");if(!xa.isString(c.via_transport))throw Hr.warn("missing or invalid JsSIP.Socket via_transport property"),new Error("Missing or invalid JsSIP.Socket via_transport property");if(eg.parse(c.sip_uri,"SIP_URI")===-1)throw Hr.warn("missing or invalid JsSIP.Socket sip_uri property"),new Error("missing or invalid JsSIP.Socket sip_uri property")}catch{return!1}try{["connect","disconnect","send"].forEach(r=>{if(!xa.isFunction(c[r]))throw Hr.warn(`missing or invalid JsSIP.Socket method: ${r}`),new Error(`Missing or invalid JsSIP.Socket method: ${r}`)})}catch{return!1}return!0};const tg=it,sg=Ma,Rf=we,It=new tg("Transport"),Ut={STATUS_CONNECTED:0,STATUS_CONNECTING:1,STATUS_DISCONNECTED:2,SOCKET_STATUS_READY:0,SOCKET_STATUS_ERROR:1,recovery_options:{min_interval:Rf.CONNECTION_RECOVERY_MIN_INTERVAL,max_interval:Rf.CONNECTION_RECOVERY_MAX_INTERVAL}};var ng=class{constructor(r,n=Ut.recovery_options){It.debug("new()"),this.status=Ut.STATUS_DISCONNECTED,this.socket=null,this.sockets=[],this.recovery_options=n,this.recover_attempts=0,this.recovery_timer=null,this.close_requested=!1;try{this.textDecoder=new TextDecoder("utf8")}catch(o){It.warn(`cannot use TextDecoder: ${o}`)}if(typeof r>"u")throw new TypeError("Invalid argument. undefined 'sockets' argument");r instanceof Array||(r=[r]),r.forEach(function(o){if(!sg.isSocket(o.socket))throw new TypeError("Invalid argument. invalid 'JsSIP.Socket' instance");if(o.weight&&!Number(o.weight))throw new TypeError("Invalid argument. 'weight' attribute is not a number");this.sockets.push({socket:o.socket,weight:o.weight||0,status:Ut.SOCKET_STATUS_READY})},this),this._getSocket()}get via_transport(){return this.socket.via_transport}get url(){return this.socket.url}get sip_uri(){return this.socket.sip_uri}connect(){if(It.debug("connect()"),this.isConnected()){It.debug("Transport is already connected");return}else if(this.isConnecting()){It.debug("Transport is connecting");return}this.close_requested=!1,this.status=Ut.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())}disconnect(){It.debug("close()"),this.close_requested=!0,this.recover_attempts=0,this.status=Ut.STATUS_DISCONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.socket.onconnect=()=>{},this.socket.ondisconnect=()=>{},this.socket.ondata=()=>{},this.socket.disconnect(),this.ondisconnect({socket:this.socket,error:!1})}send(r){if(It.debug("send()"),!this.isConnected())return It.warn("unable to send message, transport is not connected"),!1;const n=r.toString();return It.debug(`sending message:
|
116
116
|
|
117
117
|
${n}
|
118
118
|
`),this.socket.send(n)}isConnected(){return this.status===Ut.STATUS_CONNECTED}isConnecting(){return this.status===Ut.STATUS_CONNECTING}_reconnect(){this.recover_attempts+=1;let r=Math.floor(Math.random()*Math.pow(2,this.recover_attempts)+1);r<this.recovery_options.min_interval?r=this.recovery_options.min_interval:r>this.recovery_options.max_interval&&(r=this.recovery_options.max_interval),It.debug(`reconnection attempt: ${this.recover_attempts}. next connection attempt in ${r} seconds`),this.recovery_timer=setTimeout(()=>{!this.close_requested&&!(this.isConnected()||this.isConnecting())&&(this._getSocket(),this.connect())},r*1e3)}_getSocket(){let r=[];if(this.sockets.forEach(o=>{o.status!==Ut.SOCKET_STATUS_ERROR&&(r.length===0?r.push(o):o.weight>r[0].weight?r=[o]:o.weight===r[0].weight&&r.push(o))}),r.length===0){this.sockets.forEach(o=>{o.status=Ut.SOCKET_STATUS_READY}),this._getSocket();return}const n=Math.floor(Math.random()*r.length);this.socket=r[n].socket}_onConnect(){this.recover_attempts=0,this.status=Ut.STATUS_CONNECTED,this.recovery_timer!==null&&(clearTimeout(this.recovery_timer),this.recovery_timer=null),this.onconnect({socket:this})}_onDisconnect(r,n,o){this.status=Ut.STATUS_DISCONNECTED,this.ondisconnect({socket:this.socket,error:r,code:n,reason:o}),!this.close_requested&&(this.sockets.forEach(function(a){this.socket===a.socket&&(a.status=Ut.SOCKET_STATUS_ERROR)},this),this._reconnect(r))}_onData(r){if(r===`\r
|
@@ -131,14 +131,14 @@ ${r}
|
|
131
131
|
`,o+=`Call-ID: ${Le.call_id}\r
|
132
132
|
`,o+=`CSeq: ${Le.cseq} ${Le.method}\r
|
133
133
|
`,o+=`\r
|
134
|
-
`,Of.send(o)}var qa={};const In=ft(),Gs=we,Va=Gt(),Df=is(),ja=Ma,Ba=as;qa.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:Gs.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:Gs.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:Gs.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:`${In.createRandomToken(12)}.invalid`};const Ql={mandatory:{sockets(c){const r=[];if(ja.isSocket(c))r.push({socket:c});else if(Array.isArray(c)&&c.length)for(const n of c)Object.prototype.hasOwnProperty.call(n,"socket")&&ja.isSocket(n.socket)?r.push(n):ja.isSocket(n)&&r.push({socket:n});else return;return r},uri(c){/^sip:/i.test(c)||(c=`${Gs.SIP}:${c}`);const r=Df.parse(c);if(r)return r.user?r:void 0}},optional:{authorization_user(c){if(Va.parse(`"${c}"`,"quoted_string")!==-1)return c},authorization_jwt(c){if(typeof c=="string")return c},user_agent(c){if(typeof c=="string")return c},connection_recovery_max_interval(c){if(In.isDecimal(c)){const r=Number(c);if(r>0)return r}},connection_recovery_min_interval(c){if(In.isDecimal(c)){const r=Number(c);if(r>0)return r}},contact_uri(c){if(typeof c=="string"){const r=Va.parse(c,"SIP_URI");if(r!==-1)return r}},display_name(c){return c},instance_id(c){if(/^uuid:/i.test(c)&&(c=c.substr(5)),Va.parse(c,"uuid")!==-1)return c},no_answer_timeout(c){if(In.isDecimal(c)){const r=Number(c);if(r>0)return r}},session_timers(c){if(typeof c=="boolean")return c},session_timers_refresh_method(c){if(typeof c=="string"&&(c=c.toUpperCase(),c===Gs.INVITE||c===Gs.UPDATE))return c},session_timers_force_refresher(c){if(typeof c=="boolean")return c},password(c){return String(c)},realm(c){return String(c)},ha1(c){return String(c)},register(c){if(typeof c=="boolean")return c},register_expires(c){if(In.isDecimal(c)){const r=Number(c);if(r>0)return r}},registrar_server(c){/^sip:/i.test(c)||(c=`${Gs.SIP}:${c}`);const r=Df.parse(c);if(r)return r.user?void 0:r},use_preloaded_route(c){if(typeof c=="boolean")return c},extra_headers(c){const r=[];if(Array.isArray(c)&&c.length)for(const n of c)typeof n=="string"&&r.push(n);else return;return r}}};qa.load=(c,r)=>{for(const n in Ql.mandatory)if(r.hasOwnProperty(n)){const o=r[n],a=Ql.mandatory[n](o);if(a!==void 0)c[n]=a;else throw new Ba.ConfigurationError(n,o)}else throw new Ba.ConfigurationError(n);for(const n in Ql.optional)if(r.hasOwnProperty(n)){const o=r[n];if(In.isEmpty(o))continue;const a=Ql.optional[n](o);if(a!==void 0)c[n]=a;else throw new Ba.ConfigurationError(n,o)}};const Tg=ot.EventEmitter,Eg=it,_t=we,yg=om,Nf=Sf,Uf=Wm,Pf=Qm,Ga=An,Sg=ng,Zl=ft(),Cg=as,Ag=is(),Rg=If,Ka=Kt,Ig=fg,Wa=qa,He=new Eg("UA"),dt={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2};var kf=class extends Tg{static get C(){return dt}constructor(r){if(He.debug("new() [configuration:%o]",r),super(),this._cache={credentials:{}},this._configuration=Object.assign({},Wa.settings),this._dynConfiguration={},this._dialogs={},this._applicants={},this._sessions={},this._transport=null,this._contact=null,this._status=dt.STATUS_INIT,this._error=null,this._transactions={nist:{},nict:{},ist:{},ict:{}},this._data={},this._closeTimer=null,r===void 0)throw new TypeError("Not enough arguments");try{this._loadConfig(r)}catch(n){throw this._status=dt.STATUS_NOT_READY,this._error=dt.CONFIGURATION_ERROR,n}this._registrator=new yg(this)}get C(){return dt}get status(){return this._status}get contact(){return this._contact}get configuration(){return this._configuration}get transport(){return this._transport}start(){He.debug("start()"),this._status===dt.STATUS_INIT?this._transport.connect():this._status===dt.STATUS_USER_CLOSED?(He.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=dt.STATUS_INIT,this._transport.connect()):this._status===dt.STATUS_READY?He.debug("UA is in READY status, not restarted"):He.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this._dynConfiguration.register=this._configuration.register}register(){He.debug("register()"),this._dynConfiguration.register=!0,this._registrator.register()}unregister(r){He.debug("unregister()"),this._dynConfiguration.register=!1,this._registrator.unregister(r)}registrator(){return this._registrator}isRegistered(){return this._registrator.registered}isConnected(){return this._transport.isConnected()}call(r,n){He.debug("call()");const o=new Nf(this);return o.connect(r,n),o}sendMessage(r,n,o){He.debug("sendMessage()");const a=new Uf(this);return a.send(r,n,o),a}sendOptions(r,n,o){He.debug("sendOptions()");const a=new Pf(this);return a.send(r,n,o),a}terminateSessions(r){He.debug("terminateSessions()");for(const n in this._sessions)this._sessions[n].isEnded()||this._sessions[n].terminate(r)}stop(){if(He.debug("stop()"),this._dynConfiguration={},this._status===dt.STATUS_USER_CLOSED){He.debug("UA already closed");return}this._registrator.close();const r=Object.keys(this._sessions).length;for(const o in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,o)){He.debug(`closing session ${o}`);try{this._sessions[o].terminate()}catch{}}for(const o in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,o))try{this._applicants[o].close()}catch{}this._status=dt.STATUS_USER_CLOSED,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&&r===0?this._transport.disconnect():this._closeTimer=setTimeout(()=>{this._closeTimer=null,this._transport.disconnect()},2e3)}normalizeTarget(r){return Zl.normalizeTarget(r,this._configuration.hostport_params)}get(r){switch(r){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:He.warn('get() | cannot get "%s" parameter in runtime',r);return}}set(r,n){switch(r){case"authorization_user":{this._configuration.authorization_user=String(n);break}case"password":{this._configuration.password=String(n);break}case"realm":{this._configuration.realm=String(n);break}case"ha1":{this._configuration.ha1=String(n),this._configuration.password=null;break}case"authorization_jwt":{this._configuration.authorization_jwt=String(n);break}case"display_name":{this._configuration.display_name=n;break}default:return He.warn('set() | cannot set "%s" parameter in runtime',r),!1}return!0}newTransaction(r){this._transactions[r.type][r.id]=r,this.emit("newTransaction",{transaction:r})}destroyTransaction(r){delete this._transactions[r.type][r.id],this.emit("transactionDestroyed",{transaction:r})}newDialog(r){this._dialogs[r.id]=r}destroyDialog(r){delete this._dialogs[r.id]}newMessage(r,n){this._applicants[r]=r,this.emit("newMessage",n)}newOptions(r,n){this._applicants[r]=r,this.emit("newOptions",n)}destroyMessage(r){delete this._applicants[r]}newRTCSession(r,n){this._sessions[r.id]=r,this.emit("newRTCSession",n)}destroyRTCSession(r){delete this._sessions[r.id]}registered(r){this.emit("registered",r)}unregistered(r){this.emit("unregistered",r)}registrationFailed(r){this.emit("registrationFailed",r)}receiveRequest(r){const n=r.method;if(r.ruri.user!==this._configuration.uri.user&&r.ruri.user!==this._contact.uri.user){He.debug("Request-URI does not point to us"),r.method!==_t.ACK&&r.reply_sl(404);return}if(r.ruri.scheme===_t.SIPS){r.reply_sl(416);return}if(Ga.checkTransaction(this,r))return;if(n===_t.INVITE?new Ga.InviteServerTransaction(this,this._transport,r):n!==_t.ACK&&n!==_t.CANCEL&&new Ga.NonInviteServerTransaction(this,this._transport,r),n===_t.OPTIONS){if(this.listeners("newOptions").length===0){r.reply(200);return}new Pf(this).init_incoming(r)}else if(n===_t.MESSAGE){if(this.listeners("newMessage").length===0){r.reply(405);return}new Uf(this).init_incoming(r)}else if(n===_t.INVITE&&!r.to_tag&&this.listeners("newRTCSession").length===0){r.reply(405);return}let o,a;if(r.to_tag)o=this._findDialog(r.call_id,r.from_tag,r.to_tag),o?o.receiveRequest(r):n===_t.NOTIFY?(a=this._findSession(r),a?a.receiveRequest(r):(He.debug("received NOTIFY request for a non existent subscription"),r.reply(481,"Subscription does not exist"))):n!==_t.ACK&&r.reply(481);else switch(n){case _t.INVITE:if(window.RTCPeerConnection)if(r.hasHeader("replaces")){const t=r.replaces;o=this._findDialog(t.call_id,t.from_tag,t.to_tag),o?(a=o.owner,a.isEnded()?r.reply(603):a.receiveRequest(r)):r.reply(481)}else a=new Nf(this),a.init_incoming(r);else He.warn("INVITE received but WebRTC is not supported"),r.reply(488);break;case _t.BYE:r.reply(481);break;case _t.CANCEL:a=this._findSession(r),a?a.receiveRequest(r):He.debug("received CANCEL request for a non existent session");break;case _t.ACK:break;case _t.NOTIFY:this.emit("sipEvent",{event:r.event,request:r}),r.reply(200);break;default:r.reply(405);break}}_findSession({call_id:r,from_tag:n,to_tag:o}){const a=r+n,t=this._sessions[a],s=r+o,p=this._sessions[s];return t||p||null}_findDialog(r,n,o){let a=r+n+o,t=this._dialogs[a];return t||(a=r+o+n,t=this._dialogs[a],t||null)}_loadConfig(r){try{Wa.load(this._configuration,r)}catch(a){throw a}this._configuration.display_name===0&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=Zl.newUUID()),this._configuration.jssip_id=Zl.createRandomToken(5);const n=this._configuration.uri.clone();n.user=null,this._configuration.hostport_params=n.toString().replace(/^sip:/i,"");try{this._transport=new Sg(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=bg.bind(this),this._transport.onconnect=wg.bind(this),this._transport.ondisconnect=Og.bind(this),this._transport.ondata=Dg.bind(this)}catch(a){throw He.warn(a),new Cg.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){const a=this._configuration.uri.clone();a.user=null,a.clearParams(),a.clearHeaders(),this._configuration.registrar_server=a}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new Ag("sip",Zl.createRandomToken(8),this._configuration.via_host,null,{transport:"ws"}),this._contact={pub_gruu:null,temp_gruu:null,uri:this._configuration.contact_uri,toString(a={}){const t=a.anonymous||null,s=a.outbound||null;let p="<";return t?p+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":p+=this.pub_gruu||this.uri.toString(),s&&(t?!this.temp_gruu:!this.pub_gruu)&&(p+=";ob"),p+=">",p}};const o=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register"];for(const a in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,a)&&(o.indexOf(a)!==-1?Object.defineProperty(this._configuration,a,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,a,{writable:!1,configurable:!1}));He.debug("configuration parameters after validation:");for(const a in this._configuration)if(Object.prototype.hasOwnProperty.call(Wa.settings,a))switch(a){case"uri":case"registrar_server":He.debug(`- ${a}: ${this._configuration[a]}`);break;case"password":case"ha1":case"authorization_jwt":He.debug(`- ${a}: NOT SHOWN`);break;default:He.debug(`- ${a}: ${JSON.stringify(this._configuration[a])}`)}}};function bg(c){this.emit("connecting",c)}function wg(c){this._status!==dt.STATUS_USER_CLOSED&&(this._status=dt.STATUS_READY,this._error=null,this.emit("connected",c),this._dynConfiguration.register&&this._registrator.register())}function Og(c){const r=["nict","ict","nist","ist"];for(const n of r)for(const o in this._transactions[n])Object.prototype.hasOwnProperty.call(this._transactions[n],o)&&this._transactions[n][o].onTransportError();this.emit("disconnected",c),this._registrator.onTransportClosed(),this._status!==dt.STATUS_USER_CLOSED&&(this._status=dt.STATUS_NOT_READY,this._error=dt.NETWORK_ERROR)}function Dg(c){const r=c.transport;let n=c.message;if(n=Rg.parseMessage(n,this),!!n&&!(this._status===dt.STATUS_USER_CLOSED&&n instanceof Ka.IncomingRequest)&&Ig(n,this,r)){if(n instanceof Ka.IncomingRequest)n.transport=r,this.receiveRequest(n);else if(n instanceof Ka.IncomingResponse){let o;switch(n.method){case _t.INVITE:o=this._transactions.ict[n.via_branch],o&&o.receiveResponse(n);break;case _t.ACK:break;default:o=this._transactions.nict[n.via_branch],o&&o.receiveResponse(n);break}}}}const Ng=vt(kf);var Ss=ft();class bn{constructor(r){if(this.headers={},r.length>0){let n=!1;const o=r.split(`\r
|
134
|
+
`,Of.send(o)}var qa={};const In=ft(),Ks=we,Va=Gt(),Df=ls(),ja=Ma,Ba=us;qa.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:Ks.UPDATE,session_timers_force_refresher:!1,no_answer_timeout:60,register:!0,register_expires:600,registrar_server:null,sockets:null,connection_recovery_max_interval:Ks.CONNECTION_RECOVERY_MAX_INTERVAL,connection_recovery_min_interval:Ks.CONNECTION_RECOVERY_MIN_INTERVAL,extra_headers:null,via_host:`${In.createRandomToken(12)}.invalid`};const Ql={mandatory:{sockets(c){const r=[];if(ja.isSocket(c))r.push({socket:c});else if(Array.isArray(c)&&c.length)for(const n of c)Object.prototype.hasOwnProperty.call(n,"socket")&&ja.isSocket(n.socket)?r.push(n):ja.isSocket(n)&&r.push({socket:n});else return;return r},uri(c){/^sip:/i.test(c)||(c=`${Ks.SIP}:${c}`);const r=Df.parse(c);if(r)return r.user?r:void 0}},optional:{authorization_user(c){if(Va.parse(`"${c}"`,"quoted_string")!==-1)return c},authorization_jwt(c){if(typeof c=="string")return c},user_agent(c){if(typeof c=="string")return c},connection_recovery_max_interval(c){if(In.isDecimal(c)){const r=Number(c);if(r>0)return r}},connection_recovery_min_interval(c){if(In.isDecimal(c)){const r=Number(c);if(r>0)return r}},contact_uri(c){if(typeof c=="string"){const r=Va.parse(c,"SIP_URI");if(r!==-1)return r}},display_name(c){return c},instance_id(c){if(/^uuid:/i.test(c)&&(c=c.substr(5)),Va.parse(c,"uuid")!==-1)return c},no_answer_timeout(c){if(In.isDecimal(c)){const r=Number(c);if(r>0)return r}},session_timers(c){if(typeof c=="boolean")return c},session_timers_refresh_method(c){if(typeof c=="string"&&(c=c.toUpperCase(),c===Ks.INVITE||c===Ks.UPDATE))return c},session_timers_force_refresher(c){if(typeof c=="boolean")return c},password(c){return String(c)},realm(c){return String(c)},ha1(c){return String(c)},register(c){if(typeof c=="boolean")return c},register_expires(c){if(In.isDecimal(c)){const r=Number(c);if(r>0)return r}},registrar_server(c){/^sip:/i.test(c)||(c=`${Ks.SIP}:${c}`);const r=Df.parse(c);if(r)return r.user?void 0:r},use_preloaded_route(c){if(typeof c=="boolean")return c},extra_headers(c){const r=[];if(Array.isArray(c)&&c.length)for(const n of c)typeof n=="string"&&r.push(n);else return;return r}}};qa.load=(c,r)=>{for(const n in Ql.mandatory)if(r.hasOwnProperty(n)){const o=r[n],a=Ql.mandatory[n](o);if(a!==void 0)c[n]=a;else throw new Ba.ConfigurationError(n,o)}else throw new Ba.ConfigurationError(n);for(const n in Ql.optional)if(r.hasOwnProperty(n)){const o=r[n];if(In.isEmpty(o))continue;const a=Ql.optional[n](o);if(a!==void 0)c[n]=a;else throw new Ba.ConfigurationError(n,o)}};const Tg=ot.EventEmitter,Eg=it,_t=we,yg=om,Nf=Sf,Uf=Wm,Pf=Qm,Ga=An,Sg=ng,Zl=ft(),Cg=us,Ag=ls(),Rg=If,Ka=Kt,Ig=fg,Wa=qa,He=new Eg("UA"),dt={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2};var kf=class extends Tg{static get C(){return dt}constructor(r){if(He.debug("new() [configuration:%o]",r),super(),this._cache={credentials:{}},this._configuration=Object.assign({},Wa.settings),this._dynConfiguration={},this._dialogs={},this._applicants={},this._sessions={},this._transport=null,this._contact=null,this._status=dt.STATUS_INIT,this._error=null,this._transactions={nist:{},nict:{},ist:{},ict:{}},this._data={},this._closeTimer=null,r===void 0)throw new TypeError("Not enough arguments");try{this._loadConfig(r)}catch(n){throw this._status=dt.STATUS_NOT_READY,this._error=dt.CONFIGURATION_ERROR,n}this._registrator=new yg(this)}get C(){return dt}get status(){return this._status}get contact(){return this._contact}get configuration(){return this._configuration}get transport(){return this._transport}start(){He.debug("start()"),this._status===dt.STATUS_INIT?this._transport.connect():this._status===dt.STATUS_USER_CLOSED?(He.debug("restarting UA"),this._closeTimer!==null&&(clearTimeout(this._closeTimer),this._closeTimer=null,this._transport.disconnect()),this._status=dt.STATUS_INIT,this._transport.connect()):this._status===dt.STATUS_READY?He.debug("UA is in READY status, not restarted"):He.debug("ERROR: connection is down, Auto-Recovery system is trying to reconnect"),this._dynConfiguration.register=this._configuration.register}register(){He.debug("register()"),this._dynConfiguration.register=!0,this._registrator.register()}unregister(r){He.debug("unregister()"),this._dynConfiguration.register=!1,this._registrator.unregister(r)}registrator(){return this._registrator}isRegistered(){return this._registrator.registered}isConnected(){return this._transport.isConnected()}call(r,n){He.debug("call()");const o=new Nf(this);return o.connect(r,n),o}sendMessage(r,n,o){He.debug("sendMessage()");const a=new Uf(this);return a.send(r,n,o),a}sendOptions(r,n,o){He.debug("sendOptions()");const a=new Pf(this);return a.send(r,n,o),a}terminateSessions(r){He.debug("terminateSessions()");for(const n in this._sessions)this._sessions[n].isEnded()||this._sessions[n].terminate(r)}stop(){if(He.debug("stop()"),this._dynConfiguration={},this._status===dt.STATUS_USER_CLOSED){He.debug("UA already closed");return}this._registrator.close();const r=Object.keys(this._sessions).length;for(const o in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,o)){He.debug(`closing session ${o}`);try{this._sessions[o].terminate()}catch{}}for(const o in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,o))try{this._applicants[o].close()}catch{}this._status=dt.STATUS_USER_CLOSED,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&&r===0?this._transport.disconnect():this._closeTimer=setTimeout(()=>{this._closeTimer=null,this._transport.disconnect()},2e3)}normalizeTarget(r){return Zl.normalizeTarget(r,this._configuration.hostport_params)}get(r){switch(r){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:He.warn('get() | cannot get "%s" parameter in runtime',r);return}}set(r,n){switch(r){case"authorization_user":{this._configuration.authorization_user=String(n);break}case"password":{this._configuration.password=String(n);break}case"realm":{this._configuration.realm=String(n);break}case"ha1":{this._configuration.ha1=String(n),this._configuration.password=null;break}case"authorization_jwt":{this._configuration.authorization_jwt=String(n);break}case"display_name":{this._configuration.display_name=n;break}default:return He.warn('set() | cannot set "%s" parameter in runtime',r),!1}return!0}newTransaction(r){this._transactions[r.type][r.id]=r,this.emit("newTransaction",{transaction:r})}destroyTransaction(r){delete this._transactions[r.type][r.id],this.emit("transactionDestroyed",{transaction:r})}newDialog(r){this._dialogs[r.id]=r}destroyDialog(r){delete this._dialogs[r.id]}newMessage(r,n){this._applicants[r]=r,this.emit("newMessage",n)}newOptions(r,n){this._applicants[r]=r,this.emit("newOptions",n)}destroyMessage(r){delete this._applicants[r]}newRTCSession(r,n){this._sessions[r.id]=r,this.emit("newRTCSession",n)}destroyRTCSession(r){delete this._sessions[r.id]}registered(r){this.emit("registered",r)}unregistered(r){this.emit("unregistered",r)}registrationFailed(r){this.emit("registrationFailed",r)}receiveRequest(r){const n=r.method;if(r.ruri.user!==this._configuration.uri.user&&r.ruri.user!==this._contact.uri.user){He.debug("Request-URI does not point to us"),r.method!==_t.ACK&&r.reply_sl(404);return}if(r.ruri.scheme===_t.SIPS){r.reply_sl(416);return}if(Ga.checkTransaction(this,r))return;if(n===_t.INVITE?new Ga.InviteServerTransaction(this,this._transport,r):n!==_t.ACK&&n!==_t.CANCEL&&new Ga.NonInviteServerTransaction(this,this._transport,r),n===_t.OPTIONS){if(this.listeners("newOptions").length===0){r.reply(200);return}new Pf(this).init_incoming(r)}else if(n===_t.MESSAGE){if(this.listeners("newMessage").length===0){r.reply(405);return}new Uf(this).init_incoming(r)}else if(n===_t.INVITE&&!r.to_tag&&this.listeners("newRTCSession").length===0){r.reply(405);return}let o,a;if(r.to_tag)o=this._findDialog(r.call_id,r.from_tag,r.to_tag),o?o.receiveRequest(r):n===_t.NOTIFY?(a=this._findSession(r),a?a.receiveRequest(r):(He.debug("received NOTIFY request for a non existent subscription"),r.reply(481,"Subscription does not exist"))):n!==_t.ACK&&r.reply(481);else switch(n){case _t.INVITE:if(window.RTCPeerConnection)if(r.hasHeader("replaces")){const t=r.replaces;o=this._findDialog(t.call_id,t.from_tag,t.to_tag),o?(a=o.owner,a.isEnded()?r.reply(603):a.receiveRequest(r)):r.reply(481)}else a=new Nf(this),a.init_incoming(r);else He.warn("INVITE received but WebRTC is not supported"),r.reply(488);break;case _t.BYE:r.reply(481);break;case _t.CANCEL:a=this._findSession(r),a?a.receiveRequest(r):He.debug("received CANCEL request for a non existent session");break;case _t.ACK:break;case _t.NOTIFY:this.emit("sipEvent",{event:r.event,request:r}),r.reply(200);break;default:r.reply(405);break}}_findSession({call_id:r,from_tag:n,to_tag:o}){const a=r+n,t=this._sessions[a],s=r+o,p=this._sessions[s];return t||p||null}_findDialog(r,n,o){let a=r+n+o,t=this._dialogs[a];return t||(a=r+o+n,t=this._dialogs[a],t||null)}_loadConfig(r){try{Wa.load(this._configuration,r)}catch(a){throw a}this._configuration.display_name===0&&(this._configuration.display_name="0"),this._configuration.instance_id||(this._configuration.instance_id=Zl.newUUID()),this._configuration.jssip_id=Zl.createRandomToken(5);const n=this._configuration.uri.clone();n.user=null,this._configuration.hostport_params=n.toString().replace(/^sip:/i,"");try{this._transport=new Sg(this._configuration.sockets,{max_interval:this._configuration.connection_recovery_max_interval,min_interval:this._configuration.connection_recovery_min_interval}),this._transport.onconnecting=bg.bind(this),this._transport.onconnect=wg.bind(this),this._transport.ondisconnect=Og.bind(this),this._transport.ondata=Dg.bind(this)}catch(a){throw He.warn(a),new Cg.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){const a=this._configuration.uri.clone();a.user=null,a.clearParams(),a.clearHeaders(),this._configuration.registrar_server=a}this._configuration.no_answer_timeout*=1e3,this._configuration.contact_uri?this._configuration.via_host=this._configuration.contact_uri.host:this._configuration.contact_uri=new Ag("sip",Zl.createRandomToken(8),this._configuration.via_host,null,{transport:"ws"}),this._contact={pub_gruu:null,temp_gruu:null,uri:this._configuration.contact_uri,toString(a={}){const t=a.anonymous||null,s=a.outbound||null;let p="<";return t?p+=this.temp_gruu||"sip:anonymous@anonymous.invalid;transport=ws":p+=this.pub_gruu||this.uri.toString(),s&&(t?!this.temp_gruu:!this.pub_gruu)&&(p+=";ob"),p+=">",p}};const o=["authorization_user","password","realm","ha1","authorization_jwt","display_name","register"];for(const a in this._configuration)Object.prototype.hasOwnProperty.call(this._configuration,a)&&(o.indexOf(a)!==-1?Object.defineProperty(this._configuration,a,{writable:!0,configurable:!1}):Object.defineProperty(this._configuration,a,{writable:!1,configurable:!1}));He.debug("configuration parameters after validation:");for(const a in this._configuration)if(Object.prototype.hasOwnProperty.call(Wa.settings,a))switch(a){case"uri":case"registrar_server":He.debug(`- ${a}: ${this._configuration[a]}`);break;case"password":case"ha1":case"authorization_jwt":He.debug(`- ${a}: NOT SHOWN`);break;default:He.debug(`- ${a}: ${JSON.stringify(this._configuration[a])}`)}}};function bg(c){this.emit("connecting",c)}function wg(c){this._status!==dt.STATUS_USER_CLOSED&&(this._status=dt.STATUS_READY,this._error=null,this.emit("connected",c),this._dynConfiguration.register&&this._registrator.register())}function Og(c){const r=["nict","ict","nist","ist"];for(const n of r)for(const o in this._transactions[n])Object.prototype.hasOwnProperty.call(this._transactions[n],o)&&this._transactions[n][o].onTransportError();this.emit("disconnected",c),this._registrator.onTransportClosed(),this._status!==dt.STATUS_USER_CLOSED&&(this._status=dt.STATUS_NOT_READY,this._error=dt.NETWORK_ERROR)}function Dg(c){const r=c.transport;let n=c.message;if(n=Rg.parseMessage(n,this),!!n&&!(this._status===dt.STATUS_USER_CLOSED&&n instanceof Ka.IncomingRequest)&&Ig(n,this,r)){if(n instanceof Ka.IncomingRequest)n.transport=r,this.receiveRequest(n);else if(n instanceof Ka.IncomingResponse){let o;switch(n.method){case _t.INVITE:o=this._transactions.ict[n.via_branch],o&&o.receiveResponse(n);break;case _t.ACK:break;default:o=this._transactions.nict[n.via_branch],o&&o.receiveResponse(n);break}}}}const Ng=vt(kf);var Cs=ft();class bn{constructor(r){if(this.headers={},r.length>0){let n=!1;const o=r.split(`\r
|
135
135
|
`),a=o.shift().split(/\s/);this.protocol=a[0],this.ident=a[1],this.code=a.length>3?parseInt(a[2]):0,this.method=a.length>3?a[3]:a[2],this.body="";for(const t of o){if(t==`-------${this.ident}$`)break;if(t===""){n=!0;continue}if(t&&n)this.body+=`${t}\r
|
136
|
-
`;else{const s=t.split(": ");this.addHeader(s[0],s[1].trim())}}}else this.ident=
|
136
|
+
`;else{const s=t.split(": ");this.addHeader(s[0],s[1].trim())}}}else this.ident=Cs.createRandomToken(12),this.protocol="MSRP"}addHeader(r,n){this.headers[r]=n}getHeader(r){return this.headers[r]}toString(){let r=`${this.protocol} ${this.ident} ${this.code} ${this.method}`.replaceAll(/null\s|undefined\s/ig,"")+`\r
|
137
137
|
`;for(const n in this.headers)r+=`${n}: ${this.headers[n]}\r
|
138
138
|
`;return this.body&&(r+=`\r
|
139
139
|
${this.body}\r
|
140
140
|
`),r+=`-------${this.ident}$\r
|
141
|
-
`,r}}var Ug=
|
141
|
+
`,r}}var Ug=ls();const Ya=vt(Ug),ye={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};class Mf extends ot.EventEmitter{constructor(r){super(),this._id=null,this.my_ip="127.0.0.1",this._ua=r,this.auth_id=Cs.createRandomToken(10),this._status=ye.STATUS_NULL,this._dialog=null,this._earlyDialogs={},this._contact=null,this._from_tag=null,this._to_tag=null,this._msgHistory=[],this.target_addr=[],this.my_addr=[],this.credentials={username:r._configuration.authorization_user,ha1:r._configuration.ha1,realm:r._configuration.realm},this._request=null,this.status="new",this.target="",this.message="",this._connectionPromiseQueue=Promise.resolve(),this._timers={ackTimer:null,expiresTimer:null,invite2xxTimer:null,userNoAnswerTimer:null},this._direction=null,this._local_identity=null,this._remote_identity=null,this._start_time=null,this._end_time=null,this._tones=null,this._sessionTimers={enabled:this._ua.configuration.session_timers,refreshMethod:this._ua.configuration.session_timers_refresh_method,defaultExpires:Ie.SESSION_EXPIRES,currentExpires:null,running:!1,refresher:!1,timer:null},this._msrpKeepAliveTimer=null}static get C(){return ye}get direction(){return this._direction}get connection(){return this._connection}get id(){return this._id}connect(r=""){r!==""&&(this._direction="outgoing"),this.target=r,this._connection=new WebSocket(`ws://${this._ua._configuration.realm}:2856`,"msrp"),this._connection.binaryType="arraybuffer",this._connection.onopen=n=>{console.log("open",n),this.onopen()},this._connection.onclose=n=>{console.log("close",n),this.onclose()},this._connection.onmessage=n=>{console.log("msg",n),this.onmessage(n)},this._connection.onerror=n=>{console.log("error",n),this.onerror()}}_sendKeepAlive(){const r=new bn("");r.method="SEND",r.addHeader("To-Path",`${this.my_addr[1]}`),r.addHeader("From-Path",`${this.my_addr[0]}`),r.addHeader("Message-ID",Cs.createRandomToken(10)),this._connection.send(r.toString())}answer(){if(!this._createDialog(this._request,"UAS")){this._request.reply(500,"Error creating dialog");return}this._status=ye.STATUS_ANSWERED,clearTimeout(this._timers.userNoAnswerTimer),this.connect()}acceptParty(r){this._request.parseSDP(!0),this._request.reply(200,"OK",[],`v=0
|
142
142
|
o=- 4232740119537112802 2 IN IP4 ${this.my_ip}
|
143
143
|
c=IN IP4 ${this.my_ip}
|
144
144
|
t=0 0
|
@@ -152,4 +152,4 @@ t=0 0
|
|
152
152
|
m=message 2856 TCP/TLS/MSRP *
|
153
153
|
a=accept-types:text/plain text/html
|
154
154
|
a=path:${r.getHeader("Use-Path")} msrp://${this._ua._configuration.authorization_user}.${this._ua._configuration.realm}:2856/${this.auth_id};ws
|
155
|
-
`),this._newMSRPSession("local",this._request),this._id=this._request.call_id+this._from_tag,console.log("dialog be",this._dialog),new im(this._ua,this._request,{onRequestTimeout:()=>{this.onRequestTimeout(),console.log("to")},onTransportError:t=>{this.onTransportError(),console.log(t)},onAuthenticated:t=>{this._request=t},onReceiveResponse:t=>{this._receiveInviteResponse(t),console.log("dialog af",this._dialog),t.status_code===200&&(t.parseSDP(!0),this._status=ye.STATUS_CONFIRMED,this.target_addr=t.sdp.media[0].invalid[1].value.replaceAll("path:","").split(" ").reverse(),this.status="active",this.emit("active"),this.emit("confirmed"))}}).send(),this._status=ye.STATUS_INVITE_SENT}terminate(r={}){console.log("terminate",this);const n=r.cause||Ie.causes.BYE,o=Ss.cloneArray(r.extraHeaders),a=r.body;let t,s=r.status_code,p=r.reason_phrase;if(this._status===ye.STATUS_TERMINATED)throw new hm.InvalidStateError(this._status);switch(this.status="terminated",this._status){case ye.STATUS_NULL:case ye.STATUS_INVITE_SENT:case ye.STATUS_1XX_RECEIVED:if(s&&(s<200||s>=700))throw new TypeError(`Invalid status_code: ${s}`);s&&(p=p||Ie.REASON_PHRASE[s]||"",t=`SIP ;cause=${s} ;text="${p}"`),this._status===ye.STATUS_NULL||this._status===ye.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=t):this._status===ye.STATUS_1XX_RECEIVED&&this._request.cancel(t),this._status=ye.STATUS_CANCELED,console.log("failed 1"),this._failed("local",null,Ie.causes.CANCELED);break;case ye.STATUS_WAITING_FOR_ANSWER:case ye.STATUS_ANSWERED:if(s=s||480,console.log("REPLY 480"),s<300||s>=700)throw new TypeError(`Invalid status_code: ${s}`);this._request.reply(s,p,o,a),console.log("failed 2"),this._failed("local",null,Ie.causes.REJECTED);break;case ye.STATUS_WAITING_FOR_ACK:case ye.STATUS_CONFIRMED:if(p=r.reason_phrase||Ie.REASON_PHRASE[s]||"",s&&(s<200||s>=700))throw new TypeError(`Invalid status_code: ${s}`);if(s&&o.push(`Reason: SIP ;cause=${s}; text="${p}"`),this._status===ye.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==Ur.C.STATUS_TERMINATED){const h=this._dialog;this.receiveRequest=({method:d})=>{d===Ie.ACK&&(this.sendRequest(Ie.BYE,{extraHeaders:o,body:a}),h.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===Ur.C.STATUS_TERMINATED&&(this.sendRequest(Ie.BYE,{extraHeaders:o,body:a}),h.terminate())}),this._ended("local",null,n),this._dialog=h,this._ua.newDialog(h)}else console.log("here it is"),this.sendRequest(Ie.BYE,{extraHeaders:o,body:a}),this._ended("local",null,n)}}sendRequest(r,n){return this._dialog.sendRequest(r,n)}authenticate(r){this.status="auth";let n=new bn("");n.method="AUTH",n.addHeader("To-Path",`msrp://${this._ua._configuration.realm}:2856;ws`),n.addHeader("From-Path",`msrp://${this.credentials.username}.${this.credentials.realm}:2856/${this.auth_id};ws`),r&&n.addHeader("Authorization",r.toString());let o=n.toString();console.log(o);let a=[];for(var t=0;t<o.length;t++)a.push(o.charCodeAt(t).toString(16));console.log(a),this._connection.send(n.toString())}onmessage(r){console.log("onmessage",r);const n=new bn(r.data);if(this.status==="auth"&&n.code===401){const o=this.parseAuth(n.getHeader("WWW-Authenticate")),a=new Wp(this.credentials);a.authenticate({method:"AUTH",ruri:`msrp://${this._ua._configuration.realm}:2856;ws`,body:null},o,Ss.createRandomToken(12)),this.authenticate(a)}this.status==="auth"&&n.code===200&&this._direction==="outgoing"?(this.my_addr.push(n.getHeader("To-Path")),this.my_addr.push(n.getHeader("Use-Path")),this.status="active",this.inviteParty(n)):this.status==="auth"&&n.code===200&&this._direction==="incoming"?(this.my_addr.push(n.getHeader("To-Path")),this.my_addr.push(n.getHeader("Use-Path")),this.status="active",this.acceptParty(n),this.emit("confirmed")):n.method==="SEND"&&(this._sendOk(n),this._sendReport(n),n.direction="incoming",this.emit("newMessage",n),this._msgHistory.push(n),this.emit("msgHistoryUpdate",this._msgHistory),console.log("======================================================================")),n.code===480&&this._close()}onclose(){console.log("close")}onopen(){const r=new RTCPeerConnection({iceServers:[]});r.createDataChannel(""),r.createOffer().then(r.setLocalDescription.bind(r)),r.onicecandidate=n=>{if(!n||!n.candidate||!n.candidate.candidate)return;const o=/([0-9]{1,3}(\.[0-9]{1,3}){3})/,a=n.candidate.candidate.match(o);this.my_ip=a&&a[1],r.onicecandidate=()=>{},this.authenticate(null)}}onerror(r){console.log(r)}_receiveInviteResponse(r){if(console.log("resp0000000000000",r),this._dialog&&r.status_code>=200&&r.status_code<=299)if(console.log("200000000000000"),this._dialog.id.call_id===r.call_id&&this._dialog.id.local_tag===r.from_tag&&this._dialog.id.remote_tag===r.to_tag){this.sendRequest(Ie.ACK);return}else{const n=new Kl(this,r,"UAC");if(n.error!==void 0){console.log(n.error);return}this.sendRequest(Ie.ACK),this.sendRequest(Ie.BYE);return}if(this._is_canceled){r.status_code>=100&&r.status_code<200?this._request.cancel(this._cancel_reason):r.status_code>=200&&r.status_code<299&&this._acceptAndTerminate(r);return}if(!(this._status!==ye.STATUS_INVITE_SENT&&this._status!==ye.STATUS_1XX_RECEIVED))switch(console.log("start Switch"),!0){case/^100$/.test(r.status_code):this._status=ye.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(r.status_code):{if(!r.to_tag){console.log("1xx response received without to tag");break}if(r.hasHeader("contact")&&!this._createDialog(r,"UAC",!0))break;if(this._status=ye.STATUS_1XX_RECEIVED,!r.body){this._progress("remote",r);break}const n={originator:"remote",type:"answer",sdp:r.body};console.log('emit "sdp"'),this.emit("sdp",n);const o=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(o)).then(()=>this._progress("remote",r)).catch(a=>{console.log('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)});break}case/^2[0-9]{2}$/.test(r.status_code):{if(console.log("maybe here???"),this._status=ye.STATUS_CONFIRMED,!r.body){this._acceptAndTerminate(r,400,Ie.causes.MISSING_SDP),console.log("failed 3"),this._failed("remote",r,Ie.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(r,"UAC"))break;const n={originator:"remote",type:"answer",sdp:r.body};console.log('emit "sdp"'),this.emit("sdp",n),new RTCSessionDescription({type:"answer",sdp:n.sdp}),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._connection.signalingState==="stable")return this._connection.createOffer(this._rtcOfferConstraints).then(o=>this._connection.setLocalDescription(o)).catch(o=>{this._acceptAndTerminate(r,500,o.toString()),console.log("failed 4"),this._failed("local",r,Ie.causes.WEBRTC_ERROR)})}).then(()=>{this._handleSessionTimersInIncomingResponse(r),this._accepted("remote",r),this.sendRequest(Ie.ACK),this._confirmed("local",null)});break}default:{const n=Ss.sipErrorCause(r.status_code);console.log("failed 5"),this._failed("remote",r,n)}}}sendMSRP(r){const n=new bn("");n.method="SEND",n.addHeader("To-Path",`${this.my_addr[1]} ${this.target_addr[1]} ${this.target_addr[0]}`),n.addHeader("From-Path",`${this.my_addr[0]}`),n.addHeader("Message-ID",Ss.createRandomToken(10)),n.addHeader("Byte-Range","1-25/25"),n.addHeader("Content-Type","text/plain"),n.addHeader("Success-Report","yes"),n.addHeader("Failure-Report","yes"),n.body=r;let o=n.toString();console.log(o);let a=[];for(var t=0;t<o.length;t++)a.push(o.charCodeAt(t).toString(16));console.log(a),this._connection.send(n.toString()),n.direction="outgoing",this.emit("newMessage",n),this._msgHistory.push(n),this.emit("msgHistoryUpdate",this._msgHistory)}_sendOk(r){let n=r.ident,o=r.getHeader("Message-ID"),a=new bn("");a.method="200 OK",a.addHeader("To-Path",`${this.my_addr[1]}`),a.addHeader("From-Path",`${this.my_addr[0]}`),a.addHeader("Message-ID",o),a.ident=n;let t=a.toString();console.log(t);let s=[];for(var p=0;p<t.length;p++)s.push(t.charCodeAt(p).toString(16));console.log(s),this._connection.send(a.toString())}_sendReport(r){let n=r.ident,o=r.getHeader("Message-ID"),a=new bn("");a.method="REPORT",a.addHeader("To-Path",`${r.getHeader("From-Path")}`),a.addHeader("From-Path",`${this.my_addr[0]}`),a.addHeader("Message-ID",o),a.addHeader("Byte-Range","1-25/25"),a.addHeader("Status","000 200 OK"),a.ident=n;let t=a.toString();console.log(t);let s=[];for(var p=0;p<t.length;p++)s.push(t.charCodeAt(p).toString(16));console.log(s),this._connection.send(a.toString())}parseAuth(r){const n={},o=r.replace("Digest","").split(",");for(const a of o){const t=a.trim().split("=");n[t[0]]=t[1].match('^"(.+)"$')[1]}return n}init_incoming(r,n){let o;const a=r.hasHeader("Content-Type")?r.getHeader("Content-Type").toLowerCase():void 0;if(r.body&&a!=="application/sdp"){r.reply(415);return}if(this._status=ye.STATUS_INVITE_RECEIVED,this._from_tag=r.from_tag,this._id=r.call_id+this._from_tag,this._request=r,this._contact=this._ua.contact.toString(),r.hasHeader("expires")&&(o=r.getHeader("expires")*1e3),r.to_tag=Ss.newTag(),!this._createDialog(r,"UAS",!0)){r.reply(500,"Missing Contact header field");return}r.body?this._late_sdp=!1:this._late_sdp=!0,this._status=ye.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{r.reply(408),console.log("failed 6"),this._failed("local",null,Ie.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),o&&(this._timers.expiresTimer=setTimeout(()=>{this._status===ye.STATUS_WAITING_FOR_ANSWER&&(r.reply(487),console.log("failed 7"),this._failed("system",null,Ie.causes.EXPIRES))},o)),this._direction="incoming",this._local_identity=r.to,this._remote_identity=r.from,n&&n(this),r.parseSDP(!0),this.target_addr=r.sdp.media[0].invalid[1].value.replaceAll("path:","").split(" ").reverse(),this._newMSRPSession("remote",r),this._status!==ye.STATUS_TERMINATED&&(r.reply(180,null,[`Contact: ${this._ua._contact}`]),this._progress("local",null))}_failed(r,n,o){this.emit("_failed",{originator:r,message:n||null,cause:o}),this._close(),this.emit("failed",{originator:r,message:n||null,cause:o})}_close(){if(console.log("CLOSE SESSION"),this._status!==ye.STATUS_TERMINATED){if(this._status=ye.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(r){console.log("close() | error closing the RTCPeerConnection: %o",r)}for(const r in this._timers)Object.prototype.hasOwnProperty.call(this._timers,r)&&clearTimeout(this._timers[r]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const r in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,r)&&(this._earlyDialogs[r].terminate(),delete this._earlyDialogs[r]);for(const r in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,r)&&delete this._referSubscribers[r];this._ua.destroyMSRPSession(this)}}_createDialog(r,n,o){const a=n==="UAS"?r.to_tag:r.from_tag,t=n==="UAS"?r.from_tag:r.to_tag,s=r.call_id+a+t;let p=this._earlyDialogs[s];if(o)return p?!0:(p=new Kl(this,r,n,Kl.C.STATUS_EARLY),p.error?(console.log("failed 8"),this._failed("remote",r,Ie.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[s]=p,!0));{if(this._from_tag=r.from_tag,this._to_tag=r.to_tag,p)return p.update(r,n),this._dialog=p,delete this._earlyDialogs[s],!0;const h=new Kl(this,r,n);return h.error?(console.log("failed 9"),this._failed("remote",r,Ie.causes.INTERNAL_ERROR),!1):(this._dialog=h,!0)}}_newMSRPSession(r,n){this._ua.newMSRPSession(this,{originator:r,session:this,request:n})}_progress(r,n){this.emit("progress",{originator:r,response:n||null})}isEnded(){switch(this._status){case ye.STATUS_CANCELED:case ye.STATUS_TERMINATED:return!0;default:return!1}}_accepted(r,n){console.log("session accepted"),this._start_time=new Date,console.log('emit "accepted"'),this.emit("accepted",{originator:r,response:n||null})}_confirmed(r,n){console.log("session confirmed"),this._is_confirmed=!0,console.log('emit "confirmed"'),this.emit("confirmed",{originator:r,ack:n||null})}_ended(r,n,o){console.log("session ended"),this._end_time=new Date,this._close(),console.log('emit "ended"'),this.emit("ended",{originator:r,message:n||null,cause:o})}_handleSessionTimersInIncomingResponse(r){if(!this._sessionTimers.enabled)return;let n;r.session_expires&&r.session_expires>=Ie.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=r.session_expires,n=r.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,n="uac"),this._sessionTimers.refresher=n==="uac",this._runSessionTimer()}receiveRequest(r){if(console.log("receiveRequest()"),r.method===Ie.CANCEL)(this._status===ye.STATUS_WAITING_FOR_ANSWER||this._status===ye.STATUS_ANSWERED)&&(this._status=ye.STATUS_CANCELED,this._request.reply(487),console.log("failed 10"),this._failed("remote",r,Ie.causes.CANCELED));else switch(r.method){case Ie.ACK:if(this._status!==ye.STATUS_WAITING_FOR_ACK)return;if(this._status=ye.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!r.body){this.terminate({cause:Ie.causes.MISSING_SDP,status_code:400});break}const n={originator:"remote",type:"answer",sdp:r.body};console.log('emit "sdp"'),this.emit("sdp",n);const o=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(o)).then(()=>{this._is_confirmed||this._confirmed("remote",r)}).catch(a=>{this.terminate({cause:Ie.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),console.log('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)})}else this._is_confirmed||this._confirmed("remote",r);break;case Ie.BYE:this._status===ye.STATUS_CONFIRMED||this._status===ye.STATUS_WAITING_FOR_ACK?(r.reply(200),this._ended("remote",r,Ie.causes.BYE)):this._status===ye.STATUS_INVITE_RECEIVED||this._status===ye.STATUS_WAITING_FOR_ANSWER?(r.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",r,Ie.causes.BYE)):r.reply(403,"Wrong Status");break;case Ie.INVITE:this._status===ye.STATUS_CONFIRMED?r.hasHeader("replaces")?this._receiveReplaces(r):this._receiveReinvite(r):r.reply(403,"Wrong Status");break;case Ie.INFO:this._status===ye.STATUS_1XX_RECEIVED||this._status===ye.STATUS_WAITING_FOR_ANSWER||this._status===ye.STATUS_ANSWERED||this._status===ye.STATUS_WAITING_FOR_ACK||this._status===ye.STATUS_CONFIRMED?(r.hasHeader("Content-Type")?r.getHeader("Content-Type").toLowerCase():void 0)!==void 0?new bm(this).init_incoming(r):r.reply(415):r.reply(403,"Wrong Status");break;case Ie.UPDATE:this._status===ye.STATUS_CONFIRMED?this._receiveUpdate(r):r.reply(403,"Wrong Status");break;case Ie.REFER:this._status===ye.STATUS_CONFIRMED?this._receiveRefer(r):r.reply(403,"Wrong Status");break;case Ie.NOTIFY:this._status===ye.STATUS_CONFIRMED?this._receiveNotify(r):r.reply(403,"Wrong Status");break;default:r.reply(501)}}onTransportError(){console.log("onTransportError()"),this._status!==ye.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:Ie.causes.CONNECTION_ERROR,cause:Ie.causes.CONNECTION_ERROR})}onRequestTimeout(){console.log("onRequestTimeout()"),this._status!==ye.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:Ie.causes.REQUEST_TIMEOUT,cause:Ie.causes.REQUEST_TIMEOUT})}onDialogError(){console.log("onDialogError()"),this._status!==ye.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:Ie.causes.DIALOG_ERROR,cause:Ie.causes.DIALOG_ERROR})}}const zt=console,xf={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2},Pg=Ng;class kg extends Pg{constructor(r){console.log(r),super(r),this._msrp_sessions=[],this._transactions={nist:{},nict:{},ist:{},ict:{}}}call(r,n){return super.call(r,n)}newMSRPSession(r,n){r.on("msgHistoryUpdate",o=>{console.log(o)}),this._msrp_sessions[r.id]=r,this.emit("newMSRPSession",n)}destroyMSRPSession(r){delete this._msrp_sessions[r.id]}receiveRequest(r){const n=r.method;if(console.log("-----------"),r.ruri.user!==this._configuration.uri.user&&r.ruri.user!==this._contact.uri.user){zt.debug("Request-URI does not point to us"),r.method!==we.ACK&&r.reply_sl(404);return}if(r.ruri.scheme===we.SIPS){r.reply_sl(416);return}if(Ur.checkTransaction(this,r))return;if(n===we.INVITE?new Ur.InviteServerTransaction(this,this._transport,r):n!==we.ACK&&n!==we.CANCEL&&new Ur.NonInviteServerTransaction(this,this._transport,r),n===we.OPTIONS){if(this.listeners("newOptions").length===0){r.reply(200);return}new Kc.Options(this).init_incoming(r)}else if(n===we.MESSAGE){if(this.listeners("newMessage").length===0){r.reply(405);return}new Kc.Message(this).init_incoming(r)}else if(n===we.INVITE&&!r.to_tag&&this.listeners("newRTCSession").length===0){r.reply(405);return}let o,a;if(r.to_tag)o=this._findDialog(r.call_id,r.from_tag,r.to_tag),o?o.receiveRequest(r):n===we.NOTIFY?(a=this._findSession(r),a?a.receiveRequest(r):(zt.debug("received NOTIFY request for a non existent subscription"),r.reply(481,"Subscription does not exist"))):n!==we.ACK&&r.reply(481);else switch(n){case we.INVITE:if(window.RTCPeerConnection)if(r.hasHeader("replaces")){const t=r.replaces;o=this._findDialog(t.call_id,t.from_tag,t.to_tag),o?(a=o.owner,a.isEnded()?r.reply(603):a.receiveRequest(r)):r.reply(481)}else r.body.search(/MSRP/ig)>-1?(a=new Mf(this),a.init_incoming(r)):(a=new qm(this),a.init_incoming(r));else zt.warn("INVITE received but WebRTC is not supported"),r.reply(488);break;case we.BYE:r.reply(481);break;case we.CANCEL:a=this._findSession(r),a?a.receiveRequest(r):zt.debug("received CANCEL request for a non existent session");break;case we.ACK:break;case we.NOTIFY:this.emit("sipEvent",{event:r.event,request:r}),r.reply(200);break;default:r.reply(405);break}}startMSRP(r,n){zt.debug("startMSRP()",n);const o=new Mf(this);return o.connect(r),o}terminateMSRPSessions(r){zt.debug("terminateSessions()");for(const n in this._msrp_sessions)this._msrp_sessions[n].isEnded()||this._msrp_sessions[n].terminate(r)}stop(){if(zt.debug("stop()"),this._dynConfiguration={},this._status===xf.STATUS_USER_CLOSED){zt.debug("UA already closed");return}this._registrator.close();const r=Object.keys(this._sessions).length;for(const o in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,o)){zt.debug(`closing session ${o}`);try{this._sessions[o].terminate()}catch(a){console.error(a)}}for(const o in this._msrp_sessions)if(Object.prototype.hasOwnProperty.call(this._msrp_sessions,o)){zt.debug(`closing session ${o}`);try{this._msrp_sessions[o].terminate()}catch(a){console.error(a)}}for(const o in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,o))try{this._applicants[o].close()}catch(a){console.error(a)}this._status=xf.STATUS_USER_CLOSED,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&&r===0?this._transport.disconnect():this._closeTimer=setTimeout(()=>{this._closeTimer=null,this._transport.disconnect()},2e3)}}var pt={};pt.forEach=async(c,r,n)=>{const o=[];for(let a=0;a<c.length;a++)if(a in c){const t=Promise.resolve(c[a]).then(s=>r.call(n||globalThis,s,a,c));o.push(t)}await Promise.all(o)},pt.forEachSeries=async(c,r,n)=>{for(let o=0;o<c.length;o++)o in c&&await r.call(n||globalThis,await c[o],o,c)},pt.map=async(c,r,n)=>{const o=[];for(let a=0;a<c.length;a++)a in c&&(o[a]=Promise.resolve(c[a]).then(t=>r.call(n||globalThis,t,a,c)));return Promise.all(o)},pt.mapSeries=async(c,r,n)=>{const o=[];for(let a=0;a<c.length;a++)a in c&&(o[a]=await r.call(n||globalThis,await c[a],a,c));return o},pt.find=(c,r,n)=>new Promise((o,a)=>{if(c.length===0)return o();let t=1;for(let s=0;s<c.length;s++){const p=h=>{h?o(c[s]):t===c.length&&o(),t++};Promise.resolve(c[s]).then(h=>r.call(n||globalThis,h,s,c)).then(p).catch(a)}}),pt.findSeries=async(c,r,n)=>{for(let o=0;o<c.length;o++)if(await r.call(n||globalThis,await c[o],o,c))return c[o]},pt.findIndex=(c,r,n)=>new Promise((o,a)=>{if(c.length===0)return o(-1);let t=1;for(let s=0;s<c.length;s++){const p=h=>{h?o(s):t===c.length&&o(-1),t++};Promise.resolve(c[s]).then(h=>r.call(n||globalThis,h,s,c)).then(p).catch(a)}}),pt.findIndexSeries=async(c,r,n)=>{for(let o=0;o<c.length;o++)if(await r.call(n||globalThis,await c[o],o,c))return o},pt.some=(c,r,n)=>new Promise((o,a)=>{if(c.length===0)return o(!1);let t=1;for(let s=0;s<c.length;s++){if(!(s in c)){t++;continue}const p=h=>{h?o(!0):t===c.length&&o(!1),t++};Promise.resolve(c[s]).then(h=>r.call(n||globalThis,h,s,c)).then(p).catch(a)}}),pt.someSeries=async(c,r,n)=>{for(let o=0;o<c.length;o++)if(o in c&&await r.call(n||globalThis,await c[o],o,c))return!0;return!1},pt.every=(c,r,n)=>new Promise((o,a)=>{if(c.length===0)return o(!0);let t=1;for(let s=0;s<c.length;s++){if(!(s in c)){t++;continue}const p=h=>{h?t===c.length&&o(!0):o(!1),t++};Promise.resolve(c[s]).then(h=>r.call(n||globalThis,h,s,c)).then(p).catch(a)}}),pt.everySeries=async(c,r,n)=>{for(let o=0;o<c.length;o++)if(o in c&&!await r.call(n||globalThis,await c[o],o,c))return!1;return!0},pt.filter=(c,r,n)=>new Promise(async(o,a)=>{const t=[];for(let p=0;p<c.length;p++)p in c&&(t[p]=Promise.resolve(c[p]).then(h=>r.call(n||globalThis,h,p,c)).catch(a));const s=[];for(let p=0;p<t.length;p++)await t[p]&&s.push(await c[p]);o(s)}),pt.filterSeries=async(c,r,n)=>{const o=[];for(let a=0;a<c.length;a++)a in c&&await r.call(n||globalThis,await c[a],a,c)&&o.push(await c[a]);return o},pt.reduce=async(c,r,n)=>{if(c.length===0&&n===void 0)throw TypeError("Reduce of empty array with no initial value");let o,a;for(n!==void 0?(a=n,o=0):(a=c[0],o=1),o;o<c.length;o++)o in c&&(a=await r(await a,await c[o],o,c));return a};var Lf={};(function(c){const r=pt;Object.keys(r).forEach(n=>{const o=n.charAt(0).toUpperCase()+n.slice(1);c[`async${o}`]=async function(...a){return r[n](this,...a)}})})(Lf);var $f=Object.assign(pt,{instanceMethods:Lf});function za(c){return c<10?`0${c}`:`${c}`}function Mg(c){let r=c.hours||0,n=c.minutes||0,o=c.seconds||0;o++,o===60&&(o=0,n++,n===60&&(n=0,r++));const a=`${za(r)}:${za(n)}:${za(o)}`;return{seconds:o,minutes:n,hours:r,formatted:a}}function xg(c,r){return Object.keys(c).filter(n=>r.includes(n)).reduce((n,o)=>{const a=o;return{...n,[a]:c[a]}},{})}const Ks=new AudioContext,Lg=["roomId","_audioMuted","_cancel_reason","_contact","direction","_end_time","_eventsCount","_from_tag","_id","_is_canceled","_is_confirmed","_late_sdp","_localHold","_videoMuted","status","start_time","_remote_identity","audioTag","isOnHold","localMuted","autoAnswer"],$g=["_cancel_reason","_contact","direction","_end_time","_eventsCount","_from_tag","_id","_is_canceled","_is_confirmed","_late_sdp","status","start_time","_remote_identity","target_addr"];function Hf(c){const r={};return Lg.forEach(n=>{c[n]!==void 0&&(r[n]=c[n])}),r.localHold=c._localHold,r}function Ff(c){const r={};return $g.forEach(n=>{c[n]!==void 0&&(r[n]=c[n])}),r}function qf(c,r){const n=Ks.createMediaStreamSource(c),o=Ks.createMediaStreamDestination(),a=Ks.createGain();return n.connect(a),a.connect(o),a.gain.value=r,o.stream}function Hg(c,r,n,o){const a=document.createElement("audio");a.id=r._id,a.className="audioTag",a.srcObject=c.stream,a.setSinkId(n),a.volume=o,a.play(),r.audioTag=a}function Fg(c){if(c&&typeof c.log=="function"&&typeof c.warn=="function"&&typeof c.error=="function")return!0}var qg={exports:{}};(function(c){var r=function(n){var o=Object.prototype,a=o.hasOwnProperty,t=Object.defineProperty||function(Q,W,B){Q[W]=B.value},s,p=typeof Symbol=="function"?Symbol:{},h=p.iterator||"@@iterator",d=p.asyncIterator||"@@asyncIterator",g=p.toStringTag||"@@toStringTag";function v(Q,W,B){return Object.defineProperty(Q,W,{value:B,enumerable:!0,configurable:!0,writable:!0}),Q[W]}try{v({},"")}catch{v=function(W,B,te){return W[B]=te}}function E(Q,W,B,te){var de=W&&W.prototype instanceof ie?W:ie,Ae=Object.create(de.prototype),Ue=new P(te||[]);return t(Ae,"_invoke",{value:Y(Q,B,Ue)}),Ae}n.wrap=E;function S(Q,W,B){try{return{type:"normal",arg:Q.call(W,B)}}catch(te){return{type:"throw",arg:te}}}var C="suspendedStart",I="suspendedYield",w="executing",F="completed",L={};function ie(){}function N(){}function H(){}var ve={};v(ve,h,function(){return this});var me=Object.getPrototypeOf,M=me&&me(me(Z([])));M&&M!==o&&a.call(M,h)&&(ve=M);var D=H.prototype=ie.prototype=Object.create(ve);N.prototype=H,t(D,"constructor",{value:H,configurable:!0}),t(H,"constructor",{value:N,configurable:!0}),N.displayName=v(H,g,"GeneratorFunction");function j(Q){["next","throw","return"].forEach(function(W){v(Q,W,function(B){return this._invoke(W,B)})})}n.isGeneratorFunction=function(Q){var W=typeof Q=="function"&&Q.constructor;return W?W===N||(W.displayName||W.name)==="GeneratorFunction":!1},n.mark=function(Q){return Object.setPrototypeOf?Object.setPrototypeOf(Q,H):(Q.__proto__=H,v(Q,g,"GeneratorFunction")),Q.prototype=Object.create(D),Q},n.awrap=function(Q){return{__await:Q}};function V(Q,W){function B(Ae,Ue,Se,ne){var Te=S(Q[Ae],Q,Ue);if(Te.type==="throw")ne(Te.arg);else{var tt=Te.arg,st=tt.value;return st&&typeof st=="object"&&a.call(st,"__await")?W.resolve(st.__await).then(function(ge){B("next",ge,Se,ne)},function(ge){B("throw",ge,Se,ne)}):W.resolve(st).then(function(ge){tt.value=ge,Se(tt)},function(ge){return B("throw",ge,Se,ne)})}}var te;function de(Ae,Ue){function Se(){return new W(function(ne,Te){B(Ae,Ue,ne,Te)})}return te=te?te.then(Se,Se):Se()}t(this,"_invoke",{value:de})}j(V.prototype),v(V.prototype,d,function(){return this}),n.AsyncIterator=V,n.async=function(Q,W,B,te,de){de===void 0&&(de=Promise);var Ae=new V(E(Q,W,B,te),de);return n.isGeneratorFunction(W)?Ae:Ae.next().then(function(Ue){return Ue.done?Ue.value:Ae.next()})};function Y(Q,W,B){var te=C;return function(Ae,Ue){if(te===w)throw new Error("Generator is already running");if(te===F){if(Ae==="throw")throw Ue;return et()}for(B.method=Ae,B.arg=Ue;;){var Se=B.delegate;if(Se){var ne=$(Se,B);if(ne){if(ne===L)continue;return ne}}if(B.method==="next")B.sent=B._sent=B.arg;else if(B.method==="throw"){if(te===C)throw te=F,B.arg;B.dispatchException(B.arg)}else B.method==="return"&&B.abrupt("return",B.arg);te=w;var Te=S(Q,W,B);if(Te.type==="normal"){if(te=B.done?F:I,Te.arg===L)continue;return{value:Te.arg,done:B.done}}else Te.type==="throw"&&(te=F,B.method="throw",B.arg=Te.arg)}}}function $(Q,W){var B=W.method,te=Q.iterator[B];if(te===s)return W.delegate=null,B==="throw"&&Q.iterator.return&&(W.method="return",W.arg=s,$(Q,W),W.method==="throw")||B!=="return"&&(W.method="throw",W.arg=new TypeError("The iterator does not provide a '"+B+"' method")),L;var de=S(te,Q.iterator,W.arg);if(de.type==="throw")return W.method="throw",W.arg=de.arg,W.delegate=null,L;var Ae=de.arg;if(!Ae)return W.method="throw",W.arg=new TypeError("iterator result is not an object"),W.delegate=null,L;if(Ae.done)W[Q.resultName]=Ae.value,W.next=Q.nextLoc,W.method!=="return"&&(W.method="next",W.arg=s);else return Ae;return W.delegate=null,L}j(D),v(D,g,"Generator"),v(D,h,function(){return this}),v(D,"toString",function(){return"[object Generator]"});function X(Q){var W={tryLoc:Q[0]};1 in Q&&(W.catchLoc=Q[1]),2 in Q&&(W.finallyLoc=Q[2],W.afterLoc=Q[3]),this.tryEntries.push(W)}function U(Q){var W=Q.completion||{};W.type="normal",delete W.arg,Q.completion=W}function P(Q){this.tryEntries=[{tryLoc:"root"}],Q.forEach(X,this),this.reset(!0)}n.keys=function(Q){var W=Object(Q),B=[];for(var te in W)B.push(te);return B.reverse(),function de(){for(;B.length;){var Ae=B.pop();if(Ae in W)return de.value=Ae,de.done=!1,de}return de.done=!0,de}};function Z(Q){if(Q){var W=Q[h];if(W)return W.call(Q);if(typeof Q.next=="function")return Q;if(!isNaN(Q.length)){var B=-1,te=function de(){for(;++B<Q.length;)if(a.call(Q,B))return de.value=Q[B],de.done=!1,de;return de.value=s,de.done=!0,de};return te.next=te}}return{next:et}}n.values=Z;function et(){return{value:s,done:!0}}return P.prototype={constructor:P,reset:function(Q){if(this.prev=0,this.next=0,this.sent=this._sent=s,this.done=!1,this.delegate=null,this.method="next",this.arg=s,this.tryEntries.forEach(U),!Q)for(var W in this)W.charAt(0)==="t"&&a.call(this,W)&&!isNaN(+W.slice(1))&&(this[W]=s)},stop:function(){this.done=!0;var Q=this.tryEntries[0],W=Q.completion;if(W.type==="throw")throw W.arg;return this.rval},dispatchException:function(Q){if(this.done)throw Q;var W=this;function B(ne,Te){return Ae.type="throw",Ae.arg=Q,W.next=ne,Te&&(W.method="next",W.arg=s),!!Te}for(var te=this.tryEntries.length-1;te>=0;--te){var de=this.tryEntries[te],Ae=de.completion;if(de.tryLoc==="root")return B("end");if(de.tryLoc<=this.prev){var Ue=a.call(de,"catchLoc"),Se=a.call(de,"finallyLoc");if(Ue&&Se){if(this.prev<de.catchLoc)return B(de.catchLoc,!0);if(this.prev<de.finallyLoc)return B(de.finallyLoc)}else if(Ue){if(this.prev<de.catchLoc)return B(de.catchLoc,!0)}else if(Se){if(this.prev<de.finallyLoc)return B(de.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(Q,W){for(var B=this.tryEntries.length-1;B>=0;--B){var te=this.tryEntries[B];if(te.tryLoc<=this.prev&&a.call(te,"finallyLoc")&&this.prev<te.finallyLoc){var de=te;break}}de&&(Q==="break"||Q==="continue")&&de.tryLoc<=W&&W<=de.finallyLoc&&(de=null);var Ae=de?de.completion:{};return Ae.type=Q,Ae.arg=W,de?(this.method="next",this.next=de.finallyLoc,L):this.complete(Ae)},complete:function(Q,W){if(Q.type==="throw")throw Q.arg;return Q.type==="break"||Q.type==="continue"?this.next=Q.arg:Q.type==="return"?(this.rval=this.arg=Q.arg,this.method="return",this.next="end"):Q.type==="normal"&&W&&(this.next=W),L},finish:function(Q){for(var W=this.tryEntries.length-1;W>=0;--W){var B=this.tryEntries[W];if(B.finallyLoc===Q)return this.complete(B.completion,B.afterLoc),U(B),L}},catch:function(Q){for(var W=this.tryEntries.length-1;W>=0;--W){var B=this.tryEntries[W];if(B.tryLoc===Q){var te=B.completion;if(te.type==="throw"){var de=te.arg;U(B)}return de}}throw new Error("illegal catch attempt")},delegateYield:function(Q,W,B){return this.delegate={iterator:Z(Q),resultName:W,nextLoc:B},this.method==="next"&&(this.arg=s),L}},n}(c.exports);try{regeneratorRuntime=r}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}})(qg);var Vf={exports:{}};(function(c){(function(r,n){c.exports?c.exports=n():r.log=n()})(or,function(){var r=function(){},n="undefined",o=typeof window!==n&&typeof window.navigator!==n&&/Trident\/|MSIE /.test(window.navigator.userAgent),a=["trace","debug","info","warn","error"];function t(I,w){var F=I[w];if(typeof F.bind=="function")return F.bind(I);try{return Function.prototype.bind.call(F,I)}catch{return function(){return Function.prototype.apply.apply(F,[I,arguments])}}}function s(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function p(I){return I==="debug"&&(I="log"),typeof console===n?!1:I==="trace"&&o?s:console[I]!==void 0?t(console,I):console.log!==void 0?t(console,"log"):r}function h(I,w){for(var F=0;F<a.length;F++){var L=a[F];this[L]=F<I?r:this.methodFactory(L,I,w)}this.log=this.debug}function d(I,w,F){return function(){typeof console!==n&&(h.call(this,w,F),this[I].apply(this,arguments))}}function g(I,w,F){return p(I)||d.apply(this,arguments)}function v(I,w,F){var L=this,ie;w=w??"WARN";var N="loglevel";typeof I=="string"?N+=":"+I:typeof I=="symbol"&&(N=void 0);function H(D){var j=(a[D]||"silent").toUpperCase();if(!(typeof window===n||!N)){try{window.localStorage[N]=j;return}catch{}try{window.document.cookie=encodeURIComponent(N)+"="+j+";"}catch{}}}function ve(){var D;if(!(typeof window===n||!N)){try{D=window.localStorage[N]}catch{}if(typeof D===n)try{var j=window.document.cookie,V=j.indexOf(encodeURIComponent(N)+"=");V!==-1&&(D=/^([^;]+)/.exec(j.slice(V))[1])}catch{}return L.levels[D]===void 0&&(D=void 0),D}}function me(){if(!(typeof window===n||!N)){try{window.localStorage.removeItem(N);return}catch{}try{window.document.cookie=encodeURIComponent(N)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}L.name=I,L.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},L.methodFactory=F||g,L.getLevel=function(){return ie},L.setLevel=function(D,j){if(typeof D=="string"&&L.levels[D.toUpperCase()]!==void 0&&(D=L.levels[D.toUpperCase()]),typeof D=="number"&&D>=0&&D<=L.levels.SILENT){if(ie=D,j!==!1&&H(D),h.call(L,D,I),typeof console===n&&D<L.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+D},L.setDefaultLevel=function(D){w=D,ve()||L.setLevel(D,!1)},L.resetLevel=function(){L.setLevel(w,!1),me()},L.enableAll=function(D){L.setLevel(L.levels.TRACE,D)},L.disableAll=function(D){L.setLevel(L.levels.SILENT,D)};var M=ve();M==null&&(M=w),L.setLevel(M,!1)}var E=new v,S={};E.getLogger=function(w){if(typeof w!="symbol"&&typeof w!="string"||w==="")throw new TypeError("You must supply a name when creating a logger.");var F=S[w];return F||(F=S[w]=new v(w,E.getLevel(),E.methodFactory)),F};var C=typeof window!==n?window.log:void 0;return E.noConflict=function(){return typeof window!==n&&window.log===E&&(window.log=C),E},E.getLoggers=function(){return S},E.default=E,E})})(Vf);var Et=Vf.exports;const us=()=>`${new Date().toISOString()} | metrics`,cs=(c,r,n)=>`${c} | ${r} | ${n}`;Et.setDefaultLevel(Et.levels.TRACE);const Vg=c=>{Et.info(cs(us(),"log ",`set log level to ${c?"verbose":"info"}`)),Et.setLevel(c?Et.levels.TRACE:Et.levels.INFO)},jg=c=>{const r=[...Object.keys(Et.levels)];r.includes(c)?(Et.info(cs(us(),"log ",`update log level to ${c.toLowerCase()}`)),Et.setLevel(c)):Et.warn(cs(us(),"log ","Incorrect log level please choose one of "),r)},Ne=(c,r,n)=>{n?Et.debug(cs(us(),c,r),n):Et.debug(cs(us(),c,r))},Ja=(c,r)=>{Et.info(cs(us(),c,r))},Ws=(c,r)=>{Et.info(cs(us(),c,r))},eo=(c,r)=>{Et.warn(cs(us(),c,r))},wn=(c,r)=>{Et.error(cs(us(),c,r))};function Bg(c){return Math.floor(Math.random()*c).toString()}function jf(c,r){let n=r;return c.forEach(o=>{n=n.replace(o,"")}),n}function Gg(c,r){let n="";for(let o=0;o<r;o+=1)n+=c[Bg(c.length)];return n}function Kg({length:c=20,useLetters:r=!0,useNumbers:n=!0,includeSymbols:o=[],excludeSymbols:a=[]}={}){let t="abcdefghijklmnopqrstuvwxyz",s="0123456789",p=[],h=[],d=[];return r&&(a.length&&(t=jf(a,t)),h=t.split("")),n&&(a.length&&(s=jf(a,s)),d=s.split("")),p=[...h,...d,...o],Gg(p,c)}var Wg=Kg;const qr=vt(Wg),Yg=()=>"WebRTCMetrics",zg=()=>"5.0.3",ke={INBOUND:"inbound",OUTBOUND:"outbound"},fs={IDLE:"idle",RUNNING:"running",MUTED:"muted"},Vr={NEW:"new",CHECKING:"checking",CONNECTED:"connected",COMPLETED:"completed",DISCONNECTED:"disconnected",FAILED:"failed",CLOSED:"closed"},Jg=()=>({...{delta_time_to_measure_probes_ms:0,delta_time_consumed_to_measure_ms:0,delta_KBytes_in:0,delta_KBytes_out:0,delta_kbs_in:0,delta_kbs_out:0,total_time_decoded_in:0,total_time_encoded_out:0,probes:[]}}),Bf={level_in:0,codec_id_in:"",codec_in:{mime_type:null,clock_rate:null,sdp_fmtp_line:null},delta_jitter_ms_in:0,percent_packets_lost_in:0,delta_packets_in:0,delta_packets_lost_in:0,total_packets_in:0,total_packets_lost_in:0,total_KBytes_in:0,delta_KBytes_in:0,delta_kbs_in:0,mos_in:0,mos_emodel_in:0,ssrc:"",direction:ke.INBOUND},Gf={level_out:0,codec_id_out:"",codec_out:{mime_type:null,clock_rate:null,sdp_fmtp_line:null},delta_jitter_ms_out:0,delta_rtt_ms_out:null,total_rtt_ms_out:0,total_rtt_measure_out:0,percent_packets_lost_out:0,delta_packets_out:0,delta_packets_lost_out:0,total_packets_out:0,total_packets_lost_out:0,total_KBytes_out:0,delta_KBytes_out:0,delta_kbs_out:0,timestamp_out:null,mos_out:0,mos_emodel_out:0,ssrc:"",direction:ke.OUTBOUND},Kf={codec_id_in:"",size_in:{width:null,height:null,framerate:null},codec_in:{mime_type:null,clock_rate:null},delta_jitter_ms_in:0,percent_packets_lost_in:0,delta_packets_in:0,delta_packets_lost_in:0,total_packets_in:0,total_packets_lost_in:0,total_KBytes_in:0,delta_KBytes_in:0,delta_kbs_in:0,decoder_in:null,delta_ms_decode_frame_in:0,total_frames_decoded_in:0,total_time_decoded_in:0,delta_nack_sent_in:0,delta_pli_sent_in:0,total_nack_sent_in:0,total_pli_sent_in:0,ssrc:"",direction:ke.INBOUND},Wf={codec_id_out:"",size_out:{width:null,height:null,framerate:null},codec_out:{mime_type:null,clock_rate:null},delta_jitter_ms_out:0,delta_rtt_ms_out:null,total_rtt_ms_out:0,total_rtt_measure_out:0,percent_packets_lost_out:0,delta_packets_out:0,delta_packets_lost_out:0,total_packets_out:0,total_packets_lost_out:0,total_KBytes_out:0,delta_KBytes_out:0,delta_kbs_out:0,encoder_out:null,delta_ms_encode_frame_out:0,total_time_encoded_out:0,total_frames_encoded_out:0,delta_nack_received_out:0,delta_pli_received_out:0,total_nack_received_out:0,total_pli_received_out:0,limitation_out:{reason:null,durations:null,resolutionChanges:0},timestamp_out:null,ssrc:"",direction:ke.OUTBOUND},Xg=c=>{const r={pname:"",call_id:"",user_id:"",timestamp:null,count:0,audio:{},video:{},network:{infrastructure:3,local_candidate_id:"",local_candidate_type:"",local_candidate_protocol:"",local_candidate_relay_protocol:"",remote_candidate_id:"",remote_candidate_type:"",remote_candidate_protocol:""},data:{total_KBytes_in:0,total_KBytes_out:0,delta_KBytes_in:0,delta_KBytes_out:0,delta_kbs_in:0,delta_kbs_out:0,delta_kbs_bandwidth_in:0,delta_kbs_bandwidth_out:0,delta_rtt_connectivity_ms:null,total_rtt_connectivity_ms:0,total_rtt_connectivity_measure:0},experimental:{time_to_measure_ms:0}};if(c){const n={...c,audio:{},video:{},data:{...c.data},network:{...c.network},experimental:{...c.experimental}};return Object.keys(c.audio).forEach(o=>{n.audio[o]={...c.audio[o]}}),Object.keys(c.video).forEach(o=>{n.video[o]={...c.video[o]}}),n}return{...r,audio:{},video:{},data:{...r.data},network:{...r.network},experimental:{...r.experimental}}},Qg={refreshEvery:2e3,startAfter:0,stopAfter:-1,verbose:!1,pname:`p-${qr()}`,cid:`c-${qr()}`,uid:`u-${qr()}`,record:!1,ticket:!0},Ft={CANDIDATE_PAIR:"candidate-pair",CODEC:"codec",INBOUND_RTP:"inbound-rtp",LOCAL_CANDIDATE:"local-candidate",MEDIA_SOURCE:"media-source",OUTBOUND_RTP:"outbound-rtp",REMOTE_CANDIDATE:"remote-candidate",REMOTE_INBOUND_RTP:"remote-inbound-rtp",TRACK:"track"},q={AUDIO_LEVEL:"audioLevel",AVAILABLE_OUTGOING_BITRATE:"availableOutgoingBitrate",AVAILABLE_INCOMING_BITRATE:"availableIncomingBitrate",BYTES_RECEIVED:"bytesReceived",BYTES_SENT:"bytesSent",CANDIDATE_TYPE:"candidateType",CHANNELS:"channels",CLOCK_RATE:"clockRate",CODEC_ID:"codecId",CURRENT_ROUND_TRIP_TIME:"currentRoundTripTime",ROUND_TRIP_TIME:"roundTripTime",FRACTION_LOST:"fractionLost",FRAME_HEIGHT:"frameHeight",FRAME_WIDTH:"frameWidth",QUALITY_LIMITATION_REASON:"qualityLimitationReason",QUALITY_LIMITATION_DURATIONS:"qualityLimitationDurations",QUALITY_LIMITATION_RESOLUTION_CHANGES:"qualityLimitationResolutionChanges",ID:"id",JITTER:"jitter",KIND:"kind",MEDIA_TYPE:"mediaType",MIME_TYPE:"mimeType",LOCAL_CANDIDATE_ID:"localCandidateId",NETWORK_TYPE:"networkType",RELAY_PROTOCOL:"relayProtocol",NOMINATED:"nominated",PACKETS_LOST:"packetsLost",PACKETS_RECEIVED:"packetsReceived",PACKETS_SENT:"packetsSent",PROTOCOL:"protocol",PORT:"port",REMOTE_CANDIDATE_ID:"remoteCandidateId",REMOTE_SOURCE:"remoteSource",RESPONSES_RECEIVED:"responsesReceived",SDP_FMTP_LINE:"sdpFmtpLine",SSRC:"ssrc",SELECTED:"selected",STATE:"state",TIMESTAMP:"timestamp",TOTAL_ROUND_TRIP_TIME:"totalRoundTripTime",TOTAL_ROUND_TRIP_TIME_MEASUREMENTS:"roundTripTimeMeasurements",TYPE:"type",DECODER_IMPLEMENTATION:"decoderImplementation",ENCODER_IMPLEMENTATION:"encoderImplementation",FRAMES_DECODED:"framesDecoded",FRAMES_ENCODED:"framesEncoded",FRAMES_PER_SECOND:"framesPerSecond",TOTAL_DECODE_TIME:"totalDecodeTime",TOTAL_ENCODE_TIME:"totalEncodeTime",PLI:"pliCount",NACK:"nackCount"},k={SUCCEEDED:"succeeded",AUDIO:"audio",VIDEO:"video"},jr={ETHERNET:0,CELLULAR_5G:2,WIFI:3,CELLULAR_4G:5,CELLULAR:10},Xa={ETHERNET:"ethernet",CELLULAR_4G:"cellular",WIFI:"wifi"},ee={AUDIO:"audio",VIDEO:"video",NETWORK:"network",DATA:"data"},Qa="config ",Zg=(c,r={},n)=>{const o={...n,...r};return r.pname||eo(Qa,`Argument [String] 'cfg.pname' for the peerConnection name or id is missing - use generated '${n.pname}'`),r.cid||eo(Qa,`Argument [String] 'cfg.cid' for the call name or id is missing - use generated '${n.cid}'`),r.uid||eo(Qa,`Argument [String] 'cfg.uid' for the user name or id is missing - use generated '${n.uid}'`),o.pc=c,o},ev=(c={})=>{const r={...Qg,...c};return r.name=Yg(),r.version=zg(),r},Br=(c,r,n,o=!1,a)=>{let t=c.map(s=>{if(!n)return s[r];if(!a)return s[r][n];const p=s[r][a];return p?p[n]:null});return t=t.filter(s=>o?Number.isFinite(s)&&s>0:Number.isFinite(s)),t.length===0?[]:t},Cs=c=>c.reduce((r,n)=>r+n,0)/c.length,tv=()=>`probe-${qr()}`,sv=()=>`coltr-${qr()}`,Yf=c=>new Promise(r=>setTimeout(r,c)),Za=(c,r,n)=>{r?c.call(r,n):c(n)},Ve=(c,r,n,o)=>{const a=Br(c,r,n,!0,o);if(a.length===0)return null;const t=a.reduce((d,g)=>d+g,0)/a.length;return t===0?null:a.map(d=>Math.abs(t-d)).reduce((d,g)=>d+g,0)/a.length*100/t},We=(c,r,n,o=!1,a)=>{const t=Br(c,r,n,o,a);return t.length===0?null:t.reduce((s,p)=>s+p,0)/t.length},Ys=(c,r,n)=>Br(c,r,n).reduce((a,t)=>a+t,0),je=(c,r,n,o)=>{const a=Br(c,r,n,!0,o);return a.length===0?null:Math.min(...a)},Be=(c,r,n,o)=>{const a=Br(c,r,n,!1,o);return a.length===0?null:Math.max(...a)},mt=(c,r,n,o)=>{const a=c.slice().pop();if(!a)return null;if(!n)return a[r];if(!o)return a[r][n];const t=a[r][o];return t?t[n]:null},nv=c=>c.slice().pop(),lt=(c,r,n)=>{if(!r)return null;const o={};let a=r[k.AUDIO][c];a||(a=n===ke.INBOUND?{...Bf}:{...Gf}),o[k.AUDIO]=a;let t=r[k.VIDEO][c];return t||(t=n===ke.INBOUND?{...Kf}:{...Wf}),o[k.VIDEO]=t,o},Gr="exporter ",rv="2.0",zf=(c,r,n)=>{if(!c||c.length===0)return 0;const o=c[c.length-1];if(!o)return 0;const a=o[r][n];if(a){const t=a.total_rtt_ms_out,s=a.total_rtt_measure_out;return!s||!t?We(c,r,"delta_rtt_ms_out",!1,n):Number(t/s)}return null},iv=(c,r)=>{if(!c||c.length===0)return 0;const n=c[c.length-1];if(!n)return 0;const o=n[r].total_rtt_connectivity_ms,a=n[r].total_rtt_connectivity_measure;return!a||!o?We(c,r,"delta_rtt_connectivity_ms"):Number(o/a)},lv=c=>mt(c,"network","local_candidate_type")!=="relay"?`direct/${mt(c,"network","local_candidate_protocol")}`:`turn/${mt(c,"network","local_candidate_relay_protocol")}`,ov=c=>{const r=mt(c,"network","remote_candidate_type"),n=mt(c,"network","remote_candidate_protocol");return r!=="relay"?`direct/${n}`:`turn/${n}`};class av{constructor(r){this._start=null,this._end=null,this._cfg=r,this._referenceReport=null,this._reports=[],this._events=[]}start(){Ja(Gr,"start() - start exporter...");const r=new Date;return this._start=r.toJSON(),r}stop(){Ja(Gr,"stop() - stop exporter...");const r=new Date;return this._end=r.toJSON(),r}saveReferenceReport(r){this._referenceReport=r}getReferenceReport(){return this._referenceReport}addReport(r){this._cfg.ticket&&(Ne(Gr,`addReport() - add report to exporter at ${r.timestamp}`),this._reports.push(r))}addCustomEvent(r){this._events.push(r)}reset(){Ja(Gr,"resetReports() - reset reports"),this._reports=[],this._referenceReport=null,this._start=null,this._end=null}get ticket(){Ne(Gr,"ticket() - generate ticket");const r=mt(this._reports,"audio","total_packets_lost_in"),n=mt(this._reports,"audio","total_packets_in"),o=mt(this._reports,"video","total_packets_lost_in"),a=mt(this._reports,"video","total_packets_in"),t={},s=nv(this._reports);return s&&(Object.keys(s[k.AUDIO]).forEach(p=>{const h=s[k.AUDIO][p];if(t[h.ssrc]={type:k.AUDIO,direction:h.direction},h.direction===ke.INBOUND){const d={avg:We(this._reports,k.AUDIO,"delta_jitter_ms_in",!1,p),min:je(this._reports,k.AUDIO,"delta_jitter_ms_in",p),max:Be(this._reports,k.AUDIO,"delta_jitter_ms_in",p),volatility:Ve(this._reports,k.AUDIO,"delta_jitter_ms_in",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:We(this._reports,k.AUDIO,"delta_kbs_in",!1,p),min:je(this._reports,k.AUDIO,"delta_kbs_in",p),max:Be(this._reports,k.AUDIO,"delta_kbs_in",p),volatility:Ve(this._reports,k.AUDIO,"delta_kbs_in",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},v={avg:We(this._reports,k.AUDIO,"delta_KBytes_in",!1,p),min:je(this._reports,k.AUDIO,"delta_KBytes_in",p),max:Be(this._reports,k.AUDIO,"delta_KBytes_in",p),volatility:Ve(this._reports,k.AUDIO,"delta_KBytes_in",p),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E={emodel:{avg:We(this._reports,k.AUDIO,"mos_emodel_in",!1,p),min:je(this._reports,k.AUDIO,"mos_emodel_in",p),max:Be(this._reports,k.AUDIO,"mos_emodel_in",p),volatility:Ve(this._reports,k.AUDIO,"mos_emodel_in",p)},effective:{avg:We(this._reports,k.AUDIO,"mos_in",!1,p),min:je(this._reports,k.AUDIO,"mos_in",p),max:Be(this._reports,k.AUDIO,"mos_in",p),volatility:Ve(this._reports,k.AUDIO,"mos_in",p)},_unit:{avg:"number (1-5)",min:"number (1-5)",max:"number (1-5)",volatility:"percent"}},S=mt(this._reports,k.AUDIO,"total_packets_lost_in",p),C=mt(this._reports,k.AUDIO,"total_packets_in",p),I={lost:S,avg:Math.round((S/(S+C)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};t[p].jitter=d,t[p].mos=E,t[p].traffic=v,t[p].bitrate=g,t[p].loss=I}else{const d={avg:We(this._reports,k.AUDIO,"delta_jitter_ms_out",!1,p),min:je(this._reports,k.AUDIO,"delta_jitter_ms_out",p),max:Be(this._reports,k.AUDIO,"delta_jitter_ms_out",p),volatility:Ve(this._reports,k.AUDIO,"delta_jitter_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:We(this._reports,k.AUDIO,"delta_kbs_out",!1,p),min:je(this._reports,k.AUDIO,"delta_kbs_out",p),max:Be(this._reports,k.AUDIO,"delta_kbs_out",p),volatility:Ve(this._reports,k.AUDIO,"delta_kbs_out",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},v={avg:We(this._reports,k.AUDIO,"delta_KBytes_out",!1,p),min:je(this._reports,k.AUDIO,"delta_KBytes_out",p),max:Be(this._reports,k.AUDIO,"delta_KBytes_out",p),volatility:Ve(this._reports,k.AUDIO,"delta_KBytes_out",p),_unit:{avg:"KB",min:"KB",max:"KB",bitrate:"kbs",volatility:"percent"}},E={avg:zf(this._reports,k.AUDIO,p),min:je(this._reports,k.AUDIO,"delta_rtt_ms_out",p),max:Be(this._reports,k.AUDIO,"delta_rtt_ms_out",p),volatility:Ve(this._reports,k.AUDIO,"delta_rtt_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},S=mt(this._reports,k.AUDIO,"total_packets_lost_out",p),C=mt(this._reports,k.AUDIO,"total_packets_out",p),I={lost:S,avg:Math.round((S/(S+C)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}},w={emodel:{avg:We(this._reports,k.AUDIO,"mos_emodel_out",!1,p),min:je(this._reports,k.AUDIO,"mos_emodel_out",p),max:Be(this._reports,k.AUDIO,"mos_emodel_out",p),volatility:Ve(this._reports,k.AUDIO,"mos_emodel_out",p)},effective:{avg:We(this._reports,k.AUDIO,"mos_out",!1,p),min:je(this._reports,k.AUDIO,"mos_out",p),max:Be(this._reports,k.AUDIO,"mos_out",p),volatility:Ve(this._reports,k.AUDIO,"mos_out",p)},_unit:{avg:"number (1-5)",min:"number (1-5)",max:"number (1-5)",volatility:"percent"}};t[p].jitter=d,t[p].rtt=E,t[p].traffic=v,t[p].bitrate=g,t[p].loss=I,t[p].mos=w}}),Object.keys(s[k.VIDEO]).forEach(p=>{const h=s[k.VIDEO][p];if(t[p]={type:k.VIDEO,direction:h.direction},h.direction===ke.INBOUND){const d={avg:We(this._reports,k.VIDEO,"delta_jitter_ms_in",!1,p),min:je(this._reports,k.VIDEO,"delta_jitter_ms_in",p),max:Be(this._reports,k.VIDEO,"delta_jitter_ms_in",p),volatility:Ve(this._reports,k.VIDEO,"delta_jitter_ms_in",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:We(this._reports,k.VIDEO,"delta_kbs_in",!1,p),min:je(this._reports,k.VIDEO,"delta_kbs_in",p),max:Be(this._reports,k.VIDEO,"delta_kbs_in",p),volatility:Ve(this._reports,k.VIDEO,"delta_kbs_in",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},v={avg:We(this._reports,k.VIDEO,"delta_KBytes_in",!1,p),min:je(this._reports,k.VIDEO,"delta_KBytes_in",p),max:Be(this._reports,k.VIDEO,"delta_KBytes_in",p),volatility:Ve(this._reports,k.VIDEO,"delta_KBytes_in",p),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E=mt(this._reports,k.VIDEO,"total_packets_lost_in",p),S=mt(this._reports,k.VIDEO,"total_packets_in",p),C={lost:E,avg:Math.round((E/(E+S)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};t[p].jitter=d,t[p].traffic=v,t[p].bitrate=g,t[p].loss=C}else{const d={avg:We(this._reports,k.VIDEO,"delta_jitter_ms_out",!1,p),min:je(this._reports,k.VIDEO,"delta_jitter_ms_out",p),max:Be(this._reports,k.VIDEO,"delta_jitter_ms_out",p),volatility:Ve(this._reports,k.VIDEO,"delta_jitter_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:We(this._reports,k.VIDEO,"delta_kbs_out",!1,p),min:je(this._reports,k.VIDEO,"delta_kbs_out",p),max:Be(this._reports,k.VIDEO,"delta_kbs_out",p),volatility:Ve(this._reports,k.VIDEO,"delta_kbs_out",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},v={avg:We(this._reports,k.VIDEO,"delta_KBytes_out",!1,p),min:je(this._reports,k.VIDEO,"delta_KBytes_out",p),max:Be(this._reports,k.VIDEO,"delta_KBytes_out",p),volatility:Ve(this._reports,k.VIDEO,"delta_KBytes_out",p),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E={avg:zf(this._reports,k.VIDEO,p),min:je(this._reports,k.VIDEO,"delta_rtt_ms_out",p),max:Be(this._reports,k.VIDEO,"delta_rtt_ms_out",p),volatility:Ve(this._reports,k.VIDEO,"delta_rtt_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},S=mt(this._reports,k.VIDEO,"total_packets_lost_out",p),C=mt(this._reports,k.VIDEO,"total_packets_out",p),I={lost:S,avg:Math.round((S/(S+C)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};t[p].jitter=d,t[p].rtt=E,t[p].traffic=v,t[p].bitrate=g,t[p].loss=I}})),{version:rv,configuration:{frequency:this._cfg.refreshEvery},started:this._start,ended:this._end,ua:{agent:navigator.userAgent,pname:this._cfg.pname,user_id:this._cfg.uid},call:{call_id:this._cfg.cid,events:this._events},details:{count:this._reports.length,reports:this._cfg.record?this._reports:[],reference:this._referenceReport||null},ssrc:t,data:{rtt:{avg:iv(this._reports,"data"),min:je(this._reports,"data","delta_rtt_connectivity_ms"),max:Be(this._reports,"data","delta_rtt_connectivity_ms"),volatility:Ve(this._reports,"data","delta_rtt_connectivity_ms"),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},packetsLost:{audio:{in:{avg:Math.round((r/(r+n)*100||0)*100)/100}},video:{in:{avg:Math.round((o/(o+a)*100||0)*100)/100}},unit:{avg:"percent"}},bitrate:{in:{avg:We(this._reports,"data","delta_kbs_in"),min:je(this._reports,"data","delta_kbs_in"),max:Be(this._reports,"data","delta_kbs_in"),volatility:Ve(this._reports,"data","delta_kbs_in")},out:{avg:We(this._reports,"data","delta_kbs_out"),min:je(this._reports,"data","delta_kbs_out"),max:Be(this._reports,"data","delta_kbs_out"),volatility:Ve(this._reports,"data","delta_kbs_out")},unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},traffic:{in:{avg:We(this._reports,"data","delta_KBytes_in"),min:je(this._reports,"data","delta_KBytes_in"),max:Be(this._reports,"data","delta_KBytes_in"),volatility:Ve(this._reports,"data","delta_KBytes_in")},out:{avg:We(this._reports,"data","delta_KBytes_out"),min:je(this._reports,"data","delta_KBytes_out"),max:Be(this._reports,"data","delta_KBytes_out"),volatility:Ve(this._reports,"data","delta_KBytes_out")},unit:{avg:"KBytes",min:"KBytes",max:"KBytes",volatility:"percent"}},network:{localConnection:lv(this._reports),remoteConnection:ov(this._reports)}}}}updateConfig(r){this._cfg=r}getLastReport(){return this._reports.slice().pop()||null}getBeforeLastReport(){const r=this._reports.slice();return r.pop(),r.pop()||null}getReportsNumber(){return this._reports.length}}const As="extractor ",Jf=(c,r,n,o)=>{let a=!1;const t=o[r].total_rtt_ms_out,s=o[r].total_rtt_measure_out,p=n?n[r].total_rtt_ms_out:0,h=n?n[r].total_rtt_measure_out:0,d={rtt:null,totalRTT:t,totalRTTMeasurements:s};if(c[q.TIMESTAMP]===o[r].timestamp_out||!Object.prototype.hasOwnProperty.call(c,q.ROUND_TRIP_TIME)||Object.prototype.hasOwnProperty.call(c,q.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS)&&(a=!0,Number(c[q.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])===0||Number(c[q.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])-h===s))return d;const g=1e3*Number(c[q.ROUND_TRIP_TIME]);let v=t+g,E=s+1;return a&&(v=1e3*Number(c[q.TOTAL_ROUND_TRIP_TIME])-p,E=Number(c[q.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])-h),{rtt:g,totalRTT:v,totalRTTMeasurements:E}},uv=(c,r,n,o)=>{if(!Object.prototype.hasOwnProperty.call(c,q.CURRENT_ROUND_TRIP_TIME))return{rtt:null,totalRTT:o[r].total_rtt_connectivity_ms,totalRTTMeasurements:o[r].total_rtt_connectivity_measure};const a=1e3*Number(c[q.CURRENT_ROUND_TRIP_TIME]);let t=o[r].total_rtt_connectivity_ms+a,s=o[r].total_rtt_connectivity_measure+1;return Object.prototype.hasOwnProperty.call(c,q.TOTAL_ROUND_TRIP_TIME)&&(t=1e3*Number(c[q.TOTAL_ROUND_TRIP_TIME])-(n?n[r].total_rtt_connectivity_ms:0)),Object.prototype.hasOwnProperty.call(c,q.RESPONSES_RECEIVED)&&(s=Number(c[q.RESPONSES_RECEIVED])-(n?n[r].total_rtt_connectivity_measure:0)),{rtt:a,totalRTT:t,totalRTTMeasurements:s}},to=(c,r,n)=>c[q.TIMESTAMP]===n[r].timestamp_out||!Object.prototype.hasOwnProperty.call(c,q.JITTER)?null:1e3*(Number(c[q.JITTER])||0),cv=(c,r)=>{if(!Object.prototype.hasOwnProperty.call(c,q.FRAMES_DECODED)||!Object.prototype.hasOwnProperty.call(c,q.TOTAL_DECODE_TIME))return{delta_ms_decode_frame:r[k.VIDEO].delta_ms_decode_frame_in,frames_decoded:r[k.VIDEO].total_frames_decoded_in,total_decode_time:r[k.VIDEO].total_time_decoded_in};const n=c[q.FRAMES_DECODED],o=c[q.TOTAL_DECODE_TIME],a=o-r[k.VIDEO].total_time_decoded_in,t=n-r[k.VIDEO].total_frames_decoded_in;return{delta_ms_decode_frame:t>0?a*1e3/t:0,frames_decoded:n,total_decode_time:o}},fv=(c,r)=>{if(!Object.prototype.hasOwnProperty.call(c,q.FRAMES_ENCODED)||!Object.prototype.hasOwnProperty.call(c,q.TOTAL_ENCODE_TIME))return{delta_ms_encode_frame:r[k.VIDEO].delta_ms_encode_frame_out,frames_encoded:r[k.VIDEO].total_frames_encoded_out,total_encode_time:r[k.VIDEO].total_time_encoded_out};const n=c[q.FRAMES_ENCODED],o=c[q.TOTAL_ENCODE_TIME],a=o-r[k.VIDEO].total_time_encoded_out,t=n-r[k.VIDEO].total_frames_encoded_out;return{delta_ms_encode_frame:t>0&&a?a*1e3/t:0,frames_encoded:n,total_encode_time:o}},Xf=(c,r,n,o)=>{if(!Object.prototype.hasOwnProperty.call(c,q.PACKETS_SENT)||!Object.prototype.hasOwnProperty.call(c,q.BYTES_SENT))return{packetsSent:n[r].total_packets_out,packetsLost:n[r].total_packets_lost_out,bytesSent:n[r].total_KBytes_out};const a=Number(c[q.PACKETS_SENT])||0-(o?o[r].total_packets_out:0),t=a-n[r].total_packets_out,s=Number(c[q.BYTES_SENT])/1024-(o?o[r].total_KBytes_out:0),p=s-n[r].total_KBytes_out,h=c[q.TIMESTAMP]||Date.now(),d=o?o.timestamp:null;let g=n.timestamp;!g&&d&&(g=d);const v=g?h-g:0,E=v>0?p*.008*1024/v*1e3:0;return{packetsSent:a,deltaPacketsSent:t,KBytesSent:s,deltaKBytesSent:p,kbsSent:E}},Qf=(c,r,n,o)=>{let a=n[r].total_packets_lost_out,t=0,s=0;return Object.prototype.hasOwnProperty.call(c,q.PACKETS_LOST)&&(a=Number(c[q.PACKETS_LOST])||0-(o?o[r].total_packets_lost_out:0),t=a-n[r].total_packets_lost_out),Object.prototype.hasOwnProperty.call(c,q.FRACTION_LOST)&&(s=Number(100*c[q.FRACTION_LOST])),{packetsLost:a,deltaPacketsLost:t,fractionLost:s}},Zf=(c,r,n,o)=>{if(!Object.prototype.hasOwnProperty.call(c,q.PACKETS_RECEIVED)||!Object.prototype.hasOwnProperty.call(c,q.PACKETS_LOST)||!Object.prototype.hasOwnProperty.call(c,q.BYTES_RECEIVED))return{percent_packets_lost:n[r].percent_packets_lost_in,packetsReceived:n[r].total_packets_in,packetsLost:n[r].total_packets_lost_in,bytesReceived:n[r].total_KBytes_in};const a=Number(c[q.PACKETS_RECEIVED])||0-(o?o[r].total_packets_in:0),t=Number(c[q.PACKETS_LOST])||0-(o?o[r].total_packets_lost_in:0),s=t-n[r].total_packets_lost_in,p=a-n[r].total_packets_in,h=a!==n[r].total_packets_in?s*100/(s+p):0,d=Number(c[q.BYTES_RECEIVED])/1024-(o?o[r].total_KBytes_in:0),g=d-n[r].total_KBytes_in,v=c[q.TIMESTAMP]||Date.now(),E=o?o.timestamp:null;let S=n.timestamp;!S&&E&&(S=E);const C=S?v-S:0,I=C>0?g*.008*1024/C*1e3:0;return{percentPacketsLost:h,packetsReceived:a,deltaPacketsReceived:p,packetsLost:t,deltaPacketsLost:s,KBytesReceived:d,deltaKBytesReceived:g,kbsReceived:I}},hv=c=>c[q.CANDIDATE_TYPE]!=="relay"?"":c[q.RELAY_PROTOCOL]||"",_v=c=>{if(!Object.prototype.hasOwnProperty.call(c,q.NETWORK_TYPE))return jr.WIFI;switch(c[q.NETWORK_TYPE]){case Xa.ETHERNET:return jr.ETHERNET;case Xa.CELLULAR_4G:return jr.CELLULAR_4G;case Xa.WIFI:return jr.WIFI;default:return jr.CELLULAR}},eh=c=>!Object.prototype.hasOwnProperty.call(c,q.FRAME_HEIGHT)||!Object.prototype.hasOwnProperty.call(c,q.FRAME_WIDTH)?{width:null,height:null,framerate:null}:{width:c[q.FRAME_WIDTH]||null,height:c[q.FRAME_HEIGHT]||null,framerate:c[q.FRAMES_PER_SECOND]},dv=c=>{const r=Object.prototype.hasOwnProperty.call(c,q.QUALITY_LIMITATION_REASON)?c[q.QUALITY_LIMITATION_REASON]:null,n=Object.prototype.hasOwnProperty.call(c,q.QUALITY_LIMITATION_RESOLUTION_CHANGES)?c[q.QUALITY_LIMITATION_RESOLUTION_CHANGES]:null,o=Object.prototype.hasOwnProperty.call(c,q.QUALITY_LIMITATION_DURATIONS)?c[q.QUALITY_LIMITATION_DURATIONS]:null;return o&&Object.keys(o).forEach(a=>{o[a]>1e3&&(o[a]=Number(o[a]/1e3))}),{reason:r,durations:o,resolutionChanges:n}},pv=(c,r,n)=>{if(!Object.prototype.hasOwnProperty.call(c,q.PLI)||!Object.prototype.hasOwnProperty.call(c,q.NACK))return{pliCount:r.total_pli_sent_in,nackCount:r.total_nack_sent_in,deltaPliCount:0,deltaNackCount:0};const o=(c[q.PLI]||0)-(n?n[k.VIDEO].total_pli_sent_in:0),a=(c[q.NACK]||0)-(n?n[k.VIDEO].total_nack_sent_in:0);return{pliCount:o,nackCount:a,deltaPliCount:o-r[k.VIDEO].total_pli_sent_in,deltaNackCount:a-r[k.VIDEO].total_nack_sent_in}},mv=(c,r,n)=>{if(!Object.prototype.hasOwnProperty.call(c,q.PLI)||!Object.prototype.hasOwnProperty.call(c,q.NACK))return{pliCount:r.total_pli_received_out,nackCount:r.total_nack_received_out,deltaPliCount:0,deltaNackCount:0};const o=(c[q.PLI]||0)-(n?n[k.VIDEO].total_pli_received_out:0),a=(c[q.NACK]||0)-(n?n[k.VIDEO].total_nack_received_out:0);return{pliCount:o,nackCount:a,deltaPliCount:o-r[k.VIDEO].total_pli_received_out,deltaNackCount:a-r[k.VIDEO].total_nack_received_out}},gv=c=>({channels:c[q.CHANNELS]||null,clock_rate:c[q.CLOCK_RATE]||null,mime_type:c[q.MIME_TYPE]||null,sdp_fmtp_line:c[q.SDP_FMTP_LINE]||null}),vv=c=>({clock_rate:c[q.CLOCK_RATE]||null,mime_type:c[q.MIME_TYPE]||null}),Tv=(c,r,n)=>{const o=(c[q.BYTES_RECEIVED]||0)/1024-(n?n.data.total_KBytes_in:0),a=(c[q.BYTES_SENT]||0)/1024-(n?n.data.total_KBytes_out:0),t=c[q.TIMESTAMP]||Date.now(),s=o-r.data.total_KBytes_in,p=a-r.data.total_KBytes_out,h=n?n.timestamp:null;let d=r.timestamp;!d&&h&&(d=h);const g=d?t-d:0,v=g>0?s*.008*1024/g*1e3:0,E=g>0?p*.008*1024/g*1e3:0;return{total_KBytes_received:o,total_KBytes_sent:a,delta_KBytes_received:s,delta_KBytes_sent:p,kbs_speed_received:v,kbs_speed_sent:E}},Ev=c=>{const r=c[q.AVAILABLE_INCOMING_BITRATE]/1024||0,n=c[q.AVAILABLE_OUTGOING_BITRATE]/1024||0;return{kbs_incoming_bandwidth:r,kbs_outgoing_bandwidth:n}},yv=(c,r,n,o)=>{if(!c)return[];switch(c[q.TYPE]){case Ft.CANDIDATE_PAIR:let a=!1;if(c[q.NOMINATED]&&c[q.STATE]===k.SUCCEEDED&&(a=!0,Ne(As,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c),q.SELECTED in c&&!c[q.SELECTED]&&(a=!1)),a){const s=c[q.LOCAL_CANDIDATE_ID],p=c[q.REMOTE_CANDIDATE_ID],h=Tv(c,r,o),d=Ev(c),g=uv(c,"data",o,r);return[{type:ee.NETWORK,value:{local_candidate_id:s}},{type:ee.NETWORK,value:{remote_candidate_id:p}},{type:ee.DATA,value:{total_KBytes_in:h.total_KBytes_received}},{type:ee.DATA,value:{total_KBytes_out:h.total_KBytes_sent}},{type:ee.DATA,value:{delta_KBytes_in:h.delta_KBytes_received}},{type:ee.DATA,value:{delta_KBytes_out:h.delta_KBytes_sent}},{type:ee.DATA,value:{delta_kbs_in:h.kbs_speed_received}},{type:ee.DATA,value:{delta_kbs_out:h.kbs_speed_sent}},{type:ee.DATA,value:{delta_kbs_bandwidth_in:d.kbs_incoming_bandwidth}},{type:ee.DATA,value:{delta_kbs_bandwidth_out:d.kbs_outgoing_bandwidth}},{type:ee.DATA,value:{delta_rtt_connectivity_ms:g.rtt}},{type:ee.DATA,value:{total_rtt_connectivity_ms:g.totalRTT}},{type:ee.DATA,value:{total_rtt_connectivity_measure:g.totalRTTMeasurements}}]}break;case Ft.LOCAL_CANDIDATE:if(c[q.ID]===r.network.local_candidate_id)return[{type:ee.NETWORK,value:{infrastructure:_v(c)}},{type:ee.NETWORK,value:{local_candidate_type:c[q.CANDIDATE_TYPE]||""}},{type:ee.NETWORK,value:{local_candidate_protocol:c[q.PROTOCOL]||""}},{type:ee.NETWORK,value:{local_candidate_relay_protocol:hv(c)}}];break;case Ft.REMOTE_CANDIDATE:if(c[q.ID]===r.network.remote_candidate_id)return[{type:ee.NETWORK,value:{remote_candidate_type:c[q.CANDIDATE_TYPE]||""}},{type:ee.NETWORK,value:{remote_candidate_protocol:c[q.PROTOCOL]||""}}];break;case Ft.INBOUND_RTP:{Ne(As,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);const s=c[q.SSRC],p=lt(s,r,ke.INBOUND);p&&(p.timestamp=r.timestamp);const h=lt(s,o,ke.INBOUND);if(h&&(h.timestamp=o.timestamp),c[q.MEDIA_TYPE]===k.AUDIO){const d=Zf(c,k.AUDIO,p,h),g=to(c,k.AUDIO,p),v=c[q.CODEC_ID]||"";return[{ssrc:s,type:ee.AUDIO,value:{codec_id_in:v}},{ssrc:s,type:ee.AUDIO,value:{total_packets_in:d.packetsReceived}},{ssrc:s,type:ee.AUDIO,value:{delta_packets_in:d.deltaPacketsReceived}},{ssrc:s,type:ee.AUDIO,value:{total_packets_lost_in:d.packetsLost}},{ssrc:s,type:ee.AUDIO,value:{delta_packets_lost_in:d.deltaPacketsLost}},{ssrc:s,type:ee.AUDIO,value:{percent_packets_lost_in:d.percentPacketsLost}},{ssrc:s,type:ee.AUDIO,value:{total_KBytes_in:d.KBytesReceived}},{ssrc:s,type:ee.AUDIO,value:{delta_KBytes_in:d.deltaKBytesReceived}},{ssrc:s,type:ee.AUDIO,value:{delta_kbs_in:d.kbsReceived}},{ssrc:s,type:ee.AUDIO,value:{delta_jitter_ms_in:g}}]}if(c[q.MEDIA_TYPE]===k.VIDEO){const d=cv(c,p),g=Zf(c,k.VIDEO,p,h),v=to(c,k.VIDEO,p),E=c[q.DECODER_IMPLEMENTATION]||null,S=c[q.CODEC_ID]||null,C=eh(c),I=pv(c,p,h);return[{ssrc:s,type:ee.VIDEO,value:{codec_id_in:S}},{ssrc:s,type:ee.VIDEO,value:{total_packets_in:g.packetsReceived}},{ssrc:s,type:ee.VIDEO,value:{delta_packets_in:g.deltaPacketsReceived}},{ssrc:s,type:ee.VIDEO,value:{total_packets_lost_in:g.packetsLost}},{ssrc:s,type:ee.VIDEO,value:{delta_packets_lost_in:g.deltaPacketsLost}},{ssrc:s,type:ee.VIDEO,value:{percent_packets_lost_in:g.percentPacketsLost}},{ssrc:s,type:ee.VIDEO,value:{total_KBytes_in:g.KBytesReceived}},{ssrc:s,type:ee.VIDEO,value:{delta_KBytes_in:g.deltaKBytesReceived}},{ssrc:s,type:ee.VIDEO,value:{delta_kbs_in:g.kbsReceived}},{ssrc:s,type:ee.VIDEO,value:{delta_jitter_ms_in:v}},{ssrc:s,type:ee.VIDEO,value:{decoder_in:E}},{ssrc:s,type:ee.VIDEO,value:{delta_ms_decode_frame_in:d.delta_ms_decode_frame}},{ssrc:s,type:ee.VIDEO,value:{total_frames_decoded_in:d.frames_decoded}},{ssrc:s,type:ee.VIDEO,value:{total_time_decoded_in:d.total_decode_time}},{ssrc:s,type:ee.VIDEO,value:{total_nack_sent_in:I.nackCount}},{ssrc:s,type:ee.VIDEO,value:{delta_nack_sent_in:I.deltaNackCount}},{ssrc:s,type:ee.VIDEO,value:{total_pli_sent_in:I.pliCount}},{ssrc:s,type:ee.VIDEO,value:{delta_pli_sent_in:I.deltaPliCount}},{ssrc:s,type:ee.VIDEO,value:{size_in:C}}]}break}case Ft.OUTBOUND_RTP:{Ne(As,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);const s=c[q.SSRC],p=lt(s,r,ke.OUTBOUND);p&&(p.timestamp=r.timestamp);const h=lt(s,o,ke.OUTBOUND);if(h&&(h.timestamp=o.timestamp),c[q.MEDIA_TYPE]===k.AUDIO){const d=c[q.CODEC_ID]||null,g=Xf(c,k.AUDIO,p,h);return[{ssrc:s,type:ee.AUDIO,value:{codec_id_out:d}},{ssrc:s,type:ee.AUDIO,value:{total_packets_out:g.packetsSent}},{ssrc:s,type:ee.AUDIO,value:{delta_packets_out:g.deltaPacketsSent}},{ssrc:s,type:ee.AUDIO,value:{total_KBytes_out:g.KBytesSent}},{ssrc:s,type:ee.AUDIO,value:{delta_KBytes_out:g.deltaKBytesSent}},{ssrc:s,type:ee.AUDIO,value:{delta_kbs_out:g.kbsSent}}]}if(c[q.MEDIA_TYPE]===k.VIDEO){const d=c[q.ENCODER_IMPLEMENTATION]||null,g=c[q.CODEC_ID]||null,v=fv(c,p),E=eh(c),S=dv(c),C=mv(c,p,h),I=Xf(c,k.VIDEO,p,h);return[{ssrc:s,type:ee.VIDEO,value:{codec_id_out:g}},{ssrc:s,type:ee.VIDEO,value:{total_packets_out:I.packetsSent}},{ssrc:s,type:ee.VIDEO,value:{delta_packets_out:I.deltaPacketsSent}},{ssrc:s,type:ee.VIDEO,value:{total_KBytes_out:I.KBytesSent}},{ssrc:s,type:ee.VIDEO,value:{delta_KBytes_out:I.deltaKBytesSent}},{ssrc:s,type:ee.VIDEO,value:{delta_kbs_out:I.kbsSent}},{ssrc:s,type:ee.VIDEO,value:{encoder_out:d}},{ssrc:s,type:ee.VIDEO,value:{delta_ms_encode_frame_out:v.delta_ms_encode_frame}},{ssrc:s,type:ee.VIDEO,value:{total_frames_encoded_out:v.frames_encoded}},{ssrc:s,type:ee.VIDEO,value:{total_time_encoded_out:v.total_encode_time}},{ssrc:s,type:ee.VIDEO,value:{total_nack_received_out:C.nackCount}},{ssrc:s,type:ee.VIDEO,value:{delta_nack_received_out:C.deltaNackCount}},{ssrc:s,type:ee.VIDEO,value:{total_pli_received_out:C.pliCount}},{ssrc:s,type:ee.VIDEO,value:{delta_pli_received_out:C.deltaPliCount}},{ssrc:s,type:ee.VIDEO,value:{size_out:E}},{ssrc:s,type:ee.VIDEO,value:{limitation_out:S}}]}break}case Ft.MEDIA_SOURCE:{Ne(As,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);break}case Ft.TRACK:{Ne(As,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);break}case Ft.CODEC:const t=[];return Object.keys(r[k.AUDIO]).forEach(s=>{const p=r[k.AUDIO][s];if(p.codec_id_in===c[q.ID]||p.codec_id_out===c[q.ID]){Ne(As,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);const h=gv(c);c[q.ID]===p.codec_id_in?t.push({ssrc:p.ssrc,type:ee.AUDIO,value:{codec_in:h}}):t.push({ssrc:p.ssrc,type:ee.AUDIO,value:{codec_out:h}})}}),Object.keys(r[k.VIDEO]).forEach(s=>{const p=r[k.VIDEO][s];if(p.codec_id_in===c[q.ID]||p.codec_id_out===c[q.ID]){Ne(As,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);const h=vv(c);c[q.ID]===p.codec_id_in?t.push({ssrc:p.ssrc,type:ee.VIDEO,value:{codec_in:h}}):t.push({ssrc:p.ssrc,type:ee.VIDEO,value:{codec_out:h}})}}),t;case Ft.REMOTE_INBOUND_RTP:{Ne(As,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);const s=c[q.SSRC],p=lt(s,r,ke.OUTBOUND),h=lt(s,o,ke.OUTBOUND);if(c[q.KIND]===k.AUDIO){const d=Jf(c,k.AUDIO,h,p),g=to(c,k.AUDIO,p),v=Qf(c,k.AUDIO,p,h);return[{ssrc:s,type:ee.AUDIO,value:{delta_rtt_ms_out:d.rtt}},{ssrc:s,type:ee.AUDIO,value:{total_rtt_ms_out:d.totalRTT}},{ssrc:s,type:ee.AUDIO,value:{total_rtt_measure_out:d.totalRTTMeasurements}},{ssrc:s,type:ee.AUDIO,value:{delta_jitter_ms_out:g}},{ssrc:s,type:ee.AUDIO,value:{timestamp_out:c[q.TIMESTAMP]}},{ssrc:s,type:ee.AUDIO,value:{total_packets_lost_out:v.packetsLost}},{ssrc:s,type:ee.AUDIO,value:{delta_packets_lost_out:v.deltaPacketsLost}},{ssrc:s,type:ee.AUDIO,value:{percent_packets_lost_out:v.fractionLost}}]}if(c[q.KIND]===k.VIDEO){const d=Jf(c,k.VIDEO,h,p),g=to(c,k.VIDEO,p),v=Qf(c,k.VIDEO,p,h);return[{ssrc:s,type:ee.VIDEO,value:{delta_rtt_ms_out:d.rtt}},{ssrc:s,type:ee.VIDEO,value:{total_rtt_ms_out:d.totalRTT}},{ssrc:s,type:ee.VIDEO,value:{total_rtt_measure_out:d.totalRTTMeasurements}},{ssrc:s,type:ee.VIDEO,value:{delta_jitter_ms_out:g}},{ssrc:s,type:ee.VIDEO,value:{timestamp_out:c[q.TIMESTAMP]}},{ssrc:s,type:ee.VIDEO,value:{total_packets_lost_out:v.packetsLost}},{ssrc:s,type:ee.VIDEO,value:{delta_packets_lost_out:v.deltaPacketsLost}},{ssrc:s,type:ee.VIDEO,value:{percent_packets_lost_out:v.fractionLost}}]}break}}return[]},so=c=>c<0?1:c>100?4.5:1+.035*c+7/1e6*c*(c-60)*(100-c),Sv=(c,r=k.AUDIO,n,o,a)=>{const t=lt(a,c,ke.INBOUND),s=lt(a,n,ke.INBOUND),p=lt(a,o,ke.INBOUND),h=[],d=[],g=t[r].percent_packets_lost_in,v=t[r].delta_jitter_ms_in,E=s&&s[r].delta_jitter_ms_in||null,S=p&&p[r].delta_jitter_ms_in||null,C=c.data.delta_rtt_connectivity_ms,I=n&&n.data.delta_rtt_connectivity_ms||null,w=o&&o.data.delta_rtt_connectivity_ms||null;C&&h.push(C),I&&h.push(I),w&&h.push(w),v&&d.push(v),n&&E&&d.push(E),o&&S&&d.push(S);const F=h.length>0?Cs(h):100,L=d.length>0?Cs(d):10,ie=93.2-g,N=.18*ie*ie-27.9*ie+1126.62,H=(F+L)/2,ve=H-177.3<0?0:1,me=.024*H+.11*(H-177.3)*ve,M=N-me;return so(M)},Cv=(c,r=k.AUDIO,n,o,a)=>{const t=lt(a,c,ke.OUTBOUND),s=lt(a,n,ke.OUTBOUND),p=lt(a,o,ke.OUTBOUND),h=[],d=[],g=t[r].percent_packets_lost_out,v=t[r].delta_rtt_ms_out,E=s&&s[r].delta_rtt_ms_out||null,S=p&&p[r].delta_rtt_ms_out||null,C=t[r].delta_jitter_ms_out,I=s&&s[r].delta_jitter_ms_out||null,w=p&&p[r].delta_jitter_ms_out||null,F=c.data.delta_rtt_connectivity_ms,L=n&&n.data.delta_rtt_connectivity_ms||null,ie=o&&o.data.delta_rtt_connectivity_ms||null;v?h.push(v):F&&h.push(F),E?h.push(E):L&&h.push(L),S?h.push(S):ie&&h.push(ie),C&&d.push(C),n&&I&&d.push(I),o&&w&&d.push(w);const N=h.length>0?Cs(h):100,H=d.length>0?Cs(d):10,ve=93.2-g,me=.18*ve*ve-27.9*ve+1126.62,M=(N+H)/2,D=M-177.3<0?0:1,j=.024*M+.11*(M-177.3)*D,V=me-j;return so(V)},Av=(c,r=k.AUDIO,n,o,a)=>{const t=lt(a,c,ke.INBOUND),s=lt(a,n,ke.INBOUND),p=lt(a,o,ke.INBOUND),h=[],d=[],g=t[r].percent_packets_lost_in/100,v=t[r].delta_jitter_ms_in,E=s&&s[r].delta_jitter_ms_in||null,S=p&&p[r].delta_jitter_ms_in||null,C=c.data.delta_rtt_connectivity_ms,I=n&&n.data.delta_rtt_connectivity_ms||null,w=o&&o.data.delta_rtt_connectivity_ms||null;C&&h.push(C),I&&h.push(I),w&&h.push(w),v&&d.push(v),s&&E&&d.push(E),p&&S&&d.push(S);const F=h.length>0?Cs(h):100,L=d.length>0?Cs(d):10,ie=0,N=19.8,H=29.7,ve=30,me=(F+L)/2+ve,M=me-177.3<0?0:1,D=.024*me+.11*(me-177.3)*M,V=93.2-(ie+N*Math.log(1+H*g)+D);return so(V)},Rv=(c,r=k.AUDIO,n,o,a)=>{const t=lt(a,c,ke.OUTBOUND),s=lt(a,n,ke.OUTBOUND),p=lt(a,o,ke.OUTBOUND),h=[],d=[],g=t[r].percent_packets_lost_out/100,v=t[r].delta_rtt_ms_out,E=s&&s[r].delta_rtt_ms_out||null,S=p&&p[r].delta_rtt_ms_out||null,C=t[r].delta_jitter_ms_out,I=s&&s[r].delta_jitter_ms_out||null,w=p&&p[r].delta_jitter_ms_out||null,F=c.data.delta_rtt_connectivity_ms,L=n&&n.data.delta_rtt_connectivity_ms||null,ie=o&&o.data.delta_rtt_connectivity_ms||null;v?h.push(v):F&&h.push(F),E?h.push(E):L&&h.push(L),S?h.push(S):ie&&h.push(ie),C&&d.push(C),s&&I&&d.push(I),p&&w&&d.push(w);const N=h.length>0?Cs(h):100,H=d.length>0?Cs(d):10,ve=0,me=19.8,M=29.7,D=30,j=(N+H)/2+D,V=j-177.3<0?0:1,Y=.024*j+.11*(j-177.3)*V,X=93.2-(ve+me*Math.log(1+M*g)+Y);return so(X)};class Iv{constructor(r,n){this._callbacks={onreport:null,onticket:null},this._id=sv(),this._moduleName=this._id,this._probeId=n,this._config=r,this._exporter=new av(r),this._state=fs.IDLE,this.registerToPCEvents(),Ws(this._moduleName,`new collector created for probe ${this._probeId}`)}analyze(r,n,o,a){const t=(h,d)=>h===k.AUDIO?d===Ft.INBOUND_RTP?{...Bf}:{...Gf}:d===Ft.INBOUND_RTP?{...Kf}:{...Wf},s=Xg(n);s.pname=this._config.pname,s.call_id=this._config.cid,s.user_id=this._config.uid,s.count=n?n.count+1:1;let p=null;return r.forEach(h=>{!p&&h.timestamp&&(p=h.timestamp),yv(h,s,s.pname,a).forEach(g=>{if(g.value&&g.type)if(g.ssrc){let v=s[g.type][g.ssrc];v||(v=t(g.type,h.type),v.ssrc=g.ssrc,s[g.type][g.ssrc]=v),Object.keys(g.value).forEach(E=>{v[E]=g.value[E]})}else Object.keys(g.value).forEach(v=>{s[g.type][v]=g.value[v]})})}),s.timestamp=p,Object.keys(s[k.AUDIO]).forEach(h=>{const d=s[k.AUDIO][h];d.direction===ke.INBOUND?(d.mos_emodel_in=Sv(s,k.AUDIO,n,o,d.ssrc),d.mos_in=Av(s,k.AUDIO,n,o,d.ssrc)):(d.mos_emodel_out=Cv(s,k.AUDIO,n,o,d.ssrc),d.mos_out=Rv(s,k.AUDIO,n,o,d.ssrc))}),s}async takeReferenceStats(){return new Promise((r,n)=>{const o=Date.now();setTimeout(async()=>{try{const a=Date.now()-o,t=Date.now(),s=await this._config.pc.getStats(),p=this.analyze(s,null,null,null),h=Date.now();p.experimental.time_to_measure_ms=h-t,p.experimental.time_to_wait_ms=a,this._exporter.saveReferenceReport(p),Ne(this._moduleName,`got reference report for probe ${this._probeId}`),r()}catch(a){n(a)}},this._config.startAfter)})}async collectStats(){try{if(this._state!==fs.RUNNING||!this._config.pc)return Ne(this._moduleName,`report discarded (too late) for probe ${this._probeId}`),null;const r=Date.now(),n=await this._config.pc.getStats(),o=this.analyze(n,this._exporter.getLastReport(),this._exporter.getBeforeLastReport(),this._exporter.getReferenceReport()),a=Date.now();return o.experimental.time_to_measure_ms=a-r,this._exporter.addReport(o),Ne(this._moduleName,`got report for probe ${this._probeId}#${this._exporter.getReportsNumber()+1}`),this.fireOnReport(o),o}catch(r){return wn(this._moduleName,`got error ${r}`),null}}async start(){Ne(this._moduleName,"starting"),this.state=fs.RUNNING,this._startedTime=this._exporter.start(),Ne(this._moduleName,"started")}async mute(){this.state=fs.MUTED,Ne(this._moduleName,"muted")}async unmute(){this.state=fs.RUNNING,Ne(this._moduleName,"unmuted")}async stop(r){if(Ne(this._moduleName,`stopping${r?" by watchdog":""}...`),this._stoppedTime=this._exporter.stop(),this.state=fs.IDLE,this._config.ticket){const{ticket:n}=this._exporter;this.fireOnTicket(n)}this._exporter.reset(),Ne(this._moduleName,"stopped")}registerCallback(r,n,o){r in this._callbacks?(this._callbacks[r]={callback:n,context:o},Ne(this._moduleName,`registered callback '${r}'`)):wn(this._moduleName,`can't register callback for '${r}' - not found`)}unregisterCallback(r){r in this._callbacks?(this._callbacks[r]=null,delete this._callbacks[r],Ne(this._moduleName,`unregistered callback '${r}'`)):wn(this._moduleName,`can't unregister callback for '${r}' - not found`)}fireOnReport(r){this._callbacks.onreport&&Za(this._callbacks.onreport.callback,this._callbacks.onreport.context,r)}fireOnTicket(r){this._callbacks.onticket&&Za(this._callbacks.onticket.callback,this._callbacks.onticket.context,r)}updateConfig(r){this._config=r,this._exporter.updateConfig(r)}get state(){return this._state}set state(r){this._state=r,Ne(this._moduleName,`state changed to ${r}`)}addCustomEvent(r,n,o,a){this._exporter.addCustomEvent({at:typeof r=="object"?r.toJSON():r,category:n,name:o,description:a})}async registerToPCEvents(){const{pc:r}=this._config;if(navigator.mediaDevices.ondevicechange=async()=>{try{const n=await navigator.mediaDevices.enumerateDevices();this.addCustomEvent(new Date().toJSON(),"device",`${n.length} devices found`,"Media Devices state")}catch{wn(this._moduleName,"can't get devices")}},r){r.oniceconnectionstatechange=()=>{const o=r.iceConnectionState;o===Vr.CONNECTED||o===Vr.COMPLETED?this.addCustomEvent(new Date().toJSON(),"call",o,"ICE connection state"):o===Vr.DISCONNECTED||o===Vr.FAILED?this.addCustomEvent(new Date().toJSON(),"call",o,"ICE connection state"):o===Vr.CLOSED&&this.addCustomEvent(new Date().toJSON(),"call","ended","ICE connection state")},r.onicegatheringstatechange=()=>{const o=r.iceGatheringState;this.addCustomEvent(new Date().toJSON(),"call",o,"ICE gathering state")},r.ontrack=o=>{this.addCustomEvent(new Date().toJSON(),"call",`${o.track.kind}track`,"MediaStreamTrack received")},r.onnegotiationneeded=()=>{this.addCustomEvent(new Date().toJSON(),"call","negotiation","Media changed")};const n=r.getReceivers();if(n&&n.length>0){const o=n[0],{transport:a}=o;if(a){const{iceTransport:t}=a;t&&(t.onselectedcandidatepairchange=()=>{this.addCustomEvent(new Date().toJSON(),"call","transport","Candidates Pair changed")})}}}}}class bv{constructor(r){this._id=r.pname&&r.pname.substr(0,12).padEnd(12," ")||tv(),this._moduleName=this._id,Ws(this._moduleName,"probe created"),this._config=r,this._collector=new Iv(this._config,this._id)}set onreport(r){r?this._collector.registerCallback("onreport",r):this._collector.unregisterCallback("onreport")}set onticket(r){r?this._collector.registerCallback("onticket",r):this._collector.unregisterCallback("onticket")}get id(){return this._id}get pname(){return this._config.pname}get cid(){return this._config.cid}get uid(){return this._config.uid}get state(){return this._collector.state}set state(r){this._collector.state=r}addCustomEvent(r,n,o,a=new Date().toJSON()){this._collector.addCustomEvent(a,n,r,o)}get isRunning(){return this._collector.state===fs.RUNNING}get isIdle(){return this._collector.state===fs.IDLE}updateUserId(r){this._config.uid=r,this._collector.updateConfig(this._config)}updateCallId(r){this._config.cid=r,this._collector.updateConfig(this._config)}start(){if(!this.isIdle){eo(this._moduleName,"probe is already running");return}this._collector.start()}stop(r=!1){this.isRunning&&this._collector.stop(r)}async takeReferenceStats(){return this._collector.takeReferenceStats()}async collectStats(){return this._collector.collectStats()}}const yt="engine ";class wv{constructor(r){this._config=r,this._probes=[],this._startedTime=null,this._callbacks={onresult:null},Ws(yt,`configured for probing every ${this._config.refreshEvery}ms`),Ws(yt,`configured for starting after ${this._config.startAfter}ms`),Ws(yt,`${!this._config.stopAfter||this._config.stopAfter!==-1?`configured for stopped after ${this._config.stopAfter}ms`:"configured for never stopped"}`),Ne(yt,"engine initialized")}get probes(){return this._probes}get isRunning(){return this._probes.some(r=>r.isRunning)}get isIdle(){return this._probes.every(r=>r.isIdle)}addNewProbe(r,n){if(!r)throw new Error("undefined peer connection");const o=Zg(r,n,this._config),a=new bv(o);return this._probes.push(a),Ne(yt,`${this._probes.length} probes registered`),a}removeExistingProbe(r){if(!r)throw new Error("undefined probe");r.state===fs.RUNNING&&r.stop(),this._probes=this._probes.filter(n=>r.id!==n.id)}async start(){const r=()=>{this._probes.forEach(t=>t.start())},n=async()=>Promise.all(this._probes.map(t=>t.takeReferenceStats())),o=()=>this.isIdle?!1:!this._config.stopAfter||this._config.stopAfter<0?!0:Date.now()<this._startedTime+this._config.stopAfter,a=async()=>{const t=Jg(),s=this._probes.filter(p=>p.isRunning);for(const p of s){const h=await p.collectStats();h&&t.probes.push(h),Ne(yt,`got probe ${p.id}`),await Yf(0)}return t.delta_time_to_measure_probes_ms=Ys(t.probes,"experimental","time_to_measure_ms"),t.delta_KBytes_in=Ys(t.probes,"data","delta_KBytes_in"),t.delta_KBytes_out=Ys(t.probes,"data","delta_KBytes_out"),t.delta_kbs_in=Ys(t.probes,"data","delta_kbs_in"),t.delta_kbs_out=Ys(t.probes,"data","delta_kbs_out"),t.total_time_decoded_in=Ys(t.probes,"video","total_time_decoded_in"),t.total_time_encoded_out=Ys(t.probes,"video","total_time_encoded_out"),t};for(Ne(yt,"starting to collect"),r(),Ne(yt,"generating reference reports..."),await n(),Ne(yt,"reference reports generated"),this._startedTime=Date.now();o();)if(Ne(yt,`wait ${this._config.refreshEvery}ms before collecting`),await Yf(this._config.refreshEvery),o()){Ne(yt,"collecting...");const t=Date.now(),s=await a(),p=Date.now();s.delta_time_consumed_to_measure_ms=p-t,this.fireOnReports(s),Ne(yt,"collected")}Ne(yt,"reaching end of the collecting period..."),this.isRunning&&setTimeout(()=>{this.stop()},0)}stop(r){const n=o=>{this._probes.forEach(a=>{a.stop(o)})};Ws(yt,"stop collecting"),n(r)}registerCallback(r,n,o){r in this._callbacks?(this._callbacks[r]={callback:n,context:o},Ne(yt,`registered callback '${r}'`)):wn(yt,`can't register callback for '${r}' - not found`)}unregisterCallback(r){r in this._callbacks?(this._callbacks[r]=null,delete this._callbacks[r],Ne(this._moduleName,`unregistered callback '${r}'`)):wn(this._moduleName,`can't unregister callback for '${r}' - not found`)}fireOnReports(r){this._callbacks.onresult&&r.probes.length>0&&Za(this._callbacks.onresult.callback,this._callbacks.onresult.context,r)}}const Ov="interface ";class Dv{constructor(r){this._config=ev(r),Ws(Ov,`welcome to ${this._config.name} version ${this._config.version}`),Vg(this._config.verbose||!1),this._engine=new wv(this._config)}setupLogLevel(r){jg(r)}get version(){return this._config.version}get name(){return this._config.name}get probes(){return this._engine.probes}createProbe(r,n){return this._engine.addNewProbe(r,n)}startAllProbes(){this._engine.start()}stopAllProbes(){this._engine.stop()}get running(){return this._engine.isRunning}get idle(){return this._engine.isIdle}removeProbe(r){this._engine.removeExistingProbe(r)}set onresult(r){r?this._engine.registerCallback("onresult",r):this._engine.unregisterCallback("onresult")}}class Nv{constructor(r){this.intervals={},this.emitInterval=r.emitInterval||200,this.onChangeFunction=r.onChangeFunction}start(r,n){r&&r.getTracks().length&&requestAnimationFrame(()=>this.beginCalculation(r,n))}stop(r){this.clearVolumeInterval(r)}clearVolumeInterval(r){console.log("clearVolumeInterval",r),clearInterval(this.intervals[r]),delete this.intervals[r]}clearAllIntervals(){Object.keys(this.intervals).forEach(r=>{clearInterval(this.intervals[r])}),this.intervals={}}beginCalculation(r,n){this.clearVolumeInterval(n);const o=Ks.createAnalyser(),a=Ks.createMediaStreamSource(r),t=Ks.createScriptProcessor(2048,1,1);o.smoothingTimeConstant=.8,o.fftSize=1024,a.connect(o),o.connect(t),t.connect(Ks.destination),this.intervals[n]=setInterval(()=>{const s=new Uint8Array(o.frequencyBinCount);o.getByteFrequencyData(s);let p=0;const h=s.length;for(let g=0;g<h;g++)p+=s[g];const d=p/h;this.onChangeFunction(n,d)},this.emitInterval)}}const Uv=it,Pv=Gt(),Ct=new Uv("WebSocketInterface");var kv=class{constructor(r){Ct.debug('new() [url:"%s"]',r),this._url=r,this._sip_uri=null,this._via_transport=null,this._ws=null;const n=Pv.parse(r,"absoluteURI");if(n===-1)throw Ct.warn(`invalid WebSocket URI: ${r}`),new TypeError(`Invalid argument: ${r}`);if(n.scheme!=="wss"&&n.scheme!=="ws")throw Ct.warn(`invalid WebSocket URI scheme: ${n.scheme}`),new TypeError(`Invalid argument: ${r}`);this._sip_uri=`sip:${n.host}${n.port?`:${n.port}`:""};transport=ws`,this._via_transport=n.scheme.toUpperCase()}get via_transport(){return this._via_transport}set via_transport(r){this._via_transport=r.toUpperCase()}get sip_uri(){return this._sip_uri}get url(){return this._url}connect(){if(Ct.debug("connect()"),this.isConnected()){Ct.debug(`WebSocket ${this._url} is already connected`);return}else if(this.isConnecting()){Ct.debug(`WebSocket ${this._url} is connecting`);return}this._ws&&this.disconnect(),Ct.debug(`connecting to WebSocket ${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(r){this._onError(r)}}disconnect(){Ct.debug("disconnect()"),this._ws&&(this._ws.onopen=()=>{},this._ws.onclose=()=>{},this._ws.onmessage=()=>{},this._ws.onerror=()=>{},this._ws.close(),this._ws=null)}send(r){return Ct.debug("send()"),this.isConnected()?(this._ws.send(r),!0):(Ct.warn("unable to send message, WebSocket is not open"),!1)}isConnected(){return this._ws&&this._ws.readyState===this._ws.OPEN}isConnecting(){return this._ws&&this._ws.readyState===this._ws.CONNECTING}_onOpen(){Ct.debug(`WebSocket ${this._url} connected`),this.onconnect()}_onClose({wasClean:r,code:n,reason:o}){Ct.debug(`WebSocket ${this._url} closed`),r===!1&&Ct.debug("WebSocket abrupt disconnection"),this.ondisconnect(!r,n,o)}_onMessage({data:r}){Ct.debug("received WebSocket message"),this.ondata(r)}_onError(r){Ct.warn(`WebSocket ${this._url} error: `,r)}};const eu=sl,Mv=we,xv=as,Lv=ft(),$v=kf,Hv=is(),Fv=Ta(),qv=Gt(),Vv=kv;vn("JsSIP")("version %s",eu.version);var jv={C:Mv,Exceptions:xv,Utils:Lv,UA:$v,URI:Hv,NameAddrHeader:Fv,WebSocketInterface:Vv,Grammar:qv,debug:vn,get name(){return eu.title},get version(){return eu.version}};const Bv=vt(jv),Gv=["mos_in","codec_in","delta_KBytes_in","delta_kbs_in","delta_jitter_ms_in","delta_packets_lost_in"],Jt={NEW_CALL:"new_call",CALL_CONFIRMED:"confirmed",CALL_FAILED:"failed",CALL_PROGRESS:"progress",CALL_ENDED:"ended"},Kv=0,no={SELECTED_INPUT_DEVICE:"OpensipsJSInputDevice",SELECTED_OUTPUT_DEVICE:"OpensipsJSOutputDevice"};class Wv extends kg{constructor(r,n){const o={...r.configuration,sockets:r.socketInterfaces.map(a=>new Bv.WebSocketInterface(a))};super(o),this.initialized=!1,this.logger=console,this.newRTCSessionEventName="newRTCSession",this.registeredEventName="registered",this.unregisteredEventName="unregistered",this.disconnectedEventName="disconnected",this.connectedEventName="connected",this.newMSRPSessionEventName="newMSRPSession",this.muted=!1,this.isAutoAnswer=!1,this.isDNDEnabled=!1,this.muteWhenJoinEnabled=!1,this.activeRooms={},this.activeCalls={},this.extendedCalls={},this.activeMessages={},this.extendedMessages={},this.msrpHistory={},this.microphoneInputLevelValue=1,this.speakerVolumeValue=1,this.availableMediaDevices=[],this.selectedMediaDevices={input:"default",output:"default"},this.callStatus={},this.callTime={},this.callMetrics={},this.timeIntervals={},this.metricConfig={refreshEvery:1e3},this.activeStreamValue=null,this.initialStreamValue=null,this.isReconnecting=!1,this.listenersList={},this.options=r,this.VUMeter=new Nv({onChangeFunction:this.emitVolumeChange.bind(this)}),n&&Fg(n)&&(this.logger=n)}on(r,n){return super.on(r,n)}off(r,n){return super.off(r,n)}emit(r,n){return super.emit(r,n)}get sipDomain(){return this.options.sipDomain}get sipOptions(){return{...this.options.sipOptions,mediaConstraints:this.getUserMediaConstraints}}get currentActiveRoomId(){return this.currentActiveRoomIdValue}set currentActiveRoomId(r){this.currentActiveRoomIdValue=r,this.emit("currentActiveRoomChanged",r)}get autoAnswer(){return this.isAutoAnswer}get callAddingInProgress(){return this.isCallAddingInProgress}set callAddingInProgress(r){this.isCallAddingInProgress=r,this.emit("callAddingInProgressChanged",r)}get isMSRPInitializing(){return this.isMSRPInitializingValue}get muteWhenJoin(){return this.muteWhenJoinEnabled}get isDND(){return this.isDNDEnabled}get speakerVolume(){return this.speakerVolumeValue}get microphoneInputLevel(){return this.microphoneInputLevelValue}get getActiveCalls(){return this.activeCalls}get hasActiveCalls(){return Object.values(this.extendedCalls).length>0}get getActiveMessages(){return this.activeMessages}get getActiveRooms(){return this.activeRooms}get isMuted(){return this.muted}get getInputDeviceList(){return this.availableMediaDevices.filter(r=>r.kind==="audioinput")}get getOutputDeviceList(){return this.availableMediaDevices.filter(r=>r.kind==="audiooutput")}get getUserMediaConstraints(){return{audio:{deviceId:{exact:this.selectedMediaDevices.input}},video:!1}}get selectedInputDevice(){return this.selectedMediaDevices.input}get selectedOutputDevice(){return this.selectedMediaDevices.output}get activeStream(){return this.activeStreamValue}setAvailableMediaDevices(r){this.availableMediaDevices=r,this.emit("changeAvailableDeviceList",r)}async updateDeviceList(){await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints);const r=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(r)}async initializeMediaDevices(){const r=localStorage.getItem(no.SELECTED_INPUT_DEVICE)||"default",n=localStorage.getItem(no.SELECTED_OUTPUT_DEVICE)||"default";(await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints)).getTracks().forEach(t=>t.stop());const a=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(a),await this.setMicrophone(r),await this.setSpeaker(n),navigator.mediaDevices.addEventListener("devicechange",async()=>{const t=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(t)})}setCallTime(r){const n={...r};delete n.callId,this.callTime={...this.callTime,[r.callId]:n},this.emit("changeCallTime",this.callTime)}removeCallTime(r){const n={...this.callTime};delete n[r],this.callTime={...n},this.emit("changeCallTime",this.callTime)}setTimeInterval(r,n){this.timeIntervals={...this.timeIntervals,[r]:n}}removeTimeInterval(r){const n={...this.timeIntervals};clearInterval(n[r]),delete n[r],this.timeIntervals={...n}}stopCallTimer(r){this.removeTimeInterval(r),this.removeCallTime(r)}emitVolumeChange(r,n){this.emit("changeCallVolume",{callId:r,volume:n})}setMetricsConfig(r){this.metricConfig={...this.metricConfig,...r}}sendDTMF(r,n){if(!/^[A-D0-9]+$/g.test(n))throw new Error("Not allowed character in DTMF input");this.extendedCalls[r].sendDTMF(n)}setIsMuted(r){this.muted=r,this.emit("changeIsMuted",r)}processMute(r){const n=this.currentActiveRoomId;this.setIsMuted(r),this.initialStreamValue.getTracks().forEach(o=>o.enabled=!r),this.roomReconfigure(n)}mute(){this.processMute(!0)}unmute(){this.processMute(!1)}async processHold({callId:r,toHold:n,automatic:o}){const a=this.extendedCalls[r];a._automaticHold=o??!1,await new Promise(p=>{const h=()=>{p()};n?a.hold({},h):a.unhold({},h)}),this.updateCall(a);const s=Object.values(this.extendedCalls).filter(p=>p.roomId===this.currentActiveRoomId&&(n?r!==p._id:!0));s.length>1&&await this.doConference(s)}holdCall(r,n=!1){return this.processHold({callId:r,automatic:n,toHold:!0})}unholdCall(r){return this.processHold({callId:r,toHold:!1})}cancelAllOutgoingUnanswered(){Object.values(this.getActiveCalls).filter(r=>r.direction==="outgoing"&&r.status===Kv).forEach(r=>this.terminateCall(r._id))}answerCall(r){const n=this.extendedCalls[r];this.cancelAllOutgoingUnanswered(),n.answer(this.sipOptions),this.updateCall(n),this.setActiveRoom(n.roomId),n.connection.addEventListener("addstream",async o=>{this.triggerAddStream(o,n)})}msrpAnswer(r){const n=this.extendedMessages[r];n.answer(this.sipOptions),this.updateMSRPSession(n)}async moveCall(r,n){this.updateCallStatus({callId:r,isMoving:!0}),await this.processRoomChange({callId:r,roomId:n}),this.updateCallStatus({callId:r,isMoving:!1})}updateCall(r){this.activeCalls[r._id]=Hf(r),this.emit("changeActiveCalls",this.activeCalls)}updateMSRPSession(r){this.activeMessages[r._id]=Ff(r),this.emit("changeActiveMessages",this.activeMessages)}updateRoom(r){const o={...this.activeRooms[r.roomId],...r};this.activeRooms={...this.activeRooms,[r.roomId]:{...o}},this.emit("updateRoom",{room:o,roomList:this.activeRooms})}hasAutoAnswerHeaders(r){const n=/answer-after=0/,a=r.request.getHeader("Call-Info");return a&&n.test(a)}addCall(r,n=!0){this.activeCalls={...this.activeCalls,[r._id]:Hf(r)},this.extendedCalls[r._id]=r,n&&this.emit("changeActiveCalls",this.activeCalls)}addCallStatus(r){this.callStatus={...this.callStatus,[r]:{isMoving:!1,isTransferring:!1,isMerging:!1}},this.emit("changeCallStatus",this.callStatus)}addMMSRPSession(r){this.activeMessages={...this.activeMessages,[r._id]:Ff(r)},this.extendedMessages[r._id]=r,this.emit("changeActiveMessages",this.activeMessages)}addMSRPMessage(r,n){const o=this.msrpHistory[n.id]||[];o.push(r),this.msrpHistory={...this.msrpHistory,[n.id]:[...o]},this.emit("newMSRPMessage",{message:r,session:n})}updateCallStatus(r){const o={...{...this.callStatus[r.callId]}};r.isMoving!==void 0&&(o.isMoving=r.isMoving),r.isTransferring!==void 0&&(o.isTransferring=r.isTransferring),r.isMerging!==void 0&&(o.isMerging=r.isMerging),this.callStatus={...this.callStatus,[r.callId]:{...o}},this.emit("changeCallStatus",this.callStatus)}removeCallStatus(r){const n={...this.callStatus};delete n[r],this.callStatus={...n},this.emit("changeCallStatus",this.callStatus)}addRoom(r){this.activeRooms={...this.activeRooms,[r.roomId]:r},this.emit("addRoom",{room:r,roomList:this.activeRooms})}getActiveStream(){const r=qf(this.initialStreamValue,this.microphoneInputLevel*2);return r.getTracks().forEach(n=>n.enabled=!this.isMuted),this.setActiveStream(r),r}async setMicrophone(r){if(!this.getInputDeviceList.find(({deviceId:o})=>o===r)||(this.setSelectedInputDevice(r),Object.keys(this.getActiveCalls).length===0))return;await this.setupStream();const n=Object.values(this.extendedCalls).filter(o=>o.roomId===this.currentActiveRoomId);n.length===1?Object.values(n).forEach(async o=>{const a=this.getActiveStream();o.connection.getSenders()[0].replaceTrack(a.getTracks()[0]),this.updateCall(o)}):await this.doConference(n)}setActiveStream(r){this.activeStream&&this.stopVUMeter("origin"),this.setupVUMeter(r,"origin"),this.activeStreamValue=r,this.emit("changeActiveStream",r)}async setSpeaker(r){if(!this.getOutputDeviceList.find(({deviceId:a})=>a===r))return;this.setSelectedOutputDevice(r);const n=Object.values(this.extendedCalls);if(n.length===0)return;const o=n.filter(a=>a.roomId===this.currentActiveRoomId);o.length===1?n.forEach(a=>{var t;(t=a.audioTag)==null||t.setSinkId(r),this.updateCall(a)}):await this.doConference(o)}removeRoom(r){const n={...this.activeRooms},o={...n[r]};delete n[r],this.activeRooms={...n},this.emit("removeRoom",{room:o,roomList:this.activeRooms})}deleteRoomIfEmpty(r){r!==void 0&&Object.values(this.extendedCalls).filter(n=>n.roomId===r).length===0&&(this.removeRoom(r),this.currentActiveRoomId===r&&(this.currentActiveRoomId=void 0))}checkInitialized(){if(!this.initialized)throw new Error("[OpenSIPSJS] You must call `start` method first!")}muteReconfigure(r){this.muted?r.mute({audio:!0}):r.unmute({audio:!0})}async roomReconfigure(r){if(r===void 0)return;const n=Object.values(this.extendedCalls).filter(o=>o.roomId===r);if(this.currentActiveRoomId===r?n.forEach(o=>{o.audioTag&&(this.muteReconfigure(o),o.audioTag.muted=!1,this.updateCall(o))}):n.forEach(o=>{o.audioTag&&(o.audioTag.muted=!0,this.updateCall(o))}),n.length===0)this.deleteRoomIfEmpty(r);else if(n.length===1&&this.currentActiveRoomId!==r)n[0].isOnHold().local||await this.holdCall(n[0].id,!0);else if(n.length===1&&this.currentActiveRoomId===r){if(n[0].isOnHold().local&&n[0]._automaticHold&&await this.unholdCall(n[0].id),n[0].connection&&n[0].connection.getSenders()[0]){const o=this.getActiveStream();await n[0].connection.getSenders()[0].replaceTrack(o.getTracks()[0]),this.muteReconfigure(n[0])}}else n.length>1&&await this.doConference(n)}async doConference(r){await $f.forEach(r,async o=>{o._localHold&&await this.unholdCall(o._id)});const n=[];r.forEach(o=>{o!=null&&o.connection.getReceivers().forEach(a=>{n.push(a.track)})}),await $f.forEach(r,async o=>{if(o==null)return;const a=new AudioContext,t=new MediaStream,s=a.createMediaStreamDestination();if(o.connection.getReceivers().forEach(p=>{n.forEach(h=>{t.addTrack(p.track),p.track.id!==h.id&&a.createMediaStreamSource(new MediaStream([h])).connect(s)})}),r[0].roomId===this.currentActiveRoomId){const p=this.getActiveStream();a.createMediaStreamSource(p).connect(s)}o.connection.getSenders()[0]&&(await o.connection.getSenders()[0].replaceTrack(s.stream.getTracks()[0]),this.muteReconfigure(o))})}processCallerMute(r,n){const o=this.extendedCalls[r];o&&o.connection.getReceivers().length&&(o.localMuted=n,o.connection.getReceivers().forEach(a=>{a.track.enabled=!n}),this.updateCall(o))}muteCaller(r){this.processCallerMute(r,!0)}unmuteCaller(r){this.processCallerMute(r,!1)}terminateCall(r){const n=this.extendedCalls[r];n._status!==8&&n.terminate()}messageTerminate(r){const n=this.extendedMessages[r];n._status!==8&&n.terminate()}transferCall(r,n){if(n.toString().length===0)return new Error("Target must be passed");const o=this.extendedCalls[r];if(!o._is_confirmed&&!o._is_canceled){const a=`sip:${n}@${this.sipDomain}`;o.terminate({status_code:302,reason_phrase:"Moved Temporarily",extraHeaders:[`Contact: ${a}`]});return}this.updateCallStatus({callId:r,isTransferring:!0}),o.refer(`sip:${n}@${this.sipDomain}`),this.updateCall(o)}mergeCall(r){const n=Object.values(this.extendedCalls).filter(t=>t.roomId===r);if(n.length!==2)return;const o=n[0],a=n[1];!o||!a||(this.updateCallStatus({callId:o._id,isMerging:!0}),this.updateCallStatus({callId:a._id,isMerging:!0}),o.refer(a.remote_identity.uri.toString(),{replaces:a}),this.updateCall(o))}setDND(r){this.isDNDEnabled=r,this.emit("changeIsDND",r)}startCallTimer(r){const n={callId:r,hours:0,minutes:0,seconds:0,formatted:""};this.setCallTime(n);const o=setInterval(()=>{const a={...this.callTime[r]},t=Mg(a);this.setCallTime({callId:r,...t})},1e3);this.setTimeInterval(r,o)}async setActiveRoom(r){const n=this.currentActiveRoomId;r!==n&&(this.currentActiveRoomId=r,await this.roomReconfigure(n),await this.roomReconfigure(r))}getNewRoomId(){const r=Object.keys(this.activeRooms);return r.length===0?1:parseInt(r.sort()[r.length-1])+1}subscribe(r,n){const a=!this.listenersList[r]||!this.listenersList[r].length?[n]:[...this.listenersList[r],n];this.listenersList={...this.listenersList,[r]:a}}removeIListener(r){const n={...this.listenersList};delete n[r],this.listenersList={...n}}async setupCall(r){var d,g;const n=r.session;if(this.getActiveCalls[n.id]!==void 0)return;const a=this.getNewRoomId(),t={started:new Date,incomingInProgress:!1,roomId:a};n.direction==="incoming"?(this.logger.log("New incoming call from",(g=(d=n._remote_identity)==null?void 0:d._uri)==null?void 0:g._user),t.incomingInProgress=!0,this.subscribe(Jt.CALL_CONFIRMED,v=>{n.id===v.id&&(this.updateRoom({incomingInProgress:!1,roomId:a}),this.startCallTimer(n.id))}),this.subscribe(Jt.CALL_FAILED,v=>{n.id===v.id&&(this.updateRoom({incomingInProgress:!1,roomId:a}),this.deleteRoomIfEmpty(a))})):n.direction==="outgoing"&&this.startCallTimer(n.id);const s=n,p=this.hasAutoAnswerHeaders(r),h=s.direction==="incoming"&&!this.hasActiveCalls&&(p||this.autoAnswer);s.roomId=a,s.localMuted=!1,s.autoAnswer=h,h?this.addCall(s,!1):this.addCall(s),this.addCallStatus(n.id),this.addRoom(t),h&&this.answerCall(s._id)}addMessageSession(r){if(!r._id||this.getActiveMessages[r._id]!==void 0)return;const o=r;this.addMMSRPSession(o)}triggerListener({listenerType:r,session:n,event:o}){const a=this.listenersList[r];!a||!a.length||a.forEach(t=>{t(n,o)})}triggerMSRPListener({listenerType:r,session:n,event:o}){const a=this.listenersList[r];!a||!a.length||a.forEach(t=>{t(n,o)})}removeCall(r){const n={...this.activeCalls};delete n[r],this.activeCalls={...n};const o={...this.extendedCalls};delete o[r],this.extendedCalls={...o},this.emit("changeActiveCalls",this.activeCalls)}removeMMSRPSession(r){const n={...this.activeMessages};delete n[r],this.activeMessages={...n};const o={...this.extendedMessages};delete o[r],this.extendedMessages={...o},this.emit("changeActiveMessages",this.activeMessages)}activeCallListRemove(r){const n=this.extendedCalls[r._id];this.stopVUMeter("origin"),n.connection.getSenders().forEach(a=>{a.track.stop()});const o=n.roomId;this.removeCall(r._id),this.roomReconfigure(o)}activeMessageListRemove(r){this.removeMMSRPSession(r._id)}async newRTCSessionCallback(r){const n=r.session;if(this.isDND){n.terminate({status_code:486,reason_phrase:"Do Not Disturb"});return}if(n.on("ended",o=>{var t,s;this.stopVUMeter(n.id),this.logger.log("Session ended for",(s=(t=n._remote_identity)==null?void 0:t._uri)==null?void 0:s._user),this.triggerListener({listenerType:Jt.CALL_ENDED,session:n,event:o});const a=this.getActiveCalls[n.id];a&&this.activeCallListRemove(a),this.stopCallTimer(n.id),this.removeCallStatus(n.id),this.removeCallMetrics(n.id),Object.keys(this.extendedCalls).length||(this.setIsMuted(!1),this.initialStreamValue.getTracks().forEach(p=>p.stop()),this.initialStreamValue=null)}),n.on("progress",o=>{var a,t;this.logger.log("Session in progress for",(t=(a=n._remote_identity)==null?void 0:a._uri)==null?void 0:t._user),this.triggerListener({listenerType:Jt.CALL_PROGRESS,session:n,event:o})}),n.on("failed",o=>{var t,s;this.stopVUMeter(n.id),this.logger.log("Session failed for",(s=(t=n._remote_identity)==null?void 0:t._uri)==null?void 0:s._user),this.triggerListener({listenerType:Jt.CALL_FAILED,session:n,event:o}),n.id===this.callAddingInProgress&&(this.callAddingInProgress=void 0);const a=this.getActiveCalls[n.id];a&&this.activeCallListRemove(a),this.stopCallTimer(n.id),this.removeCallStatus(n.id),this.removeCallMetrics(n.id),Object.keys(this.extendedCalls).length||(this.setIsMuted(!1),this.initialStreamValue.getTracks().forEach(p=>p.stop()),this.initialStreamValue=null)}),n.on("confirmed",o=>{var a,t;this.logger.log("Session confirmed for",(t=(a=n._remote_identity)==null?void 0:a._uri)==null?void 0:t._user),this.triggerListener({listenerType:Jt.CALL_CONFIRMED,session:n,event:o}),this.updateCall(n),n.id===this.callAddingInProgress&&(this.callAddingInProgress=void 0)}),await this.setupCall(r),n.direction==="outgoing"){const o=this.getActiveCalls[n.id].roomId;this.setActiveRoom(o)}}newMSRPSessionCallback(r){const n=r.session;n.on("ended",o=>{this.triggerMSRPListener({listenerType:Jt.CALL_ENDED,session:n,event:o});const a=this.getActiveMessages[n.id];this.activeMessageListRemove(a)}),n.on("failed",o=>{this.triggerMSRPListener({listenerType:Jt.CALL_FAILED,session:n,event:o});const a=this.getActiveMessages[n.id];this.activeMessageListRemove(a)}),n.on("confirmed",o=>{this.triggerMSRPListener({listenerType:Jt.CALL_CONFIRMED,session:n,event:o}),this.updateMSRPSession(n)}),n.on("newMessage",o=>{this.addMSRPMessage(o,n)}),this.addMessageSession(n)}setInitialized(r){this.initialized=r,this.emit("ready",r)}begin(){if(this.isConnected()){console.error("Connection is already established");return}return this.on(this.registeredEventName,()=>{this.logger.log("Successfully registered to",this.options.socketInterfaces[0]),this.setInitialized(!0)}),this.on(this.unregisteredEventName,()=>{this.logger.log("Unregistered from",this.options.socketInterfaces[0]),this.setInitialized(!1)}),this.on(this.newRTCSessionEventName,this.newRTCSessionCallback.bind(this)),this.on(this.connectedEventName,()=>{this.logger.log("Connected to",this.options.socketInterfaces[0]),this.isReconnecting=!1}),this.on(this.disconnectedEventName,()=>{this.isReconnecting||(this.logger.log("Disconnected from",this.options.socketInterfaces[0]),this.logger.log("Reconnecting to",this.options.socketInterfaces[0]),this.isReconnecting=!0,this.stop(),this.setInitialized(!1),setTimeout(this.start.bind(this),5e3))}),this.on(this.newMSRPSessionEventName,this.newMSRPSessionCallback.bind(this)),this.logger.log("Connecting to",this.options.socketInterfaces[0]),this.start(),this.initializeMediaDevices(),this}setMuteWhenJoin(r){this.muteWhenJoinEnabled=r,this.emit("changeMuteWhenJoin",r)}setMicrophoneSensitivity(r){if(r<0||r>2)throw new Error("Value should be in range from 0 to 2!");this.microphoneInputLevelValue=r,this.roomReconfigure(this.currentActiveRoomId)}setSpeakerVolume(r){this.speakerVolumeValue=r,Object.values(this.extendedCalls).forEach(n=>{n.audioTag&&(n.audioTag.volume=r,this.updateCall(n))})}setAutoAnswer(r){this.isAutoAnswer=r}setSelectedInputDevice(r){localStorage.setItem(no.SELECTED_INPUT_DEVICE,r),this.selectedMediaDevices.input=r,this.emit("changeActiveInputMediaDevice",r)}setSelectedOutputDevice(r){localStorage.setItem(no.SELECTED_OUTPUT_DEVICE,r),this.selectedMediaDevices.output=r,this.emit("changeActiveOutputMediaDevice",r)}setIsMSRPInitializing(r){this.isMSRPInitializingValue=r,this.emit("isMSRPInitializingChanged",r)}setCallMetrics(r){const n={...r};delete n.callId,this.callMetrics={...this.callMetrics,[r.callId]:n},this.emit("changeCallMetrics",this.callMetrics)}removeCallMetrics(r){const n={...this.callMetrics};delete n[r],this.callMetrics={...n},this.emit("changeCallMetrics",this.callMetrics)}getCallQuality(r){const n=new Dv(this.metricConfig),o=n.createProbe(r.connection,{cid:r._id}),a=[];let t;o.onreport=s=>{Object.entries(s.audio).forEach(([d,g])=>{g.direction==="inbound"&&!a.includes(d)&&(a.push(d),t=d)});const p=s.audio[t],h=xg(p,Gv);h.callId=r._id,this.setCallMetrics(n)},this.subscribe(Jt.CALL_ENDED,s=>{s._id===r._id&&n.stopAllProbes()}),n.startAllProbes()}setupVUMeter(r,n){this.VUMeter.start(r,n)}stopVUMeter(r){this.VUMeter.stop(r)}async setupStream(){const r=await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints);this.initialStreamValue&&(this.initialStreamValue.getTracks().forEach(n=>n.stop()),this.initialStreamValue=null),this.initialStreamValue=r}async triggerAddStream(r,n){this.setIsMuted(this.muteWhenJoin||this.isMuted),this.initialStreamValue||await this.setupStream();const o=qf(this.initialStreamValue,this.microphoneInputLevel*2),a=this.isMuted||this.muteWhenJoin;o.getTracks().forEach(t=>t.enabled=!a),this.setActiveStream(o),await n.connection.getSenders()[0].replaceTrack(o.getTracks()[0]),Hg(r,n,this.selectedOutputDevice,this.speakerVolume),this.setupVUMeter(r.stream,n._id),this.getCallQuality(n),this.updateCall(n)}initCall(r,n){if(this.checkInitialized(),r.length===0)return console.error("Target must be a valid string");this.logger.log(`Calling sip:${r}@${this.sipDomain}...`);const o=this.call(`sip:${r}@${this.sipDomain}`,this.sipOptions);this.callAddingInProgress=o.id,n&&this.currentActiveRoomId!==void 0&&this.processRoomChange({callId:o.id,roomId:this.currentActiveRoomId}),o.connection.addEventListener("addstream",a=>{this.triggerAddStream(a,o)})}initMSRP(r,n,o){if(this.checkInitialized(),r.length===0)return console.error("Target must be a valid string");const a=this.startMSRP(r,o);a.on("active",()=>{this.addMessageSession(a),a.sendMSRP(n),this.setIsMSRPInitializing(!1)}),this.setIsMSRPInitializing(!0)}sendMSRP(r,n){const o=this.extendedMessages[r];if(!o)throw new Error(`MSRP session with id ${r} doesn't exist!`);o.sendMSRP(n)}async processRoomChange({callId:r,roomId:n}){const o=this.extendedCalls[r].roomId;this.extendedCalls[r].roomId=n;const a=this.extendedCalls[r];return this.updateCall(a),await this.setActiveRoom(n),Promise.all([this.roomReconfigure(o),this.roomReconfigure(n)]).then(()=>{this.deleteRoomIfEmpty(o),this.deleteRoomIfEmpty(n)})}}return Wv});
|
155
|
+
`),this._newMSRPSession("local",this._request),this._id=this._request.call_id+this._from_tag,console.log("dialog be",this._dialog),new im(this._ua,this._request,{onRequestTimeout:()=>{this.onRequestTimeout(),console.log("to")},onTransportError:t=>{this.onTransportError(),console.log(t)},onAuthenticated:t=>{this._request=t},onReceiveResponse:t=>{this._receiveInviteResponse(t),console.log("dialog af",this._dialog),t.status_code===200&&(t.parseSDP(!0),this._status=ye.STATUS_CONFIRMED,this.target_addr=t.sdp.media[0].invalid[1].value.replaceAll("path:","").split(" ").reverse(),this.status="active",this.emit("active"),this.emit("confirmed"))}}).send(),this._status=ye.STATUS_INVITE_SENT}terminate(r={}){console.log("terminate",this);const n=r.cause||Ie.causes.BYE,o=Cs.cloneArray(r.extraHeaders),a=r.body;let t,s=r.status_code,p=r.reason_phrase;if(this._status===ye.STATUS_TERMINATED)throw new hm.InvalidStateError(this._status);switch(this.status="terminated",this._status){case ye.STATUS_NULL:case ye.STATUS_INVITE_SENT:case ye.STATUS_1XX_RECEIVED:if(s&&(s<200||s>=700))throw new TypeError(`Invalid status_code: ${s}`);s&&(p=p||Ie.REASON_PHRASE[s]||"",t=`SIP ;cause=${s} ;text="${p}"`),this._status===ye.STATUS_NULL||this._status===ye.STATUS_INVITE_SENT?(this._is_canceled=!0,this._cancel_reason=t):this._status===ye.STATUS_1XX_RECEIVED&&this._request.cancel(t),this._status=ye.STATUS_CANCELED,console.log("failed 1"),this._failed("local",null,Ie.causes.CANCELED);break;case ye.STATUS_WAITING_FOR_ANSWER:case ye.STATUS_ANSWERED:if(s=s||480,console.log("REPLY 480"),s<300||s>=700)throw new TypeError(`Invalid status_code: ${s}`);this._request.reply(s,p,o,a),console.log("failed 2"),this._failed("local",null,Ie.causes.REJECTED);break;case ye.STATUS_WAITING_FOR_ACK:case ye.STATUS_CONFIRMED:if(p=r.reason_phrase||Ie.REASON_PHRASE[s]||"",s&&(s<200||s>=700))throw new TypeError(`Invalid status_code: ${s}`);if(s&&o.push(`Reason: SIP ;cause=${s}; text="${p}"`),this._status===ye.STATUS_WAITING_FOR_ACK&&this._direction==="incoming"&&this._request.server_transaction.state!==Ur.C.STATUS_TERMINATED){const h=this._dialog;this.receiveRequest=({method:d})=>{d===Ie.ACK&&(this.sendRequest(Ie.BYE,{extraHeaders:o,body:a}),h.terminate())},this._request.server_transaction.on("stateChanged",()=>{this._request.server_transaction.state===Ur.C.STATUS_TERMINATED&&(this.sendRequest(Ie.BYE,{extraHeaders:o,body:a}),h.terminate())}),this._ended("local",null,n),this._dialog=h,this._ua.newDialog(h)}else console.log("here it is"),this.sendRequest(Ie.BYE,{extraHeaders:o,body:a}),this._ended("local",null,n)}}sendRequest(r,n){return this._dialog.sendRequest(r,n)}authenticate(r){this.status="auth";let n=new bn("");n.method="AUTH",n.addHeader("To-Path",`msrp://${this._ua._configuration.realm}:2856;ws`),n.addHeader("From-Path",`msrp://${this.credentials.username}.${this.credentials.realm}:2856/${this.auth_id};ws`),r&&n.addHeader("Authorization",r.toString());let o=n.toString();console.log(o);let a=[];for(var t=0;t<o.length;t++)a.push(o.charCodeAt(t).toString(16));console.log(a),this._connection.send(n.toString())}onmessage(r){console.log("onmessage",r);const n=new bn(r.data);if(this.status==="auth"&&n.code===401){const o=this.parseAuth(n.getHeader("WWW-Authenticate")),a=new Wp(this.credentials);a.authenticate({method:"AUTH",ruri:`msrp://${this._ua._configuration.realm}:2856;ws`,body:null},o,Cs.createRandomToken(12)),this.authenticate(a)}this.status==="auth"&&n.code===200&&this._direction==="outgoing"?(this.my_addr.push(n.getHeader("To-Path")),this.my_addr.push(n.getHeader("Use-Path")),this.status="active",this.inviteParty(n)):this.status==="auth"&&n.code===200&&this._direction==="incoming"?(this.my_addr.push(n.getHeader("To-Path")),this.my_addr.push(n.getHeader("Use-Path")),this.status="active",this.acceptParty(n),this.emit("confirmed")):n.method==="SEND"&&(this._sendOk(n),this._sendReport(n),n.direction="incoming",this.emit("newMessage",n),this._msgHistory.push(n),this.emit("msgHistoryUpdate",this._msgHistory),console.log("======================================================================")),n.code===480&&this._close()}onclose(){console.log("close")}onopen(){const r=new RTCPeerConnection({iceServers:[]});r.createDataChannel(""),r.createOffer().then(r.setLocalDescription.bind(r)),r.onicecandidate=n=>{if(!n||!n.candidate||!n.candidate.candidate)return;const o=/([0-9]{1,3}(\.[0-9]{1,3}){3})/,a=n.candidate.candidate.match(o);this.my_ip=a&&a[1],r.onicecandidate=()=>{},this.authenticate(null)}}onerror(r){console.log(r)}_receiveInviteResponse(r){if(console.log("resp0000000000000",r),this._dialog&&r.status_code>=200&&r.status_code<=299)if(console.log("200000000000000"),this._dialog.id.call_id===r.call_id&&this._dialog.id.local_tag===r.from_tag&&this._dialog.id.remote_tag===r.to_tag){this.sendRequest(Ie.ACK);return}else{const n=new Kl(this,r,"UAC");if(n.error!==void 0){console.log(n.error);return}this.sendRequest(Ie.ACK),this.sendRequest(Ie.BYE);return}if(this._is_canceled){r.status_code>=100&&r.status_code<200?this._request.cancel(this._cancel_reason):r.status_code>=200&&r.status_code<299&&this._acceptAndTerminate(r);return}if(!(this._status!==ye.STATUS_INVITE_SENT&&this._status!==ye.STATUS_1XX_RECEIVED))switch(console.log("start Switch"),!0){case/^100$/.test(r.status_code):this._status=ye.STATUS_1XX_RECEIVED;break;case/^1[0-9]{2}$/.test(r.status_code):{if(!r.to_tag){console.log("1xx response received without to tag");break}if(r.hasHeader("contact")&&!this._createDialog(r,"UAC",!0))break;if(this._status=ye.STATUS_1XX_RECEIVED,!r.body){this._progress("remote",r);break}const n={originator:"remote",type:"answer",sdp:r.body};console.log('emit "sdp"'),this.emit("sdp",n);const o=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(o)).then(()=>this._progress("remote",r)).catch(a=>{console.log('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)});break}case/^2[0-9]{2}$/.test(r.status_code):{if(console.log("maybe here???"),this._status=ye.STATUS_CONFIRMED,!r.body){this._acceptAndTerminate(r,400,Ie.causes.MISSING_SDP),console.log("failed 3"),this._failed("remote",r,Ie.causes.BAD_MEDIA_DESCRIPTION);break}if(!this._createDialog(r,"UAC"))break;const n={originator:"remote",type:"answer",sdp:r.body};console.log('emit "sdp"'),this.emit("sdp",n),new RTCSessionDescription({type:"answer",sdp:n.sdp}),this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>{if(this._connection.signalingState==="stable")return this._connection.createOffer(this._rtcOfferConstraints).then(o=>this._connection.setLocalDescription(o)).catch(o=>{this._acceptAndTerminate(r,500,o.toString()),console.log("failed 4"),this._failed("local",r,Ie.causes.WEBRTC_ERROR)})}).then(()=>{this._handleSessionTimersInIncomingResponse(r),this._accepted("remote",r),this.sendRequest(Ie.ACK),this._confirmed("local",null)});break}default:{const n=Cs.sipErrorCause(r.status_code);console.log("failed 5"),this._failed("remote",r,n)}}}sendMSRP(r){const n=new bn("");n.method="SEND",n.addHeader("To-Path",`${this.my_addr[1]} ${this.target_addr[1]} ${this.target_addr[0]}`),n.addHeader("From-Path",`${this.my_addr[0]}`),n.addHeader("Message-ID",Cs.createRandomToken(10)),n.addHeader("Byte-Range","1-25/25"),n.addHeader("Content-Type","text/plain"),n.addHeader("Success-Report","yes"),n.addHeader("Failure-Report","yes"),n.body=r;let o=n.toString();console.log(o);let a=[];for(var t=0;t<o.length;t++)a.push(o.charCodeAt(t).toString(16));console.log(a),this._connection.send(n.toString()),n.direction="outgoing",this.emit("newMessage",n),this._msgHistory.push(n),this.emit("msgHistoryUpdate",this._msgHistory)}_sendOk(r){let n=r.ident,o=r.getHeader("Message-ID"),a=new bn("");a.method="200 OK",a.addHeader("To-Path",`${this.my_addr[1]}`),a.addHeader("From-Path",`${this.my_addr[0]}`),a.addHeader("Message-ID",o),a.ident=n;let t=a.toString();console.log(t);let s=[];for(var p=0;p<t.length;p++)s.push(t.charCodeAt(p).toString(16));console.log(s),this._connection.send(a.toString())}_sendReport(r){let n=r.ident,o=r.getHeader("Message-ID"),a=new bn("");a.method="REPORT",a.addHeader("To-Path",`${r.getHeader("From-Path")}`),a.addHeader("From-Path",`${this.my_addr[0]}`),a.addHeader("Message-ID",o),a.addHeader("Byte-Range","1-25/25"),a.addHeader("Status","000 200 OK"),a.ident=n;let t=a.toString();console.log(t);let s=[];for(var p=0;p<t.length;p++)s.push(t.charCodeAt(p).toString(16));console.log(s),this._connection.send(a.toString())}parseAuth(r){const n={},o=r.replace("Digest","").split(",");for(const a of o){const t=a.trim().split("=");n[t[0]]=t[1].match('^"(.+)"$')[1]}return n}init_incoming(r,n){let o;const a=r.hasHeader("Content-Type")?r.getHeader("Content-Type").toLowerCase():void 0;if(r.body&&a!=="application/sdp"){r.reply(415);return}if(this._status=ye.STATUS_INVITE_RECEIVED,this._from_tag=r.from_tag,this._id=r.call_id+this._from_tag,this._request=r,this._contact=this._ua.contact.toString(),r.hasHeader("expires")&&(o=r.getHeader("expires")*1e3),r.to_tag=Cs.newTag(),!this._createDialog(r,"UAS",!0)){r.reply(500,"Missing Contact header field");return}r.body?this._late_sdp=!1:this._late_sdp=!0,this._status=ye.STATUS_WAITING_FOR_ANSWER,this._timers.userNoAnswerTimer=setTimeout(()=>{r.reply(408),console.log("failed 6"),this._failed("local",null,Ie.causes.NO_ANSWER)},this._ua.configuration.no_answer_timeout),o&&(this._timers.expiresTimer=setTimeout(()=>{this._status===ye.STATUS_WAITING_FOR_ANSWER&&(r.reply(487),console.log("failed 7"),this._failed("system",null,Ie.causes.EXPIRES))},o)),this._direction="incoming",this._local_identity=r.to,this._remote_identity=r.from,n&&n(this),r.parseSDP(!0),this.target_addr=r.sdp.media[0].invalid[1].value.replaceAll("path:","").split(" ").reverse(),this._newMSRPSession("remote",r),this._status!==ye.STATUS_TERMINATED&&(r.reply(180,null,[`Contact: ${this._ua._contact}`]),this._progress("local",null))}_failed(r,n,o){this.emit("_failed",{originator:r,message:n||null,cause:o}),this._close(),this.emit("failed",{originator:r,message:n||null,cause:o})}_close(){if(console.log("CLOSE SESSION"),this._status!==ye.STATUS_TERMINATED){if(this._status=ye.STATUS_TERMINATED,this._connection)try{this._connection.close()}catch(r){console.log("close() | error closing the RTCPeerConnection: %o",r)}for(const r in this._timers)Object.prototype.hasOwnProperty.call(this._timers,r)&&clearTimeout(this._timers[r]);clearTimeout(this._sessionTimers.timer),this._dialog&&(this._dialog.terminate(),delete this._dialog);for(const r in this._earlyDialogs)Object.prototype.hasOwnProperty.call(this._earlyDialogs,r)&&(this._earlyDialogs[r].terminate(),delete this._earlyDialogs[r]);for(const r in this._referSubscribers)Object.prototype.hasOwnProperty.call(this._referSubscribers,r)&&delete this._referSubscribers[r];this._ua.destroyMSRPSession(this)}}_createDialog(r,n,o){const a=n==="UAS"?r.to_tag:r.from_tag,t=n==="UAS"?r.from_tag:r.to_tag,s=r.call_id+a+t;let p=this._earlyDialogs[s];if(o)return p?!0:(p=new Kl(this,r,n,Kl.C.STATUS_EARLY),p.error?(console.log("failed 8"),this._failed("remote",r,Ie.causes.INTERNAL_ERROR),!1):(this._earlyDialogs[s]=p,!0));{if(this._from_tag=r.from_tag,this._to_tag=r.to_tag,p)return p.update(r,n),this._dialog=p,delete this._earlyDialogs[s],!0;const h=new Kl(this,r,n);return h.error?(console.log("failed 9"),this._failed("remote",r,Ie.causes.INTERNAL_ERROR),!1):(this._dialog=h,!0)}}_newMSRPSession(r,n){this._ua.newMSRPSession(this,{originator:r,session:this,request:n})}_progress(r,n){this.emit("progress",{originator:r,response:n||null})}isEnded(){switch(this._status){case ye.STATUS_CANCELED:case ye.STATUS_TERMINATED:return!0;default:return!1}}_accepted(r,n){console.log("session accepted"),this._start_time=new Date,console.log('emit "accepted"'),this.emit("accepted",{originator:r,response:n||null})}_confirmed(r,n){console.log("session confirmed"),this._is_confirmed=!0,console.log('emit "confirmed"'),this.emit("confirmed",{originator:r,ack:n||null})}_ended(r,n,o){console.log("session ended"),this._end_time=new Date,this._close(),console.log('emit "ended"'),this.emit("ended",{originator:r,message:n||null,cause:o})}_handleSessionTimersInIncomingResponse(r){if(!this._sessionTimers.enabled)return;let n;r.session_expires&&r.session_expires>=Ie.MIN_SESSION_EXPIRES?(this._sessionTimers.currentExpires=r.session_expires,n=r.session_expires_refresher||"uac"):(this._sessionTimers.currentExpires=this._sessionTimers.defaultExpires,n="uac"),this._sessionTimers.refresher=n==="uac",this._runSessionTimer()}receiveRequest(r){if(console.log("receiveRequest()"),r.method===Ie.CANCEL)(this._status===ye.STATUS_WAITING_FOR_ANSWER||this._status===ye.STATUS_ANSWERED)&&(this._status=ye.STATUS_CANCELED,this._request.reply(487),console.log("failed 10"),this._failed("remote",r,Ie.causes.CANCELED));else switch(r.method){case Ie.ACK:if(this._status!==ye.STATUS_WAITING_FOR_ACK)return;if(this._status=ye.STATUS_CONFIRMED,clearTimeout(this._timers.ackTimer),clearTimeout(this._timers.invite2xxTimer),this._late_sdp){if(!r.body){this.terminate({cause:Ie.causes.MISSING_SDP,status_code:400});break}const n={originator:"remote",type:"answer",sdp:r.body};console.log('emit "sdp"'),this.emit("sdp",n);const o=new RTCSessionDescription({type:"answer",sdp:n.sdp});this._connectionPromiseQueue=this._connectionPromiseQueue.then(()=>this._connection.setRemoteDescription(o)).then(()=>{this._is_confirmed||this._confirmed("remote",r)}).catch(a=>{this.terminate({cause:Ie.causes.BAD_MEDIA_DESCRIPTION,status_code:488}),console.log('emit "peerconnection:setremotedescriptionfailed" [error:%o]',a),this.emit("peerconnection:setremotedescriptionfailed",a)})}else this._is_confirmed||this._confirmed("remote",r);break;case Ie.BYE:this._status===ye.STATUS_CONFIRMED||this._status===ye.STATUS_WAITING_FOR_ACK?(r.reply(200),this._ended("remote",r,Ie.causes.BYE)):this._status===ye.STATUS_INVITE_RECEIVED||this._status===ye.STATUS_WAITING_FOR_ANSWER?(r.reply(200),this._request.reply(487,"BYE Received"),this._ended("remote",r,Ie.causes.BYE)):r.reply(403,"Wrong Status");break;case Ie.INVITE:this._status===ye.STATUS_CONFIRMED?r.hasHeader("replaces")?this._receiveReplaces(r):this._receiveReinvite(r):r.reply(403,"Wrong Status");break;case Ie.INFO:this._status===ye.STATUS_1XX_RECEIVED||this._status===ye.STATUS_WAITING_FOR_ANSWER||this._status===ye.STATUS_ANSWERED||this._status===ye.STATUS_WAITING_FOR_ACK||this._status===ye.STATUS_CONFIRMED?(r.hasHeader("Content-Type")?r.getHeader("Content-Type").toLowerCase():void 0)!==void 0?new bm(this).init_incoming(r):r.reply(415):r.reply(403,"Wrong Status");break;case Ie.UPDATE:this._status===ye.STATUS_CONFIRMED?this._receiveUpdate(r):r.reply(403,"Wrong Status");break;case Ie.REFER:this._status===ye.STATUS_CONFIRMED?this._receiveRefer(r):r.reply(403,"Wrong Status");break;case Ie.NOTIFY:this._status===ye.STATUS_CONFIRMED?this._receiveNotify(r):r.reply(403,"Wrong Status");break;default:r.reply(501)}}onTransportError(){console.log("onTransportError()"),this._status!==ye.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:Ie.causes.CONNECTION_ERROR,cause:Ie.causes.CONNECTION_ERROR})}onRequestTimeout(){console.log("onRequestTimeout()"),this._status!==ye.STATUS_TERMINATED&&this.terminate({status_code:408,reason_phrase:Ie.causes.REQUEST_TIMEOUT,cause:Ie.causes.REQUEST_TIMEOUT})}onDialogError(){console.log("onDialogError()"),this._status!==ye.STATUS_TERMINATED&&this.terminate({status_code:500,reason_phrase:Ie.causes.DIALOG_ERROR,cause:Ie.causes.DIALOG_ERROR})}}const zt=console,xf={STATUS_INIT:0,STATUS_READY:1,STATUS_USER_CLOSED:2,STATUS_NOT_READY:3,CONFIGURATION_ERROR:1,NETWORK_ERROR:2},Pg=Ng;class kg extends Pg{constructor(r){console.log(r),super(r),this._msrp_sessions=[],this._transactions={nist:{},nict:{},ist:{},ict:{}}}call(r,n){return super.call(r,n)}newMSRPSession(r,n){r.on("msgHistoryUpdate",o=>{console.log(o)}),this._msrp_sessions[r.id]=r,this.emit("newMSRPSession",n)}destroyMSRPSession(r){delete this._msrp_sessions[r.id]}receiveRequest(r){const n=r.method;if(console.log("-----------"),r.ruri.user!==this._configuration.uri.user&&r.ruri.user!==this._contact.uri.user){zt.debug("Request-URI does not point to us"),r.method!==we.ACK&&r.reply_sl(404);return}if(r.ruri.scheme===we.SIPS){r.reply_sl(416);return}if(Ur.checkTransaction(this,r))return;if(n===we.INVITE?new Ur.InviteServerTransaction(this,this._transport,r):n!==we.ACK&&n!==we.CANCEL&&new Ur.NonInviteServerTransaction(this,this._transport,r),n===we.OPTIONS){if(this.listeners("newOptions").length===0){r.reply(200);return}new Kc.Options(this).init_incoming(r)}else if(n===we.MESSAGE){if(this.listeners("newMessage").length===0){r.reply(405);return}new Kc.Message(this).init_incoming(r)}else if(n===we.INVITE&&!r.to_tag&&this.listeners("newRTCSession").length===0){r.reply(405);return}let o,a;if(r.to_tag)o=this._findDialog(r.call_id,r.from_tag,r.to_tag),o?o.receiveRequest(r):n===we.NOTIFY?(a=this._findSession(r),a?a.receiveRequest(r):(zt.debug("received NOTIFY request for a non existent subscription"),r.reply(481,"Subscription does not exist"))):n!==we.ACK&&r.reply(481);else switch(n){case we.INVITE:if(window.RTCPeerConnection)if(r.hasHeader("replaces")){const t=r.replaces;o=this._findDialog(t.call_id,t.from_tag,t.to_tag),o?(a=o.owner,a.isEnded()?r.reply(603):a.receiveRequest(r)):r.reply(481)}else r.body.search(/MSRP/ig)>-1?(a=new Mf(this),a.init_incoming(r)):(a=new qm(this),a.init_incoming(r));else zt.warn("INVITE received but WebRTC is not supported"),r.reply(488);break;case we.BYE:r.reply(481);break;case we.CANCEL:a=this._findSession(r),a?a.receiveRequest(r):zt.debug("received CANCEL request for a non existent session");break;case we.ACK:break;case we.NOTIFY:this.emit("sipEvent",{event:r.event,request:r}),r.reply(200);break;default:r.reply(405);break}}startMSRP(r,n){zt.debug("startMSRP()",n);const o=new Mf(this);return o.connect(r),o}terminateMSRPSessions(r){zt.debug("terminateSessions()");for(const n in this._msrp_sessions)this._msrp_sessions[n].isEnded()||this._msrp_sessions[n].terminate(r)}stop(){if(zt.debug("stop()"),this._dynConfiguration={},this._status===xf.STATUS_USER_CLOSED){zt.debug("UA already closed");return}this._registrator.close();const r=Object.keys(this._sessions).length;for(const o in this._sessions)if(Object.prototype.hasOwnProperty.call(this._sessions,o)){zt.debug(`closing session ${o}`);try{this._sessions[o].terminate()}catch(a){console.error(a)}}for(const o in this._msrp_sessions)if(Object.prototype.hasOwnProperty.call(this._msrp_sessions,o)){zt.debug(`closing session ${o}`);try{this._msrp_sessions[o].terminate()}catch(a){console.error(a)}}for(const o in this._applicants)if(Object.prototype.hasOwnProperty.call(this._applicants,o))try{this._applicants[o].close()}catch(a){console.error(a)}this._status=xf.STATUS_USER_CLOSED,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&&r===0?this._transport.disconnect():this._closeTimer=setTimeout(()=>{this._closeTimer=null,this._transport.disconnect()},2e3)}}var pt={};pt.forEach=async(c,r,n)=>{const o=[];for(let a=0;a<c.length;a++)if(a in c){const t=Promise.resolve(c[a]).then(s=>r.call(n||globalThis,s,a,c));o.push(t)}await Promise.all(o)},pt.forEachSeries=async(c,r,n)=>{for(let o=0;o<c.length;o++)o in c&&await r.call(n||globalThis,await c[o],o,c)},pt.map=async(c,r,n)=>{const o=[];for(let a=0;a<c.length;a++)a in c&&(o[a]=Promise.resolve(c[a]).then(t=>r.call(n||globalThis,t,a,c)));return Promise.all(o)},pt.mapSeries=async(c,r,n)=>{const o=[];for(let a=0;a<c.length;a++)a in c&&(o[a]=await r.call(n||globalThis,await c[a],a,c));return o},pt.find=(c,r,n)=>new Promise((o,a)=>{if(c.length===0)return o();let t=1;for(let s=0;s<c.length;s++){const p=h=>{h?o(c[s]):t===c.length&&o(),t++};Promise.resolve(c[s]).then(h=>r.call(n||globalThis,h,s,c)).then(p).catch(a)}}),pt.findSeries=async(c,r,n)=>{for(let o=0;o<c.length;o++)if(await r.call(n||globalThis,await c[o],o,c))return c[o]},pt.findIndex=(c,r,n)=>new Promise((o,a)=>{if(c.length===0)return o(-1);let t=1;for(let s=0;s<c.length;s++){const p=h=>{h?o(s):t===c.length&&o(-1),t++};Promise.resolve(c[s]).then(h=>r.call(n||globalThis,h,s,c)).then(p).catch(a)}}),pt.findIndexSeries=async(c,r,n)=>{for(let o=0;o<c.length;o++)if(await r.call(n||globalThis,await c[o],o,c))return o},pt.some=(c,r,n)=>new Promise((o,a)=>{if(c.length===0)return o(!1);let t=1;for(let s=0;s<c.length;s++){if(!(s in c)){t++;continue}const p=h=>{h?o(!0):t===c.length&&o(!1),t++};Promise.resolve(c[s]).then(h=>r.call(n||globalThis,h,s,c)).then(p).catch(a)}}),pt.someSeries=async(c,r,n)=>{for(let o=0;o<c.length;o++)if(o in c&&await r.call(n||globalThis,await c[o],o,c))return!0;return!1},pt.every=(c,r,n)=>new Promise((o,a)=>{if(c.length===0)return o(!0);let t=1;for(let s=0;s<c.length;s++){if(!(s in c)){t++;continue}const p=h=>{h?t===c.length&&o(!0):o(!1),t++};Promise.resolve(c[s]).then(h=>r.call(n||globalThis,h,s,c)).then(p).catch(a)}}),pt.everySeries=async(c,r,n)=>{for(let o=0;o<c.length;o++)if(o in c&&!await r.call(n||globalThis,await c[o],o,c))return!1;return!0},pt.filter=(c,r,n)=>new Promise(async(o,a)=>{const t=[];for(let p=0;p<c.length;p++)p in c&&(t[p]=Promise.resolve(c[p]).then(h=>r.call(n||globalThis,h,p,c)).catch(a));const s=[];for(let p=0;p<t.length;p++)await t[p]&&s.push(await c[p]);o(s)}),pt.filterSeries=async(c,r,n)=>{const o=[];for(let a=0;a<c.length;a++)a in c&&await r.call(n||globalThis,await c[a],a,c)&&o.push(await c[a]);return o},pt.reduce=async(c,r,n)=>{if(c.length===0&&n===void 0)throw TypeError("Reduce of empty array with no initial value");let o,a;for(n!==void 0?(a=n,o=0):(a=c[0],o=1),o;o<c.length;o++)o in c&&(a=await r(await a,await c[o],o,c));return a};var Lf={};(function(c){const r=pt;Object.keys(r).forEach(n=>{const o=n.charAt(0).toUpperCase()+n.slice(1);c[`async${o}`]=async function(...a){return r[n](this,...a)}})})(Lf);var $f=Object.assign(pt,{instanceMethods:Lf});function za(c){return c<10?`0${c}`:`${c}`}function Mg(c){let r=c.hours||0,n=c.minutes||0,o=c.seconds||0;o++,o===60&&(o=0,n++,n===60&&(n=0,r++));const a=`${za(r)}:${za(n)}:${za(o)}`;return{seconds:o,minutes:n,hours:r,formatted:a}}function xg(c,r){return Object.keys(c).filter(n=>r.includes(n)).reduce((n,o)=>{const a=o;return{...n,[a]:c[a]}},{})}const Jt=new AudioContext,Lg=["roomId","_audioMuted","_cancel_reason","_contact","direction","_end_time","_eventsCount","_from_tag","_id","_is_canceled","_is_confirmed","_late_sdp","_localHold","_videoMuted","status","start_time","_remote_identity","audioTag","isOnHold","localMuted","autoAnswer"],$g=["_cancel_reason","_contact","direction","_end_time","_eventsCount","_from_tag","_id","_is_canceled","_is_confirmed","_late_sdp","status","start_time","_remote_identity","target_addr"];function Hf(c){const r={};return Lg.forEach(n=>{c[n]!==void 0&&(r[n]=c[n])}),r.localHold=c._localHold,r}function Ff(c){const r={};return $g.forEach(n=>{c[n]!==void 0&&(r[n]=c[n])}),r}function qf(c,r){const n=Jt.createMediaStreamSource(c),o=Jt.createMediaStreamDestination(),a=Jt.createGain();return n.connect(a),a.connect(o),a.gain.value=r,o.stream}function Hg(c,r,n,o){const a=document.createElement("audio");a.id=r._id,a.className="audioTag",a.srcObject=c.stream,a.setSinkId(n),a.volume=o,a.play(),r.audioTag=a}function Fg(c){if(c&&typeof c.log=="function"&&typeof c.warn=="function"&&typeof c.error=="function")return!0}var qg={exports:{}};(function(c){var r=function(n){var o=Object.prototype,a=o.hasOwnProperty,t=Object.defineProperty||function(Q,W,B){Q[W]=B.value},s,p=typeof Symbol=="function"?Symbol:{},h=p.iterator||"@@iterator",d=p.asyncIterator||"@@asyncIterator",g=p.toStringTag||"@@toStringTag";function v(Q,W,B){return Object.defineProperty(Q,W,{value:B,enumerable:!0,configurable:!0,writable:!0}),Q[W]}try{v({},"")}catch{v=function(W,B,te){return W[B]=te}}function E(Q,W,B,te){var de=W&&W.prototype instanceof ie?W:ie,Ae=Object.create(de.prototype),Ue=new P(te||[]);return t(Ae,"_invoke",{value:Y(Q,B,Ue)}),Ae}n.wrap=E;function S(Q,W,B){try{return{type:"normal",arg:Q.call(W,B)}}catch(te){return{type:"throw",arg:te}}}var C="suspendedStart",I="suspendedYield",w="executing",F="completed",L={};function ie(){}function N(){}function H(){}var ve={};v(ve,h,function(){return this});var me=Object.getPrototypeOf,M=me&&me(me(Z([])));M&&M!==o&&a.call(M,h)&&(ve=M);var D=H.prototype=ie.prototype=Object.create(ve);N.prototype=H,t(D,"constructor",{value:H,configurable:!0}),t(H,"constructor",{value:N,configurable:!0}),N.displayName=v(H,g,"GeneratorFunction");function j(Q){["next","throw","return"].forEach(function(W){v(Q,W,function(B){return this._invoke(W,B)})})}n.isGeneratorFunction=function(Q){var W=typeof Q=="function"&&Q.constructor;return W?W===N||(W.displayName||W.name)==="GeneratorFunction":!1},n.mark=function(Q){return Object.setPrototypeOf?Object.setPrototypeOf(Q,H):(Q.__proto__=H,v(Q,g,"GeneratorFunction")),Q.prototype=Object.create(D),Q},n.awrap=function(Q){return{__await:Q}};function V(Q,W){function B(Ae,Ue,Se,ne){var Te=S(Q[Ae],Q,Ue);if(Te.type==="throw")ne(Te.arg);else{var tt=Te.arg,st=tt.value;return st&&typeof st=="object"&&a.call(st,"__await")?W.resolve(st.__await).then(function(ge){B("next",ge,Se,ne)},function(ge){B("throw",ge,Se,ne)}):W.resolve(st).then(function(ge){tt.value=ge,Se(tt)},function(ge){return B("throw",ge,Se,ne)})}}var te;function de(Ae,Ue){function Se(){return new W(function(ne,Te){B(Ae,Ue,ne,Te)})}return te=te?te.then(Se,Se):Se()}t(this,"_invoke",{value:de})}j(V.prototype),v(V.prototype,d,function(){return this}),n.AsyncIterator=V,n.async=function(Q,W,B,te,de){de===void 0&&(de=Promise);var Ae=new V(E(Q,W,B,te),de);return n.isGeneratorFunction(W)?Ae:Ae.next().then(function(Ue){return Ue.done?Ue.value:Ae.next()})};function Y(Q,W,B){var te=C;return function(Ae,Ue){if(te===w)throw new Error("Generator is already running");if(te===F){if(Ae==="throw")throw Ue;return et()}for(B.method=Ae,B.arg=Ue;;){var Se=B.delegate;if(Se){var ne=$(Se,B);if(ne){if(ne===L)continue;return ne}}if(B.method==="next")B.sent=B._sent=B.arg;else if(B.method==="throw"){if(te===C)throw te=F,B.arg;B.dispatchException(B.arg)}else B.method==="return"&&B.abrupt("return",B.arg);te=w;var Te=S(Q,W,B);if(Te.type==="normal"){if(te=B.done?F:I,Te.arg===L)continue;return{value:Te.arg,done:B.done}}else Te.type==="throw"&&(te=F,B.method="throw",B.arg=Te.arg)}}}function $(Q,W){var B=W.method,te=Q.iterator[B];if(te===s)return W.delegate=null,B==="throw"&&Q.iterator.return&&(W.method="return",W.arg=s,$(Q,W),W.method==="throw")||B!=="return"&&(W.method="throw",W.arg=new TypeError("The iterator does not provide a '"+B+"' method")),L;var de=S(te,Q.iterator,W.arg);if(de.type==="throw")return W.method="throw",W.arg=de.arg,W.delegate=null,L;var Ae=de.arg;if(!Ae)return W.method="throw",W.arg=new TypeError("iterator result is not an object"),W.delegate=null,L;if(Ae.done)W[Q.resultName]=Ae.value,W.next=Q.nextLoc,W.method!=="return"&&(W.method="next",W.arg=s);else return Ae;return W.delegate=null,L}j(D),v(D,g,"Generator"),v(D,h,function(){return this}),v(D,"toString",function(){return"[object Generator]"});function X(Q){var W={tryLoc:Q[0]};1 in Q&&(W.catchLoc=Q[1]),2 in Q&&(W.finallyLoc=Q[2],W.afterLoc=Q[3]),this.tryEntries.push(W)}function U(Q){var W=Q.completion||{};W.type="normal",delete W.arg,Q.completion=W}function P(Q){this.tryEntries=[{tryLoc:"root"}],Q.forEach(X,this),this.reset(!0)}n.keys=function(Q){var W=Object(Q),B=[];for(var te in W)B.push(te);return B.reverse(),function de(){for(;B.length;){var Ae=B.pop();if(Ae in W)return de.value=Ae,de.done=!1,de}return de.done=!0,de}};function Z(Q){if(Q){var W=Q[h];if(W)return W.call(Q);if(typeof Q.next=="function")return Q;if(!isNaN(Q.length)){var B=-1,te=function de(){for(;++B<Q.length;)if(a.call(Q,B))return de.value=Q[B],de.done=!1,de;return de.value=s,de.done=!0,de};return te.next=te}}return{next:et}}n.values=Z;function et(){return{value:s,done:!0}}return P.prototype={constructor:P,reset:function(Q){if(this.prev=0,this.next=0,this.sent=this._sent=s,this.done=!1,this.delegate=null,this.method="next",this.arg=s,this.tryEntries.forEach(U),!Q)for(var W in this)W.charAt(0)==="t"&&a.call(this,W)&&!isNaN(+W.slice(1))&&(this[W]=s)},stop:function(){this.done=!0;var Q=this.tryEntries[0],W=Q.completion;if(W.type==="throw")throw W.arg;return this.rval},dispatchException:function(Q){if(this.done)throw Q;var W=this;function B(ne,Te){return Ae.type="throw",Ae.arg=Q,W.next=ne,Te&&(W.method="next",W.arg=s),!!Te}for(var te=this.tryEntries.length-1;te>=0;--te){var de=this.tryEntries[te],Ae=de.completion;if(de.tryLoc==="root")return B("end");if(de.tryLoc<=this.prev){var Ue=a.call(de,"catchLoc"),Se=a.call(de,"finallyLoc");if(Ue&&Se){if(this.prev<de.catchLoc)return B(de.catchLoc,!0);if(this.prev<de.finallyLoc)return B(de.finallyLoc)}else if(Ue){if(this.prev<de.catchLoc)return B(de.catchLoc,!0)}else if(Se){if(this.prev<de.finallyLoc)return B(de.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(Q,W){for(var B=this.tryEntries.length-1;B>=0;--B){var te=this.tryEntries[B];if(te.tryLoc<=this.prev&&a.call(te,"finallyLoc")&&this.prev<te.finallyLoc){var de=te;break}}de&&(Q==="break"||Q==="continue")&&de.tryLoc<=W&&W<=de.finallyLoc&&(de=null);var Ae=de?de.completion:{};return Ae.type=Q,Ae.arg=W,de?(this.method="next",this.next=de.finallyLoc,L):this.complete(Ae)},complete:function(Q,W){if(Q.type==="throw")throw Q.arg;return Q.type==="break"||Q.type==="continue"?this.next=Q.arg:Q.type==="return"?(this.rval=this.arg=Q.arg,this.method="return",this.next="end"):Q.type==="normal"&&W&&(this.next=W),L},finish:function(Q){for(var W=this.tryEntries.length-1;W>=0;--W){var B=this.tryEntries[W];if(B.finallyLoc===Q)return this.complete(B.completion,B.afterLoc),U(B),L}},catch:function(Q){for(var W=this.tryEntries.length-1;W>=0;--W){var B=this.tryEntries[W];if(B.tryLoc===Q){var te=B.completion;if(te.type==="throw"){var de=te.arg;U(B)}return de}}throw new Error("illegal catch attempt")},delegateYield:function(Q,W,B){return this.delegate={iterator:Z(Q),resultName:W,nextLoc:B},this.method==="next"&&(this.arg=s),L}},n}(c.exports);try{regeneratorRuntime=r}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}})(qg);var Vf={exports:{}};(function(c){(function(r,n){c.exports?c.exports=n():r.log=n()})(or,function(){var r=function(){},n="undefined",o=typeof window!==n&&typeof window.navigator!==n&&/Trident\/|MSIE /.test(window.navigator.userAgent),a=["trace","debug","info","warn","error"];function t(I,w){var F=I[w];if(typeof F.bind=="function")return F.bind(I);try{return Function.prototype.bind.call(F,I)}catch{return function(){return Function.prototype.apply.apply(F,[I,arguments])}}}function s(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function p(I){return I==="debug"&&(I="log"),typeof console===n?!1:I==="trace"&&o?s:console[I]!==void 0?t(console,I):console.log!==void 0?t(console,"log"):r}function h(I,w){for(var F=0;F<a.length;F++){var L=a[F];this[L]=F<I?r:this.methodFactory(L,I,w)}this.log=this.debug}function d(I,w,F){return function(){typeof console!==n&&(h.call(this,w,F),this[I].apply(this,arguments))}}function g(I,w,F){return p(I)||d.apply(this,arguments)}function v(I,w,F){var L=this,ie;w=w??"WARN";var N="loglevel";typeof I=="string"?N+=":"+I:typeof I=="symbol"&&(N=void 0);function H(D){var j=(a[D]||"silent").toUpperCase();if(!(typeof window===n||!N)){try{window.localStorage[N]=j;return}catch{}try{window.document.cookie=encodeURIComponent(N)+"="+j+";"}catch{}}}function ve(){var D;if(!(typeof window===n||!N)){try{D=window.localStorage[N]}catch{}if(typeof D===n)try{var j=window.document.cookie,V=j.indexOf(encodeURIComponent(N)+"=");V!==-1&&(D=/^([^;]+)/.exec(j.slice(V))[1])}catch{}return L.levels[D]===void 0&&(D=void 0),D}}function me(){if(!(typeof window===n||!N)){try{window.localStorage.removeItem(N);return}catch{}try{window.document.cookie=encodeURIComponent(N)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}L.name=I,L.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},L.methodFactory=F||g,L.getLevel=function(){return ie},L.setLevel=function(D,j){if(typeof D=="string"&&L.levels[D.toUpperCase()]!==void 0&&(D=L.levels[D.toUpperCase()]),typeof D=="number"&&D>=0&&D<=L.levels.SILENT){if(ie=D,j!==!1&&H(D),h.call(L,D,I),typeof console===n&&D<L.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+D},L.setDefaultLevel=function(D){w=D,ve()||L.setLevel(D,!1)},L.resetLevel=function(){L.setLevel(w,!1),me()},L.enableAll=function(D){L.setLevel(L.levels.TRACE,D)},L.disableAll=function(D){L.setLevel(L.levels.SILENT,D)};var M=ve();M==null&&(M=w),L.setLevel(M,!1)}var E=new v,S={};E.getLogger=function(w){if(typeof w!="symbol"&&typeof w!="string"||w==="")throw new TypeError("You must supply a name when creating a logger.");var F=S[w];return F||(F=S[w]=new v(w,E.getLevel(),E.methodFactory)),F};var C=typeof window!==n?window.log:void 0;return E.noConflict=function(){return typeof window!==n&&window.log===E&&(window.log=C),E},E.getLoggers=function(){return S},E.default=E,E})})(Vf);var Et=Vf.exports;const cs=()=>`${new Date().toISOString()} | metrics`,fs=(c,r,n)=>`${c} | ${r} | ${n}`;Et.setDefaultLevel(Et.levels.TRACE);const Vg=c=>{Et.info(fs(cs(),"log ",`set log level to ${c?"verbose":"info"}`)),Et.setLevel(c?Et.levels.TRACE:Et.levels.INFO)},jg=c=>{const r=[...Object.keys(Et.levels)];r.includes(c)?(Et.info(fs(cs(),"log ",`update log level to ${c.toLowerCase()}`)),Et.setLevel(c)):Et.warn(fs(cs(),"log ","Incorrect log level please choose one of "),r)},Ne=(c,r,n)=>{n?Et.debug(fs(cs(),c,r),n):Et.debug(fs(cs(),c,r))},Ja=(c,r)=>{Et.info(fs(cs(),c,r))},Ws=(c,r)=>{Et.info(fs(cs(),c,r))},eo=(c,r)=>{Et.warn(fs(cs(),c,r))},wn=(c,r)=>{Et.error(fs(cs(),c,r))};function Bg(c){return Math.floor(Math.random()*c).toString()}function jf(c,r){let n=r;return c.forEach(o=>{n=n.replace(o,"")}),n}function Gg(c,r){let n="";for(let o=0;o<r;o+=1)n+=c[Bg(c.length)];return n}function Kg({length:c=20,useLetters:r=!0,useNumbers:n=!0,includeSymbols:o=[],excludeSymbols:a=[]}={}){let t="abcdefghijklmnopqrstuvwxyz",s="0123456789",p=[],h=[],d=[];return r&&(a.length&&(t=jf(a,t)),h=t.split("")),n&&(a.length&&(s=jf(a,s)),d=s.split("")),p=[...h,...d,...o],Gg(p,c)}var Wg=Kg;const qr=vt(Wg),Yg=()=>"WebRTCMetrics",zg=()=>"5.0.3",ke={INBOUND:"inbound",OUTBOUND:"outbound"},hs={IDLE:"idle",RUNNING:"running",MUTED:"muted"},Vr={NEW:"new",CHECKING:"checking",CONNECTED:"connected",COMPLETED:"completed",DISCONNECTED:"disconnected",FAILED:"failed",CLOSED:"closed"},Jg=()=>({...{delta_time_to_measure_probes_ms:0,delta_time_consumed_to_measure_ms:0,delta_KBytes_in:0,delta_KBytes_out:0,delta_kbs_in:0,delta_kbs_out:0,total_time_decoded_in:0,total_time_encoded_out:0,probes:[]}}),Bf={level_in:0,codec_id_in:"",codec_in:{mime_type:null,clock_rate:null,sdp_fmtp_line:null},delta_jitter_ms_in:0,percent_packets_lost_in:0,delta_packets_in:0,delta_packets_lost_in:0,total_packets_in:0,total_packets_lost_in:0,total_KBytes_in:0,delta_KBytes_in:0,delta_kbs_in:0,mos_in:0,mos_emodel_in:0,ssrc:"",direction:ke.INBOUND},Gf={level_out:0,codec_id_out:"",codec_out:{mime_type:null,clock_rate:null,sdp_fmtp_line:null},delta_jitter_ms_out:0,delta_rtt_ms_out:null,total_rtt_ms_out:0,total_rtt_measure_out:0,percent_packets_lost_out:0,delta_packets_out:0,delta_packets_lost_out:0,total_packets_out:0,total_packets_lost_out:0,total_KBytes_out:0,delta_KBytes_out:0,delta_kbs_out:0,timestamp_out:null,mos_out:0,mos_emodel_out:0,ssrc:"",direction:ke.OUTBOUND},Kf={codec_id_in:"",size_in:{width:null,height:null,framerate:null},codec_in:{mime_type:null,clock_rate:null},delta_jitter_ms_in:0,percent_packets_lost_in:0,delta_packets_in:0,delta_packets_lost_in:0,total_packets_in:0,total_packets_lost_in:0,total_KBytes_in:0,delta_KBytes_in:0,delta_kbs_in:0,decoder_in:null,delta_ms_decode_frame_in:0,total_frames_decoded_in:0,total_time_decoded_in:0,delta_nack_sent_in:0,delta_pli_sent_in:0,total_nack_sent_in:0,total_pli_sent_in:0,ssrc:"",direction:ke.INBOUND},Wf={codec_id_out:"",size_out:{width:null,height:null,framerate:null},codec_out:{mime_type:null,clock_rate:null},delta_jitter_ms_out:0,delta_rtt_ms_out:null,total_rtt_ms_out:0,total_rtt_measure_out:0,percent_packets_lost_out:0,delta_packets_out:0,delta_packets_lost_out:0,total_packets_out:0,total_packets_lost_out:0,total_KBytes_out:0,delta_KBytes_out:0,delta_kbs_out:0,encoder_out:null,delta_ms_encode_frame_out:0,total_time_encoded_out:0,total_frames_encoded_out:0,delta_nack_received_out:0,delta_pli_received_out:0,total_nack_received_out:0,total_pli_received_out:0,limitation_out:{reason:null,durations:null,resolutionChanges:0},timestamp_out:null,ssrc:"",direction:ke.OUTBOUND},Xg=c=>{const r={pname:"",call_id:"",user_id:"",timestamp:null,count:0,audio:{},video:{},network:{infrastructure:3,local_candidate_id:"",local_candidate_type:"",local_candidate_protocol:"",local_candidate_relay_protocol:"",remote_candidate_id:"",remote_candidate_type:"",remote_candidate_protocol:""},data:{total_KBytes_in:0,total_KBytes_out:0,delta_KBytes_in:0,delta_KBytes_out:0,delta_kbs_in:0,delta_kbs_out:0,delta_kbs_bandwidth_in:0,delta_kbs_bandwidth_out:0,delta_rtt_connectivity_ms:null,total_rtt_connectivity_ms:0,total_rtt_connectivity_measure:0},experimental:{time_to_measure_ms:0}};if(c){const n={...c,audio:{},video:{},data:{...c.data},network:{...c.network},experimental:{...c.experimental}};return Object.keys(c.audio).forEach(o=>{n.audio[o]={...c.audio[o]}}),Object.keys(c.video).forEach(o=>{n.video[o]={...c.video[o]}}),n}return{...r,audio:{},video:{},data:{...r.data},network:{...r.network},experimental:{...r.experimental}}},Qg={refreshEvery:2e3,startAfter:0,stopAfter:-1,verbose:!1,pname:`p-${qr()}`,cid:`c-${qr()}`,uid:`u-${qr()}`,record:!1,ticket:!0},Ft={CANDIDATE_PAIR:"candidate-pair",CODEC:"codec",INBOUND_RTP:"inbound-rtp",LOCAL_CANDIDATE:"local-candidate",MEDIA_SOURCE:"media-source",OUTBOUND_RTP:"outbound-rtp",REMOTE_CANDIDATE:"remote-candidate",REMOTE_INBOUND_RTP:"remote-inbound-rtp",TRACK:"track"},q={AUDIO_LEVEL:"audioLevel",AVAILABLE_OUTGOING_BITRATE:"availableOutgoingBitrate",AVAILABLE_INCOMING_BITRATE:"availableIncomingBitrate",BYTES_RECEIVED:"bytesReceived",BYTES_SENT:"bytesSent",CANDIDATE_TYPE:"candidateType",CHANNELS:"channels",CLOCK_RATE:"clockRate",CODEC_ID:"codecId",CURRENT_ROUND_TRIP_TIME:"currentRoundTripTime",ROUND_TRIP_TIME:"roundTripTime",FRACTION_LOST:"fractionLost",FRAME_HEIGHT:"frameHeight",FRAME_WIDTH:"frameWidth",QUALITY_LIMITATION_REASON:"qualityLimitationReason",QUALITY_LIMITATION_DURATIONS:"qualityLimitationDurations",QUALITY_LIMITATION_RESOLUTION_CHANGES:"qualityLimitationResolutionChanges",ID:"id",JITTER:"jitter",KIND:"kind",MEDIA_TYPE:"mediaType",MIME_TYPE:"mimeType",LOCAL_CANDIDATE_ID:"localCandidateId",NETWORK_TYPE:"networkType",RELAY_PROTOCOL:"relayProtocol",NOMINATED:"nominated",PACKETS_LOST:"packetsLost",PACKETS_RECEIVED:"packetsReceived",PACKETS_SENT:"packetsSent",PROTOCOL:"protocol",PORT:"port",REMOTE_CANDIDATE_ID:"remoteCandidateId",REMOTE_SOURCE:"remoteSource",RESPONSES_RECEIVED:"responsesReceived",SDP_FMTP_LINE:"sdpFmtpLine",SSRC:"ssrc",SELECTED:"selected",STATE:"state",TIMESTAMP:"timestamp",TOTAL_ROUND_TRIP_TIME:"totalRoundTripTime",TOTAL_ROUND_TRIP_TIME_MEASUREMENTS:"roundTripTimeMeasurements",TYPE:"type",DECODER_IMPLEMENTATION:"decoderImplementation",ENCODER_IMPLEMENTATION:"encoderImplementation",FRAMES_DECODED:"framesDecoded",FRAMES_ENCODED:"framesEncoded",FRAMES_PER_SECOND:"framesPerSecond",TOTAL_DECODE_TIME:"totalDecodeTime",TOTAL_ENCODE_TIME:"totalEncodeTime",PLI:"pliCount",NACK:"nackCount"},k={SUCCEEDED:"succeeded",AUDIO:"audio",VIDEO:"video"},jr={ETHERNET:0,CELLULAR_5G:2,WIFI:3,CELLULAR_4G:5,CELLULAR:10},Xa={ETHERNET:"ethernet",CELLULAR_4G:"cellular",WIFI:"wifi"},ee={AUDIO:"audio",VIDEO:"video",NETWORK:"network",DATA:"data"},Qa="config ",Zg=(c,r={},n)=>{const o={...n,...r};return r.pname||eo(Qa,`Argument [String] 'cfg.pname' for the peerConnection name or id is missing - use generated '${n.pname}'`),r.cid||eo(Qa,`Argument [String] 'cfg.cid' for the call name or id is missing - use generated '${n.cid}'`),r.uid||eo(Qa,`Argument [String] 'cfg.uid' for the user name or id is missing - use generated '${n.uid}'`),o.pc=c,o},ev=(c={})=>{const r={...Qg,...c};return r.name=Yg(),r.version=zg(),r},Br=(c,r,n,o=!1,a)=>{let t=c.map(s=>{if(!n)return s[r];if(!a)return s[r][n];const p=s[r][a];return p?p[n]:null});return t=t.filter(s=>o?Number.isFinite(s)&&s>0:Number.isFinite(s)),t.length===0?[]:t},As=c=>c.reduce((r,n)=>r+n,0)/c.length,tv=()=>`probe-${qr()}`,sv=()=>`coltr-${qr()}`,Yf=c=>new Promise(r=>setTimeout(r,c)),Za=(c,r,n)=>{r?c.call(r,n):c(n)},Ve=(c,r,n,o)=>{const a=Br(c,r,n,!0,o);if(a.length===0)return null;const t=a.reduce((d,g)=>d+g,0)/a.length;return t===0?null:a.map(d=>Math.abs(t-d)).reduce((d,g)=>d+g,0)/a.length*100/t},We=(c,r,n,o=!1,a)=>{const t=Br(c,r,n,o,a);return t.length===0?null:t.reduce((s,p)=>s+p,0)/t.length},Ys=(c,r,n)=>Br(c,r,n).reduce((a,t)=>a+t,0),je=(c,r,n,o)=>{const a=Br(c,r,n,!0,o);return a.length===0?null:Math.min(...a)},Be=(c,r,n,o)=>{const a=Br(c,r,n,!1,o);return a.length===0?null:Math.max(...a)},mt=(c,r,n,o)=>{const a=c.slice().pop();if(!a)return null;if(!n)return a[r];if(!o)return a[r][n];const t=a[r][o];return t?t[n]:null},nv=c=>c.slice().pop(),lt=(c,r,n)=>{if(!r)return null;const o={};let a=r[k.AUDIO][c];a||(a=n===ke.INBOUND?{...Bf}:{...Gf}),o[k.AUDIO]=a;let t=r[k.VIDEO][c];return t||(t=n===ke.INBOUND?{...Kf}:{...Wf}),o[k.VIDEO]=t,o},Gr="exporter ",rv="2.0",zf=(c,r,n)=>{if(!c||c.length===0)return 0;const o=c[c.length-1];if(!o)return 0;const a=o[r][n];if(a){const t=a.total_rtt_ms_out,s=a.total_rtt_measure_out;return!s||!t?We(c,r,"delta_rtt_ms_out",!1,n):Number(t/s)}return null},iv=(c,r)=>{if(!c||c.length===0)return 0;const n=c[c.length-1];if(!n)return 0;const o=n[r].total_rtt_connectivity_ms,a=n[r].total_rtt_connectivity_measure;return!a||!o?We(c,r,"delta_rtt_connectivity_ms"):Number(o/a)},lv=c=>mt(c,"network","local_candidate_type")!=="relay"?`direct/${mt(c,"network","local_candidate_protocol")}`:`turn/${mt(c,"network","local_candidate_relay_protocol")}`,ov=c=>{const r=mt(c,"network","remote_candidate_type"),n=mt(c,"network","remote_candidate_protocol");return r!=="relay"?`direct/${n}`:`turn/${n}`};class av{constructor(r){this._start=null,this._end=null,this._cfg=r,this._referenceReport=null,this._reports=[],this._events=[]}start(){Ja(Gr,"start() - start exporter...");const r=new Date;return this._start=r.toJSON(),r}stop(){Ja(Gr,"stop() - stop exporter...");const r=new Date;return this._end=r.toJSON(),r}saveReferenceReport(r){this._referenceReport=r}getReferenceReport(){return this._referenceReport}addReport(r){this._cfg.ticket&&(Ne(Gr,`addReport() - add report to exporter at ${r.timestamp}`),this._reports.push(r))}addCustomEvent(r){this._events.push(r)}reset(){Ja(Gr,"resetReports() - reset reports"),this._reports=[],this._referenceReport=null,this._start=null,this._end=null}get ticket(){Ne(Gr,"ticket() - generate ticket");const r=mt(this._reports,"audio","total_packets_lost_in"),n=mt(this._reports,"audio","total_packets_in"),o=mt(this._reports,"video","total_packets_lost_in"),a=mt(this._reports,"video","total_packets_in"),t={},s=nv(this._reports);return s&&(Object.keys(s[k.AUDIO]).forEach(p=>{const h=s[k.AUDIO][p];if(t[h.ssrc]={type:k.AUDIO,direction:h.direction},h.direction===ke.INBOUND){const d={avg:We(this._reports,k.AUDIO,"delta_jitter_ms_in",!1,p),min:je(this._reports,k.AUDIO,"delta_jitter_ms_in",p),max:Be(this._reports,k.AUDIO,"delta_jitter_ms_in",p),volatility:Ve(this._reports,k.AUDIO,"delta_jitter_ms_in",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:We(this._reports,k.AUDIO,"delta_kbs_in",!1,p),min:je(this._reports,k.AUDIO,"delta_kbs_in",p),max:Be(this._reports,k.AUDIO,"delta_kbs_in",p),volatility:Ve(this._reports,k.AUDIO,"delta_kbs_in",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},v={avg:We(this._reports,k.AUDIO,"delta_KBytes_in",!1,p),min:je(this._reports,k.AUDIO,"delta_KBytes_in",p),max:Be(this._reports,k.AUDIO,"delta_KBytes_in",p),volatility:Ve(this._reports,k.AUDIO,"delta_KBytes_in",p),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E={emodel:{avg:We(this._reports,k.AUDIO,"mos_emodel_in",!1,p),min:je(this._reports,k.AUDIO,"mos_emodel_in",p),max:Be(this._reports,k.AUDIO,"mos_emodel_in",p),volatility:Ve(this._reports,k.AUDIO,"mos_emodel_in",p)},effective:{avg:We(this._reports,k.AUDIO,"mos_in",!1,p),min:je(this._reports,k.AUDIO,"mos_in",p),max:Be(this._reports,k.AUDIO,"mos_in",p),volatility:Ve(this._reports,k.AUDIO,"mos_in",p)},_unit:{avg:"number (1-5)",min:"number (1-5)",max:"number (1-5)",volatility:"percent"}},S=mt(this._reports,k.AUDIO,"total_packets_lost_in",p),C=mt(this._reports,k.AUDIO,"total_packets_in",p),I={lost:S,avg:Math.round((S/(S+C)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};t[p].jitter=d,t[p].mos=E,t[p].traffic=v,t[p].bitrate=g,t[p].loss=I}else{const d={avg:We(this._reports,k.AUDIO,"delta_jitter_ms_out",!1,p),min:je(this._reports,k.AUDIO,"delta_jitter_ms_out",p),max:Be(this._reports,k.AUDIO,"delta_jitter_ms_out",p),volatility:Ve(this._reports,k.AUDIO,"delta_jitter_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:We(this._reports,k.AUDIO,"delta_kbs_out",!1,p),min:je(this._reports,k.AUDIO,"delta_kbs_out",p),max:Be(this._reports,k.AUDIO,"delta_kbs_out",p),volatility:Ve(this._reports,k.AUDIO,"delta_kbs_out",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},v={avg:We(this._reports,k.AUDIO,"delta_KBytes_out",!1,p),min:je(this._reports,k.AUDIO,"delta_KBytes_out",p),max:Be(this._reports,k.AUDIO,"delta_KBytes_out",p),volatility:Ve(this._reports,k.AUDIO,"delta_KBytes_out",p),_unit:{avg:"KB",min:"KB",max:"KB",bitrate:"kbs",volatility:"percent"}},E={avg:zf(this._reports,k.AUDIO,p),min:je(this._reports,k.AUDIO,"delta_rtt_ms_out",p),max:Be(this._reports,k.AUDIO,"delta_rtt_ms_out",p),volatility:Ve(this._reports,k.AUDIO,"delta_rtt_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},S=mt(this._reports,k.AUDIO,"total_packets_lost_out",p),C=mt(this._reports,k.AUDIO,"total_packets_out",p),I={lost:S,avg:Math.round((S/(S+C)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}},w={emodel:{avg:We(this._reports,k.AUDIO,"mos_emodel_out",!1,p),min:je(this._reports,k.AUDIO,"mos_emodel_out",p),max:Be(this._reports,k.AUDIO,"mos_emodel_out",p),volatility:Ve(this._reports,k.AUDIO,"mos_emodel_out",p)},effective:{avg:We(this._reports,k.AUDIO,"mos_out",!1,p),min:je(this._reports,k.AUDIO,"mos_out",p),max:Be(this._reports,k.AUDIO,"mos_out",p),volatility:Ve(this._reports,k.AUDIO,"mos_out",p)},_unit:{avg:"number (1-5)",min:"number (1-5)",max:"number (1-5)",volatility:"percent"}};t[p].jitter=d,t[p].rtt=E,t[p].traffic=v,t[p].bitrate=g,t[p].loss=I,t[p].mos=w}}),Object.keys(s[k.VIDEO]).forEach(p=>{const h=s[k.VIDEO][p];if(t[p]={type:k.VIDEO,direction:h.direction},h.direction===ke.INBOUND){const d={avg:We(this._reports,k.VIDEO,"delta_jitter_ms_in",!1,p),min:je(this._reports,k.VIDEO,"delta_jitter_ms_in",p),max:Be(this._reports,k.VIDEO,"delta_jitter_ms_in",p),volatility:Ve(this._reports,k.VIDEO,"delta_jitter_ms_in",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:We(this._reports,k.VIDEO,"delta_kbs_in",!1,p),min:je(this._reports,k.VIDEO,"delta_kbs_in",p),max:Be(this._reports,k.VIDEO,"delta_kbs_in",p),volatility:Ve(this._reports,k.VIDEO,"delta_kbs_in",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},v={avg:We(this._reports,k.VIDEO,"delta_KBytes_in",!1,p),min:je(this._reports,k.VIDEO,"delta_KBytes_in",p),max:Be(this._reports,k.VIDEO,"delta_KBytes_in",p),volatility:Ve(this._reports,k.VIDEO,"delta_KBytes_in",p),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E=mt(this._reports,k.VIDEO,"total_packets_lost_in",p),S=mt(this._reports,k.VIDEO,"total_packets_in",p),C={lost:E,avg:Math.round((E/(E+S)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};t[p].jitter=d,t[p].traffic=v,t[p].bitrate=g,t[p].loss=C}else{const d={avg:We(this._reports,k.VIDEO,"delta_jitter_ms_out",!1,p),min:je(this._reports,k.VIDEO,"delta_jitter_ms_out",p),max:Be(this._reports,k.VIDEO,"delta_jitter_ms_out",p),volatility:Ve(this._reports,k.VIDEO,"delta_jitter_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},g={avg:We(this._reports,k.VIDEO,"delta_kbs_out",!1,p),min:je(this._reports,k.VIDEO,"delta_kbs_out",p),max:Be(this._reports,k.VIDEO,"delta_kbs_out",p),volatility:Ve(this._reports,k.VIDEO,"delta_kbs_out",p),_unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},v={avg:We(this._reports,k.VIDEO,"delta_KBytes_out",!1,p),min:je(this._reports,k.VIDEO,"delta_KBytes_out",p),max:Be(this._reports,k.VIDEO,"delta_KBytes_out",p),volatility:Ve(this._reports,k.VIDEO,"delta_KBytes_out",p),_unit:{avg:"KB",min:"KB",max:"KB",volatility:"percent"}},E={avg:zf(this._reports,k.VIDEO,p),min:je(this._reports,k.VIDEO,"delta_rtt_ms_out",p),max:Be(this._reports,k.VIDEO,"delta_rtt_ms_out",p),volatility:Ve(this._reports,k.VIDEO,"delta_rtt_ms_out",p),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},S=mt(this._reports,k.VIDEO,"total_packets_lost_out",p),C=mt(this._reports,k.VIDEO,"total_packets_out",p),I={lost:S,avg:Math.round((S/(S+C)*100||0)*100)/100,_unit:{avg:"percent",lost:"number"}};t[p].jitter=d,t[p].rtt=E,t[p].traffic=v,t[p].bitrate=g,t[p].loss=I}})),{version:rv,configuration:{frequency:this._cfg.refreshEvery},started:this._start,ended:this._end,ua:{agent:navigator.userAgent,pname:this._cfg.pname,user_id:this._cfg.uid},call:{call_id:this._cfg.cid,events:this._events},details:{count:this._reports.length,reports:this._cfg.record?this._reports:[],reference:this._referenceReport||null},ssrc:t,data:{rtt:{avg:iv(this._reports,"data"),min:je(this._reports,"data","delta_rtt_connectivity_ms"),max:Be(this._reports,"data","delta_rtt_connectivity_ms"),volatility:Ve(this._reports,"data","delta_rtt_connectivity_ms"),_unit:{avg:"ms",min:"ms",max:"ms",volatility:"percent"}},packetsLost:{audio:{in:{avg:Math.round((r/(r+n)*100||0)*100)/100}},video:{in:{avg:Math.round((o/(o+a)*100||0)*100)/100}},unit:{avg:"percent"}},bitrate:{in:{avg:We(this._reports,"data","delta_kbs_in"),min:je(this._reports,"data","delta_kbs_in"),max:Be(this._reports,"data","delta_kbs_in"),volatility:Ve(this._reports,"data","delta_kbs_in")},out:{avg:We(this._reports,"data","delta_kbs_out"),min:je(this._reports,"data","delta_kbs_out"),max:Be(this._reports,"data","delta_kbs_out"),volatility:Ve(this._reports,"data","delta_kbs_out")},unit:{avg:"kbs",min:"kbs",max:"kbs",volatility:"percent"}},traffic:{in:{avg:We(this._reports,"data","delta_KBytes_in"),min:je(this._reports,"data","delta_KBytes_in"),max:Be(this._reports,"data","delta_KBytes_in"),volatility:Ve(this._reports,"data","delta_KBytes_in")},out:{avg:We(this._reports,"data","delta_KBytes_out"),min:je(this._reports,"data","delta_KBytes_out"),max:Be(this._reports,"data","delta_KBytes_out"),volatility:Ve(this._reports,"data","delta_KBytes_out")},unit:{avg:"KBytes",min:"KBytes",max:"KBytes",volatility:"percent"}},network:{localConnection:lv(this._reports),remoteConnection:ov(this._reports)}}}}updateConfig(r){this._cfg=r}getLastReport(){return this._reports.slice().pop()||null}getBeforeLastReport(){const r=this._reports.slice();return r.pop(),r.pop()||null}getReportsNumber(){return this._reports.length}}const Rs="extractor ",Jf=(c,r,n,o)=>{let a=!1;const t=o[r].total_rtt_ms_out,s=o[r].total_rtt_measure_out,p=n?n[r].total_rtt_ms_out:0,h=n?n[r].total_rtt_measure_out:0,d={rtt:null,totalRTT:t,totalRTTMeasurements:s};if(c[q.TIMESTAMP]===o[r].timestamp_out||!Object.prototype.hasOwnProperty.call(c,q.ROUND_TRIP_TIME)||Object.prototype.hasOwnProperty.call(c,q.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS)&&(a=!0,Number(c[q.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])===0||Number(c[q.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])-h===s))return d;const g=1e3*Number(c[q.ROUND_TRIP_TIME]);let v=t+g,E=s+1;return a&&(v=1e3*Number(c[q.TOTAL_ROUND_TRIP_TIME])-p,E=Number(c[q.TOTAL_ROUND_TRIP_TIME_MEASUREMENTS])-h),{rtt:g,totalRTT:v,totalRTTMeasurements:E}},uv=(c,r,n,o)=>{if(!Object.prototype.hasOwnProperty.call(c,q.CURRENT_ROUND_TRIP_TIME))return{rtt:null,totalRTT:o[r].total_rtt_connectivity_ms,totalRTTMeasurements:o[r].total_rtt_connectivity_measure};const a=1e3*Number(c[q.CURRENT_ROUND_TRIP_TIME]);let t=o[r].total_rtt_connectivity_ms+a,s=o[r].total_rtt_connectivity_measure+1;return Object.prototype.hasOwnProperty.call(c,q.TOTAL_ROUND_TRIP_TIME)&&(t=1e3*Number(c[q.TOTAL_ROUND_TRIP_TIME])-(n?n[r].total_rtt_connectivity_ms:0)),Object.prototype.hasOwnProperty.call(c,q.RESPONSES_RECEIVED)&&(s=Number(c[q.RESPONSES_RECEIVED])-(n?n[r].total_rtt_connectivity_measure:0)),{rtt:a,totalRTT:t,totalRTTMeasurements:s}},to=(c,r,n)=>c[q.TIMESTAMP]===n[r].timestamp_out||!Object.prototype.hasOwnProperty.call(c,q.JITTER)?null:1e3*(Number(c[q.JITTER])||0),cv=(c,r)=>{if(!Object.prototype.hasOwnProperty.call(c,q.FRAMES_DECODED)||!Object.prototype.hasOwnProperty.call(c,q.TOTAL_DECODE_TIME))return{delta_ms_decode_frame:r[k.VIDEO].delta_ms_decode_frame_in,frames_decoded:r[k.VIDEO].total_frames_decoded_in,total_decode_time:r[k.VIDEO].total_time_decoded_in};const n=c[q.FRAMES_DECODED],o=c[q.TOTAL_DECODE_TIME],a=o-r[k.VIDEO].total_time_decoded_in,t=n-r[k.VIDEO].total_frames_decoded_in;return{delta_ms_decode_frame:t>0?a*1e3/t:0,frames_decoded:n,total_decode_time:o}},fv=(c,r)=>{if(!Object.prototype.hasOwnProperty.call(c,q.FRAMES_ENCODED)||!Object.prototype.hasOwnProperty.call(c,q.TOTAL_ENCODE_TIME))return{delta_ms_encode_frame:r[k.VIDEO].delta_ms_encode_frame_out,frames_encoded:r[k.VIDEO].total_frames_encoded_out,total_encode_time:r[k.VIDEO].total_time_encoded_out};const n=c[q.FRAMES_ENCODED],o=c[q.TOTAL_ENCODE_TIME],a=o-r[k.VIDEO].total_time_encoded_out,t=n-r[k.VIDEO].total_frames_encoded_out;return{delta_ms_encode_frame:t>0&&a?a*1e3/t:0,frames_encoded:n,total_encode_time:o}},Xf=(c,r,n,o)=>{if(!Object.prototype.hasOwnProperty.call(c,q.PACKETS_SENT)||!Object.prototype.hasOwnProperty.call(c,q.BYTES_SENT))return{packetsSent:n[r].total_packets_out,packetsLost:n[r].total_packets_lost_out,bytesSent:n[r].total_KBytes_out};const a=Number(c[q.PACKETS_SENT])||0-(o?o[r].total_packets_out:0),t=a-n[r].total_packets_out,s=Number(c[q.BYTES_SENT])/1024-(o?o[r].total_KBytes_out:0),p=s-n[r].total_KBytes_out,h=c[q.TIMESTAMP]||Date.now(),d=o?o.timestamp:null;let g=n.timestamp;!g&&d&&(g=d);const v=g?h-g:0,E=v>0?p*.008*1024/v*1e3:0;return{packetsSent:a,deltaPacketsSent:t,KBytesSent:s,deltaKBytesSent:p,kbsSent:E}},Qf=(c,r,n,o)=>{let a=n[r].total_packets_lost_out,t=0,s=0;return Object.prototype.hasOwnProperty.call(c,q.PACKETS_LOST)&&(a=Number(c[q.PACKETS_LOST])||0-(o?o[r].total_packets_lost_out:0),t=a-n[r].total_packets_lost_out),Object.prototype.hasOwnProperty.call(c,q.FRACTION_LOST)&&(s=Number(100*c[q.FRACTION_LOST])),{packetsLost:a,deltaPacketsLost:t,fractionLost:s}},Zf=(c,r,n,o)=>{if(!Object.prototype.hasOwnProperty.call(c,q.PACKETS_RECEIVED)||!Object.prototype.hasOwnProperty.call(c,q.PACKETS_LOST)||!Object.prototype.hasOwnProperty.call(c,q.BYTES_RECEIVED))return{percent_packets_lost:n[r].percent_packets_lost_in,packetsReceived:n[r].total_packets_in,packetsLost:n[r].total_packets_lost_in,bytesReceived:n[r].total_KBytes_in};const a=Number(c[q.PACKETS_RECEIVED])||0-(o?o[r].total_packets_in:0),t=Number(c[q.PACKETS_LOST])||0-(o?o[r].total_packets_lost_in:0),s=t-n[r].total_packets_lost_in,p=a-n[r].total_packets_in,h=a!==n[r].total_packets_in?s*100/(s+p):0,d=Number(c[q.BYTES_RECEIVED])/1024-(o?o[r].total_KBytes_in:0),g=d-n[r].total_KBytes_in,v=c[q.TIMESTAMP]||Date.now(),E=o?o.timestamp:null;let S=n.timestamp;!S&&E&&(S=E);const C=S?v-S:0,I=C>0?g*.008*1024/C*1e3:0;return{percentPacketsLost:h,packetsReceived:a,deltaPacketsReceived:p,packetsLost:t,deltaPacketsLost:s,KBytesReceived:d,deltaKBytesReceived:g,kbsReceived:I}},hv=c=>c[q.CANDIDATE_TYPE]!=="relay"?"":c[q.RELAY_PROTOCOL]||"",_v=c=>{if(!Object.prototype.hasOwnProperty.call(c,q.NETWORK_TYPE))return jr.WIFI;switch(c[q.NETWORK_TYPE]){case Xa.ETHERNET:return jr.ETHERNET;case Xa.CELLULAR_4G:return jr.CELLULAR_4G;case Xa.WIFI:return jr.WIFI;default:return jr.CELLULAR}},eh=c=>!Object.prototype.hasOwnProperty.call(c,q.FRAME_HEIGHT)||!Object.prototype.hasOwnProperty.call(c,q.FRAME_WIDTH)?{width:null,height:null,framerate:null}:{width:c[q.FRAME_WIDTH]||null,height:c[q.FRAME_HEIGHT]||null,framerate:c[q.FRAMES_PER_SECOND]},dv=c=>{const r=Object.prototype.hasOwnProperty.call(c,q.QUALITY_LIMITATION_REASON)?c[q.QUALITY_LIMITATION_REASON]:null,n=Object.prototype.hasOwnProperty.call(c,q.QUALITY_LIMITATION_RESOLUTION_CHANGES)?c[q.QUALITY_LIMITATION_RESOLUTION_CHANGES]:null,o=Object.prototype.hasOwnProperty.call(c,q.QUALITY_LIMITATION_DURATIONS)?c[q.QUALITY_LIMITATION_DURATIONS]:null;return o&&Object.keys(o).forEach(a=>{o[a]>1e3&&(o[a]=Number(o[a]/1e3))}),{reason:r,durations:o,resolutionChanges:n}},pv=(c,r,n)=>{if(!Object.prototype.hasOwnProperty.call(c,q.PLI)||!Object.prototype.hasOwnProperty.call(c,q.NACK))return{pliCount:r.total_pli_sent_in,nackCount:r.total_nack_sent_in,deltaPliCount:0,deltaNackCount:0};const o=(c[q.PLI]||0)-(n?n[k.VIDEO].total_pli_sent_in:0),a=(c[q.NACK]||0)-(n?n[k.VIDEO].total_nack_sent_in:0);return{pliCount:o,nackCount:a,deltaPliCount:o-r[k.VIDEO].total_pli_sent_in,deltaNackCount:a-r[k.VIDEO].total_nack_sent_in}},mv=(c,r,n)=>{if(!Object.prototype.hasOwnProperty.call(c,q.PLI)||!Object.prototype.hasOwnProperty.call(c,q.NACK))return{pliCount:r.total_pli_received_out,nackCount:r.total_nack_received_out,deltaPliCount:0,deltaNackCount:0};const o=(c[q.PLI]||0)-(n?n[k.VIDEO].total_pli_received_out:0),a=(c[q.NACK]||0)-(n?n[k.VIDEO].total_nack_received_out:0);return{pliCount:o,nackCount:a,deltaPliCount:o-r[k.VIDEO].total_pli_received_out,deltaNackCount:a-r[k.VIDEO].total_nack_received_out}},gv=c=>({channels:c[q.CHANNELS]||null,clock_rate:c[q.CLOCK_RATE]||null,mime_type:c[q.MIME_TYPE]||null,sdp_fmtp_line:c[q.SDP_FMTP_LINE]||null}),vv=c=>({clock_rate:c[q.CLOCK_RATE]||null,mime_type:c[q.MIME_TYPE]||null}),Tv=(c,r,n)=>{const o=(c[q.BYTES_RECEIVED]||0)/1024-(n?n.data.total_KBytes_in:0),a=(c[q.BYTES_SENT]||0)/1024-(n?n.data.total_KBytes_out:0),t=c[q.TIMESTAMP]||Date.now(),s=o-r.data.total_KBytes_in,p=a-r.data.total_KBytes_out,h=n?n.timestamp:null;let d=r.timestamp;!d&&h&&(d=h);const g=d?t-d:0,v=g>0?s*.008*1024/g*1e3:0,E=g>0?p*.008*1024/g*1e3:0;return{total_KBytes_received:o,total_KBytes_sent:a,delta_KBytes_received:s,delta_KBytes_sent:p,kbs_speed_received:v,kbs_speed_sent:E}},Ev=c=>{const r=c[q.AVAILABLE_INCOMING_BITRATE]/1024||0,n=c[q.AVAILABLE_OUTGOING_BITRATE]/1024||0;return{kbs_incoming_bandwidth:r,kbs_outgoing_bandwidth:n}},yv=(c,r,n,o)=>{if(!c)return[];switch(c[q.TYPE]){case Ft.CANDIDATE_PAIR:let a=!1;if(c[q.NOMINATED]&&c[q.STATE]===k.SUCCEEDED&&(a=!0,Ne(Rs,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c),q.SELECTED in c&&!c[q.SELECTED]&&(a=!1)),a){const s=c[q.LOCAL_CANDIDATE_ID],p=c[q.REMOTE_CANDIDATE_ID],h=Tv(c,r,o),d=Ev(c),g=uv(c,"data",o,r);return[{type:ee.NETWORK,value:{local_candidate_id:s}},{type:ee.NETWORK,value:{remote_candidate_id:p}},{type:ee.DATA,value:{total_KBytes_in:h.total_KBytes_received}},{type:ee.DATA,value:{total_KBytes_out:h.total_KBytes_sent}},{type:ee.DATA,value:{delta_KBytes_in:h.delta_KBytes_received}},{type:ee.DATA,value:{delta_KBytes_out:h.delta_KBytes_sent}},{type:ee.DATA,value:{delta_kbs_in:h.kbs_speed_received}},{type:ee.DATA,value:{delta_kbs_out:h.kbs_speed_sent}},{type:ee.DATA,value:{delta_kbs_bandwidth_in:d.kbs_incoming_bandwidth}},{type:ee.DATA,value:{delta_kbs_bandwidth_out:d.kbs_outgoing_bandwidth}},{type:ee.DATA,value:{delta_rtt_connectivity_ms:g.rtt}},{type:ee.DATA,value:{total_rtt_connectivity_ms:g.totalRTT}},{type:ee.DATA,value:{total_rtt_connectivity_measure:g.totalRTTMeasurements}}]}break;case Ft.LOCAL_CANDIDATE:if(c[q.ID]===r.network.local_candidate_id)return[{type:ee.NETWORK,value:{infrastructure:_v(c)}},{type:ee.NETWORK,value:{local_candidate_type:c[q.CANDIDATE_TYPE]||""}},{type:ee.NETWORK,value:{local_candidate_protocol:c[q.PROTOCOL]||""}},{type:ee.NETWORK,value:{local_candidate_relay_protocol:hv(c)}}];break;case Ft.REMOTE_CANDIDATE:if(c[q.ID]===r.network.remote_candidate_id)return[{type:ee.NETWORK,value:{remote_candidate_type:c[q.CANDIDATE_TYPE]||""}},{type:ee.NETWORK,value:{remote_candidate_protocol:c[q.PROTOCOL]||""}}];break;case Ft.INBOUND_RTP:{Ne(Rs,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);const s=c[q.SSRC],p=lt(s,r,ke.INBOUND);p&&(p.timestamp=r.timestamp);const h=lt(s,o,ke.INBOUND);if(h&&(h.timestamp=o.timestamp),c[q.MEDIA_TYPE]===k.AUDIO){const d=Zf(c,k.AUDIO,p,h),g=to(c,k.AUDIO,p),v=c[q.CODEC_ID]||"";return[{ssrc:s,type:ee.AUDIO,value:{codec_id_in:v}},{ssrc:s,type:ee.AUDIO,value:{total_packets_in:d.packetsReceived}},{ssrc:s,type:ee.AUDIO,value:{delta_packets_in:d.deltaPacketsReceived}},{ssrc:s,type:ee.AUDIO,value:{total_packets_lost_in:d.packetsLost}},{ssrc:s,type:ee.AUDIO,value:{delta_packets_lost_in:d.deltaPacketsLost}},{ssrc:s,type:ee.AUDIO,value:{percent_packets_lost_in:d.percentPacketsLost}},{ssrc:s,type:ee.AUDIO,value:{total_KBytes_in:d.KBytesReceived}},{ssrc:s,type:ee.AUDIO,value:{delta_KBytes_in:d.deltaKBytesReceived}},{ssrc:s,type:ee.AUDIO,value:{delta_kbs_in:d.kbsReceived}},{ssrc:s,type:ee.AUDIO,value:{delta_jitter_ms_in:g}}]}if(c[q.MEDIA_TYPE]===k.VIDEO){const d=cv(c,p),g=Zf(c,k.VIDEO,p,h),v=to(c,k.VIDEO,p),E=c[q.DECODER_IMPLEMENTATION]||null,S=c[q.CODEC_ID]||null,C=eh(c),I=pv(c,p,h);return[{ssrc:s,type:ee.VIDEO,value:{codec_id_in:S}},{ssrc:s,type:ee.VIDEO,value:{total_packets_in:g.packetsReceived}},{ssrc:s,type:ee.VIDEO,value:{delta_packets_in:g.deltaPacketsReceived}},{ssrc:s,type:ee.VIDEO,value:{total_packets_lost_in:g.packetsLost}},{ssrc:s,type:ee.VIDEO,value:{delta_packets_lost_in:g.deltaPacketsLost}},{ssrc:s,type:ee.VIDEO,value:{percent_packets_lost_in:g.percentPacketsLost}},{ssrc:s,type:ee.VIDEO,value:{total_KBytes_in:g.KBytesReceived}},{ssrc:s,type:ee.VIDEO,value:{delta_KBytes_in:g.deltaKBytesReceived}},{ssrc:s,type:ee.VIDEO,value:{delta_kbs_in:g.kbsReceived}},{ssrc:s,type:ee.VIDEO,value:{delta_jitter_ms_in:v}},{ssrc:s,type:ee.VIDEO,value:{decoder_in:E}},{ssrc:s,type:ee.VIDEO,value:{delta_ms_decode_frame_in:d.delta_ms_decode_frame}},{ssrc:s,type:ee.VIDEO,value:{total_frames_decoded_in:d.frames_decoded}},{ssrc:s,type:ee.VIDEO,value:{total_time_decoded_in:d.total_decode_time}},{ssrc:s,type:ee.VIDEO,value:{total_nack_sent_in:I.nackCount}},{ssrc:s,type:ee.VIDEO,value:{delta_nack_sent_in:I.deltaNackCount}},{ssrc:s,type:ee.VIDEO,value:{total_pli_sent_in:I.pliCount}},{ssrc:s,type:ee.VIDEO,value:{delta_pli_sent_in:I.deltaPliCount}},{ssrc:s,type:ee.VIDEO,value:{size_in:C}}]}break}case Ft.OUTBOUND_RTP:{Ne(Rs,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);const s=c[q.SSRC],p=lt(s,r,ke.OUTBOUND);p&&(p.timestamp=r.timestamp);const h=lt(s,o,ke.OUTBOUND);if(h&&(h.timestamp=o.timestamp),c[q.MEDIA_TYPE]===k.AUDIO){const d=c[q.CODEC_ID]||null,g=Xf(c,k.AUDIO,p,h);return[{ssrc:s,type:ee.AUDIO,value:{codec_id_out:d}},{ssrc:s,type:ee.AUDIO,value:{total_packets_out:g.packetsSent}},{ssrc:s,type:ee.AUDIO,value:{delta_packets_out:g.deltaPacketsSent}},{ssrc:s,type:ee.AUDIO,value:{total_KBytes_out:g.KBytesSent}},{ssrc:s,type:ee.AUDIO,value:{delta_KBytes_out:g.deltaKBytesSent}},{ssrc:s,type:ee.AUDIO,value:{delta_kbs_out:g.kbsSent}}]}if(c[q.MEDIA_TYPE]===k.VIDEO){const d=c[q.ENCODER_IMPLEMENTATION]||null,g=c[q.CODEC_ID]||null,v=fv(c,p),E=eh(c),S=dv(c),C=mv(c,p,h),I=Xf(c,k.VIDEO,p,h);return[{ssrc:s,type:ee.VIDEO,value:{codec_id_out:g}},{ssrc:s,type:ee.VIDEO,value:{total_packets_out:I.packetsSent}},{ssrc:s,type:ee.VIDEO,value:{delta_packets_out:I.deltaPacketsSent}},{ssrc:s,type:ee.VIDEO,value:{total_KBytes_out:I.KBytesSent}},{ssrc:s,type:ee.VIDEO,value:{delta_KBytes_out:I.deltaKBytesSent}},{ssrc:s,type:ee.VIDEO,value:{delta_kbs_out:I.kbsSent}},{ssrc:s,type:ee.VIDEO,value:{encoder_out:d}},{ssrc:s,type:ee.VIDEO,value:{delta_ms_encode_frame_out:v.delta_ms_encode_frame}},{ssrc:s,type:ee.VIDEO,value:{total_frames_encoded_out:v.frames_encoded}},{ssrc:s,type:ee.VIDEO,value:{total_time_encoded_out:v.total_encode_time}},{ssrc:s,type:ee.VIDEO,value:{total_nack_received_out:C.nackCount}},{ssrc:s,type:ee.VIDEO,value:{delta_nack_received_out:C.deltaNackCount}},{ssrc:s,type:ee.VIDEO,value:{total_pli_received_out:C.pliCount}},{ssrc:s,type:ee.VIDEO,value:{delta_pli_received_out:C.deltaPliCount}},{ssrc:s,type:ee.VIDEO,value:{size_out:E}},{ssrc:s,type:ee.VIDEO,value:{limitation_out:S}}]}break}case Ft.MEDIA_SOURCE:{Ne(Rs,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);break}case Ft.TRACK:{Ne(Rs,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);break}case Ft.CODEC:const t=[];return Object.keys(r[k.AUDIO]).forEach(s=>{const p=r[k.AUDIO][s];if(p.codec_id_in===c[q.ID]||p.codec_id_out===c[q.ID]){Ne(Rs,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);const h=gv(c);c[q.ID]===p.codec_id_in?t.push({ssrc:p.ssrc,type:ee.AUDIO,value:{codec_in:h}}):t.push({ssrc:p.ssrc,type:ee.AUDIO,value:{codec_out:h}})}}),Object.keys(r[k.VIDEO]).forEach(s=>{const p=r[k.VIDEO][s];if(p.codec_id_in===c[q.ID]||p.codec_id_out===c[q.ID]){Ne(Rs,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);const h=vv(c);c[q.ID]===p.codec_id_in?t.push({ssrc:p.ssrc,type:ee.VIDEO,value:{codec_in:h}}):t.push({ssrc:p.ssrc,type:ee.VIDEO,value:{codec_out:h}})}}),t;case Ft.REMOTE_INBOUND_RTP:{Ne(Rs,`analyze() - got stats ${c[q.TYPE]} for ${n}`,c);const s=c[q.SSRC],p=lt(s,r,ke.OUTBOUND),h=lt(s,o,ke.OUTBOUND);if(c[q.KIND]===k.AUDIO){const d=Jf(c,k.AUDIO,h,p),g=to(c,k.AUDIO,p),v=Qf(c,k.AUDIO,p,h);return[{ssrc:s,type:ee.AUDIO,value:{delta_rtt_ms_out:d.rtt}},{ssrc:s,type:ee.AUDIO,value:{total_rtt_ms_out:d.totalRTT}},{ssrc:s,type:ee.AUDIO,value:{total_rtt_measure_out:d.totalRTTMeasurements}},{ssrc:s,type:ee.AUDIO,value:{delta_jitter_ms_out:g}},{ssrc:s,type:ee.AUDIO,value:{timestamp_out:c[q.TIMESTAMP]}},{ssrc:s,type:ee.AUDIO,value:{total_packets_lost_out:v.packetsLost}},{ssrc:s,type:ee.AUDIO,value:{delta_packets_lost_out:v.deltaPacketsLost}},{ssrc:s,type:ee.AUDIO,value:{percent_packets_lost_out:v.fractionLost}}]}if(c[q.KIND]===k.VIDEO){const d=Jf(c,k.VIDEO,h,p),g=to(c,k.VIDEO,p),v=Qf(c,k.VIDEO,p,h);return[{ssrc:s,type:ee.VIDEO,value:{delta_rtt_ms_out:d.rtt}},{ssrc:s,type:ee.VIDEO,value:{total_rtt_ms_out:d.totalRTT}},{ssrc:s,type:ee.VIDEO,value:{total_rtt_measure_out:d.totalRTTMeasurements}},{ssrc:s,type:ee.VIDEO,value:{delta_jitter_ms_out:g}},{ssrc:s,type:ee.VIDEO,value:{timestamp_out:c[q.TIMESTAMP]}},{ssrc:s,type:ee.VIDEO,value:{total_packets_lost_out:v.packetsLost}},{ssrc:s,type:ee.VIDEO,value:{delta_packets_lost_out:v.deltaPacketsLost}},{ssrc:s,type:ee.VIDEO,value:{percent_packets_lost_out:v.fractionLost}}]}break}}return[]},so=c=>c<0?1:c>100?4.5:1+.035*c+7/1e6*c*(c-60)*(100-c),Sv=(c,r=k.AUDIO,n,o,a)=>{const t=lt(a,c,ke.INBOUND),s=lt(a,n,ke.INBOUND),p=lt(a,o,ke.INBOUND),h=[],d=[],g=t[r].percent_packets_lost_in,v=t[r].delta_jitter_ms_in,E=s&&s[r].delta_jitter_ms_in||null,S=p&&p[r].delta_jitter_ms_in||null,C=c.data.delta_rtt_connectivity_ms,I=n&&n.data.delta_rtt_connectivity_ms||null,w=o&&o.data.delta_rtt_connectivity_ms||null;C&&h.push(C),I&&h.push(I),w&&h.push(w),v&&d.push(v),n&&E&&d.push(E),o&&S&&d.push(S);const F=h.length>0?As(h):100,L=d.length>0?As(d):10,ie=93.2-g,N=.18*ie*ie-27.9*ie+1126.62,H=(F+L)/2,ve=H-177.3<0?0:1,me=.024*H+.11*(H-177.3)*ve,M=N-me;return so(M)},Cv=(c,r=k.AUDIO,n,o,a)=>{const t=lt(a,c,ke.OUTBOUND),s=lt(a,n,ke.OUTBOUND),p=lt(a,o,ke.OUTBOUND),h=[],d=[],g=t[r].percent_packets_lost_out,v=t[r].delta_rtt_ms_out,E=s&&s[r].delta_rtt_ms_out||null,S=p&&p[r].delta_rtt_ms_out||null,C=t[r].delta_jitter_ms_out,I=s&&s[r].delta_jitter_ms_out||null,w=p&&p[r].delta_jitter_ms_out||null,F=c.data.delta_rtt_connectivity_ms,L=n&&n.data.delta_rtt_connectivity_ms||null,ie=o&&o.data.delta_rtt_connectivity_ms||null;v?h.push(v):F&&h.push(F),E?h.push(E):L&&h.push(L),S?h.push(S):ie&&h.push(ie),C&&d.push(C),n&&I&&d.push(I),o&&w&&d.push(w);const N=h.length>0?As(h):100,H=d.length>0?As(d):10,ve=93.2-g,me=.18*ve*ve-27.9*ve+1126.62,M=(N+H)/2,D=M-177.3<0?0:1,j=.024*M+.11*(M-177.3)*D,V=me-j;return so(V)},Av=(c,r=k.AUDIO,n,o,a)=>{const t=lt(a,c,ke.INBOUND),s=lt(a,n,ke.INBOUND),p=lt(a,o,ke.INBOUND),h=[],d=[],g=t[r].percent_packets_lost_in/100,v=t[r].delta_jitter_ms_in,E=s&&s[r].delta_jitter_ms_in||null,S=p&&p[r].delta_jitter_ms_in||null,C=c.data.delta_rtt_connectivity_ms,I=n&&n.data.delta_rtt_connectivity_ms||null,w=o&&o.data.delta_rtt_connectivity_ms||null;C&&h.push(C),I&&h.push(I),w&&h.push(w),v&&d.push(v),s&&E&&d.push(E),p&&S&&d.push(S);const F=h.length>0?As(h):100,L=d.length>0?As(d):10,ie=0,N=19.8,H=29.7,ve=30,me=(F+L)/2+ve,M=me-177.3<0?0:1,D=.024*me+.11*(me-177.3)*M,V=93.2-(ie+N*Math.log(1+H*g)+D);return so(V)},Rv=(c,r=k.AUDIO,n,o,a)=>{const t=lt(a,c,ke.OUTBOUND),s=lt(a,n,ke.OUTBOUND),p=lt(a,o,ke.OUTBOUND),h=[],d=[],g=t[r].percent_packets_lost_out/100,v=t[r].delta_rtt_ms_out,E=s&&s[r].delta_rtt_ms_out||null,S=p&&p[r].delta_rtt_ms_out||null,C=t[r].delta_jitter_ms_out,I=s&&s[r].delta_jitter_ms_out||null,w=p&&p[r].delta_jitter_ms_out||null,F=c.data.delta_rtt_connectivity_ms,L=n&&n.data.delta_rtt_connectivity_ms||null,ie=o&&o.data.delta_rtt_connectivity_ms||null;v?h.push(v):F&&h.push(F),E?h.push(E):L&&h.push(L),S?h.push(S):ie&&h.push(ie),C&&d.push(C),s&&I&&d.push(I),p&&w&&d.push(w);const N=h.length>0?As(h):100,H=d.length>0?As(d):10,ve=0,me=19.8,M=29.7,D=30,j=(N+H)/2+D,V=j-177.3<0?0:1,Y=.024*j+.11*(j-177.3)*V,X=93.2-(ve+me*Math.log(1+M*g)+Y);return so(X)};class Iv{constructor(r,n){this._callbacks={onreport:null,onticket:null},this._id=sv(),this._moduleName=this._id,this._probeId=n,this._config=r,this._exporter=new av(r),this._state=hs.IDLE,this.registerToPCEvents(),Ws(this._moduleName,`new collector created for probe ${this._probeId}`)}analyze(r,n,o,a){const t=(h,d)=>h===k.AUDIO?d===Ft.INBOUND_RTP?{...Bf}:{...Gf}:d===Ft.INBOUND_RTP?{...Kf}:{...Wf},s=Xg(n);s.pname=this._config.pname,s.call_id=this._config.cid,s.user_id=this._config.uid,s.count=n?n.count+1:1;let p=null;return r.forEach(h=>{!p&&h.timestamp&&(p=h.timestamp),yv(h,s,s.pname,a).forEach(g=>{if(g.value&&g.type)if(g.ssrc){let v=s[g.type][g.ssrc];v||(v=t(g.type,h.type),v.ssrc=g.ssrc,s[g.type][g.ssrc]=v),Object.keys(g.value).forEach(E=>{v[E]=g.value[E]})}else Object.keys(g.value).forEach(v=>{s[g.type][v]=g.value[v]})})}),s.timestamp=p,Object.keys(s[k.AUDIO]).forEach(h=>{const d=s[k.AUDIO][h];d.direction===ke.INBOUND?(d.mos_emodel_in=Sv(s,k.AUDIO,n,o,d.ssrc),d.mos_in=Av(s,k.AUDIO,n,o,d.ssrc)):(d.mos_emodel_out=Cv(s,k.AUDIO,n,o,d.ssrc),d.mos_out=Rv(s,k.AUDIO,n,o,d.ssrc))}),s}async takeReferenceStats(){return new Promise((r,n)=>{const o=Date.now();setTimeout(async()=>{try{const a=Date.now()-o,t=Date.now(),s=await this._config.pc.getStats(),p=this.analyze(s,null,null,null),h=Date.now();p.experimental.time_to_measure_ms=h-t,p.experimental.time_to_wait_ms=a,this._exporter.saveReferenceReport(p),Ne(this._moduleName,`got reference report for probe ${this._probeId}`),r()}catch(a){n(a)}},this._config.startAfter)})}async collectStats(){try{if(this._state!==hs.RUNNING||!this._config.pc)return Ne(this._moduleName,`report discarded (too late) for probe ${this._probeId}`),null;const r=Date.now(),n=await this._config.pc.getStats(),o=this.analyze(n,this._exporter.getLastReport(),this._exporter.getBeforeLastReport(),this._exporter.getReferenceReport()),a=Date.now();return o.experimental.time_to_measure_ms=a-r,this._exporter.addReport(o),Ne(this._moduleName,`got report for probe ${this._probeId}#${this._exporter.getReportsNumber()+1}`),this.fireOnReport(o),o}catch(r){return wn(this._moduleName,`got error ${r}`),null}}async start(){Ne(this._moduleName,"starting"),this.state=hs.RUNNING,this._startedTime=this._exporter.start(),Ne(this._moduleName,"started")}async mute(){this.state=hs.MUTED,Ne(this._moduleName,"muted")}async unmute(){this.state=hs.RUNNING,Ne(this._moduleName,"unmuted")}async stop(r){if(Ne(this._moduleName,`stopping${r?" by watchdog":""}...`),this._stoppedTime=this._exporter.stop(),this.state=hs.IDLE,this._config.ticket){const{ticket:n}=this._exporter;this.fireOnTicket(n)}this._exporter.reset(),Ne(this._moduleName,"stopped")}registerCallback(r,n,o){r in this._callbacks?(this._callbacks[r]={callback:n,context:o},Ne(this._moduleName,`registered callback '${r}'`)):wn(this._moduleName,`can't register callback for '${r}' - not found`)}unregisterCallback(r){r in this._callbacks?(this._callbacks[r]=null,delete this._callbacks[r],Ne(this._moduleName,`unregistered callback '${r}'`)):wn(this._moduleName,`can't unregister callback for '${r}' - not found`)}fireOnReport(r){this._callbacks.onreport&&Za(this._callbacks.onreport.callback,this._callbacks.onreport.context,r)}fireOnTicket(r){this._callbacks.onticket&&Za(this._callbacks.onticket.callback,this._callbacks.onticket.context,r)}updateConfig(r){this._config=r,this._exporter.updateConfig(r)}get state(){return this._state}set state(r){this._state=r,Ne(this._moduleName,`state changed to ${r}`)}addCustomEvent(r,n,o,a){this._exporter.addCustomEvent({at:typeof r=="object"?r.toJSON():r,category:n,name:o,description:a})}async registerToPCEvents(){const{pc:r}=this._config;if(navigator.mediaDevices.ondevicechange=async()=>{try{const n=await navigator.mediaDevices.enumerateDevices();this.addCustomEvent(new Date().toJSON(),"device",`${n.length} devices found`,"Media Devices state")}catch{wn(this._moduleName,"can't get devices")}},r){r.oniceconnectionstatechange=()=>{const o=r.iceConnectionState;o===Vr.CONNECTED||o===Vr.COMPLETED?this.addCustomEvent(new Date().toJSON(),"call",o,"ICE connection state"):o===Vr.DISCONNECTED||o===Vr.FAILED?this.addCustomEvent(new Date().toJSON(),"call",o,"ICE connection state"):o===Vr.CLOSED&&this.addCustomEvent(new Date().toJSON(),"call","ended","ICE connection state")},r.onicegatheringstatechange=()=>{const o=r.iceGatheringState;this.addCustomEvent(new Date().toJSON(),"call",o,"ICE gathering state")},r.ontrack=o=>{this.addCustomEvent(new Date().toJSON(),"call",`${o.track.kind}track`,"MediaStreamTrack received")},r.onnegotiationneeded=()=>{this.addCustomEvent(new Date().toJSON(),"call","negotiation","Media changed")};const n=r.getReceivers();if(n&&n.length>0){const o=n[0],{transport:a}=o;if(a){const{iceTransport:t}=a;t&&(t.onselectedcandidatepairchange=()=>{this.addCustomEvent(new Date().toJSON(),"call","transport","Candidates Pair changed")})}}}}}class bv{constructor(r){this._id=r.pname&&r.pname.substr(0,12).padEnd(12," ")||tv(),this._moduleName=this._id,Ws(this._moduleName,"probe created"),this._config=r,this._collector=new Iv(this._config,this._id)}set onreport(r){r?this._collector.registerCallback("onreport",r):this._collector.unregisterCallback("onreport")}set onticket(r){r?this._collector.registerCallback("onticket",r):this._collector.unregisterCallback("onticket")}get id(){return this._id}get pname(){return this._config.pname}get cid(){return this._config.cid}get uid(){return this._config.uid}get state(){return this._collector.state}set state(r){this._collector.state=r}addCustomEvent(r,n,o,a=new Date().toJSON()){this._collector.addCustomEvent(a,n,r,o)}get isRunning(){return this._collector.state===hs.RUNNING}get isIdle(){return this._collector.state===hs.IDLE}updateUserId(r){this._config.uid=r,this._collector.updateConfig(this._config)}updateCallId(r){this._config.cid=r,this._collector.updateConfig(this._config)}start(){if(!this.isIdle){eo(this._moduleName,"probe is already running");return}this._collector.start()}stop(r=!1){this.isRunning&&this._collector.stop(r)}async takeReferenceStats(){return this._collector.takeReferenceStats()}async collectStats(){return this._collector.collectStats()}}const yt="engine ";class wv{constructor(r){this._config=r,this._probes=[],this._startedTime=null,this._callbacks={onresult:null},Ws(yt,`configured for probing every ${this._config.refreshEvery}ms`),Ws(yt,`configured for starting after ${this._config.startAfter}ms`),Ws(yt,`${!this._config.stopAfter||this._config.stopAfter!==-1?`configured for stopped after ${this._config.stopAfter}ms`:"configured for never stopped"}`),Ne(yt,"engine initialized")}get probes(){return this._probes}get isRunning(){return this._probes.some(r=>r.isRunning)}get isIdle(){return this._probes.every(r=>r.isIdle)}addNewProbe(r,n){if(!r)throw new Error("undefined peer connection");const o=Zg(r,n,this._config),a=new bv(o);return this._probes.push(a),Ne(yt,`${this._probes.length} probes registered`),a}removeExistingProbe(r){if(!r)throw new Error("undefined probe");r.state===hs.RUNNING&&r.stop(),this._probes=this._probes.filter(n=>r.id!==n.id)}async start(){const r=()=>{this._probes.forEach(t=>t.start())},n=async()=>Promise.all(this._probes.map(t=>t.takeReferenceStats())),o=()=>this.isIdle?!1:!this._config.stopAfter||this._config.stopAfter<0?!0:Date.now()<this._startedTime+this._config.stopAfter,a=async()=>{const t=Jg(),s=this._probes.filter(p=>p.isRunning);for(const p of s){const h=await p.collectStats();h&&t.probes.push(h),Ne(yt,`got probe ${p.id}`),await Yf(0)}return t.delta_time_to_measure_probes_ms=Ys(t.probes,"experimental","time_to_measure_ms"),t.delta_KBytes_in=Ys(t.probes,"data","delta_KBytes_in"),t.delta_KBytes_out=Ys(t.probes,"data","delta_KBytes_out"),t.delta_kbs_in=Ys(t.probes,"data","delta_kbs_in"),t.delta_kbs_out=Ys(t.probes,"data","delta_kbs_out"),t.total_time_decoded_in=Ys(t.probes,"video","total_time_decoded_in"),t.total_time_encoded_out=Ys(t.probes,"video","total_time_encoded_out"),t};for(Ne(yt,"starting to collect"),r(),Ne(yt,"generating reference reports..."),await n(),Ne(yt,"reference reports generated"),this._startedTime=Date.now();o();)if(Ne(yt,`wait ${this._config.refreshEvery}ms before collecting`),await Yf(this._config.refreshEvery),o()){Ne(yt,"collecting...");const t=Date.now(),s=await a(),p=Date.now();s.delta_time_consumed_to_measure_ms=p-t,this.fireOnReports(s),Ne(yt,"collected")}Ne(yt,"reaching end of the collecting period..."),this.isRunning&&setTimeout(()=>{this.stop()},0)}stop(r){const n=o=>{this._probes.forEach(a=>{a.stop(o)})};Ws(yt,"stop collecting"),n(r)}registerCallback(r,n,o){r in this._callbacks?(this._callbacks[r]={callback:n,context:o},Ne(yt,`registered callback '${r}'`)):wn(yt,`can't register callback for '${r}' - not found`)}unregisterCallback(r){r in this._callbacks?(this._callbacks[r]=null,delete this._callbacks[r],Ne(this._moduleName,`unregistered callback '${r}'`)):wn(this._moduleName,`can't unregister callback for '${r}' - not found`)}fireOnReports(r){this._callbacks.onresult&&r.probes.length>0&&Za(this._callbacks.onresult.callback,this._callbacks.onresult.context,r)}}const Ov="interface ";class Dv{constructor(r){this._config=ev(r),Ws(Ov,`welcome to ${this._config.name} version ${this._config.version}`),Vg(this._config.verbose||!1),this._engine=new wv(this._config)}setupLogLevel(r){jg(r)}get version(){return this._config.version}get name(){return this._config.name}get probes(){return this._engine.probes}createProbe(r,n){return this._engine.addNewProbe(r,n)}startAllProbes(){this._engine.start()}stopAllProbes(){this._engine.stop()}get running(){return this._engine.isRunning}get idle(){return this._engine.isIdle}removeProbe(r){this._engine.removeExistingProbe(r)}set onresult(r){r?this._engine.registerCallback("onresult",r):this._engine.unregisterCallback("onresult")}}class Nv{constructor(r){this.intervals={},this.emitInterval=r.emitInterval||200,this.onChangeFunction=r.onChangeFunction}start(r,n){r&&r.getTracks().length&&requestAnimationFrame(()=>this.beginCalculation(r,n))}stop(r){this.clearVolumeInterval(r)}clearVolumeInterval(r){console.log("clearVolumeInterval",r),clearInterval(this.intervals[r]),delete this.intervals[r]}clearAllIntervals(){Object.keys(this.intervals).forEach(r=>{clearInterval(this.intervals[r])}),this.intervals={}}beginCalculation(r,n){this.clearVolumeInterval(n);const o=Jt.createAnalyser(),a=Jt.createMediaStreamSource(r),t=Jt.createScriptProcessor(2048,1,1);o.smoothingTimeConstant=.8,o.fftSize=1024,a.connect(o),o.connect(t),t.connect(Jt.destination),this.intervals[n]=setInterval(()=>{const s=new Uint8Array(o.frequencyBinCount);o.getByteFrequencyData(s);let p=0;const h=s.length;for(let g=0;g<h;g++)p+=s[g];const d=p/h;this.onChangeFunction(n,d)},this.emitInterval)}}const Uv=it,Pv=Gt(),Ct=new Uv("WebSocketInterface");var kv=class{constructor(r){Ct.debug('new() [url:"%s"]',r),this._url=r,this._sip_uri=null,this._via_transport=null,this._ws=null;const n=Pv.parse(r,"absoluteURI");if(n===-1)throw Ct.warn(`invalid WebSocket URI: ${r}`),new TypeError(`Invalid argument: ${r}`);if(n.scheme!=="wss"&&n.scheme!=="ws")throw Ct.warn(`invalid WebSocket URI scheme: ${n.scheme}`),new TypeError(`Invalid argument: ${r}`);this._sip_uri=`sip:${n.host}${n.port?`:${n.port}`:""};transport=ws`,this._via_transport=n.scheme.toUpperCase()}get via_transport(){return this._via_transport}set via_transport(r){this._via_transport=r.toUpperCase()}get sip_uri(){return this._sip_uri}get url(){return this._url}connect(){if(Ct.debug("connect()"),this.isConnected()){Ct.debug(`WebSocket ${this._url} is already connected`);return}else if(this.isConnecting()){Ct.debug(`WebSocket ${this._url} is connecting`);return}this._ws&&this.disconnect(),Ct.debug(`connecting to WebSocket ${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(r){this._onError(r)}}disconnect(){Ct.debug("disconnect()"),this._ws&&(this._ws.onopen=()=>{},this._ws.onclose=()=>{},this._ws.onmessage=()=>{},this._ws.onerror=()=>{},this._ws.close(),this._ws=null)}send(r){return Ct.debug("send()"),this.isConnected()?(this._ws.send(r),!0):(Ct.warn("unable to send message, WebSocket is not open"),!1)}isConnected(){return this._ws&&this._ws.readyState===this._ws.OPEN}isConnecting(){return this._ws&&this._ws.readyState===this._ws.CONNECTING}_onOpen(){Ct.debug(`WebSocket ${this._url} connected`),this.onconnect()}_onClose({wasClean:r,code:n,reason:o}){Ct.debug(`WebSocket ${this._url} closed`),r===!1&&Ct.debug("WebSocket abrupt disconnection"),this.ondisconnect(!r,n,o)}_onMessage({data:r}){Ct.debug("received WebSocket message"),this.ondata(r)}_onError(r){Ct.warn(`WebSocket ${this._url} error: `,r)}};const eu=sl,Mv=we,xv=us,Lv=ft(),$v=kf,Hv=ls(),Fv=Ta(),qv=Gt(),Vv=kv;vn("JsSIP")("version %s",eu.version);var jv={C:Mv,Exceptions:xv,Utils:Lv,UA:$v,URI:Hv,NameAddrHeader:Fv,WebSocketInterface:Vv,Grammar:qv,debug:vn,get name(){return eu.title},get version(){return eu.version}};const Bv=vt(jv),Gv=["mos_in","codec_in","delta_KBytes_in","delta_kbs_in","delta_jitter_ms_in","delta_packets_lost_in"],Xt={NEW_CALL:"new_call",CALL_CONFIRMED:"confirmed",CALL_FAILED:"failed",CALL_PROGRESS:"progress",CALL_ENDED:"ended"},Kv=0,no={SELECTED_INPUT_DEVICE:"OpensipsJSInputDevice",SELECTED_OUTPUT_DEVICE:"OpensipsJSOutputDevice"};class Wv extends kg{constructor(r,n){const o={...r.configuration,sockets:r.socketInterfaces.map(a=>new Bv.WebSocketInterface(a))};super(o),this.initialized=!1,this.logger=console,this.newRTCSessionEventName="newRTCSession",this.registeredEventName="registered",this.unregisteredEventName="unregistered",this.disconnectedEventName="disconnected",this.connectedEventName="connected",this.newMSRPSessionEventName="newMSRPSession",this.muted=!1,this.isAutoAnswer=!1,this.isDNDEnabled=!1,this.muteWhenJoinEnabled=!1,this.activeRooms={},this.activeCalls={},this.extendedCalls={},this.activeMessages={},this.extendedMessages={},this.msrpHistory={},this.microphoneInputLevelValue=1,this.speakerVolumeValue=1,this.availableMediaDevices=[],this.selectedMediaDevices={input:"default",output:"default"},this.callStatus={},this.callTime={},this.callMetrics={},this.timeIntervals={},this.metricConfig={refreshEvery:1e3},this.activeStreamValue=null,this.initialStreamValue=null,this.isReconnecting=!1,this.listenersList={},this.options=r,this.VUMeter=new Nv({onChangeFunction:this.emitVolumeChange.bind(this)}),n&&Fg(n)&&(this.logger=n)}on(r,n){return super.on(r,n)}off(r,n){return super.off(r,n)}emit(r,n){return super.emit(r,n)}get sipDomain(){return this.options.sipDomain}get sipOptions(){return{...this.options.sipOptions,mediaConstraints:this.getUserMediaConstraints}}get currentActiveRoomId(){return this.currentActiveRoomIdValue}set currentActiveRoomId(r){this.currentActiveRoomIdValue=r,this.emit("currentActiveRoomChanged",r)}get autoAnswer(){return this.isAutoAnswer}get callAddingInProgress(){return this.isCallAddingInProgress}set callAddingInProgress(r){this.isCallAddingInProgress=r,this.emit("callAddingInProgressChanged",r)}get isMSRPInitializing(){return this.isMSRPInitializingValue}get muteWhenJoin(){return this.muteWhenJoinEnabled}get isDND(){return this.isDNDEnabled}get speakerVolume(){return this.speakerVolumeValue}get microphoneInputLevel(){return this.microphoneInputLevelValue}get getActiveCalls(){return this.activeCalls}get hasActiveCalls(){return Object.values(this.extendedCalls).length>0}get getActiveMessages(){return this.activeMessages}get getActiveRooms(){return this.activeRooms}get isMuted(){return this.muted}get getInputDeviceList(){return this.availableMediaDevices.filter(r=>r.kind==="audioinput")}get getOutputDeviceList(){return this.availableMediaDevices.filter(r=>r.kind==="audiooutput")}get getUserMediaConstraints(){return{audio:{deviceId:{exact:this.selectedMediaDevices.input}},video:!1}}get selectedInputDevice(){return this.selectedMediaDevices.input}get selectedOutputDevice(){return this.selectedMediaDevices.output}get activeStream(){return this.activeStreamValue}setAvailableMediaDevices(r){this.availableMediaDevices=r,this.emit("changeAvailableDeviceList",r)}async updateDeviceList(){await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints);const r=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(r)}async initializeMediaDevices(){const r=localStorage.getItem(no.SELECTED_INPUT_DEVICE)||"default",n=localStorage.getItem(no.SELECTED_OUTPUT_DEVICE)||"default";(await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints)).getTracks().forEach(t=>t.stop());const a=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(a),await this.setMicrophone(r),await this.setSpeaker(n),navigator.mediaDevices.addEventListener("devicechange",async()=>{const t=await navigator.mediaDevices.enumerateDevices();this.setAvailableMediaDevices(t)})}setCallTime(r){const n={...r};delete n.callId,this.callTime={...this.callTime,[r.callId]:n},this.emit("changeCallTime",this.callTime)}removeCallTime(r){const n={...this.callTime};delete n[r],this.callTime={...n},this.emit("changeCallTime",this.callTime)}setTimeInterval(r,n){this.timeIntervals={...this.timeIntervals,[r]:n}}removeTimeInterval(r){const n={...this.timeIntervals};clearInterval(n[r]),delete n[r],this.timeIntervals={...n}}stopCallTimer(r){this.removeTimeInterval(r),this.removeCallTime(r)}emitVolumeChange(r,n){this.emit("changeCallVolume",{callId:r,volume:n})}setMetricsConfig(r){this.metricConfig={...this.metricConfig,...r}}sendDTMF(r,n){if(!/^[A-D0-9]+$/g.test(n))throw new Error("Not allowed character in DTMF input");this.extendedCalls[r].sendDTMF(n)}setIsMuted(r){this.muted=r,this.emit("changeIsMuted",r)}processMute(r){const n=this.currentActiveRoomId;this.setIsMuted(r),this.initialStreamValue.getTracks().forEach(o=>o.enabled=!r),this.roomReconfigure(n)}mute(){this.processMute(!0)}unmute(){this.processMute(!1)}async processHold({callId:r,toHold:n,automatic:o}){const a=this.extendedCalls[r];a._automaticHold=o??!1,await new Promise(p=>{const h=()=>{p()};n?a.hold({},h):a.unhold({},h)}),this.updateCall(a);const s=Object.values(this.extendedCalls).filter(p=>p.roomId===this.currentActiveRoomId&&(n?r!==p._id:!0));s.length>1&&await this.doConference(s)}holdCall(r,n=!1){return this.processHold({callId:r,automatic:n,toHold:!0})}unholdCall(r){return this.processHold({callId:r,toHold:!1})}cancelAllOutgoingUnanswered(){Object.values(this.getActiveCalls).filter(r=>r.direction==="outgoing"&&r.status===Kv).forEach(r=>this.terminateCall(r._id))}answerCall(r){const n=this.extendedCalls[r];this.cancelAllOutgoingUnanswered(),n.answer(this.sipOptions),this.updateCall(n),this.setActiveRoom(n.roomId),n.connection.addEventListener("addstream",async o=>{this.triggerAddStream(o,n)})}msrpAnswer(r){const n=this.extendedMessages[r];n.answer(this.sipOptions),this.updateMSRPSession(n)}async moveCall(r,n){this.updateCallStatus({callId:r,isMoving:!0}),await this.processRoomChange({callId:r,roomId:n}),this.updateCallStatus({callId:r,isMoving:!1})}updateCall(r){this.activeCalls[r._id]=Hf(r),this.emit("changeActiveCalls",this.activeCalls)}updateMSRPSession(r){this.activeMessages[r._id]=Ff(r),this.emit("changeActiveMessages",this.activeMessages)}updateRoom(r){const o={...this.activeRooms[r.roomId],...r};this.activeRooms={...this.activeRooms,[r.roomId]:{...o}},this.emit("updateRoom",{room:o,roomList:this.activeRooms})}hasAutoAnswerHeaders(r){const n=/answer-after=0/,a=r.request.getHeader("Call-Info");return a&&n.test(a)}addCall(r,n=!0){this.activeCalls={...this.activeCalls,[r._id]:Hf(r)},this.extendedCalls[r._id]=r,n&&this.emit("changeActiveCalls",this.activeCalls)}addCallStatus(r){this.callStatus={...this.callStatus,[r]:{isMoving:!1,isTransferring:!1,isMerging:!1}},this.emit("changeCallStatus",this.callStatus)}addMMSRPSession(r){this.activeMessages={...this.activeMessages,[r._id]:Ff(r)},this.extendedMessages[r._id]=r,this.emit("changeActiveMessages",this.activeMessages)}addMSRPMessage(r,n){const o=this.msrpHistory[n.id]||[];o.push(r),this.msrpHistory={...this.msrpHistory,[n.id]:[...o]},this.emit("newMSRPMessage",{message:r,session:n})}updateCallStatus(r){const o={...{...this.callStatus[r.callId]}};r.isMoving!==void 0&&(o.isMoving=r.isMoving),r.isTransferring!==void 0&&(o.isTransferring=r.isTransferring),r.isMerging!==void 0&&(o.isMerging=r.isMerging),this.callStatus={...this.callStatus,[r.callId]:{...o}},this.emit("changeCallStatus",this.callStatus)}removeCallStatus(r){const n={...this.callStatus};delete n[r],this.callStatus={...n},this.emit("changeCallStatus",this.callStatus)}addRoom(r){this.activeRooms={...this.activeRooms,[r.roomId]:r},this.emit("addRoom",{room:r,roomList:this.activeRooms})}getActiveStream(){const r=qf(this.initialStreamValue,this.microphoneInputLevel*2);return r.getTracks().forEach(n=>n.enabled=!this.isMuted),this.setActiveStream(r),r}async setMicrophone(r){if(!this.getInputDeviceList.find(({deviceId:o})=>o===r)||(this.setSelectedInputDevice(r),Object.keys(this.getActiveCalls).length===0))return;await this.setupStream();const n=Object.values(this.extendedCalls).filter(o=>o.roomId===this.currentActiveRoomId);n.length===1?Object.values(n).forEach(async o=>{const a=this.getActiveStream();o.connection.getSenders()[0].replaceTrack(a.getTracks()[0]),this.updateCall(o)}):await this.doConference(n)}setActiveStream(r){this.activeStream&&this.stopVUMeter("origin"),this.setupVUMeter(r,"origin"),this.activeStreamValue=r,this.emit("changeActiveStream",r)}async setSpeaker(r){if(!this.getOutputDeviceList.find(({deviceId:a})=>a===r))return;this.setSelectedOutputDevice(r);const n=Object.values(this.extendedCalls);if(n.length===0)return;const o=n.filter(a=>a.roomId===this.currentActiveRoomId);o.length===1?n.forEach(a=>{var t;(t=a.audioTag)==null||t.setSinkId(r),this.updateCall(a)}):await this.doConference(o)}removeRoom(r){const n={...this.activeRooms},o={...n[r]};delete n[r],this.activeRooms={...n},this.emit("removeRoom",{room:o,roomList:this.activeRooms})}deleteRoomIfEmpty(r){r!==void 0&&Object.values(this.extendedCalls).filter(n=>n.roomId===r).length===0&&(this.removeRoom(r),this.currentActiveRoomId===r&&(this.currentActiveRoomId=void 0))}checkInitialized(){if(!this.initialized)throw new Error("[OpenSIPSJS] You must call `start` method first!")}muteReconfigure(r){this.muted?r.mute({audio:!0}):r.unmute({audio:!0})}async roomReconfigure(r){if(r===void 0)return;const n=Object.values(this.extendedCalls).filter(o=>o.roomId===r);if(this.currentActiveRoomId===r?n.forEach(o=>{o.audioTag&&(this.muteReconfigure(o),o.audioTag.muted=!1,this.updateCall(o))}):n.forEach(o=>{o.audioTag&&(o.audioTag.muted=!0,this.updateCall(o))}),n.length===0)this.deleteRoomIfEmpty(r);else if(n.length===1&&this.currentActiveRoomId!==r)n[0].isOnHold().local||await this.holdCall(n[0].id,!0);else if(n.length===1&&this.currentActiveRoomId===r){if(n[0].isOnHold().local&&n[0]._automaticHold&&await this.unholdCall(n[0].id),n[0].connection&&n[0].connection.getSenders()[0]){const o=this.getActiveStream();await n[0].connection.getSenders()[0].replaceTrack(o.getTracks()[0]),this.muteReconfigure(n[0])}}else n.length>1&&await this.doConference(n)}async doConference(r){await $f.forEach(r,async o=>{o._localHold&&await this.unholdCall(o._id)});const n=[];r.forEach(o=>{o!=null&&o.connection.getReceivers().forEach(a=>{n.push(a.track)})}),await $f.forEach(r,async o=>{if(o==null)return;const a=new MediaStream,t=Jt.createMediaStreamDestination();if(o.connection.getReceivers().forEach(s=>{n.forEach(p=>{a.addTrack(s.track),s.track.id!==p.id&&Jt.createMediaStreamSource(new MediaStream([p])).connect(t)})}),r[0].roomId===this.currentActiveRoomId){const s=this.getActiveStream();Jt.createMediaStreamSource(s).connect(t)}o.connection.getSenders()[0]&&(await o.connection.getSenders()[0].replaceTrack(t.stream.getTracks()[0]),this.muteReconfigure(o))})}processCallerMute(r,n){const o=this.extendedCalls[r];o&&o.connection.getReceivers().length&&(o.localMuted=n,o.connection.getReceivers().forEach(a=>{a.track.enabled=!n}),this.updateCall(o))}muteCaller(r){this.processCallerMute(r,!0)}unmuteCaller(r){this.processCallerMute(r,!1)}terminateCall(r){const n=this.extendedCalls[r];n._status!==8&&n.terminate()}messageTerminate(r){const n=this.extendedMessages[r];n._status!==8&&n.terminate()}transferCall(r,n){if(n.toString().length===0)return new Error("Target must be passed");const o=this.extendedCalls[r];if(!o._is_confirmed&&!o._is_canceled){const a=`sip:${n}@${this.sipDomain}`;o.terminate({status_code:302,reason_phrase:"Moved Temporarily",extraHeaders:[`Contact: ${a}`]});return}this.updateCallStatus({callId:r,isTransferring:!0}),o.refer(`sip:${n}@${this.sipDomain}`),this.updateCall(o)}mergeCall(r){const n=Object.values(this.extendedCalls).filter(t=>t.roomId===r);if(n.length!==2)return;const o=n[0],a=n[1];!o||!a||(this.updateCallStatus({callId:o._id,isMerging:!0}),this.updateCallStatus({callId:a._id,isMerging:!0}),o.refer(a.remote_identity.uri.toString(),{replaces:a}),this.updateCall(o))}setDND(r){this.isDNDEnabled=r,this.emit("changeIsDND",r)}startCallTimer(r){const n={callId:r,hours:0,minutes:0,seconds:0,formatted:""};this.setCallTime(n);const o=setInterval(()=>{const a={...this.callTime[r]},t=Mg(a);this.setCallTime({callId:r,...t})},1e3);this.setTimeInterval(r,o)}async setActiveRoom(r){const n=this.currentActiveRoomId;r!==n&&(this.currentActiveRoomId=r,await this.roomReconfigure(n),await this.roomReconfigure(r))}getNewRoomId(){const r=Object.keys(this.activeRooms);return r.length===0?1:parseInt(r.sort()[r.length-1])+1}subscribe(r,n){const a=!this.listenersList[r]||!this.listenersList[r].length?[n]:[...this.listenersList[r],n];this.listenersList={...this.listenersList,[r]:a}}removeIListener(r){const n={...this.listenersList};delete n[r],this.listenersList={...n}}async setupCall(r){var d,g;const n=r.session;if(this.getActiveCalls[n.id]!==void 0)return;const a=this.getNewRoomId(),t={started:new Date,incomingInProgress:!1,roomId:a};n.direction==="incoming"?(this.logger.log("New incoming call from",(g=(d=n._remote_identity)==null?void 0:d._uri)==null?void 0:g._user),t.incomingInProgress=!0,this.subscribe(Xt.CALL_CONFIRMED,v=>{n.id===v.id&&(this.updateRoom({incomingInProgress:!1,roomId:a}),this.startCallTimer(n.id))}),this.subscribe(Xt.CALL_FAILED,v=>{n.id===v.id&&(this.updateRoom({incomingInProgress:!1,roomId:a}),this.deleteRoomIfEmpty(a))})):n.direction==="outgoing"&&this.startCallTimer(n.id);const s=n,p=this.hasAutoAnswerHeaders(r),h=s.direction==="incoming"&&!this.hasActiveCalls&&(p||this.autoAnswer);s.roomId=a,s.localMuted=!1,s.autoAnswer=h,h?this.addCall(s,!1):this.addCall(s),this.addCallStatus(n.id),this.addRoom(t),h&&this.answerCall(s._id)}addMessageSession(r){if(!r._id||this.getActiveMessages[r._id]!==void 0)return;const o=r;this.addMMSRPSession(o)}triggerListener({listenerType:r,session:n,event:o}){const a=this.listenersList[r];!a||!a.length||a.forEach(t=>{t(n,o)})}triggerMSRPListener({listenerType:r,session:n,event:o}){const a=this.listenersList[r];!a||!a.length||a.forEach(t=>{t(n,o)})}removeCall(r){const n={...this.activeCalls};delete n[r],this.activeCalls={...n};const o={...this.extendedCalls};delete o[r],this.extendedCalls={...o},this.emit("changeActiveCalls",this.activeCalls)}removeMMSRPSession(r){const n={...this.activeMessages};delete n[r],this.activeMessages={...n};const o={...this.extendedMessages};delete o[r],this.extendedMessages={...o},this.emit("changeActiveMessages",this.activeMessages)}activeCallListRemove(r){const n=this.extendedCalls[r._id];this.stopVUMeter("origin"),n.connection.getSenders().forEach(a=>{a.track.stop()});const o=n.roomId;this.removeCall(r._id),this.roomReconfigure(o)}activeMessageListRemove(r){this.removeMMSRPSession(r._id)}async newRTCSessionCallback(r){const n=r.session;if(this.isDND){n.terminate({status_code:486,reason_phrase:"Do Not Disturb"});return}if(n.on("ended",o=>{var t,s;this.stopVUMeter(n.id),this.logger.log("Session ended for",(s=(t=n._remote_identity)==null?void 0:t._uri)==null?void 0:s._user),this.triggerListener({listenerType:Xt.CALL_ENDED,session:n,event:o});const a=this.getActiveCalls[n.id];a&&this.activeCallListRemove(a),this.stopCallTimer(n.id),this.removeCallStatus(n.id),this.removeCallMetrics(n.id),Object.keys(this.extendedCalls).length||(this.setIsMuted(!1),this.initialStreamValue.getTracks().forEach(p=>p.stop()),this.initialStreamValue=null)}),n.on("progress",o=>{var a,t;this.logger.log("Session in progress for",(t=(a=n._remote_identity)==null?void 0:a._uri)==null?void 0:t._user),this.triggerListener({listenerType:Xt.CALL_PROGRESS,session:n,event:o})}),n.on("failed",o=>{var t,s;this.stopVUMeter(n.id),this.logger.log("Session failed for",(s=(t=n._remote_identity)==null?void 0:t._uri)==null?void 0:s._user),this.triggerListener({listenerType:Xt.CALL_FAILED,session:n,event:o}),n.id===this.callAddingInProgress&&(this.callAddingInProgress=void 0);const a=this.getActiveCalls[n.id];a&&this.activeCallListRemove(a),this.stopCallTimer(n.id),this.removeCallStatus(n.id),this.removeCallMetrics(n.id),Object.keys(this.extendedCalls).length||(this.setIsMuted(!1),this.initialStreamValue.getTracks().forEach(p=>p.stop()),this.initialStreamValue=null)}),n.on("confirmed",o=>{var a,t;this.logger.log("Session confirmed for",(t=(a=n._remote_identity)==null?void 0:a._uri)==null?void 0:t._user),this.triggerListener({listenerType:Xt.CALL_CONFIRMED,session:n,event:o}),this.updateCall(n),n.id===this.callAddingInProgress&&(this.callAddingInProgress=void 0)}),await this.setupCall(r),n.direction==="outgoing"){const o=this.getActiveCalls[n.id].roomId;this.setActiveRoom(o)}}newMSRPSessionCallback(r){const n=r.session;n.on("ended",o=>{this.triggerMSRPListener({listenerType:Xt.CALL_ENDED,session:n,event:o});const a=this.getActiveMessages[n.id];this.activeMessageListRemove(a)}),n.on("failed",o=>{this.triggerMSRPListener({listenerType:Xt.CALL_FAILED,session:n,event:o});const a=this.getActiveMessages[n.id];this.activeMessageListRemove(a)}),n.on("confirmed",o=>{this.triggerMSRPListener({listenerType:Xt.CALL_CONFIRMED,session:n,event:o}),this.updateMSRPSession(n)}),n.on("newMessage",o=>{this.addMSRPMessage(o,n)}),this.addMessageSession(n)}setInitialized(r){this.initialized=r,this.emit("ready",r)}begin(){if(this.isConnected()){console.error("Connection is already established");return}return this.on(this.registeredEventName,()=>{this.logger.log("Successfully registered to",this.options.socketInterfaces[0]),this.setInitialized(!0)}),this.on(this.unregisteredEventName,()=>{this.logger.log("Unregistered from",this.options.socketInterfaces[0]),this.setInitialized(!1)}),this.on(this.newRTCSessionEventName,this.newRTCSessionCallback.bind(this)),this.on(this.connectedEventName,()=>{this.logger.log("Connected to",this.options.socketInterfaces[0]),this.isReconnecting=!1}),this.on(this.disconnectedEventName,()=>{this.isReconnecting||(this.logger.log("Disconnected from",this.options.socketInterfaces[0]),this.logger.log("Reconnecting to",this.options.socketInterfaces[0]),this.isReconnecting=!0,this.stop(),this.setInitialized(!1),setTimeout(this.start.bind(this),5e3))}),this.on(this.newMSRPSessionEventName,this.newMSRPSessionCallback.bind(this)),this.logger.log("Connecting to",this.options.socketInterfaces[0]),this.start(),this.initializeMediaDevices(),this}setMuteWhenJoin(r){this.muteWhenJoinEnabled=r,this.emit("changeMuteWhenJoin",r)}setMicrophoneSensitivity(r){if(r<0||r>1)throw new Error("Value should be in range from 0 to 1!");this.microphoneInputLevelValue=r,this.roomReconfigure(this.currentActiveRoomId)}setSpeakerVolume(r){this.speakerVolumeValue=r,Object.values(this.extendedCalls).forEach(n=>{n.audioTag&&(n.audioTag.volume=r,this.updateCall(n))})}setAutoAnswer(r){this.isAutoAnswer=r}setSelectedInputDevice(r){localStorage.setItem(no.SELECTED_INPUT_DEVICE,r),this.selectedMediaDevices.input=r,this.emit("changeActiveInputMediaDevice",r)}setSelectedOutputDevice(r){localStorage.setItem(no.SELECTED_OUTPUT_DEVICE,r),this.selectedMediaDevices.output=r,this.emit("changeActiveOutputMediaDevice",r)}setIsMSRPInitializing(r){this.isMSRPInitializingValue=r,this.emit("isMSRPInitializingChanged",r)}setCallMetrics(r){const n={...r};delete n.callId,this.callMetrics={...this.callMetrics,[r.callId]:n},this.emit("changeCallMetrics",this.callMetrics)}removeCallMetrics(r){const n={...this.callMetrics};delete n[r],this.callMetrics={...n},this.emit("changeCallMetrics",this.callMetrics)}getCallQuality(r){const n=new Dv(this.metricConfig),o=n.createProbe(r.connection,{cid:r._id}),a=[];let t;o.onreport=s=>{Object.entries(s.audio).forEach(([d,g])=>{g.direction==="inbound"&&!a.includes(d)&&(a.push(d),t=d)});const p=s.audio[t],h=xg(p,Gv);h.callId=r._id,this.setCallMetrics(n)},this.subscribe(Xt.CALL_ENDED,s=>{s._id===r._id&&n.stopAllProbes()}),n.startAllProbes()}setupVUMeter(r,n){this.VUMeter.start(r,n)}stopVUMeter(r){this.VUMeter.stop(r)}async setupStream(){const r=await navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints);this.initialStreamValue&&(this.initialStreamValue.getTracks().forEach(n=>n.stop()),this.initialStreamValue=null),this.initialStreamValue=r}async triggerAddStream(r,n){this.setIsMuted(this.muteWhenJoin||this.isMuted),this.initialStreamValue||await this.setupStream();const o=qf(this.initialStreamValue,this.microphoneInputLevel*2),a=this.isMuted||this.muteWhenJoin;o.getTracks().forEach(t=>t.enabled=!a),this.setActiveStream(o),await n.connection.getSenders()[0].replaceTrack(o.getTracks()[0]),Hg(r,n,this.selectedOutputDevice,this.speakerVolume),this.setupVUMeter(r.stream,n._id),this.getCallQuality(n),this.updateCall(n)}initCall(r,n){if(this.checkInitialized(),r.length===0)return console.error("Target must be a valid string");this.logger.log(`Calling sip:${r}@${this.sipDomain}...`);const o=this.call(`sip:${r}@${this.sipDomain}`,this.sipOptions);this.callAddingInProgress=o.id,n&&this.currentActiveRoomId!==void 0&&this.processRoomChange({callId:o.id,roomId:this.currentActiveRoomId}),o.connection.addEventListener("addstream",a=>{this.triggerAddStream(a,o)})}initMSRP(r,n,o){if(this.checkInitialized(),r.length===0)return console.error("Target must be a valid string");const a=this.startMSRP(r,o);a.on("active",()=>{this.addMessageSession(a),a.sendMSRP(n),this.setIsMSRPInitializing(!1)}),this.setIsMSRPInitializing(!0)}sendMSRP(r,n){const o=this.extendedMessages[r];if(!o)throw new Error(`MSRP session with id ${r} doesn't exist!`);o.sendMSRP(n)}async processRoomChange({callId:r,roomId:n}){const o=this.extendedCalls[r].roomId;this.extendedCalls[r].roomId=n;const a=this.extendedCalls[r];return this.updateCall(a),await this.setActiveRoom(n),Promise.all([this.roomReconfigure(o),this.roomReconfigure(n)]).then(()=>{this.deleteRoomIfEmpty(o),this.deleteRoomIfEmpty(n)})}}return Wv});
|